doc.mjs 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312
  1. var __defProp = Object.defineProperty;
  2. var __export = (target, all) => {
  3. for (var name in all)
  4. __defProp(target, name, { get: all[name], enumerable: true });
  5. };
  6. // src/document/public.js
  7. var public_exports = {};
  8. __export(public_exports, {
  9. builders: () => builders,
  10. printer: () => printer,
  11. utils: () => utils
  12. });
  13. // src/document/constants.js
  14. var DOC_TYPE_STRING = "string";
  15. var DOC_TYPE_ARRAY = "array";
  16. var DOC_TYPE_CURSOR = "cursor";
  17. var DOC_TYPE_INDENT = "indent";
  18. var DOC_TYPE_ALIGN = "align";
  19. var DOC_TYPE_TRIM = "trim";
  20. var DOC_TYPE_GROUP = "group";
  21. var DOC_TYPE_FILL = "fill";
  22. var DOC_TYPE_IF_BREAK = "if-break";
  23. var DOC_TYPE_INDENT_IF_BREAK = "indent-if-break";
  24. var DOC_TYPE_LINE_SUFFIX = "line-suffix";
  25. var DOC_TYPE_LINE_SUFFIX_BOUNDARY = "line-suffix-boundary";
  26. var DOC_TYPE_LINE = "line";
  27. var DOC_TYPE_LABEL = "label";
  28. var DOC_TYPE_BREAK_PARENT = "break-parent";
  29. var VALID_OBJECT_DOC_TYPES = /* @__PURE__ */ new Set([
  30. DOC_TYPE_CURSOR,
  31. DOC_TYPE_INDENT,
  32. DOC_TYPE_ALIGN,
  33. DOC_TYPE_TRIM,
  34. DOC_TYPE_GROUP,
  35. DOC_TYPE_FILL,
  36. DOC_TYPE_IF_BREAK,
  37. DOC_TYPE_INDENT_IF_BREAK,
  38. DOC_TYPE_LINE_SUFFIX,
  39. DOC_TYPE_LINE_SUFFIX_BOUNDARY,
  40. DOC_TYPE_LINE,
  41. DOC_TYPE_LABEL,
  42. DOC_TYPE_BREAK_PARENT
  43. ]);
  44. // src/document/utils/get-doc-type.js
  45. function getDocType(doc) {
  46. if (typeof doc === "string") {
  47. return DOC_TYPE_STRING;
  48. }
  49. if (Array.isArray(doc)) {
  50. return DOC_TYPE_ARRAY;
  51. }
  52. if (!doc) {
  53. return;
  54. }
  55. const { type } = doc;
  56. if (VALID_OBJECT_DOC_TYPES.has(type)) {
  57. return type;
  58. }
  59. }
  60. var get_doc_type_default = getDocType;
  61. // src/document/invalid-doc-error.js
  62. var disjunctionListFormat = (list) => new Intl.ListFormat("en-US", { type: "disjunction" }).format(list);
  63. function getDocErrorMessage(doc) {
  64. const type = doc === null ? "null" : typeof doc;
  65. if (type !== "string" && type !== "object") {
  66. return `Unexpected doc '${type}',
  67. Expected it to be 'string' or 'object'.`;
  68. }
  69. if (get_doc_type_default(doc)) {
  70. throw new Error("doc is valid.");
  71. }
  72. const objectType = Object.prototype.toString.call(doc);
  73. if (objectType !== "[object Object]") {
  74. return `Unexpected doc '${objectType}'.`;
  75. }
  76. const EXPECTED_TYPE_VALUES = disjunctionListFormat(
  77. [...VALID_OBJECT_DOC_TYPES].map((type2) => `'${type2}'`)
  78. );
  79. return `Unexpected doc.type '${doc.type}'.
  80. Expected it to be ${EXPECTED_TYPE_VALUES}.`;
  81. }
  82. var InvalidDocError = class extends Error {
  83. name = "InvalidDocError";
  84. constructor(doc) {
  85. super(getDocErrorMessage(doc));
  86. this.doc = doc;
  87. }
  88. };
  89. var invalid_doc_error_default = InvalidDocError;
  90. // src/document/utils/traverse-doc.js
  91. var traverseDocOnExitStackMarker = {};
  92. function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
  93. const docsStack = [doc];
  94. while (docsStack.length > 0) {
  95. const doc2 = docsStack.pop();
  96. if (doc2 === traverseDocOnExitStackMarker) {
  97. onExit(docsStack.pop());
  98. continue;
  99. }
  100. if (onExit) {
  101. docsStack.push(doc2, traverseDocOnExitStackMarker);
  102. }
  103. const docType = get_doc_type_default(doc2);
  104. if (!docType) {
  105. throw new invalid_doc_error_default(doc2);
  106. }
  107. if ((onEnter == null ? void 0 : onEnter(doc2)) === false) {
  108. continue;
  109. }
  110. switch (docType) {
  111. case DOC_TYPE_ARRAY:
  112. case DOC_TYPE_FILL: {
  113. const parts = docType === DOC_TYPE_ARRAY ? doc2 : doc2.parts;
  114. for (let ic = parts.length, i = ic - 1; i >= 0; --i) {
  115. docsStack.push(parts[i]);
  116. }
  117. break;
  118. }
  119. case DOC_TYPE_IF_BREAK:
  120. docsStack.push(doc2.flatContents, doc2.breakContents);
  121. break;
  122. case DOC_TYPE_GROUP:
  123. if (shouldTraverseConditionalGroups && doc2.expandedStates) {
  124. for (let ic = doc2.expandedStates.length, i = ic - 1; i >= 0; --i) {
  125. docsStack.push(doc2.expandedStates[i]);
  126. }
  127. } else {
  128. docsStack.push(doc2.contents);
  129. }
  130. break;
  131. case DOC_TYPE_ALIGN:
  132. case DOC_TYPE_INDENT:
  133. case DOC_TYPE_INDENT_IF_BREAK:
  134. case DOC_TYPE_LABEL:
  135. case DOC_TYPE_LINE_SUFFIX:
  136. docsStack.push(doc2.contents);
  137. break;
  138. case DOC_TYPE_STRING:
  139. case DOC_TYPE_CURSOR:
  140. case DOC_TYPE_TRIM:
  141. case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
  142. case DOC_TYPE_LINE:
  143. case DOC_TYPE_BREAK_PARENT:
  144. break;
  145. default:
  146. throw new invalid_doc_error_default(doc2);
  147. }
  148. }
  149. }
  150. var traverse_doc_default = traverseDoc;
  151. // src/document/utils/assert-doc.js
  152. var noop = () => {
  153. };
  154. var assertDoc = true ? noop : function(doc) {
  155. traverse_doc_default(doc, (doc2) => {
  156. if (checked.has(doc2)) {
  157. return false;
  158. }
  159. if (typeof doc2 !== "string") {
  160. checked.add(doc2);
  161. }
  162. });
  163. };
  164. var assertDocArray = true ? noop : function(docs, optional = false) {
  165. if (optional && !docs) {
  166. return;
  167. }
  168. if (!Array.isArray(docs)) {
  169. throw new TypeError("Unexpected doc array.");
  170. }
  171. for (const doc of docs) {
  172. assertDoc(doc);
  173. }
  174. };
  175. // src/document/builders.js
  176. function indent(contents) {
  177. assertDoc(contents);
  178. return { type: DOC_TYPE_INDENT, contents };
  179. }
  180. function align(widthOrString, contents) {
  181. assertDoc(contents);
  182. return { type: DOC_TYPE_ALIGN, contents, n: widthOrString };
  183. }
  184. function group(contents, opts = {}) {
  185. assertDoc(contents);
  186. assertDocArray(
  187. opts.expandedStates,
  188. /* optional */
  189. true
  190. );
  191. return {
  192. type: DOC_TYPE_GROUP,
  193. id: opts.id,
  194. contents,
  195. break: Boolean(opts.shouldBreak),
  196. expandedStates: opts.expandedStates
  197. };
  198. }
  199. function dedentToRoot(contents) {
  200. return align(Number.NEGATIVE_INFINITY, contents);
  201. }
  202. function markAsRoot(contents) {
  203. return align({ type: "root" }, contents);
  204. }
  205. function dedent(contents) {
  206. return align(-1, contents);
  207. }
  208. function conditionalGroup(states, opts) {
  209. return group(states[0], { ...opts, expandedStates: states });
  210. }
  211. function fill(parts) {
  212. assertDocArray(parts);
  213. return { type: DOC_TYPE_FILL, parts };
  214. }
  215. function ifBreak(breakContents, flatContents = "", opts = {}) {
  216. assertDoc(breakContents);
  217. if (flatContents !== "") {
  218. assertDoc(flatContents);
  219. }
  220. return {
  221. type: DOC_TYPE_IF_BREAK,
  222. breakContents,
  223. flatContents,
  224. groupId: opts.groupId
  225. };
  226. }
  227. function indentIfBreak(contents, opts) {
  228. assertDoc(contents);
  229. return {
  230. type: DOC_TYPE_INDENT_IF_BREAK,
  231. contents,
  232. groupId: opts.groupId,
  233. negate: opts.negate
  234. };
  235. }
  236. function lineSuffix(contents) {
  237. assertDoc(contents);
  238. return { type: DOC_TYPE_LINE_SUFFIX, contents };
  239. }
  240. var lineSuffixBoundary = { type: DOC_TYPE_LINE_SUFFIX_BOUNDARY };
  241. var breakParent = { type: DOC_TYPE_BREAK_PARENT };
  242. var trim = { type: DOC_TYPE_TRIM };
  243. var hardlineWithoutBreakParent = { type: DOC_TYPE_LINE, hard: true };
  244. var literallineWithoutBreakParent = {
  245. type: DOC_TYPE_LINE,
  246. hard: true,
  247. literal: true
  248. };
  249. var line = { type: DOC_TYPE_LINE };
  250. var softline = { type: DOC_TYPE_LINE, soft: true };
  251. var hardline = [hardlineWithoutBreakParent, breakParent];
  252. var literalline = [literallineWithoutBreakParent, breakParent];
  253. var cursor = { type: DOC_TYPE_CURSOR };
  254. function join(separator, docs) {
  255. assertDoc(separator);
  256. assertDocArray(docs);
  257. const parts = [];
  258. for (let i = 0; i < docs.length; i++) {
  259. if (i !== 0) {
  260. parts.push(separator);
  261. }
  262. parts.push(docs[i]);
  263. }
  264. return parts;
  265. }
  266. function addAlignmentToDoc(doc, size, tabWidth) {
  267. assertDoc(doc);
  268. let aligned = doc;
  269. if (size > 0) {
  270. for (let i = 0; i < Math.floor(size / tabWidth); ++i) {
  271. aligned = indent(aligned);
  272. }
  273. aligned = align(size % tabWidth, aligned);
  274. aligned = align(Number.NEGATIVE_INFINITY, aligned);
  275. }
  276. return aligned;
  277. }
  278. function label(label2, contents) {
  279. assertDoc(contents);
  280. return label2 ? { type: DOC_TYPE_LABEL, label: label2, contents } : contents;
  281. }
  282. // scripts/build/shims/at.js
  283. var at = (isOptionalObject, object, index) => {
  284. if (isOptionalObject && (object === void 0 || object === null)) {
  285. return;
  286. }
  287. if (Array.isArray(object) || typeof object === "string") {
  288. return object[index < 0 ? object.length + index : index];
  289. }
  290. return object.at(index);
  291. };
  292. var at_default = at;
  293. // scripts/build/shims/string-replace-all.js
  294. var stringReplaceAll = (isOptionalObject, original, pattern, replacement) => {
  295. if (isOptionalObject && (original === void 0 || original === null)) {
  296. return;
  297. }
  298. if (original.replaceAll) {
  299. return original.replaceAll(pattern, replacement);
  300. }
  301. if (pattern.global) {
  302. return original.replace(pattern, replacement);
  303. }
  304. return original.split(pattern).join(replacement);
  305. };
  306. var string_replace_all_default = stringReplaceAll;
  307. // src/common/end-of-line.js
  308. function convertEndOfLineToChars(value) {
  309. switch (value) {
  310. case "cr":
  311. return "\r";
  312. case "crlf":
  313. return "\r\n";
  314. default:
  315. return "\n";
  316. }
  317. }
  318. // node_modules/emoji-regex/index.mjs
  319. var emoji_regex_default = () => {
  320. return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC3\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\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]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC08\uDC26](?:\u200D\u2B1B)?|[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\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\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC2\uDECE-\uDEDB\uDEE0-\uDEE8]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
  321. };
  322. // node_modules/eastasianwidth/eastasianwidth.js
  323. var eastasianwidth_default = {
  324. eastAsianWidth(character) {
  325. var x = character.charCodeAt(0);
  326. var y = character.length == 2 ? character.charCodeAt(1) : 0;
  327. var codePoint = x;
  328. if (55296 <= x && x <= 56319 && 56320 <= y && y <= 57343) {
  329. x &= 1023;
  330. y &= 1023;
  331. codePoint = x << 10 | y;
  332. codePoint += 65536;
  333. }
  334. if (12288 == codePoint || 65281 <= codePoint && codePoint <= 65376 || 65504 <= codePoint && codePoint <= 65510) {
  335. return "F";
  336. }
  337. if (4352 <= codePoint && codePoint <= 4447 || 4515 <= codePoint && codePoint <= 4519 || 4602 <= codePoint && codePoint <= 4607 || 9001 <= codePoint && codePoint <= 9002 || 11904 <= codePoint && codePoint <= 11929 || 11931 <= codePoint && codePoint <= 12019 || 12032 <= codePoint && codePoint <= 12245 || 12272 <= codePoint && codePoint <= 12283 || 12289 <= codePoint && codePoint <= 12350 || 12353 <= codePoint && codePoint <= 12438 || 12441 <= codePoint && codePoint <= 12543 || 12549 <= codePoint && codePoint <= 12589 || 12593 <= codePoint && codePoint <= 12686 || 12688 <= codePoint && codePoint <= 12730 || 12736 <= codePoint && codePoint <= 12771 || 12784 <= codePoint && codePoint <= 12830 || 12832 <= codePoint && codePoint <= 12871 || 12880 <= codePoint && codePoint <= 13054 || 13056 <= codePoint && codePoint <= 19903 || 19968 <= codePoint && codePoint <= 42124 || 42128 <= codePoint && codePoint <= 42182 || 43360 <= codePoint && codePoint <= 43388 || 44032 <= codePoint && codePoint <= 55203 || 55216 <= codePoint && codePoint <= 55238 || 55243 <= codePoint && codePoint <= 55291 || 63744 <= codePoint && codePoint <= 64255 || 65040 <= codePoint && codePoint <= 65049 || 65072 <= codePoint && codePoint <= 65106 || 65108 <= codePoint && codePoint <= 65126 || 65128 <= codePoint && codePoint <= 65131 || 110592 <= codePoint && codePoint <= 110593 || 127488 <= codePoint && codePoint <= 127490 || 127504 <= codePoint && codePoint <= 127546 || 127552 <= codePoint && codePoint <= 127560 || 127568 <= codePoint && codePoint <= 127569 || 131072 <= codePoint && codePoint <= 194367 || 177984 <= codePoint && codePoint <= 196605 || 196608 <= codePoint && codePoint <= 262141) {
  338. return "W";
  339. }
  340. return "N";
  341. }
  342. };
  343. // src/utils/get-string-width.js
  344. var notAsciiRegex = /[^\x20-\x7F]/;
  345. function getStringWidth(text) {
  346. if (!text) {
  347. return 0;
  348. }
  349. if (!notAsciiRegex.test(text)) {
  350. return text.length;
  351. }
  352. text = text.replace(emoji_regex_default(), " ");
  353. let width = 0;
  354. for (const character of text) {
  355. const codePoint = character.codePointAt(0);
  356. if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
  357. continue;
  358. }
  359. if (codePoint >= 768 && codePoint <= 879) {
  360. continue;
  361. }
  362. const code = eastasianwidth_default.eastAsianWidth(character);
  363. width += code === "F" || code === "W" ? 2 : 1;
  364. }
  365. return width;
  366. }
  367. var get_string_width_default = getStringWidth;
  368. // src/document/utils.js
  369. var getDocParts = (doc) => {
  370. if (Array.isArray(doc)) {
  371. return doc;
  372. }
  373. if (doc.type !== DOC_TYPE_FILL) {
  374. throw new Error(`Expect doc to be 'array' or '${DOC_TYPE_FILL}'.`);
  375. }
  376. return doc.parts;
  377. };
  378. function mapDoc(doc, cb) {
  379. if (typeof doc === "string") {
  380. return cb(doc);
  381. }
  382. const mapped = /* @__PURE__ */ new Map();
  383. return rec(doc);
  384. function rec(doc2) {
  385. if (mapped.has(doc2)) {
  386. return mapped.get(doc2);
  387. }
  388. const result = process2(doc2);
  389. mapped.set(doc2, result);
  390. return result;
  391. }
  392. function process2(doc2) {
  393. switch (get_doc_type_default(doc2)) {
  394. case DOC_TYPE_ARRAY:
  395. return cb(doc2.map(rec));
  396. case DOC_TYPE_FILL:
  397. return cb({
  398. ...doc2,
  399. parts: doc2.parts.map(rec)
  400. });
  401. case DOC_TYPE_IF_BREAK:
  402. return cb({
  403. ...doc2,
  404. breakContents: rec(doc2.breakContents),
  405. flatContents: rec(doc2.flatContents)
  406. });
  407. case DOC_TYPE_GROUP: {
  408. let {
  409. expandedStates,
  410. contents
  411. } = doc2;
  412. if (expandedStates) {
  413. expandedStates = expandedStates.map(rec);
  414. contents = expandedStates[0];
  415. } else {
  416. contents = rec(contents);
  417. }
  418. return cb({
  419. ...doc2,
  420. contents,
  421. expandedStates
  422. });
  423. }
  424. case DOC_TYPE_ALIGN:
  425. case DOC_TYPE_INDENT:
  426. case DOC_TYPE_INDENT_IF_BREAK:
  427. case DOC_TYPE_LABEL:
  428. case DOC_TYPE_LINE_SUFFIX:
  429. return cb({
  430. ...doc2,
  431. contents: rec(doc2.contents)
  432. });
  433. case DOC_TYPE_STRING:
  434. case DOC_TYPE_CURSOR:
  435. case DOC_TYPE_TRIM:
  436. case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
  437. case DOC_TYPE_LINE:
  438. case DOC_TYPE_BREAK_PARENT:
  439. return cb(doc2);
  440. default:
  441. throw new invalid_doc_error_default(doc2);
  442. }
  443. }
  444. }
  445. function findInDoc(doc, fn, defaultValue) {
  446. let result = defaultValue;
  447. let shouldSkipFurtherProcessing = false;
  448. function findInDocOnEnterFn(doc2) {
  449. if (shouldSkipFurtherProcessing) {
  450. return false;
  451. }
  452. const maybeResult = fn(doc2);
  453. if (maybeResult !== void 0) {
  454. shouldSkipFurtherProcessing = true;
  455. result = maybeResult;
  456. }
  457. }
  458. traverse_doc_default(doc, findInDocOnEnterFn);
  459. return result;
  460. }
  461. function willBreakFn(doc) {
  462. if (doc.type === DOC_TYPE_GROUP && doc.break) {
  463. return true;
  464. }
  465. if (doc.type === DOC_TYPE_LINE && doc.hard) {
  466. return true;
  467. }
  468. if (doc.type === DOC_TYPE_BREAK_PARENT) {
  469. return true;
  470. }
  471. }
  472. function willBreak(doc) {
  473. return findInDoc(doc, willBreakFn, false);
  474. }
  475. function breakParentGroup(groupStack) {
  476. if (groupStack.length > 0) {
  477. const parentGroup = at_default(
  478. /* isOptionalObject*/
  479. false,
  480. groupStack,
  481. -1
  482. );
  483. if (!parentGroup.expandedStates && !parentGroup.break) {
  484. parentGroup.break = "propagated";
  485. }
  486. }
  487. return null;
  488. }
  489. function propagateBreaks(doc) {
  490. const alreadyVisitedSet = /* @__PURE__ */ new Set();
  491. const groupStack = [];
  492. function propagateBreaksOnEnterFn(doc2) {
  493. if (doc2.type === DOC_TYPE_BREAK_PARENT) {
  494. breakParentGroup(groupStack);
  495. }
  496. if (doc2.type === DOC_TYPE_GROUP) {
  497. groupStack.push(doc2);
  498. if (alreadyVisitedSet.has(doc2)) {
  499. return false;
  500. }
  501. alreadyVisitedSet.add(doc2);
  502. }
  503. }
  504. function propagateBreaksOnExitFn(doc2) {
  505. if (doc2.type === DOC_TYPE_GROUP) {
  506. const group2 = groupStack.pop();
  507. if (group2.break) {
  508. breakParentGroup(groupStack);
  509. }
  510. }
  511. }
  512. traverse_doc_default(
  513. doc,
  514. propagateBreaksOnEnterFn,
  515. propagateBreaksOnExitFn,
  516. /* shouldTraverseConditionalGroups */
  517. true
  518. );
  519. }
  520. function removeLinesFn(doc) {
  521. if (doc.type === DOC_TYPE_LINE && !doc.hard) {
  522. return doc.soft ? "" : " ";
  523. }
  524. if (doc.type === DOC_TYPE_IF_BREAK) {
  525. return doc.flatContents;
  526. }
  527. return doc;
  528. }
  529. function removeLines(doc) {
  530. return mapDoc(doc, removeLinesFn);
  531. }
  532. function stripTrailingHardlineFromParts(parts) {
  533. parts = [...parts];
  534. while (parts.length >= 2 && at_default(
  535. /* isOptionalObject*/
  536. false,
  537. parts,
  538. -2
  539. ).type === DOC_TYPE_LINE && at_default(
  540. /* isOptionalObject*/
  541. false,
  542. parts,
  543. -1
  544. ).type === DOC_TYPE_BREAK_PARENT) {
  545. parts.length -= 2;
  546. }
  547. if (parts.length > 0) {
  548. const lastPart = stripTrailingHardlineFromDoc(at_default(
  549. /* isOptionalObject*/
  550. false,
  551. parts,
  552. -1
  553. ));
  554. parts[parts.length - 1] = lastPart;
  555. }
  556. return parts;
  557. }
  558. function stripTrailingHardlineFromDoc(doc) {
  559. switch (get_doc_type_default(doc)) {
  560. case DOC_TYPE_ALIGN:
  561. case DOC_TYPE_INDENT:
  562. case DOC_TYPE_INDENT_IF_BREAK:
  563. case DOC_TYPE_GROUP:
  564. case DOC_TYPE_LINE_SUFFIX:
  565. case DOC_TYPE_LABEL: {
  566. const contents = stripTrailingHardlineFromDoc(doc.contents);
  567. return {
  568. ...doc,
  569. contents
  570. };
  571. }
  572. case DOC_TYPE_IF_BREAK:
  573. return {
  574. ...doc,
  575. breakContents: stripTrailingHardlineFromDoc(doc.breakContents),
  576. flatContents: stripTrailingHardlineFromDoc(doc.flatContents)
  577. };
  578. case DOC_TYPE_FILL:
  579. return {
  580. ...doc,
  581. parts: stripTrailingHardlineFromParts(doc.parts)
  582. };
  583. case DOC_TYPE_ARRAY:
  584. return stripTrailingHardlineFromParts(doc);
  585. case DOC_TYPE_STRING:
  586. return doc.replace(/[\n\r]*$/, "");
  587. case DOC_TYPE_CURSOR:
  588. case DOC_TYPE_TRIM:
  589. case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
  590. case DOC_TYPE_LINE:
  591. case DOC_TYPE_BREAK_PARENT:
  592. break;
  593. default:
  594. throw new invalid_doc_error_default(doc);
  595. }
  596. return doc;
  597. }
  598. function stripTrailingHardline(doc) {
  599. return stripTrailingHardlineFromDoc(cleanDoc(doc));
  600. }
  601. function cleanDocFn(doc) {
  602. switch (get_doc_type_default(doc)) {
  603. case DOC_TYPE_FILL:
  604. if (doc.parts.every((part) => part === "")) {
  605. return "";
  606. }
  607. break;
  608. case DOC_TYPE_GROUP:
  609. if (!doc.contents && !doc.id && !doc.break && !doc.expandedStates) {
  610. return "";
  611. }
  612. if (doc.contents.type === DOC_TYPE_GROUP && doc.contents.id === doc.id && doc.contents.break === doc.break && doc.contents.expandedStates === doc.expandedStates) {
  613. return doc.contents;
  614. }
  615. break;
  616. case DOC_TYPE_ALIGN:
  617. case DOC_TYPE_INDENT:
  618. case DOC_TYPE_INDENT_IF_BREAK:
  619. case DOC_TYPE_LINE_SUFFIX:
  620. if (!doc.contents) {
  621. return "";
  622. }
  623. break;
  624. case DOC_TYPE_IF_BREAK:
  625. if (!doc.flatContents && !doc.breakContents) {
  626. return "";
  627. }
  628. break;
  629. case DOC_TYPE_ARRAY: {
  630. const parts = [];
  631. for (const part of doc) {
  632. if (!part) {
  633. continue;
  634. }
  635. const [currentPart, ...restParts] = Array.isArray(part) ? part : [part];
  636. if (typeof currentPart === "string" && typeof at_default(
  637. /* isOptionalObject*/
  638. false,
  639. parts,
  640. -1
  641. ) === "string") {
  642. parts[parts.length - 1] += currentPart;
  643. } else {
  644. parts.push(currentPart);
  645. }
  646. parts.push(...restParts);
  647. }
  648. if (parts.length === 0) {
  649. return "";
  650. }
  651. if (parts.length === 1) {
  652. return parts[0];
  653. }
  654. return parts;
  655. }
  656. case DOC_TYPE_STRING:
  657. case DOC_TYPE_CURSOR:
  658. case DOC_TYPE_TRIM:
  659. case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
  660. case DOC_TYPE_LINE:
  661. case DOC_TYPE_LABEL:
  662. case DOC_TYPE_BREAK_PARENT:
  663. break;
  664. default:
  665. throw new invalid_doc_error_default(doc);
  666. }
  667. return doc;
  668. }
  669. function cleanDoc(doc) {
  670. return mapDoc(doc, (currentDoc) => cleanDocFn(currentDoc));
  671. }
  672. function replaceEndOfLine(doc, replacement = literalline) {
  673. return mapDoc(doc, (currentDoc) => typeof currentDoc === "string" ? join(replacement, currentDoc.split("\n")) : currentDoc);
  674. }
  675. function canBreakFn(doc) {
  676. if (doc.type === DOC_TYPE_LINE) {
  677. return true;
  678. }
  679. }
  680. function canBreak(doc) {
  681. return findInDoc(doc, canBreakFn, false);
  682. }
  683. // src/document/printer.js
  684. var MODE_BREAK = Symbol("MODE_BREAK");
  685. var MODE_FLAT = Symbol("MODE_FLAT");
  686. var CURSOR_PLACEHOLDER = Symbol("cursor");
  687. function rootIndent() {
  688. return {
  689. value: "",
  690. length: 0,
  691. queue: []
  692. };
  693. }
  694. function makeIndent(ind, options) {
  695. return generateInd(ind, {
  696. type: "indent"
  697. }, options);
  698. }
  699. function makeAlign(indent2, widthOrDoc, options) {
  700. if (widthOrDoc === Number.NEGATIVE_INFINITY) {
  701. return indent2.root || rootIndent();
  702. }
  703. if (widthOrDoc < 0) {
  704. return generateInd(indent2, {
  705. type: "dedent"
  706. }, options);
  707. }
  708. if (!widthOrDoc) {
  709. return indent2;
  710. }
  711. if (widthOrDoc.type === "root") {
  712. return {
  713. ...indent2,
  714. root: indent2
  715. };
  716. }
  717. const alignType = typeof widthOrDoc === "string" ? "stringAlign" : "numberAlign";
  718. return generateInd(indent2, {
  719. type: alignType,
  720. n: widthOrDoc
  721. }, options);
  722. }
  723. function generateInd(ind, newPart, options) {
  724. const queue = newPart.type === "dedent" ? ind.queue.slice(0, -1) : [...ind.queue, newPart];
  725. let value = "";
  726. let length = 0;
  727. let lastTabs = 0;
  728. let lastSpaces = 0;
  729. for (const part of queue) {
  730. switch (part.type) {
  731. case "indent":
  732. flush();
  733. if (options.useTabs) {
  734. addTabs(1);
  735. } else {
  736. addSpaces(options.tabWidth);
  737. }
  738. break;
  739. case "stringAlign":
  740. flush();
  741. value += part.n;
  742. length += part.n.length;
  743. break;
  744. case "numberAlign":
  745. lastTabs += 1;
  746. lastSpaces += part.n;
  747. break;
  748. default:
  749. throw new Error(`Unexpected type '${part.type}'`);
  750. }
  751. }
  752. flushSpaces();
  753. return {
  754. ...ind,
  755. value,
  756. length,
  757. queue
  758. };
  759. function addTabs(count) {
  760. value += " ".repeat(count);
  761. length += options.tabWidth * count;
  762. }
  763. function addSpaces(count) {
  764. value += " ".repeat(count);
  765. length += count;
  766. }
  767. function flush() {
  768. if (options.useTabs) {
  769. flushTabs();
  770. } else {
  771. flushSpaces();
  772. }
  773. }
  774. function flushTabs() {
  775. if (lastTabs > 0) {
  776. addTabs(lastTabs);
  777. }
  778. resetLast();
  779. }
  780. function flushSpaces() {
  781. if (lastSpaces > 0) {
  782. addSpaces(lastSpaces);
  783. }
  784. resetLast();
  785. }
  786. function resetLast() {
  787. lastTabs = 0;
  788. lastSpaces = 0;
  789. }
  790. }
  791. function trim2(out) {
  792. let trimCount = 0;
  793. let cursorCount = 0;
  794. let outIndex = out.length;
  795. outer:
  796. while (outIndex--) {
  797. const last = out[outIndex];
  798. if (last === CURSOR_PLACEHOLDER) {
  799. cursorCount++;
  800. continue;
  801. }
  802. if (false) {
  803. throw new Error(`Unexpected value in trim: '${typeof last}'`);
  804. }
  805. for (let charIndex = last.length - 1; charIndex >= 0; charIndex--) {
  806. const char = last[charIndex];
  807. if (char === " " || char === " ") {
  808. trimCount++;
  809. } else {
  810. out[outIndex] = last.slice(0, charIndex + 1);
  811. break outer;
  812. }
  813. }
  814. }
  815. if (trimCount > 0 || cursorCount > 0) {
  816. out.length = outIndex + 1;
  817. while (cursorCount-- > 0) {
  818. out.push(CURSOR_PLACEHOLDER);
  819. }
  820. }
  821. return trimCount;
  822. }
  823. function fits(next, restCommands, width, hasLineSuffix, groupModeMap, mustBeFlat) {
  824. if (width === Number.POSITIVE_INFINITY) {
  825. return true;
  826. }
  827. let restIdx = restCommands.length;
  828. const cmds = [next];
  829. const out = [];
  830. while (width >= 0) {
  831. if (cmds.length === 0) {
  832. if (restIdx === 0) {
  833. return true;
  834. }
  835. cmds.push(restCommands[--restIdx]);
  836. continue;
  837. }
  838. const {
  839. mode,
  840. doc
  841. } = cmds.pop();
  842. switch (get_doc_type_default(doc)) {
  843. case DOC_TYPE_STRING:
  844. out.push(doc);
  845. width -= get_string_width_default(doc);
  846. break;
  847. case DOC_TYPE_ARRAY:
  848. case DOC_TYPE_FILL: {
  849. const parts = getDocParts(doc);
  850. for (let i = parts.length - 1; i >= 0; i--) {
  851. cmds.push({
  852. mode,
  853. doc: parts[i]
  854. });
  855. }
  856. break;
  857. }
  858. case DOC_TYPE_INDENT:
  859. case DOC_TYPE_ALIGN:
  860. case DOC_TYPE_INDENT_IF_BREAK:
  861. case DOC_TYPE_LABEL:
  862. cmds.push({
  863. mode,
  864. doc: doc.contents
  865. });
  866. break;
  867. case DOC_TYPE_TRIM:
  868. width += trim2(out);
  869. break;
  870. case DOC_TYPE_GROUP: {
  871. if (mustBeFlat && doc.break) {
  872. return false;
  873. }
  874. const groupMode = doc.break ? MODE_BREAK : mode;
  875. const contents = doc.expandedStates && groupMode === MODE_BREAK ? at_default(
  876. /* isOptionalObject*/
  877. false,
  878. doc.expandedStates,
  879. -1
  880. ) : doc.contents;
  881. cmds.push({
  882. mode: groupMode,
  883. doc: contents
  884. });
  885. break;
  886. }
  887. case DOC_TYPE_IF_BREAK: {
  888. const groupMode = doc.groupId ? groupModeMap[doc.groupId] || MODE_FLAT : mode;
  889. const contents = groupMode === MODE_BREAK ? doc.breakContents : doc.flatContents;
  890. if (contents) {
  891. cmds.push({
  892. mode,
  893. doc: contents
  894. });
  895. }
  896. break;
  897. }
  898. case DOC_TYPE_LINE:
  899. if (mode === MODE_BREAK || doc.hard) {
  900. return true;
  901. }
  902. if (!doc.soft) {
  903. out.push(" ");
  904. width--;
  905. }
  906. break;
  907. case DOC_TYPE_LINE_SUFFIX:
  908. hasLineSuffix = true;
  909. break;
  910. case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
  911. if (hasLineSuffix) {
  912. return false;
  913. }
  914. break;
  915. }
  916. }
  917. return false;
  918. }
  919. function printDocToString(doc, options) {
  920. const groupModeMap = {};
  921. const width = options.printWidth;
  922. const newLine = convertEndOfLineToChars(options.endOfLine);
  923. let pos = 0;
  924. const cmds = [{
  925. ind: rootIndent(),
  926. mode: MODE_BREAK,
  927. doc
  928. }];
  929. const out = [];
  930. let shouldRemeasure = false;
  931. const lineSuffix2 = [];
  932. let printedCursorCount = 0;
  933. propagateBreaks(doc);
  934. while (cmds.length > 0) {
  935. const {
  936. ind,
  937. mode,
  938. doc: doc2
  939. } = cmds.pop();
  940. switch (get_doc_type_default(doc2)) {
  941. case DOC_TYPE_STRING: {
  942. const formatted = newLine !== "\n" ? string_replace_all_default(
  943. /* isOptionalObject*/
  944. false,
  945. doc2,
  946. "\n",
  947. newLine
  948. ) : doc2;
  949. out.push(formatted);
  950. if (cmds.length > 0) {
  951. pos += get_string_width_default(formatted);
  952. }
  953. break;
  954. }
  955. case DOC_TYPE_ARRAY:
  956. for (let i = doc2.length - 1; i >= 0; i--) {
  957. cmds.push({
  958. ind,
  959. mode,
  960. doc: doc2[i]
  961. });
  962. }
  963. break;
  964. case DOC_TYPE_CURSOR:
  965. if (printedCursorCount >= 2) {
  966. throw new Error("There are too many 'cursor' in doc.");
  967. }
  968. out.push(CURSOR_PLACEHOLDER);
  969. printedCursorCount++;
  970. break;
  971. case DOC_TYPE_INDENT:
  972. cmds.push({
  973. ind: makeIndent(ind, options),
  974. mode,
  975. doc: doc2.contents
  976. });
  977. break;
  978. case DOC_TYPE_ALIGN:
  979. cmds.push({
  980. ind: makeAlign(ind, doc2.n, options),
  981. mode,
  982. doc: doc2.contents
  983. });
  984. break;
  985. case DOC_TYPE_TRIM:
  986. pos -= trim2(out);
  987. break;
  988. case DOC_TYPE_GROUP:
  989. switch (mode) {
  990. case MODE_FLAT:
  991. if (!shouldRemeasure) {
  992. cmds.push({
  993. ind,
  994. mode: doc2.break ? MODE_BREAK : MODE_FLAT,
  995. doc: doc2.contents
  996. });
  997. break;
  998. }
  999. case MODE_BREAK: {
  1000. shouldRemeasure = false;
  1001. const next = {
  1002. ind,
  1003. mode: MODE_FLAT,
  1004. doc: doc2.contents
  1005. };
  1006. const rem = width - pos;
  1007. const hasLineSuffix = lineSuffix2.length > 0;
  1008. if (!doc2.break && fits(next, cmds, rem, hasLineSuffix, groupModeMap)) {
  1009. cmds.push(next);
  1010. } else {
  1011. if (doc2.expandedStates) {
  1012. const mostExpanded = at_default(
  1013. /* isOptionalObject*/
  1014. false,
  1015. doc2.expandedStates,
  1016. -1
  1017. );
  1018. if (doc2.break) {
  1019. cmds.push({
  1020. ind,
  1021. mode: MODE_BREAK,
  1022. doc: mostExpanded
  1023. });
  1024. break;
  1025. } else {
  1026. for (let i = 1; i < doc2.expandedStates.length + 1; i++) {
  1027. if (i >= doc2.expandedStates.length) {
  1028. cmds.push({
  1029. ind,
  1030. mode: MODE_BREAK,
  1031. doc: mostExpanded
  1032. });
  1033. break;
  1034. } else {
  1035. const state = doc2.expandedStates[i];
  1036. const cmd = {
  1037. ind,
  1038. mode: MODE_FLAT,
  1039. doc: state
  1040. };
  1041. if (fits(cmd, cmds, rem, hasLineSuffix, groupModeMap)) {
  1042. cmds.push(cmd);
  1043. break;
  1044. }
  1045. }
  1046. }
  1047. }
  1048. } else {
  1049. cmds.push({
  1050. ind,
  1051. mode: MODE_BREAK,
  1052. doc: doc2.contents
  1053. });
  1054. }
  1055. }
  1056. break;
  1057. }
  1058. }
  1059. if (doc2.id) {
  1060. groupModeMap[doc2.id] = at_default(
  1061. /* isOptionalObject*/
  1062. false,
  1063. cmds,
  1064. -1
  1065. ).mode;
  1066. }
  1067. break;
  1068. case DOC_TYPE_FILL: {
  1069. const rem = width - pos;
  1070. const {
  1071. parts
  1072. } = doc2;
  1073. if (parts.length === 0) {
  1074. break;
  1075. }
  1076. const [content, whitespace] = parts;
  1077. const contentFlatCmd = {
  1078. ind,
  1079. mode: MODE_FLAT,
  1080. doc: content
  1081. };
  1082. const contentBreakCmd = {
  1083. ind,
  1084. mode: MODE_BREAK,
  1085. doc: content
  1086. };
  1087. const contentFits = fits(contentFlatCmd, [], rem, lineSuffix2.length > 0, groupModeMap, true);
  1088. if (parts.length === 1) {
  1089. if (contentFits) {
  1090. cmds.push(contentFlatCmd);
  1091. } else {
  1092. cmds.push(contentBreakCmd);
  1093. }
  1094. break;
  1095. }
  1096. const whitespaceFlatCmd = {
  1097. ind,
  1098. mode: MODE_FLAT,
  1099. doc: whitespace
  1100. };
  1101. const whitespaceBreakCmd = {
  1102. ind,
  1103. mode: MODE_BREAK,
  1104. doc: whitespace
  1105. };
  1106. if (parts.length === 2) {
  1107. if (contentFits) {
  1108. cmds.push(whitespaceFlatCmd, contentFlatCmd);
  1109. } else {
  1110. cmds.push(whitespaceBreakCmd, contentBreakCmd);
  1111. }
  1112. break;
  1113. }
  1114. parts.splice(0, 2);
  1115. const remainingCmd = {
  1116. ind,
  1117. mode,
  1118. doc: fill(parts)
  1119. };
  1120. const secondContent = parts[0];
  1121. const firstAndSecondContentFlatCmd = {
  1122. ind,
  1123. mode: MODE_FLAT,
  1124. doc: [content, whitespace, secondContent]
  1125. };
  1126. const firstAndSecondContentFits = fits(firstAndSecondContentFlatCmd, [], rem, lineSuffix2.length > 0, groupModeMap, true);
  1127. if (firstAndSecondContentFits) {
  1128. cmds.push(remainingCmd, whitespaceFlatCmd, contentFlatCmd);
  1129. } else if (contentFits) {
  1130. cmds.push(remainingCmd, whitespaceBreakCmd, contentFlatCmd);
  1131. } else {
  1132. cmds.push(remainingCmd, whitespaceBreakCmd, contentBreakCmd);
  1133. }
  1134. break;
  1135. }
  1136. case DOC_TYPE_IF_BREAK:
  1137. case DOC_TYPE_INDENT_IF_BREAK: {
  1138. const groupMode = doc2.groupId ? groupModeMap[doc2.groupId] : mode;
  1139. if (groupMode === MODE_BREAK) {
  1140. const breakContents = doc2.type === DOC_TYPE_IF_BREAK ? doc2.breakContents : doc2.negate ? doc2.contents : indent(doc2.contents);
  1141. if (breakContents) {
  1142. cmds.push({
  1143. ind,
  1144. mode,
  1145. doc: breakContents
  1146. });
  1147. }
  1148. }
  1149. if (groupMode === MODE_FLAT) {
  1150. const flatContents = doc2.type === DOC_TYPE_IF_BREAK ? doc2.flatContents : doc2.negate ? indent(doc2.contents) : doc2.contents;
  1151. if (flatContents) {
  1152. cmds.push({
  1153. ind,
  1154. mode,
  1155. doc: flatContents
  1156. });
  1157. }
  1158. }
  1159. break;
  1160. }
  1161. case DOC_TYPE_LINE_SUFFIX:
  1162. lineSuffix2.push({
  1163. ind,
  1164. mode,
  1165. doc: doc2.contents
  1166. });
  1167. break;
  1168. case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
  1169. if (lineSuffix2.length > 0) {
  1170. cmds.push({
  1171. ind,
  1172. mode,
  1173. doc: hardlineWithoutBreakParent
  1174. });
  1175. }
  1176. break;
  1177. case DOC_TYPE_LINE:
  1178. switch (mode) {
  1179. case MODE_FLAT:
  1180. if (!doc2.hard) {
  1181. if (!doc2.soft) {
  1182. out.push(" ");
  1183. pos += 1;
  1184. }
  1185. break;
  1186. } else {
  1187. shouldRemeasure = true;
  1188. }
  1189. case MODE_BREAK:
  1190. if (lineSuffix2.length > 0) {
  1191. cmds.push({
  1192. ind,
  1193. mode,
  1194. doc: doc2
  1195. }, ...lineSuffix2.reverse());
  1196. lineSuffix2.length = 0;
  1197. break;
  1198. }
  1199. if (doc2.literal) {
  1200. if (ind.root) {
  1201. out.push(newLine, ind.root.value);
  1202. pos = ind.root.length;
  1203. } else {
  1204. out.push(newLine);
  1205. pos = 0;
  1206. }
  1207. } else {
  1208. pos -= trim2(out);
  1209. out.push(newLine + ind.value);
  1210. pos = ind.length;
  1211. }
  1212. break;
  1213. }
  1214. break;
  1215. case DOC_TYPE_LABEL:
  1216. cmds.push({
  1217. ind,
  1218. mode,
  1219. doc: doc2.contents
  1220. });
  1221. break;
  1222. case DOC_TYPE_BREAK_PARENT:
  1223. break;
  1224. default:
  1225. throw new invalid_doc_error_default(doc2);
  1226. }
  1227. if (cmds.length === 0 && lineSuffix2.length > 0) {
  1228. cmds.push(...lineSuffix2.reverse());
  1229. lineSuffix2.length = 0;
  1230. }
  1231. }
  1232. const cursorPlaceholderIndex = out.indexOf(CURSOR_PLACEHOLDER);
  1233. if (cursorPlaceholderIndex !== -1) {
  1234. const otherCursorPlaceholderIndex = out.indexOf(CURSOR_PLACEHOLDER, cursorPlaceholderIndex + 1);
  1235. const beforeCursor = out.slice(0, cursorPlaceholderIndex).join("");
  1236. const aroundCursor = out.slice(cursorPlaceholderIndex + 1, otherCursorPlaceholderIndex).join("");
  1237. const afterCursor = out.slice(otherCursorPlaceholderIndex + 1).join("");
  1238. return {
  1239. formatted: beforeCursor + aroundCursor + afterCursor,
  1240. cursorNodeStart: beforeCursor.length,
  1241. cursorNodeText: aroundCursor
  1242. };
  1243. }
  1244. return {
  1245. formatted: out.join("")
  1246. };
  1247. }
  1248. // src/document/public.js
  1249. var builders = {
  1250. join,
  1251. line,
  1252. softline,
  1253. hardline,
  1254. literalline,
  1255. group,
  1256. conditionalGroup,
  1257. fill,
  1258. lineSuffix,
  1259. lineSuffixBoundary,
  1260. cursor,
  1261. breakParent,
  1262. ifBreak,
  1263. trim,
  1264. indent,
  1265. indentIfBreak,
  1266. align,
  1267. addAlignmentToDoc,
  1268. markAsRoot,
  1269. dedentToRoot,
  1270. dedent,
  1271. hardlineWithoutBreakParent,
  1272. literallineWithoutBreakParent,
  1273. label,
  1274. // TODO: Remove this in v4
  1275. concat: (parts) => parts
  1276. };
  1277. var printer = { printDocToString };
  1278. var utils = {
  1279. willBreak,
  1280. traverseDoc: traverse_doc_default,
  1281. findInDoc,
  1282. mapDoc,
  1283. removeLines,
  1284. stripTrailingHardline,
  1285. replaceEndOfLine,
  1286. canBreak
  1287. };
  1288. // with-default-export:src/document/public.js
  1289. var public_default = public_exports;
  1290. export {
  1291. builders,
  1292. public_default as default,
  1293. printer,
  1294. utils
  1295. };