Greasy Fork is available in English.

Refined GitHub File Nesting

Bring file nesting feature to GitHub

  1. // ==UserScript==
  2. // @name Refined GitHub File Nesting
  3. // @namespace yuyinws/refined-github-file-nesting
  4. // @version 0.0.7
  5. // @author Leo <https://github.com/yuyinws>
  6. // @description Bring file nesting feature to GitHub
  7. // @license MIT
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
  9. // @homepage https://github.com/yuyinws/refined-github-file-nesting#readme
  10. // @homepageURL https://github.com/yuyinws/refined-github-file-nesting#readme
  11. // @match https://github.com/**
  12. // @grant GM_addStyle
  13. // ==/UserScript==
  14.  
  15. (e=>{if(typeof GM_addStyle=="function"){GM_addStyle(e);return}const t=document.createElement("style");t.textContent=e,document.head.append(t)})(` [data-rgfn-toggle="0"]:before{content:"";width:1em;height:1em;color:var(--fgColor-muted, #808080);--rgdn-icon: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="0.5em" height="1em" viewBox="0 0 8 16"%3E%3Cpath fill-rule="evenodd" d="M7.5 8l-5 5L1 11.5L4.75 8L1 4.5L2.5 3l5 5z" fill="currentColor"/%3E%3C/svg%3E ');mask:var(--rgdn-icon) no-repeat center / contain;-webkit-mask:var(--rgdn-icon) no-repeat center / contain;background-color:currentColor;mask-size:100% 100%;-webkit-mask-size:100% 100%}[data-rgfn-toggle="1"]:before{content:"";width:1em;height:1em;color:var(--fgColor-muted, #808080);--rgdn-icon: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="0.63em" height="1em" viewBox="0 0 10 16"%3E%3Cpath fill-rule="evenodd" d="M5 11L0 6l1.5-1.5L5 8.25L8.5 4.5L10 6l-5 5z" fill="currentColor"/%3E%3C/svg%3E');mask:var(--rgdn-icon) no-repeat center / contain;-webkit-mask:var(--rgdn-icon) no-repeat center / contain;background-color:currentColor;mask-size:100% 100%;-webkit-mask-size:100% 100%}.rgfn-file-counts{color:var(--fgColor-muted, #808080)!important;font-size:12px;margin-left:4px;display:inline}[data-rgfn-toggle="1"] .rgfn-file-counts{display:none} `);
  16.  
  17. (function () {
  18. 'use strict';
  19.  
  20. function getDefaultExportFromCjs(x) {
  21. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
  22. }
  23. var utils$4 = {};
  24. const WIN_SLASH = "\\\\/";
  25. const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
  26. const DOT_LITERAL = "\\.";
  27. const PLUS_LITERAL = "\\+";
  28. const QMARK_LITERAL = "\\?";
  29. const SLASH_LITERAL = "\\/";
  30. const ONE_CHAR = "(?=.)";
  31. const QMARK = "[^/]";
  32. const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
  33. const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
  34. const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
  35. const NO_DOT = `(?!${DOT_LITERAL})`;
  36. const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
  37. const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
  38. const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
  39. const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
  40. const STAR = `${QMARK}*?`;
  41. const SEP = "/";
  42. const POSIX_CHARS = {
  43. DOT_LITERAL,
  44. PLUS_LITERAL,
  45. QMARK_LITERAL,
  46. SLASH_LITERAL,
  47. ONE_CHAR,
  48. QMARK,
  49. END_ANCHOR,
  50. DOTS_SLASH,
  51. NO_DOT,
  52. NO_DOTS,
  53. NO_DOT_SLASH,
  54. NO_DOTS_SLASH,
  55. QMARK_NO_DOT,
  56. STAR,
  57. START_ANCHOR,
  58. SEP
  59. };
  60. const WINDOWS_CHARS = {
  61. ...POSIX_CHARS,
  62. SLASH_LITERAL: `[${WIN_SLASH}]`,
  63. QMARK: WIN_NO_SLASH,
  64. STAR: `${WIN_NO_SLASH}*?`,
  65. DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
  66. NO_DOT: `(?!${DOT_LITERAL})`,
  67. NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
  68. NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
  69. NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
  70. QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
  71. START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
  72. END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
  73. SEP: "\\"
  74. };
  75. const POSIX_REGEX_SOURCE$1 = {
  76. alnum: "a-zA-Z0-9",
  77. alpha: "a-zA-Z",
  78. ascii: "\\x00-\\x7F",
  79. blank: " \\t",
  80. cntrl: "\\x00-\\x1F\\x7F",
  81. digit: "0-9",
  82. graph: "\\x21-\\x7E",
  83. lower: "a-z",
  84. print: "\\x20-\\x7E ",
  85. punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
  86. space: " \\t\\r\\n\\v\\f",
  87. upper: "A-Z",
  88. word: "A-Za-z0-9_",
  89. xdigit: "A-Fa-f0-9"
  90. };
  91. var constants$2 = {
  92. MAX_LENGTH: 1024 * 64,
  93. POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
  94. // regular expressions
  95. REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
  96. REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
  97. REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
  98. REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
  99. REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
  100. REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
  101. // Replace globs with equivalent patterns to reduce parsing time.
  102. REPLACEMENTS: {
  103. "***": "*",
  104. "**/**": "**",
  105. "**/**/**": "**"
  106. },
  107. // Digits
  108. CHAR_0: 48,
  109. /* 0 */
  110. CHAR_9: 57,
  111. /* 9 */
  112. // Alphabet chars.
  113. CHAR_UPPERCASE_A: 65,
  114. /* A */
  115. CHAR_LOWERCASE_A: 97,
  116. /* a */
  117. CHAR_UPPERCASE_Z: 90,
  118. /* Z */
  119. CHAR_LOWERCASE_Z: 122,
  120. /* z */
  121. CHAR_LEFT_PARENTHESES: 40,
  122. /* ( */
  123. CHAR_RIGHT_PARENTHESES: 41,
  124. /* ) */
  125. CHAR_ASTERISK: 42,
  126. /* * */
  127. // Non-alphabetic chars.
  128. CHAR_AMPERSAND: 38,
  129. /* & */
  130. CHAR_AT: 64,
  131. /* @ */
  132. CHAR_BACKWARD_SLASH: 92,
  133. /* \ */
  134. CHAR_CARRIAGE_RETURN: 13,
  135. /* \r */
  136. CHAR_CIRCUMFLEX_ACCENT: 94,
  137. /* ^ */
  138. CHAR_COLON: 58,
  139. /* : */
  140. CHAR_COMMA: 44,
  141. /* , */
  142. CHAR_DOT: 46,
  143. /* . */
  144. CHAR_DOUBLE_QUOTE: 34,
  145. /* " */
  146. CHAR_EQUAL: 61,
  147. /* = */
  148. CHAR_EXCLAMATION_MARK: 33,
  149. /* ! */
  150. CHAR_FORM_FEED: 12,
  151. /* \f */
  152. CHAR_FORWARD_SLASH: 47,
  153. /* / */
  154. CHAR_GRAVE_ACCENT: 96,
  155. /* ` */
  156. CHAR_HASH: 35,
  157. /* # */
  158. CHAR_HYPHEN_MINUS: 45,
  159. /* - */
  160. CHAR_LEFT_ANGLE_BRACKET: 60,
  161. /* < */
  162. CHAR_LEFT_CURLY_BRACE: 123,
  163. /* { */
  164. CHAR_LEFT_SQUARE_BRACKET: 91,
  165. /* [ */
  166. CHAR_LINE_FEED: 10,
  167. /* \n */
  168. CHAR_NO_BREAK_SPACE: 160,
  169. /* \u00A0 */
  170. CHAR_PERCENT: 37,
  171. /* % */
  172. CHAR_PLUS: 43,
  173. /* + */
  174. CHAR_QUESTION_MARK: 63,
  175. /* ? */
  176. CHAR_RIGHT_ANGLE_BRACKET: 62,
  177. /* > */
  178. CHAR_RIGHT_CURLY_BRACE: 125,
  179. /* } */
  180. CHAR_RIGHT_SQUARE_BRACKET: 93,
  181. /* ] */
  182. CHAR_SEMICOLON: 59,
  183. /* ; */
  184. CHAR_SINGLE_QUOTE: 39,
  185. /* ' */
  186. CHAR_SPACE: 32,
  187. /* */
  188. CHAR_TAB: 9,
  189. /* \t */
  190. CHAR_UNDERSCORE: 95,
  191. /* _ */
  192. CHAR_VERTICAL_LINE: 124,
  193. /* | */
  194. CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
  195. /* \uFEFF */
  196. /**
  197. * Create EXTGLOB_CHARS
  198. */
  199. extglobChars(chars) {
  200. return {
  201. "!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
  202. "?": { type: "qmark", open: "(?:", close: ")?" },
  203. "+": { type: "plus", open: "(?:", close: ")+" },
  204. "*": { type: "star", open: "(?:", close: ")*" },
  205. "@": { type: "at", open: "(?:", close: ")" }
  206. };
  207. },
  208. /**
  209. * Create GLOB_CHARS
  210. */
  211. globChars(win32) {
  212. return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
  213. }
  214. };
  215. (function(exports) {
  216. const {
  217. REGEX_BACKSLASH,
  218. REGEX_REMOVE_BACKSLASH,
  219. REGEX_SPECIAL_CHARS,
  220. REGEX_SPECIAL_CHARS_GLOBAL
  221. } = constants$2;
  222. exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
  223. exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
  224. exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
  225. exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
  226. exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
  227. exports.isWindows = () => {
  228. if (typeof navigator !== "undefined" && navigator.platform) {
  229. const platform = navigator.platform.toLowerCase();
  230. return platform === "win32" || platform === "windows";
  231. }
  232. if (typeof process !== "undefined" && process.platform) {
  233. return process.platform === "win32";
  234. }
  235. return false;
  236. };
  237. exports.removeBackslashes = (str) => {
  238. return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
  239. return match === "\\" ? "" : match;
  240. });
  241. };
  242. exports.escapeLast = (input, char, lastIdx) => {
  243. const idx = input.lastIndexOf(char, lastIdx);
  244. if (idx === -1) return input;
  245. if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
  246. return `${input.slice(0, idx)}\\${input.slice(idx)}`;
  247. };
  248. exports.removePrefix = (input, state = {}) => {
  249. let output = input;
  250. if (output.startsWith("./")) {
  251. output = output.slice(2);
  252. state.prefix = "./";
  253. }
  254. return output;
  255. };
  256. exports.wrapOutput = (input, state = {}, options = {}) => {
  257. const prepend = options.contains ? "" : "^";
  258. const append = options.contains ? "" : "$";
  259. let output = `${prepend}(?:${input})${append}`;
  260. if (state.negated === true) {
  261. output = `(?:^(?!${output}).*$)`;
  262. }
  263. return output;
  264. };
  265. exports.basename = (path, { windows } = {}) => {
  266. const segs = path.split(windows ? /[\\/]/ : "/");
  267. const last = segs[segs.length - 1];
  268. if (last === "") {
  269. return segs[segs.length - 2];
  270. }
  271. return last;
  272. };
  273. })(utils$4);
  274. const utils$3 = utils$4;
  275. const {
  276. CHAR_ASTERISK,
  277. /* * */
  278. CHAR_AT,
  279. /* @ */
  280. CHAR_BACKWARD_SLASH,
  281. /* \ */
  282. CHAR_COMMA,
  283. /* , */
  284. CHAR_DOT,
  285. /* . */
  286. CHAR_EXCLAMATION_MARK,
  287. /* ! */
  288. CHAR_FORWARD_SLASH,
  289. /* / */
  290. CHAR_LEFT_CURLY_BRACE,
  291. /* { */
  292. CHAR_LEFT_PARENTHESES,
  293. /* ( */
  294. CHAR_LEFT_SQUARE_BRACKET,
  295. /* [ */
  296. CHAR_PLUS,
  297. /* + */
  298. CHAR_QUESTION_MARK,
  299. /* ? */
  300. CHAR_RIGHT_CURLY_BRACE,
  301. /* } */
  302. CHAR_RIGHT_PARENTHESES,
  303. /* ) */
  304. CHAR_RIGHT_SQUARE_BRACKET
  305. /* ] */
  306. } = constants$2;
  307. const isPathSeparator = (code) => {
  308. return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
  309. };
  310. const depth = (token) => {
  311. if (token.isPrefix !== true) {
  312. token.depth = token.isGlobstar ? Infinity : 1;
  313. }
  314. };
  315. const scan$1 = (input, options) => {
  316. const opts = options || {};
  317. const length = input.length - 1;
  318. const scanToEnd = opts.parts === true || opts.scanToEnd === true;
  319. const slashes = [];
  320. const tokens = [];
  321. const parts = [];
  322. let str = input;
  323. let index = -1;
  324. let start = 0;
  325. let lastIndex = 0;
  326. let isBrace = false;
  327. let isBracket = false;
  328. let isGlob = false;
  329. let isExtglob = false;
  330. let isGlobstar = false;
  331. let braceEscaped = false;
  332. let backslashes = false;
  333. let negated = false;
  334. let negatedExtglob = false;
  335. let finished = false;
  336. let braces = 0;
  337. let prev;
  338. let code;
  339. let token = { value: "", depth: 0, isGlob: false };
  340. const eos = () => index >= length;
  341. const peek = () => str.charCodeAt(index + 1);
  342. const advance = () => {
  343. prev = code;
  344. return str.charCodeAt(++index);
  345. };
  346. while (index < length) {
  347. code = advance();
  348. let next;
  349. if (code === CHAR_BACKWARD_SLASH) {
  350. backslashes = token.backslashes = true;
  351. code = advance();
  352. if (code === CHAR_LEFT_CURLY_BRACE) {
  353. braceEscaped = true;
  354. }
  355. continue;
  356. }
  357. if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
  358. braces++;
  359. while (eos() !== true && (code = advance())) {
  360. if (code === CHAR_BACKWARD_SLASH) {
  361. backslashes = token.backslashes = true;
  362. advance();
  363. continue;
  364. }
  365. if (code === CHAR_LEFT_CURLY_BRACE) {
  366. braces++;
  367. continue;
  368. }
  369. if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
  370. isBrace = token.isBrace = true;
  371. isGlob = token.isGlob = true;
  372. finished = true;
  373. if (scanToEnd === true) {
  374. continue;
  375. }
  376. break;
  377. }
  378. if (braceEscaped !== true && code === CHAR_COMMA) {
  379. isBrace = token.isBrace = true;
  380. isGlob = token.isGlob = true;
  381. finished = true;
  382. if (scanToEnd === true) {
  383. continue;
  384. }
  385. break;
  386. }
  387. if (code === CHAR_RIGHT_CURLY_BRACE) {
  388. braces--;
  389. if (braces === 0) {
  390. braceEscaped = false;
  391. isBrace = token.isBrace = true;
  392. finished = true;
  393. break;
  394. }
  395. }
  396. }
  397. if (scanToEnd === true) {
  398. continue;
  399. }
  400. break;
  401. }
  402. if (code === CHAR_FORWARD_SLASH) {
  403. slashes.push(index);
  404. tokens.push(token);
  405. token = { value: "", depth: 0, isGlob: false };
  406. if (finished === true) continue;
  407. if (prev === CHAR_DOT && index === start + 1) {
  408. start += 2;
  409. continue;
  410. }
  411. lastIndex = index + 1;
  412. continue;
  413. }
  414. if (opts.noext !== true) {
  415. const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
  416. if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
  417. isGlob = token.isGlob = true;
  418. isExtglob = token.isExtglob = true;
  419. finished = true;
  420. if (code === CHAR_EXCLAMATION_MARK && index === start) {
  421. negatedExtglob = true;
  422. }
  423. if (scanToEnd === true) {
  424. while (eos() !== true && (code = advance())) {
  425. if (code === CHAR_BACKWARD_SLASH) {
  426. backslashes = token.backslashes = true;
  427. code = advance();
  428. continue;
  429. }
  430. if (code === CHAR_RIGHT_PARENTHESES) {
  431. isGlob = token.isGlob = true;
  432. finished = true;
  433. break;
  434. }
  435. }
  436. continue;
  437. }
  438. break;
  439. }
  440. }
  441. if (code === CHAR_ASTERISK) {
  442. if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
  443. isGlob = token.isGlob = true;
  444. finished = true;
  445. if (scanToEnd === true) {
  446. continue;
  447. }
  448. break;
  449. }
  450. if (code === CHAR_QUESTION_MARK) {
  451. isGlob = token.isGlob = true;
  452. finished = true;
  453. if (scanToEnd === true) {
  454. continue;
  455. }
  456. break;
  457. }
  458. if (code === CHAR_LEFT_SQUARE_BRACKET) {
  459. while (eos() !== true && (next = advance())) {
  460. if (next === CHAR_BACKWARD_SLASH) {
  461. backslashes = token.backslashes = true;
  462. advance();
  463. continue;
  464. }
  465. if (next === CHAR_RIGHT_SQUARE_BRACKET) {
  466. isBracket = token.isBracket = true;
  467. isGlob = token.isGlob = true;
  468. finished = true;
  469. break;
  470. }
  471. }
  472. if (scanToEnd === true) {
  473. continue;
  474. }
  475. break;
  476. }
  477. if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
  478. negated = token.negated = true;
  479. start++;
  480. continue;
  481. }
  482. if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
  483. isGlob = token.isGlob = true;
  484. if (scanToEnd === true) {
  485. while (eos() !== true && (code = advance())) {
  486. if (code === CHAR_LEFT_PARENTHESES) {
  487. backslashes = token.backslashes = true;
  488. code = advance();
  489. continue;
  490. }
  491. if (code === CHAR_RIGHT_PARENTHESES) {
  492. finished = true;
  493. break;
  494. }
  495. }
  496. continue;
  497. }
  498. break;
  499. }
  500. if (isGlob === true) {
  501. finished = true;
  502. if (scanToEnd === true) {
  503. continue;
  504. }
  505. break;
  506. }
  507. }
  508. if (opts.noext === true) {
  509. isExtglob = false;
  510. isGlob = false;
  511. }
  512. let base = str;
  513. let prefix = "";
  514. let glob = "";
  515. if (start > 0) {
  516. prefix = str.slice(0, start);
  517. str = str.slice(start);
  518. lastIndex -= start;
  519. }
  520. if (base && isGlob === true && lastIndex > 0) {
  521. base = str.slice(0, lastIndex);
  522. glob = str.slice(lastIndex);
  523. } else if (isGlob === true) {
  524. base = "";
  525. glob = str;
  526. } else {
  527. base = str;
  528. }
  529. if (base && base !== "" && base !== "/" && base !== str) {
  530. if (isPathSeparator(base.charCodeAt(base.length - 1))) {
  531. base = base.slice(0, -1);
  532. }
  533. }
  534. if (opts.unescape === true) {
  535. if (glob) glob = utils$3.removeBackslashes(glob);
  536. if (base && backslashes === true) {
  537. base = utils$3.removeBackslashes(base);
  538. }
  539. }
  540. const state = {
  541. prefix,
  542. input,
  543. start,
  544. base,
  545. glob,
  546. isBrace,
  547. isBracket,
  548. isGlob,
  549. isExtglob,
  550. isGlobstar,
  551. negated,
  552. negatedExtglob
  553. };
  554. if (opts.tokens === true) {
  555. state.maxDepth = 0;
  556. if (!isPathSeparator(code)) {
  557. tokens.push(token);
  558. }
  559. state.tokens = tokens;
  560. }
  561. if (opts.parts === true || opts.tokens === true) {
  562. let prevIndex;
  563. for (let idx = 0; idx < slashes.length; idx++) {
  564. const n = prevIndex ? prevIndex + 1 : start;
  565. const i = slashes[idx];
  566. const value = input.slice(n, i);
  567. if (opts.tokens) {
  568. if (idx === 0 && start !== 0) {
  569. tokens[idx].isPrefix = true;
  570. tokens[idx].value = prefix;
  571. } else {
  572. tokens[idx].value = value;
  573. }
  574. depth(tokens[idx]);
  575. state.maxDepth += tokens[idx].depth;
  576. }
  577. if (idx !== 0 || value !== "") {
  578. parts.push(value);
  579. }
  580. prevIndex = i;
  581. }
  582. if (prevIndex && prevIndex + 1 < input.length) {
  583. const value = input.slice(prevIndex + 1);
  584. parts.push(value);
  585. if (opts.tokens) {
  586. tokens[tokens.length - 1].value = value;
  587. depth(tokens[tokens.length - 1]);
  588. state.maxDepth += tokens[tokens.length - 1].depth;
  589. }
  590. }
  591. state.slashes = slashes;
  592. state.parts = parts;
  593. }
  594. return state;
  595. };
  596. var scan_1 = scan$1;
  597. const constants$1 = constants$2;
  598. const utils$2 = utils$4;
  599. const {
  600. MAX_LENGTH,
  601. POSIX_REGEX_SOURCE,
  602. REGEX_NON_SPECIAL_CHARS,
  603. REGEX_SPECIAL_CHARS_BACKREF,
  604. REPLACEMENTS
  605. } = constants$1;
  606. const expandRange = (args, options) => {
  607. if (typeof options.expandRange === "function") {
  608. return options.expandRange(...args, options);
  609. }
  610. args.sort();
  611. const value = `[${args.join("-")}]`;
  612. try {
  613. new RegExp(value);
  614. } catch (ex) {
  615. return args.map((v) => utils$2.escapeRegex(v)).join("..");
  616. }
  617. return value;
  618. };
  619. const syntaxError = (type, char) => {
  620. return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
  621. };
  622. const parse$1 = (input, options) => {
  623. if (typeof input !== "string") {
  624. throw new TypeError("Expected a string");
  625. }
  626. input = REPLACEMENTS[input] || input;
  627. const opts = { ...options };
  628. const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
  629. let len = input.length;
  630. if (len > max) {
  631. throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
  632. }
  633. const bos = { type: "bos", value: "", output: opts.prepend || "" };
  634. const tokens = [bos];
  635. const capture = opts.capture ? "" : "?:";
  636. const PLATFORM_CHARS = constants$1.globChars(opts.windows);
  637. const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
  638. const {
  639. DOT_LITERAL: DOT_LITERAL2,
  640. PLUS_LITERAL: PLUS_LITERAL2,
  641. SLASH_LITERAL: SLASH_LITERAL2,
  642. ONE_CHAR: ONE_CHAR2,
  643. DOTS_SLASH: DOTS_SLASH2,
  644. NO_DOT: NO_DOT2,
  645. NO_DOT_SLASH: NO_DOT_SLASH2,
  646. NO_DOTS_SLASH: NO_DOTS_SLASH2,
  647. QMARK: QMARK2,
  648. QMARK_NO_DOT: QMARK_NO_DOT2,
  649. STAR: STAR2,
  650. START_ANCHOR: START_ANCHOR2
  651. } = PLATFORM_CHARS;
  652. const globstar = (opts2) => {
  653. return `(${capture}(?:(?!${START_ANCHOR2}${opts2.dot ? DOTS_SLASH2 : DOT_LITERAL2}).)*?)`;
  654. };
  655. const nodot = opts.dot ? "" : NO_DOT2;
  656. const qmarkNoDot = opts.dot ? QMARK2 : QMARK_NO_DOT2;
  657. let star = opts.bash === true ? globstar(opts) : STAR2;
  658. if (opts.capture) {
  659. star = `(${star})`;
  660. }
  661. if (typeof opts.noext === "boolean") {
  662. opts.noextglob = opts.noext;
  663. }
  664. const state = {
  665. input,
  666. index: -1,
  667. start: 0,
  668. dot: opts.dot === true,
  669. consumed: "",
  670. output: "",
  671. prefix: "",
  672. backtrack: false,
  673. negated: false,
  674. brackets: 0,
  675. braces: 0,
  676. parens: 0,
  677. quotes: 0,
  678. globstar: false,
  679. tokens
  680. };
  681. input = utils$2.removePrefix(input, state);
  682. len = input.length;
  683. const extglobs = [];
  684. const braces = [];
  685. const stack = [];
  686. let prev = bos;
  687. let value;
  688. const eos = () => state.index === len - 1;
  689. const peek = state.peek = (n = 1) => input[state.index + n];
  690. const advance = state.advance = () => input[++state.index] || "";
  691. const remaining = () => input.slice(state.index + 1);
  692. const consume = (value2 = "", num = 0) => {
  693. state.consumed += value2;
  694. state.index += num;
  695. };
  696. const append = (token) => {
  697. state.output += token.output != null ? token.output : token.value;
  698. consume(token.value);
  699. };
  700. const negate = () => {
  701. let count = 1;
  702. while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
  703. advance();
  704. state.start++;
  705. count++;
  706. }
  707. if (count % 2 === 0) {
  708. return false;
  709. }
  710. state.negated = true;
  711. state.start++;
  712. return true;
  713. };
  714. const increment = (type) => {
  715. state[type]++;
  716. stack.push(type);
  717. };
  718. const decrement = (type) => {
  719. state[type]--;
  720. stack.pop();
  721. };
  722. const push = (tok) => {
  723. if (prev.type === "globstar") {
  724. const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
  725. const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
  726. if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
  727. state.output = state.output.slice(0, -prev.output.length);
  728. prev.type = "star";
  729. prev.value = "*";
  730. prev.output = star;
  731. state.output += prev.output;
  732. }
  733. }
  734. if (extglobs.length && tok.type !== "paren") {
  735. extglobs[extglobs.length - 1].inner += tok.value;
  736. }
  737. if (tok.value || tok.output) append(tok);
  738. if (prev && prev.type === "text" && tok.type === "text") {
  739. prev.output = (prev.output || prev.value) + tok.value;
  740. prev.value += tok.value;
  741. return;
  742. }
  743. tok.prev = prev;
  744. tokens.push(tok);
  745. prev = tok;
  746. };
  747. const extglobOpen = (type, value2) => {
  748. const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
  749. token.prev = prev;
  750. token.parens = state.parens;
  751. token.output = state.output;
  752. const output = (opts.capture ? "(" : "") + token.open;
  753. increment("parens");
  754. push({ type, value: value2, output: state.output ? "" : ONE_CHAR2 });
  755. push({ type: "paren", extglob: true, value: advance(), output });
  756. extglobs.push(token);
  757. };
  758. const extglobClose = (token) => {
  759. let output = token.close + (opts.capture ? ")" : "");
  760. let rest;
  761. if (token.type === "negate") {
  762. let extglobStar = star;
  763. if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
  764. extglobStar = globstar(opts);
  765. }
  766. if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
  767. output = token.close = `)$))${extglobStar}`;
  768. }
  769. if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
  770. const expression = parse$1(rest, { ...options, fastpaths: false }).output;
  771. output = token.close = `)${expression})${extglobStar})`;
  772. }
  773. if (token.prev.type === "bos") {
  774. state.negatedExtglob = true;
  775. }
  776. }
  777. push({ type: "paren", extglob: true, value, output });
  778. decrement("parens");
  779. };
  780. if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
  781. let backslashes = false;
  782. let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
  783. if (first === "\\") {
  784. backslashes = true;
  785. return m;
  786. }
  787. if (first === "?") {
  788. if (esc) {
  789. return esc + first + (rest ? QMARK2.repeat(rest.length) : "");
  790. }
  791. if (index === 0) {
  792. return qmarkNoDot + (rest ? QMARK2.repeat(rest.length) : "");
  793. }
  794. return QMARK2.repeat(chars.length);
  795. }
  796. if (first === ".") {
  797. return DOT_LITERAL2.repeat(chars.length);
  798. }
  799. if (first === "*") {
  800. if (esc) {
  801. return esc + first + (rest ? star : "");
  802. }
  803. return star;
  804. }
  805. return esc ? m : `\\${m}`;
  806. });
  807. if (backslashes === true) {
  808. if (opts.unescape === true) {
  809. output = output.replace(/\\/g, "");
  810. } else {
  811. output = output.replace(/\\+/g, (m) => {
  812. return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
  813. });
  814. }
  815. }
  816. if (output === input && opts.contains === true) {
  817. state.output = input;
  818. return state;
  819. }
  820. state.output = utils$2.wrapOutput(output, state, options);
  821. return state;
  822. }
  823. while (!eos()) {
  824. value = advance();
  825. if (value === "\0") {
  826. continue;
  827. }
  828. if (value === "\\") {
  829. const next = peek();
  830. if (next === "/" && opts.bash !== true) {
  831. continue;
  832. }
  833. if (next === "." || next === ";") {
  834. continue;
  835. }
  836. if (!next) {
  837. value += "\\";
  838. push({ type: "text", value });
  839. continue;
  840. }
  841. const match = /^\\+/.exec(remaining());
  842. let slashes = 0;
  843. if (match && match[0].length > 2) {
  844. slashes = match[0].length;
  845. state.index += slashes;
  846. if (slashes % 2 !== 0) {
  847. value += "\\";
  848. }
  849. }
  850. if (opts.unescape === true) {
  851. value = advance();
  852. } else {
  853. value += advance();
  854. }
  855. if (state.brackets === 0) {
  856. push({ type: "text", value });
  857. continue;
  858. }
  859. }
  860. if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
  861. if (opts.posix !== false && value === ":") {
  862. const inner = prev.value.slice(1);
  863. if (inner.includes("[")) {
  864. prev.posix = true;
  865. if (inner.includes(":")) {
  866. const idx = prev.value.lastIndexOf("[");
  867. const pre = prev.value.slice(0, idx);
  868. const rest2 = prev.value.slice(idx + 2);
  869. const posix = POSIX_REGEX_SOURCE[rest2];
  870. if (posix) {
  871. prev.value = pre + posix;
  872. state.backtrack = true;
  873. advance();
  874. if (!bos.output && tokens.indexOf(prev) === 1) {
  875. bos.output = ONE_CHAR2;
  876. }
  877. continue;
  878. }
  879. }
  880. }
  881. }
  882. if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
  883. value = `\\${value}`;
  884. }
  885. if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
  886. value = `\\${value}`;
  887. }
  888. if (opts.posix === true && value === "!" && prev.value === "[") {
  889. value = "^";
  890. }
  891. prev.value += value;
  892. append({ value });
  893. continue;
  894. }
  895. if (state.quotes === 1 && value !== '"') {
  896. value = utils$2.escapeRegex(value);
  897. prev.value += value;
  898. append({ value });
  899. continue;
  900. }
  901. if (value === '"') {
  902. state.quotes = state.quotes === 1 ? 0 : 1;
  903. if (opts.keepQuotes === true) {
  904. push({ type: "text", value });
  905. }
  906. continue;
  907. }
  908. if (value === "(") {
  909. increment("parens");
  910. push({ type: "paren", value });
  911. continue;
  912. }
  913. if (value === ")") {
  914. if (state.parens === 0 && opts.strictBrackets === true) {
  915. throw new SyntaxError(syntaxError("opening", "("));
  916. }
  917. const extglob = extglobs[extglobs.length - 1];
  918. if (extglob && state.parens === extglob.parens + 1) {
  919. extglobClose(extglobs.pop());
  920. continue;
  921. }
  922. push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
  923. decrement("parens");
  924. continue;
  925. }
  926. if (value === "[") {
  927. if (opts.nobracket === true || !remaining().includes("]")) {
  928. if (opts.nobracket !== true && opts.strictBrackets === true) {
  929. throw new SyntaxError(syntaxError("closing", "]"));
  930. }
  931. value = `\\${value}`;
  932. } else {
  933. increment("brackets");
  934. }
  935. push({ type: "bracket", value });
  936. continue;
  937. }
  938. if (value === "]") {
  939. if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
  940. push({ type: "text", value, output: `\\${value}` });
  941. continue;
  942. }
  943. if (state.brackets === 0) {
  944. if (opts.strictBrackets === true) {
  945. throw new SyntaxError(syntaxError("opening", "["));
  946. }
  947. push({ type: "text", value, output: `\\${value}` });
  948. continue;
  949. }
  950. decrement("brackets");
  951. const prevValue = prev.value.slice(1);
  952. if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
  953. value = `/${value}`;
  954. }
  955. prev.value += value;
  956. append({ value });
  957. if (opts.literalBrackets === false || utils$2.hasRegexChars(prevValue)) {
  958. continue;
  959. }
  960. const escaped = utils$2.escapeRegex(prev.value);
  961. state.output = state.output.slice(0, -prev.value.length);
  962. if (opts.literalBrackets === true) {
  963. state.output += escaped;
  964. prev.value = escaped;
  965. continue;
  966. }
  967. prev.value = `(${capture}${escaped}|${prev.value})`;
  968. state.output += prev.value;
  969. continue;
  970. }
  971. if (value === "{" && opts.nobrace !== true) {
  972. increment("braces");
  973. const open = {
  974. type: "brace",
  975. value,
  976. output: "(",
  977. outputIndex: state.output.length,
  978. tokensIndex: state.tokens.length
  979. };
  980. braces.push(open);
  981. push(open);
  982. continue;
  983. }
  984. if (value === "}") {
  985. const brace = braces[braces.length - 1];
  986. if (opts.nobrace === true || !brace) {
  987. push({ type: "text", value, output: value });
  988. continue;
  989. }
  990. let output = ")";
  991. if (brace.dots === true) {
  992. const arr = tokens.slice();
  993. const range = [];
  994. for (let i = arr.length - 1; i >= 0; i--) {
  995. tokens.pop();
  996. if (arr[i].type === "brace") {
  997. break;
  998. }
  999. if (arr[i].type !== "dots") {
  1000. range.unshift(arr[i].value);
  1001. }
  1002. }
  1003. output = expandRange(range, opts);
  1004. state.backtrack = true;
  1005. }
  1006. if (brace.comma !== true && brace.dots !== true) {
  1007. const out = state.output.slice(0, brace.outputIndex);
  1008. const toks = state.tokens.slice(brace.tokensIndex);
  1009. brace.value = brace.output = "\\{";
  1010. value = output = "\\}";
  1011. state.output = out;
  1012. for (const t of toks) {
  1013. state.output += t.output || t.value;
  1014. }
  1015. }
  1016. push({ type: "brace", value, output });
  1017. decrement("braces");
  1018. braces.pop();
  1019. continue;
  1020. }
  1021. if (value === "|") {
  1022. if (extglobs.length > 0) {
  1023. extglobs[extglobs.length - 1].conditions++;
  1024. }
  1025. push({ type: "text", value });
  1026. continue;
  1027. }
  1028. if (value === ",") {
  1029. let output = value;
  1030. const brace = braces[braces.length - 1];
  1031. if (brace && stack[stack.length - 1] === "braces") {
  1032. brace.comma = true;
  1033. output = "|";
  1034. }
  1035. push({ type: "comma", value, output });
  1036. continue;
  1037. }
  1038. if (value === "/") {
  1039. if (prev.type === "dot" && state.index === state.start + 1) {
  1040. state.start = state.index + 1;
  1041. state.consumed = "";
  1042. state.output = "";
  1043. tokens.pop();
  1044. prev = bos;
  1045. continue;
  1046. }
  1047. push({ type: "slash", value, output: SLASH_LITERAL2 });
  1048. continue;
  1049. }
  1050. if (value === ".") {
  1051. if (state.braces > 0 && prev.type === "dot") {
  1052. if (prev.value === ".") prev.output = DOT_LITERAL2;
  1053. const brace = braces[braces.length - 1];
  1054. prev.type = "dots";
  1055. prev.output += value;
  1056. prev.value += value;
  1057. brace.dots = true;
  1058. continue;
  1059. }
  1060. if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
  1061. push({ type: "text", value, output: DOT_LITERAL2 });
  1062. continue;
  1063. }
  1064. push({ type: "dot", value, output: DOT_LITERAL2 });
  1065. continue;
  1066. }
  1067. if (value === "?") {
  1068. const isGroup = prev && prev.value === "(";
  1069. if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
  1070. extglobOpen("qmark", value);
  1071. continue;
  1072. }
  1073. if (prev && prev.type === "paren") {
  1074. const next = peek();
  1075. let output = value;
  1076. if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
  1077. output = `\\${value}`;
  1078. }
  1079. push({ type: "text", value, output });
  1080. continue;
  1081. }
  1082. if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
  1083. push({ type: "qmark", value, output: QMARK_NO_DOT2 });
  1084. continue;
  1085. }
  1086. push({ type: "qmark", value, output: QMARK2 });
  1087. continue;
  1088. }
  1089. if (value === "!") {
  1090. if (opts.noextglob !== true && peek() === "(") {
  1091. if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
  1092. extglobOpen("negate", value);
  1093. continue;
  1094. }
  1095. }
  1096. if (opts.nonegate !== true && state.index === 0) {
  1097. negate();
  1098. continue;
  1099. }
  1100. }
  1101. if (value === "+") {
  1102. if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
  1103. extglobOpen("plus", value);
  1104. continue;
  1105. }
  1106. if (prev && prev.value === "(" || opts.regex === false) {
  1107. push({ type: "plus", value, output: PLUS_LITERAL2 });
  1108. continue;
  1109. }
  1110. if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
  1111. push({ type: "plus", value });
  1112. continue;
  1113. }
  1114. push({ type: "plus", value: PLUS_LITERAL2 });
  1115. continue;
  1116. }
  1117. if (value === "@") {
  1118. if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
  1119. push({ type: "at", extglob: true, value, output: "" });
  1120. continue;
  1121. }
  1122. push({ type: "text", value });
  1123. continue;
  1124. }
  1125. if (value !== "*") {
  1126. if (value === "$" || value === "^") {
  1127. value = `\\${value}`;
  1128. }
  1129. const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
  1130. if (match) {
  1131. value += match[0];
  1132. state.index += match[0].length;
  1133. }
  1134. push({ type: "text", value });
  1135. continue;
  1136. }
  1137. if (prev && (prev.type === "globstar" || prev.star === true)) {
  1138. prev.type = "star";
  1139. prev.star = true;
  1140. prev.value += value;
  1141. prev.output = star;
  1142. state.backtrack = true;
  1143. state.globstar = true;
  1144. consume(value);
  1145. continue;
  1146. }
  1147. let rest = remaining();
  1148. if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
  1149. extglobOpen("star", value);
  1150. continue;
  1151. }
  1152. if (prev.type === "star") {
  1153. if (opts.noglobstar === true) {
  1154. consume(value);
  1155. continue;
  1156. }
  1157. const prior = prev.prev;
  1158. const before = prior.prev;
  1159. const isStart = prior.type === "slash" || prior.type === "bos";
  1160. const afterStar = before && (before.type === "star" || before.type === "globstar");
  1161. if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
  1162. push({ type: "star", value, output: "" });
  1163. continue;
  1164. }
  1165. const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
  1166. const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
  1167. if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
  1168. push({ type: "star", value, output: "" });
  1169. continue;
  1170. }
  1171. while (rest.slice(0, 3) === "/**") {
  1172. const after = input[state.index + 4];
  1173. if (after && after !== "/") {
  1174. break;
  1175. }
  1176. rest = rest.slice(3);
  1177. consume("/**", 3);
  1178. }
  1179. if (prior.type === "bos" && eos()) {
  1180. prev.type = "globstar";
  1181. prev.value += value;
  1182. prev.output = globstar(opts);
  1183. state.output = prev.output;
  1184. state.globstar = true;
  1185. consume(value);
  1186. continue;
  1187. }
  1188. if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
  1189. state.output = state.output.slice(0, -(prior.output + prev.output).length);
  1190. prior.output = `(?:${prior.output}`;
  1191. prev.type = "globstar";
  1192. prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
  1193. prev.value += value;
  1194. state.globstar = true;
  1195. state.output += prior.output + prev.output;
  1196. consume(value);
  1197. continue;
  1198. }
  1199. if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
  1200. const end = rest[1] !== void 0 ? "|$" : "";
  1201. state.output = state.output.slice(0, -(prior.output + prev.output).length);
  1202. prior.output = `(?:${prior.output}`;
  1203. prev.type = "globstar";
  1204. prev.output = `${globstar(opts)}${SLASH_LITERAL2}|${SLASH_LITERAL2}${end})`;
  1205. prev.value += value;
  1206. state.output += prior.output + prev.output;
  1207. state.globstar = true;
  1208. consume(value + advance());
  1209. push({ type: "slash", value: "/", output: "" });
  1210. continue;
  1211. }
  1212. if (prior.type === "bos" && rest[0] === "/") {
  1213. prev.type = "globstar";
  1214. prev.value += value;
  1215. prev.output = `(?:^|${SLASH_LITERAL2}|${globstar(opts)}${SLASH_LITERAL2})`;
  1216. state.output = prev.output;
  1217. state.globstar = true;
  1218. consume(value + advance());
  1219. push({ type: "slash", value: "/", output: "" });
  1220. continue;
  1221. }
  1222. state.output = state.output.slice(0, -prev.output.length);
  1223. prev.type = "globstar";
  1224. prev.output = globstar(opts);
  1225. prev.value += value;
  1226. state.output += prev.output;
  1227. state.globstar = true;
  1228. consume(value);
  1229. continue;
  1230. }
  1231. const token = { type: "star", value, output: star };
  1232. if (opts.bash === true) {
  1233. token.output = ".*?";
  1234. if (prev.type === "bos" || prev.type === "slash") {
  1235. token.output = nodot + token.output;
  1236. }
  1237. push(token);
  1238. continue;
  1239. }
  1240. if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
  1241. token.output = value;
  1242. push(token);
  1243. continue;
  1244. }
  1245. if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
  1246. if (prev.type === "dot") {
  1247. state.output += NO_DOT_SLASH2;
  1248. prev.output += NO_DOT_SLASH2;
  1249. } else if (opts.dot === true) {
  1250. state.output += NO_DOTS_SLASH2;
  1251. prev.output += NO_DOTS_SLASH2;
  1252. } else {
  1253. state.output += nodot;
  1254. prev.output += nodot;
  1255. }
  1256. if (peek() !== "*") {
  1257. state.output += ONE_CHAR2;
  1258. prev.output += ONE_CHAR2;
  1259. }
  1260. }
  1261. push(token);
  1262. }
  1263. while (state.brackets > 0) {
  1264. if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
  1265. state.output = utils$2.escapeLast(state.output, "[");
  1266. decrement("brackets");
  1267. }
  1268. while (state.parens > 0) {
  1269. if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
  1270. state.output = utils$2.escapeLast(state.output, "(");
  1271. decrement("parens");
  1272. }
  1273. while (state.braces > 0) {
  1274. if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
  1275. state.output = utils$2.escapeLast(state.output, "{");
  1276. decrement("braces");
  1277. }
  1278. if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
  1279. push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL2}?` });
  1280. }
  1281. if (state.backtrack === true) {
  1282. state.output = "";
  1283. for (const token of state.tokens) {
  1284. state.output += token.output != null ? token.output : token.value;
  1285. if (token.suffix) {
  1286. state.output += token.suffix;
  1287. }
  1288. }
  1289. }
  1290. return state;
  1291. };
  1292. parse$1.fastpaths = (input, options) => {
  1293. const opts = { ...options };
  1294. const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
  1295. const len = input.length;
  1296. if (len > max) {
  1297. throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
  1298. }
  1299. input = REPLACEMENTS[input] || input;
  1300. const {
  1301. DOT_LITERAL: DOT_LITERAL2,
  1302. SLASH_LITERAL: SLASH_LITERAL2,
  1303. ONE_CHAR: ONE_CHAR2,
  1304. DOTS_SLASH: DOTS_SLASH2,
  1305. NO_DOT: NO_DOT2,
  1306. NO_DOTS: NO_DOTS2,
  1307. NO_DOTS_SLASH: NO_DOTS_SLASH2,
  1308. STAR: STAR2,
  1309. START_ANCHOR: START_ANCHOR2
  1310. } = constants$1.globChars(opts.windows);
  1311. const nodot = opts.dot ? NO_DOTS2 : NO_DOT2;
  1312. const slashDot = opts.dot ? NO_DOTS_SLASH2 : NO_DOT2;
  1313. const capture = opts.capture ? "" : "?:";
  1314. const state = { negated: false, prefix: "" };
  1315. let star = opts.bash === true ? ".*?" : STAR2;
  1316. if (opts.capture) {
  1317. star = `(${star})`;
  1318. }
  1319. const globstar = (opts2) => {
  1320. if (opts2.noglobstar === true) return star;
  1321. return `(${capture}(?:(?!${START_ANCHOR2}${opts2.dot ? DOTS_SLASH2 : DOT_LITERAL2}).)*?)`;
  1322. };
  1323. const create = (str) => {
  1324. switch (str) {
  1325. case "*":
  1326. return `${nodot}${ONE_CHAR2}${star}`;
  1327. case ".*":
  1328. return `${DOT_LITERAL2}${ONE_CHAR2}${star}`;
  1329. case "*.*":
  1330. return `${nodot}${star}${DOT_LITERAL2}${ONE_CHAR2}${star}`;
  1331. case "*/*":
  1332. return `${nodot}${star}${SLASH_LITERAL2}${ONE_CHAR2}${slashDot}${star}`;
  1333. case "**":
  1334. return nodot + globstar(opts);
  1335. case "**/*":
  1336. return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL2})?${slashDot}${ONE_CHAR2}${star}`;
  1337. case "**/*.*":
  1338. return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL2})?${slashDot}${star}${DOT_LITERAL2}${ONE_CHAR2}${star}`;
  1339. case "**/.*":
  1340. return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL2})?${DOT_LITERAL2}${ONE_CHAR2}${star}`;
  1341. default: {
  1342. const match = /^(.*?)\.(\w+)$/.exec(str);
  1343. if (!match) return;
  1344. const source2 = create(match[1]);
  1345. if (!source2) return;
  1346. return source2 + DOT_LITERAL2 + match[2];
  1347. }
  1348. }
  1349. };
  1350. const output = utils$2.removePrefix(input, state);
  1351. let source = create(output);
  1352. if (source && opts.strictSlashes !== true) {
  1353. source += `${SLASH_LITERAL2}?`;
  1354. }
  1355. return source;
  1356. };
  1357. var parse_1 = parse$1;
  1358. const scan = scan_1;
  1359. const parse = parse_1;
  1360. const utils$1 = utils$4;
  1361. const constants = constants$2;
  1362. const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
  1363. const picomatch$1 = (glob, options, returnState = false) => {
  1364. if (Array.isArray(glob)) {
  1365. const fns = glob.map((input) => picomatch$1(input, options, returnState));
  1366. const arrayMatcher = (str) => {
  1367. for (const isMatch of fns) {
  1368. const state2 = isMatch(str);
  1369. if (state2) return state2;
  1370. }
  1371. return false;
  1372. };
  1373. return arrayMatcher;
  1374. }
  1375. const isState = isObject(glob) && glob.tokens && glob.input;
  1376. if (glob === "" || typeof glob !== "string" && !isState) {
  1377. throw new TypeError("Expected pattern to be a non-empty string");
  1378. }
  1379. const opts = options || {};
  1380. const posix = opts.windows;
  1381. const regex = isState ? picomatch$1.compileRe(glob, options) : picomatch$1.makeRe(glob, options, false, true);
  1382. const state = regex.state;
  1383. delete regex.state;
  1384. let isIgnored = () => false;
  1385. if (opts.ignore) {
  1386. const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
  1387. isIgnored = picomatch$1(opts.ignore, ignoreOpts, returnState);
  1388. }
  1389. const matcher = (input, returnObject = false) => {
  1390. const { isMatch, match, output } = picomatch$1.test(input, regex, options, { glob, posix });
  1391. const result = { glob, state, regex, posix, input, output, match, isMatch };
  1392. if (typeof opts.onResult === "function") {
  1393. opts.onResult(result);
  1394. }
  1395. if (isMatch === false) {
  1396. result.isMatch = false;
  1397. return returnObject ? result : false;
  1398. }
  1399. if (isIgnored(input)) {
  1400. if (typeof opts.onIgnore === "function") {
  1401. opts.onIgnore(result);
  1402. }
  1403. result.isMatch = false;
  1404. return returnObject ? result : false;
  1405. }
  1406. if (typeof opts.onMatch === "function") {
  1407. opts.onMatch(result);
  1408. }
  1409. return returnObject ? result : true;
  1410. };
  1411. if (returnState) {
  1412. matcher.state = state;
  1413. }
  1414. return matcher;
  1415. };
  1416. picomatch$1.test = (input, regex, options, { glob, posix } = {}) => {
  1417. if (typeof input !== "string") {
  1418. throw new TypeError("Expected input to be a string");
  1419. }
  1420. if (input === "") {
  1421. return { isMatch: false, output: "" };
  1422. }
  1423. const opts = options || {};
  1424. const format = opts.format || (posix ? utils$1.toPosixSlashes : null);
  1425. let match = input === glob;
  1426. let output = match && format ? format(input) : input;
  1427. if (match === false) {
  1428. output = format ? format(input) : input;
  1429. match = output === glob;
  1430. }
  1431. if (match === false || opts.capture === true) {
  1432. if (opts.matchBase === true || opts.basename === true) {
  1433. match = picomatch$1.matchBase(input, regex, options, posix);
  1434. } else {
  1435. match = regex.exec(output);
  1436. }
  1437. }
  1438. return { isMatch: Boolean(match), match, output };
  1439. };
  1440. picomatch$1.matchBase = (input, glob, options) => {
  1441. const regex = glob instanceof RegExp ? glob : picomatch$1.makeRe(glob, options);
  1442. return regex.test(utils$1.basename(input));
  1443. };
  1444. picomatch$1.isMatch = (str, patterns, options) => picomatch$1(patterns, options)(str);
  1445. picomatch$1.parse = (pattern, options) => {
  1446. if (Array.isArray(pattern)) return pattern.map((p) => picomatch$1.parse(p, options));
  1447. return parse(pattern, { ...options, fastpaths: false });
  1448. };
  1449. picomatch$1.scan = (input, options) => scan(input, options);
  1450. picomatch$1.compileRe = (state, options, returnOutput = false, returnState = false) => {
  1451. if (returnOutput === true) {
  1452. return state.output;
  1453. }
  1454. const opts = options || {};
  1455. const prepend = opts.contains ? "" : "^";
  1456. const append = opts.contains ? "" : "$";
  1457. let source = `${prepend}(?:${state.output})${append}`;
  1458. if (state && state.negated === true) {
  1459. source = `^(?!${source}).*$`;
  1460. }
  1461. const regex = picomatch$1.toRegex(source, options);
  1462. if (returnState === true) {
  1463. regex.state = state;
  1464. }
  1465. return regex;
  1466. };
  1467. picomatch$1.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
  1468. if (!input || typeof input !== "string") {
  1469. throw new TypeError("Expected a non-empty string");
  1470. }
  1471. let parsed = { negated: false, fastpaths: true };
  1472. if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
  1473. parsed.output = parse.fastpaths(input, options);
  1474. }
  1475. if (!parsed.output) {
  1476. parsed = parse(input, options);
  1477. }
  1478. return picomatch$1.compileRe(parsed, options, returnOutput, returnState);
  1479. };
  1480. picomatch$1.toRegex = (source, options) => {
  1481. try {
  1482. const opts = options || {};
  1483. return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
  1484. } catch (err) {
  1485. if (options && options.debug === true) throw err;
  1486. return /$^/;
  1487. }
  1488. };
  1489. picomatch$1.constants = constants;
  1490. var picomatch_1$1 = picomatch$1;
  1491. const pico = picomatch_1$1;
  1492. const utils = utils$4;
  1493. function picomatch(glob, options, returnState = false) {
  1494. if (options && (options.windows === null || options.windows === void 0)) {
  1495. options = { ...options, windows: utils.isWindows() };
  1496. }
  1497. return pico(glob, options, returnState);
  1498. }
  1499. Object.assign(picomatch, pico);
  1500. var picomatch_1 = picomatch;
  1501. const pm = /* @__PURE__ */ getDefaultExportFromCjs(picomatch_1);
  1502. const rules = {
  1503. ".clang-tidy": ".clang-format, .clangd, compile_commands.json",
  1504. ".env": "*.env, .env.*, .envrc, env.d.ts",
  1505. ".gitignore": ".gitattributes, .gitmodules, .gitmessage, .mailmap, .git-blame*",
  1506. ".project": ".classpath",
  1507. "+layout.svelte": "+layout.ts,+layout.ts,+layout.js,+layout.server.ts,+layout.server.js,+layout.gql",
  1508. "+page.svelte": "+page.server.ts,+page.server.js,+page.ts,+page.js,+page.gql",
  1509. "ansible.cfg": "ansible.cfg, .ansible-lint, requirements.yml",
  1510. "app.config.*": "*.env, .babelrc*, .codecov, .cssnanorc*, .env.*, .envrc, .htmlnanorc*, .lighthouserc.*, .mocha*, .postcssrc*, .terserrc*, api-extractor.json, ava.config.*, babel.config.*, capacitor.config.*, contentlayer.config.*, cssnano.config.*, cypress.*, env.d.ts, formkit.config.*, formulate.config.*, histoire.config.*, htmlnanorc.*, i18n.config.*, ionic.config.*, jasmine.*, jest.config.*, jsconfig.*, karma*, lighthouserc.*, panda.config.*, playwright.config.*, postcss.config.*, puppeteer.config.*, rspack.config.*, sst.config.*, svgo.config.*, tailwind.config.*, tsconfig.*, tsdoc.*, uno.config.*, unocss.config.*, vitest.config.*, vuetify.config.*, webpack.config.*, windi.config.*",
  1511. "artisan": "*.env, .babelrc*, .codecov, .cssnanorc*, .env.*, .envrc, .htmlnanorc*, .lighthouserc.*, .mocha*, .postcssrc*, .terserrc*, api-extractor.json, ava.config.*, babel.config.*, capacitor.config.*, contentlayer.config.*, cssnano.config.*, cypress.*, env.d.ts, formkit.config.*, formulate.config.*, histoire.config.*, htmlnanorc.*, i18n.config.*, ionic.config.*, jasmine.*, jest.config.*, jsconfig.*, karma*, lighthouserc.*, panda.config.*, playwright.config.*, postcss.config.*, puppeteer.config.*, rspack.config.*, server.php, sst.config.*, svgo.config.*, tailwind.config.*, tsconfig.*, tsdoc.*, uno.config.*, unocss.config.*, vitest.config.*, vuetify.config.*, webpack.config.*, webpack.mix.js, windi.config.*",
  1512. "astro.config.*": "*.env, .babelrc*, .codecov, .cssnanorc*, .env.*, .envrc, .htmlnanorc*, .lighthouserc.*, .mocha*, .postcssrc*, .terserrc*, api-extractor.json, ava.config.*, babel.config.*, capacitor.config.*, contentlayer.config.*, cssnano.config.*, cypress.*, env.d.ts, formkit.config.*, formulate.config.*, histoire.config.*, htmlnanorc.*, i18n.config.*, ionic.config.*, jasmine.*, jest.config.*, jsconfig.*, karma*, lighthouserc.*, panda.config.*, playwright.config.*, postcss.config.*, puppeteer.config.*, rspack.config.*, sst.config.*, svgo.config.*, tailwind.config.*, tsconfig.*, tsdoc.*, uno.config.*, unocss.config.*, vitest.config.*, vuetify.config.*, webpack.config.*, windi.config.*",
  1513. "build-wrapper.log": "build-wrapper*.log, build-wrapper-dump*.json, build-wrapper-win*.exe, build-wrapper-linux*, build-wrapper-macosx*",
  1514. "BUILD.bazel": "*.bzl, *.bazel, *.bazelrc, bazel.rc, .bazelignore, .bazelproject, WORKSPACE",
  1515. "Cargo.toml": ".clippy.toml, .rustfmt.toml, cargo.lock, clippy.toml, cross.toml, rust-toolchain.toml, rustfmt.toml",
  1516. "CMakeLists.txt": "*.cmake, *.cmake.in, .cmake-format.yaml, CMakePresets.json, CMakeCache.txt",
  1517. "composer.json": ".php*.cache, composer.lock, phpunit.xml*, psalm*.xml",
  1518. "default.nix": "shell.nix",
  1519. "deno.json*": "*.env, .env.*, .envrc, api-extractor.json, deno.lock, env.d.ts, import-map.json, import_map.json, jsconfig.*, tsconfig.*, tsdoc.*",
  1520. "Dockerfile": "*.dockerfile, .devcontainer.*, .dockerignore, captain-definition, compose.*, docker-compose.*, dockerfile*",
  1521. "flake.nix": "flake.lock",
  1522. "gatsby-config.*": "*.env, .babelrc*, .codecov, .cssnanorc*, .env.*, .envrc, .htmlnanorc*, .lighthouserc.*, .mocha*, .postcssrc*, .terserrc*, api-extractor.json, ava.config.*, babel.config.*, capacitor.config.*, contentlayer.config.*, cssnano.config.*, cypress.*, env.d.ts, formkit.config.*, formulate.config.*, gatsby-browser.*, gatsby-node.*, gatsby-ssr.*, gatsby-transformer.*, histoire.config.*, htmlnanorc.*, i18n.config.*, ionic.config.*, jasmine.*, jest.config.*, jsconfig.*, karma*, lighthouserc.*, panda.config.*, playwright.config.*, postcss.config.*, puppeteer.config.*, rspack.config.*, sst.config.*, svgo.config.*, tailwind.config.*, tsconfig.*, tsdoc.*, uno.config.*, unocss.config.*, vitest.config.*, vuetify.config.*, webpack.config.*, windi.config.*",
  1523. "gemfile": ".ruby-version, gemfile.lock",
  1524. "go.mod": ".air*, go.sum",
  1525. "go.work": "go.work.sum",
  1526. "hatch.toml": ".editorconfig, .flake8, .isort.cfg, .python-version, hatch.toml, requirements*.in, requirements*.pip, requirements*.txt, tox.ini",
  1527. "I*.cs": "$(capture).cs",
  1528. "Makefile": "*.mk",
  1529. "mix.exs": ".credo.exs, .dialyzer_ignore.exs, .formatter.exs, .iex.exs, .tool-versions, mix.lock",
  1530. "next.config.*": "*.env, .babelrc*, .codecov, .cssnanorc*, .env.*, .envrc, .htmlnanorc*, .lighthouserc.*, .mocha*, .postcssrc*, .terserrc*, api-extractor.json, ava.config.*, babel.config.*, capacitor.config.*, contentlayer.config.*, cssnano.config.*, cypress.*, env.d.ts, formkit.config.*, formulate.config.*, histoire.config.*, htmlnanorc.*, i18n.config.*, ionic.config.*, jasmine.*, jest.config.*, jsconfig.*, karma*, lighthouserc.*, next-env.d.ts, next-i18next.config.*, panda.config.*, playwright.config.*, postcss.config.*, puppeteer.config.*, rspack.config.*, sst.config.*, svgo.config.*, tailwind.config.*, tsconfig.*, tsdoc.*, uno.config.*, unocss.config.*, vitest.config.*, vuetify.config.*, webpack.config.*, windi.config.*",
  1531. "nuxt.config.*": "*.env, .babelrc*, .codecov, .cssnanorc*, .env.*, .envrc, .htmlnanorc*, .lighthouserc.*, .mocha*, .nuxtignore, .nuxtrc, .postcssrc*, .terserrc*, api-extractor.json, ava.config.*, babel.config.*, capacitor.config.*, contentlayer.config.*, cssnano.config.*, cypress.*, env.d.ts, formkit.config.*, formulate.config.*, histoire.config.*, htmlnanorc.*, i18n.config.*, ionic.config.*, jasmine.*, jest.config.*, jsconfig.*, karma*, lighthouserc.*, panda.config.*, playwright.config.*, postcss.config.*, puppeteer.config.*, rspack.config.*, sst.config.*, svgo.config.*, tailwind.config.*, tsconfig.*, tsdoc.*, uno.config.*, unocss.config.*, vitest.config.*, vuetify.config.*, webpack.config.*, windi.config.*",
  1532. "package.json": "*.code-workspace, .browserslist*, .circleci*, .commitlint*, .cursorrules, .cz-config.js, .czrc, .dlint.json, .dprint.json*, .editorconfig, .eslint*, .firebase*, .flowconfig, .github*, .gitlab*, .gitmojirc.json, .gitpod*, .huskyrc*, .jslint*, .knip.*, .lintstagedrc*, .markdownlint*, .node-version, .nodemon*, .npm*, .nvmrc, .pm2*, .pnp.*, .pnpm*, .prettier*, .pylintrc, .release-please*.json, .releaserc*, .ruff.toml, .sentry*, .simple-git-hooks*, .stackblitz*, .styleci*, .stylelint*, .tazerc*, .textlint*, .tool-versions, .travis*, .versionrc*, .vscode*, .watchman*, .xo-config*, .yamllint*, .yarnrc*, Procfile, apollo.config.*, appveyor*, azure-pipelines*, biome.json*, bower.json, build.config.*, bun.lockb, bunfig.toml, colada.options.ts, commitlint*, crowdin*, dangerfile*, dlint.json, dprint.json*, electron-builder.*, eslint*, firebase.json, grunt*, gulp*, jenkins*, knip.*, lerna*, lint-staged*, nest-cli.*, netlify*, nixpacks*, nodemon*, npm-shrinkwrap.json, nx.*, package-lock.json, package.nls*.json, phpcs.xml, pm2.*, pnpm*, prettier*, pullapprove*, pyrightconfig.json, release-please*.json, release-tasks.sh, release.config.*, renovate*, rollup.config.*, rspack*, ruff.toml, sentry.*.config.ts, simple-git-hooks*, sonar-project.properties, stylelint*, tslint*, tsup.config.*, turbo*, typedoc*, unlighthouse*, vercel*, vetur.config.*, webpack*, workspace.json, wrangler.toml, xo.config.*, yarn*",
  1533. "Pipfile": ".editorconfig, .flake8, .isort.cfg, .python-version, Pipfile, Pipfile.lock, requirements*.in, requirements*.pip, requirements*.txt, tox.ini",
  1534. "pubspec.yaml": ".metadata, .packages, all_lint_rules.yaml, analysis_options.yaml, build.yaml, pubspec.lock, pubspec_overrides.yaml",
  1535. "pyproject.toml": ".commitlint*, .dlint.json, .dprint.json*, .editorconfig, .eslint*, .flake8, .flowconfig, .isort.cfg, .jslint*, .lintstagedrc*, .markdownlint*, .pdm-python, .pdm.toml, .prettier*, .pylintrc, .python-version, .ruff.toml, .stylelint*, .textlint*, .xo-config*, .yamllint*, MANIFEST.in, Pipfile, Pipfile.lock, biome.json*, commitlint*, dangerfile*, dlint.json, dprint.json*, eslint*, hatch.toml, lint-staged*, pdm.lock, phpcs.xml, poetry.lock, poetry.toml, prettier*, pyproject.toml, pyrightconfig.json, requirements*.in, requirements*.pip, requirements*.txt, ruff.toml, setup.cfg, setup.py, stylelint*, tox.ini, tslint*, uv.lock, uv.toml, xo.config.*",
  1536. "quasar.conf.js": "*.env, .babelrc*, .codecov, .cssnanorc*, .env.*, .envrc, .htmlnanorc*, .lighthouserc.*, .mocha*, .postcssrc*, .terserrc*, api-extractor.json, ava.config.*, babel.config.*, capacitor.config.*, contentlayer.config.*, cssnano.config.*, cypress.*, env.d.ts, formkit.config.*, formulate.config.*, histoire.config.*, htmlnanorc.*, i18n.config.*, ionic.config.*, jasmine.*, jest.config.*, jsconfig.*, karma*, lighthouserc.*, panda.config.*, playwright.config.*, postcss.config.*, puppeteer.config.*, quasar.extensions.json, rspack.config.*, sst.config.*, svgo.config.*, tailwind.config.*, tsconfig.*, tsdoc.*, uno.config.*, unocss.config.*, vitest.config.*, vuetify.config.*, webpack.config.*, windi.config.*",
  1537. "readme*": "AUTHORS, Authors, BACKERS*, Backers*, CHANGELOG*, CITATION*, CODEOWNERS, CODE_OF_CONDUCT*, CONTRIBUTING*, CONTRIBUTORS, COPYING*, CREDITS, Changelog*, Citation*, Code_Of_Conduct*, Codeowners, Contributing*, Contributors, Copying*, Credits, GOVERNANCE.MD, Governance.md, HISTORY.MD, History.md, LICENSE*, License*, MAINTAINERS, Maintainers, README-*, README_*, RELEASE_NOTES*, ROADMAP.MD, Readme-*, Readme_*, Release_Notes*, Roadmap.md, SECURITY.MD, SPONSORS*, Security.md, Sponsors*, authors, backers*, changelog*, citation*, code_of_conduct*, codeowners, contributing*, contributors, copying*, credits, governance.md, history.md, license*, maintainers, readme-*, readme_*, release_notes*, roadmap.md, security.md, sponsors*",
  1538. "Readme*": "AUTHORS, Authors, BACKERS*, Backers*, CHANGELOG*, CITATION*, CODEOWNERS, CODE_OF_CONDUCT*, CONTRIBUTING*, CONTRIBUTORS, COPYING*, CREDITS, Changelog*, Citation*, Code_Of_Conduct*, Codeowners, Contributing*, Contributors, Copying*, Credits, GOVERNANCE.MD, Governance.md, HISTORY.MD, History.md, LICENSE*, License*, MAINTAINERS, Maintainers, README-*, README_*, RELEASE_NOTES*, ROADMAP.MD, Readme-*, Readme_*, Release_Notes*, Roadmap.md, SECURITY.MD, SPONSORS*, Security.md, Sponsors*, authors, backers*, changelog*, citation*, code_of_conduct*, codeowners, contributing*, contributors, copying*, credits, governance.md, history.md, license*, maintainers, readme-*, readme_*, release_notes*, roadmap.md, security.md, sponsors*",
  1539. "README*": "AUTHORS, Authors, BACKERS*, Backers*, CHANGELOG*, CITATION*, CODEOWNERS, CODE_OF_CONDUCT*, CONTRIBUTING*, CONTRIBUTORS, COPYING*, CREDITS, Changelog*, Citation*, Code_Of_Conduct*, Codeowners, Contributing*, Contributors, Copying*, Credits, GOVERNANCE.MD, Governance.md, HISTORY.MD, History.md, LICENSE*, License*, MAINTAINERS, Maintainers, README-*, README_*, RELEASE_NOTES*, ROADMAP.MD, Readme-*, Readme_*, Release_Notes*, Roadmap.md, SECURITY.MD, SPONSORS*, Security.md, Sponsors*, authors, backers*, changelog*, citation*, code_of_conduct*, codeowners, contributing*, contributors, copying*, credits, governance.md, history.md, license*, maintainers, readme-*, readme_*, release_notes*, roadmap.md, security.md, sponsors*",
  1540. "remix.config.*": "*.env, .babelrc*, .codecov, .cssnanorc*, .env.*, .envrc, .htmlnanorc*, .lighthouserc.*, .mocha*, .postcssrc*, .terserrc*, api-extractor.json, ava.config.*, babel.config.*, capacitor.config.*, contentlayer.config.*, cssnano.config.*, cypress.*, env.d.ts, formkit.config.*, formulate.config.*, histoire.config.*, htmlnanorc.*, i18n.config.*, ionic.config.*, jasmine.*, jest.config.*, jsconfig.*, karma*, lighthouserc.*, panda.config.*, playwright.config.*, postcss.config.*, puppeteer.config.*, remix.*, rspack.config.*, sst.config.*, svgo.config.*, tailwind.config.*, tsconfig.*, tsdoc.*, uno.config.*, unocss.config.*, vitest.config.*, vuetify.config.*, webpack.config.*, windi.config.*",
  1541. "requirements.txt": ".editorconfig, .flake8, .isort.cfg, .python-version, requirements*.in, requirements*.pip, requirements*.txt, tox.ini",
  1542. "rush.json": "*.code-workspace, .browserslist*, .circleci*, .commitlint*, .cursorrules, .cz-config.js, .czrc, .dlint.json, .dprint.json*, .editorconfig, .eslint*, .firebase*, .flowconfig, .github*, .gitlab*, .gitmojirc.json, .gitpod*, .huskyrc*, .jslint*, .knip.*, .lintstagedrc*, .markdownlint*, .node-version, .nodemon*, .npm*, .nvmrc, .pm2*, .pnp.*, .pnpm*, .prettier*, .pylintrc, .release-please*.json, .releaserc*, .ruff.toml, .sentry*, .simple-git-hooks*, .stackblitz*, .styleci*, .stylelint*, .tazerc*, .textlint*, .tool-versions, .travis*, .versionrc*, .vscode*, .watchman*, .xo-config*, .yamllint*, .yarnrc*, Procfile, apollo.config.*, appveyor*, azure-pipelines*, biome.json*, bower.json, build.config.*, bun.lockb, bunfig.toml, colada.options.ts, commitlint*, crowdin*, dangerfile*, dlint.json, dprint.json*, electron-builder.*, eslint*, firebase.json, grunt*, gulp*, jenkins*, knip.*, lerna*, lint-staged*, nest-cli.*, netlify*, nixpacks*, nodemon*, npm-shrinkwrap.json, nx.*, package-lock.json, package.nls*.json, phpcs.xml, pm2.*, pnpm*, prettier*, pullapprove*, pyrightconfig.json, release-please*.json, release-tasks.sh, release.config.*, renovate*, rollup.config.*, rspack*, ruff.toml, sentry.*.config.ts, simple-git-hooks*, sonar-project.properties, stylelint*, tslint*, tsup.config.*, turbo*, typedoc*, unlighthouse*, vercel*, vetur.config.*, webpack*, workspace.json, wrangler.toml, xo.config.*, yarn*",
  1543. "sanity.config.*": "sanity.cli.*, sanity.types.ts, schema.json",
  1544. "setup.cfg": ".editorconfig, .flake8, .isort.cfg, .python-version, MANIFEST.in, requirements*.in, requirements*.pip, requirements*.txt, setup.cfg, tox.ini",
  1545. "setup.py": ".editorconfig, .flake8, .isort.cfg, .python-version, MANIFEST.in, requirements*.in, requirements*.pip, requirements*.txt, setup.cfg, setup.py, tox.ini",
  1546. "shims.d.ts": "*.d.ts",
  1547. "svelte.config.*": "*.env, .babelrc*, .codecov, .cssnanorc*, .env.*, .envrc, .htmlnanorc*, .lighthouserc.*, .mocha*, .postcssrc*, .terserrc*, api-extractor.json, ava.config.*, babel.config.*, capacitor.config.*, contentlayer.config.*, cssnano.config.*, cypress.*, env.d.ts, formkit.config.*, formulate.config.*, histoire.config.*, houdini.config.*, htmlnanorc.*, i18n.config.*, ionic.config.*, jasmine.*, jest.config.*, jsconfig.*, karma*, lighthouserc.*, mdsvex.config.js, panda.config.*, playwright.config.*, postcss.config.*, puppeteer.config.*, rspack.config.*, sst.config.*, svgo.config.*, tailwind.config.*, tsconfig.*, tsdoc.*, uno.config.*, unocss.config.*, vite.config.*, vitest.config.*, vuetify.config.*, webpack.config.*, windi.config.*",
  1548. "vite.config.*": "*.env, .babelrc*, .codecov, .cssnanorc*, .env.*, .envrc, .htmlnanorc*, .lighthouserc.*, .mocha*, .postcssrc*, .terserrc*, api-extractor.json, ava.config.*, babel.config.*, capacitor.config.*, contentlayer.config.*, cssnano.config.*, cypress.*, env.d.ts, formkit.config.*, formulate.config.*, histoire.config.*, htmlnanorc.*, i18n.config.*, ionic.config.*, jasmine.*, jest.config.*, jsconfig.*, karma*, lighthouserc.*, panda.config.*, playwright.config.*, postcss.config.*, puppeteer.config.*, rspack.config.*, sst.config.*, svgo.config.*, tailwind.config.*, tsconfig.*, tsdoc.*, uno.config.*, unocss.config.*, vitest.config.*, vuetify.config.*, webpack.config.*, windi.config.*",
  1549. "vue.config.*": "*.env, .babelrc*, .codecov, .cssnanorc*, .env.*, .envrc, .htmlnanorc*, .lighthouserc.*, .mocha*, .postcssrc*, .terserrc*, api-extractor.json, ava.config.*, babel.config.*, capacitor.config.*, contentlayer.config.*, cssnano.config.*, cypress.*, env.d.ts, formkit.config.*, formulate.config.*, histoire.config.*, htmlnanorc.*, i18n.config.*, ionic.config.*, jasmine.*, jest.config.*, jsconfig.*, karma*, lighthouserc.*, panda.config.*, playwright.config.*, postcss.config.*, puppeteer.config.*, rspack.config.*, sst.config.*, svgo.config.*, tailwind.config.*, tsconfig.*, tsdoc.*, uno.config.*, unocss.config.*, vitest.config.*, vuetify.config.*, webpack.config.*, windi.config.*",
  1550. "vitest.config.ts": "vitest*",
  1551. "*.asax": "$(capture).*.cs, $(capture).*.vb",
  1552. "*.ascx": "$(capture).*.cs, $(capture).*.vb",
  1553. "*.ashx": "$(capture).*.cs, $(capture).*.vb",
  1554. "*.aspx": "$(capture).*.cs, $(capture).*.vb",
  1555. "*.axaml": "$(capture).axaml.cs",
  1556. "*.bloc.dart": "$(capture).event.dart, $(capture).state.dart",
  1557. "*.c": "$(capture).h",
  1558. "*.cc": "$(capture).hpp, $(capture).h, $(capture).hxx, $(capture).hh",
  1559. "*.cjs": "$(capture).cjs.map, $(capture).*.cjs, $(capture)_*.cjs",
  1560. "*.component.ts": "$(capture).component.html, $(capture).component.spec.ts, $(capture).component.css, $(capture).component.scss, $(capture).component.sass, $(capture).component.less",
  1561. "*.cpp": "$(capture).hpp, $(capture).h, $(capture).hxx, $(capture).hh",
  1562. "*.cs": "$(capture).*.cs",
  1563. "*.cshtml": "$(capture).cshtml.cs",
  1564. "*.csproj": "*.config, *proj.user, appsettings.*, bundleconfig.json",
  1565. "*.css": "$(capture).css.map, $(capture).*.css",
  1566. "*.cxx": "$(capture).hpp, $(capture).h, $(capture).hxx, $(capture).hh",
  1567. "*.dart": "$(capture).freezed.dart, $(capture).g.dart",
  1568. "*.db": "*.db-shm, *.db-wal",
  1569. "*.ex": "$(capture).html.eex, $(capture).html.heex, $(capture).html.leex",
  1570. "*.fs": "$(capture).fs.js, $(capture).fs.js.map, $(capture).fs.jsx, $(capture).fs.ts, $(capture).fs.tsx, $(capture).fs.rs, $(capture).fs.php, $(capture).fs.dart",
  1571. "*.go": "$(capture)_test.go",
  1572. "*.java": "$(capture).class",
  1573. "*.js": "$(capture).js.map, $(capture).*.js, $(capture)_*.js, $(capture).d.ts, $(capture).js.flow",
  1574. "*.jsx": "$(capture).js, $(capture).*.jsx, $(capture)_*.js, $(capture)_*.jsx, $(capture).module.css, $(capture).less, $(capture).module.less, $(capture).module.less.d.ts, $(capture).scss, $(capture).module.scss, $(capture).module.scss.d.ts",
  1575. "*.master": "$(capture).*.cs, $(capture).*.vb",
  1576. "*.md": "$(capture).*",
  1577. "*.mjs": "$(capture).mjs.map, $(capture).*.mjs, $(capture)_*.mjs",
  1578. "*.module.ts": "$(capture).resolver.ts, $(capture).controller.ts, $(capture).service.ts",
  1579. "*.mts": "$(capture).mts.map, $(capture).*.mts, $(capture)_*.mts",
  1580. "*.pubxml": "$(capture).pubxml.user",
  1581. "*.py": "$(capture).pyi",
  1582. "*.razor": "$(capture).razor.cs, $(capture).razor.css, $(capture).razor.scss",
  1583. "*.resx": "$(capture).*.resx, $(capture).designer.cs, $(capture).designer.vb",
  1584. "*.tex": "$(capture).acn, $(capture).acr, $(capture).alg, $(capture).aux, $(capture).bbl, $(capture).bbl-SAVE-ERROR, $(capture).bcf, $(capture).blg, $(capture).fdb_latexmk, $(capture).fls, $(capture).glg, $(capture).glo, $(capture).gls, $(capture).idx, $(capture).ind, $(capture).ist, $(capture).lof, $(capture).log, $(capture).lot, $(capture).nav, $(capture).out, $(capture).run.xml, $(capture).snm, $(capture).synctex.gz, $(capture).toc, $(capture).xdv",
  1585. "*.ts": "$(capture).js, $(capture).d.ts.map, $(capture).*.ts, $(capture)_*.js, $(capture)_*.ts",
  1586. "*.tsx": "$(capture).ts, $(capture).*.tsx, $(capture)_*.ts, $(capture)_*.tsx, $(capture).module.css, $(capture).less, $(capture).module.less, $(capture).module.less.d.ts, $(capture).scss, $(capture).module.scss, $(capture).module.scss.d.ts, $(capture).css.ts",
  1587. "*.vbproj": "*.config, *proj.user, appsettings.*, bundleconfig.json",
  1588. "*.vue": "$(capture).*.ts, $(capture).*.js, $(capture).story.vue",
  1589. "*.w": "$(capture).*.w, I$(capture).w",
  1590. "*.wat": "$(capture).wasm",
  1591. "*.xaml": "$(capture).xaml.cs"
  1592. };
  1593. (() => {
  1594. function run() {
  1595. const rows = document.querySelectorAll('table[aria-labelledby="folders-and-files"] tbody tr.react-directory-row');
  1596. if (!rows.length) {
  1597. return;
  1598. }
  1599. const attrPrefix = "rgfn";
  1600. const ruleProperties = Object.keys(rules);
  1601. const rowsData = Array.from(rows).map((row) => {
  1602. var _a, _b;
  1603. const id = row.getAttribute("id") || "unknown";
  1604. const name = ((_a = row.querySelector("a")) == null ? void 0 : _a.textContent) || "unknown";
  1605. const fileType = ((_b = row.querySelector("svg")) == null ? void 0 : _b.getAttribute("class")) === "icon-directory" ? "folder" : "file";
  1606. return {
  1607. id,
  1608. name,
  1609. type: fileType,
  1610. appendTo: ""
  1611. };
  1612. });
  1613. const files = rowsData.filter((row) => row.type === "file");
  1614. files.forEach((row) => {
  1615. const { name } = row;
  1616. const findRule = ruleProperties.find((rule) => {
  1617. const matcher = pm(rule);
  1618. return matcher(name);
  1619. });
  1620. if (findRule) {
  1621. const ruleValues = rules[findRule].split(",").map((rule) => rule.trim());
  1622. const matchers = ruleValues.map((rule) => pm(rule));
  1623. files.forEach((file) => {
  1624. if (file.id !== row.id && matchers.some((matcher) => matcher(file.name))) {
  1625. file.appendTo = row.id;
  1626. }
  1627. });
  1628. }
  1629. });
  1630. files.forEach((row) => {
  1631. var _a, _b, _c, _d;
  1632. const { id, appendTo } = row;
  1633. const rowEl = document.querySelector(`#${id}`);
  1634. if (appendTo) {
  1635. const appendToEl = document.querySelector(`#${appendTo}`);
  1636. rowEl.style.display = "none";
  1637. (_a = rowEl == null ? void 0 : rowEl.querySelectorAll(".react-directory-filename-column")) == null ? void 0 : _a.forEach((el) => {
  1638. el.setAttribute("style", "position: relative; left: 32px;");
  1639. });
  1640. if (appendToEl && rowEl) {
  1641. appendToEl.after(rowEl);
  1642. }
  1643. } else {
  1644. const findAppendTo = files.filter((file) => file.appendTo === id);
  1645. if (findAppendTo.length > 0) {
  1646. rowEl.style.cursor = "pointer";
  1647. (_b = rowEl.querySelectorAll(".react-directory-filename-cell a")) == null ? void 0 : _b.forEach((el) => {
  1648. const content = el.textContent;
  1649. el.innerHTML = `${content} <span class="${attrPrefix}-file-counts">(+${findAppendTo.length})</span>`;
  1650. });
  1651. (_c = rowEl.querySelectorAll(".react-directory-filename-column")) == null ? void 0 : _c.forEach((el) => {
  1652. el.setAttribute(`data-${attrPrefix}-toggle`, "0");
  1653. });
  1654. (_d = document.querySelector(`#${id}`)) == null ? void 0 : _d.addEventListener("click", () => {
  1655. var _a2;
  1656. const toggleEls = (_a2 = document.querySelector(`#${id}`)) == null ? void 0 : _a2.querySelectorAll(`[data-${attrPrefix}-toggle]`);
  1657. toggleEls == null ? void 0 : toggleEls.forEach((el) => {
  1658. el.setAttribute(`data-${attrPrefix}-toggle`, el.getAttribute(`data-${attrPrefix}-toggle`) === "0" ? "1" : "0");
  1659. });
  1660. findAppendTo.forEach((file) => {
  1661. const el = document.querySelector(`#${file.id}`);
  1662. const currentStyle = el.style.display;
  1663. el.style.display = currentStyle === "none" ? "table-row" : "none";
  1664. });
  1665. });
  1666. }
  1667. }
  1668. });
  1669. }
  1670. function init() {
  1671. setTimeout(() => {
  1672. run();
  1673. }, 1e3);
  1674. }
  1675. init();
  1676. document.addEventListener("pjax:end", () => init());
  1677. document.addEventListener("turbo:render", () => init());
  1678. })();
  1679.  
  1680. })();