util-D9FfmVnv.mjs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. /**
  2. * @license Angular v19.2.13
  3. * (c) 2010-2025 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. import { AnimationGroupPlayer, NoopAnimationPlayer, AUTO_STYLE, ɵPRE_STYLE as _PRE_STYLE, AnimationMetadataType, sequence } from './private_export-faY_wCkZ.mjs';
  7. import { ɵRuntimeError as _RuntimeError } from '@angular/core';
  8. const LINE_START = '\n - ';
  9. function invalidTimingValue(exp) {
  10. return new _RuntimeError(3000 /* RuntimeErrorCode.INVALID_TIMING_VALUE */, ngDevMode && `The provided timing value "${exp}" is invalid.`);
  11. }
  12. function negativeStepValue() {
  13. return new _RuntimeError(3100 /* RuntimeErrorCode.NEGATIVE_STEP_VALUE */, ngDevMode && 'Duration values below 0 are not allowed for this animation step.');
  14. }
  15. function negativeDelayValue() {
  16. return new _RuntimeError(3101 /* RuntimeErrorCode.NEGATIVE_DELAY_VALUE */, ngDevMode && 'Delay values below 0 are not allowed for this animation step.');
  17. }
  18. function invalidStyleParams(varName) {
  19. return new _RuntimeError(3001 /* RuntimeErrorCode.INVALID_STYLE_PARAMS */, ngDevMode &&
  20. `Unable to resolve the local animation param ${varName} in the given list of values`);
  21. }
  22. function invalidParamValue(varName) {
  23. return new _RuntimeError(3003 /* RuntimeErrorCode.INVALID_PARAM_VALUE */, ngDevMode && `Please provide a value for the animation param ${varName}`);
  24. }
  25. function invalidNodeType(nodeType) {
  26. return new _RuntimeError(3004 /* RuntimeErrorCode.INVALID_NODE_TYPE */, ngDevMode && `Unable to resolve animation metadata node #${nodeType}`);
  27. }
  28. function invalidCssUnitValue(userProvidedProperty, value) {
  29. return new _RuntimeError(3005 /* RuntimeErrorCode.INVALID_CSS_UNIT_VALUE */, ngDevMode && `Please provide a CSS unit value for ${userProvidedProperty}:${value}`);
  30. }
  31. function invalidTrigger() {
  32. return new _RuntimeError(3006 /* RuntimeErrorCode.INVALID_TRIGGER */, ngDevMode &&
  33. "animation triggers cannot be prefixed with an `@` sign (e.g. trigger('@foo', [...]))");
  34. }
  35. function invalidDefinition() {
  36. return new _RuntimeError(3007 /* RuntimeErrorCode.INVALID_DEFINITION */, ngDevMode && 'only state() and transition() definitions can sit inside of a trigger()');
  37. }
  38. function invalidState(metadataName, missingSubs) {
  39. return new _RuntimeError(3008 /* RuntimeErrorCode.INVALID_STATE */, ngDevMode &&
  40. `state("${metadataName}", ...) must define default values for all the following style substitutions: ${missingSubs.join(', ')}`);
  41. }
  42. function invalidStyleValue(value) {
  43. return new _RuntimeError(3002 /* RuntimeErrorCode.INVALID_STYLE_VALUE */, ngDevMode && `The provided style string value ${value} is not allowed.`);
  44. }
  45. function invalidParallelAnimation(prop, firstStart, firstEnd, secondStart, secondEnd) {
  46. return new _RuntimeError(3010 /* RuntimeErrorCode.INVALID_PARALLEL_ANIMATION */, ngDevMode &&
  47. `The CSS property "${prop}" that exists between the times of "${firstStart}ms" and "${firstEnd}ms" is also being animated in a parallel animation between the times of "${secondStart}ms" and "${secondEnd}ms"`);
  48. }
  49. function invalidKeyframes() {
  50. return new _RuntimeError(3011 /* RuntimeErrorCode.INVALID_KEYFRAMES */, ngDevMode && `keyframes() must be placed inside of a call to animate()`);
  51. }
  52. function invalidOffset() {
  53. return new _RuntimeError(3012 /* RuntimeErrorCode.INVALID_OFFSET */, ngDevMode && `Please ensure that all keyframe offsets are between 0 and 1`);
  54. }
  55. function keyframeOffsetsOutOfOrder() {
  56. return new _RuntimeError(3200 /* RuntimeErrorCode.KEYFRAME_OFFSETS_OUT_OF_ORDER */, ngDevMode && `Please ensure that all keyframe offsets are in order`);
  57. }
  58. function keyframesMissingOffsets() {
  59. return new _RuntimeError(3202 /* RuntimeErrorCode.KEYFRAMES_MISSING_OFFSETS */, ngDevMode && `Not all style() steps within the declared keyframes() contain offsets`);
  60. }
  61. function invalidStagger() {
  62. return new _RuntimeError(3013 /* RuntimeErrorCode.INVALID_STAGGER */, ngDevMode && `stagger() can only be used inside of query()`);
  63. }
  64. function invalidQuery(selector) {
  65. return new _RuntimeError(3014 /* RuntimeErrorCode.INVALID_QUERY */, ngDevMode &&
  66. `\`query("${selector}")\` returned zero elements. (Use \`query("${selector}", { optional: true })\` if you wish to allow this.)`);
  67. }
  68. function invalidExpression(expr) {
  69. return new _RuntimeError(3015 /* RuntimeErrorCode.INVALID_EXPRESSION */, ngDevMode && `The provided transition expression "${expr}" is not supported`);
  70. }
  71. function invalidTransitionAlias(alias) {
  72. return new _RuntimeError(3016 /* RuntimeErrorCode.INVALID_TRANSITION_ALIAS */, ngDevMode && `The transition alias value "${alias}" is not supported`);
  73. }
  74. function validationFailed(errors) {
  75. return new _RuntimeError(3500 /* RuntimeErrorCode.VALIDATION_FAILED */, ngDevMode && `animation validation failed:\n${errors.map((err) => err.message).join('\n')}`);
  76. }
  77. function buildingFailed(errors) {
  78. return new _RuntimeError(3501 /* RuntimeErrorCode.BUILDING_FAILED */, ngDevMode && `animation building failed:\n${errors.map((err) => err.message).join('\n')}`);
  79. }
  80. function triggerBuildFailed(name, errors) {
  81. return new _RuntimeError(3404 /* RuntimeErrorCode.TRIGGER_BUILD_FAILED */, ngDevMode &&
  82. `The animation trigger "${name}" has failed to build due to the following errors:\n - ${errors
  83. .map((err) => err.message)
  84. .join('\n - ')}`);
  85. }
  86. function animationFailed(errors) {
  87. return new _RuntimeError(3502 /* RuntimeErrorCode.ANIMATION_FAILED */, ngDevMode &&
  88. `Unable to animate due to the following errors:${LINE_START}${errors
  89. .map((err) => err.message)
  90. .join(LINE_START)}`);
  91. }
  92. function registerFailed(errors) {
  93. return new _RuntimeError(3503 /* RuntimeErrorCode.REGISTRATION_FAILED */, ngDevMode &&
  94. `Unable to build the animation due to the following errors: ${errors
  95. .map((err) => err.message)
  96. .join('\n')}`);
  97. }
  98. function missingOrDestroyedAnimation() {
  99. return new _RuntimeError(3300 /* RuntimeErrorCode.MISSING_OR_DESTROYED_ANIMATION */, ngDevMode && "The requested animation doesn't exist or has already been destroyed");
  100. }
  101. function createAnimationFailed(errors) {
  102. return new _RuntimeError(3504 /* RuntimeErrorCode.CREATE_ANIMATION_FAILED */, ngDevMode &&
  103. `Unable to create the animation due to the following errors:${errors
  104. .map((err) => err.message)
  105. .join('\n')}`);
  106. }
  107. function missingPlayer(id) {
  108. return new _RuntimeError(3301 /* RuntimeErrorCode.MISSING_PLAYER */, ngDevMode && `Unable to find the timeline player referenced by ${id}`);
  109. }
  110. function missingTrigger(phase, name) {
  111. return new _RuntimeError(3302 /* RuntimeErrorCode.MISSING_TRIGGER */, ngDevMode &&
  112. `Unable to listen on the animation trigger event "${phase}" because the animation trigger "${name}" doesn\'t exist!`);
  113. }
  114. function missingEvent(name) {
  115. return new _RuntimeError(3303 /* RuntimeErrorCode.MISSING_EVENT */, ngDevMode &&
  116. `Unable to listen on the animation trigger "${name}" because the provided event is undefined!`);
  117. }
  118. function unsupportedTriggerEvent(phase, name) {
  119. return new _RuntimeError(3400 /* RuntimeErrorCode.UNSUPPORTED_TRIGGER_EVENT */, ngDevMode &&
  120. `The provided animation trigger event "${phase}" for the animation trigger "${name}" is not supported!`);
  121. }
  122. function unregisteredTrigger(name) {
  123. return new _RuntimeError(3401 /* RuntimeErrorCode.UNREGISTERED_TRIGGER */, ngDevMode && `The provided animation trigger "${name}" has not been registered!`);
  124. }
  125. function triggerTransitionsFailed(errors) {
  126. return new _RuntimeError(3402 /* RuntimeErrorCode.TRIGGER_TRANSITIONS_FAILED */, ngDevMode &&
  127. `Unable to process animations due to the following failed trigger transitions\n ${errors
  128. .map((err) => err.message)
  129. .join('\n')}`);
  130. }
  131. function transitionFailed(name, errors) {
  132. return new _RuntimeError(3505 /* RuntimeErrorCode.TRANSITION_FAILED */, ngDevMode && `@${name} has failed due to:\n ${errors.map((err) => err.message).join('\n- ')}`);
  133. }
  134. /**
  135. * Set of all animatable CSS properties
  136. *
  137. * @see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_animated_properties
  138. */
  139. const ANIMATABLE_PROP_SET = new Set([
  140. '-moz-outline-radius',
  141. '-moz-outline-radius-bottomleft',
  142. '-moz-outline-radius-bottomright',
  143. '-moz-outline-radius-topleft',
  144. '-moz-outline-radius-topright',
  145. '-ms-grid-columns',
  146. '-ms-grid-rows',
  147. '-webkit-line-clamp',
  148. '-webkit-text-fill-color',
  149. '-webkit-text-stroke',
  150. '-webkit-text-stroke-color',
  151. 'accent-color',
  152. 'all',
  153. 'backdrop-filter',
  154. 'background',
  155. 'background-color',
  156. 'background-position',
  157. 'background-size',
  158. 'block-size',
  159. 'border',
  160. 'border-block-end',
  161. 'border-block-end-color',
  162. 'border-block-end-width',
  163. 'border-block-start',
  164. 'border-block-start-color',
  165. 'border-block-start-width',
  166. 'border-bottom',
  167. 'border-bottom-color',
  168. 'border-bottom-left-radius',
  169. 'border-bottom-right-radius',
  170. 'border-bottom-width',
  171. 'border-color',
  172. 'border-end-end-radius',
  173. 'border-end-start-radius',
  174. 'border-image-outset',
  175. 'border-image-slice',
  176. 'border-image-width',
  177. 'border-inline-end',
  178. 'border-inline-end-color',
  179. 'border-inline-end-width',
  180. 'border-inline-start',
  181. 'border-inline-start-color',
  182. 'border-inline-start-width',
  183. 'border-left',
  184. 'border-left-color',
  185. 'border-left-width',
  186. 'border-radius',
  187. 'border-right',
  188. 'border-right-color',
  189. 'border-right-width',
  190. 'border-start-end-radius',
  191. 'border-start-start-radius',
  192. 'border-top',
  193. 'border-top-color',
  194. 'border-top-left-radius',
  195. 'border-top-right-radius',
  196. 'border-top-width',
  197. 'border-width',
  198. 'bottom',
  199. 'box-shadow',
  200. 'caret-color',
  201. 'clip',
  202. 'clip-path',
  203. 'color',
  204. 'column-count',
  205. 'column-gap',
  206. 'column-rule',
  207. 'column-rule-color',
  208. 'column-rule-width',
  209. 'column-width',
  210. 'columns',
  211. 'filter',
  212. 'flex',
  213. 'flex-basis',
  214. 'flex-grow',
  215. 'flex-shrink',
  216. 'font',
  217. 'font-size',
  218. 'font-size-adjust',
  219. 'font-stretch',
  220. 'font-variation-settings',
  221. 'font-weight',
  222. 'gap',
  223. 'grid-column-gap',
  224. 'grid-gap',
  225. 'grid-row-gap',
  226. 'grid-template-columns',
  227. 'grid-template-rows',
  228. 'height',
  229. 'inline-size',
  230. 'input-security',
  231. 'inset',
  232. 'inset-block',
  233. 'inset-block-end',
  234. 'inset-block-start',
  235. 'inset-inline',
  236. 'inset-inline-end',
  237. 'inset-inline-start',
  238. 'left',
  239. 'letter-spacing',
  240. 'line-clamp',
  241. 'line-height',
  242. 'margin',
  243. 'margin-block-end',
  244. 'margin-block-start',
  245. 'margin-bottom',
  246. 'margin-inline-end',
  247. 'margin-inline-start',
  248. 'margin-left',
  249. 'margin-right',
  250. 'margin-top',
  251. 'mask',
  252. 'mask-border',
  253. 'mask-position',
  254. 'mask-size',
  255. 'max-block-size',
  256. 'max-height',
  257. 'max-inline-size',
  258. 'max-lines',
  259. 'max-width',
  260. 'min-block-size',
  261. 'min-height',
  262. 'min-inline-size',
  263. 'min-width',
  264. 'object-position',
  265. 'offset',
  266. 'offset-anchor',
  267. 'offset-distance',
  268. 'offset-path',
  269. 'offset-position',
  270. 'offset-rotate',
  271. 'opacity',
  272. 'order',
  273. 'outline',
  274. 'outline-color',
  275. 'outline-offset',
  276. 'outline-width',
  277. 'padding',
  278. 'padding-block-end',
  279. 'padding-block-start',
  280. 'padding-bottom',
  281. 'padding-inline-end',
  282. 'padding-inline-start',
  283. 'padding-left',
  284. 'padding-right',
  285. 'padding-top',
  286. 'perspective',
  287. 'perspective-origin',
  288. 'right',
  289. 'rotate',
  290. 'row-gap',
  291. 'scale',
  292. 'scroll-margin',
  293. 'scroll-margin-block',
  294. 'scroll-margin-block-end',
  295. 'scroll-margin-block-start',
  296. 'scroll-margin-bottom',
  297. 'scroll-margin-inline',
  298. 'scroll-margin-inline-end',
  299. 'scroll-margin-inline-start',
  300. 'scroll-margin-left',
  301. 'scroll-margin-right',
  302. 'scroll-margin-top',
  303. 'scroll-padding',
  304. 'scroll-padding-block',
  305. 'scroll-padding-block-end',
  306. 'scroll-padding-block-start',
  307. 'scroll-padding-bottom',
  308. 'scroll-padding-inline',
  309. 'scroll-padding-inline-end',
  310. 'scroll-padding-inline-start',
  311. 'scroll-padding-left',
  312. 'scroll-padding-right',
  313. 'scroll-padding-top',
  314. 'scroll-snap-coordinate',
  315. 'scroll-snap-destination',
  316. 'scrollbar-color',
  317. 'shape-image-threshold',
  318. 'shape-margin',
  319. 'shape-outside',
  320. 'tab-size',
  321. 'text-decoration',
  322. 'text-decoration-color',
  323. 'text-decoration-thickness',
  324. 'text-emphasis',
  325. 'text-emphasis-color',
  326. 'text-indent',
  327. 'text-shadow',
  328. 'text-underline-offset',
  329. 'top',
  330. 'transform',
  331. 'transform-origin',
  332. 'translate',
  333. 'vertical-align',
  334. 'visibility',
  335. 'width',
  336. 'word-spacing',
  337. 'z-index',
  338. 'zoom',
  339. ]);
  340. function optimizeGroupPlayer(players) {
  341. switch (players.length) {
  342. case 0:
  343. return new NoopAnimationPlayer();
  344. case 1:
  345. return players[0];
  346. default:
  347. return new AnimationGroupPlayer(players);
  348. }
  349. }
  350. function normalizeKeyframes$1(normalizer, keyframes, preStyles = new Map(), postStyles = new Map()) {
  351. const errors = [];
  352. const normalizedKeyframes = [];
  353. let previousOffset = -1;
  354. let previousKeyframe = null;
  355. keyframes.forEach((kf) => {
  356. const offset = kf.get('offset');
  357. const isSameOffset = offset == previousOffset;
  358. const normalizedKeyframe = (isSameOffset && previousKeyframe) || new Map();
  359. kf.forEach((val, prop) => {
  360. let normalizedProp = prop;
  361. let normalizedValue = val;
  362. if (prop !== 'offset') {
  363. normalizedProp = normalizer.normalizePropertyName(normalizedProp, errors);
  364. switch (normalizedValue) {
  365. case _PRE_STYLE:
  366. normalizedValue = preStyles.get(prop);
  367. break;
  368. case AUTO_STYLE:
  369. normalizedValue = postStyles.get(prop);
  370. break;
  371. default:
  372. normalizedValue = normalizer.normalizeStyleValue(prop, normalizedProp, normalizedValue, errors);
  373. break;
  374. }
  375. }
  376. normalizedKeyframe.set(normalizedProp, normalizedValue);
  377. });
  378. if (!isSameOffset) {
  379. normalizedKeyframes.push(normalizedKeyframe);
  380. }
  381. previousKeyframe = normalizedKeyframe;
  382. previousOffset = offset;
  383. });
  384. if (errors.length) {
  385. throw animationFailed(errors);
  386. }
  387. return normalizedKeyframes;
  388. }
  389. function listenOnPlayer(player, eventName, event, callback) {
  390. switch (eventName) {
  391. case 'start':
  392. player.onStart(() => callback(event && copyAnimationEvent(event, 'start', player)));
  393. break;
  394. case 'done':
  395. player.onDone(() => callback(event && copyAnimationEvent(event, 'done', player)));
  396. break;
  397. case 'destroy':
  398. player.onDestroy(() => callback(event && copyAnimationEvent(event, 'destroy', player)));
  399. break;
  400. }
  401. }
  402. function copyAnimationEvent(e, phaseName, player) {
  403. const totalTime = player.totalTime;
  404. const disabled = player.disabled ? true : false;
  405. const event = makeAnimationEvent(e.element, e.triggerName, e.fromState, e.toState, phaseName || e.phaseName, totalTime == undefined ? e.totalTime : totalTime, disabled);
  406. const data = e['_data'];
  407. if (data != null) {
  408. event['_data'] = data;
  409. }
  410. return event;
  411. }
  412. function makeAnimationEvent(element, triggerName, fromState, toState, phaseName = '', totalTime = 0, disabled) {
  413. return { element, triggerName, fromState, toState, phaseName, totalTime, disabled: !!disabled };
  414. }
  415. function getOrSetDefaultValue(map, key, defaultValue) {
  416. let value = map.get(key);
  417. if (!value) {
  418. map.set(key, (value = defaultValue));
  419. }
  420. return value;
  421. }
  422. function parseTimelineCommand(command) {
  423. const separatorPos = command.indexOf(':');
  424. const id = command.substring(1, separatorPos);
  425. const action = command.slice(separatorPos + 1);
  426. return [id, action];
  427. }
  428. const documentElement = /* @__PURE__ */ (() => typeof document === 'undefined' ? null : document.documentElement)();
  429. function getParentElement(element) {
  430. const parent = element.parentNode || element.host || null; // consider host to support shadow DOM
  431. if (parent === documentElement) {
  432. return null;
  433. }
  434. return parent;
  435. }
  436. function containsVendorPrefix(prop) {
  437. // Webkit is the only real popular vendor prefix nowadays
  438. // cc: http://shouldiprefix.com/
  439. return prop.substring(1, 6) == 'ebkit'; // webkit or Webkit
  440. }
  441. let _CACHED_BODY = null;
  442. let _IS_WEBKIT = false;
  443. function validateStyleProperty(prop) {
  444. if (!_CACHED_BODY) {
  445. _CACHED_BODY = getBodyNode() || {};
  446. _IS_WEBKIT = _CACHED_BODY.style ? 'WebkitAppearance' in _CACHED_BODY.style : false;
  447. }
  448. let result = true;
  449. if (_CACHED_BODY.style && !containsVendorPrefix(prop)) {
  450. result = prop in _CACHED_BODY.style;
  451. if (!result && _IS_WEBKIT) {
  452. const camelProp = 'Webkit' + prop.charAt(0).toUpperCase() + prop.slice(1);
  453. result = camelProp in _CACHED_BODY.style;
  454. }
  455. }
  456. return result;
  457. }
  458. function validateWebAnimatableStyleProperty(prop) {
  459. return ANIMATABLE_PROP_SET.has(prop);
  460. }
  461. function getBodyNode() {
  462. if (typeof document != 'undefined') {
  463. return document.body;
  464. }
  465. return null;
  466. }
  467. function containsElement(elm1, elm2) {
  468. while (elm2) {
  469. if (elm2 === elm1) {
  470. return true;
  471. }
  472. elm2 = getParentElement(elm2);
  473. }
  474. return false;
  475. }
  476. function invokeQuery(element, selector, multi) {
  477. if (multi) {
  478. return Array.from(element.querySelectorAll(selector));
  479. }
  480. const elem = element.querySelector(selector);
  481. return elem ? [elem] : [];
  482. }
  483. const ONE_SECOND = 1000;
  484. const SUBSTITUTION_EXPR_START = '{{';
  485. const SUBSTITUTION_EXPR_END = '}}';
  486. const ENTER_CLASSNAME = 'ng-enter';
  487. const LEAVE_CLASSNAME = 'ng-leave';
  488. const NG_TRIGGER_CLASSNAME = 'ng-trigger';
  489. const NG_TRIGGER_SELECTOR = '.ng-trigger';
  490. const NG_ANIMATING_CLASSNAME = 'ng-animating';
  491. const NG_ANIMATING_SELECTOR = '.ng-animating';
  492. function resolveTimingValue(value) {
  493. if (typeof value == 'number')
  494. return value;
  495. const matches = value.match(/^(-?[\.\d]+)(m?s)/);
  496. if (!matches || matches.length < 2)
  497. return 0;
  498. return _convertTimeValueToMS(parseFloat(matches[1]), matches[2]);
  499. }
  500. function _convertTimeValueToMS(value, unit) {
  501. switch (unit) {
  502. case 's':
  503. return value * ONE_SECOND;
  504. default: // ms or something else
  505. return value;
  506. }
  507. }
  508. function resolveTiming(timings, errors, allowNegativeValues) {
  509. return timings.hasOwnProperty('duration')
  510. ? timings
  511. : parseTimeExpression(timings, errors, allowNegativeValues);
  512. }
  513. function parseTimeExpression(exp, errors, allowNegativeValues) {
  514. const regex = /^(-?[\.\d]+)(m?s)(?:\s+(-?[\.\d]+)(m?s))?(?:\s+([-a-z]+(?:\(.+?\))?))?$/i;
  515. let duration;
  516. let delay = 0;
  517. let easing = '';
  518. if (typeof exp === 'string') {
  519. const matches = exp.match(regex);
  520. if (matches === null) {
  521. errors.push(invalidTimingValue(exp));
  522. return { duration: 0, delay: 0, easing: '' };
  523. }
  524. duration = _convertTimeValueToMS(parseFloat(matches[1]), matches[2]);
  525. const delayMatch = matches[3];
  526. if (delayMatch != null) {
  527. delay = _convertTimeValueToMS(parseFloat(delayMatch), matches[4]);
  528. }
  529. const easingVal = matches[5];
  530. if (easingVal) {
  531. easing = easingVal;
  532. }
  533. }
  534. else {
  535. duration = exp;
  536. }
  537. if (!allowNegativeValues) {
  538. let containsErrors = false;
  539. let startIndex = errors.length;
  540. if (duration < 0) {
  541. errors.push(negativeStepValue());
  542. containsErrors = true;
  543. }
  544. if (delay < 0) {
  545. errors.push(negativeDelayValue());
  546. containsErrors = true;
  547. }
  548. if (containsErrors) {
  549. errors.splice(startIndex, 0, invalidTimingValue(exp));
  550. }
  551. }
  552. return { duration, delay, easing };
  553. }
  554. function normalizeKeyframes(keyframes) {
  555. if (!keyframes.length) {
  556. return [];
  557. }
  558. if (keyframes[0] instanceof Map) {
  559. return keyframes;
  560. }
  561. return keyframes.map((kf) => new Map(Object.entries(kf)));
  562. }
  563. function normalizeStyles(styles) {
  564. return Array.isArray(styles) ? new Map(...styles) : new Map(styles);
  565. }
  566. function setStyles(element, styles, formerStyles) {
  567. styles.forEach((val, prop) => {
  568. const camelProp = dashCaseToCamelCase(prop);
  569. if (formerStyles && !formerStyles.has(prop)) {
  570. formerStyles.set(prop, element.style[camelProp]);
  571. }
  572. element.style[camelProp] = val;
  573. });
  574. }
  575. function eraseStyles(element, styles) {
  576. styles.forEach((_, prop) => {
  577. const camelProp = dashCaseToCamelCase(prop);
  578. element.style[camelProp] = '';
  579. });
  580. }
  581. function normalizeAnimationEntry(steps) {
  582. if (Array.isArray(steps)) {
  583. if (steps.length == 1)
  584. return steps[0];
  585. return sequence(steps);
  586. }
  587. return steps;
  588. }
  589. function validateStyleParams(value, options, errors) {
  590. const params = options.params || {};
  591. const matches = extractStyleParams(value);
  592. if (matches.length) {
  593. matches.forEach((varName) => {
  594. if (!params.hasOwnProperty(varName)) {
  595. errors.push(invalidStyleParams(varName));
  596. }
  597. });
  598. }
  599. }
  600. const PARAM_REGEX = /* @__PURE__ */ new RegExp(`${SUBSTITUTION_EXPR_START}\\s*(.+?)\\s*${SUBSTITUTION_EXPR_END}`, 'g');
  601. function extractStyleParams(value) {
  602. let params = [];
  603. if (typeof value === 'string') {
  604. let match;
  605. while ((match = PARAM_REGEX.exec(value))) {
  606. params.push(match[1]);
  607. }
  608. PARAM_REGEX.lastIndex = 0;
  609. }
  610. return params;
  611. }
  612. function interpolateParams(value, params, errors) {
  613. const original = `${value}`;
  614. const str = original.replace(PARAM_REGEX, (_, varName) => {
  615. let localVal = params[varName];
  616. // this means that the value was never overridden by the data passed in by the user
  617. if (localVal == null) {
  618. errors.push(invalidParamValue(varName));
  619. localVal = '';
  620. }
  621. return localVal.toString();
  622. });
  623. // we do this to assert that numeric values stay as they are
  624. return str == original ? value : str;
  625. }
  626. const DASH_CASE_REGEXP = /-+([a-z0-9])/g;
  627. function dashCaseToCamelCase(input) {
  628. return input.replace(DASH_CASE_REGEXP, (...m) => m[1].toUpperCase());
  629. }
  630. function camelCaseToDashCase(input) {
  631. return input.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
  632. }
  633. function allowPreviousPlayerStylesMerge(duration, delay) {
  634. return duration === 0 || delay === 0;
  635. }
  636. function balancePreviousStylesIntoKeyframes(element, keyframes, previousStyles) {
  637. if (previousStyles.size && keyframes.length) {
  638. let startingKeyframe = keyframes[0];
  639. let missingStyleProps = [];
  640. previousStyles.forEach((val, prop) => {
  641. if (!startingKeyframe.has(prop)) {
  642. missingStyleProps.push(prop);
  643. }
  644. startingKeyframe.set(prop, val);
  645. });
  646. if (missingStyleProps.length) {
  647. for (let i = 1; i < keyframes.length; i++) {
  648. let kf = keyframes[i];
  649. missingStyleProps.forEach((prop) => kf.set(prop, computeStyle(element, prop)));
  650. }
  651. }
  652. }
  653. return keyframes;
  654. }
  655. function visitDslNode(visitor, node, context) {
  656. switch (node.type) {
  657. case AnimationMetadataType.Trigger:
  658. return visitor.visitTrigger(node, context);
  659. case AnimationMetadataType.State:
  660. return visitor.visitState(node, context);
  661. case AnimationMetadataType.Transition:
  662. return visitor.visitTransition(node, context);
  663. case AnimationMetadataType.Sequence:
  664. return visitor.visitSequence(node, context);
  665. case AnimationMetadataType.Group:
  666. return visitor.visitGroup(node, context);
  667. case AnimationMetadataType.Animate:
  668. return visitor.visitAnimate(node, context);
  669. case AnimationMetadataType.Keyframes:
  670. return visitor.visitKeyframes(node, context);
  671. case AnimationMetadataType.Style:
  672. return visitor.visitStyle(node, context);
  673. case AnimationMetadataType.Reference:
  674. return visitor.visitReference(node, context);
  675. case AnimationMetadataType.AnimateChild:
  676. return visitor.visitAnimateChild(node, context);
  677. case AnimationMetadataType.AnimateRef:
  678. return visitor.visitAnimateRef(node, context);
  679. case AnimationMetadataType.Query:
  680. return visitor.visitQuery(node, context);
  681. case AnimationMetadataType.Stagger:
  682. return visitor.visitStagger(node, context);
  683. default:
  684. throw invalidNodeType(node.type);
  685. }
  686. }
  687. function computeStyle(element, prop) {
  688. return window.getComputedStyle(element)[prop];
  689. }
  690. export { ENTER_CLASSNAME, LEAVE_CLASSNAME, NG_ANIMATING_CLASSNAME, NG_ANIMATING_SELECTOR, NG_TRIGGER_CLASSNAME, NG_TRIGGER_SELECTOR, SUBSTITUTION_EXPR_START, allowPreviousPlayerStylesMerge, balancePreviousStylesIntoKeyframes, buildingFailed, camelCaseToDashCase, computeStyle, containsElement, createAnimationFailed, dashCaseToCamelCase, eraseStyles, extractStyleParams, getOrSetDefaultValue, getParentElement, interpolateParams, invalidCssUnitValue, invalidDefinition, invalidExpression, invalidKeyframes, invalidOffset, invalidParallelAnimation, invalidQuery, invalidStagger, invalidState, invalidStyleValue, invalidTransitionAlias, invalidTrigger, invokeQuery, keyframeOffsetsOutOfOrder, keyframesMissingOffsets, listenOnPlayer, makeAnimationEvent, missingEvent, missingOrDestroyedAnimation, missingPlayer, missingTrigger, normalizeAnimationEntry, normalizeKeyframes$1 as normalizeKeyframes, normalizeKeyframes as normalizeKeyframes$1, normalizeStyles, optimizeGroupPlayer, parseTimelineCommand, registerFailed, resolveTiming, resolveTimingValue, setStyles, transitionFailed, triggerBuildFailed, triggerTransitionsFailed, unregisteredTrigger, unsupportedTriggerEvent, validateStyleParams, validateStyleProperty, validateWebAnimatableStyleProperty, validationFailed, visitDslNode };
  691. //# sourceMappingURL=util-D9FfmVnv.mjs.map