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ACA,GACA,EAAkB,EAAkB,GACpC,EAAoB,EAEf,EAAI,EAAG,EAAI,EAAgB,OAAQ,IACxC,GAAqB,EAAgB,GAAK,EAAe,GAG7D,OAAO,GAQX,EAAQ,OAAO,QAAU,SAAS,GAC9B,IAEI,OADA,EAAkB,IACX,EACT,MAAM,GACJ,OAAO,IAaf,EAAQ,OAAO,cAAgB,SAAS,EAAQ,EAAW,EAAiB,GAExE,IAAI,GAAU,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,IAClC,EAAkB,EAAkB,EAAQ,GAG3C,IAAiB,GAAmB,OAAQ,QAAS,OAAQ,MAAO,OAAQ,SAAU,WACtF,IAAiB,GAAmB,QAAS,SAAU,QAAS,OAAQ,QAAS,UAAW,YAGjG,IAAK,IAAI,EAAI,EAAG,EAAI,EAAgB,OAAQ,IACpC,EAAgB,GAAK,IACO,GAAtB,EAAgB,GAAS,EAAO,GAAK,EAAgB,GAAK,IAAM,EAAU,GACjD,EAAO,GAAK,EAAgB,GAAK,IAAM,EAAgB,IAQ9F,OAAO,EAAO,KAAK,KAAK,OAAO,QAAQ,WAAW,MA8D/C","file":"/npm/iso8601-js-period@0.2.1/iso8601.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using UglifyJS v3.1.10.\n * Original file: /npm/iso8601-js-period@0.2.1/iso8601.js\n * \n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*\n * Shared and maintained by [Nezasa](http://www.nezasa.com)\n * Published under [Apache 2.0 license](http://www.apache.org/licenses/LICENSE-2.0.html)\n * © Nezasa, 2012-2013\n *\n * ---\n *\n * Javascript library for parsing of ISO 8601 durations. Supported are durations of\n * the form P3Y6M4DT12H30M17S or PT1S or P1Y4DT1H3S etc.\n *\n * @author Nezasa AG -- https://github.com/nezasa\n * @contributor Jason \"Palamedes\" Ellis -- https://github.com/palamedes\n * @contributor mdartic -- https://github.com/mdartic\n * @contributor murb -- https://github.com/murb\n */\n\n\n// if the module has no dependencies, the above pattern can be simplified to\n(function (root, factory) {\n    if (typeof define === 'function' && define.amd) {\n        // AMD. Register as an anonymous module.\n        define([], factory);\n    } else if (typeof module === 'object' && module.exports) {\n        // Node. Does not work with strict CommonJS, but\n        // only CommonJS-like environments that support module.exports,\n        // like Node.\n        module.exports = factory();\n    } else {\n        // Browser globals (root is window)\n        // maintaining nezasa global\n        if (!root.nezasa) root.nezasa = {};\n        if (!root.nezasa.iso8601) root.nezasa.iso8601 = factory();\n    }\n}(this, function () {\n    var iso8601 = {\n        Period: {}\n    };\n\n    // create sub packages\n\n    //---- public properties\n\n    /**\n     * version of the ISO8601 version\n     */\n    iso8601.version = '0.2';\n\n    //---- public methods\n\n    /**\n     * Returns an array of the duration per unit. The normalized sum of all array elements\n     * represents the total duration.\n     *\n     * - array[0]: years\n     * - array[1]: months\n     * - array[2]: weeks\n     * - array[3]: days\n     * - array[4]: hours\n     * - array[5]: minutes\n     * - array[6]: seconds\n     *\n     * @param period iso8601 period string\n     * @param distributeOverflow if 'true', the unit overflows are merge into the next higher units. Defaults to 'false'.\n     */\n    iso8601.Period.parse = function(period, distributeOverflow) {\n        return parsePeriodString(period, distributeOverflow);\n    };\n\n    /**\n     * Returns the total duration of the period in seconds.\n     */\n    iso8601.Period.parseToTotalSeconds = function(period) {\n\n        var multiplicators = [31104000 /* year   (360*24*60*60) */,\n            2592000  /* month  (30*24*60*60) */,\n            604800   /* week   (24*60*60*7) */,\n            86400    /* day    (24*60*60) */,\n            3600     /* hour   (60*60) */,\n            60       /* minute (60) */,\n            1        /* second (1) */];\n        var durationPerUnit = parsePeriodString(period);\n        var durationInSeconds = 0;\n\n        for (var i = 0; i < durationPerUnit.length; i++) {\n            durationInSeconds += durationPerUnit[i] * multiplicators[i];\n        }\n\n        return durationInSeconds;\n    };\n\n    /**\n     * Return boolean based on validity of period\n     * @param period\n     * @return {Boolean}\n     */\n    iso8601.Period.isValid = function(period) {\n        try {\n            parsePeriodString(period);\n            return true;\n        } catch(e) {\n            return false;\n        }\n    }\n\n    /**\n     * Returns a more readable string representation of the ISO8601 period.\n     * @param period the ISO8601 period string\n     * @param unitName the names of the time units if there is only one (such as hour or minute).\n     *        Defaults to ['year', 'month', 'week', 'day', 'hour', 'minute', 'second'].\n     * @param unitNamePlural thenames of the time units if there are several (such as hours or minutes).\n     *        Defaults to ['years', 'months', 'weeks', 'days', 'hours', 'minutes', 'seconds'].\n     * @param distributeOverflow if 'true', the unit overflows are merge into the next higher units. Defaults to 'false'.\n     */\n    iso8601.Period.parseToString = function(period, unitNames, unitNamesPlural, distributeOverflow) {\n\n        var result = ['', '', '', '', '', '', ''];\n        var durationPerUnit = parsePeriodString(period, distributeOverflow);\n\n        // input validation (use english as default)\n        if (!unitNames)       unitNames       = ['year', 'month', 'week', 'day', 'hour', 'minute', 'second'];\n        if (!unitNamesPlural) unitNamesPlural = ['years', 'months', 'weeks', 'days', 'hours', 'minutes', 'seconds'];\n\n        // assemble string per unit\n        for (var i = 0; i < durationPerUnit.length; i++) {\n            if (durationPerUnit[i] > 0) {\n                if   (durationPerUnit[i] == 1) result[i] = durationPerUnit[i] + \" \" + unitNames[i];\n                else                           result[i] = durationPerUnit[i] + \" \" + unitNamesPlural[i];\n            }\n        }\n\n        // trim because of space at very end and because of join(\" \")\n        // replace double spaces because of join(\" \") and empty strings\n        // Its actually possible to get more than 2 spaces in a row,\n        //   so lets get 2+ spaces and remove them\n        return result.join(' ').trim().replace(/[ ]{2,}/g,' ');\n    };\n\n    //---- private methods\n\n    /**\n     * Parses a ISO8601 period string.\n     * @param period iso8601 period string\n     * @param _distributeOverflow if 'true', the unit overflows are merge into the next higher units.\n     */\n    function parsePeriodString(period, _distributeOverflow) {\n\n        // regex splits as follows\n        // grp0 omitted as it is equal to the sample\n        //\n        // | sample            | grp1   | grp2 | grp3 | grp4 | grp5 | grp6       | grp7 | grp8 | grp9 |\n        // --------------------------------------------------------------------------------------------\n        // | P1Y2M3W           | 1Y2M3W | 1Y   | 2M   | 3W   | 4D   | T12H30M17S | 12H  | 30M  | 17S  |\n        // | P3Y6M4DT12H30M17S | 3Y6M4D | 3Y   | 6M   |      | 4D   | T12H30M17S | 12H  | 30M  | 17S  |\n        // | P1M               | 1M     |      | 1M   |      |      |            |      |      |      |\n        // | PT1M              | 3Y6M4D |      |      |      |      | T1M        |      | 1M   |      |\n        // --------------------------------------------------------------------------------------------\n\n        var distributeOverflow = (_distributeOverflow) ? _distributeOverflow : false;\n        var valueIndexes       = [2, 3, 4, 5, 7, 8, 9];\n        var duration           = [0, 0, 0, 0, 0, 0, 0];\n        var overflowLimits     = [0, 12, 4, 7, 24, 60, 60];\n        var struct;\n\n        // upcase the string just in case people don't follow the letter of the law\n        period = period.toUpperCase();\n\n        // input validation\n        if (!period)                         return duration;\n        else if (typeof period !== \"string\") throw new Error(\"Invalid iso8601 period string '\" + period + \"'\");\n\n        // parse the string\n        if (struct = /^P((\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?)?(T(\\d+H)?(\\d+M)?(\\d+S)?)?$/.exec(period)) {\n\n            // remove letters, replace by 0 if not defined\n            for (var i = 0; i < valueIndexes.length; i++) {\n                var structIndex = valueIndexes[i];\n                duration[i] = struct[structIndex] ? +struct[structIndex].replace(/[A-Za-z]+/g, '') : 0;\n            }\n        }\n        else {\n            throw new Error(\"String '\" + period + \"' is not a valid ISO8601 period.\");\n        }\n\n        if (distributeOverflow) {\n            // note: stop at 1 to ignore overflow of years\n            for (var i = duration.length - 1; i > 0; i--) {\n                if (duration[i] >= overflowLimits[i]) {\n                    duration[i-1] = duration[i-1] + Math.floor(duration[i]/overflowLimits[i]);\n                    duration[i] = duration[i] % overflowLimits[i];\n                }\n            }\n        }\n\n        return duration;\n    };\n\n    return iso8601;\n\n}));\n\n\n"]}