From 6d94385a414eee134e626984b4a5175f0943fd95 Mon Sep 17 00:00:00 2001 From: Vijayee Kulkaa Date: Sun, 24 Jun 2018 14:58:11 -0500 Subject: [PATCH] Windows Error Fixed --- .gitignore | 4 +- package-lock.json | 675 +- package.json | 16 +- src/block-cache.js | 2 +- src/electron/views/configuration/index.js | 12647 ++++++++-------- src/electron/views/configuration/network.vue | 1 - src/electron/views/connect/index.js | 1250 +- src/electron/views/export/export.vue | 4 +- src/electron/views/export/index.js | 12653 ++++++++--------- src/electron/views/import/import.vue | 8 +- src/electron/views/import/index.js | 1265 +- src/index.js | 2 +- src/readable-off-stream.js | 8 +- src/scheduler.js | 2 +- src/writable-off-stream.js | 3 - 15 files changed, 13298 insertions(+), 15242 deletions(-) diff --git a/.gitignore b/.gitignore index 099f02a..e7974a7 100755 --- a/.gitignore +++ b/.gitignore @@ -9,9 +9,11 @@ /node2 /~ js-offs-linux-x64/ +js-offs-linux-ia32/ js-offs-win32-x64/ js-offs-darwin-x64/ js-offs-win32-x64.zip -js-offs-win32-x64.zip +js-offs-darwin-x64.zip js-offs-linux-x64.zip +js-offs-linux-ia32.zip diff --git a/package-lock.json b/package-lock.json index 8022f9d..a7fdae4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,14 +5,14 @@ "requires": true, "dependencies": { "@types/node": { - "version": "7.0.48", - "resolved": "https://registry.npmjs.org/@types/node/-/node-7.0.48.tgz", - "integrity": "sha512-LLlXafM3BD52MH056tHxTXO8JFCnpJJQkdzIU3+m8ew+CXJY/5zIXgDNb4TK/QFvlI8QexLS5tL+sE0Qhegr1w==" + "version": "8.10.20", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.20.tgz", + "integrity": "sha512-M7x8+5D1k/CuA6jhiwuSCmE8sbUWJF0wYsjcig9WrXvwUI5ArEoUBdOXpV4JcEMrLp02/QbDjw+kI+vQeKyQgg==" }, "JSONStream": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", - "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.3.tgz", + "integrity": "sha512-3Sp6WZZ/lXl+nTDoGpGWHEpTnnC6X5fnkolYZR6nwIfzbxxvA8utPWe1gCt7i0m9uVGsSz2IS8K8mJ7HmlduMg==", "dev": true, "requires": { "jsonparse": "1.3.1", @@ -39,6 +39,40 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.1.2.tgz", "integrity": "sha512-o96FZLJBPY1lvTuJylGA9Bk3t/GKPPJG8H0ydQQl01crzwJgspa4AEIq/pVTXigmK0PHVQhiAtn8WMBLL9D2WA==" }, + "acorn-dynamic-import": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-3.0.0.tgz", + "integrity": "sha512-zVWV8Z8lislJoOKKqdNMOB+s6+XV5WERty8MnKBeFgwA+19XJjJHs2RP5dzM57FftIs+jQnRToLiWazKr6sSWg==", + "dev": true, + "requires": { + "acorn": "5.1.2" + } + }, + "acorn-node": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.5.2.tgz", + "integrity": "sha512-krFKvw/d1F17AN3XZbybIUzEY4YEPNiGo05AfP3dBlfVKrMHETKpgjpuZkSF8qDNt9UkQcqj7am8yJLseklCMg==", + "dev": true, + "requires": { + "acorn": "5.7.1", + "acorn-dynamic-import": "3.0.0", + "xtend": "4.0.1" + }, + "dependencies": { + "acorn": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.1.tgz", + "integrity": "sha512-d+nbxBUGKg7Arpsvbnlq61mc12ek3EY8EQldM3GPAhWJ1UVxC6TDGbIvUMNU6obBX3i1+ptCIzV4vq0gFPEGVQ==", + "dev": true + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + } + } + }, "ajv": { "version": "4.11.8", "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", @@ -237,14 +271,14 @@ "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=" }, "asn1.js": { - "version": "4.9.1", - "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.9.1.tgz", - "integrity": "sha1-SLokC0WpKA6UdImQull9IWYX/UA=", + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", + "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", "dev": true, "requires": { "bn.js": "4.11.8", "inherits": "2.0.3", - "minimalistic-assert": "1.0.0" + "minimalistic-assert": "1.0.1" } }, "assert": { @@ -254,6 +288,23 @@ "dev": true, "requires": { "util": "0.10.3" + }, + "dependencies": { + "inherits": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", + "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", + "dev": true + }, + "util": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", + "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", + "dev": true, + "requires": { + "inherits": "2.0.1" + } + } } }, "assert-plus": { @@ -267,23 +318,6 @@ "integrity": "sha1-E8pRXYYgbaC6xm6DTdOX2HWBCUw=", "dev": true }, - "astw": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/astw/-/astw-2.2.0.tgz", - "integrity": "sha1-e9QXhNMkk5h66yOba04cV6hzuRc=", - "dev": true, - "requires": { - "acorn": "4.0.13" - }, - "dependencies": { - "acorn": { - "version": "4.0.13", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz", - "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=", - "dev": true - } - } - }, "async": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", @@ -928,9 +962,9 @@ "integrity": "sha1-QtPXF0dPnqAiB/bRqh9CaRPut6w=" }, "base64-js": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.1.tgz", - "integrity": "sha512-dwVUVIXsBZXwTuwnXI9RK8sBmgq09NDHzyR9SAph9eqk76gKK2JSQmZARC2zRC81JC2QTtxD0ARU5qTS25gIGw==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", + "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==", "dev": true }, "bcrypt-pbkdf": { @@ -1035,22 +1069,23 @@ "dev": true }, "browser-pack": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.0.2.tgz", - "integrity": "sha1-+GzWzvT1MAyOY+B6TVEvZfv/RTE=", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.1.0.tgz", + "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==", "dev": true, "requires": { - "JSONStream": "1.3.1", - "combine-source-map": "0.7.2", + "JSONStream": "1.3.3", + "combine-source-map": "0.8.0", "defined": "1.0.0", + "safe-buffer": "5.1.1", "through2": "2.0.1", - "umd": "3.0.1" + "umd": "3.0.3" } }, "browser-resolve": { - "version": "1.11.2", - "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.2.tgz", - "integrity": "sha1-j/CbCixCFxihBRwmCzLkj0QpOM4=", + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.3.tgz", + "integrity": "sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ==", "dev": true, "requires": { "resolve": "1.1.7" @@ -1071,22 +1106,22 @@ "dev": true }, "browserify": { - "version": "14.3.0", - "resolved": "https://registry.npmjs.org/browserify/-/browserify-14.3.0.tgz", - "integrity": "sha1-/QA6I4asGuwSfwl4haPMY3O3RcQ=", + "version": "14.5.0", + "resolved": "https://registry.npmjs.org/browserify/-/browserify-14.5.0.tgz", + "integrity": "sha512-gKfOsNQv/toWz+60nSPfYzuwSEdzvV2WdxrVPUbPD/qui44rAkB3t3muNtmmGYHqrG56FGwX9SUEQmzNLAeS7g==", "dev": true, "requires": { - "JSONStream": "1.3.1", + "JSONStream": "1.3.3", "assert": "1.4.1", - "browser-pack": "6.0.2", - "browser-resolve": "1.11.2", - "browserify-zlib": "0.1.4", - "buffer": "5.0.8", + "browser-pack": "6.1.0", + "browser-resolve": "1.11.3", + "browserify-zlib": "0.2.0", + "buffer": "5.1.0", "cached-path-relative": "1.0.1", "concat-stream": "1.5.2", "console-browserify": "1.1.0", "constants-browserify": "1.0.0", - "crypto-browserify": "3.11.1", + "crypto-browserify": "3.12.0", "defined": "1.0.0", "deps-sort": "2.0.0", "domain-browser": "1.1.7", @@ -1097,12 +1132,12 @@ "htmlescape": "1.1.1", "https-browserify": "1.0.0", "inherits": "2.0.3", - "insert-module-globals": "7.0.1", - "labeled-stream-splicer": "2.0.0", + "insert-module-globals": "7.2.0", + "labeled-stream-splicer": "2.0.1", "module-deps": "4.1.1", - "os-browserify": "0.1.2", + "os-browserify": "0.3.0", "parents": "1.0.1", - "path-browserify": "0.0.0", + "path-browserify": "0.0.1", "process": "0.11.10", "punycode": "1.4.1", "querystring-es3": "0.2.1", @@ -1112,15 +1147,15 @@ "shasum": "1.0.2", "shell-quote": "1.6.1", "stream-browserify": "2.0.1", - "stream-http": "2.7.2", - "string_decoder": "0.10.31", + "stream-http": "2.8.3", + "string_decoder": "1.0.3", "subarg": "1.0.0", - "syntax-error": "1.3.0", + "syntax-error": "1.4.0", "through2": "2.0.1", "timers-browserify": "1.4.2", - "tty-browserify": "0.0.0", + "tty-browserify": "0.0.1", "url": "0.11.0", - "util": "0.10.3", + "util": "0.10.4", "vm-browserify": "0.0.4", "xtend": "4.0.1" }, @@ -1149,6 +1184,12 @@ "string_decoder": "0.10.31", "util-deprecate": "1.0.2" } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true } } }, @@ -1161,6 +1202,15 @@ "readable-stream": "2.1.4" } }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, "xtend": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", @@ -1170,14 +1220,14 @@ } }, "browserify-aes": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.1.1.tgz", - "integrity": "sha512-UGnTYAnB2a3YuYKIRy1/4FB2HdM866E0qC46JXvVTYKlBlZlnvfpSfY6OKfXZAkv70eJ2a1SqzpAo5CRhZGDFg==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", + "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "dev": true, "requires": { "buffer-xor": "1.0.3", "cipher-base": "1.0.4", - "create-hash": "1.1.3", + "create-hash": "1.2.0", "evp_bytestokey": "1.0.3", "inherits": "2.0.3", "safe-buffer": "5.1.1" @@ -1192,20 +1242,20 @@ } }, "browserify-cipher": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.0.tgz", - "integrity": "sha1-mYgkSHS/XtTijalWZtzWasj8Njo=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", + "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", "dev": true, "requires": { - "browserify-aes": "1.1.1", - "browserify-des": "1.0.0", + "browserify-aes": "1.2.0", + "browserify-des": "1.0.1", "evp_bytestokey": "1.0.3" } }, "browserify-des": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.0.tgz", - "integrity": "sha1-2qJ3cXRwki7S/hhZQRihdUOXId0=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.1.tgz", + "integrity": "sha512-zy0Cobe3hhgpiOM32Tj7KQ3Vl91m0njwsjzZQK1L+JDf11dzP9qIvjreVinsvXrgfjhStXwUWAEpB9D7Gwmayw==", "dev": true, "requires": { "cipher-base": "1.0.4", @@ -1220,7 +1270,7 @@ "dev": true, "requires": { "bn.js": "4.11.8", - "randombytes": "2.0.5" + "randombytes": "2.0.6" } }, "browserify-sign": { @@ -1231,20 +1281,20 @@ "requires": { "bn.js": "4.11.8", "browserify-rsa": "4.0.1", - "create-hash": "1.1.3", - "create-hmac": "1.1.6", + "create-hash": "1.2.0", + "create-hmac": "1.1.7", "elliptic": "6.4.0", "inherits": "2.0.3", - "parse-asn1": "5.1.0" + "parse-asn1": "5.1.1" } }, "browserify-zlib": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.1.4.tgz", - "integrity": "sha1-uzX4pRn2AOD6a4SFJByXnQFB+y0=", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", + "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", "dev": true, "requires": { - "pako": "0.2.9" + "pako": "1.0.6" } }, "browserslist": { @@ -1266,13 +1316,13 @@ } }, "buffer": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.0.8.tgz", - "integrity": "sha512-xXvjQhVNz50v2nPeoOsNqWCLGfiv4ji/gXZM28jnVwdLJxH4mFyqgqCKfaK9zf1KUbG6zTkjLOy7ou+jSMarGA==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.1.0.tgz", + "integrity": "sha512-YkIRgwsZwJWTnyQrsBTWefizHh+8GYj3kbL1BTiAQ/9pwpino0G7B2gp5tx/FUBqUlvtxV85KNR3mwfAtv15Yw==", "dev": true, "requires": { - "base64-js": "1.2.1", - "ieee754": "1.1.8" + "base64-js": "1.3.0", + "ieee754": "1.1.12" } }, "buffer-equal": { @@ -1280,6 +1330,12 @@ "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-0.0.1.tgz", "integrity": "sha1-kbx0sR6kBbyRa8aqkI+q+ltKrEs=" }, + "buffer-from": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.0.tgz", + "integrity": "sha512-c5mRlguI/Pe2dSZmpER62rSCu0ryKmWddzRYsuXc50U2/g8jMOulc31VZMa4mYx31U5xsmSOpDCgH88Vl9cDGQ==", + "dev": true + }, "buffer-indexof": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/buffer-indexof/-/buffer-indexof-0.0.2.tgz", @@ -1590,9 +1646,9 @@ "integrity": "sha1-nLFpkX7F0SwHNtPoaFdG3xyt93g=" }, "combine-source-map": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.7.2.tgz", - "integrity": "sha1-CHAxKFazB6h8xKxIbzqaYq7MwJ4=", + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.8.0.tgz", + "integrity": "sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos=", "dev": true, "requires": { "convert-source-map": "1.1.3", @@ -1727,9 +1783,9 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, "create-ecdh": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.0.tgz", - "integrity": "sha1-iIxyNZbN92EvZJgjPuvXo1MBc30=", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", + "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", "dev": true, "requires": { "bn.js": "4.11.8", @@ -1737,29 +1793,30 @@ } }, "create-hash": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.1.3.tgz", - "integrity": "sha1-YGBCrIuSYnUPSDyt2rD1gZFy2P0=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", + "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "dev": true, "requires": { "cipher-base": "1.0.4", "inherits": "2.0.3", - "ripemd160": "2.0.1", - "sha.js": "2.4.9" + "md5.js": "1.3.4", + "ripemd160": "2.0.2", + "sha.js": "2.4.11" } }, "create-hmac": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.6.tgz", - "integrity": "sha1-rLniIaThe9sHbpBlfEK5PjcmzwY=", + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "dev": true, "requires": { "cipher-base": "1.0.4", - "create-hash": "1.1.3", + "create-hash": "1.2.0", "inherits": "2.0.3", - "ripemd160": "2.0.1", + "ripemd160": "2.0.2", "safe-buffer": "5.1.1", - "sha.js": "2.4.9" + "sha.js": "2.4.11" } }, "cron": { @@ -1800,21 +1857,22 @@ } }, "crypto-browserify": { - "version": "3.11.1", - "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.11.1.tgz", - "integrity": "sha512-Na7ZlwCOqoaW5RwUK1WpXws2kv8mNhWdTlzob0UXulk6G9BDbyiJaGTYBIX61Ozn9l1EPPJpICZb4DaOpT9NlQ==", + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", + "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", "dev": true, "requires": { - "browserify-cipher": "1.0.0", + "browserify-cipher": "1.0.1", "browserify-sign": "4.0.4", - "create-ecdh": "4.0.0", - "create-hash": "1.1.3", - "create-hmac": "1.1.6", - "diffie-hellman": "5.0.2", + "create-ecdh": "4.0.3", + "create-hash": "1.2.0", + "create-hmac": "1.1.7", + "diffie-hellman": "5.0.3", "inherits": "2.0.3", - "pbkdf2": "3.0.14", - "public-encrypt": "4.0.0", - "randombytes": "2.0.5" + "pbkdf2": "3.0.16", + "public-encrypt": "4.0.2", + "randombytes": "2.0.6", + "randomfill": "1.0.4" } }, "css-color-names": { @@ -1942,8 +2000,7 @@ "de-indent": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/de-indent/-/de-indent-1.0.2.tgz", - "integrity": "sha1-sgOOhG3DO6pXlhKNCAS0VbjB4h0=", - "dev": true + "integrity": "sha1-sgOOhG3DO6pXlhKNCAS0VbjB4h0=" }, "debug": { "version": "2.6.8", @@ -2062,7 +2119,7 @@ "integrity": "sha1-CRckkC6EZYJg65EHSMzNGvbiH7U=", "dev": true, "requires": { - "JSONStream": "1.3.1", + "JSONStream": "1.3.3", "shasum": "1.0.2", "subarg": "1.0.0", "through2": "2.0.1" @@ -2075,7 +2132,7 @@ "dev": true, "requires": { "inherits": "2.0.3", - "minimalistic-assert": "1.0.0" + "minimalistic-assert": "1.0.1" } }, "destroy": { @@ -2102,19 +2159,19 @@ } }, "detective": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/detective/-/detective-4.5.0.tgz", - "integrity": "sha1-blqMaybmx6JUsca210kNmOyR7dE=", + "version": "4.7.1", + "resolved": "https://registry.npmjs.org/detective/-/detective-4.7.1.tgz", + "integrity": "sha512-H6PmeeUcZloWtdt4DAkFyzFL94arpHr3NOwwmVILFiy+9Qd4JTxxXrzfyGk/lmct2qVGBwTSwSXagqu2BxmWig==", "dev": true, "requires": { - "acorn": "4.0.13", + "acorn": "5.7.1", "defined": "1.0.0" }, "dependencies": { "acorn": { - "version": "4.0.13", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz", - "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=", + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.1.tgz", + "integrity": "sha512-d+nbxBUGKg7Arpsvbnlq61mc12ek3EY8EQldM3GPAhWJ1UVxC6TDGbIvUMNU6obBX3i1+ptCIzV4vq0gFPEGVQ==", "dev": true } } @@ -2126,14 +2183,14 @@ "dev": true }, "diffie-hellman": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.2.tgz", - "integrity": "sha1-tYNXOScM/ias9jIJn97SoH8gnl4=", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", "dev": true, "requires": { "bn.js": "4.11.8", "miller-rabin": "4.0.1", - "randombytes": "2.0.5" + "randombytes": "2.0.6" } }, "domain-browser": { @@ -2183,11 +2240,11 @@ "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" }, "electron": { - "version": "1.7.9", - "resolved": "https://registry.npmjs.org/electron/-/electron-1.7.9.tgz", - "integrity": "sha1-rdVOn4+D7QL2UZ7BATX2mLGTNs8=", + "version": "1.8.7", + "resolved": "https://registry.npmjs.org/electron/-/electron-1.8.7.tgz", + "integrity": "sha512-q6dn8bspX8u8z6tNU4bEas6ZrdNavnrjJ6d/oz49Nb4zFIPrdh8p29AFjFlSAavypGwAVR/PhYOAGwzZSQSSVQ==", "requires": { - "@types/node": "7.0.48", + "@types/node": "8.10.20", "electron-download": "3.3.0", "extract-zip": "1.6.5" } @@ -2370,10 +2427,10 @@ "requires": { "bn.js": "4.11.8", "brorand": "1.1.0", - "hash.js": "1.1.3", + "hash.js": "1.1.4", "hmac-drbg": "1.0.1", "inherits": "2.0.3", - "minimalistic-assert": "1.0.0", + "minimalistic-assert": "1.0.1", "minimalistic-crypto-utils": "1.0.1" } }, @@ -2962,6 +3019,12 @@ "is-property": "1.0.2" } }, + "get-assigned-identifiers": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz", + "integrity": "sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ==", + "dev": true + }, "get-folder-size": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/get-folder-size/-/get-folder-size-1.0.0.tgz", @@ -3432,12 +3495,13 @@ "dev": true }, "hash-base": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-2.0.2.tgz", - "integrity": "sha1-ZuodhW206KVHDK32/OI65SRO8uE=", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", + "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", "dev": true, "requires": { - "inherits": "2.0.3" + "inherits": "2.0.3", + "safe-buffer": "5.1.1" } }, "hash-sum": { @@ -3447,13 +3511,13 @@ "dev": true }, "hash.js": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", - "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.4.tgz", + "integrity": "sha512-A6RlQvvZEtFS5fLU43IDu0QUmBy+fDO9VMdTXvufKwIkt/rFfvICAViCax5fbDO4zdNzaC3/27ZhKUok5bAJyw==", "dev": true, "requires": { "inherits": "2.0.3", - "minimalistic-assert": "1.0.0" + "minimalistic-assert": "1.0.1" } }, "hawk": { @@ -3470,8 +3534,7 @@ "he": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", - "dev": true + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=" }, "hmac-drbg": { "version": "1.0.1", @@ -3479,8 +3542,8 @@ "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", "dev": true, "requires": { - "hash.js": "1.1.3", - "minimalistic-assert": "1.0.0", + "hash.js": "1.1.4", + "minimalistic-assert": "1.0.1", "minimalistic-crypto-utils": "1.0.1" } }, @@ -3562,9 +3625,9 @@ "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" }, "ieee754": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.8.tgz", - "integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q=", + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.12.tgz", + "integrity": "sha512-GguP+DRY+pJ3soyIiGPTvdiVXjZ+DbXOxGpXn3eMvNW4x4irjqXm4wHKscC+TfxSJ0yw/S1F24tqdMNsMZTiLA==", "dev": true }, "increment-buffer": { @@ -3629,46 +3692,65 @@ } }, "insert-module-globals": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.0.1.tgz", - "integrity": "sha1-wDv04BywhtW15azorQr+eInWOMM=", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.2.0.tgz", + "integrity": "sha512-VE6NlW+WGn2/AeOMd496AHFYmE7eLKkUY6Ty31k4og5vmA3Fjuwe9v6ifH6Xx/Hz27QvdoMoviw1/pqWRB09Sw==", "dev": true, "requires": { - "JSONStream": "1.3.1", - "combine-source-map": "0.7.2", - "concat-stream": "1.5.2", + "JSONStream": "1.3.3", + "acorn-node": "1.5.2", + "combine-source-map": "0.8.0", + "concat-stream": "1.6.2", "is-buffer": "1.1.5", - "lexical-scope": "1.2.0", + "path-is-absolute": "1.0.1", "process": "0.11.10", "through2": "2.0.1", + "undeclared-identifiers": "1.1.2", "xtend": "4.0.1" }, "dependencies": { "concat-stream": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.2.tgz", - "integrity": "sha1-cIl4Yk2FavQaWnQd790mHadSwmY=", + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", "dev": true, "requires": { + "buffer-from": "1.1.0", "inherits": "2.0.3", - "readable-stream": "2.0.6", + "readable-stream": "2.3.6", "typedarray": "0.0.6" } }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", + "dev": true + }, "readable-stream": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", - "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { "core-util-is": "1.0.2", "inherits": "2.0.3", "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "string_decoder": "0.10.31", + "process-nextick-args": "2.0.0", + "safe-buffer": "5.1.1", + "string_decoder": "1.1.1", "util-deprecate": "1.0.2" } }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, "xtend": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", @@ -4103,20 +4185,20 @@ } }, "labeled-stream-splicer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.0.tgz", - "integrity": "sha1-pS4dE4AkwAuGscDJH2d5GLiuClk=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.1.tgz", + "integrity": "sha512-MC94mHZRvJ3LfykJlTUipBqenZz1pacOZEMhhQ8dMGcDHs0SBE5GbsavUXV7YtP3icBW17W0Zy1I0lfASmo9Pg==", "dev": true, "requires": { "inherits": "2.0.3", - "isarray": "0.0.1", + "isarray": "2.0.4", "stream-splicer": "2.0.0" }, "dependencies": { "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.4.tgz", + "integrity": "sha512-GMxXOiUirWg1xTKRipM0Ek07rX+ubx4nNVElTJdNLYmNO/2YrDkgJGw9CljXn+r4EWiDQg/8lsRdHyg2PJuUaA==", "dev": true } } @@ -4129,15 +4211,6 @@ "invert-kv": "1.0.0" } }, - "lexical-scope": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/lexical-scope/-/lexical-scope-1.2.0.tgz", - "integrity": "sha1-/Ope3HBKSzqHls3KQZw6CvryLfQ=", - "dev": true, - "requires": { - "astw": "2.2.0" - } - }, "liftoff": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-2.3.0.tgz", @@ -4453,18 +4526,6 @@ "requires": { "hash-base": "3.0.4", "inherits": "2.0.3" - }, - "dependencies": { - "hash-base": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", - "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", - "dev": true, - "requires": { - "inherits": "2.0.3", - "safe-buffer": "5.1.1" - } - } } }, "media-typer": { @@ -4549,9 +4610,9 @@ } }, "minimalistic-assert": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.0.tgz", - "integrity": "sha1-cCvi3aazf0g2vLP121ZkG2Sh09M=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", "dev": true }, "minimalistic-crypto-utils": { @@ -4694,12 +4755,12 @@ "integrity": "sha1-IyFYM/HaE/1gbMuAh7RIUty4If0=", "dev": true, "requires": { - "JSONStream": "1.3.1", - "browser-resolve": "1.11.2", + "JSONStream": "1.3.3", + "browser-resolve": "1.11.3", "cached-path-relative": "1.0.1", "concat-stream": "1.5.2", "defined": "1.0.0", - "detective": "4.5.0", + "detective": "4.7.1", "duplexer2": "0.1.4", "inherits": "2.0.3", "parents": "1.0.1", @@ -5141,9 +5202,9 @@ "dev": true }, "os-browserify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.1.2.tgz", - "integrity": "sha1-ScoCk+CxlZCl9d4Qx/JlphfY/lQ=", + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", + "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=", "dev": true }, "os-homedir": { @@ -5197,9 +5258,9 @@ } }, "pako": { - "version": "0.2.9", - "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz", - "integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU=", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz", + "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==", "dev": true }, "parents": { @@ -5212,16 +5273,16 @@ } }, "parse-asn1": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.0.tgz", - "integrity": "sha1-N8T5t+06tlx0gXtfJICTf7+XxxI=", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz", + "integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==", "dev": true, "requires": { - "asn1.js": "4.9.1", - "browserify-aes": "1.1.1", - "create-hash": "1.1.3", + "asn1.js": "4.10.1", + "browserify-aes": "1.2.0", + "create-hash": "1.2.0", "evp_bytestokey": "1.0.3", - "pbkdf2": "3.0.14" + "pbkdf2": "3.0.16" } }, "parse-filepath": { @@ -5267,9 +5328,9 @@ "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" }, "path-browserify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", - "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=", + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", + "integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==", "dev": true }, "path-exists": { @@ -5332,16 +5393,16 @@ } }, "pbkdf2": { - "version": "3.0.14", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.14.tgz", - "integrity": "sha512-gjsZW9O34fm0R7PaLHRJmLLVfSoesxztjPjE9o6R+qtVJij90ltg1joIovN9GKrRW3t1PzhDDG3UMEMFfZ+1wA==", + "version": "3.0.16", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.16.tgz", + "integrity": "sha512-y4CXP3thSxqf7c0qmOF+9UeOTrifiVTIM+u7NWlq+PRsHbr7r7dpCmvzrZxa96JJUNi0Y5w9VqG5ZNeCVMoDcA==", "dev": true, "requires": { - "create-hash": "1.1.3", - "create-hmac": "1.1.6", - "ripemd160": "2.0.1", + "create-hash": "1.2.0", + "create-hmac": "1.1.7", + "ripemd160": "2.0.2", "safe-buffer": "5.1.1", - "sha.js": "2.4.9" + "sha.js": "2.4.11" } }, "pend": { @@ -5838,16 +5899,16 @@ "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" }, "public-encrypt": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.0.tgz", - "integrity": "sha1-OfaZ86RlYN1eusvKaTyvfGXBjMY=", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.2.tgz", + "integrity": "sha512-4kJ5Esocg8X3h8YgJsKAuoesBgB7mqH3eowiDzMUPKiRDDE7E/BqqZD1hnTByIaAFiwAw246YEltSq7tdrOH0Q==", "dev": true, "requires": { "bn.js": "4.11.8", "browserify-rsa": "4.0.1", - "create-hash": "1.1.3", - "parse-asn1": "5.1.0", - "randombytes": "2.0.5" + "create-hash": "1.2.0", + "parse-asn1": "5.1.1", + "randombytes": "2.0.6" } }, "punycode": { @@ -5971,14 +6032,24 @@ } }, "randombytes": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.5.tgz", - "integrity": "sha512-8T7Zn1AhMsQ/HI1SjcCfT/t4ii3eAqco3yOcSzS4mozsOz69lHLsoMXmF9nZgnFanYscnSlUSgs8uZyKzpE6kg==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz", + "integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==", "dev": true, "requires": { "safe-buffer": "5.1.1" } }, + "randomfill": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", + "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", + "dev": true, + "requires": { + "randombytes": "2.0.6", + "safe-buffer": "5.1.1" + } + }, "range-parser": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", @@ -6253,12 +6324,12 @@ } }, "ripemd160": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.1.tgz", - "integrity": "sha1-D0WEKVxTo2KK9+bXmsohzlfRxuc=", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", + "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", "dev": true, "requires": { - "hash-base": "2.0.2", + "hash-base": "3.0.4", "inherits": "2.0.3" } }, @@ -6412,9 +6483,9 @@ "integrity": "sha1-gaVSFB7BBLiOic44MQOtXGZWTQg=" }, "sha.js": { - "version": "2.4.9", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.9.tgz", - "integrity": "sha512-G8zektVqbiPHrylgew9Zg1VRB1L/DtXNUVAM6q4QLy8NE3qtHlFXTf8VLL4k1Yl6c7NMjtZUTdXV+X44nFaT6A==", + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "dev": true, "requires": { "inherits": "2.0.3", @@ -6433,7 +6504,7 @@ "dev": true, "requires": { "json-stable-stringify": "0.0.1", - "sha.js": "2.4.9" + "sha.js": "2.4.11" }, "dependencies": { "json-stable-stringify": { @@ -6498,6 +6569,12 @@ } } }, + "simple-concat": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz", + "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=", + "dev": true + }, "single-line-log": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/single-line-log/-/single-line-log-1.1.2.tgz", @@ -6755,37 +6832,43 @@ "dev": true }, "stream-http": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.7.2.tgz", - "integrity": "sha512-c0yTD2rbQzXtSsFSVhtpvY/vS6u066PcXOX9kBB3mSO76RiUQzL340uJkGBWnlBg4/HZzqiUXtaVA7wcRcJgEw==", + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.3.tgz", + "integrity": "sha512-+TSkfINHDo4J+ZobQLWiMouQYB+UVYFttRA94FpEzzJ7ZdqcL4uUUQ7WkdkI4DSozGmgBUE/a47L+38PenXhUw==", "dev": true, "requires": { "builtin-status-codes": "3.0.0", "inherits": "2.0.3", - "readable-stream": "2.3.3", + "readable-stream": "2.3.6", "to-arraybuffer": "1.0.1", "xtend": "4.0.1" }, "dependencies": { + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", + "dev": true + }, "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { "core-util-is": "1.0.2", "inherits": "2.0.3", "isarray": "1.0.0", - "process-nextick-args": "1.0.7", + "process-nextick-args": "2.0.0", "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", + "string_decoder": "1.1.1", "util-deprecate": "1.0.2" } }, "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { "safe-buffer": "5.1.1" @@ -6920,20 +7003,12 @@ "dev": true }, "syntax-error": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.3.0.tgz", - "integrity": "sha1-HtkmbE1AvnXcVb+bsct3Biu5bKE=", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz", + "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==", "dev": true, "requires": { - "acorn": "4.0.13" - }, - "dependencies": { - "acorn": { - "version": "4.0.13", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz", - "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=", - "dev": true - } + "acorn-node": "1.5.2" } }, "tar": { @@ -7147,9 +7222,9 @@ } }, "tty-browserify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", - "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=", + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", + "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==", "dev": true }, "tunnel-agent": { @@ -7195,9 +7270,9 @@ } }, "umd": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.1.tgz", - "integrity": "sha1-iuVW4RAR9jwllnCKiDclnwGz1g4=", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz", + "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==", "dev": true }, "unc-path-regex": { @@ -7206,6 +7281,26 @@ "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=", "dev": true }, + "undeclared-identifiers": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/undeclared-identifiers/-/undeclared-identifiers-1.1.2.tgz", + "integrity": "sha512-13EaeocO4edF/3JKime9rD7oB6QI8llAGhgn5fKOPyfkJbRb6NFv9pYV6dFEmpa4uRjKeBqLZP8GpuzqHlKDMQ==", + "dev": true, + "requires": { + "acorn-node": "1.5.2", + "get-assigned-identifiers": "1.2.0", + "simple-concat": "1.0.0", + "xtend": "4.0.1" + }, + "dependencies": { + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + } + } + }, "uniq": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz", @@ -7256,6 +7351,11 @@ } } }, + "urldecode": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/urldecode/-/urldecode-1.0.1.tgz", + "integrity": "sha1-Z1g6UffNKZBXUY08JcSQrdeDlhc=" + }, "urlencode": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/urlencode/-/urlencode-1.1.0.tgz", @@ -7277,20 +7377,12 @@ "dev": true }, "util": { - "version": "0.10.3", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", - "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", + "version": "0.10.4", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", + "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", "dev": true, "requires": { - "inherits": "2.0.1" - }, - "dependencies": { - "inherits": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", - "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", - "dev": true - } + "inherits": "2.0.3" } }, "util-deprecate": { @@ -7337,9 +7429,9 @@ "integrity": "sha1-Z1Neu2lMHVIldFeYRmUyP1h+jTc=" }, "vee-validate": { - "version": "2.0.0-rc.25", - "resolved": "https://registry.npmjs.org/vee-validate/-/vee-validate-2.0.0-rc.25.tgz", - "integrity": "sha512-AyVIBRQAupEhct8moETwMAroGBJrSm1SWw3fBHcPtQwIoql2QQfD3OQNqjg5+eBADo+57+h2QnTs1F25CAgoDQ==" + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/vee-validate/-/vee-validate-2.0.9.tgz", + "integrity": "sha512-0qA3hrpF2jIBoEReWF8YkvG1ukJVS56+oyPTxOtb2OfB5d7iUuQiyboOOpXOvOViREHNXTsIcQ5XIQOMBff/wg==" }, "vendors": { "version": "1.0.1", @@ -7472,9 +7564,9 @@ } }, "vue": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/vue/-/vue-2.5.2.tgz", - "integrity": "sha512-Au9rf8fPkBulFHfZ406UaQDd1jH9fqGRIM+0IHilrXnJ/0TeeMH4SBkNxWf2dGevl2S3aVeu0E/WklEv0/msag==" + "version": "2.5.16", + "resolved": "https://registry.npmjs.org/vue/-/vue-2.5.16.tgz", + "integrity": "sha512-/ffmsiVuPC8PsWcFkZngdpas19ABm5mh2wA7iDqcltyCTwlgZjHGeJYOXkBMo422iPwIcviOtrTCUpSfXmToLQ==" }, "vue-hot-reload-api": { "version": "2.2.0", @@ -7488,10 +7580,9 @@ "integrity": "sha512-vLLoY452L+JBpALMP5UHum9+7nzR9PeIBCghU9ZtJ1eWm6ieUI8Zb/DI3MYxH32bxkjzYV1LRjNv4qr8d+uX/w==" }, "vue-template-compiler": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.5.2.tgz", - "integrity": "sha512-FtbqBWvEANPZaeRo09VKEF7tET4kPMtJYqwsy/Nm1fdr1zIcwcTI7CXqeraXMviczho5IjtxZ6Fab1Enm4rHmA==", - "dev": true, + "version": "2.5.16", + "resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.5.16.tgz", + "integrity": "sha512-ZbuhCcF/hTYmldoUOVcu2fcbeSAZnfzwDskGduOrnjBiIWHgELAd+R8nAtX80aZkceWDKGQ6N9/0/EUpt+l22A==", "requires": { "de-indent": "1.0.2", "he": "1.1.1" @@ -7521,7 +7612,7 @@ "source-map": "0.5.7", "through": "2.3.8", "vue-hot-reload-api": "2.2.0", - "vue-template-compiler": "2.5.2", + "vue-template-compiler": "2.5.16", "vue-template-es2015-compiler": "1.6.0" }, "dependencies": { @@ -7550,9 +7641,9 @@ } }, "vuetable-2": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/vuetable-2/-/vuetable-2-1.7.2.tgz", - "integrity": "sha512-9DRNDGt4qNhVdYs+5Vcc9B/8TwUsoEeXq1W7rDgazbkX2BqdZoV3DaZ/H6QbO2xlHBXZiwJcjPQ1k4qMe48R4w==", + "version": "1.7.5", + "resolved": "https://registry.npmjs.org/vuetable-2/-/vuetable-2-1.7.5.tgz", + "integrity": "sha512-cKLD7ufbwNZZA1exOU1U7oXC+nrXq88YwDNAPL8dR9Kk1Pj/HMvLhOr4xw/15748c4OfYxBZQvVTJh4Hnu35AA==", "dev": true, "requires": { "axios": "0.15.3" diff --git a/package.json b/package.json index 6bc6379..1ba836e 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "rebuild": "./node_modules/.bin/electron-rebuild", "build-native": "./node_modules/.bin/electron-packager ./", "build-linux-x64": "./node_modules/.bin/electron-packager ./ --platform=linux --arch=x64 --icon=src/electron/images/off-logo.png --asar=true --overwrite && zip -FS -r js-offs-linux-x64.zip js-offs-linux-x64", - "build-linux-ia36": "./node_modules/.bin/electron-packager ./ --platform=linux --arch=ia36 --icon=src/electron/images/off-logo.png --asar=true --overwrite && zip -FS -r js-offs-linux-ia36.zip js-offs-linux-ia36", + "build-linux-ia32": "./node_modules/.bin/electron-packager ./ --platform=linux --arch=ia32 --icon=src/electron/images/off-logo.png --asar=true --overwrite && zip -FS -r js-offs-linux-ia36.zip js-offs-linux-ia32", "build-windows-x64": "./node_modules/.bin/electron-packager ./ --platform=win32 --arch=x64 --icon=src/electron/images/off-logo.ico --asar=true --overwrite && zip -FS -r js-offs-win32-x64.zip js-offs-win32-x64", "build-windows-ia36": "./node_modules/.bin/electron-packager ./ --platform=win32 --arch=ia36 --icon=src/electron/images/off-logo.ico --asar=true --overwrite && zip -FS -r js-offs-win32-ia36.zip js-offs-win32-x64", "build-darwin-x64": "./node_modules/.bin/electron-packager ./ --platform=darwin --arch=x64 --icon=src/electron/images/off-logo.icns --asar=true --overwrite && zip -FS -r js-offs-darwin-x64.zip js-offs-darwin-x64" @@ -29,7 +29,7 @@ "collect-stream": "1.1.1", "cron": "1.1.1", "cuckoo-filter": "1.0.3", - "electron": "^1.7.9", + "electron": "^1.8.7", "electron-ipc-responder": "^1.0.4", "electron-positioner": "3.0.0", "end-of-stream": "1.1.0", @@ -52,15 +52,17 @@ "streamifier": "0.1.1", "through2": "2.0.1", "timer-jobs": "0.1.0", + "urldecode": "^1.0.1", "urlencode": "1.1.0", - "vee-validate": "^2.0.0-rc.25", - "vue": "^2.5.2", - "vue-router": "^3.0.1" + "vee-validate": "^2.0.9", + "vue": "^2.5.16", + "vue-router": "^3.0.1", + "vue-template-compiler": "^2.5.16" }, "devDependencies": { "babel-plugin-transform-runtime": "6.23.0", "babel-preset-es2015": "^6.24.1", - "browserify": "^14.3.0", + "browserify": "^14.5.0", "chai": "3.5.0", "electron-packager": "8.6.0", "electron-prebuilt": "1.4.13", @@ -69,6 +71,6 @@ "mocha": "3.1.2", "random-ipv4": "1.0.2", "vueify": "^9.4.1", - "vuetable-2": "^1.7.2" + "vuetable-2": "^1.7.5" } } diff --git a/src/block-cache.js b/src/block-cache.js index e2852eb..6c5d786 100644 --- a/src/block-cache.js +++ b/src/block-cache.js @@ -153,7 +153,7 @@ module.exports = contains(key, cb) { let fd = util.sanitize(key, this.path) - fs.exists(fd, cb) + fs.access(fd, (err) => cb(!err)) } content (cb) { diff --git a/src/electron/views/configuration/index.js b/src/electron/views/configuration/index.js index b75b6aa..9175b24 100644 --- a/src/electron/views/configuration/index.js +++ b/src/electron/views/configuration/index.js @@ -1,4 +1,4 @@ -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o Tue Feb 11 2014 11:30:30 - * - * @example - * // Convert string '+02014101' to date, - * // if the additional number of digits in the extended year format is 1: - * var result = toDate('+02014101', {additionalDigits: 1}) - * //=> Fri Apr 11 2014 00:00:00 - */ -function toDate (argument, dirtyOptions) { - if (arguments.length < 1) { - throw new TypeError('1 argument required, but only ' + arguments.length + ' present') - } +function Timeout(id, clearFn) { + this._id = id; + this._clearFn = clearFn; +} +Timeout.prototype.unref = Timeout.prototype.ref = function() {}; +Timeout.prototype.close = function() { + this._clearFn.call(window, this._id); +}; - if (argument === null) { - return new Date(NaN) - } +// Does not start the time, just sets up the members needed. +exports.enroll = function(item, msecs) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = msecs; +}; - var options = dirtyOptions || {}; +exports.unenroll = function(item) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = -1; +}; - var additionalDigits = options.additionalDigits === undefined ? DEFAULT_ADDITIONAL_DIGITS : Number(options.additionalDigits); - if (additionalDigits !== 2 && additionalDigits !== 1 && additionalDigits !== 0) { - throw new RangeError('additionalDigits must be 0, 1 or 2') - } +exports._unrefActive = exports.active = function(item) { + clearTimeout(item._idleTimeoutId); - // Clone the date - if (argument instanceof Date) { - // Prevent the date to lose the milliseconds when passed to new Date() in IE10 - return new Date(argument.getTime()) - } else if (typeof argument !== 'string') { - return new Date(argument) + var msecs = item._idleTimeout; + if (msecs >= 0) { + item._idleTimeoutId = setTimeout(function onTimeout() { + if (item._onTimeout) + item._onTimeout(); + }, msecs); } +}; - var dateStrings = splitDateString(argument); - - var parseYearResult = parseYear(dateStrings.date, additionalDigits); - var year = parseYearResult.year; - var restDateString = parseYearResult.restDateString; - - var date = parseDate(restDateString, year); - - if (date) { - var timestamp = date.getTime(); - var time = 0; - var offset; +// That's not how node.js implements it but the exposed api is the same. +exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) { + var id = nextImmediateId++; + var args = arguments.length < 2 ? false : slice.call(arguments, 1); - if (dateStrings.time) { - time = parseTime(dateStrings.time); - } + immediateIds[id] = true; - if (dateStrings.timezone) { - offset = parseTimezone(dateStrings.timezone); - } else { - // get offset accurate to hour in timezones that change offset - offset = new Date(timestamp + time).getTimezoneOffset(); - offset = new Date(timestamp + time + offset * MILLISECONDS_IN_MINUTE).getTimezoneOffset(); + nextTick(function onNextTick() { + if (immediateIds[id]) { + // fn.call() is faster so we optimize for the common use-case + // @see http://jsperf.com/call-apply-segu + if (args) { + fn.apply(null, args); + } else { + fn.call(null); + } + // Prevent ids from leaking + exports.clearImmediate(id); } + }); - return new Date(timestamp + time + offset * MILLISECONDS_IN_MINUTE) - } else { - return new Date(argument) - } -} + return id; +}; -function splitDateString (dateString) { - var dateStrings = {}; - var array = dateString.split(patterns.dateTimeDelimeter); - var timeString; +exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) { + delete immediateIds[id]; +}; +}).call(this,require("timers").setImmediate,require("timers").clearImmediate) +},{"process/browser.js":20,"timers":21}],22:[function(require,module,exports){ +(function (process){ +/** + * vee-validate v2.0.9 + * (c) 2018 Abdelrahman Awad + * @license MIT + */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global.VeeValidate = factory()); +}(this, (function () { 'use strict'; - if (patterns.plainTime.test(array[0])) { - dateStrings.date = null; - timeString = array[0]; - } else { - dateStrings.date = array[0]; - timeString = array[1]; + var MILLISECONDS_IN_HOUR = 3600000; + var MILLISECONDS_IN_MINUTE = 60000; + var DEFAULT_ADDITIONAL_DIGITS = 2; + var patterns = { + dateTimeDelimeter: /[T ]/, + plainTime: /:/, + YY: /^(\d{2})$/, + YYY: [/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/], + YYYY: /^(\d{4})/, + YYYYY: [/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/], + MM: /^-(\d{2})$/, + DDD: /^-?(\d{3})$/, + MMDD: /^-?(\d{2})-?(\d{2})$/, + Www: /^-?W(\d{2})$/, + WwwD: /^-?W(\d{2})-?(\d{1})$/, + HH: /^(\d{2}([.,]\d*)?)$/, + HHMM: /^(\d{2}):?(\d{2}([.,]\d*)?)$/, + HHMMSS: /^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/, + timezone: /([Z+-].*)$/, + timezoneZ: /^(Z)$/, + timezoneHH: /^([+-])(\d{2})$/, + timezoneHHMM: /^([+-])(\d{2}):?(\d{2})$/ + }; + function toDate(argument, dirtyOptions) { + if (arguments.length < 1) { + throw new TypeError('1 argument required, but only ' + arguments.length + ' present'); + } + if (argument === null) { + return new Date(NaN); + } + var options = dirtyOptions || {}; + var additionalDigits = options.additionalDigits === undefined ? DEFAULT_ADDITIONAL_DIGITS : Number(options.additionalDigits); + if (additionalDigits !== 2 && additionalDigits !== 1 && additionalDigits !== 0) { + throw new RangeError('additionalDigits must be 0, 1 or 2'); + } + if (argument instanceof Date) { + return new Date(argument.getTime()); + } else if (typeof argument !== 'string') { + return new Date(argument); + } + var dateStrings = splitDateString(argument); + var parseYearResult = parseYear(dateStrings.date, additionalDigits); + var year = parseYearResult.year; + var restDateString = parseYearResult.restDateString; + var date = parseDate(restDateString, year); + if (date) { + var timestamp = date.getTime(); + var time = 0; + var offset; + if (dateStrings.time) { + time = parseTime(dateStrings.time); + } + if (dateStrings.timezone) { + offset = parseTimezone(dateStrings.timezone); + } else { + offset = new Date(timestamp + time).getTimezoneOffset(); + offset = new Date(timestamp + time + offset * MILLISECONDS_IN_MINUTE).getTimezoneOffset(); + } + return new Date(timestamp + time + offset * MILLISECONDS_IN_MINUTE); + } else { + return new Date(argument); + } } - if (timeString) { - var token = patterns.timezone.exec(timeString); - if (token) { - dateStrings.time = timeString.replace(token[1], ''); - dateStrings.timezone = token[1]; - } else { - dateStrings.time = timeString; - } + function splitDateString(dateString) { + var dateStrings = {}; + var array = dateString.split(patterns.dateTimeDelimeter); + var timeString; + if (patterns.plainTime.test(array[0])) { + dateStrings.date = null; + timeString = array[0]; + } else { + dateStrings.date = array[0]; + timeString = array[1]; + } + if (timeString) { + var token = patterns.timezone.exec(timeString); + if (token) { + dateStrings.time = timeString.replace(token[1], ''); + dateStrings.timezone = token[1]; + } else { + dateStrings.time = timeString; + } + } + return dateStrings; + } + + function parseYear(dateString, additionalDigits) { + var patternYYY = patterns.YYY[additionalDigits]; + var patternYYYYY = patterns.YYYYY[additionalDigits]; + var token; + token = patterns.YYYY.exec(dateString) || patternYYYYY.exec(dateString); + if (token) { + var yearString = token[1]; + return { + year: parseInt(yearString, 10), + restDateString: dateString.slice(yearString.length) + }; + } + token = patterns.YY.exec(dateString) || patternYYY.exec(dateString); + if (token) { + var centuryString = token[1]; + return { + year: parseInt(centuryString, 10) * 100, + restDateString: dateString.slice(centuryString.length) + }; + } + return { + year: null + }; } - return dateStrings -} - -function parseYear (dateString, additionalDigits) { - var patternYYY = patterns.YYY[additionalDigits]; - var patternYYYYY = patterns.YYYYY[additionalDigits]; - - var token; - - // YYYY or ±YYYYY - token = patterns.YYYY.exec(dateString) || patternYYYYY.exec(dateString); - if (token) { - var yearString = token[1]; - return { - year: parseInt(yearString, 10), - restDateString: dateString.slice(yearString.length) - } + function parseDate(dateString, year) { + if (year === null) { + return null; + } + var token; + var date; + var month; + var week; + if (dateString.length === 0) { + date = new Date(0); + date.setUTCFullYear(year); + return date; + } + token = patterns.MM.exec(dateString); + if (token) { + date = new Date(0); + month = parseInt(token[1], 10) - 1; + date.setUTCFullYear(year, month); + return date; + } + token = patterns.DDD.exec(dateString); + if (token) { + date = new Date(0); + var dayOfYear = parseInt(token[1], 10); + date.setUTCFullYear(year, 0, dayOfYear); + return date; + } + token = patterns.MMDD.exec(dateString); + if (token) { + date = new Date(0); + month = parseInt(token[1], 10) - 1; + var day = parseInt(token[2], 10); + date.setUTCFullYear(year, month, day); + return date; + } + token = patterns.Www.exec(dateString); + if (token) { + week = parseInt(token[1], 10) - 1; + return dayOfISOYear(year, week); + } + token = patterns.WwwD.exec(dateString); + if (token) { + week = parseInt(token[1], 10) - 1; + var dayOfWeek = parseInt(token[2], 10) - 1; + return dayOfISOYear(year, week, dayOfWeek); + } + return null; } - // YY or ±YYY - token = patterns.YY.exec(dateString) || patternYYY.exec(dateString); - if (token) { - var centuryString = token[1]; - return { - year: parseInt(centuryString, 10) * 100, - restDateString: dateString.slice(centuryString.length) - } + function parseTime(timeString) { + var token; + var hours; + var minutes; + token = patterns.HH.exec(timeString); + if (token) { + hours = parseFloat(token[1].replace(',', '.')); + return hours % 24 * MILLISECONDS_IN_HOUR; + } + token = patterns.HHMM.exec(timeString); + if (token) { + hours = parseInt(token[1], 10); + minutes = parseFloat(token[2].replace(',', '.')); + return hours % 24 * MILLISECONDS_IN_HOUR + minutes * MILLISECONDS_IN_MINUTE; + } + token = patterns.HHMMSS.exec(timeString); + if (token) { + hours = parseInt(token[1], 10); + minutes = parseInt(token[2], 10); + var seconds = parseFloat(token[3].replace(',', '.')); + return hours % 24 * MILLISECONDS_IN_HOUR + minutes * MILLISECONDS_IN_MINUTE + seconds * 1000; + } + return null; } - // Invalid ISO-formatted year - return { - year: null + function parseTimezone(timezoneString) { + var token; + var absoluteOffset; + token = patterns.timezoneZ.exec(timezoneString); + if (token) { + return 0; + } + token = patterns.timezoneHH.exec(timezoneString); + if (token) { + absoluteOffset = parseInt(token[2], 10) * 60; + return token[1] === '+' ? -absoluteOffset : absoluteOffset; + } + token = patterns.timezoneHHMM.exec(timezoneString); + if (token) { + absoluteOffset = parseInt(token[2], 10) * 60 + parseInt(token[3], 10); + return token[1] === '+' ? -absoluteOffset : absoluteOffset; + } + return 0; } -} -function parseDate (dateString, year) { - // Invalid ISO-formatted year - if (year === null) { - return null + function dayOfISOYear(isoYear, week, day) { + week = week || 0; + day = day || 0; + var date = new Date(0); + date.setUTCFullYear(isoYear, 0, 4); + var fourthOfJanuaryDay = date.getUTCDay() || 7; + var diff = week * 7 + day + 1 - fourthOfJanuaryDay; + date.setUTCDate(date.getUTCDate() + diff); + return date; } - var token; - var date; - var month; - var week; - - // YYYY - if (dateString.length === 0) { - date = new Date(0); - date.setUTCFullYear(year); - return date + function addMilliseconds(dirtyDate, dirtyAmount, dirtyOptions) { + if (arguments.length < 2) { + throw new TypeError('2 arguments required, but only ' + arguments.length + ' present'); + } + var timestamp = toDate(dirtyDate, dirtyOptions).getTime(); + var amount = Number(dirtyAmount); + return new Date(timestamp + amount); } - // YYYY-MM - token = patterns.MM.exec(dateString); - if (token) { - date = new Date(0); - month = parseInt(token[1], 10) - 1; - date.setUTCFullYear(year, month); - return date + function cloneObject(dirtyObject) { + dirtyObject = dirtyObject || {}; + var object = {}; + for (var property in dirtyObject) { + if (dirtyObject.hasOwnProperty(property)) { + object[property] = dirtyObject[property]; + } + } + return object; } - // YYYY-DDD or YYYYDDD - token = patterns.DDD.exec(dateString); - if (token) { - date = new Date(0); - var dayOfYear = parseInt(token[1], 10); - date.setUTCFullYear(year, 0, dayOfYear); - return date + var MILLISECONDS_IN_MINUTE$2 = 60000; + function addMinutes(dirtyDate, dirtyAmount, dirtyOptions) { + if (arguments.length < 2) { + throw new TypeError('2 arguments required, but only ' + arguments.length + ' present'); + } + var amount = Number(dirtyAmount); + return addMilliseconds(dirtyDate, amount * MILLISECONDS_IN_MINUTE$2, dirtyOptions); } - // YYYY-MM-DD or YYYYMMDD - token = patterns.MMDD.exec(dateString); - if (token) { - date = new Date(0); - month = parseInt(token[1], 10) - 1; - var day = parseInt(token[2], 10); - date.setUTCFullYear(year, month, day); - return date + function isValid(dirtyDate, dirtyOptions) { + if (arguments.length < 1) { + throw new TypeError('1 argument required, but only ' + arguments.length + ' present'); + } + var date = toDate(dirtyDate, dirtyOptions); + return !isNaN(date); + } + + var formatDistanceLocale = { + lessThanXSeconds: { + one: 'less than a second', + other: 'less than {{count}} seconds' + }, + xSeconds: { + one: '1 second', + other: '{{count}} seconds' + }, + halfAMinute: 'half a minute', + lessThanXMinutes: { + one: 'less than a minute', + other: 'less than {{count}} minutes' + }, + xMinutes: { + one: '1 minute', + other: '{{count}} minutes' + }, + aboutXHours: { + one: 'about 1 hour', + other: 'about {{count}} hours' + }, + xHours: { + one: '1 hour', + other: '{{count}} hours' + }, + xDays: { + one: '1 day', + other: '{{count}} days' + }, + aboutXMonths: { + one: 'about 1 month', + other: 'about {{count}} months' + }, + xMonths: { + one: '1 month', + other: '{{count}} months' + }, + aboutXYears: { + one: 'about 1 year', + other: 'about {{count}} years' + }, + xYears: { + one: '1 year', + other: '{{count}} years' + }, + overXYears: { + one: 'over 1 year', + other: 'over {{count}} years' + }, + almostXYears: { + one: 'almost 1 year', + other: 'almost {{count}} years' + } + }; + function formatDistance(token, count, options) { + options = options || {}; + var result; + if (typeof formatDistanceLocale[token] === 'string') { + result = formatDistanceLocale[token]; + } else if (count === 1) { + result = formatDistanceLocale[token].one; + } else { + result = formatDistanceLocale[token].other.replace('{{count}}', count); + } + if (options.addSuffix) { + if (options.comparison > 0) { + return 'in ' + result; + } else { + return result + ' ago'; + } + } + return result; } - // YYYY-Www or YYYYWww - token = patterns.Www.exec(dateString); - if (token) { - week = parseInt(token[1], 10) - 1; - return dayOfISOYear(year, week) + var tokensToBeShortedPattern = /MMMM|MM|DD|dddd/g; + function buildShortLongFormat(format) { + return format.replace(tokensToBeShortedPattern, function (token) { + return token.slice(1); + }); } - // YYYY-Www-D or YYYYWwwD - token = patterns.WwwD.exec(dateString); - if (token) { - week = parseInt(token[1], 10) - 1; - var dayOfWeek = parseInt(token[2], 10) - 1; - return dayOfISOYear(year, week, dayOfWeek) + function buildFormatLongFn(obj) { + var formatLongLocale = { + LTS: obj.LTS, + LT: obj.LT, + L: obj.L, + LL: obj.LL, + LLL: obj.LLL, + LLLL: obj.LLLL, + l: obj.l || buildShortLongFormat(obj.L), + ll: obj.ll || buildShortLongFormat(obj.LL), + lll: obj.lll || buildShortLongFormat(obj.LLL), + llll: obj.llll || buildShortLongFormat(obj.LLLL) + }; + return function (token) { + return formatLongLocale[token]; + }; } - // Invalid ISO-formatted date - return null -} - -function parseTime (timeString) { - var token; - var hours; - var minutes; + var formatLong = buildFormatLongFn({ + LT: 'h:mm aa', + LTS: 'h:mm:ss aa', + L: 'MM/DD/YYYY', + LL: 'MMMM D YYYY', + LLL: 'MMMM D YYYY h:mm aa', + LLLL: 'dddd, MMMM D YYYY h:mm aa' + }); - // hh - token = patterns.HH.exec(timeString); - if (token) { - hours = parseFloat(token[1].replace(',', '.')); - return (hours % 24) * MILLISECONDS_IN_HOUR + var formatRelativeLocale = { + lastWeek: '[last] dddd [at] LT', + yesterday: '[yesterday at] LT', + today: '[today at] LT', + tomorrow: '[tomorrow at] LT', + nextWeek: 'dddd [at] LT', + other: 'L' + }; + function formatRelative(token, date, baseDate, options) { + return formatRelativeLocale[token]; } - // hh:mm or hhmm - token = patterns.HHMM.exec(timeString); - if (token) { - hours = parseInt(token[1], 10); - minutes = parseFloat(token[2].replace(',', '.')); - return (hours % 24) * MILLISECONDS_IN_HOUR + - minutes * MILLISECONDS_IN_MINUTE + function buildLocalizeFn(values, defaultType, indexCallback) { + return function (dirtyIndex, dirtyOptions) { + var options = dirtyOptions || {}; + var type = options.type ? String(options.type) : defaultType; + var valuesArray = values[type] || values[defaultType]; + var index = indexCallback ? indexCallback(Number(dirtyIndex)) : Number(dirtyIndex); + return valuesArray[index]; + }; } - // hh:mm:ss or hhmmss - token = patterns.HHMMSS.exec(timeString); - if (token) { - hours = parseInt(token[1], 10); - minutes = parseInt(token[2], 10); - var seconds = parseFloat(token[3].replace(',', '.')); - return (hours % 24) * MILLISECONDS_IN_HOUR + - minutes * MILLISECONDS_IN_MINUTE + - seconds * 1000 + function buildLocalizeArrayFn(values, defaultType) { + return function (dirtyOptions) { + var options = dirtyOptions || {}; + var type = options.type ? String(options.type) : defaultType; + return values[type] || values[defaultType]; + }; } - // Invalid ISO-formatted time - return null -} - -function parseTimezone (timezoneString) { - var token; - var absoluteOffset; + var weekdayValues = { + narrow: ['Su','Mo','Tu','We','Th','Fr','Sa'], + short: ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'], + long: ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'] + }; + var monthValues = { + short: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'], + long: ['January','February','March','April','May','June','July','August','September', + 'October','November','December'] + }; + var timeOfDayValues = { + uppercase: ['AM','PM'], + lowercase: ['am','pm'], + long: ['a.m.','p.m.'] + }; + function ordinalNumber(dirtyNumber, dirtyOptions) { + var number = Number(dirtyNumber); + var rem100 = number % 100; + if (rem100 > 20 || rem100 < 10) { + switch (rem100 % 10) { + case 1: + return number + 'st'; + case 2: + return number + 'nd'; + case 3: + return number + 'rd'; + } + } + return number + 'th'; + } + + var localize = { + ordinalNumber: ordinalNumber, + weekday: buildLocalizeFn(weekdayValues, 'long'), + weekdays: buildLocalizeArrayFn(weekdayValues, 'long'), + month: buildLocalizeFn(monthValues, 'long'), + months: buildLocalizeArrayFn(monthValues, 'long'), + timeOfDay: buildLocalizeFn(timeOfDayValues, 'long', function (hours) { + return hours / 12 >= 1 ? 1 : 0; + }), + timesOfDay: buildLocalizeArrayFn(timeOfDayValues, 'long') + }; - // Z - token = patterns.timezoneZ.exec(timezoneString); - if (token) { - return 0 + function buildMatchFn(patterns, defaultType) { + return function (dirtyString, dirtyOptions) { + var options = dirtyOptions || {}; + var type = options.type ? String(options.type) : defaultType; + var pattern = patterns[type] || patterns[defaultType]; + var string = String(dirtyString); + return string.match(pattern); + }; } - // ±hh - token = patterns.timezoneHH.exec(timezoneString); - if (token) { - absoluteOffset = parseInt(token[2], 10) * 60; - return (token[1] === '+') ? -absoluteOffset : absoluteOffset + function buildParseFn(patterns, defaultType) { + return function (matchResult, dirtyOptions) { + var options = dirtyOptions || {}; + var type = options.type ? String(options.type) : defaultType; + var patternsArray = patterns[type] || patterns[defaultType]; + var string = matchResult[1]; + return patternsArray.findIndex(function (pattern) { + return pattern.test(string); + }); + }; } - // ±hh:mm or ±hhmm - token = patterns.timezoneHHMM.exec(timezoneString); - if (token) { - absoluteOffset = parseInt(token[2], 10) * 60 + parseInt(token[3], 10); - return (token[1] === '+') ? -absoluteOffset : absoluteOffset + function buildMatchPatternFn(pattern) { + return function (dirtyString) { + var string = String(dirtyString); + return string.match(pattern); + }; } - return 0 -} - -function dayOfISOYear (isoYear, week, day) { - week = week || 0; - day = day || 0; - var date = new Date(0); - date.setUTCFullYear(isoYear, 0, 4); - var fourthOfJanuaryDay = date.getUTCDay() || 7; - var diff = week * 7 + day + 1 - fourthOfJanuaryDay; - date.setUTCDate(date.getUTCDate() + diff); - return date -} - -/** - * @name addMilliseconds - * @category Millisecond Helpers - * @summary Add the specified number of milliseconds to the given date. - * - * @description - * Add the specified number of milliseconds to the given date. - * - * @param {Date|String|Number} date - the date to be changed - * @param {Number} amount - the amount of milliseconds to be added - * @param {Options} [options] - the object with options. See [Options]{@link https://date-fns.org/docs/Options} - * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate} - * @returns {Date} the new date with the milliseconds added - * @throws {TypeError} 2 arguments required - * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 - * - * @example - * // Add 750 milliseconds to 10 July 2014 12:45:30.000: - * var result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750) - * //=> Thu Jul 10 2014 12:45:30.750 - */ -function addMilliseconds (dirtyDate, dirtyAmount, dirtyOptions) { - if (arguments.length < 2) { - throw new TypeError('2 arguments required, but only ' + arguments.length + ' present') + function parseDecimal(matchResult) { + return parseInt(matchResult[1], 10); } - var timestamp = toDate(dirtyDate, dirtyOptions).getTime(); - var amount = Number(dirtyAmount); - return new Date(timestamp + amount) -} + var matchOrdinalNumbersPattern = /^(\d+)(th|st|nd|rd)?/i; + var matchWeekdaysPatterns = { + narrow: /^(su|mo|tu|we|th|fr|sa)/i, + short: /^(sun|mon|tue|wed|thu|fri|sat)/i, + long: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i + }; + var parseWeekdayPatterns = { + any: [/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i] + }; + var matchMonthsPatterns = { + short: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i, + long: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i + }; + var parseMonthPatterns = { + any: [/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i, + /^n/i,/^d/i] + }; + var matchTimesOfDayPatterns = { + short: /^(am|pm)/i, + long: /^([ap]\.?\s?m\.?)/i + }; + var parseTimeOfDayPatterns = { + any: [/^a/i,/^p/i] + }; + var match = { + ordinalNumbers: buildMatchPatternFn(matchOrdinalNumbersPattern), + ordinalNumber: parseDecimal, + weekdays: buildMatchFn(matchWeekdaysPatterns, 'long'), + weekday: buildParseFn(parseWeekdayPatterns, 'any'), + months: buildMatchFn(matchMonthsPatterns, 'long'), + month: buildParseFn(parseMonthPatterns, 'any'), + timesOfDay: buildMatchFn(matchTimesOfDayPatterns, 'long'), + timeOfDay: buildParseFn(parseTimeOfDayPatterns, 'any') + }; -function cloneObject (dirtyObject) { - dirtyObject = dirtyObject || {}; - var object = {}; + var locale = { + formatDistance: formatDistance, + formatLong: formatLong, + formatRelative: formatRelative, + localize: localize, + match: match, + options: { + weekStartsOn: 0, + firstWeekContainsDate: 1 + } + }; - for (var property in dirtyObject) { - if (dirtyObject.hasOwnProperty(property)) { - object[property] = dirtyObject[property]; - } + var MILLISECONDS_IN_DAY$1 = 86400000; + function getUTCDayOfYear(dirtyDate, dirtyOptions) { + var date = toDate(dirtyDate, dirtyOptions); + var timestamp = date.getTime(); + date.setUTCMonth(0, 1); + date.setUTCHours(0, 0, 0, 0); + var startOfYearTimestamp = date.getTime(); + var difference = timestamp - startOfYearTimestamp; + return Math.floor(difference / MILLISECONDS_IN_DAY$1) + 1; + } + + function startOfUTCISOWeek(dirtyDate, dirtyOptions) { + var weekStartsOn = 1; + var date = toDate(dirtyDate, dirtyOptions); + var day = date.getUTCDay(); + var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; + date.setUTCDate(date.getUTCDate() - diff); + date.setUTCHours(0, 0, 0, 0); + return date; + } + + function getUTCISOWeekYear(dirtyDate, dirtyOptions) { + var date = toDate(dirtyDate, dirtyOptions); + var year = date.getUTCFullYear(); + var fourthOfJanuaryOfNextYear = new Date(0); + fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4); + fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0); + var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear, dirtyOptions); + var fourthOfJanuaryOfThisYear = new Date(0); + fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4); + fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0); + var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear, dirtyOptions); + if (date.getTime() >= startOfNextYear.getTime()) { + return year + 1; + } else if (date.getTime() >= startOfThisYear.getTime()) { + return year; + } else { + return year - 1; + } } - return object -} - -var MILLISECONDS_IN_MINUTE$2 = 60000; - -/** - * @name addMinutes - * @category Minute Helpers - * @summary Add the specified number of minutes to the given date. - * - * @description - * Add the specified number of minutes to the given date. - * - * @param {Date|String|Number} date - the date to be changed - * @param {Number} amount - the amount of minutes to be added - * @param {Options} [options] - the object with options. See [Options]{@link https://date-fns.org/docs/Options} - * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate} - * @returns {Date} the new date with the minutes added - * @throws {TypeError} 2 arguments required - * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 - * - * @example - * // Add 30 minutes to 10 July 2014 12:00:00: - * var result = addMinutes(new Date(2014, 6, 10, 12, 0), 30) - * //=> Thu Jul 10 2014 12:30:00 - */ -function addMinutes (dirtyDate, dirtyAmount, dirtyOptions) { - if (arguments.length < 2) { - throw new TypeError('2 arguments required, but only ' + arguments.length + ' present') + function startOfUTCISOWeekYear(dirtyDate, dirtyOptions) { + var year = getUTCISOWeekYear(dirtyDate, dirtyOptions); + var fourthOfJanuary = new Date(0); + fourthOfJanuary.setUTCFullYear(year, 0, 4); + fourthOfJanuary.setUTCHours(0, 0, 0, 0); + var date = startOfUTCISOWeek(fourthOfJanuary, dirtyOptions); + return date; } - var amount = Number(dirtyAmount); - return addMilliseconds(dirtyDate, amount * MILLISECONDS_IN_MINUTE$2, dirtyOptions) -} - -/** - * @name isValid - * @category Common Helpers - * @summary Is the given date valid? - * - * @description - * Returns false if argument is Invalid Date and true otherwise. - * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate} - * Invalid Date is a Date, whose time value is NaN. - * - * Time value of Date: http://es5.github.io/#x15.9.1.1 - * - * @param {*} date - the date to check - * @param {Options} [options] - the object with options. See [Options]{@link https://date-fns.org/docs/Options} - * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate} - * @returns {Boolean} the date is valid - * @throws {TypeError} 1 argument required - * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 - * - * @example - * // For the valid date: - * var result = isValid(new Date(2014, 1, 31)) - * //=> true - * - * @example - * // For the value, convertable into a date: - * var result = isValid('2014-02-31') - * //=> true - * - * @example - * // For the invalid date: - * var result = isValid(new Date('')) - * //=> false - */ -function isValid (dirtyDate, dirtyOptions) { - if (arguments.length < 1) { - throw new TypeError('1 argument required, but only ' + arguments.length + ' present') + var MILLISECONDS_IN_WEEK$2 = 604800000; + function getUTCISOWeek(dirtyDate, dirtyOptions) { + var date = toDate(dirtyDate, dirtyOptions); + var diff = startOfUTCISOWeek(date, dirtyOptions).getTime() - startOfUTCISOWeekYear(date, dirtyOptions).getTime(); + return Math.round(diff / MILLISECONDS_IN_WEEK$2) + 1; } - var date = toDate(dirtyDate, dirtyOptions); - return !isNaN(date) -} - -var formatDistanceLocale = { - lessThanXSeconds: { - one: 'less than a second', - other: 'less than {{count}} seconds' - }, - - xSeconds: { - one: '1 second', - other: '{{count}} seconds' - }, - - halfAMinute: 'half a minute', - - lessThanXMinutes: { - one: 'less than a minute', - other: 'less than {{count}} minutes' - }, - - xMinutes: { - one: '1 minute', - other: '{{count}} minutes' - }, - - aboutXHours: { - one: 'about 1 hour', - other: 'about {{count}} hours' - }, - - xHours: { - one: '1 hour', - other: '{{count}} hours' - }, - - xDays: { - one: '1 day', - other: '{{count}} days' - }, - - aboutXMonths: { - one: 'about 1 month', - other: 'about {{count}} months' - }, - - xMonths: { - one: '1 month', - other: '{{count}} months' - }, - - aboutXYears: { - one: 'about 1 year', - other: 'about {{count}} years' - }, - - xYears: { - one: '1 year', - other: '{{count}} years' - }, - - overXYears: { - one: 'over 1 year', - other: 'over {{count}} years' - }, - - almostXYears: { - one: 'almost 1 year', - other: 'almost {{count}} years' + var formatters = { + 'M': function (date) { + return date.getUTCMonth() + 1; + }, + 'Mo': function (date, options) { + var month = date.getUTCMonth() + 1; + return options.locale.localize.ordinalNumber(month, { + unit: 'month' + }); + }, + 'MM': function (date) { + return addLeadingZeros(date.getUTCMonth() + 1, 2); + }, + 'MMM': function (date, options) { + return options.locale.localize.month(date.getUTCMonth(), { + type: 'short' + }); + }, + 'MMMM': function (date, options) { + return options.locale.localize.month(date.getUTCMonth(), { + type: 'long' + }); + }, + 'Q': function (date) { + return Math.ceil((date.getUTCMonth() + 1) / 3); + }, + 'Qo': function (date, options) { + var quarter = Math.ceil((date.getUTCMonth() + 1) / 3); + return options.locale.localize.ordinalNumber(quarter, { + unit: 'quarter' + }); + }, + 'D': function (date) { + return date.getUTCDate(); + }, + 'Do': function (date, options) { + return options.locale.localize.ordinalNumber(date.getUTCDate(), { + unit: 'dayOfMonth' + }); + }, + 'DD': function (date) { + return addLeadingZeros(date.getUTCDate(), 2); + }, + 'DDD': function (date) { + return getUTCDayOfYear(date); + }, + 'DDDo': function (date, options) { + return options.locale.localize.ordinalNumber(getUTCDayOfYear(date), { + unit: 'dayOfYear' + }); + }, + 'DDDD': function (date) { + return addLeadingZeros(getUTCDayOfYear(date), 3); + }, + 'dd': function (date, options) { + return options.locale.localize.weekday(date.getUTCDay(), { + type: 'narrow' + }); + }, + 'ddd': function (date, options) { + return options.locale.localize.weekday(date.getUTCDay(), { + type: 'short' + }); + }, + 'dddd': function (date, options) { + return options.locale.localize.weekday(date.getUTCDay(), { + type: 'long' + }); + }, + 'd': function (date) { + return date.getUTCDay(); + }, + 'do': function (date, options) { + return options.locale.localize.ordinalNumber(date.getUTCDay(), { + unit: 'dayOfWeek' + }); + }, + 'E': function (date) { + return date.getUTCDay() || 7; + }, + 'W': function (date) { + return getUTCISOWeek(date); + }, + 'Wo': function (date, options) { + return options.locale.localize.ordinalNumber(getUTCISOWeek(date), { + unit: 'isoWeek' + }); + }, + 'WW': function (date) { + return addLeadingZeros(getUTCISOWeek(date), 2); + }, + 'YY': function (date) { + return addLeadingZeros(date.getUTCFullYear(), 4).substr(2); + }, + 'YYYY': function (date) { + return addLeadingZeros(date.getUTCFullYear(), 4); + }, + 'GG': function (date) { + return String(getUTCISOWeekYear(date)).substr(2); + }, + 'GGGG': function (date) { + return getUTCISOWeekYear(date); + }, + 'H': function (date) { + return date.getUTCHours(); + }, + 'HH': function (date) { + return addLeadingZeros(date.getUTCHours(), 2); + }, + 'h': function (date) { + var hours = date.getUTCHours(); + if (hours === 0) { + return 12; + } else if (hours > 12) { + return hours % 12; + } else { + return hours; + } + }, + 'hh': function (date) { + return addLeadingZeros(formatters['h'](date), 2); + }, + 'm': function (date) { + return date.getUTCMinutes(); + }, + 'mm': function (date) { + return addLeadingZeros(date.getUTCMinutes(), 2); + }, + 's': function (date) { + return date.getUTCSeconds(); + }, + 'ss': function (date) { + return addLeadingZeros(date.getUTCSeconds(), 2); + }, + 'S': function (date) { + return Math.floor(date.getUTCMilliseconds() / 100); + }, + 'SS': function (date) { + return addLeadingZeros(Math.floor(date.getUTCMilliseconds() / 10), 2); + }, + 'SSS': function (date) { + return addLeadingZeros(date.getUTCMilliseconds(), 3); + }, + 'Z': function (date, options) { + var originalDate = options._originalDate || date; + return formatTimezone(originalDate.getTimezoneOffset(), ':'); + }, + 'ZZ': function (date, options) { + var originalDate = options._originalDate || date; + return formatTimezone(originalDate.getTimezoneOffset()); + }, + 'X': function (date, options) { + var originalDate = options._originalDate || date; + return Math.floor(originalDate.getTime() / 1000); + }, + 'x': function (date, options) { + var originalDate = options._originalDate || date; + return originalDate.getTime(); + }, + 'A': function (date, options) { + return options.locale.localize.timeOfDay(date.getUTCHours(), { + type: 'uppercase' + }); + }, + 'a': function (date, options) { + return options.locale.localize.timeOfDay(date.getUTCHours(), { + type: 'lowercase' + }); + }, + 'aa': function (date, options) { + return options.locale.localize.timeOfDay(date.getUTCHours(), { + type: 'long' + }); + } + }; + function formatTimezone(offset, delimeter) { + delimeter = delimeter || ''; + var sign = offset > 0 ? '-' : '+'; + var absOffset = Math.abs(offset); + var hours = Math.floor(absOffset / 60); + var minutes = absOffset % 60; + return sign + addLeadingZeros(hours, 2) + delimeter + addLeadingZeros(minutes, 2); + } + + function addLeadingZeros(number, targetLength) { + var output = Math.abs(number).toString(); + while (output.length < targetLength) { + output = '0' + output; + } + return output; } -}; - -function formatDistance (token, count, options) { - options = options || {}; - var result; - if (typeof formatDistanceLocale[token] === 'string') { - result = formatDistanceLocale[token]; - } else if (count === 1) { - result = formatDistanceLocale[token].one; - } else { - result = formatDistanceLocale[token].other.replace('{{count}}', count); + function addUTCMinutes(dirtyDate, dirtyAmount, dirtyOptions) { + var date = toDate(dirtyDate, dirtyOptions); + var amount = Number(dirtyAmount); + date.setUTCMinutes(date.getUTCMinutes() + amount); + return date; } - if (options.addSuffix) { - if (options.comparison > 0) { - return 'in ' + result - } else { - return result + ' ago' - } + var longFormattingTokensRegExp = /(\[[^[]*])|(\\)?(LTS|LT|LLLL|LLL|LL|L|llll|lll|ll|l)/g; + var defaultFormattingTokensRegExp = /(\[[^[]*])|(\\)?(x|ss|s|mm|m|hh|h|do|dddd|ddd|dd|d|aa|a|ZZ|Z|YYYY|YY|X|Wo|WW|W|SSS|SS|S|Qo|Q|Mo|MMMM|MMM|MM|M|HH|H|GGGG|GG|E|Do|DDDo|DDDD|DDD|DD|D|A|.)/g; + function format(dirtyDate, dirtyFormatStr, dirtyOptions) { + if (arguments.length < 2) { + throw new TypeError('2 arguments required, but only ' + arguments.length + ' present'); + } + var formatStr = String(dirtyFormatStr); + var options = dirtyOptions || {}; + var locale$$1 = options.locale || locale; + if (!locale$$1.localize) { + throw new RangeError('locale must contain localize property'); + } + if (!locale$$1.formatLong) { + throw new RangeError('locale must contain formatLong property'); + } + var localeFormatters = locale$$1.formatters || {}; + var formattingTokensRegExp = locale$$1.formattingTokensRegExp || defaultFormattingTokensRegExp; + var formatLong = locale$$1.formatLong; + var originalDate = toDate(dirtyDate, options); + if (!isValid(originalDate, options)) { + return 'Invalid Date'; + } + var timezoneOffset = originalDate.getTimezoneOffset(); + var utcDate = addUTCMinutes(originalDate, -timezoneOffset, options); + var formatterOptions = cloneObject(options); + formatterOptions.locale = locale$$1; + formatterOptions.formatters = formatters; + formatterOptions._originalDate = originalDate; + var result = formatStr.replace(longFormattingTokensRegExp, function (substring) { + if (substring[0] === '[') { + return substring; + } + if (substring[0] === '\\') { + return cleanEscapedString(substring); + } + return formatLong(substring); + }).replace(formattingTokensRegExp, function (substring) { + var formatter = localeFormatters[substring] || formatters[substring]; + if (formatter) { + return formatter(utcDate, formatterOptions); + } else { + return cleanEscapedString(substring); + } + }); + return result; } - return result -} - -var tokensToBeShortedPattern = /MMMM|MM|DD|dddd/g; + function cleanEscapedString(input) { + if (input.match(/\[[\s\S]/)) { + return input.replace(/^\[|]$/g, ''); + } + return input.replace(/\\/g, ''); + } -function buildShortLongFormat (format) { - return format.replace(tokensToBeShortedPattern, function (token) { - return token.slice(1) - }) -} + function subMinutes(dirtyDate, dirtyAmount, dirtyOptions) { + if (arguments.length < 2) { + throw new TypeError('2 arguments required, but only ' + arguments.length + ' present'); + } + var amount = Number(dirtyAmount); + return addMinutes(dirtyDate, -amount, dirtyOptions); + } -/** - * @name buildFormatLongFn - * @category Locale Helpers - * @summary Build `formatLong` property for locale used by `format`, `formatRelative` and `parse` functions. - * - * @description - * Build `formatLong` property for locale used by `format`, `formatRelative` and `parse` functions. - * Returns a function which takes one of the following tokens as the argument: - * `'LTS'`, `'LT'`, `'L'`, `'LL'`, `'LLL'`, `'l'`, `'ll'`, `'lll'`, `'llll'` - * and returns a long format string written as `format` token strings. - * See [format]{@link https://date-fns.org/docs/format} - * - * `'l'`, `'ll'`, `'lll'` and `'llll'` formats are built automatically - * by shortening some of the tokens from corresponding unshortened formats - * (e.g., if `LL` is `'MMMM DD YYYY'` then `ll` will be `MMM D YYYY`) - * - * @param {Object} obj - the object with long formats written as `format` token strings - * @param {String} obj.LT - time format: hours and minutes - * @param {String} obj.LTS - time format: hours, minutes and seconds - * @param {String} obj.L - short date format: numeric day, month and year - * @param {String} [obj.l] - short date format: numeric day, month and year (shortened) - * @param {String} obj.LL - long date format: day, month in words, and year - * @param {String} [obj.ll] - long date format: day, month in words, and year (shortened) - * @param {String} obj.LLL - long date and time format - * @param {String} [obj.lll] - long date and time format (shortened) - * @param {String} obj.LLLL - long date, time and weekday format - * @param {String} [obj.llll] - long date, time and weekday format (shortened) - * @returns {Function} `formatLong` property of the locale - * - * @example - * // For `en-US` locale: - * locale.formatLong = buildFormatLongFn({ - * LT: 'h:mm aa', - * LTS: 'h:mm:ss aa', - * L: 'MM/DD/YYYY', - * LL: 'MMMM D YYYY', - * LLL: 'MMMM D YYYY h:mm aa', - * LLLL: 'dddd, MMMM D YYYY h:mm aa' - * }) - */ -function buildFormatLongFn (obj) { - var formatLongLocale = { - LTS: obj.LTS, - LT: obj.LT, - L: obj.L, - LL: obj.LL, - LLL: obj.LLL, - LLLL: obj.LLLL, - l: obj.l || buildShortLongFormat(obj.L), - ll: obj.ll || buildShortLongFormat(obj.LL), - lll: obj.lll || buildShortLongFormat(obj.LLL), - llll: obj.llll || buildShortLongFormat(obj.LLLL) - }; - - return function (token) { - return formatLongLocale[token] - } -} - -var formatLong = buildFormatLongFn({ - LT: 'h:mm aa', - LTS: 'h:mm:ss aa', - L: 'MM/DD/YYYY', - LL: 'MMMM D YYYY', - LLL: 'MMMM D YYYY h:mm aa', - LLLL: 'dddd, MMMM D YYYY h:mm aa' -}); + function isAfter(dirtyDate, dirtyDateToCompare, dirtyOptions) { + if (arguments.length < 2) { + throw new TypeError('2 arguments required, but only ' + arguments.length + ' present'); + } + var date = toDate(dirtyDate, dirtyOptions); + var dateToCompare = toDate(dirtyDateToCompare, dirtyOptions); + return date.getTime() > dateToCompare.getTime(); + } -var formatRelativeLocale = { - lastWeek: '[last] dddd [at] LT', - yesterday: '[yesterday at] LT', - today: '[today at] LT', - tomorrow: '[tomorrow at] LT', - nextWeek: 'dddd [at] LT', - other: 'L' -}; + function isBefore(dirtyDate, dirtyDateToCompare, dirtyOptions) { + if (arguments.length < 2) { + throw new TypeError('2 arguments required, but only ' + arguments.length + ' present'); + } + var date = toDate(dirtyDate, dirtyOptions); + var dateToCompare = toDate(dirtyDateToCompare, dirtyOptions); + return date.getTime() < dateToCompare.getTime(); + } -function formatRelative (token, date, baseDate, options) { - return formatRelativeLocale[token] -} + function isEqual(dirtyLeftDate, dirtyRightDate, dirtyOptions) { + if (arguments.length < 2) { + throw new TypeError('2 arguments required, but only ' + arguments.length + ' present'); + } + var dateLeft = toDate(dirtyLeftDate, dirtyOptions); + var dateRight = toDate(dirtyRightDate, dirtyOptions); + return dateLeft.getTime() === dateRight.getTime(); + } + + var patterns$1 = { + 'M': /^(1[0-2]|0?\d)/, + 'D': /^(3[0-1]|[0-2]?\d)/, + 'DDD': /^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/, + 'W': /^(5[0-3]|[0-4]?\d)/, + 'YYYY': /^(\d{1,4})/, + 'H': /^(2[0-3]|[0-1]?\d)/, + 'm': /^([0-5]?\d)/, + 'Z': /^([+-])(\d{2}):(\d{2})/, + 'ZZ': /^([+-])(\d{2})(\d{2})/, + singleDigit: /^(\d)/, + twoDigits: /^(\d{2})/, + threeDigits: /^(\d{3})/, + fourDigits: /^(\d{4})/, + anyDigits: /^(\d+)/ + }; + function parseDecimal$1(matchResult) { + return parseInt(matchResult[1], 10); + } -/** - * @name buildLocalizeFn - * @category Locale Helpers - * @summary Build `localize.weekday`, `localize.month` and `localize.timeOfDay` properties for the locale. - * - * @description - * Build `localize.weekday`, `localize.month` and `localize.timeOfDay` properties for the locale - * used by `format` function. - * If no `type` is supplied to the options of the resulting function, `defaultType` will be used (see example). - * - * `localize.weekday` function takes the weekday index as argument (0 - Sunday). - * `localize.month` takes the month index (0 - January). - * `localize.timeOfDay` takes the hours. Use `indexCallback` to convert them to an array index (see example). - * - * @param {Object} values - the object with arrays of values - * @param {String} defaultType - the default type for the localize function - * @param {Function} [indexCallback] - the callback which takes the resulting function argument - * and converts it into value array index - * @returns {Function} the resulting function - * - * @example - * var timeOfDayValues = { - * uppercase: ['AM', 'PM'], - * lowercase: ['am', 'pm'], - * long: ['a.m.', 'p.m.'] - * } - * locale.localize.timeOfDay = buildLocalizeFn(timeOfDayValues, 'long', function (hours) { - * // 0 is a.m. array index, 1 is p.m. array index - * return (hours / 12) >= 1 ? 1 : 0 - * }) - * locale.localize.timeOfDay(16, {type: 'uppercase'}) //=> 'PM' - * locale.localize.timeOfDay(5) //=> 'a.m.' - */ -function buildLocalizeFn (values, defaultType, indexCallback) { - return function (dirtyIndex, dirtyOptions) { - var options = dirtyOptions || {}; - var type = options.type ? String(options.type) : defaultType; - var valuesArray = values[type] || values[defaultType]; - var index = indexCallback ? indexCallback(Number(dirtyIndex)) : Number(dirtyIndex); - return valuesArray[index] + var parsers = { + 'YY': { + unit: 'twoDigitYear', + match: patterns$1.twoDigits, + parse: function (matchResult) { + return parseDecimal$1(matchResult); + } + }, + 'YYYY': { + unit: 'year', + match: patterns$1.YYYY, + parse: parseDecimal$1 + }, + 'GG': { + unit: 'isoYear', + match: patterns$1.twoDigits, + parse: function (matchResult) { + return parseDecimal$1(matchResult) + 1900; + } + }, + 'GGGG': { + unit: 'isoYear', + match: patterns$1.YYYY, + parse: parseDecimal$1 + }, + 'Q': { + unit: 'quarter', + match: patterns$1.singleDigit, + parse: parseDecimal$1 + }, + 'Qo': { + unit: 'quarter', + match: function (string, options) { + return options.locale.match.ordinalNumbers(string, { + unit: 'quarter' + }); + }, + parse: function (matchResult, options) { + return options.locale.match.ordinalNumber(matchResult, { + unit: 'quarter' + }); + } + }, + 'M': { + unit: 'month', + match: patterns$1.M, + parse: function (matchResult) { + return parseDecimal$1(matchResult) - 1; + } + }, + 'Mo': { + unit: 'month', + match: function (string, options) { + return options.locale.match.ordinalNumbers(string, { + unit: 'month' + }); + }, + parse: function (matchResult, options) { + return options.locale.match.ordinalNumber(matchResult, { + unit: 'month' + }) - 1; + } + }, + 'MM': { + unit: 'month', + match: patterns$1.twoDigits, + parse: function (matchResult) { + return parseDecimal$1(matchResult) - 1; + } + }, + 'MMM': { + unit: 'month', + match: function (string, options) { + return options.locale.match.months(string, { + type: 'short' + }); + }, + parse: function (matchResult, options) { + return options.locale.match.month(matchResult, { + type: 'short' + }); + } + }, + 'MMMM': { + unit: 'month', + match: function (string, options) { + return options.locale.match.months(string, { + type: 'long' + }) || options.locale.match.months(string, { + type: 'short' + }); + }, + parse: function (matchResult, options) { + var parseResult = options.locale.match.month(matchResult, { + type: 'long' + }); + if (parseResult == null) { + parseResult = options.locale.match.month(matchResult, { + type: 'short' + }); + } + return parseResult; + } + }, + 'W': { + unit: 'isoWeek', + match: patterns$1.W, + parse: parseDecimal$1 + }, + 'Wo': { + unit: 'isoWeek', + match: function (string, options) { + return options.locale.match.ordinalNumbers(string, { + unit: 'isoWeek' + }); + }, + parse: function (matchResult, options) { + return options.locale.match.ordinalNumber(matchResult, { + unit: 'isoWeek' + }); + } + }, + 'WW': { + unit: 'isoWeek', + match: patterns$1.twoDigits, + parse: parseDecimal$1 + }, + 'd': { + unit: 'dayOfWeek', + match: patterns$1.singleDigit, + parse: parseDecimal$1 + }, + 'do': { + unit: 'dayOfWeek', + match: function (string, options) { + return options.locale.match.ordinalNumbers(string, { + unit: 'dayOfWeek' + }); + }, + parse: function (matchResult, options) { + return options.locale.match.ordinalNumber(matchResult, { + unit: 'dayOfWeek' + }); + } + }, + 'dd': { + unit: 'dayOfWeek', + match: function (string, options) { + return options.locale.match.weekdays(string, { + type: 'narrow' + }); + }, + parse: function (matchResult, options) { + return options.locale.match.weekday(matchResult, { + type: 'narrow' + }); + } + }, + 'ddd': { + unit: 'dayOfWeek', + match: function (string, options) { + return options.locale.match.weekdays(string, { + type: 'short' + }) || options.locale.match.weekdays(string, { + type: 'narrow' + }); + }, + parse: function (matchResult, options) { + var parseResult = options.locale.match.weekday(matchResult, { + type: 'short' + }); + if (parseResult == null) { + parseResult = options.locale.match.weekday(matchResult, { + type: 'narrow' + }); + } + return parseResult; + } + }, + 'dddd': { + unit: 'dayOfWeek', + match: function (string, options) { + return options.locale.match.weekdays(string, { + type: 'long' + }) || options.locale.match.weekdays(string, { + type: 'short' + }) || options.locale.match.weekdays(string, { + type: 'narrow' + }); + }, + parse: function (matchResult, options) { + var parseResult = options.locale.match.weekday(matchResult, { + type: 'long' + }); + if (parseResult == null) { + parseResult = options.locale.match.weekday(matchResult, { + type: 'short' + }); + if (parseResult == null) { + parseResult = options.locale.match.weekday(matchResult, { + type: 'narrow' + }); + } + } + return parseResult; + } + }, + 'E': { + unit: 'dayOfISOWeek', + match: patterns$1.singleDigit, + parse: function (matchResult) { + return parseDecimal$1(matchResult); + } + }, + 'D': { + unit: 'dayOfMonth', + match: patterns$1.D, + parse: parseDecimal$1 + }, + 'Do': { + unit: 'dayOfMonth', + match: function (string, options) { + return options.locale.match.ordinalNumbers(string, { + unit: 'dayOfMonth' + }); + }, + parse: function (matchResult, options) { + return options.locale.match.ordinalNumber(matchResult, { + unit: 'dayOfMonth' + }); + } + }, + 'DD': { + unit: 'dayOfMonth', + match: patterns$1.twoDigits, + parse: parseDecimal$1 + }, + 'DDD': { + unit: 'dayOfYear', + match: patterns$1.DDD, + parse: parseDecimal$1 + }, + 'DDDo': { + unit: 'dayOfYear', + match: function (string, options) { + return options.locale.match.ordinalNumbers(string, { + unit: 'dayOfYear' + }); + }, + parse: function (matchResult, options) { + return options.locale.match.ordinalNumber(matchResult, { + unit: 'dayOfYear' + }); + } + }, + 'DDDD': { + unit: 'dayOfYear', + match: patterns$1.threeDigits, + parse: parseDecimal$1 + }, + 'A': { + unit: 'timeOfDay', + match: function (string, options) { + return options.locale.match.timesOfDay(string, { + type: 'short' + }); + }, + parse: function (matchResult, options) { + return options.locale.match.timeOfDay(matchResult, { + type: 'short' + }); + } + }, + 'aa': { + unit: 'timeOfDay', + match: function (string, options) { + return options.locale.match.timesOfDay(string, { + type: 'long' + }) || options.locale.match.timesOfDay(string, { + type: 'short' + }); + }, + parse: function (matchResult, options) { + var parseResult = options.locale.match.timeOfDay(matchResult, { + type: 'long' + }); + if (parseResult == null) { + parseResult = options.locale.match.timeOfDay(matchResult, { + type: 'short' + }); + } + return parseResult; + } + }, + 'H': { + unit: 'hours', + match: patterns$1.H, + parse: parseDecimal$1 + }, + 'HH': { + unit: 'hours', + match: patterns$1.twoDigits, + parse: parseDecimal$1 + }, + 'h': { + unit: 'timeOfDayHours', + match: patterns$1.M, + parse: parseDecimal$1 + }, + 'hh': { + unit: 'timeOfDayHours', + match: patterns$1.twoDigits, + parse: parseDecimal$1 + }, + 'm': { + unit: 'minutes', + match: patterns$1.m, + parse: parseDecimal$1 + }, + 'mm': { + unit: 'minutes', + match: patterns$1.twoDigits, + parse: parseDecimal$1 + }, + 's': { + unit: 'seconds', + match: patterns$1.m, + parse: parseDecimal$1 + }, + 'ss': { + unit: 'seconds', + match: patterns$1.twoDigits, + parse: parseDecimal$1 + }, + 'S': { + unit: 'milliseconds', + match: patterns$1.singleDigit, + parse: function (matchResult) { + return parseDecimal$1(matchResult) * 100; + } + }, + 'SS': { + unit: 'milliseconds', + match: patterns$1.twoDigits, + parse: function (matchResult) { + return parseDecimal$1(matchResult) * 10; + } + }, + 'SSS': { + unit: 'milliseconds', + match: patterns$1.threeDigits, + parse: parseDecimal$1 + }, + 'Z': { + unit: 'timezone', + match: patterns$1.Z, + parse: function (matchResult) { + var sign = matchResult[1]; + var hours = parseInt(matchResult[2], 10); + var minutes = parseInt(matchResult[3], 10); + var absoluteOffset = hours * 60 + minutes; + return sign === '+' ? absoluteOffset : -absoluteOffset; + } + }, + 'ZZ': { + unit: 'timezone', + match: patterns$1.ZZ, + parse: function (matchResult) { + var sign = matchResult[1]; + var hours = parseInt(matchResult[2], 10); + var minutes = parseInt(matchResult[3], 10); + var absoluteOffset = hours * 60 + minutes; + return sign === '+' ? absoluteOffset : -absoluteOffset; + } + }, + 'X': { + unit: 'timestamp', + match: patterns$1.anyDigits, + parse: function (matchResult) { + return parseDecimal$1(matchResult) * 1000; + } + }, + 'x': { + unit: 'timestamp', + match: patterns$1.anyDigits, + parse: parseDecimal$1 + } + }; + parsers['a'] = parsers['A']; + + function setUTCDay(dirtyDate, dirtyDay, dirtyOptions) { + var options = dirtyOptions || {}; + var locale = options.locale; + var localeWeekStartsOn = locale && locale.options && locale.options.weekStartsOn; + var defaultWeekStartsOn = localeWeekStartsOn === undefined ? 0 : Number(localeWeekStartsOn); + var weekStartsOn = options.weekStartsOn === undefined ? defaultWeekStartsOn : Number(options.weekStartsOn); + if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) { + throw new RangeError('weekStartsOn must be between 0 and 6 inclusively'); + } + var date = toDate(dirtyDate, dirtyOptions); + var day = Number(dirtyDay); + var currentDay = date.getUTCDay(); + var remainder = day % 7; + var dayIndex = (remainder + 7) % 7; + var diff = (dayIndex < weekStartsOn ? 7 : 0) + day - currentDay; + date.setUTCDate(date.getUTCDate() + diff); + return date; + } + + function setUTCISODay(dirtyDate, dirtyDay, dirtyOptions) { + var day = Number(dirtyDay); + if (day % 7 === 0) { + day = day - 7; + } + var weekStartsOn = 1; + var date = toDate(dirtyDate, dirtyOptions); + var currentDay = date.getUTCDay(); + var remainder = day % 7; + var dayIndex = (remainder + 7) % 7; + var diff = (dayIndex < weekStartsOn ? 7 : 0) + day - currentDay; + date.setUTCDate(date.getUTCDate() + diff); + return date; + } + + function setUTCISOWeek(dirtyDate, dirtyISOWeek, dirtyOptions) { + var date = toDate(dirtyDate, dirtyOptions); + var isoWeek = Number(dirtyISOWeek); + var diff = getUTCISOWeek(date, dirtyOptions) - isoWeek; + date.setUTCDate(date.getUTCDate() - diff * 7); + return date; + } + + var MILLISECONDS_IN_DAY$3 = 86400000; + function setUTCISOWeekYear(dirtyDate, dirtyISOYear, dirtyOptions) { + var date = toDate(dirtyDate, dirtyOptions); + var isoYear = Number(dirtyISOYear); + var dateStartOfYear = startOfUTCISOWeekYear(date, dirtyOptions); + var diff = Math.floor((date.getTime() - dateStartOfYear.getTime()) / MILLISECONDS_IN_DAY$3); + var fourthOfJanuary = new Date(0); + fourthOfJanuary.setUTCFullYear(isoYear, 0, 4); + fourthOfJanuary.setUTCHours(0, 0, 0, 0); + date = startOfUTCISOWeekYear(fourthOfJanuary, dirtyOptions); + date.setUTCDate(date.getUTCDate() + diff); + return date; + } + + var MILLISECONDS_IN_MINUTE$6 = 60000; + function setTimeOfDay(hours, timeOfDay) { + var isAM = timeOfDay === 0; + if (isAM) { + if (hours === 12) { + return 0; + } + } else { + if (hours !== 12) { + return 12 + hours; + } + } + return hours; + } + + var units = { + twoDigitYear: { + priority: 10, + set: function (dateValues, value) { + var century = Math.floor(dateValues.date.getUTCFullYear() / 100); + var year = century * 100 + value; + dateValues.date.setUTCFullYear(year, 0, 1); + dateValues.date.setUTCHours(0, 0, 0, 0); + return dateValues; + } + }, + year: { + priority: 10, + set: function (dateValues, value) { + dateValues.date.setUTCFullYear(value, 0, 1); + dateValues.date.setUTCHours(0, 0, 0, 0); + return dateValues; + } + }, + isoYear: { + priority: 10, + set: function (dateValues, value, options) { + dateValues.date = startOfUTCISOWeekYear(setUTCISOWeekYear(dateValues.date, value, options), options); + return dateValues; + } + }, + quarter: { + priority: 20, + set: function (dateValues, value) { + dateValues.date.setUTCMonth((value - 1) * 3, 1); + dateValues.date.setUTCHours(0, 0, 0, 0); + return dateValues; + } + }, + month: { + priority: 30, + set: function (dateValues, value) { + dateValues.date.setUTCMonth(value, 1); + dateValues.date.setUTCHours(0, 0, 0, 0); + return dateValues; + } + }, + isoWeek: { + priority: 40, + set: function (dateValues, value, options) { + dateValues.date = startOfUTCISOWeek(setUTCISOWeek(dateValues.date, value, options), options); + return dateValues; + } + }, + dayOfWeek: { + priority: 50, + set: function (dateValues, value, options) { + dateValues.date = setUTCDay(dateValues.date, value, options); + dateValues.date.setUTCHours(0, 0, 0, 0); + return dateValues; + } + }, + dayOfISOWeek: { + priority: 50, + set: function (dateValues, value, options) { + dateValues.date = setUTCISODay(dateValues.date, value, options); + dateValues.date.setUTCHours(0, 0, 0, 0); + return dateValues; + } + }, + dayOfMonth: { + priority: 50, + set: function (dateValues, value) { + dateValues.date.setUTCDate(value); + dateValues.date.setUTCHours(0, 0, 0, 0); + return dateValues; + } + }, + dayOfYear: { + priority: 50, + set: function (dateValues, value) { + dateValues.date.setUTCMonth(0, value); + dateValues.date.setUTCHours(0, 0, 0, 0); + return dateValues; + } + }, + timeOfDay: { + priority: 60, + set: function (dateValues, value, options) { + dateValues.timeOfDay = value; + return dateValues; + } + }, + hours: { + priority: 70, + set: function (dateValues, value, options) { + dateValues.date.setUTCHours(value, 0, 0, 0); + return dateValues; + } + }, + timeOfDayHours: { + priority: 70, + set: function (dateValues, value, options) { + var timeOfDay = dateValues.timeOfDay; + if (timeOfDay != null) { + value = setTimeOfDay(value, timeOfDay); + } + dateValues.date.setUTCHours(value, 0, 0, 0); + return dateValues; + } + }, + minutes: { + priority: 80, + set: function (dateValues, value) { + dateValues.date.setUTCMinutes(value, 0, 0); + return dateValues; + } + }, + seconds: { + priority: 90, + set: function (dateValues, value) { + dateValues.date.setUTCSeconds(value, 0); + return dateValues; + } + }, + milliseconds: { + priority: 100, + set: function (dateValues, value) { + dateValues.date.setUTCMilliseconds(value); + return dateValues; + } + }, + timezone: { + priority: 110, + set: function (dateValues, value) { + dateValues.date = new Date(dateValues.date.getTime() - value * MILLISECONDS_IN_MINUTE$6); + return dateValues; + } + }, + timestamp: { + priority: 120, + set: function (dateValues, value) { + dateValues.date = new Date(value); + return dateValues; + } + } + }; + + var TIMEZONE_UNIT_PRIORITY = 110; + var MILLISECONDS_IN_MINUTE$7 = 60000; + var longFormattingTokensRegExp$1 = /(\[[^[]*])|(\\)?(LTS|LT|LLLL|LLL|LL|L|llll|lll|ll|l)/g; + var defaultParsingTokensRegExp = /(\[[^[]*])|(\\)?(x|ss|s|mm|m|hh|h|do|dddd|ddd|dd|d|aa|a|ZZ|Z|YYYY|YY|X|Wo|WW|W|SSS|SS|S|Qo|Q|Mo|MMMM|MMM|MM|M|HH|H|GGGG|GG|E|Do|DDDo|DDDD|DDD|DD|D|A|.)/g; + function parse(dirtyDateString, dirtyFormatString, dirtyBaseDate, dirtyOptions) { + if (arguments.length < 3) { + throw new TypeError('3 arguments required, but only ' + arguments.length + ' present'); + } + var dateString = String(dirtyDateString); + var options = dirtyOptions || {}; + var weekStartsOn = options.weekStartsOn === undefined ? 0 : Number(options.weekStartsOn); + if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) { + throw new RangeError('weekStartsOn must be between 0 and 6 inclusively'); + } + var locale$$1 = options.locale || locale; + var localeParsers = locale$$1.parsers || {}; + var localeUnits = locale$$1.units || {}; + if (!locale$$1.match) { + throw new RangeError('locale must contain match property'); + } + if (!locale$$1.formatLong) { + throw new RangeError('locale must contain formatLong property'); + } + var formatString = String(dirtyFormatString).replace(longFormattingTokensRegExp$1, function (substring) { + if (substring[0] === '[') { + return substring; + } + if (substring[0] === '\\') { + return cleanEscapedString$1(substring); + } + return locale$$1.formatLong(substring); + }); + if (formatString === '') { + if (dateString === '') { + return toDate(dirtyBaseDate, options); + } else { + return new Date(NaN); + } + } + var subFnOptions = cloneObject(options); + subFnOptions.locale = locale$$1; + var tokens = formatString.match(locale$$1.parsingTokensRegExp || defaultParsingTokensRegExp); + var tokensLength = tokens.length; + var setters = [{ + priority: TIMEZONE_UNIT_PRIORITY, + set: dateToSystemTimezone, + index: 0 + }]; + var i; + for (i = 0; i < tokensLength; i++) { + var token = tokens[i]; + var parser = localeParsers[token] || parsers[token]; + if (parser) { + var matchResult; + if (parser.match instanceof RegExp) { + matchResult = parser.match.exec(dateString); + } else { + matchResult = parser.match(dateString, subFnOptions); + } + if (!matchResult) { + return new Date(NaN); + } + var unitName = parser.unit; + var unit = localeUnits[unitName] || units[unitName]; + setters.push({ + priority: unit.priority, + set: unit.set, + value: parser.parse(matchResult, subFnOptions), + index: setters.length + }); + var substring = matchResult[0]; + dateString = dateString.slice(substring.length); + } else { + var head = tokens[i].match(/^\[.*]$/) ? tokens[i].replace(/^\[|]$/g, '') : tokens[i]; + if (dateString.indexOf(head) === 0) { + dateString = dateString.slice(head.length); + } else { + return new Date(NaN); + } + } + } + var uniquePrioritySetters = setters.map(function (setter) { + return setter.priority; + }).sort(function (a, b) { + return a - b; + }).filter(function (priority, index, array) { + return array.indexOf(priority) === index; + }).map(function (priority) { + return setters.filter(function (setter) { + return setter.priority === priority; + }).reverse(); + }).map(function (setterArray) { + return setterArray[0]; + }); + var date = toDate(dirtyBaseDate, options); + if (isNaN(date)) { + return new Date(NaN); + } + var utcDate = subMinutes(date, date.getTimezoneOffset()); + var dateValues = { + date: utcDate + }; + var settersLength = uniquePrioritySetters.length; + for (i = 0; i < settersLength; i++) { + var setter = uniquePrioritySetters[i]; + dateValues = setter.set(dateValues, setter.value, subFnOptions); + } + return dateValues.date; } -} -/** - * @name buildLocalizeArrayFn - * @category Locale Helpers - * @summary Build `localize.weekdays`, `localize.months` and `localize.timesOfDay` properties for the locale. - * - * @description - * Build `localize.weekdays`, `localize.months` and `localize.timesOfDay` properties for the locale. - * If no `type` is supplied to the options of the resulting function, `defaultType` will be used (see example). - * - * @param {Object} values - the object with arrays of values - * @param {String} defaultType - the default type for the localize function - * @returns {Function} the resulting function - * - * @example - * var weekdayValues = { - * narrow: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], - * short: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], - * long: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] - * } - * locale.localize.weekdays = buildLocalizeArrayFn(weekdayValues, 'long') - * locale.localize.weekdays({type: 'narrow'}) //=> ['Su', 'Mo', ...] - * locale.localize.weekdays() //=> ['Sunday', 'Monday', ...] - */ -function buildLocalizeArrayFn (values, defaultType) { - return function (dirtyOptions) { - var options = dirtyOptions || {}; - var type = options.type ? String(options.type) : defaultType; - return values[type] || values[defaultType] - } -} - -// Note: in English, the names of days of the week and months are capitalized. -// If you are making a new locale based on this one, check if the same is true for the language you're working on. -// Generally, formatted dates should look like they are in the middle of a sentence, -// e.g. in Spanish language the weekdays and months should be in the lowercase. -var weekdayValues = { - narrow: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], - short: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], - long: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] -}; + function dateToSystemTimezone(dateValues) { + var date = dateValues.date; + var time = date.getTime(); + var offset = date.getTimezoneOffset(); + offset = new Date(time + offset * MILLISECONDS_IN_MINUTE$7).getTimezoneOffset(); + dateValues.date = new Date(time + offset * MILLISECONDS_IN_MINUTE$7); + return dateValues; + } -var monthValues = { - short: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], - long: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] -}; + function cleanEscapedString$1(input) { + if (input.match(/\[[\s\S]/)) { + return input.replace(/^\[|]$/g, ''); + } + return input.replace(/\\/g, ''); + } -// `timeOfDay` is used to designate which part of the day it is, when used with 12-hour clock. -// Use the system which is used the most commonly in the locale. -// For example, if the country doesn't use a.m./p.m., you can use `night`/`morning`/`afternoon`/`evening`: -// -// var timeOfDayValues = { -// any: ['in the night', 'in the morning', 'in the afternoon', 'in the evening'] -// } -// -// And later: -// -// var localize = { -// // The callback takes the hours as the argument and returns the array index -// timeOfDay: buildLocalizeFn(timeOfDayValues, 'any', function (hours) { -// if (hours >= 17) { -// return 3 -// } else if (hours >= 12) { -// return 2 -// } else if (hours >= 4) { -// return 1 -// } else { -// return 0 -// } -// }), -// timesOfDay: buildLocalizeArrayFn(timeOfDayValues, 'any') -// } -var timeOfDayValues = { - uppercase: ['AM', 'PM'], - lowercase: ['am', 'pm'], - long: ['a.m.', 'p.m.'] -}; + function parseDate$1(date, format$$1) { + if (typeof date !== 'string') { + return isValid(date) ? date : null; + } + var parsed = parse(date, format$$1, new Date()); + if (!isValid(parsed) || format(parsed, format$$1) !== date) { + return null; + } + return parsed; + } -function ordinalNumber (dirtyNumber, dirtyOptions) { - var number = Number(dirtyNumber); + function after (value, ref) { + var otherValue = ref[0]; + var inclusion = ref[1]; + var format$$1 = ref[2]; - // If ordinal numbers depend on context, for example, - // if they are different for different grammatical genders, - // use `options.unit`: - // - // var options = dirtyOptions || {} - // var unit = String(options.unit) - // - // where `unit` can be 'month', 'quarter', 'week', 'isoWeek', 'dayOfYear', - // 'dayOfMonth' or 'dayOfWeek' - - var rem100 = number % 100; - if (rem100 > 20 || rem100 < 10) { - switch (rem100 % 10) { - case 1: - return number + 'st' - case 2: - return number + 'nd' - case 3: - return number + 'rd' - } - } - return number + 'th' -} - -var localize = { - ordinalNumber: ordinalNumber, - weekday: buildLocalizeFn(weekdayValues, 'long'), - weekdays: buildLocalizeArrayFn(weekdayValues, 'long'), - month: buildLocalizeFn(monthValues, 'long'), - months: buildLocalizeArrayFn(monthValues, 'long'), - timeOfDay: buildLocalizeFn(timeOfDayValues, 'long', function (hours) { - return (hours / 12) >= 1 ? 1 : 0 - }), - timesOfDay: buildLocalizeArrayFn(timeOfDayValues, 'long') -}; + if (typeof format$$1 === 'undefined') { + format$$1 = inclusion; + inclusion = false; + } + value = parseDate$1(value, format$$1); + otherValue = parseDate$1(otherValue, format$$1); + if (!value || !otherValue) { + return false; + } + return isAfter(value, otherValue) || inclusion && isEqual(value, otherValue); + } + + var alpha = { + en: /^[A-Z]*$/i, + cs: /^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]*$/i, + da: /^[A-ZÆØÅ]*$/i, + de: /^[A-ZÄÖÜß]*$/i, + es: /^[A-ZÁÉÍÑÓÚÜ]*$/i, + fr: /^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]*$/i, + lt: /^[A-ZĄČĘĖĮŠŲŪŽ]*$/i, + nl: /^[A-ZÉËÏÓÖÜ]*$/i, + hu: /^[A-ZÁÉÍÓÖŐÚÜŰ]*$/i, + pl: /^[A-ZĄĆĘŚŁŃÓŻŹ]*$/i, + pt: /^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]*$/i, + ru: /^[А-ЯЁ]*$/i, + sk: /^[A-ZÁÄČĎÉÍĹĽŇÓŔŠŤÚÝŽ]*$/i, + sr: /^[A-ZČĆŽŠĐ]*$/i, + tr: /^[A-ZÇĞİıÖŞÜ]*$/i, + uk: /^[А-ЩЬЮЯЄІЇҐ]*$/i, + ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]*$/ + }; + var alphaSpaces = { + en: /^[A-Z\s]*$/i, + cs: /^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ\s]*$/i, + da: /^[A-ZÆØÅ\s]*$/i, + de: /^[A-ZÄÖÜß\s]*$/i, + es: /^[A-ZÁÉÍÑÓÚÜ\s]*$/i, + fr: /^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ\s]*$/i, + lt: /^[A-ZĄČĘĖĮŠŲŪŽ\s]*$/i, + nl: /^[A-ZÉËÏÓÖÜ\s]*$/i, + hu: /^[A-ZÁÉÍÓÖŐÚÜŰ\s]*$/i, + pl: /^[A-ZĄĆĘŚŁŃÓŻŹ\s]*$/i, + pt: /^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ\s]*$/i, + ru: /^[А-ЯЁ\s]*$/i, + sk: /^[A-ZÁÄČĎÉÍĹĽŇÓŔŠŤÚÝŽ\s]*$/i, + sr: /^[A-ZČĆŽŠĐ\s]*$/i, + tr: /^[A-ZÇĞİıÖŞÜ\s]*$/i, + uk: /^[А-ЩЬЮЯЄІЇҐ\s]*$/i, + ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ\s]*$/ + }; + var alphanumeric = { + en: /^[0-9A-Z]*$/i, + cs: /^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]*$/i, + da: /^[0-9A-ZÆØÅ]$/i, + de: /^[0-9A-ZÄÖÜß]*$/i, + es: /^[0-9A-ZÁÉÍÑÓÚÜ]*$/i, + fr: /^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]*$/i, + lt: /^[0-9A-ZĄČĘĖĮŠŲŪŽ]*$/i, + hu: /^[0-9A-ZÁÉÍÓÖŐÚÜŰ]*$/i, + nl: /^[0-9A-ZÉËÏÓÖÜ]*$/i, + pl: /^[0-9A-ZĄĆĘŚŁŃÓŻŹ]*$/i, + pt: /^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]*$/i, + ru: /^[0-9А-ЯЁ]*$/i, + sk: /^[0-9A-ZÁÄČĎÉÍĹĽŇÓŔŠŤÚÝŽ]*$/i, + sr: /^[0-9A-ZČĆŽŠĐ]*$/i, + tr: /^[0-9A-ZÇĞİıÖŞÜ]*$/i, + uk: /^[0-9А-ЩЬЮЯЄІЇҐ]*$/i, + ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]*$/ + }; + var alphaDash = { + en: /^[0-9A-Z_-]*$/i, + cs: /^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ_-]*$/i, + da: /^[0-9A-ZÆØÅ_-]*$/i, + de: /^[0-9A-ZÄÖÜß_-]*$/i, + es: /^[0-9A-ZÁÉÍÑÓÚÜ_-]*$/i, + fr: /^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ_-]*$/i, + lt: /^[0-9A-ZĄČĘĖĮŠŲŪŽ_-]*$/i, + nl: /^[0-9A-ZÉËÏÓÖÜ_-]*$/i, + hu: /^[0-9A-ZÁÉÍÓÖŐÚÜŰ_-]*$/i, + pl: /^[0-9A-ZĄĆĘŚŁŃÓŻŹ_-]*$/i, + pt: /^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ_-]*$/i, + ru: /^[0-9А-ЯЁ_-]*$/i, + sk: /^[0-9A-ZÁÄČĎÉÍĹĽŇÓŔŠŤÚÝŽ_-]*$/i, + sr: /^[0-9A-ZČĆŽŠĐ_-]*$/i, + tr: /^[0-9A-ZÇĞİıÖŞÜ_-]*$/i, + uk: /^[0-9А-ЩЬЮЯЄІЇҐ_-]*$/i, + ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ_-]*$/ + }; -/** - * @name buildMatchFn - * @category Locale Helpers - * @summary Build `match.weekdays`, `match.months` and `match.timesOfDay` properties for the locale. - * - * @description - * Build `match.weekdays`, `match.months` and `match.timesOfDay` properties for the locale used by `parse` function. - * If no `type` is supplied to the options of the resulting function, `defaultType` will be used (see example). - * The result of the match function will be passed into corresponding parser function - * (`match.weekday`, `match.month` or `match.timeOfDay` respectively. See `buildParseFn`). - * - * @param {Object} values - the object with RegExps - * @param {String} defaultType - the default type for the match function - * @returns {Function} the resulting function - * - * @example - * var matchWeekdaysPatterns = { - * narrow: /^(su|mo|tu|we|th|fr|sa)/i, - * short: /^(sun|mon|tue|wed|thu|fri|sat)/i, - * long: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i - * } - * locale.match.weekdays = buildMatchFn(matchWeekdaysPatterns, 'long') - * locale.match.weekdays('Sunday', {type: 'narrow'}) //=> ['Su', 'Su', ...] - * locale.match.weekdays('Sunday') //=> ['Sunday', 'Sunday', ...] - */ -function buildMatchFn (patterns, defaultType) { - return function (dirtyString, dirtyOptions) { - var options = dirtyOptions || {}; - var type = options.type ? String(options.type) : defaultType; - var pattern = patterns[type] || patterns[defaultType]; - var string = String(dirtyString); - return string.match(pattern) - } -} + var validate = function (value, ref) { + if ( ref === void 0 ) ref = []; + var locale = ref[0]; if ( locale === void 0 ) locale = null; -/** - * @name buildParseFn - * @category Locale Helpers - * @summary Build `match.weekday`, `match.month` and `match.timeOfDay` properties for the locale. - * - * @description - * Build `match.weekday`, `match.month` and `match.timeOfDay` properties for the locale used by `parse` function. - * The argument of the resulting function is the result of the corresponding match function - * (`match.weekdays`, `match.months` or `match.timesOfDay` respectively. See `buildMatchFn`). - * - * @param {Object} values - the object with arrays of RegExps - * @param {String} defaultType - the default type for the parser function - * @returns {Function} the resulting function - * - * @example - * var parseWeekdayPatterns = { - * any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i] - * } - * locale.match.weekday = buildParseFn(matchWeekdaysPatterns, 'long') - * var matchResult = locale.match.weekdays('Friday') - * locale.match.weekday(matchResult) //=> 5 - */ -function buildParseFn (patterns, defaultType) { - return function (matchResult, dirtyOptions) { - var options = dirtyOptions || {}; - var type = options.type ? String(options.type) : defaultType; - var patternsArray = patterns[type] || patterns[defaultType]; - var string = matchResult[1]; - - return patternsArray.findIndex(function (pattern) { - return pattern.test(string) - }) - } -} + if (Array.isArray(value)) { + return value.every(function (val) { return validate(val, [locale]); }); + } + if (!locale) { + return Object.keys(alpha).some(function (loc) { return alpha[loc].test(value); }); + } + return (alpha[locale] || alpha.en).test(value); + }; -/** - * @name buildMatchPatternFn - * @category Locale Helpers - * @summary Build match function from a single RegExp. - * - * @description - * Build match function from a single RegExp. - * Usually used for building `match.ordinalNumbers` property of the locale. - * - * @param {Object} pattern - the RegExp - * @returns {Function} the resulting function - * - * @example - * locale.match.ordinalNumbers = buildMatchPatternFn(/^(\d+)(th|st|nd|rd)?/i) - * locale.match.ordinalNumbers('3rd') //=> ['3rd', '3', 'rd', ...] - */ -function buildMatchPatternFn (pattern) { - return function (dirtyString) { - var string = String(dirtyString); - return string.match(pattern) - } -} + var validate$1 = function (value, ref) { + if ( ref === void 0 ) ref = []; + var locale = ref[0]; if ( locale === void 0 ) locale = null; -/** - * @name parseDecimal - * @category Locale Helpers - * @summary Parses the match result into decimal number. - * - * @description - * Parses the match result into decimal number. - * Uses the string matched with the first set of parentheses of match RegExp. - * - * @param {Array} matchResult - the object returned by matching function - * @returns {Number} the parsed value - * - * @example - * locale.match = { - * ordinalNumbers: (dirtyString) { - * return String(dirtyString).match(/^(\d+)(th|st|nd|rd)?/i) - * }, - * ordinalNumber: parseDecimal - * } - */ -function parseDecimal (matchResult) { - return parseInt(matchResult[1], 10) -} + if (Array.isArray(value)) { + return value.every(function (val) { return validate$1(val, [locale]); }); + } + if (!locale) { + return Object.keys(alphaDash).some(function (loc) { return alphaDash[loc].test(value); }); + } + return (alphaDash[locale] || alphaDash.en).test(value); + }; -var matchOrdinalNumbersPattern = /^(\d+)(th|st|nd|rd)?/i; + var validate$2 = function (value, ref) { + if ( ref === void 0 ) ref = []; + var locale = ref[0]; if ( locale === void 0 ) locale = null; -var matchWeekdaysPatterns = { - narrow: /^(su|mo|tu|we|th|fr|sa)/i, - short: /^(sun|mon|tue|wed|thu|fri|sat)/i, - long: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i -}; + if (Array.isArray(value)) { + return value.every(function (val) { return validate$2(val, [locale]); }); + } + if (!locale) { + return Object.keys(alphanumeric).some(function (loc) { return alphanumeric[loc].test(value); }); + } + return (alphanumeric[locale] || alphanumeric.en).test(value); + }; -var parseWeekdayPatterns = { - any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i] -}; + var validate$3 = function (value, ref) { + if ( ref === void 0 ) ref = []; + var locale = ref[0]; if ( locale === void 0 ) locale = null; -var matchMonthsPatterns = { - short: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i, - long: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i -}; + if (Array.isArray(value)) { + return value.every(function (val) { return validate$3(val, [locale]); }); + } + if (!locale) { + return Object.keys(alphaSpaces).some(function (loc) { return alphaSpaces[loc].test(value); }); + } + return (alphaSpaces[locale] || alphaSpaces.en).test(value); + }; -var parseMonthPatterns = { - any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i] -}; + function before (value, ref) { + var otherValue = ref[0]; + var inclusion = ref[1]; + var format$$1 = ref[2]; -// `timeOfDay` is used to designate which part of the day it is, when used with 12-hour clock. -// Use the system which is used the most commonly in the locale. -// For example, if the country doesn't use a.m./p.m., you can use `night`/`morning`/`afternoon`/`evening`: -// -// var matchTimesOfDayPatterns = { -// long: /^((in the)? (night|morning|afternoon|evening?))/i -// } -// -// var parseTimeOfDayPatterns = { -// any: [/(night|morning)/i, /(afternoon|evening)/i] -// } -var matchTimesOfDayPatterns = { - short: /^(am|pm)/i, - long: /^([ap]\.?\s?m\.?)/i -}; + if (typeof format$$1 === 'undefined') { + format$$1 = inclusion; + inclusion = false; + } + value = parseDate$1(value, format$$1); + otherValue = parseDate$1(otherValue, format$$1); + if (!value || !otherValue) { + return false; + } + return isBefore(value, otherValue) || inclusion && isEqual(value, otherValue); + } -var parseTimeOfDayPatterns = { - any: [/^a/i, /^p/i] -}; + var validate$4 = function (value, ref) { + var min = ref[0]; + var max = ref[1]; -var match = { - ordinalNumbers: buildMatchPatternFn(matchOrdinalNumbersPattern), - ordinalNumber: parseDecimal, - weekdays: buildMatchFn(matchWeekdaysPatterns, 'long'), - weekday: buildParseFn(parseWeekdayPatterns, 'any'), - months: buildMatchFn(matchMonthsPatterns, 'long'), - month: buildParseFn(parseMonthPatterns, 'any'), - timesOfDay: buildMatchFn(matchTimesOfDayPatterns, 'long'), - timeOfDay: buildParseFn(parseTimeOfDayPatterns, 'any') -}; + if (Array.isArray(value)) { + return value.every(function (val) { return validate$4(val, [min,max]); }); + } + return Number(min) <= value && Number(max) >= value; + }; -/** - * @type {Locale} - * @category Locales - * @summary English locale (United States). - * @language English - * @iso-639-2 eng - */ -var locale = { - formatDistance: formatDistance, - formatLong: formatLong, - formatRelative: formatRelative, - localize: localize, - match: match, - options: { - weekStartsOn: 0 /* Sunday */, - firstWeekContainsDate: 1 + function confirmed (value, other) { return String(value) === String(other); } + + function unwrapExports (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } -}; -var MILLISECONDS_IN_DAY$1 = 86400000; - -// This function will be a part of public API when UTC function will be implemented. -// See issue: https://github.com/date-fns/date-fns/issues/376 -function getUTCDayOfYear (dirtyDate, dirtyOptions) { - var date = toDate(dirtyDate, dirtyOptions); - var timestamp = date.getTime(); - date.setUTCMonth(0, 1); - date.setUTCHours(0, 0, 0, 0); - var startOfYearTimestamp = date.getTime(); - var difference = timestamp - startOfYearTimestamp; - return Math.floor(difference / MILLISECONDS_IN_DAY$1) + 1 -} - -// This function will be a part of public API when UTC function will be implemented. -// See issue: https://github.com/date-fns/date-fns/issues/376 -function startOfUTCISOWeek (dirtyDate, dirtyOptions) { - var weekStartsOn = 1; - - var date = toDate(dirtyDate, dirtyOptions); - var day = date.getUTCDay(); - var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; - - date.setUTCDate(date.getUTCDate() - diff); - date.setUTCHours(0, 0, 0, 0); - return date -} - -// This function will be a part of public API when UTC function will be implemented. -// See issue: https://github.com/date-fns/date-fns/issues/376 -function getUTCISOWeekYear (dirtyDate, dirtyOptions) { - var date = toDate(dirtyDate, dirtyOptions); - var year = date.getUTCFullYear(); - - var fourthOfJanuaryOfNextYear = new Date(0); - fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4); - fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0); - var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear, dirtyOptions); - - var fourthOfJanuaryOfThisYear = new Date(0); - fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4); - fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0); - var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear, dirtyOptions); - - if (date.getTime() >= startOfNextYear.getTime()) { - return year + 1 - } else if (date.getTime() >= startOfThisYear.getTime()) { - return year - } else { - return year - 1 + function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; } -} -// This function will be a part of public API when UTC function will be implemented. -// See issue: https://github.com/date-fns/date-fns/issues/376 -function startOfUTCISOWeekYear (dirtyDate, dirtyOptions) { - var year = getUTCISOWeekYear(dirtyDate, dirtyOptions); - var fourthOfJanuary = new Date(0); - fourthOfJanuary.setUTCFullYear(year, 0, 4); - fourthOfJanuary.setUTCHours(0, 0, 0, 0); - var date = startOfUTCISOWeek(fourthOfJanuary, dirtyOptions); - return date -} + var assertString_1 = createCommonjsModule(function (module, exports) { + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = assertString; + function assertString(input) { + var isString = typeof input === 'string' || input instanceof String; + if (!isString) { + throw new TypeError('This library (validator.js) validates strings only'); + } + } + + module.exports = exports['default']; + }); + var assertString = unwrapExports(assertString_1) -var MILLISECONDS_IN_WEEK$2 = 604800000; + var assertString$1 = /*#__PURE__*/Object.freeze({ + default: assertString, + __moduleExports: assertString_1 + }); -// This function will be a part of public API when UTC function will be implemented. -// See issue: https://github.com/date-fns/date-fns/issues/376 -function getUTCISOWeek (dirtyDate, dirtyOptions) { - var date = toDate(dirtyDate, dirtyOptions); - var diff = startOfUTCISOWeek(date, dirtyOptions).getTime() - startOfUTCISOWeekYear(date, dirtyOptions).getTime(); + var _assertString = ( assertString$1 && assertString ) || assertString$1; - // Round the number of days to the nearest integer - // because the number of milliseconds in a week is not constant - // (e.g. it's different in the week of the daylight saving time clock shift) - return Math.round(diff / MILLISECONDS_IN_WEEK$2) + 1 -} + var isCreditCard_1 = createCommonjsModule(function (module, exports) { + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = isCreditCard; + var _assertString2 = _interopRequireDefault(_assertString); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + var creditCard = /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|62[0-9]{14})$/; + function isCreditCard(str) { + (0, _assertString2.default)(str); + var sanitized = str.replace(/[- ]+/g, ''); + if (!creditCard.test(sanitized)) { + return false; + } + var sum = 0; + var digit = void 0; + var tmpNum = void 0; + var shouldDouble = void 0; + for (var i = sanitized.length - 1;i >= 0; i--) { + digit = sanitized.substring(i, i + 1); + tmpNum = parseInt(digit, 10); + if (shouldDouble) { + tmpNum *= 2; + if (tmpNum >= 10) { + sum += tmpNum % 10 + 1; + } else { + sum += tmpNum; + } + } else { + sum += tmpNum; + } + shouldDouble = !shouldDouble; + } + return !(!(sum % 10 === 0 ? sanitized : false)); + } + + module.exports = exports['default']; + }); + var isCreditCard = unwrapExports(isCreditCard_1) -var formatters = { - // Month: 1, 2, ..., 12 - 'M': function (date) { - return date.getUTCMonth() + 1 - }, + function credit_card (value) { return isCreditCard(String(value)); } - // Month: 1st, 2nd, ..., 12th - 'Mo': function (date, options) { - var month = date.getUTCMonth() + 1; - return options.locale.localize.ordinalNumber(month, {unit: 'month'}) - }, + var validate$5 = function (value, ref) { + if ( ref === void 0 ) ref = []; + var decimals = ref[0]; if ( decimals === void 0 ) decimals = '*'; + var separator = ref[1]; if ( separator === void 0 ) separator = '.'; - // Month: 01, 02, ..., 12 - 'MM': function (date) { - return addLeadingZeros(date.getUTCMonth() + 1, 2) - }, + if (Array.isArray(value)) { + return value.every(function (val) { return validate$5(val, [decimals,separator]); }); + } + if (value === null || value === undefined || value === '') { + return true; + } + if (Number(decimals) === 0) { + return /^-?\d*$/.test(value); + } + var regexPart = decimals === '*' ? '+' : ("{1," + decimals + "}"); + var regex = new RegExp(("^-?\\d*(\\" + separator + "\\d" + regexPart + ")?$")); + if (!regex.test(value)) { + return false; + } + var parsedValue = parseFloat(value); + return parsedValue === parsedValue; + }; - // Month: Jan, Feb, ..., Dec - 'MMM': function (date, options) { - return options.locale.localize.month(date.getUTCMonth(), {type: 'short'}) - }, + function date_between (value, params) { + var assign, assign$1; - // Month: January, February, ..., December - 'MMMM': function (date, options) { - return options.locale.localize.month(date.getUTCMonth(), {type: 'long'}) - }, + var min$$1; + var max$$1; + var format$$1; + var inclusivity = '()'; + if (params.length > 3) { + (assign = params, min$$1 = assign[0], max$$1 = assign[1], inclusivity = assign[2], format$$1 = assign[3]); + } else { + (assign$1 = params, min$$1 = assign$1[0], max$$1 = assign$1[1], format$$1 = assign$1[2]); + } + var minDate = parseDate$1(String(min$$1), format$$1); + var maxDate = parseDate$1(String(max$$1), format$$1); + var dateVal = parseDate$1(String(value), format$$1); + if (!minDate || !maxDate || !dateVal) { + return false; + } + if (inclusivity === '()') { + return isAfter(dateVal, minDate) && isBefore(dateVal, maxDate); + } + if (inclusivity === '(]') { + return isAfter(dateVal, minDate) && (isEqual(dateVal, maxDate) || isBefore(dateVal, maxDate)); + } + if (inclusivity === '[)') { + return isBefore(dateVal, maxDate) && (isEqual(dateVal, minDate) || isAfter(dateVal, minDate)); + } + return isEqual(dateVal, maxDate) || isEqual(dateVal, minDate) || isBefore(dateVal, maxDate) && isAfter(dateVal, minDate); + } - // Quarter: 1, 2, 3, 4 - 'Q': function (date) { - return Math.ceil((date.getUTCMonth() + 1) / 3) - }, + function date_format (value, ref) { + var format = ref[0]; - // Quarter: 1st, 2nd, 3rd, 4th - 'Qo': function (date, options) { - var quarter = Math.ceil((date.getUTCMonth() + 1) / 3); - return options.locale.localize.ordinalNumber(quarter, {unit: 'quarter'}) - }, + return !(!parseDate$1(value, format)); + } - // Day of month: 1, 2, ..., 31 - 'D': function (date) { - return date.getUTCDate() - }, + var validate$6 = function (value, ref) { + var length = ref[0]; - // Day of month: 1st, 2nd, ..., 31st - 'Do': function (date, options) { - return options.locale.localize.ordinalNumber(date.getUTCDate(), {unit: 'dayOfMonth'}) - }, + if (Array.isArray(value)) { + return value.every(function (val) { return validate$6(val, [length]); }); + } + var strVal = String(value); + return /^[0-9]*$/.test(strVal) && strVal.length === Number(length); + }; - // Day of month: 01, 02, ..., 31 - 'DD': function (date) { - return addLeadingZeros(date.getUTCDate(), 2) - }, + var validateImage = function (file, width, height) { + var URL = window.URL || window.webkitURL; + return new Promise(function (resolve) { + var image = new Image(); + image.onerror = (function () { return resolve({ + valid: false + }); }); + image.onload = (function () { return resolve({ + valid: image.width === Number(width) && image.height === Number(height) + }); }); + image.src = URL.createObjectURL(file); + }); + }; + function dimensions (files, ref) { + var width = ref[0]; + var height = ref[1]; + + var list = []; + for (var i = 0;i < files.length; i++) { + if (!/\.(jpg|svg|jpeg|png|bmp|gif)$/i.test(files[i].name)) { + return false; + } + list.push(files[i]); + } + return Promise.all(list.map(function (file) { return validateImage(file, width, height); })); + } - // Day of year: 1, 2, ..., 366 - 'DDD': function (date) { - return getUTCDayOfYear(date) - }, + var merge_1 = createCommonjsModule(function (module, exports) { + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = merge; + function merge() { + var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var defaults = arguments[1]; + for (var key in defaults) { + if (typeof obj[key] === 'undefined') { + obj[key] = defaults[key]; + } + } + return obj; + } + + module.exports = exports['default']; + }); + var merge = unwrapExports(merge_1) - // Day of year: 1st, 2nd, ..., 366th - 'DDDo': function (date, options) { - return options.locale.localize.ordinalNumber(getUTCDayOfYear(date), {unit: 'dayOfYear'}) - }, + var merge$1 = /*#__PURE__*/Object.freeze({ + default: merge, + __moduleExports: merge_1 + }); - // Day of year: 001, 002, ..., 366 - 'DDDD': function (date) { - return addLeadingZeros(getUTCDayOfYear(date), 3) - }, + var isByteLength_1 = createCommonjsModule(function (module, exports) { + Object.defineProperty(exports, "__esModule", { + value: true + }); + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { + return typeof obj; + } : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + exports.default = isByteLength; + var _assertString2 = _interopRequireDefault(_assertString); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + function isByteLength(str, options) { + (0, _assertString2.default)(str); + var min = void 0; + var max = void 0; + if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object') { + min = options.min || 0; + max = options.max; + } else { + min = arguments[1]; + max = arguments[2]; + } + var len = encodeURI(str).split(/%..|./).length - 1; + return len >= min && (typeof max === 'undefined' || len <= max); + } + + module.exports = exports['default']; + }); + var isByteLength = unwrapExports(isByteLength_1) - // Day of week: Su, Mo, ..., Sa - 'dd': function (date, options) { - return options.locale.localize.weekday(date.getUTCDay(), {type: 'narrow'}) - }, + var isByteLength$1 = /*#__PURE__*/Object.freeze({ + default: isByteLength, + __moduleExports: isByteLength_1 + }); - // Day of week: Sun, Mon, ..., Sat - 'ddd': function (date, options) { - return options.locale.localize.weekday(date.getUTCDay(), {type: 'short'}) - }, + var _merge = ( merge$1 && merge ) || merge$1; - // Day of week: Sunday, Monday, ..., Saturday - 'dddd': function (date, options) { - return options.locale.localize.weekday(date.getUTCDay(), {type: 'long'}) - }, + var isFQDN_1 = createCommonjsModule(function (module, exports) { + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = isFQDN; + var _assertString2 = _interopRequireDefault(_assertString); + var _merge2 = _interopRequireDefault(_merge); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + var default_fqdn_options = { + require_tld: true, + allow_underscores: false, + allow_trailing_dot: false + }; + function isFQDN(str, options) { + (0, _assertString2.default)(str); + options = (0, _merge2.default)(options, default_fqdn_options); + if (options.allow_trailing_dot && str[str.length - 1] === '.') { + str = str.substring(0, str.length - 1); + } + var parts = str.split('.'); + if (options.require_tld) { + var tld = parts.pop(); + if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) { + return false; + } + if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20]/.test(tld)) { + return false; + } + } + for (var part, i = 0;i < parts.length; i++) { + part = parts[i]; + if (options.allow_underscores) { + part = part.replace(/_/g, ''); + } + if (!/^[a-z\u00a1-\uffff0-9-]+$/i.test(part)) { + return false; + } + if (/[\uff01-\uff5e]/.test(part)) { + return false; + } + if (part[0] === '-' || part[part.length - 1] === '-') { + return false; + } + } + return true; + } + + module.exports = exports['default']; + }); + var isFQDN = unwrapExports(isFQDN_1) - // Day of week: 0, 1, ..., 6 - 'd': function (date) { - return date.getUTCDay() - }, + var isFQDN$1 = /*#__PURE__*/Object.freeze({ + default: isFQDN, + __moduleExports: isFQDN_1 + }); - // Day of week: 0th, 1st, 2nd, ..., 6th - 'do': function (date, options) { - return options.locale.localize.ordinalNumber(date.getUTCDay(), {unit: 'dayOfWeek'}) - }, + var _isByteLength = ( isByteLength$1 && isByteLength ) || isByteLength$1; - // Day of ISO week: 1, 2, ..., 7 - 'E': function (date) { - return date.getUTCDay() || 7 - }, + var _isFQDN = ( isFQDN$1 && isFQDN ) || isFQDN$1; - // ISO week: 1, 2, ..., 53 - 'W': function (date) { - return getUTCISOWeek(date) - }, - - // ISO week: 1st, 2nd, ..., 53th - 'Wo': function (date, options) { - return options.locale.localize.ordinalNumber(getUTCISOWeek(date), {unit: 'isoWeek'}) - }, - - // ISO week: 01, 02, ..., 53 - 'WW': function (date) { - return addLeadingZeros(getUTCISOWeek(date), 2) - }, - - // Year: 00, 01, ..., 99 - 'YY': function (date) { - return addLeadingZeros(date.getUTCFullYear(), 4).substr(2) - }, - - // Year: 1900, 1901, ..., 2099 - 'YYYY': function (date) { - return addLeadingZeros(date.getUTCFullYear(), 4) - }, + var isEmail_1 = createCommonjsModule(function (module, exports) { + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = isEmail; + var _assertString2 = _interopRequireDefault(_assertString); + var _merge2 = _interopRequireDefault(_merge); + var _isByteLength2 = _interopRequireDefault(_isByteLength); + var _isFQDN2 = _interopRequireDefault(_isFQDN); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + var default_email_options = { + allow_display_name: false, + require_display_name: false, + allow_utf8_local_part: true, + require_tld: true + }; + var displayName = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\,\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/i; + var emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i; + var quotedEmailUser = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i; + var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i; + var quotedEmailUserUtf8 = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i; + function isEmail(str, options) { + (0, _assertString2.default)(str); + options = (0, _merge2.default)(options, default_email_options); + if (options.require_display_name || options.allow_display_name) { + var display_email = str.match(displayName); + if (display_email) { + str = display_email[1]; + } else if (options.require_display_name) { + return false; + } + } + var parts = str.split('@'); + var domain = parts.pop(); + var user = parts.join('@'); + var lower_domain = domain.toLowerCase(); + if (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com') { + user = user.replace(/\./g, '').toLowerCase(); + } + if (!(0, _isByteLength2.default)(user, { + max: 64 + }) || !(0, _isByteLength2.default)(domain, { + max: 254 + })) { + return false; + } + if (!(0, _isFQDN2.default)(domain, { + require_tld: options.require_tld + })) { + return false; + } + if (user[0] === '"') { + user = user.slice(1, user.length - 1); + return options.allow_utf8_local_part ? quotedEmailUserUtf8.test(user) : quotedEmailUser.test(user); + } + var pattern = options.allow_utf8_local_part ? emailUserUtf8Part : emailUserPart; + var user_parts = user.split('.'); + for (var i = 0;i < user_parts.length; i++) { + if (!pattern.test(user_parts[i])) { + return false; + } + } + return true; + } + + module.exports = exports['default']; + }); + var isEmail = unwrapExports(isEmail_1) - // ISO week-numbering year: 00, 01, ..., 99 - 'GG': function (date) { - return String(getUTCISOWeekYear(date)).substr(2) - }, + var validate$7 = function (value) { + if (Array.isArray(value)) { + return value.every(function (val) { return isEmail(String(val)); }); + } + return isEmail(String(value)); + }; - // ISO week-numbering year: 1900, 1901, ..., 2099 - 'GGGG': function (date) { - return getUTCISOWeekYear(date) - }, + function ext (files, extensions) { + var regex = new RegExp((".(" + (extensions.join('|')) + ")$"), 'i'); + return files.every(function (file) { return regex.test(file.name); }); + } - // Hour: 0, 1, ... 23 - 'H': function (date) { - return date.getUTCHours() - }, + function image (files) { return files.every(function (file) { return /\.(jpg|svg|jpeg|png|bmp|gif)$/i.test(file.name); }); } - // Hour: 00, 01, ..., 23 - 'HH': function (date) { - return addLeadingZeros(date.getUTCHours(), 2) - }, + var validate$8 = function (value, options) { + if (Array.isArray(value)) { + return value.every(function (val) { return validate$8(val, options); }); + } + return !(!options.filter(function (option) { return option == value; }).length); + }; - // Hour: 1, 2, ..., 12 - 'h': function (date) { - var hours = date.getUTCHours(); - if (hours === 0) { - return 12 - } else if (hours > 12) { - return hours % 12 - } else { - return hours - } - }, + var isIP_1 = createCommonjsModule(function (module, exports) { + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = isIP; + var _assertString2 = _interopRequireDefault(_assertString); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + var ipv4Maybe = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/; + var ipv6Block = /^[0-9A-F]{1,4}$/i; + function isIP(str) { + var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; + (0, _assertString2.default)(str); + version = String(version); + if (!version) { + return isIP(str, 4) || isIP(str, 6); + } else if (version === '4') { + if (!ipv4Maybe.test(str)) { + return false; + } + var parts = str.split('.').sort(function (a, b) { + return a - b; + }); + return parts[3] <= 255; + } else if (version === '6') { + var blocks = str.split(':'); + var foundOmissionBlock = false; + var foundIPv4TransitionBlock = isIP(blocks[blocks.length - 1], 4); + var expectedNumberOfBlocks = foundIPv4TransitionBlock ? 7 : 8; + if (blocks.length > expectedNumberOfBlocks) { + return false; + } + if (str === '::') { + return true; + } else if (str.substr(0, 2) === '::') { + blocks.shift(); + blocks.shift(); + foundOmissionBlock = true; + } else if (str.substr(str.length - 2) === '::') { + blocks.pop(); + blocks.pop(); + foundOmissionBlock = true; + } + for (var i = 0;i < blocks.length; ++i) { + if (blocks[i] === '' && i > 0 && i < blocks.length - 1) { + if (foundOmissionBlock) { + return false; + } + foundOmissionBlock = true; + } else if (foundIPv4TransitionBlock && i === blocks.length - 1) ; else if (!ipv6Block.test(blocks[i])) { + return false; + } + } + if (foundOmissionBlock) { + return blocks.length >= 1; + } + return blocks.length === expectedNumberOfBlocks; + } + return false; + } + + module.exports = exports['default']; + }); + var isIP = unwrapExports(isIP_1) - // Hour: 01, 02, ..., 12 - 'hh': function (date) { - return addLeadingZeros(formatters['h'](date), 2) - }, + var supportsPassive = true; + var detectPassiveSupport = function () { + try { + var opts = Object.defineProperty({}, 'passive', { + get: function get() { + supportsPassive = true; + } + }); + window.addEventListener('testPassive', null, opts); + window.removeEventListener('testPassive', null, opts); + } catch (e) { + supportsPassive = false; + } + return supportsPassive; + }; + var addEventListener = function (el, eventName, cb) { + el.addEventListener(eventName, cb, supportsPassive ? { + passive: true + } : false); + }; + var isTextInput = function (el) { return ['text','number','password','search','email','tel', + 'url','textarea'].indexOf(el.type) !== -1; }; + var isCheckboxOrRadioInput = function (el) { return ['radio','checkbox'].indexOf(el.type) !== -1; }; + var getDataAttribute = function (el, name) { return el.getAttribute(("data-vv-" + name)); }; + var isNullOrUndefined = function (value) { return value === null || value === undefined; }; + var createFlags = function () { return ({ + untouched: true, + touched: false, + dirty: false, + pristine: true, + valid: null, + invalid: null, + validated: false, + pending: false, + required: false, + changed: false + }); }; + var isEqual$1 = function (lhs, rhs) { + if (lhs instanceof RegExp && rhs instanceof RegExp) { + return isEqual$1(lhs.source, rhs.source) && isEqual$1(lhs.flags, rhs.flags); + } + if (Array.isArray(lhs) && Array.isArray(rhs)) { + if (lhs.length !== rhs.length) + { return false; } + for (var i = 0;i < lhs.length; i++) { + if (!isEqual$1(lhs[i], rhs[i])) { + return false; + } + } + return true; + } + if (isObject(lhs) && isObject(rhs)) { + return Object.keys(lhs).every(function (key) { return isEqual$1(lhs[key], rhs[key]); }) && Object.keys(rhs).every(function (key) { return isEqual$1(lhs[key], rhs[key]); }); + } + return lhs === rhs; + }; + var getScope = function (el) { + var scope = getDataAttribute(el, 'scope'); + if (isNullOrUndefined(scope)) { + var form = getForm(el); + if (form) { + scope = getDataAttribute(form, 'scope'); + } + } + return !isNullOrUndefined(scope) ? scope : null; + }; + var getForm = function (el) { + if (isNullOrUndefined(el)) + { return null; } + if (el.tagName === "FORM") + { return el; } + if (!isNullOrUndefined(el.form)) + { return el.form; } + return !isNullOrUndefined(el.parentNode) ? getForm(el.parentNode) : null; + }; + var getPath = function (path, target, def) { + if ( def === void 0 ) def = undefined; + + if (!path || !target) + { return def; } + var value = target; + path.split('.').every(function (prop) { + if (!Object.prototype.hasOwnProperty.call(value, prop) && value[prop] === undefined) { + value = def; + return false; + } + value = value[prop]; + return true; + }); + return value; + }; + var hasPath = function (path, target) { + var obj = target; + return path.split('.').every(function (prop) { + if (!Object.prototype.hasOwnProperty.call(obj, prop)) { + return false; + } + obj = obj[prop]; + return true; + }); + }; + var parseRule = function (rule) { + var params = []; + var name = rule.split(':')[0]; + if (~rule.indexOf(':')) { + params = rule.split(':').slice(1).join(':').split(','); + } + return { + name: name, + params: params + }; + }; + var debounce = function (fn, wait, immediate, token) { + if ( wait === void 0 ) wait = 0; + if ( immediate === void 0 ) immediate = false; + if ( token === void 0 ) token = { + cancelled: false + }; - // Minute: 0, 1, ..., 59 - 'm': function (date) { - return date.getUTCMinutes() - }, + if (wait === 0) { + return fn; + } + var timeout; + return function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + var later = function () { + timeout = null; + if (!immediate && !token.cancelled) + { fn.apply(void 0, args); } + }; + var callNow = immediate && !timeout; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + if (callNow) + { fn.apply(void 0, args); } + }; + }; + var normalizeRules = function (rules) { + if (!rules) { + return {}; + } + if (isObject(rules)) { + return Object.keys(rules).reduce(function (prev, curr) { + var params = []; + if (rules[curr] === true) { + params = []; + } else if (Array.isArray(rules[curr])) { + params = rules[curr]; + } else { + params = [rules[curr]]; + } + if (rules[curr] !== false) { + prev[curr] = params; + } + return prev; + }, {}); + } + if (typeof rules !== 'string') { + warn('rules must be either a string or an object.'); + return {}; + } + return rules.split('|').reduce(function (prev, rule) { + var parsedRule = parseRule(rule); + if (!parsedRule.name) { + return prev; + } + prev[parsedRule.name] = parsedRule.params; + return prev; + }, {}); + }; + var warn = function (message) { + console.warn(("[vee-validate] " + message)); + }; + var createError = function (message) { return new Error(("[vee-validate] " + message)); }; + var isObject = function (obj) { return obj !== null && obj && typeof obj === 'object' && !Array.isArray(obj); }; + var isCallable = function (func) { return typeof func === 'function'; }; + var hasClass = function (el, className) { + if (el.classList) { + return el.classList.contains(className); + } + return !(!el.className.match(new RegExp(("(\\s|^)" + className + "(\\s|$)")))); + }; + var addClass = function (el, className) { + if (el.classList) { + el.classList.add(className); + return; + } + if (!hasClass(el, className)) { + el.className += " " + className; + } + }; + var removeClass = function (el, className) { + if (el.classList) { + el.classList.remove(className); + return; + } + if (hasClass(el, className)) { + var reg = new RegExp(("(\\s|^)" + className + "(\\s|$)")); + el.className = el.className.replace(reg, ' '); + } + }; + var toggleClass = function (el, className, status) { + if (!el || !className) + { return; } + if (Array.isArray(className)) { + className.forEach(function (item) { return toggleClass(el, item, status); }); + return; + } + if (status) { + return addClass(el, className); + } + removeClass(el, className); + }; + var toArray = function (arrayLike) { + if (isCallable(Array.from)) { + return Array.from(arrayLike); + } + var array = []; + var length = arrayLike.length; + for (var i = 0;i < length; i++) { + array.push(arrayLike[i]); + } + return array; + }; + var assign = function (target) { + var others = [], len = arguments.length - 1; + while ( len-- > 0 ) others[ len ] = arguments[ len + 1 ]; - // Minute: 00, 01, ..., 59 - 'mm': function (date) { - return addLeadingZeros(date.getUTCMinutes(), 2) - }, + if (isCallable(Object.assign)) { + return Object.assign.apply(Object, [ target ].concat( others )); + } + if (target == null) { + throw new TypeError('Cannot convert undefined or null to object'); + } + var to = Object(target); + others.forEach(function (arg) { + if (arg != null) { + Object.keys(arg).forEach(function (key) { + to[key] = arg[key]; + }); + } + }); + return to; + }; + var id = 0; + var idTemplate = '{id}'; + var uniqId = function () { + if (id >= 9999) { + id = 0; + idTemplate = idTemplate.replace('{id}', '_{id}'); + } + id++; + var newId = idTemplate.replace('{id}', String(id)); + return newId; + }; + var find = function (arrayLike, predicate) { + var array = Array.isArray(arrayLike) ? arrayLike : toArray(arrayLike); + for (var i = 0;i < array.length; i++) { + if (predicate(array[i])) { + return array[i]; + } + } + return undefined; + }; + var isBuiltInComponent = function (vnode) { + if (!vnode) { + return false; + } + var tag = vnode.componentOptions.tag; + return /keep-alive|transition|transition-group/.test(tag); + }; + var makeEventsArray = function (events) { return typeof events === 'string' && events.length ? events.split('|') : []; }; + var makeDelayObject = function (events, delay, delayConfig) { + if (typeof delay === 'number') { + return events.reduce(function (prev, e) { + prev[e] = delay; + return prev; + }, {}); + } + return events.reduce(function (prev, e) { + if (typeof delay === 'object' && e in delay) { + prev[e] = delay[e]; + return prev; + } + if (typeof delayConfig === 'number') { + prev[e] = delayConfig; + return prev; + } + prev[e] = delayConfig && delayConfig[e] || 0; + return prev; + }, {}); + }; + var deepParseInt = function (input) { + if (typeof input === 'number') + { return input; } + if (typeof input === 'string') + { return parseInt(input); } + var map = {}; + for (var element in input) { + map[element] = parseInt(input[element]); + } + return map; + }; + var merge$2 = function (target, source) { + if (!(isObject(target) && isObject(source))) { + return target; + } + Object.keys(source).forEach(function (key) { + var obj, obj$1; - // Second: 0, 1, ..., 59 - 's': function (date) { - return date.getUTCSeconds() - }, + if (isObject(source[key])) { + if (!target[key]) { + assign(target, ( obj = {}, obj[key] = {}, obj )); + } + merge$2(target[key], source[key]); + return; + } + assign(target, ( obj$1 = {}, obj$1[key] = source[key], obj$1 )); + }); + return target; + }; - // Second: 00, 01, ..., 59 - 'ss': function (date) { - return addLeadingZeros(date.getUTCSeconds(), 2) - }, + function ip (value, ref) { + if ( ref === void 0 ) ref = []; + var version = ref[0]; if ( version === void 0 ) version = 4; - // 1/10 of second: 0, 1, ..., 9 - 'S': function (date) { - return Math.floor(date.getUTCMilliseconds() / 100) - }, + if (isNullOrUndefined(value)) { + value = ''; + } + if (Array.isArray(value)) { + return value.every(function (val) { return isIP(val, version); }); + } + return isIP(value, version); + } - // 1/100 of second: 00, 01, ..., 99 - 'SS': function (date) { - return addLeadingZeros(Math.floor(date.getUTCMilliseconds() / 10), 2) - }, + function is (value, ref) { + if ( ref === void 0 ) ref = []; + var other = ref[0]; - // Millisecond: 000, 001, ..., 999 - 'SSS': function (date) { - return addLeadingZeros(date.getUTCMilliseconds(), 3) - }, + return value === other; + } - // Timezone: -01:00, +00:00, ... +12:00 - 'Z': function (date, options) { - var originalDate = options._originalDate || date; - return formatTimezone(originalDate.getTimezoneOffset(), ':') - }, + function is_not (value, ref) { + if ( ref === void 0 ) ref = []; + var other = ref[0]; - // Timezone: -0100, +0000, ... +1200 - 'ZZ': function (date, options) { - var originalDate = options._originalDate || date; - return formatTimezone(originalDate.getTimezoneOffset()) - }, + return value !== other; + } - // Seconds timestamp: 512969520 - 'X': function (date, options) { - var originalDate = options._originalDate || date; - return Math.floor(originalDate.getTime() / 1000) - }, + var compare = function (value, length, max) { + if (max === undefined) { + return value.length === length; + } + max = Number(max); + return value.length >= length && value.length <= max; + }; + function length (value, ref) { + var length = ref[0]; + var max = ref[1]; if ( max === void 0 ) max = undefined; - // Milliseconds timestamp: 512969520900 - 'x': function (date, options) { - var originalDate = options._originalDate || date; - return originalDate.getTime() - }, + length = Number(length); + if (value === undefined || value === null) { + return false; + } + if (typeof value === 'number') { + value = String(value); + } + if (!value.length) { + value = toArray(value); + } + return compare(value, length, max); + } - // AM, PM - 'A': function (date, options) { - return options.locale.localize.timeOfDay(date.getUTCHours(), {type: 'uppercase'}) - }, + function integer (value) { + if (Array.isArray(value)) { + return value.every(function (val) { return /^-?[0-9]+$/.test(String(val)); }); + } + return /^-?[0-9]+$/.test(String(value)); + } - // am, pm - 'a': function (date, options) { - return options.locale.localize.timeOfDay(date.getUTCHours(), {type: 'lowercase'}) - }, + function max$1 (value, ref) { + var length = ref[0]; - // a.m., p.m. - 'aa': function (date, options) { - return options.locale.localize.timeOfDay(date.getUTCHours(), {type: 'long'}) + if (value === undefined || value === null) { + return length >= 0; + } + return String(value).length <= length; } -}; -function formatTimezone (offset, delimeter) { - delimeter = delimeter || ''; - var sign = offset > 0 ? '-' : '+'; - var absOffset = Math.abs(offset); - var hours = Math.floor(absOffset / 60); - var minutes = absOffset % 60; - return sign + addLeadingZeros(hours, 2) + delimeter + addLeadingZeros(minutes, 2) -} + function max_value (value, ref) { + var max = ref[0]; -function addLeadingZeros (number, targetLength) { - var output = Math.abs(number).toString(); - while (output.length < targetLength) { - output = '0' + output; + if (Array.isArray(value) || value === null || value === undefined || value === '') { + return false; + } + return Number(value) <= max; } - return output -} -// This function will be a part of public API when UTC function will be implemented. -// See issue: https://github.com/date-fns/date-fns/issues/376 -function addUTCMinutes (dirtyDate, dirtyAmount, dirtyOptions) { - var date = toDate(dirtyDate, dirtyOptions); - var amount = Number(dirtyAmount); - date.setUTCMinutes(date.getUTCMinutes() + amount); - return date -} + function mimes (files, mimes) { + var regex = new RegExp(((mimes.join('|').replace('*', '.+')) + "$"), 'i'); + return files.every(function (file) { return regex.test(file.type); }); + } -var longFormattingTokensRegExp = /(\[[^[]*])|(\\)?(LTS|LT|LLLL|LLL|LL|L|llll|lll|ll|l)/g; -var defaultFormattingTokensRegExp = /(\[[^[]*])|(\\)?(x|ss|s|mm|m|hh|h|do|dddd|ddd|dd|d|aa|a|ZZ|Z|YYYY|YY|X|Wo|WW|W|SSS|SS|S|Qo|Q|Mo|MMMM|MMM|MM|M|HH|H|GGGG|GG|E|Do|DDDo|DDDD|DDD|DD|D|A|.)/g; + function min$1 (value, ref) { + var length = ref[0]; -/** - * @name format - * @category Common Helpers - * @summary Format the date. - * - * @description - * Return the formatted date string in the given format. - * - * Accepted tokens: - * | Unit | Token | Result examples | - * |-------------------------|-------|----------------------------------| - * | Month | M | 1, 2, ..., 12 | - * | | Mo | 1st, 2nd, ..., 12th | - * | | MM | 01, 02, ..., 12 | - * | | MMM | Jan, Feb, ..., Dec | - * | | MMMM | January, February, ..., December | - * | Quarter | Q | 1, 2, 3, 4 | - * | | Qo | 1st, 2nd, 3rd, 4th | - * | Day of month | D | 1, 2, ..., 31 | - * | | Do | 1st, 2nd, ..., 31st | - * | | DD | 01, 02, ..., 31 | - * | Day of year | DDD | 1, 2, ..., 366 | - * | | DDDo | 1st, 2nd, ..., 366th | - * | | DDDD | 001, 002, ..., 366 | - * | Day of week | d | 0, 1, ..., 6 | - * | | do | 0th, 1st, ..., 6th | - * | | dd | Su, Mo, ..., Sa | - * | | ddd | Sun, Mon, ..., Sat | - * | | dddd | Sunday, Monday, ..., Saturday | - * | Day of ISO week | E | 1, 2, ..., 7 | - * | ISO week | W | 1, 2, ..., 53 | - * | | Wo | 1st, 2nd, ..., 53rd | - * | | WW | 01, 02, ..., 53 | - * | Year | YY | 00, 01, ..., 99 | - * | | YYYY | 1900, 1901, ..., 2099 | - * | ISO week-numbering year | GG | 00, 01, ..., 99 | - * | | GGGG | 1900, 1901, ..., 2099 | - * | AM/PM | A | AM, PM | - * | | a | am, pm | - * | | aa | a.m., p.m. | - * | Hour | H | 0, 1, ... 23 | - * | | HH | 00, 01, ... 23 | - * | | h | 1, 2, ..., 12 | - * | | hh | 01, 02, ..., 12 | - * | Minute | m | 0, 1, ..., 59 | - * | | mm | 00, 01, ..., 59 | - * | Second | s | 0, 1, ..., 59 | - * | | ss | 00, 01, ..., 59 | - * | 1/10 of second | S | 0, 1, ..., 9 | - * | 1/100 of second | SS | 00, 01, ..., 99 | - * | Millisecond | SSS | 000, 001, ..., 999 | - * | Timezone | Z | -01:00, +00:00, ... +12:00 | - * | | ZZ | -0100, +0000, ..., +1200 | - * | Seconds timestamp | X | 512969520 | - * | Milliseconds timestamp | x | 512969520900 | - * | Long format | LT | 05:30 a.m. | - * | | LTS | 05:30:15 a.m. | - * | | L | 07/02/1995 | - * | | l | 7/2/1995 | - * | | LL | July 2 1995 | - * | | ll | Jul 2 1995 | - * | | LLL | July 2 1995 05:30 a.m. | - * | | lll | Jul 2 1995 05:30 a.m. | - * | | LLLL | Sunday, July 2 1995 05:30 a.m. | - * | | llll | Sun, Jul 2 1995 05:30 a.m. | - * - * The characters wrapped in square brackets are escaped. - * - * The result may vary by locale. - * - * @param {Date|String|Number} date - the original date - * @param {String} format - the string of tokens - * @param {Options} [options] - the object with options. See [Options]{@link https://date-fns.org/docs/Options} - * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate} - * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale} - * @returns {String} the formatted date string - * @throws {TypeError} 2 arguments required - * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 - * @throws {RangeError} `options.locale` must contain `localize` property - * @throws {RangeError} `options.locale` must contain `formatLong` property - * - * @example - * // Represent 11 February 2014 in middle-endian format: - * var result = format( - * new Date(2014, 1, 11), - * 'MM/DD/YYYY' - * ) - * //=> '02/11/2014' - * - * @example - * // Represent 2 July 2014 in Esperanto: - * import { eoLocale } from 'date-fns/locale/eo' - * var result = format( - * new Date(2014, 6, 2), - * 'Do [de] MMMM YYYY', - * {locale: eoLocale} - * ) - * //=> '2-a de julio 2014' - */ -function format (dirtyDate, dirtyFormatStr, dirtyOptions) { - if (arguments.length < 2) { - throw new TypeError('2 arguments required, but only ' + arguments.length + ' present') + if (value === undefined || value === null) { + return false; + } + return String(value).length >= length; } - var formatStr = String(dirtyFormatStr); - var options = dirtyOptions || {}; - - var locale$$1 = options.locale || locale; + function min_value (value, ref) { + var min = ref[0]; - if (!locale$$1.localize) { - throw new RangeError('locale must contain localize property') + if (Array.isArray(value) || value === null || value === undefined || value === '') { + return false; + } + return Number(value) >= min; } - if (!locale$$1.formatLong) { - throw new RangeError('locale must contain formatLong property') - } + var validate$9 = function (value, options) { + if (Array.isArray(value)) { + return value.every(function (val) { return validate$9(val, options); }); + } + return !options.filter(function (option) { return option == value; }).length; + }; - var localeFormatters = locale$$1.formatters || {}; - var formattingTokensRegExp = locale$$1.formattingTokensRegExp || defaultFormattingTokensRegExp; - var formatLong = locale$$1.formatLong; + function numeric (value) { + if (Array.isArray(value)) { + return value.every(function (val) { return /^[0-9]+$/.test(String(val)); }); + } + return /^[0-9]+$/.test(String(value)); + } - var originalDate = toDate(dirtyDate, options); + function regex (value, ref) { + var regex = ref[0]; + var flags = ref.slice(1); - if (!isValid(originalDate, options)) { - return 'Invalid Date' + if (regex instanceof RegExp) { + return regex.test(value); + } + return new RegExp(regex, flags).test(String(value)); } - // Convert the date in system timezone to the same date in UTC+00:00 timezone. - // This ensures that when UTC functions will be implemented, locales will be compatible with them. - // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376 - var timezoneOffset = originalDate.getTimezoneOffset(); - var utcDate = addUTCMinutes(originalDate, -timezoneOffset, options); + function required (value, ref) { + if ( ref === void 0 ) ref = []; + var invalidateFalse = ref[0]; if ( invalidateFalse === void 0 ) invalidateFalse = false; - var formatterOptions = cloneObject(options); - formatterOptions.locale = locale$$1; - formatterOptions.formatters = formatters; + if (Array.isArray(value)) { + return !(!value.length); + } + if (value === false && invalidateFalse) { + return false; + } + if (value === undefined || value === null) { + return false; + } + return !(!String(value).trim().length); + } - // When UTC functions will be implemented, options._originalDate will likely be a part of public API. - // Right now, please don't use it in locales. If you have to use an original date, - // please restore it from `date`, adding a timezone offset to it. - formatterOptions._originalDate = originalDate; + function size (files, ref) { + var size = ref[0]; - var result = formatStr - .replace(longFormattingTokensRegExp, function (substring) { - if (substring[0] === '[') { - return substring + if (isNaN(size)) { + return false; + } + var nSize = Number(size) * 1024; + for (var i = 0;i < files.length; i++) { + if (files[i].size > nSize) { + return false; + } } + return true; + } - if (substring[0] === '\\') { - return cleanEscapedString(substring) + var isURL_1 = createCommonjsModule(function (module, exports) { + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = isURL; + var _assertString2 = _interopRequireDefault(_assertString); + var _isFQDN2 = _interopRequireDefault(_isFQDN); + var _isIP2 = _interopRequireDefault(isIP_1); + var _merge2 = _interopRequireDefault(_merge); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + var default_url_options = { + protocols: ['http','https','ftp'], + require_tld: true, + require_protocol: false, + require_host: true, + require_valid_protocol: true, + allow_underscores: false, + allow_trailing_dot: false, + allow_protocol_relative_urls: false + }; + var wrapped_ipv6 = /^\[([^\]]+)\](?::([0-9]+))?$/; + function isRegExp(obj) { + return Object.prototype.toString.call(obj) === '[object RegExp]'; + } + + function checkHost(host, matches) { + for (var i = 0;i < matches.length; i++) { + var match = matches[i]; + if (host === match || isRegExp(match) && match.test(host)) { + return true; + } + } + return false; + } + + function isURL(url, options) { + (0, _assertString2.default)(url); + if (!url || url.length >= 2083 || /[\s<>]/.test(url)) { + return false; + } + if (url.indexOf('mailto:') === 0) { + return false; + } + options = (0, _merge2.default)(options, default_url_options); + var protocol = void 0, auth = void 0, host = void 0, hostname = void 0, port = void 0, port_str = void 0, split = void 0, ipv6 = void 0; + split = url.split('#'); + url = split.shift(); + split = url.split('?'); + url = split.shift(); + split = url.split('://'); + if (split.length > 1) { + protocol = split.shift(); + if (options.require_valid_protocol && options.protocols.indexOf(protocol) === -1) { + return false; + } + } else if (options.require_protocol) { + return false; + } else if (options.allow_protocol_relative_urls && url.substr(0, 2) === '//') { + split[0] = url.substr(2); + } + url = split.join('://'); + if (url === '') { + return false; + } + split = url.split('/'); + url = split.shift(); + if (url === '' && !options.require_host) { + return true; + } + split = url.split('@'); + if (split.length > 1) { + auth = split.shift(); + if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) { + return false; + } + } + hostname = split.join('@'); + port_str = null; + ipv6 = null; + var ipv6_match = hostname.match(wrapped_ipv6); + if (ipv6_match) { + host = ''; + ipv6 = ipv6_match[1]; + port_str = ipv6_match[2] || null; + } else { + split = hostname.split(':'); + host = split.shift(); + if (split.length) { + port_str = split.join(':'); + } + } + if (port_str !== null) { + port = parseInt(port_str, 10); + if (!/^[0-9]+$/.test(port_str) || port <= 0 || port > 65535) { + return false; + } + } + if (!(0, _isIP2.default)(host) && !(0, _isFQDN2.default)(host, options) && (!ipv6 || !(0, _isIP2.default)(ipv6, 6))) { + return false; + } + host = host || ipv6; + if (options.host_whitelist && !checkHost(host, options.host_whitelist)) { + return false; + } + if (options.host_blacklist && checkHost(host, options.host_blacklist)) { + return false; + } + return true; } + + module.exports = exports['default']; + }); + var isURL = unwrapExports(isURL_1) - return formatLong(substring) - }) - .replace(formattingTokensRegExp, function (substring) { - var formatter = localeFormatters[substring] || formatters[substring]; + function url (value, ref) { + if ( ref === void 0 ) ref = []; + var requireProtocol = ref[0]; if ( requireProtocol === void 0 ) requireProtocol = false; - if (formatter) { - return formatter(utcDate, formatterOptions) - } else { - return cleanEscapedString(substring) + var options = { + require_protocol: !(!requireProtocol), + allow_underscores: true + }; + if (isNullOrUndefined(value)) { + value = ''; } - }); + if (Array.isArray(value)) { + return value.every(function (val) { return isURL(val, options); }); + } + return isURL(value, options); + } + + var Rules = { + after: after, + alpha_dash: validate$1, + alpha_num: validate$2, + alpha_spaces: validate$3, + alpha: validate, + before: before, + between: validate$4, + confirmed: confirmed, + credit_card: credit_card, + date_between: date_between, + date_format: date_format, + decimal: validate$5, + digits: validate$6, + dimensions: dimensions, + email: validate$7, + ext: ext, + image: image, + in: validate$8, + integer: integer, + length: length, + ip: ip, + is_not: is_not, + is: is, + max: max$1, + max_value: max_value, + mimes: mimes, + min: min$1, + min_value: min_value, + not_in: validate$9, + numeric: numeric, + regex: regex, + required: required, + size: size, + url: url + } + + var formatFileSize = function (size) { + var units = ['Byte','KB','MB','GB','TB','PB','EB','ZB','YB']; + var threshold = 1024; + size = Number(size) * threshold; + var i = size === 0 ? 0 : Math.floor(Math.log(size) / Math.log(threshold)); + return (((size / Math.pow(threshold, i)).toFixed(2) * 1) + " " + (units[i])); + }; + var isDefinedGlobally = function () { return typeof VeeValidate !== 'undefined'; }; - return result -} + var obj; + var messages = { + _default: function (field) { return ("The " + field + " value is not valid."); }, + after: function (field, ref) { + var target = ref[0]; + var inclusion = ref[1]; -function cleanEscapedString (input) { - if (input.match(/\[[\s\S]/)) { - return input.replace(/^\[|]$/g, '') - } - return input.replace(/\\/g, '') -} + return ("The " + field + " must be after " + (inclusion ? 'or equal to ' : '') + target + "."); + }, + alpha_dash: function (field) { return ("The " + field + " field may contain alpha-numeric characters as well as dashes and underscores."); }, + alpha_num: function (field) { return ("The " + field + " field may only contain alpha-numeric characters."); }, + alpha_spaces: function (field) { return ("The " + field + " field may only contain alphabetic characters as well as spaces."); }, + alpha: function (field) { return ("The " + field + " field may only contain alphabetic characters."); }, + before: function (field, ref) { + var target = ref[0]; + var inclusion = ref[1]; + + return ("The " + field + " must be before " + (inclusion ? 'or equal to ' : '') + target + "."); + }, + between: function (field, ref) { + var min = ref[0]; + var max = ref[1]; -/** - * @name subMinutes - * @category Minute Helpers - * @summary Subtract the specified number of minutes from the given date. - * - * @description - * Subtract the specified number of minutes from the given date. - * - * @param {Date|String|Number} date - the date to be changed - * @param {Number} amount - the amount of minutes to be subtracted - * @param {Options} [options] - the object with options. See [Options]{@link https://date-fns.org/docs/Options} - * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate} - * @returns {Date} the new date with the mintues subtracted - * @throws {TypeError} 2 arguments required - * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 - * - * @example - * // Subtract 30 minutes from 10 July 2014 12:00:00: - * var result = subMinutes(new Date(2014, 6, 10, 12, 0), 30) - * //=> Thu Jul 10 2014 11:30:00 - */ -function subMinutes (dirtyDate, dirtyAmount, dirtyOptions) { - if (arguments.length < 2) { - throw new TypeError('2 arguments required, but only ' + arguments.length + ' present') - } + return ("The " + field + " field must be between " + min + " and " + max + "."); + }, + confirmed: function (field) { return ("The " + field + " confirmation does not match."); }, + credit_card: function (field) { return ("The " + field + " field is invalid."); }, + date_between: function (field, ref) { + var min = ref[0]; + var max = ref[1]; - var amount = Number(dirtyAmount); - return addMinutes(dirtyDate, -amount, dirtyOptions) -} + return ("The " + field + " must be between " + min + " and " + max + "."); + }, + date_format: function (field, ref) { + var format = ref[0]; -/** - * @name isAfter - * @category Common Helpers - * @summary Is the first date after the second one? - * - * @description - * Is the first date after the second one? - * - * @param {Date|String|Number} date - the date that should be after the other one to return true - * @param {Date|String|Number} dateToCompare - the date to compare with - * @param {Options} [options] - the object with options. See [Options]{@link https://date-fns.org/docs/Options} - * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate} - * @returns {Boolean} the first date is after the second date - * @throws {TypeError} 2 arguments required - * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 - * - * @example - * // Is 10 July 1989 after 11 February 1987? - * var result = isAfter(new Date(1989, 6, 10), new Date(1987, 1, 11)) - * //=> true - */ -function isAfter (dirtyDate, dirtyDateToCompare, dirtyOptions) { - if (arguments.length < 2) { - throw new TypeError('2 arguments required, but only ' + arguments.length + ' present') - } + return ("The " + field + " must be in the format " + format + "."); + }, + decimal: function (field, ref) { + if ( ref === void 0 ) ref = []; + var decimals = ref[0]; if ( decimals === void 0 ) decimals = '*'; - var date = toDate(dirtyDate, dirtyOptions); - var dateToCompare = toDate(dirtyDateToCompare, dirtyOptions); - return date.getTime() > dateToCompare.getTime() -} + return ("The " + field + " field must be numeric and may contain " + (!decimals || decimals === '*' ? '' : decimals) + " decimal points."); + }, + digits: function (field, ref) { + var length = ref[0]; -/** - * @name isBefore - * @category Common Helpers - * @summary Is the first date before the second one? - * - * @description - * Is the first date before the second one? - * - * @param {Date|String|Number} date - the date that should be before the other one to return true - * @param {Date|String|Number} dateToCompare - the date to compare with - * @param {Options} [options] - the object with options. See [Options]{@link https://date-fns.org/docs/Options} - * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate} - * @returns {Boolean} the first date is before the second date - * @throws {TypeError} 2 arguments required - * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 - * - * @example - * // Is 10 July 1989 before 11 February 1987? - * var result = isBefore(new Date(1989, 6, 10), new Date(1987, 1, 11)) - * //=> false - */ -function isBefore (dirtyDate, dirtyDateToCompare, dirtyOptions) { - if (arguments.length < 2) { - throw new TypeError('2 arguments required, but only ' + arguments.length + ' present') - } + return ("The " + field + " field must be numeric and exactly contain " + length + " digits."); + }, + dimensions: function (field, ref) { + var width = ref[0]; + var height = ref[1]; - var date = toDate(dirtyDate, dirtyOptions); - var dateToCompare = toDate(dirtyDateToCompare, dirtyOptions); - return date.getTime() < dateToCompare.getTime() -} + return ("The " + field + " field must be " + width + " pixels by " + height + " pixels."); + }, + email: function (field) { return ("The " + field + " field must be a valid email."); }, + ext: function (field) { return ("The " + field + " field must be a valid file."); }, + image: function (field) { return ("The " + field + " field must be an image."); }, + in: function (field) { return ("The " + field + " field must be a valid value."); }, + integer: function (field) { return ("The " + field + " field must be an integer."); }, + ip: function (field) { return ("The " + field + " field must be a valid ip address."); }, + length: function (field, ref) { + var length = ref[0]; + var max = ref[1]; + + if (max) { + return ("The " + field + " length must be between " + length + " and " + max + "."); + } + return ("The " + field + " length must be " + length + "."); + }, + max: function (field, ref) { + var length = ref[0]; -/** - * @name isEqual - * @category Common Helpers - * @summary Are the given dates equal? - * - * @description - * Are the given dates equal? - * - * @param {Date|String|Number} dateLeft - the first date to compare - * @param {Date|String|Number} dateRight - the second date to compare - * @param {Options} [options] - the object with options. See [Options]{@link https://date-fns.org/docs/Options} - * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate} - * @returns {Boolean} the dates are equal - * @throws {TypeError} 2 arguments required - * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 - * - * @example - * // Are 2 July 2014 06:30:45.000 and 2 July 2014 06:30:45.500 equal? - * var result = isEqual( - * new Date(2014, 6, 2, 6, 30, 45, 0) - * new Date(2014, 6, 2, 6, 30, 45, 500) - * ) - * //=> false - */ -function isEqual (dirtyLeftDate, dirtyRightDate, dirtyOptions) { - if (arguments.length < 2) { - throw new TypeError('2 arguments required, but only ' + arguments.length + ' present') - } - - var dateLeft = toDate(dirtyLeftDate, dirtyOptions); - var dateRight = toDate(dirtyRightDate, dirtyOptions); - return dateLeft.getTime() === dateRight.getTime() -} - -var patterns$1 = { - 'M': /^(1[0-2]|0?\d)/, // 0 to 12 - 'D': /^(3[0-1]|[0-2]?\d)/, // 0 to 31 - 'DDD': /^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/, // 0 to 366 - 'W': /^(5[0-3]|[0-4]?\d)/, // 0 to 53 - 'YYYY': /^(\d{1,4})/, // 0 to 9999 - 'H': /^(2[0-3]|[0-1]?\d)/, // 0 to 23 - 'm': /^([0-5]?\d)/, // 0 to 59 - 'Z': /^([+-])(\d{2}):(\d{2})/, - 'ZZ': /^([+-])(\d{2})(\d{2})/, - singleDigit: /^(\d)/, - twoDigits: /^(\d{2})/, - threeDigits: /^(\d{3})/, - fourDigits: /^(\d{4})/, - anyDigits: /^(\d+)/ -}; - -function parseDecimal$1 (matchResult) { - return parseInt(matchResult[1], 10) -} - -var parsers = { - // Year: 00, 01, ..., 99 - 'YY': { - unit: 'twoDigitYear', - match: patterns$1.twoDigits, - parse: function (matchResult) { - return parseDecimal$1(matchResult) - } - }, - - // Year: 1900, 1901, ..., 2099 - 'YYYY': { - unit: 'year', - match: patterns$1.YYYY, - parse: parseDecimal$1 - }, - - // ISO week-numbering year: 00, 01, ..., 99 - 'GG': { - unit: 'isoYear', - match: patterns$1.twoDigits, - parse: function (matchResult) { - return parseDecimal$1(matchResult) + 1900 - } - }, - - // ISO week-numbering year: 1900, 1901, ..., 2099 - 'GGGG': { - unit: 'isoYear', - match: patterns$1.YYYY, - parse: parseDecimal$1 - }, - - // Quarter: 1, 2, 3, 4 - 'Q': { - unit: 'quarter', - match: patterns$1.singleDigit, - parse: parseDecimal$1 - }, - - // Ordinal quarter - 'Qo': { - unit: 'quarter', - match: function (string, options) { - return options.locale.match.ordinalNumbers(string, {unit: 'quarter'}) - }, - parse: function (matchResult, options) { - return options.locale.match.ordinalNumber(matchResult, {unit: 'quarter'}) - } + return ("The " + field + " field may not be greater than " + length + " characters."); }, + max_value: function (field, ref) { + var max = ref[0]; - // Month: 1, 2, ..., 12 - 'M': { - unit: 'month', - match: patterns$1.M, - parse: function (matchResult) { - return parseDecimal$1(matchResult) - 1 - } + return ("The " + field + " field must be " + max + " or less."); }, + mimes: function (field) { return ("The " + field + " field must have a valid file type."); }, + min: function (field, ref) { + var length = ref[0]; - // Ordinal month - 'Mo': { - unit: 'month', - match: function (string, options) { - return options.locale.match.ordinalNumbers(string, {unit: 'month'}) - }, - parse: function (matchResult, options) { - return options.locale.match.ordinalNumber(matchResult, {unit: 'month'}) - 1 - } + return ("The " + field + " field must be at least " + length + " characters."); }, + min_value: function (field, ref) { + var min = ref[0]; - // Month: 01, 02, ..., 12 - 'MM': { - unit: 'month', - match: patterns$1.twoDigits, - parse: function (matchResult) { - return parseDecimal$1(matchResult) - 1 - } + return ("The " + field + " field must be " + min + " or more."); }, - - // Month: Jan, Feb, ..., Dec - 'MMM': { - unit: 'month', - match: function (string, options) { - return options.locale.match.months(string, {type: 'short'}) - }, - parse: function (matchResult, options) { - return options.locale.match.month(matchResult, {type: 'short'}) - } + not_in: function (field) { return ("The " + field + " field must be a valid value."); }, + numeric: function (field) { return ("The " + field + " field may only contain numeric characters."); }, + regex: function (field) { return ("The " + field + " field format is invalid."); }, + required: function (field) { return ("The " + field + " field is required."); }, + size: function (field, ref) { + var size = ref[0]; + + return ("The " + field + " size must be less than " + (formatFileSize(size)) + "."); }, + url: function (field) { return ("The " + field + " field is not a valid URL."); } + }; + var locale$1 = { + name: 'en', + messages: messages, + attributes: {} + }; + if (isDefinedGlobally()) { + VeeValidate.Validator.localize(( obj = {}, obj[locale$1.name] = locale$1, obj )); + } - // Month: January, February, ..., December - 'MMMM': { - unit: 'month', - match: function (string, options) { - return options.locale.match.months(string, {type: 'long'}) || - options.locale.match.months(string, {type: 'short'}) - }, - parse: function (matchResult, options) { - var parseResult = options.locale.match.month(matchResult, {type: 'long'}); + var ErrorBag = function ErrorBag() { + this.items = []; + }; + ErrorBag.prototype[typeof Symbol === 'function' ? Symbol.iterator : '@@iterator'] = function () { + var this$1 = this; - if (parseResult == null) { - parseResult = options.locale.match.month(matchResult, {type: 'short'}); + var index = 0; + return { + next: function () { return ({ + value: this$1.items[index++], + done: index > this$1.items.length + }); } + }; + }; + ErrorBag.prototype.add = function add (error) { + var ref; + + if (arguments.length > 1) { + error = { + field: arguments[0], + msg: arguments[1], + rule: arguments[2], + scope: !isNullOrUndefined(arguments[3]) ? arguments[3] : null, + regenerate: null + }; } + (ref = this.items).push.apply(ref, this._normalizeError(error)); + }; + ErrorBag.prototype._normalizeError = function _normalizeError (error) { + if (Array.isArray(error)) { + return error.map(function (e) { + e.scope = !isNullOrUndefined(e.scope) ? e.scope : null; + return e; + }); + } + error.scope = !isNullOrUndefined(error.scope) ? error.scope : null; + return [error]; + }; + ErrorBag.prototype.regenerate = function regenerate () { + this.items.forEach(function (i) { + i.msg = isCallable(i.regenerate) ? i.regenerate() : i.msg; + }); + }; + ErrorBag.prototype.update = function update (id, error) { + var item = find(this.items, function (i) { return i.id === id; }); + if (!item) { + return; + } + var idx = this.items.indexOf(item); + this.items.splice(idx, 1); + item.scope = error.scope; + this.items.push(item); + }; + ErrorBag.prototype.all = function all (scope) { + if (isNullOrUndefined(scope)) { + return this.items.map(function (e) { return e.msg; }); + } + return this.items.filter(function (e) { return e.scope === scope; }).map(function (e) { return e.msg; }); + }; + ErrorBag.prototype.any = function any (scope) { + if (isNullOrUndefined(scope)) { + return !(!this.items.length); + } + return !(!this.items.filter(function (e) { return e.scope === scope; }).length); + }; + ErrorBag.prototype.clear = function clear (scope) { + var this$1 = this; - return parseResult - } - }, - - // ISO week: 1, 2, ..., 53 - 'W': { - unit: 'isoWeek', - match: patterns$1.W, - parse: parseDecimal$1 - }, - - // Ordinal ISO week - 'Wo': { - unit: 'isoWeek', - match: function (string, options) { - return options.locale.match.ordinalNumbers(string, {unit: 'isoWeek'}) - }, - parse: function (matchResult, options) { - return options.locale.match.ordinalNumber(matchResult, {unit: 'isoWeek'}) - } - }, + if (isNullOrUndefined(scope)) { + scope = null; + } + for (var i = 0;i < this.items.length; ++i) { + if (this$1.items[i].scope === scope) { + this$1.items.splice(i, 1); + --i; + } + } + }; + ErrorBag.prototype.collect = function collect (field, scope, map) { + if ( map === void 0 ) map = true; + + if (!field) { + var collection = {}; + this.items.forEach(function (e) { + if (!collection[e.field]) { + collection[e.field] = []; + } + collection[e.field].push(map ? e.msg : e); + }); + return collection; + } + field = !isNullOrUndefined(field) ? String(field) : field; + if (isNullOrUndefined(scope)) { + return this.items.filter(function (e) { return e.field === field; }).map(function (e) { return map ? e.msg : e; }); + } + return this.items.filter(function (e) { return e.field === field && e.scope === scope; }).map(function (e) { return map ? e.msg : e; }); + }; + ErrorBag.prototype.count = function count () { + return this.items.length; + }; + ErrorBag.prototype.firstById = function firstById (id) { + var error = find(this.items, function (i) { return i.id === id; }); + return error ? error.msg : null; + }; + ErrorBag.prototype.first = function first (field, scope) { + var this$1 = this; + if ( scope === void 0 ) scope = null; - // ISO week: 01, 02, ..., 53 - 'WW': { - unit: 'isoWeek', - match: patterns$1.twoDigits, - parse: parseDecimal$1 - }, + if (isNullOrUndefined(field)) { + return null; + } + field = String(field); + var selector = this._selector(field); + var scoped = this._scope(field); + if (scoped) { + var result = this.first(scoped.name, scoped.scope); + if (result) { + return result; + } + } + if (selector) { + return this.firstByRule(selector.name, selector.rule, scope); + } + for (var i = 0;i < this.items.length; ++i) { + if (this$1.items[i].field === field && this$1.items[i].scope === scope) { + return this$1.items[i].msg; + } + } + return null; + }; + ErrorBag.prototype.firstRule = function firstRule (field, scope) { + var errors = this.collect(field, scope, false); + return errors.length && errors[0].rule || null; + }; + ErrorBag.prototype.has = function has (field, scope) { + if ( scope === void 0 ) scope = null; - // Day of week: 0, 1, ..., 6 - 'd': { - unit: 'dayOfWeek', - match: patterns$1.singleDigit, - parse: parseDecimal$1 - }, + return !(!this.first(field, scope)); + }; + ErrorBag.prototype.firstByRule = function firstByRule (name, rule, scope) { + if ( scope === void 0 ) scope = null; - // Ordinal day of week - 'do': { - unit: 'dayOfWeek', - match: function (string, options) { - return options.locale.match.ordinalNumbers(string, {unit: 'dayOfWeek'}) - }, - parse: function (matchResult, options) { - return options.locale.match.ordinalNumber(matchResult, {unit: 'dayOfWeek'}) - } - }, + var error = this.collect(name, scope, false).filter(function (e) { return e.rule === rule; })[0]; + return error && error.msg || null; + }; + ErrorBag.prototype.firstNot = function firstNot (name, rule, scope) { + if ( rule === void 0 ) rule = 'required'; + if ( scope === void 0 ) scope = null; - // Day of week: Su, Mo, ..., Sa - 'dd': { - unit: 'dayOfWeek', - match: function (string, options) { - return options.locale.match.weekdays(string, {type: 'narrow'}) - }, - parse: function (matchResult, options) { - return options.locale.match.weekday(matchResult, {type: 'narrow'}) - } - }, + var error = this.collect(name, scope, false).filter(function (e) { return e.rule !== rule; })[0]; + return error && error.msg || null; + }; + ErrorBag.prototype.removeById = function removeById (id) { + var this$1 = this; - // Day of week: Sun, Mon, ..., Sat - 'ddd': { - unit: 'dayOfWeek', - match: function (string, options) { - return options.locale.match.weekdays(string, {type: 'short'}) || - options.locale.match.weekdays(string, {type: 'narrow'}) - }, - parse: function (matchResult, options) { - var parseResult = options.locale.match.weekday(matchResult, {type: 'short'}); + if (Array.isArray(id)) { + this.items = this.items.filter(function (i) { return id.indexOf(i.id) === -1; }); + return; + } + for (var i = 0;i < this.items.length; ++i) { + if (this$1.items[i].id === id) { + this$1.items.splice(i, 1); + --i; + } + } + }; + ErrorBag.prototype.remove = function remove (field, scope) { + var this$1 = this; - if (parseResult == null) { - parseResult = options.locale.match.weekday(matchResult, {type: 'narrow'}); + field = !isNullOrUndefined(field) ? String(field) : field; + var removeCondition = function (e) { + if (!isNullOrUndefined(scope)) { + return e.field === field && e.scope === scope; + } + return e.field === field && e.scope === null; + }; + for (var i = 0;i < this.items.length; ++i) { + if (removeCondition(this$1.items[i])) { + this$1.items.splice(i, 1); + --i; + } + } + }; + ErrorBag.prototype._selector = function _selector (field) { + if (field.indexOf(':') > -1) { + var ref = field.split(':'); + var name = ref[0]; + var rule = ref[1]; + return { + name: name, + rule: rule + }; + } + return null; + }; + ErrorBag.prototype._scope = function _scope (field) { + if (field.indexOf('.') > -1) { + var ref = field.split('.'); + var scope = ref[0]; + var name = ref.slice(1); + return { + name: name.join('.'), + scope: scope + }; } + return null; + }; - return parseResult - } - }, + var LOCALE = 'en'; + var Dictionary = function Dictionary(dictionary) { + if ( dictionary === void 0 ) dictionary = {}; - // Day of week: Sunday, Monday, ..., Saturday - 'dddd': { - unit: 'dayOfWeek', - match: function (string, options) { - return options.locale.match.weekdays(string, {type: 'long'}) || - options.locale.match.weekdays(string, {type: 'short'}) || - options.locale.match.weekdays(string, {type: 'narrow'}) - }, - parse: function (matchResult, options) { - var parseResult = options.locale.match.weekday(matchResult, {type: 'long'}); + this.container = {}; + this.merge(dictionary); + }; - if (parseResult == null) { - parseResult = options.locale.match.weekday(matchResult, {type: 'short'}); + var prototypeAccessors = { locale: { configurable: true } }; + prototypeAccessors.locale.get = function () { + return LOCALE; + }; + prototypeAccessors.locale.set = function (value) { + LOCALE = value || 'en'; + }; + Dictionary.prototype.hasLocale = function hasLocale (locale) { + return !(!this.container[locale]); + }; + Dictionary.prototype.setDateFormat = function setDateFormat (locale, format) { + if (!this.container[locale]) { + this.container[locale] = {}; + } + this.container[locale].dateFormat = format; + }; + Dictionary.prototype.getDateFormat = function getDateFormat (locale) { + if (!this.container[locale] || !this.container[locale].dateFormat) { + return null; + } + return this.container[locale].dateFormat; + }; + Dictionary.prototype.getMessage = function getMessage (locale, key, data) { + var message = null; + if (!this.hasMessage(locale, key)) { + message = this._getDefaultMessage(locale); + } else { + message = this.container[locale].messages[key]; + } + return isCallable(message) ? message.apply(void 0, data) : message; + }; + Dictionary.prototype.getFieldMessage = function getFieldMessage (locale, field, key, data) { + if (!this.hasLocale(locale)) { + return this.getMessage(locale, key, data); + } + var dict = this.container[locale].custom && this.container[locale].custom[field]; + if (!dict || !dict[key]) { + return this.getMessage(locale, key, data); + } + var message = dict[key]; + return isCallable(message) ? message.apply(void 0, data) : message; + }; + Dictionary.prototype._getDefaultMessage = function _getDefaultMessage (locale) { + if (this.hasMessage(locale, '_default')) { + return this.container[locale].messages._default; + } + return this.container.en.messages._default; + }; + Dictionary.prototype.getAttribute = function getAttribute (locale, key, fallback) { + if ( fallback === void 0 ) fallback = ''; - if (parseResult == null) { - parseResult = options.locale.match.weekday(matchResult, {type: 'narrow'}); - } + if (!this.hasAttribute(locale, key)) { + return fallback; } + return this.container[locale].attributes[key]; + }; + Dictionary.prototype.hasMessage = function hasMessage (locale, key) { + return !(!(this.hasLocale(locale) && this.container[locale].messages && this.container[locale].messages[key])); + }; + Dictionary.prototype.hasAttribute = function hasAttribute (locale, key) { + return !(!(this.hasLocale(locale) && this.container[locale].attributes && this.container[locale].attributes[key])); + }; + Dictionary.prototype.merge = function merge$1 (dictionary) { + merge$2(this.container, dictionary); + }; + Dictionary.prototype.setMessage = function setMessage (locale, key, message) { + if (!this.hasLocale(locale)) { + this.container[locale] = { + messages: {}, + attributes: {} + }; + } + this.container[locale].messages[key] = message; + }; + Dictionary.prototype.setAttribute = function setAttribute (locale, key, attribute) { + if (!this.hasLocale(locale)) { + this.container[locale] = { + messages: {}, + attributes: {} + }; + } + this.container[locale].attributes[key] = attribute; + }; - return parseResult - } - }, + Object.defineProperties( Dictionary.prototype, prototypeAccessors ); - // Day of ISO week: 1, 2, ..., 7 - 'E': { - unit: 'dayOfISOWeek', - match: patterns$1.singleDigit, - parse: function (matchResult) { - return parseDecimal$1(matchResult) - } - }, + var normalizeValue = function (value) { + if (isObject(value)) { + return Object.keys(value).reduce(function (prev, key) { + prev[key] = normalizeValue(value[key]); + return prev; + }, {}); + } + if (isCallable(value)) { + return value('{0}', ['{1}','{2}','{3}']); + } + return value; + }; + var normalizeFormat = function (locale) { + var messages = normalizeValue(locale.messages); + var custom = normalizeValue(locale.custom); + return { + messages: messages, + custom: custom, + attributes: locale.attributes, + dateFormat: locale.dateFormat + }; + }; + var I18nDictionary = function I18nDictionary(i18n, rootKey) { + this.i18n = i18n; + this.rootKey = rootKey; + }; - // Day of month: 1, 2, ..., 31 - 'D': { - unit: 'dayOfMonth', - match: patterns$1.D, - parse: parseDecimal$1 - }, + var prototypeAccessors$1 = { locale: { configurable: true } }; + prototypeAccessors$1.locale.get = function () { + return this.i18n.locale; + }; + prototypeAccessors$1.locale.set = function (value) { + warn('Cannot set locale from the validator when using vue-i18n, use i18n.locale setter instead'); + }; + I18nDictionary.prototype.getDateFormat = function getDateFormat (locale) { + return this.i18n.getDateTimeFormat(locale || this.locale); + }; + I18nDictionary.prototype.setDateFormat = function setDateFormat (locale, value) { + this.i18n.setDateTimeFormat(locale || this.locale, value); + }; + I18nDictionary.prototype.getMessage = function getMessage (locale, key, data) { + var path = (this.rootKey) + ".messages." + key; + if (!this.i18n.te(path)) { + return this.i18n.t(((this.rootKey) + ".messages._default"), locale, data); + } + return this.i18n.t(path, locale, data); + }; + I18nDictionary.prototype.getAttribute = function getAttribute (locale, key, fallback) { + if ( fallback === void 0 ) fallback = ''; - // Ordinal day of month - 'Do': { - unit: 'dayOfMonth', - match: function (string, options) { - return options.locale.match.ordinalNumbers(string, {unit: 'dayOfMonth'}) - }, - parse: function (matchResult, options) { - return options.locale.match.ordinalNumber(matchResult, {unit: 'dayOfMonth'}) - } - }, + var path = (this.rootKey) + ".attributes." + key; + if (!this.i18n.te(path)) { + return fallback; + } + return this.i18n.t(path, locale); + }; + I18nDictionary.prototype.getFieldMessage = function getFieldMessage (locale, field, key, data) { + var path = (this.rootKey) + ".custom." + field + "." + key; + if (this.i18n.te(path)) { + return this.i18n.t(path); + } + return this.getMessage(locale, key, data); + }; + I18nDictionary.prototype.merge = function merge$1 (dictionary) { + var this$1 = this; - // Day of month: 01, 02, ..., 31 - 'DD': { - unit: 'dayOfMonth', - match: patterns$1.twoDigits, - parse: parseDecimal$1 - }, + Object.keys(dictionary).forEach(function (localeKey) { + var obj; - // Day of year: 1, 2, ..., 366 - 'DDD': { - unit: 'dayOfYear', - match: patterns$1.DDD, - parse: parseDecimal$1 - }, + var clone = merge$2({}, getPath((localeKey + "." + (this$1.rootKey)), this$1.i18n.messages, {})); + var locale = merge$2(clone, normalizeFormat(dictionary[localeKey])); + this$1.i18n.mergeLocaleMessage(localeKey, ( obj = {}, obj[this$1.rootKey] = locale, obj )); + if (locale.dateFormat) { + this$1.i18n.setDateTimeFormat(localeKey, locale.dateFormat); + } + }); + }; + I18nDictionary.prototype.setMessage = function setMessage (locale, key, value) { + var obj, obj$1; - // Ordinal day of year - 'DDDo': { - unit: 'dayOfYear', - match: function (string, options) { - return options.locale.match.ordinalNumbers(string, {unit: 'dayOfYear'}) - }, - parse: function (matchResult, options) { - return options.locale.match.ordinalNumber(matchResult, {unit: 'dayOfYear'}) - } - }, + this.merge(( obj$1 = {}, obj$1[locale] = { + messages: ( obj = {}, obj[key] = value, obj ) + }, obj$1 )); + }; + I18nDictionary.prototype.setAttribute = function setAttribute (locale, key, value) { + var obj, obj$1; - // Day of year: 001, 002, ..., 366 - 'DDDD': { - unit: 'dayOfYear', - match: patterns$1.threeDigits, - parse: parseDecimal$1 - }, + this.merge(( obj$1 = {}, obj$1[locale] = { + attributes: ( obj = {}, obj[key] = value, obj ) + }, obj$1 )); + }; - // AM, PM - 'A': { - unit: 'timeOfDay', - match: function (string, options) { - return options.locale.match.timesOfDay(string, {type: 'short'}) - }, - parse: function (matchResult, options) { - return options.locale.match.timeOfDay(matchResult, {type: 'short'}) - } - }, + Object.defineProperties( I18nDictionary.prototype, prototypeAccessors$1 ); + + var defaultConfig = { + locale: 'en', + delay: 0, + errorBagName: 'errors', + dictionary: null, + strict: true, + fieldsBagName: 'fields', + classes: false, + classNames: null, + events: 'input|blur', + inject: true, + fastExit: true, + aria: true, + validity: false, + i18n: null, + i18nRootKey: 'validation' + }; + var currentConfig = assign({}, defaultConfig); + var dependencies = { + dictionary: new Dictionary({ + en: { + messages: {}, + attributes: {}, + custom: {} + } + }) + }; + var Config = function Config () {}; - // a.m., p.m. - 'aa': { - unit: 'timeOfDay', - match: function (string, options) { - return options.locale.match.timesOfDay(string, {type: 'long'}) || - options.locale.match.timesOfDay(string, {type: 'short'}) - }, - parse: function (matchResult, options) { - var parseResult = options.locale.match.timeOfDay(matchResult, {type: 'long'}); + var staticAccessors = { default: { configurable: true },current: { configurable: true } }; - if (parseResult == null) { - parseResult = options.locale.match.timeOfDay(matchResult, {type: 'short'}); + staticAccessors.default.get = function () { + return defaultConfig; + }; + staticAccessors.current.get = function () { + return currentConfig; + }; + Config.dependency = function dependency (key) { + return dependencies[key]; + }; + Config.merge = function merge (config) { + currentConfig = assign({}, currentConfig, config); + if (currentConfig.i18n) { + Config.register('dictionary', new I18nDictionary(currentConfig.i18n, currentConfig.i18nRootKey)); } + }; + Config.register = function register (key, value) { + dependencies[key] = value; + }; + Config.resolve = function resolve (context) { + var selfConfig = getPath('$options.$_veeValidate', context, {}); + return assign({}, Config.current, selfConfig); + }; - return parseResult - } - }, - - // Hour: 0, 1, ... 23 - 'H': { - unit: 'hours', - match: patterns$1.H, - parse: parseDecimal$1 - }, + Object.defineProperties( Config, staticAccessors ); - // Hour: 00, 01, ..., 23 - 'HH': { - unit: 'hours', - match: patterns$1.twoDigits, - parse: parseDecimal$1 - }, + var Generator = function Generator () {}; - // Hour: 1, 2, ..., 12 - 'h': { - unit: 'timeOfDayHours', - match: patterns$1.M, - parse: parseDecimal$1 - }, + Generator.generate = function generate (el, binding, vnode) { + var model = Generator.resolveModel(binding, vnode); + var options = Config.resolve(vnode.context); + return { + name: Generator.resolveName(el, vnode), + el: el, + listen: !binding.modifiers.disable, + scope: Generator.resolveScope(el, binding, vnode), + vm: Generator.makeVM(vnode.context), + expression: binding.value, + component: vnode.componentInstance, + classes: options.classes, + classNames: options.classNames, + getter: Generator.resolveGetter(el, vnode, model), + events: Generator.resolveEvents(el, vnode) || options.events, + model: model, + delay: Generator.resolveDelay(el, vnode, options), + rules: Generator.resolveRules(el, binding), + initial: !(!binding.modifiers.initial), + validity: options.validity, + aria: options.aria, + initialValue: Generator.resolveInitialValue(vnode) + }; + }; + Generator.getCtorConfig = function getCtorConfig (vnode) { + if (!vnode.componentInstance) + { return null; } + var config = getPath('componentInstance.$options.$_veeValidate', vnode); + return config; + }; + Generator.resolveRules = function resolveRules (el, binding) { + if (!binding.value && (!binding || !binding.expression)) { + return getDataAttribute(el, 'rules'); + } + if (binding.value && ~['string','object'].indexOf(typeof binding.value.rules)) { + return binding.value.rules; + } + return binding.value; + }; + Generator.resolveInitialValue = function resolveInitialValue (vnode) { + var model = vnode.data.model || find(vnode.data.directives, function (d) { return d.name === 'model'; }); + return model && model.value; + }; + Generator.makeVM = function makeVM (vm) { + return { + get $el() { + return vm.$el; + }, + get $refs() { + return vm.$refs; + }, + $watch: vm.$watch ? vm.$watch.bind(vm) : function () {}, + $validator: vm.$validator ? { + errors: vm.$validator.errors, + validate: vm.$validator.validate.bind(vm.$validator), + update: vm.$validator.update.bind(vm.$validator) + } : null + }; + }; + Generator.resolveDelay = function resolveDelay (el, vnode, options) { + var delay = getDataAttribute(el, 'delay'); + var globalDelay = options && 'delay' in options ? options.delay : 0; + if (!delay && vnode.componentInstance && vnode.componentInstance.$attrs) { + delay = vnode.componentInstance.$attrs['data-vv-delay']; + } + if (!isObject(globalDelay)) { + return deepParseInt(delay || globalDelay); + } + if (!isNullOrUndefined(delay)) { + globalDelay.input = delay; + } + return deepParseInt(globalDelay); + }; + Generator.resolveEvents = function resolveEvents (el, vnode) { + var events = getDataAttribute(el, 'validate-on'); + if (!events && vnode.componentInstance && vnode.componentInstance.$attrs) { + events = vnode.componentInstance.$attrs['data-vv-validate-on']; + } + if (!events && vnode.componentInstance) { + var config = Generator.getCtorConfig(vnode); + events = config && config.events; + } + return events; + }; + Generator.resolveScope = function resolveScope (el, binding, vnode) { + if ( vnode === void 0 ) vnode = {}; - // Hour: 01, 02, ..., 12 - 'hh': { - unit: 'timeOfDayHours', - match: patterns$1.twoDigits, - parse: parseDecimal$1 - }, + var scope = null; + if (vnode.componentInstance && isNullOrUndefined(scope)) { + scope = vnode.componentInstance.$attrs && vnode.componentInstance.$attrs['data-vv-scope']; + } + return !isNullOrUndefined(scope) ? scope : getScope(el); + }; + Generator.resolveModel = function resolveModel (binding, vnode) { + if (binding.arg) { + return { + expression: binding.arg + }; + } + var model = vnode.data.model || find(vnode.data.directives, function (d) { return d.name === 'model'; }); + if (!model) { + return null; + } + var watchable = !/[^\w.$]/.test(model.expression) && hasPath(model.expression, vnode.context); + var lazy = !(!(model.modifiers && model.modifiers.lazy)); + if (!watchable) { + return { + expression: null, + lazy: lazy + }; + } + return { + expression: model.expression, + lazy: lazy + }; + }; + Generator.resolveName = function resolveName (el, vnode) { + var name = getDataAttribute(el, 'name'); + if (!name && !vnode.componentInstance) { + return el.name; + } + if (!name && vnode.componentInstance && vnode.componentInstance.$attrs) { + name = vnode.componentInstance.$attrs['data-vv-name'] || vnode.componentInstance.$attrs['name']; + } + if (!name && vnode.componentInstance) { + var config = Generator.getCtorConfig(vnode); + if (config && isCallable(config.name)) { + var boundGetter = config.name.bind(vnode.componentInstance); + return boundGetter(); + } + return vnode.componentInstance.name; + } + return name; + }; + Generator.resolveGetter = function resolveGetter (el, vnode, model) { + if (model && model.expression) { + return function () { return getPath(model.expression, vnode.context); }; + } + if (vnode.componentInstance) { + var path = getDataAttribute(el, 'value-path') || vnode.componentInstance.$attrs && vnode.componentInstance.$attrs['data-vv-value-path']; + if (path) { + return function () { return getPath(path, vnode.componentInstance); }; + } + var config = Generator.getCtorConfig(vnode); + if (config && isCallable(config.value)) { + var boundGetter = config.value.bind(vnode.componentInstance); + return function () { return boundGetter(); }; + } + return function () { return vnode.componentInstance.value; }; + } + switch (el.type) { + case 'checkbox': + return function () { + var els = document.querySelectorAll(("input[name=\"" + (el.name) + "\"]")); + els = toArray(els).filter(function (el) { return el.checked; }); + if (!els.length) + { return undefined; } + return els.map(function (checkbox) { return checkbox.value; }); + }; + case 'radio': + return function () { + var els = document.querySelectorAll(("input[name=\"" + (el.name) + "\"]")); + var elm = find(els, function (el) { return el.checked; }); + return elm && elm.value; + }; + case 'file': + return function (context) { return toArray(el.files); }; + case 'select-multiple': + return function () { return toArray(el.options).filter(function (opt) { return opt.selected; }).map(function (opt) { return opt.value; }); }; + default: + return function () { return el && el.value; }; + } + }; - // Minute: 0, 1, ..., 59 - 'm': { - unit: 'minutes', - match: patterns$1.m, - parse: parseDecimal$1 - }, + var DEFAULT_OPTIONS = { + targetOf: null, + initial: false, + scope: null, + listen: true, + name: null, + rules: {}, + vm: null, + classes: false, + validity: true, + aria: true, + events: 'input|blur', + delay: 0, + classNames: { + touched: 'touched', + untouched: 'untouched', + valid: 'valid', + invalid: 'invalid', + pristine: 'pristine', + dirty: 'dirty' + } + }; + var Field = function Field(options) { + if ( options === void 0 ) options = {}; + + this.id = uniqId(); + this.el = options.el; + this.updated = false; + this.dependencies = []; + this.watchers = []; + this.events = []; + this.delay = 0; + this.rules = {}; + this._cacheId(options); + this.classNames = assign({}, DEFAULT_OPTIONS.classNames); + options = assign({}, DEFAULT_OPTIONS, options); + this._delay = !isNullOrUndefined(options.delay) ? options.delay : 0; + this.validity = options.validity; + this.aria = options.aria; + this.flags = createFlags(); + this.vm = options.vm; + this.component = options.component; + this.ctorConfig = this.component ? getPath('$options.$_veeValidate', this.component) : undefined; + this.update(options); + this.initialValue = this.value; + this.updated = false; + }; - // Minute: 00, 01, ..., 59 - 'mm': { - unit: 'minutes', - match: patterns$1.twoDigits, - parse: parseDecimal$1 - }, + var prototypeAccessors$2 = { validator: { configurable: true },isRequired: { configurable: true },isDisabled: { configurable: true },alias: { configurable: true },value: { configurable: true },rejectsFalse: { configurable: true } }; + prototypeAccessors$2.validator.get = function () { + if (!this.vm || !this.vm.$validator) { + warn('No validator instance detected.'); + return { + validate: function () {} + }; + } + return this.vm.$validator; + }; + prototypeAccessors$2.isRequired.get = function () { + return !(!this.rules.required); + }; + prototypeAccessors$2.isDisabled.get = function () { + return !(!(this.component && this.component.disabled)) || !(!(this.el && this.el.disabled)); + }; + prototypeAccessors$2.alias.get = function () { + if (this._alias) { + return this._alias; + } + var alias = null; + if (this.el) { + alias = getDataAttribute(this.el, 'as'); + } + if (!alias && this.component) { + return this.component.$attrs && this.component.$attrs['data-vv-as']; + } + return alias; + }; + prototypeAccessors$2.value.get = function () { + if (!isCallable(this.getter)) { + return undefined; + } + return this.getter(); + }; + prototypeAccessors$2.rejectsFalse.get = function () { + if (this.component && this.ctorConfig) { + return !(!this.ctorConfig.rejectsFalse); + } + if (!this.el) { + return false; + } + return this.el.type === 'checkbox'; + }; + Field.prototype.matches = function matches (options) { + if (!options) { + return true; + } + if (options.id) { + return this.id === options.id; + } + if (options.name === undefined && options.scope === undefined) { + return true; + } + if (options.scope === undefined) { + return this.name === options.name; + } + if (options.name === undefined) { + return this.scope === options.scope; + } + return options.name === this.name && options.scope === this.scope; + }; + Field.prototype._cacheId = function _cacheId (options) { + if (this.el && !options.targetOf) { + this.el._veeValidateId = this.id; + } + }; + Field.prototype.update = function update (options) { + this.targetOf = options.targetOf || null; + this.initial = options.initial || this.initial || false; + if (!isNullOrUndefined(options.scope) && options.scope !== this.scope && isCallable(this.validator.update)) { + this.validator.update(this.id, { + scope: options.scope + }); + } + this.scope = !isNullOrUndefined(options.scope) ? options.scope : !isNullOrUndefined(this.scope) ? this.scope : null; + this.name = (!isNullOrUndefined(options.name) ? String(options.name) : options.name) || this.name || null; + this.rules = options.rules !== undefined ? normalizeRules(options.rules) : this.rules; + this.model = options.model || this.model; + this.listen = options.listen !== undefined ? options.listen : this.listen; + this.classes = (options.classes || this.classes || false) && !this.component; + this.classNames = isObject(options.classNames) ? merge$2(this.classNames, options.classNames) : this.classNames; + this.getter = isCallable(options.getter) ? options.getter : this.getter; + this._alias = options.alias || this._alias; + this.events = options.events ? makeEventsArray(options.events) : this.events; + this.delay = makeDelayObject(this.events, options.delay || this.delay, this._delay); + this.updateDependencies(); + this.addActionListeners(); + if (!this.name && !this.targetOf) { + warn('A field is missing a "name" or "data-vv-name" attribute'); + } + if (options.rules !== undefined) { + this.flags.required = this.isRequired; + } + if (this.flags.validated && options.rules !== undefined && this.updated) { + this.validator.validate(("#" + (this.id))); + } + this.updated = true; + this.addValueListeners(); + if (!this.el) { + return; + } + this.updateClasses(); + this.updateAriaAttrs(); + }; + Field.prototype.reset = function reset () { + var this$1 = this; - // Second: 0, 1, ..., 59 - 's': { - unit: 'seconds', - match: patterns$1.m, - parse: parseDecimal$1 - }, - - // Second: 00, 01, ..., 59 - 'ss': { - unit: 'seconds', - match: patterns$1.twoDigits, - parse: parseDecimal$1 - }, - - // 1/10 of second: 0, 1, ..., 9 - 'S': { - unit: 'milliseconds', - match: patterns$1.singleDigit, - parse: function (matchResult) { - return parseDecimal$1(matchResult) * 100 - } - }, - - // 1/100 of second: 00, 01, ..., 99 - 'SS': { - unit: 'milliseconds', - match: patterns$1.twoDigits, - parse: function (matchResult) { - return parseDecimal$1(matchResult) * 10 - } - }, - - // Millisecond: 000, 001, ..., 999 - 'SSS': { - unit: 'milliseconds', - match: patterns$1.threeDigits, - parse: parseDecimal$1 - }, - - // Timezone: -01:00, +00:00, ... +12:00 - 'Z': { - unit: 'timezone', - match: patterns$1.Z, - parse: function (matchResult) { - var sign = matchResult[1]; - var hours = parseInt(matchResult[2], 10); - var minutes = parseInt(matchResult[3], 10); - var absoluteOffset = hours * 60 + minutes; - return (sign === '+') ? absoluteOffset : -absoluteOffset - } - }, - - // Timezone: -0100, +0000, ... +1200 - 'ZZ': { - unit: 'timezone', - match: patterns$1.ZZ, - parse: function (matchResult) { - var sign = matchResult[1]; - var hours = parseInt(matchResult[2], 10); - var minutes = parseInt(matchResult[3], 10); - var absoluteOffset = hours * 60 + minutes; - return (sign === '+') ? absoluteOffset : -absoluteOffset - } - }, - - // Seconds timestamp: 512969520 - 'X': { - unit: 'timestamp', - match: patterns$1.anyDigits, - parse: function (matchResult) { - return parseDecimal$1(matchResult) * 1000 - } - }, - - // Milliseconds timestamp: 512969520900 - 'x': { - unit: 'timestamp', - match: patterns$1.anyDigits, - parse: parseDecimal$1 - } -}; - -parsers['a'] = parsers['A']; - -// This function will be a part of public API when UTC function will be implemented. -// See issue: https://github.com/date-fns/date-fns/issues/376 -function setUTCDay (dirtyDate, dirtyDay, dirtyOptions) { - var options = dirtyOptions || {}; - var locale = options.locale; - var localeWeekStartsOn = locale && locale.options && locale.options.weekStartsOn; - var defaultWeekStartsOn = localeWeekStartsOn === undefined ? 0 : Number(localeWeekStartsOn); - var weekStartsOn = options.weekStartsOn === undefined ? defaultWeekStartsOn : Number(options.weekStartsOn); - - // Test if weekStartsOn is between 0 and 6 _and_ is not NaN - if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) { - throw new RangeError('weekStartsOn must be between 0 and 6 inclusively') - } - - var date = toDate(dirtyDate, dirtyOptions); - var day = Number(dirtyDay); - - var currentDay = date.getUTCDay(); - - var remainder = day % 7; - var dayIndex = (remainder + 7) % 7; - - var diff = (dayIndex < weekStartsOn ? 7 : 0) + day - currentDay; - - date.setUTCDate(date.getUTCDate() + diff); - return date -} - -// This function will be a part of public API when UTC function will be implemented. -// See issue: https://github.com/date-fns/date-fns/issues/376 -function setUTCISODay (dirtyDate, dirtyDay, dirtyOptions) { - var day = Number(dirtyDay); - - if (day % 7 === 0) { - day = day - 7; - } - - var weekStartsOn = 1; - var date = toDate(dirtyDate, dirtyOptions); - var currentDay = date.getUTCDay(); - - var remainder = day % 7; - var dayIndex = (remainder + 7) % 7; - - var diff = (dayIndex < weekStartsOn ? 7 : 0) + day - currentDay; - - date.setUTCDate(date.getUTCDate() + diff); - return date -} - -// This function will be a part of public API when UTC function will be implemented. -// See issue: https://github.com/date-fns/date-fns/issues/376 -function setUTCISOWeek (dirtyDate, dirtyISOWeek, dirtyOptions) { - var date = toDate(dirtyDate, dirtyOptions); - var isoWeek = Number(dirtyISOWeek); - var diff = getUTCISOWeek(date, dirtyOptions) - isoWeek; - date.setUTCDate(date.getUTCDate() - diff * 7); - return date -} - -var MILLISECONDS_IN_DAY$3 = 86400000; - -// This function will be a part of public API when UTC function will be implemented. -// See issue: https://github.com/date-fns/date-fns/issues/376 -function setUTCISOWeekYear (dirtyDate, dirtyISOYear, dirtyOptions) { - var date = toDate(dirtyDate, dirtyOptions); - var isoYear = Number(dirtyISOYear); - var dateStartOfYear = startOfUTCISOWeekYear(date, dirtyOptions); - var diff = Math.floor((date.getTime() - dateStartOfYear.getTime()) / MILLISECONDS_IN_DAY$3); - var fourthOfJanuary = new Date(0); - fourthOfJanuary.setUTCFullYear(isoYear, 0, 4); - fourthOfJanuary.setUTCHours(0, 0, 0, 0); - date = startOfUTCISOWeekYear(fourthOfJanuary, dirtyOptions); - date.setUTCDate(date.getUTCDate() + diff); - return date -} - -var MILLISECONDS_IN_MINUTE$7 = 60000; - -function setTimeOfDay (hours, timeOfDay) { - var isAM = timeOfDay === 0; - - if (isAM) { - if (hours === 12) { - return 0 - } - } else { - if (hours !== 12) { - return 12 + hours - } - } - - return hours -} - -var units = { - twoDigitYear: { - priority: 10, - set: function (dateValues, value) { - var century = Math.floor(dateValues.date.getUTCFullYear() / 100); - var year = century * 100 + value; - dateValues.date.setUTCFullYear(year, 0, 1); - dateValues.date.setUTCHours(0, 0, 0, 0); - return dateValues - } - }, - - year: { - priority: 10, - set: function (dateValues, value) { - dateValues.date.setUTCFullYear(value, 0, 1); - dateValues.date.setUTCHours(0, 0, 0, 0); - return dateValues - } - }, - - isoYear: { - priority: 10, - set: function (dateValues, value, options) { - dateValues.date = startOfUTCISOWeekYear(setUTCISOWeekYear(dateValues.date, value, options), options); - return dateValues - } - }, - - quarter: { - priority: 20, - set: function (dateValues, value) { - dateValues.date.setUTCMonth((value - 1) * 3, 1); - dateValues.date.setUTCHours(0, 0, 0, 0); - return dateValues - } - }, - - month: { - priority: 30, - set: function (dateValues, value) { - dateValues.date.setUTCMonth(value, 1); - dateValues.date.setUTCHours(0, 0, 0, 0); - return dateValues - } - }, - - isoWeek: { - priority: 40, - set: function (dateValues, value, options) { - dateValues.date = startOfUTCISOWeek(setUTCISOWeek(dateValues.date, value, options), options); - return dateValues - } - }, - - dayOfWeek: { - priority: 50, - set: function (dateValues, value, options) { - dateValues.date = setUTCDay(dateValues.date, value, options); - dateValues.date.setUTCHours(0, 0, 0, 0); - return dateValues - } - }, - - dayOfISOWeek: { - priority: 50, - set: function (dateValues, value, options) { - dateValues.date = setUTCISODay(dateValues.date, value, options); - dateValues.date.setUTCHours(0, 0, 0, 0); - return dateValues - } - }, - - dayOfMonth: { - priority: 50, - set: function (dateValues, value) { - dateValues.date.setUTCDate(value); - dateValues.date.setUTCHours(0, 0, 0, 0); - return dateValues - } - }, - - dayOfYear: { - priority: 50, - set: function (dateValues, value) { - dateValues.date.setUTCMonth(0, value); - dateValues.date.setUTCHours(0, 0, 0, 0); - return dateValues - } - }, - - timeOfDay: { - priority: 60, - set: function (dateValues, value, options) { - dateValues.timeOfDay = value; - return dateValues - } - }, - - hours: { - priority: 70, - set: function (dateValues, value, options) { - dateValues.date.setUTCHours(value, 0, 0, 0); - return dateValues - } - }, - - timeOfDayHours: { - priority: 70, - set: function (dateValues, value, options) { - var timeOfDay = dateValues.timeOfDay; - if (timeOfDay != null) { - value = setTimeOfDay(value, timeOfDay); + if (this._cancellationToken) { + this._cancellationToken.cancelled = true; + delete this._cancellationToken; } - dateValues.date.setUTCHours(value, 0, 0, 0); - return dateValues - } - }, - - minutes: { - priority: 80, - set: function (dateValues, value) { - dateValues.date.setUTCMinutes(value, 0, 0); - return dateValues - } - }, - - seconds: { - priority: 90, - set: function (dateValues, value) { - dateValues.date.setUTCSeconds(value, 0); - return dateValues - } - }, - - milliseconds: { - priority: 100, - set: function (dateValues, value) { - dateValues.date.setUTCMilliseconds(value); - return dateValues - } - }, - - timezone: { - priority: 110, - set: function (dateValues, value) { - dateValues.date = new Date(dateValues.date.getTime() - value * MILLISECONDS_IN_MINUTE$7); - return dateValues - } - }, - - timestamp: { - priority: 120, - set: function (dateValues, value) { - dateValues.date = new Date(value); - return dateValues - } - } -}; - -var TIMEZONE_UNIT_PRIORITY = 110; -var MILLISECONDS_IN_MINUTE$6 = 60000; - -var longFormattingTokensRegExp$1 = /(\[[^[]*])|(\\)?(LTS|LT|LLLL|LLL|LL|L|llll|lll|ll|l)/g; -var defaultParsingTokensRegExp = /(\[[^[]*])|(\\)?(x|ss|s|mm|m|hh|h|do|dddd|ddd|dd|d|aa|a|ZZ|Z|YYYY|YY|X|Wo|WW|W|SSS|SS|S|Qo|Q|Mo|MMMM|MMM|MM|M|HH|H|GGGG|GG|E|Do|DDDo|DDDD|DDD|DD|D|A|.)/g; - -/** - * @name parse - * @category Common Helpers - * @summary Parse the date. - * - * @description - * Return the date parsed from string using the given format. - * - * Accepted format tokens: - * | Unit | Priority | Token | Input examples | - * |-------------------------|----------|-------|----------------------------------| - * | Year | 10 | YY | 00, 01, ..., 99 | - * | | | YYYY | 1900, 1901, ..., 2099 | - * | ISO week-numbering year | 10 | GG | 00, 01, ..., 99 | - * | | | GGGG | 1900, 1901, ..., 2099 | - * | Quarter | 20 | Q | 1, 2, 3, 4 | - * | | | Qo | 1st, 2nd, 3rd, 4th | - * | Month | 30 | M | 1, 2, ..., 12 | - * | | | Mo | 1st, 2nd, ..., 12th | - * | | | MM | 01, 02, ..., 12 | - * | | | MMM | Jan, Feb, ..., Dec | - * | | | MMMM | January, February, ..., December | - * | ISO week | 40 | W | 1, 2, ..., 53 | - * | | | Wo | 1st, 2nd, ..., 53rd | - * | | | WW | 01, 02, ..., 53 | - * | Day of week | 50 | d | 0, 1, ..., 6 | - * | | | do | 0th, 1st, ..., 6th | - * | | | dd | Su, Mo, ..., Sa | - * | | | ddd | Sun, Mon, ..., Sat | - * | | | dddd | Sunday, Monday, ..., Saturday | - * | Day of ISO week | 50 | E | 1, 2, ..., 7 | - * | Day of month | 50 | D | 1, 2, ..., 31 | - * | | | Do | 1st, 2nd, ..., 31st | - * | | | DD | 01, 02, ..., 31 | - * | Day of year | 50 | DDD | 1, 2, ..., 366 | - * | | | DDDo | 1st, 2nd, ..., 366th | - * | | | DDDD | 001, 002, ..., 366 | - * | Time of day | 60 | A | AM, PM | - * | | | a | am, pm | - * | | | aa | a.m., p.m. | - * | Hour | 70 | H | 0, 1, ... 23 | - * | | | HH | 00, 01, ... 23 | - * | Time of day hour | 70 | h | 1, 2, ..., 12 | - * | | | hh | 01, 02, ..., 12 | - * | Minute | 80 | m | 0, 1, ..., 59 | - * | | | mm | 00, 01, ..., 59 | - * | Second | 90 | s | 0, 1, ..., 59 | - * | | | ss | 00, 01, ..., 59 | - * | 1/10 of second | 100 | S | 0, 1, ..., 9 | - * | 1/100 of second | 100 | SS | 00, 01, ..., 99 | - * | Millisecond | 100 | SSS | 000, 001, ..., 999 | - * | Timezone | 110 | Z | -01:00, +00:00, ... +12:00 | - * | | | ZZ | -0100, +0000, ..., +1200 | - * | Seconds timestamp | 120 | X | 512969520 | - * | Milliseconds timestamp | 120 | x | 512969520900 | - * - * Values will be assigned to the date in the ascending order of its unit's priority. - * Units of an equal priority overwrite each other in the order of appearance. - * - * If no values of higher priority are parsed (e.g. when parsing string 'January 1st' without a year), - * the values will be taken from 3rd argument `baseDate` which works as a context of parsing. - * - * `baseDate` must be passed for correct work of the function. - * If you're not sure which `baseDate` to supply, create a new instance of Date: - * `parse('02/11/2014', 'MM/DD/YYYY', new Date())` - * In this case parsing will be done in the context of the current date. - * If `baseDate` is `Invalid Date` or a value not convertible to valid `Date`, - * then `Invalid Date` will be returned. - * - * Also, `parse` unfolds long formats like those in [format]{@link https://date-fns.org/docs/format}: - * | Token | Input examples | - * |-------|--------------------------------| - * | LT | 05:30 a.m. | - * | LTS | 05:30:15 a.m. | - * | L | 07/02/1995 | - * | l | 7/2/1995 | - * | LL | July 2 1995 | - * | ll | Jul 2 1995 | - * | LLL | July 2 1995 05:30 a.m. | - * | lll | Jul 2 1995 05:30 a.m. | - * | LLLL | Sunday, July 2 1995 05:30 a.m. | - * | llll | Sun, Jul 2 1995 05:30 a.m. | - * - * The characters wrapped in square brackets in the format string are escaped. - * - * The result may vary by locale. - * - * If `formatString` matches with `dateString` but does not provides tokens, `baseDate` will be returned. - * - * If parsing failed, `Invalid Date` will be returned. - * Invalid Date is a Date, whose time value is NaN. - * Time value of Date: http://es5.github.io/#x15.9.1.1 - * - * @param {String} dateString - the string to parse - * @param {String} formatString - the string of tokens - * @param {Date|String|Number} baseDate - the date to took the missing higher priority values from - * @param {Options} [options] - the object with options. See [Options]{@link https://date-fns.org/docs/Options} - * @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate} - * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale} - * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday) - * @returns {Date} the parsed date - * @throws {TypeError} 3 arguments required - * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2 - * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6 - * @throws {RangeError} `options.locale` must contain `match` property - * @throws {RangeError} `options.locale` must contain `formatLong` property - * - * @example - * // Parse 11 February 2014 from middle-endian format: - * var result = parse( - * '02/11/2014', - * 'MM/DD/YYYY', - * new Date() - * ) - * //=> Tue Feb 11 2014 00:00:00 - * - * @example - * // Parse 28th of February in English locale in the context of 2010 year: - * import eoLocale from 'date-fns/locale/eo' - * var result = parse( - * '28-a de februaro', - * 'Do [de] MMMM', - * new Date(2010, 0, 1) - * {locale: eoLocale} - * ) - * //=> Sun Feb 28 2010 00:00:00 - */ -function parse (dirtyDateString, dirtyFormatString, dirtyBaseDate, dirtyOptions) { - if (arguments.length < 3) { - throw new TypeError('3 arguments required, but only ' + arguments.length + ' present') - } - - var dateString = String(dirtyDateString); - var options = dirtyOptions || {}; - - var weekStartsOn = options.weekStartsOn === undefined ? 0 : Number(options.weekStartsOn); - - // Test if weekStartsOn is between 0 and 6 _and_ is not NaN - if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) { - throw new RangeError('weekStartsOn must be between 0 and 6 inclusively') - } - - var locale$$1 = options.locale || locale; - var localeParsers = locale$$1.parsers || {}; - var localeUnits = locale$$1.units || {}; - - if (!locale$$1.match) { - throw new RangeError('locale must contain match property') - } - - if (!locale$$1.formatLong) { - throw new RangeError('locale must contain formatLong property') - } - - var formatString = String(dirtyFormatString) - .replace(longFormattingTokensRegExp$1, function (substring) { - if (substring[0] === '[') { - return substring + var defaults = createFlags(); + Object.keys(this.flags).filter(function (flag) { return flag !== 'required'; }).forEach(function (flag) { + this$1.flags[flag] = defaults[flag]; + }); + this.addActionListeners(); + this.updateClasses(); + this.updateAriaAttrs(); + this.updateCustomValidity(); + }; + Field.prototype.setFlags = function setFlags (flags) { + var this$1 = this; + + var negated = { + pristine: 'dirty', + dirty: 'pristine', + valid: 'invalid', + invalid: 'valid', + touched: 'untouched', + untouched: 'touched' + }; + Object.keys(flags).forEach(function (flag) { + this$1.flags[flag] = flags[flag]; + if (negated[flag] && flags[negated[flag]] === undefined) { + this$1.flags[negated[flag]] = !flags[flag]; + } + }); + if (flags.untouched !== undefined || flags.touched !== undefined || flags.dirty !== undefined || flags.pristine !== undefined) { + this.addActionListeners(); } + this.updateClasses(); + this.updateAriaAttrs(); + this.updateCustomValidity(); + }; + Field.prototype.updateDependencies = function updateDependencies () { + var this$1 = this; + + this.dependencies.forEach(function (d) { return d.field.destroy(); }); + this.dependencies = []; + var fields = Object.keys(this.rules).reduce(function (prev, r) { + if (Validator.isTargetRule(r)) { + var selector = this$1.rules[r][0]; + if (r === 'confirmed' && !selector) { + selector = (this$1.name) + "_confirmation"; + } + prev.push({ + selector: selector, + name: r + }); + } + return prev; + }, []); + if (!fields.length || !this.vm || !this.vm.$el) + { return; } + fields.forEach(function (ref) { + var selector = ref.selector; + var name = ref.name; + + var el = null; + if (selector[0] === '$') { + var ref$1 = this$1.vm.$refs[selector.slice(1)]; + el = Array.isArray(ref$1) ? ref$1[0] : ref$1; + } else { + try { + el = this$1.vm.$el.querySelector(selector); + } catch (err) { + el = null; + } + } + if (!el) { + try { + el = this$1.vm.$el.querySelector(("input[name=\"" + selector + "\"]")); + } catch (err) { + el = null; + } + } + if (!el) { + return; + } + var options = { + vm: this$1.vm, + classes: this$1.classes, + classNames: this$1.classNames, + delay: this$1.delay, + scope: this$1.scope, + events: this$1.events.join('|'), + initial: this$1.initial, + targetOf: this$1.id + }; + if (isCallable(el.$watch)) { + options.component = el; + options.el = el.$el; + options.getter = Generator.resolveGetter(el.$el, { + child: el + }); + } else { + options.el = el; + options.getter = Generator.resolveGetter(el, {}); + } + this$1.dependencies.push({ + name: name, + field: new Field(options) + }); + }); + }; + Field.prototype.unwatch = function unwatch (tag) { + if ( tag === void 0 ) tag = null; - if (substring[0] === '\\') { - return cleanEscapedString$1(substring) + if (!tag) { + this.watchers.forEach(function (w) { return w.unwatch(); }); + this.watchers = []; + return; } - - return locale$$1.formatLong(substring) - }); - - if (formatString === '') { - if (dateString === '') { - return toDate(dirtyBaseDate, options) - } else { - return new Date(NaN) - } - } - - var subFnOptions = cloneObject(options); - subFnOptions.locale = locale$$1; - - var tokens = formatString.match(locale$$1.parsingTokensRegExp || defaultParsingTokensRegExp); - var tokensLength = tokens.length; - - // If timezone isn't specified, it will be set to the system timezone - var setters = [{ - priority: TIMEZONE_UNIT_PRIORITY, - set: dateToSystemTimezone, - index: 0 - }]; - - var i; - for (i = 0; i < tokensLength; i++) { - var token = tokens[i]; - var parser = localeParsers[token] || parsers[token]; - if (parser) { - var matchResult; - - if (parser.match instanceof RegExp) { - matchResult = parser.match.exec(dateString); - } else { - matchResult = parser.match(dateString, subFnOptions); + this.watchers.filter(function (w) { return tag.test(w.tag); }).forEach(function (w) { return w.unwatch(); }); + this.watchers = this.watchers.filter(function (w) { return !tag.test(w.tag); }); + }; + Field.prototype.updateClasses = function updateClasses () { + var this$1 = this; + + if (!this.classes || this.isDisabled) + { return; } + var applyClasses = function (el) { + toggleClass(el, this$1.classNames.dirty, this$1.flags.dirty); + toggleClass(el, this$1.classNames.pristine, this$1.flags.pristine); + toggleClass(el, this$1.classNames.touched, this$1.flags.touched); + toggleClass(el, this$1.classNames.untouched, this$1.flags.untouched); + if (!isNullOrUndefined(this$1.flags.valid) && this$1.flags.validated) { + toggleClass(el, this$1.classNames.valid, this$1.flags.valid); + } + if (!isNullOrUndefined(this$1.flags.invalid) && this$1.flags.validated) { + toggleClass(el, this$1.classNames.invalid, this$1.flags.invalid); + } + }; + if (!isCheckboxOrRadioInput(this.el)) { + applyClasses(this.el); + return; } - - if (!matchResult) { - return new Date(NaN) + var els = document.querySelectorAll(("input[name=\"" + (this.el.name) + "\"]")); + toArray(els).forEach(applyClasses); + }; + Field.prototype.addActionListeners = function addActionListeners () { + var this$1 = this; + + this.unwatch(/class/); + if (!this.el) + { return; } + var onBlur = function () { + this$1.flags.touched = true; + this$1.flags.untouched = false; + if (this$1.classes) { + toggleClass(this$1.el, this$1.classNames.touched, true); + toggleClass(this$1.el, this$1.classNames.untouched, false); + } + this$1.unwatch(/^class_blur$/); + }; + var inputEvent = isTextInput(this.el) ? 'input' : 'change'; + var onInput = function () { + this$1.flags.dirty = true; + this$1.flags.pristine = false; + if (this$1.classes) { + toggleClass(this$1.el, this$1.classNames.pristine, false); + toggleClass(this$1.el, this$1.classNames.dirty, true); + } + this$1.unwatch(/^class_input$/); + }; + if (this.component && isCallable(this.component.$once)) { + this.component.$once('input', onInput); + this.component.$once('blur', onBlur); + this.watchers.push({ + tag: 'class_input', + unwatch: function () { + this$1.component.$off('input', onInput); + } + }); + this.watchers.push({ + tag: 'class_blur', + unwatch: function () { + this$1.component.$off('blur', onBlur); + } + }); + return; } - - var unitName = parser.unit; - var unit = localeUnits[unitName] || units[unitName]; - - setters.push({ - priority: unit.priority, - set: unit.set, - value: parser.parse(matchResult, subFnOptions), - index: setters.length + if (!this.el) + { return; } + addEventListener(this.el, inputEvent, onInput); + var blurEvent = isCheckboxOrRadioInput(this.el) ? 'change' : 'blur'; + addEventListener(this.el, blurEvent, onBlur); + this.watchers.push({ + tag: 'class_input', + unwatch: function () { + this$1.el.removeEventListener(inputEvent, onInput); + } }); - - var substring = matchResult[0]; - dateString = dateString.slice(substring.length); - } else { - var head = tokens[i].match(/^\[.*]$/) ? tokens[i].replace(/^\[|]$/g, '') : tokens[i]; - if (dateString.indexOf(head) === 0) { - dateString = dateString.slice(head.length); - } else { - return new Date(NaN) + this.watchers.push({ + tag: 'class_blur', + unwatch: function () { + this$1.el.removeEventListener(blurEvent, onBlur); + } + }); + }; + Field.prototype.checkValueChanged = function checkValueChanged () { + if (this.initialValue === null && this.value === '' && isTextInput(this.el)) { + return false; } - } - } - - var uniquePrioritySetters = setters - .map(function (setter) { - return setter.priority - }) - .sort(function (a, b) { - return a - b - }) - .filter(function (priority, index, array) { - return array.indexOf(priority) === index - }) - .map(function (priority) { - return setters - .filter(function (setter) { - return setter.priority === priority - }) - .reverse() - }) - .map(function (setterArray) { - return setterArray[0] - }); - - var date = toDate(dirtyBaseDate, options); - - if (isNaN(date)) { - return new Date(NaN) - } - - // Convert the date in system timezone to the same date in UTC+00:00 timezone. - // This ensures that when UTC functions will be implemented, locales will be compatible with them. - // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/37 - var utcDate = subMinutes(date, date.getTimezoneOffset()); - - var dateValues = {date: utcDate}; - - var settersLength = uniquePrioritySetters.length; - for (i = 0; i < settersLength; i++) { - var setter = uniquePrioritySetters[i]; - dateValues = setter.set(dateValues, setter.value, subFnOptions); - } - - return dateValues.date -} - -function dateToSystemTimezone (dateValues) { - var date = dateValues.date; - var time = date.getTime(); - - // Get the system timezone offset at (moment of time - offset) - var offset = date.getTimezoneOffset(); - - // Get the system timezone offset at the exact moment of time - offset = new Date(time + offset * MILLISECONDS_IN_MINUTE$6).getTimezoneOffset(); - - // Convert date in timezone "UTC+00:00" to the system timezone - dateValues.date = new Date(time + offset * MILLISECONDS_IN_MINUTE$6); - - return dateValues -} - -function cleanEscapedString$1 (input) { - if (input.match(/\[[\s\S]/)) { - return input.replace(/^\[|]$/g, '') - } - return input.replace(/\\/g, '') -} - -// This file is generated automatically by `scripts/build/indices.js`. Please, don't change it. - -// - -/** - * Custom parse behavior on top of date-fns parse function. - */ -function parseDate$1 (date, format$$1) { - if (typeof date !== 'string') { - return isValid(date) ? date : null; - } - - var parsed = parse(date, format$$1, new Date()); - - // if date is not valid or the formatted output after parsing does not match - // the string value passed in (avoids overflows) - if (!isValid(parsed) || format(parsed, format$$1) !== date) { - return null; - } - - return parsed; -} - -var after = function (value, ref) { - var otherValue = ref[0]; - var inclusion = ref[1]; - var format = ref[2]; - - if (typeof format === 'undefined') { - format = inclusion; - inclusion = false; - } - value = parseDate$1(value, format); - otherValue = parseDate$1(otherValue, format); - - // if either is not valid. - if (!value || !otherValue) { - return false; - } - - return isAfter(value, otherValue) || (inclusion && isEqual(value, otherValue)); -}; - -/** - * Some Alpha Regex helpers. - * https://github.com/chriso/validator.js/blob/master/src/lib/alpha.js - */ - -var alpha$1 = { - en: /^[A-Z]*$/i, - cs: /^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]*$/i, - da: /^[A-ZÆØÅ]*$/i, - de: /^[A-ZÄÖÜß]*$/i, - es: /^[A-ZÁÉÍÑÓÚÜ]*$/i, - fr: /^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]*$/i, - lt: /^[A-ZĄČĘĖĮŠŲŪŽ]*$/i, - nl: /^[A-ZÉËÏÓÖÜ]*$/i, - hu: /^[A-ZÁÉÍÓÖŐÚÜŰ]*$/i, - pl: /^[A-ZĄĆĘŚŁŃÓŻŹ]*$/i, - pt: /^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]*$/i, - ru: /^[А-ЯЁ]*$/i, - sk: /^[A-ZÁÄČĎÉÍĹĽŇÓŔŠŤÚÝŽ]*$/i, - sr: /^[A-ZČĆŽŠĐ]*$/i, - tr: /^[A-ZÇĞİıÖŞÜ]*$/i, - uk: /^[А-ЩЬЮЯЄІЇҐ]*$/i, - ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]*$/ -}; - -var alphaSpaces = { - en: /^[A-Z\s]*$/i, - cs: /^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ\s]*$/i, - da: /^[A-ZÆØÅ\s]*$/i, - de: /^[A-ZÄÖÜß\s]*$/i, - es: /^[A-ZÁÉÍÑÓÚÜ\s]*$/i, - fr: /^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ\s]*$/i, - lt: /^[A-ZĄČĘĖĮŠŲŪŽ\s]*$/i, - nl: /^[A-ZÉËÏÓÖÜ\s]*$/i, - hu: /^[A-ZÁÉÍÓÖŐÚÜŰ\s]*$/i, - pl: /^[A-ZĄĆĘŚŁŃÓŻŹ\s]*$/i, - pt: /^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ\s]*$/i, - ru: /^[А-ЯЁ\s]*$/i, - sk: /^[A-ZÁÄČĎÉÍĹĽŇÓŔŠŤÚÝŽ\s]*$/i, - sr: /^[A-ZČĆŽŠĐ\s]*$/i, - tr: /^[A-ZÇĞİıÖŞÜ\s]*$/i, - uk: /^[А-ЩЬЮЯЄІЇҐ\s]*$/i, - ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ\s]*$/ -}; - -var alphanumeric = { - en: /^[0-9A-Z]*$/i, - cs: /^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]*$/i, - da: /^[0-9A-ZÆØÅ]$/i, - de: /^[0-9A-ZÄÖÜß]*$/i, - es: /^[0-9A-ZÁÉÍÑÓÚÜ]*$/i, - fr: /^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]*$/i, - lt: /^[0-9A-ZĄČĘĖĮŠŲŪŽ]*$/i, - hu: /^[0-9A-ZÁÉÍÓÖŐÚÜŰ]*$/i, - nl: /^[0-9A-ZÉËÏÓÖÜ]*$/i, - pl: /^[0-9A-ZĄĆĘŚŁŃÓŻŹ]*$/i, - pt: /^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]*$/i, - ru: /^[0-9А-ЯЁ]*$/i, - sk: /^[0-9A-ZÁÄČĎÉÍĹĽŇÓŔŠŤÚÝŽ]*$/i, - sr: /^[0-9A-ZČĆŽŠĐ]*$/i, - tr: /^[0-9A-ZÇĞİıÖŞÜ]*$/i, - uk: /^[0-9А-ЩЬЮЯЄІЇҐ]*$/i, - ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]*$/ -}; - -var alphaDash = { - en: /^[0-9A-Z_-]*$/i, - cs: /^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ_-]*$/i, - da: /^[0-9A-ZÆØÅ_-]*$/i, - de: /^[0-9A-ZÄÖÜß_-]*$/i, - es: /^[0-9A-ZÁÉÍÑÓÚÜ_-]*$/i, - fr: /^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ_-]*$/i, - lt: /^[0-9A-ZĄČĘĖĮŠŲŪŽ_-]*$/i, - nl: /^[0-9A-ZÉËÏÓÖÜ_-]*$/i, - hu: /^[0-9A-ZÁÉÍÓÖŐÚÜŰ_-]*$/i, - pl: /^[0-9A-ZĄĆĘŚŁŃÓŻŹ_-]*$/i, - pt: /^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ_-]*$/i, - ru: /^[0-9А-ЯЁ_-]*$/i, - sk: /^[0-9A-ZÁÄČĎÉÍĹĽŇÓŔŠŤÚÝŽ_-]*$/i, - sr: /^[0-9A-ZČĆŽŠĐ_-]*$/i, - tr: /^[0-9A-ZÇĞİıÖŞÜ_-]*$/i, - uk: /^[0-9А-ЩЬЮЯЄІЇҐ_-]*$/i, - ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ_-]*$/ -}; - -var validate = function (value, ref) { - if ( ref === void 0 ) ref = []; - var locale = ref[0]; if ( locale === void 0 ) locale = null; - - if (Array.isArray(value)) { - return value.every(function (val) { return validate(val, [locale]); }); - } - - // Match at least one locale. - if (! locale) { - return Object.keys(alpha$1).some(function (loc) { return alpha$1[loc].test(value); }); - } - - return (alpha$1[locale] || alpha$1.en).test(value); -}; - -var validate$1 = function (value, ref) { - if ( ref === void 0 ) ref = []; - var locale = ref[0]; if ( locale === void 0 ) locale = null; - - if (Array.isArray(value)) { - return value.every(function (val) { return validate$1(val, [locale]); }); - } - - // Match at least one locale. - if (! locale) { - return Object.keys(alphaDash).some(function (loc) { return alphaDash[loc].test(value); }); - } - - return (alphaDash[locale] || alphaDash.en).test(value); -}; - -var validate$2 = function (value, ref) { - if ( ref === void 0 ) ref = []; - var locale = ref[0]; if ( locale === void 0 ) locale = null; - - if (Array.isArray(value)) { - return value.every(function (val) { return validate$2(val, [locale]); }); - } - - // Match at least one locale. - if (! locale) { - return Object.keys(alphanumeric).some(function (loc) { return alphanumeric[loc].test(value); }); - } - - return (alphanumeric[locale] || alphanumeric.en).test(value); -}; - -var validate$3 = function (value, ref) { - if ( ref === void 0 ) ref = []; - var locale = ref[0]; if ( locale === void 0 ) locale = null; - - if (Array.isArray(value)) { - return value.every(function (val) { return validate$3(val, [locale]); }); - } - - // Match at least one locale. - if (! locale) { - return Object.keys(alphaSpaces).some(function (loc) { return alphaSpaces[loc].test(value); }); - } - - return (alphaSpaces[locale] || alphaSpaces.en).test(value); -}; - -var before = function (value, ref) { - var otherValue = ref[0]; - var inclusion = ref[1]; - var format = ref[2]; - - if (typeof format === 'undefined') { - format = inclusion; - inclusion = false; - } - value = parseDate$1(value, format); - otherValue = parseDate$1(otherValue, format); - - // if either is not valid. - if (!value || !otherValue) { - return false; - } - - return isBefore(value, otherValue) || (inclusion && isEqual(value, otherValue)); -}; - -var validate$4 = function (value, ref) { - var min = ref[0]; - var max = ref[1]; - - if (Array.isArray(value)) { - return value.every(function (val) { return validate$4(val, [min, max]); }); - } - - return Number(min) <= value && Number(max) >= value; -}; - -var confirmed = function (value, other) { return String(value) === String(other); }; - -function unwrapExports (x) { - return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; -} - -function createCommonjsModule(fn, module) { - return module = { exports: {} }, fn(module, module.exports), module.exports; -} - -var assertString_1 = createCommonjsModule(function (module, exports) { -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = assertString; -function assertString(input) { - var isString = typeof input === 'string' || input instanceof String; - - if (!isString) { - throw new TypeError('This library (validator.js) validates strings only'); - } -} -module.exports = exports['default']; -}); - -unwrapExports(assertString_1); - -var isCreditCard_1 = createCommonjsModule(function (module, exports) { -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = isCreditCard; - - - -var _assertString2 = _interopRequireDefault(assertString_1); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/* eslint-disable max-len */ -var creditCard = /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|62[0-9]{14})$/; -/* eslint-enable max-len */ - -function isCreditCard(str) { - (0, _assertString2.default)(str); - var sanitized = str.replace(/[- ]+/g, ''); - if (!creditCard.test(sanitized)) { - return false; - } - var sum = 0; - var digit = void 0; - var tmpNum = void 0; - var shouldDouble = void 0; - for (var i = sanitized.length - 1; i >= 0; i--) { - digit = sanitized.substring(i, i + 1); - tmpNum = parseInt(digit, 10); - if (shouldDouble) { - tmpNum *= 2; - if (tmpNum >= 10) { - sum += tmpNum % 10 + 1; - } else { - sum += tmpNum; + return this.value !== this.initialValue; + }; + Field.prototype.addValueListeners = function addValueListeners () { + var this$1 = this; + + this.unwatch(/^input_.+/); + if (!this.listen || !this.el) + { return; } + var token = { + cancelled: false + }; + var fn = this.targetOf ? function () { + this$1.flags.changed = this$1.checkValueChanged(); + this$1.validator.validate(("#" + (this$1.targetOf))); + } : function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + if (args.length === 0 || isCallable(Event) && args[0] instanceof Event || args[0] && args[0].srcElement) { + args[0] = this$1.value; + } + this$1.flags.changed = this$1.checkValueChanged(); + this$1.validator.validate(("#" + (this$1.id)), args[0]); + }; + var inputEvent = this.component || isTextInput(this.el) ? 'input' : 'change'; + inputEvent = this.model && this.model.lazy ? 'change' : inputEvent; + var events = !this.events.length || this.component || isTextInput(this.el) ? this.events : ['change']; + if (this.model && this.model.expression && events.indexOf(inputEvent) !== -1) { + var debouncedFn = debounce(fn, this.delay[inputEvent], false, token); + var unwatch = this.vm.$watch(this.model.expression, function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + this$1.flags.pending = true; + this$1._cancellationToken = token; + debouncedFn.apply(void 0, args); + }); + this.watchers.push({ + tag: 'input_model', + unwatch: unwatch + }); + events = events.filter(function (e) { return e !== inputEvent; }); } - } else { - sum += tmpNum; - } - shouldDouble = !shouldDouble; - } - return !!(sum % 10 === 0 ? sanitized : false); -} -module.exports = exports['default']; -}); - -var isCreditCard = unwrapExports(isCreditCard_1); - -var credit_card = function (value) { return isCreditCard(String(value)); }; - -var validate$5 = function (value, ref) { - if ( ref === void 0 ) ref = []; - var decimals = ref[0]; if ( decimals === void 0 ) decimals = '*'; - var separator = ref[1]; if ( separator === void 0 ) separator = '.'; - - if (Array.isArray(value)) { - return value.every(function (val) { return validate$5(val, [decimals, separator]); }); - } - - if (value === null || value === undefined || value === '') { - return true; - } - - // if is 0. - if (Number(decimals) === 0) { - return /^-?\d*$/.test(value); - } - - var regexPart = decimals === '*' ? '+' : ("{1," + decimals + "}"); - var regex = new RegExp(("^-?\\d*(\\" + separator + "\\d" + regexPart + ")?$")); - - if (! regex.test(value)) { - return false; - } - - var parsedValue = parseFloat(value); - - // eslint-disable-next-line - return parsedValue === parsedValue; -}; - -var date_between = function (value, params) { - var min; - var max; - var format; - var inclusivity = '()'; - - if (params.length > 3) { - var assign; - (assign = params, min = assign[0], max = assign[1], inclusivity = assign[2], format = assign[3]); - } else { - var assign$1; - (assign$1 = params, min = assign$1[0], max = assign$1[1], format = assign$1[2]); - } - - var minDate = parseDate$1(min, format); - var maxDate = parseDate$1(max, format); - var dateVal = parseDate$1(value, format); - - if (!minDate || !maxDate || !dateVal) { - return false; - } - - if (inclusivity === '()') { - return isAfter(dateVal, minDate) && isBefore(dateVal, maxDate); - } - - if (inclusivity === '(]') { - return isAfter(dateVal, minDate) && (isEqual(dateVal, maxDate) || isBefore(dateVal, maxDate)); - } - - if (inclusivity === '[)') { - return isBefore(dateVal, maxDate) && (isEqual(dateVal, minDate) || isAfter(dateVal, minDate)); - } - - return isEqual(dateVal, maxDate) || isEqual(dateVal, minDate) || - (isBefore(dateVal, maxDate) && isAfter(dateVal, minDate)); -}; - -var date_format = function (value, ref) { - var format = ref[0]; - - return !!parseDate$1(value, format); -}; - -var validate$6 = function (value, ref) { - var length = ref[0]; - - if (Array.isArray(value)) { - return value.every(function (val) { return validate$6(val, [length]); }); - } - var strVal = String(value); - - return /^[0-9]*$/.test(strVal) && strVal.length === Number(length); -}; - -var validateImage = function (file, width, height) { - var URL = window.URL || window.webkitURL; - return new Promise(function (resolve) { - var image = new Image(); - image.onerror = function () { return resolve({ valid: false }); }; - image.onload = function () { return resolve({ - valid: image.width === Number(width) && image.height === Number(height) - }); }; - - image.src = URL.createObjectURL(file); - }); -}; - -var dimensions = function (files, ref) { - var width = ref[0]; - var height = ref[1]; - - var list = []; - for (var i = 0; i < files.length; i++) { - // if file is not an image, reject. - if (! /\.(jpg|svg|jpeg|png|bmp|gif)$/i.test(files[i].name)) { - return false; - } - - list.push(files[i]); - } - - return Promise.all(list.map(function (file) { return validateImage(file, width, height); })); -}; - -var merge_1 = createCommonjsModule(function (module, exports) { -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = merge; -function merge() { - var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var defaults = arguments[1]; - - for (var key in defaults) { - if (typeof obj[key] === 'undefined') { - obj[key] = defaults[key]; - } - } - return obj; -} -module.exports = exports['default']; -}); - -unwrapExports(merge_1); - -var isByteLength_1 = createCommonjsModule(function (module, exports) { -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - -exports.default = isByteLength; - - - -var _assertString2 = _interopRequireDefault(assertString_1); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/* eslint-disable prefer-rest-params */ -function isByteLength(str, options) { - (0, _assertString2.default)(str); - var min = void 0; - var max = void 0; - if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object') { - min = options.min || 0; - max = options.max; - } else { - // backwards compatibility: isByteLength(str, min [, max]) - min = arguments[1]; - max = arguments[2]; - } - var len = encodeURI(str).split(/%..|./).length - 1; - return len >= min && (typeof max === 'undefined' || len <= max); -} -module.exports = exports['default']; -}); - -unwrapExports(isByteLength_1); - -var isFQDN = createCommonjsModule(function (module, exports) { -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = isFDQN; - - - -var _assertString2 = _interopRequireDefault(assertString_1); - - - -var _merge2 = _interopRequireDefault(merge_1); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var default_fqdn_options = { - require_tld: true, - allow_underscores: false, - allow_trailing_dot: false -}; - -function isFDQN(str, options) { - (0, _assertString2.default)(str); - options = (0, _merge2.default)(options, default_fqdn_options); - - /* Remove the optional trailing dot before checking validity */ - if (options.allow_trailing_dot && str[str.length - 1] === '.') { - str = str.substring(0, str.length - 1); - } - var parts = str.split('.'); - if (options.require_tld) { - var tld = parts.pop(); - if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) { - return false; - } - // disallow spaces - if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20]/.test(tld)) { - return false; - } - } - for (var part, i = 0; i < parts.length; i++) { - part = parts[i]; - if (options.allow_underscores) { - part = part.replace(/_/g, ''); - } - if (!/^[a-z\u00a1-\uffff0-9-]+$/i.test(part)) { - return false; - } - // disallow full-width chars - if (/[\uff01-\uff5e]/.test(part)) { - return false; - } - if (part[0] === '-' || part[part.length - 1] === '-') { - return false; - } - } - return true; -} -module.exports = exports['default']; -}); - -unwrapExports(isFQDN); - -var isEmail_1 = createCommonjsModule(function (module, exports) { -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = isEmail; - - - -var _assertString2 = _interopRequireDefault(assertString_1); - - - -var _merge2 = _interopRequireDefault(merge_1); - - - -var _isByteLength2 = _interopRequireDefault(isByteLength_1); - - - -var _isFQDN2 = _interopRequireDefault(isFQDN); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var default_email_options = { - allow_display_name: false, - require_display_name: false, - allow_utf8_local_part: true, - require_tld: true -}; - -/* eslint-disable max-len */ -/* eslint-disable no-control-regex */ -var displayName = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\,\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/i; -var emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i; -var quotedEmailUser = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i; -var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i; -var quotedEmailUserUtf8 = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i; -/* eslint-enable max-len */ -/* eslint-enable no-control-regex */ - -function isEmail(str, options) { - (0, _assertString2.default)(str); - options = (0, _merge2.default)(options, default_email_options); - - if (options.require_display_name || options.allow_display_name) { - var display_email = str.match(displayName); - if (display_email) { - str = display_email[1]; - } else if (options.require_display_name) { - return false; - } - } - - var parts = str.split('@'); - var domain = parts.pop(); - var user = parts.join('@'); - - var lower_domain = domain.toLowerCase(); - if (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com') { - user = user.replace(/\./g, '').toLowerCase(); - } - - if (!(0, _isByteLength2.default)(user, { max: 64 }) || !(0, _isByteLength2.default)(domain, { max: 254 })) { - return false; - } - - if (!(0, _isFQDN2.default)(domain, { require_tld: options.require_tld })) { - return false; - } - - if (user[0] === '"') { - user = user.slice(1, user.length - 1); - return options.allow_utf8_local_part ? quotedEmailUserUtf8.test(user) : quotedEmailUser.test(user); - } - - var pattern = options.allow_utf8_local_part ? emailUserUtf8Part : emailUserPart; - - var user_parts = user.split('.'); - for (var i = 0; i < user_parts.length; i++) { - if (!pattern.test(user_parts[i])) { - return false; - } - } - - return true; -} -module.exports = exports['default']; -}); - -var isEmail = unwrapExports(isEmail_1); - -var validate$7 = function (value) { - if (Array.isArray(value)) { - return value.every(function (val) { return isEmail(String(val)); }); - } - - return isEmail(String(value)); -}; - -var ext = function (files, extensions) { - var regex = new RegExp((".(" + (extensions.join('|')) + ")$"), 'i'); - - return files.every(function (file) { return regex.test(file.name); }); -}; - -var image = function (files) { return files.every(function (file) { return /\.(jpg|svg|jpeg|png|bmp|gif)$/i.test(file.name); } -); }; - -var validate$8 = function (value, options) { - if (Array.isArray(value)) { - return value.every(function (val) { return validate$8(val, options); }); - } - - // eslint-disable-next-line - return !! options.filter(function (option) { return option == value; }).length; -}; - -var isIP_1 = createCommonjsModule(function (module, exports) { -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = isIP; - - - -var _assertString2 = _interopRequireDefault(assertString_1); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var ipv4Maybe = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/; -var ipv6Block = /^[0-9A-F]{1,4}$/i; - -function isIP(str) { - var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; - - (0, _assertString2.default)(str); - version = String(version); - if (!version) { - return isIP(str, 4) || isIP(str, 6); - } else if (version === '4') { - if (!ipv4Maybe.test(str)) { - return false; - } - var parts = str.split('.').sort(function (a, b) { - return a - b; - }); - return parts[3] <= 255; - } else if (version === '6') { - var blocks = str.split(':'); - var foundOmissionBlock = false; // marker to indicate :: - - // At least some OS accept the last 32 bits of an IPv6 address - // (i.e. 2 of the blocks) in IPv4 notation, and RFC 3493 says - // that '::ffff:a.b.c.d' is valid for IPv4-mapped IPv6 addresses, - // and '::a.b.c.d' is deprecated, but also valid. - var foundIPv4TransitionBlock = isIP(blocks[blocks.length - 1], 4); - var expectedNumberOfBlocks = foundIPv4TransitionBlock ? 7 : 8; - - if (blocks.length > expectedNumberOfBlocks) { - return false; - } - // initial or final :: - if (str === '::') { - return true; - } else if (str.substr(0, 2) === '::') { - blocks.shift(); - blocks.shift(); - foundOmissionBlock = true; - } else if (str.substr(str.length - 2) === '::') { - blocks.pop(); - blocks.pop(); - foundOmissionBlock = true; - } - - for (var i = 0; i < blocks.length; ++i) { - // test for a :: which can not be at the string start/end - // since those cases have been handled above - if (blocks[i] === '' && i > 0 && i < blocks.length - 1) { - if (foundOmissionBlock) { - return false; // multiple :: in address - } - foundOmissionBlock = true; - } else if (foundIPv4TransitionBlock && i === blocks.length - 1) { - // it has been checked before that the last - // block is a valid IPv4 address - } else if (!ipv6Block.test(blocks[i])) { - return false; - } - } - if (foundOmissionBlock) { - return blocks.length >= 1; - } - return blocks.length === expectedNumberOfBlocks; - } - return false; -} -module.exports = exports['default']; -}); - -var isIP = unwrapExports(isIP_1); - -// - -/** - * Gets the data attribute. the name must be kebab-case. - */ -var getDataAttribute = function (el, name) { return el.getAttribute(("data-vv-" + name)); }; - -/** - * Checks if the value is either null or undefined. - */ -var isNullOrUndefined = function (value) { - return value === null || value === undefined; -}; - -/** - * Sets the data attribute. - */ -var setDataAttribute = function (el, name, value) { return el.setAttribute(("data-vv-" + name), value); }; - -/** - * Creates a proxy object if available in the environment. - */ -var createProxy = function (target, handler) { - if (typeof Proxy === 'undefined') { - return target; - } - - return new Proxy(target, handler); -}; - -/** - * Creates the default flags object. - */ -var createFlags = function () { return ({ - untouched: true, - touched: false, - dirty: false, - pristine: true, - valid: null, - invalid: null, - validated: false, - pending: false, - required: false -}); }; - -/** - * Shallow object comparison. - */ -var isEqual$1 = function (lhs, rhs) { - if (lhs instanceof RegExp && rhs instanceof RegExp) { - return isEqual$1(lhs.source, rhs.source) && isEqual$1(lhs.flags, rhs.flags); - } - - if (Array.isArray(lhs) && Array.isArray(rhs)) { - if (lhs.length !== rhs.length) { return false; } - - for (var i = 0; i < lhs.length; i++) { - if (!isEqual$1(lhs[i], rhs[i])) { - return false; - } - } - - return true; - } - - // if both are objects, compare each key recursively. - if (isObject(lhs) && isObject(rhs)) { - return Object.keys(lhs).every(function (key) { - return isEqual$1(lhs[key], rhs[key]); - }) && Object.keys(rhs).every(function (key) { - return isEqual$1(lhs[key], rhs[key]); - }); - } - - return lhs === rhs; -}; - -/** - * Determines the input field scope. - */ -var getScope = function (el) { - var scope = getDataAttribute(el, 'scope'); - if (isNullOrUndefined(scope) && el.form) { - scope = getDataAttribute(el.form, 'scope'); - } - - return !isNullOrUndefined(scope) ? scope : null; -}; - -/** - * Gets the value in an object safely. - */ -var getPath = function (path, target, def) { - if ( def === void 0 ) def = undefined; - - if (!path || !target) { return def; } - - var value = target; - path.split('.').every(function (prop) { - if (! Object.prototype.hasOwnProperty.call(value, prop) && value[prop] === undefined) { - value = def; - - return false; - } - - value = value[prop]; - - return true; - }); - - return value; -}; - -/** - * Checks if path exists within an object. - */ -var hasPath = function (path, target) { - var obj = target; - return path.split('.').every(function (prop) { - if (! Object.prototype.hasOwnProperty.call(obj, prop)) { - return false; - } - - obj = obj[prop]; - - return true; - }); -}; - -/** - * Parses a rule string expression. - */ -var parseRule = function (rule) { - var params = []; - var name = rule.split(':')[0]; - - if (~rule.indexOf(':')) { - params = rule.split(':').slice(1).join(':').split(','); - } - - return { name: name, params: params }; -}; - -/** - * Debounces a function. - */ -var debounce = function (fn, wait, immediate) { - if ( wait === void 0 ) wait = 0; - if ( immediate === void 0 ) immediate = false; - - if (wait === 0) { - return fn; - } - - var timeout; - - return function () { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - var later = function () { - timeout = null; - if (!immediate) { fn.apply(void 0, args); } - }; - /* istanbul ignore next */ - var callNow = immediate && !timeout; - clearTimeout(timeout); - timeout = setTimeout(later, wait); - /* istanbul ignore next */ - if (callNow) { fn.apply(void 0, args); } + events.forEach(function (e) { + var debouncedFn = debounce(fn, this$1.delay[e], false, token); + var validate = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + this$1.flags.pending = true; + this$1._cancellationToken = token; + debouncedFn.apply(void 0, args); + }; + this$1._addComponentEventListener(e, validate); + this$1._addHTMLEventListener(e, validate); + }); }; -}; - -/** - * Normalizes the given rules expression. - */ -var normalizeRules = function (rules) { - // if falsy value return an empty object. - if (!rules) { - return {}; - } - - if (isObject(rules)) { - // $FlowFixMe - return Object.keys(rules).reduce(function (prev, curr) { - var params = []; - // $FlowFixMe - if (rules[curr] === true) { - params = []; - } else if (Array.isArray(rules[curr])) { - params = rules[curr]; - } else { - params = [rules[curr]]; - } - - // $FlowFixMe - if (rules[curr] !== false) { - prev[curr] = params; - } - - return prev; - }, {}); - } - - if (typeof rules !== 'string') { - warn('rules must be either a string or an object.'); - return {}; - } - - return rules.split('|').reduce(function (prev, rule) { - var parsedRule = parseRule(rule); - if (!parsedRule.name) { - return prev; - } - - prev[parsedRule.name] = parsedRule.params; - return prev; - }, {}); -}; - -/** - * Emits a warning to the console. - */ -var warn = function (message) { - console.warn(("[vee-validate] " + message)); // eslint-disable-line -}; - -/** - * Creates a branded error object. - */ -var createError = function (message) { return new Error(("[vee-validate] " + message)); }; - -/** - * Checks if the value is an object. - */ -var isObject = function (obj) { return obj !== null && obj && typeof obj === 'object' && ! Array.isArray(obj); }; - -/** - * Checks if a function is callable. - */ -var isCallable = function (func) { return typeof func === 'function'; }; - -/** - * Check if element has the css class on it. - */ -var hasClass = function (el, className) { - if (el.classList) { - return el.classList.contains(className); - } - - return !!el.className.match(new RegExp(("(\\s|^)" + className + "(\\s|$)"))); -}; - -/** - * Adds the provided css className to the element. - */ -var addClass = function (el, className) { - if (el.classList) { - el.classList.add(className); - return; - } - - if (!hasClass(el, className)) { - el.className += " " + className; - } -}; - -/** - * Remove the provided css className from the element. - */ -var removeClass = function (el, className) { - if (el.classList) { - el.classList.remove(className); - return; - } - - if (hasClass(el, className)) { - var reg = new RegExp(("(\\s|^)" + className + "(\\s|$)")); - el.className = el.className.replace(reg, ' '); - } -}; - -/** - * Adds or removes a class name on the input depending on the status flag. - */ -var toggleClass = function (el, className, status) { - if (!el || !className) { return; } - - if (status) { - return addClass(el, className); - } - - removeClass(el, className); -}; - -/** - * Converts an array-like object to array, provides a simple polyfill for Array.from - */ -var toArray = function (arrayLike) { - if (isCallable(Array.from)) { - return Array.from(arrayLike); - } - - var array = []; - var length = arrayLike.length; - for (var i = 0; i < length; i++) { - array.push(arrayLike[i]); - } - - return array; -}; - -/** - * Assign polyfill from the mdn. - */ -var assign = function (target) { - var others = [], len = arguments.length - 1; - while ( len-- > 0 ) others[ len ] = arguments[ len + 1 ]; - - /* istanbul ignore else */ - if (isCallable(Object.assign)) { - return Object.assign.apply(Object, [ target ].concat( others )); - } - - /* istanbul ignore next */ - if (target == null) { - throw new TypeError('Cannot convert undefined or null to object'); - } - - /* istanbul ignore next */ - var to = Object(target); - /* istanbul ignore next */ - others.forEach(function (arg) { - // Skip over if undefined or null - if (arg != null) { - Object.keys(arg).forEach(function (key) { - to[key] = arg[key]; + Field.prototype._addComponentEventListener = function _addComponentEventListener (evt, validate) { + var this$1 = this; + + if (!this.component) + { return; } + this.component.$on(evt, validate); + this.watchers.push({ + tag: 'input_vue', + unwatch: function () { + this$1.component.$off(evt, validate); + } }); - } - }); - /* istanbul ignore next */ - return to; -}; - -var id = 0; -var idTemplate = '{id}'; - -/** - * Generates a unique id. - */ -var uniqId = function () { - // handle too many uses of uniqId, although unlikely. - if (id >= 9999) { - id = 0; - // shift the template. - idTemplate = idTemplate.replace('{id}', '_{id}'); - } - - id++; - var newId = idTemplate.replace('{id}', String(id)); - - return newId; -}; - -/** - * finds the first element that satisfies the predicate callback, polyfills array.find - */ -var find = function (arrayLike, predicate) { - var array = toArray(arrayLike); - - if (isCallable(array.find)) { - return array.find(predicate); - } - - var result; - array.some(function (item) { - if (predicate(item)) { - result = item; - return true; - } - - return false; - }); - - return result; -}; - -/** - * Returns a suitable event name for the input element. - */ -var getInputEventName = function (el) { - if (el && (el.tagName === 'SELECT' || ~['radio', 'checkbox', 'file'].indexOf(el.type))) { - return 'change'; - } - - return 'input'; -}; - -var isBuiltInComponent = function (vnode) { - if (!vnode) { - return false; - } - - var tag = vnode.componentOptions.tag; - - return /keep-alive|transition|transition-group/.test(tag); -}; - -var makeEventsArray = function (events) { - return (typeof events === 'string' && events.length) ? events.split('|') : []; -}; - -var makeDelayObject = function (events, delay) { - var delayObject = {}; - - // We already have a valid delay object - if (typeof delay === 'object' && !('global' in delay) && !('local' in delay) && Object.keys(delay).length) { return delay; } - - var globalDelay = (typeof delay === 'object' && 'global' in delay) ? delay.global : delay || 0; - var localDelay = (typeof delay === 'object' && 'local' in delay) ? delay.local : {}; - - events.forEach(function (e) { - delayObject[e] = (typeof globalDelay === 'object') ? localDelay[e] || globalDelay[e] || 0 : localDelay[e] || globalDelay; - }); - - return delayObject; -}; - -var deepParseInt = function (input) { - if (typeof input === 'number') { return input; } - - if (typeof input === 'string') { return parseInt(input); } - - var map = {}; - for (var element in input) { - map[element] = parseInt(input[element]); - } - - return map; -}; - -var ip = function (value, ref) { - if ( ref === void 0 ) ref = []; - var version = ref[0]; if ( version === void 0 ) version = 4; - - if (isNullOrUndefined(value)) { - value = ''; - } - - if (Array.isArray(value)) { - return value.every(function (val) { return isIP(val, version); }); - } - - return isIP(value, version); -}; - -/** - * @param {Array|String} value - * @param {Number} length - * @param {Number} max - */ -var compare = function (value, length, max) { - if (max === undefined) { - return value.length === length; - } - - // cast to number. - max = Number(max); - - return value.length >= length && value.length <= max; -}; - -var length = function (value, ref) { - var length = ref[0]; - var max = ref[1]; if ( max === void 0 ) max = undefined; - - length = Number(length); - if (value === undefined || value === null) { - return false; - } - - if (typeof value === 'number') { - value = String(value); - } - - if (!value.length) { - value = toArray(value); - } - - return compare(value, length, max); -}; - -var integer = function (value) { - if (Array.isArray(value)) { - return value.every(function (val) { return /^-?[0-9]+$/.test(String(val)); }); - } - - return /^-?[0-9]+$/.test(String(value)); -}; - -var max$1 = function (value, ref) { - var length = ref[0]; - - if (value === undefined || value === null) { - return length >= 0; - } - - return String(value).length <= length; -}; - -var max_value = function (value, ref) { - var max = ref[0]; - - if (Array.isArray(value) || value === null || value === undefined || value === '') { - return false; - } - - return Number(value) <= max; -}; - -var mimes = function (files, mimes) { - var regex = new RegExp(((mimes.join('|').replace('*', '.+')) + "$"), 'i'); - - return files.every(function (file) { return regex.test(file.type); }); -}; - -var min$1 = function (value, ref) { - var length = ref[0]; - - if (value === undefined || value === null) { - return false; - } - return String(value).length >= length; -}; - -var min_value = function (value, ref) { - var min = ref[0]; - - if (Array.isArray(value) || value === null || value === undefined || value === '') { - return false; - } - - return Number(value) >= min; -}; - -var validate$9 = function (value, options) { - if (Array.isArray(value)) { - return value.every(function (val) { return validate$9(val, options); }); - } - - // eslint-disable-next-line - return ! options.filter(function (option) { return option == value; }).length; -}; - -var numeric = function (value) { - if (Array.isArray(value)) { - return value.every(function (val) { return /^[0-9]+$/.test(String(val)); }); - } - - return /^[0-9]+$/.test(String(value)); -}; - -var regex = function (value, ref) { - var regex = ref[0]; - var flags = ref.slice(1); - - if (regex instanceof RegExp) { - return regex.test(value); - } - - return new RegExp(regex, flags).test(String(value)); -}; - -var required = function (value, ref) { - if ( ref === void 0 ) ref = []; - var invalidateFalse = ref[0]; if ( invalidateFalse === void 0 ) invalidateFalse = false; - - if (Array.isArray(value)) { - return !! value.length; - } - - // incase a field considers `false` as an empty value like checkboxes. - if (value === false && invalidateFalse) { - return false; - } - - if (value === undefined || value === null) { - return false; - } - - return !! String(value).trim().length; -}; - -var size = function (files, ref) { - var size = ref[0]; - - if (isNaN(size)) { - return false; - } - - var nSize = Number(size) * 1024; - for (var i = 0; i < files.length; i++) { - if (files[i].size > nSize) { - return false; - } - } - - return true; -}; - -var isURL_1 = createCommonjsModule(function (module, exports) { -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = isURL; - - - -var _assertString2 = _interopRequireDefault(assertString_1); - - - -var _isFQDN2 = _interopRequireDefault(isFQDN); - - - -var _isIP2 = _interopRequireDefault(isIP_1); - - - -var _merge2 = _interopRequireDefault(merge_1); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var default_url_options = { - protocols: ['http', 'https', 'ftp'], - require_tld: true, - require_protocol: false, - require_host: true, - require_valid_protocol: true, - allow_underscores: false, - allow_trailing_dot: false, - allow_protocol_relative_urls: false -}; - -var wrapped_ipv6 = /^\[([^\]]+)\](?::([0-9]+))?$/; - -function isRegExp(obj) { - return Object.prototype.toString.call(obj) === '[object RegExp]'; -} - -function checkHost(host, matches) { - for (var i = 0; i < matches.length; i++) { - var match = matches[i]; - if (host === match || isRegExp(match) && match.test(host)) { - return true; - } - } - return false; -} - -function isURL(url, options) { - (0, _assertString2.default)(url); - if (!url || url.length >= 2083 || /[\s<>]/.test(url)) { - return false; - } - if (url.indexOf('mailto:') === 0) { - return false; - } - options = (0, _merge2.default)(options, default_url_options); - var protocol = void 0, - auth = void 0, - host = void 0, - hostname = void 0, - port = void 0, - port_str = void 0, - split = void 0, - ipv6 = void 0; - - split = url.split('#'); - url = split.shift(); - - split = url.split('?'); - url = split.shift(); - - split = url.split('://'); - if (split.length > 1) { - protocol = split.shift(); - if (options.require_valid_protocol && options.protocols.indexOf(protocol) === -1) { - return false; - } - } else if (options.require_protocol) { - return false; - } else if (options.allow_protocol_relative_urls && url.substr(0, 2) === '//') { - split[0] = url.substr(2); - } - url = split.join('://'); - - if (url === '') { - return false; - } - - split = url.split('/'); - url = split.shift(); - - if (url === '' && !options.require_host) { - return true; - } - - split = url.split('@'); - if (split.length > 1) { - auth = split.shift(); - if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) { - return false; - } - } - hostname = split.join('@'); - - port_str = null; - ipv6 = null; - var ipv6_match = hostname.match(wrapped_ipv6); - if (ipv6_match) { - host = ''; - ipv6 = ipv6_match[1]; - port_str = ipv6_match[2] || null; - } else { - split = hostname.split(':'); - host = split.shift(); - if (split.length) { - port_str = split.join(':'); - } - } - - if (port_str !== null) { - port = parseInt(port_str, 10); - if (!/^[0-9]+$/.test(port_str) || port <= 0 || port > 65535) { - return false; - } - } - - if (!(0, _isIP2.default)(host) && !(0, _isFQDN2.default)(host, options) && (!ipv6 || !(0, _isIP2.default)(ipv6, 6))) { - return false; - } - - host = host || ipv6; - - if (options.host_whitelist && !checkHost(host, options.host_whitelist)) { - return false; - } - if (options.host_blacklist && checkHost(host, options.host_blacklist)) { - return false; - } - - return true; -} -module.exports = exports['default']; -}); - -var isURL = unwrapExports(isURL_1); - -var url = function (value, ref) { - if ( ref === void 0 ) ref = []; - var requireProtocol = ref[0]; if ( requireProtocol === void 0 ) requireProtocol = false; - - var options = { require_protocol: !!requireProtocol, allow_underscores: true }; - if (isNullOrUndefined(value)) { - value = ''; - } - - if (Array.isArray(value)) { - return value.every(function (val) { return isURL(val, options); }); - } - - return isURL(value, options); -}; - -/* eslint-disable camelcase */ -var Rules = { - after: after, - alpha_dash: validate$1, - alpha_num: validate$2, - alpha_spaces: validate$3, - alpha: validate, - before: before, - between: validate$4, - confirmed: confirmed, - credit_card: credit_card, - date_between: date_between, - date_format: date_format, - decimal: validate$5, - digits: validate$6, - dimensions: dimensions, - email: validate$7, - ext: ext, - image: image, - in: validate$8, - integer: integer, - length: length, - ip: ip, - max: max$1, - max_value: max_value, - mimes: mimes, - min: min$1, - min_value: min_value, - not_in: validate$9, - numeric: numeric, - regex: regex, - required: required, - size: size, - url: url -}; - -/** - * Formates file size. - * - * @param {Number|String} size - */ -var formatFileSize = function (size) { - var units = ['Byte', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; - var threshold = 1024; - size = Number(size) * threshold; - var i = size === 0 ? 0 : Math.floor(Math.log(size) / Math.log(threshold)); - return (((size / Math.pow(threshold, i)).toFixed(2) * 1) + " " + (units[i])); -}; - -/** - * Checks if vee-validate is defined globally. - */ -var isDefinedGlobally = function () { - return typeof VeeValidate !== 'undefined'; -}; - -var messages = { - _default: function (field) { return ("The " + field + " value is not valid."); }, - after: function (field, ref) { - var target = ref[0]; - var inclusion = ref[1]; - - return ("The " + field + " must be after " + (inclusion ? 'or equal to ' : '') + target + "."); -}, - alpha_dash: function (field) { return ("The " + field + " field may contain alpha-numeric characters as well as dashes and underscores."); }, - alpha_num: function (field) { return ("The " + field + " field may only contain alpha-numeric characters."); }, - alpha_spaces: function (field) { return ("The " + field + " field may only contain alphabetic characters as well as spaces."); }, - alpha: function (field) { return ("The " + field + " field may only contain alphabetic characters."); }, - before: function (field, ref) { - var target = ref[0]; - var inclusion = ref[1]; - - return ("The " + field + " must be before " + (inclusion ? 'or equal to ' : '') + target + "."); -}, - between: function (field, ref) { - var min = ref[0]; - var max = ref[1]; - - return ("The " + field + " field must be between " + min + " and " + max + "."); -}, - confirmed: function (field) { return ("The " + field + " confirmation does not match."); }, - credit_card: function (field) { return ("The " + field + " field is invalid."); }, - date_between: function (field, ref) { - var min = ref[0]; - var max = ref[1]; - - return ("The " + field + " must be between " + min + " and " + max + "."); -}, - date_format: function (field, ref) { - var format = ref[0]; - - return ("The " + field + " must be in the format " + format + "."); -}, - decimal: function (field, ref) { - if ( ref === void 0 ) ref = []; - var decimals = ref[0]; if ( decimals === void 0 ) decimals = '*'; - - return ("The " + field + " field must be numeric and may contain " + (!decimals || decimals === '*' ? '' : decimals) + " decimal points."); -}, - digits: function (field, ref) { - var length = ref[0]; - - return ("The " + field + " field must be numeric and exactly contain " + length + " digits."); -}, - dimensions: function (field, ref) { - var width = ref[0]; - var height = ref[1]; - - return ("The " + field + " field must be " + width + " pixels by " + height + " pixels."); -}, - email: function (field) { return ("The " + field + " field must be a valid email."); }, - ext: function (field) { return ("The " + field + " field must be a valid file."); }, - image: function (field) { return ("The " + field + " field must be an image."); }, - in: function (field) { return ("The " + field + " field must be a valid value."); }, - integer: function (field) { return ("The " + field + " field must be an integer."); }, - ip: function (field) { return ("The " + field + " field must be a valid ip address."); }, - length: function (field, ref) { - var length = ref[0]; - var max = ref[1]; - - if (max) { - return ("The " + field + " length be between " + length + " and " + max + "."); - } - - return ("The " + field + " length must be " + length + "."); - }, - max: function (field, ref) { - var length = ref[0]; - - return ("The " + field + " field may not be greater than " + length + " characters."); -}, - max_value: function (field, ref) { - var max = ref[0]; - - return ("The " + field + " field must be " + max + " or less."); -}, - mimes: function (field) { return ("The " + field + " field must have a valid file type."); }, - min: function (field, ref) { - var length = ref[0]; - - return ("The " + field + " field must be at least " + length + " characters."); -}, - min_value: function (field, ref) { - var min = ref[0]; - - return ("The " + field + " field must be " + min + " or more."); -}, - not_in: function (field) { return ("The " + field + " field must be a valid value."); }, - numeric: function (field) { return ("The " + field + " field may only contain numeric characters."); }, - regex: function (field) { return ("The " + field + " field format is invalid."); }, - required: function (field) { return ("The " + field + " field is required."); }, - size: function (field, ref) { - var size = ref[0]; - - return ("The " + field + " size must be less than " + (formatFileSize(size)) + "."); -}, - url: function (field) { return ("The " + field + " field is not a valid URL."); } -}; - -var locale$1 = { - name: 'en', - messages: messages, - attributes: {} -}; - -if (isDefinedGlobally()) { - // eslint-disable-next-line - VeeValidate.Validator.addLocale(locale$1); -} - -// - -var ErrorBag = function ErrorBag () { - this.items = []; -}; - -/** - * Adds an error to the internal array. - */ -ErrorBag.prototype.add = function add (error) { - // handle old signature. - if (arguments.length > 1) { - error = { - field: arguments[0], - msg: arguments[1], - rule: arguments[2], - scope: !isNullOrUndefined(arguments[3]) ? arguments[3] : null - }; - } - - error.scope = !isNullOrUndefined(error.scope) ? error.scope : null; - this.items.push(error); -}; - -/** - * Updates a field error with the new field scope. - */ -ErrorBag.prototype.update = function update (id, error) { - var item = find(this.items, function (i) { return i.id === id; }); - if (!item) { - return; - } - - var idx = this.items.indexOf(item); - this.items.splice(idx, 1); - item.scope = error.scope; - this.items.push(item); -}; - -/** - * Gets all error messages from the internal array. - */ -ErrorBag.prototype.all = function all (scope) { - if (isNullOrUndefined(scope)) { - return this.items.map(function (e) { return e.msg; }); - } - - return this.items.filter(function (e) { return e.scope === scope; }).map(function (e) { return e.msg; }); -}; - -/** - * Checks if there are any errors in the internal array. - */ -ErrorBag.prototype.any = function any (scope) { - if (isNullOrUndefined(scope)) { - return !!this.items.length; - } - - return !!this.items.filter(function (e) { return e.scope === scope; }).length; -}; - -/** - * Removes all items from the internal array. - */ -ErrorBag.prototype.clear = function clear (scope) { - var this$1 = this; - - if (isNullOrUndefined(scope)) { - scope = null; - } - - for (var i = 0; i < this.items.length; ++i) { - if (this$1.items[i].scope === scope) { - this$1.items.splice(i, 1); - --i; - } - } -}; - -/** - * Collects errors into groups or for a specific field. - */ -ErrorBag.prototype.collect = function collect (field, scope, map) { - if ( map === void 0 ) map = true; - - if (!field) { - var collection = {}; - this.items.forEach(function (e) { - if (! collection[e.field]) { - collection[e.field] = []; - } - - collection[e.field].push(map ? e.msg : e); - }); - - return collection; - } - - field = !isNullOrUndefined(field) ? String(field) : field; - if (isNullOrUndefined(scope)) { - return this.items.filter(function (e) { return e.field === field; }).map(function (e) { return (map ? e.msg : e); }); - } - - return this.items.filter(function (e) { return e.field === field && e.scope === scope; }) - .map(function (e) { return (map ? e.msg : e); }); -}; -/** - * Gets the internal array length. - */ -ErrorBag.prototype.count = function count () { - return this.items.length; -}; - -/** - * Finds and fetches the first error message for the specified field id. - */ -ErrorBag.prototype.firstById = function firstById (id) { - var error = find(this.items, function (i) { return i.id === id; }); - - return error ? error.msg : null; -}; - -/** - * Gets the first error message for a specific field. - */ -ErrorBag.prototype.first = function first (field, scope) { - var this$1 = this; - if ( scope === void 0 ) scope = null; - - field = !isNullOrUndefined(field) ? String(field) : field; - var selector = this._selector(field); - var scoped = this._scope(field); - - if (scoped) { - var result = this.first(scoped.name, scoped.scope); - // if such result exist, return it. otherwise it could be a field. - // with dot in its name. - if (result) { - return result; - } - } - - if (selector) { - return this.firstByRule(selector.name, selector.rule, scope); - } - - for (var i = 0; i < this.items.length; ++i) { - if (this$1.items[i].field === field && (this$1.items[i].scope === scope)) { - return this$1.items[i].msg; - } - } - - return null; -}; - -/** - * Returns the first error rule for the specified field - */ -ErrorBag.prototype.firstRule = function firstRule (field, scope) { - var errors = this.collect(field, scope, false); - - return (errors.length && errors[0].rule) || null; -}; - -/** - * Checks if the internal array has at least one error for the specified field. - */ -ErrorBag.prototype.has = function has (field, scope) { - if ( scope === void 0 ) scope = null; - - return !!this.first(field, scope); -}; - -/** - * Gets the first error message for a specific field and a rule. - */ -ErrorBag.prototype.firstByRule = function firstByRule (name, rule, scope) { - if ( scope === void 0 ) scope = null; - - var error = this.collect(name, scope, false).filter(function (e) { return e.rule === rule; })[0]; - - return (error && error.msg) || null; -}; - -/** - * Gets the first error message for a specific field that not match the rule. - */ -ErrorBag.prototype.firstNot = function firstNot (name, rule, scope) { - if ( rule === void 0 ) rule = 'required'; - if ( scope === void 0 ) scope = null; - - var error = this.collect(name, scope, false).filter(function (e) { return e.rule !== rule; })[0]; - - return (error && error.msg) || null; -}; - -/** - * Removes errors by matching against the id. - */ -ErrorBag.prototype.removeById = function removeById (id) { - var this$1 = this; - - for (var i = 0; i < this.items.length; ++i) { - if (this$1.items[i].id === id) { - this$1.items.splice(i, 1); - --i; - } - } -}; - -/** - * Removes all error messages associated with a specific field. - */ -ErrorBag.prototype.remove = function remove (field, scope, id) { - var this$1 = this; - - field = !isNullOrUndefined(field) ? String(field) : field; - var removeCondition = function (e) { - if (e.id && id) { - return e.id === id; - } - - if (!isNullOrUndefined(scope)) { - return e.field === field && e.scope === scope; - } - - return e.field === field && e.scope === null; - }; - - for (var i = 0; i < this.items.length; ++i) { - if (removeCondition(this$1.items[i])) { - this$1.items.splice(i, 1); - --i; - } - } -}; - -/** - * Get the field attributes if there's a rule selector. - */ -ErrorBag.prototype._selector = function _selector (field) { - if (field.indexOf(':') > -1) { - var ref = field.split(':'); - var name = ref[0]; - var rule = ref[1]; - - return { name: name, rule: rule }; - } - - return null; -}; - -/** - * Get the field scope if specified using dot notation. - */ -ErrorBag.prototype._scope = function _scope (field) { - if (field.indexOf('.') > -1) { - var ref = field.split('.'); - var scope = ref[0]; - var name = ref.slice(1); - - return { name: name.join('.'), scope: scope }; - } - - return null; -}; - -// - -var Dictionary = function Dictionary (dictionary) { - if ( dictionary === void 0 ) dictionary = {}; - - this.container = {}; - this.merge(dictionary); -}; - -Dictionary.prototype.hasLocale = function hasLocale (locale) { - return !!this.container[locale]; -}; - -Dictionary.prototype.setDateFormat = function setDateFormat (locale, format) { - if (!this.container[locale]) { - this.container[locale] = {}; - } - - this.container[locale].dateFormat = format; -}; - -Dictionary.prototype.getDateFormat = function getDateFormat (locale) { - if (!this.container[locale]) { - return undefined; - } - - return this.container[locale].dateFormat; -}; - -Dictionary.prototype.getMessage = function getMessage (locale, key, fallback) { - if (!this.hasMessage(locale, key)) { - return fallback || this._getDefaultMessage(locale); - } - - return this.container[locale].messages[key]; -}; - -/** - * Gets a specific message for field. falls back to the rule message. - */ -Dictionary.prototype.getFieldMessage = function getFieldMessage (locale, field, key) { - if (!this.hasLocale(locale)) { - return this.getMessage(locale, key); - } - - var dict = this.container[locale].custom && this.container[locale].custom[field]; - if (!dict || !dict[key]) { - return this.getMessage(locale, key); - } - - return dict[key]; -}; - -Dictionary.prototype._getDefaultMessage = function _getDefaultMessage (locale) { - if (this.hasMessage(locale, '_default')) { - return this.container[locale].messages._default; - } - - return this.container.en.messages._default; -}; - -Dictionary.prototype.getAttribute = function getAttribute (locale, key, fallback) { - if ( fallback === void 0 ) fallback = ''; - - if (!this.hasAttribute(locale, key)) { - return fallback; - } - - return this.container[locale].attributes[key]; -}; - -Dictionary.prototype.hasMessage = function hasMessage (locale, key) { - return !! ( - this.hasLocale(locale) && - this.container[locale].messages && - this.container[locale].messages[key] - ); -}; - -Dictionary.prototype.hasAttribute = function hasAttribute (locale, key) { - return !! ( - this.hasLocale(locale) && - this.container[locale].attributes && - this.container[locale].attributes[key] - ); -}; - -Dictionary.prototype.merge = function merge (dictionary) { - this._merge(this.container, dictionary); -}; - -Dictionary.prototype.setMessage = function setMessage (locale, key, message) { - if (! this.hasLocale(locale)) { - this.container[locale] = { - messages: {}, - attributes: {} - }; - } - - this.container[locale].messages[key] = message; -}; - -Dictionary.prototype.setAttribute = function setAttribute (locale, key, attribute) { - if (! this.hasLocale(locale)) { - this.container[locale] = { - messages: {}, - attributes: {} - }; - } - - this.container[locale].attributes[key] = attribute; -}; - -Dictionary.prototype._merge = function _merge (target, source) { - var this$1 = this; - - if (! (isObject(target) && isObject(source))) { - return target; - } - - Object.keys(source).forEach(function (key) { - if (isObject(source[key])) { - if (! target[key]) { - assign(target, ( obj = {}, obj[key] = {}, obj )); - var obj; - } - - this$1._merge(target[key], source[key]); - return; - } - - assign(target, ( obj$1 = {}, obj$1[key] = source[key], obj$1 )); - var obj$1; - }); - - return target; -}; - -// - -var defaultConfig = { - locale: 'en', - delay: 0, - errorBagName: 'errors', - dictionary: null, - strict: true, - fieldsBagName: 'fields', - classes: false, - classNames: null, - events: 'input|blur', - inject: true, - fastExit: true, - aria: true, - validity: false -}; - -var currentConfig = assign({}, defaultConfig); - -var Config = function Config () {}; - -var staticAccessors$1 = { default: {},current: {} }; - -staticAccessors$1.default.get = function () { - return defaultConfig; -}; - -staticAccessors$1.current.get = function () { - return currentConfig; -}; - -/** - * Merges the config with a new one. - */ -Config.merge = function merge (config) { - currentConfig = assign({}, currentConfig, config); -}; - -/** - * Resolves the working config from a Vue instance. - */ -Config.resolve = function resolve (context) { - var selfConfig = getPath('$options.$_veeValidate', context, {}); - - return assign({}, Config.current, selfConfig); -}; - -Object.defineProperties( Config, staticAccessors$1 ); - -/** - * Generates the options required to construct a field. - */ -var Generator = function Generator () {}; - -Generator.generate = function generate (el, binding, vnode) { - var model = Generator.resolveModel(binding, vnode); - var options = Config.resolve(vnode.context); - - return { - name: Generator.resolveName(el, vnode), - el: el, - listen: !binding.modifiers.disable, - scope: Generator.resolveScope(el, binding, vnode), - vm: Generator.makeVM(vnode.context), - expression: binding.value, - component: vnode.child, - classes: options.classes, - classNames: options.classNames, - getter: Generator.resolveGetter(el, vnode, model), - events: Generator.resolveEvents(el, vnode) || options.events, - model: model, - delay: Generator.resolveDelay(el, vnode, options), - rules: Generator.resolveRules(el, binding), - initial: !!binding.modifiers.initial, - validity: options.validity, - aria: options.aria, - initialValue: Generator.resolveInitialValue(vnode) - }; -}; - -Generator.getCtorConfig = function getCtorConfig (vnode) { - if (!vnode.child) { return null; } - - var config = getPath('child.$options.$_veeValidate', vnode); - - return config; -}; - -/** - * - * @param {*} el - * @param {*} binding - */ -Generator.resolveRules = function resolveRules (el, binding) { - if (!binding || !binding.expression) { - return getDataAttribute(el, 'rules'); - } - - if (typeof binding.value === 'string') { - return binding.value; - } - - if (~['string', 'object'].indexOf(typeof binding.value.rules)) { - return binding.value.rules; - } - - return binding.value; -}; - -/** - * @param {*} vnode - */ -Generator.resolveInitialValue = function resolveInitialValue (vnode) { - var model = vnode.data.model || find(vnode.data.directives, function (d) { return d.name === 'model'; }); - - return model && model.value; -}; - -/** - * Creates a non-circular partial VM instance from a Vue instance. - * @param {*} vm - */ -Generator.makeVM = function makeVM (vm) { - return { - get $el () { - return vm.$el; - }, - get $refs () { - return vm.$refs; - }, - $watch: vm.$watch ? vm.$watch.bind(vm) : function () {}, - $validator: vm.$validator ? { - errors: vm.$validator.errors, - validate: vm.$validator.validate.bind(vm.$validator), - update: vm.$validator.update.bind(vm.$validator) - } : null - }; -}; - -/** - * Resolves the delay value. - * @param {*} el - * @param {*} vnode - * @param {Object} options - */ -Generator.resolveDelay = function resolveDelay (el, vnode, options) { - var delay = getDataAttribute(el, 'delay'); - var globalDelay = (options && 'delay' in options) ? options.delay : 0; - - if (!delay && vnode.child && vnode.child.$attrs) { - delay = vnode.child.$attrs['data-vv-delay']; - } - - return (delay) ? { local: { input: parseInt(delay) }, global: deepParseInt(globalDelay) } : { global: deepParseInt(globalDelay) }; -}; - -/** - * Resolves the events to validate in response to. - * @param {*} el - * @param {*} vnode - */ -Generator.resolveEvents = function resolveEvents (el, vnode) { - var events = getDataAttribute(el, 'validate-on'); - - if (!events && vnode.child && vnode.child.$attrs) { - events = vnode.child.$attrs['data-vv-validate-on']; - } - - if (!events && vnode.child) { - var config = Generator.getCtorConfig(vnode); - events = config && config.events; - } - - return events; -}; - -/** - * Resolves the scope for the field. - * @param {*} el - * @param {*} binding - */ -Generator.resolveScope = function resolveScope (el, binding, vnode) { - if ( vnode === void 0 ) vnode = {}; - - var scope = null; - if (isObject(binding.value)) { - scope = binding.value.scope; - } - - if (vnode.child && isNullOrUndefined(scope)) { - scope = vnode.child.$attrs && vnode.child.$attrs['data-vv-scope']; - } - - return !isNullOrUndefined(scope) ? scope : getScope(el); -}; - -/** - * Checks if the node directives contains a v-model or a specified arg. - * Args take priority over models. - * - * @return {Object} - */ -Generator.resolveModel = function resolveModel (binding, vnode) { - if (binding.arg) { - return binding.arg; - } - - if (isObject(binding.value) && binding.value.arg) { - return binding.value.arg; - } - - var model = vnode.data.model || find(vnode.data.directives, function (d) { return d.name === 'model'; }); - if (!model) { - return null; - } - - var watchable = /^[a-z_]+[0-9]*(\w*\.[a-z_]\w*)*$/i.test(model.expression) && hasPath(model.expression, vnode.context); - - if (!watchable) { - return null; - } - - return model.expression; -}; - -/** - * Resolves the field name to trigger validations. - * @return {String} The field name. - */ -Generator.resolveName = function resolveName (el, vnode) { - var name = getDataAttribute(el, 'name'); - - if (!name && !vnode.child) { - return el.name; - } - - if (!name && vnode.child && vnode.child.$attrs) { - name = vnode.child.$attrs['data-vv-name'] || vnode.child.$attrs['name']; - } - - if (!name && vnode.child) { - var config = Generator.getCtorConfig(vnode); - if (config && isCallable(config.name)) { - var boundGetter = config.name.bind(vnode.child); - - return boundGetter(); - } - - return vnode.child.name; - } - - return name; -}; - -/** - * Returns a value getter input type. - */ -Generator.resolveGetter = function resolveGetter (el, vnode, model) { - if (model) { - return function () { - return getPath(model, vnode.context); - }; - } - - if (vnode.child) { - var path = getDataAttribute(el, 'value-path') || (vnode.child.$attrs && vnode.child.$attrs['data-vv-value-path']); - if (path) { - return function () { - return getPath(path, vnode.child); - }; - } - - var config = Generator.getCtorConfig(vnode); - if (config && isCallable(config.value)) { - var boundGetter = config.value.bind(vnode.child); - - return function () { - return boundGetter(); - }; - } - - return function () { - return vnode.child.value; - }; - } - - switch (el.type) { - case 'checkbox': return function () { - var els = document.querySelectorAll(("input[name=\"" + (el.name) + "\"]")); - - els = toArray(els).filter(function (el) { return el.checked; }); - if (!els.length) { return undefined; } - - return els.map(function (checkbox) { return checkbox.value; }); - }; - case 'radio': return function () { - var els = document.querySelectorAll(("input[name=\"" + (el.name) + "\"]")); - var elm = find(els, function (el) { return el.checked; }); - - return elm && elm.value; - }; - case 'file': return function (context) { - return toArray(el.files); - }; - case 'select-multiple': return function () { - return toArray(el.options).filter(function (opt) { return opt.selected; }).map(function (opt) { return opt.value; }); - }; - default: return function () { - return el && el.value; - }; - } -}; - -// - -var DEFAULT_OPTIONS = { - targetOf: null, - initial: false, - scope: null, - listen: true, - name: null, - active: true, - required: false, - rules: {}, - vm: null, - classes: false, - validity: true, - aria: true, - events: 'input|blur', - delay: 0, - classNames: { - touched: 'touched', // the control has been blurred - untouched: 'untouched', // the control hasn't been blurred - valid: 'valid', // model is valid - invalid: 'invalid', // model is invalid - pristine: 'pristine', // control has not been interacted with - dirty: 'dirty' // control has been interacted with - } -}; - -var Field = function Field (el, options) { - if ( options === void 0 ) options = {}; - - this.id = uniqId(); - this.el = el; - this.updated = false; - this.dependencies = []; - this.watchers = []; - this.events = []; - this.delay = 0; - this.rules = {}; - if (this.el && !options.targetOf) { - setDataAttribute(this.el, 'id', this.id); // cache field id if it is independent and has a root element. - } - options = assign({}, DEFAULT_OPTIONS, options); - this.validity = options.validity; - this.aria = options.aria; - this.flags = createFlags(); - this.vm = options.vm; - this.component = options.component; - this.ctorConfig = this.component ? getPath('$options.$_veeValidate', this.component) : undefined; - this.update(options); - this.updated = false; -}; - -var prototypeAccessors$1 = { validator: {},isRequired: {},isDisabled: {},alias: {},value: {},rejectsFalse: {} }; - -prototypeAccessors$1.validator.get = function () { - if (!this.vm || !this.vm.$validator) { - warn('No validator instance detected.'); - return { validate: function () {} }; - } - - return this.vm.$validator; -}; - -prototypeAccessors$1.isRequired.get = function () { - return !!this.rules.required; -}; - -prototypeAccessors$1.isDisabled.get = function () { - return !!(this.component && this.component.disabled) || !!(this.el && this.el.disabled); -}; - -/** - * Gets the display name (user-friendly name). - */ -prototypeAccessors$1.alias.get = function () { - if (this._alias) { - return this._alias; - } - - var alias = null; - if (this.el) { - alias = getDataAttribute(this.el, 'as'); - } - - if (!alias && this.component) { - return this.component.$attrs && this.component.$attrs['data-vv-as']; - } - - return alias; -}; - -/** - * Gets the input value. - */ - -prototypeAccessors$1.value.get = function () { - if (!isCallable(this.getter)) { - return undefined; - } - - return this.getter(); -}; - -/** - * If the field rejects false as a valid value for the required rule. - */ - -prototypeAccessors$1.rejectsFalse.get = function () { - if (this.component && this.ctorConfig) { - return !!this.ctorConfig.rejectsFalse; - } - - if (!this.el) { - return false; - } - - return this.el.type === 'checkbox'; -}; - -/** - * Determines if the instance matches the options provided. - */ -Field.prototype.matches = function matches (options) { - if (options.id) { - return this.id === options.id; - } - - if (options.name === undefined && options.scope === undefined) { - return true; - } - - if (options.scope === undefined) { - return this.name === options.name; - } - - if (options.name === undefined) { - return this.scope === options.scope; - } - - return options.name === this.name && options.scope === this.scope; -}; - -/** - * Updates the field with changed data. - */ -Field.prototype.update = function update (options) { - this.targetOf = options.targetOf || null; - this.initial = options.initial || this.initial || false; - - // update errors scope if the field scope was changed. - if (!isNullOrUndefined(options.scope) && options.scope !== this.scope && isCallable(this.validator.update)) { - this.validator.update(this.id, { scope: options.scope }); - } - this.scope = !isNullOrUndefined(options.scope) ? options.scope - : !isNullOrUndefined(this.scope) ? this.scope : null; - this.name = (!isNullOrUndefined(options.name) ? String(options.name) : options.name) || this.name || null; - this.rules = options.rules !== undefined ? normalizeRules(options.rules) : this.rules; - this.model = options.model || this.model; - this.listen = options.listen !== undefined ? options.listen : this.listen; - this.classes = options.classes || this.classes || false; - this.classNames = options.classNames || this.classNames || DEFAULT_OPTIONS.classNames; - this.getter = isCallable(options.getter) ? options.getter : this.getter; - this._alias = options.alias || this._alias; - this.events = (options.events) ? makeEventsArray(options.events) : this.events; - this.delay = (options.delay) ? makeDelayObject(this.events, options.delay) : makeDelayObject(this.events, this.delay); - this.updateDependencies(); - this.addActionListeners(); - - // update required flag flags - if (options.rules !== undefined) { - this.flags.required = this.isRequired; - } - - // validate if it was validated before and field was updated and there was a rules mutation. - if (this.flags.validated && options.rules !== undefined && this.updated) { - this.validator.validate(("#" + (this.id))); - } - - this.updated = true; - - // no need to continue. - if (!this.el) { - return; - } - - this.updateClasses(); - this.addValueListeners(); - this.updateAriaAttrs(); -}; - -/** - * Resets field flags and errors. - */ -Field.prototype.reset = function reset () { - var this$1 = this; - - var def = createFlags(); - Object.keys(this.flags).forEach(function (flag) { - this$1.flags[flag] = def[flag]; - }); - - this.addActionListeners(); - this.updateClasses(); - this.updateAriaAttrs(); - this.updateCustomValidity(); -}; - -/** - * Sets the flags and their negated counterparts, and updates the classes and re-adds action listeners. - */ -Field.prototype.setFlags = function setFlags (flags) { - var this$1 = this; - - var negated = { - pristine: 'dirty', - dirty: 'pristine', - valid: 'invalid', - invalid: 'valid', - touched: 'untouched', - untouched: 'touched' - }; - - Object.keys(flags).forEach(function (flag) { - this$1.flags[flag] = flags[flag]; - // if it has a negation and was not specified, set it as well. - if (negated[flag] && flags[negated[flag]] === undefined) { - this$1.flags[negated[flag]] = !flags[flag]; - } - }); - - if ( - flags.untouched !== undefined || - flags.touched !== undefined || - flags.dirty !== undefined || - flags.pristine !== undefined - ) { - this.addActionListeners(); - } - this.updateClasses(); - this.updateAriaAttrs(); - this.updateCustomValidity(); -}; - -/** - * Determines if the field requires references to target fields. -*/ -Field.prototype.updateDependencies = function updateDependencies () { - var this$1 = this; - - // reset dependencies. - this.dependencies.forEach(function (d) { return d.field.destroy(); }); - this.dependencies = []; - - // we get the selectors for each field. - var fields = Object.keys(this.rules).reduce(function (prev, r) { - if (r === 'confirmed') { - prev.push({ selector: this$1.rules[r][0] || ((this$1.name) + "_confirmation"), name: r }); - } else if (/after|before/.test(r)) { - prev.push({ selector: this$1.rules[r][0], name: r }); - } - - return prev; - }, []); - - if (!fields.length || !this.vm || !this.vm.$el) { return; } - - // must be contained within the same component, so we use the vm root element constrain our dom search. - fields.forEach(function (ref) { - var selector = ref.selector; - var name = ref.name; - - var el = null; - // vue ref selector. - if (selector[0] === '$') { - el = this$1.vm.$refs[selector.slice(1)]; - } else { - try { - // try query selector - el = this$1.vm.$el.querySelector(selector); - } catch (err) { - el = null; - } - } - - if (!el) { - try { - el = this$1.vm.$el.querySelector(("input[name=\"" + selector + "\"]")); - } catch (err) { - el = null; - } - } - - if (!el) { - return; - } - - var options = { - vm: this$1.vm, - classes: this$1.classes, - classNames: this$1.classNames, - delay: this$1.delay, - scope: this$1.scope, - events: this$1.events.join('|'), - initial: this$1.initial, - targetOf: this$1.id - }; - - // probably a component. - if (isCallable(el.$watch)) { - options.component = el; - options.el = el.$el; - options.getter = Generator.resolveGetter(el.$el, { child: el }); - } else { - options.el = el; - options.getter = Generator.resolveGetter(el, {}); - } - - this$1.dependencies.push({ name: name, field: new Field(options.el, options) }); - }); -}; - -/** - * Removes listeners. - */ -Field.prototype.unwatch = function unwatch (tag) { - if ( tag === void 0 ) tag = null; - - if (!tag) { - this.watchers.forEach(function (w) { return w.unwatch(); }); - this.watchers = []; - return; - } - - this.watchers.filter(function (w) { return tag.test(w.tag); }).forEach(function (w) { return w.unwatch(); }); - this.watchers = this.watchers.filter(function (w) { return !tag.test(w.tag); }); -}; - -/** - * Updates the element classes depending on each field flag status. - */ -Field.prototype.updateClasses = function updateClasses () { - if (!this.classes) { return; } - - toggleClass(this.el, this.classNames.dirty, this.flags.dirty); - toggleClass(this.el, this.classNames.pristine, this.flags.pristine); - toggleClass(this.el, this.classNames.valid, !!this.flags.valid); - toggleClass(this.el, this.classNames.invalid, !!this.flags.invalid); - toggleClass(this.el, this.classNames.touched, this.flags.touched); - toggleClass(this.el, this.classNames.untouched, this.flags.untouched); -}; - -/** - * Adds the listeners required for automatic classes and some flags. - */ -Field.prototype.addActionListeners = function addActionListeners () { - var this$1 = this; - - // remove previous listeners. - this.unwatch(/class/); - - var onBlur = function () { - this$1.flags.touched = true; - this$1.flags.untouched = false; - if (this$1.classes) { - toggleClass(this$1.el, this$1.classNames.touched, true); - toggleClass(this$1.el, this$1.classNames.untouched, false); - } - - // only needed once. - this$1.unwatch(/^class_blur$/); - }; - - var inputEvent = getInputEventName(this.el); - var onInput = function () { - this$1.flags.dirty = true; - this$1.flags.pristine = false; - if (this$1.classes) { - toggleClass(this$1.el, this$1.classNames.pristine, false); - toggleClass(this$1.el, this$1.classNames.dirty, true); - } - - // only needed once. - this$1.unwatch(/^class_input$/); - }; - - if (this.component && isCallable(this.component.$once)) { - this.component.$once('input', onInput); - this.component.$once('blur', onBlur); - this.watchers.push({ - tag: 'class_input', - unwatch: function () { - this$1.component.$off('input', onInput); - } - }); - this.watchers.push({ - tag: 'class_blur', - unwatch: function () { - this$1.component.$off('blur', onBlur); - } - }); - return; - } - - if (!this.el) { return; } - - this.el.addEventListener(inputEvent, onInput); - // Checkboxes and radio buttons on Mac don't emit blur naturally, so we listen on click instead. - var blurEvent = ['radio', 'checkbox'].indexOf(this.el.type) === -1 ? 'blur' : 'click'; - this.el.addEventListener(blurEvent, onBlur); - this.watchers.push({ - tag: 'class_input', - unwatch: function () { - this$1.el.removeEventListener(inputEvent, onInput); - } - }); - - this.watchers.push({ - tag: 'class_blur', - unwatch: function () { - this$1.el.removeEventListener(blurEvent, onBlur); - } - }); -}; - -/** - * Adds the listeners required for validation. - */ -Field.prototype.addValueListeners = function addValueListeners () { - var this$1 = this; - - this.unwatch(/^input_.+/); - if (!this.listen) { return; } - - var fn = this.targetOf ? function () { - this$1.validator.validate(("#" + (this$1.targetOf))); - } : function () { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - // if its a DOM event, resolve the value, otherwise use the first parameter as the value. - if (args.length === 0 || (isCallable(Event) && args[0] instanceof Event) || (args[0] && args[0].srcElement)) { - args[0] = this$1.value; - } - this$1.validator.validate(("#" + (this$1.id)), args[0]); - }; - - var inputEvent = getInputEventName(this.el); - // replace input event with suitable one. - var events = this.events.map(function (e) { - return e === 'input' ? inputEvent : e; - }); - - // if there is a watchable model and an on input validation is requested. - if (this.model && events.indexOf(inputEvent) !== -1) { - var debouncedFn = debounce(fn, this.delay[inputEvent]); - var unwatch = this.vm.$watch(this.model, function () { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - this$1.flags.pending = true; - debouncedFn.apply(void 0, args); - }); - this.watchers.push({ - tag: 'input_model', - unwatch: unwatch - }); - // filter out input event as it is already handled by the watcher API. - events = events.filter(function (e) { return e !== inputEvent; }); - } - - // Add events. - events.forEach(function (e) { - var debouncedFn = debounce(fn, this$1.delay[e]); - var validate = function () { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - this$1.flags.pending = true; - debouncedFn.apply(void 0, args); - }; - - if (this$1.component) { - this$1.component.$on(e, validate); - this$1.watchers.push({ - tag: 'input_vue', - unwatch: function () { - this$1.component.$off(e, validate); - } - }); - return; - } - - if (~['radio', 'checkbox'].indexOf(this$1.el.type)) { - var els = document.querySelectorAll(("input[name=\"" + (this$1.el.name) + "\"]")); - toArray(els).forEach(function (el) { - el.addEventListener(e, validate); - this$1.watchers.push({ - tag: 'input_native', - unwatch: function () { - el.removeEventListener(e, validate); - } - }); - }); - - return; - } - - this$1.el.addEventListener(e, validate); - this$1.watchers.push({ - tag: 'input_native', - unwatch: function () { - this$1.el.removeEventListener(e, validate); - } - }); - }); -}; - -/** - * Updates aria attributes on the element. - */ -Field.prototype.updateAriaAttrs = function updateAriaAttrs () { - if (!this.aria || !this.el || !isCallable(this.el.setAttribute)) { return; } - - this.el.setAttribute('aria-required', this.isRequired ? 'true' : 'false'); - this.el.setAttribute('aria-invalid', this.flags.invalid ? 'true' : 'false'); -}; - -/** - * Updates the custom validity for the field. - */ -Field.prototype.updateCustomValidity = function updateCustomValidity () { - if (!this.validity || !this.el || !isCallable(this.el.setCustomValidity)) { return; } - - this.el.setCustomValidity(this.flags.valid ? '' : (this.validator.errors.firstById(this.id) || '')); -}; - -/** - * Removes all listeners. - */ -Field.prototype.destroy = function destroy () { - this.watchers.forEach(function (w) { return w.unwatch(); }); - this.watchers = []; - this.dependencies.forEach(function (d) { return d.field.destroy(); }); - this.dependencies = []; -}; - -Object.defineProperties( Field.prototype, prototypeAccessors$1 ); - -// - -var FieldBag = function FieldBag () { - this.items = []; -}; - -var prototypeAccessors$2 = { length: {} }; - -/** - * Gets the current items length. - */ - -prototypeAccessors$2.length.get = function () { - return this.items.length; -}; - -/** - * Finds the first field that matches the provided matcher object. - */ -FieldBag.prototype.find = function find$1 (matcher) { - return find(this.items, function (item) { return item.matches(matcher); }); -}; - -/** - * Filters the items down to the matched fields. - */ -FieldBag.prototype.filter = function filter (matcher) { - // multiple matchers to be tried. - if (Array.isArray(matcher)) { - return this.items.filter(function (item) { return matcher.some(function (m) { return item.matches(m); }); }); - } - - return this.items.filter(function (item) { return item.matches(matcher); }); -}; - -/** - * Maps the field items using the mapping function. - */ -FieldBag.prototype.map = function map (mapper) { - return this.items.map(mapper); -}; - -/** - * Finds and removes the first field that matches the provided matcher object, returns the removed item. - */ -FieldBag.prototype.remove = function remove (matcher) { - var item = null; - if (matcher instanceof Field) { - item = matcher; - } else { - item = this.find(matcher); - } - - if (!item) { return null; } - - var index = this.items.indexOf(item); - this.items.splice(index, 1); - - return item; -}; - -/** - * Adds a field item to the list. - */ -FieldBag.prototype.push = function push (item) { - if (! (item instanceof Field)) { - throw createError('FieldBag only accepts instances of Field that has an id defined.'); - } - - if (!item.id) { - throw createError('Field id must be defined.'); - } - - if (this.find({ id: item.id })) { - throw createError(("Field with id " + (item.id) + " is already added.")); - } - - this.items.push(item); -}; - -Object.defineProperties( FieldBag.prototype, prototypeAccessors$2 ); - -// - -var RULES = {}; -var LOCALE = 'en'; -var STRICT_MODE = true; -var DICTIONARY = new Dictionary({ - en: { - messages: {}, - attributes: {}, - custom: {} - } -}); - -var Validator = function Validator (validations, options) { - var this$1 = this; - if ( options === void 0 ) options = { vm: null, fastExit: true }; - - this.strict = STRICT_MODE; - this.errors = new ErrorBag(); - this.fields = new FieldBag(); - this.flags = {}; - this._createFields(validations); - this.paused = false; - this.fastExit = options.fastExit || false; - this.ownerId = options.vm && options.vm._uid; - // create it statically since we don't need constant access to the vm. - this.reset = options.vm && isCallable(options.vm.$nextTick) ? function () { - return new Promise(function (resolve, reject) { - options.vm.$nextTick(function () { - this$1.fields.items.forEach(function (i) { return i.reset(); }); - this$1.errors.clear(); - resolve(); - }); - }); - } : function () { - return new Promise(function (resolve, reject) { - this$1.fields.items.forEach(function (i) { return i.reset(); }); - this$1.errors.clear(); - resolve(); - }); - }; - /* istanbul ignore next */ - this.clean = function () { - warn('validator.clean is marked for deprecation, please use validator.reset instead.'); - this$1.reset(); - }; -}; - -var prototypeAccessors = { dictionary: {},locale: {},rules: {} }; -var staticAccessors = { dictionary: {},locale: {},rules: {} }; - -/** - * Getter for the dictionary. - */ -prototypeAccessors.dictionary.get = function () { - return DICTIONARY; -}; - -/** - * Static Getter for the dictionary. - */ -staticAccessors.dictionary.get = function () { - return DICTIONARY; -}; - -/** - * Getter for the current locale. - */ -prototypeAccessors.locale.get = function () { - return LOCALE; -}; - -/** - * Setter for the validator locale. - */ -prototypeAccessors.locale.set = function (value) { - Validator.locale = value; -}; - -/** -* Static getter for the validator locale. -*/ -staticAccessors.locale.get = function () { - return LOCALE; -}; - -/** - * Static setter for the validator locale. - */ -staticAccessors.locale.set = function (value) { - /* istanbul ignore if */ - if (!DICTIONARY.hasLocale(value)) { - // eslint-disable-next-line - warn('You are setting the validator locale to a locale that is not defined in the dictionary. English messages may still be generated.'); - } - - LOCALE = value; -}; - -/** - * Getter for the rules object. - */ -prototypeAccessors.rules.get = function () { - return RULES; -}; - -/** - * Static Getter for the rules object. - */ -staticAccessors.rules.get = function () { - return RULES; -}; - -/** - * Static constructor. - */ -Validator.create = function create (validations, options) { - return new Validator(validations, options); -}; - -/** - * Adds a custom validator to the list of validation rules. - */ -Validator.extend = function extend (name, validator) { - Validator._guardExtend(name, validator); - Validator._merge(name, validator); -}; - -/** - * Removes a rule from the list of validators. - */ -Validator.remove = function remove (name) { - delete RULES[name]; -}; - -/** - * Sets the default locale for all validators. - * @deprecated - */ -Validator.setLocale = function setLocale (language) { - if ( language === void 0 ) language = 'en'; - - Validator.locale = language; -}; - -/** - * @deprecated - */ -Validator.installDateTimeValidators = function installDateTimeValidators () { - /* istanbul ignore next */ - warn('Date validations are now installed by default, you no longer need to install it.'); -}; - -/** - * @deprecated - */ -Validator.prototype.installDateTimeValidators = function installDateTimeValidators () { - /* istanbul ignore next */ - warn('Date validations are now installed by default, you no longer need to install it.'); -}; - -/** - * Sets the operating mode for all newly created validators. - * strictMode = true: Values without a rule are invalid and cause failure. - * strictMode = false: Values without a rule are valid and are skipped. - */ -Validator.setStrictMode = function setStrictMode (strictMode) { - if ( strictMode === void 0 ) strictMode = true; - - STRICT_MODE = strictMode; -}; - -/** - * Updates the dictionary, overwriting existing values and adding new ones. - * @deprecated - */ -Validator.updateDictionary = function updateDictionary (data) { - DICTIONARY.merge(data); -}; - -/** - * Adds a locale object to the dictionary. - * @deprecated - */ -Validator.addLocale = function addLocale (locale) { - if (! locale.name) { - warn('Your locale must have a name property'); - return; - } - - this.updateDictionary(( obj = {}, obj[locale.name] = locale, obj )); - var obj; -}; - -/** - * Adds a locale object to the dictionary. - * @deprecated - * @param {Object} locale - */ -Validator.prototype.addLocale = function addLocale (locale) { - Validator.addLocale(locale); -}; - -/** - * Adds and sets the current locale for the validator. - */ -Validator.prototype.localize = function localize (lang, dictionary) { - Validator.localize(lang, dictionary); -}; - -/** - * Adds and sets the current locale for the validator. - */ -Validator.localize = function localize (lang, dictionary) { - // merge the dictionary. - if (dictionary) { - dictionary = assign({}, dictionary, { name: lang }); - Validator.addLocale(dictionary); - } - - // set the locale. - Validator.locale = lang; -}; - -/** - * Registers a field to be validated. - */ -Validator.prototype.attach = function attach (field) { - // deprecate: handle old signature. - if (arguments.length > 1) { - field = assign({}, { - name: arguments[0], - rules: arguments[1] - }, arguments[2] || { vm: { $validator: this } }); - } - - // fixes initial value detection with v-model and select elements. - var value = field.initialValue; - if (!(field instanceof Field)) { - field = new Field(field.el || null, field); - } - - this.fields.push(field); - - // validate the field initially - if (field.initial) { - this.validate(("#" + (field.id)), value || field.value); - } else { - this._validate(field, value || field.value, true).then(function (result) { - field.flags.valid = result.valid; - field.flags.invalid = !result.valid; - }); - } - - this._addFlag(field, field.scope); - return field; -}; - -/** - * Sets the flags on a field. - */ -Validator.prototype.flag = function flag (name, flags) { - var field = this._resolveField(name); - if (! field || !flags) { - return; - } - - field.setFlags(flags); -}; - -/** - * Removes a field from the validator. - */ -Validator.prototype.detach = function detach (name, scope) { - var field = name instanceof Field ? name : this._resolveField(name, scope); - if (!field) { return; } - - field.destroy(); - this.errors.remove(field.name, field.scope, field.id); - this.fields.remove(field); - var flags = this.flags; - if (!isNullOrUndefined(field.scope) && flags[("$" + (field.scope))]) { - delete flags[("$" + (field.scope))][field.name]; - } else if (isNullOrUndefined(field.scope)) { - delete flags[field.name]; - } - - this.flags = assign({}, flags); -}; - -/** - * Adds a custom validator to the list of validation rules. - */ -Validator.prototype.extend = function extend (name, validator) { - Validator.extend(name, validator); -}; - -/** - * Updates a field, updating both errors and flags. - */ -Validator.prototype.update = function update (id, ref) { - var scope = ref.scope; - - var field = this._resolveField(("#" + id)); - if (!field) { return; } - - // remove old scope. - this.errors.update(id, { scope: scope }); - if (!isNullOrUndefined(field.scope) && this.flags[("$" + (field.scope))]) { - delete this.flags[("$" + (field.scope))][field.name]; - } else if (isNullOrUndefined(field.scope)) { - delete this.flags[field.name]; - } - - this._addFlag(field, scope); -}; - -/** - * Removes a rule from the list of validators. - */ -Validator.prototype.remove = function remove (name) { - Validator.remove(name); -}; - -/** - * Sets the validator current language. - * @deprecated - */ -Validator.prototype.setLocale = function setLocale (language) { - this.locale = language; -}; - -/** - * Updates the messages dictionary, overwriting existing values and adding new ones. - * @deprecated - */ -Validator.prototype.updateDictionary = function updateDictionary (data) { - Validator.updateDictionary(data); -}; - -/** - * Validates a value against a registered field validations. - */ -Validator.prototype.validate = function validate (name, value, scope) { - var this$1 = this; - if ( scope === void 0 ) scope = null; - - if (this.paused) { return Promise.resolve(true); } - - // overload to validate all. - if (arguments.length === 0) { - return this.validateScopes(); - } - - // overload to validate scope-less fields. - if (arguments.length === 1 && arguments[0] === '*') { - return this.validateAll(); - } - - // overload to validate a scope. - if (arguments.length === 1 && typeof arguments[0] === 'string' && /^(.+)\.\*$/.test(arguments[0])) { - var matched = arguments[0].match(/^(.+)\.\*$/)[1]; - return this.validateAll(matched); - } - - var field = this._resolveField(name, scope); - if (!field) { - return this._handleFieldNotFound(name, scope); - } - - field.flags.pending = true; - if (arguments.length === 1) { - value = field.value; - } - - var silentRun = field.isDisabled; - - return this._validate(field, value, silentRun).then(function (result) { - field.setFlags({ - pending: false, - valid: result.valid, - validated: true - }); - - this$1.errors.remove(field.name, field.scope, field.id); - if (silentRun) { - return Promise.resolve(true); - } else if (result.errors) { - result.errors.forEach(function (e) { return this$1.errors.add(e); }); - } - - return result.valid; - }); -}; - -/** - * Pauses the validator. - */ -Validator.prototype.pause = function pause () { - this.paused = true; - - return this; -}; - -/** - * Resumes the validator. - */ -Validator.prototype.resume = function resume () { - this.paused = false; - - return this; -}; - -/** - * Validates each value against the corresponding field validations. - */ -Validator.prototype.validateAll = function validateAll (values) { - var arguments$1 = arguments; - var this$1 = this; - - if (this.paused) { return Promise.resolve(true); } - - var matcher = null; - var providedValues = false; - - if (typeof values === 'string') { - matcher = { scope: values }; - } else if (isObject(values)) { - matcher = Object.keys(values).map(function (key) { - return { name: key, scope: arguments$1[1] || null }; - }); - providedValues = true; - } else if (arguments.length === 0) { - matcher = { scope: null }; // global scope. - } else if (Array.isArray(values)) { - matcher = values.map(function (key) { - return { name: key, scope: arguments$1[1] || null }; - }); - } - - var promises = this.fields.filter(matcher).map(function (field) { return this$1.validate( - ("#" + (field.id)), - providedValues ? values[field.name] : field.value - ); }); - - return Promise.all(promises).then(function (results) { return results.every(function (t) { return t; }); }); -}; - -/** - * Validates all scopes. - */ -Validator.prototype.validateScopes = function validateScopes () { - var this$1 = this; - - if (this.paused) { return Promise.resolve(true); } - - var promises = this.fields.map(function (field) { return this$1.validate( - ("#" + (field.id)), - field.value - ); }); - - return Promise.all(promises).then(function (results) { return results.every(function (t) { return t; }); }); -}; - -/** - * Creates the fields to be validated. - */ -Validator.prototype._createFields = function _createFields (validations) { - var this$1 = this; - - if (!validations) { return; } - - Object.keys(validations).forEach(function (field) { - var options = assign({}, { name: field, rules: validations[field] }); - this$1.attach(options); - }); -}; - -/** - * Date rules need the existence of a format, so date_format must be supplied. - */ -Validator.prototype._getDateFormat = function _getDateFormat (validations) { - var format = null; - if (validations.date_format && Array.isArray(validations.date_format)) { - format = validations.date_format[0]; - } - - return format || this.dictionary.getDateFormat(this.locale); -}; - -/** - * Checks if the passed rule is a date rule. - */ -Validator.prototype._isADateRule = function _isADateRule (rule) { - return !! ~['after', 'before', 'date_between', 'date_format'].indexOf(rule); -}; - -/** - * Formats an error message for field and a rule. - */ -Validator.prototype._formatErrorMessage = function _formatErrorMessage (field, rule, data, targetName) { - if ( data === void 0 ) data = {}; - if ( targetName === void 0 ) targetName = null; - - var name = this._getFieldDisplayName(field); - var params = this._getLocalizedParams(rule, targetName); - // Defaults to english message. - if (!this.dictionary.hasLocale(LOCALE)) { - var msg$1 = this.dictionary.getFieldMessage('en', field.name, rule.name); - - return isCallable(msg$1) ? msg$1(name, params, data) : msg$1; - } - - var msg = this.dictionary.getFieldMessage(LOCALE, field.name, rule.name); - - return isCallable(msg) ? msg(name, params, data) : msg; -}; - -/** - * Translates the parameters passed to the rule (mainly for target fields). - */ -Validator.prototype._getLocalizedParams = function _getLocalizedParams (rule, targetName) { - if ( targetName === void 0 ) targetName = null; - - if (~['after', 'before', 'confirmed'].indexOf(rule.name) && rule.params && rule.params[0]) { - var localizedName = targetName || this.dictionary.getAttribute(LOCALE, rule.params[0], rule.params[0]); - return [localizedName].concat(rule.params.slice(1)); - } - - return rule.params; -}; - -/** - * Resolves an appropriate display name, first checking 'data-as' or the registered 'prettyName' - */ -Validator.prototype._getFieldDisplayName = function _getFieldDisplayName (field) { - return field.alias || this.dictionary.getAttribute(LOCALE, field.name, field.name); -}; - -/** - * Adds a field flags to the flags collection. - */ -Validator.prototype._addFlag = function _addFlag (field, scope) { - if ( scope === void 0 ) scope = null; - - if (isNullOrUndefined(scope)) { - this.flags = assign({}, this.flags, ( obj = {}, obj[("" + (field.name))] = field.flags, obj )); - var obj; - return; - } - - var scopeObj = assign({}, this.flags[("$" + scope)] || {}, ( obj$1 = {}, obj$1[("" + (field.name))] = field.flags, obj$1 )); - var obj$1; - this.flags = assign({}, this.flags, ( obj$2 = {}, obj$2[("$" + scope)] = scopeObj, obj$2 )); - var obj$2; -}; - -/** - * Tests a single input value against a rule. - */ -Validator.prototype._test = function _test (field, value, rule) { - var this$1 = this; - - var validator = RULES[rule.name]; - var params = Array.isArray(rule.params) ? toArray(rule.params) : []; - var targetName = null; - if (!validator || typeof validator !== 'function') { - throw createError(("No such validator '" + (rule.name) + "' exists.")); - } - - // has field dependencies. - if (/(confirmed|after|before)/.test(rule.name)) { - var target = find(field.dependencies, function (d) { return d.name === rule.name; }); - if (target) { - targetName = target.field.alias; - params = [target.field.value].concat(params.slice(1)); - } - } else if (rule.name === 'required' && field.rejectsFalse) { - // invalidate false if no args were specified and the field rejects false by default. - params = params.length ? params : [true]; - } - - if (this._isADateRule(rule.name)) { - var dateFormat = this._getDateFormat(field.rules); - if (rule.name !== 'date_format') { - params.push(dateFormat); - } - } - - var result = validator(value, params); - - // If it is a promise. - if (isCallable(result.then)) { - return result.then(function (values) { - var allValid = true; - var data = {}; - if (Array.isArray(values)) { - allValid = values.every(function (t) { return (isObject(t) ? t.valid : t); }); - } else { // Is a single object/boolean. - allValid = isObject(values) ? values.valid : values; - data = values.data; + }; + Field.prototype._addHTMLEventListener = function _addHTMLEventListener (evt, validate) { + var this$1 = this; + + if (!this.el || this.component) + { return; } + var addListener = function (el) { + addEventListener(el, evt, validate); + this$1.watchers.push({ + tag: 'input_native', + unwatch: function () { + el.removeEventListener(evt, validate); + } + }); + }; + addListener(this.el); + if (!isCheckboxOrRadioInput(this.el)) { + return; } - - return { - valid: allValid, - error: allValid ? undefined : { - id: field.id, - field: field.name, - msg: this$1._formatErrorMessage(field, rule, data, targetName), - rule: rule.name, - scope: field.scope - } + var els = document.querySelectorAll(("input[name=\"" + (this.el.name) + "\"]")); + toArray(els).forEach(function (el) { + if (el._veeValidateId && el !== this$1.el) { + return; + } + addListener(el); + }); + }; + Field.prototype.updateAriaAttrs = function updateAriaAttrs () { + var this$1 = this; + + if (!this.aria || !this.el || !isCallable(this.el.setAttribute)) + { return; } + var applyAriaAttrs = function (el) { + el.setAttribute('aria-required', this$1.isRequired ? 'true' : 'false'); + el.setAttribute('aria-invalid', this$1.flags.invalid ? 'true' : 'false'); }; - }); - } + if (!isCheckboxOrRadioInput(this.el)) { + applyAriaAttrs(this.el); + return; + } + var els = document.querySelectorAll(("input[name=\"" + (this.el.name) + "\"]")); + toArray(els).forEach(applyAriaAttrs); + }; + Field.prototype.updateCustomValidity = function updateCustomValidity () { + if (!this.validity || !this.el || !isCallable(this.el.setCustomValidity) || !this.validator.errors) + { return; } + this.el.setCustomValidity(this.flags.valid ? '' : this.validator.errors.firstById(this.id) || ''); + }; + Field.prototype.destroy = function destroy () { + this.unwatch(); + this.dependencies.forEach(function (d) { return d.field.destroy(); }); + this.dependencies = []; + }; - if (!isObject(result)) { - result = { valid: result, data: {} }; - } + Object.defineProperties( Field.prototype, prototypeAccessors$2 ); - return { - valid: result.valid, - error: result.valid ? undefined : { - id: field.id, - field: field.name, - msg: this._formatErrorMessage(field, rule, result.data, targetName), - rule: rule.name, - scope: field.scope - } + var FieldBag = function FieldBag() { + this.items = []; }; -}; - -/** - * Merges a validator object into the RULES and Messages. - */ -Validator._merge = function _merge (name, validator) { - if (isCallable(validator)) { - RULES[name] = validator; - return; - } - RULES[name] = validator.validate; - if (isCallable(validator.getMessage)) { - DICTIONARY.setMessage(LOCALE, name, validator.getMessage); - } + var prototypeAccessors$3 = { length: { configurable: true } }; + FieldBag.prototype[typeof Symbol === 'function' ? Symbol.iterator : '@@iterator'] = function () { + var this$1 = this; - if (validator.messages) { - DICTIONARY.merge( - Object.keys(validator.messages).reduce(function (prev, curr) { - var dict = prev; - dict[curr] = { - messages: ( obj = {}, obj[name] = validator.messages[curr], obj ) - }; - var obj; + var index = 0; + return { + next: function () { return ({ + value: this$1.items[index++], + done: index > this$1.items.length + }); } + }; + }; + prototypeAccessors$3.length.get = function () { + return this.items.length; + }; + FieldBag.prototype.find = function find$1 (matcher) { + return find(this.items, function (item) { return item.matches(matcher); }); + }; + FieldBag.prototype.filter = function filter (matcher) { + if (Array.isArray(matcher)) { + return this.items.filter(function (item) { return matcher.some(function (m) { return item.matches(m); }); }); + } + return this.items.filter(function (item) { return item.matches(matcher); }); + }; + FieldBag.prototype.map = function map (mapper) { + return this.items.map(mapper); + }; + FieldBag.prototype.remove = function remove (matcher) { + var item = null; + if (matcher instanceof Field) { + item = matcher; + } else { + item = this.find(matcher); + } + if (!item) + { return null; } + var index = this.items.indexOf(item); + this.items.splice(index, 1); + return item; + }; + FieldBag.prototype.push = function push (item) { + if (!(item instanceof Field)) { + throw createError('FieldBag only accepts instances of Field that has an id defined.'); + } + if (!item.id) { + throw createError('Field id must be defined.'); + } + if (this.find({ + id: item.id + })) { + throw createError(("Field with id " + (item.id) + " is already added.")); + } + this.items.push(item); + }; - return dict; - }, {}) - ); - } -}; + Object.defineProperties( FieldBag.prototype, prototypeAccessors$3 ); -/** - * Guards from extension violations. - */ -Validator._guardExtend = function _guardExtend (name, validator) { - if (isCallable(validator)) { - return; - } + var RULES = {}; + var STRICT_MODE = true; + var TARGET_RULES = ['confirmed','after','before']; + var Validator = function Validator(validations, options) { + var this$1 = this; + if ( options === void 0 ) options = { + fastExit: true + }; - if (!isCallable(validator.validate)) { - throw createError( - // eslint-disable-next-line - ("Extension Error: The validator '" + name + "' must be a function or have a 'validate' method.") - ); - } + this.strict = STRICT_MODE; + this.errors = new ErrorBag(); + this.fields = new FieldBag(); + this.flags = {}; + this._createFields(validations); + this.paused = false; + this.fastExit = options.fastExit || false; + this.ownerId = options.vm && options.vm._uid; + this._localeListener = (function () { + this$1.errors.regenerate(); + }); + if (this._vm) { + this._vm.$on('localeChanged', this._localeListener); + } + }; - if (!isCallable(validator.getMessage) && !isObject(validator.messages)) { - throw createError( - // eslint-disable-next-line - ("Extension Error: The validator '" + name + "' must have a 'getMessage' method or have a 'messages' object.") - ); - } -}; + var prototypeAccessors$4 = { dictionary: { configurable: true },_vm: { configurable: true },locale: { configurable: true },rules: { configurable: true } }; + var staticAccessors$1 = { dictionary: { configurable: true },locale: { configurable: true },rules: { configurable: true } }; + prototypeAccessors$4.dictionary.get = function () { + return Config.dependency('dictionary'); + }; + prototypeAccessors$4._vm.get = function () { + return Config.dependency('vm'); + }; + staticAccessors$1.dictionary.get = function () { + return Config.dependency('dictionary'); + }; + prototypeAccessors$4.locale.get = function () { + return this.dictionary.locale; + }; + prototypeAccessors$4.locale.set = function (value) { + Validator.locale = value; + }; + staticAccessors$1.locale.get = function () { + return Validator.dictionary.locale; + }; + staticAccessors$1.locale.set = function (value) { + var hasChanged = value !== Validator.dictionary.locale; + Validator.dictionary.locale = value; + if (hasChanged && Config.dependency('vm')) { + Config.dependency('vm').$emit('localeChanged'); + } + }; + prototypeAccessors$4.rules.get = function () { + return RULES; + }; + staticAccessors$1.rules.get = function () { + return RULES; + }; + Validator.create = function create (validations, options) { + return new Validator(validations, options); + }; + Validator.extend = function extend (name, validator, options) { + if ( options === void 0 ) options = {}; -/** - * Tries different strategies to find a field. - */ -Validator.prototype._resolveField = function _resolveField (name, scope) { - if (!isNullOrUndefined(scope)) { - return this.fields.find({ name: name, scope: scope }); - } + Validator._guardExtend(name, validator); + Validator._merge(name, validator); + if (options && options.hasTarget) { + TARGET_RULES.push(name); + } + }; + Validator.remove = function remove (name) { + delete RULES[name]; + var idx = TARGET_RULES.indexOf(name); + if (idx === -1) + { return; } + TARGET_RULES.splice(idx, 1); + }; + Validator.isTargetRule = function isTargetRule (name) { + return TARGET_RULES.indexOf(name) !== -1; + }; + Validator.setStrictMode = function setStrictMode (strictMode) { + if ( strictMode === void 0 ) strictMode = true; - if (name[0] === '#') { - return this.fields.find({ id: name.slice(1) }); - } + STRICT_MODE = strictMode; + }; + Validator.prototype.localize = function localize (lang, dictionary) { + Validator.localize(lang, dictionary); + }; + Validator.localize = function localize (lang, dictionary) { + var obj; - if (name.indexOf('.') > -1) { - var ref = name.split('.'); - var fieldScope = ref[0]; - var fieldName = ref.slice(1); - var field = this.fields.find({ name: fieldName.join('.'), scope: fieldScope }); - if (field) { + if (isObject(lang)) { + Validator.dictionary.merge(lang); + return; + } + if (dictionary) { + var locale = lang || dictionary.name; + dictionary = assign({}, dictionary); + Validator.dictionary.merge(( obj = {}, obj[locale] = dictionary, obj )); + } + if (lang) { + Validator.locale = lang; + } + }; + Validator.prototype.attach = function attach (field) { + if (arguments.length > 1) { + warn('This signature of the attach method has been deprecated, please consult the docs.'); + field = assign({}, { + name: arguments[0], + rules: arguments[1] + }, arguments[2] || { + vm: { + $validator: this + } + }); + } + var value = field.initialValue; + if (!(field instanceof Field)) { + field = new Field(field); + } + this.fields.push(field); + if (field.initial) { + this.validate(("#" + (field.id)), value || field.value); + } else { + this._validate(field, value || field.value, true).then(function (result) { + field.flags.valid = result.valid; + field.flags.invalid = !result.valid; + }); + } + this._addFlag(field, field.scope); return field; - } - } - - return this.fields.find({ name: name, scope: null }); -}; - -/** - * Handles when a field is not found depending on the strict flag. - */ -Validator.prototype._handleFieldNotFound = function _handleFieldNotFound (name, scope) { - if (!this.strict) { return Promise.resolve(true); } - - var fullName = isNullOrUndefined(scope) ? name : ("" + (!isNullOrUndefined(scope) ? scope + '.' : '') + name); - throw createError( - ("Validating a non-existent field: \"" + fullName + "\". Use \"attach()\" first.") - ); -}; - -/** - * Starts the validation process. - */ -Validator.prototype._validate = function _validate (field, value, silent) { - var this$1 = this; - if ( silent === void 0 ) silent = false; - - if (!field.isRequired && (isNullOrUndefined(value) || value === '')) { - return Promise.resolve({ valid: true }); - } - - var promises = []; - var errors = []; - var isExitEarly = false; - // use of '.some()' is to break iteration in middle by returning true - Object.keys(field.rules).some(function (rule) { - var result = this$1._test(field, value, { name: rule, params: field.rules[rule] }); - if (isCallable(result.then)) { - promises.push(result); - } else if (this$1.fastExit && !result.valid) { - errors.push(result.error); - isExitEarly = true; - } else { - // promisify the result. - promises.push(new Promise(function (resolve) { - resolve(result); - })); - } - - return isExitEarly; - }); - - if (isExitEarly) { - return Promise.resolve({ - valid: false, - errors: errors - }); - } - - return Promise.all(promises).then(function (values) { return values.map(function (v) { - if (!v.valid) { - errors.push(v.error); - } - - return v.valid; - }).every(function (t) { return t; }); } - ).then(function (result) { - return { - valid: result, - errors: errors - }; - }); -}; - -Object.defineProperties( Validator.prototype, prototypeAccessors ); -Object.defineProperties( Validator, staticAccessors ); - -// - -/* istanbul ignore next */ -var fakeFlags = createProxy({}, { - get: function get (target, key) { - // is a scope - if (String(key).indexOf('$') === 0) { - return fakeFlags; - } - - return createFlags(); - } -}); - -/** - * Checks if a parent validator instance was requested. - */ -var requestsValidator = function (injections) { - if (! injections) { - return false; - } - - /* istanbul ignore next */ - if (Array.isArray(injections) && ~injections.indexOf('$validator')) { - return true; - } - - if (isObject(injections) && injections.$validator) { - return true; - } + }; + Validator.prototype.flag = function flag (name, flags) { + var field = this._resolveField(name); + if (!field || !flags) { + return; + } + field.setFlags(flags); + }; + Validator.prototype.detach = function detach (name, scope) { + var field = name instanceof Field ? name : this._resolveField(name, scope); + if (!field) + { return; } + field.destroy(); + this.errors.remove(field.name, field.scope, field.id); + this.fields.remove(field); + var flags = this.flags; + if (!isNullOrUndefined(field.scope) && flags[("$" + (field.scope))]) { + delete flags[("$" + (field.scope))][field.name]; + } else if (isNullOrUndefined(field.scope)) { + delete flags[field.name]; + } + this.flags = assign({}, flags); + }; + Validator.prototype.extend = function extend (name, validator, options) { + if ( options === void 0 ) options = {}; - return false; -}; + Validator.extend(name, validator, options); + }; + Validator.prototype.reset = function reset (matcher) { + return new Promise((function ($return, $error) { + return this._vm.$nextTick().then((function ($await_1) { + try { + return this._vm.$nextTick().then((function ($await_2) { + var this$1 = this; + + try { + this.fields.filter(matcher).forEach(function (field) { + field.reset(); + this$1.errors.remove(field.name, field.scope, field.id); + }); + return $return(); + } catch ($boundEx) { + return $error($boundEx); + } + }).bind(this), $error); + } catch ($boundEx) { + return $error($boundEx); + } + }).bind(this), $error); + }).bind(this)); + }; + Validator.prototype.update = function update (id, ref) { + var scope = ref.scope; + + var field = this._resolveField(("#" + id)); + if (!field) + { return; } + this.errors.update(id, { + scope: scope + }); + if (!isNullOrUndefined(field.scope) && this.flags[("$" + (field.scope))]) { + delete this.flags[("$" + (field.scope))][field.name]; + } else if (isNullOrUndefined(field.scope)) { + delete this.flags[field.name]; + } + this._addFlag(field, scope); + }; + Validator.prototype.remove = function remove (name) { + Validator.remove(name); + }; + Validator.prototype.validate = function validate (name, value, scope, silent) { + if ( scope === void 0 ) scope = null; + if ( silent === void 0 ) silent = false; + + var $args = arguments; + return new Promise((function ($return, $error) { + var matched, field, result; + if (this.paused) + { return $return(Promise.resolve(true)); } + if ($args.length === 0) { + return $return(this.validateScopes()); + } + if ($args.length === 1 && $args[0] === '*') { + return $return(this.validateAll()); + } + if ($args.length === 1 && typeof $args[0] === 'string' && /^(.+)\.\*$/.test($args[0])) { + matched = $args[0].match(/^(.+)\.\*$/)[1]; + return $return(this.validateAll(matched)); + } + field = this._resolveField(name, scope); + if (!field) { + return $return(this._handleFieldNotFound(name, scope)); + } + if (!silent) + { field.flags.pending = true; } + if ($args.length === 1) { + value = field.value; + } + return this._validate(field, value).then((function ($await_3) { + try { + result = $await_3; + if (!silent) { + this._handleValidationResults([result]); + } + return $return(result.valid); + } catch ($boundEx) { + return $error($boundEx); + } + }).bind(this), $error); + }).bind(this)); + }; + Validator.prototype.pause = function pause () { + this.paused = true; + return this; + }; + Validator.prototype.resume = function resume () { + this.paused = false; + return this; + }; + Validator.prototype.validateAll = function validateAll (values, scope, silent) { + if ( scope === void 0 ) scope = null; + if ( silent === void 0 ) silent = false; + + return new Promise((function ($return, $error) { + var this$1 = this; + + var results; + var matcher, providedValues; + if (this.paused) + { return $return(true); } + matcher = null; + providedValues = false; + if (typeof values === 'string') { + matcher = { + scope: values + }; + } else if (isObject(values)) { + matcher = Object.keys(values).map(function (key) { return ({ + name: key, + scope: scope + }); }); + providedValues = true; + } else if (Array.isArray(values)) { + matcher = values.map(function (key) { return ({ + name: key, + scope: scope + }); }); + } else { + matcher = { + scope: scope + }; + } + return Promise.all(this.fields.filter(matcher).map(function (field) { return this$1._validate(field, providedValues ? values[field.name] : field.value); })).then((function ($await_4) { + try { + results = $await_4; + if (!silent) { + this._handleValidationResults(results); + } + return $return(results.every(function (t) { return t.valid; })); + } catch ($boundEx) { + return $error($boundEx); + } + }).bind(this), $error); + }).bind(this)); + }; + Validator.prototype.validateScopes = function validateScopes (silent) { + if ( silent === void 0 ) silent = false; + + return new Promise((function ($return, $error) { + var this$1 = this; + + var results; + if (this.paused) + { return $return(true); } + return Promise.all(this.fields.map(function (field) { return this$1._validate(field, field.value); })).then((function ($await_5) { + try { + results = $await_5; + if (!silent) { + this._handleValidationResults(results); + } + return $return(results.every(function (t) { return t.valid; })); + } catch ($boundEx) { + return $error($boundEx); + } + }).bind(this), $error); + }).bind(this)); + }; + Validator.prototype.destroy = function destroy () { + this._vm.$off('localeChanged', this._localeListener); + }; + Validator.prototype._createFields = function _createFields (validations) { + var this$1 = this; + + if (!validations) + { return; } + Object.keys(validations).forEach(function (field) { + var options = assign({}, { + name: field, + rules: validations[field] + }); + this$1.attach(options); + }); + }; + Validator.prototype._getDateFormat = function _getDateFormat (validations) { + var format = null; + if (validations.date_format && Array.isArray(validations.date_format)) { + format = validations.date_format[0]; + } + return format || this.dictionary.getDateFormat(this.locale); + }; + Validator.prototype._isADateRule = function _isADateRule (rule) { + return !(!(~['after','before','date_between','date_format'].indexOf(rule))); + }; + Validator.prototype._formatErrorMessage = function _formatErrorMessage (field, rule, data, targetName) { + if ( data === void 0 ) data = {}; + if ( targetName === void 0 ) targetName = null; + + var name = this._getFieldDisplayName(field); + var params = this._getLocalizedParams(rule, targetName); + return this.dictionary.getFieldMessage(this.locale, field.name, rule.name, [name, + params,data]); + }; + Validator.prototype._getLocalizedParams = function _getLocalizedParams (rule, targetName) { + if ( targetName === void 0 ) targetName = null; -/** - * Creates a validator instance. - */ -var createValidator = function (vm, options) { return new Validator(null, { vm: vm, fastExit: options.fastExit }); }; + if (~TARGET_RULES.indexOf(rule.name) && rule.params && rule.params[0]) { + var localizedName = targetName || this.dictionary.getAttribute(this.locale, rule.params[0], rule.params[0]); + return [localizedName].concat(rule.params.slice(1)); + } + return rule.params; + }; + Validator.prototype._getFieldDisplayName = function _getFieldDisplayName (field) { + return field.alias || this.dictionary.getAttribute(this.locale, field.name, field.name); + }; + Validator.prototype._addFlag = function _addFlag (field, scope) { + var obj, obj$1, obj$2; -var mixin = { - provide: function provide () { - if (this.$validator && !isBuiltInComponent(this.$vnode)) { + if ( scope === void 0 ) scope = null; + if (isNullOrUndefined(scope)) { + this.flags = assign({}, this.flags, ( obj = {}, obj[("" + (field.name))] = field.flags, obj )); + return; + } + var scopeObj = assign({}, this.flags[("$" + scope)] || {}, ( obj$1 = {}, obj$1[("" + (field.name))] = field.flags, obj$1 )); + this.flags = assign({}, this.flags, ( obj$2 = {}, obj$2[("$" + scope)] = scopeObj, obj$2 )); + }; + Validator.prototype._test = function _test (field, value, rule) { + var this$1 = this; + + var validator = RULES[rule.name]; + var params = Array.isArray(rule.params) ? toArray(rule.params) : []; + var targetName = null; + if (!validator || typeof validator !== 'function') { + throw createError(("No such validator '" + (rule.name) + "' exists.")); + } + if (TARGET_RULES.indexOf(rule.name) !== -1) { + var target = find(field.dependencies, function (d) { return d.name === rule.name; }); + if (target) { + targetName = target.field.alias; + params = [target.field.value].concat(params.slice(1)); + } + } else if (rule.name === 'required' && field.rejectsFalse) { + params = params.length ? params : [true]; + } + if (this._isADateRule(rule.name)) { + var dateFormat = this._getDateFormat(field.rules); + if (rule.name !== 'date_format') { + params.push(dateFormat); + } + } + var result = validator(value, params); + if (isCallable(result.then)) { + return result.then(function (values) { + var allValid = true; + var data = {}; + if (Array.isArray(values)) { + allValid = values.every(function (t) { return isObject(t) ? t.valid : t; }); + } else { + allValid = isObject(values) ? values.valid : values; + data = values.data; + } + return { + valid: allValid, + errors: allValid ? [] : [this$1._createFieldError(field, rule, data, targetName)] + }; + }); + } + if (!isObject(result)) { + result = { + valid: result, + data: {} + }; + } return { - $validator: this.$validator + valid: result.valid, + errors: result.valid ? [] : [this._createFieldError(field, rule, result.data, targetName)] }; - } - - return {}; - }, - beforeCreate: function beforeCreate () { - // if built in do nothing. - if (isBuiltInComponent(this.$vnode)) { - return; - } - - // if its a root instance set the config if it exists. - if (!this.$parent) { - Config.merge(this.$options.$_veeValidate || {}); - } - - var options = Config.resolve(this); - var Vue = this.$options._base; // the vue constructor. - // TODO: Deprecate - /* istanbul ignore next */ - if (this.$options.$validates) { - warn('The ctor $validates option has been deprecated please set the $_veeValidate.validator option to "new" instead'); - this.$validator = createValidator(this, options); - } - - // if its a root instance, inject anyways, or if it requested a new instance. - if (!this.$parent || (this.$options.$_veeValidate && /new/.test(this.$options.$_veeValidate.validator))) { - this.$validator = createValidator(this, options); - } - - var requested = requestsValidator(this.$options.inject); - - // if automatic injection is enabled and no instance was requested. - if (! this.$validator && options.inject && !requested) { - this.$validator = createValidator(this, options); - } - - // don't inject errors or fieldBag as no validator was resolved. - if (! requested && ! this.$validator) { - return; - } - - // There is a validator but it isn't injected, mark as reactive. - if (! requested && this.$validator) { - Vue.util.defineReactive(this.$validator, 'errors', this.$validator.errors); - Vue.util.defineReactive(this.$validator, 'flags', this.$validator.flags); - } - - if (! this.$options.computed) { - this.$options.computed = {}; - } - - this.$options.computed[options.errorBagName || 'errors'] = function errorBagGetter () { - return this.$validator.errors; - }; - this.$options.computed[options.fieldsBagName || 'fields'] = function fieldBagGetter () { - if (!Object.keys(this.$validator.flags).length) { - return fakeFlags; + }; + Validator._merge = function _merge (name, validator) { + if (isCallable(validator)) { + RULES[name] = validator; + return; } + RULES[name] = validator.validate; + if (validator.getMessage) { + Validator.dictionary.setMessage(this.locale, name, validator.getMessage); + } + }; + Validator._guardExtend = function _guardExtend (name, validator) { + if (isCallable(validator)) { + return; + } + if (!isCallable(validator.validate)) { + throw createError(("Extension Error: The validator '" + name + "' must be a function or have a 'validate' method.")); + } + }; + Validator.prototype._createFieldError = function _createFieldError (field, rule, data, targetName) { + var this$1 = this; - return this.$validator.flags; - }; - }, - - beforeDestroy: function beforeDestroy () { - if (isBuiltInComponent(this.$vnode)) { return; } - - // mark the validator paused to prevent delayed validation. - if (this.$validator && this.$validator.ownerId === this._uid && isCallable(this.$validator.pause)) { - this.$validator.pause(); - } - } -}; - -// - -/** - * Finds the requested field by id from the context object. - */ -var findField = function (el, context) { - if (!context || !context.$validator) { - return null; - } - - return context.$validator.fields.find({ id: getDataAttribute(el, 'id') }); -}; - -var directive = { - bind: function bind (el, binding, vnode) { - var validator = vnode.context.$validator; - if (! validator) { - warn("No validator instance is present on vm, did you forget to inject '$validator'?"); - return; - } - - var fieldOptions = Generator.generate(el, binding, vnode); - validator.attach(fieldOptions); - }, - inserted: function (el, binding, vnode) { - var field = findField(el, vnode.context); - var scope = Generator.resolveScope(el, binding, vnode); - - // skip if scope hasn't changed. - if (!field || scope === field.scope) { return; } - - // only update scope. - field.update({ scope: scope }); - - // allows the field to re-evaluated once more in the update hook. - field.updated = false; - }, - update: function (el, binding, vnode) { - var field = findField(el, vnode.context); - - // make sure we don't do unneccasary work if no important change was done. - if (!field || (field.updated && isEqual$1(binding.value, binding.oldValue))) { return; } - var scope = Generator.resolveScope(el, binding, vnode); - var rules = Generator.resolveRules(el, binding); - - field.update({ - scope: scope, - rules: rules - }); - }, - unbind: function unbind (el, binding, ref) { - var context = ref.context; - - var field = findField(el, context); - if (!field) { return; } - - context.$validator.detach(field); - } -}; - -var Vue; - -function install (_Vue, options) { - if ( options === void 0 ) options = {}; + return { + id: field.id, + field: field.name, + msg: this._formatErrorMessage(field, rule, data, targetName), + rule: rule.name, + scope: field.scope, + regenerate: function () { return this$1._formatErrorMessage(field, rule, data, targetName); } + }; + }; + Validator.prototype._resolveField = function _resolveField (name, scope) { + if (!isNullOrUndefined(scope)) { + return this.fields.find({ + name: name, + scope: scope + }); + } + if (name[0] === '#') { + return this.fields.find({ + id: name.slice(1) + }); + } + if (name.indexOf('.') > -1) { + var ref = name.split('.'); + var fieldScope = ref[0]; + var fieldName = ref.slice(1); + var field = this.fields.find({ + name: fieldName.join('.'), + scope: fieldScope + }); + if (field) { + return field; + } + } + return this.fields.find({ + name: name, + scope: null + }); + }; + Validator.prototype._handleFieldNotFound = function _handleFieldNotFound (name, scope) { + if (!this.strict) + { return true; } + var fullName = isNullOrUndefined(scope) ? name : ("" + (!isNullOrUndefined(scope) ? scope + '.' : '') + name); + throw createError(("Validating a non-existent field: \"" + fullName + "\". Use \"attach()\" first.")); + }; + Validator.prototype._handleValidationResults = function _handleValidationResults (results) { + var matchers = results.map(function (result) { return ({ + id: result.id + }); }); + this.errors.removeById(matchers.map(function (m) { return m.id; })); + var allErrors = results.reduce(function (prev, curr) { + prev.push.apply(prev, curr.errors); + return prev; + }, []); + this.errors.add(allErrors); + this.fields.filter(matchers).forEach(function (field) { + var result = find(results, function (r) { return r.id === field.id; }); + field.setFlags({ + pending: false, + valid: result.valid, + validated: true + }); + }); + }; + Validator.prototype._validate = function _validate (field, value) { + return new Promise((function ($return, $error) { + var this$1 = this; + + var promises, errors; + var isExitEarly; + if (field.isDisabled || !field.isRequired && (isNullOrUndefined(value) || value === '')) { + return $return({ + valid: true, + id: field.id, + errors: [] + }); + } + promises = []; + errors = []; + isExitEarly = false; + Object.keys(field.rules).some(function (rule) { + var result = this$1._test(field, value, { + name: rule, + params: field.rules[rule] + }); + if (isCallable(result.then)) { + promises.push(result); + } else if (this$1.fastExit && !result.valid) { + errors.push.apply(errors, result.errors); + isExitEarly = true; + } else { + promises.push(new Promise(function (resolve) { return resolve(result); })); + } + return isExitEarly; + }); + if (isExitEarly) { + return $return({ + valid: false, + errors: errors, + id: field.id + }); + } + return Promise.all(promises).then((function ($await_6) { + try { + return $return($await_6.reduce(function (prev, v) { + var ref; + + if (!v.valid) { + (ref = prev.errors).push.apply(ref, v.errors); + } + prev.valid = prev.valid && v.valid; + return prev; + }, { + valid: true, + errors: errors, + id: field.id + })); + } catch ($boundEx) { + return $error($boundEx); + } + }).bind(this), $error); + }).bind(this)); + }; - if (Vue) { - warn('already installed, Vue.use(VeeValidate) should only be called once.'); - return; - } + Object.defineProperties( Validator.prototype, prototypeAccessors$4 ); + Object.defineProperties( Validator, staticAccessors$1 ); - Vue = _Vue; - Config.merge(options); - if (Config.current.dictionary) { - Validator.updateDictionary(Config.current.dictionary); + var requestsValidator = function (injections) { + if (isObject(injections) && injections.$validator) { + return true; + } + return false; + }; + var createValidator = function (vm, options) { return new Validator(null, { + vm: vm, + fastExit: options.fastExit + }); }; + var mixin = { + provide: function provide() { + if (this.$validator && !isBuiltInComponent(this.$vnode)) { + return { + $validator: this.$validator + }; + } + return {}; + }, + beforeCreate: function beforeCreate() { + if (isBuiltInComponent(this.$vnode)) { + return; + } + if (!this.$parent) { + Config.merge(this.$options.$_veeValidate || {}); + } + var options = Config.resolve(this); + var Vue = this.$options._base; + if (this.$options.$validates) { + warn('The ctor $validates option has been deprecated please set the $_veeValidate.validator option to "new" instead'); + this.$validator = createValidator(this, options); + } + if (!this.$parent || this.$options.$_veeValidate && /new/.test(this.$options.$_veeValidate.validator)) { + this.$validator = createValidator(this, options); + } + var requested = requestsValidator(this.$options.inject); + if (!this.$validator && options.inject && !requested) { + this.$validator = createValidator(this, options); + } + if (!requested && !this.$validator) { + return; + } + if (!requested && this.$validator) { + Vue.util.defineReactive(this.$validator, 'errors', this.$validator.errors); + Vue.util.defineReactive(this.$validator, 'flags', this.$validator.flags); + } + if (!this.$options.computed) { + this.$options.computed = {}; + } + this.$options.computed[options.errorBagName || 'errors'] = function errorBagGetter() { + return this.$validator.errors; + }; + this.$options.computed[options.fieldsBagName || 'fields'] = function fieldBagGetter() { + return this.$validator.flags; + }; + }, + beforeDestroy: function beforeDestroy() { + if (isBuiltInComponent(this.$vnode)) + { return; } + if (this.$validator && this.$validator.ownerId === this._uid) { + this.$validator.pause(); + this.$validator.destroy(); + } + } } - if (options) { - if (options.locale) { - Validator.locale = options.locale; - } - - if (options.strict) { - Validator.setStrictMode(Config.current.strict); - } + function findField(el, context) { + if (!context || !context.$validator) { + return null; + } + return context.$validator.fields.find({ + id: el._veeValidateId + }); } - - Vue.mixin(mixin); - Vue.directive('validate', directive); -} - -// - -function use (plugin, options) { - if ( options === void 0 ) options = {}; - - if (!isCallable(plugin)) { - return warn('The plugin must be a callable function'); + var directive = { + bind: function bind(el, binding, vnode) { + var validator = vnode.context.$validator; + if (!validator) { + warn("No validator instance is present on vm, did you forget to inject '$validator'?"); + return; + } + var fieldOptions = Generator.generate(el, binding, vnode); + validator.attach(fieldOptions); + }, + inserted: function inserted(el, binding, vnode) { + var field = findField(el, vnode.context); + var scope = Generator.resolveScope(el, binding, vnode); + if (!field || scope === field.scope) + { return; } + field.update({ + scope: scope + }); + field.updated = false; + }, + update: function update(el, binding, vnode) { + var field = findField(el, vnode.context); + if (!field || field.updated && isEqual$1(binding.value, binding.oldValue)) + { return; } + var scope = Generator.resolveScope(el, binding, vnode); + var rules = Generator.resolveRules(el, binding); + field.update({ + scope: scope, + rules: rules + }); + }, + unbind: function unbind(el, binding, ref) { + var context = ref.context; + + var field = findField(el, context); + if (!field) + { return; } + context.$validator.detach(field); + } } - plugin({ Validator: Validator, ErrorBag: ErrorBag, Rules: Validator.rules }, options); -} - -// + var Vue; + function install(_Vue, options) { + if ( options === void 0 ) options = {}; -var normalize = function (fields) { - if (Array.isArray(fields)) { - return fields.reduce(function (prev, curr) { - if (~curr.indexOf('.')) { - prev[curr.split('.')[1]] = curr; - } else { - prev[curr] = curr; + if (Vue && _Vue === Vue) { + if (process.env.NODE_ENV !== 'production') { + warn('already installed, Vue.use(VeeValidate) should only be called once.'); + } + return; } - - return prev; - }, {}); + detectPassiveSupport(); + Vue = _Vue; + var localVue = new Vue(); + Config.register('vm', localVue); + Config.merge(options); + var ref = Config.current; + var dictionary = ref.dictionary; + var i18n = ref.i18n; + if (dictionary) { + Validator.localize(dictionary); + } + if (i18n && i18n._vm && isCallable(i18n._vm.$watch)) { + i18n._vm.$watch('locale', function () { + localVue.$emit('localeChanged'); + }); + } + if (!i18n && options.locale) { + Validator.localize(options.locale); + } + Validator.setStrictMode(Config.current.strict); + Vue.mixin(mixin); + Vue.directive('validate', directive); } - return fields; -}; - -// Combines two flags using either AND or OR depending on the flag type. -var combine = function (lhs, rhs) { - var mapper = { - pristine: function (lhs, rhs) { return lhs && rhs; }, - dirty: function (lhs, rhs) { return lhs || rhs; }, - touched: function (lhs, rhs) { return lhs || rhs; }, - untouched: function (lhs, rhs) { return lhs && rhs; }, - valid: function (lhs, rhs) { return lhs && rhs; }, - invalid: function (lhs, rhs) { return lhs || rhs; }, - pending: function (lhs, rhs) { return lhs || rhs; }, - required: function (lhs, rhs) { return lhs || rhs; }, - validated: function (lhs, rhs) { return lhs && rhs; } - }; - - return Object.keys(mapper).reduce(function (flags, flag) { - flags[flag] = mapper[flag](lhs[flag], rhs[flag]); - - return flags; - }, {}); -}; - -var mapScope = function (scope, deep) { - if ( deep === void 0 ) deep = true; - - return Object.keys(scope).reduce(function (flags, field) { - if (!flags) { - flags = assign({}, scope[field]); - return flags; - } - - // scope. - var isScope = field.indexOf('$') === 0; - if (deep && isScope) { - flags = mapScope(scope[field]); - return flags; - } else if (!deep && isScope) { - return flags; - } - - flags = combine(flags, scope[field]); - - return flags; - }, null); -}; - -/** - * Maps fields to computed functions. - */ -var mapFields = function (fields) { - if (!fields) { - return function () { - return mapScope(this.$validator.flags); - }; - } + function use(plugin, options) { + if ( options === void 0 ) options = {}; - var normalized = normalize(fields); - return Object.keys(normalized).reduce(function (prev, curr) { - var field = normalized[curr]; - prev[curr] = function mappedField () { - // if field exists - if (this.$validator.flags[field]) { - return this.$validator.flags[field]; + if (!isCallable(plugin)) { + return warn('The plugin must be a callable function'); } - - // scopeless fields were selected. - if (normalized[curr] === '*') { - return mapScope(this.$validator.flags, false); + plugin({ + Validator: Validator, + ErrorBag: ErrorBag, + Rules: Validator.rules + }, options); + } + + var normalize = function (fields) { + if (Array.isArray(fields)) { + return fields.reduce(function (prev, curr) { + if (~curr.indexOf('.')) { + prev[curr.split('.')[1]] = curr; + } else { + prev[curr] = curr; + } + return prev; + }, {}); } + return fields; + }; + var combine = function (lhs, rhs) { + var mapper = { + pristine: function (lhs, rhs) { return lhs && rhs; }, + dirty: function (lhs, rhs) { return lhs || rhs; }, + touched: function (lhs, rhs) { return lhs || rhs; }, + untouched: function (lhs, rhs) { return lhs && rhs; }, + valid: function (lhs, rhs) { return lhs && rhs; }, + invalid: function (lhs, rhs) { return lhs || rhs; }, + pending: function (lhs, rhs) { return lhs || rhs; }, + required: function (lhs, rhs) { return lhs || rhs; }, + validated: function (lhs, rhs) { return lhs && rhs; } + }; + return Object.keys(mapper).reduce(function (flags, flag) { + flags[flag] = mapper[flag](lhs[flag], rhs[flag]); + return flags; + }, {}); + }; + var mapScope = function (scope, deep) { + if ( deep === void 0 ) deep = true; - // if it has a scope defined - var index = field.indexOf('.'); - if (index <= 0) { - return {}; + return Object.keys(scope).reduce(function (flags, field) { + if (!flags) { + flags = assign({}, scope[field]); + return flags; } - - var ref = field.split('.'); - var scope = ref[0]; - var name = ref.slice(1); - - scope = this.$validator.flags[("$" + scope)]; - name = name.join('.'); - - // an entire scope was selected: scope.* - if (name === '*' && scope) { - return mapScope(scope); + var isScope = field.indexOf('$') === 0; + if (deep && isScope) { + return combine(mapScope(scope[field]), flags); + } else if (!deep && isScope) { + return flags; } - - if (scope && scope[name]) { - return scope[name]; + flags = combine(flags, scope[field]); + return flags; + }, null); + }; + var mapFields = function (fields) { + if (!fields) { + return function () { + return mapScope(this.$validator.flags); + }; } + var normalized = normalize(fields); + return Object.keys(normalized).reduce(function (prev, curr) { + var field = normalized[curr]; + prev[curr] = function mappedField() { + if (this.$validator.flags[field]) { + return this.$validator.flags[field]; + } + if (normalized[curr] === '*') { + return mapScope(this.$validator.flags, false); + } + var index = field.indexOf('.'); + if (index <= 0) { + return {}; + } + var ref = field.split('.'); + var scope = ref[0]; + var name = ref.slice(1); + scope = this.$validator.flags[("$" + scope)]; + name = name.join('.'); + if (name === '*' && scope) { + return mapScope(scope); + } + if (scope && scope[name]) { + return scope[name]; + } + return {}; + }; + return prev; + }, {}); + }; - return {}; - }; - - return prev; - }, {}); -}; - -var minimal$1 = { - install: install, - use: use, - directive: directive, - mixin: mixin, - mapFields: mapFields, - Validator: Validator, - ErrorBag: ErrorBag, - version: '2.0.0-rc.25' -}; - -// rules plugin definition. -var rulesPlugin = function (ref) { - var Validator = ref.Validator; + var ErrorComponent = { + name: 'vv-error', + inject: ['$validator'], + functional: true, + props: { + for: { + type: String, + required: true + }, + tag: { + type: String, + default: 'span' + } + }, + render: function render(createElement, ref) { + var props = ref.props; + var injections = ref.injections; - Object.keys(Rules).forEach(function (rule) { - Validator.extend(rule, Rules[rule]); - }); + return createElement(props.tag, injections.$validator.errors.first(props.for)); + } + }; - // Merge the english messages. - Validator.localize('en', locale$1); -}; + var minimal = { + install: install, + use: use, + directive: directive, + mixin: mixin, + mapFields: mapFields, + Validator: Validator, + ErrorBag: ErrorBag, + ErrorComponent: ErrorComponent, + version: '2.0.9' + } -// install the rules via the plugin API. -minimal$1.use(rulesPlugin); + var rulesPlugin = function (ref) { + var Validator = ref.Validator; -minimal$1.Rules = Rules; + Object.keys(Rules).forEach(function (rule) { + Validator.extend(rule, Rules[rule]); + }); + Validator.localize('en', locale$1); + }; + minimal.use(rulesPlugin); + minimal.Rules = Rules; -return minimal$1; + return minimal; }))); -},{}],22:[function(require,module,exports){ +}).call(this,require('_process')) +},{"_process":20}],23:[function(require,module,exports){ var Vue // late bind var version var map = (window.__VUE_HOT_MAP__ = Object.create(null)) @@ -7442,7 +5799,7 @@ exports.reload = tryWrap(function (id, options) { }) }) -},{}],23:[function(require,module,exports){ +},{}],24:[function(require,module,exports){ (function (process){ /** * vue-router v3.0.1 @@ -10071,17 +8428,19 @@ if (inBrowser && window.Vue) { module.exports = VueRouter; }).call(this,require('_process')) -},{"_process":20}],24:[function(require,module,exports){ -(function (process,global){ +},{"_process":20}],25:[function(require,module,exports){ +(function (process,global,setImmediate){ /*! - * Vue.js v2.5.2 - * (c) 2014-2017 Evan You + * Vue.js v2.5.16 + * (c) 2014-2018 Evan You * Released under the MIT License. */ 'use strict'; /* */ +var emptyObject = Object.freeze({}); + // these helpers produces better vm code in JS engines due to their // explicitness and function inlining function isUndef (v) { @@ -10107,6 +8466,8 @@ function isPrimitive (value) { return ( typeof value === 'string' || typeof value === 'number' || + // $flow-disable-line + typeof value === 'symbol' || typeof value === 'boolean' ) } @@ -10252,9 +8613,15 @@ var hyphenate = cached(function (str) { }); /** - * Simple bind, faster than native + * Simple bind polyfill for environments that do not support it... e.g. + * PhantomJS 1.x. Technically we don't need this anymore since native bind is + * now more performant in most browsers, but removing it would be breaking for + * code that was able to run in PhantomJS 1.x, so this must be kept for + * backwards compatibility. */ -function bind (fn, ctx) { + +/* istanbul ignore next */ +function polyfillBind (fn, ctx) { function boundFn (a) { var l = arguments.length; return l @@ -10263,11 +8630,19 @@ function bind (fn, ctx) { : fn.call(ctx, a) : fn.call(ctx) } - // record original fn length + boundFn._length = fn.length; return boundFn } +function nativeBind (fn, ctx) { + return fn.bind(ctx) +} + +var bind = Function.prototype.bind + ? nativeBind + : polyfillBind; + /** * Convert an Array-like object to a real Array. */ @@ -10411,6 +8786,7 @@ var config = ({ /** * Option merge strategies (used in core/util/options) */ + // $flow-disable-line optionMergeStrategies: Object.create(null), /** @@ -10451,6 +8827,7 @@ var config = ({ /** * Custom user key aliases for v-on */ + // $flow-disable-line keyCodes: Object.create(null), /** @@ -10491,12 +8868,10 @@ var config = ({ * Exposed for legacy reasons */ _lifecycleHooks: LIFECYCLE_HOOKS -}); +}) /* */ -var emptyObject = Object.freeze({}); - /** * Check if a string starts with $ or _ */ @@ -10542,12 +8917,14 @@ var hasProto = '__proto__' in {}; // Browser environment sniffing var inBrowser = typeof window !== 'undefined'; +var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform; +var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase(); var UA = inBrowser && window.navigator.userAgent.toLowerCase(); var isIE = UA && /msie|trident/.test(UA); var isIE9 = UA && UA.indexOf('msie 9.0') > 0; var isEdge = UA && UA.indexOf('edge/') > 0; -var isAndroid = UA && UA.indexOf('android') > 0; -var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA); +var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android'); +var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios'); var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge; // Firefox has a "watch" function on Object.prototype... @@ -10573,7 +8950,7 @@ var _isServer; var isServerRendering = function () { if (_isServer === undefined) { /* istanbul ignore if */ - if (!inBrowser && typeof global !== 'undefined') { + if (!inBrowser && !inWeex && typeof global !== 'undefined') { // detect presence of vue-server-renderer and avoid // Webpack shimming the process _isServer = global['process'].env.VUE_ENV === 'server'; @@ -10718,14 +9095,14 @@ if (process.env.NODE_ENV !== 'production') { /* */ -var uid$1 = 0; +var uid = 0; /** * A dep is an observable that can have multiple * directives subscribing to it. */ var Dep = function Dep () { - this.id = uid$1++; + this.id = uid++; this.subs = []; }; @@ -10785,9 +9162,9 @@ var VNode = function VNode ( this.elm = elm; this.ns = undefined; this.context = context; - this.functionalContext = undefined; - this.functionalOptions = undefined; - this.functionalScopeId = undefined; + this.fnContext = undefined; + this.fnOptions = undefined; + this.fnScopeId = undefined; this.key = data && data.key; this.componentOptions = componentOptions; this.componentInstance = undefined; @@ -10830,7 +9207,7 @@ function createTextVNode (val) { // used for static nodes and slot nodes because they may be reused across // multiple renders, cloning them avoids errors when DOM manipulations rely // on their elm reference. -function cloneVNode (vnode, deep) { +function cloneVNode (vnode) { var cloned = new VNode( vnode.tag, vnode.data, @@ -10845,29 +9222,22 @@ function cloneVNode (vnode, deep) { cloned.isStatic = vnode.isStatic; cloned.key = vnode.key; cloned.isComment = vnode.isComment; + cloned.fnContext = vnode.fnContext; + cloned.fnOptions = vnode.fnOptions; + cloned.fnScopeId = vnode.fnScopeId; cloned.isCloned = true; - if (deep && vnode.children) { - cloned.children = cloneVNodes(vnode.children); - } return cloned } -function cloneVNodes (vnodes, deep) { - var len = vnodes.length; - var res = new Array(len); - for (var i = 0; i < len; i++) { - res[i] = cloneVNode(vnodes[i], deep); - } - return res -} - /* * not type checking this file because flow doesn't play well with * dynamically accessing methods on Array prototype */ var arrayProto = Array.prototype; -var arrayMethods = Object.create(arrayProto);[ +var arrayMethods = Object.create(arrayProto); + +var methodsToPatch = [ 'push', 'pop', 'shift', @@ -10875,8 +9245,12 @@ var arrayMethods = Object.create(arrayProto);[ 'splice', 'sort', 'reverse' -] -.forEach(function (method) { +]; + +/** + * Intercept mutating methods and emit events + */ +methodsToPatch.forEach(function (method) { // cache original method var original = arrayProto[method]; def(arrayMethods, method, function mutator () { @@ -10907,20 +9281,20 @@ var arrayMethods = Object.create(arrayProto);[ var arrayKeys = Object.getOwnPropertyNames(arrayMethods); /** - * By default, when a reactive property is set, the new value is - * also converted to become reactive. However when passing down props, - * we don't want to force conversion because the value may be a nested value - * under a frozen data structure. Converting it would defeat the optimization. + * In some cases we may want to disable observation inside a component's + * update computation. */ -var observerState = { - shouldConvert: true -}; +var shouldObserve = true; + +function toggleObserving (value) { + shouldObserve = value; +} /** - * Observer class that are attached to each observed - * object. Once attached, the observer converts target + * Observer class that is attached to each observed + * object. Once attached, the observer converts the target * object's property keys into getter/setters that - * collect dependencies and dispatches updates. + * collect dependencies and dispatch updates. */ var Observer = function Observer (value) { this.value = value; @@ -10946,7 +9320,7 @@ var Observer = function Observer (value) { Observer.prototype.walk = function walk (obj) { var keys = Object.keys(obj); for (var i = 0; i < keys.length; i++) { - defineReactive(obj, keys[i], obj[keys[i]]); + defineReactive(obj, keys[i]); } }; @@ -10996,7 +9370,7 @@ function observe (value, asRootData) { if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) { ob = value.__ob__; } else if ( - observerState.shouldConvert && + shouldObserve && !isServerRendering() && (Array.isArray(value) || isPlainObject(value)) && Object.isExtensible(value) && @@ -11029,6 +9403,9 @@ function defineReactive ( // cater for pre-defined getter/setters var getter = property && property.get; + if (!getter && arguments.length === 2) { + val = obj[key]; + } var setter = property && property.set; var childOb = !shallow && observe(val); @@ -11075,12 +9452,17 @@ function defineReactive ( * already exist. */ function set (target, key, val) { + if (process.env.NODE_ENV !== 'production' && + (isUndef(target) || isPrimitive(target)) + ) { + warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target)))); + } if (Array.isArray(target) && isValidArrayIndex(key)) { target.length = Math.max(target.length, key); target.splice(key, 1, val); return val } - if (hasOwn(target, key)) { + if (key in target && !(key in Object.prototype)) { target[key] = val; return val } @@ -11105,6 +9487,11 @@ function set (target, key, val) { * Delete a property and trigger change if necessary. */ function del (target, key) { + if (process.env.NODE_ENV !== 'production' && + (isUndef(target) || isPrimitive(target)) + ) { + warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target)))); + } if (Array.isArray(target) && isValidArrayIndex(key)) { target.splice(key, 1); return @@ -11208,18 +9595,18 @@ function mergeDataOrFn ( // it has to be a function to pass previous merges. return function mergedDataFn () { return mergeData( - typeof childVal === 'function' ? childVal.call(this) : childVal, - typeof parentVal === 'function' ? parentVal.call(this) : parentVal + typeof childVal === 'function' ? childVal.call(this, this) : childVal, + typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal ) } - } else if (parentVal || childVal) { + } else { return function mergedInstanceDataFn () { // instance merge var instanceData = typeof childVal === 'function' - ? childVal.call(vm) + ? childVal.call(vm, vm) : childVal; var defaultData = typeof parentVal === 'function' - ? parentVal.call(vm) + ? parentVal.call(vm, vm) : parentVal; if (instanceData) { return mergeData(instanceData, defaultData) @@ -11246,7 +9633,7 @@ strats.data = function ( return parentVal } - return mergeDataOrFn.call(this, parentVal, childVal) + return mergeDataOrFn(parentVal, childVal) } return mergeDataOrFn(parentVal, childVal, vm) @@ -11371,13 +9758,23 @@ var defaultStrat = function (parentVal, childVal) { */ function checkComponents (options) { for (var key in options.components) { - var lower = key.toLowerCase(); - if (isBuiltInTag(lower) || config.isReservedTag(lower)) { - warn( - 'Do not use built-in or reserved HTML elements as component ' + - 'id: ' + key - ); - } + validateComponentName(key); + } +} + +function validateComponentName (name) { + if (!/^[a-zA-Z][\w-]*$/.test(name)) { + warn( + 'Invalid component name: "' + name + '". Component names ' + + 'can only contain alphanumeric characters and the hyphen, ' + + 'and must start with a letter.' + ); + } + if (isBuiltInTag(name) || config.isReservedTag(name)) { + warn( + 'Do not use built-in or reserved HTML elements as component ' + + 'id: ' + name + ); } } @@ -11424,6 +9821,7 @@ function normalizeProps (options, vm) { */ function normalizeInject (options, vm) { var inject = options.inject; + if (!inject) { return } var normalized = options.inject = {}; if (Array.isArray(inject)) { for (var i = 0; i < inject.length; i++) { @@ -11436,7 +9834,7 @@ function normalizeInject (options, vm) { ? extend({ from: key }, val) : { from: val }; } - } else if (process.env.NODE_ENV !== 'production' && inject) { + } else if (process.env.NODE_ENV !== 'production') { warn( "Invalid value for option \"inject\": expected an Array or an Object, " + "but got " + (toRawType(inject)) + ".", @@ -11560,12 +9958,18 @@ function validateProp ( var prop = propOptions[key]; var absent = !hasOwn(propsData, key); var value = propsData[key]; - // handle boolean props - if (isType(Boolean, prop.type)) { + // boolean casting + var booleanIndex = getTypeIndex(Boolean, prop.type); + if (booleanIndex > -1) { if (absent && !hasOwn(prop, 'default')) { value = false; - } else if (!isType(String, prop.type) && (value === '' || value === hyphenate(key))) { - value = true; + } else if (value === '' || value === hyphenate(key)) { + // only cast empty string / same name to boolean if + // boolean has higher priority + var stringIndex = getTypeIndex(String, prop.type); + if (stringIndex < 0 || booleanIndex < stringIndex) { + value = true; + } } } // check default value @@ -11573,12 +9977,16 @@ function validateProp ( value = getPropDefaultValue(vm, prop, key); // since the default value is a fresh copy, // make sure to observe it. - var prevShouldConvert = observerState.shouldConvert; - observerState.shouldConvert = true; + var prevShouldObserve = shouldObserve; + toggleObserving(true); observe(value); - observerState.shouldConvert = prevShouldConvert; + toggleObserving(prevShouldObserve); } - if (process.env.NODE_ENV !== 'production') { + if ( + process.env.NODE_ENV !== 'production' && + // skip validation for weex recycle-list child component props + !(false && isObject(value) && ('@binding' in value)) + ) { assertProp(prop, key, value, vm, absent); } return value @@ -11705,17 +10113,20 @@ function getType (fn) { return match ? match[1] : '' } -function isType (type, fn) { - if (!Array.isArray(fn)) { - return getType(fn) === getType(type) +function isSameType (a, b) { + return getType(a) === getType(b) +} + +function getTypeIndex (type, expectedTypes) { + if (!Array.isArray(expectedTypes)) { + return isSameType(expectedTypes, type) ? 0 : -1 } - for (var i = 0, len = fn.length; i < len; i++) { - if (getType(fn[i]) === getType(type)) { - return true + for (var i = 0, len = expectedTypes.length; i < len; i++) { + if (isSameType(expectedTypes[i], type)) { + return i } } - /* istanbul ignore next */ - return false + return -1 } /* */ @@ -11756,7 +10167,7 @@ function logError (err, vm, info) { warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm); } /* istanbul ignore else */ - if (inBrowser && typeof console !== 'undefined') { + if ((inBrowser || inWeex) && typeof console !== 'undefined') { console.error(err); } else { throw err @@ -11778,19 +10189,19 @@ function flushCallbacks () { } } -// Here we have async deferring wrappers using both micro and macro tasks. -// In < 2.4 we used micro tasks everywhere, but there are some scenarios where -// micro tasks have too high a priority and fires in between supposedly +// Here we have async deferring wrappers using both microtasks and (macro) tasks. +// In < 2.4 we used microtasks everywhere, but there are some scenarios where +// microtasks have too high a priority and fire in between supposedly // sequential events (e.g. #4521, #6690) or even between bubbling of the same -// event (#6566). However, using macro tasks everywhere also has subtle problems +// event (#6566). However, using (macro) tasks everywhere also has subtle problems // when state is changed right before repaint (e.g. #6813, out-in transitions). -// Here we use micro task by default, but expose a way to force macro task when +// Here we use microtask by default, but expose a way to force (macro) task when // needed (e.g. in event handlers attached by v-on). var microTimerFunc; var macroTimerFunc; var useMacroTask = false; -// Determine (macro) Task defer implementation. +// Determine (macro) task defer implementation. // Technically setImmediate should be the ideal choice, but it's only available // in IE. The only polyfill that consistently queues the callback after all DOM // events triggered in the same loop is by using MessageChannel. @@ -11817,7 +10228,7 @@ if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) { }; } -// Determine MicroTask defer implementation. +// Determine microtask defer implementation. /* istanbul ignore next, $flow-disable-line */ if (typeof Promise !== 'undefined' && isNative(Promise)) { var p = Promise.resolve(); @@ -11837,7 +10248,7 @@ if (typeof Promise !== 'undefined' && isNative(Promise)) { /** * Wrap a function so that if any code inside triggers state change, - * the changes are queued using a Task instead of a MicroTask. + * the changes are queued using a (macro) task instead of a microtask. */ function withMacroTask (fn) { return fn._withTask || (fn._withTask = function () { @@ -11903,8 +10314,7 @@ if (process.env.NODE_ENV !== 'production') { }; var hasProxy = - typeof Proxy !== 'undefined' && - Proxy.toString().match(/native code/); + typeof Proxy !== 'undefined' && isNative(Proxy); if (hasProxy) { var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact'); @@ -11955,6 +10365,43 @@ if (process.env.NODE_ENV !== 'production') { }; } +/* */ + +var seenObjects = new _Set(); + +/** + * Recursively traverse an object to evoke all converted + * getters, so that every nested property inside the object + * is collected as a "deep" dependency. + */ +function traverse (val) { + _traverse(val, seenObjects); + seenObjects.clear(); +} + +function _traverse (val, seen) { + var i, keys; + var isA = Array.isArray(val); + if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) { + return + } + if (val.__ob__) { + var depId = val.__ob__.dep.id; + if (seen.has(depId)) { + return + } + seen.add(depId); + } + if (isA) { + i = val.length; + while (i--) { _traverse(val[i], seen); } + } else { + keys = Object.keys(val); + i = keys.length; + while (i--) { _traverse(val[keys[i]], seen); } + } +} + var mark; var measure; @@ -12021,11 +10468,12 @@ function updateListeners ( remove$$1, vm ) { - var name, cur, old, event; + var name, def, cur, old, event; for (name in on) { - cur = on[name]; + def = cur = on[name]; old = oldOn[name]; event = normalizeEvent(name); + /* istanbul ignore if */ if (isUndef(cur)) { process.env.NODE_ENV !== 'production' && warn( "Invalid handler for event \"" + (event.name) + "\": got " + String(cur), @@ -12035,7 +10483,7 @@ function updateListeners ( if (isUndef(cur.fns)) { cur = on[name] = createFnInvoker(cur); } - add(event.name, cur, event.once, event.capture, event.passive); + add(event.name, cur, event.once, event.capture, event.passive, event.params); } else if (cur !== old) { old.fns = cur; on[name] = old; @@ -12052,6 +10500,9 @@ function updateListeners ( /* */ function mergeVNodeHook (def, hookKey, hook) { + if (def instanceof VNode) { + def = def.data.hook || (def.data.hook = {}); + } var invoker; var oldHook = def[hookKey]; @@ -12419,6 +10870,7 @@ function updateComponentListeners ( ) { target = vm; updateListeners(listeners, oldListeners || {}, add, remove$1, vm); + target = undefined; } function eventsMixin (Vue) { @@ -12474,7 +10926,7 @@ function eventsMixin (Vue) { if (!cbs) { return vm } - if (arguments.length === 1) { + if (!fn) { vm._events[event] = null; return vm } @@ -12525,6 +10977,8 @@ function eventsMixin (Vue) { /* */ + + /** * Runtime helper for resolving raw children VNodes into a slot object. */ @@ -12536,7 +10990,6 @@ function resolveSlots ( if (!children) { return slots } - var defaultSlot = []; for (var i = 0, l = children.length; i < l; i++) { var child = children[i]; var data = child.data; @@ -12546,29 +10999,31 @@ function resolveSlots ( } // named slots should only be respected if the vnode was rendered in the // same context. - if ((child.context === context || child.functionalContext === context) && + if ((child.context === context || child.fnContext === context) && data && data.slot != null ) { - var name = child.data.slot; + var name = data.slot; var slot = (slots[name] || (slots[name] = [])); if (child.tag === 'template') { - slot.push.apply(slot, child.children); + slot.push.apply(slot, child.children || []); } else { slot.push(child); } } else { - defaultSlot.push(child); + (slots.default || (slots.default = [])).push(child); } } - // ignore whitespace - if (!defaultSlot.every(isWhitespace)) { - slots.default = defaultSlot; + // ignore slots that contains only whitespace + for (var name$1 in slots) { + if (slots[name$1].every(isWhitespace)) { + delete slots[name$1]; + } } return slots } function isWhitespace (node) { - return node.isComment || node.text === ' ' + return (node.isComment && !node.asyncFactory) || node.text === ' ' } function resolveScopedSlots ( @@ -12764,7 +11219,10 @@ function mountComponent ( }; } - vm._watcher = new Watcher(vm, updateComponent, noop); + // we set this to vm._watcher inside the watcher's constructor + // since the watcher's initial patch may call $forceUpdate (e.g. inside child + // component's mounted hook), which relies on vm._watcher being already defined + new Watcher(vm, updateComponent, noop, null, true /* isRenderWatcher */); hydrating = false; // manually mounted instance, call mounted on self @@ -12807,29 +11265,30 @@ function updateChildComponent ( // update $attrs and $listeners hash // these are also reactive so they may trigger child update if the child // used them during render - vm.$attrs = (parentVnode.data && parentVnode.data.attrs) || emptyObject; + vm.$attrs = parentVnode.data.attrs || emptyObject; vm.$listeners = listeners || emptyObject; // update props if (propsData && vm.$options.props) { - observerState.shouldConvert = false; + toggleObserving(false); var props = vm._props; var propKeys = vm.$options._propKeys || []; for (var i = 0; i < propKeys.length; i++) { var key = propKeys[i]; - props[key] = validateProp(key, vm.$options.props, propsData, vm); + var propOptions = vm.$options.props; // wtf flow? + props[key] = validateProp(key, propOptions, propsData, vm); } - observerState.shouldConvert = true; + toggleObserving(true); // keep a copy of raw propsData vm.$options.propsData = propsData; } // update listeners - if (listeners) { - var oldListeners = vm.$options._parentListeners; - vm.$options._parentListeners = listeners; - updateComponentListeners(vm, listeners, oldListeners); - } + listeners = listeners || emptyObject; + var oldListeners = vm.$options._parentListeners; + vm.$options._parentListeners = listeners; + updateComponentListeners(vm, listeners, oldListeners); + // resolve slots + force update if has children if (hasChildren) { vm.$slots = resolveSlots(renderChildren, parentVnode.context); @@ -12883,6 +11342,8 @@ function deactivateChildComponent (vm, direct) { } function callHook (vm, hook) { + // #7573 disable dep collection when invoking lifecycle hooks + pushTarget(); var handlers = vm.$options[hook]; if (handlers) { for (var i = 0, j = handlers.length; i < j; i++) { @@ -12896,6 +11357,7 @@ function callHook (vm, hook) { if (vm._hasHookEvent) { vm.$emit('hook:' + hook); } + popTarget(); } /* */ @@ -13040,7 +11502,7 @@ function queueWatcher (watcher) { /* */ -var uid$2 = 0; +var uid$1 = 0; /** * A watcher parses an expression, collects dependencies, @@ -13051,9 +11513,13 @@ var Watcher = function Watcher ( vm, expOrFn, cb, - options + options, + isRenderWatcher ) { this.vm = vm; + if (isRenderWatcher) { + vm._watcher = this; + } vm._watchers.push(this); // options if (options) { @@ -13065,7 +11531,7 @@ var Watcher = function Watcher ( this.deep = this.user = this.lazy = this.sync = false; } this.cb = cb; - this.id = ++uid$2; // uid for batching + this.id = ++uid$1; // uid for batching this.active = true; this.dirty = this.lazy; // for lazy watchers this.deps = []; @@ -13239,47 +11705,13 @@ Watcher.prototype.teardown = function teardown () { if (!this.vm._isBeingDestroyed) { remove(this.vm._watchers, this); } - var i = this.deps.length; - while (i--) { - this$1.deps[i].removeSub(this$1); - } - this.active = false; - } -}; - -/** - * Recursively traverse an object to evoke all converted - * getters, so that every nested property inside the object - * is collected as a "deep" dependency. - */ -var seenObjects = new _Set(); -function traverse (val) { - seenObjects.clear(); - _traverse(val, seenObjects); -} - -function _traverse (val, seen) { - var i, keys; - var isA = Array.isArray(val); - if ((!isA && !isObject(val)) || !Object.isExtensible(val)) { - return - } - if (val.__ob__) { - var depId = val.__ob__.dep.id; - if (seen.has(depId)) { - return - } - seen.add(depId); - } - if (isA) { - i = val.length; - while (i--) { _traverse(val[i], seen); } - } else { - keys = Object.keys(val); - i = keys.length; - while (i--) { _traverse(val[keys[i]], seen); } + var i = this.deps.length; + while (i--) { + this$1.deps[i].removeSub(this$1); + } + this.active = false; } -} +}; /* */ @@ -13324,7 +11756,9 @@ function initProps (vm, propsOptions) { var keys = vm.$options._propKeys = []; var isRoot = !vm.$parent; // root instance props should be converted - observerState.shouldConvert = isRoot; + if (!isRoot) { + toggleObserving(false); + } var loop = function ( key ) { keys.push(key); var value = validateProp(key, propsOptions, propsData, vm); @@ -13361,7 +11795,7 @@ function initProps (vm, propsOptions) { }; for (var key in propsOptions) loop( key ); - observerState.shouldConvert = true; + toggleObserving(true); } function initData (vm) { @@ -13407,17 +11841,22 @@ function initData (vm) { } function getData (data, vm) { + // #7573 disable dep collection when invoking data getters + pushTarget(); try { return data.call(vm, vm) } catch (e) { handleError(e, vm, "data()"); return {} + } finally { + popTarget(); } } var computedWatcherOptions = { lazy: true }; function initComputed (vm, computed) { + // $flow-disable-line var watchers = vm._computedWatchers = Object.create(null); // computed properties are just getters during SSR var isSSR = isServerRendering(); @@ -13548,7 +11987,7 @@ function initWatch (vm, watch) { function createWatcher ( vm, - keyOrFn, + expOrFn, handler, options ) { @@ -13559,7 +11998,7 @@ function createWatcher ( if (typeof handler === 'string') { handler = vm[handler]; } - return vm.$watch(keyOrFn, handler, options) + return vm.$watch(expOrFn, handler, options) } function stateMixin (Vue) { @@ -13623,7 +12062,7 @@ function initProvide (vm) { function initInjections (vm) { var result = resolveInject(vm.$options.inject, vm); if (result) { - observerState.shouldConvert = false; + toggleObserving(false); Object.keys(result).forEach(function (key) { /* istanbul ignore else */ if (process.env.NODE_ENV !== 'production') { @@ -13639,7 +12078,7 @@ function initInjections (vm) { defineReactive(vm, key, result[key]); } }); - observerState.shouldConvert = true; + toggleObserving(true); } } @@ -13648,18 +12087,18 @@ function resolveInject (inject, vm) { // inject is :any because flow is not smart enough to figure out cached var result = Object.create(null); var keys = hasSymbol - ? Reflect.ownKeys(inject).filter(function (key) { - /* istanbul ignore next */ - return Object.getOwnPropertyDescriptor(inject, key).enumerable - }) - : Object.keys(inject); + ? Reflect.ownKeys(inject).filter(function (key) { + /* istanbul ignore next */ + return Object.getOwnPropertyDescriptor(inject, key).enumerable + }) + : Object.keys(inject); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var provideKey = inject[key].from; var source = vm; while (source) { - if (source._provided && provideKey in source._provided) { + if (source._provided && hasOwn(source._provided, provideKey)) { result[key] = source._provided[provideKey]; break } @@ -13726,6 +12165,7 @@ function renderSlot ( bindObject ) { var scopedSlotFn = this.$scopedSlots[name]; + var nodes; if (scopedSlotFn) { // scoped slot props = props || {}; if (bindObject) { @@ -13737,19 +12177,28 @@ function renderSlot ( } props = extend(extend({}, bindObject), props); } - return scopedSlotFn(props) || fallback + nodes = scopedSlotFn(props) || fallback; } else { var slotNodes = this.$slots[name]; // warn duplicate slot usage - if (slotNodes && process.env.NODE_ENV !== 'production') { - slotNodes._rendered && warn( - "Duplicate presence of slot \"" + name + "\" found in the same render tree " + - "- this will likely cause render errors.", - this - ); + if (slotNodes) { + if (process.env.NODE_ENV !== 'production' && slotNodes._rendered) { + warn( + "Duplicate presence of slot \"" + name + "\" found in the same render tree " + + "- this will likely cause render errors.", + this + ); + } slotNodes._rendered = true; } - return slotNodes || fallback + nodes = slotNodes || fallback; + } + + var target = props && props.slot; + if (target) { + return this.$createElement('template', { slot: target }, nodes) + } else { + return nodes } } @@ -13764,6 +12213,14 @@ function resolveFilter (id) { /* */ +function isKeyNotMatch (expect, actual) { + if (Array.isArray(expect)) { + return expect.indexOf(actual) === -1 + } else { + return expect !== actual + } +} + /** * Runtime helper for checking keyCodes from config. * exposed as Vue.prototype._k @@ -13772,16 +12229,15 @@ function resolveFilter (id) { function checkKeyCodes ( eventKeyCode, key, - builtInAlias, - eventKeyName + builtInKeyCode, + eventKeyName, + builtInKeyName ) { - var keyCodes = config.keyCodes[key] || builtInAlias; - if (keyCodes) { - if (Array.isArray(keyCodes)) { - return keyCodes.indexOf(eventKeyCode) === -1 - } else { - return keyCodes !== eventKeyCode - } + var mappedKeyCode = config.keyCodes[key] || builtInKeyCode; + if (builtInKeyName && eventKeyName && !config.keyCodes[key]) { + return isKeyNotMatch(builtInKeyName, eventKeyName) + } else if (mappedKeyCode) { + return isKeyNotMatch(mappedKeyCode, eventKeyCode) } else if (eventKeyName) { return hyphenate(eventKeyName) !== key } @@ -13850,20 +12306,19 @@ function renderStatic ( index, isInFor ) { - // static trees can be rendered once and cached on the contructor options - // so every instance shares the same cached trees - var renderFns = this.$options.staticRenderFns; - var cached = renderFns.cached || (renderFns.cached = []); + var cached = this._staticTrees || (this._staticTrees = []); var tree = cached[index]; // if has already-rendered static tree and not inside v-for, - // we can reuse the same tree by doing a shallow clone. + // we can reuse the same tree. if (tree && !isInFor) { - return Array.isArray(tree) - ? cloneVNodes(tree) - : cloneVNode(tree) + return tree } // otherwise, render a fresh tree. - tree = cached[index] = renderFns[index].call(this._renderProxy, null, this); + tree = cached[index] = this.$options.staticRenderFns[index].call( + this._renderProxy, + null, + this // for render fns generated for functional component templates + ); markStatic(tree, ("__static__" + index), false); return tree } @@ -13954,6 +12409,24 @@ function FunctionalRenderContext ( Ctor ) { var options = Ctor.options; + // ensure the createElement function in functional components + // gets a unique context - this is necessary for correct named slot check + var contextVm; + if (hasOwn(parent, '_uid')) { + contextVm = Object.create(parent); + // $flow-disable-line + contextVm._original = parent; + } else { + // the context vm passed in is a functional context as well. + // in this case we want to make sure we are able to get a hold to the + // real context instance. + contextVm = parent; + // $flow-disable-line + parent = parent._original; + } + var isCompiled = isTrue(options._compiled); + var needNormalization = !isCompiled; + this.data = data; this.props = props; this.children = children; @@ -13962,12 +12435,6 @@ function FunctionalRenderContext ( this.injections = resolveInject(options.inject, parent); this.slots = function () { return resolveSlots(children, parent); }; - // ensure the createElement function in functional components - // gets a unique context - this is necessary for correct named slot check - var contextVm = Object.create(parent); - var isCompiled = isTrue(options._compiled); - var needNormalization = !isCompiled; - // support for compiled functional template if (isCompiled) { // exposing $options for renderStatic() @@ -13980,9 +12447,9 @@ function FunctionalRenderContext ( if (options._scopeId) { this._c = function (a, b, c, d) { var vnode = createElement(contextVm, a, b, c, d, needNormalization); - if (vnode) { - vnode.functionalScopeId = options._scopeId; - vnode.functionalContext = parent; + if (vnode && !Array.isArray(vnode)) { + vnode.fnScopeId = options._scopeId; + vnode.fnContext = parent; } return vnode }; @@ -14023,14 +12490,28 @@ function createFunctionalComponent ( var vnode = options.render.call(null, renderContext._c, renderContext); if (vnode instanceof VNode) { - vnode.functionalContext = contextVm; - vnode.functionalOptions = options; - if (data.slot) { - (vnode.data || (vnode.data = {})).slot = data.slot; + return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options) + } else if (Array.isArray(vnode)) { + var vnodes = normalizeChildren(vnode) || []; + var res = new Array(vnodes.length); + for (var i = 0; i < vnodes.length; i++) { + res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options); } + return res } +} - return vnode +function cloneAndMarkFunctionalResult (vnode, data, contextVm, options) { + // #7817 clone node before setting fnContext, otherwise if the node is reused + // (e.g. it was from a cached normal slot) the fnContext causes named slots + // that should not be matched to match. + var clone = cloneVNode(vnode); + clone.fnContext = contextVm; + clone.fnOptions = options; + if (data.slot) { + (clone.data || (clone.data = {})).slot = data.slot; + } + return clone } function mergeProps (to, from) { @@ -14041,7 +12522,26 @@ function mergeProps (to, from) { /* */ -// hooks to be invoked on component VNodes during patch + + + +// Register the component hook to weex native render engine. +// The hook will be triggered by native, not javascript. + + +// Updates the state of the component to weex native render engine. + +/* */ + +// https://github.com/Hanks10100/weex-native-directive/tree/master/component + +// listening on native callback + +/* */ + +/* */ + +// inline hooks to be invoked on component VNodes during patch var componentVNodeHooks = { init: function init ( vnode, @@ -14049,7 +12549,15 @@ var componentVNodeHooks = { parentElm, refElm ) { - if (!vnode.componentInstance || vnode.componentInstance._isDestroyed) { + if ( + vnode.componentInstance && + !vnode.componentInstance._isDestroyed && + vnode.data.keepAlive + ) { + // kept-alive components, treat as a patch + var mountedNode = vnode; // work around flow + componentVNodeHooks.prepatch(mountedNode, mountedNode); + } else { var child = vnode.componentInstance = createComponentInstanceForVnode( vnode, activeInstance, @@ -14057,10 +12565,6 @@ var componentVNodeHooks = { refElm ); child.$mount(hydrating ? vnode.elm : undefined, hydrating); - } else if (vnode.data.keepAlive) { - // kept-alive components, treat as a patch - var mountedNode = vnode; // work around flow - componentVNodeHooks.prepatch(mountedNode, mountedNode); } }, @@ -14195,8 +12699,8 @@ function createComponent ( } } - // merge component management hooks onto the placeholder node - mergeHooks(data); + // install component management hooks onto the placeholder node + installComponentHooks(data); // return a placeholder vnode var name = Ctor.options.name || tag; @@ -14206,6 +12710,11 @@ function createComponent ( { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children }, asyncFactory ); + + // Weex specific: invoke recycle-list optimized @render function for + // extracting cell-slot template. + // https://github.com/Hanks10100/weex-native-directive/tree/master/component + /* istanbul ignore if */ return vnode } @@ -14215,15 +12724,10 @@ function createComponentInstanceForVnode ( parentElm, refElm ) { - var vnodeComponentOptions = vnode.componentOptions; var options = { _isComponent: true, parent: parent, - propsData: vnodeComponentOptions.propsData, - _componentTag: vnodeComponentOptions.tag, _parentVnode: vnode, - _parentListeners: vnodeComponentOptions.listeners, - _renderChildren: vnodeComponentOptions.children, _parentElm: parentElm || null, _refElm: refElm || null }; @@ -14233,25 +12737,14 @@ function createComponentInstanceForVnode ( options.render = inlineTemplate.render; options.staticRenderFns = inlineTemplate.staticRenderFns; } - return new vnodeComponentOptions.Ctor(options) + return new vnode.componentOptions.Ctor(options) } -function mergeHooks (data) { - if (!data.hook) { - data.hook = {}; - } +function installComponentHooks (data) { + var hooks = data.hook || (data.hook = {}); for (var i = 0; i < hooksToMerge.length; i++) { var key = hooksToMerge[i]; - var fromParent = data.hook[key]; - var ours = componentVNodeHooks[key]; - data.hook[key] = fromParent ? mergeHook$1(ours, fromParent) : ours; - } -} - -function mergeHook$1 (one, two) { - return function (a, b, c, d) { - one(a, b, c, d); - two(a, b, c, d); + hooks[key] = componentVNodeHooks[key]; } } @@ -14321,11 +12814,13 @@ function _createElement ( if (process.env.NODE_ENV !== 'production' && isDef(data) && isDef(data.key) && !isPrimitive(data.key) ) { - warn( - 'Avoid using non-primitive value as key, ' + - 'use string/number value instead.', - context - ); + { + warn( + 'Avoid using non-primitive value as key, ' + + 'use string/number value instead.', + context + ); + } } // support single function children as default scoped slot if (Array.isArray(children) && @@ -14366,8 +12861,11 @@ function _createElement ( // direct component options / constructor vnode = createComponent(tag, data, context, children); } - if (isDef(vnode)) { - if (ns) { applyNS(vnode, ns); } + if (Array.isArray(vnode)) { + return vnode + } else if (isDef(vnode)) { + if (isDef(ns)) { applyNS(vnode, ns); } + if (isDef(data)) { registerDeepBindings(data); } return vnode } else { return createEmptyVNode() @@ -14384,17 +12882,31 @@ function applyNS (vnode, ns, force) { if (isDef(vnode.children)) { for (var i = 0, l = vnode.children.length; i < l; i++) { var child = vnode.children[i]; - if (isDef(child.tag) && (isUndef(child.ns) || isTrue(force))) { + if (isDef(child.tag) && ( + isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) { applyNS(child, ns, force); } } } } +// ref #5318 +// necessary to ensure parent re-render when deep bindings like :style and +// :class are used on slot nodes +function registerDeepBindings (data) { + if (isObject(data.style)) { + traverse(data.style); + } + if (isObject(data.class)) { + traverse(data.class); + } +} + /* */ function initRender (vm) { vm._vnode = null; // the root of the child tree + vm._staticTrees = null; // v-once cached trees var options = vm.$options; var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree var renderContext = parentVnode && parentVnode.context; @@ -14441,18 +12953,17 @@ function renderMixin (Vue) { var render = ref.render; var _parentVnode = ref._parentVnode; - if (vm._isMounted) { - // if the parent didn't update, the slot nodes will be the ones from - // last render. They need to be cloned to ensure "freshness" for this render. + // reset _rendered flag on slots for duplicate slot check + if (process.env.NODE_ENV !== 'production') { for (var key in vm.$slots) { - var slot = vm.$slots[key]; - if (slot._rendered) { - vm.$slots[key] = cloneVNodes(slot, true /* deep */); - } + // $flow-disable-line + vm.$slots[key]._rendered = false; } } - vm.$scopedSlots = (_parentVnode && _parentVnode.data.scopedSlots) || emptyObject; + if (_parentVnode) { + vm.$scopedSlots = _parentVnode.data.scopedSlots || emptyObject; + } // set parent vnode. this allows render functions to have access // to the data on the placeholder node. @@ -14500,13 +13011,13 @@ function renderMixin (Vue) { /* */ -var uid = 0; +var uid$3 = 0; function initMixin (Vue) { Vue.prototype._init = function (options) { var vm = this; // a uid - vm._uid = uid++; + vm._uid = uid$3++; var startTag, endTag; /* istanbul ignore if */ @@ -14564,14 +13075,18 @@ function initMixin (Vue) { function initInternalComponent (vm, options) { var opts = vm.$options = Object.create(vm.constructor.options); // doing this because it's faster than dynamic enumeration. + var parentVnode = options._parentVnode; opts.parent = options.parent; - opts.propsData = options.propsData; - opts._parentVnode = options._parentVnode; - opts._parentListeners = options._parentListeners; - opts._renderChildren = options._renderChildren; - opts._componentTag = options._componentTag; + opts._parentVnode = parentVnode; opts._parentElm = options._parentElm; opts._refElm = options._refElm; + + var vnodeComponentOptions = parentVnode.componentOptions; + opts.propsData = vnodeComponentOptions.propsData; + opts._parentListeners = vnodeComponentOptions.listeners; + opts._renderChildren = vnodeComponentOptions.children; + opts._componentTag = vnodeComponentOptions.tag; + if (options.render) { opts.render = options.render; opts.staticRenderFns = options.staticRenderFns; @@ -14635,20 +13150,20 @@ function dedupe (latest, extended, sealed) { } } -function Vue$3 (options) { +function Vue (options) { if (process.env.NODE_ENV !== 'production' && - !(this instanceof Vue$3) + !(this instanceof Vue) ) { warn('Vue is a constructor and should be called with the `new` keyword'); } this._init(options); } -initMixin(Vue$3); -stateMixin(Vue$3); -eventsMixin(Vue$3); -lifecycleMixin(Vue$3); -renderMixin(Vue$3); +initMixin(Vue); +stateMixin(Vue); +eventsMixin(Vue); +lifecycleMixin(Vue); +renderMixin(Vue); /* */ @@ -14705,14 +13220,8 @@ function initExtend (Vue) { } var name = extendOptions.name || Super.options.name; - if (process.env.NODE_ENV !== 'production') { - if (!/^[a-zA-Z][\w-]*$/.test(name)) { - warn( - 'Invalid component name: "' + name + '". Component names ' + - 'can only contain alphanumeric characters and the hyphen, ' + - 'and must start with a letter.' - ); - } + if (process.env.NODE_ENV !== 'production' && name) { + validateComponentName(name); } var Sub = function VueComponent (options) { @@ -14794,13 +13303,8 @@ function initAssetRegisters (Vue) { return this.options[type + 's'][id] } else { /* istanbul ignore if */ - if (process.env.NODE_ENV !== 'production') { - if (type === 'component' && config.isReservedTag(id)) { - warn( - 'Do not use built-in or reserved HTML elements as component ' + - 'id: ' + id - ); - } + if (process.env.NODE_ENV !== 'production' && type === 'component') { + validateComponentName(id); } if (type === 'component' && isPlainObject(definition)) { definition.name = definition.name || id; @@ -14856,7 +13360,7 @@ function pruneCacheEntry ( current ) { var cached$$1 = cache[key]; - if (cached$$1 && cached$$1 !== current) { + if (cached$$1 && (!current || cached$$1.tag !== current.tag)) { cached$$1.componentInstance.$destroy(); } cache[key] = null; @@ -14888,31 +13392,39 @@ var KeepAlive = { } }, - watch: { - include: function include (val) { - pruneCache(this, function (name) { return matches(val, name); }); - }, - exclude: function exclude (val) { - pruneCache(this, function (name) { return !matches(val, name); }); - } + mounted: function mounted () { + var this$1 = this; + + this.$watch('include', function (val) { + pruneCache(this$1, function (name) { return matches(val, name); }); + }); + this.$watch('exclude', function (val) { + pruneCache(this$1, function (name) { return !matches(val, name); }); + }); }, render: function render () { - var vnode = getFirstComponentChild(this.$slots.default); + var slot = this.$slots.default; + var vnode = getFirstComponentChild(slot); var componentOptions = vnode && vnode.componentOptions; if (componentOptions) { // check pattern var name = getComponentName(componentOptions); - if (name && ( - (this.include && !matches(this.include, name)) || - (this.exclude && matches(this.exclude, name)) - )) { + var ref = this; + var include = ref.include; + var exclude = ref.exclude; + if ( + // not included + (include && (!name || !matches(include, name))) || + // excluded + (exclude && name && matches(exclude, name)) + ) { return vnode } - var ref = this; - var cache = ref.cache; - var keys = ref.keys; + var ref$1 = this; + var cache = ref$1.cache; + var keys = ref$1.keys; var key = vnode.key == null // same constructor may get registered as different local components // so cid alone is not enough (#3269) @@ -14934,13 +13446,13 @@ var KeepAlive = { vnode.data.keepAlive = true; } - return vnode + return vnode || (slot && slot[0]) } -}; +} var builtInComponents = { KeepAlive: KeepAlive -}; +} /* */ @@ -14988,20 +13500,25 @@ function initGlobalAPI (Vue) { initAssetRegisters(Vue); } -initGlobalAPI(Vue$3); +initGlobalAPI(Vue); -Object.defineProperty(Vue$3.prototype, '$isServer', { +Object.defineProperty(Vue.prototype, '$isServer', { get: isServerRendering }); -Object.defineProperty(Vue$3.prototype, '$ssrContext', { +Object.defineProperty(Vue.prototype, '$ssrContext', { get: function get () { /* istanbul ignore next */ return this.$vnode && this.$vnode.ssrContext } }); -Vue$3.version = '2.5.2'; +// expose FunctionalRenderContext for ssr runtime helper installation +Object.defineProperty(Vue, 'FunctionalRenderContext', { + value: FunctionalRenderContext +}); + +Vue.version = '2.5.16'; /* */ @@ -15053,12 +13570,12 @@ function genClassForVnode (vnode) { var childNode = vnode; while (isDef(childNode.componentInstance)) { childNode = childNode.componentInstance._vnode; - if (childNode.data) { + if (childNode && childNode.data) { data = mergeClassData(childNode.data, data); } } while (isDef(parentNode = parentNode.parent)) { - if (parentNode.data) { + if (parentNode && parentNode.data) { data = mergeClassData(data, parentNode.data); } } @@ -15275,8 +13792,8 @@ function setTextContent (node, text) { node.textContent = text; } -function setAttribute (node, key, val) { - node.setAttribute(key, val); +function setStyleScope (node, scopeId) { + node.setAttribute(scopeId, ''); } @@ -15292,7 +13809,7 @@ var nodeOps = Object.freeze({ nextSibling: nextSibling, tagName: tagName, setTextContent: setTextContent, - setAttribute: setAttribute + setStyleScope: setStyleScope }); /* */ @@ -15310,11 +13827,11 @@ var ref = { destroy: function destroy (vnode) { registerRef(vnode, true); } -}; +} function registerRef (vnode, isRemoval) { var key = vnode.data.ref; - if (!key) { return } + if (!isDef(key)) { return } var vm = vnode.context; var ref = vnode.componentInstance || vnode.elm; @@ -15428,8 +13945,42 @@ function createPatchFunction (backend) { } } - var inPre = 0; - function createElm (vnode, insertedVnodeQueue, parentElm, refElm, nested) { + function isUnknownElement$$1 (vnode, inVPre) { + return ( + !inVPre && + !vnode.ns && + !( + config.ignoredElements.length && + config.ignoredElements.some(function (ignore) { + return isRegExp(ignore) + ? ignore.test(vnode.tag) + : ignore === vnode.tag + }) + ) && + config.isUnknownElement(vnode.tag) + ) + } + + var creatingElmInVPre = 0; + + function createElm ( + vnode, + insertedVnodeQueue, + parentElm, + refElm, + nested, + ownerArray, + index + ) { + if (isDef(vnode.elm) && isDef(ownerArray)) { + // This vnode was used in a previous render! + // now it's used as a new node, overwriting its elm would cause + // potential patch errors down the road when it's used as an insertion + // reference node. Instead, we clone the node on-demand before creating + // associated DOM element for it. + vnode = ownerArray[index] = cloneVNode(vnode); + } + vnode.isRootInsert = !nested; // for transition enter check if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) { return @@ -15441,21 +13992,9 @@ function createPatchFunction (backend) { if (isDef(tag)) { if (process.env.NODE_ENV !== 'production') { if (data && data.pre) { - inPre++; + creatingElmInVPre++; } - if ( - !inPre && - !vnode.ns && - !( - config.ignoredElements.length && - config.ignoredElements.some(function (ignore) { - return isRegExp(ignore) - ? ignore.test(tag) - : ignore === tag - }) - ) && - config.isUnknownElement(tag) - ) { + if (isUnknownElement$$1(vnode, creatingElmInVPre)) { warn( 'Unknown custom element: <' + tag + '> - did you ' + 'register the component correctly? For recursive components, ' + @@ -15464,6 +14003,7 @@ function createPatchFunction (backend) { ); } } + vnode.elm = vnode.ns ? nodeOps.createElementNS(vnode.ns, tag) : nodeOps.createElement(tag, vnode); @@ -15479,7 +14019,7 @@ function createPatchFunction (backend) { } if (process.env.NODE_ENV !== 'production' && data && data.pre) { - inPre--; + creatingElmInVPre--; } } else if (isTrue(vnode.isComment)) { vnode.elm = nodeOps.createComment(vnode.text); @@ -15565,11 +14105,14 @@ function createPatchFunction (backend) { function createChildren (vnode, children, insertedVnodeQueue) { if (Array.isArray(children)) { + if (process.env.NODE_ENV !== 'production') { + checkDuplicateKeys(children); + } for (var i = 0; i < children.length; ++i) { - createElm(children[i], insertedVnodeQueue, vnode.elm, null, true); + createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i); } } else if (isPrimitive(vnode.text)) { - nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(vnode.text)); + nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text))); } } @@ -15596,13 +14139,13 @@ function createPatchFunction (backend) { // of going through the normal attribute patching process. function setScope (vnode) { var i; - if (isDef(i = vnode.functionalScopeId)) { - nodeOps.setAttribute(vnode.elm, i, ''); + if (isDef(i = vnode.fnScopeId)) { + nodeOps.setStyleScope(vnode.elm, i); } else { var ancestor = vnode; while (ancestor) { if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) { - nodeOps.setAttribute(vnode.elm, i, ''); + nodeOps.setStyleScope(vnode.elm, i); } ancestor = ancestor.parent; } @@ -15610,16 +14153,16 @@ function createPatchFunction (backend) { // for slot content they should also get the scopeId from the host instance. if (isDef(i = activeInstance) && i !== vnode.context && - i !== vnode.functionalContext && + i !== vnode.fnContext && isDef(i = i.$options._scopeId) ) { - nodeOps.setAttribute(vnode.elm, i, ''); + nodeOps.setStyleScope(vnode.elm, i); } } function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) { for (; startIdx <= endIdx; ++startIdx) { - createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm); + createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx); } } @@ -15696,6 +14239,10 @@ function createPatchFunction (backend) { // during leaving transitions var canMove = !removeOnly; + if (process.env.NODE_ENV !== 'production') { + checkDuplicateKeys(newCh); + } + while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) { if (isUndef(oldStartVnode)) { oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left @@ -15725,23 +14272,16 @@ function createPatchFunction (backend) { ? oldKeyToIdx[newStartVnode.key] : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx); if (isUndef(idxInOld)) { // New element - createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm); + createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx); } else { vnodeToMove = oldCh[idxInOld]; - /* istanbul ignore if */ - if (process.env.NODE_ENV !== 'production' && !vnodeToMove) { - warn( - 'It seems there are duplicate keys that is causing an update error. ' + - 'Make sure each v-for item has a unique key.' - ); - } if (sameVnode(vnodeToMove, newStartVnode)) { patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue); oldCh[idxInOld] = undefined; canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm); } else { // same key but different element. treat as new element - createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm); + createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx); } } newStartVnode = newCh[++newStartIdx]; @@ -15755,6 +14295,24 @@ function createPatchFunction (backend) { } } + function checkDuplicateKeys (children) { + var seenKeys = {}; + for (var i = 0; i < children.length; i++) { + var vnode = children[i]; + var key = vnode.key; + if (isDef(key)) { + if (seenKeys[key]) { + warn( + ("Duplicate keys detected: '" + key + "'. This may cause an update error."), + vnode.context + ); + } else { + seenKeys[key] = true; + } + } + } + } + function findIdxInOld (node, oldCh, start, end) { for (var i = start; i < end; i++) { var c = oldCh[i]; @@ -15834,27 +14392,32 @@ function createPatchFunction (backend) { } } - var bailed = false; + var hydrationBailed = false; // list of modules that can skip create hook during hydration because they // are already rendered on the client or has no need for initialization - var isRenderedModule = makeMap('attrs,style,class,staticClass,staticStyle,key'); + // Note: style is excluded because it relies on initial clone for future + // deep updates (#7063). + var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key'); // Note: this is a browser-only function so we can assume elms are DOM nodes. - function hydrate (elm, vnode, insertedVnodeQueue) { + function hydrate (elm, vnode, insertedVnodeQueue, inVPre) { + var i; + var tag = vnode.tag; + var data = vnode.data; + var children = vnode.children; + inVPre = inVPre || (data && data.pre); + vnode.elm = elm; + if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) { - vnode.elm = elm; vnode.isAsyncPlaceholder = true; return true } + // assert node match if (process.env.NODE_ENV !== 'production') { - if (!assertNodeMatch(elm, vnode)) { + if (!assertNodeMatch(elm, vnode, inVPre)) { return false } } - vnode.elm = elm; - var tag = vnode.tag; - var data = vnode.data; - var children = vnode.children; if (isDef(data)) { if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); } if (isDef(i = vnode.componentInstance)) { @@ -15875,9 +14438,9 @@ function createPatchFunction (backend) { /* istanbul ignore if */ if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined' && - !bailed + !hydrationBailed ) { - bailed = true; + hydrationBailed = true; console.warn('Parent: ', elm); console.warn('server innerHTML: ', i); console.warn('client innerHTML: ', elm.innerHTML); @@ -15889,7 +14452,7 @@ function createPatchFunction (backend) { var childrenMatch = true; var childNode = elm.firstChild; for (var i$1 = 0; i$1 < children.length; i$1++) { - if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) { + if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) { childrenMatch = false; break } @@ -15901,9 +14464,9 @@ function createPatchFunction (backend) { /* istanbul ignore if */ if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined' && - !bailed + !hydrationBailed ) { - bailed = true; + hydrationBailed = true; console.warn('Parent: ', elm); console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children); } @@ -15913,12 +14476,18 @@ function createPatchFunction (backend) { } } if (isDef(data)) { + var fullInvoke = false; for (var key in data) { if (!isRenderedModule(key)) { + fullInvoke = true; invokeCreateHooks(vnode, insertedVnodeQueue); break } } + if (!fullInvoke && data['class']) { + // ensure collecting deps for deep class bindings for future updates + traverse(data['class']); + } } } else if (elm.data !== vnode.text) { elm.data = vnode.text; @@ -15926,10 +14495,10 @@ function createPatchFunction (backend) { return true } - function assertNodeMatch (node, vnode) { + function assertNodeMatch (node, vnode, inVPre) { if (isDef(vnode.tag)) { - return ( - vnode.tag.indexOf('vue-component') === 0 || + return vnode.tag.indexOf('vue-component') === 0 || ( + !isUnknownElement$$1(vnode, inVPre) && vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase()) ) } else { @@ -15982,9 +14551,12 @@ function createPatchFunction (backend) { // create an empty node and replace it oldVnode = emptyNodeAt(oldVnode); } + // replacing existing element var oldElm = oldVnode.elm; var parentElm$1 = nodeOps.parentNode(oldElm); + + // create new node createElm( vnode, insertedVnodeQueue, @@ -15995,9 +14567,8 @@ function createPatchFunction (backend) { nodeOps.nextSibling(oldElm) ); + // update parent placeholder node element, recursively if (isDef(vnode.parent)) { - // component root element replaced. - // update parent placeholder node element, recursively var ancestor = vnode.parent; var patchable = isPatchable(vnode); while (ancestor) { @@ -16026,6 +14597,7 @@ function createPatchFunction (backend) { } } + // destroy old node if (isDef(parentElm$1)) { removeVnodes(parentElm$1, [oldVnode], 0, 0); } else if (isDef(oldVnode.tag)) { @@ -16047,7 +14619,7 @@ var directives = { destroy: function unbindDirectives (vnode) { updateDirectives(vnode, emptyNode); } -}; +} function updateDirectives (oldVnode, vnode) { if (oldVnode.data.directives || vnode.data.directives) { @@ -16091,14 +14663,14 @@ function _update (oldVnode, vnode) { } }; if (isCreate) { - mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', callInsert); + mergeVNodeHook(vnode, 'insert', callInsert); } else { callInsert(); } } if (dirsWithPostpatch.length) { - mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'postpatch', function () { + mergeVNodeHook(vnode, 'postpatch', function () { for (var i = 0; i < dirsWithPostpatch.length; i++) { callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode); } @@ -16123,17 +14695,20 @@ function normalizeDirectives$1 ( ) { var res = Object.create(null); if (!dirs) { + // $flow-disable-line return res } var i, dir; for (i = 0; i < dirs.length; i++) { dir = dirs[i]; if (!dir.modifiers) { + // $flow-disable-line dir.modifiers = emptyModifiers; } res[getRawDirName(dir)] = dir; dir.def = resolveAsset(vm.$options, 'directives', dir.name, true); } + // $flow-disable-line return res } @@ -16155,7 +14730,7 @@ function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) { var baseModules = [ ref, directives -]; +] /* */ @@ -16186,7 +14761,7 @@ function updateAttrs (oldVnode, vnode) { // #4391: in IE9, setting type can reset value for input[type=radio] // #6666: IE/Edge forces progress value down to 1 before setting a max /* istanbul ignore if */ - if ((isIE9 || isEdge) && attrs.value !== oldAttrs.value) { + if ((isIE || isEdge) && attrs.value !== oldAttrs.value) { setAttr(elm, 'value', attrs.value); } for (key in oldAttrs) { @@ -16201,7 +14776,9 @@ function updateAttrs (oldVnode, vnode) { } function setAttr (el, key, value) { - if (isBooleanAttr(key)) { + if (el.tagName.indexOf('-') > -1) { + baseSetAttr(el, key, value); + } else if (isBooleanAttr(key)) { // set attribute for blank value // e.g. if (isFalsyAttrValue(value)) { @@ -16223,18 +14800,39 @@ function setAttr (el, key, value) { el.setAttributeNS(xlinkNS, key, value); } } else { - if (isFalsyAttrValue(value)) { - el.removeAttribute(key); - } else { - el.setAttribute(key, value); + baseSetAttr(el, key, value); + } +} + +function baseSetAttr (el, key, value) { + if (isFalsyAttrValue(value)) { + el.removeAttribute(key); + } else { + // #7138: IE10 & 11 fires input event when setting placeholder on + // ",o.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var qa=d.documentElement,ra=/^key/,sa=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,ta=/^([^.]*)(?:\.(.+)|)/;function ua(){return!0}function va(){return!1}function wa(){try{return d.activeElement}catch(a){}}function xa(a,b,c,d,e,f){var g,h;if("object"==typeof b){"string"!=typeof c&&(d=d||c,c=void 0);for(h in b)xa(a,h,c,d,b[h],f);return a}if(null==d&&null==e?(e=c,d=c=void 0):null==e&&("string"==typeof c?(e=d,d=void 0):(e=d,d=c,c=void 0)),e===!1)e=va;else if(!e)return a;return 1===f&&(g=e,e=function(a){return r().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=r.guid++)),a.each(function(){r.event.add(this,b,e,d,c)})}r.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=V.get(a);if(q){c.handler&&(f=c,c=f.handler,e=f.selector),e&&r.find.matchesSelector(qa,e),c.guid||(c.guid=r.guid++),(i=q.events)||(i=q.events={}),(g=q.handle)||(g=q.handle=function(b){return"undefined"!=typeof r&&r.event.triggered!==b.type?r.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(K)||[""],j=b.length;while(j--)h=ta.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n&&(l=r.event.special[n]||{},n=(e?l.delegateType:l.bindType)||n,l=r.event.special[n]||{},k=r.extend({type:n,origType:p,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&r.expr.match.needsContext.test(e),namespace:o.join(".")},f),(m=i[n])||(m=i[n]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,o,g)!==!1||a.addEventListener&&a.addEventListener(n,g)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),r.event.global[n]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=V.hasData(a)&&V.get(a);if(q&&(i=q.events)){b=(b||"").match(K)||[""],j=b.length;while(j--)if(h=ta.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n){l=r.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=i[n]||[],h=h[2]&&new RegExp("(^|\\.)"+o.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&p!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,o,q.handle)!==!1||r.removeEvent(a,n,q.handle),delete i[n])}else for(n in i)r.event.remove(a,n+b[j],c,d,!0);r.isEmptyObject(i)&&V.remove(a,"handle events")}},dispatch:function(a){var b=r.event.fix(a),c,d,e,f,g,h,i=new Array(arguments.length),j=(V.get(this,"events")||{})[b.type]||[],k=r.event.special[b.type]||{};for(i[0]=b,c=1;c=1))for(;j!==this;j=j.parentNode||this)if(1===j.nodeType&&("click"!==a.type||j.disabled!==!0)){for(f=[],g={},c=0;c-1:r.find(e,this,null,[j]).length),g[e]&&f.push(d);f.length&&h.push({elem:j,handlers:f})}return j=this,i\x20\t\r\n\f]*)[^>]*)\/>/gi,za=/\s*$/g;function Da(a,b){return r.nodeName(a,"table")&&r.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a:a}function Ea(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function Fa(a){var b=Ba.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function Ga(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(V.hasData(a)&&(f=V.access(a),g=V.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;c1&&"string"==typeof q&&!o.checkClone&&Aa.test(q))return a.each(function(e){var f=a.eq(e);s&&(b[0]=q.call(this,e,f.html())),Ia(f,b,c,d)});if(m&&(e=pa(b,a[0].ownerDocument,!1,a,d),f=e.firstChild,1===e.childNodes.length&&(e=f),f||d)){for(h=r.map(ma(e,"script"),Ea),i=h.length;l")},clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=r.contains(a.ownerDocument,a);if(!(o.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||r.isXMLDoc(a)))for(g=ma(h),f=ma(a),d=0,e=f.length;d0&&na(g,!i&&ma(a,"script")),h},cleanData:function(a){for(var b,c,d,e=r.event.special,f=0;void 0!==(c=a[f]);f++)if(T(c)){if(b=c[V.expando]){if(b.events)for(d in b.events)e[d]?r.event.remove(c,d):r.removeEvent(c,d,b.handle);c[V.expando]=void 0}c[W.expando]&&(c[W.expando]=void 0)}}}),r.fn.extend({detach:function(a){return Ja(this,a,!0)},remove:function(a){return Ja(this,a)},text:function(a){return S(this,function(a){return void 0===a?r.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=a)})},null,a,arguments.length)},append:function(){return Ia(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Da(this,a);b.appendChild(a)}})},prepend:function(){return Ia(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Da(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return Ia(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return Ia(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(r.cleanData(ma(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null!=a&&a,b=null==b?a:b,this.map(function(){return r.clone(this,a,b)})},html:function(a){return S(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!za.test(a)&&!la[(ja.exec(a)||["",""])[1].toLowerCase()]){a=r.htmlPrefilter(a);try{for(;c1)}});function Ya(a,b,c,d,e){return new Ya.prototype.init(a,b,c,d,e)}r.Tween=Ya,Ya.prototype={constructor:Ya,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||r.easing._default,this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(r.cssNumber[c]?"":"px")},cur:function(){var a=Ya.propHooks[this.prop];return a&&a.get?a.get(this):Ya.propHooks._default.get(this)},run:function(a){var b,c=Ya.propHooks[this.prop];return this.options.duration?this.pos=b=r.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):this.pos=b=a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Ya.propHooks._default.set(this),this}},Ya.prototype.init.prototype=Ya.prototype,Ya.propHooks={_default:{get:function(a){var b;return 1!==a.elem.nodeType||null!=a.elem[a.prop]&&null==a.elem.style[a.prop]?a.elem[a.prop]:(b=r.css(a.elem,a.prop,""),b&&"auto"!==b?b:0)},set:function(a){r.fx.step[a.prop]?r.fx.step[a.prop](a):1!==a.elem.nodeType||null==a.elem.style[r.cssProps[a.prop]]&&!r.cssHooks[a.prop]?a.elem[a.prop]=a.now:r.style(a.elem,a.prop,a.now+a.unit)}}},Ya.propHooks.scrollTop=Ya.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},r.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2},_default:"swing"},r.fx=Ya.prototype.init,r.fx.step={};var Za,$a,_a=/^(?:toggle|show|hide)$/,ab=/queueHooks$/;function bb(){$a&&(a.requestAnimationFrame(bb),r.fx.tick())}function cb(){return a.setTimeout(function(){Za=void 0}),Za=r.now()}function db(a,b){var c,d=0,e={height:a};for(b=b?1:0;d<4;d+=2-b)c=ba[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function eb(a,b,c){for(var d,e=(hb.tweeners[b]||[]).concat(hb.tweeners["*"]),f=0,g=e.length;f1)},removeAttr:function(a){return this.each(function(){r.removeAttr(this,a)})}}),r.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return"undefined"==typeof a.getAttribute?r.prop(a,b,c):(1===f&&r.isXMLDoc(a)||(e=r.attrHooks[b.toLowerCase()]||(r.expr.match.bool.test(b)?ib:void 0)), void 0!==c?null===c?void r.removeAttr(a,b):e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:(a.setAttribute(b,c+""),c):e&&"get"in e&&null!==(d=e.get(a,b))?d:(d=r.find.attr(a,b),null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"===b&&r.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}},removeAttr:function(a,b){var c,d=0,e=b&&b.match(K);if(e&&1===a.nodeType)while(c=e[d++])a.removeAttribute(c)}}),ib={set:function(a,b,c){return b===!1?r.removeAttr(a,c):a.setAttribute(c,c),c}},r.each(r.expr.match.bool.source.match(/\w+/g),function(a,b){var c=jb[b]||r.find.attr;jb[b]=function(a,b,d){var e,f,g=b.toLowerCase();return d||(f=jb[g],jb[g]=e,e=null!=c(a,b,d)?g:null,jb[g]=f),e}});var kb=/^(?:input|select|textarea|button)$/i,lb=/^(?:a|area)$/i;r.fn.extend({prop:function(a,b){return S(this,r.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[r.propFix[a]||a]})}}),r.extend({prop:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return 1===f&&r.isXMLDoc(a)||(b=r.propFix[b]||b,e=r.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=r.find.attr(a,"tabindex");return b?parseInt(b,10):kb.test(a.nodeName)||lb.test(a.nodeName)&&a.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),o.optSelected||(r.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null},set:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}}),r.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){r.propFix[this.toLowerCase()]=this});function mb(a){var b=a.match(K)||[];return b.join(" ")}function nb(a){return a.getAttribute&&a.getAttribute("class")||""}r.fn.extend({addClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).addClass(a.call(this,b,nb(this)))});if("string"==typeof a&&a){b=a.match(K)||[];while(c=this[i++])if(e=nb(c),d=1===c.nodeType&&" "+mb(e)+" "){g=0;while(f=b[g++])d.indexOf(" "+f+" ")<0&&(d+=f+" ");h=mb(d),e!==h&&c.setAttribute("class",h)}}return this},removeClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).removeClass(a.call(this,b,nb(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof a&&a){b=a.match(K)||[];while(c=this[i++])if(e=nb(c),d=1===c.nodeType&&" "+mb(e)+" "){g=0;while(f=b[g++])while(d.indexOf(" "+f+" ")>-1)d=d.replace(" "+f+" "," ");h=mb(d),e!==h&&c.setAttribute("class",h)}}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):r.isFunction(a)?this.each(function(c){r(this).toggleClass(a.call(this,c,nb(this),b),b)}):this.each(function(){var b,d,e,f;if("string"===c){d=0,e=r(this),f=a.match(K)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else void 0!==a&&"boolean"!==c||(b=nb(this),b&&V.set(this,"__className__",b),this.setAttribute&&this.setAttribute("class",b||a===!1?"":V.get(this,"__className__")||""))})},hasClass:function(a){var b,c,d=0;b=" "+a+" ";while(c=this[d++])if(1===c.nodeType&&(" "+mb(nb(c))+" ").indexOf(b)>-1)return!0;return!1}});var ob=/\r/g;r.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=r.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,r(this).val()):a,null==e?e="":"number"==typeof e?e+="":r.isArray(e)&&(e=r.map(e,function(a){return null==a?"":a+""})),b=r.valHooks[this.type]||r.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=r.valHooks[e.type]||r.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(ob,""):null==c?"":c)}}}),r.extend({valHooks:{option:{get:function(a){var b=r.find.attr(a,"value");return null!=b?b:mb(r.text(a))}},select:{get:function(a){var b,c,d,e=a.options,f=a.selectedIndex,g="select-one"===a.type,h=g?null:[],i=g?f+1:e.length;for(d=f<0?i:g?f:0;d-1)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),r.each(["radio","checkbox"],function(){r.valHooks[this]={set:function(a,b){if(r.isArray(b))return a.checked=r.inArray(r(a).val(),b)>-1}},o.checkOn||(r.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var pb=/^(?:focusinfocus|focusoutblur)$/;r.extend(r.event,{trigger:function(b,c,e,f){var g,h,i,j,k,m,n,o=[e||d],p=l.call(b,"type")?b.type:b,q=l.call(b,"namespace")?b.namespace.split("."):[];if(h=i=e=e||d,3!==e.nodeType&&8!==e.nodeType&&!pb.test(p+r.event.triggered)&&(p.indexOf(".")>-1&&(q=p.split("."),p=q.shift(),q.sort()),k=p.indexOf(":")<0&&"on"+p,b=b[r.expando]?b:new r.Event(p,"object"==typeof b&&b),b.isTrigger=f?2:3,b.namespace=q.join("."),b.rnamespace=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=e),c=null==c?[b]:r.makeArray(c,[b]),n=r.event.special[p]||{},f||!n.trigger||n.trigger.apply(e,c)!==!1)){if(!f&&!n.noBubble&&!r.isWindow(e)){for(j=n.delegateType||p,pb.test(j+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),i=h;i===(e.ownerDocument||d)&&o.push(i.defaultView||i.parentWindow||a)}g=0;while((h=o[g++])&&!b.isPropagationStopped())b.type=g>1?j:n.bindType||p,m=(V.get(h,"events")||{})[b.type]&&V.get(h,"handle"),m&&m.apply(h,c),m=k&&h[k],m&&m.apply&&T(h)&&(b.result=m.apply(h,c),b.result===!1&&b.preventDefault());return b.type=p,f||b.isDefaultPrevented()||n._default&&n._default.apply(o.pop(),c)!==!1||!T(e)||k&&r.isFunction(e[p])&&!r.isWindow(e)&&(i=e[k],i&&(e[k]=null),r.event.triggered=p,e[p](),r.event.triggered=void 0,i&&(e[k]=i)),b.result}},simulate:function(a,b,c){var d=r.extend(new r.Event,c,{type:a,isSimulated:!0});r.event.trigger(d,null,b)}}),r.fn.extend({trigger:function(a,b){return this.each(function(){r.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];if(c)return r.event.trigger(a,b,c,!0)}}),r.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(a,b){r.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),r.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}}),o.focusin="onfocusin"in a,o.focusin||r.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){r.event.simulate(b,a.target,r.event.fix(a))};r.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=V.access(d,b);e||d.addEventListener(a,c,!0),V.access(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=V.access(d,b)-1;e?V.access(d,b,e):(d.removeEventListener(a,c,!0),V.remove(d,b))}}});var qb=a.location,rb=r.now(),sb=/\?/;r.parseXML=function(b){var c;if(!b||"string"!=typeof b)return null;try{c=(new a.DOMParser).parseFromString(b,"text/xml")}catch(d){c=void 0}return c&&!c.getElementsByTagName("parsererror").length||r.error("Invalid XML: "+b),c};var tb=/\[\]$/,ub=/\r?\n/g,vb=/^(?:submit|button|image|reset|file)$/i,wb=/^(?:input|select|textarea|keygen)/i;function xb(a,b,c,d){var e;if(r.isArray(b))r.each(b,function(b,e){c||tb.test(a)?d(a,e):xb(a+"["+("object"==typeof e&&null!=e?b:"")+"]",e,c,d)});else if(c||"object"!==r.type(b))d(a,b);else for(e in b)xb(a+"["+e+"]",b[e],c,d)}r.param=function(a,b){var c,d=[],e=function(a,b){var c=r.isFunction(b)?b():b;d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(null==c?"":c)};if(r.isArray(a)||a.jquery&&!r.isPlainObject(a))r.each(a,function(){e(this.name,this.value)});else for(c in a)xb(c,a[c],b,e);return d.join("&")},r.fn.extend({serialize:function(){return r.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=r.prop(this,"elements");return a?r.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!r(this).is(":disabled")&&wb.test(this.nodeName)&&!vb.test(a)&&(this.checked||!ia.test(a))}).map(function(a,b){var c=r(this).val();return null==c?null:r.isArray(c)?r.map(c,function(a){return{name:b.name,value:a.replace(ub,"\r\n")}}):{name:b.name,value:c.replace(ub,"\r\n")}}).get()}});var yb=/%20/g,zb=/#.*$/,Ab=/([?&])_=[^&]*/,Bb=/^(.*?):[ \t]*([^\r\n]*)$/gm,Cb=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Db=/^(?:GET|HEAD)$/,Eb=/^\/\//,Fb={},Gb={},Hb="*/".concat("*"),Ib=d.createElement("a");Ib.href=qb.href;function Jb(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(K)||[];if(r.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function Kb(a,b,c,d){var e={},f=a===Gb;function g(h){var i;return e[h]=!0,r.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function Lb(a,b){var c,d,e=r.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&r.extend(!0,a,d),a}function Mb(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}if(f)return f!==i[0]&&i.unshift(f),c[f]}function Nb(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}r.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:qb.href,type:"GET",isLocal:Cb.test(qb.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Hb,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":r.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?Lb(Lb(a,r.ajaxSettings),b):Lb(r.ajaxSettings,a)},ajaxPrefilter:Jb(Fb),ajaxTransport:Jb(Gb),ajax:function(b,c){"object"==typeof b&&(c=b,b=void 0),c=c||{};var e,f,g,h,i,j,k,l,m,n,o=r.ajaxSetup({},c),p=o.context||o,q=o.context&&(p.nodeType||p.jquery)?r(p):r.event,s=r.Deferred(),t=r.Callbacks("once memory"),u=o.statusCode||{},v={},w={},x="canceled",y={readyState:0,getResponseHeader:function(a){var b;if(k){if(!h){h={};while(b=Bb.exec(g))h[b[1].toLowerCase()]=b[2]}b=h[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return k?g:null},setRequestHeader:function(a,b){return null==k&&(a=w[a.toLowerCase()]=w[a.toLowerCase()]||a,v[a]=b),this},overrideMimeType:function(a){return null==k&&(o.mimeType=a),this},statusCode:function(a){var b;if(a)if(k)y.always(a[y.status]);else for(b in a)u[b]=[u[b],a[b]];return this},abort:function(a){var b=a||x;return e&&e.abort(b),A(0,b),this}};if(s.promise(y),o.url=((b||o.url||qb.href)+"").replace(Eb,qb.protocol+"//"),o.type=c.method||c.type||o.method||o.type,o.dataTypes=(o.dataType||"*").toLowerCase().match(K)||[""],null==o.crossDomain){j=d.createElement("a");try{j.href=o.url,j.href=j.href,o.crossDomain=Ib.protocol+"//"+Ib.host!=j.protocol+"//"+j.host}catch(z){o.crossDomain=!0}}if(o.data&&o.processData&&"string"!=typeof o.data&&(o.data=r.param(o.data,o.traditional)),Kb(Fb,o,c,y),k)return y;l=r.event&&o.global,l&&0===r.active++&&r.event.trigger("ajaxStart"),o.type=o.type.toUpperCase(),o.hasContent=!Db.test(o.type),f=o.url.replace(zb,""),o.hasContent?o.data&&o.processData&&0===(o.contentType||"").indexOf("application/x-www-form-urlencoded")&&(o.data=o.data.replace(yb,"+")):(n=o.url.slice(f.length),o.data&&(f+=(sb.test(f)?"&":"?")+o.data,delete o.data),o.cache===!1&&(f=f.replace(Ab,"$1"),n=(sb.test(f)?"&":"?")+"_="+rb++ +n),o.url=f+n),o.ifModified&&(r.lastModified[f]&&y.setRequestHeader("If-Modified-Since",r.lastModified[f]),r.etag[f]&&y.setRequestHeader("If-None-Match",r.etag[f])),(o.data&&o.hasContent&&o.contentType!==!1||c.contentType)&&y.setRequestHeader("Content-Type",o.contentType),y.setRequestHeader("Accept",o.dataTypes[0]&&o.accepts[o.dataTypes[0]]?o.accepts[o.dataTypes[0]]+("*"!==o.dataTypes[0]?", "+Hb+"; q=0.01":""):o.accepts["*"]);for(m in o.headers)y.setRequestHeader(m,o.headers[m]);if(o.beforeSend&&(o.beforeSend.call(p,y,o)===!1||k))return y.abort();if(x="abort",t.add(o.complete),y.done(o.success),y.fail(o.error),e=Kb(Gb,o,c,y)){if(y.readyState=1,l&&q.trigger("ajaxSend",[y,o]),k)return y;o.async&&o.timeout>0&&(i=a.setTimeout(function(){y.abort("timeout")},o.timeout));try{k=!1,e.send(v,A)}catch(z){if(k)throw z;A(-1,z)}}else A(-1,"No Transport");function A(b,c,d,h){var j,m,n,v,w,x=c;k||(k=!0,i&&a.clearTimeout(i),e=void 0,g=h||"",y.readyState=b>0?4:0,j=b>=200&&b<300||304===b,d&&(v=Mb(o,y,d)),v=Nb(o,v,y,j),j?(o.ifModified&&(w=y.getResponseHeader("Last-Modified"),w&&(r.lastModified[f]=w),w=y.getResponseHeader("etag"),w&&(r.etag[f]=w)),204===b||"HEAD"===o.type?x="nocontent":304===b?x="notmodified":(x=v.state,m=v.data,n=v.error,j=!n)):(n=x,!b&&x||(x="error",b<0&&(b=0))),y.status=b,y.statusText=(c||x)+"",j?s.resolveWith(p,[m,x,y]):s.rejectWith(p,[y,x,n]),y.statusCode(u),u=void 0,l&&q.trigger(j?"ajaxSuccess":"ajaxError",[y,o,j?m:n]),t.fireWith(p,[y,x]),l&&(q.trigger("ajaxComplete",[y,o]),--r.active||r.event.trigger("ajaxStop")))}return y},getJSON:function(a,b,c){return r.get(a,b,c,"json")},getScript:function(a,b){return r.get(a,void 0,b,"script")}}),r.each(["get","post"],function(a,b){r[b]=function(a,c,d,e){return r.isFunction(c)&&(e=e||d,d=c,c=void 0),r.ajax(r.extend({url:a,type:b,dataType:e,data:c,success:d},r.isPlainObject(a)&&a))}}),r._evalUrl=function(a){return r.ajax({url:a,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},r.fn.extend({wrapAll:function(a){var b;return this[0]&&(r.isFunction(a)&&(a=a.call(this[0])),b=r(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this},wrapInner:function(a){return r.isFunction(a)?this.each(function(b){r(this).wrapInner(a.call(this,b))}):this.each(function(){var b=r(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=r.isFunction(a);return this.each(function(c){r(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(a){return this.parent(a).not("body").each(function(){r(this).replaceWith(this.childNodes)}),this}}),r.expr.pseudos.hidden=function(a){return!r.expr.pseudos.visible(a)},r.expr.pseudos.visible=function(a){return!!(a.offsetWidth||a.offsetHeight||a.getClientRects().length)},r.ajaxSettings.xhr=function(){try{return new a.XMLHttpRequest}catch(b){}};var Ob={0:200,1223:204},Pb=r.ajaxSettings.xhr();o.cors=!!Pb&&"withCredentials"in Pb,o.ajax=Pb=!!Pb,r.ajaxTransport(function(b){var c,d;if(o.cors||Pb&&!b.crossDomain)return{send:function(e,f){var g,h=b.xhr();if(h.open(b.type,b.url,b.async,b.username,b.password),b.xhrFields)for(g in b.xhrFields)h[g]=b.xhrFields[g];b.mimeType&&h.overrideMimeType&&h.overrideMimeType(b.mimeType),b.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest");for(g in e)h.setRequestHeader(g,e[g]);c=function(a){return function(){c&&(c=d=h.onload=h.onerror=h.onabort=h.onreadystatechange=null,"abort"===a?h.abort():"error"===a?"number"!=typeof h.status?f(0,"error"):f(h.status,h.statusText):f(Ob[h.status]||h.status,h.statusText,"text"!==(h.responseType||"text")||"string"!=typeof h.responseText?{binary:h.response}:{text:h.responseText},h.getAllResponseHeaders()))}},h.onload=c(),d=h.onerror=c("error"),void 0!==h.onabort?h.onabort=d:h.onreadystatechange=function(){4===h.readyState&&a.setTimeout(function(){c&&d()})},c=c("abort");try{h.send(b.hasContent&&b.data||null)}catch(i){if(c)throw i}},abort:function(){c&&c()}}}),r.ajaxPrefilter(function(a){a.crossDomain&&(a.contents.script=!1)}),r.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(a){return r.globalEval(a),a}}}),r.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),r.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(e,f){b=r("