prettier 3.0.0-alpha.0 → 3.0.0-alpha.2

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.
Files changed (56) hide show
  1. package/LICENSE +51 -67
  2. package/{bin-prettier.js → bin/prettier.cjs} +2 -2
  3. package/doc.js +438 -221
  4. package/doc.mjs +1490 -0
  5. package/index.cjs +532 -0
  6. package/{index.js → index.mjs} +4411 -5763
  7. package/{cli.mjs → internal/cli.mjs} +150 -94
  8. package/{third-party.js → internal/third-party.mjs} +129 -100
  9. package/package.json +139 -6
  10. package/plugins/acorn-and-espree.js +13 -0
  11. package/plugins/acorn-and-espree.mjs +13 -0
  12. package/plugins/angular.js +2 -0
  13. package/plugins/angular.mjs +2 -0
  14. package/plugins/babel.js +16 -0
  15. package/plugins/babel.mjs +16 -0
  16. package/plugins/flow.js +21 -0
  17. package/plugins/flow.mjs +21 -0
  18. package/{parser-glimmer.js → plugins/glimmer.js} +9 -9
  19. package/{esm/parser-glimmer.mjs → plugins/glimmer.mjs} +10 -10
  20. package/plugins/graphql.js +9 -0
  21. package/plugins/graphql.mjs +9 -0
  22. package/plugins/html.js +29 -0
  23. package/plugins/html.mjs +29 -0
  24. package/plugins/markdown.js +39 -0
  25. package/plugins/markdown.mjs +39 -0
  26. package/plugins/meriyah.js +6 -0
  27. package/plugins/meriyah.mjs +6 -0
  28. package/plugins/postcss.js +50 -0
  29. package/plugins/postcss.mjs +50 -0
  30. package/plugins/typescript.js +242 -0
  31. package/plugins/typescript.mjs +242 -0
  32. package/{parser-yaml.js → plugins/yaml.js} +1 -1
  33. package/{esm/parser-yaml.mjs → plugins/yaml.mjs} +1 -1
  34. package/standalone.js +70 -87
  35. package/standalone.mjs +107 -0
  36. package/esm/parser-angular.mjs +0 -2
  37. package/esm/parser-babel.mjs +0 -18
  38. package/esm/parser-espree.mjs +0 -15
  39. package/esm/parser-flow.mjs +0 -23
  40. package/esm/parser-graphql.mjs +0 -9
  41. package/esm/parser-html.mjs +0 -28
  42. package/esm/parser-markdown.mjs +0 -60
  43. package/esm/parser-meriyah.mjs +0 -8
  44. package/esm/parser-postcss.mjs +0 -53
  45. package/esm/parser-typescript.mjs +0 -269
  46. package/esm/standalone.mjs +0 -124
  47. package/parser-angular.js +0 -2
  48. package/parser-babel.js +0 -18
  49. package/parser-espree.js +0 -15
  50. package/parser-flow.js +0 -23
  51. package/parser-graphql.js +0 -9
  52. package/parser-html.js +0 -28
  53. package/parser-markdown.js +0 -60
  54. package/parser-meriyah.js +0 -8
  55. package/parser-postcss.js +0 -53
  56. package/parser-typescript.js +0 -269
package/doc.mjs ADDED
@@ -0,0 +1,1490 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
11
+ var __commonJS = (cb, mod) => function __require() {
12
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13
+ };
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __publicField = (obj, key, value) => {
31
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
32
+ return value;
33
+ };
34
+
35
+ // <define:process>
36
+ var init_define_process = __esm({
37
+ "<define:process>"() {
38
+ }
39
+ });
40
+
41
+ // node_modules/string-width/node_modules/emoji-regex/index.js
42
+ var require_emoji_regex = __commonJS({
43
+ "node_modules/string-width/node_modules/emoji-regex/index.js"(exports, module) {
44
+ "use strict";
45
+ init_define_process();
46
+ module.exports = function() {
47
+ return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93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C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\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42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
48
+ };
49
+ }
50
+ });
51
+
52
+ // src/document/index.js
53
+ init_define_process();
54
+
55
+ // src/document/builders.js
56
+ var builders_exports = {};
57
+ __export(builders_exports, {
58
+ addAlignmentToDoc: () => addAlignmentToDoc,
59
+ align: () => align,
60
+ breakParent: () => breakParent,
61
+ concat: () => concat,
62
+ conditionalGroup: () => conditionalGroup,
63
+ cursor: () => cursor,
64
+ dedent: () => dedent,
65
+ dedentToRoot: () => dedentToRoot,
66
+ fill: () => fill,
67
+ group: () => group,
68
+ hardline: () => hardline,
69
+ hardlineWithoutBreakParent: () => hardlineWithoutBreakParent,
70
+ ifBreak: () => ifBreak,
71
+ indent: () => indent,
72
+ indentIfBreak: () => indentIfBreak,
73
+ join: () => join,
74
+ label: () => label,
75
+ line: () => line,
76
+ lineSuffix: () => lineSuffix,
77
+ lineSuffixBoundary: () => lineSuffixBoundary,
78
+ literalline: () => literalline,
79
+ literallineWithoutBreakParent: () => literallineWithoutBreakParent,
80
+ markAsRoot: () => markAsRoot,
81
+ softline: () => softline,
82
+ trim: () => trim
83
+ });
84
+ init_define_process();
85
+
86
+ // src/document/constants.js
87
+ init_define_process();
88
+ var DOC_TYPE_STRING = "string";
89
+ var DOC_TYPE_ARRAY = "array";
90
+ var DOC_TYPE_CURSOR = "cursor";
91
+ var DOC_TYPE_INDENT = "indent";
92
+ var DOC_TYPE_ALIGN = "align";
93
+ var DOC_TYPE_TRIM = "trim";
94
+ var DOC_TYPE_GROUP = "group";
95
+ var DOC_TYPE_FILL = "fill";
96
+ var DOC_TYPE_IF_BREAK = "if-break";
97
+ var DOC_TYPE_INDENT_IF_BREAK = "indent-if-break";
98
+ var DOC_TYPE_LINE_SUFFIX = "line-suffix";
99
+ var DOC_TYPE_LINE_SUFFIX_BOUNDARY = "line-suffix-boundary";
100
+ var DOC_TYPE_LINE = "line";
101
+ var DOC_TYPE_LABEL = "label";
102
+ var DOC_TYPE_BREAK_PARENT = "break-parent";
103
+ var VALID_OBJECT_DOC_TYPES = /* @__PURE__ */ new Set([
104
+ DOC_TYPE_CURSOR,
105
+ DOC_TYPE_INDENT,
106
+ DOC_TYPE_ALIGN,
107
+ DOC_TYPE_TRIM,
108
+ DOC_TYPE_GROUP,
109
+ DOC_TYPE_FILL,
110
+ DOC_TYPE_IF_BREAK,
111
+ DOC_TYPE_INDENT_IF_BREAK,
112
+ DOC_TYPE_LINE_SUFFIX,
113
+ DOC_TYPE_LINE_SUFFIX_BOUNDARY,
114
+ DOC_TYPE_LINE,
115
+ DOC_TYPE_LABEL,
116
+ DOC_TYPE_BREAK_PARENT
117
+ ]);
118
+
119
+ // src/document/builders.js
120
+ function indent(contents) {
121
+ if (false) {
122
+ assertDoc(contents);
123
+ }
124
+ return { type: DOC_TYPE_INDENT, contents };
125
+ }
126
+ function align(widthOrString, contents) {
127
+ if (false) {
128
+ assertDoc(contents);
129
+ }
130
+ return { type: DOC_TYPE_ALIGN, contents, n: widthOrString };
131
+ }
132
+ function group(contents, opts = {}) {
133
+ if (false) {
134
+ assertDoc(contents);
135
+ }
136
+ return {
137
+ type: DOC_TYPE_GROUP,
138
+ id: opts.id,
139
+ contents,
140
+ break: Boolean(opts.shouldBreak),
141
+ expandedStates: opts.expandedStates
142
+ };
143
+ }
144
+ function dedentToRoot(contents) {
145
+ return align(Number.NEGATIVE_INFINITY, contents);
146
+ }
147
+ function markAsRoot(contents) {
148
+ return align({ type: "root" }, contents);
149
+ }
150
+ function dedent(contents) {
151
+ return align(-1, contents);
152
+ }
153
+ function conditionalGroup(states, opts) {
154
+ return group(states[0], { ...opts, expandedStates: states });
155
+ }
156
+ function fill(parts) {
157
+ if (false) {
158
+ for (const part of parts) {
159
+ assertDoc(part);
160
+ }
161
+ }
162
+ return { type: DOC_TYPE_FILL, parts };
163
+ }
164
+ function ifBreak(breakContents, flatContents, opts = {}) {
165
+ if (false) {
166
+ if (breakContents) {
167
+ assertDoc(breakContents);
168
+ }
169
+ if (flatContents) {
170
+ assertDoc(flatContents);
171
+ }
172
+ }
173
+ return {
174
+ type: DOC_TYPE_IF_BREAK,
175
+ breakContents,
176
+ flatContents,
177
+ groupId: opts.groupId
178
+ };
179
+ }
180
+ function indentIfBreak(contents, opts) {
181
+ return {
182
+ type: DOC_TYPE_INDENT_IF_BREAK,
183
+ contents,
184
+ groupId: opts.groupId,
185
+ negate: opts.negate
186
+ };
187
+ }
188
+ function lineSuffix(contents) {
189
+ if (false) {
190
+ assertDoc(contents);
191
+ }
192
+ return { type: DOC_TYPE_LINE_SUFFIX, contents };
193
+ }
194
+ var lineSuffixBoundary = { type: DOC_TYPE_LINE_SUFFIX_BOUNDARY };
195
+ var breakParent = { type: DOC_TYPE_BREAK_PARENT };
196
+ var trim = { type: DOC_TYPE_TRIM };
197
+ var hardlineWithoutBreakParent = { type: DOC_TYPE_LINE, hard: true };
198
+ var literallineWithoutBreakParent = {
199
+ type: DOC_TYPE_LINE,
200
+ hard: true,
201
+ literal: true
202
+ };
203
+ var line = { type: DOC_TYPE_LINE };
204
+ var softline = { type: DOC_TYPE_LINE, soft: true };
205
+ var hardline = [hardlineWithoutBreakParent, breakParent];
206
+ var literalline = [literallineWithoutBreakParent, breakParent];
207
+ var cursor = { type: DOC_TYPE_CURSOR };
208
+ function join(sep, arr) {
209
+ const res = [];
210
+ for (let i = 0; i < arr.length; i++) {
211
+ if (i !== 0) {
212
+ res.push(sep);
213
+ }
214
+ res.push(arr[i]);
215
+ }
216
+ return res;
217
+ }
218
+ function addAlignmentToDoc(doc, size, tabWidth) {
219
+ let aligned = doc;
220
+ if (size > 0) {
221
+ for (let i = 0; i < Math.floor(size / tabWidth); ++i) {
222
+ aligned = indent(aligned);
223
+ }
224
+ aligned = align(size % tabWidth, aligned);
225
+ aligned = align(Number.NEGATIVE_INFINITY, aligned);
226
+ }
227
+ return aligned;
228
+ }
229
+ function label(label2, contents) {
230
+ return label2 ? { type: DOC_TYPE_LABEL, label: label2, contents } : contents;
231
+ }
232
+ var concat = (parts) => parts;
233
+
234
+ // src/document/printer.js
235
+ var printer_exports = {};
236
+ __export(printer_exports, {
237
+ printDocToString: () => printDocToString
238
+ });
239
+ init_define_process();
240
+
241
+ // scripts/build/shims/at.js
242
+ init_define_process();
243
+ var at = (isOptionalObject, object, index, ...args) => {
244
+ if (isOptionalObject && (object === void 0 || object === null)) {
245
+ return;
246
+ }
247
+ return object.at ? object.at(index, ...args) : object[index < 0 ? object.length + index : index];
248
+ };
249
+ var at_default = at;
250
+
251
+ // src/common/end-of-line.js
252
+ init_define_process();
253
+ function convertEndOfLineToChars(value) {
254
+ switch (value) {
255
+ case "cr":
256
+ return "\r";
257
+ case "crlf":
258
+ return "\r\n";
259
+ default:
260
+ return "\n";
261
+ }
262
+ }
263
+
264
+ // src/utils/get-string-width.js
265
+ init_define_process();
266
+
267
+ // node_modules/string-width/index.js
268
+ init_define_process();
269
+
270
+ // node_modules/strip-ansi/index.js
271
+ init_define_process();
272
+
273
+ // node_modules/strip-ansi/node_modules/ansi-regex/index.js
274
+ init_define_process();
275
+ function ansiRegex({ onlyFirst = false } = {}) {
276
+ const pattern = [
277
+ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
278
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
279
+ ].join("|");
280
+ return new RegExp(pattern, onlyFirst ? void 0 : "g");
281
+ }
282
+
283
+ // node_modules/strip-ansi/index.js
284
+ function stripAnsi(string) {
285
+ if (typeof string !== "string") {
286
+ throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
287
+ }
288
+ return string.replace(ansiRegex(), "");
289
+ }
290
+
291
+ // node_modules/string-width/node_modules/is-fullwidth-code-point/index.js
292
+ init_define_process();
293
+ function isFullwidthCodePoint(codePoint) {
294
+ if (!Number.isInteger(codePoint)) {
295
+ return false;
296
+ }
297
+ return codePoint >= 4352 && (codePoint <= 4447 || codePoint === 9001 || codePoint === 9002 || 11904 <= codePoint && codePoint <= 12871 && codePoint !== 12351 || 12880 <= codePoint && codePoint <= 19903 || 19968 <= codePoint && codePoint <= 42182 || 43360 <= codePoint && codePoint <= 43388 || 44032 <= codePoint && codePoint <= 55203 || 63744 <= codePoint && codePoint <= 64255 || 65040 <= codePoint && codePoint <= 65049 || 65072 <= codePoint && codePoint <= 65131 || 65281 <= codePoint && codePoint <= 65376 || 65504 <= codePoint && codePoint <= 65510 || 110592 <= codePoint && codePoint <= 110593 || 127488 <= codePoint && codePoint <= 127569 || 131072 <= codePoint && codePoint <= 262141);
298
+ }
299
+
300
+ // node_modules/string-width/index.js
301
+ var import_emoji_regex = __toESM(require_emoji_regex(), 1);
302
+ function stringWidth(string) {
303
+ if (typeof string !== "string" || string.length === 0) {
304
+ return 0;
305
+ }
306
+ string = stripAnsi(string);
307
+ if (string.length === 0) {
308
+ return 0;
309
+ }
310
+ string = string.replace((0, import_emoji_regex.default)(), " ");
311
+ let width = 0;
312
+ for (let index = 0; index < string.length; index++) {
313
+ const codePoint = string.codePointAt(index);
314
+ if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
315
+ continue;
316
+ }
317
+ if (codePoint >= 768 && codePoint <= 879) {
318
+ continue;
319
+ }
320
+ if (codePoint > 65535) {
321
+ index++;
322
+ }
323
+ width += isFullwidthCodePoint(codePoint) ? 2 : 1;
324
+ }
325
+ return width;
326
+ }
327
+
328
+ // src/utils/get-string-width.js
329
+ var notAsciiRegex = /[^\x20-\x7F]/;
330
+ function getStringWidth(text) {
331
+ if (!text) {
332
+ return 0;
333
+ }
334
+ if (!notAsciiRegex.test(text)) {
335
+ return text.length;
336
+ }
337
+ return stringWidth(text);
338
+ }
339
+ var get_string_width_default = getStringWidth;
340
+
341
+ // src/document/utils.js
342
+ var utils_exports = {};
343
+ __export(utils_exports, {
344
+ canBreak: () => canBreak,
345
+ cleanDoc: () => cleanDoc,
346
+ findInDoc: () => findInDoc,
347
+ getDocParts: () => getDocParts,
348
+ getDocType: () => get_doc_type_default,
349
+ mapDoc: () => mapDoc,
350
+ normalizeDoc: () => normalizeDoc,
351
+ normalizeParts: () => normalizeParts,
352
+ propagateBreaks: () => propagateBreaks,
353
+ removeLines: () => removeLines,
354
+ replaceEndOfLine: () => replaceEndOfLine,
355
+ stripTrailingHardline: () => stripTrailingHardline,
356
+ traverseDoc: () => traverse_doc_default,
357
+ willBreak: () => willBreak
358
+ });
359
+ init_define_process();
360
+
361
+ // src/document/utils/get-doc-type.js
362
+ init_define_process();
363
+ function getDocType(doc) {
364
+ if (typeof doc === "string") {
365
+ return DOC_TYPE_STRING;
366
+ }
367
+ if (Array.isArray(doc)) {
368
+ return DOC_TYPE_ARRAY;
369
+ }
370
+ if (!doc) {
371
+ return;
372
+ }
373
+ const { type } = doc;
374
+ if (VALID_OBJECT_DOC_TYPES.has(type)) {
375
+ return type;
376
+ }
377
+ }
378
+ var get_doc_type_default = getDocType;
379
+
380
+ // src/document/utils/traverse-doc.js
381
+ init_define_process();
382
+
383
+ // src/document/invalid-doc-error.js
384
+ init_define_process();
385
+ var disjunctionListFormat = (list) => [...list.slice(0, -1), `or ${at_default(false, list, -1)}`].join(", ");
386
+ function getDocErrorMessage(doc) {
387
+ const type = doc === null ? null : typeof doc;
388
+ if (type !== "string" && type !== "object") {
389
+ return `Unexpected doc '${type}',
390
+ Expected it to be 'string' or 'object'.`;
391
+ }
392
+ if (get_doc_type_default(doc)) {
393
+ throw new Error("doc is valid.");
394
+ }
395
+ const objectType = Object.prototype.toString.call(doc);
396
+ if (objectType !== "[object Object]") {
397
+ return `Unexpected doc '${objectType}'.`;
398
+ }
399
+ const EXPECTED_TYPE_VALUES = disjunctionListFormat([...VALID_OBJECT_DOC_TYPES].map((type2) => `'${type2}'`));
400
+ return `Unexpected doc.type '${doc.type}'.
401
+ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
402
+ }
403
+ var InvalidDocError = class extends Error {
404
+ constructor(doc) {
405
+ super(getDocErrorMessage(doc));
406
+ __publicField(this, "name", "InvalidDocError");
407
+ this.doc = doc;
408
+ }
409
+ };
410
+ var invalid_doc_error_default = InvalidDocError;
411
+
412
+ // src/document/utils/traverse-doc.js
413
+ var traverseDocOnExitStackMarker = {};
414
+ function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
415
+ const docsStack = [doc];
416
+ while (docsStack.length > 0) {
417
+ const doc2 = docsStack.pop();
418
+ if (doc2 === traverseDocOnExitStackMarker) {
419
+ onExit(docsStack.pop());
420
+ continue;
421
+ }
422
+ if (onExit) {
423
+ docsStack.push(doc2, traverseDocOnExitStackMarker);
424
+ }
425
+ if ((onEnter == null ? void 0 : onEnter(doc2)) === false) {
426
+ continue;
427
+ }
428
+ const docType = get_doc_type_default(doc2);
429
+ switch (docType) {
430
+ case DOC_TYPE_ARRAY:
431
+ case DOC_TYPE_FILL: {
432
+ const parts = docType === DOC_TYPE_ARRAY ? doc2 : doc2.parts;
433
+ for (let ic = parts.length, i = ic - 1; i >= 0; --i) {
434
+ docsStack.push(parts[i]);
435
+ }
436
+ break;
437
+ }
438
+ case DOC_TYPE_IF_BREAK:
439
+ if (doc2.flatContents) {
440
+ docsStack.push(doc2.flatContents);
441
+ }
442
+ if (doc2.breakContents) {
443
+ docsStack.push(doc2.breakContents);
444
+ }
445
+ break;
446
+ case DOC_TYPE_GROUP:
447
+ if (shouldTraverseConditionalGroups && doc2.expandedStates) {
448
+ for (let ic = doc2.expandedStates.length, i = ic - 1; i >= 0; --i) {
449
+ docsStack.push(doc2.expandedStates[i]);
450
+ }
451
+ } else {
452
+ docsStack.push(doc2.contents);
453
+ }
454
+ break;
455
+ case DOC_TYPE_ALIGN:
456
+ case DOC_TYPE_INDENT:
457
+ case DOC_TYPE_INDENT_IF_BREAK:
458
+ case DOC_TYPE_LABEL:
459
+ case DOC_TYPE_LINE_SUFFIX:
460
+ docsStack.push(doc2.contents);
461
+ break;
462
+ case DOC_TYPE_STRING:
463
+ case DOC_TYPE_CURSOR:
464
+ case DOC_TYPE_TRIM:
465
+ case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
466
+ case DOC_TYPE_LINE:
467
+ case DOC_TYPE_BREAK_PARENT:
468
+ break;
469
+ default:
470
+ throw new invalid_doc_error_default(doc2);
471
+ }
472
+ }
473
+ }
474
+ var traverse_doc_default = traverseDoc;
475
+
476
+ // src/document/utils.js
477
+ var getDocParts = (doc) => {
478
+ if (Array.isArray(doc)) {
479
+ return doc;
480
+ }
481
+ if (doc.type !== DOC_TYPE_FILL) {
482
+ throw new Error(`Expect doc to be 'array' or '${DOC_TYPE_FILL}'.`);
483
+ }
484
+ return doc.parts;
485
+ };
486
+ function mapDoc(doc, cb) {
487
+ if (typeof doc === "string") {
488
+ return cb(doc);
489
+ }
490
+ const mapped = /* @__PURE__ */ new Map();
491
+ return rec(doc);
492
+ function rec(doc2) {
493
+ if (mapped.has(doc2)) {
494
+ return mapped.get(doc2);
495
+ }
496
+ const result = process2(doc2);
497
+ mapped.set(doc2, result);
498
+ return result;
499
+ }
500
+ function process2(doc2) {
501
+ switch (get_doc_type_default(doc2)) {
502
+ case DOC_TYPE_ARRAY:
503
+ return cb(doc2.map(rec));
504
+ case DOC_TYPE_FILL:
505
+ return cb({
506
+ ...doc2,
507
+ parts: doc2.parts.map(rec)
508
+ });
509
+ case DOC_TYPE_IF_BREAK: {
510
+ let {
511
+ breakContents,
512
+ flatContents
513
+ } = doc2;
514
+ breakContents && (breakContents = rec(breakContents));
515
+ flatContents && (flatContents = rec(flatContents));
516
+ return cb({
517
+ ...doc2,
518
+ breakContents,
519
+ flatContents
520
+ });
521
+ }
522
+ case DOC_TYPE_GROUP: {
523
+ let {
524
+ expandedStates,
525
+ contents
526
+ } = doc2;
527
+ if (expandedStates) {
528
+ expandedStates = expandedStates.map(rec);
529
+ contents = expandedStates[0];
530
+ } else {
531
+ contents = rec(contents);
532
+ }
533
+ return cb({
534
+ ...doc2,
535
+ contents,
536
+ expandedStates
537
+ });
538
+ }
539
+ case DOC_TYPE_ALIGN:
540
+ case DOC_TYPE_INDENT:
541
+ case DOC_TYPE_INDENT_IF_BREAK:
542
+ case DOC_TYPE_LABEL:
543
+ case DOC_TYPE_LINE_SUFFIX:
544
+ return cb({
545
+ ...doc2,
546
+ contents: rec(doc2.contents)
547
+ });
548
+ case DOC_TYPE_STRING:
549
+ case DOC_TYPE_CURSOR:
550
+ case DOC_TYPE_TRIM:
551
+ case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
552
+ case DOC_TYPE_LINE:
553
+ case DOC_TYPE_BREAK_PARENT:
554
+ return cb(doc2);
555
+ default:
556
+ throw new invalid_doc_error_default(doc2);
557
+ }
558
+ }
559
+ }
560
+ function findInDoc(doc, fn, defaultValue) {
561
+ let result = defaultValue;
562
+ let shouldSkipFurtherProcessing = false;
563
+ function findInDocOnEnterFn(doc2) {
564
+ if (shouldSkipFurtherProcessing) {
565
+ return false;
566
+ }
567
+ const maybeResult = fn(doc2);
568
+ if (maybeResult !== void 0) {
569
+ shouldSkipFurtherProcessing = true;
570
+ result = maybeResult;
571
+ }
572
+ }
573
+ traverse_doc_default(doc, findInDocOnEnterFn);
574
+ return result;
575
+ }
576
+ function willBreakFn(doc) {
577
+ if (doc.type === DOC_TYPE_GROUP && doc.break) {
578
+ return true;
579
+ }
580
+ if (doc.type === DOC_TYPE_LINE && doc.hard) {
581
+ return true;
582
+ }
583
+ if (doc.type === DOC_TYPE_BREAK_PARENT) {
584
+ return true;
585
+ }
586
+ }
587
+ function willBreak(doc) {
588
+ return findInDoc(doc, willBreakFn, false);
589
+ }
590
+ function breakParentGroup(groupStack) {
591
+ if (groupStack.length > 0) {
592
+ const parentGroup = at_default(false, groupStack, -1);
593
+ if (!parentGroup.expandedStates && !parentGroup.break) {
594
+ parentGroup.break = "propagated";
595
+ }
596
+ }
597
+ return null;
598
+ }
599
+ function propagateBreaks(doc) {
600
+ const alreadyVisitedSet = /* @__PURE__ */ new Set();
601
+ const groupStack = [];
602
+ function propagateBreaksOnEnterFn(doc2) {
603
+ if (doc2.type === DOC_TYPE_BREAK_PARENT) {
604
+ breakParentGroup(groupStack);
605
+ }
606
+ if (doc2.type === DOC_TYPE_GROUP) {
607
+ groupStack.push(doc2);
608
+ if (alreadyVisitedSet.has(doc2)) {
609
+ return false;
610
+ }
611
+ alreadyVisitedSet.add(doc2);
612
+ }
613
+ }
614
+ function propagateBreaksOnExitFn(doc2) {
615
+ if (doc2.type === DOC_TYPE_GROUP) {
616
+ const group2 = groupStack.pop();
617
+ if (group2.break) {
618
+ breakParentGroup(groupStack);
619
+ }
620
+ }
621
+ }
622
+ traverse_doc_default(
623
+ doc,
624
+ propagateBreaksOnEnterFn,
625
+ propagateBreaksOnExitFn,
626
+ true
627
+ );
628
+ }
629
+ function removeLinesFn(doc) {
630
+ if (doc.type === DOC_TYPE_LINE && !doc.hard) {
631
+ return doc.soft ? "" : " ";
632
+ }
633
+ if (doc.type === DOC_TYPE_IF_BREAK) {
634
+ return doc.flatContents || "";
635
+ }
636
+ return doc;
637
+ }
638
+ function removeLines(doc) {
639
+ return mapDoc(doc, removeLinesFn);
640
+ }
641
+ var isHardline = (doc, nextDoc) => doc && doc.type === DOC_TYPE_LINE && doc.hard && nextDoc && nextDoc.type === DOC_TYPE_BREAK_PARENT;
642
+ function stripDocTrailingHardlineFromDoc(doc) {
643
+ if (!doc) {
644
+ return doc;
645
+ }
646
+ if (Array.isArray(doc) || doc.type === DOC_TYPE_FILL) {
647
+ const parts = getDocParts(doc);
648
+ while (parts.length > 1 && isHardline(...parts.slice(-2))) {
649
+ parts.length -= 2;
650
+ }
651
+ if (parts.length > 0) {
652
+ const lastPart = stripDocTrailingHardlineFromDoc(at_default(false, parts, -1));
653
+ parts[parts.length - 1] = lastPart;
654
+ }
655
+ return Array.isArray(doc) ? parts : {
656
+ ...doc,
657
+ parts
658
+ };
659
+ }
660
+ switch (doc.type) {
661
+ case DOC_TYPE_ALIGN:
662
+ case DOC_TYPE_INDENT:
663
+ case DOC_TYPE_INDENT_IF_BREAK:
664
+ case DOC_TYPE_GROUP:
665
+ case DOC_TYPE_LINE_SUFFIX:
666
+ case DOC_TYPE_LABEL: {
667
+ const contents = stripDocTrailingHardlineFromDoc(doc.contents);
668
+ return {
669
+ ...doc,
670
+ contents
671
+ };
672
+ }
673
+ case DOC_TYPE_IF_BREAK: {
674
+ const breakContents = stripDocTrailingHardlineFromDoc(doc.breakContents);
675
+ const flatContents = stripDocTrailingHardlineFromDoc(doc.flatContents);
676
+ return {
677
+ ...doc,
678
+ breakContents,
679
+ flatContents
680
+ };
681
+ }
682
+ }
683
+ return doc;
684
+ }
685
+ function stripTrailingHardline(doc) {
686
+ if (typeof doc === "string") {
687
+ return doc.replace(/(?:\r?\n)*$/, "");
688
+ }
689
+ return stripDocTrailingHardlineFromDoc(cleanDoc(doc));
690
+ }
691
+ function cleanDocFn(doc) {
692
+ switch (get_doc_type_default(doc)) {
693
+ case DOC_TYPE_FILL:
694
+ if (doc.parts.every((part) => part === "")) {
695
+ return "";
696
+ }
697
+ break;
698
+ case DOC_TYPE_GROUP:
699
+ if (!doc.contents && !doc.id && !doc.break && !doc.expandedStates) {
700
+ return "";
701
+ }
702
+ if (doc.contents.type === DOC_TYPE_GROUP && doc.contents.id === doc.id && doc.contents.break === doc.break && doc.contents.expandedStates === doc.expandedStates) {
703
+ return doc.contents;
704
+ }
705
+ break;
706
+ case DOC_TYPE_ALIGN:
707
+ case DOC_TYPE_INDENT:
708
+ case DOC_TYPE_INDENT_IF_BREAK:
709
+ case DOC_TYPE_LINE_SUFFIX:
710
+ if (!doc.contents) {
711
+ return "";
712
+ }
713
+ break;
714
+ case DOC_TYPE_IF_BREAK:
715
+ if (!doc.flatContents && !doc.breakContents) {
716
+ return "";
717
+ }
718
+ break;
719
+ case DOC_TYPE_ARRAY: {
720
+ const parts = [];
721
+ for (const part of doc) {
722
+ if (!part) {
723
+ continue;
724
+ }
725
+ const [currentPart, ...restParts] = Array.isArray(part) ? part : [part];
726
+ if (typeof currentPart === "string" && typeof at_default(false, parts, -1) === "string") {
727
+ parts[parts.length - 1] += currentPart;
728
+ } else {
729
+ parts.push(currentPart);
730
+ }
731
+ parts.push(...restParts);
732
+ }
733
+ if (parts.length === 0) {
734
+ return "";
735
+ }
736
+ if (parts.length === 1) {
737
+ return parts[0];
738
+ }
739
+ return parts;
740
+ }
741
+ case DOC_TYPE_STRING:
742
+ case DOC_TYPE_CURSOR:
743
+ case DOC_TYPE_TRIM:
744
+ case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
745
+ case DOC_TYPE_LINE:
746
+ case DOC_TYPE_LABEL:
747
+ case DOC_TYPE_BREAK_PARENT:
748
+ break;
749
+ default:
750
+ throw new invalid_doc_error_default(doc);
751
+ }
752
+ return doc;
753
+ }
754
+ function cleanDoc(doc) {
755
+ return mapDoc(doc, (currentDoc) => cleanDocFn(currentDoc));
756
+ }
757
+ function normalizeParts(parts) {
758
+ const newParts = [];
759
+ const restParts = parts.filter(Boolean);
760
+ while (restParts.length > 0) {
761
+ const part = restParts.shift();
762
+ if (!part) {
763
+ continue;
764
+ }
765
+ if (Array.isArray(part)) {
766
+ restParts.unshift(...part);
767
+ continue;
768
+ }
769
+ if (newParts.length > 0 && typeof at_default(false, newParts, -1) === "string" && typeof part === "string") {
770
+ newParts[newParts.length - 1] += part;
771
+ continue;
772
+ }
773
+ newParts.push(part);
774
+ }
775
+ return newParts;
776
+ }
777
+ function normalizeDoc(doc) {
778
+ return mapDoc(doc, (currentDoc) => {
779
+ if (Array.isArray(currentDoc)) {
780
+ return normalizeParts(currentDoc);
781
+ }
782
+ if (!currentDoc.parts) {
783
+ return currentDoc;
784
+ }
785
+ return {
786
+ ...currentDoc,
787
+ parts: normalizeParts(currentDoc.parts)
788
+ };
789
+ });
790
+ }
791
+ function replaceEndOfLine(doc, replacement = literalline) {
792
+ return mapDoc(doc, (currentDoc) => typeof currentDoc === "string" ? join(replacement, currentDoc.split("\n")) : currentDoc);
793
+ }
794
+ function canBreakFn(doc) {
795
+ if (doc.type === DOC_TYPE_LINE) {
796
+ return true;
797
+ }
798
+ }
799
+ function canBreak(doc) {
800
+ return findInDoc(doc, canBreakFn, false);
801
+ }
802
+
803
+ // src/document/printer.js
804
+ var MODE_BREAK = Symbol("MODE_BREAK");
805
+ var MODE_FLAT = Symbol("MODE_FLAT");
806
+ var CURSOR_PLACEHOLDER = Symbol("cursor");
807
+ function rootIndent() {
808
+ return {
809
+ value: "",
810
+ length: 0,
811
+ queue: []
812
+ };
813
+ }
814
+ function makeIndent(ind, options) {
815
+ return generateInd(ind, {
816
+ type: "indent"
817
+ }, options);
818
+ }
819
+ function makeAlign(indent2, widthOrDoc, options) {
820
+ if (widthOrDoc === Number.NEGATIVE_INFINITY) {
821
+ return indent2.root || rootIndent();
822
+ }
823
+ if (widthOrDoc < 0) {
824
+ return generateInd(indent2, {
825
+ type: "dedent"
826
+ }, options);
827
+ }
828
+ if (!widthOrDoc) {
829
+ return indent2;
830
+ }
831
+ if (widthOrDoc.type === "root") {
832
+ return {
833
+ ...indent2,
834
+ root: indent2
835
+ };
836
+ }
837
+ const alignType = typeof widthOrDoc === "string" ? "stringAlign" : "numberAlign";
838
+ return generateInd(indent2, {
839
+ type: alignType,
840
+ n: widthOrDoc
841
+ }, options);
842
+ }
843
+ function generateInd(ind, newPart, options) {
844
+ const queue = newPart.type === "dedent" ? ind.queue.slice(0, -1) : [...ind.queue, newPart];
845
+ let value = "";
846
+ let length = 0;
847
+ let lastTabs = 0;
848
+ let lastSpaces = 0;
849
+ for (const part of queue) {
850
+ switch (part.type) {
851
+ case "indent":
852
+ flush();
853
+ if (options.useTabs) {
854
+ addTabs(1);
855
+ } else {
856
+ addSpaces(options.tabWidth);
857
+ }
858
+ break;
859
+ case "stringAlign":
860
+ flush();
861
+ value += part.n;
862
+ length += part.n.length;
863
+ break;
864
+ case "numberAlign":
865
+ lastTabs += 1;
866
+ lastSpaces += part.n;
867
+ break;
868
+ default:
869
+ throw new Error(`Unexpected type '${part.type}'`);
870
+ }
871
+ }
872
+ flushSpaces();
873
+ return {
874
+ ...ind,
875
+ value,
876
+ length,
877
+ queue
878
+ };
879
+ function addTabs(count) {
880
+ value += " ".repeat(count);
881
+ length += options.tabWidth * count;
882
+ }
883
+ function addSpaces(count) {
884
+ value += " ".repeat(count);
885
+ length += count;
886
+ }
887
+ function flush() {
888
+ if (options.useTabs) {
889
+ flushTabs();
890
+ } else {
891
+ flushSpaces();
892
+ }
893
+ }
894
+ function flushTabs() {
895
+ if (lastTabs > 0) {
896
+ addTabs(lastTabs);
897
+ }
898
+ resetLast();
899
+ }
900
+ function flushSpaces() {
901
+ if (lastSpaces > 0) {
902
+ addSpaces(lastSpaces);
903
+ }
904
+ resetLast();
905
+ }
906
+ function resetLast() {
907
+ lastTabs = 0;
908
+ lastSpaces = 0;
909
+ }
910
+ }
911
+ function trim2(out) {
912
+ let trimCount = 0;
913
+ let cursorCount = 0;
914
+ let outIndex = out.length;
915
+ outer:
916
+ while (outIndex--) {
917
+ const last = out[outIndex];
918
+ if (last === CURSOR_PLACEHOLDER) {
919
+ cursorCount++;
920
+ continue;
921
+ }
922
+ if (false) {
923
+ throw new Error(`Unexpected value in trim: '${typeof last}'`);
924
+ }
925
+ for (let charIndex = last.length - 1; charIndex >= 0; charIndex--) {
926
+ const char = last[charIndex];
927
+ if (char === " " || char === " ") {
928
+ trimCount++;
929
+ } else {
930
+ out[outIndex] = last.slice(0, charIndex + 1);
931
+ break outer;
932
+ }
933
+ }
934
+ }
935
+ if (trimCount > 0 || cursorCount > 0) {
936
+ out.length = outIndex + 1;
937
+ while (cursorCount-- > 0) {
938
+ out.push(CURSOR_PLACEHOLDER);
939
+ }
940
+ }
941
+ return trimCount;
942
+ }
943
+ function fits(next, restCommands, width, hasLineSuffix, groupModeMap, mustBeFlat) {
944
+ let restIdx = restCommands.length;
945
+ const cmds = [next];
946
+ const out = [];
947
+ while (width >= 0) {
948
+ if (cmds.length === 0) {
949
+ if (restIdx === 0) {
950
+ return true;
951
+ }
952
+ cmds.push(restCommands[--restIdx]);
953
+ continue;
954
+ }
955
+ const {
956
+ mode,
957
+ doc
958
+ } = cmds.pop();
959
+ switch (get_doc_type_default(doc)) {
960
+ case DOC_TYPE_STRING:
961
+ out.push(doc);
962
+ width -= get_string_width_default(doc);
963
+ break;
964
+ case DOC_TYPE_ARRAY:
965
+ case DOC_TYPE_FILL: {
966
+ const parts = getDocParts(doc);
967
+ for (let i = parts.length - 1; i >= 0; i--) {
968
+ cmds.push({
969
+ mode,
970
+ doc: parts[i]
971
+ });
972
+ }
973
+ break;
974
+ }
975
+ case DOC_TYPE_INDENT:
976
+ case DOC_TYPE_ALIGN:
977
+ case DOC_TYPE_INDENT_IF_BREAK:
978
+ case DOC_TYPE_LABEL:
979
+ cmds.push({
980
+ mode,
981
+ doc: doc.contents
982
+ });
983
+ break;
984
+ case DOC_TYPE_TRIM:
985
+ width += trim2(out);
986
+ break;
987
+ case DOC_TYPE_GROUP: {
988
+ if (mustBeFlat && doc.break) {
989
+ return false;
990
+ }
991
+ const groupMode = doc.break ? MODE_BREAK : mode;
992
+ const contents = doc.expandedStates && groupMode === MODE_BREAK ? at_default(false, doc.expandedStates, -1) : doc.contents;
993
+ cmds.push({
994
+ mode: groupMode,
995
+ doc: contents
996
+ });
997
+ break;
998
+ }
999
+ case DOC_TYPE_IF_BREAK: {
1000
+ const groupMode = doc.groupId ? groupModeMap[doc.groupId] || MODE_FLAT : mode;
1001
+ const contents = groupMode === MODE_BREAK ? doc.breakContents : doc.flatContents;
1002
+ if (contents) {
1003
+ cmds.push({
1004
+ mode,
1005
+ doc: contents
1006
+ });
1007
+ }
1008
+ break;
1009
+ }
1010
+ case DOC_TYPE_LINE:
1011
+ if (mode === MODE_BREAK || doc.hard) {
1012
+ return true;
1013
+ }
1014
+ if (!doc.soft) {
1015
+ out.push(" ");
1016
+ width--;
1017
+ }
1018
+ break;
1019
+ case DOC_TYPE_LINE_SUFFIX:
1020
+ hasLineSuffix = true;
1021
+ break;
1022
+ case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
1023
+ if (hasLineSuffix) {
1024
+ return false;
1025
+ }
1026
+ break;
1027
+ }
1028
+ }
1029
+ return false;
1030
+ }
1031
+ function printDocToString(doc, options) {
1032
+ const groupModeMap = {};
1033
+ const width = options.printWidth;
1034
+ const newLine = convertEndOfLineToChars(options.endOfLine);
1035
+ let pos = 0;
1036
+ const cmds = [{
1037
+ ind: rootIndent(),
1038
+ mode: MODE_BREAK,
1039
+ doc
1040
+ }];
1041
+ const out = [];
1042
+ let shouldRemeasure = false;
1043
+ const lineSuffix2 = [];
1044
+ let printedCursorCount = 0;
1045
+ while (cmds.length > 0) {
1046
+ const {
1047
+ ind,
1048
+ mode,
1049
+ doc: doc2
1050
+ } = cmds.pop();
1051
+ switch (get_doc_type_default(doc2)) {
1052
+ case DOC_TYPE_STRING: {
1053
+ const formatted = newLine !== "\n" ? doc2.replace(/\n/g, newLine) : doc2;
1054
+ out.push(formatted);
1055
+ pos += get_string_width_default(formatted);
1056
+ break;
1057
+ }
1058
+ case DOC_TYPE_ARRAY:
1059
+ for (let i = doc2.length - 1; i >= 0; i--) {
1060
+ cmds.push({
1061
+ ind,
1062
+ mode,
1063
+ doc: doc2[i]
1064
+ });
1065
+ }
1066
+ break;
1067
+ case DOC_TYPE_CURSOR:
1068
+ if (printedCursorCount >= 2) {
1069
+ throw new Error("There are too many 'cursor' in doc.");
1070
+ }
1071
+ out.push(CURSOR_PLACEHOLDER);
1072
+ printedCursorCount++;
1073
+ break;
1074
+ case DOC_TYPE_INDENT:
1075
+ cmds.push({
1076
+ ind: makeIndent(ind, options),
1077
+ mode,
1078
+ doc: doc2.contents
1079
+ });
1080
+ break;
1081
+ case DOC_TYPE_ALIGN:
1082
+ cmds.push({
1083
+ ind: makeAlign(ind, doc2.n, options),
1084
+ mode,
1085
+ doc: doc2.contents
1086
+ });
1087
+ break;
1088
+ case DOC_TYPE_TRIM:
1089
+ pos -= trim2(out);
1090
+ break;
1091
+ case DOC_TYPE_GROUP:
1092
+ switch (mode) {
1093
+ case MODE_FLAT:
1094
+ if (!shouldRemeasure) {
1095
+ cmds.push({
1096
+ ind,
1097
+ mode: doc2.break ? MODE_BREAK : MODE_FLAT,
1098
+ doc: doc2.contents
1099
+ });
1100
+ break;
1101
+ }
1102
+ case MODE_BREAK: {
1103
+ shouldRemeasure = false;
1104
+ const next = {
1105
+ ind,
1106
+ mode: MODE_FLAT,
1107
+ doc: doc2.contents
1108
+ };
1109
+ const rem = width - pos;
1110
+ const hasLineSuffix = lineSuffix2.length > 0;
1111
+ if (!doc2.break && fits(next, cmds, rem, hasLineSuffix, groupModeMap)) {
1112
+ cmds.push(next);
1113
+ } else {
1114
+ if (doc2.expandedStates) {
1115
+ const mostExpanded = at_default(false, doc2.expandedStates, -1);
1116
+ if (doc2.break) {
1117
+ cmds.push({
1118
+ ind,
1119
+ mode: MODE_BREAK,
1120
+ doc: mostExpanded
1121
+ });
1122
+ break;
1123
+ } else {
1124
+ for (let i = 1; i < doc2.expandedStates.length + 1; i++) {
1125
+ if (i >= doc2.expandedStates.length) {
1126
+ cmds.push({
1127
+ ind,
1128
+ mode: MODE_BREAK,
1129
+ doc: mostExpanded
1130
+ });
1131
+ break;
1132
+ } else {
1133
+ const state = doc2.expandedStates[i];
1134
+ const cmd = {
1135
+ ind,
1136
+ mode: MODE_FLAT,
1137
+ doc: state
1138
+ };
1139
+ if (fits(cmd, cmds, rem, hasLineSuffix, groupModeMap)) {
1140
+ cmds.push(cmd);
1141
+ break;
1142
+ }
1143
+ }
1144
+ }
1145
+ }
1146
+ } else {
1147
+ cmds.push({
1148
+ ind,
1149
+ mode: MODE_BREAK,
1150
+ doc: doc2.contents
1151
+ });
1152
+ }
1153
+ }
1154
+ break;
1155
+ }
1156
+ }
1157
+ if (doc2.id) {
1158
+ groupModeMap[doc2.id] = at_default(false, cmds, -1).mode;
1159
+ }
1160
+ break;
1161
+ case DOC_TYPE_FILL: {
1162
+ const rem = width - pos;
1163
+ const {
1164
+ parts
1165
+ } = doc2;
1166
+ if (parts.length === 0) {
1167
+ break;
1168
+ }
1169
+ const [content, whitespace] = parts;
1170
+ const contentFlatCmd = {
1171
+ ind,
1172
+ mode: MODE_FLAT,
1173
+ doc: content
1174
+ };
1175
+ const contentBreakCmd = {
1176
+ ind,
1177
+ mode: MODE_BREAK,
1178
+ doc: content
1179
+ };
1180
+ const contentFits = fits(contentFlatCmd, [], rem, lineSuffix2.length > 0, groupModeMap, true);
1181
+ if (parts.length === 1) {
1182
+ if (contentFits) {
1183
+ cmds.push(contentFlatCmd);
1184
+ } else {
1185
+ cmds.push(contentBreakCmd);
1186
+ }
1187
+ break;
1188
+ }
1189
+ const whitespaceFlatCmd = {
1190
+ ind,
1191
+ mode: MODE_FLAT,
1192
+ doc: whitespace
1193
+ };
1194
+ const whitespaceBreakCmd = {
1195
+ ind,
1196
+ mode: MODE_BREAK,
1197
+ doc: whitespace
1198
+ };
1199
+ if (parts.length === 2) {
1200
+ if (contentFits) {
1201
+ cmds.push(whitespaceFlatCmd, contentFlatCmd);
1202
+ } else {
1203
+ cmds.push(whitespaceBreakCmd, contentBreakCmd);
1204
+ }
1205
+ break;
1206
+ }
1207
+ parts.splice(0, 2);
1208
+ const remainingCmd = {
1209
+ ind,
1210
+ mode,
1211
+ doc: fill(parts)
1212
+ };
1213
+ const secondContent = parts[0];
1214
+ const firstAndSecondContentFlatCmd = {
1215
+ ind,
1216
+ mode: MODE_FLAT,
1217
+ doc: [content, whitespace, secondContent]
1218
+ };
1219
+ const firstAndSecondContentFits = fits(firstAndSecondContentFlatCmd, [], rem, lineSuffix2.length > 0, groupModeMap, true);
1220
+ if (firstAndSecondContentFits) {
1221
+ cmds.push(remainingCmd, whitespaceFlatCmd, contentFlatCmd);
1222
+ } else if (contentFits) {
1223
+ cmds.push(remainingCmd, whitespaceBreakCmd, contentFlatCmd);
1224
+ } else {
1225
+ cmds.push(remainingCmd, whitespaceBreakCmd, contentBreakCmd);
1226
+ }
1227
+ break;
1228
+ }
1229
+ case DOC_TYPE_IF_BREAK:
1230
+ case DOC_TYPE_INDENT_IF_BREAK: {
1231
+ const groupMode = doc2.groupId ? groupModeMap[doc2.groupId] : mode;
1232
+ if (groupMode === MODE_BREAK) {
1233
+ const breakContents = doc2.type === DOC_TYPE_IF_BREAK ? doc2.breakContents : doc2.negate ? doc2.contents : indent(doc2.contents);
1234
+ if (breakContents) {
1235
+ cmds.push({
1236
+ ind,
1237
+ mode,
1238
+ doc: breakContents
1239
+ });
1240
+ }
1241
+ }
1242
+ if (groupMode === MODE_FLAT) {
1243
+ const flatContents = doc2.type === DOC_TYPE_IF_BREAK ? doc2.flatContents : doc2.negate ? indent(doc2.contents) : doc2.contents;
1244
+ if (flatContents) {
1245
+ cmds.push({
1246
+ ind,
1247
+ mode,
1248
+ doc: flatContents
1249
+ });
1250
+ }
1251
+ }
1252
+ break;
1253
+ }
1254
+ case DOC_TYPE_LINE_SUFFIX:
1255
+ lineSuffix2.push({
1256
+ ind,
1257
+ mode,
1258
+ doc: doc2.contents
1259
+ });
1260
+ break;
1261
+ case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
1262
+ if (lineSuffix2.length > 0) {
1263
+ cmds.push({
1264
+ ind,
1265
+ mode,
1266
+ doc: hardlineWithoutBreakParent
1267
+ });
1268
+ }
1269
+ break;
1270
+ case DOC_TYPE_LINE:
1271
+ switch (mode) {
1272
+ case MODE_FLAT:
1273
+ if (!doc2.hard) {
1274
+ if (!doc2.soft) {
1275
+ out.push(" ");
1276
+ pos += 1;
1277
+ }
1278
+ break;
1279
+ } else {
1280
+ shouldRemeasure = true;
1281
+ }
1282
+ case MODE_BREAK:
1283
+ if (lineSuffix2.length > 0) {
1284
+ cmds.push({
1285
+ ind,
1286
+ mode,
1287
+ doc: doc2
1288
+ }, ...lineSuffix2.reverse());
1289
+ lineSuffix2.length = 0;
1290
+ break;
1291
+ }
1292
+ if (doc2.literal) {
1293
+ if (ind.root) {
1294
+ out.push(newLine, ind.root.value);
1295
+ pos = ind.root.length;
1296
+ } else {
1297
+ out.push(newLine);
1298
+ pos = 0;
1299
+ }
1300
+ } else {
1301
+ pos -= trim2(out);
1302
+ out.push(newLine + ind.value);
1303
+ pos = ind.length;
1304
+ }
1305
+ break;
1306
+ }
1307
+ break;
1308
+ case DOC_TYPE_LABEL:
1309
+ cmds.push({
1310
+ ind,
1311
+ mode,
1312
+ doc: doc2.contents
1313
+ });
1314
+ break;
1315
+ case DOC_TYPE_BREAK_PARENT:
1316
+ break;
1317
+ default:
1318
+ throw new invalid_doc_error_default(doc2);
1319
+ }
1320
+ if (cmds.length === 0 && lineSuffix2.length > 0) {
1321
+ cmds.push(...lineSuffix2.reverse());
1322
+ lineSuffix2.length = 0;
1323
+ }
1324
+ }
1325
+ const cursorPlaceholderIndex = out.indexOf(CURSOR_PLACEHOLDER);
1326
+ if (cursorPlaceholderIndex !== -1) {
1327
+ const otherCursorPlaceholderIndex = out.indexOf(CURSOR_PLACEHOLDER, cursorPlaceholderIndex + 1);
1328
+ const beforeCursor = out.slice(0, cursorPlaceholderIndex).join("");
1329
+ const aroundCursor = out.slice(cursorPlaceholderIndex + 1, otherCursorPlaceholderIndex).join("");
1330
+ const afterCursor = out.slice(otherCursorPlaceholderIndex + 1).join("");
1331
+ return {
1332
+ formatted: beforeCursor + aroundCursor + afterCursor,
1333
+ cursorNodeStart: beforeCursor.length,
1334
+ cursorNodeText: aroundCursor
1335
+ };
1336
+ }
1337
+ return {
1338
+ formatted: out.join("")
1339
+ };
1340
+ }
1341
+
1342
+ // src/document/debug.js
1343
+ var debug_exports = {};
1344
+ __export(debug_exports, {
1345
+ printDocToDebug: () => printDocToDebug
1346
+ });
1347
+ init_define_process();
1348
+ function flattenDoc(doc) {
1349
+ if (!doc) {
1350
+ return "";
1351
+ }
1352
+ if (Array.isArray(doc)) {
1353
+ const res = [];
1354
+ for (const part of doc) {
1355
+ if (Array.isArray(part)) {
1356
+ res.push(...flattenDoc(part));
1357
+ } else {
1358
+ const flattened = flattenDoc(part);
1359
+ if (flattened !== "") {
1360
+ res.push(flattened);
1361
+ }
1362
+ }
1363
+ }
1364
+ return res;
1365
+ }
1366
+ if (doc.type === DOC_TYPE_IF_BREAK) {
1367
+ return {
1368
+ ...doc,
1369
+ breakContents: flattenDoc(doc.breakContents),
1370
+ flatContents: flattenDoc(doc.flatContents)
1371
+ };
1372
+ }
1373
+ if (doc.type === DOC_TYPE_GROUP) {
1374
+ return {
1375
+ ...doc,
1376
+ contents: flattenDoc(doc.contents),
1377
+ expandedStates: doc.expandedStates && doc.expandedStates.map(flattenDoc)
1378
+ };
1379
+ }
1380
+ if (doc.type === DOC_TYPE_FILL) {
1381
+ return { type: "fill", parts: doc.parts.map(flattenDoc) };
1382
+ }
1383
+ if (doc.contents) {
1384
+ return { ...doc, contents: flattenDoc(doc.contents) };
1385
+ }
1386
+ return doc;
1387
+ }
1388
+ function printDocToDebug(doc) {
1389
+ const printedSymbols = /* @__PURE__ */ Object.create(null);
1390
+ const usedKeysForSymbols = /* @__PURE__ */ new Set();
1391
+ return printDoc(flattenDoc(doc));
1392
+ function printDoc(doc2, index, parentParts) {
1393
+ if (typeof doc2 === "string") {
1394
+ return JSON.stringify(doc2);
1395
+ }
1396
+ if (Array.isArray(doc2)) {
1397
+ const printed = doc2.map(printDoc).filter(Boolean);
1398
+ return printed.length === 1 ? printed[0] : `[${printed.join(", ")}]`;
1399
+ }
1400
+ if (doc2.type === DOC_TYPE_LINE) {
1401
+ const withBreakParent = Array.isArray(parentParts) && parentParts[index + 1] && parentParts[index + 1].type === DOC_TYPE_BREAK_PARENT;
1402
+ if (doc2.literal) {
1403
+ return withBreakParent ? "literalline" : "literallineWithoutBreakParent";
1404
+ }
1405
+ if (doc2.hard) {
1406
+ return withBreakParent ? "hardline" : "hardlineWithoutBreakParent";
1407
+ }
1408
+ if (doc2.soft) {
1409
+ return "softline";
1410
+ }
1411
+ return "line";
1412
+ }
1413
+ if (doc2.type === DOC_TYPE_BREAK_PARENT) {
1414
+ const afterHardline = Array.isArray(parentParts) && parentParts[index - 1] && parentParts[index - 1].type === DOC_TYPE_LINE && parentParts[index - 1].hard;
1415
+ return afterHardline ? void 0 : "breakParent";
1416
+ }
1417
+ if (doc2.type === DOC_TYPE_TRIM) {
1418
+ return "trim";
1419
+ }
1420
+ if (doc2.type === DOC_TYPE_INDENT) {
1421
+ return "indent(" + printDoc(doc2.contents) + ")";
1422
+ }
1423
+ if (doc2.type === DOC_TYPE_ALIGN) {
1424
+ return doc2.n === Number.NEGATIVE_INFINITY ? "dedentToRoot(" + printDoc(doc2.contents) + ")" : doc2.n < 0 ? "dedent(" + printDoc(doc2.contents) + ")" : doc2.n.type === "root" ? "markAsRoot(" + printDoc(doc2.contents) + ")" : "align(" + JSON.stringify(doc2.n) + ", " + printDoc(doc2.contents) + ")";
1425
+ }
1426
+ if (doc2.type === DOC_TYPE_IF_BREAK) {
1427
+ return "ifBreak(" + printDoc(doc2.breakContents) + (doc2.flatContents ? ", " + printDoc(doc2.flatContents) : "") + (doc2.groupId ? (!doc2.flatContents ? ', ""' : "") + `, { groupId: ${printGroupId(doc2.groupId)} }` : "") + ")";
1428
+ }
1429
+ if (doc2.type === DOC_TYPE_INDENT_IF_BREAK) {
1430
+ const optionsParts = [];
1431
+ if (doc2.negate) {
1432
+ optionsParts.push("negate: true");
1433
+ }
1434
+ if (doc2.groupId) {
1435
+ optionsParts.push(`groupId: ${printGroupId(doc2.groupId)}`);
1436
+ }
1437
+ const options = optionsParts.length > 0 ? `, { ${optionsParts.join(", ")} }` : "";
1438
+ return `indentIfBreak(${printDoc(doc2.contents)}${options})`;
1439
+ }
1440
+ if (doc2.type === DOC_TYPE_GROUP) {
1441
+ const optionsParts = [];
1442
+ if (doc2.break && doc2.break !== "propagated") {
1443
+ optionsParts.push("shouldBreak: true");
1444
+ }
1445
+ if (doc2.id) {
1446
+ optionsParts.push(`id: ${printGroupId(doc2.id)}`);
1447
+ }
1448
+ const options = optionsParts.length > 0 ? `, { ${optionsParts.join(", ")} }` : "";
1449
+ if (doc2.expandedStates) {
1450
+ return `conditionalGroup([${doc2.expandedStates.map((part) => printDoc(part)).join(",")}]${options})`;
1451
+ }
1452
+ return `group(${printDoc(doc2.contents)}${options})`;
1453
+ }
1454
+ if (doc2.type === DOC_TYPE_FILL) {
1455
+ return `fill([${doc2.parts.map((part) => printDoc(part)).join(", ")}])`;
1456
+ }
1457
+ if (doc2.type === DOC_TYPE_LINE_SUFFIX) {
1458
+ return "lineSuffix(" + printDoc(doc2.contents) + ")";
1459
+ }
1460
+ if (doc2.type === DOC_TYPE_LINE_SUFFIX_BOUNDARY) {
1461
+ return "lineSuffixBoundary";
1462
+ }
1463
+ if (doc2.type === DOC_TYPE_LABEL) {
1464
+ return `label(${JSON.stringify(doc2.label)}, ${printDoc(doc2.contents)})`;
1465
+ }
1466
+ throw new Error("Unknown doc type " + doc2.type);
1467
+ }
1468
+ function printGroupId(id) {
1469
+ if (typeof id !== "symbol") {
1470
+ return JSON.stringify(String(id));
1471
+ }
1472
+ if (id in printedSymbols) {
1473
+ return printedSymbols[id];
1474
+ }
1475
+ const prefix = id.description || "symbol";
1476
+ for (let counter = 0; ; counter++) {
1477
+ const key = prefix + (counter > 0 ? ` #${counter}` : "");
1478
+ if (!usedKeysForSymbols.has(key)) {
1479
+ usedKeysForSymbols.add(key);
1480
+ return printedSymbols[id] = `Symbol.for(${JSON.stringify(key)})`;
1481
+ }
1482
+ }
1483
+ }
1484
+ }
1485
+ export {
1486
+ builders_exports as builders,
1487
+ debug_exports as debug,
1488
+ printer_exports as printer,
1489
+ utils_exports as utils
1490
+ };