版博士V2.0程序
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082
  1. /*! *****************************************************************************
  2. Copyright (c) Microsoft Corporation.
  3. Permission to use, copy, modify, and/or distribute this software for any
  4. purpose with or without fee is hereby granted.
  5. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  6. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  7. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  8. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  9. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  10. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  11. PERFORMANCE OF THIS SOFTWARE.
  12. ***************************************************************************** */
  13. /* global Reflect, Promise */
  14. var extendStatics = function(d, b) {
  15. extendStatics = Object.setPrototypeOf ||
  16. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  17. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  18. return extendStatics(d, b);
  19. };
  20. function __extends(d, b) {
  21. if (typeof b !== "function" && b !== null)
  22. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  23. extendStatics(d, b);
  24. function __() { this.constructor = d; }
  25. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26. }
  27. function __spreadArray(to, from, pack) {
  28. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  29. if (ar || !(i in from)) {
  30. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  31. ar[i] = from[i];
  32. }
  33. }
  34. return to.concat(ar || Array.prototype.slice.call(from));
  35. }
  36. function toArray(v) {
  37. if (Array.isArray(v))
  38. return v;
  39. return [v];
  40. }
  41. function hash(str) {
  42. str = str.replace(/\r/g, '');
  43. var hash = 5381;
  44. var i = str.length;
  45. while (i--)
  46. hash = ((hash << 5) - hash) ^ str.charCodeAt(i);
  47. return (hash >>> 0).toString(36);
  48. }
  49. function indent(code, tab) {
  50. if (tab === void 0) { tab = 2; }
  51. var spaces = Array(tab).fill(' ').join('');
  52. return code
  53. .split('\n')
  54. .map(function (line) { return spaces + line; })
  55. .join('\n');
  56. }
  57. function wrapit(code, start, end, tab, minify) {
  58. if (start === void 0) { start = '{'; }
  59. if (end === void 0) { end = '}'; }
  60. if (tab === void 0) { tab = 2; }
  61. if (minify === void 0) { minify = false; }
  62. if (minify)
  63. return "".concat(start).concat(code).concat(end);
  64. return "".concat(start, "\n").concat(indent(code, tab), "\n").concat(end);
  65. }
  66. function camelToDash(str) {
  67. // Use exact the same regex as Post CSS
  68. return str.replace(/([A-Z])/g, '-$1').replace(/^ms-/, '-ms-').toLowerCase();
  69. }
  70. function searchFrom(text, target, startIndex, endIndex) {
  71. if (startIndex === void 0) { startIndex = 0; }
  72. // search from partial of string
  73. var subText = text.substring(startIndex, endIndex);
  74. var relativeIndex = subText.search(target);
  75. return relativeIndex === -1 ? -1 : startIndex + relativeIndex;
  76. }
  77. function connectList(a, b, append) {
  78. if (append === void 0) { append = true; }
  79. return append ? __spreadArray(__spreadArray([], (a !== null && a !== void 0 ? a : []), true), (b !== null && b !== void 0 ? b : []), true) : __spreadArray(__spreadArray([], (b !== null && b !== void 0 ? b : []), true), (a !== null && a !== void 0 ? a : []), true);
  80. }
  81. function deepCopy(source) {
  82. return Array.isArray(source)
  83. ? source.map(function (item) { return deepCopy(item); })
  84. : source instanceof Date
  85. ? new Date(source.getTime())
  86. : source && typeof source === 'object'
  87. ? Object.getOwnPropertyNames(source).reduce(function (o, prop) {
  88. var descriptor = Object.getOwnPropertyDescriptor(source, prop);
  89. if (descriptor) {
  90. Object.defineProperty(o, prop, descriptor);
  91. if (source && typeof source === 'object') {
  92. o[prop] = deepCopy(source[prop]);
  93. }
  94. }
  95. return o;
  96. }, Object.create(Object.getPrototypeOf(source)))
  97. : source;
  98. }
  99. function isTagName(name) {
  100. return ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embd', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'svg', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr'].includes(name);
  101. }
  102. function searchPropEnd(text, startIndex) {
  103. if (startIndex === void 0) { startIndex = 0; }
  104. var index = startIndex;
  105. var output = -1;
  106. var openSingleQuote = false;
  107. var openDoubleQuote = false;
  108. var openBracket = false;
  109. var isEscaped = false;
  110. while (index < text.length) {
  111. switch (text.charAt(index)) {
  112. case '\\':
  113. isEscaped = !isEscaped;
  114. break;
  115. case '\'':
  116. if (!openDoubleQuote && !openBracket && !isEscaped)
  117. openSingleQuote = !openSingleQuote;
  118. isEscaped = false;
  119. break;
  120. case '"':
  121. if (!openSingleQuote && !openBracket && !isEscaped)
  122. openDoubleQuote = !openDoubleQuote;
  123. isEscaped = false;
  124. break;
  125. case '(':
  126. if (!openBracket && !openSingleQuote && !openDoubleQuote && !isEscaped)
  127. openBracket = true;
  128. isEscaped = false;
  129. break;
  130. case ')':
  131. if (openBracket && !isEscaped)
  132. openBracket = false;
  133. isEscaped = false;
  134. break;
  135. case ';':
  136. if (!isEscaped && !openSingleQuote && !openDoubleQuote && !openBracket)
  137. output = index;
  138. isEscaped = false;
  139. break;
  140. default:
  141. isEscaped = false;
  142. break;
  143. }
  144. if (output !== -1)
  145. break;
  146. index++;
  147. }
  148. return output;
  149. }
  150. var Property = /** @class */ (function () {
  151. function Property(name, value, comment, important) {
  152. if (important === void 0) { important = false; }
  153. this.meta = { type: 'utilities', group: 'plugin', order: 0, offset: 0, corePlugin: false };
  154. this.name = name;
  155. this.value = value;
  156. this.comment = comment;
  157. this.important = important;
  158. }
  159. Property._singleParse = function (css) {
  160. css = css.trim();
  161. if (!css)
  162. return;
  163. if (css.charAt(0) === '@')
  164. return InlineAtRule.parse(css);
  165. var split = css.search(':');
  166. var end = searchPropEnd(css);
  167. if (split === -1)
  168. return;
  169. var important = false;
  170. var prop = css.substring(split + 1, end === -1 ? undefined : end).trim();
  171. if (/!important;?$/.test(prop)) {
  172. important = true;
  173. prop = prop.replace(/!important/, '').trimRight();
  174. }
  175. return new Property(css.substring(0, split).trim(), prop, undefined, important);
  176. };
  177. Property.parse = function (css) {
  178. if (!/;\s*$/.test(css))
  179. css += ';'; // Fix for the situation where the last semicolon is omitted
  180. var properties = [];
  181. var index = 0;
  182. var end = searchPropEnd(css, index);
  183. while (end !== -1) {
  184. var parsed = this._singleParse(css.substring(searchFrom(css, /\S/, index), end + 1));
  185. if (parsed)
  186. properties.push(parsed);
  187. index = end + 1;
  188. end = searchPropEnd(css, index);
  189. }
  190. var count = properties.length;
  191. if (count > 1)
  192. return properties;
  193. if (count === 1)
  194. return properties[0];
  195. };
  196. Property.prototype.clone = function () {
  197. return deepCopy(this);
  198. };
  199. Property.prototype.toStyle = function (selector) {
  200. var style = new Style(selector, this, this.important);
  201. style.meta = this.meta;
  202. return style;
  203. };
  204. Property.prototype.build = function (minify) {
  205. var _this = this;
  206. if (minify === void 0) { minify = false; }
  207. var createProperty = function (name, value) {
  208. if (minify) {
  209. return "".concat(name, ":").concat(value).concat(_this.important ? '!important' : '', ";");
  210. }
  211. else {
  212. var p = "".concat(name, ": ").concat(value).concat(_this.important ? ' !important' : '', ";");
  213. return _this.comment ? p + " /* ".concat(_this.comment, " */") : p;
  214. }
  215. };
  216. if (!this.value)
  217. return '';
  218. return typeof this.name === 'string'
  219. ? createProperty(this.name, this.value)
  220. : this.name
  221. .map(function (i) { return createProperty(i, _this.value); })
  222. .join(minify ? '' : '\n');
  223. };
  224. Property.prototype.updateMeta = function (type, group, order, offset, corePlugin) {
  225. if (offset === void 0) { offset = 0; }
  226. if (corePlugin === void 0) { corePlugin = false; }
  227. this.meta = {
  228. type: type,
  229. group: group,
  230. order: order,
  231. offset: offset,
  232. corePlugin: corePlugin,
  233. };
  234. return this;
  235. };
  236. return Property;
  237. }());
  238. var InlineAtRule = /** @class */ (function (_super) {
  239. __extends(InlineAtRule, _super);
  240. function InlineAtRule(name, value, important) {
  241. if (important === void 0) { important = false; }
  242. var _this = _super.call(this, name, value, undefined, important) || this;
  243. _this.name = name;
  244. return _this;
  245. }
  246. InlineAtRule.parse = function (css) {
  247. var _a;
  248. var matchName = css.match(/@[^\s;{}]+/);
  249. if (matchName) {
  250. var name_1 = matchName[0].substring(1);
  251. var important = false;
  252. var expression = matchName.index !== undefined
  253. ? (_a = css
  254. .substring(matchName.index + name_1.length + 1)
  255. .match(/(?:(['"]).*?\1|[^;])*/)) === null || _a === void 0 ? void 0 : _a[0].trim()
  256. : undefined;
  257. if (expression && /!important;?$/.test(expression)) {
  258. important = true;
  259. expression = expression.replace(/!important/, '').trimRight();
  260. }
  261. return new InlineAtRule(name_1, expression === '' ? undefined : expression, important);
  262. }
  263. };
  264. InlineAtRule.prototype.build = function () {
  265. return this.value
  266. ? "@".concat(this.name, " ").concat(this.value).concat(this.important ? ' !important' : '', ";")
  267. : "@".concat(this.name).concat(this.important ? ' !important' : '', ";");
  268. };
  269. return InlineAtRule;
  270. }(Property));
  271. var Style = /** @class */ (function () {
  272. function Style(selector, property, important) {
  273. if (important === void 0) { important = false; }
  274. this.meta = { type: 'components', group: 'plugin', order: 0, offset: 0, corePlugin: false };
  275. this.selector = selector;
  276. this.important = important;
  277. this.property = toArray(property || []);
  278. }
  279. Object.defineProperty(Style.prototype, "rule", {
  280. get: function () {
  281. var _this = this;
  282. var _a, _b, _c;
  283. var selectors = ((_a = this.selector) !== null && _a !== void 0 ? _a : '').trim().split(/\s*,\s*/g);
  284. this._parentSelectors && (selectors = selectors.map(function (i) { var _a; return "".concat((_a = _this._parentSelectors) === null || _a === void 0 ? void 0 : _a.join(' '), " ").concat(i); }));
  285. ((_b = this._wrapSelectors) !== null && _b !== void 0 ? _b : []).forEach(function (func) { return (selectors = selectors.map(function (i) { return func(i); })); });
  286. this._pseudoClasses && (selectors = selectors.map(function (i) { var _a; return i + ":".concat((_a = _this._pseudoClasses) === null || _a === void 0 ? void 0 : _a.join(':')); }));
  287. this._pseudoElements && (selectors = selectors.map(function (i) { var _a; return i + "::".concat((_a = _this._pseudoElements) === null || _a === void 0 ? void 0 : _a.join('::')); }));
  288. this._brotherSelectors && (selectors = selectors.map(function (i) { var _a; return i + ".".concat((_a = _this._brotherSelectors) === null || _a === void 0 ? void 0 : _a.join('.')); }));
  289. this._childSelectors && (selectors = selectors.map(function (i) { var _a; return i + " ".concat((_a = _this._childSelectors) === null || _a === void 0 ? void 0 : _a.join(' ')); }));
  290. ((_c = this._wrapRules) !== null && _c !== void 0 ? _c : []).forEach(function (func) { return (selectors = selectors.map(function (i) { return func(i); })); });
  291. return selectors.join(', ');
  292. },
  293. enumerable: false,
  294. configurable: true
  295. });
  296. Object.defineProperty(Style.prototype, "pseudoClasses", {
  297. get: function () {
  298. return this._pseudoClasses;
  299. },
  300. enumerable: false,
  301. configurable: true
  302. });
  303. Object.defineProperty(Style.prototype, "pseudoElements", {
  304. get: function () {
  305. return this._pseudoElements;
  306. },
  307. enumerable: false,
  308. configurable: true
  309. });
  310. Object.defineProperty(Style.prototype, "parentSelectors", {
  311. get: function () {
  312. return this._parentSelectors;
  313. },
  314. enumerable: false,
  315. configurable: true
  316. });
  317. Object.defineProperty(Style.prototype, "childSelectors", {
  318. get: function () {
  319. return this._childSelectors;
  320. },
  321. enumerable: false,
  322. configurable: true
  323. });
  324. Object.defineProperty(Style.prototype, "brotherSelectors", {
  325. get: function () {
  326. return this._brotherSelectors;
  327. },
  328. enumerable: false,
  329. configurable: true
  330. });
  331. Object.defineProperty(Style.prototype, "wrapProperties", {
  332. get: function () {
  333. return this._wrapProperties;
  334. },
  335. enumerable: false,
  336. configurable: true
  337. });
  338. Object.defineProperty(Style.prototype, "wrapSelectors", {
  339. get: function () {
  340. return this._wrapSelectors;
  341. },
  342. enumerable: false,
  343. configurable: true
  344. });
  345. Object.defineProperty(Style.prototype, "wrapRules", {
  346. get: function () {
  347. return this._wrapRules;
  348. },
  349. enumerable: false,
  350. configurable: true
  351. });
  352. Object.defineProperty(Style.prototype, "simple", {
  353. get: function () {
  354. // is this style only has property and no wrap?
  355. return !(this.atRules || this._pseudoClasses || this._pseudoElements || this._parentSelectors || this._childSelectors || this._brotherSelectors || this._wrapProperties || this._wrapSelectors || this._wrapRules);
  356. },
  357. enumerable: false,
  358. configurable: true
  359. });
  360. Object.defineProperty(Style.prototype, "isAtrule", {
  361. get: function () {
  362. return !(this.atRules === undefined || this.atRules.length === 0);
  363. },
  364. enumerable: false,
  365. configurable: true
  366. });
  367. Style.generate = function (parent, property, root) {
  368. if (!root)
  369. root = (parent === null || parent === void 0 ? void 0 : parent.startsWith('@'))
  370. ? new Style().atRule(parent)
  371. : new Style(parent);
  372. var output = [];
  373. var _loop_1 = function (key, value) {
  374. var propertyValue = value;
  375. if (Array.isArray(propertyValue) && propertyValue.every(function (e) { return typeof e === 'object'; })) {
  376. propertyValue = Object.assign.apply(Object, __spreadArray([{}], propertyValue, false));
  377. }
  378. if (typeof propertyValue === 'string') {
  379. root.add(new Property(camelToDash(key), propertyValue));
  380. }
  381. else if (Array.isArray(propertyValue)) {
  382. propertyValue.map(function (i) { return root === null || root === void 0 ? void 0 : root.add(new Property(camelToDash(key), i)); });
  383. }
  384. else {
  385. var wrap = deepCopy(root);
  386. wrap.property = [];
  387. var child = void 0;
  388. if (key.startsWith('@')) {
  389. child = wrap.atRule(key, false);
  390. }
  391. else {
  392. if (wrap.selector === undefined) {
  393. wrap.selector = key;
  394. child = wrap;
  395. }
  396. else {
  397. if (/^[a-z]+$/.test(key) && !isTagName(key)) {
  398. wrap.wrapProperty(function (property) { return "".concat(key, "-").concat(property); });
  399. child = wrap;
  400. }
  401. else {
  402. var _hKey_1 = function (selector, key) { return (/&/.test(key) ? key : "& ".concat(key)).replace('&', selector); };
  403. wrap.wrapSelector(function (selector) {
  404. return selector
  405. .trim()
  406. .split(/\s*,\s*/g)
  407. .map(function (s) {
  408. return key
  409. .split(/\s*,\s*/g)
  410. .map(function (i) { return _hKey_1(s, i); })
  411. .join(', ');
  412. })
  413. .join(', ');
  414. });
  415. child = wrap;
  416. }
  417. }
  418. }
  419. output = output.concat(Style.generate(key.startsWith('@') ? undefined : key, propertyValue, child));
  420. }
  421. };
  422. for (var _i = 0, _a = Object.entries(property !== null && property !== void 0 ? property : {}); _i < _a.length; _i++) {
  423. var _b = _a[_i], key = _b[0], value = _b[1];
  424. _loop_1(key, value);
  425. }
  426. if (root.property.length > 0)
  427. output.unshift(root);
  428. return output;
  429. };
  430. Style.prototype.atRule = function (atrule, append) {
  431. if (append === void 0) { append = true; }
  432. if (!atrule)
  433. return this;
  434. if (this.atRules) {
  435. append ? this.atRules.push(atrule) : this.atRules.unshift(atrule);
  436. }
  437. else {
  438. this.atRules = [atrule];
  439. }
  440. return this;
  441. };
  442. Style.prototype.pseudoClass = function (string) {
  443. if (this._pseudoClasses) {
  444. this._pseudoClasses.push(string);
  445. }
  446. else {
  447. this._pseudoClasses = [string];
  448. }
  449. return this;
  450. };
  451. Style.prototype.pseudoElement = function (string) {
  452. if (this._pseudoElements) {
  453. this._pseudoElements.push(string);
  454. }
  455. else {
  456. this._pseudoElements = [string];
  457. }
  458. return this;
  459. };
  460. Style.prototype.brother = function (string) {
  461. if (this._brotherSelectors) {
  462. this._brotherSelectors.push(string);
  463. }
  464. else {
  465. this._brotherSelectors = [string];
  466. }
  467. return this;
  468. };
  469. Style.prototype.parent = function (string) {
  470. if (this._parentSelectors) {
  471. this._parentSelectors.push(string);
  472. }
  473. else {
  474. this._parentSelectors = [string];
  475. }
  476. return this;
  477. };
  478. Style.prototype.child = function (string) {
  479. if (this._childSelectors) {
  480. this._childSelectors.push(string);
  481. }
  482. else {
  483. this._childSelectors = [string];
  484. }
  485. return this;
  486. };
  487. Style.prototype.wrapProperty = function (func) {
  488. if (this._wrapProperties) {
  489. this._wrapProperties.push(func);
  490. }
  491. else {
  492. this._wrapProperties = [func];
  493. }
  494. return this;
  495. };
  496. Style.prototype.wrapSelector = function (func) {
  497. if (this._wrapSelectors) {
  498. this._wrapSelectors.push(func);
  499. }
  500. else {
  501. this._wrapSelectors = [func];
  502. }
  503. return this;
  504. };
  505. Style.prototype.wrapRule = function (func) {
  506. if (this._wrapRules) {
  507. this._wrapRules.push(func);
  508. }
  509. else {
  510. this._wrapRules = [func];
  511. }
  512. return this;
  513. };
  514. Style.prototype.add = function (item) {
  515. item = toArray(item);
  516. if (this.important)
  517. item.forEach(function (i) { return (i.important = true); });
  518. this.property = __spreadArray(__spreadArray([], this.property, true), item, true);
  519. return this;
  520. };
  521. Style.prototype.extend = function (item, onlyProperty, append) {
  522. if (onlyProperty === void 0) { onlyProperty = false; }
  523. if (append === void 0) { append = true; }
  524. if (!item)
  525. return this;
  526. if (item.wrapProperties) {
  527. var props_1 = [];
  528. item.property.forEach(function (p) {
  529. var _a;
  530. var pc = new Property(p.name, p.value, p.comment);
  531. (_a = item.wrapProperties) === null || _a === void 0 ? void 0 : _a.forEach(function (wrap) {
  532. pc.name = Array.isArray(pc.name)
  533. ? pc.name.map(function (i) { return wrap(i); })
  534. : wrap(pc.name);
  535. });
  536. if (item.important)
  537. pc.important = true;
  538. props_1.push(pc);
  539. });
  540. this.property = connectList(this.property, props_1, append);
  541. }
  542. else {
  543. if (item.important)
  544. item.property.forEach(function (i) { return (i.important = true); });
  545. this.property = connectList(this.property, item.property, append);
  546. }
  547. if (onlyProperty)
  548. return this;
  549. item.selector && (this.selector = item.selector);
  550. this.meta = item.meta;
  551. item.atRules &&
  552. (this.atRules = connectList(item.atRules, this.atRules, append)); // atrule is build in reverse
  553. item._brotherSelectors &&
  554. (this._brotherSelectors = connectList(this._brotherSelectors, item._brotherSelectors, append));
  555. item._childSelectors &&
  556. (this._childSelectors = connectList(this._childSelectors, item._childSelectors, append));
  557. item._parentSelectors &&
  558. (this._parentSelectors = connectList(this._parentSelectors, item._parentSelectors, append));
  559. item._pseudoClasses &&
  560. (this._pseudoClasses = connectList(this._pseudoClasses, item._pseudoClasses, append));
  561. item._pseudoElements &&
  562. (this._pseudoElements = connectList(this._pseudoElements, item._pseudoElements, append));
  563. item._wrapRules &&
  564. (this._wrapRules = connectList(this._wrapRules, item._wrapRules, append));
  565. item._wrapSelectors &&
  566. (this._wrapSelectors = connectList(this._wrapSelectors, item._wrapSelectors, append));
  567. return this;
  568. };
  569. Style.prototype.clean = function () {
  570. // remove duplicated property
  571. var property = [];
  572. var cache = [];
  573. this.property.forEach(function (i) {
  574. var inline = i.build();
  575. if (!cache.includes(inline)) {
  576. cache.push(inline);
  577. property.push(i);
  578. }
  579. });
  580. this.property = property;
  581. return this;
  582. };
  583. Style.prototype.flat = function () {
  584. var properties = [];
  585. this.property.forEach(function (p) {
  586. if (Array.isArray(p.name)) {
  587. p.name.forEach(function (i) {
  588. properties.push(new Property(i, p.value, p.comment));
  589. });
  590. }
  591. else {
  592. properties.push(p);
  593. }
  594. });
  595. this.property = properties;
  596. return this;
  597. };
  598. Style.prototype.clone = function (selector, property) {
  599. var newStyle = deepCopy(this);
  600. if (selector)
  601. newStyle.selector = selector;
  602. if (property)
  603. newStyle.property = Array.isArray(property) ? property : [property];
  604. return newStyle;
  605. };
  606. Style.prototype.sort = function () {
  607. // sort property
  608. this.property = this.property.sort(function (a, b) {
  609. return "".concat(a.name).substring(0, 2) > "".concat(b.name).substring(0, 2) ? 1 : -1;
  610. });
  611. return this;
  612. };
  613. Style.prototype.build = function (minify, prefixer) {
  614. var _this = this;
  615. if (minify === void 0) { minify = false; }
  616. if (prefixer === void 0) { prefixer = true; }
  617. var properties = this.property;
  618. if (!prefixer)
  619. properties = properties.filter(function (p) {
  620. if (p.value && /-(webkit|ms|moz|o)-/.test(p.value))
  621. return false;
  622. if (Array.isArray(p.name)) {
  623. p.name = p.name.filter(function (i) { return !/^-(webkit|ms|moz|o)-/.test(i); });
  624. return true;
  625. }
  626. return !/^-(webkit|ms|moz|o)-/.test(p.name);
  627. });
  628. var result = properties.map(function (p) {
  629. if (_this._wrapProperties) {
  630. var name_2 = p.name;
  631. _this._wrapProperties.forEach(function (w) { return (name_2 = Array.isArray(name_2) ? name_2.map(function (n) { return w(n); }) : w(name_2)); });
  632. return new Property(name_2, p.value, p.comment, _this.important ? true : p.important).build(minify);
  633. }
  634. return _this.important ? new Property(p.name, p.value, p.comment, true).build(minify) : p.build(minify);
  635. }).join(minify ? '' : '\n');
  636. if (!this.selector && !this.atRules)
  637. return result.replace(/;}/g, '}');
  638. if (this.selector)
  639. result = (minify ? this.rule.replace(/,\s/g, ',') : this.rule + ' ') + wrapit(result, undefined, undefined, undefined, result !== '' ? minify : true);
  640. if (this.atRules) {
  641. for (var _i = 0, _a = this.atRules; _i < _a.length; _i++) {
  642. var rule = _a[_i];
  643. result = minify ? "".concat(rule.replace(/\s/g, '')).concat(wrapit(result, undefined, undefined, undefined, minify)) : "".concat(rule, " ").concat(wrapit(result, undefined, undefined, undefined, result !== '' ? minify : true));
  644. }
  645. }
  646. return minify ? result.replace(/;}/g, '}') : result;
  647. };
  648. Style.prototype.updateMeta = function (type, group, order, offset, corePlugin, respectSelector) {
  649. if (offset === void 0) { offset = 0; }
  650. if (corePlugin === void 0) { corePlugin = false; }
  651. if (respectSelector === void 0) { respectSelector = false; }
  652. this.meta = {
  653. type: type,
  654. group: group,
  655. order: order,
  656. offset: offset,
  657. corePlugin: corePlugin,
  658. respectSelector: respectSelector,
  659. };
  660. return this;
  661. };
  662. return Style;
  663. }());
  664. var GlobalStyle = /** @class */ (function (_super) {
  665. __extends(GlobalStyle, _super);
  666. function GlobalStyle(selector, property, important) {
  667. return _super.call(this, selector, property, important) || this;
  668. }
  669. return GlobalStyle;
  670. }(Style));
  671. var Keyframes = /** @class */ (function (_super) {
  672. __extends(Keyframes, _super);
  673. function Keyframes(selector, property, important) {
  674. return _super.call(this, selector, property, important) || this;
  675. }
  676. // root param only for consist with style
  677. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  678. Keyframes.generate = function (name, children, root, prefixer) {
  679. if (prefixer === void 0) { prefixer = true; }
  680. var styles = [];
  681. var webkitStyles = [];
  682. for (var _i = 0, _a = Object.entries(children); _i < _a.length; _i++) {
  683. var _b = _a[_i], key = _b[0], value = _b[1];
  684. var style = new Keyframes(key).atRule("@keyframes ".concat(name));
  685. var webkitStyle = new Keyframes(key).atRule("@-webkit-keyframes ".concat(name));
  686. for (var _c = 0, _d = Object.entries(value); _c < _d.length; _c++) {
  687. var _e = _d[_c], pkey = _e[0], pvalue = _e[1];
  688. var prop = pkey;
  689. if (pkey === 'transform') {
  690. prop = prefixer ? ['-webkit-transform', 'transform'] : 'transform';
  691. }
  692. else if (['animationTimingFunction', 'animation-timing-function'].includes(pkey)) {
  693. prop = prefixer ? [
  694. '-webkit-animation-timing-function',
  695. 'animation-timing-function',
  696. ] : 'animation-timing-function';
  697. }
  698. style.add(new Property(prop, pvalue));
  699. webkitStyle.add(new Property(prop, pvalue));
  700. }
  701. styles.push(style);
  702. if (prefixer)
  703. webkitStyles.push(webkitStyle);
  704. }
  705. return __spreadArray(__spreadArray([], styles, true), webkitStyles, true);
  706. };
  707. return Keyframes;
  708. }(Style));
  709. var Container = /** @class */ (function (_super) {
  710. __extends(Container, _super);
  711. function Container(selector, property, important) {
  712. return _super.call(this, selector, property, important) || this;
  713. }
  714. return Container;
  715. }(Style));
  716. var minMaxWidth = /(!?\(\s*min(-device-)?-width).+\(\s*max(-device)?-width/i;
  717. var minWidth = /\(\s*min(-device)?-width/i;
  718. var maxMinWidth = /(!?\(\s*max(-device)?-width).+\(\s*min(-device)?-width/i;
  719. var maxWidth = /\(\s*max(-device)?-width/i;
  720. var isMinWidth = _testQuery(minMaxWidth, maxMinWidth, minWidth);
  721. var isMaxWidth = _testQuery(maxMinWidth, minMaxWidth, maxWidth);
  722. var minMaxHeight = /(!?\(\s*min(-device)?-height).+\(\s*max(-device)?-height/i;
  723. var minHeight = /\(\s*min(-device)?-height/i;
  724. var maxMinHeight = /(!?\(\s*max(-device)?-height).+\(\s*min(-device)?-height/i;
  725. var maxHeight = /\(\s*max(-device)?-height/i;
  726. var isMinHeight = _testQuery(minMaxHeight, maxMinHeight, minHeight);
  727. var isMaxHeight = _testQuery(maxMinHeight, minMaxHeight, maxHeight);
  728. var isPrint = /print/i;
  729. var isPrintOnly = /^print\$/i;
  730. var isAtRule = /^\s*@/i;
  731. var isMedia = /^\s*@media/i;
  732. var maxValue = Number.MAX_VALUE;
  733. function _getQueryLength(length) {
  734. var result = /(-?\d*\.?\d+)(ch|em|ex|px|rpx|rem)/.exec(length);
  735. if (result === null) {
  736. return maxValue;
  737. }
  738. var number = result[1];
  739. var unit = result[2];
  740. switch (unit) {
  741. case 'ch':
  742. return parseFloat(number) * 8.8984375;
  743. case 'em':
  744. case 'rem':
  745. return parseFloat(number) * 16;
  746. case 'ex':
  747. return parseFloat(number) * 8.296875;
  748. case 'px':
  749. case 'rpx':
  750. return parseFloat(number);
  751. }
  752. return +number;
  753. }
  754. function _testQuery(doubleTestTrue, doubleTestFalse, singleTest) {
  755. return function (query) {
  756. if (doubleTestTrue.test(query)) {
  757. return true;
  758. }
  759. else if (doubleTestFalse.test(query)) {
  760. return false;
  761. }
  762. return singleTest.test(query);
  763. };
  764. }
  765. function _testAtRule(a, b) {
  766. var isMediaA = isMedia.test(a);
  767. var isMediaB = isMedia.test(b);
  768. if (isMediaA && isMediaB)
  769. return null;
  770. var isAtRuleA = isAtRule.test(a);
  771. var isAtRuleB = isAtRule.test(b);
  772. if (isAtRuleA)
  773. return 1;
  774. if (isAtRuleB)
  775. return -1;
  776. return 0; // don't sort selector name, may cause overwrite bug.
  777. }
  778. function _testIsPrint(a, b) {
  779. var isPrintA = isPrint.test(a);
  780. var isPrintOnlyA = isPrintOnly.test(a);
  781. var isPrintB = isPrint.test(b);
  782. var isPrintOnlyB = isPrintOnly.test(b);
  783. if (isPrintA && isPrintB) {
  784. if (!isPrintOnlyA && isPrintOnlyB) {
  785. return 1;
  786. }
  787. if (isPrintOnlyA && !isPrintOnlyB) {
  788. return -1;
  789. }
  790. return a.localeCompare(b);
  791. }
  792. if (isPrintA) {
  793. return 1;
  794. }
  795. if (isPrintB) {
  796. return -1;
  797. }
  798. return null;
  799. }
  800. function sortMediaQuery(a, b) {
  801. var testAtRule = _testAtRule(a, b);
  802. if (testAtRule !== null)
  803. return testAtRule;
  804. var testIsPrint = _testIsPrint(a, b);
  805. if (testIsPrint !== null)
  806. return testIsPrint;
  807. var minA = isMinWidth(a) || isMinHeight(a);
  808. var maxA = isMaxWidth(a) || isMaxHeight(a);
  809. var minB = isMinWidth(b) || isMinHeight(b);
  810. var maxB = isMaxWidth(b) || isMaxHeight(b);
  811. if (minA && maxB) {
  812. return -1;
  813. }
  814. if (maxA && minB) {
  815. return 1;
  816. }
  817. var lengthA = _getQueryLength(a);
  818. var lengthB = _getQueryLength(b);
  819. if (lengthA === maxValue && lengthB === maxValue) {
  820. return a.localeCompare(b);
  821. }
  822. else if (lengthA === maxValue) {
  823. return 1;
  824. }
  825. else if (lengthB === maxValue) {
  826. return -1;
  827. }
  828. if (lengthA > lengthB) {
  829. if (maxA) {
  830. return -1;
  831. }
  832. return 1;
  833. }
  834. if (lengthA < lengthB) {
  835. if (maxA) {
  836. return 1;
  837. }
  838. return -1;
  839. }
  840. return a.localeCompare(b);
  841. }
  842. function getWeights(a) {
  843. var first = a.charAt(0);
  844. var second = a.charAt(1);
  845. if (first === ':' && second === ':')
  846. return 59; // ::moz ...
  847. if (first === '#')
  848. return 500; // #id ...
  849. if (first !== '.')
  850. return first.charCodeAt(0); // html, body ...
  851. return 499;
  852. }
  853. function sortMeta(a, b) {
  854. var _a, _b, _c, _d;
  855. if (a.meta.type === 'base' && b.meta.type === 'base')
  856. return getWeights((_a = a.selector) !== null && _a !== void 0 ? _a : '') - getWeights((_b = b.selector) !== null && _b !== void 0 ? _b : '');
  857. return sortMediaQuery(((_c = a.meta.variants) === null || _c === void 0 ? void 0 : _c[0]) || '', ((_d = b.meta.variants) === null || _d === void 0 ? void 0 : _d[0]) || '') || (a.meta.order - b.meta.order) || (a.meta.offset - b.meta.offset) || +b.meta.corePlugin - +a.meta.corePlugin;
  858. }
  859. function _buildAtrule(atrule, children, minify, prefixer) {
  860. if (minify === void 0) { minify = false; }
  861. if (prefixer === void 0) { prefixer = true; }
  862. return "".concat(atrule).concat(minify ? '' : ' ').concat(wrapit(_buildStyleList(children, minify, prefixer), undefined, undefined, undefined, minify));
  863. }
  864. function _buildStyleList(styleList, minify, prefixer) {
  865. if (minify === void 0) { minify = false; }
  866. if (prefixer === void 0) { prefixer = true; }
  867. var currentAtrule;
  868. var currentStyle;
  869. var styleStack = [];
  870. var output = [];
  871. var _loop_1 = function (style) {
  872. if (style.isAtrule) {
  873. if (currentStyle) {
  874. output.push(currentStyle.clean().build(minify, prefixer));
  875. currentStyle = undefined;
  876. }
  877. var newAtrule = style.atRules.pop();
  878. if (currentAtrule) {
  879. if (currentAtrule === newAtrule && newAtrule !== '@font-face') { // @font-face shouldn't been combined
  880. styleStack.push(style);
  881. }
  882. else {
  883. output.push(_buildAtrule(currentAtrule, styleStack, minify, prefixer));
  884. currentAtrule = newAtrule;
  885. styleStack = [style];
  886. }
  887. }
  888. else {
  889. currentAtrule = newAtrule;
  890. styleStack = [style];
  891. }
  892. }
  893. else {
  894. if (currentAtrule) {
  895. output.push(_buildAtrule(currentAtrule, styleStack, minify, prefixer));
  896. currentAtrule = undefined;
  897. styleStack = [];
  898. }
  899. if (currentStyle) {
  900. if (style.rule === currentStyle.rule) {
  901. if (style.important)
  902. style.property.forEach(function (p) { return p.important = true; });
  903. if (style.wrapProperties)
  904. style.property.forEach(function (p) { var _a; return (_a = style.wrapProperties) === null || _a === void 0 ? void 0 : _a.forEach(function (wrap) { return p.name = Array.isArray(p.name) ? p.name.map(function (i) { return wrap(i); }) : wrap(p.name); }); });
  905. currentStyle.add(style.property);
  906. }
  907. else {
  908. output.push(currentStyle.clean().build(minify, prefixer));
  909. currentStyle = style;
  910. }
  911. }
  912. else {
  913. currentStyle = style;
  914. }
  915. }
  916. };
  917. for (var _i = 0, styleList_1 = styleList; _i < styleList_1.length; _i++) {
  918. var style = styleList_1[_i];
  919. _loop_1(style);
  920. }
  921. if (currentAtrule)
  922. output.push(_buildAtrule(currentAtrule, styleStack, minify, prefixer));
  923. if (currentStyle)
  924. output.push(currentStyle.clean().build(minify, prefixer));
  925. return output.join(minify ? '' : '\n');
  926. }
  927. function compileStyleSheet (styleList, minify, prefixer) {
  928. if (minify === void 0) { minify = false; }
  929. if (prefixer === void 0) { prefixer = true; }
  930. return _buildStyleList(deepCopy(styleList), minify, prefixer);
  931. }
  932. var StyleSheet = /** @class */ (function () {
  933. function StyleSheet(children) {
  934. this.prefixer = true;
  935. this.children = children || [];
  936. }
  937. StyleSheet.prototype.add = function (item) {
  938. if (!item)
  939. return this;
  940. if (Array.isArray(item)) {
  941. this.children = __spreadArray(__spreadArray([], this.children, true), item, true);
  942. }
  943. else {
  944. this.children.push(item);
  945. }
  946. return this;
  947. };
  948. StyleSheet.prototype.extend = function (styleSheet, append, dedup) {
  949. if (append === void 0) { append = true; }
  950. if (dedup === void 0) { dedup = false; }
  951. if (styleSheet) {
  952. var extended = styleSheet.children;
  953. if (dedup) {
  954. var hashes_1 = extended.map(function (i) { return hash(i.build()); });
  955. extended = extended.filter(function (i) { return !hashes_1.includes(hash(i.build())); });
  956. }
  957. this.prefixer = styleSheet.prefixer;
  958. this.children = append ? __spreadArray(__spreadArray([], this.children, true), extended, true) : __spreadArray(__spreadArray([], extended, true), this.children, true);
  959. }
  960. return this;
  961. };
  962. StyleSheet.prototype.combine = function () {
  963. var styleMap = {};
  964. this.children.forEach(function (style, index) {
  965. var _a;
  966. var hashValue = hash(style.atRules + style.meta.type + style.rule);
  967. if (hashValue in styleMap) {
  968. if ((_a = style.atRules) === null || _a === void 0 ? void 0 : _a.includes('@font-face')) {
  969. // keeps multiple @font-face
  970. styleMap[hashValue + index] = style;
  971. }
  972. else {
  973. styleMap[hashValue] = styleMap[hashValue].extend(style, true);
  974. }
  975. }
  976. else {
  977. styleMap[hashValue] = style;
  978. }
  979. });
  980. this.children = Object.values(styleMap).map(function (i) { return i.clean(); });
  981. return this;
  982. };
  983. StyleSheet.prototype.layer = function (type) {
  984. var styleSheet = new StyleSheet(this.children.filter(function (i) { return i.meta.type === type; }));
  985. styleSheet.prefixer = this.prefixer;
  986. return styleSheet;
  987. };
  988. StyleSheet.prototype.split = function () {
  989. return {
  990. base: this.layer('base'),
  991. components: this.layer('components'),
  992. utilities: this.layer('utilities'),
  993. };
  994. };
  995. StyleSheet.prototype.clone = function () {
  996. return deepCopy(this);
  997. };
  998. StyleSheet.prototype.sort = function () {
  999. this.children = this.children.sort(sortMeta);
  1000. return this;
  1001. };
  1002. StyleSheet.prototype.sortby = function (compareFn) {
  1003. this.children = this.children.sort(compareFn);
  1004. return this;
  1005. };
  1006. StyleSheet.prototype.build = function (minify) {
  1007. if (minify === void 0) { minify = false; }
  1008. return compileStyleSheet(this.children, minify, this.prefixer);
  1009. };
  1010. return StyleSheet;
  1011. }());
  1012. function linearGradient(value) {
  1013. // Stupid method, will be changed in the next version...
  1014. var map = {
  1015. 'linear-gradient(to top, var(--tw-gradient-stops))': [
  1016. '-o-linear-gradient(bottom, var(--tw-gradient-stops))',
  1017. '-webkit-gradient(linear, left bottom, left top, from(var(--tw-gradient-stops)))',
  1018. 'linear-gradient(to top, var(--tw-gradient-stops))',
  1019. ],
  1020. 'linear-gradient(to top right, var(--tw-gradient-stops))': [
  1021. '-o-linear-gradient(bottom left, var(--tw-gradient-stops))',
  1022. '-webkit-gradient(linear, left bottom, right top, from(var(--tw-gradient-stops)))',
  1023. 'linear-gradient(to top right, var(--tw-gradient-stops))',
  1024. ],
  1025. 'linear-gradient(to right, var(--tw-gradient-stops))': [
  1026. '-o-linear-gradient(left, var(--tw-gradient-stops))',
  1027. '-webkit-gradient(linear, left top, right top, from(var(--tw-gradient-stops)))',
  1028. 'linear-gradient(to right, var(--tw-gradient-stops))',
  1029. ],
  1030. 'linear-gradient(to bottom right, var(--tw-gradient-stops))': [
  1031. '-o-linear-gradient(top left, var(--tw-gradient-stops))',
  1032. '-webkit-gradient(linear, left top, right bottom, from(var(--tw-gradient-stops)))',
  1033. 'linear-gradient(to bottom right, var(--tw-gradient-stops))',
  1034. ],
  1035. 'linear-gradient(to bottom, var(--tw-gradient-stops))': [
  1036. '-o-linear-gradient(top, var(--tw-gradient-stops))',
  1037. '-webkit-gradient(linear, left top, left bottom, from(var(--tw-gradient-stops)))',
  1038. 'linear-gradient(to bottom, var(--tw-gradient-stops))',
  1039. ],
  1040. 'linear-gradient(to bottom left, var(--tw-gradient-stops))': [
  1041. '-o-linear-gradient(top right, var(--tw-gradient-stops))',
  1042. '-webkit-gradient(linear, right top, left bottom, from(var(--tw-gradient-stops)))',
  1043. 'linear-gradient(to bottom left, var(--tw-gradient-stops))',
  1044. ],
  1045. 'linear-gradient(to left, var(--tw-gradient-stops))': [
  1046. '-o-linear-gradient(right, var(--tw-gradient-stops))',
  1047. '-webkit-gradient(linear, right top, left top, from(var(--tw-gradient-stops)))',
  1048. 'linear-gradient(to left, var(--tw-gradient-stops))',
  1049. ],
  1050. 'linear-gradient(to top left, var(--tw-gradient-stops))': [
  1051. '-o-linear-gradient(bottom right, var(--tw-gradient-stops))',
  1052. '-webkit-gradient(linear, right bottom, left top, from(var(--tw-gradient-stops)))',
  1053. 'linear-gradient(to top left, var(--tw-gradient-stops))',
  1054. ],
  1055. };
  1056. if (Object.keys(map).includes(value))
  1057. return map[value];
  1058. return value;
  1059. }
  1060. function minMaxContent(value) {
  1061. if (value === 'min-content') {
  1062. return ['-webkit-min-content', 'min-content'];
  1063. }
  1064. else if (value === 'max-content') {
  1065. return ['-webkit-max-content', 'max-content'];
  1066. }
  1067. return value;
  1068. }
  1069. export { Container, GlobalStyle, InlineAtRule, Keyframes, Property, Style, StyleSheet, linearGradient, minMaxContent };