prettier 2.7.1 → 3.0.0-alpha.1

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 (61) hide show
  1. package/LICENSE +181 -1101
  2. package/{bin-prettier.js → bin/prettier.cjs} +10 -5
  3. package/doc.js +1432 -1305
  4. package/doc.mjs +1490 -0
  5. package/index.cjs +532 -0
  6. package/index.mjs +35778 -0
  7. package/{cli.js → internal/cli.mjs} +12236 -13897
  8. package/{third-party.js → internal/third-party.mjs} +704 -611
  9. package/package.json +140 -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/plugins/glimmer.js +25 -0
  19. package/plugins/glimmer.mjs +25 -0
  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/plugins/yaml.js +148 -0
  33. package/plugins/yaml.mjs +148 -0
  34. package/standalone.js +75 -85
  35. package/standalone.mjs +106 -0
  36. package/esm/parser-angular.mjs +0 -2
  37. package/esm/parser-babel.mjs +0 -27
  38. package/esm/parser-espree.mjs +0 -26
  39. package/esm/parser-flow.mjs +0 -35
  40. package/esm/parser-glimmer.mjs +0 -27
  41. package/esm/parser-graphql.mjs +0 -15
  42. package/esm/parser-html.mjs +0 -36
  43. package/esm/parser-markdown.mjs +0 -76
  44. package/esm/parser-meriyah.mjs +0 -19
  45. package/esm/parser-postcss.mjs +0 -76
  46. package/esm/parser-typescript.mjs +0 -280
  47. package/esm/parser-yaml.mjs +0 -150
  48. package/esm/standalone.mjs +0 -116
  49. package/index.js +0 -37282
  50. package/parser-angular.js +0 -2
  51. package/parser-babel.js +0 -27
  52. package/parser-espree.js +0 -26
  53. package/parser-flow.js +0 -35
  54. package/parser-glimmer.js +0 -27
  55. package/parser-graphql.js +0 -15
  56. package/parser-html.js +0 -36
  57. package/parser-markdown.js +0 -76
  58. package/parser-meriyah.js +0 -19
  59. package/parser-postcss.js +0 -76
  60. package/parser-typescript.js +0 -280
  61. package/parser-yaml.js +0 -150
package/doc.js CHANGED
@@ -1,8 +1,15 @@
1
1
  (function (factory) {
2
+ function interopModuleDefault(factory) {
3
+ var module = factory();
4
+ return module;
5
+ }
6
+
2
7
  if (typeof exports === "object" && typeof module === "object") {
3
- module.exports = factory();
8
+ module.exports = interopModuleDefault(factory);
4
9
  } else if (typeof define === "function" && define.amd) {
5
- define(factory);
10
+ define(function () {
11
+ return interopModuleDefault(factory)
12
+ });
6
13
  } else {
7
14
  var root =
8
15
  typeof globalThis !== "undefined"
@@ -12,1381 +19,1501 @@
12
19
  : typeof self !== "undefined"
13
20
  ? self
14
21
  : this || {};
15
- root.doc = factory();
22
+ root.doc = interopModuleDefault(factory);
16
23
  }
17
24
  })(function() {
18
25
  "use strict";
26
+ var __create = Object.create;
27
+ var __defProp = Object.defineProperty;
28
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
19
29
  var __getOwnPropNames = Object.getOwnPropertyNames;
30
+ var __getProtoOf = Object.getPrototypeOf;
31
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
32
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
33
+ var __esm = (fn, res) => function __init() {
34
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
35
+ };
20
36
  var __commonJS = (cb, mod) => function __require() {
21
37
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
22
38
  };
39
+ var __export = (target, all) => {
40
+ for (var name in all)
41
+ __defProp(target, name, { get: all[name], enumerable: true });
42
+ };
43
+ var __copyProps = (to, from, except, desc) => {
44
+ if (from && typeof from === "object" || typeof from === "function") {
45
+ for (let key of __getOwnPropNames(from))
46
+ if (!__hasOwnProp.call(to, key) && key !== except)
47
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
48
+ }
49
+ return to;
50
+ };
51
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
52
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
53
+ mod
54
+ ));
55
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
56
+ var __publicField = (obj, key, value) => {
57
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
58
+ return value;
59
+ };
23
60
 
24
- // dist/_doc.js.umd.js
25
- var require_doc_js_umd = __commonJS({
26
- "dist/_doc.js.umd.js"(exports, module) {
27
- var __create = Object.create;
28
- var __defProp = Object.defineProperty;
29
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
30
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
31
- var __getProtoOf = Object.getPrototypeOf;
32
- var __hasOwnProp = Object.prototype.hasOwnProperty;
33
- var __esm = (fn, res) => function __init() {
34
- return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
35
- };
36
- var __commonJS2 = (cb, mod) => function __require() {
37
- return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = {
38
- exports: {}
39
- }).exports, mod), mod.exports;
40
- };
41
- var __export = (target, all) => {
42
- for (var name in all)
43
- __defProp(target, name, {
44
- get: all[name],
45
- enumerable: true
46
- });
47
- };
48
- var __copyProps = (to, from, except, desc) => {
49
- if (from && typeof from === "object" || typeof from === "function") {
50
- for (let key of __getOwnPropNames2(from))
51
- if (!__hasOwnProp.call(to, key) && key !== except)
52
- __defProp(to, key, {
53
- get: () => from[key],
54
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
55
- });
56
- }
57
- return to;
61
+ // <define:process>
62
+ var init_define_process = __esm({
63
+ "<define:process>"() {
64
+ }
65
+ });
66
+
67
+ // node_modules/string-width/node_modules/emoji-regex/index.js
68
+ var require_emoji_regex = __commonJS({
69
+ "node_modules/string-width/node_modules/emoji-regex/index.js"(exports, module) {
70
+ "use strict";
71
+ init_define_process();
72
+ module.exports = function() {
73
+ 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])|\uD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uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\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\uD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DF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\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;
58
74
  };
59
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
60
- value: mod,
61
- enumerable: true
62
- }) : target, mod));
63
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", {
64
- value: true
65
- }), mod);
66
- var init_define_process = __esm({
67
- "<define:process>"() {
68
- }
69
- });
70
- var require_doc_builders = __commonJS2({
71
- "src/document/doc-builders.js"(exports2, module2) {
72
- "use strict";
73
- init_define_process();
74
- function concat(parts) {
75
- if (false) {
76
- for (const part of parts) {
77
- assertDoc(part);
78
- }
79
- }
80
- return {
81
- type: "concat",
82
- parts
83
- };
84
- }
85
- function indent(contents) {
86
- if (false) {
87
- assertDoc(contents);
88
- }
89
- return {
90
- type: "indent",
91
- contents
92
- };
93
- }
94
- function align(widthOrString, contents) {
95
- if (false) {
96
- assertDoc(contents);
97
- }
98
- return {
99
- type: "align",
100
- contents,
101
- n: widthOrString
102
- };
103
- }
104
- function group(contents) {
105
- let opts = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
106
- if (false) {
107
- assertDoc(contents);
108
- }
109
- return {
110
- type: "group",
111
- id: opts.id,
112
- contents,
113
- break: Boolean(opts.shouldBreak),
114
- expandedStates: opts.expandedStates
115
- };
116
- }
117
- function dedentToRoot(contents) {
118
- return align(Number.NEGATIVE_INFINITY, contents);
119
- }
120
- function markAsRoot(contents) {
121
- return align({
122
- type: "root"
123
- }, contents);
124
- }
125
- function dedent(contents) {
126
- return align(-1, contents);
127
- }
128
- function conditionalGroup(states, opts) {
129
- return group(states[0], Object.assign(Object.assign({}, opts), {}, {
130
- expandedStates: states
131
- }));
132
- }
133
- function fill(parts) {
134
- if (false) {
135
- for (const part of parts) {
136
- assertDoc(part);
137
- }
138
- }
139
- return {
140
- type: "fill",
141
- parts
142
- };
143
- }
144
- function ifBreak(breakContents, flatContents) {
145
- let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
146
- if (false) {
147
- if (breakContents) {
148
- assertDoc(breakContents);
149
- }
150
- if (flatContents) {
151
- assertDoc(flatContents);
152
- }
153
- }
154
- return {
155
- type: "if-break",
156
- breakContents,
157
- flatContents,
158
- groupId: opts.groupId
159
- };
160
- }
161
- function indentIfBreak(contents, opts) {
162
- return {
163
- type: "indent-if-break",
164
- contents,
165
- groupId: opts.groupId,
166
- negate: opts.negate
167
- };
168
- }
169
- function lineSuffix(contents) {
170
- if (false) {
171
- assertDoc(contents);
172
- }
173
- return {
174
- type: "line-suffix",
175
- contents
176
- };
177
- }
178
- var lineSuffixBoundary = {
179
- type: "line-suffix-boundary"
180
- };
181
- var breakParent = {
182
- type: "break-parent"
183
- };
184
- var trim = {
185
- type: "trim"
186
- };
187
- var hardlineWithoutBreakParent = {
188
- type: "line",
189
- hard: true
190
- };
191
- var literallineWithoutBreakParent = {
192
- type: "line",
193
- hard: true,
194
- literal: true
195
- };
196
- var line = {
197
- type: "line"
198
- };
199
- var softline = {
200
- type: "line",
201
- soft: true
202
- };
203
- var hardline = concat([hardlineWithoutBreakParent, breakParent]);
204
- var literalline = concat([literallineWithoutBreakParent, breakParent]);
205
- var cursor = {
206
- type: "cursor",
207
- placeholder: Symbol("cursor")
208
- };
209
- function join(sep, arr) {
210
- const res = [];
211
- for (let i = 0; i < arr.length; i++) {
212
- if (i !== 0) {
213
- res.push(sep);
214
- }
215
- res.push(arr[i]);
216
- }
217
- return concat(res);
218
- }
219
- function addAlignmentToDoc(doc, size, tabWidth) {
220
- let aligned = doc;
221
- if (size > 0) {
222
- for (let i = 0; i < Math.floor(size / tabWidth); ++i) {
223
- aligned = indent(aligned);
224
- }
225
- aligned = align(size % tabWidth, aligned);
226
- aligned = align(Number.NEGATIVE_INFINITY, aligned);
227
- }
228
- return aligned;
229
- }
230
- function label(label2, contents) {
231
- return {
232
- type: "label",
233
- label: label2,
234
- contents
235
- };
75
+ }
76
+ });
77
+
78
+ // src/document/index.js
79
+ var document_exports = {};
80
+ __export(document_exports, {
81
+ builders: () => builders_exports,
82
+ debug: () => debug_exports,
83
+ printer: () => printer_exports,
84
+ utils: () => utils_exports
85
+ });
86
+ init_define_process();
87
+
88
+ // src/document/builders.js
89
+ var builders_exports = {};
90
+ __export(builders_exports, {
91
+ addAlignmentToDoc: () => addAlignmentToDoc,
92
+ align: () => align,
93
+ breakParent: () => breakParent,
94
+ concat: () => concat,
95
+ conditionalGroup: () => conditionalGroup,
96
+ cursor: () => cursor,
97
+ dedent: () => dedent,
98
+ dedentToRoot: () => dedentToRoot,
99
+ fill: () => fill,
100
+ group: () => group,
101
+ hardline: () => hardline,
102
+ hardlineWithoutBreakParent: () => hardlineWithoutBreakParent,
103
+ ifBreak: () => ifBreak,
104
+ indent: () => indent,
105
+ indentIfBreak: () => indentIfBreak,
106
+ join: () => join,
107
+ label: () => label,
108
+ line: () => line,
109
+ lineSuffix: () => lineSuffix,
110
+ lineSuffixBoundary: () => lineSuffixBoundary,
111
+ literalline: () => literalline,
112
+ literallineWithoutBreakParent: () => literallineWithoutBreakParent,
113
+ markAsRoot: () => markAsRoot,
114
+ softline: () => softline,
115
+ trim: () => trim
116
+ });
117
+ init_define_process();
118
+
119
+ // src/document/constants.js
120
+ init_define_process();
121
+ var DOC_TYPE_STRING = "string";
122
+ var DOC_TYPE_ARRAY = "array";
123
+ var DOC_TYPE_CURSOR = "cursor";
124
+ var DOC_TYPE_INDENT = "indent";
125
+ var DOC_TYPE_ALIGN = "align";
126
+ var DOC_TYPE_TRIM = "trim";
127
+ var DOC_TYPE_GROUP = "group";
128
+ var DOC_TYPE_FILL = "fill";
129
+ var DOC_TYPE_IF_BREAK = "if-break";
130
+ var DOC_TYPE_INDENT_IF_BREAK = "indent-if-break";
131
+ var DOC_TYPE_LINE_SUFFIX = "line-suffix";
132
+ var DOC_TYPE_LINE_SUFFIX_BOUNDARY = "line-suffix-boundary";
133
+ var DOC_TYPE_LINE = "line";
134
+ var DOC_TYPE_LABEL = "label";
135
+ var DOC_TYPE_BREAK_PARENT = "break-parent";
136
+ var VALID_OBJECT_DOC_TYPES = /* @__PURE__ */ new Set([
137
+ DOC_TYPE_CURSOR,
138
+ DOC_TYPE_INDENT,
139
+ DOC_TYPE_ALIGN,
140
+ DOC_TYPE_TRIM,
141
+ DOC_TYPE_GROUP,
142
+ DOC_TYPE_FILL,
143
+ DOC_TYPE_IF_BREAK,
144
+ DOC_TYPE_INDENT_IF_BREAK,
145
+ DOC_TYPE_LINE_SUFFIX,
146
+ DOC_TYPE_LINE_SUFFIX_BOUNDARY,
147
+ DOC_TYPE_LINE,
148
+ DOC_TYPE_LABEL,
149
+ DOC_TYPE_BREAK_PARENT
150
+ ]);
151
+
152
+ // src/document/builders.js
153
+ function indent(contents) {
154
+ if (false) {
155
+ assertDoc(contents);
156
+ }
157
+ return { type: DOC_TYPE_INDENT, contents };
158
+ }
159
+ function align(widthOrString, contents) {
160
+ if (false) {
161
+ assertDoc(contents);
162
+ }
163
+ return { type: DOC_TYPE_ALIGN, contents, n: widthOrString };
164
+ }
165
+ function group(contents, opts = {}) {
166
+ if (false) {
167
+ assertDoc(contents);
168
+ }
169
+ return {
170
+ type: DOC_TYPE_GROUP,
171
+ id: opts.id,
172
+ contents,
173
+ break: Boolean(opts.shouldBreak),
174
+ expandedStates: opts.expandedStates
175
+ };
176
+ }
177
+ function dedentToRoot(contents) {
178
+ return align(Number.NEGATIVE_INFINITY, contents);
179
+ }
180
+ function markAsRoot(contents) {
181
+ return align({ type: "root" }, contents);
182
+ }
183
+ function dedent(contents) {
184
+ return align(-1, contents);
185
+ }
186
+ function conditionalGroup(states, opts) {
187
+ return group(states[0], { ...opts, expandedStates: states });
188
+ }
189
+ function fill(parts) {
190
+ if (false) {
191
+ for (const part of parts) {
192
+ assertDoc(part);
193
+ }
194
+ }
195
+ return { type: DOC_TYPE_FILL, parts };
196
+ }
197
+ function ifBreak(breakContents, flatContents, opts = {}) {
198
+ if (false) {
199
+ if (breakContents) {
200
+ assertDoc(breakContents);
201
+ }
202
+ if (flatContents) {
203
+ assertDoc(flatContents);
204
+ }
205
+ }
206
+ return {
207
+ type: DOC_TYPE_IF_BREAK,
208
+ breakContents,
209
+ flatContents,
210
+ groupId: opts.groupId
211
+ };
212
+ }
213
+ function indentIfBreak(contents, opts) {
214
+ return {
215
+ type: DOC_TYPE_INDENT_IF_BREAK,
216
+ contents,
217
+ groupId: opts.groupId,
218
+ negate: opts.negate
219
+ };
220
+ }
221
+ function lineSuffix(contents) {
222
+ if (false) {
223
+ assertDoc(contents);
224
+ }
225
+ return { type: DOC_TYPE_LINE_SUFFIX, contents };
226
+ }
227
+ var lineSuffixBoundary = { type: DOC_TYPE_LINE_SUFFIX_BOUNDARY };
228
+ var breakParent = { type: DOC_TYPE_BREAK_PARENT };
229
+ var trim = { type: DOC_TYPE_TRIM };
230
+ var hardlineWithoutBreakParent = { type: DOC_TYPE_LINE, hard: true };
231
+ var literallineWithoutBreakParent = {
232
+ type: DOC_TYPE_LINE,
233
+ hard: true,
234
+ literal: true
235
+ };
236
+ var line = { type: DOC_TYPE_LINE };
237
+ var softline = { type: DOC_TYPE_LINE, soft: true };
238
+ var hardline = [hardlineWithoutBreakParent, breakParent];
239
+ var literalline = [literallineWithoutBreakParent, breakParent];
240
+ var cursor = { type: DOC_TYPE_CURSOR };
241
+ function join(sep, arr) {
242
+ const res = [];
243
+ for (let i = 0; i < arr.length; i++) {
244
+ if (i !== 0) {
245
+ res.push(sep);
246
+ }
247
+ res.push(arr[i]);
248
+ }
249
+ return res;
250
+ }
251
+ function addAlignmentToDoc(doc, size, tabWidth) {
252
+ let aligned = doc;
253
+ if (size > 0) {
254
+ for (let i = 0; i < Math.floor(size / tabWidth); ++i) {
255
+ aligned = indent(aligned);
256
+ }
257
+ aligned = align(size % tabWidth, aligned);
258
+ aligned = align(Number.NEGATIVE_INFINITY, aligned);
259
+ }
260
+ return aligned;
261
+ }
262
+ function label(label2, contents) {
263
+ return label2 ? { type: DOC_TYPE_LABEL, label: label2, contents } : contents;
264
+ }
265
+ var concat = (parts) => parts;
266
+
267
+ // src/document/printer.js
268
+ var printer_exports = {};
269
+ __export(printer_exports, {
270
+ printDocToString: () => printDocToString
271
+ });
272
+ init_define_process();
273
+
274
+ // scripts/build/shims/at.js
275
+ init_define_process();
276
+ var at = (isOptionalObject, object, index, ...args) => {
277
+ if (isOptionalObject && (object === void 0 || object === null)) {
278
+ return;
279
+ }
280
+ return object.at ? object.at(index, ...args) : object[index < 0 ? object.length + index : index];
281
+ };
282
+ var at_default = at;
283
+
284
+ // src/common/end-of-line.js
285
+ init_define_process();
286
+ function convertEndOfLineToChars(value) {
287
+ switch (value) {
288
+ case "cr":
289
+ return "\r";
290
+ case "crlf":
291
+ return "\r\n";
292
+ default:
293
+ return "\n";
294
+ }
295
+ }
296
+
297
+ // src/utils/get-string-width.js
298
+ init_define_process();
299
+
300
+ // node_modules/string-width/index.js
301
+ init_define_process();
302
+
303
+ // node_modules/strip-ansi/index.js
304
+ init_define_process();
305
+
306
+ // node_modules/strip-ansi/node_modules/ansi-regex/index.js
307
+ init_define_process();
308
+ function ansiRegex({ onlyFirst = false } = {}) {
309
+ const pattern = [
310
+ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
311
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
312
+ ].join("|");
313
+ return new RegExp(pattern, onlyFirst ? void 0 : "g");
314
+ }
315
+
316
+ // node_modules/strip-ansi/index.js
317
+ function stripAnsi(string) {
318
+ if (typeof string !== "string") {
319
+ throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
320
+ }
321
+ return string.replace(ansiRegex(), "");
322
+ }
323
+
324
+ // node_modules/string-width/node_modules/is-fullwidth-code-point/index.js
325
+ init_define_process();
326
+ function isFullwidthCodePoint(codePoint) {
327
+ if (!Number.isInteger(codePoint)) {
328
+ return false;
329
+ }
330
+ 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);
331
+ }
332
+
333
+ // node_modules/string-width/index.js
334
+ var import_emoji_regex = __toESM(require_emoji_regex(), 1);
335
+ function stringWidth(string) {
336
+ if (typeof string !== "string" || string.length === 0) {
337
+ return 0;
338
+ }
339
+ string = stripAnsi(string);
340
+ if (string.length === 0) {
341
+ return 0;
342
+ }
343
+ string = string.replace((0, import_emoji_regex.default)(), " ");
344
+ let width = 0;
345
+ for (let index = 0; index < string.length; index++) {
346
+ const codePoint = string.codePointAt(index);
347
+ if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
348
+ continue;
349
+ }
350
+ if (codePoint >= 768 && codePoint <= 879) {
351
+ continue;
352
+ }
353
+ if (codePoint > 65535) {
354
+ index++;
355
+ }
356
+ width += isFullwidthCodePoint(codePoint) ? 2 : 1;
357
+ }
358
+ return width;
359
+ }
360
+
361
+ // src/utils/get-string-width.js
362
+ var notAsciiRegex = /[^\x20-\x7F]/;
363
+ function getStringWidth(text) {
364
+ if (!text) {
365
+ return 0;
366
+ }
367
+ if (!notAsciiRegex.test(text)) {
368
+ return text.length;
369
+ }
370
+ return stringWidth(text);
371
+ }
372
+ var get_string_width_default = getStringWidth;
373
+
374
+ // src/document/utils.js
375
+ var utils_exports = {};
376
+ __export(utils_exports, {
377
+ canBreak: () => canBreak,
378
+ cleanDoc: () => cleanDoc,
379
+ findInDoc: () => findInDoc,
380
+ getDocParts: () => getDocParts,
381
+ getDocType: () => get_doc_type_default,
382
+ mapDoc: () => mapDoc,
383
+ normalizeDoc: () => normalizeDoc,
384
+ normalizeParts: () => normalizeParts,
385
+ propagateBreaks: () => propagateBreaks,
386
+ removeLines: () => removeLines,
387
+ replaceEndOfLine: () => replaceEndOfLine,
388
+ stripTrailingHardline: () => stripTrailingHardline,
389
+ traverseDoc: () => traverse_doc_default,
390
+ willBreak: () => willBreak
391
+ });
392
+ init_define_process();
393
+
394
+ // src/document/utils/get-doc-type.js
395
+ init_define_process();
396
+ function getDocType(doc) {
397
+ if (typeof doc === "string") {
398
+ return DOC_TYPE_STRING;
399
+ }
400
+ if (Array.isArray(doc)) {
401
+ return DOC_TYPE_ARRAY;
402
+ }
403
+ if (!doc) {
404
+ return;
405
+ }
406
+ const { type } = doc;
407
+ if (VALID_OBJECT_DOC_TYPES.has(type)) {
408
+ return type;
409
+ }
410
+ }
411
+ var get_doc_type_default = getDocType;
412
+
413
+ // src/document/utils/traverse-doc.js
414
+ init_define_process();
415
+
416
+ // src/document/invalid-doc-error.js
417
+ init_define_process();
418
+ var disjunctionListFormat = (list) => [...list.slice(0, -1), `or ${at_default(false, list, -1)}`].join(", ");
419
+ function getDocErrorMessage(doc) {
420
+ const type = doc === null ? null : typeof doc;
421
+ if (type !== "string" && type !== "object") {
422
+ return `Unexpected doc '${type}',
423
+ Expected it to be 'string' or 'object'.`;
424
+ }
425
+ if (get_doc_type_default(doc)) {
426
+ throw new Error("doc is valid.");
427
+ }
428
+ const objectType = Object.prototype.toString.call(doc);
429
+ if (objectType !== "[object Object]") {
430
+ return `Unexpected doc '${objectType}'.`;
431
+ }
432
+ const EXPECTED_TYPE_VALUES = disjunctionListFormat([...VALID_OBJECT_DOC_TYPES].map((type2) => `'${type2}'`));
433
+ return `Unexpected doc.type '${doc.type}'.
434
+ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
435
+ }
436
+ var InvalidDocError = class extends Error {
437
+ constructor(doc) {
438
+ super(getDocErrorMessage(doc));
439
+ __publicField(this, "name", "InvalidDocError");
440
+ this.doc = doc;
441
+ }
442
+ };
443
+ var invalid_doc_error_default = InvalidDocError;
444
+
445
+ // src/document/utils/traverse-doc.js
446
+ var traverseDocOnExitStackMarker = {};
447
+ function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
448
+ const docsStack = [doc];
449
+ while (docsStack.length > 0) {
450
+ const doc2 = docsStack.pop();
451
+ if (doc2 === traverseDocOnExitStackMarker) {
452
+ onExit(docsStack.pop());
453
+ continue;
454
+ }
455
+ if (onExit) {
456
+ docsStack.push(doc2, traverseDocOnExitStackMarker);
457
+ }
458
+ if ((onEnter == null ? void 0 : onEnter(doc2)) === false) {
459
+ continue;
460
+ }
461
+ const docType = get_doc_type_default(doc2);
462
+ switch (docType) {
463
+ case DOC_TYPE_ARRAY:
464
+ case DOC_TYPE_FILL: {
465
+ const parts = docType === DOC_TYPE_ARRAY ? doc2 : doc2.parts;
466
+ for (let ic = parts.length, i = ic - 1; i >= 0; --i) {
467
+ docsStack.push(parts[i]);
236
468
  }
237
- module2.exports = {
238
- concat,
239
- join,
240
- line,
241
- softline,
242
- hardline,
243
- literalline,
244
- group,
245
- conditionalGroup,
246
- fill,
247
- lineSuffix,
248
- lineSuffixBoundary,
249
- cursor,
250
- breakParent,
251
- ifBreak,
252
- trim,
253
- indent,
254
- indentIfBreak,
255
- align,
256
- addAlignmentToDoc,
257
- markAsRoot,
258
- dedentToRoot,
259
- dedent,
260
- hardlineWithoutBreakParent,
261
- literallineWithoutBreakParent,
262
- label
263
- };
469
+ break;
264
470
  }
265
- });
266
- var require_end_of_line = __commonJS2({
267
- "src/common/end-of-line.js"(exports2, module2) {
268
- "use strict";
269
- init_define_process();
270
- function guessEndOfLine(text) {
271
- const index = text.indexOf("\r");
272
- if (index >= 0) {
273
- return text.charAt(index + 1) === "\n" ? "crlf" : "cr";
274
- }
275
- return "lf";
471
+ case DOC_TYPE_IF_BREAK:
472
+ if (doc2.flatContents) {
473
+ docsStack.push(doc2.flatContents);
276
474
  }
277
- function convertEndOfLineToChars(value) {
278
- switch (value) {
279
- case "cr":
280
- return "\r";
281
- case "crlf":
282
- return "\r\n";
283
- default:
284
- return "\n";
285
- }
475
+ if (doc2.breakContents) {
476
+ docsStack.push(doc2.breakContents);
286
477
  }
287
- function countEndOfLineChars(text, eol) {
288
- let regex;
289
- switch (eol) {
290
- case "\n":
291
- regex = /\n/g;
292
- break;
293
- case "\r":
294
- regex = /\r/g;
295
- break;
296
- case "\r\n":
297
- regex = /\r\n/g;
298
- break;
299
- default:
300
- throw new Error('Unexpected "eol" '.concat(JSON.stringify(eol), "."));
478
+ break;
479
+ case DOC_TYPE_GROUP:
480
+ if (shouldTraverseConditionalGroups && doc2.expandedStates) {
481
+ for (let ic = doc2.expandedStates.length, i = ic - 1; i >= 0; --i) {
482
+ docsStack.push(doc2.expandedStates[i]);
301
483
  }
302
- const endOfLines = text.match(regex);
303
- return endOfLines ? endOfLines.length : 0;
484
+ } else {
485
+ docsStack.push(doc2.contents);
304
486
  }
305
- function normalizeEndOfLine(text) {
306
- return text.replace(/\r\n?/g, "\n");
307
- }
308
- module2.exports = {
309
- guessEndOfLine,
310
- convertEndOfLineToChars,
311
- countEndOfLineChars,
312
- normalizeEndOfLine
313
- };
314
- }
315
- });
316
- var require_get_last = __commonJS2({
317
- "src/utils/get-last.js"(exports2, module2) {
318
- "use strict";
319
- init_define_process();
320
- var getLast = (arr) => arr[arr.length - 1];
321
- module2.exports = getLast;
322
- }
323
- });
324
- function ansiRegex() {
325
- let {
326
- onlyFirst = false
327
- } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
328
- const pattern = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");
329
- return new RegExp(pattern, onlyFirst ? void 0 : "g");
487
+ break;
488
+ case DOC_TYPE_ALIGN:
489
+ case DOC_TYPE_INDENT:
490
+ case DOC_TYPE_INDENT_IF_BREAK:
491
+ case DOC_TYPE_LABEL:
492
+ case DOC_TYPE_LINE_SUFFIX:
493
+ docsStack.push(doc2.contents);
494
+ break;
495
+ case DOC_TYPE_STRING:
496
+ case DOC_TYPE_CURSOR:
497
+ case DOC_TYPE_TRIM:
498
+ case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
499
+ case DOC_TYPE_LINE:
500
+ case DOC_TYPE_BREAK_PARENT:
501
+ break;
502
+ default:
503
+ throw new invalid_doc_error_default(doc2);
504
+ }
505
+ }
506
+ }
507
+ var traverse_doc_default = traverseDoc;
508
+
509
+ // src/document/utils.js
510
+ var getDocParts = (doc) => {
511
+ if (Array.isArray(doc)) {
512
+ return doc;
513
+ }
514
+ if (doc.type !== DOC_TYPE_FILL) {
515
+ throw new Error(`Expect doc to be 'array' or '${DOC_TYPE_FILL}'.`);
516
+ }
517
+ return doc.parts;
518
+ };
519
+ function mapDoc(doc, cb) {
520
+ if (typeof doc === "string") {
521
+ return cb(doc);
522
+ }
523
+ const mapped = /* @__PURE__ */ new Map();
524
+ return rec(doc);
525
+ function rec(doc2) {
526
+ if (mapped.has(doc2)) {
527
+ return mapped.get(doc2);
330
528
  }
331
- var init_ansi_regex = __esm({
332
- "node_modules/strip-ansi/node_modules/ansi-regex/index.js"() {
333
- init_define_process();
529
+ const result = process2(doc2);
530
+ mapped.set(doc2, result);
531
+ return result;
532
+ }
533
+ function process2(doc2) {
534
+ switch (get_doc_type_default(doc2)) {
535
+ case DOC_TYPE_ARRAY:
536
+ return cb(doc2.map(rec));
537
+ case DOC_TYPE_FILL:
538
+ return cb({
539
+ ...doc2,
540
+ parts: doc2.parts.map(rec)
541
+ });
542
+ case DOC_TYPE_IF_BREAK: {
543
+ let {
544
+ breakContents,
545
+ flatContents
546
+ } = doc2;
547
+ breakContents && (breakContents = rec(breakContents));
548
+ flatContents && (flatContents = rec(flatContents));
549
+ return cb({
550
+ ...doc2,
551
+ breakContents,
552
+ flatContents
553
+ });
334
554
  }
335
- });
336
- function stripAnsi(string) {
337
- if (typeof string !== "string") {
338
- throw new TypeError("Expected a `string`, got `".concat(typeof string, "`"));
555
+ case DOC_TYPE_GROUP: {
556
+ let {
557
+ expandedStates,
558
+ contents
559
+ } = doc2;
560
+ if (expandedStates) {
561
+ expandedStates = expandedStates.map(rec);
562
+ contents = expandedStates[0];
563
+ } else {
564
+ contents = rec(contents);
565
+ }
566
+ return cb({
567
+ ...doc2,
568
+ contents,
569
+ expandedStates
570
+ });
339
571
  }
340
- return string.replace(ansiRegex(), "");
572
+ case DOC_TYPE_ALIGN:
573
+ case DOC_TYPE_INDENT:
574
+ case DOC_TYPE_INDENT_IF_BREAK:
575
+ case DOC_TYPE_LABEL:
576
+ case DOC_TYPE_LINE_SUFFIX:
577
+ return cb({
578
+ ...doc2,
579
+ contents: rec(doc2.contents)
580
+ });
581
+ case DOC_TYPE_STRING:
582
+ case DOC_TYPE_CURSOR:
583
+ case DOC_TYPE_TRIM:
584
+ case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
585
+ case DOC_TYPE_LINE:
586
+ case DOC_TYPE_BREAK_PARENT:
587
+ return cb(doc2);
588
+ default:
589
+ throw new invalid_doc_error_default(doc2);
341
590
  }
342
- var init_strip_ansi = __esm({
343
- "node_modules/strip-ansi/index.js"() {
344
- init_define_process();
345
- init_ansi_regex();
346
- }
347
- });
348
- function isFullwidthCodePoint(codePoint) {
349
- if (!Number.isInteger(codePoint)) {
591
+ }
592
+ }
593
+ function findInDoc(doc, fn, defaultValue) {
594
+ let result = defaultValue;
595
+ let shouldSkipFurtherProcessing = false;
596
+ function findInDocOnEnterFn(doc2) {
597
+ if (shouldSkipFurtherProcessing) {
598
+ return false;
599
+ }
600
+ const maybeResult = fn(doc2);
601
+ if (maybeResult !== void 0) {
602
+ shouldSkipFurtherProcessing = true;
603
+ result = maybeResult;
604
+ }
605
+ }
606
+ traverse_doc_default(doc, findInDocOnEnterFn);
607
+ return result;
608
+ }
609
+ function willBreakFn(doc) {
610
+ if (doc.type === DOC_TYPE_GROUP && doc.break) {
611
+ return true;
612
+ }
613
+ if (doc.type === DOC_TYPE_LINE && doc.hard) {
614
+ return true;
615
+ }
616
+ if (doc.type === DOC_TYPE_BREAK_PARENT) {
617
+ return true;
618
+ }
619
+ }
620
+ function willBreak(doc) {
621
+ return findInDoc(doc, willBreakFn, false);
622
+ }
623
+ function breakParentGroup(groupStack) {
624
+ if (groupStack.length > 0) {
625
+ const parentGroup = at_default(false, groupStack, -1);
626
+ if (!parentGroup.expandedStates && !parentGroup.break) {
627
+ parentGroup.break = "propagated";
628
+ }
629
+ }
630
+ return null;
631
+ }
632
+ function propagateBreaks(doc) {
633
+ const alreadyVisitedSet = /* @__PURE__ */ new Set();
634
+ const groupStack = [];
635
+ function propagateBreaksOnEnterFn(doc2) {
636
+ if (doc2.type === DOC_TYPE_BREAK_PARENT) {
637
+ breakParentGroup(groupStack);
638
+ }
639
+ if (doc2.type === DOC_TYPE_GROUP) {
640
+ groupStack.push(doc2);
641
+ if (alreadyVisitedSet.has(doc2)) {
350
642
  return false;
351
643
  }
352
- 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);
644
+ alreadyVisitedSet.add(doc2);
353
645
  }
354
- var init_is_fullwidth_code_point = __esm({
355
- "node_modules/is-fullwidth-code-point/index.js"() {
356
- init_define_process();
646
+ }
647
+ function propagateBreaksOnExitFn(doc2) {
648
+ if (doc2.type === DOC_TYPE_GROUP) {
649
+ const group2 = groupStack.pop();
650
+ if (group2.break) {
651
+ breakParentGroup(groupStack);
357
652
  }
358
- });
359
- var require_emoji_regex = __commonJS2({
360
- "node_modules/emoji-regex/index.js"(exports2, module2) {
361
- "use strict";
362
- init_define_process();
363
- module2.exports = function() {
364
- 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\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u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\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\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\u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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;
365
- };
653
+ }
654
+ }
655
+ traverse_doc_default(
656
+ doc,
657
+ propagateBreaksOnEnterFn,
658
+ propagateBreaksOnExitFn,
659
+ true
660
+ );
661
+ }
662
+ function removeLinesFn(doc) {
663
+ if (doc.type === DOC_TYPE_LINE && !doc.hard) {
664
+ return doc.soft ? "" : " ";
665
+ }
666
+ if (doc.type === DOC_TYPE_IF_BREAK) {
667
+ return doc.flatContents || "";
668
+ }
669
+ return doc;
670
+ }
671
+ function removeLines(doc) {
672
+ return mapDoc(doc, removeLinesFn);
673
+ }
674
+ var isHardline = (doc, nextDoc) => doc && doc.type === DOC_TYPE_LINE && doc.hard && nextDoc && nextDoc.type === DOC_TYPE_BREAK_PARENT;
675
+ function stripDocTrailingHardlineFromDoc(doc) {
676
+ if (!doc) {
677
+ return doc;
678
+ }
679
+ if (Array.isArray(doc) || doc.type === DOC_TYPE_FILL) {
680
+ const parts = getDocParts(doc);
681
+ while (parts.length > 1 && isHardline(...parts.slice(-2))) {
682
+ parts.length -= 2;
683
+ }
684
+ if (parts.length > 0) {
685
+ const lastPart = stripDocTrailingHardlineFromDoc(at_default(false, parts, -1));
686
+ parts[parts.length - 1] = lastPart;
687
+ }
688
+ return Array.isArray(doc) ? parts : {
689
+ ...doc,
690
+ parts
691
+ };
692
+ }
693
+ switch (doc.type) {
694
+ case DOC_TYPE_ALIGN:
695
+ case DOC_TYPE_INDENT:
696
+ case DOC_TYPE_INDENT_IF_BREAK:
697
+ case DOC_TYPE_GROUP:
698
+ case DOC_TYPE_LINE_SUFFIX:
699
+ case DOC_TYPE_LABEL: {
700
+ const contents = stripDocTrailingHardlineFromDoc(doc.contents);
701
+ return {
702
+ ...doc,
703
+ contents
704
+ };
705
+ }
706
+ case DOC_TYPE_IF_BREAK: {
707
+ const breakContents = stripDocTrailingHardlineFromDoc(doc.breakContents);
708
+ const flatContents = stripDocTrailingHardlineFromDoc(doc.flatContents);
709
+ return {
710
+ ...doc,
711
+ breakContents,
712
+ flatContents
713
+ };
714
+ }
715
+ }
716
+ return doc;
717
+ }
718
+ function stripTrailingHardline(doc) {
719
+ if (typeof doc === "string") {
720
+ return doc.replace(/(?:\r?\n)*$/, "");
721
+ }
722
+ return stripDocTrailingHardlineFromDoc(cleanDoc(doc));
723
+ }
724
+ function cleanDocFn(doc) {
725
+ switch (get_doc_type_default(doc)) {
726
+ case DOC_TYPE_FILL:
727
+ if (doc.parts.every((part) => part === "")) {
728
+ return "";
729
+ }
730
+ break;
731
+ case DOC_TYPE_GROUP:
732
+ if (!doc.contents && !doc.id && !doc.break && !doc.expandedStates) {
733
+ return "";
734
+ }
735
+ if (doc.contents.type === DOC_TYPE_GROUP && doc.contents.id === doc.id && doc.contents.break === doc.break && doc.contents.expandedStates === doc.expandedStates) {
736
+ return doc.contents;
366
737
  }
367
- });
368
- var string_width_exports = {};
369
- __export(string_width_exports, {
370
- default: () => stringWidth
371
- });
372
- function stringWidth(string) {
373
- if (typeof string !== "string" || string.length === 0) {
374
- return 0;
738
+ break;
739
+ case DOC_TYPE_ALIGN:
740
+ case DOC_TYPE_INDENT:
741
+ case DOC_TYPE_INDENT_IF_BREAK:
742
+ case DOC_TYPE_LINE_SUFFIX:
743
+ if (!doc.contents) {
744
+ return "";
375
745
  }
376
- string = stripAnsi(string);
377
- if (string.length === 0) {
378
- return 0;
746
+ break;
747
+ case DOC_TYPE_IF_BREAK:
748
+ if (!doc.flatContents && !doc.breakContents) {
749
+ return "";
379
750
  }
380
- string = string.replace((0, import_emoji_regex.default)(), " ");
381
- let width = 0;
382
- for (let index = 0; index < string.length; index++) {
383
- const codePoint = string.codePointAt(index);
384
- if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
751
+ break;
752
+ case DOC_TYPE_ARRAY: {
753
+ const parts = [];
754
+ for (const part of doc) {
755
+ if (!part) {
385
756
  continue;
386
757
  }
387
- if (codePoint >= 768 && codePoint <= 879) {
388
- continue;
758
+ const [currentPart, ...restParts] = Array.isArray(part) ? part : [part];
759
+ if (typeof currentPart === "string" && typeof at_default(false, parts, -1) === "string") {
760
+ parts[parts.length - 1] += currentPart;
761
+ } else {
762
+ parts.push(currentPart);
763
+ }
764
+ parts.push(...restParts);
765
+ }
766
+ if (parts.length === 0) {
767
+ return "";
768
+ }
769
+ if (parts.length === 1) {
770
+ return parts[0];
771
+ }
772
+ return parts;
773
+ }
774
+ case DOC_TYPE_STRING:
775
+ case DOC_TYPE_CURSOR:
776
+ case DOC_TYPE_TRIM:
777
+ case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
778
+ case DOC_TYPE_LINE:
779
+ case DOC_TYPE_LABEL:
780
+ case DOC_TYPE_BREAK_PARENT:
781
+ break;
782
+ default:
783
+ throw new invalid_doc_error_default(doc);
784
+ }
785
+ return doc;
786
+ }
787
+ function cleanDoc(doc) {
788
+ return mapDoc(doc, (currentDoc) => cleanDocFn(currentDoc));
789
+ }
790
+ function normalizeParts(parts) {
791
+ const newParts = [];
792
+ const restParts = parts.filter(Boolean);
793
+ while (restParts.length > 0) {
794
+ const part = restParts.shift();
795
+ if (!part) {
796
+ continue;
797
+ }
798
+ if (Array.isArray(part)) {
799
+ restParts.unshift(...part);
800
+ continue;
801
+ }
802
+ if (newParts.length > 0 && typeof at_default(false, newParts, -1) === "string" && typeof part === "string") {
803
+ newParts[newParts.length - 1] += part;
804
+ continue;
805
+ }
806
+ newParts.push(part);
807
+ }
808
+ return newParts;
809
+ }
810
+ function normalizeDoc(doc) {
811
+ return mapDoc(doc, (currentDoc) => {
812
+ if (Array.isArray(currentDoc)) {
813
+ return normalizeParts(currentDoc);
814
+ }
815
+ if (!currentDoc.parts) {
816
+ return currentDoc;
817
+ }
818
+ return {
819
+ ...currentDoc,
820
+ parts: normalizeParts(currentDoc.parts)
821
+ };
822
+ });
823
+ }
824
+ function replaceEndOfLine(doc, replacement = literalline) {
825
+ return mapDoc(doc, (currentDoc) => typeof currentDoc === "string" ? join(replacement, currentDoc.split("\n")) : currentDoc);
826
+ }
827
+ function canBreakFn(doc) {
828
+ if (doc.type === DOC_TYPE_LINE) {
829
+ return true;
830
+ }
831
+ }
832
+ function canBreak(doc) {
833
+ return findInDoc(doc, canBreakFn, false);
834
+ }
835
+
836
+ // src/document/printer.js
837
+ var MODE_BREAK = Symbol("MODE_BREAK");
838
+ var MODE_FLAT = Symbol("MODE_FLAT");
839
+ var CURSOR_PLACEHOLDER = Symbol("cursor");
840
+ function rootIndent() {
841
+ return {
842
+ value: "",
843
+ length: 0,
844
+ queue: []
845
+ };
846
+ }
847
+ function makeIndent(ind, options) {
848
+ return generateInd(ind, {
849
+ type: "indent"
850
+ }, options);
851
+ }
852
+ function makeAlign(indent2, widthOrDoc, options) {
853
+ if (widthOrDoc === Number.NEGATIVE_INFINITY) {
854
+ return indent2.root || rootIndent();
855
+ }
856
+ if (widthOrDoc < 0) {
857
+ return generateInd(indent2, {
858
+ type: "dedent"
859
+ }, options);
860
+ }
861
+ if (!widthOrDoc) {
862
+ return indent2;
863
+ }
864
+ if (widthOrDoc.type === "root") {
865
+ return {
866
+ ...indent2,
867
+ root: indent2
868
+ };
869
+ }
870
+ const alignType = typeof widthOrDoc === "string" ? "stringAlign" : "numberAlign";
871
+ return generateInd(indent2, {
872
+ type: alignType,
873
+ n: widthOrDoc
874
+ }, options);
875
+ }
876
+ function generateInd(ind, newPart, options) {
877
+ const queue = newPart.type === "dedent" ? ind.queue.slice(0, -1) : [...ind.queue, newPart];
878
+ let value = "";
879
+ let length = 0;
880
+ let lastTabs = 0;
881
+ let lastSpaces = 0;
882
+ for (const part of queue) {
883
+ switch (part.type) {
884
+ case "indent":
885
+ flush();
886
+ if (options.useTabs) {
887
+ addTabs(1);
888
+ } else {
889
+ addSpaces(options.tabWidth);
389
890
  }
390
- if (codePoint > 65535) {
391
- index++;
891
+ break;
892
+ case "stringAlign":
893
+ flush();
894
+ value += part.n;
895
+ length += part.n.length;
896
+ break;
897
+ case "numberAlign":
898
+ lastTabs += 1;
899
+ lastSpaces += part.n;
900
+ break;
901
+ default:
902
+ throw new Error(`Unexpected type '${part.type}'`);
903
+ }
904
+ }
905
+ flushSpaces();
906
+ return {
907
+ ...ind,
908
+ value,
909
+ length,
910
+ queue
911
+ };
912
+ function addTabs(count) {
913
+ value += " ".repeat(count);
914
+ length += options.tabWidth * count;
915
+ }
916
+ function addSpaces(count) {
917
+ value += " ".repeat(count);
918
+ length += count;
919
+ }
920
+ function flush() {
921
+ if (options.useTabs) {
922
+ flushTabs();
923
+ } else {
924
+ flushSpaces();
925
+ }
926
+ }
927
+ function flushTabs() {
928
+ if (lastTabs > 0) {
929
+ addTabs(lastTabs);
930
+ }
931
+ resetLast();
932
+ }
933
+ function flushSpaces() {
934
+ if (lastSpaces > 0) {
935
+ addSpaces(lastSpaces);
936
+ }
937
+ resetLast();
938
+ }
939
+ function resetLast() {
940
+ lastTabs = 0;
941
+ lastSpaces = 0;
942
+ }
943
+ }
944
+ function trim2(out) {
945
+ let trimCount = 0;
946
+ let cursorCount = 0;
947
+ let outIndex = out.length;
948
+ outer:
949
+ while (outIndex--) {
950
+ const last = out[outIndex];
951
+ if (last === CURSOR_PLACEHOLDER) {
952
+ cursorCount++;
953
+ continue;
954
+ }
955
+ if (false) {
956
+ throw new Error(`Unexpected value in trim: '${typeof last}'`);
957
+ }
958
+ for (let charIndex = last.length - 1; charIndex >= 0; charIndex--) {
959
+ const char = last[charIndex];
960
+ if (char === " " || char === " ") {
961
+ trimCount++;
962
+ } else {
963
+ out[outIndex] = last.slice(0, charIndex + 1);
964
+ break outer;
392
965
  }
393
- width += isFullwidthCodePoint(codePoint) ? 2 : 1;
394
966
  }
395
- return width;
396
967
  }
397
- var import_emoji_regex;
398
- var init_string_width = __esm({
399
- "node_modules/string-width/index.js"() {
400
- init_define_process();
401
- init_strip_ansi();
402
- init_is_fullwidth_code_point();
403
- import_emoji_regex = __toESM(require_emoji_regex());
968
+ if (trimCount > 0 || cursorCount > 0) {
969
+ out.length = outIndex + 1;
970
+ while (cursorCount-- > 0) {
971
+ out.push(CURSOR_PLACEHOLDER);
972
+ }
973
+ }
974
+ return trimCount;
975
+ }
976
+ function fits(next, restCommands, width, hasLineSuffix, groupModeMap, mustBeFlat) {
977
+ let restIdx = restCommands.length;
978
+ const cmds = [next];
979
+ const out = [];
980
+ while (width >= 0) {
981
+ if (cmds.length === 0) {
982
+ if (restIdx === 0) {
983
+ return true;
404
984
  }
405
- });
406
- var require_get_string_width = __commonJS2({
407
- "src/utils/get-string-width.js"(exports2, module2) {
408
- "use strict";
409
- init_define_process();
410
- var stringWidth2 = (init_string_width(), __toCommonJS(string_width_exports)).default;
411
- var notAsciiRegex = /[^\x20-\x7F]/;
412
- function getStringWidth(text) {
413
- if (!text) {
414
- return 0;
415
- }
416
- if (!notAsciiRegex.test(text)) {
417
- return text.length;
418
- }
419
- return stringWidth2(text);
985
+ cmds.push(restCommands[--restIdx]);
986
+ continue;
987
+ }
988
+ const {
989
+ mode,
990
+ doc
991
+ } = cmds.pop();
992
+ switch (get_doc_type_default(doc)) {
993
+ case DOC_TYPE_STRING:
994
+ out.push(doc);
995
+ width -= get_string_width_default(doc);
996
+ break;
997
+ case DOC_TYPE_ARRAY:
998
+ case DOC_TYPE_FILL: {
999
+ const parts = getDocParts(doc);
1000
+ for (let i = parts.length - 1; i >= 0; i--) {
1001
+ cmds.push({
1002
+ mode,
1003
+ doc: parts[i]
1004
+ });
420
1005
  }
421
- module2.exports = getStringWidth;
1006
+ break;
422
1007
  }
423
- });
424
- var require_doc_utils = __commonJS2({
425
- "src/document/doc-utils.js"(exports2, module2) {
426
- "use strict";
427
- init_define_process();
428
- var getLast = require_get_last();
429
- var {
430
- literalline,
431
- join
432
- } = require_doc_builders();
433
- var isConcat = (doc) => Array.isArray(doc) || doc && doc.type === "concat";
434
- var getDocParts = (doc) => {
435
- if (Array.isArray(doc)) {
436
- return doc;
437
- }
438
- if (doc.type !== "concat" && doc.type !== "fill") {
439
- throw new Error("Expect doc type to be `concat` or `fill`.");
440
- }
441
- return doc.parts;
442
- };
443
- var traverseDocOnExitStackMarker = {};
444
- function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
445
- const docsStack = [doc];
446
- while (docsStack.length > 0) {
447
- const doc2 = docsStack.pop();
448
- if (doc2 === traverseDocOnExitStackMarker) {
449
- onExit(docsStack.pop());
450
- continue;
451
- }
452
- if (onExit) {
453
- docsStack.push(doc2, traverseDocOnExitStackMarker);
454
- }
455
- if (!onEnter || onEnter(doc2) !== false) {
456
- if (isConcat(doc2) || doc2.type === "fill") {
457
- const parts = getDocParts(doc2);
458
- for (let ic = parts.length, i = ic - 1; i >= 0; --i) {
459
- docsStack.push(parts[i]);
460
- }
461
- } else if (doc2.type === "if-break") {
462
- if (doc2.flatContents) {
463
- docsStack.push(doc2.flatContents);
464
- }
465
- if (doc2.breakContents) {
466
- docsStack.push(doc2.breakContents);
467
- }
468
- } else if (doc2.type === "group" && doc2.expandedStates) {
469
- if (shouldTraverseConditionalGroups) {
470
- for (let ic = doc2.expandedStates.length, i = ic - 1; i >= 0; --i) {
471
- docsStack.push(doc2.expandedStates[i]);
472
- }
473
- } else {
474
- docsStack.push(doc2.contents);
475
- }
476
- } else if (doc2.contents) {
477
- docsStack.push(doc2.contents);
478
- }
479
- }
480
- }
481
- }
482
- function mapDoc(doc, cb) {
483
- const mapped = /* @__PURE__ */ new Map();
484
- return rec(doc);
485
- function rec(doc2) {
486
- if (mapped.has(doc2)) {
487
- return mapped.get(doc2);
488
- }
489
- const result = process2(doc2);
490
- mapped.set(doc2, result);
491
- return result;
492
- }
493
- function process2(doc2) {
494
- if (Array.isArray(doc2)) {
495
- return cb(doc2.map(rec));
496
- }
497
- if (doc2.type === "concat" || doc2.type === "fill") {
498
- const parts = doc2.parts.map(rec);
499
- return cb(Object.assign(Object.assign({}, doc2), {}, {
500
- parts
501
- }));
502
- }
503
- if (doc2.type === "if-break") {
504
- const breakContents = doc2.breakContents && rec(doc2.breakContents);
505
- const flatContents = doc2.flatContents && rec(doc2.flatContents);
506
- return cb(Object.assign(Object.assign({}, doc2), {}, {
507
- breakContents,
508
- flatContents
509
- }));
510
- }
511
- if (doc2.type === "group" && doc2.expandedStates) {
512
- const expandedStates = doc2.expandedStates.map(rec);
513
- const contents = expandedStates[0];
514
- return cb(Object.assign(Object.assign({}, doc2), {}, {
515
- contents,
516
- expandedStates
517
- }));
518
- }
519
- if (doc2.contents) {
520
- const contents = rec(doc2.contents);
521
- return cb(Object.assign(Object.assign({}, doc2), {}, {
522
- contents
523
- }));
524
- }
525
- return cb(doc2);
526
- }
527
- }
528
- function findInDoc(doc, fn, defaultValue) {
529
- let result = defaultValue;
530
- let hasStopped = false;
531
- function findInDocOnEnterFn(doc2) {
532
- const maybeResult = fn(doc2);
533
- if (maybeResult !== void 0) {
534
- hasStopped = true;
535
- result = maybeResult;
536
- }
537
- if (hasStopped) {
538
- return false;
539
- }
540
- }
541
- traverseDoc(doc, findInDocOnEnterFn);
542
- return result;
543
- }
544
- function willBreakFn(doc) {
545
- if (doc.type === "group" && doc.break) {
546
- return true;
547
- }
548
- if (doc.type === "line" && doc.hard) {
549
- return true;
550
- }
551
- if (doc.type === "break-parent") {
552
- return true;
553
- }
554
- }
555
- function willBreak(doc) {
556
- return findInDoc(doc, willBreakFn, false);
557
- }
558
- function breakParentGroup(groupStack) {
559
- if (groupStack.length > 0) {
560
- const parentGroup = getLast(groupStack);
561
- if (!parentGroup.expandedStates && !parentGroup.break) {
562
- parentGroup.break = "propagated";
563
- }
564
- }
565
- return null;
566
- }
567
- function propagateBreaks(doc) {
568
- const alreadyVisitedSet = /* @__PURE__ */ new Set();
569
- const groupStack = [];
570
- function propagateBreaksOnEnterFn(doc2) {
571
- if (doc2.type === "break-parent") {
572
- breakParentGroup(groupStack);
573
- }
574
- if (doc2.type === "group") {
575
- groupStack.push(doc2);
576
- if (alreadyVisitedSet.has(doc2)) {
577
- return false;
578
- }
579
- alreadyVisitedSet.add(doc2);
580
- }
581
- }
582
- function propagateBreaksOnExitFn(doc2) {
583
- if (doc2.type === "group") {
584
- const group = groupStack.pop();
585
- if (group.break) {
586
- breakParentGroup(groupStack);
587
- }
588
- }
589
- }
590
- traverseDoc(doc, propagateBreaksOnEnterFn, propagateBreaksOnExitFn, true);
591
- }
592
- function removeLinesFn(doc) {
593
- if (doc.type === "line" && !doc.hard) {
594
- return doc.soft ? "" : " ";
595
- }
596
- if (doc.type === "if-break") {
597
- return doc.flatContents || "";
598
- }
599
- return doc;
600
- }
601
- function removeLines(doc) {
602
- return mapDoc(doc, removeLinesFn);
603
- }
604
- var isHardline = (doc, nextDoc) => doc && doc.type === "line" && doc.hard && nextDoc && nextDoc.type === "break-parent";
605
- function stripDocTrailingHardlineFromDoc(doc) {
606
- if (!doc) {
607
- return doc;
608
- }
609
- if (isConcat(doc) || doc.type === "fill") {
610
- const parts = getDocParts(doc);
611
- while (parts.length > 1 && isHardline(...parts.slice(-2))) {
612
- parts.length -= 2;
613
- }
614
- if (parts.length > 0) {
615
- const lastPart = stripDocTrailingHardlineFromDoc(getLast(parts));
616
- parts[parts.length - 1] = lastPart;
617
- }
618
- return Array.isArray(doc) ? parts : Object.assign(Object.assign({}, doc), {}, {
619
- parts
620
- });
621
- }
622
- switch (doc.type) {
623
- case "align":
624
- case "indent":
625
- case "indent-if-break":
626
- case "group":
627
- case "line-suffix":
628
- case "label": {
629
- const contents = stripDocTrailingHardlineFromDoc(doc.contents);
630
- return Object.assign(Object.assign({}, doc), {}, {
631
- contents
632
- });
633
- }
634
- case "if-break": {
635
- const breakContents = stripDocTrailingHardlineFromDoc(doc.breakContents);
636
- const flatContents = stripDocTrailingHardlineFromDoc(doc.flatContents);
637
- return Object.assign(Object.assign({}, doc), {}, {
638
- breakContents,
639
- flatContents
640
- });
641
- }
642
- }
643
- return doc;
644
- }
645
- function stripTrailingHardline(doc) {
646
- return stripDocTrailingHardlineFromDoc(cleanDoc(doc));
647
- }
648
- function cleanDocFn(doc) {
649
- switch (doc.type) {
650
- case "fill":
651
- if (doc.parts.every((part) => part === "")) {
652
- return "";
653
- }
654
- break;
655
- case "group":
656
- if (!doc.contents && !doc.id && !doc.break && !doc.expandedStates) {
657
- return "";
658
- }
659
- if (doc.contents.type === "group" && doc.contents.id === doc.id && doc.contents.break === doc.break && doc.contents.expandedStates === doc.expandedStates) {
660
- return doc.contents;
661
- }
662
- break;
663
- case "align":
664
- case "indent":
665
- case "indent-if-break":
666
- case "line-suffix":
667
- if (!doc.contents) {
668
- return "";
669
- }
670
- break;
671
- case "if-break":
672
- if (!doc.flatContents && !doc.breakContents) {
673
- return "";
674
- }
675
- break;
676
- }
677
- if (!isConcat(doc)) {
678
- return doc;
679
- }
680
- const parts = [];
681
- for (const part of getDocParts(doc)) {
682
- if (!part) {
683
- continue;
684
- }
685
- const [currentPart, ...restParts] = isConcat(part) ? getDocParts(part) : [part];
686
- if (typeof currentPart === "string" && typeof getLast(parts) === "string") {
687
- parts[parts.length - 1] += currentPart;
688
- } else {
689
- parts.push(currentPart);
690
- }
691
- parts.push(...restParts);
692
- }
693
- if (parts.length === 0) {
694
- return "";
695
- }
696
- if (parts.length === 1) {
697
- return parts[0];
698
- }
699
- return Array.isArray(doc) ? parts : Object.assign(Object.assign({}, doc), {}, {
700
- parts
701
- });
702
- }
703
- function cleanDoc(doc) {
704
- return mapDoc(doc, (currentDoc) => cleanDocFn(currentDoc));
705
- }
706
- function normalizeParts(parts) {
707
- const newParts = [];
708
- const restParts = parts.filter(Boolean);
709
- while (restParts.length > 0) {
710
- const part = restParts.shift();
711
- if (!part) {
712
- continue;
713
- }
714
- if (isConcat(part)) {
715
- restParts.unshift(...getDocParts(part));
716
- continue;
717
- }
718
- if (newParts.length > 0 && typeof getLast(newParts) === "string" && typeof part === "string") {
719
- newParts[newParts.length - 1] += part;
720
- continue;
721
- }
722
- newParts.push(part);
723
- }
724
- return newParts;
1008
+ case DOC_TYPE_INDENT:
1009
+ case DOC_TYPE_ALIGN:
1010
+ case DOC_TYPE_INDENT_IF_BREAK:
1011
+ case DOC_TYPE_LABEL:
1012
+ cmds.push({
1013
+ mode,
1014
+ doc: doc.contents
1015
+ });
1016
+ break;
1017
+ case DOC_TYPE_TRIM:
1018
+ width += trim2(out);
1019
+ break;
1020
+ case DOC_TYPE_GROUP: {
1021
+ if (mustBeFlat && doc.break) {
1022
+ return false;
725
1023
  }
726
- function normalizeDoc(doc) {
727
- return mapDoc(doc, (currentDoc) => {
728
- if (Array.isArray(currentDoc)) {
729
- return normalizeParts(currentDoc);
730
- }
731
- if (!currentDoc.parts) {
732
- return currentDoc;
733
- }
734
- return Object.assign(Object.assign({}, currentDoc), {}, {
735
- parts: normalizeParts(currentDoc.parts)
736
- });
1024
+ const groupMode = doc.break ? MODE_BREAK : mode;
1025
+ const contents = doc.expandedStates && groupMode === MODE_BREAK ? at_default(false, doc.expandedStates, -1) : doc.contents;
1026
+ cmds.push({
1027
+ mode: groupMode,
1028
+ doc: contents
1029
+ });
1030
+ break;
1031
+ }
1032
+ case DOC_TYPE_IF_BREAK: {
1033
+ const groupMode = doc.groupId ? groupModeMap[doc.groupId] || MODE_FLAT : mode;
1034
+ const contents = groupMode === MODE_BREAK ? doc.breakContents : doc.flatContents;
1035
+ if (contents) {
1036
+ cmds.push({
1037
+ mode,
1038
+ doc: contents
737
1039
  });
738
1040
  }
739
- function replaceEndOfLine(doc) {
740
- return mapDoc(doc, (currentDoc) => typeof currentDoc === "string" && currentDoc.includes("\n") ? replaceTextEndOfLine(currentDoc) : currentDoc);
741
- }
742
- function replaceTextEndOfLine(text) {
743
- let replacement = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : literalline;
744
- return join(replacement, text.split("\n")).parts;
745
- }
746
- function canBreakFn(doc) {
747
- if (doc.type === "line") {
748
- return true;
749
- }
750
- }
751
- function canBreak(doc) {
752
- return findInDoc(doc, canBreakFn, false);
753
- }
754
- module2.exports = {
755
- isConcat,
756
- getDocParts,
757
- willBreak,
758
- traverseDoc,
759
- findInDoc,
760
- mapDoc,
761
- propagateBreaks,
762
- removeLines,
763
- stripTrailingHardline,
764
- normalizeParts,
765
- normalizeDoc,
766
- cleanDoc,
767
- replaceTextEndOfLine,
768
- replaceEndOfLine,
769
- canBreak
770
- };
1041
+ break;
771
1042
  }
772
- });
773
- var require_doc_printer = __commonJS2({
774
- "src/document/doc-printer.js"(exports2, module2) {
775
- "use strict";
776
- init_define_process();
777
- var {
778
- convertEndOfLineToChars
779
- } = require_end_of_line();
780
- var getLast = require_get_last();
781
- var getStringWidth = require_get_string_width();
782
- var {
783
- fill,
784
- cursor,
785
- indent
786
- } = require_doc_builders();
787
- var {
788
- isConcat,
789
- getDocParts
790
- } = require_doc_utils();
791
- var groupModeMap;
792
- var MODE_BREAK = 1;
793
- var MODE_FLAT = 2;
794
- function rootIndent() {
795
- return {
796
- value: "",
797
- length: 0,
798
- queue: []
799
- };
1043
+ case DOC_TYPE_LINE:
1044
+ if (mode === MODE_BREAK || doc.hard) {
1045
+ return true;
800
1046
  }
801
- function makeIndent(ind, options) {
802
- return generateInd(ind, {
803
- type: "indent"
804
- }, options);
1047
+ if (!doc.soft) {
1048
+ out.push(" ");
1049
+ width--;
805
1050
  }
806
- function makeAlign(indent2, widthOrDoc, options) {
807
- if (widthOrDoc === Number.NEGATIVE_INFINITY) {
808
- return indent2.root || rootIndent();
809
- }
810
- if (widthOrDoc < 0) {
811
- return generateInd(indent2, {
812
- type: "dedent"
813
- }, options);
814
- }
815
- if (!widthOrDoc) {
816
- return indent2;
817
- }
818
- if (widthOrDoc.type === "root") {
819
- return Object.assign(Object.assign({}, indent2), {}, {
820
- root: indent2
821
- });
822
- }
823
- const alignType = typeof widthOrDoc === "string" ? "stringAlign" : "numberAlign";
824
- return generateInd(indent2, {
825
- type: alignType,
826
- n: widthOrDoc
827
- }, options);
1051
+ break;
1052
+ case DOC_TYPE_LINE_SUFFIX:
1053
+ hasLineSuffix = true;
1054
+ break;
1055
+ case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
1056
+ if (hasLineSuffix) {
1057
+ return false;
828
1058
  }
829
- function generateInd(ind, newPart, options) {
830
- const queue = newPart.type === "dedent" ? ind.queue.slice(0, -1) : [...ind.queue, newPart];
831
- let value = "";
832
- let length = 0;
833
- let lastTabs = 0;
834
- let lastSpaces = 0;
835
- for (const part of queue) {
836
- switch (part.type) {
837
- case "indent":
838
- flush();
839
- if (options.useTabs) {
840
- addTabs(1);
841
- } else {
842
- addSpaces(options.tabWidth);
843
- }
844
- break;
845
- case "stringAlign":
846
- flush();
847
- value += part.n;
848
- length += part.n.length;
849
- break;
850
- case "numberAlign":
851
- lastTabs += 1;
852
- lastSpaces += part.n;
853
- break;
854
- default:
855
- throw new Error("Unexpected type '".concat(part.type, "'"));
856
- }
857
- }
858
- flushSpaces();
859
- return Object.assign(Object.assign({}, ind), {}, {
860
- value,
861
- length,
862
- queue
1059
+ break;
1060
+ }
1061
+ }
1062
+ return false;
1063
+ }
1064
+ function printDocToString(doc, options) {
1065
+ const groupModeMap = {};
1066
+ const width = options.printWidth;
1067
+ const newLine = convertEndOfLineToChars(options.endOfLine);
1068
+ let pos = 0;
1069
+ const cmds = [{
1070
+ ind: rootIndent(),
1071
+ mode: MODE_BREAK,
1072
+ doc
1073
+ }];
1074
+ const out = [];
1075
+ let shouldRemeasure = false;
1076
+ const lineSuffix2 = [];
1077
+ let printedCursorCount = 0;
1078
+ while (cmds.length > 0) {
1079
+ const {
1080
+ ind,
1081
+ mode,
1082
+ doc: doc2
1083
+ } = cmds.pop();
1084
+ switch (get_doc_type_default(doc2)) {
1085
+ case DOC_TYPE_STRING: {
1086
+ const formatted = newLine !== "\n" ? doc2.replace(/\n/g, newLine) : doc2;
1087
+ out.push(formatted);
1088
+ pos += get_string_width_default(formatted);
1089
+ break;
1090
+ }
1091
+ case DOC_TYPE_ARRAY:
1092
+ for (let i = doc2.length - 1; i >= 0; i--) {
1093
+ cmds.push({
1094
+ ind,
1095
+ mode,
1096
+ doc: doc2[i]
863
1097
  });
864
- function addTabs(count) {
865
- value += " ".repeat(count);
866
- length += options.tabWidth * count;
867
- }
868
- function addSpaces(count) {
869
- value += " ".repeat(count);
870
- length += count;
871
- }
872
- function flush() {
873
- if (options.useTabs) {
874
- flushTabs();
875
- } else {
876
- flushSpaces();
877
- }
878
- }
879
- function flushTabs() {
880
- if (lastTabs > 0) {
881
- addTabs(lastTabs);
882
- }
883
- resetLast();
884
- }
885
- function flushSpaces() {
886
- if (lastSpaces > 0) {
887
- addSpaces(lastSpaces);
888
- }
889
- resetLast();
890
- }
891
- function resetLast() {
892
- lastTabs = 0;
893
- lastSpaces = 0;
894
- }
895
1098
  }
896
- function trim(out) {
897
- if (out.length === 0) {
898
- return 0;
899
- }
900
- let trimCount = 0;
901
- while (out.length > 0 && typeof getLast(out) === "string" && /^[\t ]*$/.test(getLast(out))) {
902
- trimCount += out.pop().length;
903
- }
904
- if (out.length > 0 && typeof getLast(out) === "string") {
905
- const trimmed = getLast(out).replace(/[\t ]*$/, "");
906
- trimCount += getLast(out).length - trimmed.length;
907
- out[out.length - 1] = trimmed;
908
- }
909
- return trimCount;
1099
+ break;
1100
+ case DOC_TYPE_CURSOR:
1101
+ if (printedCursorCount >= 2) {
1102
+ throw new Error("There are too many 'cursor' in doc.");
910
1103
  }
911
- function fits(next, restCommands, width, options, hasLineSuffix, mustBeFlat) {
912
- let restIdx = restCommands.length;
913
- const cmds = [next];
914
- const out = [];
915
- while (width >= 0) {
916
- if (cmds.length === 0) {
917
- if (restIdx === 0) {
918
- return true;
919
- }
920
- cmds.push(restCommands[restIdx - 1]);
921
- restIdx--;
922
- continue;
923
- }
924
- const [ind, mode, doc] = cmds.pop();
925
- if (typeof doc === "string") {
926
- out.push(doc);
927
- width -= getStringWidth(doc);
928
- } else if (isConcat(doc)) {
929
- const parts = getDocParts(doc);
930
- for (let i = parts.length - 1; i >= 0; i--) {
931
- cmds.push([ind, mode, parts[i]]);
932
- }
933
- } else {
934
- switch (doc.type) {
935
- case "indent":
936
- cmds.push([makeIndent(ind, options), mode, doc.contents]);
937
- break;
938
- case "align":
939
- cmds.push([makeAlign(ind, doc.n, options), mode, doc.contents]);
940
- break;
941
- case "trim":
942
- width += trim(out);
943
- break;
944
- case "group": {
945
- if (mustBeFlat && doc.break) {
946
- return false;
947
- }
948
- const groupMode = doc.break ? MODE_BREAK : mode;
949
- cmds.push([ind, groupMode, doc.expandedStates && groupMode === MODE_BREAK ? getLast(doc.expandedStates) : doc.contents]);
950
- if (doc.id) {
951
- groupModeMap[doc.id] = groupMode;
952
- }
953
- break;
954
- }
955
- case "fill":
956
- for (let i = doc.parts.length - 1; i >= 0; i--) {
957
- cmds.push([ind, mode, doc.parts[i]]);
958
- }
959
- break;
960
- case "if-break":
961
- case "indent-if-break": {
962
- const groupMode = doc.groupId ? groupModeMap[doc.groupId] : mode;
963
- if (groupMode === MODE_BREAK) {
964
- const breakContents = doc.type === "if-break" ? doc.breakContents : doc.negate ? doc.contents : indent(doc.contents);
965
- if (breakContents) {
966
- cmds.push([ind, mode, breakContents]);
967
- }
968
- }
969
- if (groupMode === MODE_FLAT) {
970
- const flatContents = doc.type === "if-break" ? doc.flatContents : doc.negate ? indent(doc.contents) : doc.contents;
971
- if (flatContents) {
972
- cmds.push([ind, mode, flatContents]);
973
- }
974
- }
975
- break;
976
- }
977
- case "line":
978
- switch (mode) {
979
- case MODE_FLAT:
980
- if (!doc.hard) {
981
- if (!doc.soft) {
982
- out.push(" ");
983
- width -= 1;
984
- }
985
- break;
986
- }
987
- return true;
988
- case MODE_BREAK:
989
- return true;
990
- }
991
- break;
992
- case "line-suffix":
993
- hasLineSuffix = true;
994
- break;
995
- case "line-suffix-boundary":
996
- if (hasLineSuffix) {
997
- return false;
998
- }
999
- break;
1000
- case "label":
1001
- cmds.push([ind, mode, doc.contents]);
1002
- break;
1003
- }
1104
+ out.push(CURSOR_PLACEHOLDER);
1105
+ printedCursorCount++;
1106
+ break;
1107
+ case DOC_TYPE_INDENT:
1108
+ cmds.push({
1109
+ ind: makeIndent(ind, options),
1110
+ mode,
1111
+ doc: doc2.contents
1112
+ });
1113
+ break;
1114
+ case DOC_TYPE_ALIGN:
1115
+ cmds.push({
1116
+ ind: makeAlign(ind, doc2.n, options),
1117
+ mode,
1118
+ doc: doc2.contents
1119
+ });
1120
+ break;
1121
+ case DOC_TYPE_TRIM:
1122
+ pos -= trim2(out);
1123
+ break;
1124
+ case DOC_TYPE_GROUP:
1125
+ switch (mode) {
1126
+ case MODE_FLAT:
1127
+ if (!shouldRemeasure) {
1128
+ cmds.push({
1129
+ ind,
1130
+ mode: doc2.break ? MODE_BREAK : MODE_FLAT,
1131
+ doc: doc2.contents
1132
+ });
1133
+ break;
1004
1134
  }
1005
- }
1006
- return false;
1007
- }
1008
- function printDocToString(doc, options) {
1009
- groupModeMap = {};
1010
- const width = options.printWidth;
1011
- const newLine = convertEndOfLineToChars(options.endOfLine);
1012
- let pos = 0;
1013
- const cmds = [[rootIndent(), MODE_BREAK, doc]];
1014
- const out = [];
1015
- let shouldRemeasure = false;
1016
- let lineSuffix = [];
1017
- while (cmds.length > 0) {
1018
- const [ind, mode, doc2] = cmds.pop();
1019
- if (typeof doc2 === "string") {
1020
- const formatted = newLine !== "\n" ? doc2.replace(/\n/g, newLine) : doc2;
1021
- out.push(formatted);
1022
- pos += getStringWidth(formatted);
1023
- } else if (isConcat(doc2)) {
1024
- const parts = getDocParts(doc2);
1025
- for (let i = parts.length - 1; i >= 0; i--) {
1026
- cmds.push([ind, mode, parts[i]]);
1027
- }
1135
+ case MODE_BREAK: {
1136
+ shouldRemeasure = false;
1137
+ const next = {
1138
+ ind,
1139
+ mode: MODE_FLAT,
1140
+ doc: doc2.contents
1141
+ };
1142
+ const rem = width - pos;
1143
+ const hasLineSuffix = lineSuffix2.length > 0;
1144
+ if (!doc2.break && fits(next, cmds, rem, hasLineSuffix, groupModeMap)) {
1145
+ cmds.push(next);
1028
1146
  } else {
1029
- switch (doc2.type) {
1030
- case "cursor":
1031
- out.push(cursor.placeholder);
1032
- break;
1033
- case "indent":
1034
- cmds.push([makeIndent(ind, options), mode, doc2.contents]);
1035
- break;
1036
- case "align":
1037
- cmds.push([makeAlign(ind, doc2.n, options), mode, doc2.contents]);
1038
- break;
1039
- case "trim":
1040
- pos -= trim(out);
1147
+ if (doc2.expandedStates) {
1148
+ const mostExpanded = at_default(false, doc2.expandedStates, -1);
1149
+ if (doc2.break) {
1150
+ cmds.push({
1151
+ ind,
1152
+ mode: MODE_BREAK,
1153
+ doc: mostExpanded
1154
+ });
1041
1155
  break;
1042
- case "group":
1043
- switch (mode) {
1044
- case MODE_FLAT:
1045
- if (!shouldRemeasure) {
1046
- cmds.push([ind, doc2.break ? MODE_BREAK : MODE_FLAT, doc2.contents]);
1047
- break;
1048
- }
1049
- case MODE_BREAK: {
1050
- shouldRemeasure = false;
1051
- const next = [ind, MODE_FLAT, doc2.contents];
1052
- const rem = width - pos;
1053
- const hasLineSuffix = lineSuffix.length > 0;
1054
- if (!doc2.break && fits(next, cmds, rem, options, hasLineSuffix)) {
1055
- cmds.push(next);
1056
- } else {
1057
- if (doc2.expandedStates) {
1058
- const mostExpanded = getLast(doc2.expandedStates);
1059
- if (doc2.break) {
1060
- cmds.push([ind, MODE_BREAK, mostExpanded]);
1061
- break;
1062
- } else {
1063
- for (let i = 1; i < doc2.expandedStates.length + 1; i++) {
1064
- if (i >= doc2.expandedStates.length) {
1065
- cmds.push([ind, MODE_BREAK, mostExpanded]);
1066
- break;
1067
- } else {
1068
- const state = doc2.expandedStates[i];
1069
- const cmd = [ind, MODE_FLAT, state];
1070
- if (fits(cmd, cmds, rem, options, hasLineSuffix)) {
1071
- cmds.push(cmd);
1072
- break;
1073
- }
1074
- }
1075
- }
1076
- }
1077
- } else {
1078
- cmds.push([ind, MODE_BREAK, doc2.contents]);
1079
- }
1080
- }
1156
+ } else {
1157
+ for (let i = 1; i < doc2.expandedStates.length + 1; i++) {
1158
+ if (i >= doc2.expandedStates.length) {
1159
+ cmds.push({
1160
+ ind,
1161
+ mode: MODE_BREAK,
1162
+ doc: mostExpanded
1163
+ });
1081
1164
  break;
1082
- }
1083
- }
1084
- if (doc2.id) {
1085
- groupModeMap[doc2.id] = getLast(cmds)[1];
1086
- }
1087
- break;
1088
- case "fill": {
1089
- const rem = width - pos;
1090
- const {
1091
- parts
1092
- } = doc2;
1093
- if (parts.length === 0) {
1094
- break;
1095
- }
1096
- const [content, whitespace] = parts;
1097
- const contentFlatCmd = [ind, MODE_FLAT, content];
1098
- const contentBreakCmd = [ind, MODE_BREAK, content];
1099
- const contentFits = fits(contentFlatCmd, [], rem, options, lineSuffix.length > 0, true);
1100
- if (parts.length === 1) {
1101
- if (contentFits) {
1102
- cmds.push(contentFlatCmd);
1103
1165
  } else {
1104
- cmds.push(contentBreakCmd);
1105
- }
1106
- break;
1107
- }
1108
- const whitespaceFlatCmd = [ind, MODE_FLAT, whitespace];
1109
- const whitespaceBreakCmd = [ind, MODE_BREAK, whitespace];
1110
- if (parts.length === 2) {
1111
- if (contentFits) {
1112
- cmds.push(whitespaceFlatCmd, contentFlatCmd);
1113
- } else {
1114
- cmds.push(whitespaceBreakCmd, contentBreakCmd);
1115
- }
1116
- break;
1117
- }
1118
- parts.splice(0, 2);
1119
- const remainingCmd = [ind, mode, fill(parts)];
1120
- const secondContent = parts[0];
1121
- const firstAndSecondContentFlatCmd = [ind, MODE_FLAT, [content, whitespace, secondContent]];
1122
- const firstAndSecondContentFits = fits(firstAndSecondContentFlatCmd, [], rem, options, lineSuffix.length > 0, true);
1123
- if (firstAndSecondContentFits) {
1124
- cmds.push(remainingCmd, whitespaceFlatCmd, contentFlatCmd);
1125
- } else if (contentFits) {
1126
- cmds.push(remainingCmd, whitespaceBreakCmd, contentFlatCmd);
1127
- } else {
1128
- cmds.push(remainingCmd, whitespaceBreakCmd, contentBreakCmd);
1129
- }
1130
- break;
1131
- }
1132
- case "if-break":
1133
- case "indent-if-break": {
1134
- const groupMode = doc2.groupId ? groupModeMap[doc2.groupId] : mode;
1135
- if (groupMode === MODE_BREAK) {
1136
- const breakContents = doc2.type === "if-break" ? doc2.breakContents : doc2.negate ? doc2.contents : indent(doc2.contents);
1137
- if (breakContents) {
1138
- cmds.push([ind, mode, breakContents]);
1139
- }
1140
- }
1141
- if (groupMode === MODE_FLAT) {
1142
- const flatContents = doc2.type === "if-break" ? doc2.flatContents : doc2.negate ? indent(doc2.contents) : doc2.contents;
1143
- if (flatContents) {
1144
- cmds.push([ind, mode, flatContents]);
1145
- }
1146
- }
1147
- break;
1148
- }
1149
- case "line-suffix":
1150
- lineSuffix.push([ind, mode, doc2.contents]);
1151
- break;
1152
- case "line-suffix-boundary":
1153
- if (lineSuffix.length > 0) {
1154
- cmds.push([ind, mode, {
1155
- type: "line",
1156
- hard: true
1157
- }]);
1158
- }
1159
- break;
1160
- case "line":
1161
- switch (mode) {
1162
- case MODE_FLAT:
1163
- if (!doc2.hard) {
1164
- if (!doc2.soft) {
1165
- out.push(" ");
1166
- pos += 1;
1167
- }
1168
- break;
1169
- } else {
1170
- shouldRemeasure = true;
1171
- }
1172
- case MODE_BREAK:
1173
- if (lineSuffix.length > 0) {
1174
- cmds.push([ind, mode, doc2], ...lineSuffix.reverse());
1175
- lineSuffix = [];
1166
+ const state = doc2.expandedStates[i];
1167
+ const cmd = {
1168
+ ind,
1169
+ mode: MODE_FLAT,
1170
+ doc: state
1171
+ };
1172
+ if (fits(cmd, cmds, rem, hasLineSuffix, groupModeMap)) {
1173
+ cmds.push(cmd);
1176
1174
  break;
1177
1175
  }
1178
- if (doc2.literal) {
1179
- if (ind.root) {
1180
- out.push(newLine, ind.root.value);
1181
- pos = ind.root.length;
1182
- } else {
1183
- out.push(newLine);
1184
- pos = 0;
1185
- }
1186
- } else {
1187
- pos -= trim(out);
1188
- out.push(newLine + ind.value);
1189
- pos = ind.length;
1190
- }
1191
- break;
1176
+ }
1192
1177
  }
1193
- break;
1194
- case "label":
1195
- cmds.push([ind, mode, doc2.contents]);
1196
- break;
1197
- default:
1178
+ }
1179
+ } else {
1180
+ cmds.push({
1181
+ ind,
1182
+ mode: MODE_BREAK,
1183
+ doc: doc2.contents
1184
+ });
1198
1185
  }
1199
1186
  }
1200
- if (cmds.length === 0 && lineSuffix.length > 0) {
1201
- cmds.push(...lineSuffix.reverse());
1202
- lineSuffix = [];
1203
- }
1204
- }
1205
- const cursorPlaceholderIndex = out.indexOf(cursor.placeholder);
1206
- if (cursorPlaceholderIndex !== -1) {
1207
- const otherCursorPlaceholderIndex = out.indexOf(cursor.placeholder, cursorPlaceholderIndex + 1);
1208
- const beforeCursor = out.slice(0, cursorPlaceholderIndex).join("");
1209
- const aroundCursor = out.slice(cursorPlaceholderIndex + 1, otherCursorPlaceholderIndex).join("");
1210
- const afterCursor = out.slice(otherCursorPlaceholderIndex + 1).join("");
1211
- return {
1212
- formatted: beforeCursor + aroundCursor + afterCursor,
1213
- cursorNodeStart: beforeCursor.length,
1214
- cursorNodeText: aroundCursor
1215
- };
1187
+ break;
1216
1188
  }
1217
- return {
1218
- formatted: out.join("")
1219
- };
1220
1189
  }
1221
- module2.exports = {
1222
- printDocToString
1190
+ if (doc2.id) {
1191
+ groupModeMap[doc2.id] = at_default(false, cmds, -1).mode;
1192
+ }
1193
+ break;
1194
+ case DOC_TYPE_FILL: {
1195
+ const rem = width - pos;
1196
+ const {
1197
+ parts
1198
+ } = doc2;
1199
+ if (parts.length === 0) {
1200
+ break;
1201
+ }
1202
+ const [content, whitespace] = parts;
1203
+ const contentFlatCmd = {
1204
+ ind,
1205
+ mode: MODE_FLAT,
1206
+ doc: content
1223
1207
  };
1224
- }
1225
- });
1226
- var require_doc_debug = __commonJS2({
1227
- "src/document/doc-debug.js"(exports2, module2) {
1228
- "use strict";
1229
- init_define_process();
1230
- var {
1231
- isConcat,
1232
- getDocParts
1233
- } = require_doc_utils();
1234
- function flattenDoc(doc) {
1235
- if (!doc) {
1236
- return "";
1237
- }
1238
- if (isConcat(doc)) {
1239
- const res = [];
1240
- for (const part of getDocParts(doc)) {
1241
- if (isConcat(part)) {
1242
- res.push(...flattenDoc(part).parts);
1243
- } else {
1244
- const flattened = flattenDoc(part);
1245
- if (flattened !== "") {
1246
- res.push(flattened);
1247
- }
1248
- }
1249
- }
1250
- return {
1251
- type: "concat",
1252
- parts: res
1253
- };
1208
+ const contentBreakCmd = {
1209
+ ind,
1210
+ mode: MODE_BREAK,
1211
+ doc: content
1212
+ };
1213
+ const contentFits = fits(contentFlatCmd, [], rem, lineSuffix2.length > 0, groupModeMap, true);
1214
+ if (parts.length === 1) {
1215
+ if (contentFits) {
1216
+ cmds.push(contentFlatCmd);
1217
+ } else {
1218
+ cmds.push(contentBreakCmd);
1254
1219
  }
1255
- if (doc.type === "if-break") {
1256
- return Object.assign(Object.assign({}, doc), {}, {
1257
- breakContents: flattenDoc(doc.breakContents),
1258
- flatContents: flattenDoc(doc.flatContents)
1259
- });
1220
+ break;
1221
+ }
1222
+ const whitespaceFlatCmd = {
1223
+ ind,
1224
+ mode: MODE_FLAT,
1225
+ doc: whitespace
1226
+ };
1227
+ const whitespaceBreakCmd = {
1228
+ ind,
1229
+ mode: MODE_BREAK,
1230
+ doc: whitespace
1231
+ };
1232
+ if (parts.length === 2) {
1233
+ if (contentFits) {
1234
+ cmds.push(whitespaceFlatCmd, contentFlatCmd);
1235
+ } else {
1236
+ cmds.push(whitespaceBreakCmd, contentBreakCmd);
1260
1237
  }
1261
- if (doc.type === "group") {
1262
- return Object.assign(Object.assign({}, doc), {}, {
1263
- contents: flattenDoc(doc.contents),
1264
- expandedStates: doc.expandedStates && doc.expandedStates.map(flattenDoc)
1238
+ break;
1239
+ }
1240
+ parts.splice(0, 2);
1241
+ const remainingCmd = {
1242
+ ind,
1243
+ mode,
1244
+ doc: fill(parts)
1245
+ };
1246
+ const secondContent = parts[0];
1247
+ const firstAndSecondContentFlatCmd = {
1248
+ ind,
1249
+ mode: MODE_FLAT,
1250
+ doc: [content, whitespace, secondContent]
1251
+ };
1252
+ const firstAndSecondContentFits = fits(firstAndSecondContentFlatCmd, [], rem, lineSuffix2.length > 0, groupModeMap, true);
1253
+ if (firstAndSecondContentFits) {
1254
+ cmds.push(remainingCmd, whitespaceFlatCmd, contentFlatCmd);
1255
+ } else if (contentFits) {
1256
+ cmds.push(remainingCmd, whitespaceBreakCmd, contentFlatCmd);
1257
+ } else {
1258
+ cmds.push(remainingCmd, whitespaceBreakCmd, contentBreakCmd);
1259
+ }
1260
+ break;
1261
+ }
1262
+ case DOC_TYPE_IF_BREAK:
1263
+ case DOC_TYPE_INDENT_IF_BREAK: {
1264
+ const groupMode = doc2.groupId ? groupModeMap[doc2.groupId] : mode;
1265
+ if (groupMode === MODE_BREAK) {
1266
+ const breakContents = doc2.type === DOC_TYPE_IF_BREAK ? doc2.breakContents : doc2.negate ? doc2.contents : indent(doc2.contents);
1267
+ if (breakContents) {
1268
+ cmds.push({
1269
+ ind,
1270
+ mode,
1271
+ doc: breakContents
1265
1272
  });
1266
1273
  }
1267
- if (doc.type === "fill") {
1268
- return {
1269
- type: "fill",
1270
- parts: doc.parts.map(flattenDoc)
1271
- };
1272
- }
1273
- if (doc.contents) {
1274
- return Object.assign(Object.assign({}, doc), {}, {
1275
- contents: flattenDoc(doc.contents)
1274
+ }
1275
+ if (groupMode === MODE_FLAT) {
1276
+ const flatContents = doc2.type === DOC_TYPE_IF_BREAK ? doc2.flatContents : doc2.negate ? indent(doc2.contents) : doc2.contents;
1277
+ if (flatContents) {
1278
+ cmds.push({
1279
+ ind,
1280
+ mode,
1281
+ doc: flatContents
1276
1282
  });
1277
1283
  }
1278
- return doc;
1279
1284
  }
1280
- function printDocToDebug(doc) {
1281
- const printedSymbols = /* @__PURE__ */ Object.create(null);
1282
- const usedKeysForSymbols = /* @__PURE__ */ new Set();
1283
- return printDoc(flattenDoc(doc));
1284
- function printDoc(doc2, index, parentParts) {
1285
- if (typeof doc2 === "string") {
1286
- return JSON.stringify(doc2);
1287
- }
1288
- if (isConcat(doc2)) {
1289
- const printed = getDocParts(doc2).map(printDoc).filter(Boolean);
1290
- return printed.length === 1 ? printed[0] : "[".concat(printed.join(", "), "]");
1291
- }
1292
- if (doc2.type === "line") {
1293
- const withBreakParent = Array.isArray(parentParts) && parentParts[index + 1] && parentParts[index + 1].type === "break-parent";
1294
- if (doc2.literal) {
1295
- return withBreakParent ? "literalline" : "literallineWithoutBreakParent";
1296
- }
1297
- if (doc2.hard) {
1298
- return withBreakParent ? "hardline" : "hardlineWithoutBreakParent";
1299
- }
1300
- if (doc2.soft) {
1301
- return "softline";
1302
- }
1303
- return "line";
1304
- }
1305
- if (doc2.type === "break-parent") {
1306
- const afterHardline = Array.isArray(parentParts) && parentParts[index - 1] && parentParts[index - 1].type === "line" && parentParts[index - 1].hard;
1307
- return afterHardline ? void 0 : "breakParent";
1308
- }
1309
- if (doc2.type === "trim") {
1310
- return "trim";
1311
- }
1312
- if (doc2.type === "indent") {
1313
- return "indent(" + printDoc(doc2.contents) + ")";
1314
- }
1315
- if (doc2.type === "align") {
1316
- 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) + ")";
1317
- }
1318
- if (doc2.type === "if-break") {
1319
- return "ifBreak(" + printDoc(doc2.breakContents) + (doc2.flatContents ? ", " + printDoc(doc2.flatContents) : "") + (doc2.groupId ? (!doc2.flatContents ? ', ""' : "") + ", { groupId: ".concat(printGroupId(doc2.groupId), " }") : "") + ")";
1320
- }
1321
- if (doc2.type === "indent-if-break") {
1322
- const optionsParts = [];
1323
- if (doc2.negate) {
1324
- optionsParts.push("negate: true");
1325
- }
1326
- if (doc2.groupId) {
1327
- optionsParts.push("groupId: ".concat(printGroupId(doc2.groupId)));
1328
- }
1329
- const options = optionsParts.length > 0 ? ", { ".concat(optionsParts.join(", "), " }") : "";
1330
- return "indentIfBreak(".concat(printDoc(doc2.contents)).concat(options, ")");
1331
- }
1332
- if (doc2.type === "group") {
1333
- const optionsParts = [];
1334
- if (doc2.break && doc2.break !== "propagated") {
1335
- optionsParts.push("shouldBreak: true");
1336
- }
1337
- if (doc2.id) {
1338
- optionsParts.push("id: ".concat(printGroupId(doc2.id)));
1339
- }
1340
- const options = optionsParts.length > 0 ? ", { ".concat(optionsParts.join(", "), " }") : "";
1341
- if (doc2.expandedStates) {
1342
- return "conditionalGroup([".concat(doc2.expandedStates.map((part) => printDoc(part)).join(","), "]").concat(options, ")");
1285
+ break;
1286
+ }
1287
+ case DOC_TYPE_LINE_SUFFIX:
1288
+ lineSuffix2.push({
1289
+ ind,
1290
+ mode,
1291
+ doc: doc2.contents
1292
+ });
1293
+ break;
1294
+ case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
1295
+ if (lineSuffix2.length > 0) {
1296
+ cmds.push({
1297
+ ind,
1298
+ mode,
1299
+ doc: hardlineWithoutBreakParent
1300
+ });
1301
+ }
1302
+ break;
1303
+ case DOC_TYPE_LINE:
1304
+ switch (mode) {
1305
+ case MODE_FLAT:
1306
+ if (!doc2.hard) {
1307
+ if (!doc2.soft) {
1308
+ out.push(" ");
1309
+ pos += 1;
1343
1310
  }
1344
- return "group(".concat(printDoc(doc2.contents)).concat(options, ")");
1345
- }
1346
- if (doc2.type === "fill") {
1347
- return "fill([".concat(doc2.parts.map((part) => printDoc(part)).join(", "), "])");
1348
- }
1349
- if (doc2.type === "line-suffix") {
1350
- return "lineSuffix(" + printDoc(doc2.contents) + ")";
1351
- }
1352
- if (doc2.type === "line-suffix-boundary") {
1353
- return "lineSuffixBoundary";
1354
- }
1355
- if (doc2.type === "label") {
1356
- return "label(".concat(JSON.stringify(doc2.label), ", ").concat(printDoc(doc2.contents), ")");
1357
- }
1358
- throw new Error("Unknown doc type " + doc2.type);
1359
- }
1360
- function printGroupId(id) {
1361
- if (typeof id !== "symbol") {
1362
- return JSON.stringify(String(id));
1311
+ break;
1312
+ } else {
1313
+ shouldRemeasure = true;
1363
1314
  }
1364
- if (id in printedSymbols) {
1365
- return printedSymbols[id];
1315
+ case MODE_BREAK:
1316
+ if (lineSuffix2.length > 0) {
1317
+ cmds.push({
1318
+ ind,
1319
+ mode,
1320
+ doc: doc2
1321
+ }, ...lineSuffix2.reverse());
1322
+ lineSuffix2.length = 0;
1323
+ break;
1366
1324
  }
1367
- const prefix = String(id).slice(7, -1) || "symbol";
1368
- for (let counter = 0; ; counter++) {
1369
- const key = prefix + (counter > 0 ? " #".concat(counter) : "");
1370
- if (!usedKeysForSymbols.has(key)) {
1371
- usedKeysForSymbols.add(key);
1372
- return printedSymbols[id] = "Symbol.for(".concat(JSON.stringify(key), ")");
1325
+ if (doc2.literal) {
1326
+ if (ind.root) {
1327
+ out.push(newLine, ind.root.value);
1328
+ pos = ind.root.length;
1329
+ } else {
1330
+ out.push(newLine);
1331
+ pos = 0;
1373
1332
  }
1333
+ } else {
1334
+ pos -= trim2(out);
1335
+ out.push(newLine + ind.value);
1336
+ pos = ind.length;
1374
1337
  }
1375
- }
1338
+ break;
1376
1339
  }
1377
- module2.exports = {
1378
- printDocToDebug
1379
- };
1380
- }
1381
- });
1382
- init_define_process();
1383
- module.exports = {
1384
- builders: require_doc_builders(),
1385
- printer: require_doc_printer(),
1386
- utils: require_doc_utils(),
1387
- debug: require_doc_debug()
1340
+ break;
1341
+ case DOC_TYPE_LABEL:
1342
+ cmds.push({
1343
+ ind,
1344
+ mode,
1345
+ doc: doc2.contents
1346
+ });
1347
+ break;
1348
+ case DOC_TYPE_BREAK_PARENT:
1349
+ break;
1350
+ default:
1351
+ throw new invalid_doc_error_default(doc2);
1352
+ }
1353
+ if (cmds.length === 0 && lineSuffix2.length > 0) {
1354
+ cmds.push(...lineSuffix2.reverse());
1355
+ lineSuffix2.length = 0;
1356
+ }
1357
+ }
1358
+ const cursorPlaceholderIndex = out.indexOf(CURSOR_PLACEHOLDER);
1359
+ if (cursorPlaceholderIndex !== -1) {
1360
+ const otherCursorPlaceholderIndex = out.indexOf(CURSOR_PLACEHOLDER, cursorPlaceholderIndex + 1);
1361
+ const beforeCursor = out.slice(0, cursorPlaceholderIndex).join("");
1362
+ const aroundCursor = out.slice(cursorPlaceholderIndex + 1, otherCursorPlaceholderIndex).join("");
1363
+ const afterCursor = out.slice(otherCursorPlaceholderIndex + 1).join("");
1364
+ return {
1365
+ formatted: beforeCursor + aroundCursor + afterCursor,
1366
+ cursorNodeStart: beforeCursor.length,
1367
+ cursorNodeText: aroundCursor
1388
1368
  };
1389
1369
  }
1370
+ return {
1371
+ formatted: out.join("")
1372
+ };
1373
+ }
1374
+
1375
+ // src/document/debug.js
1376
+ var debug_exports = {};
1377
+ __export(debug_exports, {
1378
+ printDocToDebug: () => printDocToDebug
1390
1379
  });
1391
- return require_doc_js_umd();
1380
+ init_define_process();
1381
+ function flattenDoc(doc) {
1382
+ if (!doc) {
1383
+ return "";
1384
+ }
1385
+ if (Array.isArray(doc)) {
1386
+ const res = [];
1387
+ for (const part of doc) {
1388
+ if (Array.isArray(part)) {
1389
+ res.push(...flattenDoc(part));
1390
+ } else {
1391
+ const flattened = flattenDoc(part);
1392
+ if (flattened !== "") {
1393
+ res.push(flattened);
1394
+ }
1395
+ }
1396
+ }
1397
+ return res;
1398
+ }
1399
+ if (doc.type === DOC_TYPE_IF_BREAK) {
1400
+ return {
1401
+ ...doc,
1402
+ breakContents: flattenDoc(doc.breakContents),
1403
+ flatContents: flattenDoc(doc.flatContents)
1404
+ };
1405
+ }
1406
+ if (doc.type === DOC_TYPE_GROUP) {
1407
+ return {
1408
+ ...doc,
1409
+ contents: flattenDoc(doc.contents),
1410
+ expandedStates: doc.expandedStates && doc.expandedStates.map(flattenDoc)
1411
+ };
1412
+ }
1413
+ if (doc.type === DOC_TYPE_FILL) {
1414
+ return { type: "fill", parts: doc.parts.map(flattenDoc) };
1415
+ }
1416
+ if (doc.contents) {
1417
+ return { ...doc, contents: flattenDoc(doc.contents) };
1418
+ }
1419
+ return doc;
1420
+ }
1421
+ function printDocToDebug(doc) {
1422
+ const printedSymbols = /* @__PURE__ */ Object.create(null);
1423
+ const usedKeysForSymbols = /* @__PURE__ */ new Set();
1424
+ return printDoc(flattenDoc(doc));
1425
+ function printDoc(doc2, index, parentParts) {
1426
+ if (typeof doc2 === "string") {
1427
+ return JSON.stringify(doc2);
1428
+ }
1429
+ if (Array.isArray(doc2)) {
1430
+ const printed = doc2.map(printDoc).filter(Boolean);
1431
+ return printed.length === 1 ? printed[0] : `[${printed.join(", ")}]`;
1432
+ }
1433
+ if (doc2.type === DOC_TYPE_LINE) {
1434
+ const withBreakParent = Array.isArray(parentParts) && parentParts[index + 1] && parentParts[index + 1].type === DOC_TYPE_BREAK_PARENT;
1435
+ if (doc2.literal) {
1436
+ return withBreakParent ? "literalline" : "literallineWithoutBreakParent";
1437
+ }
1438
+ if (doc2.hard) {
1439
+ return withBreakParent ? "hardline" : "hardlineWithoutBreakParent";
1440
+ }
1441
+ if (doc2.soft) {
1442
+ return "softline";
1443
+ }
1444
+ return "line";
1445
+ }
1446
+ if (doc2.type === DOC_TYPE_BREAK_PARENT) {
1447
+ const afterHardline = Array.isArray(parentParts) && parentParts[index - 1] && parentParts[index - 1].type === DOC_TYPE_LINE && parentParts[index - 1].hard;
1448
+ return afterHardline ? void 0 : "breakParent";
1449
+ }
1450
+ if (doc2.type === DOC_TYPE_TRIM) {
1451
+ return "trim";
1452
+ }
1453
+ if (doc2.type === DOC_TYPE_INDENT) {
1454
+ return "indent(" + printDoc(doc2.contents) + ")";
1455
+ }
1456
+ if (doc2.type === DOC_TYPE_ALIGN) {
1457
+ 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) + ")";
1458
+ }
1459
+ if (doc2.type === DOC_TYPE_IF_BREAK) {
1460
+ return "ifBreak(" + printDoc(doc2.breakContents) + (doc2.flatContents ? ", " + printDoc(doc2.flatContents) : "") + (doc2.groupId ? (!doc2.flatContents ? ', ""' : "") + `, { groupId: ${printGroupId(doc2.groupId)} }` : "") + ")";
1461
+ }
1462
+ if (doc2.type === DOC_TYPE_INDENT_IF_BREAK) {
1463
+ const optionsParts = [];
1464
+ if (doc2.negate) {
1465
+ optionsParts.push("negate: true");
1466
+ }
1467
+ if (doc2.groupId) {
1468
+ optionsParts.push(`groupId: ${printGroupId(doc2.groupId)}`);
1469
+ }
1470
+ const options = optionsParts.length > 0 ? `, { ${optionsParts.join(", ")} }` : "";
1471
+ return `indentIfBreak(${printDoc(doc2.contents)}${options})`;
1472
+ }
1473
+ if (doc2.type === DOC_TYPE_GROUP) {
1474
+ const optionsParts = [];
1475
+ if (doc2.break && doc2.break !== "propagated") {
1476
+ optionsParts.push("shouldBreak: true");
1477
+ }
1478
+ if (doc2.id) {
1479
+ optionsParts.push(`id: ${printGroupId(doc2.id)}`);
1480
+ }
1481
+ const options = optionsParts.length > 0 ? `, { ${optionsParts.join(", ")} }` : "";
1482
+ if (doc2.expandedStates) {
1483
+ return `conditionalGroup([${doc2.expandedStates.map((part) => printDoc(part)).join(",")}]${options})`;
1484
+ }
1485
+ return `group(${printDoc(doc2.contents)}${options})`;
1486
+ }
1487
+ if (doc2.type === DOC_TYPE_FILL) {
1488
+ return `fill([${doc2.parts.map((part) => printDoc(part)).join(", ")}])`;
1489
+ }
1490
+ if (doc2.type === DOC_TYPE_LINE_SUFFIX) {
1491
+ return "lineSuffix(" + printDoc(doc2.contents) + ")";
1492
+ }
1493
+ if (doc2.type === DOC_TYPE_LINE_SUFFIX_BOUNDARY) {
1494
+ return "lineSuffixBoundary";
1495
+ }
1496
+ if (doc2.type === DOC_TYPE_LABEL) {
1497
+ return `label(${JSON.stringify(doc2.label)}, ${printDoc(doc2.contents)})`;
1498
+ }
1499
+ throw new Error("Unknown doc type " + doc2.type);
1500
+ }
1501
+ function printGroupId(id) {
1502
+ if (typeof id !== "symbol") {
1503
+ return JSON.stringify(String(id));
1504
+ }
1505
+ if (id in printedSymbols) {
1506
+ return printedSymbols[id];
1507
+ }
1508
+ const prefix = id.description || "symbol";
1509
+ for (let counter = 0; ; counter++) {
1510
+ const key = prefix + (counter > 0 ? ` #${counter}` : "");
1511
+ if (!usedKeysForSymbols.has(key)) {
1512
+ usedKeysForSymbols.add(key);
1513
+ return printedSymbols[id] = `Symbol.for(${JSON.stringify(key)})`;
1514
+ }
1515
+ }
1516
+ }
1517
+ }
1518
+ return __toCommonJS(document_exports);
1392
1519
  });