@sjawhar/claude-envoy 5.5.0 → 5.6.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/dispatch.js CHANGED
@@ -1581,1741 +1581,1072 @@ function consumeMarker(stores, argv, args, files, now) {
1581
1581
  why: mismatched ? "its arguments differ from the ones AskGate reviewed" : expired ? "its AskGate marker expired before it ran" : "this call carries no AskGate marker"
1582
1582
  };
1583
1583
  }
1584
-
1585
- // ../envoy-client/src/askgate-new-asks.ts
1586
- var OPENING_CODE_POINTS = 60;
1587
- function newAsks(toolName, input) {
1588
- switch (toolName) {
1589
- case "dispatch_ask":
1590
- return [questionAsk(input)];
1591
- case "dispatch_issue":
1592
- return typeof input.spec === "string" ? askBlocks(input.spec) : [];
1593
- case "dispatch_artifact":
1594
- return typeof input.content === "string" ? askBlocks(input.content) : [];
1595
- case "dispatch_doc_edit":
1596
- return editOps(input).flatMap((op) => {
1597
- const { op: kind, markdown, with: replacement, type, block } = op;
1598
- if (kind === "insert" && typeof markdown === "string") {
1599
- return scanAsks(markdown, op.before === "start" || op.after === "start");
1600
- }
1601
- if (kind === "replace" && typeof replacement === "string") {
1602
- return replacementAsks(replacement);
1603
- }
1604
- if (kind === "retype" && type === "ask" && typeof block === "string") {
1605
- return [{ kind: "retype", id: block, text: "", opening: "" }];
1606
- }
1607
- return [];
1584
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/core.js
1585
+ var NEVER = Object.freeze({
1586
+ status: "aborted"
1587
+ });
1588
+ function $constructor(name, initializer, params) {
1589
+ function init(inst, def) {
1590
+ if (!inst._zod) {
1591
+ Object.defineProperty(inst, "_zod", {
1592
+ value: {
1593
+ def,
1594
+ constr: _,
1595
+ traits: new Set
1596
+ },
1597
+ enumerable: false
1608
1598
  });
1609
- default:
1610
- return [];
1599
+ }
1600
+ if (inst._zod.traits.has(name)) {
1601
+ return;
1602
+ }
1603
+ inst._zod.traits.add(name);
1604
+ initializer(inst, def);
1605
+ const proto = _.prototype;
1606
+ const keys = Object.keys(proto);
1607
+ for (let i = 0;i < keys.length; i++) {
1608
+ const k = keys[i];
1609
+ if (!(k in inst)) {
1610
+ inst[k] = proto[k].bind(inst);
1611
+ }
1612
+ }
1611
1613
  }
1612
- }
1613
- function newAskCount(toolName, input) {
1614
- if (toolName !== "dispatch_doc_edit")
1615
- return newAsks(toolName, input).length;
1616
- let count = 0;
1617
- for (const op of editOps(input)) {
1618
- count += op.op === "replace" && typeof op.with === "string" ? Math.max(...replacementReadings(op.with).map((text) => scanAsks(text, false).length)) : newAsks(toolName, { ops: [op] }).length;
1614
+ const Parent = params?.Parent ?? Object;
1615
+
1616
+ class Definition extends Parent {
1619
1617
  }
1620
- return count;
1618
+ Object.defineProperty(Definition, "name", { value: name });
1619
+ function _(def) {
1620
+ var _a;
1621
+ const inst = params?.Parent ? new Definition : this;
1622
+ init(inst, def);
1623
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
1624
+ for (const fn of inst._zod.deferred) {
1625
+ fn();
1626
+ }
1627
+ return inst;
1628
+ }
1629
+ Object.defineProperty(_, "init", { value: init });
1630
+ Object.defineProperty(_, Symbol.hasInstance, {
1631
+ value: (inst) => {
1632
+ if (params?.Parent && inst instanceof params.Parent)
1633
+ return true;
1634
+ return inst?._zod?.traits?.has(name);
1635
+ }
1636
+ });
1637
+ Object.defineProperty(_, "name", { value: name });
1638
+ return _;
1621
1639
  }
1622
- function editOps(input) {
1623
- return (Array.isArray(input.ops) ? input.ops : []).filter((op) => typeof op === "object" && op !== null);
1640
+ var $brand = Symbol("zod_brand");
1641
+
1642
+ class $ZodAsyncError extends Error {
1643
+ constructor() {
1644
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
1645
+ }
1624
1646
  }
1625
- function questionAsk(input) {
1626
- const question = typeof input.question === "string" ? input.question.trim() : "";
1627
- const options = (Array.isArray(input.options) ? input.options : []).flatMap((option) => {
1628
- if (typeof option !== "object" || option === null)
1629
- return [];
1630
- const { label, description } = option;
1631
- return [
1632
- typeof description === "string" && description !== "" ? `- ${String(label ?? "")}: ${description}` : `- ${String(label ?? "")}`
1633
- ];
1634
- });
1635
- return {
1636
- kind: "ask",
1637
- text: options.length === 0 ? question : `${question}
1638
1647
 
1639
- ${options.join(`
1640
- `)}`,
1641
- opening: openingOf(question)
1642
- };
1648
+ class $ZodEncodeError extends Error {
1649
+ constructor(name) {
1650
+ super(`Encountered unidirectional transform during encode: ${name}`);
1651
+ this.name = "ZodEncodeError";
1652
+ }
1643
1653
  }
1644
- function openingOf(text) {
1645
- return Array.from(text.replace(/\s+/g, " ").trim()).slice(0, OPENING_CODE_POINTS).join("");
1654
+ var globalConfig = {};
1655
+ function config(newConfig) {
1656
+ if (newConfig)
1657
+ Object.assign(globalConfig, newConfig);
1658
+ return globalConfig;
1646
1659
  }
1647
- var FRONT_MATTER_FENCE = /^---[ \t]*$/;
1648
- function askBlocks(markdown) {
1649
- return scanAsks(markdown, true);
1660
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/util.js
1661
+ function assertEqual(val) {
1662
+ return val;
1650
1663
  }
1651
- function scanAsks(markdown, frontMatter) {
1652
- let lines = markdown.replace(/\r\n?/g, `
1653
- `).split(`
1654
- `);
1655
- let unclosedFrontMatter = false;
1656
- if (frontMatter && FRONT_MATTER_FENCE.test(lines[0] ?? "")) {
1657
- const close = lines.findIndex((line, index) => index > 0 && FRONT_MATTER_FENCE.test(line));
1658
- if (close === -1)
1659
- unclosedFrontMatter = true;
1660
- else
1661
- lines = lines.slice(close + 1);
1662
- }
1663
- const scan = {
1664
- lines,
1665
- index: 0,
1666
- opened: [],
1667
- drafts: [],
1668
- emptyItemWithBlankLines: false,
1669
- skipList: false,
1670
- unclosedFrontMatter
1671
- };
1672
- const document = {
1673
- kind: "document",
1674
- parent: undefined,
1675
- previous: undefined,
1676
- children: 0,
1677
- last: undefined
1678
- };
1679
- for (const [index, text] of lines.entries()) {
1680
- scan.index = index;
1681
- readLine(scan, document, new Line(text));
1682
- }
1683
- return scan.drafts.map(({ id, lines: body }) => {
1684
- const text = body.join(`
1685
- `).trim();
1686
- return { kind: "block", ...id === undefined ? {} : { id }, text, opening: openingOf(text) };
1687
- });
1664
+ function assertNotEqual(val) {
1665
+ return val;
1688
1666
  }
1689
- function replacementAsks(replacement) {
1690
- const variants = new Map;
1691
- for (const reading of replacementReadings(replacement)) {
1692
- for (const ask of scanAsks(reading, false)) {
1693
- const key = JSON.stringify([ask.id ?? null, ask.text]);
1694
- if (!variants.has(key))
1695
- variants.set(key, ask);
1667
+ function assertIs(_arg) {}
1668
+ function assertNever(_x) {
1669
+ throw new Error("Unexpected value in exhaustive check");
1670
+ }
1671
+ function assert(_) {}
1672
+ function getEnumValues(entries) {
1673
+ const numericValues = Object.values(entries).filter((v) => typeof v === "number");
1674
+ const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
1675
+ return values;
1676
+ }
1677
+ function joinValues(array, separator = "|") {
1678
+ return array.map((val) => stringifyPrimitive(val)).join(separator);
1679
+ }
1680
+ function jsonStringifyReplacer(_, value) {
1681
+ if (typeof value === "bigint")
1682
+ return value.toString();
1683
+ return value;
1684
+ }
1685
+ function cached(getter) {
1686
+ const set = false;
1687
+ return {
1688
+ get value() {
1689
+ if (!set) {
1690
+ const value = getter();
1691
+ Object.defineProperty(this, "value", { value });
1692
+ return value;
1693
+ }
1694
+ throw new Error("cached value already set");
1696
1695
  }
1697
- }
1698
- const found = [...variants.values()];
1699
- const idsWithText = new Set(found.flatMap((ask) => ask.text !== "" && ask.id !== undefined ? [ask.id] : []));
1700
- const anyText = found.some((ask) => ask.text !== "");
1701
- return found.filter((ask) => ask.text !== "" || (ask.id === undefined ? !anyText : !idsWithText.has(ask.id)));
1696
+ };
1702
1697
  }
1703
- function replacementReadings(replacement) {
1704
- const readings = [replacement];
1705
- let text = replacement;
1706
- for (let strip = LEADING_STRIP.exec(text);strip !== null; strip = LEADING_STRIP.exec(text)) {
1707
- text = text.slice(strip[0].length);
1708
- readings.push(text);
1709
- }
1710
- return readings;
1698
+ function nullish(input) {
1699
+ return input === null || input === undefined;
1711
1700
  }
1712
- var LEADING_STRIP = /^(?:[ \t]*(?:#{1,6}|[0-9]{1,9}[.)]|[-*+])[ \t]+|\[[ xX]\][ \t]+)/u;
1713
-
1714
- class Line {
1715
- text;
1716
- #starts;
1717
- #pos = 0;
1718
- #column = 0;
1719
- constructor(text) {
1720
- this.text = text;
1721
- const starts = [0];
1722
- let column = 0;
1723
- for (let index = 0;index < text.length; index++) {
1724
- column += text[index] === "\t" ? 4 - column % 4 : 1;
1725
- starts.push(column);
1701
+ function cleanRegex(source) {
1702
+ const start = source.startsWith("^") ? 1 : 0;
1703
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
1704
+ return source.slice(start, end);
1705
+ }
1706
+ function floatSafeRemainder(val, step) {
1707
+ const valDecCount = (val.toString().split(".")[1] || "").length;
1708
+ const stepString = step.toString();
1709
+ let stepDecCount = (stepString.split(".")[1] || "").length;
1710
+ if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
1711
+ const match = stepString.match(/\d?e-(\d?)/);
1712
+ if (match?.[1]) {
1713
+ stepDecCount = Number.parseInt(match[1]);
1726
1714
  }
1727
- this.#starts = starts;
1728
- }
1729
- get column() {
1730
- return this.#column;
1731
- }
1732
- columnAt(index) {
1733
- return this.#starts[index];
1734
- }
1735
- #afterSpaces(index) {
1736
- let end = index;
1737
- while (end < this.text.length && (this.text[end] === " " || this.text[end] === "\t"))
1738
- end++;
1739
- return end;
1740
- }
1741
- spacesAt(index) {
1742
- return this.columnAt(this.#afterSpaces(index)) - this.columnAt(index);
1743
- }
1744
- indent() {
1745
- const at = this.#afterSpaces(this.#pos);
1746
- return { width: this.columnAt(at) - this.#column, at };
1747
- }
1748
- blank() {
1749
- return this.indent().at === this.text.length;
1750
- }
1751
- skip(columns) {
1752
- this.#column += columns;
1753
- while (this.#pos < this.text.length && this.columnAt(this.#pos + 1) <= this.#column)
1754
- this.#pos++;
1755
- }
1756
- advanceTo(index) {
1757
- this.#pos = index;
1758
- this.#column = this.columnAt(index);
1759
- }
1760
- rest() {
1761
- const start = this.columnAt(this.#pos);
1762
- if (this.#pos < this.text.length && start < this.#column) {
1763
- return " ".repeat(this.columnAt(this.#pos + 1) - this.#column) + this.text.slice(this.#pos + 1);
1764
- }
1765
- return this.text.slice(this.#pos);
1766
1715
  }
1716
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
1717
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
1718
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
1719
+ return valInt % stepInt / 10 ** decCount;
1767
1720
  }
1768
- function readLine(scan, document, line) {
1769
- if (scan.opened.length === 0) {
1770
- if (!line.blank())
1771
- openBlocks(scan, document, line);
1772
- return;
1773
- }
1774
- const opened = [...scan.opened];
1775
- const lastIndex = opened.length - 1;
1776
- for (const [index, block] of opened.entries()) {
1777
- if (block.kind !== "paragraph") {
1778
- const continuation = continueBlock(scan, block, line);
1779
- if (continuation === "children" && index === lastIndex) {
1780
- openBlocks(scan, block, line);
1721
+ var EVALUATING = Symbol("evaluating");
1722
+ function defineLazy(object, key, getter) {
1723
+ let value = undefined;
1724
+ Object.defineProperty(object, key, {
1725
+ get() {
1726
+ if (value === EVALUATING) {
1781
1727
  return;
1782
1728
  }
1783
- if (continuation !== "close")
1784
- continue;
1785
- }
1786
- if (openBlocks(scan, opened[index - 1] ?? document, line) !== "paragraph") {
1787
- scan.opened.splice(index, lastIndex - index + 1);
1788
- }
1789
- return;
1729
+ if (value === undefined) {
1730
+ value = EVALUATING;
1731
+ value = getter();
1732
+ }
1733
+ return value;
1734
+ },
1735
+ set(v) {
1736
+ Object.defineProperty(object, key, {
1737
+ value: v
1738
+ });
1739
+ },
1740
+ configurable: true
1741
+ });
1742
+ }
1743
+ function objectClone(obj) {
1744
+ return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
1745
+ }
1746
+ function assignProp(target, prop, value) {
1747
+ Object.defineProperty(target, prop, {
1748
+ value,
1749
+ writable: true,
1750
+ enumerable: true,
1751
+ configurable: true
1752
+ });
1753
+ }
1754
+ function mergeDefs(...defs) {
1755
+ const mergedDescriptors = {};
1756
+ for (const def of defs) {
1757
+ const descriptors = Object.getOwnPropertyDescriptors(def);
1758
+ Object.assign(mergedDescriptors, descriptors);
1790
1759
  }
1760
+ return Object.defineProperties({}, mergedDescriptors);
1791
1761
  }
1792
- function openBlocks(scan, parent, line) {
1793
- const continuable = scan.opened.at(-1)?.kind === "paragraph";
1794
- let result = "none";
1795
- for (let into = parent;; ) {
1796
- const { width, at } = line.indent();
1797
- if (at === line.text.length)
1798
- break;
1799
- const char = line.text.charAt(at);
1800
- const interrupting = continuable && result === "none";
1801
- let opened;
1802
- for (const parser of BLOCK_PARSERS) {
1803
- if (parser.triggers !== undefined && !parser.triggers.includes(char))
1804
- continue;
1805
- if (interrupting && !parser.interrupts)
1806
- continue;
1807
- if (width > 3 && !parser.indented)
1808
- continue;
1809
- opened = parser.open(scan, into, line, width, at);
1810
- if (opened !== undefined)
1811
- break;
1762
+ function cloneDef(schema) {
1763
+ return mergeDefs(schema._zod.def);
1764
+ }
1765
+ function getElementAtPath(obj, path) {
1766
+ if (!path)
1767
+ return obj;
1768
+ return path.reduce((acc, key) => acc?.[key], obj);
1769
+ }
1770
+ function promiseAllObject(promisesObj) {
1771
+ const keys = Object.keys(promisesObj);
1772
+ const promises = keys.map((key) => promisesObj[key]);
1773
+ return Promise.all(promises).then((results) => {
1774
+ const resolvedObj = {};
1775
+ for (let i = 0;i < keys.length; i++) {
1776
+ resolvedObj[keys[i]] = results[i];
1812
1777
  }
1813
- if (opened === undefined)
1814
- break;
1815
- into.children++;
1816
- into.last = opened.block;
1817
- scan.opened.push(opened.block);
1818
- result = "opened";
1819
- if (!opened.children)
1820
- break;
1821
- into = opened.block;
1822
- }
1823
- const last = scan.opened.at(-1);
1824
- if (result === "none" && last?.kind === "paragraph" && !line.blank()) {
1825
- last.rows.push(line.rest());
1826
- last.lastLine = scan.index;
1827
- line.advanceTo(line.text.length);
1828
- return "paragraph";
1778
+ return resolvedObj;
1779
+ });
1780
+ }
1781
+ function randomString(length = 10) {
1782
+ const chars = "abcdefghijklmnopqrstuvwxyz";
1783
+ let str = "";
1784
+ for (let i = 0;i < length; i++) {
1785
+ str += chars[Math.floor(Math.random() * chars.length)];
1829
1786
  }
1830
- return result;
1787
+ return str;
1831
1788
  }
1832
- function under(parent) {
1833
- return { parent, previous: parent.last, children: 0, last: undefined };
1789
+ function esc(str) {
1790
+ return JSON.stringify(str);
1834
1791
  }
1835
- function leafAt(parent, line) {
1836
- line.advanceTo(line.text.length);
1837
- return { block: { kind: "leaf", ...under(parent) }, children: false };
1792
+ function slugify(input) {
1793
+ return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
1838
1794
  }
1839
- function frontMatterHolds(scan, parent) {
1840
- return scan.unclosedFrontMatter && parent.kind === "document";
1795
+ var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
1796
+ function isObject(data) {
1797
+ return typeof data === "object" && data !== null && !Array.isArray(data);
1841
1798
  }
1842
- var BLOCK_PARSERS = [
1843
- {
1844
- triggers: "-=",
1845
- interrupts: true,
1846
- indented: false,
1847
- open(scan, parent, line, _width, at) {
1848
- const last = scan.opened.at(-1);
1849
- if (last?.kind !== "paragraph" || last.parent !== parent)
1850
- return;
1851
- return setextUnderline(line.text.slice(at)) ? leafAt(parent, line) : undefined;
1799
+ var allowsEval = cached(() => {
1800
+ if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
1801
+ return false;
1802
+ }
1803
+ try {
1804
+ const F = Function;
1805
+ new F("");
1806
+ return true;
1807
+ } catch (_) {
1808
+ return false;
1809
+ }
1810
+ });
1811
+ function isPlainObject(o) {
1812
+ if (isObject(o) === false)
1813
+ return false;
1814
+ const ctor = o.constructor;
1815
+ if (ctor === undefined)
1816
+ return true;
1817
+ if (typeof ctor !== "function")
1818
+ return true;
1819
+ const prot = ctor.prototype;
1820
+ if (isObject(prot) === false)
1821
+ return false;
1822
+ if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
1823
+ return false;
1824
+ }
1825
+ return true;
1826
+ }
1827
+ function shallowClone(o) {
1828
+ if (isPlainObject(o))
1829
+ return { ...o };
1830
+ if (Array.isArray(o))
1831
+ return [...o];
1832
+ return o;
1833
+ }
1834
+ function numKeys(data) {
1835
+ let keyCount = 0;
1836
+ for (const key in data) {
1837
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
1838
+ keyCount++;
1852
1839
  }
1853
- },
1854
- {
1855
- triggers: "-*_",
1856
- interrupts: true,
1857
- indented: false,
1858
- open: (_scan, parent, line, _width, at) => thematicBreak(line.text.slice(at)) ? leafAt(parent, line) : undefined
1859
- },
1860
- {
1861
- triggers: "-+*0123456789",
1862
- interrupts: true,
1863
- indented: false,
1864
- open(scan, parent, line) {
1865
- const last = scan.opened.at(-1);
1866
- if (last?.kind === "list" || scan.skipList) {
1867
- scan.skipList = false;
1868
- return;
1840
+ }
1841
+ return keyCount;
1842
+ }
1843
+ var getParsedType = (data) => {
1844
+ const t = typeof data;
1845
+ switch (t) {
1846
+ case "undefined":
1847
+ return "undefined";
1848
+ case "string":
1849
+ return "string";
1850
+ case "number":
1851
+ return Number.isNaN(data) ? "nan" : "number";
1852
+ case "boolean":
1853
+ return "boolean";
1854
+ case "function":
1855
+ return "function";
1856
+ case "bigint":
1857
+ return "bigint";
1858
+ case "symbol":
1859
+ return "symbol";
1860
+ case "object":
1861
+ if (Array.isArray(data)) {
1862
+ return "array";
1869
1863
  }
1870
- const marker = listMarker(line);
1871
- if (marker === undefined || frontMatterHolds(scan, parent))
1872
- return;
1873
- if (marker.empty || marker.number !== undefined && marker.number !== "1") {
1874
- if (last?.kind === "paragraph" && last.parent === parent)
1875
- return;
1876
- if (interruptsOpenBlock(scan, parent))
1877
- return;
1864
+ if (data === null) {
1865
+ return "null";
1878
1866
  }
1879
- scan.emptyItemWithBlankLines = false;
1880
- return { block: { kind: "list", marker: marker.char, ...under(parent) }, children: true };
1881
- }
1882
- },
1883
- {
1884
- triggers: "-+*0123456789",
1885
- interrupts: true,
1886
- indented: false,
1887
- open(scan, parent, line) {
1888
- if (parent.kind !== "list")
1889
- return;
1890
- const previous = parent.last?.kind === "item" ? parent.last.offset : 0;
1891
- const marker = listMarker(line);
1892
- if (marker === undefined || marker.indent - previous > 3)
1893
- return;
1894
- scan.emptyItemWithBlankLines = false;
1895
- const after = line.spacesAt(marker.end);
1896
- const spacing = marker.empty || after > 4 ? 1 : after;
1897
- const offset = line.columnAt(marker.end) - line.column + spacing;
1898
- const item = { kind: "item", offset, ...under(parent) };
1899
- if (marker.empty)
1900
- return { block: item, children: false };
1901
- line.advanceTo(marker.end);
1902
- line.skip(spacing);
1903
- return { block: item, children: true };
1904
- }
1905
- },
1906
- {
1907
- interrupts: false,
1908
- indented: true,
1909
- open(scan, parent, line, width) {
1910
- if (width < 4)
1911
- return;
1912
- line.skip(4);
1913
- const previous = scan.lines[scan.index - 1];
1914
- const block = {
1915
- kind: "code",
1916
- lastLine: scan.index,
1917
- blankBefore: previous === undefined || /^[ \t]*$/.test(previous),
1918
- ...under(parent)
1919
- };
1920
- return { block, children: false };
1921
- }
1922
- },
1923
- {
1924
- triggers: "#",
1925
- interrupts: true,
1926
- indented: false,
1927
- open: (_scan, parent, line, _width, at) => /^#{1,6}(?:[ \t]|$)/.test(line.text.slice(at)) ? leafAt(parent, line) : undefined
1928
- },
1929
- {
1930
- triggers: "`~",
1931
- interrupts: true,
1932
- indented: false,
1933
- open(_scan, parent, line, _width, at) {
1934
- const char = line.text.charAt(at);
1935
- const length = runOf(line.text, at, char);
1936
- if (length < 3)
1937
- return;
1938
- if (char === "`" && line.text.slice(at + length).includes("`"))
1939
- return;
1940
- line.advanceTo(line.text.length);
1941
- return { block: { kind: "fence", char, length, ...under(parent) }, children: false };
1942
- }
1943
- },
1944
- {
1945
- triggers: ">",
1946
- interrupts: true,
1947
- indented: false,
1948
- open: (scan, parent, line) => !frontMatterHolds(scan, parent) && quoteMarker(line) ? { block: { kind: "quote", ...under(parent) }, children: true } : undefined
1949
- },
1950
- {
1951
- triggers: ":",
1952
- interrupts: true,
1953
- indented: false,
1954
- open: (_scan, parent, line, _width, at) => refusedDirective(line.text.slice(at)) ? leafAt(parent, line) : undefined
1955
- },
1956
- {
1957
- triggers: ":",
1958
- interrupts: true,
1959
- indented: false,
1960
- open(scan, parent, line, width, at) {
1961
- const opener = typedOpener(line.text.slice(at));
1962
- if (opener === undefined)
1963
- return;
1964
- let draft;
1965
- if (opener.name === "ask") {
1966
- draft = { id: opener.id, lines: [] };
1967
- scan.drafts.push(draft);
1867
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
1868
+ return "promise";
1968
1869
  }
1969
- line.advanceTo(line.text.length);
1970
- const block = {
1971
- kind: "typed",
1972
- fence: opener.colons,
1973
- indent: width,
1974
- draft,
1975
- ...under(parent)
1976
- };
1977
- return { block, children: true };
1978
- }
1979
- },
1980
- {
1981
- triggers: "[",
1982
- interrupts: true,
1983
- indented: false,
1984
- open(scan, parent, line, _width, at) {
1985
- const definition = /^\[\^([^\]]*)\]:/.exec(line.text.slice(at));
1986
- if (definition === null || /^\s*$/.test(definition[1] ?? ""))
1987
- return;
1988
- if (frontMatterHolds(scan, parent))
1989
- return;
1990
- const label = at + definition[0].length;
1991
- const content = line.text.slice(label).search(/[^ \t]/);
1992
- line.advanceTo(content < 0 ? label : label + content);
1993
- return { block: { kind: "footnote", ...under(parent) }, children: true };
1994
- }
1995
- },
1996
- {
1997
- interrupts: false,
1998
- indented: false,
1999
- open: (scan, parent, line) => {
2000
- const block = {
2001
- kind: "paragraph",
2002
- rows: [line.rest()],
2003
- lastLine: scan.index,
2004
- ...under(parent)
2005
- };
2006
- line.advanceTo(line.text.length);
2007
- return { block, children: false };
2008
- }
2009
- }
2010
- ];
2011
- function interruptsOpenBlock(scan, parent) {
2012
- let previous = parent.last;
2013
- const opensContainers = previous === undefined;
2014
- let node = parent;
2015
- while (previous === undefined && node !== undefined && node.kind !== "document") {
2016
- previous = node.previous;
2017
- node = node.parent;
2018
- }
2019
- if (previous?.kind === "paragraph") {
2020
- return opensContainers && !previous.rows.slice(1).some((row) => TABLE_DELIMITER_ROW.test(row)) && scan.index - previous.lastLine <= 1;
2021
- }
2022
- if (previous?.kind !== "code")
2023
- return false;
2024
- if (previous.previous?.kind === "list")
2025
- return false;
2026
- if (previous.previous?.kind === "quote" && !previous.blankBefore)
2027
- return false;
2028
- return scan.lines.slice(previous.lastLine + 1, scan.index).every((row) => /^[ \t>]*$/.test(row));
2029
- }
2030
- var TABLE_DELIMITER_ROW = /^(?=.*\|)[ \t]*\|?[ \t]*:?-+:?[ \t]*(?:\|[ \t]*:?-+:?[ \t]*)*\|?[ \t]*$/;
2031
- function continueBlock(scan, block, line) {
2032
- switch (block.kind) {
2033
- case "quote":
2034
- return quoteMarker(line) ? "children" : "close";
2035
- case "list":
2036
- return continueList(scan, block, line);
2037
- case "item":
2038
- return continueItem(scan, block, line);
2039
- case "footnote": {
2040
- if (line.blank())
2041
- return "children";
2042
- const { width } = line.indent();
2043
- if (width < 4)
2044
- return "close";
2045
- line.skip(4);
2046
- return "children";
2047
- }
2048
- case "typed": {
2049
- const { width, at } = line.indent();
2050
- if (width < 4 && at < line.text.length && fenceColons(line.text.slice(at)) >= block.fence) {
2051
- line.advanceTo(line.text.length);
2052
- return "close";
1870
+ if (typeof Map !== "undefined" && data instanceof Map) {
1871
+ return "map";
2053
1872
  }
2054
- if (at < line.text.length)
2055
- line.skip(Math.min(width, block.indent));
2056
- block.draft?.lines.push(line.rest());
2057
- return "children";
2058
- }
2059
- case "fence": {
2060
- const { width, at } = line.indent();
2061
- if (width < 4) {
2062
- const length = runOf(line.text, at, block.char);
2063
- if (length >= block.length && /^[ \t]*$/.test(line.text.slice(at + length))) {
2064
- line.advanceTo(line.text.length);
2065
- return "close";
2066
- }
1873
+ if (typeof Set !== "undefined" && data instanceof Set) {
1874
+ return "set";
2067
1875
  }
2068
- line.advanceTo(line.text.length);
2069
- return "continue";
2070
- }
2071
- case "code": {
2072
- if (line.blank())
2073
- return "continue";
2074
- if (line.indent().width < 4)
2075
- return "close";
2076
- block.lastLine = scan.index;
2077
- line.advanceTo(line.text.length);
2078
- return "continue";
2079
- }
1876
+ if (typeof Date !== "undefined" && data instanceof Date) {
1877
+ return "date";
1878
+ }
1879
+ if (typeof File !== "undefined" && data instanceof File) {
1880
+ return "file";
1881
+ }
1882
+ return "object";
2080
1883
  default:
2081
- return block.kind === "document" ? "children" : "close";
1884
+ throw new Error(`Unknown data type: ${t}`);
2082
1885
  }
1886
+ };
1887
+ var propertyKeyTypes = new Set(["string", "number", "symbol"]);
1888
+ var primitiveTypes = new Set(["string", "number", "bigint", "boolean", "symbol", "undefined"]);
1889
+ function escapeRegex(str) {
1890
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2083
1891
  }
2084
- function continueList(scan, list, line) {
2085
- const last = list.last;
2086
- const lastIsEmpty = last === undefined || last.children === 0;
2087
- if (line.blank()) {
2088
- if (lastIsEmpty)
2089
- scan.emptyItemWithBlankLines = true;
2090
- return "children";
1892
+ function clone(inst, def, params) {
1893
+ const cl = new inst._zod.constr(def ?? inst._zod.def);
1894
+ if (!def || params?.parent)
1895
+ cl._zod.parent = inst;
1896
+ return cl;
1897
+ }
1898
+ function normalizeParams(_params) {
1899
+ const params = _params;
1900
+ if (!params)
1901
+ return {};
1902
+ if (typeof params === "string")
1903
+ return { error: () => params };
1904
+ if (params?.message !== undefined) {
1905
+ if (params?.error !== undefined)
1906
+ throw new Error("Cannot specify both `message` and `error` params");
1907
+ params.error = params.message;
2091
1908
  }
2092
- const offset = last?.kind === "item" ? last.offset : 0;
2093
- const { width, at } = line.indent();
2094
- if (width < offset || lastIsEmpty) {
2095
- if (width < 4) {
2096
- const marker = listMarker(line);
2097
- if (marker !== undefined && marker.indent - offset < 4) {
2098
- if (marker.char !== list.marker)
2099
- return "close";
2100
- const fromMarker = line.text.slice(at);
2101
- const heading = scan.opened.at(-1)?.kind === "paragraph" && setextUnderline(fromMarker);
2102
- if (thematicBreak(fromMarker) && !heading)
2103
- return "close";
2104
- return "children";
2105
- }
2106
- }
2107
- if (!lastIsEmpty)
2108
- return "close";
2109
- }
2110
- if (lastIsEmpty && width < offset)
2111
- return "close";
2112
- if (scan.emptyItemWithBlankLines)
2113
- return "close";
2114
- return "children";
1909
+ delete params.message;
1910
+ if (typeof params.error === "string")
1911
+ return { ...params, error: () => params.error };
1912
+ return params;
2115
1913
  }
2116
- function continueItem(scan, item, line) {
2117
- const { width } = line.indent();
2118
- if (line.blank()) {
2119
- line.skip(Math.min(width, item.offset));
2120
- return "children";
2121
- }
2122
- const isEmpty = item.children === 0 && scan.emptyItemWithBlankLines;
2123
- if ((isEmpty || width < item.offset) && width < 4) {
2124
- if (listMarker(line) !== undefined) {
2125
- scan.skipList = true;
2126
- return "close";
1914
+ function createTransparentProxy(getter) {
1915
+ let target;
1916
+ return new Proxy({}, {
1917
+ get(_, prop, receiver) {
1918
+ target ?? (target = getter());
1919
+ return Reflect.get(target, prop, receiver);
1920
+ },
1921
+ set(_, prop, value, receiver) {
1922
+ target ?? (target = getter());
1923
+ return Reflect.set(target, prop, value, receiver);
1924
+ },
1925
+ has(_, prop) {
1926
+ target ?? (target = getter());
1927
+ return Reflect.has(target, prop);
1928
+ },
1929
+ deleteProperty(_, prop) {
1930
+ target ?? (target = getter());
1931
+ return Reflect.deleteProperty(target, prop);
1932
+ },
1933
+ ownKeys(_) {
1934
+ target ?? (target = getter());
1935
+ return Reflect.ownKeys(target);
1936
+ },
1937
+ getOwnPropertyDescriptor(_, prop) {
1938
+ target ?? (target = getter());
1939
+ return Reflect.getOwnPropertyDescriptor(target, prop);
1940
+ },
1941
+ defineProperty(_, prop, descriptor) {
1942
+ target ?? (target = getter());
1943
+ return Reflect.defineProperty(target, prop, descriptor);
2127
1944
  }
2128
- if (!isEmpty)
2129
- return "close";
2130
- }
2131
- line.skip(Math.min(width, item.offset));
2132
- return "children";
2133
- }
2134
- function listMarker(line) {
2135
- const { width, at } = line.indent();
2136
- if (width > 3)
2137
- return;
2138
- const { text } = line;
2139
- const first = text.charAt(at);
2140
- let end = at;
2141
- let number;
2142
- if (first === "-" || first === "*" || first === "+") {
2143
- end = at + 1;
2144
- } else {
2145
- while (end < text.length && end - at <= 9 && /[0-9]/.test(text.charAt(end)))
2146
- end++;
2147
- const delimiter = text.charAt(end);
2148
- if (end === at || end - at > 9 || delimiter !== "." && delimiter !== ")")
2149
- return;
2150
- number = text.slice(at, end);
2151
- end++;
2152
- }
2153
- const after = text.charAt(end);
2154
- if (end < text.length && after !== " " && after !== "\t")
2155
- return;
2156
- return {
2157
- indent: width,
2158
- end,
2159
- char: text.charAt(end - 1),
2160
- number,
2161
- empty: /^[ \t]*$/.test(text.slice(end))
2162
- };
2163
- }
2164
- function quoteMarker(line) {
2165
- const { width, at } = line.indent();
2166
- if (width > 3 || line.text.charAt(at) !== ">")
2167
- return false;
2168
- line.advanceTo(at + 1);
2169
- const next = line.text.charAt(at + 1);
2170
- if (next === " " || next === "\t")
2171
- line.skip(1);
2172
- return true;
2173
- }
2174
- function thematicBreak(text) {
2175
- const marks = text.replace(/[ \t]/g, "");
2176
- return marks.length >= 3 && /^(?:\*+|-+|_+)$/.test(marks);
2177
- }
2178
- function setextUnderline(text) {
2179
- return /^(?:=+|-+)[ \t]*$/.test(text);
2180
- }
2181
- function runOf(text, index, char) {
2182
- let end = index;
2183
- while (text.charAt(end) === char)
2184
- end++;
2185
- return end - index;
2186
- }
2187
- function fenceColons(text) {
2188
- const trimmed = text.replace(/^[ \t]+|[ \t]+$/g, "");
2189
- return /^:+$/.test(trimmed) ? trimmed.length : 0;
1945
+ });
2190
1946
  }
2191
- function nameChar(char) {
2192
- return /^[A-Za-z0-9_-]$/.test(char);
1947
+ function stringifyPrimitive(value) {
1948
+ if (typeof value === "bigint")
1949
+ return value.toString() + "n";
1950
+ if (typeof value === "string")
1951
+ return `"${value}"`;
1952
+ return `${value}`;
2193
1953
  }
2194
- function typedOpener(text) {
2195
- const colons = runOf(text, 0, ":");
2196
- if (colons < 3)
2197
- return;
2198
- const rest = text.slice(colons);
2199
- let nameEnd = 0;
2200
- while (nameEnd < rest.length && nameChar(rest.charAt(nameEnd)))
2201
- nameEnd++;
2202
- if (nameEnd === 0 || rest.charAt(nameEnd) !== "{" || !rest.endsWith("}"))
2203
- return;
2204
- const attributes = directiveAttributes(rest.slice(nameEnd + 1, -1));
2205
- if (attributes === undefined)
2206
- return;
2207
- return { name: rest.slice(0, nameEnd), id: attributes.id, colons };
1954
+ function optionalKeys(shape) {
1955
+ return Object.keys(shape).filter((k) => {
1956
+ return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
1957
+ });
2208
1958
  }
2209
- function refusedDirective(text) {
2210
- if (text.startsWith(":::"))
2211
- return text !== ":::" && typedOpener(text) === undefined;
2212
- if (text.startsWith("::"))
2213
- return text.length > 2 && nameChar(text.charAt(2));
2214
- return text.length > 1 && nameChar(text.charAt(1)) && text.includes("{");
1959
+ var NUMBER_FORMAT_RANGES = {
1960
+ safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
1961
+ int32: [-2147483648, 2147483647],
1962
+ uint32: [0, 4294967295],
1963
+ float32: [-340282346638528860000000000000000000000, 340282346638528860000000000000000000000],
1964
+ float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
1965
+ };
1966
+ var BIGINT_FORMAT_RANGES = {
1967
+ int64: [/* @__PURE__ */ BigInt("-9223372036854775808"), /* @__PURE__ */ BigInt("9223372036854775807")],
1968
+ uint64: [/* @__PURE__ */ BigInt(0), /* @__PURE__ */ BigInt("18446744073709551615")]
1969
+ };
1970
+ function pick(schema, mask) {
1971
+ const currDef = schema._zod.def;
1972
+ const checks = currDef.checks;
1973
+ const hasChecks = checks && checks.length > 0;
1974
+ if (hasChecks) {
1975
+ throw new Error(".pick() cannot be used on object schemas containing refinements");
1976
+ }
1977
+ const def = mergeDefs(schema._zod.def, {
1978
+ get shape() {
1979
+ const newShape = {};
1980
+ for (const key in mask) {
1981
+ if (!(key in currDef.shape)) {
1982
+ throw new Error(`Unrecognized key: "${key}"`);
1983
+ }
1984
+ if (!mask[key])
1985
+ continue;
1986
+ newShape[key] = currDef.shape[key];
1987
+ }
1988
+ assignProp(this, "shape", newShape);
1989
+ return newShape;
1990
+ },
1991
+ checks: []
1992
+ });
1993
+ return clone(schema, def);
2215
1994
  }
2216
- function attributeSpace(char) {
2217
- return char === " " || char >= "\t" && char <= "\r";
1995
+ function omit(schema, mask) {
1996
+ const currDef = schema._zod.def;
1997
+ const checks = currDef.checks;
1998
+ const hasChecks = checks && checks.length > 0;
1999
+ if (hasChecks) {
2000
+ throw new Error(".omit() cannot be used on object schemas containing refinements");
2001
+ }
2002
+ const def = mergeDefs(schema._zod.def, {
2003
+ get shape() {
2004
+ const newShape = { ...schema._zod.def.shape };
2005
+ for (const key in mask) {
2006
+ if (!(key in currDef.shape)) {
2007
+ throw new Error(`Unrecognized key: "${key}"`);
2008
+ }
2009
+ if (!mask[key])
2010
+ continue;
2011
+ delete newShape[key];
2012
+ }
2013
+ assignProp(this, "shape", newShape);
2014
+ return newShape;
2015
+ },
2016
+ checks: []
2017
+ });
2018
+ return clone(schema, def);
2218
2019
  }
2219
- var BLOCK_ID_ATTRIBUTE = "blockId";
2220
- function directiveAttributes(value) {
2221
- const named = new Set;
2222
- let id;
2223
- let offset = 0;
2224
- const name = () => {
2225
- const start = offset;
2226
- while (offset < value.length && nameChar(value.charAt(offset)))
2227
- offset++;
2228
- return value.slice(start, offset);
2229
- };
2230
- while (offset < value.length) {
2231
- while (offset < value.length && attributeSpace(value.charAt(offset)))
2232
- offset++;
2233
- if (offset === value.length)
2234
- break;
2235
- const sigil = value.charAt(offset);
2236
- if (sigil === "#") {
2237
- offset++;
2238
- const read = name();
2239
- if (read === "" || named.has(BLOCK_ID_ATTRIBUTE))
2240
- return;
2241
- named.add(BLOCK_ID_ATTRIBUTE);
2242
- id = read;
2243
- } else if (sigil === ".") {
2244
- offset++;
2245
- if (name() === "")
2246
- return;
2247
- named.add("class");
2248
- } else {
2249
- const key = name();
2250
- if (key === "" || named.has(key))
2251
- return;
2252
- named.add(key);
2253
- if (offset === value.length || value.charAt(offset) === " ")
2254
- continue;
2255
- if (value.charAt(offset) !== "=" || value.charAt(offset + 1) !== '"')
2256
- return;
2257
- offset += 2;
2258
- const start = offset;
2259
- let escaped = false;
2260
- while (offset < value.length && (value.charAt(offset) !== '"' || escaped)) {
2261
- escaped = value.charAt(offset) === "\\" && !escaped;
2262
- offset++;
2020
+ function extend(schema, shape) {
2021
+ if (!isPlainObject(shape)) {
2022
+ throw new Error("Invalid input to extend: expected a plain object");
2023
+ }
2024
+ const checks = schema._zod.def.checks;
2025
+ const hasChecks = checks && checks.length > 0;
2026
+ if (hasChecks) {
2027
+ const existingShape = schema._zod.def.shape;
2028
+ for (const key in shape) {
2029
+ if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) {
2030
+ throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
2263
2031
  }
2264
- if (offset === value.length)
2265
- return;
2266
- const quoted = value.slice(start, offset);
2267
- if (!goQuoted(quoted))
2268
- return;
2269
- if (key === BLOCK_ID_ATTRIBUTE)
2270
- id = /[\\&]/.test(quoted) ? undefined : quoted;
2271
- offset++;
2272
2032
  }
2273
- if (offset < value.length && !attributeSpace(value.charAt(offset)))
2274
- return;
2275
2033
  }
2276
- return { id };
2277
- }
2278
- function goQuoted(body) {
2279
- return /^(?:[^\\\n"]|\\(?:[abfnrtv\\"]|x[0-9A-Fa-f]{2}|[0-3][0-7]{2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8}))*$/.test(body);
2034
+ const def = mergeDefs(schema._zod.def, {
2035
+ get shape() {
2036
+ const _shape = { ...schema._zod.def.shape, ...shape };
2037
+ assignProp(this, "shape", _shape);
2038
+ return _shape;
2039
+ }
2040
+ });
2041
+ return clone(schema, def);
2280
2042
  }
2281
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/core.js
2282
- var NEVER = Object.freeze({
2283
- status: "aborted"
2284
- });
2285
- function $constructor(name, initializer, params) {
2286
- function init(inst, def) {
2287
- if (!inst._zod) {
2288
- Object.defineProperty(inst, "_zod", {
2289
- value: {
2290
- def,
2291
- constr: _,
2292
- traits: new Set
2293
- },
2294
- enumerable: false
2295
- });
2296
- }
2297
- if (inst._zod.traits.has(name)) {
2298
- return;
2299
- }
2300
- inst._zod.traits.add(name);
2301
- initializer(inst, def);
2302
- const proto = _.prototype;
2303
- const keys = Object.keys(proto);
2304
- for (let i = 0;i < keys.length; i++) {
2305
- const k = keys[i];
2306
- if (!(k in inst)) {
2307
- inst[k] = proto[k].bind(inst);
2308
- }
2309
- }
2310
- }
2311
- const Parent = params?.Parent ?? Object;
2312
-
2313
- class Definition extends Parent {
2314
- }
2315
- Object.defineProperty(Definition, "name", { value: name });
2316
- function _(def) {
2317
- var _a;
2318
- const inst = params?.Parent ? new Definition : this;
2319
- init(inst, def);
2320
- (_a = inst._zod).deferred ?? (_a.deferred = []);
2321
- for (const fn of inst._zod.deferred) {
2322
- fn();
2323
- }
2324
- return inst;
2043
+ function safeExtend(schema, shape) {
2044
+ if (!isPlainObject(shape)) {
2045
+ throw new Error("Invalid input to safeExtend: expected a plain object");
2325
2046
  }
2326
- Object.defineProperty(_, "init", { value: init });
2327
- Object.defineProperty(_, Symbol.hasInstance, {
2328
- value: (inst) => {
2329
- if (params?.Parent && inst instanceof params.Parent)
2330
- return true;
2331
- return inst?._zod?.traits?.has(name);
2047
+ const def = mergeDefs(schema._zod.def, {
2048
+ get shape() {
2049
+ const _shape = { ...schema._zod.def.shape, ...shape };
2050
+ assignProp(this, "shape", _shape);
2051
+ return _shape;
2332
2052
  }
2333
2053
  });
2334
- Object.defineProperty(_, "name", { value: name });
2335
- return _;
2054
+ return clone(schema, def);
2336
2055
  }
2337
- var $brand = Symbol("zod_brand");
2338
-
2339
- class $ZodAsyncError extends Error {
2340
- constructor() {
2341
- super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
2342
- }
2056
+ function merge(a, b) {
2057
+ const def = mergeDefs(a._zod.def, {
2058
+ get shape() {
2059
+ const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
2060
+ assignProp(this, "shape", _shape);
2061
+ return _shape;
2062
+ },
2063
+ get catchall() {
2064
+ return b._zod.def.catchall;
2065
+ },
2066
+ checks: []
2067
+ });
2068
+ return clone(a, def);
2343
2069
  }
2344
-
2345
- class $ZodEncodeError extends Error {
2346
- constructor(name) {
2347
- super(`Encountered unidirectional transform during encode: ${name}`);
2348
- this.name = "ZodEncodeError";
2070
+ function partial(Class2, schema, mask) {
2071
+ const currDef = schema._zod.def;
2072
+ const checks = currDef.checks;
2073
+ const hasChecks = checks && checks.length > 0;
2074
+ if (hasChecks) {
2075
+ throw new Error(".partial() cannot be used on object schemas containing refinements");
2349
2076
  }
2077
+ const def = mergeDefs(schema._zod.def, {
2078
+ get shape() {
2079
+ const oldShape = schema._zod.def.shape;
2080
+ const shape = { ...oldShape };
2081
+ if (mask) {
2082
+ for (const key in mask) {
2083
+ if (!(key in oldShape)) {
2084
+ throw new Error(`Unrecognized key: "${key}"`);
2085
+ }
2086
+ if (!mask[key])
2087
+ continue;
2088
+ shape[key] = Class2 ? new Class2({
2089
+ type: "optional",
2090
+ innerType: oldShape[key]
2091
+ }) : oldShape[key];
2092
+ }
2093
+ } else {
2094
+ for (const key in oldShape) {
2095
+ shape[key] = Class2 ? new Class2({
2096
+ type: "optional",
2097
+ innerType: oldShape[key]
2098
+ }) : oldShape[key];
2099
+ }
2100
+ }
2101
+ assignProp(this, "shape", shape);
2102
+ return shape;
2103
+ },
2104
+ checks: []
2105
+ });
2106
+ return clone(schema, def);
2350
2107
  }
2351
- var globalConfig = {};
2352
- function config(newConfig) {
2353
- if (newConfig)
2354
- Object.assign(globalConfig, newConfig);
2355
- return globalConfig;
2108
+ function required(Class2, schema, mask) {
2109
+ const def = mergeDefs(schema._zod.def, {
2110
+ get shape() {
2111
+ const oldShape = schema._zod.def.shape;
2112
+ const shape = { ...oldShape };
2113
+ if (mask) {
2114
+ for (const key in mask) {
2115
+ if (!(key in shape)) {
2116
+ throw new Error(`Unrecognized key: "${key}"`);
2117
+ }
2118
+ if (!mask[key])
2119
+ continue;
2120
+ shape[key] = new Class2({
2121
+ type: "nonoptional",
2122
+ innerType: oldShape[key]
2123
+ });
2124
+ }
2125
+ } else {
2126
+ for (const key in oldShape) {
2127
+ shape[key] = new Class2({
2128
+ type: "nonoptional",
2129
+ innerType: oldShape[key]
2130
+ });
2131
+ }
2132
+ }
2133
+ assignProp(this, "shape", shape);
2134
+ return shape;
2135
+ }
2136
+ });
2137
+ return clone(schema, def);
2356
2138
  }
2357
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/util.js
2358
- function assertEqual(val) {
2359
- return val;
2139
+ function aborted(x, startIndex = 0) {
2140
+ if (x.aborted === true)
2141
+ return true;
2142
+ for (let i = startIndex;i < x.issues.length; i++) {
2143
+ if (x.issues[i]?.continue !== true) {
2144
+ return true;
2145
+ }
2146
+ }
2147
+ return false;
2360
2148
  }
2361
- function assertNotEqual(val) {
2362
- return val;
2149
+ function prefixIssues(path, issues) {
2150
+ return issues.map((iss) => {
2151
+ var _a;
2152
+ (_a = iss).path ?? (_a.path = []);
2153
+ iss.path.unshift(path);
2154
+ return iss;
2155
+ });
2363
2156
  }
2364
- function assertIs(_arg) {}
2365
- function assertNever(_x) {
2366
- throw new Error("Unexpected value in exhaustive check");
2157
+ function unwrapMessage(message) {
2158
+ return typeof message === "string" ? message : message?.message;
2367
2159
  }
2368
- function assert(_) {}
2369
- function getEnumValues(entries) {
2370
- const numericValues = Object.values(entries).filter((v) => typeof v === "number");
2371
- const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
2372
- return values;
2160
+ function finalizeIssue(iss, ctx, config) {
2161
+ const full = { ...iss, path: iss.path ?? [] };
2162
+ if (!iss.message) {
2163
+ const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
2164
+ full.message = message;
2165
+ }
2166
+ delete full.inst;
2167
+ delete full.continue;
2168
+ if (!ctx?.reportInput) {
2169
+ delete full.input;
2170
+ }
2171
+ return full;
2373
2172
  }
2374
- function joinValues(array, separator = "|") {
2375
- return array.map((val) => stringifyPrimitive(val)).join(separator);
2173
+ function getSizableOrigin(input) {
2174
+ if (input instanceof Set)
2175
+ return "set";
2176
+ if (input instanceof Map)
2177
+ return "map";
2178
+ if (input instanceof File)
2179
+ return "file";
2180
+ return "unknown";
2376
2181
  }
2377
- function jsonStringifyReplacer(_, value) {
2378
- if (typeof value === "bigint")
2379
- return value.toString();
2380
- return value;
2182
+ function getLengthableOrigin(input) {
2183
+ if (Array.isArray(input))
2184
+ return "array";
2185
+ if (typeof input === "string")
2186
+ return "string";
2187
+ return "unknown";
2381
2188
  }
2382
- function cached(getter) {
2383
- const set = false;
2384
- return {
2385
- get value() {
2386
- if (!set) {
2387
- const value = getter();
2388
- Object.defineProperty(this, "value", { value });
2389
- return value;
2189
+ function parsedType(data) {
2190
+ const t = typeof data;
2191
+ switch (t) {
2192
+ case "number": {
2193
+ return Number.isNaN(data) ? "nan" : "number";
2194
+ }
2195
+ case "object": {
2196
+ if (data === null) {
2197
+ return "null";
2198
+ }
2199
+ if (Array.isArray(data)) {
2200
+ return "array";
2201
+ }
2202
+ const obj = data;
2203
+ if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) {
2204
+ return obj.constructor.name;
2390
2205
  }
2391
- throw new Error("cached value already set");
2392
2206
  }
2393
- };
2207
+ }
2208
+ return t;
2394
2209
  }
2395
- function nullish(input) {
2396
- return input === null || input === undefined;
2210
+ function issue(...args) {
2211
+ const [iss, input, inst] = args;
2212
+ if (typeof iss === "string") {
2213
+ return {
2214
+ message: iss,
2215
+ code: "custom",
2216
+ input,
2217
+ inst
2218
+ };
2219
+ }
2220
+ return { ...iss };
2397
2221
  }
2398
- function cleanRegex(source) {
2399
- const start = source.startsWith("^") ? 1 : 0;
2400
- const end = source.endsWith("$") ? source.length - 1 : source.length;
2401
- return source.slice(start, end);
2222
+ function cleanEnum(obj) {
2223
+ return Object.entries(obj).filter(([k, _]) => {
2224
+ return Number.isNaN(Number.parseInt(k, 10));
2225
+ }).map((el) => el[1]);
2402
2226
  }
2403
- function floatSafeRemainder(val, step) {
2404
- const valDecCount = (val.toString().split(".")[1] || "").length;
2405
- const stepString = step.toString();
2406
- let stepDecCount = (stepString.split(".")[1] || "").length;
2407
- if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
2408
- const match = stepString.match(/\d?e-(\d?)/);
2409
- if (match?.[1]) {
2410
- stepDecCount = Number.parseInt(match[1]);
2411
- }
2227
+ function base64ToUint8Array(base64) {
2228
+ const binaryString = atob(base64);
2229
+ const bytes = new Uint8Array(binaryString.length);
2230
+ for (let i = 0;i < binaryString.length; i++) {
2231
+ bytes[i] = binaryString.charCodeAt(i);
2412
2232
  }
2413
- const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
2414
- const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
2415
- const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
2416
- return valInt % stepInt / 10 ** decCount;
2233
+ return bytes;
2417
2234
  }
2418
- var EVALUATING = Symbol("evaluating");
2419
- function defineLazy(object, key, getter) {
2420
- let value = undefined;
2421
- Object.defineProperty(object, key, {
2422
- get() {
2423
- if (value === EVALUATING) {
2424
- return;
2425
- }
2426
- if (value === undefined) {
2427
- value = EVALUATING;
2428
- value = getter();
2429
- }
2430
- return value;
2431
- },
2432
- set(v) {
2433
- Object.defineProperty(object, key, {
2434
- value: v
2435
- });
2436
- },
2437
- configurable: true
2438
- });
2235
+ function uint8ArrayToBase64(bytes) {
2236
+ let binaryString = "";
2237
+ for (let i = 0;i < bytes.length; i++) {
2238
+ binaryString += String.fromCharCode(bytes[i]);
2239
+ }
2240
+ return btoa(binaryString);
2439
2241
  }
2440
- function objectClone(obj) {
2441
- return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
2242
+ function base64urlToUint8Array(base64url) {
2243
+ const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/");
2244
+ const padding = "=".repeat((4 - base64.length % 4) % 4);
2245
+ return base64ToUint8Array(base64 + padding);
2442
2246
  }
2443
- function assignProp(target, prop, value) {
2444
- Object.defineProperty(target, prop, {
2445
- value,
2446
- writable: true,
2447
- enumerable: true,
2448
- configurable: true
2449
- });
2247
+ function uint8ArrayToBase64url(bytes) {
2248
+ return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
2450
2249
  }
2451
- function mergeDefs(...defs) {
2452
- const mergedDescriptors = {};
2453
- for (const def of defs) {
2454
- const descriptors = Object.getOwnPropertyDescriptors(def);
2455
- Object.assign(mergedDescriptors, descriptors);
2250
+ function hexToUint8Array(hex) {
2251
+ const cleanHex = hex.replace(/^0x/, "");
2252
+ if (cleanHex.length % 2 !== 0) {
2253
+ throw new Error("Invalid hex string length");
2456
2254
  }
2457
- return Object.defineProperties({}, mergedDescriptors);
2255
+ const bytes = new Uint8Array(cleanHex.length / 2);
2256
+ for (let i = 0;i < cleanHex.length; i += 2) {
2257
+ bytes[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16);
2258
+ }
2259
+ return bytes;
2458
2260
  }
2459
- function cloneDef(schema) {
2460
- return mergeDefs(schema._zod.def);
2261
+ function uint8ArrayToHex(bytes) {
2262
+ return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
2461
2263
  }
2462
- function getElementAtPath(obj, path) {
2463
- if (!path)
2464
- return obj;
2465
- return path.reduce((acc, key) => acc?.[key], obj);
2264
+
2265
+ class Class {
2266
+ constructor(..._args) {}
2466
2267
  }
2467
- function promiseAllObject(promisesObj) {
2468
- const keys = Object.keys(promisesObj);
2469
- const promises = keys.map((key) => promisesObj[key]);
2470
- return Promise.all(promises).then((results) => {
2471
- const resolvedObj = {};
2472
- for (let i = 0;i < keys.length; i++) {
2473
- resolvedObj[keys[i]] = results[i];
2474
- }
2475
- return resolvedObj;
2268
+
2269
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/errors.js
2270
+ var initializer = (inst, def) => {
2271
+ inst.name = "$ZodError";
2272
+ Object.defineProperty(inst, "_zod", {
2273
+ value: inst._zod,
2274
+ enumerable: false
2476
2275
  });
2477
- }
2478
- function randomString(length = 10) {
2479
- const chars = "abcdefghijklmnopqrstuvwxyz";
2480
- let str = "";
2481
- for (let i = 0;i < length; i++) {
2482
- str += chars[Math.floor(Math.random() * chars.length)];
2276
+ Object.defineProperty(inst, "issues", {
2277
+ value: def,
2278
+ enumerable: false
2279
+ });
2280
+ inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
2281
+ Object.defineProperty(inst, "toString", {
2282
+ value: () => inst.message,
2283
+ enumerable: false
2284
+ });
2285
+ };
2286
+ var $ZodError = $constructor("$ZodError", initializer);
2287
+ var $ZodRealError = $constructor("$ZodError", initializer, { Parent: Error });
2288
+ function flattenError(error, mapper = (issue) => issue.message) {
2289
+ const fieldErrors = {};
2290
+ const formErrors = [];
2291
+ for (const sub of error.issues) {
2292
+ if (sub.path.length > 0) {
2293
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
2294
+ fieldErrors[sub.path[0]].push(mapper(sub));
2295
+ } else {
2296
+ formErrors.push(mapper(sub));
2297
+ }
2483
2298
  }
2484
- return str;
2485
- }
2486
- function esc(str) {
2487
- return JSON.stringify(str);
2299
+ return { formErrors, fieldErrors };
2488
2300
  }
2489
- function slugify(input) {
2490
- return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
2301
+ function formatError(error, mapper = (issue) => issue.message) {
2302
+ const fieldErrors = { _errors: [] };
2303
+ const processError = (error) => {
2304
+ for (const issue of error.issues) {
2305
+ if (issue.code === "invalid_union" && issue.errors.length) {
2306
+ issue.errors.map((issues) => processError({ issues }));
2307
+ } else if (issue.code === "invalid_key") {
2308
+ processError({ issues: issue.issues });
2309
+ } else if (issue.code === "invalid_element") {
2310
+ processError({ issues: issue.issues });
2311
+ } else if (issue.path.length === 0) {
2312
+ fieldErrors._errors.push(mapper(issue));
2313
+ } else {
2314
+ let curr = fieldErrors;
2315
+ let i = 0;
2316
+ while (i < issue.path.length) {
2317
+ const el = issue.path[i];
2318
+ const terminal = i === issue.path.length - 1;
2319
+ if (!terminal) {
2320
+ curr[el] = curr[el] || { _errors: [] };
2321
+ } else {
2322
+ curr[el] = curr[el] || { _errors: [] };
2323
+ curr[el]._errors.push(mapper(issue));
2324
+ }
2325
+ curr = curr[el];
2326
+ i++;
2327
+ }
2328
+ }
2329
+ }
2330
+ };
2331
+ processError(error);
2332
+ return fieldErrors;
2491
2333
  }
2492
- var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
2493
- function isObject(data) {
2494
- return typeof data === "object" && data !== null && !Array.isArray(data);
2334
+ function treeifyError(error, mapper = (issue) => issue.message) {
2335
+ const result = { errors: [] };
2336
+ const processError = (error, path = []) => {
2337
+ var _a, _b;
2338
+ for (const issue of error.issues) {
2339
+ if (issue.code === "invalid_union" && issue.errors.length) {
2340
+ issue.errors.map((issues) => processError({ issues }, issue.path));
2341
+ } else if (issue.code === "invalid_key") {
2342
+ processError({ issues: issue.issues }, issue.path);
2343
+ } else if (issue.code === "invalid_element") {
2344
+ processError({ issues: issue.issues }, issue.path);
2345
+ } else {
2346
+ const fullpath = [...path, ...issue.path];
2347
+ if (fullpath.length === 0) {
2348
+ result.errors.push(mapper(issue));
2349
+ continue;
2350
+ }
2351
+ let curr = result;
2352
+ let i = 0;
2353
+ while (i < fullpath.length) {
2354
+ const el = fullpath[i];
2355
+ const terminal = i === fullpath.length - 1;
2356
+ if (typeof el === "string") {
2357
+ curr.properties ?? (curr.properties = {});
2358
+ (_a = curr.properties)[el] ?? (_a[el] = { errors: [] });
2359
+ curr = curr.properties[el];
2360
+ } else {
2361
+ curr.items ?? (curr.items = []);
2362
+ (_b = curr.items)[el] ?? (_b[el] = { errors: [] });
2363
+ curr = curr.items[el];
2364
+ }
2365
+ if (terminal) {
2366
+ curr.errors.push(mapper(issue));
2367
+ }
2368
+ i++;
2369
+ }
2370
+ }
2371
+ }
2372
+ };
2373
+ processError(error);
2374
+ return result;
2495
2375
  }
2496
- var allowsEval = cached(() => {
2497
- if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
2498
- return false;
2376
+ function toDotPath(_path) {
2377
+ const segs = [];
2378
+ const path = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
2379
+ for (const seg of path) {
2380
+ if (typeof seg === "number")
2381
+ segs.push(`[${seg}]`);
2382
+ else if (typeof seg === "symbol")
2383
+ segs.push(`[${JSON.stringify(String(seg))}]`);
2384
+ else if (/[^\w$]/.test(seg))
2385
+ segs.push(`[${JSON.stringify(seg)}]`);
2386
+ else {
2387
+ if (segs.length)
2388
+ segs.push(".");
2389
+ segs.push(seg);
2390
+ }
2499
2391
  }
2500
- try {
2501
- const F = Function;
2502
- new F("");
2503
- return true;
2504
- } catch (_) {
2505
- return false;
2392
+ return segs.join("");
2393
+ }
2394
+ function prettifyError(error) {
2395
+ const lines = [];
2396
+ const issues = [...error.issues].sort((a, b) => (a.path ?? []).length - (b.path ?? []).length);
2397
+ for (const issue of issues) {
2398
+ lines.push(`\u2716 ${issue.message}`);
2399
+ if (issue.path?.length)
2400
+ lines.push(` \u2192 at ${toDotPath(issue.path)}`);
2506
2401
  }
2507
- });
2508
- function isPlainObject(o) {
2509
- if (isObject(o) === false)
2510
- return false;
2511
- const ctor = o.constructor;
2512
- if (ctor === undefined)
2513
- return true;
2514
- if (typeof ctor !== "function")
2515
- return true;
2516
- const prot = ctor.prototype;
2517
- if (isObject(prot) === false)
2518
- return false;
2519
- if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
2520
- return false;
2521
- }
2522
- return true;
2523
- }
2524
- function shallowClone(o) {
2525
- if (isPlainObject(o))
2526
- return { ...o };
2527
- if (Array.isArray(o))
2528
- return [...o];
2529
- return o;
2402
+ return lines.join(`
2403
+ `);
2530
2404
  }
2531
- function numKeys(data) {
2532
- let keyCount = 0;
2533
- for (const key in data) {
2534
- if (Object.prototype.hasOwnProperty.call(data, key)) {
2535
- keyCount++;
2536
- }
2405
+
2406
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/parse.js
2407
+ var _parse = (_Err) => (schema, value, _ctx, _params) => {
2408
+ const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
2409
+ const result = schema._zod.run({ value, issues: [] }, ctx);
2410
+ if (result instanceof Promise) {
2411
+ throw new $ZodAsyncError;
2537
2412
  }
2538
- return keyCount;
2539
- }
2540
- var getParsedType = (data) => {
2541
- const t = typeof data;
2542
- switch (t) {
2543
- case "undefined":
2544
- return "undefined";
2545
- case "string":
2546
- return "string";
2547
- case "number":
2548
- return Number.isNaN(data) ? "nan" : "number";
2549
- case "boolean":
2550
- return "boolean";
2551
- case "function":
2552
- return "function";
2553
- case "bigint":
2554
- return "bigint";
2555
- case "symbol":
2556
- return "symbol";
2557
- case "object":
2558
- if (Array.isArray(data)) {
2559
- return "array";
2560
- }
2561
- if (data === null) {
2562
- return "null";
2563
- }
2564
- if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
2565
- return "promise";
2566
- }
2567
- if (typeof Map !== "undefined" && data instanceof Map) {
2568
- return "map";
2569
- }
2570
- if (typeof Set !== "undefined" && data instanceof Set) {
2571
- return "set";
2572
- }
2573
- if (typeof Date !== "undefined" && data instanceof Date) {
2574
- return "date";
2575
- }
2576
- if (typeof File !== "undefined" && data instanceof File) {
2577
- return "file";
2578
- }
2579
- return "object";
2580
- default:
2581
- throw new Error(`Unknown data type: ${t}`);
2413
+ if (result.issues.length) {
2414
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
2415
+ captureStackTrace(e, _params?.callee);
2416
+ throw e;
2582
2417
  }
2418
+ return result.value;
2583
2419
  };
2584
- var propertyKeyTypes = new Set(["string", "number", "symbol"]);
2585
- var primitiveTypes = new Set(["string", "number", "bigint", "boolean", "symbol", "undefined"]);
2586
- function escapeRegex(str) {
2587
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2588
- }
2589
- function clone(inst, def, params) {
2590
- const cl = new inst._zod.constr(def ?? inst._zod.def);
2591
- if (!def || params?.parent)
2592
- cl._zod.parent = inst;
2593
- return cl;
2594
- }
2595
- function normalizeParams(_params) {
2596
- const params = _params;
2597
- if (!params)
2598
- return {};
2599
- if (typeof params === "string")
2600
- return { error: () => params };
2601
- if (params?.message !== undefined) {
2602
- if (params?.error !== undefined)
2603
- throw new Error("Cannot specify both `message` and `error` params");
2604
- params.error = params.message;
2420
+ var parse = /* @__PURE__ */ _parse($ZodRealError);
2421
+ var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
2422
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
2423
+ let result = schema._zod.run({ value, issues: [] }, ctx);
2424
+ if (result instanceof Promise)
2425
+ result = await result;
2426
+ if (result.issues.length) {
2427
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
2428
+ captureStackTrace(e, params?.callee);
2429
+ throw e;
2605
2430
  }
2606
- delete params.message;
2607
- if (typeof params.error === "string")
2608
- return { ...params, error: () => params.error };
2609
- return params;
2610
- }
2611
- function createTransparentProxy(getter) {
2612
- let target;
2613
- return new Proxy({}, {
2614
- get(_, prop, receiver) {
2615
- target ?? (target = getter());
2616
- return Reflect.get(target, prop, receiver);
2617
- },
2618
- set(_, prop, value, receiver) {
2619
- target ?? (target = getter());
2620
- return Reflect.set(target, prop, value, receiver);
2621
- },
2622
- has(_, prop) {
2623
- target ?? (target = getter());
2624
- return Reflect.has(target, prop);
2625
- },
2626
- deleteProperty(_, prop) {
2627
- target ?? (target = getter());
2628
- return Reflect.deleteProperty(target, prop);
2629
- },
2630
- ownKeys(_) {
2631
- target ?? (target = getter());
2632
- return Reflect.ownKeys(target);
2633
- },
2634
- getOwnPropertyDescriptor(_, prop) {
2635
- target ?? (target = getter());
2636
- return Reflect.getOwnPropertyDescriptor(target, prop);
2637
- },
2638
- defineProperty(_, prop, descriptor) {
2639
- target ?? (target = getter());
2640
- return Reflect.defineProperty(target, prop, descriptor);
2641
- }
2642
- });
2643
- }
2644
- function stringifyPrimitive(value) {
2645
- if (typeof value === "bigint")
2646
- return value.toString() + "n";
2647
- if (typeof value === "string")
2648
- return `"${value}"`;
2649
- return `${value}`;
2650
- }
2651
- function optionalKeys(shape) {
2652
- return Object.keys(shape).filter((k) => {
2653
- return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
2654
- });
2655
- }
2656
- var NUMBER_FORMAT_RANGES = {
2657
- safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
2658
- int32: [-2147483648, 2147483647],
2659
- uint32: [0, 4294967295],
2660
- float32: [-340282346638528860000000000000000000000, 340282346638528860000000000000000000000],
2661
- float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
2662
- };
2663
- var BIGINT_FORMAT_RANGES = {
2664
- int64: [/* @__PURE__ */ BigInt("-9223372036854775808"), /* @__PURE__ */ BigInt("9223372036854775807")],
2665
- uint64: [/* @__PURE__ */ BigInt(0), /* @__PURE__ */ BigInt("18446744073709551615")]
2431
+ return result.value;
2666
2432
  };
2667
- function pick(schema, mask) {
2668
- const currDef = schema._zod.def;
2669
- const checks = currDef.checks;
2670
- const hasChecks = checks && checks.length > 0;
2671
- if (hasChecks) {
2672
- throw new Error(".pick() cannot be used on object schemas containing refinements");
2673
- }
2674
- const def = mergeDefs(schema._zod.def, {
2675
- get shape() {
2676
- const newShape = {};
2677
- for (const key in mask) {
2678
- if (!(key in currDef.shape)) {
2679
- throw new Error(`Unrecognized key: "${key}"`);
2680
- }
2681
- if (!mask[key])
2682
- continue;
2683
- newShape[key] = currDef.shape[key];
2684
- }
2685
- assignProp(this, "shape", newShape);
2686
- return newShape;
2687
- },
2688
- checks: []
2689
- });
2690
- return clone(schema, def);
2691
- }
2692
- function omit(schema, mask) {
2693
- const currDef = schema._zod.def;
2694
- const checks = currDef.checks;
2695
- const hasChecks = checks && checks.length > 0;
2696
- if (hasChecks) {
2697
- throw new Error(".omit() cannot be used on object schemas containing refinements");
2698
- }
2699
- const def = mergeDefs(schema._zod.def, {
2700
- get shape() {
2701
- const newShape = { ...schema._zod.def.shape };
2702
- for (const key in mask) {
2703
- if (!(key in currDef.shape)) {
2704
- throw new Error(`Unrecognized key: "${key}"`);
2705
- }
2706
- if (!mask[key])
2707
- continue;
2708
- delete newShape[key];
2709
- }
2710
- assignProp(this, "shape", newShape);
2711
- return newShape;
2712
- },
2713
- checks: []
2714
- });
2715
- return clone(schema, def);
2716
- }
2717
- function extend(schema, shape) {
2718
- if (!isPlainObject(shape)) {
2719
- throw new Error("Invalid input to extend: expected a plain object");
2720
- }
2721
- const checks = schema._zod.def.checks;
2722
- const hasChecks = checks && checks.length > 0;
2723
- if (hasChecks) {
2724
- const existingShape = schema._zod.def.shape;
2725
- for (const key in shape) {
2726
- if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) {
2727
- throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
2728
- }
2729
- }
2433
+ var parseAsync = /* @__PURE__ */ _parseAsync($ZodRealError);
2434
+ var _safeParse = (_Err) => (schema, value, _ctx) => {
2435
+ const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
2436
+ const result = schema._zod.run({ value, issues: [] }, ctx);
2437
+ if (result instanceof Promise) {
2438
+ throw new $ZodAsyncError;
2730
2439
  }
2731
- const def = mergeDefs(schema._zod.def, {
2732
- get shape() {
2733
- const _shape = { ...schema._zod.def.shape, ...shape };
2734
- assignProp(this, "shape", _shape);
2735
- return _shape;
2736
- }
2737
- });
2738
- return clone(schema, def);
2739
- }
2740
- function safeExtend(schema, shape) {
2741
- if (!isPlainObject(shape)) {
2742
- throw new Error("Invalid input to safeExtend: expected a plain object");
2743
- }
2744
- const def = mergeDefs(schema._zod.def, {
2745
- get shape() {
2746
- const _shape = { ...schema._zod.def.shape, ...shape };
2747
- assignProp(this, "shape", _shape);
2748
- return _shape;
2749
- }
2750
- });
2751
- return clone(schema, def);
2752
- }
2753
- function merge(a, b) {
2754
- const def = mergeDefs(a._zod.def, {
2755
- get shape() {
2756
- const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
2757
- assignProp(this, "shape", _shape);
2758
- return _shape;
2759
- },
2760
- get catchall() {
2761
- return b._zod.def.catchall;
2762
- },
2763
- checks: []
2764
- });
2765
- return clone(a, def);
2766
- }
2767
- function partial(Class2, schema, mask) {
2768
- const currDef = schema._zod.def;
2769
- const checks = currDef.checks;
2770
- const hasChecks = checks && checks.length > 0;
2771
- if (hasChecks) {
2772
- throw new Error(".partial() cannot be used on object schemas containing refinements");
2773
- }
2774
- const def = mergeDefs(schema._zod.def, {
2775
- get shape() {
2776
- const oldShape = schema._zod.def.shape;
2777
- const shape = { ...oldShape };
2778
- if (mask) {
2779
- for (const key in mask) {
2780
- if (!(key in oldShape)) {
2781
- throw new Error(`Unrecognized key: "${key}"`);
2782
- }
2783
- if (!mask[key])
2784
- continue;
2785
- shape[key] = Class2 ? new Class2({
2786
- type: "optional",
2787
- innerType: oldShape[key]
2788
- }) : oldShape[key];
2789
- }
2790
- } else {
2791
- for (const key in oldShape) {
2792
- shape[key] = Class2 ? new Class2({
2793
- type: "optional",
2794
- innerType: oldShape[key]
2795
- }) : oldShape[key];
2796
- }
2797
- }
2798
- assignProp(this, "shape", shape);
2799
- return shape;
2800
- },
2801
- checks: []
2802
- });
2803
- return clone(schema, def);
2440
+ return result.issues.length ? {
2441
+ success: false,
2442
+ error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
2443
+ } : { success: true, data: result.value };
2444
+ };
2445
+ var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
2446
+ var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
2447
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
2448
+ let result = schema._zod.run({ value, issues: [] }, ctx);
2449
+ if (result instanceof Promise)
2450
+ result = await result;
2451
+ return result.issues.length ? {
2452
+ success: false,
2453
+ error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
2454
+ } : { success: true, data: result.value };
2455
+ };
2456
+ var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
2457
+ var _encode = (_Err) => (schema, value, _ctx) => {
2458
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
2459
+ return _parse(_Err)(schema, value, ctx);
2460
+ };
2461
+ var encode = /* @__PURE__ */ _encode($ZodRealError);
2462
+ var _decode = (_Err) => (schema, value, _ctx) => {
2463
+ return _parse(_Err)(schema, value, _ctx);
2464
+ };
2465
+ var decode = /* @__PURE__ */ _decode($ZodRealError);
2466
+ var _encodeAsync = (_Err) => async (schema, value, _ctx) => {
2467
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
2468
+ return _parseAsync(_Err)(schema, value, ctx);
2469
+ };
2470
+ var encodeAsync = /* @__PURE__ */ _encodeAsync($ZodRealError);
2471
+ var _decodeAsync = (_Err) => async (schema, value, _ctx) => {
2472
+ return _parseAsync(_Err)(schema, value, _ctx);
2473
+ };
2474
+ var decodeAsync = /* @__PURE__ */ _decodeAsync($ZodRealError);
2475
+ var _safeEncode = (_Err) => (schema, value, _ctx) => {
2476
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
2477
+ return _safeParse(_Err)(schema, value, ctx);
2478
+ };
2479
+ var safeEncode = /* @__PURE__ */ _safeEncode($ZodRealError);
2480
+ var _safeDecode = (_Err) => (schema, value, _ctx) => {
2481
+ return _safeParse(_Err)(schema, value, _ctx);
2482
+ };
2483
+ var safeDecode = /* @__PURE__ */ _safeDecode($ZodRealError);
2484
+ var _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
2485
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
2486
+ return _safeParseAsync(_Err)(schema, value, ctx);
2487
+ };
2488
+ var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync($ZodRealError);
2489
+ var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
2490
+ return _safeParseAsync(_Err)(schema, value, _ctx);
2491
+ };
2492
+ var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
2493
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/regexes.js
2494
+ var cuid = /^[cC][^\s-]{8,}$/;
2495
+ var cuid2 = /^[0-9a-z]+$/;
2496
+ var ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
2497
+ var xid = /^[0-9a-vA-V]{20}$/;
2498
+ var ksuid = /^[A-Za-z0-9]{27}$/;
2499
+ var nanoid = /^[a-zA-Z0-9_-]{21}$/;
2500
+ var duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
2501
+ var extendedDuration = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
2502
+ var guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
2503
+ var uuid = (version) => {
2504
+ if (!version)
2505
+ return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
2506
+ return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
2507
+ };
2508
+ var uuid4 = /* @__PURE__ */ uuid(4);
2509
+ var uuid6 = /* @__PURE__ */ uuid(6);
2510
+ var uuid7 = /* @__PURE__ */ uuid(7);
2511
+ var email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
2512
+ var html5Email = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
2513
+ var rfc5322Email = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
2514
+ var unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
2515
+ var idnEmail = unicodeEmail;
2516
+ var browserEmail = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
2517
+ var _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
2518
+ function emoji() {
2519
+ return new RegExp(_emoji, "u");
2804
2520
  }
2805
- function required(Class2, schema, mask) {
2806
- const def = mergeDefs(schema._zod.def, {
2807
- get shape() {
2808
- const oldShape = schema._zod.def.shape;
2809
- const shape = { ...oldShape };
2810
- if (mask) {
2811
- for (const key in mask) {
2812
- if (!(key in shape)) {
2813
- throw new Error(`Unrecognized key: "${key}"`);
2814
- }
2815
- if (!mask[key])
2816
- continue;
2817
- shape[key] = new Class2({
2818
- type: "nonoptional",
2819
- innerType: oldShape[key]
2820
- });
2821
- }
2822
- } else {
2823
- for (const key in oldShape) {
2824
- shape[key] = new Class2({
2825
- type: "nonoptional",
2826
- innerType: oldShape[key]
2827
- });
2828
- }
2829
- }
2830
- assignProp(this, "shape", shape);
2831
- return shape;
2832
- }
2833
- });
2834
- return clone(schema, def);
2521
+ var ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
2522
+ var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
2523
+ var mac = (delimiter) => {
2524
+ const escapedDelim = escapeRegex(delimiter ?? ":");
2525
+ return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
2526
+ };
2527
+ var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
2528
+ var cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
2529
+ var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
2530
+ var base64url = /^[A-Za-z0-9_-]*$/;
2531
+ var hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
2532
+ var domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
2533
+ var e164 = /^\+[1-9]\d{6,14}$/;
2534
+ var dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
2535
+ var date = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
2536
+ function timeSource(args) {
2537
+ const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
2538
+ const regex = typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
2539
+ return regex;
2835
2540
  }
2836
- function aborted(x, startIndex = 0) {
2837
- if (x.aborted === true)
2838
- return true;
2839
- for (let i = startIndex;i < x.issues.length; i++) {
2840
- if (x.issues[i]?.continue !== true) {
2841
- return true;
2842
- }
2843
- }
2844
- return false;
2541
+ function time(args) {
2542
+ return new RegExp(`^${timeSource(args)}$`);
2845
2543
  }
2846
- function prefixIssues(path, issues) {
2847
- return issues.map((iss) => {
2848
- var _a;
2849
- (_a = iss).path ?? (_a.path = []);
2850
- iss.path.unshift(path);
2851
- return iss;
2852
- });
2544
+ function datetime(args) {
2545
+ const time2 = timeSource({ precision: args.precision });
2546
+ const opts = ["Z"];
2547
+ if (args.local)
2548
+ opts.push("");
2549
+ if (args.offset)
2550
+ opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
2551
+ const timeRegex = `${time2}(?:${opts.join("|")})`;
2552
+ return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
2853
2553
  }
2854
- function unwrapMessage(message) {
2855
- return typeof message === "string" ? message : message?.message;
2554
+ var string = (params) => {
2555
+ const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
2556
+ return new RegExp(`^${regex}$`);
2557
+ };
2558
+ var bigint = /^-?\d+n?$/;
2559
+ var integer = /^-?\d+$/;
2560
+ var number = /^-?\d+(?:\.\d+)?$/;
2561
+ var boolean = /^(?:true|false)$/i;
2562
+ var _null = /^null$/i;
2563
+ var _undefined = /^undefined$/i;
2564
+ var lowercase = /^[^A-Z]*$/;
2565
+ var uppercase = /^[^a-z]*$/;
2566
+ var hex = /^[0-9a-fA-F]*$/;
2567
+ function fixedBase64(bodyLength, padding) {
2568
+ return new RegExp(`^[A-Za-z0-9+/]{${bodyLength}}${padding}$`);
2856
2569
  }
2857
- function finalizeIssue(iss, ctx, config) {
2858
- const full = { ...iss, path: iss.path ?? [] };
2859
- if (!iss.message) {
2860
- const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
2861
- full.message = message;
2862
- }
2863
- delete full.inst;
2864
- delete full.continue;
2865
- if (!ctx?.reportInput) {
2866
- delete full.input;
2867
- }
2868
- return full;
2869
- }
2870
- function getSizableOrigin(input) {
2871
- if (input instanceof Set)
2872
- return "set";
2873
- if (input instanceof Map)
2874
- return "map";
2875
- if (input instanceof File)
2876
- return "file";
2877
- return "unknown";
2878
- }
2879
- function getLengthableOrigin(input) {
2880
- if (Array.isArray(input))
2881
- return "array";
2882
- if (typeof input === "string")
2883
- return "string";
2884
- return "unknown";
2885
- }
2886
- function parsedType(data) {
2887
- const t = typeof data;
2888
- switch (t) {
2889
- case "number": {
2890
- return Number.isNaN(data) ? "nan" : "number";
2891
- }
2892
- case "object": {
2893
- if (data === null) {
2894
- return "null";
2895
- }
2896
- if (Array.isArray(data)) {
2897
- return "array";
2898
- }
2899
- const obj = data;
2900
- if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) {
2901
- return obj.constructor.name;
2902
- }
2903
- }
2904
- }
2905
- return t;
2906
- }
2907
- function issue(...args) {
2908
- const [iss, input, inst] = args;
2909
- if (typeof iss === "string") {
2910
- return {
2911
- message: iss,
2912
- code: "custom",
2913
- input,
2914
- inst
2915
- };
2916
- }
2917
- return { ...iss };
2918
- }
2919
- function cleanEnum(obj) {
2920
- return Object.entries(obj).filter(([k, _]) => {
2921
- return Number.isNaN(Number.parseInt(k, 10));
2922
- }).map((el) => el[1]);
2923
- }
2924
- function base64ToUint8Array(base64) {
2925
- const binaryString = atob(base64);
2926
- const bytes = new Uint8Array(binaryString.length);
2927
- for (let i = 0;i < binaryString.length; i++) {
2928
- bytes[i] = binaryString.charCodeAt(i);
2929
- }
2930
- return bytes;
2931
- }
2932
- function uint8ArrayToBase64(bytes) {
2933
- let binaryString = "";
2934
- for (let i = 0;i < bytes.length; i++) {
2935
- binaryString += String.fromCharCode(bytes[i]);
2936
- }
2937
- return btoa(binaryString);
2938
- }
2939
- function base64urlToUint8Array(base64url) {
2940
- const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/");
2941
- const padding = "=".repeat((4 - base64.length % 4) % 4);
2942
- return base64ToUint8Array(base64 + padding);
2943
- }
2944
- function uint8ArrayToBase64url(bytes) {
2945
- return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
2946
- }
2947
- function hexToUint8Array(hex) {
2948
- const cleanHex = hex.replace(/^0x/, "");
2949
- if (cleanHex.length % 2 !== 0) {
2950
- throw new Error("Invalid hex string length");
2951
- }
2952
- const bytes = new Uint8Array(cleanHex.length / 2);
2953
- for (let i = 0;i < cleanHex.length; i += 2) {
2954
- bytes[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16);
2955
- }
2956
- return bytes;
2957
- }
2958
- function uint8ArrayToHex(bytes) {
2959
- return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
2960
- }
2961
-
2962
- class Class {
2963
- constructor(..._args) {}
2570
+ function fixedBase64url(length) {
2571
+ return new RegExp(`^[A-Za-z0-9_-]{${length}}$`);
2964
2572
  }
2573
+ var md5_hex = /^[0-9a-fA-F]{32}$/;
2574
+ var md5_base64 = /* @__PURE__ */ fixedBase64(22, "==");
2575
+ var md5_base64url = /* @__PURE__ */ fixedBase64url(22);
2576
+ var sha1_hex = /^[0-9a-fA-F]{40}$/;
2577
+ var sha1_base64 = /* @__PURE__ */ fixedBase64(27, "=");
2578
+ var sha1_base64url = /* @__PURE__ */ fixedBase64url(27);
2579
+ var sha256_hex = /^[0-9a-fA-F]{64}$/;
2580
+ var sha256_base64 = /* @__PURE__ */ fixedBase64(43, "=");
2581
+ var sha256_base64url = /* @__PURE__ */ fixedBase64url(43);
2582
+ var sha384_hex = /^[0-9a-fA-F]{96}$/;
2583
+ var sha384_base64 = /* @__PURE__ */ fixedBase64(64, "");
2584
+ var sha384_base64url = /* @__PURE__ */ fixedBase64url(64);
2585
+ var sha512_hex = /^[0-9a-fA-F]{128}$/;
2586
+ var sha512_base64 = /* @__PURE__ */ fixedBase64(86, "==");
2587
+ var sha512_base64url = /* @__PURE__ */ fixedBase64url(86);
2965
2588
 
2966
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/errors.js
2967
- var initializer = (inst, def) => {
2968
- inst.name = "$ZodError";
2969
- Object.defineProperty(inst, "_zod", {
2970
- value: inst._zod,
2971
- enumerable: false
2972
- });
2973
- Object.defineProperty(inst, "issues", {
2974
- value: def,
2975
- enumerable: false
2976
- });
2977
- inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
2978
- Object.defineProperty(inst, "toString", {
2979
- value: () => inst.message,
2980
- enumerable: false
2981
- });
2589
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/checks.js
2590
+ var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
2591
+ var _a;
2592
+ inst._zod ?? (inst._zod = {});
2593
+ inst._zod.def = def;
2594
+ (_a = inst._zod).onattach ?? (_a.onattach = []);
2595
+ });
2596
+ var numericOriginMap = {
2597
+ number: "number",
2598
+ bigint: "bigint",
2599
+ object: "date"
2982
2600
  };
2983
- var $ZodError = $constructor("$ZodError", initializer);
2984
- var $ZodRealError = $constructor("$ZodError", initializer, { Parent: Error });
2985
- function flattenError(error, mapper = (issue) => issue.message) {
2986
- const fieldErrors = {};
2987
- const formErrors = [];
2988
- for (const sub of error.issues) {
2989
- if (sub.path.length > 0) {
2990
- fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
2991
- fieldErrors[sub.path[0]].push(mapper(sub));
2992
- } else {
2993
- formErrors.push(mapper(sub));
2601
+ var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
2602
+ $ZodCheck.init(inst, def);
2603
+ const origin = numericOriginMap[typeof def.value];
2604
+ inst._zod.onattach.push((inst) => {
2605
+ const bag = inst._zod.bag;
2606
+ const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
2607
+ if (def.value < curr) {
2608
+ if (def.inclusive)
2609
+ bag.maximum = def.value;
2610
+ else
2611
+ bag.exclusiveMaximum = def.value;
2994
2612
  }
2995
- }
2996
- return { formErrors, fieldErrors };
2997
- }
2998
- function formatError(error, mapper = (issue) => issue.message) {
2999
- const fieldErrors = { _errors: [] };
3000
- const processError = (error) => {
3001
- for (const issue of error.issues) {
3002
- if (issue.code === "invalid_union" && issue.errors.length) {
3003
- issue.errors.map((issues) => processError({ issues }));
3004
- } else if (issue.code === "invalid_key") {
3005
- processError({ issues: issue.issues });
3006
- } else if (issue.code === "invalid_element") {
3007
- processError({ issues: issue.issues });
3008
- } else if (issue.path.length === 0) {
3009
- fieldErrors._errors.push(mapper(issue));
3010
- } else {
3011
- let curr = fieldErrors;
3012
- let i = 0;
3013
- while (i < issue.path.length) {
3014
- const el = issue.path[i];
3015
- const terminal = i === issue.path.length - 1;
3016
- if (!terminal) {
3017
- curr[el] = curr[el] || { _errors: [] };
3018
- } else {
3019
- curr[el] = curr[el] || { _errors: [] };
3020
- curr[el]._errors.push(mapper(issue));
3021
- }
3022
- curr = curr[el];
3023
- i++;
3024
- }
3025
- }
2613
+ });
2614
+ inst._zod.check = (payload) => {
2615
+ if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
2616
+ return;
3026
2617
  }
2618
+ payload.issues.push({
2619
+ origin,
2620
+ code: "too_big",
2621
+ maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
2622
+ input: payload.value,
2623
+ inclusive: def.inclusive,
2624
+ inst,
2625
+ continue: !def.abort
2626
+ });
3027
2627
  };
3028
- processError(error);
3029
- return fieldErrors;
3030
- }
3031
- function treeifyError(error, mapper = (issue) => issue.message) {
3032
- const result = { errors: [] };
3033
- const processError = (error, path = []) => {
3034
- var _a, _b;
3035
- for (const issue of error.issues) {
3036
- if (issue.code === "invalid_union" && issue.errors.length) {
3037
- issue.errors.map((issues) => processError({ issues }, issue.path));
3038
- } else if (issue.code === "invalid_key") {
3039
- processError({ issues: issue.issues }, issue.path);
3040
- } else if (issue.code === "invalid_element") {
3041
- processError({ issues: issue.issues }, issue.path);
3042
- } else {
3043
- const fullpath = [...path, ...issue.path];
3044
- if (fullpath.length === 0) {
3045
- result.errors.push(mapper(issue));
3046
- continue;
3047
- }
3048
- let curr = result;
3049
- let i = 0;
3050
- while (i < fullpath.length) {
3051
- const el = fullpath[i];
3052
- const terminal = i === fullpath.length - 1;
3053
- if (typeof el === "string") {
3054
- curr.properties ?? (curr.properties = {});
3055
- (_a = curr.properties)[el] ?? (_a[el] = { errors: [] });
3056
- curr = curr.properties[el];
3057
- } else {
3058
- curr.items ?? (curr.items = []);
3059
- (_b = curr.items)[el] ?? (_b[el] = { errors: [] });
3060
- curr = curr.items[el];
3061
- }
3062
- if (terminal) {
3063
- curr.errors.push(mapper(issue));
3064
- }
3065
- i++;
3066
- }
3067
- }
3068
- }
3069
- };
3070
- processError(error);
3071
- return result;
3072
- }
3073
- function toDotPath(_path) {
3074
- const segs = [];
3075
- const path = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
3076
- for (const seg of path) {
3077
- if (typeof seg === "number")
3078
- segs.push(`[${seg}]`);
3079
- else if (typeof seg === "symbol")
3080
- segs.push(`[${JSON.stringify(String(seg))}]`);
3081
- else if (/[^\w$]/.test(seg))
3082
- segs.push(`[${JSON.stringify(seg)}]`);
3083
- else {
3084
- if (segs.length)
3085
- segs.push(".");
3086
- segs.push(seg);
3087
- }
3088
- }
3089
- return segs.join("");
3090
- }
3091
- function prettifyError(error) {
3092
- const lines = [];
3093
- const issues = [...error.issues].sort((a, b) => (a.path ?? []).length - (b.path ?? []).length);
3094
- for (const issue of issues) {
3095
- lines.push(`\u2716 ${issue.message}`);
3096
- if (issue.path?.length)
3097
- lines.push(` \u2192 at ${toDotPath(issue.path)}`);
3098
- }
3099
- return lines.join(`
3100
- `);
3101
- }
3102
-
3103
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/parse.js
3104
- var _parse = (_Err) => (schema, value, _ctx, _params) => {
3105
- const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
3106
- const result = schema._zod.run({ value, issues: [] }, ctx);
3107
- if (result instanceof Promise) {
3108
- throw new $ZodAsyncError;
3109
- }
3110
- if (result.issues.length) {
3111
- const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
3112
- captureStackTrace(e, _params?.callee);
3113
- throw e;
3114
- }
3115
- return result.value;
3116
- };
3117
- var parse = /* @__PURE__ */ _parse($ZodRealError);
3118
- var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
3119
- const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
3120
- let result = schema._zod.run({ value, issues: [] }, ctx);
3121
- if (result instanceof Promise)
3122
- result = await result;
3123
- if (result.issues.length) {
3124
- const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
3125
- captureStackTrace(e, params?.callee);
3126
- throw e;
3127
- }
3128
- return result.value;
3129
- };
3130
- var parseAsync = /* @__PURE__ */ _parseAsync($ZodRealError);
3131
- var _safeParse = (_Err) => (schema, value, _ctx) => {
3132
- const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
3133
- const result = schema._zod.run({ value, issues: [] }, ctx);
3134
- if (result instanceof Promise) {
3135
- throw new $ZodAsyncError;
3136
- }
3137
- return result.issues.length ? {
3138
- success: false,
3139
- error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
3140
- } : { success: true, data: result.value };
3141
- };
3142
- var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
3143
- var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
3144
- const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
3145
- let result = schema._zod.run({ value, issues: [] }, ctx);
3146
- if (result instanceof Promise)
3147
- result = await result;
3148
- return result.issues.length ? {
3149
- success: false,
3150
- error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
3151
- } : { success: true, data: result.value };
3152
- };
3153
- var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
3154
- var _encode = (_Err) => (schema, value, _ctx) => {
3155
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
3156
- return _parse(_Err)(schema, value, ctx);
3157
- };
3158
- var encode = /* @__PURE__ */ _encode($ZodRealError);
3159
- var _decode = (_Err) => (schema, value, _ctx) => {
3160
- return _parse(_Err)(schema, value, _ctx);
3161
- };
3162
- var decode = /* @__PURE__ */ _decode($ZodRealError);
3163
- var _encodeAsync = (_Err) => async (schema, value, _ctx) => {
3164
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
3165
- return _parseAsync(_Err)(schema, value, ctx);
3166
- };
3167
- var encodeAsync = /* @__PURE__ */ _encodeAsync($ZodRealError);
3168
- var _decodeAsync = (_Err) => async (schema, value, _ctx) => {
3169
- return _parseAsync(_Err)(schema, value, _ctx);
3170
- };
3171
- var decodeAsync = /* @__PURE__ */ _decodeAsync($ZodRealError);
3172
- var _safeEncode = (_Err) => (schema, value, _ctx) => {
3173
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
3174
- return _safeParse(_Err)(schema, value, ctx);
3175
- };
3176
- var safeEncode = /* @__PURE__ */ _safeEncode($ZodRealError);
3177
- var _safeDecode = (_Err) => (schema, value, _ctx) => {
3178
- return _safeParse(_Err)(schema, value, _ctx);
3179
- };
3180
- var safeDecode = /* @__PURE__ */ _safeDecode($ZodRealError);
3181
- var _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
3182
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
3183
- return _safeParseAsync(_Err)(schema, value, ctx);
3184
- };
3185
- var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync($ZodRealError);
3186
- var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
3187
- return _safeParseAsync(_Err)(schema, value, _ctx);
3188
- };
3189
- var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
3190
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/regexes.js
3191
- var cuid = /^[cC][^\s-]{8,}$/;
3192
- var cuid2 = /^[0-9a-z]+$/;
3193
- var ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
3194
- var xid = /^[0-9a-vA-V]{20}$/;
3195
- var ksuid = /^[A-Za-z0-9]{27}$/;
3196
- var nanoid = /^[a-zA-Z0-9_-]{21}$/;
3197
- var duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
3198
- var extendedDuration = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
3199
- var guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
3200
- var uuid = (version) => {
3201
- if (!version)
3202
- return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
3203
- return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
3204
- };
3205
- var uuid4 = /* @__PURE__ */ uuid(4);
3206
- var uuid6 = /* @__PURE__ */ uuid(6);
3207
- var uuid7 = /* @__PURE__ */ uuid(7);
3208
- var email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
3209
- var html5Email = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
3210
- var rfc5322Email = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
3211
- var unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
3212
- var idnEmail = unicodeEmail;
3213
- var browserEmail = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
3214
- var _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
3215
- function emoji() {
3216
- return new RegExp(_emoji, "u");
3217
- }
3218
- var ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
3219
- var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
3220
- var mac = (delimiter) => {
3221
- const escapedDelim = escapeRegex(delimiter ?? ":");
3222
- return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
3223
- };
3224
- var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
3225
- var cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
3226
- var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
3227
- var base64url = /^[A-Za-z0-9_-]*$/;
3228
- var hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
3229
- var domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
3230
- var e164 = /^\+[1-9]\d{6,14}$/;
3231
- var dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
3232
- var date = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
3233
- function timeSource(args) {
3234
- const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
3235
- const regex = typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
3236
- return regex;
3237
- }
3238
- function time(args) {
3239
- return new RegExp(`^${timeSource(args)}$`);
3240
- }
3241
- function datetime(args) {
3242
- const time2 = timeSource({ precision: args.precision });
3243
- const opts = ["Z"];
3244
- if (args.local)
3245
- opts.push("");
3246
- if (args.offset)
3247
- opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
3248
- const timeRegex = `${time2}(?:${opts.join("|")})`;
3249
- return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
3250
- }
3251
- var string = (params) => {
3252
- const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
3253
- return new RegExp(`^${regex}$`);
3254
- };
3255
- var bigint = /^-?\d+n?$/;
3256
- var integer = /^-?\d+$/;
3257
- var number = /^-?\d+(?:\.\d+)?$/;
3258
- var boolean = /^(?:true|false)$/i;
3259
- var _null = /^null$/i;
3260
- var _undefined = /^undefined$/i;
3261
- var lowercase = /^[^A-Z]*$/;
3262
- var uppercase = /^[^a-z]*$/;
3263
- var hex = /^[0-9a-fA-F]*$/;
3264
- function fixedBase64(bodyLength, padding) {
3265
- return new RegExp(`^[A-Za-z0-9+/]{${bodyLength}}${padding}$`);
3266
- }
3267
- function fixedBase64url(length) {
3268
- return new RegExp(`^[A-Za-z0-9_-]{${length}}$`);
3269
- }
3270
- var md5_hex = /^[0-9a-fA-F]{32}$/;
3271
- var md5_base64 = /* @__PURE__ */ fixedBase64(22, "==");
3272
- var md5_base64url = /* @__PURE__ */ fixedBase64url(22);
3273
- var sha1_hex = /^[0-9a-fA-F]{40}$/;
3274
- var sha1_base64 = /* @__PURE__ */ fixedBase64(27, "=");
3275
- var sha1_base64url = /* @__PURE__ */ fixedBase64url(27);
3276
- var sha256_hex = /^[0-9a-fA-F]{64}$/;
3277
- var sha256_base64 = /* @__PURE__ */ fixedBase64(43, "=");
3278
- var sha256_base64url = /* @__PURE__ */ fixedBase64url(43);
3279
- var sha384_hex = /^[0-9a-fA-F]{96}$/;
3280
- var sha384_base64 = /* @__PURE__ */ fixedBase64(64, "");
3281
- var sha384_base64url = /* @__PURE__ */ fixedBase64url(64);
3282
- var sha512_hex = /^[0-9a-fA-F]{128}$/;
3283
- var sha512_base64 = /* @__PURE__ */ fixedBase64(86, "==");
3284
- var sha512_base64url = /* @__PURE__ */ fixedBase64url(86);
3285
-
3286
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/checks.js
3287
- var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
3288
- var _a;
3289
- inst._zod ?? (inst._zod = {});
3290
- inst._zod.def = def;
3291
- (_a = inst._zod).onattach ?? (_a.onattach = []);
3292
- });
3293
- var numericOriginMap = {
3294
- number: "number",
3295
- bigint: "bigint",
3296
- object: "date"
3297
- };
3298
- var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
3299
- $ZodCheck.init(inst, def);
3300
- const origin = numericOriginMap[typeof def.value];
3301
- inst._zod.onattach.push((inst) => {
3302
- const bag = inst._zod.bag;
3303
- const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
3304
- if (def.value < curr) {
3305
- if (def.inclusive)
3306
- bag.maximum = def.value;
3307
- else
3308
- bag.exclusiveMaximum = def.value;
2628
+ });
2629
+ var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
2630
+ $ZodCheck.init(inst, def);
2631
+ const origin = numericOriginMap[typeof def.value];
2632
+ inst._zod.onattach.push((inst) => {
2633
+ const bag = inst._zod.bag;
2634
+ const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
2635
+ if (def.value > curr) {
2636
+ if (def.inclusive)
2637
+ bag.minimum = def.value;
2638
+ else
2639
+ bag.exclusiveMinimum = def.value;
3309
2640
  }
3310
2641
  });
3311
2642
  inst._zod.check = (payload) => {
3312
- if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
2643
+ if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
3313
2644
  return;
3314
2645
  }
3315
2646
  payload.issues.push({
3316
2647
  origin,
3317
- code: "too_big",
3318
- maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
2648
+ code: "too_small",
2649
+ minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
3319
2650
  input: payload.value,
3320
2651
  inclusive: def.inclusive,
3321
2652
  inst,
@@ -3323,39 +2654,11 @@ var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst,
3323
2654
  });
3324
2655
  };
3325
2656
  });
3326
- var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
2657
+ var $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
3327
2658
  $ZodCheck.init(inst, def);
3328
- const origin = numericOriginMap[typeof def.value];
3329
2659
  inst._zod.onattach.push((inst) => {
3330
- const bag = inst._zod.bag;
3331
- const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
3332
- if (def.value > curr) {
3333
- if (def.inclusive)
3334
- bag.minimum = def.value;
3335
- else
3336
- bag.exclusiveMinimum = def.value;
3337
- }
3338
- });
3339
- inst._zod.check = (payload) => {
3340
- if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
3341
- return;
3342
- }
3343
- payload.issues.push({
3344
- origin,
3345
- code: "too_small",
3346
- minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
3347
- input: payload.value,
3348
- inclusive: def.inclusive,
3349
- inst,
3350
- continue: !def.abort
3351
- });
3352
- };
3353
- });
3354
- var $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
3355
- $ZodCheck.init(inst, def);
3356
- inst._zod.onattach.push((inst) => {
3357
- var _a;
3358
- (_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
2660
+ var _a;
2661
+ (_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
3359
2662
  });
3360
2663
  inst._zod.check = (payload) => {
3361
2664
  if (typeof payload.value !== typeof def.value)
@@ -15365,7 +14668,7 @@ var DOCUMENT_IS_MARKDOWN = "a document holds Markdown, which rewrites other text
15365
14668
  var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
15366
14669
  var ARTIFACT_CONTENT_NAME_RULE = `${CONTENT_IS_MARKDOWN}, so a document's name ends in .md or .markdown or has no extension, under content and under neither flag alike; upload any other file (.jsonl, .tsv, .json, .txt) with ${PATH_KEEPS_BYTES}.`;
15367
14670
  var ARTIFACT_NAME_EXISTS_RULE = `An upload under the name of a document the owner already holds is refused: it writes that document's next version, over the text it holds. Change a document with dispatch doc-edit. To write the next version, send the upload again with force (--force) and the token of the version it replaces (--precondition-json '{"document":"sha256:\u2026"}', the token dispatch doc-read prints).`;
15368
- var ARTIFACT_STORED_TEXT_RULE = `content and content-file hold text Dispatch stores as Markdown, and a text the store would write under another spelling is refused. The refusal prints the text Dispatch stores: send that text. A name that does not end in .md or .markdown has a second way out, which keeps the text as it was written: send it as a file with ${PATH_KEEPS_BYTES}.`;
14671
+ var ARTIFACT_STORED_TEXT_RULE = `content and content-file hold text Dispatch stores as Markdown, and a text the store would write under another spelling is refused. A typed block whose attributes differ from Dispatch's only in their order is not refused: the command uploads it with them in Dispatch's order and names each such block. A refusal names the first difference: a changed line by the attribute or the word that differs, a word of more than 200 characters by a window from its first character that differs, and a line the store adds or drops by a quote cut at 200 characters, each cut named. The refusal prints the text Dispatch stores: send that text. A name that does not end in .md or .markdown has a second way out, which keeps the text as it was written: send it as a file with ${PATH_KEEPS_BYTES}.`;
15369
14672
  var NAME_EXTENSION = /\.([^\s.]+)$/u;
15370
14673
  var MARKDOWN_EXTENSION = /^(md|markdown)$/i;
15371
14674
  function preconditionArgument(z) {
@@ -15667,7 +14970,7 @@ var dispatchToolSpecs = [
15667
14970
  {
15668
14971
  name: "dispatch_issue",
15669
14972
  example: { project: "DSP", title: "Native workspace" },
15670
- description: "Create a native Dispatch issue for newly tracked work. Search first with dispatch search; if potentially duplicate issues exist, this returns 409 POSSIBLE_DUPLICATE unless --force is set after reading them, or, when the refusal cannot be recorded, creates the issue and names the near copy to read in the result. " + "When passing a spec, before calling, have a fresh read-only reader check it against the code and the human's words, then resolve every finding; a Legion architect uses `plan-gap-analyst`. " + "A spec holding an ask block whose body breaks its content rule (one or more question paragraphs, then at most one bullet list of options, last) is refused with 400 INVALID_ASK_BLOCK. " + `${CI_CHECK_RULE} ` + "Create a project only when a person asks for one; work that spans projects goes in the project that owns most of it. " + `${RELATED_CHECK_RESULT} With --force, the result also names each issue whose title you forced past. ` + `Do not use it when an existing issue already covers the work; read or update that issue instead. ${ISSUE_REFERENCE}`,
14973
+ description: "Create a native Dispatch issue for newly tracked work. Search first with dispatch search; if potentially duplicate issues exist, this returns 409 POSSIBLE_DUPLICATE unless --force is set after reading them, or, when the refusal cannot be recorded, creates the issue and names the near copy to read in the result. " + "Where the spec is large, or changed in a way you cannot check alone, a fresh read-only reader can find its gaps and check its factual claims; a Legion architect can use `plan-gap-analyst` and `plan-reviewer`. " + "A spec holding an ask block whose body breaks its content rule (one or more question paragraphs, then at most one bullet list of options, last) is refused with 400 INVALID_ASK_BLOCK. " + `${CI_CHECK_RULE} ` + "Create a project only when a person asks for one; work that spans projects goes in the project that owns most of it. " + `${RELATED_CHECK_RESULT} With --force, the result also names each issue whose title you forced past. ` + `Do not use it when an existing issue already covers the work; read or update that issue instead. ${ISSUE_REFERENCE}`,
15671
14974
  arguments: (z) => ({
15672
14975
  project: z.string().describe("Project key for the new issue."),
15673
14976
  title: z.string({ max: ISSUE_TITLE_MAX }).describe("Concise issue title, at most 1,000 characters."),
@@ -15952,12 +15255,12 @@ var dispatchToolSpecs = [
15952
15255
  {
15953
15256
  name: "dispatch_request_approval",
15954
15257
  example: { issue: "DSP-1", summary: "A live sync replaces the nightly export." },
15955
- description: "Ask a human to approve a document at its current version. Before calling, have a fresh read-only reader check the spec against the code and the human's words, then resolve every finding; a Legion architect runs `plan-gap-analyst` and `plan-reviewer`. Opens an approval ask (Approve / " + "Request changes) in the human's Inbox whose question names the document and version, " + "followed by the summary; the answer pins a review to that version and arrives as " + "artifact.approved or artifact.changes_requested. " + "The request reaches the person it was handed to, else the issue's assignee, else the " + "project's default assignee, so it always reaches a person, and this tool's answer names " + "that person. " + "An open request follows the document: a " + "later version moves it to that version and leaves it waiting on you, as a human's reply in " + "its thread does. Only the first move since the request was opened or handed back sends an " + "event, and never to the session whose version made it; dispatch doc-read shows whom it " + "waits on. Once the revision is complete and " + HUMAN_AGREED_TO_DOCUMENT + ", call this again to hand that same Inbox row back. The request carries nothing new. A " + "call while it already waits on the human hands nothing back: the same summary changes " + "nothing, and a different one is refused, since it would rewrite the card the human is " + "reading. Approve and Request changes each close the request, so the next call opens a new " + "one. Call it once per revision, when the revision is complete, never after each edit. An " + "approval goes stale when the document changes outside its decision blocks after it, until " + "a later version's text is exactly the approved version's again, as when an accidental " + "edit is undone exactly, and no decision block in it was decided since: that version " + "carries the approval and the document reads approved at it, so nothing is requested for " + "it. When the document does not read approved, request approval again once that revision " + "is complete and " + HUMAN_AGREED_TO_DOCUMENT + ", with a one-sentence summary naming what changed since the earlier approval: the card " + "names that approval (version, date, reviewer) and its Show diff control carries the detail. " + "A human's own answer to a decision block carries the approval to the version it writes when " + "that answer is the whole change since the approved version, so nothing is requested for " + "it. A new version of a Legion root spec closes its armed design gate until a human " + "approves it; a carried approval reopens it too. " + "Refused, with nothing sent, while the document holds an open decision block, even when a " + "human asked for approval: the refusal names each block; ask the human to answer or waive " + "it first. " + "Refused 409 PLAN_APPROVED_BY_REVIEW on an issue's plan, which its plan review approves " + "(dispatch plan-approve), never a person. " + "On an issue's spec the answer ends with a `Coverage of <name>:` line naming each requirement " + "the spec marks that no check serves, in any document of the issue or of its descendants, or saying " + "the spec marks no requirements; a spec every requirement of which has a check gets no such line. It never " + "names a missing plan task, and a gap refuses nothing. " + OWNER_REFERENCE,
15258
+ description: "Ask a human to approve a document at its current version. Where the spec is large, or changed in a way you cannot check alone, a fresh read-only reader can find its gaps and check its factual claims; a Legion architect can use `plan-gap-analyst` and `plan-reviewer`. Opens an approval ask (Approve / " + "Request changes) in the human's Inbox whose question names the document and version, " + "followed by the summary; the answer pins a review to that version and arrives as " + "artifact.approved or artifact.changes_requested. " + "The request reaches the person it was handed to, else the issue's assignee, else the " + "project's default assignee, so it always reaches a person, and this tool's answer names " + "that person. " + "An open request follows the document: a " + "later version moves it to that version and leaves it waiting on you, as a human's reply in " + "its thread does. Only the first move since the request was opened or handed back sends an " + "event, and never to the session whose version made it; dispatch doc-read shows whom it " + "waits on. Once the revision is complete and " + HUMAN_AGREED_TO_DOCUMENT + ", call this again to hand that same Inbox row back. The request carries nothing new. A " + "call while it already waits on the human hands nothing back: the same summary changes " + "nothing, and a different one is refused, since it would rewrite the card the human is " + "reading. Approve and Request changes each close the request, so the next call opens a new " + "one. Call it once per revision, when the revision is complete, never after each edit. An " + "approval goes stale when the document changes outside its decision blocks after it, until " + "a later version's text is exactly the approved version's again, as when an accidental " + "edit is undone exactly, and no decision block in it was decided since: that version " + "carries the approval and the document reads approved at it, so nothing is requested for " + "it. When the document does not read approved, request approval again once that revision " + "is complete and " + HUMAN_AGREED_TO_DOCUMENT + ", with a one-sentence summary naming what changed since the earlier approval: the card " + "names that approval (version, date, reviewer) and its Show diff control carries the detail. " + "A human's own answer to a decision block carries the approval to the version it writes when " + "that answer is the whole change since the approved version, so nothing is requested for " + "it. A new version of a Legion root spec closes its armed design gate until a human " + "approves it; a carried approval reopens it too. " + "Refused, with nothing sent, while the document holds an open decision block, even when a " + "human asked for approval: the refusal names each block; ask the human to answer or waive " + "it first. " + "Refused 409 PLAN_APPROVED_BY_REVIEW on an issue's plan, which its plan review approves " + "(dispatch plan-approve), never a person. " + "On an issue's spec the answer ends with a `Coverage of <name>:` line naming each requirement " + "the spec marks that no check serves, in any document of the issue or of its descendants, or saying " + "the spec marks no requirements; a spec every requirement of which has a check gets no such line. It never " + "names a missing plan task, and a gap refuses nothing. " + OWNER_REFERENCE,
15956
15259
  arguments: (z) => ({
15957
15260
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
15958
15261
  project: z.string().describe("Project key owning the document.").optional(),
15959
15262
  artifact: z.string().describe("Project document artifact id, slug, or filename; primary document by default for an issue.").optional(),
15960
- summary: z.string({ min: 1 }).describe(`What the human is approving, in one to three sentences, and nothing else: no commentary on itself or the conversation, and no question; after an earlier approval, one sentence naming what changed since it, since the card shows that approval and a diff. A Legion architect adds one last sentence with its two spec reviews' results. Request approval only once ${HUMAN_AGREED_TO_DOCUMENT}.`),
15263
+ summary: z.string({ min: 1 }).describe(`What the human is approving, in one to three sentences, and nothing else: no commentary on itself or the conversation, and no question; after an earlier approval, one sentence naming what changed since it, since the card shows that approval and a diff. Request approval only once ${HUMAN_AGREED_TO_DOCUMENT}.`),
15961
15264
  include_verification: z.boolean().describe("Ask for the issue's Verification document in the same request, beside this one: one Inbox card names both at their current versions, and the answer records the human's review on each. 409 NO_VERIFICATION_DOCUMENT when the issue has no verification.md. Without it the request names this document alone and records nothing on the Verification document.").optional()
15962
15265
  }),
15963
15266
  validation: documentOwnerValidation(true)
@@ -16039,7 +15342,7 @@ var dispatchToolSpecs = [
16039
15342
  project: z.string().describe("Project key for an unlinked document.").optional(),
16040
15343
  name: z.string().describe("Artifact filename shown in Dispatch."),
16041
15344
  path: z.string().describe("Local path to the file to upload.").optional(),
16042
- content: z.string().describe("Inline text to store as a Markdown document, under a name ending in .md or .markdown or with no extension. The command refuses a text the store would write under another spelling, a CR LF or a lone carriage return among them, which Dispatch stores as a line feed. A missing line feed at the end is not such a text: Dispatch adds one, and the upload goes on. The refusal prints the text Dispatch stores, which is the text to send.").optional(),
15345
+ content: z.string().describe("Inline text to store as a Markdown document, under a name ending in .md or .markdown or with no extension. The command refuses a text the store would write under another spelling, a CR LF or a lone carriage return among them, which Dispatch stores as a line feed. A missing line feed at the end is not such a text: Dispatch adds one, and the upload goes on. Nor is a typed block whose attributes differ only in their order: the upload puts them in Dispatch's order. The refusal names the first difference: a changed line by the attribute or the word that differs, a word of more than 200 characters by a window from its first character that differs, and a line the store adds or drops by a quote cut at 200 characters, each cut named. It prints the text Dispatch stores, which is the text to send.").optional(),
16043
15346
  force: z.boolean().describe("Write the next version of a document the owner already holds under this name; without it the upload of a name that exists is refused.").optional(),
16044
15347
  precondition: uploadPreconditionArgument(z),
16045
15348
  summary: z.string().describe("Optional version summary.").optional()
@@ -18277,107 +17580,878 @@ function canonicalTopic(topic) {
18277
17580
  const role = kept.rest[0];
18278
17581
  return { canonical: `${KEPT_PREFIX}${kept.kind}.${roleProject(role)}.${role}`, legacy: true };
18279
17582
  }
18280
- return unchanged;
18281
- }
18282
- function isProjectPosition(token) {
18283
- return token !== undefined && (PROJECT_KEY_PATTERN.test(token) || token === NO_PROJECT || token === "*");
17583
+ return unchanged;
17584
+ }
17585
+ function isProjectPosition(token) {
17586
+ return token !== undefined && (PROJECT_KEY_PATTERN.test(token) || token === NO_PROJECT || token === "*");
17587
+ }
17588
+ function legacyTwin(canonical) {
17589
+ if (canonical.startsWith(DISPATCH_ISSUE_TOPIC_PREFIX)) {
17590
+ const [project, key, ...rest] = canonical.slice(DISPATCH_ISSUE_TOPIC_PREFIX.length).split(".");
17591
+ if (key === undefined || project === undefined)
17592
+ return;
17593
+ const keyProject = issueProject(key);
17594
+ if (keyProject === undefined || project !== keyProject)
17595
+ return;
17596
+ return [`${DISPATCH_ISSUE_TOPIC_PREFIX}${key}`, ...rest].join(".");
17597
+ }
17598
+ for (const prefix of [AGENT_TOPIC_PREFIX, ROLE_TOPIC_PREFIX]) {
17599
+ if (canonical.startsWith(prefix)) {
17600
+ const rest = canonical.slice(prefix.length).split(".");
17601
+ return rest.length === 2 && isProjectPosition(rest[0]) && isLiteral(rest[1]) ? `${prefix}${rest[1]}` : undefined;
17602
+ }
17603
+ }
17604
+ if (canonical.startsWith(EXCEPTION_PREFIX)) {
17605
+ const twin = legacyTwin(canonical.slice(EXCEPTION_PREFIX.length));
17606
+ return twin === undefined ? undefined : `${EXCEPTION_PREFIX}${twin}`;
17607
+ }
17608
+ const kept = keptLane(canonical);
17609
+ if (kept !== undefined && kept.rest.length === 2 && isProjectPosition(kept.rest[0])) {
17610
+ const role = kept.rest[1];
17611
+ return isLiteral(role) ? `${KEPT_PREFIX}${kept.kind}.${role}` : undefined;
17612
+ }
17613
+ return;
17614
+ }
17615
+ function topicForms(topic) {
17616
+ const { canonical, legacy } = canonicalTopic(topic);
17617
+ if (legacy)
17618
+ return [topic, canonical];
17619
+ const twin = legacyTwin(topic);
17620
+ return twin === undefined ? [topic] : [topic, twin];
17621
+ }
17622
+ // ../contracts/src/tool-schema.ts
17623
+ function overCapMessage(length, max) {
17624
+ return `is ${length - max} characters over the ${max}-character limit (${length}/${max})`;
17625
+ }
17626
+ function literalOfSet(api, values) {
17627
+ const node = api.literal?.(values);
17628
+ if (node === undefined || typeof node.safeParse !== "function")
17629
+ return;
17630
+ return values.every((value) => node.safeParse(value).success) ? node : undefined;
17631
+ }
17632
+ function zodSchemaApi(zod) {
17633
+ const api = zod;
17634
+ return {
17635
+ string: (opts = {}) => {
17636
+ let schema = api.string();
17637
+ if (opts.min !== undefined)
17638
+ schema = schema.min(opts.min);
17639
+ if (opts.max !== undefined) {
17640
+ const max = opts.max;
17641
+ const hint = opts.maxHint === undefined ? "" : `; ${opts.maxHint}`;
17642
+ schema = schema.max(max, {
17643
+ error: (issue) => overCapMessage(typeof issue.input === "string" ? issue.input.length : max + 1, max) + hint
17644
+ });
17645
+ }
17646
+ return schema;
17647
+ },
17648
+ number: (opts = {}) => {
17649
+ let schema = api.number();
17650
+ if (opts.int)
17651
+ schema = schema.int();
17652
+ if (opts.min !== undefined)
17653
+ schema = schema.min(opts.min);
17654
+ if (opts.max !== undefined)
17655
+ schema = schema.max(opts.max);
17656
+ return schema;
17657
+ },
17658
+ boolean: () => api.boolean(),
17659
+ enum: (values) => api.enum(values),
17660
+ literal: (values) => literalOfSet(api, values) ?? api.unknown(),
17661
+ unknown: () => api.unknown(),
17662
+ array: (item, opts = {}) => {
17663
+ let schema = api.array(item);
17664
+ if (opts.min !== undefined)
17665
+ schema = schema.min(opts.min);
17666
+ if (opts.max !== undefined)
17667
+ schema = schema.max(opts.max);
17668
+ return schema;
17669
+ },
17670
+ object: (shape, opts = {}) => {
17671
+ let schema = api.object(shape);
17672
+ if (opts.strict)
17673
+ schema = schema.strict();
17674
+ return schema;
17675
+ },
17676
+ refineObject: (shape, check, message, opts = {}) => {
17677
+ let schema = api.object(shape);
17678
+ if (opts.strict)
17679
+ schema = schema.strict();
17680
+ return schema.refine(check, typeof message === "string" ? message : { error: (issue) => message(issue.input) });
17681
+ }
17682
+ };
17683
+ }
17684
+ // ../envoy-client/src/typed-block-opener.ts
17685
+ function runOf(text, index, char) {
17686
+ let end = index;
17687
+ while (text.charAt(end) === char)
17688
+ end++;
17689
+ return end - index;
17690
+ }
17691
+ function directiveNameChar(char) {
17692
+ return /^[A-Za-z0-9_-]$/.test(char);
17693
+ }
17694
+ function typedFenceBrace(text, at) {
17695
+ const nameStart = at + runOf(text, at, ":");
17696
+ if (nameStart - at < 3)
17697
+ return -1;
17698
+ let brace = nameStart;
17699
+ while (directiveNameChar(text.charAt(brace)))
17700
+ brace++;
17701
+ return brace > nameStart && text.charAt(brace) === "{" ? brace : -1;
17702
+ }
17703
+ function typedOpenerAt(text, at) {
17704
+ const brace = typedFenceBrace(text, at);
17705
+ if (brace === -1 || !text.endsWith("}"))
17706
+ return;
17707
+ const attributes = directiveAttributes(text.slice(brace + 1, -1));
17708
+ if (attributes === undefined)
17709
+ return;
17710
+ const colons = runOf(text, at, ":");
17711
+ return { ...attributes, name: text.slice(at + colons, brace), colons };
17712
+ }
17713
+ function refusedDirective(text) {
17714
+ if (text.startsWith(":::"))
17715
+ return text !== ":::" && typedOpenerAt(text, 0) === undefined;
17716
+ if (text.startsWith("::"))
17717
+ return text.length > 2 && directiveNameChar(text.charAt(2));
17718
+ return text.length > 1 && directiveNameChar(text.charAt(1)) && text.includes("{");
17719
+ }
17720
+ function attributeSpace(char) {
17721
+ return char === " " || char >= "\t" && char <= "\r";
17722
+ }
17723
+ var BLOCK_ID_ATTRIBUTE = "blockId";
17724
+ function directiveAttributes(value) {
17725
+ const attributes = [];
17726
+ const gaps = [];
17727
+ const named = new Set;
17728
+ let hasId = false;
17729
+ let id;
17730
+ let offset = 0;
17731
+ for (;; ) {
17732
+ const gap = offset;
17733
+ while (offset < value.length && attributeSpace(value.charAt(offset)))
17734
+ offset++;
17735
+ gaps.push(value.slice(gap, offset));
17736
+ if (offset === value.length)
17737
+ break;
17738
+ const start = offset;
17739
+ const sigil = value.charAt(start);
17740
+ let name;
17741
+ if (sigil === "#") {
17742
+ offset = start + 1;
17743
+ while (offset < value.length && !TYPED_BLOCK_ID_SHORTCUT_EXCLUDED.includes(value.charAt(offset)))
17744
+ offset++;
17745
+ if (offset === start + 1 || hasId)
17746
+ return;
17747
+ hasId = true;
17748
+ id = value.slice(start + 1, offset);
17749
+ name = "id";
17750
+ } else if (sigil === ".") {
17751
+ offset = start + 1;
17752
+ while (offset < value.length && directiveNameChar(value.charAt(offset)))
17753
+ offset++;
17754
+ if (offset === start + 1)
17755
+ return;
17756
+ named.add("class");
17757
+ name = "class";
17758
+ } else {
17759
+ while (offset < value.length && directiveNameChar(value.charAt(offset)))
17760
+ offset++;
17761
+ name = value.slice(start, offset);
17762
+ if (name === "")
17763
+ return;
17764
+ if (name === "id") {
17765
+ const close = value.startsWith('="', offset) ? value.indexOf('"', offset + 2) : -1;
17766
+ if (close === -1 || close === offset + 2 || hasId)
17767
+ return;
17768
+ hasId = true;
17769
+ id = decodedId(value.slice(offset + 2, close));
17770
+ offset = close + 1;
17771
+ } else {
17772
+ if (name === BLOCK_ID_ATTRIBUTE || named.has(name))
17773
+ return;
17774
+ named.add(name);
17775
+ if (offset < value.length && value.charAt(offset) !== " ") {
17776
+ const close = value.startsWith('="', offset) ? value.indexOf('"', offset + 2) : -1;
17777
+ if (close === -1)
17778
+ return;
17779
+ offset = close + 1;
17780
+ }
17781
+ }
17782
+ }
17783
+ if (offset < value.length && !attributeSpace(value.charAt(offset)))
17784
+ return;
17785
+ attributes.push({ name, text: value.slice(start, offset) });
17786
+ }
17787
+ return { attributes, gaps, id };
17788
+ }
17789
+ var NAMED_REFERENCES = new Map([
17790
+ ["amp;", "&"],
17791
+ ["amp", "&"],
17792
+ ["lt;", "<"],
17793
+ ["lt", "<"],
17794
+ ["gt;", ">"],
17795
+ ["gt", ">"],
17796
+ ["quot;", '"'],
17797
+ ["quot", '"'],
17798
+ ["apos;", "'"],
17799
+ ["nbsp;", "\xA0"],
17800
+ ["nbsp", "\xA0"]
17801
+ ]);
17802
+ var WINDOWS_1252 = "\u20AC\x81\u201A\u0192\u201E\u2026\u2020\u2021\u02C6\u2030\u0160\u2039\u0152\x8D\u017D\x8F" + "\x90\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u02DC\u2122\u0161\u203A\u0153\x9D\u017E\u0178";
17803
+ function decodedId(raw) {
17804
+ let id = "";
17805
+ let at = 0;
17806
+ for (let amp = raw.indexOf("&");amp !== -1; amp = raw.indexOf("&", at)) {
17807
+ id += raw.slice(at, amp);
17808
+ const s = raw.slice(amp);
17809
+ let i = 1;
17810
+ if (s.charAt(1) === "#") {
17811
+ const hex = s.charAt(2) === "x" || s.charAt(2) === "X";
17812
+ let x = 0;
17813
+ i = hex ? 3 : 2;
17814
+ while (s.length > 3 && i < s.length) {
17815
+ const c = s.charAt(i++);
17816
+ const digit = (hex ? /^[0-9A-Fa-f]$/ : /^[0-9]$/).test(c) ? Number.parseInt(c, 16) : -1;
17817
+ if (digit >= 0) {
17818
+ x = Math.imul(x, hex ? 16 : 10) + digit | 0;
17819
+ continue;
17820
+ }
17821
+ if (c !== ";")
17822
+ i--;
17823
+ break;
17824
+ }
17825
+ if (s.length <= 3 || i <= 3) {
17826
+ id += "&";
17827
+ i = 1;
17828
+ } else if (x >= 128 && x <= 159) {
17829
+ id += WINDOWS_1252.charAt(x - 128);
17830
+ } else if (x <= 0 || x >= 55296 && x <= 57343 || x > 1114111) {
17831
+ id += "\uFFFD";
17832
+ } else {
17833
+ id += String.fromCodePoint(x);
17834
+ }
17835
+ } else {
17836
+ while (i < s.length && /^[A-Za-z0-9]$/.test(s.charAt(i)))
17837
+ i++;
17838
+ if (s.charAt(i) === ";")
17839
+ i++;
17840
+ const name = s.slice(1, i);
17841
+ const decoded = NAMED_REFERENCES.get(name);
17842
+ if (decoded !== undefined)
17843
+ id += decoded;
17844
+ else if (name.replace(/;$/, "").length > 1 && /^[A-Za-z]/.test(name))
17845
+ return;
17846
+ else
17847
+ id += s.slice(0, i);
17848
+ }
17849
+ at = amp + i;
17850
+ }
17851
+ return id + raw.slice(at);
17852
+ }
17853
+
17854
+ // ../envoy-client/src/askgate-new-asks.ts
17855
+ var OPENING_CODE_POINTS = 60;
17856
+ function newAsks(toolName, input) {
17857
+ switch (toolName) {
17858
+ case "dispatch_ask":
17859
+ return [questionAsk(input)];
17860
+ case "dispatch_issue":
17861
+ return typeof input.spec === "string" ? askBlocks(input.spec) : [];
17862
+ case "dispatch_artifact":
17863
+ return typeof input.content === "string" ? askBlocks(input.content) : [];
17864
+ case "dispatch_doc_edit":
17865
+ return editOps(input).flatMap((op) => {
17866
+ const { op: kind, markdown, with: replacement, type, block } = op;
17867
+ if (kind === "insert" && typeof markdown === "string") {
17868
+ return scanAsks(markdown, op.before === "start" || op.after === "start");
17869
+ }
17870
+ if (kind === "replace" && typeof replacement === "string") {
17871
+ return replacementAsks(replacement);
17872
+ }
17873
+ if (kind === "retype" && type === "ask" && typeof block === "string") {
17874
+ return [{ kind: "retype", id: block, text: "", opening: "" }];
17875
+ }
17876
+ return [];
17877
+ });
17878
+ default:
17879
+ return [];
17880
+ }
17881
+ }
17882
+ function newAskCount(toolName, input) {
17883
+ if (toolName !== "dispatch_doc_edit")
17884
+ return newAsks(toolName, input).length;
17885
+ let count = 0;
17886
+ for (const op of editOps(input)) {
17887
+ count += op.op === "replace" && typeof op.with === "string" ? Math.max(...replacementReadings(op.with).map((text) => scanAsks(text, false).length)) : newAsks(toolName, { ops: [op] }).length;
17888
+ }
17889
+ return count;
17890
+ }
17891
+ function editOps(input) {
17892
+ return (Array.isArray(input.ops) ? input.ops : []).filter((op) => typeof op === "object" && op !== null);
17893
+ }
17894
+ function questionAsk(input) {
17895
+ const question = typeof input.question === "string" ? input.question.trim() : "";
17896
+ const options = (Array.isArray(input.options) ? input.options : []).flatMap((option) => {
17897
+ if (typeof option !== "object" || option === null)
17898
+ return [];
17899
+ const { label, description } = option;
17900
+ return [
17901
+ typeof description === "string" && description !== "" ? `- ${String(label ?? "")}: ${description}` : `- ${String(label ?? "")}`
17902
+ ];
17903
+ });
17904
+ return {
17905
+ kind: "ask",
17906
+ text: options.length === 0 ? question : `${question}
17907
+
17908
+ ${options.join(`
17909
+ `)}`,
17910
+ opening: openingOf(question)
17911
+ };
17912
+ }
17913
+ function openingOf(text) {
17914
+ return Array.from(text.replace(/\s+/g, " ").trim()).slice(0, OPENING_CODE_POINTS).join("");
17915
+ }
17916
+ var FRONT_MATTER_FENCE = /^---[ \t]*$/;
17917
+ function askBlocks(markdown) {
17918
+ return scanAsks(markdown, true);
17919
+ }
17920
+ function scanAsks(markdown, frontMatter) {
17921
+ let lines = markdown.replace(/\r\n?/g, `
17922
+ `).split(`
17923
+ `);
17924
+ let unclosedFrontMatter = false;
17925
+ if (frontMatter && FRONT_MATTER_FENCE.test(lines[0] ?? "")) {
17926
+ const close = lines.findIndex((line, index) => index > 0 && FRONT_MATTER_FENCE.test(line));
17927
+ if (close === -1)
17928
+ unclosedFrontMatter = true;
17929
+ else
17930
+ lines = lines.slice(close + 1);
17931
+ }
17932
+ const scan = {
17933
+ lines,
17934
+ index: 0,
17935
+ opened: [],
17936
+ drafts: [],
17937
+ emptyItemWithBlankLines: false,
17938
+ skipList: false,
17939
+ unclosedFrontMatter
17940
+ };
17941
+ const document = {
17942
+ kind: "document",
17943
+ parent: undefined,
17944
+ previous: undefined,
17945
+ children: 0,
17946
+ last: undefined
17947
+ };
17948
+ for (const [index, text] of lines.entries()) {
17949
+ scan.index = index;
17950
+ readLine(scan, document, new Line(text));
17951
+ }
17952
+ return scan.drafts.map(({ id, lines: body }) => {
17953
+ const text = body.join(`
17954
+ `).trim();
17955
+ return { kind: "block", ...id === undefined ? {} : { id }, text, opening: openingOf(text) };
17956
+ });
17957
+ }
17958
+ function replacementAsks(replacement) {
17959
+ const variants = new Map;
17960
+ for (const reading of replacementReadings(replacement)) {
17961
+ for (const ask of scanAsks(reading, false)) {
17962
+ const key = JSON.stringify([ask.id ?? null, ask.text]);
17963
+ if (!variants.has(key))
17964
+ variants.set(key, ask);
17965
+ }
17966
+ }
17967
+ const found = [...variants.values()];
17968
+ const idsWithText = new Set(found.flatMap((ask) => ask.text !== "" && ask.id !== undefined ? [ask.id] : []));
17969
+ const anyText = found.some((ask) => ask.text !== "");
17970
+ return found.filter((ask) => ask.text !== "" || (ask.id === undefined ? !anyText : !idsWithText.has(ask.id)));
17971
+ }
17972
+ function replacementReadings(replacement) {
17973
+ const readings = [replacement];
17974
+ let text = replacement;
17975
+ for (let strip = LEADING_STRIP.exec(text);strip !== null; strip = LEADING_STRIP.exec(text)) {
17976
+ text = text.slice(strip[0].length);
17977
+ readings.push(text);
17978
+ }
17979
+ return readings;
17980
+ }
17981
+ var LEADING_STRIP = /^(?:[ \t]*(?:#{1,6}|[0-9]{1,9}[.)]|[-*+])[ \t]+|\[[ xX]\][ \t]+)/u;
17982
+
17983
+ class Line {
17984
+ text;
17985
+ #starts;
17986
+ #pos = 0;
17987
+ #column = 0;
17988
+ constructor(text) {
17989
+ this.text = text;
17990
+ const starts = [0];
17991
+ let column = 0;
17992
+ for (let index = 0;index < text.length; index++) {
17993
+ column += text[index] === "\t" ? 4 - column % 4 : 1;
17994
+ starts.push(column);
17995
+ }
17996
+ this.#starts = starts;
17997
+ }
17998
+ get column() {
17999
+ return this.#column;
18000
+ }
18001
+ columnAt(index) {
18002
+ return this.#starts[index];
18003
+ }
18004
+ #afterSpaces(index) {
18005
+ let end = index;
18006
+ while (end < this.text.length && (this.text[end] === " " || this.text[end] === "\t"))
18007
+ end++;
18008
+ return end;
18009
+ }
18010
+ spacesAt(index) {
18011
+ return this.columnAt(this.#afterSpaces(index)) - this.columnAt(index);
18012
+ }
18013
+ indent() {
18014
+ const at = this.#afterSpaces(this.#pos);
18015
+ return { width: this.columnAt(at) - this.#column, at };
18016
+ }
18017
+ blank() {
18018
+ return this.indent().at === this.text.length;
18019
+ }
18020
+ skip(columns) {
18021
+ this.#column += columns;
18022
+ while (this.#pos < this.text.length && this.columnAt(this.#pos + 1) <= this.#column)
18023
+ this.#pos++;
18024
+ }
18025
+ advanceTo(index) {
18026
+ this.#pos = index;
18027
+ this.#column = this.columnAt(index);
18028
+ }
18029
+ rest() {
18030
+ const start = this.columnAt(this.#pos);
18031
+ if (this.#pos < this.text.length && start < this.#column) {
18032
+ return " ".repeat(this.columnAt(this.#pos + 1) - this.#column) + this.text.slice(this.#pos + 1);
18033
+ }
18034
+ return this.text.slice(this.#pos);
18035
+ }
18036
+ }
18037
+ function readLine(scan, document, line) {
18038
+ if (scan.opened.length === 0) {
18039
+ if (!line.blank())
18040
+ openBlocks(scan, document, line);
18041
+ return;
18042
+ }
18043
+ const opened = [...scan.opened];
18044
+ const lastIndex = opened.length - 1;
18045
+ for (const [index, block] of opened.entries()) {
18046
+ if (block.kind !== "paragraph") {
18047
+ const continuation = continueBlock(scan, block, line);
18048
+ if (continuation === "children" && index === lastIndex) {
18049
+ openBlocks(scan, block, line);
18050
+ return;
18051
+ }
18052
+ if (continuation !== "close")
18053
+ continue;
18054
+ }
18055
+ if (openBlocks(scan, opened[index - 1] ?? document, line) !== "paragraph") {
18056
+ scan.opened.splice(index, lastIndex - index + 1);
18057
+ }
18058
+ return;
18059
+ }
18060
+ }
18061
+ function openBlocks(scan, parent, line) {
18062
+ const continuable = scan.opened.at(-1)?.kind === "paragraph";
18063
+ let result = "none";
18064
+ for (let into = parent;; ) {
18065
+ const { width, at } = line.indent();
18066
+ if (at === line.text.length)
18067
+ break;
18068
+ const char = line.text.charAt(at);
18069
+ const interrupting = continuable && result === "none";
18070
+ let opened;
18071
+ for (const parser of BLOCK_PARSERS) {
18072
+ if (parser.triggers !== undefined && !parser.triggers.includes(char))
18073
+ continue;
18074
+ if (interrupting && !parser.interrupts)
18075
+ continue;
18076
+ if (width > 3 && !parser.indented)
18077
+ continue;
18078
+ opened = parser.open(scan, into, line, width, at);
18079
+ if (opened !== undefined)
18080
+ break;
18081
+ }
18082
+ if (opened === undefined)
18083
+ break;
18084
+ into.children++;
18085
+ into.last = opened.block;
18086
+ scan.opened.push(opened.block);
18087
+ result = "opened";
18088
+ if (!opened.children)
18089
+ break;
18090
+ into = opened.block;
18091
+ }
18092
+ const last = scan.opened.at(-1);
18093
+ if (result === "none" && last?.kind === "paragraph" && !line.blank()) {
18094
+ last.rows.push(line.rest());
18095
+ last.lastLine = scan.index;
18096
+ line.advanceTo(line.text.length);
18097
+ return "paragraph";
18098
+ }
18099
+ return result;
18100
+ }
18101
+ function under(parent) {
18102
+ return { parent, previous: parent.last, children: 0, last: undefined };
18103
+ }
18104
+ function leafAt(parent, line) {
18105
+ line.advanceTo(line.text.length);
18106
+ return { block: { kind: "leaf", ...under(parent) }, children: false };
18107
+ }
18108
+ function frontMatterHolds(scan, parent) {
18109
+ return scan.unclosedFrontMatter && parent.kind === "document";
18110
+ }
18111
+ var BLOCK_PARSERS = [
18112
+ {
18113
+ triggers: "-=",
18114
+ interrupts: true,
18115
+ indented: false,
18116
+ open(scan, parent, line, _width, at) {
18117
+ const last = scan.opened.at(-1);
18118
+ if (last?.kind !== "paragraph" || last.parent !== parent)
18119
+ return;
18120
+ return setextUnderline(line.text.slice(at)) ? leafAt(parent, line) : undefined;
18121
+ }
18122
+ },
18123
+ {
18124
+ triggers: "-*_",
18125
+ interrupts: true,
18126
+ indented: false,
18127
+ open: (_scan, parent, line, _width, at) => thematicBreak(line.text.slice(at)) ? leafAt(parent, line) : undefined
18128
+ },
18129
+ {
18130
+ triggers: "-+*0123456789",
18131
+ interrupts: true,
18132
+ indented: false,
18133
+ open(scan, parent, line) {
18134
+ const last = scan.opened.at(-1);
18135
+ if (last?.kind === "list" || scan.skipList) {
18136
+ scan.skipList = false;
18137
+ return;
18138
+ }
18139
+ const marker = listMarker(line);
18140
+ if (marker === undefined || frontMatterHolds(scan, parent))
18141
+ return;
18142
+ if (marker.empty || marker.number !== undefined && marker.number !== "1") {
18143
+ if (last?.kind === "paragraph" && last.parent === parent)
18144
+ return;
18145
+ if (interruptsOpenBlock(scan, parent))
18146
+ return;
18147
+ }
18148
+ scan.emptyItemWithBlankLines = false;
18149
+ return { block: { kind: "list", marker: marker.char, ...under(parent) }, children: true };
18150
+ }
18151
+ },
18152
+ {
18153
+ triggers: "-+*0123456789",
18154
+ interrupts: true,
18155
+ indented: false,
18156
+ open(scan, parent, line) {
18157
+ if (parent.kind !== "list")
18158
+ return;
18159
+ const previous = parent.last?.kind === "item" ? parent.last.offset : 0;
18160
+ const marker = listMarker(line);
18161
+ if (marker === undefined || marker.indent - previous > 3)
18162
+ return;
18163
+ scan.emptyItemWithBlankLines = false;
18164
+ const after = line.spacesAt(marker.end);
18165
+ const spacing = marker.empty || after > 4 ? 1 : after;
18166
+ const offset = line.columnAt(marker.end) - line.column + spacing;
18167
+ const item = { kind: "item", offset, ...under(parent) };
18168
+ if (marker.empty)
18169
+ return { block: item, children: false };
18170
+ line.advanceTo(marker.end);
18171
+ line.skip(spacing);
18172
+ return { block: item, children: true };
18173
+ }
18174
+ },
18175
+ {
18176
+ interrupts: false,
18177
+ indented: true,
18178
+ open(scan, parent, line, width) {
18179
+ if (width < 4)
18180
+ return;
18181
+ line.skip(4);
18182
+ const previous = scan.lines[scan.index - 1];
18183
+ const block = {
18184
+ kind: "code",
18185
+ lastLine: scan.index,
18186
+ blankBefore: previous === undefined || /^[ \t]*$/.test(previous),
18187
+ ...under(parent)
18188
+ };
18189
+ return { block, children: false };
18190
+ }
18191
+ },
18192
+ {
18193
+ triggers: "#",
18194
+ interrupts: true,
18195
+ indented: false,
18196
+ open: (_scan, parent, line, _width, at) => /^#{1,6}(?:[ \t]|$)/.test(line.text.slice(at)) ? leafAt(parent, line) : undefined
18197
+ },
18198
+ {
18199
+ triggers: "`~",
18200
+ interrupts: true,
18201
+ indented: false,
18202
+ open(_scan, parent, line, _width, at) {
18203
+ const char = line.text.charAt(at);
18204
+ const length = runOf(line.text, at, char);
18205
+ if (length < 3)
18206
+ return;
18207
+ if (char === "`" && line.text.slice(at + length).includes("`"))
18208
+ return;
18209
+ line.advanceTo(line.text.length);
18210
+ return { block: { kind: "fence", char, length, ...under(parent) }, children: false };
18211
+ }
18212
+ },
18213
+ {
18214
+ triggers: ">",
18215
+ interrupts: true,
18216
+ indented: false,
18217
+ open: (scan, parent, line) => !frontMatterHolds(scan, parent) && quoteMarker(line) ? { block: { kind: "quote", ...under(parent) }, children: true } : undefined
18218
+ },
18219
+ {
18220
+ triggers: ":",
18221
+ interrupts: true,
18222
+ indented: false,
18223
+ open: (_scan, parent, line, _width, at) => refusedDirective(line.text.slice(at)) ? leafAt(parent, line) : undefined
18224
+ },
18225
+ {
18226
+ triggers: ":",
18227
+ interrupts: true,
18228
+ indented: false,
18229
+ open(scan, parent, line, width, at) {
18230
+ const opener = typedOpenerAt(line.text, at);
18231
+ if (opener === undefined)
18232
+ return;
18233
+ let draft;
18234
+ if (opener.name === "ask") {
18235
+ draft = { id: opener.id, lines: [] };
18236
+ scan.drafts.push(draft);
18237
+ }
18238
+ line.advanceTo(line.text.length);
18239
+ const block = {
18240
+ kind: "typed",
18241
+ fence: opener.colons,
18242
+ indent: width,
18243
+ draft,
18244
+ ...under(parent)
18245
+ };
18246
+ return { block, children: true };
18247
+ }
18248
+ },
18249
+ {
18250
+ triggers: "[",
18251
+ interrupts: true,
18252
+ indented: false,
18253
+ open(scan, parent, line, _width, at) {
18254
+ const definition = /^\[\^([^\]]*)\]:/.exec(line.text.slice(at));
18255
+ if (definition === null || /^\s*$/.test(definition[1] ?? ""))
18256
+ return;
18257
+ if (frontMatterHolds(scan, parent))
18258
+ return;
18259
+ const label = at + definition[0].length;
18260
+ const content = line.text.slice(label).search(/[^ \t]/);
18261
+ line.advanceTo(content < 0 ? label : label + content);
18262
+ return { block: { kind: "footnote", ...under(parent) }, children: true };
18263
+ }
18264
+ },
18265
+ {
18266
+ interrupts: false,
18267
+ indented: false,
18268
+ open: (scan, parent, line) => {
18269
+ const block = {
18270
+ kind: "paragraph",
18271
+ rows: [line.rest()],
18272
+ lastLine: scan.index,
18273
+ ...under(parent)
18274
+ };
18275
+ line.advanceTo(line.text.length);
18276
+ return { block, children: false };
18277
+ }
18278
+ }
18279
+ ];
18280
+ function interruptsOpenBlock(scan, parent) {
18281
+ let previous = parent.last;
18282
+ const opensContainers = previous === undefined;
18283
+ let node = parent;
18284
+ while (previous === undefined && node !== undefined && node.kind !== "document") {
18285
+ previous = node.previous;
18286
+ node = node.parent;
18287
+ }
18288
+ if (previous?.kind === "paragraph") {
18289
+ return opensContainers && !previous.rows.slice(1).some((row) => TABLE_DELIMITER_ROW.test(row)) && scan.index - previous.lastLine <= 1;
18290
+ }
18291
+ if (previous?.kind !== "code")
18292
+ return false;
18293
+ if (previous.previous?.kind === "list")
18294
+ return false;
18295
+ if (previous.previous?.kind === "quote" && !previous.blankBefore)
18296
+ return false;
18297
+ return scan.lines.slice(previous.lastLine + 1, scan.index).every((row) => /^[ \t>]*$/.test(row));
18298
+ }
18299
+ var TABLE_DELIMITER_ROW = /^(?=.*\|)[ \t]*\|?[ \t]*:?-+:?[ \t]*(?:\|[ \t]*:?-+:?[ \t]*)*\|?[ \t]*$/;
18300
+ function continueBlock(scan, block, line) {
18301
+ switch (block.kind) {
18302
+ case "quote":
18303
+ return quoteMarker(line) ? "children" : "close";
18304
+ case "list":
18305
+ return continueList(scan, block, line);
18306
+ case "item":
18307
+ return continueItem(scan, block, line);
18308
+ case "footnote": {
18309
+ if (line.blank())
18310
+ return "children";
18311
+ const { width } = line.indent();
18312
+ if (width < 4)
18313
+ return "close";
18314
+ line.skip(4);
18315
+ return "children";
18316
+ }
18317
+ case "typed": {
18318
+ const { width, at } = line.indent();
18319
+ if (width < 4 && at < line.text.length && fenceColons(line.text.slice(at)) >= block.fence) {
18320
+ line.advanceTo(line.text.length);
18321
+ return "close";
18322
+ }
18323
+ if (at < line.text.length)
18324
+ line.skip(Math.min(width, block.indent));
18325
+ block.draft?.lines.push(line.rest());
18326
+ return "children";
18327
+ }
18328
+ case "fence": {
18329
+ const { width, at } = line.indent();
18330
+ if (width < 4) {
18331
+ const length = runOf(line.text, at, block.char);
18332
+ if (length >= block.length && /^[ \t]*$/.test(line.text.slice(at + length))) {
18333
+ line.advanceTo(line.text.length);
18334
+ return "close";
18335
+ }
18336
+ }
18337
+ line.advanceTo(line.text.length);
18338
+ return "continue";
18339
+ }
18340
+ case "code": {
18341
+ if (line.blank())
18342
+ return "continue";
18343
+ if (line.indent().width < 4)
18344
+ return "close";
18345
+ block.lastLine = scan.index;
18346
+ line.advanceTo(line.text.length);
18347
+ return "continue";
18348
+ }
18349
+ default:
18350
+ return block.kind === "document" ? "children" : "close";
18351
+ }
18284
18352
  }
18285
- function legacyTwin(canonical) {
18286
- if (canonical.startsWith(DISPATCH_ISSUE_TOPIC_PREFIX)) {
18287
- const [project, key, ...rest] = canonical.slice(DISPATCH_ISSUE_TOPIC_PREFIX.length).split(".");
18288
- if (key === undefined || project === undefined)
18289
- return;
18290
- const keyProject = issueProject(key);
18291
- if (keyProject === undefined || project !== keyProject)
18292
- return;
18293
- return [`${DISPATCH_ISSUE_TOPIC_PREFIX}${key}`, ...rest].join(".");
18353
+ function continueList(scan, list, line) {
18354
+ const last = list.last;
18355
+ const lastIsEmpty = last === undefined || last.children === 0;
18356
+ if (line.blank()) {
18357
+ if (lastIsEmpty)
18358
+ scan.emptyItemWithBlankLines = true;
18359
+ return "children";
18294
18360
  }
18295
- for (const prefix of [AGENT_TOPIC_PREFIX, ROLE_TOPIC_PREFIX]) {
18296
- if (canonical.startsWith(prefix)) {
18297
- const rest = canonical.slice(prefix.length).split(".");
18298
- return rest.length === 2 && isProjectPosition(rest[0]) && isLiteral(rest[1]) ? `${prefix}${rest[1]}` : undefined;
18361
+ const offset = last?.kind === "item" ? last.offset : 0;
18362
+ const { width, at } = line.indent();
18363
+ if (width < offset || lastIsEmpty) {
18364
+ if (width < 4) {
18365
+ const marker = listMarker(line);
18366
+ if (marker !== undefined && marker.indent - offset < 4) {
18367
+ if (marker.char !== list.marker)
18368
+ return "close";
18369
+ const fromMarker = line.text.slice(at);
18370
+ const heading = scan.opened.at(-1)?.kind === "paragraph" && setextUnderline(fromMarker);
18371
+ if (thematicBreak(fromMarker) && !heading)
18372
+ return "close";
18373
+ return "children";
18374
+ }
18299
18375
  }
18376
+ if (!lastIsEmpty)
18377
+ return "close";
18300
18378
  }
18301
- if (canonical.startsWith(EXCEPTION_PREFIX)) {
18302
- const twin = legacyTwin(canonical.slice(EXCEPTION_PREFIX.length));
18303
- return twin === undefined ? undefined : `${EXCEPTION_PREFIX}${twin}`;
18379
+ if (lastIsEmpty && width < offset)
18380
+ return "close";
18381
+ if (scan.emptyItemWithBlankLines)
18382
+ return "close";
18383
+ return "children";
18384
+ }
18385
+ function continueItem(scan, item, line) {
18386
+ const { width } = line.indent();
18387
+ if (line.blank()) {
18388
+ line.skip(Math.min(width, item.offset));
18389
+ return "children";
18304
18390
  }
18305
- const kept = keptLane(canonical);
18306
- if (kept !== undefined && kept.rest.length === 2 && isProjectPosition(kept.rest[0])) {
18307
- const role = kept.rest[1];
18308
- return isLiteral(role) ? `${KEPT_PREFIX}${kept.kind}.${role}` : undefined;
18391
+ const isEmpty = item.children === 0 && scan.emptyItemWithBlankLines;
18392
+ if ((isEmpty || width < item.offset) && width < 4) {
18393
+ if (listMarker(line) !== undefined) {
18394
+ scan.skipList = true;
18395
+ return "close";
18396
+ }
18397
+ if (!isEmpty)
18398
+ return "close";
18309
18399
  }
18310
- return;
18311
- }
18312
- function topicForms(topic) {
18313
- const { canonical, legacy } = canonicalTopic(topic);
18314
- if (legacy)
18315
- return [topic, canonical];
18316
- const twin = legacyTwin(topic);
18317
- return twin === undefined ? [topic] : [topic, twin];
18318
- }
18319
- // ../contracts/src/tool-schema.ts
18320
- function overCapMessage(length, max) {
18321
- return `is ${length - max} characters over the ${max}-character limit (${length}/${max})`;
18400
+ line.skip(Math.min(width, item.offset));
18401
+ return "children";
18322
18402
  }
18323
- function literalOfSet(api, values) {
18324
- const node = api.literal?.(values);
18325
- if (node === undefined || typeof node.safeParse !== "function")
18403
+ function listMarker(line) {
18404
+ const { width, at } = line.indent();
18405
+ if (width > 3)
18406
+ return;
18407
+ const { text } = line;
18408
+ const first = text.charAt(at);
18409
+ let end = at;
18410
+ let number;
18411
+ if (first === "-" || first === "*" || first === "+") {
18412
+ end = at + 1;
18413
+ } else {
18414
+ while (end < text.length && end - at <= 9 && /[0-9]/.test(text.charAt(end)))
18415
+ end++;
18416
+ const delimiter = text.charAt(end);
18417
+ if (end === at || end - at > 9 || delimiter !== "." && delimiter !== ")")
18418
+ return;
18419
+ number = text.slice(at, end);
18420
+ end++;
18421
+ }
18422
+ const after = text.charAt(end);
18423
+ if (end < text.length && after !== " " && after !== "\t")
18326
18424
  return;
18327
- return values.every((value) => node.safeParse(value).success) ? node : undefined;
18328
- }
18329
- function zodSchemaApi(zod) {
18330
- const api = zod;
18331
18425
  return {
18332
- string: (opts = {}) => {
18333
- let schema = api.string();
18334
- if (opts.min !== undefined)
18335
- schema = schema.min(opts.min);
18336
- if (opts.max !== undefined) {
18337
- const max = opts.max;
18338
- const hint = opts.maxHint === undefined ? "" : `; ${opts.maxHint}`;
18339
- schema = schema.max(max, {
18340
- error: (issue) => overCapMessage(typeof issue.input === "string" ? issue.input.length : max + 1, max) + hint
18341
- });
18342
- }
18343
- return schema;
18344
- },
18345
- number: (opts = {}) => {
18346
- let schema = api.number();
18347
- if (opts.int)
18348
- schema = schema.int();
18349
- if (opts.min !== undefined)
18350
- schema = schema.min(opts.min);
18351
- if (opts.max !== undefined)
18352
- schema = schema.max(opts.max);
18353
- return schema;
18354
- },
18355
- boolean: () => api.boolean(),
18356
- enum: (values) => api.enum(values),
18357
- literal: (values) => literalOfSet(api, values) ?? api.unknown(),
18358
- unknown: () => api.unknown(),
18359
- array: (item, opts = {}) => {
18360
- let schema = api.array(item);
18361
- if (opts.min !== undefined)
18362
- schema = schema.min(opts.min);
18363
- if (opts.max !== undefined)
18364
- schema = schema.max(opts.max);
18365
- return schema;
18366
- },
18367
- object: (shape, opts = {}) => {
18368
- let schema = api.object(shape);
18369
- if (opts.strict)
18370
- schema = schema.strict();
18371
- return schema;
18372
- },
18373
- refineObject: (shape, check, message, opts = {}) => {
18374
- let schema = api.object(shape);
18375
- if (opts.strict)
18376
- schema = schema.strict();
18377
- return schema.refine(check, typeof message === "string" ? message : { error: (issue) => message(issue.input) });
18378
- }
18426
+ indent: width,
18427
+ end,
18428
+ char: text.charAt(end - 1),
18429
+ number,
18430
+ empty: /^[ \t]*$/.test(text.slice(end))
18379
18431
  };
18380
18432
  }
18433
+ function quoteMarker(line) {
18434
+ const { width, at } = line.indent();
18435
+ if (width > 3 || line.text.charAt(at) !== ">")
18436
+ return false;
18437
+ line.advanceTo(at + 1);
18438
+ const next = line.text.charAt(at + 1);
18439
+ if (next === " " || next === "\t")
18440
+ line.skip(1);
18441
+ return true;
18442
+ }
18443
+ function thematicBreak(text) {
18444
+ const marks = text.replace(/[ \t]/g, "");
18445
+ return marks.length >= 3 && /^(?:\*+|-+|_+)$/.test(marks);
18446
+ }
18447
+ function setextUnderline(text) {
18448
+ return /^(?:=+|-+)[ \t]*$/.test(text);
18449
+ }
18450
+ function fenceColons(text) {
18451
+ const trimmed = text.replace(/^[ \t]+|[ \t]+$/g, "");
18452
+ return /^:+$/.test(trimmed) ? trimmed.length : 0;
18453
+ }
18454
+
18381
18455
  // ../envoy-client/src/dispatch-command.ts
18382
18456
  var PREFIXED_FLAGS = [
18383
18457
  {
@@ -30473,27 +30547,157 @@ import { resolve as resolvePath2 } from "path";
30473
30547
  // ../contracts/src/go-blank.ts
30474
30548
  var goBlankPattern = /^[\t\n\v\f\r \u0085\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]*$/u;
30475
30549
 
30476
- // ../envoy-client/src/dispatch-commands/upload-checks.ts
30477
- function artifactUnderName(artifacts, name) {
30478
- const written = name.trim();
30479
- return artifacts.find((held) => held.slug === written) ?? artifacts.find((held) => held.name === written);
30550
+ // ../envoy-client/src/dispatch-commands/stored-spelling.ts
30551
+ function headedOpener(line) {
30552
+ for (let at = 0;at < line.length; at += Math.max(1, runOf(line, at, ":"))) {
30553
+ const brace = typedFenceBrace(line, at);
30554
+ if (brace === -1)
30555
+ continue;
30556
+ const opener = typedOpenerAt(line, at);
30557
+ return opener === undefined ? undefined : { ...opener, head: line.slice(0, brace + 1) };
30558
+ }
30559
+ return;
30480
30560
  }
30481
- function artifactNameExistsProblem(held, owner) {
30482
- const versions = held.versions ?? [];
30483
- const newest = versions[versions.length - 1];
30484
- if (newest === undefined) {
30485
- return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}), which has no version yet and which ${actorText(held.created_by)} created. ${ARTIFACT_NAME_EXISTS_RULE}`;
30561
+ function attributesByName(attributes) {
30562
+ const byName = new Map(attributes.map((attribute) => [attribute.name, attribute.text]));
30563
+ return byName.size === attributes.length ? byName : undefined;
30564
+ }
30565
+ function inStoredOrder(given, stored) {
30566
+ const written = attributesByName(given.attributes);
30567
+ if (written === undefined || attributesByName(stored.attributes) === undefined || stored.attributes.length !== given.attributes.length) {
30568
+ return;
30486
30569
  }
30487
- const authors = (newest.authors ?? []).map(actorText);
30488
- const wroteIt = authors.length === 0 ? actorText(held.created_by) : authors.join(" and ");
30489
- return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}) at version ${newest.number}, which ${wroteIt} wrote. ${ARTIFACT_NAME_EXISTS_RULE}`;
30570
+ let line = `${given.head}${given.gaps[0] ?? ""}`;
30571
+ for (const [index, attribute] of stored.attributes.entries()) {
30572
+ const text = written.get(attribute.name);
30573
+ if (text === undefined)
30574
+ return;
30575
+ line += `${text}${given.gaps[index + 1] ?? ""}`;
30576
+ }
30577
+ return `${line}}`;
30578
+ }
30579
+ function onlyReordered(given, held, stored) {
30580
+ return given !== undefined && stored !== undefined && inStoredOrder(given, stored) === held;
30581
+ }
30582
+ function reorderedBlockLine(line, opener) {
30583
+ const named = `${opener.name} block${opener.id === undefined ? "" : ` ${opener.id}`}`;
30584
+ const order = opener.attributes.map((attribute) => attribute.name).join(", ");
30585
+ return `This upload put the attributes of ${named} (line ${line}) in the order Dispatch stores: ${order}.`;
30586
+ }
30587
+ function attributesReordered(given, stored) {
30588
+ const written = withoutFinalLineFeed(given).split(`
30589
+ `);
30590
+ const holds = withoutFinalLineFeed(stored).split(`
30591
+ `);
30592
+ if (written.length !== holds.length)
30593
+ return;
30594
+ const lines = [];
30595
+ for (const [index, held] of holds.entries()) {
30596
+ const wrote = written[index];
30597
+ if (wrote === held)
30598
+ continue;
30599
+ const opener = headedOpener(held);
30600
+ if (wrote === undefined || opener === undefined || !onlyReordered(headedOpener(wrote), held, opener)) {
30601
+ return;
30602
+ }
30603
+ lines.push(reorderedBlockLine(index + 1, opener));
30604
+ }
30605
+ return lines;
30490
30606
  }
30491
30607
  var STORED_LINE_QUOTED = 200;
30492
- function quotedStoredLine(line) {
30493
- if (line.length <= STORED_LINE_QUOTED)
30494
- return JSON.stringify(line);
30495
- const head = JSON.stringify(line.slice(0, STORED_LINE_QUOTED));
30496
- return `${head} (cut after ${STORED_LINE_QUOTED} of its ${line.length} characters)`;
30608
+ function quotedStoredLine(characters, from) {
30609
+ const shown = characters.slice(from, from + STORED_LINE_QUOTED);
30610
+ const quote = JSON.stringify(shown.join(""));
30611
+ const cutAfter = from + shown.length < characters.length;
30612
+ if (from === 0 && !cutAfter)
30613
+ return quote;
30614
+ const cut = from === 0 ? "after" : cutAfter ? "before and after" : "before the last";
30615
+ return `${quote} (cut ${cut} ${shown.length} of its ${characters.length} characters)`;
30616
+ }
30617
+ function lineWords(line, opener) {
30618
+ const plain = (text) => (text.match(/\s+|\S+/g) ?? []).map((word) => ({ text: word, attribute: false }));
30619
+ if (opener === undefined)
30620
+ return plain(line);
30621
+ const words = plain(opener.head);
30622
+ for (const [index, gap] of opener.gaps.entries()) {
30623
+ if (gap !== "")
30624
+ words.push({ text: gap, attribute: false });
30625
+ const attribute = opener.attributes[index];
30626
+ if (attribute !== undefined)
30627
+ words.push({ text: attribute.text, attribute: true });
30628
+ }
30629
+ words.push({ text: "}", attribute: false });
30630
+ return words;
30631
+ }
30632
+ function wordText(word, from = 0, characters = Array.from(word.text)) {
30633
+ if (word.attribute)
30634
+ return `the attribute ${word.text}`;
30635
+ return `${/\S/.test(word.text) ? "the word" : "the space"} ${quotedStoredLine(characters, from)}`;
30636
+ }
30637
+ function wordDifference(written, holds) {
30638
+ let before = 0;
30639
+ for (let index = 0;index < Math.max(written.length, holds.length); index += 1) {
30640
+ const given = written[index];
30641
+ const stored = holds[index];
30642
+ if (given !== undefined && stored !== undefined && given.text === stored.text) {
30643
+ before += Array.from(given.text).length;
30644
+ continue;
30645
+ }
30646
+ if (given === undefined && stored !== undefined) {
30647
+ return `ends after character ${before}, where Dispatch goes on with ${wordText(stored)}`;
30648
+ }
30649
+ if (given !== undefined && stored === undefined) {
30650
+ return `reads ${wordText(given)} at character ${before + 1}, where Dispatch ends the line`;
30651
+ }
30652
+ if (given !== undefined && stored !== undefined) {
30653
+ const wrote = Array.from(given.text);
30654
+ const held = Array.from(stored.text);
30655
+ let from = 0;
30656
+ if (!given.attribute && !stored.attribute && Math.max(wrote.length, held.length) > STORED_LINE_QUOTED) {
30657
+ while (from < wrote.length && wrote[from] === held[from])
30658
+ from += 1;
30659
+ const tail = Math.max(0, from - STORED_LINE_QUOTED);
30660
+ if (from === wrote.length) {
30661
+ return `ends ${wordText(given, tail, wrote)} after character ${before + from}, where Dispatch goes on with ${wordText(stored, from, held)}`;
30662
+ }
30663
+ if (from === held.length) {
30664
+ return `reads ${wordText(given, from, wrote)} at character ${before + from + 1}, where Dispatch ends ${wordText(stored, tail, held)}`;
30665
+ }
30666
+ }
30667
+ return `reads ${wordText(given, from, wrote)} at character ${before + from + 1}, where Dispatch stores ${wordText(stored, from, held)}`;
30668
+ }
30669
+ }
30670
+ return "differs from the line Dispatch stores";
30671
+ }
30672
+ function attributeDifference(line, given, stored) {
30673
+ const written = attributesByName(given.attributes);
30674
+ if (written === undefined)
30675
+ return;
30676
+ for (const attribute of stored.attributes) {
30677
+ const text = written.get(attribute.name);
30678
+ if (text === undefined)
30679
+ return `Dispatch adds the attribute ${attribute.text} to line ${line}`;
30680
+ if (text !== attribute.text) {
30681
+ return `line ${line} holds the attribute ${text}, which Dispatch stores as ${attribute.text}`;
30682
+ }
30683
+ }
30684
+ const held = new Set(stored.attributes.map((attribute) => attribute.name));
30685
+ const dropped = given.attributes.find((attribute) => !held.has(attribute.name));
30686
+ return dropped === undefined ? undefined : `line ${line} holds the attribute ${dropped.text}, which Dispatch drops`;
30687
+ }
30688
+ function lineDifference(line, wrote, given, held, stored) {
30689
+ if (given === undefined || stored === undefined) {
30690
+ return `line ${line} ${wordDifference(lineWords(wrote, undefined), lineWords(held, undefined))}`;
30691
+ }
30692
+ const attribute = attributeDifference(line, given, stored);
30693
+ if (attribute !== undefined)
30694
+ return attribute;
30695
+ const reordered = inStoredOrder(given, stored);
30696
+ if (reordered !== undefined && reordered !== wrote) {
30697
+ const words = lineWords(reordered, headedOpener(reordered));
30698
+ return `line ${line}, with its attributes put in the order Dispatch stores, ${wordDifference(words, lineWords(held, stored))}`;
30699
+ }
30700
+ return `line ${line} ${wordDifference(lineWords(wrote, given), lineWords(held, stored))}`;
30497
30701
  }
30498
30702
  function firstStoredDifference(given, stored) {
30499
30703
  const written = given.split(`
@@ -30506,13 +30710,17 @@ function firstStoredDifference(given, stored) {
30506
30710
  if (wrote === held)
30507
30711
  continue;
30508
30712
  if (wrote === undefined && held !== undefined) {
30509
- return `the store writes a line ${line + 1}, ${quotedStoredLine(held)}`;
30713
+ return `the store writes a line ${line + 1}, ${quotedStoredLine(Array.from(held), 0)}`;
30510
30714
  }
30511
30715
  if (held === undefined && wrote !== undefined) {
30512
- return `the store drops line ${line + 1}, ${quotedStoredLine(wrote)}`;
30716
+ return `the store drops line ${line + 1}, ${quotedStoredLine(Array.from(wrote), 0)}`;
30513
30717
  }
30514
30718
  if (wrote !== undefined && held !== undefined) {
30515
- return `line ${line + 1} reads ${quotedStoredLine(wrote)} and is stored as ${quotedStoredLine(held)}`;
30719
+ const givenOpener = headedOpener(wrote);
30720
+ const storedOpener = headedOpener(held);
30721
+ if (onlyReordered(givenOpener, held, storedOpener))
30722
+ continue;
30723
+ return lineDifference(line + 1, wrote, givenOpener, held, storedOpener);
30516
30724
  }
30517
30725
  }
30518
30726
  return "the stored text differs from the text given";
@@ -30542,6 +30750,33 @@ ${printed.text}`,
30542
30750
  "--- end of the text Dispatch stores ---"
30543
30751
  ].join("");
30544
30752
  }
30753
+ function withoutFinalLineFeed(text) {
30754
+ return text.endsWith(`
30755
+ `) ? text.slice(0, -1) : text;
30756
+ }
30757
+ function storedUpload(given, stored, name) {
30758
+ if (withoutFinalLineFeed(stored) === withoutFinalLineFeed(given)) {
30759
+ return { sent: given, reordered: [] };
30760
+ }
30761
+ const reordered = attributesReordered(given, stored);
30762
+ return reordered === undefined ? { refusal: storedTextProblem(given, stored, name) } : { sent: stored, reordered };
30763
+ }
30764
+
30765
+ // ../envoy-client/src/dispatch-commands/upload-checks.ts
30766
+ function artifactUnderName(artifacts, name) {
30767
+ const written = name.trim();
30768
+ return artifacts.find((held) => held.slug === written) ?? artifacts.find((held) => held.name === written);
30769
+ }
30770
+ function artifactNameExistsProblem(held, owner) {
30771
+ const versions = held.versions ?? [];
30772
+ const newest = versions[versions.length - 1];
30773
+ if (newest === undefined) {
30774
+ return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}), which has no version yet and which ${actorText(held.created_by)} created. ${ARTIFACT_NAME_EXISTS_RULE}`;
30775
+ }
30776
+ const authors = (newest.authors ?? []).map(actorText);
30777
+ const wroteIt = authors.length === 0 ? actorText(held.created_by) : authors.join(" and ");
30778
+ return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}) at version ${newest.number}, which ${wroteIt} wrote. ${ARTIFACT_NAME_EXISTS_RULE}`;
30779
+ }
30545
30780
  function storedTextCheckFailed(error, name) {
30546
30781
  const failure = `Dispatch could not say how it would store this text, so nothing was uploaded: POST /api/v1/markdown/round-trip failed with ${messageFor(error)}.`;
30547
30782
  if (!dispatchAnswered(error, 413)) {
@@ -30553,10 +30788,6 @@ function storedTextCheckFailed(error, name) {
30553
30788
  function roundTripRouteAbsent(error) {
30554
30789
  return dispatchAnswered(error, 404) || dispatchAnswered(error, 405);
30555
30790
  }
30556
- function withoutFinalLineFeed(text) {
30557
- return text.endsWith(`
30558
- `) ? text.slice(0, -1) : text;
30559
- }
30560
30791
 
30561
30792
  // ../envoy-client/src/dispatch-commands/documents.ts
30562
30793
  async function blockAsks(client, resolved, state) {
@@ -30940,6 +31171,8 @@ async function artifactCommand(context) {
30940
31171
  ]);
30941
31172
  }
30942
31173
  }
31174
+ let sent = content;
31175
+ let reordered = [];
30943
31176
  if (!blank) {
30944
31177
  let stored;
30945
31178
  try {
@@ -30949,8 +31182,12 @@ async function artifactCommand(context) {
30949
31182
  throw new Error(storedTextCheckFailed(error, name), { cause: error });
30950
31183
  }
30951
31184
  }
30952
- if (stored !== undefined && withoutFinalLineFeed(stored) !== withoutFinalLineFeed(content)) {
30953
- throw new ToolInputError(input.tool, [storedTextProblem(content, stored, name)]);
31185
+ if (stored !== undefined) {
31186
+ const upload = storedUpload(content, stored, name);
31187
+ if ("refusal" in upload)
31188
+ throw new ToolInputError(input.tool, [upload.refusal]);
31189
+ sent = upload.sent;
31190
+ reordered = upload.reordered;
30954
31191
  }
30955
31192
  }
30956
31193
  const artifactInput = path !== undefined ? {
@@ -30958,7 +31195,7 @@ async function artifactCommand(context) {
30958
31195
  file: input.uploadBytes === undefined ? Bun.file(resolvePath2(input.cwd, path)) : new Blob([new Uint8Array(input.uploadBytes)], {
30959
31196
  type: Bun.file(resolvePath2(input.cwd, path)).type
30960
31197
  })
30961
- } : content !== undefined ? { ...options, content } : options;
31198
+ } : sent !== undefined ? { ...options, content: sent } : options;
30962
31199
  const result = artifactOwner.kind === "project" ? await client.projectArtifact(artifactOwner.project, artifactInput) : await client.artifact(issue(), artifactInput);
30963
31200
  const artifactRef = dispatchDocumentRef(artifactOwner.kind === "project" ? artifactOwner.project : issue(), result.artifact.slug);
30964
31201
  const uploadOwner = artifactOwner.kind === "project" ? documentTopic(result.artifact) : issueTopic(issue());
@@ -30969,6 +31206,7 @@ async function artifactCommand(context) {
30969
31206
  return {
30970
31207
  text: [
30971
31208
  path === undefined && content === undefined ? `Made ${result.artifact.name} as an empty document (artifact slug ${result.artifact.slug}; ${artifactRef}). Write in it with dispatch doc-edit.${await notSubscribed(uploadOwner, input.subscriptions)}` : `Uploaded ${result.artifact.name} as version ${result.version.number} (artifact slug ${result.artifact.slug}; ${artifactRef})${await notSubscribed(uploadOwner, input.subscriptions)}`,
31209
+ ...reordered,
30972
31210
  ...adviceLines
30973
31211
  ].join(`
30974
31212
  `),