index.cjs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
  1. function $parcel$defineInteropFlag(a) {
  2. Object.defineProperty(a, '__esModule', {value: true, configurable: true});
  3. }
  4. function $parcel$exportWildcard(dest, source) {
  5. Object.keys(source).forEach(function(key) {
  6. if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) {
  7. return;
  8. }
  9. Object.defineProperty(dest, key, {
  10. enumerable: true,
  11. get: function get() {
  12. return source[key];
  13. }
  14. });
  15. });
  16. return dest;
  17. }
  18. function $parcel$export(e, n, v, s) {
  19. Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
  20. }
  21. $parcel$defineInteropFlag(module.exports);
  22. $parcel$export(module.exports, "parse", () => $882b6d93070905b3$export$98e6a39c04603d36);
  23. $parcel$export(module.exports, "stringify", () => $882b6d93070905b3$export$fac44ee5b035f737);
  24. $parcel$export(module.exports, "default", () => $882b6d93070905b3$export$2e2bcd8739ae039);
  25. var $cb508b9219b02820$exports = {};
  26. $parcel$defineInteropFlag($cb508b9219b02820$exports);
  27. $parcel$export($cb508b9219b02820$exports, "default", () => $cb508b9219b02820$export$2e2bcd8739ae039);
  28. class $cb508b9219b02820$export$2e2bcd8739ae039 extends Error {
  29. constructor(filename, msg, lineno, column, css){
  30. super(filename + ':' + lineno + ':' + column + ': ' + msg);
  31. this.reason = msg;
  32. this.filename = filename;
  33. this.line = lineno;
  34. this.column = column;
  35. this.source = css;
  36. }
  37. }
  38. var $4bafb28828007b46$exports = {};
  39. $parcel$defineInteropFlag($4bafb28828007b46$exports);
  40. $parcel$export($4bafb28828007b46$exports, "default", () => $4bafb28828007b46$export$2e2bcd8739ae039);
  41. /**
  42. * Store position information for a node
  43. */ class $4bafb28828007b46$export$2e2bcd8739ae039 {
  44. constructor(start, end, source){
  45. this.start = start;
  46. this.end = end;
  47. this.source = source;
  48. }
  49. }
  50. var $d103407e81c97042$exports = {};
  51. $parcel$export($d103407e81c97042$exports, "CssTypes", () => $d103407e81c97042$export$9be5dd6e61d5d73a);
  52. var $d103407e81c97042$export$9be5dd6e61d5d73a = /*#__PURE__*/ function(CssTypes) {
  53. CssTypes["stylesheet"] = "stylesheet";
  54. CssTypes["rule"] = "rule";
  55. CssTypes["declaration"] = "declaration";
  56. CssTypes["comment"] = "comment";
  57. CssTypes["container"] = "container";
  58. CssTypes["charset"] = "charset";
  59. CssTypes["document"] = "document";
  60. CssTypes["customMedia"] = "custom-media";
  61. CssTypes["fontFace"] = "font-face";
  62. CssTypes["host"] = "host";
  63. CssTypes["import"] = "import";
  64. CssTypes["keyframes"] = "keyframes";
  65. CssTypes["keyframe"] = "keyframe";
  66. CssTypes["layer"] = "layer";
  67. CssTypes["media"] = "media";
  68. CssTypes["namespace"] = "namespace";
  69. CssTypes["page"] = "page";
  70. CssTypes["startingStyle"] = "starting-style";
  71. CssTypes["supports"] = "supports";
  72. return CssTypes;
  73. }({});
  74. // http://www.w3.org/TR/CSS21/grammar.html
  75. // https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
  76. // New rule => https://www.w3.org/TR/CSS22/syndata.html#comments
  77. // [^] is equivalent to [.\n\r]
  78. const $b499486c7f02abe7$var$commentre = /\/\*[^]*?(?:\*\/|$)/g;
  79. const $b499486c7f02abe7$export$98e6a39c04603d36 = (css, options)=>{
  80. options = options || {};
  81. /**
  82. * Positional.
  83. */ let lineno = 1;
  84. let column = 1;
  85. /**
  86. * Update lineno and column based on `str`.
  87. */ function updatePosition(str) {
  88. const lines = str.match(/\n/g);
  89. if (lines) lineno += lines.length;
  90. const i = str.lastIndexOf('\n');
  91. column = ~i ? str.length - i : column + str.length;
  92. }
  93. /**
  94. * Mark position and patch `node.position`.
  95. */ function position() {
  96. const start = {
  97. line: lineno,
  98. column: column
  99. };
  100. return function(node) {
  101. node.position = new (0, $4bafb28828007b46$export$2e2bcd8739ae039)(start, {
  102. line: lineno,
  103. column: column
  104. }, options?.source || '');
  105. whitespace();
  106. return node;
  107. };
  108. }
  109. /**
  110. * Error `msg`.
  111. */ const errorsList = [];
  112. function error(msg) {
  113. const err = new (0, $cb508b9219b02820$export$2e2bcd8739ae039)(options?.source || '', msg, lineno, column, css);
  114. if (options?.silent) errorsList.push(err);
  115. else throw err;
  116. }
  117. /**
  118. * Parse stylesheet.
  119. */ function stylesheet() {
  120. const rulesList = rules();
  121. const result = {
  122. type: (0, $d103407e81c97042$export$9be5dd6e61d5d73a).stylesheet,
  123. stylesheet: {
  124. source: options?.source,
  125. rules: rulesList,
  126. parsingErrors: errorsList
  127. }
  128. };
  129. return result;
  130. }
  131. /**
  132. * Opening brace.
  133. */ function open() {
  134. return match(/^{\s*/);
  135. }
  136. /**
  137. * Closing brace.
  138. */ function close() {
  139. return match(/^}/);
  140. }
  141. /**
  142. * Parse ruleset.
  143. */ function rules() {
  144. let node;
  145. const rules = [];
  146. whitespace();
  147. comments(rules);
  148. while(css.length && css.charAt(0) !== '}' && (node = atrule() || rule()))if (node) {
  149. rules.push(node);
  150. comments(rules);
  151. }
  152. return rules;
  153. }
  154. /**
  155. * Match `re` and return captures.
  156. */ function match(re) {
  157. const m = re.exec(css);
  158. if (!m) return;
  159. const str = m[0];
  160. updatePosition(str);
  161. css = css.slice(str.length);
  162. return m;
  163. }
  164. /**
  165. * Parse whitespace.
  166. */ function whitespace() {
  167. match(/^\s*/);
  168. }
  169. /**
  170. * Parse comments;
  171. */ function comments(rules) {
  172. let c;
  173. rules = rules || [];
  174. while(c = comment())if (c) rules.push(c);
  175. return rules;
  176. }
  177. /**
  178. * Parse comment.
  179. */ function comment() {
  180. const pos = position();
  181. if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) return;
  182. const m = match(/^\/\*[^]*?\*\//);
  183. if (!m) return error('End of comment missing');
  184. return pos({
  185. type: (0, $d103407e81c97042$export$9be5dd6e61d5d73a).comment,
  186. comment: m[0].slice(2, -2)
  187. });
  188. }
  189. function findClosingParenthese(str, start, depth) {
  190. let ptr = start + 1;
  191. let found = false;
  192. let closeParentheses = str.indexOf(')', ptr);
  193. while(!found && closeParentheses !== -1){
  194. const nextParentheses = str.indexOf('(', ptr);
  195. if (nextParentheses !== -1 && nextParentheses < closeParentheses) {
  196. const nextSearch = findClosingParenthese(str, nextParentheses + 1, depth + 1);
  197. ptr = nextSearch + 1;
  198. closeParentheses = str.indexOf(')', ptr);
  199. } else found = true;
  200. }
  201. if (found && closeParentheses !== -1) return closeParentheses;
  202. else return -1;
  203. }
  204. /**
  205. * Parse selector.
  206. */ function selector() {
  207. const m = match(/^([^{]+)/);
  208. if (!m) return;
  209. // remove comment in selector;
  210. let res = $b499486c7f02abe7$var$trim(m[0]).replace($b499486c7f02abe7$var$commentre, '');
  211. // Optimisation: If there is no ',' no need to split or post-process (this is less costly)
  212. if (res.indexOf(',') === -1) return [
  213. res
  214. ];
  215. // Replace all the , in the parentheses by \u200C
  216. let ptr = 0;
  217. let startParentheses = res.indexOf('(', ptr);
  218. while(startParentheses !== -1){
  219. const closeParentheses = findClosingParenthese(res, startParentheses, 0);
  220. if (closeParentheses === -1) break;
  221. ptr = closeParentheses + 1;
  222. res = res.substring(0, startParentheses) + res.substring(startParentheses, closeParentheses).replace(/,/g, '\u200C') + res.substring(closeParentheses);
  223. startParentheses = res.indexOf('(', ptr);
  224. }
  225. // Replace all the , in ' and " by \u200C
  226. res = res/**
  227. * replace ',' by \u200C for data selector (div[data-lang="fr,de,us"])
  228. *
  229. * Examples:
  230. * div[data-lang="fr,\"de,us"]
  231. * div[data-lang='fr,\'de,us']
  232. *
  233. * Regex logic:
  234. * ("|')(?:\\\1|.)*?\1 => Handle the " and '
  235. *
  236. * Optimization 1:
  237. * No greedy capture (see docs about the difference between .* and .*?)
  238. *
  239. * Optimization 2:
  240. * ("|')(?:\\\1|.)*?\1 this use reference to capture group, it work faster.
  241. */ .replace(/("|')(?:\\\1|.)*?\1/g, (m)=>m.replace(/,/g, '\u200C'));
  242. // Split all the left , and replace all the \u200C by ,
  243. return res// Split the selector by ','
  244. .split(',')// Replace back \u200C by ','
  245. .map((s)=>{
  246. return $b499486c7f02abe7$var$trim(s.replace(/\u200C/g, ','));
  247. });
  248. }
  249. /**
  250. * Parse declaration.
  251. */ function declaration() {
  252. const pos = position();
  253. // prop
  254. const propMatch = match(/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
  255. if (!propMatch) return;
  256. const propValue = $b499486c7f02abe7$var$trim(propMatch[0]);
  257. // :
  258. if (!match(/^:\s*/)) return error("property missing ':'");
  259. // val
  260. const val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|[^)])*?\)|[^};])+)/);
  261. const ret = pos({
  262. type: (0, $d103407e81c97042$export$9be5dd6e61d5d73a).declaration,
  263. property: propValue.replace($b499486c7f02abe7$var$commentre, ''),
  264. value: val ? $b499486c7f02abe7$var$trim(val[0]).replace($b499486c7f02abe7$var$commentre, '') : ''
  265. });
  266. // ;
  267. match(/^[;\s]*/);
  268. return ret;
  269. }
  270. /**
  271. * Parse declarations.
  272. */ function declarations() {
  273. const decls = [];
  274. if (!open()) return error("missing '{'");
  275. comments(decls);
  276. // declarations
  277. let decl;
  278. while(decl = declaration())if (decl) {
  279. decls.push(decl);
  280. comments(decls);
  281. }
  282. if (!close()) return error("missing '}'");
  283. return decls;
  284. }
  285. /**
  286. * Parse keyframe.
  287. */ function keyframe() {
  288. let m;
  289. const vals = [];
  290. const pos = position();
  291. while(m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/)){
  292. vals.push(m[1]);
  293. match(/^,\s*/);
  294. }
  295. if (!vals.length) return;
  296. return pos({
  297. type: (0, $d103407e81c97042$export$9be5dd6e61d5d73a).keyframe,
  298. values: vals,
  299. declarations: declarations() || []
  300. });
  301. }
  302. /**
  303. * Parse keyframes.
  304. */ function atkeyframes() {
  305. const pos = position();
  306. const m1 = match(/^@([-\w]+)?keyframes\s*/);
  307. if (!m1) return;
  308. const vendor = m1[1];
  309. // identifier
  310. const m2 = match(/^([-\w]+)\s*/);
  311. if (!m2) return error('@keyframes missing name');
  312. const name = m2[1];
  313. if (!open()) return error("@keyframes missing '{'");
  314. let frame;
  315. let frames = comments();
  316. while(frame = keyframe()){
  317. frames.push(frame);
  318. frames = frames.concat(comments());
  319. }
  320. if (!close()) return error("@keyframes missing '}'");
  321. return pos({
  322. type: (0, $d103407e81c97042$export$9be5dd6e61d5d73a).keyframes,
  323. name: name,
  324. vendor: vendor,
  325. keyframes: frames
  326. });
  327. }
  328. /**
  329. * Parse supports.
  330. */ function atsupports() {
  331. const pos = position();
  332. const m = match(/^@supports *([^{]+)/);
  333. if (!m) return;
  334. const supports = $b499486c7f02abe7$var$trim(m[1]);
  335. if (!open()) return error("@supports missing '{'");
  336. const style = comments().concat(rules());
  337. if (!close()) return error("@supports missing '}'");
  338. return pos({
  339. type: (0, $d103407e81c97042$export$9be5dd6e61d5d73a).supports,
  340. supports: supports,
  341. rules: style
  342. });
  343. }
  344. /**
  345. * Parse host.
  346. */ function athost() {
  347. const pos = position();
  348. const m = match(/^@host\s*/);
  349. if (!m) return;
  350. if (!open()) return error("@host missing '{'");
  351. const style = comments().concat(rules());
  352. if (!close()) return error("@host missing '}'");
  353. return pos({
  354. type: (0, $d103407e81c97042$export$9be5dd6e61d5d73a).host,
  355. rules: style
  356. });
  357. }
  358. /**
  359. * Parse container.
  360. */ function atcontainer() {
  361. const pos = position();
  362. const m = match(/^@container *([^{]+)/);
  363. if (!m) return;
  364. const container = $b499486c7f02abe7$var$trim(m[1]);
  365. if (!open()) return error("@container missing '{'");
  366. const style = comments().concat(rules());
  367. if (!close()) return error("@container missing '}'");
  368. return pos({
  369. type: (0, $d103407e81c97042$export$9be5dd6e61d5d73a).container,
  370. container: container,
  371. rules: style
  372. });
  373. }
  374. /**
  375. * Parse container.
  376. */ function atlayer() {
  377. const pos = position();
  378. const m = match(/^@layer *([^{;@]+)/);
  379. if (!m) return;
  380. const layer = $b499486c7f02abe7$var$trim(m[1]);
  381. if (!open()) {
  382. match(/^[;\s]*/);
  383. return pos({
  384. type: (0, $d103407e81c97042$export$9be5dd6e61d5d73a).layer,
  385. layer: layer
  386. });
  387. }
  388. const style = comments().concat(rules());
  389. if (!close()) return error("@layer missing '}'");
  390. return pos({
  391. type: (0, $d103407e81c97042$export$9be5dd6e61d5d73a).layer,
  392. layer: layer,
  393. rules: style
  394. });
  395. }
  396. /**
  397. * Parse media.
  398. */ function atmedia() {
  399. const pos = position();
  400. const m = match(/^@media *([^{]+)/);
  401. if (!m) return;
  402. const media = $b499486c7f02abe7$var$trim(m[1]);
  403. if (!open()) return error("@media missing '{'");
  404. const style = comments().concat(rules());
  405. if (!close()) return error("@media missing '}'");
  406. return pos({
  407. type: (0, $d103407e81c97042$export$9be5dd6e61d5d73a).media,
  408. media: media,
  409. rules: style
  410. });
  411. }
  412. /**
  413. * Parse custom-media.
  414. */ function atcustommedia() {
  415. const pos = position();
  416. const m = match(/^@custom-media\s+(--\S+)\s*([^{;\s][^{;]*);/);
  417. if (!m) return;
  418. return pos({
  419. type: (0, $d103407e81c97042$export$9be5dd6e61d5d73a).customMedia,
  420. name: $b499486c7f02abe7$var$trim(m[1]),
  421. media: $b499486c7f02abe7$var$trim(m[2])
  422. });
  423. }
  424. /**
  425. * Parse paged media.
  426. */ function atpage() {
  427. const pos = position();
  428. const m = match(/^@page */);
  429. if (!m) return;
  430. const sel = selector() || [];
  431. if (!open()) return error("@page missing '{'");
  432. let decls = comments();
  433. // declarations
  434. let decl;
  435. while(decl = declaration()){
  436. decls.push(decl);
  437. decls = decls.concat(comments());
  438. }
  439. if (!close()) return error("@page missing '}'");
  440. return pos({
  441. type: (0, $d103407e81c97042$export$9be5dd6e61d5d73a).page,
  442. selectors: sel,
  443. declarations: decls
  444. });
  445. }
  446. /**
  447. * Parse document.
  448. */ function atdocument() {
  449. const pos = position();
  450. const m = match(/^@([-\w]+)?document *([^{]+)/);
  451. if (!m) return;
  452. const vendor = $b499486c7f02abe7$var$trim(m[1]);
  453. const doc = $b499486c7f02abe7$var$trim(m[2]);
  454. if (!open()) return error("@document missing '{'");
  455. const style = comments().concat(rules());
  456. if (!close()) return error("@document missing '}'");
  457. return pos({
  458. type: (0, $d103407e81c97042$export$9be5dd6e61d5d73a).document,
  459. document: doc,
  460. vendor: vendor,
  461. rules: style
  462. });
  463. }
  464. /**
  465. * Parse font-face.
  466. */ function atfontface() {
  467. const pos = position();
  468. const m = match(/^@font-face\s*/);
  469. if (!m) return;
  470. if (!open()) return error("@font-face missing '{'");
  471. let decls = comments();
  472. // declarations
  473. let decl;
  474. while(decl = declaration()){
  475. decls.push(decl);
  476. decls = decls.concat(comments());
  477. }
  478. if (!close()) return error("@font-face missing '}'");
  479. return pos({
  480. type: (0, $d103407e81c97042$export$9be5dd6e61d5d73a).fontFace,
  481. declarations: decls
  482. });
  483. }
  484. /**
  485. * Parse starting style.
  486. */ function atstartingstyle() {
  487. const pos = position();
  488. const m = match(/^@starting-style\s*/);
  489. if (!m) return;
  490. if (!open()) return error("@starting-style missing '{'");
  491. const style = comments().concat(rules());
  492. if (!close()) return error("@starting-style missing '}'");
  493. return pos({
  494. type: (0, $d103407e81c97042$export$9be5dd6e61d5d73a).startingStyle,
  495. rules: style
  496. });
  497. }
  498. /**
  499. * Parse import
  500. */ const atimport = _compileAtrule('import');
  501. /**
  502. * Parse charset
  503. */ const atcharset = _compileAtrule('charset');
  504. /**
  505. * Parse namespace
  506. */ const atnamespace = _compileAtrule('namespace');
  507. /**
  508. * Parse non-block at-rules
  509. */ function _compileAtrule(name) {
  510. const re = new RegExp('^@' + name + '\\s*((?::?[^;\'"]|"(?:\\\\"|[^"])*?"|\'(?:\\\\\'|[^\'])*?\')+)(?:;|$)');
  511. // ^@import\s*([^;"']|("|')(?:\\\2|.)*?\2)+(;|$)
  512. return function() {
  513. const pos = position();
  514. const m = match(re);
  515. if (!m) return;
  516. const ret = {
  517. type: name
  518. };
  519. ret[name] = m[1].trim();
  520. return pos(ret);
  521. };
  522. }
  523. /**
  524. * Parse at rule.
  525. */ function atrule() {
  526. if (css[0] !== '@') return;
  527. return atkeyframes() || atmedia() || atcustommedia() || atsupports() || atimport() || atcharset() || atnamespace() || atdocument() || atpage() || athost() || atfontface() || atcontainer() || atstartingstyle() || atlayer();
  528. }
  529. /**
  530. * Parse rule.
  531. */ function rule() {
  532. const pos = position();
  533. const sel = selector();
  534. if (!sel) return error('selector missing');
  535. comments();
  536. return pos({
  537. type: (0, $d103407e81c97042$export$9be5dd6e61d5d73a).rule,
  538. selectors: sel,
  539. declarations: declarations() || []
  540. });
  541. }
  542. return $b499486c7f02abe7$var$addParent(stylesheet());
  543. };
  544. /**
  545. * Trim `str`.
  546. */ function $b499486c7f02abe7$var$trim(str) {
  547. return str ? str.trim() : '';
  548. }
  549. /**
  550. * Adds non-enumerable parent node reference to each node.
  551. */ function $b499486c7f02abe7$var$addParent(obj, parent) {
  552. const isNode = obj && typeof obj.type === 'string';
  553. const childParent = isNode ? obj : parent;
  554. for(const k in obj){
  555. const value = obj[k];
  556. if (Array.isArray(value)) value.forEach((v)=>{
  557. $b499486c7f02abe7$var$addParent(v, childParent);
  558. });
  559. else if (value && typeof value === 'object') $b499486c7f02abe7$var$addParent(value, childParent);
  560. }
  561. if (isNode) Object.defineProperty(obj, 'parent', {
  562. configurable: true,
  563. writable: true,
  564. enumerable: false,
  565. value: parent || null
  566. });
  567. return obj;
  568. }
  569. var $b499486c7f02abe7$export$2e2bcd8739ae039 = $b499486c7f02abe7$export$98e6a39c04603d36;
  570. class $24dc7e49cb76910e$var$Compiler {
  571. constructor(options){
  572. this.level = 0;
  573. this.indentation = ' ';
  574. this.compress = false;
  575. if (typeof options?.indent === 'string') this.indentation = options?.indent;
  576. if (options?.compress) this.compress = true;
  577. }
  578. // We disable no-unused-vars for _position. We keep position for potential reintroduction of source-map
  579. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  580. emit(str, _position) {
  581. return str;
  582. }
  583. /**
  584. * Increase, decrease or return current indentation.
  585. */ indent(level) {
  586. this.level = this.level || 1;
  587. if (level) {
  588. this.level += level;
  589. return '';
  590. }
  591. return Array(this.level).join(this.indentation);
  592. }
  593. visit(node) {
  594. switch(node.type){
  595. case (0, $d103407e81c97042$export$9be5dd6e61d5d73a).stylesheet:
  596. return this.stylesheet(node);
  597. case (0, $d103407e81c97042$export$9be5dd6e61d5d73a).rule:
  598. return this.rule(node);
  599. case (0, $d103407e81c97042$export$9be5dd6e61d5d73a).declaration:
  600. return this.declaration(node);
  601. case (0, $d103407e81c97042$export$9be5dd6e61d5d73a).comment:
  602. return this.comment(node);
  603. case (0, $d103407e81c97042$export$9be5dd6e61d5d73a).container:
  604. return this.container(node);
  605. case (0, $d103407e81c97042$export$9be5dd6e61d5d73a).charset:
  606. return this.charset(node);
  607. case (0, $d103407e81c97042$export$9be5dd6e61d5d73a).document:
  608. return this.document(node);
  609. case (0, $d103407e81c97042$export$9be5dd6e61d5d73a).customMedia:
  610. return this.customMedia(node);
  611. case (0, $d103407e81c97042$export$9be5dd6e61d5d73a).fontFace:
  612. return this.fontFace(node);
  613. case (0, $d103407e81c97042$export$9be5dd6e61d5d73a).host:
  614. return this.host(node);
  615. case (0, $d103407e81c97042$export$9be5dd6e61d5d73a).import:
  616. return this.import(node);
  617. case (0, $d103407e81c97042$export$9be5dd6e61d5d73a).keyframes:
  618. return this.keyframes(node);
  619. case (0, $d103407e81c97042$export$9be5dd6e61d5d73a).keyframe:
  620. return this.keyframe(node);
  621. case (0, $d103407e81c97042$export$9be5dd6e61d5d73a).layer:
  622. return this.layer(node);
  623. case (0, $d103407e81c97042$export$9be5dd6e61d5d73a).media:
  624. return this.media(node);
  625. case (0, $d103407e81c97042$export$9be5dd6e61d5d73a).namespace:
  626. return this.namespace(node);
  627. case (0, $d103407e81c97042$export$9be5dd6e61d5d73a).page:
  628. return this.page(node);
  629. case (0, $d103407e81c97042$export$9be5dd6e61d5d73a).startingStyle:
  630. return this.startingStyle(node);
  631. case (0, $d103407e81c97042$export$9be5dd6e61d5d73a).supports:
  632. return this.supports(node);
  633. }
  634. }
  635. mapVisit(nodes, delim) {
  636. let buf = '';
  637. delim = delim || '';
  638. for(let i = 0, length = nodes.length; i < length; i++){
  639. buf += this.visit(nodes[i]);
  640. if (delim && i < length - 1) buf += this.emit(delim);
  641. }
  642. return buf;
  643. }
  644. compile(node) {
  645. if (this.compress) return node.stylesheet.rules.map(this.visit, this).join('');
  646. return this.stylesheet(node);
  647. }
  648. /**
  649. * Visit stylesheet node.
  650. */ stylesheet(node) {
  651. return this.mapVisit(node.stylesheet.rules, '\n\n');
  652. }
  653. /**
  654. * Visit comment node.
  655. */ comment(node) {
  656. if (this.compress) return this.emit('', node.position);
  657. return this.emit(this.indent() + '/*' + node.comment + '*/', node.position);
  658. }
  659. /**
  660. * Visit container node.
  661. */ container(node) {
  662. if (this.compress) return this.emit('@container ' + node.container, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
  663. return this.emit(this.indent() + '@container ' + node.container, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit('\n' + this.indent(-1) + this.indent() + '}');
  664. }
  665. /**
  666. * Visit container node.
  667. */ layer(node) {
  668. if (this.compress) return this.emit('@layer ' + node.layer, node.position) + (node.rules ? this.emit('{') + this.mapVisit(node.rules) + this.emit('}') : ';');
  669. return this.emit(this.indent() + '@layer ' + node.layer, node.position) + (node.rules ? this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit('\n' + this.indent(-1) + this.indent() + '}') : ';');
  670. }
  671. /**
  672. * Visit import node.
  673. */ import(node) {
  674. return this.emit('@import ' + node.import + ';', node.position);
  675. }
  676. /**
  677. * Visit media node.
  678. */ media(node) {
  679. if (this.compress) return this.emit('@media ' + node.media, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
  680. return this.emit(this.indent() + '@media ' + node.media, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit('\n' + this.indent(-1) + this.indent() + '}');
  681. }
  682. /**
  683. * Visit document node.
  684. */ document(node) {
  685. const doc = '@' + (node.vendor || '') + 'document ' + node.document;
  686. if (this.compress) return this.emit(doc, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
  687. return this.emit(doc, node.position) + this.emit(" {\n" + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}');
  688. }
  689. /**
  690. * Visit charset node.
  691. */ charset(node) {
  692. return this.emit('@charset ' + node.charset + ';', node.position);
  693. }
  694. /**
  695. * Visit namespace node.
  696. */ namespace(node) {
  697. return this.emit('@namespace ' + node.namespace + ';', node.position);
  698. }
  699. /**
  700. * Visit container node.
  701. */ startingStyle(node) {
  702. if (this.compress) return this.emit('@starting-style', node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
  703. return this.emit(this.indent() + '@starting-style', node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit('\n' + this.indent(-1) + this.indent() + '}');
  704. }
  705. /**
  706. * Visit supports node.
  707. */ supports(node) {
  708. if (this.compress) return this.emit('@supports ' + node.supports, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
  709. return this.emit(this.indent() + '@supports ' + node.supports, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit('\n' + this.indent(-1) + this.indent() + '}');
  710. }
  711. /**
  712. * Visit keyframes node.
  713. */ keyframes(node) {
  714. if (this.compress) return this.emit('@' + (node.vendor || '') + 'keyframes ' + node.name, node.position) + this.emit('{') + this.mapVisit(node.keyframes) + this.emit('}');
  715. return this.emit('@' + (node.vendor || '') + 'keyframes ' + node.name, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.keyframes, '\n') + this.emit(this.indent(-1) + '}');
  716. }
  717. /**
  718. * Visit keyframe node.
  719. */ keyframe(node) {
  720. const decls = node.declarations;
  721. if (this.compress) return this.emit(node.values.join(','), node.position) + this.emit('{') + this.mapVisit(decls) + this.emit('}');
  722. return this.emit(this.indent()) + this.emit(node.values.join(', '), node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(decls, '\n') + this.emit(this.indent(-1) + '\n' + this.indent() + '}\n');
  723. }
  724. /**
  725. * Visit page node.
  726. */ page(node) {
  727. if (this.compress) {
  728. const sel = node.selectors.length ? node.selectors.join(', ') : '';
  729. return this.emit('@page ' + sel, node.position) + this.emit('{') + this.mapVisit(node.declarations) + this.emit('}');
  730. }
  731. const sel = node.selectors.length ? node.selectors.join(', ') + ' ' : '';
  732. return this.emit('@page ' + sel, node.position) + this.emit('{\n') + this.emit(this.indent(1)) + this.mapVisit(node.declarations, '\n') + this.emit(this.indent(-1)) + this.emit('\n}');
  733. }
  734. /**
  735. * Visit font-face node.
  736. */ fontFace(node) {
  737. if (this.compress) return this.emit('@font-face', node.position) + this.emit('{') + this.mapVisit(node.declarations) + this.emit('}');
  738. return this.emit('@font-face ', node.position) + this.emit('{\n') + this.emit(this.indent(1)) + this.mapVisit(node.declarations, '\n') + this.emit(this.indent(-1)) + this.emit('\n}');
  739. }
  740. /**
  741. * Visit host node.
  742. */ host(node) {
  743. if (this.compress) return this.emit('@host', node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
  744. return this.emit('@host', node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}');
  745. }
  746. /**
  747. * Visit custom-media node.
  748. */ customMedia(node) {
  749. return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position);
  750. }
  751. /**
  752. * Visit rule node.
  753. */ rule(node) {
  754. const decls = node.declarations;
  755. if (!decls.length) return '';
  756. if (this.compress) return this.emit(node.selectors.join(','), node.position) + this.emit('{') + this.mapVisit(decls) + this.emit('}');
  757. const indent = this.indent();
  758. return this.emit(node.selectors.map((s)=>{
  759. return indent + s;
  760. }).join(',\n'), node.position) + this.emit(' {\n') + this.emit(this.indent(1)) + this.mapVisit(decls, '\n') + this.emit(this.indent(-1)) + this.emit('\n' + this.indent() + '}');
  761. }
  762. /**
  763. * Visit declaration node.
  764. */ declaration(node) {
  765. if (this.compress) return this.emit(node.property + ':' + node.value, node.position) + this.emit(';');
  766. return this.emit(this.indent()) + this.emit(node.property + ': ' + node.value, node.position) + this.emit(';');
  767. }
  768. }
  769. var $24dc7e49cb76910e$export$2e2bcd8739ae039 = $24dc7e49cb76910e$var$Compiler;
  770. var $fd680ce0c35731f5$export$2e2bcd8739ae039 = (node, options)=>{
  771. const compiler = new (0, $24dc7e49cb76910e$export$2e2bcd8739ae039)(options || {});
  772. return compiler.compile(node);
  773. };
  774. const $882b6d93070905b3$export$98e6a39c04603d36 = (0, $b499486c7f02abe7$export$2e2bcd8739ae039);
  775. const $882b6d93070905b3$export$fac44ee5b035f737 = (0, $fd680ce0c35731f5$export$2e2bcd8739ae039);
  776. var $882b6d93070905b3$export$2e2bcd8739ae039 = {
  777. parse: $882b6d93070905b3$export$98e6a39c04603d36,
  778. stringify: $882b6d93070905b3$export$fac44ee5b035f737
  779. };
  780. $parcel$exportWildcard(module.exports, $d103407e81c97042$exports);
  781. $parcel$exportWildcard(module.exports, $cb508b9219b02820$exports);
  782. $parcel$exportWildcard(module.exports, $4bafb28828007b46$exports);
  783. //# sourceMappingURL=index.cjs.map