{"ast":null,"code":"import { constructFrom } from \"./constructFrom.mjs\";\nimport { isSaturday } from \"./isSaturday.mjs\";\nimport { isSunday } from \"./isSunday.mjs\";\nimport { isWeekend } from \"./isWeekend.mjs\";\nimport { toDate } from \"./toDate.mjs\";\n\n/**\n * @name addBusinessDays\n * @category Date Extension Helpers\n * @summary Add the specified number of business days (mon - fri) to the given date.\n *\n * @description\n * Add the specified number of business days (mon - fri) to the given date, ignoring weekends.\n *\n * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).\n *\n * @param date - The date to be changed\n * @param amount - The amount of business days to be added.\n *\n * @returns The new date with the business days added\n *\n * @example\n * // Add 10 business days to 1 September 2014:\n * const result = addBusinessDays(new Date(2014, 8, 1), 10)\n * //=> Mon Sep 15 2014 00:00:00 (skipped weekend days)\n */\nexport function addBusinessDays(date, amount) {\n  const _date = toDate(date);\n  const startedOnWeekend = isWeekend(_date);\n  if (isNaN(amount)) return constructFrom(date, NaN);\n  const hours = _date.getHours();\n  const sign = amount < 0 ? -1 : 1;\n  const fullWeeks = Math.trunc(amount / 5);\n  _date.setDate(_date.getDate() + fullWeeks * 7);\n\n  // Get remaining days not part of a full week\n  let restDays = Math.abs(amount % 5);\n\n  // Loops over remaining days\n  while (restDays > 0) {\n    _date.setDate(_date.getDate() + sign);\n    if (!isWeekend(_date)) restDays -= 1;\n  }\n\n  // If the date is a weekend day and we reduce a dividable of\n  // 5 from it, we land on a weekend date.\n  // To counter this, we add days accordingly to land on the next business day\n  if (startedOnWeekend && isWeekend(_date) && amount !== 0) {\n    // If we're reducing days, we want to add days until we land on a weekday\n    // If we're adding days we want to reduce days until we land on a weekday\n    if (isSaturday(_date)) _date.setDate(_date.getDate() + (sign < 0 ? 2 : -1));\n    if (isSunday(_date)) _date.setDate(_date.getDate() + (sign < 0 ? 1 : -2));\n  }\n\n  // Restore hours to avoid DST lag\n  _date.setHours(hours);\n  return _date;\n}\n\n// Fallback for modularized imports:\nexport default addBusinessDays;","map":{"version":3,"names":["constructFrom","isSaturday","isSunday","isWeekend","toDate","addBusinessDays","date","amount","_date","startedOnWeekend","isNaN","NaN","hours","getHours","sign","fullWeeks","Math","trunc","setDate","getDate","restDays","abs","setHours"],"sources":["/root/rfcontavagas_hom/12.-Servidor-local-Docker/Front-Parking-Angular/node_modules/date-fns/addBusinessDays.mjs"],"sourcesContent":["import { constructFrom } from \"./constructFrom.mjs\";\nimport { isSaturday } from \"./isSaturday.mjs\";\nimport { isSunday } from \"./isSunday.mjs\";\nimport { isWeekend } from \"./isWeekend.mjs\";\nimport { toDate } from \"./toDate.mjs\";\n\n/**\n * @name addBusinessDays\n * @category Date Extension Helpers\n * @summary Add the specified number of business days (mon - fri) to the given date.\n *\n * @description\n * Add the specified number of business days (mon - fri) to the given date, ignoring weekends.\n *\n * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).\n *\n * @param date - The date to be changed\n * @param amount - The amount of business days to be added.\n *\n * @returns The new date with the business days added\n *\n * @example\n * // Add 10 business days to 1 September 2014:\n * const result = addBusinessDays(new Date(2014, 8, 1), 10)\n * //=> Mon Sep 15 2014 00:00:00 (skipped weekend days)\n */\nexport function addBusinessDays(date, amount) {\n  const _date = toDate(date);\n  const startedOnWeekend = isWeekend(_date);\n\n  if (isNaN(amount)) return constructFrom(date, NaN);\n\n  const hours = _date.getHours();\n  const sign = amount < 0 ? -1 : 1;\n  const fullWeeks = Math.trunc(amount / 5);\n\n  _date.setDate(_date.getDate() + fullWeeks * 7);\n\n  // Get remaining days not part of a full week\n  let restDays = Math.abs(amount % 5);\n\n  // Loops over remaining days\n  while (restDays > 0) {\n    _date.setDate(_date.getDate() + sign);\n    if (!isWeekend(_date)) restDays -= 1;\n  }\n\n  // If the date is a weekend day and we reduce a dividable of\n  // 5 from it, we land on a weekend date.\n  // To counter this, we add days accordingly to land on the next business day\n  if (startedOnWeekend && isWeekend(_date) && amount !== 0) {\n    // If we're reducing days, we want to add days until we land on a weekday\n    // If we're adding days we want to reduce days until we land on a weekday\n    if (isSaturday(_date)) _date.setDate(_date.getDate() + (sign < 0 ? 2 : -1));\n    if (isSunday(_date)) _date.setDate(_date.getDate() + (sign < 0 ? 1 : -2));\n  }\n\n  // Restore hours to avoid DST lag\n  _date.setHours(hours);\n\n  return _date;\n}\n\n// Fallback for modularized imports:\nexport default addBusinessDays;\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,MAAM,QAAQ,cAAc;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAACC,IAAI,EAAEC,MAAM,EAAE;EAC5C,MAAMC,KAAK,GAAGJ,MAAM,CAACE,IAAI,CAAC;EAC1B,MAAMG,gBAAgB,GAAGN,SAAS,CAACK,KAAK,CAAC;EAEzC,IAAIE,KAAK,CAACH,MAAM,CAAC,EAAE,OAAOP,aAAa,CAACM,IAAI,EAAEK,GAAG,CAAC;EAElD,MAAMC,KAAK,GAAGJ,KAAK,CAACK,QAAQ,CAAC,CAAC;EAC9B,MAAMC,IAAI,GAAGP,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;EAChC,MAAMQ,SAAS,GAAGC,IAAI,CAACC,KAAK,CAACV,MAAM,GAAG,CAAC,CAAC;EAExCC,KAAK,CAACU,OAAO,CAACV,KAAK,CAACW,OAAO,CAAC,CAAC,GAAGJ,SAAS,GAAG,CAAC,CAAC;;EAE9C;EACA,IAAIK,QAAQ,GAAGJ,IAAI,CAACK,GAAG,CAACd,MAAM,GAAG,CAAC,CAAC;;EAEnC;EACA,OAAOa,QAAQ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