From f21d8ef2c4fad535c56e004f7f2057429fdcc1c6 Mon Sep 17 00:00:00 2001 From: monjack Date: Tue, 22 Apr 2025 21:34:47 +0800 Subject: [PATCH 1/4] new Files --- front/src/App.vue | 19 +- front/src/views/HomePage.vue | 4 +- .../views/zl-station/menjizhenItemView.vue | 132 +- package-lock.json | 1781 +++++++++++++++++ package.json | 5 + 5 files changed, 1923 insertions(+), 18 deletions(-) create mode 100644 package-lock.json create mode 100644 package.json diff --git a/front/src/App.vue b/front/src/App.vue index b82e655..988bd5f 100644 --- a/front/src/App.vue +++ b/front/src/App.vue @@ -1,9 +1,13 @@ - - + + diff --git a/front/src/views/zl-station/menjizhenItemView.vue b/front/src/views/zl-station/menjizhenItemView.vue index 0264a6c..cb36910 100644 --- a/front/src/views/zl-station/menjizhenItemView.vue +++ b/front/src/views/zl-station/menjizhenItemView.vue @@ -1,27 +1,137 @@ \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..8e7ee67 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1781 @@ +{ + "name": "OutpatientSys", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "vue-devui": "^1.6.32" + } + }, + "node_modules/@babel/helper-hoist-variables": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.24.7.tgz", + "integrity": "sha512-MJJwhkoGy5c4ehfoRyrJ/owKeMl19U54h27YYftT0o2teQ3FJ3nQUf/I3LlJsX4l3qlw7WRXUmiyajvHXoTubQ==", + "license": "MIT", + "dependencies": { + "@babel/types": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz", + "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz", + "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.27.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.27.0.tgz", + "integrity": "sha512-iaepho73/2Pz7w2eMS0Q5f83+0RKI7i4xmiYeBmDzfRVbQtTOG7Ts0S4HzJVsTMGI9keU8rNfuZr8DKfSt7Yyg==", + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/types": "^7.27.0" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/types": { + "version": "7.27.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.27.0.tgz", + "integrity": "sha512-H45s8fVLYjbhFH62dIJ3WtmJ6RSPt/3DRO0ZcT2SUiYiQyz3BLVb9ADEnLl91m74aQPS3AzzeajZHYOalWe3bg==", + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@braintree/sanitize-url": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/@braintree/sanitize-url/-/sanitize-url-6.0.4.tgz", + "integrity": "sha512-s3jaWicZd0pkP0jf5ysyHUI/RE7MHos6qlToFcGWXVp+ykHOy77OUMrfbgJ9it2C5bow7OIQwYYaHjk9XlBQ2A==", + "license": "MIT" + }, + "node_modules/@devui-design/icons": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@devui-design/icons/-/icons-1.4.0.tgz", + "integrity": "sha512-taAX1RNW0QHUqQTRPqLTYTB2PZIqUplhWeF4hcmWkSTjpWlDNI40DssG/WRb3sISkfBk/4BMUxxC5XeTL3jo7A==", + "license": "MIT" + }, + "node_modules/@floating-ui/core": { + "version": "1.6.9", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.9.tgz", + "integrity": "sha512-uMXCuQ3BItDUbAMhIXw7UPXRfAlOAvZzdK9BWpE60MCn+Svt3aLn9jsPTi/WNGlRUu2uI0v5S7JiIUsbsvh3fw==", + "license": "MIT", + "dependencies": { + "@floating-ui/utils": "^0.2.9" + } + }, + "node_modules/@floating-ui/dom": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.2.5.tgz", + "integrity": "sha512-+sAUfpQ3Frz+VCbPCqj+cZzvEESy3fjSeT/pDWkYCWOBXYNNKZfuVsHuv8/JO2zze8+Eb/Q7a6hZVgzS81fLbQ==", + "license": "MIT", + "dependencies": { + "@floating-ui/core": "^1.2.4" + } + }, + "node_modules/@floating-ui/utils": { + "version": "0.2.9", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.9.tgz", + "integrity": "sha512-MDWhGtE+eHw5JW7lq4qhc5yRLS11ERl1c7Z6Xd0a58DozHES6EnNNwUWbMiG4J9Cgj053Bhk8zvlhFYKVhULwg==", + "license": "MIT" + }, + "node_modules/@iktakahiro/markdown-it-katex": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@iktakahiro/markdown-it-katex/-/markdown-it-katex-4.0.1.tgz", + "integrity": "sha512-kGFooO7fIOgY34PSG8ZNVsUlKhhNoqhzW2kq94TNGa8COzh73PO4KsEoPOsQVG1mEAe8tg7GqG0FoVao0aMHaw==", + "license": "MIT", + "dependencies": { + "katex": "^0.12.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "license": "MIT", + "peer": true + }, + "node_modules/@types/codemirror": { + "version": "0.0.97", + "resolved": "https://registry.npmjs.org/@types/codemirror/-/codemirror-0.0.97.tgz", + "integrity": "sha512-n5d7o9nWhC49DjfhsxANP7naWSeTzrjXASkUDQh7626sM4zK9XP2EVcHp1IcCf/IPV6c7ORzDUDF3Bkt231VKg==", + "license": "MIT", + "dependencies": { + "@types/tern": "*" + } + }, + "node_modules/@types/estree": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.7.tgz", + "integrity": "sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==", + "license": "MIT" + }, + "node_modules/@types/lodash": { + "version": "4.17.16", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.16.tgz", + "integrity": "sha512-HX7Em5NYQAXKW+1T+FiuG27NGwzJfCX3s1GjOa7ujxZa52kjJLOr4FUxT+giF6Tgxv1e+/czV/iTtBw27WTU9g==", + "license": "MIT" + }, + "node_modules/@types/lodash-es": { + "version": "4.17.12", + "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.12.tgz", + "integrity": "sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==", + "license": "MIT", + "dependencies": { + "@types/lodash": "*" + } + }, + "node_modules/@types/tern": { + "version": "0.23.9", + "resolved": "https://registry.npmjs.org/@types/tern/-/tern-0.23.9.tgz", + "integrity": "sha512-ypzHFE/wBzh+BlH6rrBgS5I/Z7RD21pGhZ2rltb/+ZrVM1awdZwjx7hE5XfuYgHWk9uvV5HLZN3SloevCAp3Bw==", + "license": "MIT", + "dependencies": { + "@types/estree": "*" + } + }, + "node_modules/@types/web-bluetooth": { + "version": "0.0.14", + "resolved": "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.14.tgz", + "integrity": "sha512-5d2RhCard1nQUC3aHcq/gHzWYO6K0WJmAbjO7mQJgCQKtZpgXxv1rOM6O/dBDhDYYVutk1sciOgNSe+5YyfM8A==", + "license": "MIT" + }, + "node_modules/@vue/compiler-core": { + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.13.tgz", + "integrity": "sha512-oOdAkwqUfW1WqpwSYJce06wvt6HljgY3fGeM9NcVA1HaYOij3mZG9Rkysn0OHuyUAGMbEbARIpsG+LPVlBJ5/Q==", + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/parser": "^7.25.3", + "@vue/shared": "3.5.13", + "entities": "^4.5.0", + "estree-walker": "^2.0.2", + "source-map-js": "^1.2.0" + } + }, + "node_modules/@vue/compiler-dom": { + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.13.tgz", + "integrity": "sha512-ZOJ46sMOKUjO3e94wPdCzQ6P1Lx/vhp2RSvfaab88Ajexs0AHeV0uasYhi99WPaogmBlRHNRuly8xV75cNTMDA==", + "license": "MIT", + "peer": true, + "dependencies": { + "@vue/compiler-core": "3.5.13", + "@vue/shared": "3.5.13" + } + }, + "node_modules/@vue/compiler-sfc": { + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.13.tgz", + "integrity": "sha512-6VdaljMpD82w6c2749Zhf5T9u5uLBWKnVue6XWxprDobftnletJ8+oel7sexFfM3qIxNmVE7LSFGTpv6obNyaQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/parser": "^7.25.3", + "@vue/compiler-core": "3.5.13", + "@vue/compiler-dom": "3.5.13", + "@vue/compiler-ssr": "3.5.13", + "@vue/shared": "3.5.13", + "estree-walker": "^2.0.2", + "magic-string": "^0.30.11", + "postcss": "^8.4.48", + "source-map-js": "^1.2.0" + } + }, + "node_modules/@vue/compiler-ssr": { + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.13.tgz", + "integrity": "sha512-wMH6vrYHxQl/IybKJagqbquvxpWCuVYpoUJfCqFZwa/JY1GdATAQ+TgVtgrwwMZ0D07QhA99rs/EAAWfvG6KpA==", + "license": "MIT", + "peer": true, + "dependencies": { + "@vue/compiler-dom": "3.5.13", + "@vue/shared": "3.5.13" + } + }, + "node_modules/@vue/devtools-api": { + "version": "6.6.4", + "resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.6.4.tgz", + "integrity": "sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==", + "license": "MIT" + }, + "node_modules/@vue/reactivity": { + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.13.tgz", + "integrity": "sha512-NaCwtw8o48B9I6L1zl2p41OHo/2Z4wqYGGIK1Khu5T7yxrn+ATOixn/Udn2m+6kZKB/J7cuT9DbWWhRxqixACg==", + "license": "MIT", + "peer": true, + "dependencies": { + "@vue/shared": "3.5.13" + } + }, + "node_modules/@vue/runtime-core": { + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.13.tgz", + "integrity": "sha512-Fj4YRQ3Az0WTZw1sFe+QDb0aXCerigEpw418pw1HBUKFtnQHWzwojaukAs2X/c9DQz4MQ4bsXTGlcpGxU/RCIw==", + "license": "MIT", + "peer": true, + "dependencies": { + "@vue/reactivity": "3.5.13", + "@vue/shared": "3.5.13" + } + }, + "node_modules/@vue/runtime-dom": { + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.13.tgz", + "integrity": "sha512-dLaj94s93NYLqjLiyFzVs9X6dWhTdAlEAciC3Moq7gzAc13VJUdCnjjRurNM6uTLFATRHexHCTu/Xp3eW6yoog==", + "license": "MIT", + "peer": true, + "dependencies": { + "@vue/reactivity": "3.5.13", + "@vue/runtime-core": "3.5.13", + "@vue/shared": "3.5.13", + "csstype": "^3.1.3" + } + }, + "node_modules/@vue/server-renderer": { + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.13.tgz", + "integrity": "sha512-wAi4IRJV/2SAW3htkTlB+dHeRmpTiVIK1OGLWV1yeStVSebSQQOwGwIq0D3ZIoBj2C2qpgz5+vX9iEBkTdk5YA==", + "license": "MIT", + "peer": true, + "dependencies": { + "@vue/compiler-ssr": "3.5.13", + "@vue/shared": "3.5.13" + }, + "peerDependencies": { + "vue": "3.5.13" + } + }, + "node_modules/@vue/shared": { + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.13.tgz", + "integrity": "sha512-/hnE/qP5ZoGpol0a5mDi45bOd7t3tjYJBjsgCsivow7D48cJeV5l05RD82lPqi7gRiphZM37rnhW1l6ZoCNNnQ==", + "license": "MIT" + }, + "node_modules/@vueuse/core": { + "version": "8.9.4", + "resolved": "https://registry.npmjs.org/@vueuse/core/-/core-8.9.4.tgz", + "integrity": "sha512-B/Mdj9TK1peFyWaPof+Zf/mP9XuGAngaJZBwPaXBvU3aCTZlx3ltlrFFFyMV4iGBwsjSCeUCgZrtkEj9dS2Y3Q==", + "license": "MIT", + "dependencies": { + "@types/web-bluetooth": "^0.0.14", + "@vueuse/metadata": "8.9.4", + "@vueuse/shared": "8.9.4", + "vue-demi": "*" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "@vue/composition-api": "^1.1.0", + "vue": "^2.6.0 || ^3.2.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + }, + "vue": { + "optional": true + } + } + }, + "node_modules/@vueuse/core/node_modules/@vueuse/shared": { + "version": "8.9.4", + "resolved": "https://registry.npmjs.org/@vueuse/shared/-/shared-8.9.4.tgz", + "integrity": "sha512-wt+T30c4K6dGRMVqPddexEVLa28YwxW5OFIPmzUHICjphfAuBFTTdDoyqREZNDOFJZ44ARH1WWQNCUK8koJ+Ag==", + "license": "MIT", + "dependencies": { + "vue-demi": "*" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "@vue/composition-api": "^1.1.0", + "vue": "^2.6.0 || ^3.2.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + }, + "vue": { + "optional": true + } + } + }, + "node_modules/@vueuse/core/node_modules/vue-demi": { + "version": "0.14.10", + "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.10.tgz", + "integrity": "sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==", + "hasInstallScript": true, + "license": "MIT", + "bin": { + "vue-demi-fix": "bin/vue-demi-fix.js", + "vue-demi-switch": "bin/vue-demi-switch.js" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "@vue/composition-api": "^1.0.0-rc.1", + "vue": "^3.0.0-0 || ^2.6.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + } + } + }, + "node_modules/@vueuse/metadata": { + "version": "8.9.4", + "resolved": "https://registry.npmjs.org/@vueuse/metadata/-/metadata-8.9.4.tgz", + "integrity": "sha512-IwSfzH80bnJMzqhaapqJl9JRIiyQU0zsRGEgnxN6jhq7992cPUJIRfV+JHRIZXjYqbwt07E1gTEp0R0zPJ1aqw==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "license": "ISC" + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "license": "Python-2.0" + }, + "node_modules/async-validator": { + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/async-validator/-/async-validator-4.2.5.tgz", + "integrity": "sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg==", + "license": "MIT" + }, + "node_modules/clipboard": { + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.11.tgz", + "integrity": "sha512-C+0bbOqkezLIsmWSvlsXS0Q0bmkugu7jcfMIACB+RDEntIzQIkdr148we28AfSloQLRdZlYL/QYyrq05j/3Faw==", + "license": "MIT", + "dependencies": { + "good-listener": "^1.2.2", + "select": "^1.1.2", + "tiny-emitter": "^2.0.0" + } + }, + "node_modules/clipboard-copy": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/clipboard-copy/-/clipboard-copy-4.0.1.tgz", + "integrity": "sha512-wOlqdqziE/NNTUJsfSgXmBMIrYmfd5V0HCGsR8uAKHcg+h9NENWINcfRjtWGU77wDHC8B8ijV4hMTGYbrKovng==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/codemirror": { + "version": "5.63.3", + "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.63.3.tgz", + "integrity": "sha512-1C+LELr+5grgJYqwZKqxrcbPsHFHapVaVAloBsFBASbpLnQqLw1U8yXJ3gT5D+rhxIiSpo+kTqN+hQ+9ialIXw==", + "license": "MIT" + }, + "node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "license": "MIT" + }, + "node_modules/cssfilter": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/cssfilter/-/cssfilter-0.0.10.tgz", + "integrity": "sha512-FAaLDaplstoRsDR8XGYH51znUN0UY7nMc6Z9/fvE8EXGwvJE9hu7W2vHwx1+bd6gCYnln9nLbzxFTrcO9YQDZw==", + "license": "MIT" + }, + "node_modules/csstype": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==", + "license": "MIT", + "peer": true + }, + "node_modules/d3": { + "version": "7.9.0", + "resolved": "https://registry.npmjs.org/d3/-/d3-7.9.0.tgz", + "integrity": "sha512-e1U46jVP+w7Iut8Jt8ri1YsPOvFpg46k+K8TpCb0P+zjCkjkPnV7WzfDJzMHy1LnA+wj5pLT1wjO901gLXeEhA==", + "license": "ISC", + "dependencies": { + "d3-array": "3", + "d3-axis": "3", + "d3-brush": "3", + "d3-chord": "3", + "d3-color": "3", + "d3-contour": "4", + "d3-delaunay": "6", + "d3-dispatch": "3", + "d3-drag": "3", + "d3-dsv": "3", + "d3-ease": "3", + "d3-fetch": "3", + "d3-force": "3", + "d3-format": "3", + "d3-geo": "3", + "d3-hierarchy": "3", + "d3-interpolate": "3", + "d3-path": "3", + "d3-polygon": "3", + "d3-quadtree": "3", + "d3-random": "3", + "d3-scale": "4", + "d3-scale-chromatic": "3", + "d3-selection": "3", + "d3-shape": "3", + "d3-time": "3", + "d3-time-format": "4", + "d3-timer": "3", + "d3-transition": "3", + "d3-zoom": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-array": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz", + "integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==", + "license": "ISC", + "dependencies": { + "internmap": "1 - 2" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-axis": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-axis/-/d3-axis-3.0.0.tgz", + "integrity": "sha512-IH5tgjV4jE/GhHkRV0HiVYPDtvfjHQlQfJHs0usq7M30XcSBvOotpmH1IgkcXsO/5gEQZD43B//fc7SRT5S+xw==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-brush": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-brush/-/d3-brush-3.0.0.tgz", + "integrity": "sha512-ALnjWlVYkXsVIGlOsuWH1+3udkYFI48Ljihfnh8FZPF2QS9o+PzGLBslO0PjzVoHLZ2KCVgAM8NVkXPJB2aNnQ==", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-drag": "2 - 3", + "d3-interpolate": "1 - 3", + "d3-selection": "3", + "d3-transition": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-chord": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-chord/-/d3-chord-3.0.1.tgz", + "integrity": "sha512-VE5S6TNa+j8msksl7HwjxMHDM2yNK3XCkusIlpX5kwauBfXuyLAtNg9jCp/iHH61tgI4sb6R/EIMWCqEIdjT/g==", + "license": "ISC", + "dependencies": { + "d3-path": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-collection": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/d3-collection/-/d3-collection-1.0.7.tgz", + "integrity": "sha512-ii0/r5f4sjKNTfh84Di+DpztYwqKhEyUlKoPrzUFfeSkWxjW49xU2QzO9qrPrNkpdI0XJkfzvmTu8V2Zylln6A==", + "license": "BSD-3-Clause" + }, + "node_modules/d3-color": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-color/-/d3-color-3.1.0.tgz", + "integrity": "sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-contour": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/d3-contour/-/d3-contour-4.0.2.tgz", + "integrity": "sha512-4EzFTRIikzs47RGmdxbeUvLWtGedDUNkTcmzoeyg4sP/dvCexO47AaQL7VKy/gul85TOxw+IBgA8US2xwbToNA==", + "license": "ISC", + "dependencies": { + "d3-array": "^3.2.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-delaunay": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/d3-delaunay/-/d3-delaunay-6.0.4.tgz", + "integrity": "sha512-mdjtIZ1XLAM8bm/hx3WwjfHt6Sggek7qH043O8KEjDXN40xi3vx/6pYSVTwLjEgiXQTbvaouWKynLBiUZ6SK6A==", + "license": "ISC", + "dependencies": { + "delaunator": "5" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-dispatch": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-dispatch/-/d3-dispatch-3.0.1.tgz", + "integrity": "sha512-rzUyPU/S7rwUflMyLc1ETDeBj0NRuHKKAcvukozwhshr6g6c5d8zh4c2gQjY2bZ0dXeGLWc1PF174P2tVvKhfg==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-drag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-drag/-/d3-drag-3.0.0.tgz", + "integrity": "sha512-pWbUJLdETVA8lQNJecMxoXfH6x+mO2UQo8rSmZ+QqxcbyA3hfeprFgIT//HW2nlHChWeIIMwS2Fq+gEARkhTkg==", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-selection": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-dsv": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-dsv/-/d3-dsv-3.0.1.tgz", + "integrity": "sha512-UG6OvdI5afDIFP9w4G0mNq50dSOsXHJaRE8arAS5o9ApWnIElp8GZw1Dun8vP8OyHOZ/QJUKUJwxiiCCnUwm+Q==", + "license": "ISC", + "dependencies": { + "commander": "7", + "iconv-lite": "0.6", + "rw": "1" + }, + "bin": { + "csv2json": "bin/dsv2json.js", + "csv2tsv": "bin/dsv2dsv.js", + "dsv2dsv": "bin/dsv2dsv.js", + "dsv2json": "bin/dsv2json.js", + "json2csv": "bin/json2dsv.js", + "json2dsv": "bin/json2dsv.js", + "json2tsv": "bin/json2dsv.js", + "tsv2csv": "bin/dsv2dsv.js", + "tsv2json": "bin/dsv2json.js" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-dsv/node_modules/commander": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", + "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", + "license": "MIT", + "engines": { + "node": ">= 10" + } + }, + "node_modules/d3-ease": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-ease/-/d3-ease-3.0.1.tgz", + "integrity": "sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-fetch": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-fetch/-/d3-fetch-3.0.1.tgz", + "integrity": "sha512-kpkQIM20n3oLVBKGg6oHrUchHM3xODkTzjMoj7aWQFq5QEM+R6E4WkzT5+tojDY7yjez8KgCBRoj4aEr99Fdqw==", + "license": "ISC", + "dependencies": { + "d3-dsv": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-force": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-force/-/d3-force-3.0.0.tgz", + "integrity": "sha512-zxV/SsA+U4yte8051P4ECydjD/S+qeYtnaIyAs9tgHCqfguma/aAQDjo85A9Z6EKhBirHRJHXIgJUlffT4wdLg==", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-quadtree": "1 - 3", + "d3-timer": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-format": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-format/-/d3-format-3.1.0.tgz", + "integrity": "sha512-YyUI6AEuY/Wpt8KWLgZHsIU86atmikuoOmCfommt0LYHiQSPjvX2AcFc38PX0CBpr2RCyZhjex+NS/LPOv6YqA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-geo": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/d3-geo/-/d3-geo-3.1.1.tgz", + "integrity": "sha512-637ln3gXKXOwhalDzinUgY83KzNWZRKbYubaG+fGVuc/dxO64RRljtCTnf5ecMyE1RIdtqpkVcq0IbtU2S8j2Q==", + "license": "ISC", + "dependencies": { + "d3-array": "2.5.0 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-hierarchy": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/d3-hierarchy/-/d3-hierarchy-3.1.2.tgz", + "integrity": "sha512-FX/9frcub54beBdugHjDCdikxThEqjnR93Qt7PvQTOHxyiNCAlvMrHhclk3cD5VeAaq9fxmfRp+CnWw9rEMBuA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-interpolate": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-interpolate/-/d3-interpolate-3.0.1.tgz", + "integrity": "sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g==", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-path": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-path/-/d3-path-3.1.0.tgz", + "integrity": "sha512-p3KP5HCf/bvjBSSKuXid6Zqijx7wIfNW+J/maPs+iwR35at5JCbLUT0LzF1cnjbCHWhqzQTIN2Jpe8pRebIEFQ==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-polygon": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-polygon/-/d3-polygon-3.0.1.tgz", + "integrity": "sha512-3vbA7vXYwfe1SYhED++fPUQlWSYTTGmFmQiany/gdbiWgU/iEyQzyymwL9SkJjFFuCS4902BSzewVGsHHmHtXg==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-quadtree": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-quadtree/-/d3-quadtree-3.0.1.tgz", + "integrity": "sha512-04xDrxQTDTCFwP5H6hRhsRcb9xxv2RzkcsygFzmkSIOJy3PeRJP7sNk3VRIbKXcog561P9oU0/rVH6vDROAgUw==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-random": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-random/-/d3-random-3.0.1.tgz", + "integrity": "sha512-FXMe9GfxTxqd5D6jFsQ+DJ8BJS4E/fT5mqqdjovykEB2oFbTMDVdg1MGFxfQW+FBOGoB++k8swBrgwSHT1cUXQ==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-scale": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/d3-scale/-/d3-scale-4.0.2.tgz", + "integrity": "sha512-GZW464g1SH7ag3Y7hXjf8RoUuAFIqklOAq3MRl4OaWabTFJY9PN/E1YklhXLh+OQ3fM9yS2nOkCoS+WLZ6kvxQ==", + "license": "ISC", + "dependencies": { + "d3-array": "2.10.0 - 3", + "d3-format": "1 - 3", + "d3-interpolate": "1.2.0 - 3", + "d3-time": "2.1.1 - 3", + "d3-time-format": "2 - 4" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-scale-chromatic": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-scale-chromatic/-/d3-scale-chromatic-3.1.0.tgz", + "integrity": "sha512-A3s5PWiZ9YCXFye1o246KoscMWqf8BsD9eRiJ3He7C9OBaxKhAd5TFCdEx/7VbKtxxTsu//1mMJFrEt572cEyQ==", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3", + "d3-interpolate": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-selection": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz", + "integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-shape": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-3.2.0.tgz", + "integrity": "sha512-SaLBuwGm3MOViRq2ABk3eLoxwZELpH6zhl3FbAoJ7Vm1gofKx6El1Ib5z23NUEhF9AsGl7y+dzLe5Cw2AArGTA==", + "license": "ISC", + "dependencies": { + "d3-path": "^3.1.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-time": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-time/-/d3-time-3.1.0.tgz", + "integrity": "sha512-VqKjzBLejbSMT4IgbmVgDjpkYrNWUYJnbCGo874u7MMKIWsILRX+OpX/gTk8MqjpT1A/c6HY2dCA77ZN0lkQ2Q==", + "license": "ISC", + "dependencies": { + "d3-array": "2 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-time-format": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/d3-time-format/-/d3-time-format-4.1.0.tgz", + "integrity": "sha512-dJxPBlzC7NugB2PDLwo9Q8JiTR3M3e4/XANkreKSUxF8vvXKqm1Yfq4Q5dl8budlunRVlUUaDUgFt7eA8D6NLg==", + "license": "ISC", + "dependencies": { + "d3-time": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-timer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-timer/-/d3-timer-3.0.1.tgz", + "integrity": "sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-transition": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-transition/-/d3-transition-3.0.1.tgz", + "integrity": "sha512-ApKvfjsSR6tg06xrL434C0WydLr7JewBB3V+/39RMHsaXTOG0zmt/OAXeng5M5LBm0ojmxJrpomQVZ1aPvBL4w==", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3", + "d3-dispatch": "1 - 3", + "d3-ease": "1 - 3", + "d3-interpolate": "1 - 3", + "d3-timer": "1 - 3" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "d3-selection": "2 - 3" + } + }, + "node_modules/d3-voronoi": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/d3-voronoi/-/d3-voronoi-1.1.4.tgz", + "integrity": "sha512-dArJ32hchFsrQ8uMiTBLq256MpnZjeuBtdHpaDlYuQyjU0CVzCJl/BVW+SkszaAeH95D/8gxqAhgx0ouAWAfRg==", + "license": "BSD-3-Clause" + }, + "node_modules/d3-zoom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-zoom/-/d3-zoom-3.0.0.tgz", + "integrity": "sha512-b8AmV3kfQaqWAuacbPuNbL6vahnOJflOhexLzMMNLga62+/nh0JzvJ0aO/5a5MVgUFGS7Hu1P9P03o3fJkDCyw==", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-drag": "2 - 3", + "d3-interpolate": "1 - 3", + "d3-selection": "2 - 3", + "d3-transition": "2 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/dagre": { + "version": "0.8.5", + "resolved": "https://registry.npmjs.org/dagre/-/dagre-0.8.5.tgz", + "integrity": "sha512-/aTqmnRta7x7MCCpExk7HQL2O4owCT2h8NT//9I1OQ9vt29Pa0BzSAkR5lwFUcQ7491yVi/3CXU9jQ5o0Mn2Sw==", + "license": "MIT", + "dependencies": { + "graphlib": "^2.1.8", + "lodash": "^4.17.15" + } + }, + "node_modules/dagre-d3": { + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/dagre-d3/-/dagre-d3-0.6.4.tgz", + "integrity": "sha512-e/6jXeCP7/ptlAM48clmX4xTZc5Ek6T6kagS7Oz2HrYSdqcLZFLqpAfh7ldbZRFfxCZVyh61NEPR08UQRVxJzQ==", + "license": "MIT", + "dependencies": { + "d3": "^5.14", + "dagre": "^0.8.5", + "graphlib": "^2.1.8", + "lodash": "^4.17.15" + } + }, + "node_modules/dagre-d3/node_modules/d3": { + "version": "5.16.0", + "resolved": "https://registry.npmjs.org/d3/-/d3-5.16.0.tgz", + "integrity": "sha512-4PL5hHaHwX4m7Zr1UapXW23apo6pexCgdetdJ5kTmADpG/7T9Gkxw0M0tf/pjoB63ezCCm0u5UaFYy2aMt0Mcw==", + "license": "BSD-3-Clause", + "dependencies": { + "d3-array": "1", + "d3-axis": "1", + "d3-brush": "1", + "d3-chord": "1", + "d3-collection": "1", + "d3-color": "1", + "d3-contour": "1", + "d3-dispatch": "1", + "d3-drag": "1", + "d3-dsv": "1", + "d3-ease": "1", + "d3-fetch": "1", + "d3-force": "1", + "d3-format": "1", + "d3-geo": "1", + "d3-hierarchy": "1", + "d3-interpolate": "1", + "d3-path": "1", + "d3-polygon": "1", + "d3-quadtree": "1", + "d3-random": "1", + "d3-scale": "2", + "d3-scale-chromatic": "1", + "d3-selection": "1", + "d3-shape": "1", + "d3-time": "1", + "d3-time-format": "2", + "d3-timer": "1", + "d3-transition": "1", + "d3-voronoi": "1", + "d3-zoom": "1" + } + }, + "node_modules/dagre-d3/node_modules/d3-array": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-1.2.4.tgz", + "integrity": "sha512-KHW6M86R+FUPYGb3R5XiYjXPq7VzwxZ22buHhAEVG5ztoEcZZMLov530mmccaqA1GghZArjQV46fuc8kUqhhHw==", + "license": "BSD-3-Clause" + }, + "node_modules/dagre-d3/node_modules/d3-axis": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/d3-axis/-/d3-axis-1.0.12.tgz", + "integrity": "sha512-ejINPfPSNdGFKEOAtnBtdkpr24c4d4jsei6Lg98mxf424ivoDP2956/5HDpIAtmHo85lqT4pruy+zEgvRUBqaQ==", + "license": "BSD-3-Clause" + }, + "node_modules/dagre-d3/node_modules/d3-brush": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/d3-brush/-/d3-brush-1.1.6.tgz", + "integrity": "sha512-7RW+w7HfMCPyZLifTz/UnJmI5kdkXtpCbombUSs8xniAyo0vIbrDzDwUJB6eJOgl9u5DQOt2TQlYumxzD1SvYA==", + "license": "BSD-3-Clause", + "dependencies": { + "d3-dispatch": "1", + "d3-drag": "1", + "d3-interpolate": "1", + "d3-selection": "1", + "d3-transition": "1" + } + }, + "node_modules/dagre-d3/node_modules/d3-chord": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/d3-chord/-/d3-chord-1.0.6.tgz", + "integrity": "sha512-JXA2Dro1Fxw9rJe33Uv+Ckr5IrAa74TlfDEhE/jfLOaXegMQFQTAgAw9WnZL8+HxVBRXaRGCkrNU7pJeylRIuA==", + "license": "BSD-3-Clause", + "dependencies": { + "d3-array": "1", + "d3-path": "1" + } + }, + "node_modules/dagre-d3/node_modules/d3-color": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/d3-color/-/d3-color-1.4.1.tgz", + "integrity": "sha512-p2sTHSLCJI2QKunbGb7ocOh7DgTAn8IrLx21QRc/BSnodXM4sv6aLQlnfpvehFMLZEfBc6g9pH9SWQccFYfJ9Q==", + "license": "BSD-3-Clause" + }, + "node_modules/dagre-d3/node_modules/d3-contour": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/d3-contour/-/d3-contour-1.3.2.tgz", + "integrity": "sha512-hoPp4K/rJCu0ladiH6zmJUEz6+u3lgR+GSm/QdM2BBvDraU39Vr7YdDCicJcxP1z8i9B/2dJLgDC1NcvlF8WCg==", + "license": "BSD-3-Clause", + "dependencies": { + "d3-array": "^1.1.1" + } + }, + "node_modules/dagre-d3/node_modules/d3-dispatch": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/d3-dispatch/-/d3-dispatch-1.0.6.tgz", + "integrity": "sha512-fVjoElzjhCEy+Hbn8KygnmMS7Or0a9sI2UzGwoB7cCtvI1XpVN9GpoYlnb3xt2YV66oXYb1fLJ8GMvP4hdU1RA==", + "license": "BSD-3-Clause" + }, + "node_modules/dagre-d3/node_modules/d3-drag": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/d3-drag/-/d3-drag-1.2.5.tgz", + "integrity": "sha512-rD1ohlkKQwMZYkQlYVCrSFxsWPzI97+W+PaEIBNTMxRuxz9RF0Hi5nJWHGVJ3Om9d2fRTe1yOBINJyy/ahV95w==", + "license": "BSD-3-Clause", + "dependencies": { + "d3-dispatch": "1", + "d3-selection": "1" + } + }, + "node_modules/dagre-d3/node_modules/d3-dsv": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/d3-dsv/-/d3-dsv-1.2.0.tgz", + "integrity": "sha512-9yVlqvZcSOMhCYzniHE7EVUws7Fa1zgw+/EAV2BxJoG3ME19V6BQFBwI855XQDsxyOuG7NibqRMTtiF/Qup46g==", + "license": "BSD-3-Clause", + "dependencies": { + "commander": "2", + "iconv-lite": "0.4", + "rw": "1" + }, + "bin": { + "csv2json": "bin/dsv2json", + "csv2tsv": "bin/dsv2dsv", + "dsv2dsv": "bin/dsv2dsv", + "dsv2json": "bin/dsv2json", + "json2csv": "bin/json2dsv", + "json2dsv": "bin/json2dsv", + "json2tsv": "bin/json2dsv", + "tsv2csv": "bin/dsv2dsv", + "tsv2json": "bin/dsv2json" + } + }, + "node_modules/dagre-d3/node_modules/d3-ease": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/d3-ease/-/d3-ease-1.0.7.tgz", + "integrity": "sha512-lx14ZPYkhNx0s/2HX5sLFUI3mbasHjSSpwO/KaaNACweVwxUruKyWVcb293wMv1RqTPZyZ8kSZ2NogUZNcLOFQ==", + "license": "BSD-3-Clause" + }, + "node_modules/dagre-d3/node_modules/d3-fetch": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/d3-fetch/-/d3-fetch-1.2.0.tgz", + "integrity": "sha512-yC78NBVcd2zFAyR/HnUiBS7Lf6inSCoWcSxFfw8FYL7ydiqe80SazNwoffcqOfs95XaLo7yebsmQqDKSsXUtvA==", + "license": "BSD-3-Clause", + "dependencies": { + "d3-dsv": "1" + } + }, + "node_modules/dagre-d3/node_modules/d3-force": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/d3-force/-/d3-force-1.2.1.tgz", + "integrity": "sha512-HHvehyaiUlVo5CxBJ0yF/xny4xoaxFxDnBXNvNcfW9adORGZfyNF1dj6DGLKyk4Yh3brP/1h3rnDzdIAwL08zg==", + "license": "BSD-3-Clause", + "dependencies": { + "d3-collection": "1", + "d3-dispatch": "1", + "d3-quadtree": "1", + "d3-timer": "1" + } + }, + "node_modules/dagre-d3/node_modules/d3-format": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/d3-format/-/d3-format-1.4.5.tgz", + "integrity": "sha512-J0piedu6Z8iB6TbIGfZgDzfXxUFN3qQRMofy2oPdXzQibYGqPB/9iMcxr/TGalU+2RsyDO+U4f33id8tbnSRMQ==", + "license": "BSD-3-Clause" + }, + "node_modules/dagre-d3/node_modules/d3-geo": { + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/d3-geo/-/d3-geo-1.12.1.tgz", + "integrity": "sha512-XG4d1c/UJSEX9NfU02KwBL6BYPj8YKHxgBEw5om2ZnTRSbIcego6dhHwcxuSR3clxh0EpE38os1DVPOmnYtTPg==", + "license": "BSD-3-Clause", + "dependencies": { + "d3-array": "1" + } + }, + "node_modules/dagre-d3/node_modules/d3-hierarchy": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/d3-hierarchy/-/d3-hierarchy-1.1.9.tgz", + "integrity": "sha512-j8tPxlqh1srJHAtxfvOUwKNYJkQuBFdM1+JAUfq6xqH5eAqf93L7oG1NVqDa4CpFZNvnNKtCYEUC8KY9yEn9lQ==", + "license": "BSD-3-Clause" + }, + "node_modules/dagre-d3/node_modules/d3-interpolate": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/d3-interpolate/-/d3-interpolate-1.4.0.tgz", + "integrity": "sha512-V9znK0zc3jOPV4VD2zZn0sDhZU3WAE2bmlxdIwwQPPzPjvyLkd8B3JUVdS1IDUFDkWZ72c9qnv1GK2ZagTZ8EA==", + "license": "BSD-3-Clause", + "dependencies": { + "d3-color": "1" + } + }, + "node_modules/dagre-d3/node_modules/d3-path": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/d3-path/-/d3-path-1.0.9.tgz", + "integrity": "sha512-VLaYcn81dtHVTjEHd8B+pbe9yHWpXKZUC87PzoFmsFrJqgFwDe/qxfp5MlfsfM1V5E/iVt0MmEbWQ7FVIXh/bg==", + "license": "BSD-3-Clause" + }, + "node_modules/dagre-d3/node_modules/d3-polygon": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/d3-polygon/-/d3-polygon-1.0.6.tgz", + "integrity": "sha512-k+RF7WvI08PC8reEoXa/w2nSg5AUMTi+peBD9cmFc+0ixHfbs4QmxxkarVal1IkVkgxVuk9JSHhJURHiyHKAuQ==", + "license": "BSD-3-Clause" + }, + "node_modules/dagre-d3/node_modules/d3-quadtree": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/d3-quadtree/-/d3-quadtree-1.0.7.tgz", + "integrity": "sha512-RKPAeXnkC59IDGD0Wu5mANy0Q2V28L+fNe65pOCXVdVuTJS3WPKaJlFHer32Rbh9gIo9qMuJXio8ra4+YmIymA==", + "license": "BSD-3-Clause" + }, + "node_modules/dagre-d3/node_modules/d3-random": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/d3-random/-/d3-random-1.1.2.tgz", + "integrity": "sha512-6AK5BNpIFqP+cx/sreKzNjWbwZQCSUatxq+pPRmFIQaWuoD+NrbVWw7YWpHiXpCQ/NanKdtGDuB+VQcZDaEmYQ==", + "license": "BSD-3-Clause" + }, + "node_modules/dagre-d3/node_modules/d3-scale": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/d3-scale/-/d3-scale-2.2.2.tgz", + "integrity": "sha512-LbeEvGgIb8UMcAa0EATLNX0lelKWGYDQiPdHj+gLblGVhGLyNbaCn3EvrJf0A3Y/uOOU5aD6MTh5ZFCdEwGiCw==", + "license": "BSD-3-Clause", + "dependencies": { + "d3-array": "^1.2.0", + "d3-collection": "1", + "d3-format": "1", + "d3-interpolate": "1", + "d3-time": "1", + "d3-time-format": "2" + } + }, + "node_modules/dagre-d3/node_modules/d3-scale-chromatic": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/d3-scale-chromatic/-/d3-scale-chromatic-1.5.0.tgz", + "integrity": "sha512-ACcL46DYImpRFMBcpk9HhtIyC7bTBR4fNOPxwVSl0LfulDAwyiHyPOTqcDG1+t5d4P9W7t/2NAuWu59aKko/cg==", + "license": "BSD-3-Clause", + "dependencies": { + "d3-color": "1", + "d3-interpolate": "1" + } + }, + "node_modules/dagre-d3/node_modules/d3-selection": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-1.4.2.tgz", + "integrity": "sha512-SJ0BqYihzOjDnnlfyeHT0e30k0K1+5sR3d5fNueCNeuhZTnGw4M4o8mqJchSwgKMXCNFo+e2VTChiSJ0vYtXkg==", + "license": "BSD-3-Clause" + }, + "node_modules/dagre-d3/node_modules/d3-shape": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-1.3.7.tgz", + "integrity": "sha512-EUkvKjqPFUAZyOlhY5gzCxCeI0Aep04LwIRpsZ/mLFelJiUfnK56jo5JMDSE7yyP2kLSb6LtF+S5chMk7uqPqw==", + "license": "BSD-3-Clause", + "dependencies": { + "d3-path": "1" + } + }, + "node_modules/dagre-d3/node_modules/d3-time": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/d3-time/-/d3-time-1.1.0.tgz", + "integrity": "sha512-Xh0isrZ5rPYYdqhAVk8VLnMEidhz5aP7htAADH6MfzgmmicPkTo8LhkLxci61/lCB7n7UmE3bN0leRt+qvkLxA==", + "license": "BSD-3-Clause" + }, + "node_modules/dagre-d3/node_modules/d3-time-format": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/d3-time-format/-/d3-time-format-2.3.0.tgz", + "integrity": "sha512-guv6b2H37s2Uq/GefleCDtbe0XZAuy7Wa49VGkPVPMfLL9qObgBST3lEHJBMUp8S7NdLQAGIvr2KXk8Hc98iKQ==", + "license": "BSD-3-Clause", + "dependencies": { + "d3-time": "1" + } + }, + "node_modules/dagre-d3/node_modules/d3-timer": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/d3-timer/-/d3-timer-1.0.10.tgz", + "integrity": "sha512-B1JDm0XDaQC+uvo4DT79H0XmBskgS3l6Ve+1SBCfxgmtIb1AVrPIoqd+nPSv+loMX8szQ0sVUhGngL7D5QPiXw==", + "license": "BSD-3-Clause" + }, + "node_modules/dagre-d3/node_modules/d3-transition": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/d3-transition/-/d3-transition-1.3.2.tgz", + "integrity": "sha512-sc0gRU4PFqZ47lPVHloMn9tlPcv8jxgOQg+0zjhfZXMQuvppjG6YuwdMBE0TuqCZjeJkLecku/l9R0JPcRhaDA==", + "license": "BSD-3-Clause", + "dependencies": { + "d3-color": "1", + "d3-dispatch": "1", + "d3-ease": "1", + "d3-interpolate": "1", + "d3-selection": "^1.1.0", + "d3-timer": "1" + } + }, + "node_modules/dagre-d3/node_modules/d3-zoom": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/d3-zoom/-/d3-zoom-1.8.3.tgz", + "integrity": "sha512-VoLXTK4wvy1a0JpH2Il+F2CiOhVu7VRXWF5M/LroMIh3/zBAC3WAt7QoIvPibOavVo20hN6/37vwAsdBejLyKQ==", + "license": "BSD-3-Clause", + "dependencies": { + "d3-dispatch": "1", + "d3-drag": "1", + "d3-interpolate": "1", + "d3-selection": "1", + "d3-transition": "1" + } + }, + "node_modules/dagre-d3/node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/dayjs": { + "version": "1.11.13", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.13.tgz", + "integrity": "sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==", + "license": "MIT" + }, + "node_modules/delaunator": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/delaunator/-/delaunator-5.0.1.tgz", + "integrity": "sha512-8nvh+XBe96aCESrGOqMp/84b13H9cdKbG5P2ejQCh4d4sK9RL4371qou9drQjMhvnPmhWl5hnmqbEE0fXr9Xnw==", + "license": "ISC", + "dependencies": { + "robust-predicates": "^3.0.2" + } + }, + "node_modules/delegate": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz", + "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==", + "license": "MIT" + }, + "node_modules/devui-theme": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/devui-theme/-/devui-theme-0.0.1.tgz", + "integrity": "sha512-5nF6fChlsXKeAtvkaAF4bZ0NMiEAbzwqQ9XZQiNuM0RRFz5lW29nnbhfDCNPkmnw5ZyCVyXqYwVRBIZrwZHXrA==" + }, + "node_modules/diff": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-7.0.0.tgz", + "integrity": "sha512-PJWHUb1RFevKCwaFA9RlG5tCd+FO5iRh9A8HEtkmBH2Li03iJriB6m6JIN4rGz3K3JLawI7/veA1xzRKP6ISBw==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/diff2html": { + "version": "3.4.51", + "resolved": "https://registry.npmjs.org/diff2html/-/diff2html-3.4.51.tgz", + "integrity": "sha512-/rVCSDyokkzSCEGaGjkkElXtIRwyNDRzIa3S8VUhR6pjk25p6+AMnb1s2zGmhjl66D5m/HnV3IeZoxnWsvTy+w==", + "license": "MIT", + "dependencies": { + "diff": "^7.0.0", + "hogan.js": "3.0.2" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "highlight.js": "11.9.0" + } + }, + "node_modules/diff2html/node_modules/highlight.js": { + "version": "11.9.0", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.9.0.tgz", + "integrity": "sha512-fJ7cW7fQGCYAkgv4CPfwFHrfd/cLS4Hau96JuJ+ZTOWhjnhoeN1ub1tFmALm/+lW5z4WCAuAV9bm05AP0mS6Gw==", + "license": "BSD-3-Clause", + "optional": true, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/dompurify": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.3.6.tgz", + "integrity": "sha512-OFP2u/3T1R5CEgWCEONuJ1a5+MFKnOYpkywpUSxv/dj1LeBT1erK+JwM7zK0ROy2BRhqVCf0LRw/kHqKuMkVGg==", + "license": "(MPL-2.0 OR Apache-2.0)" + }, + "node_modules/echarts": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/echarts/-/echarts-5.3.3.tgz", + "integrity": "sha512-BRw2serInRwO5SIwRviZ6Xgm5Lb7irgz+sLiFMmy/HOaf4SQ+7oYqxKzRHAKp4xHQ05AuHw1xvoQWJjDQq/FGw==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "2.3.0", + "zrender": "5.3.2" + } + }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "license": "BSD-2-Clause", + "peer": true, + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "license": "MIT", + "peer": true + }, + "node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/good-listener": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz", + "integrity": "sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw==", + "license": "MIT", + "dependencies": { + "delegate": "^3.1.2" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "license": "ISC" + }, + "node_modules/graphlib": { + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/graphlib/-/graphlib-2.1.8.tgz", + "integrity": "sha512-jcLLfkpoVGmH7/InMC/1hIvOPSUh38oJtGhvrOFGzioE1DZ+0YW16RgmOJhHiuWTvGiJQ9Z1Ik43JvkRPRvE+A==", + "license": "MIT", + "dependencies": { + "lodash": "^4.17.15" + } + }, + "node_modules/highlight.js": { + "version": "11.11.1", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.11.1.tgz", + "integrity": "sha512-Xwwo44whKBVCYoliBQwaPvtd/2tYFkRQtXDWj1nackaV2JPXx3L0+Jvd8/qCJ2p+ML0/XVkJ2q+Mr+UVdpJK5w==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/hogan.js": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/hogan.js/-/hogan.js-3.0.2.tgz", + "integrity": "sha512-RqGs4wavGYJWE07t35JQccByczmNUXQT0E12ZYV1VKYu5UiAU9lsos/yBAcf840+zrUQQxgVduCR5/B8nNtibg==", + "dependencies": { + "mkdirp": "0.3.0", + "nopt": "1.0.10" + }, + "bin": { + "hulk": "bin/hulk" + } + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/internmap": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/internmap/-/internmap-2.0.3.tgz", + "integrity": "sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "license": "MIT", + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/katex": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/katex/-/katex-0.12.0.tgz", + "integrity": "sha512-y+8btoc/CK70XqcHqjxiGWBOeIL8upbS0peTPXTvgrh21n1RiWWcIpSWM+4uXq+IAgNh9YYQWdc7LVDPDAEEAg==", + "license": "MIT", + "dependencies": { + "commander": "^2.19.0" + }, + "bin": { + "katex": "cli.js" + } + }, + "node_modules/khroma": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/khroma/-/khroma-2.1.0.tgz", + "integrity": "sha512-Ls993zuzfayK269Svk9hzpeGUKob/sIgZzyHYdjQoAdQetRKpOLj+k/QQQ/6Qi0Yz65mlROrfd+Ev+1+7dz9Kw==" + }, + "node_modules/linkify-it": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.3.tgz", + "integrity": "sha512-ynTsyrFSdE5oZ/O9GEf00kPngmOfVwazR5GKDq6EYfhlpFug3J2zybX56a2PRRpc9P+FuSoGNAwjlbDs9jJBPQ==", + "license": "MIT", + "dependencies": { + "uc.micro": "^1.0.1" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "license": "MIT" + }, + "node_modules/lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==", + "license": "MIT" + }, + "node_modules/magic-string": { + "version": "0.30.17", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz", + "integrity": "sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==", + "license": "MIT", + "peer": true, + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0" + } + }, + "node_modules/markdown-it": { + "version": "12.2.0", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-12.2.0.tgz", + "integrity": "sha512-Wjws+uCrVQRqOoJvze4HCqkKl1AsSh95iFAeQDwnyfxM09divCBSXlDR1uTvyUP3Grzpn4Ru8GeCxYPM8vkCQg==", + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1", + "entities": "~2.1.0", + "linkify-it": "^3.0.1", + "mdurl": "^1.0.1", + "uc.micro": "^1.0.5" + }, + "bin": { + "markdown-it": "bin/markdown-it.js" + } + }, + "node_modules/markdown-it-emoji": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/markdown-it-emoji/-/markdown-it-emoji-3.0.0.tgz", + "integrity": "sha512-+rUD93bXHubA4arpEZO3q80so0qgoFJEKRkRbjKX8RTdca89v2kfyF+xR3i2sQTwql9tpPZPOQN5B+PunspXRg==", + "license": "MIT" + }, + "node_modules/markdown-it-plantuml": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/markdown-it-plantuml/-/markdown-it-plantuml-1.4.1.tgz", + "integrity": "sha512-13KgnZaGYTHBp4iUmGofzZSBz+Zj6cyqfR0SXUIc9wgWTto5Xhn7NjaXYxY0z7uBeTUMlc9LMQq5uP4OM5xCHg==", + "license": "MIT" + }, + "node_modules/markdown-it/node_modules/entities": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz", + "integrity": "sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==", + "license": "BSD-2-Clause", + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/mdurl": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", + "integrity": "sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g==", + "license": "MIT" + }, + "node_modules/mermaid": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/mermaid/-/mermaid-9.1.1.tgz", + "integrity": "sha512-2RVD+WkzZ4VDyO9gQvQAuQ/ux2gLigJtKDTlbwjYqOR/NwsVzTSfGm/kx648/qWJsg6Sv04tE9BWCO8s6a+pFA==", + "license": "MIT", + "dependencies": { + "@braintree/sanitize-url": "^6.0.0", + "d3": "^7.0.0", + "dagre": "^0.8.5", + "dagre-d3": "^0.6.4", + "dompurify": "2.3.6", + "graphlib": "^2.1.8", + "khroma": "^2.0.0", + "moment-mini": "^2.24.0", + "stylis": "^4.0.10" + } + }, + "node_modules/mitt": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz", + "integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==", + "license": "MIT" + }, + "node_modules/mkdirp": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz", + "integrity": "sha512-OHsdUcVAQ6pOtg5JYWpCBo9W/GySVuwvP9hueRMW7UqshC0tbfzLv8wjySTPm3tfUZ/21CE9E1pJagOA91Pxew==", + "deprecated": "Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)", + "license": "MIT/X11", + "engines": { + "node": "*" + } + }, + "node_modules/moment-mini": { + "version": "2.29.4", + "resolved": "https://registry.npmjs.org/moment-mini/-/moment-mini-2.29.4.tgz", + "integrity": "sha512-uhXpYwHFeiTbY9KSgPPRoo1nt8OxNVdMVoTBYHfSEKeRkIkwGpO+gERmhuhBtzfaeOyTkykSrm2+noJBgqt3Hg==", + "license": "MIT" + }, + "node_modules/monaco-editor": { + "version": "0.34.0", + "resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.34.0.tgz", + "integrity": "sha512-VF+S5zG8wxfinLKLrWcl4WUizMx+LeJrG4PM/M78OhcwocpV0jiyhX/pG6Q9jIOhrb/ckYi6nHnaR5OojlOZCQ==", + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "peer": true, + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/nopt": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", + "integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==", + "license": "MIT", + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": "*" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "license": "ISC", + "peer": true + }, + "node_modules/postcss": { + "version": "8.5.3", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.3.tgz", + "integrity": "sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "peer": true, + "dependencies": { + "nanoid": "^3.3.8", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/robust-predicates": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/robust-predicates/-/robust-predicates-3.0.2.tgz", + "integrity": "sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg==", + "license": "Unlicense" + }, + "node_modules/rw": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/rw/-/rw-1.3.3.tgz", + "integrity": "sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ==", + "license": "BSD-3-Clause" + }, + "node_modules/rxjs": { + "version": "7.8.2", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz", + "integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/select": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz", + "integrity": "sha512-OwpTSOfy6xSs1+pwcNrv0RBMOzI39Lp3qQKUTPVVPRjCdNa5JH/oPRiqsesIskK8TVgmRiHwO4KXlV2Li9dANA==", + "license": "MIT" + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "license": "BSD-3-Clause", + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/stylis": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.3.6.tgz", + "integrity": "sha512-yQ3rwFWRfwNUY7H5vpU0wfdkNSnvnJinhF9830Swlaxl03zsOjCfmX0ugac+3LtK0lYSgwL/KXc8oYL3mG4YFQ==", + "license": "MIT" + }, + "node_modules/tiny-emitter": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", + "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==", + "license": "MIT" + }, + "node_modules/tslib": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz", + "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==", + "license": "0BSD" + }, + "node_modules/uc.micro": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", + "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==", + "license": "MIT" + }, + "node_modules/universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "license": "MIT", + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/vue": { + "version": "3.5.13", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.13.tgz", + "integrity": "sha512-wmeiSMxkZCSc+PM2w2VRsOYAZC8GdipNFRTsLSfodVqI9mbejKeXEGr8SckuLnrQPGe3oJN5c3K0vpoU9q/wCQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "@vue/compiler-dom": "3.5.13", + "@vue/compiler-sfc": "3.5.13", + "@vue/runtime-dom": "3.5.13", + "@vue/server-renderer": "3.5.13", + "@vue/shared": "3.5.13" + }, + "peerDependencies": { + "typescript": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/vue-devui": { + "version": "1.6.32", + "resolved": "https://registry.npmjs.org/vue-devui/-/vue-devui-1.6.32.tgz", + "integrity": "sha512-+nIEcXujYjKctsRVpDUEtRALEcaefbXZLO5AlWtcBNVksAj6Gutv104DGeTVfDkFpBL8IjiYu8ym1qVnnZs77g==", + "license": "MIT", + "dependencies": { + "@babel/helper-hoist-variables": "^7.22.5", + "@devui-design/icons": "^1.3.0", + "@floating-ui/dom": "1.2.5", + "@iktakahiro/markdown-it-katex": "^4.0.1", + "@types/codemirror": "0.0.97", + "@types/lodash-es": "^4.17.4", + "@vue/shared": "^3.2.33", + "@vueuse/core": "8.9.4", + "async-validator": "^4.0.7", + "clipboard": "^2.0.11", + "clipboard-copy": "^4.0.1", + "codemirror": "5.63.3", + "dayjs": "^1.11.3", + "devui-theme": "^0.0.1", + "diff2html": "^3.4.35", + "echarts": "5.3.3", + "fs-extra": "^10.0.0", + "highlight.js": "^11.6.0", + "katex": "^0.12.0", + "lodash": "^4.17.21", + "lodash-es": "^4.17.20", + "markdown-it": "12.2.0", + "markdown-it-emoji": "^3.0.0", + "markdown-it-plantuml": "^1.4.1", + "mermaid": "9.1.1", + "mitt": "^3.0.0", + "monaco-editor": "0.34.0", + "rxjs": "^7.8.1", + "uuid": "^9.0.1", + "vue-router": "^4.0.3", + "xss": "^1.0.14" + }, + "peerDependencies": { + "vue": "^3.3" + } + }, + "node_modules/vue-router": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.5.0.tgz", + "integrity": "sha512-HDuk+PuH5monfNuY+ct49mNmkCRK4xJAV9Ts4z9UFc4rzdDnxQLyCMGGc8pKhZhHTVzfanpNwB/lwqevcBwI4w==", + "license": "MIT", + "dependencies": { + "@vue/devtools-api": "^6.6.4" + }, + "funding": { + "url": "https://github.com/sponsors/posva" + }, + "peerDependencies": { + "vue": "^3.2.0" + } + }, + "node_modules/xss": { + "version": "1.0.15", + "resolved": "https://registry.npmjs.org/xss/-/xss-1.0.15.tgz", + "integrity": "sha512-FVdlVVC67WOIPvfOwhoMETV72f6GbW7aOabBC3WxN/oUdoEMDyLz4OgRv5/gck2ZeNqEQu+Tb0kloovXOfpYVg==", + "license": "MIT", + "dependencies": { + "commander": "^2.20.3", + "cssfilter": "0.0.10" + }, + "bin": { + "xss": "bin/xss" + }, + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/zrender": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/zrender/-/zrender-5.3.2.tgz", + "integrity": "sha512-8IiYdfwHj2rx0UeIGZGGU4WEVSDEdeVCaIg/fomejg1Xu6OifAL1GVzIPHg2D+MyUkbNgPWji90t0a8IDk+39w==", + "license": "BSD-3-Clause", + "dependencies": { + "tslib": "2.3.0" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..2eb52f5 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "vue-devui": "^1.6.32" + } +} From 1a86b9bfc170e110d26024bec5f23f430bf34e73 Mon Sep 17 00:00:00 2001 From: monjack Date: Wed, 23 Apr 2025 13:27:25 +0800 Subject: [PATCH 2/4] new Files --- front/public/code/AppendDoc.vue | 32 + front/public/code/BindData.vue | 96 + front/public/code/Calculate.vue | 19 + front/public/code/Command.vue | 47 + front/public/code/DataTable.vue | 60 + front/public/code/DocLang.vue | 27 + front/public/code/DocMode.vue | 20 + front/public/code/EChart.vue | 153 + front/public/code/Editor.vue | 18 + front/public/code/Home.vue | 15 + front/public/code/SaveDoc.vue | 76 + front/public/code/Signature.vue | 44 + front/public/code/Simple.vue | 20 + front/public/code/VitalSigns.vue | 134 + front/public/editor.html | 49 + front/public/editor_dev.html | 54 + front/public/mock/assess_table.html | 48 + front/public/mock/bind_data.html | 140 + front/public/mock/data_table.html | 37 + front/public/mock/en_us.html | 10 + front/public/mock/sign.html | 75 + front/public/mock/yizhu.html | 12 + front/public/mock/zh-bo.html | 1368 + front/public/mock/zh-tw.html | 1167 + front/public/mock/zh-ug.html | 1167 + front/public/vender/JsBarcode.all.js | 3670 ++ front/public/vender/codemirror.js | 1 + front/public/vender/date97/My97DatePicker.htm | 66 + front/public/vender/date97/WdatePicker.js | 678 + front/public/vender/date97/calendar.js | 5 + front/public/vender/date97/lang/en.js | 14 + front/public/vender/date97/lang/zh-cn.js | 14 + front/public/vender/date97/lang/zh-tw.js | 14 + .../public/vender/date97/skin/WdatePicker.css | 11 + .../public/vender/date97/skin/datePicker.gif | Bin 0 -> 1043 bytes .../vender/date97/skin/default/datepicker.css | 328 + .../public/vender/date97/skin/default/img.gif | Bin 0 -> 2504 bytes .../vender/date97/skin/ext/datepicker.css | 309 + .../vender/date97/skin/ext/dateselect.gif | Bin 0 -> 190 bytes .../vender/date97/skin/ext/glass-bg.gif | Bin 0 -> 873 bytes .../vender/date97/skin/ext/hd-sprite.gif | Bin 0 -> 1099 bytes front/public/vender/date97/skin/ext/img.gif | Bin 0 -> 1604 bytes .../vender/date97/skin/ext/left-btn.gif | Bin 0 -> 870 bytes .../vender/date97/skin/ext/left-btn2.gif | Bin 0 -> 113 bytes .../vender/date97/skin/ext/right-btn.gif | Bin 0 -> 871 bytes .../vender/date97/skin/ext/right-btn2.gif | Bin 0 -> 113 bytes .../public/vender/date97/skin/whyGreen/bg.jpg | Bin 0 -> 307 bytes .../date97/skin/whyGreen/datepicker.css | 256 + .../vender/date97/skin/whyGreen/img.gif | Bin 0 -> 1679 bytes front/public/vender/diff.js | 1627 + front/public/vender/fabric.js | 31187 ++++++++++++++++ front/public/vender/fonts/mui.ttf | Bin 0 -> 29884 bytes front/public/vender/jquery/jquery.base64.js | 190 + front/public/vender/jquery/jquery.js | 10872 ++++++ front/public/vender/jquery/jquery.print.js | 255 + .../vender/jquery/jquery.ztree.core.min.js | 1 + .../vender/jquery/jquery.ztree.exedit.min.js | 1 + .../vender/jquery/jquery.ztree.exhide.min.js | 1 + .../jquery/zTreeStyle/img/diy/1_close.png | Bin 0 -> 601 bytes .../jquery/zTreeStyle/img/diy/1_open.png | Bin 0 -> 580 bytes .../vender/jquery/zTreeStyle/img/diy/2.png | Bin 0 -> 570 bytes .../vender/jquery/zTreeStyle/img/diy/3.png | Bin 0 -> 762 bytes .../vender/jquery/zTreeStyle/img/diy/4.png | Bin 0 -> 399 bytes .../vender/jquery/zTreeStyle/img/diy/5.png | Bin 0 -> 710 bytes .../vender/jquery/zTreeStyle/img/diy/6.png | Bin 0 -> 432 bytes .../vender/jquery/zTreeStyle/img/diy/7.png | Bin 0 -> 534 bytes .../vender/jquery/zTreeStyle/img/diy/8.png | Bin 0 -> 529 bytes .../vender/jquery/zTreeStyle/img/diy/9.png | Bin 0 -> 467 bytes .../jquery/zTreeStyle/img/line_conn.gif | Bin 0 -> 45 bytes .../vender/jquery/zTreeStyle/img/loading.gif | Bin 0 -> 381 bytes .../jquery/zTreeStyle/img/zTreeStandard.gif | Bin 0 -> 5564 bytes .../jquery/zTreeStyle/img/zTreeStandard.png | Bin 0 -> 14056 bytes .../jquery/zTreeStyle/img/zTreeStandard.psd | Bin 0 -> 96885 bytes .../vender/jquery/zTreeStyle/zTreeStyle.css | 97 + front/public/vender/mui/mui.min.css | 5 + front/public/vender/mui/mui.min.js | 6 + front/public/vender/mui/mui.picker.min.css | 7 + front/public/vender/mui/mui.picker.min.js | 7 + front/public/vender/qrcode.js | 7 + front/public/vender/requirejs/require.js | 2145 ++ .../signature/jSignature.CompressorSVG.js | 519 + .../vender/signature/jSignature.UndoButton.js | 165 + front/public/vender/signature/jSignature.js | 1486 + front/public/vender/validator.js | 5094 +++ front/public/vender/weui/weui.css | 5659 +++ front/public/vender/weui/weui.min.css | 5 + front/public/vender/weui/weui.min.js | 12 + front/src/App.vue | 240 +- front/src/Menu.vue | 95 + front/src/components/Editor.vue | 18 + front/src/main.js | 13 +- .../src/{views => pages}/404/notFoundPage.vue | 0 front/src/{views => pages}/HomePage.vue | 4 +- .../zl-station/menjizhenItem-tabs/tab2.vue | 99 + .../zl-station/menjizhenItem-tabs/tab3.vue | 157 + .../zl-station/menjizhenItem-tabs/tab4.vue | 118 + .../zl-station/menjizhenItem-tabs/tab5.vue | 150 + .../pages/zl-station/menjizhenItemView.vue | 250 + .../pages/zl-station/zhuyuanItem/subItem.vue | 231 + .../zl-station/zhuyuanItem/tabs/tab2.vue | 407 + .../zl-station/zhuyuanItem/tabs/tab3.vue | 407 + .../zl-station/zhuyuanItem/tabs/tab4.vue | 391 + .../zl-station/zhuyuanItem/tabs/tab5.vue | 39 + .../zl-station/zhuyuanItem/tabs/tab6.vue | 392 + .../src/pages/zl-station/zhuyuanItemView.vue | 109 + front/src/router/index.js | 54 +- .../views/zl-station/menjizhenItemView.vue | 137 - 107 files changed, 72655 insertions(+), 258 deletions(-) create mode 100644 front/public/code/AppendDoc.vue create mode 100644 front/public/code/BindData.vue create mode 100644 front/public/code/Calculate.vue create mode 100644 front/public/code/Command.vue create mode 100644 front/public/code/DataTable.vue create mode 100644 front/public/code/DocLang.vue create mode 100644 front/public/code/DocMode.vue create mode 100644 front/public/code/EChart.vue create mode 100644 front/public/code/Editor.vue create mode 100644 front/public/code/Home.vue create mode 100644 front/public/code/SaveDoc.vue create mode 100644 front/public/code/Signature.vue create mode 100644 front/public/code/Simple.vue create mode 100644 front/public/code/VitalSigns.vue create mode 100644 front/public/editor.html create mode 100644 front/public/editor_dev.html create mode 100644 front/public/mock/assess_table.html create mode 100644 front/public/mock/bind_data.html create mode 100644 front/public/mock/data_table.html create mode 100644 front/public/mock/en_us.html create mode 100644 front/public/mock/sign.html create mode 100644 front/public/mock/yizhu.html create mode 100644 front/public/mock/zh-bo.html create mode 100644 front/public/mock/zh-tw.html create mode 100644 front/public/mock/zh-ug.html create mode 100644 front/public/vender/JsBarcode.all.js create mode 100644 front/public/vender/codemirror.js create mode 100644 front/public/vender/date97/My97DatePicker.htm create mode 100644 front/public/vender/date97/WdatePicker.js create mode 100644 front/public/vender/date97/calendar.js create mode 100644 front/public/vender/date97/lang/en.js create mode 100644 front/public/vender/date97/lang/zh-cn.js create mode 100644 front/public/vender/date97/lang/zh-tw.js create mode 100644 front/public/vender/date97/skin/WdatePicker.css create mode 100644 front/public/vender/date97/skin/datePicker.gif create mode 100644 front/public/vender/date97/skin/default/datepicker.css create mode 100644 front/public/vender/date97/skin/default/img.gif create mode 100644 front/public/vender/date97/skin/ext/datepicker.css create mode 100644 front/public/vender/date97/skin/ext/dateselect.gif create mode 100644 front/public/vender/date97/skin/ext/glass-bg.gif create mode 100644 front/public/vender/date97/skin/ext/hd-sprite.gif create mode 100644 front/public/vender/date97/skin/ext/img.gif create mode 100644 front/public/vender/date97/skin/ext/left-btn.gif create mode 100644 front/public/vender/date97/skin/ext/left-btn2.gif create mode 100644 front/public/vender/date97/skin/ext/right-btn.gif create mode 100644 front/public/vender/date97/skin/ext/right-btn2.gif create mode 100644 front/public/vender/date97/skin/whyGreen/bg.jpg create mode 100644 front/public/vender/date97/skin/whyGreen/datepicker.css create mode 100644 front/public/vender/date97/skin/whyGreen/img.gif create mode 100644 front/public/vender/diff.js create mode 100644 front/public/vender/fabric.js create mode 100644 front/public/vender/fonts/mui.ttf create mode 100644 front/public/vender/jquery/jquery.base64.js create mode 100644 front/public/vender/jquery/jquery.js create mode 100644 front/public/vender/jquery/jquery.print.js create mode 100644 front/public/vender/jquery/jquery.ztree.core.min.js create mode 100644 front/public/vender/jquery/jquery.ztree.exedit.min.js create mode 100644 front/public/vender/jquery/jquery.ztree.exhide.min.js create mode 100644 front/public/vender/jquery/zTreeStyle/img/diy/1_close.png create mode 100644 front/public/vender/jquery/zTreeStyle/img/diy/1_open.png create mode 100644 front/public/vender/jquery/zTreeStyle/img/diy/2.png create mode 100644 front/public/vender/jquery/zTreeStyle/img/diy/3.png create mode 100644 front/public/vender/jquery/zTreeStyle/img/diy/4.png create mode 100644 front/public/vender/jquery/zTreeStyle/img/diy/5.png create mode 100644 front/public/vender/jquery/zTreeStyle/img/diy/6.png create mode 100644 front/public/vender/jquery/zTreeStyle/img/diy/7.png create mode 100644 front/public/vender/jquery/zTreeStyle/img/diy/8.png create mode 100644 front/public/vender/jquery/zTreeStyle/img/diy/9.png create mode 100644 front/public/vender/jquery/zTreeStyle/img/line_conn.gif create mode 100644 front/public/vender/jquery/zTreeStyle/img/loading.gif create mode 100644 front/public/vender/jquery/zTreeStyle/img/zTreeStandard.gif create mode 100644 front/public/vender/jquery/zTreeStyle/img/zTreeStandard.png create mode 100644 front/public/vender/jquery/zTreeStyle/img/zTreeStandard.psd create mode 100644 front/public/vender/jquery/zTreeStyle/zTreeStyle.css create mode 100644 front/public/vender/mui/mui.min.css create mode 100644 front/public/vender/mui/mui.min.js create mode 100644 front/public/vender/mui/mui.picker.min.css create mode 100644 front/public/vender/mui/mui.picker.min.js create mode 100644 front/public/vender/qrcode.js create mode 100644 front/public/vender/requirejs/require.js create mode 100644 front/public/vender/signature/jSignature.CompressorSVG.js create mode 100644 front/public/vender/signature/jSignature.UndoButton.js create mode 100644 front/public/vender/signature/jSignature.js create mode 100644 front/public/vender/validator.js create mode 100644 front/public/vender/weui/weui.css create mode 100644 front/public/vender/weui/weui.min.css create mode 100644 front/public/vender/weui/weui.min.js create mode 100644 front/src/Menu.vue create mode 100644 front/src/components/Editor.vue rename front/src/{views => pages}/404/notFoundPage.vue (100%) rename front/src/{views => pages}/HomePage.vue (96%) create mode 100644 front/src/pages/zl-station/menjizhenItem-tabs/tab2.vue create mode 100644 front/src/pages/zl-station/menjizhenItem-tabs/tab3.vue create mode 100644 front/src/pages/zl-station/menjizhenItem-tabs/tab4.vue create mode 100644 front/src/pages/zl-station/menjizhenItem-tabs/tab5.vue create mode 100644 front/src/pages/zl-station/menjizhenItemView.vue create mode 100644 front/src/pages/zl-station/zhuyuanItem/subItem.vue create mode 100644 front/src/pages/zl-station/zhuyuanItem/tabs/tab2.vue create mode 100644 front/src/pages/zl-station/zhuyuanItem/tabs/tab3.vue create mode 100644 front/src/pages/zl-station/zhuyuanItem/tabs/tab4.vue create mode 100644 front/src/pages/zl-station/zhuyuanItem/tabs/tab5.vue create mode 100644 front/src/pages/zl-station/zhuyuanItem/tabs/tab6.vue create mode 100644 front/src/pages/zl-station/zhuyuanItemView.vue delete mode 100644 front/src/views/zl-station/menjizhenItemView.vue diff --git a/front/public/code/AppendDoc.vue b/front/public/code/AppendDoc.vue new file mode 100644 index 0000000..33e4be4 --- /dev/null +++ b/front/public/code/AppendDoc.vue @@ -0,0 +1,32 @@ + + + + \ No newline at end of file diff --git a/front/public/code/BindData.vue b/front/public/code/BindData.vue new file mode 100644 index 0000000..a8ab79b --- /dev/null +++ b/front/public/code/BindData.vue @@ -0,0 +1,96 @@ + + + \ No newline at end of file diff --git a/front/public/code/Calculate.vue b/front/public/code/Calculate.vue new file mode 100644 index 0000000..3569a6c --- /dev/null +++ b/front/public/code/Calculate.vue @@ -0,0 +1,19 @@ + + + \ No newline at end of file diff --git a/front/public/code/Command.vue b/front/public/code/Command.vue new file mode 100644 index 0000000..6eba34b --- /dev/null +++ b/front/public/code/Command.vue @@ -0,0 +1,47 @@ + + + \ No newline at end of file diff --git a/front/public/code/DataTable.vue b/front/public/code/DataTable.vue new file mode 100644 index 0000000..d2704ef --- /dev/null +++ b/front/public/code/DataTable.vue @@ -0,0 +1,60 @@ + + + + \ No newline at end of file diff --git a/front/public/code/DocLang.vue b/front/public/code/DocLang.vue new file mode 100644 index 0000000..fccfb43 --- /dev/null +++ b/front/public/code/DocLang.vue @@ -0,0 +1,27 @@ + + + \ No newline at end of file diff --git a/front/public/code/DocMode.vue b/front/public/code/DocMode.vue new file mode 100644 index 0000000..2dab3de --- /dev/null +++ b/front/public/code/DocMode.vue @@ -0,0 +1,20 @@ + + + \ No newline at end of file diff --git a/front/public/code/EChart.vue b/front/public/code/EChart.vue new file mode 100644 index 0000000..68f22ca --- /dev/null +++ b/front/public/code/EChart.vue @@ -0,0 +1,153 @@ + + + + \ No newline at end of file diff --git a/front/public/code/Editor.vue b/front/public/code/Editor.vue new file mode 100644 index 0000000..f15a5db --- /dev/null +++ b/front/public/code/Editor.vue @@ -0,0 +1,18 @@ + + + \ No newline at end of file diff --git a/front/public/code/Home.vue b/front/public/code/Home.vue new file mode 100644 index 0000000..c1c5380 --- /dev/null +++ b/front/public/code/Home.vue @@ -0,0 +1,15 @@ + + + \ No newline at end of file diff --git a/front/public/code/SaveDoc.vue b/front/public/code/SaveDoc.vue new file mode 100644 index 0000000..a27ec52 --- /dev/null +++ b/front/public/code/SaveDoc.vue @@ -0,0 +1,76 @@ + + + + \ No newline at end of file diff --git a/front/public/code/Signature.vue b/front/public/code/Signature.vue new file mode 100644 index 0000000..8b041ef --- /dev/null +++ b/front/public/code/Signature.vue @@ -0,0 +1,44 @@ + + + + \ No newline at end of file diff --git a/front/public/code/Simple.vue b/front/public/code/Simple.vue new file mode 100644 index 0000000..68975c6 --- /dev/null +++ b/front/public/code/Simple.vue @@ -0,0 +1,20 @@ + + + \ No newline at end of file diff --git a/front/public/code/VitalSigns.vue b/front/public/code/VitalSigns.vue new file mode 100644 index 0000000..70cfc75 --- /dev/null +++ b/front/public/code/VitalSigns.vue @@ -0,0 +1,134 @@ + + + \ No newline at end of file diff --git a/front/public/editor.html b/front/public/editor.html new file mode 100644 index 0000000..c6c1d8b --- /dev/null +++ b/front/public/editor.html @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + diff --git a/front/public/editor_dev.html b/front/public/editor_dev.html new file mode 100644 index 0000000..057eec0 --- /dev/null +++ b/front/public/editor_dev.html @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + diff --git a/front/public/mock/assess_table.html b/front/public/mock/assess_table.html new file mode 100644 index 0000000..ffd9321 --- /dev/null +++ b/front/public/mock/assess_table.html @@ -0,0 +1,48 @@ +
+
 
+
姓名: + 姓名 +  科室: + 科室 床号: + 床号 住院号: + 住院号 病案号: + 病案号  +
+

抑郁焦虑表

+ + + +

1)我对以往感兴趣的事情还是有兴趣






2)我能够哈哈大笑,并看到事物好的一面






3)我感到愉快






4)我对自己的仪容失去兴趣






5)我对一切都是乐观地向前看






6)我好像感到情绪在渐渐低落






7)我能欣赏一本好书或意向好的广播或电视节目






抑郁得分(0-21分)

 1 

1)我感到紧张(或痛苦)





 

2)我感到有点害怕好像预感到什么可怕的事情要发生






3)我的心中充满烦恼





+ +

4)我能够安闲而轻松地坐着





+ +
+ +

5)我有点坐立不安,好像感到非要活动不可





+ +
+ +

6)我突然发现有恐慌感





+ +
+ +

7)我感到有点害怕,好像某个内脏器官变化了





+ +

+ +焦虑得分

0 
+ +

结果

0-7分为阴性;8-10为轻度;11-14分为中度;15-21分为 度)

+ +
1 





+
\ No newline at end of file diff --git a/front/public/mock/bind_data.html b/front/public/mock/bind_data.html new file mode 100644 index 0000000..a050606 --- /dev/null +++ b/front/public/mock/bind_data.html @@ -0,0 +1,140 @@ + +
+
+
成都中医药大学附属第一医院
+
电子病历
+
. +
+
+
+
姓名: +    性别: +    年龄: +    就诊科室: + 风湿免疫科   就诊号: + + MZ07882405098  +
+
+
就诊时间: +
+ 2024-05-09 14:21:52 +   +
                    + +
+
联系电话: +   家庭住址: + 地址 + +
+
主诉: +   +
+
现病史: +   +
+
既往史: + 既往史  +
+
过敏史: + 过敏史  +
+
诊断: + +
+
处方: +   +
+
建议: + 在用药过程中有任何身体不适,请及时前往实体医院就诊  +
+

+
医师签字: + + 张某某            +   手签: +
+
+ +
\ No newline at end of file diff --git a/front/public/mock/data_table.html b/front/public/mock/data_table.html new file mode 100644 index 0000000..004415d --- /dev/null +++ b/front/public/mock/data_table.html @@ -0,0 +1,37 @@ +
+
+
+

+ + + + + + + + + +
编号名称ID
数据表格使用方法要点:
+
绑定方式一
  1. 右键菜单选择一级菜单“表格”,再选择“表格属性 + +”
  2. 右侧表格属性面板中,列字段里填写绑定JSON数据中对应的KEY值,其中NUM会自动生成编号
  3. 使用editor.bindDataList( 表格ID,JSON数据数组)可以自动渲染表格行
  4.    
+ + + +绑定方式二
  1. 每页打印行以下的第一行作为“模板行”
  2. 选择模板行的各单元格的属性
  3. 单元格的属性面板中用标识作为绑定JSON数据中对应的KEY值,其中NUM会自动生成编号 + +
  4. + +使用editor.bindDataList( 表格ID,JSON数据数组)可以自动渲染表格行 + +



注意点如果数据表格中有列属性,程序会优先方式一方式渲染表格,方式二无效

+ +
+ + +
    +
      +
        +
          +
            +
            \ No newline at end of file diff --git a/front/public/mock/en_us.html b/front/public/mock/en_us.html new file mode 100644 index 0000000..bb11deb --- /dev/null +++ b/front/public/mock/en_us.html @@ -0,0 +1,10 @@ +

            Shanghai First Hospital

            Admission records

            Name:Xin-Hua gender:female age:65Age Department:internal medicine Bed No:0013 Medical record number:100153 


                  Name:Xin Xiuhua Address: HandanTianheyuan, Xiangdu District, City 
                      gender:female employer:-- 
                      age:65 Admission time:2023-07-15 15:44:07 
                      Marriage:Married Recording time:2023-07-15 17:54:07 
                      nationality:Han nationaliy History Narrator:I am
                      Profession:Freelance reliability:reliable

            Chief complaint:Left limb weakness accompanied by slurred speech and right corner of the mouth for 6 hours.  

            History of present illness:The patient had left limb weakness with slurred speech, right corner of the mouth, walking left deviation, unconscious disturbance, no dizziness, no deafness, tinnitus, no blurred vision, no urination and defecation due to no obvious cause 6 hours before admission The incontinence did not improve significantly after rest, and now she came to our hospital urgently for treatment, and was admitted to the hospital for treatment as "cerebral infarction".
                 Since the onset of the disease, the patient had no cough, sputum, and nocturnal paroxysmal pink foamy sputum, no convulsions, no chest pain, and no radiating pain. There were no symptoms of frequent urination, urgency, or dysuria, and no abnormalities were found in the appearance of urine and stool.
              
            Past history:The previous history of "hypertension" was 5 years, the highest blood pressure was 200/120mmHg, and antihypertensive drugs were not used regularly; 4 years ago, he was cured after surgery for "right upper limb fracture"; "acute upper respiratory tract infection" for 7 days, with runny nose Mainly symptoms such as cold, symptoms relieved after oral administration of cold medicine; denied history of diabetes. He denied any history of drug allergy. No history of hepatitis, tuberculosis and other infectious diseases. Vaccination history was ominous, and the systematic review was unremarkable.  

              Personal History:Born in the original place, lived in the local area for a long time, never been to the epidemic area or pastoral area, no venereal disease and travel history, no smoking and drinking habits.  

              Marriage History:Married at the right age, with 1 son and 1 daughter, both spouse and children are in good health. 

            Menstrual history: 136-728-3051 Usually menstruation is regular, natural menopause at the age of 51. 

            birth history: 2-0-0-2, with 1 son and 1 daughter, both of them are healthy.  

              Family History:There was no history of bleeding or genetic disease in the family. There is no history of cancer in the family.  

            physical examination

            T:36.5℃  P:112times/min R:20times/min BP:140/80mmHg

            generally:Normal development, clear mind, slurred speech, cooperation in physical examination.  
            Skin and mucous membranes:The skin has no yellow stain, no bleeding point, blood stasis and ecchymosis. 
            Lymph nodes:Superficial lymph nodes around the body were not palpably enlarged.  
            Head and facial features:No skull deformity. There was no edema in both eyelids, no hyperemia in the conjunctiva, no jaundice in the sclera, bilateral pupils were large and equi-circular, and were sensitive to light reflex. The ear and nose were normal, the left nasolabial fold became shallower, the corners of the mouth deviated to the right, the tongue deviated to the left, the lips were not cyanotic, the pharynx was not congested, and the tonsils were not enlarged.  
            neck:The neck is bilaterally symmetrical and no jugular veins are seen
            . Neck:Both sides of the neck are symmetrical, no jugular vein engorgement
            neck:Both sides of the neck are symmetrical, no jugular vein engorgement
            neck:Both sides of the neck are symmetrical, no jugular vein engorgement
              neck:Both sides of the neck are symmetrical, no jugular vein engorgement
              neck:Both sides of the neck are symmetrical, no jugular vein engorgement
             
            neck:The neck is bilaterally symmetrical and no jugular veins are seen . Neck:
              Both sides of the neck are symmetrical, no jugular vein engorgement 
              neck:Both sides of the neck are symmetrical, no jugular vein engorgement
              neck:Both sides of the neck are symmetrical, no jugular vein engorgement
            neck:Both sides of the neck are symmetrical, no jugular vein engorgement
            neck:Both sides of the neck are symmetrical, no jugular vein engorgement
             
             
            neck:The neck was symmetrical on both sides, no distended jugular veins and abnormal carotid pulses were seen, and the hepatic jugular reflux sign was negative. The neck was soft, no resistance, the trachea was in the middle, the thyroid gland was small, and no vascular murmur was heard.  
            Chest:There was no deformity of the thorax, and both sides were symmetrical, the respiratory rate was consistent on both sides, and the verbal tremors on both sides were equal, without enhancement or weakening.  
            lungs:On percussion, the relative dullness of the lung and liver is located in the fifth intercostal space on the right midclavicular line. The breath sounds of both lungs are clear, and dry and wet rales and pleural friction rub are not heard in both lungs.  
            heart:There was no prominence in the precordial area, no obvious apical beat, no palpable tremor, small heart circle, heart rate 112 beats/min, regular heart rhythm, no murmur heard in the valve auscultation area, no pericardial friction rub and pericardial percussion sound.    

            abdomen:Flat and soft abdomen, no intestinal pattern and peristaltic wave, no abdominal wall varicose veins, no tenderness, no rebound tenderness and muscle tension, no palpation of liver and spleen, abdominal percussion drum sound, no moving dullness, no liver and kidney area Percussion pain, bowel sounds are normal.  
            Anus, external genitalia:Anus and external genitalia were normal. 
            Spine limbs:There was no tenderness in the spine and vertebral bodies, no deformity in the limbs, pitting edema in both lower limbs, muscle strength of the left limb was grade 4, muscle strength of the right limb was grade 5, and the muscle tone of the limbs was normal.  
            nervous system:Bilateral biceps tendon and Achilles tendon reflexes were normal, left Babinski sign was positive, right Babinski sign was not elicited, and bilateral Kernig sign was negative. Bilateral Hoffmann sign, Chvostek sign and Trousseau sign were not elicited. 
             

            Auxiliary inspection

             Electrocardiogram: sinus tachycardia, extensive lead ST-T abnormalities suggest myocardial ischemia.
                Head CT showed: left basal ganglia and right corona radiata small ischemic lesions; cerebral white matter demyelination; senile brain changes; combined with clinical practice, MRI examination is recommended. Chest CT showed: the anterior segment of the right upper lobe and the lingual segment of the left upper lobe fibrous cords and calcified plaques in the right lower lobe; calcification of the aorta and coronary arteries; local thickening of the right pleura.
                Random glucose: 7.26 (mmol/L). The five items of blood lipids showed: triglyceride: 3.01 (mmol/L), total cholesterol: 5.52 (mmol/L), low-density lipoprotein cholesterol: 3.45 (mmol/L), and the rest was normal. Routine blood test showed: white blood cells: 10.34 (10^9/L), and the rest had no obvious abnormalities. C-reactive protein, electrolytes, liver function, kidney function, myocardial enzymes, troponin, five items of blood coagulation, and five items of hepatitis B showed no obvious abnormalities.
             

            Discharge diagnosis:initial diagnosis:
             1. Carotid artery stenosis and cerebral infarction (acute stage)
                 carotid atherosclerosis Carotid artery stenosis
                 Vertebral
                 artery stenosis
             2. Hypertension grade 3 very high risk
             3. Hyperlipidemia
             4. Acute upper respiratory tract infection
                             Xu Jingjiang
                           2023-07-15 
              
             1. Cerebral infarction (acute phase)
             2. Hypertension grade 2 very high risk
             3. Hyperlipidemia   
             4. Acute upper respiratory tract infection 
                                 Xu Jingjiang revised diagnosis on
                               July 25, 2023 : 1. Carotid artery stenosis cerebral infarction (acute phase)      carotid artery Atherosclerotic      carotid stenosis      Vertebral artery stenosis  2. Hypertension grade 3 very high risk  3. Hyperlipidemia  4. Acute upper respiratory infection                       Xu Jingjiang                    2023-07-28   

            + +
            \ No newline at end of file diff --git a/front/public/mock/sign.html b/front/public/mock/sign.html new file mode 100644 index 0000000..f1e02fc --- /dev/null +++ b/front/public/mock/sign.html @@ -0,0 +1,75 @@ + +
            +
            +

            + +

            + +

            + +
            +

            + + 姓名 + + 性别 + + 年龄 + +病历号  +科室  + 床号 +

            + +诊断  + 执行手术 + + {体重} + +

            + +

            + +

            + + +

            + +

            + +

            + +

            + +

            + +

            + +

            + +

            + +

            + +

            + 双击手写签名 签字时间_____年___月___日___ 时____分 

            + 双击手写签名与患者关系_____


            + +

            + + + + + + + + + + + +

            + + + +
            diff --git a/front/public/mock/yizhu.html b/front/public/mock/yizhu.html new file mode 100644 index 0000000..1d906b1 --- /dev/null +++ b/front/public/mock/yizhu.html @@ -0,0 +1,12 @@ + + + 长期医嘱单
            +
            \ No newline at end of file diff --git a/front/public/mock/zh-bo.html b/front/public/mock/zh-bo.html new file mode 100644 index 0000000..5eb3050 --- /dev/null +++ b/front/public/mock/zh-bo.html @@ -0,0 +1,1368 @@ + + + 病案首页
            +
            + +
            + +
            + +
            + +
            + +
            + +
            + +
            + +
            + +
            + +
            + +
            +
            +
            \ No newline at end of file diff --git a/front/public/mock/zh-tw.html b/front/public/mock/zh-tw.html new file mode 100644 index 0000000..7f96890 --- /dev/null +++ b/front/public/mock/zh-tw.html @@ -0,0 +1,1167 @@ + +
            +
            +

             南京醫科大學附屬第一人民醫院12370600493502999Y + +   + +    +

            + +
            +

            + + 1-城鎮職工基本醫療保險 

            +                   3 + + + +

            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            +

            +   + 2019年01月08日 + 5歲 

            + + + + + 2 + + 23.44 + +

            +

            + 農民 + + 已婚 + +

            + 山東省煙台市龍口市石良鎮關李家村124號 + 15553502541 + + 265700 +

            + 山東省煙台市龍口市石良鎮關李家村124號 + + 265700 +

            + + 15553502541 + + 265700 +

            + 刁永進 +山東省煙台市龍口市石良鎮關李家村124號 +

            + + 2-門診 + + 轉診醫療機構名稱 + +

            + 2022年04月14日08時 + + 胸腔外科病房 + + - + + + +

            + 2022年04月24日07時 + + 胸腔外科病房 + + - + + 10 + +

            + +門診診斷  + R91.x03

            +

            +

            +

            +

            +

            + +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            + F61.x00x001

            +

            + 1-有

            +

            +    + +

            +

            + L74.300

            +

            + 1-有

            +

            +

            +

            + F60.800x001

            +

            + 1-有

            + +鼻瘻 + +

            +

            + J34.800x031

            +

            + 1-有

            + + + + + + + +診斷訊息 +

            + 疾病編碼

            +

            + 1-有

            + + + + +癌症 +

            + 疾病編碼

            +

            + 1-有

            + + + + + + + +診斷訊息 +

            + 疾病編碼

            +

            + 1-有

            + + + + + +

            + 疾病編碼

            +

            + 1-有

            + + + + + + + +診斷訊息 +

            + 疾病編碼

            +

            + 1-有

            + + + + +診斷訊息 +

            + 疾病編碼

            +

            + 1-有

            + + + + + + + +診斷訊息 +

            + 疾病編碼

            +

            + 1-有

            + + + + +診斷訊息 +

            + 疾病編碼

            +

            + 1-有

            + + + + + + + +診斷訊息 +

            + 疾病編碼

            +

            + 1-有

            + + + + +診斷訊息 +

            + 疾病編碼

            +

            + 1-有

            + + + + + + + +診斷訊息 +

            + 疾病編碼

            +

            + 1-有

            + + + + +診斷訊息 +

            + 疾病編碼

            +

            + 1-有

            + + + + + + + +診斷訊息 +

            + 疾病編碼

            +

            + 1-有

            + + + + +診斷訊息 +

            + 疾病編碼

            +

            + 1-有

            + + + + + + + +診斷訊息 +

            + 疾病編碼

            +

            + 1-有

            + + + + +診斷訊息 +

            + 疾病編碼

            +

            + 1-有

            + + + + + + + +診斷訊息 +

            + 疾病編碼

            +

            + 1-有

            + + + + +診斷訊息 +

            + 疾病編碼

            +

            + 1-有

            + + + + + + + +診斷訊息 +

            + 疾病編碼

            +

            + 1-有

            + + + + +診斷訊息 +

            + 疾病編碼

            +

            + 1-有

            + + + + + + + +診斷訊息 +

            + 疾病編碼

            +

            + 1-有

            + + + + +診斷訊息 +

            + 疾病編碼

            +

            + 1-有

            +

            +

            +

            + 診斷訊息

            +

            + 疾病編碼

            +

            + 1-有

            +

            + + - + + 中毒疾病編碼

            +

            + + 腺癌 + + M81400/3

            + + + + 202224179 

            +

            + + 病理(包括細胞學 + + 1-無 + + 過敏藥物 + + 1-是 +

            +

            + + 1-A + + 2-陽 +

            +

            + + 科主任 + + 組長 + + 實習醫師 + + 編碼員

            +

            + + 1-甲 + + 品管醫師 + + 品管護士 + 2022年04月24日

            +

            + +

            +

            +

            + +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            +

            + 編碼

            +

            日期

            +

            + 手術名稱

            +

            + 1-一級手術

            +

            + 擇期

            +

            + 術者

            +

            + Ⅰ助

            +

            + Ⅱ助

            +

            + 0

            +

            + 麻醉方式

            +

            + 麻醉醫師

            +

            + 編碼

            +

            日期

            +

            + 手術名稱

            +

            + 1-一級手術

            +

            + 擇期

            +

            + 術者

            +

            + Ⅰ助

            +

            + Ⅱ助

            +

            + /

            +

            + 麻醉方式

            +

            + 麻醉醫師

            +

            + 編碼

            +

            日期

            +

            + 手術名稱

            +

            + 1-一級手術

            +

            + 擇期

            +

            + 術者

            +

            + Ⅰ助

            +

            + Ⅱ助

            +

            + /

            +

            + 麻醉方式

            +

            + 麻醉醫師

            +

            + 編碼

            +

            日期

            +

            + 手術名稱

            +

            + 1-一級手術

            +

            + 擇期

            +

            + 術者

            +

            + Ⅰ助

            +

            + Ⅱ助

            +

            + /

            +

            + 麻醉方式

            +

            + 麻醉醫師

            +

            + 編碼

            +

            日期

            +

            + 手術名稱

            +

            + 1-一級手術

            +

            + 擇期

            +

            + 術者

            +

            + Ⅰ助

            +

            + Ⅱ助

            +

            + /

            +

            + 麻醉方式

            +

            + 麻醉醫師

            +

            + 編碼

            +

            日期

            +

            + 手術名稱

            +

            + 1-一級手術

            +

            + 擇期

            +

            + 術者

            +

            + Ⅰ助

            +

            + Ⅱ助

            +

            + /

            +

            + 麻醉方式

            +

            + 麻醉醫師

            +

            + 編碼

            +

            日期

            +

            + 手術名稱

            +

            + 1-一級手術

            +

            + 擇期

            +

            + 術者

            +

            + Ⅰ助

            +

            + Ⅱ助

            +

            + /

            +

            + 麻醉方式

            +

            + 麻醉醫師

            +

            + 編碼

            +

            日期

            +

            + 手術名稱

            +

            + 1-一級手術

            +

            + 擇期

            +

            + 術者

            +

            + Ⅰ助

            +

            + Ⅱ助

            +

            + /

            +

            + 麻醉方式

            +

            + 麻醉醫師

            +

            + + + -空 + + -空 + + + + -空 + +

            +

            + + 1-醫囑離院 + + 擬接收機構名稱 + + + —-— + +

            + + 擬接收機構名稱 +

            +

            + + 1-無 + + 目的

            +

            + + 天數 + + 小時 + + 分分鐘 + + 天數 + + 小時 + + +

            +

            + + 入院診斷 + 編碼 + + 1-治愈 + +

            + + 0-未做 + + 0-未做 + + 0-未做 + + 0-未做 + + 0-未做 + + 1-有 + + + 感染名稱

            + + 1-有 + + 搶救次數 + + 成功次數 + +

            + + 1-是 + + 1-是 + +

            + + 1-是 + + 1-是 + + 1-有 + +

            + + 1-有 + + 1-有 + +

            + + 1-15日內再住院 + +

            + + 1-是 + + 0-未做 + +

            + + 0-未輸 + + 0-未輸 + +

            + + 紅血球 + + 血小板 + + 血漿 + + 冷沉澱 + + 其他 + +

            + + 0-未用 + + 1-已送檢 + +

            +  

            + +

            + +

            + +

            + + 1-產傷-新生兒 +

            + +

            + +

            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                +
                \ No newline at end of file diff --git a/front/public/mock/zh-ug.html b/front/public/mock/zh-ug.html new file mode 100644 index 0000000..710f9a1 --- /dev/null +++ b/front/public/mock/zh-ug.html @@ -0,0 +1,1167 @@ + +
                +
                +

                 نەنجىڭ تېببىي ئۇنىۋېرسىتېتىغا قاراشلىق تۇنجى خەلق دوختۇرخانىسى 12370600493502999Y + +   + +    +

                + +
                +

                + + 1-شەھەر خىزمەتچىلىرى ئاساسىي داۋالىنىش سۇغۇرتىسى 

                + 001677741400                  3 + + + +

                + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                +

                +  ئايال + 2019-يىل 8-يانۋار + 5 ياش 

                + + + + + 2 + + 23.44 + +

                +

                + دېھقان + + توي قىلغان + +

                + 124-نومۇر ، شەندۇڭ ئۆلكىسى يەنتەي شەھىرى لۇڭكوۋ شەھىرى شىلياڭ بازىرى گۇەنلىجيا يېزىسى + 15553502541 + + 265700 +

                + 124-نومۇر ، شەندۇڭ ئۆلكىسى يەنتەي شەھىرى لۇڭكوۋ شەھىرى شىلياڭ بازىرى گۇەنلىجيا يېزىسى + + 265700 +

                + + 15553502541 + + 265700 +

                + Diao Yongjin +124-نومۇر ، شەندۇڭ ئۆلكىسى يەنتەي شەھىرى لۇڭكوۋ شەھىرى شىلياڭ بازىرى گۇەنلىجيا يېزىسى +

                + + 2-ئامبۇلاتورىيە + + داۋالاش ئاپپاراتىنىڭ ئىسمى + +

                + 2022-يىل 4-ئاينىڭ 14-كۈنى 08:00 + + كۆكرەك ئوپېراتسىيىسى بۆلۈمى + + - + + + +

                + 2022-يىل 4-ئاينىڭ 24-كۈنى 07:00 + + كۆكرەك ئوپېراتسىيىسى بۆلۈمى + + - + + 10 + +

                + +ئامبۇلاتورىيەگە دىئاگنوز قويۇش  + R91.x03

                +

                +

                +

                +

                +

                + +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                + F61.x00x001

                +

                + 1-ھەئە

                +

                +  قاتتىق ئىسسىق  + +

                +

                + L74.300

                +

                + 1-ھەئە

                +

                +

                +

                + F60.800x001

                +

                + 1-ھەئە

                + +بۇرۇن يەللىكى + +

                +

                + J34.800x031

                +

                + 1-ھەئە

                + + + + + + + +دىئاگنوز ئۇچۇرى +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                + + + + +راك +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                + + + + + + + +دىئاگنوز ئۇچۇرى +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                + + + + +hernia +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                + + + + + + + +دىئاگنوز ئۇچۇرى +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                + + + + +دىئاگنوز ئۇچۇرى +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                + + + + + + + +دىئاگنوز ئۇچۇرى +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                + + + + +دىئاگنوز ئۇچۇرى +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                + + + + + + + +دىئاگنوز ئۇچۇرى +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                + + + + +دىئاگنوز ئۇچۇرى +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                + + + + + + + +دىئاگنوز ئۇچۇرى +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                + + + + +دىئاگنوز ئۇچۇرى +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                + + + + + + + +دىئاگنوز ئۇچۇرى +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                + + + + +دىئاگنوز ئۇچۇرى +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                + + + + + + + +دىئاگنوز ئۇچۇرى +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                + + + + +دىئاگنوز ئۇچۇرى +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                + + + + + + + +دىئاگنوز ئۇچۇرى +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                + + + + +دىئاگنوز ئۇچۇرى +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                + + + + + + + +دىئاگنوز ئۇچۇرى +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                + + + + +دىئاگنوز ئۇچۇرى +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                + + + + + + + +دىئاگنوز ئۇچۇرى +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                + + + + +دىئاگنوز ئۇچۇرى +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                +

                +

                +

                + دىئاگنوز ئۇچۇرى

                +

                + كېسەللىك كودى

                +

                + 1-ھەئە

                +

                + + - + + زەھەرلىك كېسەللىك كودى

                +

                + + Adenocarcinoma + + M81400 / 3

                + + + + 202224179 

                +

                + + كېسەللىك ئىلمى (سىتولوگىيەنىمۇ ئۆز ئىچىگە ئالىدۇ) + + 1-None + + سەزگۈر دورا + + 1-ھەئە +

                +

                + + 1-A + + 2-yang +

                +

                + + مۇدىر + + گۇرۇپپا باشلىقى + + پىراكتىكانت + + coder

                +

                + + 1-A + + سۈپەت كونترول دوختۇرى + + سۈپەت كونترول سېستىرا + 2022-يىل 24-ئاپرېل

                +

                + +

                +

                +

                + +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                +

                + كودلاش

                +

                چېسلا

                +

                + ئوپېراتسىيە ئىسمى

                +

                + 1-دەرىجىلىك ئوپېراتسىيە

                +

                + تاللانما چېسلا

                +

                + سېھىرگەر

                +

                + ⅠAssistant

                +

                + ⅡAssistant

                +

                + 0

                +

                + ناركوز ئۇسۇلى

                +

                + ناركوز دوختۇرى

                +

                + كودلاش

                +

                چېسلا

                +

                + ئوپېراتسىيە ئىسمى

                +

                + 1-دەرىجىلىك ئوپېراتسىيە

                +

                + تاللانما چېسلا

                +

                + سېھىرگەر

                +

                + ⅠAssistant

                +

                + ⅡAssistant

                +

                + /

                +

                + ناركوز ئۇسۇلى

                +

                + ناركوز دوختۇرى

                +

                + كودلاش

                +

                چېسلا

                +

                + ئوپېراتسىيە ئىسمى

                +

                + 1-دەرىجىلىك ئوپېراتسىيە

                +

                + تاللانما چېسلا

                +

                + سېھىرگەر

                +

                + ⅠAssistant

                +

                + ⅡAssistant

                +

                + /

                +

                + ناركوز ئۇسۇلى

                +

                + ناركوز دوختۇرى

                +

                + كودلاش

                +

                چېسلا

                +

                + ئوپېراتسىيە ئىسمى

                +

                + 1-دەرىجىلىك ئوپېراتسىيە

                +

                + تاللانما چېسلا

                +

                + سېھىرگەر

                +

                + ⅠAssistant

                +

                + ⅡAssistant

                +

                + /

                +

                + ناركوز ئۇسۇلى

                +

                + ناركوز دوختۇرى

                +

                + كودلاش

                +

                چېسلا

                +

                + ئوپېراتسىيە ئىسمى

                +

                + 1-دەرىجىلىك ئوپېراتسىيە

                +

                + تاللانما چېسلا

                +

                + سېھىرگەر

                +

                + ⅠAssistant

                +

                + ⅡAssistant

                +

                + /

                +

                + ناركوز ئۇسۇلى

                +

                + ناركوز دوختۇرى

                +

                + كودلاش

                +

                چېسلا

                +

                + ئوپېراتسىيە ئىسمى

                +

                + 1-دەرىجىلىك ئوپېراتسىيە

                +

                + تاللانما چېسلا

                +

                + سېھىرگەر

                +

                + ⅠAssistant

                +

                + ⅡAssistant

                +

                + /

                +

                + ناركوز ئۇسۇلى

                +

                + ناركوز دوختۇرى

                +

                + كودلاش

                +

                چېسلا

                +

                + ئوپېراتسىيە ئىسمى

                +

                + 1-دەرىجىلىك ئوپېراتسىيە

                +

                + تاللانما چېسلا

                +

                + سېھىرگەر

                +

                + ⅠAssistant

                +

                + ⅡAssistant

                +

                + /

                +

                + ناركوز ئۇسۇلى

                +

                + ناركوز دوختۇرى

                +

                + كودلاش

                +

                چېسلا

                +

                + ئوپېراتسىيە ئىسمى

                +

                + 1-دەرىجىلىك ئوپېراتسىيە

                +

                + تاللانما چېسلا

                +

                + سېھىرگەر

                +

                + ⅠAssistant

                +

                + ⅡAssistant

                +

                + /

                +

                + ناركوز ئۇسۇلى

                +

                + ناركوز دوختۇرى

                +

                + + + -null + + -null + + + + -null + +

                +

                + + 1-دوختۇردىن مەسلىھەت سوراپ دوختۇرخانىدىن چىقىڭ + + تەكلىپ قىلىنغان قوبۇل قىلغۇچى ئورگاننىڭ ئىسمى + + + ——- + +

                + + تەكلىپ قىلىنغان قوبۇل قىلغۇچى ئورگاننىڭ ئىسمى +

                +

                + + 1-None + + مەقسەت

                +

                + + كۈن + + سائەت + + مىنۇت + + كۈن + + سائەت + _ + قوڭغۇراق +

                +

                + + قوبۇل قىلىش دىئاگنوزى + كودلاش + + 1-داۋالاش + +

                + + 0-not done + + 0-not done + + 0-not done + + 0-not done + + 0-not done + + 1-ھەئە + + + يۇقۇملىنىش ئىسمى

                + + 1-ھەئە + + قۇتقۇزۇش سانى + + مۇۋەپپەقىيەت سانى + +

                + + 1-ھەئە + + 1-ھەئە + +

                + + 1-ھەئە + + 1-ھەئە + + 1-ھەئە + +

                + + 1-ھەئە + + 1-ھەئە + +

                + + 1-15 كۈن ئىچىدە دوختۇرخانىغا كىرىش + +

                + + 1-ھەئە + + 0-not done + +

                + + 0-يوقاپ كەتمىدى + + 0-يوقاپ كەتمىدى + +

                + + قىزىل قان ھۈجەيرىسى + + قان پلاستىنكىسى + + پلازما + + Cryoprecipitate + + other + +

                + + 0-not used + + 1-تەكشۈرۈشكە ئەۋەتىلدى + +

                +  خاتا

                + +

                + +

                + +

                + + 1-تۇغۇلۇش يارىلىنىش-يېڭى تۇغۇلغان بوۋاق +

                + +

                + +

                + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                    +
                    \ No newline at end of file diff --git a/front/public/vender/JsBarcode.all.js b/front/public/vender/JsBarcode.all.js new file mode 100644 index 0000000..e0c6c88 --- /dev/null +++ b/front/public/vender/JsBarcode.all.js @@ -0,0 +1,3670 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _barcodes = __webpack_require__(1); + +var _barcodes2 = _interopRequireDefault(_barcodes); + +var _merge = __webpack_require__(36); + +var _merge2 = _interopRequireDefault(_merge); + +var _linearizeEncodings = __webpack_require__(37); + +var _linearizeEncodings2 = _interopRequireDefault(_linearizeEncodings); + +var _fixOptions = __webpack_require__(38); + +var _fixOptions2 = _interopRequireDefault(_fixOptions); + +var _getRenderProperties = __webpack_require__(39); + +var _getRenderProperties2 = _interopRequireDefault(_getRenderProperties); + +var _optionsFromStrings = __webpack_require__(41); + +var _optionsFromStrings2 = _interopRequireDefault(_optionsFromStrings); + +var _ErrorHandler = __webpack_require__(49); + +var _ErrorHandler2 = _interopRequireDefault(_ErrorHandler); + +var _exceptions = __webpack_require__(48); + +var _defaults = __webpack_require__(42); + +var _defaults2 = _interopRequireDefault(_defaults); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// The protype of the object returned from the JsBarcode() call + + +// Help functions +var API = function API() {}; + +// The first call of the library API +// Will return an object with all barcodes calls and the data that is used +// by the renderers + + +// Default values + + +// Exceptions +// Import all the barcodes +var JsBarcode = function JsBarcode(element, text, options) { + var api = new API(); + + if (typeof element === "undefined") { + throw Error("No element to render on was provided."); + } + + // Variables that will be pased through the API calls + api._renderProperties = (0, _getRenderProperties2.default)(element); + api._encodings = []; + api._options = _defaults2.default; + api._errorHandler = new _ErrorHandler2.default(api); + + // If text is set, use the simple syntax (render the barcode directly) + if (typeof text !== "undefined") { + options = options || {}; + + if (!options.format) { + options.format = autoSelectBarcode(); + } + + api.options(options)[options.format](text, options).render(); + } + + return api; +}; + +// To make tests work TODO: remove +JsBarcode.getModule = function (name) { + return _barcodes2.default[name]; +}; + +// Register all barcodes +for (var name in _barcodes2.default) { + if (_barcodes2.default.hasOwnProperty(name)) { + // Security check if the propery is a prototype property + registerBarcode(_barcodes2.default, name); + } +} +function registerBarcode(barcodes, name) { + API.prototype[name] = API.prototype[name.toUpperCase()] = API.prototype[name.toLowerCase()] = function (text, options) { + var api = this; + return api._errorHandler.wrapBarcodeCall(function () { + // Ensure text is options.text + options.text = typeof options.text === 'undefined' ? undefined : '' + options.text; + + var newOptions = (0, _merge2.default)(api._options, options); + newOptions = (0, _optionsFromStrings2.default)(newOptions); + var Encoder = barcodes[name]; + var encoded = encode(text, Encoder, newOptions); + api._encodings.push(encoded); + + return api; + }); + }; +} + +// encode() handles the Encoder call and builds the binary string to be rendered +function encode(text, Encoder, options) { + // Ensure that text is a string + text = "" + text; + + var encoder = new Encoder(text, options); + + // If the input is not valid for the encoder, throw error. + // If the valid callback option is set, call it instead of throwing error + if (!encoder.valid()) { + throw new _exceptions.InvalidInputException(encoder.constructor.name, text); + } + + // Make a request for the binary data (and other infromation) that should be rendered + var encoded = encoder.encode(); + + // Encodings can be nestled like [[1-1, 1-2], 2, [3-1, 3-2] + // Convert to [1-1, 1-2, 2, 3-1, 3-2] + encoded = (0, _linearizeEncodings2.default)(encoded); + + // Merge + for (var i = 0; i < encoded.length; i++) { + encoded[i].options = (0, _merge2.default)(options, encoded[i].options); + } + + return encoded; +} + +function autoSelectBarcode() { + // If CODE128 exists. Use it + if (_barcodes2.default["CODE128"]) { + return "CODE128"; + } + + // Else, take the first (probably only) barcode + return Object.keys(_barcodes2.default)[0]; +} + +// Sets global encoder options +// Added to the api by the JsBarcode function +API.prototype.options = function (options) { + this._options = (0, _merge2.default)(this._options, options); + return this; +}; + +// Will create a blank space (usually in between barcodes) +API.prototype.blank = function (size) { + var zeroes = new Array(size + 1).join("0"); + this._encodings.push({ data: zeroes }); + return this; +}; + +// Initialize JsBarcode on all HTML elements defined. +API.prototype.init = function () { + // Should do nothing if no elements where found + if (!this._renderProperties) { + return; + } + + // Make sure renderProperies is an array + if (!Array.isArray(this._renderProperties)) { + this._renderProperties = [this._renderProperties]; + } + + var renderProperty; + for (var i in this._renderProperties) { + renderProperty = this._renderProperties[i]; + var options = (0, _merge2.default)(this._options, renderProperty.options); + + if (options.format == "auto") { + options.format = autoSelectBarcode(); + } + + this._errorHandler.wrapBarcodeCall(function () { + var text = options.value; + var Encoder = _barcodes2.default[options.format.toUpperCase()]; + var encoded = encode(text, Encoder, options); + + render(renderProperty, encoded, options); + }); + } +}; + +// The render API call. Calls the real render function. +API.prototype.render = function () { + if (!this._renderProperties) { + throw new _exceptions.NoElementException(); + } + + if (Array.isArray(this._renderProperties)) { + for (var i = 0; i < this._renderProperties.length; i++) { + render(this._renderProperties[i], this._encodings, this._options); + } + } else { + render(this._renderProperties, this._encodings, this._options); + } + + return this; +}; + +API.prototype._defaults = _defaults2.default; + +// Prepares the encodings and calls the renderer +function render(renderProperties, encodings, options) { + encodings = (0, _linearizeEncodings2.default)(encodings); + + for (var i = 0; i < encodings.length; i++) { + encodings[i].options = (0, _merge2.default)(options, encodings[i].options); + (0, _fixOptions2.default)(encodings[i].options); + } + + (0, _fixOptions2.default)(options); + + var Renderer = renderProperties.renderer; + var renderer = new Renderer(renderProperties.element, encodings, options); + renderer.render(); + + if (renderProperties.afterRender) { + renderProperties.afterRender(); + } +} + +// Export to browser +if (typeof window !== "undefined") { + window.JsBarcode = JsBarcode; +} + +// Export to jQuery +/*global jQuery */ +if (typeof jQuery !== 'undefined') { + jQuery.fn.JsBarcode = function (content, options) { + var elementArray = []; + jQuery(this).each(function () { + elementArray.push(this); + }); + return JsBarcode(elementArray, content, options); + }; +} + +// Export to commonJS +module.exports = JsBarcode; + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _CODE = __webpack_require__(2); + +var _CODE2 = __webpack_require__(4); + +var _EAN_UPC = __webpack_require__(12); + +var _ITF = __webpack_require__(22); + +var _MSI = __webpack_require__(26); + +var _pharmacode = __webpack_require__(33); + +var _codabar = __webpack_require__(34); + +var _GenericBarcode = __webpack_require__(35); + +exports.default = { + CODE39: _CODE.CODE39, + CODE128: _CODE2.CODE128, CODE128A: _CODE2.CODE128A, CODE128B: _CODE2.CODE128B, CODE128C: _CODE2.CODE128C, + EAN13: _EAN_UPC.EAN13, EAN8: _EAN_UPC.EAN8, EAN5: _EAN_UPC.EAN5, EAN2: _EAN_UPC.EAN2, UPC: _EAN_UPC.UPC, UPCE: _EAN_UPC.UPCE, + ITF14: _ITF.ITF14, + ITF: _ITF.ITF, + MSI: _MSI.MSI, MSI10: _MSI.MSI10, MSI11: _MSI.MSI11, MSI1010: _MSI.MSI1010, MSI1110: _MSI.MSI1110, + pharmacode: _pharmacode.pharmacode, + codabar: _codabar.codabar, + GenericBarcode: _GenericBarcode.GenericBarcode +}; + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.CODE39 = undefined; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _Barcode2 = __webpack_require__(3); + +var _Barcode3 = _interopRequireDefault(_Barcode2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation: +// https://en.wikipedia.org/wiki/Code_39#Encoding + +var CODE39 = function (_Barcode) { + _inherits(CODE39, _Barcode); + + function CODE39(data, options) { + _classCallCheck(this, CODE39); + + data = data.toUpperCase(); + + // Calculate mod43 checksum if enabled + if (options.mod43) { + data += getCharacter(mod43checksum(data)); + } + + return _possibleConstructorReturn(this, (CODE39.__proto__ || Object.getPrototypeOf(CODE39)).call(this, data, options)); + } + + _createClass(CODE39, [{ + key: "encode", + value: function encode() { + // First character is always a * + var result = getEncoding("*"); + + // Take every character and add the binary representation to the result + for (var i = 0; i < this.data.length; i++) { + result += getEncoding(this.data[i]) + "0"; + } + + // Last character is always a * + result += getEncoding("*"); + + return { + data: result, + text: this.text + }; + } + }, { + key: "valid", + value: function valid() { + return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/) !== -1; + } + }]); + + return CODE39; +}(_Barcode3.default); + +// All characters. The position in the array is the (checksum) value + + +var characters = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "-", ".", " ", "$", "/", "+", "%", "*"]; + +// The decimal representation of the characters, is converted to the +// corresponding binary with the getEncoding function +var encodings = [20957, 29783, 23639, 30485, 20951, 29813, 23669, 20855, 29789, 23645, 29975, 23831, 30533, 22295, 30149, 24005, 21623, 29981, 23837, 22301, 30023, 23879, 30545, 22343, 30161, 24017, 21959, 30065, 23921, 22385, 29015, 18263, 29141, 17879, 29045, 18293, 17783, 29021, 18269, 17477, 17489, 17681, 20753, 35770]; + +// Get the binary representation of a character by converting the encodings +// from decimal to binary +function getEncoding(character) { + return getBinary(characterValue(character)); +} + +function getBinary(characterValue) { + return encodings[characterValue].toString(2); +} + +function getCharacter(characterValue) { + return characters[characterValue]; +} + +function characterValue(character) { + return characters.indexOf(character); +} + +function mod43checksum(data) { + var checksum = 0; + for (var i = 0; i < data.length; i++) { + checksum += characterValue(data[i]); + } + + checksum = checksum % 43; + return checksum; +} + +exports.CODE39 = CODE39; + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var Barcode = function Barcode(data, options) { + _classCallCheck(this, Barcode); + + this.data = data; + this.text = options.text || data; + this.options = options; +}; + +exports.default = Barcode; + +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.CODE128C = exports.CODE128B = exports.CODE128A = exports.CODE128 = undefined; + +var _CODE128_AUTO = __webpack_require__(5); + +var _CODE128_AUTO2 = _interopRequireDefault(_CODE128_AUTO); + +var _CODE128A = __webpack_require__(9); + +var _CODE128A2 = _interopRequireDefault(_CODE128A); + +var _CODE128B = __webpack_require__(10); + +var _CODE128B2 = _interopRequireDefault(_CODE128B); + +var _CODE128C = __webpack_require__(11); + +var _CODE128C2 = _interopRequireDefault(_CODE128C); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.CODE128 = _CODE128_AUTO2.default; +exports.CODE128A = _CODE128A2.default; +exports.CODE128B = _CODE128B2.default; +exports.CODE128C = _CODE128C2.default; + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _CODE2 = __webpack_require__(6); + +var _CODE3 = _interopRequireDefault(_CODE2); + +var _auto = __webpack_require__(8); + +var _auto2 = _interopRequireDefault(_auto); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var CODE128AUTO = function (_CODE) { + _inherits(CODE128AUTO, _CODE); + + function CODE128AUTO(data, options) { + _classCallCheck(this, CODE128AUTO); + + // ASCII value ranges 0-127, 200-211 + if (/^[\x00-\x7F\xC8-\xD3]+$/.test(data)) { + var _this = _possibleConstructorReturn(this, (CODE128AUTO.__proto__ || Object.getPrototypeOf(CODE128AUTO)).call(this, (0, _auto2.default)(data), options)); + } else { + var _this = _possibleConstructorReturn(this, (CODE128AUTO.__proto__ || Object.getPrototypeOf(CODE128AUTO)).call(this, data, options)); + } + return _possibleConstructorReturn(_this); + } + + return CODE128AUTO; +}(_CODE3.default); + +exports.default = CODE128AUTO; + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _Barcode2 = __webpack_require__(3); + +var _Barcode3 = _interopRequireDefault(_Barcode2); + +var _constants = __webpack_require__(7); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +// This is the master class, +// it does require the start code to be included in the string +var CODE128 = function (_Barcode) { + _inherits(CODE128, _Barcode); + + function CODE128(data, options) { + _classCallCheck(this, CODE128); + + // Get array of ascii codes from data + var _this = _possibleConstructorReturn(this, (CODE128.__proto__ || Object.getPrototypeOf(CODE128)).call(this, data.substring(1), options)); + + _this.bytes = data.split('').map(function (char) { + return char.charCodeAt(0); + }); + return _this; + } + + _createClass(CODE128, [{ + key: 'valid', + value: function valid() { + // ASCII value ranges 0-127, 200-211 + return (/^[\x00-\x7F\xC8-\xD3]+$/.test(this.data) + ); + } + + // The public encoding function + + }, { + key: 'encode', + value: function encode() { + var bytes = this.bytes; + // Remove the start code from the bytes and set its index + var startIndex = bytes.shift() - 105; + // Get start set by index + var startSet = _constants.SET_BY_CODE[startIndex]; + + if (startSet === undefined) { + throw new RangeError('The encoding does not start with a start character.'); + } + + if (this.shouldEncodeAsEan128() === true) { + bytes.unshift(_constants.FNC1); + } + + // Start encode with the right type + var encodingResult = CODE128.next(bytes, 1, startSet); + + return { + text: this.text === this.data ? this.text.replace(/[^\x20-\x7E]/g, '') : this.text, + data: + // Add the start bits + CODE128.getBar(startIndex) + + // Add the encoded bits + encodingResult.result + + // Add the checksum + CODE128.getBar((encodingResult.checksum + startIndex) % _constants.MODULO) + + // Add the end bits + CODE128.getBar(_constants.STOP) + }; + } + + // GS1-128/EAN-128 + + }, { + key: 'shouldEncodeAsEan128', + value: function shouldEncodeAsEan128() { + var isEAN128 = this.options.ean128 || false; + if (typeof isEAN128 === 'string') { + isEAN128 = isEAN128.toLowerCase() === 'true'; + } + return isEAN128; + } + + // Get a bar symbol by index + + }], [{ + key: 'getBar', + value: function getBar(index) { + return _constants.BARS[index] ? _constants.BARS[index].toString() : ''; + } + + // Correct an index by a set and shift it from the bytes array + + }, { + key: 'correctIndex', + value: function correctIndex(bytes, set) { + if (set === _constants.SET_A) { + var charCode = bytes.shift(); + return charCode < 32 ? charCode + 64 : charCode - 32; + } else if (set === _constants.SET_B) { + return bytes.shift() - 32; + } else { + return (bytes.shift() - 48) * 10 + bytes.shift() - 48; + } + } + }, { + key: 'next', + value: function next(bytes, pos, set) { + if (!bytes.length) { + return { result: '', checksum: 0 }; + } + + var nextCode = void 0, + index = void 0; + + // Special characters + if (bytes[0] >= 200) { + index = bytes.shift() - 105; + var nextSet = _constants.SWAP[index]; + + // Swap to other set + if (nextSet !== undefined) { + nextCode = CODE128.next(bytes, pos + 1, nextSet); + } + // Continue on current set but encode a special character + else { + // Shift + if ((set === _constants.SET_A || set === _constants.SET_B) && index === _constants.SHIFT) { + // Convert the next character so that is encoded correctly + bytes[0] = set === _constants.SET_A ? bytes[0] > 95 ? bytes[0] - 96 : bytes[0] : bytes[0] < 32 ? bytes[0] + 96 : bytes[0]; + } + nextCode = CODE128.next(bytes, pos + 1, set); + } + } + // Continue encoding + else { + index = CODE128.correctIndex(bytes, set); + nextCode = CODE128.next(bytes, pos + 1, set); + } + + // Get the correct binary encoding and calculate the weight + var enc = CODE128.getBar(index); + var weight = index * pos; + + return { + result: enc + nextCode.result, + checksum: weight + nextCode.checksum + }; + } + }]); + + return CODE128; +}(_Barcode3.default); + +exports.default = CODE128; + +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _SET_BY_CODE; + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// constants for internal usage +var SET_A = exports.SET_A = 0; +var SET_B = exports.SET_B = 1; +var SET_C = exports.SET_C = 2; + +// Special characters +var SHIFT = exports.SHIFT = 98; +var START_A = exports.START_A = 103; +var START_B = exports.START_B = 104; +var START_C = exports.START_C = 105; +var MODULO = exports.MODULO = 103; +var STOP = exports.STOP = 106; +var FNC1 = exports.FNC1 = 207; + +// Get set by start code +var SET_BY_CODE = exports.SET_BY_CODE = (_SET_BY_CODE = {}, _defineProperty(_SET_BY_CODE, START_A, SET_A), _defineProperty(_SET_BY_CODE, START_B, SET_B), _defineProperty(_SET_BY_CODE, START_C, SET_C), _SET_BY_CODE); + +// Get next set by code +var SWAP = exports.SWAP = { + 101: SET_A, + 100: SET_B, + 99: SET_C +}; + +var A_START_CHAR = exports.A_START_CHAR = String.fromCharCode(208); // START_A + 105 +var B_START_CHAR = exports.B_START_CHAR = String.fromCharCode(209); // START_B + 105 +var C_START_CHAR = exports.C_START_CHAR = String.fromCharCode(210); // START_C + 105 + +// 128A (Code Set A) +// ASCII characters 00 to 95 (0–9, A–Z and control codes), special characters, and FNC 1–4 +var A_CHARS = exports.A_CHARS = "[\x00-\x5F\xC8-\xCF]"; + +// 128B (Code Set B) +// ASCII characters 32 to 127 (0–9, A–Z, a–z), special characters, and FNC 1–4 +var B_CHARS = exports.B_CHARS = "[\x20-\x7F\xC8-\xCF]"; + +// 128C (Code Set C) +// 00–99 (encodes two digits with a single code point) and FNC1 +var C_CHARS = exports.C_CHARS = "(\xCF*[0-9]{2}\xCF*)"; + +// CODE128 includes 107 symbols: +// 103 data symbols, 3 start symbols (A, B and C), and 1 stop symbol (the last one) +// Each symbol consist of three black bars (1) and three white spaces (0). +var BARS = exports.BARS = [11011001100, 11001101100, 11001100110, 10010011000, 10010001100, 10001001100, 10011001000, 10011000100, 10001100100, 11001001000, 11001000100, 11000100100, 10110011100, 10011011100, 10011001110, 10111001100, 10011101100, 10011100110, 11001110010, 11001011100, 11001001110, 11011100100, 11001110100, 11101101110, 11101001100, 11100101100, 11100100110, 11101100100, 11100110100, 11100110010, 11011011000, 11011000110, 11000110110, 10100011000, 10001011000, 10001000110, 10110001000, 10001101000, 10001100010, 11010001000, 11000101000, 11000100010, 10110111000, 10110001110, 10001101110, 10111011000, 10111000110, 10001110110, 11101110110, 11010001110, 11000101110, 11011101000, 11011100010, 11011101110, 11101011000, 11101000110, 11100010110, 11101101000, 11101100010, 11100011010, 11101111010, 11001000010, 11110001010, 10100110000, 10100001100, 10010110000, 10010000110, 10000101100, 10000100110, 10110010000, 10110000100, 10011010000, 10011000010, 10000110100, 10000110010, 11000010010, 11001010000, 11110111010, 11000010100, 10001111010, 10100111100, 10010111100, 10010011110, 10111100100, 10011110100, 10011110010, 11110100100, 11110010100, 11110010010, 11011011110, 11011110110, 11110110110, 10101111000, 10100011110, 10001011110, 10111101000, 10111100010, 11110101000, 11110100010, 10111011110, 10111101110, 11101011110, 11110101110, 11010000100, 11010010000, 11010011100, 1100011101011]; + +/***/ }), +/* 8 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _constants = __webpack_require__(7); + +// Match Set functions +var matchSetALength = function matchSetALength(string) { + return string.match(new RegExp('^' + _constants.A_CHARS + '*'))[0].length; +}; +var matchSetBLength = function matchSetBLength(string) { + return string.match(new RegExp('^' + _constants.B_CHARS + '*'))[0].length; +}; +var matchSetC = function matchSetC(string) { + return string.match(new RegExp('^' + _constants.C_CHARS + '*'))[0]; +}; + +// CODE128A or CODE128B +function autoSelectFromAB(string, isA) { + var ranges = isA ? _constants.A_CHARS : _constants.B_CHARS; + var untilC = string.match(new RegExp('^(' + ranges + '+?)(([0-9]{2}){2,})([^0-9]|$)')); + + if (untilC) { + return untilC[1] + String.fromCharCode(204) + autoSelectFromC(string.substring(untilC[1].length)); + } + + var chars = string.match(new RegExp('^' + ranges + '+'))[0]; + + if (chars.length === string.length) { + return string; + } + + return chars + String.fromCharCode(isA ? 205 : 206) + autoSelectFromAB(string.substring(chars.length), !isA); +} + +// CODE128C +function autoSelectFromC(string) { + var cMatch = matchSetC(string); + var length = cMatch.length; + + if (length === string.length) { + return string; + } + + string = string.substring(length); + + // Select A/B depending on the longest match + var isA = matchSetALength(string) >= matchSetBLength(string); + return cMatch + String.fromCharCode(isA ? 206 : 205) + autoSelectFromAB(string, isA); +} + +// Detect Code Set (A, B or C) and format the string + +exports.default = function (string) { + var newString = void 0; + var cLength = matchSetC(string).length; + + // Select 128C if the string start with enough digits + if (cLength >= 2) { + newString = _constants.C_START_CHAR + autoSelectFromC(string); + } else { + // Select A/B depending on the longest match + var isA = matchSetALength(string) > matchSetBLength(string); + newString = (isA ? _constants.A_START_CHAR : _constants.B_START_CHAR) + autoSelectFromAB(string, isA); + } + + return newString.replace(/[\xCD\xCE]([^])[\xCD\xCE]/, // Any sequence between 205 and 206 characters + function (match, char) { + return String.fromCharCode(203) + char; + }); +}; + +/***/ }), +/* 9 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _CODE2 = __webpack_require__(6); + +var _CODE3 = _interopRequireDefault(_CODE2); + +var _constants = __webpack_require__(7); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var CODE128A = function (_CODE) { + _inherits(CODE128A, _CODE); + + function CODE128A(string, options) { + _classCallCheck(this, CODE128A); + + return _possibleConstructorReturn(this, (CODE128A.__proto__ || Object.getPrototypeOf(CODE128A)).call(this, _constants.A_START_CHAR + string, options)); + } + + _createClass(CODE128A, [{ + key: 'valid', + value: function valid() { + return new RegExp('^' + _constants.A_CHARS + '+$').test(this.data); + } + }]); + + return CODE128A; +}(_CODE3.default); + +exports.default = CODE128A; + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _CODE2 = __webpack_require__(6); + +var _CODE3 = _interopRequireDefault(_CODE2); + +var _constants = __webpack_require__(7); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var CODE128B = function (_CODE) { + _inherits(CODE128B, _CODE); + + function CODE128B(string, options) { + _classCallCheck(this, CODE128B); + + return _possibleConstructorReturn(this, (CODE128B.__proto__ || Object.getPrototypeOf(CODE128B)).call(this, _constants.B_START_CHAR + string, options)); + } + + _createClass(CODE128B, [{ + key: 'valid', + value: function valid() { + return new RegExp('^' + _constants.B_CHARS + '+$').test(this.data); + } + }]); + + return CODE128B; +}(_CODE3.default); + +exports.default = CODE128B; + +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _CODE2 = __webpack_require__(6); + +var _CODE3 = _interopRequireDefault(_CODE2); + +var _constants = __webpack_require__(7); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var CODE128C = function (_CODE) { + _inherits(CODE128C, _CODE); + + function CODE128C(string, options) { + _classCallCheck(this, CODE128C); + + return _possibleConstructorReturn(this, (CODE128C.__proto__ || Object.getPrototypeOf(CODE128C)).call(this, _constants.C_START_CHAR + string, options)); + } + + _createClass(CODE128C, [{ + key: 'valid', + value: function valid() { + return new RegExp('^' + _constants.C_CHARS + '+$').test(this.data); + } + }]); + + return CODE128C; +}(_CODE3.default); + +exports.default = CODE128C; + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.UPCE = exports.UPC = exports.EAN2 = exports.EAN5 = exports.EAN8 = exports.EAN13 = undefined; + +var _EAN = __webpack_require__(13); + +var _EAN2 = _interopRequireDefault(_EAN); + +var _EAN3 = __webpack_require__(17); + +var _EAN4 = _interopRequireDefault(_EAN3); + +var _EAN5 = __webpack_require__(18); + +var _EAN6 = _interopRequireDefault(_EAN5); + +var _EAN7 = __webpack_require__(19); + +var _EAN8 = _interopRequireDefault(_EAN7); + +var _UPC = __webpack_require__(20); + +var _UPC2 = _interopRequireDefault(_UPC); + +var _UPCE = __webpack_require__(21); + +var _UPCE2 = _interopRequireDefault(_UPCE); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.EAN13 = _EAN2.default; +exports.EAN8 = _EAN4.default; +exports.EAN5 = _EAN6.default; +exports.EAN2 = _EAN8.default; +exports.UPC = _UPC2.default; +exports.UPCE = _UPCE2.default; + +/***/ }), +/* 13 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + +var _constants = __webpack_require__(14); + +var _EAN2 = __webpack_require__(15); + +var _EAN3 = _interopRequireDefault(_EAN2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation: +// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Binary_encoding_of_data_digits_into_EAN-13_barcode + +// Calculate the checksum digit +// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Calculation_of_checksum_digit +var checksum = function checksum(number) { + var res = number.substr(0, 12).split('').map(function (n) { + return +n; + }).reduce(function (sum, a, idx) { + return idx % 2 ? sum + a * 3 : sum + a; + }, 0); + + return (10 - res % 10) % 10; +}; + +var EAN13 = function (_EAN) { + _inherits(EAN13, _EAN); + + function EAN13(data, options) { + _classCallCheck(this, EAN13); + + // Add checksum if it does not exist + if (data.search(/^[0-9]{12}$/) !== -1) { + data += checksum(data); + } + + // Adds a last character to the end of the barcode + var _this = _possibleConstructorReturn(this, (EAN13.__proto__ || Object.getPrototypeOf(EAN13)).call(this, data, options)); + + _this.lastChar = options.lastChar; + return _this; + } + + _createClass(EAN13, [{ + key: 'valid', + value: function valid() { + return this.data.search(/^[0-9]{13}$/) !== -1 && +this.data[12] === checksum(this.data); + } + }, { + key: 'leftText', + value: function leftText() { + return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'leftText', this).call(this, 1, 6); + } + }, { + key: 'leftEncode', + value: function leftEncode() { + var data = this.data.substr(1, 6); + var structure = _constants.EAN13_STRUCTURE[this.data[0]]; + return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'leftEncode', this).call(this, data, structure); + } + }, { + key: 'rightText', + value: function rightText() { + return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'rightText', this).call(this, 7, 6); + } + }, { + key: 'rightEncode', + value: function rightEncode() { + var data = this.data.substr(7, 6); + return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'rightEncode', this).call(this, data, 'RRRRRR'); + } + + // The "standard" way of printing EAN13 barcodes with guard bars + + }, { + key: 'encodeGuarded', + value: function encodeGuarded() { + var data = _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'encodeGuarded', this).call(this); + + // Extend data with left digit & last character + if (this.options.displayValue) { + data.unshift({ + data: '000000000000', + text: this.text.substr(0, 1), + options: { textAlign: 'left', fontSize: this.fontSize } + }); + + if (this.options.lastChar) { + data.push({ + data: '00' + }); + data.push({ + data: '00000', + text: this.options.lastChar, + options: { fontSize: this.fontSize } + }); + } + } + + return data; + } + }]); + + return EAN13; +}(_EAN3.default); + +exports.default = EAN13; + +/***/ }), +/* 14 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +// Standard start end and middle bits +var SIDE_BIN = exports.SIDE_BIN = '101'; +var MIDDLE_BIN = exports.MIDDLE_BIN = '01010'; + +var BINARIES = exports.BINARIES = { + 'L': [// The L (left) type of encoding + '0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011'], + 'G': [// The G type of encoding + '0100111', '0110011', '0011011', '0100001', '0011101', '0111001', '0000101', '0010001', '0001001', '0010111'], + 'R': [// The R (right) type of encoding + '1110010', '1100110', '1101100', '1000010', '1011100', '1001110', '1010000', '1000100', '1001000', '1110100'], + 'O': [// The O (odd) encoding for UPC-E + '0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011'], + 'E': [// The E (even) encoding for UPC-E + '0100111', '0110011', '0011011', '0100001', '0011101', '0111001', '0000101', '0010001', '0001001', '0010111'] +}; + +// Define the EAN-2 structure +var EAN2_STRUCTURE = exports.EAN2_STRUCTURE = ['LL', 'LG', 'GL', 'GG']; + +// Define the EAN-5 structure +var EAN5_STRUCTURE = exports.EAN5_STRUCTURE = ['GGLLL', 'GLGLL', 'GLLGL', 'GLLLG', 'LGGLL', 'LLGGL', 'LLLGG', 'LGLGL', 'LGLLG', 'LLGLG']; + +// Define the EAN-13 structure +var EAN13_STRUCTURE = exports.EAN13_STRUCTURE = ['LLLLLL', 'LLGLGG', 'LLGGLG', 'LLGGGL', 'LGLLGG', 'LGGLLG', 'LGGGLL', 'LGLGLG', 'LGLGGL', 'LGGLGL']; + +/***/ }), +/* 15 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _constants = __webpack_require__(14); + +var _encoder = __webpack_require__(16); + +var _encoder2 = _interopRequireDefault(_encoder); + +var _Barcode2 = __webpack_require__(3); + +var _Barcode3 = _interopRequireDefault(_Barcode2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +// Base class for EAN8 & EAN13 +var EAN = function (_Barcode) { + _inherits(EAN, _Barcode); + + function EAN(data, options) { + _classCallCheck(this, EAN); + + // Make sure the font is not bigger than the space between the guard bars + var _this = _possibleConstructorReturn(this, (EAN.__proto__ || Object.getPrototypeOf(EAN)).call(this, data, options)); + + _this.fontSize = !options.flat && options.fontSize > options.width * 10 ? options.width * 10 : options.fontSize; + + // Make the guard bars go down half the way of the text + _this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin; + return _this; + } + + _createClass(EAN, [{ + key: 'encode', + value: function encode() { + return this.options.flat ? this.encodeFlat() : this.encodeGuarded(); + } + }, { + key: 'leftText', + value: function leftText(from, to) { + return this.text.substr(from, to); + } + }, { + key: 'leftEncode', + value: function leftEncode(data, structure) { + return (0, _encoder2.default)(data, structure); + } + }, { + key: 'rightText', + value: function rightText(from, to) { + return this.text.substr(from, to); + } + }, { + key: 'rightEncode', + value: function rightEncode(data, structure) { + return (0, _encoder2.default)(data, structure); + } + }, { + key: 'encodeGuarded', + value: function encodeGuarded() { + var textOptions = { fontSize: this.fontSize }; + var guardOptions = { height: this.guardHeight }; + + return [{ data: _constants.SIDE_BIN, options: guardOptions }, { data: this.leftEncode(), text: this.leftText(), options: textOptions }, { data: _constants.MIDDLE_BIN, options: guardOptions }, { data: this.rightEncode(), text: this.rightText(), options: textOptions }, { data: _constants.SIDE_BIN, options: guardOptions }]; + } + }, { + key: 'encodeFlat', + value: function encodeFlat() { + var data = [_constants.SIDE_BIN, this.leftEncode(), _constants.MIDDLE_BIN, this.rightEncode(), _constants.SIDE_BIN]; + + return { + data: data.join(''), + text: this.text + }; + } + }]); + + return EAN; +}(_Barcode3.default); + +exports.default = EAN; + +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _constants = __webpack_require__(14); + +// Encode data string +var encode = function encode(data, structure, separator) { + var encoded = data.split('').map(function (val, idx) { + return _constants.BINARIES[structure[idx]]; + }).map(function (val, idx) { + return val ? val[data[idx]] : ''; + }); + + if (separator) { + var last = data.length - 1; + encoded = encoded.map(function (val, idx) { + return idx < last ? val + separator : val; + }); + } + + return encoded.join(''); +}; + +exports.default = encode; + +/***/ }), +/* 17 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + +var _EAN2 = __webpack_require__(15); + +var _EAN3 = _interopRequireDefault(_EAN2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation: +// http://www.barcodeisland.com/ean8.phtml + +// Calculate the checksum digit +var checksum = function checksum(number) { + var res = number.substr(0, 7).split('').map(function (n) { + return +n; + }).reduce(function (sum, a, idx) { + return idx % 2 ? sum + a : sum + a * 3; + }, 0); + + return (10 - res % 10) % 10; +}; + +var EAN8 = function (_EAN) { + _inherits(EAN8, _EAN); + + function EAN8(data, options) { + _classCallCheck(this, EAN8); + + // Add checksum if it does not exist + if (data.search(/^[0-9]{7}$/) !== -1) { + data += checksum(data); + } + + return _possibleConstructorReturn(this, (EAN8.__proto__ || Object.getPrototypeOf(EAN8)).call(this, data, options)); + } + + _createClass(EAN8, [{ + key: 'valid', + value: function valid() { + return this.data.search(/^[0-9]{8}$/) !== -1 && +this.data[7] === checksum(this.data); + } + }, { + key: 'leftText', + value: function leftText() { + return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'leftText', this).call(this, 0, 4); + } + }, { + key: 'leftEncode', + value: function leftEncode() { + var data = this.data.substr(0, 4); + return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'leftEncode', this).call(this, data, 'LLLL'); + } + }, { + key: 'rightText', + value: function rightText() { + return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'rightText', this).call(this, 4, 4); + } + }, { + key: 'rightEncode', + value: function rightEncode() { + var data = this.data.substr(4, 4); + return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'rightEncode', this).call(this, data, 'RRRR'); + } + }]); + + return EAN8; +}(_EAN3.default); + +exports.default = EAN8; + +/***/ }), +/* 18 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _constants = __webpack_require__(14); + +var _encoder = __webpack_require__(16); + +var _encoder2 = _interopRequireDefault(_encoder); + +var _Barcode2 = __webpack_require__(3); + +var _Barcode3 = _interopRequireDefault(_Barcode2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation: +// https://en.wikipedia.org/wiki/EAN_5#Encoding + +var checksum = function checksum(data) { + var result = data.split('').map(function (n) { + return +n; + }).reduce(function (sum, a, idx) { + return idx % 2 ? sum + a * 9 : sum + a * 3; + }, 0); + return result % 10; +}; + +var EAN5 = function (_Barcode) { + _inherits(EAN5, _Barcode); + + function EAN5(data, options) { + _classCallCheck(this, EAN5); + + return _possibleConstructorReturn(this, (EAN5.__proto__ || Object.getPrototypeOf(EAN5)).call(this, data, options)); + } + + _createClass(EAN5, [{ + key: 'valid', + value: function valid() { + return this.data.search(/^[0-9]{5}$/) !== -1; + } + }, { + key: 'encode', + value: function encode() { + var structure = _constants.EAN5_STRUCTURE[checksum(this.data)]; + return { + data: '1011' + (0, _encoder2.default)(this.data, structure, '01'), + text: this.text + }; + } + }]); + + return EAN5; +}(_Barcode3.default); + +exports.default = EAN5; + +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _constants = __webpack_require__(14); + +var _encoder = __webpack_require__(16); + +var _encoder2 = _interopRequireDefault(_encoder); + +var _Barcode2 = __webpack_require__(3); + +var _Barcode3 = _interopRequireDefault(_Barcode2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation: +// https://en.wikipedia.org/wiki/EAN_2#Encoding + +var EAN2 = function (_Barcode) { + _inherits(EAN2, _Barcode); + + function EAN2(data, options) { + _classCallCheck(this, EAN2); + + return _possibleConstructorReturn(this, (EAN2.__proto__ || Object.getPrototypeOf(EAN2)).call(this, data, options)); + } + + _createClass(EAN2, [{ + key: 'valid', + value: function valid() { + return this.data.search(/^[0-9]{2}$/) !== -1; + } + }, { + key: 'encode', + value: function encode() { + // Choose the structure based on the number mod 4 + var structure = _constants.EAN2_STRUCTURE[parseInt(this.data) % 4]; + return { + // Start bits + Encode the two digits with 01 in between + data: '1011' + (0, _encoder2.default)(this.data, structure, '01'), + text: this.text + }; + } + }]); + + return EAN2; +}(_Barcode3.default); + +exports.default = EAN2; + +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +exports.checksum = checksum; + +var _encoder = __webpack_require__(16); + +var _encoder2 = _interopRequireDefault(_encoder); + +var _Barcode2 = __webpack_require__(3); + +var _Barcode3 = _interopRequireDefault(_Barcode2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation: +// https://en.wikipedia.org/wiki/Universal_Product_Code#Encoding + +var UPC = function (_Barcode) { + _inherits(UPC, _Barcode); + + function UPC(data, options) { + _classCallCheck(this, UPC); + + // Add checksum if it does not exist + if (data.search(/^[0-9]{11}$/) !== -1) { + data += checksum(data); + } + + var _this = _possibleConstructorReturn(this, (UPC.__proto__ || Object.getPrototypeOf(UPC)).call(this, data, options)); + + _this.displayValue = options.displayValue; + + // Make sure the font is not bigger than the space between the guard bars + if (options.fontSize > options.width * 10) { + _this.fontSize = options.width * 10; + } else { + _this.fontSize = options.fontSize; + } + + // Make the guard bars go down half the way of the text + _this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin; + return _this; + } + + _createClass(UPC, [{ + key: "valid", + value: function valid() { + return this.data.search(/^[0-9]{12}$/) !== -1 && this.data[11] == checksum(this.data); + } + }, { + key: "encode", + value: function encode() { + if (this.options.flat) { + return this.flatEncoding(); + } else { + return this.guardedEncoding(); + } + } + }, { + key: "flatEncoding", + value: function flatEncoding() { + var result = ""; + + result += "101"; + result += (0, _encoder2.default)(this.data.substr(0, 6), "LLLLLL"); + result += "01010"; + result += (0, _encoder2.default)(this.data.substr(6, 6), "RRRRRR"); + result += "101"; + + return { + data: result, + text: this.text + }; + } + }, { + key: "guardedEncoding", + value: function guardedEncoding() { + var result = []; + + // Add the first digit + if (this.displayValue) { + result.push({ + data: "00000000", + text: this.text.substr(0, 1), + options: { textAlign: "left", fontSize: this.fontSize } + }); + } + + // Add the guard bars + result.push({ + data: "101" + (0, _encoder2.default)(this.data[0], "L"), + options: { height: this.guardHeight } + }); + + // Add the left side + result.push({ + data: (0, _encoder2.default)(this.data.substr(1, 5), "LLLLL"), + text: this.text.substr(1, 5), + options: { fontSize: this.fontSize } + }); + + // Add the middle bits + result.push({ + data: "01010", + options: { height: this.guardHeight } + }); + + // Add the right side + result.push({ + data: (0, _encoder2.default)(this.data.substr(6, 5), "RRRRR"), + text: this.text.substr(6, 5), + options: { fontSize: this.fontSize } + }); + + // Add the end bits + result.push({ + data: (0, _encoder2.default)(this.data[11], "R") + "101", + options: { height: this.guardHeight } + }); + + // Add the last digit + if (this.displayValue) { + result.push({ + data: "00000000", + text: this.text.substr(11, 1), + options: { textAlign: "right", fontSize: this.fontSize } + }); + } + + return result; + } + }]); + + return UPC; +}(_Barcode3.default); + +// Calulate the checksum digit +// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Calculation_of_checksum_digit + + +function checksum(number) { + var result = 0; + + var i; + for (i = 1; i < 11; i += 2) { + result += parseInt(number[i]); + } + for (i = 0; i < 11; i += 2) { + result += parseInt(number[i]) * 3; + } + + return (10 - result % 10) % 10; +} + +exports.default = UPC; + +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _encoder = __webpack_require__(16); + +var _encoder2 = _interopRequireDefault(_encoder); + +var _Barcode2 = __webpack_require__(3); + +var _Barcode3 = _interopRequireDefault(_Barcode2); + +var _UPC = __webpack_require__(20); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation: +// https://en.wikipedia.org/wiki/Universal_Product_Code#Encoding +// +// UPC-E documentation: +// https://en.wikipedia.org/wiki/Universal_Product_Code#UPC-E + +var EXPANSIONS = ["XX00000XXX", "XX10000XXX", "XX20000XXX", "XXX00000XX", "XXXX00000X", "XXXXX00005", "XXXXX00006", "XXXXX00007", "XXXXX00008", "XXXXX00009"]; + +var PARITIES = [["EEEOOO", "OOOEEE"], ["EEOEOO", "OOEOEE"], ["EEOOEO", "OOEEOE"], ["EEOOOE", "OOEEEO"], ["EOEEOO", "OEOOEE"], ["EOOEEO", "OEEOOE"], ["EOOOEE", "OEEEOO"], ["EOEOEO", "OEOEOE"], ["EOEOOE", "OEOEEO"], ["EOOEOE", "OEEOEO"]]; + +var UPCE = function (_Barcode) { + _inherits(UPCE, _Barcode); + + function UPCE(data, options) { + _classCallCheck(this, UPCE); + + var _this = _possibleConstructorReturn(this, (UPCE.__proto__ || Object.getPrototypeOf(UPCE)).call(this, data, options)); + // Code may be 6 or 8 digits; + // A 7 digit code is ambiguous as to whether the extra digit + // is a UPC-A check or number system digit. + + + _this.isValid = false; + if (data.search(/^[0-9]{6}$/) !== -1) { + _this.middleDigits = data; + _this.upcA = expandToUPCA(data, "0"); + _this.text = options.text || '' + _this.upcA[0] + data + _this.upcA[_this.upcA.length - 1]; + _this.isValid = true; + } else if (data.search(/^[01][0-9]{7}$/) !== -1) { + _this.middleDigits = data.substring(1, data.length - 1); + _this.upcA = expandToUPCA(_this.middleDigits, data[0]); + + if (_this.upcA[_this.upcA.length - 1] === data[data.length - 1]) { + _this.isValid = true; + } else { + // checksum mismatch + return _possibleConstructorReturn(_this); + } + } else { + return _possibleConstructorReturn(_this); + } + + _this.displayValue = options.displayValue; + + // Make sure the font is not bigger than the space between the guard bars + if (options.fontSize > options.width * 10) { + _this.fontSize = options.width * 10; + } else { + _this.fontSize = options.fontSize; + } + + // Make the guard bars go down half the way of the text + _this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin; + return _this; + } + + _createClass(UPCE, [{ + key: 'valid', + value: function valid() { + return this.isValid; + } + }, { + key: 'encode', + value: function encode() { + if (this.options.flat) { + return this.flatEncoding(); + } else { + return this.guardedEncoding(); + } + } + }, { + key: 'flatEncoding', + value: function flatEncoding() { + var result = ""; + + result += "101"; + result += this.encodeMiddleDigits(); + result += "010101"; + + return { + data: result, + text: this.text + }; + } + }, { + key: 'guardedEncoding', + value: function guardedEncoding() { + var result = []; + + // Add the UPC-A number system digit beneath the quiet zone + if (this.displayValue) { + result.push({ + data: "00000000", + text: this.text[0], + options: { textAlign: "left", fontSize: this.fontSize } + }); + } + + // Add the guard bars + result.push({ + data: "101", + options: { height: this.guardHeight } + }); + + // Add the 6 UPC-E digits + result.push({ + data: this.encodeMiddleDigits(), + text: this.text.substring(1, 7), + options: { fontSize: this.fontSize } + }); + + // Add the end bits + result.push({ + data: "010101", + options: { height: this.guardHeight } + }); + + // Add the UPC-A check digit beneath the quiet zone + if (this.displayValue) { + result.push({ + data: "00000000", + text: this.text[7], + options: { textAlign: "right", fontSize: this.fontSize } + }); + } + + return result; + } + }, { + key: 'encodeMiddleDigits', + value: function encodeMiddleDigits() { + var numberSystem = this.upcA[0]; + var checkDigit = this.upcA[this.upcA.length - 1]; + var parity = PARITIES[parseInt(checkDigit)][parseInt(numberSystem)]; + return (0, _encoder2.default)(this.middleDigits, parity); + } + }]); + + return UPCE; +}(_Barcode3.default); + +function expandToUPCA(middleDigits, numberSystem) { + var lastUpcE = parseInt(middleDigits[middleDigits.length - 1]); + var expansion = EXPANSIONS[lastUpcE]; + + var result = ""; + var digitIndex = 0; + for (var i = 0; i < expansion.length; i++) { + var c = expansion[i]; + if (c === 'X') { + result += middleDigits[digitIndex++]; + } else { + result += c; + } + } + + result = '' + numberSystem + result; + return '' + result + (0, _UPC.checksum)(result); +} + +exports.default = UPCE; + +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.ITF14 = exports.ITF = undefined; + +var _ITF = __webpack_require__(23); + +var _ITF2 = _interopRequireDefault(_ITF); + +var _ITF3 = __webpack_require__(25); + +var _ITF4 = _interopRequireDefault(_ITF3); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.ITF = _ITF2.default; +exports.ITF14 = _ITF4.default; + +/***/ }), +/* 23 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _constants = __webpack_require__(24); + +var _Barcode2 = __webpack_require__(3); + +var _Barcode3 = _interopRequireDefault(_Barcode2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var ITF = function (_Barcode) { + _inherits(ITF, _Barcode); + + function ITF() { + _classCallCheck(this, ITF); + + return _possibleConstructorReturn(this, (ITF.__proto__ || Object.getPrototypeOf(ITF)).apply(this, arguments)); + } + + _createClass(ITF, [{ + key: 'valid', + value: function valid() { + return this.data.search(/^([0-9]{2})+$/) !== -1; + } + }, { + key: 'encode', + value: function encode() { + var _this2 = this; + + // Calculate all the digit pairs + var encoded = this.data.match(/.{2}/g).map(function (pair) { + return _this2.encodePair(pair); + }).join(''); + + return { + data: _constants.START_BIN + encoded + _constants.END_BIN, + text: this.text + }; + } + + // Calculate the data of a number pair + + }, { + key: 'encodePair', + value: function encodePair(pair) { + var second = _constants.BINARIES[pair[1]]; + + return _constants.BINARIES[pair[0]].split('').map(function (first, idx) { + return (first === '1' ? '111' : '1') + (second[idx] === '1' ? '000' : '0'); + }).join(''); + } + }]); + + return ITF; +}(_Barcode3.default); + +exports.default = ITF; + +/***/ }), +/* 24 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +var START_BIN = exports.START_BIN = '1010'; +var END_BIN = exports.END_BIN = '11101'; + +var BINARIES = exports.BINARIES = ['00110', '10001', '01001', '11000', '00101', '10100', '01100', '00011', '10010', '01010']; + +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _ITF2 = __webpack_require__(23); + +var _ITF3 = _interopRequireDefault(_ITF2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +// Calculate the checksum digit +var checksum = function checksum(data) { + var res = data.substr(0, 13).split('').map(function (num) { + return parseInt(num, 10); + }).reduce(function (sum, n, idx) { + return sum + n * (3 - idx % 2 * 2); + }, 0); + + return Math.ceil(res / 10) * 10 - res; +}; + +var ITF14 = function (_ITF) { + _inherits(ITF14, _ITF); + + function ITF14(data, options) { + _classCallCheck(this, ITF14); + + // Add checksum if it does not exist + if (data.search(/^[0-9]{13}$/) !== -1) { + data += checksum(data); + } + return _possibleConstructorReturn(this, (ITF14.__proto__ || Object.getPrototypeOf(ITF14)).call(this, data, options)); + } + + _createClass(ITF14, [{ + key: 'valid', + value: function valid() { + return this.data.search(/^[0-9]{14}$/) !== -1 && +this.data[13] === checksum(this.data); + } + }]); + + return ITF14; +}(_ITF3.default); + +exports.default = ITF14; + +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.MSI1110 = exports.MSI1010 = exports.MSI11 = exports.MSI10 = exports.MSI = undefined; + +var _MSI = __webpack_require__(27); + +var _MSI2 = _interopRequireDefault(_MSI); + +var _MSI3 = __webpack_require__(28); + +var _MSI4 = _interopRequireDefault(_MSI3); + +var _MSI5 = __webpack_require__(30); + +var _MSI6 = _interopRequireDefault(_MSI5); + +var _MSI7 = __webpack_require__(31); + +var _MSI8 = _interopRequireDefault(_MSI7); + +var _MSI9 = __webpack_require__(32); + +var _MSI10 = _interopRequireDefault(_MSI9); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.MSI = _MSI2.default; +exports.MSI10 = _MSI4.default; +exports.MSI11 = _MSI6.default; +exports.MSI1010 = _MSI8.default; +exports.MSI1110 = _MSI10.default; + +/***/ }), +/* 27 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _Barcode2 = __webpack_require__(3); + +var _Barcode3 = _interopRequireDefault(_Barcode2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation +// https://en.wikipedia.org/wiki/MSI_Barcode#Character_set_and_binary_lookup + +var MSI = function (_Barcode) { + _inherits(MSI, _Barcode); + + function MSI(data, options) { + _classCallCheck(this, MSI); + + return _possibleConstructorReturn(this, (MSI.__proto__ || Object.getPrototypeOf(MSI)).call(this, data, options)); + } + + _createClass(MSI, [{ + key: "encode", + value: function encode() { + // Start bits + var ret = "110"; + + for (var i = 0; i < this.data.length; i++) { + // Convert the character to binary (always 4 binary digits) + var digit = parseInt(this.data[i]); + var bin = digit.toString(2); + bin = addZeroes(bin, 4 - bin.length); + + // Add 100 for every zero and 110 for every 1 + for (var b = 0; b < bin.length; b++) { + ret += bin[b] == "0" ? "100" : "110"; + } + } + + // End bits + ret += "1001"; + + return { + data: ret, + text: this.text + }; + } + }, { + key: "valid", + value: function valid() { + return this.data.search(/^[0-9]+$/) !== -1; + } + }]); + + return MSI; +}(_Barcode3.default); + +function addZeroes(number, n) { + for (var i = 0; i < n; i++) { + number = "0" + number; + } + return number; +} + +exports.default = MSI; + +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _MSI2 = __webpack_require__(27); + +var _MSI3 = _interopRequireDefault(_MSI2); + +var _checksums = __webpack_require__(29); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var MSI10 = function (_MSI) { + _inherits(MSI10, _MSI); + + function MSI10(data, options) { + _classCallCheck(this, MSI10); + + return _possibleConstructorReturn(this, (MSI10.__proto__ || Object.getPrototypeOf(MSI10)).call(this, data + (0, _checksums.mod10)(data), options)); + } + + return MSI10; +}(_MSI3.default); + +exports.default = MSI10; + +/***/ }), +/* 29 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.mod10 = mod10; +exports.mod11 = mod11; +function mod10(number) { + var sum = 0; + for (var i = 0; i < number.length; i++) { + var n = parseInt(number[i]); + if ((i + number.length) % 2 === 0) { + sum += n; + } else { + sum += n * 2 % 10 + Math.floor(n * 2 / 10); + } + } + return (10 - sum % 10) % 10; +} + +function mod11(number) { + var sum = 0; + var weights = [2, 3, 4, 5, 6, 7]; + for (var i = 0; i < number.length; i++) { + var n = parseInt(number[number.length - 1 - i]); + sum += weights[i % weights.length] * n; + } + return (11 - sum % 11) % 11; +} + +/***/ }), +/* 30 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _MSI2 = __webpack_require__(27); + +var _MSI3 = _interopRequireDefault(_MSI2); + +var _checksums = __webpack_require__(29); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var MSI11 = function (_MSI) { + _inherits(MSI11, _MSI); + + function MSI11(data, options) { + _classCallCheck(this, MSI11); + + return _possibleConstructorReturn(this, (MSI11.__proto__ || Object.getPrototypeOf(MSI11)).call(this, data + (0, _checksums.mod11)(data), options)); + } + + return MSI11; +}(_MSI3.default); + +exports.default = MSI11; + +/***/ }), +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _MSI2 = __webpack_require__(27); + +var _MSI3 = _interopRequireDefault(_MSI2); + +var _checksums = __webpack_require__(29); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var MSI1010 = function (_MSI) { + _inherits(MSI1010, _MSI); + + function MSI1010(data, options) { + _classCallCheck(this, MSI1010); + + data += (0, _checksums.mod10)(data); + data += (0, _checksums.mod10)(data); + return _possibleConstructorReturn(this, (MSI1010.__proto__ || Object.getPrototypeOf(MSI1010)).call(this, data, options)); + } + + return MSI1010; +}(_MSI3.default); + +exports.default = MSI1010; + +/***/ }), +/* 32 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _MSI2 = __webpack_require__(27); + +var _MSI3 = _interopRequireDefault(_MSI2); + +var _checksums = __webpack_require__(29); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var MSI1110 = function (_MSI) { + _inherits(MSI1110, _MSI); + + function MSI1110(data, options) { + _classCallCheck(this, MSI1110); + + data += (0, _checksums.mod11)(data); + data += (0, _checksums.mod10)(data); + return _possibleConstructorReturn(this, (MSI1110.__proto__ || Object.getPrototypeOf(MSI1110)).call(this, data, options)); + } + + return MSI1110; +}(_MSI3.default); + +exports.default = MSI1110; + +/***/ }), +/* 33 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.pharmacode = undefined; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _Barcode2 = __webpack_require__(3); + +var _Barcode3 = _interopRequireDefault(_Barcode2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation +// http://www.gomaro.ch/ftproot/Laetus_PHARMA-CODE.pdf + +var pharmacode = function (_Barcode) { + _inherits(pharmacode, _Barcode); + + function pharmacode(data, options) { + _classCallCheck(this, pharmacode); + + var _this = _possibleConstructorReturn(this, (pharmacode.__proto__ || Object.getPrototypeOf(pharmacode)).call(this, data, options)); + + _this.number = parseInt(data, 10); + return _this; + } + + _createClass(pharmacode, [{ + key: "encode", + value: function encode() { + var z = this.number; + var result = ""; + + // http://i.imgur.com/RMm4UDJ.png + // (source: http://www.gomaro.ch/ftproot/Laetus_PHARMA-CODE.pdf, page: 34) + while (!isNaN(z) && z != 0) { + if (z % 2 === 0) { + // Even + result = "11100" + result; + z = (z - 2) / 2; + } else { + // Odd + result = "100" + result; + z = (z - 1) / 2; + } + } + + // Remove the two last zeroes + result = result.slice(0, -2); + + return { + data: result, + text: this.text + }; + } + }, { + key: "valid", + value: function valid() { + return this.number >= 3 && this.number <= 131070; + } + }]); + + return pharmacode; +}(_Barcode3.default); + +exports.pharmacode = pharmacode; + +/***/ }), +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.codabar = undefined; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _Barcode2 = __webpack_require__(3); + +var _Barcode3 = _interopRequireDefault(_Barcode2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding specification: +// http://www.barcodeisland.com/codabar.phtml + +var codabar = function (_Barcode) { + _inherits(codabar, _Barcode); + + function codabar(data, options) { + _classCallCheck(this, codabar); + + if (data.search(/^[0-9\-\$\:\.\+\/]+$/) === 0) { + data = "A" + data + "A"; + } + + var _this = _possibleConstructorReturn(this, (codabar.__proto__ || Object.getPrototypeOf(codabar)).call(this, data.toUpperCase(), options)); + + _this.text = _this.options.text || _this.text.replace(/[A-D]/g, ''); + return _this; + } + + _createClass(codabar, [{ + key: "valid", + value: function valid() { + return this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/) !== -1; + } + }, { + key: "encode", + value: function encode() { + var result = []; + var encodings = this.getEncodings(); + for (var i = 0; i < this.data.length; i++) { + result.push(encodings[this.data.charAt(i)]); + // for all characters except the last, append a narrow-space ("0") + if (i !== this.data.length - 1) { + result.push("0"); + } + } + return { + text: this.text, + data: result.join('') + }; + } + }, { + key: "getEncodings", + value: function getEncodings() { + return { + "0": "101010011", + "1": "101011001", + "2": "101001011", + "3": "110010101", + "4": "101101001", + "5": "110101001", + "6": "100101011", + "7": "100101101", + "8": "100110101", + "9": "110100101", + "-": "101001101", + "$": "101100101", + ":": "1101011011", + "/": "1101101011", + ".": "1101101101", + "+": "1011011011", + "A": "1011001001", + "B": "1001001011", + "C": "1010010011", + "D": "1010011001" + }; + } + }]); + + return codabar; +}(_Barcode3.default); + +exports.codabar = codabar; + +/***/ }), +/* 35 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.GenericBarcode = undefined; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _Barcode2 = __webpack_require__(3); + +var _Barcode3 = _interopRequireDefault(_Barcode2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var GenericBarcode = function (_Barcode) { + _inherits(GenericBarcode, _Barcode); + + function GenericBarcode(data, options) { + _classCallCheck(this, GenericBarcode); + + return _possibleConstructorReturn(this, (GenericBarcode.__proto__ || Object.getPrototypeOf(GenericBarcode)).call(this, data, options)); // Sets this.data and this.text + } + + // Return the corresponding binary numbers for the data provided + + + _createClass(GenericBarcode, [{ + key: "encode", + value: function encode() { + return { + data: "10101010101010101010101010101010101010101", + text: this.text + }; + } + + // Resturn true/false if the string provided is valid for this encoder + + }, { + key: "valid", + value: function valid() { + return true; + } + }]); + + return GenericBarcode; +}(_Barcode3.default); + +exports.GenericBarcode = GenericBarcode; + +/***/ }), +/* 36 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +exports.default = function (old, replaceObj) { + return _extends({}, old, replaceObj); +}; + +/***/ }), +/* 37 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = linearizeEncodings; + +// Encodings can be nestled like [[1-1, 1-2], 2, [3-1, 3-2] +// Convert to [1-1, 1-2, 2, 3-1, 3-2] + +function linearizeEncodings(encodings) { + var linearEncodings = []; + function nextLevel(encoded) { + if (Array.isArray(encoded)) { + for (var i = 0; i < encoded.length; i++) { + nextLevel(encoded[i]); + } + } else { + encoded.text = encoded.text || ""; + encoded.data = encoded.data || ""; + linearEncodings.push(encoded); + } + } + nextLevel(encodings); + + return linearEncodings; +} + +/***/ }), +/* 38 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = fixOptions; + + +function fixOptions(options) { + // Fix the margins + options.marginTop = options.marginTop || options.margin; + options.marginBottom = options.marginBottom || options.margin; + options.marginRight = options.marginRight || options.margin; + options.marginLeft = options.marginLeft || options.margin; + + return options; +} + +/***/ }), +/* 39 */ +/***/ (function(module, exports, __webpack_require__) { + +"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; }; /* global HTMLImageElement */ +/* global HTMLCanvasElement */ +/* global SVGElement */ + +var _getOptionsFromElement = __webpack_require__(40); + +var _getOptionsFromElement2 = _interopRequireDefault(_getOptionsFromElement); + +var _renderers = __webpack_require__(43); + +var _renderers2 = _interopRequireDefault(_renderers); + +var _exceptions = __webpack_require__(48); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Takes an element and returns an object with information about how +// it should be rendered +// This could also return an array with these objects +// { +// element: The element that the renderer should draw on +// renderer: The name of the renderer +// afterRender (optional): If something has to done after the renderer +// completed, calls afterRender (function) +// options (optional): Options that can be defined in the element +// } + +function getRenderProperties(element) { + // If the element is a string, query select call again + if (typeof element === "string") { + return querySelectedRenderProperties(element); + } + // If element is array. Recursivly call with every object in the array + else if (Array.isArray(element)) { + var returnArray = []; + for (var i = 0; i < element.length; i++) { + returnArray.push(getRenderProperties(element[i])); + } + return returnArray; + } + // If element, render on canvas and set the uri as src + else if (typeof HTMLCanvasElement !== 'undefined' && element.nodeName.toLowerCase() =='img') { + return newCanvasRenderProperties(element); + } + // If SVG + else if (element && element.nodeName && element.nodeName.toLowerCase() === 'svg' || typeof SVGElement !== 'undefined' && element instanceof SVGElement) { + return { + element: element, + options: (0, _getOptionsFromElement2.default)(element), + renderer: _renderers2.default.SVGRenderer + }; + } + // If canvas (in browser) + else if (typeof HTMLCanvasElement !== 'undefined' && element instanceof HTMLCanvasElement) { + return { + element: element, + options: (0, _getOptionsFromElement2.default)(element), + renderer: _renderers2.default.CanvasRenderer + }; + } + // If canvas (in node) + else if (element && element.getContext) { + return { + element: element, + renderer: _renderers2.default.CanvasRenderer + }; + } else if (element && (typeof element === "undefined" ? "undefined" : _typeof(element)) === 'object' && !element.nodeName) { + return { + element: element, + renderer: _renderers2.default.ObjectRenderer + }; + } else { + throw new _exceptions.InvalidElementException(); + } +} + +function querySelectedRenderProperties(string) { + var selector = document.querySelectorAll(string); + if (selector.length === 0) { + return undefined; + } else { + var returnArray = []; + for (var i = 0; i < selector.length; i++) { + returnArray.push(getRenderProperties(selector[i])); + } + return returnArray; + } +} + +function newCanvasRenderProperties(imgElement) { + var canvas = document.createElement('canvas'); + return { + element: canvas, + options: (0, _getOptionsFromElement2.default)(imgElement), + renderer: _renderers2.default.CanvasRenderer, + afterRender: function afterRender() { + imgElement.setAttribute("src", canvas.toDataURL()); + } + }; +} + +exports.default = getRenderProperties; + +/***/ }), +/* 40 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _optionsFromStrings = __webpack_require__(41); + +var _optionsFromStrings2 = _interopRequireDefault(_optionsFromStrings); + +var _defaults = __webpack_require__(42); + +var _defaults2 = _interopRequireDefault(_defaults); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function getOptionsFromElement(element) { + var options = {}; + for (var property in _defaults2.default) { + if (_defaults2.default.hasOwnProperty(property)) { + // jsbarcode-* + if (element.hasAttribute("jsbarcode-" + property.toLowerCase())) { + options[property] = element.getAttribute("jsbarcode-" + property.toLowerCase()); + } + + // data-* + if (element.hasAttribute("data-" + property.toLowerCase())) { + options[property] = element.getAttribute("data-" + property.toLowerCase()); + } + } + } + + options["value"] = element.getAttribute("jsbarcode-value") || element.getAttribute("data-value"); + + // Since all atributes are string they need to be converted to integers + options = (0, _optionsFromStrings2.default)(options); + + return options; +} + +exports.default = getOptionsFromElement; + +/***/ }), +/* 41 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = optionsFromStrings; + +// Convert string to integers/booleans where it should be + +function optionsFromStrings(options) { + var intOptions = ["width", "height", "textMargin", "fontSize", "margin", "marginTop", "marginBottom", "marginLeft", "marginRight"]; + + for (var intOption in intOptions) { + if (intOptions.hasOwnProperty(intOption)) { + intOption = intOptions[intOption]; + if (typeof options[intOption] === "string") { + options[intOption] = parseInt(options[intOption], 10); + } + } + } + + if (typeof options["displayValue"] === "string") { + options["displayValue"] = options["displayValue"] != "false"; + } + + return options; +} + +/***/ }), +/* 42 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +var defaults = { + width: 2, + height: 100, + format: "auto", + displayValue: true, + fontOptions: "", + font: "monospace", + text: undefined, + textAlign: "center", + textPosition: "bottom", + textMargin: 2, + fontSize: 20, + background: "#ffffff", + lineColor: "#000000", + margin: 10, + marginTop: undefined, + marginBottom: undefined, + marginLeft: undefined, + marginRight: undefined, + valid: function valid() {} +}; + +exports.default = defaults; + +/***/ }), +/* 43 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _canvas = __webpack_require__(44); + +var _canvas2 = _interopRequireDefault(_canvas); + +var _svg = __webpack_require__(46); + +var _svg2 = _interopRequireDefault(_svg); + +var _object = __webpack_require__(47); + +var _object2 = _interopRequireDefault(_object); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = { CanvasRenderer: _canvas2.default, SVGRenderer: _svg2.default, ObjectRenderer: _object2.default }; + +/***/ }), +/* 44 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _merge = __webpack_require__(36); + +var _merge2 = _interopRequireDefault(_merge); + +var _shared = __webpack_require__(45); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var CanvasRenderer = function () { + function CanvasRenderer(canvas, encodings, options) { + _classCallCheck(this, CanvasRenderer); + + this.canvas = canvas; + this.encodings = encodings; + this.options = options; + } + + _createClass(CanvasRenderer, [{ + key: "render", + value: function render() { + // Abort if the browser does not support HTML5 canvas + if (!this.canvas.getContext) { + throw new Error('The browser does not support canvas.'); + } + + this.prepareCanvas(); + for (var i = 0; i < this.encodings.length; i++) { + var encodingOptions = (0, _merge2.default)(this.options, this.encodings[i].options); + + this.drawCanvasBarcode(encodingOptions, this.encodings[i]); + this.drawCanvasText(encodingOptions, this.encodings[i]); + + this.moveCanvasDrawing(this.encodings[i]); + } + + this.restoreCanvas(); + } + }, { + key: "prepareCanvas", + value: function prepareCanvas() { + // Get the canvas context + var ctx = this.canvas.getContext("2d"); + + ctx.save(); + + (0, _shared.calculateEncodingAttributes)(this.encodings, this.options, ctx); + var totalWidth = (0, _shared.getTotalWidthOfEncodings)(this.encodings); + var maxHeight = (0, _shared.getMaximumHeightOfEncodings)(this.encodings); + + this.canvas.width = totalWidth + this.options.marginLeft + this.options.marginRight; + + this.canvas.height = maxHeight; + + // Paint the canvas + ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); + if (this.options.background) { + ctx.fillStyle = this.options.background; + ctx.fillRect(0, 0, this.canvas.width, this.canvas.height); + } + + ctx.translate(this.options.marginLeft, 0); + } + }, { + key: "drawCanvasBarcode", + value: function drawCanvasBarcode(options, encoding) { + // Get the canvas context + var ctx = this.canvas.getContext("2d"); + + var binary = encoding.data; + + // Creates the barcode out of the encoded binary + var yFrom; + if (options.textPosition == "top") { + yFrom = options.marginTop + options.fontSize + options.textMargin; + } else { + yFrom = options.marginTop; + } + + ctx.fillStyle = options.lineColor; + + for (var b = 0; b < binary.length; b++) { + var x = b * options.width + encoding.barcodePadding; + + if (binary[b] === "1") { + ctx.fillRect(x, yFrom, options.width, options.height); + } else if (binary[b]) { + ctx.fillRect(x, yFrom, options.width, options.height * binary[b]); + } + } + } + }, { + key: "drawCanvasText", + value: function drawCanvasText(options, encoding) { + // Get the canvas context + var ctx = this.canvas.getContext("2d"); + + var font = options.fontOptions + " " + options.fontSize + "px " + options.font; + + // Draw the text if displayValue is set + if (options.displayValue) { + var x, y; + + if (options.textPosition == "top") { + y = options.marginTop + options.fontSize - options.textMargin; + } else { + y = options.height + options.textMargin + options.marginTop + options.fontSize; + } + + ctx.font = font; + + // Draw the text in the correct X depending on the textAlign option + if (options.textAlign == "left" || encoding.barcodePadding > 0) { + x = 0; + ctx.textAlign = 'left'; + } else if (options.textAlign == "right") { + x = encoding.width - 1; + ctx.textAlign = 'right'; + } + // In all other cases, center the text + else { + x = encoding.width / 2; + ctx.textAlign = 'center'; + } + + ctx.fillText(encoding.text, x, y); + } + } + }, { + key: "moveCanvasDrawing", + value: function moveCanvasDrawing(encoding) { + var ctx = this.canvas.getContext("2d"); + + ctx.translate(encoding.width, 0); + } + }, { + key: "restoreCanvas", + value: function restoreCanvas() { + // Get the canvas context + var ctx = this.canvas.getContext("2d"); + + ctx.restore(); + } + }]); + + return CanvasRenderer; +}(); + +exports.default = CanvasRenderer; + +/***/ }), +/* 45 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getTotalWidthOfEncodings = exports.calculateEncodingAttributes = exports.getBarcodePadding = exports.getEncodingHeight = exports.getMaximumHeightOfEncodings = undefined; + +var _merge = __webpack_require__(36); + +var _merge2 = _interopRequireDefault(_merge); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function getEncodingHeight(encoding, options) { + return options.height + (options.displayValue && encoding.text.length > 0 ? options.fontSize + options.textMargin : 0) + options.marginTop + options.marginBottom; +} + +function getBarcodePadding(textWidth, barcodeWidth, options) { + if (options.displayValue && barcodeWidth < textWidth) { + if (options.textAlign == "center") { + return Math.floor((textWidth - barcodeWidth) / 2); + } else if (options.textAlign == "left") { + return 0; + } else if (options.textAlign == "right") { + return Math.floor(textWidth - barcodeWidth); + } + } + return 0; +} + +function calculateEncodingAttributes(encodings, barcodeOptions, context) { + for (var i = 0; i < encodings.length; i++) { + var encoding = encodings[i]; + var options = (0, _merge2.default)(barcodeOptions, encoding.options); + + // Calculate the width of the encoding + var textWidth; + if (options.displayValue) { + textWidth = messureText(encoding.text, options, context); + } else { + textWidth = 0; + } + + var barcodeWidth = encoding.data.length * options.width; + encoding.width = Math.ceil(Math.max(textWidth, barcodeWidth)); + + encoding.height = getEncodingHeight(encoding, options); + + encoding.barcodePadding = getBarcodePadding(textWidth, barcodeWidth, options); + } +} + +function getTotalWidthOfEncodings(encodings) { + var totalWidth = 0; + for (var i = 0; i < encodings.length; i++) { + totalWidth += encodings[i].width; + } + return totalWidth; +} + +function getMaximumHeightOfEncodings(encodings) { + var maxHeight = 0; + for (var i = 0; i < encodings.length; i++) { + if (encodings[i].height > maxHeight) { + maxHeight = encodings[i].height; + } + } + return maxHeight; +} + +function messureText(string, options, context) { + var ctx; + + if (context) { + ctx = context; + } else if (typeof document !== "undefined") { + ctx = document.createElement("canvas").getContext("2d"); + } else { + // If the text cannot be messured we will return 0. + // This will make some barcode with big text render incorrectly + return 0; + } + ctx.font = options.fontOptions + " " + options.fontSize + "px " + options.font; + + // Calculate the width of the encoding + var measureTextResult = ctx.measureText(string); + if (!measureTextResult) { + // Some implementations don't implement measureText and return undefined. + // If the text cannot be measured we will return 0. + // This will make some barcode with big text render incorrectly + return 0; + } + var size = measureTextResult.width; + return size; +} + +exports.getMaximumHeightOfEncodings = getMaximumHeightOfEncodings; +exports.getEncodingHeight = getEncodingHeight; +exports.getBarcodePadding = getBarcodePadding; +exports.calculateEncodingAttributes = calculateEncodingAttributes; +exports.getTotalWidthOfEncodings = getTotalWidthOfEncodings; + +/***/ }), +/* 46 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _merge = __webpack_require__(36); + +var _merge2 = _interopRequireDefault(_merge); + +var _shared = __webpack_require__(45); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var svgns = "http://www.w3.org/2000/svg"; + +var SVGRenderer = function () { + function SVGRenderer(svg, encodings, options) { + _classCallCheck(this, SVGRenderer); + + this.svg = svg; + this.encodings = encodings; + this.options = options; + this.document = options.xmlDocument || document; + } + + _createClass(SVGRenderer, [{ + key: "render", + value: function render() { + var currentX = this.options.marginLeft; + + this.prepareSVG(); + for (var i = 0; i < this.encodings.length; i++) { + var encoding = this.encodings[i]; + var encodingOptions = (0, _merge2.default)(this.options, encoding.options); + + var group = this.createGroup(currentX, encodingOptions.marginTop, this.svg); + + this.setGroupOptions(group, encodingOptions); + + this.drawSvgBarcode(group, encodingOptions, encoding); + this.drawSVGText(group, encodingOptions, encoding); + + currentX += encoding.width; + } + } + }, { + key: "prepareSVG", + value: function prepareSVG() { + // Clear the SVG + while (this.svg.firstChild) { + this.svg.removeChild(this.svg.firstChild); + } + + (0, _shared.calculateEncodingAttributes)(this.encodings, this.options); + var totalWidth = (0, _shared.getTotalWidthOfEncodings)(this.encodings); + var maxHeight = (0, _shared.getMaximumHeightOfEncodings)(this.encodings); + + var width = totalWidth + this.options.marginLeft + this.options.marginRight; + this.setSvgAttributes(width, maxHeight); + + if (this.options.background) { + this.drawRect(0, 0, width, maxHeight, this.svg).setAttribute("style", "fill:" + this.options.background + ";"); + } + } + }, { + key: "drawSvgBarcode", + value: function drawSvgBarcode(parent, options, encoding) { + var binary = encoding.data; + + // Creates the barcode out of the encoded binary + var yFrom; + if (options.textPosition == "top") { + yFrom = options.fontSize + options.textMargin; + } else { + yFrom = 0; + } + + var barWidth = 0; + var x = 0; + for (var b = 0; b < binary.length; b++) { + x = b * options.width + encoding.barcodePadding; + + if (binary[b] === "1") { + barWidth++; + } else if (barWidth > 0) { + this.drawRect(x - options.width * barWidth, yFrom, options.width * barWidth, options.height, parent); + barWidth = 0; + } + } + + // Last draw is needed since the barcode ends with 1 + if (barWidth > 0) { + this.drawRect(x - options.width * (barWidth - 1), yFrom, options.width * barWidth, options.height, parent); + } + } + }, { + key: "drawSVGText", + value: function drawSVGText(parent, options, encoding) { + var textElem = this.document.createElementNS(svgns, 'text'); + + // Draw the text if displayValue is set + if (options.displayValue) { + var x, y; + + textElem.setAttribute("style", "font:" + options.fontOptions + " " + options.fontSize + "px " + options.font); + + if (options.textPosition == "top") { + y = options.fontSize - options.textMargin; + } else { + y = options.height + options.textMargin + options.fontSize; + } + + // Draw the text in the correct X depending on the textAlign option + if (options.textAlign == "left" || encoding.barcodePadding > 0) { + x = 0; + textElem.setAttribute("text-anchor", "start"); + } else if (options.textAlign == "right") { + x = encoding.width - 1; + textElem.setAttribute("text-anchor", "end"); + } + // In all other cases, center the text + else { + x = encoding.width / 2; + textElem.setAttribute("text-anchor", "middle"); + } + + textElem.setAttribute("x", x); + textElem.setAttribute("y", y); + + textElem.appendChild(this.document.createTextNode(encoding.text)); + + parent.appendChild(textElem); + } + } + }, { + key: "setSvgAttributes", + value: function setSvgAttributes(width, height) { + var svg = this.svg; + svg.setAttribute("width", width + "px"); + svg.setAttribute("height", height + "px"); + svg.setAttribute("x", "0px"); + svg.setAttribute("y", "0px"); + svg.setAttribute("viewBox", "0 0 " + width + " " + height); + + svg.setAttribute("xmlns", svgns); + svg.setAttribute("version", "1.1"); + + svg.setAttribute("style", "transform: translate(0,0)"); + } + }, { + key: "createGroup", + value: function createGroup(x, y, parent) { + var group = this.document.createElementNS(svgns, 'g'); + group.setAttribute("transform", "translate(" + x + ", " + y + ")"); + + parent.appendChild(group); + + return group; + } + }, { + key: "setGroupOptions", + value: function setGroupOptions(group, options) { + group.setAttribute("style", "fill:" + options.lineColor + ";"); + } + }, { + key: "drawRect", + value: function drawRect(x, y, width, height, parent) { + var rect = this.document.createElementNS(svgns, 'rect'); + + rect.setAttribute("x", x); + rect.setAttribute("y", y); + rect.setAttribute("width", width); + rect.setAttribute("height", height); + + parent.appendChild(rect); + + return rect; + } + }]); + + return SVGRenderer; +}(); + +exports.default = SVGRenderer; + +/***/ }), +/* 47 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var ObjectRenderer = function () { + function ObjectRenderer(object, encodings, options) { + _classCallCheck(this, ObjectRenderer); + + this.object = object; + this.encodings = encodings; + this.options = options; + } + + _createClass(ObjectRenderer, [{ + key: "render", + value: function render() { + this.object.encodings = this.encodings; + } + }]); + + return ObjectRenderer; +}(); + +exports.default = ObjectRenderer; + +/***/ }), +/* 48 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var InvalidInputException = function (_Error) { + _inherits(InvalidInputException, _Error); + + function InvalidInputException(symbology, input) { + _classCallCheck(this, InvalidInputException); + + var _this = _possibleConstructorReturn(this, (InvalidInputException.__proto__ || Object.getPrototypeOf(InvalidInputException)).call(this)); + + _this.name = "InvalidInputException"; + + _this.symbology = symbology; + _this.input = input; + + _this.message = '"' + _this.input + '" is not a valid input for ' + _this.symbology; + return _this; + } + + return InvalidInputException; +}(Error); + +var InvalidElementException = function (_Error2) { + _inherits(InvalidElementException, _Error2); + + function InvalidElementException() { + _classCallCheck(this, InvalidElementException); + + var _this2 = _possibleConstructorReturn(this, (InvalidElementException.__proto__ || Object.getPrototypeOf(InvalidElementException)).call(this)); + + _this2.name = "InvalidElementException"; + _this2.message = "Not supported type to render on"; + return _this2; + } + + return InvalidElementException; +}(Error); + +var NoElementException = function (_Error3) { + _inherits(NoElementException, _Error3); + + function NoElementException() { + _classCallCheck(this, NoElementException); + + var _this3 = _possibleConstructorReturn(this, (NoElementException.__proto__ || Object.getPrototypeOf(NoElementException)).call(this)); + + _this3.name = "NoElementException"; + _this3.message = "No element to render on."; + return _this3; + } + + return NoElementException; +}(Error); + +exports.InvalidInputException = InvalidInputException; +exports.InvalidElementException = InvalidElementException; +exports.NoElementException = NoElementException; + +/***/ }), +/* 49 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/*eslint no-console: 0 */ + +var ErrorHandler = function () { + function ErrorHandler(api) { + _classCallCheck(this, ErrorHandler); + + this.api = api; + } + + _createClass(ErrorHandler, [{ + key: "handleCatch", + value: function handleCatch(e) { + // If babel supported extending of Error in a correct way instanceof would be used here + if (e.name === "InvalidInputException") { + if (this.api._options.valid !== this.api._defaults.valid) { + this.api._options.valid(false); + } else { + throw e.message; + } + } else { + throw e; + } + + this.api.render = function () {}; + } + }, { + key: "wrapBarcodeCall", + value: function wrapBarcodeCall(func) { + try { + var result = func.apply(undefined, arguments); + this.api._options.valid(true); + return result; + } catch (e) { + this.handleCatch(e); + + return this.api; + } + } + }]); + + return ErrorHandler; +}(); + +exports.default = ErrorHandler; + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/front/public/vender/codemirror.js b/front/public/vender/codemirror.js new file mode 100644 index 0000000..c485eed --- /dev/null +++ b/front/public/vender/codemirror.js @@ -0,0 +1 @@ +(function(){'use strict';!function(e){("object"!=typeof exports||"undefined"==typeof module)&&"function"==typeof define&&define.amd?define(e):e();}(function(){function e(n){var t=this.constructor;return this.then(function(e){return t.resolve(n()).then(function(){return e;});},function(e){return t.resolve(n()).then(function(){return t.reject(e);});});}var n=setTimeout;function a(e){return e&&"undefined"!=typeof e.length;}function o(){}function i(e){if(!(this instanceof i))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=undefined,this._deferreds=[],s(e,this);}function r(o,r){for(;3===o._state;)o=o._value;0!==o._state?(o._handled=!0,i._immediateFn(function(){var e=1===o._state?r.onFulfilled:r.onRejected;if(null!==e){var n;try{n=e(o._value);}catch(t){return void u(r.promise,t);}f(r.promise,n);}else(1===o._state?f:u)(r.promise,o._value);})):o._deferreds.push(r);}function f(e,n){try{if(n===e)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var t=n.then;if(n instanceof i)return e._state=3,e._value=n,void c(e);if("function"==typeof t)return void s(function o(e,n){return function(){e.apply(n,arguments);};}(t,n),e);}e._state=1,e._value=n,c(e);}catch(r){u(e,r);}}function u(e,n){e._state=2,e._value=n,c(e);}function c(e){2===e._state&&0===e._deferreds.length&&i._immediateFn(function(){e._handled||i._unhandledRejectionFn(e._value);});for(var n=0,t=e._deferreds.length;nthis.length)throw new RangeError(`Invalid position ${pos} in document of length ${this.length}`);return this.lineInner(pos,false,1,0);}line(n){if(n<1||n>this.lines)throw new RangeError(`Invalid line number ${n} in ${this.lines}-line document`);return this.lineInner(n,true,1,0);}replace(from,to,text){let parts=[];this.decompose(0,from,parts,2);if(text.length)text.decompose(0,text.length,parts,1|2);this.decompose(to,this.length,parts,1);return TextNode.from(parts,this.length-(to-from)+text.length);}append(other){return this.replace(this.length,this.length,other);}slice(from,to=this.length){let parts=[];this.decompose(from,to,parts,0);return TextNode.from(parts,to-from);}eq(other){if(other==this)return true;if(other.length!=this.length||other.lines!=this.lines)return false;let start=this.scanIdentical(other,1),end=this.length-this.scanIdentical(other,-1);let a=new RawTextCursor(this),b=new RawTextCursor(other);for(let skip=start,pos=start;;){a.next(skip);b.next(skip);skip=0;if(a.lineBreak!=b.lineBreak||a.done!=b.done||a.value!=b.value)return false;pos+=a.value.length;if(a.done||pos>=end)return true;}}iter(dir=1){return new RawTextCursor(this,dir);}iterRange(from,to=this.length){return new PartialTextCursor(this,from,to);}iterLines(from,to){let inner;if(from==null){inner=this.iter();}else{if(to==null)to=this.lines+1;let start=this.line(from).from;inner=this.iterRange(start,Math.max(start,to==this.lines+1?this.length:to<=1?0:this.line(to-1).to));}return new LineCursor(inner);}toString(){return this.sliceString(0);}toJSON(){let lines=[];this.flatten(lines);return lines;}constructor(){}static of(text){if(text.length==0)throw new RangeError("A document must have at least one line");if(text.length==1&&!text[0])return Text$1.empty;return text.length<=32?new TextLeaf(text):TextNode.from(TextLeaf.split(text,[]));}}class TextLeaf extends Text$1{constructor(text,length=textLength(text)){super();this.text=text;this.length=length;}get lines(){return this.text.length;}get children(){return null;}lineInner(target,isLine,line,offset){for(let i=0;;i++){let string=this.text[i],end=offset+string.length;if((isLine?line:end)>=target)return new Line$1(offset,end,line,string);offset=end+1;line++;}}decompose(from,to,target,open){let text=from<=0&&to>=this.length?this:new TextLeaf(sliceText(this.text,from,to),Math.min(to,this.length)-Math.max(0,from));if(open&1){let prev=target.pop();let joined=appendText(text.text,prev.text.slice(),0,text.length);if(joined.length<=32){target.push(new TextLeaf(joined,prev.length+text.length));}else{let mid=joined.length>>1;target.push(new TextLeaf(joined.slice(0,mid)),new TextLeaf(joined.slice(mid)));}}else{target.push(text);}}replace(from,to,text){if(!(text instanceof TextLeaf))return super.replace(from,to,text);let lines=appendText(this.text,appendText(text.text,sliceText(this.text,0,from)),to);let newLen=this.length+text.length-(to-from);if(lines.length<=32)return new TextLeaf(lines,newLen);return TextNode.from(TextLeaf.split(lines,[]),newLen);}sliceString(from,to=this.length,lineSep="\n"){let result="";for(let pos=0,i=0;pos<=to&&ifrom&&i)result+=lineSep;if(frompos)result+=line.slice(Math.max(0,from-pos),to-pos);pos=end+1;}return result;}flatten(target){for(let _i=0,_this$text=this.text,_length=_this$text.length;_i<_length;_i++){let line=_this$text[_i];target.push(line);}}scanIdentical(){return 0;}static split(text,target){let part=[],len=-1;for(let _i2=0,_length2=text.length;_i2<_length2;_i2++){let line=text[_i2];part.push(line);len+=line.length+1;if(part.length==32){target.push(new TextLeaf(part,len));part=[];len=-1;}}if(len>-1)target.push(new TextLeaf(part,len));return target;}}class TextNode extends Text$1{constructor(children,length){super();this.children=children;this.length=length;this.lines=0;for(let _i3=0,_length3=children.length;_i3<_length3;_i3++){let child=children[_i3];this.lines+=child.lines;}}lineInner(target,isLine,line,offset){for(let i=0;;i++){let child=this.children[i],end=offset+child.length,endLine=line+child.lines-1;if((isLine?endLine:end)>=target)return child.lineInner(target,isLine,line,offset);offset=end+1;line=endLine+1;}}decompose(from,to,target,open){for(let i=0,pos=0;pos<=to&&i=pos){let childOpen=open&((pos<=from?1:0)|(end>=to?2:0));if(pos>=from&&end<=to&&!childOpen)target.push(child);else child.decompose(from-pos,to-pos,target,childOpen);}pos=end+1;}}replace(from,to,text){if(text.lines=pos&&to<=end){let updated=child.replace(from-pos,to-pos,text);let totalLines=this.lines-child.lines+updated.lines;if(updated.lines>5-1&&updated.lines>totalLines>>5+1){let copy=this.children.slice();copy[i]=updated;return new TextNode(copy,this.length-(to-from)+text.length);}return super.replace(pos,end,updated);}pos=end+1;}return super.replace(from,to,text);}sliceString(from,to=this.length,lineSep="\n"){let result="";for(let i=0,pos=0;ifrom&&i)result+=lineSep;if(frompos)result+=child.sliceString(from-pos,to-pos,lineSep);pos=end+1;}return result;}flatten(target){for(let _i4=0,_this$children=this.children,_length4=_this$children.length;_i4<_length4;_i4++){let child=_this$children[_i4];child.flatten(target);}}scanIdentical(other,dir){if(!(other instanceof TextNode))return 0;let length=0;let[iA,iB,eA,eB]=dir>0?[0,0,this.children.length,other.children.length]:[this.children.length-1,other.children.length-1,-1,-1];for(;;iA+=dir,iB+=dir){if(iA==eA||iB==eB)return length;let chA=this.children[iA],chB=other.children[iB];if(chA!=chB)return length+chA.scanIdentical(chB,dir);length+=chA.length+1;}}static from(children,length=children.reduce((l,ch)=>l+ch.length+1,-1)){let lines=0;for(let _i5=0,_length5=children.length;_i5<_length5;_i5++){let ch=children[_i5];lines+=ch.lines;}if(lines<32){let flat=[];for(let _i6=0,_length6=children.length;_i6<_length6;_i6++){let ch=children[_i6];ch.flatten(flat);}return new TextLeaf(flat,length);}let chunk=Math.max(32,lines>>5),maxChunk=chunk<<1,minChunk=chunk>>1;let chunked=[],currentLines=0,currentLen=-1,currentChunk=[];function add(child){let last;if(child.lines>maxChunk&&child instanceof TextNode){for(let _i7=0,_child$children=child.children,_length7=_child$children.length;_i7<_length7;_i7++){let node=_child$children[_i7];add(node);}}else if(child.lines>minChunk&&(currentLines>minChunk||!currentLines)){flush();chunked.push(child);}else if(child instanceof TextLeaf&¤tLines&&(last=currentChunk[currentChunk.length-1])instanceof TextLeaf&&child.lines+last.lines<=32){currentLines+=child.lines;currentLen+=child.length+1;currentChunk[currentChunk.length-1]=new TextLeaf(last.text.concat(child.text),last.length+1+child.length);}else{if(currentLines+child.lines>chunk)flush();currentLines+=child.lines;currentLen+=child.length+1;currentChunk.push(child);}}function flush(){if(currentLines==0)return;chunked.push(currentChunk.length==1?currentChunk[0]:TextNode.from(currentChunk,currentLen));currentLen=-1;currentLines=currentChunk.length=0;}for(let _i8=0,_length8=children.length;_i8<_length8;_i8++){let child=children[_i8];add(child);}flush();return chunked.length==1?chunked[0]:new TextNode(chunked,length);}}Text$1.empty=new TextLeaf([""],0);function textLength(text){let length=-1;for(let _i9=0,_length9=text.length;_i9<_length9;_i9++){let line=text[_i9];length+=line.length+1;}return length;}function appendText(text,target,from=0,to=1e9){for(let pos=0,i=0,first=true;i=from){if(end>to)line=line.slice(0,to-pos);if(pos0?1:(text instanceof TextLeaf?text.text.length:text.children.length)<<1];}nextInner(skip,dir){this.done=this.lineBreak=false;for(;;){let last=this.nodes.length-1;let top=this.nodes[last],offsetValue=this.offsets[last],offset=offsetValue>>1;let size=top instanceof TextLeaf?top.text.length:top.children.length;if(offset==(dir>0?size:0)){if(last==0){this.done=true;this.value="";return this;}if(dir>0)this.offsets[last-1]++;this.nodes.pop();this.offsets.pop();}else if((offsetValue&1)==(dir>0?0:1)){this.offsets[last]+=dir;if(skip==0){this.lineBreak=true;this.value="\n";return this;}skip--;}else if(top instanceof TextLeaf){let next=top.text[offset+(dir<0?-1:0)];this.offsets[last]+=dir;if(next.length>Math.max(0,skip)){this.value=skip==0?next:dir>0?next.slice(skip):next.slice(0,next.length-skip);return this;}skip-=next.length;}else{let next=top.children[offset+(dir<0?-1:0)];if(skip>next.length){skip-=next.length;this.offsets[last]+=dir;}else{if(dir<0)this.offsets[last]--;this.nodes.push(next);this.offsets.push(dir>0?1:(next instanceof TextLeaf?next.text.length:next.children.length)<<1);}}}}next(skip=0){if(skip<0){this.nextInner(-skip,-this.dir);skip=this.value.length;}return this.nextInner(skip,this.dir);}}class PartialTextCursor{constructor(text,start,end){this.value="";this.done=false;this.cursor=new RawTextCursor(text,start>end?-1:1);this.pos=start>end?text.length:0;this.from=Math.min(start,end);this.to=Math.max(start,end);}nextInner(skip,dir){if(dir<0?this.pos<=this.from:this.pos>=this.to){this.value="";this.done=true;return this;}skip+=Math.max(0,dir<0?this.pos-this.to:this.from-this.pos);let limit=dir<0?this.pos-this.from:this.to-this.pos;if(skip>limit)skip=limit;limit-=skip;let{value}=this.cursor.next(skip);this.pos+=(value.length+skip)*dir;this.value=value.length<=limit?value:dir<0?value.slice(value.length-limit):value.slice(0,limit);this.done=!this.value;return this;}next(skip=0){if(skip<0)skip=Math.max(skip,this.from-this.pos);else if(skip>0)skip=Math.min(skip,this.to-this.pos);return this.nextInner(skip,this.cursor.dir);}get lineBreak(){return this.cursor.lineBreak&&this.value!="";}}class LineCursor{constructor(inner){this.inner=inner;this.afterBreak=true;this.value="";this.done=false;}next(skip=0){let{done,lineBreak,value}=this.inner.next(skip);if(done){this.done=true;this.value="";}else if(lineBreak){if(this.afterBreak){this.value="";}else{this.afterBreak=true;this.next();}}else{this.value=value;this.afterBreak=false;}return this;}get lineBreak(){return false;}}if(typeof Symbol!="undefined"){Text$1.prototype[Symbol.iterator]=function(){return this.iter();};RawTextCursor.prototype[Symbol.iterator]=PartialTextCursor.prototype[Symbol.iterator]=LineCursor.prototype[Symbol.iterator]=function(){return this;};}class Line$1{constructor(from,to,number,text){this.from=from;this.to=to;this.number=number;this.text=text;}get length(){return this.to-this.from;}}let extend="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g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,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(s=>s?parseInt(s,36):1);for(let i=1;icode)return extend[i-1]<=code;return false;}function isRegionalIndicator(code){return code>=0x1F1E6&&code<=0x1F1FF;}const ZWJ=0x200d;function findClusterBreak(str,pos,forward=true,includeExtending=true){return(forward?nextClusterBreak:prevClusterBreak)(str,pos,includeExtending);}function nextClusterBreak(str,pos,includeExtending){if(pos==str.length)return pos;if(pos&&surrogateLow(str.charCodeAt(pos))&&surrogateHigh(str.charCodeAt(pos-1)))pos--;let prev=codePointAt(str,pos);pos+=codePointSize(prev);while(pos=0&&isRegionalIndicator(codePointAt(str,i))){countBefore++;i-=2;}if(countBefore%2==0)break;else pos+=2;}else{break;}}return pos;}function prevClusterBreak(str,pos,includeExtending){while(pos>0){let found=nextClusterBreak(str,pos-2,includeExtending);if(found=0xDC00&&ch<0xE000;}function surrogateHigh(ch){return ch>=0xD800&&ch<0xDC00;}function codePointAt(str,pos){let code0=str.charCodeAt(pos);if(!surrogateHigh(code0)||pos+1==str.length)return code0;let code1=str.charCodeAt(pos+1);if(!surrogateLow(code1))return code0;return(code0-0xd800<<10)+(code1-0xdc00)+0x10000;}function fromCodePoint(code){if(code<=0xffff)return String.fromCharCode(code);code-=0x10000;return String.fromCharCode((code>>10)+0xd800,(code&1023)+0xdc00);}function codePointSize(code){return code<0x10000?1:2;}const DefaultSplit=/\r\n?|\n/;var MapMode=function(MapMode){MapMode[MapMode["Simple"]=0]="Simple";MapMode[MapMode["TrackDel"]=1]="TrackDel";MapMode[MapMode["TrackBefore"]=2]="TrackBefore";MapMode[MapMode["TrackAfter"]=3]="TrackAfter";return MapMode;}(MapMode||(MapMode={}));class ChangeDesc{constructor(sections){this.sections=sections;}get length(){let result=0;for(let i=0;ipos)return posB+(pos-posA);posB+=len;}else{if(mode!=MapMode.Simple&&endA>=pos&&(mode==MapMode.TrackDel&&posApos||mode==MapMode.TrackBefore&&posApos))return null;if(endA>pos||endA==pos&&assoc<0&&!len)return pos==posA||assoc<0?posB:posB+ins;posB+=ins;}posA=endA;}if(pos>posA)throw new RangeError(`Position ${pos} is out of range for changeset of length ${posA}`);return posB;}touchesRange(from,to=from){for(let i=0,pos=0;i=0&&pos<=to&&end>=from)return posto?"cover":true;pos=end;}return false;}toString(){let result="";for(let i=0;i=0?":"+ins:"");}return result;}toJSON(){return this.sections;}static fromJSON(json){if(!Array.isArray(json)||json.length%2||json.some(a=>typeof a!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new ChangeDesc(json);}static create(sections){return new ChangeDesc(sections);}}class ChangeSet extends ChangeDesc{constructor(sections,inserted){super(sections);this.inserted=inserted;}apply(doc){if(this.length!=doc.length)throw new RangeError("Applying change set to a document with the wrong length");iterChanges(this,(fromA,toA,fromB,_toB,text)=>doc=doc.replace(fromB,fromB+(toA-fromA),text),false);return doc;}mapDesc(other,before=false){return mapSet(this,other,before,true);}invert(doc){let sections=this.sections.slice(),inserted=[];for(let i=0,pos=0;i=0){sections[i]=ins;sections[i+1]=len;let index=i>>1;while(inserted.length0)addInsert(resultInserted,resultSections,iter.text);iter.forward(len);pos+=len;}let end=ranges[i++];while(pos>1].toJSON()));}return parts;}static of(changes,length,lineSep){let sections=[],inserted=[],pos=0;let total=null;function flush(force=false){if(!force&&!sections.length)return;if(posto||from<0||to>length)throw new RangeError(`Invalid change range ${from} to ${to} (in doc of length ${length})`);let insText=!insert?Text$1.empty:typeof insert=="string"?Text$1.of(insert.split(lineSep||DefaultSplit)):insert;let insLen=insText.length;if(from==to&&insLen==0)return;if(frompos)addSection(sections,from-pos,-1);addSection(sections,to-from,insLen);addInsert(inserted,sections,insText);pos=to;}}process(changes);flush(!total);return total;}static empty(length){return new ChangeSet(length?[length,-1]:[],[]);}static fromJSON(json){if(!Array.isArray(json))throw new RangeError("Invalid JSON representation of ChangeSet");let sections=[],inserted=[];for(let i=0;ii&&typeof e!="string")){throw new RangeError("Invalid JSON representation of ChangeSet");}else if(part.length==1){sections.push(part[0],0);}else{while(inserted.length=0&&ins<=0&&ins==sections[last+1])sections[last]+=len;else if(len==0&§ions[last]==0)sections[last+1]+=ins;else if(forceJoin){sections[last]+=len;sections[last+1]+=ins;}else sections.push(len,ins);}function addInsert(values,sections,value){if(value.length==0)return;let index=sections.length-2>>1;if(index>1]);if(individual||i==desc.sections.length||desc.sections[i+1]<0)break;len=desc.sections[i++];ins=desc.sections[i++];}f(posA,endA,posB,endB,text);posA=endA;posB=endB;}}}function mapSet(setA,setB,before,mkSet=false){let sections=[],insert=mkSet?[]:null;let a=new SectionIter(setA),b=new SectionIter(setB);for(let inserted=-1;;){if(a.ins==-1&&b.ins==-1){let len=Math.min(a.len,b.len);addSection(sections,len,-1);a.forward(len);b.forward(len);}else if(b.ins>=0&&(a.ins<0||inserted==a.i||a.off==0&&(b.len=0&&inserted=0){let len=0,left=a.len;while(left){if(b.ins==-1){let piece=Math.min(left,b.len);len+=piece;left-=piece;b.forward(piece);}else if(b.ins==0&&b.lenlen||b.ins>=0&&b.len>len)&&(open||sections.length>sectionLen);a.forward2(len);b.forward(len);}}}class SectionIter{constructor(set){this.set=set;this.i=0;this.next();}next(){let{sections}=this.set;if(this.i>1;return index>=inserted.length?Text$1.empty:inserted[index];}textBit(len){let{inserted}=this.set,index=this.i-2>>1;return index>=inserted.length&&!len?Text$1.empty:inserted[index].slice(this.off,len==null?undefined:this.off+len);}forward(len){if(len==this.len)this.next();else{this.len-=len;this.off+=len;}}forward2(len){if(this.ins==-1)this.forward(len);else if(len==this.ins)this.next();else{this.ins-=len;this.off+=len;}}}class SelectionRange{constructor(from,to,flags){this.from=from;this.to=to;this.flags=flags;}get anchor(){return this.flags&16?this.to:this.from;}get head(){return this.flags&16?this.from:this.to;}get empty(){return this.from==this.to;}get assoc(){return this.flags&4?-1:this.flags&8?1:0;}get bidiLevel(){let level=this.flags&3;return level==3?null:level;}get goalColumn(){let value=this.flags>>5;return value==33554431?undefined:value;}map(change,assoc=-1){let from,to;if(this.empty){from=to=change.mapPos(this.from,assoc);}else{from=change.mapPos(this.from,1);to=change.mapPos(this.to,-1);}return from==this.from&&to==this.to?this:new SelectionRange(from,to,this.flags);}extend(from,to=from){if(from<=this.anchor&&to>=this.anchor)return EditorSelection.range(from,to);let head=Math.abs(from-this.anchor)>Math.abs(to-this.anchor)?from:to;return EditorSelection.range(this.anchor,head);}eq(other){return this.anchor==other.anchor&&this.head==other.head;}toJSON(){return{anchor:this.anchor,head:this.head};}static fromJSON(json){if(!json||typeof json.anchor!="number"||typeof json.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return EditorSelection.range(json.anchor,json.head);}static create(from,to,flags){return new SelectionRange(from,to,flags);}}class EditorSelection{constructor(ranges,mainIndex){this.ranges=ranges;this.mainIndex=mainIndex;}map(change,assoc=-1){if(change.empty)return this;return EditorSelection.create(this.ranges.map(r=>r.map(change,assoc)),this.mainIndex);}eq(other){if(this.ranges.length!=other.ranges.length||this.mainIndex!=other.mainIndex)return false;for(let i=0;ir.toJSON()),main:this.mainIndex};}static fromJSON(json){if(!json||!Array.isArray(json.ranges)||typeof json.main!="number"||json.main>=json.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new EditorSelection(json.ranges.map(r=>SelectionRange.fromJSON(r)),json.main);}static single(anchor,head=anchor){return new EditorSelection([EditorSelection.range(anchor,head)],0);}static create(ranges,mainIndex=0){if(ranges.length==0)throw new RangeError("A selection needs at least one range");for(let pos=0,i=0;ianchor?4:0)|flags);}static normalized(ranges,mainIndex=0){let main=ranges[mainIndex];ranges.sort((a,b)=>a.from-b.from);mainIndex=ranges.indexOf(main);for(let i=1;irange.head?EditorSelection.range(to,from):EditorSelection.range(from,to));}}return new EditorSelection(ranges,mainIndex);}}function checkSelection(selection,docLength){for(let _i11=0,_selection$ranges=selection.ranges,_length11=_selection$ranges.length;_i11<_length11;_i11++){let range=_selection$ranges[_i11];if(range.to>docLength)throw new RangeError("Selection points outside of document");}}let nextID=0;class Facet{constructor(combine,compareInput,compare,isStatic,enables){this.combine=combine;this.compareInput=compareInput;this.compare=compare;this.isStatic=isStatic;this.id=nextID++;this.default=combine([]);this.extensions=typeof enables=="function"?enables(this):enables;}static define(config={}){return new Facet(config.combine||(a=>a),config.compareInput||((a,b)=>a===b),config.compare||(!config.combine?sameArray$1:(a,b)=>a===b),!!config.static,config.enables);}of(value){return new FacetProvider([],this,0,value);}compute(deps,get){if(this.isStatic)throw new Error("Can't compute a static facet");return new FacetProvider(deps,this,1,get);}computeN(deps,get){if(this.isStatic)throw new Error("Can't compute a static facet");return new FacetProvider(deps,this,2,get);}from(field,get){if(!get)get=x=>x;return this.compute([field],state=>get(state.field(field)));}}function sameArray$1(a,b){return a==b||a.length==b.length&&a.every((e,i)=>e===b[i]);}class FacetProvider{constructor(dependencies,facet,type,value){this.dependencies=dependencies;this.facet=facet;this.type=type;this.value=value;this.id=nextID++;}dynamicSlot(addresses){var _a;let getter=this.value;let compare=this.facet.compareInput;let id=this.id,idx=addresses[id]>>1,multi=this.type==2;let depDoc=false,depSel=false,depAddrs=[];for(let _i12=0,_this$dependencies=this.dependencies,_length12=_this$dependencies.length;_i12<_length12;_i12++){let dep=_this$dependencies[_i12];if(dep=="doc")depDoc=true;else if(dep=="selection")depSel=true;else if((((_a=addresses[dep.id])!==null&&_a!==void 0?_a:1)&1)==0)depAddrs.push(addresses[dep.id]);}return{create(state){state.values[idx]=getter(state);return 1;},update(state,tr){if(depDoc&&tr.docChanged||depSel&&(tr.docChanged||tr.selection)||ensureAll(state,depAddrs)){let newVal=getter(state);if(multi?!compareArray(newVal,state.values[idx],compare):!compare(newVal,state.values[idx])){state.values[idx]=newVal;return 1;}}return 0;},reconfigure:(state,oldState)=>{let newVal,oldAddr=oldState.config.address[id];if(oldAddr!=null){let oldVal=getAddr(oldState,oldAddr);if(this.dependencies.every(dep=>{return dep instanceof Facet?oldState.facet(dep)===state.facet(dep):dep instanceof StateField?oldState.field(dep,false)==state.field(dep,false):true;})||(multi?compareArray(newVal=getter(state),oldVal,compare):compare(newVal=getter(state),oldVal))){state.values[idx]=oldVal;return 0;}}else{newVal=getter(state);}state.values[idx]=newVal;return 1;}};}}function compareArray(a,b,compare){if(a.length!=b.length)return false;for(let i=0;iaddresses[p.id]);let providerTypes=providers.map(p=>p.type);let dynamic=providerAddrs.filter(p=>!(p&1));let idx=addresses[facet.id]>>1;function get(state){let values=[];for(let i=0;ia===b),config);if(config.provide)field.provides=config.provide(field);return field;}create(state){let init=state.facet(initField).find(i=>i.field==this);return((init===null||init===void 0?void 0:init.create)||this.createF)(state);}slot(addresses){let idx=addresses[this.id]>>1;return{create:state=>{state.values[idx]=this.create(state);return 1;},update:(state,tr)=>{let oldVal=state.values[idx];let value=this.updateF(oldVal,tr);if(this.compareF(oldVal,value))return 0;state.values[idx]=value;return 1;},reconfigure:(state,oldState)=>{if(oldState.config.address[this.id]!=null){state.values[idx]=oldState.field(this);return 0;}state.values[idx]=this.create(state);return 1;}};}init(create){return[this,initField.of({field:this,create})];}get extension(){return this;}}const Prec_={lowest:4,low:3,default:2,high:1,highest:0};function prec(value){return ext=>new PrecExtension(ext,value);}const Prec={highest:prec(Prec_.highest),high:prec(Prec_.high),default:prec(Prec_.default),low:prec(Prec_.low),lowest:prec(Prec_.lowest)};class PrecExtension{constructor(inner,prec){this.inner=inner;this.prec=prec;}}class Compartment{of(ext){return new CompartmentInstance(this,ext);}reconfigure(content){return Compartment.reconfigure.of({compartment:this,extension:content});}get(state){return state.config.compartments.get(this);}}class CompartmentInstance{constructor(compartment,inner){this.compartment=compartment;this.inner=inner;}}class Configuration{constructor(base,compartments,dynamicSlots,address,staticValues,facets){this.base=base;this.compartments=compartments;this.dynamicSlots=dynamicSlots;this.address=address;this.staticValues=staticValues;this.facets=facets;this.statusTemplate=[];while(this.statusTemplate.length>1];}static resolve(base,compartments,oldState){let fields=[];let facets=Object.create(null);let newCompartments=new Map();for(let _i16=0,_flatten=flatten(base,compartments,newCompartments),_length16=_flatten.length;_i16<_length16;_i16++){let ext=_flatten[_i16];if(ext instanceof StateField)fields.push(ext);else(facets[ext.facet.id]||(facets[ext.facet.id]=[])).push(ext);}let address=Object.create(null);let staticValues=[];let dynamicSlots=[];for(let _i17=0,_length17=fields.length;_i17<_length17;_i17++){let field=fields[_i17];address[field.id]=dynamicSlots.length<<1;dynamicSlots.push(a=>field.slot(a));}let oldFacets=oldState===null||oldState===void 0?void 0:oldState.config.facets;for(let id in facets){let providers=facets[id],facet=providers[0].facet;let oldProviders=oldFacets&&oldFacets[id]||[];if(providers.every(p=>p.type==0)){address[facet.id]=staticValues.length<<1|1;if(sameArray$1(oldProviders,providers)){staticValues.push(oldState.facet(facet));}else{let value=facet.combine(providers.map(p=>p.value));staticValues.push(oldState&&facet.compare(value,oldState.facet(facet))?oldState.facet(facet):value);}}else{for(let _i18=0,_length18=providers.length;_i18<_length18;_i18++){let p=providers[_i18];if(p.type==0){address[p.id]=staticValues.length<<1|1;staticValues.push(p.value);}else{address[p.id]=dynamicSlots.length<<1;dynamicSlots.push(a=>p.dynamicSlot(a));}}address[facet.id]=dynamicSlots.length<<1;dynamicSlots.push(a=>dynamicFacetSlot(a,facet,providers));}}let dynamic=dynamicSlots.map(f=>f(address));return new Configuration(base,newCompartments,dynamic,address,staticValues,facets);}}function flatten(extension,compartments,newCompartments){let result=[[],[],[],[],[]];let seen=new Map();function inner(ext,prec){let known=seen.get(ext);if(known!=null){if(known<=prec)return;let found=result[known].indexOf(ext);if(found>-1)result[known].splice(found,1);if(ext instanceof CompartmentInstance)newCompartments.delete(ext.compartment);}seen.set(ext,prec);if(Array.isArray(ext)){for(let _i19=0,_length19=ext.length;_i19<_length19;_i19++){let e=ext[_i19];inner(e,prec);}}else if(ext instanceof CompartmentInstance){if(newCompartments.has(ext.compartment))throw new RangeError(`Duplicate use of compartment in extensions`);let content=compartments.get(ext.compartment)||ext.inner;newCompartments.set(ext.compartment,content);inner(content,prec);}else if(ext instanceof PrecExtension){inner(ext.inner,ext.prec);}else if(ext instanceof StateField){result[prec].push(ext);if(ext.provides)inner(ext.provides,prec);}else if(ext instanceof FacetProvider){result[prec].push(ext);if(ext.facet.extensions)inner(ext.facet.extensions,Prec_.default);}else{let content=ext.extension;if(!content)throw new Error(`Unrecognized extension value in extension set (${ext}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);inner(content,prec);}}inner(extension,Prec_.default);return result.reduce((a,b)=>a.concat(b));}function ensureAddr(state,addr){if(addr&1)return 2;let idx=addr>>1;let status=state.status[idx];if(status==4)throw new Error("Cyclic dependency between fields and/or facets");if(status&2)return status;state.status[idx]=4;let changed=state.computeSlot(state,state.config.dynamicSlots[idx]);return state.status[idx]=2|changed;}function getAddr(state,addr){return addr&1?state.config.staticValues[addr>>1]:state.values[addr>>1];}const languageData=Facet.define();const allowMultipleSelections=Facet.define({combine:values=>values.some(v=>v),static:true});const lineSeparator=Facet.define({combine:values=>values.length?values[0]:undefined,static:true});const changeFilter=Facet.define();const transactionFilter=Facet.define();const transactionExtender=Facet.define();const readOnly=Facet.define({combine:values=>values.length?values[0]:false});class Annotation{constructor(type,value){this.type=type;this.value=value;}static define(){return new AnnotationType();}}class AnnotationType{of(value){return new Annotation(this,value);}}class StateEffectType{constructor(map){this.map=map;}of(value){return new StateEffect(this,value);}}class StateEffect{constructor(type,value){this.type=type;this.value=value;}map(mapping){let mapped=this.type.map(this.value,mapping);return mapped===undefined?undefined:mapped==this.value?this:new StateEffect(this.type,mapped);}is(type){return this.type==type;}static define(spec={}){return new StateEffectType(spec.map||(v=>v));}static mapEffects(effects,mapping){if(!effects.length)return effects;let result=[];for(let _i20=0,_length20=effects.length;_i20<_length20;_i20++){let effect=effects[_i20];let mapped=effect.map(mapping);if(mapped)result.push(mapped);}return result;}}StateEffect.reconfigure=StateEffect.define();StateEffect.appendConfig=StateEffect.define();class Transaction{constructor(startState,changes,selection,effects,annotations,scrollIntoView){this.startState=startState;this.changes=changes;this.selection=selection;this.effects=effects;this.annotations=annotations;this.scrollIntoView=scrollIntoView;this._doc=null;this._state=null;if(selection)checkSelection(selection,changes.newLength);if(!annotations.some(a=>a.type==Transaction.time))this.annotations=annotations.concat(Transaction.time.of(Date.now()));}static create(startState,changes,selection,effects,annotations,scrollIntoView){return new Transaction(startState,changes,selection,effects,annotations,scrollIntoView);}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc));}get newSelection(){return this.selection||this.startState.selection.map(this.changes);}get state(){if(!this._state)this.startState.applyTransaction(this);return this._state;}annotation(type){for(let _i21=0,_this$annotations=this.annotations,_length21=_this$annotations.length;_i21<_length21;_i21++){let ann=_this$annotations[_i21];if(ann.type==type)return ann.value;}return undefined;}get docChanged(){return!this.changes.empty;}get reconfigured(){return this.startState.config!=this.state.config;}isUserEvent(event){let e=this.annotation(Transaction.userEvent);return!!(e&&(e==event||e.length>event.length&&e.slice(0,event.length)==event&&e[event.length]=="."));}}Transaction.time=Annotation.define();Transaction.userEvent=Annotation.define();Transaction.addToHistory=Annotation.define();Transaction.remote=Annotation.define();function joinRanges(a,b){let result=[];for(let iA=0,iB=0;;){let from,to;if(iA=a[iA])){from=a[iA++];to=a[iA++];}else if(iB=0;i--){let filtered=filters[i](tr);if(filtered instanceof Transaction)tr=filtered;else if(Array.isArray(filtered)&&filtered.length==1&&filtered[0]instanceof Transaction)tr=filtered[0];else tr=resolveTransaction(state,asArray$1(filtered),false);}return tr;}function extendTransaction(tr){let state=tr.startState,extenders=state.facet(transactionExtender),spec=tr;for(let i=extenders.length-1;i>=0;i--){let extension=extenders[i](tr);if(extension&&Object.keys(extension).length)spec=mergeTransaction(spec,resolveTransactionInner(state,extension,tr.changes.newLength),true);}return spec==tr?tr:Transaction.create(state,tr.changes,tr.selection,spec.effects,spec.annotations,spec.scrollIntoView);}const none$3=[];function asArray$1(value){return value==null?none$3:Array.isArray(value)?value:[value];}var CharCategory=function(CharCategory){CharCategory[CharCategory["Word"]=0]="Word";CharCategory[CharCategory["Space"]=1]="Space";CharCategory[CharCategory["Other"]=2]="Other";return CharCategory;}(CharCategory||(CharCategory={}));const nonASCIISingleCaseWordChar=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let wordChar$1;try{wordChar$1=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u");}catch(_){}function hasWordChar(str){if(wordChar$1)return wordChar$1.test(str);for(let i=0;i"\x80"&&(ch.toUpperCase()!=ch.toLowerCase()||nonASCIISingleCaseWordChar.test(ch)))return true;}return false;}function makeCategorizer(wordChars){return char=>{if(!/\S/.test(char))return CharCategory.Space;if(hasWordChar(char))return CharCategory.Word;for(let i=0;i-1)return CharCategory.Word;return CharCategory.Other;};}class EditorState{constructor(config,doc,selection,values,computeSlot,tr){this.config=config;this.doc=doc;this.selection=selection;this.values=values;this.status=config.statusTemplate.slice();this.computeSlot=computeSlot;if(tr)tr._state=this;for(let i=0;icompartments.set(key,val));conf=null;}compartments.set(effect.value.compartment,effect.value.extension);}else if(effect.is(StateEffect.reconfigure)){conf=null;base=effect.value;}else if(effect.is(StateEffect.appendConfig)){conf=null;base=asArray$1(base).concat(effect.value);}}let startValues;if(!conf){conf=Configuration.resolve(base,compartments,this);let intermediateState=new EditorState(conf,this.doc,this.selection,conf.dynamicSlots.map(()=>null),(state,slot)=>slot.reconfigure(state,this),null);startValues=intermediateState.values;}else{startValues=tr.startState.values.slice();}new EditorState(conf,tr.newDoc,tr.newSelection,startValues,(state,slot)=>slot.update(state,tr),tr);}replaceSelection(text){if(typeof text=="string")text=this.toText(text);return this.changeByRange(range=>({changes:{from:range.from,to:range.to,insert:text},range:EditorSelection.cursor(range.from+text.length)}));}changeByRange(f){let sel=this.selection;let result1=f(sel.ranges[0]);let changes=this.changes(result1.changes),ranges=[result1.range];let effects=asArray$1(result1.effects);for(let i=1;ifield.spec.fromJSON(value,state)));}}return EditorState.create({doc:json.doc,selection:EditorSelection.fromJSON(json.selection),extensions:config.extensions?fieldInit.concat([config.extensions]):fieldInit});}static create(config={}){let configuration=Configuration.resolve(config.extensions||[],new Map());let doc=config.doc instanceof Text$1?config.doc:Text$1.of((config.doc||"").split(configuration.staticFacet(EditorState.lineSeparator)||DefaultSplit));let selection=!config.selection?EditorSelection.single(0):config.selection instanceof EditorSelection?config.selection:EditorSelection.single(config.selection.anchor,config.selection.head);checkSelection(selection,doc.length);if(!configuration.staticFacet(allowMultipleSelections))selection=selection.asSingle();return new EditorState(configuration,doc,selection,configuration.dynamicSlots.map(()=>null),(state,slot)=>slot.create(state),null);}get tabSize(){return this.facet(EditorState.tabSize);}get lineBreak(){return this.facet(EditorState.lineSeparator)||"\n";}get readOnly(){return this.facet(readOnly);}phrase(phrase,...insert){for(let _i24=0,_this$facet=this.facet(EditorState.phrases),_length24=_this$facet.length;_i24<_length24;_i24++){let map=_this$facet[_i24];if(Object.prototype.hasOwnProperty.call(map,phrase)){phrase=map[phrase];break;}}if(insert.length)phrase=phrase.replace(/\$(\$|\d*)/g,(m,i)=>{if(i=="$")return"$";let n=+(i||1);return!n||n>insert.length?m:insert[n-1];});return phrase;}languageDataAt(name,pos,side=-1){let values=[];for(let _i25=0,_this$facet2=this.facet(languageData),_length25=_this$facet2.length;_i25<_length25;_i25++){let provider=_this$facet2[_i25];for(let _i26=0,_provider=provider(this,pos,side),_length26=_provider.length;_i26<_length26;_i26++){let result=_provider[_i26];if(Object.prototype.hasOwnProperty.call(result,name))values.push(result[name]);}}return values;}charCategorizer(at){return makeCategorizer(this.languageDataAt("wordChars",at).join(""));}wordAt(pos){let{text,from,length}=this.doc.lineAt(pos);let cat=this.charCategorizer(pos);let start=pos-from,end=pos-from;while(start>0){let prev=findClusterBreak(text,start,false);if(cat(text.slice(prev,start))!=CharCategory.Word)break;start=prev;}while(endvalues.length?values[0]:4});EditorState.lineSeparator=lineSeparator;EditorState.readOnly=readOnly;EditorState.phrases=Facet.define({compare(a,b){let kA=Object.keys(a),kB=Object.keys(b);return kA.length==kB.length&&kA.every(k=>a[k]==b[k]);}});EditorState.languageData=languageData;EditorState.changeFilter=changeFilter;EditorState.transactionFilter=transactionFilter;EditorState.transactionExtender=transactionExtender;Compartment.reconfigure=StateEffect.define();function combineConfig(configs,defaults,combine={}){let result={};for(let _i27=0,_length27=configs.length;_i27<_length27;_i27++){let config=configs[_i27];for(let _i28=0,_Object$keys=Object.keys(config),_length28=_Object$keys.length;_i28<_length28;_i28++){let key=_Object$keys[_i28];let value=config[key],current=result[key];if(current===undefined)result[key]=value;else if(current===value||value===undefined);else if(Object.hasOwnProperty.call(combine,key))result[key]=combine[key](current,value);else throw new Error("Config merge conflict for field "+key);}}for(let key in defaults)if(result[key]===undefined)result[key]=defaults[key];return result;}class RangeValue{eq(other){return this==other;}range(from,to=from){return Range$1.create(from,to,this);}}RangeValue.prototype.startSide=RangeValue.prototype.endSide=0;RangeValue.prototype.point=false;RangeValue.prototype.mapMode=MapMode.TrackDel;class Range$1{constructor(from,to,value){this.from=from;this.to=to;this.value=value;}static create(from,to,value){return new Range$1(from,to,value);}}function cmpRange(a,b){return a.from-b.from||a.value.startSide-b.value.startSide;}class Chunk$1{constructor(from,to,value,maxPoint){this.from=from;this.to=to;this.value=value;this.maxPoint=maxPoint;}get length(){return this.to[this.to.length-1];}findIndex(pos,side,end,startAt=0){let arr=end?this.to:this.from;for(let lo=startAt,hi=arr.length;;){if(lo==hi)return lo;let mid=lo+hi>>1;let diff=arr[mid]-pos||(end?this.value[mid].endSide:this.value[mid].startSide)-side;if(mid==lo)return diff>=0?lo:hi;if(diff>=0)hi=mid;else lo=mid+1;}}between(offset,from,to,f){for(let i=this.findIndex(from,-1000000000,true),e=this.findIndex(to,1000000000,false,i);inewTo||newFrom==newTo&&val.startSide>0&&val.endSide<=0)continue;}if((newTo-newFrom||val.endSide-val.startSide)<0)continue;if(newPos<0)newPos=newFrom;if(val.point)maxPoint=Math.max(maxPoint,newTo-newFrom);value.push(val);from.push(newFrom-newPos);to.push(newTo-newPos);}return{mapped:value.length?new Chunk$1(from,to,value,maxPoint):null,pos:newPos};}}class RangeSet{constructor(chunkPos,chunk,nextLayer,maxPoint){this.chunkPos=chunkPos;this.chunk=chunk;this.nextLayer=nextLayer;this.maxPoint=maxPoint;}static create(chunkPos,chunk,nextLayer,maxPoint){return new RangeSet(chunkPos,chunk,nextLayer,maxPoint);}get length(){let last=this.chunk.length-1;return last<0?0:Math.max(this.chunkEnd(last),this.nextLayer.length);}get size(){if(this.isEmpty)return 0;let size=this.nextLayer.size;for(let _i29=0,_this$chunk=this.chunk,_length29=_this$chunk.length;_i29<_length29;_i29++){let chunk=_this$chunk[_i29];size+=chunk.value.length;}return size;}chunkEnd(index){return this.chunkPos[index]+this.chunk[index].length;}update(updateSpec){let{add=[],sort=false,filterFrom=0,filterTo=this.length}=updateSpec;let filter=updateSpec.filter;if(add.length==0&&!filter)return this;if(sort)add=add.slice().sort(cmpRange);if(this.isEmpty)return add.length?RangeSet.of(add):this;let cur=new LayerCursor(this,null,-1).goto(0),i=0,spill=[];let builder=new RangeSetBuilder();while(cur.value||i=0){let range=add[i++];if(!builder.addInner(range.from,range.to,range.value))spill.push(range);}else if(cur.rangeIndex==1&&cur.chunkIndexthis.chunkEnd(cur.chunkIndex)||filterTocur.to||filterTo=start&&from<=start+chunk.length&&chunk.between(start,from-start,to-start,f)===false)return;}this.nextLayer.between(from,to,f);}iter(from=0){return HeapCursor.from([this]).goto(from);}get isEmpty(){return this.nextLayer==this;}static iter(sets,from=0){return HeapCursor.from(sets).goto(from);}static compare(oldSets,newSets,textDiff,comparator,minPointSize=-1){let a=oldSets.filter(set=>set.maxPoint>0||!set.isEmpty&&set.maxPoint>=minPointSize);let b=newSets.filter(set=>set.maxPoint>0||!set.isEmpty&&set.maxPoint>=minPointSize);let sharedChunks=findSharedChunks(a,b,textDiff);let sideA=new SpanCursor(a,sharedChunks,minPointSize);let sideB=new SpanCursor(b,sharedChunks,minPointSize);textDiff.iterGaps((fromA,fromB,length)=>compare(sideA,fromA,sideB,fromB,length,comparator));if(textDiff.empty&&textDiff.length==0)compare(sideA,0,sideB,0,0,comparator);}static eq(oldSets,newSets,from=0,to){if(to==null)to=1000000000-1;let a=oldSets.filter(set=>!set.isEmpty&&newSets.indexOf(set)<0);let b=newSets.filter(set=>!set.isEmpty&&oldSets.indexOf(set)<0);if(a.length!=b.length)return false;if(!a.length)return true;let sharedChunks=findSharedChunks(a,b);let sideA=new SpanCursor(a,sharedChunks,0).goto(from),sideB=new SpanCursor(b,sharedChunks,0).goto(from);for(;;){if(sideA.to!=sideB.to||!sameValues(sideA.active,sideB.active)||sideA.point&&(!sideB.point||!sideA.point.eq(sideB.point)))return false;if(sideA.to>to)return true;sideA.next();sideB.next();}}static spans(sets,from,to,iterator,minPointSize=-1){let cursor=new SpanCursor(sets,null,minPointSize).goto(from),pos=from;let openRanges=cursor.openStart;for(;;){let curTo=Math.min(cursor.to,to);if(cursor.point){let active=cursor.activeForPoint(cursor.to);let openCount=cursor.pointFrompos){iterator.span(pos,curTo,cursor.active,openRanges);openRanges=cursor.openEnd(curTo);}if(cursor.to>to)return openRanges+(cursor.point&&cursor.to>to?1:0);pos=cursor.to;cursor.next();}}static of(ranges,sort=false){let build=new RangeSetBuilder();for(let _i30=0,_ref=ranges instanceof Range$1?[ranges]:sort?lazySort(ranges):ranges,_length30=_ref.length;_i30<_length30;_i30++){let range=_ref[_i30];build.add(range.from,range.to,range.value);}return build.finish();}}RangeSet.empty=new RangeSet([],[],null,-1);function lazySort(ranges){if(ranges.length>1)for(let prev=ranges[0],i=1;i0)return ranges.slice().sort(cmpRange);prev=cur;}return ranges;}RangeSet.empty.nextLayer=RangeSet.empty;class RangeSetBuilder{finishChunk(newArrays){this.chunks.push(new Chunk$1(this.from,this.to,this.value,this.maxPoint));this.chunkPos.push(this.chunkStart);this.chunkStart=-1;this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint);this.maxPoint=-1;if(newArrays){this.from=[];this.to=[];this.value=[];}}constructor(){this.chunks=[];this.chunkPos=[];this.chunkStart=-1;this.last=null;this.lastFrom=-1000000000;this.lastTo=-1000000000;this.from=[];this.to=[];this.value=[];this.maxPoint=-1;this.setMaxPoint=-1;this.nextLayer=null;}add(from,to,value){if(!this.addInner(from,to,value))(this.nextLayer||(this.nextLayer=new RangeSetBuilder())).add(from,to,value);}addInner(from,to,value){let diff=from-this.lastTo||value.startSide-this.last.endSide;if(diff<=0&&(from-this.lastFrom||value.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");if(diff<0)return false;if(this.from.length==250)this.finishChunk(true);if(this.chunkStart<0)this.chunkStart=from;this.from.push(from-this.chunkStart);this.to.push(to-this.chunkStart);this.last=value;this.lastFrom=from;this.lastTo=to;this.value.push(value);if(value.point)this.maxPoint=Math.max(this.maxPoint,to-from);return true;}addChunk(from,chunk){if((from-this.lastTo||chunk.value[0].startSide-this.last.endSide)<0)return false;if(this.from.length)this.finishChunk(true);this.setMaxPoint=Math.max(this.setMaxPoint,chunk.maxPoint);this.chunks.push(chunk);this.chunkPos.push(from);let last=chunk.value.length-1;this.last=chunk.value[last];this.lastFrom=chunk.from[last]+from;this.lastTo=chunk.to[last]+from;return true;}finish(){return this.finishInner(RangeSet.empty);}finishInner(next){if(this.from.length)this.finishChunk(false);if(this.chunks.length==0)return next;let result=RangeSet.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(next):next,this.setMaxPoint);this.from=null;return result;}}function findSharedChunks(a,b,textDiff){let inA=new Map();for(let _i31=0,_length31=a.length;_i31<_length31;_i31++){let set=a[_i31];for(let i=0;i=this.minPoint)break;}}}setRangeIndex(index){if(index==this.layer.chunk[this.chunkIndex].value.length){this.chunkIndex++;if(this.skip){while(this.chunkIndex=minPoint)heap.push(new LayerCursor(cur,skip,minPoint,i));}}return heap.length==1?heap[0]:new HeapCursor(heap);}get startSide(){return this.value?this.value.startSide:0;}goto(pos,side=-1000000000){for(let _i33=0,_this$heap=this.heap,_length33=_this$heap.length;_i33<_length33;_i33++){let cur=_this$heap[_i33];cur.goto(pos,side);}for(let i=this.heap.length>>1;i>=0;i--)heapBubble(this.heap,i);this.next();return this;}forward(pos,side){for(let _i34=0,_this$heap2=this.heap,_length34=_this$heap2.length;_i34<_length34;_i34++){let cur=_this$heap2[_i34];cur.forward(pos,side);}for(let i=this.heap.length>>1;i>=0;i--)heapBubble(this.heap,i);if((this.to-pos||this.value.endSide-side)<0)this.next();}next(){if(this.heap.length==0){this.from=this.to=1000000000;this.value=null;this.rank=-1;}else{let top=this.heap[0];this.from=top.from;this.to=top.to;this.value=top.value;this.rank=top.rank;if(top.value)top.next();heapBubble(this.heap,0);}}}function heapBubble(heap,index){for(let cur=heap[index];;){let childIndex=(index<<1)+1;if(childIndex>=heap.length)break;let child=heap[childIndex];if(childIndex+1=0){child=heap[childIndex+1];childIndex++;}if(cur.compare(child)<0)break;heap[childIndex]=cur;heap[index]=child;index=childIndex;}}class SpanCursor{constructor(sets,skip,minPoint){this.minPoint=minPoint;this.active=[];this.activeTo=[];this.activeRank=[];this.minActive=-1;this.point=null;this.pointFrom=0;this.pointRank=0;this.to=-1000000000;this.endSide=0;this.openStart=-1;this.cursor=HeapCursor.from(sets,skip,minPoint);}goto(pos,side=-1000000000){this.cursor.goto(pos,side);this.active.length=this.activeTo.length=this.activeRank.length=0;this.minActive=-1;this.to=pos;this.endSide=side;this.openStart=-1;this.next();return this;}forward(pos,side){while(this.minActive>-1&&(this.activeTo[this.minActive]-pos||this.active[this.minActive].endSide-side)<0)this.removeActive(this.minActive);this.cursor.forward(pos,side);}removeActive(index){remove(this.active,index);remove(this.activeTo,index);remove(this.activeRank,index);this.minActive=findMinIndex(this.active,this.activeTo);}addActive(trackOpen){let i=0,{value,to,rank}=this.cursor;while(i-1&&(this.activeTo[a]-this.cursor.from||this.active[a].endSide-this.cursor.startSide)<0){if(this.activeTo[a]>from){this.to=this.activeTo[a];this.endSide=this.active[a].endSide;break;}this.removeActive(a);if(trackOpen)remove(trackOpen,a);}else if(!this.cursor.value){this.to=this.endSide=1000000000;break;}else if(this.cursor.from>from){this.to=this.cursor.from;this.endSide=this.cursor.startSide;break;}else{let nextVal=this.cursor.value;if(!nextVal.point){this.addActive(trackOpen);this.cursor.next();}else if(wasPoint&&this.cursor.to==this.to&&this.cursor.from=0&&trackOpen[i]=0;i--){if(this.activeRank[i]to||this.activeTo[i]==to&&this.active[i].endSide>=this.point.endSide)active.push(this.active[i]);}return active.reverse();}openEnd(to){let open=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>to;i--)open++;return open;}}function compare(a,startA,b,startB,length,comparator){a.goto(startA);b.goto(startB);let endB=startB+length;let pos=startB,dPos=startB-startA;for(;;){let diff=a.to+dPos-b.to||a.endSide-b.endSide;let end=diff<0?a.to+dPos:b.to,clipEnd=Math.min(end,endB);if(a.point||b.point){if(!(a.point&&b.point&&(a.point==b.point||a.point.eq(b.point))&&sameValues(a.activeForPoint(a.to+dPos),b.activeForPoint(b.to))))comparator.comparePoint(pos,clipEnd,a.point,b.point);}else{if(clipEnd>pos&&!sameValues(a.active,b.active))comparator.compareRange(pos,clipEnd,a.active,b.active);}if(end>endB)break;pos=end;if(diff<=0)a.next();if(diff>=0)b.next();}}function sameValues(a,b){if(a.length!=b.length)return false;for(let i=0;i=index;i--)array[i+1]=array[i];array[index]=value;}function findMinIndex(value,array){let found=-1,foundPos=1000000000;for(let i=0;i=col)return i;if(i==string.length)break;n+=string.charCodeAt(i)==9?tabSize-n%tabSize:1;i=findClusterBreak(string,i);}return strict===true?-1:string.length;}var _m0=Object.freeze({__proto__:null,Annotation:Annotation,AnnotationType:AnnotationType,ChangeDesc:ChangeDesc,ChangeSet:ChangeSet,get CharCategory(){return CharCategory;},Compartment:Compartment,EditorSelection:EditorSelection,EditorState:EditorState,Facet:Facet,Line:Line$1,get MapMode(){return MapMode;},Prec:Prec,Range:Range$1,RangeSet:RangeSet,RangeSetBuilder:RangeSetBuilder,RangeValue:RangeValue,SelectionRange:SelectionRange,StateEffect:StateEffect,StateEffectType:StateEffectType,StateField:StateField,Text:Text$1,Transaction:Transaction,codePointAt:codePointAt,codePointSize:codePointSize,combineConfig:combineConfig,countColumn:countColumn,findClusterBreak:findClusterBreak,findColumn:findColumn,fromCodePoint:fromCodePoint});const C="\u037c";const COUNT=typeof Symbol=="undefined"?"__"+C:Symbol.for(C);const SET=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet");const top=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{};class StyleModule{constructor(spec,options){this.rules=[];let{finish}=options||{};function splitSelector(selector){return /^@/.test(selector)?[selector]:selector.split(/,\s*/);}function render(selectors,spec,target,isKeyframes){let local=[],isAt=/^@(\w+)\b/.exec(selectors[0]),keyframes=isAt&&isAt[1]=="keyframes";if(isAt&&spec==null)return target.push(selectors[0]+";");for(let prop in spec){let value=spec[prop];if(/&/.test(prop)){render(prop.split(/,\s*/).map(part=>selectors.map(sel=>part.replace(/&/,sel))).reduce((a,b)=>a.concat(b)),value,target);}else if(value&&typeof value=="object"){if(!isAt)throw new RangeError("The value of a property ("+prop+") should be a primitive value.");render(splitSelector(prop),value,local,keyframes);}else if(value!=null){local.push(prop.replace(/_.*/,"").replace(/[A-Z]/g,l=>"-"+l.toLowerCase())+": "+value+";");}}if(local.length||keyframes){target.push((finish&&!isAt&&!isKeyframes?selectors.map(finish):selectors).join(", ")+" {"+local.join(" ")+"}");}}for(let prop in spec)render(splitSelector(prop),spec[prop],this.rules);}getRules(){return this.rules.join("\n");}static newName(){let id=top[COUNT]||1;top[COUNT]=id+1;return C+id.toString(36);}static mount(root,modules){(root[SET]||new StyleSet(root)).mount(Array.isArray(modules)?modules:[modules]);}}let adoptedSet=new Map();class StyleSet{constructor(root){let doc=root.ownerDocument||root,win=doc.defaultView;if(!root.head&&root.adoptedStyleSheets&&win.CSSStyleSheet){let adopted=adoptedSet.get(doc);if(adopted){root.adoptedStyleSheets=[adopted.sheet,...root.adoptedStyleSheets];return root[SET]=adopted;}this.sheet=new win.CSSStyleSheet();root.adoptedStyleSheets=[this.sheet,...root.adoptedStyleSheets];adoptedSet.set(doc,this);}else{this.styleTag=doc.createElement("style");let target=root.head||root;target.insertBefore(this.styleTag,target.firstChild);}this.modules=[];root[SET]=this;}mount(modules){let sheet=this.sheet;let pos=0,j=0;for(let i=0;i-1){this.modules.splice(index,1);j--;index=-1;}if(index==-1){this.modules.splice(j++,0,mod);if(sheet)for(let k=0;k",191:"?",192:"~",219:"{",220:"|",221:"}",222:"\""};var chrome$1=typeof navigator!="undefined"&&/Chrome\/(\d+)/.exec(navigator.userAgent);typeof navigator!="undefined"&&/Gecko\/\d+/.test(navigator.userAgent);var mac=typeof navigator!="undefined"&&/Mac/.test(navigator.platform);var ie$1=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);var brokenModifierNames=mac||chrome$1&&+chrome$1[1]<57;for(var i=0;i<10;i++)base[48+i]=base[96+i]=String(i);for(var i=1;i<=24;i++)base[i+111]="F"+i;for(var i=65;i<=90;i++){base[i]=String.fromCharCode(i+32);shift[i]=String.fromCharCode(i);}for(var code in base)if(!shift.hasOwnProperty(code))shift[code]=base[code];function keyName(event){var ignoreKey=brokenModifierNames&&(event.ctrlKey||event.altKey||event.metaKey)||ie$1&&event.shiftKey&&event.key&&event.key.length==1||event.key=="Unidentified";var name=!ignoreKey&&event.key||(event.shiftKey?shift:base)[event.keyCode]||event.key||"Unidentified";if(name=="Esc")name="Escape";if(name=="Del")name="Delete";if(name=="Left")name="ArrowLeft";if(name=="Up")name="ArrowUp";if(name=="Right")name="ArrowRight";if(name=="Down")name="ArrowDown";return name;}function getSelection(root){let target;if(root.nodeType==11){target=root.getSelection?root:root.ownerDocument;}else{target=root;}return target.getSelection();}function contains(dom,node){return node?dom==node||dom.contains(node.nodeType!=1?node.parentNode:node):false;}function deepActiveElement(doc){let elt=doc.activeElement;while(elt&&elt.shadowRoot)elt=elt.shadowRoot.activeElement;return elt;}function hasSelection(dom,selection){if(!selection.anchorNode)return false;try{return contains(dom,selection.anchorNode);}catch(_){return false;}}function clientRectsFor(dom){if(dom.nodeType==3)return textRange(dom,0,dom.nodeValue.length).getClientRects();else if(dom.nodeType==1)return dom.getClientRects();else return[];}function isEquivalentPosition(node,off,targetNode,targetOff){return targetNode?scanFor(node,off,targetNode,targetOff,-1)||scanFor(node,off,targetNode,targetOff,1):false;}function domIndex(node){for(var index=0;;index++){node=node.previousSibling;if(!node)return index;}}function scanFor(node,off,targetNode,targetOff,dir){for(;;){if(node==targetNode&&off==targetOff)return true;if(off==(dir<0?0:maxOffset(node))){if(node.nodeName=="DIV")return false;let parent=node.parentNode;if(!parent||parent.nodeType!=1)return false;off=domIndex(node)+(dir<0?0:1);node=parent;}else if(node.nodeType==1){node=node.childNodes[off+(dir<0?-1:0)];if(node.nodeType==1&&node.contentEditable=="false")return false;off=dir<0?maxOffset(node):0;}else{return false;}}}function maxOffset(node){return node.nodeType==3?node.nodeValue.length:node.childNodes.length;}function flattenRect(rect,left){let x=left?rect.left:rect.right;return{left:x,right:x,top:rect.top,bottom:rect.bottom};}function windowRect(win){return{left:0,right:win.innerWidth,top:0,bottom:win.innerHeight};}function scrollRectIntoView(dom,rect,side,x,y,xMargin,yMargin,ltr){let doc=dom.ownerDocument,win=doc.defaultView||window;for(let cur=dom,stop=false;cur&&!stop;){if(cur.nodeType==1){let bounding,top=cur==doc.body;if(top){bounding=windowRect(win);}else{if(/^(fixed|sticky)$/.test(getComputedStyle(cur).position))stop=true;if(cur.scrollHeight<=cur.clientHeight&&cur.scrollWidth<=cur.clientWidth){cur=cur.assignedSlot||cur.parentNode;continue;}let rect=cur.getBoundingClientRect();bounding={left:rect.left,right:rect.left+cur.clientWidth,top:rect.top,bottom:rect.top+cur.clientHeight};}let moveX=0,moveY=0;if(y=="nearest"){if(rect.top0&&rect.bottom>bounding.bottom+moveY)moveY=rect.bottom-bounding.bottom+moveY+yMargin;}else if(rect.bottom>bounding.bottom){moveY=rect.bottom-bounding.bottom+yMargin;if(side<0&&rect.top-moveY0&&rect.right>bounding.right+moveX)moveX=rect.right-bounding.right+moveX+xMargin;}else if(rect.right>bounding.right){moveX=rect.right-bounding.right+xMargin;if(side<0&&rect.leftcur.clientHeight||cur.scrollWidth>cur.clientWidth)return cur;cur=cur.assignedSlot||cur.parentNode;}else if(cur.nodeType==11){cur=cur.host;}else{break;}}return null;}class DOMSelectionState{constructor(){this.anchorNode=null;this.anchorOffset=0;this.focusNode=null;this.focusOffset=0;}eq(domSel){return this.anchorNode==domSel.anchorNode&&this.anchorOffset==domSel.anchorOffset&&this.focusNode==domSel.focusNode&&this.focusOffset==domSel.focusOffset;}setRange(range){let{anchorNode,focusNode}=range;this.set(anchorNode,Math.min(range.anchorOffset,anchorNode?maxOffset(anchorNode):0),focusNode,Math.min(range.focusOffset,focusNode?maxOffset(focusNode):0));}set(anchorNode,anchorOffset,focusNode,focusOffset){this.anchorNode=anchorNode;this.anchorOffset=anchorOffset;this.focusNode=focusNode;this.focusOffset=focusOffset;}}let preventScrollSupported=null;function focusPreventScroll(dom){if(dom.setActive)return dom.setActive();if(preventScrollSupported)return dom.focus(preventScrollSupported);let stack=[];for(let cur=dom;cur;cur=cur.parentNode){stack.push(cur,cur.scrollTop,cur.scrollLeft);if(cur==cur.ownerDocument)break;}dom.focus(preventScrollSupported==null?{get preventScroll(){preventScrollSupported={preventScroll:true};return true;}}:undefined);if(!preventScrollSupported){preventScrollSupported=false;for(let i=0;iMath.max(1,elt.scrollHeight-elt.clientHeight-4);}class DOMPos{constructor(node,offset,precise=true){this.node=node;this.offset=offset;this.precise=precise;}static before(dom,precise){return new DOMPos(dom.parentNode,domIndex(dom),precise);}static after(dom,precise){return new DOMPos(dom.parentNode,domIndex(dom)+1,precise);}}const noChildren=[];class ContentView{constructor(){this.parent=null;this.dom=null;this.flags=2;}get overrideDOMText(){return null;}get posAtStart(){return this.parent?this.parent.posBefore(this):0;}get posAtEnd(){return this.posAtStart+this.length;}posBefore(view){let pos=this.posAtStart;for(let _i35=0,_this$children2=this.children,_length35=_this$children2.length;_i35<_length35;_i35++){let child=_this$children2[_i35];if(child==view)return pos;pos+=child.length+child.breakAfter;}throw new RangeError("Invalid child in posBefore");}posAfter(view){return this.posBefore(view)+view.length;}sync(view,track){if(this.flags&2){let parent=this.dom;let prev=null,next;for(let _i36=0,_this$children3=this.children,_length36=_this$children3.length;_i36<_length36;_i36++){let child=_this$children3[_i36];if(child.flags&7){if(!child.dom&&(next=prev?prev.nextSibling:parent.firstChild)){let contentView=ContentView.get(next);if(!contentView||!contentView.parent&&contentView.canReuseDOM(child))child.reuseDOM(next);}child.sync(view,track);child.flags&=~7;}next=prev?prev.nextSibling:parent.firstChild;if(track&&!track.written&&track.node==parent&&next!=child.dom)track.written=true;if(child.dom.parentNode==parent){while(next&&next!=child.dom)next=rm$1(next);}else{parent.insertBefore(child.dom,next);}prev=child.dom;}next=prev?prev.nextSibling:parent.firstChild;if(next&&track&&track.node==parent)track.written=true;while(next)next=rm$1(next);}else if(this.flags&1){for(let _i37=0,_this$children4=this.children,_length37=_this$children4.length;_i37<_length37;_i37++){let child=_this$children4[_i37];if(child.flags&7){child.sync(view,track);child.flags&=~7;}}}}reuseDOM(_dom){}localPosFromDOM(node,offset){let after;if(node==this.dom){after=this.dom.childNodes[offset];}else{let bias=maxOffset(node)==0?0:offset==0?-1:1;for(;;){let parent=node.parentNode;if(parent==this.dom)break;if(bias==0&&parent.firstChild!=parent.lastChild){if(node==parent.firstChild)bias=-1;else bias=1;}node=parent;}if(bias<0)after=node;else after=node.nextSibling;}if(after==this.dom.firstChild)return 0;while(after&&!ContentView.get(after))after=after.nextSibling;if(!after)return this.length;for(let i=0,pos=0;;i++){let child=this.children[i];if(child.dom==after)return pos;pos+=child.length+child.breakAfter;}}domBoundsAround(from,to,offset=0){let fromI=-1,fromStart=-1,toI=-1,toEnd=-1;for(let i=0,pos=offset,prevEnd=offset;ito)return child.domBoundsAround(from,to,pos);if(end>=from&&fromI==-1){fromI=i;fromStart=pos;}if(pos>to&&child.dom.parentNode==this.dom){toI=i;toEnd=prevEnd;break;}prevEnd=end;pos=end+child.breakAfter;}return{from:fromStart,to:toEnd<0?offset+this.length:toEnd,startDOM:(fromI?this.children[fromI-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:toI=0?this.children[toI].dom:null};}markDirty(andParent=false){this.flags|=2;this.markParentsDirty(andParent);}markParentsDirty(childList){for(let parent=this.parent;parent;parent=parent.parent){if(childList)parent.flags|=2;if(parent.flags&1)return;parent.flags|=1;childList=false;}}setParent(parent){if(this.parent!=parent){this.parent=parent;if(this.flags&7)this.markParentsDirty(true);}}setDOM(dom){if(this.dom)this.dom.cmView=null;this.dom=dom;dom.cmView=this;}get rootView(){for(let v=this;;){let parent=v.parent;if(!parent)return v;v=parent;}}replaceChildren(from,to,children=noChildren){this.markDirty();for(let i=from;ithis.pos||pos==this.pos&&(bias>0||this.i==0||this.children[this.i-1].breakAfter)){this.off=pos-this.pos;return this;}let next=this.children[--this.i];this.pos-=next.length+next.breakAfter;}}}function replaceRange(parent,fromI,fromOff,toI,toOff,insert,breakAtStart,openStart,openEnd){let{children}=parent;let before=children.length?children[fromI]:null;let last=insert.length?insert[insert.length-1]:null;let breakAtEnd=last?last.breakAfter:breakAtStart;if(fromI==toI&&before&&!breakAtStart&&!breakAtEnd&&insert.length<2&&before.merge(fromOff,toOff,insert.length?last:null,fromOff==0,openStart,openEnd))return;if(toI0){if(!breakAtStart&&insert.length&&before.merge(fromOff,before.length,insert[0],false,openStart,0)){before.breakAfter=insert.shift().breakAfter;}else if(fromOffoldLen)this.lineBreak();cur=next;}this.findPointBefore(parent,end);return this;}readTextNode(node){let text=node.nodeValue;for(let _i39=0,_this$points=this.points,_length39=_this$points.length;_i39<_length39;_i39++){let point=_this$points[_i39];if(point.node==node)point.pos=this.text.length+Math.min(point.offset,text.length);}for(let off=0,re=this.lineSeparator?null:/\r\n?|\n/g;;){let nextBreak=-1,breakSize=1,m;if(this.lineSeparator){nextBreak=text.indexOf(this.lineSeparator,off);breakSize=this.lineSeparator.length;}else if(m=re.exec(text)){nextBreak=m.index;breakSize=m[0].length;}this.append(text.slice(off,nextBreak<0?text.length:nextBreak));if(nextBreak<0)break;this.lineBreak();if(breakSize>1)for(let _i40=0,_this$points2=this.points,_length40=_this$points2.length;_i40<_length40;_i40++){let point=_this$points2[_i40];if(point.node==node&&point.pos>this.text.length)point.pos-=breakSize-1;}off=nextBreak+breakSize;}}readNode(node){if(node.cmIgnore)return;let view=ContentView.get(node);let fromView=view&&view.overrideDOMText;if(fromView!=null){this.findPointInside(node,fromView.length);for(let i=fromView.iter();!i.next().done;){if(i.lineBreak)this.lineBreak();else this.append(i.value);}}else if(node.nodeType==3){this.readTextNode(node);}else if(node.nodeName=="BR"){if(node.nextSibling)this.lineBreak();}else if(node.nodeType==1){this.readRange(node.firstChild,null);}}findPointBefore(node,next){for(let _i41=0,_this$points3=this.points,_length41=_this$points3.length;_i41<_length41;_i41++){let point=_this$points3[_i41];if(point.node==node&&node.childNodes[point.offset]==next)point.pos=this.text.length;}}findPointInside(node,maxLen){for(let _i42=0,_this$points4=this.points,_length42=_this$points4.length;_i42<_length42;_i42++){let point=_this$points4[_i42];if(node.nodeType==3?point.node==node:node.contains(point.node))point.pos=this.text.length+Math.min(maxLen,point.offset);}}}function isBlockElement(node){return node.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(node.nodeName);}class DOMPoint{constructor(node,offset){this.node=node;this.offset=offset;this.pos=-1;}}let nav=typeof navigator!="undefined"?navigator:{userAgent:"",vendor:"",platform:""};let doc=typeof document!="undefined"?document:{documentElement:{style:{}}};const ie_edge=/Edge\/(\d+)/.exec(nav.userAgent);const ie_upto10=/MSIE \d/.test(nav.userAgent);const ie_11up=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nav.userAgent);const ie=!!(ie_upto10||ie_11up||ie_edge);const gecko=!ie&&/gecko\/(\d+)/i.test(nav.userAgent);const chrome=!ie&&/Chrome\/(\d+)/.exec(nav.userAgent);const webkit=("webkitFontSmoothing"in doc.documentElement.style);const safari=!ie&&/Apple Computer/.test(nav.vendor);const ios=safari&&(/Mobile\/\w+/.test(nav.userAgent)||nav.maxTouchPoints>2);var browser={mac:ios||/Mac/.test(nav.platform),windows:/Win/.test(nav.platform),linux:/Linux|X11/.test(nav.platform),ie,ie_version:ie_upto10?doc.documentMode||6:ie_11up?+ie_11up[1]:ie_edge?+ie_edge[1]:0,gecko,gecko_version:gecko?+(/Firefox\/(\d+)/.exec(nav.userAgent)||[0,0])[1]:0,chrome:!!chrome,chrome_version:chrome?+chrome[1]:0,ios,android:/Android\b/.test(nav.userAgent),webkit,safari,webkit_version:webkit?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:doc.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const MaxJoinLen=256;class TextView extends ContentView{constructor(text){super();this.text=text;}get length(){return this.text.length;}createDOM(textDOM){this.setDOM(textDOM||document.createTextNode(this.text));}sync(view,track){if(!this.dom)this.createDOM();if(this.dom.nodeValue!=this.text){if(track&&track.node==this.dom)track.written=true;this.dom.nodeValue=this.text;}}reuseDOM(dom){if(dom.nodeType==3)this.createDOM(dom);}merge(from,to,source){if(this.flags&8||source&&(!(source instanceof TextView)||this.length-(to-from)+source.length>MaxJoinLen||source.flags&8))return false;this.text=this.text.slice(0,from)+(source?source.text:"")+this.text.slice(to);this.markDirty();return true;}split(from){let result=new TextView(this.text.slice(from));this.text=this.text.slice(0,from);this.markDirty();result.flags|=this.flags&8;return result;}localPosFromDOM(node,offset){return node==this.dom?offset:offset?this.text.length:0;}domAtPos(pos){return new DOMPos(this.dom,pos);}domBoundsAround(_from,_to,offset){return{from:offset,to:offset+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling};}coordsAt(pos,side){return textCoords(this.dom,pos,side);}}class MarkView extends ContentView{constructor(mark,children=[],length=0){super();this.mark=mark;this.children=children;this.length=length;for(let _i43=0,_length43=children.length;_i43<_length43;_i43++){let ch=children[_i43];ch.setParent(this);}}setAttrs(dom){clearAttributes(dom);if(this.mark.class)dom.className=this.mark.class;if(this.mark.attrs)for(let name in this.mark.attrs)dom.setAttribute(name,this.mark.attrs[name]);return dom;}canReuseDOM(other){return super.canReuseDOM(other)&&!((this.flags|other.flags)&8);}reuseDOM(node){if(node.nodeName==this.mark.tagName.toUpperCase()){this.setDOM(node);this.flags|=4|2;}}sync(view,track){if(!this.dom)this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));else if(this.flags&4)this.setAttrs(this.dom);super.sync(view,track);}merge(from,to,source,_hasStart,openStart,openEnd){if(source&&(!(source instanceof MarkView&&source.mark.eq(this.mark))||from&&openStart<=0||tofrom)result.push(off=from)detachFrom=i;off=end;i++;}let length=this.length-from;this.length=from;if(detachFrom>-1){this.children.length=detachFrom;this.markDirty();}return new MarkView(this.mark,result,length);}domAtPos(pos){return inlineDOMAtPos(this,pos);}coordsAt(pos,side){return coordsInChildren(this,pos,side);}}function textCoords(text,pos,side){let length=text.nodeValue.length;if(pos>length)pos=length;let from=pos,to=pos,flatten=0;if(pos==0&&side<0||pos==length&&side>=0){if(!(browser.chrome||browser.gecko)){if(pos){from--;flatten=1;}else if(to=0)?0:rects.length-1];if(browser.safari&&!flatten&&rect.width==0)rect=Array.prototype.find.call(rects,r=>r.width)||rect;return flatten?flattenRect(rect,flatten<0):rect||null;}class WidgetView extends ContentView{static create(widget,length,side){return new WidgetView(widget,length,side);}constructor(widget,length,side){super();this.widget=widget;this.length=length;this.side=side;this.prevWidget=null;}split(from){let result=WidgetView.create(this.widget,this.length-from,this.side);this.length-=from;return result;}sync(view){if(!this.dom||!this.widget.updateDOM(this.dom,view)){if(this.dom&&this.prevWidget)this.prevWidget.destroy(this.dom);this.prevWidget=null;this.setDOM(this.widget.toDOM(view));this.dom.contentEditable="false";}}getSide(){return this.side;}merge(from,to,source,hasStart,openStart,openEnd){if(source&&(!(source instanceof WidgetView)||!this.widget.compare(source.widget)||from>0&&openStart<=0||to0)?DOMPos.before(this.dom):DOMPos.after(this.dom,pos==this.length);}domBoundsAround(){return null;}coordsAt(pos,side){let custom=this.widget.coordsAt(this.dom,pos,side);if(custom)return custom;let rects=this.dom.getClientRects(),rect=null;if(!rects.length)return null;let fromBack=this.side?this.side<0:pos>0;for(let i=fromBack?rects.length-1:0;;i+=fromBack?-1:1){rect=rects[i];if(pos>0?i==0:i==rects.length-1||rect.top0?DOMPos.before(this.dom):DOMPos.after(this.dom);}localPosFromDOM(){return 0;}domBoundsAround(){return null;}coordsAt(pos){return this.dom.getBoundingClientRect();}get overrideDOMText(){return Text$1.empty;}get isHidden(){return true;}}TextView.prototype.children=WidgetView.prototype.children=WidgetBufferView.prototype.children=noChildren;function inlineDOMAtPos(parent,pos){let dom=parent.dom,{children}=parent,i=0;for(let off=0;ioff&&pos0;j--){let prev=children[j-1];if(prev.dom.parentNode==dom)return prev.domAtPos(prev.length);}for(let j=i;j0&&view instanceof MarkView&&children.length&&(last=children[children.length-1])instanceof MarkView&&last.mark.eq(view.mark)){joinInlineInto(last,view.children[0],open-1);}else{children.push(view);view.setParent(parent);}parent.length+=view.length;}function coordsInChildren(view,pos,side){let before=null,beforePos=-1,after=null,afterPos=-1;function scan(view,pos){for(let i=0,off=0;i=pos){if(child.children.length){scan(child,pos-off);}else if((!after||after.isHidden&&side>0)&&(end>pos||off==end&&child.getSide()>0)){after=child;afterPos=pos-off;}else if(off-1?1:0)!=keysB.length-(ignore&&keysB.indexOf(ignore)>-1?1:0))return false;for(let _i45=0,_length45=keysA.length;_i45<_length45;_i45++){let key=keysA[_i45];if(key!=ignore&&(keysB.indexOf(key)==-1||a[key]!==b[key]))return false;}return true;}function updateAttrs(dom,prev,attrs){let changed=null;if(prev)for(let name in prev)if(!(attrs&&name in attrs))dom.removeAttribute(changed=name);if(attrs)for(let name in attrs)if(!(prev&&prev[name]==attrs[name]))dom.setAttribute(changed=name,attrs[name]);return!!changed;}function getAttrs$1(dom){let attrs=Object.create(null);for(let i=0;i0?300000000:-400000000:side>0?100000000:-100000000;return new PointDecoration(spec,side,side,block,spec.widget||null,false);}static replace(spec){let block=!!spec.block,startSide,endSide;if(spec.isBlockGap){startSide=-500000000;endSide=400000000;}else{let{start,end}=getInclusive(spec,block);startSide=(start?block?-300000000:-1:500000000)-1;endSide=(end?block?200000000:1:-600000000)+1;}return new PointDecoration(spec,startSide,endSide,block,spec.widget||null,true);}static line(spec){return new LineDecoration(spec);}static set(of,sort=false){return RangeSet.of(of,sort);}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:false;}}Decoration.none=RangeSet.empty;class MarkDecoration extends Decoration{constructor(spec){let{start,end}=getInclusive(spec);super(start?-1:500000000,end?1:-600000000,null,spec);this.tagName=spec.tagName||"span";this.class=spec.class||"";this.attrs=spec.attributes||null;}eq(other){var _a,_b;return this==other||other instanceof MarkDecoration&&this.tagName==other.tagName&&(this.class||((_a=this.attrs)===null||_a===void 0?void 0:_a.class))==(other.class||((_b=other.attrs)===null||_b===void 0?void 0:_b.class))&&attrsEq(this.attrs,other.attrs,"class");}range(from,to=from){if(from>=to)throw new RangeError("Mark decorations may not be empty");return super.range(from,to);}}MarkDecoration.prototype.point=false;class LineDecoration extends Decoration{constructor(spec){super(-200000000,-200000000,null,spec);}eq(other){return other instanceof LineDecoration&&this.spec.class==other.spec.class&&attrsEq(this.spec.attributes,other.spec.attributes);}range(from,to=from){if(to!=from)throw new RangeError("Line decoration ranges must be zero-length");return super.range(from,to);}}LineDecoration.prototype.mapMode=MapMode.TrackBefore;LineDecoration.prototype.point=true;class PointDecoration extends Decoration{constructor(spec,startSide,endSide,block,widget,isReplace){super(startSide,endSide,widget,spec);this.block=block;this.isReplace=isReplace;this.mapMode=!block?MapMode.TrackDel:startSide<=0?MapMode.TrackBefore:MapMode.TrackAfter;}get type(){return this.startSide=5||this.widget.lineBreaks>0);}eq(other){return other instanceof PointDecoration&&widgetsEq(this.widget,other.widget)&&this.block==other.block&&this.startSide==other.startSide&&this.endSide==other.endSide;}range(from,to=from){if(this.isReplace&&(from>to||from==to&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&to!=from)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(from,to);}}PointDecoration.prototype.point=true;function getInclusive(spec,block=false){let{inclusiveStart:start,inclusiveEnd:end}=spec;if(start==null)start=spec.inclusive;if(end==null)end=spec.inclusive;return{start:start!==null&&start!==void 0?start:block,end:end!==null&&end!==void 0?end:block};}function widgetsEq(a,b){return a==b||!!(a&&b&&a.compare(b));}function addRange(from,to,ranges,margin=0){let last=ranges.length-1;if(last>=0&&ranges[last]+margin>=from)ranges[last]=Math.max(ranges[last],to);else ranges.push(from,to);}class LineView extends ContentView{constructor(){super(...arguments);this.children=[];this.length=0;this.prevAttrs=undefined;this.attrs=null;this.breakAfter=0;}merge(from,to,source,hasStart,openStart,openEnd){if(source){if(!(source instanceof LineView))return false;if(!this.dom)source.transferDOM(this);}if(hasStart)this.setDeco(source?source.attrs:null);mergeChildrenInto(this,from,to,source?source.children:[],openStart,openEnd);return true;}split(at){let end=new LineView();end.breakAfter=this.breakAfter;if(this.length==0)return end;let{i,off}=this.childPos(at);if(off){end.append(this.children[i].split(off),0);this.children[i].merge(off,this.children[i].length,null,false,0,0);i++;}for(let j=i;j0&&this.children[i-1].length==0)this.children[--i].destroy();this.children.length=i;this.markDirty();this.length=at;return end;}transferDOM(other){if(!this.dom)return;this.markDirty();other.setDOM(this.dom);other.prevAttrs=this.prevAttrs===undefined?this.attrs:this.prevAttrs;this.prevAttrs=undefined;this.dom=null;}setDeco(attrs){if(!attrsEq(this.attrs,attrs)){if(this.dom){this.prevAttrs=this.attrs;this.markDirty();}this.attrs=attrs;}}append(child,openStart){joinInlineInto(this,child,openStart);}addLineDeco(deco){let attrs=deco.spec.attributes,cls=deco.spec.class;if(attrs)this.attrs=combineAttrs(attrs,this.attrs||{});if(cls)this.attrs=combineAttrs({class:cls},this.attrs||{});}domAtPos(pos){return inlineDOMAtPos(this,pos);}reuseDOM(node){if(node.nodeName=="DIV"){this.setDOM(node);this.flags|=4|2;}}sync(view,track){var _a;if(!this.dom){this.setDOM(document.createElement("div"));this.dom.className="cm-line";this.prevAttrs=this.attrs?null:undefined;}else if(this.flags&4){clearAttributes(this.dom);this.dom.className="cm-line";this.prevAttrs=this.attrs?null:undefined;}if(this.prevAttrs!==undefined){updateAttrs(this.dom,this.prevAttrs,this.attrs);this.dom.classList.add("cm-line");this.prevAttrs=undefined;}super.sync(view,track);let last=this.dom.lastChild;while(last&&ContentView.get(last)instanceof MarkView)last=last.lastChild;if(!last||!this.length||last.nodeName!="BR"&&((_a=ContentView.get(last))===null||_a===void 0?void 0:_a.isEditable)==false&&(!browser.ios||!this.children.some(ch=>ch instanceof TextView))){let hack=document.createElement("BR");hack.cmIgnore=true;this.dom.appendChild(hack);}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let totalWidth=0,textHeight;for(let _i46=0,_this$children6=this.children,_length46=_this$children6.length;_i46<_length46;_i46++){let child=_this$children6[_i46];if(!(child instanceof TextView)||/[^ -~]/.test(child.text))return null;let rects=clientRectsFor(child.dom);if(rects.length!=1)return null;totalWidth+=rects[0].width;textHeight=rects[0].height;}return!totalWidth?null:{lineHeight:this.dom.getBoundingClientRect().height,charWidth:totalWidth/this.length,textHeight};}coordsAt(pos,side){let rect=coordsInChildren(this,pos,side);if(!this.children.length&&rect&&this.parent){let{heightOracle}=this.parent.view.viewState,height=rect.bottom-rect.top;if(Math.abs(height-heightOracle.lineHeight)<2&&heightOracle.textHeight=pos){if(block instanceof LineView)return block;if(end>pos)break;}off=end+block.breakAfter;}return null;}}class BlockWidgetView extends ContentView{constructor(widget,length,type){super();this.widget=widget;this.length=length;this.type=type;this.breakAfter=0;this.prevWidget=null;}merge(from,to,source,_takeDeco,openStart,openEnd){if(source&&(!(source instanceof BlockWidgetView)||!this.widget.compare(source.widget)||from>0&&openStart<=0||to0){if(this.textOff==this.text.length){let{value,lineBreak,done}=this.cursor.next(this.skip);this.skip=0;if(done)throw new Error("Ran out of text content when drawing inline views");if(lineBreak){if(!this.posCovered())this.getLine();if(this.content.length)this.content[this.content.length-1].breakAfter=1;else this.breakAtStart=1;this.flushBuffer();this.curLine=null;this.atCursorPos=true;length--;continue;}else{this.text=value;this.textOff=0;}}let take=Math.min(this.text.length-this.textOff,length,512);this.flushBuffer(active.slice(active.length-openStart));this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff,this.textOff+take)),active),openStart);this.atCursorPos=true;this.textOff+=take;length-=take;openStart=0;}}span(from,to,active,openStart){this.buildText(to-from,active,openStart);this.pos=to;if(this.openStart<0)this.openStart=openStart;}point(from,to,deco,active,openStart,index){if(this.disallowBlockEffectsFor[index]&&deco instanceof PointDecoration){if(deco.block)throw new RangeError("Block decorations may not be specified via plugins");if(to>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins");}let len=to-from;if(deco instanceof PointDecoration){if(deco.block){let{type}=deco;if(type==BlockType.WidgetAfter&&!this.posCovered())this.getLine();this.addBlockWidget(new BlockWidgetView(deco.widget||new NullWidget("div"),len,type));}else{let view=WidgetView.create(deco.widget||new NullWidget("span"),len,len?0:deco.startSide);let cursorBefore=this.atCursorPos&&!view.isEditable&&openStart<=active.length&&(from0);let cursorAfter=!view.isEditable&&(fromactive.length||deco.startSide<=0);let line=this.getLine();if(this.pendingBuffer==2&&!cursorBefore&&!view.isEditable)this.pendingBuffer=0;this.flushBuffer(active);if(cursorBefore){line.append(wrapMarks(new WidgetBufferView(1),active),openStart);openStart=active.length+Math.max(0,openStart-active.length);}line.append(wrapMarks(view,active),openStart);this.atCursorPos=cursorAfter;this.pendingBuffer=!cursorAfter?0:fromactive.length?1:2;if(this.pendingBuffer)this.bufferMarks=active.slice();}}else if(this.doc.lineAt(this.pos).from==this.pos){this.getLine().addLineDeco(deco);}if(len){if(this.textOff+len<=this.text.length){this.textOff+=len;}else{this.skip+=len-(this.text.length-this.textOff);this.text="";this.textOff=0;}this.pos=to;}if(this.openStart<0)this.openStart=openStart;}static build(text,from,to,decorations,dynamicDecorationMap){let builder=new ContentBuilder(text,from,to,dynamicDecorationMap);builder.openEnd=RangeSet.spans(decorations,from,to,builder);if(builder.openStart<0)builder.openStart=builder.openEnd;builder.finish(builder.openEnd);return builder;}}function wrapMarks(view,active){for(let _i47=0,_length47=active.length;_i47<_length47;_i47++){let mark=active[_i47];view=new MarkView(mark,[view],view.length);}return view;}class NullWidget extends WidgetType{constructor(tag){super();this.tag=tag;}eq(other){return other.tag==this.tag;}toDOM(){return document.createElement(this.tag);}updateDOM(elt){return elt.nodeName.toLowerCase()==this.tag;}get isHidden(){return true;}}const clickAddsSelectionRange=Facet.define();const dragMovesSelection$1=Facet.define();const mouseSelectionStyle=Facet.define();const exceptionSink=Facet.define();const updateListener=Facet.define();const inputHandler$1=Facet.define();const focusChangeEffect=Facet.define();const perLineTextDirection=Facet.define({combine:values=>values.some(x=>x)});const nativeSelectionHidden=Facet.define({combine:values=>values.some(x=>x)});class ScrollTarget{constructor(range,y="nearest",x="nearest",yMargin=5,xMargin=5){this.range=range;this.y=y;this.x=x;this.yMargin=yMargin;this.xMargin=xMargin;}map(changes){return changes.empty?this:new ScrollTarget(this.range.map(changes),this.y,this.x,this.yMargin,this.xMargin);}}const scrollIntoView$1=StateEffect.define({map:(t,ch)=>t.map(ch)});function logException(state,exception,context){let handler=state.facet(exceptionSink);if(handler.length)handler[0](exception);else if(window.onerror)window.onerror(String(exception),context,undefined,undefined,exception);else if(context)console.error(context+":",exception);else console.error(exception);}const editable=Facet.define({combine:values=>values.length?values[0]:true});let nextPluginID=0;const viewPlugin=Facet.define();class ViewPlugin{constructor(id,create,domEventHandlers,buildExtensions){this.id=id;this.create=create;this.domEventHandlers=domEventHandlers;this.extension=buildExtensions(this);}static define(create,spec){const{eventHandlers,provide,decorations:deco}=spec||{};return new ViewPlugin(nextPluginID++,create,eventHandlers,plugin=>{let ext=[viewPlugin.of(plugin)];if(deco)ext.push(decorations.of(view=>{let pluginInst=view.plugin(plugin);return pluginInst?deco(pluginInst):Decoration.none;}));if(provide)ext.push(provide(plugin));return ext;});}static fromClass(cls,spec){return ViewPlugin.define(view=>new cls(view),spec);}}class PluginInstance{constructor(spec){this.spec=spec;this.mustUpdate=null;this.value=null;}update(view){if(!this.value){if(this.spec){try{this.value=this.spec.create(view);}catch(e){logException(view.state,e,"CodeMirror plugin crashed");this.deactivate();}}}else if(this.mustUpdate){let update=this.mustUpdate;this.mustUpdate=null;if(this.value.update){try{this.value.update(update);}catch(e){logException(update.state,e,"CodeMirror plugin crashed");if(this.value.destroy)try{this.value.destroy();}catch(_){}this.deactivate();}}}return this;}destroy(view){var _a;if((_a=this.value)===null||_a===void 0?void 0:_a.destroy){try{this.value.destroy();}catch(e){logException(view.state,e,"CodeMirror plugin crashed");}}}deactivate(){this.spec=this.value=null;}}const editorAttributes=Facet.define();const contentAttributes=Facet.define();const decorations=Facet.define();const atomicRanges=Facet.define();const scrollMargins=Facet.define();function getScrollMargins(view){let left=0,right=0,top=0,bottom=0;for(let _i48=0,_view$state$facet=view.state.facet(scrollMargins),_length48=_view$state$facet.length;_i48<_length48;_i48++){let source=_view$state$facet[_i48];let m=source(view);if(m){if(m.left!=null)left=Math.max(left,m.left);if(m.right!=null)right=Math.max(right,m.right);if(m.top!=null)top=Math.max(top,m.top);if(m.bottom!=null)bottom=Math.max(bottom,m.bottom);}}return{left,right,top,bottom};}const styleModule=Facet.define();class ChangedRange{constructor(fromA,toA,fromB,toB){this.fromA=fromA;this.toA=toA;this.fromB=fromB;this.toB=toB;}join(other){return new ChangedRange(Math.min(this.fromA,other.fromA),Math.max(this.toA,other.toA),Math.min(this.fromB,other.fromB),Math.max(this.toB,other.toB));}addToSet(set){let i=set.length,me=this;for(;i>0;i--){let range=set[i-1];if(range.fromA>me.toA)continue;if(range.toAend)break;else rI+=2;}if(!next)return result;new ChangedRange(next.fromA,next.toA,next.fromB,next.toB).addToSet(result);posA=next.toA;posB=next.toB;}}}class ViewUpdate{constructor(view,state,transactions){this.view=view;this.state=state;this.transactions=transactions;this.flags=0;this.startState=view.state;this.changes=ChangeSet.empty(this.startState.doc.length);for(let _i49=0,_length49=transactions.length;_i49<_length49;_i49++){let tr=transactions[_i49];this.changes=this.changes.compose(tr.changes);}let changedRanges=[];this.changes.iterChangedRanges((fromA,toA,fromB,toB)=>changedRanges.push(new ChangedRange(fromA,toA,fromB,toB)));this.changedRanges=changedRanges;}static create(view,state,transactions){return new ViewUpdate(view,state,transactions);}get viewportChanged(){return(this.flags&4)>0;}get heightChanged(){return(this.flags&2)>0;}get geometryChanged(){return this.docChanged||(this.flags&(8|2))>0;}get focusChanged(){return(this.flags&1)>0;}get docChanged(){return!this.changes.empty;}get selectionSet(){return this.transactions.some(tr=>tr.selection);}get empty(){return this.flags==0&&this.transactions.length==0;}}var Direction=function(Direction){Direction[Direction["LTR"]=0]="LTR";Direction[Direction["RTL"]=1]="RTL";return Direction;}(Direction||(Direction={}));const LTR=Direction.LTR,RTL=Direction.RTL;function dec(str){let result=[];for(let i=0;i=index){if(span.level==level)return i;if(maybe<0||(assoc!=0?assoc<0?span.fromindex:order[maybe].level>span.level))maybe=i;}}if(maybe<0)throw new RangeError("Index out of range");return maybe;}}const types=[];function computeOrder(line,direction){let len=line.length,outerType=direction==LTR?1:2,oppositeType=direction==LTR?2:1;if(!line||outerType==1&&!BidiRE.test(line))return trivialOrder(len);for(let i=0,prev=outerType,prevStrong=outerType;i=0;sJ-=3){if(BracketStack[sJ+1]==-br){let flags=BracketStack[sJ+2];let type=flags&2?outerType:!(flags&4)?0:flags&1?oppositeType:outerType;if(type)types[i]=types[BracketStack[sJ]]=type;sI=sJ;break;}}}else if(BracketStack.length==189){break;}else{BracketStack[sI++]=i;BracketStack[sI++]=ch;BracketStack[sI++]=context;}}else if((type=types[i])==2||type==1){let embed=type==outerType;context=embed?0:1;for(let sJ=sI-3;sJ>=0;sJ-=3){let cur=BracketStack[sJ+2];if(cur&2)break;if(embed){BracketStack[sJ+2]|=2;}else{if(cur&4)break;BracketStack[sJ+2]|=4;}}}}for(let i=0;istart;){let end=j,l=types[--j]!=2;while(j>start&&l==(types[j-1]!=2))j--;order.push(new BidiSpan(j,end,l?2:1));}}else{order.push(new BidiSpan(start,i,0));}}}else{for(let i=0;i0&&changedRanges.length){if(!changedRanges.every(({fromA,toA})=>toAthis.minWidthTo)){this.minWidth=this.minWidthFrom=this.minWidthTo=0;}else{this.minWidthFrom=update.changes.mapPos(this.minWidthFrom,1);this.minWidthTo=update.changes.mapPos(this.minWidthTo,1);}}let composition=this.view.inputState.composing<0?null:findCompositionRange(this.view,update.changes);if(this.hasComposition){this.markedForComposition.clear();let{from,to}=this.hasComposition;changedRanges=new ChangedRange(from,to,update.changes.mapPos(from,-1),update.changes.mapPos(to,1)).addToSet(changedRanges.slice());}this.hasComposition=composition?{from:composition.range.fromB,to:composition.range.toB}:null;if((browser.ie||browser.chrome)&&!composition&&update&&update.state.doc.lines!=update.startState.doc.lines)this.forceSelection=true;let prevDeco=this.decorations,deco=this.updateDeco();let decoDiff=findChangedDeco(prevDeco,deco,update.changes);changedRanges=ChangedRange.extendWithRanges(changedRanges,decoDiff);if(!(this.flags&7)&&changedRanges.length==0){return false;}else{this.updateInner(changedRanges,update.startState.doc.length,composition);if(update.transactions.length)this.lastUpdate=Date.now();return true;}}updateInner(changes,oldLength,composition){this.view.viewState.mustMeasureContent=true;this.updateChildren(changes,oldLength,composition);let{observer}=this.view;observer.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight+"px";this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let track=browser.chrome||browser.ios?{node:observer.selectionRange.focusNode,written:false}:undefined;this.sync(this.view,track);this.flags&=~7;if(track&&(track.written||observer.selectionRange.focusNode!=track.node))this.forceSelection=true;this.dom.style.height="";});this.markedForComposition.forEach(cView=>cView.flags&=~8);let gaps=[];if(this.view.viewport.from||this.view.viewport.to=0?ranges[i]:null;if(!next)break;let{fromA,toA,fromB,toB}=next,content,breakAtStart,openStart,openEnd;if(composition&&composition.range.fromBfromB){let before=ContentBuilder.build(this.view.state.doc,fromB,composition.range.fromB,this.decorations,this.dynamicDecorationMap);let after=ContentBuilder.build(this.view.state.doc,composition.range.toB,toB,this.decorations,this.dynamicDecorationMap);breakAtStart=before.breakAtStart;openStart=before.openStart;openEnd=after.openEnd;let compLine=this.compositionView(composition);if(after.breakAtStart){compLine.breakAfter=1;}else if(after.content.length&&compLine.merge(compLine.length,compLine.length,after.content[0],false,after.openStart,0)){compLine.breakAfter=after.content[0].breakAfter;after.content.shift();}if(before.content.length&&compLine.merge(0,0,before.content[before.content.length-1],true,0,before.openEnd)){before.content.pop();}content=before.content.concat(compLine).concat(after.content);}else{({content,breakAtStart,openStart,openEnd}=ContentBuilder.build(this.view.state.doc,fromB,toB,this.decorations,this.dynamicDecorationMap));}let{i:toI,off:toOff}=cursor.findPos(toA,1);let{i:fromI,off:fromOff}=cursor.findPos(fromA,-1);replaceRange(this,fromI,fromOff,toI,toOff,content,breakAtStart,openStart,openEnd);}if(composition)this.fixCompositionDOM(composition);}compositionView(composition){let cur=new TextView(composition.text.nodeValue);cur.flags|=8;for(let _i52=0,_composition$marks=composition.marks,_length52=_composition$marks.length;_i52<_length52;_i52++){let{deco}=_composition$marks[_i52];cur=new MarkView(deco,[cur],cur.length);}let line=new LineView();line.append(cur,0);return line;}fixCompositionDOM(composition){let fix=(dom,cView)=>{cView.flags|=8;this.markedForComposition.add(cView);let prev=ContentView.get(dom);if(prev!=cView){if(prev)prev.dom=null;cView.setDOM(dom);}};let pos=this.childPos(composition.range.fromB,1);let cView=this.children[pos.i];fix(composition.line,cView);for(let i=composition.marks.length-1;i>=-1;i--){pos=cView.childPos(pos.off,1);cView=cView.children[pos.i];fix(i>=0?composition.marks[i].node:composition.text,cView);}}updateSelection(mustRead=false,fromPointer=false){if(mustRead||!this.view.observer.selectionRange.focusNode)this.view.observer.readSelectionRange();let activeElt=this.view.root.activeElement,focused=activeElt==this.dom;let selectionNotFocus=!focused&&hasSelection(this.dom,this.view.observer.selectionRange)&&!(activeElt&&this.dom.contains(activeElt));if(!(focused||fromPointer||selectionNotFocus))return;let force=this.forceSelection;this.forceSelection=false;let main=this.view.state.selection.main;let anchor=this.domAtPos(main.anchor);let head=main.empty?anchor:this.domAtPos(main.head);if(browser.gecko&&main.empty&&!this.hasComposition&&betweenUneditable(anchor)){let dummy=document.createTextNode("");this.view.observer.ignore(()=>anchor.node.insertBefore(dummy,anchor.node.childNodes[anchor.offset]||null));anchor=head=new DOMPos(dummy,0);force=true;}let domSel=this.view.observer.selectionRange;if(force||!domSel.focusNode||!isEquivalentPosition(anchor.node,anchor.offset,domSel.anchorNode,domSel.anchorOffset)||!isEquivalentPosition(head.node,head.offset,domSel.focusNode,domSel.focusOffset)){this.view.observer.ignore(()=>{if(browser.android&&browser.chrome&&this.dom.contains(domSel.focusNode)&&inUneditable(domSel.focusNode,this.dom)){this.dom.blur();this.dom.focus({preventScroll:true});}let rawSel=getSelection(this.view.root);if(!rawSel);else if(main.empty){if(browser.gecko){let nextTo=nextToUneditable(anchor.node,anchor.offset);if(nextTo&&nextTo!=(1|2)){let text=nearbyTextNode(anchor.node,anchor.offset,nextTo==1?1:-1);if(text)anchor=new DOMPos(text,nextTo==1?0:text.nodeValue.length);}}rawSel.collapse(anchor.node,anchor.offset);if(main.bidiLevel!=null&&domSel.cursorBidiLevel!=null)domSel.cursorBidiLevel=main.bidiLevel;}else if(rawSel.extend){rawSel.collapse(anchor.node,anchor.offset);try{rawSel.extend(head.node,head.offset);}catch(_){}}else{let range=document.createRange();if(main.anchor>main.head)[anchor,head]=[head,anchor];range.setEnd(head.node,head.offset);range.setStart(anchor.node,anchor.offset);rawSel.removeAllRanges();rawSel.addRange(range);}if(selectionNotFocus&&this.view.root.activeElement==this.dom){this.dom.blur();if(activeElt)activeElt.focus();}});this.view.observer.setSelectionRange(anchor,head);}this.impreciseAnchor=anchor.precise?null:new DOMPos(domSel.anchorNode,domSel.anchorOffset);this.impreciseHead=head.precise?null:new DOMPos(domSel.focusNode,domSel.focusOffset);}enforceCursorAssoc(){if(this.hasComposition)return;let{view}=this,cursor=view.state.selection.main;let sel=getSelection(view.root);let{anchorNode,anchorOffset}=view.observer.selectionRange;if(!sel||!cursor.empty||!cursor.assoc||!sel.modify)return;let line=LineView.find(this,cursor.head);if(!line)return;let lineStart=line.posAtStart;if(cursor.head==lineStart||cursor.head==lineStart+line.length)return;let before=this.coordsAt(cursor.head,-1),after=this.coordsAt(cursor.head,1);if(!before||!after||before.bottom>after.top)return;let dom=this.domAtPos(cursor.head+cursor.assoc);sel.collapse(dom.node,dom.offset);sel.modify("move",cursor.assoc<0?"forward":"backward","lineboundary");view.observer.readSelectionRange();let newRange=view.observer.selectionRange;if(view.docView.posFromDOM(newRange.anchorNode,newRange.anchorOffset)!=cursor.from)sel.collapse(anchorNode,anchorOffset);}nearest(dom){for(let cur=dom;cur;){let domView=ContentView.get(cur);if(domView&&domView.rootView==this)return domView;cur=cur.parentNode;}return null;}posFromDOM(node,offset){let view=this.nearest(node);if(!view)throw new RangeError("Trying to find position for a DOM position outside of the document");return view.localPosFromDOM(node,offset)+view.posAtStart;}domAtPos(pos){let{i,off}=this.childCursor().findPos(pos,-1);for(;istart||pos==start&&child.type!=BlockType.WidgetBefore&&child.type!=BlockType.WidgetAfter&&(!i||side==2||this.children[i-1].breakAfter||this.children[i-1].type==BlockType.WidgetBefore&&side>-2))return child.coordsAt(pos-start,side);off=start;}}coordsForChar(pos){let{i,off}=this.childPos(pos,1),child=this.children[i];if(!(child instanceof LineView))return null;while(child.children.length){let{i,off:childOff}=child.childPos(off,1);for(;;i++){if(i==child.children.length)return null;if((child=child.children[i]).length)break;}off=childOff;}if(!(child instanceof TextView))return null;let end=findClusterBreak(child.text,off);if(end==off)return null;let rects=textRange(child.dom,off,end).getClientRects();return!rects.length||rects[0].top>=rects[0].bottom?null:rects[0];}measureVisibleLineHeights(viewport){let result=[],{from,to}=viewport;let contentWidth=this.view.contentDOM.clientWidth;let isWider=contentWidth>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1;let widest=-1,ltr=this.view.textDirection==Direction.LTR;for(let pos=0,i=0;ito)break;if(pos>=from){let childRect=child.dom.getBoundingClientRect();result.push(childRect.height);if(isWider){let last=child.dom.lastChild;let rects=last?clientRectsFor(last):[];if(rects.length){let rect=rects[rects.length-1];let width=ltr?rect.right-childRect.left:childRect.right-rect.left;if(width>widest){widest=width;this.minWidth=contentWidth;this.minWidthFrom=pos;this.minWidthTo=end;}}}}pos=end+child.breakAfter;}return result;}textDirectionAt(pos){let{i}=this.childPos(pos,1);return getComputedStyle(this.children[i].dom).direction=="rtl"?Direction.RTL:Direction.LTR;}measureTextSize(){for(let _i53=0,_this$children8=this.children,_length53=_this$children8.length;_i53<_length53;_i53++){let child=_this$children8[_i53];if(child instanceof LineView){let measure=child.measureTextSize();if(measure)return measure;}}let dummy=document.createElement("div"),lineHeight,charWidth,textHeight;dummy.className="cm-line";dummy.style.width="99999px";dummy.style.position="absolute";dummy.textContent="abc def ghi jkl mno pqr stu";this.view.observer.ignore(()=>{this.dom.appendChild(dummy);let rect=clientRectsFor(dummy.firstChild)[0];lineHeight=dummy.getBoundingClientRect().height;charWidth=rect?rect.width/27:7;textHeight=rect?rect.height:lineHeight;dummy.remove();});return{lineHeight,charWidth,textHeight};}childCursor(pos=this.length){let i=this.children.length;if(i)pos-=this.children[--i].length;return new ChildCursor(this.children,pos,i);}computeBlockGapDeco(){let deco=[],vs=this.view.viewState;for(let pos=0,i=0;;i++){let next=i==vs.viewports.length?null:vs.viewports[i];let end=next?next.from-1:this.length;if(end>pos){let height=vs.lineBlockAt(end).bottom-vs.lineBlockAt(pos).top;deco.push(Decoration.replace({widget:new BlockGapWidget(height),block:true,inclusive:true,isBlockGap:true}).range(pos,end));}if(!next)break;pos=next.to+1;}return Decoration.set(deco);}updateDeco(){let allDeco=this.view.state.facet(decorations).map((d,i)=>{let dynamic=this.dynamicDecorationMap[i]=typeof d=="function";return dynamic?d(this.view):d;});for(let i=allDeco.length;irange.anchor?-1:1),other;if(!rect)return;if(!range.empty&&(other=this.coordsAt(range.anchor,range.anchor>range.head?-1:1)))rect={left:Math.min(rect.left,other.left),top:Math.min(rect.top,other.top),right:Math.max(rect.right,other.right),bottom:Math.max(rect.bottom,other.bottom)};let margins=getScrollMargins(this.view);let targetRect={left:rect.left-margins.left,top:rect.top-margins.top,right:rect.right+margins.right,bottom:rect.bottom+margins.bottom};scrollRectIntoView(this.view.scrollDOM,targetRect,range.head-1)return null;offset+=reader.text.length;}node=node.parentNode;if(!node)return null;let parentView=ContentView.get(node);if(parentView){from=to=parentView.posAtStart+offset;break;}}}return{from,to,node:textNode};}function findCompositionRange(view,changes){let found=findCompositionNode(view);if(!found)return null;let{from:fromA,to:toA,node:textNode}=found;let fromB=changes.mapPos(fromA,-1),toB=changes.mapPos(toA,1);let text=textNode.nodeValue;if(/[\n\r]/.test(text))return null;if(toB-fromB!=text.length){let fromB2=changes.mapPos(fromA,1),toB2=changes.mapPos(toA,-1);if(toB2-fromB2==text.length)fromB=fromB2,toB=toB2;else if(view.state.doc.sliceString(toB-text.length,toB)==text)fromB=toB-text.length;else if(view.state.doc.sliceString(fromB,fromB+text.length)==text)toB=fromB+text.length;else return null;}let{main}=view.state.selection;if(view.state.doc.sliceString(fromB,toB)!=text||fromB>main.head||toB0){node=node.childNodes[offset-1];offset=maxOffset(node);}else{break;}}if(side>=0)for(let node=startNode,offset=startOffset;;){if(node.nodeType==3)return node;if(node.nodeType==1&&offset=0){node=node.childNodes[offset];offset=0;}else{break;}}return null;}function nextToUneditable(node,offset){if(node.nodeType!=1)return 0;return(offset&&node.childNodes[offset-1].contentEditable=="false"?1:0)|(offset0){let prev=findClusterBreak(line.text,from,false);if(categorize(line.text.slice(prev,from))!=cat)break;from=prev;}while(tox?rect.left-x:Math.max(0,x-rect.right);}function getdy(y,rect){return rect.top>y?rect.top-y:Math.max(0,y-rect.bottom);}function yOverlap(a,b){return a.topb.top+1;}function upTop(rect,top){return toprect.bottom?{top:rect.top,left:rect.left,right:rect.right,bottom}:rect;}function domPosAtCoords(parent,x,y){let closest,closestRect,closestX,closestY,closestOverlap=false;let above,below,aboveRect,belowRect;for(let child=parent.firstChild;child;child=child.nextSibling){let rects=clientRectsFor(child);for(let i=0;idy||closestY==dy&&closestX>dx){closest=child;closestRect=rect;closestX=dx;closestY=dy;let side=dy?y0?i0);}if(dx==0){if(y>rect.bottom&&(!aboveRect||aboveRect.bottomrect.top)){below=child;belowRect=rect;}}else if(aboveRect&&yOverlap(aboveRect,rect)){aboveRect=upBot(aboveRect,rect.bottom);}else if(belowRect&&yOverlap(belowRect,rect)){belowRect=upTop(belowRect,rect.top);}}}if(aboveRect&&aboveRect.bottom>=y){closest=above;closestRect=aboveRect;}else if(belowRect&&belowRect.top<=y){closest=below;closestRect=belowRect;}if(!closest)return{node:parent,offset:0};let clipX=Math.max(closestRect.left,Math.min(closestRect.right,x));if(closest.nodeType==3)return domPosInText(closest,clipX,y);if(closestOverlap&&closest.contentEditable!="false")return domPosAtCoords(closest,clipX,y);let offset=Array.prototype.indexOf.call(parent.childNodes,closest)+(x>=(closestRect.left+closestRect.right)/2?1:0);return{node:parent,offset};}function domPosInText(node,x,y){let len=node.nodeValue.length;let closestOffset=-1,closestDY=1e9,generalSide=0;for(let i=0;iy?rect.top-y:y-rect.bottom)-1;if(rect.left-1<=x&&rect.right+1>=x&&dy=(rect.left+rect.right)/2,after=right;if(browser.chrome||browser.gecko){let rectBefore=textRange(node,i).getBoundingClientRect();if(rectBefore.left==rect.right)after=!right;}if(dy<=0)return{node,offset:i+(after?1:0)};closestOffset=i+(after?1:0);closestDY=dy;}}}return{node,offset:closestOffset>-1?closestOffset:generalSide>0?node.nodeValue.length:0};}function posAtCoords(view,coords,precise,bias=-1){var _a,_b;let content=view.contentDOM.getBoundingClientRect(),docTop=content.top+view.viewState.paddingTop;let block,{docHeight}=view.viewState;let{x,y}=coords,yOffset=y-docTop;if(yOffset<0)return 0;if(yOffset>docHeight)return view.state.doc.length;for(let halfLine=view.viewState.heightOracle.textHeight/2,bounced=false;;){block=view.elementAtHeight(yOffset);if(block.type==BlockType.Text)break;for(;;){yOffset=bias>0?block.bottom+halfLine:block.top-halfLine;if(yOffset>=0&&yOffset<=docHeight)break;if(bounced)return precise?null:0;bounced=true;bias=-bias;}}y=docTop+yOffset;let lineStart=block.from;if(lineStartview.viewport.to)return view.viewport.to==view.state.doc.length?view.state.doc.length:precise?null:posAtCoordsImprecise(view,content,block,x,y);let doc=view.dom.ownerDocument;let root=view.root.elementFromPoint?view.root:doc;let element=root.elementFromPoint(x,y);if(element&&!view.contentDOM.contains(element))element=null;if(!element){x=Math.max(content.left+1,Math.min(content.right-1,x));element=root.elementFromPoint(x,y);if(element&&!view.contentDOM.contains(element))element=null;}let node,offset=-1;if(element&&((_a=view.docView.nearest(element))===null||_a===void 0?void 0:_a.isEditable)!=false){if(doc.caretPositionFromPoint){let pos=doc.caretPositionFromPoint(x,y);if(pos)({offsetNode:node,offset}=pos);}else if(doc.caretRangeFromPoint){let range=doc.caretRangeFromPoint(x,y);if(range){({startContainer:node,startOffset:offset}=range);if(!view.contentDOM.contains(node)||browser.safari&&isSuspiciousSafariCaretResult(node,offset,x)||browser.chrome&&isSuspiciousChromeCaretResult(node,offset,x))node=undefined;}}}if(!node||!view.docView.dom.contains(node)){let line=LineView.find(view.docView,lineStart);if(!line)return yOffset>block.top+block.height/2?block.to:block.from;({node,offset}=domPosAtCoords(line.dom,x,y));}let nearest=view.docView.nearest(node);if(!nearest)return null;if(nearest.isWidget&&((_b=nearest.dom)===null||_b===void 0?void 0:_b.nodeType)==1){let rect=nearest.dom.getBoundingClientRect();return coords.yview.defaultLineHeight*1.5){let textHeight=view.viewState.heightOracle.textHeight;let line=Math.floor((y-block.top-(view.defaultLineHeight-textHeight)*0.5)/textHeight);into+=line*view.viewState.heightOracle.lineLength;}let content=view.state.sliceDoc(block.from,block.to);return block.from+findColumn(content,into,view.state.tabSize);}function isSuspiciousSafariCaretResult(node,offset,x){let len;if(node.nodeType!=3||offset!=(len=node.nodeValue.length))return false;for(let next=node.nextSibling;next;next=next.nextSibling)if(next.nodeType!=1||next.nodeName!="BR")return false;return textRange(node,len-1,len).getBoundingClientRect().left>x;}function isSuspiciousChromeCaretResult(node,offset,x){if(offset!=0)return false;for(let cur=node;;){let parent=cur.parentNode;if(!parent||parent.nodeType!=1||parent.firstChild!=cur)return false;if(parent.classList.contains("cm-line"))break;cur=parent;}let rect=node.nodeType==1?node.getBoundingClientRect():textRange(node,0,Math.max(node.nodeValue.length,1)).getBoundingClientRect();return x-rect.left>5;}function blockAt(view,pos){let line=view.lineBlockAt(pos);if(Array.isArray(line.type))for(let _i54=0,_line$type=line.type,_length54=_line$type.length;_i54<_length54;_i54++){let l=_line$type[_i54];if(l.to>pos||l.to==pos&&(l.to==line.to||l.type==BlockType.Text))return l;}return line;}function moveToLineBoundary(view,start,forward,includeWrap){let line=blockAt(view,start.head);let coords=!includeWrap||line.type!=BlockType.Text||!(view.lineWrapping||line.widgetLineBreaks)?null:view.coordsAtPos(start.assoc<0&&start.head>line.from?start.head-1:start.head);if(coords){let editorRect=view.dom.getBoundingClientRect();let direction=view.textDirectionAt(line.from);let pos=view.posAtCoords({x:forward==(direction==Direction.LTR)?editorRect.right-1:editorRect.left+1,y:(coords.top+coords.bottom)/2});if(pos!=null)return EditorSelection.cursor(pos,forward?-1:1);}return EditorSelection.cursor(forward?line.to:line.from,forward?-1:1);}function moveByChar(view,start,forward,by){let line=view.state.doc.lineAt(start.head),spans=view.bidiSpans(line);let direction=view.textDirectionAt(line.from);for(let cur=start,check=null;;){let next=moveVisually(line,spans,direction,cur,forward),char=movedOver;if(!next){if(line.number==(forward?view.state.doc.lines:1))return cur;char="\n";line=view.state.doc.line(line.number+(forward?1:-1));spans=view.bidiSpans(line);next=EditorSelection.cursor(forward?line.from:line.to);}if(!check){if(!by)return next;check=by(char);}else if(!check(char)){return cur;}cur=next;}}function byGroup(view,pos,start){let categorize=view.state.charCategorizer(pos);let cat=categorize(start);return next=>{let nextCat=categorize(next);if(cat==CharCategory.Space)cat=nextCat;return cat==nextCat;};}function moveVertically(view,start,forward,distance){let startPos=start.head,dir=forward?1:-1;if(startPos==(forward?view.state.doc.length:0))return EditorSelection.cursor(startPos,start.assoc);let goal=start.goalColumn,startY;let rect=view.contentDOM.getBoundingClientRect();let startCoords=view.coordsAtPos(startPos),docTop=view.documentTop;if(startCoords){if(goal==null)goal=startCoords.left-rect.left;startY=dir<0?startCoords.top:startCoords.bottom;}else{let line=view.viewState.lineBlockAt(startPos);if(goal==null)goal=Math.min(rect.right-rect.left,view.defaultCharacterWidth*(startPos-line.from));startY=(dir<0?line.top:line.bottom)+docTop;}let resolvedGoal=rect.left+goal;let dist=distance!==null&&distance!==void 0?distance:view.viewState.heightOracle.textHeight>>1;for(let extra=0;;extra+=10){let curY=startY+(dist+extra)*dir;let pos=posAtCoords(view,{x:resolvedGoal,y:curY},false,dir);if(curYrect.bottom||(dir<0?posstartPos))return EditorSelection.cursor(pos,start.assoc,undefined,goal);}}function skipAtomicRanges(atoms,pos,bias){for(;;){let moved=0;for(let _i55=0,_length55=atoms.length;_i55<_length55;_i55++){let set=atoms[_i55];set.between(pos-1,pos+1,(from,to,value)=>{if(pos>from&&posf(view)),pos.from,oldPos.head>pos.from?-1:1);return newPos==pos.from?pos:EditorSelection.cursor(newPos,newPos{if(this.ignoreDuringComposition(event))return;if(event.type=="keydown"&&this.keydown(view,event))return;if(this.mustFlushObserver(event))view.observer.forceFlush();if(this.runCustomHandlers(event.type,view,event))event.preventDefault();else handler(view,event);};for(let type in handlers){let handler=handlers[type];view.contentDOM.addEventListener(type,event=>{if(eventBelongsToEditor(view,event))handleEvent(handler,event);},handlerOptions[type]);this.registeredEvents.push(type);}view.scrollDOM.addEventListener("mousedown",event=>{if(event.target==view.scrollDOM&&event.clientY>view.contentDOM.getBoundingClientRect().bottom){handleEvent(handlers.mousedown,event);if(!event.defaultPrevented&&event.button==2){let start=view.contentDOM.style.minHeight;view.contentDOM.style.minHeight="100%";setTimeout(()=>view.contentDOM.style.minHeight=start,200);}}});view.scrollDOM.addEventListener("drop",event=>{if(event.target==view.scrollDOM&&event.clientY>view.contentDOM.getBoundingClientRect().bottom)handleEvent(handlers.drop,event);});if(browser.chrome&&browser.chrome_version==102){view.scrollDOM.addEventListener("wheel",()=>{if(this.chromeScrollHack<0)view.contentDOM.style.pointerEvents="none";else window.clearTimeout(this.chromeScrollHack);this.chromeScrollHack=setTimeout(()=>{this.chromeScrollHack=-1;view.contentDOM.style.pointerEvents="";},100);},{passive:true});}this.notifiedFocused=view.hasFocus;if(browser.safari)view.contentDOM.addEventListener("input",()=>null);}ensureHandlers(view,plugins){var _a;let handlers;this.customHandlers=[];for(let _i56=0,_length56=plugins.length;_i56<_length56;_i56++){let plugin=plugins[_i56];if(handlers=(_a=plugin.update(view).spec)===null||_a===void 0?void 0:_a.domEventHandlers){this.customHandlers.push({plugin:plugin.value,handlers});for(let type in handlers)if(this.registeredEvents.indexOf(type)<0&&type!="scroll"){this.registeredEvents.push(type);view.contentDOM.addEventListener(type,event=>{if(!eventBelongsToEditor(view,event))return;if(this.runCustomHandlers(type,view,event))event.preventDefault();});}}}}runCustomHandlers(type,view,event){for(let _i57=0,_this$customHandlers=this.customHandlers,_length57=_this$customHandlers.length;_i57<_length57;_i57++){let set=_this$customHandlers[_i57];let handler=set.handlers[type];if(handler){try{if(handler.call(set.plugin,event,view)||event.defaultPrevented)return true;}catch(e){logException(view.state,e);}}}return false;}runScrollHandlers(view,event){this.lastScrollTop=view.scrollDOM.scrollTop;this.lastScrollLeft=view.scrollDOM.scrollLeft;for(let _i58=0,_this$customHandlers2=this.customHandlers,_length58=_this$customHandlers2.length;_i58<_length58;_i58++){let set=_this$customHandlers2[_i58];let handler=set.handlers.scroll;if(handler){try{handler.call(set.plugin,event,view);}catch(e){logException(view.state,e);}}}}keydown(view,event){this.lastKeyCode=event.keyCode;this.lastKeyTime=Date.now();if(event.keyCode==9&&Date.now()key.keyCode==event.keyCode))&&!event.ctrlKey||EmacsyPendingKeys.indexOf(event.key)>-1&&event.ctrlKey&&!event.shiftKey)){this.pendingIOSKey=pending||event;setTimeout(()=>this.flushIOSKey(view),250);return true;}return false;}flushIOSKey(view){let key=this.pendingIOSKey;if(!key)return false;this.pendingIOSKey=undefined;return dispatchKey(view.contentDOM,key.key,key.keyCode);}ignoreDuringComposition(event){if(!/^key/.test(event.type))return false;if(this.composing>0)return true;if(browser.safari&&!browser.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100){this.compositionPendingKey=false;return true;}return false;}mustFlushObserver(event){return event.type=="keydown"&&event.keyCode!=229;}startMouseSelection(mouseSelection){if(this.mouseSelection)this.mouseSelection.destroy();this.mouseSelection=mouseSelection;}update(update){if(this.mouseSelection)this.mouseSelection.update(update);if(update.transactions.length)this.lastKeyCode=this.lastSelectionTime=0;}destroy(){if(this.mouseSelection)this.mouseSelection.destroy();}}const PendingKeys=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}];const EmacsyPendingKeys="dthko";const modifierCodes=[16,17,18,20,91,92,224,225];const dragScrollMargin=6;function dragScrollSpeed(dist){return Math.max(0,dist)*0.7+8;}function dist(a,b){return Math.max(Math.abs(a.clientX-b.clientX),Math.abs(a.clientY-b.clientY));}class MouseSelection{constructor(view,startEvent,style,mustSelect){this.view=view;this.startEvent=startEvent;this.style=style;this.mustSelect=mustSelect;this.scrollSpeed={x:0,y:0};this.scrolling=-1;this.lastEvent=startEvent;this.scrollParent=scrollableParent(view.contentDOM);this.atoms=view.state.facet(atomicRanges).map(f=>f(view));let doc=view.contentDOM.ownerDocument;doc.addEventListener("mousemove",this.move=this.move.bind(this));doc.addEventListener("mouseup",this.up=this.up.bind(this));this.extend=startEvent.shiftKey;this.multiple=view.state.facet(EditorState.allowMultipleSelections)&&addsSelectionRange(view,startEvent);this.dragging=isInPrimarySelection(view,startEvent)&&getClickType(startEvent)==1?null:false;}start(event){if(this.dragging===false){event.preventDefault();this.select(event);}}move(event){var _a;if(event.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&dist(this.startEvent,event)<10)return;this.select(this.lastEvent=event);let sx=0,sy=0;let rect=((_a=this.scrollParent)===null||_a===void 0?void 0:_a.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight};let margins=getScrollMargins(this.view);if(event.clientX-margins.left<=rect.left+dragScrollMargin)sx=-dragScrollSpeed(rect.left-event.clientX);else if(event.clientX+margins.right>=rect.right-dragScrollMargin)sx=dragScrollSpeed(event.clientX-rect.right);if(event.clientY-margins.top<=rect.top+dragScrollMargin)sy=-dragScrollSpeed(rect.top-event.clientY);else if(event.clientY+margins.bottom>=rect.bottom-dragScrollMargin)sy=dragScrollSpeed(event.clientY-rect.bottom);this.setScrollSpeed(sx,sy);}up(event){if(this.dragging==null)this.select(this.lastEvent);if(!this.dragging)event.preventDefault();this.destroy();}destroy(){this.setScrollSpeed(0,0);let doc=this.view.contentDOM.ownerDocument;doc.removeEventListener("mousemove",this.move);doc.removeEventListener("mouseup",this.up);this.view.inputState.mouseSelection=null;}setScrollSpeed(sx,sy){this.scrollSpeed={x:sx,y:sy};if(sx||sy){if(this.scrolling<0)this.scrolling=setInterval(()=>this.scroll(),50);}else if(this.scrolling>-1){clearInterval(this.scrolling);this.scrolling=-1;}}scroll(){if(this.scrollParent){this.scrollParent.scrollLeft+=this.scrollSpeed.x;this.scrollParent.scrollTop+=this.scrollSpeed.y;}else{this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y);}if(this.dragging===false)this.select(this.lastEvent);}skipAtoms(sel){let ranges=null;for(let i=0;ithis.select(this.lastEvent),20);}}function addsSelectionRange(view,event){let facet=view.state.facet(clickAddsSelectionRange);return facet.length?facet[0](event):browser.mac?event.metaKey:event.ctrlKey;}function dragMovesSelection(view,event){let facet=view.state.facet(dragMovesSelection$1);return facet.length?facet[0](event):browser.mac?!event.altKey:!event.ctrlKey;}function isInPrimarySelection(view,event){let{main}=view.state.selection;if(main.empty)return false;let sel=getSelection(view.root);if(!sel||sel.rangeCount==0)return true;let rects=sel.getRangeAt(0).getClientRects();for(let i=0;i=event.clientX&&rect.top<=event.clientY&&rect.bottom>=event.clientY)return true;}return false;}function eventBelongsToEditor(view,event){if(!event.bubbles)return true;if(event.defaultPrevented)return false;for(let node=event.target,cView;node!=view.contentDOM;node=node.parentNode)if(!node||node.nodeType==11||(cView=ContentView.get(node))&&cView.ignoreEvent(event))return false;return true;}const handlers=Object.create(null);const handlerOptions=Object.create(null);const brokenClipboardAPI=browser.ie&&browser.ie_version<15||browser.ios&&browser.webkit_version<604;function capturePaste(view){let parent=view.dom.parentNode;if(!parent)return;let target=parent.appendChild(document.createElement("textarea"));target.style.cssText="position: fixed; left: -10000px; top: 10px";target.focus();setTimeout(()=>{view.focus();target.remove();doPaste(view,target.value);},50);}function doPaste(view,input){let{state}=view,changes,i=1,text=state.toText(input);let byLine=text.lines==state.selection.ranges.length;let linewise=lastLinewiseCopy!=null&&state.selection.ranges.every(r=>r.empty)&&lastLinewiseCopy==text.toString();if(linewise){let lastLine=-1;changes=state.changeByRange(range=>{let line=state.doc.lineAt(range.from);if(line.from==lastLine)return{range};lastLine=line.from;let insert=state.toText((byLine?text.line(i++).text:input)+state.lineBreak);return{changes:{from:line.from,insert},range:EditorSelection.cursor(range.from+insert.length)};});}else if(byLine){changes=state.changeByRange(range=>{let line=text.line(i++);return{changes:{from:range.from,to:range.to,insert:line.text},range:EditorSelection.cursor(range.from+line.length)};});}else{changes=state.replaceSelection(text);}view.dispatch(changes,{userEvent:"input.paste",scrollIntoView:true});}handlers.keydown=(view,event)=>{view.inputState.setSelectionOrigin("select");if(event.keyCode==27)view.inputState.lastEscPress=Date.now();};handlers.touchstart=(view,e)=>{view.inputState.lastTouchTime=Date.now();view.inputState.setSelectionOrigin("select.pointer");};handlers.touchmove=view=>{view.inputState.setSelectionOrigin("select.pointer");};handlerOptions.touchstart=handlerOptions.touchmove={passive:true};handlers.mousedown=(view,event)=>{view.observer.flush();if(view.inputState.lastTouchTime>Date.now()-2000)return;let style=null;for(let _i59=0,_view$state$facet2=view.state.facet(mouseSelectionStyle),_length59=_view$state$facet2.length;_i59<_length59;_i59++){let makeStyle=_view$state$facet2[_i59];style=makeStyle(view,event);if(style)break;}if(!style&&event.button==0)style=basicMouseSelection(view,event);if(style){let mustFocus=!view.hasFocus;view.inputState.startMouseSelection(new MouseSelection(view,event,style,mustFocus));if(mustFocus)view.observer.ignore(()=>focusPreventScroll(view.contentDOM));if(view.inputState.mouseSelection)view.inputState.mouseSelection.start(event);}};function rangeForClick(view,pos,bias,type){if(type==1){return EditorSelection.cursor(pos,bias);}else if(type==2){return groupAt(view.state,pos,bias);}else{let visual=LineView.find(view.docView,pos),line=view.state.doc.lineAt(visual?visual.posAtEnd:pos);let from=visual?visual.posAtStart:line.from,to=visual?visual.posAtEnd:line.to;if(toy>=rect.top&&y<=rect.bottom;let inside=(x,y,rect)=>insideY(y,rect)&&x>=rect.left&&x<=rect.right;function findPositionSide(view,pos,x,y){let line=LineView.find(view.docView,pos);if(!line)return 1;let off=pos-line.posAtStart;if(off==0)return 1;if(off==line.length)return-1;let before=line.coordsAt(off,-1);if(before&&inside(x,y,before))return-1;let after=line.coordsAt(off,1);if(after&&inside(x,y,after))return 1;return before&&insideY(y,before)?-1:1;}function queryPos(view,event){let pos=view.posAtCoords({x:event.clientX,y:event.clientY},false);return{pos,bias:findPositionSide(view,pos,event.clientX,event.clientY)};}const BadMouseDetail=browser.ie&&browser.ie_version<=11;let lastMouseDown=null,lastMouseDownCount=0,lastMouseDownTime=0;function getClickType(event){if(!BadMouseDetail)return event.detail;let last=lastMouseDown,lastTime=lastMouseDownTime;lastMouseDown=event;lastMouseDownTime=Date.now();return lastMouseDownCount=!last||lastTime>Date.now()-400&&Math.abs(last.clientX-event.clientX)<2&&Math.abs(last.clientY-event.clientY)<2?(lastMouseDownCount+1)%3:1;}function basicMouseSelection(view,event){let start=queryPos(view,event),type=getClickType(event);let startSel=view.state.selection;return{update(update){if(update.docChanged){start.pos=update.changes.mapPos(start.pos);startSel=startSel.map(update.changes);}},get(event,extend,multiple){let cur=queryPos(view,event),removed;let range=rangeForClick(view,cur.pos,cur.bias,type);if(start.pos!=cur.pos&&!extend){let startRange=rangeForClick(view,start.pos,start.bias,type);let from=Math.min(startRange.from,range.from),to=Math.max(startRange.to,range.to);range=from1&&(removed=removeRangeAround(startSel,cur.pos)))return removed;else if(multiple)return startSel.addRange(range);else return EditorSelection.create([range]);}};}function removeRangeAround(sel,pos){for(let i=0;i=pos)return EditorSelection.create(sel.ranges.slice(0,i).concat(sel.ranges.slice(i+1)),sel.mainIndex==i?0:sel.mainIndex-(sel.mainIndex>i?1:0));}return null;}handlers.dragstart=(view,event)=>{let{selection:{main}}=view.state;let{mouseSelection}=view.inputState;if(mouseSelection)mouseSelection.dragging=main;if(event.dataTransfer){event.dataTransfer.setData("Text",view.state.sliceDoc(main.from,main.to));event.dataTransfer.effectAllowed="copyMove";}};function dropText(view,event,text,direct){if(!text)return;let dropPos=view.posAtCoords({x:event.clientX,y:event.clientY},false);event.preventDefault();let{mouseSelection}=view.inputState;let del=direct&&mouseSelection&&mouseSelection.dragging&&dragMovesSelection(view,event)?{from:mouseSelection.dragging.from,to:mouseSelection.dragging.to}:null;let ins={from:dropPos,insert:text};let changes=view.state.changes(del?[del,ins]:ins);view.focus();view.dispatch({changes,selection:{anchor:changes.mapPos(dropPos,-1),head:changes.mapPos(dropPos,1)},userEvent:del?"move.drop":"input.drop"});}handlers.drop=(view,event)=>{if(!event.dataTransfer)return;if(view.state.readOnly)return event.preventDefault();let files=event.dataTransfer.files;if(files&&files.length){event.preventDefault();let text=Array(files.length),read=0;let finishFile=()=>{if(++read==files.length)dropText(view,event,text.filter(s=>s!=null).join(view.state.lineBreak),false);};for(let i=0;i{if(!/[\x00-\x08\x0e-\x1f]{2}/.test(reader.result))text[i]=reader.result;finishFile();};reader.readAsText(files[i]);}}else{dropText(view,event,event.dataTransfer.getData("Text"),true);}};handlers.paste=(view,event)=>{if(view.state.readOnly)return event.preventDefault();view.observer.flush();let data=brokenClipboardAPI?null:event.clipboardData;if(data){doPaste(view,data.getData("text/plain")||data.getData("text/uri-text"));event.preventDefault();}else{capturePaste(view);}};function captureCopy(view,text){let parent=view.dom.parentNode;if(!parent)return;let target=parent.appendChild(document.createElement("textarea"));target.style.cssText="position: fixed; left: -10000px; top: 10px";target.value=text;target.focus();target.selectionEnd=text.length;target.selectionStart=0;setTimeout(()=>{target.remove();view.focus();},50);}function copiedRange(state){let content=[],ranges=[],linewise=false;for(let _i60=0,_state$selection$rang=state.selection.ranges,_length60=_state$selection$rang.length;_i60<_length60;_i60++){let range=_state$selection$rang[_i60];if(!range.empty){content.push(state.sliceDoc(range.from,range.to));ranges.push(range);}}if(!content.length){let upto=-1;for(let _i61=0,_state$selection$rang2=state.selection.ranges,_length61=_state$selection$rang2.length;_i61<_length61;_i61++){let{from}=_state$selection$rang2[_i61];let line=state.doc.lineAt(from);if(line.number>upto){content.push(line.text);ranges.push({from:line.from,to:Math.min(state.doc.length,line.to+1)});}upto=line.number;}linewise=true;}return{text:content.join(state.lineBreak),ranges,linewise};}let lastLinewiseCopy=null;handlers.copy=handlers.cut=(view,event)=>{let{text,ranges,linewise}=copiedRange(view.state);if(!text&&!linewise)return;lastLinewiseCopy=linewise?text:null;let data=brokenClipboardAPI?null:event.clipboardData;if(data){event.preventDefault();data.clearData();data.setData("text/plain",text);}else{captureCopy(view,text);}if(event.type=="cut"&&!view.state.readOnly)view.dispatch({changes:ranges,scrollIntoView:true,userEvent:"delete.cut"});};const isFocusChange=Annotation.define();function focusChangeTransaction(state,focus){let effects=[];for(let _i62=0,_state$facet2=state.facet(focusChangeEffect),_length62=_state$facet2.length;_i62<_length62;_i62++){let getEffect=_state$facet2[_i62];let effect=getEffect(state,focus);if(effect)effects.push(effect);}return effects?state.update({effects,annotations:isFocusChange.of(true)}):null;}function updateForFocusChange(view){setTimeout(()=>{let focus=view.hasFocus;if(focus!=view.inputState.notifiedFocused){let tr=focusChangeTransaction(view.state,focus);if(tr)view.dispatch(tr);else view.update([]);}},10);}handlers.focus=view=>{view.inputState.lastFocusTime=Date.now();if(!view.scrollDOM.scrollTop&&(view.inputState.lastScrollTop||view.inputState.lastScrollLeft)){view.scrollDOM.scrollTop=view.inputState.lastScrollTop;view.scrollDOM.scrollLeft=view.inputState.lastScrollLeft;}updateForFocusChange(view);};handlers.blur=view=>{view.observer.clearSelectionRange();updateForFocusChange(view);};handlers.compositionstart=handlers.compositionupdate=view=>{if(view.inputState.compositionFirstChange==null)view.inputState.compositionFirstChange=true;if(view.inputState.composing<0){view.inputState.composing=0;}};handlers.compositionend=view=>{view.inputState.composing=-1;view.inputState.compositionEndedAt=Date.now();view.inputState.compositionPendingKey=true;view.inputState.compositionPendingChange=view.observer.pendingRecords().length>0;view.inputState.compositionFirstChange=null;if(browser.chrome&&browser.android){view.observer.flushSoon();}else if(view.inputState.compositionPendingChange){Promise.resolve().then(()=>view.observer.flush());}else{setTimeout(()=>{if(view.inputState.composing<0&&view.docView.hasComposition)view.update([]);},50);}};handlers.contextmenu=view=>{view.inputState.lastContextMenu=Date.now();};handlers.beforeinput=(view,event)=>{var _a;let pending;if(browser.chrome&&browser.android&&(pending=PendingKeys.find(key=>key.inputType==event.inputType))){view.observer.delayAndroidKey(pending.key,pending.keyCode);if(pending.key=="Backspace"||pending.key=="Delete"){let startViewHeight=((_a=window.visualViewport)===null||_a===void 0?void 0:_a.height)||0;setTimeout(()=>{var _a;if((((_a=window.visualViewport)===null||_a===void 0?void 0:_a.height)||0)>startViewHeight+10&&view.hasFocus){view.contentDOM.blur();view.focus();}},100);}}};const wrappingWhiteSpace=["pre-wrap","normal","pre-line","break-spaces"];class HeightOracle{constructor(lineWrapping){this.lineWrapping=lineWrapping;this.doc=Text$1.empty;this.heightSamples={};this.lineHeight=14;this.charWidth=7;this.textHeight=14;this.lineLength=30;this.heightChanged=false;}heightForGap(from,to){let lines=this.doc.lineAt(to).number-this.doc.lineAt(from).number+1;if(this.lineWrapping)lines+=Math.max(0,Math.ceil((to-from-lines*this.lineLength*0.5)/this.lineLength));return this.lineHeight*lines;}heightForLine(length){if(!this.lineWrapping)return this.lineHeight;let lines=1+Math.max(0,Math.ceil((length-this.lineLength)/(this.lineLength-5)));return lines*this.lineHeight;}setDoc(doc){this.doc=doc;return this;}mustRefreshForWrapping(whiteSpace){return wrappingWhiteSpace.indexOf(whiteSpace)>-1!=this.lineWrapping;}mustRefreshForHeights(lineHeights){let newHeight=false;for(let i=0;i-1;let changed=Math.round(lineHeight)!=Math.round(this.lineHeight)||this.lineWrapping!=lineWrapping;this.lineWrapping=lineWrapping;this.lineHeight=lineHeight;this.charWidth=charWidth;this.textHeight=textHeight;this.lineLength=lineLength;if(changed){this.heightSamples={};for(let i=0;i0;}set outdated(value){this.flags=(value?2:0)|this.flags&~2;}setHeight(oracle,height){if(this.height!=height){if(Math.abs(this.height-height)>Epsilon)oracle.heightChanged=true;this.height=height;}}replace(_from,_to,nodes){return HeightMap.of(nodes);}decomposeLeft(_to,result){result.push(this);}decomposeRight(_from,result){result.push(this);}applyChanges(decorations,oldDoc,oracle,changes){let me=this,doc=oracle.doc;for(let i=changes.length-1;i>=0;i--){let{fromA,toA,fromB,toB}=changes[i];let start=me.lineAt(fromA,QueryType$1.ByPosNoHeight,oracle.setDoc(oldDoc),0,0);let end=start.to>=toA?start:me.lineAt(toA,QueryType$1.ByPosNoHeight,oracle,0,0);toB+=end.to-toA;toA=end.to;while(i>0&&start.from<=changes[i-1].toA){fromA=changes[i-1].fromA;fromB=changes[i-1].fromB;i--;if(fromAafter*2){let split=nodes[i-1];if(split.break)nodes.splice(--i,1,split.left,null,split.right);else nodes.splice(--i,1,split.left,split.right);j+=1+split.break;before-=split.size;}else if(after>before*2){let split=nodes[j];if(split.break)nodes.splice(j,1,split.left,null,split.right);else nodes.splice(j,1,split.left,split.right);j+=2+split.break;after-=split.size;}else{break;}}else if(before=offset)f(this.blockAt(0,oracle,top,offset));}updateHeight(oracle,offset=0,_force=false,measured){if(measured&&measured.from<=offset&&measured.more)this.setHeight(oracle,measured.heights[measured.index++]);this.outdated=false;return this;}toString(){return`block(${this.length})`;}}class HeightMapText extends HeightMapBlock{constructor(length,height){super(length,height,null);this.collapsed=0;this.widgetHeight=0;this.breaks=0;}blockAt(_height,_oracle,top,offset){return new BlockInfo(offset,this.length,top,this.height,this.breaks);}replace(_from,_to,nodes){let node=nodes[0];if(nodes.length==1&&(node instanceof HeightMapText||node instanceof HeightMapGap&&node.flags&4)&&Math.abs(this.length-node.length)<10){if(node instanceof HeightMapGap)node=new HeightMapText(node.length,this.height);else node.height=this.height;if(!this.outdated)node.outdated=false;return node;}else{return HeightMap.of(nodes);}}updateHeight(oracle,offset=0,force=false,measured){if(measured&&measured.from<=offset&&measured.more)this.setHeight(oracle,measured.heights[measured.index++]);else if(force||this.outdated)this.setHeight(oracle,Math.max(this.widgetHeight,oracle.heightForLine(this.length-this.collapsed))+this.breaks*oracle.lineHeight);this.outdated=false;return this;}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`;}}class HeightMapGap extends HeightMap{constructor(length){super(length,0);}heightMetrics(oracle,offset){let firstLine=oracle.doc.lineAt(offset).number,lastLine=oracle.doc.lineAt(offset+this.length).number;let lines=lastLine-firstLine+1;let perLine,perChar=0;if(oracle.lineWrapping){let totalPerLine=Math.min(this.height,oracle.lineHeight*lines);perLine=totalPerLine/lines;if(this.length>lines+1)perChar=(this.height-totalPerLine)/(this.length-lines-1);}else{perLine=this.height/lines;}return{firstLine,lastLine,perLine,perChar};}blockAt(height,oracle,top,offset){let{firstLine,lastLine,perLine,perChar}=this.heightMetrics(oracle,offset);if(oracle.lineWrapping){let guess=offset+Math.round(Math.max(0,Math.min(1,(height-top)/this.height))*this.length);let line=oracle.doc.lineAt(guess),lineHeight=perLine+line.length*perChar;let lineTop=Math.max(top,height-lineHeight/2);return new BlockInfo(line.from,line.length,lineTop,lineHeight,0);}else{let line=Math.max(0,Math.min(lastLine-firstLine,Math.floor((height-top)/perLine)));let{from,length}=oracle.doc.line(firstLine+line);return new BlockInfo(from,length,top+perLine*line,perLine,0);}}lineAt(value,type,oracle,top,offset){if(type==QueryType$1.ByHeight)return this.blockAt(value,oracle,top,offset);if(type==QueryType$1.ByPosNoHeight){let{from,to}=oracle.doc.lineAt(value);return new BlockInfo(from,to-from,0,0,0);}let{firstLine,perLine,perChar}=this.heightMetrics(oracle,offset);let line=oracle.doc.lineAt(value),lineHeight=perLine+line.length*perChar;let linesAbove=line.number-firstLine;let lineTop=top+perLine*linesAbove+perChar*(line.from-offset-linesAbove);return new BlockInfo(line.from,line.length,Math.max(top,Math.min(lineTop,top+this.height-lineHeight)),lineHeight,0);}forEachLine(from,to,oracle,top,offset,f){from=Math.max(from,offset);to=Math.min(to,offset+this.length);let{firstLine,perLine,perChar}=this.heightMetrics(oracle,offset);for(let pos=from,lineTop=top;pos<=to;){let line=oracle.doc.lineAt(pos);if(pos==from){let linesAbove=line.number-firstLine;lineTop+=perLine*linesAbove+perChar*(from-offset-linesAbove);}let lineHeight=perLine+perChar*line.length;f(new BlockInfo(line.from,line.length,lineTop,lineHeight,0));lineTop+=lineHeight;pos=line.to+1;}}replace(from,to,nodes){let after=this.length-to;if(after>0){let last=nodes[nodes.length-1];if(last instanceof HeightMapGap)nodes[nodes.length-1]=new HeightMapGap(last.length+after);else nodes.push(null,new HeightMapGap(after-1));}if(from>0){let first=nodes[0];if(first instanceof HeightMapGap)nodes[0]=new HeightMapGap(from+first.length);else nodes.unshift(new HeightMapGap(from-1),null);}return HeightMap.of(nodes);}decomposeLeft(to,result){result.push(new HeightMapGap(to-1),null);}decomposeRight(from,result){result.push(null,new HeightMapGap(this.length-from-1));}updateHeight(oracle,offset=0,force=false,measured){let end=offset+this.length;if(measured&&measured.from<=offset+this.length&&measured.more){let nodes=[],pos=Math.max(offset,measured.from),singleHeight=-1;if(measured.from>offset)nodes.push(new HeightMapGap(measured.from-offset-1).updateHeight(oracle,offset));while(pos<=end&&measured.more){let len=oracle.doc.lineAt(pos).length;if(nodes.length)nodes.push(null);let height=measured.heights[measured.index++];if(singleHeight==-1)singleHeight=height;else if(Math.abs(height-singleHeight)>=Epsilon)singleHeight=-2;let line=new HeightMapText(len,height);line.outdated=false;nodes.push(line);pos+=len+1;}if(pos<=end)nodes.push(null,new HeightMapGap(end-pos).updateHeight(oracle,pos));let result=HeightMap.of(nodes);if(singleHeight<0||Math.abs(result.height-this.height)>=Epsilon||Math.abs(singleHeight-this.heightMetrics(oracle,offset).perLine)>=Epsilon)oracle.heightChanged=true;return result;}else if(force||this.outdated){this.setHeight(oracle,oracle.heightForGap(offset,offset+this.length));this.outdated=false;}return this;}toString(){return`gap(${this.length})`;}}class HeightMapBranch extends HeightMap{constructor(left,brk,right){super(left.length+brk+right.length,left.height+right.height,brk|(left.outdated||right.outdated?2:0));this.left=left;this.right=right;this.size=left.size+right.size;}get break(){return this.flags&1;}blockAt(height,oracle,top,offset){let mid=top+this.left.height;return heightrightOffset))return base;let subQuery=type==QueryType$1.ByPosNoHeight?QueryType$1.ByPosNoHeight:QueryType$1.ByPos;if(left)return base.join(this.right.lineAt(rightOffset,subQuery,oracle,rightTop,rightOffset));else return this.left.lineAt(rightOffset,subQuery,oracle,top,offset).join(base);}forEachLine(from,to,oracle,top,offset,f){let rightTop=top+this.left.height,rightOffset=offset+this.left.length+this.break;if(this.break){if(from=rightOffset)this.right.forEachLine(from,to,oracle,rightTop,rightOffset,f);}else{let mid=this.lineAt(rightOffset,QueryType$1.ByPos,oracle,top,offset);if(from=from&&mid.from<=to)f(mid);if(to>mid.to)this.right.forEachLine(mid.to+1,to,oracle,rightTop,rightOffset,f);}}replace(from,to,nodes){let rightStart=this.left.length+this.break;if(tothis.left.length)return this.balanced(this.left,this.right.replace(from-rightStart,to-rightStart,nodes));let result=[];if(from>0)this.decomposeLeft(from,result);let left=result.length;for(let _i63=0,_length63=nodes.length;_i63<_length63;_i63++){let node=nodes[_i63];result.push(node);}if(from>0)mergeGaps(result,left-1);if(to=left)result.push(null);}if(to>left)this.right.decomposeLeft(to-left,result);}decomposeRight(from,result){let left=this.left.length,right=left+this.break;if(from>=right)return this.right.decomposeRight(from-right,result);if(from2*right.size||right.size>2*left.size)return HeightMap.of(this.break?[left,null,right]:[left,right]);this.left=left;this.right=right;this.height=left.height+right.height;this.outdated=left.outdated||right.outdated;this.size=left.size+right.size;this.length=left.length+this.break+right.length;return this;}updateHeight(oracle,offset=0,force=false,measured){let{left,right}=this,rightStart=offset+left.length+this.break,rebalance=null;if(measured&&measured.from<=offset+left.length&&measured.more)rebalance=left=left.updateHeight(oracle,offset,force,measured);else left.updateHeight(oracle,offset,force);if(measured&&measured.from<=rightStart+right.length&&measured.more)rebalance=right=right.updateHeight(oracle,rightStart,force,measured);else right.updateHeight(oracle,rightStart,force);if(rebalance)return this.balanced(left,right);this.height=this.left.height+this.right.height;this.outdated=false;return this;}toString(){return this.left+(this.break?" ":"-")+this.right;}}function mergeGaps(nodes,around){let before,after;if(nodes[around]==null&&(before=nodes[around-1])instanceof HeightMapGap&&(after=nodes[around+1])instanceof HeightMapGap)nodes.splice(around-1,3,new HeightMapGap(before.length+1+after.length));}const relevantWidgetHeight=5;class NodeBuilder{constructor(pos,oracle){this.pos=pos;this.oracle=oracle;this.nodes=[];this.lineStart=-1;this.lineEnd=-1;this.covering=null;this.writtenTo=pos;}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering;}span(_from,to){if(this.lineStart>-1){let end=Math.min(to,this.lineEnd),last=this.nodes[this.nodes.length-1];if(last instanceof HeightMapText)last.length+=end-this.pos;else if(end>this.pos||!this.isCovered)this.nodes.push(new HeightMapText(end-this.pos,-1));this.writtenTo=end;if(to>end){this.nodes.push(null);this.writtenTo++;this.lineStart=-1;}}this.pos=to;}point(from,to,deco){if(from=relevantWidgetHeight){this.addLineDeco(height,breaks,len);}}else if(to>from){this.span(from,to);}if(this.lineEnd>-1&&this.lineEnd-1)return;let{from,to}=this.oracle.doc.lineAt(this.pos);this.lineStart=from;this.lineEnd=to;if(this.writtenTofrom)this.nodes.push(new HeightMapText(this.pos-from,-1));this.writtenTo=this.pos;}blankContent(from,to){let gap=new HeightMapGap(to-from);if(this.oracle.doc.lineAt(from).to==to)gap.flags|=4;return gap;}ensureLine(){this.enterLine();let last=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(last instanceof HeightMapText)return last;let line=new HeightMapText(0,-1);this.nodes.push(line);return line;}addBlock(block){var _a;this.enterLine();let type=(_a=block.deco)===null||_a===void 0?void 0:_a.type;if(type==BlockType.WidgetAfter&&!this.isCovered)this.ensureLine();this.nodes.push(block);this.writtenTo=this.pos=this.pos+block.length;if(type!=BlockType.WidgetBefore)this.covering=block;}addLineDeco(height,breaks,length){let line=this.ensureLine();line.length+=length;line.collapsed+=length;line.widgetHeight=Math.max(line.widgetHeight,height);line.breaks+=breaks;this.writtenTo=this.pos=this.pos+length;}finish(from){let last=this.nodes.length==0?null:this.nodes[this.nodes.length-1];if(this.lineStart>-1&&!(last instanceof HeightMapText)&&!this.isCovered)this.nodes.push(new HeightMapText(0,-1));else if(this.writtenToelt.clientHeight||elt.scrollWidth>elt.clientWidth)&&style.overflow!="visible"){let parentRect=elt.getBoundingClientRect();left=Math.max(left,parentRect.left);right=Math.min(right,parentRect.right);top=Math.max(top,parentRect.top);bottom=parent==dom.parentNode?parentRect.bottom:Math.min(bottom,parentRect.bottom);}parent=style.position=="absolute"||style.position=="fixed"?elt.offsetParent:elt.parentNode;}else if(parent.nodeType==11){parent=parent.host;}else{break;}}return{left:left-rect.left,right:Math.max(left,right)-rect.left,top:top-(rect.top+paddingTop),bottom:Math.max(top,bottom)-(rect.top+paddingTop)};}function fullPixelRange(dom,paddingTop){let rect=dom.getBoundingClientRect();return{left:0,right:rect.right-rect.left,top:paddingTop,bottom:rect.bottom-(rect.top+paddingTop)};}class LineGap{constructor(from,to,size){this.from=from;this.to=to;this.size=size;}static same(a,b){if(a.length!=b.length)return false;for(let i=0;itypeof v!="function"&&v.class=="cm-lineWrapping");this.heightOracle=new HeightOracle(guessWrapping);this.stateDeco=state.facet(decorations).filter(d=>typeof d!="function");this.heightMap=HeightMap.empty().applyChanges(this.stateDeco,Text$1.empty,this.heightOracle.setDoc(state.doc),[new ChangedRange(0,0,0,state.doc.length)]);this.viewport=this.getViewport(0,null);this.updateViewportLines();this.updateForViewport();this.lineGaps=this.ensureLineGaps([]);this.lineGapDeco=Decoration.set(this.lineGaps.map(gap=>gap.draw(false)));this.computeVisibleRanges();}updateForViewport(){let viewports=[this.viewport],{main}=this.state.selection;for(let i=0;i<=1;i++){let pos=i?main.head:main.anchor;if(!viewports.some(({from,to})=>pos>=from&&pos<=to)){let{from,to}=this.lineBlockAt(pos);viewports.push(new Viewport(from,to));}}this.viewports=viewports.sort((a,b)=>a.from-b.from);this.scaler=this.heightMap.height<=7000000?IdScaler:new BigScaler(this.heightOracle,this.heightMap,this.viewports);}updateViewportLines(){this.viewportLines=[];this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,block=>{this.viewportLines.push(this.scaler.scale==1?block:scaleBlock(block,this.scaler));});}update(update,scrollTarget=null){this.state=update.state;let prevDeco=this.stateDeco;this.stateDeco=this.state.facet(decorations).filter(d=>typeof d!="function");let contentChanges=update.changedRanges;let heightChanges=ChangedRange.extendWithRanges(contentChanges,heightRelevantDecoChanges(prevDeco,this.stateDeco,update?update.changes:ChangeSet.empty(this.state.doc.length)));let prevHeight=this.heightMap.height;let scrollAnchor=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,update.startState.doc,this.heightOracle.setDoc(this.state.doc),heightChanges);if(this.heightMap.height!=prevHeight)update.flags|=2;if(scrollAnchor){this.scrollAnchorPos=update.changes.mapPos(scrollAnchor.from,-1);this.scrollAnchorHeight=scrollAnchor.top;}else{this.scrollAnchorPos=-1;this.scrollAnchorHeight=this.heightMap.height;}let viewport=heightChanges.length?this.mapViewport(this.viewport,update.changes):this.viewport;if(scrollTarget&&(scrollTarget.range.headviewport.to)||!this.viewportIsAppropriate(viewport))viewport=this.getViewport(0,scrollTarget);let updateLines=!update.changes.empty||update.flags&2||viewport.from!=this.viewport.from||viewport.to!=this.viewport.to;this.viewport=viewport;this.updateForViewport();if(updateLines)this.updateViewportLines();if(this.lineGaps.length||this.viewport.to-this.viewport.from>2000<<1)this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,update.changes)));update.flags|=this.computeVisibleRanges();if(scrollTarget)this.scrollTarget=scrollTarget;if(!this.mustEnforceCursorAssoc&&update.selectionSet&&update.view.lineWrapping&&update.state.selection.main.empty&&update.state.selection.main.assoc&&!update.state.facet(nativeSelectionHidden))this.mustEnforceCursorAssoc=true;}measure(view){let dom=view.contentDOM,style=window.getComputedStyle(dom);let oracle=this.heightOracle;let whiteSpace=style.whiteSpace;this.defaultTextDirection=style.direction=="rtl"?Direction.RTL:Direction.LTR;let refresh=this.heightOracle.mustRefreshForWrapping(whiteSpace);let domRect=dom.getBoundingClientRect();let measureContent=refresh||this.mustMeasureContent||this.contentDOMHeight!=domRect.height;this.contentDOMHeight=domRect.height;this.mustMeasureContent=false;let result=0,bias=0;let paddingTop=parseInt(style.paddingTop)||0,paddingBottom=parseInt(style.paddingBottom)||0;if(this.paddingTop!=paddingTop||this.paddingBottom!=paddingBottom){this.paddingTop=paddingTop;this.paddingBottom=paddingBottom;result|=8|2;}if(this.editorWidth!=view.scrollDOM.clientWidth){if(oracle.lineWrapping)measureContent=true;this.editorWidth=view.scrollDOM.clientWidth;result|=8;}if(this.scrollTop!=view.scrollDOM.scrollTop){this.scrollAnchorHeight=-1;this.scrollTop=view.scrollDOM.scrollTop;}this.scrolledToBottom=isScrolledToBottom(view.scrollDOM);let pixelViewport=(this.printing?fullPixelRange:visiblePixelRange)(dom,this.paddingTop);let dTop=pixelViewport.top-this.pixelViewport.top,dBottom=pixelViewport.bottom-this.pixelViewport.bottom;this.pixelViewport=pixelViewport;let inView=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(inView!=this.inView){this.inView=inView;if(inView)measureContent=true;}if(!this.inView&&!this.scrollTarget)return 0;let contentWidth=domRect.width;if(this.contentDOMWidth!=contentWidth||this.editorHeight!=view.scrollDOM.clientHeight){this.contentDOMWidth=domRect.width;this.editorHeight=view.scrollDOM.clientHeight;result|=8;}if(measureContent){let lineHeights=view.docView.measureVisibleLineHeights(this.viewport);if(oracle.mustRefreshForHeights(lineHeights))refresh=true;if(refresh||oracle.lineWrapping&&Math.abs(contentWidth-this.contentDOMWidth)>oracle.charWidth){let{lineHeight,charWidth,textHeight}=view.docView.measureTextSize();refresh=lineHeight>0&&oracle.refresh(whiteSpace,lineHeight,charWidth,textHeight,contentWidth/charWidth,lineHeights);if(refresh){view.docView.minWidth=0;result|=8;}}if(dTop>0&&dBottom>0)bias=Math.max(dTop,dBottom);else if(dTop<0&&dBottom<0)bias=Math.min(dTop,dBottom);oracle.heightChanged=false;for(let _i65=0,_this$viewports=this.viewports,_length65=_this$viewports.length;_i65<_length65;_i65++){let vp=_this$viewports[_i65];let heights=vp.from==this.viewport.from?lineHeights:view.docView.measureVisibleLineHeights(vp);this.heightMap=(refresh?HeightMap.empty().applyChanges(this.stateDeco,Text$1.empty,this.heightOracle,[new ChangedRange(0,0,0,view.state.doc.length)]):this.heightMap).updateHeight(oracle,0,refresh,new MeasuredHeights(vp.from,heights));}if(oracle.heightChanged)result|=2;}let viewportChange=!this.viewportIsAppropriate(this.viewport,bias)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);if(viewportChange)this.viewport=this.getViewport(bias,this.scrollTarget);this.updateForViewport();if(result&2||viewportChange)this.updateViewportLines();if(this.lineGaps.length||this.viewport.to-this.viewport.from>2000<<1)this.updateLineGaps(this.ensureLineGaps(refresh?[]:this.lineGaps,view));result|=this.computeVisibleRanges();if(this.mustEnforceCursorAssoc){this.mustEnforceCursorAssoc=false;view.docView.enforceCursorAssoc();}return result;}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top);}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom);}getViewport(bias,scrollTarget){let marginTop=0.5-Math.max(-0.5,Math.min(0.5,bias/1000/2));let map=this.heightMap,oracle=this.heightOracle;let{visibleTop,visibleBottom}=this;let viewport=new Viewport(map.lineAt(visibleTop-marginTop*1000,QueryType$1.ByHeight,oracle,0,0).from,map.lineAt(visibleBottom+(1-marginTop)*1000,QueryType$1.ByHeight,oracle,0,0).to);if(scrollTarget){let{head}=scrollTarget.range;if(headviewport.to){let viewHeight=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top);let block=map.lineAt(head,QueryType$1.ByPos,oracle,0,0),topPos;if(scrollTarget.y=="center")topPos=(block.top+block.bottom)/2-viewHeight/2;else if(scrollTarget.y=="start"||scrollTarget.y=="nearest"&&head=visibleBottom+Math.max(10,Math.min(bias,250)))&&top>visibleTop-2*1000&&bottom>1,doubleMargin=margin<<1;if(this.defaultTextDirection!=Direction.LTR&&!wrapping)return[];let gaps=[];let addGap=(from,to,line,structure)=>{if(to-fromfrom&&posgap.from>=line.from&&gap.to<=line.to&&Math.abs(gap.from-from)gap.frompos));if(!gap){if(tor.from<=to&&r.to>=to)){let lineStart=mayMeasure.moveToLineBoundary(EditorSelection.cursor(to),false,true).head;if(lineStart>from)to=lineStart;}gap=new LineGap(from,to,this.gapSize(line,from,to,structure));}gaps.push(gap);};for(let _i68=0,_this$viewportLines=this.viewportLines,_length68=_this$viewportLines.length;_i68<_length68;_i68++){let line=_this$viewportLines[_i68];if(line.lengthline.from)addGap(line.from,viewFrom,line,structure);if(viewTogap.draw(this.heightOracle.lineWrapping)));}}computeVisibleRanges(){let deco=this.stateDeco;if(this.lineGaps.length)deco=deco.concat(this.lineGapDeco);let ranges=[];RangeSet.spans(deco,this.viewport.from,this.viewport.to,{span(from,to){ranges.push({from,to});},point(){}},20);let changed=ranges.length!=this.visibleRanges.length||this.visibleRanges.some((r,i)=>r.from!=ranges[i].from||r.to!=ranges[i].to);this.visibleRanges=ranges;return changed?4:0;}lineBlockAt(pos){return pos>=this.viewport.from&&pos<=this.viewport.to&&this.viewportLines.find(b=>b.from<=pos&&b.to>=pos)||scaleBlock(this.heightMap.lineAt(pos,QueryType$1.ByPos,this.heightOracle,0,0),this.scaler);}lineBlockAtHeight(height){return scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(height),QueryType$1.ByHeight,this.heightOracle,0,0),this.scaler);}scrollAnchorAt(scrollTop){let block=this.lineBlockAtHeight(scrollTop+8);return block.from>=this.viewport.from||this.viewportLines[0].top-scrollTop>200?block:this.viewportLines[0];}elementAtHeight(height){return scaleBlock(this.heightMap.blockAt(this.scaler.fromDOM(height),this.heightOracle,0,0),this.scaler);}get docHeight(){return this.scaler.toDOM(this.heightMap.height);}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom;}}class Viewport{constructor(from,to){this.from=from;this.to=to;}}function lineStructure(from,to,stateDeco){let ranges=[],pos=from,total=0;RangeSet.spans(stateDeco,from,to,{span(){},point(from,to){if(from>pos){ranges.push({from:pos,to:from});total+=from-pos;}pos=to;}},20);if(pos=1)return ranges[ranges.length-1].to;let dist=Math.floor(total*ratio);for(let i=0;;i++){let{from,to}=ranges[i],size=to-from;if(dist<=size)return from+dist;dist-=size;}}function findFraction(structure,pos){let counted=0;for(let _i69=0,_structure$ranges=structure.ranges,_length69=_structure$ranges.length;_i69<_length69;_i69++){let{from,to}=_structure$ranges[_i69];if(pos<=to){counted+=pos-from;break;}counted+=to-from;}return counted/structure.total;}function find(array,f){for(let _i70=0,_length70=array.length;_i70<_length70;_i70++){let val=array[_i70];if(f(val))return val;}return undefined;}const IdScaler={toDOM(n){return n;},fromDOM(n){return n;},scale:1};class BigScaler{constructor(oracle,heightMap,viewports){let vpHeight=0,base=0,domBase=0;this.viewports=viewports.map(({from,to})=>{let top=heightMap.lineAt(from,QueryType$1.ByPos,oracle,0,0).top;let bottom=heightMap.lineAt(to,QueryType$1.ByPos,oracle,0,0).bottom;vpHeight+=bottom-top;return{from,to,top,bottom,domTop:0,domBottom:0};});this.scale=(7000000-vpHeight)/(heightMap.height-vpHeight);for(let _i71=0,_this$viewports2=this.viewports,_length71=_this$viewports2.length;_i71<_length71;_i71++){let obj=_this$viewports2[_i71];obj.domTop=domBase+(obj.top-base)*this.scale;domBase=obj.domBottom=obj.domTop+(obj.bottom-obj.top);base=obj.bottom;}}toDOM(n){for(let i=0,base=0,domBase=0;;i++){let vp=iscaleBlock(b,scaler)):block._content);}const theme=Facet.define({combine:strs=>strs.join(" ")});const darkTheme=Facet.define({combine:values=>values.indexOf(true)>-1});const baseThemeID=StyleModule.newName(),baseLightID=StyleModule.newName(),baseDarkID=StyleModule.newName();const lightDarkIDs={"&light":"."+baseLightID,"&dark":"."+baseDarkID};function buildTheme(main,spec,scopes){return new StyleModule(spec,{finish(sel){return /&/.test(sel)?sel.replace(/&\w*/,m=>{if(m=="&")return main;if(!scopes||!scopes[m])throw new RangeError(`Unsupported selector: ${m}`);return scopes[m];}):main+" "+sel;}});}const baseTheme$1$3=buildTheme("."+baseThemeID,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},lightDarkIDs);class DOMChange{constructor(view,start,end,typeOver){this.typeOver=typeOver;this.bounds=null;this.text="";let{impreciseHead:iHead,impreciseAnchor:iAnchor}=view.docView;if(view.state.readOnly&&start>-1){this.newSel=null;}else if(start>-1&&(this.bounds=view.docView.domBoundsAround(start,end,0))){let selPoints=iHead||iAnchor?[]:selectionPoints(view);let reader=new DOMReader(selPoints,view.state);reader.readRange(this.bounds.startDOM,this.bounds.endDOM);this.text=reader.text;this.newSel=selectionFromPoints(selPoints,this.bounds.from);}else{let domSel=view.observer.selectionRange;let head=iHead&&iHead.node==domSel.focusNode&&iHead.offset==domSel.focusOffset||!contains(view.contentDOM,domSel.focusNode)?view.state.selection.main.head:view.docView.posFromDOM(domSel.focusNode,domSel.focusOffset);let anchor=iAnchor&&iAnchor.node==domSel.anchorNode&&iAnchor.offset==domSel.anchorOffset||!contains(view.contentDOM,domSel.anchorNode)?view.state.selection.main.anchor:view.docView.posFromDOM(domSel.anchorNode,domSel.anchorOffset);this.newSel=EditorSelection.single(anchor,head);}}}function applyDOMChange(view,domChange){let change;let{newSel}=domChange,sel=view.state.selection.main;let lastKey=view.inputState.lastKeyTime>Date.now()-100?view.inputState.lastKeyCode:-1;if(domChange.bounds){let{from,to}=domChange.bounds;let preferredPos=sel.from,preferredSide=null;if(lastKey===8||browser.android&&domChange.text.length=sel.from&&change.to<=sel.to&&(change.from!=sel.from||change.to!=sel.to)&&sel.to-sel.from-(change.to-change.from)<=4){change={from:sel.from,to:sel.to,insert:view.state.doc.slice(sel.from,change.from).append(change.insert).append(view.state.doc.slice(change.to,sel.to))};}else if((browser.mac||browser.android)&&change&&change.from==change.to&&change.from==sel.head-1&&/^\. ?$/.test(change.insert.toString())&&view.contentDOM.getAttribute("autocorrect")=="off"){if(newSel&&change.insert.length==2)newSel=EditorSelection.single(newSel.main.anchor-1,newSel.main.head-1);change={from:sel.from,to:sel.to,insert:Text$1.of([" "])};}else if(browser.chrome&&change&&change.from==change.to&&change.from==sel.head&&change.insert.toString()=="\n "&&view.lineWrapping){if(newSel)newSel=EditorSelection.single(newSel.main.anchor-1,newSel.main.head-1);change={from:sel.from,to:sel.to,insert:Text$1.of([" "])};}if(change){let startState=view.state;if(browser.ios&&view.inputState.flushIOSKey(view))return true;if(browser.android&&(change.from==sel.from&&change.to==sel.to&&change.insert.length==1&&change.insert.lines==2&&dispatchKey(view.contentDOM,"Enter",13)||(change.from==sel.from-1&&change.to==sel.to&&change.insert.length==0||lastKey==8&&change.insert.lengthh(view,change.from,change.to,text)))return true;if(view.inputState.composing>=0)view.inputState.composing++;let tr;if(change.from>=sel.from&&change.to<=sel.to&&change.to-change.from>=(sel.to-sel.from)/3&&(!newSel||newSel.main.empty&&newSel.main.from==change.from+change.insert.length)&&view.inputState.composing<0){let before=sel.fromchange.to?startState.sliceDoc(change.to,sel.to):"";tr=startState.replaceSelection(view.state.toText(before+change.insert.sliceString(0,undefined,view.state.lineBreak)+after));}else{let changes=startState.changes(change);let mainSel=newSel&&newSel.main.to<=changes.newLength?newSel.main:undefined;if(startState.selection.ranges.length>1&&view.inputState.composing>=0&&change.to<=sel.to&&change.to>=sel.to-10){let replaced=view.state.sliceDoc(change.from,change.to);let composition=findCompositionNode(view)||view.state.doc.lineAt(sel.head);let offset=sel.to-change.to,size=sel.to-sel.from;tr=startState.changeByRange(range=>{if(range.from==sel.from&&range.to==sel.to)return{changes,range:mainSel||range.map(changes)};let to=range.to-offset,from=to-replaced.length;if(range.to-range.from!=size||view.state.sliceDoc(from,to)!=replaced||composition&&range.to>=composition.from&&range.from<=composition.to)return{range};let rangeChanges=startState.changes({from,to,insert:change.insert}),selOff=range.to-sel.to;return{changes:rangeChanges,range:!mainSel?range.map(rangeChanges):EditorSelection.range(Math.max(0,mainSel.anchor+selOff),Math.max(0,mainSel.head+selOff))};});}else{tr={changes,selection:mainSel&&startState.selection.replaceRange(mainSel)};}}let userEvent="input.type";if(view.composing||view.inputState.compositionPendingChange&&view.inputState.compositionEndedAt>Date.now()-50){view.inputState.compositionPendingChange=false;userEvent+=".compose";if(view.inputState.compositionFirstChange){userEvent+=".start";view.inputState.compositionFirstChange=false;}}view.dispatch(tr,{scrollIntoView:true,userEvent});return true;}else if(newSel&&!newSel.main.eq(sel)){let scrollIntoView=false,userEvent="select";if(view.inputState.lastSelectionTime>Date.now()-50){if(view.inputState.lastSelectionOrigin=="select")scrollIntoView=true;userEvent=view.inputState.lastSelectionOrigin;}view.dispatch({selection:newSel,scrollIntoView,userEvent});return true;}else{return false;}}function findDiff$1(a,b,preferredPos,preferredSide){let minLen=Math.min(a.length,b.length);let from=0;while(from0&&toB>0&&a.charCodeAt(toA-1)==b.charCodeAt(toB-1)){toA--;toB--;}if(preferredSide=="end"){let adjust=Math.max(0,from-Math.min(toA,toB));preferredPos-=toA+adjust-from;}if(toA=toA?from-preferredPos:0;from-=move;toB=from+(toB-toA);toA=from;}else if(toB=toB?from-preferredPos:0;from-=move;toA=from+(toA-toB);toB=from;}return{from,toA,toB};}function selectionPoints(view){let result=[];if(view.root.activeElement!=view.contentDOM)return result;let{anchorNode,anchorOffset,focusNode,focusOffset}=view.observer.selectionRange;if(anchorNode){result.push(new DOMPoint(anchorNode,anchorOffset));if(focusNode!=anchorNode||focusOffset!=anchorOffset)result.push(new DOMPoint(focusNode,focusOffset));}return result;}function selectionFromPoints(points,base){if(points.length==0)return null;let anchor=points[0].pos,head=points.length==2?points[1].pos:anchor;return anchor>-1&&head>-1?EditorSelection.single(anchor+base,head+base):null;}const observeOptions={childList:true,characterData:true,subtree:true,attributes:true,characterDataOldValue:true};const useCharData=browser.ie&&browser.ie_version<=11;class DOMObserver{constructor(view){this.view=view;this.active=false;this.selectionRange=new DOMSelectionState();this.selectionChanged=false;this.delayedFlush=-1;this.resizeTimeout=-1;this.queue=[];this.delayedAndroidKey=null;this.flushingAndroidKey=-1;this.lastChange=0;this.scrollTargets=[];this.intersection=null;this.resizeScroll=null;this.resizeContent=null;this.intersecting=false;this.gapIntersection=null;this.gaps=[];this.parentCheck=-1;this.dom=view.contentDOM;this.observer=new MutationObserver(mutations=>{for(let _i72=0,_length72=mutations.length;_i72<_length72;_i72++){let mut=mutations[_i72];this.queue.push(mut);}if((browser.ie&&browser.ie_version<=11||browser.ios&&view.composing)&&mutations.some(m=>m.type=="childList"&&m.removedNodes.length||m.type=="characterData"&&m.oldValue.length>m.target.nodeValue.length))this.flushSoon();else this.flush();});if(useCharData)this.onCharData=event=>{this.queue.push({target:event.target,type:"characterData",oldValue:event.prevValue});this.flushSoon();};this.onSelectionChange=this.onSelectionChange.bind(this);this.onResize=this.onResize.bind(this);this.onPrint=this.onPrint.bind(this);this.onScroll=this.onScroll.bind(this);if(typeof ResizeObserver=="function"){this.resizeScroll=new ResizeObserver(()=>{var _a;if(((_a=this.view.docView)===null||_a===void 0?void 0:_a.lastUpdate)this.view.requestMeasure());this.resizeContent.observe(view.contentDOM);}this.addWindowListeners(this.win=view.win);this.start();if(typeof IntersectionObserver=="function"){this.intersection=new IntersectionObserver(entries=>{if(this.parentCheck<0)this.parentCheck=setTimeout(this.listenForScroll.bind(this),1000);if(entries.length>0&&entries[entries.length-1].intersectionRatio>0!=this.intersecting){this.intersecting=!this.intersecting;if(this.intersecting!=this.view.inView)this.onScrollChanged(document.createEvent("Event"));}},{threshold:[0,.001]});this.intersection.observe(this.dom);this.gapIntersection=new IntersectionObserver(entries=>{if(entries.length>0&&entries[entries.length-1].intersectionRatio>0)this.onScrollChanged(document.createEvent("Event"));},{});}this.listenForScroll();this.readSelectionRange();}onScrollChanged(e){this.view.inputState.runScrollHandlers(this.view,e);if(this.intersecting)this.view.measure();}onScroll(e){if(this.intersecting)this.flush(false);this.onScrollChanged(e);}onResize(){if(this.resizeTimeout<0)this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1;this.view.requestMeasure();},50);}onPrint(){this.view.viewState.printing=true;this.view.measure();setTimeout(()=>{this.view.viewState.printing=false;this.view.requestMeasure();},500);}updateGaps(gaps){if(this.gapIntersection&&(gaps.length!=this.gaps.length||this.gaps.some((g,i)=>g!=gaps[i]))){this.gapIntersection.disconnect();for(let _i73=0,_length73=gaps.length;_i73<_length73;_i73++){let gap=gaps[_i73];this.gapIntersection.observe(gap);}this.gaps=gaps;}}onSelectionChange(event){let wasChanged=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view}=this,sel=this.selectionRange;if(view.state.facet(editable)?view.root.activeElement!=this.dom:!hasSelection(view.dom,sel))return;let context=sel.anchorNode&&view.docView.nearest(sel.anchorNode);if(context&&context.ignoreEvent(event)){if(!wasChanged)this.selectionChanged=false;return;}if((browser.ie&&browser.ie_version<=11||browser.android&&browser.chrome)&&!view.state.selection.main.empty&&sel.focusNode&&isEquivalentPosition(sel.focusNode,sel.focusOffset,sel.anchorNode,sel.anchorOffset))this.flushSoon();else this.flush(false);}readSelectionRange(){let{view}=this;let range=browser.safari&&view.root.nodeType==11&&deepActiveElement(this.dom.ownerDocument)==this.dom&&safariSelectionRangeHack(this.view)||getSelection(view.root);if(!range||this.selectionRange.eq(range))return false;let local=hasSelection(this.dom,range);if(local&&!this.selectionChanged&&view.inputState.lastFocusTime>Date.now()-200&&view.inputState.lastTouchTime{let key=this.delayedAndroidKey;if(key){this.clearDelayedAndroidKey();this.view.inputState.lastKeyCode=key.keyCode;this.view.inputState.lastKeyTime=Date.now();let flushed=this.flush();if(!flushed&&key.force)dispatchKey(this.dom,key.key,key.keyCode);}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(flush);}if(!this.delayedAndroidKey||key=="Enter")this.delayedAndroidKey={key,keyCode,force:this.lastChange{this.delayedFlush=-1;this.flush();});}forceFlush(){if(this.delayedFlush>=0){this.view.win.cancelAnimationFrame(this.delayedFlush);this.delayedFlush=-1;}this.flush();}pendingRecords(){for(let _i76=0,_this$observer$takeRe=this.observer.takeRecords(),_length76=_this$observer$takeRe.length;_i76<_length76;_i76++){let mut=_this$observer$takeRe[_i76];this.queue.push(mut);}return this.queue;}processRecords(){let records=this.pendingRecords();if(records.length)this.queue=[];let from=-1,to=-1,typeOver=false;for(let _i77=0,_length77=records.length;_i77<_length77;_i77++){let record=records[_i77];let range=this.readMutation(record);if(!range)continue;if(range.typeOver)typeOver=true;if(from==-1){({from,to}=range);}else{from=Math.min(range.from,from);to=Math.max(range.to,to);}}return{from,to,typeOver};}readChange(){let{from,to,typeOver}=this.processRecords();let newSel=this.selectionChanged&&hasSelection(this.dom,this.selectionRange);if(from<0&&!newSel)return null;if(from>-1)this.lastChange=Date.now();this.view.inputState.lastFocusTime=0;this.selectionChanged=false;return new DOMChange(this.view,from,to,typeOver);}flush(readSelection=true){if(this.delayedFlush>=0||this.delayedAndroidKey)return false;if(readSelection)this.readSelectionRange();let domChange=this.readChange();if(!domChange)return false;let startState=this.view.state;let handled=applyDOMChange(this.view,domChange);if(this.view.state==startState)this.view.update([]);return handled;}readMutation(rec){let cView=this.view.docView.nearest(rec.target);if(!cView||cView.ignoreMutation(rec))return null;cView.markDirty(rec.type=="attributes");if(rec.type=="attributes")cView.flags|=4;if(rec.type=="childList"){let childBefore=findChild(cView,rec.previousSibling||rec.target.previousSibling,-1);let childAfter=findChild(cView,rec.nextSibling||rec.target.nextSibling,1);return{from:childBefore?cView.posAfter(childBefore):cView.posAtStart,to:childAfter?cView.posBefore(childAfter):cView.posAtEnd,typeOver:false};}else if(rec.type=="characterData"){return{from:cView.posAtStart,to:cView.posAtEnd,typeOver:rec.target.nodeValue==rec.oldValue};}else{return null;}}setWindow(win){if(win!=this.win){this.removeWindowListeners(this.win);this.win=win;this.addWindowListeners(this.win);}}addWindowListeners(win){win.addEventListener("resize",this.onResize);win.addEventListener("beforeprint",this.onPrint);win.addEventListener("scroll",this.onScroll);win.document.addEventListener("selectionchange",this.onSelectionChange);}removeWindowListeners(win){win.removeEventListener("scroll",this.onScroll);win.removeEventListener("resize",this.onResize);win.removeEventListener("beforeprint",this.onPrint);win.document.removeEventListener("selectionchange",this.onSelectionChange);}destroy(){var _a,_b,_c,_d;this.stop();(_a=this.intersection)===null||_a===void 0?void 0:_a.disconnect();(_b=this.gapIntersection)===null||_b===void 0?void 0:_b.disconnect();(_c=this.resizeScroll)===null||_c===void 0?void 0:_c.disconnect();(_d=this.resizeContent)===null||_d===void 0?void 0:_d.disconnect();for(let _i78=0,_this$scrollTargets3=this.scrollTargets,_length78=_this$scrollTargets3.length;_i78<_length78;_i78++){let dom=_this$scrollTargets3[_i78];dom.removeEventListener("scroll",this.onScroll);}this.removeWindowListeners(this.win);clearTimeout(this.parentCheck);clearTimeout(this.resizeTimeout);this.win.cancelAnimationFrame(this.delayedFlush);this.win.cancelAnimationFrame(this.flushingAndroidKey);}}function findChild(cView,dom,dir){while(dom){let curView=ContentView.get(dom);if(curView&&curView.parent==cView)return curView;let parent=dom.parentNode;dom=parent!=cView.dom?parent:dir>0?dom.nextSibling:dom.previousSibling;}return null;}function safariSelectionRangeHack(view){let found=null;function read(event){event.preventDefault();event.stopImmediatePropagation();found=event.getTargetRanges()[0];}view.contentDOM.addEventListener("beforeinput",read,true);view.dom.ownerDocument.execCommand("indent");view.contentDOM.removeEventListener("beforeinput",read,true);if(!found)return null;let anchorNode=found.startContainer,anchorOffset=found.startOffset;let focusNode=found.endContainer,focusOffset=found.endOffset;let curAnchor=view.docView.domAtPos(view.state.selection.main.anchor);if(isEquivalentPosition(curAnchor.node,curAnchor.offset,focusNode,focusOffset))[anchorNode,anchorOffset,focusNode,focusOffset]=[focusNode,focusOffset,anchorNode,anchorOffset];return{anchorNode,anchorOffset,focusNode,focusOffset};}class EditorView{get state(){return this.viewState.state;}get viewport(){return this.viewState.viewport;}get visibleRanges(){return this.viewState.visibleRanges;}get inView(){return this.viewState.inView;}get composing(){return this.inputState.composing>0;}get compositionStarted(){return this.inputState.composing>=0;}get root(){return this._root;}get win(){return this.dom.ownerDocument.defaultView||window;}constructor(config={}){this.plugins=[];this.pluginMap=new Map();this.editorAttrs={};this.contentAttrs={};this.bidiCache=[];this.destroyed=false;this.updateState=2;this.measureScheduled=-1;this.measureRequests=[];this.contentDOM=document.createElement("div");this.scrollDOM=document.createElement("div");this.scrollDOM.tabIndex=-1;this.scrollDOM.className="cm-scroller";this.scrollDOM.appendChild(this.contentDOM);this.announceDOM=document.createElement("div");this.announceDOM.style.cssText="position: fixed; top: -10000px";this.announceDOM.setAttribute("aria-live","polite");this.dom=document.createElement("div");this.dom.appendChild(this.announceDOM);this.dom.appendChild(this.scrollDOM);this._dispatch=config.dispatch||(tr=>this.update([tr]));this.dispatch=this.dispatch.bind(this);this._root=config.root||getRoot(config.parent)||document;this.viewState=new ViewState(config.state||EditorState.create(config));this.plugins=this.state.facet(viewPlugin).map(spec=>new PluginInstance(spec));for(let _i79=0,_this$plugins=this.plugins,_length79=_this$plugins.length;_i79<_length79;_i79++){let plugin=_this$plugins[_i79];plugin.update(this);}this.observer=new DOMObserver(this);this.inputState=new InputState(this);this.inputState.ensureHandlers(this,this.plugins);this.docView=new DocView(this);this.mountStyles();this.updateAttrs();this.updateState=0;this.requestMeasure();if(config.parent)config.parent.appendChild(this.dom);}dispatch(...input){let tr=input.length==1&&input[0]instanceof Transaction?input[0]:this.state.update(...input);this._dispatch(tr,this);}update(transactions){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let redrawn=false,attrsChanged=false,update;let state=this.state;for(let _i80=0,_length80=transactions.length;_i80<_length80;_i80++){let tr=transactions[_i80];if(tr.startState!=state)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");state=tr.state;}if(this.destroyed){this.viewState.state=state;return;}let focus=this.hasFocus,focusFlag=0,dispatchFocus=null;if(transactions.some(tr=>tr.annotation(isFocusChange))){this.inputState.notifiedFocused=focus;focusFlag=1;}else if(focus!=this.inputState.notifiedFocused){this.inputState.notifiedFocused=focus;dispatchFocus=focusChangeTransaction(state,focus);if(!dispatchFocus)focusFlag=1;}let pendingKey=this.observer.delayedAndroidKey,domChange=null;if(pendingKey){this.observer.clearDelayedAndroidKey();domChange=this.observer.readChange();if(domChange&&!this.state.doc.eq(state.doc)||!this.state.selection.eq(state.selection))domChange=null;}else{this.observer.clear();}if(state.facet(EditorState.phrases)!=this.state.facet(EditorState.phrases))return this.setState(state);update=ViewUpdate.create(this,state,transactions);update.flags|=focusFlag;let scrollTarget=this.viewState.scrollTarget;try{this.updateState=2;for(let _i81=0,_length81=transactions.length;_i81<_length81;_i81++){let tr=transactions[_i81];if(scrollTarget)scrollTarget=scrollTarget.map(tr.changes);if(tr.scrollIntoView){let{main}=tr.state.selection;scrollTarget=new ScrollTarget(main.empty?main:EditorSelection.cursor(main.head,main.head>main.anchor?-1:1));}for(let _i82=0,_tr$effects2=tr.effects,_length82=_tr$effects2.length;_i82<_length82;_i82++){let e=_tr$effects2[_i82];if(e.is(scrollIntoView$1))scrollTarget=e.value;}}this.viewState.update(update,scrollTarget);this.bidiCache=CachedOrder.update(this.bidiCache,update.changes);if(!update.empty){this.updatePlugins(update);this.inputState.update(update);}redrawn=this.docView.update(update);if(this.state.facet(styleModule)!=this.styleModules)this.mountStyles();attrsChanged=this.updateAttrs();this.showAnnouncements(transactions);this.docView.updateSelection(redrawn,transactions.some(tr=>tr.isUserEvent("select.pointer")));}finally{this.updateState=0;}if(update.startState.facet(theme)!=update.state.facet(theme))this.viewState.mustMeasureContent=true;if(redrawn||attrsChanged||scrollTarget||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)this.requestMeasure();if(!update.empty)for(let _i83=0,_this$state$facet=this.state.facet(updateListener),_length83=_this$state$facet.length;_i83<_length83;_i83++){let listener=_this$state$facet[_i83];listener(update);}if(dispatchFocus||domChange)Promise.resolve().then(()=>{if(dispatchFocus&&this.state==dispatchFocus.startState)this.dispatch(dispatchFocus);if(domChange){if(!applyDOMChange(this,domChange)&&pendingKey.force)dispatchKey(this.contentDOM,pendingKey.key,pendingKey.keyCode);}});}setState(newState){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=newState;return;}this.updateState=2;let hadFocus=this.hasFocus;try{for(let _i84=0,_this$plugins2=this.plugins,_length84=_this$plugins2.length;_i84<_length84;_i84++){let plugin=_this$plugins2[_i84];plugin.destroy(this);}this.viewState=new ViewState(newState);this.plugins=newState.facet(viewPlugin).map(spec=>new PluginInstance(spec));this.pluginMap.clear();for(let _i85=0,_this$plugins3=this.plugins,_length85=_this$plugins3.length;_i85<_length85;_i85++){let plugin=_this$plugins3[_i85];plugin.update(this);}this.docView=new DocView(this);this.inputState.ensureHandlers(this,this.plugins);this.mountStyles();this.updateAttrs();this.bidiCache=[];}finally{this.updateState=0;}if(hadFocus)this.focus();this.requestMeasure();}updatePlugins(update){let prevSpecs=update.startState.facet(viewPlugin),specs=update.state.facet(viewPlugin);if(prevSpecs!=specs){let newPlugins=[];for(let _i86=0,_length86=specs.length;_i86<_length86;_i86++){let spec=specs[_i86];let found=prevSpecs.indexOf(spec);if(found<0){newPlugins.push(new PluginInstance(spec));}else{let plugin=this.plugins[found];plugin.mustUpdate=update;newPlugins.push(plugin);}}for(let _i87=0,_this$plugins4=this.plugins,_length87=_this$plugins4.length;_i87<_length87;_i87++){let plugin=_this$plugins4[_i87];if(plugin.mustUpdate!=update)plugin.destroy(this);}this.plugins=newPlugins;this.pluginMap.clear();this.inputState.ensureHandlers(this,this.plugins);}else{for(let _i88=0,_this$plugins5=this.plugins,_length88=_this$plugins5.length;_i88<_length88;_i88++){let p=_this$plugins5[_i88];p.mustUpdate=update;}}for(let i=0;i-1)this.win.cancelAnimationFrame(this.measureScheduled);this.measureScheduled=0;if(flush)this.observer.forceFlush();let updated=null;let sDOM=this.scrollDOM,{scrollTop}=sDOM;let{scrollAnchorPos,scrollAnchorHeight}=this.viewState;if(scrollTop!=this.viewState.scrollTop)scrollAnchorHeight=-1;this.viewState.scrollAnchorHeight=-1;try{for(let i=0;;i++){if(scrollAnchorHeight<0){if(isScrolledToBottom(sDOM)){scrollAnchorPos=-1;scrollAnchorHeight=this.viewState.heightMap.height;}else{let block=this.viewState.scrollAnchorAt(scrollTop);scrollAnchorPos=block.from;scrollAnchorHeight=block.top;}}this.updateState=1;let changed=this.viewState.measure(this);if(!changed&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(i>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break;}let measuring=[];if(!(changed&4))[this.measureRequests,measuring]=[measuring,this.measureRequests];let measured=measuring.map(m=>{try{return m.read(this);}catch(e){logException(this.state,e);return BadMeasure;}});let update=ViewUpdate.create(this,this.state,[]),redrawn=false;update.flags|=changed;if(!updated)updated=update;else updated.flags|=changed;this.updateState=2;if(!update.empty){this.updatePlugins(update);this.inputState.update(update);this.updateAttrs();redrawn=this.docView.update(update);}for(let i=0;i1||diff<-1){scrollTop=sDOM.scrollTop=scrollTop+diff;scrollAnchorHeight=-1;continue;}}}break;}}}finally{this.updateState=0;this.measureScheduled=-1;}if(updated&&!updated.empty)for(let _i89=0,_this$state$facet2=this.state.facet(updateListener),_length89=_this$state$facet2.length;_i89<_length89;_i89++){let listener=_this$state$facet2[_i89];listener(updated);}}get themeClasses(){return baseThemeID+" "+(this.state.facet(darkTheme)?baseDarkID:baseLightID)+" "+this.state.facet(theme);}updateAttrs(){let editorAttrs=attrsFromFacet(this,editorAttributes,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses});let contentAttrs={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:!this.state.facet(editable)?"false":"true",class:"cm-content",style:`${browser.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};if(this.state.readOnly)contentAttrs["aria-readonly"]="true";attrsFromFacet(this,contentAttributes,contentAttrs);let changed=this.observer.ignore(()=>{let changedContent=updateAttrs(this.contentDOM,this.contentAttrs,contentAttrs);let changedEditor=updateAttrs(this.dom,this.editorAttrs,editorAttrs);return changedContent||changedEditor;});this.editorAttrs=editorAttrs;this.contentAttrs=contentAttrs;return changed;}showAnnouncements(trs){let first=true;for(let _i90=0,_length90=trs.length;_i90<_length90;_i90++){let tr=trs[_i90];for(let _i91=0,_tr$effects3=tr.effects,_length91=_tr$effects3.length;_i91<_length91;_i91++){let effect=_tr$effects3[_i91];if(effect.is(EditorView.announce)){if(first)this.announceDOM.textContent="";first=false;let div=this.announceDOM.appendChild(document.createElement("div"));div.textContent=effect.value;}}}}mountStyles(){this.styleModules=this.state.facet(styleModule);StyleModule.mount(this.root,this.styleModules.concat(baseTheme$1$3).reverse());}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");if(this.updateState==0&&this.measureScheduled>-1)this.measure(false);}requestMeasure(request){if(this.measureScheduled<0)this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure());if(request){if(this.measureRequests.indexOf(request)>-1)return;if(request.key!=null)for(let i=0;ip.spec==plugin)||null);return known&&known.update(this).value;}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop;}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom};}elementAtHeight(height){this.readMeasured();return this.viewState.elementAtHeight(height);}lineBlockAtHeight(height){this.readMeasured();return this.viewState.lineBlockAtHeight(height);}get viewportLineBlocks(){return this.viewState.viewportLines;}lineBlockAt(pos){return this.viewState.lineBlockAt(pos);}get contentHeight(){return this.viewState.contentHeight;}moveByChar(start,forward,by){return skipAtoms(this,start,moveByChar(this,start,forward,by));}moveByGroup(start,forward){return skipAtoms(this,start,moveByChar(this,start,forward,initial=>byGroup(this,start.head,initial)));}moveToLineBoundary(start,forward,includeWrap=true){return moveToLineBoundary(this,start,forward,includeWrap);}moveVertically(start,forward,distance){return skipAtoms(this,start,moveVertically(this,start,forward,distance));}domAtPos(pos){return this.docView.domAtPos(pos);}posAtDOM(node,offset=0){return this.docView.posFromDOM(node,offset);}posAtCoords(coords,precise=true){this.readMeasured();return posAtCoords(this,coords,precise);}coordsAtPos(pos,side=1){this.readMeasured();let rect=this.docView.coordsAt(pos,side);if(!rect||rect.left==rect.right)return rect;let line=this.state.doc.lineAt(pos),order=this.bidiSpans(line);let span=order[BidiSpan.find(order,pos-line.from,-1,side)];return flattenRect(rect,span.dir==Direction.LTR==side>0);}coordsForChar(pos){this.readMeasured();return this.docView.coordsForChar(pos);}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth;}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight;}get textDirection(){return this.viewState.defaultTextDirection;}textDirectionAt(pos){let perLine=this.state.facet(perLineTextDirection);if(!perLine||posthis.viewport.to)return this.textDirection;this.readMeasured();return this.docView.textDirectionAt(pos);}get lineWrapping(){return this.viewState.heightOracle.lineWrapping;}bidiSpans(line){if(line.length>MaxBidiLine)return trivialOrder(line.length);let dir=this.textDirectionAt(line.from);for(let _i92=0,_this$bidiCache=this.bidiCache,_length92=_this$bidiCache.length;_i92<_length92;_i92++){let entry=_this$bidiCache[_i92];if(entry.from==line.from&&entry.dir==dir)return entry.order;}let order=computeOrder(line.text,dir);this.bidiCache.push(new CachedOrder(line.from,line.to,dir,order));return order;}get hasFocus(){var _a;return(this.dom.ownerDocument.hasFocus()||browser.safari&&((_a=this.inputState)===null||_a===void 0?void 0:_a.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM;}focus(){this.observer.ignore(()=>{focusPreventScroll(this.contentDOM);this.docView.updateSelection();});}setRoot(root){if(this._root!=root){this._root=root;this.observer.setWindow((root.nodeType==9?root:root.ownerDocument).defaultView||window);this.mountStyles();}}destroy(){for(let _i93=0,_this$plugins6=this.plugins,_length93=_this$plugins6.length;_i93<_length93;_i93++){let plugin=_this$plugins6[_i93];plugin.destroy(this);}this.plugins=[];this.inputState.destroy();this.dom.remove();this.observer.destroy();if(this.measureScheduled>-1)this.win.cancelAnimationFrame(this.measureScheduled);this.destroyed=true;}static scrollIntoView(pos,options={}){return scrollIntoView$1.of(new ScrollTarget(typeof pos=="number"?EditorSelection.cursor(pos):pos,options.y,options.x,options.yMargin,options.xMargin));}static domEventHandlers(handlers){return ViewPlugin.define(()=>({}),{eventHandlers:handlers});}static theme(spec,options){let prefix=StyleModule.newName();let result=[theme.of(prefix),styleModule.of(buildTheme(`.${prefix}`,spec))];if(options&&options.dark)result.push(darkTheme.of(true));return result;}static baseTheme(spec){return Prec.lowest(styleModule.of(buildTheme("."+baseThemeID,spec,lightDarkIDs)));}static findFromDOM(dom){var _a;let content=dom.querySelector(".cm-content");let cView=content&&ContentView.get(content)||ContentView.get(dom);return((_a=cView===null||cView===void 0?void 0:cView.rootView)===null||_a===void 0?void 0:_a.view)||null;}}EditorView.styleModule=styleModule;EditorView.inputHandler=inputHandler$1;EditorView.focusChangeEffect=focusChangeEffect;EditorView.perLineTextDirection=perLineTextDirection;EditorView.exceptionSink=exceptionSink;EditorView.updateListener=updateListener;EditorView.editable=editable;EditorView.mouseSelectionStyle=mouseSelectionStyle;EditorView.dragMovesSelection=dragMovesSelection$1;EditorView.clickAddsSelectionRange=clickAddsSelectionRange;EditorView.decorations=decorations;EditorView.atomicRanges=atomicRanges;EditorView.scrollMargins=scrollMargins;EditorView.darkTheme=darkTheme;EditorView.contentAttributes=contentAttributes;EditorView.editorAttributes=editorAttributes;EditorView.lineWrapping=EditorView.contentAttributes.of({"class":"cm-lineWrapping"});EditorView.announce=StateEffect.define();const MaxBidiLine=4096;const BadMeasure={};class CachedOrder{constructor(from,to,dir,order){this.from=from;this.to=to;this.dir=dir;this.order=order;}static update(cache,changes){if(changes.empty)return cache;let result=[],lastDir=cache.length?cache[cache.length-1].dir:Direction.LTR;for(let i=Math.max(0,cache.length-10);i=0;i--){let source=sources[i],value=typeof source=="function"?source(view):source;if(value)combineAttrs(value,base);}return base;}const currentPlatform=browser.mac?"mac":browser.windows?"win":browser.linux?"linux":"key";function normalizeKeyName(name,platform){const parts=name.split(/-(?!$)/);let result=parts[parts.length-1];if(result=="Space")result=" ";let alt,ctrl,shift,meta;for(let i=0;ia.concat(b),[])));return map;}function runScopeHandlers(view,event,scope){return runHandlers(getKeymap(view.state),event,view,scope);}let storedPrefix=null;const PrefixTimeout=4000;function buildKeymap(bindings,platform=currentPlatform){let bound=Object.create(null);let isPrefix=Object.create(null);let checkPrefix=(name,is)=>{let current=isPrefix[name];if(current==null)isPrefix[name]=is;else if(current!=is)throw new Error("Key binding "+name+" is used both as a regular binding and as a multi-stroke prefix");};let add=(scope,key,command,preventDefault,stopPropagation)=>{var _a,_b;let scopeObj=bound[scope]||(bound[scope]=Object.create(null));let parts=key.split(/ (?!$)/).map(k=>normalizeKeyName(k,platform));for(let i=1;i{let ourObj=storedPrefix={view,prefix,scope};setTimeout(()=>{if(storedPrefix==ourObj)storedPrefix=null;},PrefixTimeout);return true;}]};}let full=parts.join(" ");checkPrefix(full,false);let binding=scopeObj[full]||(scopeObj[full]={preventDefault:false,stopPropagation:false,run:((_b=(_a=scopeObj._any)===null||_a===void 0?void 0:_a.run)===null||_b===void 0?void 0:_b.slice())||[]});if(command)binding.run.push(command);if(preventDefault)binding.preventDefault=true;if(stopPropagation)binding.stopPropagation=true;};for(let _i94=0,_length94=bindings.length;_i94<_length94;_i94++){let b=bindings[_i94];let scopes=b.scope?b.scope.split(" "):["editor"];if(b.any)for(let _i95=0,_length95=scopes.length;_i95<_length95;_i95++){let scope=scopes[_i95];let scopeObj=bound[scope]||(bound[scope]=Object.create(null));if(!scopeObj._any)scopeObj._any={preventDefault:false,stopPropagation:false,run:[]};for(let key in scopeObj)scopeObj[key].run.push(b.any);}let name=b[platform]||b.key;if(!name)continue;for(let _i96=0,_length96=scopes.length;_i96<_length96;_i96++){let scope=scopes[_i96];add(scope,name,b.run,b.preventDefault,b.stopPropagation);if(b.shift)add(scope,"Shift-"+name,b.shift,b.preventDefault,b.stopPropagation);}}return bound;}function runHandlers(map,event,view,scope){let name=keyName(event);let charCode=codePointAt(name,0),isChar=codePointSize(charCode)==name.length&&name!=" ";let prefix="",handled=false,prevented=false,stopPropagation=false;if(storedPrefix&&storedPrefix.view==view&&storedPrefix.scope==scope){prefix=storedPrefix.prefix+" ";if(modifierCodes.indexOf(event.keyCode)<0){prevented=true;storedPrefix=null;}}let ran=new Set();let runFor=binding=>{if(binding){for(let _i97=0,_binding$run=binding.run,_length97=_binding$run.length;_i97<_length97;_i97++){let cmd=_binding$run[_i97];if(!ran.has(cmd)){ran.add(cmd);if(cmd(view,event)){if(binding.stopPropagation)stopPropagation=true;return true;}}}if(binding.preventDefault){if(binding.stopPropagation)stopPropagation=true;prevented=true;}}return false;};let scopeObj=map[scope],baseName,shiftName;if(scopeObj){if(runFor(scopeObj[prefix+modifiers(name,event,!isChar)])){handled=true;}else if(isChar&&(event.altKey||event.metaKey||event.ctrlKey)&&!(browser.windows&&event.ctrlKey&&event.altKey)&&(baseName=base[event.keyCode])&&baseName!=name){if(runFor(scopeObj[prefix+modifiers(baseName,event,true)])){handled=true;}else if(event.shiftKey&&(shiftName=shift[event.keyCode])!=name&&shiftName!=baseName&&runFor(scopeObj[prefix+modifiers(shiftName,event,false)])){handled=true;}}else if(isChar&&event.shiftKey&&runFor(scopeObj[prefix+modifiers(name,event,true)])){handled=true;}if(!handled&&runFor(scopeObj._any))handled=true;}if(prevented)handled=true;if(handled&&stopPropagation)event.stopPropagation();return handled;}class RectangleMarker{constructor(className,left,top,width,height){this.className=className;this.left=left;this.top=top;this.width=width;this.height=height;}draw(){let elt=document.createElement("div");elt.className=this.className;this.adjust(elt);return elt;}update(elt,prev){if(prev.className!=this.className)return false;this.adjust(elt);return true;}adjust(elt){elt.style.left=this.left+"px";elt.style.top=this.top+"px";if(this.width!=null)elt.style.width=this.width+"px";elt.style.height=this.height+"px";}eq(p){return this.left==p.left&&this.top==p.top&&this.width==p.width&&this.height==p.height&&this.className==p.className;}static forRange(view,className,range){if(range.empty){let pos=view.coordsAtPos(range.head,range.assoc||1);if(!pos)return[];let base=getBase(view);return[new RectangleMarker(className,pos.left-base.left,pos.top-base.top,null,pos.bottom-pos.top)];}else{return rectanglesForRange(view,className,range);}}}function getBase(view){let rect=view.scrollDOM.getBoundingClientRect();let left=view.textDirection==Direction.LTR?rect.left:rect.right-view.scrollDOM.clientWidth;return{left:left-view.scrollDOM.scrollLeft,top:rect.top-view.scrollDOM.scrollTop};}function wrappedLine(view,pos,inside){let range=EditorSelection.cursor(pos);return{from:Math.max(inside.from,view.moveToLineBoundary(range,false,true).from),to:Math.min(inside.to,view.moveToLineBoundary(range,true,true).from),type:BlockType.Text};}function rectanglesForRange(view,className,range){if(range.to<=view.viewport.from||range.from>=view.viewport.to)return[];let from=Math.max(range.from,view.viewport.from),to=Math.min(range.to,view.viewport.to);let ltr=view.textDirection==Direction.LTR;let content=view.contentDOM,contentRect=content.getBoundingClientRect(),base=getBase(view);let lineElt=content.querySelector(".cm-line"),lineStyle=lineElt&&window.getComputedStyle(lineElt);let leftSide=contentRect.left+(lineStyle?parseInt(lineStyle.paddingLeft)+Math.min(0,parseInt(lineStyle.textIndent)):0);let rightSide=contentRect.right-(lineStyle?parseInt(lineStyle.paddingRight):0);let startBlock=blockAt(view,from),endBlock=blockAt(view,to);let visualStart=startBlock.type==BlockType.Text?startBlock:null;let visualEnd=endBlock.type==BlockType.Text?endBlock:null;if(visualStart&&(view.lineWrapping||startBlock.widgetLineBreaks))visualStart=wrappedLine(view,from,visualStart);if(visualEnd&&(view.lineWrapping||endBlock.widgetLineBreaks))visualEnd=wrappedLine(view,to,visualEnd);if(visualStart&&visualEnd&&visualStart.from==visualEnd.from){return pieces(drawForLine(range.from,range.to,visualStart));}else{let top=visualStart?drawForLine(range.from,null,visualStart):drawForWidget(startBlock,false);let bottom=visualEnd?drawForLine(null,range.to,visualEnd):drawForWidget(endBlock,true);let between=[];if((visualStart||startBlock).to<(visualEnd||endBlock).from-(visualStart&&visualEnd?1:0)||startBlock.widgetLineBreaks>1&&top.bottom+view.defaultLineHeight/2start&&r.from=endPos)break;if(spanTo>pos)addSpan(Math.max(spanFrom,pos),from==null&&spanFrom<=start,Math.min(spanTo,endPos),to==null&&spanTo>=end,span.dir);}pos=docLine.to+1;if(pos>=endPos)break;}}}if(horizontal.length==0)addSpan(start,from==null,end,to==null,view.textDirection);return{top,bottom,horizontal};}function drawForWidget(block,top){let y=contentRect.top+(top?block.top:block.bottom);return{top:y,bottom:y,horizontal:[]};}}function sameMarker(a,b){return a.constructor==b.constructor&&a.eq(b);}class LayerView{constructor(view,layer){this.view=view;this.layer=layer;this.drawn=[];this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)};this.dom=view.scrollDOM.appendChild(document.createElement("div"));this.dom.classList.add("cm-layer");if(layer.above)this.dom.classList.add("cm-layer-above");if(layer.class)this.dom.classList.add(layer.class);this.dom.setAttribute("aria-hidden","true");this.setOrder(view.state);view.requestMeasure(this.measureReq);if(layer.mount)layer.mount(this.dom,view);}update(update){if(update.startState.facet(layerOrder)!=update.state.facet(layerOrder))this.setOrder(update.state);if(this.layer.update(update,this.dom)||update.geometryChanged)update.view.requestMeasure(this.measureReq);}setOrder(state){let pos=0,order=state.facet(layerOrder);while(pos!sameMarker(p,this.drawn[i]))){let old=this.dom.firstChild,oldI=0;for(let _i100=0,_length100=markers.length;_i100<_length100;_i100++){let marker=markers[_i100];if(marker.update&&old&&marker.constructor&&this.drawn[oldI].constructor&&marker.update(old,this.drawn[oldI])){old=old.nextSibling;oldI++;}else{this.dom.insertBefore(marker.draw(),old);}}while(old){let next=old.nextSibling;old.remove();old=next;}this.drawn=markers;}}destroy(){if(this.layer.destroy)this.layer.destroy(this.dom,this.view);this.dom.remove();}}const layerOrder=Facet.define();function layer(config){return[ViewPlugin.define(v=>new LayerView(v,config)),layerOrder.of(config)];}const CanHidePrimary=!browser.ios;const selectionConfig=Facet.define({combine(configs){return combineConfig(configs,{cursorBlinkRate:1200,drawRangeCursor:true},{cursorBlinkRate:(a,b)=>Math.min(a,b),drawRangeCursor:(a,b)=>a||b});}});function drawSelection(config={}){return[selectionConfig.of(config),cursorLayer,selectionLayer,hideNativeSelection,nativeSelectionHidden.of(true)];}function configChanged$1(update){return update.startState.facet(selectionConfig)!=update.state.facet(selectionConfig);}const cursorLayer=layer({above:true,markers(view){let{state}=view,conf=state.facet(selectionConfig);let cursors=[];for(let _i101=0,_state$selection$rang3=state.selection.ranges,_length101=_state$selection$rang3.length;_i101<_length101;_i101++){let r=_state$selection$rang3[_i101];let prim=r==state.selection.main;if(r.empty?!prim||CanHidePrimary:conf.drawRangeCursor){let className=prim?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary";let cursor=r.empty?r:EditorSelection.cursor(r.head,r.head>r.anchor?-1:1);for(let _i102=0,_RectangleMarker$forR=RectangleMarker.forRange(view,className,cursor),_length102=_RectangleMarker$forR.length;_i102<_length102;_i102++){let piece=_RectangleMarker$forR[_i102];cursors.push(piece);}}}return cursors;},update(update,dom){if(update.transactions.some(tr=>tr.selection))dom.style.animationName=dom.style.animationName=="cm-blink"?"cm-blink2":"cm-blink";let confChange=configChanged$1(update);if(confChange)setBlinkRate(update.state,dom);return update.docChanged||update.selectionSet||confChange;},mount(dom,view){setBlinkRate(view.state,dom);},class:"cm-cursorLayer"});function setBlinkRate(state,dom){dom.style.animationDuration=state.facet(selectionConfig).cursorBlinkRate+"ms";}const selectionLayer=layer({above:false,markers(view){return view.state.selection.ranges.map(r=>r.empty?[]:RectangleMarker.forRange(view,"cm-selectionBackground",r)).reduce((a,b)=>a.concat(b));},update(update,dom){return update.docChanged||update.selectionSet||update.viewportChanged||configChanged$1(update);},class:"cm-selectionLayer"});const themeSpec={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};if(CanHidePrimary)themeSpec[".cm-line"].caretColor="transparent !important";const hideNativeSelection=Prec.highest(EditorView.theme(themeSpec));const setDropCursorPos=StateEffect.define({map(pos,mapping){return pos==null?null:mapping.mapPos(pos);}});const dropCursorPos=StateField.define({create(){return null;},update(pos,tr){if(pos!=null)pos=tr.changes.mapPos(pos);return tr.effects.reduce((pos,e)=>e.is(setDropCursorPos)?e.value:pos,pos);}});const drawDropCursor=ViewPlugin.fromClass(class{constructor(view){this.view=view;this.cursor=null;this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)};}update(update){var _a;let cursorPos=update.state.field(dropCursorPos);if(cursorPos==null){if(this.cursor!=null){(_a=this.cursor)===null||_a===void 0?void 0:_a.remove();this.cursor=null;}}else{if(!this.cursor){this.cursor=this.view.scrollDOM.appendChild(document.createElement("div"));this.cursor.className="cm-dropCursor";}if(update.startState.field(dropCursorPos)!=cursorPos||update.docChanged||update.geometryChanged)this.view.requestMeasure(this.measureReq);}}readPos(){let pos=this.view.state.field(dropCursorPos);let rect=pos!=null&&this.view.coordsAtPos(pos);if(!rect)return null;let outer=this.view.scrollDOM.getBoundingClientRect();return{left:rect.left-outer.left+this.view.scrollDOM.scrollLeft,top:rect.top-outer.top+this.view.scrollDOM.scrollTop,height:rect.bottom-rect.top};}drawCursor(pos){if(this.cursor){if(pos){this.cursor.style.left=pos.left+"px";this.cursor.style.top=pos.top+"px";this.cursor.style.height=pos.height+"px";}else{this.cursor.style.left="-100000px";}}}destroy(){if(this.cursor)this.cursor.remove();}setDropPos(pos){if(this.view.state.field(dropCursorPos)!=pos)this.view.dispatch({effects:setDropCursorPos.of(pos)});}},{eventHandlers:{dragover(event){this.setDropPos(this.view.posAtCoords({x:event.clientX,y:event.clientY}));},dragleave(event){if(event.target==this.view.contentDOM||!this.view.contentDOM.contains(event.relatedTarget))this.setDropPos(null);},dragend(){this.setDropPos(null);},drop(){this.setDropPos(null);}}});function dropCursor(){return[dropCursorPos,drawDropCursor];}function iterMatches(doc,re,from,to,f){re.lastIndex=0;for(let cursor=doc.iterRange(from,to),pos=from,m;!cursor.next().done;pos+=cursor.value.length){if(!cursor.lineBreak)while(m=re.exec(cursor.value))f(pos+m.index,m);}}function matchRanges(view,maxLength){let visible=view.visibleRanges;if(visible.length==1&&visible[0].from==view.viewport.from&&visible[0].to==view.viewport.to)return visible;let result=[];for(let _i103=0,_length103=visible.length;_i103<_length103;_i103++){let{from,to}=visible[_i103];from=Math.max(view.state.doc.lineAt(from).from,from-maxLength);to=Math.min(view.state.doc.lineAt(to).to,to+maxLength);if(result.length&&result[result.length-1].to>=from)result[result.length-1].to=to;else result.push({from,to});}return result;}class MatchDecorator{constructor(config){const{regexp,decoration,decorate,boundary,maxLength=1000}=config;if(!regexp.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");this.regexp=regexp;if(decorate){this.addMatch=(match,view,from,add)=>decorate(add,from,from+match[0].length,match,view);}else if(typeof decoration=="function"){this.addMatch=(match,view,from,add)=>{let deco=decoration(match,view,from);if(deco)add(from,from+match[0].length,deco);};}else if(decoration){this.addMatch=(match,_view,from,add)=>add(from,from+match[0].length,decoration);}else{throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");}this.boundary=boundary;this.maxLength=maxLength;}createDeco(view){let build=new RangeSetBuilder(),add=build.add.bind(build);for(let _i104=0,_matchRanges=matchRanges(view,this.maxLength),_length104=_matchRanges.length;_i104<_length104;_i104++){let{from,to}=_matchRanges[_i104];iterMatches(view.state.doc,this.regexp,from,to,(from,m)=>this.addMatch(m,view,from,add));}return build.finish();}updateDeco(update,deco){let changeFrom=1e9,changeTo=-1;if(update.docChanged)update.changes.iterChanges((_f,_t,from,to)=>{if(to>update.view.viewport.from&&from1000)return this.createDeco(update.view);if(changeTo>-1)return this.updateRange(update.view,deco.map(update.changes),changeFrom,changeTo);return deco;}updateRange(view,deco,updateFrom,updateTo){for(let _i105=0,_view$visibleRanges2=view.visibleRanges,_length105=_view$visibleRanges2.length;_i105<_length105;_i105++){let r=_view$visibleRanges2[_i105];let from=Math.max(r.from,updateFrom),to=Math.min(r.to,updateTo);if(to>from){let fromLine=view.state.doc.lineAt(from),toLine=fromLine.tofromLine.from;from--)if(this.boundary.test(fromLine.text[from-1-fromLine.from])){start=from;break;}for(;toranges.push(deco.range(from,to));if(fromLine==toLine){this.regexp.lastIndex=start-fromLine.from;while((m=this.regexp.exec(fromLine.text))&&m.indexthis.addMatch(m,view,from,add));}deco=deco.update({filterFrom:start,filterTo:end,filter:(from,to)=>fromend,add:ranges});}}return deco;}}const UnicodeRegexpSupport=/x/.unicode!=null?"gu":"g";const Specials=new RegExp("[\u0000-\u0008\u000a-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\u2066\u2067\u2069\ufeff\ufff9-\ufffc]",UnicodeRegexpSupport);const Names={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let _supportsTabSize=null;function supportsTabSize(){var _a;if(_supportsTabSize==null&&typeof document!="undefined"&&document.body){let styles=document.body.style;_supportsTabSize=((_a=styles.tabSize)!==null&&_a!==void 0?_a:styles.MozTabSize)!=null;}return _supportsTabSize||false;}const specialCharConfig=Facet.define({combine(configs){let config=combineConfig(configs,{render:null,specialChars:Specials,addSpecialChars:null});if(config.replaceTabs=!supportsTabSize())config.specialChars=new RegExp("\t|"+config.specialChars.source,UnicodeRegexpSupport);if(config.addSpecialChars)config.specialChars=new RegExp(config.specialChars.source+"|"+config.addSpecialChars.source,UnicodeRegexpSupport);return config;}});function highlightSpecialChars(config={}){return[specialCharConfig.of(config),specialCharPlugin()];}let _plugin=null;function specialCharPlugin(){return _plugin||(_plugin=ViewPlugin.fromClass(class{constructor(view){this.view=view;this.decorations=Decoration.none;this.decorationCache=Object.create(null);this.decorator=this.makeDecorator(view.state.facet(specialCharConfig));this.decorations=this.decorator.createDeco(view);}makeDecorator(conf){return new MatchDecorator({regexp:conf.specialChars,decoration:(m,view,pos)=>{let{doc}=view.state;let code=codePointAt(m[0],0);if(code==9){let line=doc.lineAt(pos);let size=view.state.tabSize,col=countColumn(line.text,size,pos-line.from);return Decoration.replace({widget:new TabWidget((size-col%size)*this.view.defaultCharacterWidth)});}return this.decorationCache[code]||(this.decorationCache[code]=Decoration.replace({widget:new SpecialCharWidget(conf,code)}));},boundary:conf.replaceTabs?undefined:/[^]/});}update(update){let conf=update.state.facet(specialCharConfig);if(update.startState.facet(specialCharConfig)!=conf){this.decorator=this.makeDecorator(conf);this.decorations=this.decorator.createDeco(update.view);}else{this.decorations=this.decorator.updateDeco(update,this.decorations);}}},{decorations:v=>v.decorations}));}const DefaultPlaceholder="\u2022";function placeholder$1(code){if(code>=32)return DefaultPlaceholder;if(code==10)return"\u2424";return String.fromCharCode(9216+code);}class SpecialCharWidget extends WidgetType{constructor(options,code){super();this.options=options;this.code=code;}eq(other){return other.code==this.code;}toDOM(view){let ph=placeholder$1(this.code);let desc=view.state.phrase("Control character")+" "+(Names[this.code]||"0x"+this.code.toString(16));let custom=this.options.render&&this.options.render(this.code,desc,ph);if(custom)return custom;let span=document.createElement("span");span.textContent=ph;span.title=desc;span.setAttribute("aria-label",desc);span.className="cm-specialChar";return span;}ignoreEvent(){return false;}}class TabWidget extends WidgetType{constructor(width){super();this.width=width;}eq(other){return other.width==this.width;}toDOM(){let span=document.createElement("span");span.textContent="\t";span.className="cm-tab";span.style.width=this.width+"px";return span;}ignoreEvent(){return false;}}const plugin=ViewPlugin.fromClass(class{constructor(){this.height=1000;this.attrs={style:"padding-bottom: 1000px"};}update(update){let{view}=update;let height=view.viewState.editorHeight-view.defaultLineHeight-view.documentPadding.top-0.5;if(height>=0&&height!=this.height){this.height=height;this.attrs={style:`padding-bottom: ${height}px`};}}});function scrollPastEnd(){return[plugin,contentAttributes.of(view=>{var _a;return((_a=view.plugin(plugin))===null||_a===void 0?void 0:_a.attrs)||null;})];}function highlightActiveLine(){return activeLineHighlighter;}const lineDeco=Decoration.line({class:"cm-activeLine"});const activeLineHighlighter=ViewPlugin.fromClass(class{constructor(view){this.decorations=this.getDeco(view);}update(update){if(update.docChanged||update.selectionSet)this.decorations=this.getDeco(update.view);}getDeco(view){let lastLineStart=-1,deco=[];for(let _i106=0,_view$state$selection=view.state.selection.ranges,_length106=_view$state$selection.length;_i106<_length106;_i106++){let r=_view$state$selection[_i106];let line=view.lineBlockAt(r.head);if(line.from>lastLineStart){deco.push(lineDeco.range(line.from));lastLineStart=line.from;}}return Decoration.set(deco);}},{decorations:v=>v.decorations});class Placeholder extends WidgetType{constructor(content){super();this.content=content;}toDOM(){let wrap=document.createElement("span");wrap.className="cm-placeholder";wrap.style.pointerEvents="none";wrap.appendChild(typeof this.content=="string"?document.createTextNode(this.content):this.content);if(typeof this.content=="string")wrap.setAttribute("aria-label","placeholder "+this.content);else wrap.setAttribute("aria-hidden","true");return wrap;}coordsAt(dom){let rects=dom.firstChild?clientRectsFor(dom.firstChild):[];if(!rects.length)return null;let style=window.getComputedStyle(dom.parentNode);let rect=flattenRect(rects[0],style.direction!="rtl");let lineHeight=parseInt(style.lineHeight);if(rect.bottom-rect.top>lineHeight*1.5)return{left:rect.left,right:rect.right,top:rect.top,bottom:rect.top+lineHeight};return rect;}ignoreEvent(){return false;}}function placeholder(content){return ViewPlugin.fromClass(class{constructor(view){this.view=view;this.placeholder=content?Decoration.set([Decoration.widget({widget:new Placeholder(content),side:1}).range(0)]):Decoration.none;}get decorations(){return this.view.state.doc.length?Decoration.none:this.placeholder;}},{decorations:v=>v.decorations});}const MaxOff=2000;function rectangleFor(state,a,b){let startLine=Math.min(a.line,b.line),endLine=Math.max(a.line,b.line);let ranges=[];if(a.off>MaxOff||b.off>MaxOff||a.col<0||b.col<0){let startOff=Math.min(a.off,b.off),endOff=Math.max(a.off,b.off);for(let i=startLine;i<=endLine;i++){let line=state.doc.line(i);if(line.length<=endOff)ranges.push(EditorSelection.range(line.from+startOff,line.to+endOff));}}else{let startCol=Math.min(a.col,b.col),endCol=Math.max(a.col,b.col);for(let i=startLine;i<=endLine;i++){let line=state.doc.line(i);let start=findColumn(line.text,startCol,state.tabSize,true);if(start<0){ranges.push(EditorSelection.cursor(line.to));}else{let end=findColumn(line.text,endCol,state.tabSize);ranges.push(EditorSelection.range(line.from+start,line.from+end));}}}return ranges;}function absoluteColumn(view,x){let ref=view.coordsAtPos(view.viewport.from);return ref?Math.round(Math.abs((ref.left-x)/view.defaultCharacterWidth)):-1;}function getPos(view,event){let offset=view.posAtCoords({x:event.clientX,y:event.clientY},false);let line=view.state.doc.lineAt(offset),off=offset-line.from;let col=off>MaxOff?-1:off==line.length?absoluteColumn(view,event.clientX):countColumn(line.text,view.state.tabSize,offset-line.from);return{line:line.number,col,off};}function rectangleSelectionStyle(view,event){let start=getPos(view,event),startSel=view.state.selection;if(!start)return null;return{update(update){if(update.docChanged){let newStart=update.changes.mapPos(update.startState.doc.line(start.line).from);let newLine=update.state.doc.lineAt(newStart);start={line:newLine.number,col:start.col,off:Math.min(start.off,newLine.length)};startSel=startSel.map(update.changes);}},get(event,_extend,multiple){let cur=getPos(view,event);if(!cur)return startSel;let ranges=rectangleFor(view.state,start,cur);if(!ranges.length)return startSel;if(multiple)return EditorSelection.create(ranges.concat(startSel.ranges));else return EditorSelection.create(ranges);}};}function rectangularSelection(options){let filter=(options===null||options===void 0?void 0:options.eventFilter)||(e=>e.altKey&&e.button==0);return EditorView.mouseSelectionStyle.of((view,event)=>filter(event)?rectangleSelectionStyle(view,event):null);}const keys={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]};const showCrosshair={style:"cursor: crosshair"};function crosshairCursor(options={}){let[code,getter]=keys[options.key||"Alt"];let plugin=ViewPlugin.fromClass(class{constructor(view){this.view=view;this.isDown=false;}set(isDown){if(this.isDown!=isDown){this.isDown=isDown;this.view.update([]);}}},{eventHandlers:{keydown(e){this.set(e.keyCode==code||getter(e));},keyup(e){if(e.keyCode==code||!getter(e))this.set(false);},mousemove(e){this.set(getter(e));}}});return[plugin,EditorView.contentAttributes.of(view=>{var _a;return((_a=view.plugin(plugin))===null||_a===void 0?void 0:_a.isDown)?showCrosshair:null;})];}const Outside="-10000px";class TooltipViewManager{constructor(view,facet,createTooltipView){this.facet=facet;this.createTooltipView=createTooltipView;this.input=view.state.facet(facet);this.tooltips=this.input.filter(t=>t);this.tooltipViews=this.tooltips.map(createTooltipView);}update(update){var _a;let input=update.state.facet(this.facet);let tooltips=input.filter(x=>x);if(input===this.input){for(let _i107=0,_this$tooltipViews=this.tooltipViews,_length107=_this$tooltipViews.length;_i107<_length107;_i107++){let t=_this$tooltipViews[_i107];if(t.update)t.update(update);}return false;}let tooltipViews=[];for(let i=0;i{var _a,_b,_c;return{position:browser.ios?"absolute":((_a=values.find(conf=>conf.position))===null||_a===void 0?void 0:_a.position)||"fixed",parent:((_b=values.find(conf=>conf.parent))===null||_b===void 0?void 0:_b.parent)||null,tooltipSpace:((_c=values.find(conf=>conf.tooltipSpace))===null||_c===void 0?void 0:_c.tooltipSpace)||windowSpace};}});const knownHeight=new WeakMap();const tooltipPlugin=ViewPlugin.fromClass(class{constructor(view){this.view=view;this.inView=true;this.lastTransaction=0;this.measureTimeout=-1;let config=view.state.facet(tooltipConfig);this.position=config.position;this.parent=config.parent;this.classes=view.themeClasses;this.createContainer();this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this};this.manager=new TooltipViewManager(view,showTooltip,t=>this.createTooltip(t));this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(entries=>{if(Date.now()>this.lastTransaction-50&&entries.length>0&&entries[entries.length-1].intersectionRatio<1)this.measureSoon();},{threshold:[1]}):null;this.observeIntersection();view.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this));this.maybeMeasure();}createContainer(){if(this.parent){this.container=document.createElement("div");this.container.style.position="relative";this.container.className=this.view.themeClasses;this.parent.appendChild(this.container);}else{this.container=this.view.dom;}}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let _i109=0,_this$manager$tooltip=this.manager.tooltipViews,_length109=_this$manager$tooltip.length;_i109<_length109;_i109++){let tooltip=_this$manager$tooltip[_i109];this.intersectionObserver.observe(tooltip.dom);}}}measureSoon(){if(this.measureTimeout<0)this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1;this.maybeMeasure();},50);}update(update){if(update.transactions.length)this.lastTransaction=Date.now();let updated=this.manager.update(update);if(updated)this.observeIntersection();let shouldMeasure=updated||update.geometryChanged;let newConfig=update.state.facet(tooltipConfig);if(newConfig.position!=this.position){this.position=newConfig.position;for(let _i110=0,_this$manager$tooltip2=this.manager.tooltipViews,_length110=_this$manager$tooltip2.length;_i110<_length110;_i110++){let t=_this$manager$tooltip2[_i110];t.dom.style.position=this.position;}shouldMeasure=true;}if(newConfig.parent!=this.parent){if(this.parent)this.container.remove();this.parent=newConfig.parent;this.createContainer();for(let _i111=0,_this$manager$tooltip3=this.manager.tooltipViews,_length111=_this$manager$tooltip3.length;_i111<_length111;_i111++){let t=_this$manager$tooltip3[_i111];this.container.appendChild(t.dom);}shouldMeasure=true;}else if(this.parent&&this.view.themeClasses!=this.classes){this.classes=this.container.className=this.view.themeClasses;}if(shouldMeasure)this.maybeMeasure();}createTooltip(tooltip){let tooltipView=tooltip.create(this.view);tooltipView.dom.classList.add("cm-tooltip");if(tooltip.arrow&&!tooltipView.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let arrow=document.createElement("div");arrow.className="cm-tooltip-arrow";tooltipView.dom.appendChild(arrow);}tooltipView.dom.style.position=this.position;tooltipView.dom.style.top=Outside;this.container.appendChild(tooltipView.dom);if(tooltipView.mount)tooltipView.mount(this.view);return tooltipView;}destroy(){var _a,_b;this.view.win.removeEventListener("resize",this.measureSoon);for(let _i112=0,_this$manager$tooltip4=this.manager.tooltipViews,_length112=_this$manager$tooltip4.length;_i112<_length112;_i112++){let tooltipView=_this$manager$tooltip4[_i112];tooltipView.dom.remove();(_a=tooltipView.destroy)===null||_a===void 0?void 0:_a.call(tooltipView);}(_b=this.intersectionObserver)===null||_b===void 0?void 0:_b.disconnect();clearTimeout(this.measureTimeout);}readMeasure(){let editor=this.view.dom.getBoundingClientRect();return{editor,parent:this.parent?this.container.getBoundingClientRect():editor,pos:this.manager.tooltips.map((t,i)=>{let tv=this.manager.tooltipViews[i];return tv.getCoords?tv.getCoords(t.pos):this.view.coordsAtPos(t.pos);}),size:this.manager.tooltipViews.map(({dom})=>dom.getBoundingClientRect()),space:this.view.state.facet(tooltipConfig).tooltipSpace(this.view)};}writeMeasure(measured){var _a;let{editor,space}=measured;let others=[];for(let i=0;i=Math.min(editor.bottom,space.bottom)||pos.rightMath.min(editor.right,space.right)+.1){dom.style.top=Outside;continue;}let arrow=tooltip.arrow?tView.dom.querySelector(".cm-tooltip-arrow"):null;let arrowHeight=arrow?7:0;let width=size.right-size.left,height=(_a=knownHeight.get(tView))!==null&&_a!==void 0?_a:size.bottom-size.top;let offset=tView.offset||noOffset,ltr=this.view.textDirection==Direction.LTR;let left=size.width>space.right-space.left?ltr?space.left:space.right-size.width:ltr?Math.min(pos.left-(arrow?14:0)+offset.x,space.right-width):Math.max(space.left,pos.left-width+(arrow?14:0)-offset.x);let above=!!tooltip.above;if(!tooltip.strictSide&&(above?pos.top-(size.bottom-size.top)-offset.yspace.bottom)&&above==space.bottom-pos.bottom>pos.top-space.top)above=!above;let spaceVert=(above?pos.top-space.top:space.bottom-pos.bottom)-arrowHeight;if(spaceVertleft&&r.toptop)top=above?r.top-height-2-arrowHeight:r.bottom+arrowHeight+2;}if(this.position=="absolute"){dom.style.top=top-measured.parent.top+"px";dom.style.left=left-measured.parent.left+"px";}else{dom.style.top=top+"px";dom.style.left=left+"px";}if(arrow)arrow.style.left=`${pos.left+(ltr?offset.x:-offset.x)-(left+14-7)}px`;if(tView.overlap!==true)others.push({left,top,right,bottom:top+height});dom.classList.toggle("cm-tooltip-above",above);dom.classList.toggle("cm-tooltip-below",!above);if(tView.positioned)tView.positioned(measured.space);}}maybeMeasure(){if(this.manager.tooltips.length){if(this.view.inView)this.view.requestMeasure(this.measureReq);if(this.inView!=this.view.inView){this.inView=this.view.inView;if(!this.inView)for(let _i114=0,_this$manager$tooltip5=this.manager.tooltipViews,_length114=_this$manager$tooltip5.length;_i114<_length114;_i114++){let tv=_this$manager$tooltip5[_i114];tv.dom.style.top=Outside;}}}}},{eventHandlers:{scroll(){this.maybeMeasure();}}});const baseTheme$5=EditorView.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:`${7}px`,width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:`${7}px solid transparent`,borderRight:`${7}px solid transparent`},".cm-tooltip-above &":{bottom:`-${7}px`,"&:before":{borderTop:`${7}px solid #bbb`},"&:after":{borderTop:`${7}px solid #f5f5f5`,bottom:"1px"}},".cm-tooltip-below &":{top:`-${7}px`,"&:before":{borderBottom:`${7}px solid #bbb`},"&:after":{borderBottom:`${7}px solid #f5f5f5`,top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}});const noOffset={x:0,y:0};const showTooltip=Facet.define({enables:[tooltipPlugin,baseTheme$5]});const showHoverTooltip=Facet.define();class HoverTooltipHost{static create(view){return new HoverTooltipHost(view);}constructor(view){this.view=view;this.mounted=false;this.dom=document.createElement("div");this.dom.classList.add("cm-tooltip-hover");this.manager=new TooltipViewManager(view,showHoverTooltip,t=>this.createHostedView(t));}createHostedView(tooltip){let hostedView=tooltip.create(this.view);hostedView.dom.classList.add("cm-tooltip-section");this.dom.appendChild(hostedView.dom);if(this.mounted&&hostedView.mount)hostedView.mount(this.view);return hostedView;}mount(view){for(let _i115=0,_this$manager$tooltip6=this.manager.tooltipViews,_length115=_this$manager$tooltip6.length;_i115<_length115;_i115++){let hostedView=_this$manager$tooltip6[_i115];if(hostedView.mount)hostedView.mount(view);}this.mounted=true;}positioned(space){for(let _i116=0,_this$manager$tooltip7=this.manager.tooltipViews,_length116=_this$manager$tooltip7.length;_i116<_length116;_i116++){let hostedView=_this$manager$tooltip7[_i116];if(hostedView.positioned)hostedView.positioned(space);}}update(update){this.manager.update(update);}destroy(){var _a;for(let _i117=0,_this$manager$tooltip8=this.manager.tooltipViews,_length117=_this$manager$tooltip8.length;_i117<_length117;_i117++){let t=_this$manager$tooltip8[_i117];(_a=t.destroy)===null||_a===void 0?void 0:_a.call(t);}}}const showHoverTooltipHost=showTooltip.compute([showHoverTooltip],state=>{let tooltips=state.facet(showHoverTooltip).filter(t=>t);if(tooltips.length===0)return null;return{pos:Math.min(...tooltips.map(t=>t.pos)),end:Math.max(...tooltips.filter(t=>t.end!=null).map(t=>t.end)),create:HoverTooltipHost.create,above:tooltips[0].above,arrow:tooltips.some(t=>t.arrow)};});class HoverPlugin{constructor(view,source,field,setHover,hoverTime){this.view=view;this.source=source;this.field=field;this.setHover=setHover;this.hoverTime=hoverTime;this.hoverTimeout=-1;this.restartTimeout=-1;this.pending=null;this.lastMove={x:0,y:0,target:view.dom,time:0};this.checkHover=this.checkHover.bind(this);view.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this));view.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this));}update(){if(this.pending){this.pending=null;clearTimeout(this.restartTimeout);this.restartTimeout=setTimeout(()=>this.startHover(),20);}}get active(){return this.view.state.field(this.field);}checkHover(){this.hoverTimeout=-1;if(this.active)return;let hovered=Date.now()-this.lastMove.time;if(hoveredposCoords.bottom||lastMove.xposCoords.right+this.view.defaultCharacterWidth)return;let bidi=this.view.bidiSpans(this.view.state.doc.lineAt(pos)).find(s=>s.from<=pos&&s.to>=pos);let rtl=bidi&&bidi.dir==Direction.RTL?-1:1;let open=this.source(this.view,pos,lastMove.x{if(this.pending==pending){this.pending=null;if(result)this.view.dispatch({effects:this.setHover.of(result)});}},e=>logException(this.view.state,e,"hover tooltip"));}else if(open){this.view.dispatch({effects:this.setHover.of(open)});}}mousemove(event){var _a;this.lastMove={x:event.clientX,y:event.clientY,target:event.target,time:Date.now()};if(this.hoverTimeout<0)this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime);let tooltip=this.active;if(tooltip&&!isInTooltip(this.lastMove.target)||this.pending){let{pos}=tooltip||this.pending,end=(_a=tooltip===null||tooltip===void 0?void 0:tooltip.end)!==null&&_a!==void 0?_a:pos;if(pos==end?this.view.posAtCoords(this.lastMove)!=pos:!isOverRange(this.view,pos,end,event.clientX,event.clientY,6)){this.view.dispatch({effects:this.setHover.of(null)});this.pending=null;}}}mouseleave(e){clearTimeout(this.hoverTimeout);this.hoverTimeout=-1;if(this.active&&!isInTooltip(e.relatedTarget))this.view.dispatch({effects:this.setHover.of(null)});}destroy(){clearTimeout(this.hoverTimeout);this.view.dom.removeEventListener("mouseleave",this.mouseleave);this.view.dom.removeEventListener("mousemove",this.mousemove);}}function isInTooltip(elt){for(let cur=elt;cur;cur=cur.parentNode)if(cur.nodeType==1&&cur.classList.contains("cm-tooltip"))return true;return false;}function isOverRange(view,from,to,x,y,margin){let range=document.createRange();let fromDOM=view.domAtPos(from),toDOM=view.domAtPos(to);range.setEnd(toDOM.node,toDOM.offset);range.setStart(fromDOM.node,fromDOM.offset);let rects=range.getClientRects();range.detach();for(let i=0;ishowHoverTooltip.from(f)});return[hoverState,ViewPlugin.define(view=>new HoverPlugin(view,source,hoverState,setHover,options.hoverTime||300)),showHoverTooltipHost];}function getTooltip(view,tooltip){let plugin=view.plugin(tooltipPlugin);if(!plugin)return null;let found=plugin.manager.tooltips.indexOf(tooltip);return found<0?null:plugin.manager.tooltipViews[found];}function hasHoverTooltips(state){return state.facet(showHoverTooltip).some(x=>x);}const closeHoverTooltipEffect=StateEffect.define();const closeHoverTooltips=closeHoverTooltipEffect.of(null);function repositionTooltips(view){var _a;(_a=view.plugin(tooltipPlugin))===null||_a===void 0?void 0:_a.maybeMeasure();}const panelConfig=Facet.define({combine(configs){let topContainer,bottomContainer;for(let _i119=0,_length119=configs.length;_i119<_length119;_i119++){let c=configs[_i119];topContainer=topContainer||c.topContainer;bottomContainer=bottomContainer||c.bottomContainer;}return{topContainer,bottomContainer};}});function panels(config){return config?[panelConfig.of(config)]:[];}function getPanel(view,panel){let plugin=view.plugin(panelPlugin);let index=plugin?plugin.specs.indexOf(panel):-1;return index>-1?plugin.panels[index]:null;}const panelPlugin=ViewPlugin.fromClass(class{constructor(view){this.input=view.state.facet(showPanel);this.specs=this.input.filter(s=>s);this.panels=this.specs.map(spec=>spec(view));let conf=view.state.facet(panelConfig);this.top=new PanelGroup(view,true,conf.topContainer);this.bottom=new PanelGroup(view,false,conf.bottomContainer);this.top.sync(this.panels.filter(p=>p.top));this.bottom.sync(this.panels.filter(p=>!p.top));for(let _i120=0,_this$panels=this.panels,_length120=_this$panels.length;_i120<_length120;_i120++){let p=_this$panels[_i120];p.dom.classList.add("cm-panel");if(p.mount)p.mount();}}update(update){let conf=update.state.facet(panelConfig);if(this.top.container!=conf.topContainer){this.top.sync([]);this.top=new PanelGroup(update.view,true,conf.topContainer);}if(this.bottom.container!=conf.bottomContainer){this.bottom.sync([]);this.bottom=new PanelGroup(update.view,false,conf.bottomContainer);}this.top.syncClasses();this.bottom.syncClasses();let input=update.state.facet(showPanel);if(input!=this.input){let specs=input.filter(x=>x);let panels=[],top=[],bottom=[],mount=[];for(let _i121=0,_length121=specs.length;_i121<_length121;_i121++){let spec=specs[_i121];let known=this.specs.indexOf(spec),panel;if(known<0){panel=spec(update.view);mount.push(panel);}else{panel=this.panels[known];if(panel.update)panel.update(update);}panels.push(panel);(panel.top?top:bottom).push(panel);}this.specs=specs;this.panels=panels;this.top.sync(top);this.bottom.sync(bottom);for(let _i122=0,_length122=mount.length;_i122<_length122;_i122++){let p=mount[_i122];p.dom.classList.add("cm-panel");if(p.mount)p.mount();}}else{for(let _i123=0,_this$panels2=this.panels,_length123=_this$panels2.length;_i123<_length123;_i123++){let p=_this$panels2[_i123];if(p.update)p.update(update);}}}destroy(){this.top.sync([]);this.bottom.sync([]);}},{provide:plugin=>EditorView.scrollMargins.of(view=>{let value=view.plugin(plugin);return value&&{top:value.top.scrollMargin(),bottom:value.bottom.scrollMargin()};})});class PanelGroup{constructor(view,top,container){this.view=view;this.top=top;this.container=container;this.dom=undefined;this.classes="";this.panels=[];this.syncClasses();}sync(panels){for(let _i124=0,_this$panels3=this.panels,_length124=_this$panels3.length;_i124<_length124;_i124++){let p=_this$panels3[_i124];if(p.destroy&&panels.indexOf(p)<0)p.destroy();}this.panels=panels;this.syncDOM();}syncDOM(){if(this.panels.length==0){if(this.dom){this.dom.remove();this.dom=undefined;}return;}if(!this.dom){this.dom=document.createElement("div");this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";this.dom.style[this.top?"top":"bottom"]="0";let parent=this.container||this.view.dom;parent.insertBefore(this.dom,this.top?parent.firstChild:null);}let curDOM=this.dom.firstChild;for(let _i125=0,_this$panels4=this.panels,_length125=_this$panels4.length;_i125<_length125;_i125++){let panel=_this$panels4[_i125];if(panel.dom.parentNode==this.dom){while(curDOM!=panel.dom)curDOM=rm$2(curDOM);curDOM=curDOM.nextSibling;}else{this.dom.insertBefore(panel.dom,curDOM);}}while(curDOM)curDOM=rm$2(curDOM);}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top);}syncClasses(){if(!this.container||this.classes==this.view.themeClasses)return;for(let _i126=0,_this$classes$split=this.classes.split(" "),_length126=_this$classes$split.length;_i126<_length126;_i126++){let cls=_this$classes$split[_i126];if(cls)this.container.classList.remove(cls);}for(let _i127=0,_this$classes$split2=(this.classes=this.view.themeClasses).split(" "),_length127=_this$classes$split2.length;_i127<_length127;_i127++){let cls=_this$classes$split2[_i127];if(cls)this.container.classList.add(cls);}}}function rm$2(node){let next=node.nextSibling;node.remove();return next;}const showPanel=Facet.define({enables:panelPlugin});class GutterMarker extends RangeValue{compare(other){return this==other||this.constructor==other.constructor&&this.eq(other);}eq(other){return false;}destroy(dom){}}GutterMarker.prototype.elementClass="";GutterMarker.prototype.toDOM=undefined;GutterMarker.prototype.mapMode=MapMode.TrackBefore;GutterMarker.prototype.startSide=GutterMarker.prototype.endSide=-1;GutterMarker.prototype.point=true;const gutterLineClass=Facet.define();const defaults$2={class:"",renderEmptyElements:false,elementStyle:"",markers:()=>RangeSet.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}};const activeGutters=Facet.define();function gutter(config){return[gutters(),activeGutters.of(Object.assign(Object.assign({},defaults$2),config))];}const unfixGutters=Facet.define({combine:values=>values.some(x=>x)});function gutters(config){let result=[gutterView];if(config&&config.fixed===false)result.push(unfixGutters.of(true));return result;}const gutterView=ViewPlugin.fromClass(class{constructor(view){this.view=view;this.prevViewport=view.viewport;this.dom=document.createElement("div");this.dom.className="cm-gutters";this.dom.setAttribute("aria-hidden","true");this.dom.style.minHeight=this.view.contentHeight+"px";this.gutters=view.state.facet(activeGutters).map(conf=>new SingleGutterView(view,conf));for(let _i128=0,_this$gutters=this.gutters,_length128=_this$gutters.length;_i128<_length128;_i128++){let gutter=_this$gutters[_i128];this.dom.appendChild(gutter.dom);}this.fixed=!view.state.facet(unfixGutters);if(this.fixed){this.dom.style.position="sticky";}this.syncGutters(false);view.scrollDOM.insertBefore(this.dom,view.contentDOM);}update(update){if(this.updateGutters(update)){let vpA=this.prevViewport,vpB=update.view.viewport;let vpOverlap=Math.min(vpA.to,vpB.to)-Math.max(vpA.from,vpB.from);this.syncGutters(vpOverlap<(vpB.to-vpB.from)*0.8);}if(update.geometryChanged)this.dom.style.minHeight=this.view.contentHeight+"px";if(this.view.state.facet(unfixGutters)!=!this.fixed){this.fixed=!this.fixed;this.dom.style.position=this.fixed?"sticky":"";}this.prevViewport=update.view.viewport;}syncGutters(detach){let after=this.dom.nextSibling;if(detach)this.dom.remove();let lineClasses=RangeSet.iter(this.view.state.facet(gutterLineClass),this.view.viewport.from);let classSet=[];let contexts=this.gutters.map(gutter=>new UpdateContext(gutter,this.view.viewport,-this.view.documentPadding.top));for(let _i129=0,_this$view$viewportLi=this.view.viewportLineBlocks,_length129=_this$view$viewportLi.length;_i129<_length129;_i129++){let line=_this$view$viewportLi[_i129];if(classSet.length)classSet=[];if(Array.isArray(line.type)){let first=true;for(let _i130=0,_line$type2=line.type,_length130=_line$type2.length;_i130<_length130;_i130++){let b=_line$type2[_i130];if(b.type==BlockType.Text&&first){advanceCursor(lineClasses,classSet,b.from);for(let _i131=0,_length131=contexts.length;_i131<_length131;_i131++){let cx=contexts[_i131];cx.line(this.view,b,classSet);}first=false;}else if(b.widget){for(let _i132=0,_length132=contexts.length;_i132<_length132;_i132++){let cx=contexts[_i132];cx.widget(this.view,b);}}}}else if(line.type==BlockType.Text){advanceCursor(lineClasses,classSet,line.from);for(let _i133=0,_length133=contexts.length;_i133<_length133;_i133++){let cx=contexts[_i133];cx.line(this.view,line,classSet);}}}for(let _i134=0,_length134=contexts.length;_i134<_length134;_i134++){let cx=contexts[_i134];cx.finish();}if(detach)this.view.scrollDOM.insertBefore(this.dom,after);}updateGutters(update){let prev=update.startState.facet(activeGutters),cur=update.state.facet(activeGutters);let change=update.docChanged||update.heightChanged||update.viewportChanged||!RangeSet.eq(update.startState.facet(gutterLineClass),update.state.facet(gutterLineClass),update.view.viewport.from,update.view.viewport.to);if(prev==cur){for(let _i135=0,_this$gutters2=this.gutters,_length135=_this$gutters2.length;_i135<_length135;_i135++){let gutter=_this$gutters2[_i135];if(gutter.update(update))change=true;}}else{change=true;let gutters=[];for(let _i136=0,_length136=cur.length;_i136<_length136;_i136++){let conf=cur[_i136];let known=prev.indexOf(conf);if(known<0){gutters.push(new SingleGutterView(this.view,conf));}else{this.gutters[known].update(update);gutters.push(this.gutters[known]);}}for(let _i137=0,_this$gutters3=this.gutters,_length137=_this$gutters3.length;_i137<_length137;_i137++){let g=_this$gutters3[_i137];g.dom.remove();if(gutters.indexOf(g)<0)g.destroy();}for(let _i138=0,_length138=gutters.length;_i138<_length138;_i138++){let g=gutters[_i138];this.dom.appendChild(g.dom);}this.gutters=gutters;}return change;}destroy(){for(let _i139=0,_this$gutters4=this.gutters,_length139=_this$gutters4.length;_i139<_length139;_i139++){let view=_this$gutters4[_i139];view.destroy();}this.dom.remove();}},{provide:plugin=>EditorView.scrollMargins.of(view=>{let value=view.plugin(plugin);if(!value||value.gutters.length==0||!value.fixed)return null;return view.textDirection==Direction.LTR?{left:value.dom.offsetWidth}:{right:value.dom.offsetWidth};})});function asArray(val){return Array.isArray(val)?val:[val];}function advanceCursor(cursor,collect,pos){while(cursor.value&&cursor.from<=pos){if(cursor.from==pos)collect.push(cursor.value);cursor.next();}}class UpdateContext{constructor(gutter,viewport,height){this.gutter=gutter;this.height=height;this.i=0;this.cursor=RangeSet.iter(gutter.markers,viewport.from);}addElement(view,block,markers){let{gutter}=this,above=block.top-this.height;if(this.i==gutter.elements.length){let newElt=new GutterElement(view,block.height,above,markers);gutter.elements.push(newElt);gutter.dom.appendChild(newElt.dom);}else{gutter.elements[this.i].update(view,block.height,above,markers);}this.height=block.bottom;this.i++;}line(view,line,extraMarkers){let localMarkers=[];advanceCursor(this.cursor,localMarkers,line.from);if(extraMarkers.length)localMarkers=localMarkers.concat(extraMarkers);let forLine=this.gutter.config.lineMarker(view,line,localMarkers);if(forLine)localMarkers.unshift(forLine);let gutter=this.gutter;if(localMarkers.length==0&&!gutter.config.renderEmptyElements)return;this.addElement(view,line,localMarkers);}widget(view,block){let marker=this.gutter.config.widgetMarker(view,block.widget,block);if(marker)this.addElement(view,block,[marker]);}finish(){let gutter=this.gutter;while(gutter.elements.length>this.i){let last=gutter.elements.pop();gutter.dom.removeChild(last.dom);last.destroy();}}}class SingleGutterView{constructor(view,config){this.view=view;this.config=config;this.elements=[];this.spacer=null;this.dom=document.createElement("div");this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let prop in config.domEventHandlers){this.dom.addEventListener(prop,event=>{let target=event.target,y;if(target!=this.dom&&this.dom.contains(target)){while(target.parentNode!=this.dom)target=target.parentNode;let rect=target.getBoundingClientRect();y=(rect.top+rect.bottom)/2;}else{y=event.clientY;}let line=view.lineBlockAtHeight(y-view.documentTop);if(config.domEventHandlers[prop](view,line,event))event.preventDefault();});}this.markers=asArray(config.markers(view));if(config.initialSpacer){this.spacer=new GutterElement(view,0,0,[config.initialSpacer(view)]);this.dom.appendChild(this.spacer.dom);this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none";}}update(update){let prevMarkers=this.markers;this.markers=asArray(this.config.markers(update.view));if(this.spacer&&this.config.updateSpacer){let updated=this.config.updateSpacer(this.spacer.markers[0],update);if(updated!=this.spacer.markers[0])this.spacer.update(update.view,0,0,[updated]);}let vp=update.view.viewport;return!RangeSet.eq(this.markers,prevMarkers,vp.from,vp.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(update):false);}destroy(){for(let _i140=0,_this$elements=this.elements,_length140=_this$elements.length;_i140<_length140;_i140++){let elt=_this$elements[_i140];elt.destroy();}}}class GutterElement{constructor(view,height,above,markers){this.height=-1;this.above=0;this.markers=[];this.dom=document.createElement("div");this.dom.className="cm-gutterElement";this.update(view,height,above,markers);}update(view,height,above,markers){if(this.height!=height)this.dom.style.height=(this.height=height)+"px";if(this.above!=above)this.dom.style.marginTop=(this.above=above)?above+"px":"";if(!sameMarkers(this.markers,markers))this.setMarkers(view,markers);}setMarkers(view,markers){let cls="cm-gutterElement",domPos=this.dom.firstChild;for(let iNew=0,iOld=0;;){let skipTo=iOld,marker=iNewexists(view,line,event)||add(view,line,event):add;}return result;}});}});class NumberMarker extends GutterMarker{constructor(number){super();this.number=number;}eq(other){return this.number==other.number;}toDOM(){return document.createTextNode(this.number);}}function formatNumber(view,number){return view.state.facet(lineNumberConfig).formatNumber(number,view.state);}const lineNumberGutter=activeGutters.compute([lineNumberConfig],state=>({class:"cm-lineNumbers",renderEmptyElements:false,markers(view){return view.state.facet(lineNumberMarkers);},lineMarker(view,line,others){if(others.some(m=>m.toDOM))return null;return new NumberMarker(formatNumber(view,view.state.doc.lineAt(line.from).number));},widgetMarker:()=>null,lineMarkerChange:update=>update.startState.facet(lineNumberConfig)!=update.state.facet(lineNumberConfig),initialSpacer(view){return new NumberMarker(formatNumber(view,maxLineNumber(view.state.doc.lines)));},updateSpacer(spacer,update){let max=formatNumber(update.view,maxLineNumber(update.view.state.doc.lines));return max==spacer.number?spacer:new NumberMarker(max);},domEventHandlers:state.facet(lineNumberConfig).domEventHandlers}));function lineNumbers(config={}){return[lineNumberConfig.of(config),gutters(),lineNumberGutter];}function maxLineNumber(lines){let last=9;while(last{let marks=[],last=-1;for(let _i141=0,_state$selection$rang4=state.selection.ranges,_length141=_state$selection$rang4.length;_i141<_length141;_i141++){let range=_state$selection$rang4[_i141];let linePos=state.doc.lineAt(range.head).from;if(linePos>last){last=linePos;marks.push(activeLineGutterMarker.range(linePos));}}return RangeSet.of(marks);});function highlightActiveLineGutter(){return activeLineGutterHighlighter;}const WhitespaceDeco=new Map();function getWhitespaceDeco(space){let deco=WhitespaceDeco.get(space);if(!deco)WhitespaceDeco.set(space,deco=Decoration.mark({attributes:space==="\t"?{class:"cm-highlightTab"}:{class:"cm-highlightSpace","data-display":space.replace(/ /g,"·")}}));return deco;}function matcher(decorator){return ViewPlugin.define(view=>({decorations:decorator.createDeco(view),update(u){this.decorations=decorator.updateDeco(u,this.decorations);}}),{decorations:v=>v.decorations});}const whitespaceHighlighter=matcher(new MatchDecorator({regexp:/\t| +/g,decoration:match=>getWhitespaceDeco(match[0]),boundary:/\S/}));function highlightWhitespace(){return whitespaceHighlighter;}const trailingHighlighter=matcher(new MatchDecorator({regexp:/\s+$/g,decoration:Decoration.mark({class:"cm-trailingSpace"}),boundary:/\S/}));function highlightTrailingWhitespace(){return trailingHighlighter;}const __test={HeightMap,HeightOracle,MeasuredHeights,QueryType:QueryType$1,ChangedRange,computeOrder,moveVisually};var _m1=Object.freeze({__proto__:null,BidiSpan:BidiSpan,BlockInfo:BlockInfo,get BlockType(){return BlockType;},Decoration:Decoration,get Direction(){return Direction;},EditorView:EditorView,GutterMarker:GutterMarker,MatchDecorator:MatchDecorator,RectangleMarker:RectangleMarker,ViewPlugin:ViewPlugin,ViewUpdate:ViewUpdate,WidgetType:WidgetType,__test:__test,closeHoverTooltips:closeHoverTooltips,crosshairCursor:crosshairCursor,drawSelection:drawSelection,dropCursor:dropCursor,getPanel:getPanel,getTooltip:getTooltip,gutter:gutter,gutterLineClass:gutterLineClass,gutters:gutters,hasHoverTooltips:hasHoverTooltips,highlightActiveLine:highlightActiveLine,highlightActiveLineGutter:highlightActiveLineGutter,highlightSpecialChars:highlightSpecialChars,highlightTrailingWhitespace:highlightTrailingWhitespace,highlightWhitespace:highlightWhitespace,hoverTooltip:hoverTooltip,keymap:keymap,layer:layer,lineNumberMarkers:lineNumberMarkers,lineNumbers:lineNumbers,logException:logException,panels:panels,placeholder:placeholder,rectangularSelection:rectangularSelection,repositionTooltips:repositionTooltips,runScopeHandlers:runScopeHandlers,scrollPastEnd:scrollPastEnd,showPanel:showPanel,showTooltip:showTooltip,tooltips:tooltips});const DefaultBufferLength=1024;let nextPropID=0;class Range{constructor(from,to){this.from=from;this.to=to;}}class NodeProp{constructor(config={}){this.id=nextPropID++;this.perNode=!!config.perNode;this.deserialize=config.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function");});}add(match){if(this.perNode)throw new RangeError("Can't add per-node props to node types");if(typeof match!="function")match=NodeType.match(match);return type=>{let result=match(type);return result===undefined?null:[this,result];};}}NodeProp.closedBy=new NodeProp({deserialize:str=>str.split(" ")});NodeProp.openedBy=new NodeProp({deserialize:str=>str.split(" ")});NodeProp.group=new NodeProp({deserialize:str=>str.split(" ")});NodeProp.contextHash=new NodeProp({perNode:true});NodeProp.lookAhead=new NodeProp({perNode:true});NodeProp.mounted=new NodeProp({perNode:true});class MountedTree{constructor(tree,overlay,parser){this.tree=tree;this.overlay=overlay;this.parser=parser;}}const noProps=Object.create(null);class NodeType{constructor(name,props,id,flags=0){this.name=name;this.props=props;this.id=id;this.flags=flags;}static define(spec){let props=spec.props&&spec.props.length?Object.create(null):noProps;let flags=(spec.top?1:0)|(spec.skipped?2:0)|(spec.error?4:0)|(spec.name==null?8:0);let type=new NodeType(spec.name||"",props,spec.id,flags);if(spec.props)for(let _i142=0,_spec$props=spec.props,_length142=_spec$props.length;_i142<_length142;_i142++){let src=_spec$props[_i142];if(!Array.isArray(src))src=src(type);if(src){if(src[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");props[src[0].id]=src[1];}}return type;}prop(prop){return this.props[prop.id];}get isTop(){return(this.flags&1)>0;}get isSkipped(){return(this.flags&2)>0;}get isError(){return(this.flags&4)>0;}get isAnonymous(){return(this.flags&8)>0;}is(name){if(typeof name=='string'){if(this.name==name)return true;let group=this.prop(NodeProp.group);return group?group.indexOf(name)>-1:false;}return this.id==name;}static match(map){let direct=Object.create(null);for(let prop in map)for(let _i143=0,_prop$split=prop.split(" "),_length143=_prop$split.length;_i143<_length143;_i143++){let name=_prop$split[_i143];direct[name]=map[prop];}return node=>{for(let groups=node.prop(NodeProp.group),i=-1;i<(groups?groups.length:0);i++){let found=direct[i<0?node.name:groups[i]];if(found)return found;}};}}NodeType.none=new NodeType("",Object.create(null),0,8);class NodeSet{constructor(types){this.types=types;for(let i=0;i0;for(let c=this.cursor(mode|IterMode.IncludeAnonymous);;){let entered=false;if(c.from<=to&&c.to>=from&&(!anon&&c.type.isAnonymous||enter(c)!==false)){if(c.firstChild())continue;entered=true;}for(;;){if(entered&&leave&&(anon||!c.type.isAnonymous))leave(c);if(c.nextSibling())break;if(!c.parent())return;entered=true;}}}prop(prop){return!prop.perNode?this.type.prop(prop):this.props?this.props[prop.id]:undefined;}get propValues(){let result=[];if(this.props)for(let id in this.props)result.push([+id,this.props[id]]);return result;}balance(config={}){return this.children.length<=8?this:balanceRange(NodeType.none,this.children,this.positions,0,this.children.length,0,this.length,(children,positions,length)=>new Tree(this.type,children,positions,length,this.propValues),config.makeTree||((children,positions,length)=>new Tree(NodeType.none,children,positions,length)));}static build(data){return buildTree(data);}}Tree.empty=new Tree(NodeType.none,[],[],0);class FlatBufferCursor{constructor(buffer,index){this.buffer=buffer;this.index=index;}get id(){return this.buffer[this.index-4];}get start(){return this.buffer[this.index-3];}get end(){return this.buffer[this.index-2];}get size(){return this.buffer[this.index-1];}get pos(){return this.index;}next(){this.index-=4;}fork(){return new FlatBufferCursor(this.buffer,this.index);}}class TreeBuffer{constructor(buffer,length,set){this.buffer=buffer;this.length=length;this.set=set;}get type(){return NodeType.none;}toString(){let result=[];for(let index=0;index0)break;}}return pick;}slice(startI,endI,from){let b=this.buffer;let copy=new Uint16Array(endI-startI),len=0;for(let i=startI,j=0;i=pos&&frompos;case 1:return from<=pos&&to>pos;case 2:return to>pos;case 4:return true;}}function enterUnfinishedNodesBefore(node,pos){let scan=node.childBefore(pos);while(scan){let last=scan.lastChild;if(!last||last.to!=scan.to)break;if(last.type.isError&&last.from==last.to){node=scan;scan=last.prevSibling;}else{scan=last;}}return node;}function resolveNode(node,pos,side,overlays){var _a;while(node.from==node.to||(side<1?node.from>=pos:node.from>pos)||(side>-1?node.to<=pos:node.to0?children.length:-1;i!=e;i+=dir){let next=children[i],start=positions[i]+parent.from;if(!checkSide(side,pos,start,start+next.length))continue;if(next instanceof TreeBuffer){if(mode&IterMode.ExcludeBuffers)continue;let index=next.findChild(0,next.buffer.length,dir,pos-start,side);if(index>-1)return new BufferNode(new BufferContext(parent,next,i,start),null,index);}else if(mode&IterMode.IncludeAnonymous||!next.type.isAnonymous||hasChild(next)){let mounted;if(!(mode&IterMode.IgnoreMounts)&&next.props&&(mounted=next.prop(NodeProp.mounted))&&!mounted.overlay)return new TreeNode(mounted.tree,start,i,parent);let inner=new TreeNode(next,start,i,parent);return mode&IterMode.IncludeAnonymous||!inner.type.isAnonymous?inner:inner.nextChild(dir<0?next.children.length-1:0,dir,pos,side);}}if(mode&IterMode.IncludeAnonymous||!parent.type.isAnonymous)return null;if(parent.index>=0)i=parent.index+dir;else i=dir<0?-1:parent._parent._tree.children.length;parent=parent._parent;if(!parent)return null;}}get firstChild(){return this.nextChild(0,1,0,4);}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4);}childAfter(pos){return this.nextChild(0,1,pos,2);}childBefore(pos){return this.nextChild(this._tree.children.length-1,-1,pos,-2);}enter(pos,side,mode=0){let mounted;if(!(mode&IterMode.IgnoreOverlays)&&(mounted=this._tree.prop(NodeProp.mounted))&&mounted.overlay){let rPos=pos-this.from;for(let _i148=0,_mounted$overlay=mounted.overlay,_length148=_mounted$overlay.length;_i148<_length148;_i148++){let{from,to}=_mounted$overlay[_i148];if((side>0?from<=rPos:from=rPos:to>rPos))return new TreeNode(mounted.tree,mounted.overlay[0].from+this.from,-1,this);}}return this.nextChild(0,1,pos,side,mode);}nextSignificantParent(){let val=this;while(val.type.isAnonymous&&val._parent)val=val._parent;return val;}get parent(){return this._parent?this._parent.nextSignificantParent():null;}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null;}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null;}cursor(mode=0){return new TreeCursor(this,mode);}get tree(){return this._tree;}toTree(){return this._tree;}resolve(pos,side=0){return resolveNode(this,pos,side,false);}resolveInner(pos,side=0){return resolveNode(this,pos,side,true);}enterUnfinishedNodesBefore(pos){return enterUnfinishedNodesBefore(this,pos);}getChild(type,before=null,after=null){let r=getChildren(this,type,before,after);return r.length?r[0]:null;}getChildren(type,before=null,after=null){return getChildren(this,type,before,after);}toString(){return this._tree.toString();}get node(){return this;}matchContext(context){return matchNodeContext(this,context);}}function getChildren(node,type,before,after){let cur=node.cursor(),result=[];if(!cur.firstChild())return result;if(before!=null)while(!cur.type.is(before))if(!cur.nextSibling())return result;for(;;){if(after!=null&&cur.type.is(after))return result;if(cur.type.is(type))result.push(cur.node);if(!cur.nextSibling())return after==null?result:[];}}function matchNodeContext(node,context,i=context.length-1){for(let p=node.parent;i>=0;p=p.parent){if(!p)return false;if(!p.type.isAnonymous){if(context[i]&&context[i]!=p.name)return false;i--;}}return true;}class BufferContext{constructor(parent,buffer,index,start){this.parent=parent;this.buffer=buffer;this.index=index;this.start=start;}}class BufferNode{get name(){return this.type.name;}get from(){return this.context.start+this.context.buffer.buffer[this.index+1];}get to(){return this.context.start+this.context.buffer.buffer[this.index+2];}constructor(context,_parent,index){this.context=context;this._parent=_parent;this.index=index;this.type=context.buffer.set.types[context.buffer.buffer[index]];}child(dir,pos,side){let{buffer}=this.context;let index=buffer.findChild(this.index+4,buffer.buffer[this.index+3],dir,pos-this.context.start,side);return index<0?null:new BufferNode(this.context,this,index);}get firstChild(){return this.child(1,0,4);}get lastChild(){return this.child(-1,0,4);}childAfter(pos){return this.child(1,pos,2);}childBefore(pos){return this.child(-1,pos,-2);}enter(pos,side,mode=0){if(mode&IterMode.ExcludeBuffers)return null;let{buffer}=this.context;let index=buffer.findChild(this.index+4,buffer.buffer[this.index+3],side>0?1:-1,pos-this.context.start,side);return index<0?null:new BufferNode(this.context,this,index);}get parent(){return this._parent||this.context.parent.nextSignificantParent();}externalSibling(dir){return this._parent?null:this.context.parent.nextChild(this.context.index+dir,dir,0,4);}get nextSibling(){let{buffer}=this.context;let after=buffer.buffer[this.index+3];if(after<(this._parent?buffer.buffer[this._parent.index+3]:buffer.buffer.length))return new BufferNode(this.context,this._parent,after);return this.externalSibling(1);}get prevSibling(){let{buffer}=this.context;let parentStart=this._parent?this._parent.index+4:0;if(this.index==parentStart)return this.externalSibling(-1);return new BufferNode(this.context,this._parent,buffer.findChild(parentStart,this.index,-1,0,4));}cursor(mode=0){return new TreeCursor(this,mode);}get tree(){return null;}toTree(){let children=[],positions=[];let{buffer}=this.context;let startI=this.index+4,endI=buffer.buffer[this.index+3];if(endI>startI){let from=buffer.buffer[this.index+1];children.push(buffer.slice(startI,endI,from));positions.push(0);}return new Tree(this.type,children,positions,this.to-this.from);}resolve(pos,side=0){return resolveNode(this,pos,side,false);}resolveInner(pos,side=0){return resolveNode(this,pos,side,true);}enterUnfinishedNodesBefore(pos){return enterUnfinishedNodesBefore(this,pos);}toString(){return this.context.buffer.childString(this.index);}getChild(type,before=null,after=null){let r=getChildren(this,type,before,after);return r.length?r[0]:null;}getChildren(type,before=null,after=null){return getChildren(this,type,before,after);}get node(){return this;}matchContext(context){return matchNodeContext(this,context);}}class TreeCursor{get name(){return this.type.name;}constructor(node,mode=0){this.mode=mode;this.buffer=null;this.stack=[];this.index=0;this.bufferNode=null;if(node instanceof TreeNode){this.yieldNode(node);}else{this._tree=node.context.parent;this.buffer=node.context;for(let n=node._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=node;this.yieldBuf(node.index);}}yieldNode(node){if(!node)return false;this._tree=node;this.type=node.type;this.from=node.from;this.to=node.to;return true;}yieldBuf(index,type){this.index=index;let{start,buffer}=this.buffer;this.type=type||buffer.set.types[buffer.buffer[index]];this.from=start+buffer.buffer[index+1];this.to=start+buffer.buffer[index+2];return true;}yield(node){if(!node)return false;if(node instanceof TreeNode){this.buffer=null;return this.yieldNode(node);}this.buffer=node.context;return this.yieldBuf(node.index,node.type);}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString();}enterChild(dir,pos,side){if(!this.buffer)return this.yield(this._tree.nextChild(dir<0?this._tree._tree.children.length-1:0,dir,pos,side,this.mode));let{buffer}=this.buffer;let index=buffer.findChild(this.index+4,buffer.buffer[this.index+3],dir,pos-this.buffer.start,side);if(index<0)return false;this.stack.push(this.index);return this.yieldBuf(index);}firstChild(){return this.enterChild(1,0,4);}lastChild(){return this.enterChild(-1,0,4);}childAfter(pos){return this.enterChild(1,pos,2);}childBefore(pos){return this.enterChild(-1,pos,-2);}enter(pos,side,mode=this.mode){if(!this.buffer)return this.yield(this._tree.enter(pos,side,mode));return mode&IterMode.ExcludeBuffers?false:this.enterChild(1,pos,side);}parent(){if(!this.buffer)return this.yieldNode(this.mode&IterMode.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let parent=this.mode&IterMode.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();this.buffer=null;return this.yieldNode(parent);}sibling(dir){if(!this.buffer)return!this._tree._parent?false:this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+dir,dir,0,4,this.mode));let{buffer}=this.buffer,d=this.stack.length-1;if(dir<0){let parentStart=d<0?0:this.stack[d]+4;if(this.index!=parentStart)return this.yieldBuf(buffer.findChild(parentStart,this.index,-1,0,4));}else{let after=buffer.buffer[this.index+3];if(after<(d<0?buffer.buffer.length:buffer.buffer[this.stack[d]+3]))return this.yieldBuf(after);}return d<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+dir,dir,0,4,this.mode)):false;}nextSibling(){return this.sibling(1);}prevSibling(){return this.sibling(-1);}atLastNode(dir){let index,parent,{buffer}=this;if(buffer){if(dir>0){if(this.index-1)for(let i=index+dir,e=dir<0?-1:parent._tree.children.length;i!=e;i+=dir){let child=parent._tree.children[i];if(this.mode&IterMode.IncludeAnonymous||child instanceof TreeBuffer||!child.type.isAnonymous||hasChild(child))return false;}}return true;}move(dir,enter){if(enter&&this.enterChild(dir,0,4))return true;for(;;){if(this.sibling(dir))return true;if(this.atLastNode(dir)||!this.parent())return false;}}next(enter=true){return this.move(1,enter);}prev(enter=true){return this.move(-1,enter);}moveTo(pos,side=0){while(this.from==this.to||(side<1?this.from>=pos:this.from>pos)||(side>-1?this.to<=pos:this.to=0;){for(let c=cache;c;c=c._parent)if(c.index==index){if(index==this.index)return c;result=c;depth=d+1;break scan;}index=this.stack[--d];}}for(let i=depth;i=0;d--){if(d<0)return matchNodeContext(this.node,context,i);let type=types[buffer.buffer[this.stack[d]]];if(!type.isAnonymous){if(context[i]&&context[i]!=type.name)return false;i--;}}return true;}}function hasChild(tree){return tree.children.some(ch=>ch instanceof TreeBuffer||!ch.type.isAnonymous||hasChild(ch));}function buildTree(data){var _a;let{buffer,nodeSet,maxBufferLength=DefaultBufferLength,reused=[],minRepeatType=nodeSet.types.length}=data;let cursor=Array.isArray(buffer)?new FlatBufferCursor(buffer,buffer.length):buffer;let types=nodeSet.types;let contextHash=0,lookAhead=0;function takeNode(parentStart,minPos,children,positions,inRepeat){let{id,start,end,size}=cursor;let lookAheadAtStart=lookAhead;while(size<0){cursor.next();if(size==-1){let node=reused[id];children.push(node);positions.push(start-parentStart);return;}else if(size==-3){contextHash=id;return;}else if(size==-4){lookAhead=id;return;}else{throw new RangeError(`Unrecognized record size: ${size}`);}}let type=types[id],node,buffer;let startPos=start-parentStart;if(end-start<=maxBufferLength&&(buffer=findBufferSize(cursor.pos-minPos,inRepeat))){let data=new Uint16Array(buffer.size-buffer.skip);let endPos=cursor.pos-buffer.size,index=data.length;while(cursor.pos>endPos)index=copyToBuffer(buffer.start,data,index);node=new TreeBuffer(data,end-buffer.start,nodeSet);startPos=buffer.start-parentStart;}else{let endPos=cursor.pos-size;cursor.next();let localChildren=[],localPositions=[];let localInRepeat=id>=minRepeatType?id:-1;let lastGroup=0,lastEnd=end;while(cursor.pos>endPos){if(localInRepeat>=0&&cursor.id==localInRepeat&&cursor.size>=0){if(cursor.end<=lastEnd-maxBufferLength){makeRepeatLeaf(localChildren,localPositions,start,lastGroup,cursor.end,lastEnd,localInRepeat,lookAheadAtStart);lastGroup=localChildren.length;lastEnd=cursor.end;}cursor.next();}else{takeNode(start,endPos,localChildren,localPositions,localInRepeat);}}if(localInRepeat>=0&&lastGroup>0&&lastGroup-1&&lastGroup>0){let make=makeBalanced(type);node=balanceRange(type,localChildren,localPositions,0,localChildren.length,0,end-start,make,make);}else{node=makeTree(type,localChildren,localPositions,end-start,lookAheadAtStart-end);}}children.push(node);positions.push(startPos);}function makeBalanced(type){return(children,positions,length)=>{let lookAhead=0,lastI=children.length-1,last,lookAheadProp;if(lastI>=0&&(last=children[lastI])instanceof Tree){if(!lastI&&last.type==type&&last.length==length)return last;if(lookAheadProp=last.prop(NodeProp.lookAhead))lookAhead=positions[lastI]+last.length+lookAheadProp;}return makeTree(type,children,positions,length,lookAhead);};}function makeRepeatLeaf(children,positions,base,i,from,to,type,lookAhead){let localChildren=[],localPositions=[];while(children.length>i){localChildren.push(children.pop());localPositions.push(positions.pop()+base-from);}children.push(makeTree(nodeSet.types[type],localChildren,localPositions,to-from,lookAhead-to));positions.push(from-base);}function makeTree(type,children,positions,length,lookAhead=0,props){if(contextHash){let pair=[NodeProp.contextHash,contextHash];props=props?[pair].concat(props):[pair];}if(lookAhead>25){let pair=[NodeProp.lookAhead,lookAhead];props=props?[pair].concat(props):[pair];}return new Tree(type,children,positions,length,props);}function findBufferSize(maxSize,inRepeat){let fork=cursor.fork();let size=0,start=0,skip=0,minStart=fork.end-maxBufferLength;let result={size:0,start:0,skip:0};scan:for(let minPos=fork.pos-maxSize;fork.pos>minPos;){let nodeSize=fork.size;if(fork.id==inRepeat&&nodeSize>=0){result.size=size;result.start=start;result.skip=skip;skip+=4;size+=4;fork.next();continue;}let startPos=fork.pos-nodeSize;if(nodeSize<0||startPos=minRepeatType?4:0;let nodeStart=fork.start;fork.next();while(fork.pos>startPos){if(fork.size<0){if(fork.size==-3)localSkipped+=4;else break scan;}else if(fork.id>=minRepeatType){localSkipped+=4;}fork.next();}start=nodeStart;size+=nodeSize;skip+=localSkipped;}if(inRepeat<0||size==maxSize){result.size=size;result.start=start;result.skip=skip;}return result.size>4?result:undefined;}function copyToBuffer(bufferStart,buffer,index){let{id,start,end,size}=cursor;cursor.next();if(size>=0&&id4){let endPos=cursor.pos-(size-4);while(cursor.pos>endPos)index=copyToBuffer(bufferStart,buffer,index);}buffer[--index]=startIndex;buffer[--index]=end-bufferStart;buffer[--index]=start-bufferStart;buffer[--index]=id;}else if(size==-3){contextHash=id;}else if(size==-4){lookAhead=id;}return index;}let children=[],positions=[];while(cursor.pos>0)takeNode(data.start||0,data.bufferStart||0,children,positions,-1);let length=(_a=data.length)!==null&&_a!==void 0?_a:children.length?positions[0]+children[0].length:0;return new Tree(types[data.topID],children.reverse(),positions.reverse(),length);}const nodeSizeCache=new WeakMap();function nodeSize(balanceType,node){if(!balanceType.isAnonymous||node instanceof TreeBuffer||node.type!=balanceType)return 1;let size=nodeSizeCache.get(node);if(size==null){size=1;for(let _i149=0,_node$children=node.children,_length149=_node$children.length;_i149<_length149;_i149++){let child=_node$children[_i149];if(child.type!=balanceType||!(child instanceof Tree)){size=1;break;}size+=nodeSize(balanceType,child);}nodeSizeCache.set(node,size);}return size;}function balanceRange(balanceType,children,positions,from,to,start,length,mkTop,mkTree){let total=0;for(let i=from;i=maxChild)break;groupSize+=nextSize;}if(i==groupFrom+1){if(groupSize>maxChild){let only=children[groupFrom];divide(only.children,only.positions,0,only.children.length,positions[groupFrom]+offset);continue;}localChildren.push(children[groupFrom]);}else{let length=positions[i-1]+children[i-1].length-groupStart;localChildren.push(balanceRange(balanceType,children,positions,groupFrom,i,groupStart,length,null,mkTree));}localPositions.push(groupStart+offset-start);}}divide(children,positions,from,to,0);return(mkTop||mkTree)(localChildren,localPositions,length);}class NodeWeakMap{constructor(){this.map=new WeakMap();}setBuffer(buffer,index,value){let inner=this.map.get(buffer);if(!inner)this.map.set(buffer,inner=new Map());inner.set(index,value);}getBuffer(buffer,index){let inner=this.map.get(buffer);return inner&&inner.get(index);}set(node,value){if(node instanceof BufferNode)this.setBuffer(node.context.buffer,node.index,value);else if(node instanceof TreeNode)this.map.set(node.tree,value);}get(node){return node instanceof BufferNode?this.getBuffer(node.context.buffer,node.index):node instanceof TreeNode?this.map.get(node.tree):undefined;}cursorSet(cursor,value){if(cursor.buffer)this.setBuffer(cursor.buffer.buffer,cursor.index,value);else this.map.set(cursor.tree,value);}cursorGet(cursor){return cursor.buffer?this.getBuffer(cursor.buffer.buffer,cursor.index):this.map.get(cursor.tree);}}class TreeFragment{constructor(from,to,tree,offset,openStart=false,openEnd=false){this.from=from;this.to=to;this.tree=tree;this.offset=offset;this.open=(openStart?1:0)|(openEnd?2:0);}get openStart(){return(this.open&1)>0;}get openEnd(){return(this.open&2)>0;}static addTree(tree,fragments=[],partial=false){let result=[new TreeFragment(0,tree.length,tree,0,false,partial)];for(let _i150=0,_length150=fragments.length;_i150<_length150;_i150++){let f=fragments[_i150];if(f.to>tree.length)result.push(f);}return result;}static applyChanges(fragments,changes,minGap=128){if(!changes.length)return fragments;let result=[];let fI=1,nextF=fragments.length?fragments[0]:null;for(let cI=0,pos=0,off=0;;cI++){let nextC=cI=minGap)while(nextF&&nextF.from=cut.from||nextPos<=cut.to||off){let fFrom=Math.max(cut.from,pos)-off,fTo=Math.min(cut.to,nextPos)-off;cut=fFrom>=fTo?null:new TreeFragment(fFrom,fTo,cut.tree,cut.offset+off,cI>0,!!nextC);}if(cut)result.push(cut);if(nextF.to>nextPos)break;nextF=fInew Range(r.from,r.to)):[new Range(0,0)];return this.createParse(input,fragments||[],ranges);}parse(input,fragments,ranges){let parse=this.startParse(input,fragments,ranges);for(;;){let done=parse.advance();if(done)return done;}}}class StringInput{constructor(string){this.string=string;}get length(){return this.string.length;}chunk(from){return this.string.slice(from);}get lineChunks(){return false;}read(from,to){return this.string.slice(from,to);}}function parseMixed(nest){return(parse,input,fragments,ranges)=>new MixedParse(parse,nest,input,fragments,ranges);}class InnerParse{constructor(parser,parse,overlay,target,ranges){this.parser=parser;this.parse=parse;this.overlay=overlay;this.target=target;this.ranges=ranges;if(!ranges.length||ranges.some(r=>r.from>=r.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(ranges));}}class ActiveOverlay{constructor(parser,predicate,mounts,index,start,target,prev){this.parser=parser;this.predicate=predicate;this.mounts=mounts;this.index=index;this.start=start;this.target=target;this.prev=prev;this.depth=0;this.ranges=[];}}const stoppedInner=new NodeProp({perNode:true});class MixedParse{constructor(base,nest,input,fragments,ranges){this.nest=nest;this.input=input;this.fragments=fragments;this.ranges=ranges;this.inner=[];this.innerDone=0;this.baseTree=null;this.stoppedAt=null;this.baseParse=base;}advance(){if(this.baseParse){let done=this.baseParse.advance();if(!done)return null;this.baseParse=null;this.baseTree=done;this.startInner();if(this.stoppedAt!=null)for(let _i151=0,_this$inner=this.inner,_length151=_this$inner.length;_i151<_length151;_i151++){let inner=_this$inner[_i151];inner.parse.stopAt(this.stoppedAt);}}if(this.innerDone==this.inner.length){let result=this.baseTree;if(this.stoppedAt!=null)result=new Tree(result.type,result.children,result.positions,result.length,result.propValues.concat([[stoppedInner,this.stoppedAt]]));return result;}let inner=this.inner[this.innerDone],done=inner.parse.advance();if(done){this.innerDone++;let props=Object.assign(Object.create(null),inner.target.props);props[NodeProp.mounted.id]=new MountedTree(done,inner.overlay,inner.parser);inner.target.props=props;}return null;}get parsedPos(){if(this.baseParse)return 0;let pos=this.input.length;for(let i=this.innerDone;im.frag.from<=cursor.from&&m.frag.to>=cursor.to&&m.mount.overlay);if(match)for(let _i152=0,_match$mount$overlay=match.mount.overlay,_length152=_match$mount$overlay.length;_i152<_length152;_i152++){let r=_match$mount$overlay[_i152];let from=r.from+match.pos,to=r.to+match.pos;if(from>=cursor.from&&to<=cursor.to&&!overlay.ranges.some(r=>r.fromfrom))overlay.ranges.push({from,to});}}enter=false;}else if(covered&&(isCovered=checkCover(covered.ranges,cursor.from,cursor.to))){enter=isCovered!=2;}else if(!cursor.type.isAnonymous&&cursor.fromnew Range(r.from-cursor.from,r.to-cursor.from)):null,cursor.tree,ranges));if(!nest.overlay)enter=false;else if(ranges.length)covered={ranges,depth:0,prev:covered};}}else if(overlay&&(range=overlay.predicate(cursor))){if(range===true)range=new Range(cursor.from,cursor.to);if(range.fromnew Range(r.from-overlay.start,r.to-overlay.start)),overlay.target,ranges));overlay=overlay.prev;}if(covered&&! --covered.depth)covered=covered.prev;}}}}}function checkCover(covered,from,to){for(let _i153=0,_length153=covered.length;_i153<_length153;_i153++){let range=covered[_i153];if(range.from>=to)break;if(range.to>from)return range.from<=from&&range.to>=to?2:1;}return 0;}function sliceBuf(buf,startI,endI,nodes,positions,off){if(startI=node.to)break;}let buf=base.children[i],b=buf.buffer;function split(startI,endI,type,innerOffset,length){let i=startI;while(b[i+2]+off<=node.from)i=b[i+3];let children=[],positions=[];sliceBuf(buf,startI,i,children,positions,innerOffset);let from=b[i+1],to=b[i+2];let isTarget=from+off==node.from&&to+off==node.to&&b[i]==node.type.id;children.push(isTarget?node.toTree():split(i+4,b[i+3],buf.set.types[b[i]],from,to-from));positions.push(from-innerOffset);sliceBuf(buf,b[i+3],endI,children,positions,innerOffset);return new Tree(type,children,positions,length);}base.children[i]=split(0,b.length,NodeType.none,0,buf.length);for(let d=0;d<=depth;d++)cursor.childAfter(node.from);}class StructureCursor{constructor(root,offset){this.offset=offset;this.done=false;this.cursor=root.cursor(IterMode.IncludeAnonymous|IterMode.IgnoreMounts);}moveTo(pos){let{cursor}=this,p=pos-this.offset;while(!this.done&&cursor.from=pos&&cursor.enter(p,1,IterMode.IgnoreOverlays|IterMode.ExcludeBuffers));else if(!cursor.next(false))this.done=true;}}hasNode(cursor){this.moveTo(cursor.from);if(!this.done&&this.cursor.from+this.offset==cursor.from&&this.cursor.tree){for(let tree=this.cursor.tree;;){if(tree==cursor.tree)return true;if(tree.children.length&&tree.positions[0]==0&&tree.children[0]instanceof Tree)tree=tree.children[0];else break;}}return false;}}class FragmentCursor$2{constructor(fragments){var _a;this.fragments=fragments;this.curTo=0;this.fragI=0;if(fragments.length){let first=this.curFrag=fragments[0];this.curTo=(_a=first.tree.prop(stoppedInner))!==null&&_a!==void 0?_a:first.to;this.inner=new StructureCursor(first.tree,-first.offset);}else{this.curFrag=this.inner=null;}}hasNode(node){while(this.curFrag&&node.from>=this.curTo)this.nextFrag();return this.curFrag&&this.curFrag.from<=node.from&&this.curTo>=node.to&&this.inner.hasNode(node);}nextFrag(){var _a;this.fragI++;if(this.fragI==this.fragments.length){this.curFrag=this.inner=null;}else{let frag=this.curFrag=this.fragments[this.fragI];this.curTo=(_a=frag.tree.prop(stoppedInner))!==null&&_a!==void 0?_a:frag.to;this.inner=new StructureCursor(frag.tree,-frag.offset);}}findMounts(pos,parser){var _a;let result=[];if(this.inner){this.inner.cursor.moveTo(pos,1);for(let pos=this.inner.cursor.node;pos;pos=pos.parent){let mount=(_a=pos.tree)===null||_a===void 0?void 0:_a.prop(NodeProp.mounted);if(mount&&mount.parser==parser){for(let i=this.fragI;i=pos.to)break;if(frag.tree==this.curFrag.tree)result.push({frag,pos:pos.from-frag.offset,mount});}}}}return result;}}function punchRanges(outer,ranges){let copy=null,current=ranges;for(let i=1,j=0;i=gapTo)break;if(r.to<=gapFrom)continue;if(!copy)current=copy=ranges.slice();if(r.fromgapTo)copy.splice(j+1,0,new Range(gapTo,r.to));}else if(r.to>gapTo){copy[j--]=new Range(gapTo,r.to);}else{copy.splice(j--,1);}}}return current;}function findCoverChanges(a,b,from,to){let iA=0,iB=0,inA=false,inB=false,pos=-1e9;let result=[];for(;;){let nextA=iA==a.length?1e9:inA?a[iA].to:a[iA].from;let nextB=iB==b.length?1e9:inB?b[iB].to:b[iB].from;if(inA!=inB){let start=Math.max(pos,from),end=Math.min(nextA,nextB,to);if(startnew Range(r.from+pos,r.to+pos));let changes=findCoverChanges(ranges,overlay,from,to);for(let i=0,pos=from;;i++){let last=i==changes.length,end=last?to:changes[i].from;if(end>pos)result.push(new TreeFragment(pos,end,mount.tree,-startPos,frag.from>=pos||frag.openStart,frag.to<=end||frag.openEnd));if(last)break;pos=changes[i].to;}}else{result.push(new TreeFragment(from,to,mount.tree,-startPos,frag.from>=startPos||frag.openStart,frag.to<=endPos||frag.openEnd));}}return result;}var _m30=Object.freeze({__proto__:null,DefaultBufferLength:DefaultBufferLength,get IterMode(){return IterMode;},MountedTree:MountedTree,NodeProp:NodeProp,NodeSet:NodeSet,NodeType:NodeType,NodeWeakMap:NodeWeakMap,Parser:Parser,Tree:Tree,TreeBuffer:TreeBuffer,TreeCursor:TreeCursor,TreeFragment:TreeFragment,parseMixed:parseMixed});let nextTagID=0;class Tag{constructor(set,base,modified){this.set=set;this.base=base;this.modified=modified;this.id=nextTagID++;}static define(parent){if(parent===null||parent===void 0?void 0:parent.base)throw new Error("Can not derive from a modified tag");let tag=new Tag([],null,[]);tag.set.push(tag);if(parent)for(let _i155=0,_parent$set=parent.set,_length155=_parent$set.length;_i155<_length155;_i155++){let t=_parent$set[_i155];tag.set.push(t);}return tag;}static defineModifier(){let mod=new Modifier();return tag=>{if(tag.modified.indexOf(mod)>-1)return tag;return Modifier.get(tag.base||tag,tag.modified.concat(mod).sort((a,b)=>a.id-b.id));};}}let nextModifierID=0;class Modifier{constructor(){this.instances=[];this.id=nextModifierID++;}static get(base,mods){if(!mods.length)return base;let exists=mods[0].instances.find(t=>t.base==base&&sameArray(mods,t.modified));if(exists)return exists;let set=[],tag=new Tag(set,base,mods);for(let _i156=0,_length156=mods.length;_i156<_length156;_i156++){let m=mods[_i156];m.instances.push(tag);}let configs=powerSet(mods);for(let _i157=0,_base$set=base.set,_length157=_base$set.length;_i157<_length157;_i157++){let parent=_base$set[_i157];if(!parent.modified.length)for(let _i158=0,_length158=configs.length;_i158<_length158;_i158++){let config=configs[_i158];set.push(Modifier.get(parent,config));}}return tag;}}function sameArray(a,b){return a.length==b.length&&a.every((x,i)=>x==b[i]);}function powerSet(array){let sets=[[]];for(let i=0;ib.length-a.length);}function styleTags(spec){let byName=Object.create(null);for(let prop in spec){let tags=spec[prop];if(!Array.isArray(tags))tags=[tags];for(let _i159=0,_prop$split2=prop.split(" "),_length159=_prop$split2.length;_i159<_length159;_i159++){let part=_prop$split2[_i159];if(part){let pieces=[],mode=2,rest=part;for(let pos=0;;){if(rest=="..."&&pos>0&&pos+3==part.length){mode=1;break;}let m=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(rest);if(!m)throw new RangeError("Invalid path: "+part);pieces.push(m[0]=="*"?"":m[0][0]=='"'?JSON.parse(m[0]):m[0]);pos+=m[0].length;if(pos==part.length)break;let next=part[pos++];if(pos==part.length&&next=="!"){mode=0;break;}if(next!="/")throw new RangeError("Invalid path: "+part);rest=part.slice(pos);}let last=pieces.length-1,inner=pieces[last];if(!inner)throw new RangeError("Invalid path: "+part);let rule=new Rule(tags,mode,last>0?pieces.slice(0,last):null);byName[inner]=rule.sort(byName[inner]);}}}return ruleNodeProp.add(byName);}const ruleNodeProp=new NodeProp();class Rule{constructor(tags,mode,context,next){this.tags=tags;this.mode=mode;this.context=context;this.next=next;}get opaque(){return this.mode==0;}get inherit(){return this.mode==1;}sort(other){if(!other||other.depth{let cls=all;for(let _i162=0,_length162=tags.length;_i162<_length162;_i162++){let tag=tags[_i162];for(let _i163=0,_tag$set=tag.set,_length163=_tag$set.length;_i163<_length163;_i163++){let sub=_tag$set[_i163];let tagClass=map[sub.id];if(tagClass){cls=cls?cls+" "+tagClass:tagClass;break;}}}return cls;},scope};}function highlightTags(highlighters,tags){let result=null;for(let _i164=0,_length164=highlighters.length;_i164<_length164;_i164++){let highlighter=highlighters[_i164];let value=highlighter.style(tags);if(value)result=result?result+" "+value:value;}return result;}function highlightTree(tree,highlighter,putStyle,from=0,to=tree.length){let builder=new HighlightBuilder(from,Array.isArray(highlighter)?highlighter:[highlighter],putStyle);builder.highlightRange(tree.cursor(),from,to,"",builder.highlighters);builder.flush(to);}class HighlightBuilder{constructor(at,highlighters,span){this.at=at;this.highlighters=highlighters;this.span=span;this.class="";}startSpan(at,cls){if(cls!=this.class){this.flush(at);if(at>this.at)this.at=at;this.class=cls;}}flush(to){if(to>this.at&&this.class)this.span(this.at,to,this.class);}highlightRange(cursor,from,to,inheritedClass,highlighters){let{type,from:start,to:end}=cursor;if(start>=to||end<=from)return;if(type.isTop)highlighters=this.highlighters.filter(h=>!h.scope||h.scope(type));let cls=inheritedClass;let rule=getStyleTags(cursor)||Rule.empty;let tagCls=highlightTags(highlighters,rule.tags);if(tagCls){if(cls)cls+=" ";cls+=tagCls;if(rule.mode==1)inheritedClass+=(inheritedClass?" ":"")+tagCls;}this.startSpan(cursor.from,cls);if(rule.opaque)return;let mounted=cursor.tree&&cursor.tree.prop(NodeProp.mounted);if(mounted&&mounted.overlay){let inner=cursor.node.enter(mounted.overlay[0].from+start,1);let innerHighlighters=this.highlighters.filter(h=>!h.scope||h.scope(mounted.tree.type));let hasChild=cursor.firstChild();for(let i=0,pos=start;;i++){let next=i=nextPos||!cursor.nextSibling())break;}}if(!next||nextPos>to)break;pos=next.to+start;if(pos>from){this.highlightRange(inner.cursor(),Math.max(from,next.from+start),Math.min(to,pos),inheritedClass,innerHighlighters);this.startSpan(pos,cls);}}if(hasChild)cursor.parent();}else if(cursor.firstChild()){do{if(cursor.to<=from)continue;if(cursor.from>=to)break;this.highlightRange(cursor,from,to,inheritedClass,highlighters);this.startSpan(Math.min(to,cursor.to),cls);}while(cursor.nextSibling());cursor.parent();}}}function getStyleTags(node){let rule=node.type.prop(ruleNodeProp);while(rule&&rule.context&&!node.matchContext(rule.context))rule=rule.next;return rule||null;}const t=Tag.define;const comment=t(),name=t(),typeName=t(name),propertyName=t(name),literal=t(),string=t(literal),number=t(literal),content=t(),heading=t(content),keyword=t(),operator=t(),punctuation=t(),bracket=t(punctuation),meta=t();const tags$1={comment,lineComment:t(comment),blockComment:t(comment),docComment:t(comment),name,variableName:t(name),typeName:typeName,tagName:t(typeName),propertyName:propertyName,attributeName:t(propertyName),className:t(name),labelName:t(name),namespace:t(name),macroName:t(name),literal,string,docString:t(string),character:t(string),attributeValue:t(string),number,integer:t(number),float:t(number),bool:t(literal),regexp:t(literal),escape:t(literal),color:t(literal),url:t(literal),keyword,self:t(keyword),null:t(keyword),atom:t(keyword),unit:t(keyword),modifier:t(keyword),operatorKeyword:t(keyword),controlKeyword:t(keyword),definitionKeyword:t(keyword),moduleKeyword:t(keyword),operator,derefOperator:t(operator),arithmeticOperator:t(operator),logicOperator:t(operator),bitwiseOperator:t(operator),compareOperator:t(operator),updateOperator:t(operator),definitionOperator:t(operator),typeOperator:t(operator),controlOperator:t(operator),punctuation,separator:t(punctuation),bracket,angleBracket:t(bracket),squareBracket:t(bracket),paren:t(bracket),brace:t(bracket),content,heading,heading1:t(heading),heading2:t(heading),heading3:t(heading),heading4:t(heading),heading5:t(heading),heading6:t(heading),contentSeparator:t(content),list:t(content),quote:t(content),emphasis:t(content),strong:t(content),link:t(content),monospace:t(content),strikethrough:t(content),inserted:t(),deleted:t(),changed:t(),invalid:t(),meta,documentMeta:t(meta),annotation:t(meta),processingInstruction:t(meta),definition:Tag.defineModifier(),constant:Tag.defineModifier(),function:Tag.defineModifier(),standard:Tag.defineModifier(),local:Tag.defineModifier(),special:Tag.defineModifier()};const classHighlighter=tagHighlighter([{tag:tags$1.link,class:"tok-link"},{tag:tags$1.heading,class:"tok-heading"},{tag:tags$1.emphasis,class:"tok-emphasis"},{tag:tags$1.strong,class:"tok-strong"},{tag:tags$1.keyword,class:"tok-keyword"},{tag:tags$1.atom,class:"tok-atom"},{tag:tags$1.bool,class:"tok-bool"},{tag:tags$1.url,class:"tok-url"},{tag:tags$1.labelName,class:"tok-labelName"},{tag:tags$1.inserted,class:"tok-inserted"},{tag:tags$1.deleted,class:"tok-deleted"},{tag:tags$1.literal,class:"tok-literal"},{tag:tags$1.string,class:"tok-string"},{tag:tags$1.number,class:"tok-number"},{tag:[tags$1.regexp,tags$1.escape,tags$1.special(tags$1.string)],class:"tok-string2"},{tag:tags$1.variableName,class:"tok-variableName"},{tag:tags$1.local(tags$1.variableName),class:"tok-variableName tok-local"},{tag:tags$1.definition(tags$1.variableName),class:"tok-variableName tok-definition"},{tag:tags$1.special(tags$1.variableName),class:"tok-variableName2"},{tag:tags$1.definition(tags$1.propertyName),class:"tok-propertyName tok-definition"},{tag:tags$1.typeName,class:"tok-typeName"},{tag:tags$1.namespace,class:"tok-namespace"},{tag:tags$1.className,class:"tok-className"},{tag:tags$1.macroName,class:"tok-macroName"},{tag:tags$1.propertyName,class:"tok-propertyName"},{tag:tags$1.operator,class:"tok-operator"},{tag:tags$1.comment,class:"tok-comment"},{tag:tags$1.meta,class:"tok-meta"},{tag:tags$1.invalid,class:"tok-invalid"},{tag:tags$1.punctuation,class:"tok-punctuation"}]);var _m31=Object.freeze({__proto__:null,Tag:Tag,classHighlighter:classHighlighter,getStyleTags:getStyleTags,highlightTree:highlightTree,styleTags:styleTags,tagHighlighter:tagHighlighter,tags:tags$1});var _a;const languageDataProp=new NodeProp();function defineLanguageFacet(baseData){return Facet.define({combine:baseData?values=>values.concat(baseData):undefined});}const sublanguageProp=new NodeProp();class Language{constructor(data,parser,extraExtensions=[],name=""){this.data=data;this.name=name;if(!EditorState.prototype.hasOwnProperty("tree"))Object.defineProperty(EditorState.prototype,"tree",{get(){return syntaxTree(this);}});this.parser=parser;this.extension=[language.of(this),EditorState.languageData.of((state,pos,side)=>{let top=topNodeAt(state,pos,side),data=top.type.prop(languageDataProp);if(!data)return[];let base=state.facet(data),sub=top.type.prop(sublanguageProp);if(sub){let innerNode=top.resolve(pos-top.from,side);for(let _i165=0,_length165=sub.length;_i165<_length165;_i165++){let sublang=sub[_i165];if(sublang.test(innerNode,state)){let data=state.facet(sublang.facet);return sublang.type=="replace"?data:data.concat(base);}}}return base;})].concat(extraExtensions);}isActiveAt(state,pos,side=-1){return topNodeAt(state,pos,side).type.prop(languageDataProp)==this.data;}findRegions(state){let lang=state.facet(language);if((lang===null||lang===void 0?void 0:lang.data)==this.data)return[{from:0,to:state.doc.length}];if(!lang||!lang.allowsNesting)return[];let result=[];let explore=(tree,from)=>{if(tree.prop(languageDataProp)==this.data){result.push({from,to:from+tree.length});return;}let mount=tree.prop(NodeProp.mounted);if(mount){if(mount.tree.prop(languageDataProp)==this.data){if(mount.overlay)for(let _i166=0,_mount$overlay=mount.overlay,_length166=_mount$overlay.length;_i166<_length166;_i166++){let r=_mount$overlay[_i166];result.push({from:r.from+from,to:r.to+from});}else result.push({from:from,to:from+tree.length});return;}else if(mount.overlay){let size=result.length;explore(mount.tree,mount.overlay[0].from+from);if(result.length>size)return;}}for(let i=0;itype.isTop?data:undefined)]}),spec.name);}configure(options,name){return new LRLanguage(this.data,this.parser.configure(options),name||this.name);}get allowsNesting(){return this.parser.hasWrappers();}}function syntaxTree(state){let field=state.field(Language.state,false);return field?field.tree:Tree.empty;}function ensureSyntaxTree(state,upto,timeout=50){var _a;let parse=(_a=state.field(Language.state,false))===null||_a===void 0?void 0:_a.context;if(!parse)return null;let oldVieport=parse.viewport;parse.updateViewport({from:0,to:upto});let result=parse.isDone(upto)||parse.work(timeout,upto)?parse.tree:null;parse.updateViewport(oldVieport);return result;}function syntaxTreeAvailable(state,upto=state.doc.length){var _a;return((_a=state.field(Language.state,false))===null||_a===void 0?void 0:_a.context.isDone(upto))||false;}function forceParsing(view,upto=view.viewport.to,timeout=100){let success=ensureSyntaxTree(view.state,upto,timeout);if(success!=syntaxTree(view.state))view.dispatch({});return!!success;}function syntaxParserRunning(view){var _a;return((_a=view.plugin(parseWorker))===null||_a===void 0?void 0:_a.isWorking())||false;}class DocInput{constructor(doc){this.doc=doc;this.cursorPos=0;this.string="";this.cursor=doc.iter();}get length(){return this.doc.length;}syncTo(pos){this.string=this.cursor.next(pos-this.cursorPos).value;this.cursorPos=pos+this.string.length;return this.cursorPos-this.string.length;}chunk(pos){this.syncTo(pos);return this.string;}get lineChunks(){return true;}read(from,to){let stringStart=this.cursorPos-this.string.length;if(from=this.cursorPos)return this.doc.sliceString(from,to);else return this.string.slice(from-stringStart,to-stringStart);}}let currentContext=null;class ParseContext{constructor(parser,state,fragments=[],tree,treeLen,viewport,skipped,scheduleOn){this.parser=parser;this.state=state;this.fragments=fragments;this.tree=tree;this.treeLen=treeLen;this.viewport=viewport;this.skipped=skipped;this.scheduleOn=scheduleOn;this.parse=null;this.tempSkipped=[];}static create(parser,state,viewport){return new ParseContext(parser,state,[],Tree.empty,0,viewport,[],null);}startParse(){return this.parser.startParse(new DocInput(this.state.doc),this.fragments);}work(until,upto){if(upto!=null&&upto>=this.state.doc.length)upto=undefined;if(this.tree!=Tree.empty&&this.isDone(upto!==null&&upto!==void 0?upto:this.state.doc.length)){this.takeTree();return true;}return this.withContext(()=>{var _a;if(typeof until=="number"){let endTime=Date.now()+until;until=()=>Date.now()>endTime;}if(!this.parse)this.parse=this.startParse();if(upto!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>upto)&&upto=this.treeLen){if(this.parse.stoppedAt==null||this.parse.stoppedAt>pos)this.parse.stopAt(pos);this.withContext(()=>{while(!(tree=this.parse.advance())){}});this.treeLen=pos;this.tree=tree;this.fragments=this.withoutTempSkipped(TreeFragment.addTree(this.tree,this.fragments,true));this.parse=null;}}withContext(f){let prev=currentContext;currentContext=this;try{return f();}finally{currentContext=prev;}}withoutTempSkipped(fragments){for(let r;r=this.tempSkipped.pop();)fragments=cutFragments(fragments,r.from,r.to);return fragments;}changes(changes,newState){let{fragments,tree,treeLen,viewport,skipped}=this;this.takeTree();if(!changes.empty){let ranges=[];changes.iterChangedRanges((fromA,toA,fromB,toB)=>ranges.push({fromA,toA,fromB,toB}));fragments=TreeFragment.applyChanges(fragments,ranges);tree=Tree.empty;treeLen=0;viewport={from:changes.mapPos(viewport.from,-1),to:changes.mapPos(viewport.to,1)};if(this.skipped.length){skipped=[];for(let _i167=0,_this$skipped=this.skipped,_length167=_this$skipped.length;_i167<_length167;_i167++){let r=_this$skipped[_i167];let from=changes.mapPos(r.from,1),to=changes.mapPos(r.to,-1);if(fromviewport.from){this.fragments=cutFragments(this.fragments,from,to);this.skipped.splice(i--,1);}}if(this.skipped.length>=startLen)return false;this.reset();return true;}reset(){if(this.parse){this.takeTree();this.parse=null;}}skipUntilInView(from,to){this.skipped.push({from,to});}static getSkippingParser(until){return new class extends Parser{createParse(input,fragments,ranges){let from=ranges[0].from,to=ranges[ranges.length-1].to;let parser={parsedPos:from,advance(){let cx=currentContext;if(cx){for(let _i168=0,_length168=ranges.length;_i168<_length168;_i168++){let r=ranges[_i168];cx.tempSkipped.push(r);}if(until)cx.scheduleOn=cx.scheduleOn?Promise.all([cx.scheduleOn,until]):until;}this.parsedPos=to;return new Tree(NodeType.none,[],[],to-from);},stoppedAt:null,stopAt(){}};return parser;}}();}isDone(upto){upto=Math.min(upto,this.state.doc.length);let frags=this.fragments;return this.treeLen>=upto&&frags.length&&frags[0].from==0&&frags[0].to>=upto;}static get(){return currentContext;}}function cutFragments(fragments,from,to){return TreeFragment.applyChanges(fragments,[{fromA:from,toA:to,fromB:from,toB:to}]);}class LanguageState{constructor(context){this.context=context;this.tree=context.tree;}apply(tr){if(!tr.docChanged&&this.tree==this.context.tree)return this;let newCx=this.context.changes(tr.changes,tr.state);let upto=this.context.treeLen==tr.startState.doc.length?undefined:Math.max(tr.changes.mapPos(this.context.treeLen),newCx.viewport.to);if(!newCx.work(20,upto))newCx.takeTree();return new LanguageState(newCx);}static init(state){let vpTo=Math.min(3000,state.doc.length);let parseState=ParseContext.create(state.facet(language).parser,state,{from:0,to:vpTo});if(!parseState.work(20,vpTo))parseState.takeTree();return new LanguageState(parseState);}}Language.state=StateField.define({create:LanguageState.init,update(value,tr){for(let _i169=0,_tr$effects5=tr.effects,_length169=_tr$effects5.length;_i169<_length169;_i169++){let e=_tr$effects5[_i169];if(e.is(Language.setState))return e.value;}if(tr.startState.facet(language)!=tr.state.facet(language))return LanguageState.init(tr.state);return value.apply(tr);}});let requestIdle=callback=>{let timeout=setTimeout(()=>callback(),500);return()=>clearTimeout(timeout);};if(typeof requestIdleCallback!="undefined")requestIdle=callback=>{let idle=-1,timeout=setTimeout(()=>{idle=requestIdleCallback(callback,{timeout:500-100});},100);return()=>idle<0?clearTimeout(timeout):cancelIdleCallback(idle);};const isInputPending=typeof navigator!="undefined"&&((_a=navigator.scheduling)===null||_a===void 0?void 0:_a.isInputPending)?()=>navigator.scheduling.isInputPending():null;const parseWorker=ViewPlugin.fromClass(class ParseWorker{constructor(view){this.view=view;this.working=null;this.workScheduled=0;this.chunkEnd=-1;this.chunkBudget=-1;this.work=this.work.bind(this);this.scheduleWork();}update(update){let cx=this.view.state.field(Language.state).context;if(cx.updateViewport(update.view.viewport)||this.view.viewport.to>cx.treeLen)this.scheduleWork();if(update.docChanged){if(this.view.hasFocus)this.chunkBudget+=50;this.scheduleWork();}this.checkAsyncSchedule(cx);}scheduleWork(){if(this.working)return;let{state}=this.view,field=state.field(Language.state);if(field.tree!=field.context.tree||!field.context.isDone(state.doc.length))this.working=requestIdle(this.work);}work(deadline){this.working=null;let now=Date.now();if(this.chunkEndvpTo+1000;let done=field.context.work(()=>{return isInputPending&&isInputPending()||Date.now()>endTime;},vpTo+(viewportFirst?0:100000));this.chunkBudget-=Date.now()-now;if(done||this.chunkBudget<=0){field.context.takeTree();this.view.dispatch({effects:Language.setState.of(new LanguageState(field.context))});}if(this.chunkBudget>0&&!(done&&!viewportFirst))this.scheduleWork();this.checkAsyncSchedule(field.context);}checkAsyncSchedule(cx){if(cx.scheduleOn){this.workScheduled++;cx.scheduleOn.then(()=>this.scheduleWork()).catch(err=>logException(this.view.state,err)).then(()=>this.workScheduled--);cx.scheduleOn=null;}}destroy(){if(this.working)this.working();}isWorking(){return!!(this.working||this.workScheduled>0);}},{eventHandlers:{focus(){this.scheduleWork();}}});const language=Facet.define({combine(languages){return languages.length?languages[0]:null;},enables:language=>[Language.state,parseWorker,EditorView.contentAttributes.compute([language],state=>{let lang=state.facet(language);return lang&&lang.name?{"data-language":lang.name}:{};})]});class LanguageSupport{constructor(language,support=[]){this.language=language;this.support=support;this.extension=[language,support];}}class LanguageDescription{constructor(name,alias,extensions,filename,loadFunc,support=undefined){this.name=name;this.alias=alias;this.extensions=extensions;this.filename=filename;this.loadFunc=loadFunc;this.support=support;this.loading=null;}load(){return this.loading||(this.loading=this.loadFunc().then(support=>this.support=support,err=>{this.loading=null;throw err;}));}static of(spec){let{load,support}=spec;if(!load){if(!support)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");load=()=>Promise.resolve(support);}return new LanguageDescription(spec.name,(spec.alias||[]).concat(spec.name).map(s=>s.toLowerCase()),spec.extensions||[],spec.filename,load,support);}static matchFilename(descs,filename){for(let _i170=0,_length170=descs.length;_i170<_length170;_i170++){let d=descs[_i170];if(d.filename&&d.filename.test(filename))return d;}let ext=/\.([^.]+)$/.exec(filename);if(ext)for(let _i171=0,_length171=descs.length;_i171<_length171;_i171++){let d=descs[_i171];if(d.extensions.indexOf(ext[1])>-1)return d;}return null;}static matchLanguageName(descs,name,fuzzy=true){name=name.toLowerCase();for(let _i172=0,_length172=descs.length;_i172<_length172;_i172++){let d=descs[_i172];if(d.alias.some(a=>a==name))return d;}if(fuzzy)for(let _i173=0,_length173=descs.length;_i173<_length173;_i173++){let d=descs[_i173];for(let _i174=0,_d$alias=d.alias,_length174=_d$alias.length;_i174<_length174;_i174++){let a=_d$alias[_i174];let found=name.indexOf(a);if(found>-1&&(a.length>2||!/\w/.test(name[found-1])&&!/\w/.test(name[found+a.length])))return d;}}return null;}}const indentService=Facet.define();const indentUnit=Facet.define({combine:values=>{if(!values.length)return" ";let unit=values[0];if(!unit||/\S/.test(unit)||Array.from(unit).some(e=>e!=unit[0]))throw new Error("Invalid indent unit: "+JSON.stringify(values[0]));return unit;}});function getIndentUnit(state){let unit=state.facet(indentUnit);return unit.charCodeAt(0)==9?state.tabSize*unit.length:unit.length;}function indentString(state,cols){let result="",ts=state.tabSize,ch=state.facet(indentUnit)[0];if(ch=="\t"){while(cols>=ts){result+="\t";cols-=ts;}ch=" ";}for(let i=0;i=pos?syntaxIndentation(context,tree,pos):null;}function indentRange(state,from,to){let updated=Object.create(null);let context=new IndentContext(state,{overrideIndentation:start=>{var _a;return(_a=updated[start])!==null&&_a!==void 0?_a:-1;}});let changes=[];for(let pos=from;pos<=to;){let line=state.doc.lineAt(pos);pos=line.to+1;let indent=getIndentation(context,line.from);if(indent==null)continue;if(!/\S/.test(line.text))indent=0;let cur=/^\s*/.exec(line.text)[0];let norm=indentString(state,indent);if(cur!=norm){updated[line.from]=indent;changes.push({from:line.from,to:line.from+cur.length,insert:norm});}}return state.changes(changes);}class IndentContext{constructor(state,options={}){this.state=state;this.options=options;this.unit=getIndentUnit(state);}lineAt(pos,bias=1){let line=this.state.doc.lineAt(pos);let{simulateBreak,simulateDoubleBreak}=this.options;if(simulateBreak!=null&&simulateBreak>=line.from&&simulateBreak<=line.to){if(simulateDoubleBreak&&simulateBreak==pos)return{text:"",from:pos};else if(bias<0?simulateBreak-1)result+=override-this.countColumn(text,text.search(/\S|$/));return result;}countColumn(line,pos=line.length){return countColumn(line,this.state.tabSize,pos);}lineIndent(pos,bias=1){let{text,from}=this.lineAt(pos,bias);let override=this.options.overrideIndentation;if(override){let overriden=override(from);if(overriden>-1)return overriden;}return this.countColumn(text,text.search(/\S|$/));}get simulatedBreak(){return this.options.simulateBreak||null;}}const indentNodeProp=new NodeProp();function syntaxIndentation(cx,ast,pos){return indentFrom(ast.resolveInner(pos).enterUnfinishedNodesBefore(pos),pos,cx);}function ignoreClosed(cx){return cx.pos==cx.options.simulateBreak&&cx.options.simulateDoubleBreak;}function indentStrategy(tree){let strategy=tree.type.prop(indentNodeProp);if(strategy)return strategy;let first=tree.firstChild,close;if(first&&(close=first.type.prop(NodeProp.closedBy))){let last=tree.lastChild,closed=last&&close.indexOf(last.name)>-1;return cx=>delimitedStrategy(cx,true,1,undefined,closed&&!ignoreClosed(cx)?last.from:undefined);}return tree.parent==null?topIndent$2:null;}function indentFrom(node,pos,base){for(;node;node=node.parent){let strategy=indentStrategy(node);if(strategy)return strategy(TreeIndentContext.create(base,pos,node));}return null;}function topIndent$2(){return 0;}class TreeIndentContext extends IndentContext{constructor(base,pos,node){super(base.state,base.options);this.base=base;this.pos=pos;this.node=node;}static create(base,pos,node){return new TreeIndentContext(base,pos,node);}get textAfter(){return this.textAfterPos(this.pos);}get baseIndent(){return this.baseIndentFor(this.node);}baseIndentFor(node){let line=this.state.doc.lineAt(node.from);for(;;){let atBreak=node.resolve(line.from);while(atBreak.parent&&atBreak.parent.from==atBreak.from)atBreak=atBreak.parent;if(isParent(atBreak,node))break;line=this.state.doc.lineAt(atBreak.from);}return this.lineIndent(line.from);}continue(){let parent=this.node.parent;return parent?indentFrom(parent,this.pos,this.base):0;}}function isParent(parent,of){for(let cur=of;cur;cur=cur.parent)if(parent==cur)return true;return false;}function bracketedAligned(context){let tree=context.node;let openToken=tree.childAfter(tree.from),last=tree.lastChild;if(!openToken)return null;let sim=context.options.simulateBreak;let openLine=context.state.doc.lineAt(openToken.from);let lineEnd=sim==null||sim<=openLine.from?openLine.to:Math.min(openLine.to,sim);for(let pos=openToken.to;;){let next=tree.childAfter(pos);if(!next||next==last)return null;if(!next.type.isSkipped)return next.fromdelimitedStrategy(context,align,units,closing);}function delimitedStrategy(context,align,units,closing,closedAt){let after=context.textAfter,space=after.match(/^\s*/)[0].length;let closed=closing&&after.slice(space,space+closing.length)==closing||closedAt==context.pos+space;let aligned=align?bracketedAligned(context):null;if(aligned)return closed?context.column(aligned.from):context.column(aligned.to);return context.baseIndent+(closed?0:context.unit*units);}const flatIndent=context=>context.baseIndent;function continuedIndent({except,units=1}={}){return context=>{let matchExcept=except&&except.test(context.textAfter);return context.baseIndent+(matchExcept?0:units*context.unit);};}const DontIndentBeyond=200;function indentOnInput(){return EditorState.transactionFilter.of(tr=>{if(!tr.docChanged||!tr.isUserEvent("input.type")&&!tr.isUserEvent("input.complete"))return tr;let rules=tr.startState.languageDataAt("indentOnInput",tr.startState.selection.main.head);if(!rules.length)return tr;let doc=tr.newDoc,{head}=tr.newSelection.main,line=doc.lineAt(head);if(head>line.from+DontIndentBeyond)return tr;let lineStart=doc.sliceString(line.from,head);if(!rules.some(r=>r.test(lineStart)))return tr;let{state}=tr,last=-1,changes=[];for(let _i176=0,_state$selection$rang5=state.selection.ranges,_length176=_state$selection$rang5.length;_i176<_length176;_i176++){let{head}=_state$selection$rang5[_i176];let line=state.doc.lineAt(head);if(line.from==last)continue;last=line.from;let indent=getIndentation(state,line.from);if(indent==null)continue;let cur=/^\s*/.exec(line.text)[0];let norm=indentString(state,indent);if(cur!=norm)changes.push({from:line.from,to:line.from+cur.length,insert:norm});}return changes.length?[tr,{changes,sequential:true}]:tr;});}const foldService=Facet.define();const foldNodeProp=new NodeProp();function foldInside(node){let first=node.firstChild,last=node.lastChild;return first&&first.toend)continue;if(found&&cur.from=start&&value.to>end)found=value;}}return found;}function isUnfinished(node){let ch=node.lastChild;return ch&&ch.to==node.to&&ch.type.isError;}function foldable(state,lineStart,lineEnd){for(let _i177=0,_state$facet3=state.facet(foldService),_length177=_state$facet3.length;_i177<_length177;_i177++){let service=_state$facet3[_i177];let result=service(state,lineStart,lineEnd);if(result)return result;}return syntaxFolding(state,lineStart,lineEnd);}function mapRange(range,mapping){let from=mapping.mapPos(range.from,1),to=mapping.mapPos(range.to,-1);return from>=to?undefined:{from,to};}const foldEffect=StateEffect.define({map:mapRange});const unfoldEffect=StateEffect.define({map:mapRange});function selectedLines(view){let lines=[];for(let _i178=0,_view$state$selection2=view.state.selection.ranges,_length178=_view$state$selection2.length;_i178<_length178;_i178++){let{head}=_view$state$selection2[_i178];if(lines.some(l=>l.from<=head&&l.to>=head))continue;lines.push(view.lineBlockAt(head));}return lines;}const foldState=StateField.define({create(){return Decoration.none;},update(folded,tr){folded=folded.map(tr.changes);for(let _i179=0,_tr$effects6=tr.effects,_length179=_tr$effects6.length;_i179<_length179;_i179++){let e=_tr$effects6[_i179];if(e.is(foldEffect)&&!foldExists(folded,e.value.from,e.value.to)){let{preparePlaceholder}=tr.state.facet(foldConfig);let widget=!preparePlaceholder?foldWidget:Decoration.replace({widget:new PreparedFoldWidget(preparePlaceholder(tr.state,e.value))});folded=folded.update({add:[widget.range(e.value.from,e.value.to)]});}else if(e.is(unfoldEffect)){folded=folded.update({filter:(from,to)=>e.value.from!=from||e.value.to!=to,filterFrom:e.value.from,filterTo:e.value.to});}}if(tr.selection){let onSelection=false,{head}=tr.selection.main;folded.between(head,head,(a,b)=>{if(ahead)onSelection=true;});if(onSelection)folded=folded.update({filterFrom:head,filterTo:head,filter:(a,b)=>b<=head||a>=head});}return folded;},provide:f=>EditorView.decorations.from(f),toJSON(folded,state){let ranges=[];folded.between(0,state.doc.length,(from,to)=>{ranges.push(from,to);});return ranges;},fromJSON(value){if(!Array.isArray(value)||value.length%2)throw new RangeError("Invalid JSON for fold state");let ranges=[];for(let i=0;i{if(!found||found.from>from)found={from,to};});return found;}function foldExists(folded,from,to){let found=false;folded.between(from,from,(a,b)=>{if(a==from&&b==to)found=true;});return found;}function maybeEnable(state,other){return state.field(foldState,false)?other:other.concat(StateEffect.appendConfig.of(codeFolding()));}const foldCode=view=>{for(let _i180=0,_selectedLines=selectedLines(view),_length180=_selectedLines.length;_i180<_length180;_i180++){let line=_selectedLines[_i180];let range=foldable(view.state,line.from,line.to);if(range){view.dispatch({effects:maybeEnable(view.state,[foldEffect.of(range),announceFold(view,range)])});return true;}}return false;};const unfoldCode=view=>{if(!view.state.field(foldState,false))return false;let effects=[];for(let _i181=0,_selectedLines2=selectedLines(view),_length181=_selectedLines2.length;_i181<_length181;_i181++){let line=_selectedLines2[_i181];let folded=findFold(view.state,line.from,line.to);if(folded)effects.push(unfoldEffect.of(folded),announceFold(view,folded,false));}if(effects.length)view.dispatch({effects});return effects.length>0;};function announceFold(view,range,fold=true){let lineFrom=view.state.doc.lineAt(range.from).number,lineTo=view.state.doc.lineAt(range.to).number;return EditorView.announce.of(`${view.state.phrase(fold?"Folded lines":"Unfolded lines")} ${lineFrom} ${view.state.phrase("to")} ${lineTo}.`);}const foldAll=view=>{let{state}=view,effects=[];for(let pos=0;pos{let field=view.state.field(foldState,false);if(!field||!field.size)return false;let effects=[];field.between(0,view.state.doc.length,(from,to)=>{effects.push(unfoldEffect.of({from,to}));});view.dispatch({effects});return true;};function foldableContainer(view,lineBlock){for(let line=lineBlock;;){let foldableRegion=foldable(view.state,line.from,line.to);if(foldableRegion&&foldableRegion.to>lineBlock.from)return foldableRegion;if(!line.from)return null;line=view.lineBlockAt(line.from-1);}}const toggleFold=view=>{let effects=[];for(let _i182=0,_selectedLines3=selectedLines(view),_length182=_selectedLines3.length;_i182<_length182;_i182++){let line=_selectedLines3[_i182];let folded=findFold(view.state,line.from,line.to);if(folded){effects.push(unfoldEffect.of(folded),announceFold(view,folded,false));}else{let foldRange=foldableContainer(view,line);if(foldRange)effects.push(foldEffect.of(foldRange),announceFold(view,foldRange));}}if(effects.length>0)view.dispatch({effects:maybeEnable(view.state,effects)});return!!effects.length;};const foldKeymap=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:foldCode},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:unfoldCode},{key:"Ctrl-Alt-[",run:foldAll},{key:"Ctrl-Alt-]",run:unfoldAll}];const defaultConfig={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"};const foldConfig=Facet.define({combine(values){return combineConfig(values,defaultConfig);}});function codeFolding(config){let result=[foldState,baseTheme$1$2];if(config)result.push(foldConfig.of(config));return result;}function widgetToDOM(view,prepared){let{state}=view,conf=state.facet(foldConfig);let onclick=event=>{let line=view.lineBlockAt(view.posAtDOM(event.target));let folded=findFold(view.state,line.from,line.to);if(folded)view.dispatch({effects:unfoldEffect.of(folded)});event.preventDefault();};if(conf.placeholderDOM)return conf.placeholderDOM(view,onclick,prepared);let element=document.createElement("span");element.textContent=conf.placeholderText;element.setAttribute("aria-label",state.phrase("folded code"));element.title=state.phrase("unfold");element.className="cm-foldPlaceholder";element.onclick=onclick;return element;}const foldWidget=Decoration.replace({widget:new class extends WidgetType{toDOM(view){return widgetToDOM(view,null);}}()});class PreparedFoldWidget extends WidgetType{constructor(value){super();this.value=value;}eq(other){return this.value==other.value;}toDOM(view){return widgetToDOM(view,this.value);}}const foldGutterDefaults={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>false};class FoldMarker extends GutterMarker{constructor(config,open){super();this.config=config;this.open=open;}eq(other){return this.config==other.config&&this.open==other.open;}toDOM(view){if(this.config.markerDOM)return this.config.markerDOM(this.open);let span=document.createElement("span");span.textContent=this.open?this.config.openText:this.config.closedText;span.title=view.state.phrase(this.open?"Fold line":"Unfold line");return span;}}function foldGutter(config={}){let fullConfig=Object.assign(Object.assign({},foldGutterDefaults),config);let canFold=new FoldMarker(fullConfig,true),canUnfold=new FoldMarker(fullConfig,false);let markers=ViewPlugin.fromClass(class{constructor(view){this.from=view.viewport.from;this.markers=this.buildMarkers(view);}update(update){if(update.docChanged||update.viewportChanged||update.startState.facet(language)!=update.state.facet(language)||update.startState.field(foldState,false)!=update.state.field(foldState,false)||syntaxTree(update.startState)!=syntaxTree(update.state)||fullConfig.foldingChanged(update))this.markers=this.buildMarkers(update.view);}buildMarkers(view){let builder=new RangeSetBuilder();for(let _i183=0,_view$viewportLineBlo=view.viewportLineBlocks,_length183=_view$viewportLineBlo.length;_i183<_length183;_i183++){let line=_view$viewportLineBlo[_i183];let mark=findFold(view.state,line.from,line.to)?canUnfold:foldable(view.state,line.from,line.to)?canFold:null;if(mark)builder.add(line.from,line.from,mark);}return builder.finish();}});let{domEventHandlers}=fullConfig;return[markers,gutter({class:"cm-foldGutter",markers(view){var _a;return((_a=view.plugin(markers))===null||_a===void 0?void 0:_a.markers)||RangeSet.empty;},initialSpacer(){return new FoldMarker(fullConfig,false);},domEventHandlers:Object.assign(Object.assign({},domEventHandlers),{click:(view,line,event)=>{if(domEventHandlers.click&&domEventHandlers.click(view,line,event))return true;let folded=findFold(view.state,line.from,line.to);if(folded){view.dispatch({effects:unfoldEffect.of(folded)});return true;}let range=foldable(view.state,line.from,line.to);if(range){view.dispatch({effects:foldEffect.of(range)});return true;}return false;}})}),codeFolding()];}const baseTheme$1$2=EditorView.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class HighlightStyle{constructor(specs,options){this.specs=specs;let modSpec;function def(spec){let cls=StyleModule.newName();(modSpec||(modSpec=Object.create(null)))["."+cls]=spec;return cls;}const all=typeof options.all=="string"?options.all:options.all?def(options.all):undefined;const scopeOpt=options.scope;this.scope=scopeOpt instanceof Language?type=>type.prop(languageDataProp)==scopeOpt.data:scopeOpt?type=>type==scopeOpt:undefined;this.style=tagHighlighter(specs.map(style=>({tag:style.tag,class:style.class||def(Object.assign({},style,{tag:null}))})),{all}).style;this.module=modSpec?new StyleModule(modSpec):null;this.themeType=options.themeType;}static define(specs,options){return new HighlightStyle(specs,options||{});}}const highlighterFacet=Facet.define();const fallbackHighlighter=Facet.define({combine(values){return values.length?[values[0]]:null;}});function getHighlighters(state){let main=state.facet(highlighterFacet);return main.length?main:state.facet(fallbackHighlighter);}function syntaxHighlighting(highlighter,options){let ext=[treeHighlighter],themeType;if(highlighter instanceof HighlightStyle){if(highlighter.module)ext.push(EditorView.styleModule.of(highlighter.module));themeType=highlighter.themeType;}if(options===null||options===void 0?void 0:options.fallback)ext.push(fallbackHighlighter.of(highlighter));else if(themeType)ext.push(highlighterFacet.computeN([EditorView.darkTheme],state=>{return state.facet(EditorView.darkTheme)==(themeType=="dark")?[highlighter]:[];}));else ext.push(highlighterFacet.of(highlighter));return ext;}function highlightingFor(state,tags,scope){let highlighters=getHighlighters(state);let result=null;if(highlighters)for(let _i184=0,_length184=highlighters.length;_i184<_length184;_i184++){let highlighter=highlighters[_i184];if(!highlighter.scope||scope&&highlighter.scope(scope)){let cls=highlighter.style(tags);if(cls)result=result?result+" "+cls:cls;}}return result;}class TreeHighlighter{constructor(view){this.markCache=Object.create(null);this.tree=syntaxTree(view.state);this.decorations=this.buildDeco(view,getHighlighters(view.state));}update(update){let tree=syntaxTree(update.state),highlighters=getHighlighters(update.state);let styleChange=highlighters!=getHighlighters(update.startState);if(tree.length{builder.add(from,to,this.markCache[style]||(this.markCache[style]=Decoration.mark({class:style})));},from,to);}return builder.finish();}}const treeHighlighter=Prec.high(ViewPlugin.fromClass(TreeHighlighter,{decorations:v=>v.decorations}));const defaultHighlightStyle=HighlightStyle.define([{tag:tags$1.meta,color:"#404740"},{tag:tags$1.link,textDecoration:"underline"},{tag:tags$1.heading,textDecoration:"underline",fontWeight:"bold"},{tag:tags$1.emphasis,fontStyle:"italic"},{tag:tags$1.strong,fontWeight:"bold"},{tag:tags$1.strikethrough,textDecoration:"line-through"},{tag:tags$1.keyword,color:"#708"},{tag:[tags$1.atom,tags$1.bool,tags$1.url,tags$1.contentSeparator,tags$1.labelName],color:"#219"},{tag:[tags$1.literal,tags$1.inserted],color:"#164"},{tag:[tags$1.string,tags$1.deleted],color:"#a11"},{tag:[tags$1.regexp,tags$1.escape,tags$1.special(tags$1.string)],color:"#e40"},{tag:tags$1.definition(tags$1.variableName),color:"#00f"},{tag:tags$1.local(tags$1.variableName),color:"#30a"},{tag:[tags$1.typeName,tags$1.namespace],color:"#085"},{tag:tags$1.className,color:"#167"},{tag:[tags$1.special(tags$1.variableName),tags$1.macroName],color:"#256"},{tag:tags$1.definition(tags$1.propertyName),color:"#00c"},{tag:tags$1.comment,color:"#940"},{tag:tags$1.invalid,color:"#f00"}]);const baseTheme$4=EditorView.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}});const DefaultScanDist=10000,DefaultBrackets="()[]{}";const bracketMatchingConfig=Facet.define({combine(configs){return combineConfig(configs,{afterCursor:true,brackets:DefaultBrackets,maxScanDistance:DefaultScanDist,renderMatch:defaultRenderMatch});}});const matchingMark=Decoration.mark({class:"cm-matchingBracket"}),nonmatchingMark=Decoration.mark({class:"cm-nonmatchingBracket"});function defaultRenderMatch(match){let decorations=[];let mark=match.matched?matchingMark:nonmatchingMark;decorations.push(mark.range(match.start.from,match.start.to));if(match.end)decorations.push(mark.range(match.end.from,match.end.to));return decorations;}const bracketMatchingState=StateField.define({create(){return Decoration.none;},update(deco,tr){if(!tr.docChanged&&!tr.selection)return deco;let decorations=[];let config=tr.state.facet(bracketMatchingConfig);for(let _i186=0,_tr$state$selection$r=tr.state.selection.ranges,_length186=_tr$state$selection$r.length;_i186<_length186;_i186++){let range=_tr$state$selection$r[_i186];if(!range.empty)continue;let match=matchBrackets(tr.state,range.head,-1,config)||range.head>0&&matchBrackets(tr.state,range.head-1,1,config)||config.afterCursor&&(matchBrackets(tr.state,range.head,1,config)||range.headEditorView.decorations.from(f)});const bracketMatchingUnique=[bracketMatchingState,baseTheme$4];function bracketMatching(config={}){return[bracketMatchingConfig.of(config),bracketMatchingUnique];}const bracketMatchingHandle=new NodeProp();function matchingNodes(node,dir,brackets){let byProp=node.prop(dir<0?NodeProp.openedBy:NodeProp.closedBy);if(byProp)return byProp;if(node.name.length==1){let index=brackets.indexOf(node.name);if(index>-1&&index%2==(dir<0?1:0))return[brackets[index+dir]];}return null;}function findHandle(node){let hasHandle=node.type.prop(bracketMatchingHandle);return hasHandle?hasHandle(node.node):node;}function matchBrackets(state,pos,dir,config={}){let maxScanDistance=config.maxScanDistance||DefaultScanDist,brackets=config.brackets||DefaultBrackets;let tree=syntaxTree(state),node=tree.resolveInner(pos,dir);for(let cur=node;cur;cur=cur.parent){let matches=matchingNodes(cur.type,dir,brackets);if(matches&&cur.from0?pos>=handle.from&&poshandle.from&&pos<=handle.to))return matchMarkedBrackets(state,pos,dir,cur,handle,matches,brackets);}}return matchPlainBrackets(state,pos,dir,tree,node.type,maxScanDistance,brackets);}function matchMarkedBrackets(_state,_pos,dir,token,handle,matching,brackets){let parent=token.parent,firstToken={from:handle.from,to:handle.to};let depth=0,cursor=parent===null||parent===void 0?void 0:parent.cursor();if(cursor&&(dir<0?cursor.childBefore(token.from):cursor.childAfter(token.to)))do{if(dir<0?cursor.to<=token.from:cursor.from>=token.to){if(depth==0&&matching.indexOf(cursor.type.name)>-1&&cursor.from0)return null;let startToken={from:dir<0?pos-1:pos,to:dir>0?pos+1:pos};let iter=state.doc.iterRange(pos,dir>0?state.doc.length:0),depth=0;for(let distance=0;!iter.next().done&&distance<=maxScanDistance;){let text=iter.value;if(dir<0)distance+=text.length;let basePos=pos+distance*dir;for(let pos=dir>0?0:text.length-1,end=dir>0?text.length:-1;pos!=end;pos+=dir){let found=brackets.indexOf(text[pos]);if(found<0||tree.resolveInner(basePos+pos,1).type!=tokenType)continue;if(found%2==0==dir>0){depth++;}else if(depth==1){return{start:startToken,end:{from:basePos+pos,to:basePos+pos+1},matched:found>>1==bracket>>1};}else{depth--;}}if(dir>0)distance+=text.length;}return iter.done?{start:startToken,matched:false}:null;}function countCol(string,end,tabSize,startIndex=0,startValue=0){if(end==null){end=string.search(/[^\s\u00a0]/);if(end==-1)end=string.length;}let n=startValue;for(let i=startIndex;i=this.string.length;}sol(){return this.pos==0;}peek(){return this.string.charAt(this.pos)||undefined;}next(){if(this.posstart;}eatSpace(){let start=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos)))++this.pos;return this.pos>start;}skipToEnd(){this.pos=this.string.length;}skipTo(ch){let found=this.string.indexOf(ch,this.pos);if(found>-1){this.pos=found;return true;}}backUp(n){this.pos-=n;}column(){if(this.lastColumnPoscaseInsensitive?str.toLowerCase():str;let substr=this.string.substr(this.pos,pattern.length);if(cased(substr)==cased(pattern)){if(consume!==false)this.pos+=pattern.length;return true;}else return null;}else{let match=this.string.slice(this.pos).match(pattern);if(match&&match.index>0)return null;if(match&&consume!==false)this.pos+=match[0].length;return match;}}current(){return this.string.slice(this.start,this.pos);}}function fullParser(spec){return{name:spec.name||"",token:spec.token,blankLine:spec.blankLine||(()=>{}),startState:spec.startState||(()=>true),copyState:spec.copyState||defaultCopyState,indent:spec.indent||(()=>null),languageData:spec.languageData||{},tokenTable:spec.tokenTable||noTokens};}function defaultCopyState(state){if(typeof state!="object")return state;let newState={};for(let prop in state){let val=state[prop];newState[prop]=val instanceof Array?val.slice():val;}return newState;}const IndentedFrom=new WeakMap();class StreamLanguage extends Language{constructor(parser){let data=defineLanguageFacet(parser.languageData);let p=fullParser(parser),self;let impl=new class extends Parser{createParse(input,fragments,ranges){return new Parse$1(self,input,fragments,ranges);}}();super(data,impl,[indentService.of((cx,pos)=>this.getIndent(cx,pos))],parser.name);this.topNode=docID(data);self=this;this.streamParser=p;this.stateAfter=new NodeProp({perNode:true});this.tokenTable=parser.tokenTable?new TokenTable(p.tokenTable):defaultTokenTable;}static define(spec){return new StreamLanguage(spec);}getIndent(cx,pos){let tree=syntaxTree(cx.state),at=tree.resolve(pos);while(at&&at.type!=this.topNode)at=at.parent;if(!at)return null;let from=undefined;let{overrideIndentation}=cx.options;if(overrideIndentation){from=IndentedFrom.get(cx.state);if(from!=null&&from10000)return null;while(statePos=startPos&&off+tree.length<=before&&tree.prop(lang.stateAfter);if(state)return{state:lang.streamParser.copyState(state),pos:off+tree.length};for(let i=tree.children.length-1;i>=0;i--){let child=tree.children[i],pos=off+tree.positions[i];let found=child instanceof Tree&&pos=tree.length)return tree;if(!inside&&tree.type==lang.topNode)inside=true;for(let i=tree.children.length-1;i>=0;i--){let pos=tree.positions[i],child=tree.children[i],inner;if(posstartPos&&findState(lang,f.tree,0-f.offset,startPos,to),tree;if(found&&(tree=cutTree(lang,f.tree,startPos+f.offset,found.pos+f.offset,false)))return{state:found.state,tree};}return{state:lang.streamParser.startState(editorState?getIndentUnit(editorState):4),tree:Tree.empty};}class Parse$1{constructor(lang,input,fragments,ranges){this.lang=lang;this.input=input;this.fragments=fragments;this.ranges=ranges;this.stoppedAt=null;this.chunks=[];this.chunkPos=[];this.chunk=[];this.chunkReused=undefined;this.rangeIndex=0;this.to=ranges[ranges.length-1].to;let context=ParseContext.get(),from=ranges[0].from;let{state,tree}=findStartInFragments(lang,fragments,from,context===null||context===void 0?void 0:context.state);this.state=state;this.parsedPos=this.chunkStart=from+tree.length;for(let i=0;i=parseEnd)return this.finish();if(context&&this.parsedPos>=context.viewport.to){context.skipUntilInView(this.parsedPos,parseEnd);return this.finish();}return null;}stopAt(pos){this.stoppedAt=pos;}lineAfter(pos){let chunk=this.input.chunk(pos);if(!this.input.lineChunks){let eol=chunk.indexOf("\n");if(eol>-1)chunk=chunk.slice(0,eol);}else if(chunk=="\n"){chunk="";}return pos+chunk.length<=this.to?chunk:chunk.slice(0,this.to-pos);}nextLine(){let from=this.parsedPos,line=this.lineAfter(from),end=from+line.length;for(let index=this.rangeIndex;;){let rangeEnd=this.ranges[index].to;if(rangeEnd>=end)break;line=line.slice(0,rangeEnd-(end-line.length));index++;if(index==this.ranges.length)break;let rangeStart=this.ranges[index].from;let after=this.lineAfter(rangeStart);line+=after;end=rangeStart+after.length;}return{line,end};}skipGapsTo(pos,offset,side){for(;;){let end=this.ranges[this.rangeIndex].to,offPos=pos+offset;if(side>0?end>offPos:end>=offPos)break;let start=this.ranges[++this.rangeIndex].from;offset+=start-end;}return offset;}moveRangeIndex(){while(this.ranges[this.rangeIndex].to1){offset=this.skipGapsTo(from,offset,1);from+=offset;let len0=this.chunk.length;offset=this.skipGapsTo(to,offset,-1);to+=offset;size+=this.chunk.length-len0;}this.chunk.push(id,from,to,size);return offset;}parseLine(context){let{line,end}=this.nextLine(),offset=0,{streamParser}=this.lang;let stream=new StringStream(line,context?context.state.tabSize:4,context?getIndentUnit(context.state):2);if(stream.eol()){streamParser.blankLine(this.state,stream.indentUnit);}else{while(!stream.eol()){let token=readToken$1(streamParser.token,stream,this.state);if(token)offset=this.emitToken(this.lang.tokenTable.resolve(token),this.parsedPos+stream.start,this.parsedPos+stream.pos,4,offset);if(stream.start>10000)break;}}this.parsedPos=end;this.moveRangeIndex();if(this.parsedPosstream.start)return result;}throw new Error("Stream parser failed to advance stream.");}const noTokens=Object.create(null);const typeArray=[NodeType.none];const nodeSet=new NodeSet(typeArray);const warned=[];const defaultTable=Object.create(null);for(let _i188=0,_ref3=[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]],_length188=_ref3.length;_i188<_length188;_i188++){let[legacyName,name]=_ref3[_i188];defaultTable[legacyName]=createTokenType(noTokens,name);}class TokenTable{constructor(extra){this.extra=extra;this.table=Object.assign(Object.create(null),defaultTable);}resolve(tag){return!tag?0:this.table[tag]||(this.table[tag]=createTokenType(this.extra,tag));}}const defaultTokenTable=new TokenTable(noTokens);function warnForPart(part,msg){if(warned.indexOf(part)>-1)return;warned.push(part);console.warn(msg);}function createTokenType(extra,tagStr){let tag=null;for(let _i189=0,_tagStr$split=tagStr.split("."),_length189=_tagStr$split.length;_i189<_length189;_i189++){let part=_tagStr$split[_i189];let value=extra[part]||tags$1[part];if(!value){warnForPart(part,`Unknown highlighting tag ${part}`);}else if(typeof value=="function"){if(!tag)warnForPart(part,`Modifier ${part} used at start of tag`);else tag=value(tag);}else{if(tag)warnForPart(part,`Tag ${part} used as modifier`);else tag=value;}}if(!tag)return 0;let name=tagStr.replace(/ /g,"_"),type=NodeType.define({id:typeArray.length,name,props:[styleTags({[name]:tag})]});typeArray.push(type);return type.id;}function docID(data){let type=NodeType.define({id:typeArray.length,name:"Document",props:[languageDataProp.add(()=>data)],top:true});typeArray.push(type);return type;}var _m2=Object.freeze({__proto__:null,DocInput:DocInput,HighlightStyle:HighlightStyle,IndentContext:IndentContext,LRLanguage:LRLanguage,Language:Language,LanguageDescription:LanguageDescription,LanguageSupport:LanguageSupport,ParseContext:ParseContext,StreamLanguage:StreamLanguage,StringStream:StringStream,TreeIndentContext:TreeIndentContext,bracketMatching:bracketMatching,bracketMatchingHandle:bracketMatchingHandle,codeFolding:codeFolding,continuedIndent:continuedIndent,defaultHighlightStyle:defaultHighlightStyle,defineLanguageFacet:defineLanguageFacet,delimitedIndent:delimitedIndent,ensureSyntaxTree:ensureSyntaxTree,flatIndent:flatIndent,foldAll:foldAll,foldCode:foldCode,foldEffect:foldEffect,foldGutter:foldGutter,foldInside:foldInside,foldKeymap:foldKeymap,foldNodeProp:foldNodeProp,foldService:foldService,foldState:foldState,foldable:foldable,foldedRanges:foldedRanges,forceParsing:forceParsing,getIndentUnit:getIndentUnit,getIndentation:getIndentation,highlightingFor:highlightingFor,indentNodeProp:indentNodeProp,indentOnInput:indentOnInput,indentRange:indentRange,indentService:indentService,indentString:indentString,indentUnit:indentUnit,language:language,languageDataProp:languageDataProp,matchBrackets:matchBrackets,sublanguageProp:sublanguageProp,syntaxHighlighting:syntaxHighlighting,syntaxParserRunning:syntaxParserRunning,syntaxTree:syntaxTree,syntaxTreeAvailable:syntaxTreeAvailable,toggleFold:toggleFold,unfoldAll:unfoldAll,unfoldCode:unfoldCode,unfoldEffect:unfoldEffect});const toggleComment=target=>{let{state}=target,line=state.doc.lineAt(state.selection.main.from),config=getConfig(target.state,line.from);return config.line?toggleLineComment(target):config.block?toggleBlockCommentByLine(target):false;};function command(f,option){return({state,dispatch})=>{if(state.readOnly)return false;let tr=f(option,state);if(!tr)return false;dispatch(state.update(tr));return true;};}const toggleLineComment=command(changeLineComment,0);const lineComment=command(changeLineComment,1);const lineUncomment=command(changeLineComment,2);const toggleBlockComment=command(changeBlockComment,0);const blockComment=command(changeBlockComment,1);const blockUncomment=command(changeBlockComment,2);const toggleBlockCommentByLine=command((o,s)=>changeBlockComment(o,s,selectedLineRanges(s)),0);function getConfig(state,pos){let data=state.languageDataAt("commentTokens",pos);return data.length?data[0]:{};}const SearchMargin=50;function findBlockComment(state,{open,close},from,to){let textBefore=state.sliceDoc(from-SearchMargin,from);let textAfter=state.sliceDoc(to,to+SearchMargin);let spaceBefore=/\s*$/.exec(textBefore)[0].length,spaceAfter=/^\s*/.exec(textAfter)[0].length;let beforeOff=textBefore.length-spaceBefore;if(textBefore.slice(beforeOff-open.length,beforeOff)==open&&textAfter.slice(spaceAfter,spaceAfter+close.length)==close){return{open:{pos:from-spaceBefore,margin:spaceBefore&&1},close:{pos:to+spaceAfter,margin:spaceAfter&&1}};}let startText,endText;if(to-from<=2*SearchMargin){startText=endText=state.sliceDoc(from,to);}else{startText=state.sliceDoc(from,from+SearchMargin);endText=state.sliceDoc(to-SearchMargin,to);}let startSpace=/^\s*/.exec(startText)[0].length,endSpace=/\s*$/.exec(endText)[0].length;let endOff=endText.length-endSpace-close.length;if(startText.slice(startSpace,startSpace+open.length)==open&&endText.slice(endOff,endOff+close.length)==close){return{open:{pos:from+startSpace+open.length,margin:/\s/.test(startText.charAt(startSpace+open.length))?1:0},close:{pos:to-endSpace-close.length,margin:/\s/.test(endText.charAt(endOff-1))?1:0}};}return null;}function selectedLineRanges(state){let ranges=[];for(let _i190=0,_state$selection$rang6=state.selection.ranges,_length190=_state$selection$rang6.length;_i190<_length190;_i190++){let r=_state$selection$rang6[_i190];let fromLine=state.doc.lineAt(r.from);let toLine=r.to<=fromLine.to?fromLine:state.doc.lineAt(r.to);let last=ranges.length-1;if(last>=0&&ranges[last].to>fromLine.from)ranges[last].to=toLine.to;else ranges.push({from:fromLine.from+/^\s*/.exec(fromLine.text)[0].length,to:toLine.to});}return ranges;}function changeBlockComment(option,state,ranges=state.selection.ranges){let tokens=ranges.map(r=>getConfig(state,r.from).block);if(!tokens.every(c=>c))return null;let comments=ranges.map((r,i)=>findBlockComment(state,tokens[i],r.from,r.to));if(option!=2&&!comments.every(c=>c)){return{changes:state.changes(ranges.map((range,i)=>{if(comments[i])return[];return[{from:range.from,insert:tokens[i].open+" "},{from:range.to,insert:" "+tokens[i].close}];}))};}else if(option!=1&&comments.some(c=>c)){let changes=[];for(let i=0,comment;iprevLine&&(from==to||to>line.from)){prevLine=line.from;let indent=/^\s*/.exec(line.text)[0].length;let empty=indent==line.length;let comment=line.text.slice(indent,indent+token.length)==token?indent:-1;if(indentl.comment<0&&(!l.empty||l.single))){let changes=[];for(let _i192=0,_length192=lines.length;_i192<_length192;_i192++){let{line,token,indent,empty,single}=lines[_i192];if(single||!empty)changes.push({from:line.from+indent,insert:token+" "});}let changeSet=state.changes(changes);return{changes:changeSet,selection:state.selection.map(changeSet,1)};}else if(option!=1&&lines.some(l=>l.comment>=0)){let changes=[];for(let _i193=0,_length193=lines.length;_i193<_length193;_i193++){let{line,comment,token}=lines[_i193];if(comment>=0){let from=line.from+comment,to=from+token.length;if(line.text[to-line.from]==" ")to++;changes.push({from,to});}}return{changes};}return null;}const fromHistory=Annotation.define();const isolateHistory=Annotation.define();const invertedEffects=Facet.define();const historyConfig=Facet.define({combine(configs){return combineConfig(configs,{minDepth:100,newGroupDelay:500,joinToEvent:(_t,isAdjacent)=>isAdjacent},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(a,b)=>(tr,adj)=>a(tr,adj)||b(tr,adj)});}});function changeEnd(changes){let end=0;changes.iterChangedRanges((_,to)=>end=to);return end;}const historyField_=StateField.define({create(){return HistoryState.empty;},update(state,tr){let config=tr.state.facet(historyConfig);let fromHist=tr.annotation(fromHistory);if(fromHist){let selection=tr.docChanged?EditorSelection.single(changeEnd(tr.changes)):undefined;let item=HistEvent.fromTransaction(tr,selection),from=fromHist.side;let other=from==0?state.undone:state.done;if(item)other=updateBranch(other,other.length,config.minDepth,item);else other=addSelection(other,tr.startState.selection);return new HistoryState(from==0?fromHist.rest:other,from==0?other:fromHist.rest);}let isolate=tr.annotation(isolateHistory);if(isolate=="full"||isolate=="before")state=state.isolate();if(tr.annotation(Transaction.addToHistory)===false)return!tr.changes.empty?state.addMapping(tr.changes.desc):state;let event=HistEvent.fromTransaction(tr);let time=tr.annotation(Transaction.time),userEvent=tr.annotation(Transaction.userEvent);if(event)state=state.addChanges(event,time,userEvent,config,tr);else if(tr.selection)state=state.addSelection(tr.startState.selection,time,userEvent,config.newGroupDelay);if(isolate=="full"||isolate=="after")state=state.isolate();return state;},toJSON(value){return{done:value.done.map(e=>e.toJSON()),undone:value.undone.map(e=>e.toJSON())};},fromJSON(json){return new HistoryState(json.done.map(HistEvent.fromJSON),json.undone.map(HistEvent.fromJSON));}});function history(config={}){return[historyField_,historyConfig.of(config),EditorView.domEventHandlers({beforeinput(e,view){let command=e.inputType=="historyUndo"?undo:e.inputType=="historyRedo"?redo:null;if(!command)return false;e.preventDefault();return command(view);}})];}const historyField=historyField_;function cmd(side,selection){return function({state,dispatch}){if(!selection&&state.readOnly)return false;let historyState=state.field(historyField_,false);if(!historyState)return false;let tr=historyState.pop(side,state,selection);if(!tr)return false;dispatch(tr);return true;};}const undo=cmd(0,false);const redo=cmd(1,false);const undoSelection=cmd(0,true);const redoSelection=cmd(1,true);function depth(side){return function(state){let histState=state.field(historyField_,false);if(!histState)return 0;let branch=side==0?histState.done:histState.undone;return branch.length-(branch.length&&!branch[0].changes?1:0);};}const undoDepth=depth(0);const redoDepth=depth(1);class HistEvent{constructor(changes,effects,mapped,startSelection,selectionsAfter){this.changes=changes;this.effects=effects;this.mapped=mapped;this.startSelection=startSelection;this.selectionsAfter=selectionsAfter;}setSelAfter(after){return new HistEvent(this.changes,this.effects,this.mapped,this.startSelection,after);}toJSON(){var _a,_b,_c;return{changes:(_a=this.changes)===null||_a===void 0?void 0:_a.toJSON(),mapped:(_b=this.mapped)===null||_b===void 0?void 0:_b.toJSON(),startSelection:(_c=this.startSelection)===null||_c===void 0?void 0:_c.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())};}static fromJSON(json){return new HistEvent(json.changes&&ChangeSet.fromJSON(json.changes),[],json.mapped&&ChangeDesc.fromJSON(json.mapped),json.startSelection&&EditorSelection.fromJSON(json.startSelection),json.selectionsAfter.map(EditorSelection.fromJSON));}static fromTransaction(tr,selection){let effects=none$2;for(let _i194=0,_tr$startState$facet=tr.startState.facet(invertedEffects),_length194=_tr$startState$facet.length;_i194<_length194;_i194++){let invert=_tr$startState$facet[_i194];let result=invert(tr);if(result.length)effects=effects.concat(result);}if(!effects.length&&tr.changes.empty)return null;return new HistEvent(tr.changes.invert(tr.startState.doc),effects,undefined,selection||tr.startState.selection,none$2);}static selection(selections){return new HistEvent(undefined,none$2,undefined,undefined,selections);}}function updateBranch(branch,to,maxLen,newEvent){let start=to+1>maxLen+20?to-maxLen-1:0;let newBranch=branch.slice(start,to);newBranch.push(newEvent);return newBranch;}function isAdjacent(a,b){let ranges=[],isAdjacent=false;a.iterChangedRanges((f,t)=>ranges.push(f,t));b.iterChangedRanges((_f,_t,f,t)=>{for(let i=0;i=from&&f<=to)isAdjacent=true;}});return isAdjacent;}function eqSelectionShape(a,b){return a.ranges.length==b.ranges.length&&a.ranges.filter((r,i)=>r.empty!=b.ranges[i].empty).length===0;}function conc(a,b){return!a.length?b:!b.length?a:a.concat(b);}const none$2=[];const MaxSelectionsPerEvent=200;function addSelection(branch,selection){if(!branch.length){return[HistEvent.selection([selection])];}else{let lastEvent=branch[branch.length-1];let sels=lastEvent.selectionsAfter.slice(Math.max(0,lastEvent.selectionsAfter.length-MaxSelectionsPerEvent));if(sels.length&&sels[sels.length-1].eq(selection))return branch;sels.push(selection);return updateBranch(branch,branch.length-1,1e9,lastEvent.setSelAfter(sels));}}function popSelection(branch){let last=branch[branch.length-1];let newBranch=branch.slice();newBranch[branch.length-1]=last.setSelAfter(last.selectionsAfter.slice(0,last.selectionsAfter.length-1));return newBranch;}function addMappingToBranch(branch,mapping){if(!branch.length)return branch;let length=branch.length,selections=none$2;while(length){let event=mapEvent(branch[length-1],mapping,selections);if(event.changes&&!event.changes.empty||event.effects.length){let result=branch.slice(0,length);result[length-1]=event;return result;}else{mapping=event.mapped;length--;selections=event.selectionsAfter;}}return selections.length?[HistEvent.selection(selections)]:none$2;}function mapEvent(event,mapping,extraSelections){let selections=conc(event.selectionsAfter.length?event.selectionsAfter.map(s=>s.map(mapping)):none$2,extraSelections);if(!event.changes)return HistEvent.selection(selections);let mappedChanges=event.changes.map(mapping),before=mapping.mapDesc(event.changes,true);let fullMapping=event.mapped?event.mapped.composeDesc(before):before;return new HistEvent(mappedChanges,StateEffect.mapEffects(event.effects,mapping),fullMapping,event.startSelection.map(before),selections);}const joinableUserEvent=/^(input\.type|delete)($|\.)/;class HistoryState{constructor(done,undone,prevTime=0,prevUserEvent=undefined){this.done=done;this.undone=undone;this.prevTime=prevTime;this.prevUserEvent=prevUserEvent;}isolate(){return this.prevTime?new HistoryState(this.done,this.undone):this;}addChanges(event,time,userEvent,config,tr){let done=this.done,lastEvent=done[done.length-1];if(lastEvent&&lastEvent.changes&&!lastEvent.changes.empty&&event.changes&&(!userEvent||joinableUserEvent.test(userEvent))&&(!lastEvent.selectionsAfter.length&&time-this.prevTime0&&time-this.prevTimerange.empty?view.moveByChar(range,forward):rangeEnd(range,forward));}function ltrAtCursor(view){return view.textDirectionAt(view.state.selection.main.head)==Direction.LTR;}const cursorCharLeft=view=>cursorByChar(view,!ltrAtCursor(view));const cursorCharRight=view=>cursorByChar(view,ltrAtCursor(view));const cursorCharForward=view=>cursorByChar(view,true);const cursorCharBackward=view=>cursorByChar(view,false);function cursorByGroup(view,forward){return moveSel(view,range=>range.empty?view.moveByGroup(range,forward):rangeEnd(range,forward));}const cursorGroupLeft=view=>cursorByGroup(view,!ltrAtCursor(view));const cursorGroupRight=view=>cursorByGroup(view,ltrAtCursor(view));const cursorGroupForward=view=>cursorByGroup(view,true);const cursorGroupBackward=view=>cursorByGroup(view,false);const segmenter=typeof Intl!="undefined"&&Intl.Segmenter?new Intl.Segmenter(undefined,{granularity:"word"}):null;function moveBySubword(view,range,forward){let categorize=view.state.charCategorizer(range.from);let cat=CharCategory.Space,pos=range.from,steps=0;let done=false,sawUpper=false,sawLower=false;let step=next=>{if(done)return false;pos+=forward?next.length:-next.length;let nextCat=categorize(next),ahead;if(nextCat==CharCategory.Word&&next.charCodeAt(0)<128&&/[\W_]/.test(next))nextCat=-1;if(cat==CharCategory.Space)cat=nextCat;if(cat!=nextCat)return false;if(cat==CharCategory.Word){if(next.toLowerCase()==next){if(!forward&&sawUpper)return false;sawLower=true;}else if(sawLower){if(forward)return false;done=true;}else{if(sawUpper&&forward&&categorize(ahead=view.state.sliceDoc(pos,pos+1))==CharCategory.Word&&ahead.toLowerCase()==ahead)return false;sawUpper=true;}}steps++;return true;};let end=view.moveByChar(range,forward,start=>{step(start);return step;});if(segmenter&&cat==CharCategory.Word&&end.from==range.from+steps*(forward?1:-1)){let from=Math.min(range.head,end.head),to=Math.max(range.head,end.head);let skipped=view.state.sliceDoc(from,to);if(skipped.length>1&&/[\u4E00-\uffff]/.test(skipped)){let segments=Array.from(segmenter.segment(skipped));if(segments.length>1){if(forward)return EditorSelection.cursor(range.head+segments[1].index,-1);return EditorSelection.cursor(end.head+segments[segments.length-1].index,1);}}}return end;}function cursorBySubword(view,forward){return moveSel(view,range=>range.empty?moveBySubword(view,range,forward):rangeEnd(range,forward));}const cursorSubwordForward=view=>cursorBySubword(view,true);const cursorSubwordBackward=view=>cursorBySubword(view,false);function interestingNode(state,node,bracketProp){if(node.type.prop(bracketProp))return true;let len=node.to-node.from;return len&&(len>2||/[^\s,.;:]/.test(state.sliceDoc(node.from,node.to)))||node.firstChild;}function moveBySyntax(state,start,forward){let pos=syntaxTree(state).resolveInner(start.head);let bracketProp=forward?NodeProp.closedBy:NodeProp.openedBy;for(let at=start.head;;){let next=forward?pos.childAfter(at):pos.childBefore(at);if(!next)break;if(interestingNode(state,next,bracketProp))pos=next;else at=forward?next.to:next.from;}let bracket=pos.type.prop(bracketProp),match,newPos;if(bracket&&(match=forward?matchBrackets(state,pos.from,1):matchBrackets(state,pos.to,-1))&&match.matched)newPos=forward?match.end.to:match.end.from;else newPos=forward?pos.to:pos.from;return EditorSelection.cursor(newPos,forward?-1:1);}const cursorSyntaxLeft=view=>moveSel(view,range=>moveBySyntax(view.state,range,!ltrAtCursor(view)));const cursorSyntaxRight=view=>moveSel(view,range=>moveBySyntax(view.state,range,ltrAtCursor(view)));function cursorByLine(view,forward){return moveSel(view,range=>{if(!range.empty)return rangeEnd(range,forward);let moved=view.moveVertically(range,forward);return moved.head!=range.head?moved:view.moveToLineBoundary(range,forward);});}const cursorLineUp=view=>cursorByLine(view,false);const cursorLineDown=view=>cursorByLine(view,true);function pageInfo(view){let selfScroll=view.scrollDOM.clientHeight{return range.empty?view.moveVertically(range,forward,page.height):rangeEnd(range,forward);});if(selection.eq(state.selection))return false;let effect;if(page.selfScroll){let startPos=view.coordsAtPos(state.selection.main.head);let scrollRect=view.scrollDOM.getBoundingClientRect();let scrollTop=scrollRect.top+page.marginTop,scrollBottom=scrollRect.bottom-page.marginBottom;if(startPos&&startPos.top>scrollTop&&startPos.bottomcursorByPage(view,false);const cursorPageDown=view=>cursorByPage(view,true);function moveByLineBoundary(view,start,forward){let line=view.lineBlockAt(start.head),moved=view.moveToLineBoundary(start,forward);if(moved.head==start.head&&moved.head!=(forward?line.to:line.from))moved=view.moveToLineBoundary(start,forward,false);if(!forward&&moved.head==line.from&&line.length){let space=/^\s*/.exec(view.state.sliceDoc(line.from,Math.min(line.from+100,line.to)))[0].length;if(space&&start.head!=line.from+space)moved=EditorSelection.cursor(line.from+space);}return moved;}const cursorLineBoundaryForward=view=>moveSel(view,range=>moveByLineBoundary(view,range,true));const cursorLineBoundaryBackward=view=>moveSel(view,range=>moveByLineBoundary(view,range,false));const cursorLineBoundaryLeft=view=>moveSel(view,range=>moveByLineBoundary(view,range,!ltrAtCursor(view)));const cursorLineBoundaryRight=view=>moveSel(view,range=>moveByLineBoundary(view,range,ltrAtCursor(view)));const cursorLineStart=view=>moveSel(view,range=>EditorSelection.cursor(view.lineBlockAt(range.head).from,1));const cursorLineEnd=view=>moveSel(view,range=>EditorSelection.cursor(view.lineBlockAt(range.head).to,-1));function toMatchingBracket(state,dispatch,extend){let found=false,selection=updateSel(state.selection,range=>{let matching=matchBrackets(state,range.head,-1)||matchBrackets(state,range.head,1)||range.head>0&&matchBrackets(state,range.head-1,1)||range.headtoMatchingBracket(state,dispatch,false);const selectMatchingBracket=({state,dispatch})=>toMatchingBracket(state,dispatch,true);function extendSel(view,how){let selection=updateSel(view.state.selection,range=>{let head=how(range);return EditorSelection.range(range.anchor,head.head,head.goalColumn,head.bidiLevel||undefined);});if(selection.eq(view.state.selection))return false;view.dispatch(setSel(view.state,selection));return true;}function selectByChar(view,forward){return extendSel(view,range=>view.moveByChar(range,forward));}const selectCharLeft=view=>selectByChar(view,!ltrAtCursor(view));const selectCharRight=view=>selectByChar(view,ltrAtCursor(view));const selectCharForward=view=>selectByChar(view,true);const selectCharBackward=view=>selectByChar(view,false);function selectByGroup(view,forward){return extendSel(view,range=>view.moveByGroup(range,forward));}const selectGroupLeft=view=>selectByGroup(view,!ltrAtCursor(view));const selectGroupRight=view=>selectByGroup(view,ltrAtCursor(view));const selectGroupForward=view=>selectByGroup(view,true);const selectGroupBackward=view=>selectByGroup(view,false);function selectBySubword(view,forward){return extendSel(view,range=>moveBySubword(view,range,forward));}const selectSubwordForward=view=>selectBySubword(view,true);const selectSubwordBackward=view=>selectBySubword(view,false);const selectSyntaxLeft=view=>extendSel(view,range=>moveBySyntax(view.state,range,!ltrAtCursor(view)));const selectSyntaxRight=view=>extendSel(view,range=>moveBySyntax(view.state,range,ltrAtCursor(view)));function selectByLine(view,forward){return extendSel(view,range=>view.moveVertically(range,forward));}const selectLineUp=view=>selectByLine(view,false);const selectLineDown=view=>selectByLine(view,true);function selectByPage(view,forward){return extendSel(view,range=>view.moveVertically(range,forward,pageInfo(view).height));}const selectPageUp=view=>selectByPage(view,false);const selectPageDown=view=>selectByPage(view,true);const selectLineBoundaryForward=view=>extendSel(view,range=>moveByLineBoundary(view,range,true));const selectLineBoundaryBackward=view=>extendSel(view,range=>moveByLineBoundary(view,range,false));const selectLineBoundaryLeft=view=>extendSel(view,range=>moveByLineBoundary(view,range,!ltrAtCursor(view)));const selectLineBoundaryRight=view=>extendSel(view,range=>moveByLineBoundary(view,range,ltrAtCursor(view)));const selectLineStart=view=>extendSel(view,range=>EditorSelection.cursor(view.lineBlockAt(range.head).from));const selectLineEnd=view=>extendSel(view,range=>EditorSelection.cursor(view.lineBlockAt(range.head).to));const cursorDocStart=({state,dispatch})=>{dispatch(setSel(state,{anchor:0}));return true;};const cursorDocEnd=({state,dispatch})=>{dispatch(setSel(state,{anchor:state.doc.length}));return true;};const selectDocStart=({state,dispatch})=>{dispatch(setSel(state,{anchor:state.selection.main.anchor,head:0}));return true;};const selectDocEnd=({state,dispatch})=>{dispatch(setSel(state,{anchor:state.selection.main.anchor,head:state.doc.length}));return true;};const selectAll=({state,dispatch})=>{dispatch(state.update({selection:{anchor:0,head:state.doc.length},userEvent:"select"}));return true;};const selectLine=({state,dispatch})=>{let ranges=selectedLineBlocks(state).map(({from,to})=>EditorSelection.range(from,Math.min(to+1,state.doc.length)));dispatch(state.update({selection:EditorSelection.create(ranges),userEvent:"select"}));return true;};const selectParentSyntax=({state,dispatch})=>{let selection=updateSel(state.selection,range=>{var _a;let context=syntaxTree(state).resolveInner(range.head,1);while(!(context.from=range.to||context.to>range.to&&context.from<=range.from||!((_a=context.parent)===null||_a===void 0?void 0:_a.parent)))context=context.parent;return EditorSelection.range(context.to,context.from);});dispatch(setSel(state,selection));return true;};const simplifySelection=({state,dispatch})=>{let cur=state.selection,selection=null;if(cur.ranges.length>1)selection=EditorSelection.create([cur.main]);else if(!cur.main.empty)selection=EditorSelection.create([EditorSelection.cursor(cur.main.head)]);if(!selection)return false;dispatch(setSel(state,selection));return true;};function deleteBy(target,by){if(target.state.readOnly)return false;let event="delete.selection",{state}=target;let changes=state.changeByRange(range=>{let{from,to}=range;if(from==to){let towards=by(from);if(towardsfrom){event="delete.forward";towards=skipAtomic(target,towards,true);}from=Math.min(from,towards);to=Math.max(to,towards);}else{from=skipAtomic(target,from,false);to=skipAtomic(target,to,true);}return from==to?{range}:{changes:{from,to},range:EditorSelection.cursor(from)};});if(changes.changes.empty)return false;target.dispatch(state.update(changes,{scrollIntoView:true,userEvent:event,effects:event=="delete.selection"?EditorView.announce.of(state.phrase("Selection deleted")):undefined}));return true;}function skipAtomic(target,pos,forward){if(target instanceof EditorView)for(let _i196=0,_target$state$facet$m=target.state.facet(EditorView.atomicRanges).map(f=>f(target)),_length196=_target$state$facet$m.length;_i196<_length196;_i196++){let ranges=_target$state$facet$m[_i196];ranges.between(pos,pos,(from,to)=>{if(frompos)pos=forward?to:from;});}return pos;}const deleteByChar=(target,forward)=>deleteBy(target,pos=>{let{state}=target,line=state.doc.lineAt(pos),before,targetPos;if(!forward&&pos>line.from&&posdeleteByChar(view,false);const deleteCharForward=view=>deleteByChar(view,true);const deleteByGroup=(target,forward)=>deleteBy(target,start=>{let pos=start,{state}=target,line=state.doc.lineAt(pos);let categorize=state.charCategorizer(pos);for(let cat=null;;){if(pos==(forward?line.to:line.from)){if(pos==start&&line.number!=(forward?state.doc.lines:1))pos+=forward?1:-1;break;}let next=findClusterBreak(line.text,pos-line.from,forward)+line.from;let nextChar=line.text.slice(Math.min(pos,next)-line.from,Math.max(pos,next)-line.from);let nextCat=categorize(nextChar);if(cat!=null&&nextCat!=cat)break;if(nextChar!=" "||pos!=start)cat=nextCat;pos=next;}return pos;});const deleteGroupBackward=target=>deleteByGroup(target,false);const deleteGroupForward=target=>deleteByGroup(target,true);const deleteToLineEnd=view=>deleteBy(view,pos=>{let lineEnd=view.lineBlockAt(pos).to;return posdeleteBy(view,pos=>{let lineStart=view.lineBlockAt(pos).from;return pos>lineStart?lineStart:Math.max(0,pos-1);});const deleteTrailingWhitespace=({state,dispatch})=>{if(state.readOnly)return false;let changes=[];for(let pos=0,prev="",iter=state.doc.iter();;){iter.next();if(iter.lineBreak||iter.done){let trailing=prev.search(/\s+$/);if(trailing>-1)changes.push({from:pos-(prev.length-trailing),to:pos});if(iter.done)break;prev="";}else{prev=iter.value;}pos+=iter.value.length;}if(!changes.length)return false;dispatch(state.update({changes,userEvent:"delete"}));return true;};const splitLine=({state,dispatch})=>{if(state.readOnly)return false;let changes=state.changeByRange(range=>{return{changes:{from:range.from,to:range.to,insert:Text$1.of(["",""])},range:EditorSelection.cursor(range.from)};});dispatch(state.update(changes,{scrollIntoView:true,userEvent:"input"}));return true;};const transposeChars=({state,dispatch})=>{if(state.readOnly)return false;let changes=state.changeByRange(range=>{if(!range.empty||range.from==0||range.from==state.doc.length)return{range};let pos=range.from,line=state.doc.lineAt(pos);let from=pos==line.from?pos-1:findClusterBreak(line.text,pos-line.from,false)+line.from;let to=pos==line.to?pos+1:findClusterBreak(line.text,pos-line.from,true)+line.from;return{changes:{from,to,insert:state.doc.slice(pos,to).append(state.doc.slice(from,pos))},range:EditorSelection.cursor(to)};});if(changes.changes.empty)return false;dispatch(state.update(changes,{scrollIntoView:true,userEvent:"move.character"}));return true;};function selectedLineBlocks(state){let blocks=[],upto=-1;for(let _i197=0,_state$selection$rang7=state.selection.ranges,_length197=_state$selection$rang7.length;_i197<_length197;_i197++){let range=_state$selection$rang7[_i197];let startLine=state.doc.lineAt(range.from),endLine=state.doc.lineAt(range.to);if(!range.empty&&range.to==endLine.from)endLine=state.doc.lineAt(range.to-1);if(upto>=startLine.number){let prev=blocks[blocks.length-1];prev.to=endLine.to;prev.ranges.push(range);}else{blocks.push({from:startLine.from,to:endLine.to,ranges:[range]});}upto=endLine.number+1;}return blocks;}function moveLine(state,dispatch,forward){if(state.readOnly)return false;let changes=[],ranges=[];for(let _i198=0,_selectedLineBlocks=selectedLineBlocks(state),_length198=_selectedLineBlocks.length;_i198<_length198;_i198++){let block=_selectedLineBlocks[_i198];if(forward?block.to==state.doc.length:block.from==0)continue;let nextLine=state.doc.lineAt(forward?block.to+1:block.from-1);let size=nextLine.length+1;if(forward){changes.push({from:block.to,to:nextLine.to},{from:block.from,insert:nextLine.text+state.lineBreak});for(let _i199=0,_block$ranges=block.ranges,_length199=_block$ranges.length;_i199<_length199;_i199++){let r=_block$ranges[_i199];ranges.push(EditorSelection.range(Math.min(state.doc.length,r.anchor+size),Math.min(state.doc.length,r.head+size)));}}else{changes.push({from:nextLine.from,to:block.from},{from:block.to,insert:state.lineBreak+nextLine.text});for(let _i200=0,_block$ranges2=block.ranges,_length200=_block$ranges2.length;_i200<_length200;_i200++){let r=_block$ranges2[_i200];ranges.push(EditorSelection.range(r.anchor-size,r.head-size));}}}if(!changes.length)return false;dispatch(state.update({changes,scrollIntoView:true,selection:EditorSelection.create(ranges,state.selection.mainIndex),userEvent:"move.line"}));return true;}const moveLineUp=({state,dispatch})=>moveLine(state,dispatch,false);const moveLineDown=({state,dispatch})=>moveLine(state,dispatch,true);function copyLine(state,dispatch,forward){if(state.readOnly)return false;let changes=[];for(let _i201=0,_selectedLineBlocks2=selectedLineBlocks(state),_length201=_selectedLineBlocks2.length;_i201<_length201;_i201++){let block=_selectedLineBlocks2[_i201];if(forward)changes.push({from:block.from,insert:state.doc.slice(block.from,block.to)+state.lineBreak});else changes.push({from:block.to,insert:state.lineBreak+state.doc.slice(block.from,block.to)});}dispatch(state.update({changes,scrollIntoView:true,userEvent:"input.copyline"}));return true;}const copyLineUp=({state,dispatch})=>copyLine(state,dispatch,false);const copyLineDown=({state,dispatch})=>copyLine(state,dispatch,true);const deleteLine=view=>{if(view.state.readOnly)return false;let{state}=view,changes=state.changes(selectedLineBlocks(state).map(({from,to})=>{if(from>0)from--;else if(toview.moveVertically(range,true)).map(changes);view.dispatch({changes,selection,scrollIntoView:true,userEvent:"delete.line"});return true;};const insertNewline=({state,dispatch})=>{dispatch(state.update(state.replaceSelection(state.lineBreak),{scrollIntoView:true,userEvent:"input"}));return true;};function isBetweenBrackets(state,pos){if(/\(\)|\[\]|\{\}/.test(state.sliceDoc(pos-1,pos+1)))return{from:pos,to:pos};let context=syntaxTree(state).resolveInner(pos);let before=context.childBefore(pos),after=context.childAfter(pos),closedBy;if(before&&after&&before.to<=pos&&after.from>=pos&&(closedBy=before.type.prop(NodeProp.closedBy))&&closedBy.indexOf(after.name)>-1&&state.doc.lineAt(before.to).from==state.doc.lineAt(after.from).from&&!/\S/.test(state.sliceDoc(before.to,after.from)))return{from:before.to,to:after.from};return null;}const insertNewlineAndIndent=newlineAndIndent(false);const insertBlankLine=newlineAndIndent(true);function newlineAndIndent(atEof){return({state,dispatch})=>{if(state.readOnly)return false;let changes=state.changeByRange(range=>{let{from,to}=range,line=state.doc.lineAt(from);let explode=!atEof&&from==to&&isBetweenBrackets(state,from);if(atEof)from=to=(to<=line.to?line:state.doc.lineAt(to)).to;let cx=new IndentContext(state,{simulateBreak:from,simulateDoubleBreak:!!explode});let indent=getIndentation(cx,from);if(indent==null)indent=countColumn(/^\s*/.exec(state.doc.lineAt(from).text)[0],state.tabSize);while(toline.from&&from{let changes=[];for(let pos=range.from;pos<=range.to;){let line=state.doc.lineAt(pos);if(line.number>atLine&&(range.empty||range.to>line.from)){f(line,changes,range);atLine=line.number;}pos=line.to+1;}let changeSet=state.changes(changes);return{changes,range:EditorSelection.range(changeSet.mapPos(range.anchor,1),changeSet.mapPos(range.head,1))};});}const indentSelection=({state,dispatch})=>{if(state.readOnly)return false;let updated=Object.create(null);let context=new IndentContext(state,{overrideIndentation:start=>{let found=updated[start];return found==null?-1:found;}});let changes=changeBySelectedLine(state,(line,changes,range)=>{let indent=getIndentation(context,line.from);if(indent==null)return;if(!/\S/.test(line.text))indent=0;let cur=/^\s*/.exec(line.text)[0];let norm=indentString(state,indent);if(cur!=norm||range.from{if(state.readOnly)return false;dispatch(state.update(changeBySelectedLine(state,(line,changes)=>{changes.push({from:line.from,insert:state.facet(indentUnit)});}),{userEvent:"input.indent"}));return true;};const indentLess=({state,dispatch})=>{if(state.readOnly)return false;dispatch(state.update(changeBySelectedLine(state,(line,changes)=>{let space=/^\s*/.exec(line.text)[0];if(!space)return;let col=countColumn(space,state.tabSize),keep=0;let insert=indentString(state,Math.max(0,col-getIndentUnit(state)));while(keep{if(state.selection.ranges.some(r=>!r.empty))return indentMore({state,dispatch});dispatch(state.update(state.replaceSelection("\t"),{scrollIntoView:true,userEvent:"input"}));return true;};const emacsStyleKeymap=[{key:"Ctrl-b",run:cursorCharLeft,shift:selectCharLeft,preventDefault:true},{key:"Ctrl-f",run:cursorCharRight,shift:selectCharRight},{key:"Ctrl-p",run:cursorLineUp,shift:selectLineUp},{key:"Ctrl-n",run:cursorLineDown,shift:selectLineDown},{key:"Ctrl-a",run:cursorLineStart,shift:selectLineStart},{key:"Ctrl-e",run:cursorLineEnd,shift:selectLineEnd},{key:"Ctrl-d",run:deleteCharForward},{key:"Ctrl-h",run:deleteCharBackward},{key:"Ctrl-k",run:deleteToLineEnd},{key:"Ctrl-Alt-h",run:deleteGroupBackward},{key:"Ctrl-o",run:splitLine},{key:"Ctrl-t",run:transposeChars},{key:"Ctrl-v",run:cursorPageDown}];const standardKeymap=[{key:"ArrowLeft",run:cursorCharLeft,shift:selectCharLeft,preventDefault:true},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:cursorGroupLeft,shift:selectGroupLeft,preventDefault:true},{mac:"Cmd-ArrowLeft",run:cursorLineBoundaryLeft,shift:selectLineBoundaryLeft,preventDefault:true},{key:"ArrowRight",run:cursorCharRight,shift:selectCharRight,preventDefault:true},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:cursorGroupRight,shift:selectGroupRight,preventDefault:true},{mac:"Cmd-ArrowRight",run:cursorLineBoundaryRight,shift:selectLineBoundaryRight,preventDefault:true},{key:"ArrowUp",run:cursorLineUp,shift:selectLineUp,preventDefault:true},{mac:"Cmd-ArrowUp",run:cursorDocStart,shift:selectDocStart},{mac:"Ctrl-ArrowUp",run:cursorPageUp,shift:selectPageUp},{key:"ArrowDown",run:cursorLineDown,shift:selectLineDown,preventDefault:true},{mac:"Cmd-ArrowDown",run:cursorDocEnd,shift:selectDocEnd},{mac:"Ctrl-ArrowDown",run:cursorPageDown,shift:selectPageDown},{key:"PageUp",run:cursorPageUp,shift:selectPageUp},{key:"PageDown",run:cursorPageDown,shift:selectPageDown},{key:"Home",run:cursorLineBoundaryBackward,shift:selectLineBoundaryBackward,preventDefault:true},{key:"Mod-Home",run:cursorDocStart,shift:selectDocStart},{key:"End",run:cursorLineBoundaryForward,shift:selectLineBoundaryForward,preventDefault:true},{key:"Mod-End",run:cursorDocEnd,shift:selectDocEnd},{key:"Enter",run:insertNewlineAndIndent},{key:"Mod-a",run:selectAll},{key:"Backspace",run:deleteCharBackward,shift:deleteCharBackward},{key:"Delete",run:deleteCharForward},{key:"Mod-Backspace",mac:"Alt-Backspace",run:deleteGroupBackward},{key:"Mod-Delete",mac:"Alt-Delete",run:deleteGroupForward},{mac:"Mod-Backspace",run:deleteToLineStart},{mac:"Mod-Delete",run:deleteToLineEnd}].concat(emacsStyleKeymap.map(b=>({mac:b.key,run:b.run,shift:b.shift})));const defaultKeymap=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:cursorSyntaxLeft,shift:selectSyntaxLeft},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:cursorSyntaxRight,shift:selectSyntaxRight},{key:"Alt-ArrowUp",run:moveLineUp},{key:"Shift-Alt-ArrowUp",run:copyLineUp},{key:"Alt-ArrowDown",run:moveLineDown},{key:"Shift-Alt-ArrowDown",run:copyLineDown},{key:"Escape",run:simplifySelection},{key:"Mod-Enter",run:insertBlankLine},{key:"Alt-l",mac:"Ctrl-l",run:selectLine},{key:"Mod-i",run:selectParentSyntax,preventDefault:true},{key:"Mod-[",run:indentLess},{key:"Mod-]",run:indentMore},{key:"Mod-Alt-\\",run:indentSelection},{key:"Shift-Mod-k",run:deleteLine},{key:"Shift-Mod-\\",run:cursorMatchingBracket},{key:"Mod-/",run:toggleComment},{key:"Alt-A",run:toggleBlockComment}].concat(standardKeymap);const indentWithTab={key:"Tab",run:indentMore,shift:indentLess};var _m3=Object.freeze({__proto__:null,blockComment:blockComment,blockUncomment:blockUncomment,copyLineDown:copyLineDown,copyLineUp:copyLineUp,cursorCharBackward:cursorCharBackward,cursorCharForward:cursorCharForward,cursorCharLeft:cursorCharLeft,cursorCharRight:cursorCharRight,cursorDocEnd:cursorDocEnd,cursorDocStart:cursorDocStart,cursorGroupBackward:cursorGroupBackward,cursorGroupForward:cursorGroupForward,cursorGroupLeft:cursorGroupLeft,cursorGroupRight:cursorGroupRight,cursorLineBoundaryBackward:cursorLineBoundaryBackward,cursorLineBoundaryForward:cursorLineBoundaryForward,cursorLineBoundaryLeft:cursorLineBoundaryLeft,cursorLineBoundaryRight:cursorLineBoundaryRight,cursorLineDown:cursorLineDown,cursorLineEnd:cursorLineEnd,cursorLineStart:cursorLineStart,cursorLineUp:cursorLineUp,cursorMatchingBracket:cursorMatchingBracket,cursorPageDown:cursorPageDown,cursorPageUp:cursorPageUp,cursorSubwordBackward:cursorSubwordBackward,cursorSubwordForward:cursorSubwordForward,cursorSyntaxLeft:cursorSyntaxLeft,cursorSyntaxRight:cursorSyntaxRight,defaultKeymap:defaultKeymap,deleteCharBackward:deleteCharBackward,deleteCharForward:deleteCharForward,deleteGroupBackward:deleteGroupBackward,deleteGroupForward:deleteGroupForward,deleteLine:deleteLine,deleteToLineEnd:deleteToLineEnd,deleteToLineStart:deleteToLineStart,deleteTrailingWhitespace:deleteTrailingWhitespace,emacsStyleKeymap:emacsStyleKeymap,history:history,historyField:historyField,historyKeymap:historyKeymap,indentLess:indentLess,indentMore:indentMore,indentSelection:indentSelection,indentWithTab:indentWithTab,insertBlankLine:insertBlankLine,insertNewline:insertNewline,insertNewlineAndIndent:insertNewlineAndIndent,insertTab:insertTab,invertedEffects:invertedEffects,isolateHistory:isolateHistory,lineComment:lineComment,lineUncomment:lineUncomment,moveLineDown:moveLineDown,moveLineUp:moveLineUp,redo:redo,redoDepth:redoDepth,redoSelection:redoSelection,selectAll:selectAll,selectCharBackward:selectCharBackward,selectCharForward:selectCharForward,selectCharLeft:selectCharLeft,selectCharRight:selectCharRight,selectDocEnd:selectDocEnd,selectDocStart:selectDocStart,selectGroupBackward:selectGroupBackward,selectGroupForward:selectGroupForward,selectGroupLeft:selectGroupLeft,selectGroupRight:selectGroupRight,selectLine:selectLine,selectLineBoundaryBackward:selectLineBoundaryBackward,selectLineBoundaryForward:selectLineBoundaryForward,selectLineBoundaryLeft:selectLineBoundaryLeft,selectLineBoundaryRight:selectLineBoundaryRight,selectLineDown:selectLineDown,selectLineEnd:selectLineEnd,selectLineStart:selectLineStart,selectLineUp:selectLineUp,selectMatchingBracket:selectMatchingBracket,selectPageDown:selectPageDown,selectPageUp:selectPageUp,selectParentSyntax:selectParentSyntax,selectSubwordBackward:selectSubwordBackward,selectSubwordForward:selectSubwordForward,selectSyntaxLeft:selectSyntaxLeft,selectSyntaxRight:selectSyntaxRight,simplifySelection:simplifySelection,splitLine:splitLine,standardKeymap:standardKeymap,toggleBlockComment:toggleBlockComment,toggleBlockCommentByLine:toggleBlockCommentByLine,toggleComment:toggleComment,toggleLineComment:toggleLineComment,transposeChars:transposeChars,undo:undo,undoDepth:undoDepth,undoSelection:undoSelection});function crelt(){var elt=arguments[0];if(typeof elt=="string")elt=document.createElement(elt);var i=1,next=arguments[1];if(next&&typeof next=="object"&&next.nodeType==null&&!Array.isArray(next)){for(var name in next)if(Object.prototype.hasOwnProperty.call(next,name)){var value=next[name];if(typeof value=="string")elt.setAttribute(name,value);else if(value!=null)elt[name]=value;}i++;}for(;ix.normalize("NFKD"):x=>x;class SearchCursor{constructor(text,query,from=0,to=text.length,normalize,test){this.test=test;this.value={from:0,to:0};this.done=false;this.matches=[];this.buffer="";this.bufferPos=0;this.iter=text.iterRange(from,to);this.bufferStart=from;this.normalize=normalize?x=>normalize(basicNormalize(x)):basicNormalize;this.query=this.normalize(query);}peek(){if(this.bufferPos==this.buffer.length){this.bufferStart+=this.buffer.length;this.iter.next();if(this.iter.done)return-1;this.bufferPos=0;this.buffer=this.iter.value;}return codePointAt(this.buffer,this.bufferPos);}next(){while(this.matches.length)this.matches.pop();return this.nextOverlapping();}nextOverlapping(){for(;;){let next=this.peek();if(next<0){this.done=true;return this;}let str=fromCodePoint(next),start=this.bufferStart+this.bufferPos;this.bufferPos+=codePointSize(next);let norm=this.normalize(str);for(let i=0,pos=start;;i++){let code=norm.charCodeAt(i);let match=this.match(code,pos);if(i==norm.length-1){if(match){this.value=match;return this;}break;}if(pos==start&&ithis.to)this.curLine=this.curLine.slice(0,this.to-this.curLineStart);this.iter.next();}}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1;if(this.curLineStart>this.to)this.curLine="";else this.getLine(0);}next(){for(let off=this.matchPos-this.curLineStart;;){this.re.lastIndex=off;let match=this.matchPos<=this.to&&this.re.exec(this.curLine);if(match){let from=this.curLineStart+match.index,to=from+match[0].length;this.matchPos=toCharEnd(this.text,to+(from==to?1:0));if(from==this.curLineStart+this.curLine.length)this.nextLine();if((fromthis.value.to)&&(!this.test||this.test(from,to,match))){this.value={from,to,match};return this;}off=this.matchPos-this.curLineStart;}else if(this.curLineStart+this.curLine.length=to||cached.to<=from){let flat=new FlattenedDoc(from,doc.sliceString(from,to));flattened.set(doc,flat);return flat;}if(cached.from==from&&cached.to==to)return cached;let{text,from:cachedFrom}=cached;if(cachedFrom>from){text=doc.sliceString(from,cachedFrom)+text;cachedFrom=from;}if(cached.to=this.to?this.to:this.text.lineAt(pos).to;}next(){for(;;){let off=this.re.lastIndex=this.matchPos-this.flat.from;let match=this.re.exec(this.flat.text);if(match&&!match[0]&&match.index==off){this.re.lastIndex=off+1;match=this.re.exec(this.flat.text);}if(match){let from=this.flat.from+match.index,to=from+match[0].length;if((this.flat.to>=this.to||match.index+match[0].length<=this.flat.text.length-10)&&(!this.test||this.test(from,to,match))){this.value={from,to,match};this.matchPos=toCharEnd(this.text,to+(from==to?1:0));return this;}}if(this.flat.to==this.to){this.done=true;return this;}this.flat=FlattenedDoc.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2));}}}if(typeof Symbol!="undefined"){RegExpCursor.prototype[Symbol.iterator]=MultilineRegExpCursor.prototype[Symbol.iterator]=function(){return this;};}function validRegExp(source){try{new RegExp(source,baseFlags);return true;}catch(_a){return false;}}function toCharEnd(text,pos){if(pos>=text.length)return pos;let line=text.lineAt(pos),next;while(pos=0xDC00&&next<0xE000)pos++;return pos;}function createLineDialog(view){let input=crelt("input",{class:"cm-textfield",name:"line"});let dom=crelt("form",{class:"cm-gotoLine",onkeydown:event=>{if(event.keyCode==27){event.preventDefault();view.dispatch({effects:dialogEffect.of(false)});view.focus();}else if(event.keyCode==13){event.preventDefault();go();}},onsubmit:event=>{event.preventDefault();go();}},crelt("label",view.state.phrase("Go to line"),": ",input)," ",crelt("button",{class:"cm-button",type:"submit"},view.state.phrase("go")));function go(){let match=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(input.value);if(!match)return;let{state}=view,startLine=state.doc.lineAt(state.selection.main.head);let[,sign,ln,cl,percent]=match;let col=cl?+cl.slice(1):0;let line=ln?+ln:startLine.number;if(ln&&percent){let pc=line/100;if(sign)pc=pc*(sign=="-"?-1:1)+startLine.number/state.doc.lines;line=Math.round(state.doc.lines*pc);}else if(ln&&sign){line=line*(sign=="-"?-1:1)+startLine.number;}let docLine=state.doc.line(Math.max(1,Math.min(state.doc.lines,line)));let selection=EditorSelection.cursor(docLine.from+Math.max(0,Math.min(col,docLine.length)));view.dispatch({effects:[dialogEffect.of(false),EditorView.scrollIntoView(selection.from,{y:'center'})],selection});view.focus();}return{dom};}const dialogEffect=StateEffect.define();const dialogField=StateField.define({create(){return true;},update(value,tr){for(let _i202=0,_tr$effects7=tr.effects,_length202=_tr$effects7.length;_i202<_length202;_i202++){let e=_tr$effects7[_i202];if(e.is(dialogEffect))value=e.value;}return value;},provide:f=>showPanel.from(f,val=>val?createLineDialog:null)});const gotoLine=view=>{let panel=getPanel(view,createLineDialog);if(!panel){let effects=[dialogEffect.of(true)];if(view.state.field(dialogField,false)==null)effects.push(StateEffect.appendConfig.of([dialogField,baseTheme$1$1]));view.dispatch({effects});panel=getPanel(view,createLineDialog);}if(panel)panel.dom.querySelector("input").focus();return true;};const baseTheme$1$1=EditorView.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}});const defaultHighlightOptions={highlightWordAroundCursor:false,minSelectionLength:1,maxMatches:100,wholeWords:false};const highlightConfig=Facet.define({combine(options){return combineConfig(options,defaultHighlightOptions,{highlightWordAroundCursor:(a,b)=>a||b,minSelectionLength:Math.min,maxMatches:Math.min});}});function highlightSelectionMatches(options){let ext=[defaultTheme,matchHighlighter];if(options)ext.push(highlightConfig.of(options));return ext;}const matchDeco=Decoration.mark({class:"cm-selectionMatch"});const mainMatchDeco=Decoration.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function insideWordBoundaries(check,state,from,to){return(from==0||check(state.sliceDoc(from-1,from))!=CharCategory.Word)&&(to==state.doc.length||check(state.sliceDoc(to,to+1))!=CharCategory.Word);}function insideWord(check,state,from,to){return check(state.sliceDoc(from,from+1))==CharCategory.Word&&check(state.sliceDoc(to-1,to))==CharCategory.Word;}const matchHighlighter=ViewPlugin.fromClass(class{constructor(view){this.decorations=this.getDeco(view);}update(update){if(update.selectionSet||update.docChanged||update.viewportChanged)this.decorations=this.getDeco(update.view);}getDeco(view){let conf=view.state.facet(highlightConfig);let{state}=view,sel=state.selection;if(sel.ranges.length>1)return Decoration.none;let range=sel.main,query,check=null;if(range.empty){if(!conf.highlightWordAroundCursor)return Decoration.none;let word=state.wordAt(range.head);if(!word)return Decoration.none;check=state.charCategorizer(range.head);query=state.sliceDoc(word.from,word.to);}else{let len=range.to-range.from;if(len200)return Decoration.none;if(conf.wholeWords){query=state.sliceDoc(range.from,range.to);check=state.charCategorizer(range.head);if(!(insideWordBoundaries(check,state,range.from,range.to)&&insideWord(check,state,range.from,range.to)))return Decoration.none;}else{query=state.sliceDoc(range.from,range.to).trim();if(!query)return Decoration.none;}}let deco=[];for(let _i203=0,_view$visibleRanges4=view.visibleRanges,_length203=_view$visibleRanges4.length;_i203<_length203;_i203++){let part=_view$visibleRanges4[_i203];let cursor=new SearchCursor(state.doc,query,part.from,part.to);while(!cursor.next().done){let{from,to}=cursor.value;if(!check||insideWordBoundaries(check,state,from,to)){if(range.empty&&from<=range.from&&to>=range.to)deco.push(mainMatchDeco.range(from,to));else if(from>=range.to||to<=range.from)deco.push(matchDeco.range(from,to));if(deco.length>conf.maxMatches)return Decoration.none;}}}return Decoration.set(deco);}},{decorations:v=>v.decorations});const defaultTheme=EditorView.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const selectWord=({state,dispatch})=>{let{selection}=state;let newSel=EditorSelection.create(selection.ranges.map(range=>state.wordAt(range.head)||EditorSelection.cursor(range.head)),selection.mainIndex);if(newSel.eq(selection))return false;dispatch(state.update({selection:newSel}));return true;};function findNextOccurrence(state,query){let{main,ranges}=state.selection;let word=state.wordAt(main.head),fullWord=word&&word.from==main.from&&word.to==main.to;for(let cycled=false,cursor=new SearchCursor(state.doc,query,ranges[ranges.length-1].to);;){cursor.next();if(cursor.done){if(cycled)return null;cursor=new SearchCursor(state.doc,query,0,Math.max(0,ranges[ranges.length-1].from-1));cycled=true;}else{if(cycled&&ranges.some(r=>r.from==cursor.value.from))continue;if(fullWord){let word=state.wordAt(cursor.value.from);if(!word||word.from!=cursor.value.from||word.to!=cursor.value.to)continue;}return cursor.value;}}}const selectNextOccurrence=({state,dispatch})=>{let{ranges}=state.selection;if(ranges.some(sel=>sel.from===sel.to))return selectWord({state,dispatch});let searchedText=state.sliceDoc(ranges[0].from,ranges[0].to);if(state.selection.ranges.some(r=>state.sliceDoc(r.from,r.to)!=searchedText))return false;let range=findNextOccurrence(state,searchedText);if(!range)return false;dispatch(state.update({selection:state.selection.addRange(EditorSelection.range(range.from,range.to),false),effects:EditorView.scrollIntoView(range.to)}));return true;};const searchConfigFacet=Facet.define({combine(configs){return combineConfig(configs,{top:false,caseSensitive:false,literal:false,regexp:false,wholeWord:false,createPanel:view=>new SearchPanel(view),scrollToMatch:range=>EditorView.scrollIntoView(range)});}});function search(config){return config?[searchConfigFacet.of(config),searchExtensions]:searchExtensions;}class SearchQuery{constructor(config){this.search=config.search;this.caseSensitive=!!config.caseSensitive;this.literal=!!config.literal;this.regexp=!!config.regexp;this.replace=config.replace||"";this.valid=!!this.search&&(!this.regexp||validRegExp(this.search));this.unquoted=this.unquote(this.search);this.wholeWord=!!config.wholeWord;}unquote(text){return this.literal?text:text.replace(/\\([nrt\\])/g,(_,ch)=>ch=="n"?"\n":ch=="r"?"\r":ch=="t"?"\t":"\\");}eq(other){return this.search==other.search&&this.replace==other.replace&&this.caseSensitive==other.caseSensitive&&this.regexp==other.regexp&&this.wholeWord==other.wholeWord;}create(){return this.regexp?new RegExpQuery(this):new StringQuery(this);}getCursor(state,from=0,to){let st=state.doc?state:EditorState.create({doc:state});if(to==null)to=st.doc.length;return this.regexp?regexpCursor(this,st,from,to):stringCursor(this,st,from,to);}}class QueryType{constructor(spec){this.spec=spec;}}function stringCursor(spec,state,from,to){return new SearchCursor(state.doc,spec.unquoted,from,to,spec.caseSensitive?undefined:x=>x.toLowerCase(),spec.wholeWord?stringWordTest(state.doc,state.charCategorizer(state.selection.main.head)):undefined);}function stringWordTest(doc,categorizer){return(from,to,buf,bufPos)=>{if(bufPos>from||bufPos+buf.length=limit)return null;ranges.push(cursor.value);}return ranges;}highlight(state,from,to,add){let cursor=stringCursor(this.spec,state,Math.max(0,from-this.spec.unquoted.length),Math.min(to+this.spec.unquoted.length,state.doc.length));while(!cursor.next().done)add(cursor.value.from,cursor.value.to);}}function regexpCursor(spec,state,from,to){return new RegExpCursor(state.doc,spec.search,{ignoreCase:!spec.caseSensitive,test:spec.wholeWord?regexpWordTest(state.charCategorizer(state.selection.main.head)):undefined},from,to);}function charBefore(str,index){return str.slice(findClusterBreak(str,index,false),index);}function charAfter(str,index){return str.slice(index,findClusterBreak(str,index));}function regexpWordTest(categorizer){return(_from,_to,match)=>!match[0].length||(categorizer(charBefore(match.input,match.index))!=CharCategory.Word||categorizer(charAfter(match.input,match.index))!=CharCategory.Word)&&(categorizer(charAfter(match.input,match.index+match[0].length))!=CharCategory.Word||categorizer(charBefore(match.input,match.index+match[0].length))!=CharCategory.Word);}class RegExpQuery extends QueryType{nextMatch(state,curFrom,curTo){let cursor=regexpCursor(this.spec,state,curTo,state.doc.length).next();if(cursor.done)cursor=regexpCursor(this.spec,state,0,curFrom).next();return cursor.done?null:cursor.value;}prevMatchInRange(state,from,to){for(let size=1;;size++){let start=Math.max(from,to-size*10000);let cursor=regexpCursor(this.spec,state,start,to),range=null;while(!cursor.next().done)range=cursor.value;if(range&&(start==from||range.from>start+10))return range;if(start==from)return null;}}prevMatch(state,curFrom,curTo){return this.prevMatchInRange(state,0,curFrom)||this.prevMatchInRange(state,curTo,state.doc.length);}getReplacement(result){return this.spec.unquote(this.spec.replace.replace(/\$([$&\d+])/g,(m,i)=>i=="$"?"$":i=="&"?result.match[0]:i!="0"&&+i=limit)return null;ranges.push(cursor.value);}return ranges;}highlight(state,from,to,add){let cursor=regexpCursor(this.spec,state,Math.max(0,from-250),Math.min(to+250,state.doc.length));while(!cursor.next().done)add(cursor.value.from,cursor.value.to);}}const setSearchQuery=StateEffect.define();const togglePanel$1=StateEffect.define();const searchState=StateField.define({create(state){return new SearchState(defaultQuery(state).create(),null);},update(value,tr){for(let _i204=0,_tr$effects8=tr.effects,_length204=_tr$effects8.length;_i204<_length204;_i204++){let effect=_tr$effects8[_i204];if(effect.is(setSearchQuery))value=new SearchState(effect.value.create(),value.panel);else if(effect.is(togglePanel$1))value=new SearchState(value.query,effect.value?createSearchPanel:null);}return value;},provide:f=>showPanel.from(f,val=>val.panel)});function getSearchQuery(state){let curState=state.field(searchState,false);return curState?curState.query.spec:defaultQuery(state);}function searchPanelOpen(state){var _a;return((_a=state.field(searchState,false))===null||_a===void 0?void 0:_a.panel)!=null;}class SearchState{constructor(query,panel){this.query=query;this.panel=panel;}}const matchMark=Decoration.mark({class:"cm-searchMatch"}),selectedMatchMark=Decoration.mark({class:"cm-searchMatch cm-searchMatch-selected"});const searchHighlighter=ViewPlugin.fromClass(class{constructor(view){this.view=view;this.decorations=this.highlight(view.state.field(searchState));}update(update){let state=update.state.field(searchState);if(state!=update.startState.field(searchState)||update.docChanged||update.selectionSet||update.viewportChanged)this.decorations=this.highlight(state);}highlight({query,panel}){if(!panel||!query.spec.valid)return Decoration.none;let{view}=this;let builder=new RangeSetBuilder();for(let i=0,ranges=view.visibleRanges,l=ranges.length;iranges[i+1].from-2*250)to=ranges[++i].to;query.highlight(view.state,from,to,(from,to)=>{let selected=view.state.selection.ranges.some(r=>r.from==from&&r.to==to);builder.add(from,to,selected?selectedMatchMark:matchMark);});}return builder.finish();}},{decorations:v=>v.decorations});function searchCommand(f){return view=>{let state=view.state.field(searchState,false);return state&&state.query.spec.valid?f(view,state):openSearchPanel(view);};}const findNext=searchCommand((view,{query})=>{let{to}=view.state.selection.main;let next=query.nextMatch(view.state,to,to);if(!next)return false;let selection=EditorSelection.single(next.from,next.to);let config=view.state.facet(searchConfigFacet);view.dispatch({selection,effects:[announceMatch(view,next),config.scrollToMatch(selection.main,view)],userEvent:"select.search"});selectSearchInput(view);return true;});const findPrevious=searchCommand((view,{query})=>{let{state}=view,{from}=state.selection.main;let prev=query.prevMatch(state,from,from);if(!prev)return false;let selection=EditorSelection.single(prev.from,prev.to);let config=view.state.facet(searchConfigFacet);view.dispatch({selection,effects:[announceMatch(view,prev),config.scrollToMatch(selection.main,view)],userEvent:"select.search"});selectSearchInput(view);return true;});const selectMatches=searchCommand((view,{query})=>{let ranges=query.matchAll(view.state,1000);if(!ranges||!ranges.length)return false;view.dispatch({selection:EditorSelection.create(ranges.map(r=>EditorSelection.range(r.from,r.to))),userEvent:"select.search.matches"});return true;});const selectSelectionMatches=({state,dispatch})=>{let sel=state.selection;if(sel.ranges.length>1||sel.main.empty)return false;let{from,to}=sel.main;let ranges=[],main=0;for(let cur=new SearchCursor(state.doc,state.sliceDoc(from,to));!cur.next().done;){if(ranges.length>1000)return false;if(cur.value.from==from)main=ranges.length;ranges.push(EditorSelection.range(cur.value.from,cur.value.to));}dispatch(state.update({selection:EditorSelection.create(ranges,main),userEvent:"select.search.matches"}));return true;};const replaceNext=searchCommand((view,{query})=>{let{state}=view,{from,to}=state.selection.main;if(state.readOnly)return false;let next=query.nextMatch(state,from,from);if(!next)return false;let changes=[],selection,replacement;let effects=[];if(next.from==from&&next.to==to){replacement=state.toText(query.getReplacement(next));changes.push({from:next.from,to:next.to,insert:replacement});next=query.nextMatch(state,next.from,next.to);effects.push(EditorView.announce.of(state.phrase("replaced match on line $",state.doc.lineAt(from).number)+"."));}if(next){let off=changes.length==0||changes[0].from>=next.to?0:next.to-next.from-replacement.length;selection=EditorSelection.single(next.from-off,next.to-off);effects.push(announceMatch(view,next));effects.push(state.facet(searchConfigFacet).scrollToMatch(selection.main,view));}view.dispatch({changes,selection,effects,userEvent:"input.replace"});return true;});const replaceAll=searchCommand((view,{query})=>{if(view.state.readOnly)return false;let changes=query.matchAll(view.state,1e9).map(match=>{let{from,to}=match;return{from,to,insert:query.getReplacement(match)};});if(!changes.length)return false;let announceText=view.state.phrase("replaced $ matches",changes.length)+".";view.dispatch({changes,effects:EditorView.announce.of(announceText),userEvent:"input.replace.all"});return true;});function createSearchPanel(view){return view.state.facet(searchConfigFacet).createPanel(view);}function defaultQuery(state,fallback){var _a,_b,_c,_d,_e;let sel=state.selection.main;let selText=sel.empty||sel.to>sel.from+100?"":state.sliceDoc(sel.from,sel.to);if(fallback&&!selText)return fallback;let config=state.facet(searchConfigFacet);return new SearchQuery({search:((_a=fallback===null||fallback===void 0?void 0:fallback.literal)!==null&&_a!==void 0?_a:config.literal)?selText:selText.replace(/\n/g,"\\n"),caseSensitive:(_b=fallback===null||fallback===void 0?void 0:fallback.caseSensitive)!==null&&_b!==void 0?_b:config.caseSensitive,literal:(_c=fallback===null||fallback===void 0?void 0:fallback.literal)!==null&&_c!==void 0?_c:config.literal,regexp:(_d=fallback===null||fallback===void 0?void 0:fallback.regexp)!==null&&_d!==void 0?_d:config.regexp,wholeWord:(_e=fallback===null||fallback===void 0?void 0:fallback.wholeWord)!==null&&_e!==void 0?_e:config.wholeWord});}function getSearchInput(view){let panel=getPanel(view,createSearchPanel);return panel&&panel.dom.querySelector("[main-field]");}function selectSearchInput(view){let input=getSearchInput(view);if(input&&input==view.root.activeElement)input.select();}const openSearchPanel=view=>{let state=view.state.field(searchState,false);if(state&&state.panel){let searchInput=getSearchInput(view);if(searchInput&&searchInput!=view.root.activeElement){let query=defaultQuery(view.state,state.query.spec);if(query.valid)view.dispatch({effects:setSearchQuery.of(query)});searchInput.focus();searchInput.select();}}else{view.dispatch({effects:[togglePanel$1.of(true),state?setSearchQuery.of(defaultQuery(view.state,state.query.spec)):StateEffect.appendConfig.of(searchExtensions)]});}return true;};const closeSearchPanel=view=>{let state=view.state.field(searchState,false);if(!state||!state.panel)return false;let panel=getPanel(view,createSearchPanel);if(panel&&panel.dom.contains(view.root.activeElement))view.focus();view.dispatch({effects:togglePanel$1.of(false)});return true;};const searchKeymap=[{key:"Mod-f",run:openSearchPanel,scope:"editor search-panel"},{key:"F3",run:findNext,shift:findPrevious,scope:"editor search-panel",preventDefault:true},{key:"Mod-g",run:findNext,shift:findPrevious,scope:"editor search-panel",preventDefault:true},{key:"Escape",run:closeSearchPanel,scope:"editor search-panel"},{key:"Mod-Shift-l",run:selectSelectionMatches},{key:"Alt-g",run:gotoLine},{key:"Mod-d",run:selectNextOccurrence,preventDefault:true}];class SearchPanel{constructor(view){this.view=view;let query=this.query=view.state.field(searchState).query.spec;this.commit=this.commit.bind(this);this.searchField=crelt("input",{value:query.search,placeholder:phrase(view,"Find"),"aria-label":phrase(view,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit});this.replaceField=crelt("input",{value:query.replace,placeholder:phrase(view,"Replace"),"aria-label":phrase(view,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit});this.caseField=crelt("input",{type:"checkbox",name:"case",form:"",checked:query.caseSensitive,onchange:this.commit});this.reField=crelt("input",{type:"checkbox",name:"re",form:"",checked:query.regexp,onchange:this.commit});this.wordField=crelt("input",{type:"checkbox",name:"word",form:"",checked:query.wholeWord,onchange:this.commit});function button(name,onclick,content){return crelt("button",{class:"cm-button",name,onclick,type:"button"},content);}this.dom=crelt("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,button("next",()=>findNext(view),[phrase(view,"next")]),button("prev",()=>findPrevious(view),[phrase(view,"previous")]),button("select",()=>selectMatches(view),[phrase(view,"all")]),crelt("label",null,[this.caseField,phrase(view,"match case")]),crelt("label",null,[this.reField,phrase(view,"regexp")]),crelt("label",null,[this.wordField,phrase(view,"by word")]),...(view.state.readOnly?[]:[crelt("br"),this.replaceField,button("replace",()=>replaceNext(view),[phrase(view,"replace")]),button("replaceAll",()=>replaceAll(view),[phrase(view,"replace all")])]),crelt("button",{name:"close",onclick:()=>closeSearchPanel(view),"aria-label":phrase(view,"close"),type:"button"},["×"])]);}commit(){let query=new SearchQuery({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});if(!query.eq(this.query)){this.query=query;this.view.dispatch({effects:setSearchQuery.of(query)});}}keydown(e){if(runScopeHandlers(this.view,e,"search-panel")){e.preventDefault();}else if(e.keyCode==13&&e.target==this.searchField){e.preventDefault();(e.shiftKey?findPrevious:findNext)(this.view);}else if(e.keyCode==13&&e.target==this.replaceField){e.preventDefault();replaceNext(this.view);}}update(update){for(let _i205=0,_update$transactions=update.transactions,_length205=_update$transactions.length;_i205<_length205;_i205++){let tr=_update$transactions[_i205];for(let _i206=0,_tr$effects9=tr.effects,_length206=_tr$effects9.length;_i206<_length206;_i206++){let effect=_tr$effects9[_i206];if(effect.is(setSearchQuery)&&!effect.value.eq(this.query))this.setQuery(effect.value);}}}setQuery(query){this.query=query;this.searchField.value=query.search;this.replaceField.value=query.replace;this.caseField.checked=query.caseSensitive;this.reField.checked=query.regexp;this.wordField.checked=query.wholeWord;}mount(){this.searchField.select();}get pos(){return 80;}get top(){return this.view.state.facet(searchConfigFacet).top;}}function phrase(view,phrase){return view.state.phrase(phrase);}const AnnounceMargin=30;const Break=/[\s\.,:;?!]/;function announceMatch(view,{from,to}){let line=view.state.doc.lineAt(from),lineEnd=view.state.doc.lineAt(to).to;let start=Math.max(line.from,from-AnnounceMargin),end=Math.min(lineEnd,to+AnnounceMargin);let text=view.state.sliceDoc(start,end);if(start!=line.from){for(let i=0;itext.length-AnnounceMargin;i--)if(!Break.test(text[i-1])&&Break.test(text[i])){text=text.slice(0,i);break;}}return EditorView.announce.of(`${view.state.phrase("current match")}. ${text} ${view.state.phrase("on line")} ${line.number}.`);}const baseTheme$3=EditorView.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}});const searchExtensions=[searchState,Prec.low(searchHighlighter),baseTheme$3];var _m4=Object.freeze({__proto__:null,RegExpCursor:RegExpCursor,SearchCursor:SearchCursor,SearchQuery:SearchQuery,closeSearchPanel:closeSearchPanel,findNext:findNext,findPrevious:findPrevious,getSearchQuery:getSearchQuery,gotoLine:gotoLine,highlightSelectionMatches:highlightSelectionMatches,openSearchPanel:openSearchPanel,replaceAll:replaceAll,replaceNext:replaceNext,search:search,searchKeymap:searchKeymap,searchPanelOpen:searchPanelOpen,selectMatches:selectMatches,selectNextOccurrence:selectNextOccurrence,selectSelectionMatches:selectSelectionMatches,setSearchQuery:setSearchQuery});class CompletionContext{constructor(state,pos,explicit){this.state=state;this.pos=pos;this.explicit=explicit;this.abortListeners=[];}tokenBefore(types){let token=syntaxTree(this.state).resolveInner(this.pos,-1);while(token&&types.indexOf(token.name)<0)token=token.parent;return token?{from:token.from,to:this.pos,text:this.state.sliceDoc(token.from,this.pos),type:token.type}:null;}matchBefore(expr){let line=this.state.doc.lineAt(this.pos);let start=Math.max(line.from,this.pos-250);let str=line.text.slice(start-line.from,this.pos-line.from);let found=str.search(ensureAnchor(expr,false));return found<0?null:{from:start+found,to:this.pos,text:str.slice(found)};}get aborted(){return this.abortListeners==null;}addEventListener(type,listener){if(type=="abort"&&this.abortListeners)this.abortListeners.push(listener);}}function toSet(chars){let flat=Object.keys(chars).join("");let words=/\w/.test(flat);if(words)flat=flat.replace(/\w/g,"");return`[${words?"\\w":""}${flat.replace(/[^\w\s]/g,"\\$&")}]`;}function prefixMatch(options){let first=Object.create(null),rest=Object.create(null);for(let _i207=0,_length207=options.length;_i207<_length207;_i207++){let{label}=options[_i207];first[label[0]]=true;for(let i=1;itypeof o=="string"?{label:o}:o);let[validFor,match]=options.every(o=>/^\w+$/.test(o.label))?[/\w*$/,/\w+$/]:prefixMatch(options);return context=>{let token=context.matchBefore(match);return token||context.explicit?{from:token?token.from:context.pos,options,validFor}:null;};}function ifIn(nodes,source){return context=>{for(let pos=syntaxTree(context.state).resolveInner(context.pos,-1);pos;pos=pos.parent){if(nodes.indexOf(pos.name)>-1)return source(context);if(pos.type.isTop)break;}return null;};}function ifNotIn(nodes,source){return context=>{for(let pos=syntaxTree(context.state).resolveInner(context.pos,-1);pos;pos=pos.parent){if(nodes.indexOf(pos.name)>-1)return null;if(pos.type.isTop)break;}return source(context);};}class Option{constructor(completion,source,match,score){this.completion=completion;this.source=source;this.match=match;this.score=score;}}function cur(state){return state.selection.main.from;}function ensureAnchor(expr,start){var _a;let{source}=expr;let addStart=start&&source[0]!="^",addEnd=source[source.length-1]!="$";if(!addStart&&!addEnd)return expr;return new RegExp(`${addStart?"^":""}(?:${source})${addEnd?"$":""}`,(_a=expr.flags)!==null&&_a!==void 0?_a:expr.ignoreCase?"i":"");}const pickedCompletion=Annotation.define();function insertCompletionText(state,text,from,to){let{main}=state.selection,fromOff=from-main.from,toOff=to-main.from;return Object.assign(Object.assign({},state.changeByRange(range=>{if(range!=main&&from!=to&&state.sliceDoc(range.from+fromOff,range.from+toOff)!=state.sliceDoc(from,to))return{range};return{changes:{from:range.from+fromOff,to:to==main.from?range.to:range.from+toOff,insert:text},range:EditorSelection.cursor(range.from+fromOff+text.length)};})),{userEvent:"input.complete"});}const SourceCache=new WeakMap();function asSource(source){if(!Array.isArray(source))return source;let known=SourceCache.get(source);if(!known)SourceCache.set(source,known=completeFromList(source));return known;}const startCompletionEffect=StateEffect.define();const closeCompletionEffect=StateEffect.define();class FuzzyMatcher{constructor(pattern){this.pattern=pattern;this.chars=[];this.folded=[];this.any=[];this.precise=[];this.byWord=[];this.score=0;this.matched=[];for(let p=0;p=48&&next<=57||next>=97&&next<=122?2:next>=65&&next<=90?1:0:(ch=fromCodePoint(next))!=ch.toLowerCase()?1:ch!=ch.toUpperCase()?2:0;if(!i||type==1&&hasLower||prevType==0&&type!=0){if(chars[byWordTo]==next||folded[byWordTo]==next&&(byWordFolded=true))byWord[byWordTo++]=i;else if(byWord.length)wordAdjacent=false;}prevType=type;i+=codePointSize(next);}if(byWordTo==len&&byWord[0]==0&&wordAdjacent)return this.result(-100+(byWordFolded?-200:0),byWord,word);if(adjacentTo==len&&adjacentStart==0)return this.ret(-200-word.length+(adjacentEnd==word.length?0:-100),[0,adjacentEnd]);if(direct>-1)return this.ret(-700-word.length,[direct,direct+this.pattern.length]);if(adjacentTo==len)return this.ret(-200+-700-word.length,[adjacentStart,adjacentEnd]);if(byWordTo==len)return this.result(-100+(byWordFolded?-200:0)+-700+(wordAdjacent?0:-1100),byWord,word);return chars.length==2?false:this.result((any[0]?-700:0)+-200+-1100,any,word);}result(score,positions,word){let result=[],i=0;for(let _i208=0,_length208=positions.length;_i208<_length208;_i208++){let pos=positions[_i208];let to=pos+(this.astral?codePointSize(codePointAt(word,pos)):1);if(i&&result[i-1]==pos)result[i-1]=to;else{result[i++]=pos;result[i++]=to;}}return this.ret(score-word.length,result);}}const completionConfig=Facet.define({combine(configs){return combineConfig(configs,{activateOnTyping:true,selectOnOpen:true,override:null,closeOnBlur:true,maxRenderedOptions:100,defaultKeymap:true,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:false,icons:true,addToOptions:[],positionInfo:defaultPositionInfo,compareCompletions:(a,b)=>a.label.localeCompare(b.label),interactionDelay:75},{defaultKeymap:(a,b)=>a&&b,closeOnBlur:(a,b)=>a&&b,icons:(a,b)=>a&&b,tooltipClass:(a,b)=>c=>joinClass(a(c),b(c)),optionClass:(a,b)=>c=>joinClass(a(c),b(c)),addToOptions:(a,b)=>a.concat(b)});}});function joinClass(a,b){return a?b?a+" "+b:a:b;}function defaultPositionInfo(view,list,option,info,space){let rtl=view.textDirection==Direction.RTL,left=rtl,narrow=false;let side="top",offset,maxWidth;let spaceLeft=list.left-space.left,spaceRight=space.right-list.right;let infoWidth=info.right-info.left,infoHeight=info.bottom-info.top;if(left&&spaceLeft=infoHeight||spaceBelow>list.top){offset=option.bottom-list.top;}else{side="bottom";offset=list.bottom-option.top;}}return{style:`${side}: ${offset}px; max-width: ${maxWidth}px`,class:"cm-completionInfo-"+(narrow?rtl?"left-narrow":"right-narrow":left?"left":"right")};}function optionContent(config){let content=config.addToOptions.slice();if(config.icons)content.push({render(completion){let icon=document.createElement("div");icon.classList.add("cm-completionIcon");if(completion.type)icon.classList.add(...completion.type.split(/\s+/g).map(cls=>"cm-completionIcon-"+cls));icon.setAttribute("aria-hidden","true");return icon;},position:20});content.push({render(completion,_s,match){let labelElt=document.createElement("span");labelElt.className="cm-completionLabel";let label=completion.displayLabel||completion.label,off=0;for(let j=0;joff)labelElt.appendChild(document.createTextNode(label.slice(off,from)));let span=labelElt.appendChild(document.createElement("span"));span.appendChild(document.createTextNode(label.slice(from,to)));span.className="cm-completionMatchedText";off=to;}if(offa.position-b.position).map(a=>a.render);}function rangeAroundSelected(total,selected,max){if(total<=max)return{from:0,to:total};if(selected<0)selected=0;if(selected<=total>>1){let off=Math.floor(selected/max);return{from:off*max,to:(off+1)*max};}let off=Math.floor((total-selected)/max);return{from:total-(off+1)*max,to:total-off*max};}class CompletionTooltip{constructor(view,stateField,applyCompletion){this.view=view;this.stateField=stateField;this.applyCompletion=applyCompletion;this.info=null;this.infoDestroy=null;this.placeInfoReq={read:()=>this.measureInfo(),write:pos=>this.placeInfo(pos),key:this};this.space=null;this.currentClass="";let cState=view.state.field(stateField);let{options,selected}=cState.open;let config=view.state.facet(completionConfig);this.optionContent=optionContent(config);this.optionClass=config.optionClass;this.tooltipClass=config.tooltipClass;this.range=rangeAroundSelected(options.length,selected,config.maxRenderedOptions);this.dom=document.createElement("div");this.dom.className="cm-tooltip-autocomplete";this.updateTooltipClass(view.state);this.dom.addEventListener("mousedown",e=>{for(let dom=e.target,match;dom&&dom!=this.dom;dom=dom.parentNode){if(dom.nodeName=="LI"&&(match=/-(\d+)$/.exec(dom.id))&&+match[1]{let state=view.state.field(this.stateField,false);if(state&&state.tooltip&&view.state.facet(completionConfig).closeOnBlur&&e.relatedTarget!=view.contentDOM)view.dispatch({effects:closeCompletionEffect.of(null)});});this.list=this.dom.appendChild(this.createListBox(options,cState.id,this.range));this.list.addEventListener("scroll",()=>{if(this.info)this.view.requestMeasure(this.placeInfoReq);});}mount(){this.updateSel();}update(update){var _a,_b,_c;let cState=update.state.field(this.stateField);let prevState=update.startState.field(this.stateField);this.updateTooltipClass(update.state);if(cState!=prevState){this.updateSel();if(((_a=cState.open)===null||_a===void 0?void 0:_a.disabled)!=((_b=prevState.open)===null||_b===void 0?void 0:_b.disabled))this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!((_c=cState.open)===null||_c===void 0?void 0:_c.disabled));}}updateTooltipClass(state){let cls=this.tooltipClass(state);if(cls!=this.currentClass){for(let _i209=0,_this$currentClass$sp=this.currentClass.split(" "),_length209=_this$currentClass$sp.length;_i209<_length209;_i209++){let c=_this$currentClass$sp[_i209];if(c)this.dom.classList.remove(c);}for(let _i210=0,_cls$split=cls.split(" "),_length210=_cls$split.length;_i210<_length210;_i210++){let c=_cls$split[_i210];if(c)this.dom.classList.add(c);}this.currentClass=cls;}}positioned(space){this.space=space;if(this.info)this.view.requestMeasure(this.placeInfoReq);}updateSel(){let cState=this.view.state.field(this.stateField),open=cState.open;if(open.selected>-1&&open.selected=this.range.to){this.range=rangeAroundSelected(open.options.length,open.selected,this.view.state.facet(completionConfig).maxRenderedOptions);this.list.remove();this.list=this.dom.appendChild(this.createListBox(open.options,cState.id,this.range));this.list.addEventListener("scroll",()=>{if(this.info)this.view.requestMeasure(this.placeInfoReq);});}if(this.updateSelectedOption(open.selected)){this.destroyInfo();let{completion}=open.options[open.selected];let{info}=completion;if(!info)return;let infoResult=typeof info==="string"?document.createTextNode(info):info(completion);if(!infoResult)return;if("then"in infoResult){infoResult.then(obj=>{if(obj&&this.view.state.field(this.stateField,false)==cState)this.addInfoPane(obj,completion);}).catch(e=>logException(this.view.state,e,"completion info"));}else{this.addInfoPane(infoResult,completion);}}}addInfoPane(content,completion){this.destroyInfo();let wrap=this.info=document.createElement("div");wrap.className="cm-tooltip cm-completionInfo";if(content.nodeType!=null){wrap.appendChild(content);this.infoDestroy=null;}else{let{dom,destroy}=content;wrap.appendChild(dom);this.infoDestroy=destroy||null;}this.dom.appendChild(wrap);this.view.requestMeasure(this.placeInfoReq);}updateSelectedOption(selected){let set=null;for(let opt=this.list.firstChild,i=this.range.from;opt;opt=opt.nextSibling,i++){if(opt.nodeName!="LI"||!opt.id){i--;}else if(i==selected){if(!opt.hasAttribute("aria-selected")){opt.setAttribute("aria-selected","true");set=opt;}}else{if(opt.hasAttribute("aria-selected"))opt.removeAttribute("aria-selected");}}if(set)scrollIntoView(this.list,set);return set;}measureInfo(){let sel=this.dom.querySelector("[aria-selected]");if(!sel||!this.info)return null;let listRect=this.dom.getBoundingClientRect();let infoRect=this.info.getBoundingClientRect();let selRect=sel.getBoundingClientRect();let space=this.space;if(!space){let win=this.dom.ownerDocument.defaultView||window;space={left:0,top:0,right:win.innerWidth,bottom:win.innerHeight};}if(selRect.top>Math.min(space.bottom,listRect.bottom)-10||selRect.bottomrange.from||range.from==0)){curSection=name;if(typeof section!="string"&§ion.header){ul.appendChild(section.header(section));}else{let header=ul.appendChild(document.createElement("completion-section"));header.textContent=name;}}}const li=ul.appendChild(document.createElement("li"));li.id=id+"-"+i;li.setAttribute("role","option");let cls=this.optionClass(completion);if(cls)li.className=cls;for(let _i211=0,_this$optionContent=this.optionContent,_length211=_this$optionContent.length;_i211<_length211;_i211++){let source=_this$optionContent[_i211];let node=source(completion,this.view.state,match);if(node)li.appendChild(node);}}if(range.from)ul.classList.add("cm-completionListIncompleteTop");if(range.tonew CompletionTooltip(view,stateField,applyCompletion);}function scrollIntoView(container,element){let parent=container.getBoundingClientRect();let self=element.getBoundingClientRect();if(self.topparent.bottom)container.scrollTop+=self.bottom-parent.bottom;}function score(option){return(option.boost||0)*100+(option.apply?10:0)+(option.info?5:0)+(option.type?1:0);}function sortOptions(active,state){let options=[];let sections=null;let addOption=option=>{options.push(option);let{section}=option.completion;if(section){if(!sections)sections=[];let name=typeof section=="string"?section:section.name;if(!sections.some(s=>s.name==name))sections.push(typeof section=="string"?{name}:section);}};for(let _i212=0,_length212=active.length;_i212<_length212;_i212++){let a=active[_i212];if(a.hasResult()){let getMatch=a.result.getMatch;if(a.result.filter===false){for(let _i213=0,_a$result$options=a.result.options,_length213=_a$result$options.length;_i213<_length213;_i213++){let option=_a$result$options[_i213];addOption(new Option(option,a.source,getMatch?getMatch(option):[],1e9-options.length));}}else{let matcher=new FuzzyMatcher(state.sliceDoc(a.from,a.to));for(let _i214=0,_a$result$options2=a.result.options,_length214=_a$result$options2.length;_i214<_length214;_i214++){let option=_a$result$options2[_i214];if(matcher.match(option.label)){let matched=!option.displayLabel?matcher.matched:getMatch?getMatch(option,matcher.matched):[];addOption(new Option(option,a.source,matched,matcher.score+(option.boost||0)));}}}}}if(sections){let sectionOrder=Object.create(null),pos=0;let cmp=(a,b)=>{var _a,_b;return((_a=a.rank)!==null&&_a!==void 0?_a:1e9)-((_b=b.rank)!==null&&_b!==void 0?_b:1e9)||(a.nameb.score-a.score||compare(a.completion,b.completion)),_length217=_options$sort.length;_i217<_length217;_i217++){let opt=_options$sort[_i217];let cur=opt.completion;if(!prev||prev.label!=cur.label||prev.detail!=cur.detail||prev.type!=null&&cur.type!=null&&prev.type!=cur.type||prev.apply!=cur.apply||prev.boost!=cur.boost)result.push(opt);else if(score(opt.completion)>score(prev))result[result.length-1]=opt;prev=opt.completion;}return result;}class CompletionDialog{constructor(options,attrs,tooltip,timestamp,selected,disabled){this.options=options;this.attrs=attrs;this.tooltip=tooltip;this.timestamp=timestamp;this.selected=selected;this.disabled=disabled;}setSelected(selected,id){return selected==this.selected||selected>=this.options.length?this:new CompletionDialog(this.options,makeAttrs(id,selected),this.tooltip,this.timestamp,selected,this.disabled);}static build(active,state,id,prev,conf){let options=sortOptions(active,state);if(!options.length){return prev&&active.some(a=>a.state==1)?new CompletionDialog(prev.options,prev.attrs,prev.tooltip,prev.timestamp,prev.selected,true):null;}let selected=state.facet(completionConfig).selectOnOpen?0:-1;if(prev&&prev.selected!=selected&&prev.selected!=-1){let selectedValue=prev.options[prev.selected].completion;for(let i=0;ib.hasResult()?Math.min(a,b.from):a,1e8),create:completionTooltip(completionState,applyCompletion),above:conf.aboveCursor},prev?prev.timestamp:Date.now(),selected,false);}map(changes){return new CompletionDialog(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:changes.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled);}}class CompletionState{constructor(active,id,open){this.active=active;this.id=id;this.open=open;}static start(){return new CompletionState(none$1,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null);}update(tr){let{state}=tr,conf=state.facet(completionConfig);let sources=conf.override||state.languageDataAt("autocomplete",cur(state)).map(asSource);let active=sources.map(source=>{let value=this.active.find(s=>s.source==source)||new ActiveSource(source,this.active.some(a=>a.state!=0)?1:0);return value.update(tr,conf);});if(active.length==this.active.length&&active.every((a,i)=>a==this.active[i]))active=this.active;let open=this.open;if(open&&tr.docChanged)open=open.map(tr.changes);if(tr.selection||active.some(a=>a.hasResult()&&tr.changes.touchesRange(a.from,a.to))||!sameResults(active,this.active))open=CompletionDialog.build(active,state,this.id,open,conf);else if(open&&open.disabled&&!active.some(a=>a.state==1))open=null;if(!open&&active.every(a=>a.state!=1)&&active.some(a=>a.hasResult()))active=active.map(a=>a.hasResult()?new ActiveSource(a.source,0):a);for(let _i218=0,_tr$effects10=tr.effects,_length218=_tr$effects10.length;_i218<_length218;_i218++){let effect=_tr$effects10[_i218];if(effect.is(setSelectedEffect))open=open&&open.setSelected(effect.value,this.id);}return active==this.active&&open==this.open?this:new CompletionState(active,this.id,open);}get tooltip(){return this.open?this.open.tooltip:null;}get attrs(){return this.open?this.open.attrs:baseAttrs;}}function sameResults(a,b){if(a==b)return true;for(let iA=0,iB=0;;){while(iA-1)result["aria-activedescendant"]=id+"-"+selected;return result;}const none$1=[];function getUserEvent(tr){return tr.isUserEvent("input.type")?"input":tr.isUserEvent("delete.backward")?"delete":null;}class ActiveSource{constructor(source,state,explicitPos=-1){this.source=source;this.state=state;this.explicitPos=explicitPos;}hasResult(){return false;}update(tr,conf){let event=getUserEvent(tr),value=this;if(event)value=value.handleUserEvent(tr,event,conf);else if(tr.docChanged)value=value.handleChange(tr);else if(tr.selection&&value.state!=0)value=new ActiveSource(value.source,0);for(let _i219=0,_tr$effects11=tr.effects,_length219=_tr$effects11.length;_i219<_length219;_i219++){let effect=_tr$effects11[_i219];if(effect.is(startCompletionEffect))value=new ActiveSource(value.source,1,effect.value?cur(tr.state):-1);else if(effect.is(closeCompletionEffect))value=new ActiveSource(value.source,0);else if(effect.is(setActiveEffect))for(let _i220=0,_effect$value=effect.value,_length220=_effect$value.length;_i220<_length220;_i220++){let active=_effect$value[_i220];if(active.source==value.source)value=active;}}return value;}handleUserEvent(tr,type,conf){return type=="delete"||!conf.activateOnTyping?this.map(tr.changes):new ActiveSource(this.source,1);}handleChange(tr){return tr.changes.touchesRange(cur(tr.startState))?new ActiveSource(this.source,0):this.map(tr.changes);}map(changes){return changes.empty||this.explicitPos<0?this:new ActiveSource(this.source,this.state,changes.mapPos(this.explicitPos));}}class ActiveResult extends ActiveSource{constructor(source,explicitPos,result,from,to){super(source,2,explicitPos);this.result=result;this.from=from;this.to=to;}hasResult(){return true;}handleUserEvent(tr,type,conf){var _a;let from=tr.changes.mapPos(this.from),to=tr.changes.mapPos(this.to,1);let pos=cur(tr.state);if((this.explicitPos<0?pos<=from:posto||type=="delete"&&cur(tr.startState)==this.from)return new ActiveSource(this.source,type=="input"&&conf.activateOnTyping?1:0);let explicitPos=this.explicitPos<0?-1:tr.changes.mapPos(this.explicitPos),updated;if(checkValid(this.result.validFor,tr.state,from,to))return new ActiveResult(this.source,explicitPos,this.result,from,to);if(this.result.update&&(updated=this.result.update(this.result,from,to,new CompletionContext(tr.state,pos,explicitPos>=0))))return new ActiveResult(this.source,explicitPos,updated,updated.from,(_a=updated.to)!==null&&_a!==void 0?_a:cur(tr.state));return new ActiveSource(this.source,1,explicitPos);}handleChange(tr){return tr.changes.touchesRange(this.from,this.to)?new ActiveSource(this.source,0):this.map(tr.changes);}map(mapping){return mapping.empty?this:new ActiveResult(this.source,this.explicitPos<0?-1:mapping.mapPos(this.explicitPos),this.result,mapping.mapPos(this.from),mapping.mapPos(this.to,1));}}function checkValid(validFor,state,from,to){if(!validFor)return false;let text=state.sliceDoc(from,to);return typeof validFor=="function"?validFor(text,from,to,state):ensureAnchor(validFor,true).test(text);}const setActiveEffect=StateEffect.define({map(sources,mapping){return sources.map(s=>s.map(mapping));}});const setSelectedEffect=StateEffect.define();const completionState=StateField.define({create(){return CompletionState.start();},update(value,tr){return value.update(tr);},provide:f=>[showTooltip.from(f,val=>val.tooltip),EditorView.contentAttributes.from(f,state=>state.attrs)]});function applyCompletion(view,option){const apply=option.completion.apply||option.completion.label;let result=view.state.field(completionState).active.find(a=>a.source==option.source);if(!(result instanceof ActiveResult))return false;if(typeof apply=="string")view.dispatch(Object.assign(Object.assign({},insertCompletionText(view.state,apply,result.from,result.to)),{annotations:pickedCompletion.of(option.completion)}));else apply(view,option.completion,result.from,result.to);return true;}function moveCompletionSelection(forward,by="option"){return view=>{let cState=view.state.field(completionState,false);if(!cState||!cState.open||cState.open.disabled||Date.now()-cState.open.timestamp-1?cState.open.selected+step*(forward?1:-1):forward?0:length-1;if(selected<0)selected=by=="page"?0:length-1;else if(selected>=length)selected=by=="page"?length-1:0;view.dispatch({effects:setSelectedEffect.of(selected)});return true;};}const acceptCompletion=view=>{let cState=view.state.field(completionState,false);if(view.state.readOnly||!cState||!cState.open||cState.open.selected<0||cState.open.disabled||Date.now()-cState.open.timestamp{let cState=view.state.field(completionState,false);if(!cState)return false;view.dispatch({effects:startCompletionEffect.of(true)});return true;};const closeCompletion=view=>{let cState=view.state.field(completionState,false);if(!cState||!cState.active.some(a=>a.state!=0))return false;view.dispatch({effects:closeCompletionEffect.of(null)});return true;};class RunningQuery{constructor(active,context){this.active=active;this.context=context;this.time=Date.now();this.updates=[];this.done=undefined;}}const DebounceTime=50,MaxUpdateCount=50,MinAbortTime=1000;const completionPlugin=ViewPlugin.fromClass(class{constructor(view){this.view=view;this.debounceUpdate=-1;this.running=[];this.debounceAccept=-1;this.composing=0;for(let _i221=0,_view$state$field$act=view.state.field(completionState).active,_length221=_view$state$field$act.length;_i221<_length221;_i221++){let active=_view$state$field$act[_i221];if(active.state==1)this.startQuery(active);}}update(update){let cState=update.state.field(completionState);if(!update.selectionSet&&!update.docChanged&&update.startState.field(completionState)==cState)return;let doesReset=update.transactions.some(tr=>{return(tr.selection||tr.docChanged)&&!getUserEvent(tr);});for(let i=0;iMaxUpdateCount&&Date.now()-query.time>MinAbortTime){for(let _i222=0,_query$context$abortL=query.context.abortListeners,_length222=_query$context$abortL.length;_i222<_length222;_i222++){let handler=_query$context$abortL[_i222];try{handler();}catch(e){logException(this.view.state,e);}}query.context.abortListeners=null;this.running.splice(i--,1);}else{query.updates.push(...update.transactions);}}if(this.debounceUpdate>-1)clearTimeout(this.debounceUpdate);this.debounceUpdate=cState.active.some(a=>a.state==1&&!this.running.some(q=>q.active.source==a.source))?setTimeout(()=>this.startUpdate(),DebounceTime):-1;if(this.composing!=0)for(let _i223=0,_update$transactions2=update.transactions,_length223=_update$transactions2.length;_i223<_length223;_i223++){let tr=_update$transactions2[_i223];if(getUserEvent(tr)=="input")this.composing=2;else if(this.composing==2&&tr.selection)this.composing=3;}}startUpdate(){this.debounceUpdate=-1;let{state}=this.view,cState=state.field(completionState);for(let _i224=0,_cState$active=cState.active,_length224=_cState$active.length;_i224<_length224;_i224++){let active=_cState$active[_i224];if(active.state==1&&!this.running.some(r=>r.active.source==active.source))this.startQuery(active);}}startQuery(active){let{state}=this.view,pos=cur(state);let context=new CompletionContext(state,pos,active.explicitPos==pos);let pending=new RunningQuery(active,context);this.running.push(pending);Promise.resolve(active.source(context)).then(result=>{if(!pending.context.aborted){pending.done=result||null;this.scheduleAccept();}},err=>{this.view.dispatch({effects:closeCompletionEffect.of(null)});logException(this.view.state,err);});}scheduleAccept(){if(this.running.every(q=>q.done!==undefined))this.accept();else if(this.debounceAccept<0)this.debounceAccept=setTimeout(()=>this.accept(),DebounceTime);}accept(){var _a;if(this.debounceAccept>-1)clearTimeout(this.debounceAccept);this.debounceAccept=-1;let updated=[];let conf=this.view.state.facet(completionConfig);for(let i=0;ia.source==query.active.source);if(current&¤t.state==1){if(query.done==null){let active=new ActiveSource(query.active.source,0);for(let _i226=0,_query$updates2=query.updates,_length226=_query$updates2.length;_i226<_length226;_i226++){let tr=_query$updates2[_i226];active=active.update(tr,conf);}if(active.state!=1)updated.push(active);}else{this.startQuery(current);}}}if(updated.length)this.view.dispatch({effects:setActiveEffect.of(updated)});}},{eventHandlers:{blur(event){let state=this.view.state.field(completionState,false);if(state&&state.tooltip&&this.view.state.facet(completionConfig).closeOnBlur){let dialog=state.open&&getTooltip(this.view,state.open.tooltip);if(!dialog||!dialog.dom.contains(event.relatedTarget))this.view.dispatch({effects:closeCompletionEffect.of(null)});}},compositionstart(){this.composing=1;},compositionend(){if(this.composing==3){setTimeout(()=>this.view.dispatch({effects:startCompletionEffect.of(false)}),20);}this.composing=0;}}});const baseTheme$2=EditorView.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:0.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:0.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:`${400}px`,boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`${30}px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`${30}px`},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑\uFE0E'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class FieldPos{constructor(field,line,from,to){this.field=field;this.line=line;this.from=from;this.to=to;}}class FieldRange{constructor(field,from,to){this.field=field;this.from=from;this.to=to;}map(changes){let from=changes.mapPos(this.from,-1,MapMode.TrackDel);let to=changes.mapPos(this.to,1,MapMode.TrackDel);return from==null||to==null?null:new FieldRange(this.field,from,to);}}class Snippet{constructor(lines,fieldPositions){this.lines=lines;this.fieldPositions=fieldPositions;}instantiate(state,pos){let text=[],lineStart=[pos];let lineObj=state.doc.lineAt(pos),baseIndent=/^\s*/.exec(lineObj.text)[0];for(let _i227=0,_this$lines=this.lines,_length227=_this$lines.length;_i227<_length227;_i227++){let line=_this$lines[_i227];if(text.length){let indent=baseIndent,tabs=/^\t*/.exec(line)[0].length;for(let i=0;inew FieldRange(pos.field,lineStart[pos.line]+pos.from,lineStart[pos.line]+pos.to));return{text,ranges};}static parse(template){let fields=[];let lines=[],positions=[],m;for(let _i228=0,_template$split=template.split(/\r\n?|\n/),_length228=_template$split.length;_i228<_length228;_i228++){let line=_template$split[_i228];while(m=/[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(line)){let seq=m[1]?+m[1]:null,name=m[2]||m[3]||"",found=-1;for(let i=0;i=found)pos.field++;}}positions.push(new FieldPos(found,lines.length,m.index,m.index+name.length));line=line.slice(0,m.index)+name+line.slice(m.index+m[0].length);}for(let esc;esc=/\\([{}])/.exec(line);){line=line.slice(0,esc.index)+esc[1]+line.slice(esc.index+esc[0].length);for(let _i230=0,_length230=positions.length;_i230<_length230;_i230++){let pos=positions[_i230];if(pos.line==lines.length&&pos.from>esc.index){pos.from--;pos.to--;}}}lines.push(line);}return new Snippet(lines,positions);}}let fieldMarker=Decoration.widget({widget:new class extends WidgetType{toDOM(){let span=document.createElement("span");span.className="cm-snippetFieldPosition";return span;}ignoreEvent(){return false;}}()});let fieldRange=Decoration.mark({class:"cm-snippetField"});class ActiveSnippet{constructor(ranges,active){this.ranges=ranges;this.active=active;this.deco=Decoration.set(ranges.map(r=>(r.from==r.to?fieldMarker:fieldRange).range(r.from,r.to)));}map(changes){let ranges=[];for(let _i231=0,_this$ranges=this.ranges,_length231=_this$ranges.length;_i231<_length231;_i231++){let r=_this$ranges[_i231];let mapped=r.map(changes);if(!mapped)return null;ranges.push(mapped);}return new ActiveSnippet(ranges,this.active);}selectionInsideField(sel){return sel.ranges.every(range=>this.ranges.some(r=>r.field==this.active&&r.from<=range.from&&r.to>=range.to));}}const setActive=StateEffect.define({map(value,changes){return value&&value.map(changes);}});const moveToField=StateEffect.define();const snippetState=StateField.define({create(){return null;},update(value,tr){for(let _i232=0,_tr$effects12=tr.effects,_length232=_tr$effects12.length;_i232<_length232;_i232++){let effect=_tr$effects12[_i232];if(effect.is(setActive))return effect.value;if(effect.is(moveToField)&&value)return new ActiveSnippet(value.ranges,effect.value);}if(value&&tr.docChanged)value=value.map(tr.changes);if(value&&tr.selection&&!value.selectionInsideField(tr.selection))value=null;return value;},provide:f=>EditorView.decorations.from(f,val=>val?val.deco:Decoration.none)});function fieldSelection(ranges,field){return EditorSelection.create(ranges.filter(r=>r.field==field).map(r=>EditorSelection.range(r.from,r.to)));}function snippet(template){let snippet=Snippet.parse(template);return(editor,completion,from,to)=>{let{text,ranges}=snippet.instantiate(editor.state,from);let spec={changes:{from,to,insert:Text$1.of(text)},scrollIntoView:true,annotations:completion?pickedCompletion.of(completion):undefined};if(ranges.length)spec.selection=fieldSelection(ranges,0);if(ranges.length>1){let active=new ActiveSnippet(ranges,0);let effects=spec.effects=[setActive.of(active)];if(editor.state.field(snippetState,false)===undefined)effects.push(StateEffect.appendConfig.of([snippetState,addSnippetKeymap,snippetPointerHandler,baseTheme$2]));}editor.dispatch(editor.state.update(spec));};}function moveField(dir){return({state,dispatch})=>{let active=state.field(snippetState,false);if(!active||dir<0&&active.active==0)return false;let next=active.active+dir,last=dir>0&&!active.ranges.some(r=>r.field==next+dir);dispatch(state.update({selection:fieldSelection(active.ranges,next),effects:setActive.of(last?null:new ActiveSnippet(active.ranges,next))}));return true;};}const clearSnippet=({state,dispatch})=>{let active=state.field(snippetState,false);if(!active)return false;dispatch(state.update({effects:setActive.of(null)}));return true;};const nextSnippetField=moveField(1);const prevSnippetField=moveField(-1);function hasNextSnippetField(state){let active=state.field(snippetState,false);return!!(active&&active.ranges.some(r=>r.field==active.active+1));}function hasPrevSnippetField(state){let active=state.field(snippetState,false);return!!(active&&active.active>0);}const defaultSnippetKeymap=[{key:"Tab",run:nextSnippetField,shift:prevSnippetField},{key:"Escape",run:clearSnippet}];const snippetKeymap=Facet.define({combine(maps){return maps.length?maps[0]:defaultSnippetKeymap;}});const addSnippetKeymap=Prec.highest(keymap.compute([snippetKeymap],state=>state.facet(snippetKeymap)));function snippetCompletion(template,completion){return Object.assign(Object.assign({},completion),{apply:snippet(template)});}const snippetPointerHandler=EditorView.domEventHandlers({mousedown(event,view){let active=view.state.field(snippetState,false),pos;if(!active||(pos=view.posAtCoords({x:event.clientX,y:event.clientY}))==null)return false;let match=active.ranges.find(r=>r.from<=pos&&r.to>=pos);if(!match||match.field==active.active)return false;view.dispatch({selection:fieldSelection(active.ranges,match.field),effects:setActive.of(active.ranges.some(r=>r.field>match.field)?new ActiveSnippet(active.ranges,match.field):null)});return true;}});function wordRE(wordChars){let escaped=wordChars.replace(/[\\[.+*?(){|^$]/g,"\\$&");try{return new RegExp(`[\\p{Alphabetic}\\p{Number}_${escaped}]+`,"ug");}catch(_a){return new RegExp(`[\w${escaped}]`,"g");}}function mapRE(re,f){return new RegExp(f(re.source),re.unicode?"u":"");}const wordCaches=Object.create(null);function wordCache(wordChars){return wordCaches[wordChars]||(wordCaches[wordChars]=new WeakMap());}function storeWords(doc,wordRE,result,seen,ignoreAt){for(let lines=doc.iterLines(),pos=0;!lines.next().done;){let{value}=lines,m;wordRE.lastIndex=0;while(m=wordRE.exec(value)){if(!seen[m[0]]&&pos+m.index!=ignoreAt){result.push({type:"text",label:m[0]});seen[m[0]]=true;if(result.length>=2000)return;}}pos+=value.length+1;}}function collectWords(doc,cache,wordRE,to,ignoreAt){let big=doc.length>=1000;let cached=big&&cache.get(doc);if(cached)return cached;let result=[],seen=Object.create(null);if(doc.children){let pos=0;for(let _i233=0,_doc$children=doc.children,_length233=_doc$children.length;_i233<_length233;_i233++){let ch=_doc$children[_i233];if(ch.length>=1000){for(let _i234=0,_collectWords=collectWords(ch,cache,wordRE,to-pos,ignoreAt-pos),_length234=_collectWords.length;_i234<_length234;_i234++){let c=_collectWords[_i234];if(!seen[c.label]){seen[c.label]=true;result.push(c);}}}else{storeWords(ch,wordRE,result,seen,ignoreAt-pos);}pos+=ch.length+1;}}else{storeWords(doc,wordRE,result,seen,ignoreAt);}if(big&&result.length<2000)cache.set(doc,result);return result;}const completeAnyWord=context=>{let wordChars=context.state.languageDataAt("wordChars",context.pos).join("");let re=wordRE(wordChars);let token=context.matchBefore(mapRE(re,s=>s+"$"));if(!token&&!context.explicit)return null;let from=token?token.from:context.pos;let options=collectWords(context.state.doc,wordCache(wordChars),re,50000,from);return{from,options,validFor:mapRE(re,s=>"^"+s)};};const defaults$1={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]};const closeBracketEffect=StateEffect.define({map(value,mapping){let mapped=mapping.mapPos(value,-1,MapMode.TrackAfter);return mapped==null?undefined:mapped;}});const closedBracket=new class extends RangeValue{}();closedBracket.startSide=1;closedBracket.endSide=-1;const bracketState=StateField.define({create(){return RangeSet.empty;},update(value,tr){if(tr.selection){let lineStart=tr.state.doc.lineAt(tr.selection.main.head).from;let prevLineStart=tr.startState.doc.lineAt(tr.startState.selection.main.head).from;if(lineStart!=tr.changes.mapPos(prevLineStart,-1))value=RangeSet.empty;}value=value.map(tr.changes);for(let _i235=0,_tr$effects13=tr.effects,_length235=_tr$effects13.length;_i235<_length235;_i235++){let effect=_tr$effects13[_i235];if(effect.is(closeBracketEffect))value=value.update({add:[closedBracket.range(effect.value,effect.value+1)]});}return value;}});function closeBrackets(){return[inputHandler,bracketState];}const definedClosing="()[]{}<>";function closing(ch){for(let i=0;i{if((android$1?view.composing:view.compositionStarted)||view.state.readOnly)return false;let sel=view.state.selection.main;if(insert.length>2||insert.length==2&&codePointSize(codePointAt(insert,0))==1||from!=sel.from||to!=sel.to)return false;let tr=insertBracket(view.state,insert);if(!tr)return false;view.dispatch(tr);return true;});const deleteBracketPair=({state,dispatch})=>{if(state.readOnly)return false;let conf=config(state,state.selection.main.head);let tokens=conf.brackets||defaults$1.brackets;let dont=null,changes=state.changeByRange(range=>{if(range.empty){let before=prevChar(state.doc,range.head);for(let _i236=0,_length236=tokens.length;_i236<_length236;_i236++){let token=tokens[_i236];if(token==before&&nextChar(state.doc,range.head)==closing(codePointAt(token,0)))return{changes:{from:range.head-token.length,to:range.head+token.length},range:EditorSelection.cursor(range.head-token.length)};}}return{range:dont=range};});if(!dont)dispatch(state.update(changes,{scrollIntoView:true,userEvent:"delete.backward"}));return!dont;};const closeBracketsKeymap=[{key:"Backspace",run:deleteBracketPair}];function insertBracket(state,bracket){let conf=config(state,state.selection.main.head);let tokens=conf.brackets||defaults$1.brackets;for(let _i237=0,_length237=tokens.length;_i237<_length237;_i237++){let tok=tokens[_i237];let closed=closing(codePointAt(tok,0));if(bracket==tok)return closed==tok?handleSame(state,tok,tokens.indexOf(tok+tok+tok)>-1,conf):handleOpen(state,tok,closed,conf.before||defaults$1.before);if(bracket==closed&&closedBracketAt(state,state.selection.main.from))return handleClose(state,tok,closed);}return null;}function closedBracketAt(state,pos){let found=false;state.field(bracketState).between(0,state.doc.length,from=>{if(from==pos)found=true;});return found;}function nextChar(doc,pos){let next=doc.sliceString(pos,pos+2);return next.slice(0,codePointSize(codePointAt(next,0)));}function prevChar(doc,pos){let prev=doc.sliceString(pos-2,pos);return codePointSize(codePointAt(prev,0))==prev.length?prev:prev.slice(1);}function handleOpen(state,open,close,closeBefore){let dont=null,changes=state.changeByRange(range=>{if(!range.empty)return{changes:[{insert:open,from:range.from},{insert:close,from:range.to}],effects:closeBracketEffect.of(range.to+open.length),range:EditorSelection.range(range.anchor+open.length,range.head+open.length)};let next=nextChar(state.doc,range.head);if(!next||/\s/.test(next)||closeBefore.indexOf(next)>-1)return{changes:{insert:open+close,from:range.head},effects:closeBracketEffect.of(range.head+open.length),range:EditorSelection.cursor(range.head+open.length)};return{range:dont=range};});return dont?null:state.update(changes,{scrollIntoView:true,userEvent:"input.type"});}function handleClose(state,_open,close){let dont=null,changes=state.changeByRange(range=>{if(range.empty&&nextChar(state.doc,range.head)==close)return{changes:{from:range.head,to:range.head+close.length,insert:close},range:EditorSelection.cursor(range.head+close.length)};return dont={range};});return dont?null:state.update(changes,{scrollIntoView:true,userEvent:"input.type"});}function handleSame(state,token,allowTriple,config){let stringPrefixes=config.stringPrefixes||defaults$1.stringPrefixes;let dont=null,changes=state.changeByRange(range=>{if(!range.empty)return{changes:[{insert:token,from:range.from},{insert:token,from:range.to}],effects:closeBracketEffect.of(range.to+token.length),range:EditorSelection.range(range.anchor+token.length,range.head+token.length)};let pos=range.head,next=nextChar(state.doc,pos),start;if(next==token){if(nodeStart(state,pos)){return{changes:{insert:token+token,from:pos},effects:closeBracketEffect.of(pos+token.length),range:EditorSelection.cursor(pos+token.length)};}else if(closedBracketAt(state,pos)){let isTriple=allowTriple&&state.sliceDoc(pos,pos+token.length*3)==token+token+token;let content=isTriple?token+token+token:token;return{changes:{from:pos,to:pos+content.length,insert:content},range:EditorSelection.cursor(pos+content.length)};}}else if(allowTriple&&state.sliceDoc(pos-2*token.length,pos)==token+token&&(start=canStartStringAt(state,pos-2*token.length,stringPrefixes))>-1&&nodeStart(state,start)){return{changes:{insert:token+token+token+token,from:pos},effects:closeBracketEffect.of(pos+token.length),range:EditorSelection.cursor(pos+token.length)};}else if(state.charCategorizer(pos)(next)!=CharCategory.Word){if(canStartStringAt(state,pos,stringPrefixes)>-1&&!probablyInString(state,pos,token,stringPrefixes))return{changes:{insert:token+token,from:pos},effects:closeBracketEffect.of(pos+token.length),range:EditorSelection.cursor(pos+token.length)};}return{range:dont=range};});return dont?null:state.update(changes,{scrollIntoView:true,userEvent:"input.type"});}function nodeStart(state,pos){let tree=syntaxTree(state).resolveInner(pos+1);return tree.parent&&tree.from==pos;}function probablyInString(state,pos,quoteToken,prefixes){let node=syntaxTree(state).resolveInner(pos,-1);let maxPrefix=prefixes.reduce((m,p)=>Math.max(m,p.length),0);for(let i=0;i<5;i++){let start=state.sliceDoc(node.from,Math.min(node.to,node.from+quoteToken.length+maxPrefix));let quotePos=start.indexOf(quoteToken);if(!quotePos||quotePos>-1&&prefixes.indexOf(start.slice(0,quotePos))>-1){let first=node.firstChild;while(first&&first.from==node.from&&first.to-first.from>quoteToken.length+quotePos){if(state.sliceDoc(first.to-quoteToken.length,first.to)==quoteToken)return false;first=first.firstChild;}return true;}let parent=node.to==pos&&node.parent;if(!parent)break;node=parent;}return false;}function canStartStringAt(state,pos,prefixes){let charCat=state.charCategorizer(pos);if(charCat(state.sliceDoc(pos-1,pos))!=CharCategory.Word)return pos;for(let _i238=0,_length238=prefixes.length;_i238<_length238;_i238++){let prefix=prefixes[_i238];let start=pos-prefix.length;if(state.sliceDoc(start,pos)==prefix&&charCat(state.sliceDoc(start-1,start))!=CharCategory.Word)return start;}return-1;}function autocompletion(config={}){return[completionState,completionConfig.of(config),completionPlugin,completionKeymapExt,baseTheme$2];}const completionKeymap=[{key:"Ctrl-Space",run:startCompletion},{key:"Escape",run:closeCompletion},{key:"ArrowDown",run:moveCompletionSelection(true)},{key:"ArrowUp",run:moveCompletionSelection(false)},{key:"PageDown",run:moveCompletionSelection(true,"page")},{key:"PageUp",run:moveCompletionSelection(false,"page")},{key:"Enter",run:acceptCompletion}];const completionKeymapExt=Prec.highest(keymap.computeN([completionConfig],state=>state.facet(completionConfig).defaultKeymap?[completionKeymap]:[]));function completionStatus(state){let cState=state.field(completionState,false);return cState&&cState.active.some(a=>a.state==1)?"pending":cState&&cState.active.some(a=>a.state!=0)?"active":null;}const completionArrayCache=new WeakMap();function currentCompletions(state){var _a;let open=(_a=state.field(completionState,false))===null||_a===void 0?void 0:_a.open;if(!open||open.disabled)return[];let completions=completionArrayCache.get(open.options);if(!completions)completionArrayCache.set(open.options,completions=open.options.map(o=>o.completion));return completions;}function selectedCompletion(state){var _a;let open=(_a=state.field(completionState,false))===null||_a===void 0?void 0:_a.open;return open&&!open.disabled&&open.selected>=0?open.options[open.selected].completion:null;}function selectedCompletionIndex(state){var _a;let open=(_a=state.field(completionState,false))===null||_a===void 0?void 0:_a.open;return open&&!open.disabled&&open.selected>=0?open.selected:null;}function setSelectedCompletion(index){return setSelectedEffect.of(index);}var _m5=Object.freeze({__proto__:null,CompletionContext:CompletionContext,acceptCompletion:acceptCompletion,autocompletion:autocompletion,clearSnippet:clearSnippet,closeBrackets:closeBrackets,closeBracketsKeymap:closeBracketsKeymap,closeCompletion:closeCompletion,completeAnyWord:completeAnyWord,completeFromList:completeFromList,completionKeymap:completionKeymap,completionStatus:completionStatus,currentCompletions:currentCompletions,deleteBracketPair:deleteBracketPair,hasNextSnippetField:hasNextSnippetField,hasPrevSnippetField:hasPrevSnippetField,ifIn:ifIn,ifNotIn:ifNotIn,insertBracket:insertBracket,insertCompletionText:insertCompletionText,moveCompletionSelection:moveCompletionSelection,nextSnippetField:nextSnippetField,pickedCompletion:pickedCompletion,prevSnippetField:prevSnippetField,selectedCompletion:selectedCompletion,selectedCompletionIndex:selectedCompletionIndex,setSelectedCompletion:setSelectedCompletion,snippet:snippet,snippetCompletion:snippetCompletion,snippetKeymap:snippetKeymap,startCompletion:startCompletion});class SelectedDiagnostic{constructor(from,to,diagnostic){this.from=from;this.to=to;this.diagnostic=diagnostic;}}class LintState{constructor(diagnostics,panel,selected){this.diagnostics=diagnostics;this.panel=panel;this.selected=selected;}static init(diagnostics,panel,state){let markedDiagnostics=diagnostics;let diagnosticFilter=state.facet(lintConfig).markerFilter;if(diagnosticFilter)markedDiagnostics=diagnosticFilter(markedDiagnostics);let ranges=Decoration.set(markedDiagnostics.map(d=>{return d.from==d.to||d.from==d.to-1&&state.doc.lineAt(d.from).to==d.from?Decoration.widget({widget:new DiagnosticWidget(d),diagnostic:d}).range(d.from):Decoration.mark({attributes:{class:"cm-lintRange cm-lintRange-"+d.severity+(d.markClass?" "+d.markClass:"")},diagnostic:d}).range(d.from,d.to);}),true);return new LintState(ranges,panel,findDiagnostic(ranges));}}function findDiagnostic(diagnostics,diagnostic=null,after=0){let found=null;diagnostics.between(after,1e9,(from,to,{spec})=>{if(diagnostic&&spec.diagnostic!=diagnostic)return;found=new SelectedDiagnostic(from,to,spec.diagnostic);return false;});return found;}function hideTooltip(tr,tooltip){let line=tr.startState.doc.lineAt(tooltip.pos);return!!(tr.effects.some(e=>e.is(setDiagnosticsEffect))||tr.changes.touchesRange(line.from,line.to));}function maybeEnableLint(state,effects){return state.field(lintState,false)?effects:effects.concat(StateEffect.appendConfig.of(lintExtensions));}function setDiagnostics(state,diagnostics){return{effects:maybeEnableLint(state,[setDiagnosticsEffect.of(diagnostics)])};}const setDiagnosticsEffect=StateEffect.define();const togglePanel=StateEffect.define();const movePanelSelection=StateEffect.define();const lintState=StateField.define({create(){return new LintState(Decoration.none,null,null);},update(value,tr){if(tr.docChanged){let mapped=value.diagnostics.map(tr.changes),selected=null;if(value.selected){let selPos=tr.changes.mapPos(value.selected.from,1);selected=findDiagnostic(mapped,value.selected.diagnostic,selPos)||findDiagnostic(mapped,null,selPos);}value=new LintState(mapped,value.panel,selected);}for(let _i239=0,_tr$effects14=tr.effects,_length239=_tr$effects14.length;_i239<_length239;_i239++){let effect=_tr$effects14[_i239];if(effect.is(setDiagnosticsEffect)){value=LintState.init(effect.value,value.panel,tr.state);}else if(effect.is(togglePanel)){value=new LintState(value.diagnostics,effect.value?LintPanel.open:null,value.selected);}else if(effect.is(movePanelSelection)){value=new LintState(value.diagnostics,value.panel,effect.value);}}return value;},provide:f=>[showPanel.from(f,val=>val.panel),EditorView.decorations.from(f,s=>s.diagnostics)]});function diagnosticCount(state){let lint=state.field(lintState,false);return lint?lint.diagnostics.size:0;}const activeMark=Decoration.mark({class:"cm-lintRange cm-lintRange-active"});function lintTooltip(view,pos,side){let{diagnostics}=view.state.field(lintState);let found=[],stackStart=2e8,stackEnd=0;diagnostics.between(pos-(side<0?1:0),pos+(side>0?1:0),(from,to,{spec})=>{if(pos>=from&&pos<=to&&(from==to||(pos>from||side>0)&&(posrenderDiagnostic(view,d,false)));}const openLintPanel=view=>{let field=view.state.field(lintState,false);if(!field||!field.panel)view.dispatch({effects:maybeEnableLint(view.state,[togglePanel.of(true)])});let panel=getPanel(view,LintPanel.open);if(panel)panel.dom.querySelector(".cm-panel-lint ul").focus();return true;};const closeLintPanel=view=>{let field=view.state.field(lintState,false);if(!field||!field.panel)return false;view.dispatch({effects:togglePanel.of(false)});return true;};const nextDiagnostic=view=>{let field=view.state.field(lintState,false);if(!field)return false;let sel=view.state.selection.main,next=field.diagnostics.iter(sel.to+1);if(!next.value){next=field.diagnostics.iter(0);if(!next.value||next.from==sel.from&&next.to==sel.to)return false;}view.dispatch({selection:{anchor:next.from,head:next.to},scrollIntoView:true});return true;};const previousDiagnostic=view=>{let{state}=view,field=state.field(lintState,false);if(!field)return false;let sel=state.selection.main;let prevFrom,prevTo,lastFrom,lastTo;field.diagnostics.between(0,state.doc.length,(from,to)=>{if(tolastFrom){lastFrom=from;lastTo=to;}});if(lastFrom==null||prevFrom==null&&lastFrom==sel.from)return false;view.dispatch({selection:{anchor:prevFrom!==null&&prevFrom!==void 0?prevFrom:lastFrom,head:prevTo!==null&&prevTo!==void 0?prevTo:lastTo},scrollIntoView:true});return true;};const lintKeymap=[{key:"Mod-Shift-m",run:openLintPanel,preventDefault:true},{key:"F8",run:nextDiagnostic}];const lintPlugin=ViewPlugin.fromClass(class{constructor(view){this.view=view;this.timeout=-1;this.set=true;let{delay}=view.state.facet(lintConfig);this.lintTime=Date.now()+delay;this.run=this.run.bind(this);this.timeout=setTimeout(this.run,delay);}run(){let now=Date.now();if(nowPromise.resolve(source(this.view)))).then(annotations=>{let all=annotations.reduce((a,b)=>a.concat(b));if(this.view.state.doc==state.doc)this.view.dispatch(setDiagnostics(this.view.state,all));},error=>{logException(this.view.state,error);});}}update(update){let config=update.state.facet(lintConfig);if(update.docChanged||config!=update.startState.facet(lintConfig)||config.needsRefresh&&config.needsRefresh(update)){this.lintTime=Date.now()+config.delay;if(!this.set){this.set=true;this.timeout=setTimeout(this.run,config.delay);}}}force(){if(this.set){this.lintTime=Date.now();this.run();}}destroy(){clearTimeout(this.timeout);}});const lintConfig=Facet.define({combine(input){return Object.assign({sources:input.map(i=>i.source)},combineConfig(input.map(i=>i.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null},{needsRefresh:(a,b)=>!a?b:!b?a:u=>a(u)||b(u)}));}});function linter(source,config={}){return[lintConfig.of({source,config}),lintPlugin,lintExtensions];}function forceLinting(view){let plugin=view.plugin(lintPlugin);if(plugin)plugin.force();}function assignKeys(actions){let assigned=[];if(actions)actions:for(let _i240=0,_length240=actions.length;_i240<_length240;_i240++){let{name}=actions[_i240];for(let i=0;ic.toLowerCase()==ch.toLowerCase())){assigned.push(ch);continue actions;}}assigned.push("");}return assigned;}function renderDiagnostic(view,diagnostic,inPanel){var _a;let keys=inPanel?assignKeys(diagnostic.actions):[];return crelt("li",{class:"cm-diagnostic cm-diagnostic-"+diagnostic.severity},crelt("span",{class:"cm-diagnosticText"},diagnostic.renderMessage?diagnostic.renderMessage():diagnostic.message),(_a=diagnostic.actions)===null||_a===void 0?void 0:_a.map((action,i)=>{let fired=false,click=e=>{e.preventDefault();if(fired)return;fired=true;let found=findDiagnostic(view.state.field(lintState).diagnostics,diagnostic);if(found)action.apply(view,found.from,found.to);};let{name}=action,keyIndex=keys[i]?name.indexOf(keys[i]):-1;let nameElt=keyIndex<0?name:[name.slice(0,keyIndex),crelt("u",name.slice(keyIndex,keyIndex+1)),name.slice(keyIndex+1)];return crelt("button",{type:"button",class:"cm-diagnosticAction",onclick:click,onmousedown:click,"aria-label":` Action: ${name}${keyIndex<0?"":` (access key "${keys[i]})"`}.`},nameElt);}),diagnostic.source&&crelt("div",{class:"cm-diagnosticSource"},diagnostic.source));}class DiagnosticWidget extends WidgetType{constructor(diagnostic){super();this.diagnostic=diagnostic;}eq(other){return other.diagnostic==this.diagnostic;}toDOM(){return crelt("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity});}}class PanelItem{constructor(view,diagnostic){this.diagnostic=diagnostic;this.id="item_"+Math.floor(Math.random()*0xffffffff).toString(16);this.dom=renderDiagnostic(view,diagnostic,true);this.dom.id=this.id;this.dom.setAttribute("role","option");}}class LintPanel{constructor(view){this.view=view;this.items=[];let onkeydown=event=>{if(event.keyCode==27){closeLintPanel(this.view);this.view.focus();}else if(event.keyCode==38||event.keyCode==33){this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);}else if(event.keyCode==40||event.keyCode==34){this.moveSelection((this.selectedIndex+1)%this.items.length);}else if(event.keyCode==36){this.moveSelection(0);}else if(event.keyCode==35){this.moveSelection(this.items.length-1);}else if(event.keyCode==13){this.view.focus();}else if(event.keyCode>=65&&event.keyCode<=90&&this.selectedIndex>=0){let{diagnostic}=this.items[this.selectedIndex],keys=assignKeys(diagnostic.actions);for(let i=0;i{for(let i=0;icloseLintPanel(this.view)},"×"));this.update();}get selectedIndex(){let selected=this.view.state.field(lintState).selected;if(!selected)return-1;for(let i=0;i{let found=-1,item;for(let j=i;ji){this.items.splice(i,found-i);needsSync=true;}}if(selected&&item.diagnostic==selected.diagnostic){if(!item.dom.hasAttribute("aria-selected")){item.dom.setAttribute("aria-selected","true");newSelectedItem=item;}}else if(item.dom.hasAttribute("aria-selected")){item.dom.removeAttribute("aria-selected");}i++;});while(i({sel:newSelectedItem.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel,panel})=>{if(sel.toppanel.bottom)this.list.scrollTop+=sel.bottom-panel.bottom;}});}else if(this.selectedIndex<0){this.list.removeAttribute("aria-activedescendant");}if(needsSync)this.sync();}sync(){let domPos=this.list.firstChild;function rm(){let prev=domPos;domPos=prev.nextSibling;prev.remove();}for(let _i241=0,_this$items=this.items,_length241=_this$items.length;_i241<_length241;_i241++){let item=_this$items[_i241];if(item.dom.parentNode==this.list){while(domPos!=item.dom)rm();domPos=item.dom.nextSibling;}else{this.list.insertBefore(item.dom,domPos);}}while(domPos)rm();}moveSelection(selectedIndex){if(this.selectedIndex<0)return;let field=this.view.state.field(lintState);let selection=findDiagnostic(field.diagnostics,this.items[selectedIndex].diagnostic);if(!selection)return;this.view.dispatch({selection:{anchor:selection.from,head:selection.to},scrollIntoView:true,effects:movePanelSelection.of(selection)});}static open(view){return new LintPanel(view);}}function svg(content,attrs=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,${encodeURIComponent(content)}')`;}function underline(color){return svg(``,`width="6" height="3"`);}const baseTheme$1=EditorView.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:underline("#d11")},".cm-lintRange-warning":{backgroundImage:underline("orange")},".cm-lintRange-info":{backgroundImage:underline("#999")},".cm-lintRange-hint":{backgroundImage:underline("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function severityWeight(sev){return sev=="error"?4:sev=="warning"?3:sev=="info"?2:1;}class LintGutterMarker extends GutterMarker{constructor(diagnostics){super();this.diagnostics=diagnostics;this.severity=diagnostics.reduce((max,d)=>severityWeight(max)gutterMarkerMouseOver(view,elt,diagnostics);return elt;}}function trackHoverOn(view,marker){let mousemove=event=>{let rect=marker.getBoundingClientRect();if(event.clientX>rect.left-10&&event.clientXrect.top-10&&event.clientYmarker.getBoundingClientRect()};}})});}marker.onmouseout=marker.onmousemove=null;trackHoverOn(view,marker);}let{hoverTime}=view.state.facet(lintGutterConfig);let hoverTimeout=setTimeout(hovered,hoverTime);marker.onmouseout=()=>{clearTimeout(hoverTimeout);marker.onmouseout=marker.onmousemove=null;};marker.onmousemove=()=>{clearTimeout(hoverTimeout);hoverTimeout=setTimeout(hovered,hoverTime);};}function markersForDiagnostics(doc,diagnostics){let byLine=Object.create(null);for(let _i242=0,_length242=diagnostics.length;_i242<_length242;_i242++){let diagnostic=diagnostics[_i242];let line=doc.lineAt(diagnostic.from);(byLine[line.from]||(byLine[line.from]=[])).push(diagnostic);}let markers=[];for(let line in byLine){markers.push(new LintGutterMarker(byLine[line]).range(+line));}return RangeSet.of(markers,true);}const lintGutterExtension=gutter({class:"cm-gutter-lint",markers:view=>view.state.field(lintGutterMarkers)});const lintGutterMarkers=StateField.define({create(){return RangeSet.empty;},update(markers,tr){markers=markers.map(tr.changes);let diagnosticFilter=tr.state.facet(lintGutterConfig).markerFilter;for(let _i243=0,_tr$effects15=tr.effects,_length243=_tr$effects15.length;_i243<_length243;_i243++){let effect=_tr$effects15[_i243];if(effect.is(setDiagnosticsEffect)){let diagnostics=effect.value;if(diagnosticFilter)diagnostics=diagnosticFilter(diagnostics||[]);markers=markersForDiagnostics(tr.state.doc,diagnostics.slice(0));}}return markers;}});const setLintGutterTooltip=StateEffect.define();const lintGutterTooltip=StateField.define({create(){return null;},update(tooltip,tr){if(tooltip&&tr.docChanged)tooltip=hideTooltip(tr,tooltip)?null:Object.assign(Object.assign({},tooltip),{pos:tr.changes.mapPos(tooltip.pos)});return tr.effects.reduce((t,e)=>e.is(setLintGutterTooltip)?e.value:t,tooltip);},provide:field=>showTooltip.from(field)});const lintGutterTheme=EditorView.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:svg(``)},".cm-lint-marker-warning":{content:svg(``)},".cm-lint-marker-error":{content:svg(``)}});const lintExtensions=[lintState,EditorView.decorations.compute([lintState],state=>{let{selected,panel}=state.field(lintState);return!selected||!panel||selected.from==selected.to?Decoration.none:Decoration.set([activeMark.range(selected.from,selected.to)]);}),hoverTooltip(lintTooltip,{hideOn:hideTooltip}),baseTheme$1];const lintGutterConfig=Facet.define({combine(configs){return combineConfig(configs,{hoverTime:300,markerFilter:null,tooltipFilter:null});}});function lintGutter(config={}){return[lintGutterConfig.of(config),lintGutterMarkers,lintGutterExtension,lintGutterTheme,lintGutterTooltip];}function forEachDiagnostic(state,f){let lState=state.field(lintState,false);if(lState&&lState.diagnostics.size)for(let iter=RangeSet.iter([lState.diagnostics]);iter.value;iter.next())f(iter.value.spec.diagnostic,iter.from,iter.to);}var _m6=Object.freeze({__proto__:null,closeLintPanel:closeLintPanel,diagnosticCount:diagnosticCount,forEachDiagnostic:forEachDiagnostic,forceLinting:forceLinting,lintGutter:lintGutter,lintKeymap:lintKeymap,linter:linter,nextDiagnostic:nextDiagnostic,openLintPanel:openLintPanel,previousDiagnostic:previousDiagnostic,setDiagnostics:setDiagnostics,setDiagnosticsEffect:setDiagnosticsEffect});class LocalUpdate{constructor(origin,changes,effects,clientID){this.origin=origin;this.changes=changes;this.effects=effects;this.clientID=clientID;}}class CollabState{constructor(version,unconfirmed){this.version=version;this.unconfirmed=unconfirmed;}}const collabConfig=Facet.define({combine(configs){let combined=combineConfig(configs,{startVersion:0,clientID:null,sharedEffects:()=>[]});if(combined.clientID==null)combined.clientID=configs.length&&configs[0].generatedID||"";return combined;}});const collabReceive=Annotation.define();const collabField=StateField.define({create(state){return new CollabState(state.facet(collabConfig).startVersion,[]);},update(collab,tr){let isSync=tr.annotation(collabReceive);if(isSync)return isSync;let{sharedEffects,clientID}=tr.startState.facet(collabConfig);let effects=sharedEffects(tr);if(effects.length||!tr.changes.empty)return new CollabState(collab.version,collab.unconfirmed.concat(new LocalUpdate(tr,tr.changes,effects,clientID)));return collab;}});function collab(config={}){return[collabField,collabConfig.of(Object.assign({generatedID:Math.floor(Math.random()*1e9).toString(36)},config))];}function receiveUpdates(state,updates){let{version,unconfirmed}=state.field(collabField);let{clientID}=state.facet(collabConfig);version+=updates.length;let effects=[],changes=null;let own=0;for(let _i244=0,_length244=updates.length;_i244<_length244;_i244++){let update=updates[_i244];let ours=own{let updateChanges=update.changes.map(changes);changes=changes.map(update.changes,true);return new LocalUpdate(update.origin,updateChanges,StateEffect.mapEffects(update.effects,changes),clientID);});if(effects.length){let composed=unconfirmed.reduce((ch,u)=>ch.compose(u.changes),ChangeSet.empty(unconfirmed[0].changes.length));effects=StateEffect.mapEffects(effects,composed);}}if(!changes)return state.update({annotations:[collabReceive.of(new CollabState(version,unconfirmed))]});return state.update({changes:changes,effects,annotations:[Transaction.addToHistory.of(false),Transaction.remote.of(true),collabReceive.of(new CollabState(version,unconfirmed))],filter:false});}function sendableUpdates(state){return state.field(collabField).unconfirmed;}function getSyncedVersion(state){return state.field(collabField).version;}function getClientID(state){return state.facet(collabConfig).clientID;}function rebaseUpdates(updates,over){if(!over.length||!updates.length)return updates;let changes=null,skip=0;for(let _i245=0,_length245=over.length;_i245<_length245;_i245++){let update=over[_i245];let other=skip{let updateChanges=update.changes.map(changes);changes=changes.mapDesc(update.changes,true);return{changes:updateChanges,effects:update.effects&&StateEffect.mapEffects(update.effects,changes),clientID:update.clientID};});}var _m7=Object.freeze({__proto__:null,collab:collab,getClientID:getClientID,getSyncedVersion:getSyncedVersion,rebaseUpdates:rebaseUpdates,receiveUpdates:receiveUpdates,sendableUpdates:sendableUpdates});const basicSetup=(()=>[lineNumbers(),highlightActiveLineGutter(),highlightSpecialChars(),history(),foldGutter(),drawSelection(),dropCursor(),EditorState.allowMultipleSelections.of(true),indentOnInput(),syntaxHighlighting(defaultHighlightStyle,{fallback:true}),bracketMatching(),closeBrackets(),autocompletion(),rectangularSelection(),crosshairCursor(),highlightActiveLine(),highlightSelectionMatches(),keymap.of([...closeBracketsKeymap,...defaultKeymap,...searchKeymap,...historyKeymap,...foldKeymap,...completionKeymap,...lintKeymap])])();const minimalSetup=(()=>[highlightSpecialChars(),history(),drawSelection(),syntaxHighlighting(defaultHighlightStyle,{fallback:true}),keymap.of([...defaultKeymap,...historyKeymap])])();var _m8=Object.freeze({__proto__:null,basicSetup:basicSetup,minimalSetup:minimalSetup,EditorView:EditorView});class Stack{constructor(p,stack,state,reducePos,pos,score,buffer,bufferBase,curContext,lookAhead=0,parent){this.p=p;this.stack=stack;this.state=state;this.reducePos=reducePos;this.pos=pos;this.score=score;this.buffer=buffer;this.bufferBase=bufferBase;this.curContext=curContext;this.lookAhead=lookAhead;this.parent=parent;}toString(){return`[${this.stack.filter((_,i)=>i%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`;}static start(p,state,pos=0){let cx=p.parser.context;return new Stack(p,[],state,pos,pos,0,[],0,cx?new StackContext(cx,cx.start):null,0,null);}get context(){return this.curContext?this.curContext.context:null;}pushState(state,start){this.stack.push(this.state,start,this.bufferBase+this.buffer.length);this.state=state;}reduce(action){var _a;let depth=action>>19,type=action&65535;let{parser}=this.p;let dPrec=parser.dynamicPrecedence(type);if(dPrec)this.score+=dPrec;if(depth==0){this.pushState(parser.getGoto(this.state,type,true),this.reducePos);if(type=2000&&!((_a=this.p.parser.nodeSet.types[type])===null||_a===void 0?void 0:_a.isAnonymous)){if(start==this.p.lastBigReductionStart){this.p.bigReductionCount++;this.p.lastBigReductionSize=size;}else if(this.p.lastBigReductionSizebase)this.stack.pop();this.reduceContext(type,start);}storeNode(term,start,end,size=4,isReduce=false){if(term==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&cur.buffer[top-4]==0&&cur.buffer[top-1]>-1){if(start==end)return;if(cur.buffer[top-2]>=start){cur.buffer[top-2]=end;return;}}}if(!isReduce||this.pos==end){this.buffer.push(term,start,end,size);}else{let index=this.buffer.length;if(index>0&&this.buffer[index-4]!=0)while(index>0&&this.buffer[index-2]>end){this.buffer[index]=this.buffer[index-4];this.buffer[index+1]=this.buffer[index-3];this.buffer[index+2]=this.buffer[index-2];this.buffer[index+3]=this.buffer[index-1];index-=4;if(size>4)size-=4;}this.buffer[index]=term;this.buffer[index+1]=start;this.buffer[index+2]=end;this.buffer[index+3]=size;}}shift(action,next,nextEnd){let start=this.pos;if(action&131072){this.pushState(action&65535,this.pos);}else if((action&262144)==0){let nextState=action,{parser}=this.p;if(nextEnd>this.pos||next<=parser.maxNode){this.pos=nextEnd;if(!parser.stateFlag(nextState,1))this.reducePos=nextEnd;}this.pushState(nextState,start);this.shiftContext(next,start);if(next<=parser.maxNode)this.buffer.push(next,start,nextEnd,4);}else{this.pos=nextEnd;this.shiftContext(next,start);if(next<=this.p.parser.maxNode)this.buffer.push(next,start,nextEnd,4);}}apply(action,next,nextEnd){if(action&65536)this.reduce(action);else this.shift(action,next,nextEnd);}useNode(value,next){let index=this.p.reused.length-1;if(index<0||this.p.reused[index]!=value){this.p.reused.push(value);index++;}let start=this.pos;this.reducePos=this.pos=start+value.length;this.pushState(next,start);this.buffer.push(index,start,this.reducePos,-1);if(this.curContext)this.updateContext(this.curContext.tracker.reuse(this.curContext.context,value,this,this.p.stream.reset(this.pos-value.length)));}split(){let parent=this;let off=parent.buffer.length;while(off>0&&parent.buffer[off-2]>parent.reducePos)off-=4;let buffer=parent.buffer.slice(off),base=parent.bufferBase+off;while(parent&&base==parent.bufferBase)parent=parent.parent;return new Stack(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,buffer,base,this.curContext,this.lookAhead,parent);}recoverByDelete(next,nextEnd){let isNode=next<=this.p.parser.maxNode;if(isNode)this.storeNode(next,this.pos,nextEnd,4);this.storeNode(0,this.pos,nextEnd,isNode?8:4);this.pos=this.reducePos=nextEnd;this.score-=190;}canShift(term){for(let sim=new SimulatedStack(this);;){let action=this.p.parser.stateSlot(sim.state,4)||this.p.parser.hasAction(sim.state,term);if(action==0)return false;if((action&65536)==0)return true;sim.reduce(action);}}recoverByInsert(next){if(this.stack.length>=300)return[];let nextStates=this.p.parser.nextStates(this.state);if(nextStates.length>4<<1||this.stack.length>=120){let best=[];for(let i=0,s;ii&1&&v==s))best.push(nextStates[i],s);}nextStates=best;}let result=[];for(let i=0;i>19,term=reduce&65535;let target=this.stack.length-depth*3;if(target<0||parser.getGoto(this.stack[target],term,false)<0){let backup=this.findForcedReduction();if(backup==null)return false;reduce=backup;}this.storeNode(0,this.pos,this.pos,4,true);this.score-=100;}this.reducePos=this.pos;this.reduce(reduce);return true;}findForcedReduction(){let{parser}=this.p,seen=[];let explore=(state,depth)=>{if(seen.includes(state))return;seen.push(state);return parser.allActions(state,action=>{if(action&(262144|131072));else if(action&65536){let rDepth=(action>>19)-depth;if(rDepth>1){let term=action&65535,target=this.stack.length-rDepth*3;if(target>=0&&parser.getGoto(this.stack[target],term,false)>=0)return rDepth<<19|65536|term;}}else{let found=explore(action,depth+1);if(found!=null)return found;}});};return explore(this.state,0);}forceAll(){while(!this.p.parser.stateFlag(this.state,2)){if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,true);break;}}return this;}get deadEnd(){if(this.stack.length!=3)return false;let{parser}=this.p;return parser.data[parser.stateSlot(this.state,1)]==65535&&!parser.stateSlot(this.state,4);}restart(){this.state=this.stack[0];this.stack.length=0;}sameState(other){if(this.state!=other.state||this.stack.length!=other.stack.length)return false;for(let i=0;ithis.lookAhead){this.emitLookAhead();this.lookAhead=lookAhead;}}close(){if(this.curContext&&this.curContext.tracker.strict)this.emitContext();if(this.lookAhead>0)this.emitLookAhead();}}class StackContext{constructor(tracker,context){this.tracker=tracker;this.context=context;this.hash=tracker.strict?tracker.hash(context):0;}}var Recover;(function(Recover){Recover[Recover["Insert"]=200]="Insert";Recover[Recover["Delete"]=190]="Delete";Recover[Recover["Reduce"]=100]="Reduce";Recover[Recover["MaxNext"]=4]="MaxNext";Recover[Recover["MaxInsertStackDepth"]=300]="MaxInsertStackDepth";Recover[Recover["DampenInsertStackDepth"]=120]="DampenInsertStackDepth";Recover[Recover["MinBigReduction"]=2000]="MinBigReduction";})(Recover||(Recover={}));class SimulatedStack{constructor(start){this.start=start;this.state=start.state;this.stack=start.stack;this.base=this.stack.length;}reduce(action){let term=action&65535,depth=action>>19;if(depth==0){if(this.stack==this.start.stack)this.stack=this.stack.slice();this.stack.push(this.state,0,0);this.base+=3;}else{this.base-=(depth-1)*3;}let goto=this.start.p.parser.getGoto(this.stack[this.base-3],term,true);this.state=goto;}}class StackBufferCursor{constructor(stack,pos,index){this.stack=stack;this.pos=pos;this.index=index;this.buffer=stack.buffer;if(this.index==0)this.maybeNext();}static create(stack,pos=stack.bufferBase+stack.buffer.length){return new StackBufferCursor(stack,pos,pos-stack.bufferBase);}maybeNext(){let next=this.stack.parent;if(next!=null){this.index=this.stack.bufferBase-next.bufferBase;this.stack=next;this.buffer=next.buffer;}}get id(){return this.buffer[this.index-4];}get start(){return this.buffer[this.index-3];}get end(){return this.buffer[this.index-2];}get size(){return this.buffer[this.index-1];}next(){this.index-=4;this.pos-=4;if(this.index==0)this.maybeNext();}fork(){return new StackBufferCursor(this.stack,this.pos,this.index);}}function decodeArray(input,Type=Uint16Array){if(typeof input!="string")return input;let array=null;for(let pos=0,out=0;pos=92)next--;if(next>=34)next--;let digit=next-32;if(digit>=46){digit-=46;stop=true;}value+=digit;if(stop)break;value*=46;}if(array)array[out++]=value;else array=new Type(value);}return array;}class CachedToken{constructor(){this.start=-1;this.value=-1;this.end=-1;this.extended=-1;this.lookAhead=0;this.mask=0;this.context=0;}}const nullToken=new CachedToken();class InputStream{constructor(input,ranges){this.input=input;this.ranges=ranges;this.chunk="";this.chunkOff=0;this.chunk2="";this.chunk2Pos=0;this.next=-1;this.token=nullToken;this.rangeIndex=0;this.pos=this.chunkPos=ranges[0].from;this.range=ranges[0];this.end=ranges[ranges.length-1].to;this.readNext();}resolveOffset(offset,assoc){let range=this.range,index=this.rangeIndex;let pos=this.pos+offset;while(posrange.to:pos>=range.to){if(index==this.ranges.length-1)return null;let next=this.ranges[++index];pos+=next.from-range.to;range=next;}return pos;}clipPos(pos){if(pos>=this.range.from&&pospos)return Math.max(pos,range.from);}return this.end;}peek(offset){let idx=this.chunkOff+offset,pos,result;if(idx>=0&&idx=this.chunk2Pos&&posrange.to)this.chunk2=this.chunk2.slice(0,range.to-pos);result=this.chunk2.charCodeAt(0);}}if(pos>=this.token.lookAhead)this.token.lookAhead=pos+1;return result;}acceptToken(token,endOffset=0){let end=endOffset?this.resolveOffset(endOffset,-1):this.pos;if(end==null||end=this.chunk2Pos&&this.posthis.range.to?nextChunk.slice(0,this.range.to-this.pos):nextChunk;this.chunkPos=this.pos;this.chunkOff=0;}}readNext(){if(this.chunkOff>=this.chunk.length){this.getChunk();if(this.chunkOff==this.chunk.length)return this.next=-1;}return this.next=this.chunk.charCodeAt(this.chunkOff);}advance(n=1){this.chunkOff+=n;while(this.pos+n>=this.range.to){if(this.rangeIndex==this.ranges.length-1)return this.setDone();n-=this.range.to-this.pos;this.range=this.ranges[++this.rangeIndex];this.pos=this.range.from;}this.pos+=n;if(this.pos>=this.token.lookAhead)this.token.lookAhead=this.pos+1;return this.readNext();}setDone(){this.pos=this.chunkPos=this.end;this.range=this.ranges[this.rangeIndex=this.ranges.length-1];this.chunk="";return this.next=-1;}reset(pos,token){if(token){this.token=token;token.start=pos;token.lookAhead=pos+1;token.value=token.extended=-1;}else{this.token=nullToken;}if(this.pos!=pos){this.pos=pos;if(pos==this.end){this.setDone();return this;}while(pos=this.range.to)this.range=this.ranges[++this.rangeIndex];if(pos>=this.chunkPos&&pos=this.chunkPos&&to<=this.chunkPos+this.chunk.length)return this.chunk.slice(from-this.chunkPos,to-this.chunkPos);if(from>=this.chunk2Pos&&to<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(from-this.chunk2Pos,to-this.chunk2Pos);if(from>=this.range.from&&to<=this.range.to)return this.input.read(from,to);let result="";for(let _i247=0,_this$ranges3=this.ranges,_length247=_this$ranges3.length;_i247<_length247;_i247++){let r=_this$ranges3[_i247];if(r.from>=to)break;if(r.to>from)result+=this.input.read(Math.max(r.from,from),Math.min(r.to,to));}return result;}}class TokenGroup{constructor(data,id){this.data=data;this.id=id;}token(input,stack){let{parser}=stack.p;readToken(this.data,input,stack,this.id,parser.data,parser.tokenPrecTable);}}TokenGroup.prototype.contextual=TokenGroup.prototype.fallback=TokenGroup.prototype.extend=false;class LocalTokenGroup{constructor(data,precTable,elseToken){this.precTable=precTable;this.elseToken=elseToken;this.data=typeof data=="string"?decodeArray(data):data;}token(input,stack){let start=input.pos,skipped=0;for(;;){let atEof=input.next<0,nextPos=input.resolveOffset(1,1);readToken(this.data,input,stack,0,this.data,this.precTable);if(input.token.value>-1)break;if(this.elseToken==null)return;if(!atEof)skipped++;if(nextPos==null)break;input.reset(nextPos,input.token);}if(skipped){input.reset(start,input.token);input.acceptToken(this.elseToken,skipped);}}}LocalTokenGroup.prototype.contextual=TokenGroup.prototype.fallback=TokenGroup.prototype.extend=false;class ExternalTokenizer{constructor(token,options={}){this.token=token;this.contextual=!!options.contextual;this.fallback=!!options.fallback;this.extend=!!options.extend;}}function readToken(data,input,stack,group,precTable,precOffset){let state=0,groupMask=1<0){let term=data[i];if(dialect.allows(term)&&(input.token.value==-1||input.token.value==term||overrides(term,input.token.value,precTable,precOffset))){input.acceptToken(term);break;}}let next=input.next,low=0,high=data[state+2];if(input.next<0&&high>low&&data[accEnd+high*3-3]==65535&&data[accEnd+high*3-3]==65535){state=data[accEnd+high*3-1];continue scan;}for(;low>1;let index=accEnd+mid+(mid<<1);let from=data[index],to=data[index+1]||0x10000;if(next=to)low=mid+1;else{state=data[index+2];input.advance();continue scan;}}break;}}function findOffset(data,start,term){for(let i=start,next;(next=data[i])!=65535;i++)if(next==term)return i-start;return-1;}function overrides(token,prev,tableData,tableOffset){let iPrev=findOffset(tableData,tableOffset,prev);return iPrev<0||findOffset(tableData,tableOffset,token)pos)&&!cursor.type.isError)return side<0?Math.max(0,Math.min(cursor.to-1,pos-25)):Math.min(tree.length,Math.max(cursor.from+1,pos+25));if(side<0?cursor.prevSibling():cursor.nextSibling())break;if(!cursor.parent())return side<0?0:tree.length;}}}class FragmentCursor$1{constructor(fragments,nodeSet){this.fragments=fragments;this.nodeSet=nodeSet;this.i=0;this.fragment=null;this.safeFrom=-1;this.safeTo=-1;this.trees=[];this.start=[];this.index=[];this.nextFragment();}nextFragment(){let fr=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(fr){this.safeFrom=fr.openStart?cutAt(fr.tree,fr.from+fr.offset,1)-fr.offset:fr.from;this.safeTo=fr.openEnd?cutAt(fr.tree,fr.to+fr.offset,-1)-fr.offset:fr.to;while(this.trees.length){this.trees.pop();this.start.pop();this.index.pop();}this.trees.push(fr.tree);this.start.push(-fr.offset);this.index.push(0);this.nextStart=this.safeFrom;}else{this.nextStart=1e9;}}nodeAt(pos){if(pospos){this.nextStart=start;return null;}if(next instanceof Tree){if(start==pos){if(start=Math.max(this.safeFrom,pos)){this.trees.push(next);this.start.push(start);this.index.push(0);}}else{this.index[last]++;this.nextStart=start+next.length;}}}}class TokenCache{constructor(parser,stream){this.stream=stream;this.tokens=[];this.mainToken=null;this.actions=[];this.tokens=parser.tokenizers.map(_=>new CachedToken());}getActions(stack){let actionIndex=0;let main=null;let{parser}=stack.p,{tokenizers}=parser;let mask=parser.stateSlot(stack.state,3);let context=stack.curContext?stack.curContext.hash:0;let lookAhead=0;for(let i=0;itoken.end+25)lookAhead=Math.max(token.lookAhead,lookAhead);if(token.value!=0){let startIndex=actionIndex;if(token.extended>-1)actionIndex=this.addActions(stack,token.extended,token.end,actionIndex);actionIndex=this.addActions(stack,token.value,token.end,actionIndex);if(!tokenizer.extend){main=token;if(actionIndex>startIndex)break;}}}while(this.actions.length>actionIndex)this.actions.pop();if(lookAhead)stack.setLookAhead(lookAhead);if(!main&&stack.pos==this.stream.end){main=new CachedToken();main.value=stack.p.parser.eofTerm;main.start=main.end=stack.pos;actionIndex=this.addActions(stack,main.value,main.end,actionIndex);}this.mainToken=main;return this.actions;}getMainToken(stack){if(this.mainToken)return this.mainToken;let main=new CachedToken(),{pos,p}=stack;main.start=pos;main.end=Math.min(pos+1,p.stream.end);main.value=pos==p.stream.end?p.parser.eofTerm:0;return main;}updateCachedToken(token,tokenizer,stack){let start=this.stream.clipPos(stack.pos);tokenizer.token(this.stream.reset(start,token),stack);if(token.value>-1){let{parser}=stack.p;for(let i=0;i=0&&stack.p.parser.dialect.allows(result>>1)){if((result&1)==0)token.value=result>>1;else token.extended=result>>1;break;}}}else{token.value=0;token.end=this.stream.clipPos(start+1);}}putAction(action,token,end,index){for(let i=0;iparser.bufferLength*4?new FragmentCursor$1(fragments,parser.nodeSet):null;}get parsedPos(){return this.minStackPos;}advance(){let stacks=this.stacks,pos=this.minStackPos;let newStacks=this.stacks=[];let stopped,stoppedTokens;if(this.bigReductionCount>300&&stacks.length==1){let[s]=stacks;while(s.forceReduce()&&s.stack.length&&s.stack[s.stack.length-2]>=this.lastBigReductionStart){}this.bigReductionCount=this.lastBigReductionSize=0;}for(let i=0;ipos){newStacks.push(stack);}else if(this.advanceStack(stack,newStacks,stacks)){continue;}else{if(!stopped){stopped=[];stoppedTokens=[];}stopped.push(stack);let tok=this.tokens.getMainToken(stack);stoppedTokens.push(tok.value,tok.end);}break;}}if(!newStacks.length){let finished=stopped&&findFinished(stopped);if(finished)return this.stackToTree(finished);if(this.parser.strict){if(verbose&&stopped)console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none"));throw new SyntaxError("No parse at "+pos);}if(!this.recovering)this.recovering=5;}if(this.recovering&&stopped){let finished=this.stoppedAt!=null&&stopped[0].pos>this.stoppedAt?stopped[0]:this.runRecovery(stopped,stoppedTokens,newStacks);if(finished)return this.stackToTree(finished.forceAll());}if(this.recovering){let maxRemaining=this.recovering==1?1:this.recovering*3;if(newStacks.length>maxRemaining){newStacks.sort((a,b)=>b.score-a.score);while(newStacks.length>maxRemaining)newStacks.pop();}if(newStacks.some(s=>s.reducePos>pos))this.recovering--;}else if(newStacks.length>1){outer:for(let i=0;i500&&other.buffer.length>500){if((stack.score-other.score||stack.buffer.length-other.buffer.length)>0){newStacks.splice(j--,1);}else{newStacks.splice(i--,1);continue outer;}}}}if(newStacks.length>12)newStacks.splice(12,newStacks.length-12);}this.minStackPos=newStacks[0].pos;for(let i=1;i ":"";if(this.stoppedAt!=null&&start>this.stoppedAt)return stack.forceReduce()?stack:null;if(this.fragments){let strictCx=stack.curContext&&stack.curContext.tracker.strict,cxHash=strictCx?stack.curContext.hash:0;for(let cached=this.fragments.nodeAt(start);cached;){let match=this.parser.nodeSet.types[cached.type.id]==cached.type?parser.getGoto(stack.state,cached.type.id):-1;if(match>-1&&cached.length&&(!strictCx||(cached.prop(NodeProp.contextHash)||0)==cxHash)){stack.useNode(cached,match);if(verbose)console.log(base+this.stackID(stack)+` (via reuse of ${parser.getName(cached.type.id)})`);return true;}if(!(cached instanceof Tree)||cached.children.length==0||cached.positions[0]>0)break;let inner=cached.children[0];if(inner instanceof Tree&&cached.positions[0]==0)cached=inner;else break;}}let defaultReduce=parser.stateSlot(stack.state,4);if(defaultReduce>0){stack.reduce(defaultReduce);if(verbose)console.log(base+this.stackID(stack)+` (via always-reduce ${parser.getName(defaultReduce&65535)})`);return true;}if(stack.stack.length>=15000){while(stack.stack.length>9000&&stack.forceReduce()){}}let actions=this.tokens.getActions(stack);for(let i=0;istart)stacks.push(localStack);else split.push(localStack);}return false;}advanceFully(stack,newStacks){let pos=stack.pos;for(;;){if(!this.advanceStack(stack,null,null))return false;if(stack.pos>pos){pushStackDedup(stack,newStacks);return true;}}}runRecovery(stacks,tokens,newStacks){let finished=null,restarted=false;for(let i=0;i ":"";if(stack.deadEnd){if(restarted)continue;restarted=true;stack.restart();if(verbose)console.log(base+this.stackID(stack)+" (restarted)");let done=this.advanceFully(stack,newStacks);if(done)continue;}let force=stack.split(),forceBase=base;for(let j=0;force.forceReduce()&&j<10;j++){if(verbose)console.log(forceBase+this.stackID(force)+" (via force-reduce)");let done=this.advanceFully(force,newStacks);if(done)break;if(verbose)forceBase=this.stackID(force)+" -> ";}for(let _i248=0,_stack$recoverByInser=stack.recoverByInsert(token),_length248=_stack$recoverByInser.length;_i248<_length248;_i248++){let insert=_stack$recoverByInser[_i248];if(verbose)console.log(base+this.stackID(insert)+" (via recover-insert)");this.advanceFully(insert,newStacks);}if(this.stream.end>stack.pos){if(tokenEnd==stack.pos){tokenEnd++;token=0;}stack.recoverByDelete(token,tokenEnd);if(verbose)console.log(base+this.stackID(stack)+` (via recover-delete ${this.parser.getName(token)})`);pushStackDedup(stack,newStacks);}else if(!finished||finished.scorex;class ContextTracker{constructor(spec){this.start=spec.start;this.shift=spec.shift||id;this.reduce=spec.reduce||id;this.reuse=spec.reuse||id;this.hash=spec.hash||(()=>0);this.strict=spec.strict!==false;}}class LRParser extends Parser{constructor(spec){super();this.wrappers=[];if(spec.version!=14)throw new RangeError(`Parser version (${spec.version}) doesn't match runtime version (${14})`);let nodeNames=spec.nodeNames.split(" ");this.minRepeatTerm=nodeNames.length;for(let i=0;ispec.topRules[r][1]);let nodeProps=[];for(let i=0;i=0){setProp(next,prop,propSpec[i++]);}else{let value=propSpec[i+-next];for(let j=-next;j>0;j--)setProp(propSpec[i++],prop,value);i++;}}}this.nodeSet=new NodeSet(nodeNames.map((name,i)=>NodeType.define({name:i>=this.minRepeatTerm?undefined:name,id:i,props:nodeProps[i],top:topTerms.indexOf(i)>-1,error:i==0,skipped:spec.skippedNodes&&spec.skippedNodes.indexOf(i)>-1})));if(spec.propSources)this.nodeSet=this.nodeSet.extend(...spec.propSources);this.strict=false;this.bufferLength=DefaultBufferLength;let tokenArray=decodeArray(spec.tokenData);this.context=spec.context;this.specializerSpecs=spec.specialized||[];this.specialized=new Uint16Array(this.specializerSpecs.length);for(let i=0;itypeof value=="number"?new TokenGroup(tokenArray,value):value);this.topRules=spec.topRules;this.dialects=spec.dialects||{};this.dynamicPrecedences=spec.dynamicPrecedences||null;this.tokenPrecTable=spec.tokenPrec;this.termNames=spec.termNames||null;this.maxNode=this.nodeSet.types.length-1;this.dialect=this.parseDialect();this.top=this.topRules[Object.keys(this.topRules)[0]];}createParse(input,fragments,ranges){let parse=new Parse(this,input,fragments,ranges);for(let _i250=0,_this$wrappers=this.wrappers,_length250=_this$wrappers.length;_i250<_length250;_i250++){let w=_this$wrappers[_i250];parse=w(parse,input,fragments,ranges);}return parse;}getGoto(state,term,loose=false){let table=this.goto;if(term>=table[0])return-1;for(let pos=table[term+1];;){let groupTag=table[pos++],last=groupTag&1;let target=table[pos++];if(last&&loose)return target;for(let end=pos+(groupTag>>1);pos0;}validAction(state,action){return!!this.allActions(state,a=>a==action?true:null);}allActions(state,action){let deflt=this.stateSlot(state,4);let result=deflt?action(deflt):undefined;for(let i=this.stateSlot(state,1);result==null;i+=3){if(this.data[i]==65535){if(this.data[i+1]==1)i=pair(this.data,i+2);else break;}result=action(pair(this.data,i+1));}return result;}nextStates(state){let result=[];for(let i=this.stateSlot(state,1);;i+=3){if(this.data[i]==65535){if(this.data[i+1]==1)i=pair(this.data,i+2);else break;}if((this.data[i+2]&65536>>16)==0){let value=this.data[i+1];if(!result.some((v,i)=>i&1&&v==value))result.push(this.data[i],value);}}return result;}configure(config){let copy=Object.assign(Object.create(LRParser.prototype),this);if(config.props)copy.nodeSet=this.nodeSet.extend(...config.props);if(config.top){let info=this.topRules[config.top];if(!info)throw new RangeError(`Invalid top rule name ${config.top}`);copy.top=info;}if(config.tokenizers)copy.tokenizers=this.tokenizers.map(t=>{let found=config.tokenizers.find(r=>r.from==t);return found?found.to:t;});if(config.specializers){copy.specializers=this.specializers.slice();copy.specializerSpecs=this.specializerSpecs.map((s,i)=>{let found=config.specializers.find(r=>r.from==s.external);if(!found)return s;let spec=Object.assign(Object.assign({},s),{external:found.to});copy.specializers[i]=getSpecializer(spec);return spec;});}if(config.contextTracker)copy.context=config.contextTracker;if(config.dialect)copy.dialect=this.parseDialect(config.dialect);if(config.strict!=null)copy.strict=config.strict;if(config.wrap)copy.wrappers=copy.wrappers.concat(config.wrap);if(config.bufferLength!=null)copy.bufferLength=config.bufferLength;return copy;}hasWrappers(){return this.wrappers.length>0;}getName(term){return this.termNames?this.termNames[term]:String(term<=this.maxNode&&this.nodeSet.types[term].name||term);}get eofTerm(){return this.maxNode+1;}get topNode(){return this.nodeSet.types[this.top[1]];}dynamicPrecedence(term){let prec=this.dynamicPrecedences;return prec==null?0:prec[term]||0;}parseDialect(dialect){let values=Object.keys(this.dialects),flags=values.map(()=>false);if(dialect)for(let _i251=0,_dialect$split=dialect.split(" "),_length251=_dialect$split.length;_i251<_length251;_i251++){let part=_dialect$split[_i251];let id=values.indexOf(part);if(id>=0)flags[id]=true;}let disabled=null;for(let i=0;istopped)&&stack.p.parser.stateFlag(stack.state,2)&&(!best||best.scorespec.external(value,stack)<<1|mask;}return spec.get;}var _m29=Object.freeze({__proto__:null,ContextTracker:ContextTracker,ExternalTokenizer:ExternalTokenizer,InputStream:InputStream,LRParser:LRParser,LocalTokenGroup:LocalTokenGroup,Stack:Stack});const noSemi=302,incdec=1,incdecPrefix=2,insertSemi=303,spaces$1=305,newline$3=306,LineComment$2=3,BlockComment$1=4;const space$5=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288];const braceR$1=125,semicolon$1=59,slash$2=47,star=42,plus$1=43,minus=45;const trackNewline=new ContextTracker({start:false,shift(context,term){return term==LineComment$2||term==BlockComment$1||term==spaces$1?context:term==newline$3;},strict:false});const insertSemicolon=new ExternalTokenizer((input,stack)=>{let{next}=input;if((next==braceR$1||next==-1||stack.context)&&stack.canShift(insertSemi))input.acceptToken(insertSemi);},{contextual:true,fallback:true});const noSemicolon=new ExternalTokenizer((input,stack)=>{let{next}=input,after;if(space$5.indexOf(next)>-1)return;if(next==slash$2&&((after=input.peek(1))==slash$2||after==star))return;if(next!=braceR$1&&next!=semicolon$1&&next!=-1&&!stack.context&&stack.canShift(noSemi))input.acceptToken(noSemi);},{contextual:true});const incdecToken=new ExternalTokenizer((input,stack)=>{let{next}=input;if(next==plus$1||next==minus){input.advance();if(next==input.next){input.advance();let mayPostfix=!stack.context&&stack.canShift(incdec);input.acceptToken(mayPostfix?incdec:incdecPrefix);}}},{contextual:true});const jsHighlight=styleTags({"get set async static":tags$1.modifier,"for while do if else switch try catch finally return throw break continue default case":tags$1.controlKeyword,"in of await yield void typeof delete instanceof":tags$1.operatorKeyword,"let var const function class extends":tags$1.definitionKeyword,"import export from":tags$1.moduleKeyword,"with debugger as new":tags$1.keyword,TemplateString:tags$1.special(tags$1.string),super:tags$1.atom,BooleanLiteral:tags$1.bool,this:tags$1.self,null:tags$1.null,Star:tags$1.modifier,VariableName:tags$1.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":tags$1.function(tags$1.variableName),VariableDefinition:tags$1.definition(tags$1.variableName),Label:tags$1.labelName,PropertyName:tags$1.propertyName,PrivatePropertyName:tags$1.special(tags$1.propertyName),"CallExpression/MemberExpression/PropertyName":tags$1.function(tags$1.propertyName),"FunctionDeclaration/VariableDefinition":tags$1.function(tags$1.definition(tags$1.variableName)),"ClassDeclaration/VariableDefinition":tags$1.definition(tags$1.className),PropertyDefinition:tags$1.definition(tags$1.propertyName),PrivatePropertyDefinition:tags$1.definition(tags$1.special(tags$1.propertyName)),UpdateOp:tags$1.updateOperator,LineComment:tags$1.lineComment,BlockComment:tags$1.blockComment,Number:tags$1.number,String:tags$1.string,Escape:tags$1.escape,ArithOp:tags$1.arithmeticOperator,LogicOp:tags$1.logicOperator,BitOp:tags$1.bitwiseOperator,CompareOp:tags$1.compareOperator,RegExp:tags$1.regexp,Equals:tags$1.definitionOperator,Arrow:tags$1.function(tags$1.punctuation),": Spread":tags$1.punctuation,"( )":tags$1.paren,"[ ]":tags$1.squareBracket,"{ }":tags$1.brace,"InterpolationStart InterpolationEnd":tags$1.special(tags$1.brace),".":tags$1.derefOperator,", ;":tags$1.separator,"@":tags$1.meta,TypeName:tags$1.typeName,TypeDefinition:tags$1.definition(tags$1.typeName),"type enum interface implements namespace module declare":tags$1.definitionKeyword,"abstract global Privacy readonly override":tags$1.modifier,"is keyof unique infer":tags$1.operatorKeyword,JSXAttributeValue:tags$1.attributeValue,JSXText:tags$1.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":tags$1.angleBracket,"JSXIdentifier JSXNameSpacedName":tags$1.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":tags$1.attributeName,"JSXBuiltin/JSXIdentifier":tags$1.standard(tags$1.tagName)});const spec_identifier$7={__proto__:null,export:14,as:19,from:27,default:30,async:35,function:36,extends:46,this:50,true:58,false:58,null:70,void:74,typeof:78,super:96,new:130,delete:146,yield:155,await:159,class:164,public:221,private:221,protected:221,readonly:223,instanceof:242,satisfies:245,in:246,const:248,import:280,keyof:335,unique:339,infer:345,is:381,abstract:401,implements:403,type:405,let:408,var:410,interface:417,enum:421,namespace:427,module:429,declare:433,global:437,for:456,of:465,while:468,with:472,do:476,if:480,else:482,switch:486,case:492,try:498,catch:502,finally:506,return:510,throw:514,break:518,continue:522,debugger:526};const spec_word={__proto__:null,async:117,get:119,set:121,declare:181,public:183,private:183,protected:183,static:185,abstract:187,override:189,readonly:195,accessor:197,new:385};const spec_LessThan={__proto__:null,"<":137};const parser$h=LRParser.deserialize({version:14,states:"$6[O`QUOOO%QQUOOO'TQW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1r,oQ5e1jQ7m5fT:x&y+fT#]W%vS#[W%vS'u#S'}S'z#V+eS,t&y+fT-h't-mT'O!c%wQ$hfR)j$mT)_$h)`R3Z.kT*O$u*QR*W$xQ/}*zQ2e.OQ4s0wQ5{2iQ7X4vQ7x5zQ8e7WQ8w7wQ9W8gQ9`8yQ9e9XR9h9alpOXr!X#`%]&d&f&g&i,],b1b1eQ&^!TR,Q&ZV%z|},ZR0q+qR,P&XQ%szR+c%tR+X%nT&b!U&eT&c!U&eT1d,b1e",nodeNames:"⚠ ArithOp ArithOp LineComment BlockComment Script ExportDeclaration export Star as VariableName String Escape from ; default FunctionDeclaration async function VariableDefinition > TypeParamList TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . ?. PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewExpression new TypeArgList CompareOp < ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies in const CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXStartTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast ArrowFunction TypeParamList SequenceExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:364,context:trackNewline,nodeProps:[["group",-26,6,14,16,62,199,203,206,207,209,212,215,225,227,233,235,237,239,242,248,254,256,258,260,262,264,265,"Statement",-32,10,11,25,28,29,35,45,48,49,51,56,64,72,76,78,80,81,103,104,113,114,131,134,136,137,138,139,141,142,162,163,165,"Expression",-23,24,26,30,34,36,38,166,168,170,171,173,174,175,177,178,179,181,182,183,193,195,197,198,"Type",-3,84,96,102,"ClassItem"],["openedBy",31,"InterpolationStart",50,"[",54,"{",69,"(",143,"JSXStartTag",155,"JSXStartTag JSXStartCloseTag"],["closedBy",33,"InterpolationEnd",44,"]",55,"}",70,")",144,"JSXSelfCloseEndTag JSXEndTag",160,"JSXEndTag"]],propSources:[jsHighlight],skippedNodes:[0,3,4,268],repeatNodeCount:33,tokenData:"$>y(CSR!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tu>PuvBavwDxwxGgxyMvyz! Qz{!![{|!%O|}!&]}!O!%O!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":1},specialized:[{term:312,get:value=>spec_identifier$7[value]||-1},{term:328,get:value=>spec_word[value]||-1},{term:67,get:value=>spec_LessThan[value]||-1}],tokenPrec:12712});const snippets$1=[snippetCompletion("function ${name}(${params}) {\n\t${}\n}",{label:"function",detail:"definition",type:"keyword"}),snippetCompletion("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n\t${}\n}",{label:"for",detail:"loop",type:"keyword"}),snippetCompletion("for (let ${name} of ${collection}) {\n\t${}\n}",{label:"for",detail:"of loop",type:"keyword"}),snippetCompletion("do {\n\t${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),snippetCompletion("while (${}) {\n\t${}\n}",{label:"while",detail:"loop",type:"keyword"}),snippetCompletion("try {\n\t${}\n} catch (${error}) {\n\t${}\n}",{label:"try",detail:"/ catch block",type:"keyword"}),snippetCompletion("if (${}) {\n\t${}\n}",{label:"if",detail:"block",type:"keyword"}),snippetCompletion("if (${}) {\n\t${}\n} else {\n\t${}\n}",{label:"if",detail:"/ else block",type:"keyword"}),snippetCompletion("class ${name} {\n\tconstructor(${params}) {\n\t\t${}\n\t}\n}",{label:"class",detail:"definition",type:"keyword"}),snippetCompletion("import {${names}} from \"${module}\"\n${}",{label:"import",detail:"named",type:"keyword"}),snippetCompletion("import ${name} from \"${module}\"\n${}",{label:"import",detail:"default",type:"keyword"})];const typescriptSnippets=snippets$1.concat([snippetCompletion("interface ${name} {\n\t${}\n}",{label:"interface",detail:"definition",type:"keyword"}),snippetCompletion("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),snippetCompletion("enum ${name} {\n\t${}\n}",{label:"enum",detail:"definition",type:"keyword"})]);const cache$1=new NodeWeakMap();const ScopeNodes$1=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function defID$1(type){return(node,def)=>{let id=node.node.getChild("VariableDefinition");if(id)def(id,type);return true;};}const functionContext=["FunctionDeclaration"];const gatherCompletions$1={FunctionDeclaration:defID$1("function"),ClassDeclaration:defID$1("class"),ClassExpression:()=>true,EnumDeclaration:defID$1("constant"),TypeAliasDeclaration:defID$1("type"),NamespaceDeclaration:defID$1("namespace"),VariableDefinition(node,def){if(!node.matchContext(functionContext))def(node,"variable");},TypeDefinition(node,def){def(node,"type");},__proto__:null};function getScope$1(doc,node){let cached=cache$1.get(node);if(cached)return cached;let completions=[],top=true;function def(node,type){let name=doc.sliceString(node.from,node.to);completions.push({label:name,type});}node.cursor(IterMode.IncludeAnonymous).iterate(node=>{if(top){top=false;}else if(node.name){let gather=gatherCompletions$1[node.name];if(gather&&gather(node,def)||ScopeNodes$1.has(node.name))return false;}else if(node.to-node.from>8192){for(let _i253=0,_getScope$=getScope$1(doc,node.node),_length253=_getScope$.length;_i253<_length253;_i253++){let c=_getScope$[_i253];completions.push(c);}return false;}});cache$1.set(node,completions);return completions;}const Identifier$3=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/;const dontComplete$1=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName",".","?."];function localCompletionSource$1(context){let inner=syntaxTree(context.state).resolveInner(context.pos,-1);if(dontComplete$1.indexOf(inner.name)>-1)return null;let isWord=inner.name=="VariableName"||inner.to-inner.from<20&&Identifier$3.test(context.state.sliceDoc(inner.from,inner.to));if(!isWord&&!context.explicit)return null;let options=[];for(let pos=inner;pos;pos=pos.parent){if(ScopeNodes$1.has(pos.name))options=options.concat(getScope$1(context.state.doc,pos));}return{options,from:isWord?inner.from:context.pos,validFor:Identifier$3};}function pathFor$1(read,member,name){var _a;let path=[];for(;;){let obj=member.firstChild,prop;if((obj===null||obj===void 0?void 0:obj.name)=="VariableName"){path.push(read(obj));return{path:path.reverse(),name};}else if((obj===null||obj===void 0?void 0:obj.name)=="MemberExpression"&&((_a=prop=obj.lastChild)===null||_a===void 0?void 0:_a.name)=="PropertyName"){path.push(read(prop));member=obj;}else{return null;}}}function completionPath(context){let read=node=>context.state.doc.sliceString(node.from,node.to);let inner=syntaxTree(context.state).resolveInner(context.pos,-1);if(inner.name=="PropertyName"){return pathFor$1(read,inner.parent,read(inner));}else if((inner.name=="."||inner.name=="?.")&&inner.parent.name=="MemberExpression"){return pathFor$1(read,inner.parent,"");}else if(dontComplete$1.indexOf(inner.name)>-1){return null;}else if(inner.name=="VariableName"||inner.to-inner.from<20&&Identifier$3.test(read(inner))){return{path:[],name:read(inner)};}else if(inner.name=="MemberExpression"){return pathFor$1(read,inner,"");}else{return context.explicit?{path:[],name:""}:null;}}function enumeratePropertyCompletions(obj,top){let options=[],seen=new Set();for(let depth=0;;depth++){for(let _i254=0,_ref4=(Object.getOwnPropertyNames||Object.keys)(obj),_length254=_ref4.length;_i254<_length254;_i254++){let name=_ref4[_i254];if(!/^[a-zA-Z_$\xaa-\uffdc][\w$\xaa-\uffdc]*$/.test(name)||seen.has(name))continue;seen.add(name);let value;try{value=obj[name];}catch(_){continue;}options.push({label:name,type:typeof value=="function"?/^[A-Z]/.test(name)?"class":top?"function":"method":top?"variable":"property",boost:-depth});}let next=Object.getPrototypeOf(obj);if(!next)return options;obj=next;}}function scopeCompletionSource(scope){let cache=new Map();return context=>{let path=completionPath(context);if(!path)return null;let target=scope;for(let _i255=0,_path$path=path.path,_length255=_path$path.length;_i255<_length255;_i255++){let step=_path$path[_i255];target=target[step];if(!target)return null;}let options=cache.get(target);if(!options)cache.set(target,options=enumeratePropertyCompletions(target,!path.path.length));return{from:context.pos-path.name.length,options,validFor:Identifier$3};};}const javascriptLanguage=LRLanguage.define({name:"javascript",parser:parser$h.configure({props:[indentNodeProp.add({IfStatement:continuedIndent({except:/^\s*({|else\b)/}),TryStatement:continuedIndent({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:flatIndent,SwitchBody:context=>{let after=context.textAfter,closed=/^\s*\}/.test(after),isCase=/^\s*(case|default)\b/.test(after);return context.baseIndent+(closed?0:isCase?1:2)*context.unit;},Block:delimitedIndent({closing:"}"}),ArrowFunction:cx=>cx.baseIndent+cx.unit,"TemplateString BlockComment":()=>null,"Statement Property":continuedIndent({except:/^{/}),JSXElement(context){let closed=/^\s*<\//.test(context.textAfter);return context.lineIndent(context.node.from)+(closed?0:context.unit);},JSXEscape(context){let closed=/\s*\}/.test(context.textAfter);return context.lineIndent(context.node.from)+(closed?0:context.unit);},"JSXOpenTag JSXSelfClosingTag"(context){return context.column(context.node.from)+context.unit;}}),foldNodeProp.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":foldInside,BlockComment(tree){return{from:tree.from+2,to:tree.to-2};}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}});const jsxSublanguage={test:node=>/^JSX/.test(node.name),facet:defineLanguageFacet({commentTokens:{block:{open:"{/*",close:"*/}"}}})};const typescriptLanguage=javascriptLanguage.configure({dialect:"ts"},"typescript");const jsxLanguage=javascriptLanguage.configure({dialect:"jsx",props:[sublanguageProp.add(n=>n.isTop?[jsxSublanguage]:undefined)]});const tsxLanguage=javascriptLanguage.configure({dialect:"jsx ts",props:[sublanguageProp.add(n=>n.isTop?[jsxSublanguage]:undefined)]},"typescript");let kwCompletion=name=>({label:name,type:"keyword"});const keywords$2="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(kwCompletion);const typescriptKeywords=keywords$2.concat(["declare","implements","private","protected","public"].map(kwCompletion));function javascript(config={}){let lang=config.jsx?config.typescript?tsxLanguage:jsxLanguage:config.typescript?typescriptLanguage:javascriptLanguage;let completions=config.typescript?typescriptSnippets.concat(typescriptKeywords):snippets$1.concat(keywords$2);return new LanguageSupport(lang,[javascriptLanguage.data.of({autocomplete:ifNotIn(dontComplete$1,completeFromList(completions))}),javascriptLanguage.data.of({autocomplete:localCompletionSource$1}),config.jsx?autoCloseTags$1:[]]);}function findOpenTag(node){for(;;){if(node.name=="JSXOpenTag"||node.name=="JSXSelfClosingTag"||node.name=="JSXFragmentTag")return node;if(node.name=="JSXEscape"||!node.parent)return null;node=node.parent;}}function elementName$2(doc,tree,max=doc.length){for(let ch=tree===null||tree===void 0?void 0:tree.firstChild;ch;ch=ch.nextSibling){if(ch.name=="JSXIdentifier"||ch.name=="JSXBuiltin"||ch.name=="JSXNamespacedName"||ch.name=="JSXMemberExpression")return doc.sliceString(ch.from,Math.min(ch.to,max));}return"";}function isEndTag(node){return node&&(node.name=="JSXEndTag"||node.name=="JSXSelfCloseEndTag");}const android=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent);const autoCloseTags$1=EditorView.inputHandler.of((view,from,to,text)=>{if((android?view.composing:view.compositionStarted)||view.state.readOnly||from!=to||text!=">"&&text!="/"||!javascriptLanguage.isActiveAt(view.state,from,-1))return false;let{state}=view;let changes=state.changeByRange(range=>{var _a;let{head}=range,around=syntaxTree(state).resolveInner(head,-1),name;if(around.name=="JSXStartTag")around=around.parent;if(around.name=="JSXAttributeValue"&&around.to>head);else if(text==">"&&around.name=="JSXFragmentTag"){return{range:EditorSelection.cursor(head+1),changes:{from:head,insert:`>`}};}else if(text=="/"&&around.name=="JSXFragmentTag"){let empty=around.parent,base=empty===null||empty===void 0?void 0:empty.parent;if(empty.from==head-1&&((_a=base.lastChild)===null||_a===void 0?void 0:_a.name)!="JSXEndTag"&&(name=elementName$2(state.doc,base===null||base===void 0?void 0:base.firstChild,head))){let insert=`/${name}>`;return{range:EditorSelection.cursor(head+insert.length),changes:{from:head,insert}};}}else if(text==">"){let openTag=findOpenTag(around);if(openTag&&!isEndTag(openTag.lastChild)&&state.sliceDoc(head,head+2)!="`}};}return{range};});if(changes.changes.empty)return false;view.dispatch(changes,{userEvent:"input.type",scrollIntoView:true});return true;});function esLint(eslint,config){if(!config){config={parserOptions:{ecmaVersion:2019,sourceType:"module"},env:{browser:true,node:true,es6:true,es2015:true,es2017:true,es2020:true},rules:{}};eslint.getRules().forEach((desc,name)=>{if(desc.meta.docs.recommended)config.rules[name]=2;});}return view=>{let{state}=view,found=[];for(let _i256=0,_javascriptLanguage$f=javascriptLanguage.findRegions(state),_length256=_javascriptLanguage$f.length;_i256<_length256;_i256++){let{from,to}=_javascriptLanguage$f[_i256];let fromLine=state.doc.lineAt(from),offset={line:fromLine.number-1,col:from-fromLine.from,pos:from};for(let _i257=0,_eslint$verify=eslint.verify(state.sliceDoc(from,to),config),_length257=_eslint$verify.length;_i257<_length257;_i257++){let d=_eslint$verify[_i257];found.push(translateDiagnostic(d,state.doc,offset));}}return found;};}function mapPos$1(line,col,doc,offset){return doc.line(line+offset.line).from+col+(line==1?offset.col-1:-1);}function translateDiagnostic(input,doc,offset){let start=mapPos$1(input.line,input.column,doc,offset);let result={from:start,to:input.endLine!=null&&input.endColumn!=1?mapPos$1(input.endLine,input.endColumn,doc,offset):start,message:input.message,source:input.ruleId?"eslint:"+input.ruleId:"eslint",severity:input.severity==1?"warning":"error"};if(input.fix){let{range,text}=input.fix,from=range[0]+offset.pos-start,to=range[1]+offset.pos-start;result.actions=[{name:"fix",apply(view,start){view.dispatch({changes:{from:start+from,to:start+to,insert:text},scrollIntoView:true});}}];}return result;}var _m9=Object.freeze({__proto__:null,autoCloseTags:autoCloseTags$1,completionPath:completionPath,esLint:esLint,javascript:javascript,javascriptLanguage:javascriptLanguage,jsxLanguage:jsxLanguage,localCompletionSource:localCompletionSource$1,scopeCompletionSource:scopeCompletionSource,snippets:snippets$1,tsxLanguage:tsxLanguage,typescriptLanguage:typescriptLanguage,typescriptSnippets:typescriptSnippets});const javaHighlighting=styleTags({null:tags$1.null,instanceof:tags$1.operatorKeyword,this:tags$1.self,"new super assert open to with void":tags$1.keyword,"class interface extends implements enum var":tags$1.definitionKeyword,"module package import":tags$1.moduleKeyword,"switch while for if else case default do break continue return try catch finally throw":tags$1.controlKeyword,["requires exports opens uses provides public private protected static transitive abstract final "+"strictfp synchronized native transient volatile throws"]:tags$1.modifier,IntegerLiteral:tags$1.integer,FloatingPointLiteral:tags$1.float,"StringLiteral TextBlock":tags$1.string,CharacterLiteral:tags$1.character,LineComment:tags$1.lineComment,BlockComment:tags$1.blockComment,BooleanLiteral:tags$1.bool,PrimitiveType:tags$1.standard(tags$1.typeName),TypeName:tags$1.typeName,Identifier:tags$1.variableName,"MethodName/Identifier":tags$1.function(tags$1.variableName),Definition:tags$1.definition(tags$1.variableName),ArithOp:tags$1.arithmeticOperator,LogicOp:tags$1.logicOperator,BitOp:tags$1.bitwiseOperator,CompareOp:tags$1.compareOperator,AssignOp:tags$1.definitionOperator,UpdateOp:tags$1.updateOperator,Asterisk:tags$1.punctuation,Label:tags$1.labelName,"( )":tags$1.paren,"[ ]":tags$1.squareBracket,"{ }":tags$1.brace,".":tags$1.derefOperator,", ;":tags$1.separator});const spec_identifier$6={__proto__:null,true:34,false:34,null:42,void:46,byte:48,short:48,int:48,long:48,char:48,float:48,double:48,boolean:48,extends:62,super:64,class:76,this:78,new:84,public:100,protected:102,private:104,abstract:106,static:108,final:110,strictfp:112,default:114,synchronized:116,native:118,transient:120,volatile:122,throws:150,implements:160,interface:166,enum:176,instanceof:236,open:265,module:267,requires:272,transitive:274,exports:276,to:278,opens:280,uses:282,provides:284,with:286,package:290,import:294,if:306,else:308,while:312,for:316,var:323,assert:330,switch:334,case:340,do:344,break:348,continue:352,return:356,throw:362,try:366,catch:370,finally:378};const parser$g=LRParser.deserialize({version:14,states:"#!hQ]QPOOO&tQQO'#H[O(xQQO'#CbOOQO'#Cb'#CbO)PQPO'#CaO)XOSO'#CpOOQO'#Ha'#HaOOQO'#Cu'#CuO*tQPO'#D_O+_QQO'#HkOOQO'#Hk'#HkO-sQQO'#HfO-zQQO'#HfOOQO'#Hf'#HfOOQO'#He'#HeO0OQPO'#DUO0]QPO'#GlO3TQPO'#D_O3[QPO'#DzO)PQPO'#E[O3}QPO'#E[OOQO'#DV'#DVO5]QQO'#H_O7dQQO'#EeO7k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]V}R&WSOY%QYZ%lZr%Qrs%qs;'S%Q;'S;=`&s<%lO%Q_# {Z&|X#cQ&WSOY%QYZ%lZr%Qrs%qs!_%Q!_!`6e!`#p%Q#p#q#!n#q;'S%Q;'S;=`&s<%lO%QU#!uV#dQ&WSOY%QYZ%lZr%Qrs%qs;'S%Q;'S;=`&s<%lO%QV##cV|R&WSOY%QYZ%lZr%Qrs%qs;'S%Q;'S;=`&s<%lO%QT#$PV#tP&WSOY%QYZ%lZr%Qrs%qs;'S%Q;'S;=`&s<%lO%Q",tokenizers:[0,1,2,3],topRules:{"Program":[0,3]},dynamicPrecedences:{"27":1,"230":-1,"241":-1},specialized:[{term:229,get:value=>spec_identifier$6[value]||-1}],tokenPrec:7067});const javaLanguage=LRLanguage.define({name:"java",parser:parser$g.configure({props:[indentNodeProp.add({IfStatement:continuedIndent({except:/^\s*({|else\b)/}),TryStatement:continuedIndent({except:/^\s*({|catch|finally)\b/}),LabeledStatement:flatIndent,SwitchBlock:context=>{let after=context.textAfter,closed=/^\s*\}/.test(after),isCase=/^\s*(case|default)\b/.test(after);return context.baseIndent+(closed?0:isCase?1:2)*context.unit;},Block:delimitedIndent({closing:"}"}),BlockComment:()=>null,Statement:continuedIndent({except:/^{/})}),foldNodeProp.add({["Block SwitchBlock ClassBody ElementValueArrayInitializer ModuleBody EnumBody "+"ConstructorBody InterfaceBody ArrayInitializer"]:foldInside,BlockComment(tree){return{from:tree.from+2,to:tree.to-2};}})]}),languageData:{commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\})$/}});function java(){return new LanguageSupport(javaLanguage);}var _m10=Object.freeze({__proto__:null,java:java,javaLanguage:javaLanguage});const jsonHighlighting=styleTags({String:tags$1.string,Number:tags$1.number,"True False":tags$1.bool,PropertyName:tags$1.propertyName,Null:tags$1.null,",":tags$1.separator,"[ ]":tags$1.squareBracket,"{ }":tags$1.brace});const parser$f=LRParser.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#CjOOQO'#Cp'#CpQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CrOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59U,59UO!iQPO,59UOVQPO,59QOqQPO'#CkO!nQPO,59^OOQO1G.k1G.kOVQPO'#ClO!vQPO,59aOOQO1G.p1G.pOOQO1G.l1G.lOOQO,59V,59VOOQO-E6i-E6iOOQO,59W,59WOOQO-E6j-E6j",stateData:"#O~OcOS~OQSORSOSSOTSOWQO]ROePO~OVXOeUO~O[[O~PVOg^O~Oh_OVfX~OVaO~OhbO[iX~O[dO~Oh_OVfa~OhbO[ia~O",goto:"!kjPPPPPPkPPkqwPPk{!RPPP!XP!ePP!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName ] [ Array",maxTerm:25,nodeProps:[["openedBy",7,"{",12,"["],["closedBy",8,"}",13,"]"]],propSources:[jsonHighlighting],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oc~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Oe~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zOh~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yOg~~'OO]~~'TO[~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{"JsonText":[0,1]},tokenPrec:0});const jsonParseLinter=()=>view=>{try{JSON.parse(view.state.doc.toString());}catch(e){if(!(e instanceof SyntaxError))throw e;const pos=getErrorPosition(e,view.state.doc);return[{from:pos,message:e.message,severity:'error',to:pos}];}return[];};function getErrorPosition(error,doc){let m;if(m=error.message.match(/at position (\d+)/))return Math.min(+m[1],doc.length);if(m=error.message.match(/at line (\d+) column (\d+)/))return Math.min(doc.line(+m[1]).from+ +m[2]-1,doc.length);return 0;}const jsonLanguage=LRLanguage.define({name:"json",parser:parser$f.configure({props:[indentNodeProp.add({Object:continuedIndent({except:/^\s*\}/}),Array:continuedIndent({except:/^\s*\]/})}),foldNodeProp.add({"Object Array":foldInside})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function json(){return new LanguageSupport(jsonLanguage);}var _m11=Object.freeze({__proto__:null,json:json,jsonLanguage:jsonLanguage,jsonParseLinter:jsonParseLinter});const RawString$1=1,templateArgsEndFallback=2,MacroName=3;const R=82,L=76,u=117,U=85,a=97,z=122,A=65,Z=90,Underscore=95,Zero$1=48,Quote$1=34,ParenL$2=40,ParenR$1=41,Space$1=32,GreaterThan$1=62;const rawString=new ExternalTokenizer(input=>{if(input.next==L||input.next==U){input.advance();}else if(input.next==u){input.advance();if(input.next==Zero$1+8)input.advance();}if(input.next!=R)return;input.advance();if(input.next!=Quote$1)return;input.advance();let marker="";while(input.next!=ParenL$2){if(input.next==Space$1||input.next<=13||input.next==ParenR$1)return;marker+=String.fromCharCode(input.next);input.advance();}input.advance();for(;;){if(input.next<0)return input.acceptToken(RawString$1);if(input.next==ParenR$1){let match=true;for(let i=0;match&&i{if(input.next==GreaterThan$1){if(input.peek(1)==GreaterThan$1)input.acceptToken(templateArgsEndFallback,1);}else{let sawLetter=false,i=0;for(;;i++){if(input.next>=A&&input.next<=Z)sawLetter=true;else if(input.next>=a&&input.next<=z)return;else if(input.next!=Underscore&&!(input.next>=Zero$1&&input.next<=Zero$1+9))break;input.advance();}if(sawLetter&&i>1)input.acceptToken(MacroName);}},{extend:true});const cppHighlighting=styleTags({"typedef struct union enum class typename decltype auto template operator friend noexcept namespace using requires concept import export module __attribute__ __declspec __based":tags$1.definitionKeyword,"extern MsCallModifier MsPointerModifier extern static register thread_local inline const volatile restrict _Atomic mutable constexpr constinit consteval virtual explicit VirtualSpecifier Access":tags$1.modifier,"if else switch for while do case default return break continue goto throw try catch":tags$1.controlKeyword,"co_return co_yield co_await":tags$1.controlKeyword,"new sizeof delete static_assert":tags$1.operatorKeyword,"NULL nullptr":tags$1.null,this:tags$1.self,"True False":tags$1.bool,"TypeSize PrimitiveType":tags$1.standard(tags$1.typeName),TypeIdentifier:tags$1.typeName,FieldIdentifier:tags$1.propertyName,"CallExpression/FieldExpression/FieldIdentifier":tags$1.function(tags$1.propertyName),"ModuleName/Identifier":tags$1.namespace,"PartitionName":tags$1.labelName,StatementIdentifier:tags$1.labelName,"Identifier DestructorName":tags$1.variableName,"CallExpression/Identifier":tags$1.function(tags$1.variableName),"CallExpression/ScopedIdentifier/Identifier":tags$1.function(tags$1.variableName),"FunctionDeclarator/Identifier FunctionDeclarator/DestructorName":tags$1.function(tags$1.definition(tags$1.variableName)),NamespaceIdentifier:tags$1.namespace,OperatorName:tags$1.operator,ArithOp:tags$1.arithmeticOperator,LogicOp:tags$1.logicOperator,BitOp:tags$1.bitwiseOperator,CompareOp:tags$1.compareOperator,AssignOp:tags$1.definitionOperator,UpdateOp:tags$1.updateOperator,LineComment:tags$1.lineComment,BlockComment:tags$1.blockComment,Number:tags$1.number,String:tags$1.string,"RawString SystemLibString":tags$1.special(tags$1.string),CharLiteral:tags$1.character,EscapeSequence:tags$1.escape,"UserDefinedLiteral/Identifier":tags$1.literal,PreProcArg:tags$1.meta,"PreprocDirectiveName #include #ifdef #ifndef #if #define #else #endif #elif":tags$1.processingInstruction,MacroName:tags$1.special(tags$1.name),"( )":tags$1.paren,"[ ]":tags$1.squareBracket,"{ }":tags$1.brace,"< >":tags$1.angleBracket,". ->":tags$1.derefOperator,", ;":tags$1.separator});const spec_identifier$5={__proto__:null,bool:34,char:34,int:34,float:34,double:34,void:34,size_t:34,ssize_t:34,intptr_t:34,uintptr_t:34,charptr_t:34,int8_t:34,int16_t:34,int32_t:34,int64_t:34,uint8_t:34,uint16_t:34,uint32_t:34,uint64_t:34,char8_t:34,char16_t:34,char32_t:34,char64_t:34,const:68,volatile:70,restrict:72,_Atomic:74,mutable:76,constexpr:78,constinit:80,consteval:82,struct:86,__declspec:90,final:148,override:148,public:152,private:152,protected:152,virtual:154,extern:160,static:162,register:164,inline:166,thread_local:168,__attribute__:172,__based:178,__restrict:180,__uptr:180,__sptr:180,_unaligned:180,__unaligned:180,noexcept:194,requires:198,TRUE:786,true:786,FALSE:788,false:788,typename:218,class:220,template:234,throw:248,__cdecl:256,__clrcall:256,__stdcall:256,__fastcall:256,__thiscall:256,__vectorcall:256,try:260,catch:264,export:284,import:288,case:298,default:300,if:310,else:316,switch:320,do:324,while:326,for:332,return:336,break:340,continue:344,goto:348,co_return:352,co_yield:356,using:364,typedef:368,namespace:382,new:400,delete:402,co_await:404,concept:408,enum:412,static_assert:416,friend:424,union:426,explicit:432,operator:446,module:458,signed:520,unsigned:520,long:520,short:520,decltype:530,auto:532,sizeof:568,NULL:574,nullptr:588,this:590};const spec_={__proto__:null,"<":131};const spec_templateArgsEnd={__proto__:null,">":135};const spec_scopedIdentifier={__proto__:null,operator:390,new:578,delete:584};const parser$e=LRParser.deserialize({version:14,states:"$;fQ!QQVOOP'gOUOOO(XOWO'#CdO,RQUO'#CgO,]QUO'#Fk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o9]9^:Vl)Q#k.j3w3{4O4P7g7i7j7l7o9]9^:VT+R%y0v`UOwx!g&S'e*r-fW$`[e$e(c#l$p_!f!u!}#R#S#T#U#V#Z$S$T$l%U&U&Y&c&m'_(O(Q(V(_(h)k)q+]+b+c+u+z,Y,l,{-R-r-w.Z.[.b.c.g.t.x1W1[1i1n1p2o3`3a3b3t3x5n6R6T7`8_![%cg$g%d%i&s*Z*u+^,m,w-`0}1R2b;[;];^;e;f;s;t;u;v;z;{;}<[<]<^Y%snp%w-s.il(}#k.j3w3{4O4P7g7i7j7l7o9]9^:VS;i'u-zU;j(R.p.r&| MacroName LineComment BlockComment PreprocDirective #include String EscapeSequence SystemLibString Identifier ArgumentList ( ConditionalExpression AssignmentExpression CallExpression PrimitiveType FieldExpression FieldIdentifier DestructorName TemplateMethod ScopedFieldIdentifier NamespaceIdentifier TemplateType TypeIdentifier ScopedTypeIdentifier ScopedNamespaceIdentifier :: NamespaceIdentifier TypeIdentifier TemplateArgumentList < TypeDescriptor const volatile restrict _Atomic mutable constexpr constinit consteval StructSpecifier struct MsDeclspecModifier __declspec ) Attribute AttributeName Identifier AttributeArgs { } [ ] UpdateOp ArithOp ArithOp ArithOp LogicOp BitOp BitOp BitOp CompareOp CompareOp CompareOp > CompareOp BitOp UpdateOp , Number CharLiteral AttributeArgs VirtualSpecifier BaseClassClause Access virtual FieldDeclarationList FieldDeclaration extern static register inline thread_local AttributeSpecifier __attribute__ PointerDeclarator MsBasedModifier __based MsPointerModifier FunctionDeclarator ParameterList ParameterDeclaration PointerDeclarator FunctionDeclarator Noexcept noexcept RequiresClause requires True False ParenthesizedExpression CommaExpression LambdaExpression LambdaCaptureSpecifier TemplateParameterList OptionalParameterDeclaration TypeParameterDeclaration typename class VariadicParameterDeclaration VariadicDeclarator ReferenceDeclarator OptionalTypeParameterDeclaration VariadicTypeParameterDeclaration TemplateTemplateParameterDeclaration template AbstractFunctionDeclarator AbstractPointerDeclarator AbstractArrayDeclarator AbstractParenthesizedDeclarator AbstractReferenceDeclarator ThrowSpecifier throw TrailingReturnType CompoundStatement FunctionDefinition MsCallModifier TryStatement try CatchClause catch LinkageSpecification Declaration InitDeclarator InitializerList InitializerPair SubscriptDesignator FieldDesignator DeclarationList ExportDeclaration export ImportDeclaration import ModuleName PartitionName HeaderName CaseStatement case default LabeledStatement StatementIdentifier ExpressionStatement IfStatement if ConditionClause Declaration else SwitchStatement switch DoStatement do while WhileStatement ForStatement for ReturnStatement return BreakStatement break ContinueStatement continue GotoStatement goto CoReturnStatement co_return CoYieldStatement co_yield AttributeStatement ForRangeLoop AliasDeclaration using TypeDefinition typedef PointerDeclarator FunctionDeclarator ArrayDeclarator ParenthesizedDeclarator ThrowStatement NamespaceDefinition namespace ScopedIdentifier Identifier OperatorName operator ArithOp BitOp CompareOp LogicOp new delete co_await ConceptDefinition concept UsingDeclaration enum StaticAssertDeclaration static_assert ConcatenatedString TemplateDeclaration FriendDeclaration friend union FunctionDefinition ExplicitFunctionSpecifier explicit FieldInitializerList FieldInitializer DefaultMethodClause DeleteMethodClause FunctionDefinition OperatorCast operator TemplateInstantiation FunctionDefinition FunctionDefinition Declaration ModuleDeclaration module RequiresExpression RequirementList SimpleRequirement TypeRequirement CompoundRequirement ReturnTypeRequirement ConstraintConjuction LogicOp ConstraintDisjunction LogicOp ArrayDeclarator ParenthesizedDeclarator ReferenceDeclarator TemplateFunction OperatorName StructuredBindingDeclarator ArrayDeclarator ParenthesizedDeclarator ReferenceDeclarator BitfieldClause FunctionDefinition FunctionDefinition Declaration FunctionDefinition Declaration AccessSpecifier UnionSpecifier ClassSpecifier EnumSpecifier SizedTypeSpecifier TypeSize EnumeratorList Enumerator DependentType Decltype decltype auto PlaceholderTypeSpecifier ParameterPackExpansion ParameterPackExpansion FieldIdentifier PointerExpression SubscriptExpression BinaryExpression ArithOp LogicOp LogicOp BitOp UnaryExpression LogicOp BitOp UpdateExpression CastExpression SizeofExpression sizeof CoAwaitExpression CompoundLiteralExpression NULL NewExpression new NewDeclarator DeleteExpression delete ParameterPackExpansion nullptr this UserDefinedLiteral ParamPack #define PreprocArg #if #ifdef #ifndef #else #endif #elif PreprocDirectiveName Macro Program",maxTerm:426,nodeProps:[["group",-35,1,8,11,14,15,16,18,71,72,100,101,102,104,192,209,230,243,244,271,272,273,278,281,282,283,285,286,287,288,291,293,294,295,296,297,"Expression",-13,17,24,25,26,42,256,257,258,259,263,264,266,267,"Type",-19,126,129,148,151,153,154,159,161,164,165,167,169,171,173,175,177,179,180,189,"Statement"]],propSources:[cppHighlighting],skippedNodes:[0,3,4,5,6,7,10,298,299,300,301,302,303,304,305,306,307,348,349],repeatNodeCount:41,tokenData:"&*r7ZR!UOX$eXY({YZ.gZ]$e]^+P^p$epq({qr.}rs0}st2ktu$euv!7dvw!9bwx!;exy!O{|!?R|}!AV}!O!BQ!O!P!DX!P!Q#+y!Q!R#Az!R![$(x![!]$Ag!]!^$Cc!^!_$D^!_!`%1W!`!a%2X!a!b%5_!b!c$e!c!n%6Y!n!o%7q!o!w%6Y!w!x%7q!x!}%6Y!}#O%:n#O#P%u#Y#]4Y#]#^NZ#^#o4Y#o;'S$e;'S;=`(u<%lO$e4e4eb)[W(qQ'g&j'n.oOY$eZr$ers%^sw$ewx(Ox!Q$e!Q![4Y![!c$e!c!}4Y!}#O$e#O#P&f#P#R$e#R#S4Y#S#T$e#T#o4Y#o;'S$e;'S;=`(u<%lO$e4e5xd)[W(qQ'g&j'n.oOY$eZr$ers%^sw$ewx(Ox!Q$e!Q![4Y![!c$e!c!}4Y!}#O$e#O#P&f#P#R$e#R#S4Y#S#T$e#T#X4Y#X#Y7W#Y#o4Y#o;'S$e;'S;=`(u<%lO$e4e7cd)[W(qQ'g&j'n.oOY$eZr$ers%^sw$ewx(Ox!Q$e!Q![4Y![!c$e!c!}4Y!}#O$e#O#P&f#P#R$e#R#S4Y#S#T$e#T#Y4Y#Y#Z8q#Z#o4Y#o;'S$e;'S;=`(u<%lO$e4e8|d)[W(qQ'g&j'n.oOY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[W(zS(qQ!R,f(s%y'g&jOY$eZr$ers%9Ysw$ewx%9{x!Q$e!Q!Y%6Y!Y!Z%7q!Z![%6Y![!c$e!c!}%6Y!}#O$e#O#P&f#P#R$e#R#S%6Y#S#T$e#T#o%6Y#o;'S$e;'S;=`(u<%lO$e2]&!pY!T,g)[W(qQ'g&jOY$eZr$ers%^sw$ewx(Ox#O$e#O#P&f#P;'S$e;'S;=`(u<%lO$e3o&#m^)[W(qQ%]!b'g&j!^,gOY$eZr$ers%^sw$ewx(Ox!_$e!_!`!8g!`#O$e#O#P&f#P#p$e#p#q&$i#q;'S$e;'S;=`(u<%lO$e3o&$vY)U,g%_!b)[W(qQ'g&jOY$eZr$ers%^sw$ewx(Ox#O$e#O#P&f#P;'S$e;'S;=`(u<%lO$e'V&%qY!Ua)[W(qQ'g&jOY$eZr$ers%^sw$ewx(Ox#O$e#O#P&f#P;'S$e;'S;=`(u<%lO$e(]&&nc)[W(qQ%]!b'SP'g&jOX$eXY&'yZp$epq&'yqr$ers%^sw$ewx(Ox!c$e!c!}&)_!}#O$e#O#P&f#P#R$e#R#S&)_#S#T$e#T#o&)_#o;'S$e;'S;=`(u<%lO$e&y&(Sc)[W(qQ'g&jOX$eXY&'yZp$epq&'yqr$ers%^sw$ewx(Ox!c$e!c!}&)_!}#O$e#O#P&f#P#R$e#R#S&)_#S#T$e#T#o&)_#o;'S$e;'S;=`(u<%lO$e&y&)jb)[W(qQdT'g&jOY$eZr$ers%^sw$ewx(Ox!Q$e!Q![&)_![!c$e!c!}&)_!}#O$e#O#P&f#P#R$e#R#S&)_#S#T$e#T#o&)_#o;'S$e;'S;=`(u<%lO$e",tokenizers:[rawString,fallback,0,1,2,3,4,5,6,7,8,9],topRules:{"Program":[0,308]},dynamicPrecedences:{"87":1,"94":1,"119":1,"185":1,"188":-10,"241":-10,"242":1,"245":-1,"247":-10,"248":1,"263":-1,"268":2,"269":2,"307":-10,"366":3,"418":1,"419":3,"420":1,"421":1},specialized:[{term:357,get:value=>spec_identifier$5[value]||-1},{term:32,get:value=>spec_[value]||-1},{term:66,get:value=>spec_templateArgsEnd[value]||-1},{term:364,get:value=>spec_scopedIdentifier[value]||-1}],tokenPrec:24905});const cppLanguage=LRLanguage.define({name:"cpp",parser:parser$e.configure({props:[indentNodeProp.add({IfStatement:continuedIndent({except:/^\s*({|else\b)/}),TryStatement:continuedIndent({except:/^\s*({|catch)\b/}),LabeledStatement:flatIndent,CaseStatement:context=>context.baseIndent+context.unit,BlockComment:()=>null,CompoundStatement:delimitedIndent({closing:"}"}),Statement:continuedIndent({except:/^{/})}),foldNodeProp.add({"DeclarationList CompoundStatement EnumeratorList FieldDeclarationList InitializerList":foldInside,BlockComment(tree){return{from:tree.from+2,to:tree.to-2};}})]}),languageData:{commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\})$/,closeBrackets:{stringPrefixes:["L","u","U","u8","LR","UR","uR","u8R","R"]}}});function cpp(){return new LanguageSupport(cppLanguage);}var _m12=Object.freeze({__proto__:null,cpp:cpp,cppLanguage:cppLanguage});const castOpen=1,HeredocString=2,interpolatedStringContent=263,EscapeSequence=3,afterInterpolation=264,automaticSemicolon=265,eof$2=266,abstract=4,and=5,array=6,as=7,Boolean=8,_break=9,_case=10,_catch=11,clone=12,_const=13,_continue=14,_default=15,declare=16,_do=17,echo=18,_else=19,elseif=20,enddeclare=21,endfor=22,endforeach=23,endif=24,endswitch=25,endwhile=26,_enum=27,_extends=28,final=29,_finally=30,fn=31,_for=32,foreach=33,from=34,_function=35,global$1=36,goto=37,_if=38,_implements=39,include=40,include_once=41,_instanceof=42,insteadof=43,_interface=44,list=45,match=46,namespace=47,_new=48,_null=49,or=50,print=51,_require=52,require_once=53,_return=54,_switch=55,_throw=56,trait=57,_try=58,unset=59,use=60,_var=61,Visibility=62,_while=63,xor=64,_yield=65;const keywordMap={abstract,and,array,as,true:Boolean,false:Boolean,break:_break,case:_case,catch:_catch,clone,const:_const,continue:_continue,declare,default:_default,do:_do,echo,else:_else,elseif,enddeclare,endfor,endforeach,endif,endswitch,endwhile,enum:_enum,extends:_extends,final,finally:_finally,fn,for:_for,foreach,from,function:_function,global:global$1,goto,if:_if,implements:_implements,include,include_once,instanceof:_instanceof,insteadof,interface:_interface,list,match,namespace,new:_new,null:_null,or,print,require:_require,require_once,return:_return,switch:_switch,throw:_throw,trait,try:_try,unset,use,var:_var,public:Visibility,private:Visibility,protected:Visibility,while:_while,xor,yield:_yield,__proto__:null};function keywords$1(name){let found=keywordMap[name.toLowerCase()];return found==null?-1:found;}function isSpace$2(ch){return ch==9||ch==10||ch==13||ch==32;}function isASCIILetter(ch){return ch>=97&&ch<=122||ch>=65&&ch<=90;}function isIdentifierStart(ch){return ch==95||ch>=0x80||isASCIILetter(ch);}function isHex(ch){return ch>=48&&ch<=55||ch>=97&&ch<=102||ch>=65&&ch<=70;}const castTypes={int:true,integer:true,bool:true,boolean:true,float:true,double:true,real:true,string:true,array:true,object:true,unset:true,__proto__:null};const expression=new ExternalTokenizer(input=>{if(input.next==40){input.advance();let peek=0;while(isSpace$2(input.peek(peek)))peek++;let name="",next;while(isASCIILetter(next=input.peek(peek))){name+=String.fromCharCode(next);peek++;}while(isSpace$2(input.peek(peek)))peek++;if(input.peek(peek)==41&&castTypes[name.toLowerCase()])input.acceptToken(castOpen);}else if(input.next==60&&input.peek(1)==60&&input.peek(2)==60){for(let i=0;i<3;i++)input.advance();while(input.next==32||input.next==9)input.advance();let quoted=input.next==39;if(quoted)input.advance();if(!isIdentifierStart(input.next))return;let tag=String.fromCharCode(input.next);for(;;){input.advance();if(!isIdentifierStart(input.next)&&!(input.next>=48&&input.next<=55))break;tag+=String.fromCharCode(input.next);}if(quoted){if(input.next!=39)return;input.advance();}if(input.next!=10&&input.next!=13)return;for(;;){let lineStart=input.next==10||input.next==13;input.advance();if(input.next<0)return;if(lineStart){while(input.next==32||input.next==9)input.advance();let match=true;for(let i=0;i{if(input.next<0)input.acceptToken(eof$2);});const semicolon=new ExternalTokenizer((input,stack)=>{if(input.next==63&&stack.canShift(automaticSemicolon)&&input.peek(1)==62)input.acceptToken(automaticSemicolon);});function scanEscape(input){let after=input.peek(1);if(after==110||after==114||after==116||after==118||after==101||after==102||after==92||after==36||after==34||after==123)return 2;if(after>=48&&after<=55){let size=2,next;while(size<5&&(next=input.peek(size))>=48&&next<=55)size++;return size;}if(after==120&&isHex(input.peek(2))){return isHex(input.peek(3))?4:3;}if(after==117&&input.peek(2)==123){for(let size=3;;size++){let next=input.peek(size);if(next==125)return size==2?0:size+1;if(!isHex(next))break;}}return 0;}const interpolated=new ExternalTokenizer((input,stack)=>{let content=false;for(;;content=true){if(input.next==34||input.next<0||input.next==36&&(isIdentifierStart(input.peek(1))||input.peek(1)==123)||input.next==123&&input.peek(1)==36){break;}else if(input.next==92){let escaped=scanEscape(input);if(escaped){if(content)break;else return input.acceptToken(EscapeSequence,escaped);}}else if(!content&&(input.next==91||input.next==45&&input.peek(1)==62&&isIdentifierStart(input.peek(2))||input.next==63&&input.peek(1)==45&&input.peek(2)==62&&isIdentifierStart(input.peek(3)))&&stack.canShift(afterInterpolation)){break;}input.advance();}if(content)input.acceptToken(interpolatedStringContent);});const phpHighlighting=styleTags({"Visibility abstract final static":tags$1.modifier,"for foreach while do if else elseif switch try catch finally return throw break continue default case":tags$1.controlKeyword,"endif endfor endforeach endswitch endwhile declare enddeclare goto match":tags$1.controlKeyword,"and or xor yield unset clone instanceof insteadof":tags$1.operatorKeyword,"function fn class trait implements extends const enum global interface use var":tags$1.definitionKeyword,"include include_once require require_once namespace":tags$1.moduleKeyword,"new from echo print array list as":tags$1.keyword,null:tags$1.null,Boolean:tags$1.bool,VariableName:tags$1.variableName,"NamespaceName/...":tags$1.namespace,"NamedType/...":tags$1.typeName,Name:tags$1.name,"CallExpression/Name":tags$1.function(tags$1.variableName),"LabelStatement/Name":tags$1.labelName,"MemberExpression/Name":tags$1.propertyName,"MemberExpression/VariableName":tags$1.special(tags$1.propertyName),"ScopedExpression/ClassMemberName/Name":tags$1.propertyName,"ScopedExpression/ClassMemberName/VariableName":tags$1.special(tags$1.propertyName),"CallExpression/MemberExpression/Name":tags$1.function(tags$1.propertyName),"CallExpression/ScopedExpression/ClassMemberName/Name":tags$1.function(tags$1.propertyName),"MethodDeclaration/Name":tags$1.function(tags$1.definition(tags$1.variableName)),"FunctionDefinition/Name":tags$1.function(tags$1.definition(tags$1.variableName)),"ClassDeclaration/Name":tags$1.definition(tags$1.className),UpdateOp:tags$1.updateOperator,ArithOp:tags$1.arithmeticOperator,LogicOp:tags$1.logicOperator,BitOp:tags$1.bitwiseOperator,CompareOp:tags$1.compareOperator,ControlOp:tags$1.controlOperator,AssignOp:tags$1.definitionOperator,"$ ConcatOp":tags$1.operator,LineComment:tags$1.lineComment,BlockComment:tags$1.blockComment,Integer:tags$1.integer,Float:tags$1.float,String:tags$1.string,ShellExpression:tags$1.special(tags$1.string),"=> ->":tags$1.punctuation,"( )":tags$1.paren,"#[ [ ]":tags$1.squareBracket,"${ { }":tags$1.brace,"-> ?->":tags$1.derefOperator,", ; :: : \\":tags$1.separator,"PhpOpen PhpClose":tags$1.processingInstruction});const spec_Name={__proto__:null,static:311,STATIC:311,class:333,CLASS:333};const parser$d=LRParser.deserialize({version:14,states:"$GSQ`OWOOQhQaOOP%oO`OOOOO#t'#H_'#H_O%tO#|O'#DtOOO#u'#Dw'#DwQ&SOWO'#DwO&XO$VOOOOQ#u'#Dx'#DxO&lQaO'#D|O(mQdO'#E}O(tQdO'#EQO*kQaO'#EWO,zQ`O'#ETO-PQ`O'#E^O/nQaO'#E^O/uQ`O'#EfO/zQ`O'#EoO*kQaO'#EoO0VQ`O'#HhO0[Q`O'#E{O0[Q`O'#E{OOQS'#Ic'#IcO0aQ`O'#EvOOQS'#IZ'#IZO2oQdO'#IWO6tQeO'#FUO*kQaO'#FeO*kQaO'#FfO*kQaO'#FgO*kQaO'#FhO*kQaO'#FhO*kQaO'#FkOOQO'#Id'#IdO7RQ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o2p2s2t2u2v2w3P3d3g3h3k3o3p3s3z3|4O4Q4S4U5v5w!x;b3u3v3x3y3{3}4P4R4T4V4Z4a4b4c4d4e4f4g4h4i4j4k4l4m4n4o4p4q4r4s4t4u4v4w4x5Q5e5h5i5l5p5q5t$O=z_j!]!g#k#n#o#s#t%R%T&p&s&t&w'O'z(l({)P)i*P*U,V,X-R6^6_6`6a6b6c6d6e6f6g6h6i6j6k6l6m6n6o6p6q6r6s6t6u6v6z6{6|7X7l7o7r7w7|8T8U8X8Z8[8f8g8h8i#|>]!y!z!}%c&W)t)v*T*o,T-d-k.t/c/i/m0d0v4W6T7i7s7u7z8j8k8l8m8n8o8p8q8r8s8t8u8v8w8x8y8z8{8|8}9O9P9Q9R9S9T9Z9[9]9h9y9}:O:R:Y:Z:_:a:b;c;d=Z=m=n!v>^+z-Q9V9X:d:e:f:g:h:j:k:m:o:p:r:t:v:x:z:|;O;Q;S;U;W;Y;[;^;`;e;g;i;t_0V1]9W:i:l:n:q:s:u:w:y:{:};P;R;T;V;X;Z;];_;a;f;h;u AssignmentExpression ArrayExpression ValueList & VariadicUnpacking ... Pair [ ] ListExpression ValueList Pair Pair SubscriptExpression MemberExpression -> ?-> VariableName DynamicVariable $ ${ CallExpression ArgList NamedArgument SpreadArgument CastExpression UnionType LogicOp OptionalType NamedType QualifiedName \\ NamespaceName ScopedExpression :: ClassMemberName AssignOp UpdateExpression UpdateOp YieldExpression BinaryExpression LogicOp LogicOp LogicOp BitOp BitOp BitOp CompareOp CompareOp BitOp ArithOp ConcatOp ArithOp ArithOp IncludeExpression RequireExpression CloneExpression UnaryExpression ControlOp LogicOp PrintIntrinsic FunctionExpression static ParamList Parameter #[ Attributes Attribute VariadicParameter PropertyParameter UseList ArrowFunction NewExpression class BaseClause ClassInterfaceClause DeclarationList ConstDeclaration VariableDeclarator PropertyDeclaration VariableDeclarator MethodDeclaration UseDeclaration UseList UseInsteadOfClause UseAsClause UpdateExpression ArithOp ShellExpression ThrowExpression Integer Float String MemberExpression SubscriptExpression UnaryExpression ArithOp Interpolation String IfStatement ColonBlock SwitchStatement Block CaseStatement DefaultStatement ColonBlock WhileStatement EmptyStatement DoStatement ForStatement ForSpec SequenceExpression ForeachStatement ForSpec Pair GotoStatement ContinueStatement BreakStatement ReturnStatement TryStatement CatchDeclarator DeclareStatement EchoStatement UnsetStatement ConstDeclaration FunctionDefinition ClassDeclaration InterfaceDeclaration TraitDeclaration EnumDeclaration EnumBody EnumCase NamespaceDefinition NamespaceUseDeclaration UseGroup UseClause UseClause GlobalDeclaration FunctionStaticDeclaration Program",maxTerm:304,nodeProps:[["group",-36,2,8,49,81,83,85,88,93,94,102,106,107,110,111,114,118,123,126,130,132,133,147,148,149,150,153,154,164,165,179,181,182,183,184,185,191,"Expression",-28,74,78,80,82,192,194,199,201,202,205,208,209,210,211,212,214,215,216,217,218,219,220,221,222,225,226,230,231,"Statement",-3,119,121,122,"Type"],["openedBy",69,"phpOpen",76,"{",86,"(",101,"#["],["closedBy",71,"phpClose",77,"}",87,")",158,"]"]],propSources:[phpHighlighting],skippedNodes:[0],repeatNodeCount:29,tokenData:"!F|_R!]OX$zXY&^YZ'sZ]$z]^&^^p$zpq&^qr)Rrs+Pst+otu2buv5evw6rwx8Vxy>]yz>yz{?g{|@}|}Bb}!OCO!O!PDh!P!QKT!Q!R!!o!R![!$q![!]!,P!]!^!-a!^!_!-}!_!`!1S!`!a!2d!a!b!3t!b!c!7^!c!d!7z!d!e!9W!e!}!7z!}#O!;^#O#P!;z#P#Q!V<%lO8VR9WV&wP%VQOw9mwx:Xx#O9m#O#P:^#P;'S9m;'S;=`;X<%lO9mQ9rV%VQOw9mwx:Xx#O9m#O#P:^#P;'S9m;'S;=`;X<%lO9mQ:^O%VQQ:aRO;'S9m;'S;=`:j;=`O9mQ:oW%VQOw9mwx:Xx#O9m#O#P:^#P;'S9m;'S;=`;X;=`<%l9m<%lO9mQ;[P;=`<%l9mR;fV&wP%VQOY$zYZ%fZ!^$z!^!_%k!_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#P#S!=u#S#T!B{#T;'S!=u;'S;=`!Ci<%lO!=uR!>rV&wPO#O!?X#O#P!?q#P#S!?X#S#T!@j#T;'S!?X;'S;=`!@o<%lO!?XQ!?[VO#O!?X#O#P!?q#P#S!?X#S#T!@j#T;'S!?X;'S;=`!@o<%lO!?XQ!?tRO;'S!?X;'S;=`!?};=`O!?XQ!@QWO#O!?X#O#P!?q#P#S!?X#S#T!@j#T;'S!?X;'S;=`!@o;=`<%l!?X<%lO!?XQ!@oO${QQ!@rP;=`<%l!?XR!@x]OY!=uYZ!>mZ!a!=u!a!b!?X!b#O!=u#O#P!Aq#P#S!=u#S#T!B{#T;'S!=u;'S;=`!Ci<%l~!=u~O!=u~~%fR!AvW&wPOY!=uYZ!>mZ!^!=u!^!_!@u!_;'S!=u;'S;=`!B`;=`<%l!?X<%lO!=uR!BcWO#O!?X#O#P!?q#P#S!?X#S#T!@j#T;'S!?X;'S;=`!@o;=`<%l!=u<%lO!?XR!CSV${Q&wPOY$zYZ%fZ!^$z!^!_%k!_;'S$z;'S;=`&W<%lO$zR!ClP;=`<%l!=uV!CvV!oU&wPOY$zYZ%fZ!^$z!^!_%k!_;'S$z;'S;=`&W<%lO$zV!DfY#}Q#lS&wPOY$zYZ%fZ!^$z!^!_%k!_!`6U!`#p$z#p#q!EU#q;'S$z;'S;=`&W<%lO$zR!E]V#{Q&wPOY$zYZ%fZ!^$z!^!_%k!_;'S$z;'S;=`&W<%lO$zR!EyV!nQ&wPOY$zYZ%fZ!^$z!^!_%k!_;'S$z;'S;=`&W<%lO$zR!FgV$^Q&wPOY$zYZ%fZ!^$z!^!_%k!_;'S$z;'S;=`&W<%lO$z",tokenizers:[expression,interpolated,semicolon,0,1,2,3,eofToken],topRules:{"Template":[0,72],"Program":[1,232]},dynamicPrecedences:{"284":1},specialized:[{term:81,get:(value,stack)=>keywords$1(value)<<1,external:keywords$1},{term:81,get:value=>spec_Name[value]||-1}],tokenPrec:29354});const scriptText=54,StartCloseScriptTag=1,styleText=55,StartCloseStyleTag=2,textareaText=56,StartCloseTextareaTag=3,EndTag=4,SelfClosingEndTag=5,StartTag$1=6,StartScriptTag=7,StartStyleTag=8,StartTextareaTag=9,StartSelfClosingTag=10,StartCloseTag$1=11,NoMatchStartCloseTag=12,MismatchedStartCloseTag=13,missingCloseTag=57,IncompleteCloseTag=14,commentContent$1$1=58,Element$4=20,TagName=22,Attribute=23,AttributeName=24,AttributeValue=26,UnquotedAttributeValue=27,ScriptText=28,StyleText=31,TextareaText=34,OpenTag$1=36,CloseTag=37,Dialect_noMatch=0,Dialect_selfClosing=1;const selfClosers$1={area:true,base:true,br:true,col:true,command:true,embed:true,frame:true,hr:true,img:true,input:true,keygen:true,link:true,meta:true,param:true,source:true,track:true,wbr:true,menuitem:true};const implicitlyClosed={dd:true,li:true,optgroup:true,option:true,p:true,rp:true,rt:true,tbody:true,td:true,tfoot:true,th:true,tr:true};const closeOnOpen={dd:{dd:true,dt:true},dt:{dd:true,dt:true},li:{li:true},option:{option:true,optgroup:true},optgroup:{optgroup:true},p:{address:true,article:true,aside:true,blockquote:true,dir:true,div:true,dl:true,fieldset:true,footer:true,form:true,h1:true,h2:true,h3:true,h4:true,h5:true,h6:true,header:true,hgroup:true,hr:true,menu:true,nav:true,ol:true,p:true,pre:true,section:true,table:true,ul:true},rp:{rp:true,rt:true},rt:{rp:true,rt:true},tbody:{tbody:true,tfoot:true},td:{td:true,th:true},tfoot:{tbody:true},th:{td:true,th:true},thead:{tbody:true,tfoot:true},tr:{tr:true}};function nameChar$1(ch){return ch==45||ch==46||ch==58||ch>=65&&ch<=90||ch==95||ch>=97&&ch<=122||ch>=161;}function isSpace$1(ch){return ch==9||ch==10||ch==13||ch==32;}let cachedName$1=null,cachedInput$1=null,cachedPos$1=0;function tagNameAfter$1(input,offset){let pos=input.pos+offset;if(cachedPos$1==pos&&cachedInput$1==input)return cachedName$1;let next=input.peek(offset);while(isSpace$1(next))next=input.peek(++offset);let name="";for(;;){if(!nameChar$1(next))break;name+=String.fromCharCode(next);next=input.peek(++offset);}cachedInput$1=input;cachedPos$1=pos;return cachedName$1=name?name.toLowerCase():next==question||next==bang?undefined:null;}const lessThan=60,greaterThan=62,slash$1=47,question=63,bang=33,dash$2=45;function ElementContext$1(name,parent){this.name=name;this.parent=parent;this.hash=parent?parent.hash:0;for(let i=0;i-1?new ElementContext$1(tagNameAfter$1(input,1)||"",context):context;},reduce(context,term){return term==Element$4&&context?context.parent:context;},reuse(context,node,stack,input){let type=node.type.id;return type==StartTag$1||type==OpenTag$1?new ElementContext$1(tagNameAfter$1(input,1)||"",context):context;},hash(context){return context?context.hash:0;},strict:false});const tagStart=new ExternalTokenizer((input,stack)=>{if(input.next!=lessThan){if(input.next<0&&stack.context)input.acceptToken(missingCloseTag);return;}input.advance();let close=input.next==slash$1;if(close)input.advance();let name=tagNameAfter$1(input,0);if(name===undefined)return;if(!name)return input.acceptToken(close?IncompleteCloseTag:StartTag$1);let parent=stack.context?stack.context.name:null;if(close){if(name==parent)return input.acceptToken(StartCloseTag$1);if(parent&&implicitlyClosed[parent])return input.acceptToken(missingCloseTag,-2);if(stack.dialectEnabled(Dialect_noMatch))return input.acceptToken(NoMatchStartCloseTag);for(let cx=stack.context;cx;cx=cx.parent)if(cx.name==name)return;input.acceptToken(MismatchedStartCloseTag);}else{if(name=="script")return input.acceptToken(StartScriptTag);if(name=="style")return input.acceptToken(StartStyleTag);if(name=="textarea")return input.acceptToken(StartTextareaTag);if(selfClosers$1.hasOwnProperty(name))return input.acceptToken(StartSelfClosingTag);if(parent&&closeOnOpen[parent]&&closeOnOpen[parent][name])input.acceptToken(missingCloseTag,-1);else input.acceptToken(StartTag$1);}},{contextual:true});const commentContent$2=new ExternalTokenizer(input=>{for(let dashes=0,i=0;;i++){if(input.next<0){if(i)input.acceptToken(commentContent$1$1);break;}if(input.next==dash$2){dashes++;}else if(input.next==greaterThan&&dashes>=2){if(i>3)input.acceptToken(commentContent$1$1,-2);break;}else{dashes=0;}input.advance();}});function inForeignElement(context){for(;context;context=context.parent)if(context.name=="svg"||context.name=="math")return true;return false;}const endTag=new ExternalTokenizer((input,stack)=>{if(input.next==slash$1&&input.peek(1)==greaterThan){let selfClosing=stack.dialectEnabled(Dialect_selfClosing)||inForeignElement(stack.context);input.acceptToken(selfClosing?SelfClosingEndTag:EndTag,2);}else if(input.next==greaterThan){input.acceptToken(EndTag,1);}});function contentTokenizer(tag,textToken,endToken){let lastState=2+tag.length;return new ExternalTokenizer(input=>{for(let state=0,matchedLen=0,i=0;;i++){if(input.next<0){if(i)input.acceptToken(textToken);break;}if(state==0&&input.next==lessThan||state==1&&input.next==slash$1||state>=2&&statematchedLen)input.acceptToken(textToken,-matchedLen);else input.acceptToken(endToken,-(matchedLen-2));break;}else if((input.next==10||input.next==13)&&i){input.acceptToken(textToken,1);break;}else{state=matchedLen=0;}input.advance();}});}const scriptTokens=contentTokenizer("script",scriptText,StartCloseScriptTag);const styleTokens=contentTokenizer("style",styleText,StartCloseStyleTag);const textareaTokens=contentTokenizer("textarea",textareaText,StartCloseTextareaTag);const htmlHighlighting=styleTags({"Text RawText":tags$1.content,"StartTag StartCloseTag SelfClosingEndTag EndTag":tags$1.angleBracket,TagName:tags$1.tagName,"MismatchedCloseTag/TagName":[tags$1.tagName,tags$1.invalid],AttributeName:tags$1.attributeName,"AttributeValue UnquotedAttributeValue":tags$1.attributeValue,Is:tags$1.definitionOperator,"EntityReference CharacterReference":tags$1.character,Comment:tags$1.blockComment,ProcessingInst:tags$1.processingInstruction,DoctypeDecl:tags$1.documentMeta});const parser$c=LRParser.deserialize({version:14,states:",xOVO!rOOO!WQ#tO'#CqO!]Q#tO'#CzO!bQ#tO'#C}O!gQ#tO'#DQO!lQ#tO'#DSO!qOaO'#CpO!|ObO'#CpO#XOdO'#CpO$eO!rO'#CpOOO`'#Cp'#CpO$lO$fO'#DTO$tQ#tO'#DVO$yQ#tO'#DWOOO`'#Dk'#DkOOO`'#DY'#DYQVO!rOOO%OQ&rO,59]O%WQ&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![sO!euO~OfvO~OfwO~OS|OhyO~OS!OOhyO~OS!QOhyO~OS!SOT!TOhyO~OS!TOhyO~O!WfOPlX!ZlX~OP!WO!Z!XO~O!XiOQoX!ZoX~OQ!ZO!Z!XO~O!YlORrX!ZrX~OR!]O!Z!XO~O!Z!XO~P#dOf!_O~O![sO!e!aO~OS!bO~OS!cO~Oi!dOSgXhgXTgX~OS!fOhyO~OS!gOhyO~OS!hOhyO~OS!iOT!jOhyO~OS!jOhyO~Of!kO~Of!lO~Of!mO~OS!nO~Ok!qO!`!oO!b!pO~OS!rO~OS!sO~OS!tO~Oa!uOb!uOc!uO!`!wO!a!uO~Oa!xOb!xOc!xO!b!wO!c!xO~Oa!uOb!uOc!uO!`!{O!a!uO~Oa!xOb!xOc!xO!b!{O!c!xO~OT~bac!dx{!d~",goto:"%p!`PPPPPPPPPPPPPPPPPPPP!a!gP!mPP!yP!|#P#S#Y#]#`#f#i#l#r#x!aP!a!aP$O$U$l$r$x%O%U%[%bPPPPPPPP%hX^OX`pXUOX`pezabcde{}!P!R!UR!q!dRhUR!XhXVOX`pRkVR!XkXWOX`pRnWR!XnXXOX`pQrXR!XpXYOX`pQ`ORx`Q{aQ}bQ!PcQ!RdQ!UeZ!e{}!P!R!UQ!v!oR!z!vQ!y!pR!|!yQgUR!VgQjVR!YjQmWR![mQpXR!^pQtZR!`tS_O`ToXp",nodeNames:"⚠ StartCloseTag StartCloseTag StartCloseTag EndTag SelfClosingEndTag StartTag StartTag StartTag StartTag StartTag StartCloseTag StartCloseTag StartCloseTag IncompleteCloseTag Document Text EntityReference CharacterReference InvalidEntity Element OpenTag TagName Attribute AttributeName Is AttributeValue UnquotedAttributeValue ScriptText CloseTag OpenTag StyleText CloseTag OpenTag TextareaText CloseTag OpenTag CloseTag SelfClosingTag Comment ProcessingInst MismatchedCloseTag CloseTag DoctypeDecl",maxTerm:67,context:elementContext$1,nodeProps:[["closedBy",-10,1,2,3,7,8,9,10,11,12,13,"EndTag",6,"EndTag SelfClosingEndTag",-4,21,30,33,36,"CloseTag"],["openedBy",4,"StartTag StartCloseTag",5,"StartTag",-4,29,32,35,37,"OpenTag"],["group",-9,14,17,18,19,20,39,40,41,42,"Entity",16,"Entity TextContent",-3,28,31,34,"TextContent Entity"]],propSources:[htmlHighlighting],skippedNodes:[0],repeatNodeCount:9,tokenData:"#%g!aR!YOX$qXY,QYZ,QZ[$q[]&X]^,Q^p$qpq,Qqr-_rs4ysv-_vw5iwxJ^x}-_}!OKP!O!P-_!P!Q$q!Q![-_![!]!!O!]!^-_!^!_!&W!_!`#$o!`!a&X!a!c-_!c!}!!O!}#R-_#R#S!!O#S#T3V#T#o!!O#o#s-_#s$f$q$f%W-_%W%o!!O%o%p-_%p&a!!O&a&b-_&b1p!!O1p4U-_4U4d!!O4d4e-_4e$IS!!O$IS$I`-_$I`$Ib!!O$Ib$Kh-_$Kh%#t!!O%#t&/x-_&/x&Et!!O&Et&FV-_&FV;'S!!O;'S;:j!&Q;:j;=`4s<%l?&r-_?&r?Ah!!O?Ah?BY$q?BY?Mn!!O?MnO$q!Z$|c`PkW!a`!cpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr$qrs&}sv$qvw+Pwx(tx!^$q!^!_*V!_!a&X!a#S$q#S#T&X#T;'S$q;'S;=`+z<%lO$q!R&bX`P!a`!cpOr&Xrs&}sv&Xwx(tx!^&X!^!_*V!_;'S&X;'S;=`*y<%lO&Xq'UV`P!cpOv&}wx'kx!^&}!^!_(V!_;'S&};'S;=`(n<%lO&}P'pT`POv'kw!^'k!_;'S'k;'S;=`(P<%lO'kP(SP;=`<%l'kp([S!cpOv(Vx;'S(V;'S;=`(h<%lO(Vp(kP;=`<%l(Vq(qP;=`<%l&}a({W`P!a`Or(trs'ksv(tw!^(t!^!_)e!_;'S(t;'S;=`*P<%lO(t`)jT!a`Or)esv)ew;'S)e;'S;=`)y<%lO)e`)|P;=`<%l)ea*SP;=`<%l(t!Q*^V!a`!cpOr*Vrs(Vsv*Vwx)ex;'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POr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!N`P;=`<%l!G_T!NhbhSOq!Hpqr!Ncrs!Hpsw!Ncwx!Hpx!P!Nc!P!Q!Hp!Q!_!Nc!_!a!Hp!a!b# p!b#s!Nc#s$f!Hp$f;'S!Nc;'S;=`#!}<%l?Ah!Nc?Ah?BY!Hp?BY?Mn!Nc?MnO!HpT# ubhSOq!Hpqr!Ncrs!Hpsw!Ncwx!Hpx!P!Nc!P!Q!Hp!Q!_!Nc!_!`!Hp!`!a!If!a#s!Nc#s$f!Hp$f;'S!Nc;'S;=`#!}<%l?Ah!Nc?Ah?BY!Hp?BY?Mn!Nc?MnO!HpT##QP;=`<%l!Nc!V##^chS!a`!cpOq!G_qr!Eyrs!HUsv!Eyvw!Ncwx!Jvx!P!Ey!P!Q!G_!Q!_!Ey!_!`!G_!`!a!Mm!a#s!Ey#s$f!G_$f;'S!Ey;'S;=`#$i<%l?Ah!Ey?Ah?BY!G_?BY?Mn!Ey?MnO!G_!V#$lP;=`<%l!Ey!V#$zXiS`P!a`!cpOr&Xrs&}sv&Xwx(tx!^&X!^!_*V!_;'S&X;'S;=`*y<%lO&X",tokenizers:[scriptTokens,styleTokens,textareaTokens,endTag,tagStart,commentContent$2,0,1,2,3,4,5],topRules:{"Document":[0,15]},dialects:{noMatch:0,selfClosing:485},tokenPrec:487});function getAttrs(openTag,input){let attrs=Object.create(null);for(let _i258=0,_openTag$getChildren=openTag.getChildren(Attribute),_length258=_openTag$getChildren.length;_i258<_length258;_i258++){let att=_openTag$getChildren[_i258];let name=att.getChild(AttributeName),value=att.getChild(AttributeValue)||att.getChild(UnquotedAttributeValue);if(name)attrs[input.read(name.from,name.to)]=!value?"":value.type.id==AttributeValue?input.read(value.from+1,value.to-1):input.read(value.from,value.to);}return attrs;}function findTagName(openTag,input){let tagNameNode=openTag.getChild(TagName);return tagNameNode?input.read(tagNameNode.from,tagNameNode.to):" ";}function maybeNest(node,input,tags){let attrs;for(let _i259=0,_length259=tags.length;_i259<_length259;_i259++){let tag=tags[_i259];if(!tag.attrs||tag.attrs(attrs||(attrs=getAttrs(node.node.parent.firstChild,input))))return{parser:tag.parser};}return null;}function configureNesting(tags=[],attributes=[]){let script=[],style=[],textarea=[],other=[];for(let _i260=0,_length260=tags.length;_i260<_length260;_i260++){let tag=tags[_i260];let array=tag.tag=="script"?script:tag.tag=="style"?style:tag.tag=="textarea"?textarea:other;array.push(tag);}let attrs=attributes.length?Object.create(null):null;for(let _i261=0,_length261=attributes.length;_i261<_length261;_i261++){let attr=attributes[_i261];(attrs[attr.name]||(attrs[attr.name]=[])).push(attr);}return parseMixed((node,input)=>{let id=node.type.id;if(id==ScriptText)return maybeNest(node,input,script);if(id==StyleText)return maybeNest(node,input,style);if(id==TextareaText)return maybeNest(node,input,textarea);if(id==Element$4&&other.length){let n=node.node,open=n.firstChild,tagName=open&&findTagName(open,input),attrs;if(tagName)for(let _i262=0,_length262=other.length;_i262<_length262;_i262++){let tag=other[_i262];if(tag.tag==tagName&&(!tag.attrs||tag.attrs(attrs||(attrs=getAttrs(n,input))))){let close=n.lastChild;return{parser:tag.parser,overlay:[{from:open.to,to:close.type.id==CloseTag?close.from:n.to}]};}}}if(attrs&&id==Attribute){let n=node.node,nameNode;if(nameNode=n.firstChild){let matches=attrs[input.read(nameNode.from,nameNode.to)];if(matches)for(let _i263=0,_length263=matches.length;_i263<_length263;_i263++){let attr=matches[_i263];if(attr.tagName&&attr.tagName!=findTagName(n.parent,input))continue;let value=n.lastChild;if(value.type.id==AttributeValue){let from=value.from+1;let last=value.lastChild,to=value.to-(last&&last.isError?0:1);if(to>from)return{parser:attr.parser,overlay:[{from,to}]};}else if(value.type.id==UnquotedAttributeValue){return{parser:attr.parser,overlay:[{from:value.from,to:value.to}]};}}}}return null;});}const descendantOp$2=95,Unit$2=1,callee$1=96,identifier$3=97,VariableName$1=2;const space$4=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288];const colon$1=58,parenL$1=40,underscore$1=95,bracketL$1=91,dash$1=45,period$1=46,hash$2=35,percent$1=37;function isAlpha$3(ch){return ch>=65&&ch<=90||ch>=97&&ch<=122||ch>=161;}function isDigit$2(ch){return ch>=48&&ch<=57;}const identifiers$1=new ExternalTokenizer((input,stack)=>{for(let inside=false,dashes=0,i=0;;i++){let{next}=input;if(isAlpha$3(next)||next==dash$1||next==underscore$1||inside&&isDigit$2(next)){if(!inside&&(next!=dash$1||i>0))inside=true;if(dashes===i&&next==dash$1)dashes++;input.advance();}else{if(inside)input.acceptToken(next==parenL$1?callee$1:dashes==2&&stack.canShift(VariableName$1)?VariableName$1:identifier$3);break;}}});const descendant$2=new ExternalTokenizer(input=>{if(space$4.includes(input.peek(-1))){let{next}=input;if(isAlpha$3(next)||next==underscore$1||next==hash$2||next==period$1||next==bracketL$1||next==colon$1||next==dash$1)input.acceptToken(descendantOp$2);}});const unitToken$2=new ExternalTokenizer(input=>{if(!space$4.includes(input.peek(-1))){let{next}=input;if(next==percent$1){input.advance();input.acceptToken(Unit$2);}if(isAlpha$3(next)){do{input.advance();}while(isAlpha$3(input.next));input.acceptToken(Unit$2);}}});const cssHighlighting$1=styleTags({"AtKeyword import charset namespace keyframes media supports":tags$1.definitionKeyword,"from to selector":tags$1.keyword,NamespaceName:tags$1.namespace,KeyframeName:tags$1.labelName,KeyframeRangeName:tags$1.operatorKeyword,TagName:tags$1.tagName,ClassName:tags$1.className,PseudoClassName:tags$1.constant(tags$1.className),IdName:tags$1.labelName,"FeatureName PropertyName":tags$1.propertyName,AttributeName:tags$1.attributeName,NumberLiteral:tags$1.number,KeywordQuery:tags$1.keyword,UnaryQueryOp:tags$1.operatorKeyword,"CallTag ValueName":tags$1.atom,VariableName:tags$1.variableName,Callee:tags$1.operatorKeyword,Unit:tags$1.unit,"UniversalSelector NestingSelector":tags$1.definitionOperator,MatchOp:tags$1.compareOperator,"ChildOp SiblingOp, LogicOp":tags$1.logicOperator,BinOp:tags$1.arithmeticOperator,Important:tags$1.modifier,Comment:tags$1.blockComment,ColorLiteral:tags$1.color,"ParenthesizedContent StringLiteral":tags$1.string,":":tags$1.punctuation,"PseudoOp #":tags$1.derefOperator,"; ,":tags$1.separator,"( )":tags$1.paren,"[ ]":tags$1.squareBracket,"{ }":tags$1.brace});const spec_callee$1={__proto__:null,lang:32,"nth-child":32,"nth-last-child":32,"nth-of-type":32,"nth-last-of-type":32,dir:32,"host-context":32,url:60,"url-prefix":60,domain:60,regexp:60,selector:134};const spec_AtKeyword$2={__proto__:null,"@import":114,"@media":138,"@charset":142,"@namespace":146,"@keyframes":152,"@supports":164};const spec_identifier$4={__proto__:null,not:128,only:128};const parser$b=LRParser.deserialize({version:14,states:"8`QYQ[OOO#_Q[OOOOQP'#Cd'#CdOOQP'#Cc'#CcO#fQ[O'#CfO$YQXO'#CaO$aQ[O'#ChO$lQ[O'#DPO$qQ[O'#DTOOQP'#Ee'#EeO$vQdO'#DeO%bQ[O'#DrO$vQdO'#DtO%sQ[O'#DvO&OQ[O'#DyO&WQ[O'#EPO&fQ[O'#EROOQS'#Ed'#EdOOQS'#ET'#ETQYQ[OOO&mQXO'#CdO'bQWO'#DaO'gQWO'#EkO'rQ[O'#EkQOQWOOOOQP'#Cg'#CgOOQP,59Q,59QO#fQ[O,59QO'|Q[O'#EWO(hQWO,58{O(pQ[O,59SO$lQ[O,59kO$qQ[O,59oO'|Q[O,59sO'|Q[O,59uO'|Q[O,59vO({Q[O'#D`OOQS,58{,58{OOQP'#Ck'#CkOOQO'#C}'#C}OOQP,59S,59SO)SQWO,59SO)XQWO,59SOOQP'#DR'#DROOQP,59k,59kOOQO'#DV'#DVO)^Q`O,59oOOQS'#Cp'#CpO$vQdO'#CqO)fQvO'#CsO*sQtO,5:POOQO'#Cx'#CxO)XQWO'#CwO+XQWO'#CyOOQS'#Eh'#EhOOQO'#Dh'#DhO+^Q[O'#DoO+lQWO'#ElO&WQ[O'#DmO+zQWO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;'S%^;'S;=`%o<%lO%^^I[SvUOy%^z;'S%^;'S;=`%o<%lO%^XIkUOy%^z#b%^#b#cI}#c;'S%^;'S;=`%o<%lO%^XJSUoWOy%^z#W%^#W#XJf#X;'S%^;'S;=`%o<%lO%^XJmS!`PoWOy%^z;'S%^;'S;=`%o<%lO%^XJ|UOy%^z#f%^#f#gJf#g;'S%^;'S;=`%o<%lO%^ZKeS!RROy%^z;'S%^;'S;=`%o<%lO%^_KvS!QVOy%^z;'S%^;'S;=`%o<%lO%^ZLXU!PPOy%^z!_%^!_!`6y!`;'S%^;'S;=`%o<%lO%^WLnP;=`<%l$}",tokenizers:[descendant$2,unitToken$2,identifiers$1,0,1,2,3],topRules:{"StyleSheet":[0,4],"Styles":[1,84]},specialized:[{term:96,get:value=>spec_callee$1[value]||-1},{term:56,get:value=>spec_AtKeyword$2[value]||-1},{term:97,get:value=>spec_identifier$4[value]||-1}],tokenPrec:1142});let _properties=null;function properties(){if(!_properties&&typeof document=="object"&&document.body){let{style}=document.body,names=[],seen=new Set();for(let prop in style)if(prop!="cssText"&&prop!="cssFloat"){if(typeof style[prop]=="string"){if(/[A-Z]/.test(prop))prop=prop.replace(/[A-Z]/g,ch=>"-"+ch.toLowerCase());if(!seen.has(prop)){names.push(prop);seen.add(prop);}}}_properties=names.sort().map(name=>({type:"property",label:name}));}return _properties||[];}const pseudoClasses=["active","after","any-link","autofill","backdrop","before","checked","cue","default","defined","disabled","empty","enabled","file-selector-button","first","first-child","first-letter","first-line","first-of-type","focus","focus-visible","focus-within","fullscreen","has","host","host-context","hover","in-range","indeterminate","invalid","is","lang","last-child","last-of-type","left","link","marker","modal","not","nth-child","nth-last-child","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","part","placeholder","placeholder-shown","read-only","read-write","required","right","root","scope","selection","slotted","target","target-text","valid","visited","where"].map(name=>({type:"class",label:name}));const values=["above","absolute","activeborder","additive","activecaption","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","antialiased","appworkspace","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","axis-pan","background","backwards","baseline","below","bidi-override","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","contain","content","contents","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic-abegede-gez","ethiopic-halehame-aa-er","ethiopic-halehame-gez","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fill-box","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","graytext","grid","groove","hand","hard-light","help","hidden","hide","higher","highlight","highlighttext","horizontal","hsl","hsla","hue","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","justify","keep-all","landscape","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-hexadecimal","lower-latin","lower-norwegian","lowercase","ltr","luminosity","manipulation","match","matrix","matrix3d","medium","menu","menutext","message-box","middle","min-intrinsic","mix","monospace","move","multiple","multiple_mask_images","multiply","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","opacity","open-quote","optimizeLegibility","optimizeSpeed","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","perspective","pinch-zoom","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","self-start","self-end","semi-condensed","semi-expanded","separate","serif","show","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","start","static","status-bar","stretch","stroke","stroke-box","sub","subpixel-antialiased","svg_masks","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","text","text-bottom","text-top","textarea","textfield","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","to","top","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unidirectional-pan","unset","up","upper-latin","uppercase","url","var","vertical","vertical-text","view-box","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"].map(name=>({type:"keyword",label:name})).concat(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"].map(name=>({type:"constant",label:name})));const tags=["a","abbr","address","article","aside","b","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","dd","del","details","dfn","dialog","div","dl","dt","em","figcaption","figure","footer","form","header","hgroup","h1","h2","h3","h4","h5","h6","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","main","meter","nav","ol","output","p","pre","ruby","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","tr","u","ul"].map(name=>({type:"type",label:name}));const identifier$2=/^(\w[\w-]*|-\w[\w-]*|)$/,variable=/^-(-[\w-]*)?$/;function isVarArg(node,doc){var _a;if(node.name=="("||node.type.isError)node=node.parent||node;if(node.name!="ArgList")return false;let callee=(_a=node.parent)===null||_a===void 0?void 0:_a.firstChild;if((callee===null||callee===void 0?void 0:callee.name)!="Callee")return false;return doc.sliceString(callee.from,callee.to)=="var";}const VariablesByNode=new NodeWeakMap();const declSelector=["Declaration"];function astTop(node){for(let cur=node;;){if(cur.type.isTop)return cur;if(!(cur=cur.parent))return node;}}function variableNames(doc,node,isVariable){if(node.to-node.from>4096){let known=VariablesByNode.get(node);if(known)return known;let result=[],seen=new Set(),cursor=node.cursor(IterMode.IncludeAnonymous);if(cursor.firstChild())do{for(let _i264=0,_variableNames=variableNames(doc,cursor.node,isVariable),_length264=_variableNames.length;_i264<_length264;_i264++){let option=_variableNames[_i264];if(!seen.has(option.label)){seen.add(option.label);result.push(option);}}}while(cursor.nextSibling());VariablesByNode.set(node,result);return result;}else{let result=[],seen=new Set();node.cursor().iterate(node=>{var _a;if(isVariable(node)&&node.matchContext(declSelector)&&((_a=node.node.nextSibling)===null||_a===void 0?void 0:_a.name)==":"){let name=doc.sliceString(node.from,node.to);if(!seen.has(name)){seen.add(name);result.push({label:name,type:"variable"});}}});return result;}}const defineCSSCompletionSource=isVariable=>context=>{let{state,pos}=context,node=syntaxTree(state).resolveInner(pos,-1);let isDash=node.type.isError&&node.from==node.to-1&&state.doc.sliceString(node.from,node.to)=="-";if(node.name=="PropertyName"||(isDash||node.name=="TagName")&&/^(Block|Styles)$/.test(node.resolve(node.to).name))return{from:node.from,options:properties(),validFor:identifier$2};if(node.name=="ValueName")return{from:node.from,options:values,validFor:identifier$2};if(node.name=="PseudoClassName")return{from:node.from,options:pseudoClasses,validFor:identifier$2};if(isVariable(node)||(context.explicit||isDash)&&isVarArg(node,state.doc))return{from:isVariable(node)||isDash?node.from:pos,options:variableNames(state.doc,astTop(node),isVariable),validFor:variable};if(node.name=="TagName"){for(let{parent}=node;parent;parent=parent.parent)if(parent.name=="Block")return{from:node.from,options:properties(),validFor:identifier$2};return{from:node.from,options:tags,validFor:identifier$2};}if(!context.explicit)return null;let above=node.resolve(pos),before=above.childBefore(pos);if(before&&before.name==":"&&above.name=="PseudoClassSelector")return{from:pos,options:pseudoClasses,validFor:identifier$2};if(before&&before.name==":"&&above.name=="Declaration"||above.name=="ArgList")return{from:pos,options:values,validFor:identifier$2};if(above.name=="Block"||above.name=="Styles")return{from:pos,options:properties(),validFor:identifier$2};return null;};const cssCompletionSource=defineCSSCompletionSource(n=>n.name=="VariableName");const cssLanguage=LRLanguage.define({name:"css",parser:parser$b.configure({props:[indentNodeProp.add({Declaration:continuedIndent()}),foldNodeProp.add({"Block KeyframeList":foldInside})]}),languageData:{commentTokens:{block:{open:"/*",close:"*/"}},indentOnInput:/^\s*\}$/,wordChars:"-"}});function css(){return new LanguageSupport(cssLanguage,cssLanguage.data.of({autocomplete:cssCompletionSource}));}var _m15=Object.freeze({__proto__:null,css:css,cssCompletionSource:cssCompletionSource,cssLanguage:cssLanguage,defineCSSCompletionSource:defineCSSCompletionSource});const Targets=["_blank","_self","_top","_parent"];const Charsets=["ascii","utf-8","utf-16","latin1","latin1"];const Methods=["get","post","put","delete"];const Encs=["application/x-www-form-urlencoded","multipart/form-data","text/plain"];const Bool$1=["true","false"];const S={};const Tags={a:{attrs:{href:null,ping:null,type:null,media:null,target:Targets,hreflang:null}},abbr:S,address:S,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:S,aside:S,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:S,base:{attrs:{href:null,target:Targets}},bdi:S,bdo:S,blockquote:{attrs:{cite:null}},body:S,br:S,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:Encs,formmethod:Methods,formnovalidate:["novalidate"],formtarget:Targets,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:S,center:S,cite:S,code:S,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:S,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:S,div:S,dl:S,dt:S,em:S,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:S,figure:S,footer:S,form:{attrs:{action:null,name:null,"accept-charset":Charsets,autocomplete:["on","off"],enctype:Encs,method:Methods,novalidate:["novalidate"],target:Targets}},h1:S,h2:S,h3:S,h4:S,h5:S,h6:S,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:S,hgroup:S,hr:S,html:{attrs:{manifest:null}},i:S,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:Encs,formmethod:Methods,formnovalidate:["novalidate"],formtarget:Targets,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:S,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:S,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:S,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:Charsets,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:S,noscript:S,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:S,param:{attrs:{name:null,value:null}},pre:S,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:S,rt:S,ruby:S,samp:S,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:Charsets}},section:S,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:S,source:{attrs:{src:null,type:null,media:null}},span:S,strong:S,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:S,summary:S,sup:S,table:S,tbody:S,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:S,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:S,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:S,time:{attrs:{datetime:null}},title:S,tr:S,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:S,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:S};const GlobalAttrs={accesskey:null,class:null,contenteditable:Bool$1,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:Bool$1,autocorrect:Bool$1,autocapitalize:Bool$1,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":Bool$1,"aria-autocomplete":["inline","list","both","none"],"aria-busy":Bool$1,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":Bool$1,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":Bool$1,"aria-hidden":Bool$1,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":Bool$1,"aria-multiselectable":Bool$1,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":Bool$1,"aria-relevant":null,"aria-required":Bool$1,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null};const eventAttributes=("beforeunload copy cut dragstart dragover dragleave dragenter dragend "+"drag paste focus blur change click load mousedown mouseenter mouseleave "+"mouseup keydown keyup resize scroll unload").split(" ").map(n=>"on"+n);for(let _i265=0,_length265=eventAttributes.length;_i265<_length265;_i265++){let a=eventAttributes[_i265];GlobalAttrs[a]=null;}class Schema{constructor(extraTags,extraAttrs){this.tags=Object.assign(Object.assign({},Tags),extraTags);this.globalAttrs=Object.assign(Object.assign({},GlobalAttrs),extraAttrs);this.allTags=Object.keys(this.tags);this.globalAttrNames=Object.keys(this.globalAttrs);}}Schema.default=new Schema();function elementName$1(doc,tree,max=doc.length){if(!tree)return"";let tag=tree.firstChild;let name=tag&&tag.getChild("TagName");return name?doc.sliceString(name.from,Math.min(name.to,max)):"";}function findParentElement$1(tree,skip=false){for(;tree;tree=tree.parent)if(tree.name=="Element"){if(skip)skip=false;else return tree;}return null;}function allowedChildren(doc,tree,schema){let parentInfo=schema.tags[elementName$1(doc,findParentElement$1(tree))];return(parentInfo===null||parentInfo===void 0?void 0:parentInfo.children)||schema.allTags;}function openTags(doc,tree){let open=[];for(let parent=findParentElement$1(tree);parent&&!parent.type.isTop;parent=findParentElement$1(parent.parent)){let tagName=elementName$1(doc,parent);if(tagName&&parent.lastChild.name=="CloseTag")break;if(tagName&&open.indexOf(tagName)<0&&(tree.name=="EndTag"||tree.from>=parent.firstChild.to))open.push(tagName);}return open;}const identifier$1=/^[:\-\.\w\u00b7-\uffff]*$/;function completeTag(state,schema,tree,from,to){let end=/\s*>/.test(state.sliceDoc(to,to+5))?"":">";let parent=findParentElement$1(tree,true);return{from,to,options:allowedChildren(state.doc,parent,schema).map(tagName=>({label:tagName,type:"type"})).concat(openTags(state.doc,tree).map((tag,i)=>({label:"/"+tag,apply:"/"+tag+end,type:"type",boost:99-i}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/};}function completeCloseTag(state,tree,from,to){let end=/\s*>/.test(state.sliceDoc(to,to+5))?"":">";return{from,to,options:openTags(state.doc,tree).map((tag,i)=>({label:tag,apply:tag+end,type:"type",boost:99-i})),validFor:identifier$1};}function completeStartTag(state,schema,tree,pos){let options=[],level=0;for(let _i266=0,_allowedChildren=allowedChildren(state.doc,tree,schema),_length266=_allowedChildren.length;_i266<_length266;_i266++){let tagName=_allowedChildren[_i266];options.push({label:"<"+tagName,type:"type"});}for(let _i267=0,_openTags=openTags(state.doc,tree),_length267=_openTags.length;_i267<_length267;_i267++){let open=_openTags[_i267];options.push({label:"",type:"type",boost:99-level++});}return{from:pos,to:pos,options,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/};}function completeAttrName(state,schema,tree,from,to){let elt=findParentElement$1(tree),info=elt?schema.tags[elementName$1(state.doc,elt)]:null;let localAttrs=info&&info.attrs?Object.keys(info.attrs):[];let names=info&&info.globalAttrs===false?localAttrs:localAttrs.length?localAttrs.concat(schema.globalAttrNames):schema.globalAttrNames;return{from,to,options:names.map(attrName=>({label:attrName,type:"property"})),validFor:identifier$1};}function completeAttrValue(state,schema,tree,from,to){var _a;let nameNode=(_a=tree.parent)===null||_a===void 0?void 0:_a.getChild("AttributeName");let options=[],token=undefined;if(nameNode){let attrName=state.sliceDoc(nameNode.from,nameNode.to);let attrs=schema.globalAttrs[attrName];if(!attrs){let elt=findParentElement$1(tree),info=elt?schema.tags[elementName$1(state.doc,elt)]:null;attrs=(info===null||info===void 0?void 0:info.attrs)&&info.attrs[attrName];}if(attrs){let base=state.sliceDoc(from,to).toLowerCase(),quoteStart='"',quoteEnd='"';if(/^['"]/.test(base)){token=base[0]=='"'?/^[^"]*$/:/^[^']*$/;quoteStart="";quoteEnd=state.sliceDoc(to,to+1)==base[0]?"":base[0];base=base.slice(1);from++;}else{token=/^[^\s<>='"]*$/;}for(let _i268=0,_attrs=attrs,_length268=_attrs.length;_i268<_length268;_i268++){let value=_attrs[_i268];options.push({label:value,apply:quoteStart+value+quoteEnd,type:"constant"});}}}return{from,to,options,validFor:token};}function htmlCompletionFor(schema,context){let{state,pos}=context,tree=syntaxTree(state).resolveInner(pos,-1),around=tree.resolve(pos);for(let scan=pos,before;around==tree&&(before=tree.childBefore(scan));){let last=before.lastChild;if(!last||!last.type.isError||last.fromhtmlCompletionFor(schema,context);}const defaultNesting=[{tag:"script",attrs:attrs=>attrs.type=="text/typescript"||attrs.lang=="ts",parser:typescriptLanguage.parser},{tag:"script",attrs:attrs=>attrs.type=="text/babel"||attrs.type=="text/jsx",parser:jsxLanguage.parser},{tag:"script",attrs:attrs=>attrs.type=="text/typescript-jsx",parser:tsxLanguage.parser},{tag:"script",attrs(attrs){return!attrs.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(attrs.type);},parser:javascriptLanguage.parser},{tag:"style",attrs(attrs){return(!attrs.lang||attrs.lang=="css")&&(!attrs.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(attrs.type));},parser:cssLanguage.parser}];const defaultAttrs=[{name:"style",parser:cssLanguage.parser.configure({top:"Styles"})}].concat(eventAttributes.map(name=>({name,parser:javascriptLanguage.parser})));const htmlPlain=LRLanguage.define({name:"html",parser:parser$c.configure({props:[indentNodeProp.add({Element(context){let after=/^(\s*)(<\/)?/.exec(context.textAfter);if(context.node.to<=context.pos+after[0].length)return context.continue();return context.lineIndent(context.node.from)+(after[2]?0:context.unit);},"OpenTag CloseTag SelfClosingTag"(context){return context.column(context.node.from)+context.unit;},Document(context){if(context.pos+/\s*/.exec(context.textAfter)[0].lengthnode.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:""}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-._"}});const htmlLanguage=htmlPlain.configure({wrap:configureNesting(defaultNesting,defaultAttrs)});function html(config={}){let dialect="",wrap;if(config.matchClosingTags===false)dialect="noMatch";if(config.selfClosingTags===true)dialect=(dialect?dialect+" ":"")+"selfClosing";if(config.nestedLanguages&&config.nestedLanguages.length||config.nestedAttributes&&config.nestedAttributes.length)wrap=configureNesting((config.nestedLanguages||[]).concat(defaultNesting),(config.nestedAttributes||[]).concat(defaultAttrs));let lang=wrap?htmlPlain.configure({wrap,dialect}):dialect?htmlLanguage.configure({dialect}):htmlLanguage;return new LanguageSupport(lang,[htmlLanguage.data.of({autocomplete:htmlCompletionSourceWith(config)}),config.autoCloseTags!==false?autoCloseTags:[],javascript().support,css().support]);}const selfClosers=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" "));const autoCloseTags=EditorView.inputHandler.of((view,from,to,text)=>{if(view.composing||view.state.readOnly||from!=to||text!=">"&&text!="/"||!htmlLanguage.isActiveAt(view.state,from,-1))return false;let{state}=view;let changes=state.changeByRange(range=>{var _a,_b,_c;let{head}=range,around=syntaxTree(state).resolveInner(head,-1),name;if(around.name=="TagName"||around.name=="StartTag")around=around.parent;if(text==">"&&around.name=="OpenTag"){if(((_b=(_a=around.parent)===null||_a===void 0?void 0:_a.lastChild)===null||_b===void 0?void 0:_b.name)!="CloseTag"&&(name=elementName$1(state.doc,around.parent,head))&&!selfClosers.has(name)){let hasRightBracket=view.state.doc.sliceString(head,head+1)===">";let insert=`${hasRightBracket?"":">"}`;return{range:EditorSelection.cursor(head+1),changes:{from:head+(hasRightBracket?1:0),insert}};}}else if(text=="/"&&around.name=="OpenTag"){let empty=around.parent,base=empty===null||empty===void 0?void 0:empty.parent;if(empty.from==head-1&&((_c=base.lastChild)===null||_c===void 0?void 0:_c.name)!="CloseTag"&&(name=elementName$1(state.doc,base,head))&&!selfClosers.has(name)){let hasRightBracket=view.state.doc.sliceString(head,head+1)===">";let insert=`/${name}${hasRightBracket?"":">"}`;let pos=head+insert.length+(hasRightBracket?1:0);return{range:EditorSelection.cursor(pos),changes:{from:head,insert}};}}return{range};});if(changes.changes.empty)return false;view.dispatch(changes,{userEvent:"input.type",scrollIntoView:true});return true;});var _m17=Object.freeze({__proto__:null,autoCloseTags:autoCloseTags,html:html,htmlCompletionSource:htmlCompletionSource,htmlCompletionSourceWith:htmlCompletionSourceWith,htmlLanguage:htmlLanguage,htmlPlain:htmlPlain});const phpLanguage=LRLanguage.define({name:"php",parser:parser$d.configure({props:[indentNodeProp.add({IfStatement:continuedIndent({except:/^\s*({|else\b|elseif\b|endif\b)/}),TryStatement:continuedIndent({except:/^\s*({|catch\b|finally\b)/}),SwitchBody:context=>{let after=context.textAfter,closed=/^\s*\}/.test(after),isCase=/^\s*(case|default)\b/.test(after);return context.baseIndent+(closed?0:isCase?1:2)*context.unit;},ColonBlock:cx=>cx.baseIndent+cx.unit,"Block EnumBody DeclarationList":delimitedIndent({closing:"}"}),ArrowFunction:cx=>cx.baseIndent+cx.unit,"String BlockComment":()=>null,Statement:continuedIndent({except:/^({|end(for|foreach|switch|while)\b)/})}),foldNodeProp.add({"Block EnumBody DeclarationList SwitchBody ArrayExpression ValueList":foldInside,ColonBlock(tree){return{from:tree.from+1,to:tree.to};},BlockComment(tree){return{from:tree.from+2,to:tree.to-2};}})]}),languageData:{commentTokens:{block:{open:"/*",close:"*/"},line:"//"},indentOnInput:/^\s*(?:case |default:|end(?:if|for(?:each)?|switch|while)|else(?:if)?|\{|\})$/,wordChars:"$",closeBrackets:{stringPrefixes:["b","B"]}}});function php(config={}){let support=[],base;if(config.baseLanguage===null);else if(config.baseLanguage){base=config.baseLanguage;}else{let htmlSupport=html({matchClosingTags:false});support.push(htmlSupport.support);base=htmlSupport.language;}return new LanguageSupport(phpLanguage.configure({wrap:base&&parseMixed(node=>{if(!node.type.isTop)return null;return{parser:base.parser,overlay:node=>node.name=="Text"};}),top:config.plain?"Program":"Template"}),support);}var _m13=Object.freeze({__proto__:null,php:php,phpLanguage:phpLanguage});const printKeyword=1,indent$1=196,dedent$1=197,newline$1=198,blankLineStart$1=199,newlineBracketed=200,eof$1=201,formatString1Content=202,formatString1Brace=2,formatString1End=203,formatString2Content=204,formatString2Brace=3,formatString2End=205,formatString1lContent=206,formatString1lBrace=4,formatString1lEnd=207,formatString2lContent=208,formatString2lBrace=5,formatString2lEnd=209,ParenL$1=26,ParenthesizedExpression=27,TupleExpression=51,ComprehensionExpression=52,BracketL$1=57,ArrayExpression=58,ArrayComprehensionExpression=59,BraceL$1=61,DictionaryExpression=62,DictionaryComprehensionExpression=63,SetExpression=64,SetComprehensionExpression=65,ArgList=67,subscript=246,FormatString=74,importList=265,ParamList=129,SequencePattern=150,MappingPattern=151,PatternArgList=154;const newline$2=10,carriageReturn=13,space$3=32,tab=9,hash$1=35,parenOpen=40,dot=46,braceOpen=123,singleQuote=39,doubleQuote=34;const bracketed=new Set([ParenthesizedExpression,TupleExpression,ComprehensionExpression,importList,ArgList,ParamList,ArrayExpression,ArrayComprehensionExpression,subscript,SetExpression,SetComprehensionExpression,FormatString,DictionaryExpression,DictionaryComprehensionExpression,SequencePattern,MappingPattern,PatternArgList]);function isLineBreak(ch){return ch==newline$2||ch==carriageReturn;}const newlines=new ExternalTokenizer((input,stack)=>{let prev;if(input.next<0){input.acceptToken(eof$1);}else if(stack.context.depth<0){if(isLineBreak(input.next))input.acceptToken(newlineBracketed,1);}else if(((prev=input.peek(-1))<0||isLineBreak(prev))&&stack.canShift(blankLineStart$1)){let spaces=0;while(input.next==space$3||input.next==tab){input.advance();spaces++;}if(input.next==newline$2||input.next==carriageReturn||input.next==hash$1)input.acceptToken(blankLineStart$1,-spaces);}else if(isLineBreak(input.next)){input.acceptToken(newline$1,1);}},{contextual:true});const indentation$1=new ExternalTokenizer((input,stack)=>{let cDepth=stack.context.depth;if(cDepth<0)return;let prev=input.peek(-1);if(prev==newline$2||prev==carriageReturn){let depth=0,chars=0;for(;;){if(input.next==space$3)depth++;else if(input.next==tab)depth+=8-depth%8;else break;input.advance();chars++;}if(depth!=cDepth&&input.next!=newline$2&&input.next!=carriageReturn&&input.next!=hash$1){if(depth{for(let i=0;i<5;i++){if(input.next!="print".charCodeAt(i))return;input.advance();}if(/\w/.test(String.fromCharCode(input.next)))return;for(let off=0;;off++){let next=input.peek(off);if(next==space$3||next==tab)continue;if(next!=parenOpen&&next!=dot&&next!=newline$2&&next!=carriageReturn&&next!=hash$1)input.acceptToken(printKeyword);return;}});function formatString(quote,len,content,brace,end){return new ExternalTokenizer(input=>{let start=input.pos;for(;;){if(input.next<0){break;}else if(input.next==braceOpen){if(input.peek(1)==braceOpen){input.advance(2);}else{if(input.pos==start){input.acceptToken(brace,1);return;}break;}}else if(input.next=="\\"){input.advance();if(input.next>=0)input.advance();}else if(input.next==quote&&(len==1||input.peek(1)==quote&&input.peek(2)==quote)){if(input.pos==start){input.acceptToken(end,len);return;}break;}else{input.advance();}}if(input.pos>start)input.acceptToken(content);});}const formatString1=formatString(singleQuote,1,formatString1Content,formatString1Brace,formatString1End);const formatString2=formatString(doubleQuote,1,formatString2Content,formatString2Brace,formatString2End);const formatString1l=formatString(singleQuote,3,formatString1lContent,formatString1lBrace,formatString1lEnd);const formatString2l=formatString(doubleQuote,3,formatString2lContent,formatString2lBrace,formatString2lEnd);const pythonHighlighting=styleTags({"async \"*\" \"**\" FormatConversion FormatSpec":tags$1.modifier,"for while if elif else try except finally return raise break continue with pass assert await yield match case":tags$1.controlKeyword,"in not and or is del":tags$1.operatorKeyword,"from def class global nonlocal lambda":tags$1.definitionKeyword,import:tags$1.moduleKeyword,"with as print":tags$1.keyword,Boolean:tags$1.bool,None:tags$1.null,VariableName:tags$1.variableName,"CallExpression/VariableName":tags$1.function(tags$1.variableName),"FunctionDefinition/VariableName":tags$1.function(tags$1.definition(tags$1.variableName)),"ClassDefinition/VariableName":tags$1.definition(tags$1.className),PropertyName:tags$1.propertyName,"CallExpression/MemberExpression/PropertyName":tags$1.function(tags$1.propertyName),Comment:tags$1.lineComment,Number:tags$1.number,String:tags$1.string,FormatString:tags$1.special(tags$1.string),UpdateOp:tags$1.updateOperator,"ArithOp!":tags$1.arithmeticOperator,BitOp:tags$1.bitwiseOperator,CompareOp:tags$1.compareOperator,AssignOp:tags$1.definitionOperator,Ellipsis:tags$1.punctuation,At:tags$1.meta,"( )":tags$1.paren,"[ ]":tags$1.squareBracket,"{ }":tags$1.brace,".":tags$1.derefOperator,", ;":tags$1.separator});const spec_identifier$3={__proto__:null,await:48,or:58,and:60,in:64,not:66,is:68,if:74,else:76,lambda:80,yield:98,from:100,async:106,for:108,None:168,True:170,False:170,del:184,pass:188,break:192,continue:196,return:200,raise:208,import:212,as:214,global:218,nonlocal:220,assert:224,elif:234,while:238,try:244,except:246,finally:248,with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GT!a!L{Y&eS&hWOr8^rs9Qsw8^wx:dx#O8^#O#P;v#P;'S8^;'S;=`Q<%lO$TP;=`<%l$ei&m!b&eS&hW&b`%}sOr%Trs$@Ssw%Twx$C`x!Q%T!Q![$Q<%lO$Q<%lO$Q<%lO$Q<%lO$Q<%lO$spec_identifier$3[value]||-1}],tokenPrec:7205});const cache=new NodeWeakMap();const ScopeNodes=new Set(["Script","Body","FunctionDefinition","ClassDefinition","LambdaExpression","ForStatement","MatchClause"]);function defID(type){return(node,def,outer)=>{if(outer)return false;let id=node.node.getChild("VariableName");if(id)def(id,type);return true;};}const gatherCompletions={FunctionDefinition:defID("function"),ClassDefinition:defID("class"),ForStatement(node,def,outer){if(outer)for(let child=node.node.firstChild;child;child=child.nextSibling){if(child.name=="VariableName")def(child,"variable");else if(child.name=="in")break;}},ImportStatement(_node,def){var _a,_b;let{node}=_node;let isFrom=((_a=node.firstChild)===null||_a===void 0?void 0:_a.name)=="from";for(let ch=node.getChild("import");ch;ch=ch.nextSibling){if(ch.name=="VariableName"&&((_b=ch.nextSibling)===null||_b===void 0?void 0:_b.name)!="as")def(ch,isFrom?"variable":"namespace");}},AssignStatement(node,def){for(let child=node.node.firstChild;child;child=child.nextSibling){if(child.name=="VariableName")def(child,"variable");else if(child.name==":"||child.name=="AssignOp")break;}},ParamList(node,def){for(let prev=null,child=node.node.firstChild;child;child=child.nextSibling){if(child.name=="VariableName"&&(!prev||!/\*|AssignOp/.test(prev.name)))def(child,"variable");prev=child;}},CapturePattern:defID("variable"),AsPattern:defID("variable"),__proto__:null};function getScope(doc,node){let cached=cache.get(node);if(cached)return cached;let completions=[],top=true;function def(node,type){let name=doc.sliceString(node.from,node.to);completions.push({label:name,type});}node.cursor(IterMode.IncludeAnonymous).iterate(node=>{if(node.name){let gather=gatherCompletions[node.name];if(gather&&gather(node,def,top)||!top&&ScopeNodes.has(node.name))return false;top=false;}else if(node.to-node.from>8192){for(let _i269=0,_getScope=getScope(doc,node.node),_length269=_getScope.length;_i269<_length269;_i269++){let c=_getScope[_i269];completions.push(c);}return false;}});cache.set(node,completions);return completions;}const Identifier$2=/^[\w\xa1-\uffff][\w\d\xa1-\uffff]*$/;const dontComplete=["String","FormatString","Comment","PropertyName"];function localCompletionSource(context){let inner=syntaxTree(context.state).resolveInner(context.pos,-1);if(dontComplete.indexOf(inner.name)>-1)return null;let isWord=inner.name=="VariableName"||inner.to-inner.from<20&&Identifier$2.test(context.state.sliceDoc(inner.from,inner.to));if(!isWord&&!context.explicit)return null;let options=[];for(let pos=inner;pos;pos=pos.parent){if(ScopeNodes.has(pos.name))options=options.concat(getScope(context.state.doc,pos));}return{options,from:isWord?inner.from:context.pos,validFor:Identifier$2};}const globals=["__annotations__","__builtins__","__debug__","__doc__","__import__","__name__","__loader__","__package__","__spec__","False","None","True"].map(n=>({label:n,type:"constant"})).concat(["ArithmeticError","AssertionError","AttributeError","BaseException","BlockingIOError","BrokenPipeError","BufferError","BytesWarning","ChildProcessError","ConnectionAbortedError","ConnectionError","ConnectionRefusedError","ConnectionResetError","DeprecationWarning","EOFError","Ellipsis","EncodingWarning","EnvironmentError","Exception","FileExistsError","FileNotFoundError","FloatingPointError","FutureWarning","GeneratorExit","IOError","ImportError","ImportWarning","IndentationError","IndexError","InterruptedError","IsADirectoryError","KeyError","KeyboardInterrupt","LookupError","MemoryError","ModuleNotFoundError","NameError","NotADirectoryError","NotImplemented","NotImplementedError","OSError","OverflowError","PendingDeprecationWarning","PermissionError","ProcessLookupError","RecursionError","ReferenceError","ResourceWarning","RuntimeError","RuntimeWarning","StopAsyncIteration","StopIteration","SyntaxError","SyntaxWarning","SystemError","SystemExit","TabError","TimeoutError","TypeError","UnboundLocalError","UnicodeDecodeError","UnicodeEncodeError","UnicodeError","UnicodeTranslateError","UnicodeWarning","UserWarning","ValueError","Warning","ZeroDivisionError"].map(n=>({label:n,type:"type"}))).concat(["bool","bytearray","bytes","classmethod","complex","float","frozenset","int","list","map","memoryview","object","range","set","staticmethod","str","super","tuple","type"].map(n=>({label:n,type:"class"}))).concat(["abs","aiter","all","anext","any","ascii","bin","breakpoint","callable","chr","compile","delattr","dict","dir","divmod","enumerate","eval","exec","exit","filter","format","getattr","globals","hasattr","hash","help","hex","id","input","isinstance","issubclass","iter","len","license","locals","max","min","next","oct","open","ord","pow","print","property","quit","repr","reversed","round","setattr","slice","sorted","sum","vars","zip"].map(n=>({label:n,type:"function"})));const snippets=[snippetCompletion("def ${name}(${params}):\n\t${}",{label:"def",detail:"function",type:"keyword"}),snippetCompletion("for ${name} in ${collection}:\n\t${}",{label:"for",detail:"loop",type:"keyword"}),snippetCompletion("while ${}:\n\t${}",{label:"while",detail:"loop",type:"keyword"}),snippetCompletion("try:\n\t${}\nexcept ${error}:\n\t${}",{label:"try",detail:"/ except block",type:"keyword"}),snippetCompletion("if ${}:\n\t\n",{label:"if",detail:"block",type:"keyword"}),snippetCompletion("if ${}:\n\t${}\nelse:\n\t${}",{label:"if",detail:"/ else block",type:"keyword"}),snippetCompletion("class ${name}:\n\tdef __init__(self, ${params}):\n\t\t\t${}",{label:"class",detail:"definition",type:"keyword"}),snippetCompletion("import ${module}",{label:"import",detail:"statement",type:"keyword"}),snippetCompletion("from ${module} import ${names}",{label:"from",detail:"import",type:"keyword"})];const globalCompletion=ifNotIn(dontComplete,completeFromList(globals.concat(snippets)));function indentBody(context,node){let base=context.baseIndentFor(node);let line=context.lineAt(context.pos,-1),to=line.from+line.text.length;if(/^\s*($|#)/.test(line.text)&&context.node.tobase)return null;return base+context.unit;}const pythonLanguage=LRLanguage.define({name:"python",parser:parser$a.configure({props:[indentNodeProp.add({Body:context=>{var _a;return(_a=indentBody(context,context.node))!==null&&_a!==void 0?_a:context.continue();},IfStatement:cx=>/^\s*(else:|elif )/.test(cx.textAfter)?cx.baseIndent:cx.continue(),TryStatement:cx=>/^\s*(except |finally:|else:)/.test(cx.textAfter)?cx.baseIndent:cx.continue(),"TupleExpression ComprehensionExpression ParamList ArgList ParenthesizedExpression":delimitedIndent({closing:")"}),"DictionaryExpression DictionaryComprehensionExpression SetExpression SetComprehensionExpression":delimitedIndent({closing:"}"}),"ArrayExpression ArrayComprehensionExpression":delimitedIndent({closing:"]"}),"String FormatString":()=>null,Script:context=>{if(context.pos+/\s*/.exec(context.textAfter)[0].length>=context.node.to){let endBody=null;for(let cur=context.node,to=cur.to;;){cur=cur.lastChild;if(!cur||cur.to!=to)break;if(cur.type.name=="Body")endBody=cur;}if(endBody){let bodyIndent=indentBody(context,endBody);if(bodyIndent!=null)return bodyIndent;}}return context.continue();}}),foldNodeProp.add({"ArrayExpression DictionaryExpression SetExpression TupleExpression":foldInside,Body:(node,state)=>({from:node.from+1,to:node.to-(node.to==state.doc.length?0:1)})})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"'''",'"""'],stringPrefixes:["f","fr","rf","r","u","b","br","rb","F","FR","RF","R","U","B","BR","RB"]},commentTokens:{line:"#"},indentOnInput:/^\s*([\}\]\)]|else:|elif |except |finally:)$/}});function python(){return new LanguageSupport(pythonLanguage,[pythonLanguage.data.of({autocomplete:localCompletionSource}),pythonLanguage.data.of({autocomplete:globalCompletion})]);}var _m14=Object.freeze({__proto__:null,globalCompletion:globalCompletion,localCompletionSource:localCompletionSource,python:python,pythonLanguage:pythonLanguage});const indent=146,dedent=147,descendantOp$1=148,InterpolationEnd=1,InterpolationContinue=2,Unit$1=3,callee=149,identifier=150,VariableName=4,InterpolationStart=5,newline=151,blankLineStart=152,eof=153,whitespace$1=154,LineComment$1=6,Comment=7,IndentedMixin=8,IndentedInclude=9,Dialect_indented=0;const space$2=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288];const colon=58,parenL=40,underscore=95,bracketL=91,dash=45,period=46,hash=35,percent=37,braceL=123,braceR=125,slash=47,asterisk=42,newlineChar=10,equals=61,plus=43;function isAlpha$2(ch){return ch>=65&&ch<=90||ch>=97&&ch<=122||ch>=161;}function isDigit$1(ch){return ch>=48&&ch<=57;}function startOfComment(input){let next;return input.next==slash&&((next=input.peek(1))==slash||next==asterisk);}const spaces=new ExternalTokenizer((input,stack)=>{if(stack.dialectEnabled(Dialect_indented)){let prev;if(input.next<0&&stack.canShift(eof)){input.acceptToken(eof);}else if(((prev=input.peek(-1))==newlineChar||prev<0)&&stack.canShift(blankLineStart)){let spaces=0;while(input.next!=newlineChar&&space$2.includes(input.next)){input.advance();spaces++;}if(input.next==newlineChar||startOfComment(input))input.acceptToken(blankLineStart,-spaces);else if(spaces)input.acceptToken(whitespace$1);}else if(input.next==newlineChar){input.acceptToken(newline,1);}else if(space$2.includes(input.next)){input.advance();while(input.next!=newlineChar&&space$2.includes(input.next))input.advance();input.acceptToken(whitespace$1);}}else{let length=0;while(space$2.includes(input.next)){input.advance();length++;}if(length)input.acceptToken(whitespace$1);}},{contextual:true});const comments=new ExternalTokenizer((input,stack)=>{if(!startOfComment(input))return;input.advance();if(stack.dialectEnabled(Dialect_indented)){let indentedComment=-1;for(let off=1;;off++){let prev=input.peek(-off-1);if(prev==newlineChar||prev<0){indentedComment=off+1;break;}else if(!space$2.includes(prev)){break;}}if(indentedComment>-1){let block=input.next==asterisk,end=0;input.advance();while(input.next>=0){if(input.next==newlineChar){input.advance();let indented=0;while(input.next!=newlineChar&&space$2.includes(input.next)){indented++;input.advance();}if(indented=0)input.advance();input.acceptToken(LineComment$1);}else{input.advance();while(input.next>=0){let{next}=input;input.advance();if(next==asterisk&&input.next==slash){input.advance();break;}}input.acceptToken(Comment);}});const indentedMixins=new ExternalTokenizer((input,stack)=>{if((input.next==plus||input.next==equals)&&stack.dialectEnabled(Dialect_indented))input.acceptToken(input.next==equals?IndentedMixin:IndentedInclude,1);});const indentation=new ExternalTokenizer((input,stack)=>{if(!stack.dialectEnabled(Dialect_indented))return;let cDepth=stack.context.depth;if(input.next<0&&cDepth){input.acceptToken(dedent);return;}let prev=input.peek(-1);if(prev==newlineChar){let depth=0;while(input.next!=newlineChar&&space$2.includes(input.next)){input.advance();depth++;}if(depth!=cDepth&&input.next!=newlineChar&&!startOfComment(input)){if(depth{for(let inside=false,dashes=0,i=0;;i++){let{next}=input;if(isAlpha$2(next)||next==dash||next==underscore||inside&&isDigit$1(next)){if(!inside&&(next!=dash||i>0))inside=true;if(dashes===i&&next==dash)dashes++;input.advance();}else if(next==hash&&input.peek(1)==braceL){input.acceptToken(InterpolationStart,2);break;}else{if(inside)input.acceptToken(next==parenL?callee:dashes==2&&stack.canShift(VariableName)?VariableName:identifier);break;}}});const interpolationEnd=new ExternalTokenizer(input=>{if(input.next==braceR){input.advance();while(isAlpha$2(input.next)||input.next==dash||input.next==underscore||isDigit$1(input.next))input.advance();if(input.next==hash&&input.peek(1)==braceL)input.acceptToken(InterpolationContinue,2);else input.acceptToken(InterpolationEnd);}});const descendant$1=new ExternalTokenizer(input=>{if(space$2.includes(input.peek(-1))){let{next}=input;if(isAlpha$2(next)||next==underscore||next==hash||next==period||next==bracketL||next==colon||next==dash)input.acceptToken(descendantOp$1);}});const unitToken$1=new ExternalTokenizer(input=>{if(!space$2.includes(input.peek(-1))){let{next}=input;if(next==percent){input.advance();input.acceptToken(Unit$1);}if(isAlpha$2(next)){do{input.advance();}while(isAlpha$2(input.next));input.acceptToken(Unit$1);}}});function IndentLevel(parent,depth){this.parent=parent;this.depth=depth;this.hash=(parent?parent.hash+parent.hash<<8:0)+depth+(depth<<4);}const topIndent=new IndentLevel(null,0);const trackIndent=new ContextTracker({start:topIndent,shift(context,term,stack,input){if(term==indent)return new IndentLevel(context,stack.pos-input.pos);if(term==dedent)return context.parent;return context;},hash(context){return context.hash;}});const cssHighlighting=styleTags({"AtKeyword import charset namespace keyframes media supports include mixin use forward extend at-root":tags$1.definitionKeyword,"Keyword selector":tags$1.keyword,"ControlKeyword":tags$1.controlKeyword,NamespaceName:tags$1.namespace,KeyframeName:tags$1.labelName,TagName:tags$1.tagName,ClassName:tags$1.className,PseudoClassName:tags$1.constant(tags$1.className),IdName:tags$1.labelName,"FeatureName PropertyName":tags$1.propertyName,AttributeName:tags$1.attributeName,NumberLiteral:tags$1.number,KeywordQuery:tags$1.keyword,UnaryQueryOp:tags$1.operatorKeyword,"CallTag ValueName":tags$1.atom,VariableName:tags$1.variableName,SassVariableName:tags$1.special(tags$1.variableName),Callee:tags$1.operatorKeyword,Unit:tags$1.unit,"UniversalSelector NestingSelector IndentedMixin IndentedInclude":tags$1.definitionOperator,MatchOp:tags$1.compareOperator,"ChildOp SiblingOp, LogicOp":tags$1.logicOperator,BinOp:tags$1.arithmeticOperator,"Important Global Default":tags$1.modifier,Comment:tags$1.blockComment,LineComment:tags$1.lineComment,ParenthesizedContent:tags$1.special(tags$1.name),ColorLiteral:tags$1.color,StringLiteral:tags$1.string,"InterpolationStart InterpolationContinue InterpolationEnd":tags$1.meta,": \"...\"":tags$1.punctuation,"PseudoOp #":tags$1.derefOperator,"; ,":tags$1.separator,"( )":tags$1.paren,"[ ]":tags$1.squareBracket,"{ }":tags$1.brace});const spec_identifier$2={__proto__:null,not:58,only:58,using:169,with:179,without:179,hide:193,show:193,from:216,to:218,if:231,through:237,in:243};const spec_callee={__proto__:null,url:76,"url-prefix":76,domain:76,regexp:76,lang:90,"nth-child":90,"nth-last-child":90,"nth-of-type":90,"nth-last-of-type":90,dir:90,"host-context":90,selector:162};const spec_AtKeyword$1={__proto__:null,"@import":146,"@include":166,"@mixin":172,"@function":172,"@use":176,"@extend":182,"@at-root":186,"@forward":190,"@media":196,"@charset":200,"@namespace":204,"@keyframes":210,"@supports":222,"@if":226,"@else":228,"@for":234,"@each":240,"@while":246,"@debug":250,"@warn":250,"@error":250,"@return":250};const parser$9=LRParser.deserialize({version:14,states:"HzQ`Q+tOOO#cQ+tOOP#jOpOOO#oQ(pO'#CjOOQ#U'#Ci'#CiO$gQ.jO'#ClO%_Q#dO'#DUO&UQ(pO'#CgO&]Q)OO'#DWO&hQ#dO'#D_O&mQ#dO'#DcOOQ#U'#Fp'#FpO&rQ(pO'#FpO'jQ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![J|![!c$R!c!}J|!}#T$R#T#oJ|#o;'S$R;'S;=`$d<%lO$RXLOS!WPOy$Rz;'S$R;'S;=`$d<%lO$R^LaS!UUOy$Rz;'S$R;'S;=`$d<%lO$R[LpUOy$Rz!_$R!_!`;T!`;'S$R;'S;=`$d<%lO$RZMVUOy$Rz#b$R#b#cMi#c;'S$R;'S;=`$d<%lO$RZMnUwWOy$Rz#W$R#W#XNQ#X;'S$R;'S;=`$d<%lO$RZNXSkRwWOy$Rz;'S$R;'S;=`$d<%lO$RZNhUOy$Rz#f$R#f#gNQ#g;'S$R;'S;=`$d<%lO$RZ! PS!aROy$Rz;'S$R;'S;=`$d<%lO$RZ! bS!hROy$Rz;'S$R;'S;=`$d<%lO$R]! sU!_POy$Rz!_$R!_!`;T!`;'S$R;'S;=`$d<%lO$RW!!YP;=`<%l#r",tokenizers:[indentation,descendant$1,interpolationEnd,unitToken$1,identifiers,spaces,comments,indentedMixins,0,1,2,3],topRules:{"StyleSheet":[0,10],"Styles":[1,127]},dialects:{indented:0},specialized:[{term:150,get:value=>spec_identifier$2[value]||-1},{term:149,get:value=>spec_callee[value]||-1},{term:72,get:value=>spec_AtKeyword$1[value]||-1}],tokenPrec:2798});const sassLanguage=LRLanguage.define({name:"sass",parser:parser$9.configure({props:[foldNodeProp.add({Block:foldInside,Comment(node,state){return{from:node.from+2,to:state.sliceDoc(node.to-2,node.to)=="*/"?node.to-2:node.to};}}),indentNodeProp.add({Declaration:continuedIndent()})]}),languageData:{commentTokens:{block:{open:"/*",close:"*/"},line:"//"},indentOnInput:/^\s*\}$/,wordChars:"$-"}});const indentedSassLanguage=sassLanguage.configure({dialect:"indented",props:[indentNodeProp.add({"Block RuleSet":cx=>cx.baseIndent+cx.unit}),foldNodeProp.add({Block:node=>({from:node.from,to:node.to})})]});const sassCompletionSource=defineCSSCompletionSource(node=>node.name=="VariableName"||node.name=="SassVariableName");function sass(config){return new LanguageSupport((config===null||config===void 0?void 0:config.indented)?indentedSassLanguage:sassLanguage,sassLanguage.data.of({autocomplete:sassCompletionSource}));}var _m16=Object.freeze({__proto__:null,sass:sass,sassCompletionSource:sassCompletionSource,sassLanguage:sassLanguage});const whitespace=36,LineComment=1,BlockComment=2,String$1=3,Number=4,Bool=5,Null=6,ParenL=7,ParenR=8,BraceL=9,BraceR=10,BracketL=11,BracketR=12,Semi=13,Dot$1=14,Operator=15,Punctuation$1=16,SpecialVar=17,Identifier$1=18,QuotedIdentifier=19,Keyword=20,Type$1=21,Bits=22,Bytes=23,Builtin=24;function isAlpha$1(ch){return ch>=65&&ch<=90||ch>=97&&ch<=122||ch>=48&&ch<=57;}function isHexDigit(ch){return ch>=48&&ch<=57||ch>=97&&ch<=102||ch>=65&&ch<=70;}function readLiteral(input,endQuote,backslashEscapes){for(let escaped=false;;){if(input.next<0)return;if(input.next==endQuote&&!escaped){input.advance();return;}escaped=backslashEscapes&&!escaped&&input.next==92;input.advance();}}function readDoubleDollarLiteral(input){for(;;){if(input.next<0||input.peek(1)<0)return;if(input.next==36&&input.peek(1)==36){input.advance(2);return;}input.advance();}}function readPLSQLQuotedLiteral(input,openDelim){let matchingDelim="[{<(".indexOf(String.fromCharCode(openDelim));let closeDelim=matchingDelim<0?openDelim:"]}>)".charCodeAt(matchingDelim);for(;;){if(input.next<0)return;if(input.next==closeDelim&&input.peek(1)==39){input.advance(2);return;}input.advance();}}function readWord(input,result){for(;;){if(input.next!=95&&!isAlpha$1(input.next))break;if(result!=null)result+=String.fromCharCode(input.next);input.advance();}return result;}function readWordOrQuoted(input){if(input.next==39||input.next==34||input.next==96){let quote=input.next;input.advance();readLiteral(input,quote,false);}else{readWord(input);}}function readBits(input,endQuote){while(input.next==48||input.next==49)input.advance();if(endQuote&&input.next==endQuote)input.advance();}function readNumber(input,sawDot){for(;;){if(input.next==46){if(sawDot)break;sawDot=true;}else if(input.next<48||input.next>57){break;}input.advance();}if(input.next==69||input.next==101){input.advance();if(input.next==43||input.next==45)input.advance();while(input.next>=48&&input.next<=57)input.advance();}}function eol(input){while(!(input.next<0||input.next==10))input.advance();}function inString(ch,str){for(let i=0;i!=&|~^/",specialVar:"?",identifierQuotes:'"',words:keywords(SQLKeywords,SQLTypes)};function dialect(spec,kws,types,builtin){let dialect={};for(let prop in defaults)dialect[prop]=(spec.hasOwnProperty(prop)?spec:defaults)[prop];if(kws)dialect.words=keywords(kws,types||"",builtin);return dialect;}function tokensFor(d){return new ExternalTokenizer(input=>{var _a;let{next}=input;input.advance();if(inString(next,Space)){while(inString(input.next,Space))input.advance();input.acceptToken(whitespace);}else if(next==36&&input.next==36&&d.doubleDollarQuotedStrings){readDoubleDollarLiteral(input);input.acceptToken(String$1);}else if(next==39||next==34&&d.doubleQuotedStrings){readLiteral(input,next,d.backslashEscapes);input.acceptToken(String$1);}else if(next==35&&d.hashComments||next==47&&input.next==47&&d.slashComments){eol(input);input.acceptToken(LineComment);}else if(next==45&&input.next==45&&(!d.spaceAfterDashes||input.peek(1)==32)){eol(input);input.acceptToken(LineComment);}else if(next==47&&input.next==42){input.advance();for(let depth=1;;){let cur=input.next;if(input.next<0)break;input.advance();if(cur==42&&input.next==47){depth--;input.advance();if(!depth)break;}else if(cur==47&&input.next==42){depth++;input.advance();}}input.acceptToken(BlockComment);}else if((next==101||next==69)&&input.next==39){input.advance();readLiteral(input,39,true);}else if((next==110||next==78)&&input.next==39&&d.charSetCasts){input.advance();readLiteral(input,39,d.backslashEscapes);input.acceptToken(String$1);}else if(next==95&&d.charSetCasts){for(let i=0;;i++){if(input.next==39&&i>1){input.advance();readLiteral(input,39,d.backslashEscapes);input.acceptToken(String$1);break;}if(!isAlpha$1(input.next))break;input.advance();}}else if(d.plsqlQuotingMechanism&&(next==113||next==81)&&input.next==39&&input.peek(1)>0&&!inString(input.peek(1),Space)){let openDelim=input.peek(1);input.advance(2);readPLSQLQuotedLiteral(input,openDelim);input.acceptToken(String$1);}else if(next==40){input.acceptToken(ParenL);}else if(next==41){input.acceptToken(ParenR);}else if(next==123){input.acceptToken(BraceL);}else if(next==125){input.acceptToken(BraceR);}else if(next==91){input.acceptToken(BracketL);}else if(next==93){input.acceptToken(BracketR);}else if(next==59){input.acceptToken(Semi);}else if(d.unquotedBitLiterals&&next==48&&input.next==98){input.advance();readBits(input);input.acceptToken(Bits);}else if((next==98||next==66)&&(input.next==39||input.next==34)){const quoteStyle=input.next;input.advance();if(d.treatBitsAsBytes){readLiteral(input,quoteStyle,d.backslashEscapes);input.acceptToken(Bytes);}else{readBits(input,quoteStyle);input.acceptToken(Bits);}}else if(next==48&&(input.next==120||input.next==88)||(next==120||next==88)&&input.next==39){let quoted=input.next==39;input.advance();while(isHexDigit(input.next))input.advance();if(quoted&&input.next==39)input.advance();input.acceptToken(Number);}else if(next==46&&input.next>=48&&input.next<=57){readNumber(input,true);input.acceptToken(Number);}else if(next==46){input.acceptToken(Dot$1);}else if(next>=48&&next<=57){readNumber(input,false);input.acceptToken(Number);}else if(inString(next,d.operatorChars)){while(inString(input.next,d.operatorChars))input.advance();input.acceptToken(Operator);}else if(inString(next,d.specialVar)){if(input.next==next)input.advance();readWordOrQuoted(input);input.acceptToken(SpecialVar);}else if(inString(next,d.identifierQuotes)){readLiteral(input,next,false);input.acceptToken(QuotedIdentifier);}else if(next==58||next==44){input.acceptToken(Punctuation$1);}else if(isAlpha$1(next)){let word=readWord(input,String.fromCharCode(next));input.acceptToken(input.next==46?Identifier$1:(_a=d.words[word.toLowerCase()])!==null&&_a!==void 0?_a:Identifier$1);}});}const tokens=tokensFor(defaults);const parser$1$1=LRParser.deserialize({version:14,states:"%vQ]QQOOO#wQRO'#DSO$OQQO'#CwO%eQQO'#CxO%lQQO'#CyO%sQQO'#CzOOQQ'#DS'#DSOOQQ'#C}'#C}O'UQRO'#C{OOQQ'#Cv'#CvOOQQ'#C|'#C|Q]QQOOQOQQOOO'`QQO'#DOO(xQRO,59cO)PQQO,59cO)UQQO'#DSOOQQ,59d,59dO)cQQO,59dOOQQ,59e,59eO)jQQO,59eOOQQ,59f,59fO)qQQO,59fOOQQ-E6{-E6{OOQQ,59b,59bOOQQ-E6z-E6zOOQQ,59j,59jOOQQ-E6|-E6|O+VQRO1G.}O+^QQO,59cOOQQ1G/O1G/OOOQQ1G/P1G/POOQQ1G/Q1G/QP+kQQO'#C}O+rQQO1G.}O)PQQO,59cO,PQQO'#Cw",stateData:",[~OtOSPOSQOS~ORUOSUOTUOUUOVROXSOZTO]XO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O^]ORvXSvXTvXUvXVvXXvXZvX]vX_vX`vXavXbvXcvXdvXevXfvXgvXhvX~OsvX~P!jOa_Ob_Oc_O~ORUOSUOTUOUUOVROXSOZTO^tO_UO`UOa`Ob`Oc`OdUOeUOfUOgUOhUO~OWaO~P$ZOYcO~P$ZO[eO~P$ZORUOSUOTUOUUOVROXSOZTO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O]hOsoX~P%zOajObjOcjO~O^]ORkaSkaTkaUkaVkaXkaZka]ka_ka`kaakabkackadkaekafkagkahka~Oska~P'kO^]O~OWvXYvX[vX~P!jOWnO~P$ZOYoO~P$ZO[pO~P$ZO^]ORkiSkiTkiUkiVkiXkiZki]ki_ki`kiakibkickidkiekifkigkihki~Oski~P)xOWkaYka[ka~P'kO]hO~P$ZOWkiYki[ki~P)xOasObsOcsO~O",goto:"#hwPPPPPPPPPPPPPPPPPPPPPPPPPPx||||!Y!^!d!xPPP#[TYOZeUORSTWZbdfqT[OZQZORiZSWOZQbRQdSQfTZgWbdfqQ^PWk^lmrQl_Qm`RrseVORSTWZbdfq",nodeNames:"⚠ LineComment BlockComment String Number Bool Null ( ) { } [ ] ; . Operator Punctuation SpecialVar Identifier QuotedIdentifier Keyword Type Bits Bytes Builtin Script Statement CompositeIdentifier Parens Braces Brackets Statement",maxTerm:38,skippedNodes:[0,1,2],repeatNodeCount:3,tokenData:"RORO",tokenizers:[0,tokens],topRules:{"Script":[0,25]},tokenPrec:0});function tokenBefore(tree){let cursor=tree.cursor().moveTo(tree.from,-1);while(/Comment/.test(cursor.name))cursor.moveTo(cursor.from,-1);return cursor.node;}function idName(doc,node){let text=doc.sliceString(node.from,node.to);let quoted=/^([`'"])(.*)\1$/.exec(text);return quoted?quoted[2]:text;}function plainID(node){return node&&(node.name=="Identifier"||node.name=="QuotedIdentifier");}function pathFor(doc,id){if(id.name=="CompositeIdentifier"){let path=[];for(let ch=id.firstChild;ch;ch=ch.nextSibling)if(plainID(ch))path.push(idName(doc,ch));return path;}return[idName(doc,id)];}function parentsFor(doc,node){for(let path=[];;){if(!node||node.name!=".")return path;let name=tokenBefore(node);if(!plainID(name))return path;path.unshift(idName(doc,name));node=tokenBefore(name);}}function sourceContext(state,startPos){let pos=syntaxTree(state).resolveInner(startPos,-1);let aliases=getAliases(state.doc,pos);if(pos.name=="Identifier"||pos.name=="QuotedIdentifier"||pos.name=="Keyword"){return{from:pos.from,quoted:pos.name=="QuotedIdentifier"?state.doc.sliceString(pos.from,pos.from+1):null,parents:parentsFor(state.doc,tokenBefore(pos)),aliases};}if(pos.name=="."){return{from:startPos,quoted:null,parents:parentsFor(state.doc,pos),aliases};}else{return{from:startPos,quoted:null,parents:[],empty:true,aliases};}}const EndFrom=new Set("where group having order union intersect except all distinct limit offset fetch for".split(" "));function getAliases(doc,at){let statement;for(let parent=at;!statement;parent=parent.parent){if(!parent)return null;if(parent.name=="Statement")statement=parent;}let aliases=null;for(let scan=statement.firstChild,sawFrom=false,prevID=null;scan;scan=scan.nextSibling){let kw=scan.name=="Keyword"?doc.sliceString(scan.from,scan.to).toLowerCase():null;let alias=null;if(!sawFrom){sawFrom=kw=="from";}else if(kw=="as"&&prevID&&plainID(scan.nextSibling)){alias=idName(doc,scan.nextSibling);}else if(kw&&EndFrom.has(kw)){break;}else if(prevID&&plainID(scan)){alias=idName(doc,scan);}if(alias){if(!aliases)aliases=Object.create(null);aliases[alias]=pathFor(doc,prevID);}prevID=/Identifier$/.test(scan.name)?scan:null;}return aliases;}function maybeQuoteCompletions(quote,completions){if(!quote)return completions;return completions.map(c=>Object.assign(Object.assign({},c),{label:quote+c.label+quote,apply:undefined}));}const Span=/^\w*$/,QuotedSpan=/^[`'"]?\w*[`'"]?$/;class CompletionLevel{constructor(){this.list=[];this.children=undefined;}child(name,idQuote){let children=this.children||(this.children=Object.create(null));let found=children[name];if(found)return found;if(name)this.list.push(nameCompletion(name,"type",idQuote));return children[name]=new CompletionLevel();}addCompletions(list){for(let _i273=0,_length273=list.length;_i273<_length273;_i273++){let option=list[_i273];let found=this.list.findIndex(o=>o.label==option.label);if(found>-1)this.list[found]=option;else this.list.push(option);}}}function nameCompletion(label,type,idQuote){if(!/[^\w\xb5-\uffff]/.test(label))return{label,type};return{label,type,apply:idQuote+label+idQuote};}function completeFromSchema$1(schema,tables,schemas,defaultTableName,defaultSchemaName,dialect){var _a;let top=new CompletionLevel();let idQuote=((_a=dialect===null||dialect===void 0?void 0:dialect.spec.identifierQuotes)===null||_a===void 0?void 0:_a[0])||'"';let defaultSchema=top.child(defaultSchemaName||"",idQuote);for(let table in schema){let parts=table.replace(/\\?\./g,p=>p=="."?"\0":p).split("\0");let base=parts.length==1?defaultSchema:top;for(let _i274=0,_length274=parts.length;_i274<_length274;_i274++){let part=parts[_i274];base=base.child(part.replace(/\\\./g,"."),idQuote);}for(let _i275=0,_schema$table=schema[table],_length275=_schema$table.length;_i275<_length275;_i275++){let option=_schema$table[_i275];if(option)base.list.push(typeof option=="string"?nameCompletion(option,"property",idQuote):option);}}if(tables)defaultSchema.addCompletions(tables);if(schemas)top.addCompletions(schemas);top.addCompletions(defaultSchema.list);if(defaultTableName)top.addCompletions(defaultSchema.child(defaultTableName,idQuote).list);return context=>{let{parents,from,quoted,empty,aliases}=sourceContext(context.state,context.pos);if(empty&&!context.explicit)return null;if(aliases&&parents.length==1)parents=aliases[parents[0]]||parents;let level=top;for(let _i276=0,_parents=parents,_length276=_parents.length;_i276<_length276;_i276++){let name=_parents[_i276];while(!level.children||!level.children[name]){if(level==top)level=defaultSchema;else if(level==defaultSchema&&defaultTableName)level=level.child(defaultTableName,idQuote);else return null;}level=level.child(name,idQuote);}let quoteAfter=quoted&&context.state.sliceDoc(context.pos,context.pos+1)==quoted;let options=level.list;if(level==top&&aliases)options=options.concat(Object.keys(aliases).map(name=>({label:name,type:"constant"})));return{from,to:quoteAfter?context.pos+1:undefined,options:maybeQuoteCompletions(quoted,options),validFor:quoted?QuotedSpan:Span};};}function completeKeywords(keywords,upperCase){let completions=Object.keys(keywords).map(keyword=>({label:upperCase?keyword.toUpperCase():keyword,type:keywords[keyword]==Type$1?"type":keywords[keyword]==Keyword?"keyword":"variable",boost:-1}));return ifNotIn(["QuotedIdentifier","SpecialVar","String","LineComment","BlockComment","."],completeFromList(completions));}let parser$8=parser$1$1.configure({props:[indentNodeProp.add({Statement:continuedIndent()}),foldNodeProp.add({Statement(tree){return{from:tree.firstChild.to,to:tree.to};},BlockComment(tree){return{from:tree.from+2,to:tree.to-2};}}),styleTags({Keyword:tags$1.keyword,Type:tags$1.typeName,Builtin:tags$1.standard(tags$1.name),Bits:tags$1.number,Bytes:tags$1.string,Bool:tags$1.bool,Null:tags$1.null,Number:tags$1.number,String:tags$1.string,Identifier:tags$1.name,QuotedIdentifier:tags$1.special(tags$1.string),SpecialVar:tags$1.special(tags$1.name),LineComment:tags$1.lineComment,BlockComment:tags$1.blockComment,Operator:tags$1.operator,"Semi Punctuation":tags$1.punctuation,"( )":tags$1.paren,"{ }":tags$1.brace,"[ ]":tags$1.squareBracket})]});class SQLDialect{constructor(dialect,language,spec){this.dialect=dialect;this.language=language;this.spec=spec;}get extension(){return this.language.extension;}static define(spec){let d=dialect(spec,spec.keywords,spec.types,spec.builtin);let language=LRLanguage.define({name:"sql",parser:parser$8.configure({tokenizers:[{from:tokens,to:tokensFor(d)}]}),languageData:{commentTokens:{line:"--",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]}}});return new SQLDialect(d,language,spec);}}function keywordCompletionSource(dialect,upperCase=false){return completeKeywords(dialect.dialect.words,upperCase);}function keywordCompletion(dialect,upperCase=false){return dialect.language.data.of({autocomplete:keywordCompletionSource(dialect,upperCase)});}function schemaCompletionSource(config){return config.schema?completeFromSchema$1(config.schema,config.tables,config.schemas,config.defaultTable,config.defaultSchema,config.dialect||StandardSQL):()=>null;}function schemaCompletion(config){return config.schema?(config.dialect||StandardSQL).language.data.of({autocomplete:schemaCompletionSource(config)}):[];}function sql(config={}){let lang=config.dialect||StandardSQL;return new LanguageSupport(lang.language,[schemaCompletion(config),keywordCompletion(lang,!!config.upperCaseKeywords)]);}const StandardSQL=SQLDialect.define({});const PostgreSQL=SQLDialect.define({charSetCasts:true,doubleDollarQuotedStrings:true,operatorChars:"+-*/<>=~!@#%^&|`?",specialVar:"",keywords:SQLKeywords+"a abort abs absent access according ada admin aggregate alias also always analyse analyze array_agg array_max_cardinality asensitive assert assignment asymmetric atomic attach attribute attributes avg backward base64 begin_frame begin_partition bernoulli bit_length blocked bom c cache called cardinality catalog_name ceil ceiling chain char_length character_length character_set_catalog character_set_name character_set_schema characteristics characters checkpoint class class_origin cluster coalesce cobol collation_catalog collation_name collation_schema collect column_name columns command_function command_function_code comment comments committed concurrently condition_number configuration conflict connection_name constant constraint_catalog constraint_name constraint_schema contains content control conversion convert copy corr cost covar_pop covar_samp csv cume_dist current_catalog current_row current_schema cursor_name database datalink datatype datetime_interval_code datetime_interval_precision db debug defaults defined definer degree delimiter delimiters dense_rank depends derived detach detail dictionary disable discard dispatch dlnewcopy dlpreviouscopy dlurlcomplete dlurlcompleteonly dlurlcompletewrite dlurlpath dlurlpathonly dlurlpathwrite dlurlscheme dlurlserver dlvalue document dump dynamic_function dynamic_function_code element elsif empty enable encoding encrypted end_frame end_partition endexec enforced enum errcode error event every exclude excluding exclusive exp explain expression extension extract family file filter final first_value flag floor following force foreach fortran forward frame_row freeze fs functions fusion g generated granted greatest groups handler header hex hierarchy hint id ignore ilike immediately immutable implementation implicit import include including increment indent index indexes info inherit inherits inline insensitive instance instantiable instead integrity intersection invoker isnull k key_member key_type label lag last_value lead leakproof least length library like_regex link listen ln load location lock locked log logged lower m mapping matched materialized max max_cardinality maxvalue member merge message message_length message_octet_length message_text min minvalue mod mode more move multiset mumps name namespace nfc nfd nfkc nfkd nil normalize normalized nothing notice notify notnull nowait nth_value ntile nullable nullif nulls number occurrences_regex octet_length octets off offset oids operator options ordering others over overlay overriding owned owner p parallel parameter_mode parameter_name parameter_ordinal_position parameter_specific_catalog parameter_specific_name parameter_specific_schema parser partition pascal passing passthrough password percent percent_rank percentile_cont percentile_disc perform period permission pg_context pg_datatype_name pg_exception_context pg_exception_detail pg_exception_hint placing plans pli policy portion position position_regex power precedes preceding prepared print_strict_params procedural procedures program publication query quote raise range rank reassign recheck recovery refresh regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy regr_syy reindex rename repeatable replace replica requiring reset respect restart restore result_oid returned_cardinality returned_length returned_octet_length returned_sqlstate returning reverse routine_catalog routine_name routine_schema routines row_count row_number rowtype rule scale schema_name schemas scope scope_catalog scope_name scope_schema security selective self sensitive sequence sequences serializable server server_name setof share show simple skip slice snapshot source specific_name sqlcode sqlerror sqrt stable stacked standalone statement statistics stddev_pop stddev_samp stdin stdout storage strict strip structure style subclass_origin submultiset subscription substring substring_regex succeeds sum symmetric sysid system system_time t table_name tables tablesample tablespace temp template ties token top_level_count transaction_active transactions_committed transactions_rolled_back transform transforms translate translate_regex trigger_catalog trigger_name trigger_schema trim trim_array truncate trusted type types uescape unbounded uncommitted unencrypted unlink unlisten unlogged unnamed untyped upper uri use_column use_variable user_defined_type_catalog user_defined_type_code user_defined_type_name user_defined_type_schema vacuum valid validate validator value_of var_pop var_samp varbinary variable_conflict variadic verbose version versioning views volatile warning whitespace width_bucket window within wrapper xmlagg xmlattributes xmlbinary xmlcast xmlcomment xmlconcat xmldeclaration xmldocument xmlelement xmlexists xmlforest xmliterate xmlnamespaces xmlparse xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltext xmlvalidate yes",types:SQLTypes+"bigint int8 bigserial serial8 varbit bool box bytea cidr circle precision float8 inet int4 json jsonb line lseg macaddr macaddr8 money numeric pg_lsn point polygon float4 int2 smallserial serial2 serial serial4 text timetz timestamptz tsquery tsvector txid_snapshot uuid xml"});const MySQLKeywords="accessible algorithm analyze asensitive authors auto_increment autocommit avg avg_row_length binlog btree cache catalog_name chain change changed checkpoint checksum class_origin client_statistics coalesce code collations columns comment committed completion concurrent consistent contains contributors convert database databases day_hour day_microsecond day_minute day_second delay_key_write delayed delimiter des_key_file dev_pop dev_samp deviance directory disable discard distinctrow div dual dumpfile enable enclosed ends engine engines enum errors escaped even event events every explain extended fast field fields flush force found_rows fulltext grants handler hash high_priority hosts hour_microsecond hour_minute hour_second ignore ignore_server_ids import index index_statistics infile innodb insensitive insert_method install invoker iterate keys kill linear lines list load lock logs low_priority master master_heartbeat_period master_ssl_verify_server_cert masters max max_rows maxvalue message_text middleint migrate min min_rows minute_microsecond minute_second mod mode modify mutex mysql_errno no_write_to_binlog offline offset one online optimize optionally outfile pack_keys parser partition partitions password phase plugin plugins prev processlist profile profiles purge query quick range read_write rebuild recover regexp relaylog remove rename reorganize repair repeatable replace require resume rlike row_format rtree schedule schema_name schemas second_microsecond security sensitive separator serializable server share show slave slow snapshot soname spatial sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_no_cache sql_small_result ssl starting starts std stddev stddev_pop stddev_samp storage straight_join subclass_origin sum suspend table_name table_statistics tables tablespace terminated triggers truncate uncommitted uninstall unlock upgrade use use_frm user_resources user_statistics utc_date utc_time utc_timestamp variables views warnings xa xor year_month zerofill";const MySQLTypes=SQLTypes+"bool blob long longblob longtext medium mediumblob mediumint mediumtext tinyblob tinyint tinytext text bigint int1 int2 int3 int4 int8 float4 float8 varbinary varcharacter precision datetime unsigned signed";const MySQLBuiltin="charset clear edit ego help nopager notee nowarning pager print prompt quit rehash source status system tee";const MySQL=SQLDialect.define({operatorChars:"*+-%<>!=&|^",charSetCasts:true,doubleQuotedStrings:true,unquotedBitLiterals:true,hashComments:true,spaceAfterDashes:true,specialVar:"@?",identifierQuotes:"`",keywords:SQLKeywords+"group_concat "+MySQLKeywords,types:MySQLTypes,builtin:MySQLBuiltin});const MariaSQL=SQLDialect.define({operatorChars:"*+-%<>!=&|^",charSetCasts:true,doubleQuotedStrings:true,unquotedBitLiterals:true,hashComments:true,spaceAfterDashes:true,specialVar:"@?",identifierQuotes:"`",keywords:SQLKeywords+"always generated groupby_concat hard persistent shutdown soft virtual "+MySQLKeywords,types:MySQLTypes,builtin:MySQLBuiltin});const MSSQL=SQLDialect.define({keywords:SQLKeywords+"trigger proc view index for add constraint key primary foreign collate clustered nonclustered declare exec go if use index holdlock nolock nowait paglock pivot readcommitted readcommittedlock readpast readuncommitted repeatableread rowlock serializable snapshot tablock tablockx unpivot updlock with",types:SQLTypes+"bigint smallint smallmoney tinyint money real text nvarchar ntext varbinary image hierarchyid uniqueidentifier sql_variant xml",builtin:"binary_checksum checksum connectionproperty context_info current_request_id error_line error_message error_number error_procedure error_severity error_state formatmessage get_filestream_transaction_context getansinull host_id host_name isnull isnumeric min_active_rowversion newid newsequentialid rowcount_big xact_state object_id",operatorChars:"*+-%<>!=^&|/",specialVar:"@"});const SQLite=SQLDialect.define({keywords:SQLKeywords+"abort analyze attach autoincrement conflict database detach exclusive fail glob ignore index indexed instead isnull notnull offset plan pragma query raise regexp reindex rename replace temp vacuum virtual",types:SQLTypes+"bool blob long longblob longtext medium mediumblob mediumint mediumtext tinyblob tinyint tinytext text bigint int2 int8 unsigned signed real",builtin:"auth backup bail changes clone databases dbinfo dump echo eqp explain fullschema headers help import imposter indexes iotrace lint load log mode nullvalue once print prompt quit restore save scanstats separator shell show stats system tables testcase timeout timer trace vfsinfo vfslist vfsname width",operatorChars:"*+-%<>!=&|/~",identifierQuotes:"`\"",specialVar:"@:?$"});const Cassandra=SQLDialect.define({keywords:"add all allow alter and any apply as asc authorize batch begin by clustering columnfamily compact consistency count create custom delete desc distinct drop each_quorum exists filtering from grant if in index insert into key keyspace keyspaces level limit local_one local_quorum modify nan norecursive nosuperuser not of on one order password permission permissions primary quorum rename revoke schema select set storage superuser table three to token truncate ttl two type unlogged update use user users using values where with writetime infinity NaN",types:SQLTypes+"ascii bigint blob counter frozen inet list map static text timeuuid tuple uuid varint",slashComments:true});const PLSQL=SQLDialect.define({keywords:SQLKeywords+"abort accept access add all alter and any arraylen as asc assert assign at attributes audit authorization avg base_table begin between binary_integer body by case cast char_base check close cluster clusters colauth column comment commit compress connected constant constraint crash create current currval cursor data_base database dba deallocate debugoff debugon declare default definition delay delete desc digits dispose distinct do drop else elseif elsif enable end entry exception exception_init exchange exclusive exists external fast fetch file for force form from function generic goto grant group having identified if immediate in increment index indexes indicator initial initrans insert interface intersect into is key level library like limited local lock log logging loop master maxextents maxtrans member minextents minus mislabel mode modify multiset new next no noaudit nocompress nologging noparallel not nowait number_base of off offline on online only option or order out package parallel partition pctfree pctincrease pctused pls_integer positive positiven pragma primary prior private privileges procedure public raise range raw rebuild record ref references refresh rename replace resource restrict return returning returns reverse revoke rollback row rowid rowlabel rownum rows run savepoint schema segment select separate set share snapshot some space split sql start statement storage subtype successful synonym tabauth table tables tablespace task terminate then to trigger truncate type union unique unlimited unrecoverable unusable update use using validate value values variable view views when whenever where while with work",builtin:"appinfo arraysize autocommit autoprint autorecovery autotrace blockterminator break btitle cmdsep colsep compatibility compute concat copycommit copytypecheck define echo editfile embedded feedback flagger flush heading headsep instance linesize lno loboffset logsource longchunksize markup native newpage numformat numwidth pagesize pause pno recsep recsepchar repfooter repheader serveroutput shiftinout show showmode spool sqlblanklines sqlcase sqlcode sqlcontinue sqlnumber sqlpluscompatibility sqlprefix sqlprompt sqlterminator suffix tab term termout timing trimout trimspool ttitle underline verify version wrap",types:SQLTypes+"ascii bfile bfilename bigserial bit blob dec long number nvarchar nvarchar2 serial smallint string text uid varchar2 xml",operatorChars:"*/+-%<>!=~",doubleQuotedStrings:true,charSetCasts:true,plsqlQuotingMechanism:true});var _m18=Object.freeze({__proto__:null,Cassandra:Cassandra,MSSQL:MSSQL,MariaSQL:MariaSQL,MySQL:MySQL,PLSQL:PLSQL,PostgreSQL:PostgreSQL,SQLDialect:SQLDialect,SQLite:SQLite,StandardSQL:StandardSQL,keywordCompletion:keywordCompletion,keywordCompletionSource:keywordCompletionSource,schemaCompletion:schemaCompletion,schemaCompletionSource:schemaCompletionSource,sql:sql});const closureParamDelim=1,tpOpen=2,tpClose=3,RawString=4,Float=5;const _b=98,_e=101,_f=102,_r=114,_E=69,Zero=48,Dot=46,Plus=43,Minus=45,Hash=35,Quote=34,Pipe=124,LessThan=60,GreaterThan=62;function isNum(ch){return ch>=48&&ch<=57;}function isNum_(ch){return isNum(ch)||ch==95;}const literalTokens=new ExternalTokenizer((input,stack)=>{if(isNum(input.next)){let isFloat=false;do{input.advance();}while(isNum_(input.next));if(input.next==Dot){isFloat=true;input.advance();if(isNum(input.next)){do{input.advance();}while(isNum_(input.next));}else if(input.next==Dot||input.next>0x7f||/\w/.test(String.fromCharCode(input.next))){return;}}if(input.next==_e||input.next==_E){isFloat=true;input.advance();if(input.next==Plus||input.next==Minus)input.advance();if(!isNum_(input.next))return;do{input.advance();}while(isNum_(input.next));}if(input.next==_f){let after=input.peek(1);if(after==Zero+3&&input.peek(2)==Zero+2||after==Zero+6&&input.peek(2)==Zero+4){input.advance(3);isFloat=true;}else{return;}}if(isFloat)input.acceptToken(Float);}else if(input.next==_b||input.next==_r){if(input.next==_b)input.advance();if(input.next!=_r)return;input.advance();let count=0;while(input.next==Hash){count++;input.advance();}if(input.next!=Quote)return;input.advance();content:for(;;){if(input.next<0)return;let isQuote=input.next==Quote;input.advance();if(isQuote){for(let i=0;i{if(input.next==Pipe)input.acceptToken(closureParamDelim,1);});const tpDelim=new ExternalTokenizer(input=>{if(input.next==LessThan)input.acceptToken(tpOpen,1);else if(input.next==GreaterThan)input.acceptToken(tpClose,1);});const rustHighlighting=styleTags({"const macro_rules struct union enum type fn impl trait let static":tags$1.definitionKeyword,"mod use crate":tags$1.moduleKeyword,"pub unsafe async mut extern default move":tags$1.modifier,"for if else loop while match continue break return await":tags$1.controlKeyword,"as in ref":tags$1.operatorKeyword,"where _ crate super dyn":tags$1.keyword,"self":tags$1.self,String:tags$1.string,Char:tags$1.character,RawString:tags$1.special(tags$1.string),Boolean:tags$1.bool,Identifier:tags$1.variableName,"CallExpression/Identifier":tags$1.function(tags$1.variableName),BoundIdentifier:tags$1.definition(tags$1.variableName),"FunctionItem/BoundIdentifier":tags$1.function(tags$1.definition(tags$1.variableName)),LoopLabel:tags$1.labelName,FieldIdentifier:tags$1.propertyName,"CallExpression/FieldExpression/FieldIdentifier":tags$1.function(tags$1.propertyName),Lifetime:tags$1.special(tags$1.variableName),ScopeIdentifier:tags$1.namespace,TypeIdentifier:tags$1.typeName,"MacroInvocation/Identifier MacroInvocation/ScopedIdentifier/Identifier":tags$1.macroName,"MacroInvocation/TypeIdentifier MacroInvocation/ScopedIdentifier/TypeIdentifier":tags$1.macroName,"\"!\"":tags$1.macroName,UpdateOp:tags$1.updateOperator,LineComment:tags$1.lineComment,BlockComment:tags$1.blockComment,Integer:tags$1.integer,Float:tags$1.float,ArithOp:tags$1.arithmeticOperator,LogicOp:tags$1.logicOperator,BitOp:tags$1.bitwiseOperator,CompareOp:tags$1.compareOperator,"=":tags$1.definitionOperator,".. ... => ->":tags$1.punctuation,"( )":tags$1.paren,"[ ]":tags$1.squareBracket,"{ }":tags$1.brace,". DerefOp":tags$1.derefOperator,"&":tags$1.operator,", ; ::":tags$1.separator,"Attribute/...":tags$1.meta});const spec_identifier$1={__proto__:null,self:28,super:32,crate:34,impl:46,true:72,false:72,pub:88,in:92,const:96,unsafe:104,async:108,move:110,if:114,let:118,ref:142,mut:144,_:198,else:200,match:204,as:248,return:252,await:262,break:270,continue:276,while:312,loop:316,for:320,macro_rules:327,mod:334,extern:342,struct:346,where:364,union:379,enum:382,type:390,default:395,fn:396,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4R4U4_4e4t5`5d5v6R6Y6p6v6x7c7r8gR${xR0b+UR0W*xR0U*xR6{4PR/y*vR/x*vR0P*wR0O*wR0_+QR0^+Q%XyObxz!O!P!Q!T!n$O$u$y$|%_%b%f%n%o%p%q%y%{&P&o&p&r'](q)S)U)i)s)v)x)y*O*P*R*V*[*^*e*n*w*x+U+V+h+o+}-i-t-v.U.`.p.t.x.y/Z/[/{/}0`0r0w1O1Y1Z1y2a2h2j2m2s2v3V3u3{3|4R4U4_4e4t5`5d5v6R6Y6p6v6x7c7r8gR0k+ZR0j+ZQ'R!qQ)c%XQ+w&|R4y1PX'Q!q%X&|1PR+y&|R+x&|T/S*S4TT/R*S4TR.o)sR.n)sR){%p",nodeNames:"⚠ | < > RawString Float LineComment BlockComment SourceFile ] InnerAttribute ! [ MetaItem self Metavariable super crate Identifier ScopedIdentifier :: QualifiedScope AbstractType impl SelfType MetaType TypeIdentifier ScopedTypeIdentifier ScopeIdentifier TypeArgList TypeBinding = Lifetime String Escape Char Boolean Integer } { Block ; ConstItem Vis pub ( in ) const BoundIdentifier : UnsafeBlock unsafe AsyncBlock async move IfExpression if LetDeclaration let LiteralPattern ArithOp MetaPattern SelfPattern ScopedIdentifier TuplePattern ScopedTypeIdentifier , StructPattern FieldPatternList FieldPattern ref mut FieldIdentifier .. RefPattern SlicePattern CapturedPattern ReferencePattern & MutPattern RangePattern ... OrPattern MacroPattern ParenthesizedTokens TokenBinding Identifier TokenRepetition ArithOp BitOp LogicOp UpdateOp CompareOp -> => ArithOp BracketedTokens BracedTokens _ else MatchExpression match MatchBlock MatchArm Attribute Guard UnaryExpression ArithOp DerefOp LogicOp ReferenceExpression TryExpression BinaryExpression ArithOp ArithOp BitOp BitOp BitOp BitOp LogicOp LogicOp AssignmentExpression TypeCastExpression as ReturnExpression return RangeExpression CallExpression ArgList AwaitExpression await FieldExpression GenericFunction BreakExpression break LoopLabel ContinueExpression continue IndexExpression ArrayExpression TupleExpression MacroInvocation UnitExpression ClosureExpression ParamList Parameter Parameter ParenthesizedExpression StructExpression FieldInitializerList ShorthandFieldInitializer FieldInitializer BaseFieldInitializer MatchArm WhileExpression while LoopExpression loop ForExpression for MacroInvocation MacroDefinition macro_rules MacroRule EmptyStatement ModItem mod DeclarationList AttributeItem ForeignModItem extern StructItem struct TypeParamList ConstrainedTypeParameter TraitBounds HigherRankedTraitBound RemovedTraitBound OptionalTypeParameter ConstParameter WhereClause where LifetimeClause TypeBoundClause FieldDeclarationList FieldDeclaration OrderedFieldDeclarationList UnionItem union EnumItem enum EnumVariantList EnumVariant TypeItem type FunctionItem default fn ParamList Parameter SelfParameter VariadicParameter VariadicParameter ImplItem TraitItem trait AssociatedType LetDeclaration UseDeclaration use ScopedIdentifier UseAsClause ScopedIdentifier UseList ScopedUseList UseWildcard ExternCrateDeclaration StaticItem static ExpressionStatement ExpressionStatement GenericType FunctionType ForLifetimes ParamList VariadicParameter Parameter VariadicParameter Parameter ReferenceType PointerType TupleType UnitType ArrayType MacroInvocation EmptyType DynamicType dyn BoundedType",maxTerm:359,nodeProps:[["group",-42,4,5,14,15,16,17,18,19,33,35,36,37,40,51,53,56,101,107,111,112,113,122,123,125,127,128,130,132,133,134,137,139,140,141,142,143,144,148,149,155,157,159,"Expression",-16,22,24,25,26,27,222,223,230,231,232,233,234,235,236,237,239,"Type",-20,42,161,162,165,166,169,170,172,188,190,194,196,204,205,207,208,209,217,218,220,"Statement",-17,49,60,62,63,64,65,68,74,75,76,77,78,80,81,83,84,99,"Pattern"],["openedBy",9,"[",38,"{",47,"("],["closedBy",12,"]",39,"}",45,")"]],propSources:[rustHighlighting],skippedNodes:[0,6,7,240],repeatNodeCount:32,tokenData:"$%h_R!XOX$nXY5gYZ6iZ]$n]^5g^p$npq5gqr7Xrs9cst:Rtu;Tuv>vvwAQwxCbxy!+Tyz!,Vz{!-X{|!/_|}!0g}!O!1i!O!P!3v!P!Q!8[!Q!R!Bw!R![!Dr![!]#+q!]!^#-{!^!_#.}!_!`#1b!`!a#3o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$#m]'|X'_Q'OSOY$nYZ%nZr$nrs&[sz$nz{+O{!P$n!P!Q,z!Q#O$n#O#P&[#P;'S$n;'S;=`4s<%lO$n_$$o]vX'_Q'OSOY$nYZ%nZr$nrs&[sz$nz{+O{!P$n!P!Q,z!Q#O$n#O#P&[#P;'S$n;'S;=`4s<%lO$n",tokenizers:[closureParam,tpDelim,literalTokens,0,1,2,3],topRules:{"SourceFile":[0,8]},specialized:[{term:281,get:value=>spec_identifier$1[value]||-1}],tokenPrec:15596});const rustLanguage=LRLanguage.define({name:"rust",parser:parser$7.configure({props:[indentNodeProp.add({IfExpression:continuedIndent({except:/^\s*({|else\b)/}),"String BlockComment":()=>null,"AttributeItem":cx=>cx.continue(),"Statement MatchArm":continuedIndent()}),foldNodeProp.add(type=>{if(/(Block|edTokens|List)$/.test(type.name))return foldInside;if(type.name=="BlockComment")return tree=>({from:tree.from+2,to:tree.to-2});return undefined;})]}),languageData:{commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:\{|\})$/,closeBrackets:{stringPrefixes:["b","r","br"]}}});function rust(){return new LanguageSupport(rustLanguage);}var _m19=Object.freeze({__proto__:null,rust:rust,rustLanguage:rustLanguage});const StartTag=1,StartCloseTag=2,MissingCloseTag=3,mismatchedStartCloseTag=4,incompleteStartCloseTag=5,commentContent$1=35,piContent$1=36,cdataContent$1=37,Element$3=11,OpenTag=13;function nameChar(ch){return ch==45||ch==46||ch==58||ch>=65&&ch<=90||ch==95||ch>=97&&ch<=122||ch>=161;}function isSpace(ch){return ch==9||ch==10||ch==13||ch==32;}let cachedName=null,cachedInput=null,cachedPos=0;function tagNameAfter(input,offset){let pos=input.pos+offset;if(cachedInput==input&&cachedPos==pos)return cachedName;while(isSpace(input.peek(offset)))offset++;let name="";for(;;){let next=input.peek(offset);if(!nameChar(next))break;name+=String.fromCharCode(next);offset++;}cachedInput=input;cachedPos=pos;return cachedName=name||null;}function ElementContext(name,parent){this.name=name;this.parent=parent;this.hash=parent?parent.hash:0;for(let i=0;i{if(input.next!=60)return;input.advance();if(input.next==47){input.advance();let name=tagNameAfter(input,0);if(!name)return input.acceptToken(incompleteStartCloseTag);if(stack.context&&name==stack.context.name)return input.acceptToken(StartCloseTag);for(let cx=stack.context;cx;cx=cx.parent)if(cx.name==name)return input.acceptToken(MissingCloseTag,-2);input.acceptToken(mismatchedStartCloseTag);}else if(input.next!=33&&input.next!=63){return input.acceptToken(StartTag);}},{contextual:true});function scanTo(type,end){return new ExternalTokenizer(input=>{for(let endPos=0,len=0;;len++){if(input.next<0){if(len)input.acceptToken(type);break;}if(input.next==end.charCodeAt(endPos)){endPos++;if(endPos==end.length){if(len>=end.length)input.acceptToken(type,1-end.length);break;}}else{endPos=input.next==end.charCodeAt(0)?1:0;}input.advance();}});}const commentContent=scanTo(commentContent$1,"-->");const piContent=scanTo(piContent$1,"?>");const cdataContent=scanTo(cdataContent$1,"]]>");const xmlHighlighting=styleTags({Text:tags$1.content,"StartTag StartCloseTag EndTag SelfCloseEndTag":tags$1.angleBracket,TagName:tags$1.tagName,"MismatchedCloseTag/Tagname":[tags$1.tagName,tags$1.invalid],AttributeName:tags$1.attributeName,AttributeValue:tags$1.attributeValue,Is:tags$1.definitionOperator,"EntityReference CharacterReference":tags$1.character,Comment:tags$1.blockComment,ProcessingInst:tags$1.processingInstruction,DoctypeDecl:tags$1.documentMeta,Cdata:tags$1.special(tags$1.string)});const parser$6=LRParser.deserialize({version:14,states:",SOQOaOOOrOxO'#CfOzOpO'#CiO!tOaO'#CgOOOP'#Cg'#CgO!{OrO'#CrO#TOtO'#CsO#]OpO'#CtOOOP'#DS'#DSOOOP'#Cv'#CvQQOaOOOOOW'#Cw'#CwO#eOxO,59QOOOP,59Q,59QOOOO'#Cx'#CxO#mOpO,59TO#uO!bO,59TOOOP'#C{'#C{O$TOaO,59RO$[OpO'#CoOOOP,59R,59ROOOQ'#C|'#C|O$dOrO,59^OOOP,59^,59^OOOS'#C}'#C}O$lOtO,59_OOOP,59_,59_O$tOpO,59`O$|OpO,59`OOOP-E6t-E6tOOOW-E6u-E6uOOOP1G.l1G.lOOOO-E6v-E6vO%UO!bO1G.oO%UO!bO1G.oO%dOpO'#CkO%lO!bO'#CyO%zO!bO1G.oOOOP1G.o1G.oOOOP1G.w1G.wOOOP-E6y-E6yOOOP1G.m1G.mO&VOpO,59ZO&_OpO,59ZOOOQ-E6z-E6zOOOP1G.x1G.xOOOS-E6{-E6{OOOP1G.y1G.yO&gOpO1G.zO&gOpO1G.zOOOP1G.z1G.zO&oO!bO7+$ZO&}O!bO7+$ZOOOP7+$Z7+$ZOOOP7+$c7+$cO'YOpO,59VO'bOpO,59VO'jO!bO,59eOOOO-E6w-E6wO'xOpO1G.uO'xOpO1G.uOOOP1G.u1G.uO(QOpO7+$fOOOP7+$f7+$fO(YO!bO<`#X;'S%y;'S;=`&_<%lO%yX>eV{WOr%ysv%yw#T%y#T#U>z#U;'S%y;'S;=`&_<%lO%yX?PV{WOr%ysv%yw#h%y#h#i?f#i;'S%y;'S;=`&_<%lO%yX?kV{WOr%ysv%yw#T%y#T#Ua.from<=pos&&a.to>=pos);let name=attr&&attr.getChild("AttributeName");return name?doc.sliceString(name.from,name.to):"";}function findParentElement(tree){for(let cur=tree&&tree.parent;cur;cur=cur.parent)if(cur.name=="Element")return cur;return null;}function findLocation(state,pos){var _a;let at=syntaxTree(state).resolveInner(pos,-1),inTag=null;for(let cur=at;!inTag&&cur.parent;cur=cur.parent)if(cur.name=="OpenTag"||cur.name=="CloseTag"||cur.name=="SelfClosingTag"||cur.name=="MismatchedCloseTag")inTag=cur;if(inTag&&(inTag.to>pos||inTag.lastChild.type.isError)){let elt=inTag.parent;if(at.name=="TagName")return inTag.name=="CloseTag"||inTag.name=="MismatchedCloseTag"?{type:"closeTag",from:at.from,context:elt}:{type:"openTag",from:at.from,context:findParentElement(elt)};if(at.name=="AttributeName")return{type:"attrName",from:at.from,context:inTag};if(at.name=="AttributeValue")return{type:"attrValue",from:at.from,context:inTag};let before=at==inTag||at.name=="Attribute"?at.childBefore(pos):at;if((before===null||before===void 0?void 0:before.name)=="StartTag")return{type:"openTag",from:pos,context:findParentElement(elt)};if((before===null||before===void 0?void 0:before.name)=="StartCloseTag"&&before.to<=pos)return{type:"closeTag",from:pos,context:elt};if((before===null||before===void 0?void 0:before.name)=="Is")return{type:"attrValue",from:pos,context:inTag};if(before)return{type:"attrName",from:pos,context:inTag};return null;}else if(at.name=="StartCloseTag"){return{type:"closeTag",from:pos,context:at.parent};}while(at.parent&&at.to==pos&&!((_a=at.lastChild)===null||_a===void 0?void 0:_a.type.isError))at=at.parent;if(at.name=="Element"||at.name=="Text"||at.name=="Document")return{type:"tag",from:pos,context:at.name=="Element"?at:findParentElement(at)};return null;}class Element$2{constructor(spec,attrs,attrValues){this.attrs=attrs;this.attrValues=attrValues;this.children=[];this.name=spec.name;this.completion=Object.assign(Object.assign({type:"type"},spec.completion||{}),{label:this.name});this.openCompletion=Object.assign(Object.assign({},this.completion),{label:"<"+this.name});this.closeCompletion=Object.assign(Object.assign({},this.completion),{label:"",boost:2});this.closeNameCompletion=Object.assign(Object.assign({},this.completion),{label:this.name+">"});this.text=spec.textContent?spec.textContent.map(s=>({label:s,type:"text"})):[];}}const Identifier=/^[:\-\.\w\u00b7-\uffff]*$/;function attrCompletion(spec){return Object.assign(Object.assign({type:"property"},spec.completion||{}),{label:spec.name});}function valueCompletion(spec){return typeof spec=="string"?{label:`"${spec}"`,type:"constant"}:/^"/.test(spec.label)?spec:Object.assign(Object.assign({},spec),{label:`"${spec.label}"`});}function completeFromSchema(eltSpecs,attrSpecs){let allAttrs=[],globalAttrs=[];let attrValues=Object.create(null);for(let _i277=0,_length277=attrSpecs.length;_i277<_length277;_i277++){let s=attrSpecs[_i277];let completion=attrCompletion(s);allAttrs.push(completion);if(s.global)globalAttrs.push(completion);if(s.values)attrValues[s.name]=s.values.map(valueCompletion);}let allElements=[],topElements=[];let byName=Object.create(null);for(let _i278=0,_length278=eltSpecs.length;_i278<_length278;_i278++){let s=eltSpecs[_i278];let attrs=globalAttrs,attrVals=attrValues;if(s.attributes)attrs=attrs.concat(s.attributes.map(s=>{if(typeof s=="string")return allAttrs.find(a=>a.label==s)||{label:s,type:"property"};if(s.values){if(attrVals==attrValues)attrVals=Object.create(attrVals);attrVals[s.name]=s.values.map(valueCompletion);}return attrCompletion(s);}));let elt=new Element$2(s,attrs,attrVals);byName[elt.name]=elt;allElements.push(elt);if(s.top)topElements.push(elt);}if(!topElements.length)topElements=allElements;for(let i=0;i{var _a;let{doc}=cx.state,loc=findLocation(cx.state,cx.pos);if(!loc||loc.type=="tag"&&!cx.explicit)return null;let{type,from,context}=loc;if(type=="openTag"){let children=topElements;let parentName=elementName(doc,context);if(parentName){let parent=byName[parentName];children=(parent===null||parent===void 0?void 0:parent.children)||allElements;}return{from,options:children.map(ch=>ch.completion),validFor:Identifier};}else if(type=="closeTag"){let parentName=elementName(doc,context);return parentName?{from,to:cx.pos+(doc.sliceString(cx.pos,cx.pos+1)==">"?1:0),options:[((_a=byName[parentName])===null||_a===void 0?void 0:_a.closeNameCompletion)||{label:parentName+">",type:"type"}],validFor:Identifier}:null;}else if(type=="attrName"){let parent=byName[tagName(doc,context)];return{from,options:(parent===null||parent===void 0?void 0:parent.attrs)||globalAttrs,validFor:Identifier};}else if(type=="attrValue"){let attr=attrName(doc,context,from);if(!attr)return null;let parent=byName[tagName(doc,context)];let values=((parent===null||parent===void 0?void 0:parent.attrValues)||attrValues)[attr];if(!values||!values.length)return null;return{from,to:cx.pos+(doc.sliceString(cx.pos,cx.pos+1)=='"'?1:0),options:values,validFor:/^"[^"]*"?$/};}else if(type=="tag"){let parentName=elementName(doc,context),parent=byName[parentName];let closing=[],last=context&&context.lastChild;if(parentName&&(!last||last.name!="CloseTag"||tagName(doc,last)!=parentName))closing.push(parent?parent.closeCompletion:{label:"",type:"type",boost:2});let options=closing.concat(((parent===null||parent===void 0?void 0:parent.children)||(context?allElements:topElements)).map(e=>e.openCompletion));if(context&&(parent===null||parent===void 0?void 0:parent.text.length)){let openTag=context.firstChild;if(openTag.to>cx.pos-20&&!/\S/.test(cx.state.sliceDoc(openTag.to,cx.pos)))options=options.concat(parent.text);}return{from,options,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/};}else{return null;}};}const xmlLanguage=LRLanguage.define({name:"xml",parser:parser$6.configure({props:[indentNodeProp.add({Element(context){let closed=/^\s*<\//.test(context.textAfter);return context.lineIndent(context.node.from)+(closed?0:context.unit);},"OpenTag CloseTag SelfClosingTag"(context){return context.column(context.node.from)+context.unit;}}),foldNodeProp.add({Element(subtree){let first=subtree.firstChild,last=subtree.lastChild;if(!first||first.name!="OpenTag")return null;return{from:first.to,to:last.name=="CloseTag"?last.from:subtree.to};}}),bracketMatchingHandle.add({"OpenTag CloseTag":node=>node.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:""}},indentOnInput:/^\s*<\/$/}});function xml(conf={}){return new LanguageSupport(xmlLanguage,xmlLanguage.data.of({autocomplete:completeFromSchema(conf.elements||[],conf.attributes||[])}));}var _m20=Object.freeze({__proto__:null,completeFromSchema:completeFromSchema,xml:xml,xmlLanguage:xmlLanguage});class CompositeBlock{static create(type,value,from,parentHash,end){let hash=parentHash+(parentHash<<8)+type+(value<<4)|0;return new CompositeBlock(type,value,from,hash,end,[],[]);}constructor(type,value,from,hash,end,children,positions){this.type=type;this.value=value;this.from=from;this.hash=hash;this.end=end;this.children=children;this.positions=positions;this.hashProp=[[NodeProp.contextHash,hash]];}addChild(child,pos){if(child.prop(NodeProp.contextHash)!=this.hash)child=new Tree(child.type,child.children,child.positions,child.length,this.hashProp);this.children.push(child);this.positions.push(pos);}toTree(nodeSet,end=this.end){let last=this.children.length-1;if(last>=0)end=Math.max(end,this.positions[last]+this.children[last].length+this.from);let tree=new Tree(nodeSet.types[this.type],this.children,this.positions,end-this.from).balance({makeTree:(children,positions,length)=>new Tree(NodeType.none,children,positions,length,this.hashProp)});return tree;}}var Type;(function(Type){Type[Type["Document"]=1]="Document";Type[Type["CodeBlock"]=2]="CodeBlock";Type[Type["FencedCode"]=3]="FencedCode";Type[Type["Blockquote"]=4]="Blockquote";Type[Type["HorizontalRule"]=5]="HorizontalRule";Type[Type["BulletList"]=6]="BulletList";Type[Type["OrderedList"]=7]="OrderedList";Type[Type["ListItem"]=8]="ListItem";Type[Type["ATXHeading1"]=9]="ATXHeading1";Type[Type["ATXHeading2"]=10]="ATXHeading2";Type[Type["ATXHeading3"]=11]="ATXHeading3";Type[Type["ATXHeading4"]=12]="ATXHeading4";Type[Type["ATXHeading5"]=13]="ATXHeading5";Type[Type["ATXHeading6"]=14]="ATXHeading6";Type[Type["SetextHeading1"]=15]="SetextHeading1";Type[Type["SetextHeading2"]=16]="SetextHeading2";Type[Type["HTMLBlock"]=17]="HTMLBlock";Type[Type["LinkReference"]=18]="LinkReference";Type[Type["Paragraph"]=19]="Paragraph";Type[Type["CommentBlock"]=20]="CommentBlock";Type[Type["ProcessingInstructionBlock"]=21]="ProcessingInstructionBlock";Type[Type["Escape"]=22]="Escape";Type[Type["Entity"]=23]="Entity";Type[Type["HardBreak"]=24]="HardBreak";Type[Type["Emphasis"]=25]="Emphasis";Type[Type["StrongEmphasis"]=26]="StrongEmphasis";Type[Type["Link"]=27]="Link";Type[Type["Image"]=28]="Image";Type[Type["InlineCode"]=29]="InlineCode";Type[Type["HTMLTag"]=30]="HTMLTag";Type[Type["Comment"]=31]="Comment";Type[Type["ProcessingInstruction"]=32]="ProcessingInstruction";Type[Type["URL"]=33]="URL";Type[Type["HeaderMark"]=34]="HeaderMark";Type[Type["QuoteMark"]=35]="QuoteMark";Type[Type["ListMark"]=36]="ListMark";Type[Type["LinkMark"]=37]="LinkMark";Type[Type["EmphasisMark"]=38]="EmphasisMark";Type[Type["CodeMark"]=39]="CodeMark";Type[Type["CodeText"]=40]="CodeText";Type[Type["CodeInfo"]=41]="CodeInfo";Type[Type["LinkTitle"]=42]="LinkTitle";Type[Type["LinkLabel"]=43]="LinkLabel";})(Type||(Type={}));class LeafBlock{constructor(start,content){this.start=start;this.content=content;this.marks=[];this.parsers=[];}}class Line{constructor(){this.text="";this.baseIndent=0;this.basePos=0;this.depth=0;this.markers=[];this.pos=0;this.indent=0;this.next=-1;}forward(){if(this.basePos>this.pos)this.forwardInner();}forwardInner(){let newPos=this.skipSpace(this.basePos);this.indent=this.countIndent(newPos,this.pos,this.indent);this.pos=newPos;this.next=newPos==this.text.length?-1:this.text.charCodeAt(newPos);}skipSpace(from){return skipSpace(this.text,from);}reset(text){this.text=text;this.baseIndent=this.basePos=this.pos=this.indent=0;this.forwardInner();this.depth=1;while(this.markers.length)this.markers.pop();}moveBase(to){this.basePos=to;this.baseIndent=this.countIndent(to,this.pos,this.indent);}moveBaseColumn(indent){this.baseIndent=indent;this.basePos=this.findColumn(indent);}addMarker(elt){this.markers.push(elt);}countIndent(to,from=0,indent=0){for(let i=from;i=cx.stack[line.depth+1].value+line.baseIndent)return true;if(line.indent>=line.baseIndent+4)return false;let size=(bl.type==Type.OrderedList?isOrderedList:isBulletList)(line,cx,false);return size>0&&(bl.type!=Type.BulletList||isHorizontalRule(line,cx,false)<0)&&line.text.charCodeAt(line.pos+size-1)==bl.value;}const DefaultSkipMarkup={[Type.Blockquote](bl,cx,line){if(line.next!=62)return false;line.markers.push(elt(Type.QuoteMark,cx.lineStart+line.pos,cx.lineStart+line.pos+1));line.moveBase(line.pos+(space$1(line.text.charCodeAt(line.pos+1))?2:1));bl.end=cx.lineStart+line.text.length;return true;},[Type.ListItem](bl,_cx,line){if(line.indent-1)return false;line.moveBaseColumn(line.baseIndent+bl.value);return true;},[Type.OrderedList]:skipForList,[Type.BulletList]:skipForList,[Type.Document](){return true;}};function space$1(ch){return ch==32||ch==9||ch==10||ch==13;}function skipSpace(line,i=0){while(ito&&space$1(line.charCodeAt(i-1)))i--;return i;}function isFencedCode(line){if(line.next!=96&&line.next!=126)return-1;let pos=line.pos+1;while(pos-1&&line.depth==cx.stack.length)return-1;return count<3?-1:1;}function inList(cx,type){for(let i=cx.stack.length-1;i>=0;i--)if(cx.stack[i].type==type)return true;return false;}function isBulletList(line,cx,breaking){return(line.next==45||line.next==43||line.next==42)&&(line.pos==line.text.length-1||space$1(line.text.charCodeAt(line.pos+1)))&&(!breaking||inList(cx,Type.BulletList)||line.skipSpace(line.pos+2)=48&&next<=57)pos++;else break;if(pos==line.text.length)return-1;next=line.text.charCodeAt(pos);}if(pos==line.pos||pos>line.pos+9||next!=46&&next!=41||posline.pos+1||line.next!=49))return-1;return pos+1-line.pos;}function isAtxHeading(line){if(line.next!=35)return-1;let pos=line.pos+1;while(pos6?-1:size;}function isSetextUnderline(line){if(line.next!=45&&line.next!=61||line.indent>=line.baseIndent+4)return-1;let pos=line.pos+1;while(pos/,ProcessingEnd=/\?>/;const HTMLBlockStyle=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*/i.exec(after);if(comment)return cx.append(elt(Type.Comment,start,start+1+comment[0].length));let procInst=/^\?[^]*?\?>/.exec(after);if(procInst)return cx.append(elt(Type.ProcessingInstruction,start,start+1+procInst[0].length));let m=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(after);if(!m)return-1;return cx.append(elt(Type.HTMLTag,start,start+1+m[0].length));},Emphasis(cx,next,start){if(next!=95&&next!=42)return-1;let pos=start+1;while(cx.char(pos)==next)pos++;let before=cx.slice(start-1,start),after=cx.slice(pos,pos+1);let pBefore=Punctuation.test(before),pAfter=Punctuation.test(after);let sBefore=/\s|^$/.test(before),sAfter=/\s|^$/.test(after);let leftFlanking=!sAfter&&(!pAfter||sBefore||pBefore);let rightFlanking=!sBefore&&(!pBefore||sAfter||pAfter);let canOpen=leftFlanking&&(next==42||!rightFlanking||pBefore);let canClose=rightFlanking&&(next==42||!leftFlanking||pAfter);return cx.append(new InlineDelimiter(next==95?EmphasisUnderscore:EmphasisAsterisk,start,pos,(canOpen?1:0)|(canClose?2:0)));},HardBreak(cx,next,start){if(next==92&&cx.char(start+1)==10)return cx.append(elt(Type.HardBreak,start,start+2));if(next==32){let pos=start+1;while(cx.char(pos)==32)pos++;if(cx.char(pos)==10&&pos>=start+2)return cx.append(elt(Type.HardBreak,start,pos+1));}return-1;},Link(cx,next,start){return next==91?cx.append(new InlineDelimiter(LinkStart,start,start+1,1)):-1;},Image(cx,next,start){return next==33&&cx.char(start+1)==91?cx.append(new InlineDelimiter(ImageStart,start,start+2,1)):-1;},LinkEnd(cx,next,start){if(next!=93)return-1;for(let i=cx.parts.length-1;i>=0;i--){let part=cx.parts[i];if(part instanceof InlineDelimiter&&(part.type==LinkStart||part.type==ImageStart)){if(!part.side||cx.skipSpace(part.to)==start&&!/[(\[]/.test(cx.slice(start+1,start+2))){cx.parts[i]=null;return-1;}let content=cx.takeContent(i);let link=cx.parts[i]=finishLink(cx,content,part.type==LinkStart?Type.Link:Type.Image,part.from,start+1);if(part.type==LinkStart)for(let j=0;jstart?elt(Type.URL,start+offset,pos+offset):pos==text.length?null:false;}}function parseLinkTitle(text,start,offset){let next=text.charCodeAt(start);if(next!=39&&next!=34&&next!=40)return false;let end=next==40?41:next;for(let pos=start+1,escaped=false;pos=this.end?-1:this.text.charCodeAt(pos-this.offset);}get end(){return this.offset+this.text.length;}slice(from,to){return this.text.slice(from-this.offset,to-this.offset);}append(elt){this.parts.push(elt);return elt.to;}addDelimiter(type,from,to,open,close){return this.append(new InlineDelimiter(type,from,to,(open?1:0)|(close?2:0)));}addElement(elt){return this.append(elt);}resolveMarkers(from){for(let i=from;i=from;j--){let part=this.parts[j];if(part instanceof InlineDelimiter&&part.side&1&&part.type==close.type&&!(emp&&(close.side&1||part.side&2)&&(part.to-part.from+closeSize)%3==0&&((part.to-part.from)%3||closeSize%3))){open=part;break;}}if(!open)continue;let type=close.type.resolve,content=[];let start=open.from,end=close.to;if(emp){let size=Math.min(2,open.to-open.from,closeSize);start=open.to-size;end=close.from+size;type=size==1?"Emphasis":"StrongEmphasis";}if(open.type.mark)content.push(this.elt(open.type.mark,start,open.to));for(let k=j+1;k=0;i--){let part=this.parts[i];if(part instanceof InlineDelimiter&&part.type==type)return i;}return null;}takeContent(startIndex){let content=this.resolveMarkers(startIndex);this.parts.length=startIndex;return content;}skipSpace(from){return skipSpace(this.text,from-this.offset)+this.offset;}elt(type,from,to,children){if(typeof type=="string")return elt(this.parser.getNodeType(type),from,to,children);return new TreeElement(type,from);}}function injectMarks(elements,marks){if(!marks.length)return elements;if(!elements.length)return marks;let elts=elements.slice(),eI=0;for(let _i301=0,_length301=marks.length;_i301<_length301;_i301++){let mark=marks[_i301];while(eI(pos?pos-1:0))return false;if(this.fragmentEnd<0){let end=this.fragment.to;while(end>0&&this.input.read(end-1,end)!="\n")end--;this.fragmentEnd=end?end-1:0;}let c=this.cursor;if(!c){c=this.cursor=this.fragment.tree.cursor();c.firstChild();}let rPos=pos+this.fragment.offset;while(c.to<=rPos)if(!c.parent())return false;for(;;){if(c.from>=rPos)return this.fragment.from<=lineStart;if(!c.childAfter(rPos))return false;}}matches(hash){let tree=this.cursor.tree;return tree&&tree.prop(NodeProp.contextHash)==hash;}takeNodes(cx){let cur=this.cursor,off=this.fragment.offset,fragEnd=this.fragmentEnd-(this.fragment.openEnd?1:0);let start=cx.absoluteLineStart,end=start,blockI=cx.block.children.length;let prevEnd=end,prevI=blockI;for(;;){if(cur.to-off>fragEnd){if(cur.type.isAnonymous&&cur.firstChild())continue;break;}cx.dontInject.add(cur.tree);cx.addNode(cur.tree,cur.from-off);if(cur.type.is("Block")){if(NotLast.indexOf(cur.type.id)<0){end=cur.to-off;blockI=cx.block.children.length;}else{end=prevEnd;blockI=prevI;prevEnd=cur.to-off;prevI=cx.block.children.length;}}if(!cur.nextSibling())break;}while(cx.block.children.length>blockI){cx.block.children.pop();cx.block.positions.pop();}return end-start;}}const markdownHighlighting=styleTags({"Blockquote/...":tags$1.quote,HorizontalRule:tags$1.contentSeparator,"ATXHeading1/... SetextHeading1/...":tags$1.heading1,"ATXHeading2/... SetextHeading2/...":tags$1.heading2,"ATXHeading3/...":tags$1.heading3,"ATXHeading4/...":tags$1.heading4,"ATXHeading5/...":tags$1.heading5,"ATXHeading6/...":tags$1.heading6,"Comment CommentBlock":tags$1.comment,Escape:tags$1.escape,Entity:tags$1.character,"Emphasis/...":tags$1.emphasis,"StrongEmphasis/...":tags$1.strong,"Link/... Image/...":tags$1.link,"OrderedList/... BulletList/...":tags$1.list,"BlockQuote/...":tags$1.quote,"InlineCode CodeText":tags$1.monospace,URL:tags$1.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":tags$1.processingInstruction,"CodeInfo LinkLabel":tags$1.labelName,LinkTitle:tags$1.string,Paragraph:tags$1.content});const parser$5=new MarkdownParser(new NodeSet(nodeTypes).extend(markdownHighlighting),Object.keys(DefaultBlockParsers).map(n=>DefaultBlockParsers[n]),Object.keys(DefaultBlockParsers).map(n=>DefaultLeafBlocks[n]),Object.keys(DefaultBlockParsers),DefaultEndLeaf,DefaultSkipMarkup,Object.keys(DefaultInline).map(n=>DefaultInline[n]),Object.keys(DefaultInline),[]);function leftOverSpace(node,from,to){let ranges=[];for(let n=node.firstChild,pos=from;;n=n.nextSibling){let nextPos=n?n.from:to;if(nextPos>pos)ranges.push({from:pos,to:nextPos});if(!n)break;pos=n.to;}return ranges;}function parseCode(config){let{codeParser,htmlParser}=config;let wrap=parseMixed((node,input)=>{let id=node.type.id;if(codeParser&&(id==Type.CodeBlock||id==Type.FencedCode)){let info="";if(id==Type.FencedCode){let infoNode=node.node.getChild(Type.CodeInfo);if(infoNode)info=input.read(infoNode.from,infoNode.to);}let parser=codeParser(info);if(parser)return{parser,overlay:node=>node.type.id==Type.CodeText};}else if(htmlParser&&(id==Type.HTMLBlock||id==Type.HTMLTag)){return{parser:htmlParser,overlay:leftOverSpace(node.node,node.from,node.to)};}return null;});return{wrap};}const StrikethroughDelim={resolve:"Strikethrough",mark:"StrikethroughMark"};const Strikethrough={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":tags$1.strikethrough}},{name:"StrikethroughMark",style:tags$1.processingInstruction}],parseInline:[{name:"Strikethrough",parse(cx,next,pos){if(next!=126||cx.char(pos+1)!=126||cx.char(pos+2)==126)return-1;let before=cx.slice(pos-1,pos),after=cx.slice(pos+2,pos+3);let sBefore=/\s|^$/.test(before),sAfter=/\s|^$/.test(after);let pBefore=Punctuation.test(before),pAfter=Punctuation.test(after);return cx.addDelimiter(StrikethroughDelim,pos,pos+2,!sAfter&&(!pAfter||sBefore||pBefore),!sBefore&&(!pBefore||sAfter||pAfter));},after:"Emphasis"}]};function parseRow(cx,line,startI=0,elts,offset=0){let count=0,first=true,cellStart=-1,cellEnd=-1,esc=false;let parseCell=()=>{elts.push(cx.elt("TableCell",offset+cellStart,offset+cellEnd,cx.parser.parseInline(line.slice(cellStart,cellEnd),offset+cellStart)));};for(let i=startI;i-1)count++;first=false;if(elts){if(cellStart>-1)parseCell();elts.push(cx.elt("TableDelimiter",i+offset,i+offset+1));}cellStart=cellEnd=-1;}else if(esc||next!=32&&next!=9){if(cellStart<0)cellStart=i;cellEnd=i+1;}esc=!esc&&next==92;}if(cellStart>-1){count++;if(elts)parseCell();}return count;}function hasPipe(str,start){for(let i=start;ip instanceof TableParser)||!hasPipe(line.text,line.basePos))return false;let next=cx.scanLine(cx.absoluteLineEnd+1).text;return delimiterLine.test(next)&&parseRow(cx,line.text,line.basePos)==parseRow(cx,next,line.basePos);},before:"SetextHeading"}]};class TaskParser{nextLine(){return false;}finish(cx,leaf){cx.addLeafElement(leaf,cx.elt("Task",leaf.start,leaf.start+leaf.content.length,[cx.elt("TaskMarker",leaf.start,leaf.start+3),...cx.parser.parseInline(leaf.content.slice(3),leaf.start+3)]));return true;}}const TaskList={defineNodes:[{name:"Task",block:true,style:tags$1.list},{name:"TaskMarker",style:tags$1.atom}],parseBlock:[{name:"TaskList",leaf(cx,leaf){return /^\[[ xX]\][ \t]/.test(leaf.content)&&cx.parentType().name=="ListItem"?new TaskParser():null;},after:"SetextHeading"}]};const GFM=[Table,TaskList,Strikethrough];function parseSubSuper(ch,node,mark){return(cx,next,pos)=>{if(next!=ch||cx.char(pos+1)==ch)return-1;let elts=[cx.elt(mark,pos,pos+1)];for(let i=pos+1;i"}}});const headingProp=new NodeProp();const commonmark=parser$5.configure({props:[foldNodeProp.add(type=>{return!type.is("Block")||type.is("Document")||isHeading(type)!=null?undefined:(tree,state)=>({from:state.doc.lineAt(tree.from).to,to:tree.to});}),headingProp.add(isHeading),indentNodeProp.add({Document:()=>null}),languageDataProp.add({Document:data})]});function isHeading(type){let match=/^(?:ATX|Setext)Heading(\d)$/.exec(type.name);return match?+match[1]:undefined;}function findSectionEnd(headerNode,level){let last=headerNode;for(;;){let next=last.nextSibling,heading;if(!next||(heading=isHeading(next.type))!=null&&heading<=level)break;last=next;}return last.to;}const headerIndent=foldService.of((state,start,end)=>{for(let node=syntaxTree(state).resolveInner(end,-1);node;node=node.parent){if(node.fromend)return{from:end,to:upto};}return null;});function mkLang(parser){return new Language(data,parser,[headerIndent],"markdown");}const commonmarkLanguage=mkLang(commonmark);const extended=commonmark.configure([GFM,Subscript,Superscript,Emoji]);const markdownLanguage=mkLang(extended);function getCodeParser(languages,defaultLanguage){return info=>{if(info&&languages){let found=null;info=/\S*/.exec(info)[0];if(typeof languages=="function")found=languages(info);else found=LanguageDescription.matchLanguageName(languages,info,true);if(found instanceof LanguageDescription)return found.support?found.support.language.parser:ParseContext.getSkippingParser(found.load());else if(found)return found.parser;}return defaultLanguage?defaultLanguage.parser:null;};}class Context{constructor(node,from,to,spaceBefore,spaceAfter,type,item){this.node=node;this.from=from;this.to=to;this.spaceBefore=spaceBefore;this.spaceAfter=spaceAfter;this.type=type;this.item=item;}blank(maxWidth,trailing=true){let result=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(maxWidth!=null){while(result.length0;i--)result+=" ";return result+(trailing?this.spaceAfter:"");}}marker(doc,add){let number=this.node.name=="OrderedList"?String(+itemNumber(this.item,doc)[2]+add):"";return this.spaceBefore+number+this.type+this.spaceAfter;}}function getContext(node,doc){let nodes=[];for(let cur=node;cur&&cur.name!="Document";cur=cur.parent){if(cur.name=="ListItem"||cur.name=="Blockquote"||cur.name=="FencedCode")nodes.push(cur);}let context=[];for(let i=nodes.length-1;i>=0;i--){let node=nodes[i],match;let line=doc.lineAt(node.from),startPos=node.from-line.from;if(node.name=="FencedCode"){context.push(new Context(node,startPos,startPos,"","","",null));}else if(node.name=="Blockquote"&&(match=/^[ \t]*>( ?)/.exec(line.text.slice(startPos)))){context.push(new Context(node,startPos,startPos+match[0].length,"",match[1],">",null));}else if(node.name=="ListItem"&&node.parent.name=="OrderedList"&&(match=/^([ \t]*)\d+([.)])([ \t]*)/.exec(line.text.slice(startPos)))){let after=match[3],len=match[0].length;if(after.length>=4){after=after.slice(0,after.length-4);len-=4;}context.push(new Context(node.parent,startPos,startPos+len,match[1],after,match[2],node));}else if(node.name=="ListItem"&&node.parent.name=="BulletList"&&(match=/^([ \t]*)([-+*])([ \t]{1,4}\[[ xX]\])?([ \t]+)/.exec(line.text.slice(startPos)))){let after=match[4],len=match[0].length;if(after.length>4){after=after.slice(0,after.length-4);len-=4;}let type=match[2];if(match[3])type+=match[3].replace(/[xX]/,' ');context.push(new Context(node.parent,startPos,startPos+len,match[1],after,type,node));}}return context;}function itemNumber(item,doc){return /^(\s*)(\d+)(?=[.)])/.exec(doc.sliceString(item.from,item.from+10));}function renumberList(after,doc,changes,offset=0){for(let prev=-1,node=after;;){if(node.name=="ListItem"){let m=itemNumber(node,doc);let number=+m[2];if(prev>=0){if(number!=prev+1)return;changes.push({from:node.from+m[1].length,to:node.from+m[0].length,insert:String(prev+2+offset)});}prev=number;}let next=node.nextSibling;if(!next)break;node=next;}}const insertNewlineContinueMarkup=({state,dispatch})=>{let tree=syntaxTree(state),{doc}=state;let dont=null,changes=state.changeByRange(range=>{if(!range.empty||!markdownLanguage.isActiveAt(state,range.from))return dont={range};let pos=range.from,line=doc.lineAt(pos);let context=getContext(tree.resolveInner(pos,-1),doc);while(context.length&&context[context.length-1].from>pos-line.from)context.pop();if(!context.length)return dont={range};let inner=context[context.length-1];if(inner.to-inner.spaceAfter.length>pos-line.from)return dont={range};let emptyLine=pos>=inner.to-inner.spaceAfter.length&&!/\S/.test(line.text.slice(inner.to));if(inner.item&&emptyLine){if(inner.node.firstChild.to>=pos||line.from>0&&!/[^\s>]/.test(doc.lineAt(line.from-1).text)){let next=context.length>1?context[context.length-2]:null;let delTo,insert="";if(next&&next.item){delTo=line.from+next.from;insert=next.marker(doc,1);}else{delTo=line.from+(next?next.to:0);}let changes=[{from:delTo,to:pos,insert}];if(inner.node.name=="OrderedList")renumberList(inner.item,doc,changes,-2);if(next&&next.node.name=="OrderedList")renumberList(next.item,doc,changes);return{range:EditorSelection.cursor(delTo+insert.length),changes};}else{let insert="";for(let i=0,e=context.length-2;i<=e;i++){insert+=context[i].blank(i\s*$/.exec(prevLine.text);if(quoted&"ed.index==inner.from){let changes=state.changes([{from:prevLine.from+quoted.index,to:prevLine.to},{from:line.from+inner.from,to:line.to}]);return{range:range.map(changes),changes};}}let changes=[];if(inner.node.name=="OrderedList")renumberList(inner.item,doc,changes);let continued=inner.item&&inner.item.from]*/.exec(line.text)[0].length>=inner.to){for(let i=0,e=context.length-1;i<=e;i++){insert+=i==e&&!continued?context[i].marker(doc,1):context[i].blank(iline.from&&/\s/.test(line.text.charAt(from-line.from-1)))from--;insert=state.lineBreak+insert;changes.push({from,to:pos,insert});return{range:EditorSelection.cursor(from+insert.length),changes};});if(dont)return false;dispatch(state.update(changes,{scrollIntoView:true,userEvent:"input"}));return true;};function isMark(node){return node.name=="QuoteMark"||node.name=="ListMark";}function contextNodeForDelete(tree,pos){let node=tree.resolveInner(pos,-1),scan=pos;if(isMark(node)){scan=node.from;node=node.parent;}for(let prev;prev=node.childBefore(scan);){if(isMark(prev)){scan=prev.from;}else if(prev.name=="OrderedList"||prev.name=="BulletList"){node=prev.lastChild;scan=node.to;}else{break;}}return node;}const deleteMarkupBackward=({state,dispatch})=>{let tree=syntaxTree(state);let dont=null,changes=state.changeByRange(range=>{let pos=range.from,{doc}=state;if(range.empty&&markdownLanguage.isActiveAt(state,range.from)){let line=doc.lineAt(pos);let context=getContext(contextNodeForDelete(tree,pos),doc);if(context.length){let inner=context[context.length-1];let spaceEnd=inner.to-inner.spaceAfter.length+(inner.spaceAfter?1:0);if(pos-line.from>spaceEnd&&!/\S/.test(line.text.slice(spaceEnd,pos-line.from)))return{range:EditorSelection.cursor(line.from+spaceEnd),changes:{from:line.from+spaceEnd,to:pos}};if(pos-line.from==spaceEnd&&(!inner.item||line.from<=inner.item.from||!/\S/.test(line.text.slice(0,inner.to)))){let start=line.from+inner.from;if(inner.item&&inner.node.fromnAN>nO7oQPOAN>sO6lQPOAN>xOOQO1G.s1G.sOOQO,5;O,5;OOOQO-E8b-E8bOOQO7+$g7+$gOOQO7+%`7+%`O7tQPO7+%`O7yQPO'#DzO8XQPO'#EkO8dQPO,5:eOOQO,5:e,5:eOOQOG24_G24_OOQOG24dG24dOOQO<spec_AtName[value]||-1},{term:125,get:value=>spec_keyword[value]||-1}],tokenPrec:1086});const lezerLanguage=LRLanguage.define({name:"lezer",parser:parser$4.configure({props:[foldNodeProp.add({"Body TokensBody SkipBody PrecedenceBody":foldInside})]}),languageData:{commentTokens:{block:{open:"/*",close:"*/"},line:"//"},indentOnInput:/^\s*\}$/}});function lezer(){return new LanguageSupport(lezerLanguage);}var _m22=Object.freeze({__proto__:null,lezer:lezer,lezerLanguage:lezerLanguage});const spec_Keyword={__proto__:null,anyref:34,dataref:34,eqref:34,externref:34,i31ref:34,funcref:34,i8:34,i16:34,i32:34,i64:34,f32:34,f64:34};const parser$3=LRParser.deserialize({version:14,states:"!^Q]QPOOOqQPO'#CbOOQO'#Cd'#CdOOQO'#Cl'#ClOOQO'#Ch'#ChQ]QPOOOOQO,58|,58|OxQPO,58|OOQO-E6f-E6fOOQO1G.h1G.h",stateData:"!P~O_OSPOSQOS~OTPOVROXROYROZROaQO~OSUO~P]OSXO~P]O",goto:"xaPPPPPPbPbPPPhPPPrXROPTVQTOQVPTWTVXSOPTV",nodeNames:"⚠ LineComment BlockComment Module ) ( App Identifier Type Keyword Number String",maxTerm:17,nodeProps:[["openedBy",4,"("],["closedBy",5,")"],["group",-6,6,7,8,9,10,11,"Expression"]],skippedNodes:[0,1,2],repeatNodeCount:1,tokenData:"0o~R^XY}YZ}]^}pq}rs!Stu#pxy'Uyz(e{|(j}!O(j!Q!R(s!R![*p!]!^.^#T#o.{~!SO_~~!VVOr!Srs!ls#O!S#O#P!q#P;'S!S;'S;=`#j<%lO!S~!qOZ~~!tRO;'S!S;'S;=`!};=`O!S~#QWOr!Srs!ls#O!S#O#P!q#P;'S!S;'S;=`#j;=`<%l!S<%lO!S~#mP;=`<%l!S~#siqr%bst%btu%buv%bvw%bwx%bz{%b{|%b}!O%b!O!P%b!P!Q%b!Q![%b![!]%b!^!_%b!_!`%b!`!a%b!a!b%b!b!c%b!c!}%b#Q#R%b#R#S%b#S#T%b#T#o%b#p#q%b#r#s%b~%giV~qr%bst%btu%buv%bvw%bwx%bz{%b{|%b}!O%b!O!P%b!P!Q%b!Q![%b![!]%b!^!_%b!_!`%b!`!a%b!a!b%b!b!c%b!c!}%b#Q#R%b#R#S%b#S#T%b#T#o%b#p#q%b#r#s%b~'ZPT~!]!^'^~'aTO!]'^!]!^'p!^;'S'^;'S;=`(_<%lO'^~'sVOy'^yz(Yz!]'^!]!^'p!^;'S'^;'S;=`(_<%lO'^~(_OQ~~(bP;=`<%l'^~(jOS~~(mQ!Q!R(s!R![*p~(xUY~!O!P)[!Q![*p!g!h){#R#S+U#X#Y){#l#m+[~)aRY~!Q![)j!g!h){#X#Y){~)oSY~!Q![)j!g!h){#R#S*j#X#Y){~*OR{|*X}!O*X!Q![*_~*[P!Q![*_~*dQY~!Q![*_#R#S*X~*mP!Q![)j~*uTY~!O!P)[!Q![*p!g!h){#R#S+U#X#Y){~+XP!Q![*p~+_R!Q![+h!c!i+h#T#Z+h~+mVY~!O!P,S!Q![+h!c!i+h!r!s-P#R#S+[#T#Z+h#d#e-P~,XTY~!Q![,h!c!i,h!r!s-P#T#Z,h#d#e-P~,mUY~!Q![,h!c!i,h!r!s-P#R#S.Q#T#Z,h#d#e-P~-ST{|-c}!O-c!Q![-o!c!i-o#T#Z-o~-fR!Q![-o!c!i-o#T#Z-o~-tSY~!Q![-o!c!i-o#R#S-c#T#Z-o~.TR!Q![,h!c!i,h#T#Z,h~.aP!]!^.d~.iSP~OY.dZ;'S.d;'S;=`.u<%lO.d~.xP;=`<%l.d~/QiX~qr.{st.{tu.{uv.{vw.{wx.{z{.{{|.{}!O.{!O!P.{!P!Q.{!Q![.{![!].{!^!_.{!_!`.{!`!a.{!a!b.{!b!c.{!c!}.{#Q#R.{#R#S.{#S#T.{#T#o.{#p#q.{#r#s.{",tokenizers:[0],topRules:{"Module":[0,3]},specialized:[{term:9,get:value=>spec_Keyword[value]||-1}],tokenPrec:0});const wastLanguage=LRLanguage.define({name:"wast",parser:parser$3.configure({props:[indentNodeProp.add({App:delimitedIndent({closing:")",align:false})}),foldNodeProp.add({App:foldInside,BlockComment(tree){return{from:tree.from+2,to:tree.to-2};}}),styleTags({Keyword:tags$1.keyword,Type:tags$1.typeName,Number:tags$1.number,String:tags$1.string,Identifier:tags$1.variableName,LineComment:tags$1.lineComment,BlockComment:tags$1.blockComment,"( )":tags$1.paren})]}),languageData:{commentTokens:{line:";;",block:{open:"(;",close:";)"}},closeBrackets:{brackets:["(",'"']}}});function wast(){return new LanguageSupport(wastLanguage);}var _m23=Object.freeze({__proto__:null,wast:wast,wastLanguage:wastLanguage});const Text=1,attributeContentSingle=33,attributeContentDouble=34,scriptAttributeContentSingle=35,scriptAttributeContentDouble=36;const text=new ExternalTokenizer(input=>{let start=input.pos;for(;;){if(input.next==10){input.advance();break;}else if(input.next==123&&input.peek(1)==123||input.next<0){break;}input.advance();}if(input.pos>start)input.acceptToken(Text);});function attrContent(quote,token,script){return new ExternalTokenizer(input=>{let start=input.pos;while(input.next!=quote&&input.next>=0&&(script||input.next!=38&&(input.next!=123||input.peek(1)!=123)))input.advance();if(input.pos>start)input.acceptToken(token);});}const attrSingle=attrContent(39,attributeContentSingle,false);const attrDouble=attrContent(34,attributeContentDouble,false);const scriptAttrSingle=attrContent(39,scriptAttributeContentSingle,true);const scriptAttrDouble=attrContent(34,scriptAttributeContentDouble,true);const parser$2=LRParser.deserialize({version:14,states:"(jOVOqOOOeQpOOOvO!bO'#CaOOOP'#Cx'#CxQVOqOOO!OQpO'#CfO!WQpO'#ClO!]QpO'#CrO!bQpO'#CsOOQO'#Cv'#CvQ!gQpOOQ!lQpOOQ!qQpOOOOOV,58{,58{O!vOpO,58{OOOP-E6v-E6vO!{QpO,59QO#TQpO,59QOOQO,59W,59WO#YQpO,59^OOQO,59_,59_O#_QpOOO#_QpOOO#gQpOOOOOV1G.g1G.gO#oQpO'#CyO#tQpO1G.lOOQO1G.l1G.lO#|QpO1G.lOOQO1G.x1G.xO$UO`O'#DUO$ZOWO'#DUOOQO'#Co'#CoQOQpOOOOQO'#Cu'#CuO$`OtO'#CwO$qOrO'#CwOOQO,59e,59eOOQO-E6w-E6wOOQO7+$W7+$WO%SQpO7+$WO%[QpO7+$WOOOO'#Cp'#CpO%aOpO,59pOOOO'#Cq'#CqO%fOpO,59pOOOS'#Cz'#CzO%kOtO,59cOOQO,59c,59cOOOQ'#C{'#C{O%|OrO,59cO&_QpO<node.name=="InterpolationContent"?exprMixed$1:null)});const attrParser$1=baseParser$1.configure({wrap:parseMixed((node,input)=>{var _a;return node.name=="InterpolationContent"?exprMixed$1:node.name!="AttributeInterpolation"?null:((_a=node.node.parent)===null||_a===void 0?void 0:_a.name)=="StatementAttributeValue"?statementMixed:exprMixed$1;}),top:"Attribute"});const textMixed$1={parser:textParser$1},attrMixed$1={parser:attrParser$1};const angularLanguage=LRLanguage.define({name:"angular",parser:htmlLanguage.parser.configure({wrap:parseMixed(mixAngular)}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function mixAngular(node,input){switch(node.name){case"Attribute":return /^[*#(\[]|\{\{/.test(input.read(node.from,node.to))?attrMixed$1:null;case"Text":return textMixed$1;}return null;}function angular(){return new LanguageSupport(angularLanguage);}var _m24=Object.freeze({__proto__:null,angular:angular,angularLanguage:angularLanguage});const parser$1=LRParser.deserialize({version:14,states:"%pOVOWOOObQPOOOpOSO'#C_OOOO'#Cp'#CpQVOWOOQxQPOOO!TQQOOQ!YQPOOOOOO,58y,58yO!_OSO,58yOOOO-E6n-E6nO!dQQO'#CqQ{QPOOO!iQPOOQ{QPOOO!qQPOOOOOO1G.e1G.eOOQO,59],59]OOQO-E6o-E6oO!yOpO'#CiO#RO`O'#CiQOQPOOO#ZO#tO'#CmO#fO!bO'#CmOOQO,59T,59TO#qOpO,59TO#vO`O,59TOOOO'#Cr'#CrO#{O#tO,59XOOQO,59X,59XOOOO'#Cs'#CsO$WO!bO,59XOOQO1G.o1G.oOOOO-E6p-E6pOOQO1G.s1G.sOOOO-E6q-E6q",stateData:"$g~OjOS~OQROUROkQO~OWTOXUOZUO`VO~OSXOTWO~OXUO[]OlZO~OY^O~O[_O~OT`O~OYaO~OmcOodO~OmfOogO~O^iOnhO~O_jOphO~ObkOqkOrmO~OcnOsnOtmO~OnpO~OppO~ObkOqkOrrO~OcnOsnOtrO~OWX`~",goto:"!^hPPPiPPPPPPPPPmPPPpPPsy!Q!WTROSRe]Re_QSORYSS[T^Rb[QlfRqlQogRso",nodeNames:"⚠ Content Text Interpolation InterpolationContent }} Entity Attribute VueAttributeName : Identifier @ Is ScriptAttributeValue AttributeScript AttributeScript AttributeName AttributeValue Entity Entity",maxTerm:36,skippedNodes:[0],repeatNodeCount:4,tokenData:"'y~RdXY!aYZ!a]^!apq!ars!rwx!w}!O!|!O!P#t!Q![#y![!]$s!_!`%g!b!c%l!c!}#y#R#S#y#T#j#y#j#k%q#k#o#y%W;'S#y;'S;:j$m<%lO#y~!fSj~XY!aYZ!a]^!apq!a~!wOm~~!|Oo~!b#RX`!b}!O!|!Q![!|![!]!|!c!}!|#R#S!|#T#o!|%W;'S!|;'S;:j#n<%lO!|!b#qP;=`<%l!|~#yOl~%W$QXY#t`!b}!O!|!Q![#y![!]!|!c!}#y#R#S#y#T#o#y%W;'S#y;'S;:j$m<%lO#y%W$pP;=`<%l#y~$zXX~`!b}!O!|!Q![!|![!]!|!c!}!|#R#S!|#T#o!|%W;'S!|;'S;:j#n<%lO!|~%lO[~~%qOZ~%W%xXY#t`!b}!O&e!Q![#y![!]!|!c!}#y#R#S#y#T#o#y%W;'S#y;'S;:j$m<%lO#y!b&jX`!b}!O!|!Q![!|![!]!|!c!}'V#R#S!|#T#o'V%W;'S!|;'S;:j#n<%lO!|!b'^XW!b`!b}!O!|!Q![!|![!]!|!c!}'V#R#S!|#T#o'V%W;'S!|;'S;:j#n<%lO!|",tokenizers:[6,7,new LocalTokenGroup("b~RP#q#rU~XP#q#r[~aOT~~",17,4),new LocalTokenGroup("!k~RQvwX#o#p!_~^TU~Opmq!]m!^;'Sm;'S;=`!X<%lOm~pUOpmq!]m!]!^!S!^;'Sm;'S;=`!X<%lOm~!XOU~~![P;=`<%lm~!bP#o#p!e~!jOk~~",72,2),new LocalTokenGroup("[~RPwxU~ZOp~~",11,15),new LocalTokenGroup("[~RPrsU~ZOn~~",11,14),new LocalTokenGroup("!e~RQvwXwx!_~^Tc~Opmq!]m!^;'Sm;'S;=`!X<%lOm~pUOpmq!]m!]!^!S!^;'Sm;'S;=`!X<%lOm~!XOc~~![P;=`<%lm~!dOt~~",66,35),new LocalTokenGroup("!e~RQrsXvw^~^Or~~cTb~Oprq!]r!^;'Sr;'S;=`!^<%lOr~uUOprq!]r!]!^!X!^;'Sr;'S;=`!^<%lOr~!^Ob~~!aP;=`<%lr~",66,33)],topRules:{"Content":[0,1],"Attribute":[1,7]},tokenPrec:157});const exprParser=javascriptLanguage.parser.configure({top:"SingleExpression"});const baseParser=parser$1.configure({props:[styleTags({Text:tags$1.content,Is:tags$1.definitionOperator,AttributeName:tags$1.attributeName,VueAttributeName:tags$1.keyword,Identifier:tags$1.variableName,"AttributeValue ScriptAttributeValue":tags$1.attributeValue,Entity:tags$1.character,"{{ }}":tags$1.brace,"@ :":tags$1.punctuation})]});const exprMixed={parser:exprParser};const textParser=baseParser.configure({wrap:parseMixed((node,input)=>node.name=="InterpolationContent"?exprMixed:null)});const attrParser=baseParser.configure({wrap:parseMixed((node,input)=>node.name=="AttributeScript"?exprMixed:null),top:"Attribute"});const textMixed={parser:textParser},attrMixed={parser:attrParser};const vueLanguage=LRLanguage.define({name:"vue",parser:htmlLanguage.parser.configure({dialect:"selfClosing",wrap:parseMixed(mixVue)}),languageData:{closeBrackets:{brackets:["{",'"']}}});function mixVue(node,input){switch(node.name){case"Attribute":return /^(@|:|v-)/.test(input.read(node.from,node.from+2))?attrMixed:null;case"Text":return textMixed;}return null;}function vue(){return new LanguageSupport(vueLanguage);}var _m25=Object.freeze({__proto__:null,vue:vue,vueLanguage:vueLanguage});const descendantOp=110,Unit=1,openArgList=2;const space=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288];function isAlpha(ch){return ch>=65&&ch<=90||ch>=97&&ch<=122||ch>=161;}function isDigit(ch){return ch>=48&&ch<=57;}const argList=new ExternalTokenizer((input,stack)=>{if(input.next==40){let prev=input.peek(-1);if(isAlpha(prev)||isDigit(prev)||prev==95||prev==45)input.acceptToken(openArgList,1);}});const descendant=new ExternalTokenizer(input=>{if(space.indexOf(input.peek(-1))>-1){let{next}=input;if(isAlpha(next)||next==95||next==35||next==46||next==91||next==58||next==45)input.acceptToken(descendantOp);}});const unitToken=new ExternalTokenizer(input=>{if(space.indexOf(input.peek(-1))<0){let{next}=input;if(next==37){input.advance();input.acceptToken(Unit);}if(isAlpha(next)){do{input.advance();}while(isAlpha(input.next));input.acceptToken(Unit);}}});const lessHighlighting=styleTags({"import charset namespace keyframes media supports when":tags$1.definitionKeyword,"from to selector":tags$1.keyword,NamespaceName:tags$1.namespace,KeyframeName:tags$1.labelName,TagName:tags$1.tagName,ClassName:tags$1.className,PseudoClassName:tags$1.constant(tags$1.className),IdName:tags$1.labelName,"FeatureName PropertyName PropertyVariable":tags$1.propertyName,AttributeName:tags$1.attributeName,NumberLiteral:tags$1.number,KeywordQuery:tags$1.keyword,UnaryQueryOp:tags$1.operatorKeyword,"CallTag ValueName":tags$1.atom,VariableName:tags$1.variableName,"AtKeyword Interpolation":tags$1.special(tags$1.variableName),Callee:tags$1.operatorKeyword,Unit:tags$1.unit,"UniversalSelector NestingSelector":tags$1.definitionOperator,MatchOp:tags$1.compareOperator,"ChildOp SiblingOp, LogicOp":tags$1.logicOperator,BinOp:tags$1.arithmeticOperator,Important:tags$1.modifier,"Comment LineComment":tags$1.blockComment,ColorLiteral:tags$1.color,"ParenthesizedContent StringLiteral":tags$1.string,Escape:tags$1.special(tags$1.string),": ...":tags$1.punctuation,"PseudoOp #":tags$1.derefOperator,"; ,":tags$1.separator,"( )":tags$1.paren,"[ ]":tags$1.squareBracket,"{ }":tags$1.brace});const spec_identifier={__proto__:null,lang:40,"nth-child":40,"nth-last-child":40,"nth-of-type":40,"nth-last-of-type":40,dir:40,"host-context":40,and:244,or:244,not:74,only:74,url:86,"url-prefix":86,domain:86,regexp:86,when:117,selector:142,from:172,to:174};const spec_AtKeyword={__proto__:null,"@import":126,"@plugin":126,"@media":152,"@charset":156,"@namespace":160,"@keyframes":166,"@supports":178};const parser=LRParser.deserialize({version:14,states:"@^O!gQWOOO!nQaO'#CeOOQP'#Cd'#CdO$RQWO'#CgO$xQa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<%lO!+v]!-gP;=`<%l!+vm!-oU|`Oy!*kyz!+vz;'S!*k;'S;=`!.R;=`<%l!+v<%lO!*km!.UXOY!+vZr!+vrs!,cs#O!+v#O#P!,h#P;'S!+v;'S;=`!-d;=`<%l!*k<%lO!+vm!.tP;=`<%l!*km!.|Z|`OY!.wYZ%TZw!.wwx!+cxy!.wyz!/oz#O!.w#O#P!1^#P;'S!.w;'S;=`!2e<%lO!.w]!/rWOY!/oZw!/owx!,cx#O!/o#O#P!0[#P;'S!/o;'S;=`!1W<%lO!/o]!0_RO;'S!/o;'S;=`!0h;=`O!/o]!0kXOY!/oZw!/owx!,cx#O!/o#O#P!0[#P;'S!/o;'S;=`!1W;=`<%l!/o<%lO!/o]!1ZP;=`<%l!/om!1cU|`Oy!.wyz!/oz;'S!.w;'S;=`!1u;=`<%l!/o<%lO!.wm!1xXOY!/oZw!/owx!,cx#O!/o#O#P!0[#P;'S!/o;'S;=`!1W;=`<%l!.w<%lO!/om!2hP;=`<%l!.w`!2nP;=`<%l$t",tokenizers:[descendant,unitToken,argList,0,1,2,3,4],topRules:{"StyleSheet":[0,5]},specialized:[{term:116,get:value=>spec_identifier[value]||-1},{term:23,get:value=>spec_AtKeyword[value]||-1}],tokenPrec:2180});const lessLanguage=LRLanguage.define({name:"less",parser:parser.configure({props:[indentNodeProp.add({Declaration:continuedIndent()}),foldNodeProp.add({Block:foldInside})]}),languageData:{commentTokens:{block:{open:"/*",close:"*/"},line:"//"},indentOnInput:/^\s*\}$/,wordChars:"@-"}});const lessCompletionSource=defineCSSCompletionSource(node=>node.name=="VariableName"||node.name=="AtKeyword");function less(){return new LanguageSupport(lessLanguage,lessLanguage.data.of({autocomplete:lessCompletionSource}));}var _m26=Object.freeze({__proto__:null,less:less,lessCompletionSource:lessCompletionSource,lessLanguage:lessLanguage});const chalky="#e5c07b",coral="#e06c75",cyan="#56b6c2",invalid="#ffffff",ivory="#abb2bf",stone="#7d8799",malibu="#61afef",sage="#98c379",whiskey="#d19a66",violet="#c678dd",darkBackground="#21252b",highlightBackground="#2c313a",background="#282c34",tooltipBackground="#353a42",selection="#3E4451",cursor="#528bff";const color={chalky,coral,cyan,invalid,ivory,stone,malibu,sage,whiskey,violet,darkBackground,highlightBackground,background,tooltipBackground,selection,cursor};const oneDarkTheme=EditorView.theme({"&":{color:ivory,backgroundColor:background},".cm-content":{caretColor:cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:cursor},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:selection},".cm-panels":{backgroundColor:darkBackground,color:ivory},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:background,color:stone,border:"none"},".cm-activeLineGutter":{backgroundColor:highlightBackground},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:tooltipBackground},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:tooltipBackground,borderBottomColor:tooltipBackground},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:highlightBackground,color:ivory}}},{dark:true});const oneDarkHighlightStyle=HighlightStyle.define([{tag:tags$1.keyword,color:violet},{tag:[tags$1.name,tags$1.deleted,tags$1.character,tags$1.propertyName,tags$1.macroName],color:coral},{tag:[tags$1.function(tags$1.variableName),tags$1.labelName],color:malibu},{tag:[tags$1.color,tags$1.constant(tags$1.name),tags$1.standard(tags$1.name)],color:whiskey},{tag:[tags$1.definition(tags$1.name),tags$1.separator],color:ivory},{tag:[tags$1.typeName,tags$1.className,tags$1.number,tags$1.changed,tags$1.annotation,tags$1.modifier,tags$1.self,tags$1.namespace],color:chalky},{tag:[tags$1.operator,tags$1.operatorKeyword,tags$1.url,tags$1.escape,tags$1.regexp,tags$1.link,tags$1.special(tags$1.string)],color:cyan},{tag:[tags$1.meta,tags$1.comment],color:stone},{tag:tags$1.strong,fontWeight:"bold"},{tag:tags$1.emphasis,fontStyle:"italic"},{tag:tags$1.strikethrough,textDecoration:"line-through"},{tag:tags$1.link,color:stone,textDecoration:"underline"},{tag:tags$1.heading,fontWeight:"bold",color:coral},{tag:[tags$1.atom,tags$1.bool,tags$1.special(tags$1.variableName)],color:whiskey},{tag:[tags$1.processingInstruction,tags$1.string,tags$1.inserted],color:sage},{tag:tags$1.invalid,color:invalid}]);const oneDark=[oneDarkTheme,syntaxHighlighting(oneDarkHighlightStyle)];var _m27=Object.freeze({__proto__:null,color:color,oneDark:oneDark,oneDarkHighlightStyle:oneDarkHighlightStyle,oneDarkTheme:oneDarkTheme});class Change{constructor(fromA,toA,fromB,toB){this.fromA=fromA;this.toA=toA;this.fromB=fromB;this.toB=toB;}offset(offA,offB){return new Change(this.fromA+offA,this.toA+offA,this.fromB+offB,this.toB+offB);}}function findDiff(a,fromA,toA,b,fromB,toB){if(a==b)return[];let prefix=commonPrefix(a,fromA,toA,b,fromB,toB);let suffix=commonSuffix(a,fromA+prefix,toA,b,fromB+prefix,toB);fromA+=prefix;toA-=suffix;fromB+=prefix;toB-=suffix;let lenA=toA-fromA,lenB=toB-fromB;if(!lenA||!lenB)return[new Change(fromA,toA,fromB,toB)];if(lenA>lenB){let found=a.slice(fromA,toA).indexOf(b.slice(fromB,toB));if(found>-1)return[new Change(fromA,fromA+found,fromB,fromB),new Change(fromA+found+lenB,toA,toB,toB)];}else if(lenB>lenA){let found=b.slice(fromB,toB).indexOf(a.slice(fromA,toA));if(found>-1)return[new Change(fromA,fromA,fromB,fromB+found),new Change(toA,toA,fromB+found+lenA,toB)];}if(lenA==1||lenB==1)return[new Change(fromA,toA,fromB,toB)];let half=halfMatch(a,fromA,toA,b,fromB,toB);if(half){let[sharedA,sharedB,sharedLen]=half;return findDiff(a,fromA,sharedA,b,fromB,sharedB).concat(findDiff(a,sharedA+sharedLen,toA,b,sharedB+sharedLen,toB));}return findSnake(a,fromA,toA,b,fromB,toB);}let scanLimit=1e9;function findSnake(a,fromA,toA,b,fromB,toB){let lenA=toA-fromA,lenB=toB-fromB;if(scanLimit<1e9&&Math.min(lenA,lenB)>scanLimit*16){if(Math.min(lenA,lenB)>scanLimit*64)return[new Change(fromA,toA,fromB,toB)];return crudeMatch(a,fromA,toA,b,fromB,toB);}let off=Math.ceil((lenA+lenB)/2);frontier1.reset(off);frontier2.reset(off);let match1=(x,y)=>a.charCodeAt(fromA+x)==b.charCodeAt(fromB+y);let match2=(x,y)=>a.charCodeAt(toA-x-1)==b.charCodeAt(toB-y-1);let test1=(lenA-lenB)%2!=0?frontier2:null,test2=test1?null:frontier1;for(let depth=0;depthscanLimit)return crudeMatch(a,fromA,toA,b,fromB,toB);let done=frontier1.advance(depth,lenA,lenB,off,test1,false,match1)||frontier2.advance(depth,lenA,lenB,off,test2,true,match2);if(done)return bisect(a,fromA,toA,fromA+done[0],b,fromB,toB,fromB+done[1]);}return[new Change(fromA,toA,fromB,toB)];}class Frontier{constructor(){this.vec=[];}reset(off){this.len=off<<1;for(let i=0;ilenX){this.end+=2;}else if(y>lenY){this.start+=2;}else if(other){let offOther=vOff+(lenX-lenY)-k;if(offOther>=0&&offOther=xOther)return[x,y];}else{let xOther=other.vec[offOther];if(xOther>=lenX-x)return[xOther,vOff+xOther-offOther];}}}}return null;}}const frontier1=new Frontier(),frontier2=new Frontier();function bisect(a,fromA,toA,splitA,b,fromB,toB,splitB){let stop=false;if(!validIndex(a,splitA)&&++splitA==toA)stop=true;if(!validIndex(b,splitB)&&++splitB==toB)stop=true;if(stop)return[new Change(fromA,toA,fromB,toB)];return findDiff(a,fromA,splitA,b,fromB,splitB).concat(findDiff(a,splitA,toA,b,splitB,toB));}function chunkSize(lenA,lenB){let size=1,max=Math.min(lenA,lenB);while(sizetoA||endB>toB||a.slice(pA,endA)!=b.slice(pB,endB)){if(chunk==1)return pA-fromA-(validIndex(a,pA)?0:1);chunk=chunk>>1;}else if(endA==toA||endB==toB){return endA-fromA;}else{pA=endA;pB=endB;}}}function commonSuffix(a,fromA,toA,b,fromB,toB){if(fromA==toA||fromB==toB||a.charCodeAt(toA-1)!=b.charCodeAt(toB-1))return 0;let chunk=chunkSize(toA-fromA,toB-fromB);for(let pA=toA,pB=toB;;){let sA=pA-chunk,sB=pB-chunk;if(sA>1;}else if(sA==fromA||sB==fromB){return toA-sA;}else{pA=sA;pB=sB;}}}function findMatch(a,fromA,toA,b,fromB,toB,size,divideTo){let rangeB=b.slice(fromB,toB);let best=null;for(;;){if(best||size=toA)break;let seed=a.slice(start,end);let found=-1;while((found=rangeB.indexOf(seed,found+1))!=-1){let prefixAfter=commonPrefix(a,end,toA,b,fromB+found+seed.length,toB);let suffixBefore=commonSuffix(a,fromA,start,b,fromB,fromB+found);let length=seed.length+prefixAfter+suffixBefore;if(!best||best[2]>1;}}function halfMatch(a,fromA,toA,b,fromB,toB){let lenA=toA-fromA,lenB=toB-fromB;if(lenAcur.fromA-minGap&&prev.toB>cur.fromB-minGap){changes[i-1]=new Change(prev.fromA,cur.toA,prev.fromB,cur.toB);changes.splice(i--,1);}}}function normalize(a,b,changes){for(;;){mergeAdjacent(changes,1);let moved=false;for(let i=0;i3||lenB>3){let nextChangeA=i==changes.length-1?a.length:changes[i+1].fromA;let maxScanBefore=change.fromA-posA,maxScanAfter=nextChangeA-change.toA;let boundBefore=findWordBoundaryBefore(a,change.fromA,Math.min(maxScanBefore,5));let boundAfter=findWordBoundaryAfter(a,change.toA,Math.min(maxScanAfter,5));let lenBefore=change.fromA-boundBefore,lenAfter=boundAfter-change.toA;if(!lenA||!lenB){let changeLen=Math.max(lenA,lenB);let[changeText,changeFrom,changeTo]=lenA?[a,change.fromA,change.toA]:[b,change.fromB,change.toB];let indentBefore,indentLen;if(lenBefore&&lenAfter){if(changeLen>lenBefore&&a.slice(boundBefore,change.fromA)==changeText.slice(changeTo-lenBefore,changeTo)){change=changes[i]=new Change(boundBefore,boundBefore+lenA,change.fromB-lenBefore,change.toB-lenBefore);boundBefore=change.fromA;boundAfter=findWordBoundaryAfter(a,change.toA,Math.min(nextChangeA-change.toA,5));}else if(changeLen>lenAfter&&a.slice(change.toA,boundAfter)==changeText.slice(changeFrom,changeFrom+lenAfter)){change=changes[i]=new Change(boundAfter-lenA,boundAfter,change.fromB+lenAfter,change.toB+lenAfter);boundAfter=change.toA;boundBefore=findWordBoundaryBefore(a,change.fromA,Math.min(change.fromA-posA,5));}lenBefore=change.fromA-boundBefore;lenAfter=boundAfter-change.toA;}else if(!lenBefore&&!lenAfter&&(indentLen=change.fromA-(indentBefore=findIndentBefore(a,change.fromA,maxScanBefore)))&&a.slice(indentBefore,change.fromA)==changeText.slice(changeTo-indentLen,changeTo)){change=changes[i]=new Change(indentBefore,indentBefore+lenA,change.fromB-indentLen,change.toB-indentLen);}}if(lenBefore||lenAfter){change=changes[i]=new Change(change.fromA-lenBefore,change.toA+lenAfter,change.fromB-lenBefore,change.toB+lenAfter);}posA=change.toA;}}mergeAdjacent(changes,3);return changes;}let wordChar;try{wordChar=new RegExp("[\\p{Alphabetic}\\p{Number}]","u");}catch(_){}function asciiWordChar(code){return code>48&&code<58||code>64&&code<91||code>96&&code<123;}function wordCharAfter(s,pos){if(pos==s.length)return 0;let next=s.charCodeAt(pos);if(next<192)return asciiWordChar(next)?1:0;if(!wordChar)return 0;if(!isSurrogate1(next)||pos==s.length-1)return wordChar.test(String.fromCharCode(next))?1:0;return wordChar.test(s.slice(pos,pos+2))?2:0;}function wordCharBefore(s,pos){if(!pos)return 0;let prev=s.charCodeAt(pos-1);if(prev<192)return asciiWordChar(prev)?1:0;if(!wordChar)return 0;if(!isSurrogate2(prev)||pos==1)return wordChar.test(String.fromCharCode(prev))?1:0;return wordChar.test(s.slice(pos-2,pos))?2:0;}function findWordBoundaryAfter(s,pos,max){if(pos==s.length||!wordCharBefore(s,pos))return pos;for(let cur=pos,end=pos+max;;){let size=wordCharAfter(s,cur);if(!size)return cur;cur+=size;if(cur>end)return pos;}}function findWordBoundaryBefore(s,pos,max){if(!pos||!wordCharAfter(s,pos))return pos;for(let cur=pos,end=pos-max;;){let size=wordCharBefore(s,cur);if(!size)return cur;cur-=size;if(curcode>=0xD800&&code<=0xDBFF;const isSurrogate2=code=>code>=0xDC00&&code<=0xDFFF;function validIndex(s,index){return!index||index==s.length||!isSurrogate1(s.charCodeAt(index-1))||!isSurrogate2(s.charCodeAt(index));}function diff(a,b,config){var _a;scanLimit=((_a=config===null||config===void 0?void 0:config.scanLimit)!==null&&_a!==void 0?_a:1e9)>>1;return normalize(a,b,findDiff(a,0,a.length,b,0,b.length));}function presentableDiff(a,b,config){return makePresentable(diff(a,b,config),a,b);}const limit={scanLimit:500};class Chunk{constructor(changes,fromA,toA,fromB,toB){this.changes=changes;this.fromA=fromA;this.toA=toA;this.fromB=fromB;this.toB=toB;}offset(offA,offB){return offA||offB?new Chunk(this.changes,this.fromA+offA,this.toA+offA,this.fromB+offB,this.toB+offB):this;}get endA(){return Math.max(this.fromA,this.toA-1);}get endB(){return Math.max(this.fromB,this.toB-1);}static build(a,b){return toChunks(presentableDiff(a.toString(),b.toString(),limit),a,b,0,0);}static updateA(chunks,a,b,changes){return updateChunks(findRangesForChange(chunks,changes,true,b.length),chunks,a,b);}static updateB(chunks,a,b,changes){return updateChunks(findRangesForChange(chunks,changes,false,a.length),chunks,a,b);}}function fromLine(fromA,fromB,a,b){let lineA=a.lineAt(fromA),lineB=b.lineAt(fromB);return lineA.to==fromA&&lineB.to==fromB&&fromAtoA+1&&nextB>toB+1)break;chunk.push(next.offset(-fromA+offA,-fromB+offB));[toA,toB]=toLine(next.toA+offA,next.toB+offB,a,b);i++;}chunks.push(new Chunk(chunk,fromA,Math.max(fromA,toA),fromB,Math.max(fromB,toB)));}return chunks;}const updateMargin=1000;function findPos(chunks,pos,isA,start){let lo=0,hi=chunks.length;for(;;){if(lo==hi){let refA=0,refB=0;if(lo)({toA:refA,toB:refB}=chunks[lo-1]);let off=pos-(isA?refA:refB);return[refA+off,refB+off];}let mid=lo+hi>>1,chunk=chunks[mid];let[from,to]=isA?[chunk.fromA,chunk.toA]:[chunk.fromB,chunk.toB];if(from>pos)hi=mid;else if(to<=pos)lo=mid+1;else return start?[chunk.fromA,chunk.fromB]:[chunk.toA,chunk.toB];}}function findRangesForChange(chunks,changes,isA,otherLen){let ranges=[];changes.iterChangedRanges((cFromA,cToA,cFromB,cToB)=>{let fromA=0,toA=isA?changes.length:otherLen;let fromB=0,toB=isA?otherLen:changes.length;if(cFromA>updateMargin)[fromA,fromB]=findPos(chunks,cFromA-updateMargin,isA,true);if(cToA=fromA)ranges[ranges.length-1]={fromA:last.fromA,fromB:last.fromB,toA,toB,diffA:last.diffA+diffA,diffB:last.diffB+diffB};else ranges.push({fromA,toA,fromB,toB,diffA,diffB});});return ranges;}function updateChunks(ranges,chunks,a,b){if(!ranges.length)return chunks;let chunkI=0,offA=0,offB=0;let result=[];for(let _i302=0,_length302=ranges.length;_i302<_length302;_i302++){let range=ranges[_i302];let fromA=range.fromA+offA,toA=range.toA+offA+range.diffA;let fromB=range.fromB+offB,toB=range.toB+offB+range.diffB;while(chunkItoA)break;chunkI++;}for(let _i303=0,_toChunks=toChunks(presentableDiff(a.sliceString(fromA,toA),b.sliceString(fromB,toB),limit),a,b,fromA,fromB),_length303=_toChunks.length;_i303<_length303;_i303++){let chunk=_toChunks[_i303];result.push(chunk);}offA+=range.diffA;offB+=range.diffB;}while(chunkIvalues[0]});const decorateChunks=ViewPlugin.fromClass(class{constructor(view){({deco:this.deco,gutter:this.gutter}=getChunkDeco(view));}update(update){if(update.docChanged||update.viewportChanged||chunksChanged(update.startState,update.state)||configChanged(update.startState,update.state))({deco:this.deco,gutter:this.gutter}=getChunkDeco(update.view));}},{decorations:d=>d.deco});const changeGutter=Prec.low(gutter({class:"cm-changeGutter",markers:view=>{var _a;return((_a=view.plugin(decorateChunks))===null||_a===void 0?void 0:_a.gutter)||RangeSet.empty;}}));function chunksChanged(s1,s2){return s1.field(ChunkField,false)!=s2.field(ChunkField,false);}function configChanged(s1,s2){return s1.facet(mergeConfig)!=s2.facet(mergeConfig);}const changedLine=Decoration.line({class:"cm-changedLine"});const changedText=Decoration.mark({class:"cm-changedText"});const inserted=Decoration.mark({tagName:"ins"}),deleted=Decoration.mark({tagName:"del"});const changedLineGutterMarker=new class extends GutterMarker{constructor(){super(...arguments);this.elementClass="cm-changedLineGutter";}}();function buildChunkDeco(chunk,doc,isA,highlight,builder,gutterBuilder){let from=isA?chunk.fromA:chunk.fromB,to=isA?chunk.toA:chunk.toB;let changeI=0;if(from!=to){builder.add(from,from,changedLine);builder.add(from,to,isA?deleted:inserted);if(gutterBuilder)gutterBuilder.add(from,from,changedLineGutterMarker);for(let iter=doc.iterRange(from,to-1),pos=from;!iter.next().done;){if(iter.lineBreak){pos++;builder.add(pos,pos,changedLine);if(gutterBuilder)gutterBuilder.add(pos,pos,changedLineGutterMarker);continue;}let lineEnd=pos+iter.value.length;if(highlight)while(changeI=to)break;if((isA?chunk.toA:chunk.toB)>from)buildChunkDeco(chunk,view.state.doc,isA,highlightChanges,builder,gutterBuilder);}return{deco:builder.finish(),gutter:gutterBuilder&&gutterBuilder.finish()};}class Spacer extends WidgetType{constructor(height){super();this.height=height;}eq(other){return this.height==other.height;}toDOM(){let elt=document.createElement("div");elt.className="cm-mergeSpacer";elt.style.height=this.height+"px";return elt;}updateDOM(dom){dom.style.height=this.height+"px";return true;}get estimatedHeight(){return this.height;}ignoreEvent(){return false;}}const adjustSpacers=StateEffect.define({map:(value,mapping)=>value.map(mapping)});const Spacers=StateField.define({create:()=>Decoration.none,update:(spacers,tr)=>{for(let _i306=0,_tr$effects17=tr.effects,_length306=_tr$effects17.length;_i306<_length306;_i306++){let e=_tr$effects17[_i306];if(e.is(adjustSpacers))return e.value;}return spacers.map(tr.changes);},provide:f=>EditorView.decorations.from(f)});const epsilon=.0001;function updateSpacers(a,b,chunks){let buildA=new RangeSetBuilder(),buildB=new RangeSetBuilder();let linesA=a.viewportLineBlocks,linesB=b.viewportLineBlocks,iA=0,iB=0;let spacersA=a.state.field(Spacers).iter(),spacersB=b.state.field(Spacers).iter();let posA=0,posB=0,offA=0,offB=0;chunks:for(let chunkI=0;;chunkI++){let chunk=chunkI=endA||lineB.from>=endB)break;let relA=lineA.from-posA,relB=lineB.from-posB;if(relA<0||relAepsilon){offB+=diff;buildB.add(lineB.from,lineB.from,Decoration.widget({widget:new Spacer(diff),block:true,side:-1}));}iA++;iB++;}}if(!chunk)break;posA=chunk.toA;posB=chunk.toB;}while(spacersA.value){offA-=spacersA.value.spec.widget.height;spacersA.next();}while(spacersB.value){offB-=spacersB.value.spec.widget.height;spacersB.next();}let docDiff=a.contentHeight+offA-(b.contentHeight+offB);if(docDiffepsilon)buildB.add(b.state.doc.length,b.state.doc.length,Decoration.widget({widget:new Spacer(docDiff),block:true,side:1}));let decoA=buildA.finish(),decoB=buildB.finish();if(!RangeSet.eq([decoA],[a.state.field(Spacers)]))a.dispatch({effects:adjustSpacers.of(decoA)});if(!RangeSet.eq([decoB],[b.state.field(Spacers)]))b.dispatch({effects:adjustSpacers.of(decoB)});}const uncollapse=StateEffect.define({map:(value,change)=>change.mapPos(value)});class CollapseWidget extends WidgetType{constructor(lines){super();this.lines=lines;}eq(other){return this.lines==other.lines;}toDOM(view){let outer=document.createElement("div");outer.className="cm-collapsedLines";outer.textContent="⦚ "+view.state.phrase("$ unchanged lines",this.lines)+" ⦚";outer.addEventListener("click",e=>{let pos=view.posAtDOM(e.target);view.dispatch({effects:uncollapse.of(pos)});let{side,sibling}=view.state.facet(mergeConfig);if(sibling)sibling().dispatch({effects:uncollapse.of(mapPos(pos,view.state.field(ChunkField),side=="a"))});});return outer;}ignoreEvent(e){return e instanceof MouseEvent;}get estimatedHeight(){return 27;}}function mapPos(pos,chunks,isA){let startOur=0,startOther=0;for(let i=0;;i++){let next=i=pos)return startOther+(pos-startOur);[startOur,startOther]=isA?[next.toA,next.toB]:[next.toB,next.toA];}}const CollapsedRanges=StateField.define({create(state){return Decoration.none;},update(deco,tr){deco=deco.map(tr.changes);for(let _i307=0,_tr$effects18=tr.effects,_length307=_tr$effects18.length;_i307<_length307;_i307++){let e=_tr$effects18[_i307];if(e.is(uncollapse))deco=deco.update({filter:from=>from!=e.value});}return deco;},provide:f=>EditorView.decorations.from(f)});function collapseUnchanged({margin=3,minSize=4}){return CollapsedRanges.init(state=>buildCollapsedRanges(state,margin,minSize));}function buildCollapsedRanges(state,margin,minLines){let builder=new RangeSetBuilder();let isA=state.facet(mergeConfig).side=="a";let chunks=state.field(ChunkField);let prevLine=1;for(let i=0;;i++){let chunk=i=minLines){builder.add(state.doc.line(collapseFrom).from,state.doc.line(collapseTo).to,Decoration.replace({widget:new CollapseWidget(lines),block:true}));}if(!chunk)break;prevLine=state.doc.lineAt(Math.min(state.doc.length,isA?chunk.toA:chunk.toB)).number;}return builder.finish();}const externalTheme=EditorView.styleModule.of(new StyleModule({".cm-mergeView":{overflowY:"auto"},".cm-mergeViewEditors":{display:"flex",alignItems:"stretch"},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:"hidden"},".cm-merge-revert":{width:"1.6em",flexGrow:0,flexShrink:0,position:"relative"},".cm-merge-revert button":{position:"absolute",display:"block",width:"100%",boxSizing:"border-box",textAlign:"center",background:"none",border:"none",font:"inherit",cursor:"pointer"}}));const baseTheme=EditorView.baseTheme({"& .cm-scroller, &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb2266, #22bb2266) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff8866, #88ff8866) bottom/100% 2px no-repeat"},"del, ins":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer"},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"}});const collapseCompartment=new Compartment(),configCompartment=new Compartment();class MergeView{constructor(config){this.revertDOM=null;this.revertToA=false;this.revertToLeft=false;this.measuring=-1;let sharedExtensions=[Prec.low(decorateChunks),baseTheme,externalTheme,Spacers,EditorView.updateListener.of(update=>{if(this.measuring<0&&(update.heightChanged||update.viewportChanged)&&!update.transactions.some(tr=>tr.effects.some(e=>e.is(adjustSpacers))))this.measure();})];let configA=[mergeConfig.of({side:"a",sibling:()=>this.b,highlightChanges:config.highlightChanges!==false,markGutter:config.gutter!==false})];if(config.gutter!==false)configA.push(changeGutter);let stateA=EditorState.create({doc:config.a.doc,selection:config.a.selection,extensions:[config.a.extensions||[],EditorView.editorAttributes.of({class:"cm-merge-a"}),configCompartment.of(configA),sharedExtensions]});let configB=[mergeConfig.of({side:"b",sibling:()=>this.a,highlightChanges:config.highlightChanges!==false,markGutter:config.gutter!==false})];if(config.gutter!==false)configB.push(changeGutter);let stateB=EditorState.create({doc:config.b.doc,selection:config.b.selection,extensions:[config.b.extensions||[],EditorView.editorAttributes.of({class:"cm-merge-b"}),configCompartment.of(configB),sharedExtensions]});this.chunks=Chunk.build(stateA.doc,stateB.doc);let add=[ChunkField.init(()=>this.chunks),collapseCompartment.of(config.collapseUnchanged?collapseUnchanged(config.collapseUnchanged):[])];stateA=stateA.update({effects:StateEffect.appendConfig.of(add)}).state;stateB=stateB.update({effects:StateEffect.appendConfig.of(add)}).state;this.dom=document.createElement("div");this.dom.className="cm-mergeView";this.editorDOM=this.dom.appendChild(document.createElement("div"));this.editorDOM.className="cm-mergeViewEditors";let orientation=config.orientation||"a-b";let wrapA=document.createElement("div");wrapA.className="cm-mergeViewEditor";let wrapB=document.createElement("div");wrapB.className="cm-mergeViewEditor";this.editorDOM.appendChild(orientation=="a-b"?wrapA:wrapB);this.editorDOM.appendChild(orientation=="a-b"?wrapB:wrapA);this.a=new EditorView({state:stateA,parent:wrapA,root:config.root,dispatch:tr=>this.dispatch(tr,this.a)});this.b=new EditorView({state:stateB,parent:wrapB,root:config.root,dispatch:tr=>this.dispatch(tr,this.b)});this.setupRevertControls(!!config.revertControls,config.revertControls=="b-to-a",config.renderRevertControl);if(config.parent)config.parent.appendChild(this.dom);this.scheduleMeasure();}dispatch(tr,target){if(tr.docChanged){this.chunks=target==this.a?Chunk.updateA(this.chunks,tr.newDoc,this.b.state.doc,tr.changes):Chunk.updateB(this.chunks,this.a.state.doc,tr.newDoc,tr.changes);target.update([tr,tr.state.update({effects:setChunks.of(this.chunks)})]);let other=target==this.a?this.b:this.a;other.update([other.state.update({effects:setChunks.of(this.chunks)})]);this.scheduleMeasure();}else{target.update([tr]);}}reconfigure(config){if("orientation"in config){let aB=config.orientation!="b-a";if(aB!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let domA=this.a.dom.parentNode,domB=this.b.dom.parentNode;domA.remove();domB.remove();this.editorDOM.insertBefore(aB?domA:domB,this.editorDOM.firstChild);this.editorDOM.appendChild(aB?domB:domA);this.revertToLeft=!this.revertToLeft;if(this.revertDOM)this.revertDOM.textContent="";}}if("revertControls"in config||"renderRevertControl"in config){let controls=!!this.revertDOM,toA=this.revertToA,render=this.renderRevert;if("revertControls"in config){controls=!!config.revertControls;toA=config.revertControls=="b-to-a";}if("renderRevertControl"in config)render=config.renderRevertControl;this.setupRevertControls(controls,toA,render);}let highlight=("highlightChanges"in config),gutter=("gutter"in config),collapse=("collapseUnchanged"in config);if(highlight||gutter||collapse){let effectsA=[],effectsB=[];if(highlight||gutter){let currentConfig=this.a.state.facet(mergeConfig);let markGutter=gutter?config.gutter!==false:currentConfig.markGutter;let highlightChanges=highlight?config.highlightChanges!==false:currentConfig.highlightChanges;effectsA.push(configCompartment.reconfigure([mergeConfig.of({side:"a",sibling:()=>this.b,highlightChanges,markGutter}),markGutter?changeGutter:[]]));effectsB.push(configCompartment.reconfigure([mergeConfig.of({side:"b",sibling:()=>this.a,highlightChanges,markGutter}),markGutter?changeGutter:[]]));}if(collapse){let effect=collapseCompartment.reconfigure(config.collapseUnchanged?collapseUnchanged(config.collapseUnchanged):[]);effectsA.push(effect);effectsB.push(effect);}this.a.dispatch({effects:effectsA});this.b.dispatch({effects:effectsB});}this.scheduleMeasure();}setupRevertControls(controls,toA,render){this.revertToA=toA;this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode);this.renderRevert=render;if(!controls&&this.revertDOM){this.revertDOM.remove();this.revertDOM=null;}else if(controls&&!this.revertDOM){this.revertDOM=this.editorDOM.insertBefore(document.createElement("div"),this.editorDOM.firstChild.nextSibling);this.revertDOM.addEventListener("mousedown",e=>this.revertClicked(e));this.revertDOM.className="cm-merge-revert";}else if(this.revertDOM){this.revertDOM.textContent="";}}scheduleMeasure(){if(this.measuring<0){let win=this.dom.ownerDocument.defaultView||window;this.measuring=win.requestAnimationFrame(()=>{this.measuring=-1;this.measure();});}}measure(){updateSpacers(this.a,this.b,this.chunks);if(this.revertDOM)this.updateRevertButtons();}updateRevertButtons(){let dom=this.revertDOM,next=dom.firstChild;let vpA=this.a.viewport,vpB=this.b.viewport;for(let i=0;ivpA.to||chunk.fromB>vpB.to)break;if(chunk.fromA-1)(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring);this.dom.remove();}}function rm(elt){let next=elt.nextSibling;elt.remove();return next;}function getChunks(state){let field=state.field(ChunkField,false);if(!field)return null;return{chunks:field,side:state.facet(mergeConfig).side};}const deletedChunkGutterMarker=new class extends GutterMarker{constructor(){super(...arguments);this.elementClass="cm-deletedLineGutter";}}();const unifiedChangeGutter=Prec.low(gutter({class:"cm-changeGutter",markers:view=>{var _a;return((_a=view.plugin(decorateChunks))===null||_a===void 0?void 0:_a.gutter)||RangeSet.empty;},widgetMarker:(view,widget)=>widget instanceof DeletionWidget?deletedChunkGutterMarker:null}));function unifiedMergeView(config){let orig=typeof config.original=="string"?Text$1.of(config.original.split(/\r?\n/)):config.original;return[Prec.low(decorateChunks),deletedChunks,baseTheme,EditorView.editorAttributes.of({class:"cm-merge-b"}),EditorState.transactionExtender.of(tr=>{let updateDoc=tr.effects.find(e=>e.is(updateOriginalDoc));if(!tr.docChanged&&!updateDoc)return null;let prev=tr.startState.field(ChunkField);let chunks=updateDoc?Chunk.updateA(prev,updateDoc.value.doc,tr.newDoc,updateDoc.value.changes):Chunk.updateB(prev,tr.startState.field(originalDoc),tr.newDoc,tr.changes);return{effects:setChunks.of(chunks)};}),mergeConfig.of({highlightChanges:config.highlightChanges!==false,markGutter:config.gutter!==false,syntaxHighlightDeletions:config.syntaxHighlightDeletions!==false,mergeControls:config.mergeControls!==false,side:"b"}),originalDoc.init(()=>orig),config.gutter!==false?unifiedChangeGutter:[],ChunkField.init(state=>Chunk.build(orig,state.doc))];}const updateOriginalDoc=StateEffect.define();const originalDoc=StateField.define({create:()=>Text$1.empty,update(doc,tr){for(let _i308=0,_tr$effects19=tr.effects,_length308=_tr$effects19.length;_i308<_length308;_i308++){let e=_tr$effects19[_i308];if(e.is(updateOriginalDoc))doc=e.value.doc;}return doc;}});const DeletionWidgets=new WeakMap();class DeletionWidget extends WidgetType{constructor(buildDOM){super();this.buildDOM=buildDOM;this.dom=null;}eq(other){return this.dom==other.dom;}toDOM(view){return this.dom||(this.dom=this.buildDOM(view));}}function deletionWidget(state,chunk){let known=DeletionWidgets.get(chunk.changes);if(known)return known;let buildDOM=view=>{let{highlightChanges,syntaxHighlightDeletions,mergeControls}=state.facet(mergeConfig);let text=view.state.field(originalDoc).sliceString(chunk.fromA,chunk.endA);let lang=syntaxHighlightDeletions&&state.facet(language);let dom=document.createElement("div");dom.className="cm-deletedChunk";if(mergeControls){let buttons=dom.appendChild(document.createElement("div"));buttons.className="cm-chunkButtons";let accept=buttons.appendChild(document.createElement("button"));accept.name="accept";accept.textContent=state.phrase("Accept");accept.onmousedown=e=>{e.preventDefault();acceptChunk(view,view.posAtDOM(dom));};let reject=buttons.appendChild(document.createElement("button"));reject.name="reject";reject.textContent=state.phrase("Reject");reject.onmousedown=e=>{e.preventDefault();rejectChunk(view,view.posAtDOM(dom));};}let content=dom.appendChild(document.createElement("del"));let changes=chunk.changes,changeI=0,inside=false;function add(from,to,cls){for(let at=from;atat){let node=document.createTextNode(text.slice(at,nextStop));if(nodeCls){let span=dom.appendChild(document.createElement("span"));span.className=nodeCls;content.appendChild(node);}else{content.appendChild(node);}}at=nextStop;}}if(lang){let tree=lang.parser.parse(text),pos=0;highlightTree(tree,{style:tags=>highlightingFor(state,tags)},(from,to,cls)=>{if(from>pos)add(pos,from,"");add(from,to,cls);pos=to;});add(pos,text.length,"");}else{add(0,text.length,"");}return dom;};let deco=Decoration.widget({block:true,side:-1,widget:new DeletionWidget(buildDOM)});DeletionWidgets.set(chunk.changes,deco);return deco;}function acceptChunk(view,pos){let{state}=view,at=pos!==null&&pos!==void 0?pos:state.selection.main.head;let chunk=view.state.field(ChunkField).find(ch=>ch.fromB<=at&&ch.endB>=at);if(!chunk)return false;let insert=view.state.sliceDoc(chunk.fromB,Math.max(chunk.fromB,chunk.toB-1));let orig=view.state.field(originalDoc);if(chunk.fromB!=chunk.toB&&chunk.toA<=orig.length)insert+=view.state.lineBreak;let changes=ChangeSet.of({from:chunk.fromA,to:Math.min(orig.length,chunk.toA),insert},orig.length);view.dispatch({effects:updateOriginalDoc.of({doc:changes.apply(orig),changes})});return true;}function rejectChunk(view,pos){let{state}=view,at=pos!==null&&pos!==void 0?pos:state.selection.main.head;let chunk=state.field(ChunkField).find(ch=>ch.fromB<=at&&ch.endB>=at);if(!chunk)return false;let orig=state.field(originalDoc);let insert=orig.sliceString(chunk.fromA,Math.max(chunk.fromA,chunk.toA-1));if(chunk.fromA!=chunk.toA&&chunk.toB<=state.doc.length)insert+=state.lineBreak;view.dispatch({changes:{from:chunk.fromB,to:Math.min(state.doc.length,chunk.toB),insert},userEvent:"revert"});return true;}function buildDeletedChunks(state){let builder=new RangeSetBuilder();for(let _i309=0,_state$field=state.field(ChunkField),_length309=_state$field.length;_i309<_length309;_i309++){let ch=_state$field[_i309];builder.add(ch.fromB,ch.fromB,deletionWidget(state,ch));}return builder.finish();}const deletedChunks=StateField.define({create:state=>buildDeletedChunks(state),update(deco,tr){return tr.state.field(ChunkField,false)!=tr.startState.field(ChunkField,false)?buildDeletedChunks(tr.state):deco;},provide:f=>EditorView.decorations.from(f)});var _m28=Object.freeze({__proto__:null,Change:Change,Chunk:Chunk,MergeView:MergeView,acceptChunk:acceptChunk,diff:diff,getChunks:getChunks,presentableDiff:presentableDiff,rejectChunk:rejectChunk,unifiedMergeView:unifiedMergeView});window.CM={"@codemirror/state":_m0,"@codemirror/view":_m1,"@codemirror/language":_m2,"@codemirror/commands":_m3,"@codemirror/search":_m4,"@codemirror/autocomplete":_m5,"@codemirror/lint":_m6,"@codemirror/collab":_m7,"codemirror":_m8,"@codemirror/lang-javascript":_m9,"@codemirror/lang-java":_m10,"@codemirror/lang-json":_m11,"@codemirror/lang-cpp":_m12,"@codemirror/lang-php":_m13,"@codemirror/lang-python":_m14,"@codemirror/lang-css":_m15,"@codemirror/lang-sass":_m16,"@codemirror/lang-html":_m17,"@codemirror/lang-sql":_m18,"@codemirror/lang-rust":_m19,"@codemirror/lang-xml":_m20,"@codemirror/lang-markdown":_m21,"@codemirror/lang-lezer":_m22,"@codemirror/lang-wast":_m23,"@codemirror/lang-angular":_m24,"@codemirror/lang-vue":_m25,"@codemirror/lang-less":_m26,"@codemirror/theme-one-dark":_m27,"@codemirror/merge":_m28,"@lezer/lr":_m29,"@lezer/common":_m30,"@lezer/highlight":_m31,"crelt":_m32};})(); \ No newline at end of file diff --git a/front/public/vender/date97/My97DatePicker.htm b/front/public/vender/date97/My97DatePicker.htm new file mode 100644 index 0000000..0d64229 --- /dev/null +++ b/front/public/vender/date97/My97DatePicker.htm @@ -0,0 +1,66 @@ + + + +My97DatePicker + + + + + + + + \ No newline at end of file diff --git a/front/public/vender/date97/WdatePicker.js b/front/public/vender/date97/WdatePicker.js new file mode 100644 index 0000000..ff26ee7 --- /dev/null +++ b/front/public/vender/date97/WdatePicker.js @@ -0,0 +1,678 @@ +/* + * My97 DatePicker 4.8.5 + * License: http://www.my97.net/license.asp + */ +var $dp, WdatePicker; +(function () { + var Config = { + $langList: [{ + name: 'en', + charset: 'UTF-8' + }, + { + name: 'zh-cn', + charset: 'gb2312' + }, + { + name: 'zh-tw', + charset: 'GBK' + } + ], + $skinList: [{ + name: 'default', + charset: 'gb2312' + }, + { + name: 'whyGreen', + charset: 'gb2312' + }, + { + name: 'blue', + charset: 'gb2312' + }, + { + name: 'green', + charset: 'gb2312' + }, + { + name: 'simple', + charset: 'gb2312' + }, + { + name: 'ext', + charset: 'gb2312' + }, + { + name: 'blueFresh', + charset: 'gb2312' + }, + { + name: 'twoer', + charset: 'gb2312' + }, + { + name: 'YcloudRed', + charset: 'gb2312' + }, + { + name: 'thinkpap', + charset: 'gb2312' + } + ], + $wdate: false, + $crossFrame: false, + $preLoad: false, + $dpPath: '', + doubleCalendar: false, + enableKeyboard: true, + enableInputMask: true, + autoUpdateOnChanged: null, + weekMethod: 'MSExcel', + position: {}, + lang: 'auto', + skin: 'default', + dateFmt: 'yyyy年MM月dd日 HH时mm分', + realDateFmt: 'yyyy-MM-dd', + realTimeFmt: 'HH:mm:ss', + realFullFmt: '%Date %Time', + minDate: '0001-01-01 00:00:00', + maxDate: '9999-12-31 23:59:59', + minTime: '00:00:00', + maxTime: '23:59:59', + startDate: '', + alwaysUseStartDate: false, + yearOffset: 1911, + firstDayOfWeek: 0, + isShowWeek: false, + highLineWeekDay: true, + isShowClear: true, + isShowToday: true, + isShowOK: true, + isShowOthers: true, + readOnly: false, + errDealMode: 0, + autoPickDate: null, + qsEnabled: true, + autoShowQS: false, + hmsMenuCfg: { + H: [1, 6], + m: [5, 6], + s: [15, 4] + }, + + opposite: false, + specialDates: null, + specialDays: null, + disabledDates: null, + disabledDays: null, + onpicking: null, + onpicked: null, + onclearing: null, + oncleared: null, + ychanging: null, + ychanged: null, + Mchanging: null, + Mchanged: null, + dchanging: null, + dchanged: null, + Hchanging: null, + Hchanged: null, + mchanging: null, + mchanged: null, + schanging: null, + schanged: null, + eCont: null, + vel: null, + elProp: '', + errMsg: '', + quickSel: [], + has: {}, + getRealLang: function () { + var arr = Config.$langList; + for (var i = 0; i < arr.length; i++) { + if (arr[i].name == this.lang) { + return arr[i] + } + } + return arr[0] + } + }; + WdatePicker = main; + var w = window, + emptyEl = { + innerHTML: '' + }, + d = 'document', + de = 'documentElement', + tag = 'getElementsByTagName', + dptop, jsPath, $IE, $FF, $OPERA; + var ua = navigator.userAgent, + isTablet = /(?:iPad|PlayBook)/.test(ua) || (/(?:Android)/.test(ua) && !/(?:Mobile)/.test(ua)), + isPhone = /(?:iPhone)/.test(ua) || /(?:Android)/.test(ua) && /(?:Mobile)/.test(ua); + var appName = navigator.appName; + if (appName == 'Microsoft Internet Explorer') $IE = true; + else if (appName == 'Opera') $OPERA = true; + else $FF = true; + jsPath = Config.$dpPath || getJsPath(); + if (Config.$wdate) { + loadCSS(jsPath + 'skin/WdatePicker.css') + } + dptop = w; + if (Config.$crossFrame) { + try { + while (dptop.parent != dptop && dptop.parent[d][tag]('frameset').length == 0) { + dptop = dptop.parent + } + } catch (e) {} + } + if (!dptop.$dp) { + dptop.$dp = { + ff: $FF, + ie: $IE, + opera: $OPERA, + status: 0, + defMinDate: Config.minDate, + defMaxDate: Config.maxDate, + isTablet: isTablet, + isPhone: isPhone, + isTouch: isTablet || isPhone + } + } + initTopDP(); + if (Config.$preLoad && $dp.status == 0) { + dpAttachEvent(w, 'onload', function () { + main(null, true) + }) + } + var docEventName = $dp.isTouch ? 'ontouchstart' : 'onmousedown'; + if (!w[d].docMD) { + dpAttachEvent(w[d], docEventName, disposeDP, true); + w[d].docMD = true + } + if (!dptop[d].docMD) { + dpAttachEvent(dptop[d], docEventName, disposeDP, true); + dptop[d].docMD = true + } + dpAttachEvent(w, 'onunload', function () { + if ($dp.dd) { + display($dp.dd, "none") + } + }); + + function initTopDP() { + try { + dptop[d], dptop.$dp = dptop.$dp || {} + } catch (e) { + dptop = w; + $dp = $dp || {} + } + var obj = { + win: w, + $: function (el) { + return (typeof el == 'string') ? w[d].getElementById(el) : el + }, + $D: function (id, arg) { + return this.$DV(this.$(id).value, arg) + }, + $DV: function (v, arg) { + if (v != '') { + this.dt = $dp.cal.splitDate(v, $dp.cal.dateFmt); + if (arg) { + for (var p in arg) { + if (this.dt[p] === undefined) { + this.errMsg = 'invalid property:' + p + } else { + this.dt[p] += arg[p]; + if (p == 'M') { + var offset = arg['M'] > 0 ? 1 : 0; + var tmpday = new Date(this.dt['y'], this.dt['M'], 0).getDate(); + this.dt['d'] = Math.min(tmpday + offset, this.dt['d']) + } + } + } + } + if (this.dt.refresh()) { + return this.dt + } + } + return '' + }, + show: function () { + var divs = dptop[d].getElementsByTagName('div'), + maxZIndex = 1e5; + for (var i = 0; i < divs.length; i++) { + var curZ = parseInt(divs[i].style.zIndex); + if (curZ > maxZIndex) { + maxZIndex = curZ + } + } + this.dd.style.zIndex = maxZIndex + 2; + display(this.dd, "block"); + display(this.dd.firstChild, "") + }, + unbind: function (el) { + el = this.$(el); + if (el.initcfg) { + dpDetachEvent(el, 'onclick', function () { + main(el.initcfg) + }); + dpDetachEvent(el, 'onfocus', function () { + main(el.initcfg) + }) + } + }, + hide: function () { + display(this.dd, "none") + }, + attachEvent: dpAttachEvent + }; + for (var p in obj) { + dptop.$dp[p] = obj[p]; + } + $dp = dptop.$dp + } + + function dpAttachEvent(o, sType, fHandler, useCapture) { + if (o.addEventListener) { + var shortTypeName = sType.replace(/on/, ""); + fHandler._ieEmuEventHandler = function (e) { + return fHandler(e) + }; + o.addEventListener(shortTypeName, fHandler._ieEmuEventHandler, useCapture) + } else { + o.attachEvent(sType, fHandler) + } + } + + function dpDetachEvent(o, sType, fHandler) { + if (o.removeEventListener) { + var shortTypeName = sType.replace(/on/, ""); + fHandler._ieEmuEventHandler = function (e) { + return fHandler(e) + }; + o.removeEventListener(shortTypeName, fHandler._ieEmuEventHandler, false) + } else { + o.detachEvent(sType, fHandler) + } + } + + function compareCfg(o1, o2, issub) { + if (typeof o1 != typeof o2) return false; + if (typeof o1 == 'object') { + if (!issub) { + for (var o in o1) { + if (typeof o2[o] == 'undefined') return false; + if (!compareCfg(o1[o], o2[o], true)) return false + } + } + return true + } else if (typeof o1 == 'function' && typeof o2 == 'function') { + return o1.toString() == o2.toString() + } else { + return o1 == o2 + } + } + + function getJsPath() { + var path, tmp, scripts = w[d][tag]("script"); + for (var i = 0; i < scripts.length; i++) { + path = scripts[i].getAttribute('src') || ''; + path = path.substr(0, path.toLowerCase().indexOf('wdatepicker.js')); + var tmp = path.lastIndexOf("/"); + if (tmp > 0) path = path.substring(0, tmp + 1); + if (path) break + } + return path + } + + function loadCSS(path, title, charset) { + var head = w[d][tag]('HEAD').item(0), + style = w[d].createElement('link'); + if (head) { + style.href = path; + style.rel = 'stylesheet'; + style.type = 'text/css'; + if (title) style.title = title; + if (charset) style.charset = charset; + head.appendChild(style) + } + } + + function getAbsM(w) { + w = w || dptop; + var lm = 0, + tm = 0; + while (w != dptop) { + var ifs = w.parent[d][tag]('iframe'); + for (var i = 0; i < ifs.length; i++) { + try { + if (ifs[i].contentWindow == w) { + var rc = getBound(ifs[i]); + lm += rc.left; + tm += rc.top; + break + } + } catch (e) {} + } + w = w.parent + } + return { + 'leftM': lm, + 'topM': tm + } + } + + function getBound(o, ignoreScr) { + if (o.getBoundingClientRect) { + return o.getBoundingClientRect() + } else { + var patterns = { + ROOT_TAG: /^body|html$/i, + OP_SCROLL: /^(?:inline|table-row)$/i + }; + var hssFixed = false, + win = null, + t = o.offsetTop, + l = o.offsetLeft, + r = o.offsetWidth, + b = o.offsetHeight; + var parentNode = o.offsetParent; + if (parentNode != o) { + while (parentNode) { + l += parentNode.offsetLeft; + t += parentNode.offsetTop; + if (getStyle(parentNode, 'position').toLowerCase() == 'fixed') hssFixed = true; + else if (parentNode.tagName.toLowerCase() == "body") win = parentNode.ownerDocument.defaultView; + parentNode = parentNode.offsetParent + } + } + parentNode = o.parentNode; + while (parentNode.tagName && !patterns.ROOT_TAG.test(parentNode.tagName)) { + if (parentNode.scrollTop || parentNode.scrollLeft) { + if (!patterns.OP_SCROLL.test(display(parentNode))) { + if (!$OPERA || parentNode.style.overflow !== 'visible') { + l -= parentNode.scrollLeft; + t -= parentNode.scrollTop + } + } + } + parentNode = parentNode.parentNode + } + if (!hssFixed) { + var scr = getScroll(win); + l -= scr.left; + t -= scr.top + } + r += l; + b += t; + return { + 'left': l, + 'top': t, + 'right': r, + 'bottom': b + } + } + } + + function getWH(w) { + w = w || dptop; + var doc = w[d], + width = (w.innerWidth) ? w.innerWidth : (doc[de] && doc[de].clientWidth) ? doc[de].clientWidth : doc.body.offsetWidth, + height = (w.innerHeight) ? w.innerHeight : (doc[de] && doc[de].clientHeight) ? doc[de].clientHeight : doc.body.offsetHeight; + return { + 'width': width, + 'height': height + } + } + + function getScroll(w) { + w = w || dptop; + var doc = w[d], + doce = doc[de], + db = doc.body; + doc = (doce && doce.scrollTop != null && (doce.scrollTop > db.scrollTop || doce.scrollLeft > db.scrollLeft)) ? doce : db; + return { + 'top': doc.scrollTop, + 'left': doc.scrollLeft + } + } + + function disposeDP(e) { + try { + var src = e ? (e.srcElement || e.target) : null; + if ($dp.cal && !$dp.eCont && $dp.dd && src != $dp.el && $dp.dd.style.display == 'block') { + $dp.cal.close() + } + } catch (e) {} + } + + function dpLoaded() { + $dp.status = 2 + } + var isDptopReady, dptopInterval; + + function main(initcfg, preLoad) { + if (!$dp) return; + initcfg.el = initcfg.el || w[d].activeElement; + if ($dp.isTouch) { + try { + initcfg.el.readOnly = true; + initcfg.el.blur() + } catch (e) {} + } + initTopDP(); + var cfg = {}; + for (var p in initcfg) { + cfg[p] = initcfg[p] + } + for (var p in Config) { + if (p.substring(0, 1) != '$' && cfg[p] === undefined) { + cfg[p] = Config[p] + } + } + if (preLoad) { + if (!dptopReady()) { + dptopInterval = dptopInterval || setInterval(function () { + if (dptop[d].readyState == 'complete') { + clearInterval(dptopInterval); + } + main(null, true) + }, 50); + return + } + if ($dp.status == 0) { + $dp.status = 1; + cfg.el = emptyEl; + showPicker(cfg, true) + } else { + return + } + } else if (cfg.eCont) { + cfg.eCont = $dp.$(cfg.eCont); + cfg.el = emptyEl; + cfg.autoPickDate = true; + cfg.qsEnabled = false; + showPicker(cfg) + } else { + if (Config.$preLoad && $dp.status != 2) return; + if (!cfg.el) { + var evt = SearchEvent(); + if (w.event === evt || evt) { + cfg.srcEl = evt.srcElement || evt.target; + evt.cancelBubble = true + } + } + cfg.el = cfg.el = $dp.$(cfg.el || cfg.srcEl); + if (cfg.el == null) { + alert('WdatePicker:el is null!\nexample:onclick="WdatePicker({el:this})"'); + return + } + try { + if (!cfg.el || cfg.el['My97Mark'] === true || cfg.el.disabled || ($dp.dd && display($dp.dd) != 'none' && $dp.dd.style.left != '-970px')) { + if (cfg.el['My97Mark']) cfg.el['My97Mark'] = false; + return + } + } catch (e) {} + if (evt && cfg.el.nodeType == 1 && !compareCfg(cfg.el.initcfg, initcfg)) { + $dp.unbind(cfg.el); + dpAttachEvent(cfg.el, evt.type == 'focus' ? 'onclick' : 'onfocus', function () { + main(initcfg) + }); + cfg.el.initcfg = initcfg; + } + showPicker(cfg) + } + + function dptopReady() { + if ($IE && dptop != w && dptop[d].readyState != 'complete') return false; + return true + } + + function SearchEvent() { + if ($FF) { + try { + var count = 0; + func = SearchEvent.caller; + while (func != null) { + var arg0 = func.arguments[0]; + if (arg0 && (arg0 + '').indexOf('Event') >= 0 || (count++) > 97) { + return arg0 + } + func = func.caller + } + } catch (e) {} + return null + } + return event + } + } + + function getStyle(obj, attribute) { + return obj.currentStyle ? obj.currentStyle[attribute] : document.defaultView.getComputedStyle(obj, false)[attribute] + } + + function display(obj, value) { + if (obj) { + if (value != null) obj.style.display = value; + else return getStyle(obj, 'display') + } + } + + function showPicker(cfg, preLoad) { + var nodeName = cfg.el ? cfg.el.nodeName : 'INPUT'; + if (preLoad || cfg.eCont || new RegExp(/input|textarea|div|field|span|p|a/ig).test(nodeName)) { + cfg.elProp = cfg.elProp || nodeName == 'INPUT' ? 'value' : 'innerHTML' + } else { + return + } + if (cfg.lang == 'auto') { + cfg.lang = $IE ? navigator.browserLanguage.toLowerCase() : navigator.language.toLowerCase() + } + if (!cfg.eCont) { + for (var p in cfg) { + $dp[p] = cfg[p] + } + } + if (!$dp.dd || cfg.eCont || ($dp.dd && (cfg.getRealLang().name != $dp.dd.lang || cfg.skin != $dp.dd.skin))) { + if (cfg.eCont) { + ddInit(cfg.eCont, cfg) + } else { + $dp.dd = dptop[d].createElement("DIV"); + $dp.dd.style.cssText = 'position:absolute'; + dptop[d].body.appendChild($dp.dd); + ddInit($dp.dd, cfg); + if (preLoad) { + $dp.dd.style.left = $dp.dd.style.top = '-970px' + } else { + $dp.show(); + setPos($dp) + } + } + } else if ($dp.cal) { + $dp.show(); + $dp.cal.init(); + if (!$dp.eCont) setPos($dp) + } + + function ddInit(cont, cfg) { + var dm = dptop[d].domain, + isCross = false, + defHtml = ''; + cont.innerHTML = defHtml; + var langList = Config.$langList, + skinList = Config.$skinList, + doc; + try { + doc = cont.lastChild.contentWindow[d] + } catch (e) { + isCross = true; + cont.removeChild(cont.lastChild); + var ifr = dptop[d].createElement("iframe"); + ifr.hideFocus = true; + ifr.frameBorder = 0; + ifr.scrolling = 'no'; + ifr.src = "javascript:(function(){var d=document;d.open();d.domain='" + dm + "';})()"; + cont.appendChild(ifr); + setTimeout(function () { + doc = cont.lastChild.contentWindow[d]; + ddWrite() + }, 97); + return + } + ddWrite(); + + function ddWrite() { + var realLang = cfg.getRealLang(), + ver = '4.9.0b3'; + cont.lang = realLang.name; + cont.skin = cfg.skin; + var h = ['']; + if (isCross) h[1] = 'document.domain="' + dm + '";'; + for (var i = 0; i < skinList.length; i++) { + if (skinList[i].name == cfg.skin) { + h.push('') + } + } + h.push(''); + h.push(''); + h.push(''); + cfg.setPos = setPos; + cfg.onload = dpLoaded; + doc.write(''); + doc.cfg = cfg; + doc.write(h.join('')); + doc.close() + } + } + + function setPos(dp) { + var l = dp.position.left, + t = dp.position.top, + el = dp.el; + if (el == emptyEl) return; + if (el != dp.srcEl && (display(el) == 'none' || el.type == 'hidden')) el = dp.srcEl; + var objxy = getBound(el), + mm = getAbsM(w), + currWH = getWH(dptop), + scr = getScroll(dptop), + ddHeight = $dp.dd.offsetHeight, + ddWidth = $dp.dd.offsetWidth; + if (isNaN(t)) t = 0; + if ((mm.topM + objxy.bottom + ddHeight > currWH.height) && (mm.topM + objxy.top - ddHeight > 0)) { + t += scr.top + mm.topM + objxy.top - ddHeight - 2 + } else { + t += scr.top + mm.topM + objxy.bottom; + var offsetT = t - scr.top + ddHeight - currWH.height; + if (offsetT > 0) t -= offsetT + } + if (isNaN(l)) l = 0; + l += scr.left + Math.min(mm.leftM + objxy.left, currWH.width - ddWidth - 5) - ($IE ? 2 : 0); + dp.dd.style.top = (t + 2) + 'px'; + dp.dd.style.left = l + 'px' + } + } +})(); \ No newline at end of file diff --git a/front/public/vender/date97/calendar.js b/front/public/vender/date97/calendar.js new file mode 100644 index 0000000..3847a1a --- /dev/null +++ b/front/public/vender/date97/calendar.js @@ -0,0 +1,5 @@ +/* + * My97 DatePicker 4.8.5 + * License: http://www.my97.net/license.asp + */ +function My97DP(){$c=this,this.QS=[],$d=document.createElement("div"),$d.className="WdateDiv",$d.innerHTML='
                     
                    ',attachTabEvent($d,function(){hideSel()}),function(){function t(t){return $d.getElementsByTagName(t)}var e=t("a");divs=t("div"),ipts=t("input"),btns=t("button"),spans=t("span"),$d.navLeftImg=e[0],$d.leftImg=e[1],$d.rightImg=e[3],$d.navRightImg=e[2],$d.rMD=divs[9],$d.MI=ipts[0],$d.yI=ipts[1],$d.titleDiv=divs[0],$d.MD=divs[4],$d.yD=divs[6],$d.qsDivSel=divs[10],$d.dDiv=divs[11],$d.tDiv=divs[12],$d.HD=divs[13],$d.mD=divs[14],$d.sD=divs[15],$d.qsDiv=divs[16],$d.qsDiv.title=$lang.quickStr,$d.bDiv=divs[17],$d.HI=ipts[2],$d.mI=ipts[4],$d.sI=ipts[6],$d.clearI=ipts[7],$d.todayI=ipts[8],$d.okI=ipts[9],$d.upButton=btns[0],$d.downButton=btns[1],$d.timeSpan=spans[0]}(),this.init(),$dp.focusArr=[document,$d.MI,$d.yI,$d.HI,$d.mI,$d.sI,$d.clearI,$d.todayI,$d.okI];for(var t=0;t<$dp.focusArr.length;t++){var e=$dp.focusArr[t];e.nextCtrl=t==$dp.focusArr.length-1?$dp.focusArr[1]:$dp.focusArr[t+1],$dp.attachEvent(e,"onkeydown",_tab)}!function(){$d.navLeftImg.onclick=function(){if($ny=$ny<=0?$ny-1:-1,$ny%5==0)return void $d.yI.focus();$d.yI.value=$dt.y-1,$d.yI.onblur()},$d.leftImg.onclick=function(){$dt.attr("M",-1),$d.MI.onblur()},$d.rightImg.onclick=function(){$dt.attr("M",1),$d.MI.onblur()},$d.navRightImg.onclick=function(){if($ny=$ny>=0?$ny+1:1,$ny%5==0)return void $d.yI.focus();$d.yI.value=$dt.y+1,$d.yI.onblur()}}(),_inputBindEvent("y,M,H,m,s"),$d.upButton.onclick=function(){updownEvent(1)},$d.downButton.onclick=function(){updownEvent(-1)},$d.qsDiv.onclick=function(){"block"!=$d.qsDivSel.style.display?($c._fillQS(),showB($d.qsDivSel)):hide($d.qsDivSel)},document.body.appendChild($d)}function elFocus(){var t=$dp.el;try{"none"==t.style.display||"hidden"==t.type||"input"!=t.nodeName.toLowerCase()&&"textarea"!=t.nodeName.toLowerCase()||(t.My97Mark=!0,t.focus())}catch(t){}setTimeout(function(){t.My97Mark=!1},197)}function sb(){this.s=new Array,this.i=0,this.a=function(t){this.s[this.i++]=t},this.j=function(){return this.s.join("")}}function getWeek(t,e){e=e||0;var d,a=new Date(t.y,t.M-1,t.d+e);if("ISO8601"==$dp.weekMethod){a.setDate(a.getDate()-(a.getDay()+6)%7+3);var n=a.valueOf();a.setMonth(0),a.setDate(4),d=Math.round((n-a.valueOf())/6048e5)+1}else{var s=new Date(t.y,0,1);a=Math.round((a.valueOf()-s.valueOf())/864e5),d=Math.ceil((a+(s.getDay()+1))/7)}return 1==$dt.M&&d>52?1:d}function getDay(t){return new Date(t.y,t.M-1,t.d).getDay()}function show(){setDisp(arguments,"")}function showB(){setDisp(arguments,"block")}function hide(){setDisp(arguments,"none")}function setDisp(t,e){for(i=0;i=0&&(a=makeInRange(e,0,59)),$dt[t]=a,$d[t+"I"]&&("M"==t?($d.MI.realValue=a,$d.MI.value=$lang.aMonStr[a-1]):$d[t+"I"].value=a),$sdt[t]==a||callFunc(t+"changing")||(d=$c.checkRange(),0==d?sv(t,a):d<0?_setAll($c.minDate):d>0&&_setAll($c.maxDate),$d.okI.disabled=!$c.checkValid($sdt),"yMd".indexOf(t)>=0&&$c.draw(),callFunc(t+"changed"))}function _setTime(t){sv("H",t.H),sv("m",t.m),sv("s",t.s)}function _setAll(t){sv("y",t.y),sv("M",t.M),sv("d",t.d),_setTime(t)}function day_Click(t,e,d,a,n,s){var i=new DPDate($dt.y,$dt.M,$dt.d,$dt.H,$dt.m,$dt.s);if($dt.loadDate(t,e,d,a,n,s),callFunc("onpicking"))$dt=i;else{var r=i.y==t&&i.M==e&&i.d==d;r||0==arguments.length||(c("y",t),c("M",e),c("d",d),$dp.has.st&&updownEvent(0),$c.currFocus=$dp.el,dealAutoUpdate()),($c.autoPickDate||r||0==arguments.length)&&$c.pickDate()}}function dealAutoUpdate(){if($dp.autoUpdateOnChanged)try{$c.update(),$dp.el.focus()}catch(t){}}function callFunc(t){var e;return $dp[t]&&(e=$dp[t].call($dp.el,$dp)),e}function sv(t,e){if(null==e&&(e=$dt[t]),$sdt[t]=$dt[t]=e,"yHms".indexOf(t)>=0&&($d[t+"I"].value=e),"M"==t&&($d.MI.realValue=e,$d.MI.value=$lang.aMonStr[e-1]),"Hms".indexOf(t)>=0){var d=$c.checkTimeRange($dt,t);d<0?(_setTime($c.minTime),e=$c.minTime[t]):d>0&&(_setTime($c.maxTime),e=$c.maxTime[t])}}function makeInRange(t,e,d){return td&&(t=d),t}function attachTabEvent(t,e){$dp.attachEvent(t,"onkeydown",function(t){t=t||event,k=void 0==t.which?t.keyCode:t.which,9==k&&e()})}function doStr(t,e){for(t+="";t.length=0&&(d.style.marginLeft=Math.min(this.offsetLeft,$d.sI.offsetLeft+60*$dp._scaled-d.offsetWidth),d.style.marginTop=this.offsetTop-d.offsetHeight-2)}}function _blur(showDiv){if(!(new Date-$c.lastFocusTime<97)){var p=_foundInput(this),isR,mStr,v=this.value,oldv=$dt[p];0!=p&&($dt[p]=Number(v)>=0?Number(v):$dt[p],"y"==p?(isR=this==$d.ryI)&&12==$dt.M&&($dt.y-=1):"M"==p&&(isR=this==$d.rMI,isR&&(mStr=$lang.aMonStr[$dt[p]-1],12==oldv&&($dt.y+=1),$dt.attr("M",-1)),$sdt.M==$dt.M&&(this.value=mStr||$lang.aMonStr[$dt[p]-1]),$sdt.y!=$dt.y&&c("y",$dt.y)),eval('c("'+p+'",'+$dt[p]+")"),!0!==showDiv&&("y"!=p&&"M"!=p||(this.className="yminput"),hide($d[p+"D"])),dealAutoUpdate())}}function _cancelKey(t){t.preventDefault?(t.preventDefault(),t.stopPropagation()):(t.cancelBubble=!0,t.returnValue=!1),$OPERA&&(t.keyCode=0)}function _inputBindEvent(t){for(var e=t.split(","),d=0;d=96&&d<=105&&(d-=48),$dp.enableKeyboard&&a){if(e.nextCtrl||(e.nextCtrl=$dp.focusArr[1],$c.currFocus=$dp.el),e==$dp.el&&($c.currFocus=$dp.el),27==d){if(e==$dp.el)return void $c.close();$dp.el.focus()}if(d>=37&&d<=40){var n;if($c.currFocus==$dp.el||$c.currFocus==$d.okI){if($dp.has.d)return n="d",38==d?$dt[n]-=7:39==d?$dt[n]+=1:37==d?$dt[n]-=1:$dt[n]+=7,$dt.refresh(),c("y",$dt.y),c("M",$dt.M),c("d",$dt[n]),void _cancelKey(t);n=$dp.has.minUnit,$d[n+"I"].focus()}n=n||_foundInput($c.currFocus),n&&(38==d||39==d?$dt[n]+=1:$dt[n]-=1,$dt.refresh(),$c.currFocus.value=$dt[n],_blur.call($c.currFocus,!0),$dp.isTouch||$c.currFocus.select())}else if(9==d){for(var s=e.nextCtrl,i=0;i<$dp.focusArr.length&&(1==s.disabled||0==s.offsetHeight);i++)s=s.nextCtrl;$c.currFocus!=s&&($c.currFocus=s,s.focus())}else 13==d&&(_blur.call($c.currFocus),"button"==$c.currFocus.type?$c.currFocus.click():$dp.cal.oldValue==$dp.el[$dp.elProp]?$c.pickDate():$c.close(),$c.currFocus=$dp.el)}else 9==d&&e==$dp.el&&$c.close();if($dp.enableInputMask&&!$dp.isTouch&&!$OPERA&&!$dp.readOnly&&$c.currFocus==$dp.el&&d>=48&&d<=57){var r,l,o,$,p,u,h,f,m=$dp.el,y=m.value,v=function(t){var e=0;if($dp.win.document.selection){var d=$dp.win.document.selection.createRange(),a=d.text.length;d.moveStart("character",-t.value.length),e=d.text.length-a}else(t.selectionStart||"0"==t.selectionStart)&&(e=t.selectionStart);return e}(m),g={str:"",arr:[]},i=0,D=0,M=0,I=0,b=/yyyy|yyy|yy|y|MM|M|dd|d|%ld|HH|H|mm|m|ss|s|WW|W|w/g,w=$dp.dateFmt.match(b),l=0;if(""!=y){for(I=y.match(/[0-9]/g),I=null==I?0:I.length,i=0;i=0?1:0,1==I&&v>=y.length&&(v=y.length-1)}for(y=y.substring(0,v)+String.fromCharCode(d)+y.substring(v+I),v++,i=0;i=0&&(y+=$dp.dateFmt.substring(D,M),v>=D+l&&v<=M+l&&(v+=M-D)),D=b.lastIndex,f=D-M,o=g.str.substring(0,f),$=r[0].charAt(0),p=pInt(o.charAt(0)),g.str.length>1?(u=g.str.charAt(1),h=10*p+pInt(u)):(u="",h=p),g.arr[M+1]||"M"==$&&h>12||"d"==$&&h>31||"H"==$&&h>23||"ms".indexOf($)>=0&&h>59?(o=2==r[0].length?"0"+p:p,v++):1==f&&(o=h,f++,l++),y+=o,g.str=g.str.substring(f),""!=g.str););m.value=y,function(t,e){if(t.setSelectionRange)t.focus(),t.setSelectionRange(e,e);else if(t.createTextRange){var d=t.createTextRange();d.collapse(!0),d.moveEnd("character",e),d.moveStart("character",e),d.select()}}(m,v),_cancelKey(t)}a&&$c.currFocus!=$dp.el&&!(d>=48&&d<=57||8==d||46==d)&&_cancelKey(t)}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};if($cfg.eCont){$dp={};for(var p in $pdp)if("object"==_typeof($pdp[p])){$dp[p]={};for(var pp in $pdp[p])$dp[p][pp]=$pdp[p][pp]}else $dp[p]=$pdp[p]}else $dp=$pdp;for(var p in $cfg)$dp[p]=$cfg[p];var $c;$FF&&(Event.prototype.__defineSetter__("returnValue",function(t){return t||this.preventDefault(),t}),Event.prototype.__defineGetter__("srcElement",function(){for(var t=this.target;1!=t.nodeType;)t=t.parentNode;return t})),My97DP.prototype={init:function(){$ny=0,$dp.cal=this,$dp.readOnly&&null!=$dp.el.readOnly&&($dp.el.readOnly=!0,$dp.el.blur()),this._dealFmt(),$dt=this.newdate=new DPDate,$tdt=new DPDate,$sdt=this.date=new DPDate,$dp.valueEdited=0,this.dateFmt=this.doExp($dp.dateFmt),this.autoPickDate=null==$dp.autoPickDate?!$dp.has.st||!$dp.has.st:$dp.autoPickDate,$dp.autoUpdateOnChanged=null==$dp.autoUpdateOnChanged?!$dp.isShowOK||!$dp.has.d:$dp.autoUpdateOnChanged,this.ddateRe=this._initRe("disabledDates"),this.ddayRe=this._initRe("disabledDays"),this.sdateRe=this._initRe("specialDates"),this.sdayRe=this._initRe("specialDays"),this.minDate=this.doCustomDate($dp.minDate,$dp.minDate!=$dp.defMinDate?$dp.realFmt:$dp.realFullFmt,$dp.defMinDate),this.maxDate=this.doCustomDate($dp.maxDate,$dp.maxDate!=$dp.defMaxDate?$dp.realFmt:$dp.realFullFmt,$dp.defMaxDate),this.minTime=this.doCustomDate($dp.minTime,$dp.realTimeFmt),this.maxTime=this.doCustomDate($dp.maxTime,$dp.realTimeFmt),this.minDate.compareWith(this.maxDate)>0&&($dp.errMsg=$lang.err_1),this.loadDate()?(this._makeDateInRange(),this.oldValue=$dp.el[$dp.elProp]):this.mark(!1,2),_setAll($dt),$d.timeSpan.innerHTML=$lang.timeStr,$d.clearI.value=$lang.clearStr,$d.todayI.value=$lang.todayStr,$d.okI.value=$lang.okStr,$d.okI.disabled=!$c.checkValid($sdt),this.initShowAndHide(),this.initBtn(),$dp.errMsg&&alert($dp.errMsg),this.draw(),1==$dp.el.nodeType&&void 0===$dp.el.My97Mark&&($dp.attachEvent($dp.el,"onkeydown",_tab),$dp.attachEvent($dp.el,"onblur",function(){$dp&&"none"==$dp.dd.style.display&&$c.close()}),$dp.el.My97Mark=!1),$c.currFocus=$dp.el,hideSel()},_makeDateInRange:function(){var t=this.checkRange();if(0!=t){var e;e=t>0?this.maxDate:this.minDate,$dp.has.sd&&($dt.y=e.y,$dt.M=e.M,$dt.d=e.d),$dp.has.st&&($dt.H=e.H,$dt.m=e.m,$dt.s=e.s)}},splitDate:function(t,e,d,a,n,s,i,r,l){var o;if(t&&t.loadDate)o=t;else{o=new DPDate,e=e||$dp.dateFmt;var c,$,p,u=0,h=/yyyy|yyy|yy|y|MMMM|MMM|MM|M|dd|d|%ld|HH|H|mm|m|ss|s|DD|D|WW|W|w/g,f=e.match(h);if(h.lastIndex=0,l)p=t.split(/\W+/);else{for(var m=0,y="^";null!==(p=h.exec(e));)switch(m>=0&&($=e.substring(m,p.index),$&&"-/\\".indexOf($)>=0&&($="[\\-/]"),y+=$),m=h.lastIndex,p[0]){case"yyyy":y+="(\\d{4})";break;case"yyy":y+="(\\d{3})";break;case"MMMM":case"MMM":case"DD":case"D":y+="(\\D+)";break;default:y+="(\\d\\d?)"}y+=".*$",p=new RegExp(y).exec(t),u=1}if(p){for(c=0;c0){for(e=0;e=0&&(t=t.replace(/%ld/g,"0")),a.refresh()),a},loadDate:function(){var t=$dp.el[$dp.elProp],e=this.dateFmt,d=$dp.has;if(($dp.alwaysUseStartDate||""!=$dp.startDate&&""==t)&&(t=this.doExp($dp.startDate),e=$dp.realFmt),$dt.loadFromDate(this.splitDate(t,e)),""!=t){var a=1;return d.sd&&!this.isDate($dt)&&($dt.y=$tdt.y,$dt.M=$tdt.M,$dt.d=$tdt.d,a=0),d.st&&!this.isTime($dt)&&($dt.H=$tdt.H,$dt.m=$tdt.m,$dt.s=$tdt.s,a=0),a&&this.checkValid($dt)}return d.H||($dt.H=0),d.m||($dt.m=0),d.s||($dt.s=0),1},isDate:function(t){return null!=t.y&&(t=doStr(t.y,4)+"-"+t.M+"-"+t.d),t.match(/^((\d{2}(([02468][048])|([13579][26]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|([1-2][0-9])))))|(\d{2}(([02468][1235679])|([13579][01345789]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\s(((0?[0-9])|([1-2][0-3]))\:([0-5]?[0-9])((\s)|(\:([0-5]?[0-9])))))?$/)},isTime:function(t){return null!=t.H&&(t=t.H+":"+t.m+":"+t.s),t.match(/^([0-9]|([0-1][0-9])|([2][0-3])):([0-9]|([0-5][0-9])):([0-9]|([0-5][0-9]))$/)},checkRange:function(t,e){t=t||$dt;var d=t.compareWith(this.minDate,e);return d>0&&(d=t.compareWith(this.maxDate,e))<0&&(d=0),d},checkTimeRange:function(t,e){return t=t||$dt,t.compareWith(this.minTime,e,"Hms")<0?-1:t.compareWith(this.maxTime,e,"Hms")>0?1:0},checkValid:function(t,e,d){e=e||$dp.has.minUnit;var a=this.checkRange(t,e);return 0==a?(a=1,"d"==e&&null==d&&(d=Math.abs((new Date(t.y,t.M-1,t.d).getDay()-$dp.firstDayOfWeek+7)%7)),a=!this.testDisDay(d)&&!this.testDisDate(t,e),"Hms".indexOf(e)>=0&&(a=0==this.checkTimeRange(t,e))):a=0,a},checkAndUpdate:function(){var t=($dp.el,this),e=$dp.el[$dp.elProp];if($dp.errDealMode>=0&&$dp.errDealMode<=2&&null!=e){if(""!=e&&t.date.loadFromDate(t.splitDate(e,$dp.dateFmt)),!(""==e||t.isDate(t.date)&&t.isTime(t.date)&&t.checkValid(t.date)))return!1;""!=e?(t.newdate.loadFromDate(t.date),t.update()):t.setRealValue("")}return!0},close:function(t){hideSel(),this.checkAndUpdate()?(this.mark(!0),$dp.hide()):(t?(_cancelKey(t),this.mark(!1,2)):this.mark(!1),$dp.show())},_fd:function(){var t,e,d,a,n,s=new sb,i=$lang.aWeekStr,r=$dp.firstDayOfWeek,l="",o="",c=new DPDate($dt.y,$dt.M,$dt.d,2,0,0),$=c.y,p=c.M;for(n=1-new Date($,p-1,1).getDay()+r,n>1&&(n-=7),s.a(""),s.a(""),$dp.isShowWeek&&s.a(""),t=0;t<7;t++)s.a("");for(s.a(""),t=1,e=n;t<7;t++){for(s.a(""),d=0;d<7;d++){if(c.loadDate($,p,e++),c.refresh(),c.M==p)a=!0,l=0==c.compareWith($sdt,"d")?"Wselday":0==c.compareWith($tdt,"d")?"Wtoday":!$dp.highLineWeekDay||0!=(r+d)%7&&6!=(r+d)%7?"Wday":"Wwday",o=!$dp.highLineWeekDay||0!=(r+d)%7&&6!=(r+d)%7?"WdayOn":"WwdayOn";else if($dp.isShowOthers){if(0==d&&t>1)break;a=!0,l="WotherDay",o="WotherDayOn"}else a=!1;$dp.isShowWeek&&0==d&&(t<4||a)&&s.a(""),s.a("")):s.a(">")}s.a("")}return s.a("
                    "+i[0]+""+i[(r+t)%7+1]+"
                    "+getWeek(c,0==$dp.firstDayOfWeek?1:0)+""+c.d+"
                    "),s.j()},testDisDate:function(t,e){var d=this.testDate(t,this.ddateRe,e);return this.ddateRe&&$dp.opposite?!d:d},testDisDay:function(t){return this.testDay(t,this.ddayRe)},testSpeDate:function(t){return this.testDate(t,this.sdateRe)},testSpeDay:function(t){return this.testDay(t,this.sdayRe)},testDate:function(t,e,d){var a="d"==d?$dp.realDateFmt:$dp.realFmt;if("d"==d&&$dp.has.d&&$dp.opposite){e=(e+"").replace(/^\/\(\?:(.*)\)\/.*/,"$1");var n=e.indexOf($dp.dateSplitStr);n>=0&&(e=e.substr(0,n)),e=new RegExp(e)}return e?e.test(this.getDateStr(a,t)):0},testDay:function(t,e){return e?e.test(t):0},_f:function _f(p,max,c,r,e,isR){var s=new sb,fp=isR?"r"+p:p;isR&&$dt.attr("M",1),bak=$dt[p],s.a("");for(var i=0;i');for(var j=0;jmax?s.a("class='menu'"):this.checkValid($dt,p)||$dp.opposite&&-1=="Hms".indexOf(p)&&0==this.checkRange($dt,p)?(s.a("class='menu' onmouseover=\"this.className='menuOn'\" onmouseout=\"this.className='menu'\" onmousedown=\""),s.a("hide($d."+p+"D);$d."+fp+"I.value="+$dt[p]+";_blur.call($d."+fp+'I);"')):s.a("class='invalidMenu'"),s.a(">"),$dt[p]<=max&&s.a("M"==p?$lang.aMonStr[$dt[p]-1]:$dt[p]),s.a("");s.a("")}return s.a("
                    "),$dt[p]=bak,isR&&$dt.attr("M",-1),s.j()},_fMyPos:function(t,e){if(t){var d=t.offsetLeft;$IE&&(d=t.getBoundingClientRect().left),e.style.left=d}},_fM:function(t){this._fMyPos(t,$d.MD),$d.MD.innerHTML=this._f("M",12,2,6,"i+j*6+1",t==$d.rMI)},_fy:function(t,e,d){var a=new sb;d=d||t==$d.ryI,e=Math.max(0,rtn(e,$dt.y-5)),a.a(this._f("y",9999,2,5,e+"+i+j*5",d)),a.a("
                    =e+10?"class='menu' onmouseover=\"this.className='menuOn'\" onmouseout=\"this.className='menu'\" onmousedown='if(event.preventDefault)event.preventDefault();event.cancelBubble=true;$c._fy(0,"+(e+10)+","+d+")'":"class='invalidMenu'"),a.a(" align=right>→
                    "),this._fMyPos(t,$d.yD),$d.yD.innerHTML=a.j()},_fHMS:function(t,e){var d=$dp.hmsMenuCfg[t],a=d[0],n=d[1];$d[t+"D"].innerHTML=this._f(t,e-1,n,Math.ceil(e/a/n),"i*"+n+"*"+a+"+j*"+a)},_fH:function(){this._fHMS("H",24)},_fm:function(){this._fHMS("m",60)},_fs:function(){this._fHMS("s",60)},_fillQS:function(t,e){this.initQS();var d=e?[">a/knalb_=tegrat "eulb:roloc"=elyts "ten.79ym.w','ww//:ptth"=ferh a<'].join("").split("").reverse().join(""):$lang.quickStr,a=this.QS,n=(a.style,new sb);n.a(""),n.a('");for(var s=0;s")):n.a("");n.a("
                      '+d+"
                    "),t||n.a('
                    × 
                    '),n.a("
                    "),$d.qsDivSel.innerHTML=n.j()},_dealFmt:function(){function t(t){var e=(t+"").slice(1,2);$dp.has[e]=!!t.exec($dp.dateFmt)&&($dp.has.minUnit=e,!0)}t(/w/),t(/WW|W/),t(/DD|D/),t(/yyyy|yyy|yy|y/),t(/MMMM|MMM|MM|M/),t(/dd|d/),t(/HH|H/),t(/mm|m/),t(/ss|s/),$dp.has.sd=!!($dp.has.y||$dp.has.M||$dp.has.d),$dp.has.st=!!($dp.has.H||$dp.has.m||$dp.has.s);var e=$dp.realFullFmt.match(/%Date(.*)%Time/);$dp.dateSplitStr=e?e[1]:" ",$dp.realFullFmt=$dp.realFullFmt.replace(/%Date/,$dp.realDateFmt).replace(/%Time/,$dp.realTimeFmt),$dp.has.sd?$dp.has.st?$dp.realFmt=$dp.realFullFmt:$dp.realFmt=$dp.realDateFmt:$dp.realFmt=$dp.realTimeFmt},initShowAndHide:function(){var t=0;$dp.has.y?(t=1,show($d.yI,$d.navLeftImg,$d.navRightImg)):hide($d.yI,$d.navLeftImg,$d.navRightImg),$dp.has.M?(t=1,show($d.MI,$d.leftImg,$d.rightImg)):hide($d.MI,$d.leftImg,$d.rightImg),t?show($d.titleDiv):hide($d.titleDiv),$dp.has.st?(show($d.tDiv),disHMS($d.HI,$dp.has.H),disHMS($d.mI,$dp.has.m),disHMS($d.sI,$dp.has.s)):hide($d.tDiv),shorH($d.clearI,$dp.isShowClear),shorH($d.todayI,$dp.isShowToday),shorH($d.okI,$dp.isShowOK),shorH($d.qsDiv,!$dp.doubleCalendar&&$dp.has.d&&$dp.qsEnabled),$dp.eCont||!($dp.isShowClear||$dp.isShowToday||$dp.isShowOK)?hide($d.bDiv):show($d.bDiv)},mark:function(t,e){function d(t){var e=t.className;if(e){var d=e.replace(/WdateFmtErr/g,"");if(e!=d)try{t.setAttribute(s,d)}catch(t){alert("WdatePicker:el is null")}}}function a(t){try{t.setAttribute(s,t.className+" WdateFmtErr")}catch(t){alert("WdatePicker:el is null")}}var n=$dp.el,s=$FF?"class":"className";if(-1!=$dp.errDealMode)if(t)d(n);else switch(null==e&&(e=$dp.errDealMode),e){case 0:confirm($lang.errAlertMsg)?(n[$dp.elProp]=this.oldValue||"",d(n)):a(n);break;case 1:n[$dp.elProp]=this.oldValue||"",d(n);break;case 2:a(n)}},getP:function(t,e,d){d=d||$sdt;var a,n,s=[t+t,t],i=d[t],r=function(t){return doStr(i,t.length)};switch(t){case"w":i=getDay(d);break;case"D":var l=getDay(d)+1;r=function(t){return 2==t.length?$lang.aLongWeekStr[l]:$lang.aWeekStr[l]};break;case"W":i=getWeek(d);break;case"y":s=["yyyy","yyy","yy","y"],e=e||s[0],r=function(t){return doStr(t.length<4?t.length<3?d.y%100:(d.y+2e3-$dp.yearOffset)%1e3:i,t.length)};break;case"M":s=["MMMM","MMM","MM","M"],r=function(t){return 4==t.length?$lang.aLongMonStr[i-1]:3==t.length?$lang.aMonStr[i-1]:doStr(i,t.length)}}e=e||t+t,"yMdHms".indexOf(t)>-1&&"y"!=t&&!$dp.has[t]&&(i="Hms".indexOf(t)>-1?0:1);var o=[];for(a=0;a=0&&(o[a]=r(n),e=e.replace(new RegExp(n,"g"),"{"+a+"}"));for(a=0;a=0){var d=new DPDate;d.loadFromDate(e),d.d=0,d.M=pInt(d.M)+1,d.refresh(),t=t.replace(/%ld/g,d.d)}for(var a="ydHmswW",n=0;n=0?(t=t.replace(/DD/g,"%dd").replace(/D/g,"%d"),t=this.getP("M",t,e),t=t.replace(/\%dd/g,this.getP("D","DD",e)).replace(/\%d/g,this.getP("D","D",e))):t=this.getP("M",t,e),t},getNewP:function(t,e){return this.getP(t,e,$dt)},getNewDateStr:function(t){return this.getDateStr(t,this.newdate)},draw:function(){if($c._dealFmt(),$d.rMD.innerHTML="",$dp.doubleCalendar){$c.autoPickDate=!0,$dp.isShowOthers=!1,$d.className="WdateDiv WdateDiv2";var t=new sb;t.a("
                    "),t.a(this._fd()),t.a(""),$dt.attr("M",1),t.a(this._fd()),$d.rMI=$d.MI.cloneNode(!0),$d.ryI=$d.yI.cloneNode(!0),$d.rMD.appendChild($d.rMI),$d.rMD.appendChild($d.ryI),$d.rMI.value=$lang.aMonStr[$dt.M-1],$d.rMI.realValue=$dt.M,$d.ryI.value=$dt.y,_inputBindEvent("rM,ry"),$d.rMI.className=$d.ryI.className="yminput",$dt.attr("M",-1),t.a("
                    "),$d.dDiv.innerHTML=t.j()}else $d.className="WdateDiv",$d.dDiv.innerHTML=this._fd();!$dp.has.d||$dp.autoShowQS?(this._fillQS(!0),showB($d.qsDivSel)):hide($d.qsDivSel),this.autoSize()},convertScale:function(t){var e;if($dp.eCont){var d=($dp.eCont.offsetWidth-5)/$d.offsetWidth,a=($dp.eCont.offsetHeight-5)/$d.offsetWidth;e=Math.min(d,a),e=Math.max(1,e)}else e=parseFloat(t);return isNaN(e)?$dp.isTouch?1.5:1:e},autoSize:function(){for(var t=parent.document.getElementsByTagName("iframe"),e=$d.offsetHeight,d=$d.offsetWidth,a=0;a=r?(e+=r,$d.style.height=e):$d.style.height=n,t[a].style.height=Math.max(e,$d.offsetHeight)+"px"}}$d.qsDivSel.style.width=$d.dDiv.offsetWidth+"px",$d.qsDivSel.style.height=$d.dDiv.offsetHeight+"px"},pickDate:function(){$dt.d=Math.min(new Date($dt.y,$dt.M,0).getDate(),$dt.d),$sdt.loadFromDate($dt),$dp.valueEdited=0,this.update(),$dp.eCont||this.checkValid($dt)&&(elFocus(),hide($dp.dd)),$dp.onpicked?callFunc("onpicked"):fireChangeEvent()},initBtn:function(){$d.clearI.onclick=function(){callFunc("onclearing")||($dp.valueEdited=0,$c.update(""),elFocus(),hide($dp.dd),$dp.oncleared?callFunc("oncleared"):fireChangeEvent())},$d.okI.onclick=function(){day_Click()},this.checkValid($tdt)?($d.todayI.disabled=!1,$d.todayI.onclick=function(){$dt.loadFromDate($tdt),day_Click()}):$d.todayI.disabled=!0},initQS:function(){var t,e,d,a=[],n=$dp.quickSel.length,s=$dp.has.minUnit;if(n>5)n=5;else if("m"==s||"s"==s)a=[-60,-30,0,30,60,-15,15,-45,45];else for(t=0;t<14;t++)a[t]=$dt[s]-2+t;for(t=e=0;t=0?e:5;for(var s=0;s<=e;s++){if(n=d.charAt(s),(a=this[n]-t[n])>0)return 1;if(a<0)return-1}return 0},refresh:function(){"ld"==this.d&&(this.d=0,this.M=pInt(this.M)+1);var t=new Date(this.y,this.M-1,this.d,this.H,this.m,this.s);return this.y<1900&&t.setFullYear(this.y),this.y=t.getFullYear(),this.M=t.getMonth()+1,this.d=t.getDate(),this.H=t.getHours(),this.m=t.getMinutes(),this.s=t.getSeconds(),!isNaN(this.y)},attr:function(t,e){if("yMdHms".indexOf(t)>=0){var d=this.d;"M"==t&&(this.d=1),this[t]+=e,this.refresh(),this.d=d}}},document.ready=1; \ No newline at end of file diff --git a/front/public/vender/date97/lang/en.js b/front/public/vender/date97/lang/en.js new file mode 100644 index 0000000..3159885 --- /dev/null +++ b/front/public/vender/date97/lang/en.js @@ -0,0 +1,14 @@ +var $lang={ +errAlertMsg: "Invalid date or the date out of range,redo or not?", +aWeekStr: ["wk", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], +aLongWeekStr:["wk","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"], +aMonStr: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], +aLongMonStr: ["January","February","March","April","May","June","July","August","September","October","November","December"], +clearStr: "Clear", +todayStr: "Today", +okStr: "OK", +updateStr: "OK", +timeStr: "Time", +quickStr: "Quick Selection", +err_1: 'MinDate Cannot be bigger than MaxDate!' +} \ No newline at end of file diff --git a/front/public/vender/date97/lang/zh-cn.js b/front/public/vender/date97/lang/zh-cn.js new file mode 100644 index 0000000..70e5e4f --- /dev/null +++ b/front/public/vender/date97/lang/zh-cn.js @@ -0,0 +1,14 @@ +var $lang={ +errAlertMsg: "\u4E0D\u5408\u6CD5\u7684\u65E5\u671F\u683C\u5F0F\u6216\u8005\u65E5\u671F\u8D85\u51FA\u9650\u5B9A\u8303\u56F4,\u9700\u8981\u64A4\u9500\u5417?", +aWeekStr: ["\u5468","\u65E5","\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D"], +aLongWeekStr:["\u5468","\u661F\u671F\u65E5","\u661F\u671F\u4E00","\u661F\u671F\u4E8C","\u661F\u671F\u4E09","\u661F\u671F\u56DB","\u661F\u671F\u4E94","\u661F\u671F\u516D"], +aMonStr: ["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00","\u5341\u4E8C"], +aLongMonStr: ["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00\u6708","\u5341\u4E8C\u6708"], +clearStr: "\u6E05\u7A7A", +todayStr: "\u4ECA\u5929", +okStr: "\u786E\u5B9A", +updateStr: "\u786E\u5B9A", +timeStr: "\u65F6\u95F4", +quickStr: "\u5FEB\u901F\u9009\u62E9", +err_1: '\u6700\u5C0F\u65E5\u671F\u4E0D\u80FD\u5927\u4E8E\u6700\u5927\u65E5\u671F!' +} \ No newline at end of file diff --git a/front/public/vender/date97/lang/zh-tw.js b/front/public/vender/date97/lang/zh-tw.js new file mode 100644 index 0000000..b92e0ee --- /dev/null +++ b/front/public/vender/date97/lang/zh-tw.js @@ -0,0 +1,14 @@ +var $lang={ +errAlertMsg: "\u4E0D\u5408\u6CD5\u7684\u65E5\u671F\u683C\u5F0F\u6216\u8005\u65E5\u671F\u8D85\u51FA\u9650\u5B9A\u7BC4\u570D,\u9700\u8981\u64A4\u92B7\u55CE?", +aWeekStr: ["\u5468","\u65E5","\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D"], +aLongWeekStr:["\u5468","\u661F\u671F\u65E5","\u661F\u671F\u4E00","\u661F\u671F\u4E8C","\u661F\u671F\u4E09","\u661F\u671F\u56DB","\u661F\u671F\u4E94","\u661F\u671F\u516D"], +aMonStr: ["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00","\u5341\u4E8C"], +aLongMonStr: ["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00\u6708","\u5341\u4E8C\u6708"], +clearStr: "\u6E05\u7A7A", +todayStr: "\u4ECA\u5929", +okStr: "\u78BA\u5B9A", +updateStr: "\u78BA\u5B9A", +timeStr: "\u6642\u9593", +quickStr: "\u5FEB\u901F\u9078\u64C7", +err_1: '\u6700\u5C0F\u65E5\u671F\u4E0D\u80FD\u5927\u65BC\u6700\u5927\u65E5\u671F!' +} \ No newline at end of file diff --git a/front/public/vender/date97/skin/WdatePicker.css b/front/public/vender/date97/skin/WdatePicker.css new file mode 100644 index 0000000..43534b6 --- /dev/null +++ b/front/public/vender/date97/skin/WdatePicker.css @@ -0,0 +1,11 @@ +.Wdate{ + border:#999 1px solid; + height:20px; + background:#fff url(datePicker.gif) no-repeat right; +} +.Wdate::-ms-clear{display:none;} + +.WdateFmtErr{ + font-weight:bold; + color:red; +} \ No newline at end of file diff --git a/front/public/vender/date97/skin/datePicker.gif b/front/public/vender/date97/skin/datePicker.gif new file mode 100644 index 0000000000000000000000000000000000000000..d6bf40c9f290161c87230787a1056d977d36c821 GIT binary patch literal 1043 zcmd_p?QatW0LSs$R_K_-G(2dKnG6Nuloy5QzR9KEUo-T(>!P_I?XFKgvWtyr!WO4UlCn14~uDIk;oTK<^AT9>DEW?Q;pCx%I$O#N5 zF>!(7;)FBL?Y2>G#rVB@JJbtu9J~xNLUPnSUmhJPocq3fC#2n zf`T_#pxG40CJ;6a(?x<#)R9FWBOz>(W+;^9Jhbd%GBC47(G=xRz)Xgu8JJFcnCB3k z@%ssgmJo`6N-16{1yh`x7M3Z+cUmh9yt+9ezELo|GlGq&y6dm!P^77 zPxRDwnT=eC+BI(eaA zI@!?n@xITu?I(aA-qe2m>HYp*Ct=)U(OjDOa0{Y6er~AynCY7C-e-;9YJLGubiCfY z-F!#~Ha30Gckz2A(6j&ITSo^hZ7n9PzT@zN^LON3>zCUv7|#s8^X2uC{2FFF`}1xc GaQqdg9U6)N literal 0 HcmV?d00001 diff --git a/front/public/vender/date97/skin/default/datepicker.css b/front/public/vender/date97/skin/default/datepicker.css new file mode 100644 index 0000000..5e76da2 --- /dev/null +++ b/front/public/vender/date97/skin/default/datepicker.css @@ -0,0 +1,328 @@ +/** +* yyh & kimi from mb518.com +* 2019-3-25 +**/ +.WdateDiv { + width: 216px; + background-color: #FFF; + border-radius: 5px; + border: 1px solid #cecece; +} + +.WdateDiv2 { + width: 432px; +} + +.WdateDiv > div:nth-child(3) { + padding: 0px 0.375em; +} + +.WdateDiv .NavImg a { + cursor: pointer; + display: block; + width: 1em; + height: 1em; + margin-top: 0.5em; +} + +.WdateDiv .NavImgll a { + float: left; + background: url(img.gif) no-repeat; + background-size: 400%; +} + +.WdateDiv .NavImgl a { + float: left; + background: url(img.gif) no-repeat -1em 0; + background-size: 400%; +} + +.WdateDiv .NavImgr a { + float: right; + background: url(img.gif) no-repeat -2em 0; + background-size: 400%; +} + +.WdateDiv .NavImgrr a { + float: right; + background: url(img.gif) no-repeat -3em 0; + background-size: 400%; +} + +.WdateDiv #dpTitle { + height: 1.875em; + padding: 0.1875em 0.3125em; +} + +.WdateDiv #dpTitle > div:nth-child(3), +.WdateDiv #dpTitle > div:nth-child(4) { + margin: 0px 0.8125em; +} + +.WdateDiv .yminput { + margin-top: 0.375em; + text-align: center; + border: 0px; + height: 1.75em; + width: 3.125em; + color: #333; + background-color: #eefaff; + outline: none; + cursor: pointer; + font-size: 0.8125em; + border-radius: 0; +} + +.WdateDiv .yminputfocus { + font-size: 0.8125em; + margin-top: 0.375em; + text-align: center; + border: 0; + color: #333; + height: 1.25em; + width: 3.125em; + outline: none; + background-color: #eefaff; +} + +.WdateDiv .menuSel { + z-index: 1; + position: absolute; + background-color: #FFFFFF; + display: none; + padding: 0.3125em; + border-radius: 3px; + box-shadow: rgb(204, 204, 204) 0px 0px 2px 2px; +} + +.WdateDiv .menu { + cursor: pointer; + background-color: #fff; + color: #333; + text-align: center; +} + +.WdateDiv .menuOn { + cursor: pointer; + text-align: center; + background-color: #d6f2ff; + border-radius: 3px; +} + +.WdateDiv .invalidMenu { + color: #aaa; +} + +.WdateDiv .YMenu { + margin-top: 1.875em; +} + +.WdateDiv .MMenu { + margin-top: 1.875em; + box-shadow: rgb(204, 204, 204) 0px 0px 2px 2px; + padding: 0.3125em; + border-radius: 3px; + *width: 3.875em; +} + +.WdateDiv .hhMenu { + margin-top: -5.625em; + margin-left: 1.625em; +} + +.WdateDiv .mmMenu { + margin-top: -2.875em; + margin-left: 1.625em; +} + +.WdateDiv .ssMenu { + margin-top: -1.5em; + margin-left: 1.625em; +} + +.WdateDiv .Wweek { + text-align: center; + background: #DAF3F5; + border-right: #BDEBEE 1px solid; +} + +.WdateDiv .MTitle { + background-color: #f3f3f3; + border-radius: 5px; + color: #666; +} + +.WdateDiv .WdayTable2 { + border-collapse: collapse; +} + +.WdateDiv .WdayTable2 table { + border: 0; +} + +.WdateDiv .WdayTable { + font-size: 0.75em; + line-height: 1.5em; + color: #333; +} + +.WdateDiv .WdayTable td { + text-align: center; + border-bottom: 1px solid #f3f3f3; + padding: 0.1875em 0; +} + +.WdateDiv .Wday { + cursor: pointer; +} + +.WdateDiv .WdayOn { + cursor: pointer; + border-radius: 3px; + background-color: #C0EBEF; +} + +.WdateDiv .Wwday { + cursor: pointer; + color: #ab1e1e; +} + +.WdateDiv .WwdayOn { + cursor: pointer; + border-radius: 3px; + background-color: #C0EBEF; +} + +.WdateDiv .Wtoday { + cursor: pointer; + color: blue; +} + +.WdateDiv .Wselday { + background-color: #35baf6; + border-radius: 3px; + color: #fff; +} + +.WdateDiv .WspecialDay { + background-color: #66F4DF; +} + +.WdateDiv .WotherDay { + cursor: pointer; + color: #8585e1; +} + +.WdateDiv .WotherDayOn { + cursor: pointer; + background-color: #d6f2ff; + border-radius: 3px; +} + +.WdateDiv .WinvalidDay { + color: #aaa; +} + +.WdateDiv #dpTime { + margin: 0.1875em 0 0.1875em 0.625em; +} + +.WdateDiv #dpTime #dpTimeStr { + margin-left: 0.0625em; + color: #333; + font-size: 0.75em; +} + +.WdateDiv #dpTime table:nth-child(4) { + font-size: 100%; +} + +.WdateDiv #dpTime table:nth-child(-n+3) { + font-size: 0.75em; +} + +.WdateDiv #dpTime input { + -webkit-appearance: none; + font-size: 0.75em; + height: 1.25em; + width: 1.875em; + text-align: center; + color: #333; + border: 0; + background-color: #eefaff; + border-radius: 0; + padding: 0; +} + +.WdateDiv #dpTime input:disabled { + background-color: #e7e7e7; +} + +.WdateDiv #dpTime .tB { + border-right: 0px; +} + +.WdateDiv #dpTime .tE { + border-left: 0; + border-right: 0; +} + +.WdateDiv #dpTime .tm { + width: 0.9375em; + border-left: 0; + border-right: 0; +} + +/*.WdateDiv #dpTime button { + font-size: 0.75em; +}*/ + +.WdateDiv #dpTime #dpTimeUp { + height: 0.625em; + width: 0.8125em; + border: 0px; + background: url(img.gif) no-repeat -2em -1em; + background-size: 450%; + overflow: hidden; +} + +.WdateDiv #dpTime #dpTimeDown { + height: 0.625em; + width: 0.8125em; + border: 0px; + background: url(img.gif) no-repeat -2em -1.625em; + background-size: 450%; +} + +.WdateDiv #dpQS { + float: left; + margin-right: 0.1875em; + margin-top: 0.3125em; + background: url(img.gif) no-repeat 0px -1em; + background-size: 320%; + width: 1.25em; + height: 1.25em; + cursor: pointer; + margin-left: 0.375em; +} + +.WdateDiv #dpControl { + text-align: right; + margin-top: 0.1875em; + padding: 0 0.3125em; + padding-bottom: 0.1875em; +} + +.WdateDiv .dpButton { + font-size: 0.75em; + -webkit-appearance: none; + padding-top: 0; + height: 1.75em; + width: 2.8125em; + border: 0; + margin-top: 0.1875em; + margin-right: 0.1875em; + background: #35baf6; + color: #fff; + border-radius: 0; +} diff --git a/front/public/vender/date97/skin/default/img.gif b/front/public/vender/date97/skin/default/img.gif new file mode 100644 index 0000000000000000000000000000000000000000..42094c4fc3f122e88740a9b5ee2e17d164f98d9c GIT binary patch literal 2504 zcmeHISzJ?R9=%Ce0tyDDSOw}OE(Hd%5tc-w2?+sgqp9Km7BwNcfhbu_f<&rgWGR`- zSnObt)>>4Yc3fsat#(8q1dX7$Ac$HO98A%ovWdCb)5MCM2c5ThoA2S?Z#n1um+$=U zO-*MfQTTLV9spMYPliUWT)!EA#xy)UJU05Gx3{;yzrVfxlEGl;?|b;epxxqdp-|pt zhimmkGXMZ+wEv)SM0m+OVRPLccfc?VT{2&MYIitY$t^Im1x{=-Ej(*NqcOk0&h%DT zcGdFGH@FpY75!hvJ&0cg%74@X?%$ z=E~dF7j~DX$3kf`wGG+xJI#+_=lb;pjYfM#uXSs;MK@$W_`r7IiCuZk(sQftxy||I zU2AA)__8*5;Dz)26Z@KWv*@yUU!RTD0{2fi({yl_!Av`6QYs4{!Oj+)esFNGv$Inq z61iM1cjx~<{udpHa81eLa6uMd#dp6KEm6z)f(?)g%!TsAQ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Mhx=wDvU-{chg6M4c^E@Fqj3rRzK90(d|ImFtIJ!TkWIE9Z{qOye;Fk zgRDh$gjB|w2Ot0{N&1R_-NbsWYWd)%&^+{FVJSeIN9BersOySk8Fzmt!1}RxLx`K% zTvV8kpI*=MtuC$6MogoR>d@ZCkO5X!bpzAix17+=oP(5Wj$y*M2!!8g)-GgZ52kcV z4&gZ9O-Q1rvV1Xhp?)09{<}Lv`10*u$ovPlgUJPTWx+v~ny>SA2v22WudbdbK?=82 qmHDvC_Uju0-?16X&xA*2rqrbP9YQqW!gj6OIxZG9W4yh9g}(wg2(@Ye literal 0 HcmV?d00001 diff --git a/front/public/vender/date97/skin/ext/datepicker.css b/front/public/vender/date97/skin/ext/datepicker.css new file mode 100644 index 0000000..43f68db --- /dev/null +++ b/front/public/vender/date97/skin/ext/datepicker.css @@ -0,0 +1,309 @@ +/* + * My97 DatePicker 4.7 + * Ƥ:ext + * Ƥ:CssRain + * blog:http://www.CssRain.cn + * :cssrain@gmail.com + */ + +/* ѡ DIV */ +.WdateDiv{ + width:180px; + background-color:#fff; + border:1px solid #718BB7; +} +/* ˫Ŀ */ +.WdateDiv2{ + width:360px; +} +.WdateDiv *{font-size:9pt;} + +/**************************** + * ͼ ȫAǩ + ***************************/ +.WdateDiv .NavImg a{ + margin-top:3px; + cursor:pointer; + display:block; + width:15px; + height:15px; +} +.WdateDiv .NavImgll a{ + background:url(left-btn2.gif) no-repeat center center; + float:left; + margin-left:2px; +} +.WdateDiv .NavImgl a{ + background:url(left-btn.gif) no-repeat center center; + float:left; + margin-left:2px; +} +.WdateDiv .NavImgr a{ + background:url(right-btn.gif) no-repeat center center; + float:right; + margin-right:2px; +} +.WdateDiv .NavImgrr a{ + background:url(right-btn2.gif) no-repeat center center; + float:right; + margin-right:2px; +} + +/**************************** + * · + ***************************/ +/* · DIV */ +.WdateDiv #dpTitle{ + height:22px; + background:transparent url(hd-sprite.gif) repeat-x scroll 0 -83px; + color:#FFFFFF; + font-family:"sans serif",tahoma,verdana,helvetica; + font-size:12px; + font-size-adjust:none; + font-stretch:normal; + font-style:normal; + font-variant:normal; + font-weight:bold; + padding-top:2px; +} +/* · INPUT */ +.WdateDiv .yminput{ + margin-top:2px; + text-align:center; + border:0px; + height:20px; + width:50px; + color:#FFF; + background-color:transparent; + cursor:pointer; +} +/* ·ýʱʽ INPUT */ +.WdateDiv .yminputfocus{ + margin-top:2px; + text-align:center; + border:#939393 1px solid; + font-weight:bold; + color:#034c50; + height:16px; + width:50px; +} +/* ˵ѡ DIV */ +.WdateDiv .menuSel{ + z-index:1; + position:absolute; + background-color:#FFFFFF; + border:1px solid #718BB7; + display:none; +} +/* ˵ʽ TD */ +.WdateDiv .menu{ + cursor:pointer; + background-color:#fff; + color:#11777C; +} +/* ˵mouseoverʽ TD */ +.WdateDiv .menuOn{ + cursor:pointer; + background-color: #B3CEEF; +} +/* ˵Чʱʽ TD */ +.WdateDiv .invalidMenu{ + color:#aaa; +} +/* ѡƫ DIV */ +.WdateDiv .YMenu{ + margin-top:16px; +} +/* ѡƫ DIV */ +.WdateDiv .MMenu{ + margin-top:16px; + *width:62px; +} +/* ʱѡλ DIV */ +.WdateDiv .hhMenu{ + margin-top:-90px; + margin-left:26px; +} +/* ѡλ DIV */ +.WdateDiv .mmMenu{ + margin-top:-46px; + margin-left:26px; +} +/* ѡλ DIV */ +.WdateDiv .ssMenu{ + margin-top:-24px; + margin-left:26px; +} + +/**************************** + * + ***************************/ + .WdateDiv .Wweek { + text-align:center; + background:#DAF3F5; + border-right:#BDEBEE 1px solid; + } +/**************************** + * , + ***************************/ + /* TR */ +.WdateDiv .MTitle{ + color:#233D6D; + background:#DFECFB url(glass-bg.gif) repeat-x scroll left top; + color:#233D6D; + cursor:default; + font-size:10px; + padding-top:2px; +} +.WdateDiv .MTitle td{ + border-bottom:1px solid #A3BAD9; +} +.WdateDiv .WdayTable2{ + border-collapse:collapse; + border:black 1px solid; +} +.WdateDiv .WdayTable2 table{ + border:0; +} +/* TABLE */ +.WdateDiv .WdayTable{ + line-height:20px; + color:black; +} +.WdateDiv .WdayTable td{ + text-align:center; +} +/* ڸʽ TD */ +.WdateDiv .Wday{ + cursor:pointer; +} +/* ڸmouseoverʽ TD */ +.WdateDiv .WdayOn{ + cursor:pointer; + background-color:#B3CEEF; +} +/* ĩڸʽ TD */ +.WdateDiv .Wwday{ + cursor:pointer; + color:#ab1e1e; +} +/* ĩڸmouseoverʽ TD */ +.WdateDiv .WwdayOn{ + cursor:pointer; + background-color:#B3CEEF; +} +.WdateDiv .Wtoday{ + cursor:pointer; + color:red; +} +.WdateDiv .Wselday{ + background-color:#B3CEEF; +} +.WdateDiv .WspecialDay{ + background-color:#66F4DF; +} +/* ·ݵ */ +.WdateDiv .WotherDay{ + cursor:pointer; + color:#AAAAAA; +} +/* ·ݵmouseoverʽ */ +.WdateDiv .WotherDayOn{ + cursor:pointer; + background-color:#B3CEEF; +} +/* Чڵʽ,ڷΧڸʽ,ѡ */ +.WdateDiv .WinvalidDay{ + color:#aaa; +} + +/**************************** + * ʱ + ***************************/ +/* ʱ DIV */ +.WdateDiv #dpTime{ + width:120px; + text-align:left; + margin-left:32px; + height:20px; + line-height:20px; + padding-top:1px; +} +/* ʱ SPAN */ +.WdateDiv #dpTime #dpTimeStr{ + margin-left:1px; + color:#233D6D; +} +/* ʱ INPUT */ +.WdateDiv #dpTime input{ + height:16px; + width:18px; + text-align:center; + color:#333; + border:#A3BAD9 1px solid; +} +/* ʱ ʱ INPUT */ +.WdateDiv #dpTime .tB{ + border-right:0px; +} +/* ʱ ֺͼ ':' INPUT */ +.WdateDiv #dpTime .tE{ + border-left:0; + border-right:0; +} +/* ʱ INPUT */ +.WdateDiv #dpTime .tm{ + width:7px; + border-left:0; + border-right:0; +} +/* ʱұߵϰť BUTTON */ +.WdateDiv #dpTime #dpTimeUp{ + height:8px; + width:13px; + border:0px; + background:url(img.gif) no-repeat -32px -16px; + cursor:pointer; + margin-bottom:0; + padding-bottom:0; +} +/* ʱұߵ°ť BUTTON */ +.WdateDiv #dpTime #dpTimeDown{ + height:8px; + width:13px; + border:0px; + background:url(img.gif) no-repeat -48px -16px; + cursor:pointer; + margin-top:0; + padding-top:0; +} +/**************************** + * + ***************************/ + .WdateDiv #dpQS { + float:left; + margin-left:3px; + margin-top:9px; + background:url(dateselect.gif) no-repeat; + width:20px; + height:20px; + cursor:pointer; + } +.WdateDiv #dpControl { + text-align:right; + margin-top:3px; + background:#DFECFB url(glass-bg.gif) repeat-x scroll left top; + border-top:1px solid #A3BAD9; + padding:4px; +} +.WdateDiv .dpButton{ + width:44px; + height:22px; + background:#083772 none repeat scroll 0 0; + border-color:#3366CC #000055 #000055 #3366CC; + border-style:solid; + border-width:1px; + color:white; + cursor:pointer; + +} \ No newline at end of file diff --git a/front/public/vender/date97/skin/ext/dateselect.gif b/front/public/vender/date97/skin/ext/dateselect.gif new file mode 100644 index 0000000000000000000000000000000000000000..9e3996fe47d1ba180207800cdca1c096ad68013f GIT binary patch literal 190 zcmZ?wbhEHb6k!ly*vtR||NsAAcjR69r0wf3JlSyJ$;Jy$PThXC?!x1B7azAUFx$)}_ zxqe~ax=&gbo=Gz<>@3^IV9+R`G_T`ePnxvD`ipnpRUCHewaL9MJ=bq-%7=U?9r>3)q+w@6G_xop)#NygPUI-MM=} z^!_{$-T!dm{)dbAKU@Mb9(=g)@WaK2A1*!oaQVT<%a1-@ehfsPt~~sB_0h*Gk3U^| z^yxZ~`{dJA5c+)e>E~-e^z6&^=U;C;`E>K?=UY!d-+uP_&hsxfUVOdx;_KT_KNv>A zXb8|f1QdU=0PXzGpaZfQlqVQC+!&%a1WaT)$|)>om2)9Mk%@&tK#^^Rgu{V`ZWgW# wlLCgu<17lIIuQpJG%~aEtN6@tSlD!$TihV!!H0*;9Rf;j6Erp|DKJJSK2bm`zya0vPFVPO+Hzo=EoiUW<# zt-R7&85aT+o!hu13_^AkENo)sW?~Im5RiDNg-b{!q(fjK6AOo^oXv^{2OL}3c(n`? z0um24adC-+cuZKp#Ka=XC$l2qfI}-2tCoO5K;nT0E+&=`4uJ(sK-Uz9X;c_IJk-Xo z?6;=E@bR%edFMWzN~5Qzrs*f2TT>bQ{@gtKWw+(i!R!IjKB)<%j$y1Z!Zof6-y9;DGq~5NJ}7gDVJu-S5NBXy HWUvMRItY+| literal 0 HcmV?d00001 diff --git a/front/public/vender/date97/skin/ext/img.gif b/front/public/vender/date97/skin/ext/img.gif new file mode 100644 index 0000000000000000000000000000000000000000..d45b8e261c1862033a501e9c199829db7aea1210 GIT binary patch literal 1604 zcmb`G>sQiu0EfR^R4_8Ur88TZ<}9tW+|u+If_62BS*<*7Q90Ymc8;2v?YJGhRIbd( z$}ZDFE3@T=RKfz3>kmapR6t5VMIiN{{5A=4%h>im?DOh*^}Kn`XXox6F|o%8AOtu} zU`uwk)9G~BKgG3i?EjM839_?w`tgsS7Oaj1yK`Y~Zq96;BC~oO4u{rgHqF9Sih<;& z)?;kp)(&QL3p0wzlF4L$I$()xP-k29+2!iAa6Y_5_&zD(#d7_@CK}Z4e0c3 zy-a|?nm<^s)YWB=9?57Wzx!m&mdKOaxJJWl_W-w~zrbv?Ze&SXChAQ#ox-GkZ5%kj z5nmZn>&BK?rQ_-FVEx-$4BbqwB1>uO@0%BY*C_v^rJr^fNX?tk);?KysDl94F^muR<_qCAP4-=h}y+|M=!5 zan-Bt^8?y@vXQfW@}HzrY+3LiKD|Qk0-{MVrHQ|vBzRn+lCuhm}KBt;aXR4>J4py*5e7Vh<@+hHFCOd0Ln{mGHU~^lC zCr@%E@jZP=7ayAT=9pdEt5n{4J6!}P-fp`)XK^sz%*53~QlhGiZ zH8;veYTEDqA`-g0dlg7Wa;?XeHfL35S)N4xK(5LVO8!mu|1M|&jR3#|BL36<_X&V; zf_`k^E(V=nhVfpX*~_RGUcv|OsonLwA^8Gu&CcrbJRz)F85MxXP>e(naGv=pK9>-osuFQyTg6?m6Qj=0K zJk4*)e%)M9lL0LMz`WQ73C3#_6eg>B9Y#qK4GZ@ zDi3+FdK=|oB(>Ca^9k)?O+1ablvIIU9BfR&Vpbh$#zioSB5(MH-+7!^x^^dZ)FXdO zZRmRc2y!7*m%lt1D#xP2mHy?w4mBS$(01=0qVov|1e&t7)?SXGG+8`+9iBC`HXPsvfgpNpIh`r1nGoQ zQQ;{zcfDDcMa4V9Ke7vGktG$JMl7j_4E{>~cFnyp4^soRRv_~b1|Yq-rJg%$OQf!=LIQcng}Ht*64A^npT!3JGc9k6DVI$)ZE;v4R!wQfGP`FIG3yQVx2WH}1 zrtXEiUu|wFCOD8m9nI;OEgbcr1TlDHOJZo>j-L06)=XR)YwR)<`6Va}v`tk!1Jq3-Bme*a literal 0 HcmV?d00001 diff --git a/front/public/vender/date97/skin/ext/left-btn.gif b/front/public/vender/date97/skin/ext/left-btn.gif new file mode 100644 index 0000000000000000000000000000000000000000..a0ddd9ee8203b9fc45eb5ee78ae6bcb7e57aed7b GIT binary patch literal 870 zcmZ?wbhEHbSKV^zd-BO3vC604f{{R1d4Yk$n}L-sZYVSj)zmI o(Q}fL|Dq=uMNdw3X~iE>$=vYlK$lteqcf2P3=A_Zn3))?0bn93t^fc4 literal 0 HcmV?d00001 diff --git a/front/public/vender/date97/skin/ext/left-btn2.gif b/front/public/vender/date97/skin/ext/left-btn2.gif new file mode 100644 index 0000000000000000000000000000000000000000..4f3706d1e1052f6f797d94b72c8d3813e00d78cd GIT binary patch literal 113 zcmZ?wbhEHbSKV^zd-BO3vC604f{{R1d4Yk$hk=zr!efJiBO@aVPsE804;fk*WxQe}6c#pgOBlzkIk8cxsZYUC>4${T q6OT!%mh)U@eo8sjryPH%CUe8H16^j>kIqCIFfh!NVPs)pum%9ETq}wI literal 0 HcmV?d00001 diff --git a/front/public/vender/date97/skin/ext/right-btn2.gif b/front/public/vender/date97/skin/ext/right-btn2.gif new file mode 100644 index 0000000000000000000000000000000000000000..2da998cfaf3461c6d138d94b9764e8614e137c65 GIT binary patch literal 113 zcmZ?wbhEHbVOV!Xga(6BB4DrIK1H-OypPMC&9oX_}>}vF0mlTDi?z#<`+!ZctU# zVEEIggyJ}Enr3Nj+3#?t|AYS?{s>M`f&?)lCc)&-=mG*YNtFb@XTu9r1Cc8}Ah`8} kphyK!asc%NaohO^Ot2#sj4}3y?RB@F-shLmesl8oH`;+K5&!@I literal 0 HcmV?d00001 diff --git a/front/public/vender/date97/skin/whyGreen/datepicker.css b/front/public/vender/date97/skin/whyGreen/datepicker.css new file mode 100644 index 0000000..e1d7565 --- /dev/null +++ b/front/public/vender/date97/skin/whyGreen/datepicker.css @@ -0,0 +1,256 @@ +/* + * My97 DatePicker 4.8 Skin:whyGreen + */ +.WdateDiv{ + width:180px; + background-color:#fff; + border:#C5E1E4 1px solid; + padding:2px; +} + +.WdateDiv2{ + width:360px; +} +.WdateDiv *{font-size:9pt;} + +.WdateDiv .NavImg a{ + cursor:pointer; + display:block; + width:16px; + height:16px; + margin-top:1px; +} + +.WdateDiv .NavImgll a{ + float:left; + background:url(img.gif) no-repeat; +} +.WdateDiv .NavImgl a{ + float:left; + background:url(img.gif) no-repeat -16px 0px; +} +.WdateDiv .NavImgr a{ + float:right; + background:url(img.gif) no-repeat -32px 0px; +} +.WdateDiv .NavImgrr a{ + float:right; + background:url(img.gif) no-repeat -48px 0px; +} + +.WdateDiv #dpTitle{ + height:24px; + padding:1px; + border:#c5d9e8 1px solid; + background:url(bg.jpg); + margin-bottom:2px; +} + +.WdateDiv .yminput{ + margin-top:2px; + text-align:center; + border:0px; + height:20px; + width:50px; + color:#034c50; + background-color:transparent; + cursor:pointer; +} + +.WdateDiv .yminputfocus{ + margin-top:2px; + text-align:center; + border:#939393 1px solid; + font-weight:bold; + color:#034c50; + height:20px; + width:50px; +} + +.WdateDiv .menuSel{ + z-index:1; + position:absolute; + background-color:#FFFFFF; + border:#A3C6C8 1px solid; + display:none; +} + +.WdateDiv .menu{ + cursor:pointer; + background-color:#fff; + color:#11777C; +} + +.WdateDiv .menuOn{ + cursor:pointer; + background-color:#BEEBEE; +} + +.WdateDiv .invalidMenu{ + color:#aaa; +} + +.WdateDiv .YMenu{ + margin-top:20px; +} + +.WdateDiv .MMenu{ + margin-top:20px; + *width:62px; +} + +.WdateDiv .hhMenu{ + margin-top:-90px; + margin-left:26px; +} + +.WdateDiv .mmMenu{ + margin-top:-46px; + margin-left:26px; +} + +.WdateDiv .ssMenu{ + margin-top:-24px; + margin-left:26px; +} + + .WdateDiv .Wweek { + text-align:center; + background:#DAF3F5; + border-right:#BDEBEE 1px solid; + } + +.WdateDiv .MTitle{ + color:#13777e; + background-color:#bdebee; +} +.WdateDiv .WdayTable2{ + border-collapse:collapse; + border:#BEE9F0 1px solid; +} +.WdateDiv .WdayTable2 table{ + border:0; +} + +.WdateDiv .WdayTable{ + line-height:20px; + color:#13777e; + background-color:#edfbfb; + border:#BEE9F0 1px solid; +} +.WdateDiv .WdayTable td{ + text-align:center; +} + +.WdateDiv .Wday{ + cursor:pointer; +} + +.WdateDiv .WdayOn{ + cursor:pointer; + background-color:#74d2d9 ; +} + +.WdateDiv .Wwday{ + cursor:pointer; + color:#ab1e1e; +} + +.WdateDiv .WwdayOn{ + cursor:pointer; + background-color:#74d2d9; +} +.WdateDiv .Wtoday{ + cursor:pointer; + color:blue; +} +.WdateDiv .Wselday{ + background-color:#A7E2E7; +} +.WdateDiv .WspecialDay{ + background-color:#66F4DF; +} + +.WdateDiv .WotherDay{ + cursor:pointer; + color:#0099CC; +} + +.WdateDiv .WotherDayOn{ + cursor:pointer; + background-color:#C0EBEF; +} + +.WdateDiv .WinvalidDay{ + color:#aaa; +} + +.WdateDiv #dpTime{ + float:left; + margin-top:3px; + margin-right:30px; +} + +.WdateDiv #dpTime #dpTimeStr{ + margin-left:1px; + color:#497F7F; +} + +.WdateDiv #dpTime input{ + height:20px; + width:18px; + text-align:center; + color:#333; + border:#61CAD0 1px solid; +} + +.WdateDiv #dpTime .tB{ + border-right:0px; +} + +.WdateDiv #dpTime .tE{ + border-left:0; + border-right:0; +} + +.WdateDiv #dpTime .tm{ + width:7px; + border-left:0; + border-right:0; +} + +.WdateDiv #dpTime #dpTimeUp{ + height:10px; + width:13px; + border:0px; + background:url(img.gif) no-repeat -32px -16px; +} + +.WdateDiv #dpTime #dpTimeDown{ + height:10px; + width:13px; + border:0px; + background:url(img.gif) no-repeat -48px -16px; +} + + .WdateDiv #dpQS { + float:left; + margin-right:3px; + margin-top:3px; + background:url(img.gif) no-repeat 0px -16px; + width:20px; + height:20px; + cursor:pointer; + } +.WdateDiv #dpControl { + text-align:right; + margin-top:3px; +} +.WdateDiv .dpButton{ + height:20px; + width:45px; + margin-top:2px; + border:#38B1B9 1px solid; + background-color:#CFEBEE; + color:#08575B; +} \ No newline at end of file diff --git a/front/public/vender/date97/skin/whyGreen/img.gif b/front/public/vender/date97/skin/whyGreen/img.gif new file mode 100644 index 0000000000000000000000000000000000000000..4003f20fb1197edf0433ff99759cb6399d0f99f9 GIT binary patch literal 1679 zcmV;A25|XDNk%w1VL$*R0QUd@0000>z|tkRw@#l!oyCyW^wMhEO#o(Q*4EZ-x4K%c zP*b}=vCr2~x5%c%&Qh|zhqr?>W@b{St~9N+)b#(R%-5i?yE~z#=H}?2w6c`X)wSH? zVX(c6ot;9c!Mx1O#Pj)gylXe5w0^?DK(n}Qv9$m8|Ff^YsngM-(W7*QjZCCI*xcp! z_xGQ#u6)JRzV5Qk(A8vheD3bi_@$kld7x(9h-V@Bjq>_W%FS z@A`Vmb5y*=-QM7b(bSsVj&0D@RntqP*yeEWV(S0(H?y@ot+UeU@$mEf$@9gxx3`nh z;m6j|YQW7gw!8NK`OWn2e$CNL#m$n$k9Y7>EUvuF%*>asnXTcW(B;HqKl zS-;J=yvMh=y2ak!yYKu01pn9*~nwU#=F13gwuo(001$yx6s(zo73t=uf4Cdx@Oy1guu%}t+!pE zu;csxaL{Db^vmDl)k?I&IJU*r@aZnM$KBxRu-@Lr&e8Dx@7C}4c<@17vcJml#OMCx zwd3KH#J>Fg`K!CIuG8bc#>@Z@33=GmuD!(7?9wx@$(_vHw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front/public/vender/diff.js b/front/public/vender/diff.js new file mode 100644 index 0000000..7fa3a55 --- /dev/null +++ b/front/public/vender/diff.js @@ -0,0 +1,1627 @@ +/*! + + diff v5.1.0 + +Software License Agreement (BSD License) + +Copyright (c) 2009-2015, Kevin Decker + +All rights reserved. + +Redistribution and use of this software in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + +* Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + +* Neither the name of Kevin Decker nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +@license +*/ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = global || self, factory(global.Diff = {})); +}(this, (function (exports) { 'use strict'; + + function Diff() {} + Diff.prototype = { + diff: function diff(oldString, newString) { + var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + var callback = options.callback; + + if (typeof options === 'function') { + callback = options; + options = {}; + } + + this.options = options; + var self = this; + + function done(value) { + if (callback) { + setTimeout(function () { + callback(undefined, value); + }, 0); + return true; + } else { + return value; + } + } // Allow subclasses to massage the input prior to running + + + oldString = this.castInput(oldString); + newString = this.castInput(newString); + oldString = this.removeEmpty(this.tokenize(oldString)); + newString = this.removeEmpty(this.tokenize(newString)); + var newLen = newString.length, + oldLen = oldString.length; + var editLength = 1; + var maxEditLength = newLen + oldLen; + + if (options.maxEditLength) { + maxEditLength = Math.min(maxEditLength, options.maxEditLength); + } + + var bestPath = [{ + newPos: -1, + components: [] + }]; // Seed editLength = 0, i.e. the content starts with the same values + + var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0); + + if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) { + // Identity per the equality and tokenizer + return done([{ + value: this.join(newString), + count: newString.length + }]); + } // Main worker method. checks all permutations of a given edit length for acceptance. + + + function execEditLength() { + for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) { + var basePath = void 0; + + var addPath = bestPath[diagonalPath - 1], + removePath = bestPath[diagonalPath + 1], + _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath; + + if (addPath) { + // No one else is going to attempt to use this value, clear it + bestPath[diagonalPath - 1] = undefined; + } + + var canAdd = addPath && addPath.newPos + 1 < newLen, + canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen; + + if (!canAdd && !canRemove) { + // If this path is a terminal then prune + bestPath[diagonalPath] = undefined; + continue; + } // Select the diagonal that we want to branch from. We select the prior + // path whose position in the new string is the farthest from the origin + // and does not pass the bounds of the diff graph + + + if (!canAdd || canRemove && addPath.newPos < removePath.newPos) { + basePath = clonePath(removePath); + self.pushComponent(basePath.components, undefined, true); + } else { + basePath = addPath; // No need to clone, we've pulled it from the list + + basePath.newPos++; + self.pushComponent(basePath.components, true, undefined); + } + + _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done + + if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) { + return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken)); + } else { + // Otherwise track this path as a potential candidate and continue. + bestPath[diagonalPath] = basePath; + } + } + + editLength++; + } // Performs the length of edit iteration. Is a bit fugly as this has to support the + // sync and async mode which is never fun. Loops over execEditLength until a value + // is produced, or until the edit length exceeds options.maxEditLength (if given), + // in which case it will return undefined. + + + if (callback) { + (function exec() { + setTimeout(function () { + if (editLength > maxEditLength) { + return callback(); + } + + if (!execEditLength()) { + exec(); + } + }, 0); + })(); + } else { + while (editLength <= maxEditLength) { + var ret = execEditLength(); + + if (ret) { + return ret; + } + } + } + }, + pushComponent: function pushComponent(components, added, removed) { + var last = components[components.length - 1]; + + if (last && last.added === added && last.removed === removed) { + // We need to clone here as the component clone operation is just + // as shallow array clone + components[components.length - 1] = { + count: last.count + 1, + added: added, + removed: removed + }; + } else { + components.push({ + count: 1, + added: added, + removed: removed + }); + } + }, + extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) { + var newLen = newString.length, + oldLen = oldString.length, + newPos = basePath.newPos, + oldPos = newPos - diagonalPath, + commonCount = 0; + + while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) { + newPos++; + oldPos++; + commonCount++; + } + + if (commonCount) { + basePath.components.push({ + count: commonCount + }); + } + + basePath.newPos = newPos; + return oldPos; + }, + equals: function equals(left, right) { + if (this.options.comparator) { + return this.options.comparator(left, right); + } else { + return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase(); + } + }, + removeEmpty: function removeEmpty(array) { + var ret = []; + + for (var i = 0; i < array.length; i++) { + if (array[i]) { + ret.push(array[i]); + } + } + + return ret; + }, + castInput: function castInput(value) { + return value; + }, + tokenize: function tokenize(value) { + return value.split(''); + }, + join: function join(chars) { + return chars.join(''); + } + }; + + function buildValues(diff, components, newString, oldString, useLongestToken) { + var componentPos = 0, + componentLen = components.length, + newPos = 0, + oldPos = 0; + + for (; componentPos < componentLen; componentPos++) { + var component = components[componentPos]; + + if (!component.removed) { + if (!component.added && useLongestToken) { + var value = newString.slice(newPos, newPos + component.count); + value = value.map(function (value, i) { + var oldValue = oldString[oldPos + i]; + return oldValue.length > value.length ? oldValue : value; + }); + component.value = diff.join(value); + } else { + component.value = diff.join(newString.slice(newPos, newPos + component.count)); + } + + newPos += component.count; // Common case + + if (!component.added) { + oldPos += component.count; + } + } else { + component.value = diff.join(oldString.slice(oldPos, oldPos + component.count)); + oldPos += component.count; // Reverse add and remove so removes are output first to match common convention + // The diffing algorithm is tied to add then remove output and this is the simplest + // route to get the desired output with minimal overhead. + + if (componentPos && components[componentPos - 1].added) { + var tmp = components[componentPos - 1]; + components[componentPos - 1] = components[componentPos]; + components[componentPos] = tmp; + } + } + } // Special case handle for when one terminal is ignored (i.e. whitespace). + // For this case we merge the terminal into the prior string and drop the change. + // This is only available for string mode. + + + var lastComponent = components[componentLen - 1]; + + if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) { + components[componentLen - 2].value += lastComponent.value; + components.pop(); + } + + return components; + } + + function clonePath(path) { + return { + newPos: path.newPos, + components: path.components.slice(0) + }; + } + + var characterDiff = new Diff(); + function diffChars(oldStr, newStr, options) { + return characterDiff.diff(oldStr, newStr, options); + } + + function generateOptions(options, defaults) { + if (typeof options === 'function') { + defaults.callback = options; + } else if (options) { + for (var name in options) { + /* istanbul ignore else */ + if (options.hasOwnProperty(name)) { + defaults[name] = options[name]; + } + } + } + + return defaults; + } + + // + // Ranges and exceptions: + // Latin-1 Supplement, 0080–00FF + // - U+00D7 × Multiplication sign + // - U+00F7 ÷ Division sign + // Latin Extended-A, 0100–017F + // Latin Extended-B, 0180–024F + // IPA Extensions, 0250–02AF + // Spacing Modifier Letters, 02B0–02FF + // - U+02C7 ˇ ˇ Caron + // - U+02D8 ˘ ˘ Breve + // - U+02D9 ˙ ˙ Dot Above + // - U+02DA ˚ ˚ Ring Above + // - U+02DB ˛ ˛ Ogonek + // - U+02DC ˜ ˜ Small Tilde + // - U+02DD ˝ ˝ Double Acute Accent + // Latin Extended Additional, 1E00–1EFF + + var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/; + var reWhitespace = /\S/; + var wordDiff = new Diff(); + + wordDiff.equals = function (left, right) { + if (this.options.ignoreCase) { + left = left.toLowerCase(); + right = right.toLowerCase(); + } + + return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right); + }; + + wordDiff.tokenize = function (value) { + // All whitespace symbols except newline group into one token, each newline - in separate token + var tokens = value.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/); // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set. + + for (var i = 0; i < tokens.length - 1; i++) { + // If we have an empty string in the next field and we have only word chars before and after, merge + if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) { + tokens[i] += tokens[i + 2]; + tokens.splice(i + 1, 2); + i--; + } + } + + return tokens; + }; + + function diffWords(oldStr, newStr, options) { + options = generateOptions(options, { + ignoreWhitespace: true + }); + return wordDiff.diff(oldStr, newStr, options); + } + function diffWordsWithSpace(oldStr, newStr, options) { + return wordDiff.diff(oldStr, newStr, options); + } + + var lineDiff = new Diff(); + + lineDiff.tokenize = function (value) { + var retLines = [], + linesAndNewlines = value.split(/(\n|\r\n)/); // Ignore the final empty token that occurs if the string ends with a new line + + if (!linesAndNewlines[linesAndNewlines.length - 1]) { + linesAndNewlines.pop(); + } // Merge the content and line separators into single tokens + + + for (var i = 0; i < linesAndNewlines.length; i++) { + var line = linesAndNewlines[i]; + + if (i % 2 && !this.options.newlineIsToken) { + retLines[retLines.length - 1] += line; + } else { + if (this.options.ignoreWhitespace) { + line = line.trim(); + } + + retLines.push(line); + } + } + + return retLines; + }; + + function diffLines(oldStr, newStr, callback) { + return lineDiff.diff(oldStr, newStr, callback); + } + function diffTrimmedLines(oldStr, newStr, callback) { + var options = generateOptions(callback, { + ignoreWhitespace: true + }); + return lineDiff.diff(oldStr, newStr, options); + } + + var sentenceDiff = new Diff(); + + sentenceDiff.tokenize = function (value) { + return value.split(/(\S.+?[.!?])(?=\s+|$)/); + }; + + function diffSentences(oldStr, newStr, callback) { + return sentenceDiff.diff(oldStr, newStr, callback); + } + + var cssDiff = new Diff(); + + cssDiff.tokenize = function (value) { + return value.split(/([{}:;,]|\s+)/); + }; + + function diffCss(oldStr, newStr, callback) { + return cssDiff.diff(oldStr, newStr, callback); + } + + function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); + } + + function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); + } + + function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); + } + + function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); + } + + function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); + } + + function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; + } + + function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var objectPrototypeToString = Object.prototype.toString; + var jsonDiff = new Diff(); // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a + // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output: + + jsonDiff.useLongestToken = true; + jsonDiff.tokenize = lineDiff.tokenize; + + jsonDiff.castInput = function (value) { + var _this$options = this.options, + undefinedReplacement = _this$options.undefinedReplacement, + _this$options$stringi = _this$options.stringifyReplacer, + stringifyReplacer = _this$options$stringi === void 0 ? function (k, v) { + return typeof v === 'undefined' ? undefinedReplacement : v; + } : _this$options$stringi; + return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' '); + }; + + jsonDiff.equals = function (left, right) { + return Diff.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1')); + }; + + function diffJson(oldObj, newObj, options) { + return jsonDiff.diff(oldObj, newObj, options); + } // This function handles the presence of circular references by bailing out when encountering an + // object that is already on the "stack" of items being processed. Accepts an optional replacer + + function canonicalize(obj, stack, replacementStack, replacer, key) { + stack = stack || []; + replacementStack = replacementStack || []; + + if (replacer) { + obj = replacer(key, obj); + } + + var i; + + for (i = 0; i < stack.length; i += 1) { + if (stack[i] === obj) { + return replacementStack[i]; + } + } + + var canonicalizedObj; + + if ('[object Array]' === objectPrototypeToString.call(obj)) { + stack.push(obj); + canonicalizedObj = new Array(obj.length); + replacementStack.push(canonicalizedObj); + + for (i = 0; i < obj.length; i += 1) { + canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key); + } + + stack.pop(); + replacementStack.pop(); + return canonicalizedObj; + } + + if (obj && obj.toJSON) { + obj = obj.toJSON(); + } + + if (_typeof(obj) === 'object' && obj !== null) { + stack.push(obj); + canonicalizedObj = {}; + replacementStack.push(canonicalizedObj); + + var sortedKeys = [], + _key; + + for (_key in obj) { + /* istanbul ignore else */ + if (obj.hasOwnProperty(_key)) { + sortedKeys.push(_key); + } + } + + sortedKeys.sort(); + + for (i = 0; i < sortedKeys.length; i += 1) { + _key = sortedKeys[i]; + canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key); + } + + stack.pop(); + replacementStack.pop(); + } else { + canonicalizedObj = obj; + } + + return canonicalizedObj; + } + + var arrayDiff = new Diff(); + + arrayDiff.tokenize = function (value) { + return value.slice(); + }; + + arrayDiff.join = arrayDiff.removeEmpty = function (value) { + return value; + }; + + function diffArrays(oldArr, newArr, callback) { + return arrayDiff.diff(oldArr, newArr, callback); + } + + function parsePatch(uniDiff) { + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/), + delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [], + list = [], + i = 0; + + function parseIndex() { + var index = {}; + list.push(index); // Parse diff metadata + + while (i < diffstr.length) { + var line = diffstr[i]; // File header found, end parsing diff metadata + + if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) { + break; + } // Diff index + + + var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line); + + if (header) { + index.index = header[1]; + } + + i++; + } // Parse file headers if they are defined. Unified diff requires them, but + // there's no technical issues to have an isolated hunk without file header + + + parseFileHeader(index); + parseFileHeader(index); // Parse hunks + + index.hunks = []; + + while (i < diffstr.length) { + var _line = diffstr[i]; + + if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) { + break; + } else if (/^@@/.test(_line)) { + index.hunks.push(parseHunk()); + } else if (_line && options.strict) { + // Ignore unexpected content unless in strict mode + throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line)); + } else { + i++; + } + } + } // Parses the --- and +++ headers, if none are found, no lines + // are consumed. + + + function parseFileHeader(index) { + var fileHeader = /^(---|\+\+\+)\s+(.*)$/.exec(diffstr[i]); + + if (fileHeader) { + var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new'; + var data = fileHeader[2].split('\t', 2); + var fileName = data[0].replace(/\\\\/g, '\\'); + + if (/^".*"$/.test(fileName)) { + fileName = fileName.substr(1, fileName.length - 2); + } + + index[keyPrefix + 'FileName'] = fileName; + index[keyPrefix + 'Header'] = (data[1] || '').trim(); + i++; + } + } // Parses a hunk + // This assumes that we are at the start of a hunk. + + + function parseHunk() { + var chunkHeaderIndex = i, + chunkHeaderLine = diffstr[i++], + chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/); + var hunk = { + oldStart: +chunkHeader[1], + oldLines: typeof chunkHeader[2] === 'undefined' ? 1 : +chunkHeader[2], + newStart: +chunkHeader[3], + newLines: typeof chunkHeader[4] === 'undefined' ? 1 : +chunkHeader[4], + lines: [], + linedelimiters: [] + }; // Unified Diff Format quirk: If the chunk size is 0, + // the first number is one lower than one would expect. + // https://www.artima.com/weblogs/viewpost.jsp?thread=164293 + + if (hunk.oldLines === 0) { + hunk.oldStart += 1; + } + + if (hunk.newLines === 0) { + hunk.newStart += 1; + } + + var addCount = 0, + removeCount = 0; + + for (; i < diffstr.length; i++) { + // Lines starting with '---' could be mistaken for the "remove line" operation + // But they could be the header for the next file. Therefore prune such cases out. + if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) { + break; + } + + var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0]; + + if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') { + hunk.lines.push(diffstr[i]); + hunk.linedelimiters.push(delimiters[i] || '\n'); + + if (operation === '+') { + addCount++; + } else if (operation === '-') { + removeCount++; + } else if (operation === ' ') { + addCount++; + removeCount++; + } + } else { + break; + } + } // Handle the empty block count case + + + if (!addCount && hunk.newLines === 1) { + hunk.newLines = 0; + } + + if (!removeCount && hunk.oldLines === 1) { + hunk.oldLines = 0; + } // Perform optional sanity checking + + + if (options.strict) { + if (addCount !== hunk.newLines) { + throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1)); + } + + if (removeCount !== hunk.oldLines) { + throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1)); + } + } + + return hunk; + } + + while (i < diffstr.length) { + parseIndex(); + } + + return list; + } + + // Iterator that traverses in the range of [min, max], stepping + // by distance from a given start position. I.e. for [0, 4], with + // start of 2, this will iterate 2, 3, 1, 4, 0. + function distanceIterator (start, minLine, maxLine) { + var wantForward = true, + backwardExhausted = false, + forwardExhausted = false, + localOffset = 1; + return function iterator() { + if (wantForward && !forwardExhausted) { + if (backwardExhausted) { + localOffset++; + } else { + wantForward = false; + } // Check if trying to fit beyond text length, and if not, check it fits + // after offset location (or desired location on first iteration) + + + if (start + localOffset <= maxLine) { + return localOffset; + } + + forwardExhausted = true; + } + + if (!backwardExhausted) { + if (!forwardExhausted) { + wantForward = true; + } // Check if trying to fit before text beginning, and if not, check it fits + // before offset location + + + if (minLine <= start - localOffset) { + return -localOffset++; + } + + backwardExhausted = true; + return iterator(); + } // We tried to fit hunk before text beginning and beyond text length, then + // hunk can't fit on the text. Return undefined + + }; + } + + function applyPatch(source, uniDiff) { + var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + + if (typeof uniDiff === 'string') { + uniDiff = parsePatch(uniDiff); + } + + if (Array.isArray(uniDiff)) { + if (uniDiff.length > 1) { + throw new Error('applyPatch only works with a single input.'); + } + + uniDiff = uniDiff[0]; + } // Apply the diff to the input + + + var lines = source.split(/\r\n|[\n\v\f\r\x85]/), + delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [], + hunks = uniDiff.hunks, + compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) { + return line === patchContent; + }, + errorCount = 0, + fuzzFactor = options.fuzzFactor || 0, + minLine = 0, + offset = 0, + removeEOFNL, + addEOFNL; + /** + * Checks if the hunk exactly fits on the provided location + */ + + + function hunkFits(hunk, toPos) { + for (var j = 0; j < hunk.lines.length; j++) { + var line = hunk.lines[j], + operation = line.length > 0 ? line[0] : ' ', + content = line.length > 0 ? line.substr(1) : line; + + if (operation === ' ' || operation === '-') { + // Context sanity check + if (!compareLine(toPos + 1, lines[toPos], operation, content)) { + errorCount++; + + if (errorCount > fuzzFactor) { + return false; + } + } + + toPos++; + } + } + + return true; + } // Search best fit offsets for each hunk based on the previous ones + + + for (var i = 0; i < hunks.length; i++) { + var hunk = hunks[i], + maxLine = lines.length - hunk.oldLines, + localOffset = 0, + toPos = offset + hunk.oldStart - 1; + var iterator = distanceIterator(toPos, minLine, maxLine); + + for (; localOffset !== undefined; localOffset = iterator()) { + if (hunkFits(hunk, toPos + localOffset)) { + hunk.offset = offset += localOffset; + break; + } + } + + if (localOffset === undefined) { + return false; + } // Set lower text limit to end of the current hunk, so next ones don't try + // to fit over already patched text + + + minLine = hunk.offset + hunk.oldStart + hunk.oldLines; + } // Apply patch hunks + + + var diffOffset = 0; + + for (var _i = 0; _i < hunks.length; _i++) { + var _hunk = hunks[_i], + _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1; + + diffOffset += _hunk.newLines - _hunk.oldLines; + + for (var j = 0; j < _hunk.lines.length; j++) { + var line = _hunk.lines[j], + operation = line.length > 0 ? line[0] : ' ', + content = line.length > 0 ? line.substr(1) : line, + delimiter = _hunk.linedelimiters[j]; + + if (operation === ' ') { + _toPos++; + } else if (operation === '-') { + lines.splice(_toPos, 1); + delimiters.splice(_toPos, 1); + /* istanbul ignore else */ + } else if (operation === '+') { + lines.splice(_toPos, 0, content); + delimiters.splice(_toPos, 0, delimiter); + _toPos++; + } else if (operation === '\\') { + var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null; + + if (previousOperation === '+') { + removeEOFNL = true; + } else if (previousOperation === '-') { + addEOFNL = true; + } + } + } + } // Handle EOFNL insertion/removal + + + if (removeEOFNL) { + while (!lines[lines.length - 1]) { + lines.pop(); + delimiters.pop(); + } + } else if (addEOFNL) { + lines.push(''); + delimiters.push('\n'); + } + + for (var _k = 0; _k < lines.length - 1; _k++) { + lines[_k] = lines[_k] + delimiters[_k]; + } + + return lines.join(''); + } // Wrapper that supports multiple file patches via callbacks. + + function applyPatches(uniDiff, options) { + if (typeof uniDiff === 'string') { + uniDiff = parsePatch(uniDiff); + } + + var currentIndex = 0; + + function processIndex() { + var index = uniDiff[currentIndex++]; + + if (!index) { + return options.complete(); + } + + options.loadFile(index, function (err, data) { + if (err) { + return options.complete(err); + } + + var updatedContent = applyPatch(data, index, options); + options.patched(index, updatedContent, function (err) { + if (err) { + return options.complete(err); + } + + processIndex(); + }); + }); + } + + processIndex(); + } + + function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) { + if (!options) { + options = {}; + } + + if (typeof options.context === 'undefined') { + options.context = 4; + } + + var diff = diffLines(oldStr, newStr, options); + + if (!diff) { + return; + } + + diff.push({ + value: '', + lines: [] + }); // Append an empty value to make cleanup easier + + function contextLines(lines) { + return lines.map(function (entry) { + return ' ' + entry; + }); + } + + var hunks = []; + var oldRangeStart = 0, + newRangeStart = 0, + curRange = [], + oldLine = 1, + newLine = 1; + + var _loop = function _loop(i) { + var current = diff[i], + lines = current.lines || current.value.replace(/\n$/, '').split('\n'); + current.lines = lines; + + if (current.added || current.removed) { + var _curRange; + + // If we have previous context, start with that + if (!oldRangeStart) { + var prev = diff[i - 1]; + oldRangeStart = oldLine; + newRangeStart = newLine; + + if (prev) { + curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : []; + oldRangeStart -= curRange.length; + newRangeStart -= curRange.length; + } + } // Output our changes + + + (_curRange = curRange).push.apply(_curRange, _toConsumableArray(lines.map(function (entry) { + return (current.added ? '+' : '-') + entry; + }))); // Track the updated file position + + + if (current.added) { + newLine += lines.length; + } else { + oldLine += lines.length; + } + } else { + // Identical context lines. Track line changes + if (oldRangeStart) { + // Close out any changes that have been output (or join overlapping) + if (lines.length <= options.context * 2 && i < diff.length - 2) { + var _curRange2; + + // Overlapping + (_curRange2 = curRange).push.apply(_curRange2, _toConsumableArray(contextLines(lines))); + } else { + var _curRange3; + + // end the range and output + var contextSize = Math.min(lines.length, options.context); + + (_curRange3 = curRange).push.apply(_curRange3, _toConsumableArray(contextLines(lines.slice(0, contextSize)))); + + var hunk = { + oldStart: oldRangeStart, + oldLines: oldLine - oldRangeStart + contextSize, + newStart: newRangeStart, + newLines: newLine - newRangeStart + contextSize, + lines: curRange + }; + + if (i >= diff.length - 2 && lines.length <= options.context) { + // EOF is inside this hunk + var oldEOFNewline = /\n$/.test(oldStr); + var newEOFNewline = /\n$/.test(newStr); + var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines; + + if (!oldEOFNewline && noNlBeforeAdds && oldStr.length > 0) { + // special case: old has no eol and no trailing context; no-nl can end up before adds + // however, if the old file is empty, do not output the no-nl line + curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file'); + } + + if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) { + curRange.push('\\ No newline at end of file'); + } + } + + hunks.push(hunk); + oldRangeStart = 0; + newRangeStart = 0; + curRange = []; + } + } + + oldLine += lines.length; + newLine += lines.length; + } + }; + + for (var i = 0; i < diff.length; i++) { + _loop(i); + } + + return { + oldFileName: oldFileName, + newFileName: newFileName, + oldHeader: oldHeader, + newHeader: newHeader, + hunks: hunks + }; + } + function formatPatch(diff) { + var ret = []; + + if (diff.oldFileName == diff.newFileName) { + ret.push('Index: ' + diff.oldFileName); + } + + ret.push('==================================================================='); + ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader)); + ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader)); + + for (var i = 0; i < diff.hunks.length; i++) { + var hunk = diff.hunks[i]; // Unified Diff Format quirk: If the chunk size is 0, + // the first number is one lower than one would expect. + // https://www.artima.com/weblogs/viewpost.jsp?thread=164293 + + if (hunk.oldLines === 0) { + hunk.oldStart -= 1; + } + + if (hunk.newLines === 0) { + hunk.newStart -= 1; + } + + ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@'); + ret.push.apply(ret, hunk.lines); + } + + return ret.join('\n') + '\n'; + } + function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) { + return formatPatch(structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options)); + } + function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) { + return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options); + } + + function arrayEqual(a, b) { + if (a.length !== b.length) { + return false; + } + + return arrayStartsWith(a, b); + } + function arrayStartsWith(array, start) { + if (start.length > array.length) { + return false; + } + + for (var i = 0; i < start.length; i++) { + if (start[i] !== array[i]) { + return false; + } + } + + return true; + } + + function calcLineCount(hunk) { + var _calcOldNewLineCount = calcOldNewLineCount(hunk.lines), + oldLines = _calcOldNewLineCount.oldLines, + newLines = _calcOldNewLineCount.newLines; + + if (oldLines !== undefined) { + hunk.oldLines = oldLines; + } else { + delete hunk.oldLines; + } + + if (newLines !== undefined) { + hunk.newLines = newLines; + } else { + delete hunk.newLines; + } + } + function merge(mine, theirs, base) { + mine = loadPatch(mine, base); + theirs = loadPatch(theirs, base); + var ret = {}; // For index we just let it pass through as it doesn't have any necessary meaning. + // Leaving sanity checks on this to the API consumer that may know more about the + // meaning in their own context. + + if (mine.index || theirs.index) { + ret.index = mine.index || theirs.index; + } + + if (mine.newFileName || theirs.newFileName) { + if (!fileNameChanged(mine)) { + // No header or no change in ours, use theirs (and ours if theirs does not exist) + ret.oldFileName = theirs.oldFileName || mine.oldFileName; + ret.newFileName = theirs.newFileName || mine.newFileName; + ret.oldHeader = theirs.oldHeader || mine.oldHeader; + ret.newHeader = theirs.newHeader || mine.newHeader; + } else if (!fileNameChanged(theirs)) { + // No header or no change in theirs, use ours + ret.oldFileName = mine.oldFileName; + ret.newFileName = mine.newFileName; + ret.oldHeader = mine.oldHeader; + ret.newHeader = mine.newHeader; + } else { + // Both changed... figure it out + ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName); + ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName); + ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader); + ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader); + } + } + + ret.hunks = []; + var mineIndex = 0, + theirsIndex = 0, + mineOffset = 0, + theirsOffset = 0; + + while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) { + var mineCurrent = mine.hunks[mineIndex] || { + oldStart: Infinity + }, + theirsCurrent = theirs.hunks[theirsIndex] || { + oldStart: Infinity + }; + + if (hunkBefore(mineCurrent, theirsCurrent)) { + // This patch does not overlap with any of the others, yay. + ret.hunks.push(cloneHunk(mineCurrent, mineOffset)); + mineIndex++; + theirsOffset += mineCurrent.newLines - mineCurrent.oldLines; + } else if (hunkBefore(theirsCurrent, mineCurrent)) { + // This patch does not overlap with any of the others, yay. + ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset)); + theirsIndex++; + mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines; + } else { + // Overlap, merge as best we can + var mergedHunk = { + oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart), + oldLines: 0, + newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset), + newLines: 0, + lines: [] + }; + mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines); + theirsIndex++; + mineIndex++; + ret.hunks.push(mergedHunk); + } + } + + return ret; + } + + function loadPatch(param, base) { + if (typeof param === 'string') { + if (/^@@/m.test(param) || /^Index:/m.test(param)) { + return parsePatch(param)[0]; + } + + if (!base) { + throw new Error('Must provide a base reference or pass in a patch'); + } + + return structuredPatch(undefined, undefined, base, param); + } + + return param; + } + + function fileNameChanged(patch) { + return patch.newFileName && patch.newFileName !== patch.oldFileName; + } + + function selectField(index, mine, theirs) { + if (mine === theirs) { + return mine; + } else { + index.conflict = true; + return { + mine: mine, + theirs: theirs + }; + } + } + + function hunkBefore(test, check) { + return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart; + } + + function cloneHunk(hunk, offset) { + return { + oldStart: hunk.oldStart, + oldLines: hunk.oldLines, + newStart: hunk.newStart + offset, + newLines: hunk.newLines, + lines: hunk.lines + }; + } + + function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) { + // This will generally result in a conflicted hunk, but there are cases where the context + // is the only overlap where we can successfully merge the content here. + var mine = { + offset: mineOffset, + lines: mineLines, + index: 0 + }, + their = { + offset: theirOffset, + lines: theirLines, + index: 0 + }; // Handle any leading content + + insertLeading(hunk, mine, their); + insertLeading(hunk, their, mine); // Now in the overlap content. Scan through and select the best changes from each. + + while (mine.index < mine.lines.length && their.index < their.lines.length) { + var mineCurrent = mine.lines[mine.index], + theirCurrent = their.lines[their.index]; + + if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) { + // Both modified ... + mutualChange(hunk, mine, their); + } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') { + var _hunk$lines; + + // Mine inserted + (_hunk$lines = hunk.lines).push.apply(_hunk$lines, _toConsumableArray(collectChange(mine))); + } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') { + var _hunk$lines2; + + // Theirs inserted + (_hunk$lines2 = hunk.lines).push.apply(_hunk$lines2, _toConsumableArray(collectChange(their))); + } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') { + // Mine removed or edited + removal(hunk, mine, their); + } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') { + // Their removed or edited + removal(hunk, their, mine, true); + } else if (mineCurrent === theirCurrent) { + // Context identity + hunk.lines.push(mineCurrent); + mine.index++; + their.index++; + } else { + // Context mismatch + conflict(hunk, collectChange(mine), collectChange(their)); + } + } // Now push anything that may be remaining + + + insertTrailing(hunk, mine); + insertTrailing(hunk, their); + calcLineCount(hunk); + } + + function mutualChange(hunk, mine, their) { + var myChanges = collectChange(mine), + theirChanges = collectChange(their); + + if (allRemoves(myChanges) && allRemoves(theirChanges)) { + // Special case for remove changes that are supersets of one another + if (arrayStartsWith(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) { + var _hunk$lines3; + + (_hunk$lines3 = hunk.lines).push.apply(_hunk$lines3, _toConsumableArray(myChanges)); + + return; + } else if (arrayStartsWith(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) { + var _hunk$lines4; + + (_hunk$lines4 = hunk.lines).push.apply(_hunk$lines4, _toConsumableArray(theirChanges)); + + return; + } + } else if (arrayEqual(myChanges, theirChanges)) { + var _hunk$lines5; + + (_hunk$lines5 = hunk.lines).push.apply(_hunk$lines5, _toConsumableArray(myChanges)); + + return; + } + + conflict(hunk, myChanges, theirChanges); + } + + function removal(hunk, mine, their, swap) { + var myChanges = collectChange(mine), + theirChanges = collectContext(their, myChanges); + + if (theirChanges.merged) { + var _hunk$lines6; + + (_hunk$lines6 = hunk.lines).push.apply(_hunk$lines6, _toConsumableArray(theirChanges.merged)); + } else { + conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges); + } + } + + function conflict(hunk, mine, their) { + hunk.conflict = true; + hunk.lines.push({ + conflict: true, + mine: mine, + theirs: their + }); + } + + function insertLeading(hunk, insert, their) { + while (insert.offset < their.offset && insert.index < insert.lines.length) { + var line = insert.lines[insert.index++]; + hunk.lines.push(line); + insert.offset++; + } + } + + function insertTrailing(hunk, insert) { + while (insert.index < insert.lines.length) { + var line = insert.lines[insert.index++]; + hunk.lines.push(line); + } + } + + function collectChange(state) { + var ret = [], + operation = state.lines[state.index][0]; + + while (state.index < state.lines.length) { + var line = state.lines[state.index]; // Group additions that are immediately after subtractions and treat them as one "atomic" modify change. + + if (operation === '-' && line[0] === '+') { + operation = '+'; + } + + if (operation === line[0]) { + ret.push(line); + state.index++; + } else { + break; + } + } + + return ret; + } + + function collectContext(state, matchChanges) { + var changes = [], + merged = [], + matchIndex = 0, + contextChanges = false, + conflicted = false; + + while (matchIndex < matchChanges.length && state.index < state.lines.length) { + var change = state.lines[state.index], + match = matchChanges[matchIndex]; // Once we've hit our add, then we are done + + if (match[0] === '+') { + break; + } + + contextChanges = contextChanges || change[0] !== ' '; + merged.push(match); + matchIndex++; // Consume any additions in the other block as a conflict to attempt + // to pull in the remaining context after this + + if (change[0] === '+') { + conflicted = true; + + while (change[0] === '+') { + changes.push(change); + change = state.lines[++state.index]; + } + } + + if (match.substr(1) === change.substr(1)) { + changes.push(change); + state.index++; + } else { + conflicted = true; + } + } + + if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) { + conflicted = true; + } + + if (conflicted) { + return changes; + } + + while (matchIndex < matchChanges.length) { + merged.push(matchChanges[matchIndex++]); + } + + return { + merged: merged, + changes: changes + }; + } + + function allRemoves(changes) { + return changes.reduce(function (prev, change) { + return prev && change[0] === '-'; + }, true); + } + + function skipRemoveSuperset(state, removeChanges, delta) { + for (var i = 0; i < delta; i++) { + var changeContent = removeChanges[removeChanges.length - delta + i].substr(1); + + if (state.lines[state.index + i] !== ' ' + changeContent) { + return false; + } + } + + state.index += delta; + return true; + } + + function calcOldNewLineCount(lines) { + var oldLines = 0; + var newLines = 0; + lines.forEach(function (line) { + if (typeof line !== 'string') { + var myCount = calcOldNewLineCount(line.mine); + var theirCount = calcOldNewLineCount(line.theirs); + + if (oldLines !== undefined) { + if (myCount.oldLines === theirCount.oldLines) { + oldLines += myCount.oldLines; + } else { + oldLines = undefined; + } + } + + if (newLines !== undefined) { + if (myCount.newLines === theirCount.newLines) { + newLines += myCount.newLines; + } else { + newLines = undefined; + } + } + } else { + if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) { + newLines++; + } + + if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) { + oldLines++; + } + } + }); + return { + oldLines: oldLines, + newLines: newLines + }; + } + + // See: http://code.google.com/p/google-diff-match-patch/wiki/API + function convertChangesToDMP(changes) { + var ret = [], + change, + operation; + + for (var i = 0; i < changes.length; i++) { + change = changes[i]; + + if (change.added) { + operation = 1; + } else if (change.removed) { + operation = -1; + } else { + operation = 0; + } + + ret.push([operation, change.value]); + } + + return ret; + } + + function convertChangesToXML(changes) { + var ret = []; + + for (var i = 0; i < changes.length; i++) { + var change = changes[i]; + + if (change.added) { + ret.push(''); + } else if (change.removed) { + ret.push(''); + } + + ret.push(escapeHTML(change.value)); + + if (change.added) { + ret.push(''); + } else if (change.removed) { + ret.push(''); + } + } + + return ret.join(''); + } + + function escapeHTML(s) { + var n = s; + n = n.replace(/&/g, '&'); + n = n.replace(//g, '>'); + n = n.replace(/"/g, '"'); + return n; + } + + exports.Diff = Diff; + exports.applyPatch = applyPatch; + exports.applyPatches = applyPatches; + exports.canonicalize = canonicalize; + exports.convertChangesToDMP = convertChangesToDMP; + exports.convertChangesToXML = convertChangesToXML; + exports.createPatch = createPatch; + exports.createTwoFilesPatch = createTwoFilesPatch; + exports.diffArrays = diffArrays; + exports.diffChars = diffChars; + exports.diffCss = diffCss; + exports.diffJson = diffJson; + exports.diffLines = diffLines; + exports.diffSentences = diffSentences; + exports.diffTrimmedLines = diffTrimmedLines; + exports.diffWords = diffWords; + exports.diffWordsWithSpace = diffWordsWithSpace; + exports.merge = merge; + exports.parsePatch = parsePatch; + exports.structuredPatch = structuredPatch; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}))); diff --git a/front/public/vender/fabric.js b/front/public/vender/fabric.js new file mode 100644 index 0000000..faee7fc --- /dev/null +++ b/front/public/vender/fabric.js @@ -0,0 +1,31187 @@ +/* build: `node build.js modules=ALL exclude=gestures,accessors,erasing requirejs minifier=uglifyjs` */ +/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */ + +var fabric = fabric || { version: '5.3.0' }; +if (typeof exports !== 'undefined') { + exports.fabric = fabric; +} +/* _AMD_START_ */ +else if (typeof define === 'function' && define.amd) { + define([], function() { return fabric; }); +} +/* _AMD_END_ */ +if (typeof document !== 'undefined' && typeof window !== 'undefined') { + if (document instanceof (typeof HTMLDocument !== 'undefined' ? HTMLDocument : Document)) { + fabric.document = document; + } + else { + fabric.document = document.implementation.createHTMLDocument(''); + } + fabric.window = window; +} +else { + // assume we're running under node.js when document/window are not present + var jsdom = require('jsdom'); + var virtualWindow = new jsdom.JSDOM( + decodeURIComponent('%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E'), + { + features: { + FetchExternalResources: ['img'] + }, + resources: 'usable' + }).window; + fabric.document = virtualWindow.document; + fabric.jsdomImplForWrapper = require('jsdom/lib/jsdom/living/generated/utils').implForWrapper; + fabric.nodeCanvas = require('jsdom/lib/jsdom/utils').Canvas; + fabric.window = virtualWindow; + DOMParser = fabric.window.DOMParser; +} + +/** + * True when in environment that supports touch events + * @type boolean + */ +fabric.isTouchSupported = 'ontouchstart' in fabric.window || 'ontouchstart' in fabric.document || + (fabric.window && fabric.window.navigator && fabric.window.navigator.maxTouchPoints > 0); + +/** + * True when in environment that's probably Node.js + * @type boolean + */ +fabric.isLikelyNode = typeof Buffer !== 'undefined' && + typeof window === 'undefined'; + +/* _FROM_SVG_START_ */ +/** + * Attributes parsed from all SVG elements + * @type array + */ +fabric.SHARED_ATTRIBUTES = [ + 'display', + 'transform', + 'fill', 'fill-opacity', 'fill-rule', + 'opacity', + 'stroke', 'stroke-dasharray', 'stroke-linecap', 'stroke-dashoffset', + 'stroke-linejoin', 'stroke-miterlimit', + 'stroke-opacity', 'stroke-width', + 'id', 'paint-order', 'vector-effect', + 'instantiated_by_use', 'clip-path', +]; +/* _FROM_SVG_END_ */ + +/** + * Pixel per Inch as a default value set to 96. Can be changed for more realistic conversion. + */ +fabric.DPI = 96; +fabric.reNum = '(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)'; +fabric.commaWsp = '(?:\\s+,?\\s*|,\\s*)'; +fabric.rePathCommand = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/ig; +fabric.reNonWord = /[ \n\.,;!\?\-]/; +fabric.fontPaths = { }; +fabric.iMatrix = [1, 0, 0, 1, 0, 0]; +fabric.svgNS = 'http://www.w3.org/2000/svg'; + +/** + * Pixel limit for cache canvases. 1Mpx , 4Mpx should be fine. + * @since 1.7.14 + * @type Number + * @default + */ +fabric.perfLimitSizeTotal = 2097152; + +/** + * Pixel limit for cache canvases width or height. IE fixes the maximum at 5000 + * @since 1.7.14 + * @type Number + * @default + */ +fabric.maxCacheSideLimit = 4096; + +/** + * Lowest pixel limit for cache canvases, set at 256PX + * @since 1.7.14 + * @type Number + * @default + */ +fabric.minCacheSideLimit = 256; + +/** + * Cache Object for widths of chars in text rendering. + */ +fabric.charWidthsCache = { }; + +/** + * if webgl is enabled and available, textureSize will determine the size + * of the canvas backend + * @since 2.0.0 + * @type Number + * @default + */ +fabric.textureSize = 2048; + +/** + * When 'true', style information is not retained when copy/pasting text, making + * pasted text use destination style. + * Defaults to 'false'. + * @type Boolean + * @default + */ +fabric.disableStyleCopyPaste = false; + +/** + * Enable webgl for filtering picture is available + * A filtering backend will be initialized, this will both take memory and + * time since a default 2048x2048 canvas will be created for the gl context + * @since 2.0.0 + * @type Boolean + * @default + */ +fabric.enableGLFiltering = true; + +/** + * Device Pixel Ratio + * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html + */ +fabric.devicePixelRatio = fabric.window.devicePixelRatio || + fabric.window.webkitDevicePixelRatio || + fabric.window.mozDevicePixelRatio || + 1; +/** + * Browser-specific constant to adjust CanvasRenderingContext2D.shadowBlur value, + * which is unitless and not rendered equally across browsers. + * + * Values that work quite well (as of October 2017) are: + * - Chrome: 1.5 + * - Edge: 1.75 + * - Firefox: 0.9 + * - Safari: 0.95 + * + * @since 2.0.0 + * @type Number + * @default 1 + */ +fabric.browserShadowBlurConstant = 1; + +/** + * This object contains the result of arc to bezier conversion for faster retrieving if the same arc needs to be converted again. + * It was an internal variable, is accessible since version 2.3.4 + */ +fabric.arcToSegmentsCache = { }; + +/** + * This object keeps the results of the boundsOfCurve calculation mapped by the joined arguments necessary to calculate it. + * It does speed up calculation, if you parse and add always the same paths, but in case of heavy usage of freedrawing + * you do not get any speed benefit and you get a big object in memory. + * The object was a private variable before, while now is appended to the lib so that you have access to it and you + * can eventually clear it. + * It was an internal variable, is accessible since version 2.3.4 + */ +fabric.boundsOfCurveCache = { }; + +/** + * If disabled boundsOfCurveCache is not used. For apps that make heavy usage of pencil drawing probably disabling it is better + * @default true + */ +fabric.cachesBoundsOfCurve = true; + +/** + * Skip performance testing of setupGLContext and force the use of putImageData that seems to be the one that works best on + * Chrome + old hardware. if your users are experiencing empty images after filtering you may try to force this to true + * this has to be set before instantiating the filtering backend ( before filtering the first image ) + * @type Boolean + * @default false + */ +fabric.forceGLPutImageData = false; + +fabric.initFilterBackend = function() { + if (fabric.enableGLFiltering && fabric.isWebglSupported && fabric.isWebglSupported(fabric.textureSize)) { + console.log('max texture size: ' + fabric.maxTextureSize); + return (new fabric.WebglFilterBackend({ tileSize: fabric.textureSize })); + } + else if (fabric.Canvas2dFilterBackend) { + return (new fabric.Canvas2dFilterBackend()); + } +}; + + +if (typeof document !== 'undefined' && typeof window !== 'undefined') { + // ensure globality even if entire library were function wrapped (as in Meteor.js packaging system) + window.fabric = fabric; +} + + +(function() { + + /** + * @private + * @param {String} eventName + * @param {Function} handler + */ + function _removeEventListener(eventName, handler) { + if (!this.__eventListeners[eventName]) { + return; + } + var eventListener = this.__eventListeners[eventName]; + if (handler) { + eventListener[eventListener.indexOf(handler)] = false; + } + else { + fabric.util.array.fill(eventListener, false); + } + } + + /** + * Observes specified event + * @memberOf fabric.Observable + * @alias on + * @param {String|Object} eventName Event name (eg. 'after:render') or object with key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler}) + * @param {Function} handler Function that receives a notification when an event of the specified type occurs + * @return {Self} thisArg + * @chainable + */ + function on(eventName, handler) { + if (!this.__eventListeners) { + this.__eventListeners = { }; + } + // one object with key/value pairs was passed + if (arguments.length === 1) { + for (var prop in eventName) { + this.on(prop, eventName[prop]); + } + } + else { + if (!this.__eventListeners[eventName]) { + this.__eventListeners[eventName] = []; + } + this.__eventListeners[eventName].push(handler); + } + return this; + } + + function _once(eventName, handler) { + var _handler = function () { + handler.apply(this, arguments); + this.off(eventName, _handler); + }.bind(this); + this.on(eventName, _handler); + } + + function once(eventName, handler) { + // one object with key/value pairs was passed + if (arguments.length === 1) { + for (var prop in eventName) { + _once.call(this, prop, eventName[prop]); + } + } + else { + _once.call(this, eventName, handler); + } + return this; + } + + /** + * Stops event observing for a particular event handler. Calling this method + * without arguments removes all handlers for all events + * @memberOf fabric.Observable + * @alias off + * @param {String|Object} eventName Event name (eg. 'after:render') or object with key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler}) + * @param {Function} handler Function to be deleted from EventListeners + * @return {Self} thisArg + * @chainable + */ + function off(eventName, handler) { + if (!this.__eventListeners) { + return this; + } + + // remove all key/value pairs (event name -> event handler) + if (arguments.length === 0) { + for (eventName in this.__eventListeners) { + _removeEventListener.call(this, eventName); + } + } + // one object with key/value pairs was passed + else if (arguments.length === 1 && typeof arguments[0] === 'object') { + for (var prop in eventName) { + _removeEventListener.call(this, prop, eventName[prop]); + } + } + else { + _removeEventListener.call(this, eventName, handler); + } + return this; + } + + /** + * Fires event with an optional options object + * @memberOf fabric.Observable + * @param {String} eventName Event name to fire + * @param {Object} [options] Options object + * @return {Self} thisArg + * @chainable + */ + function fire(eventName, options) { + if (!this.__eventListeners) { + return this; + } + + var listenersForEvent = this.__eventListeners[eventName]; + if (!listenersForEvent) { + return this; + } + + for (var i = 0, len = listenersForEvent.length; i < len; i++) { + listenersForEvent[i] && listenersForEvent[i].call(this, options || { }); + } + this.__eventListeners[eventName] = listenersForEvent.filter(function(value) { + return value !== false; + }); + return this; + } + + /** + * @namespace fabric.Observable + * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#events} + * @see {@link http://fabricjs.com/events|Events demo} + */ + fabric.Observable = { + fire: fire, + on: on, + once: once, + off: off, + }; +})(); + + +/** + * @namespace fabric.Collection + */ +fabric.Collection = { + + _objects: [], + + /** + * Adds objects to collection, Canvas or Group, then renders canvas + * (if `renderOnAddRemove` is not `false`). + * in case of Group no changes to bounding box are made. + * Objects should be instances of (or inherit from) fabric.Object + * Use of this function is highly discouraged for groups. + * you can add a bunch of objects with the add method but then you NEED + * to run a addWithUpdate call for the Group class or position/bbox will be wrong. + * @param {...fabric.Object} object Zero or more fabric instances + * @return {Self} thisArg + * @chainable + */ + add: function () { + this._objects.push.apply(this._objects, arguments); + if (this._onObjectAdded) { + for (var i = 0, length = arguments.length; i < length; i++) { + this._onObjectAdded(arguments[i]); + } + } + this.renderOnAddRemove && this.requestRenderAll(); + return this; + }, + + /** + * Inserts an object into collection at specified index, then renders canvas (if `renderOnAddRemove` is not `false`) + * An object should be an instance of (or inherit from) fabric.Object + * Use of this function is highly discouraged for groups. + * you can add a bunch of objects with the insertAt method but then you NEED + * to run a addWithUpdate call for the Group class or position/bbox will be wrong. + * @param {Object} object Object to insert + * @param {Number} index Index to insert object at + * @param {Boolean} nonSplicing When `true`, no splicing (shifting) of objects occurs + * @return {Self} thisArg + * @chainable + */ + insertAt: function (object, index, nonSplicing) { + var objects = this._objects; + if (nonSplicing) { + objects[index] = object; + } + else { + objects.splice(index, 0, object); + } + this._onObjectAdded && this._onObjectAdded(object); + this.renderOnAddRemove && this.requestRenderAll(); + return this; + }, + + /** + * Removes objects from a collection, then renders canvas (if `renderOnAddRemove` is not `false`) + * @param {...fabric.Object} object Zero or more fabric instances + * @return {Self} thisArg + * @chainable + */ + remove: function() { + var objects = this._objects, + index, somethingRemoved = false; + + for (var i = 0, length = arguments.length; i < length; i++) { + index = objects.indexOf(arguments[i]); + + // only call onObjectRemoved if an object was actually removed + if (index !== -1) { + somethingRemoved = true; + objects.splice(index, 1); + this._onObjectRemoved && this._onObjectRemoved(arguments[i]); + } + } + + this.renderOnAddRemove && somethingRemoved && this.requestRenderAll(); + return this; + }, + + /** + * Executes given function for each object in this group + * @param {Function} callback + * Callback invoked with current object as first argument, + * index - as second and an array of all objects - as third. + * Callback is invoked in a context of Global Object (e.g. `window`) + * when no `context` argument is given + * + * @param {Object} context Context (aka thisObject) + * @return {Self} thisArg + * @chainable + */ + forEachObject: function(callback, context) { + var objects = this.getObjects(); + for (var i = 0, len = objects.length; i < len; i++) { + callback.call(context, objects[i], i, objects); + } + return this; + }, + + /** + * Returns an array of children objects of this instance + * Type parameter introduced in 1.3.10 + * since 2.3.5 this method return always a COPY of the array; + * @param {String} [type] When specified, only objects of this type are returned + * @return {Array} + */ + getObjects: function(type) { + if (typeof type === 'undefined') { + return this._objects.concat(); + } + return this._objects.filter(function(o) { + return o.type === type; + }); + }, + + /** + * Returns object at specified index + * @param {Number} index + * @return {Self} thisArg + */ + item: function (index) { + return this._objects[index]; + }, + + /** + * Returns true if collection contains no objects + * @return {Boolean} true if collection is empty + */ + isEmpty: function () { + return this._objects.length === 0; + }, + + /** + * Returns a size of a collection (i.e: length of an array containing its objects) + * @return {Number} Collection size + */ + size: function() { + return this._objects.length; + }, + + /** + * Returns true if collection contains an object + * @param {Object} object Object to check against + * @param {Boolean} [deep=false] `true` to check all descendants, `false` to check only `_objects` + * @return {Boolean} `true` if collection contains an object + */ + contains: function (object, deep) { + if (this._objects.indexOf(object) > -1) { + return true; + } + else if (deep) { + return this._objects.some(function (obj) { + return typeof obj.contains === 'function' && obj.contains(object, true); + }); + } + return false; + }, + + /** + * Returns number representation of a collection complexity + * @return {Number} complexity + */ + complexity: function () { + return this._objects.reduce(function (memo, current) { + memo += current.complexity ? current.complexity() : 0; + return memo; + }, 0); + } +}; + + +/** + * @namespace fabric.CommonMethods + */ +fabric.CommonMethods = { + + /** + * Sets object's properties from options + * @param {Object} [options] Options object + */ + _setOptions: function(options) { + for (var prop in options) { + this.set(prop, options[prop]); + } + }, + + /** + * @private + * @param {Object} [filler] Options object + * @param {String} [property] property to set the Gradient to + */ + _initGradient: function(filler, property) { + if (filler && filler.colorStops && !(filler instanceof fabric.Gradient)) { + this.set(property, new fabric.Gradient(filler)); + } + }, + + /** + * @private + * @param {Object} [filler] Options object + * @param {String} [property] property to set the Pattern to + * @param {Function} [callback] callback to invoke after pattern load + */ + _initPattern: function(filler, property, callback) { + if (filler && filler.source && !(filler instanceof fabric.Pattern)) { + this.set(property, new fabric.Pattern(filler, callback)); + } + else { + callback && callback(); + } + }, + + /** + * @private + */ + _setObject: function(obj) { + for (var prop in obj) { + this._set(prop, obj[prop]); + } + }, + + /** + * Sets property to a given value. When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. If you need to update those, call `setCoords()`. + * @param {String|Object} key Property name or object (if object, iterate over the object properties) + * @param {Object|Function} value Property value (if function, the value is passed into it and its return value is used as a new one) + * @return {fabric.Object} thisArg + * @chainable + */ + set: function(key, value) { + if (typeof key === 'object') { + this._setObject(key); + } + else { + this._set(key, value); + } + return this; + }, + + _set: function(key, value) { + this[key] = value; + }, + + /** + * Toggles specified property from `true` to `false` or from `false` to `true` + * @param {String} property Property to toggle + * @return {fabric.Object} thisArg + * @chainable + */ + toggle: function(property) { + var value = this.get(property); + if (typeof value === 'boolean') { + this.set(property, !value); + } + return this; + }, + + /** + * Basic getter + * @param {String} property Property name + * @return {*} value of a property + */ + get: function(property) { + return this[property]; + } +}; + + +(function(global) { + + var sqrt = Math.sqrt, + atan2 = Math.atan2, + pow = Math.pow, + PiBy180 = Math.PI / 180, + PiBy2 = Math.PI / 2; + + /** + * @namespace fabric.util + */ + fabric.util = { + + /** + * Calculate the cos of an angle, avoiding returning floats for known results + * @static + * @memberOf fabric.util + * @param {Number} angle the angle in radians or in degree + * @return {Number} + */ + cos: function(angle) { + if (angle === 0) { return 1; } + if (angle < 0) { + // cos(a) = cos(-a) + angle = -angle; + } + var angleSlice = angle / PiBy2; + switch (angleSlice) { + case 1: case 3: return 0; + case 2: return -1; + } + return Math.cos(angle); + }, + + /** + * Calculate the sin of an angle, avoiding returning floats for known results + * @static + * @memberOf fabric.util + * @param {Number} angle the angle in radians or in degree + * @return {Number} + */ + sin: function(angle) { + if (angle === 0) { return 0; } + var angleSlice = angle / PiBy2, sign = 1; + if (angle < 0) { + // sin(-a) = -sin(a) + sign = -1; + } + switch (angleSlice) { + case 1: return sign; + case 2: return 0; + case 3: return -sign; + } + return Math.sin(angle); + }, + + /** + * Removes value from an array. + * Presence of value (and its position in an array) is determined via `Array.prototype.indexOf` + * @static + * @memberOf fabric.util + * @param {Array} array + * @param {*} value + * @return {Array} original array + */ + removeFromArray: function(array, value) { + var idx = array.indexOf(value); + if (idx !== -1) { + array.splice(idx, 1); + } + return array; + }, + + /** + * Returns random number between 2 specified ones. + * @static + * @memberOf fabric.util + * @param {Number} min lower limit + * @param {Number} max upper limit + * @return {Number} random value (between min and max) + */ + getRandomInt: function(min, max) { + return Math.floor(Math.random() * (max - min + 1)) + min; + }, + + /** + * Transforms degrees to radians. + * @static + * @memberOf fabric.util + * @param {Number} degrees value in degrees + * @return {Number} value in radians + */ + degreesToRadians: function(degrees) { + return degrees * PiBy180; + }, + + /** + * Transforms radians to degrees. + * @static + * @memberOf fabric.util + * @param {Number} radians value in radians + * @return {Number} value in degrees + */ + radiansToDegrees: function(radians) { + return radians / PiBy180; + }, + + /** + * Rotates `point` around `origin` with `radians` + * @static + * @memberOf fabric.util + * @param {fabric.Point} point The point to rotate + * @param {fabric.Point} origin The origin of the rotation + * @param {Number} radians The radians of the angle for the rotation + * @return {fabric.Point} The new rotated point + */ + rotatePoint: function(point, origin, radians) { + var newPoint = new fabric.Point(point.x - origin.x, point.y - origin.y), + v = fabric.util.rotateVector(newPoint, radians); + return new fabric.Point(v.x, v.y).addEquals(origin); + }, + + /** + * Rotates `vector` with `radians` + * @static + * @memberOf fabric.util + * @param {Object} vector The vector to rotate (x and y) + * @param {Number} radians The radians of the angle for the rotation + * @return {Object} The new rotated point + */ + rotateVector: function(vector, radians) { + var sin = fabric.util.sin(radians), + cos = fabric.util.cos(radians), + rx = vector.x * cos - vector.y * sin, + ry = vector.x * sin + vector.y * cos; + return { + x: rx, + y: ry + }; + }, + + /** + * Creates a vetor from points represented as a point + * @static + * @memberOf fabric.util + * + * @typedef {Object} Point + * @property {number} x + * @property {number} y + * + * @param {Point} from + * @param {Point} to + * @returns {Point} vector + */ + createVector: function (from, to) { + return new fabric.Point(to.x - from.x, to.y - from.y); + }, + + /** + * Calculates angle between 2 vectors using dot product + * @static + * @memberOf fabric.util + * @param {Point} a + * @param {Point} b + * @returns the angle in radian between the vectors + */ + calcAngleBetweenVectors: function (a, b) { + return Math.acos((a.x * b.x + a.y * b.y) / (Math.hypot(a.x, a.y) * Math.hypot(b.x, b.y))); + }, + + /** + * @static + * @memberOf fabric.util + * @param {Point} v + * @returns {Point} vector representing the unit vector of pointing to the direction of `v` + */ + getHatVector: function (v) { + return new fabric.Point(v.x, v.y).multiply(1 / Math.hypot(v.x, v.y)); + }, + + /** + * @static + * @memberOf fabric.util + * @param {Point} A + * @param {Point} B + * @param {Point} C + * @returns {{ vector: Point, angle: number }} vector representing the bisector of A and A's angle + */ + getBisector: function (A, B, C) { + var AB = fabric.util.createVector(A, B), AC = fabric.util.createVector(A, C); + var alpha = fabric.util.calcAngleBetweenVectors(AB, AC); + // check if alpha is relative to AB->BC + var ro = fabric.util.calcAngleBetweenVectors(fabric.util.rotateVector(AB, alpha), AC); + var phi = alpha * (ro === 0 ? 1 : -1) / 2; + return { + vector: fabric.util.getHatVector(fabric.util.rotateVector(AB, phi)), + angle: alpha + }; + }, + + /** + * Project stroke width on points returning 2 projections for each point as follows: + * - `miter`: 2 points corresponding to the outer boundary and the inner boundary of stroke. + * - `bevel`: 2 points corresponding to the bevel boundaries, tangent to the bisector. + * - `round`: same as `bevel` + * Used to calculate object's bounding box + * @static + * @memberOf fabric.util + * @param {Point[]} points + * @param {Object} options + * @param {number} options.strokeWidth + * @param {'miter'|'bevel'|'round'} options.strokeLineJoin + * @param {number} options.strokeMiterLimit https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-miterlimit + * @param {boolean} options.strokeUniform + * @param {number} options.scaleX + * @param {number} options.scaleY + * @param {boolean} [openPath] whether the shape is open or not, affects the calculations of the first and last points + * @returns {fabric.Point[]} array of size 2n/4n of all suspected points + */ + projectStrokeOnPoints: function (points, options, openPath) { + var coords = [], s = options.strokeWidth / 2, + strokeUniformScalar = options.strokeUniform ? + new fabric.Point(1 / options.scaleX, 1 / options.scaleY) : new fabric.Point(1, 1), + getStrokeHatVector = function (v) { + var scalar = s / (Math.hypot(v.x, v.y)); + return new fabric.Point(v.x * scalar * strokeUniformScalar.x, v.y * scalar * strokeUniformScalar.y); + }; + if (points.length <= 1) {return coords;} + points.forEach(function (p, index) { + var A = new fabric.Point(p.x, p.y), B, C; + if (index === 0) { + C = points[index + 1]; + B = openPath ? getStrokeHatVector(fabric.util.createVector(C, A)).addEquals(A) : points[points.length - 1]; + } + else if (index === points.length - 1) { + B = points[index - 1]; + C = openPath ? getStrokeHatVector(fabric.util.createVector(B, A)).addEquals(A) : points[0]; + } + else { + B = points[index - 1]; + C = points[index + 1]; + } + var bisector = fabric.util.getBisector(A, B, C), + bisectorVector = bisector.vector, + alpha = bisector.angle, + scalar, + miterVector; + if (options.strokeLineJoin === 'miter') { + scalar = -s / Math.sin(alpha / 2); + miterVector = new fabric.Point( + bisectorVector.x * scalar * strokeUniformScalar.x, + bisectorVector.y * scalar * strokeUniformScalar.y + ); + if (Math.hypot(miterVector.x, miterVector.y) / s <= options.strokeMiterLimit) { + coords.push(A.add(miterVector)); + coords.push(A.subtract(miterVector)); + return; + } + } + scalar = -s * Math.SQRT2; + miterVector = new fabric.Point( + bisectorVector.x * scalar * strokeUniformScalar.x, + bisectorVector.y * scalar * strokeUniformScalar.y + ); + coords.push(A.add(miterVector)); + coords.push(A.subtract(miterVector)); + }); + return coords; + }, + + /** + * Apply transform t to point p + * @static + * @memberOf fabric.util + * @param {fabric.Point} p The point to transform + * @param {Array} t The transform + * @param {Boolean} [ignoreOffset] Indicates that the offset should not be applied + * @return {fabric.Point} The transformed point + */ + transformPoint: function(p, t, ignoreOffset) { + if (ignoreOffset) { + return new fabric.Point( + t[0] * p.x + t[2] * p.y, + t[1] * p.x + t[3] * p.y + ); + } + return new fabric.Point( + t[0] * p.x + t[2] * p.y + t[4], + t[1] * p.x + t[3] * p.y + t[5] + ); + }, + + /** + * Returns coordinates of points's bounding rectangle (left, top, width, height) + * @param {Array} points 4 points array + * @param {Array} [transform] an array of 6 numbers representing a 2x3 transform matrix + * @return {Object} Object with left, top, width, height properties + */ + makeBoundingBoxFromPoints: function(points, transform) { + if (transform) { + for (var i = 0; i < points.length; i++) { + points[i] = fabric.util.transformPoint(points[i], transform); + } + } + var xPoints = [points[0].x, points[1].x, points[2].x, points[3].x], + minX = fabric.util.array.min(xPoints), + maxX = fabric.util.array.max(xPoints), + width = maxX - minX, + yPoints = [points[0].y, points[1].y, points[2].y, points[3].y], + minY = fabric.util.array.min(yPoints), + maxY = fabric.util.array.max(yPoints), + height = maxY - minY; + + return { + left: minX, + top: minY, + width: width, + height: height + }; + }, + + /** + * Invert transformation t + * @static + * @memberOf fabric.util + * @param {Array} t The transform + * @return {Array} The inverted transform + */ + invertTransform: function(t) { + var a = 1 / (t[0] * t[3] - t[1] * t[2]), + r = [a * t[3], -a * t[1], -a * t[2], a * t[0]], + o = fabric.util.transformPoint({ x: t[4], y: t[5] }, r, true); + r[4] = -o.x; + r[5] = -o.y; + return r; + }, + + /** + * A wrapper around Number#toFixed, which contrary to native method returns number, not string. + * @static + * @memberOf fabric.util + * @param {Number|String} number number to operate on + * @param {Number} fractionDigits number of fraction digits to "leave" + * @return {Number} + */ + toFixed: function(number, fractionDigits) { + return parseFloat(Number(number).toFixed(fractionDigits)); + }, + + /** + * Converts from attribute value to pixel value if applicable. + * Returns converted pixels or original value not converted. + * @param {Number|String} value number to operate on + * @param {Number} fontSize + * @return {Number|String} + */ + parseUnit: function(value, fontSize) { + var unit = /\D{0,2}$/.exec(value), + number = parseFloat(value); + if (!fontSize) { + fontSize = fabric.Text.DEFAULT_SVG_FONT_SIZE; + } + switch (unit[0]) { + case 'mm': + return number * fabric.DPI / 25.4; + + case 'cm': + return number * fabric.DPI / 2.54; + + case 'in': + return number * fabric.DPI; + + case 'pt': + return number * fabric.DPI / 72; // or * 4 / 3 + + case 'pc': + return number * fabric.DPI / 72 * 12; // or * 16 + + case 'em': + return number * fontSize; + + default: + return number; + } + }, + + /** + * Function which always returns `false`. + * @static + * @memberOf fabric.util + * @return {Boolean} + */ + falseFunction: function() { + return false; + }, + + /** + * Returns klass "Class" object of given namespace + * @memberOf fabric.util + * @param {String} type Type of object (eg. 'circle') + * @param {String} namespace Namespace to get klass "Class" object from + * @return {Object} klass "Class" + */ + getKlass: function(type, namespace) { + // capitalize first letter only + type = fabric.util.string.camelize(type.charAt(0).toUpperCase() + type.slice(1)); + return fabric.util.resolveNamespace(namespace)[type]; + }, + + /** + * Returns array of attributes for given svg that fabric parses + * @memberOf fabric.util + * @param {String} type Type of svg element (eg. 'circle') + * @return {Array} string names of supported attributes + */ + getSvgAttributes: function(type) { + var attributes = [ + 'instantiated_by_use', + 'style', + 'id', + 'class' + ]; + switch (type) { + case 'linearGradient': + attributes = attributes.concat(['x1', 'y1', 'x2', 'y2', 'gradientUnits', 'gradientTransform']); + break; + case 'radialGradient': + attributes = attributes.concat(['gradientUnits', 'gradientTransform', 'cx', 'cy', 'r', 'fx', 'fy', 'fr']); + break; + case 'stop': + attributes = attributes.concat(['offset', 'stop-color', 'stop-opacity']); + break; + } + return attributes; + }, + + /** + * Returns object of given namespace + * @memberOf fabric.util + * @param {String} namespace Namespace string e.g. 'fabric.Image.filter' or 'fabric' + * @return {Object} Object for given namespace (default fabric) + */ + resolveNamespace: function(namespace) { + if (!namespace) { + return fabric; + } + + var parts = namespace.split('.'), + len = parts.length, i, + obj = global || fabric.window; + + for (i = 0; i < len; ++i) { + obj = obj[parts[i]]; + } + + return obj; + }, + + /** + * Loads image element from given url and passes it to a callback + * @memberOf fabric.util + * @param {String} url URL representing an image + * @param {Function} callback Callback; invoked with loaded image + * @param {*} [context] Context to invoke callback in + * @param {Object} [crossOrigin] crossOrigin value to set image element to + */ + loadImage: function(url, callback, context, crossOrigin) { + if (!url) { + callback && callback.call(context, url); + return; + } + + var img = fabric.util.createImage(); + + /** @ignore */ + var onLoadCallback = function () { + callback && callback.call(context, img, false); + img = img.onload = img.onerror = null; + }; + + img.onload = onLoadCallback; + /** @ignore */ + img.onerror = function() { + fabric.log('Error loading ' + img.src); + callback && callback.call(context, null, true); + img = img.onload = img.onerror = null; + }; + + // data-urls appear to be buggy with crossOrigin + // https://github.com/kangax/fabric.js/commit/d0abb90f1cd5c5ef9d2a94d3fb21a22330da3e0a#commitcomment-4513767 + // see https://code.google.com/p/chromium/issues/detail?id=315152 + // https://bugzilla.mozilla.org/show_bug.cgi?id=935069 + // crossOrigin null is the same as not set. + if (url.indexOf('data') !== 0 && + crossOrigin !== undefined && + crossOrigin !== null) { + img.crossOrigin = crossOrigin; + } + + // IE10 / IE11-Fix: SVG contents from data: URI + // will only be available if the IMG is present + // in the DOM (and visible) + if (url.substring(0,14) === 'data:image/svg') { + img.onload = null; + fabric.util.loadImageInDom(img, onLoadCallback); + } + + img.src = url; + }, + + /** + * Attaches SVG image with data: URL to the dom + * @memberOf fabric.util + * @param {Object} img Image object with data:image/svg src + * @param {Function} callback Callback; invoked with loaded image + * @return {Object} DOM element (div containing the SVG image) + */ + loadImageInDom: function(img, onLoadCallback) { + var div = fabric.document.createElement('div'); + div.style.width = div.style.height = '1px'; + div.style.left = div.style.top = '-100%'; + div.style.position = 'absolute'; + div.appendChild(img); + fabric.document.querySelector('body').appendChild(div); + /** + * Wrap in function to: + * 1. Call existing callback + * 2. Cleanup DOM + */ + img.onload = function () { + onLoadCallback(); + div.parentNode.removeChild(div); + div = null; + }; + }, + + /** + * Creates corresponding fabric instances from their object representations + * @static + * @memberOf fabric.util + * @param {Array} objects Objects to enliven + * @param {Function} callback Callback to invoke when all objects are created + * @param {String} namespace Namespace to get klass "Class" object from + * @param {Function} reviver Method for further parsing of object elements, + * called after each fabric object created. + */ + enlivenObjects: function(objects, callback, namespace, reviver) { + objects = objects || []; + + var enlivenedObjects = [], + numLoadedObjects = 0, + numTotalObjects = objects.length; + + function onLoaded() { + if (++numLoadedObjects === numTotalObjects) { + callback && callback(enlivenedObjects.filter(function(obj) { + // filter out undefined objects (objects that gave error) + return obj; + })); + } + } + + if (!numTotalObjects) { + callback && callback(enlivenedObjects); + return; + } + + objects.forEach(function (o, index) { + // if sparse array + if (!o || !o.type) { + onLoaded(); + return; + } + var klass = fabric.util.getKlass(o.type, namespace); + klass.fromObject(o, function (obj, error) { + error || (enlivenedObjects[index] = obj); + reviver && reviver(o, obj, error); + onLoaded(); + }); + }); + }, + + /** + * Creates corresponding fabric instances residing in an object, e.g. `clipPath` + * @see {@link fabric.Object.ENLIVEN_PROPS} + * @param {Object} object + * @param {Object} [context] assign enlived props to this object (pass null to skip this) + * @param {(objects:fabric.Object[]) => void} callback + */ + enlivenObjectEnlivables: function (object, context, callback) { + var enlivenProps = fabric.Object.ENLIVEN_PROPS.filter(function (key) { return !!object[key]; }); + fabric.util.enlivenObjects(enlivenProps.map(function (key) { return object[key]; }), function (enlivedProps) { + var objects = {}; + enlivenProps.forEach(function (key, index) { + objects[key] = enlivedProps[index]; + context && (context[key] = enlivedProps[index]); + }); + callback && callback(objects); + }); + }, + + /** + * Create and wait for loading of patterns + * @static + * @memberOf fabric.util + * @param {Array} patterns Objects to enliven + * @param {Function} callback Callback to invoke when all objects are created + * called after each fabric object created. + */ + enlivenPatterns: function(patterns, callback) { + patterns = patterns || []; + + function onLoaded() { + if (++numLoadedPatterns === numPatterns) { + callback && callback(enlivenedPatterns); + } + } + + var enlivenedPatterns = [], + numLoadedPatterns = 0, + numPatterns = patterns.length; + + if (!numPatterns) { + callback && callback(enlivenedPatterns); + return; + } + + patterns.forEach(function (p, index) { + if (p && p.source) { + new fabric.Pattern(p, function(pattern) { + enlivenedPatterns[index] = pattern; + onLoaded(); + }); + } + else { + enlivenedPatterns[index] = p; + onLoaded(); + } + }); + }, + + /** + * Groups SVG elements (usually those retrieved from SVG document) + * @static + * @memberOf fabric.util + * @param {Array} elements SVG elements to group + * @param {Object} [options] Options object + * @param {String} path Value to set sourcePath to + * @return {fabric.Object|fabric.Group} + */ + groupSVGElements: function(elements, options, path) { + var object; + if (elements && elements.length === 1) { + if (typeof path !== 'undefined') { + elements[0].sourcePath = path; + } + return elements[0]; + } + if (options) { + if (options.width && options.height) { + options.centerPoint = { + x: options.width / 2, + y: options.height / 2 + }; + } + else { + delete options.width; + delete options.height; + } + } + object = new fabric.Group(elements, options); + if (typeof path !== 'undefined') { + object.sourcePath = path; + } + return object; + }, + + /** + * Populates an object with properties of another object + * @static + * @memberOf fabric.util + * @param {Object} source Source object + * @param {Object} destination Destination object + * @return {Array} properties Properties names to include + */ + populateWithProperties: function(source, destination, properties) { + if (properties && Array.isArray(properties)) { + for (var i = 0, len = properties.length; i < len; i++) { + if (properties[i] in source) { + destination[properties[i]] = source[properties[i]]; + } + } + } + }, + + /** + * Creates canvas element + * @static + * @memberOf fabric.util + * @return {CanvasElement} initialized canvas element + */ + createCanvasElement: function() { + return fabric.document.createElement('canvas'); + }, + + /** + * Creates a canvas element that is a copy of another and is also painted + * @param {CanvasElement} canvas to copy size and content of + * @static + * @memberOf fabric.util + * @return {CanvasElement} initialized canvas element + */ + copyCanvasElement: function(canvas) { + var newCanvas = fabric.util.createCanvasElement(); + newCanvas.width = canvas.width; + newCanvas.height = canvas.height; + newCanvas.getContext('2d').drawImage(canvas, 0, 0); + return newCanvas; + }, + + /** + * since 2.6.0 moved from canvas instance to utility. + * @param {CanvasElement} canvasEl to copy size and content of + * @param {String} format 'jpeg' or 'png', in some browsers 'webp' is ok too + * @param {Number} quality <= 1 and > 0 + * @static + * @memberOf fabric.util + * @return {String} data url + */ + toDataURL: function(canvasEl, format, quality) { + return canvasEl.toDataURL('image/' + format, quality); + }, + + /** + * Creates image element (works on client and node) + * @static + * @memberOf fabric.util + * @return {HTMLImageElement} HTML image element + */ + createImage: function() { + return fabric.document.createElement('img'); + }, + + /** + * Multiply matrix A by matrix B to nest transformations + * @static + * @memberOf fabric.util + * @param {Array} a First transformMatrix + * @param {Array} b Second transformMatrix + * @param {Boolean} is2x2 flag to multiply matrices as 2x2 matrices + * @return {Array} The product of the two transform matrices + */ + multiplyTransformMatrices: function(a, b, is2x2) { + // Matrix multiply a * b + return [ + a[0] * b[0] + a[2] * b[1], + a[1] * b[0] + a[3] * b[1], + a[0] * b[2] + a[2] * b[3], + a[1] * b[2] + a[3] * b[3], + is2x2 ? 0 : a[0] * b[4] + a[2] * b[5] + a[4], + is2x2 ? 0 : a[1] * b[4] + a[3] * b[5] + a[5] + ]; + }, + + /** + * Decomposes standard 2x3 matrix into transform components + * @static + * @memberOf fabric.util + * @param {Array} a transformMatrix + * @return {Object} Components of transform + */ + qrDecompose: function(a) { + var angle = atan2(a[1], a[0]), + denom = pow(a[0], 2) + pow(a[1], 2), + scaleX = sqrt(denom), + scaleY = (a[0] * a[3] - a[2] * a[1]) / scaleX, + skewX = atan2(a[0] * a[2] + a[1] * a [3], denom); + return { + angle: angle / PiBy180, + scaleX: scaleX, + scaleY: scaleY, + skewX: skewX / PiBy180, + skewY: 0, + translateX: a[4], + translateY: a[5] + }; + }, + + /** + * Returns a transform matrix starting from an object of the same kind of + * the one returned from qrDecompose, useful also if you want to calculate some + * transformations from an object that is not enlived yet + * @static + * @memberOf fabric.util + * @param {Object} options + * @param {Number} [options.angle] angle in degrees + * @return {Number[]} transform matrix + */ + calcRotateMatrix: function(options) { + if (!options.angle) { + return fabric.iMatrix.concat(); + } + var theta = fabric.util.degreesToRadians(options.angle), + cos = fabric.util.cos(theta), + sin = fabric.util.sin(theta); + return [cos, sin, -sin, cos, 0, 0]; + }, + + /** + * Returns a transform matrix starting from an object of the same kind of + * the one returned from qrDecompose, useful also if you want to calculate some + * transformations from an object that is not enlived yet. + * is called DimensionsTransformMatrix because those properties are the one that influence + * the size of the resulting box of the object. + * @static + * @memberOf fabric.util + * @param {Object} options + * @param {Number} [options.scaleX] + * @param {Number} [options.scaleY] + * @param {Boolean} [options.flipX] + * @param {Boolean} [options.flipY] + * @param {Number} [options.skewX] + * @param {Number} [options.skewY] + * @return {Number[]} transform matrix + */ + calcDimensionsMatrix: function(options) { + var scaleX = typeof options.scaleX === 'undefined' ? 1 : options.scaleX, + scaleY = typeof options.scaleY === 'undefined' ? 1 : options.scaleY, + scaleMatrix = [ + options.flipX ? -scaleX : scaleX, + 0, + 0, + options.flipY ? -scaleY : scaleY, + 0, + 0], + multiply = fabric.util.multiplyTransformMatrices, + degreesToRadians = fabric.util.degreesToRadians; + if (options.skewX) { + scaleMatrix = multiply( + scaleMatrix, + [1, 0, Math.tan(degreesToRadians(options.skewX)), 1], + true); + } + if (options.skewY) { + scaleMatrix = multiply( + scaleMatrix, + [1, Math.tan(degreesToRadians(options.skewY)), 0, 1], + true); + } + return scaleMatrix; + }, + + /** + * Returns a transform matrix starting from an object of the same kind of + * the one returned from qrDecompose, useful also if you want to calculate some + * transformations from an object that is not enlived yet + * @static + * @memberOf fabric.util + * @param {Object} options + * @param {Number} [options.angle] + * @param {Number} [options.scaleX] + * @param {Number} [options.scaleY] + * @param {Boolean} [options.flipX] + * @param {Boolean} [options.flipY] + * @param {Number} [options.skewX] + * @param {Number} [options.skewX] + * @param {Number} [options.translateX] + * @param {Number} [options.translateY] + * @return {Number[]} transform matrix + */ + composeMatrix: function(options) { + var matrix = [1, 0, 0, 1, options.translateX || 0, options.translateY || 0], + multiply = fabric.util.multiplyTransformMatrices; + if (options.angle) { + matrix = multiply(matrix, fabric.util.calcRotateMatrix(options)); + } + if (options.scaleX !== 1 || options.scaleY !== 1 || + options.skewX || options.skewY || options.flipX || options.flipY) { + matrix = multiply(matrix, fabric.util.calcDimensionsMatrix(options)); + } + return matrix; + }, + + /** + * reset an object transform state to neutral. Top and left are not accounted for + * @static + * @memberOf fabric.util + * @param {fabric.Object} target object to transform + */ + resetObjectTransform: function (target) { + target.scaleX = 1; + target.scaleY = 1; + target.skewX = 0; + target.skewY = 0; + target.flipX = false; + target.flipY = false; + target.rotate(0); + }, + + /** + * Extract Object transform values + * @static + * @memberOf fabric.util + * @param {fabric.Object} target object to read from + * @return {Object} Components of transform + */ + saveObjectTransform: function (target) { + return { + scaleX: target.scaleX, + scaleY: target.scaleY, + skewX: target.skewX, + skewY: target.skewY, + angle: target.angle, + left: target.left, + flipX: target.flipX, + flipY: target.flipY, + top: target.top + }; + }, + + /** + * Returns true if context has transparent pixel + * at specified location (taking tolerance into account) + * @param {CanvasRenderingContext2D} ctx context + * @param {Number} x x coordinate + * @param {Number} y y coordinate + * @param {Number} tolerance Tolerance + */ + isTransparent: function(ctx, x, y, tolerance) { + + // If tolerance is > 0 adjust start coords to take into account. + // If moves off Canvas fix to 0 + if (tolerance > 0) { + if (x > tolerance) { + x -= tolerance; + } + else { + x = 0; + } + if (y > tolerance) { + y -= tolerance; + } + else { + y = 0; + } + } + + var _isTransparent = true, i, temp, + imageData = ctx.getImageData(x, y, (tolerance * 2) || 1, (tolerance * 2) || 1), + l = imageData.data.length; + + // Split image data - for tolerance > 1, pixelDataSize = 4; + for (i = 3; i < l; i += 4) { + temp = imageData.data[i]; + _isTransparent = temp <= 0; + if (_isTransparent === false) { + break; // Stop if colour found + } + } + + imageData = null; + + return _isTransparent; + }, + + /** + * Parse preserveAspectRatio attribute from element + * @param {string} attribute to be parsed + * @return {Object} an object containing align and meetOrSlice attribute + */ + parsePreserveAspectRatioAttribute: function(attribute) { + var meetOrSlice = 'meet', alignX = 'Mid', alignY = 'Mid', + aspectRatioAttrs = attribute.split(' '), align; + + if (aspectRatioAttrs && aspectRatioAttrs.length) { + meetOrSlice = aspectRatioAttrs.pop(); + if (meetOrSlice !== 'meet' && meetOrSlice !== 'slice') { + align = meetOrSlice; + meetOrSlice = 'meet'; + } + else if (aspectRatioAttrs.length) { + align = aspectRatioAttrs.pop(); + } + } + //divide align in alignX and alignY + alignX = align !== 'none' ? align.slice(1, 4) : 'none'; + alignY = align !== 'none' ? align.slice(5, 8) : 'none'; + return { + meetOrSlice: meetOrSlice, + alignX: alignX, + alignY: alignY + }; + }, + + /** + * Clear char widths cache for the given font family or all the cache if no + * fontFamily is specified. + * Use it if you know you are loading fonts in a lazy way and you are not waiting + * for custom fonts to load properly when adding text objects to the canvas. + * If a text object is added when its own font is not loaded yet, you will get wrong + * measurement and so wrong bounding boxes. + * After the font cache is cleared, either change the textObject text content or call + * initDimensions() to trigger a recalculation + * @memberOf fabric.util + * @param {String} [fontFamily] font family to clear + */ + clearFabricFontCache: function(fontFamily) { + fontFamily = (fontFamily || '').toLowerCase(); + if (!fontFamily) { + fabric.charWidthsCache = { }; + } + else if (fabric.charWidthsCache[fontFamily]) { + delete fabric.charWidthsCache[fontFamily]; + } + }, + + /** + * Given current aspect ratio, determines the max width and height that can + * respect the total allowed area for the cache. + * @memberOf fabric.util + * @param {Number} ar aspect ratio + * @param {Number} maximumArea Maximum area you want to achieve + * @return {Object.x} Limited dimensions by X + * @return {Object.y} Limited dimensions by Y + */ + limitDimsByArea: function(ar, maximumArea) { + var roughWidth = Math.sqrt(maximumArea * ar), + perfLimitSizeY = Math.floor(maximumArea / roughWidth); + return { x: Math.floor(roughWidth), y: perfLimitSizeY }; + }, + + capValue: function(min, value, max) { + return Math.max(min, Math.min(value, max)); + }, + + /** + * Finds the scale for the object source to fit inside the object destination, + * keeping aspect ratio intact. + * respect the total allowed area for the cache. + * @memberOf fabric.util + * @param {Object | fabric.Object} source + * @param {Number} source.height natural unscaled height of the object + * @param {Number} source.width natural unscaled width of the object + * @param {Object | fabric.Object} destination + * @param {Number} destination.height natural unscaled height of the object + * @param {Number} destination.width natural unscaled width of the object + * @return {Number} scale factor to apply to source to fit into destination + */ + findScaleToFit: function(source, destination) { + return Math.min(destination.width / source.width, destination.height / source.height); + }, + + /** + * Finds the scale for the object source to cover entirely the object destination, + * keeping aspect ratio intact. + * respect the total allowed area for the cache. + * @memberOf fabric.util + * @param {Object | fabric.Object} source + * @param {Number} source.height natural unscaled height of the object + * @param {Number} source.width natural unscaled width of the object + * @param {Object | fabric.Object} destination + * @param {Number} destination.height natural unscaled height of the object + * @param {Number} destination.width natural unscaled width of the object + * @return {Number} scale factor to apply to source to cover destination + */ + findScaleToCover: function(source, destination) { + return Math.max(destination.width / source.width, destination.height / source.height); + }, + + /** + * given an array of 6 number returns something like `"matrix(...numbers)"` + * @memberOf fabric.util + * @param {Array} transform an array with 6 numbers + * @return {String} transform matrix for svg + * @return {Object.y} Limited dimensions by Y + */ + matrixToSVG: function(transform) { + return 'matrix(' + transform.map(function(value) { + return fabric.util.toFixed(value, fabric.Object.NUM_FRACTION_DIGITS); + }).join(' ') + ')'; + }, + + /** + * given an object and a transform, apply the inverse transform to the object, + * this is equivalent to remove from that object that transformation, so that + * added in a space with the removed transform, the object will be the same as before. + * Removing from an object a transform that scale by 2 is like scaling it by 1/2. + * Removing from an object a transfrom that rotate by 30deg is like rotating by 30deg + * in the opposite direction. + * This util is used to add objects inside transformed groups or nested groups. + * @memberOf fabric.util + * @param {fabric.Object} object the object you want to transform + * @param {Array} transform the destination transform + */ + removeTransformFromObject: function(object, transform) { + var inverted = fabric.util.invertTransform(transform), + finalTransform = fabric.util.multiplyTransformMatrices(inverted, object.calcOwnMatrix()); + fabric.util.applyTransformToObject(object, finalTransform); + }, + + /** + * given an object and a transform, apply the transform to the object. + * this is equivalent to change the space where the object is drawn. + * Adding to an object a transform that scale by 2 is like scaling it by 2. + * This is used when removing an object from an active selection for example. + * @memberOf fabric.util + * @param {fabric.Object} object the object you want to transform + * @param {Array} transform the destination transform + */ + addTransformToObject: function(object, transform) { + fabric.util.applyTransformToObject( + object, + fabric.util.multiplyTransformMatrices(transform, object.calcOwnMatrix()) + ); + }, + + /** + * discard an object transform state and apply the one from the matrix. + * @memberOf fabric.util + * @param {fabric.Object} object the object you want to transform + * @param {Array} transform the destination transform + */ + applyTransformToObject: function(object, transform) { + var options = fabric.util.qrDecompose(transform), + center = new fabric.Point(options.translateX, options.translateY); + object.flipX = false; + object.flipY = false; + object.set('scaleX', options.scaleX); + object.set('scaleY', options.scaleY); + object.skewX = options.skewX; + object.skewY = options.skewY; + object.angle = options.angle; + object.setPositionByOrigin(center, 'center', 'center'); + }, + + /** + * given a width and height, return the size of the bounding box + * that can contains the box with width/height with applied transform + * described in options. + * Use to calculate the boxes around objects for controls. + * @memberOf fabric.util + * @param {Number} width + * @param {Number} height + * @param {Object} options + * @param {Number} options.scaleX + * @param {Number} options.scaleY + * @param {Number} options.skewX + * @param {Number} options.skewY + * @return {Object.x} width of containing + * @return {Object.y} height of containing + */ + sizeAfterTransform: function(width, height, options) { + var dimX = width / 2, dimY = height / 2, + points = [ + { + x: -dimX, + y: -dimY + }, + { + x: dimX, + y: -dimY + }, + { + x: -dimX, + y: dimY + }, + { + x: dimX, + y: dimY + }], + transformMatrix = fabric.util.calcDimensionsMatrix(options), + bbox = fabric.util.makeBoundingBoxFromPoints(points, transformMatrix); + return { + x: bbox.width, + y: bbox.height, + }; + }, + + /** + * Merges 2 clip paths into one visually equal clip path + * + * **IMPORTANT**:\ + * Does **NOT** clone the arguments, clone them proir if necessary. + * + * Creates a wrapper (group) that contains one clip path and is clipped by the other so content is kept where both overlap. + * Use this method if both the clip paths may have nested clip paths of their own, so assigning one to the other's clip path property is not possible. + * + * In order to handle the `inverted` property we follow logic described in the following cases:\ + * **(1)** both clip paths are inverted - the clip paths pass the inverted prop to the wrapper and loose it themselves.\ + * **(2)** one is inverted and the other isn't - the wrapper shouldn't become inverted and the inverted clip path must clip the non inverted one to produce an identical visual effect.\ + * **(3)** both clip paths are not inverted - wrapper and clip paths remain unchanged. + * + * @memberOf fabric.util + * @param {fabric.Object} c1 + * @param {fabric.Object} c2 + * @returns {fabric.Object} merged clip path + */ + mergeClipPaths: function (c1, c2) { + var a = c1, b = c2; + if (a.inverted && !b.inverted) { + // case (2) + a = c2; + b = c1; + } + // `b` becomes `a`'s clip path so we transform `b` to `a` coordinate plane + fabric.util.applyTransformToObject( + b, + fabric.util.multiplyTransformMatrices( + fabric.util.invertTransform(a.calcTransformMatrix()), + b.calcTransformMatrix() + ) + ); + // assign the `inverted` prop to the wrapping group + var inverted = a.inverted && b.inverted; + if (inverted) { + // case (1) + a.inverted = b.inverted = false; + } + return new fabric.Group([a], { clipPath: b, inverted: inverted }); + }, + + /** + * @memberOf fabric.util + * @param {Object} prevStyle first style to compare + * @param {Object} thisStyle second style to compare + * @param {boolean} forTextSpans whether to check overline, underline, and line-through properties + * @return {boolean} true if the style changed + */ + hasStyleChanged: function(prevStyle, thisStyle, forTextSpans) { + forTextSpans = forTextSpans || false; + return (prevStyle.fill !== thisStyle.fill || + prevStyle.stroke !== thisStyle.stroke || + prevStyle.strokeWidth !== thisStyle.strokeWidth || + prevStyle.fontSize !== thisStyle.fontSize || + prevStyle.fontFamily !== thisStyle.fontFamily || + prevStyle.fontWeight !== thisStyle.fontWeight || + prevStyle.fontStyle !== thisStyle.fontStyle || + prevStyle.textBackgroundColor !== thisStyle.textBackgroundColor || + prevStyle.deltaY !== thisStyle.deltaY) || + (forTextSpans && + (prevStyle.overline !== thisStyle.overline || + prevStyle.underline !== thisStyle.underline || + prevStyle.linethrough !== thisStyle.linethrough)); + }, + + /** + * Returns the array form of a text object's inline styles property with styles grouped in ranges + * rather than per character. This format is less verbose, and is better suited for storage + * so it is used in serialization (not during runtime). + * @memberOf fabric.util + * @param {object} styles per character styles for a text object + * @param {String} text the text string that the styles are applied to + * @return {{start: number, end: number, style: object}[]} + */ + stylesToArray: function(styles, text) { + // clone style structure to prevent mutation + var styles = fabric.util.object.clone(styles, true), + textLines = text.split('\n'), + charIndex = -1, prevStyle = {}, stylesArray = []; + //loop through each textLine + for (var i = 0; i < textLines.length; i++) { + if (!styles[i]) { + //no styles exist for this line, so add the line's length to the charIndex total + charIndex += textLines[i].length; + continue; + } + //loop through each character of the current line + for (var c = 0; c < textLines[i].length; c++) { + charIndex++; + var thisStyle = styles[i][c]; + //check if style exists for this character + if (thisStyle && Object.keys(thisStyle).length > 0) { + var styleChanged = fabric.util.hasStyleChanged(prevStyle, thisStyle, true); + if (styleChanged) { + stylesArray.push({ + start: charIndex, + end: charIndex + 1, + style: thisStyle + }); + } + else { + //if style is the same as previous character, increase end index + stylesArray[stylesArray.length - 1].end++; + } + } + prevStyle = thisStyle || {}; + } + } + return stylesArray; + }, + + /** + * Returns the object form of the styles property with styles that are assigned per + * character rather than grouped by range. This format is more verbose, and is + * only used during runtime (not for serialization/storage) + * @memberOf fabric.util + * @param {Array} styles the serialized form of a text object's styles + * @param {String} text the text string that the styles are applied to + * @return {Object} + */ + stylesFromArray: function(styles, text) { + if (!Array.isArray(styles)) { + return styles; + } + var textLines = text.split('\n'), + charIndex = -1, styleIndex = 0, stylesObject = {}; + //loop through each textLine + for (var i = 0; i < textLines.length; i++) { + //loop through each character of the current line + for (var c = 0; c < textLines[i].length; c++) { + charIndex++; + //check if there's a style collection that includes the current character + if (styles[styleIndex] + && styles[styleIndex].start <= charIndex + && charIndex < styles[styleIndex].end) { + //create object for line index if it doesn't exist + stylesObject[i] = stylesObject[i] || {}; + //assign a style at this character's index + stylesObject[i][c] = Object.assign({}, styles[styleIndex].style); + //if character is at the end of the current style collection, move to the next + if (charIndex === styles[styleIndex].end - 1) { + styleIndex++; + } + } + } + } + return stylesObject; + } + }; +})(typeof exports !== 'undefined' ? exports : this); + + +(function() { + var _join = Array.prototype.join, + commandLengths = { + m: 2, + l: 2, + h: 1, + v: 1, + c: 6, + s: 4, + q: 4, + t: 2, + a: 7 + }, + repeatedCommands = { + m: 'l', + M: 'L' + }; + function segmentToBezier(th2, th3, cosTh, sinTh, rx, ry, cx1, cy1, mT, fromX, fromY) { + var costh2 = fabric.util.cos(th2), + sinth2 = fabric.util.sin(th2), + costh3 = fabric.util.cos(th3), + sinth3 = fabric.util.sin(th3), + toX = cosTh * rx * costh3 - sinTh * ry * sinth3 + cx1, + toY = sinTh * rx * costh3 + cosTh * ry * sinth3 + cy1, + cp1X = fromX + mT * ( -cosTh * rx * sinth2 - sinTh * ry * costh2), + cp1Y = fromY + mT * ( -sinTh * rx * sinth2 + cosTh * ry * costh2), + cp2X = toX + mT * ( cosTh * rx * sinth3 + sinTh * ry * costh3), + cp2Y = toY + mT * ( sinTh * rx * sinth3 - cosTh * ry * costh3); + + return ['C', + cp1X, cp1Y, + cp2X, cp2Y, + toX, toY + ]; + } + + /* Adapted from http://dxr.mozilla.org/mozilla-central/source/content/svg/content/src/nsSVGPathDataParser.cpp + * by Andrea Bogazzi code is under MPL. if you don't have a copy of the license you can take it here + * http://mozilla.org/MPL/2.0/ + */ + function arcToSegments(toX, toY, rx, ry, large, sweep, rotateX) { + var PI = Math.PI, th = rotateX * PI / 180, + sinTh = fabric.util.sin(th), + cosTh = fabric.util.cos(th), + fromX = 0, fromY = 0; + + rx = Math.abs(rx); + ry = Math.abs(ry); + + var px = -cosTh * toX * 0.5 - sinTh * toY * 0.5, + py = -cosTh * toY * 0.5 + sinTh * toX * 0.5, + rx2 = rx * rx, ry2 = ry * ry, py2 = py * py, px2 = px * px, + pl = rx2 * ry2 - rx2 * py2 - ry2 * px2, + root = 0; + + if (pl < 0) { + var s = Math.sqrt(1 - pl / (rx2 * ry2)); + rx *= s; + ry *= s; + } + else { + root = (large === sweep ? -1.0 : 1.0) * + Math.sqrt( pl / (rx2 * py2 + ry2 * px2)); + } + + var cx = root * rx * py / ry, + cy = -root * ry * px / rx, + cx1 = cosTh * cx - sinTh * cy + toX * 0.5, + cy1 = sinTh * cx + cosTh * cy + toY * 0.5, + mTheta = calcVectorAngle(1, 0, (px - cx) / rx, (py - cy) / ry), + dtheta = calcVectorAngle((px - cx) / rx, (py - cy) / ry, (-px - cx) / rx, (-py - cy) / ry); + + if (sweep === 0 && dtheta > 0) { + dtheta -= 2 * PI; + } + else if (sweep === 1 && dtheta < 0) { + dtheta += 2 * PI; + } + + // Convert into cubic bezier segments <= 90deg + var segments = Math.ceil(Math.abs(dtheta / PI * 2)), + result = [], mDelta = dtheta / segments, + mT = 8 / 3 * Math.sin(mDelta / 4) * Math.sin(mDelta / 4) / Math.sin(mDelta / 2), + th3 = mTheta + mDelta; + + for (var i = 0; i < segments; i++) { + result[i] = segmentToBezier(mTheta, th3, cosTh, sinTh, rx, ry, cx1, cy1, mT, fromX, fromY); + fromX = result[i][5]; + fromY = result[i][6]; + mTheta = th3; + th3 += mDelta; + } + return result; + } + + /* + * Private + */ + function calcVectorAngle(ux, uy, vx, vy) { + var ta = Math.atan2(uy, ux), + tb = Math.atan2(vy, vx); + if (tb >= ta) { + return tb - ta; + } + else { + return 2 * Math.PI - (ta - tb); + } + } + + /** + * Calculate bounding box of a beziercurve + * @param {Number} x0 starting point + * @param {Number} y0 + * @param {Number} x1 first control point + * @param {Number} y1 + * @param {Number} x2 secondo control point + * @param {Number} y2 + * @param {Number} x3 end of bezier + * @param {Number} y3 + */ + // taken from http://jsbin.com/ivomiq/56/edit no credits available for that. + // TODO: can we normalize this with the starting points set at 0 and then translated the bbox? + function getBoundsOfCurve(x0, y0, x1, y1, x2, y2, x3, y3) { + var argsString; + if (fabric.cachesBoundsOfCurve) { + argsString = _join.call(arguments); + if (fabric.boundsOfCurveCache[argsString]) { + return fabric.boundsOfCurveCache[argsString]; + } + } + + var sqrt = Math.sqrt, + min = Math.min, max = Math.max, + abs = Math.abs, tvalues = [], + bounds = [[], []], + a, b, c, t, t1, t2, b2ac, sqrtb2ac; + + b = 6 * x0 - 12 * x1 + 6 * x2; + a = -3 * x0 + 9 * x1 - 9 * x2 + 3 * x3; + c = 3 * x1 - 3 * x0; + + for (var i = 0; i < 2; ++i) { + if (i > 0) { + b = 6 * y0 - 12 * y1 + 6 * y2; + a = -3 * y0 + 9 * y1 - 9 * y2 + 3 * y3; + c = 3 * y1 - 3 * y0; + } + + if (abs(a) < 1e-12) { + if (abs(b) < 1e-12) { + continue; + } + t = -c / b; + if (0 < t && t < 1) { + tvalues.push(t); + } + continue; + } + b2ac = b * b - 4 * c * a; + if (b2ac < 0) { + continue; + } + sqrtb2ac = sqrt(b2ac); + t1 = (-b + sqrtb2ac) / (2 * a); + if (0 < t1 && t1 < 1) { + tvalues.push(t1); + } + t2 = (-b - sqrtb2ac) / (2 * a); + if (0 < t2 && t2 < 1) { + tvalues.push(t2); + } + } + + var x, y, j = tvalues.length, jlen = j, mt; + while (j--) { + t = tvalues[j]; + mt = 1 - t; + x = (mt * mt * mt * x0) + (3 * mt * mt * t * x1) + (3 * mt * t * t * x2) + (t * t * t * x3); + bounds[0][j] = x; + + y = (mt * mt * mt * y0) + (3 * mt * mt * t * y1) + (3 * mt * t * t * y2) + (t * t * t * y3); + bounds[1][j] = y; + } + + bounds[0][jlen] = x0; + bounds[1][jlen] = y0; + bounds[0][jlen + 1] = x3; + bounds[1][jlen + 1] = y3; + var result = [ + { + x: min.apply(null, bounds[0]), + y: min.apply(null, bounds[1]) + }, + { + x: max.apply(null, bounds[0]), + y: max.apply(null, bounds[1]) + } + ]; + if (fabric.cachesBoundsOfCurve) { + fabric.boundsOfCurveCache[argsString] = result; + } + return result; + } + + /** + * Converts arc to a bunch of bezier curves + * @param {Number} fx starting point x + * @param {Number} fy starting point y + * @param {Array} coords Arc command + */ + function fromArcToBeziers(fx, fy, coords) { + var rx = coords[1], + ry = coords[2], + rot = coords[3], + large = coords[4], + sweep = coords[5], + tx = coords[6], + ty = coords[7], + segsNorm = arcToSegments(tx - fx, ty - fy, rx, ry, large, sweep, rot); + + for (var i = 0, len = segsNorm.length; i < len; i++) { + segsNorm[i][1] += fx; + segsNorm[i][2] += fy; + segsNorm[i][3] += fx; + segsNorm[i][4] += fy; + segsNorm[i][5] += fx; + segsNorm[i][6] += fy; + } + return segsNorm; + }; + + /** + * This function take a parsed SVG path and make it simpler for fabricJS logic. + * simplification consist of: only UPPERCASE absolute commands ( relative converted to absolute ) + * S converted in C, T converted in Q, A converted in C. + * @param {Array} path the array of commands of a parsed svg path for fabric.Path + * @return {Array} the simplified array of commands of a parsed svg path for fabric.Path + */ + function makePathSimpler(path) { + // x and y represent the last point of the path. the previous command point. + // we add them to each relative command to make it an absolute comment. + // we also swap the v V h H with L, because are easier to transform. + var x = 0, y = 0, len = path.length, + // x1 and y1 represent the last point of the subpath. the subpath is started with + // m or M command. When a z or Z command is drawn, x and y need to be resetted to + // the last x1 and y1. + x1 = 0, y1 = 0, current, i, converted, + // previous will host the letter of the previous command, to handle S and T. + // controlX and controlY will host the previous reflected control point + destinationPath = [], previous, controlX, controlY; + for (i = 0; i < len; ++i) { + converted = false; + current = path[i].slice(0); + switch (current[0]) { // first letter + case 'l': // lineto, relative + current[0] = 'L'; + current[1] += x; + current[2] += y; + // falls through + case 'L': + x = current[1]; + y = current[2]; + break; + case 'h': // horizontal lineto, relative + current[1] += x; + // falls through + case 'H': + current[0] = 'L'; + current[2] = y; + x = current[1]; + break; + case 'v': // vertical lineto, relative + current[1] += y; + // falls through + case 'V': + current[0] = 'L'; + y = current[1]; + current[1] = x; + current[2] = y; + break; + case 'm': // moveTo, relative + current[0] = 'M'; + current[1] += x; + current[2] += y; + // falls through + case 'M': + x = current[1]; + y = current[2]; + x1 = current[1]; + y1 = current[2]; + break; + case 'c': // bezierCurveTo, relative + current[0] = 'C'; + current[1] += x; + current[2] += y; + current[3] += x; + current[4] += y; + current[5] += x; + current[6] += y; + // falls through + case 'C': + controlX = current[3]; + controlY = current[4]; + x = current[5]; + y = current[6]; + break; + case 's': // shorthand cubic bezierCurveTo, relative + current[0] = 'S'; + current[1] += x; + current[2] += y; + current[3] += x; + current[4] += y; + // falls through + case 'S': + // would be sScC but since we are swapping sSc for C, we check just that. + if (previous === 'C') { + // calculate reflection of previous control points + controlX = 2 * x - controlX; + controlY = 2 * y - controlY; + } + else { + // If there is no previous command or if the previous command was not a C, c, S, or s, + // the control point is coincident with the current point + controlX = x; + controlY = y; + } + x = current[3]; + y = current[4]; + current[0] = 'C'; + current[5] = current[3]; + current[6] = current[4]; + current[3] = current[1]; + current[4] = current[2]; + current[1] = controlX; + current[2] = controlY; + // current[3] and current[4] are NOW the second control point. + // we keep it for the next reflection. + controlX = current[3]; + controlY = current[4]; + break; + case 'q': // quadraticCurveTo, relative + current[0] = 'Q'; + current[1] += x; + current[2] += y; + current[3] += x; + current[4] += y; + // falls through + case 'Q': + controlX = current[1]; + controlY = current[2]; + x = current[3]; + y = current[4]; + break; + case 't': // shorthand quadraticCurveTo, relative + current[0] = 'T'; + current[1] += x; + current[2] += y; + // falls through + case 'T': + if (previous === 'Q') { + // calculate reflection of previous control point + controlX = 2 * x - controlX; + controlY = 2 * y - controlY; + } + else { + // If there is no previous command or if the previous command was not a Q, q, T or t, + // assume the control point is coincident with the current point + controlX = x; + controlY = y; + } + current[0] = 'Q'; + x = current[1]; + y = current[2]; + current[1] = controlX; + current[2] = controlY; + current[3] = x; + current[4] = y; + break; + case 'a': + current[0] = 'A'; + current[6] += x; + current[7] += y; + // falls through + case 'A': + converted = true; + destinationPath = destinationPath.concat(fromArcToBeziers(x, y, current)); + x = current[6]; + y = current[7]; + break; + case 'z': + case 'Z': + x = x1; + y = y1; + break; + default: + } + if (!converted) { + destinationPath.push(current); + } + previous = current[0]; + } + return destinationPath; + }; + + /** + * Calc length from point x1,y1 to x2,y2 + * @param {Number} x1 starting point x + * @param {Number} y1 starting point y + * @param {Number} x2 starting point x + * @param {Number} y2 starting point y + * @return {Number} length of segment + */ + function calcLineLength(x1, y1, x2, y2) { + return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); + } + + // functions for the Cubic beizer + // taken from: https://github.com/konvajs/konva/blob/7.0.5/src/shapes/Path.ts#L350 + function CB1(t) { + return t * t * t; + } + function CB2(t) { + return 3 * t * t * (1 - t); + } + function CB3(t) { + return 3 * t * (1 - t) * (1 - t); + } + function CB4(t) { + return (1 - t) * (1 - t) * (1 - t); + } + + function getPointOnCubicBezierIterator(p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y) { + return function(pct) { + var c1 = CB1(pct), c2 = CB2(pct), c3 = CB3(pct), c4 = CB4(pct); + return { + x: p4x * c1 + p3x * c2 + p2x * c3 + p1x * c4, + y: p4y * c1 + p3y * c2 + p2y * c3 + p1y * c4 + }; + }; + } + + function getTangentCubicIterator(p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y) { + return function (pct) { + var invT = 1 - pct, + tangentX = (3 * invT * invT * (p2x - p1x)) + (6 * invT * pct * (p3x - p2x)) + + (3 * pct * pct * (p4x - p3x)), + tangentY = (3 * invT * invT * (p2y - p1y)) + (6 * invT * pct * (p3y - p2y)) + + (3 * pct * pct * (p4y - p3y)); + return Math.atan2(tangentY, tangentX); + }; + } + + function QB1(t) { + return t * t; + } + + function QB2(t) { + return 2 * t * (1 - t); + } + + function QB3(t) { + return (1 - t) * (1 - t); + } + + function getPointOnQuadraticBezierIterator(p1x, p1y, p2x, p2y, p3x, p3y) { + return function(pct) { + var c1 = QB1(pct), c2 = QB2(pct), c3 = QB3(pct); + return { + x: p3x * c1 + p2x * c2 + p1x * c3, + y: p3y * c1 + p2y * c2 + p1y * c3 + }; + }; + } + + function getTangentQuadraticIterator(p1x, p1y, p2x, p2y, p3x, p3y) { + return function (pct) { + var invT = 1 - pct, + tangentX = (2 * invT * (p2x - p1x)) + (2 * pct * (p3x - p2x)), + tangentY = (2 * invT * (p2y - p1y)) + (2 * pct * (p3y - p2y)); + return Math.atan2(tangentY, tangentX); + }; + } + + + // this will run over a path segment ( a cubic or quadratic segment) and approximate it + // with 100 segemnts. This will good enough to calculate the length of the curve + function pathIterator(iterator, x1, y1) { + var tempP = { x: x1, y: y1 }, p, tmpLen = 0, perc; + for (perc = 1; perc <= 100; perc += 1) { + p = iterator(perc / 100); + tmpLen += calcLineLength(tempP.x, tempP.y, p.x, p.y); + tempP = p; + } + return tmpLen; + } + + /** + * Given a pathInfo, and a distance in pixels, find the percentage from 0 to 1 + * that correspond to that pixels run over the path. + * The percentage will be then used to find the correct point on the canvas for the path. + * @param {Array} segInfo fabricJS collection of information on a parsed path + * @param {Number} distance from starting point, in pixels. + * @return {Object} info object with x and y ( the point on canvas ) and angle, the tangent on that point; + */ + function findPercentageForDistance(segInfo, distance) { + var perc = 0, tmpLen = 0, iterator = segInfo.iterator, tempP = { x: segInfo.x, y: segInfo.y }, + p, nextLen, nextStep = 0.01, angleFinder = segInfo.angleFinder, lastPerc; + // nextStep > 0.0001 covers 0.00015625 that 1/64th of 1/100 + // the path + while (tmpLen < distance && nextStep > 0.0001) { + p = iterator(perc); + lastPerc = perc; + nextLen = calcLineLength(tempP.x, tempP.y, p.x, p.y); + // compare tmpLen each cycle with distance, decide next perc to test. + if ((nextLen + tmpLen) > distance) { + // we discard this step and we make smaller steps. + perc -= nextStep; + nextStep /= 2; + } + else { + tempP = p; + perc += nextStep; + tmpLen += nextLen; + } + } + p.angle = angleFinder(lastPerc); + return p; + } + + /** + * Run over a parsed and simplifed path and extrac some informations. + * informations are length of each command and starting point + * @param {Array} path fabricJS parsed path commands + * @return {Array} path commands informations + */ + function getPathSegmentsInfo(path) { + var totalLength = 0, len = path.length, current, + //x2 and y2 are the coords of segment start + //x1 and y1 are the coords of the current point + x1 = 0, y1 = 0, x2 = 0, y2 = 0, info = [], iterator, tempInfo, angleFinder; + for (var i = 0; i < len; i++) { + current = path[i]; + tempInfo = { + x: x1, + y: y1, + command: current[0], + }; + switch (current[0]) { //first letter + case 'M': + tempInfo.length = 0; + x2 = x1 = current[1]; + y2 = y1 = current[2]; + break; + case 'L': + tempInfo.length = calcLineLength(x1, y1, current[1], current[2]); + x1 = current[1]; + y1 = current[2]; + break; + case 'C': + iterator = getPointOnCubicBezierIterator( + x1, + y1, + current[1], + current[2], + current[3], + current[4], + current[5], + current[6] + ); + angleFinder = getTangentCubicIterator( + x1, + y1, + current[1], + current[2], + current[3], + current[4], + current[5], + current[6] + ); + tempInfo.iterator = iterator; + tempInfo.angleFinder = angleFinder; + tempInfo.length = pathIterator(iterator, x1, y1); + x1 = current[5]; + y1 = current[6]; + break; + case 'Q': + iterator = getPointOnQuadraticBezierIterator( + x1, + y1, + current[1], + current[2], + current[3], + current[4] + ); + angleFinder = getTangentQuadraticIterator( + x1, + y1, + current[1], + current[2], + current[3], + current[4] + ); + tempInfo.iterator = iterator; + tempInfo.angleFinder = angleFinder; + tempInfo.length = pathIterator(iterator, x1, y1); + x1 = current[3]; + y1 = current[4]; + break; + case 'Z': + case 'z': + // we add those in order to ease calculations later + tempInfo.destX = x2; + tempInfo.destY = y2; + tempInfo.length = calcLineLength(x1, y1, x2, y2); + x1 = x2; + y1 = y2; + break; + } + totalLength += tempInfo.length; + info.push(tempInfo); + } + info.push({ length: totalLength, x: x1, y: y1 }); + return info; + } + + function getPointOnPath(path, distance, infos) { + if (!infos) { + infos = getPathSegmentsInfo(path); + } + var i = 0; + while ((distance - infos[i].length > 0) && i < (infos.length - 2)) { + distance -= infos[i].length; + i++; + } + // var distance = infos[infos.length - 1] * perc; + var segInfo = infos[i], segPercent = distance / segInfo.length, + command = segInfo.command, segment = path[i], info; + + switch (command) { + case 'M': + return { x: segInfo.x, y: segInfo.y, angle: 0 }; + case 'Z': + case 'z': + info = new fabric.Point(segInfo.x, segInfo.y).lerp( + new fabric.Point(segInfo.destX, segInfo.destY), + segPercent + ); + info.angle = Math.atan2(segInfo.destY - segInfo.y, segInfo.destX - segInfo.x); + return info; + case 'L': + info = new fabric.Point(segInfo.x, segInfo.y).lerp( + new fabric.Point(segment[1], segment[2]), + segPercent + ); + info.angle = Math.atan2(segment[2] - segInfo.y, segment[1] - segInfo.x); + return info; + case 'C': + return findPercentageForDistance(segInfo, distance); + case 'Q': + return findPercentageForDistance(segInfo, distance); + } + } + + /** + * + * @param {string} pathString + * @return {(string|number)[][]} An array of SVG path commands + * @example Usage + * parsePath('M 3 4 Q 3 5 2 1 4 0 Q 9 12 2 1 4 0') === [ + * ['M', 3, 4], + * ['Q', 3, 5, 2, 1, 4, 0], + * ['Q', 9, 12, 2, 1, 4, 0], + * ]; + * + */ + function parsePath(pathString) { + var result = [], + coords = [], + currentPath, + parsed, + re = fabric.rePathCommand, + rNumber = '[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?\\s*', + rNumberCommaWsp = '(' + rNumber + ')' + fabric.commaWsp, + rFlagCommaWsp = '([01])' + fabric.commaWsp + '?', + rArcSeq = rNumberCommaWsp + '?' + rNumberCommaWsp + '?' + rNumberCommaWsp + rFlagCommaWsp + rFlagCommaWsp + + rNumberCommaWsp + '?(' + rNumber + ')', + regArcArgumentSequence = new RegExp(rArcSeq, 'g'), + match, + coordsStr, + // one of commands (m,M,l,L,q,Q,c,C,etc.) followed by non-command characters (i.e. command values) + path; + if (!pathString || !pathString.match) { + return result; + } + path = pathString.match(/[mzlhvcsqta][^mzlhvcsqta]*/gi); + + for (var i = 0, coordsParsed, len = path.length; i < len; i++) { + currentPath = path[i]; + + coordsStr = currentPath.slice(1).trim(); + coords.length = 0; + + var command = currentPath.charAt(0); + coordsParsed = [command]; + + if (command.toLowerCase() === 'a') { + // arcs have special flags that apparently don't require spaces so handle special + for (var args; (args = regArcArgumentSequence.exec(coordsStr));) { + for (var j = 1; j < args.length; j++) { + coords.push(args[j]); + } + } + } + else { + while ((match = re.exec(coordsStr))) { + coords.push(match[0]); + } + } + + for (var j = 0, jlen = coords.length; j < jlen; j++) { + parsed = parseFloat(coords[j]); + if (!isNaN(parsed)) { + coordsParsed.push(parsed); + } + } + + var commandLength = commandLengths[command.toLowerCase()], + repeatedCommand = repeatedCommands[command] || command; + + if (coordsParsed.length - 1 > commandLength) { + for (var k = 1, klen = coordsParsed.length; k < klen; k += commandLength) { + result.push([command].concat(coordsParsed.slice(k, k + commandLength))); + command = repeatedCommand; + } + } + else { + result.push(coordsParsed); + } + } + + return result; + }; + + /** + * + * Converts points to a smooth SVG path + * @param {{ x: number,y: number }[]} points Array of points + * @param {number} [correction] Apply a correction to the path (usually we use `width / 1000`). If value is undefined 0 is used as the correction value. + * @return {(string|number)[][]} An array of SVG path commands + */ + function getSmoothPathFromPoints(points, correction) { + var path = [], i, + p1 = new fabric.Point(points[0].x, points[0].y), + p2 = new fabric.Point(points[1].x, points[1].y), + len = points.length, multSignX = 1, multSignY = 0, manyPoints = len > 2; + correction = correction || 0; + + if (manyPoints) { + multSignX = points[2].x < p2.x ? -1 : points[2].x === p2.x ? 0 : 1; + multSignY = points[2].y < p2.y ? -1 : points[2].y === p2.y ? 0 : 1; + } + path.push(['M', p1.x - multSignX * correction, p1.y - multSignY * correction]); + for (i = 1; i < len; i++) { + if (!p1.eq(p2)) { + var midPoint = p1.midPointFrom(p2); + // p1 is our bezier control point + // midpoint is our endpoint + // start point is p(i-1) value. + path.push(['Q', p1.x, p1.y, midPoint.x, midPoint.y]); + } + p1 = points[i]; + if ((i + 1) < points.length) { + p2 = points[i + 1]; + } + } + if (manyPoints) { + multSignX = p1.x > points[i - 2].x ? 1 : p1.x === points[i - 2].x ? 0 : -1; + multSignY = p1.y > points[i - 2].y ? 1 : p1.y === points[i - 2].y ? 0 : -1; + } + path.push(['L', p1.x + multSignX * correction, p1.y + multSignY * correction]); + return path; + } + /** + * Transform a path by transforming each segment. + * it has to be a simplified path or it won't work. + * WARNING: this depends from pathOffset for correct operation + * @param {Array} path fabricJS parsed and simplified path commands + * @param {Array} transform matrix that represent the transformation + * @param {Object} [pathOffset] the fabric.Path pathOffset + * @param {Number} pathOffset.x + * @param {Number} pathOffset.y + * @returns {Array} the transformed path + */ + function transformPath(path, transform, pathOffset) { + if (pathOffset) { + transform = fabric.util.multiplyTransformMatrices( + transform, + [1, 0, 0, 1, -pathOffset.x, -pathOffset.y] + ); + } + return path.map(function(pathSegment) { + var newSegment = pathSegment.slice(0), point = {}; + for (var i = 1; i < pathSegment.length - 1; i += 2) { + point.x = pathSegment[i]; + point.y = pathSegment[i + 1]; + point = fabric.util.transformPoint(point, transform); + newSegment[i] = point.x; + newSegment[i + 1] = point.y; + } + return newSegment; + }); + } + + /** + * Join path commands to go back to svg format + * @param {Array} pathData fabricJS parsed path commands + * @return {String} joined path 'M 0 0 L 20 30' + */ + fabric.util.joinPath = function(pathData) { + return pathData.map(function (segment) { return segment.join(' '); }).join(' '); + }; + fabric.util.parsePath = parsePath; + fabric.util.makePathSimpler = makePathSimpler; + fabric.util.getSmoothPathFromPoints = getSmoothPathFromPoints; + fabric.util.getPathSegmentsInfo = getPathSegmentsInfo; + fabric.util.getBoundsOfCurve = getBoundsOfCurve; + fabric.util.getPointOnPath = getPointOnPath; + fabric.util.transformPath = transformPath; +})(); + + +(function() { + + var slice = Array.prototype.slice; + + /** + * Invokes method on all items in a given array + * @memberOf fabric.util.array + * @param {Array} array Array to iterate over + * @param {String} method Name of a method to invoke + * @return {Array} + */ + function invoke(array, method) { + var args = slice.call(arguments, 2), result = []; + for (var i = 0, len = array.length; i < len; i++) { + result[i] = args.length ? array[i][method].apply(array[i], args) : array[i][method].call(array[i]); + } + return result; + } + + /** + * Finds maximum value in array (not necessarily "first" one) + * @memberOf fabric.util.array + * @param {Array} array Array to iterate over + * @param {String} byProperty + * @return {*} + */ + function max(array, byProperty) { + return find(array, byProperty, function(value1, value2) { + return value1 >= value2; + }); + } + + /** + * Finds minimum value in array (not necessarily "first" one) + * @memberOf fabric.util.array + * @param {Array} array Array to iterate over + * @param {String} byProperty + * @return {*} + */ + function min(array, byProperty) { + return find(array, byProperty, function(value1, value2) { + return value1 < value2; + }); + } + + /** + * @private + */ + function fill(array, value) { + var k = array.length; + while (k--) { + array[k] = value; + } + return array; + } + + /** + * @private + */ + function find(array, byProperty, condition) { + if (!array || array.length === 0) { + return; + } + + var i = array.length - 1, + result = byProperty ? array[i][byProperty] : array[i]; + if (byProperty) { + while (i--) { + if (condition(array[i][byProperty], result)) { + result = array[i][byProperty]; + } + } + } + else { + while (i--) { + if (condition(array[i], result)) { + result = array[i]; + } + } + } + return result; + } + + /** + * @namespace fabric.util.array + */ + fabric.util.array = { + fill: fill, + invoke: invoke, + min: min, + max: max + }; + +})(); + + +(function() { + /** + * Copies all enumerable properties of one js object to another + * this does not and cannot compete with generic utils. + * Does not clone or extend fabric.Object subclasses. + * This is mostly for internal use and has extra handling for fabricJS objects + * it skips the canvas and group properties in deep cloning. + * @memberOf fabric.util.object + * @param {Object} destination Where to copy to + * @param {Object} source Where to copy from + * @param {Boolean} [deep] Whether to extend nested objects + * @return {Object} + */ + + function extend(destination, source, deep) { + // JScript DontEnum bug is not taken care of + // the deep clone is for internal use, is not meant to avoid + // javascript traps or cloning html element or self referenced objects. + if (deep) { + if (!fabric.isLikelyNode && source instanceof Element) { + // avoid cloning deep images, canvases, + destination = source; + } + else if (source instanceof Array) { + destination = []; + for (var i = 0, len = source.length; i < len; i++) { + destination[i] = extend({ }, source[i], deep); + } + } + else if (source && typeof source === 'object') { + for (var property in source) { + if (property === 'canvas' || property === 'group') { + // we do not want to clone this props at all. + // we want to keep the keys in the copy + destination[property] = null; + } + else if (source.hasOwnProperty(property)) { + destination[property] = extend({ }, source[property], deep); + } + } + } + else { + // this sounds odd for an extend but is ok for recursive use + destination = source; + } + } + else { + for (var property in source) { + destination[property] = source[property]; + } + } + return destination; + } + + /** + * Creates an empty object and copies all enumerable properties of another object to it + * This method is mostly for internal use, and not intended for duplicating shapes in canvas. + * @memberOf fabric.util.object + * @param {Object} object Object to clone + * @param {Boolean} [deep] Whether to clone nested objects + * @return {Object} + */ + + //TODO: this function return an empty object if you try to clone null + function clone(object, deep) { + return extend({ }, object, deep); + } + + /** @namespace fabric.util.object */ + fabric.util.object = { + extend: extend, + clone: clone + }; + fabric.util.object.extend(fabric.util, fabric.Observable); +})(); + + +(function() { + + /** + * Camelizes a string + * @memberOf fabric.util.string + * @param {String} string String to camelize + * @return {String} Camelized version of a string + */ + function camelize(string) { + return string.replace(/-+(.)?/g, function(match, character) { + return character ? character.toUpperCase() : ''; + }); + } + + /** + * Capitalizes a string + * @memberOf fabric.util.string + * @param {String} string String to capitalize + * @param {Boolean} [firstLetterOnly] If true only first letter is capitalized + * and other letters stay untouched, if false first letter is capitalized + * and other letters are converted to lowercase. + * @return {String} Capitalized version of a string + */ + function capitalize(string, firstLetterOnly) { + return string.charAt(0).toUpperCase() + + (firstLetterOnly ? string.slice(1) : string.slice(1).toLowerCase()); + } + + /** + * Escapes XML in a string + * @memberOf fabric.util.string + * @param {String} string String to escape + * @return {String} Escaped version of a string + */ + function escapeXml(string) { + return string.replace(/&/g, '&') + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(//g, '>'); + } + + /** + * Divide a string in the user perceived single units + * @memberOf fabric.util.string + * @param {String} textstring String to escape + * @return {Array} array containing the graphemes + */ + function graphemeSplit(textstring) { + var i = 0, chr, graphemes = []; + for (i = 0, chr; i < textstring.length; i++) { + if ((chr = getWholeChar(textstring, i)) === false) { + continue; + } + graphemes.push(chr); + } + return graphemes; + } + + // taken from mdn in the charAt doc page. + function getWholeChar(str, i) { + var code = str.charCodeAt(i); + + if (isNaN(code)) { + return ''; // Position not found + } + if (code < 0xD800 || code > 0xDFFF) { + return str.charAt(i); + } + + // High surrogate (could change last hex to 0xDB7F to treat high private + // surrogates as single characters) + if (0xD800 <= code && code <= 0xDBFF) { + if (str.length <= (i + 1)) { + throw 'High surrogate without following low surrogate'; + } + var next = str.charCodeAt(i + 1); + if (0xDC00 > next || next > 0xDFFF) { + throw 'High surrogate without following low surrogate'; + } + return str.charAt(i) + str.charAt(i + 1); + } + // Low surrogate (0xDC00 <= code && code <= 0xDFFF) + if (i === 0) { + throw 'Low surrogate without preceding high surrogate'; + } + var prev = str.charCodeAt(i - 1); + + // (could change last hex to 0xDB7F to treat high private + // surrogates as single characters) + if (0xD800 > prev || prev > 0xDBFF) { + throw 'Low surrogate without preceding high surrogate'; + } + // We can pass over low surrogates now as the second component + // in a pair which we have already processed + return false; + } + + + /** + * String utilities + * @namespace fabric.util.string + */ + fabric.util.string = { + camelize: camelize, + capitalize: capitalize, + escapeXml: escapeXml, + graphemeSplit: graphemeSplit + }; +})(); + + +(function() { + + var slice = Array.prototype.slice, emptyFunction = function() { }, + + IS_DONTENUM_BUGGY = (function() { + for (var p in { toString: 1 }) { + if (p === 'toString') { + return false; + } + } + return true; + })(), + + /** @ignore */ + addMethods = function(klass, source, parent) { + for (var property in source) { + + if (property in klass.prototype && + typeof klass.prototype[property] === 'function' && + (source[property] + '').indexOf('callSuper') > -1) { + + klass.prototype[property] = (function(property) { + return function() { + + var superclass = this.constructor.superclass; + this.constructor.superclass = parent; + var returnValue = source[property].apply(this, arguments); + this.constructor.superclass = superclass; + + if (property !== 'initialize') { + return returnValue; + } + }; + })(property); + } + else { + klass.prototype[property] = source[property]; + } + + if (IS_DONTENUM_BUGGY) { + if (source.toString !== Object.prototype.toString) { + klass.prototype.toString = source.toString; + } + if (source.valueOf !== Object.prototype.valueOf) { + klass.prototype.valueOf = source.valueOf; + } + } + } + }; + + function Subclass() { } + + function callSuper(methodName) { + var parentMethod = null, + _this = this; + + // climb prototype chain to find method not equal to callee's method + while (_this.constructor.superclass) { + var superClassMethod = _this.constructor.superclass.prototype[methodName]; + if (_this[methodName] !== superClassMethod) { + parentMethod = superClassMethod; + break; + } + // eslint-disable-next-line + _this = _this.constructor.superclass.prototype; + } + + if (!parentMethod) { + return console.log('tried to callSuper ' + methodName + ', method not found in prototype chain', this); + } + + return (arguments.length > 1) + ? parentMethod.apply(this, slice.call(arguments, 1)) + : parentMethod.call(this); + } + + /** + * Helper for creation of "classes". + * @memberOf fabric.util + * @param {Function} [parent] optional "Class" to inherit from + * @param {Object} [properties] Properties shared by all instances of this class + * (be careful modifying objects defined here as this would affect all instances) + */ + function createClass() { + var parent = null, + properties = slice.call(arguments, 0); + + if (typeof properties[0] === 'function') { + parent = properties.shift(); + } + function klass() { + this.initialize.apply(this, arguments); + } + + klass.superclass = parent; + klass.subclasses = []; + + if (parent) { + Subclass.prototype = parent.prototype; + klass.prototype = new Subclass(); + parent.subclasses.push(klass); + } + for (var i = 0, length = properties.length; i < length; i++) { + addMethods(klass, properties[i], parent); + } + if (!klass.prototype.initialize) { + klass.prototype.initialize = emptyFunction; + } + klass.prototype.constructor = klass; + klass.prototype.callSuper = callSuper; + return klass; + } + + fabric.util.createClass = createClass; +})(); + + +(function () { + // since ie11 can use addEventListener but they do not support options, i need to check + var couldUseAttachEvent = !!fabric.document.createElement('div').attachEvent, + touchEvents = ['touchstart', 'touchmove', 'touchend']; + /** + * Adds an event listener to an element + * @function + * @memberOf fabric.util + * @param {HTMLElement} element + * @param {String} eventName + * @param {Function} handler + */ + fabric.util.addListener = function(element, eventName, handler, options) { + element && element.addEventListener(eventName, handler, couldUseAttachEvent ? false : options); + }; + + /** + * Removes an event listener from an element + * @function + * @memberOf fabric.util + * @param {HTMLElement} element + * @param {String} eventName + * @param {Function} handler + */ + fabric.util.removeListener = function(element, eventName, handler, options) { + element && element.removeEventListener(eventName, handler, couldUseAttachEvent ? false : options); + }; + + function getTouchInfo(event) { + var touchProp = event.changedTouches; + if (touchProp && touchProp[0]) { + return touchProp[0]; + } + return event; + } + + fabric.util.getPointer = function(event) { + var element = event.target, + scroll = fabric.util.getScrollLeftTop(element), + _evt = getTouchInfo(event); + return { + x: _evt.clientX + scroll.left, + y: _evt.clientY + scroll.top + }; + }; + + fabric.util.isTouchEvent = function(event) { + return touchEvents.indexOf(event.type) > -1 || event.pointerType === 'touch'; + }; +})(); + + +(function () { + + /** + * Cross-browser wrapper for setting element's style + * @memberOf fabric.util + * @param {HTMLElement} element + * @param {Object} styles + * @return {HTMLElement} Element that was passed as a first argument + */ + function setStyle(element, styles) { + var elementStyle = element.style; + if (!elementStyle) { + return element; + } + if (typeof styles === 'string') { + element.style.cssText += ';' + styles; + return styles.indexOf('opacity') > -1 + ? setOpacity(element, styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) + : element; + } + for (var property in styles) { + if (property === 'opacity') { + setOpacity(element, styles[property]); + } + else { + var normalizedProperty = (property === 'float' || property === 'cssFloat') + ? (typeof elementStyle.styleFloat === 'undefined' ? 'cssFloat' : 'styleFloat') + : property; + elementStyle.setProperty(normalizedProperty, styles[property]); + } + } + return element; + } + + var parseEl = fabric.document.createElement('div'), + supportsOpacity = typeof parseEl.style.opacity === 'string', + supportsFilters = typeof parseEl.style.filter === 'string', + reOpacity = /alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/, + + /** @ignore */ + setOpacity = function (element) { return element; }; + + if (supportsOpacity) { + /** @ignore */ + setOpacity = function(element, value) { + element.style.opacity = value; + return element; + }; + } + else if (supportsFilters) { + /** @ignore */ + setOpacity = function(element, value) { + var es = element.style; + if (element.currentStyle && !element.currentStyle.hasLayout) { + es.zoom = 1; + } + if (reOpacity.test(es.filter)) { + value = value >= 0.9999 ? '' : ('alpha(opacity=' + (value * 100) + ')'); + es.filter = es.filter.replace(reOpacity, value); + } + else { + es.filter += ' alpha(opacity=' + (value * 100) + ')'; + } + return element; + }; + } + + fabric.util.setStyle = setStyle; + +})(); + + +(function() { + + var _slice = Array.prototype.slice; + + /** + * Takes id and returns an element with that id (if one exists in a document) + * @memberOf fabric.util + * @param {String|HTMLElement} id + * @return {HTMLElement|null} + */ + function getById(id) { + return typeof id === 'string' ? fabric.document.getElementById(id) : id; + } + + var sliceCanConvertNodelists, + /** + * Converts an array-like object (e.g. arguments or NodeList) to an array + * @memberOf fabric.util + * @param {Object} arrayLike + * @return {Array} + */ + toArray = function(arrayLike) { + return _slice.call(arrayLike, 0); + }; + + try { + sliceCanConvertNodelists = toArray(fabric.document.childNodes) instanceof Array; + } + catch (err) { } + + if (!sliceCanConvertNodelists) { + toArray = function(arrayLike) { + var arr = new Array(arrayLike.length), i = arrayLike.length; + while (i--) { + arr[i] = arrayLike[i]; + } + return arr; + }; + } + + /** + * Creates specified element with specified attributes + * @memberOf fabric.util + * @param {String} tagName Type of an element to create + * @param {Object} [attributes] Attributes to set on an element + * @return {HTMLElement} Newly created element + */ + function makeElement(tagName, attributes) { + var el = fabric.document.createElement(tagName); + for (var prop in attributes) { + if (prop === 'class') { + el.className = attributes[prop]; + } + else if (prop === 'for') { + el.htmlFor = attributes[prop]; + } + else { + el.setAttribute(prop, attributes[prop]); + } + } + return el; + } + + /** + * Adds class to an element + * @memberOf fabric.util + * @param {HTMLElement} element Element to add class to + * @param {String} className Class to add to an element + */ + function addClass(element, className) { + if (element && (' ' + element.className + ' ').indexOf(' ' + className + ' ') === -1) { + element.className += (element.className ? ' ' : '') + className; + } + } + + /** + * Wraps element with another element + * @memberOf fabric.util + * @param {HTMLElement} element Element to wrap + * @param {HTMLElement|String} wrapper Element to wrap with + * @param {Object} [attributes] Attributes to set on a wrapper + * @return {HTMLElement} wrapper + */ + function wrapElement(element, wrapper, attributes) { + if (typeof wrapper === 'string') { + wrapper = makeElement(wrapper, attributes); + } + if (element.parentNode) { + element.parentNode.replaceChild(wrapper, element); + } + wrapper.appendChild(element); + return wrapper; + } + + /** + * Returns element scroll offsets + * @memberOf fabric.util + * @param {HTMLElement} element Element to operate on + * @return {Object} Object with left/top values + */ + function getScrollLeftTop(element) { + + var left = 0, + top = 0, + docElement = fabric.document.documentElement, + body = fabric.document.body || { + scrollLeft: 0, scrollTop: 0 + }; + + // While loop checks (and then sets element to) .parentNode OR .host + // to account for ShadowDOM. We still want to traverse up out of ShadowDOM, + // but the .parentNode of a root ShadowDOM node will always be null, instead + // it should be accessed through .host. See http://stackoverflow.com/a/24765528/4383938 + while (element && (element.parentNode || element.host)) { + + // Set element to element parent, or 'host' in case of ShadowDOM + element = element.parentNode || element.host; + + if (element === fabric.document) { + left = body.scrollLeft || docElement.scrollLeft || 0; + top = body.scrollTop || docElement.scrollTop || 0; + } + else { + left += element.scrollLeft || 0; + top += element.scrollTop || 0; + } + + if (element.nodeType === 1 && element.style.position === 'fixed') { + break; + } + } + + return { left: left, top: top }; + } + + /** + * Returns offset for a given element + * @function + * @memberOf fabric.util + * @param {HTMLElement} element Element to get offset for + * @return {Object} Object with "left" and "top" properties + */ + function getElementOffset(element) { + var docElem, + doc = element && element.ownerDocument, + box = { left: 0, top: 0 }, + offset = { left: 0, top: 0 }, + scrollLeftTop, + offsetAttributes = { + borderLeftWidth: 'left', + borderTopWidth: 'top', + paddingLeft: 'left', + paddingTop: 'top' + }; + + if (!doc) { + return offset; + } + + for (var attr in offsetAttributes) { + offset[offsetAttributes[attr]] += parseInt(getElementStyle(element, attr), 10) || 0; + } + + docElem = doc.documentElement; + if ( typeof element.getBoundingClientRect !== 'undefined' ) { + box = element.getBoundingClientRect(); + } + + scrollLeftTop = getScrollLeftTop(element); + + return { + left: box.left + scrollLeftTop.left - (docElem.clientLeft || 0) + offset.left, + top: box.top + scrollLeftTop.top - (docElem.clientTop || 0) + offset.top + }; + } + + /** + * Returns style attribute value of a given element + * @memberOf fabric.util + * @param {HTMLElement} element Element to get style attribute for + * @param {String} attr Style attribute to get for element + * @return {String} Style attribute value of the given element. + */ + var getElementStyle; + if (fabric.document.defaultView && fabric.document.defaultView.getComputedStyle) { + getElementStyle = function(element, attr) { + var style = fabric.document.defaultView.getComputedStyle(element, null); + return style ? style[attr] : undefined; + }; + } + else { + getElementStyle = function(element, attr) { + var value = element.style[attr]; + if (!value && element.currentStyle) { + value = element.currentStyle[attr]; + } + return value; + }; + } + + (function () { + var style = fabric.document.documentElement.style, + selectProp = 'userSelect' in style + ? 'userSelect' + : 'MozUserSelect' in style + ? 'MozUserSelect' + : 'WebkitUserSelect' in style + ? 'WebkitUserSelect' + : 'KhtmlUserSelect' in style + ? 'KhtmlUserSelect' + : ''; + + /** + * Makes element unselectable + * @memberOf fabric.util + * @param {HTMLElement} element Element to make unselectable + * @return {HTMLElement} Element that was passed in + */ + function makeElementUnselectable(element) { + if (typeof element.onselectstart !== 'undefined') { + element.onselectstart = fabric.util.falseFunction; + } + if (selectProp) { + element.style[selectProp] = 'none'; + } + else if (typeof element.unselectable === 'string') { + element.unselectable = 'on'; + } + return element; + } + + /** + * Makes element selectable + * @memberOf fabric.util + * @param {HTMLElement} element Element to make selectable + * @return {HTMLElement} Element that was passed in + */ + function makeElementSelectable(element) { + if (typeof element.onselectstart !== 'undefined') { + element.onselectstart = null; + } + if (selectProp) { + element.style[selectProp] = ''; + } + else if (typeof element.unselectable === 'string') { + element.unselectable = ''; + } + return element; + } + + fabric.util.makeElementUnselectable = makeElementUnselectable; + fabric.util.makeElementSelectable = makeElementSelectable; + })(); + + function getNodeCanvas(element) { + var impl = fabric.jsdomImplForWrapper(element); + return impl._canvas || impl._image; + }; + + function cleanUpJsdomNode(element) { + if (!fabric.isLikelyNode) { + return; + } + var impl = fabric.jsdomImplForWrapper(element); + if (impl) { + impl._image = null; + impl._canvas = null; + // unsure if necessary + impl._currentSrc = null; + impl._attributes = null; + impl._classList = null; + } + } + + function setImageSmoothing(ctx, value) { + ctx.imageSmoothingEnabled = ctx.imageSmoothingEnabled || ctx.webkitImageSmoothingEnabled + || ctx.mozImageSmoothingEnabled || ctx.msImageSmoothingEnabled || ctx.oImageSmoothingEnabled; + ctx.imageSmoothingEnabled = value; + } + + /** + * setImageSmoothing sets the context imageSmoothingEnabled property. + * Used by canvas and by ImageObject. + * @memberOf fabric.util + * @since 4.0.0 + * @param {HTMLRenderingContext2D} ctx to set on + * @param {Boolean} value true or false + */ + fabric.util.setImageSmoothing = setImageSmoothing; + fabric.util.getById = getById; + fabric.util.toArray = toArray; + fabric.util.addClass = addClass; + fabric.util.makeElement = makeElement; + fabric.util.wrapElement = wrapElement; + fabric.util.getScrollLeftTop = getScrollLeftTop; + fabric.util.getElementOffset = getElementOffset; + fabric.util.getNodeCanvas = getNodeCanvas; + fabric.util.cleanUpJsdomNode = cleanUpJsdomNode; + +})(); + + +(function() { + + function addParamToUrl(url, param) { + return url + (/\?/.test(url) ? '&' : '?') + param; + } + + function emptyFn() { } + + /** + * Cross-browser abstraction for sending XMLHttpRequest + * @memberOf fabric.util + * @param {String} url URL to send XMLHttpRequest to + * @param {Object} [options] Options object + * @param {String} [options.method="GET"] + * @param {String} [options.parameters] parameters to append to url in GET or in body + * @param {String} [options.body] body to send with POST or PUT request + * @param {Function} options.onComplete Callback to invoke when request is completed + * @return {XMLHttpRequest} request + */ + function request(url, options) { + options || (options = { }); + + var method = options.method ? options.method.toUpperCase() : 'GET', + onComplete = options.onComplete || function() { }, + xhr = new fabric.window.XMLHttpRequest(), + body = options.body || options.parameters; + + /** @ignore */ + xhr.onreadystatechange = function() { + if (xhr.readyState === 4) { + onComplete(xhr); + xhr.onreadystatechange = emptyFn; + } + }; + + if (method === 'GET') { + body = null; + if (typeof options.parameters === 'string') { + url = addParamToUrl(url, options.parameters); + } + } + + xhr.open(method, url, true); + + if (method === 'POST' || method === 'PUT') { + xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); + } + + xhr.send(body); + return xhr; + } + + fabric.util.request = request; +})(); + + +/** + * Wrapper around `console.log` (when available) + * @param {*} [values] Values to log + */ +fabric.log = console.log; + +/** + * Wrapper around `console.warn` (when available) + * @param {*} [values] Values to log as a warning + */ +fabric.warn = console.warn; + + +(function () { + + var extend = fabric.util.object.extend, + clone = fabric.util.object.clone; + + /** + * @typedef {Object} AnimationOptions + * Animation of a value or list of values. + * When using lists, think of something like this: + * fabric.util.animate({ + * startValue: [1, 2, 3], + * endValue: [2, 4, 6], + * onChange: function([a, b, c]) { + * canvas.zoomToPoint({x: b, y: c}, a) + * canvas.renderAll() + * } + * }); + * @example + * @property {Function} [onChange] Callback; invoked on every value change + * @property {Function} [onComplete] Callback; invoked when value change is completed + * @example + * // Note: startValue, endValue, and byValue must match the type + * var animationOptions = { startValue: 0, endValue: 1, byValue: 0.25 } + * var animationOptions = { startValue: [0, 1], endValue: [1, 2], byValue: [0.25, 0.25] } + * @property {number | number[]} [startValue=0] Starting value + * @property {number | number[]} [endValue=100] Ending value + * @property {number | number[]} [byValue=100] Value to modify the property by + * @property {Function} [easing] Easing function + * @property {Number} [duration=500] Duration of change (in ms) + * @property {Function} [abort] Additional function with logic. If returns true, animation aborts. + * + * @typedef {() => void} CancelFunction + * + * @typedef {Object} AnimationCurrentState + * @property {number | number[]} currentValue value in range [`startValue`, `endValue`] + * @property {number} completionRate value in range [0, 1] + * @property {number} durationRate value in range [0, 1] + * + * @typedef {(AnimationOptions & AnimationCurrentState & { cancel: CancelFunction }} AnimationContext + */ + + /** + * Array holding all running animations + * @memberof fabric + * @type {AnimationContext[]} + */ + var RUNNING_ANIMATIONS = []; + fabric.util.object.extend(RUNNING_ANIMATIONS, { + + /** + * cancel all running animations at the next requestAnimFrame + * @returns {AnimationContext[]} + */ + cancelAll: function () { + var animations = this.splice(0); + animations.forEach(function (animation) { + animation.cancel(); + }); + return animations; + }, + + /** + * cancel all running animations attached to canvas at the next requestAnimFrame + * @param {fabric.Canvas} canvas + * @returns {AnimationContext[]} + */ + cancelByCanvas: function (canvas) { + if (!canvas) { + return []; + } + var cancelled = this.filter(function (animation) { + return typeof animation.target === 'object' && animation.target.canvas === canvas; + }); + cancelled.forEach(function (animation) { + animation.cancel(); + }); + return cancelled; + }, + + /** + * cancel all running animations for target at the next requestAnimFrame + * @param {*} target + * @returns {AnimationContext[]} + */ + cancelByTarget: function (target) { + var cancelled = this.findAnimationsByTarget(target); + cancelled.forEach(function (animation) { + animation.cancel(); + }); + return cancelled; + }, + + /** + * + * @param {CancelFunction} cancelFunc the function returned by animate + * @returns {number} + */ + findAnimationIndex: function (cancelFunc) { + return this.indexOf(this.findAnimation(cancelFunc)); + }, + + /** + * + * @param {CancelFunction} cancelFunc the function returned by animate + * @returns {AnimationContext | undefined} animation's options object + */ + findAnimation: function (cancelFunc) { + return this.find(function (animation) { + return animation.cancel === cancelFunc; + }); + }, + + /** + * + * @param {*} target the object that is assigned to the target property of the animation context + * @returns {AnimationContext[]} array of animation options object associated with target + */ + findAnimationsByTarget: function (target) { + if (!target) { + return []; + } + return this.filter(function (animation) { + return animation.target === target; + }); + } + }); + + function noop() { + return false; + } + + function defaultEasing(t, b, c, d) { + return -c * Math.cos(t / d * (Math.PI / 2)) + c + b; + } + + /** + * Changes value from one to another within certain period of time, invoking callbacks as value is being changed. + * @memberOf fabric.util + * @param {AnimationOptions} [options] Animation options + * @example + * // Note: startValue, endValue, and byValue must match the type + * fabric.util.animate({ startValue: 0, endValue: 1, byValue: 0.25 }) + * fabric.util.animate({ startValue: [0, 1], endValue: [1, 2], byValue: [0.25, 0.25] }) + * @returns {CancelFunction} cancel function + */ + function animate(options) { + options || (options = {}); + var cancel = false, + context, + removeFromRegistry = function () { + var index = fabric.runningAnimations.indexOf(context); + return index > -1 && fabric.runningAnimations.splice(index, 1)[0]; + }; + + context = extend(clone(options), { + cancel: function () { + cancel = true; + return removeFromRegistry(); + }, + currentValue: 'startValue' in options ? options.startValue : 0, + completionRate: 0, + durationRate: 0 + }); + fabric.runningAnimations.push(context); + + requestAnimFrame(function(timestamp) { + var start = timestamp || +new Date(), + duration = options.duration || 500, + finish = start + duration, time, + onChange = options.onChange || noop, + abort = options.abort || noop, + onComplete = options.onComplete || noop, + easing = options.easing || defaultEasing, + isMany = 'startValue' in options ? options.startValue.length > 0 : false, + startValue = 'startValue' in options ? options.startValue : 0, + endValue = 'endValue' in options ? options.endValue : 100, + byValue = options.byValue || (isMany ? startValue.map(function(value, i) { + return endValue[i] - startValue[i]; + }) : endValue - startValue); + + options.onStart && options.onStart(); + + (function tick(ticktime) { + time = ticktime || +new Date(); + var currentTime = time > finish ? duration : (time - start), + timePerc = currentTime / duration, + current = isMany ? startValue.map(function(_value, i) { + return easing(currentTime, startValue[i], byValue[i], duration); + }) : easing(currentTime, startValue, byValue, duration), + valuePerc = isMany ? Math.abs((current[0] - startValue[0]) / byValue[0]) + : Math.abs((current - startValue) / byValue); + // update context + context.currentValue = isMany ? current.slice() : current; + context.completionRate = valuePerc; + context.durationRate = timePerc; + if (cancel) { + return; + } + if (abort(current, valuePerc, timePerc)) { + removeFromRegistry(); + return; + } + if (time > finish) { + // update context + context.currentValue = isMany ? endValue.slice() : endValue; + context.completionRate = 1; + context.durationRate = 1; + // execute callbacks + onChange(isMany ? endValue.slice() : endValue, 1, 1); + onComplete(endValue, 1, 1); + removeFromRegistry(); + return; + } + else { + onChange(current, valuePerc, timePerc); + requestAnimFrame(tick); + } + })(start); + }); + + return context.cancel; + } + + var _requestAnimFrame = fabric.window.requestAnimationFrame || + fabric.window.webkitRequestAnimationFrame || + fabric.window.mozRequestAnimationFrame || + fabric.window.oRequestAnimationFrame || + fabric.window.msRequestAnimationFrame || + function(callback) { + return fabric.window.setTimeout(callback, 1000 / 60); + }; + + var _cancelAnimFrame = fabric.window.cancelAnimationFrame || fabric.window.clearTimeout; + + /** + * requestAnimationFrame polyfill based on http://paulirish.com/2011/requestanimationframe-for-smart-animating/ + * In order to get a precise start time, `requestAnimFrame` should be called as an entry into the method + * @memberOf fabric.util + * @param {Function} callback Callback to invoke + * @param {DOMElement} element optional Element to associate with animation + */ + function requestAnimFrame() { + return _requestAnimFrame.apply(fabric.window, arguments); + } + + function cancelAnimFrame() { + return _cancelAnimFrame.apply(fabric.window, arguments); + } + + fabric.util.animate = animate; + fabric.util.requestAnimFrame = requestAnimFrame; + fabric.util.cancelAnimFrame = cancelAnimFrame; + fabric.runningAnimations = RUNNING_ANIMATIONS; +})(); + + +(function() { + // Calculate an in-between color. Returns a "rgba()" string. + // Credit: Edwin Martin + // http://www.bitstorm.org/jquery/color-animation/jquery.animate-colors.js + function calculateColor(begin, end, pos) { + var color = 'rgba(' + + parseInt((begin[0] + pos * (end[0] - begin[0])), 10) + ',' + + parseInt((begin[1] + pos * (end[1] - begin[1])), 10) + ',' + + parseInt((begin[2] + pos * (end[2] - begin[2])), 10); + + color += ',' + (begin && end ? parseFloat(begin[3] + pos * (end[3] - begin[3])) : 1); + color += ')'; + return color; + } + + /** + * Changes the color from one to another within certain period of time, invoking callbacks as value is being changed. + * @memberOf fabric.util + * @param {String} fromColor The starting color in hex or rgb(a) format. + * @param {String} toColor The starting color in hex or rgb(a) format. + * @param {Number} [duration] Duration of change (in ms). + * @param {Object} [options] Animation options + * @param {Function} [options.onChange] Callback; invoked on every value change + * @param {Function} [options.onComplete] Callback; invoked when value change is completed + * @param {Function} [options.colorEasing] Easing function. Note that this function only take two arguments (currentTime, duration). Thus the regular animation easing functions cannot be used. + * @param {Function} [options.abort] Additional function with logic. If returns true, onComplete is called. + * @returns {Function} abort function + */ + function animateColor(fromColor, toColor, duration, options) { + var startColor = new fabric.Color(fromColor).getSource(), + endColor = new fabric.Color(toColor).getSource(), + originalOnComplete = options.onComplete, + originalOnChange = options.onChange; + options = options || {}; + + return fabric.util.animate(fabric.util.object.extend(options, { + duration: duration || 500, + startValue: startColor, + endValue: endColor, + byValue: endColor, + easing: function (currentTime, startValue, byValue, duration) { + var posValue = options.colorEasing + ? options.colorEasing(currentTime, duration) + : 1 - Math.cos(currentTime / duration * (Math.PI / 2)); + return calculateColor(startValue, byValue, posValue); + }, + // has to take in account for color restoring; + onComplete: function(current, valuePerc, timePerc) { + if (originalOnComplete) { + return originalOnComplete( + calculateColor(endColor, endColor, 0), + valuePerc, + timePerc + ); + } + }, + onChange: function(current, valuePerc, timePerc) { + if (originalOnChange) { + if (Array.isArray(current)) { + return originalOnChange( + calculateColor(current, current, 0), + valuePerc, + timePerc + ); + } + originalOnChange(current, valuePerc, timePerc); + } + } + })); + } + + fabric.util.animateColor = animateColor; + +})(); + + +(function() { + + function normalize(a, c, p, s) { + if (a < Math.abs(c)) { + a = c; + s = p / 4; + } + else { + //handle the 0/0 case: + if (c === 0 && a === 0) { + s = p / (2 * Math.PI) * Math.asin(1); + } + else { + s = p / (2 * Math.PI) * Math.asin(c / a); + } + } + return { a: a, c: c, p: p, s: s }; + } + + function elastic(opts, t, d) { + return opts.a * + Math.pow(2, 10 * (t -= 1)) * + Math.sin( (t * d - opts.s) * (2 * Math.PI) / opts.p ); + } + + /** + * Cubic easing out + * @memberOf fabric.util.ease + */ + function easeOutCubic(t, b, c, d) { + return c * ((t = t / d - 1) * t * t + 1) + b; + } + + /** + * Cubic easing in and out + * @memberOf fabric.util.ease + */ + function easeInOutCubic(t, b, c, d) { + t /= d / 2; + if (t < 1) { + return c / 2 * t * t * t + b; + } + return c / 2 * ((t -= 2) * t * t + 2) + b; + } + + /** + * Quartic easing in + * @memberOf fabric.util.ease + */ + function easeInQuart(t, b, c, d) { + return c * (t /= d) * t * t * t + b; + } + + /** + * Quartic easing out + * @memberOf fabric.util.ease + */ + function easeOutQuart(t, b, c, d) { + return -c * ((t = t / d - 1) * t * t * t - 1) + b; + } + + /** + * Quartic easing in and out + * @memberOf fabric.util.ease + */ + function easeInOutQuart(t, b, c, d) { + t /= d / 2; + if (t < 1) { + return c / 2 * t * t * t * t + b; + } + return -c / 2 * ((t -= 2) * t * t * t - 2) + b; + } + + /** + * Quintic easing in + * @memberOf fabric.util.ease + */ + function easeInQuint(t, b, c, d) { + return c * (t /= d) * t * t * t * t + b; + } + + /** + * Quintic easing out + * @memberOf fabric.util.ease + */ + function easeOutQuint(t, b, c, d) { + return c * ((t = t / d - 1) * t * t * t * t + 1) + b; + } + + /** + * Quintic easing in and out + * @memberOf fabric.util.ease + */ + function easeInOutQuint(t, b, c, d) { + t /= d / 2; + if (t < 1) { + return c / 2 * t * t * t * t * t + b; + } + return c / 2 * ((t -= 2) * t * t * t * t + 2) + b; + } + + /** + * Sinusoidal easing in + * @memberOf fabric.util.ease + */ + function easeInSine(t, b, c, d) { + return -c * Math.cos(t / d * (Math.PI / 2)) + c + b; + } + + /** + * Sinusoidal easing out + * @memberOf fabric.util.ease + */ + function easeOutSine(t, b, c, d) { + return c * Math.sin(t / d * (Math.PI / 2)) + b; + } + + /** + * Sinusoidal easing in and out + * @memberOf fabric.util.ease + */ + function easeInOutSine(t, b, c, d) { + return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b; + } + + /** + * Exponential easing in + * @memberOf fabric.util.ease + */ + function easeInExpo(t, b, c, d) { + return (t === 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b; + } + + /** + * Exponential easing out + * @memberOf fabric.util.ease + */ + function easeOutExpo(t, b, c, d) { + return (t === d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b; + } + + /** + * Exponential easing in and out + * @memberOf fabric.util.ease + */ + function easeInOutExpo(t, b, c, d) { + if (t === 0) { + return b; + } + if (t === d) { + return b + c; + } + t /= d / 2; + if (t < 1) { + return c / 2 * Math.pow(2, 10 * (t - 1)) + b; + } + return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b; + } + + /** + * Circular easing in + * @memberOf fabric.util.ease + */ + function easeInCirc(t, b, c, d) { + return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b; + } + + /** + * Circular easing out + * @memberOf fabric.util.ease + */ + function easeOutCirc(t, b, c, d) { + return c * Math.sqrt(1 - (t = t / d - 1) * t) + b; + } + + /** + * Circular easing in and out + * @memberOf fabric.util.ease + */ + function easeInOutCirc(t, b, c, d) { + t /= d / 2; + if (t < 1) { + return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b; + } + return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b; + } + + /** + * Elastic easing in + * @memberOf fabric.util.ease + */ + function easeInElastic(t, b, c, d) { + var s = 1.70158, p = 0, a = c; + if (t === 0) { + return b; + } + t /= d; + if (t === 1) { + return b + c; + } + if (!p) { + p = d * 0.3; + } + var opts = normalize(a, c, p, s); + return -elastic(opts, t, d) + b; + } + + /** + * Elastic easing out + * @memberOf fabric.util.ease + */ + function easeOutElastic(t, b, c, d) { + var s = 1.70158, p = 0, a = c; + if (t === 0) { + return b; + } + t /= d; + if (t === 1) { + return b + c; + } + if (!p) { + p = d * 0.3; + } + var opts = normalize(a, c, p, s); + return opts.a * Math.pow(2, -10 * t) * Math.sin((t * d - opts.s) * (2 * Math.PI) / opts.p ) + opts.c + b; + } + + /** + * Elastic easing in and out + * @memberOf fabric.util.ease + */ + function easeInOutElastic(t, b, c, d) { + var s = 1.70158, p = 0, a = c; + if (t === 0) { + return b; + } + t /= d / 2; + if (t === 2) { + return b + c; + } + if (!p) { + p = d * (0.3 * 1.5); + } + var opts = normalize(a, c, p, s); + if (t < 1) { + return -0.5 * elastic(opts, t, d) + b; + } + return opts.a * Math.pow(2, -10 * (t -= 1)) * + Math.sin((t * d - opts.s) * (2 * Math.PI) / opts.p ) * 0.5 + opts.c + b; + } + + /** + * Backwards easing in + * @memberOf fabric.util.ease + */ + function easeInBack(t, b, c, d, s) { + if (s === undefined) { + s = 1.70158; + } + return c * (t /= d) * t * ((s + 1) * t - s) + b; + } + + /** + * Backwards easing out + * @memberOf fabric.util.ease + */ + function easeOutBack(t, b, c, d, s) { + if (s === undefined) { + s = 1.70158; + } + return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b; + } + + /** + * Backwards easing in and out + * @memberOf fabric.util.ease + */ + function easeInOutBack(t, b, c, d, s) { + if (s === undefined) { + s = 1.70158; + } + t /= d / 2; + if (t < 1) { + return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b; + } + return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b; + } + + /** + * Bouncing easing in + * @memberOf fabric.util.ease + */ + function easeInBounce(t, b, c, d) { + return c - easeOutBounce (d - t, 0, c, d) + b; + } + + /** + * Bouncing easing out + * @memberOf fabric.util.ease + */ + function easeOutBounce(t, b, c, d) { + if ((t /= d) < (1 / 2.75)) { + return c * (7.5625 * t * t) + b; + } + else if (t < (2 / 2.75)) { + return c * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75) + b; + } + else if (t < (2.5 / 2.75)) { + return c * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375) + b; + } + else { + return c * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375) + b; + } + } + + /** + * Bouncing easing in and out + * @memberOf fabric.util.ease + */ + function easeInOutBounce(t, b, c, d) { + if (t < d / 2) { + return easeInBounce (t * 2, 0, c, d) * 0.5 + b; + } + return easeOutBounce(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b; + } + + /** + * Easing functions + * See Easing Equations by Robert Penner + * @namespace fabric.util.ease + */ + fabric.util.ease = { + + /** + * Quadratic easing in + * @memberOf fabric.util.ease + */ + easeInQuad: function(t, b, c, d) { + return c * (t /= d) * t + b; + }, + + /** + * Quadratic easing out + * @memberOf fabric.util.ease + */ + easeOutQuad: function(t, b, c, d) { + return -c * (t /= d) * (t - 2) + b; + }, + + /** + * Quadratic easing in and out + * @memberOf fabric.util.ease + */ + easeInOutQuad: function(t, b, c, d) { + t /= (d / 2); + if (t < 1) { + return c / 2 * t * t + b; + } + return -c / 2 * ((--t) * (t - 2) - 1) + b; + }, + + /** + * Cubic easing in + * @memberOf fabric.util.ease + */ + easeInCubic: function(t, b, c, d) { + return c * (t /= d) * t * t + b; + }, + + easeOutCubic: easeOutCubic, + easeInOutCubic: easeInOutCubic, + easeInQuart: easeInQuart, + easeOutQuart: easeOutQuart, + easeInOutQuart: easeInOutQuart, + easeInQuint: easeInQuint, + easeOutQuint: easeOutQuint, + easeInOutQuint: easeInOutQuint, + easeInSine: easeInSine, + easeOutSine: easeOutSine, + easeInOutSine: easeInOutSine, + easeInExpo: easeInExpo, + easeOutExpo: easeOutExpo, + easeInOutExpo: easeInOutExpo, + easeInCirc: easeInCirc, + easeOutCirc: easeOutCirc, + easeInOutCirc: easeInOutCirc, + easeInElastic: easeInElastic, + easeOutElastic: easeOutElastic, + easeInOutElastic: easeInOutElastic, + easeInBack: easeInBack, + easeOutBack: easeOutBack, + easeInOutBack: easeInOutBack, + easeInBounce: easeInBounce, + easeOutBounce: easeOutBounce, + easeInOutBounce: easeInOutBounce + }; + +})(); + + +(function(global) { + + 'use strict'; + + /** + * @name fabric + * @namespace + */ + + var fabric = global.fabric || (global.fabric = { }), + extend = fabric.util.object.extend, + clone = fabric.util.object.clone, + toFixed = fabric.util.toFixed, + parseUnit = fabric.util.parseUnit, + multiplyTransformMatrices = fabric.util.multiplyTransformMatrices, + + svgValidTagNames = ['path', 'circle', 'polygon', 'polyline', 'ellipse', 'rect', 'line', + 'image', 'text'], + svgViewBoxElements = ['symbol', 'image', 'marker', 'pattern', 'view', 'svg'], + svgInvalidAncestors = ['pattern', 'defs', 'symbol', 'metadata', 'clipPath', 'mask', 'desc'], + svgValidParents = ['symbol', 'g', 'a', 'svg', 'clipPath', 'defs'], + + attributesMap = { + cx: 'left', + x: 'left', + r: 'radius', + cy: 'top', + y: 'top', + display: 'visible', + visibility: 'visible', + transform: 'transformMatrix', + 'fill-opacity': 'fillOpacity', + 'fill-rule': 'fillRule', + 'font-family': 'fontFamily', + 'font-size': 'fontSize', + 'font-style': 'fontStyle', + 'font-weight': 'fontWeight', + 'letter-spacing': 'charSpacing', + 'paint-order': 'paintFirst', + 'stroke-dasharray': 'strokeDashArray', + 'stroke-dashoffset': 'strokeDashOffset', + 'stroke-linecap': 'strokeLineCap', + 'stroke-linejoin': 'strokeLineJoin', + 'stroke-miterlimit': 'strokeMiterLimit', + 'stroke-opacity': 'strokeOpacity', + 'stroke-width': 'strokeWidth', + 'text-decoration': 'textDecoration', + 'text-anchor': 'textAnchor', + opacity: 'opacity', + 'clip-path': 'clipPath', + 'clip-rule': 'clipRule', + 'vector-effect': 'strokeUniform', + 'image-rendering': 'imageSmoothing', + }, + + colorAttributes = { + stroke: 'strokeOpacity', + fill: 'fillOpacity' + }, + + fSize = 'font-size', cPath = 'clip-path'; + + fabric.svgValidTagNamesRegEx = getSvgRegex(svgValidTagNames); + fabric.svgViewBoxElementsRegEx = getSvgRegex(svgViewBoxElements); + fabric.svgInvalidAncestorsRegEx = getSvgRegex(svgInvalidAncestors); + fabric.svgValidParentsRegEx = getSvgRegex(svgValidParents); + + fabric.cssRules = { }; + fabric.gradientDefs = { }; + fabric.clipPaths = { }; + + function normalizeAttr(attr) { + // transform attribute names + if (attr in attributesMap) { + return attributesMap[attr]; + } + return attr; + } + + function normalizeValue(attr, value, parentAttributes, fontSize) { + var isArray = Array.isArray(value), parsed; + + if ((attr === 'fill' || attr === 'stroke') && value === 'none') { + value = ''; + } + else if (attr === 'strokeUniform') { + return (value === 'non-scaling-stroke'); + } + else if (attr === 'strokeDashArray') { + if (value === 'none') { + value = null; + } + else { + value = value.replace(/,/g, ' ').split(/\s+/).map(parseFloat); + } + } + else if (attr === 'transformMatrix') { + if (parentAttributes && parentAttributes.transformMatrix) { + value = multiplyTransformMatrices( + parentAttributes.transformMatrix, fabric.parseTransformAttribute(value)); + } + else { + value = fabric.parseTransformAttribute(value); + } + } + else if (attr === 'visible') { + value = value !== 'none' && value !== 'hidden'; + // display=none on parent element always takes precedence over child element + if (parentAttributes && parentAttributes.visible === false) { + value = false; + } + } + else if (attr === 'opacity') { + value = parseFloat(value); + if (parentAttributes && typeof parentAttributes.opacity !== 'undefined') { + value *= parentAttributes.opacity; + } + } + else if (attr === 'textAnchor' /* text-anchor */) { + value = value === 'start' ? 'left' : value === 'end' ? 'right' : 'center'; + } + else if (attr === 'charSpacing') { + // parseUnit returns px and we convert it to em + parsed = parseUnit(value, fontSize) / fontSize * 1000; + } + else if (attr === 'paintFirst') { + var fillIndex = value.indexOf('fill'); + var strokeIndex = value.indexOf('stroke'); + var value = 'fill'; + if (fillIndex > -1 && strokeIndex > -1 && strokeIndex < fillIndex) { + value = 'stroke'; + } + else if (fillIndex === -1 && strokeIndex > -1) { + value = 'stroke'; + } + } + else if (attr === 'href' || attr === 'xlink:href' || attr === 'font') { + return value; + } + else if (attr === 'imageSmoothing') { + return (value === 'optimizeQuality'); + } + else { + parsed = isArray ? value.map(parseUnit) : parseUnit(value, fontSize); + } + + return (!isArray && isNaN(parsed) ? value : parsed); + } + + /** + * @private + */ + function getSvgRegex(arr) { + return new RegExp('^(' + arr.join('|') + ')\\b', 'i'); + } + + /** + * @private + * @param {Object} attributes Array of attributes to parse + */ + function _setStrokeFillOpacity(attributes) { + for (var attr in colorAttributes) { + + if (typeof attributes[colorAttributes[attr]] === 'undefined' || attributes[attr] === '') { + continue; + } + + if (typeof attributes[attr] === 'undefined') { + if (!fabric.Object.prototype[attr]) { + continue; + } + attributes[attr] = fabric.Object.prototype[attr]; + } + + if (attributes[attr].indexOf('url(') === 0) { + continue; + } + + var color = new fabric.Color(attributes[attr]); + attributes[attr] = color.setAlpha(toFixed(color.getAlpha() * attributes[colorAttributes[attr]], 2)).toRgba(); + } + return attributes; + } + + /** + * @private + */ + function _getMultipleNodes(doc, nodeNames) { + var nodeName, nodeArray = [], nodeList, i, len; + for (i = 0, len = nodeNames.length; i < len; i++) { + nodeName = nodeNames[i]; + nodeList = doc.getElementsByTagName(nodeName); + nodeArray = nodeArray.concat(Array.prototype.slice.call(nodeList)); + } + return nodeArray; + } + + /** + * Parses "transform" attribute, returning an array of values + * @static + * @function + * @memberOf fabric + * @param {String} attributeValue String containing attribute value + * @return {Array} Array of 6 elements representing transformation matrix + */ + fabric.parseTransformAttribute = (function() { + function rotateMatrix(matrix, args) { + var cos = fabric.util.cos(args[0]), sin = fabric.util.sin(args[0]), + x = 0, y = 0; + if (args.length === 3) { + x = args[1]; + y = args[2]; + } + + matrix[0] = cos; + matrix[1] = sin; + matrix[2] = -sin; + matrix[3] = cos; + matrix[4] = x - (cos * x - sin * y); + matrix[5] = y - (sin * x + cos * y); + } + + function scaleMatrix(matrix, args) { + var multiplierX = args[0], + multiplierY = (args.length === 2) ? args[1] : args[0]; + + matrix[0] = multiplierX; + matrix[3] = multiplierY; + } + + function skewMatrix(matrix, args, pos) { + matrix[pos] = Math.tan(fabric.util.degreesToRadians(args[0])); + } + + function translateMatrix(matrix, args) { + matrix[4] = args[0]; + if (args.length === 2) { + matrix[5] = args[1]; + } + } + + // identity matrix + var iMatrix = fabric.iMatrix, + + // == begin transform regexp + number = fabric.reNum, + + commaWsp = fabric.commaWsp, + + skewX = '(?:(skewX)\\s*\\(\\s*(' + number + ')\\s*\\))', + + skewY = '(?:(skewY)\\s*\\(\\s*(' + number + ')\\s*\\))', + + rotate = '(?:(rotate)\\s*\\(\\s*(' + number + ')(?:' + + commaWsp + '(' + number + ')' + + commaWsp + '(' + number + '))?\\s*\\))', + + scale = '(?:(scale)\\s*\\(\\s*(' + number + ')(?:' + + commaWsp + '(' + number + '))?\\s*\\))', + + translate = '(?:(translate)\\s*\\(\\s*(' + number + ')(?:' + + commaWsp + '(' + number + '))?\\s*\\))', + + matrix = '(?:(matrix)\\s*\\(\\s*' + + '(' + number + ')' + commaWsp + + '(' + number + ')' + commaWsp + + '(' + number + ')' + commaWsp + + '(' + number + ')' + commaWsp + + '(' + number + ')' + commaWsp + + '(' + number + ')' + + '\\s*\\))', + + transform = '(?:' + + matrix + '|' + + translate + '|' + + scale + '|' + + rotate + '|' + + skewX + '|' + + skewY + + ')', + + transforms = '(?:' + transform + '(?:' + commaWsp + '*' + transform + ')*' + ')', + + transformList = '^\\s*(?:' + transforms + '?)\\s*$', + + // http://www.w3.org/TR/SVG/coords.html#TransformAttribute + reTransformList = new RegExp(transformList), + // == end transform regexp + + reTransform = new RegExp(transform, 'g'); + + return function(attributeValue) { + + // start with identity matrix + var matrix = iMatrix.concat(), + matrices = []; + + // return if no argument was given or + // an argument does not match transform attribute regexp + if (!attributeValue || (attributeValue && !reTransformList.test(attributeValue))) { + return matrix; + } + + attributeValue.replace(reTransform, function(match) { + + var m = new RegExp(transform).exec(match).filter(function (match) { + // match !== '' && match != null + return (!!match); + }), + operation = m[1], + args = m.slice(2).map(parseFloat); + + switch (operation) { + case 'translate': + translateMatrix(matrix, args); + break; + case 'rotate': + args[0] = fabric.util.degreesToRadians(args[0]); + rotateMatrix(matrix, args); + break; + case 'scale': + scaleMatrix(matrix, args); + break; + case 'skewX': + skewMatrix(matrix, args, 2); + break; + case 'skewY': + skewMatrix(matrix, args, 1); + break; + case 'matrix': + matrix = args; + break; + } + + // snapshot current matrix into matrices array + matrices.push(matrix.concat()); + // reset + matrix = iMatrix.concat(); + }); + + var combinedMatrix = matrices[0]; + while (matrices.length > 1) { + matrices.shift(); + combinedMatrix = fabric.util.multiplyTransformMatrices(combinedMatrix, matrices[0]); + } + return combinedMatrix; + }; + })(); + + /** + * @private + */ + function parseStyleString(style, oStyle) { + var attr, value; + style.replace(/;\s*$/, '').split(';').forEach(function (chunk) { + var pair = chunk.split(':'); + + attr = pair[0].trim().toLowerCase(); + value = pair[1].trim(); + + oStyle[attr] = value; + }); + } + + /** + * @private + */ + function parseStyleObject(style, oStyle) { + var attr, value; + for (var prop in style) { + if (typeof style[prop] === 'undefined') { + continue; + } + + attr = prop.toLowerCase(); + value = style[prop]; + + oStyle[attr] = value; + } + } + + /** + * @private + */ + function getGlobalStylesForElement(element, svgUid) { + var styles = { }; + for (var rule in fabric.cssRules[svgUid]) { + if (elementMatchesRule(element, rule.split(' '))) { + for (var property in fabric.cssRules[svgUid][rule]) { + styles[property] = fabric.cssRules[svgUid][rule][property]; + } + } + } + return styles; + } + + /** + * @private + */ + function elementMatchesRule(element, selectors) { + var firstMatching, parentMatching = true; + //start from rightmost selector. + firstMatching = selectorMatches(element, selectors.pop()); + if (firstMatching && selectors.length) { + parentMatching = doesSomeParentMatch(element, selectors); + } + return firstMatching && parentMatching && (selectors.length === 0); + } + + function doesSomeParentMatch(element, selectors) { + var selector, parentMatching = true; + while (element.parentNode && element.parentNode.nodeType === 1 && selectors.length) { + if (parentMatching) { + selector = selectors.pop(); + } + element = element.parentNode; + parentMatching = selectorMatches(element, selector); + } + return selectors.length === 0; + } + + /** + * @private + */ + function selectorMatches(element, selector) { + var nodeName = element.nodeName, + classNames = element.getAttribute('class'), + id = element.getAttribute('id'), matcher, i; + // i check if a selector matches slicing away part from it. + // if i get empty string i should match + matcher = new RegExp('^' + nodeName, 'i'); + selector = selector.replace(matcher, ''); + if (id && selector.length) { + matcher = new RegExp('#' + id + '(?![a-zA-Z\\-]+)', 'i'); + selector = selector.replace(matcher, ''); + } + if (classNames && selector.length) { + classNames = classNames.split(' '); + for (i = classNames.length; i--;) { + matcher = new RegExp('\\.' + classNames[i] + '(?![a-zA-Z\\-]+)', 'i'); + selector = selector.replace(matcher, ''); + } + } + return selector.length === 0; + } + + /** + * @private + * to support IE8 missing getElementById on SVGdocument and on node xmlDOM + */ + function elementById(doc, id) { + var el; + doc.getElementById && (el = doc.getElementById(id)); + if (el) { + return el; + } + var node, i, len, nodelist = doc.getElementsByTagName('*'); + for (i = 0, len = nodelist.length; i < len; i++) { + node = nodelist[i]; + if (id === node.getAttribute('id')) { + return node; + } + } + } + + /** + * @private + */ + function parseUseDirectives(doc) { + var nodelist = _getMultipleNodes(doc, ['use', 'svg:use']), i = 0; + while (nodelist.length && i < nodelist.length) { + var el = nodelist[i], + xlinkAttribute = el.getAttribute('xlink:href') || el.getAttribute('href'); + + if (xlinkAttribute === null) { + return; + } + + var xlink = xlinkAttribute.slice(1), + x = el.getAttribute('x') || 0, + y = el.getAttribute('y') || 0, + el2 = elementById(doc, xlink).cloneNode(true), + currentTrans = (el2.getAttribute('transform') || '') + ' translate(' + x + ', ' + y + ')', + parentNode, + oldLength = nodelist.length, attr, + j, + attrs, + len, + namespace = fabric.svgNS; + + applyViewboxTransform(el2); + if (/^svg$/i.test(el2.nodeName)) { + var el3 = el2.ownerDocument.createElementNS(namespace, 'g'); + for (j = 0, attrs = el2.attributes, len = attrs.length; j < len; j++) { + attr = attrs.item(j); + el3.setAttributeNS(namespace, attr.nodeName, attr.nodeValue); + } + // el2.firstChild != null + while (el2.firstChild) { + el3.appendChild(el2.firstChild); + } + el2 = el3; + } + + for (j = 0, attrs = el.attributes, len = attrs.length; j < len; j++) { + attr = attrs.item(j); + if (attr.nodeName === 'x' || attr.nodeName === 'y' || + attr.nodeName === 'xlink:href' || attr.nodeName === 'href') { + continue; + } + + if (attr.nodeName === 'transform') { + currentTrans = attr.nodeValue + ' ' + currentTrans; + } + else { + el2.setAttribute(attr.nodeName, attr.nodeValue); + } + } + + el2.setAttribute('transform', currentTrans); + el2.setAttribute('instantiated_by_use', '1'); + el2.removeAttribute('id'); + parentNode = el.parentNode; + parentNode.replaceChild(el2, el); + // some browsers do not shorten nodelist after replaceChild (IE8) + if (nodelist.length === oldLength) { + i++; + } + } + } + + // http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute + // matches, e.g.: +14.56e-12, etc. + var reViewBoxAttrValue = new RegExp( + '^' + + '\\s*(' + fabric.reNum + '+)\\s*,?' + + '\\s*(' + fabric.reNum + '+)\\s*,?' + + '\\s*(' + fabric.reNum + '+)\\s*,?' + + '\\s*(' + fabric.reNum + '+)\\s*' + + '$' + ); + + /** + * Add a element that envelop all child elements and makes the viewbox transformMatrix descend on all elements + */ + function applyViewboxTransform(element) { + if (!fabric.svgViewBoxElementsRegEx.test(element.nodeName)) { + return {}; + } + var viewBoxAttr = element.getAttribute('viewBox'), + scaleX = 1, + scaleY = 1, + minX = 0, + minY = 0, + viewBoxWidth, viewBoxHeight, matrix, el, + widthAttr = element.getAttribute('width'), + heightAttr = element.getAttribute('height'), + x = element.getAttribute('x') || 0, + y = element.getAttribute('y') || 0, + preserveAspectRatio = element.getAttribute('preserveAspectRatio') || '', + missingViewBox = (!viewBoxAttr || !(viewBoxAttr = viewBoxAttr.match(reViewBoxAttrValue))), + missingDimAttr = (!widthAttr || !heightAttr || widthAttr === '100%' || heightAttr === '100%'), + toBeParsed = missingViewBox && missingDimAttr, + parsedDim = { }, translateMatrix = '', widthDiff = 0, heightDiff = 0; + + parsedDim.width = 0; + parsedDim.height = 0; + parsedDim.toBeParsed = toBeParsed; + + if (missingViewBox) { + if (((x || y) && element.parentNode && element.parentNode.nodeName !== '#document')) { + translateMatrix = ' translate(' + parseUnit(x) + ' ' + parseUnit(y) + ') '; + matrix = (element.getAttribute('transform') || '') + translateMatrix; + element.setAttribute('transform', matrix); + element.removeAttribute('x'); + element.removeAttribute('y'); + } + } + + if (toBeParsed) { + return parsedDim; + } + + if (missingViewBox) { + parsedDim.width = parseUnit(widthAttr); + parsedDim.height = parseUnit(heightAttr); + // set a transform for elements that have x y and are inner(only) SVGs + return parsedDim; + } + minX = -parseFloat(viewBoxAttr[1]); + minY = -parseFloat(viewBoxAttr[2]); + viewBoxWidth = parseFloat(viewBoxAttr[3]); + viewBoxHeight = parseFloat(viewBoxAttr[4]); + parsedDim.minX = minX; + parsedDim.minY = minY; + parsedDim.viewBoxWidth = viewBoxWidth; + parsedDim.viewBoxHeight = viewBoxHeight; + if (!missingDimAttr) { + parsedDim.width = parseUnit(widthAttr); + parsedDim.height = parseUnit(heightAttr); + scaleX = parsedDim.width / viewBoxWidth; + scaleY = parsedDim.height / viewBoxHeight; + } + else { + parsedDim.width = viewBoxWidth; + parsedDim.height = viewBoxHeight; + } + + // default is to preserve aspect ratio + preserveAspectRatio = fabric.util.parsePreserveAspectRatioAttribute(preserveAspectRatio); + if (preserveAspectRatio.alignX !== 'none') { + //translate all container for the effect of Mid, Min, Max + if (preserveAspectRatio.meetOrSlice === 'meet') { + scaleY = scaleX = (scaleX > scaleY ? scaleY : scaleX); + // calculate additional translation to move the viewbox + } + if (preserveAspectRatio.meetOrSlice === 'slice') { + scaleY = scaleX = (scaleX > scaleY ? scaleX : scaleY); + // calculate additional translation to move the viewbox + } + widthDiff = parsedDim.width - viewBoxWidth * scaleX; + heightDiff = parsedDim.height - viewBoxHeight * scaleX; + if (preserveAspectRatio.alignX === 'Mid') { + widthDiff /= 2; + } + if (preserveAspectRatio.alignY === 'Mid') { + heightDiff /= 2; + } + if (preserveAspectRatio.alignX === 'Min') { + widthDiff = 0; + } + if (preserveAspectRatio.alignY === 'Min') { + heightDiff = 0; + } + } + + if (scaleX === 1 && scaleY === 1 && minX === 0 && minY === 0 && x === 0 && y === 0) { + return parsedDim; + } + if ((x || y) && element.parentNode.nodeName !== '#document') { + translateMatrix = ' translate(' + parseUnit(x) + ' ' + parseUnit(y) + ') '; + } + + matrix = translateMatrix + ' matrix(' + scaleX + + ' 0' + + ' 0 ' + + scaleY + ' ' + + (minX * scaleX + widthDiff) + ' ' + + (minY * scaleY + heightDiff) + ') '; + // seems unused. + // parsedDim.viewboxTransform = fabric.parseTransformAttribute(matrix); + if (element.nodeName === 'svg') { + el = element.ownerDocument.createElementNS(fabric.svgNS, 'g'); + // element.firstChild != null + while (element.firstChild) { + el.appendChild(element.firstChild); + } + element.appendChild(el); + } + else { + el = element; + el.removeAttribute('x'); + el.removeAttribute('y'); + matrix = el.getAttribute('transform') + matrix; + } + el.setAttribute('transform', matrix); + return parsedDim; + } + + function hasAncestorWithNodeName(element, nodeName) { + while (element && (element = element.parentNode)) { + if (element.nodeName && nodeName.test(element.nodeName.replace('svg:', '')) + && !element.getAttribute('instantiated_by_use')) { + return true; + } + } + return false; + } + + /** + * Parses an SVG document, converts it to an array of corresponding fabric.* instances and passes them to a callback + * @static + * @function + * @memberOf fabric + * @param {SVGDocument} doc SVG document to parse + * @param {Function} callback Callback to call when parsing is finished; + * It's being passed an array of elements (parsed from a document). + * @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created. + * @param {Object} [parsingOptions] options for parsing document + * @param {String} [parsingOptions.crossOrigin] crossOrigin settings + */ + fabric.parseSVGDocument = function(doc, callback, reviver, parsingOptions) { + if (!doc) { + return; + } + + parseUseDirectives(doc); + + var svgUid = fabric.Object.__uid++, i, len, + options = applyViewboxTransform(doc), + descendants = fabric.util.toArray(doc.getElementsByTagName('*')); + options.crossOrigin = parsingOptions && parsingOptions.crossOrigin; + options.svgUid = svgUid; + + if (descendants.length === 0 && fabric.isLikelyNode) { + // we're likely in node, where "o3-xml" library fails to gEBTN("*") + // https://github.com/ajaxorg/node-o3-xml/issues/21 + descendants = doc.selectNodes('//*[name(.)!="svg"]'); + var arr = []; + for (i = 0, len = descendants.length; i < len; i++) { + arr[i] = descendants[i]; + } + descendants = arr; + } + + var elements = descendants.filter(function(el) { + applyViewboxTransform(el); + return fabric.svgValidTagNamesRegEx.test(el.nodeName.replace('svg:', '')) && + !hasAncestorWithNodeName(el, fabric.svgInvalidAncestorsRegEx); // http://www.w3.org/TR/SVG/struct.html#DefsElement + }); + if (!elements || (elements && !elements.length)) { + callback && callback([], {}); + return; + } + var clipPaths = { }; + descendants.filter(function(el) { + return el.nodeName.replace('svg:', '') === 'clipPath'; + }).forEach(function(el) { + var id = el.getAttribute('id'); + clipPaths[id] = fabric.util.toArray(el.getElementsByTagName('*')).filter(function(el) { + return fabric.svgValidTagNamesRegEx.test(el.nodeName.replace('svg:', '')); + }); + }); + fabric.gradientDefs[svgUid] = fabric.getGradientDefs(doc); + fabric.cssRules[svgUid] = fabric.getCSSRules(doc); + fabric.clipPaths[svgUid] = clipPaths; + // Precedence of rules: style > class > attribute + fabric.parseElements(elements, function(instances, elements) { + if (callback) { + callback(instances, options, elements, descendants); + delete fabric.gradientDefs[svgUid]; + delete fabric.cssRules[svgUid]; + delete fabric.clipPaths[svgUid]; + } + }, clone(options), reviver, parsingOptions); + }; + + function recursivelyParseGradientsXlink(doc, gradient) { + var gradientsAttrs = ['gradientTransform', 'x1', 'x2', 'y1', 'y2', 'gradientUnits', 'cx', 'cy', 'r', 'fx', 'fy'], + xlinkAttr = 'xlink:href', + xLink = gradient.getAttribute(xlinkAttr).slice(1), + referencedGradient = elementById(doc, xLink); + if (referencedGradient && referencedGradient.getAttribute(xlinkAttr)) { + recursivelyParseGradientsXlink(doc, referencedGradient); + } + gradientsAttrs.forEach(function(attr) { + if (referencedGradient && !gradient.hasAttribute(attr) && referencedGradient.hasAttribute(attr)) { + gradient.setAttribute(attr, referencedGradient.getAttribute(attr)); + } + }); + if (!gradient.children.length) { + var referenceClone = referencedGradient.cloneNode(true); + while (referenceClone.firstChild) { + gradient.appendChild(referenceClone.firstChild); + } + } + gradient.removeAttribute(xlinkAttr); + } + + var reFontDeclaration = new RegExp( + '(normal|italic)?\\s*(normal|small-caps)?\\s*' + + '(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*(' + + fabric.reNum + + '(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|' + fabric.reNum + '))?\\s+(.*)'); + + extend(fabric, { + /** + * Parses a short font declaration, building adding its properties to a style object + * @static + * @function + * @memberOf fabric + * @param {String} value font declaration + * @param {Object} oStyle definition + */ + parseFontDeclaration: function(value, oStyle) { + var match = value.match(reFontDeclaration); + + if (!match) { + return; + } + var fontStyle = match[1], + // font variant is not used + // fontVariant = match[2], + fontWeight = match[3], + fontSize = match[4], + lineHeight = match[5], + fontFamily = match[6]; + + if (fontStyle) { + oStyle.fontStyle = fontStyle; + } + if (fontWeight) { + oStyle.fontWeight = isNaN(parseFloat(fontWeight)) ? fontWeight : parseFloat(fontWeight); + } + if (fontSize) { + oStyle.fontSize = parseUnit(fontSize); + } + if (fontFamily) { + oStyle.fontFamily = fontFamily; + } + if (lineHeight) { + oStyle.lineHeight = lineHeight === 'normal' ? 1 : lineHeight; + } + }, + + /** + * Parses an SVG document, returning all of the gradient declarations found in it + * @static + * @function + * @memberOf fabric + * @param {SVGDocument} doc SVG document to parse + * @return {Object} Gradient definitions; key corresponds to element id, value -- to gradient definition element + */ + getGradientDefs: function(doc) { + var tagArray = [ + 'linearGradient', + 'radialGradient', + 'svg:linearGradient', + 'svg:radialGradient'], + elList = _getMultipleNodes(doc, tagArray), + el, j = 0, gradientDefs = { }; + j = elList.length; + while (j--) { + el = elList[j]; + if (el.getAttribute('xlink:href')) { + recursivelyParseGradientsXlink(doc, el); + } + gradientDefs[el.getAttribute('id')] = el; + } + return gradientDefs; + }, + + /** + * Returns an object of attributes' name/value, given element and an array of attribute names; + * Parses parent "g" nodes recursively upwards. + * @static + * @memberOf fabric + * @param {DOMElement} element Element to parse + * @param {Array} attributes Array of attributes to parse + * @return {Object} object containing parsed attributes' names/values + */ + parseAttributes: function(element, attributes, svgUid) { + + if (!element) { + return; + } + + var value, + parentAttributes = { }, + fontSize, parentFontSize; + + if (typeof svgUid === 'undefined') { + svgUid = element.getAttribute('svgUid'); + } + // if there's a parent container (`g` or `a` or `symbol` node), parse its attributes recursively upwards + if (element.parentNode && fabric.svgValidParentsRegEx.test(element.parentNode.nodeName)) { + parentAttributes = fabric.parseAttributes(element.parentNode, attributes, svgUid); + } + + var ownAttributes = attributes.reduce(function(memo, attr) { + value = element.getAttribute(attr); + if (value) { // eslint-disable-line + memo[attr] = value; + } + return memo; + }, { }); + // add values parsed from style, which take precedence over attributes + // (see: http://www.w3.org/TR/SVG/styling.html#UsingPresentationAttributes) + var cssAttrs = extend( + getGlobalStylesForElement(element, svgUid), + fabric.parseStyleAttribute(element) + ); + ownAttributes = extend( + ownAttributes, + cssAttrs + ); + if (cssAttrs[cPath]) { + element.setAttribute(cPath, cssAttrs[cPath]); + } + fontSize = parentFontSize = parentAttributes.fontSize || fabric.Text.DEFAULT_SVG_FONT_SIZE; + if (ownAttributes[fSize]) { + // looks like the minimum should be 9px when dealing with ems. this is what looks like in browsers. + ownAttributes[fSize] = fontSize = parseUnit(ownAttributes[fSize], parentFontSize); + } + + var normalizedAttr, normalizedValue, normalizedStyle = {}; + for (var attr in ownAttributes) { + normalizedAttr = normalizeAttr(attr); + normalizedValue = normalizeValue(normalizedAttr, ownAttributes[attr], parentAttributes, fontSize); + normalizedStyle[normalizedAttr] = normalizedValue; + } + if (normalizedStyle && normalizedStyle.font) { + fabric.parseFontDeclaration(normalizedStyle.font, normalizedStyle); + } + var mergedAttrs = extend(parentAttributes, normalizedStyle); + return fabric.svgValidParentsRegEx.test(element.nodeName) ? mergedAttrs : _setStrokeFillOpacity(mergedAttrs); + }, + + /** + * Transforms an array of svg elements to corresponding fabric.* instances + * @static + * @memberOf fabric + * @param {Array} elements Array of elements to parse + * @param {Function} callback Being passed an array of fabric instances (transformed from SVG elements) + * @param {Object} [options] Options object + * @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created. + */ + parseElements: function(elements, callback, options, reviver, parsingOptions) { + new fabric.ElementsParser(elements, callback, options, reviver, parsingOptions).parse(); + }, + + /** + * Parses "style" attribute, retuning an object with values + * @static + * @memberOf fabric + * @param {SVGElement} element Element to parse + * @return {Object} Objects with values parsed from style attribute of an element + */ + parseStyleAttribute: function(element) { + var oStyle = { }, + style = element.getAttribute('style'); + + if (!style) { + return oStyle; + } + + if (typeof style === 'string') { + parseStyleString(style, oStyle); + } + else { + parseStyleObject(style, oStyle); + } + + return oStyle; + }, + + /** + * Parses "points" attribute, returning an array of values + * @static + * @memberOf fabric + * @param {String} points points attribute string + * @return {Array} array of points + */ + parsePointsAttribute: function(points) { + + // points attribute is required and must not be empty + if (!points) { + return null; + } + + // replace commas with whitespace and remove bookending whitespace + points = points.replace(/,/g, ' ').trim(); + + points = points.split(/\s+/); + var parsedPoints = [], i, len; + + for (i = 0, len = points.length; i < len; i += 2) { + parsedPoints.push({ + x: parseFloat(points[i]), + y: parseFloat(points[i + 1]) + }); + } + + // odd number of points is an error + // if (parsedPoints.length % 2 !== 0) { + // return null; + // } + + return parsedPoints; + }, + + /** + * Returns CSS rules for a given SVG document + * @static + * @function + * @memberOf fabric + * @param {SVGDocument} doc SVG document to parse + * @return {Object} CSS rules of this document + */ + getCSSRules: function(doc) { + var styles = doc.getElementsByTagName('style'), i, len, + allRules = { }, rules; + + // very crude parsing of style contents + for (i = 0, len = styles.length; i < len; i++) { + var styleContents = styles[i].textContent; + + // remove comments + styleContents = styleContents.replace(/\/\*[\s\S]*?\*\//g, ''); + if (styleContents.trim() === '') { + continue; + } + // recovers all the rule in this form `body { style code... }` + // rules = styleContents.match(/[^{]*\{[\s\S]*?\}/g); + rules = styleContents.split('}'); + // remove empty rules. + rules = rules.filter(function(rule) { return rule.trim(); }); + // at this point we have hopefully an array of rules `body { style code... ` + // eslint-disable-next-line no-loop-func + rules.forEach(function(rule) { + + var match = rule.split('{'), + ruleObj = { }, declaration = match[1].trim(), + propertyValuePairs = declaration.split(';').filter(function(pair) { return pair.trim(); }); + + for (i = 0, len = propertyValuePairs.length; i < len; i++) { + var pair = propertyValuePairs[i].split(':'), + property = pair[0].trim(), + value = pair[1].trim(); + ruleObj[property] = value; + } + rule = match[0].trim(); + rule.split(',').forEach(function(_rule) { + _rule = _rule.replace(/^svg/i, '').trim(); + if (_rule === '') { + return; + } + if (allRules[_rule]) { + fabric.util.object.extend(allRules[_rule], ruleObj); + } + else { + allRules[_rule] = fabric.util.object.clone(ruleObj); + } + }); + }); + } + return allRules; + }, + + /** + * Takes url corresponding to an SVG document, and parses it into a set of fabric objects. + * Note that SVG is fetched via XMLHttpRequest, so it needs to conform to SOP (Same Origin Policy) + * @memberOf fabric + * @param {String} url + * @param {Function} callback + * @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created. + * @param {Object} [options] Object containing options for parsing + * @param {String} [options.crossOrigin] crossOrigin crossOrigin setting to use for external resources + */ + loadSVGFromURL: function(url, callback, reviver, options) { + + url = url.replace(/^\n\s*/, '').trim(); + new fabric.util.request(url, { + method: 'get', + onComplete: onComplete + }); + + function onComplete(r) { + + var xml = r.responseXML; + if (!xml || !xml.documentElement) { + callback && callback(null); + return false; + } + + fabric.parseSVGDocument(xml.documentElement, function (results, _options, elements, allElements) { + callback && callback(results, _options, elements, allElements); + }, reviver, options); + } + }, + + /** + * Takes string corresponding to an SVG document, and parses it into a set of fabric objects + * @memberOf fabric + * @param {String} string + * @param {Function} callback + * @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created. + * @param {Object} [options] Object containing options for parsing + * @param {String} [options.crossOrigin] crossOrigin crossOrigin setting to use for external resources + */ + loadSVGFromString: function(string, callback, reviver, options) { + var parser = new fabric.window.DOMParser(), + doc = parser.parseFromString(string.trim(), 'text/xml'); + fabric.parseSVGDocument(doc.documentElement, function (results, _options, elements, allElements) { + callback(results, _options, elements, allElements); + }, reviver, options); + } + }); + +})(typeof exports !== 'undefined' ? exports : this); + + +fabric.ElementsParser = function(elements, callback, options, reviver, parsingOptions, doc) { + this.elements = elements; + this.callback = callback; + this.options = options; + this.reviver = reviver; + this.svgUid = (options && options.svgUid) || 0; + this.parsingOptions = parsingOptions; + this.regexUrl = /^url\(['"]?#([^'"]+)['"]?\)/g; + this.doc = doc; +}; + +(function(proto) { + proto.parse = function() { + this.instances = new Array(this.elements.length); + this.numElements = this.elements.length; + this.createObjects(); + }; + + proto.createObjects = function() { + var _this = this; + this.elements.forEach(function(element, i) { + element.setAttribute('svgUid', _this.svgUid); + _this.createObject(element, i); + }); + }; + + proto.findTag = function(el) { + return fabric[fabric.util.string.capitalize(el.tagName.replace('svg:', ''))]; + }; + + proto.createObject = function(el, index) { + var klass = this.findTag(el); + if (klass && klass.fromElement) { + try { + klass.fromElement(el, this.createCallback(index, el), this.options); + } + catch (err) { + fabric.log(err); + } + } + else { + this.checkIfDone(); + } + }; + + proto.createCallback = function(index, el) { + var _this = this; + return function(obj) { + var _options; + _this.resolveGradient(obj, el, 'fill'); + _this.resolveGradient(obj, el, 'stroke'); + if (obj instanceof fabric.Image && obj._originalElement) { + _options = obj.parsePreserveAspectRatioAttribute(el); + } + obj._removeTransformMatrix(_options); + _this.resolveClipPath(obj, el); + _this.reviver && _this.reviver(el, obj); + _this.instances[index] = obj; + _this.checkIfDone(); + }; + }; + + proto.extractPropertyDefinition = function(obj, property, storage) { + var value = obj[property], regex = this.regexUrl; + if (!regex.test(value)) { + return; + } + regex.lastIndex = 0; + var id = regex.exec(value)[1]; + regex.lastIndex = 0; + return fabric[storage][this.svgUid][id]; + }; + + proto.resolveGradient = function(obj, el, property) { + var gradientDef = this.extractPropertyDefinition(obj, property, 'gradientDefs'); + if (gradientDef) { + var opacityAttr = el.getAttribute(property + '-opacity'); + var gradient = fabric.Gradient.fromElement(gradientDef, obj, opacityAttr, this.options); + obj.set(property, gradient); + } + }; + + proto.createClipPathCallback = function(obj, container) { + return function(_newObj) { + _newObj._removeTransformMatrix(); + _newObj.fillRule = _newObj.clipRule; + container.push(_newObj); + }; + }; + + proto.resolveClipPath = function(obj, usingElement) { + var clipPath = this.extractPropertyDefinition(obj, 'clipPath', 'clipPaths'), + element, klass, objTransformInv, container, gTransform, options; + if (clipPath) { + container = []; + objTransformInv = fabric.util.invertTransform(obj.calcTransformMatrix()); + // move the clipPath tag as sibling to the real element that is using it + var clipPathTag = clipPath[0].parentNode; + var clipPathOwner = usingElement; + while (clipPathOwner.parentNode && clipPathOwner.getAttribute('clip-path') !== obj.clipPath) { + clipPathOwner = clipPathOwner.parentNode; + } + clipPathOwner.parentNode.appendChild(clipPathTag); + for (var i = 0; i < clipPath.length; i++) { + element = clipPath[i]; + klass = this.findTag(element); + klass.fromElement( + element, + this.createClipPathCallback(obj, container), + this.options + ); + } + if (container.length === 1) { + clipPath = container[0]; + } + else { + clipPath = new fabric.Group(container); + } + gTransform = fabric.util.multiplyTransformMatrices( + objTransformInv, + clipPath.calcTransformMatrix() + ); + if (clipPath.clipPath) { + this.resolveClipPath(clipPath, clipPathOwner); + } + var options = fabric.util.qrDecompose(gTransform); + clipPath.flipX = false; + clipPath.flipY = false; + clipPath.set('scaleX', options.scaleX); + clipPath.set('scaleY', options.scaleY); + clipPath.angle = options.angle; + clipPath.skewX = options.skewX; + clipPath.skewY = 0; + clipPath.setPositionByOrigin({ x: options.translateX, y: options.translateY }, 'center', 'center'); + obj.clipPath = clipPath; + } + else { + // if clip-path does not resolve to any element, delete the property. + delete obj.clipPath; + } + }; + + proto.checkIfDone = function() { + if (--this.numElements === 0) { + this.instances = this.instances.filter(function(el) { + // eslint-disable-next-line no-eq-null, eqeqeq + return el != null; + }); + this.callback(this.instances, this.elements); + } + }; +})(fabric.ElementsParser.prototype); + + +(function(global) { + + 'use strict'; + + /* Adaptation of work of Kevin Lindsey (kevin@kevlindev.com) */ + + var fabric = global.fabric || (global.fabric = { }); + + if (fabric.Point) { + fabric.warn('fabric.Point is already defined'); + return; + } + + fabric.Point = Point; + + /** + * Point class + * @class fabric.Point + * @memberOf fabric + * @constructor + * @param {Number} x + * @param {Number} y + * @return {fabric.Point} thisArg + */ + function Point(x, y) { + this.x = x; + this.y = y; + } + + Point.prototype = /** @lends fabric.Point.prototype */ { + + type: 'point', + + constructor: Point, + + /** + * Adds another point to this one and returns another one + * @param {fabric.Point} that + * @return {fabric.Point} new Point instance with added values + */ + add: function (that) { + return new Point(this.x + that.x, this.y + that.y); + }, + + /** + * Adds another point to this one + * @param {fabric.Point} that + * @return {fabric.Point} thisArg + * @chainable + */ + addEquals: function (that) { + this.x += that.x; + this.y += that.y; + return this; + }, + + /** + * Adds value to this point and returns a new one + * @param {Number} scalar + * @return {fabric.Point} new Point with added value + */ + scalarAdd: function (scalar) { + return new Point(this.x + scalar, this.y + scalar); + }, + + /** + * Adds value to this point + * @param {Number} scalar + * @return {fabric.Point} thisArg + * @chainable + */ + scalarAddEquals: function (scalar) { + this.x += scalar; + this.y += scalar; + return this; + }, + + /** + * Subtracts another point from this point and returns a new one + * @param {fabric.Point} that + * @return {fabric.Point} new Point object with subtracted values + */ + subtract: function (that) { + return new Point(this.x - that.x, this.y - that.y); + }, + + /** + * Subtracts another point from this point + * @param {fabric.Point} that + * @return {fabric.Point} thisArg + * @chainable + */ + subtractEquals: function (that) { + this.x -= that.x; + this.y -= that.y; + return this; + }, + + /** + * Subtracts value from this point and returns a new one + * @param {Number} scalar + * @return {fabric.Point} + */ + scalarSubtract: function (scalar) { + return new Point(this.x - scalar, this.y - scalar); + }, + + /** + * Subtracts value from this point + * @param {Number} scalar + * @return {fabric.Point} thisArg + * @chainable + */ + scalarSubtractEquals: function (scalar) { + this.x -= scalar; + this.y -= scalar; + return this; + }, + + /** + * Multiplies this point by a value and returns a new one + * TODO: rename in scalarMultiply in 2.0 + * @param {Number} scalar + * @return {fabric.Point} + */ + multiply: function (scalar) { + return new Point(this.x * scalar, this.y * scalar); + }, + + /** + * Multiplies this point by a value + * TODO: rename in scalarMultiplyEquals in 2.0 + * @param {Number} scalar + * @return {fabric.Point} thisArg + * @chainable + */ + multiplyEquals: function (scalar) { + this.x *= scalar; + this.y *= scalar; + return this; + }, + + /** + * Divides this point by a value and returns a new one + * TODO: rename in scalarDivide in 2.0 + * @param {Number} scalar + * @return {fabric.Point} + */ + divide: function (scalar) { + return new Point(this.x / scalar, this.y / scalar); + }, + + /** + * Divides this point by a value + * TODO: rename in scalarDivideEquals in 2.0 + * @param {Number} scalar + * @return {fabric.Point} thisArg + * @chainable + */ + divideEquals: function (scalar) { + this.x /= scalar; + this.y /= scalar; + return this; + }, + + /** + * Returns true if this point is equal to another one + * @param {fabric.Point} that + * @return {Boolean} + */ + eq: function (that) { + return (this.x === that.x && this.y === that.y); + }, + + /** + * Returns true if this point is less than another one + * @param {fabric.Point} that + * @return {Boolean} + */ + lt: function (that) { + return (this.x < that.x && this.y < that.y); + }, + + /** + * Returns true if this point is less than or equal to another one + * @param {fabric.Point} that + * @return {Boolean} + */ + lte: function (that) { + return (this.x <= that.x && this.y <= that.y); + }, + + /** + + * Returns true if this point is greater another one + * @param {fabric.Point} that + * @return {Boolean} + */ + gt: function (that) { + return (this.x > that.x && this.y > that.y); + }, + + /** + * Returns true if this point is greater than or equal to another one + * @param {fabric.Point} that + * @return {Boolean} + */ + gte: function (that) { + return (this.x >= that.x && this.y >= that.y); + }, + + /** + * Returns new point which is the result of linear interpolation with this one and another one + * @param {fabric.Point} that + * @param {Number} t , position of interpolation, between 0 and 1 default 0.5 + * @return {fabric.Point} + */ + lerp: function (that, t) { + if (typeof t === 'undefined') { + t = 0.5; + } + t = Math.max(Math.min(1, t), 0); + return new Point(this.x + (that.x - this.x) * t, this.y + (that.y - this.y) * t); + }, + + /** + * Returns distance from this point and another one + * @param {fabric.Point} that + * @return {Number} + */ + distanceFrom: function (that) { + var dx = this.x - that.x, + dy = this.y - that.y; + return Math.sqrt(dx * dx + dy * dy); + }, + + /** + * Returns the point between this point and another one + * @param {fabric.Point} that + * @return {fabric.Point} + */ + midPointFrom: function (that) { + return this.lerp(that); + }, + + /** + * Returns a new point which is the min of this and another one + * @param {fabric.Point} that + * @return {fabric.Point} + */ + min: function (that) { + return new Point(Math.min(this.x, that.x), Math.min(this.y, that.y)); + }, + + /** + * Returns a new point which is the max of this and another one + * @param {fabric.Point} that + * @return {fabric.Point} + */ + max: function (that) { + return new Point(Math.max(this.x, that.x), Math.max(this.y, that.y)); + }, + + /** + * Returns string representation of this point + * @return {String} + */ + toString: function () { + return this.x + ',' + this.y; + }, + + /** + * Sets x/y of this point + * @param {Number} x + * @param {Number} y + * @chainable + */ + setXY: function (x, y) { + this.x = x; + this.y = y; + return this; + }, + + /** + * Sets x of this point + * @param {Number} x + * @chainable + */ + setX: function (x) { + this.x = x; + return this; + }, + + /** + * Sets y of this point + * @param {Number} y + * @chainable + */ + setY: function (y) { + this.y = y; + return this; + }, + + /** + * Sets x/y of this point from another point + * @param {fabric.Point} that + * @chainable + */ + setFromPoint: function (that) { + this.x = that.x; + this.y = that.y; + return this; + }, + + /** + * Swaps x/y of this point and another point + * @param {fabric.Point} that + */ + swap: function (that) { + var x = this.x, + y = this.y; + this.x = that.x; + this.y = that.y; + that.x = x; + that.y = y; + }, + + /** + * return a cloned instance of the point + * @return {fabric.Point} + */ + clone: function () { + return new Point(this.x, this.y); + } + }; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + /* Adaptation of work of Kevin Lindsey (kevin@kevlindev.com) */ + var fabric = global.fabric || (global.fabric = { }); + + if (fabric.Intersection) { + fabric.warn('fabric.Intersection is already defined'); + return; + } + + /** + * Intersection class + * @class fabric.Intersection + * @memberOf fabric + * @constructor + */ + function Intersection(status) { + this.status = status; + this.points = []; + } + + fabric.Intersection = Intersection; + + fabric.Intersection.prototype = /** @lends fabric.Intersection.prototype */ { + + constructor: Intersection, + + /** + * Appends a point to intersection + * @param {fabric.Point} point + * @return {fabric.Intersection} thisArg + * @chainable + */ + appendPoint: function (point) { + this.points.push(point); + return this; + }, + + /** + * Appends points to intersection + * @param {Array} points + * @return {fabric.Intersection} thisArg + * @chainable + */ + appendPoints: function (points) { + this.points = this.points.concat(points); + return this; + } + }; + + /** + * Checks if one line intersects another + * TODO: rename in intersectSegmentSegment + * @static + * @param {fabric.Point} a1 + * @param {fabric.Point} a2 + * @param {fabric.Point} b1 + * @param {fabric.Point} b2 + * @return {fabric.Intersection} + */ + fabric.Intersection.intersectLineLine = function (a1, a2, b1, b2) { + var result, + uaT = (b2.x - b1.x) * (a1.y - b1.y) - (b2.y - b1.y) * (a1.x - b1.x), + ubT = (a2.x - a1.x) * (a1.y - b1.y) - (a2.y - a1.y) * (a1.x - b1.x), + uB = (b2.y - b1.y) * (a2.x - a1.x) - (b2.x - b1.x) * (a2.y - a1.y); + if (uB !== 0) { + var ua = uaT / uB, + ub = ubT / uB; + if (0 <= ua && ua <= 1 && 0 <= ub && ub <= 1) { + result = new Intersection('Intersection'); + result.appendPoint(new fabric.Point(a1.x + ua * (a2.x - a1.x), a1.y + ua * (a2.y - a1.y))); + } + else { + result = new Intersection(); + } + } + else { + if (uaT === 0 || ubT === 0) { + result = new Intersection('Coincident'); + } + else { + result = new Intersection('Parallel'); + } + } + return result; + }; + + /** + * Checks if line intersects polygon + * TODO: rename in intersectSegmentPolygon + * fix detection of coincident + * @static + * @param {fabric.Point} a1 + * @param {fabric.Point} a2 + * @param {Array} points + * @return {fabric.Intersection} + */ + fabric.Intersection.intersectLinePolygon = function(a1, a2, points) { + var result = new Intersection(), + length = points.length, + b1, b2, inter, i; + + for (i = 0; i < length; i++) { + b1 = points[i]; + b2 = points[(i + 1) % length]; + inter = Intersection.intersectLineLine(a1, a2, b1, b2); + + result.appendPoints(inter.points); + } + if (result.points.length > 0) { + result.status = 'Intersection'; + } + return result; + }; + + /** + * Checks if polygon intersects another polygon + * @static + * @param {Array} points1 + * @param {Array} points2 + * @return {fabric.Intersection} + */ + fabric.Intersection.intersectPolygonPolygon = function (points1, points2) { + var result = new Intersection(), + length = points1.length, i; + + for (i = 0; i < length; i++) { + var a1 = points1[i], + a2 = points1[(i + 1) % length], + inter = Intersection.intersectLinePolygon(a1, a2, points2); + + result.appendPoints(inter.points); + } + if (result.points.length > 0) { + result.status = 'Intersection'; + } + return result; + }; + + /** + * Checks if polygon intersects rectangle + * @static + * @param {Array} points + * @param {fabric.Point} r1 + * @param {fabric.Point} r2 + * @return {fabric.Intersection} + */ + fabric.Intersection.intersectPolygonRectangle = function (points, r1, r2) { + var min = r1.min(r2), + max = r1.max(r2), + topRight = new fabric.Point(max.x, min.y), + bottomLeft = new fabric.Point(min.x, max.y), + inter1 = Intersection.intersectLinePolygon(min, topRight, points), + inter2 = Intersection.intersectLinePolygon(topRight, max, points), + inter3 = Intersection.intersectLinePolygon(max, bottomLeft, points), + inter4 = Intersection.intersectLinePolygon(bottomLeft, min, points), + result = new Intersection(); + + result.appendPoints(inter1.points); + result.appendPoints(inter2.points); + result.appendPoints(inter3.points); + result.appendPoints(inter4.points); + + if (result.points.length > 0) { + result.status = 'Intersection'; + } + return result; + }; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }); + + if (fabric.Color) { + fabric.warn('fabric.Color is already defined.'); + return; + } + + /** + * Color class + * The purpose of {@link fabric.Color} is to abstract and encapsulate common color operations; + * {@link fabric.Color} is a constructor and creates instances of {@link fabric.Color} objects. + * + * @class fabric.Color + * @param {String} color optional in hex or rgb(a) or hsl format or from known color list + * @return {fabric.Color} thisArg + * @tutorial {@link http://fabricjs.com/fabric-intro-part-2/#colors} + */ + function Color(color) { + if (!color) { + this.setSource([0, 0, 0, 1]); + } + else { + this._tryParsingColor(color); + } + } + + fabric.Color = Color; + + fabric.Color.prototype = /** @lends fabric.Color.prototype */ { + + /** + * @private + * @param {String|Array} color Color value to parse + */ + _tryParsingColor: function(color) { + var source; + + if (color in Color.colorNameMap) { + color = Color.colorNameMap[color]; + } + + if (color === 'transparent') { + source = [255, 255, 255, 0]; + } + + if (!source) { + source = Color.sourceFromHex(color); + } + if (!source) { + source = Color.sourceFromRgb(color); + } + if (!source) { + source = Color.sourceFromHsl(color); + } + if (!source) { + //if color is not recognize let's make black as canvas does + source = [0, 0, 0, 1]; + } + if (source) { + this.setSource(source); + } + }, + + /** + * Adapted from https://github.com/mjijackson + * @private + * @param {Number} r Red color value + * @param {Number} g Green color value + * @param {Number} b Blue color value + * @return {Array} Hsl color + */ + _rgbToHsl: function(r, g, b) { + r /= 255; g /= 255; b /= 255; + + var h, s, l, + max = fabric.util.array.max([r, g, b]), + min = fabric.util.array.min([r, g, b]); + + l = (max + min) / 2; + + if (max === min) { + h = s = 0; // achromatic + } + else { + var d = max - min; + s = l > 0.5 ? d / (2 - max - min) : d / (max + min); + switch (max) { + case r: + h = (g - b) / d + (g < b ? 6 : 0); + break; + case g: + h = (b - r) / d + 2; + break; + case b: + h = (r - g) / d + 4; + break; + } + h /= 6; + } + + return [ + Math.round(h * 360), + Math.round(s * 100), + Math.round(l * 100) + ]; + }, + + /** + * Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1]) + * @return {Array} + */ + getSource: function() { + return this._source; + }, + + /** + * Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1]) + * @param {Array} source + */ + setSource: function(source) { + this._source = source; + }, + + /** + * Returns color representation in RGB format + * @return {String} ex: rgb(0-255,0-255,0-255) + */ + toRgb: function() { + var source = this.getSource(); + return 'rgb(' + source[0] + ',' + source[1] + ',' + source[2] + ')'; + }, + + /** + * Returns color representation in RGBA format + * @return {String} ex: rgba(0-255,0-255,0-255,0-1) + */ + toRgba: function() { + var source = this.getSource(); + return 'rgba(' + source[0] + ',' + source[1] + ',' + source[2] + ',' + source[3] + ')'; + }, + + /** + * Returns color representation in HSL format + * @return {String} ex: hsl(0-360,0%-100%,0%-100%) + */ + toHsl: function() { + var source = this.getSource(), + hsl = this._rgbToHsl(source[0], source[1], source[2]); + + return 'hsl(' + hsl[0] + ',' + hsl[1] + '%,' + hsl[2] + '%)'; + }, + + /** + * Returns color representation in HSLA format + * @return {String} ex: hsla(0-360,0%-100%,0%-100%,0-1) + */ + toHsla: function() { + var source = this.getSource(), + hsl = this._rgbToHsl(source[0], source[1], source[2]); + + return 'hsla(' + hsl[0] + ',' + hsl[1] + '%,' + hsl[2] + '%,' + source[3] + ')'; + }, + + /** + * Returns color representation in HEX format + * @return {String} ex: FF5555 + */ + toHex: function() { + var source = this.getSource(), r, g, b; + + r = source[0].toString(16); + r = (r.length === 1) ? ('0' + r) : r; + + g = source[1].toString(16); + g = (g.length === 1) ? ('0' + g) : g; + + b = source[2].toString(16); + b = (b.length === 1) ? ('0' + b) : b; + + return r.toUpperCase() + g.toUpperCase() + b.toUpperCase(); + }, + + /** + * Returns color representation in HEXA format + * @return {String} ex: FF5555CC + */ + toHexa: function() { + var source = this.getSource(), a; + + a = Math.round(source[3] * 255); + a = a.toString(16); + a = (a.length === 1) ? ('0' + a) : a; + + return this.toHex() + a.toUpperCase(); + }, + + /** + * Gets value of alpha channel for this color + * @return {Number} 0-1 + */ + getAlpha: function() { + return this.getSource()[3]; + }, + + /** + * Sets value of alpha channel for this color + * @param {Number} alpha Alpha value 0-1 + * @return {fabric.Color} thisArg + */ + setAlpha: function(alpha) { + var source = this.getSource(); + source[3] = alpha; + this.setSource(source); + return this; + }, + + /** + * Transforms color to its grayscale representation + * @return {fabric.Color} thisArg + */ + toGrayscale: function() { + var source = this.getSource(), + average = parseInt((source[0] * 0.3 + source[1] * 0.59 + source[2] * 0.11).toFixed(0), 10), + currentAlpha = source[3]; + this.setSource([average, average, average, currentAlpha]); + return this; + }, + + /** + * Transforms color to its black and white representation + * @param {Number} threshold + * @return {fabric.Color} thisArg + */ + toBlackWhite: function(threshold) { + var source = this.getSource(), + average = (source[0] * 0.3 + source[1] * 0.59 + source[2] * 0.11).toFixed(0), + currentAlpha = source[3]; + + threshold = threshold || 127; + + average = (Number(average) < Number(threshold)) ? 0 : 255; + this.setSource([average, average, average, currentAlpha]); + return this; + }, + + /** + * Overlays color with another color + * @param {String|fabric.Color} otherColor + * @return {fabric.Color} thisArg + */ + overlayWith: function(otherColor) { + if (!(otherColor instanceof Color)) { + otherColor = new Color(otherColor); + } + + var result = [], + alpha = this.getAlpha(), + otherAlpha = 0.5, + source = this.getSource(), + otherSource = otherColor.getSource(), i; + + for (i = 0; i < 3; i++) { + result.push(Math.round((source[i] * (1 - otherAlpha)) + (otherSource[i] * otherAlpha))); + } + + result[3] = alpha; + this.setSource(result); + return this; + } + }; + + /** + * Regex matching color in RGB or RGBA formats (ex: rgb(0, 0, 0), rgba(255, 100, 10, 0.5), rgba( 255 , 100 , 10 , 0.5 ), rgb(1,1,1), rgba(100%, 60%, 10%, 0.5)) + * @static + * @field + * @memberOf fabric.Color + */ + // eslint-disable-next-line max-len + fabric.Color.reRGBa = /^rgba?\(\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*(?:\s*,\s*((?:\d*\.?\d+)?)\s*)?\)$/i; + + /** + * Regex matching color in HSL or HSLA formats (ex: hsl(200, 80%, 10%), hsla(300, 50%, 80%, 0.5), hsla( 300 , 50% , 80% , 0.5 )) + * @static + * @field + * @memberOf fabric.Color + */ + fabric.Color.reHSLa = /^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3}\%)\s*,\s*(\d{1,3}\%)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/i; + + /** + * Regex matching color in HEX format (ex: #FF5544CC, #FF5555, 010155, aff) + * @static + * @field + * @memberOf fabric.Color + */ + fabric.Color.reHex = /^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i; + + /** + * Map of the 148 color names with HEX code + * @static + * @field + * @memberOf fabric.Color + * @see: https://www.w3.org/TR/css3-color/#svg-color + */ + fabric.Color.colorNameMap = { + aliceblue: '#F0F8FF', + antiquewhite: '#FAEBD7', + aqua: '#00FFFF', + aquamarine: '#7FFFD4', + azure: '#F0FFFF', + beige: '#F5F5DC', + bisque: '#FFE4C4', + black: '#000000', + blanchedalmond: '#FFEBCD', + blue: '#0000FF', + blueviolet: '#8A2BE2', + brown: '#A52A2A', + burlywood: '#DEB887', + cadetblue: '#5F9EA0', + chartreuse: '#7FFF00', + chocolate: '#D2691E', + coral: '#FF7F50', + cornflowerblue: '#6495ED', + cornsilk: '#FFF8DC', + crimson: '#DC143C', + cyan: '#00FFFF', + darkblue: '#00008B', + darkcyan: '#008B8B', + darkgoldenrod: '#B8860B', + darkgray: '#A9A9A9', + darkgrey: '#A9A9A9', + darkgreen: '#006400', + darkkhaki: '#BDB76B', + darkmagenta: '#8B008B', + darkolivegreen: '#556B2F', + darkorange: '#FF8C00', + darkorchid: '#9932CC', + darkred: '#8B0000', + darksalmon: '#E9967A', + darkseagreen: '#8FBC8F', + darkslateblue: '#483D8B', + darkslategray: '#2F4F4F', + darkslategrey: '#2F4F4F', + darkturquoise: '#00CED1', + darkviolet: '#9400D3', + deeppink: '#FF1493', + deepskyblue: '#00BFFF', + dimgray: '#696969', + dimgrey: '#696969', + dodgerblue: '#1E90FF', + firebrick: '#B22222', + floralwhite: '#FFFAF0', + forestgreen: '#228B22', + fuchsia: '#FF00FF', + gainsboro: '#DCDCDC', + ghostwhite: '#F8F8FF', + gold: '#FFD700', + goldenrod: '#DAA520', + gray: '#808080', + grey: '#808080', + green: '#008000', + greenyellow: '#ADFF2F', + honeydew: '#F0FFF0', + hotpink: '#FF69B4', + indianred: '#CD5C5C', + indigo: '#4B0082', + ivory: '#FFFFF0', + khaki: '#F0E68C', + lavender: '#E6E6FA', + lavenderblush: '#FFF0F5', + lawngreen: '#7CFC00', + lemonchiffon: '#FFFACD', + lightblue: '#ADD8E6', + lightcoral: '#F08080', + lightcyan: '#E0FFFF', + lightgoldenrodyellow: '#FAFAD2', + lightgray: '#D3D3D3', + lightgrey: '#D3D3D3', + lightgreen: '#90EE90', + lightpink: '#FFB6C1', + lightsalmon: '#FFA07A', + lightseagreen: '#20B2AA', + lightskyblue: '#87CEFA', + lightslategray: '#778899', + lightslategrey: '#778899', + lightsteelblue: '#B0C4DE', + lightyellow: '#FFFFE0', + lime: '#00FF00', + limegreen: '#32CD32', + linen: '#FAF0E6', + magenta: '#FF00FF', + maroon: '#800000', + mediumaquamarine: '#66CDAA', + mediumblue: '#0000CD', + mediumorchid: '#BA55D3', + mediumpurple: '#9370DB', + mediumseagreen: '#3CB371', + mediumslateblue: '#7B68EE', + mediumspringgreen: '#00FA9A', + mediumturquoise: '#48D1CC', + mediumvioletred: '#C71585', + midnightblue: '#191970', + mintcream: '#F5FFFA', + mistyrose: '#FFE4E1', + moccasin: '#FFE4B5', + navajowhite: '#FFDEAD', + navy: '#000080', + oldlace: '#FDF5E6', + olive: '#808000', + olivedrab: '#6B8E23', + orange: '#FFA500', + orangered: '#FF4500', + orchid: '#DA70D6', + palegoldenrod: '#EEE8AA', + palegreen: '#98FB98', + paleturquoise: '#AFEEEE', + palevioletred: '#DB7093', + papayawhip: '#FFEFD5', + peachpuff: '#FFDAB9', + peru: '#CD853F', + pink: '#FFC0CB', + plum: '#DDA0DD', + powderblue: '#B0E0E6', + purple: '#800080', + rebeccapurple: '#663399', + red: '#FF0000', + rosybrown: '#BC8F8F', + royalblue: '#4169E1', + saddlebrown: '#8B4513', + salmon: '#FA8072', + sandybrown: '#F4A460', + seagreen: '#2E8B57', + seashell: '#FFF5EE', + sienna: '#A0522D', + silver: '#C0C0C0', + skyblue: '#87CEEB', + slateblue: '#6A5ACD', + slategray: '#708090', + slategrey: '#708090', + snow: '#FFFAFA', + springgreen: '#00FF7F', + steelblue: '#4682B4', + tan: '#D2B48C', + teal: '#008080', + thistle: '#D8BFD8', + tomato: '#FF6347', + turquoise: '#40E0D0', + violet: '#EE82EE', + wheat: '#F5DEB3', + white: '#FFFFFF', + whitesmoke: '#F5F5F5', + yellow: '#FFFF00', + yellowgreen: '#9ACD32' + }; + + /** + * @private + * @param {Number} p + * @param {Number} q + * @param {Number} t + * @return {Number} + */ + function hue2rgb(p, q, t) { + if (t < 0) { + t += 1; + } + if (t > 1) { + t -= 1; + } + if (t < 1 / 6) { + return p + (q - p) * 6 * t; + } + if (t < 1 / 2) { + return q; + } + if (t < 2 / 3) { + return p + (q - p) * (2 / 3 - t) * 6; + } + return p; + } + + /** + * Returns new color object, when given a color in RGB format + * @memberOf fabric.Color + * @param {String} color Color value ex: rgb(0-255,0-255,0-255) + * @return {fabric.Color} + */ + fabric.Color.fromRgb = function(color) { + return Color.fromSource(Color.sourceFromRgb(color)); + }; + + /** + * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format + * @memberOf fabric.Color + * @param {String} color Color value ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%) + * @return {Array} source + */ + fabric.Color.sourceFromRgb = function(color) { + var match = color.match(Color.reRGBa); + if (match) { + var r = parseInt(match[1], 10) / (/%$/.test(match[1]) ? 100 : 1) * (/%$/.test(match[1]) ? 255 : 1), + g = parseInt(match[2], 10) / (/%$/.test(match[2]) ? 100 : 1) * (/%$/.test(match[2]) ? 255 : 1), + b = parseInt(match[3], 10) / (/%$/.test(match[3]) ? 100 : 1) * (/%$/.test(match[3]) ? 255 : 1); + + return [ + parseInt(r, 10), + parseInt(g, 10), + parseInt(b, 10), + match[4] ? parseFloat(match[4]) : 1 + ]; + } + }; + + /** + * Returns new color object, when given a color in RGBA format + * @static + * @function + * @memberOf fabric.Color + * @param {String} color + * @return {fabric.Color} + */ + fabric.Color.fromRgba = Color.fromRgb; + + /** + * Returns new color object, when given a color in HSL format + * @param {String} color Color value ex: hsl(0-260,0%-100%,0%-100%) + * @memberOf fabric.Color + * @return {fabric.Color} + */ + fabric.Color.fromHsl = function(color) { + return Color.fromSource(Color.sourceFromHsl(color)); + }; + + /** + * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HSL or HSLA format. + * Adapted from https://github.com/mjijackson + * @memberOf fabric.Color + * @param {String} color Color value ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1) + * @return {Array} source + * @see http://http://www.w3.org/TR/css3-color/#hsl-color + */ + fabric.Color.sourceFromHsl = function(color) { + var match = color.match(Color.reHSLa); + if (!match) { + return; + } + + var h = (((parseFloat(match[1]) % 360) + 360) % 360) / 360, + s = parseFloat(match[2]) / (/%$/.test(match[2]) ? 100 : 1), + l = parseFloat(match[3]) / (/%$/.test(match[3]) ? 100 : 1), + r, g, b; + + if (s === 0) { + r = g = b = l; + } + else { + var q = l <= 0.5 ? l * (s + 1) : l + s - l * s, + p = l * 2 - q; + + r = hue2rgb(p, q, h + 1 / 3); + g = hue2rgb(p, q, h); + b = hue2rgb(p, q, h - 1 / 3); + } + + return [ + Math.round(r * 255), + Math.round(g * 255), + Math.round(b * 255), + match[4] ? parseFloat(match[4]) : 1 + ]; + }; + + /** + * Returns new color object, when given a color in HSLA format + * @static + * @function + * @memberOf fabric.Color + * @param {String} color + * @return {fabric.Color} + */ + fabric.Color.fromHsla = Color.fromHsl; + + /** + * Returns new color object, when given a color in HEX format + * @static + * @memberOf fabric.Color + * @param {String} color Color value ex: FF5555 + * @return {fabric.Color} + */ + fabric.Color.fromHex = function(color) { + return Color.fromSource(Color.sourceFromHex(color)); + }; + + /** + * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HEX format + * @static + * @memberOf fabric.Color + * @param {String} color ex: FF5555 or FF5544CC (RGBa) + * @return {Array} source + */ + fabric.Color.sourceFromHex = function(color) { + if (color.match(Color.reHex)) { + var value = color.slice(color.indexOf('#') + 1), + isShortNotation = (value.length === 3 || value.length === 4), + isRGBa = (value.length === 8 || value.length === 4), + r = isShortNotation ? (value.charAt(0) + value.charAt(0)) : value.substring(0, 2), + g = isShortNotation ? (value.charAt(1) + value.charAt(1)) : value.substring(2, 4), + b = isShortNotation ? (value.charAt(2) + value.charAt(2)) : value.substring(4, 6), + a = isRGBa ? (isShortNotation ? (value.charAt(3) + value.charAt(3)) : value.substring(6, 8)) : 'FF'; + + return [ + parseInt(r, 16), + parseInt(g, 16), + parseInt(b, 16), + parseFloat((parseInt(a, 16) / 255).toFixed(2)) + ]; + } + }; + + /** + * Returns new color object, when given color in array representation (ex: [200, 100, 100, 0.5]) + * @static + * @memberOf fabric.Color + * @param {Array} source + * @return {fabric.Color} + */ + fabric.Color.fromSource = function(source) { + var oColor = new Color(); + oColor.setSource(source); + return oColor; + }; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + scaleMap = ['e', 'se', 's', 'sw', 'w', 'nw', 'n', 'ne', 'e'], + skewMap = ['ns', 'nesw', 'ew', 'nwse'], + controls = {}, + LEFT = 'left', TOP = 'top', RIGHT = 'right', BOTTOM = 'bottom', CENTER = 'center', + opposite = { + top: BOTTOM, + bottom: TOP, + left: RIGHT, + right: LEFT, + center: CENTER, + }, radiansToDegrees = fabric.util.radiansToDegrees, + sign = (Math.sign || function(x) { return ((x > 0) - (x < 0)) || +x; }); + + /** + * Combine control position and object angle to find the control direction compared + * to the object center. + * @param {fabric.Object} fabricObject the fabric object for which we are rendering controls + * @param {fabric.Control} control the control class + * @return {Number} 0 - 7 a quadrant number + */ + function findCornerQuadrant(fabricObject, control) { + var cornerAngle = fabricObject.angle + radiansToDegrees(Math.atan2(control.y, control.x)) + 360; + return Math.round((cornerAngle % 360) / 45); + } + + function fireEvent(eventName, options) { + var target = options.transform.target, + canvas = target.canvas, + canvasOptions = fabric.util.object.clone(options); + canvasOptions.target = target; + canvas && canvas.fire('object:' + eventName, canvasOptions); + target.fire(eventName, options); + } + + /** + * Inspect event and fabricObject properties to understand if the scaling action + * @param {Event} eventData from the user action + * @param {fabric.Object} fabricObject the fabric object about to scale + * @return {Boolean} true if scale is proportional + */ + function scaleIsProportional(eventData, fabricObject) { + var canvas = fabricObject.canvas, uniScaleKey = canvas.uniScaleKey, + uniformIsToggled = eventData[uniScaleKey]; + return (canvas.uniformScaling && !uniformIsToggled) || + (!canvas.uniformScaling && uniformIsToggled); + } + + /** + * Checks if transform is centered + * @param {Object} transform transform data + * @return {Boolean} true if transform is centered + */ + function isTransformCentered(transform) { + return transform.originX === CENTER && transform.originY === CENTER; + } + + /** + * Inspect fabricObject to understand if the current scaling action is allowed + * @param {fabric.Object} fabricObject the fabric object about to scale + * @param {String} by 'x' or 'y' or '' + * @param {Boolean} scaleProportionally true if we are trying to scale proportionally + * @return {Boolean} true if scaling is not allowed at current conditions + */ + function scalingIsForbidden(fabricObject, by, scaleProportionally) { + var lockX = fabricObject.lockScalingX, lockY = fabricObject.lockScalingY; + if (lockX && lockY) { + return true; + } + if (!by && (lockX || lockY) && scaleProportionally) { + return true; + } + if (lockX && by === 'x') { + return true; + } + if (lockY && by === 'y') { + return true; + } + return false; + } + + /** + * return the correct cursor style for the scale action + * @param {Event} eventData the javascript event that is causing the scale + * @param {fabric.Control} control the control that is interested in the action + * @param {fabric.Object} fabricObject the fabric object that is interested in the action + * @return {String} a valid css string for the cursor + */ + function scaleCursorStyleHandler(eventData, control, fabricObject) { + var notAllowed = 'not-allowed', + scaleProportionally = scaleIsProportional(eventData, fabricObject), + by = ''; + if (control.x !== 0 && control.y === 0) { + by = 'x'; + } + else if (control.x === 0 && control.y !== 0) { + by = 'y'; + } + if (scalingIsForbidden(fabricObject, by, scaleProportionally)) { + return notAllowed; + } + var n = findCornerQuadrant(fabricObject, control); + return scaleMap[n] + '-resize'; + } + + /** + * return the correct cursor style for the skew action + * @param {Event} eventData the javascript event that is causing the scale + * @param {fabric.Control} control the control that is interested in the action + * @param {fabric.Object} fabricObject the fabric object that is interested in the action + * @return {String} a valid css string for the cursor + */ + function skewCursorStyleHandler(eventData, control, fabricObject) { + var notAllowed = 'not-allowed'; + if (control.x !== 0 && fabricObject.lockSkewingY) { + return notAllowed; + } + if (control.y !== 0 && fabricObject.lockSkewingX) { + return notAllowed; + } + var n = findCornerQuadrant(fabricObject, control) % 4; + return skewMap[n] + '-resize'; + } + + /** + * Combine skew and scale style handlers to cover fabric standard use case + * @param {Event} eventData the javascript event that is causing the scale + * @param {fabric.Control} control the control that is interested in the action + * @param {fabric.Object} fabricObject the fabric object that is interested in the action + * @return {String} a valid css string for the cursor + */ + function scaleSkewCursorStyleHandler(eventData, control, fabricObject) { + if (eventData[fabricObject.canvas.altActionKey]) { + return controls.skewCursorStyleHandler(eventData, control, fabricObject); + } + return controls.scaleCursorStyleHandler(eventData, control, fabricObject); + } + + /** + * Inspect event, control and fabricObject to return the correct action name + * @param {Event} eventData the javascript event that is causing the scale + * @param {fabric.Control} control the control that is interested in the action + * @param {fabric.Object} fabricObject the fabric object that is interested in the action + * @return {String} an action name + */ + function scaleOrSkewActionName(eventData, control, fabricObject) { + var isAlternative = eventData[fabricObject.canvas.altActionKey]; + if (control.x === 0) { + // then is scaleY or skewX + return isAlternative ? 'skewX' : 'scaleY'; + } + if (control.y === 0) { + // then is scaleY or skewX + return isAlternative ? 'skewY' : 'scaleX'; + } + } + + /** + * Find the correct style for the control that is used for rotation. + * this function is very simple and it just take care of not-allowed or standard cursor + * @param {Event} eventData the javascript event that is causing the scale + * @param {fabric.Control} control the control that is interested in the action + * @param {fabric.Object} fabricObject the fabric object that is interested in the action + * @return {String} a valid css string for the cursor + */ + function rotationStyleHandler(eventData, control, fabricObject) { + if (fabricObject.lockRotation) { + return 'not-allowed'; + } + return control.cursorStyle; + } + + function commonEventInfo(eventData, transform, x, y) { + return { + e: eventData, + transform: transform, + pointer: { + x: x, + y: y, + } + }; + } + + /** + * Wrap an action handler with saving/restoring object position on the transform. + * this is the code that permits to objects to keep their position while transforming. + * @param {Function} actionHandler the function to wrap + * @return {Function} a function with an action handler signature + */ + function wrapWithFixedAnchor(actionHandler) { + return function(eventData, transform, x, y) { + var target = transform.target, centerPoint = target.getCenterPoint(), + constraint = target.translateToOriginPoint(centerPoint, transform.originX, transform.originY), + actionPerformed = actionHandler(eventData, transform, x, y); + target.setPositionByOrigin(constraint, transform.originX, transform.originY); + return actionPerformed; + }; + } + + /** + * Wrap an action handler with firing an event if the action is performed + * @param {Function} actionHandler the function to wrap + * @return {Function} a function with an action handler signature + */ + function wrapWithFireEvent(eventName, actionHandler) { + return function(eventData, transform, x, y) { + var actionPerformed = actionHandler(eventData, transform, x, y); + if (actionPerformed) { + fireEvent(eventName, commonEventInfo(eventData, transform, x, y)); + } + return actionPerformed; + }; + } + + /** + * Transforms a point described by x and y in a distance from the top left corner of the object + * bounding box. + * @param {Object} transform + * @param {String} originX + * @param {String} originY + * @param {number} x + * @param {number} y + * @return {Fabric.Point} the normalized point + */ + function getLocalPoint(transform, originX, originY, x, y) { + var target = transform.target, + control = target.controls[transform.corner], + zoom = target.canvas.getZoom(), + padding = target.padding / zoom, + localPoint = target.toLocalPoint(new fabric.Point(x, y), originX, originY); + if (localPoint.x >= padding) { + localPoint.x -= padding; + } + if (localPoint.x <= -padding) { + localPoint.x += padding; + } + if (localPoint.y >= padding) { + localPoint.y -= padding; + } + if (localPoint.y <= padding) { + localPoint.y += padding; + } + localPoint.x -= control.offsetX; + localPoint.y -= control.offsetY; + return localPoint; + } + + /** + * Detect if the fabric object is flipped on one side. + * @param {fabric.Object} target + * @return {Boolean} true if one flip, but not two. + */ + function targetHasOneFlip(target) { + return target.flipX !== target.flipY; + } + + /** + * Utility function to compensate the scale factor when skew is applied on both axes + * @private + */ + function compensateScaleForSkew(target, oppositeSkew, scaleToCompensate, axis, reference) { + if (target[oppositeSkew] !== 0) { + var newDim = target._getTransformedDimensions()[axis]; + var newValue = reference / newDim * target[scaleToCompensate]; + target.set(scaleToCompensate, newValue); + } + } + + /** + * Action handler for skewing on the X axis + * @private + */ + function skewObjectX(eventData, transform, x, y) { + var target = transform.target, + // find how big the object would be, if there was no skewX. takes in account scaling + dimNoSkew = target._getTransformedDimensions(0, target.skewY), + localPoint = getLocalPoint(transform, transform.originX, transform.originY, x, y), + // the mouse is in the center of the object, and we want it to stay there. + // so the object will grow twice as much as the mouse. + // this makes the skew growth to localPoint * 2 - dimNoSkew. + totalSkewSize = Math.abs(localPoint.x * 2) - dimNoSkew.x, + currentSkew = target.skewX, newSkew; + if (totalSkewSize < 2) { + // let's make it easy to go back to position 0. + newSkew = 0; + } + else { + newSkew = radiansToDegrees( + Math.atan2((totalSkewSize / target.scaleX), (dimNoSkew.y / target.scaleY)) + ); + // now we have to find the sign of the skew. + // it mostly depend on the origin of transformation. + if (transform.originX === LEFT && transform.originY === BOTTOM) { + newSkew = -newSkew; + } + if (transform.originX === RIGHT && transform.originY === TOP) { + newSkew = -newSkew; + } + if (targetHasOneFlip(target)) { + newSkew = -newSkew; + } + } + var hasSkewed = currentSkew !== newSkew; + if (hasSkewed) { + var dimBeforeSkewing = target._getTransformedDimensions().y; + target.set('skewX', newSkew); + compensateScaleForSkew(target, 'skewY', 'scaleY', 'y', dimBeforeSkewing); + } + return hasSkewed; + } + + /** + * Action handler for skewing on the Y axis + * @private + */ + function skewObjectY(eventData, transform, x, y) { + var target = transform.target, + // find how big the object would be, if there was no skewX. takes in account scaling + dimNoSkew = target._getTransformedDimensions(target.skewX, 0), + localPoint = getLocalPoint(transform, transform.originX, transform.originY, x, y), + // the mouse is in the center of the object, and we want it to stay there. + // so the object will grow twice as much as the mouse. + // this makes the skew growth to localPoint * 2 - dimNoSkew. + totalSkewSize = Math.abs(localPoint.y * 2) - dimNoSkew.y, + currentSkew = target.skewY, newSkew; + if (totalSkewSize < 2) { + // let's make it easy to go back to position 0. + newSkew = 0; + } + else { + newSkew = radiansToDegrees( + Math.atan2((totalSkewSize / target.scaleY), (dimNoSkew.x / target.scaleX)) + ); + // now we have to find the sign of the skew. + // it mostly depend on the origin of transformation. + if (transform.originX === LEFT && transform.originY === BOTTOM) { + newSkew = -newSkew; + } + if (transform.originX === RIGHT && transform.originY === TOP) { + newSkew = -newSkew; + } + if (targetHasOneFlip(target)) { + newSkew = -newSkew; + } + } + var hasSkewed = currentSkew !== newSkew; + if (hasSkewed) { + var dimBeforeSkewing = target._getTransformedDimensions().x; + target.set('skewY', newSkew); + compensateScaleForSkew(target, 'skewX', 'scaleX', 'x', dimBeforeSkewing); + } + return hasSkewed; + } + + /** + * Wrapped Action handler for skewing on the Y axis, takes care of the + * skew direction and determine the correct transform origin for the anchor point + * @param {Event} eventData javascript event that is doing the transform + * @param {Object} transform javascript object containing a series of information around the current transform + * @param {number} x current mouse x position, canvas normalized + * @param {number} y current mouse y position, canvas normalized + * @return {Boolean} true if some change happened + */ + function skewHandlerX(eventData, transform, x, y) { + // step1 figure out and change transform origin. + // if skewX > 0 and originY bottom we anchor on right + // if skewX > 0 and originY top we anchor on left + // if skewX < 0 and originY bottom we anchor on left + // if skewX < 0 and originY top we anchor on right + // if skewX is 0, we look for mouse position to understand where are we going. + var target = transform.target, currentSkew = target.skewX, originX, originY = transform.originY; + if (target.lockSkewingX) { + return false; + } + if (currentSkew === 0) { + var localPointFromCenter = getLocalPoint(transform, CENTER, CENTER, x, y); + if (localPointFromCenter.x > 0) { + // we are pulling right, anchor left; + originX = LEFT; + } + else { + // we are pulling right, anchor right + originX = RIGHT; + } + } + else { + if (currentSkew > 0) { + originX = originY === TOP ? LEFT : RIGHT; + } + if (currentSkew < 0) { + originX = originY === TOP ? RIGHT : LEFT; + } + // is the object flipped on one side only? swap the origin. + if (targetHasOneFlip(target)) { + originX = originX === LEFT ? RIGHT : LEFT; + } + } + + // once we have the origin, we find the anchor point + transform.originX = originX; + var finalHandler = wrapWithFireEvent('skewing', wrapWithFixedAnchor(skewObjectX)); + return finalHandler(eventData, transform, x, y); + } + + /** + * Wrapped Action handler for skewing on the Y axis, takes care of the + * skew direction and determine the correct transform origin for the anchor point + * @param {Event} eventData javascript event that is doing the transform + * @param {Object} transform javascript object containing a series of information around the current transform + * @param {number} x current mouse x position, canvas normalized + * @param {number} y current mouse y position, canvas normalized + * @return {Boolean} true if some change happened + */ + function skewHandlerY(eventData, transform, x, y) { + // step1 figure out and change transform origin. + // if skewY > 0 and originX left we anchor on top + // if skewY > 0 and originX right we anchor on bottom + // if skewY < 0 and originX left we anchor on bottom + // if skewY < 0 and originX right we anchor on top + // if skewY is 0, we look for mouse position to understand where are we going. + var target = transform.target, currentSkew = target.skewY, originY, originX = transform.originX; + if (target.lockSkewingY) { + return false; + } + if (currentSkew === 0) { + var localPointFromCenter = getLocalPoint(transform, CENTER, CENTER, x, y); + if (localPointFromCenter.y > 0) { + // we are pulling down, anchor up; + originY = TOP; + } + else { + // we are pulling up, anchor down + originY = BOTTOM; + } + } + else { + if (currentSkew > 0) { + originY = originX === LEFT ? TOP : BOTTOM; + } + if (currentSkew < 0) { + originY = originX === LEFT ? BOTTOM : TOP; + } + // is the object flipped on one side only? swap the origin. + if (targetHasOneFlip(target)) { + originY = originY === TOP ? BOTTOM : TOP; + } + } + + // once we have the origin, we find the anchor point + transform.originY = originY; + var finalHandler = wrapWithFireEvent('skewing', wrapWithFixedAnchor(skewObjectY)); + return finalHandler(eventData, transform, x, y); + } + + /** + * Action handler for rotation and snapping, without anchor point. + * Needs to be wrapped with `wrapWithFixedAnchor` to be effective + * @param {Event} eventData javascript event that is doing the transform + * @param {Object} transform javascript object containing a series of information around the current transform + * @param {number} x current mouse x position, canvas normalized + * @param {number} y current mouse y position, canvas normalized + * @return {Boolean} true if some change happened + * @private + */ + function rotationWithSnapping(eventData, transform, x, y) { + var t = transform, + target = t.target, + pivotPoint = target.translateToOriginPoint(target.getCenterPoint(), t.originX, t.originY); + + if (target.lockRotation) { + return false; + } + + var lastAngle = Math.atan2(t.ey - pivotPoint.y, t.ex - pivotPoint.x), + curAngle = Math.atan2(y - pivotPoint.y, x - pivotPoint.x), + angle = radiansToDegrees(curAngle - lastAngle + t.theta), + hasRotated = true; + + if (target.snapAngle > 0) { + var snapAngle = target.snapAngle, + snapThreshold = target.snapThreshold || snapAngle, + rightAngleLocked = Math.ceil(angle / snapAngle) * snapAngle, + leftAngleLocked = Math.floor(angle / snapAngle) * snapAngle; + + if (Math.abs(angle - leftAngleLocked) < snapThreshold) { + angle = leftAngleLocked; + } + else if (Math.abs(angle - rightAngleLocked) < snapThreshold) { + angle = rightAngleLocked; + } + } + + // normalize angle to positive value + if (angle < 0) { + angle = 360 + angle; + } + angle %= 360; + + hasRotated = target.angle !== angle; + target.angle = angle; + return hasRotated; + } + + /** + * Basic scaling logic, reused with different constrain for scaling X,Y, freely or equally. + * Needs to be wrapped with `wrapWithFixedAnchor` to be effective + * @param {Event} eventData javascript event that is doing the transform + * @param {Object} transform javascript object containing a series of information around the current transform + * @param {number} x current mouse x position, canvas normalized + * @param {number} y current mouse y position, canvas normalized + * @param {Object} options additional information for scaling + * @param {String} options.by 'x', 'y', 'equally' or '' to indicate type of scaling + * @return {Boolean} true if some change happened + * @private + */ + function scaleObject(eventData, transform, x, y, options) { + options = options || {}; + var target = transform.target, + lockScalingX = target.lockScalingX, lockScalingY = target.lockScalingY, + by = options.by, newPoint, scaleX, scaleY, dim, + scaleProportionally = scaleIsProportional(eventData, target), + forbidScaling = scalingIsForbidden(target, by, scaleProportionally), + signX, signY, gestureScale = transform.gestureScale; + + if (forbidScaling) { + return false; + } + if (gestureScale) { + scaleX = transform.scaleX * gestureScale; + scaleY = transform.scaleY * gestureScale; + } + else { + newPoint = getLocalPoint(transform, transform.originX, transform.originY, x, y); + // use of sign: We use sign to detect change of direction of an action. sign usually change when + // we cross the origin point with the mouse. So a scale flip for example. There is an issue when scaling + // by center and scaling using one middle control ( default: mr, mt, ml, mb), the mouse movement can easily + // cross many time the origin point and flip the object. so we need a way to filter out the noise. + // This ternary here should be ok to filter out X scaling when we want Y only and vice versa. + signX = by !== 'y' ? sign(newPoint.x) : 1; + signY = by !== 'x' ? sign(newPoint.y) : 1; + if (!transform.signX) { + transform.signX = signX; + } + if (!transform.signY) { + transform.signY = signY; + } + + if (target.lockScalingFlip && + (transform.signX !== signX || transform.signY !== signY) + ) { + return false; + } + + dim = target._getTransformedDimensions(); + // missing detection of flip and logic to switch the origin + if (scaleProportionally && !by) { + // uniform scaling + var distance = Math.abs(newPoint.x) + Math.abs(newPoint.y), + original = transform.original, + originalDistance = Math.abs(dim.x * original.scaleX / target.scaleX) + + Math.abs(dim.y * original.scaleY / target.scaleY), + scale = distance / originalDistance; + scaleX = original.scaleX * scale; + scaleY = original.scaleY * scale; + } + else { + scaleX = Math.abs(newPoint.x * target.scaleX / dim.x); + scaleY = Math.abs(newPoint.y * target.scaleY / dim.y); + } + // if we are scaling by center, we need to double the scale + if (isTransformCentered(transform)) { + scaleX *= 2; + scaleY *= 2; + } + if (transform.signX !== signX && by !== 'y') { + transform.originX = opposite[transform.originX]; + scaleX *= -1; + transform.signX = signX; + } + if (transform.signY !== signY && by !== 'x') { + transform.originY = opposite[transform.originY]; + scaleY *= -1; + transform.signY = signY; + } + } + // minScale is taken are in the setter. + var oldScaleX = target.scaleX, oldScaleY = target.scaleY; + if (!by) { + !lockScalingX && target.set('scaleX', scaleX); + !lockScalingY && target.set('scaleY', scaleY); + } + else { + // forbidden cases already handled on top here. + by === 'x' && target.set('scaleX', scaleX); + by === 'y' && target.set('scaleY', scaleY); + } + return oldScaleX !== target.scaleX || oldScaleY !== target.scaleY; + } + + /** + * Generic scaling logic, to scale from corners either equally or freely. + * Needs to be wrapped with `wrapWithFixedAnchor` to be effective + * @param {Event} eventData javascript event that is doing the transform + * @param {Object} transform javascript object containing a series of information around the current transform + * @param {number} x current mouse x position, canvas normalized + * @param {number} y current mouse y position, canvas normalized + * @return {Boolean} true if some change happened + */ + function scaleObjectFromCorner(eventData, transform, x, y) { + return scaleObject(eventData, transform, x, y); + } + + /** + * Scaling logic for the X axis. + * Needs to be wrapped with `wrapWithFixedAnchor` to be effective + * @param {Event} eventData javascript event that is doing the transform + * @param {Object} transform javascript object containing a series of information around the current transform + * @param {number} x current mouse x position, canvas normalized + * @param {number} y current mouse y position, canvas normalized + * @return {Boolean} true if some change happened + */ + function scaleObjectX(eventData, transform, x, y) { + return scaleObject(eventData, transform, x, y , { by: 'x' }); + } + + /** + * Scaling logic for the Y axis. + * Needs to be wrapped with `wrapWithFixedAnchor` to be effective + * @param {Event} eventData javascript event that is doing the transform + * @param {Object} transform javascript object containing a series of information around the current transform + * @param {number} x current mouse x position, canvas normalized + * @param {number} y current mouse y position, canvas normalized + * @return {Boolean} true if some change happened + */ + function scaleObjectY(eventData, transform, x, y) { + return scaleObject(eventData, transform, x, y , { by: 'y' }); + } + + /** + * Composed action handler to either scale Y or skew X + * Needs to be wrapped with `wrapWithFixedAnchor` to be effective + * @param {Event} eventData javascript event that is doing the transform + * @param {Object} transform javascript object containing a series of information around the current transform + * @param {number} x current mouse x position, canvas normalized + * @param {number} y current mouse y position, canvas normalized + * @return {Boolean} true if some change happened + */ + function scalingYOrSkewingX(eventData, transform, x, y) { + // ok some safety needed here. + if (eventData[transform.target.canvas.altActionKey]) { + return controls.skewHandlerX(eventData, transform, x, y); + } + return controls.scalingY(eventData, transform, x, y); + } + + /** + * Composed action handler to either scale X or skew Y + * Needs to be wrapped with `wrapWithFixedAnchor` to be effective + * @param {Event} eventData javascript event that is doing the transform + * @param {Object} transform javascript object containing a series of information around the current transform + * @param {number} x current mouse x position, canvas normalized + * @param {number} y current mouse y position, canvas normalized + * @return {Boolean} true if some change happened + */ + function scalingXOrSkewingY(eventData, transform, x, y) { + // ok some safety needed here. + if (eventData[transform.target.canvas.altActionKey]) { + return controls.skewHandlerY(eventData, transform, x, y); + } + return controls.scalingX(eventData, transform, x, y); + } + + /** + * Action handler to change textbox width + * Needs to be wrapped with `wrapWithFixedAnchor` to be effective + * @param {Event} eventData javascript event that is doing the transform + * @param {Object} transform javascript object containing a series of information around the current transform + * @param {number} x current mouse x position, canvas normalized + * @param {number} y current mouse y position, canvas normalized + * @return {Boolean} true if some change happened + */ + function changeWidth(eventData, transform, x, y) { + var target = transform.target, localPoint = getLocalPoint(transform, transform.originX, transform.originY, x, y), + strokePadding = target.strokeWidth / (target.strokeUniform ? target.scaleX : 1), + multiplier = isTransformCentered(transform) ? 2 : 1, + oldWidth = target.width, + newWidth = Math.abs(localPoint.x * multiplier / target.scaleX) - strokePadding; + target.set('width', Math.max(newWidth, 0)); + return oldWidth !== newWidth; + } + + /** + * Action handler + * @private + * @param {Event} eventData javascript event that is doing the transform + * @param {Object} transform javascript object containing a series of information around the current transform + * @param {number} x current mouse x position, canvas normalized + * @param {number} y current mouse y position, canvas normalized + * @return {Boolean} true if the translation occurred + */ + function dragHandler(eventData, transform, x, y) { + var target = transform.target, + newLeft = x - transform.offsetX, + newTop = y - transform.offsetY, + moveX = !target.get('lockMovementX') && target.left !== newLeft, + moveY = !target.get('lockMovementY') && target.top !== newTop; + moveX && target.set('left', newLeft); + moveY && target.set('top', newTop); + if (moveX || moveY) { + fireEvent('moving', commonEventInfo(eventData, transform, x, y)); + } + return moveX || moveY; + } + + controls.scaleCursorStyleHandler = scaleCursorStyleHandler; + controls.skewCursorStyleHandler = skewCursorStyleHandler; + controls.scaleSkewCursorStyleHandler = scaleSkewCursorStyleHandler; + controls.rotationWithSnapping = wrapWithFireEvent('rotating', wrapWithFixedAnchor(rotationWithSnapping)); + controls.scalingEqually = wrapWithFireEvent('scaling', wrapWithFixedAnchor( scaleObjectFromCorner)); + controls.scalingX = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObjectX)); + controls.scalingY = wrapWithFireEvent('scaling', wrapWithFixedAnchor(scaleObjectY)); + controls.scalingYOrSkewingX = scalingYOrSkewingX; + controls.scalingXOrSkewingY = scalingXOrSkewingY; + controls.changeWidth = wrapWithFireEvent('resizing', wrapWithFixedAnchor(changeWidth)); + controls.skewHandlerX = skewHandlerX; + controls.skewHandlerY = skewHandlerY; + controls.dragHandler = dragHandler; + controls.scaleOrSkewActionName = scaleOrSkewActionName; + controls.rotationStyleHandler = rotationStyleHandler; + controls.fireEvent = fireEvent; + controls.wrapWithFixedAnchor = wrapWithFixedAnchor; + controls.wrapWithFireEvent = wrapWithFireEvent; + controls.getLocalPoint = getLocalPoint; + fabric.controlsUtils = controls; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + degreesToRadians = fabric.util.degreesToRadians, + controls = fabric.controlsUtils; + + /** + * Render a round control, as per fabric features. + * This function is written to respect object properties like transparentCorners, cornerSize + * cornerColor, cornerStrokeColor + * plus the addition of offsetY and offsetX. + * @param {CanvasRenderingContext2D} ctx context to render on + * @param {Number} left x coordinate where the control center should be + * @param {Number} top y coordinate where the control center should be + * @param {Object} styleOverride override for fabric.Object controls style + * @param {fabric.Object} fabricObject the fabric object for which we are rendering controls + */ + function renderCircleControl (ctx, left, top, styleOverride, fabricObject) { + styleOverride = styleOverride || {}; + var xSize = this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize, + ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize, + transparentCorners = typeof styleOverride.transparentCorners !== 'undefined' ? + styleOverride.transparentCorners : fabricObject.transparentCorners, + methodName = transparentCorners ? 'stroke' : 'fill', + stroke = !transparentCorners && (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor), + myLeft = left, + myTop = top, size; + ctx.save(); + ctx.fillStyle = styleOverride.cornerColor || fabricObject.cornerColor; + ctx.strokeStyle = styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor; + // as soon as fabric react v5, remove ie11, use proper ellipse code. + if (xSize > ySize) { + size = xSize; + ctx.scale(1.0, ySize / xSize); + myTop = top * xSize / ySize; + } + else if (ySize > xSize) { + size = ySize; + ctx.scale(xSize / ySize, 1.0); + myLeft = left * ySize / xSize; + } + else { + size = xSize; + } + // this is still wrong + ctx.lineWidth = 1; + ctx.beginPath(); + ctx.arc(myLeft, myTop, size / 2, 0, 2 * Math.PI, false); + ctx[methodName](); + if (stroke) { + ctx.stroke(); + } + ctx.restore(); + } + + /** + * Render a square control, as per fabric features. + * This function is written to respect object properties like transparentCorners, cornerSize + * cornerColor, cornerStrokeColor + * plus the addition of offsetY and offsetX. + * @param {CanvasRenderingContext2D} ctx context to render on + * @param {Number} left x coordinate where the control center should be + * @param {Number} top y coordinate where the control center should be + * @param {Object} styleOverride override for fabric.Object controls style + * @param {fabric.Object} fabricObject the fabric object for which we are rendering controls + */ + function renderSquareControl(ctx, left, top, styleOverride, fabricObject) { + styleOverride = styleOverride || {}; + var xSize = this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize, + ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize, + transparentCorners = typeof styleOverride.transparentCorners !== 'undefined' ? + styleOverride.transparentCorners : fabricObject.transparentCorners, + methodName = transparentCorners ? 'stroke' : 'fill', + stroke = !transparentCorners && ( + styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor + ), xSizeBy2 = xSize / 2, ySizeBy2 = ySize / 2; + ctx.save(); + ctx.fillStyle = styleOverride.cornerColor || fabricObject.cornerColor; + ctx.strokeStyle = styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor; + // this is still wrong + ctx.lineWidth = 1; + ctx.translate(left, top); + ctx.rotate(degreesToRadians(fabricObject.angle)); + // this does not work, and fixed with ( && ) does not make sense. + // to have real transparent corners we need the controls on upperCanvas + // transparentCorners || ctx.clearRect(-xSizeBy2, -ySizeBy2, xSize, ySize); + ctx[methodName + 'Rect'](-xSizeBy2, -ySizeBy2, xSize, ySize); + if (stroke) { + ctx.strokeRect(-xSizeBy2, -ySizeBy2, xSize, ySize); + } + ctx.restore(); + } + + controls.renderCircleControl = renderCircleControl; + controls.renderSquareControl = renderSquareControl; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }); + + function Control(options) { + for (var i in options) { + this[i] = options[i]; + } + } + + fabric.Control = Control; + + fabric.Control.prototype = /** @lends fabric.Control.prototype */ { + + /** + * keep track of control visibility. + * mainly for backward compatibility. + * if you do not want to see a control, you can remove it + * from the controlset. + * @type {Boolean} + * @default true + */ + visible: true, + + /** + * Name of the action that the control will likely execute. + * This is optional. FabricJS uses to identify what the user is doing for some + * extra optimizations. If you are writing a custom control and you want to know + * somewhere else in the code what is going on, you can use this string here. + * you can also provide a custom getActionName if your control run multiple actions + * depending on some external state. + * default to scale since is the most common, used on 4 corners by default + * @type {String} + * @default 'scale' + */ + actionName: 'scale', + + /** + * Drawing angle of the control. + * NOT used for now, but name marked as needed for internal logic + * example: to reuse the same drawing function for different rotated controls + * @type {Number} + * @default 0 + */ + angle: 0, + + /** + * Relative position of the control. X + * 0,0 is the center of the Object, while -0.5 (left) or 0.5 (right) are the extremities + * of the bounding box. + * @type {Number} + * @default 0 + */ + x: 0, + + /** + * Relative position of the control. Y + * 0,0 is the center of the Object, while -0.5 (top) or 0.5 (bottom) are the extremities + * of the bounding box. + * @type {Number} + * @default 0 + */ + y: 0, + + /** + * Horizontal offset of the control from the defined position. In pixels + * Positive offset moves the control to the right, negative to the left. + * It used when you want to have position of control that does not scale with + * the bounding box. Example: rotation control is placed at x:0, y: 0.5 on + * the boundindbox, with an offset of 30 pixels vertically. Those 30 pixels will + * stay 30 pixels no matter how the object is big. Another example is having 2 + * controls in the corner, that stay in the same position when the object scale. + * of the bounding box. + * @type {Number} + * @default 0 + */ + offsetX: 0, + + /** + * Vertical offset of the control from the defined position. In pixels + * Positive offset moves the control to the bottom, negative to the top. + * @type {Number} + * @default 0 + */ + offsetY: 0, + + /** + * Sets the length of the control. If null, defaults to object's cornerSize. + * Expects both sizeX and sizeY to be set when set. + * @type {?Number} + * @default null + */ + sizeX: null, + + /** + * Sets the height of the control. If null, defaults to object's cornerSize. + * Expects both sizeX and sizeY to be set when set. + * @type {?Number} + * @default null + */ + sizeY: null, + + /** + * Sets the length of the touch area of the control. If null, defaults to object's touchCornerSize. + * Expects both touchSizeX and touchSizeY to be set when set. + * @type {?Number} + * @default null + */ + touchSizeX: null, + + /** + * Sets the height of the touch area of the control. If null, defaults to object's touchCornerSize. + * Expects both touchSizeX and touchSizeY to be set when set. + * @type {?Number} + * @default null + */ + touchSizeY: null, + + /** + * Css cursor style to display when the control is hovered. + * if the method `cursorStyleHandler` is provided, this property is ignored. + * @type {String} + * @default 'crosshair' + */ + cursorStyle: 'crosshair', + + /** + * If controls has an offsetY or offsetX, draw a line that connects + * the control to the bounding box + * @type {Boolean} + * @default false + */ + withConnection: false, + + /** + * The control actionHandler, provide one to handle action ( control being moved ) + * @param {Event} eventData the native mouse event + * @param {Object} transformData properties of the current transform + * @param {Number} x x position of the cursor + * @param {Number} y y position of the cursor + * @return {Boolean} true if the action/event modified the object + */ + actionHandler: function(/* eventData, transformData, x, y */) { }, + + /** + * The control handler for mouse down, provide one to handle mouse down on control + * @param {Event} eventData the native mouse event + * @param {Object} transformData properties of the current transform + * @param {Number} x x position of the cursor + * @param {Number} y y position of the cursor + * @return {Boolean} true if the action/event modified the object + */ + mouseDownHandler: function(/* eventData, transformData, x, y */) { }, + + /** + * The control mouseUpHandler, provide one to handle an effect on mouse up. + * @param {Event} eventData the native mouse event + * @param {Object} transformData properties of the current transform + * @param {Number} x x position of the cursor + * @param {Number} y y position of the cursor + * @return {Boolean} true if the action/event modified the object + */ + mouseUpHandler: function(/* eventData, transformData, x, y */) { }, + + /** + * Returns control actionHandler + * @param {Event} eventData the native mouse event + * @param {fabric.Object} fabricObject on which the control is displayed + * @param {fabric.Control} control control for which the action handler is being asked + * @return {Function} the action handler + */ + getActionHandler: function(/* eventData, fabricObject, control */) { + return this.actionHandler; + }, + + /** + * Returns control mouseDown handler + * @param {Event} eventData the native mouse event + * @param {fabric.Object} fabricObject on which the control is displayed + * @param {fabric.Control} control control for which the action handler is being asked + * @return {Function} the action handler + */ + getMouseDownHandler: function(/* eventData, fabricObject, control */) { + return this.mouseDownHandler; + }, + + /** + * Returns control mouseUp handler + * @param {Event} eventData the native mouse event + * @param {fabric.Object} fabricObject on which the control is displayed + * @param {fabric.Control} control control for which the action handler is being asked + * @return {Function} the action handler + */ + getMouseUpHandler: function(/* eventData, fabricObject, control */) { + return this.mouseUpHandler; + }, + + /** + * Returns control cursorStyle for css using cursorStyle. If you need a more elaborate + * function you can pass one in the constructor + * the cursorStyle property + * @param {Event} eventData the native mouse event + * @param {fabric.Control} control the current control ( likely this) + * @param {fabric.Object} object on which the control is displayed + * @return {String} + */ + cursorStyleHandler: function(eventData, control /* fabricObject */) { + return control.cursorStyle; + }, + + /** + * Returns the action name. The basic implementation just return the actionName property. + * @param {Event} eventData the native mouse event + * @param {fabric.Control} control the current control ( likely this) + * @param {fabric.Object} object on which the control is displayed + * @return {String} + */ + getActionName: function(eventData, control /* fabricObject */) { + return control.actionName; + }, + + /** + * Returns controls visibility + * @param {fabric.Object} object on which the control is displayed + * @param {String} controlKey key where the control is memorized on the + * @return {Boolean} + */ + getVisibility: function(fabricObject, controlKey) { + var objectVisibility = fabricObject._controlsVisibility; + if (objectVisibility && typeof objectVisibility[controlKey] !== 'undefined') { + return objectVisibility[controlKey]; + } + return this.visible; + }, + + /** + * Sets controls visibility + * @param {Boolean} visibility for the object + * @return {Void} + */ + setVisibility: function(visibility /* name, fabricObject */) { + this.visible = visibility; + }, + + + positionHandler: function(dim, finalMatrix /*, fabricObject, currentControl */) { + var point = fabric.util.transformPoint({ + x: this.x * dim.x + this.offsetX, + y: this.y * dim.y + this.offsetY }, finalMatrix); + return point; + }, + + /** + * Returns the coords for this control based on object values. + * @param {Number} objectAngle angle from the fabric object holding the control + * @param {Number} objectCornerSize cornerSize from the fabric object holding the control (or touchCornerSize if + * isTouch is true) + * @param {Number} centerX x coordinate where the control center should be + * @param {Number} centerY y coordinate where the control center should be + * @param {boolean} isTouch true if touch corner, false if normal corner + */ + calcCornerCoords: function(objectAngle, objectCornerSize, centerX, centerY, isTouch) { + var cosHalfOffset, + sinHalfOffset, + cosHalfOffsetComp, + sinHalfOffsetComp, + xSize = (isTouch) ? this.touchSizeX : this.sizeX, + ySize = (isTouch) ? this.touchSizeY : this.sizeY; + if (xSize && ySize && xSize !== ySize) { + // handle rectangular corners + var controlTriangleAngle = Math.atan2(ySize, xSize); + var cornerHypotenuse = Math.sqrt(xSize * xSize + ySize * ySize) / 2; + var newTheta = controlTriangleAngle - fabric.util.degreesToRadians(objectAngle); + var newThetaComp = Math.PI / 2 - controlTriangleAngle - fabric.util.degreesToRadians(objectAngle); + cosHalfOffset = cornerHypotenuse * fabric.util.cos(newTheta); + sinHalfOffset = cornerHypotenuse * fabric.util.sin(newTheta); + // use complementary angle for two corners + cosHalfOffsetComp = cornerHypotenuse * fabric.util.cos(newThetaComp); + sinHalfOffsetComp = cornerHypotenuse * fabric.util.sin(newThetaComp); + } + else { + // handle square corners + // use default object corner size unless size is defined + var cornerSize = (xSize && ySize) ? xSize : objectCornerSize; + /* 0.7071067812 stands for sqrt(2)/2 */ + cornerHypotenuse = cornerSize * 0.7071067812; + // complementary angles are equal since they're both 45 degrees + var newTheta = fabric.util.degreesToRadians(45 - objectAngle); + cosHalfOffset = cosHalfOffsetComp = cornerHypotenuse * fabric.util.cos(newTheta); + sinHalfOffset = sinHalfOffsetComp = cornerHypotenuse * fabric.util.sin(newTheta); + } + + return { + tl: { + x: centerX - sinHalfOffsetComp, + y: centerY - cosHalfOffsetComp, + }, + tr: { + x: centerX + cosHalfOffset, + y: centerY - sinHalfOffset, + }, + bl: { + x: centerX - cosHalfOffset, + y: centerY + sinHalfOffset, + }, + br: { + x: centerX + sinHalfOffsetComp, + y: centerY + cosHalfOffsetComp, + }, + }; + }, + + /** + * Render function for the control. + * When this function runs the context is unscaled. unrotate. Just retina scaled. + * all the functions will have to translate to the point left,top before starting Drawing + * if they want to draw a control where the position is detected. + * left and top are the result of the positionHandler function + * @param {RenderingContext2D} ctx the context where the control will be drawn + * @param {Number} left position of the canvas where we are about to render the control. + * @param {Number} top position of the canvas where we are about to render the control. + * @param {Object} styleOverride + * @param {fabric.Object} fabricObject the object where the control is about to be rendered + */ + render: function(ctx, left, top, styleOverride, fabricObject) { + styleOverride = styleOverride || {}; + switch (styleOverride.cornerStyle || fabricObject.cornerStyle) { + case 'circle': + fabric.controlsUtils.renderCircleControl.call(this, ctx, left, top, styleOverride, fabricObject); + break; + default: + fabric.controlsUtils.renderSquareControl.call(this, ctx, left, top, styleOverride, fabricObject); + } + }, + }; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function() { + + /* _FROM_SVG_START_ */ + function getColorStop(el, multiplier) { + var style = el.getAttribute('style'), + offset = el.getAttribute('offset') || 0, + color, colorAlpha, opacity, i; + + // convert percents to absolute values + offset = parseFloat(offset) / (/%$/.test(offset) ? 100 : 1); + offset = offset < 0 ? 0 : offset > 1 ? 1 : offset; + if (style) { + var keyValuePairs = style.split(/\s*;\s*/); + + if (keyValuePairs[keyValuePairs.length - 1] === '') { + keyValuePairs.pop(); + } + + for (i = keyValuePairs.length; i--; ) { + + var split = keyValuePairs[i].split(/\s*:\s*/), + key = split[0].trim(), + value = split[1].trim(); + + if (key === 'stop-color') { + color = value; + } + else if (key === 'stop-opacity') { + opacity = value; + } + } + } + + if (!color) { + color = el.getAttribute('stop-color') || 'rgb(0,0,0)'; + } + if (!opacity) { + opacity = el.getAttribute('stop-opacity'); + } + + color = new fabric.Color(color); + colorAlpha = color.getAlpha(); + opacity = isNaN(parseFloat(opacity)) ? 1 : parseFloat(opacity); + opacity *= colorAlpha * multiplier; + + return { + offset: offset, + color: color.toRgb(), + opacity: opacity + }; + } + + function getLinearCoords(el) { + return { + x1: el.getAttribute('x1') || 0, + y1: el.getAttribute('y1') || 0, + x2: el.getAttribute('x2') || '100%', + y2: el.getAttribute('y2') || 0 + }; + } + + function getRadialCoords(el) { + return { + x1: el.getAttribute('fx') || el.getAttribute('cx') || '50%', + y1: el.getAttribute('fy') || el.getAttribute('cy') || '50%', + r1: 0, + x2: el.getAttribute('cx') || '50%', + y2: el.getAttribute('cy') || '50%', + r2: el.getAttribute('r') || '50%' + }; + } + /* _FROM_SVG_END_ */ + + var clone = fabric.util.object.clone; + + /** + * Gradient class + * @class fabric.Gradient + * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#gradients} + * @see {@link fabric.Gradient#initialize} for constructor definition + */ + fabric.Gradient = fabric.util.createClass(/** @lends fabric.Gradient.prototype */ { + + /** + * Horizontal offset for aligning gradients coming from SVG when outside pathgroups + * @type Number + * @default 0 + */ + offsetX: 0, + + /** + * Vertical offset for aligning gradients coming from SVG when outside pathgroups + * @type Number + * @default 0 + */ + offsetY: 0, + + /** + * A transform matrix to apply to the gradient before painting. + * Imported from svg gradients, is not applied with the current transform in the center. + * Before this transform is applied, the origin point is at the top left corner of the object + * plus the addition of offsetY and offsetX. + * @type Number[] + * @default null + */ + gradientTransform: null, + + /** + * coordinates units for coords. + * If `pixels`, the number of coords are in the same unit of width / height. + * If set as `percentage` the coords are still a number, but 1 means 100% of width + * for the X and 100% of the height for the y. It can be bigger than 1 and negative. + * allowed values pixels or percentage. + * @type String + * @default 'pixels' + */ + gradientUnits: 'pixels', + + /** + * Gradient type linear or radial + * @type String + * @default 'pixels' + */ + type: 'linear', + + /** + * Constructor + * @param {Object} options Options object with type, coords, gradientUnits and colorStops + * @param {Object} [options.type] gradient type linear or radial + * @param {Object} [options.gradientUnits] gradient units + * @param {Object} [options.offsetX] SVG import compatibility + * @param {Object} [options.offsetY] SVG import compatibility + * @param {Object[]} options.colorStops contains the colorstops. + * @param {Object} options.coords contains the coords of the gradient + * @param {Number} [options.coords.x1] X coordiante of the first point for linear or of the focal point for radial + * @param {Number} [options.coords.y1] Y coordiante of the first point for linear or of the focal point for radial + * @param {Number} [options.coords.x2] X coordiante of the second point for linear or of the center point for radial + * @param {Number} [options.coords.y2] Y coordiante of the second point for linear or of the center point for radial + * @param {Number} [options.coords.r1] only for radial gradient, radius of the inner circle + * @param {Number} [options.coords.r2] only for radial gradient, radius of the external circle + * @return {fabric.Gradient} thisArg + */ + initialize: function(options) { + options || (options = { }); + options.coords || (options.coords = { }); + + var coords, _this = this; + + // sets everything, then coords and colorstops get sets again + Object.keys(options).forEach(function(option) { + _this[option] = options[option]; + }); + + if (this.id) { + this.id += '_' + fabric.Object.__uid++; + } + else { + this.id = fabric.Object.__uid++; + } + + coords = { + x1: options.coords.x1 || 0, + y1: options.coords.y1 || 0, + x2: options.coords.x2 || 0, + y2: options.coords.y2 || 0 + }; + + if (this.type === 'radial') { + coords.r1 = options.coords.r1 || 0; + coords.r2 = options.coords.r2 || 0; + } + + this.coords = coords; + this.colorStops = options.colorStops.slice(); + }, + + /** + * Adds another colorStop + * @param {Object} colorStop Object with offset and color + * @return {fabric.Gradient} thisArg + */ + addColorStop: function(colorStops) { + for (var position in colorStops) { + var color = new fabric.Color(colorStops[position]); + this.colorStops.push({ + offset: parseFloat(position), + color: color.toRgb(), + opacity: color.getAlpha() + }); + } + return this; + }, + + /** + * Returns object representation of a gradient + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} + */ + toObject: function(propertiesToInclude) { + var object = { + type: this.type, + coords: this.coords, + colorStops: this.colorStops, + offsetX: this.offsetX, + offsetY: this.offsetY, + gradientUnits: this.gradientUnits, + gradientTransform: this.gradientTransform ? this.gradientTransform.concat() : this.gradientTransform + }; + fabric.util.populateWithProperties(this, object, propertiesToInclude); + + return object; + }, + + /* _TO_SVG_START_ */ + /** + * Returns SVG representation of an gradient + * @param {Object} object Object to create a gradient for + * @return {String} SVG representation of an gradient (linear/radial) + */ + toSVG: function(object, options) { + var coords = clone(this.coords, true), i, len, options = options || {}, + markup, commonAttributes, colorStops = clone(this.colorStops, true), + needsSwap = coords.r1 > coords.r2, + transform = this.gradientTransform ? this.gradientTransform.concat() : fabric.iMatrix.concat(), + offsetX = -this.offsetX, offsetY = -this.offsetY, + withViewport = !!options.additionalTransform, + gradientUnits = this.gradientUnits === 'pixels' ? 'userSpaceOnUse' : 'objectBoundingBox'; + // colorStops must be sorted ascending + colorStops.sort(function(a, b) { + return a.offset - b.offset; + }); + + if (gradientUnits === 'objectBoundingBox') { + offsetX /= object.width; + offsetY /= object.height; + } + else { + offsetX += object.width / 2; + offsetY += object.height / 2; + } + if (object.type === 'path' && this.gradientUnits !== 'percentage') { + offsetX -= object.pathOffset.x; + offsetY -= object.pathOffset.y; + } + + + transform[4] -= offsetX; + transform[5] -= offsetY; + + commonAttributes = 'id="SVGID_' + this.id + + '" gradientUnits="' + gradientUnits + '"'; + commonAttributes += ' gradientTransform="' + (withViewport ? + options.additionalTransform + ' ' : '') + fabric.util.matrixToSVG(transform) + '" '; + + if (this.type === 'linear') { + markup = [ + '\n' + ]; + } + else if (this.type === 'radial') { + // svg radial gradient has just 1 radius. the biggest. + markup = [ + '\n' + ]; + } + + if (this.type === 'radial') { + if (needsSwap) { + // svg goes from internal to external radius. if radius are inverted, swap color stops. + colorStops = colorStops.concat(); + colorStops.reverse(); + for (i = 0, len = colorStops.length; i < len; i++) { + colorStops[i].offset = 1 - colorStops[i].offset; + } + } + var minRadius = Math.min(coords.r1, coords.r2); + if (minRadius > 0) { + // i have to shift all colorStops and add new one in 0. + var maxRadius = Math.max(coords.r1, coords.r2), + percentageShift = minRadius / maxRadius; + for (i = 0, len = colorStops.length; i < len; i++) { + colorStops[i].offset += percentageShift * (1 - colorStops[i].offset); + } + } + } + + for (i = 0, len = colorStops.length; i < len; i++) { + var colorStop = colorStops[i]; + markup.push( + '\n' + ); + } + + markup.push((this.type === 'linear' ? '\n' : '\n')); + + return markup.join(''); + }, + /* _TO_SVG_END_ */ + + /** + * Returns an instance of CanvasGradient + * @param {CanvasRenderingContext2D} ctx Context to render on + * @return {CanvasGradient} + */ + toLive: function(ctx) { + var gradient, coords = fabric.util.object.clone(this.coords), i, len; + + if (!this.type) { + return; + } + + if (this.type === 'linear') { + gradient = ctx.createLinearGradient( + coords.x1, coords.y1, coords.x2, coords.y2); + } + else if (this.type === 'radial') { + gradient = ctx.createRadialGradient( + coords.x1, coords.y1, coords.r1, coords.x2, coords.y2, coords.r2); + } + + for (i = 0, len = this.colorStops.length; i < len; i++) { + var color = this.colorStops[i].color, + opacity = this.colorStops[i].opacity, + offset = this.colorStops[i].offset; + + if (typeof opacity !== 'undefined') { + color = new fabric.Color(color).setAlpha(opacity).toRgba(); + } + gradient.addColorStop(offset, color); + } + + return gradient; + } + }); + + fabric.util.object.extend(fabric.Gradient, { + + /* _FROM_SVG_START_ */ + /** + * Returns {@link fabric.Gradient} instance from an SVG element + * @static + * @memberOf fabric.Gradient + * @param {SVGGradientElement} el SVG gradient element + * @param {fabric.Object} instance + * @param {String} opacityAttr A fill-opacity or stroke-opacity attribute to multiply to each stop's opacity. + * @param {Object} svgOptions an object containing the size of the SVG in order to parse correctly gradients + * that uses gradientUnits as 'userSpaceOnUse' and percentages. + * @param {Object.number} viewBoxWidth width part of the viewBox attribute on svg + * @param {Object.number} viewBoxHeight height part of the viewBox attribute on svg + * @param {Object.number} width width part of the svg tag if viewBox is not specified + * @param {Object.number} height height part of the svg tag if viewBox is not specified + * @return {fabric.Gradient} Gradient instance + * @see http://www.w3.org/TR/SVG/pservers.html#LinearGradientElement + * @see http://www.w3.org/TR/SVG/pservers.html#RadialGradientElement + */ + fromElement: function(el, instance, opacityAttr, svgOptions) { + /** + * @example: + * + * + * + * + * + * + * OR + * + * + * + * + * + * + * OR + * + * + * + * + * + * + * + * OR + * + * + * + * + * + * + * + */ + + var multiplier = parseFloat(opacityAttr) / (/%$/.test(opacityAttr) ? 100 : 1); + multiplier = multiplier < 0 ? 0 : multiplier > 1 ? 1 : multiplier; + if (isNaN(multiplier)) { + multiplier = 1; + } + + var colorStopEls = el.getElementsByTagName('stop'), + type, + gradientUnits = el.getAttribute('gradientUnits') === 'userSpaceOnUse' ? + 'pixels' : 'percentage', + gradientTransform = el.getAttribute('gradientTransform') || '', + colorStops = [], + coords, i, offsetX = 0, offsetY = 0, + transformMatrix; + if (el.nodeName === 'linearGradient' || el.nodeName === 'LINEARGRADIENT') { + type = 'linear'; + coords = getLinearCoords(el); + } + else { + type = 'radial'; + coords = getRadialCoords(el); + } + + for (i = colorStopEls.length; i--; ) { + colorStops.push(getColorStop(colorStopEls[i], multiplier)); + } + + transformMatrix = fabric.parseTransformAttribute(gradientTransform); + + __convertPercentUnitsToValues(instance, coords, svgOptions, gradientUnits); + + if (gradientUnits === 'pixels') { + offsetX = -instance.left; + offsetY = -instance.top; + } + + var gradient = new fabric.Gradient({ + id: el.getAttribute('id'), + type: type, + coords: coords, + colorStops: colorStops, + gradientUnits: gradientUnits, + gradientTransform: transformMatrix, + offsetX: offsetX, + offsetY: offsetY, + }); + + return gradient; + } + /* _FROM_SVG_END_ */ + }); + + /** + * @private + */ + function __convertPercentUnitsToValues(instance, options, svgOptions, gradientUnits) { + var propValue, finalValue; + Object.keys(options).forEach(function(prop) { + propValue = options[prop]; + if (propValue === 'Infinity') { + finalValue = 1; + } + else if (propValue === '-Infinity') { + finalValue = 0; + } + else { + finalValue = parseFloat(options[prop], 10); + if (typeof propValue === 'string' && /^(\d+\.\d+)%|(\d+)%$/.test(propValue)) { + finalValue *= 0.01; + if (gradientUnits === 'pixels') { + // then we need to fix those percentages here in svg parsing + if (prop === 'x1' || prop === 'x2' || prop === 'r2') { + finalValue *= svgOptions.viewBoxWidth || svgOptions.width; + } + if (prop === 'y1' || prop === 'y2') { + finalValue *= svgOptions.viewBoxHeight || svgOptions.height; + } + } + } + } + options[prop] = finalValue; + }); + } +})(); + + +(function() { + + 'use strict'; + + var toFixed = fabric.util.toFixed; + + /** + * Pattern class + * @class fabric.Pattern + * @see {@link http://fabricjs.com/patterns|Pattern demo} + * @see {@link http://fabricjs.com/dynamic-patterns|DynamicPattern demo} + * @see {@link fabric.Pattern#initialize} for constructor definition + */ + + + fabric.Pattern = fabric.util.createClass(/** @lends fabric.Pattern.prototype */ { + + /** + * Repeat property of a pattern (one of repeat, repeat-x, repeat-y or no-repeat) + * @type String + * @default + */ + repeat: 'repeat', + + /** + * Pattern horizontal offset from object's left/top corner + * @type Number + * @default + */ + offsetX: 0, + + /** + * Pattern vertical offset from object's left/top corner + * @type Number + * @default + */ + offsetY: 0, + + /** + * crossOrigin value (one of "", "anonymous", "use-credentials") + * @see https://developer.mozilla.org/en-US/docs/HTML/CORS_settings_attributes + * @type String + * @default + */ + crossOrigin: '', + + /** + * transform matrix to change the pattern, imported from svgs. + * @type Array + * @default + */ + patternTransform: null, + + /** + * Constructor + * @param {Object} [options] Options object + * @param {Function} [callback] function to invoke after callback init. + * @return {fabric.Pattern} thisArg + */ + initialize: function(options, callback) { + options || (options = { }); + + this.id = fabric.Object.__uid++; + this.setOptions(options); + if (!options.source || (options.source && typeof options.source !== 'string')) { + callback && callback(this); + return; + } + else { + // img src string + var _this = this; + this.source = fabric.util.createImage(); + fabric.util.loadImage(options.source, function(img, isError) { + _this.source = img; + callback && callback(_this, isError); + }, null, this.crossOrigin); + } + }, + + /** + * Returns object representation of a pattern + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} Object representation of a pattern instance + */ + toObject: function(propertiesToInclude) { + var NUM_FRACTION_DIGITS = fabric.Object.NUM_FRACTION_DIGITS, + source, object; + + // element + if (typeof this.source.src === 'string') { + source = this.source.src; + } + // element + else if (typeof this.source === 'object' && this.source.toDataURL) { + source = this.source.toDataURL(); + } + + object = { + type: 'pattern', + source: source, + repeat: this.repeat, + crossOrigin: this.crossOrigin, + offsetX: toFixed(this.offsetX, NUM_FRACTION_DIGITS), + offsetY: toFixed(this.offsetY, NUM_FRACTION_DIGITS), + patternTransform: this.patternTransform ? this.patternTransform.concat() : null + }; + fabric.util.populateWithProperties(this, object, propertiesToInclude); + + return object; + }, + + /* _TO_SVG_START_ */ + /** + * Returns SVG representation of a pattern + * @param {fabric.Object} object + * @return {String} SVG representation of a pattern + */ + toSVG: function(object) { + var patternSource = typeof this.source === 'function' ? this.source() : this.source, + patternWidth = patternSource.width / object.width, + patternHeight = patternSource.height / object.height, + patternOffsetX = this.offsetX / object.width, + patternOffsetY = this.offsetY / object.height, + patternImgSrc = ''; + if (this.repeat === 'repeat-x' || this.repeat === 'no-repeat') { + patternHeight = 1; + if (patternOffsetY) { + patternHeight += Math.abs(patternOffsetY); + } + } + if (this.repeat === 'repeat-y' || this.repeat === 'no-repeat') { + patternWidth = 1; + if (patternOffsetX) { + patternWidth += Math.abs(patternOffsetX); + } + + } + if (patternSource.src) { + patternImgSrc = patternSource.src; + } + else if (patternSource.toDataURL) { + patternImgSrc = patternSource.toDataURL(); + } + + return '\n' + + '\n' + + '\n'; + }, + /* _TO_SVG_END_ */ + + setOptions: function(options) { + for (var prop in options) { + this[prop] = options[prop]; + } + }, + + /** + * Returns an instance of CanvasPattern + * @param {CanvasRenderingContext2D} ctx Context to create pattern + * @return {CanvasPattern} + */ + toLive: function(ctx) { + var source = this.source; + // if the image failed to load, return, and allow rest to continue loading + if (!source) { + return ''; + } + + // if an image + if (typeof source.src !== 'undefined') { + if (!source.complete) { + return ''; + } + if (source.naturalWidth === 0 || source.naturalHeight === 0) { + return ''; + } + } + return ctx.createPattern(source, this.repeat); + } + }); +})(); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + toFixed = fabric.util.toFixed; + + if (fabric.Shadow) { + fabric.warn('fabric.Shadow is already defined.'); + return; + } + + /** + * Shadow class + * @class fabric.Shadow + * @see {@link http://fabricjs.com/shadows|Shadow demo} + * @see {@link fabric.Shadow#initialize} for constructor definition + */ + fabric.Shadow = fabric.util.createClass(/** @lends fabric.Shadow.prototype */ { + + /** + * Shadow color + * @type String + * @default + */ + color: 'rgb(0,0,0)', + + /** + * Shadow blur + * @type Number + */ + blur: 0, + + /** + * Shadow horizontal offset + * @type Number + * @default + */ + offsetX: 0, + + /** + * Shadow vertical offset + * @type Number + * @default + */ + offsetY: 0, + + /** + * Whether the shadow should affect stroke operations + * @type Boolean + * @default + */ + affectStroke: false, + + /** + * Indicates whether toObject should include default values + * @type Boolean + * @default + */ + includeDefaultValues: true, + + /** + * When `false`, the shadow will scale with the object. + * When `true`, the shadow's offsetX, offsetY, and blur will not be affected by the object's scale. + * default to false + * @type Boolean + * @default + */ + nonScaling: false, + + /** + * Constructor + * @param {Object|String} [options] Options object with any of color, blur, offsetX, offsetY properties or string (e.g. "rgba(0,0,0,0.2) 2px 2px 10px") + * @return {fabric.Shadow} thisArg + */ + initialize: function(options) { + + if (typeof options === 'string') { + options = this._parseShadow(options); + } + + for (var prop in options) { + this[prop] = options[prop]; + } + + this.id = fabric.Object.__uid++; + }, + + /** + * @private + * @param {String} shadow Shadow value to parse + * @return {Object} Shadow object with color, offsetX, offsetY and blur + */ + _parseShadow: function(shadow) { + var shadowStr = shadow.trim(), + offsetsAndBlur = fabric.Shadow.reOffsetsAndBlur.exec(shadowStr) || [], + color = shadowStr.replace(fabric.Shadow.reOffsetsAndBlur, '') || 'rgb(0,0,0)'; + + return { + color: color.trim(), + offsetX: parseFloat(offsetsAndBlur[1], 10) || 0, + offsetY: parseFloat(offsetsAndBlur[2], 10) || 0, + blur: parseFloat(offsetsAndBlur[3], 10) || 0 + }; + }, + + /** + * Returns a string representation of an instance + * @see http://www.w3.org/TR/css-text-decor-3/#text-shadow + * @return {String} Returns CSS3 text-shadow declaration + */ + toString: function() { + return [this.offsetX, this.offsetY, this.blur, this.color].join('px '); + }, + + /* _TO_SVG_START_ */ + /** + * Returns SVG representation of a shadow + * @param {fabric.Object} object + * @return {String} SVG representation of a shadow + */ + toSVG: function(object) { + var fBoxX = 40, fBoxY = 40, NUM_FRACTION_DIGITS = fabric.Object.NUM_FRACTION_DIGITS, + offset = fabric.util.rotateVector( + { x: this.offsetX, y: this.offsetY }, + fabric.util.degreesToRadians(-object.angle)), + BLUR_BOX = 20, color = new fabric.Color(this.color); + + if (object.width && object.height) { + //http://www.w3.org/TR/SVG/filters.html#FilterEffectsRegion + // we add some extra space to filter box to contain the blur ( 20 ) + fBoxX = toFixed((Math.abs(offset.x) + this.blur) / object.width, NUM_FRACTION_DIGITS) * 100 + BLUR_BOX; + fBoxY = toFixed((Math.abs(offset.y) + this.blur) / object.height, NUM_FRACTION_DIGITS) * 100 + BLUR_BOX; + } + if (object.flipX) { + offset.x *= -1; + } + if (object.flipY) { + offset.y *= -1; + } + + return ( + '\n' + + '\t\n' + + '\t\n' + + '\t\n' + + '\t\n' + + '\t\n' + + '\t\t\n' + + '\t\t\n' + + '\t\n' + + '\n'); + }, + /* _TO_SVG_END_ */ + + /** + * Returns object representation of a shadow + * @return {Object} Object representation of a shadow instance + */ + toObject: function() { + if (this.includeDefaultValues) { + return { + color: this.color, + blur: this.blur, + offsetX: this.offsetX, + offsetY: this.offsetY, + affectStroke: this.affectStroke, + nonScaling: this.nonScaling + }; + } + var obj = { }, proto = fabric.Shadow.prototype; + + ['color', 'blur', 'offsetX', 'offsetY', 'affectStroke', 'nonScaling'].forEach(function(prop) { + if (this[prop] !== proto[prop]) { + obj[prop] = this[prop]; + } + }, this); + + return obj; + } + }); + + /** + * Regex matching shadow offsetX, offsetY and blur (ex: "2px 2px 10px rgba(0,0,0,0.2)", "rgb(0,255,0) 2px 2px") + * @static + * @field + * @memberOf fabric.Shadow + */ + // eslint-disable-next-line max-len + fabric.Shadow.reOffsetsAndBlur = /(?:\s|^)(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(\d+(?:\.\d*)?(?:px)?)?(?:\s?|$)(?:$|\s)/; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function () { + + 'use strict'; + + if (fabric.StaticCanvas) { + fabric.warn('fabric.StaticCanvas is already defined.'); + return; + } + + // aliases for faster resolution + var extend = fabric.util.object.extend, + getElementOffset = fabric.util.getElementOffset, + removeFromArray = fabric.util.removeFromArray, + toFixed = fabric.util.toFixed, + transformPoint = fabric.util.transformPoint, + invertTransform = fabric.util.invertTransform, + getNodeCanvas = fabric.util.getNodeCanvas, + createCanvasElement = fabric.util.createCanvasElement, + + CANVAS_INIT_ERROR = new Error('Could not initialize `canvas` element'); + + /** + * Static canvas class + * @class fabric.StaticCanvas + * @mixes fabric.Collection + * @mixes fabric.Observable + * @see {@link http://fabricjs.com/static_canvas|StaticCanvas demo} + * @see {@link fabric.StaticCanvas#initialize} for constructor definition + * @fires before:render + * @fires after:render + * @fires canvas:cleared + * @fires object:added + * @fires object:removed + */ + fabric.StaticCanvas = fabric.util.createClass(fabric.CommonMethods, /** @lends fabric.StaticCanvas.prototype */ { + + /** + * Constructor + * @param {HTMLElement | String} el <canvas> element to initialize instance on + * @param {Object} [options] Options object + * @return {Object} thisArg + */ + initialize: function(el, options) { + options || (options = { }); + this.renderAndResetBound = this.renderAndReset.bind(this); + this.requestRenderAllBound = this.requestRenderAll.bind(this); + this._initStatic(el, options); + }, + + /** + * Background color of canvas instance. + * Should be set via {@link fabric.StaticCanvas#setBackgroundColor}. + * @type {(String|fabric.Pattern)} + * @default + */ + backgroundColor: '', + + /** + * Background image of canvas instance. + * since 2.4.0 image caching is active, please when putting an image as background, add to the + * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom + * vale. As an alternative you can disable image objectCaching + * @type fabric.Image + * @default + */ + backgroundImage: null, + + /** + * Overlay color of canvas instance. + * Should be set via {@link fabric.StaticCanvas#setOverlayColor} + * @since 1.3.9 + * @type {(String|fabric.Pattern)} + * @default + */ + overlayColor: '', + + /** + * Overlay image of canvas instance. + * since 2.4.0 image caching is active, please when putting an image as overlay, add to the + * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom + * vale. As an alternative you can disable image objectCaching + * @type fabric.Image + * @default + */ + overlayImage: null, + + /** + * Indicates whether toObject/toDatalessObject should include default values + * if set to false, takes precedence over the object value. + * @type Boolean + * @default + */ + includeDefaultValues: true, + + /** + * Indicates whether objects' state should be saved + * @type Boolean + * @default + */ + stateful: false, + + /** + * Indicates whether {@link fabric.Collection.add}, {@link fabric.Collection.insertAt} and {@link fabric.Collection.remove}, + * {@link fabric.StaticCanvas.moveTo}, {@link fabric.StaticCanvas.clear} and many more, should also re-render canvas. + * Disabling this option will not give a performance boost when adding/removing a lot of objects to/from canvas at once + * since the renders are quequed and executed one per frame. + * Disabling is suggested anyway and managing the renders of the app manually is not a big effort ( canvas.requestRenderAll() ) + * Left default to true to do not break documentation and old app, fiddles. + * @type Boolean + * @default + */ + renderOnAddRemove: true, + + /** + * Indicates whether object controls (borders/controls) are rendered above overlay image + * @type Boolean + * @default + */ + controlsAboveOverlay: false, + + /** + * Indicates whether the browser can be scrolled when using a touchscreen and dragging on the canvas + * @type Boolean + * @default + */ + allowTouchScrolling: false, + + /** + * Indicates whether this canvas will use image smoothing, this is on by default in browsers + * @type Boolean + * @default + */ + imageSmoothingEnabled: true, + + /** + * The transformation (a Canvas 2D API transform matrix) which focuses the viewport + * @type Array + * @example Default transform + * canvas.viewportTransform = [1, 0, 0, 1, 0, 0]; + * @example Scale by 70% and translate toward bottom-right by 50, without skewing + * canvas.viewportTransform = [0.7, 0, 0, 0.7, 50, 50]; + * @default + */ + viewportTransform: fabric.iMatrix.concat(), + + /** + * if set to false background image is not affected by viewport transform + * @since 1.6.3 + * @type Boolean + * @default + */ + backgroundVpt: true, + + /** + * if set to false overlya image is not affected by viewport transform + * @since 1.6.3 + * @type Boolean + * @default + */ + overlayVpt: true, + + /** + * When true, canvas is scaled by devicePixelRatio for better rendering on retina screens + * @type Boolean + * @default + */ + enableRetinaScaling: true, + + /** + * Describe canvas element extension over design + * properties are tl,tr,bl,br. + * if canvas is not zoomed/panned those points are the four corner of canvas + * if canvas is viewportTransformed you those points indicate the extension + * of canvas element in plain untrasformed coordinates + * The coordinates get updated with @method calcViewportBoundaries. + * @memberOf fabric.StaticCanvas.prototype + */ + vptCoords: { }, + + /** + * Based on vptCoords and object.aCoords, skip rendering of objects that + * are not included in current viewport. + * May greatly help in applications with crowded canvas and use of zoom/pan + * If One of the corner of the bounding box of the object is on the canvas + * the objects get rendered. + * @memberOf fabric.StaticCanvas.prototype + * @type Boolean + * @default + */ + skipOffscreen: true, + + /** + * a fabricObject that, without stroke define a clipping area with their shape. filled in black + * the clipPath object gets used when the canvas has rendered, and the context is placed in the + * top left corner of the canvas. + * clipPath will clip away controls, if you do not want this to happen use controlsAboveOverlay = true + * @type fabric.Object + */ + clipPath: undefined, + + /** + * @private + * @param {HTMLElement | String} el <canvas> element to initialize instance on + * @param {Object} [options] Options object + */ + _initStatic: function(el, options) { + var cb = this.requestRenderAllBound; + this._objects = []; + this._createLowerCanvas(el); + this._initOptions(options); + // only initialize retina scaling once + if (!this.interactive) { + this._initRetinaScaling(); + } + + if (options.overlayImage) { + this.setOverlayImage(options.overlayImage, cb); + } + if (options.backgroundImage) { + this.setBackgroundImage(options.backgroundImage, cb); + } + if (options.backgroundColor) { + this.setBackgroundColor(options.backgroundColor, cb); + } + if (options.overlayColor) { + this.setOverlayColor(options.overlayColor, cb); + } + this.calcOffset(); + }, + + /** + * @private + */ + _isRetinaScaling: function() { + return (fabric.devicePixelRatio > 1 && this.enableRetinaScaling); + }, + + /** + * @private + * @return {Number} retinaScaling if applied, otherwise 1; + */ + getRetinaScaling: function() { + return this._isRetinaScaling() ? Math.max(1, fabric.devicePixelRatio) : 1; + }, + + /** + * @private + */ + _initRetinaScaling: function() { + if (!this._isRetinaScaling()) { + return; + } + var scaleRatio = fabric.devicePixelRatio; + this.__initRetinaScaling(scaleRatio, this.lowerCanvasEl, this.contextContainer); + if (this.upperCanvasEl) { + this.__initRetinaScaling(scaleRatio, this.upperCanvasEl, this.contextTop); + } + }, + + __initRetinaScaling: function(scaleRatio, canvas, context) { + canvas.setAttribute('width', this.width * scaleRatio); + canvas.setAttribute('height', this.height * scaleRatio); + context.scale(scaleRatio, scaleRatio); + }, + + + /** + * Calculates canvas element offset relative to the document + * This method is also attached as "resize" event handler of window + * @return {fabric.Canvas} instance + * @chainable + */ + calcOffset: function () { + this._offset = getElementOffset(this.lowerCanvasEl); + return this; + }, + + /** + * Sets {@link fabric.StaticCanvas#overlayImage|overlay image} for this canvas + * @param {(fabric.Image|String)} image fabric.Image instance or URL of an image to set overlay to + * @param {Function} callback callback to invoke when image is loaded and set as an overlay + * @param {Object} [options] Optional options to set for the {@link fabric.Image|overlay image}. + * @return {fabric.Canvas} thisArg + * @chainable + * @see {@link http://jsfiddle.net/fabricjs/MnzHT/|jsFiddle demo} + * @example Normal overlayImage with left/top = 0 + * canvas.setOverlayImage('http://fabricjs.com/assets/jail_cell_bars.png', canvas.renderAll.bind(canvas), { + * // Needed to position overlayImage at 0/0 + * originX: 'left', + * originY: 'top' + * }); + * @example overlayImage with different properties + * canvas.setOverlayImage('http://fabricjs.com/assets/jail_cell_bars.png', canvas.renderAll.bind(canvas), { + * opacity: 0.5, + * angle: 45, + * left: 400, + * top: 400, + * originX: 'left', + * originY: 'top' + * }); + * @example Stretched overlayImage #1 - width/height correspond to canvas width/height + * fabric.Image.fromURL('http://fabricjs.com/assets/jail_cell_bars.png', function(img, isError) { + * img.set({width: canvas.width, height: canvas.height, originX: 'left', originY: 'top'}); + * canvas.setOverlayImage(img, canvas.renderAll.bind(canvas)); + * }); + * @example Stretched overlayImage #2 - width/height correspond to canvas width/height + * canvas.setOverlayImage('http://fabricjs.com/assets/jail_cell_bars.png', canvas.renderAll.bind(canvas), { + * width: canvas.width, + * height: canvas.height, + * // Needed to position overlayImage at 0/0 + * originX: 'left', + * originY: 'top' + * }); + * @example overlayImage loaded from cross-origin + * canvas.setOverlayImage('http://fabricjs.com/assets/jail_cell_bars.png', canvas.renderAll.bind(canvas), { + * opacity: 0.5, + * angle: 45, + * left: 400, + * top: 400, + * originX: 'left', + * originY: 'top', + * crossOrigin: 'anonymous' + * }); + */ + setOverlayImage: function (image, callback, options) { + return this.__setBgOverlayImage('overlayImage', image, callback, options); + }, + + /** + * Sets {@link fabric.StaticCanvas#backgroundImage|background image} for this canvas + * @param {(fabric.Image|String)} image fabric.Image instance or URL of an image to set background to + * @param {Function} callback Callback to invoke when image is loaded and set as background + * @param {Object} [options] Optional options to set for the {@link fabric.Image|background image}. + * @return {fabric.Canvas} thisArg + * @chainable + * @see {@link http://jsfiddle.net/djnr8o7a/28/|jsFiddle demo} + * @example Normal backgroundImage with left/top = 0 + * canvas.setBackgroundImage('http://fabricjs.com/assets/honey_im_subtle.png', canvas.renderAll.bind(canvas), { + * // Needed to position backgroundImage at 0/0 + * originX: 'left', + * originY: 'top' + * }); + * @example backgroundImage with different properties + * canvas.setBackgroundImage('http://fabricjs.com/assets/honey_im_subtle.png', canvas.renderAll.bind(canvas), { + * opacity: 0.5, + * angle: 45, + * left: 400, + * top: 400, + * originX: 'left', + * originY: 'top' + * }); + * @example Stretched backgroundImage #1 - width/height correspond to canvas width/height + * fabric.Image.fromURL('http://fabricjs.com/assets/honey_im_subtle.png', function(img, isError) { + * img.set({width: canvas.width, height: canvas.height, originX: 'left', originY: 'top'}); + * canvas.setBackgroundImage(img, canvas.renderAll.bind(canvas)); + * }); + * @example Stretched backgroundImage #2 - width/height correspond to canvas width/height + * canvas.setBackgroundImage('http://fabricjs.com/assets/honey_im_subtle.png', canvas.renderAll.bind(canvas), { + * width: canvas.width, + * height: canvas.height, + * // Needed to position backgroundImage at 0/0 + * originX: 'left', + * originY: 'top' + * }); + * @example backgroundImage loaded from cross-origin + * canvas.setBackgroundImage('http://fabricjs.com/assets/honey_im_subtle.png', canvas.renderAll.bind(canvas), { + * opacity: 0.5, + * angle: 45, + * left: 400, + * top: 400, + * originX: 'left', + * originY: 'top', + * crossOrigin: 'anonymous' + * }); + */ + // TODO: fix stretched examples + setBackgroundImage: function (image, callback, options) { + return this.__setBgOverlayImage('backgroundImage', image, callback, options); + }, + + /** + * Sets {@link fabric.StaticCanvas#overlayColor|foreground color} for this canvas + * @param {(String|fabric.Pattern)} overlayColor Color or pattern to set foreground color to + * @param {Function} callback Callback to invoke when foreground color is set + * @return {fabric.Canvas} thisArg + * @chainable + * @see {@link http://jsfiddle.net/fabricjs/pB55h/|jsFiddle demo} + * @example Normal overlayColor - color value + * canvas.setOverlayColor('rgba(255, 73, 64, 0.6)', canvas.renderAll.bind(canvas)); + * @example fabric.Pattern used as overlayColor + * canvas.setOverlayColor({ + * source: 'http://fabricjs.com/assets/escheresque_ste.png' + * }, canvas.renderAll.bind(canvas)); + * @example fabric.Pattern used as overlayColor with repeat and offset + * canvas.setOverlayColor({ + * source: 'http://fabricjs.com/assets/escheresque_ste.png', + * repeat: 'repeat', + * offsetX: 200, + * offsetY: 100 + * }, canvas.renderAll.bind(canvas)); + */ + setOverlayColor: function(overlayColor, callback) { + return this.__setBgOverlayColor('overlayColor', overlayColor, callback); + }, + + /** + * Sets {@link fabric.StaticCanvas#backgroundColor|background color} for this canvas + * @param {(String|fabric.Pattern)} backgroundColor Color or pattern to set background color to + * @param {Function} callback Callback to invoke when background color is set + * @return {fabric.Canvas} thisArg + * @chainable + * @see {@link http://jsfiddle.net/fabricjs/hXzvk/|jsFiddle demo} + * @example Normal backgroundColor - color value + * canvas.setBackgroundColor('rgba(255, 73, 64, 0.6)', canvas.renderAll.bind(canvas)); + * @example fabric.Pattern used as backgroundColor + * canvas.setBackgroundColor({ + * source: 'http://fabricjs.com/assets/escheresque_ste.png' + * }, canvas.renderAll.bind(canvas)); + * @example fabric.Pattern used as backgroundColor with repeat and offset + * canvas.setBackgroundColor({ + * source: 'http://fabricjs.com/assets/escheresque_ste.png', + * repeat: 'repeat', + * offsetX: 200, + * offsetY: 100 + * }, canvas.renderAll.bind(canvas)); + */ + setBackgroundColor: function(backgroundColor, callback) { + return this.__setBgOverlayColor('backgroundColor', backgroundColor, callback); + }, + + /** + * @private + * @param {String} property Property to set ({@link fabric.StaticCanvas#backgroundImage|backgroundImage} + * or {@link fabric.StaticCanvas#overlayImage|overlayImage}) + * @param {(fabric.Image|String|null)} image fabric.Image instance, URL of an image or null to set background or overlay to + * @param {Function} callback Callback to invoke when image is loaded and set as background or overlay. The first argument is the created image, the second argument is a flag indicating whether an error occurred or not. + * @param {Object} [options] Optional options to set for the {@link fabric.Image|image}. + */ + __setBgOverlayImage: function(property, image, callback, options) { + if (typeof image === 'string') { + fabric.util.loadImage(image, function(img, isError) { + if (img) { + var instance = new fabric.Image(img, options); + this[property] = instance; + instance.canvas = this; + } + callback && callback(img, isError); + }, this, options && options.crossOrigin); + } + else { + options && image.setOptions(options); + this[property] = image; + image && (image.canvas = this); + callback && callback(image, false); + } + + return this; + }, + + /** + * @private + * @param {String} property Property to set ({@link fabric.StaticCanvas#backgroundColor|backgroundColor} + * or {@link fabric.StaticCanvas#overlayColor|overlayColor}) + * @param {(Object|String|null)} color Object with pattern information, color value or null + * @param {Function} [callback] Callback is invoked when color is set + */ + __setBgOverlayColor: function(property, color, callback) { + this[property] = color; + this._initGradient(color, property); + this._initPattern(color, property, callback); + return this; + }, + + /** + * @private + */ + _createCanvasElement: function() { + var element = createCanvasElement(); + if (!element) { + throw CANVAS_INIT_ERROR; + } + if (!element.style) { + element.style = { }; + } + if (typeof element.getContext === 'undefined') { + throw CANVAS_INIT_ERROR; + } + return element; + }, + + /** + * @private + * @param {Object} [options] Options object + */ + _initOptions: function (options) { + var lowerCanvasEl = this.lowerCanvasEl; + this._setOptions(options); + + this.width = this.width || parseInt(lowerCanvasEl.width, 10) || 0; + this.height = this.height || parseInt(lowerCanvasEl.height, 10) || 0; + + if (!this.lowerCanvasEl.style) { + return; + } + + lowerCanvasEl.width = this.width; + lowerCanvasEl.height = this.height; + + lowerCanvasEl.style.width = this.width + 'px'; + lowerCanvasEl.style.height = this.height + 'px'; + + this.viewportTransform = this.viewportTransform.slice(); + }, + + /** + * Creates a bottom canvas + * @private + * @param {HTMLElement} [canvasEl] + */ + _createLowerCanvas: function (canvasEl) { + // canvasEl === 'HTMLCanvasElement' does not work on jsdom/node + if (canvasEl && canvasEl.getContext) { + this.lowerCanvasEl = canvasEl; + } + else { + this.lowerCanvasEl = fabric.util.getById(canvasEl) || this._createCanvasElement(); + } + + fabric.util.addClass(this.lowerCanvasEl, 'lower-canvas'); + this._originalCanvasStyle = this.lowerCanvasEl.style; + if (this.interactive) { + this._applyCanvasStyle(this.lowerCanvasEl); + } + + this.contextContainer = this.lowerCanvasEl.getContext('2d'); + }, + + /** + * Returns canvas width (in px) + * @return {Number} + */ + getWidth: function () { + return this.width; + }, + + /** + * Returns canvas height (in px) + * @return {Number} + */ + getHeight: function () { + return this.height; + }, + + /** + * Sets width of this canvas instance + * @param {Number|String} value Value to set width to + * @param {Object} [options] Options object + * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions + * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions + * @return {fabric.Canvas} instance + * @chainable true + */ + setWidth: function (value, options) { + return this.setDimensions({ width: value }, options); + }, + + /** + * Sets height of this canvas instance + * @param {Number|String} value Value to set height to + * @param {Object} [options] Options object + * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions + * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions + * @return {fabric.Canvas} instance + * @chainable true + */ + setHeight: function (value, options) { + return this.setDimensions({ height: value }, options); + }, + + /** + * Sets dimensions (width, height) of this canvas instance. when options.cssOnly flag active you should also supply the unit of measure (px/%/em) + * @param {Object} dimensions Object with width/height properties + * @param {Number|String} [dimensions.width] Width of canvas element + * @param {Number|String} [dimensions.height] Height of canvas element + * @param {Object} [options] Options object + * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions + * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions + * @return {fabric.Canvas} thisArg + * @chainable + */ + setDimensions: function (dimensions, options) { + var cssValue; + + options = options || {}; + + for (var prop in dimensions) { + cssValue = dimensions[prop]; + + if (!options.cssOnly) { + this._setBackstoreDimension(prop, dimensions[prop]); + cssValue += 'px'; + this.hasLostContext = true; + } + + if (!options.backstoreOnly) { + this._setCssDimension(prop, cssValue); + } + } + if (this._isCurrentlyDrawing) { + this.freeDrawingBrush && this.freeDrawingBrush._setBrushStyles(this.contextTop); + } + this._initRetinaScaling(); + this.calcOffset(); + + if (!options.cssOnly) { + this.requestRenderAll(); + } + + return this; + }, + + /** + * Helper for setting width/height + * @private + * @param {String} prop property (width|height) + * @param {Number} value value to set property to + * @return {fabric.Canvas} instance + * @chainable true + */ + _setBackstoreDimension: function (prop, value) { + this.lowerCanvasEl[prop] = value; + + if (this.upperCanvasEl) { + this.upperCanvasEl[prop] = value; + } + + if (this.cacheCanvasEl) { + this.cacheCanvasEl[prop] = value; + } + + this[prop] = value; + + return this; + }, + + /** + * Helper for setting css width/height + * @private + * @param {String} prop property (width|height) + * @param {String} value value to set property to + * @return {fabric.Canvas} instance + * @chainable true + */ + _setCssDimension: function (prop, value) { + this.lowerCanvasEl.style[prop] = value; + + if (this.upperCanvasEl) { + this.upperCanvasEl.style[prop] = value; + } + + if (this.wrapperEl) { + this.wrapperEl.style[prop] = value; + } + + return this; + }, + + /** + * Returns canvas zoom level + * @return {Number} + */ + getZoom: function () { + return this.viewportTransform[0]; + }, + + /** + * Sets viewport transformation of this canvas instance + * @param {Array} vpt a Canvas 2D API transform matrix + * @return {fabric.Canvas} instance + * @chainable true + */ + setViewportTransform: function (vpt) { + var activeObject = this._activeObject, + backgroundObject = this.backgroundImage, + overlayObject = this.overlayImage, + object, i, len; + this.viewportTransform = vpt; + for (i = 0, len = this._objects.length; i < len; i++) { + object = this._objects[i]; + object.group || object.setCoords(true); + } + if (activeObject) { + activeObject.setCoords(); + } + if (backgroundObject) { + backgroundObject.setCoords(true); + } + if (overlayObject) { + overlayObject.setCoords(true); + } + this.calcViewportBoundaries(); + this.renderOnAddRemove && this.requestRenderAll(); + return this; + }, + + /** + * Sets zoom level of this canvas instance, the zoom centered around point + * meaning that following zoom to point with the same point will have the visual + * effect of the zoom originating from that point. The point won't move. + * It has nothing to do with canvas center or visual center of the viewport. + * @param {fabric.Point} point to zoom with respect to + * @param {Number} value to set zoom to, less than 1 zooms out + * @return {fabric.Canvas} instance + * @chainable true + */ + zoomToPoint: function (point, value) { + // TODO: just change the scale, preserve other transformations + var before = point, vpt = this.viewportTransform.slice(0); + point = transformPoint(point, invertTransform(this.viewportTransform)); + vpt[0] = value; + vpt[3] = value; + var after = transformPoint(point, vpt); + vpt[4] += before.x - after.x; + vpt[5] += before.y - after.y; + return this.setViewportTransform(vpt); + }, + + /** + * Sets zoom level of this canvas instance + * @param {Number} value to set zoom to, less than 1 zooms out + * @return {fabric.Canvas} instance + * @chainable true + */ + setZoom: function (value) { + this.zoomToPoint(new fabric.Point(0, 0), value); + return this; + }, + + /** + * Pan viewport so as to place point at top left corner of canvas + * @param {fabric.Point} point to move to + * @return {fabric.Canvas} instance + * @chainable true + */ + absolutePan: function (point) { + var vpt = this.viewportTransform.slice(0); + vpt[4] = -point.x; + vpt[5] = -point.y; + return this.setViewportTransform(vpt); + }, + + /** + * Pans viewpoint relatively + * @param {fabric.Point} point (position vector) to move by + * @return {fabric.Canvas} instance + * @chainable true + */ + relativePan: function (point) { + return this.absolutePan(new fabric.Point( + -point.x - this.viewportTransform[4], + -point.y - this.viewportTransform[5] + )); + }, + + /** + * Returns <canvas> element corresponding to this instance + * @return {HTMLCanvasElement} + */ + getElement: function () { + return this.lowerCanvasEl; + }, + + /** + * @private + * @param {fabric.Object} obj Object that was added + */ + _onObjectAdded: function(obj) { + this.stateful && obj.setupState(); + obj._set('canvas', this); + obj.setCoords(); + this.fire('object:added', { target: obj }); + obj.fire('added'); + }, + + /** + * @private + * @param {fabric.Object} obj Object that was removed + */ + _onObjectRemoved: function(obj) { + this.fire('object:removed', { target: obj }); + obj.fire('removed'); + delete obj.canvas; + }, + + /** + * Clears specified context of canvas element + * @param {CanvasRenderingContext2D} ctx Context to clear + * @return {fabric.Canvas} thisArg + * @chainable + */ + clearContext: function(ctx) { + ctx.clearRect(0, 0, this.width, this.height); + return this; + }, + + /** + * Returns context of canvas where objects are drawn + * @return {CanvasRenderingContext2D} + */ + getContext: function () { + return this.contextContainer; + }, + + /** + * Clears all contexts (background, main, top) of an instance + * @return {fabric.Canvas} thisArg + * @chainable + */ + clear: function () { + this.remove.apply(this, this.getObjects()); + this.backgroundImage = null; + this.overlayImage = null; + this.backgroundColor = ''; + this.overlayColor = ''; + if (this._hasITextHandlers) { + this.off('mouse:up', this._mouseUpITextHandler); + this._iTextInstances = null; + this._hasITextHandlers = false; + } + this.clearContext(this.contextContainer); + this.fire('canvas:cleared'); + this.renderOnAddRemove && this.requestRenderAll(); + return this; + }, + + /** + * Renders the canvas + * @return {fabric.Canvas} instance + * @chainable + */ + renderAll: function () { + var canvasToDrawOn = this.contextContainer; + this.renderCanvas(canvasToDrawOn, this._objects); + return this; + }, + + /** + * Function created to be instance bound at initialization + * used in requestAnimationFrame rendering + * Let the fabricJS call it. If you call it manually you could have more + * animationFrame stacking on to of each other + * for an imperative rendering, use canvas.renderAll + * @private + * @return {fabric.Canvas} instance + * @chainable + */ + renderAndReset: function() { + this.isRendering = 0; + this.renderAll(); + }, + + /** + * Append a renderAll request to next animation frame. + * unless one is already in progress, in that case nothing is done + * a boolean flag will avoid appending more. + * @return {fabric.Canvas} instance + * @chainable + */ + requestRenderAll: function () { + if (!this.isRendering) { + this.isRendering = fabric.util.requestAnimFrame(this.renderAndResetBound); + } + return this; + }, + + /** + * Calculate the position of the 4 corner of canvas with current viewportTransform. + * helps to determinate when an object is in the current rendering viewport using + * object absolute coordinates ( aCoords ) + * @return {Object} points.tl + * @chainable + */ + calcViewportBoundaries: function() { + var points = { }, width = this.width, height = this.height, + iVpt = invertTransform(this.viewportTransform); + points.tl = transformPoint({ x: 0, y: 0 }, iVpt); + points.br = transformPoint({ x: width, y: height }, iVpt); + points.tr = new fabric.Point(points.br.x, points.tl.y); + points.bl = new fabric.Point(points.tl.x, points.br.y); + this.vptCoords = points; + return points; + }, + + cancelRequestedRender: function() { + if (this.isRendering) { + fabric.util.cancelAnimFrame(this.isRendering); + this.isRendering = 0; + } + }, + + /** + * Renders background, objects, overlay and controls. + * @param {CanvasRenderingContext2D} ctx + * @param {Array} objects to render + * @return {fabric.Canvas} instance + * @chainable + */ + renderCanvas: function(ctx, objects) { + var v = this.viewportTransform, path = this.clipPath; + this.cancelRequestedRender(); + this.calcViewportBoundaries(); + this.clearContext(ctx); + fabric.util.setImageSmoothing(ctx, this.imageSmoothingEnabled); + this.fire('before:render', { ctx: ctx, }); + this._renderBackground(ctx); + + ctx.save(); + //apply viewport transform once for all rendering process + ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]); + this._renderObjects(ctx, objects); + ctx.restore(); + if (!this.controlsAboveOverlay && this.interactive) { + this.drawControls(ctx); + } + if (path) { + path.canvas = this; + // needed to setup a couple of variables + path.shouldCache(); + path._transformDone = true; + path.renderCache({ forClipping: true }); + this.drawClipPathOnCanvas(ctx); + } + this._renderOverlay(ctx); + if (this.controlsAboveOverlay && this.interactive) { + this.drawControls(ctx); + } + this.fire('after:render', { ctx: ctx, }); + }, + + /** + * Paint the cached clipPath on the lowerCanvasEl + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + drawClipPathOnCanvas: function(ctx) { + var v = this.viewportTransform, path = this.clipPath; + ctx.save(); + ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]); + // DEBUG: uncomment this line, comment the following + // ctx.globalAlpha = 0.4; + ctx.globalCompositeOperation = 'destination-in'; + path.transform(ctx); + ctx.scale(1 / path.zoomX, 1 / path.zoomY); + ctx.drawImage(path._cacheCanvas, -path.cacheTranslationX, -path.cacheTranslationY); + ctx.restore(); + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + * @param {Array} objects to render + */ + _renderObjects: function(ctx, objects) { + var i, len; + for (i = 0, len = objects.length; i < len; ++i) { + objects[i] && objects[i].render(ctx); + } + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + * @param {string} property 'background' or 'overlay' + */ + _renderBackgroundOrOverlay: function(ctx, property) { + var fill = this[property + 'Color'], object = this[property + 'Image'], + v = this.viewportTransform, needsVpt = this[property + 'Vpt']; + if (!fill && !object) { + return; + } + if (fill) { + ctx.save(); + ctx.beginPath(); + ctx.moveTo(0, 0); + ctx.lineTo(this.width, 0); + ctx.lineTo(this.width, this.height); + ctx.lineTo(0, this.height); + ctx.closePath(); + ctx.fillStyle = fill.toLive + ? fill.toLive(ctx, this) + : fill; + if (needsVpt) { + ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]); + } + ctx.transform(1, 0, 0, 1, fill.offsetX || 0, fill.offsetY || 0); + var m = fill.gradientTransform || fill.patternTransform; + m && ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]); + ctx.fill(); + ctx.restore(); + } + if (object) { + ctx.save(); + if (needsVpt) { + ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]); + } + object.render(ctx); + ctx.restore(); + } + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _renderBackground: function(ctx) { + this._renderBackgroundOrOverlay(ctx, 'background'); + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _renderOverlay: function(ctx) { + this._renderBackgroundOrOverlay(ctx, 'overlay'); + }, + + /** + * Returns coordinates of a center of canvas. + * Returned value is an object with top and left properties + * @return {Object} object with "top" and "left" number values + * @deprecated migrate to `getCenterPoint` + */ + getCenter: function () { + return { + top: this.height / 2, + left: this.width / 2 + }; + }, + + /** + * Returns coordinates of a center of canvas. + * @return {fabric.Point} + */ + getCenterPoint: function () { + return new fabric.Point(this.width / 2, this.height / 2); + }, + + /** + * Centers object horizontally in the canvas + * @param {fabric.Object} object Object to center horizontally + * @return {fabric.Canvas} thisArg + */ + centerObjectH: function (object) { + return this._centerObject(object, new fabric.Point(this.getCenterPoint().x, object.getCenterPoint().y)); + }, + + /** + * Centers object vertically in the canvas + * @param {fabric.Object} object Object to center vertically + * @return {fabric.Canvas} thisArg + * @chainable + */ + centerObjectV: function (object) { + return this._centerObject(object, new fabric.Point(object.getCenterPoint().x, this.getCenterPoint().y)); + }, + + /** + * Centers object vertically and horizontally in the canvas + * @param {fabric.Object} object Object to center vertically and horizontally + * @return {fabric.Canvas} thisArg + * @chainable + */ + centerObject: function(object) { + var center = this.getCenterPoint(); + return this._centerObject(object, center); + }, + + /** + * Centers object vertically and horizontally in the viewport + * @param {fabric.Object} object Object to center vertically and horizontally + * @return {fabric.Canvas} thisArg + * @chainable + */ + viewportCenterObject: function(object) { + var vpCenter = this.getVpCenter(); + return this._centerObject(object, vpCenter); + }, + + /** + * Centers object horizontally in the viewport, object.top is unchanged + * @param {fabric.Object} object Object to center vertically and horizontally + * @return {fabric.Canvas} thisArg + * @chainable + */ + viewportCenterObjectH: function(object) { + var vpCenter = this.getVpCenter(); + this._centerObject(object, new fabric.Point(vpCenter.x, object.getCenterPoint().y)); + return this; + }, + + /** + * Centers object Vertically in the viewport, object.top is unchanged + * @param {fabric.Object} object Object to center vertically and horizontally + * @return {fabric.Canvas} thisArg + * @chainable + */ + viewportCenterObjectV: function(object) { + var vpCenter = this.getVpCenter(); + + return this._centerObject(object, new fabric.Point(object.getCenterPoint().x, vpCenter.y)); + }, + + /** + * Calculate the point in canvas that correspond to the center of actual viewport. + * @return {fabric.Point} vpCenter, viewport center + * @chainable + */ + getVpCenter: function() { + var center = this.getCenterPoint(), + iVpt = invertTransform(this.viewportTransform); + return transformPoint(center, iVpt); + }, + + /** + * @private + * @param {fabric.Object} object Object to center + * @param {fabric.Point} center Center point + * @return {fabric.Canvas} thisArg + * @chainable + */ + _centerObject: function(object, center) { + object.setPositionByOrigin(center, 'center', 'center'); + object.setCoords(); + this.renderOnAddRemove && this.requestRenderAll(); + return this; + }, + + /** + * Returns dataless JSON representation of canvas + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {String} json string + */ + toDatalessJSON: function (propertiesToInclude) { + return this.toDatalessObject(propertiesToInclude); + }, + + /** + * Returns object representation of canvas + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toObject: function (propertiesToInclude) { + return this._toObjectMethod('toObject', propertiesToInclude); + }, + + /** + * Returns dataless object representation of canvas + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toDatalessObject: function (propertiesToInclude) { + return this._toObjectMethod('toDatalessObject', propertiesToInclude); + }, + + /** + * @private + */ + _toObjectMethod: function (methodName, propertiesToInclude) { + + var clipPath = this.clipPath, data = { + version: fabric.version, + objects: this._toObjects(methodName, propertiesToInclude), + }; + if (clipPath && !clipPath.excludeFromExport) { + data.clipPath = this._toObject(this.clipPath, methodName, propertiesToInclude); + } + extend(data, this.__serializeBgOverlay(methodName, propertiesToInclude)); + + fabric.util.populateWithProperties(this, data, propertiesToInclude); + + return data; + }, + + /** + * @private + */ + _toObjects: function(methodName, propertiesToInclude) { + return this._objects.filter(function(object) { + return !object.excludeFromExport; + }).map(function(instance) { + return this._toObject(instance, methodName, propertiesToInclude); + }, this); + }, + + /** + * @private + */ + _toObject: function(instance, methodName, propertiesToInclude) { + var originalValue; + + if (!this.includeDefaultValues) { + originalValue = instance.includeDefaultValues; + instance.includeDefaultValues = false; + } + + var object = instance[methodName](propertiesToInclude); + if (!this.includeDefaultValues) { + instance.includeDefaultValues = originalValue; + } + return object; + }, + + /** + * @private + */ + __serializeBgOverlay: function(methodName, propertiesToInclude) { + var data = {}, bgImage = this.backgroundImage, overlayImage = this.overlayImage, + bgColor = this.backgroundColor, overlayColor = this.overlayColor; + + if (bgColor && bgColor.toObject) { + if (!bgColor.excludeFromExport) { + data.background = bgColor.toObject(propertiesToInclude); + } + } + else if (bgColor) { + data.background = bgColor; + } + + if (overlayColor && overlayColor.toObject) { + if (!overlayColor.excludeFromExport) { + data.overlay = overlayColor.toObject(propertiesToInclude); + } + } + else if (overlayColor) { + data.overlay = overlayColor; + } + + if (bgImage && !bgImage.excludeFromExport) { + data.backgroundImage = this._toObject(bgImage, methodName, propertiesToInclude); + } + if (overlayImage && !overlayImage.excludeFromExport) { + data.overlayImage = this._toObject(overlayImage, methodName, propertiesToInclude); + } + + return data; + }, + + /* _TO_SVG_START_ */ + /** + * When true, getSvgTransform() will apply the StaticCanvas.viewportTransform to the SVG transformation. When true, + * a zoomed canvas will then produce zoomed SVG output. + * @type Boolean + * @default + */ + svgViewportTransformation: true, + + /** + * Returns SVG representation of canvas + * @function + * @param {Object} [options] Options object for SVG output + * @param {Boolean} [options.suppressPreamble=false] If true xml tag is not included + * @param {Object} [options.viewBox] SVG viewbox object + * @param {Number} [options.viewBox.x] x-coordinate of viewbox + * @param {Number} [options.viewBox.y] y-coordinate of viewbox + * @param {Number} [options.viewBox.width] Width of viewbox + * @param {Number} [options.viewBox.height] Height of viewbox + * @param {String} [options.encoding=UTF-8] Encoding of SVG output + * @param {String} [options.width] desired width of svg with or without units + * @param {String} [options.height] desired height of svg with or without units + * @param {Function} [reviver] Method for further parsing of svg elements, called after each fabric object converted into svg representation. + * @return {String} SVG string + * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#serialization} + * @see {@link http://jsfiddle.net/fabricjs/jQ3ZZ/|jsFiddle demo} + * @example Normal SVG output + * var svg = canvas.toSVG(); + * @example SVG output without preamble (without <?xml ../>) + * var svg = canvas.toSVG({suppressPreamble: true}); + * @example SVG output with viewBox attribute + * var svg = canvas.toSVG({ + * viewBox: { + * x: 100, + * y: 100, + * width: 200, + * height: 300 + * } + * }); + * @example SVG output with different encoding (default: UTF-8) + * var svg = canvas.toSVG({encoding: 'ISO-8859-1'}); + * @example Modify SVG output with reviver function + * var svg = canvas.toSVG(null, function(svg) { + * return svg.replace('stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; ', ''); + * }); + */ + toSVG: function(options, reviver) { + options || (options = { }); + options.reviver = reviver; + var markup = []; + + this._setSVGPreamble(markup, options); + this._setSVGHeader(markup, options); + if (this.clipPath) { + markup.push('\n'); + } + this._setSVGBgOverlayColor(markup, 'background'); + this._setSVGBgOverlayImage(markup, 'backgroundImage', reviver); + this._setSVGObjects(markup, reviver); + if (this.clipPath) { + markup.push('\n'); + } + this._setSVGBgOverlayColor(markup, 'overlay'); + this._setSVGBgOverlayImage(markup, 'overlayImage', reviver); + + markup.push(''); + + return markup.join(''); + }, + + /** + * @private + */ + _setSVGPreamble: function(markup, options) { + if (options.suppressPreamble) { + return; + } + markup.push( + '\n', + '\n' + ); + }, + + /** + * @private + */ + _setSVGHeader: function(markup, options) { + var width = options.width || this.width, + height = options.height || this.height, + vpt, viewBox = 'viewBox="0 0 ' + this.width + ' ' + this.height + '" ', + NUM_FRACTION_DIGITS = fabric.Object.NUM_FRACTION_DIGITS; + + if (options.viewBox) { + viewBox = 'viewBox="' + + options.viewBox.x + ' ' + + options.viewBox.y + ' ' + + options.viewBox.width + ' ' + + options.viewBox.height + '" '; + } + else { + if (this.svgViewportTransformation) { + vpt = this.viewportTransform; + viewBox = 'viewBox="' + + toFixed(-vpt[4] / vpt[0], NUM_FRACTION_DIGITS) + ' ' + + toFixed(-vpt[5] / vpt[3], NUM_FRACTION_DIGITS) + ' ' + + toFixed(this.width / vpt[0], NUM_FRACTION_DIGITS) + ' ' + + toFixed(this.height / vpt[3], NUM_FRACTION_DIGITS) + '" '; + } + } + + markup.push( + '\n', + 'Created with Fabric.js ', fabric.version, '\n', + '\n', + this.createSVGFontFacesMarkup(), + this.createSVGRefElementsMarkup(), + this.createSVGClipPathMarkup(options), + '\n' + ); + }, + + createSVGClipPathMarkup: function(options) { + var clipPath = this.clipPath; + if (clipPath) { + clipPath.clipPathId = 'CLIPPATH_' + fabric.Object.__uid++; + return '\n' + + this.clipPath.toClipPathSVG(options.reviver) + + '\n'; + } + return ''; + }, + + /** + * Creates markup containing SVG referenced elements like patterns, gradients etc. + * @return {String} + */ + createSVGRefElementsMarkup: function() { + var _this = this, + markup = ['background', 'overlay'].map(function(prop) { + var fill = _this[prop + 'Color']; + if (fill && fill.toLive) { + var shouldTransform = _this[prop + 'Vpt'], vpt = _this.viewportTransform, + object = { + width: _this.width / (shouldTransform ? vpt[0] : 1), + height: _this.height / (shouldTransform ? vpt[3] : 1) + }; + return fill.toSVG( + object, + { additionalTransform: shouldTransform ? fabric.util.matrixToSVG(vpt) : '' } + ); + } + }); + return markup.join(''); + }, + + /** + * Creates markup containing SVG font faces, + * font URLs for font faces must be collected by developers + * and are not extracted from the DOM by fabricjs + * @param {Array} objects Array of fabric objects + * @return {String} + */ + createSVGFontFacesMarkup: function() { + var markup = '', fontList = { }, obj, fontFamily, + style, row, rowIndex, _char, charIndex, i, len, + fontPaths = fabric.fontPaths, objects = []; + + this._objects.forEach(function add(object) { + objects.push(object); + if (object._objects) { + object._objects.forEach(add); + } + }); + + for (i = 0, len = objects.length; i < len; i++) { + obj = objects[i]; + fontFamily = obj.fontFamily; + if (obj.type.indexOf('text') === -1 || fontList[fontFamily] || !fontPaths[fontFamily]) { + continue; + } + fontList[fontFamily] = true; + if (!obj.styles) { + continue; + } + style = obj.styles; + for (rowIndex in style) { + row = style[rowIndex]; + for (charIndex in row) { + _char = row[charIndex]; + fontFamily = _char.fontFamily; + if (!fontList[fontFamily] && fontPaths[fontFamily]) { + fontList[fontFamily] = true; + } + } + } + } + + for (var j in fontList) { + markup += [ + '\t\t@font-face {\n', + '\t\t\tfont-family: \'', j, '\';\n', + '\t\t\tsrc: url(\'', fontPaths[j], '\');\n', + '\t\t}\n' + ].join(''); + } + + if (markup) { + markup = [ + '\t\n' + ].join(''); + } + + return markup; + }, + + /** + * @private + */ + _setSVGObjects: function(markup, reviver) { + var instance, i, len, objects = this._objects; + for (i = 0, len = objects.length; i < len; i++) { + instance = objects[i]; + if (instance.excludeFromExport) { + continue; + } + this._setSVGObject(markup, instance, reviver); + } + }, + + /** + * @private + */ + _setSVGObject: function(markup, instance, reviver) { + markup.push(instance.toSVG(reviver)); + }, + + /** + * @private + */ + _setSVGBgOverlayImage: function(markup, property, reviver) { + if (this[property] && !this[property].excludeFromExport && this[property].toSVG) { + markup.push(this[property].toSVG(reviver)); + } + }, + + /** + * @private + */ + _setSVGBgOverlayColor: function(markup, property) { + var filler = this[property + 'Color'], vpt = this.viewportTransform, finalWidth = this.width, + finalHeight = this.height; + if (!filler) { + return; + } + if (filler.toLive) { + var repeat = filler.repeat, iVpt = fabric.util.invertTransform(vpt), shouldInvert = this[property + 'Vpt'], + additionalTransform = shouldInvert ? fabric.util.matrixToSVG(iVpt) : ''; + markup.push( + '\n' + ); + } + else { + markup.push( + '\n' + ); + } + }, + /* _TO_SVG_END_ */ + + /** + * Moves an object or the objects of a multiple selection + * to the bottom of the stack of drawn objects + * @param {fabric.Object} object Object to send to back + * @return {fabric.Canvas} thisArg + * @chainable + */ + sendToBack: function (object) { + if (!object) { + return this; + } + var activeSelection = this._activeObject, + i, obj, objs; + if (object === activeSelection && object.type === 'activeSelection') { + objs = activeSelection._objects; + for (i = objs.length; i--;) { + obj = objs[i]; + removeFromArray(this._objects, obj); + this._objects.unshift(obj); + } + } + else { + removeFromArray(this._objects, object); + this._objects.unshift(object); + } + this.renderOnAddRemove && this.requestRenderAll(); + return this; + }, + + /** + * Moves an object or the objects of a multiple selection + * to the top of the stack of drawn objects + * @param {fabric.Object} object Object to send + * @return {fabric.Canvas} thisArg + * @chainable + */ + bringToFront: function (object) { + if (!object) { + return this; + } + var activeSelection = this._activeObject, + i, obj, objs; + if (object === activeSelection && object.type === 'activeSelection') { + objs = activeSelection._objects; + for (i = 0; i < objs.length; i++) { + obj = objs[i]; + removeFromArray(this._objects, obj); + this._objects.push(obj); + } + } + else { + removeFromArray(this._objects, object); + this._objects.push(object); + } + this.renderOnAddRemove && this.requestRenderAll(); + return this; + }, + + /** + * Moves an object or a selection down in stack of drawn objects + * An optional parameter, intersecting allows to move the object in behind + * the first intersecting object. Where intersection is calculated with + * bounding box. If no intersection is found, there will not be change in the + * stack. + * @param {fabric.Object} object Object to send + * @param {Boolean} [intersecting] If `true`, send object behind next lower intersecting object + * @return {fabric.Canvas} thisArg + * @chainable + */ + sendBackwards: function (object, intersecting) { + if (!object) { + return this; + } + var activeSelection = this._activeObject, + i, obj, idx, newIdx, objs, objsMoved = 0; + + if (object === activeSelection && object.type === 'activeSelection') { + objs = activeSelection._objects; + for (i = 0; i < objs.length; i++) { + obj = objs[i]; + idx = this._objects.indexOf(obj); + if (idx > 0 + objsMoved) { + newIdx = idx - 1; + removeFromArray(this._objects, obj); + this._objects.splice(newIdx, 0, obj); + } + objsMoved++; + } + } + else { + idx = this._objects.indexOf(object); + if (idx !== 0) { + // if object is not on the bottom of stack + newIdx = this._findNewLowerIndex(object, idx, intersecting); + removeFromArray(this._objects, object); + this._objects.splice(newIdx, 0, object); + } + } + this.renderOnAddRemove && this.requestRenderAll(); + return this; + }, + + /** + * @private + */ + _findNewLowerIndex: function(object, idx, intersecting) { + var newIdx, i; + + if (intersecting) { + newIdx = idx; + + // traverse down the stack looking for the nearest intersecting object + for (i = idx - 1; i >= 0; --i) { + + var isIntersecting = object.intersectsWithObject(this._objects[i]) || + object.isContainedWithinObject(this._objects[i]) || + this._objects[i].isContainedWithinObject(object); + + if (isIntersecting) { + newIdx = i; + break; + } + } + } + else { + newIdx = idx - 1; + } + + return newIdx; + }, + + /** + * Moves an object or a selection up in stack of drawn objects + * An optional parameter, intersecting allows to move the object in front + * of the first intersecting object. Where intersection is calculated with + * bounding box. If no intersection is found, there will not be change in the + * stack. + * @param {fabric.Object} object Object to send + * @param {Boolean} [intersecting] If `true`, send object in front of next upper intersecting object + * @return {fabric.Canvas} thisArg + * @chainable + */ + bringForward: function (object, intersecting) { + if (!object) { + return this; + } + var activeSelection = this._activeObject, + i, obj, idx, newIdx, objs, objsMoved = 0; + + if (object === activeSelection && object.type === 'activeSelection') { + objs = activeSelection._objects; + for (i = objs.length; i--;) { + obj = objs[i]; + idx = this._objects.indexOf(obj); + if (idx < this._objects.length - 1 - objsMoved) { + newIdx = idx + 1; + removeFromArray(this._objects, obj); + this._objects.splice(newIdx, 0, obj); + } + objsMoved++; + } + } + else { + idx = this._objects.indexOf(object); + if (idx !== this._objects.length - 1) { + // if object is not on top of stack (last item in an array) + newIdx = this._findNewUpperIndex(object, idx, intersecting); + removeFromArray(this._objects, object); + this._objects.splice(newIdx, 0, object); + } + } + this.renderOnAddRemove && this.requestRenderAll(); + return this; + }, + + /** + * @private + */ + _findNewUpperIndex: function(object, idx, intersecting) { + var newIdx, i, len; + + if (intersecting) { + newIdx = idx; + + // traverse up the stack looking for the nearest intersecting object + for (i = idx + 1, len = this._objects.length; i < len; ++i) { + + var isIntersecting = object.intersectsWithObject(this._objects[i]) || + object.isContainedWithinObject(this._objects[i]) || + this._objects[i].isContainedWithinObject(object); + + if (isIntersecting) { + newIdx = i; + break; + } + } + } + else { + newIdx = idx + 1; + } + + return newIdx; + }, + + /** + * Moves an object to specified level in stack of drawn objects + * @param {fabric.Object} object Object to send + * @param {Number} index Position to move to + * @return {fabric.Canvas} thisArg + * @chainable + */ + moveTo: function (object, index) { + removeFromArray(this._objects, object); + this._objects.splice(index, 0, object); + return this.renderOnAddRemove && this.requestRenderAll(); + }, + + /** + * Clears a canvas element and dispose objects + * @return {fabric.Canvas} thisArg + * @chainable + */ + dispose: function () { + // cancel eventually ongoing renders + if (this.isRendering) { + fabric.util.cancelAnimFrame(this.isRendering); + this.isRendering = 0; + } + this.forEachObject(function(object) { + object.dispose && object.dispose(); + }); + this._objects = []; + if (this.backgroundImage && this.backgroundImage.dispose) { + this.backgroundImage.dispose(); + } + this.backgroundImage = null; + if (this.overlayImage && this.overlayImage.dispose) { + this.overlayImage.dispose(); + } + this.overlayImage = null; + this._iTextInstances = null; + this.contextContainer = null; + // restore canvas style + this.lowerCanvasEl.classList.remove('lower-canvas'); + fabric.util.setStyle(this.lowerCanvasEl, this._originalCanvasStyle); + delete this._originalCanvasStyle; + // restore canvas size to original size in case retina scaling was applied + this.lowerCanvasEl.setAttribute('width', this.width); + this.lowerCanvasEl.setAttribute('height', this.height); + fabric.util.cleanUpJsdomNode(this.lowerCanvasEl); + this.lowerCanvasEl = undefined; + return this; + }, + + /** + * Returns a string representation of an instance + * @return {String} string representation of an instance + */ + toString: function () { + return '#'; + } + }); + + extend(fabric.StaticCanvas.prototype, fabric.Observable); + extend(fabric.StaticCanvas.prototype, fabric.Collection); + extend(fabric.StaticCanvas.prototype, fabric.DataURLExporter); + + extend(fabric.StaticCanvas, /** @lends fabric.StaticCanvas */ { + + /** + * @static + * @type String + * @default + */ + EMPTY_JSON: '{"objects": [], "background": "white"}', + + /** + * Provides a way to check support of some of the canvas methods + * (either those of HTMLCanvasElement itself, or rendering context) + * + * @param {String} methodName Method to check support for; + * Could be one of "setLineDash" + * @return {Boolean | null} `true` if method is supported (or at least exists), + * `null` if canvas element or context can not be initialized + */ + supports: function (methodName) { + var el = createCanvasElement(); + + if (!el || !el.getContext) { + return null; + } + + var ctx = el.getContext('2d'); + if (!ctx) { + return null; + } + + switch (methodName) { + + case 'setLineDash': + return typeof ctx.setLineDash !== 'undefined'; + + default: + return null; + } + } + }); + + /** + * Returns Object representation of canvas + * this alias is provided because if you call JSON.stringify on an instance, + * the toJSON object will be invoked if it exists. + * Having a toJSON method means you can do JSON.stringify(myCanvas) + * @function + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} JSON compatible object + * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#serialization} + * @see {@link http://jsfiddle.net/fabricjs/pec86/|jsFiddle demo} + * @example JSON without additional properties + * var json = canvas.toJSON(); + * @example JSON with additional properties included + * var json = canvas.toJSON(['lockMovementX', 'lockMovementY', 'lockRotation', 'lockScalingX', 'lockScalingY']); + * @example JSON without default values + * canvas.includeDefaultValues = false; + * var json = canvas.toJSON(); + */ + fabric.StaticCanvas.prototype.toJSON = fabric.StaticCanvas.prototype.toObject; + + if (fabric.isLikelyNode) { + fabric.StaticCanvas.prototype.createPNGStream = function() { + var impl = getNodeCanvas(this.lowerCanvasEl); + return impl && impl.createPNGStream(); + }; + fabric.StaticCanvas.prototype.createJPEGStream = function(opts) { + var impl = getNodeCanvas(this.lowerCanvasEl); + return impl && impl.createJPEGStream(opts); + }; + } +})(); + + +/** + * BaseBrush class + * @class fabric.BaseBrush + * @see {@link http://fabricjs.com/freedrawing|Freedrawing demo} + */ +fabric.BaseBrush = fabric.util.createClass(/** @lends fabric.BaseBrush.prototype */ { + + /** + * Color of a brush + * @type String + * @default + */ + color: 'rgb(0, 0, 0)', + + /** + * Width of a brush, has to be a Number, no string literals + * @type Number + * @default + */ + width: 1, + + /** + * Shadow object representing shadow of this shape. + * Backwards incompatibility note: This property replaces "shadowColor" (String), "shadowOffsetX" (Number), + * "shadowOffsetY" (Number) and "shadowBlur" (Number) since v1.2.12 + * @type fabric.Shadow + * @default + */ + shadow: null, + + /** + * Line endings style of a brush (one of "butt", "round", "square") + * @type String + * @default + */ + strokeLineCap: 'round', + + /** + * Corner style of a brush (one of "bevel", "round", "miter") + * @type String + * @default + */ + strokeLineJoin: 'round', + + /** + * Maximum miter length (used for strokeLineJoin = "miter") of a brush's + * @type Number + * @default + */ + strokeMiterLimit: 10, + + /** + * Stroke Dash Array. + * @type Array + * @default + */ + strokeDashArray: null, + + /** + * When `true`, the free drawing is limited to the whiteboard size. Default to false. + * @type Boolean + * @default false + */ + + limitedToCanvasSize: false, + + + /** + * Sets brush styles + * @private + * @param {CanvasRenderingContext2D} ctx + */ + _setBrushStyles: function (ctx) { + ctx.strokeStyle = this.color; + ctx.lineWidth = this.width; + ctx.lineCap = this.strokeLineCap; + ctx.miterLimit = this.strokeMiterLimit; + ctx.lineJoin = this.strokeLineJoin; + ctx.setLineDash(this.strokeDashArray || []); + }, + + /** + * Sets the transformation on given context + * @param {RenderingContext2d} ctx context to render on + * @private + */ + _saveAndTransform: function(ctx) { + var v = this.canvas.viewportTransform; + ctx.save(); + ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]); + }, + + /** + * Sets brush shadow styles + * @private + */ + _setShadow: function() { + if (!this.shadow) { + return; + } + + var canvas = this.canvas, + shadow = this.shadow, + ctx = canvas.contextTop, + zoom = canvas.getZoom(); + if (canvas && canvas._isRetinaScaling()) { + zoom *= fabric.devicePixelRatio; + } + + ctx.shadowColor = shadow.color; + ctx.shadowBlur = shadow.blur * zoom; + ctx.shadowOffsetX = shadow.offsetX * zoom; + ctx.shadowOffsetY = shadow.offsetY * zoom; + }, + + needsFullRender: function() { + var color = new fabric.Color(this.color); + return color.getAlpha() < 1 || !!this.shadow; + }, + + /** + * Removes brush shadow styles + * @private + */ + _resetShadow: function() { + var ctx = this.canvas.contextTop; + + ctx.shadowColor = ''; + ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0; + }, + + /** + * Check is pointer is outside canvas boundaries + * @param {Object} pointer + * @private + */ + _isOutSideCanvas: function(pointer) { + return pointer.x < 0 || pointer.x > this.canvas.getWidth() || pointer.y < 0 || pointer.y > this.canvas.getHeight(); + } +}); + + +(function() { + /** + * PencilBrush class + * @class fabric.PencilBrush + * @extends fabric.BaseBrush + */ + fabric.PencilBrush = fabric.util.createClass(fabric.BaseBrush, /** @lends fabric.PencilBrush.prototype */ { + + /** + * Discard points that are less than `decimate` pixel distant from each other + * @type Number + * @default 0.4 + */ + decimate: 0.4, + + /** + * Draws a straight line between last recorded point to current pointer + * Used for `shift` functionality + * + * @type boolean + * @default false + */ + drawStraightLine: false, + + /** + * The event modifier key that makes the brush draw a straight line. + * If `null` or 'none' or any other string that is not a modifier key the feature is disabled. + * @type {'altKey' | 'shiftKey' | 'ctrlKey' | 'none' | undefined | null} + */ + straightLineKey: 'shiftKey', + + /** + * Constructor + * @param {fabric.Canvas} canvas + * @return {fabric.PencilBrush} Instance of a pencil brush + */ + initialize: function(canvas) { + this.canvas = canvas; + this._points = []; + }, + + needsFullRender: function () { + return this.callSuper('needsFullRender') || this._hasStraightLine; + }, + + /** + * Invoked inside on mouse down and mouse move + * @param {Object} pointer + */ + _drawSegment: function (ctx, p1, p2) { + var midPoint = p1.midPointFrom(p2); + ctx.quadraticCurveTo(p1.x, p1.y, midPoint.x, midPoint.y); + return midPoint; + }, + + /** + * Invoked on mouse down + * @param {Object} pointer + */ + onMouseDown: function(pointer, options) { + if (!this.canvas._isMainEvent(options.e)) { + return; + } + this.drawStraightLine = options.e[this.straightLineKey]; + this._prepareForDrawing(pointer); + // capture coordinates immediately + // this allows to draw dots (when movement never occurs) + this._captureDrawingPath(pointer); + this._render(); + }, + + /** + * Invoked on mouse move + * @param {Object} pointer + */ + onMouseMove: function(pointer, options) { + if (!this.canvas._isMainEvent(options.e)) { + return; + } + this.drawStraightLine = options.e[this.straightLineKey]; + if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) { + return; + } + if (this._captureDrawingPath(pointer) && this._points.length > 1) { + if (this.needsFullRender()) { + // redraw curve + // clear top canvas + this.canvas.clearContext(this.canvas.contextTop); + this._render(); + } + else { + var points = this._points, length = points.length, ctx = this.canvas.contextTop; + // draw the curve update + this._saveAndTransform(ctx); + if (this.oldEnd) { + ctx.beginPath(); + ctx.moveTo(this.oldEnd.x, this.oldEnd.y); + } + this.oldEnd = this._drawSegment(ctx, points[length - 2], points[length - 1], true); + ctx.stroke(); + ctx.restore(); + } + } + }, + + /** + * Invoked on mouse up + */ + onMouseUp: function(options) { + if (!this.canvas._isMainEvent(options.e)) { + return true; + } + this.drawStraightLine = false; + this.oldEnd = undefined; + this._finalizeAndAddPath(); + return false; + }, + + /** + * @private + * @param {Object} pointer Actual mouse position related to the canvas. + */ + _prepareForDrawing: function(pointer) { + + var p = new fabric.Point(pointer.x, pointer.y); + + this._reset(); + this._addPoint(p); + this.canvas.contextTop.moveTo(p.x, p.y); + }, + + /** + * @private + * @param {fabric.Point} point Point to be added to points array + */ + _addPoint: function(point) { + if (this._points.length > 1 && point.eq(this._points[this._points.length - 1])) { + return false; + } + if (this.drawStraightLine && this._points.length > 1) { + this._hasStraightLine = true; + this._points.pop(); + } + this._points.push(point); + return true; + }, + + /** + * Clear points array and set contextTop canvas style. + * @private + */ + _reset: function() { + this._points = []; + this._setBrushStyles(this.canvas.contextTop); + this._setShadow(); + this._hasStraightLine = false; + }, + + /** + * @private + * @param {Object} pointer Actual mouse position related to the canvas. + */ + _captureDrawingPath: function(pointer) { + var pointerPoint = new fabric.Point(pointer.x, pointer.y); + return this._addPoint(pointerPoint); + }, + + /** + * Draw a smooth path on the topCanvas using quadraticCurveTo + * @private + * @param {CanvasRenderingContext2D} [ctx] + */ + _render: function(ctx) { + var i, len, + p1 = this._points[0], + p2 = this._points[1]; + ctx = ctx || this.canvas.contextTop; + this._saveAndTransform(ctx); + ctx.beginPath(); + //if we only have 2 points in the path and they are the same + //it means that the user only clicked the canvas without moving the mouse + //then we should be drawing a dot. A path isn't drawn between two identical dots + //that's why we set them apart a bit + if (this._points.length === 2 && p1.x === p2.x && p1.y === p2.y) { + var width = this.width / 1000; + p1 = new fabric.Point(p1.x, p1.y); + p2 = new fabric.Point(p2.x, p2.y); + p1.x -= width; + p2.x += width; + } + ctx.moveTo(p1.x, p1.y); + + for (i = 1, len = this._points.length; i < len; i++) { + // we pick the point between pi + 1 & pi + 2 as the + // end point and p1 as our control point. + this._drawSegment(ctx, p1, p2); + p1 = this._points[i]; + p2 = this._points[i + 1]; + } + // Draw last line as a straight line while + // we wait for the next point to be able to calculate + // the bezier control point + ctx.lineTo(p1.x, p1.y); + ctx.stroke(); + ctx.restore(); + }, + + /** + * Converts points to SVG path + * @param {Array} points Array of points + * @return {(string|number)[][]} SVG path commands + */ + convertPointsToSVGPath: function (points) { + var correction = this.width / 1000; + return fabric.util.getSmoothPathFromPoints(points, correction); + }, + + /** + * @private + * @param {(string|number)[][]} pathData SVG path commands + * @returns {boolean} + */ + _isEmptySVGPath: function (pathData) { + var pathString = fabric.util.joinPath(pathData); + return pathString === 'M 0 0 Q 0 0 0 0 L 0 0'; + }, + + /** + * Creates fabric.Path object to add on canvas + * @param {(string|number)[][]} pathData Path data + * @return {fabric.Path} Path to add on canvas + */ + createPath: function(pathData) { + var path = new fabric.Path(pathData, { + fill: null, + stroke: this.color, + strokeWidth: this.width, + strokeLineCap: this.strokeLineCap, + strokeMiterLimit: this.strokeMiterLimit, + strokeLineJoin: this.strokeLineJoin, + strokeDashArray: this.strokeDashArray, + }); + if (this.shadow) { + this.shadow.affectStroke = true; + path.shadow = new fabric.Shadow(this.shadow); + } + + return path; + }, + + /** + * Decimate points array with the decimate value + */ + decimatePoints: function(points, distance) { + if (points.length <= 2) { + return points; + } + var zoom = this.canvas.getZoom(), adjustedDistance = Math.pow(distance / zoom, 2), + i, l = points.length - 1, lastPoint = points[0], newPoints = [lastPoint], + cDistance; + for (i = 1; i < l - 1; i++) { + cDistance = Math.pow(lastPoint.x - points[i].x, 2) + Math.pow(lastPoint.y - points[i].y, 2); + if (cDistance >= adjustedDistance) { + lastPoint = points[i]; + newPoints.push(lastPoint); + } + } + /** + * Add the last point from the original line to the end of the array. + * This ensures decimate doesn't delete the last point on the line, and ensures the line is > 1 point. + */ + newPoints.push(points[l]); + return newPoints; + }, + + /** + * On mouseup after drawing the path on contextTop canvas + * we use the points captured to create an new fabric path object + * and add it to the fabric canvas. + */ + _finalizeAndAddPath: function() { + var ctx = this.canvas.contextTop; + ctx.closePath(); + if (this.decimate) { + this._points = this.decimatePoints(this._points, this.decimate); + } + var pathData = this.convertPointsToSVGPath(this._points); + if (this._isEmptySVGPath(pathData)) { + // do not create 0 width/height paths, as they are + // rendered inconsistently across browsers + // Firefox 4, for example, renders a dot, + // whereas Chrome 10 renders nothing + this.canvas.requestRenderAll(); + return; + } + + var path = this.createPath(pathData); + this.canvas.clearContext(this.canvas.contextTop); + this.canvas.fire('before:path:created', { path: path }); + this.canvas.add(path); + this.canvas.requestRenderAll(); + path.setCoords(); + this._resetShadow(); + + + // fire event 'path' created + this.canvas.fire('path:created', { path: path }); + } + }); +})(); + + +/** + * CircleBrush class + * @class fabric.CircleBrush + */ +fabric.CircleBrush = fabric.util.createClass(fabric.BaseBrush, /** @lends fabric.CircleBrush.prototype */ { + + /** + * Width of a brush + * @type Number + * @default + */ + width: 10, + + /** + * Constructor + * @param {fabric.Canvas} canvas + * @return {fabric.CircleBrush} Instance of a circle brush + */ + initialize: function(canvas) { + this.canvas = canvas; + this.points = []; + }, + + /** + * Invoked inside on mouse down and mouse move + * @param {Object} pointer + */ + drawDot: function(pointer) { + var point = this.addPoint(pointer), + ctx = this.canvas.contextTop; + this._saveAndTransform(ctx); + this.dot(ctx, point); + ctx.restore(); + }, + + dot: function(ctx, point) { + ctx.fillStyle = point.fill; + ctx.beginPath(); + ctx.arc(point.x, point.y, point.radius, 0, Math.PI * 2, false); + ctx.closePath(); + ctx.fill(); + }, + + /** + * Invoked on mouse down + */ + onMouseDown: function(pointer) { + this.points.length = 0; + this.canvas.clearContext(this.canvas.contextTop); + this._setShadow(); + this.drawDot(pointer); + }, + + /** + * Render the full state of the brush + * @private + */ + _render: function() { + var ctx = this.canvas.contextTop, i, len, + points = this.points; + this._saveAndTransform(ctx); + for (i = 0, len = points.length; i < len; i++) { + this.dot(ctx, points[i]); + } + ctx.restore(); + }, + + /** + * Invoked on mouse move + * @param {Object} pointer + */ + onMouseMove: function(pointer) { + if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) { + return; + } + if (this.needsFullRender()) { + this.canvas.clearContext(this.canvas.contextTop); + this.addPoint(pointer); + this._render(); + } + else { + this.drawDot(pointer); + } + }, + + /** + * Invoked on mouse up + */ + onMouseUp: function() { + var originalRenderOnAddRemove = this.canvas.renderOnAddRemove, i, len; + this.canvas.renderOnAddRemove = false; + + var circles = []; + + for (i = 0, len = this.points.length; i < len; i++) { + var point = this.points[i], + circle = new fabric.Circle({ + radius: point.radius, + left: point.x, + top: point.y, + originX: 'center', + originY: 'center', + fill: point.fill + }); + + this.shadow && (circle.shadow = new fabric.Shadow(this.shadow)); + + circles.push(circle); + } + var group = new fabric.Group(circles); + group.canvas = this.canvas; + + this.canvas.fire('before:path:created', { path: group }); + this.canvas.add(group); + this.canvas.fire('path:created', { path: group }); + + this.canvas.clearContext(this.canvas.contextTop); + this._resetShadow(); + this.canvas.renderOnAddRemove = originalRenderOnAddRemove; + this.canvas.requestRenderAll(); + }, + + /** + * @param {Object} pointer + * @return {fabric.Point} Just added pointer point + */ + addPoint: function(pointer) { + var pointerPoint = new fabric.Point(pointer.x, pointer.y), + + circleRadius = fabric.util.getRandomInt( + Math.max(0, this.width - 20), this.width + 20) / 2, + + circleColor = new fabric.Color(this.color) + .setAlpha(fabric.util.getRandomInt(0, 100) / 100) + .toRgba(); + + pointerPoint.radius = circleRadius; + pointerPoint.fill = circleColor; + + this.points.push(pointerPoint); + + return pointerPoint; + } +}); + + +/** + * SprayBrush class + * @class fabric.SprayBrush + */ +fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @lends fabric.SprayBrush.prototype */ { + + /** + * Width of a spray + * @type Number + * @default + */ + width: 10, + + /** + * Density of a spray (number of dots per chunk) + * @type Number + * @default + */ + density: 20, + + /** + * Width of spray dots + * @type Number + * @default + */ + dotWidth: 1, + + /** + * Width variance of spray dots + * @type Number + * @default + */ + dotWidthVariance: 1, + + /** + * Whether opacity of a dot should be random + * @type Boolean + * @default + */ + randomOpacity: false, + + /** + * Whether overlapping dots (rectangles) should be removed (for performance reasons) + * @type Boolean + * @default + */ + optimizeOverlapping: true, + + /** + * Constructor + * @param {fabric.Canvas} canvas + * @return {fabric.SprayBrush} Instance of a spray brush + */ + initialize: function(canvas) { + this.canvas = canvas; + this.sprayChunks = []; + }, + + /** + * Invoked on mouse down + * @param {Object} pointer + */ + onMouseDown: function(pointer) { + this.sprayChunks.length = 0; + this.canvas.clearContext(this.canvas.contextTop); + this._setShadow(); + + this.addSprayChunk(pointer); + this.render(this.sprayChunkPoints); + }, + + /** + * Invoked on mouse move + * @param {Object} pointer + */ + onMouseMove: function(pointer) { + if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) { + return; + } + this.addSprayChunk(pointer); + this.render(this.sprayChunkPoints); + }, + + /** + * Invoked on mouse up + */ + onMouseUp: function() { + var originalRenderOnAddRemove = this.canvas.renderOnAddRemove; + this.canvas.renderOnAddRemove = false; + + var rects = []; + + for (var i = 0, ilen = this.sprayChunks.length; i < ilen; i++) { + var sprayChunk = this.sprayChunks[i]; + + for (var j = 0, jlen = sprayChunk.length; j < jlen; j++) { + + var rect = new fabric.Rect({ + width: sprayChunk[j].width, + height: sprayChunk[j].width, + left: sprayChunk[j].x + 1, + top: sprayChunk[j].y + 1, + originX: 'center', + originY: 'center', + fill: this.color + }); + rects.push(rect); + } + } + + if (this.optimizeOverlapping) { + rects = this._getOptimizedRects(rects); + } + + var group = new fabric.Group(rects); + this.shadow && group.set('shadow', new fabric.Shadow(this.shadow)); + this.canvas.fire('before:path:created', { path: group }); + this.canvas.add(group); + this.canvas.fire('path:created', { path: group }); + + this.canvas.clearContext(this.canvas.contextTop); + this._resetShadow(); + this.canvas.renderOnAddRemove = originalRenderOnAddRemove; + this.canvas.requestRenderAll(); + }, + + /** + * @private + * @param {Array} rects + */ + _getOptimizedRects: function(rects) { + + // avoid creating duplicate rects at the same coordinates + var uniqueRects = { }, key, i, len; + + for (i = 0, len = rects.length; i < len; i++) { + key = rects[i].left + '' + rects[i].top; + if (!uniqueRects[key]) { + uniqueRects[key] = rects[i]; + } + } + var uniqueRectsArray = []; + for (key in uniqueRects) { + uniqueRectsArray.push(uniqueRects[key]); + } + + return uniqueRectsArray; + }, + + /** + * Render new chunk of spray brush + */ + render: function(sprayChunk) { + var ctx = this.canvas.contextTop, i, len; + ctx.fillStyle = this.color; + + this._saveAndTransform(ctx); + + for (i = 0, len = sprayChunk.length; i < len; i++) { + var point = sprayChunk[i]; + if (typeof point.opacity !== 'undefined') { + ctx.globalAlpha = point.opacity; + } + ctx.fillRect(point.x, point.y, point.width, point.width); + } + ctx.restore(); + }, + + /** + * Render all spray chunks + */ + _render: function() { + var ctx = this.canvas.contextTop, i, ilen; + ctx.fillStyle = this.color; + + this._saveAndTransform(ctx); + + for (i = 0, ilen = this.sprayChunks.length; i < ilen; i++) { + this.render(this.sprayChunks[i]); + } + ctx.restore(); + }, + + /** + * @param {Object} pointer + */ + addSprayChunk: function(pointer) { + this.sprayChunkPoints = []; + + var x, y, width, radius = this.width / 2, i; + + for (i = 0; i < this.density; i++) { + + x = fabric.util.getRandomInt(pointer.x - radius, pointer.x + radius); + y = fabric.util.getRandomInt(pointer.y - radius, pointer.y + radius); + + if (this.dotWidthVariance) { + width = fabric.util.getRandomInt( + // bottom clamp width to 1 + Math.max(1, this.dotWidth - this.dotWidthVariance), + this.dotWidth + this.dotWidthVariance); + } + else { + width = this.dotWidth; + } + + var point = new fabric.Point(x, y); + point.width = width; + + if (this.randomOpacity) { + point.opacity = fabric.util.getRandomInt(0, 100) / 100; + } + + this.sprayChunkPoints.push(point); + } + + this.sprayChunks.push(this.sprayChunkPoints); + } +}); + + +/** + * PatternBrush class + * @class fabric.PatternBrush + * @extends fabric.BaseBrush + */ +fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fabric.PatternBrush.prototype */ { + + getPatternSrc: function() { + + var dotWidth = 20, + dotDistance = 5, + patternCanvas = fabric.util.createCanvasElement(), + patternCtx = patternCanvas.getContext('2d'); + + patternCanvas.width = patternCanvas.height = dotWidth + dotDistance; + + patternCtx.fillStyle = this.color; + patternCtx.beginPath(); + patternCtx.arc(dotWidth / 2, dotWidth / 2, dotWidth / 2, 0, Math.PI * 2, false); + patternCtx.closePath(); + patternCtx.fill(); + + return patternCanvas; + }, + + getPatternSrcFunction: function() { + return String(this.getPatternSrc).replace('this.color', '"' + this.color + '"'); + }, + + /** + * Creates "pattern" instance property + * @param {CanvasRenderingContext2D} ctx + */ + getPattern: function(ctx) { + return ctx.createPattern(this.source || this.getPatternSrc(), 'repeat'); + }, + + /** + * Sets brush styles + * @param {CanvasRenderingContext2D} ctx + */ + _setBrushStyles: function(ctx) { + this.callSuper('_setBrushStyles', ctx); + ctx.strokeStyle = this.getPattern(ctx); + }, + + /** + * Creates path + */ + createPath: function(pathData) { + var path = this.callSuper('createPath', pathData), + topLeft = path._getLeftTopCoords().scalarAdd(path.strokeWidth / 2); + + path.stroke = new fabric.Pattern({ + source: this.source || this.getPatternSrcFunction(), + offsetX: -topLeft.x, + offsetY: -topLeft.y + }); + return path; + } +}); + + +(function() { + + var getPointer = fabric.util.getPointer, + degreesToRadians = fabric.util.degreesToRadians, + isTouchEvent = fabric.util.isTouchEvent; + + /** + * Canvas class + * @class fabric.Canvas + * @extends fabric.StaticCanvas + * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#canvas} + * @see {@link fabric.Canvas#initialize} for constructor definition + * + * @fires object:modified at the end of a transform or any change when statefull is true + * @fires object:rotating while an object is being rotated from the control + * @fires object:scaling while an object is being scaled by controls + * @fires object:moving while an object is being dragged + * @fires object:skewing while an object is being skewed from the controls + * + * @fires before:transform before a transform is is started + * @fires before:selection:cleared + * @fires selection:cleared + * @fires selection:updated + * @fires selection:created + * + * @fires path:created after a drawing operation ends and the path is added + * @fires mouse:down + * @fires mouse:move + * @fires mouse:up + * @fires mouse:down:before on mouse down, before the inner fabric logic runs + * @fires mouse:move:before on mouse move, before the inner fabric logic runs + * @fires mouse:up:before on mouse up, before the inner fabric logic runs + * @fires mouse:over + * @fires mouse:out + * @fires mouse:dblclick whenever a native dbl click event fires on the canvas. + * + * @fires dragover + * @fires dragenter + * @fires dragleave + * @fires drop:before before drop event. same native event. This is added to handle edge cases + * @fires drop + * @fires after:render at the end of the render process, receives the context in the callback + * @fires before:render at start the render process, receives the context in the callback + * + */ + fabric.Canvas = fabric.util.createClass(fabric.StaticCanvas, /** @lends fabric.Canvas.prototype */ { + + /** + * Constructor + * @param {HTMLElement | String} el <canvas> element to initialize instance on + * @param {Object} [options] Options object + * @return {Object} thisArg + */ + initialize: function(el, options) { + options || (options = { }); + this.renderAndResetBound = this.renderAndReset.bind(this); + this.requestRenderAllBound = this.requestRenderAll.bind(this); + this._initStatic(el, options); + this._initInteractive(); + this._createCacheCanvas(); + }, + + /** + * When true, objects can be transformed by one side (unproportionally) + * when dragged on the corners that normally would not do that. + * @type Boolean + * @default + * @since fabric 4.0 // changed name and default value + */ + uniformScaling: true, + + /** + * Indicates which key switches uniform scaling. + * values: 'altKey', 'shiftKey', 'ctrlKey'. + * If `null` or 'none' or any other string that is not a modifier key + * feature is disabled. + * totally wrong named. this sounds like `uniform scaling` + * if Canvas.uniformScaling is true, pressing this will set it to false + * and viceversa. + * @since 1.6.2 + * @type String + * @default + */ + uniScaleKey: 'shiftKey', + + /** + * When true, objects use center point as the origin of scale transformation. + * Backwards incompatibility note: This property replaces "centerTransform" (Boolean). + * @since 1.3.4 + * @type Boolean + * @default + */ + centeredScaling: false, + + /** + * When true, objects use center point as the origin of rotate transformation. + * Backwards incompatibility note: This property replaces "centerTransform" (Boolean). + * @since 1.3.4 + * @type Boolean + * @default + */ + centeredRotation: false, + + /** + * Indicates which key enable centered Transform + * values: 'altKey', 'shiftKey', 'ctrlKey'. + * If `null` or 'none' or any other string that is not a modifier key + * feature is disabled feature disabled. + * @since 1.6.2 + * @type String + * @default + */ + centeredKey: 'altKey', + + /** + * Indicates which key enable alternate action on corner + * values: 'altKey', 'shiftKey', 'ctrlKey'. + * If `null` or 'none' or any other string that is not a modifier key + * feature is disabled feature disabled. + * @since 1.6.2 + * @type String + * @default + */ + altActionKey: 'shiftKey', + + /** + * Indicates that canvas is interactive. This property should not be changed. + * @type Boolean + * @default + */ + interactive: true, + + /** + * Indicates whether group selection should be enabled + * @type Boolean + * @default + */ + selection: true, + + /** + * Indicates which key or keys enable multiple click selection + * Pass value as a string or array of strings + * values: 'altKey', 'shiftKey', 'ctrlKey'. + * If `null` or empty or containing any other string that is not a modifier key + * feature is disabled. + * @since 1.6.2 + * @type String|Array + * @default + */ + selectionKey: 'shiftKey', + + /** + * Indicates which key enable alternative selection + * in case of target overlapping with active object + * values: 'altKey', 'shiftKey', 'ctrlKey'. + * For a series of reason that come from the general expectations on how + * things should work, this feature works only for preserveObjectStacking true. + * If `null` or 'none' or any other string that is not a modifier key + * feature is disabled. + * @since 1.6.5 + * @type null|String + * @default + */ + altSelectionKey: null, + + /** + * Color of selection + * @type String + * @default + */ + selectionColor: 'rgba(100, 100, 255, 0.3)', // blue + + /** + * Default dash array pattern + * If not empty the selection border is dashed + * @type Array + */ + selectionDashArray: [], + + /** + * Color of the border of selection (usually slightly darker than color of selection itself) + * @type String + * @default + */ + selectionBorderColor: 'rgba(255, 255, 255, 0.3)', + + /** + * Width of a line used in object/group selection + * @type Number + * @default + */ + selectionLineWidth: 1, + + /** + * Select only shapes that are fully contained in the dragged selection rectangle. + * @type Boolean + * @default + */ + selectionFullyContained: false, + + /** + * Default cursor value used when hovering over an object on canvas + * @type String + * @default + */ + hoverCursor: 'move', + + /** + * Default cursor value used when moving an object on canvas + * @type String + * @default + */ + moveCursor: 'move', + + /** + * Default cursor value used for the entire canvas + * @type String + * @default + */ + defaultCursor: 'default', + + /** + * Cursor value used during free drawing + * @type String + * @default + */ + freeDrawingCursor: 'crosshair', + + /** + * Cursor value used for disabled elements ( corners with disabled action ) + * @type String + * @since 2.0.0 + * @default + */ + notAllowedCursor: 'not-allowed', + + /** + * Default element class that's given to wrapper (div) element of canvas + * @type String + * @default + */ + containerClass: 'canvas-container', + + /** + * When true, object detection happens on per-pixel basis rather than on per-bounding-box + * @type Boolean + * @default + */ + perPixelTargetFind: false, + + /** + * Number of pixels around target pixel to tolerate (consider active) during object detection + * @type Number + * @default + */ + targetFindTolerance: 0, + + /** + * When true, target detection is skipped. Target detection will return always undefined. + * click selection won't work anymore, events will fire with no targets. + * if something is selected before setting it to true, it will be deselected at the first click. + * area selection will still work. check the `selection` property too. + * if you deactivate both, you should look into staticCanvas. + * @type Boolean + * @default + */ + skipTargetFind: false, + + /** + * When true, mouse events on canvas (mousedown/mousemove/mouseup) result in free drawing. + * After mousedown, mousemove creates a shape, + * and then mouseup finalizes it and adds an instance of `fabric.Path` onto canvas. + * @tutorial {@link http://fabricjs.com/fabric-intro-part-4#free_drawing} + * @type Boolean + * @default + */ + isDrawingMode: false, + + /** + * Indicates whether objects should remain in current stack position when selected. + * When false objects are brought to top and rendered as part of the selection group + * @type Boolean + * @default + */ + preserveObjectStacking: false, + + /** + * Indicates the angle that an object will lock to while rotating. + * @type Number + * @since 1.6.7 + * @default + */ + snapAngle: 0, + + /** + * Indicates the distance from the snapAngle the rotation will lock to the snapAngle. + * When `null`, the snapThreshold will default to the snapAngle. + * @type null|Number + * @since 1.6.7 + * @default + */ + snapThreshold: null, + + /** + * Indicates if the right click on canvas can output the context menu or not + * @type Boolean + * @since 1.6.5 + * @default + */ + stopContextMenu: false, + + /** + * Indicates if the canvas can fire right click events + * @type Boolean + * @since 1.6.5 + * @default + */ + fireRightClick: false, + + /** + * Indicates if the canvas can fire middle click events + * @type Boolean + * @since 1.7.8 + * @default + */ + fireMiddleClick: false, + + /** + * Keep track of the subTargets for Mouse Events + * @type fabric.Object[] + */ + targets: [], + + /** + * When the option is enabled, PointerEvent is used instead of MouseEvent. + * @type Boolean + * @default + */ + enablePointerEvents: false, + + /** + * Keep track of the hovered target + * @type fabric.Object + * @private + */ + _hoveredTarget: null, + + /** + * hold the list of nested targets hovered + * @type fabric.Object[] + * @private + */ + _hoveredTargets: [], + + /** + * @private + */ + _initInteractive: function() { + this._currentTransform = null; + this._groupSelector = null; + this._initWrapperElement(); + this._createUpperCanvas(); + this._initEventListeners(); + + this._initRetinaScaling(); + + this.freeDrawingBrush = fabric.PencilBrush && new fabric.PencilBrush(this); + + this.calcOffset(); + }, + + /** + * Divides objects in two groups, one to render immediately + * and one to render as activeGroup. + * @return {Array} objects to render immediately and pushes the other in the activeGroup. + */ + _chooseObjectsToRender: function() { + var activeObjects = this.getActiveObjects(), + object, objsToRender, activeGroupObjects; + + if (activeObjects.length > 0 && !this.preserveObjectStacking) { + objsToRender = []; + activeGroupObjects = []; + for (var i = 0, length = this._objects.length; i < length; i++) { + object = this._objects[i]; + if (activeObjects.indexOf(object) === -1 ) { + objsToRender.push(object); + } + else { + activeGroupObjects.push(object); + } + } + if (activeObjects.length > 1) { + this._activeObject._objects = activeGroupObjects; + } + objsToRender.push.apply(objsToRender, activeGroupObjects); + } + else { + objsToRender = this._objects; + } + return objsToRender; + }, + + /** + * Renders both the top canvas and the secondary container canvas. + * @return {fabric.Canvas} instance + * @chainable + */ + renderAll: function () { + if (this.contextTopDirty && !this._groupSelector && !this.isDrawingMode) { + this.clearContext(this.contextTop); + this.contextTopDirty = false; + } + if (this.hasLostContext) { + this.renderTopLayer(this.contextTop); + this.hasLostContext = false; + } + var canvasToDrawOn = this.contextContainer; + this.renderCanvas(canvasToDrawOn, this._chooseObjectsToRender()); + return this; + }, + + renderTopLayer: function(ctx) { + ctx.save(); + if (this.isDrawingMode && this._isCurrentlyDrawing) { + this.freeDrawingBrush && this.freeDrawingBrush._render(); + this.contextTopDirty = true; + } + // we render the top context - last object + if (this.selection && this._groupSelector) { + this._drawSelection(ctx); + this.contextTopDirty = true; + } + ctx.restore(); + }, + + /** + * Method to render only the top canvas. + * Also used to render the group selection box. + * @return {fabric.Canvas} thisArg + * @chainable + */ + renderTop: function () { + var ctx = this.contextTop; + this.clearContext(ctx); + this.renderTopLayer(ctx); + this.fire('after:render'); + return this; + }, + + /** + * @private + */ + _normalizePointer: function (object, pointer) { + var m = object.calcTransformMatrix(), + invertedM = fabric.util.invertTransform(m), + vptPointer = this.restorePointerVpt(pointer); + return fabric.util.transformPoint(vptPointer, invertedM); + }, + + /** + * Returns true if object is transparent at a certain location + * @param {fabric.Object} target Object to check + * @param {Number} x Left coordinate + * @param {Number} y Top coordinate + * @return {Boolean} + */ + isTargetTransparent: function (target, x, y) { + // in case the target is the activeObject, we cannot execute this optimization + // because we need to draw controls too. + if (target.shouldCache() && target._cacheCanvas && target !== this._activeObject) { + var normalizedPointer = this._normalizePointer(target, {x: x, y: y}), + targetRelativeX = Math.max(target.cacheTranslationX + (normalizedPointer.x * target.zoomX), 0), + targetRelativeY = Math.max(target.cacheTranslationY + (normalizedPointer.y * target.zoomY), 0); + + var isTransparent = fabric.util.isTransparent( + target._cacheContext, Math.round(targetRelativeX), Math.round(targetRelativeY), this.targetFindTolerance); + + return isTransparent; + } + + var ctx = this.contextCache, + originalColor = target.selectionBackgroundColor, v = this.viewportTransform; + + target.selectionBackgroundColor = ''; + + this.clearContext(ctx); + + ctx.save(); + ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]); + target.render(ctx); + ctx.restore(); + + target.selectionBackgroundColor = originalColor; + + var isTransparent = fabric.util.isTransparent( + ctx, x, y, this.targetFindTolerance); + + return isTransparent; + }, + + /** + * takes an event and determines if selection key has been pressed + * @private + * @param {Event} e Event object + */ + _isSelectionKeyPressed: function(e) { + var selectionKeyPressed = false; + + if (Array.isArray(this.selectionKey)) { + selectionKeyPressed = !!this.selectionKey.find(function(key) { return e[key] === true; }); + } + else { + selectionKeyPressed = e[this.selectionKey]; + } + + return selectionKeyPressed; + }, + + /** + * @private + * @param {Event} e Event object + * @param {fabric.Object} target + */ + _shouldClearSelection: function (e, target) { + var activeObjects = this.getActiveObjects(), + activeObject = this._activeObject; + + return ( + !target + || + (target && + activeObject && + activeObjects.length > 1 && + activeObjects.indexOf(target) === -1 && + activeObject !== target && + !this._isSelectionKeyPressed(e)) + || + (target && !target.evented) + || + (target && + !target.selectable && + activeObject && + activeObject !== target) + ); + }, + + /** + * centeredScaling from object can't override centeredScaling from canvas. + * this should be fixed, since object setting should take precedence over canvas. + * also this should be something that will be migrated in the control properties. + * as ability to define the origin of the transformation that the control provide. + * @private + * @param {fabric.Object} target + * @param {String} action + * @param {Boolean} altKey + */ + _shouldCenterTransform: function (target, action, altKey) { + if (!target) { + return; + } + + var centerTransform; + + if (action === 'scale' || action === 'scaleX' || action === 'scaleY' || action === 'resizing') { + centerTransform = this.centeredScaling || target.centeredScaling; + } + else if (action === 'rotate') { + centerTransform = this.centeredRotation || target.centeredRotation; + } + + return centerTransform ? !altKey : altKey; + }, + + /** + * should disappear before release 4.0 + * @private + */ + _getOriginFromCorner: function(target, corner) { + var origin = { + x: target.originX, + y: target.originY + }; + + if (corner === 'ml' || corner === 'tl' || corner === 'bl') { + origin.x = 'right'; + } + else if (corner === 'mr' || corner === 'tr' || corner === 'br') { + origin.x = 'left'; + } + + if (corner === 'tl' || corner === 'mt' || corner === 'tr') { + origin.y = 'bottom'; + } + else if (corner === 'bl' || corner === 'mb' || corner === 'br') { + origin.y = 'top'; + } + return origin; + }, + + /** + * @private + * @param {Boolean} alreadySelected true if target is already selected + * @param {String} corner a string representing the corner ml, mr, tl ... + * @param {Event} e Event object + * @param {fabric.Object} [target] inserted back to help overriding. Unused + */ + _getActionFromCorner: function(alreadySelected, corner, e, target) { + if (!corner || !alreadySelected) { + return 'drag'; + } + var control = target.controls[corner]; + return control.getActionName(e, control, target); + }, + + /** + * @private + * @param {Event} e Event object + * @param {fabric.Object} target + */ + _setupCurrentTransform: function (e, target, alreadySelected) { + if (!target) { + return; + } + + var pointer = this.getPointer(e), corner = target.__corner, + control = target.controls[corner], + actionHandler = (alreadySelected && corner) ? + control.getActionHandler(e, target, control) : fabric.controlsUtils.dragHandler, + action = this._getActionFromCorner(alreadySelected, corner, e, target), + origin = this._getOriginFromCorner(target, corner), + altKey = e[this.centeredKey], + transform = { + target: target, + action: action, + actionHandler: actionHandler, + corner: corner, + scaleX: target.scaleX, + scaleY: target.scaleY, + skewX: target.skewX, + skewY: target.skewY, + // used by transation + offsetX: pointer.x - target.left, + offsetY: pointer.y - target.top, + originX: origin.x, + originY: origin.y, + ex: pointer.x, + ey: pointer.y, + lastX: pointer.x, + lastY: pointer.y, + // unsure they are useful anymore. + // left: target.left, + // top: target.top, + theta: degreesToRadians(target.angle), + // end of unsure + width: target.width * target.scaleX, + shiftKey: e.shiftKey, + altKey: altKey, + original: fabric.util.saveObjectTransform(target), + }; + + if (this._shouldCenterTransform(target, action, altKey)) { + transform.originX = 'center'; + transform.originY = 'center'; + } + transform.original.originX = origin.x; + transform.original.originY = origin.y; + this._currentTransform = transform; + this._beforeTransform(e); + }, + + /** + * Set the cursor type of the canvas element + * @param {String} value Cursor type of the canvas element. + * @see http://www.w3.org/TR/css3-ui/#cursor + */ + setCursor: function (value) { + this.upperCanvasEl.style.cursor = value; + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx to draw the selection on + */ + _drawSelection: function (ctx) { + var selector = this._groupSelector, + viewportStart = new fabric.Point(selector.ex, selector.ey), + start = fabric.util.transformPoint(viewportStart, this.viewportTransform), + viewportExtent = new fabric.Point(selector.ex + selector.left, selector.ey + selector.top), + extent = fabric.util.transformPoint(viewportExtent, this.viewportTransform), + minX = Math.min(start.x, extent.x), + minY = Math.min(start.y, extent.y), + maxX = Math.max(start.x, extent.x), + maxY = Math.max(start.y, extent.y), + strokeOffset = this.selectionLineWidth / 2; + + if (this.selectionColor) { + ctx.fillStyle = this.selectionColor; + ctx.fillRect(minX, minY, maxX - minX, maxY - minY); + } + + if (!this.selectionLineWidth || !this.selectionBorderColor) { + return; + } + ctx.lineWidth = this.selectionLineWidth; + ctx.strokeStyle = this.selectionBorderColor; + + minX += strokeOffset; + minY += strokeOffset; + maxX -= strokeOffset; + maxY -= strokeOffset; + // selection border + fabric.Object.prototype._setLineDash.call(this, ctx, this.selectionDashArray); + ctx.strokeRect(minX, minY, maxX - minX, maxY - minY); + }, + + /** + * Method that determines what object we are clicking on + * the skipGroup parameter is for internal use, is needed for shift+click action + * 11/09/2018 TODO: would be cool if findTarget could discern between being a full target + * or the outside part of the corner. + * @param {Event} e mouse event + * @param {Boolean} skipGroup when true, activeGroup is skipped and only objects are traversed through + * @return {fabric.Object} the target found + */ + findTarget: function (e, skipGroup) { + if (this.skipTargetFind) { + return; + } + + var ignoreZoom = true, + pointer = this.getPointer(e, ignoreZoom), + activeObject = this._activeObject, + aObjects = this.getActiveObjects(), + activeTarget, activeTargetSubs, + isTouch = isTouchEvent(e), + shouldLookForActive = (aObjects.length > 1 && !skipGroup) || aObjects.length === 1; + + // first check current group (if one exists) + // active group does not check sub targets like normal groups. + // if active group just exits. + this.targets = []; + + // if we hit the corner of an activeObject, let's return that. + if (shouldLookForActive && activeObject._findTargetCorner(pointer, isTouch)) { + return activeObject; + } + if (aObjects.length > 1 && !skipGroup && activeObject === this._searchPossibleTargets([activeObject], pointer)) { + return activeObject; + } + if (aObjects.length === 1 && + activeObject === this._searchPossibleTargets([activeObject], pointer)) { + if (!this.preserveObjectStacking) { + return activeObject; + } + else { + activeTarget = activeObject; + activeTargetSubs = this.targets; + this.targets = []; + } + } + var target = this._searchPossibleTargets(this._objects, pointer); + if (e[this.altSelectionKey] && target && activeTarget && target !== activeTarget) { + target = activeTarget; + this.targets = activeTargetSubs; + } + return target; + }, + + /** + * Checks point is inside the object. + * @param {Object} [pointer] x,y object of point coordinates we want to check. + * @param {fabric.Object} obj Object to test against + * @param {Object} [globalPointer] x,y object of point coordinates relative to canvas used to search per pixel target. + * @return {Boolean} true if point is contained within an area of given object + * @private + */ + _checkTarget: function(pointer, obj, globalPointer) { + if (obj && + obj.visible && + obj.evented && + // http://www.geog.ubc.ca/courses/klink/gis.notes/ncgia/u32.html + // http://idav.ucdavis.edu/~okreylos/TAship/Spring2000/PointInPolygon.html + obj.containsPoint(pointer) + ) { + if ((this.perPixelTargetFind || obj.perPixelTargetFind) && !obj.isEditing) { + var isTransparent = this.isTargetTransparent(obj, globalPointer.x, globalPointer.y); + if (!isTransparent) { + return true; + } + } + else { + return true; + } + } + }, + + /** + * Function used to search inside objects an object that contains pointer in bounding box or that contains pointerOnCanvas when painted + * @param {Array} [objects] objects array to look into + * @param {Object} [pointer] x,y object of point coordinates we want to check. + * @return {fabric.Object} object that contains pointer + * @private + */ + _searchPossibleTargets: function(objects, pointer) { + // Cache all targets where their bounding box contains point. + var target, i = objects.length, subTarget; + // Do not check for currently grouped objects, since we check the parent group itself. + // until we call this function specifically to search inside the activeGroup + while (i--) { + var objToCheck = objects[i]; + var pointerToUse = objToCheck.group ? + this._normalizePointer(objToCheck.group, pointer) : pointer; + if (this._checkTarget(pointerToUse, objToCheck, pointer)) { + target = objects[i]; + if (target.subTargetCheck && target instanceof fabric.Group) { + subTarget = this._searchPossibleTargets(target._objects, pointer); + subTarget && this.targets.push(subTarget); + } + break; + } + } + return target; + }, + + /** + * Returns pointer coordinates without the effect of the viewport + * @param {Object} pointer with "x" and "y" number values + * @return {Object} object with "x" and "y" number values + */ + restorePointerVpt: function(pointer) { + return fabric.util.transformPoint( + pointer, + fabric.util.invertTransform(this.viewportTransform) + ); + }, + + /** + * Returns pointer coordinates relative to canvas. + * Can return coordinates with or without viewportTransform. + * ignoreZoom false gives back coordinates that represent + * the point clicked on canvas element. + * ignoreZoom true gives back coordinates after being processed + * by the viewportTransform ( sort of coordinates of what is displayed + * on the canvas where you are clicking. + * ignoreZoom true = HTMLElement coordinates relative to top,left + * ignoreZoom false, default = fabric space coordinates, the same used for shape position + * To interact with your shapes top and left you want to use ignoreZoom true + * most of the time, while ignoreZoom false will give you coordinates + * compatible with the object.oCoords system. + * of the time. + * @param {Event} e + * @param {Boolean} ignoreZoom + * @return {Object} object with "x" and "y" number values + */ + getPointer: function (e, ignoreZoom) { + // return cached values if we are in the event processing chain + if (this._absolutePointer && !ignoreZoom) { + return this._absolutePointer; + } + if (this._pointer && ignoreZoom) { + return this._pointer; + } + + var pointer = getPointer(e), + upperCanvasEl = this.upperCanvasEl, + bounds = upperCanvasEl.getBoundingClientRect(), + boundsWidth = bounds.width || 0, + boundsHeight = bounds.height || 0, + cssScale; + + if (!boundsWidth || !boundsHeight ) { + if ('top' in bounds && 'bottom' in bounds) { + boundsHeight = Math.abs( bounds.top - bounds.bottom ); + } + if ('right' in bounds && 'left' in bounds) { + boundsWidth = Math.abs( bounds.right - bounds.left ); + } + } + + this.calcOffset(); + pointer.x = pointer.x - this._offset.left; + pointer.y = pointer.y - this._offset.top; + if (!ignoreZoom) { + pointer = this.restorePointerVpt(pointer); + } + + var retinaScaling = this.getRetinaScaling(); + if (retinaScaling !== 1) { + pointer.x /= retinaScaling; + pointer.y /= retinaScaling; + } + + if (boundsWidth === 0 || boundsHeight === 0) { + // If bounds are not available (i.e. not visible), do not apply scale. + cssScale = { width: 1, height: 1 }; + } + else { + cssScale = { + width: upperCanvasEl.width / boundsWidth, + height: upperCanvasEl.height / boundsHeight + }; + } + + return { + x: pointer.x * cssScale.width, + y: pointer.y * cssScale.height + }; + }, + + /** + * @private + * @throws {CANVAS_INIT_ERROR} If canvas can not be initialized + */ + _createUpperCanvas: function () { + var lowerCanvasClass = this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/, ''), + lowerCanvasEl = this.lowerCanvasEl, upperCanvasEl = this.upperCanvasEl; + + // there is no need to create a new upperCanvas element if we have already one. + if (upperCanvasEl) { + upperCanvasEl.className = ''; + } + else { + upperCanvasEl = this._createCanvasElement(); + this.upperCanvasEl = upperCanvasEl; + } + fabric.util.addClass(upperCanvasEl, 'upper-canvas ' + lowerCanvasClass); + + this.wrapperEl.appendChild(upperCanvasEl); + + this._copyCanvasStyle(lowerCanvasEl, upperCanvasEl); + this._applyCanvasStyle(upperCanvasEl); + this.contextTop = upperCanvasEl.getContext('2d'); + }, + + /** + * Returns context of top canvas where interactions are drawn + * @returns {CanvasRenderingContext2D} + */ + getTopContext: function () { + return this.contextTop; + }, + + /** + * @private + */ + _createCacheCanvas: function () { + this.cacheCanvasEl = this._createCanvasElement(); + this.cacheCanvasEl.setAttribute('width', this.width); + this.cacheCanvasEl.setAttribute('height', this.height); + this.contextCache = this.cacheCanvasEl.getContext('2d'); + }, + + /** + * @private + */ + _initWrapperElement: function () { + this.wrapperEl = fabric.util.wrapElement(this.lowerCanvasEl, 'div', { + 'class': this.containerClass + }); + fabric.util.setStyle(this.wrapperEl, { + width: this.width + 'px', + height: this.height + 'px', + position: 'relative' + }); + fabric.util.makeElementUnselectable(this.wrapperEl); + }, + + /** + * @private + * @param {HTMLElement} element canvas element to apply styles on + */ + _applyCanvasStyle: function (element) { + var width = this.width || element.width, + height = this.height || element.height; + + fabric.util.setStyle(element, { + position: 'absolute', + width: width + 'px', + height: height + 'px', + left: 0, + top: 0, + 'touch-action': this.allowTouchScrolling ? 'manipulation' : 'none', + '-ms-touch-action': this.allowTouchScrolling ? 'manipulation' : 'none' + }); + element.width = width; + element.height = height; + fabric.util.makeElementUnselectable(element); + }, + + /** + * Copy the entire inline style from one element (fromEl) to another (toEl) + * @private + * @param {Element} fromEl Element style is copied from + * @param {Element} toEl Element copied style is applied to + */ + _copyCanvasStyle: function (fromEl, toEl) { + toEl.style.cssText = fromEl.style.cssText; + }, + + /** + * Returns context of canvas where object selection is drawn + * @return {CanvasRenderingContext2D} + */ + getSelectionContext: function() { + return this.contextTop; + }, + + /** + * Returns <canvas> element on which object selection is drawn + * @return {HTMLCanvasElement} + */ + getSelectionElement: function () { + return this.upperCanvasEl; + }, + + /** + * Returns currently active object + * @return {fabric.Object} active object + */ + getActiveObject: function () { + return this._activeObject; + }, + + /** + * Returns an array with the current selected objects + * @return {fabric.Object} active object + */ + getActiveObjects: function () { + var active = this._activeObject; + if (active) { + if (active.type === 'activeSelection' && active._objects) { + return active._objects.slice(0); + } + else { + return [active]; + } + } + return []; + }, + + /** + * @private + * @param {fabric.Object} obj Object that was removed + */ + _onObjectRemoved: function(obj) { + // removing active object should fire "selection:cleared" events + if (obj === this._activeObject) { + this.fire('before:selection:cleared', { target: obj }); + this._discardActiveObject(); + this.fire('selection:cleared', { target: obj }); + obj.fire('deselected'); + } + if (obj === this._hoveredTarget){ + this._hoveredTarget = null; + this._hoveredTargets = []; + } + this.callSuper('_onObjectRemoved', obj); + }, + + /** + * @private + * Compares the old activeObject with the current one and fires correct events + * @param {fabric.Object} obj old activeObject + */ + _fireSelectionEvents: function(oldObjects, e) { + var somethingChanged = false, objects = this.getActiveObjects(), + added = [], removed = []; + oldObjects.forEach(function(oldObject) { + if (objects.indexOf(oldObject) === -1) { + somethingChanged = true; + oldObject.fire('deselected', { + e: e, + target: oldObject + }); + removed.push(oldObject); + } + }); + objects.forEach(function(object) { + if (oldObjects.indexOf(object) === -1) { + somethingChanged = true; + object.fire('selected', { + e: e, + target: object + }); + added.push(object); + } + }); + if (oldObjects.length > 0 && objects.length > 0) { + somethingChanged && this.fire('selection:updated', { + e: e, + selected: added, + deselected: removed, + }); + } + else if (objects.length > 0) { + this.fire('selection:created', { + e: e, + selected: added, + }); + } + else if (oldObjects.length > 0) { + this.fire('selection:cleared', { + e: e, + deselected: removed, + }); + } + }, + + /** + * Sets given object as the only active object on canvas + * @param {fabric.Object} object Object to set as an active one + * @param {Event} [e] Event (passed along when firing "object:selected") + * @return {fabric.Canvas} thisArg + * @chainable + */ + setActiveObject: function (object, e) { + var currentActives = this.getActiveObjects(); + this._setActiveObject(object, e); + this._fireSelectionEvents(currentActives, e); + return this; + }, + + /** + * This is a private method for now. + * This is supposed to be equivalent to setActiveObject but without firing + * any event. There is commitment to have this stay this way. + * This is the functional part of setActiveObject. + * @private + * @param {Object} object to set as active + * @param {Event} [e] Event (passed along when firing "object:selected") + * @return {Boolean} true if the selection happened + */ + _setActiveObject: function(object, e) { + if (this._activeObject === object) { + return false; + } + if (!this._discardActiveObject(e, object)) { + return false; + } + if (object.onSelect({ e: e })) { + return false; + } + this._activeObject = object; + return true; + }, + + /** + * This is a private method for now. + * This is supposed to be equivalent to discardActiveObject but without firing + * any events. There is commitment to have this stay this way. + * This is the functional part of discardActiveObject. + * @param {Event} [e] Event (passed along when firing "object:deselected") + * @param {Object} object to set as active + * @return {Boolean} true if the selection happened + * @private + */ + _discardActiveObject: function(e, object) { + var obj = this._activeObject; + if (obj) { + // onDeselect return TRUE to cancel selection; + if (obj.onDeselect({ e: e, object: object })) { + return false; + } + this._activeObject = null; + } + return true; + }, + + /** + * Discards currently active object and fire events. If the function is called by fabric + * as a consequence of a mouse event, the event is passed as a parameter and + * sent to the fire function for the custom events. When used as a method the + * e param does not have any application. + * @param {event} e + * @return {fabric.Canvas} thisArg + * @chainable + */ + discardActiveObject: function (e) { + var currentActives = this.getActiveObjects(), activeObject = this.getActiveObject(); + if (currentActives.length) { + this.fire('before:selection:cleared', { target: activeObject, e: e }); + } + this._discardActiveObject(e); + this._fireSelectionEvents(currentActives, e); + return this; + }, + + /** + * Clears a canvas element and removes all event listeners + * @return {fabric.Canvas} thisArg + * @chainable + */ + dispose: function () { + var wrapper = this.wrapperEl; + this.removeListeners(); + wrapper.removeChild(this.upperCanvasEl); + wrapper.removeChild(this.lowerCanvasEl); + this.contextCache = null; + this.contextTop = null; + ['upperCanvasEl', 'cacheCanvasEl'].forEach((function(element) { + fabric.util.cleanUpJsdomNode(this[element]); + this[element] = undefined; + }).bind(this)); + if (wrapper.parentNode) { + wrapper.parentNode.replaceChild(this.lowerCanvasEl, this.wrapperEl); + } + delete this.wrapperEl; + fabric.StaticCanvas.prototype.dispose.call(this); + return this; + }, + + /** + * Clears all contexts (background, main, top) of an instance + * @return {fabric.Canvas} thisArg + * @chainable + */ + clear: function () { + // this.discardActiveGroup(); + this.discardActiveObject(); + this.clearContext(this.contextTop); + return this.callSuper('clear'); + }, + + /** + * Draws objects' controls (borders/controls) + * @param {CanvasRenderingContext2D} ctx Context to render controls on + */ + drawControls: function(ctx) { + var activeObject = this._activeObject; + + if (activeObject) { + activeObject._renderControls(ctx); + } + }, + + /** + * @private + */ + _toObject: function(instance, methodName, propertiesToInclude) { + //If the object is part of the current selection group, it should + //be transformed appropriately + //i.e. it should be serialised as it would appear if the selection group + //were to be destroyed. + var originalProperties = this._realizeGroupTransformOnObject(instance), + object = this.callSuper('_toObject', instance, methodName, propertiesToInclude); + //Undo the damage we did by changing all of its properties + this._unwindGroupTransformOnObject(instance, originalProperties); + return object; + }, + + /** + * Realises an object's group transformation on it + * @private + * @param {fabric.Object} [instance] the object to transform (gets mutated) + * @returns the original values of instance which were changed + */ + _realizeGroupTransformOnObject: function(instance) { + if (instance.group && instance.group.type === 'activeSelection' && this._activeObject === instance.group) { + var layoutProps = ['angle', 'flipX', 'flipY', 'left', 'scaleX', 'scaleY', 'skewX', 'skewY', 'top']; + //Copy all the positionally relevant properties across now + var originalValues = {}; + layoutProps.forEach(function(prop) { + originalValues[prop] = instance[prop]; + }); + fabric.util.addTransformToObject(instance, this._activeObject.calcOwnMatrix()); + return originalValues; + } + else { + return null; + } + }, + + /** + * Restores the changed properties of instance + * @private + * @param {fabric.Object} [instance] the object to un-transform (gets mutated) + * @param {Object} [originalValues] the original values of instance, as returned by _realizeGroupTransformOnObject + */ + _unwindGroupTransformOnObject: function(instance, originalValues) { + if (originalValues) { + instance.set(originalValues); + } + }, + + /** + * @private + */ + _setSVGObject: function(markup, instance, reviver) { + //If the object is in a selection group, simulate what would happen to that + //object when the group is deselected + var originalProperties = this._realizeGroupTransformOnObject(instance); + this.callSuper('_setSVGObject', markup, instance, reviver); + this._unwindGroupTransformOnObject(instance, originalProperties); + }, + + setViewportTransform: function (vpt) { + if (this.renderOnAddRemove && this._activeObject && this._activeObject.isEditing) { + this._activeObject.clearContextTop(); + } + fabric.StaticCanvas.prototype.setViewportTransform.call(this, vpt); + } + }); + + // copying static properties manually to work around Opera's bug, + // where "prototype" property is enumerable and overrides existing prototype + for (var prop in fabric.StaticCanvas) { + if (prop !== 'prototype') { + fabric.Canvas[prop] = fabric.StaticCanvas[prop]; + } + } +})(); + + +(function() { + + var addListener = fabric.util.addListener, + removeListener = fabric.util.removeListener, + RIGHT_CLICK = 3, MIDDLE_CLICK = 2, LEFT_CLICK = 1, + addEventOptions = { passive: false }; + + function checkClick(e, value) { + return e.button && (e.button === value - 1); + } + + fabric.util.object.extend(fabric.Canvas.prototype, /** @lends fabric.Canvas.prototype */ { + + /** + * Contains the id of the touch event that owns the fabric transform + * @type Number + * @private + */ + mainTouchId: null, + + /** + * Adds mouse listeners to canvas + * @private + */ + _initEventListeners: function () { + // in case we initialized the class twice. This should not happen normally + // but in some kind of applications where the canvas element may be changed + // this is a workaround to having double listeners. + this.removeListeners(); + this._bindEvents(); + this.addOrRemove(addListener, 'add'); + }, + + /** + * return an event prefix pointer or mouse. + * @private + */ + _getEventPrefix: function () { + return this.enablePointerEvents ? 'pointer' : 'mouse'; + }, + + addOrRemove: function(functor, eventjsFunctor) { + var canvasElement = this.upperCanvasEl, + eventTypePrefix = this._getEventPrefix(); + functor(fabric.window, 'resize', this._onResize); + functor(canvasElement, eventTypePrefix + 'down', this._onMouseDown); + functor(canvasElement, eventTypePrefix + 'move', this._onMouseMove, addEventOptions); + functor(canvasElement, eventTypePrefix + 'out', this._onMouseOut); + functor(canvasElement, eventTypePrefix + 'enter', this._onMouseEnter); + functor(canvasElement, 'wheel', this._onMouseWheel); + functor(canvasElement, 'contextmenu', this._onContextMenu); + functor(canvasElement, 'dblclick', this._onDoubleClick); + functor(canvasElement, 'dragover', this._onDragOver); + functor(canvasElement, 'dragenter', this._onDragEnter); + functor(canvasElement, 'dragleave', this._onDragLeave); + functor(canvasElement, 'drop', this._onDrop); + if (!this.enablePointerEvents) { + functor(canvasElement, 'touchstart', this._onTouchStart, addEventOptions); + } + if (typeof eventjs !== 'undefined' && eventjsFunctor in eventjs) { + eventjs[eventjsFunctor](canvasElement, 'gesture', this._onGesture); + eventjs[eventjsFunctor](canvasElement, 'drag', this._onDrag); + eventjs[eventjsFunctor](canvasElement, 'orientation', this._onOrientationChange); + eventjs[eventjsFunctor](canvasElement, 'shake', this._onShake); + eventjs[eventjsFunctor](canvasElement, 'longpress', this._onLongPress); + } + }, + + /** + * Removes all event listeners + */ + removeListeners: function() { + this.addOrRemove(removeListener, 'remove'); + // if you dispose on a mouseDown, before mouse up, you need to clean document to... + var eventTypePrefix = this._getEventPrefix(); + removeListener(fabric.document, eventTypePrefix + 'up', this._onMouseUp); + removeListener(fabric.document, 'touchend', this._onTouchEnd, addEventOptions); + removeListener(fabric.document, eventTypePrefix + 'move', this._onMouseMove, addEventOptions); + removeListener(fabric.document, 'touchmove', this._onMouseMove, addEventOptions); + }, + + /** + * @private + */ + _bindEvents: function() { + if (this.eventsBound) { + // for any reason we pass here twice we do not want to bind events twice. + return; + } + this._onMouseDown = this._onMouseDown.bind(this); + this._onTouchStart = this._onTouchStart.bind(this); + this._onMouseMove = this._onMouseMove.bind(this); + this._onMouseUp = this._onMouseUp.bind(this); + this._onTouchEnd = this._onTouchEnd.bind(this); + this._onResize = this._onResize.bind(this); + this._onGesture = this._onGesture.bind(this); + this._onDrag = this._onDrag.bind(this); + this._onShake = this._onShake.bind(this); + this._onLongPress = this._onLongPress.bind(this); + this._onOrientationChange = this._onOrientationChange.bind(this); + this._onMouseWheel = this._onMouseWheel.bind(this); + this._onMouseOut = this._onMouseOut.bind(this); + this._onMouseEnter = this._onMouseEnter.bind(this); + this._onContextMenu = this._onContextMenu.bind(this); + this._onDoubleClick = this._onDoubleClick.bind(this); + this._onDragOver = this._onDragOver.bind(this); + this._onDragEnter = this._simpleEventHandler.bind(this, 'dragenter'); + this._onDragLeave = this._simpleEventHandler.bind(this, 'dragleave'); + this._onDrop = this._onDrop.bind(this); + this.eventsBound = true; + }, + + /** + * @private + * @param {Event} [e] Event object fired on Event.js gesture + * @param {Event} [self] Inner Event object + */ + _onGesture: function(e, self) { + this.__onTransformGesture && this.__onTransformGesture(e, self); + }, + + /** + * @private + * @param {Event} [e] Event object fired on Event.js drag + * @param {Event} [self] Inner Event object + */ + _onDrag: function(e, self) { + this.__onDrag && this.__onDrag(e, self); + }, + + /** + * @private + * @param {Event} [e] Event object fired on wheel event + */ + _onMouseWheel: function(e) { + this.__onMouseWheel(e); + }, + + /** + * @private + * @param {Event} e Event object fired on mousedown + */ + _onMouseOut: function(e) { + var target = this._hoveredTarget; + this.fire('mouse:out', { target: target, e: e }); + this._hoveredTarget = null; + target && target.fire('mouseout', { e: e }); + + var _this = this; + this._hoveredTargets.forEach(function(_target){ + _this.fire('mouse:out', { target: target, e: e }); + _target && target.fire('mouseout', { e: e }); + }); + this._hoveredTargets = []; + }, + + /** + * @private + * @param {Event} e Event object fired on mouseenter + */ + _onMouseEnter: function(e) { + // This find target and consequent 'mouse:over' is used to + // clear old instances on hovered target. + // calling findTarget has the side effect of killing target.__corner. + // as a short term fix we are not firing this if we are currently transforming. + // as a long term fix we need to separate the action of finding a target with the + // side effects we added to it. + if (!this._currentTransform && !this.findTarget(e)) { + this.fire('mouse:over', { target: null, e: e }); + this._hoveredTarget = null; + this._hoveredTargets = []; + } + }, + + /** + * @private + * @param {Event} [e] Event object fired on Event.js orientation change + * @param {Event} [self] Inner Event object + */ + _onOrientationChange: function(e, self) { + this.__onOrientationChange && this.__onOrientationChange(e, self); + }, + + /** + * @private + * @param {Event} [e] Event object fired on Event.js shake + * @param {Event} [self] Inner Event object + */ + _onShake: function(e, self) { + this.__onShake && this.__onShake(e, self); + }, + + /** + * @private + * @param {Event} [e] Event object fired on Event.js shake + * @param {Event} [self] Inner Event object + */ + _onLongPress: function(e, self) { + this.__onLongPress && this.__onLongPress(e, self); + }, + + /** + * prevent default to allow drop event to be fired + * @private + * @param {Event} [e] Event object fired on Event.js shake + */ + _onDragOver: function(e) { + e.preventDefault(); + var target = this._simpleEventHandler('dragover', e); + this._fireEnterLeaveEvents(target, e); + }, + + /** + * `drop:before` is a an event that allow you to schedule logic + * before the `drop` event. Prefer `drop` event always, but if you need + * to run some drop-disabling logic on an event, since there is no way + * to handle event handlers ordering, use `drop:before` + * @param {Event} e + */ + _onDrop: function (e) { + this._simpleEventHandler('drop:before', e); + return this._simpleEventHandler('drop', e); + }, + + /** + * @private + * @param {Event} e Event object fired on mousedown + */ + _onContextMenu: function (e) { + if (this.stopContextMenu) { + e.stopPropagation(); + e.preventDefault(); + } + return false; + }, + + /** + * @private + * @param {Event} e Event object fired on mousedown + */ + _onDoubleClick: function (e) { + this._cacheTransformEventData(e); + this._handleEvent(e, 'dblclick'); + this._resetTransformEventData(e); + }, + + /** + * Return a the id of an event. + * returns either the pointerId or the identifier or 0 for the mouse event + * @private + * @param {Event} evt Event object + */ + getPointerId: function(evt) { + var changedTouches = evt.changedTouches; + + if (changedTouches) { + return changedTouches[0] && changedTouches[0].identifier; + } + + if (this.enablePointerEvents) { + return evt.pointerId; + } + + return -1; + }, + + /** + * Determines if an event has the id of the event that is considered main + * @private + * @param {evt} event Event object + */ + _isMainEvent: function(evt) { + if (evt.isPrimary === true) { + return true; + } + if (evt.isPrimary === false) { + return false; + } + if (evt.type === 'touchend' && evt.touches.length === 0) { + return true; + } + if (evt.changedTouches) { + return evt.changedTouches[0].identifier === this.mainTouchId; + } + return true; + }, + + /** + * @private + * @param {Event} e Event object fired on mousedown + */ + _onTouchStart: function(e) { + e.preventDefault(); + if (this.mainTouchId === null) { + this.mainTouchId = this.getPointerId(e); + } + this.__onMouseDown(e); + this._resetTransformEventData(); + var canvasElement = this.upperCanvasEl, + eventTypePrefix = this._getEventPrefix(); + addListener(fabric.document, 'touchend', this._onTouchEnd, addEventOptions); + addListener(fabric.document, 'touchmove', this._onMouseMove, addEventOptions); + // Unbind mousedown to prevent double triggers from touch devices + removeListener(canvasElement, eventTypePrefix + 'down', this._onMouseDown); + }, + + /** + * @private + * @param {Event} e Event object fired on mousedown + */ + _onMouseDown: function (e) { + this.__onMouseDown(e); + this._resetTransformEventData(); + var canvasElement = this.upperCanvasEl, + eventTypePrefix = this._getEventPrefix(); + removeListener(canvasElement, eventTypePrefix + 'move', this._onMouseMove, addEventOptions); + addListener(fabric.document, eventTypePrefix + 'up', this._onMouseUp); + addListener(fabric.document, eventTypePrefix + 'move', this._onMouseMove, addEventOptions); + }, + + /** + * @private + * @param {Event} e Event object fired on mousedown + */ + _onTouchEnd: function(e) { + if (e.touches.length > 0) { + // if there are still touches stop here + return; + } + this.__onMouseUp(e); + this._resetTransformEventData(); + this.mainTouchId = null; + var eventTypePrefix = this._getEventPrefix(); + removeListener(fabric.document, 'touchend', this._onTouchEnd, addEventOptions); + removeListener(fabric.document, 'touchmove', this._onMouseMove, addEventOptions); + var _this = this; + if (this._willAddMouseDown) { + clearTimeout(this._willAddMouseDown); + } + this._willAddMouseDown = setTimeout(function() { + // Wait 400ms before rebinding mousedown to prevent double triggers + // from touch devices + addListener(_this.upperCanvasEl, eventTypePrefix + 'down', _this._onMouseDown); + _this._willAddMouseDown = 0; + }, 400); + }, + + /** + * @private + * @param {Event} e Event object fired on mouseup + */ + _onMouseUp: function (e) { + this.__onMouseUp(e); + this._resetTransformEventData(); + var canvasElement = this.upperCanvasEl, + eventTypePrefix = this._getEventPrefix(); + if (this._isMainEvent(e)) { + removeListener(fabric.document, eventTypePrefix + 'up', this._onMouseUp); + removeListener(fabric.document, eventTypePrefix + 'move', this._onMouseMove, addEventOptions); + addListener(canvasElement, eventTypePrefix + 'move', this._onMouseMove, addEventOptions); + } + }, + + /** + * @private + * @param {Event} e Event object fired on mousemove + */ + _onMouseMove: function (e) { + !this.allowTouchScrolling && e.preventDefault && e.preventDefault(); + this.__onMouseMove(e); + }, + + /** + * @private + */ + _onResize: function () { + this.calcOffset(); + }, + + /** + * Decides whether the canvas should be redrawn in mouseup and mousedown events. + * @private + * @param {Object} target + */ + _shouldRender: function(target) { + var activeObject = this._activeObject; + + if ( + !!activeObject !== !!target || + (activeObject && target && (activeObject !== target)) + ) { + // this covers: switch of target, from target to no target, selection of target + // multiSelection with key and mouse + return true; + } + else if (activeObject && activeObject.isEditing) { + // if we mouse up/down over a editing textbox a cursor change, + // there is no need to re render + return false; + } + return false; + }, + + /** + * Method that defines the actions when mouse is released on canvas. + * The method resets the currentTransform parameters, store the image corner + * position in the image object and render the canvas on top. + * @private + * @param {Event} e Event object fired on mouseup + */ + __onMouseUp: function (e) { + var target, transform = this._currentTransform, + groupSelector = this._groupSelector, shouldRender = false, + isClick = (!groupSelector || (groupSelector.left === 0 && groupSelector.top === 0)); + this._cacheTransformEventData(e); + target = this._target; + this._handleEvent(e, 'up:before'); + // if right/middle click just fire events and return + // target undefined will make the _handleEvent search the target + if (checkClick(e, RIGHT_CLICK)) { + if (this.fireRightClick) { + this._handleEvent(e, 'up', RIGHT_CLICK, isClick); + } + return; + } + + if (checkClick(e, MIDDLE_CLICK)) { + if (this.fireMiddleClick) { + this._handleEvent(e, 'up', MIDDLE_CLICK, isClick); + } + this._resetTransformEventData(); + return; + } + + if (this.isDrawingMode && this._isCurrentlyDrawing) { + this._onMouseUpInDrawingMode(e); + return; + } + + if (!this._isMainEvent(e)) { + return; + } + if (transform) { + this._finalizeCurrentTransform(e); + shouldRender = transform.actionPerformed; + } + if (!isClick) { + var targetWasActive = target === this._activeObject; + this._maybeGroupObjects(e); + if (!shouldRender) { + shouldRender = ( + this._shouldRender(target) || + (!targetWasActive && target === this._activeObject) + ); + } + } + var corner, pointer; + if (target) { + corner = target._findTargetCorner( + this.getPointer(e, true), + fabric.util.isTouchEvent(e) + ); + if (target.selectable && target !== this._activeObject && target.activeOn === 'up') { + this.setActiveObject(target, e); + shouldRender = true; + } + else { + var control = target.controls[corner], + mouseUpHandler = control && control.getMouseUpHandler(e, target, control); + if (mouseUpHandler) { + pointer = this.getPointer(e); + mouseUpHandler(e, transform, pointer.x, pointer.y); + } + } + target.isMoving = false; + } + // if we are ending up a transform on a different control or a new object + // fire the original mouse up from the corner that started the transform + if (transform && (transform.target !== target || transform.corner !== corner)) { + var originalControl = transform.target && transform.target.controls[transform.corner], + originalMouseUpHandler = originalControl && originalControl.getMouseUpHandler(e, target, control); + pointer = pointer || this.getPointer(e); + originalMouseUpHandler && originalMouseUpHandler(e, transform, pointer.x, pointer.y); + } + this._setCursorFromEvent(e, target); + this._handleEvent(e, 'up', LEFT_CLICK, isClick); + this._groupSelector = null; + this._currentTransform = null; + // reset the target information about which corner is selected + target && (target.__corner = 0); + if (shouldRender) { + this.requestRenderAll(); + } + else if (!isClick) { + this.renderTop(); + } + }, + + /** + * @private + * Handle event firing for target and subtargets + * @param {Event} e event from mouse + * @param {String} eventType event to fire (up, down or move) + * @return {Fabric.Object} target return the the target found, for internal reasons. + */ + _simpleEventHandler: function(eventType, e) { + var target = this.findTarget(e), + targets = this.targets, + options = { + e: e, + target: target, + subTargets: targets, + }; + this.fire(eventType, options); + target && target.fire(eventType, options); + if (!targets) { + return target; + } + for (var i = 0; i < targets.length; i++) { + targets[i].fire(eventType, options); + } + return target; + }, + + /** + * @private + * Handle event firing for target and subtargets + * @param {Event} e event from mouse + * @param {String} eventType event to fire (up, down or move) + * @param {fabric.Object} targetObj receiving event + * @param {Number} [button] button used in the event 1 = left, 2 = middle, 3 = right + * @param {Boolean} isClick for left button only, indicates that the mouse up happened without move. + */ + _handleEvent: function(e, eventType, button, isClick) { + var target = this._target, + targets = this.targets || [], + options = { + e: e, + target: target, + subTargets: targets, + button: button || LEFT_CLICK, + isClick: isClick || false, + pointer: this._pointer, + absolutePointer: this._absolutePointer, + transform: this._currentTransform + }; + if (eventType === 'up') { + options.currentTarget = this.findTarget(e); + options.currentSubTargets = this.targets; + } + this.fire('mouse:' + eventType, options); + target && target.fire('mouse' + eventType, options); + for (var i = 0; i < targets.length; i++) { + targets[i].fire('mouse' + eventType, options); + } + }, + + /** + * @private + * @param {Event} e send the mouse event that generate the finalize down, so it can be used in the event + */ + _finalizeCurrentTransform: function(e) { + + var transform = this._currentTransform, + target = transform.target, + options = { + e: e, + target: target, + transform: transform, + action: transform.action, + }; + + if (target._scaling) { + target._scaling = false; + } + + target.setCoords(); + + if (transform.actionPerformed || (this.stateful && target.hasStateChanged())) { + this._fire('modified', options); + } + }, + + /** + * @private + * @param {Event} e Event object fired on mousedown + */ + _onMouseDownInDrawingMode: function(e) { + this._isCurrentlyDrawing = true; + if (this.getActiveObject()) { + this.discardActiveObject(e).requestRenderAll(); + } + var pointer = this.getPointer(e); + this.freeDrawingBrush.onMouseDown(pointer, { e: e, pointer: pointer }); + this._handleEvent(e, 'down'); + }, + + /** + * @private + * @param {Event} e Event object fired on mousemove + */ + _onMouseMoveInDrawingMode: function(e) { + if (this._isCurrentlyDrawing) { + var pointer = this.getPointer(e); + this.freeDrawingBrush.onMouseMove(pointer, { e: e, pointer: pointer }); + } + this.setCursor(this.freeDrawingCursor); + this._handleEvent(e, 'move'); + }, + + /** + * @private + * @param {Event} e Event object fired on mouseup + */ + _onMouseUpInDrawingMode: function(e) { + var pointer = this.getPointer(e); + this._isCurrentlyDrawing = this.freeDrawingBrush.onMouseUp({ e: e, pointer: pointer }); + this._handleEvent(e, 'up'); + }, + + /** + * Method that defines the actions when mouse is clicked on canvas. + * The method inits the currentTransform parameters and renders all the + * canvas so the current image can be placed on the top canvas and the rest + * in on the container one. + * @private + * @param {Event} e Event object fired on mousedown + */ + __onMouseDown: function (e) { + this._cacheTransformEventData(e); + this._handleEvent(e, 'down:before'); + var target = this._target; + // if right click just fire events + if (checkClick(e, RIGHT_CLICK)) { + if (this.fireRightClick) { + this._handleEvent(e, 'down', RIGHT_CLICK); + } + return; + } + + if (checkClick(e, MIDDLE_CLICK)) { + if (this.fireMiddleClick) { + this._handleEvent(e, 'down', MIDDLE_CLICK); + } + return; + } + + if (this.isDrawingMode) { + this._onMouseDownInDrawingMode(e); + return; + } + + if (!this._isMainEvent(e)) { + return; + } + + // ignore if some object is being transformed at this moment + if (this._currentTransform) { + return; + } + + var pointer = this._pointer; + // save pointer for check in __onMouseUp event + this._previousPointer = pointer; + var shouldRender = this._shouldRender(target), + shouldGroup = this._shouldGroup(e, target); + if (this._shouldClearSelection(e, target)) { + this.discardActiveObject(e); + } + else if (shouldGroup) { + this._handleGrouping(e, target); + target = this._activeObject; + } + + if (this.selection && (!target || + (!target.selectable && !target.isEditing && target !== this._activeObject))) { + this._groupSelector = { + ex: this._absolutePointer.x, + ey: this._absolutePointer.y, + top: 0, + left: 0 + }; + } + + if (target) { + var alreadySelected = target === this._activeObject; + if (target.selectable && target.activeOn === 'down') { + this.setActiveObject(target, e); + } + var corner = target._findTargetCorner( + this.getPointer(e, true), + fabric.util.isTouchEvent(e) + ); + target.__corner = corner; + if (target === this._activeObject && (corner || !shouldGroup)) { + this._setupCurrentTransform(e, target, alreadySelected); + var control = target.controls[corner], + pointer = this.getPointer(e), + mouseDownHandler = control && control.getMouseDownHandler(e, target, control); + if (mouseDownHandler) { + mouseDownHandler(e, this._currentTransform, pointer.x, pointer.y); + } + } + } + this._handleEvent(e, 'down'); + // we must renderAll so that we update the visuals + (shouldRender || shouldGroup) && this.requestRenderAll(); + }, + + /** + * reset cache form common information needed during event processing + * @private + */ + _resetTransformEventData: function() { + this._target = null; + this._pointer = null; + this._absolutePointer = null; + }, + + /** + * Cache common information needed during event processing + * @private + * @param {Event} e Event object fired on event + */ + _cacheTransformEventData: function(e) { + // reset in order to avoid stale caching + this._resetTransformEventData(); + this._pointer = this.getPointer(e, true); + this._absolutePointer = this.restorePointerVpt(this._pointer); + this._target = this._currentTransform ? this._currentTransform.target : this.findTarget(e) || null; + }, + + /** + * @private + */ + _beforeTransform: function(e) { + var t = this._currentTransform; + this.stateful && t.target.saveState(); + this.fire('before:transform', { + e: e, + transform: t, + }); + }, + + /** + * Method that defines the actions when mouse is hovering the canvas. + * The currentTransform parameter will define whether the user is rotating/scaling/translating + * an image or neither of them (only hovering). A group selection is also possible and would cancel + * all any other type of action. + * In case of an image transformation only the top canvas will be rendered. + * @private + * @param {Event} e Event object fired on mousemove + */ + __onMouseMove: function (e) { + this._handleEvent(e, 'move:before'); + this._cacheTransformEventData(e); + var target, pointer; + + if (this.isDrawingMode) { + this._onMouseMoveInDrawingMode(e); + return; + } + + if (!this._isMainEvent(e)) { + return; + } + + var groupSelector = this._groupSelector; + + // We initially clicked in an empty area, so we draw a box for multiple selection + if (groupSelector) { + pointer = this._absolutePointer; + + groupSelector.left = pointer.x - groupSelector.ex; + groupSelector.top = pointer.y - groupSelector.ey; + + this.renderTop(); + } + else if (!this._currentTransform) { + target = this.findTarget(e) || null; + this._setCursorFromEvent(e, target); + this._fireOverOutEvents(target, e); + } + else { + this._transformObject(e); + } + this._handleEvent(e, 'move'); + this._resetTransformEventData(); + }, + + /** + * Manage the mouseout, mouseover events for the fabric object on the canvas + * @param {Fabric.Object} target the target where the target from the mousemove event + * @param {Event} e Event object fired on mousemove + * @private + */ + _fireOverOutEvents: function(target, e) { + var _hoveredTarget = this._hoveredTarget, + _hoveredTargets = this._hoveredTargets, targets = this.targets, + length = Math.max(_hoveredTargets.length, targets.length); + + this.fireSyntheticInOutEvents(target, e, { + oldTarget: _hoveredTarget, + evtOut: 'mouseout', + canvasEvtOut: 'mouse:out', + evtIn: 'mouseover', + canvasEvtIn: 'mouse:over', + }); + for (var i = 0; i < length; i++){ + this.fireSyntheticInOutEvents(targets[i], e, { + oldTarget: _hoveredTargets[i], + evtOut: 'mouseout', + evtIn: 'mouseover', + }); + } + this._hoveredTarget = target; + this._hoveredTargets = this.targets.concat(); + }, + + /** + * Manage the dragEnter, dragLeave events for the fabric objects on the canvas + * @param {Fabric.Object} target the target where the target from the onDrag event + * @param {Event} e Event object fired on ondrag + * @private + */ + _fireEnterLeaveEvents: function(target, e) { + var _draggedoverTarget = this._draggedoverTarget, + _hoveredTargets = this._hoveredTargets, targets = this.targets, + length = Math.max(_hoveredTargets.length, targets.length); + + this.fireSyntheticInOutEvents(target, e, { + oldTarget: _draggedoverTarget, + evtOut: 'dragleave', + evtIn: 'dragenter', + }); + for (var i = 0; i < length; i++) { + this.fireSyntheticInOutEvents(targets[i], e, { + oldTarget: _hoveredTargets[i], + evtOut: 'dragleave', + evtIn: 'dragenter', + }); + } + this._draggedoverTarget = target; + }, + + /** + * Manage the synthetic in/out events for the fabric objects on the canvas + * @param {Fabric.Object} target the target where the target from the supported events + * @param {Event} e Event object fired + * @param {Object} config configuration for the function to work + * @param {String} config.targetName property on the canvas where the old target is stored + * @param {String} [config.canvasEvtOut] name of the event to fire at canvas level for out + * @param {String} config.evtOut name of the event to fire for out + * @param {String} [config.canvasEvtIn] name of the event to fire at canvas level for in + * @param {String} config.evtIn name of the event to fire for in + * @private + */ + fireSyntheticInOutEvents: function(target, e, config) { + var inOpt, outOpt, oldTarget = config.oldTarget, outFires, inFires, + targetChanged = oldTarget !== target, canvasEvtIn = config.canvasEvtIn, canvasEvtOut = config.canvasEvtOut; + if (targetChanged) { + inOpt = { e: e, target: target, previousTarget: oldTarget }; + outOpt = { e: e, target: oldTarget, nextTarget: target }; + } + inFires = target && targetChanged; + outFires = oldTarget && targetChanged; + if (outFires) { + canvasEvtOut && this.fire(canvasEvtOut, outOpt); + oldTarget.fire(config.evtOut, outOpt); + } + if (inFires) { + canvasEvtIn && this.fire(canvasEvtIn, inOpt); + target.fire(config.evtIn, inOpt); + } + }, + + /** + * Method that defines actions when an Event Mouse Wheel + * @param {Event} e Event object fired on mouseup + */ + __onMouseWheel: function(e) { + this._cacheTransformEventData(e); + this._handleEvent(e, 'wheel'); + this._resetTransformEventData(); + }, + + /** + * @private + * @param {Event} e Event fired on mousemove + */ + _transformObject: function(e) { + var pointer = this.getPointer(e), + transform = this._currentTransform; + + transform.reset = false; + transform.shiftKey = e.shiftKey; + transform.altKey = e[this.centeredKey]; + + this._performTransformAction(e, transform, pointer); + transform.actionPerformed && this.requestRenderAll(); + }, + + /** + * @private + */ + _performTransformAction: function(e, transform, pointer) { + var x = pointer.x, + y = pointer.y, + action = transform.action, + actionPerformed = false, + actionHandler = transform.actionHandler; + // this object could be created from the function in the control handlers + + + if (actionHandler) { + actionPerformed = actionHandler(e, transform, x, y); + } + if (action === 'drag' && actionPerformed) { + transform.target.isMoving = true; + this.setCursor(transform.target.moveCursor || this.moveCursor); + } + transform.actionPerformed = transform.actionPerformed || actionPerformed; + }, + + /** + * @private + */ + _fire: fabric.controlsUtils.fireEvent, + + /** + * Sets the cursor depending on where the canvas is being hovered. + * Note: very buggy in Opera + * @param {Event} e Event object + * @param {Object} target Object that the mouse is hovering, if so. + */ + _setCursorFromEvent: function (e, target) { + if (!target) { + this.setCursor(this.defaultCursor); + return false; + } + var hoverCursor = target.hoverCursor || this.hoverCursor, + activeSelection = this._activeObject && this._activeObject.type === 'activeSelection' ? + this._activeObject : null, + // only show proper corner when group selection is not active + corner = (!activeSelection || !activeSelection.contains(target)) + // here we call findTargetCorner always with undefined for the touch parameter. + // we assume that if you are using a cursor you do not need to interact with + // the bigger touch area. + && target._findTargetCorner(this.getPointer(e, true)); + + if (!corner) { + if (target.subTargetCheck){ + // hoverCursor should come from top-most subTarget, + // so we walk the array backwards + this.targets.concat().reverse().map(function(_target){ + hoverCursor = _target.hoverCursor || hoverCursor; + }); + } + this.setCursor(hoverCursor); + } + else { + this.setCursor(this.getCornerCursor(corner, target, e)); + } + }, + + /** + * @private + */ + getCornerCursor: function(corner, target, e) { + var control = target.controls[corner]; + return control.cursorStyleHandler(e, control, target); + } + }); +})(); + + +(function() { + + var min = Math.min, + max = Math.max; + + fabric.util.object.extend(fabric.Canvas.prototype, /** @lends fabric.Canvas.prototype */ { + + /** + * @private + * @param {Event} e Event object + * @param {fabric.Object} target + * @return {Boolean} + */ + _shouldGroup: function(e, target) { + var activeObject = this._activeObject; + return activeObject && this._isSelectionKeyPressed(e) && target && target.selectable && this.selection && + (activeObject !== target || activeObject.type === 'activeSelection') && !target.onSelect({ e: e }); + }, + + /** + * @private + * @param {Event} e Event object + * @param {fabric.Object} target + */ + _handleGrouping: function (e, target) { + var activeObject = this._activeObject; + // avoid multi select when shift click on a corner + if (activeObject.__corner) { + return; + } + if (target === activeObject) { + // if it's a group, find target again, using activeGroup objects + target = this.findTarget(e, true); + // if even object is not found or we are on activeObjectCorner, bail out + if (!target || !target.selectable) { + return; + } + } + if (activeObject && activeObject.type === 'activeSelection') { + this._updateActiveSelection(target, e); + } + else { + this._createActiveSelection(target, e); + } + }, + + /** + * @private + */ + _updateActiveSelection: function(target, e) { + var activeSelection = this._activeObject, + currentActiveObjects = activeSelection._objects.slice(0); + if (activeSelection.contains(target)) { + activeSelection.removeWithUpdate(target); + this._hoveredTarget = target; + this._hoveredTargets = this.targets.concat(); + if (activeSelection.size() === 1) { + // activate last remaining object + this._setActiveObject(activeSelection.item(0), e); + } + } + else { + activeSelection.addWithUpdate(target); + this._hoveredTarget = activeSelection; + this._hoveredTargets = this.targets.concat(); + } + this._fireSelectionEvents(currentActiveObjects, e); + }, + + /** + * @private + */ + _createActiveSelection: function(target, e) { + var currentActives = this.getActiveObjects(), group = this._createGroup(target); + this._hoveredTarget = group; + // ISSUE 4115: should we consider subTargets here? + // this._hoveredTargets = []; + // this._hoveredTargets = this.targets.concat(); + this._setActiveObject(group, e); + this._fireSelectionEvents(currentActives, e); + }, + + /** + * @private + * @param {Object} target + */ + _createGroup: function(target) { + var objects = this._objects, + isActiveLower = objects.indexOf(this._activeObject) < objects.indexOf(target), + groupObjects = isActiveLower + ? [this._activeObject, target] + : [target, this._activeObject]; + this._activeObject.isEditing && this._activeObject.exitEditing(); + return new fabric.ActiveSelection(groupObjects, { + canvas: this + }); + }, + + /** + * @private + * @param {Event} e mouse event + */ + _groupSelectedObjects: function (e) { + + var group = this._collectObjects(e), + aGroup; + + // do not create group for 1 element only + if (group.length === 1) { + this.setActiveObject(group[0], e); + } + else if (group.length > 1) { + aGroup = new fabric.ActiveSelection(group.reverse(), { + canvas: this + }); + this.setActiveObject(aGroup, e); + } + }, + + /** + * @private + */ + _collectObjects: function(e) { + var group = [], + currentObject, + x1 = this._groupSelector.ex, + y1 = this._groupSelector.ey, + x2 = x1 + this._groupSelector.left, + y2 = y1 + this._groupSelector.top, + selectionX1Y1 = new fabric.Point(min(x1, x2), min(y1, y2)), + selectionX2Y2 = new fabric.Point(max(x1, x2), max(y1, y2)), + allowIntersect = !this.selectionFullyContained, + isClick = x1 === x2 && y1 === y2; + // we iterate reverse order to collect top first in case of click. + for (var i = this._objects.length; i--; ) { + currentObject = this._objects[i]; + + if (!currentObject || !currentObject.selectable || !currentObject.visible) { + continue; + } + + if ((allowIntersect && currentObject.intersectsWithRect(selectionX1Y1, selectionX2Y2, true)) || + currentObject.isContainedWithinRect(selectionX1Y1, selectionX2Y2, true) || + (allowIntersect && currentObject.containsPoint(selectionX1Y1, null, true)) || + (allowIntersect && currentObject.containsPoint(selectionX2Y2, null, true)) + ) { + group.push(currentObject); + // only add one object if it's a click + if (isClick) { + break; + } + } + } + + if (group.length > 1) { + group = group.filter(function(object) { + return !object.onSelect({ e: e }); + }); + } + + return group; + }, + + /** + * @private + */ + _maybeGroupObjects: function(e) { + if (this.selection && this._groupSelector) { + this._groupSelectedObjects(e); + } + this.setCursor(this.defaultCursor); + // clear selection and current transformation + this._groupSelector = null; + } + }); + +})(); + + +(function () { + fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.StaticCanvas.prototype */ { + + /** + * Exports canvas element to a dataurl image. Note that when multiplier is used, cropping is scaled appropriately + * @param {Object} [options] Options object + * @param {String} [options.format=png] The format of the output image. Either "jpeg" or "png" + * @param {Number} [options.quality=1] Quality level (0..1). Only used for jpeg. + * @param {Number} [options.multiplier=1] Multiplier to scale by, to have consistent + * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14 + * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14 + * @param {Number} [options.width] Cropping width. Introduced in v1.2.14 + * @param {Number} [options.height] Cropping height. Introduced in v1.2.14 + * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 2.0.0 + * @return {String} Returns a data: URL containing a representation of the object in the format specified by options.format + * @see {@link http://jsfiddle.net/fabricjs/NfZVb/|jsFiddle demo} + * @example Generate jpeg dataURL with lower quality + * var dataURL = canvas.toDataURL({ + * format: 'jpeg', + * quality: 0.8 + * }); + * @example Generate cropped png dataURL (clipping of canvas) + * var dataURL = canvas.toDataURL({ + * format: 'png', + * left: 100, + * top: 100, + * width: 200, + * height: 200 + * }); + * @example Generate double scaled png dataURL + * var dataURL = canvas.toDataURL({ + * format: 'png', + * multiplier: 2 + * }); + */ + toDataURL: function (options) { + options || (options = { }); + + var format = options.format || 'png', + quality = options.quality || 1, + multiplier = (options.multiplier || 1) * (options.enableRetinaScaling ? this.getRetinaScaling() : 1), + canvasEl = this.toCanvasElement(multiplier, options); + return fabric.util.toDataURL(canvasEl, format, quality); + }, + + /** + * Create a new HTMLCanvas element painted with the current canvas content. + * No need to resize the actual one or repaint it. + * Will transfer object ownership to a new canvas, paint it, and set everything back. + * This is an intermediary step used to get to a dataUrl but also it is useful to + * create quick image copies of a canvas without passing for the dataUrl string + * @param {Number} [multiplier] a zoom factor. + * @param {Object} [cropping] Cropping informations + * @param {Number} [cropping.left] Cropping left offset. + * @param {Number} [cropping.top] Cropping top offset. + * @param {Number} [cropping.width] Cropping width. + * @param {Number} [cropping.height] Cropping height. + */ + toCanvasElement: function(multiplier, cropping) { + multiplier = multiplier || 1; + cropping = cropping || { }; + var scaledWidth = (cropping.width || this.width) * multiplier, + scaledHeight = (cropping.height || this.height) * multiplier, + zoom = this.getZoom(), + originalWidth = this.width, + originalHeight = this.height, + newZoom = zoom * multiplier, + vp = this.viewportTransform, + translateX = (vp[4] - (cropping.left || 0)) * multiplier, + translateY = (vp[5] - (cropping.top || 0)) * multiplier, + originalInteractive = this.interactive, + newVp = [newZoom, 0, 0, newZoom, translateX, translateY], + originalRetina = this.enableRetinaScaling, + canvasEl = fabric.util.createCanvasElement(), + originalContextTop = this.contextTop; + canvasEl.width = scaledWidth; + canvasEl.height = scaledHeight; + this.contextTop = null; + this.enableRetinaScaling = false; + this.interactive = false; + this.viewportTransform = newVp; + this.width = scaledWidth; + this.height = scaledHeight; + this.calcViewportBoundaries(); + this.renderCanvas(canvasEl.getContext('2d'), this._objects); + this.viewportTransform = vp; + this.width = originalWidth; + this.height = originalHeight; + this.calcViewportBoundaries(); + this.interactive = originalInteractive; + this.enableRetinaScaling = originalRetina; + this.contextTop = originalContextTop; + return canvasEl; + }, + }); + +})(); + + +fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.StaticCanvas.prototype */ { + /** + * Populates canvas with data from the specified JSON. + * JSON format must conform to the one of {@link fabric.Canvas#toJSON} + * @param {String|Object} json JSON string or object + * @param {Function} callback Callback, invoked when json is parsed + * and corresponding objects (e.g: {@link fabric.Image}) + * are initialized + * @param {Function} [reviver] Method for further parsing of JSON elements, called after each fabric object created. + * @return {fabric.Canvas} instance + * @chainable + * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#deserialization} + * @see {@link http://jsfiddle.net/fabricjs/fmgXt/|jsFiddle demo} + * @example loadFromJSON + * canvas.loadFromJSON(json, canvas.renderAll.bind(canvas)); + * @example loadFromJSON with reviver + * canvas.loadFromJSON(json, canvas.renderAll.bind(canvas), function(o, object) { + * // `o` = json object + * // `object` = fabric.Object instance + * // ... do some stuff ... + * }); + */ + loadFromJSON: function (json, callback, reviver) { + if (!json) { + return; + } + + // serialize if it wasn't already + var serialized = (typeof json === 'string') + ? JSON.parse(json) + : fabric.util.object.clone(json); + + var _this = this, + clipPath = serialized.clipPath, + renderOnAddRemove = this.renderOnAddRemove; + + this.renderOnAddRemove = false; + + delete serialized.clipPath; + + this._enlivenObjects(serialized.objects, function (enlivenedObjects) { + _this.clear(); + _this._setBgOverlay(serialized, function () { + if (clipPath) { + _this._enlivenObjects([clipPath], function (enlivenedCanvasClip) { + _this.clipPath = enlivenedCanvasClip[0]; + _this.__setupCanvas.call(_this, serialized, enlivenedObjects, renderOnAddRemove, callback); + }); + } + else { + _this.__setupCanvas.call(_this, serialized, enlivenedObjects, renderOnAddRemove, callback); + } + }); + }, reviver); + return this; + }, + + /** + * @private + * @param {Object} serialized Object with background and overlay information + * @param {Array} restored canvas objects + * @param {Function} cached renderOnAddRemove callback + * @param {Function} callback Invoked after all background and overlay images/patterns loaded + */ + __setupCanvas: function(serialized, enlivenedObjects, renderOnAddRemove, callback) { + var _this = this; + enlivenedObjects.forEach(function(obj, index) { + // we splice the array just in case some custom classes restored from JSON + // will add more object to canvas at canvas init. + _this.insertAt(obj, index); + }); + this.renderOnAddRemove = renderOnAddRemove; + // remove parts i cannot set as options + delete serialized.objects; + delete serialized.backgroundImage; + delete serialized.overlayImage; + delete serialized.background; + delete serialized.overlay; + // this._initOptions does too many things to just + // call it. Normally loading an Object from JSON + // create the Object instance. Here the Canvas is + // already an instance and we are just loading things over it + this._setOptions(serialized); + this.renderAll(); + callback && callback(); + }, + + /** + * @private + * @param {Object} serialized Object with background and overlay information + * @param {Function} callback Invoked after all background and overlay images/patterns loaded + */ + _setBgOverlay: function(serialized, callback) { + var loaded = { + backgroundColor: false, + overlayColor: false, + backgroundImage: false, + overlayImage: false + }; + + if (!serialized.backgroundImage && !serialized.overlayImage && !serialized.background && !serialized.overlay) { + callback && callback(); + return; + } + + var cbIfLoaded = function () { + if (loaded.backgroundImage && loaded.overlayImage && loaded.backgroundColor && loaded.overlayColor) { + callback && callback(); + } + }; + + this.__setBgOverlay('backgroundImage', serialized.backgroundImage, loaded, cbIfLoaded); + this.__setBgOverlay('overlayImage', serialized.overlayImage, loaded, cbIfLoaded); + this.__setBgOverlay('backgroundColor', serialized.background, loaded, cbIfLoaded); + this.__setBgOverlay('overlayColor', serialized.overlay, loaded, cbIfLoaded); + }, + + /** + * @private + * @param {String} property Property to set (backgroundImage, overlayImage, backgroundColor, overlayColor) + * @param {(Object|String)} value Value to set + * @param {Object} loaded Set loaded property to true if property is set + * @param {Object} callback Callback function to invoke after property is set + */ + __setBgOverlay: function(property, value, loaded, callback) { + var _this = this; + + if (!value) { + loaded[property] = true; + callback && callback(); + return; + } + + if (property === 'backgroundImage' || property === 'overlayImage') { + fabric.util.enlivenObjects([value], function(enlivedObject){ + _this[property] = enlivedObject[0]; + loaded[property] = true; + callback && callback(); + }); + } + else { + this['set' + fabric.util.string.capitalize(property, true)](value, function() { + loaded[property] = true; + callback && callback(); + }); + } + }, + + /** + * @private + * @param {Array} objects + * @param {Function} callback + * @param {Function} [reviver] + */ + _enlivenObjects: function (objects, callback, reviver) { + if (!objects || objects.length === 0) { + callback && callback([]); + return; + } + + fabric.util.enlivenObjects(objects, function(enlivenedObjects) { + callback && callback(enlivenedObjects); + }, null, reviver); + }, + + /** + * @private + * @param {String} format + * @param {Function} callback + */ + _toDataURL: function (format, callback) { + this.clone(function (clone) { + callback(clone.toDataURL(format)); + }); + }, + + /** + * @private + * @param {String} format + * @param {Number} multiplier + * @param {Function} callback + */ + _toDataURLWithMultiplier: function (format, multiplier, callback) { + this.clone(function (clone) { + callback(clone.toDataURLWithMultiplier(format, multiplier)); + }); + }, + + /** + * Clones canvas instance + * @param {Object} [callback] Receives cloned instance as a first argument + * @param {Array} [properties] Array of properties to include in the cloned canvas and children + */ + clone: function (callback, properties) { + var data = JSON.stringify(this.toJSON(properties)); + this.cloneWithoutData(function(clone) { + clone.loadFromJSON(data, function() { + callback && callback(clone); + }); + }); + }, + + /** + * Clones canvas instance without cloning existing data. + * This essentially copies canvas dimensions, clipping properties, etc. + * but leaves data empty (so that you can populate it with your own) + * @param {Object} [callback] Receives cloned instance as a first argument + */ + cloneWithoutData: function(callback) { + var el = fabric.util.createCanvasElement(); + + el.width = this.width; + el.height = this.height; + + var clone = new fabric.Canvas(el); + if (this.backgroundImage) { + clone.setBackgroundImage(this.backgroundImage.src, function() { + clone.renderAll(); + callback && callback(clone); + }); + clone.backgroundImageOpacity = this.backgroundImageOpacity; + clone.backgroundImageStretch = this.backgroundImageStretch; + } + else { + callback && callback(clone); + } + } +}); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + extend = fabric.util.object.extend, + clone = fabric.util.object.clone, + toFixed = fabric.util.toFixed, + capitalize = fabric.util.string.capitalize, + degreesToRadians = fabric.util.degreesToRadians, + objectCaching = !fabric.isLikelyNode, + ALIASING_LIMIT = 2; + + if (fabric.Object) { + return; + } + + /** + * Root object class from which all 2d shape classes inherit from + * @class fabric.Object + * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#objects} + * @see {@link fabric.Object#initialize} for constructor definition + * + * @fires added + * @fires removed + * + * @fires selected + * @fires deselected + * @fires modified + * @fires modified + * @fires moved + * @fires scaled + * @fires rotated + * @fires skewed + * + * @fires rotating + * @fires scaling + * @fires moving + * @fires skewing + * + * @fires mousedown + * @fires mouseup + * @fires mouseover + * @fires mouseout + * @fires mousewheel + * @fires mousedblclick + * + * @fires dragover + * @fires dragenter + * @fires dragleave + * @fires drop + */ + fabric.Object = fabric.util.createClass(fabric.CommonMethods, /** @lends fabric.Object.prototype */ { + + /** + * Type of an object (rect, circle, path, etc.). + * Note that this property is meant to be read-only and not meant to be modified. + * If you modify, certain parts of Fabric (such as JSON loading) won't work correctly. + * @type String + * @default + */ + type: 'object', + + /** + * Horizontal origin of transformation of an object (one of "left", "right", "center") + * See http://jsfiddle.net/1ow02gea/244/ on how originX/originY affect objects in groups + * @type String + * @default + */ + originX: 'left', + + /** + * Vertical origin of transformation of an object (one of "top", "bottom", "center") + * See http://jsfiddle.net/1ow02gea/244/ on how originX/originY affect objects in groups + * @type String + * @default + */ + originY: 'top', + + /** + * Top position of an object. Note that by default it's relative to object top. You can change this by setting originY={top/center/bottom} + * @type Number + * @default + */ + top: 0, + + /** + * Left position of an object. Note that by default it's relative to object left. You can change this by setting originX={left/center/right} + * @type Number + * @default + */ + left: 0, + + /** + * Object width + * @type Number + * @default + */ + width: 0, + + /** + * Object height + * @type Number + * @default + */ + height: 0, + + /** + * Object scale factor (horizontal) + * @type Number + * @default + */ + scaleX: 1, + + /** + * Object scale factor (vertical) + * @type Number + * @default + */ + scaleY: 1, + + /** + * When true, an object is rendered as flipped horizontally + * @type Boolean + * @default + */ + flipX: false, + + /** + * When true, an object is rendered as flipped vertically + * @type Boolean + * @default + */ + flipY: false, + + /** + * Opacity of an object + * @type Number + * @default + */ + opacity: 1, + + /** + * Angle of rotation of an object (in degrees) + * @type Number + * @default + */ + angle: 0, + + /** + * Angle of skew on x axes of an object (in degrees) + * @type Number + * @default + */ + skewX: 0, + + /** + * Angle of skew on y axes of an object (in degrees) + * @type Number + * @default + */ + skewY: 0, + + /** + * Size of object's controlling corners (in pixels) + * @type Number + * @default + */ + cornerSize: 13, + + /** + * Size of object's controlling corners when touch interaction is detected + * @type Number + * @default + */ + touchCornerSize: 24, + + /** + * When true, object's controlling corners are rendered as transparent inside (i.e. stroke instead of fill) + * @type Boolean + * @default + */ + transparentCorners: true, + + /** + * Default cursor value used when hovering over this object on canvas + * @type String + * @default + */ + hoverCursor: null, + + /** + * Default cursor value used when moving this object on canvas + * @type String + * @default + */ + moveCursor: null, + + /** + * Padding between object and its controlling borders (in pixels) + * @type Number + * @default + */ + padding: 0, + + /** + * Color of controlling borders of an object (when it's active) + * @type String + * @default + */ + borderColor: 'rgb(178,204,255)', + + /** + * Array specifying dash pattern of an object's borders (hasBorder must be true) + * @since 1.6.2 + * @type Array + */ + borderDashArray: null, + + /** + * Color of controlling corners of an object (when it's active) + * @type String + * @default + */ + cornerColor: 'rgb(178,204,255)', + + /** + * Color of controlling corners of an object (when it's active and transparentCorners false) + * @since 1.6.2 + * @type String + * @default + */ + cornerStrokeColor: null, + + /** + * Specify style of control, 'rect' or 'circle' + * @since 1.6.2 + * @type String + */ + cornerStyle: 'rect', + + /** + * Array specifying dash pattern of an object's control (hasBorder must be true) + * @since 1.6.2 + * @type Array + */ + cornerDashArray: null, + + /** + * When true, this object will use center point as the origin of transformation + * when being scaled via the controls. + * Backwards incompatibility note: This property replaces "centerTransform" (Boolean). + * @since 1.3.4 + * @type Boolean + * @default + */ + centeredScaling: false, + + /** + * When true, this object will use center point as the origin of transformation + * when being rotated via the controls. + * Backwards incompatibility note: This property replaces "centerTransform" (Boolean). + * @since 1.3.4 + * @type Boolean + * @default + */ + centeredRotation: true, + + /** + * Color of object's fill + * takes css colors https://www.w3.org/TR/css-color-3/ + * @type String + * @default + */ + fill: 'rgb(0,0,0)', + + /** + * Fill rule used to fill an object + * accepted values are nonzero, evenodd + * Backwards incompatibility note: This property was used for setting globalCompositeOperation until v1.4.12 (use `fabric.Object#globalCompositeOperation` instead) + * @type String + * @default + */ + fillRule: 'nonzero', + + /** + * Composite rule used for canvas globalCompositeOperation + * @type String + * @default + */ + globalCompositeOperation: 'source-over', + + /** + * Background color of an object. + * takes css colors https://www.w3.org/TR/css-color-3/ + * @type String + * @default + */ + backgroundColor: '', + + /** + * Selection Background color of an object. colored layer behind the object when it is active. + * does not mix good with globalCompositeOperation methods. + * @type String + * @default + */ + selectionBackgroundColor: '', + + /** + * When defined, an object is rendered via stroke and this property specifies its color + * takes css colors https://www.w3.org/TR/css-color-3/ + * @type String + * @default + */ + stroke: null, + + /** + * Width of a stroke used to render this object + * @type Number + * @default + */ + strokeWidth: 1, + + /** + * Array specifying dash pattern of an object's stroke (stroke must be defined) + * @type Array + */ + strokeDashArray: null, + + /** + * Line offset of an object's stroke + * @type Number + * @default + */ + strokeDashOffset: 0, + + /** + * Line endings style of an object's stroke (one of "butt", "round", "square") + * @type String + * @default + */ + strokeLineCap: 'butt', + + /** + * Corner style of an object's stroke (one of "bevel", "round", "miter") + * @type String + * @default + */ + strokeLineJoin: 'miter', + + /** + * Maximum miter length (used for strokeLineJoin = "miter") of an object's stroke + * @type Number + * @default + */ + strokeMiterLimit: 4, + + /** + * Shadow object representing shadow of this shape + * @type fabric.Shadow + * @default + */ + shadow: null, + + /** + * Opacity of object's controlling borders when object is active and moving + * @type Number + * @default + */ + borderOpacityWhenMoving: 0.4, + + /** + * Scale factor of object's controlling borders + * bigger number will make a thicker border + * border is 1, so this is basically a border thickness + * since there is no way to change the border itself. + * @type Number + * @default + */ + borderScaleFactor: 1, + + /** + * Minimum allowed scale value of an object + * @type Number + * @default + */ + minScaleLimit: 0, + + /** + * When set to `false`, an object can not be selected for modification (using either point-click-based or group-based selection). + * But events still fire on it. + * @type Boolean + * @default + */ + selectable: true, + + /** + * When set to `false`, an object can not be a target of events. All events propagate through it. Introduced in v1.3.4 + * @type Boolean + * @default + */ + evented: true, + + /** + * When set to `false`, an object is not rendered on canvas + * @type Boolean + * @default + */ + visible: true, + + /** + * When set to `false`, object's controls are not displayed and can not be used to manipulate object + * @type Boolean + * @default + */ + hasControls: true, + + /** + * When set to `false`, object's controlling borders are not rendered + * @type Boolean + * @default + */ + hasBorders: true, + + /** + * When set to `true`, objects are "found" on canvas on per-pixel basis rather than according to bounding box + * @type Boolean + * @default + */ + perPixelTargetFind: false, + + /** + * When `false`, default object's values are not included in its serialization + * @type Boolean + * @default + */ + includeDefaultValues: true, + + /** + * When `true`, object horizontal movement is locked + * @type Boolean + * @default + */ + lockMovementX: false, + + /** + * When `true`, object vertical movement is locked + * @type Boolean + * @default + */ + lockMovementY: false, + + /** + * When `true`, object rotation is locked + * @type Boolean + * @default + */ + lockRotation: false, + + /** + * When `true`, object horizontal scaling is locked + * @type Boolean + * @default + */ + lockScalingX: false, + + /** + * When `true`, object vertical scaling is locked + * @type Boolean + * @default + */ + lockScalingY: false, + + /** + * When `true`, object horizontal skewing is locked + * @type Boolean + * @default + */ + lockSkewingX: false, + + /** + * When `true`, object vertical skewing is locked + * @type Boolean + * @default + */ + lockSkewingY: false, + + /** + * When `true`, object cannot be flipped by scaling into negative values + * @type Boolean + * @default + */ + lockScalingFlip: false, + + /** + * When `true`, object is not exported in OBJECT/JSON + * @since 1.6.3 + * @type Boolean + * @default + */ + excludeFromExport: false, + + /** + * When `true`, object is cached on an additional canvas. + * When `false`, object is not cached unless necessary ( clipPath ) + * default to true + * @since 1.7.0 + * @type Boolean + * @default true + */ + objectCaching: objectCaching, + + /** + * When `true`, object properties are checked for cache invalidation. In some particular + * situation you may want this to be disabled ( spray brush, very big, groups) + * or if your application does not allow you to modify properties for groups child you want + * to disable it for groups. + * default to false + * since 1.7.0 + * @type Boolean + * @default false + */ + statefullCache: false, + + /** + * When `true`, cache does not get updated during scaling. The picture will get blocky if scaled + * too much and will be redrawn with correct details at the end of scaling. + * this setting is performance and application dependant. + * default to true + * since 1.7.0 + * @type Boolean + * @default true + */ + noScaleCache: true, + + /** + * When `false`, the stoke width will scale with the object. + * When `true`, the stroke will always match the exact pixel size entered for stroke width. + * this Property does not work on Text classes or drawing call that uses strokeText,fillText methods + * default to false + * @since 2.6.0 + * @type Boolean + * @default false + * @type Boolean + * @default false + */ + strokeUniform: false, + + /** + * When set to `true`, object's cache will be rerendered next render call. + * since 1.7.0 + * @type Boolean + * @default true + */ + dirty: true, + + /** + * keeps the value of the last hovered corner during mouse move. + * 0 is no corner, or 'mt', 'ml', 'mtr' etc.. + * It should be private, but there is no harm in using it as + * a read-only property. + * @type number|string|any + * @default 0 + */ + __corner: 0, + + /** + * Determines if the fill or the stroke is drawn first (one of "fill" or "stroke") + * @type String + * @default + */ + paintFirst: 'fill', + + /** + * When 'down', object is set to active on mousedown/touchstart + * When 'up', object is set to active on mouseup/touchend + * Experimental. Let's see if this breaks anything before supporting officially + * @private + * since 4.4.0 + * @type String + * @default 'down' + */ + activeOn: 'down', + + /** + * List of properties to consider when checking if state + * of an object is changed (fabric.Object#hasStateChanged) + * as well as for history (undo/redo) purposes + * @type Array + */ + stateProperties: ( + 'top left width height scaleX scaleY flipX flipY originX originY transformMatrix ' + + 'stroke strokeWidth strokeDashArray strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit ' + + 'angle opacity fill globalCompositeOperation shadow visible backgroundColor ' + + 'skewX skewY fillRule paintFirst clipPath strokeUniform' + ).split(' '), + + /** + * List of properties to consider when checking if cache needs refresh + * Those properties are checked by statefullCache ON ( or lazy mode if we want ) or from single + * calls to Object.set(key, value). If the key is in this list, the object is marked as dirty + * and refreshed at the next render + * @type Array + */ + cacheProperties: ( + 'fill stroke strokeWidth strokeDashArray width height paintFirst strokeUniform' + + ' strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit backgroundColor clipPath' + ).split(' '), + + /** + * List of properties to consider for animating colors. + * @type Array + */ + colorProperties: ( + 'fill stroke backgroundColor' + ).split(' '), + + /** + * a fabricObject that, without stroke define a clipping area with their shape. filled in black + * the clipPath object gets used when the object has rendered, and the context is placed in the center + * of the object cacheCanvas. + * If you want 0,0 of a clipPath to align with an object center, use clipPath.originX/Y to 'center' + * @type fabric.Object + */ + clipPath: undefined, + + /** + * Meaningful ONLY when the object is used as clipPath. + * if true, the clipPath will make the object clip to the outside of the clipPath + * since 2.4.0 + * @type boolean + * @default false + */ + inverted: false, + + /** + * Meaningful ONLY when the object is used as clipPath. + * if true, the clipPath will have its top and left relative to canvas, and will + * not be influenced by the object transform. This will make the clipPath relative + * to the canvas, but clipping just a particular object. + * WARNING this is beta, this feature may change or be renamed. + * since 2.4.0 + * @type boolean + * @default false + */ + absolutePositioned: false, + + /** + * Constructor + * @param {Object} [options] Options object + */ + initialize: function(options) { + if (options) { + this.setOptions(options); + } + }, + + /** + * Create a the canvas used to keep the cached copy of the object + * @private + */ + _createCacheCanvas: function() { + this._cacheProperties = {}; + this._cacheCanvas = fabric.util.createCanvasElement(); + this._cacheContext = this._cacheCanvas.getContext('2d'); + this._updateCacheCanvas(); + // if canvas gets created, is empty, so dirty. + this.dirty = true; + }, + + /** + * Limit the cache dimensions so that X * Y do not cross fabric.perfLimitSizeTotal + * and each side do not cross fabric.cacheSideLimit + * those numbers are configurable so that you can get as much detail as you want + * making bargain with performances. + * @param {Object} dims + * @param {Object} dims.width width of canvas + * @param {Object} dims.height height of canvas + * @param {Object} dims.zoomX zoomX zoom value to unscale the canvas before drawing cache + * @param {Object} dims.zoomY zoomY zoom value to unscale the canvas before drawing cache + * @return {Object}.width width of canvas + * @return {Object}.height height of canvas + * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache + * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache + */ + _limitCacheSize: function(dims) { + var perfLimitSizeTotal = fabric.perfLimitSizeTotal, + width = dims.width, height = dims.height, + max = fabric.maxCacheSideLimit, min = fabric.minCacheSideLimit; + if (width <= max && height <= max && width * height <= perfLimitSizeTotal) { + if (width < min) { + dims.width = min; + } + if (height < min) { + dims.height = min; + } + return dims; + } + var ar = width / height, limitedDims = fabric.util.limitDimsByArea(ar, perfLimitSizeTotal), + capValue = fabric.util.capValue, + x = capValue(min, limitedDims.x, max), + y = capValue(min, limitedDims.y, max); + if (width > x) { + dims.zoomX /= width / x; + dims.width = x; + dims.capped = true; + } + if (height > y) { + dims.zoomY /= height / y; + dims.height = y; + dims.capped = true; + } + return dims; + }, + + /** + * Return the dimension and the zoom level needed to create a cache canvas + * big enough to host the object to be cached. + * @private + * @return {Object}.x width of object to be cached + * @return {Object}.y height of object to be cached + * @return {Object}.width width of canvas + * @return {Object}.height height of canvas + * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache + * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache + */ + _getCacheCanvasDimensions: function() { + var objectScale = this.getTotalObjectScaling(), + // caculate dimensions without skewing + dim = this._getTransformedDimensions(0, 0), + neededX = dim.x * objectScale.scaleX / this.scaleX, + neededY = dim.y * objectScale.scaleY / this.scaleY; + return { + // for sure this ALIASING_LIMIT is slightly creating problem + // in situation in which the cache canvas gets an upper limit + // also objectScale contains already scaleX and scaleY + width: neededX + ALIASING_LIMIT, + height: neededY + ALIASING_LIMIT, + zoomX: objectScale.scaleX, + zoomY: objectScale.scaleY, + x: neededX, + y: neededY + }; + }, + + /** + * Update width and height of the canvas for cache + * returns true or false if canvas needed resize. + * @private + * @return {Boolean} true if the canvas has been resized + */ + _updateCacheCanvas: function() { + var targetCanvas = this.canvas; + if (this.noScaleCache && targetCanvas && targetCanvas._currentTransform) { + var target = targetCanvas._currentTransform.target, + action = targetCanvas._currentTransform.action; + if (this === target && action.slice && action.slice(0, 5) === 'scale') { + return false; + } + } + var canvas = this._cacheCanvas, + dims = this._limitCacheSize(this._getCacheCanvasDimensions()), + minCacheSize = fabric.minCacheSideLimit, + width = dims.width, height = dims.height, drawingWidth, drawingHeight, + zoomX = dims.zoomX, zoomY = dims.zoomY, + dimensionsChanged = width !== this.cacheWidth || height !== this.cacheHeight, + zoomChanged = this.zoomX !== zoomX || this.zoomY !== zoomY, + shouldRedraw = dimensionsChanged || zoomChanged, + additionalWidth = 0, additionalHeight = 0, shouldResizeCanvas = false; + if (dimensionsChanged) { + var canvasWidth = this._cacheCanvas.width, + canvasHeight = this._cacheCanvas.height, + sizeGrowing = width > canvasWidth || height > canvasHeight, + sizeShrinking = (width < canvasWidth * 0.9 || height < canvasHeight * 0.9) && + canvasWidth > minCacheSize && canvasHeight > minCacheSize; + shouldResizeCanvas = sizeGrowing || sizeShrinking; + if (sizeGrowing && !dims.capped && (width > minCacheSize || height > minCacheSize)) { + additionalWidth = width * 0.1; + additionalHeight = height * 0.1; + } + } + if (this instanceof fabric.Text && this.path) { + shouldRedraw = true; + shouldResizeCanvas = true; + additionalWidth += this.getHeightOfLine(0) * this.zoomX; + additionalHeight += this.getHeightOfLine(0) * this.zoomY; + } + if (shouldRedraw) { + if (shouldResizeCanvas) { + canvas.width = Math.ceil(width + additionalWidth); + canvas.height = Math.ceil(height + additionalHeight); + } + else { + this._cacheContext.setTransform(1, 0, 0, 1, 0, 0); + this._cacheContext.clearRect(0, 0, canvas.width, canvas.height); + } + drawingWidth = dims.x / 2; + drawingHeight = dims.y / 2; + this.cacheTranslationX = Math.round(canvas.width / 2 - drawingWidth) + drawingWidth; + this.cacheTranslationY = Math.round(canvas.height / 2 - drawingHeight) + drawingHeight; + this.cacheWidth = width; + this.cacheHeight = height; + this._cacheContext.translate(this.cacheTranslationX, this.cacheTranslationY); + this._cacheContext.scale(zoomX, zoomY); + this.zoomX = zoomX; + this.zoomY = zoomY; + return true; + } + return false; + }, + + /** + * Sets object's properties from options + * @param {Object} [options] Options object + */ + setOptions: function(options) { + this._setOptions(options); + this._initGradient(options.fill, 'fill'); + this._initGradient(options.stroke, 'stroke'); + this._initPattern(options.fill, 'fill'); + this._initPattern(options.stroke, 'stroke'); + }, + + /** + * Transforms context when rendering an object + * @param {CanvasRenderingContext2D} ctx Context + */ + transform: function(ctx) { + var needFullTransform = (this.group && !this.group._transformDone) || + (this.group && this.canvas && ctx === this.canvas.contextTop); + var m = this.calcTransformMatrix(!needFullTransform); + ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]); + }, + + /** + * Returns an object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} Object representation of an instance + */ + toObject: function(propertiesToInclude) { + var NUM_FRACTION_DIGITS = fabric.Object.NUM_FRACTION_DIGITS, + + object = { + type: this.type, + version: fabric.version, + originX: this.originX, + originY: this.originY, + left: toFixed(this.left, NUM_FRACTION_DIGITS), + top: toFixed(this.top, NUM_FRACTION_DIGITS), + width: toFixed(this.width, NUM_FRACTION_DIGITS), + height: toFixed(this.height, NUM_FRACTION_DIGITS), + fill: (this.fill && this.fill.toObject) ? this.fill.toObject() : this.fill, + stroke: (this.stroke && this.stroke.toObject) ? this.stroke.toObject() : this.stroke, + strokeWidth: toFixed(this.strokeWidth, NUM_FRACTION_DIGITS), + strokeDashArray: this.strokeDashArray ? this.strokeDashArray.concat() : this.strokeDashArray, + strokeLineCap: this.strokeLineCap, + strokeDashOffset: this.strokeDashOffset, + strokeLineJoin: this.strokeLineJoin, + strokeUniform: this.strokeUniform, + strokeMiterLimit: toFixed(this.strokeMiterLimit, NUM_FRACTION_DIGITS), + scaleX: toFixed(this.scaleX, NUM_FRACTION_DIGITS), + scaleY: toFixed(this.scaleY, NUM_FRACTION_DIGITS), + angle: toFixed(this.angle, NUM_FRACTION_DIGITS), + flipX: this.flipX, + flipY: this.flipY, + opacity: toFixed(this.opacity, NUM_FRACTION_DIGITS), + shadow: (this.shadow && this.shadow.toObject) ? this.shadow.toObject() : this.shadow, + visible: this.visible, + backgroundColor: this.backgroundColor, + fillRule: this.fillRule, + paintFirst: this.paintFirst, + globalCompositeOperation: this.globalCompositeOperation, + skewX: toFixed(this.skewX, NUM_FRACTION_DIGITS), + skewY: toFixed(this.skewY, NUM_FRACTION_DIGITS), + }; + + if (this.clipPath && !this.clipPath.excludeFromExport) { + object.clipPath = this.clipPath.toObject(propertiesToInclude); + object.clipPath.inverted = this.clipPath.inverted; + object.clipPath.absolutePositioned = this.clipPath.absolutePositioned; + } + + fabric.util.populateWithProperties(this, object, propertiesToInclude); + if (!this.includeDefaultValues) { + object = this._removeDefaultValues(object); + } + + return object; + }, + + /** + * Returns (dataless) object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} Object representation of an instance + */ + toDatalessObject: function(propertiesToInclude) { + // will be overwritten by subclasses + return this.toObject(propertiesToInclude); + }, + + /** + * @private + * @param {Object} object + */ + _removeDefaultValues: function(object) { + var prototype = fabric.util.getKlass(object.type).prototype, + stateProperties = prototype.stateProperties; + stateProperties.forEach(function(prop) { + if (prop === 'left' || prop === 'top') { + return; + } + if (object[prop] === prototype[prop]) { + delete object[prop]; + } + // basically a check for [] === [] + if (Array.isArray(object[prop]) && Array.isArray(prototype[prop]) + && object[prop].length === 0 && prototype[prop].length === 0) { + delete object[prop]; + } + }); + + return object; + }, + + /** + * Returns a string representation of an instance + * @return {String} + */ + toString: function() { + return '#'; + }, + + /** + * Return the object scale factor counting also the group scaling + * @return {Object} object with scaleX and scaleY properties + */ + getObjectScaling: function() { + // if the object is a top level one, on the canvas, we go for simple aritmetic + // otherwise the complex method with angles will return approximations and decimals + // and will likely kill the cache when not needed + // https://github.com/fabricjs/fabric.js/issues/7157 + if (!this.group) { + return { + scaleX: this.scaleX, + scaleY: this.scaleY, + }; + } + // if we are inside a group total zoom calculation is complex, we defer to generic matrices + var options = fabric.util.qrDecompose(this.calcTransformMatrix()); + return { scaleX: Math.abs(options.scaleX), scaleY: Math.abs(options.scaleY) }; + }, + + /** + * Return the object scale factor counting also the group scaling, zoom and retina + * @return {Object} object with scaleX and scaleY properties + */ + getTotalObjectScaling: function() { + var scale = this.getObjectScaling(), scaleX = scale.scaleX, scaleY = scale.scaleY; + if (this.canvas) { + var zoom = this.canvas.getZoom(); + var retina = this.canvas.getRetinaScaling(); + scaleX *= zoom * retina; + scaleY *= zoom * retina; + } + return { scaleX: scaleX, scaleY: scaleY }; + }, + + /** + * Return the object opacity counting also the group property + * @return {Number} + */ + getObjectOpacity: function() { + var opacity = this.opacity; + if (this.group) { + opacity *= this.group.getObjectOpacity(); + } + return opacity; + }, + + /** + * @private + * @param {String} key + * @param {*} value + * @return {fabric.Object} thisArg + */ + _set: function(key, value) { + var shouldConstrainValue = (key === 'scaleX' || key === 'scaleY'), + isChanged = this[key] !== value, groupNeedsUpdate = false; + + if (shouldConstrainValue) { + value = this._constrainScale(value); + } + if (key === 'scaleX' && value < 0) { + this.flipX = !this.flipX; + value *= -1; + } + else if (key === 'scaleY' && value < 0) { + this.flipY = !this.flipY; + value *= -1; + } + else if (key === 'shadow' && value && !(value instanceof fabric.Shadow)) { + value = new fabric.Shadow(value); + } + else if (key === 'dirty' && this.group) { + this.group.set('dirty', value); + } + + this[key] = value; + + if (isChanged) { + groupNeedsUpdate = this.group && this.group.isOnACache(); + if (this.cacheProperties.indexOf(key) > -1) { + this.dirty = true; + groupNeedsUpdate && this.group.set('dirty', true); + } + else if (groupNeedsUpdate && this.stateProperties.indexOf(key) > -1) { + this.group.set('dirty', true); + } + } + return this; + }, + + /** + * This callback function is called by the parent group of an object every + * time a non-delegated property changes on the group. It is passed the key + * and value as parameters. Not adding in this function's signature to avoid + * Travis build error about unused variables. + */ + setOnGroup: function() { + // implemented by sub-classes, as needed. + }, + + /** + * Retrieves viewportTransform from Object's canvas if possible + * @method getViewportTransform + * @memberOf fabric.Object.prototype + * @return {Array} + */ + getViewportTransform: function() { + if (this.canvas && this.canvas.viewportTransform) { + return this.canvas.viewportTransform; + } + return fabric.iMatrix.concat(); + }, + + /* + * @private + * return if the object would be visible in rendering + * @memberOf fabric.Object.prototype + * @return {Boolean} + */ + isNotVisible: function() { + return this.opacity === 0 || + (!this.width && !this.height && this.strokeWidth === 0) || + !this.visible; + }, + + /** + * Renders an object on a specified context + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + render: function(ctx) { + // do not render if width/height are zeros or object is not visible + if (this.isNotVisible()) { + return; + } + if (this.canvas && this.canvas.skipOffscreen && !this.group && !this.isOnScreen()) { + return; + } + ctx.save(); + this._setupCompositeOperation(ctx); + this.drawSelectionBackground(ctx); + this.transform(ctx); + this._setOpacity(ctx); + this._setShadow(ctx, this); + if (this.shouldCache()) { + this.renderCache(); + this.drawCacheOnCanvas(ctx); + } + else { + this._removeCacheCanvas(); + this.dirty = false; + this.drawObject(ctx); + if (this.objectCaching && this.statefullCache) { + this.saveState({ propertySet: 'cacheProperties' }); + } + } + ctx.restore(); + }, + + renderCache: function(options) { + options = options || {}; + if (!this._cacheCanvas || !this._cacheContext) { + this._createCacheCanvas(); + } + if (this.isCacheDirty()) { + this.statefullCache && this.saveState({ propertySet: 'cacheProperties' }); + this.drawObject(this._cacheContext, options.forClipping); + this.dirty = false; + } + }, + + /** + * Remove cacheCanvas and its dimensions from the objects + */ + _removeCacheCanvas: function() { + this._cacheCanvas = null; + this._cacheContext = null; + this.cacheWidth = 0; + this.cacheHeight = 0; + }, + + /** + * return true if the object will draw a stroke + * Does not consider text styles. This is just a shortcut used at rendering time + * We want it to be an approximation and be fast. + * wrote to avoid extra caching, it has to return true when stroke happens, + * can guess when it will not happen at 100% chance, does not matter if it misses + * some use case where the stroke is invisible. + * @since 3.0.0 + * @returns Boolean + */ + hasStroke: function() { + return this.stroke && this.stroke !== 'transparent' && this.strokeWidth !== 0; + }, + + /** + * return true if the object will draw a fill + * Does not consider text styles. This is just a shortcut used at rendering time + * We want it to be an approximation and be fast. + * wrote to avoid extra caching, it has to return true when fill happens, + * can guess when it will not happen at 100% chance, does not matter if it misses + * some use case where the fill is invisible. + * @since 3.0.0 + * @returns Boolean + */ + hasFill: function() { + return this.fill && this.fill !== 'transparent'; + }, + + /** + * When set to `true`, force the object to have its own cache, even if it is inside a group + * it may be needed when your object behave in a particular way on the cache and always needs + * its own isolated canvas to render correctly. + * Created to be overridden + * since 1.7.12 + * @returns Boolean + */ + needsItsOwnCache: function() { + if (this.paintFirst === 'stroke' && + this.hasFill() && this.hasStroke() && typeof this.shadow === 'object') { + return true; + } + if (this.clipPath) { + return true; + } + return false; + }, + + /** + * Decide if the object should cache or not. Create its own cache level + * objectCaching is a global flag, wins over everything + * needsItsOwnCache should be used when the object drawing method requires + * a cache step. None of the fabric classes requires it. + * Generally you do not cache objects in groups because the group outside is cached. + * Read as: cache if is needed, or if the feature is enabled but we are not already caching. + * @return {Boolean} + */ + shouldCache: function() { + this.ownCaching = this.needsItsOwnCache() || ( + this.objectCaching && + (!this.group || !this.group.isOnACache()) + ); + return this.ownCaching; + }, + + /** + * Check if this object or a child object will cast a shadow + * used by Group.shouldCache to know if child has a shadow recursively + * @return {Boolean} + */ + willDrawShadow: function() { + return !!this.shadow && (this.shadow.offsetX !== 0 || this.shadow.offsetY !== 0); + }, + + /** + * Execute the drawing operation for an object clipPath + * @param {CanvasRenderingContext2D} ctx Context to render on + * @param {fabric.Object} clipPath + */ + drawClipPathOnCache: function(ctx, clipPath) { + ctx.save(); + // DEBUG: uncomment this line, comment the following + // ctx.globalAlpha = 0.4 + if (clipPath.inverted) { + ctx.globalCompositeOperation = 'destination-out'; + } + else { + ctx.globalCompositeOperation = 'destination-in'; + } + //ctx.scale(1 / 2, 1 / 2); + if (clipPath.absolutePositioned) { + var m = fabric.util.invertTransform(this.calcTransformMatrix()); + ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]); + } + clipPath.transform(ctx); + ctx.scale(1 / clipPath.zoomX, 1 / clipPath.zoomY); + ctx.drawImage(clipPath._cacheCanvas, -clipPath.cacheTranslationX, -clipPath.cacheTranslationY); + ctx.restore(); + }, + + /** + * Execute the drawing operation for an object on a specified context + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + drawObject: function(ctx, forClipping) { + var originalFill = this.fill, originalStroke = this.stroke; + if (forClipping) { + this.fill = 'black'; + this.stroke = ''; + this._setClippingProperties(ctx); + } + else { + this._renderBackground(ctx); + } + this._render(ctx); + this._drawClipPath(ctx, this.clipPath); + this.fill = originalFill; + this.stroke = originalStroke; + }, + + /** + * Prepare clipPath state and cache and draw it on instance's cache + * @param {CanvasRenderingContext2D} ctx + * @param {fabric.Object} clipPath + */ + _drawClipPath: function (ctx, clipPath) { + if (!clipPath) { return; } + // needed to setup a couple of variables + // path canvas gets overridden with this one. + // TODO find a better solution? + clipPath.canvas = this.canvas; + clipPath.shouldCache(); + clipPath._transformDone = true; + clipPath.renderCache({ forClipping: true }); + this.drawClipPathOnCache(ctx, clipPath); + }, + + /** + * Paint the cached copy of the object on the target context. + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + drawCacheOnCanvas: function(ctx) { + ctx.scale(1 / this.zoomX, 1 / this.zoomY); + ctx.drawImage(this._cacheCanvas, -this.cacheTranslationX, -this.cacheTranslationY); + }, + + /** + * Check if cache is dirty + * @param {Boolean} skipCanvas skip canvas checks because this object is painted + * on parent canvas. + */ + isCacheDirty: function(skipCanvas) { + if (this.isNotVisible()) { + return false; + } + if (this._cacheCanvas && this._cacheContext && !skipCanvas && this._updateCacheCanvas()) { + // in this case the context is already cleared. + return true; + } + else { + if (this.dirty || + (this.clipPath && this.clipPath.absolutePositioned) || + (this.statefullCache && this.hasStateChanged('cacheProperties')) + ) { + if (this._cacheCanvas && this._cacheContext && !skipCanvas) { + var width = this.cacheWidth / this.zoomX; + var height = this.cacheHeight / this.zoomY; + this._cacheContext.clearRect(-width / 2, -height / 2, width, height); + } + return true; + } + } + return false; + }, + + /** + * Draws a background for the object big as its untransformed dimensions + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _renderBackground: function(ctx) { + if (!this.backgroundColor) { + return; + } + var dim = this._getNonTransformedDimensions(); + ctx.fillStyle = this.backgroundColor; + + ctx.fillRect( + -dim.x / 2, + -dim.y / 2, + dim.x, + dim.y + ); + // if there is background color no other shadows + // should be casted + this._removeShadow(ctx); + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _setOpacity: function(ctx) { + if (this.group && !this.group._transformDone) { + ctx.globalAlpha = this.getObjectOpacity(); + } + else { + ctx.globalAlpha *= this.opacity; + } + }, + + _setStrokeStyles: function(ctx, decl) { + var stroke = decl.stroke; + if (stroke) { + ctx.lineWidth = decl.strokeWidth; + ctx.lineCap = decl.strokeLineCap; + ctx.lineDashOffset = decl.strokeDashOffset; + ctx.lineJoin = decl.strokeLineJoin; + ctx.miterLimit = decl.strokeMiterLimit; + if (stroke.toLive) { + if (stroke.gradientUnits === 'percentage' || stroke.gradientTransform || stroke.patternTransform) { + // need to transform gradient in a pattern. + // this is a slow process. If you are hitting this codepath, and the object + // is not using caching, you should consider switching it on. + // we need a canvas as big as the current object caching canvas. + this._applyPatternForTransformedGradient(ctx, stroke); + } + else { + // is a simple gradient or pattern + ctx.strokeStyle = stroke.toLive(ctx, this); + this._applyPatternGradientTransform(ctx, stroke); + } + } + else { + // is a color + ctx.strokeStyle = decl.stroke; + } + } + }, + + _setFillStyles: function(ctx, decl) { + var fill = decl.fill; + if (fill) { + if (fill.toLive) { + ctx.fillStyle = fill.toLive(ctx, this); + this._applyPatternGradientTransform(ctx, decl.fill); + } + else { + ctx.fillStyle = fill; + } + } + }, + + _setClippingProperties: function(ctx) { + ctx.globalAlpha = 1; + ctx.strokeStyle = 'transparent'; + ctx.fillStyle = '#000000'; + }, + + /** + * @private + * Sets line dash + * @param {CanvasRenderingContext2D} ctx Context to set the dash line on + * @param {Array} dashArray array representing dashes + */ + _setLineDash: function(ctx, dashArray) { + if (!dashArray || dashArray.length === 0) { + return; + } + // Spec requires the concatenation of two copies the dash list when the number of elements is odd + if (1 & dashArray.length) { + dashArray.push.apply(dashArray, dashArray); + } + ctx.setLineDash(dashArray); + }, + + /** + * Renders controls and borders for the object + * the context here is not transformed + * @param {CanvasRenderingContext2D} ctx Context to render on + * @param {Object} [styleOverride] properties to override the object style + */ + _renderControls: function(ctx, styleOverride) { + var vpt = this.getViewportTransform(), + matrix = this.calcTransformMatrix(), + options, drawBorders, drawControls; + styleOverride = styleOverride || { }; + drawBorders = typeof styleOverride.hasBorders !== 'undefined' ? styleOverride.hasBorders : this.hasBorders; + drawControls = typeof styleOverride.hasControls !== 'undefined' ? styleOverride.hasControls : this.hasControls; + matrix = fabric.util.multiplyTransformMatrices(vpt, matrix); + options = fabric.util.qrDecompose(matrix); + ctx.save(); + ctx.translate(options.translateX, options.translateY); + ctx.lineWidth = 1 * this.borderScaleFactor; + if (!this.group) { + ctx.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1; + } + if (this.flipX) { + options.angle -= 180; + } + ctx.rotate(degreesToRadians(this.group ? options.angle : this.angle)); + if (styleOverride.forActiveSelection || this.group) { + drawBorders && this.drawBordersInGroup(ctx, options, styleOverride); + } + else { + drawBorders && this.drawBorders(ctx, styleOverride); + } + drawControls && this.drawControls(ctx, styleOverride); + ctx.restore(); + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _setShadow: function(ctx) { + if (!this.shadow) { + return; + } + + var shadow = this.shadow, canvas = this.canvas, scaling, + multX = (canvas && canvas.viewportTransform[0]) || 1, + multY = (canvas && canvas.viewportTransform[3]) || 1; + if (shadow.nonScaling) { + scaling = { scaleX: 1, scaleY: 1 }; + } + else { + scaling = this.getObjectScaling(); + } + if (canvas && canvas._isRetinaScaling()) { + multX *= fabric.devicePixelRatio; + multY *= fabric.devicePixelRatio; + } + ctx.shadowColor = shadow.color; + ctx.shadowBlur = shadow.blur * fabric.browserShadowBlurConstant * + (multX + multY) * (scaling.scaleX + scaling.scaleY) / 4; + ctx.shadowOffsetX = shadow.offsetX * multX * scaling.scaleX; + ctx.shadowOffsetY = shadow.offsetY * multY * scaling.scaleY; + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _removeShadow: function(ctx) { + if (!this.shadow) { + return; + } + + ctx.shadowColor = ''; + ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0; + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + * @param {Object} filler fabric.Pattern or fabric.Gradient + * @return {Object} offset.offsetX offset for text rendering + * @return {Object} offset.offsetY offset for text rendering + */ + _applyPatternGradientTransform: function(ctx, filler) { + if (!filler || !filler.toLive) { + return { offsetX: 0, offsetY: 0 }; + } + var t = filler.gradientTransform || filler.patternTransform; + var offsetX = -this.width / 2 + filler.offsetX || 0, + offsetY = -this.height / 2 + filler.offsetY || 0; + + if (filler.gradientUnits === 'percentage') { + ctx.transform(this.width, 0, 0, this.height, offsetX, offsetY); + } + else { + ctx.transform(1, 0, 0, 1, offsetX, offsetY); + } + if (t) { + ctx.transform(t[0], t[1], t[2], t[3], t[4], t[5]); + } + return { offsetX: offsetX, offsetY: offsetY }; + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _renderPaintInOrder: function(ctx) { + if (this.paintFirst === 'stroke') { + this._renderStroke(ctx); + this._renderFill(ctx); + } + else { + this._renderFill(ctx); + this._renderStroke(ctx); + } + }, + + /** + * @private + * function that actually render something on the context. + * empty here to allow Obects to work on tests to benchmark fabric functionalites + * not related to rendering + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _render: function(/* ctx */) { + + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _renderFill: function(ctx) { + if (!this.fill) { + return; + } + + ctx.save(); + this._setFillStyles(ctx, this); + if (this.fillRule === 'evenodd') { + ctx.fill('evenodd'); + } + else { + ctx.fill(); + } + ctx.restore(); + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _renderStroke: function(ctx) { + if (!this.stroke || this.strokeWidth === 0) { + return; + } + + if (this.shadow && !this.shadow.affectStroke) { + this._removeShadow(ctx); + } + + ctx.save(); + if (this.strokeUniform && this.group) { + var scaling = this.getObjectScaling(); + ctx.scale(1 / scaling.scaleX, 1 / scaling.scaleY); + } + else if (this.strokeUniform) { + ctx.scale(1 / this.scaleX, 1 / this.scaleY); + } + this._setLineDash(ctx, this.strokeDashArray); + this._setStrokeStyles(ctx, this); + ctx.stroke(); + ctx.restore(); + }, + + /** + * This function try to patch the missing gradientTransform on canvas gradients. + * transforming a context to transform the gradient, is going to transform the stroke too. + * we want to transform the gradient but not the stroke operation, so we create + * a transformed gradient on a pattern and then we use the pattern instead of the gradient. + * this method has drwabacks: is slow, is in low resolution, needs a patch for when the size + * is limited. + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + * @param {fabric.Gradient} filler a fabric gradient instance + */ + _applyPatternForTransformedGradient: function(ctx, filler) { + var dims = this._limitCacheSize(this._getCacheCanvasDimensions()), + pCanvas = fabric.util.createCanvasElement(), pCtx, retinaScaling = this.canvas.getRetinaScaling(), + width = dims.x / this.scaleX / retinaScaling, height = dims.y / this.scaleY / retinaScaling; + pCanvas.width = width; + pCanvas.height = height; + pCtx = pCanvas.getContext('2d'); + pCtx.beginPath(); pCtx.moveTo(0, 0); pCtx.lineTo(width, 0); pCtx.lineTo(width, height); + pCtx.lineTo(0, height); pCtx.closePath(); + pCtx.translate(width / 2, height / 2); + pCtx.scale( + dims.zoomX / this.scaleX / retinaScaling, + dims.zoomY / this.scaleY / retinaScaling + ); + this._applyPatternGradientTransform(pCtx, filler); + pCtx.fillStyle = filler.toLive(ctx); + pCtx.fill(); + ctx.translate(-this.width / 2 - this.strokeWidth / 2, -this.height / 2 - this.strokeWidth / 2); + ctx.scale( + retinaScaling * this.scaleX / dims.zoomX, + retinaScaling * this.scaleY / dims.zoomY + ); + ctx.strokeStyle = pCtx.createPattern(pCanvas, 'no-repeat'); + }, + + /** + * This function is an helper for svg import. it returns the center of the object in the svg + * untransformed coordinates + * @private + * @return {Object} center point from element coordinates + */ + _findCenterFromElement: function() { + return { x: this.left + this.width / 2, y: this.top + this.height / 2 }; + }, + + /** + * This function is an helper for svg import. it decompose the transformMatrix + * and assign properties to object. + * untransformed coordinates + * @private + * @chainable + */ + _assignTransformMatrixProps: function() { + if (this.transformMatrix) { + var options = fabric.util.qrDecompose(this.transformMatrix); + this.flipX = false; + this.flipY = false; + this.set('scaleX', options.scaleX); + this.set('scaleY', options.scaleY); + this.angle = options.angle; + this.skewX = options.skewX; + this.skewY = 0; + } + }, + + /** + * This function is an helper for svg import. it removes the transform matrix + * and set to object properties that fabricjs can handle + * @private + * @param {Object} preserveAspectRatioOptions + * @return {thisArg} + */ + _removeTransformMatrix: function(preserveAspectRatioOptions) { + var center = this._findCenterFromElement(); + if (this.transformMatrix) { + this._assignTransformMatrixProps(); + center = fabric.util.transformPoint(center, this.transformMatrix); + } + this.transformMatrix = null; + if (preserveAspectRatioOptions) { + this.scaleX *= preserveAspectRatioOptions.scaleX; + this.scaleY *= preserveAspectRatioOptions.scaleY; + this.cropX = preserveAspectRatioOptions.cropX; + this.cropY = preserveAspectRatioOptions.cropY; + center.x += preserveAspectRatioOptions.offsetLeft; + center.y += preserveAspectRatioOptions.offsetTop; + this.width = preserveAspectRatioOptions.width; + this.height = preserveAspectRatioOptions.height; + } + this.setPositionByOrigin(center, 'center', 'center'); + }, + + /** + * Clones an instance, using a callback method will work for every object. + * @param {Function} callback Callback is invoked with a clone as a first argument + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + */ + clone: function(callback, propertiesToInclude) { + var objectForm = this.toObject(propertiesToInclude); + if (this.constructor.fromObject) { + this.constructor.fromObject(objectForm, callback); + } + else { + fabric.Object._fromObject('Object', objectForm, callback); + } + }, + + /** + * Creates an instance of fabric.Image out of an object + * makes use of toCanvasElement. + * Once this method was based on toDataUrl and loadImage, so it also had a quality + * and format option. toCanvasElement is faster and produce no loss of quality. + * If you need to get a real Jpeg or Png from an object, using toDataURL is the right way to do it. + * toCanvasElement and then toBlob from the obtained canvas is also a good option. + * This method is sync now, but still support the callback because we did not want to break. + * When fabricJS 5.0 will be planned, this will probably be changed to not have a callback. + * @param {Function} callback callback, invoked with an instance as a first argument + * @param {Object} [options] for clone as image, passed to toDataURL + * @param {Number} [options.multiplier=1] Multiplier to scale by + * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14 + * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14 + * @param {Number} [options.width] Cropping width. Introduced in v1.2.14 + * @param {Number} [options.height] Cropping height. Introduced in v1.2.14 + * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4 + * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4 + * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2 + * @return {fabric.Object} thisArg + */ + cloneAsImage: function(callback, options) { + var canvasEl = this.toCanvasElement(options); + if (callback) { + callback(new fabric.Image(canvasEl)); + } + return this; + }, + + /** + * Converts an object into a HTMLCanvas element + * @param {Object} options Options object + * @param {Number} [options.multiplier=1] Multiplier to scale by + * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14 + * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14 + * @param {Number} [options.width] Cropping width. Introduced in v1.2.14 + * @param {Number} [options.height] Cropping height. Introduced in v1.2.14 + * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4 + * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4 + * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2 + * @return {HTMLCanvasElement} Returns DOM element with the fabric.Object + */ + toCanvasElement: function(options) { + options || (options = { }); + + var utils = fabric.util, origParams = utils.saveObjectTransform(this), + originalGroup = this.group, + originalShadow = this.shadow, abs = Math.abs, + multiplier = (options.multiplier || 1) * (options.enableRetinaScaling ? fabric.devicePixelRatio : 1); + delete this.group; + if (options.withoutTransform) { + utils.resetObjectTransform(this); + } + if (options.withoutShadow) { + this.shadow = null; + } + + var el = fabric.util.createCanvasElement(), + // skip canvas zoom and calculate with setCoords now. + boundingRect = this.getBoundingRect(true, true), + shadow = this.shadow, scaling, + shadowOffset = { x: 0, y: 0 }, shadowBlur, + width, height; + + if (shadow) { + shadowBlur = shadow.blur; + if (shadow.nonScaling) { + scaling = { scaleX: 1, scaleY: 1 }; + } + else { + scaling = this.getObjectScaling(); + } + // consider non scaling shadow. + shadowOffset.x = 2 * Math.round(abs(shadow.offsetX) + shadowBlur) * (abs(scaling.scaleX)); + shadowOffset.y = 2 * Math.round(abs(shadow.offsetY) + shadowBlur) * (abs(scaling.scaleY)); + } + width = boundingRect.width + shadowOffset.x; + height = boundingRect.height + shadowOffset.y; + // if the current width/height is not an integer + // we need to make it so. + el.width = Math.ceil(width); + el.height = Math.ceil(height); + var canvas = new fabric.StaticCanvas(el, { + enableRetinaScaling: false, + renderOnAddRemove: false, + skipOffscreen: false, + }); + if (options.format === 'jpeg') { + canvas.backgroundColor = '#fff'; + } + this.setPositionByOrigin(new fabric.Point(canvas.width / 2, canvas.height / 2), 'center', 'center'); + + var originalCanvas = this.canvas; + canvas.add(this); + var canvasEl = canvas.toCanvasElement(multiplier || 1, options); + this.shadow = originalShadow; + this.set('canvas', originalCanvas); + if (originalGroup) { + this.group = originalGroup; + } + this.set(origParams).setCoords(); + // canvas.dispose will call image.dispose that will nullify the elements + // since this canvas is a simple element for the process, we remove references + // to objects in this way in order to avoid object trashing. + canvas._objects = []; + canvas.dispose(); + canvas = null; + + return canvasEl; + }, + + /** + * Converts an object into a data-url-like string + * @param {Object} options Options object + * @param {String} [options.format=png] The format of the output image. Either "jpeg" or "png" + * @param {Number} [options.quality=1] Quality level (0..1). Only used for jpeg. + * @param {Number} [options.multiplier=1] Multiplier to scale by + * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14 + * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14 + * @param {Number} [options.width] Cropping width. Introduced in v1.2.14 + * @param {Number} [options.height] Cropping height. Introduced in v1.2.14 + * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4 + * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4 + * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2 + * @return {String} Returns a data: URL containing a representation of the object in the format specified by options.format + */ + toDataURL: function(options) { + options || (options = { }); + return fabric.util.toDataURL(this.toCanvasElement(options), options.format || 'png', options.quality || 1); + }, + + /** + * Returns true if specified type is identical to the type of an instance + * @param {String} type Type to check against + * @return {Boolean} + */ + isType: function(type) { + return arguments.length > 1 ? Array.from(arguments).includes(this.type) : this.type === type; + }, + + /** + * Returns complexity of an instance + * @return {Number} complexity of this instance (is 1 unless subclassed) + */ + complexity: function() { + return 1; + }, + + /** + * Returns a JSON representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} JSON + */ + toJSON: function(propertiesToInclude) { + // delegate, not alias + return this.toObject(propertiesToInclude); + }, + + /** + * Sets "angle" of an instance with centered rotation + * @param {Number} angle Angle value (in degrees) + * @return {fabric.Object} thisArg + * @chainable + */ + rotate: function(angle) { + var shouldCenterOrigin = (this.originX !== 'center' || this.originY !== 'center') && this.centeredRotation; + + if (shouldCenterOrigin) { + this._setOriginToCenter(); + } + + this.set('angle', angle); + + if (shouldCenterOrigin) { + this._resetOrigin(); + } + + return this; + }, + + /** + * Centers object horizontally on canvas to which it was added last. + * You might need to call `setCoords` on an object after centering, to update controls area. + * @return {fabric.Object} thisArg + * @chainable + */ + centerH: function () { + this.canvas && this.canvas.centerObjectH(this); + return this; + }, + + /** + * Centers object horizontally on current viewport of canvas to which it was added last. + * You might need to call `setCoords` on an object after centering, to update controls area. + * @return {fabric.Object} thisArg + * @chainable + */ + viewportCenterH: function () { + this.canvas && this.canvas.viewportCenterObjectH(this); + return this; + }, + + /** + * Centers object vertically on canvas to which it was added last. + * You might need to call `setCoords` on an object after centering, to update controls area. + * @return {fabric.Object} thisArg + * @chainable + */ + centerV: function () { + this.canvas && this.canvas.centerObjectV(this); + return this; + }, + + /** + * Centers object vertically on current viewport of canvas to which it was added last. + * You might need to call `setCoords` on an object after centering, to update controls area. + * @return {fabric.Object} thisArg + * @chainable + */ + viewportCenterV: function () { + this.canvas && this.canvas.viewportCenterObjectV(this); + return this; + }, + + /** + * Centers object vertically and horizontally on canvas to which is was added last + * You might need to call `setCoords` on an object after centering, to update controls area. + * @return {fabric.Object} thisArg + * @chainable + */ + center: function () { + this.canvas && this.canvas.centerObject(this); + return this; + }, + + /** + * Centers object on current viewport of canvas to which it was added last. + * You might need to call `setCoords` on an object after centering, to update controls area. + * @return {fabric.Object} thisArg + * @chainable + */ + viewportCenter: function () { + this.canvas && this.canvas.viewportCenterObject(this); + return this; + }, + + /** + * Returns coordinates of a pointer relative to an object + * @param {Event} e Event to operate upon + * @param {Object} [pointer] Pointer to operate upon (instead of event) + * @return {Object} Coordinates of a pointer (x, y) + */ + getLocalPointer: function(e, pointer) { + pointer = pointer || this.canvas.getPointer(e); + var pClicked = new fabric.Point(pointer.x, pointer.y), + objectLeftTop = this._getLeftTopCoords(); + if (this.angle) { + pClicked = fabric.util.rotatePoint( + pClicked, objectLeftTop, degreesToRadians(-this.angle)); + } + return { + x: pClicked.x - objectLeftTop.x, + y: pClicked.y - objectLeftTop.y + }; + }, + + /** + * Sets canvas globalCompositeOperation for specific object + * custom composition operation for the particular object can be specified using globalCompositeOperation property + * @param {CanvasRenderingContext2D} ctx Rendering canvas context + */ + _setupCompositeOperation: function (ctx) { + if (this.globalCompositeOperation) { + ctx.globalCompositeOperation = this.globalCompositeOperation; + } + }, + + /** + * cancel instance's running animations + * override if necessary to dispose artifacts such as `clipPath` + */ + dispose: function () { + if (fabric.runningAnimations) { + fabric.runningAnimations.cancelByTarget(this); + } + } + }); + + fabric.util.createAccessors && fabric.util.createAccessors(fabric.Object); + + extend(fabric.Object.prototype, fabric.Observable); + + /** + * Defines the number of fraction digits to use when serializing object values. + * You can use it to increase/decrease precision of such values like left, top, scaleX, scaleY, etc. + * @static + * @memberOf fabric.Object + * @constant + * @type Number + */ + fabric.Object.NUM_FRACTION_DIGITS = 2; + + /** + * Defines which properties should be enlivened from the object passed to {@link fabric.Object._fromObject} + * @static + * @memberOf fabric.Object + * @constant + * @type string[] + */ + fabric.Object.ENLIVEN_PROPS = ['clipPath']; + + fabric.Object._fromObject = function(className, object, callback, extraParam) { + var klass = fabric[className]; + object = clone(object, true); + fabric.util.enlivenPatterns([object.fill, object.stroke], function(patterns) { + if (typeof patterns[0] !== 'undefined') { + object.fill = patterns[0]; + } + if (typeof patterns[1] !== 'undefined') { + object.stroke = patterns[1]; + } + fabric.util.enlivenObjectEnlivables(object, object, function () { + var instance = extraParam ? new klass(object[extraParam], object) : new klass(object); + callback && callback(instance); + }); + }); + }; + + /** + * Unique id used internally when creating SVG elements + * @static + * @memberOf fabric.Object + * @type Number + */ + fabric.Object.__uid = 0; +})(typeof exports !== 'undefined' ? exports : this); + + +(function() { + + var degreesToRadians = fabric.util.degreesToRadians, + originXOffset = { + left: -0.5, + center: 0, + right: 0.5 + }, + originYOffset = { + top: -0.5, + center: 0, + bottom: 0.5 + }; + + fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ { + + /** + * Translates the coordinates from a set of origin to another (based on the object's dimensions) + * @param {fabric.Point} point The point which corresponds to the originX and originY params + * @param {String} fromOriginX Horizontal origin: 'left', 'center' or 'right' + * @param {String} fromOriginY Vertical origin: 'top', 'center' or 'bottom' + * @param {String} toOriginX Horizontal origin: 'left', 'center' or 'right' + * @param {String} toOriginY Vertical origin: 'top', 'center' or 'bottom' + * @return {fabric.Point} + */ + translateToGivenOrigin: function(point, fromOriginX, fromOriginY, toOriginX, toOriginY) { + var x = point.x, + y = point.y, + offsetX, offsetY, dim; + + if (typeof fromOriginX === 'string') { + fromOriginX = originXOffset[fromOriginX]; + } + else { + fromOriginX -= 0.5; + } + + if (typeof toOriginX === 'string') { + toOriginX = originXOffset[toOriginX]; + } + else { + toOriginX -= 0.5; + } + + offsetX = toOriginX - fromOriginX; + + if (typeof fromOriginY === 'string') { + fromOriginY = originYOffset[fromOriginY]; + } + else { + fromOriginY -= 0.5; + } + + if (typeof toOriginY === 'string') { + toOriginY = originYOffset[toOriginY]; + } + else { + toOriginY -= 0.5; + } + + offsetY = toOriginY - fromOriginY; + + if (offsetX || offsetY) { + dim = this._getTransformedDimensions(); + x = point.x + offsetX * dim.x; + y = point.y + offsetY * dim.y; + } + + return new fabric.Point(x, y); + }, + + /** + * Translates the coordinates from origin to center coordinates (based on the object's dimensions) + * @param {fabric.Point} point The point which corresponds to the originX and originY params + * @param {String} originX Horizontal origin: 'left', 'center' or 'right' + * @param {String} originY Vertical origin: 'top', 'center' or 'bottom' + * @return {fabric.Point} + */ + translateToCenterPoint: function(point, originX, originY) { + var p = this.translateToGivenOrigin(point, originX, originY, 'center', 'center'); + if (this.angle) { + return fabric.util.rotatePoint(p, point, degreesToRadians(this.angle)); + } + return p; + }, + + /** + * Translates the coordinates from center to origin coordinates (based on the object's dimensions) + * @param {fabric.Point} center The point which corresponds to center of the object + * @param {String} originX Horizontal origin: 'left', 'center' or 'right' + * @param {String} originY Vertical origin: 'top', 'center' or 'bottom' + * @return {fabric.Point} + */ + translateToOriginPoint: function(center, originX, originY) { + var p = this.translateToGivenOrigin(center, 'center', 'center', originX, originY); + if (this.angle) { + return fabric.util.rotatePoint(p, center, degreesToRadians(this.angle)); + } + return p; + }, + + /** + * Returns the real center coordinates of the object + * @return {fabric.Point} + */ + getCenterPoint: function() { + var leftTop = new fabric.Point(this.left, this.top); + return this.translateToCenterPoint(leftTop, this.originX, this.originY); + }, + + /** + * Returns the coordinates of the object based on center coordinates + * @param {fabric.Point} point The point which corresponds to the originX and originY params + * @return {fabric.Point} + */ + // getOriginPoint: function(center) { + // return this.translateToOriginPoint(center, this.originX, this.originY); + // }, + + /** + * Returns the coordinates of the object as if it has a different origin + * @param {String} originX Horizontal origin: 'left', 'center' or 'right' + * @param {String} originY Vertical origin: 'top', 'center' or 'bottom' + * @return {fabric.Point} + */ + getPointByOrigin: function(originX, originY) { + var center = this.getCenterPoint(); + return this.translateToOriginPoint(center, originX, originY); + }, + + /** + * Returns the point in local coordinates + * @param {fabric.Point} point The point relative to the global coordinate system + * @param {String} originX Horizontal origin: 'left', 'center' or 'right' + * @param {String} originY Vertical origin: 'top', 'center' or 'bottom' + * @return {fabric.Point} + */ + toLocalPoint: function(point, originX, originY) { + var center = this.getCenterPoint(), + p, p2; + + if (typeof originX !== 'undefined' && typeof originY !== 'undefined' ) { + p = this.translateToGivenOrigin(center, 'center', 'center', originX, originY); + } + else { + p = new fabric.Point(this.left, this.top); + } + + p2 = new fabric.Point(point.x, point.y); + if (this.angle) { + p2 = fabric.util.rotatePoint(p2, center, -degreesToRadians(this.angle)); + } + return p2.subtractEquals(p); + }, + + /** + * Returns the point in global coordinates + * @param {fabric.Point} The point relative to the local coordinate system + * @return {fabric.Point} + */ + // toGlobalPoint: function(point) { + // return fabric.util.rotatePoint(point, this.getCenterPoint(), degreesToRadians(this.angle)).addEquals(new fabric.Point(this.left, this.top)); + // }, + + /** + * Sets the position of the object taking into consideration the object's origin + * @param {fabric.Point} pos The new position of the object + * @param {String} originX Horizontal origin: 'left', 'center' or 'right' + * @param {String} originY Vertical origin: 'top', 'center' or 'bottom' + * @return {void} + */ + setPositionByOrigin: function(pos, originX, originY) { + var center = this.translateToCenterPoint(pos, originX, originY), + position = this.translateToOriginPoint(center, this.originX, this.originY); + this.set('left', position.x); + this.set('top', position.y); + }, + + /** + * @param {String} to One of 'left', 'center', 'right' + */ + adjustPosition: function(to) { + var angle = degreesToRadians(this.angle), + hypotFull = this.getScaledWidth(), + xFull = fabric.util.cos(angle) * hypotFull, + yFull = fabric.util.sin(angle) * hypotFull, + offsetFrom, offsetTo; + + //TODO: this function does not consider mixed situation like top, center. + if (typeof this.originX === 'string') { + offsetFrom = originXOffset[this.originX]; + } + else { + offsetFrom = this.originX - 0.5; + } + if (typeof to === 'string') { + offsetTo = originXOffset[to]; + } + else { + offsetTo = to - 0.5; + } + this.left += xFull * (offsetTo - offsetFrom); + this.top += yFull * (offsetTo - offsetFrom); + this.setCoords(); + this.originX = to; + }, + + /** + * Sets the origin/position of the object to it's center point + * @private + * @return {void} + */ + _setOriginToCenter: function() { + this._originalOriginX = this.originX; + this._originalOriginY = this.originY; + + var center = this.getCenterPoint(); + + this.originX = 'center'; + this.originY = 'center'; + + this.left = center.x; + this.top = center.y; + }, + + /** + * Resets the origin/position of the object to it's original origin + * @private + * @return {void} + */ + _resetOrigin: function() { + var originPoint = this.translateToOriginPoint( + this.getCenterPoint(), + this._originalOriginX, + this._originalOriginY); + + this.originX = this._originalOriginX; + this.originY = this._originalOriginY; + + this.left = originPoint.x; + this.top = originPoint.y; + + this._originalOriginX = null; + this._originalOriginY = null; + }, + + /** + * @private + */ + _getLeftTopCoords: function() { + return this.translateToOriginPoint(this.getCenterPoint(), 'left', 'top'); + }, + }); + +})(); + + +(function() { + + function arrayFromCoords(coords) { + return [ + new fabric.Point(coords.tl.x, coords.tl.y), + new fabric.Point(coords.tr.x, coords.tr.y), + new fabric.Point(coords.br.x, coords.br.y), + new fabric.Point(coords.bl.x, coords.bl.y) + ]; + } + + var util = fabric.util, + degreesToRadians = util.degreesToRadians, + multiplyMatrices = util.multiplyTransformMatrices, + transformPoint = util.transformPoint; + + util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ { + + /** + * Describe object's corner position in canvas element coordinates. + * properties are depending on control keys and padding the main controls. + * each property is an object with x, y and corner. + * The `corner` property contains in a similar manner the 4 points of the + * interactive area of the corner. + * The coordinates depends from the controls positionHandler and are used + * to draw and locate controls + * @memberOf fabric.Object.prototype + */ + oCoords: null, + + /** + * Describe object's corner position in canvas object absolute coordinates + * properties are tl,tr,bl,br and describe the four main corner. + * each property is an object with x, y, instance of Fabric.Point. + * The coordinates depends from this properties: width, height, scaleX, scaleY + * skewX, skewY, angle, strokeWidth, top, left. + * Those coordinates are useful to understand where an object is. They get updated + * with oCoords but they do not need to be updated when zoom or panning change. + * The coordinates get updated with @method setCoords. + * You can calculate them without updating with @method calcACoords(); + * @memberOf fabric.Object.prototype + */ + aCoords: null, + + /** + * Describe object's corner position in canvas element coordinates. + * includes padding. Used of object detection. + * set and refreshed with setCoords. + * @memberOf fabric.Object.prototype + */ + lineCoords: null, + + /** + * storage for object transform matrix + */ + ownMatrixCache: null, + + /** + * storage for object full transform matrix + */ + matrixCache: null, + + /** + * custom controls interface + * controls are added by default_controls.js + */ + controls: { }, + + /** + * return correct set of coordinates for intersection + * this will return either aCoords or lineCoords. + * @param {Boolean} absolute will return aCoords if true or lineCoords + * @return {Object} {tl, tr, br, bl} points + */ + _getCoords: function(absolute, calculate) { + if (calculate) { + return (absolute ? this.calcACoords() : this.calcLineCoords()); + } + if (!this.aCoords || !this.lineCoords) { + this.setCoords(true); + } + return (absolute ? this.aCoords : this.lineCoords); + }, + + /** + * return correct set of coordinates for intersection + * this will return either aCoords or lineCoords. + * The coords are returned in an array. + * @return {Array} [tl, tr, br, bl] of points + */ + getCoords: function(absolute, calculate) { + return arrayFromCoords(this._getCoords(absolute, calculate)); + }, + + /** + * Checks if object intersects with an area formed by 2 points + * @param {Object} pointTL top-left point of area + * @param {Object} pointBR bottom-right point of area + * @param {Boolean} [absolute] use coordinates without viewportTransform + * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords + * @return {Boolean} true if object intersects with an area formed by 2 points + */ + intersectsWithRect: function(pointTL, pointBR, absolute, calculate) { + var coords = this.getCoords(absolute, calculate), + intersection = fabric.Intersection.intersectPolygonRectangle( + coords, + pointTL, + pointBR + ); + return intersection.status === 'Intersection'; + }, + + /** + * Checks if object intersects with another object + * @param {Object} other Object to test + * @param {Boolean} [absolute] use coordinates without viewportTransform + * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords + * @return {Boolean} true if object intersects with another object + */ + intersectsWithObject: function(other, absolute, calculate) { + var intersection = fabric.Intersection.intersectPolygonPolygon( + this.getCoords(absolute, calculate), + other.getCoords(absolute, calculate) + ); + + return intersection.status === 'Intersection' + || other.isContainedWithinObject(this, absolute, calculate) + || this.isContainedWithinObject(other, absolute, calculate); + }, + + /** + * Checks if object is fully contained within area of another object + * @param {Object} other Object to test + * @param {Boolean} [absolute] use coordinates without viewportTransform + * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords + * @return {Boolean} true if object is fully contained within area of another object + */ + isContainedWithinObject: function(other, absolute, calculate) { + var points = this.getCoords(absolute, calculate), + otherCoords = absolute ? other.aCoords : other.lineCoords, + i = 0, lines = other._getImageLines(otherCoords); + for (; i < 4; i++) { + if (!other.containsPoint(points[i], lines)) { + return false; + } + } + return true; + }, + + /** + * Checks if object is fully contained within area formed by 2 points + * @param {Object} pointTL top-left point of area + * @param {Object} pointBR bottom-right point of area + * @param {Boolean} [absolute] use coordinates without viewportTransform + * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords + * @return {Boolean} true if object is fully contained within area formed by 2 points + */ + isContainedWithinRect: function(pointTL, pointBR, absolute, calculate) { + var boundingRect = this.getBoundingRect(absolute, calculate); + + return ( + boundingRect.left >= pointTL.x && + boundingRect.left + boundingRect.width <= pointBR.x && + boundingRect.top >= pointTL.y && + boundingRect.top + boundingRect.height <= pointBR.y + ); + }, + + /** + * Checks if point is inside the object + * @param {fabric.Point} point Point to check against + * @param {Object} [lines] object returned from @method _getImageLines + * @param {Boolean} [absolute] use coordinates without viewportTransform + * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords + * @return {Boolean} true if point is inside the object + */ + containsPoint: function(point, lines, absolute, calculate) { + var coords = this._getCoords(absolute, calculate), + lines = lines || this._getImageLines(coords), + xPoints = this._findCrossPoints(point, lines); + // if xPoints is odd then point is inside the object + return (xPoints !== 0 && xPoints % 2 === 1); + }, + + /** + * Checks if object is contained within the canvas with current viewportTransform + * the check is done stopping at first point that appears on screen + * @param {Boolean} [calculate] use coordinates of current position instead of .aCoords + * @return {Boolean} true if object is fully or partially contained within canvas + */ + isOnScreen: function(calculate) { + if (!this.canvas) { + return false; + } + var pointTL = this.canvas.vptCoords.tl, pointBR = this.canvas.vptCoords.br; + var points = this.getCoords(true, calculate); + // if some point is on screen, the object is on screen. + if (points.some(function(point) { + return point.x <= pointBR.x && point.x >= pointTL.x && + point.y <= pointBR.y && point.y >= pointTL.y; + })) { + return true; + } + // no points on screen, check intersection with absolute coordinates + if (this.intersectsWithRect(pointTL, pointBR, true, calculate)) { + return true; + } + return this._containsCenterOfCanvas(pointTL, pointBR, calculate); + }, + + /** + * Checks if the object contains the midpoint between canvas extremities + * Does not make sense outside the context of isOnScreen and isPartiallyOnScreen + * @private + * @param {Fabric.Point} pointTL Top Left point + * @param {Fabric.Point} pointBR Top Right point + * @param {Boolean} calculate use coordinates of current position instead of .oCoords + * @return {Boolean} true if the object contains the point + */ + _containsCenterOfCanvas: function(pointTL, pointBR, calculate) { + // worst case scenario the object is so big that contains the screen + var centerPoint = { x: (pointTL.x + pointBR.x) / 2, y: (pointTL.y + pointBR.y) / 2 }; + if (this.containsPoint(centerPoint, null, true, calculate)) { + return true; + } + return false; + }, + + /** + * Checks if object is partially contained within the canvas with current viewportTransform + * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords + * @return {Boolean} true if object is partially contained within canvas + */ + isPartiallyOnScreen: function(calculate) { + if (!this.canvas) { + return false; + } + var pointTL = this.canvas.vptCoords.tl, pointBR = this.canvas.vptCoords.br; + if (this.intersectsWithRect(pointTL, pointBR, true, calculate)) { + return true; + } + var allPointsAreOutside = this.getCoords(true, calculate).every(function(point) { + return (point.x >= pointBR.x || point.x <= pointTL.x) && + (point.y >= pointBR.y || point.y <= pointTL.y); + }); + return allPointsAreOutside && this._containsCenterOfCanvas(pointTL, pointBR, calculate); + }, + + /** + * Method that returns an object with the object edges in it, given the coordinates of the corners + * @private + * @param {Object} oCoords Coordinates of the object corners + */ + _getImageLines: function(oCoords) { + + var lines = { + topline: { + o: oCoords.tl, + d: oCoords.tr + }, + rightline: { + o: oCoords.tr, + d: oCoords.br + }, + bottomline: { + o: oCoords.br, + d: oCoords.bl + }, + leftline: { + o: oCoords.bl, + d: oCoords.tl + } + }; + + // // debugging + // if (this.canvas.contextTop) { + // this.canvas.contextTop.fillRect(lines.bottomline.d.x, lines.bottomline.d.y, 2, 2); + // this.canvas.contextTop.fillRect(lines.bottomline.o.x, lines.bottomline.o.y, 2, 2); + // + // this.canvas.contextTop.fillRect(lines.leftline.d.x, lines.leftline.d.y, 2, 2); + // this.canvas.contextTop.fillRect(lines.leftline.o.x, lines.leftline.o.y, 2, 2); + // + // this.canvas.contextTop.fillRect(lines.topline.d.x, lines.topline.d.y, 2, 2); + // this.canvas.contextTop.fillRect(lines.topline.o.x, lines.topline.o.y, 2, 2); + // + // this.canvas.contextTop.fillRect(lines.rightline.d.x, lines.rightline.d.y, 2, 2); + // this.canvas.contextTop.fillRect(lines.rightline.o.x, lines.rightline.o.y, 2, 2); + // } + + return lines; + }, + + /** + * Helper method to determine how many cross points are between the 4 object edges + * and the horizontal line determined by a point on canvas + * @private + * @param {fabric.Point} point Point to check + * @param {Object} lines Coordinates of the object being evaluated + */ + // remove yi, not used but left code here just in case. + _findCrossPoints: function(point, lines) { + var b1, b2, a1, a2, xi, // yi, + xcount = 0, + iLine; + + for (var lineKey in lines) { + iLine = lines[lineKey]; + // optimisation 1: line below point. no cross + if ((iLine.o.y < point.y) && (iLine.d.y < point.y)) { + continue; + } + // optimisation 2: line above point. no cross + if ((iLine.o.y >= point.y) && (iLine.d.y >= point.y)) { + continue; + } + // optimisation 3: vertical line case + if ((iLine.o.x === iLine.d.x) && (iLine.o.x >= point.x)) { + xi = iLine.o.x; + // yi = point.y; + } + // calculate the intersection point + else { + b1 = 0; + b2 = (iLine.d.y - iLine.o.y) / (iLine.d.x - iLine.o.x); + a1 = point.y - b1 * point.x; + a2 = iLine.o.y - b2 * iLine.o.x; + + xi = -(a1 - a2) / (b1 - b2); + // yi = a1 + b1 * xi; + } + // dont count xi < point.x cases + if (xi >= point.x) { + xcount += 1; + } + // optimisation 4: specific for square images + if (xcount === 2) { + break; + } + } + return xcount; + }, + + /** + * Returns coordinates of object's bounding rectangle (left, top, width, height) + * the box is intended as aligned to axis of canvas. + * @param {Boolean} [absolute] use coordinates without viewportTransform + * @param {Boolean} [calculate] use coordinates of current position instead of .oCoords / .aCoords + * @return {Object} Object with left, top, width, height properties + */ + getBoundingRect: function(absolute, calculate) { + var coords = this.getCoords(absolute, calculate); + return util.makeBoundingBoxFromPoints(coords); + }, + + /** + * Returns width of an object's bounding box counting transformations + * before 2.0 it was named getWidth(); + * @return {Number} width value + */ + getScaledWidth: function() { + return this._getTransformedDimensions().x; + }, + + /** + * Returns height of an object bounding box counting transformations + * before 2.0 it was named getHeight(); + * @return {Number} height value + */ + getScaledHeight: function() { + return this._getTransformedDimensions().y; + }, + + /** + * Makes sure the scale is valid and modifies it if necessary + * @private + * @param {Number} value + * @return {Number} + */ + _constrainScale: function(value) { + if (Math.abs(value) < this.minScaleLimit) { + if (value < 0) { + return -this.minScaleLimit; + } + else { + return this.minScaleLimit; + } + } + else if (value === 0) { + return 0.0001; + } + return value; + }, + + /** + * Scales an object (equally by x and y) + * @param {Number} value Scale factor + * @return {fabric.Object} thisArg + * @chainable + */ + scale: function(value) { + this._set('scaleX', value); + this._set('scaleY', value); + return this.setCoords(); + }, + + /** + * Scales an object to a given width, with respect to bounding box (scaling by x/y equally) + * @param {Number} value New width value + * @param {Boolean} absolute ignore viewport + * @return {fabric.Object} thisArg + * @chainable + */ + scaleToWidth: function(value, absolute) { + // adjust to bounding rect factor so that rotated shapes would fit as well + var boundingRectFactor = this.getBoundingRect(absolute).width / this.getScaledWidth(); + return this.scale(value / this.width / boundingRectFactor); + }, + + /** + * Scales an object to a given height, with respect to bounding box (scaling by x/y equally) + * @param {Number} value New height value + * @param {Boolean} absolute ignore viewport + * @return {fabric.Object} thisArg + * @chainable + */ + scaleToHeight: function(value, absolute) { + // adjust to bounding rect factor so that rotated shapes would fit as well + var boundingRectFactor = this.getBoundingRect(absolute).height / this.getScaledHeight(); + return this.scale(value / this.height / boundingRectFactor); + }, + + calcLineCoords: function() { + var vpt = this.getViewportTransform(), + padding = this.padding, angle = degreesToRadians(this.angle), + cos = util.cos(angle), sin = util.sin(angle), + cosP = cos * padding, sinP = sin * padding, cosPSinP = cosP + sinP, + cosPMinusSinP = cosP - sinP, aCoords = this.calcACoords(); + + var lineCoords = { + tl: transformPoint(aCoords.tl, vpt), + tr: transformPoint(aCoords.tr, vpt), + bl: transformPoint(aCoords.bl, vpt), + br: transformPoint(aCoords.br, vpt), + }; + + if (padding) { + lineCoords.tl.x -= cosPMinusSinP; + lineCoords.tl.y -= cosPSinP; + lineCoords.tr.x += cosPSinP; + lineCoords.tr.y -= cosPMinusSinP; + lineCoords.bl.x -= cosPSinP; + lineCoords.bl.y += cosPMinusSinP; + lineCoords.br.x += cosPMinusSinP; + lineCoords.br.y += cosPSinP; + } + + return lineCoords; + }, + + calcOCoords: function() { + var rotateMatrix = this._calcRotateMatrix(), + translateMatrix = this._calcTranslateMatrix(), + vpt = this.getViewportTransform(), + startMatrix = multiplyMatrices(vpt, translateMatrix), + finalMatrix = multiplyMatrices(startMatrix, rotateMatrix), + finalMatrix = multiplyMatrices(finalMatrix, [1 / vpt[0], 0, 0, 1 / vpt[3], 0, 0]), + dim = this._calculateCurrentDimensions(), + coords = {}; + this.forEachControl(function(control, key, fabricObject) { + coords[key] = control.positionHandler(dim, finalMatrix, fabricObject); + }); + + // debug code + // var canvas = this.canvas; + // setTimeout(function() { + // canvas.contextTop.clearRect(0, 0, 700, 700); + // canvas.contextTop.fillStyle = 'green'; + // Object.keys(coords).forEach(function(key) { + // var control = coords[key]; + // canvas.contextTop.fillRect(control.x, control.y, 3, 3); + // }); + // }, 50); + return coords; + }, + + calcACoords: function() { + var rotateMatrix = this._calcRotateMatrix(), + translateMatrix = this._calcTranslateMatrix(), + finalMatrix = multiplyMatrices(translateMatrix, rotateMatrix), + dim = this._getTransformedDimensions(), + w = dim.x / 2, h = dim.y / 2; + return { + // corners + tl: transformPoint({ x: -w, y: -h }, finalMatrix), + tr: transformPoint({ x: w, y: -h }, finalMatrix), + bl: transformPoint({ x: -w, y: h }, finalMatrix), + br: transformPoint({ x: w, y: h }, finalMatrix) + }; + }, + + /** + * Sets corner and controls position coordinates based on current angle, width and height, left and top. + * oCoords are used to find the corners + * aCoords are used to quickly find an object on the canvas + * lineCoords are used to quickly find object during pointer events. + * See {@link https://github.com/fabricjs/fabric.js/wiki/When-to-call-setCoords} and {@link http://fabricjs.com/fabric-gotchas} + * + * @param {Boolean} [skipCorners] skip calculation of oCoords. + * @return {fabric.Object} thisArg + * @chainable + */ + setCoords: function(skipCorners) { + this.aCoords = this.calcACoords(); + // in case we are in a group, for how the inner group target check works, + // lineCoords are exactly aCoords. Since the vpt gets absorbed by the normalized pointer. + this.lineCoords = this.group ? this.aCoords : this.calcLineCoords(); + if (skipCorners) { + return this; + } + // set coordinates of the draggable boxes in the corners used to scale/rotate the image + this.oCoords = this.calcOCoords(); + this._setCornerCoords && this._setCornerCoords(); + return this; + }, + + /** + * calculate rotation matrix of an object + * @return {Array} rotation matrix for the object + */ + _calcRotateMatrix: function() { + return util.calcRotateMatrix(this); + }, + + /** + * calculate the translation matrix for an object transform + * @return {Array} rotation matrix for the object + */ + _calcTranslateMatrix: function() { + var center = this.getCenterPoint(); + return [1, 0, 0, 1, center.x, center.y]; + }, + + transformMatrixKey: function(skipGroup) { + var sep = '_', prefix = ''; + if (!skipGroup && this.group) { + prefix = this.group.transformMatrixKey(skipGroup) + sep; + }; + return prefix + this.top + sep + this.left + sep + this.scaleX + sep + this.scaleY + + sep + this.skewX + sep + this.skewY + sep + this.angle + sep + this.originX + sep + this.originY + + sep + this.width + sep + this.height + sep + this.strokeWidth + this.flipX + this.flipY; + }, + + /** + * calculate transform matrix that represents the current transformations from the + * object's properties. + * @param {Boolean} [skipGroup] return transform matrix for object not counting parent transformations + * There are some situation in which this is useful to avoid the fake rotation. + * @return {Array} transform matrix for the object + */ + calcTransformMatrix: function(skipGroup) { + var matrix = this.calcOwnMatrix(); + if (skipGroup || !this.group) { + return matrix; + } + var key = this.transformMatrixKey(skipGroup), cache = this.matrixCache || (this.matrixCache = {}); + if (cache.key === key) { + return cache.value; + } + if (this.group) { + matrix = multiplyMatrices(this.group.calcTransformMatrix(false), matrix); + } + cache.key = key; + cache.value = matrix; + return matrix; + }, + + /** + * calculate transform matrix that represents the current transformations from the + * object's properties, this matrix does not include the group transformation + * @return {Array} transform matrix for the object + */ + calcOwnMatrix: function() { + var key = this.transformMatrixKey(true), cache = this.ownMatrixCache || (this.ownMatrixCache = {}); + if (cache.key === key) { + return cache.value; + } + var tMatrix = this._calcTranslateMatrix(), + options = { + angle: this.angle, + translateX: tMatrix[4], + translateY: tMatrix[5], + scaleX: this.scaleX, + scaleY: this.scaleY, + skewX: this.skewX, + skewY: this.skewY, + flipX: this.flipX, + flipY: this.flipY, + }; + cache.key = key; + cache.value = util.composeMatrix(options); + return cache.value; + }, + + /* + * Calculate object dimensions from its properties + * @private + * @return {Object} .x width dimension + * @return {Object} .y height dimension + */ + _getNonTransformedDimensions: function() { + var strokeWidth = this.strokeWidth, + w = this.width + strokeWidth, + h = this.height + strokeWidth; + return { x: w, y: h }; + }, + + /* + * Calculate object bounding box dimensions from its properties scale, skew. + * @param {Number} skewX, a value to override current skewX + * @param {Number} skewY, a value to override current skewY + * @private + * @return {Object} .x width dimension + * @return {Object} .y height dimension + */ + _getTransformedDimensions: function(skewX, skewY) { + if (typeof skewX === 'undefined') { + skewX = this.skewX; + } + if (typeof skewY === 'undefined') { + skewY = this.skewY; + } + var dimensions, dimX, dimY, + noSkew = skewX === 0 && skewY === 0; + + if (this.strokeUniform) { + dimX = this.width; + dimY = this.height; + } + else { + dimensions = this._getNonTransformedDimensions(); + dimX = dimensions.x; + dimY = dimensions.y; + } + if (noSkew) { + return this._finalizeDimensions(dimX * this.scaleX, dimY * this.scaleY); + } + var bbox = util.sizeAfterTransform(dimX, dimY, { + scaleX: this.scaleX, + scaleY: this.scaleY, + skewX: skewX, + skewY: skewY, + }); + return this._finalizeDimensions(bbox.x, bbox.y); + }, + + /* + * Calculate object bounding box dimensions from its properties scale, skew. + * @param Number width width of the bbox + * @param Number height height of the bbox + * @private + * @return {Object} .x finalized width dimension + * @return {Object} .y finalized height dimension + */ + _finalizeDimensions: function(width, height) { + return this.strokeUniform ? + { x: width + this.strokeWidth, y: height + this.strokeWidth } + : + { x: width, y: height }; + }, + + /* + * Calculate object dimensions for controls box, including padding and canvas zoom. + * and active selection + * private + */ + _calculateCurrentDimensions: function() { + var vpt = this.getViewportTransform(), + dim = this._getTransformedDimensions(), + p = transformPoint(dim, vpt, true); + return p.scalarAdd(2 * this.padding); + }, + }); +})(); + + +fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ { + + /** + * Moves an object to the bottom of the stack of drawn objects + * @return {fabric.Object} thisArg + * @chainable + */ + sendToBack: function() { + if (this.group) { + fabric.StaticCanvas.prototype.sendToBack.call(this.group, this); + } + else if (this.canvas) { + this.canvas.sendToBack(this); + } + return this; + }, + + /** + * Moves an object to the top of the stack of drawn objects + * @return {fabric.Object} thisArg + * @chainable + */ + bringToFront: function() { + if (this.group) { + fabric.StaticCanvas.prototype.bringToFront.call(this.group, this); + } + else if (this.canvas) { + this.canvas.bringToFront(this); + } + return this; + }, + + /** + * Moves an object down in stack of drawn objects + * @param {Boolean} [intersecting] If `true`, send object behind next lower intersecting object + * @return {fabric.Object} thisArg + * @chainable + */ + sendBackwards: function(intersecting) { + if (this.group) { + fabric.StaticCanvas.prototype.sendBackwards.call(this.group, this, intersecting); + } + else if (this.canvas) { + this.canvas.sendBackwards(this, intersecting); + } + return this; + }, + + /** + * Moves an object up in stack of drawn objects + * @param {Boolean} [intersecting] If `true`, send object in front of next upper intersecting object + * @return {fabric.Object} thisArg + * @chainable + */ + bringForward: function(intersecting) { + if (this.group) { + fabric.StaticCanvas.prototype.bringForward.call(this.group, this, intersecting); + } + else if (this.canvas) { + this.canvas.bringForward(this, intersecting); + } + return this; + }, + + /** + * Moves an object to specified level in stack of drawn objects + * @param {Number} index New position of object + * @return {fabric.Object} thisArg + * @chainable + */ + moveTo: function(index) { + if (this.group && this.group.type !== 'activeSelection') { + fabric.StaticCanvas.prototype.moveTo.call(this.group, this, index); + } + else if (this.canvas) { + this.canvas.moveTo(this, index); + } + return this; + } +}); + + +/* _TO_SVG_START_ */ +(function() { + function getSvgColorString(prop, value) { + if (!value) { + return prop + ': none; '; + } + else if (value.toLive) { + return prop + ': url(#SVGID_' + value.id + '); '; + } + else { + var color = new fabric.Color(value), + str = prop + ': ' + color.toRgb() + '; ', + opacity = color.getAlpha(); + if (opacity !== 1) { + //change the color in rgb + opacity + str += prop + '-opacity: ' + opacity.toString() + '; '; + } + return str; + } + } + + var toFixed = fabric.util.toFixed; + + fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ { + /** + * Returns styles-string for svg-export + * @param {Boolean} skipShadow a boolean to skip shadow filter output + * @return {String} + */ + getSvgStyles: function(skipShadow) { + + var fillRule = this.fillRule ? this.fillRule : 'nonzero', + strokeWidth = this.strokeWidth ? this.strokeWidth : '0', + strokeDashArray = this.strokeDashArray ? this.strokeDashArray.join(' ') : 'none', + strokeDashOffset = this.strokeDashOffset ? this.strokeDashOffset : '0', + strokeLineCap = this.strokeLineCap ? this.strokeLineCap : 'butt', + strokeLineJoin = this.strokeLineJoin ? this.strokeLineJoin : 'miter', + strokeMiterLimit = this.strokeMiterLimit ? this.strokeMiterLimit : '4', + opacity = typeof this.opacity !== 'undefined' ? this.opacity : '1', + visibility = this.visible ? '' : ' visibility: hidden;', + filter = skipShadow ? '' : this.getSvgFilter(), + fill = getSvgColorString('fill', this.fill), + stroke = getSvgColorString('stroke', this.stroke); + + return [ + stroke, + 'stroke-width: ', strokeWidth, '; ', + 'stroke-dasharray: ', strokeDashArray, '; ', + 'stroke-linecap: ', strokeLineCap, '; ', + 'stroke-dashoffset: ', strokeDashOffset, '; ', + 'stroke-linejoin: ', strokeLineJoin, '; ', + 'stroke-miterlimit: ', strokeMiterLimit, '; ', + fill, + 'fill-rule: ', fillRule, '; ', + 'opacity: ', opacity, ';', + filter, + visibility + ].join(''); + }, + + /** + * Returns styles-string for svg-export + * @param {Object} style the object from which to retrieve style properties + * @param {Boolean} useWhiteSpace a boolean to include an additional attribute in the style. + * @return {String} + */ + getSvgSpanStyles: function(style, useWhiteSpace) { + var term = '; '; + var fontFamily = style.fontFamily ? + 'font-family: ' + (((style.fontFamily.indexOf('\'') === -1 && style.fontFamily.indexOf('"') === -1) ? + '\'' + style.fontFamily + '\'' : style.fontFamily)) + term : ''; + var strokeWidth = style.strokeWidth ? 'stroke-width: ' + style.strokeWidth + term : '', + fontFamily = fontFamily, + fontSize = style.fontSize ? 'font-size: ' + style.fontSize + 'px' + term : '', + fontStyle = style.fontStyle ? 'font-style: ' + style.fontStyle + term : '', + fontWeight = style.fontWeight ? 'font-weight: ' + style.fontWeight + term : '', + fill = style.fill ? getSvgColorString('fill', style.fill) : '', + stroke = style.stroke ? getSvgColorString('stroke', style.stroke) : '', + textDecoration = this.getSvgTextDecoration(style), + deltaY = style.deltaY ? 'baseline-shift: ' + (-style.deltaY) + '; ' : ''; + if (textDecoration) { + textDecoration = 'text-decoration: ' + textDecoration + term; + } + + return [ + stroke, + strokeWidth, + fontFamily, + fontSize, + fontStyle, + fontWeight, + textDecoration, + fill, + deltaY, + useWhiteSpace ? 'white-space: pre; ' : '' + ].join(''); + }, + + /** + * Returns text-decoration property for svg-export + * @param {Object} style the object from which to retrieve style properties + * @return {String} + */ + getSvgTextDecoration: function(style) { + return ['overline', 'underline', 'line-through'].filter(function(decoration) { + return style[decoration.replace('-', '')]; + }).join(' '); + }, + + /** + * Returns filter for svg shadow + * @return {String} + */ + getSvgFilter: function() { + return this.shadow ? 'filter: url(#SVGID_' + this.shadow.id + ');' : ''; + }, + + /** + * Returns id attribute for svg output + * @return {String} + */ + getSvgCommons: function() { + return [ + this.id ? 'id="' + this.id + '" ' : '', + this.clipPath ? 'clip-path="url(#' + this.clipPath.clipPathId + ')" ' : '', + ].join(''); + }, + + /** + * Returns transform-string for svg-export + * @param {Boolean} use the full transform or the single object one. + * @return {String} + */ + getSvgTransform: function(full, additionalTransform) { + var transform = full ? this.calcTransformMatrix() : this.calcOwnMatrix(), + svgTransform = 'transform="' + fabric.util.matrixToSVG(transform); + return svgTransform + + (additionalTransform || '') + '" '; + }, + + _setSVGBg: function(textBgRects) { + if (this.backgroundColor) { + var NUM_FRACTION_DIGITS = fabric.Object.NUM_FRACTION_DIGITS; + textBgRects.push( + '\t\t\n'); + } + }, + + /** + * Returns svg representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toSVG: function(reviver) { + return this._createBaseSVGMarkup(this._toSVG(reviver), { reviver: reviver }); + }, + + /** + * Returns svg clipPath representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toClipPathSVG: function(reviver) { + return '\t' + this._createBaseClipPathSVGMarkup(this._toSVG(reviver), { reviver: reviver }); + }, + + /** + * @private + */ + _createBaseClipPathSVGMarkup: function(objectMarkup, options) { + options = options || {}; + var reviver = options.reviver, + additionalTransform = options.additionalTransform || '', + commonPieces = [ + this.getSvgTransform(true, additionalTransform), + this.getSvgCommons(), + ].join(''), + // insert commons in the markup, style and svgCommons + index = objectMarkup.indexOf('COMMON_PARTS'); + objectMarkup[index] = commonPieces; + return reviver ? reviver(objectMarkup.join('')) : objectMarkup.join(''); + }, + + /** + * @private + */ + _createBaseSVGMarkup: function(objectMarkup, options) { + options = options || {}; + var noStyle = options.noStyle, + reviver = options.reviver, + styleInfo = noStyle ? '' : 'style="' + this.getSvgStyles() + '" ', + shadowInfo = options.withShadow ? 'style="' + this.getSvgFilter() + '" ' : '', + clipPath = this.clipPath, + vectorEffect = this.strokeUniform ? 'vector-effect="non-scaling-stroke" ' : '', + absoluteClipPath = clipPath && clipPath.absolutePositioned, + stroke = this.stroke, fill = this.fill, shadow = this.shadow, + commonPieces, markup = [], clipPathMarkup, + // insert commons in the markup, style and svgCommons + index = objectMarkup.indexOf('COMMON_PARTS'), + additionalTransform = options.additionalTransform; + if (clipPath) { + clipPath.clipPathId = 'CLIPPATH_' + fabric.Object.__uid++; + clipPathMarkup = '\n' + + clipPath.toClipPathSVG(reviver) + + '\n'; + } + if (absoluteClipPath) { + markup.push( + '\n' + ); + } + markup.push( + '\n' + ); + commonPieces = [ + styleInfo, + vectorEffect, + noStyle ? '' : this.addPaintOrder(), ' ', + additionalTransform ? 'transform="' + additionalTransform + '" ' : '', + ].join(''); + objectMarkup[index] = commonPieces; + if (fill && fill.toLive) { + markup.push(fill.toSVG(this)); + } + if (stroke && stroke.toLive) { + markup.push(stroke.toSVG(this)); + } + if (shadow) { + markup.push(shadow.toSVG(this)); + } + if (clipPath) { + markup.push(clipPathMarkup); + } + markup.push(objectMarkup.join('')); + markup.push('\n'); + absoluteClipPath && markup.push('\n'); + return reviver ? reviver(markup.join('')) : markup.join(''); + }, + + addPaintOrder: function() { + return this.paintFirst !== 'fill' ? ' paint-order="' + this.paintFirst + '" ' : ''; + } + }); +})(); +/* _TO_SVG_END_ */ + + +(function() { + + var extend = fabric.util.object.extend, + originalSet = 'stateProperties'; + + /* + Depends on `stateProperties` + */ + function saveProps(origin, destination, props) { + var tmpObj = { }, deep = true; + props.forEach(function(prop) { + tmpObj[prop] = origin[prop]; + }); + + extend(origin[destination], tmpObj, deep); + } + + function _isEqual(origValue, currentValue, firstPass) { + if (origValue === currentValue) { + // if the objects are identical, return + return true; + } + else if (Array.isArray(origValue)) { + if (!Array.isArray(currentValue) || origValue.length !== currentValue.length) { + return false; + } + for (var i = 0, len = origValue.length; i < len; i++) { + if (!_isEqual(origValue[i], currentValue[i])) { + return false; + } + } + return true; + } + else if (origValue && typeof origValue === 'object') { + var keys = Object.keys(origValue), key; + if (!currentValue || + typeof currentValue !== 'object' || + (!firstPass && keys.length !== Object.keys(currentValue).length) + ) { + return false; + } + for (var i = 0, len = keys.length; i < len; i++) { + key = keys[i]; + // since clipPath is in the statefull cache list and the clipPath objects + // would be iterated as an object, this would lead to possible infinite recursion + // we do not want to compare those. + if (key === 'canvas' || key === 'group') { + continue; + } + if (!_isEqual(origValue[key], currentValue[key])) { + return false; + } + } + return true; + } + } + + + fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ { + + /** + * Returns true if object state (one of its state properties) was changed + * @param {String} [propertySet] optional name for the set of property we want to save + * @return {Boolean} true if instance' state has changed since `{@link fabric.Object#saveState}` was called + */ + hasStateChanged: function(propertySet) { + propertySet = propertySet || originalSet; + var dashedPropertySet = '_' + propertySet; + if (Object.keys(this[dashedPropertySet]).length < this[propertySet].length) { + return true; + } + return !_isEqual(this[dashedPropertySet], this, true); + }, + + /** + * Saves state of an object + * @param {Object} [options] Object with additional `stateProperties` array to include when saving state + * @return {fabric.Object} thisArg + */ + saveState: function(options) { + var propertySet = options && options.propertySet || originalSet, + destination = '_' + propertySet; + if (!this[destination]) { + return this.setupState(options); + } + saveProps(this, destination, this[propertySet]); + if (options && options.stateProperties) { + saveProps(this, destination, options.stateProperties); + } + return this; + }, + + /** + * Setups state of an object + * @param {Object} [options] Object with additional `stateProperties` array to include when saving state + * @return {fabric.Object} thisArg + */ + setupState: function(options) { + options = options || { }; + var propertySet = options.propertySet || originalSet; + options.propertySet = propertySet; + this['_' + propertySet] = { }; + this.saveState(options); + return this; + } + }); +})(); + + +(function() { + + var degreesToRadians = fabric.util.degreesToRadians; + + fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ { + /** + * Determines which corner has been clicked + * @private + * @param {Object} pointer The pointer indicating the mouse position + * @return {String|Boolean} corner code (tl, tr, bl, br, etc.), or false if nothing is found + */ + _findTargetCorner: function(pointer, forTouch) { + // objects in group, anykind, are not self modificable, + // must not return an hovered corner. + if (!this.hasControls || this.group || (!this.canvas || this.canvas._activeObject !== this)) { + return false; + } + + var ex = pointer.x, + ey = pointer.y, + xPoints, + lines, keys = Object.keys(this.oCoords), + j = keys.length - 1, i; + this.__corner = 0; + + // cycle in reverse order so we pick first the one on top + for (; j >= 0; j--) { + i = keys[j]; + if (!this.isControlVisible(i)) { + continue; + } + + lines = this._getImageLines(forTouch ? this.oCoords[i].touchCorner : this.oCoords[i].corner); + // // debugging + // + // this.canvas.contextTop.fillRect(lines.bottomline.d.x, lines.bottomline.d.y, 2, 2); + // this.canvas.contextTop.fillRect(lines.bottomline.o.x, lines.bottomline.o.y, 2, 2); + // + // this.canvas.contextTop.fillRect(lines.leftline.d.x, lines.leftline.d.y, 2, 2); + // this.canvas.contextTop.fillRect(lines.leftline.o.x, lines.leftline.o.y, 2, 2); + // + // this.canvas.contextTop.fillRect(lines.topline.d.x, lines.topline.d.y, 2, 2); + // this.canvas.contextTop.fillRect(lines.topline.o.x, lines.topline.o.y, 2, 2); + // + // this.canvas.contextTop.fillRect(lines.rightline.d.x, lines.rightline.d.y, 2, 2); + // this.canvas.contextTop.fillRect(lines.rightline.o.x, lines.rightline.o.y, 2, 2); + + xPoints = this._findCrossPoints({ x: ex, y: ey }, lines); + if (xPoints !== 0 && xPoints % 2 === 1) { + this.__corner = i; + return i; + } + } + return false; + }, + + /** + * Calls a function for each control. The function gets called, + * with the control, the object that is calling the iterator and the control's key + * @param {Function} fn function to iterate over the controls over + */ + forEachControl: function(fn) { + for (var i in this.controls) { + fn(this.controls[i], i, this); + }; + }, + + /** + * Sets the coordinates of the draggable boxes in the corners of + * the image used to scale/rotate it. + * note: if we would switch to ROUND corner area, all of this would disappear. + * everything would resolve to a single point and a pythagorean theorem for the distance + * @private + */ + _setCornerCoords: function() { + var coords = this.oCoords; + + for (var control in coords) { + var controlObject = this.controls[control]; + coords[control].corner = controlObject.calcCornerCoords( + this.angle, this.cornerSize, coords[control].x, coords[control].y, false); + coords[control].touchCorner = controlObject.calcCornerCoords( + this.angle, this.touchCornerSize, coords[control].x, coords[control].y, true); + } + }, + + /** + * Draws a colored layer behind the object, inside its selection borders. + * Requires public options: padding, selectionBackgroundColor + * this function is called when the context is transformed + * has checks to be skipped when the object is on a staticCanvas + * @param {CanvasRenderingContext2D} ctx Context to draw on + * @return {fabric.Object} thisArg + * @chainable + */ + drawSelectionBackground: function(ctx) { + if (!this.selectionBackgroundColor || + (this.canvas && !this.canvas.interactive) || + (this.canvas && this.canvas._activeObject !== this) + ) { + return this; + } + ctx.save(); + var center = this.getCenterPoint(), wh = this._calculateCurrentDimensions(), + vpt = this.canvas.viewportTransform; + ctx.translate(center.x, center.y); + ctx.scale(1 / vpt[0], 1 / vpt[3]); + ctx.rotate(degreesToRadians(this.angle)); + ctx.fillStyle = this.selectionBackgroundColor; + ctx.fillRect(-wh.x / 2, -wh.y / 2, wh.x, wh.y); + ctx.restore(); + return this; + }, + + /** + * Draws borders of an object's bounding box. + * Requires public properties: width, height + * Requires public options: padding, borderColor + * @param {CanvasRenderingContext2D} ctx Context to draw on + * @param {Object} styleOverride object to override the object style + * @return {fabric.Object} thisArg + * @chainable + */ + drawBorders: function(ctx, styleOverride) { + styleOverride = styleOverride || {}; + var wh = this._calculateCurrentDimensions(), + strokeWidth = this.borderScaleFactor, + width = wh.x + strokeWidth, + height = wh.y + strokeWidth, + hasControls = typeof styleOverride.hasControls !== 'undefined' ? + styleOverride.hasControls : this.hasControls, + shouldStroke = false; + + ctx.save(); + ctx.strokeStyle = styleOverride.borderColor || this.borderColor; + this._setLineDash(ctx, styleOverride.borderDashArray || this.borderDashArray); + + ctx.strokeRect( + -width / 2, + -height / 2, + width, + height + ); + + if (hasControls) { + ctx.beginPath(); + this.forEachControl(function(control, key, fabricObject) { + // in this moment, the ctx is centered on the object. + // width and height of the above function are the size of the bbox. + if (control.withConnection && control.getVisibility(fabricObject, key)) { + // reset movement for each control + shouldStroke = true; + ctx.moveTo(control.x * width, control.y * height); + ctx.lineTo( + control.x * width + control.offsetX, + control.y * height + control.offsetY + ); + } + }); + if (shouldStroke) { + ctx.stroke(); + } + } + ctx.restore(); + return this; + }, + + /** + * Draws borders of an object's bounding box when it is inside a group. + * Requires public properties: width, height + * Requires public options: padding, borderColor + * @param {CanvasRenderingContext2D} ctx Context to draw on + * @param {object} options object representing current object parameters + * @param {Object} styleOverride object to override the object style + * @return {fabric.Object} thisArg + * @chainable + */ + drawBordersInGroup: function(ctx, options, styleOverride) { + styleOverride = styleOverride || {}; + var bbox = fabric.util.sizeAfterTransform(this.width, this.height, options), + strokeWidth = this.strokeWidth, + strokeUniform = this.strokeUniform, + borderScaleFactor = this.borderScaleFactor, + width = + bbox.x + strokeWidth * (strokeUniform ? this.canvas.getZoom() : options.scaleX) + borderScaleFactor, + height = + bbox.y + strokeWidth * (strokeUniform ? this.canvas.getZoom() : options.scaleY) + borderScaleFactor; + ctx.save(); + this._setLineDash(ctx, styleOverride.borderDashArray || this.borderDashArray); + ctx.strokeStyle = styleOverride.borderColor || this.borderColor; + ctx.strokeRect( + -width / 2, + -height / 2, + width, + height + ); + + ctx.restore(); + return this; + }, + + /** + * Draws corners of an object's bounding box. + * Requires public properties: width, height + * Requires public options: cornerSize, padding + * @param {CanvasRenderingContext2D} ctx Context to draw on + * @param {Object} styleOverride object to override the object style + * @return {fabric.Object} thisArg + * @chainable + */ + drawControls: function(ctx, styleOverride) { + styleOverride = styleOverride || {}; + ctx.save(); + var retinaScaling = this.canvas.getRetinaScaling(), matrix, p; + ctx.setTransform(retinaScaling, 0, 0, retinaScaling, 0, 0); + ctx.strokeStyle = ctx.fillStyle = styleOverride.cornerColor || this.cornerColor; + if (!this.transparentCorners) { + ctx.strokeStyle = styleOverride.cornerStrokeColor || this.cornerStrokeColor; + } + this._setLineDash(ctx, styleOverride.cornerDashArray || this.cornerDashArray); + this.setCoords(); + if (this.group) { + // fabricJS does not really support drawing controls inside groups, + // this piece of code here helps having at least the control in places. + // If an application needs to show some objects as selected because of some UI state + // can still call Object._renderControls() on any object they desire, independently of groups. + // using no padding, circular controls and hiding the rotating cursor is higly suggested, + matrix = this.group.calcTransformMatrix(); + } + this.forEachControl(function(control, key, fabricObject) { + p = fabricObject.oCoords[key]; + if (control.getVisibility(fabricObject, key)) { + if (matrix) { + p = fabric.util.transformPoint(p, matrix); + } + control.render(ctx, p.x, p.y, styleOverride, fabricObject); + } + }); + ctx.restore(); + + return this; + }, + + /** + * Returns true if the specified control is visible, false otherwise. + * @param {String} controlKey The key of the control. Possible values are 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr'. + * @returns {Boolean} true if the specified control is visible, false otherwise + */ + isControlVisible: function(controlKey) { + return this.controls[controlKey] && this.controls[controlKey].getVisibility(this, controlKey); + }, + + /** + * Sets the visibility of the specified control. + * @param {String} controlKey The key of the control. Possible values are 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr'. + * @param {Boolean} visible true to set the specified control visible, false otherwise + * @return {fabric.Object} thisArg + * @chainable + */ + setControlVisible: function(controlKey, visible) { + if (!this._controlsVisibility) { + this._controlsVisibility = {}; + } + this._controlsVisibility[controlKey] = visible; + return this; + }, + + /** + * Sets the visibility state of object controls. + * @param {Object} [options] Options object + * @param {Boolean} [options.bl] true to enable the bottom-left control, false to disable it + * @param {Boolean} [options.br] true to enable the bottom-right control, false to disable it + * @param {Boolean} [options.mb] true to enable the middle-bottom control, false to disable it + * @param {Boolean} [options.ml] true to enable the middle-left control, false to disable it + * @param {Boolean} [options.mr] true to enable the middle-right control, false to disable it + * @param {Boolean} [options.mt] true to enable the middle-top control, false to disable it + * @param {Boolean} [options.tl] true to enable the top-left control, false to disable it + * @param {Boolean} [options.tr] true to enable the top-right control, false to disable it + * @param {Boolean} [options.mtr] true to enable the middle-top-rotate control, false to disable it + * @return {fabric.Object} thisArg + * @chainable + */ + setControlsVisibility: function(options) { + options || (options = { }); + + for (var p in options) { + this.setControlVisible(p, options[p]); + } + return this; + }, + + + /** + * This callback function is called every time _discardActiveObject or _setActiveObject + * try to to deselect this object. If the function returns true, the process is cancelled + * @param {Object} [options] options sent from the upper functions + * @param {Event} [options.e] event if the process is generated by an event + */ + onDeselect: function() { + // implemented by sub-classes, as needed. + }, + + + /** + * This callback function is called every time _discardActiveObject or _setActiveObject + * try to to select this object. If the function returns true, the process is cancelled + * @param {Object} [options] options sent from the upper functions + * @param {Event} [options.e] event if the process is generated by an event + */ + onSelect: function() { + // implemented by sub-classes, as needed. + } + }); +})(); + + +fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.StaticCanvas.prototype */ { + + /** + * Animation duration (in ms) for fx* methods + * @type Number + * @default + */ + FX_DURATION: 500, + + /** + * Centers object horizontally with animation. + * @param {fabric.Object} object Object to center + * @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties + * @param {Function} [callbacks.onComplete] Invoked on completion + * @param {Function} [callbacks.onChange] Invoked on every step of animation + * @return {fabric.AnimationContext} context + */ + fxCenterObjectH: function (object, callbacks) { + callbacks = callbacks || { }; + + var empty = function() { }, + onComplete = callbacks.onComplete || empty, + onChange = callbacks.onChange || empty, + _this = this; + + return fabric.util.animate({ + target: this, + startValue: object.left, + endValue: this.getCenterPoint().x, + duration: this.FX_DURATION, + onChange: function(value) { + object.set('left', value); + _this.requestRenderAll(); + onChange(); + }, + onComplete: function() { + object.setCoords(); + onComplete(); + } + }); + }, + + /** + * Centers object vertically with animation. + * @param {fabric.Object} object Object to center + * @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties + * @param {Function} [callbacks.onComplete] Invoked on completion + * @param {Function} [callbacks.onChange] Invoked on every step of animation + * @return {fabric.AnimationContext} context + */ + fxCenterObjectV: function (object, callbacks) { + callbacks = callbacks || { }; + + var empty = function() { }, + onComplete = callbacks.onComplete || empty, + onChange = callbacks.onChange || empty, + _this = this; + + return fabric.util.animate({ + target: this, + startValue: object.top, + endValue: this.getCenterPoint().y, + duration: this.FX_DURATION, + onChange: function(value) { + object.set('top', value); + _this.requestRenderAll(); + onChange(); + }, + onComplete: function() { + object.setCoords(); + onComplete(); + } + }); + }, + + /** + * Same as `fabric.Canvas#remove` but animated + * @param {fabric.Object} object Object to remove + * @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties + * @param {Function} [callbacks.onComplete] Invoked on completion + * @param {Function} [callbacks.onChange] Invoked on every step of animation + * @return {fabric.AnimationContext} context + */ + fxRemove: function (object, callbacks) { + callbacks = callbacks || { }; + + var empty = function() { }, + onComplete = callbacks.onComplete || empty, + onChange = callbacks.onChange || empty, + _this = this; + + return fabric.util.animate({ + target: this, + startValue: object.opacity, + endValue: 0, + duration: this.FX_DURATION, + onChange: function(value) { + object.set('opacity', value); + _this.requestRenderAll(); + onChange(); + }, + onComplete: function () { + _this.remove(object); + onComplete(); + } + }); + } +}); + +fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ { + /** + * Animates object's properties + * @param {String|Object} property Property to animate (if string) or properties to animate (if object) + * @param {Number|Object} value Value to animate property to (if string was given first) or options object + * @return {fabric.Object} thisArg + * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#animation} + * @return {fabric.AnimationContext | fabric.AnimationContext[]} animation context (or an array if passed multiple properties) + * + * As object — multiple properties + * + * object.animate({ left: ..., top: ... }); + * object.animate({ left: ..., top: ... }, { duration: ... }); + * + * As string — one property + * + * object.animate('left', ...); + * object.animate('left', { duration: ... }); + * + */ + animate: function () { + if (arguments[0] && typeof arguments[0] === 'object') { + var propsToAnimate = [], prop, skipCallbacks, out = []; + for (prop in arguments[0]) { + propsToAnimate.push(prop); + } + for (var i = 0, len = propsToAnimate.length; i < len; i++) { + prop = propsToAnimate[i]; + skipCallbacks = i !== len - 1; + out.push(this._animate(prop, arguments[0][prop], arguments[1], skipCallbacks)); + } + return out; + } + else { + return this._animate.apply(this, arguments); + } + }, + + /** + * @private + * @param {String} property Property to animate + * @param {String} to Value to animate to + * @param {Object} [options] Options object + * @param {Boolean} [skipCallbacks] When true, callbacks like onchange and oncomplete are not invoked + */ + _animate: function(property, to, options, skipCallbacks) { + var _this = this, propPair; + + to = to.toString(); + + if (!options) { + options = { }; + } + else { + options = fabric.util.object.clone(options); + } + + if (~property.indexOf('.')) { + propPair = property.split('.'); + } + + var propIsColor = + _this.colorProperties.indexOf(property) > -1 || + (propPair && _this.colorProperties.indexOf(propPair[1]) > -1); + + var currentValue = propPair + ? this.get(propPair[0])[propPair[1]] + : this.get(property); + + if (!('from' in options)) { + options.from = currentValue; + } + + if (!propIsColor) { + if (~to.indexOf('=')) { + to = currentValue + parseFloat(to.replace('=', '')); + } + else { + to = parseFloat(to); + } + } + + var _options = { + target: this, + startValue: options.from, + endValue: to, + byValue: options.by, + easing: options.easing, + duration: options.duration, + abort: options.abort && function(value, valueProgress, timeProgress) { + return options.abort.call(_this, value, valueProgress, timeProgress); + }, + onChange: function (value, valueProgress, timeProgress) { + if (propPair) { + _this[propPair[0]][propPair[1]] = value; + } + else { + _this.set(property, value); + } + if (skipCallbacks) { + return; + } + options.onChange && options.onChange(value, valueProgress, timeProgress); + }, + onComplete: function (value, valueProgress, timeProgress) { + if (skipCallbacks) { + return; + } + + _this.setCoords(); + options.onComplete && options.onComplete(value, valueProgress, timeProgress); + } + }; + + if (propIsColor) { + return fabric.util.animateColor(_options.startValue, _options.endValue, _options.duration, _options); + } + else { + return fabric.util.animate(_options); + } + } +}); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + extend = fabric.util.object.extend, + clone = fabric.util.object.clone, + coordProps = { x1: 1, x2: 1, y1: 1, y2: 1 }; + + if (fabric.Line) { + fabric.warn('fabric.Line is already defined'); + return; + } + + /** + * Line class + * @class fabric.Line + * @extends fabric.Object + * @see {@link fabric.Line#initialize} for constructor definition + */ + fabric.Line = fabric.util.createClass(fabric.Object, /** @lends fabric.Line.prototype */ { + + /** + * Type of an object + * @type String + * @default + */ + type: 'line', + + /** + * x value or first line edge + * @type Number + * @default + */ + x1: 0, + + /** + * y value or first line edge + * @type Number + * @default + */ + y1: 0, + + /** + * x value or second line edge + * @type Number + * @default + */ + x2: 0, + + /** + * y value or second line edge + * @type Number + * @default + */ + y2: 0, + + cacheProperties: fabric.Object.prototype.cacheProperties.concat('x1', 'x2', 'y1', 'y2'), + + /** + * Constructor + * @param {Array} [points] Array of points + * @param {Object} [options] Options object + * @return {fabric.Line} thisArg + */ + initialize: function(points, options) { + if (!points) { + points = [0, 0, 0, 0]; + } + + this.callSuper('initialize', options); + + this.set('x1', points[0]); + this.set('y1', points[1]); + this.set('x2', points[2]); + this.set('y2', points[3]); + + this._setWidthHeight(options); + }, + + /** + * @private + * @param {Object} [options] Options + */ + _setWidthHeight: function(options) { + options || (options = { }); + + this.width = Math.abs(this.x2 - this.x1); + this.height = Math.abs(this.y2 - this.y1); + + this.left = 'left' in options + ? options.left + : this._getLeftToOriginX(); + + this.top = 'top' in options + ? options.top + : this._getTopToOriginY(); + }, + + /** + * @private + * @param {String} key + * @param {*} value + */ + _set: function(key, value) { + this.callSuper('_set', key, value); + if (typeof coordProps[key] !== 'undefined') { + this._setWidthHeight(); + } + return this; + }, + + /** + * @private + * @return {Number} leftToOriginX Distance from left edge of canvas to originX of Line. + */ + _getLeftToOriginX: makeEdgeToOriginGetter( + { // property names + origin: 'originX', + axis1: 'x1', + axis2: 'x2', + dimension: 'width' + }, + { // possible values of origin + nearest: 'left', + center: 'center', + farthest: 'right' + } + ), + + /** + * @private + * @return {Number} topToOriginY Distance from top edge of canvas to originY of Line. + */ + _getTopToOriginY: makeEdgeToOriginGetter( + { // property names + origin: 'originY', + axis1: 'y1', + axis2: 'y2', + dimension: 'height' + }, + { // possible values of origin + nearest: 'top', + center: 'center', + farthest: 'bottom' + } + ), + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _render: function(ctx) { + ctx.beginPath(); + + + var p = this.calcLinePoints(); + ctx.moveTo(p.x1, p.y1); + ctx.lineTo(p.x2, p.y2); + + ctx.lineWidth = this.strokeWidth; + + // TODO: test this + // make sure setting "fill" changes color of a line + // (by copying fillStyle to strokeStyle, since line is stroked, not filled) + var origStrokeStyle = ctx.strokeStyle; + ctx.strokeStyle = this.stroke || ctx.fillStyle; + this.stroke && this._renderStroke(ctx); + ctx.strokeStyle = origStrokeStyle; + }, + + /** + * This function is an helper for svg import. it returns the center of the object in the svg + * untransformed coordinates + * @private + * @return {Object} center point from element coordinates + */ + _findCenterFromElement: function() { + return { + x: (this.x1 + this.x2) / 2, + y: (this.y1 + this.y2) / 2, + }; + }, + + /** + * Returns object representation of an instance + * @method toObject + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toObject: function(propertiesToInclude) { + return extend(this.callSuper('toObject', propertiesToInclude), this.calcLinePoints()); + }, + + /* + * Calculate object dimensions from its properties + * @private + */ + _getNonTransformedDimensions: function() { + var dim = this.callSuper('_getNonTransformedDimensions'); + if (this.strokeLineCap === 'butt') { + if (this.width === 0) { + dim.y -= this.strokeWidth; + } + if (this.height === 0) { + dim.x -= this.strokeWidth; + } + } + return dim; + }, + + /** + * Recalculates line points given width and height + * @private + */ + calcLinePoints: function() { + var xMult = this.x1 <= this.x2 ? -1 : 1, + yMult = this.y1 <= this.y2 ? -1 : 1, + x1 = (xMult * this.width * 0.5), + y1 = (yMult * this.height * 0.5), + x2 = (xMult * this.width * -0.5), + y2 = (yMult * this.height * -0.5); + + return { + x1: x1, + x2: x2, + y1: y1, + y2: y2 + }; + }, + + /* _TO_SVG_START_ */ + /** + * Returns svg representation of an instance + * @return {Array} an array of strings with the specific svg representation + * of the instance + */ + _toSVG: function() { + var p = this.calcLinePoints(); + return [ + '\n' + ]; + }, + /* _TO_SVG_END_ */ + }); + + /* _FROM_SVG_START_ */ + /** + * List of attribute names to account for when parsing SVG element (used by {@link fabric.Line.fromElement}) + * @static + * @memberOf fabric.Line + * @see http://www.w3.org/TR/SVG/shapes.html#LineElement + */ + fabric.Line.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat('x1 y1 x2 y2'.split(' ')); + + /** + * Returns fabric.Line instance from an SVG element + * @static + * @memberOf fabric.Line + * @param {SVGElement} element Element to parse + * @param {Object} [options] Options object + * @param {Function} [callback] callback function invoked after parsing + */ + fabric.Line.fromElement = function(element, callback, options) { + options = options || { }; + var parsedAttributes = fabric.parseAttributes(element, fabric.Line.ATTRIBUTE_NAMES), + points = [ + parsedAttributes.x1 || 0, + parsedAttributes.y1 || 0, + parsedAttributes.x2 || 0, + parsedAttributes.y2 || 0 + ]; + callback(new fabric.Line(points, extend(parsedAttributes, options))); + }; + /* _FROM_SVG_END_ */ + + /** + * Returns fabric.Line instance from an object representation + * @static + * @memberOf fabric.Line + * @param {Object} object Object to create an instance from + * @param {function} [callback] invoked with new instance as first argument + */ + fabric.Line.fromObject = function(object, callback) { + function _callback(instance) { + delete instance.points; + callback && callback(instance); + }; + var options = clone(object, true); + options.points = [object.x1, object.y1, object.x2, object.y2]; + fabric.Object._fromObject('Line', options, _callback, 'points'); + }; + + /** + * Produces a function that calculates distance from canvas edge to Line origin. + */ + function makeEdgeToOriginGetter(propertyNames, originValues) { + var origin = propertyNames.origin, + axis1 = propertyNames.axis1, + axis2 = propertyNames.axis2, + dimension = propertyNames.dimension, + nearest = originValues.nearest, + center = originValues.center, + farthest = originValues.farthest; + + return function() { + switch (this.get(origin)) { + case nearest: + return Math.min(this.get(axis1), this.get(axis2)); + case center: + return Math.min(this.get(axis1), this.get(axis2)) + (0.5 * this.get(dimension)); + case farthest: + return Math.max(this.get(axis1), this.get(axis2)); + } + }; + + } + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + degreesToRadians = fabric.util.degreesToRadians; + + if (fabric.Circle) { + fabric.warn('fabric.Circle is already defined.'); + return; + } + + /** + * Circle class + * @class fabric.Circle + * @extends fabric.Object + * @see {@link fabric.Circle#initialize} for constructor definition + */ + fabric.Circle = fabric.util.createClass(fabric.Object, /** @lends fabric.Circle.prototype */ { + + /** + * Type of an object + * @type String + * @default + */ + type: 'circle', + + /** + * Radius of this circle + * @type Number + * @default + */ + radius: 0, + + /** + * degrees of start of the circle. + * probably will change to degrees in next major version + * @type Number 0 - 359 + * @default 0 + */ + startAngle: 0, + + /** + * End angle of the circle + * probably will change to degrees in next major version + * @type Number 1 - 360 + * @default 360 + */ + endAngle: 360, + + cacheProperties: fabric.Object.prototype.cacheProperties.concat('radius', 'startAngle', 'endAngle'), + + /** + * @private + * @param {String} key + * @param {*} value + * @return {fabric.Circle} thisArg + */ + _set: function(key, value) { + this.callSuper('_set', key, value); + + if (key === 'radius') { + this.setRadius(value); + } + + return this; + }, + + /** + * Returns object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toObject: function(propertiesToInclude) { + return this.callSuper('toObject', ['radius', 'startAngle', 'endAngle'].concat(propertiesToInclude)); + }, + + /* _TO_SVG_START_ */ + + /** + * Returns svg representation of an instance + * @return {Array} an array of strings with the specific svg representation + * of the instance + */ + _toSVG: function() { + var svgString, x = 0, y = 0, + angle = (this.endAngle - this.startAngle) % 360; + + if (angle === 0) { + svgString = [ + '\n' + ]; + } + else { + var start = degreesToRadians(this.startAngle), + end = degreesToRadians(this.endAngle), + radius = this.radius, + startX = fabric.util.cos(start) * radius, + startY = fabric.util.sin(start) * radius, + endX = fabric.util.cos(end) * radius, + endY = fabric.util.sin(end) * radius, + largeFlag = angle > 180 ? '1' : '0'; + svgString = [ + '\n' + ]; + } + return svgString; + }, + /* _TO_SVG_END_ */ + + /** + * @private + * @param {CanvasRenderingContext2D} ctx context to render on + */ + _render: function(ctx) { + ctx.beginPath(); + ctx.arc( + 0, + 0, + this.radius, + degreesToRadians(this.startAngle), + degreesToRadians(this.endAngle), + false + ); + this._renderPaintInOrder(ctx); + }, + + /** + * Returns horizontal radius of an object (according to how an object is scaled) + * @return {Number} + */ + getRadiusX: function() { + return this.get('radius') * this.get('scaleX'); + }, + + /** + * Returns vertical radius of an object (according to how an object is scaled) + * @return {Number} + */ + getRadiusY: function() { + return this.get('radius') * this.get('scaleY'); + }, + + /** + * Sets radius of an object (and updates width accordingly) + * @return {fabric.Circle} thisArg + */ + setRadius: function(value) { + this.radius = value; + return this.set('width', value * 2).set('height', value * 2); + }, + }); + + /* _FROM_SVG_START_ */ + /** + * List of attribute names to account for when parsing SVG element (used by {@link fabric.Circle.fromElement}) + * @static + * @memberOf fabric.Circle + * @see: http://www.w3.org/TR/SVG/shapes.html#CircleElement + */ + fabric.Circle.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat('cx cy r'.split(' ')); + + /** + * Returns {@link fabric.Circle} instance from an SVG element + * @static + * @memberOf fabric.Circle + * @param {SVGElement} element Element to parse + * @param {Function} [callback] Options callback invoked after parsing is finished + * @param {Object} [options] Options object + * @throws {Error} If value of `r` attribute is missing or invalid + */ + fabric.Circle.fromElement = function(element, callback) { + var parsedAttributes = fabric.parseAttributes(element, fabric.Circle.ATTRIBUTE_NAMES); + + if (!isValidRadius(parsedAttributes)) { + throw new Error('value of `r` attribute is required and can not be negative'); + } + + parsedAttributes.left = (parsedAttributes.left || 0) - parsedAttributes.radius; + parsedAttributes.top = (parsedAttributes.top || 0) - parsedAttributes.radius; + callback(new fabric.Circle(parsedAttributes)); + }; + + /** + * @private + */ + function isValidRadius(attributes) { + return (('radius' in attributes) && (attributes.radius >= 0)); + } + /* _FROM_SVG_END_ */ + + /** + * Returns {@link fabric.Circle} instance from an object representation + * @static + * @memberOf fabric.Circle + * @param {Object} object Object to create an instance from + * @param {function} [callback] invoked with new instance as first argument + * @return {void} + */ + fabric.Circle.fromObject = function(object, callback) { + fabric.Object._fromObject('Circle', object, callback); + }; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }); + + if (fabric.Triangle) { + fabric.warn('fabric.Triangle is already defined'); + return; + } + + /** + * Triangle class + * @class fabric.Triangle + * @extends fabric.Object + * @return {fabric.Triangle} thisArg + * @see {@link fabric.Triangle#initialize} for constructor definition + */ + fabric.Triangle = fabric.util.createClass(fabric.Object, /** @lends fabric.Triangle.prototype */ { + + /** + * Type of an object + * @type String + * @default + */ + type: 'triangle', + + /** + * Width is set to 100 to compensate the old initialize code that was setting it to 100 + * @type Number + * @default + */ + width: 100, + + /** + * Height is set to 100 to compensate the old initialize code that was setting it to 100 + * @type Number + * @default + */ + height: 100, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _render: function(ctx) { + var widthBy2 = this.width / 2, + heightBy2 = this.height / 2; + + ctx.beginPath(); + ctx.moveTo(-widthBy2, heightBy2); + ctx.lineTo(0, -heightBy2); + ctx.lineTo(widthBy2, heightBy2); + ctx.closePath(); + + this._renderPaintInOrder(ctx); + }, + + /* _TO_SVG_START_ */ + /** + * Returns svg representation of an instance + * @return {Array} an array of strings with the specific svg representation + * of the instance + */ + _toSVG: function() { + var widthBy2 = this.width / 2, + heightBy2 = this.height / 2, + points = [ + -widthBy2 + ' ' + heightBy2, + '0 ' + -heightBy2, + widthBy2 + ' ' + heightBy2 + ].join(','); + return [ + '' + ]; + }, + /* _TO_SVG_END_ */ + }); + + /** + * Returns {@link fabric.Triangle} instance from an object representation + * @static + * @memberOf fabric.Triangle + * @param {Object} object Object to create an instance from + * @param {function} [callback] invoked with new instance as first argument + */ + fabric.Triangle.fromObject = function(object, callback) { + return fabric.Object._fromObject('Triangle', object, callback); + }; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + piBy2 = Math.PI * 2; + + if (fabric.Ellipse) { + fabric.warn('fabric.Ellipse is already defined.'); + return; + } + + /** + * Ellipse class + * @class fabric.Ellipse + * @extends fabric.Object + * @return {fabric.Ellipse} thisArg + * @see {@link fabric.Ellipse#initialize} for constructor definition + */ + fabric.Ellipse = fabric.util.createClass(fabric.Object, /** @lends fabric.Ellipse.prototype */ { + + /** + * Type of an object + * @type String + * @default + */ + type: 'ellipse', + + /** + * Horizontal radius + * @type Number + * @default + */ + rx: 0, + + /** + * Vertical radius + * @type Number + * @default + */ + ry: 0, + + cacheProperties: fabric.Object.prototype.cacheProperties.concat('rx', 'ry'), + + /** + * Constructor + * @param {Object} [options] Options object + * @return {fabric.Ellipse} thisArg + */ + initialize: function(options) { + this.callSuper('initialize', options); + this.set('rx', options && options.rx || 0); + this.set('ry', options && options.ry || 0); + }, + + /** + * @private + * @param {String} key + * @param {*} value + * @return {fabric.Ellipse} thisArg + */ + _set: function(key, value) { + this.callSuper('_set', key, value); + switch (key) { + + case 'rx': + this.rx = value; + this.set('width', value * 2); + break; + + case 'ry': + this.ry = value; + this.set('height', value * 2); + break; + + } + return this; + }, + + /** + * Returns horizontal radius of an object (according to how an object is scaled) + * @return {Number} + */ + getRx: function() { + return this.get('rx') * this.get('scaleX'); + }, + + /** + * Returns Vertical radius of an object (according to how an object is scaled) + * @return {Number} + */ + getRy: function() { + return this.get('ry') * this.get('scaleY'); + }, + + /** + * Returns object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toObject: function(propertiesToInclude) { + return this.callSuper('toObject', ['rx', 'ry'].concat(propertiesToInclude)); + }, + + /* _TO_SVG_START_ */ + /** + * Returns svg representation of an instance + * @return {Array} an array of strings with the specific svg representation + * of the instance + */ + _toSVG: function() { + return [ + '\n' + ]; + }, + /* _TO_SVG_END_ */ + + /** + * @private + * @param {CanvasRenderingContext2D} ctx context to render on + */ + _render: function(ctx) { + ctx.beginPath(); + ctx.save(); + ctx.transform(1, 0, 0, this.ry / this.rx, 0, 0); + ctx.arc( + 0, + 0, + this.rx, + 0, + piBy2, + false); + ctx.restore(); + this._renderPaintInOrder(ctx); + }, + }); + + /* _FROM_SVG_START_ */ + /** + * List of attribute names to account for when parsing SVG element (used by {@link fabric.Ellipse.fromElement}) + * @static + * @memberOf fabric.Ellipse + * @see http://www.w3.org/TR/SVG/shapes.html#EllipseElement + */ + fabric.Ellipse.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat('cx cy rx ry'.split(' ')); + + /** + * Returns {@link fabric.Ellipse} instance from an SVG element + * @static + * @memberOf fabric.Ellipse + * @param {SVGElement} element Element to parse + * @param {Function} [callback] Options callback invoked after parsing is finished + * @return {fabric.Ellipse} + */ + fabric.Ellipse.fromElement = function(element, callback) { + + var parsedAttributes = fabric.parseAttributes(element, fabric.Ellipse.ATTRIBUTE_NAMES); + + parsedAttributes.left = (parsedAttributes.left || 0) - parsedAttributes.rx; + parsedAttributes.top = (parsedAttributes.top || 0) - parsedAttributes.ry; + callback(new fabric.Ellipse(parsedAttributes)); + }; + /* _FROM_SVG_END_ */ + + /** + * Returns {@link fabric.Ellipse} instance from an object representation + * @static + * @memberOf fabric.Ellipse + * @param {Object} object Object to create an instance from + * @param {function} [callback] invoked with new instance as first argument + * @return {void} + */ + fabric.Ellipse.fromObject = function(object, callback) { + fabric.Object._fromObject('Ellipse', object, callback); + }; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + extend = fabric.util.object.extend; + + if (fabric.Rect) { + fabric.warn('fabric.Rect is already defined'); + return; + } + + /** + * Rectangle class + * @class fabric.Rect + * @extends fabric.Object + * @return {fabric.Rect} thisArg + * @see {@link fabric.Rect#initialize} for constructor definition + */ + fabric.Rect = fabric.util.createClass(fabric.Object, /** @lends fabric.Rect.prototype */ { + + /** + * List of properties to consider when checking if state of an object is changed ({@link fabric.Object#hasStateChanged}) + * as well as for history (undo/redo) purposes + * @type Array + */ + stateProperties: fabric.Object.prototype.stateProperties.concat('rx', 'ry'), + + /** + * Type of an object + * @type String + * @default + */ + type: 'rect', + + /** + * Horizontal border radius + * @type Number + * @default + */ + rx: 0, + + /** + * Vertical border radius + * @type Number + * @default + */ + ry: 0, + + cacheProperties: fabric.Object.prototype.cacheProperties.concat('rx', 'ry'), + + /** + * Constructor + * @param {Object} [options] Options object + * @return {Object} thisArg + */ + initialize: function(options) { + this.callSuper('initialize', options); + this._initRxRy(); + }, + + /** + * Initializes rx/ry attributes + * @private + */ + _initRxRy: function() { + if (this.rx && !this.ry) { + this.ry = this.rx; + } + else if (this.ry && !this.rx) { + this.rx = this.ry; + } + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _render: function(ctx) { + + // 1x1 case (used in spray brush) optimization was removed because + // with caching and higher zoom level this makes more damage than help + + var rx = this.rx ? Math.min(this.rx, this.width / 2) : 0, + ry = this.ry ? Math.min(this.ry, this.height / 2) : 0, + w = this.width, + h = this.height, + x = -this.width / 2, + y = -this.height / 2, + isRounded = rx !== 0 || ry !== 0, + /* "magic number" for bezier approximations of arcs (http://itc.ktu.lt/itc354/Riskus354.pdf) */ + k = 1 - 0.5522847498; + ctx.beginPath(); + + ctx.moveTo(x + rx, y); + + ctx.lineTo(x + w - rx, y); + isRounded && ctx.bezierCurveTo(x + w - k * rx, y, x + w, y + k * ry, x + w, y + ry); + + ctx.lineTo(x + w, y + h - ry); + isRounded && ctx.bezierCurveTo(x + w, y + h - k * ry, x + w - k * rx, y + h, x + w - rx, y + h); + + ctx.lineTo(x + rx, y + h); + isRounded && ctx.bezierCurveTo(x + k * rx, y + h, x, y + h - k * ry, x, y + h - ry); + + ctx.lineTo(x, y + ry); + isRounded && ctx.bezierCurveTo(x, y + k * ry, x + k * rx, y, x + rx, y); + + ctx.closePath(); + + this._renderPaintInOrder(ctx); + }, + + /** + * Returns object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toObject: function(propertiesToInclude) { + return this.callSuper('toObject', ['rx', 'ry'].concat(propertiesToInclude)); + }, + + /* _TO_SVG_START_ */ + /** + * Returns svg representation of an instance + * @return {Array} an array of strings with the specific svg representation + * of the instance + */ + _toSVG: function() { + var x = -this.width / 2, y = -this.height / 2; + return [ + '\n' + ]; + }, + /* _TO_SVG_END_ */ + }); + + /* _FROM_SVG_START_ */ + /** + * List of attribute names to account for when parsing SVG element (used by `fabric.Rect.fromElement`) + * @static + * @memberOf fabric.Rect + * @see: http://www.w3.org/TR/SVG/shapes.html#RectElement + */ + fabric.Rect.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat('x y rx ry width height'.split(' ')); + + /** + * Returns {@link fabric.Rect} instance from an SVG element + * @static + * @memberOf fabric.Rect + * @param {SVGElement} element Element to parse + * @param {Function} callback callback function invoked after parsing + * @param {Object} [options] Options object + */ + fabric.Rect.fromElement = function(element, callback, options) { + if (!element) { + return callback(null); + } + options = options || { }; + + var parsedAttributes = fabric.parseAttributes(element, fabric.Rect.ATTRIBUTE_NAMES); + parsedAttributes.left = parsedAttributes.left || 0; + parsedAttributes.top = parsedAttributes.top || 0; + parsedAttributes.height = parsedAttributes.height || 0; + parsedAttributes.width = parsedAttributes.width || 0; + var rect = new fabric.Rect(extend((options ? fabric.util.object.clone(options) : { }), parsedAttributes)); + rect.visible = rect.visible && rect.width > 0 && rect.height > 0; + callback(rect); + }; + /* _FROM_SVG_END_ */ + + /** + * Returns {@link fabric.Rect} instance from an object representation + * @static + * @memberOf fabric.Rect + * @param {Object} object Object to create an instance from + * @param {Function} [callback] Callback to invoke when an fabric.Rect instance is created + */ + fabric.Rect.fromObject = function(object, callback) { + return fabric.Object._fromObject('Rect', object, callback); + }; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + extend = fabric.util.object.extend, + min = fabric.util.array.min, + max = fabric.util.array.max, + toFixed = fabric.util.toFixed, + projectStrokeOnPoints = fabric.util.projectStrokeOnPoints; + + if (fabric.Polyline) { + fabric.warn('fabric.Polyline is already defined'); + return; + } + + /** + * Polyline class + * @class fabric.Polyline + * @extends fabric.Object + * @see {@link fabric.Polyline#initialize} for constructor definition + */ + fabric.Polyline = fabric.util.createClass(fabric.Object, /** @lends fabric.Polyline.prototype */ { + + /** + * Type of an object + * @type String + * @default + */ + type: 'polyline', + + /** + * Points array + * @type Array + * @default + */ + points: null, + + /** + * WARNING: Feature in progress + * Calculate the exact bounding box taking in account strokeWidth on acute angles + * this will be turned to true by default on fabric 6.0 + * maybe will be left in as an optimization since calculations may be slow + * @deprecated + * @type Boolean + * @default false + */ + exactBoundingBox: false, + + cacheProperties: fabric.Object.prototype.cacheProperties.concat('points'), + + /** + * Constructor + * @param {Array} points Array of points (where each point is an object with x and y) + * @param {Object} [options] Options object + * @return {fabric.Polyline} thisArg + * @example + * var poly = new fabric.Polyline([ + * { x: 10, y: 10 }, + * { x: 50, y: 30 }, + * { x: 40, y: 70 }, + * { x: 60, y: 50 }, + * { x: 100, y: 150 }, + * { x: 40, y: 100 } + * ], { + * stroke: 'red', + * left: 100, + * top: 100 + * }); + */ + initialize: function(points, options) { + options = options || {}; + this.points = points || []; + this.callSuper('initialize', options); + this._setPositionDimensions(options); + }, + + /** + * @private + */ + _projectStrokeOnPoints: function () { + return projectStrokeOnPoints(this.points, this, true); + }, + + _setPositionDimensions: function(options) { + var calcDim = this._calcDimensions(options), correctLeftTop, + correctSize = this.exactBoundingBox ? this.strokeWidth : 0; + this.width = calcDim.width - correctSize; + this.height = calcDim.height - correctSize; + if (!options.fromSVG) { + correctLeftTop = this.translateToGivenOrigin( + { + // this looks bad, but is one way to keep it optional for now. + x: calcDim.left - this.strokeWidth / 2 + correctSize / 2, + y: calcDim.top - this.strokeWidth / 2 + correctSize / 2 + }, + 'left', + 'top', + this.originX, + this.originY + ); + } + if (typeof options.left === 'undefined') { + this.left = options.fromSVG ? calcDim.left : correctLeftTop.x; + } + if (typeof options.top === 'undefined') { + this.top = options.fromSVG ? calcDim.top : correctLeftTop.y; + } + this.pathOffset = { + x: calcDim.left + this.width / 2 + correctSize / 2, + y: calcDim.top + this.height / 2 + correctSize / 2 + }; + }, + + /** + * Calculate the polygon min and max point from points array, + * returning an object with left, top, width, height to measure the + * polygon size + * @return {Object} object.left X coordinate of the polygon leftmost point + * @return {Object} object.top Y coordinate of the polygon topmost point + * @return {Object} object.width distance between X coordinates of the polygon leftmost and rightmost point + * @return {Object} object.height distance between Y coordinates of the polygon topmost and bottommost point + * @private + */ + _calcDimensions: function() { + + var points = this.exactBoundingBox ? this._projectStrokeOnPoints() : this.points, + minX = min(points, 'x') || 0, + minY = min(points, 'y') || 0, + maxX = max(points, 'x') || 0, + maxY = max(points, 'y') || 0, + width = (maxX - minX), + height = (maxY - minY); + + return { + left: minX, + top: minY, + width: width, + height: height, + }; + }, + + /** + * Returns object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} Object representation of an instance + */ + toObject: function(propertiesToInclude) { + return extend(this.callSuper('toObject', propertiesToInclude), { + points: this.points.concat() + }); + }, + + /* _TO_SVG_START_ */ + /** + * Returns svg representation of an instance + * @return {Array} an array of strings with the specific svg representation + * of the instance + */ + _toSVG: function() { + var points = [], diffX = this.pathOffset.x, diffY = this.pathOffset.y, + NUM_FRACTION_DIGITS = fabric.Object.NUM_FRACTION_DIGITS; + + for (var i = 0, len = this.points.length; i < len; i++) { + points.push( + toFixed(this.points[i].x - diffX, NUM_FRACTION_DIGITS), ',', + toFixed(this.points[i].y - diffY, NUM_FRACTION_DIGITS), ' ' + ); + } + return [ + '<' + this.type + ' ', 'COMMON_PARTS', + 'points="', points.join(''), + '" />\n' + ]; + }, + /* _TO_SVG_END_ */ + + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + commonRender: function(ctx) { + var point, len = this.points.length, + x = this.pathOffset.x, + y = this.pathOffset.y; + + if (!len || isNaN(this.points[len - 1].y)) { + // do not draw if no points or odd points + // NaN comes from parseFloat of a empty string in parser + return false; + } + ctx.beginPath(); + ctx.moveTo(this.points[0].x - x, this.points[0].y - y); + for (var i = 0; i < len; i++) { + point = this.points[i]; + ctx.lineTo(point.x - x, point.y - y); + } + return true; + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _render: function(ctx) { + if (!this.commonRender(ctx)) { + return; + } + this._renderPaintInOrder(ctx); + }, + + /** + * Returns complexity of an instance + * @return {Number} complexity of this instance + */ + complexity: function() { + return this.get('points').length; + } + }); + + /* _FROM_SVG_START_ */ + /** + * List of attribute names to account for when parsing SVG element (used by {@link fabric.Polyline.fromElement}) + * @static + * @memberOf fabric.Polyline + * @see: http://www.w3.org/TR/SVG/shapes.html#PolylineElement + */ + fabric.Polyline.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat(); + + /** + * Returns fabric.Polyline instance from an SVG element + * @static + * @memberOf fabric.Polyline + * @param {SVGElement} element Element to parser + * @param {Function} callback callback function invoked after parsing + * @param {Object} [options] Options object + */ + fabric.Polyline.fromElementGenerator = function(_class) { + return function(element, callback, options) { + if (!element) { + return callback(null); + } + options || (options = { }); + + var points = fabric.parsePointsAttribute(element.getAttribute('points')), + parsedAttributes = fabric.parseAttributes(element, fabric[_class].ATTRIBUTE_NAMES); + parsedAttributes.fromSVG = true; + callback(new fabric[_class](points, extend(parsedAttributes, options))); + }; + }; + + fabric.Polyline.fromElement = fabric.Polyline.fromElementGenerator('Polyline'); + + /* _FROM_SVG_END_ */ + + /** + * Returns fabric.Polyline instance from an object representation + * @static + * @memberOf fabric.Polyline + * @param {Object} object Object to create an instance from + * @param {Function} [callback] Callback to invoke when an fabric.Path instance is created + */ + fabric.Polyline.fromObject = function(object, callback) { + return fabric.Object._fromObject('Polyline', object, callback, 'points'); + }; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = {}), + projectStrokeOnPoints = fabric.util.projectStrokeOnPoints; + + if (fabric.Polygon) { + fabric.warn('fabric.Polygon is already defined'); + return; + } + + /** + * Polygon class + * @class fabric.Polygon + * @extends fabric.Polyline + * @see {@link fabric.Polygon#initialize} for constructor definition + */ + fabric.Polygon = fabric.util.createClass(fabric.Polyline, /** @lends fabric.Polygon.prototype */ { + + /** + * Type of an object + * @type String + * @default + */ + type: 'polygon', + + /** + * @private + */ + _projectStrokeOnPoints: function () { + return projectStrokeOnPoints(this.points, this); + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _render: function(ctx) { + if (!this.commonRender(ctx)) { + return; + } + ctx.closePath(); + this._renderPaintInOrder(ctx); + }, + + }); + + /* _FROM_SVG_START_ */ + /** + * List of attribute names to account for when parsing SVG element (used by `fabric.Polygon.fromElement`) + * @static + * @memberOf fabric.Polygon + * @see: http://www.w3.org/TR/SVG/shapes.html#PolygonElement + */ + fabric.Polygon.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat(); + + /** + * Returns {@link fabric.Polygon} instance from an SVG element + * @static + * @memberOf fabric.Polygon + * @param {SVGElement} element Element to parse + * @param {Function} callback callback function invoked after parsing + * @param {Object} [options] Options object + */ + fabric.Polygon.fromElement = fabric.Polyline.fromElementGenerator('Polygon'); + /* _FROM_SVG_END_ */ + + /** + * Returns fabric.Polygon instance from an object representation + * @static + * @memberOf fabric.Polygon + * @param {Object} object Object to create an instance from + * @param {Function} [callback] Callback to invoke when an fabric.Path instance is created + * @return {void} + */ + fabric.Polygon.fromObject = function(object, callback) { + fabric.Object._fromObject('Polygon', object, callback, 'points'); + }; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + min = fabric.util.array.min, + max = fabric.util.array.max, + extend = fabric.util.object.extend, + clone = fabric.util.object.clone, + toFixed = fabric.util.toFixed; + + if (fabric.Path) { + fabric.warn('fabric.Path is already defined'); + return; + } + + /** + * Path class + * @class fabric.Path + * @extends fabric.Object + * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#path_and_pathgroup} + * @see {@link fabric.Path#initialize} for constructor definition + */ + fabric.Path = fabric.util.createClass(fabric.Object, /** @lends fabric.Path.prototype */ { + + /** + * Type of an object + * @type String + * @default + */ + type: 'path', + + /** + * Array of path points + * @type Array + * @default + */ + path: null, + + cacheProperties: fabric.Object.prototype.cacheProperties.concat('path', 'fillRule'), + + stateProperties: fabric.Object.prototype.stateProperties.concat('path'), + + /** + * Constructor + * @param {Array|String} path Path data (sequence of coordinates and corresponding "command" tokens) + * @param {Object} [options] Options object + * @return {fabric.Path} thisArg + */ + initialize: function (path, options) { + options = clone(options || {}); + delete options.path; + this.callSuper('initialize', options); + this._setPath(path || [], options); + }, + + /** + * @private + * @param {Array|String} path Path data (sequence of coordinates and corresponding "command" tokens) + * @param {Object} [options] Options object + */ + _setPath: function (path, options) { + this.path = fabric.util.makePathSimpler( + Array.isArray(path) ? path : fabric.util.parsePath(path) + ); + + fabric.Polyline.prototype._setPositionDimensions.call(this, options || {}); + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx context to render path on + */ + _renderPathCommands: function(ctx) { + var current, // current instruction + subpathStartX = 0, + subpathStartY = 0, + x = 0, // current x + y = 0, // current y + controlX = 0, // current control point x + controlY = 0, // current control point y + l = -this.pathOffset.x, + t = -this.pathOffset.y; + + ctx.beginPath(); + + for (var i = 0, len = this.path.length; i < len; ++i) { + + current = this.path[i]; + + switch (current[0]) { // first letter + + case 'L': // lineto, absolute + x = current[1]; + y = current[2]; + ctx.lineTo(x + l, y + t); + break; + + case 'M': // moveTo, absolute + x = current[1]; + y = current[2]; + subpathStartX = x; + subpathStartY = y; + ctx.moveTo(x + l, y + t); + break; + + case 'C': // bezierCurveTo, absolute + x = current[5]; + y = current[6]; + controlX = current[3]; + controlY = current[4]; + ctx.bezierCurveTo( + current[1] + l, + current[2] + t, + controlX + l, + controlY + t, + x + l, + y + t + ); + break; + + case 'Q': // quadraticCurveTo, absolute + ctx.quadraticCurveTo( + current[1] + l, + current[2] + t, + current[3] + l, + current[4] + t + ); + x = current[3]; + y = current[4]; + controlX = current[1]; + controlY = current[2]; + break; + + case 'z': + case 'Z': + x = subpathStartX; + y = subpathStartY; + ctx.closePath(); + break; + } + } + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx context to render path on + */ + _render: function(ctx) { + this._renderPathCommands(ctx); + this._renderPaintInOrder(ctx); + }, + + /** + * Returns string representation of an instance + * @return {String} string representation of an instance + */ + toString: function() { + return '#'; + }, + + /** + * Returns object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toObject: function(propertiesToInclude) { + return extend(this.callSuper('toObject', propertiesToInclude), { + path: this.path.map(function(item) { return item.slice(); }), + }); + }, + + /** + * Returns dataless object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toDatalessObject: function(propertiesToInclude) { + var o = this.toObject(['sourcePath'].concat(propertiesToInclude)); + if (o.sourcePath) { + delete o.path; + } + return o; + }, + + /* _TO_SVG_START_ */ + /** + * Returns svg representation of an instance + * @return {Array} an array of strings with the specific svg representation + * of the instance + */ + _toSVG: function() { + var path = fabric.util.joinPath(this.path); + return [ + '\n' + ]; + }, + + _getOffsetTransform: function() { + var digits = fabric.Object.NUM_FRACTION_DIGITS; + return ' translate(' + toFixed(-this.pathOffset.x, digits) + ', ' + + toFixed(-this.pathOffset.y, digits) + ')'; + }, + + /** + * Returns svg clipPath representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toClipPathSVG: function(reviver) { + var additionalTransform = this._getOffsetTransform(); + return '\t' + this._createBaseClipPathSVGMarkup( + this._toSVG(), { reviver: reviver, additionalTransform: additionalTransform } + ); + }, + + /** + * Returns svg representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toSVG: function(reviver) { + var additionalTransform = this._getOffsetTransform(); + return this._createBaseSVGMarkup(this._toSVG(), { reviver: reviver, additionalTransform: additionalTransform }); + }, + /* _TO_SVG_END_ */ + + /** + * Returns number representation of an instance complexity + * @return {Number} complexity of this instance + */ + complexity: function() { + return this.path.length; + }, + + /** + * @private + */ + _calcDimensions: function() { + + var aX = [], + aY = [], + current, // current instruction + subpathStartX = 0, + subpathStartY = 0, + x = 0, // current x + y = 0, // current y + bounds; + + for (var i = 0, len = this.path.length; i < len; ++i) { + + current = this.path[i]; + + switch (current[0]) { // first letter + + case 'L': // lineto, absolute + x = current[1]; + y = current[2]; + bounds = []; + break; + + case 'M': // moveTo, absolute + x = current[1]; + y = current[2]; + subpathStartX = x; + subpathStartY = y; + bounds = []; + break; + + case 'C': // bezierCurveTo, absolute + bounds = fabric.util.getBoundsOfCurve(x, y, + current[1], + current[2], + current[3], + current[4], + current[5], + current[6] + ); + x = current[5]; + y = current[6]; + break; + + case 'Q': // quadraticCurveTo, absolute + bounds = fabric.util.getBoundsOfCurve(x, y, + current[1], + current[2], + current[1], + current[2], + current[3], + current[4] + ); + x = current[3]; + y = current[4]; + break; + + case 'z': + case 'Z': + x = subpathStartX; + y = subpathStartY; + break; + } + bounds.forEach(function (point) { + aX.push(point.x); + aY.push(point.y); + }); + aX.push(x); + aY.push(y); + } + + var minX = min(aX) || 0, + minY = min(aY) || 0, + maxX = max(aX) || 0, + maxY = max(aY) || 0, + deltaX = maxX - minX, + deltaY = maxY - minY; + + return { + left: minX, + top: minY, + width: deltaX, + height: deltaY + }; + } + }); + + /** + * Creates an instance of fabric.Path from an object + * @static + * @memberOf fabric.Path + * @param {Object} object + * @param {Function} [callback] Callback to invoke when an fabric.Path instance is created + */ + fabric.Path.fromObject = function(object, callback) { + if (typeof object.sourcePath === 'string') { + var pathUrl = object.sourcePath; + fabric.loadSVGFromURL(pathUrl, function (elements) { + var path = elements[0]; + path.setOptions(object); + if (object.clipPath) { + fabric.util.enlivenObjects([object.clipPath], function(elivenedObjects) { + path.clipPath = elivenedObjects[0]; + callback && callback(path); + }); + } + else { + callback && callback(path); + } + }); + } + else { + fabric.Object._fromObject('Path', object, callback, 'path'); + } + }; + + /* _FROM_SVG_START_ */ + /** + * List of attribute names to account for when parsing SVG element (used by `fabric.Path.fromElement`) + * @static + * @memberOf fabric.Path + * @see http://www.w3.org/TR/SVG/paths.html#PathElement + */ + fabric.Path.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat(['d']); + + /** + * Creates an instance of fabric.Path from an SVG element + * @static + * @memberOf fabric.Path + * @param {SVGElement} element to parse + * @param {Function} callback Callback to invoke when an fabric.Path instance is created + * @param {Object} [options] Options object + * @param {Function} [callback] Options callback invoked after parsing is finished + */ + fabric.Path.fromElement = function(element, callback, options) { + var parsedAttributes = fabric.parseAttributes(element, fabric.Path.ATTRIBUTE_NAMES); + parsedAttributes.fromSVG = true; + callback(new fabric.Path(parsedAttributes.d, extend(parsedAttributes, options))); + }; + /* _FROM_SVG_END_ */ + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + min = fabric.util.array.min, + max = fabric.util.array.max; + + if (fabric.Group) { + return; + } + + /** + * Group class + * @class fabric.Group + * @extends fabric.Object + * @mixes fabric.Collection + * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#groups} + * @see {@link fabric.Group#initialize} for constructor definition + */ + fabric.Group = fabric.util.createClass(fabric.Object, fabric.Collection, /** @lends fabric.Group.prototype */ { + + /** + * Type of an object + * @type String + * @default + */ + type: 'group', + + /** + * Width of stroke + * @type Number + * @default + */ + strokeWidth: 0, + + /** + * Indicates if click, mouseover, mouseout events & hoverCursor should also check for subtargets + * @type Boolean + * @default + */ + subTargetCheck: false, + + /** + * Groups are container, do not render anything on theyr own, ence no cache properties + * @type Array + * @default + */ + cacheProperties: [], + + /** + * setOnGroup is a method used for TextBox that is no more used since 2.0.0 The behavior is still + * available setting this boolean to true. + * @type Boolean + * @since 2.0.0 + * @default + */ + useSetOnGroup: false, + + /** + * Constructor + * @param {Object} objects Group objects + * @param {Object} [options] Options object + * @param {Boolean} [isAlreadyGrouped] if true, objects have been grouped already. + * @return {Object} thisArg + */ + initialize: function(objects, options, isAlreadyGrouped) { + options = options || {}; + this._objects = []; + // if objects enclosed in a group have been grouped already, + // we cannot change properties of objects. + // Thus we need to set options to group without objects, + isAlreadyGrouped && this.callSuper('initialize', options); + this._objects = objects || []; + for (var i = this._objects.length; i--; ) { + this._objects[i].group = this; + } + + if (!isAlreadyGrouped) { + var center = options && options.centerPoint; + // we want to set origins before calculating the bounding box. + // so that the topleft can be set with that in mind. + // if specific top and left are passed, are overwritten later + // with the callSuper('initialize', options) + if (options.originX !== undefined) { + this.originX = options.originX; + } + if (options.originY !== undefined) { + this.originY = options.originY; + } + // if coming from svg i do not want to calc bounds. + // i assume width and height are passed along options + center || this._calcBounds(); + this._updateObjectsCoords(center); + delete options.centerPoint; + this.callSuper('initialize', options); + } + else { + this._updateObjectsACoords(); + } + + this.setCoords(); + }, + + /** + * @private + */ + _updateObjectsACoords: function() { + var skipControls = true; + for (var i = this._objects.length; i--; ){ + this._objects[i].setCoords(skipControls); + } + }, + + /** + * @private + * @param {Boolean} [skipCoordsChange] if true, coordinates of objects enclosed in a group do not change + */ + _updateObjectsCoords: function(center) { + var center = center || this.getCenterPoint(); + for (var i = this._objects.length; i--; ){ + this._updateObjectCoords(this._objects[i], center); + } + }, + + /** + * @private + * @param {Object} object + * @param {fabric.Point} center, current center of group. + */ + _updateObjectCoords: function(object, center) { + var objectLeft = object.left, + objectTop = object.top, + skipControls = true; + + object.set({ + left: objectLeft - center.x, + top: objectTop - center.y + }); + object.group = this; + object.setCoords(skipControls); + }, + + /** + * Returns string represenation of a group + * @return {String} + */ + toString: function() { + return '#'; + }, + + /** + * Adds an object to a group; Then recalculates group's dimension, position. + * @param {Object} object + * @return {fabric.Group} thisArg + * @chainable + */ + addWithUpdate: function(object) { + var nested = !!this.group; + this._restoreObjectsState(); + fabric.util.resetObjectTransform(this); + if (object) { + if (nested) { + // if this group is inside another group, we need to pre transform the object + fabric.util.removeTransformFromObject(object, this.group.calcTransformMatrix()); + } + this._objects.push(object); + object.group = this; + object._set('canvas', this.canvas); + } + this._calcBounds(); + this._updateObjectsCoords(); + this.dirty = true; + if (nested) { + this.group.addWithUpdate(); + } + else { + this.setCoords(); + } + return this; + }, + + /** + * Removes an object from a group; Then recalculates group's dimension, position. + * @param {Object} object + * @return {fabric.Group} thisArg + * @chainable + */ + removeWithUpdate: function(object) { + this._restoreObjectsState(); + fabric.util.resetObjectTransform(this); + + this.remove(object); + this._calcBounds(); + this._updateObjectsCoords(); + this.setCoords(); + this.dirty = true; + return this; + }, + + /** + * @private + */ + _onObjectAdded: function(object) { + this.dirty = true; + object.group = this; + object._set('canvas', this.canvas); + }, + + /** + * @private + */ + _onObjectRemoved: function(object) { + this.dirty = true; + delete object.group; + }, + + /** + * @private + */ + _set: function(key, value) { + var i = this._objects.length; + if (this.useSetOnGroup) { + while (i--) { + this._objects[i].setOnGroup(key, value); + } + } + if (key === 'canvas') { + while (i--) { + this._objects[i]._set(key, value); + } + } + fabric.Object.prototype._set.call(this, key, value); + }, + + /** + * Returns object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toObject: function(propertiesToInclude) { + var _includeDefaultValues = this.includeDefaultValues; + var objsToObject = this._objects + .filter(function (obj) { + return !obj.excludeFromExport; + }) + .map(function (obj) { + var originalDefaults = obj.includeDefaultValues; + obj.includeDefaultValues = _includeDefaultValues; + var _obj = obj.toObject(propertiesToInclude); + obj.includeDefaultValues = originalDefaults; + return _obj; + }); + var obj = fabric.Object.prototype.toObject.call(this, propertiesToInclude); + obj.objects = objsToObject; + return obj; + }, + + /** + * Returns object representation of an instance, in dataless mode. + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toDatalessObject: function(propertiesToInclude) { + var objsToObject, sourcePath = this.sourcePath; + if (sourcePath) { + objsToObject = sourcePath; + } + else { + var _includeDefaultValues = this.includeDefaultValues; + objsToObject = this._objects.map(function(obj) { + var originalDefaults = obj.includeDefaultValues; + obj.includeDefaultValues = _includeDefaultValues; + var _obj = obj.toDatalessObject(propertiesToInclude); + obj.includeDefaultValues = originalDefaults; + return _obj; + }); + } + var obj = fabric.Object.prototype.toDatalessObject.call(this, propertiesToInclude); + obj.objects = objsToObject; + return obj; + }, + + /** + * Renders instance on a given context + * @param {CanvasRenderingContext2D} ctx context to render instance on + */ + render: function(ctx) { + this._transformDone = true; + this.callSuper('render', ctx); + this._transformDone = false; + }, + + /** + * Decide if the object should cache or not. Create its own cache level + * needsItsOwnCache should be used when the object drawing method requires + * a cache step. None of the fabric classes requires it. + * Generally you do not cache objects in groups because the group is already cached. + * @return {Boolean} + */ + shouldCache: function() { + var ownCache = fabric.Object.prototype.shouldCache.call(this); + if (ownCache) { + for (var i = 0, len = this._objects.length; i < len; i++) { + if (this._objects[i].willDrawShadow()) { + this.ownCaching = false; + return false; + } + } + } + return ownCache; + }, + + /** + * Check if this object or a child object will cast a shadow + * @return {Boolean} + */ + willDrawShadow: function() { + if (fabric.Object.prototype.willDrawShadow.call(this)) { + return true; + } + for (var i = 0, len = this._objects.length; i < len; i++) { + if (this._objects[i].willDrawShadow()) { + return true; + } + } + return false; + }, + + /** + * Check if this group or its parent group are caching, recursively up + * @return {Boolean} + */ + isOnACache: function() { + return this.ownCaching || (this.group && this.group.isOnACache()); + }, + + /** + * Execute the drawing operation for an object on a specified context + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + drawObject: function(ctx) { + for (var i = 0, len = this._objects.length; i < len; i++) { + this._objects[i].render(ctx); + } + this._drawClipPath(ctx, this.clipPath); + }, + + /** + * Check if cache is dirty + */ + isCacheDirty: function(skipCanvas) { + if (this.callSuper('isCacheDirty', skipCanvas)) { + return true; + } + if (!this.statefullCache) { + return false; + } + for (var i = 0, len = this._objects.length; i < len; i++) { + if (this._objects[i].isCacheDirty(true)) { + if (this._cacheCanvas) { + // if this group has not a cache canvas there is nothing to clean + var x = this.cacheWidth / this.zoomX, y = this.cacheHeight / this.zoomY; + this._cacheContext.clearRect(-x / 2, -y / 2, x, y); + } + return true; + } + } + return false; + }, + + /** + * Restores original state of each of group objects (original state is that which was before group was created). + * if the nested boolean is true, the original state will be restored just for the + * first group and not for all the group chain + * @private + * @param {Boolean} nested tell the function to restore object state up to the parent group and not more + * @return {fabric.Group} thisArg + * @chainable + */ + _restoreObjectsState: function() { + var groupMatrix = this.calcOwnMatrix(); + this._objects.forEach(function(object) { + // instead of using _this = this; + fabric.util.addTransformToObject(object, groupMatrix); + delete object.group; + object.setCoords(); + }); + return this; + }, + + /** + * Destroys a group (restoring state of its objects) + * @return {fabric.Group} thisArg + * @chainable + */ + destroy: function() { + // when group is destroyed objects needs to get a repaint to be eventually + // displayed on canvas. + this._objects.forEach(function(object) { + object.set('dirty', true); + }); + return this._restoreObjectsState(); + }, + + dispose: function () { + this.callSuper('dispose'); + this.forEachObject(function (object) { + object.dispose && object.dispose(); + }); + this._objects = []; + }, + + /** + * make a group an active selection, remove the group from canvas + * the group has to be on canvas for this to work. + * @return {fabric.ActiveSelection} thisArg + * @chainable + */ + toActiveSelection: function() { + if (!this.canvas) { + return; + } + var objects = this._objects, canvas = this.canvas; + this._objects = []; + var options = this.toObject(); + delete options.objects; + var activeSelection = new fabric.ActiveSelection([]); + activeSelection.set(options); + activeSelection.type = 'activeSelection'; + canvas.remove(this); + objects.forEach(function(object) { + object.group = activeSelection; + object.dirty = true; + canvas.add(object); + }); + activeSelection.canvas = canvas; + activeSelection._objects = objects; + canvas._activeObject = activeSelection; + activeSelection.setCoords(); + return activeSelection; + }, + + /** + * Destroys a group (restoring state of its objects) + * @return {fabric.Group} thisArg + * @chainable + */ + ungroupOnCanvas: function() { + return this._restoreObjectsState(); + }, + + /** + * Sets coordinates of all objects inside group + * @return {fabric.Group} thisArg + * @chainable + */ + setObjectsCoords: function() { + var skipControls = true; + this.forEachObject(function(object) { + object.setCoords(skipControls); + }); + return this; + }, + + /** + * @private + */ + _calcBounds: function(onlyWidthHeight) { + var aX = [], + aY = [], + o, prop, coords, + props = ['tr', 'br', 'bl', 'tl'], + i = 0, iLen = this._objects.length, + j, jLen = props.length; + + for ( ; i < iLen; ++i) { + o = this._objects[i]; + coords = o.calcACoords(); + for (j = 0; j < jLen; j++) { + prop = props[j]; + aX.push(coords[prop].x); + aY.push(coords[prop].y); + } + o.aCoords = coords; + } + + this._getBounds(aX, aY, onlyWidthHeight); + }, + + /** + * @private + */ + _getBounds: function(aX, aY, onlyWidthHeight) { + var minXY = new fabric.Point(min(aX), min(aY)), + maxXY = new fabric.Point(max(aX), max(aY)), + top = minXY.y || 0, left = minXY.x || 0, + width = (maxXY.x - minXY.x) || 0, + height = (maxXY.y - minXY.y) || 0; + this.width = width; + this.height = height; + if (!onlyWidthHeight) { + // the bounding box always finds the topleft most corner. + // whatever is the group origin, we set up here the left/top position. + this.setPositionByOrigin({ x: left, y: top }, 'left', 'top'); + } + }, + + /* _TO_SVG_START_ */ + /** + * Returns svg representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + _toSVG: function(reviver) { + var svgString = ['\n']; + + for (var i = 0, len = this._objects.length; i < len; i++) { + svgString.push('\t\t', this._objects[i].toSVG(reviver)); + } + svgString.push('\n'); + return svgString; + }, + + /** + * Returns styles-string for svg-export, specific version for group + * @return {String} + */ + getSvgStyles: function() { + var opacity = typeof this.opacity !== 'undefined' && this.opacity !== 1 ? + 'opacity: ' + this.opacity + ';' : '', + visibility = this.visible ? '' : ' visibility: hidden;'; + return [ + opacity, + this.getSvgFilter(), + visibility + ].join(''); + }, + + /** + * Returns svg clipPath representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toClipPathSVG: function(reviver) { + var svgString = []; + + for (var i = 0, len = this._objects.length; i < len; i++) { + svgString.push('\t', this._objects[i].toClipPathSVG(reviver)); + } + + return this._createBaseClipPathSVGMarkup(svgString, { reviver: reviver }); + }, + /* _TO_SVG_END_ */ + }); + + /** + * Returns {@link fabric.Group} instance from an object representation + * @static + * @memberOf fabric.Group + * @param {Object} object Object to create a group from + * @param {Function} [callback] Callback to invoke when an group instance is created + */ + fabric.Group.fromObject = function(object, callback) { + var objects = object.objects, + options = fabric.util.object.clone(object, true); + delete options.objects; + if (typeof objects === 'string') { + // it has to be an url or something went wrong. + fabric.loadSVGFromURL(objects, function (elements) { + var group = fabric.util.groupSVGElements(elements, object, objects); + var clipPath = options.clipPath; + delete options.clipPath; + group.set(options); + if (clipPath) { + fabric.util.enlivenObjects([clipPath], function(elivenedObjects) { + group.clipPath = elivenedObjects[0]; + callback && callback(group); + }); + } + else { + callback && callback(group); + } + }); + return; + } + fabric.util.enlivenObjects(objects, function (enlivenedObjects) { + fabric.util.enlivenObjectEnlivables(object, options, function () { + callback && callback(new fabric.Group(enlivenedObjects, options, true)); + }); + }); + }; +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }); + + if (fabric.ActiveSelection) { + return; + } + + /** + * Group class + * @class fabric.ActiveSelection + * @extends fabric.Group + * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#groups} + * @see {@link fabric.ActiveSelection#initialize} for constructor definition + */ + fabric.ActiveSelection = fabric.util.createClass(fabric.Group, /** @lends fabric.ActiveSelection.prototype */ { + + /** + * Type of an object + * @type String + * @default + */ + type: 'activeSelection', + + /** + * Constructor + * @param {Object} objects ActiveSelection objects + * @param {Object} [options] Options object + * @return {Object} thisArg + */ + initialize: function(objects, options) { + options = options || {}; + this._objects = objects || []; + for (var i = this._objects.length; i--; ) { + this._objects[i].group = this; + } + + if (options.originX) { + this.originX = options.originX; + } + if (options.originY) { + this.originY = options.originY; + } + this._calcBounds(); + this._updateObjectsCoords(); + fabric.Object.prototype.initialize.call(this, options); + this.setCoords(); + }, + + /** + * Change te activeSelection to a normal group, + * High level function that automatically adds it to canvas as + * active object. no events fired. + * @since 2.0.0 + * @return {fabric.Group} + */ + toGroup: function() { + var objects = this._objects.concat(); + this._objects = []; + var options = fabric.Object.prototype.toObject.call(this); + var newGroup = new fabric.Group([]); + delete options.type; + newGroup.set(options); + objects.forEach(function(object) { + object.canvas.remove(object); + object.group = newGroup; + }); + newGroup._objects = objects; + if (!this.canvas) { + return newGroup; + } + var canvas = this.canvas; + canvas.add(newGroup); + canvas._activeObject = newGroup; + newGroup.setCoords(); + return newGroup; + }, + + /** + * If returns true, deselection is cancelled. + * @since 2.0.0 + * @return {Boolean} [cancel] + */ + onDeselect: function() { + this.destroy(); + return false; + }, + + /** + * Returns string representation of a group + * @return {String} + */ + toString: function() { + return '#'; + }, + + /** + * Decide if the object should cache or not. Create its own cache level + * objectCaching is a global flag, wins over everything + * needsItsOwnCache should be used when the object drawing method requires + * a cache step. None of the fabric classes requires it. + * Generally you do not cache objects in groups because the group outside is cached. + * @return {Boolean} + */ + shouldCache: function() { + return false; + }, + + /** + * Check if this group or its parent group are caching, recursively up + * @return {Boolean} + */ + isOnACache: function() { + return false; + }, + + /** + * Renders controls and borders for the object + * @param {CanvasRenderingContext2D} ctx Context to render on + * @param {Object} [styleOverride] properties to override the object style + * @param {Object} [childrenOverride] properties to override the children overrides + */ + _renderControls: function(ctx, styleOverride, childrenOverride) { + ctx.save(); + ctx.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1; + this.callSuper('_renderControls', ctx, styleOverride); + childrenOverride = childrenOverride || { }; + if (typeof childrenOverride.hasControls === 'undefined') { + childrenOverride.hasControls = false; + } + childrenOverride.forActiveSelection = true; + for (var i = 0, len = this._objects.length; i < len; i++) { + this._objects[i]._renderControls(ctx, childrenOverride); + } + ctx.restore(); + }, + }); + + /** + * Returns {@link fabric.ActiveSelection} instance from an object representation + * @static + * @memberOf fabric.ActiveSelection + * @param {Object} object Object to create a group from + * @param {Function} [callback] Callback to invoke when an ActiveSelection instance is created + */ + fabric.ActiveSelection.fromObject = function(object, callback) { + fabric.util.enlivenObjects(object.objects, function(enlivenedObjects) { + delete object.objects; + callback && callback(new fabric.ActiveSelection(enlivenedObjects, object, true)); + }); + }; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var extend = fabric.util.object.extend; + + if (!global.fabric) { + global.fabric = { }; + } + + if (global.fabric.Image) { + fabric.warn('fabric.Image is already defined.'); + return; + } + + /** + * Image class + * @class fabric.Image + * @extends fabric.Object + * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#images} + * @see {@link fabric.Image#initialize} for constructor definition + */ + fabric.Image = fabric.util.createClass(fabric.Object, /** @lends fabric.Image.prototype */ { + + /** + * Type of an object + * @type String + * @default + */ + type: 'image', + + /** + * Width of a stroke. + * For image quality a stroke multiple of 2 gives better results. + * @type Number + * @default + */ + strokeWidth: 0, + + /** + * When calling {@link fabric.Image.getSrc}, return value from element src with `element.getAttribute('src')`. + * This allows for relative urls as image src. + * @since 2.7.0 + * @type Boolean + * @default + */ + srcFromAttribute: false, + + /** + * private + * contains last value of scaleX to detect + * if the Image got resized after the last Render + * @type Number + */ + _lastScaleX: 1, + + /** + * private + * contains last value of scaleY to detect + * if the Image got resized after the last Render + * @type Number + */ + _lastScaleY: 1, + + /** + * private + * contains last value of scaling applied by the apply filter chain + * @type Number + */ + _filterScalingX: 1, + + /** + * private + * contains last value of scaling applied by the apply filter chain + * @type Number + */ + _filterScalingY: 1, + + /** + * minimum scale factor under which any resizeFilter is triggered to resize the image + * 0 will disable the automatic resize. 1 will trigger automatically always. + * number bigger than 1 are not implemented yet. + * @type Number + */ + minimumScaleTrigger: 0.5, + + /** + * List of properties to consider when checking if + * state of an object is changed ({@link fabric.Object#hasStateChanged}) + * as well as for history (undo/redo) purposes + * @type Array + */ + stateProperties: fabric.Object.prototype.stateProperties.concat('cropX', 'cropY'), + + /** + * List of properties to consider when checking if cache needs refresh + * Those properties are checked by statefullCache ON ( or lazy mode if we want ) or from single + * calls to Object.set(key, value). If the key is in this list, the object is marked as dirty + * and refreshed at the next render + * @type Array + */ + cacheProperties: fabric.Object.prototype.cacheProperties.concat('cropX', 'cropY'), + + /** + * key used to retrieve the texture representing this image + * @since 2.0.0 + * @type String + * @default + */ + cacheKey: '', + + /** + * Image crop in pixels from original image size. + * @since 2.0.0 + * @type Number + * @default + */ + cropX: 0, + + /** + * Image crop in pixels from original image size. + * @since 2.0.0 + * @type Number + * @default + */ + cropY: 0, + + /** + * Indicates whether this canvas will use image smoothing when painting this image. + * Also influence if the cacheCanvas for this image uses imageSmoothing + * @since 4.0.0-beta.11 + * @type Boolean + * @default + */ + imageSmoothing: true, + + /** + * Constructor + * Image can be initialized with any canvas drawable or a string. + * The string should be a url and will be loaded as an image. + * Canvas and Image element work out of the box, while videos require extra code to work. + * Please check video element events for seeking. + * @param {HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | String} element Image element + * @param {Object} [options] Options object + * @param {function} [callback] callback function to call after eventual filters applied. + * @return {fabric.Image} thisArg + */ + initialize: function(element, options) { + options || (options = { }); + this.filters = []; + this.cacheKey = 'texture' + fabric.Object.__uid++; + this.callSuper('initialize', options); + this._initElement(element, options); + }, + + /** + * Returns image element which this instance if based on + * @return {HTMLImageElement} Image element + */ + getElement: function() { + return this._element || {}; + }, + + /** + * Sets image element for this instance to a specified one. + * If filters defined they are applied to new image. + * You might need to call `canvas.renderAll` and `object.setCoords` after replacing, to render new image and update controls area. + * @param {HTMLImageElement} element + * @param {Object} [options] Options object + * @return {fabric.Image} thisArg + * @chainable + */ + setElement: function(element, options) { + this.removeTexture(this.cacheKey); + this.removeTexture(this.cacheKey + '_filtered'); + this._element = element; + this._originalElement = element; + this._initConfig(options); + if (this.filters.length !== 0) { + this.applyFilters(); + } + // resizeFilters work on the already filtered copy. + // we need to apply resizeFilters AFTER normal filters. + // applyResizeFilters is run more often than normal filters + // and is triggered by user interactions rather than dev code + if (this.resizeFilter) { + this.applyResizeFilters(); + } + return this; + }, + + /** + * Delete a single texture if in webgl mode + */ + removeTexture: function(key) { + var backend = fabric.filterBackend; + if (backend && backend.evictCachesForKey) { + backend.evictCachesForKey(key); + } + }, + + /** + * Delete textures, reference to elements and eventually JSDOM cleanup + */ + dispose: function () { + this.callSuper('dispose'); + this.removeTexture(this.cacheKey); + this.removeTexture(this.cacheKey + '_filtered'); + this._cacheContext = undefined; + ['_originalElement', '_element', '_filteredEl', '_cacheCanvas'].forEach((function(element) { + fabric.util.cleanUpJsdomNode(this[element]); + this[element] = undefined; + }).bind(this)); + }, + + /** + * Get the crossOrigin value (of the corresponding image element) + */ + getCrossOrigin: function() { + return this._originalElement && (this._originalElement.crossOrigin || null); + }, + + /** + * Returns original size of an image + * @return {Object} Object with "width" and "height" properties + */ + getOriginalSize: function() { + var element = this.getElement(); + return { + width: element.naturalWidth || element.width, + height: element.naturalHeight || element.height + }; + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _stroke: function(ctx) { + if (!this.stroke || this.strokeWidth === 0) { + return; + } + var w = this.width / 2, h = this.height / 2; + ctx.beginPath(); + ctx.moveTo(-w, -h); + ctx.lineTo(w, -h); + ctx.lineTo(w, h); + ctx.lineTo(-w, h); + ctx.lineTo(-w, -h); + ctx.closePath(); + }, + + /** + * Returns object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} Object representation of an instance + */ + toObject: function(propertiesToInclude) { + var filters = []; + + this.filters.forEach(function(filterObj) { + if (filterObj) { + filters.push(filterObj.toObject()); + } + }); + var object = extend( + this.callSuper( + 'toObject', + ['cropX', 'cropY'].concat(propertiesToInclude) + ), { + src: this.getSrc(), + crossOrigin: this.getCrossOrigin(), + filters: filters, + }); + if (this.resizeFilter) { + object.resizeFilter = this.resizeFilter.toObject(); + } + return object; + }, + + /** + * Returns true if an image has crop applied, inspecting values of cropX,cropY,width,height. + * @return {Boolean} + */ + hasCrop: function() { + return this.cropX || this.cropY || this.width < this._element.width || this.height < this._element.height; + }, + + /* _TO_SVG_START_ */ + /** + * Returns svg representation of an instance + * @return {Array} an array of strings with the specific svg representation + * of the instance + */ + _toSVG: function() { + var svgString = [], imageMarkup = [], strokeSvg, element = this._element, + x = -this.width / 2, y = -this.height / 2, clipPath = '', imageRendering = ''; + if (!element) { + return []; + } + if (this.hasCrop()) { + var clipPathId = fabric.Object.__uid++; + svgString.push( + '\n', + '\t\n', + '\n' + ); + clipPath = ' clip-path="url(#imageCrop_' + clipPathId + ')" '; + } + if (!this.imageSmoothing) { + imageRendering = '" image-rendering="optimizeSpeed'; + } + imageMarkup.push('\t\n'); + + if (this.stroke || this.strokeDashArray) { + var origFill = this.fill; + this.fill = null; + strokeSvg = [ + '\t\n' + ]; + this.fill = origFill; + } + if (this.paintFirst !== 'fill') { + svgString = svgString.concat(strokeSvg, imageMarkup); + } + else { + svgString = svgString.concat(imageMarkup, strokeSvg); + } + return svgString; + }, + /* _TO_SVG_END_ */ + + /** + * Returns source of an image + * @param {Boolean} filtered indicates if the src is needed for svg + * @return {String} Source of an image + */ + getSrc: function(filtered) { + var element = filtered ? this._element : this._originalElement; + if (element) { + if (element.toDataURL) { + return element.toDataURL(); + } + + if (this.srcFromAttribute) { + return element.getAttribute('src'); + } + else { + return element.src; + } + } + else { + return this.src || ''; + } + }, + + /** + * Sets source of an image + * @param {String} src Source string (URL) + * @param {Function} [callback] Callback is invoked when image has been loaded (and all filters have been applied) + * @param {Object} [options] Options object + * @param {String} [options.crossOrigin] crossOrigin value (one of "", "anonymous", "use-credentials") + * @see https://developer.mozilla.org/en-US/docs/HTML/CORS_settings_attributes + * @return {fabric.Image} thisArg + * @chainable + */ + setSrc: function(src, callback, options) { + fabric.util.loadImage(src, function(img, isError) { + this.setElement(img, options); + this._setWidthHeight(); + callback && callback(this, isError); + }, this, options && options.crossOrigin); + return this; + }, + + /** + * Returns string representation of an instance + * @return {String} String representation of an instance + */ + toString: function() { + return '#'; + }, + + applyResizeFilters: function() { + var filter = this.resizeFilter, + minimumScale = this.minimumScaleTrigger, + objectScale = this.getTotalObjectScaling(), + scaleX = objectScale.scaleX, + scaleY = objectScale.scaleY, + elementToFilter = this._filteredEl || this._originalElement; + if (this.group) { + this.set('dirty', true); + } + if (!filter || (scaleX > minimumScale && scaleY > minimumScale)) { + this._element = elementToFilter; + this._filterScalingX = 1; + this._filterScalingY = 1; + this._lastScaleX = scaleX; + this._lastScaleY = scaleY; + return; + } + if (!fabric.filterBackend) { + fabric.filterBackend = fabric.initFilterBackend(); + } + var canvasEl = fabric.util.createCanvasElement(), + cacheKey = this._filteredEl ? (this.cacheKey + '_filtered') : this.cacheKey, + sourceWidth = elementToFilter.width, sourceHeight = elementToFilter.height; + canvasEl.width = sourceWidth; + canvasEl.height = sourceHeight; + this._element = canvasEl; + this._lastScaleX = filter.scaleX = scaleX; + this._lastScaleY = filter.scaleY = scaleY; + fabric.filterBackend.applyFilters( + [filter], elementToFilter, sourceWidth, sourceHeight, this._element, cacheKey); + this._filterScalingX = canvasEl.width / this._originalElement.width; + this._filterScalingY = canvasEl.height / this._originalElement.height; + }, + + /** + * Applies filters assigned to this image (from "filters" array) or from filter param + * @method applyFilters + * @param {Array} filters to be applied + * @param {Boolean} forResizing specify if the filter operation is a resize operation + * @return {thisArg} return the fabric.Image object + * @chainable + */ + applyFilters: function(filters) { + + filters = filters || this.filters || []; + filters = filters.filter(function(filter) { return filter && !filter.isNeutralState(); }); + this.set('dirty', true); + + // needs to clear out or WEBGL will not resize correctly + this.removeTexture(this.cacheKey + '_filtered'); + + if (filters.length === 0) { + this._element = this._originalElement; + this._filteredEl = null; + this._filterScalingX = 1; + this._filterScalingY = 1; + return this; + } + + var imgElement = this._originalElement, + sourceWidth = imgElement.naturalWidth || imgElement.width, + sourceHeight = imgElement.naturalHeight || imgElement.height; + + if (this._element === this._originalElement) { + // if the element is the same we need to create a new element + var canvasEl = fabric.util.createCanvasElement(); + canvasEl.width = sourceWidth; + canvasEl.height = sourceHeight; + this._element = canvasEl; + this._filteredEl = canvasEl; + } + else { + // clear the existing element to get new filter data + // also dereference the eventual resized _element + this._element = this._filteredEl; + this._filteredEl.getContext('2d').clearRect(0, 0, sourceWidth, sourceHeight); + // we also need to resize again at next renderAll, so remove saved _lastScaleX/Y + this._lastScaleX = 1; + this._lastScaleY = 1; + } + if (!fabric.filterBackend) { + fabric.filterBackend = fabric.initFilterBackend(); + } + fabric.filterBackend.applyFilters( + filters, this._originalElement, sourceWidth, sourceHeight, this._element, this.cacheKey); + if (this._originalElement.width !== this._element.width || + this._originalElement.height !== this._element.height) { + this._filterScalingX = this._element.width / this._originalElement.width; + this._filterScalingY = this._element.height / this._originalElement.height; + } + return this; + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _render: function(ctx) { + fabric.util.setImageSmoothing(ctx, this.imageSmoothing); + if (this.isMoving !== true && this.resizeFilter && this._needsResize()) { + this.applyResizeFilters(); + } + this._stroke(ctx); + this._renderPaintInOrder(ctx); + }, + + /** + * Paint the cached copy of the object on the target context. + * it will set the imageSmoothing for the draw operation + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + drawCacheOnCanvas: function(ctx) { + fabric.util.setImageSmoothing(ctx, this.imageSmoothing); + fabric.Object.prototype.drawCacheOnCanvas.call(this, ctx); + }, + + /** + * Decide if the object should cache or not. Create its own cache level + * needsItsOwnCache should be used when the object drawing method requires + * a cache step. None of the fabric classes requires it. + * Generally you do not cache objects in groups because the group outside is cached. + * This is the special image version where we would like to avoid caching where possible. + * Essentially images do not benefit from caching. They may require caching, and in that + * case we do it. Also caching an image usually ends in a loss of details. + * A full performance audit should be done. + * @return {Boolean} + */ + shouldCache: function() { + return this.needsItsOwnCache(); + }, + + _renderFill: function(ctx) { + var elementToDraw = this._element; + if (!elementToDraw) { + return; + } + var scaleX = this._filterScalingX, scaleY = this._filterScalingY, + w = this.width, h = this.height, min = Math.min, max = Math.max, + // crop values cannot be lesser than 0. + cropX = max(this.cropX, 0), cropY = max(this.cropY, 0), + elWidth = elementToDraw.naturalWidth || elementToDraw.width, + elHeight = elementToDraw.naturalHeight || elementToDraw.height, + sX = cropX * scaleX, + sY = cropY * scaleY, + // the width height cannot exceed element width/height, starting from the crop offset. + sW = min(w * scaleX, elWidth - sX), + sH = min(h * scaleY, elHeight - sY), + x = -w / 2, y = -h / 2, + maxDestW = min(w, elWidth / scaleX - cropX), + maxDestH = min(h, elHeight / scaleY - cropY); + + elementToDraw && ctx.drawImage(elementToDraw, sX, sY, sW, sH, x, y, maxDestW, maxDestH); + }, + + /** + * needed to check if image needs resize + * @private + */ + _needsResize: function() { + var scale = this.getTotalObjectScaling(); + return (scale.scaleX !== this._lastScaleX || scale.scaleY !== this._lastScaleY); + }, + + /** + * @private + */ + _resetWidthHeight: function() { + this.set(this.getOriginalSize()); + }, + + /** + * The Image class's initialization method. This method is automatically + * called by the constructor. + * @private + * @param {HTMLImageElement|String} element The element representing the image + * @param {Object} [options] Options object + */ + _initElement: function(element, options) { + this.setElement(fabric.util.getById(element), options); + fabric.util.addClass(this.getElement(), fabric.Image.CSS_CANVAS); + }, + + /** + * @private + * @param {Object} [options] Options object + */ + _initConfig: function(options) { + options || (options = { }); + this.setOptions(options); + this._setWidthHeight(options); + }, + + /** + * @private + * @param {Array} filters to be initialized + * @param {Function} callback Callback to invoke when all fabric.Image.filters instances are created + */ + _initFilters: function(filters, callback) { + if (filters && filters.length) { + fabric.util.enlivenObjects(filters, function(enlivenedObjects) { + callback && callback(enlivenedObjects); + }, 'fabric.Image.filters'); + } + else { + callback && callback(); + } + }, + + /** + * @private + * Set the width and the height of the image object, using the element or the + * options. + * @param {Object} [options] Object with width/height properties + */ + _setWidthHeight: function(options) { + options || (options = { }); + var el = this.getElement(); + this.width = options.width || el.naturalWidth || el.width || 0; + this.height = options.height || el.naturalHeight || el.height || 0; + }, + + /** + * Calculate offset for center and scale factor for the image in order to respect + * the preserveAspectRatio attribute + * @private + * @return {Object} + */ + parsePreserveAspectRatioAttribute: function() { + var pAR = fabric.util.parsePreserveAspectRatioAttribute(this.preserveAspectRatio || ''), + rWidth = this._element.width, rHeight = this._element.height, + scaleX = 1, scaleY = 1, offsetLeft = 0, offsetTop = 0, cropX = 0, cropY = 0, + offset, pWidth = this.width, pHeight = this.height, parsedAttributes = { width: pWidth, height: pHeight }; + if (pAR && (pAR.alignX !== 'none' || pAR.alignY !== 'none')) { + if (pAR.meetOrSlice === 'meet') { + scaleX = scaleY = fabric.util.findScaleToFit(this._element, parsedAttributes); + offset = (pWidth - rWidth * scaleX) / 2; + if (pAR.alignX === 'Min') { + offsetLeft = -offset; + } + if (pAR.alignX === 'Max') { + offsetLeft = offset; + } + offset = (pHeight - rHeight * scaleY) / 2; + if (pAR.alignY === 'Min') { + offsetTop = -offset; + } + if (pAR.alignY === 'Max') { + offsetTop = offset; + } + } + if (pAR.meetOrSlice === 'slice') { + scaleX = scaleY = fabric.util.findScaleToCover(this._element, parsedAttributes); + offset = rWidth - pWidth / scaleX; + if (pAR.alignX === 'Mid') { + cropX = offset / 2; + } + if (pAR.alignX === 'Max') { + cropX = offset; + } + offset = rHeight - pHeight / scaleY; + if (pAR.alignY === 'Mid') { + cropY = offset / 2; + } + if (pAR.alignY === 'Max') { + cropY = offset; + } + rWidth = pWidth / scaleX; + rHeight = pHeight / scaleY; + } + } + else { + scaleX = pWidth / rWidth; + scaleY = pHeight / rHeight; + } + return { + width: rWidth, + height: rHeight, + scaleX: scaleX, + scaleY: scaleY, + offsetLeft: offsetLeft, + offsetTop: offsetTop, + cropX: cropX, + cropY: cropY + }; + } + }); + + /** + * Default CSS class name for canvas + * @static + * @type String + * @default + */ + fabric.Image.CSS_CANVAS = 'canvas-img'; + + /** + * Alias for getSrc + * @static + */ + fabric.Image.prototype.getSvgSrc = fabric.Image.prototype.getSrc; + + /** + * Creates an instance of fabric.Image from its object representation + * @static + * @param {Object} object Object to create an instance from + * @param {Function} callback Callback to invoke when an image instance is created + */ + fabric.Image.fromObject = function(_object, callback) { + var object = fabric.util.object.clone(_object); + fabric.util.loadImage(object.src, function(img, isError) { + if (isError) { + callback && callback(null, true); + return; + } + fabric.Image.prototype._initFilters.call(object, object.filters, function(filters) { + object.filters = filters || []; + fabric.Image.prototype._initFilters.call(object, [object.resizeFilter], function(resizeFilters) { + object.resizeFilter = resizeFilters[0]; + fabric.util.enlivenObjectEnlivables(object, object, function () { + var image = new fabric.Image(img, object); + callback(image, false); + }); + }); + }); + }, null, object.crossOrigin); + }; + + /** + * Creates an instance of fabric.Image from an URL string + * @static + * @param {String} url URL to create an image from + * @param {Function} [callback] Callback to invoke when image is created (newly created image is passed as a first argument). Second argument is a boolean indicating if an error occurred or not. + * @param {Object} [imgOptions] Options object + */ + fabric.Image.fromURL = function(url, callback, imgOptions) { + fabric.util.loadImage(url, function(img, isError) { + callback && callback(new fabric.Image(img, imgOptions), isError); + }, null, imgOptions && imgOptions.crossOrigin); + }; + + /* _FROM_SVG_START_ */ + /** + * List of attribute names to account for when parsing SVG element (used by {@link fabric.Image.fromElement}) + * @static + * @see {@link http://www.w3.org/TR/SVG/struct.html#ImageElement} + */ + fabric.Image.ATTRIBUTE_NAMES = + fabric.SHARED_ATTRIBUTES.concat( + 'x y width height preserveAspectRatio xlink:href crossOrigin image-rendering'.split(' ') + ); + + /** + * Returns {@link fabric.Image} instance from an SVG element + * @static + * @param {SVGElement} element Element to parse + * @param {Object} [options] Options object + * @param {Function} callback Callback to execute when fabric.Image object is created + * @return {fabric.Image} Instance of fabric.Image + */ + fabric.Image.fromElement = function(element, callback, options) { + var parsedAttributes = fabric.parseAttributes(element, fabric.Image.ATTRIBUTE_NAMES); + fabric.Image.fromURL(parsedAttributes['xlink:href'], callback, + extend((options ? fabric.util.object.clone(options) : { }), parsedAttributes)); + }; + /* _FROM_SVG_END_ */ + +})(typeof exports !== 'undefined' ? exports : this); + + +fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ { + + /** + * @private + * @return {Number} angle value + */ + _getAngleValueForStraighten: function() { + var angle = this.angle % 360; + if (angle > 0) { + return Math.round((angle - 1) / 90) * 90; + } + return Math.round(angle / 90) * 90; + }, + + /** + * Straightens an object (rotating it from current angle to one of 0, 90, 180, 270, etc. depending on which is closer) + * @return {fabric.Object} thisArg + * @chainable + */ + straighten: function() { + return this.rotate(this._getAngleValueForStraighten()); + }, + + /** + * Same as {@link fabric.Object.prototype.straighten} but with animation + * @param {Object} callbacks Object with callback functions + * @param {Function} [callbacks.onComplete] Invoked on completion + * @param {Function} [callbacks.onChange] Invoked on every step of animation + * @return {fabric.Object} thisArg + */ + fxStraighten: function(callbacks) { + callbacks = callbacks || { }; + + var empty = function() { }, + onComplete = callbacks.onComplete || empty, + onChange = callbacks.onChange || empty, + _this = this; + + return fabric.util.animate({ + target: this, + startValue: this.get('angle'), + endValue: this._getAngleValueForStraighten(), + duration: this.FX_DURATION, + onChange: function(value) { + _this.rotate(value); + onChange(); + }, + onComplete: function() { + _this.setCoords(); + onComplete(); + }, + }); + } +}); + +fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.StaticCanvas.prototype */ { + + /** + * Straightens object, then rerenders canvas + * @param {fabric.Object} object Object to straighten + * @return {fabric.Canvas} thisArg + * @chainable + */ + straightenObject: function (object) { + object.straighten(); + this.requestRenderAll(); + return this; + }, + + /** + * Same as {@link fabric.Canvas.prototype.straightenObject}, but animated + * @param {fabric.Object} object Object to straighten + * @return {fabric.Canvas} thisArg + */ + fxStraightenObject: function (object) { + return object.fxStraighten({ + onChange: this.requestRenderAllBound + }); + } +}); + + +(function() { + + 'use strict'; + + /** + * Tests if webgl supports certain precision + * @param {WebGL} Canvas WebGL context to test on + * @param {String} Precision to test can be any of following: 'lowp', 'mediump', 'highp' + * @returns {Boolean} Whether the user's browser WebGL supports given precision. + */ + function testPrecision(gl, precision){ + var fragmentSource = 'precision ' + precision + ' float;\nvoid main(){}'; + var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); + gl.shaderSource(fragmentShader, fragmentSource); + gl.compileShader(fragmentShader); + if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) { + return false; + } + return true; + } + + /** + * Indicate whether this filtering backend is supported by the user's browser. + * @param {Number} tileSize check if the tileSize is supported + * @returns {Boolean} Whether the user's browser supports WebGL. + */ + fabric.isWebglSupported = function(tileSize) { + if (fabric.isLikelyNode) { + return false; + } + tileSize = tileSize || fabric.WebglFilterBackend.prototype.tileSize; + var canvas = document.createElement('canvas'); + var gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); + var isSupported = false; + // eslint-disable-next-line + if (gl) { + fabric.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); + isSupported = fabric.maxTextureSize >= tileSize; + var precisions = ['highp', 'mediump', 'lowp']; + for (var i = 0; i < 3; i++){ + if (testPrecision(gl, precisions[i])){ + fabric.webGlPrecision = precisions[i]; + break; + }; + } + } + this.isSupported = isSupported; + return isSupported; + }; + + fabric.WebglFilterBackend = WebglFilterBackend; + + /** + * WebGL filter backend. + */ + function WebglFilterBackend(options) { + if (options && options.tileSize) { + this.tileSize = options.tileSize; + } + this.setupGLContext(this.tileSize, this.tileSize); + this.captureGPUInfo(); + }; + + WebglFilterBackend.prototype = /** @lends fabric.WebglFilterBackend.prototype */ { + + tileSize: 2048, + + /** + * Experimental. This object is a sort of repository of help layers used to avoid + * of recreating them during frequent filtering. If you are previewing a filter with + * a slider you probably do not want to create help layers every filter step. + * in this object there will be appended some canvases, created once, resized sometimes + * cleared never. Clearing is left to the developer. + **/ + resources: { + + }, + + /** + * Setup a WebGL context suitable for filtering, and bind any needed event handlers. + */ + setupGLContext: function(width, height) { + this.dispose(); + this.createWebGLCanvas(width, height); + // eslint-disable-next-line + this.aPosition = new Float32Array([0, 0, 0, 1, 1, 0, 1, 1]); + this.chooseFastestCopyGLTo2DMethod(width, height); + }, + + /** + * Pick a method to copy data from GL context to 2d canvas. In some browsers using + * putImageData is faster than drawImage for that specific operation. + */ + chooseFastestCopyGLTo2DMethod: function(width, height) { + var canMeasurePerf = typeof window.performance !== 'undefined', canUseImageData; + try { + new ImageData(1, 1); + canUseImageData = true; + } + catch (e) { + canUseImageData = false; + } + // eslint-disable-next-line no-undef + var canUseArrayBuffer = typeof ArrayBuffer !== 'undefined'; + // eslint-disable-next-line no-undef + var canUseUint8Clamped = typeof Uint8ClampedArray !== 'undefined'; + + if (!(canMeasurePerf && canUseImageData && canUseArrayBuffer && canUseUint8Clamped)) { + return; + } + + var targetCanvas = fabric.util.createCanvasElement(); + // eslint-disable-next-line no-undef + var imageBuffer = new ArrayBuffer(width * height * 4); + if (fabric.forceGLPutImageData) { + this.imageBuffer = imageBuffer; + this.copyGLTo2D = copyGLTo2DPutImageData; + return; + } + var testContext = { + imageBuffer: imageBuffer, + destinationWidth: width, + destinationHeight: height, + targetCanvas: targetCanvas + }; + var startTime, drawImageTime, putImageDataTime; + targetCanvas.width = width; + targetCanvas.height = height; + + startTime = window.performance.now(); + copyGLTo2DDrawImage.call(testContext, this.gl, testContext); + drawImageTime = window.performance.now() - startTime; + + startTime = window.performance.now(); + copyGLTo2DPutImageData.call(testContext, this.gl, testContext); + putImageDataTime = window.performance.now() - startTime; + + if (drawImageTime > putImageDataTime) { + this.imageBuffer = imageBuffer; + this.copyGLTo2D = copyGLTo2DPutImageData; + } + else { + this.copyGLTo2D = copyGLTo2DDrawImage; + } + }, + + /** + * Create a canvas element and associated WebGL context and attaches them as + * class properties to the GLFilterBackend class. + */ + createWebGLCanvas: function(width, height) { + var canvas = fabric.util.createCanvasElement(); + canvas.width = width; + canvas.height = height; + var glOptions = { + alpha: true, + premultipliedAlpha: false, + depth: false, + stencil: false, + antialias: false + }, + gl = canvas.getContext('webgl', glOptions); + if (!gl) { + gl = canvas.getContext('experimental-webgl', glOptions); + } + if (!gl) { + return; + } + gl.clearColor(0, 0, 0, 0); + // this canvas can fire webglcontextlost and webglcontextrestored + this.canvas = canvas; + this.gl = gl; + }, + + /** + * Attempts to apply the requested filters to the source provided, drawing the filtered output + * to the provided target canvas. + * + * @param {Array} filters The filters to apply. + * @param {HTMLImageElement|HTMLCanvasElement} source The source to be filtered. + * @param {Number} width The width of the source input. + * @param {Number} height The height of the source input. + * @param {HTMLCanvasElement} targetCanvas The destination for filtered output to be drawn. + * @param {String|undefined} cacheKey A key used to cache resources related to the source. If + * omitted, caching will be skipped. + */ + applyFilters: function(filters, source, width, height, targetCanvas, cacheKey) { + var gl = this.gl; + var cachedTexture; + if (cacheKey) { + cachedTexture = this.getCachedTexture(cacheKey, source); + } + var pipelineState = { + originalWidth: source.width || source.originalWidth, + originalHeight: source.height || source.originalHeight, + sourceWidth: width, + sourceHeight: height, + destinationWidth: width, + destinationHeight: height, + context: gl, + sourceTexture: this.createTexture(gl, width, height, !cachedTexture && source), + targetTexture: this.createTexture(gl, width, height), + originalTexture: cachedTexture || + this.createTexture(gl, width, height, !cachedTexture && source), + passes: filters.length, + webgl: true, + aPosition: this.aPosition, + programCache: this.programCache, + pass: 0, + filterBackend: this, + targetCanvas: targetCanvas + }; + var tempFbo = gl.createFramebuffer(); + gl.bindFramebuffer(gl.FRAMEBUFFER, tempFbo); + filters.forEach(function(filter) { filter && filter.applyTo(pipelineState); }); + resizeCanvasIfNeeded(pipelineState); + this.copyGLTo2D(gl, pipelineState); + gl.bindTexture(gl.TEXTURE_2D, null); + gl.deleteTexture(pipelineState.sourceTexture); + gl.deleteTexture(pipelineState.targetTexture); + gl.deleteFramebuffer(tempFbo); + targetCanvas.getContext('2d').setTransform(1, 0, 0, 1, 0, 0); + return pipelineState; + }, + + /** + * Detach event listeners, remove references, and clean up caches. + */ + dispose: function() { + if (this.canvas) { + this.canvas = null; + this.gl = null; + } + this.clearWebGLCaches(); + }, + + /** + * Wipe out WebGL-related caches. + */ + clearWebGLCaches: function() { + this.programCache = {}; + this.textureCache = {}; + }, + + /** + * Create a WebGL texture object. + * + * Accepts specific dimensions to initialize the texture to or a source image. + * + * @param {WebGLRenderingContext} gl The GL context to use for creating the texture. + * @param {Number} width The width to initialize the texture at. + * @param {Number} height The height to initialize the texture. + * @param {HTMLImageElement|HTMLCanvasElement} textureImageSource A source for the texture data. + * @param {Number} filterType gl.NEAREST or gl.LINEAR usually, webgl numeri constants + * @returns {WebGLTexture} + */ + createTexture: function(gl, width, height, textureImageSource, filterType) { + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filterType || gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filterType || gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + if (textureImageSource) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, textureImageSource); + } + else { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + } + return texture; + }, + + /** + * Can be optionally used to get a texture from the cache array + * + * If an existing texture is not found, a new texture is created and cached. + * + * @param {String} uniqueId A cache key to use to find an existing texture. + * @param {HTMLImageElement|HTMLCanvasElement} textureImageSource A source to use to create the + * texture cache entry if one does not already exist. + */ + getCachedTexture: function(uniqueId, textureImageSource) { + if (this.textureCache[uniqueId]) { + return this.textureCache[uniqueId]; + } + else { + var texture = this.createTexture( + this.gl, textureImageSource.width, textureImageSource.height, textureImageSource); + this.textureCache[uniqueId] = texture; + return texture; + } + }, + + /** + * Clear out cached resources related to a source image that has been + * filtered previously. + * + * @param {String} cacheKey The cache key provided when the source image was filtered. + */ + evictCachesForKey: function(cacheKey) { + if (this.textureCache[cacheKey]) { + this.gl.deleteTexture(this.textureCache[cacheKey]); + delete this.textureCache[cacheKey]; + } + }, + + copyGLTo2D: copyGLTo2DDrawImage, + + /** + * Attempt to extract GPU information strings from a WebGL context. + * + * Useful information when debugging or blacklisting specific GPUs. + * + * @returns {Object} A GPU info object with renderer and vendor strings. + */ + captureGPUInfo: function() { + if (this.gpuInfo) { + return this.gpuInfo; + } + var gl = this.gl, gpuInfo = { renderer: '', vendor: '' }; + if (!gl) { + return gpuInfo; + } + var ext = gl.getExtension('WEBGL_debug_renderer_info'); + if (ext) { + var renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL); + var vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL); + if (renderer) { + gpuInfo.renderer = renderer.toLowerCase(); + } + if (vendor) { + gpuInfo.vendor = vendor.toLowerCase(); + } + } + this.gpuInfo = gpuInfo; + return gpuInfo; + }, + }; +})(); + +function resizeCanvasIfNeeded(pipelineState) { + var targetCanvas = pipelineState.targetCanvas, + width = targetCanvas.width, height = targetCanvas.height, + dWidth = pipelineState.destinationWidth, + dHeight = pipelineState.destinationHeight; + + if (width !== dWidth || height !== dHeight) { + targetCanvas.width = dWidth; + targetCanvas.height = dHeight; + } +} + +/** + * Copy an input WebGL canvas on to an output 2D canvas. + * + * The WebGL canvas is assumed to be upside down, with the top-left pixel of the + * desired output image appearing in the bottom-left corner of the WebGL canvas. + * + * @param {WebGLRenderingContext} sourceContext The WebGL context to copy from. + * @param {HTMLCanvasElement} targetCanvas The 2D target canvas to copy on to. + * @param {Object} pipelineState The 2D target canvas to copy on to. + */ +function copyGLTo2DDrawImage(gl, pipelineState) { + var glCanvas = gl.canvas, targetCanvas = pipelineState.targetCanvas, + ctx = targetCanvas.getContext('2d'); + ctx.translate(0, targetCanvas.height); // move it down again + ctx.scale(1, -1); // vertical flip + // where is my image on the big glcanvas? + var sourceY = glCanvas.height - targetCanvas.height; + ctx.drawImage(glCanvas, 0, sourceY, targetCanvas.width, targetCanvas.height, 0, 0, + targetCanvas.width, targetCanvas.height); +} + +/** + * Copy an input WebGL canvas on to an output 2D canvas using 2d canvas' putImageData + * API. Measurably faster than using ctx.drawImage in Firefox (version 54 on OSX Sierra). + * + * @param {WebGLRenderingContext} sourceContext The WebGL context to copy from. + * @param {HTMLCanvasElement} targetCanvas The 2D target canvas to copy on to. + * @param {Object} pipelineState The 2D target canvas to copy on to. + */ +function copyGLTo2DPutImageData(gl, pipelineState) { + var targetCanvas = pipelineState.targetCanvas, ctx = targetCanvas.getContext('2d'), + dWidth = pipelineState.destinationWidth, + dHeight = pipelineState.destinationHeight, + numBytes = dWidth * dHeight * 4; + + // eslint-disable-next-line no-undef + var u8 = new Uint8Array(this.imageBuffer, 0, numBytes); + // eslint-disable-next-line no-undef + var u8Clamped = new Uint8ClampedArray(this.imageBuffer, 0, numBytes); + + gl.readPixels(0, 0, dWidth, dHeight, gl.RGBA, gl.UNSIGNED_BYTE, u8); + var imgData = new ImageData(u8Clamped, dWidth, dHeight); + ctx.putImageData(imgData, 0, 0); +} + + +(function() { + + 'use strict'; + + var noop = function() {}; + + fabric.Canvas2dFilterBackend = Canvas2dFilterBackend; + + /** + * Canvas 2D filter backend. + */ + function Canvas2dFilterBackend() {}; + + Canvas2dFilterBackend.prototype = /** @lends fabric.Canvas2dFilterBackend.prototype */ { + evictCachesForKey: noop, + dispose: noop, + clearWebGLCaches: noop, + + /** + * Experimental. This object is a sort of repository of help layers used to avoid + * of recreating them during frequent filtering. If you are previewing a filter with + * a slider you probably do not want to create help layers every filter step. + * in this object there will be appended some canvases, created once, resized sometimes + * cleared never. Clearing is left to the developer. + **/ + resources: { + + }, + + /** + * Apply a set of filters against a source image and draw the filtered output + * to the provided destination canvas. + * + * @param {EnhancedFilter} filters The filter to apply. + * @param {HTMLImageElement|HTMLCanvasElement} sourceElement The source to be filtered. + * @param {Number} sourceWidth The width of the source input. + * @param {Number} sourceHeight The height of the source input. + * @param {HTMLCanvasElement} targetCanvas The destination for filtered output to be drawn. + */ + applyFilters: function(filters, sourceElement, sourceWidth, sourceHeight, targetCanvas) { + var ctx = targetCanvas.getContext('2d'); + ctx.drawImage(sourceElement, 0, 0, sourceWidth, sourceHeight); + var imageData = ctx.getImageData(0, 0, sourceWidth, sourceHeight); + var originalImageData = ctx.getImageData(0, 0, sourceWidth, sourceHeight); + var pipelineState = { + sourceWidth: sourceWidth, + sourceHeight: sourceHeight, + imageData: imageData, + originalEl: sourceElement, + originalImageData: originalImageData, + canvasEl: targetCanvas, + ctx: ctx, + filterBackend: this, + }; + filters.forEach(function(filter) { filter.applyTo(pipelineState); }); + if (pipelineState.imageData.width !== sourceWidth || pipelineState.imageData.height !== sourceHeight) { + targetCanvas.width = pipelineState.imageData.width; + targetCanvas.height = pipelineState.imageData.height; + } + ctx.putImageData(pipelineState.imageData, 0, 0); + return pipelineState; + }, + + }; +})(); + + +/** + * @namespace fabric.Image.filters + * @memberOf fabric.Image + * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#image_filters} + * @see {@link http://fabricjs.com/image-filters|ImageFilters demo} + */ +fabric.Image = fabric.Image || { }; +fabric.Image.filters = fabric.Image.filters || { }; + +/** + * Root filter class from which all filter classes inherit from + * @class fabric.Image.filters.BaseFilter + * @memberOf fabric.Image.filters + */ +fabric.Image.filters.BaseFilter = fabric.util.createClass(/** @lends fabric.Image.filters.BaseFilter.prototype */ { + + /** + * Filter type + * @param {String} type + * @default + */ + type: 'BaseFilter', + + /** + * Array of attributes to send with buffers. do not modify + * @private + */ + + vertexSource: 'attribute vec2 aPosition;\n' + + 'varying vec2 vTexCoord;\n' + + 'void main() {\n' + + 'vTexCoord = aPosition;\n' + + 'gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n' + + '}', + + fragmentSource: 'precision highp float;\n' + + 'varying vec2 vTexCoord;\n' + + 'uniform sampler2D uTexture;\n' + + 'void main() {\n' + + 'gl_FragColor = texture2D(uTexture, vTexCoord);\n' + + '}', + + /** + * Constructor + * @param {Object} [options] Options object + */ + initialize: function(options) { + if (options) { + this.setOptions(options); + } + }, + + /** + * Sets filter's properties from options + * @param {Object} [options] Options object + */ + setOptions: function(options) { + for (var prop in options) { + this[prop] = options[prop]; + } + }, + + /** + * Compile this filter's shader program. + * + * @param {WebGLRenderingContext} gl The GL canvas context to use for shader compilation. + * @param {String} fragmentSource fragmentShader source for compilation + * @param {String} vertexSource vertexShader source for compilation + */ + createProgram: function(gl, fragmentSource, vertexSource) { + fragmentSource = fragmentSource || this.fragmentSource; + vertexSource = vertexSource || this.vertexSource; + if (fabric.webGlPrecision !== 'highp'){ + fragmentSource = fragmentSource.replace( + /precision highp float/g, + 'precision ' + fabric.webGlPrecision + ' float' + ); + } + var vertexShader = gl.createShader(gl.VERTEX_SHADER); + gl.shaderSource(vertexShader, vertexSource); + gl.compileShader(vertexShader); + if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) { + throw new Error( + // eslint-disable-next-line prefer-template + 'Vertex shader compile error for ' + this.type + ': ' + + gl.getShaderInfoLog(vertexShader) + ); + } + + var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); + gl.shaderSource(fragmentShader, fragmentSource); + gl.compileShader(fragmentShader); + if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) { + throw new Error( + // eslint-disable-next-line prefer-template + 'Fragment shader compile error for ' + this.type + ': ' + + gl.getShaderInfoLog(fragmentShader) + ); + } + + var program = gl.createProgram(); + gl.attachShader(program, vertexShader); + gl.attachShader(program, fragmentShader); + gl.linkProgram(program); + if (!gl.getProgramParameter(program, gl.LINK_STATUS)) { + throw new Error( + // eslint-disable-next-line prefer-template + 'Shader link error for "${this.type}" ' + + gl.getProgramInfoLog(program) + ); + } + + var attributeLocations = this.getAttributeLocations(gl, program); + var uniformLocations = this.getUniformLocations(gl, program) || { }; + uniformLocations.uStepW = gl.getUniformLocation(program, 'uStepW'); + uniformLocations.uStepH = gl.getUniformLocation(program, 'uStepH'); + return { + program: program, + attributeLocations: attributeLocations, + uniformLocations: uniformLocations + }; + }, + + /** + * Return a map of attribute names to WebGLAttributeLocation objects. + * + * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program. + * @param {WebGLShaderProgram} program The shader program from which to take attribute locations. + * @returns {Object} A map of attribute names to attribute locations. + */ + getAttributeLocations: function(gl, program) { + return { + aPosition: gl.getAttribLocation(program, 'aPosition'), + }; + }, + + /** + * Return a map of uniform names to WebGLUniformLocation objects. + * + * Intended to be overridden by subclasses. + * + * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program. + * @param {WebGLShaderProgram} program The shader program from which to take uniform locations. + * @returns {Object} A map of uniform names to uniform locations. + */ + getUniformLocations: function (/* gl, program */) { + // in case i do not need any special uniform i need to return an empty object + return { }; + }, + + /** + * Send attribute data from this filter to its shader program on the GPU. + * + * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program. + * @param {Object} attributeLocations A map of shader attribute names to their locations. + */ + sendAttributeData: function(gl, attributeLocations, aPositionData) { + var attributeLocation = attributeLocations.aPosition; + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.enableVertexAttribArray(attributeLocation); + gl.vertexAttribPointer(attributeLocation, 2, gl.FLOAT, false, 0, 0); + gl.bufferData(gl.ARRAY_BUFFER, aPositionData, gl.STATIC_DRAW); + }, + + _setupFrameBuffer: function(options) { + var gl = options.context, width, height; + if (options.passes > 1) { + width = options.destinationWidth; + height = options.destinationHeight; + if (options.sourceWidth !== width || options.sourceHeight !== height) { + gl.deleteTexture(options.targetTexture); + options.targetTexture = options.filterBackend.createTexture(gl, width, height); + } + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, + options.targetTexture, 0); + } + else { + // draw last filter on canvas and not to framebuffer. + gl.bindFramebuffer(gl.FRAMEBUFFER, null); + gl.finish(); + } + }, + + _swapTextures: function(options) { + options.passes--; + options.pass++; + var temp = options.targetTexture; + options.targetTexture = options.sourceTexture; + options.sourceTexture = temp; + }, + + /** + * Generic isNeutral implementation for one parameter based filters. + * Used only in image applyFilters to discard filters that will not have an effect + * on the image + * Other filters may need their own version ( ColorMatrix, HueRotation, gamma, ComposedFilter ) + * @param {Object} options + **/ + isNeutralState: function(/* options */) { + var main = this.mainParameter, + _class = fabric.Image.filters[this.type].prototype; + if (main) { + if (Array.isArray(_class[main])) { + for (var i = _class[main].length; i--;) { + if (this[main][i] !== _class[main][i]) { + return false; + } + } + return true; + } + else { + return _class[main] === this[main]; + } + } + else { + return false; + } + }, + + /** + * Apply this filter to the input image data provided. + * + * Determines whether to use WebGL or Canvas2D based on the options.webgl flag. + * + * @param {Object} options + * @param {Number} options.passes The number of filters remaining to be executed + * @param {Boolean} options.webgl Whether to use webgl to render the filter. + * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered. + * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn. + * @param {WebGLRenderingContext} options.context The GL context used for rendering. + * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type. + */ + applyTo: function(options) { + if (options.webgl) { + this._setupFrameBuffer(options); + this.applyToWebGL(options); + this._swapTextures(options); + } + else { + this.applyTo2d(options); + } + }, + + /** + * Retrieves the cached shader. + * @param {Object} options + * @param {WebGLRenderingContext} options.context The GL context used for rendering. + * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type. + */ + retrieveShader: function(options) { + if (!options.programCache.hasOwnProperty(this.type)) { + options.programCache[this.type] = this.createProgram(options.context); + } + return options.programCache[this.type]; + }, + + /** + * Apply this filter using webgl. + * + * @param {Object} options + * @param {Number} options.passes The number of filters remaining to be executed + * @param {Boolean} options.webgl Whether to use webgl to render the filter. + * @param {WebGLTexture} options.originalTexture The texture of the original input image. + * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered. + * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn. + * @param {WebGLRenderingContext} options.context The GL context used for rendering. + * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type. + */ + applyToWebGL: function(options) { + var gl = options.context; + var shader = this.retrieveShader(options); + if (options.pass === 0 && options.originalTexture) { + gl.bindTexture(gl.TEXTURE_2D, options.originalTexture); + } + else { + gl.bindTexture(gl.TEXTURE_2D, options.sourceTexture); + } + gl.useProgram(shader.program); + this.sendAttributeData(gl, shader.attributeLocations, options.aPosition); + + gl.uniform1f(shader.uniformLocations.uStepW, 1 / options.sourceWidth); + gl.uniform1f(shader.uniformLocations.uStepH, 1 / options.sourceHeight); + + this.sendUniformData(gl, shader.uniformLocations); + gl.viewport(0, 0, options.destinationWidth, options.destinationHeight); + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + }, + + bindAdditionalTexture: function(gl, texture, textureUnit) { + gl.activeTexture(textureUnit); + gl.bindTexture(gl.TEXTURE_2D, texture); + // reset active texture to 0 as usual + gl.activeTexture(gl.TEXTURE0); + }, + + unbindAdditionalTexture: function(gl, textureUnit) { + gl.activeTexture(textureUnit); + gl.bindTexture(gl.TEXTURE_2D, null); + gl.activeTexture(gl.TEXTURE0); + }, + + getMainParameter: function() { + return this[this.mainParameter]; + }, + + setMainParameter: function(value) { + this[this.mainParameter] = value; + }, + + /** + * Send uniform data from this filter to its shader program on the GPU. + * + * Intended to be overridden by subclasses. + * + * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program. + * @param {Object} uniformLocations A map of shader uniform names to their locations. + */ + sendUniformData: function(/* gl, uniformLocations */) { + // Intentionally left blank. Override me in subclasses. + }, + + /** + * If needed by a 2d filter, this functions can create an helper canvas to be used + * remember that options.targetCanvas is available for use till end of chain. + */ + createHelpLayer: function(options) { + if (!options.helpLayer) { + var helpLayer = document.createElement('canvas'); + helpLayer.width = options.sourceWidth; + helpLayer.height = options.sourceHeight; + options.helpLayer = helpLayer; + } + }, + + /** + * Returns object representation of an instance + * @return {Object} Object representation of an instance + */ + toObject: function() { + var object = { type: this.type }, mainP = this.mainParameter; + if (mainP) { + object[mainP] = this[mainP]; + } + return object; + }, + + /** + * Returns a JSON representation of an instance + * @return {Object} JSON + */ + toJSON: function() { + // delegate, not alias + return this.toObject(); + } +}); + +fabric.Image.filters.BaseFilter.fromObject = function(object, callback) { + var filter = new fabric.Image.filters[object.type](object); + callback && callback(filter); + return filter; +}; + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + filters = fabric.Image.filters, + createClass = fabric.util.createClass; + + /** + * Color Matrix filter class + * @class fabric.Image.filters.ColorMatrix + * @memberOf fabric.Image.filters + * @extends fabric.Image.filters.BaseFilter + * @see {@link fabric.Image.filters.ColorMatrix#initialize} for constructor definition + * @see {@link http://fabricjs.com/image-filters|ImageFilters demo} + * @see {@Link http://www.webwasp.co.uk/tutorials/219/Color_Matrix_Filter.php} + * @see {@Link http://phoboslab.org/log/2013/11/fast-image-filters-with-webgl} + * @example Kodachrome filter + * var filter = new fabric.Image.filters.ColorMatrix({ + * matrix: [ + 1.1285582396593525, -0.3967382283601348, -0.03992559172921793, 0, 63.72958762196502, + -0.16404339962244616, 1.0835251566291304, -0.05498805115633132, 0, 24.732407896706203, + -0.16786010706155763, -0.5603416277695248, 1.6014850761964943, 0, 35.62982807460946, + 0, 0, 0, 1, 0 + ] + * }); + * object.filters.push(filter); + * object.applyFilters(); + */ + filters.ColorMatrix = createClass(filters.BaseFilter, /** @lends fabric.Image.filters.ColorMatrix.prototype */ { + + /** + * Filter type + * @param {String} type + * @default + */ + type: 'ColorMatrix', + + fragmentSource: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'varying vec2 vTexCoord;\n' + + 'uniform mat4 uColorMatrix;\n' + + 'uniform vec4 uConstants;\n' + + 'void main() {\n' + + 'vec4 color = texture2D(uTexture, vTexCoord);\n' + + 'color *= uColorMatrix;\n' + + 'color += uConstants;\n' + + 'gl_FragColor = color;\n' + + '}', + + /** + * Colormatrix for pixels. + * array of 20 floats. Numbers in positions 4, 9, 14, 19 loose meaning + * outside the -1, 1 range. + * 0.0039215686 is the part of 1 that get translated to 1 in 2d + * @param {Array} matrix array of 20 numbers. + * @default + */ + matrix: [ + 1, 0, 0, 0, 0, + 0, 1, 0, 0, 0, + 0, 0, 1, 0, 0, + 0, 0, 0, 1, 0 + ], + + mainParameter: 'matrix', + + /** + * Lock the colormatrix on the color part, skipping alpha, mainly for non webgl scenario + * to save some calculation + * @type Boolean + * @default true + */ + colorsOnly: true, + + /** + * Constructor + * @param {Object} [options] Options object + */ + initialize: function(options) { + this.callSuper('initialize', options); + // create a new array instead mutating the prototype with push + this.matrix = this.matrix.slice(0); + }, + + /** + * Apply the ColorMatrix operation to a Uint8Array representing the pixels of an image. + * + * @param {Object} options + * @param {ImageData} options.imageData The Uint8Array to be filtered. + */ + applyTo2d: function(options) { + var imageData = options.imageData, + data = imageData.data, + iLen = data.length, + m = this.matrix, + r, g, b, a, i, colorsOnly = this.colorsOnly; + + for (i = 0; i < iLen; i += 4) { + r = data[i]; + g = data[i + 1]; + b = data[i + 2]; + if (colorsOnly) { + data[i] = r * m[0] + g * m[1] + b * m[2] + m[4] * 255; + data[i + 1] = r * m[5] + g * m[6] + b * m[7] + m[9] * 255; + data[i + 2] = r * m[10] + g * m[11] + b * m[12] + m[14] * 255; + } + else { + a = data[i + 3]; + data[i] = r * m[0] + g * m[1] + b * m[2] + a * m[3] + m[4] * 255; + data[i + 1] = r * m[5] + g * m[6] + b * m[7] + a * m[8] + m[9] * 255; + data[i + 2] = r * m[10] + g * m[11] + b * m[12] + a * m[13] + m[14] * 255; + data[i + 3] = r * m[15] + g * m[16] + b * m[17] + a * m[18] + m[19] * 255; + } + } + }, + + /** + * Return WebGL uniform locations for this filter's shader. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {WebGLShaderProgram} program This filter's compiled shader program. + */ + getUniformLocations: function(gl, program) { + return { + uColorMatrix: gl.getUniformLocation(program, 'uColorMatrix'), + uConstants: gl.getUniformLocation(program, 'uConstants'), + }; + }, + + /** + * Send data from this filter to its shader program's uniforms. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects + */ + sendUniformData: function(gl, uniformLocations) { + var m = this.matrix, + matrix = [ + m[0], m[1], m[2], m[3], + m[5], m[6], m[7], m[8], + m[10], m[11], m[12], m[13], + m[15], m[16], m[17], m[18] + ], + constants = [m[4], m[9], m[14], m[19]]; + gl.uniformMatrix4fv(uniformLocations.uColorMatrix, false, matrix); + gl.uniform4fv(uniformLocations.uConstants, constants); + }, + }); + + /** + * Returns filter instance from an object representation + * @static + * @param {Object} object Object to create an instance from + * @param {function} [callback] function to invoke after filter creation + * @return {fabric.Image.filters.ColorMatrix} Instance of fabric.Image.filters.ColorMatrix + */ + fabric.Image.filters.ColorMatrix.fromObject = fabric.Image.filters.BaseFilter.fromObject; +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + filters = fabric.Image.filters, + createClass = fabric.util.createClass; + + /** + * Brightness filter class + * @class fabric.Image.filters.Brightness + * @memberOf fabric.Image.filters + * @extends fabric.Image.filters.BaseFilter + * @see {@link fabric.Image.filters.Brightness#initialize} for constructor definition + * @see {@link http://fabricjs.com/image-filters|ImageFilters demo} + * @example + * var filter = new fabric.Image.filters.Brightness({ + * brightness: 0.05 + * }); + * object.filters.push(filter); + * object.applyFilters(); + */ + filters.Brightness = createClass(filters.BaseFilter, /** @lends fabric.Image.filters.Brightness.prototype */ { + + /** + * Filter type + * @param {String} type + * @default + */ + type: 'Brightness', + + /** + * Fragment source for the brightness program + */ + fragmentSource: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform float uBrightness;\n' + + 'varying vec2 vTexCoord;\n' + + 'void main() {\n' + + 'vec4 color = texture2D(uTexture, vTexCoord);\n' + + 'color.rgb += uBrightness;\n' + + 'gl_FragColor = color;\n' + + '}', + + /** + * Brightness value, from -1 to 1. + * translated to -255 to 255 for 2d + * 0.0039215686 is the part of 1 that get translated to 1 in 2d + * @param {Number} brightness + * @default + */ + brightness: 0, + + /** + * Describe the property that is the filter parameter + * @param {String} m + * @default + */ + mainParameter: 'brightness', + + /** + * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image. + * + * @param {Object} options + * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered. + */ + applyTo2d: function(options) { + if (this.brightness === 0) { + return; + } + var imageData = options.imageData, + data = imageData.data, i, len = data.length, + brightness = Math.round(this.brightness * 255); + for (i = 0; i < len; i += 4) { + data[i] = data[i] + brightness; + data[i + 1] = data[i + 1] + brightness; + data[i + 2] = data[i + 2] + brightness; + } + }, + + /** + * Return WebGL uniform locations for this filter's shader. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {WebGLShaderProgram} program This filter's compiled shader program. + */ + getUniformLocations: function(gl, program) { + return { + uBrightness: gl.getUniformLocation(program, 'uBrightness'), + }; + }, + + /** + * Send data from this filter to its shader program's uniforms. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects + */ + sendUniformData: function(gl, uniformLocations) { + gl.uniform1f(uniformLocations.uBrightness, this.brightness); + }, + }); + + /** + * Returns filter instance from an object representation + * @static + * @param {Object} object Object to create an instance from + * @param {function} [callback] to be invoked after filter creation + * @return {fabric.Image.filters.Brightness} Instance of fabric.Image.filters.Brightness + */ + fabric.Image.filters.Brightness.fromObject = fabric.Image.filters.BaseFilter.fromObject; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + extend = fabric.util.object.extend, + filters = fabric.Image.filters, + createClass = fabric.util.createClass; + + /** + * Adapted from html5rocks article + * @class fabric.Image.filters.Convolute + * @memberOf fabric.Image.filters + * @extends fabric.Image.filters.BaseFilter + * @see {@link fabric.Image.filters.Convolute#initialize} for constructor definition + * @see {@link http://fabricjs.com/image-filters|ImageFilters demo} + * @example Sharpen filter + * var filter = new fabric.Image.filters.Convolute({ + * matrix: [ 0, -1, 0, + * -1, 5, -1, + * 0, -1, 0 ] + * }); + * object.filters.push(filter); + * object.applyFilters(); + * canvas.renderAll(); + * @example Blur filter + * var filter = new fabric.Image.filters.Convolute({ + * matrix: [ 1/9, 1/9, 1/9, + * 1/9, 1/9, 1/9, + * 1/9, 1/9, 1/9 ] + * }); + * object.filters.push(filter); + * object.applyFilters(); + * canvas.renderAll(); + * @example Emboss filter + * var filter = new fabric.Image.filters.Convolute({ + * matrix: [ 1, 1, 1, + * 1, 0.7, -1, + * -1, -1, -1 ] + * }); + * object.filters.push(filter); + * object.applyFilters(); + * canvas.renderAll(); + * @example Emboss filter with opaqueness + * var filter = new fabric.Image.filters.Convolute({ + * opaque: true, + * matrix: [ 1, 1, 1, + * 1, 0.7, -1, + * -1, -1, -1 ] + * }); + * object.filters.push(filter); + * object.applyFilters(); + * canvas.renderAll(); + */ + filters.Convolute = createClass(filters.BaseFilter, /** @lends fabric.Image.filters.Convolute.prototype */ { + + /** + * Filter type + * @param {String} type + * @default + */ + type: 'Convolute', + + /* + * Opaque value (true/false) + */ + opaque: false, + + /* + * matrix for the filter, max 9x9 + */ + matrix: [0, 0, 0, 0, 1, 0, 0, 0, 0], + + /** + * Fragment source for the brightness program + */ + fragmentSource: { + Convolute_3_1: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform float uMatrix[9];\n' + + 'uniform float uStepW;\n' + + 'uniform float uStepH;\n' + + 'varying vec2 vTexCoord;\n' + + 'void main() {\n' + + 'vec4 color = vec4(0, 0, 0, 0);\n' + + 'for (float h = 0.0; h < 3.0; h+=1.0) {\n' + + 'for (float w = 0.0; w < 3.0; w+=1.0) {\n' + + 'vec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));\n' + + 'color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];\n' + + '}\n' + + '}\n' + + 'gl_FragColor = color;\n' + + '}', + Convolute_3_0: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform float uMatrix[9];\n' + + 'uniform float uStepW;\n' + + 'uniform float uStepH;\n' + + 'varying vec2 vTexCoord;\n' + + 'void main() {\n' + + 'vec4 color = vec4(0, 0, 0, 1);\n' + + 'for (float h = 0.0; h < 3.0; h+=1.0) {\n' + + 'for (float w = 0.0; w < 3.0; w+=1.0) {\n' + + 'vec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));\n' + + 'color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];\n' + + '}\n' + + '}\n' + + 'float alpha = texture2D(uTexture, vTexCoord).a;\n' + + 'gl_FragColor = color;\n' + + 'gl_FragColor.a = alpha;\n' + + '}', + Convolute_5_1: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform float uMatrix[25];\n' + + 'uniform float uStepW;\n' + + 'uniform float uStepH;\n' + + 'varying vec2 vTexCoord;\n' + + 'void main() {\n' + + 'vec4 color = vec4(0, 0, 0, 0);\n' + + 'for (float h = 0.0; h < 5.0; h+=1.0) {\n' + + 'for (float w = 0.0; w < 5.0; w+=1.0) {\n' + + 'vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\n' + + 'color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];\n' + + '}\n' + + '}\n' + + 'gl_FragColor = color;\n' + + '}', + Convolute_5_0: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform float uMatrix[25];\n' + + 'uniform float uStepW;\n' + + 'uniform float uStepH;\n' + + 'varying vec2 vTexCoord;\n' + + 'void main() {\n' + + 'vec4 color = vec4(0, 0, 0, 1);\n' + + 'for (float h = 0.0; h < 5.0; h+=1.0) {\n' + + 'for (float w = 0.0; w < 5.0; w+=1.0) {\n' + + 'vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\n' + + 'color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];\n' + + '}\n' + + '}\n' + + 'float alpha = texture2D(uTexture, vTexCoord).a;\n' + + 'gl_FragColor = color;\n' + + 'gl_FragColor.a = alpha;\n' + + '}', + Convolute_7_1: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform float uMatrix[49];\n' + + 'uniform float uStepW;\n' + + 'uniform float uStepH;\n' + + 'varying vec2 vTexCoord;\n' + + 'void main() {\n' + + 'vec4 color = vec4(0, 0, 0, 0);\n' + + 'for (float h = 0.0; h < 7.0; h+=1.0) {\n' + + 'for (float w = 0.0; w < 7.0; w+=1.0) {\n' + + 'vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\n' + + 'color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];\n' + + '}\n' + + '}\n' + + 'gl_FragColor = color;\n' + + '}', + Convolute_7_0: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform float uMatrix[49];\n' + + 'uniform float uStepW;\n' + + 'uniform float uStepH;\n' + + 'varying vec2 vTexCoord;\n' + + 'void main() {\n' + + 'vec4 color = vec4(0, 0, 0, 1);\n' + + 'for (float h = 0.0; h < 7.0; h+=1.0) {\n' + + 'for (float w = 0.0; w < 7.0; w+=1.0) {\n' + + 'vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\n' + + 'color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];\n' + + '}\n' + + '}\n' + + 'float alpha = texture2D(uTexture, vTexCoord).a;\n' + + 'gl_FragColor = color;\n' + + 'gl_FragColor.a = alpha;\n' + + '}', + Convolute_9_1: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform float uMatrix[81];\n' + + 'uniform float uStepW;\n' + + 'uniform float uStepH;\n' + + 'varying vec2 vTexCoord;\n' + + 'void main() {\n' + + 'vec4 color = vec4(0, 0, 0, 0);\n' + + 'for (float h = 0.0; h < 9.0; h+=1.0) {\n' + + 'for (float w = 0.0; w < 9.0; w+=1.0) {\n' + + 'vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\n' + + 'color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];\n' + + '}\n' + + '}\n' + + 'gl_FragColor = color;\n' + + '}', + Convolute_9_0: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform float uMatrix[81];\n' + + 'uniform float uStepW;\n' + + 'uniform float uStepH;\n' + + 'varying vec2 vTexCoord;\n' + + 'void main() {\n' + + 'vec4 color = vec4(0, 0, 0, 1);\n' + + 'for (float h = 0.0; h < 9.0; h+=1.0) {\n' + + 'for (float w = 0.0; w < 9.0; w+=1.0) {\n' + + 'vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\n' + + 'color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];\n' + + '}\n' + + '}\n' + + 'float alpha = texture2D(uTexture, vTexCoord).a;\n' + + 'gl_FragColor = color;\n' + + 'gl_FragColor.a = alpha;\n' + + '}', + }, + + /** + * Constructor + * @memberOf fabric.Image.filters.Convolute.prototype + * @param {Object} [options] Options object + * @param {Boolean} [options.opaque=false] Opaque value (true/false) + * @param {Array} [options.matrix] Filter matrix + */ + + + /** + * Retrieves the cached shader. + * @param {Object} options + * @param {WebGLRenderingContext} options.context The GL context used for rendering. + * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type. + */ + retrieveShader: function(options) { + var size = Math.sqrt(this.matrix.length); + var cacheKey = this.type + '_' + size + '_' + (this.opaque ? 1 : 0); + var shaderSource = this.fragmentSource[cacheKey]; + if (!options.programCache.hasOwnProperty(cacheKey)) { + options.programCache[cacheKey] = this.createProgram(options.context, shaderSource); + } + return options.programCache[cacheKey]; + }, + + /** + * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image. + * + * @param {Object} options + * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered. + */ + applyTo2d: function(options) { + var imageData = options.imageData, + data = imageData.data, + weights = this.matrix, + side = Math.round(Math.sqrt(weights.length)), + halfSide = Math.floor(side / 2), + sw = imageData.width, + sh = imageData.height, + output = options.ctx.createImageData(sw, sh), + dst = output.data, + // go through the destination image pixels + alphaFac = this.opaque ? 1 : 0, + r, g, b, a, dstOff, + scx, scy, srcOff, wt, + x, y, cx, cy; + + for (y = 0; y < sh; y++) { + for (x = 0; x < sw; x++) { + dstOff = (y * sw + x) * 4; + // calculate the weighed sum of the source image pixels that + // fall under the convolution matrix + r = 0; g = 0; b = 0; a = 0; + + for (cy = 0; cy < side; cy++) { + for (cx = 0; cx < side; cx++) { + scy = y + cy - halfSide; + scx = x + cx - halfSide; + + // eslint-disable-next-line max-depth + if (scy < 0 || scy >= sh || scx < 0 || scx >= sw) { + continue; + } + + srcOff = (scy * sw + scx) * 4; + wt = weights[cy * side + cx]; + + r += data[srcOff] * wt; + g += data[srcOff + 1] * wt; + b += data[srcOff + 2] * wt; + // eslint-disable-next-line max-depth + if (!alphaFac) { + a += data[srcOff + 3] * wt; + } + } + } + dst[dstOff] = r; + dst[dstOff + 1] = g; + dst[dstOff + 2] = b; + if (!alphaFac) { + dst[dstOff + 3] = a; + } + else { + dst[dstOff + 3] = data[dstOff + 3]; + } + } + } + options.imageData = output; + }, + + /** + * Return WebGL uniform locations for this filter's shader. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {WebGLShaderProgram} program This filter's compiled shader program. + */ + getUniformLocations: function(gl, program) { + return { + uMatrix: gl.getUniformLocation(program, 'uMatrix'), + uOpaque: gl.getUniformLocation(program, 'uOpaque'), + uHalfSize: gl.getUniformLocation(program, 'uHalfSize'), + uSize: gl.getUniformLocation(program, 'uSize'), + }; + }, + + /** + * Send data from this filter to its shader program's uniforms. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects + */ + sendUniformData: function(gl, uniformLocations) { + gl.uniform1fv(uniformLocations.uMatrix, this.matrix); + }, + + /** + * Returns object representation of an instance + * @return {Object} Object representation of an instance + */ + toObject: function() { + return extend(this.callSuper('toObject'), { + opaque: this.opaque, + matrix: this.matrix + }); + } + }); + + /** + * Returns filter instance from an object representation + * @static + * @param {Object} object Object to create an instance from + * @param {function} [callback] to be invoked after filter creation + * @return {fabric.Image.filters.Convolute} Instance of fabric.Image.filters.Convolute + */ + fabric.Image.filters.Convolute.fromObject = fabric.Image.filters.BaseFilter.fromObject; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + filters = fabric.Image.filters, + createClass = fabric.util.createClass; + + /** + * Grayscale image filter class + * @class fabric.Image.filters.Grayscale + * @memberOf fabric.Image.filters + * @extends fabric.Image.filters.BaseFilter + * @see {@link http://fabricjs.com/image-filters|ImageFilters demo} + * @example + * var filter = new fabric.Image.filters.Grayscale(); + * object.filters.push(filter); + * object.applyFilters(); + */ + filters.Grayscale = createClass(filters.BaseFilter, /** @lends fabric.Image.filters.Grayscale.prototype */ { + + /** + * Filter type + * @param {String} type + * @default + */ + type: 'Grayscale', + + fragmentSource: { + average: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'varying vec2 vTexCoord;\n' + + 'void main() {\n' + + 'vec4 color = texture2D(uTexture, vTexCoord);\n' + + 'float average = (color.r + color.b + color.g) / 3.0;\n' + + 'gl_FragColor = vec4(average, average, average, color.a);\n' + + '}', + lightness: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform int uMode;\n' + + 'varying vec2 vTexCoord;\n' + + 'void main() {\n' + + 'vec4 col = texture2D(uTexture, vTexCoord);\n' + + 'float average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;\n' + + 'gl_FragColor = vec4(average, average, average, col.a);\n' + + '}', + luminosity: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform int uMode;\n' + + 'varying vec2 vTexCoord;\n' + + 'void main() {\n' + + 'vec4 col = texture2D(uTexture, vTexCoord);\n' + + 'float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;\n' + + 'gl_FragColor = vec4(average, average, average, col.a);\n' + + '}', + }, + + + /** + * Grayscale mode, between 'average', 'lightness', 'luminosity' + * @param {String} type + * @default + */ + mode: 'average', + + mainParameter: 'mode', + + /** + * Apply the Grayscale operation to a Uint8Array representing the pixels of an image. + * + * @param {Object} options + * @param {ImageData} options.imageData The Uint8Array to be filtered. + */ + applyTo2d: function(options) { + var imageData = options.imageData, + data = imageData.data, i, + len = data.length, value, + mode = this.mode; + for (i = 0; i < len; i += 4) { + if (mode === 'average') { + value = (data[i] + data[i + 1] + data[i + 2]) / 3; + } + else if (mode === 'lightness') { + value = (Math.min(data[i], data[i + 1], data[i + 2]) + + Math.max(data[i], data[i + 1], data[i + 2])) / 2; + } + else if (mode === 'luminosity') { + value = 0.21 * data[i] + 0.72 * data[i + 1] + 0.07 * data[i + 2]; + } + data[i] = value; + data[i + 1] = value; + data[i + 2] = value; + } + }, + + /** + * Retrieves the cached shader. + * @param {Object} options + * @param {WebGLRenderingContext} options.context The GL context used for rendering. + * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type. + */ + retrieveShader: function(options) { + var cacheKey = this.type + '_' + this.mode; + if (!options.programCache.hasOwnProperty(cacheKey)) { + var shaderSource = this.fragmentSource[this.mode]; + options.programCache[cacheKey] = this.createProgram(options.context, shaderSource); + } + return options.programCache[cacheKey]; + }, + + /** + * Return WebGL uniform locations for this filter's shader. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {WebGLShaderProgram} program This filter's compiled shader program. + */ + getUniformLocations: function(gl, program) { + return { + uMode: gl.getUniformLocation(program, 'uMode'), + }; + }, + + /** + * Send data from this filter to its shader program's uniforms. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects + */ + sendUniformData: function(gl, uniformLocations) { + // default average mode. + var mode = 1; + gl.uniform1i(uniformLocations.uMode, mode); + }, + + /** + * Grayscale filter isNeutralState implementation + * The filter is never neutral + * on the image + **/ + isNeutralState: function() { + return false; + }, + }); + + /** + * Returns filter instance from an object representation + * @static + * @param {Object} object Object to create an instance from + * @param {function} [callback] to be invoked after filter creation + * @return {fabric.Image.filters.Grayscale} Instance of fabric.Image.filters.Grayscale + */ + fabric.Image.filters.Grayscale.fromObject = fabric.Image.filters.BaseFilter.fromObject; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + filters = fabric.Image.filters, + createClass = fabric.util.createClass; + + /** + * Invert filter class + * @class fabric.Image.filters.Invert + * @memberOf fabric.Image.filters + * @extends fabric.Image.filters.BaseFilter + * @see {@link http://fabricjs.com/image-filters|ImageFilters demo} + * @example + * var filter = new fabric.Image.filters.Invert(); + * object.filters.push(filter); + * object.applyFilters(canvas.renderAll.bind(canvas)); + */ + filters.Invert = createClass(filters.BaseFilter, /** @lends fabric.Image.filters.Invert.prototype */ { + + /** + * Filter type + * @param {String} type + * @default + */ + type: 'Invert', + + fragmentSource: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform int uInvert;\n' + + 'varying vec2 vTexCoord;\n' + + 'void main() {\n' + + 'vec4 color = texture2D(uTexture, vTexCoord);\n' + + 'if (uInvert == 1) {\n' + + 'gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);\n' + + '} else {\n' + + 'gl_FragColor = color;\n' + + '}\n' + + '}', + + /** + * Filter invert. if false, does nothing + * @param {Boolean} invert + * @default + */ + invert: true, + + mainParameter: 'invert', + + /** + * Apply the Invert operation to a Uint8Array representing the pixels of an image. + * + * @param {Object} options + * @param {ImageData} options.imageData The Uint8Array to be filtered. + */ + applyTo2d: function(options) { + var imageData = options.imageData, + data = imageData.data, i, + len = data.length; + for (i = 0; i < len; i += 4) { + data[i] = 255 - data[i]; + data[i + 1] = 255 - data[i + 1]; + data[i + 2] = 255 - data[i + 2]; + } + }, + + /** + * Invert filter isNeutralState implementation + * Used only in image applyFilters to discard filters that will not have an effect + * on the image + * @param {Object} options + **/ + isNeutralState: function() { + return !this.invert; + }, + + /** + * Return WebGL uniform locations for this filter's shader. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {WebGLShaderProgram} program This filter's compiled shader program. + */ + getUniformLocations: function(gl, program) { + return { + uInvert: gl.getUniformLocation(program, 'uInvert'), + }; + }, + + /** + * Send data from this filter to its shader program's uniforms. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects + */ + sendUniformData: function(gl, uniformLocations) { + gl.uniform1i(uniformLocations.uInvert, this.invert); + }, + }); + + /** + * Returns filter instance from an object representation + * @static + * @param {Object} object Object to create an instance from + * @param {function} [callback] to be invoked after filter creation + * @return {fabric.Image.filters.Invert} Instance of fabric.Image.filters.Invert + */ + fabric.Image.filters.Invert.fromObject = fabric.Image.filters.BaseFilter.fromObject; + + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + extend = fabric.util.object.extend, + filters = fabric.Image.filters, + createClass = fabric.util.createClass; + + /** + * Noise filter class + * @class fabric.Image.filters.Noise + * @memberOf fabric.Image.filters + * @extends fabric.Image.filters.BaseFilter + * @see {@link fabric.Image.filters.Noise#initialize} for constructor definition + * @see {@link http://fabricjs.com/image-filters|ImageFilters demo} + * @example + * var filter = new fabric.Image.filters.Noise({ + * noise: 700 + * }); + * object.filters.push(filter); + * object.applyFilters(); + * canvas.renderAll(); + */ + filters.Noise = createClass(filters.BaseFilter, /** @lends fabric.Image.filters.Noise.prototype */ { + + /** + * Filter type + * @param {String} type + * @default + */ + type: 'Noise', + + /** + * Fragment source for the noise program + */ + fragmentSource: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform float uStepH;\n' + + 'uniform float uNoise;\n' + + 'uniform float uSeed;\n' + + 'varying vec2 vTexCoord;\n' + + 'float rand(vec2 co, float seed, float vScale) {\n' + + 'return fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);\n' + + '}\n' + + 'void main() {\n' + + 'vec4 color = texture2D(uTexture, vTexCoord);\n' + + 'color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;\n' + + 'gl_FragColor = color;\n' + + '}', + + /** + * Describe the property that is the filter parameter + * @param {String} m + * @default + */ + mainParameter: 'noise', + + /** + * Noise value, from + * @param {Number} noise + * @default + */ + noise: 0, + + /** + * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image. + * + * @param {Object} options + * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered. + */ + applyTo2d: function(options) { + if (this.noise === 0) { + return; + } + var imageData = options.imageData, + data = imageData.data, i, len = data.length, + noise = this.noise, rand; + + for (i = 0, len = data.length; i < len; i += 4) { + + rand = (0.5 - Math.random()) * noise; + + data[i] += rand; + data[i + 1] += rand; + data[i + 2] += rand; + } + }, + + /** + * Return WebGL uniform locations for this filter's shader. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {WebGLShaderProgram} program This filter's compiled shader program. + */ + getUniformLocations: function(gl, program) { + return { + uNoise: gl.getUniformLocation(program, 'uNoise'), + uSeed: gl.getUniformLocation(program, 'uSeed'), + }; + }, + + /** + * Send data from this filter to its shader program's uniforms. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects + */ + sendUniformData: function(gl, uniformLocations) { + gl.uniform1f(uniformLocations.uNoise, this.noise / 255); + gl.uniform1f(uniformLocations.uSeed, Math.random()); + }, + + /** + * Returns object representation of an instance + * @return {Object} Object representation of an instance + */ + toObject: function() { + return extend(this.callSuper('toObject'), { + noise: this.noise + }); + } + }); + + /** + * Returns filter instance from an object representation + * @static + * @param {Object} object Object to create an instance from + * @param {Function} [callback] to be invoked after filter creation + * @return {fabric.Image.filters.Noise} Instance of fabric.Image.filters.Noise + */ + fabric.Image.filters.Noise.fromObject = fabric.Image.filters.BaseFilter.fromObject; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + filters = fabric.Image.filters, + createClass = fabric.util.createClass; + + /** + * Pixelate filter class + * @class fabric.Image.filters.Pixelate + * @memberOf fabric.Image.filters + * @extends fabric.Image.filters.BaseFilter + * @see {@link fabric.Image.filters.Pixelate#initialize} for constructor definition + * @see {@link http://fabricjs.com/image-filters|ImageFilters demo} + * @example + * var filter = new fabric.Image.filters.Pixelate({ + * blocksize: 8 + * }); + * object.filters.push(filter); + * object.applyFilters(); + */ + filters.Pixelate = createClass(filters.BaseFilter, /** @lends fabric.Image.filters.Pixelate.prototype */ { + + /** + * Filter type + * @param {String} type + * @default + */ + type: 'Pixelate', + + blocksize: 4, + + mainParameter: 'blocksize', + + /** + * Fragment source for the Pixelate program + */ + fragmentSource: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform float uBlocksize;\n' + + 'uniform float uStepW;\n' + + 'uniform float uStepH;\n' + + 'varying vec2 vTexCoord;\n' + + 'void main() {\n' + + 'float blockW = uBlocksize * uStepW;\n' + + 'float blockH = uBlocksize * uStepW;\n' + + 'int posX = int(vTexCoord.x / blockW);\n' + + 'int posY = int(vTexCoord.y / blockH);\n' + + 'float fposX = float(posX);\n' + + 'float fposY = float(posY);\n' + + 'vec2 squareCoords = vec2(fposX * blockW, fposY * blockH);\n' + + 'vec4 color = texture2D(uTexture, squareCoords);\n' + + 'gl_FragColor = color;\n' + + '}', + + /** + * Apply the Pixelate operation to a Uint8ClampedArray representing the pixels of an image. + * + * @param {Object} options + * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered. + */ + applyTo2d: function(options) { + var imageData = options.imageData, + data = imageData.data, + iLen = imageData.height, + jLen = imageData.width, + index, i, j, r, g, b, a, + _i, _j, _iLen, _jLen; + + for (i = 0; i < iLen; i += this.blocksize) { + for (j = 0; j < jLen; j += this.blocksize) { + + index = (i * 4) * jLen + (j * 4); + + r = data[index]; + g = data[index + 1]; + b = data[index + 2]; + a = data[index + 3]; + + _iLen = Math.min(i + this.blocksize, iLen); + _jLen = Math.min(j + this.blocksize, jLen); + for (_i = i; _i < _iLen; _i++) { + for (_j = j; _j < _jLen; _j++) { + index = (_i * 4) * jLen + (_j * 4); + data[index] = r; + data[index + 1] = g; + data[index + 2] = b; + data[index + 3] = a; + } + } + } + } + }, + + /** + * Indicate when the filter is not gonna apply changes to the image + **/ + isNeutralState: function() { + return this.blocksize === 1; + }, + + /** + * Return WebGL uniform locations for this filter's shader. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {WebGLShaderProgram} program This filter's compiled shader program. + */ + getUniformLocations: function(gl, program) { + return { + uBlocksize: gl.getUniformLocation(program, 'uBlocksize'), + uStepW: gl.getUniformLocation(program, 'uStepW'), + uStepH: gl.getUniformLocation(program, 'uStepH'), + }; + }, + + /** + * Send data from this filter to its shader program's uniforms. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects + */ + sendUniformData: function(gl, uniformLocations) { + gl.uniform1f(uniformLocations.uBlocksize, this.blocksize); + }, + }); + + /** + * Returns filter instance from an object representation + * @static + * @param {Object} object Object to create an instance from + * @param {Function} [callback] to be invoked after filter creation + * @return {fabric.Image.filters.Pixelate} Instance of fabric.Image.filters.Pixelate + */ + fabric.Image.filters.Pixelate.fromObject = fabric.Image.filters.BaseFilter.fromObject; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + extend = fabric.util.object.extend, + filters = fabric.Image.filters, + createClass = fabric.util.createClass; + + /** + * Remove white filter class + * @class fabric.Image.filters.RemoveColor + * @memberOf fabric.Image.filters + * @extends fabric.Image.filters.BaseFilter + * @see {@link fabric.Image.filters.RemoveColor#initialize} for constructor definition + * @see {@link http://fabricjs.com/image-filters|ImageFilters demo} + * @example + * var filter = new fabric.Image.filters.RemoveColor({ + * threshold: 0.2, + * }); + * object.filters.push(filter); + * object.applyFilters(); + * canvas.renderAll(); + */ + filters.RemoveColor = createClass(filters.BaseFilter, /** @lends fabric.Image.filters.RemoveColor.prototype */ { + + /** + * Filter type + * @param {String} type + * @default + */ + type: 'RemoveColor', + + /** + * Color to remove, in any format understood by fabric.Color. + * @param {String} type + * @default + */ + color: '#FFFFFF', + + /** + * Fragment source for the brightness program + */ + fragmentSource: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform vec4 uLow;\n' + + 'uniform vec4 uHigh;\n' + + 'varying vec2 vTexCoord;\n' + + 'void main() {\n' + + 'gl_FragColor = texture2D(uTexture, vTexCoord);\n' + + 'if(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {\n' + + 'gl_FragColor.a = 0.0;\n' + + '}\n' + + '}', + + /** + * distance to actual color, as value up or down from each r,g,b + * between 0 and 1 + **/ + distance: 0.02, + + /** + * For color to remove inside distance, use alpha channel for a smoother deletion + * NOT IMPLEMENTED YET + **/ + useAlpha: false, + + /** + * Constructor + * @memberOf fabric.Image.filters.RemoveWhite.prototype + * @param {Object} [options] Options object + * @param {Number} [options.color=#RRGGBB] Threshold value + * @param {Number} [options.distance=10] Distance value + */ + + /** + * Applies filter to canvas element + * @param {Object} canvasEl Canvas element to apply filter to + */ + applyTo2d: function(options) { + var imageData = options.imageData, + data = imageData.data, i, + distance = this.distance * 255, + r, g, b, + source = new fabric.Color(this.color).getSource(), + lowC = [ + source[0] - distance, + source[1] - distance, + source[2] - distance, + ], + highC = [ + source[0] + distance, + source[1] + distance, + source[2] + distance, + ]; + + + for (i = 0; i < data.length; i += 4) { + r = data[i]; + g = data[i + 1]; + b = data[i + 2]; + + if (r > lowC[0] && + g > lowC[1] && + b > lowC[2] && + r < highC[0] && + g < highC[1] && + b < highC[2]) { + data[i + 3] = 0; + } + } + }, + + /** + * Return WebGL uniform locations for this filter's shader. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {WebGLShaderProgram} program This filter's compiled shader program. + */ + getUniformLocations: function(gl, program) { + return { + uLow: gl.getUniformLocation(program, 'uLow'), + uHigh: gl.getUniformLocation(program, 'uHigh'), + }; + }, + + /** + * Send data from this filter to its shader program's uniforms. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects + */ + sendUniformData: function(gl, uniformLocations) { + var source = new fabric.Color(this.color).getSource(), + distance = parseFloat(this.distance), + lowC = [ + 0 + source[0] / 255 - distance, + 0 + source[1] / 255 - distance, + 0 + source[2] / 255 - distance, + 1 + ], + highC = [ + source[0] / 255 + distance, + source[1] / 255 + distance, + source[2] / 255 + distance, + 1 + ]; + gl.uniform4fv(uniformLocations.uLow, lowC); + gl.uniform4fv(uniformLocations.uHigh, highC); + }, + + /** + * Returns object representation of an instance + * @return {Object} Object representation of an instance + */ + toObject: function() { + return extend(this.callSuper('toObject'), { + color: this.color, + distance: this.distance + }); + } + }); + + /** + * Returns filter instance from an object representation + * @static + * @param {Object} object Object to create an instance from + * @param {Function} [callback] to be invoked after filter creation + * @return {fabric.Image.filters.RemoveColor} Instance of fabric.Image.filters.RemoveWhite + */ + fabric.Image.filters.RemoveColor.fromObject = fabric.Image.filters.BaseFilter.fromObject; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + filters = fabric.Image.filters, + createClass = fabric.util.createClass; + + var matrices = { + Brownie: [ + 0.59970,0.34553,-0.27082,0,0.186, + -0.03770,0.86095,0.15059,0,-0.1449, + 0.24113,-0.07441,0.44972,0,-0.02965, + 0,0,0,1,0 + ], + Vintage: [ + 0.62793,0.32021,-0.03965,0,0.03784, + 0.02578,0.64411,0.03259,0,0.02926, + 0.04660,-0.08512,0.52416,0,0.02023, + 0,0,0,1,0 + ], + Kodachrome: [ + 1.12855,-0.39673,-0.03992,0,0.24991, + -0.16404,1.08352,-0.05498,0,0.09698, + -0.16786,-0.56034,1.60148,0,0.13972, + 0,0,0,1,0 + ], + Technicolor: [ + 1.91252,-0.85453,-0.09155,0,0.04624, + -0.30878,1.76589,-0.10601,0,-0.27589, + -0.23110,-0.75018,1.84759,0,0.12137, + 0,0,0,1,0 + ], + Polaroid: [ + 1.438,-0.062,-0.062,0,0, + -0.122,1.378,-0.122,0,0, + -0.016,-0.016,1.483,0,0, + 0,0,0,1,0 + ], + Sepia: [ + 0.393, 0.769, 0.189, 0, 0, + 0.349, 0.686, 0.168, 0, 0, + 0.272, 0.534, 0.131, 0, 0, + 0, 0, 0, 1, 0 + ], + BlackWhite: [ + 1.5, 1.5, 1.5, 0, -1, + 1.5, 1.5, 1.5, 0, -1, + 1.5, 1.5, 1.5, 0, -1, + 0, 0, 0, 1, 0, + ] + }; + + for (var key in matrices) { + filters[key] = createClass(filters.ColorMatrix, /** @lends fabric.Image.filters.Sepia.prototype */ { + + /** + * Filter type + * @param {String} type + * @default + */ + type: key, + + /** + * Colormatrix for the effect + * array of 20 floats. Numbers in positions 4, 9, 14, 19 loose meaning + * outside the -1, 1 range. + * @param {Array} matrix array of 20 numbers. + * @default + */ + matrix: matrices[key], + + /** + * Lock the matrix export for this kind of static, parameter less filters. + */ + mainParameter: false, + /** + * Lock the colormatrix on the color part, skipping alpha + */ + colorsOnly: true, + + }); + fabric.Image.filters[key].fromObject = fabric.Image.filters.BaseFilter.fromObject; + } +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + 'use strict'; + + var fabric = global.fabric, + filters = fabric.Image.filters, + createClass = fabric.util.createClass; + + /** + * Color Blend filter class + * @class fabric.Image.filter.BlendColor + * @memberOf fabric.Image.filters + * @extends fabric.Image.filters.BaseFilter + * @example + * var filter = new fabric.Image.filters.BlendColor({ + * color: '#000', + * mode: 'multiply' + * }); + * + * var filter = new fabric.Image.filters.BlendImage({ + * image: fabricImageObject, + * mode: 'multiply', + * alpha: 0.5 + * }); + * object.filters.push(filter); + * object.applyFilters(); + * canvas.renderAll(); + */ + + filters.BlendColor = createClass(filters.BaseFilter, /** @lends fabric.Image.filters.Blend.prototype */ { + type: 'BlendColor', + + /** + * Color to make the blend operation with. default to a reddish color since black or white + * gives always strong result. + * @type String + * @default + **/ + color: '#F95C63', + + /** + * Blend mode for the filter: one of multiply, add, diff, screen, subtract, + * darken, lighten, overlay, exclusion, tint. + * @type String + * @default + **/ + mode: 'multiply', + + /** + * alpha value. represent the strength of the blend color operation. + * @type Number + * @default + **/ + alpha: 1, + + /** + * Fragment source for the Multiply program + */ + fragmentSource: { + multiply: 'gl_FragColor.rgb *= uColor.rgb;\n', + screen: 'gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);\n', + add: 'gl_FragColor.rgb += uColor.rgb;\n', + diff: 'gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);\n', + subtract: 'gl_FragColor.rgb -= uColor.rgb;\n', + lighten: 'gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);\n', + darken: 'gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);\n', + exclusion: 'gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);\n', + overlay: 'if (uColor.r < 0.5) {\n' + + 'gl_FragColor.r *= 2.0 * uColor.r;\n' + + '} else {\n' + + 'gl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);\n' + + '}\n' + + 'if (uColor.g < 0.5) {\n' + + 'gl_FragColor.g *= 2.0 * uColor.g;\n' + + '} else {\n' + + 'gl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);\n' + + '}\n' + + 'if (uColor.b < 0.5) {\n' + + 'gl_FragColor.b *= 2.0 * uColor.b;\n' + + '} else {\n' + + 'gl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);\n' + + '}\n', + tint: 'gl_FragColor.rgb *= (1.0 - uColor.a);\n' + + 'gl_FragColor.rgb += uColor.rgb;\n', + }, + + /** + * build the fragment source for the filters, joining the common part with + * the specific one. + * @param {String} mode the mode of the filter, a key of this.fragmentSource + * @return {String} the source to be compiled + * @private + */ + buildSource: function(mode) { + return 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform vec4 uColor;\n' + + 'varying vec2 vTexCoord;\n' + + 'void main() {\n' + + 'vec4 color = texture2D(uTexture, vTexCoord);\n' + + 'gl_FragColor = color;\n' + + 'if (color.a > 0.0) {\n' + + this.fragmentSource[mode] + + '}\n' + + '}'; + }, + + /** + * Retrieves the cached shader. + * @param {Object} options + * @param {WebGLRenderingContext} options.context The GL context used for rendering. + * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type. + */ + retrieveShader: function(options) { + var cacheKey = this.type + '_' + this.mode, shaderSource; + if (!options.programCache.hasOwnProperty(cacheKey)) { + shaderSource = this.buildSource(this.mode); + options.programCache[cacheKey] = this.createProgram(options.context, shaderSource); + } + return options.programCache[cacheKey]; + }, + + /** + * Apply the Blend operation to a Uint8ClampedArray representing the pixels of an image. + * + * @param {Object} options + * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered. + */ + applyTo2d: function(options) { + var imageData = options.imageData, + data = imageData.data, iLen = data.length, + tr, tg, tb, + r, g, b, + source, alpha1 = 1 - this.alpha; + + source = new fabric.Color(this.color).getSource(); + tr = source[0] * this.alpha; + tg = source[1] * this.alpha; + tb = source[2] * this.alpha; + + for (var i = 0; i < iLen; i += 4) { + + r = data[i]; + g = data[i + 1]; + b = data[i + 2]; + + switch (this.mode) { + case 'multiply': + data[i] = r * tr / 255; + data[i + 1] = g * tg / 255; + data[i + 2] = b * tb / 255; + break; + case 'screen': + data[i] = 255 - (255 - r) * (255 - tr) / 255; + data[i + 1] = 255 - (255 - g) * (255 - tg) / 255; + data[i + 2] = 255 - (255 - b) * (255 - tb) / 255; + break; + case 'add': + data[i] = r + tr; + data[i + 1] = g + tg; + data[i + 2] = b + tb; + break; + case 'diff': + case 'difference': + data[i] = Math.abs(r - tr); + data[i + 1] = Math.abs(g - tg); + data[i + 2] = Math.abs(b - tb); + break; + case 'subtract': + data[i] = r - tr; + data[i + 1] = g - tg; + data[i + 2] = b - tb; + break; + case 'darken': + data[i] = Math.min(r, tr); + data[i + 1] = Math.min(g, tg); + data[i + 2] = Math.min(b, tb); + break; + case 'lighten': + data[i] = Math.max(r, tr); + data[i + 1] = Math.max(g, tg); + data[i + 2] = Math.max(b, tb); + break; + case 'overlay': + data[i] = tr < 128 ? (2 * r * tr / 255) : (255 - 2 * (255 - r) * (255 - tr) / 255); + data[i + 1] = tg < 128 ? (2 * g * tg / 255) : (255 - 2 * (255 - g) * (255 - tg) / 255); + data[i + 2] = tb < 128 ? (2 * b * tb / 255) : (255 - 2 * (255 - b) * (255 - tb) / 255); + break; + case 'exclusion': + data[i] = tr + r - ((2 * tr * r) / 255); + data[i + 1] = tg + g - ((2 * tg * g) / 255); + data[i + 2] = tb + b - ((2 * tb * b) / 255); + break; + case 'tint': + data[i] = tr + r * alpha1; + data[i + 1] = tg + g * alpha1; + data[i + 2] = tb + b * alpha1; + } + } + }, + + /** + * Return WebGL uniform locations for this filter's shader. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {WebGLShaderProgram} program This filter's compiled shader program. + */ + getUniformLocations: function(gl, program) { + return { + uColor: gl.getUniformLocation(program, 'uColor'), + }; + }, + + /** + * Send data from this filter to its shader program's uniforms. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects + */ + sendUniformData: function(gl, uniformLocations) { + var source = new fabric.Color(this.color).getSource(); + source[0] = this.alpha * source[0] / 255; + source[1] = this.alpha * source[1] / 255; + source[2] = this.alpha * source[2] / 255; + source[3] = this.alpha; + gl.uniform4fv(uniformLocations.uColor, source); + }, + + /** + * Returns object representation of an instance + * @return {Object} Object representation of an instance + */ + toObject: function() { + return { + type: this.type, + color: this.color, + mode: this.mode, + alpha: this.alpha + }; + } + }); + + /** + * Returns filter instance from an object representation + * @static + * @param {Object} object Object to create an instance from + * @param {function} [callback] to be invoked after filter creation + * @return {fabric.Image.filters.BlendColor} Instance of fabric.Image.filters.BlendColor + */ + fabric.Image.filters.BlendColor.fromObject = fabric.Image.filters.BaseFilter.fromObject; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + 'use strict'; + + var fabric = global.fabric, + filters = fabric.Image.filters, + createClass = fabric.util.createClass; + + /** + * Image Blend filter class + * @class fabric.Image.filter.BlendImage + * @memberOf fabric.Image.filters + * @extends fabric.Image.filters.BaseFilter + * @example + * var filter = new fabric.Image.filters.BlendColor({ + * color: '#000', + * mode: 'multiply' + * }); + * + * var filter = new fabric.Image.filters.BlendImage({ + * image: fabricImageObject, + * mode: 'multiply', + * alpha: 0.5 + * }); + * object.filters.push(filter); + * object.applyFilters(); + * canvas.renderAll(); + */ + + filters.BlendImage = createClass(filters.BaseFilter, /** @lends fabric.Image.filters.BlendImage.prototype */ { + type: 'BlendImage', + + /** + * Color to make the blend operation with. default to a reddish color since black or white + * gives always strong result. + **/ + image: null, + + /** + * Blend mode for the filter (one of "multiply", "mask") + * @type String + * @default + **/ + mode: 'multiply', + + /** + * alpha value. represent the strength of the blend image operation. + * not implemented. + **/ + alpha: 1, + + vertexSource: 'attribute vec2 aPosition;\n' + + 'varying vec2 vTexCoord;\n' + + 'varying vec2 vTexCoord2;\n' + + 'uniform mat3 uTransformMatrix;\n' + + 'void main() {\n' + + 'vTexCoord = aPosition;\n' + + 'vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\n' + + 'gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n' + + '}', + + /** + * Fragment source for the Multiply program + */ + fragmentSource: { + multiply: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform sampler2D uImage;\n' + + 'uniform vec4 uColor;\n' + + 'varying vec2 vTexCoord;\n' + + 'varying vec2 vTexCoord2;\n' + + 'void main() {\n' + + 'vec4 color = texture2D(uTexture, vTexCoord);\n' + + 'vec4 color2 = texture2D(uImage, vTexCoord2);\n' + + 'color.rgba *= color2.rgba;\n' + + 'gl_FragColor = color;\n' + + '}', + mask: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform sampler2D uImage;\n' + + 'uniform vec4 uColor;\n' + + 'varying vec2 vTexCoord;\n' + + 'varying vec2 vTexCoord2;\n' + + 'void main() {\n' + + 'vec4 color = texture2D(uTexture, vTexCoord);\n' + + 'vec4 color2 = texture2D(uImage, vTexCoord2);\n' + + 'color.a = color2.a;\n' + + 'gl_FragColor = color;\n' + + '}', + }, + + /** + * Retrieves the cached shader. + * @param {Object} options + * @param {WebGLRenderingContext} options.context The GL context used for rendering. + * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type. + */ + retrieveShader: function(options) { + var cacheKey = this.type + '_' + this.mode; + var shaderSource = this.fragmentSource[this.mode]; + if (!options.programCache.hasOwnProperty(cacheKey)) { + options.programCache[cacheKey] = this.createProgram(options.context, shaderSource); + } + return options.programCache[cacheKey]; + }, + + applyToWebGL: function(options) { + // load texture to blend. + var gl = options.context, + texture = this.createTexture(options.filterBackend, this.image); + this.bindAdditionalTexture(gl, texture, gl.TEXTURE1); + this.callSuper('applyToWebGL', options); + this.unbindAdditionalTexture(gl, gl.TEXTURE1); + }, + + createTexture: function(backend, image) { + return backend.getCachedTexture(image.cacheKey, image._element); + }, + + /** + * Calculate a transformMatrix to adapt the image to blend over + * @param {Object} options + * @param {WebGLRenderingContext} options.context The GL context used for rendering. + * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type. + */ + calculateMatrix: function() { + var image = this.image, + width = image._element.width, + height = image._element.height; + return [ + 1 / image.scaleX, 0, 0, + 0, 1 / image.scaleY, 0, + -image.left / width, -image.top / height, 1 + ]; + }, + + /** + * Apply the Blend operation to a Uint8ClampedArray representing the pixels of an image. + * + * @param {Object} options + * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered. + */ + applyTo2d: function(options) { + var imageData = options.imageData, + resources = options.filterBackend.resources, + data = imageData.data, iLen = data.length, + width = imageData.width, + height = imageData.height, + tr, tg, tb, ta, + r, g, b, a, + canvas1, context, image = this.image, blendData; + + if (!resources.blendImage) { + resources.blendImage = fabric.util.createCanvasElement(); + } + canvas1 = resources.blendImage; + context = canvas1.getContext('2d'); + if (canvas1.width !== width || canvas1.height !== height) { + canvas1.width = width; + canvas1.height = height; + } + else { + context.clearRect(0, 0, width, height); + } + context.setTransform(image.scaleX, 0, 0, image.scaleY, image.left, image.top); + context.drawImage(image._element, 0, 0, width, height); + blendData = context.getImageData(0, 0, width, height).data; + for (var i = 0; i < iLen; i += 4) { + + r = data[i]; + g = data[i + 1]; + b = data[i + 2]; + a = data[i + 3]; + + tr = blendData[i]; + tg = blendData[i + 1]; + tb = blendData[i + 2]; + ta = blendData[i + 3]; + + switch (this.mode) { + case 'multiply': + data[i] = r * tr / 255; + data[i + 1] = g * tg / 255; + data[i + 2] = b * tb / 255; + data[i + 3] = a * ta / 255; + break; + case 'mask': + data[i + 3] = ta; + break; + } + } + }, + + /** + * Return WebGL uniform locations for this filter's shader. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {WebGLShaderProgram} program This filter's compiled shader program. + */ + getUniformLocations: function(gl, program) { + return { + uTransformMatrix: gl.getUniformLocation(program, 'uTransformMatrix'), + uImage: gl.getUniformLocation(program, 'uImage'), + }; + }, + + /** + * Send data from this filter to its shader program's uniforms. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects + */ + sendUniformData: function(gl, uniformLocations) { + var matrix = this.calculateMatrix(); + gl.uniform1i(uniformLocations.uImage, 1); // texture unit 1. + gl.uniformMatrix3fv(uniformLocations.uTransformMatrix, false, matrix); + }, + + /** + * Returns object representation of an instance + * @return {Object} Object representation of an instance + */ + toObject: function() { + return { + type: this.type, + image: this.image && this.image.toObject(), + mode: this.mode, + alpha: this.alpha + }; + } + }); + + /** + * Returns filter instance from an object representation + * @static + * @param {Object} object Object to create an instance from + * @param {function} callback to be invoked after filter creation + * @return {fabric.Image.filters.BlendImage} Instance of fabric.Image.filters.BlendImage + */ + fabric.Image.filters.BlendImage.fromObject = function(object, callback) { + fabric.Image.fromObject(object.image, function(image) { + var options = fabric.util.object.clone(object); + options.image = image; + callback(new fabric.Image.filters.BlendImage(options)); + }); + }; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), pow = Math.pow, floor = Math.floor, + sqrt = Math.sqrt, abs = Math.abs, round = Math.round, sin = Math.sin, + ceil = Math.ceil, + filters = fabric.Image.filters, + createClass = fabric.util.createClass; + + /** + * Resize image filter class + * @class fabric.Image.filters.Resize + * @memberOf fabric.Image.filters + * @extends fabric.Image.filters.BaseFilter + * @see {@link http://fabricjs.com/image-filters|ImageFilters demo} + * @example + * var filter = new fabric.Image.filters.Resize(); + * object.filters.push(filter); + * object.applyFilters(canvas.renderAll.bind(canvas)); + */ + filters.Resize = createClass(filters.BaseFilter, /** @lends fabric.Image.filters.Resize.prototype */ { + + /** + * Filter type + * @param {String} type + * @default + */ + type: 'Resize', + + /** + * Resize type + * for webgl resizeType is just lanczos, for canvas2d can be: + * bilinear, hermite, sliceHack, lanczos. + * @param {String} resizeType + * @default + */ + resizeType: 'hermite', + + /** + * Scale factor for resizing, x axis + * @param {Number} scaleX + * @default + */ + scaleX: 1, + + /** + * Scale factor for resizing, y axis + * @param {Number} scaleY + * @default + */ + scaleY: 1, + + /** + * LanczosLobes parameter for lanczos filter, valid for resizeType lanczos + * @param {Number} lanczosLobes + * @default + */ + lanczosLobes: 3, + + + /** + * Return WebGL uniform locations for this filter's shader. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {WebGLShaderProgram} program This filter's compiled shader program. + */ + getUniformLocations: function(gl, program) { + return { + uDelta: gl.getUniformLocation(program, 'uDelta'), + uTaps: gl.getUniformLocation(program, 'uTaps'), + }; + }, + + /** + * Send data from this filter to its shader program's uniforms. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects + */ + sendUniformData: function(gl, uniformLocations) { + gl.uniform2fv(uniformLocations.uDelta, this.horizontal ? [1 / this.width, 0] : [0, 1 / this.height]); + gl.uniform1fv(uniformLocations.uTaps, this.taps); + }, + + /** + * Retrieves the cached shader. + * @param {Object} options + * @param {WebGLRenderingContext} options.context The GL context used for rendering. + * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type. + */ + retrieveShader: function(options) { + var filterWindow = this.getFilterWindow(), cacheKey = this.type + '_' + filterWindow; + if (!options.programCache.hasOwnProperty(cacheKey)) { + var fragmentShader = this.generateShader(filterWindow); + options.programCache[cacheKey] = this.createProgram(options.context, fragmentShader); + } + return options.programCache[cacheKey]; + }, + + getFilterWindow: function() { + var scale = this.tempScale; + return Math.ceil(this.lanczosLobes / scale); + }, + + getTaps: function() { + var lobeFunction = this.lanczosCreate(this.lanczosLobes), scale = this.tempScale, + filterWindow = this.getFilterWindow(), taps = new Array(filterWindow); + for (var i = 1; i <= filterWindow; i++) { + taps[i - 1] = lobeFunction(i * scale); + } + return taps; + }, + + /** + * Generate vertex and shader sources from the necessary steps numbers + * @param {Number} filterWindow + */ + generateShader: function(filterWindow) { + var offsets = new Array(filterWindow), + fragmentShader = this.fragmentSourceTOP, filterWindow; + + for (var i = 1; i <= filterWindow; i++) { + offsets[i - 1] = i + '.0 * uDelta'; + } + + fragmentShader += 'uniform float uTaps[' + filterWindow + '];\n'; + fragmentShader += 'void main() {\n'; + fragmentShader += ' vec4 color = texture2D(uTexture, vTexCoord);\n'; + fragmentShader += ' float sum = 1.0;\n'; + + offsets.forEach(function(offset, i) { + fragmentShader += ' color += texture2D(uTexture, vTexCoord + ' + offset + ') * uTaps[' + i + '];\n'; + fragmentShader += ' color += texture2D(uTexture, vTexCoord - ' + offset + ') * uTaps[' + i + '];\n'; + fragmentShader += ' sum += 2.0 * uTaps[' + i + '];\n'; + }); + fragmentShader += ' gl_FragColor = color / sum;\n'; + fragmentShader += '}'; + return fragmentShader; + }, + + fragmentSourceTOP: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform vec2 uDelta;\n' + + 'varying vec2 vTexCoord;\n', + + /** + * Apply the resize filter to the image + * Determines whether to use WebGL or Canvas2D based on the options.webgl flag. + * + * @param {Object} options + * @param {Number} options.passes The number of filters remaining to be executed + * @param {Boolean} options.webgl Whether to use webgl to render the filter. + * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered. + * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn. + * @param {WebGLRenderingContext} options.context The GL context used for rendering. + * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type. + */ + applyTo: function(options) { + if (options.webgl) { + options.passes++; + this.width = options.sourceWidth; + this.horizontal = true; + this.dW = Math.round(this.width * this.scaleX); + this.dH = options.sourceHeight; + this.tempScale = this.dW / this.width; + this.taps = this.getTaps(); + options.destinationWidth = this.dW; + this._setupFrameBuffer(options); + this.applyToWebGL(options); + this._swapTextures(options); + options.sourceWidth = options.destinationWidth; + + this.height = options.sourceHeight; + this.horizontal = false; + this.dH = Math.round(this.height * this.scaleY); + this.tempScale = this.dH / this.height; + this.taps = this.getTaps(); + options.destinationHeight = this.dH; + this._setupFrameBuffer(options); + this.applyToWebGL(options); + this._swapTextures(options); + options.sourceHeight = options.destinationHeight; + } + else { + this.applyTo2d(options); + } + }, + + isNeutralState: function() { + return this.scaleX === 1 && this.scaleY === 1; + }, + + lanczosCreate: function(lobes) { + return function(x) { + if (x >= lobes || x <= -lobes) { + return 0.0; + } + if (x < 1.19209290E-07 && x > -1.19209290E-07) { + return 1.0; + } + x *= Math.PI; + var xx = x / lobes; + return (sin(x) / x) * sin(xx) / xx; + }; + }, + + /** + * Applies filter to canvas element + * @memberOf fabric.Image.filters.Resize.prototype + * @param {Object} canvasEl Canvas element to apply filter to + * @param {Number} scaleX + * @param {Number} scaleY + */ + applyTo2d: function(options) { + var imageData = options.imageData, + scaleX = this.scaleX, + scaleY = this.scaleY; + + this.rcpScaleX = 1 / scaleX; + this.rcpScaleY = 1 / scaleY; + + var oW = imageData.width, oH = imageData.height, + dW = round(oW * scaleX), dH = round(oH * scaleY), + newData; + + if (this.resizeType === 'sliceHack') { + newData = this.sliceByTwo(options, oW, oH, dW, dH); + } + else if (this.resizeType === 'hermite') { + newData = this.hermiteFastResize(options, oW, oH, dW, dH); + } + else if (this.resizeType === 'bilinear') { + newData = this.bilinearFiltering(options, oW, oH, dW, dH); + } + else if (this.resizeType === 'lanczos') { + newData = this.lanczosResize(options, oW, oH, dW, dH); + } + options.imageData = newData; + }, + + /** + * Filter sliceByTwo + * @param {Object} canvasEl Canvas element to apply filter to + * @param {Number} oW Original Width + * @param {Number} oH Original Height + * @param {Number} dW Destination Width + * @param {Number} dH Destination Height + * @returns {ImageData} + */ + sliceByTwo: function(options, oW, oH, dW, dH) { + var imageData = options.imageData, + mult = 0.5, doneW = false, doneH = false, stepW = oW * mult, + stepH = oH * mult, resources = fabric.filterBackend.resources, + tmpCanvas, ctx, sX = 0, sY = 0, dX = oW, dY = 0; + if (!resources.sliceByTwo) { + resources.sliceByTwo = document.createElement('canvas'); + } + tmpCanvas = resources.sliceByTwo; + if (tmpCanvas.width < oW * 1.5 || tmpCanvas.height < oH) { + tmpCanvas.width = oW * 1.5; + tmpCanvas.height = oH; + } + ctx = tmpCanvas.getContext('2d'); + ctx.clearRect(0, 0, oW * 1.5, oH); + ctx.putImageData(imageData, 0, 0); + + dW = floor(dW); + dH = floor(dH); + + while (!doneW || !doneH) { + oW = stepW; + oH = stepH; + if (dW < floor(stepW * mult)) { + stepW = floor(stepW * mult); + } + else { + stepW = dW; + doneW = true; + } + if (dH < floor(stepH * mult)) { + stepH = floor(stepH * mult); + } + else { + stepH = dH; + doneH = true; + } + ctx.drawImage(tmpCanvas, sX, sY, oW, oH, dX, dY, stepW, stepH); + sX = dX; + sY = dY; + dY += stepH; + } + return ctx.getImageData(sX, sY, dW, dH); + }, + + /** + * Filter lanczosResize + * @param {Object} canvasEl Canvas element to apply filter to + * @param {Number} oW Original Width + * @param {Number} oH Original Height + * @param {Number} dW Destination Width + * @param {Number} dH Destination Height + * @returns {ImageData} + */ + lanczosResize: function(options, oW, oH, dW, dH) { + + function process(u) { + var v, i, weight, idx, a, red, green, + blue, alpha, fX, fY; + center.x = (u + 0.5) * ratioX; + icenter.x = floor(center.x); + for (v = 0; v < dH; v++) { + center.y = (v + 0.5) * ratioY; + icenter.y = floor(center.y); + a = 0; red = 0; green = 0; blue = 0; alpha = 0; + for (i = icenter.x - range2X; i <= icenter.x + range2X; i++) { + if (i < 0 || i >= oW) { + continue; + } + fX = floor(1000 * abs(i - center.x)); + if (!cacheLanc[fX]) { + cacheLanc[fX] = { }; + } + for (var j = icenter.y - range2Y; j <= icenter.y + range2Y; j++) { + if (j < 0 || j >= oH) { + continue; + } + fY = floor(1000 * abs(j - center.y)); + if (!cacheLanc[fX][fY]) { + cacheLanc[fX][fY] = lanczos(sqrt(pow(fX * rcpRatioX, 2) + pow(fY * rcpRatioY, 2)) / 1000); + } + weight = cacheLanc[fX][fY]; + if (weight > 0) { + idx = (j * oW + i) * 4; + a += weight; + red += weight * srcData[idx]; + green += weight * srcData[idx + 1]; + blue += weight * srcData[idx + 2]; + alpha += weight * srcData[idx + 3]; + } + } + } + idx = (v * dW + u) * 4; + destData[idx] = red / a; + destData[idx + 1] = green / a; + destData[idx + 2] = blue / a; + destData[idx + 3] = alpha / a; + } + + if (++u < dW) { + return process(u); + } + else { + return destImg; + } + } + + var srcData = options.imageData.data, + destImg = options.ctx.createImageData(dW, dH), + destData = destImg.data, + lanczos = this.lanczosCreate(this.lanczosLobes), + ratioX = this.rcpScaleX, ratioY = this.rcpScaleY, + rcpRatioX = 2 / this.rcpScaleX, rcpRatioY = 2 / this.rcpScaleY, + range2X = ceil(ratioX * this.lanczosLobes / 2), + range2Y = ceil(ratioY * this.lanczosLobes / 2), + cacheLanc = { }, center = { }, icenter = { }; + + return process(0); + }, + + /** + * bilinearFiltering + * @param {Object} canvasEl Canvas element to apply filter to + * @param {Number} oW Original Width + * @param {Number} oH Original Height + * @param {Number} dW Destination Width + * @param {Number} dH Destination Height + * @returns {ImageData} + */ + bilinearFiltering: function(options, oW, oH, dW, dH) { + var a, b, c, d, x, y, i, j, xDiff, yDiff, chnl, + color, offset = 0, origPix, ratioX = this.rcpScaleX, + ratioY = this.rcpScaleY, + w4 = 4 * (oW - 1), img = options.imageData, + pixels = img.data, destImage = options.ctx.createImageData(dW, dH), + destPixels = destImage.data; + for (i = 0; i < dH; i++) { + for (j = 0; j < dW; j++) { + x = floor(ratioX * j); + y = floor(ratioY * i); + xDiff = ratioX * j - x; + yDiff = ratioY * i - y; + origPix = 4 * (y * oW + x); + + for (chnl = 0; chnl < 4; chnl++) { + a = pixels[origPix + chnl]; + b = pixels[origPix + 4 + chnl]; + c = pixels[origPix + w4 + chnl]; + d = pixels[origPix + w4 + 4 + chnl]; + color = a * (1 - xDiff) * (1 - yDiff) + b * xDiff * (1 - yDiff) + + c * yDiff * (1 - xDiff) + d * xDiff * yDiff; + destPixels[offset++] = color; + } + } + } + return destImage; + }, + + /** + * hermiteFastResize + * @param {Object} canvasEl Canvas element to apply filter to + * @param {Number} oW Original Width + * @param {Number} oH Original Height + * @param {Number} dW Destination Width + * @param {Number} dH Destination Height + * @returns {ImageData} + */ + hermiteFastResize: function(options, oW, oH, dW, dH) { + var ratioW = this.rcpScaleX, ratioH = this.rcpScaleY, + ratioWHalf = ceil(ratioW / 2), + ratioHHalf = ceil(ratioH / 2), + img = options.imageData, data = img.data, + img2 = options.ctx.createImageData(dW, dH), data2 = img2.data; + for (var j = 0; j < dH; j++) { + for (var i = 0; i < dW; i++) { + var x2 = (i + j * dW) * 4, weight = 0, weights = 0, weightsAlpha = 0, + gxR = 0, gxG = 0, gxB = 0, gxA = 0, centerY = (j + 0.5) * ratioH; + for (var yy = floor(j * ratioH); yy < (j + 1) * ratioH; yy++) { + var dy = abs(centerY - (yy + 0.5)) / ratioHHalf, + centerX = (i + 0.5) * ratioW, w0 = dy * dy; + for (var xx = floor(i * ratioW); xx < (i + 1) * ratioW; xx++) { + var dx = abs(centerX - (xx + 0.5)) / ratioWHalf, + w = sqrt(w0 + dx * dx); + /* eslint-disable max-depth */ + if (w > 1 && w < -1) { + continue; + } + //hermite filter + weight = 2 * w * w * w - 3 * w * w + 1; + if (weight > 0) { + dx = 4 * (xx + yy * oW); + //alpha + gxA += weight * data[dx + 3]; + weightsAlpha += weight; + //colors + if (data[dx + 3] < 255) { + weight = weight * data[dx + 3] / 250; + } + gxR += weight * data[dx]; + gxG += weight * data[dx + 1]; + gxB += weight * data[dx + 2]; + weights += weight; + } + /* eslint-enable max-depth */ + } + } + data2[x2] = gxR / weights; + data2[x2 + 1] = gxG / weights; + data2[x2 + 2] = gxB / weights; + data2[x2 + 3] = gxA / weightsAlpha; + } + } + return img2; + }, + + /** + * Returns object representation of an instance + * @return {Object} Object representation of an instance + */ + toObject: function() { + return { + type: this.type, + scaleX: this.scaleX, + scaleY: this.scaleY, + resizeType: this.resizeType, + lanczosLobes: this.lanczosLobes + }; + } + }); + + /** + * Returns filter instance from an object representation + * @static + * @param {Object} object Object to create an instance from + * @param {Function} [callback] to be invoked after filter creation + * @return {fabric.Image.filters.Resize} Instance of fabric.Image.filters.Resize + */ + fabric.Image.filters.Resize.fromObject = fabric.Image.filters.BaseFilter.fromObject; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + filters = fabric.Image.filters, + createClass = fabric.util.createClass; + + /** + * Contrast filter class + * @class fabric.Image.filters.Contrast + * @memberOf fabric.Image.filters + * @extends fabric.Image.filters.BaseFilter + * @see {@link fabric.Image.filters.Contrast#initialize} for constructor definition + * @see {@link http://fabricjs.com/image-filters|ImageFilters demo} + * @example + * var filter = new fabric.Image.filters.Contrast({ + * contrast: 0.25 + * }); + * object.filters.push(filter); + * object.applyFilters(); + */ + filters.Contrast = createClass(filters.BaseFilter, /** @lends fabric.Image.filters.Contrast.prototype */ { + + /** + * Filter type + * @param {String} type + * @default + */ + type: 'Contrast', + + fragmentSource: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform float uContrast;\n' + + 'varying vec2 vTexCoord;\n' + + 'void main() {\n' + + 'vec4 color = texture2D(uTexture, vTexCoord);\n' + + 'float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));\n' + + 'color.rgb = contrastF * (color.rgb - 0.5) + 0.5;\n' + + 'gl_FragColor = color;\n' + + '}', + + /** + * contrast value, range from -1 to 1. + * @param {Number} contrast + * @default 0 + */ + contrast: 0, + + mainParameter: 'contrast', + + /** + * Constructor + * @memberOf fabric.Image.filters.Contrast.prototype + * @param {Object} [options] Options object + * @param {Number} [options.contrast=0] Value to contrast the image up (-1...1) + */ + + /** + * Apply the Contrast operation to a Uint8Array representing the pixels of an image. + * + * @param {Object} options + * @param {ImageData} options.imageData The Uint8Array to be filtered. + */ + applyTo2d: function(options) { + if (this.contrast === 0) { + return; + } + var imageData = options.imageData, i, len, + data = imageData.data, len = data.length, + contrast = Math.floor(this.contrast * 255), + contrastF = 259 * (contrast + 255) / (255 * (259 - contrast)); + + for (i = 0; i < len; i += 4) { + data[i] = contrastF * (data[i] - 128) + 128; + data[i + 1] = contrastF * (data[i + 1] - 128) + 128; + data[i + 2] = contrastF * (data[i + 2] - 128) + 128; + } + }, + + /** + * Return WebGL uniform locations for this filter's shader. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {WebGLShaderProgram} program This filter's compiled shader program. + */ + getUniformLocations: function(gl, program) { + return { + uContrast: gl.getUniformLocation(program, 'uContrast'), + }; + }, + + /** + * Send data from this filter to its shader program's uniforms. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects + */ + sendUniformData: function(gl, uniformLocations) { + gl.uniform1f(uniformLocations.uContrast, this.contrast); + }, + }); + + /** + * Returns filter instance from an object representation + * @static + * @param {Object} object Object to create an instance from + * @param {function} [callback] to be invoked after filter creation + * @return {fabric.Image.filters.Contrast} Instance of fabric.Image.filters.Contrast + */ + fabric.Image.filters.Contrast.fromObject = fabric.Image.filters.BaseFilter.fromObject; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + filters = fabric.Image.filters, + createClass = fabric.util.createClass; + + /** + * Saturate filter class + * @class fabric.Image.filters.Saturation + * @memberOf fabric.Image.filters + * @extends fabric.Image.filters.BaseFilter + * @see {@link fabric.Image.filters.Saturation#initialize} for constructor definition + * @see {@link http://fabricjs.com/image-filters|ImageFilters demo} + * @example + * var filter = new fabric.Image.filters.Saturation({ + * saturation: 1 + * }); + * object.filters.push(filter); + * object.applyFilters(); + */ + filters.Saturation = createClass(filters.BaseFilter, /** @lends fabric.Image.filters.Saturation.prototype */ { + + /** + * Filter type + * @param {String} type + * @default + */ + type: 'Saturation', + + fragmentSource: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform float uSaturation;\n' + + 'varying vec2 vTexCoord;\n' + + 'void main() {\n' + + 'vec4 color = texture2D(uTexture, vTexCoord);\n' + + 'float rgMax = max(color.r, color.g);\n' + + 'float rgbMax = max(rgMax, color.b);\n' + + 'color.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;\n' + + 'color.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;\n' + + 'color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;\n' + + 'gl_FragColor = color;\n' + + '}', + + /** + * Saturation value, from -1 to 1. + * Increases/decreases the color saturation. + * A value of 0 has no effect. + * + * @param {Number} saturation + * @default + */ + saturation: 0, + + mainParameter: 'saturation', + + /** + * Constructor + * @memberOf fabric.Image.filters.Saturate.prototype + * @param {Object} [options] Options object + * @param {Number} [options.saturate=0] Value to saturate the image (-1...1) + */ + + /** + * Apply the Saturation operation to a Uint8ClampedArray representing the pixels of an image. + * + * @param {Object} options + * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered. + */ + applyTo2d: function(options) { + if (this.saturation === 0) { + return; + } + var imageData = options.imageData, + data = imageData.data, len = data.length, + adjust = -this.saturation, i, max; + + for (i = 0; i < len; i += 4) { + max = Math.max(data[i], data[i + 1], data[i + 2]); + data[i] += max !== data[i] ? (max - data[i]) * adjust : 0; + data[i + 1] += max !== data[i + 1] ? (max - data[i + 1]) * adjust : 0; + data[i + 2] += max !== data[i + 2] ? (max - data[i + 2]) * adjust : 0; + } + }, + + /** + * Return WebGL uniform locations for this filter's shader. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {WebGLShaderProgram} program This filter's compiled shader program. + */ + getUniformLocations: function(gl, program) { + return { + uSaturation: gl.getUniformLocation(program, 'uSaturation'), + }; + }, + + /** + * Send data from this filter to its shader program's uniforms. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects + */ + sendUniformData: function(gl, uniformLocations) { + gl.uniform1f(uniformLocations.uSaturation, -this.saturation); + }, + }); + + /** + * Returns filter instance from an object representation + * @static + * @param {Object} object Object to create an instance from + * @param {Function} [callback] to be invoked after filter creation + * @return {fabric.Image.filters.Saturation} Instance of fabric.Image.filters.Saturate + */ + fabric.Image.filters.Saturation.fromObject = fabric.Image.filters.BaseFilter.fromObject; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + filters = fabric.Image.filters, + createClass = fabric.util.createClass; + + /** + * Vibrance filter class + * @class fabric.Image.filters.Vibrance + * @memberOf fabric.Image.filters + * @extends fabric.Image.filters.BaseFilter + * @see {@link fabric.Image.filters.Vibrance#initialize} for constructor definition + * @see {@link http://fabricjs.com/image-filters|ImageFilters demo} + * @example + * var filter = new fabric.Image.filters.Vibrance({ + * vibrance: 1 + * }); + * object.filters.push(filter); + * object.applyFilters(); + */ + filters.Vibrance = createClass(filters.BaseFilter, /** @lends fabric.Image.filters.Vibrance.prototype */ { + + /** + * Filter type + * @param {String} type + * @default + */ + type: 'Vibrance', + + fragmentSource: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform float uVibrance;\n' + + 'varying vec2 vTexCoord;\n' + + 'void main() {\n' + + 'vec4 color = texture2D(uTexture, vTexCoord);\n' + + 'float max = max(color.r, max(color.g, color.b));\n' + + 'float avg = (color.r + color.g + color.b) / 3.0;\n' + + 'float amt = (abs(max - avg) * 2.0) * uVibrance;\n' + + 'color.r += max != color.r ? (max - color.r) * amt : 0.00;\n' + + 'color.g += max != color.g ? (max - color.g) * amt : 0.00;\n' + + 'color.b += max != color.b ? (max - color.b) * amt : 0.00;\n' + + 'gl_FragColor = color;\n' + + '}', + + /** + * Vibrance value, from -1 to 1. + * Increases/decreases the saturation of more muted colors with less effect on saturated colors. + * A value of 0 has no effect. + * + * @param {Number} vibrance + * @default + */ + vibrance: 0, + + mainParameter: 'vibrance', + + /** + * Constructor + * @memberOf fabric.Image.filters.Vibrance.prototype + * @param {Object} [options] Options object + * @param {Number} [options.vibrance=0] Vibrance value for the image (between -1 and 1) + */ + + /** + * Apply the Vibrance operation to a Uint8ClampedArray representing the pixels of an image. + * + * @param {Object} options + * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered. + */ + applyTo2d: function(options) { + if (this.vibrance === 0) { + return; + } + var imageData = options.imageData, + data = imageData.data, len = data.length, + adjust = -this.vibrance, i, max, avg, amt; + + for (i = 0; i < len; i += 4) { + max = Math.max(data[i], data[i + 1], data[i + 2]); + avg = (data[i] + data[i + 1] + data[i + 2]) / 3; + amt = ((Math.abs(max - avg) * 2 / 255) * adjust); + data[i] += max !== data[i] ? (max - data[i]) * amt : 0; + data[i + 1] += max !== data[i + 1] ? (max - data[i + 1]) * amt : 0; + data[i + 2] += max !== data[i + 2] ? (max - data[i + 2]) * amt : 0; + } + }, + + /** + * Return WebGL uniform locations for this filter's shader. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {WebGLShaderProgram} program This filter's compiled shader program. + */ + getUniformLocations: function(gl, program) { + return { + uVibrance: gl.getUniformLocation(program, 'uVibrance'), + }; + }, + + /** + * Send data from this filter to its shader program's uniforms. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects + */ + sendUniformData: function(gl, uniformLocations) { + gl.uniform1f(uniformLocations.uVibrance, -this.vibrance); + }, + }); + + /** + * Returns filter instance from an object representation + * @static + * @param {Object} object Object to create an instance from + * @param {Function} [callback] to be invoked after filter creation + * @return {fabric.Image.filters.Vibrance} Instance of fabric.Image.filters.Vibrance + */ + fabric.Image.filters.Vibrance.fromObject = fabric.Image.filters.BaseFilter.fromObject; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + filters = fabric.Image.filters, + createClass = fabric.util.createClass; + + /** + * Blur filter class + * @class fabric.Image.filters.Blur + * @memberOf fabric.Image.filters + * @extends fabric.Image.filters.BaseFilter + * @see {@link fabric.Image.filters.Blur#initialize} for constructor definition + * @see {@link http://fabricjs.com/image-filters|ImageFilters demo} + * @example + * var filter = new fabric.Image.filters.Blur({ + * blur: 0.5 + * }); + * object.filters.push(filter); + * object.applyFilters(); + * canvas.renderAll(); + */ + filters.Blur = createClass(filters.BaseFilter, /** @lends fabric.Image.filters.Blur.prototype */ { + + type: 'Blur', + + /* +'gl_FragColor = vec4(0.0);', +'gl_FragColor += texture2D(texture, vTexCoord + -7 * uDelta)*0.0044299121055113265;', +'gl_FragColor += texture2D(texture, vTexCoord + -6 * uDelta)*0.00895781211794;', +'gl_FragColor += texture2D(texture, vTexCoord + -5 * uDelta)*0.0215963866053;', +'gl_FragColor += texture2D(texture, vTexCoord + -4 * uDelta)*0.0443683338718;', +'gl_FragColor += texture2D(texture, vTexCoord + -3 * uDelta)*0.0776744219933;', +'gl_FragColor += texture2D(texture, vTexCoord + -2 * uDelta)*0.115876621105;', +'gl_FragColor += texture2D(texture, vTexCoord + -1 * uDelta)*0.147308056121;', +'gl_FragColor += texture2D(texture, vTexCoord )*0.159576912161;', +'gl_FragColor += texture2D(texture, vTexCoord + 1 * uDelta)*0.147308056121;', +'gl_FragColor += texture2D(texture, vTexCoord + 2 * uDelta)*0.115876621105;', +'gl_FragColor += texture2D(texture, vTexCoord + 3 * uDelta)*0.0776744219933;', +'gl_FragColor += texture2D(texture, vTexCoord + 4 * uDelta)*0.0443683338718;', +'gl_FragColor += texture2D(texture, vTexCoord + 5 * uDelta)*0.0215963866053;', +'gl_FragColor += texture2D(texture, vTexCoord + 6 * uDelta)*0.00895781211794;', +'gl_FragColor += texture2D(texture, vTexCoord + 7 * uDelta)*0.0044299121055113265;', +*/ + + /* eslint-disable max-len */ + fragmentSource: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform vec2 uDelta;\n' + + 'varying vec2 vTexCoord;\n' + + 'const float nSamples = 15.0;\n' + + 'vec3 v3offset = vec3(12.9898, 78.233, 151.7182);\n' + + 'float random(vec3 scale) {\n' + + /* use the fragment position for a different seed per-pixel */ + 'return fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);\n' + + '}\n' + + 'void main() {\n' + + 'vec4 color = vec4(0.0);\n' + + 'float total = 0.0;\n' + + 'float offset = random(v3offset);\n' + + 'for (float t = -nSamples; t <= nSamples; t++) {\n' + + 'float percent = (t + offset - 0.5) / nSamples;\n' + + 'float weight = 1.0 - abs(percent);\n' + + 'color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\n' + + 'total += weight;\n' + + '}\n' + + 'gl_FragColor = color / total;\n' + + '}', + /* eslint-enable max-len */ + + /** + * blur value, in percentage of image dimensions. + * specific to keep the image blur constant at different resolutions + * range between 0 and 1. + * @type Number + * @default + */ + blur: 0, + + mainParameter: 'blur', + + applyTo: function(options) { + if (options.webgl) { + // this aspectRatio is used to give the same blur to vertical and horizontal + this.aspectRatio = options.sourceWidth / options.sourceHeight; + options.passes++; + this._setupFrameBuffer(options); + this.horizontal = true; + this.applyToWebGL(options); + this._swapTextures(options); + this._setupFrameBuffer(options); + this.horizontal = false; + this.applyToWebGL(options); + this._swapTextures(options); + } + else { + this.applyTo2d(options); + } + }, + + applyTo2d: function(options) { + // paint canvasEl with current image data. + //options.ctx.putImageData(options.imageData, 0, 0); + options.imageData = this.simpleBlur(options); + }, + + simpleBlur: function(options) { + var resources = options.filterBackend.resources, canvas1, canvas2, + width = options.imageData.width, + height = options.imageData.height; + + if (!resources.blurLayer1) { + resources.blurLayer1 = fabric.util.createCanvasElement(); + resources.blurLayer2 = fabric.util.createCanvasElement(); + } + canvas1 = resources.blurLayer1; + canvas2 = resources.blurLayer2; + if (canvas1.width !== width || canvas1.height !== height) { + canvas2.width = canvas1.width = width; + canvas2.height = canvas1.height = height; + } + var ctx1 = canvas1.getContext('2d'), + ctx2 = canvas2.getContext('2d'), + nSamples = 15, + random, percent, j, i, + blur = this.blur * 0.06 * 0.5; + + // load first canvas + ctx1.putImageData(options.imageData, 0, 0); + ctx2.clearRect(0, 0, width, height); + + for (i = -nSamples; i <= nSamples; i++) { + random = (Math.random() - 0.5) / 4; + percent = i / nSamples; + j = blur * percent * width + random; + ctx2.globalAlpha = 1 - Math.abs(percent); + ctx2.drawImage(canvas1, j, random); + ctx1.drawImage(canvas2, 0, 0); + ctx2.globalAlpha = 1; + ctx2.clearRect(0, 0, canvas2.width, canvas2.height); + } + for (i = -nSamples; i <= nSamples; i++) { + random = (Math.random() - 0.5) / 4; + percent = i / nSamples; + j = blur * percent * height + random; + ctx2.globalAlpha = 1 - Math.abs(percent); + ctx2.drawImage(canvas1, random, j); + ctx1.drawImage(canvas2, 0, 0); + ctx2.globalAlpha = 1; + ctx2.clearRect(0, 0, canvas2.width, canvas2.height); + } + options.ctx.drawImage(canvas1, 0, 0); + var newImageData = options.ctx.getImageData(0, 0, canvas1.width, canvas1.height); + ctx1.globalAlpha = 1; + ctx1.clearRect(0, 0, canvas1.width, canvas1.height); + return newImageData; + }, + + /** + * Return WebGL uniform locations for this filter's shader. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {WebGLShaderProgram} program This filter's compiled shader program. + */ + getUniformLocations: function(gl, program) { + return { + delta: gl.getUniformLocation(program, 'uDelta'), + }; + }, + + /** + * Send data from this filter to its shader program's uniforms. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects + */ + sendUniformData: function(gl, uniformLocations) { + var delta = this.chooseRightDelta(); + gl.uniform2fv(uniformLocations.delta, delta); + }, + + /** + * choose right value of image percentage to blur with + * @returns {Array} a numeric array with delta values + */ + chooseRightDelta: function() { + var blurScale = 1, delta = [0, 0], blur; + if (this.horizontal) { + if (this.aspectRatio > 1) { + // image is wide, i want to shrink radius horizontal + blurScale = 1 / this.aspectRatio; + } + } + else { + if (this.aspectRatio < 1) { + // image is tall, i want to shrink radius vertical + blurScale = this.aspectRatio; + } + } + blur = blurScale * this.blur * 0.12; + if (this.horizontal) { + delta[0] = blur; + } + else { + delta[1] = blur; + } + return delta; + }, + }); + + /** + * Deserialize a JSON definition of a BlurFilter into a concrete instance. + */ + filters.Blur.fromObject = fabric.Image.filters.BaseFilter.fromObject; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + filters = fabric.Image.filters, + createClass = fabric.util.createClass; + + /** + * Gamma filter class + * @class fabric.Image.filters.Gamma + * @memberOf fabric.Image.filters + * @extends fabric.Image.filters.BaseFilter + * @see {@link fabric.Image.filters.Gamma#initialize} for constructor definition + * @see {@link http://fabricjs.com/image-filters|ImageFilters demo} + * @example + * var filter = new fabric.Image.filters.Gamma({ + * gamma: [1, 0.5, 2.1] + * }); + * object.filters.push(filter); + * object.applyFilters(); + */ + filters.Gamma = createClass(filters.BaseFilter, /** @lends fabric.Image.filters.Gamma.prototype */ { + + /** + * Filter type + * @param {String} type + * @default + */ + type: 'Gamma', + + fragmentSource: 'precision highp float;\n' + + 'uniform sampler2D uTexture;\n' + + 'uniform vec3 uGamma;\n' + + 'varying vec2 vTexCoord;\n' + + 'void main() {\n' + + 'vec4 color = texture2D(uTexture, vTexCoord);\n' + + 'vec3 correction = (1.0 / uGamma);\n' + + 'color.r = pow(color.r, correction.r);\n' + + 'color.g = pow(color.g, correction.g);\n' + + 'color.b = pow(color.b, correction.b);\n' + + 'gl_FragColor = color;\n' + + 'gl_FragColor.rgb *= color.a;\n' + + '}', + + /** + * Gamma array value, from 0.01 to 2.2. + * @param {Array} gamma + * @default + */ + gamma: [1, 1, 1], + + /** + * Describe the property that is the filter parameter + * @param {String} m + * @default + */ + mainParameter: 'gamma', + + /** + * Constructor + * @param {Object} [options] Options object + */ + initialize: function(options) { + this.gamma = [1, 1, 1]; + filters.BaseFilter.prototype.initialize.call(this, options); + }, + + /** + * Apply the Gamma operation to a Uint8Array representing the pixels of an image. + * + * @param {Object} options + * @param {ImageData} options.imageData The Uint8Array to be filtered. + */ + applyTo2d: function(options) { + var imageData = options.imageData, data = imageData.data, + gamma = this.gamma, len = data.length, + rInv = 1 / gamma[0], gInv = 1 / gamma[1], + bInv = 1 / gamma[2], i; + + if (!this.rVals) { + // eslint-disable-next-line + this.rVals = new Uint8Array(256); + // eslint-disable-next-line + this.gVals = new Uint8Array(256); + // eslint-disable-next-line + this.bVals = new Uint8Array(256); + } + + // This is an optimization - pre-compute a look-up table for each color channel + // instead of performing these pow calls for each pixel in the image. + for (i = 0, len = 256; i < len; i++) { + this.rVals[i] = Math.pow(i / 255, rInv) * 255; + this.gVals[i] = Math.pow(i / 255, gInv) * 255; + this.bVals[i] = Math.pow(i / 255, bInv) * 255; + } + for (i = 0, len = data.length; i < len; i += 4) { + data[i] = this.rVals[data[i]]; + data[i + 1] = this.gVals[data[i + 1]]; + data[i + 2] = this.bVals[data[i + 2]]; + } + }, + + /** + * Return WebGL uniform locations for this filter's shader. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {WebGLShaderProgram} program This filter's compiled shader program. + */ + getUniformLocations: function(gl, program) { + return { + uGamma: gl.getUniformLocation(program, 'uGamma'), + }; + }, + + /** + * Send data from this filter to its shader program's uniforms. + * + * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader. + * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects + */ + sendUniformData: function(gl, uniformLocations) { + gl.uniform3fv(uniformLocations.uGamma, this.gamma); + }, + }); + + /** + * Returns filter instance from an object representation + * @static + * @param {Object} object Object to create an instance from + * @param {function} [callback] to be invoked after filter creation + * @return {fabric.Image.filters.Gamma} Instance of fabric.Image.filters.Gamma + */ + fabric.Image.filters.Gamma.fromObject = fabric.Image.filters.BaseFilter.fromObject; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + filters = fabric.Image.filters, + createClass = fabric.util.createClass; + + /** + * A container class that knows how to apply a sequence of filters to an input image. + */ + filters.Composed = createClass(filters.BaseFilter, /** @lends fabric.Image.filters.Composed.prototype */ { + + type: 'Composed', + + /** + * A non sparse array of filters to apply + */ + subFilters: [], + + /** + * Constructor + * @param {Object} [options] Options object + */ + initialize: function(options) { + this.callSuper('initialize', options); + // create a new array instead mutating the prototype with push + this.subFilters = this.subFilters.slice(0); + }, + + /** + * Apply this container's filters to the input image provided. + * + * @param {Object} options + * @param {Number} options.passes The number of filters remaining to be applied. + */ + applyTo: function(options) { + options.passes += this.subFilters.length - 1; + this.subFilters.forEach(function(filter) { + filter.applyTo(options); + }); + }, + + /** + * Serialize this filter into JSON. + * + * @returns {Object} A JSON representation of this filter. + */ + toObject: function() { + return fabric.util.object.extend(this.callSuper('toObject'), { + subFilters: this.subFilters.map(function(filter) { return filter.toObject(); }), + }); + }, + + isNeutralState: function() { + return !this.subFilters.some(function(filter) { return !filter.isNeutralState(); }); + } + }); + + /** + * Deserialize a JSON definition of a ComposedFilter into a concrete instance. + */ + fabric.Image.filters.Composed.fromObject = function(object, callback) { + var filters = object.subFilters || [], + subFilters = filters.map(function(filter) { + return new fabric.Image.filters[filter.type](filter); + }), + instance = new fabric.Image.filters.Composed({ subFilters: subFilters }); + callback && callback(instance); + return instance; + }; +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + filters = fabric.Image.filters, + createClass = fabric.util.createClass; + + /** + * HueRotation filter class + * @class fabric.Image.filters.HueRotation + * @memberOf fabric.Image.filters + * @extends fabric.Image.filters.BaseFilter + * @see {@link fabric.Image.filters.HueRotation#initialize} for constructor definition + * @see {@link http://fabricjs.com/image-filters|ImageFilters demo} + * @example + * var filter = new fabric.Image.filters.HueRotation({ + * rotation: -0.5 + * }); + * object.filters.push(filter); + * object.applyFilters(); + */ + filters.HueRotation = createClass(filters.ColorMatrix, /** @lends fabric.Image.filters.HueRotation.prototype */ { + + /** + * Filter type + * @param {String} type + * @default + */ + type: 'HueRotation', + + /** + * HueRotation value, from -1 to 1. + * the unit is radians + * @param {Number} myParameter + * @default + */ + rotation: 0, + + /** + * Describe the property that is the filter parameter + * @param {String} m + * @default + */ + mainParameter: 'rotation', + + calculateMatrix: function() { + var rad = this.rotation * Math.PI, cos = fabric.util.cos(rad), sin = fabric.util.sin(rad), + aThird = 1 / 3, aThirdSqtSin = Math.sqrt(aThird) * sin, OneMinusCos = 1 - cos; + this.matrix = [ + 1, 0, 0, 0, 0, + 0, 1, 0, 0, 0, + 0, 0, 1, 0, 0, + 0, 0, 0, 1, 0 + ]; + this.matrix[0] = cos + OneMinusCos / 3; + this.matrix[1] = aThird * OneMinusCos - aThirdSqtSin; + this.matrix[2] = aThird * OneMinusCos + aThirdSqtSin; + this.matrix[5] = aThird * OneMinusCos + aThirdSqtSin; + this.matrix[6] = cos + aThird * OneMinusCos; + this.matrix[7] = aThird * OneMinusCos - aThirdSqtSin; + this.matrix[10] = aThird * OneMinusCos - aThirdSqtSin; + this.matrix[11] = aThird * OneMinusCos + aThirdSqtSin; + this.matrix[12] = cos + aThird * OneMinusCos; + }, + + /** + * HueRotation isNeutralState implementation + * Used only in image applyFilters to discard filters that will not have an effect + * on the image + * @param {Object} options + **/ + isNeutralState: function(options) { + this.calculateMatrix(); + return filters.BaseFilter.prototype.isNeutralState.call(this, options); + }, + + /** + * Apply this filter to the input image data provided. + * + * Determines whether to use WebGL or Canvas2D based on the options.webgl flag. + * + * @param {Object} options + * @param {Number} options.passes The number of filters remaining to be executed + * @param {Boolean} options.webgl Whether to use webgl to render the filter. + * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered. + * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn. + * @param {WebGLRenderingContext} options.context The GL context used for rendering. + * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type. + */ + applyTo: function(options) { + this.calculateMatrix(); + filters.BaseFilter.prototype.applyTo.call(this, options); + }, + + }); + + /** + * Returns filter instance from an object representation + * @static + * @param {Object} object Object to create an instance from + * @param {function} [callback] to be invoked after filter creation + * @return {fabric.Image.filters.HueRotation} Instance of fabric.Image.filters.HueRotation + */ + fabric.Image.filters.HueRotation.fromObject = fabric.Image.filters.BaseFilter.fromObject; + +})(typeof exports !== 'undefined' ? exports : this); + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = { }), + clone = fabric.util.object.clone; + + if (fabric.Text) { + fabric.warn('fabric.Text is already defined'); + return; + } + + var additionalProps = + ('fontFamily fontWeight fontSize text underline overline linethrough' + + ' textAlign fontStyle lineHeight textBackgroundColor charSpacing styles' + + ' direction path pathStartOffset pathSide pathAlign').split(' '); + + /** + * Text class + * @class fabric.Text + * @extends fabric.Object + * @return {fabric.Text} thisArg + * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#text} + * @see {@link fabric.Text#initialize} for constructor definition + */ + fabric.Text = fabric.util.createClass(fabric.Object, /** @lends fabric.Text.prototype */ { + + /** + * Properties which when set cause object to change dimensions + * @type Array + * @private + */ + _dimensionAffectingProps: [ + 'fontSize', + 'fontWeight', + 'fontFamily', + 'fontStyle', + 'lineHeight', + 'text', + 'charSpacing', + 'textAlign', + 'styles', + 'path', + 'pathStartOffset', + 'pathSide', + 'pathAlign' + ], + + /** + * @private + */ + _reNewline: /\r?\n/, + + /** + * Use this regular expression to filter for whitespaces that is not a new line. + * Mostly used when text is 'justify' aligned. + * @private + */ + _reSpacesAndTabs: /[ \t\r]/g, + + /** + * Use this regular expression to filter for whitespace that is not a new line. + * Mostly used when text is 'justify' aligned. + * @private + */ + _reSpaceAndTab: /[ \t\r]/, + + /** + * Use this regular expression to filter consecutive groups of non spaces. + * Mostly used when text is 'justify' aligned. + * @private + */ + _reWords: /\S+/g, + + /** + * Type of an object + * @type String + * @default + */ + type: 'text', + + /** + * Font size (in pixels) + * @type Number + * @default + */ + fontSize: 40, + + /** + * Font weight (e.g. bold, normal, 400, 600, 800) + * @type {(Number|String)} + * @default + */ + fontWeight: 'normal', + + /** + * Font family + * @type String + * @default + */ + fontFamily: 'Times New Roman', + + /** + * Text decoration underline. + * @type Boolean + * @default + */ + underline: false, + + /** + * Text decoration overline. + * @type Boolean + * @default + */ + overline: false, + + /** + * Text decoration linethrough. + * @type Boolean + * @default + */ + linethrough: false, + + /** + * Text alignment. Possible values: "left", "center", "right", "justify", + * "justify-left", "justify-center" or "justify-right". + * @type String + * @default + */ + textAlign: 'left', + + /** + * Font style . Possible values: "", "normal", "italic" or "oblique". + * @type String + * @default + */ + fontStyle: 'normal', + + /** + * Line height + * @type Number + * @default + */ + lineHeight: 1.16, + + /** + * Superscript schema object (minimum overlap) + * @type {Object} + * @default + */ + superscript: { + size: 0.60, // fontSize factor + baseline: -0.35 // baseline-shift factor (upwards) + }, + + /** + * Subscript schema object (minimum overlap) + * @type {Object} + * @default + */ + subscript: { + size: 0.60, // fontSize factor + baseline: 0.11 // baseline-shift factor (downwards) + }, + + /** + * Background color of text lines + * @type String + * @default + */ + textBackgroundColor: '', + + /** + * List of properties to consider when checking if + * state of an object is changed ({@link fabric.Object#hasStateChanged}) + * as well as for history (undo/redo) purposes + * @type Array + */ + stateProperties: fabric.Object.prototype.stateProperties.concat(additionalProps), + + /** + * List of properties to consider when checking if cache needs refresh + * @type Array + */ + cacheProperties: fabric.Object.prototype.cacheProperties.concat(additionalProps), + + /** + * When defined, an object is rendered via stroke and this property specifies its color. + * Backwards incompatibility note: This property was named "strokeStyle" until v1.1.6 + * @type String + * @default + */ + stroke: null, + + /** + * Shadow object representing shadow of this shape. + * Backwards incompatibility note: This property was named "textShadow" (String) until v1.2.11 + * @type fabric.Shadow + * @default + */ + shadow: null, + + /** + * fabric.Path that the text should follow. + * since 4.6.0 the path will be drawn automatically. + * if you want to make the path visible, give it a stroke and strokeWidth or fill value + * if you want it to be hidden, assign visible = false to the path. + * This feature is in BETA, and SVG import/export is not yet supported. + * @type fabric.Path + * @example + * var textPath = new fabric.Text('Text on a path', { + * top: 150, + * left: 150, + * textAlign: 'center', + * charSpacing: -50, + * path: new fabric.Path('M 0 0 C 50 -100 150 -100 200 0', { + * strokeWidth: 1, + * visible: false + * }), + * pathSide: 'left', + * pathStartOffset: 0 + * }); + * @default + */ + path: null, + + /** + * Offset amount for text path starting position + * Only used when text has a path + * @type Number + * @default + */ + pathStartOffset: 0, + + /** + * Which side of the path the text should be drawn on. + * Only used when text has a path + * @type {String} 'left|right' + * @default + */ + pathSide: 'left', + + /** + * How text is aligned to the path. This property determines + * the perpendicular position of each character relative to the path. + * (one of "baseline", "center", "ascender", "descender") + * This feature is in BETA, and its behavior may change + * @type String + * @default + */ + pathAlign: 'baseline', + + /** + * @private + */ + _fontSizeFraction: 0.222, + + /** + * @private + */ + offsets: { + underline: 0.10, + linethrough: -0.315, + overline: -0.88 + }, + + /** + * Text Line proportion to font Size (in pixels) + * @type Number + * @default + */ + _fontSizeMult: 1.13, + + /** + * additional space between characters + * expressed in thousands of em unit + * @type Number + * @default + */ + charSpacing: 0, + + /** + * Object containing character styles - top-level properties -> line numbers, + * 2nd-level properties - character numbers + * @type Object + * @default + */ + styles: null, + + /** + * Reference to a context to measure text char or couple of chars + * the cacheContext of the canvas will be used or a freshly created one if the object is not on canvas + * once created it will be referenced on fabric._measuringContext to avoid creating a canvas for every + * text object created. + * @type {CanvasRenderingContext2D} + * @default + */ + _measuringContext: null, + + /** + * Baseline shift, styles only, keep at 0 for the main text object + * @type {Number} + * @default + */ + deltaY: 0, + + /** + * WARNING: EXPERIMENTAL. NOT SUPPORTED YET + * determine the direction of the text. + * This has to be set manually together with textAlign and originX for proper + * experience. + * some interesting link for the future + * https://www.w3.org/International/questions/qa-bidi-unicode-controls + * @since 4.5.0 + * @type {String} 'ltr|rtl' + * @default + */ + direction: 'ltr', + + /** + * Array of properties that define a style unit (of 'styles'). + * @type {Array} + * @default + */ + _styleProperties: [ + 'stroke', + 'strokeWidth', + 'fill', + 'fontFamily', + 'fontSize', + 'fontWeight', + 'fontStyle', + 'underline', + 'overline', + 'linethrough', + 'deltaY', + 'textBackgroundColor', + ], + + /** + * contains characters bounding boxes + */ + __charBounds: [], + + /** + * use this size when measuring text. To avoid IE11 rounding errors + * @type {Number} + * @default + * @readonly + * @private + */ + CACHE_FONT_SIZE: 400, + + /** + * contains the min text width to avoid getting 0 + * @type {Number} + * @default + */ + MIN_TEXT_WIDTH: 2, + + /** + * Constructor + * @param {String} text Text string + * @param {Object} [options] Options object + * @return {fabric.Text} thisArg + */ + initialize: function(text, options) { + this.styles = options ? (options.styles || { }) : { }; + this.text = text; + this.__skipDimension = true; + this.callSuper('initialize', options); + if (this.path) { + this.setPathInfo(); + } + this.__skipDimension = false; + this.initDimensions(); + this.setCoords(); + this.setupState({ propertySet: '_dimensionAffectingProps' }); + }, + + /** + * If text has a path, it will add the extra information needed + * for path and text calculations + * @return {fabric.Text} thisArg + */ + setPathInfo: function() { + var path = this.path; + if (path) { + path.segmentsInfo = fabric.util.getPathSegmentsInfo(path.path); + } + }, + + /** + * Return a context for measurement of text string. + * if created it gets stored for reuse + * this is for internal use, please do not use it + * @private + * @param {String} text Text string + * @param {Object} [options] Options object + * @return {fabric.Text} thisArg + */ + getMeasuringContext: function() { + // if we did not return we have to measure something. + if (!fabric._measuringContext) { + fabric._measuringContext = this.canvas && this.canvas.contextCache || + fabric.util.createCanvasElement().getContext('2d'); + } + return fabric._measuringContext; + }, + + /** + * @private + * Divides text into lines of text and lines of graphemes. + */ + _splitText: function() { + var newLines = this._splitTextIntoLines(this.text); + this.textLines = newLines.lines; + this._textLines = newLines.graphemeLines; + this._unwrappedTextLines = newLines._unwrappedLines; + this._text = newLines.graphemeText; + return newLines; + }, + + /** + * Initialize or update text dimensions. + * Updates this.width and this.height with the proper values. + * Does not return dimensions. + */ + initDimensions: function() { + if (this.__skipDimension) { + return; + } + this._splitText(); + this._clearCache(); + if (this.path) { + this.width = this.path.width; + this.height = this.path.height; + } + else { + this.width = this.calcTextWidth() || this.cursorWidth || this.MIN_TEXT_WIDTH; + this.height = this.calcTextHeight(); + } + if (this.textAlign.indexOf('justify') !== -1) { + // once text is measured we need to make space fatter to make justified text. + this.enlargeSpaces(); + } + this.saveState({ propertySet: '_dimensionAffectingProps' }); + }, + + /** + * Enlarge space boxes and shift the others + */ + enlargeSpaces: function() { + var diffSpace, currentLineWidth, numberOfSpaces, accumulatedSpace, line, charBound, spaces; + for (var i = 0, len = this._textLines.length; i < len; i++) { + if (this.textAlign !== 'justify' && (i === len - 1 || this.isEndOfWrapping(i))) { + continue; + } + accumulatedSpace = 0; + line = this._textLines[i]; + currentLineWidth = this.getLineWidth(i); + if (currentLineWidth < this.width && (spaces = this.textLines[i].match(this._reSpacesAndTabs))) { + numberOfSpaces = spaces.length; + diffSpace = (this.width - currentLineWidth) / numberOfSpaces; + for (var j = 0, jlen = line.length; j <= jlen; j++) { + charBound = this.__charBounds[i][j]; + if (this._reSpaceAndTab.test(line[j])) { + charBound.width += diffSpace; + charBound.kernedWidth += diffSpace; + charBound.left += accumulatedSpace; + accumulatedSpace += diffSpace; + } + else { + charBound.left += accumulatedSpace; + } + } + } + } + }, + + /** + * Detect if the text line is ended with an hard break + * text and itext do not have wrapping, return false + * @return {Boolean} + */ + isEndOfWrapping: function(lineIndex) { + return lineIndex === this._textLines.length - 1; + }, + + /** + * Detect if a line has a linebreak and so we need to account for it when moving + * and counting style. + * It return always for text and Itext. + * @return Number + */ + missingNewlineOffset: function() { + return 1; + }, + + /** + * Returns string representation of an instance + * @return {String} String representation of text object + */ + toString: function() { + return '#'; + }, + + /** + * Return the dimension and the zoom level needed to create a cache canvas + * big enough to host the object to be cached. + * @private + * @param {Object} dim.x width of object to be cached + * @param {Object} dim.y height of object to be cached + * @return {Object}.width width of canvas + * @return {Object}.height height of canvas + * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache + * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache + */ + _getCacheCanvasDimensions: function() { + var dims = this.callSuper('_getCacheCanvasDimensions'); + var fontSize = this.fontSize; + dims.width += fontSize * dims.zoomX; + dims.height += fontSize * dims.zoomY; + return dims; + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _render: function(ctx) { + var path = this.path; + path && !path.isNotVisible() && path._render(ctx); + this._setTextStyles(ctx); + this._renderTextLinesBackground(ctx); + this._renderTextDecoration(ctx, 'underline'); + this._renderText(ctx); + this._renderTextDecoration(ctx, 'overline'); + this._renderTextDecoration(ctx, 'linethrough'); + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _renderText: function(ctx) { + if (this.paintFirst === 'stroke') { + this._renderTextStroke(ctx); + this._renderTextFill(ctx); + } + else { + this._renderTextFill(ctx); + this._renderTextStroke(ctx); + } + }, + + /** + * Set the font parameter of the context with the object properties or with charStyle + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + * @param {Object} [charStyle] object with font style properties + * @param {String} [charStyle.fontFamily] Font Family + * @param {Number} [charStyle.fontSize] Font size in pixels. ( without px suffix ) + * @param {String} [charStyle.fontWeight] Font weight + * @param {String} [charStyle.fontStyle] Font style (italic|normal) + */ + _setTextStyles: function(ctx, charStyle, forMeasuring) { + ctx.textBaseline = 'alphabetical'; + if (this.path) { + switch (this.pathAlign) { + case 'center': + ctx.textBaseline = 'middle'; + break; + case 'ascender': + ctx.textBaseline = 'top'; + break; + case 'descender': + ctx.textBaseline = 'bottom'; + break; + } + } + ctx.font = this._getFontDeclaration(charStyle, forMeasuring); + }, + + /** + * calculate and return the text Width measuring each line. + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + * @return {Number} Maximum width of fabric.Text object + */ + calcTextWidth: function() { + var maxWidth = this.getLineWidth(0); + + for (var i = 1, len = this._textLines.length; i < len; i++) { + var currentLineWidth = this.getLineWidth(i); + if (currentLineWidth > maxWidth) { + maxWidth = currentLineWidth; + } + } + return maxWidth; + }, + + /** + * @private + * @param {String} method Method name ("fillText" or "strokeText") + * @param {CanvasRenderingContext2D} ctx Context to render on + * @param {String} line Text to render + * @param {Number} left Left position of text + * @param {Number} top Top position of text + * @param {Number} lineIndex Index of a line in a text + */ + _renderTextLine: function(method, ctx, line, left, top, lineIndex) { + this._renderChars(method, ctx, line, left, top, lineIndex); + }, + + /** + * Renders the text background for lines, taking care of style + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _renderTextLinesBackground: function(ctx) { + if (!this.textBackgroundColor && !this.styleHas('textBackgroundColor')) { + return; + } + var heightOfLine, + lineLeftOffset, originalFill = ctx.fillStyle, + line, lastColor, + leftOffset = this._getLeftOffset(), + lineTopOffset = this._getTopOffset(), + boxStart = 0, boxWidth = 0, charBox, currentColor, path = this.path, + drawStart; + + for (var i = 0, len = this._textLines.length; i < len; i++) { + heightOfLine = this.getHeightOfLine(i); + if (!this.textBackgroundColor && !this.styleHas('textBackgroundColor', i)) { + lineTopOffset += heightOfLine; + continue; + } + line = this._textLines[i]; + lineLeftOffset = this._getLineLeftOffset(i); + boxWidth = 0; + boxStart = 0; + lastColor = this.getValueOfPropertyAt(i, 0, 'textBackgroundColor'); + for (var j = 0, jlen = line.length; j < jlen; j++) { + charBox = this.__charBounds[i][j]; + currentColor = this.getValueOfPropertyAt(i, j, 'textBackgroundColor'); + if (path) { + ctx.save(); + ctx.translate(charBox.renderLeft, charBox.renderTop); + ctx.rotate(charBox.angle); + ctx.fillStyle = currentColor; + currentColor && ctx.fillRect( + -charBox.width / 2, + -heightOfLine / this.lineHeight * (1 - this._fontSizeFraction), + charBox.width, + heightOfLine / this.lineHeight + ); + ctx.restore(); + } + else if (currentColor !== lastColor) { + drawStart = leftOffset + lineLeftOffset + boxStart; + if (this.direction === 'rtl') { + drawStart = this.width - drawStart - boxWidth; + } + ctx.fillStyle = lastColor; + lastColor && ctx.fillRect( + drawStart, + lineTopOffset, + boxWidth, + heightOfLine / this.lineHeight + ); + boxStart = charBox.left; + boxWidth = charBox.width; + lastColor = currentColor; + } + else { + boxWidth += charBox.kernedWidth; + } + } + if (currentColor && !path) { + drawStart = leftOffset + lineLeftOffset + boxStart; + if (this.direction === 'rtl') { + drawStart = this.width - drawStart - boxWidth; + } + ctx.fillStyle = currentColor; + ctx.fillRect( + drawStart, + lineTopOffset, + boxWidth, + heightOfLine / this.lineHeight + ); + } + lineTopOffset += heightOfLine; + } + ctx.fillStyle = originalFill; + // if there is text background color no + // other shadows should be casted + this._removeShadow(ctx); + }, + + /** + * @private + * @param {Object} decl style declaration for cache + * @param {String} decl.fontFamily fontFamily + * @param {String} decl.fontStyle fontStyle + * @param {String} decl.fontWeight fontWeight + * @return {Object} reference to cache + */ + getFontCache: function(decl) { + var fontFamily = decl.fontFamily.toLowerCase(); + if (!fabric.charWidthsCache[fontFamily]) { + fabric.charWidthsCache[fontFamily] = { }; + } + var cache = fabric.charWidthsCache[fontFamily], + cacheProp = decl.fontStyle.toLowerCase() + '_' + (decl.fontWeight + '').toLowerCase(); + if (!cache[cacheProp]) { + cache[cacheProp] = { }; + } + return cache[cacheProp]; + }, + + /** + * measure and return the width of a single character. + * possibly overridden to accommodate different measure logic or + * to hook some external lib for character measurement + * @private + * @param {String} _char, char to be measured + * @param {Object} charStyle style of char to be measured + * @param {String} [previousChar] previous char + * @param {Object} [prevCharStyle] style of previous char + */ + _measureChar: function(_char, charStyle, previousChar, prevCharStyle) { + // first i try to return from cache + var fontCache = this.getFontCache(charStyle), fontDeclaration = this._getFontDeclaration(charStyle), + previousFontDeclaration = this._getFontDeclaration(prevCharStyle), couple = previousChar + _char, + stylesAreEqual = fontDeclaration === previousFontDeclaration, width, coupleWidth, previousWidth, + fontMultiplier = charStyle.fontSize / this.CACHE_FONT_SIZE, kernedWidth; + + if (previousChar && fontCache[previousChar] !== undefined) { + previousWidth = fontCache[previousChar]; + } + if (fontCache[_char] !== undefined) { + kernedWidth = width = fontCache[_char]; + } + if (stylesAreEqual && fontCache[couple] !== undefined) { + coupleWidth = fontCache[couple]; + kernedWidth = coupleWidth - previousWidth; + } + if (width === undefined || previousWidth === undefined || coupleWidth === undefined) { + var ctx = this.getMeasuringContext(); + // send a TRUE to specify measuring font size CACHE_FONT_SIZE + this._setTextStyles(ctx, charStyle, true); + } + if (width === undefined) { + kernedWidth = width = ctx.measureText(_char).width; + fontCache[_char] = width; + } + if (previousWidth === undefined && stylesAreEqual && previousChar) { + previousWidth = ctx.measureText(previousChar).width; + fontCache[previousChar] = previousWidth; + } + if (stylesAreEqual && coupleWidth === undefined) { + // we can measure the kerning couple and subtract the width of the previous character + coupleWidth = ctx.measureText(couple).width; + fontCache[couple] = coupleWidth; + kernedWidth = coupleWidth - previousWidth; + } + return { width: width * fontMultiplier, kernedWidth: kernedWidth * fontMultiplier }; + }, + + /** + * Computes height of character at given position + * @param {Number} line the line index number + * @param {Number} _char the character index number + * @return {Number} fontSize of the character + */ + getHeightOfChar: function(line, _char) { + return this.getValueOfPropertyAt(line, _char, 'fontSize'); + }, + + /** + * measure a text line measuring all characters. + * @param {Number} lineIndex line number + * @return {Number} Line width + */ + measureLine: function(lineIndex) { + var lineInfo = this._measureLine(lineIndex); + if (this.charSpacing !== 0) { + lineInfo.width -= this._getWidthOfCharSpacing(); + } + if (lineInfo.width < 0) { + lineInfo.width = 0; + } + return lineInfo; + }, + + /** + * measure every grapheme of a line, populating __charBounds + * @param {Number} lineIndex + * @return {Object} object.width total width of characters + * @return {Object} object.widthOfSpaces length of chars that match this._reSpacesAndTabs + */ + _measureLine: function(lineIndex) { + var width = 0, i, grapheme, line = this._textLines[lineIndex], prevGrapheme, + graphemeInfo, numOfSpaces = 0, lineBounds = new Array(line.length), + positionInPath = 0, startingPoint, totalPathLength, path = this.path, + reverse = this.pathSide === 'right'; + + this.__charBounds[lineIndex] = lineBounds; + for (i = 0; i < line.length; i++) { + grapheme = line[i]; + graphemeInfo = this._getGraphemeBox(grapheme, lineIndex, i, prevGrapheme); + lineBounds[i] = graphemeInfo; + width += graphemeInfo.kernedWidth; + prevGrapheme = grapheme; + } + // this latest bound box represent the last character of the line + // to simplify cursor handling in interactive mode. + lineBounds[i] = { + left: graphemeInfo ? graphemeInfo.left + graphemeInfo.width : 0, + width: 0, + kernedWidth: 0, + height: this.fontSize + }; + if (path) { + totalPathLength = path.segmentsInfo[path.segmentsInfo.length - 1].length; + startingPoint = fabric.util.getPointOnPath(path.path, 0, path.segmentsInfo); + startingPoint.x += path.pathOffset.x; + startingPoint.y += path.pathOffset.y; + switch (this.textAlign) { + case 'left': + positionInPath = reverse ? (totalPathLength - width) : 0; + break; + case 'center': + positionInPath = (totalPathLength - width) / 2; + break; + case 'right': + positionInPath = reverse ? 0 : (totalPathLength - width); + break; + //todo - add support for justify + } + positionInPath += this.pathStartOffset * (reverse ? -1 : 1); + for (i = reverse ? line.length - 1 : 0; + reverse ? i >= 0 : i < line.length; + reverse ? i-- : i++) { + graphemeInfo = lineBounds[i]; + if (positionInPath > totalPathLength) { + positionInPath %= totalPathLength; + } + else if (positionInPath < 0) { + positionInPath += totalPathLength; + } + // it would probably much faster to send all the grapheme position for a line + // and calculate path position/angle at once. + this._setGraphemeOnPath(positionInPath, graphemeInfo, startingPoint); + positionInPath += graphemeInfo.kernedWidth; + } + } + return { width: width, numOfSpaces: numOfSpaces }; + }, + + /** + * Calculate the angle and the left,top position of the char that follow a path. + * It appends it to graphemeInfo to be reused later at rendering + * @private + * @param {Number} positionInPath to be measured + * @param {Object} graphemeInfo current grapheme box information + * @param {Object} startingPoint position of the point + */ + _setGraphemeOnPath: function(positionInPath, graphemeInfo, startingPoint) { + var centerPosition = positionInPath + graphemeInfo.kernedWidth / 2, + path = this.path; + + // we are at currentPositionOnPath. we want to know what point on the path is. + var info = fabric.util.getPointOnPath(path.path, centerPosition, path.segmentsInfo); + graphemeInfo.renderLeft = info.x - startingPoint.x; + graphemeInfo.renderTop = info.y - startingPoint.y; + graphemeInfo.angle = info.angle + (this.pathSide === 'right' ? Math.PI : 0); + }, + + /** + * Measure and return the info of a single grapheme. + * needs the the info of previous graphemes already filled + * @private + * @param {String} grapheme to be measured + * @param {Number} lineIndex index of the line where the char is + * @param {Number} charIndex position in the line + * @param {String} [prevGrapheme] character preceding the one to be measured + */ + _getGraphemeBox: function(grapheme, lineIndex, charIndex, prevGrapheme, skipLeft) { + var style = this.getCompleteStyleDeclaration(lineIndex, charIndex), + prevStyle = prevGrapheme ? this.getCompleteStyleDeclaration(lineIndex, charIndex - 1) : { }, + info = this._measureChar(grapheme, style, prevGrapheme, prevStyle), + kernedWidth = info.kernedWidth, + width = info.width, charSpacing; + + if (this.charSpacing !== 0) { + charSpacing = this._getWidthOfCharSpacing(); + width += charSpacing; + kernedWidth += charSpacing; + } + + var box = { + width: width, + left: 0, + height: style.fontSize, + kernedWidth: kernedWidth, + deltaY: style.deltaY, + }; + if (charIndex > 0 && !skipLeft) { + var previousBox = this.__charBounds[lineIndex][charIndex - 1]; + box.left = previousBox.left + previousBox.width + info.kernedWidth - info.width; + } + return box; + }, + + /** + * Calculate height of line at 'lineIndex' + * @param {Number} lineIndex index of line to calculate + * @return {Number} + */ + getHeightOfLine: function(lineIndex) { + if (this.__lineHeights[lineIndex]) { + return this.__lineHeights[lineIndex]; + } + + var line = this._textLines[lineIndex], + // char 0 is measured before the line cycle because it nneds to char + // emptylines + maxHeight = this.getHeightOfChar(lineIndex, 0); + for (var i = 1, len = line.length; i < len; i++) { + maxHeight = Math.max(this.getHeightOfChar(lineIndex, i), maxHeight); + } + + return this.__lineHeights[lineIndex] = maxHeight * this.lineHeight * this._fontSizeMult; + }, + + /** + * Calculate text box height + */ + calcTextHeight: function() { + var lineHeight, height = 0; + for (var i = 0, len = this._textLines.length; i < len; i++) { + lineHeight = this.getHeightOfLine(i); + height += (i === len - 1 ? lineHeight / this.lineHeight : lineHeight); + } + return height; + }, + + /** + * @private + * @return {Number} Left offset + */ + _getLeftOffset: function() { + return this.direction === 'ltr' ? -this.width / 2 : this.width / 2; + }, + + /** + * @private + * @return {Number} Top offset + */ + _getTopOffset: function() { + return -this.height / 2; + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + * @param {String} method Method name ("fillText" or "strokeText") + */ + _renderTextCommon: function(ctx, method) { + ctx.save(); + var lineHeights = 0, left = this._getLeftOffset(), top = this._getTopOffset(); + for (var i = 0, len = this._textLines.length; i < len; i++) { + var heightOfLine = this.getHeightOfLine(i), + maxHeight = heightOfLine / this.lineHeight, + leftOffset = this._getLineLeftOffset(i); + this._renderTextLine( + method, + ctx, + this._textLines[i], + left + leftOffset, + top + lineHeights + maxHeight, + i + ); + lineHeights += heightOfLine; + } + ctx.restore(); + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _renderTextFill: function(ctx) { + if (!this.fill && !this.styleHas('fill')) { + return; + } + + this._renderTextCommon(ctx, 'fillText'); + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _renderTextStroke: function(ctx) { + if ((!this.stroke || this.strokeWidth === 0) && this.isEmptyStyles()) { + return; + } + + if (this.shadow && !this.shadow.affectStroke) { + this._removeShadow(ctx); + } + + ctx.save(); + this._setLineDash(ctx, this.strokeDashArray); + ctx.beginPath(); + this._renderTextCommon(ctx, 'strokeText'); + ctx.closePath(); + ctx.restore(); + }, + + /** + * @private + * @param {String} method fillText or strokeText. + * @param {CanvasRenderingContext2D} ctx Context to render on + * @param {Array} line Content of the line, splitted in an array by grapheme + * @param {Number} left + * @param {Number} top + * @param {Number} lineIndex + */ + _renderChars: function(method, ctx, line, left, top, lineIndex) { + // set proper line offset + var lineHeight = this.getHeightOfLine(lineIndex), + isJustify = this.textAlign.indexOf('justify') !== -1, + actualStyle, + nextStyle, + charsToRender = '', + charBox, + boxWidth = 0, + timeToRender, + path = this.path, + shortCut = !isJustify && this.charSpacing === 0 && this.isEmptyStyles(lineIndex) && !path, + isLtr = this.direction === 'ltr', sign = this.direction === 'ltr' ? 1 : -1, + drawingLeft, currentDirection = ctx.canvas.getAttribute('dir'); + ctx.save(); + if (currentDirection !== this.direction) { + ctx.canvas.setAttribute('dir', isLtr ? 'ltr' : 'rtl'); + ctx.direction = isLtr ? 'ltr' : 'rtl'; + ctx.textAlign = isLtr ? 'left' : 'right'; + } + top -= lineHeight * this._fontSizeFraction / this.lineHeight; + if (shortCut) { + // render all the line in one pass without checking + // drawingLeft = isLtr ? left : left - this.getLineWidth(lineIndex); + this._renderChar(method, ctx, lineIndex, 0, line.join(''), left, top, lineHeight); + ctx.restore(); + return; + } + for (var i = 0, len = line.length - 1; i <= len; i++) { + timeToRender = i === len || this.charSpacing || path; + charsToRender += line[i]; + charBox = this.__charBounds[lineIndex][i]; + if (boxWidth === 0) { + left += sign * (charBox.kernedWidth - charBox.width); + boxWidth += charBox.width; + } + else { + boxWidth += charBox.kernedWidth; + } + if (isJustify && !timeToRender) { + if (this._reSpaceAndTab.test(line[i])) { + timeToRender = true; + } + } + if (!timeToRender) { + // if we have charSpacing, we render char by char + actualStyle = actualStyle || this.getCompleteStyleDeclaration(lineIndex, i); + nextStyle = this.getCompleteStyleDeclaration(lineIndex, i + 1); + timeToRender = fabric.util.hasStyleChanged(actualStyle, nextStyle, false); + } + if (timeToRender) { + if (path) { + ctx.save(); + ctx.translate(charBox.renderLeft, charBox.renderTop); + ctx.rotate(charBox.angle); + this._renderChar(method, ctx, lineIndex, i, charsToRender, -boxWidth / 2, 0, lineHeight); + ctx.restore(); + } + else { + drawingLeft = left; + this._renderChar(method, ctx, lineIndex, i, charsToRender, drawingLeft, top, lineHeight); + } + charsToRender = ''; + actualStyle = nextStyle; + left += sign * boxWidth; + boxWidth = 0; + } + } + ctx.restore(); + }, + + /** + * This function try to patch the missing gradientTransform on canvas gradients. + * transforming a context to transform the gradient, is going to transform the stroke too. + * we want to transform the gradient but not the stroke operation, so we create + * a transformed gradient on a pattern and then we use the pattern instead of the gradient. + * this method has drawbacks: is slow, is in low resolution, needs a patch for when the size + * is limited. + * @private + * @param {fabric.Gradient} filler a fabric gradient instance + * @return {CanvasPattern} a pattern to use as fill/stroke style + */ + _applyPatternGradientTransformText: function(filler) { + var pCanvas = fabric.util.createCanvasElement(), pCtx, + // TODO: verify compatibility with strokeUniform + width = this.width + this.strokeWidth, height = this.height + this.strokeWidth; + pCanvas.width = width; + pCanvas.height = height; + pCtx = pCanvas.getContext('2d'); + pCtx.beginPath(); pCtx.moveTo(0, 0); pCtx.lineTo(width, 0); pCtx.lineTo(width, height); + pCtx.lineTo(0, height); pCtx.closePath(); + pCtx.translate(width / 2, height / 2); + pCtx.fillStyle = filler.toLive(pCtx); + this._applyPatternGradientTransform(pCtx, filler); + pCtx.fill(); + return pCtx.createPattern(pCanvas, 'no-repeat'); + }, + + handleFiller: function(ctx, property, filler) { + var offsetX, offsetY; + if (filler.toLive) { + if (filler.gradientUnits === 'percentage' || filler.gradientTransform || filler.patternTransform) { + // need to transform gradient in a pattern. + // this is a slow process. If you are hitting this codepath, and the object + // is not using caching, you should consider switching it on. + // we need a canvas as big as the current object caching canvas. + offsetX = -this.width / 2; + offsetY = -this.height / 2; + ctx.translate(offsetX, offsetY); + ctx[property] = this._applyPatternGradientTransformText(filler); + return { offsetX: offsetX, offsetY: offsetY }; + } + else { + // is a simple gradient or pattern + ctx[property] = filler.toLive(ctx, this); + return this._applyPatternGradientTransform(ctx, filler); + } + } + else { + // is a color + ctx[property] = filler; + } + return { offsetX: 0, offsetY: 0 }; + }, + + _setStrokeStyles: function(ctx, decl) { + ctx.lineWidth = decl.strokeWidth; + ctx.lineCap = this.strokeLineCap; + ctx.lineDashOffset = this.strokeDashOffset; + ctx.lineJoin = this.strokeLineJoin; + ctx.miterLimit = this.strokeMiterLimit; + return this.handleFiller(ctx, 'strokeStyle', decl.stroke); + }, + + _setFillStyles: function(ctx, decl) { + return this.handleFiller(ctx, 'fillStyle', decl.fill); + }, + + /** + * @private + * @param {String} method + * @param {CanvasRenderingContext2D} ctx Context to render on + * @param {Number} lineIndex + * @param {Number} charIndex + * @param {String} _char + * @param {Number} left Left coordinate + * @param {Number} top Top coordinate + * @param {Number} lineHeight Height of the line + */ + _renderChar: function(method, ctx, lineIndex, charIndex, _char, left, top) { + var decl = this._getStyleDeclaration(lineIndex, charIndex), + fullDecl = this.getCompleteStyleDeclaration(lineIndex, charIndex), + shouldFill = method === 'fillText' && fullDecl.fill, + shouldStroke = method === 'strokeText' && fullDecl.stroke && fullDecl.strokeWidth, + fillOffsets, strokeOffsets; + + if (!shouldStroke && !shouldFill) { + return; + } + ctx.save(); + + shouldFill && (fillOffsets = this._setFillStyles(ctx, fullDecl)); + shouldStroke && (strokeOffsets = this._setStrokeStyles(ctx, fullDecl)); + + ctx.font = this._getFontDeclaration(fullDecl); + + + if (decl && decl.textBackgroundColor) { + this._removeShadow(ctx); + } + if (decl && decl.deltaY) { + top += decl.deltaY; + } + shouldFill && ctx.fillText(_char, left - fillOffsets.offsetX, top - fillOffsets.offsetY); + shouldStroke && ctx.strokeText(_char, left - strokeOffsets.offsetX, top - strokeOffsets.offsetY); + ctx.restore(); + }, + + /** + * Turns the character into a 'superior figure' (i.e. 'superscript') + * @param {Number} start selection start + * @param {Number} end selection end + * @returns {fabric.Text} thisArg + * @chainable + */ + setSuperscript: function(start, end) { + return this._setScript(start, end, this.superscript); + }, + + /** + * Turns the character into an 'inferior figure' (i.e. 'subscript') + * @param {Number} start selection start + * @param {Number} end selection end + * @returns {fabric.Text} thisArg + * @chainable + */ + setSubscript: function(start, end) { + return this._setScript(start, end, this.subscript); + }, + + /** + * Applies 'schema' at given position + * @private + * @param {Number} start selection start + * @param {Number} end selection end + * @param {Number} schema + * @returns {fabric.Text} thisArg + * @chainable + */ + _setScript: function(start, end, schema) { + var loc = this.get2DCursorLocation(start, true), + fontSize = this.getValueOfPropertyAt(loc.lineIndex, loc.charIndex, 'fontSize'), + dy = this.getValueOfPropertyAt(loc.lineIndex, loc.charIndex, 'deltaY'), + style = { fontSize: fontSize * schema.size, deltaY: dy + fontSize * schema.baseline }; + this.setSelectionStyles(style, start, end); + return this; + }, + + /** + * @private + * @param {Number} lineIndex index text line + * @return {Number} Line left offset + */ + _getLineLeftOffset: function(lineIndex) { + var lineWidth = this.getLineWidth(lineIndex), + lineDiff = this.width - lineWidth, textAlign = this.textAlign, direction = this.direction, + isEndOfWrapping, leftOffset = 0, isEndOfWrapping = this.isEndOfWrapping(lineIndex); + if (textAlign === 'justify' + || (textAlign === 'justify-center' && !isEndOfWrapping) + || (textAlign === 'justify-right' && !isEndOfWrapping) + || (textAlign === 'justify-left' && !isEndOfWrapping) + ) { + return 0; + } + if (textAlign === 'center') { + leftOffset = lineDiff / 2; + } + if (textAlign === 'right') { + leftOffset = lineDiff; + } + if (textAlign === 'justify-center') { + leftOffset = lineDiff / 2; + } + if (textAlign === 'justify-right') { + leftOffset = lineDiff; + } + if (direction === 'rtl') { + leftOffset -= lineDiff; + } + return leftOffset; + }, + + /** + * @private + */ + _clearCache: function() { + this.__lineWidths = []; + this.__lineHeights = []; + this.__charBounds = []; + }, + + /** + * @private + */ + _shouldClearDimensionCache: function() { + var shouldClear = this._forceClearCache; + shouldClear || (shouldClear = this.hasStateChanged('_dimensionAffectingProps')); + if (shouldClear) { + this.dirty = true; + this._forceClearCache = false; + } + return shouldClear; + }, + + /** + * Measure a single line given its index. Used to calculate the initial + * text bounding box. The values are calculated and stored in __lineWidths cache. + * @private + * @param {Number} lineIndex line number + * @return {Number} Line width + */ + getLineWidth: function(lineIndex) { + if (this.__lineWidths[lineIndex] !== undefined) { + return this.__lineWidths[lineIndex]; + } + + var lineInfo = this.measureLine(lineIndex); + var width = lineInfo.width; + this.__lineWidths[lineIndex] = width; + return width; + }, + + _getWidthOfCharSpacing: function() { + if (this.charSpacing !== 0) { + return this.fontSize * this.charSpacing / 1000; + } + return 0; + }, + + /** + * Retrieves the value of property at given character position + * @param {Number} lineIndex the line number + * @param {Number} charIndex the character number + * @param {String} property the property name + * @returns the value of 'property' + */ + getValueOfPropertyAt: function(lineIndex, charIndex, property) { + var charStyle = this._getStyleDeclaration(lineIndex, charIndex); + if (charStyle && typeof charStyle[property] !== 'undefined') { + return charStyle[property]; + } + return this[property]; + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _renderTextDecoration: function(ctx, type) { + if (!this[type] && !this.styleHas(type)) { + return; + } + var heightOfLine, size, _size, + lineLeftOffset, dy, _dy, + line, lastDecoration, + leftOffset = this._getLeftOffset(), + topOffset = this._getTopOffset(), top, + boxStart, boxWidth, charBox, currentDecoration, + maxHeight, currentFill, lastFill, path = this.path, + charSpacing = this._getWidthOfCharSpacing(), + offsetY = this.offsets[type]; + + for (var i = 0, len = this._textLines.length; i < len; i++) { + heightOfLine = this.getHeightOfLine(i); + if (!this[type] && !this.styleHas(type, i)) { + topOffset += heightOfLine; + continue; + } + line = this._textLines[i]; + maxHeight = heightOfLine / this.lineHeight; + lineLeftOffset = this._getLineLeftOffset(i); + boxStart = 0; + boxWidth = 0; + lastDecoration = this.getValueOfPropertyAt(i, 0, type); + lastFill = this.getValueOfPropertyAt(i, 0, 'fill'); + top = topOffset + maxHeight * (1 - this._fontSizeFraction); + size = this.getHeightOfChar(i, 0); + dy = this.getValueOfPropertyAt(i, 0, 'deltaY'); + for (var j = 0, jlen = line.length; j < jlen; j++) { + charBox = this.__charBounds[i][j]; + currentDecoration = this.getValueOfPropertyAt(i, j, type); + currentFill = this.getValueOfPropertyAt(i, j, 'fill'); + _size = this.getHeightOfChar(i, j); + _dy = this.getValueOfPropertyAt(i, j, 'deltaY'); + if (path && currentDecoration && currentFill) { + ctx.save(); + ctx.fillStyle = lastFill; + ctx.translate(charBox.renderLeft, charBox.renderTop); + ctx.rotate(charBox.angle); + ctx.fillRect( + -charBox.kernedWidth / 2, + offsetY * _size + _dy, + charBox.kernedWidth, + this.fontSize / 15 + ); + ctx.restore(); + } + else if ( + (currentDecoration !== lastDecoration || currentFill !== lastFill || _size !== size || _dy !== dy) + && boxWidth > 0 + ) { + var drawStart = leftOffset + lineLeftOffset + boxStart; + if (this.direction === 'rtl') { + drawStart = this.width - drawStart - boxWidth; + } + if (lastDecoration && lastFill) { + ctx.fillStyle = lastFill; + ctx.fillRect( + drawStart, + top + offsetY * size + dy, + boxWidth, + this.fontSize / 15 + ); + } + boxStart = charBox.left; + boxWidth = charBox.width; + lastDecoration = currentDecoration; + lastFill = currentFill; + size = _size; + dy = _dy; + } + else { + boxWidth += charBox.kernedWidth; + } + } + var drawStart = leftOffset + lineLeftOffset + boxStart; + if (this.direction === 'rtl') { + drawStart = this.width - drawStart - boxWidth; + } + ctx.fillStyle = currentFill; + currentDecoration && currentFill && ctx.fillRect( + drawStart, + top + offsetY * size + dy, + boxWidth - charSpacing, + this.fontSize / 15 + ); + topOffset += heightOfLine; + } + // if there is text background color no + // other shadows should be casted + this._removeShadow(ctx); + }, + + /** + * return font declaration string for canvas context + * @param {Object} [styleObject] object + * @returns {String} font declaration formatted for canvas context. + */ + _getFontDeclaration: function(styleObject, forMeasuring) { + var style = styleObject || this, family = this.fontFamily, + fontIsGeneric = fabric.Text.genericFonts.indexOf(family.toLowerCase()) > -1; + var fontFamily = family === undefined || + family.indexOf('\'') > -1 || family.indexOf(',') > -1 || + family.indexOf('"') > -1 || fontIsGeneric + ? style.fontFamily : '"' + style.fontFamily + '"'; + return [ + // node-canvas needs "weight style", while browsers need "style weight" + // verify if this can be fixed in JSDOM + (fabric.isLikelyNode ? style.fontWeight : style.fontStyle), + (fabric.isLikelyNode ? style.fontStyle : style.fontWeight), + forMeasuring ? this.CACHE_FONT_SIZE + 'px' : style.fontSize + 'px', + fontFamily + ].join(' '); + }, + + /** + * Renders text instance on a specified context + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + render: function(ctx) { + // do not render if object is not visible + if (!this.visible) { + return; + } + if (this.canvas && this.canvas.skipOffscreen && !this.group && !this.isOnScreen()) { + return; + } + if (this._shouldClearDimensionCache()) { + this.initDimensions(); + } + this.callSuper('render', ctx); + }, + + /** + * Returns the text as an array of lines. + * @param {String} text text to split + * @returns {Array} Lines in the text + */ + _splitTextIntoLines: function(text) { + var lines = text.split(this._reNewline), + newLines = new Array(lines.length), + newLine = ['\n'], + newText = []; + for (var i = 0; i < lines.length; i++) { + newLines[i] = fabric.util.string.graphemeSplit(lines[i]); + newText = newText.concat(newLines[i], newLine); + } + newText.pop(); + return { _unwrappedLines: newLines, lines: lines, graphemeText: newText, graphemeLines: newLines }; + }, + + /** + * Returns object representation of an instance + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} Object representation of an instance + */ + toObject: function(propertiesToInclude) { + var allProperties = additionalProps.concat(propertiesToInclude); + var obj = this.callSuper('toObject', allProperties); + obj.styles = fabric.util.stylesToArray(this.styles, this.text); + if (obj.path) { + obj.path = this.path.toObject(); + } + return obj; + }, + + /** + * Sets property to a given value. When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. If you need to update those, call `setCoords()`. + * @param {String|Object} key Property name or object (if object, iterate over the object properties) + * @param {Object|Function} value Property value (if function, the value is passed into it and its return value is used as a new one) + * @return {fabric.Object} thisArg + * @chainable + */ + set: function(key, value) { + this.callSuper('set', key, value); + var needsDims = false; + var isAddingPath = false; + if (typeof key === 'object') { + for (var _key in key) { + if (_key === 'path') { + this.setPathInfo(); + } + needsDims = needsDims || this._dimensionAffectingProps.indexOf(_key) !== -1; + isAddingPath = isAddingPath || _key === 'path'; + } + } + else { + needsDims = this._dimensionAffectingProps.indexOf(key) !== -1; + isAddingPath = key === 'path'; + } + if (isAddingPath) { + this.setPathInfo(); + } + if (needsDims) { + this.initDimensions(); + this.setCoords(); + } + return this; + }, + + /** + * Returns complexity of an instance + * @return {Number} complexity + */ + complexity: function() { + return 1; + } + }); + + /* _FROM_SVG_START_ */ + /** + * List of attribute names to account for when parsing SVG element (used by {@link fabric.Text.fromElement}) + * @static + * @memberOf fabric.Text + * @see: http://www.w3.org/TR/SVG/text.html#TextElement + */ + fabric.Text.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat( + 'x y dx dy font-family font-style font-weight font-size letter-spacing text-decoration text-anchor'.split(' ')); + + /** + * Default SVG font size + * @static + * @memberOf fabric.Text + */ + fabric.Text.DEFAULT_SVG_FONT_SIZE = 16; + + /** + * Returns fabric.Text instance from an SVG element (not yet implemented) + * @static + * @memberOf fabric.Text + * @param {SVGElement} element Element to parse + * @param {Function} callback callback function invoked after parsing + * @param {Object} [options] Options object + */ + fabric.Text.fromElement = function(element, callback, options) { + if (!element) { + return callback(null); + } + + var parsedAttributes = fabric.parseAttributes(element, fabric.Text.ATTRIBUTE_NAMES), + parsedAnchor = parsedAttributes.textAnchor || 'left'; + options = fabric.util.object.extend((options ? clone(options) : { }), parsedAttributes); + + options.top = options.top || 0; + options.left = options.left || 0; + if (parsedAttributes.textDecoration) { + var textDecoration = parsedAttributes.textDecoration; + if (textDecoration.indexOf('underline') !== -1) { + options.underline = true; + } + if (textDecoration.indexOf('overline') !== -1) { + options.overline = true; + } + if (textDecoration.indexOf('line-through') !== -1) { + options.linethrough = true; + } + delete options.textDecoration; + } + if ('dx' in parsedAttributes) { + options.left += parsedAttributes.dx; + } + if ('dy' in parsedAttributes) { + options.top += parsedAttributes.dy; + } + if (!('fontSize' in options)) { + options.fontSize = fabric.Text.DEFAULT_SVG_FONT_SIZE; + } + + var textContent = ''; + + // The XML is not properly parsed in IE9 so a workaround to get + // textContent is through firstChild.data. Another workaround would be + // to convert XML loaded from a file to be converted using DOMParser (same way loadSVGFromString() does) + if (!('textContent' in element)) { + if ('firstChild' in element && element.firstChild !== null) { + if ('data' in element.firstChild && element.firstChild.data !== null) { + textContent = element.firstChild.data; + } + } + } + else { + textContent = element.textContent; + } + + textContent = textContent.replace(/^\s+|\s+$|\n+/g, '').replace(/\s+/g, ' '); + var originalStrokeWidth = options.strokeWidth; + options.strokeWidth = 0; + + var text = new fabric.Text(textContent, options), + textHeightScaleFactor = text.getScaledHeight() / text.height, + lineHeightDiff = (text.height + text.strokeWidth) * text.lineHeight - text.height, + scaledDiff = lineHeightDiff * textHeightScaleFactor, + textHeight = text.getScaledHeight() + scaledDiff, + offX = 0; + /* + Adjust positioning: + x/y attributes in SVG correspond to the bottom-left corner of text bounding box + fabric output by default at top, left. + */ + if (parsedAnchor === 'center') { + offX = text.getScaledWidth() / 2; + } + if (parsedAnchor === 'right') { + offX = text.getScaledWidth(); + } + text.set({ + left: text.left - offX, + top: text.top - (textHeight - text.fontSize * (0.07 + text._fontSizeFraction)) / text.lineHeight, + strokeWidth: typeof originalStrokeWidth !== 'undefined' ? originalStrokeWidth : 1, + }); + callback(text); + }; + /* _FROM_SVG_END_ */ + + /** + * Returns fabric.Text instance from an object representation + * @static + * @memberOf fabric.Text + * @param {Object} object plain js Object to create an instance from + * @param {Function} [callback] Callback to invoke when an fabric.Text instance is created + */ + fabric.Text.fromObject = function(object, callback) { + var objectCopy = clone(object), path = object.path; + delete objectCopy.path; + return fabric.Object._fromObject('Text', objectCopy, function(textInstance) { + textInstance.styles = fabric.util.stylesFromArray(object.styles, object.text); + if (path) { + fabric.Object._fromObject('Path', path, function(pathInstance) { + textInstance.set('path', pathInstance); + callback(textInstance); + }, 'path'); + } + else { + callback(textInstance); + } + }, 'text'); + }; + + fabric.Text.genericFonts = ['sans-serif', 'serif', 'cursive', 'fantasy', 'monospace']; + + fabric.util.createAccessors && fabric.util.createAccessors(fabric.Text); + +})(typeof exports !== 'undefined' ? exports : this); + + +(function() { + fabric.util.object.extend(fabric.Text.prototype, /** @lends fabric.Text.prototype */ { + /** + * Returns true if object has no styling or no styling in a line + * @param {Number} lineIndex , lineIndex is on wrapped lines. + * @return {Boolean} + */ + isEmptyStyles: function(lineIndex) { + if (!this.styles) { + return true; + } + if (typeof lineIndex !== 'undefined' && !this.styles[lineIndex]) { + return true; + } + var obj = typeof lineIndex === 'undefined' ? this.styles : { line: this.styles[lineIndex] }; + for (var p1 in obj) { + for (var p2 in obj[p1]) { + // eslint-disable-next-line no-unused-vars + for (var p3 in obj[p1][p2]) { + return false; + } + } + } + return true; + }, + + /** + * Returns true if object has a style property or has it ina specified line + * This function is used to detect if a text will use a particular property or not. + * @param {String} property to check for + * @param {Number} lineIndex to check the style on + * @return {Boolean} + */ + styleHas: function(property, lineIndex) { + if (!this.styles || !property || property === '') { + return false; + } + if (typeof lineIndex !== 'undefined' && !this.styles[lineIndex]) { + return false; + } + var obj = typeof lineIndex === 'undefined' ? this.styles : { 0: this.styles[lineIndex] }; + // eslint-disable-next-line + for (var p1 in obj) { + // eslint-disable-next-line + for (var p2 in obj[p1]) { + if (typeof obj[p1][p2][property] !== 'undefined') { + return true; + } + } + } + return false; + }, + + /** + * Check if characters in a text have a value for a property + * whose value matches the textbox's value for that property. If so, + * the character-level property is deleted. If the character + * has no other properties, then it is also deleted. Finally, + * if the line containing that character has no other characters + * then it also is deleted. + * + * @param {string} property The property to compare between characters and text. + */ + cleanStyle: function(property) { + if (!this.styles || !property || property === '') { + return false; + } + var obj = this.styles, stylesCount = 0, letterCount, stylePropertyValue, + allStyleObjectPropertiesMatch = true, graphemeCount = 0, styleObject; + // eslint-disable-next-line + for (var p1 in obj) { + letterCount = 0; + // eslint-disable-next-line + for (var p2 in obj[p1]) { + var styleObject = obj[p1][p2], + stylePropertyHasBeenSet = styleObject.hasOwnProperty(property); + + stylesCount++; + + if (stylePropertyHasBeenSet) { + if (!stylePropertyValue) { + stylePropertyValue = styleObject[property]; + } + else if (styleObject[property] !== stylePropertyValue) { + allStyleObjectPropertiesMatch = false; + } + + if (styleObject[property] === this[property]) { + delete styleObject[property]; + } + } + else { + allStyleObjectPropertiesMatch = false; + } + + if (Object.keys(styleObject).length !== 0) { + letterCount++; + } + else { + delete obj[p1][p2]; + } + } + + if (letterCount === 0) { + delete obj[p1]; + } + } + // if every grapheme has the same style set then + // delete those styles and set it on the parent + for (var i = 0; i < this._textLines.length; i++) { + graphemeCount += this._textLines[i].length; + } + if (allStyleObjectPropertiesMatch && stylesCount === graphemeCount) { + this[property] = stylePropertyValue; + this.removeStyle(property); + } + }, + + /** + * Remove a style property or properties from all individual character styles + * in a text object. Deletes the character style object if it contains no other style + * props. Deletes a line style object if it contains no other character styles. + * + * @param {String} props The property to remove from character styles. + */ + removeStyle: function(property) { + if (!this.styles || !property || property === '') { + return; + } + var obj = this.styles, line, lineNum, charNum; + for (lineNum in obj) { + line = obj[lineNum]; + for (charNum in line) { + delete line[charNum][property]; + if (Object.keys(line[charNum]).length === 0) { + delete line[charNum]; + } + } + if (Object.keys(line).length === 0) { + delete obj[lineNum]; + } + } + }, + + /** + * @private + */ + _extendStyles: function(index, styles) { + var loc = this.get2DCursorLocation(index); + + if (!this._getLineStyle(loc.lineIndex)) { + this._setLineStyle(loc.lineIndex); + } + + if (!this._getStyleDeclaration(loc.lineIndex, loc.charIndex)) { + this._setStyleDeclaration(loc.lineIndex, loc.charIndex, {}); + } + + fabric.util.object.extend(this._getStyleDeclaration(loc.lineIndex, loc.charIndex), styles); + }, + + /** + * Returns 2d representation (lineIndex and charIndex) of cursor (or selection start) + * @param {Number} [selectionStart] Optional index. When not given, current selectionStart is used. + * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. useful to manage styles. + */ + get2DCursorLocation: function(selectionStart, skipWrapping) { + if (typeof selectionStart === 'undefined') { + selectionStart = this.selectionStart; + } + var lines = skipWrapping ? this._unwrappedTextLines : this._textLines, + len = lines.length; + for (var i = 0; i < len; i++) { + if (selectionStart <= lines[i].length) { + return { + lineIndex: i, + charIndex: selectionStart + }; + } + selectionStart -= lines[i].length + this.missingNewlineOffset(i); + } + return { + lineIndex: i - 1, + charIndex: lines[i - 1].length < selectionStart ? lines[i - 1].length : selectionStart + }; + }, + + /** + * Gets style of a current selection/cursor (at the start position) + * if startIndex or endIndex are not provided, selectionStart or selectionEnd will be used. + * @param {Number} [startIndex] Start index to get styles at + * @param {Number} [endIndex] End index to get styles at, if not specified selectionEnd or startIndex + 1 + * @param {Boolean} [complete] get full style or not + * @return {Array} styles an array with one, zero or more Style objects + */ + getSelectionStyles: function(startIndex, endIndex, complete) { + if (typeof startIndex === 'undefined') { + startIndex = this.selectionStart || 0; + } + if (typeof endIndex === 'undefined') { + endIndex = this.selectionEnd || startIndex; + } + var styles = []; + for (var i = startIndex; i < endIndex; i++) { + styles.push(this.getStyleAtPosition(i, complete)); + } + return styles; + }, + + /** + * Gets style of a current selection/cursor position + * @param {Number} position to get styles at + * @param {Boolean} [complete] full style if true + * @return {Object} style Style object at a specified index + * @private + */ + getStyleAtPosition: function(position, complete) { + var loc = this.get2DCursorLocation(position), + style = complete ? this.getCompleteStyleDeclaration(loc.lineIndex, loc.charIndex) : + this._getStyleDeclaration(loc.lineIndex, loc.charIndex); + return style || {}; + }, + + /** + * Sets style of a current selection, if no selection exist, do not set anything. + * @param {Object} [styles] Styles object + * @param {Number} [startIndex] Start index to get styles at + * @param {Number} [endIndex] End index to get styles at, if not specified selectionEnd or startIndex + 1 + * @return {fabric.IText} thisArg + * @chainable + */ + setSelectionStyles: function(styles, startIndex, endIndex) { + if (typeof startIndex === 'undefined') { + startIndex = this.selectionStart || 0; + } + if (typeof endIndex === 'undefined') { + endIndex = this.selectionEnd || startIndex; + } + for (var i = startIndex; i < endIndex; i++) { + this._extendStyles(i, styles); + } + /* not included in _extendStyles to avoid clearing cache more than once */ + this._forceClearCache = true; + return this; + }, + + /** + * get the reference, not a clone, of the style object for a given character + * @param {Number} lineIndex + * @param {Number} charIndex + * @return {Object} style object + */ + _getStyleDeclaration: function(lineIndex, charIndex) { + var lineStyle = this.styles && this.styles[lineIndex]; + if (!lineStyle) { + return null; + } + return lineStyle[charIndex]; + }, + + /** + * return a new object that contains all the style property for a character + * the object returned is newly created + * @param {Number} lineIndex of the line where the character is + * @param {Number} charIndex position of the character on the line + * @return {Object} style object + */ + getCompleteStyleDeclaration: function(lineIndex, charIndex) { + var style = this._getStyleDeclaration(lineIndex, charIndex) || { }, + styleObject = { }, prop; + for (var i = 0; i < this._styleProperties.length; i++) { + prop = this._styleProperties[i]; + styleObject[prop] = typeof style[prop] === 'undefined' ? this[prop] : style[prop]; + } + return styleObject; + }, + + /** + * @param {Number} lineIndex + * @param {Number} charIndex + * @param {Object} style + * @private + */ + _setStyleDeclaration: function(lineIndex, charIndex, style) { + this.styles[lineIndex][charIndex] = style; + }, + + /** + * + * @param {Number} lineIndex + * @param {Number} charIndex + * @private + */ + _deleteStyleDeclaration: function(lineIndex, charIndex) { + delete this.styles[lineIndex][charIndex]; + }, + + /** + * @param {Number} lineIndex + * @return {Boolean} if the line exists or not + * @private + */ + _getLineStyle: function(lineIndex) { + return !!this.styles[lineIndex]; + }, + + /** + * Set the line style to an empty object so that is initialized + * @param {Number} lineIndex + * @private + */ + _setLineStyle: function(lineIndex) { + this.styles[lineIndex] = {}; + }, + + /** + * @param {Number} lineIndex + * @private + */ + _deleteLineStyle: function(lineIndex) { + delete this.styles[lineIndex]; + } + }); +})(); + + +(function() { + + function parseDecoration(object) { + if (object.textDecoration) { + object.textDecoration.indexOf('underline') > -1 && (object.underline = true); + object.textDecoration.indexOf('line-through') > -1 && (object.linethrough = true); + object.textDecoration.indexOf('overline') > -1 && (object.overline = true); + delete object.textDecoration; + } + } + + /** + * IText class (introduced in v1.4) Events are also fired with "text:" + * prefix when observing canvas. + * @class fabric.IText + * @extends fabric.Text + * @mixes fabric.Observable + * + * @fires changed + * @fires selection:changed + * @fires editing:entered + * @fires editing:exited + * + * @return {fabric.IText} thisArg + * @see {@link fabric.IText#initialize} for constructor definition + * + *

                    Supported key combinations:

                    + *
                    +   *   Move cursor:                    left, right, up, down
                    +   *   Select character:               shift + left, shift + right
                    +   *   Select text vertically:         shift + up, shift + down
                    +   *   Move cursor by word:            alt + left, alt + right
                    +   *   Select words:                   shift + alt + left, shift + alt + right
                    +   *   Move cursor to line start/end:  cmd + left, cmd + right or home, end
                    +   *   Select till start/end of line:  cmd + shift + left, cmd + shift + right or shift + home, shift + end
                    +   *   Jump to start/end of text:      cmd + up, cmd + down
                    +   *   Select till start/end of text:  cmd + shift + up, cmd + shift + down or shift + pgUp, shift + pgDown
                    +   *   Delete character:               backspace
                    +   *   Delete word:                    alt + backspace
                    +   *   Delete line:                    cmd + backspace
                    +   *   Forward delete:                 delete
                    +   *   Copy text:                      ctrl/cmd + c
                    +   *   Paste text:                     ctrl/cmd + v
                    +   *   Cut text:                       ctrl/cmd + x
                    +   *   Select entire text:             ctrl/cmd + a
                    +   *   Quit editing                    tab or esc
                    +   * 
                    + * + *

                    Supported mouse/touch combination

                    + *
                    +   *   Position cursor:                click/touch
                    +   *   Create selection:               click/touch & drag
                    +   *   Create selection:               click & shift + click
                    +   *   Select word:                    double click
                    +   *   Select line:                    triple click
                    +   * 
                    + */ + fabric.IText = fabric.util.createClass(fabric.Text, fabric.Observable, /** @lends fabric.IText.prototype */ { + + /** + * Type of an object + * @type String + * @default + */ + type: 'i-text', + + /** + * Index where text selection starts (or where cursor is when there is no selection) + * @type Number + * @default + */ + selectionStart: 0, + + /** + * Index where text selection ends + * @type Number + * @default + */ + selectionEnd: 0, + + /** + * Color of text selection + * @type String + * @default + */ + selectionColor: 'rgba(17,119,255,0.3)', + + /** + * Indicates whether text is in editing mode + * @type Boolean + * @default + */ + isEditing: false, + + /** + * Indicates whether a text can be edited + * @type Boolean + * @default + */ + editable: true, + + /** + * Border color of text object while it's in editing mode + * @type String + * @default + */ + editingBorderColor: 'rgba(102,153,255,0.25)', + + /** + * Width of cursor (in px) + * @type Number + * @default + */ + cursorWidth: 2, + + /** + * Color of text cursor color in editing mode. + * if not set (default) will take color from the text. + * if set to a color value that fabric can understand, it will + * be used instead of the color of the text at the current position. + * @type String + * @default + */ + cursorColor: '', + + /** + * Delay between cursor blink (in ms) + * @type Number + * @default + */ + cursorDelay: 1000, + + /** + * Duration of cursor fadein (in ms) + * @type Number + * @default + */ + cursorDuration: 600, + + /** + * Indicates whether internal text char widths can be cached + * @type Boolean + * @default + */ + caching: true, + + /** + * DOM container to append the hiddenTextarea. + * An alternative to attaching to the document.body. + * Useful to reduce laggish redraw of the full document.body tree and + * also with modals event capturing that won't let the textarea take focus. + * @type HTMLElement + * @default + */ + hiddenTextareaContainer: null, + + /** + * @private + */ + _reSpace: /\s|\n/, + + /** + * @private + */ + _currentCursorOpacity: 0, + + /** + * @private + */ + _selectionDirection: null, + + /** + * @private + */ + _abortCursorAnimation: false, + + /** + * @private + */ + __widthOfSpace: [], + + /** + * Helps determining when the text is in composition, so that the cursor + * rendering is altered. + */ + inCompositionMode: false, + + /** + * Constructor + * @param {String} text Text string + * @param {Object} [options] Options object + * @return {fabric.IText} thisArg + */ + initialize: function(text, options) { + this.callSuper('initialize', text, options); + this.initBehavior(); + }, + + /** + * Sets selection start (left boundary of a selection) + * @param {Number} index Index to set selection start to + */ + setSelectionStart: function(index) { + index = Math.max(index, 0); + this._updateAndFire('selectionStart', index); + }, + + /** + * Sets selection end (right boundary of a selection) + * @param {Number} index Index to set selection end to + */ + setSelectionEnd: function(index) { + index = Math.min(index, this.text.length); + this._updateAndFire('selectionEnd', index); + }, + + /** + * @private + * @param {String} property 'selectionStart' or 'selectionEnd' + * @param {Number} index new position of property + */ + _updateAndFire: function(property, index) { + if (this[property] !== index) { + this._fireSelectionChanged(); + this[property] = index; + } + this._updateTextarea(); + }, + + /** + * Fires the even of selection changed + * @private + */ + _fireSelectionChanged: function() { + this.fire('selection:changed'); + this.canvas && this.canvas.fire('text:selection:changed', { target: this }); + }, + + /** + * Initialize text dimensions. Render all text on given context + * or on a offscreen canvas to get the text width with measureText. + * Updates this.width and this.height with the proper values. + * Does not return dimensions. + * @private + */ + initDimensions: function() { + this.isEditing && this.initDelayedCursor(); + this.clearContextTop(); + this.callSuper('initDimensions'); + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + render: function(ctx) { + this.clearContextTop(); + this.callSuper('render', ctx); + // clear the cursorOffsetCache, so we ensure to calculate once per renderCursor + // the correct position but not at every cursor animation. + this.cursorOffsetCache = { }; + this.renderCursorOrSelection(); + }, + + /** + * @private + * @param {CanvasRenderingContext2D} ctx Context to render on + */ + _render: function(ctx) { + this.callSuper('_render', ctx); + }, + + /** + * Prepare and clean the contextTop + */ + clearContextTop: function(skipRestore) { + if (!this.isEditing || !this.canvas || !this.canvas.contextTop) { + return; + } + var ctx = this.canvas.contextTop, v = this.canvas.viewportTransform; + ctx.save(); + ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]); + this.transform(ctx); + this._clearTextArea(ctx); + skipRestore || ctx.restore(); + }, + /** + * Renders cursor or selection (depending on what exists) + * it does on the contextTop. If contextTop is not available, do nothing. + */ + renderCursorOrSelection: function() { + if (!this.isEditing || !this.canvas || !this.canvas.contextTop) { + return; + } + var boundaries = this._getCursorBoundaries(), + ctx = this.canvas.contextTop; + this.clearContextTop(true); + if (this.selectionStart === this.selectionEnd) { + this.renderCursor(boundaries, ctx); + } + else { + this.renderSelection(boundaries, ctx); + } + ctx.restore(); + }, + + _clearTextArea: function(ctx) { + // we add 4 pixel, to be sure to do not leave any pixel out + var width = this.width + 4, height = this.height + 4; + ctx.clearRect(-width / 2, -height / 2, width, height); + }, + + /** + * Returns cursor boundaries (left, top, leftOffset, topOffset) + * @private + * @param {Array} chars Array of characters + * @param {String} typeOfBoundaries + */ + _getCursorBoundaries: function(position) { + + // left/top are left/top of entire text box + // leftOffset/topOffset are offset from that left/top point of a text box + + if (typeof position === 'undefined') { + position = this.selectionStart; + } + + var left = this._getLeftOffset(), + top = this._getTopOffset(), + offsets = this._getCursorBoundariesOffsets(position); + return { + left: left, + top: top, + leftOffset: offsets.left, + topOffset: offsets.top + }; + }, + + /** + * @private + */ + _getCursorBoundariesOffsets: function(position) { + if (this.cursorOffsetCache && 'top' in this.cursorOffsetCache) { + return this.cursorOffsetCache; + } + var lineLeftOffset, + lineIndex, + charIndex, + topOffset = 0, + leftOffset = 0, + boundaries, + cursorPosition = this.get2DCursorLocation(position); + charIndex = cursorPosition.charIndex; + lineIndex = cursorPosition.lineIndex; + for (var i = 0; i < lineIndex; i++) { + topOffset += this.getHeightOfLine(i); + } + lineLeftOffset = this._getLineLeftOffset(lineIndex); + var bound = this.__charBounds[lineIndex][charIndex]; + bound && (leftOffset = bound.left); + if (this.charSpacing !== 0 && charIndex === this._textLines[lineIndex].length) { + leftOffset -= this._getWidthOfCharSpacing(); + } + boundaries = { + top: topOffset, + left: lineLeftOffset + (leftOffset > 0 ? leftOffset : 0), + }; + if (this.direction === 'rtl') { + boundaries.left *= -1; + } + this.cursorOffsetCache = boundaries; + return this.cursorOffsetCache; + }, + + /** + * Renders cursor + * @param {Object} boundaries + * @param {CanvasRenderingContext2D} ctx transformed context to draw on + */ + renderCursor: function(boundaries, ctx) { + var cursorLocation = this.get2DCursorLocation(), + lineIndex = cursorLocation.lineIndex, + charIndex = cursorLocation.charIndex > 0 ? cursorLocation.charIndex - 1 : 0, + charHeight = this.getValueOfPropertyAt(lineIndex, charIndex, 'fontSize'), + multiplier = this.scaleX * this.canvas.getZoom(), + cursorWidth = this.cursorWidth / multiplier, + topOffset = boundaries.topOffset, + dy = this.getValueOfPropertyAt(lineIndex, charIndex, 'deltaY'); + topOffset += (1 - this._fontSizeFraction) * this.getHeightOfLine(lineIndex) / this.lineHeight + - charHeight * (1 - this._fontSizeFraction); + + if (this.inCompositionMode) { + this.renderSelection(boundaries, ctx); + } + ctx.fillStyle = this.cursorColor || this.getValueOfPropertyAt(lineIndex, charIndex, 'fill'); + ctx.globalAlpha = this.__isMousedown ? 1 : this._currentCursorOpacity; + ctx.fillRect( + boundaries.left + boundaries.leftOffset - cursorWidth / 2, + topOffset + boundaries.top + dy, + cursorWidth, + charHeight); + }, + + /** + * Renders text selection + * @param {Object} boundaries Object with left/top/leftOffset/topOffset + * @param {CanvasRenderingContext2D} ctx transformed context to draw on + */ + renderSelection: function(boundaries, ctx) { + + var selectionStart = this.inCompositionMode ? this.hiddenTextarea.selectionStart : this.selectionStart, + selectionEnd = this.inCompositionMode ? this.hiddenTextarea.selectionEnd : this.selectionEnd, + isJustify = this.textAlign.indexOf('justify') !== -1, + start = this.get2DCursorLocation(selectionStart), + end = this.get2DCursorLocation(selectionEnd), + startLine = start.lineIndex, + endLine = end.lineIndex, + startChar = start.charIndex < 0 ? 0 : start.charIndex, + endChar = end.charIndex < 0 ? 0 : end.charIndex; + + for (var i = startLine; i <= endLine; i++) { + var lineOffset = this._getLineLeftOffset(i) || 0, + lineHeight = this.getHeightOfLine(i), + realLineHeight = 0, boxStart = 0, boxEnd = 0; + + if (i === startLine) { + boxStart = this.__charBounds[startLine][startChar].left; + } + if (i >= startLine && i < endLine) { + boxEnd = isJustify && !this.isEndOfWrapping(i) ? this.width : this.getLineWidth(i) || 5; // WTF is this 5? + } + else if (i === endLine) { + if (endChar === 0) { + boxEnd = this.__charBounds[endLine][endChar].left; + } + else { + var charSpacing = this._getWidthOfCharSpacing(); + boxEnd = this.__charBounds[endLine][endChar - 1].left + + this.__charBounds[endLine][endChar - 1].width - charSpacing; + } + } + realLineHeight = lineHeight; + if (this.lineHeight < 1 || (i === endLine && this.lineHeight > 1)) { + lineHeight /= this.lineHeight; + } + var drawStart = boundaries.left + lineOffset + boxStart, + drawWidth = boxEnd - boxStart, + drawHeight = lineHeight, extraTop = 0; + if (this.inCompositionMode) { + ctx.fillStyle = this.compositionColor || 'black'; + drawHeight = 1; + extraTop = lineHeight; + } + else { + ctx.fillStyle = this.selectionColor; + } + if (this.direction === 'rtl') { + drawStart = this.width - drawStart - drawWidth; + } + ctx.fillRect( + drawStart, + boundaries.top + boundaries.topOffset + extraTop, + drawWidth, + drawHeight); + boundaries.topOffset += realLineHeight; + } + }, + + /** + * High level function to know the height of the cursor. + * the currentChar is the one that precedes the cursor + * Returns fontSize of char at the current cursor + * Unused from the library, is for the end user + * @return {Number} Character font size + */ + getCurrentCharFontSize: function() { + var cp = this._getCurrentCharIndex(); + return this.getValueOfPropertyAt(cp.l, cp.c, 'fontSize'); + }, + + /** + * High level function to know the color of the cursor. + * the currentChar is the one that precedes the cursor + * Returns color (fill) of char at the current cursor + * if the text object has a pattern or gradient for filler, it will return that. + * Unused by the library, is for the end user + * @return {String | fabric.Gradient | fabric.Pattern} Character color (fill) + */ + getCurrentCharColor: function() { + var cp = this._getCurrentCharIndex(); + return this.getValueOfPropertyAt(cp.l, cp.c, 'fill'); + }, + + /** + * Returns the cursor position for the getCurrent.. functions + * @private + */ + _getCurrentCharIndex: function() { + var cursorPosition = this.get2DCursorLocation(this.selectionStart, true), + charIndex = cursorPosition.charIndex > 0 ? cursorPosition.charIndex - 1 : 0; + return { l: cursorPosition.lineIndex, c: charIndex }; + } + }); + + /** + * Returns fabric.IText instance from an object representation + * @static + * @memberOf fabric.IText + * @param {Object} object Object to create an instance from + * @param {function} [callback] invoked with new instance as argument + */ + fabric.IText.fromObject = function(object, callback) { + var styles = fabric.util.stylesFromArray(object.styles, object.text); + //copy object to prevent mutation + var objCopy = Object.assign({}, object, { styles: styles }); + parseDecoration(objCopy); + if (objCopy.styles) { + for (var i in objCopy.styles) { + for (var j in objCopy.styles[i]) { + parseDecoration(objCopy.styles[i][j]); + } + } + } + fabric.Object._fromObject('IText', objCopy, callback, 'text'); + }; +})(); + + +(function() { + + var clone = fabric.util.object.clone; + + fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.prototype */ { + + /** + * Initializes all the interactive behavior of IText + */ + initBehavior: function() { + this.initAddedHandler(); + this.initRemovedHandler(); + this.initCursorSelectionHandlers(); + this.initDoubleClickSimulation(); + this.mouseMoveHandler = this.mouseMoveHandler.bind(this); + }, + + onDeselect: function() { + this.isEditing && this.exitEditing(); + this.selected = false; + }, + + /** + * Initializes "added" event handler + */ + initAddedHandler: function() { + var _this = this; + this.on('added', function() { + var canvas = _this.canvas; + if (canvas) { + if (!canvas._hasITextHandlers) { + canvas._hasITextHandlers = true; + _this._initCanvasHandlers(canvas); + } + canvas._iTextInstances = canvas._iTextInstances || []; + canvas._iTextInstances.push(_this); + } + }); + }, + + initRemovedHandler: function() { + var _this = this; + this.on('removed', function() { + var canvas = _this.canvas; + if (canvas) { + canvas._iTextInstances = canvas._iTextInstances || []; + fabric.util.removeFromArray(canvas._iTextInstances, _this); + if (canvas._iTextInstances.length === 0) { + canvas._hasITextHandlers = false; + _this._removeCanvasHandlers(canvas); + } + } + }); + }, + + /** + * register canvas event to manage exiting on other instances + * @private + */ + _initCanvasHandlers: function(canvas) { + canvas._mouseUpITextHandler = function() { + if (canvas._iTextInstances) { + canvas._iTextInstances.forEach(function(obj) { + obj.__isMousedown = false; + }); + } + }; + canvas.on('mouse:up', canvas._mouseUpITextHandler); + }, + + /** + * remove canvas event to manage exiting on other instances + * @private + */ + _removeCanvasHandlers: function(canvas) { + canvas.off('mouse:up', canvas._mouseUpITextHandler); + }, + + /** + * @private + */ + _tick: function() { + this._currentTickState = this._animateCursor(this, 1, this.cursorDuration, '_onTickComplete'); + }, + + /** + * @private + */ + _animateCursor: function(obj, targetOpacity, duration, completeMethod) { + + var tickState; + + tickState = { + isAborted: false, + abort: function() { + this.isAborted = true; + }, + }; + + obj.animate('_currentCursorOpacity', targetOpacity, { + duration: duration, + onComplete: function() { + if (!tickState.isAborted) { + obj[completeMethod](); + } + }, + onChange: function() { + // we do not want to animate a selection, only cursor + if (obj.canvas && obj.selectionStart === obj.selectionEnd) { + obj.renderCursorOrSelection(); + } + }, + abort: function() { + return tickState.isAborted; + } + }); + return tickState; + }, + + /** + * @private + */ + _onTickComplete: function() { + + var _this = this; + + if (this._cursorTimeout1) { + clearTimeout(this._cursorTimeout1); + } + this._cursorTimeout1 = setTimeout(function() { + _this._currentTickCompleteState = _this._animateCursor(_this, 0, this.cursorDuration / 2, '_tick'); + }, 100); + }, + + /** + * Initializes delayed cursor + */ + initDelayedCursor: function(restart) { + var _this = this, + delay = restart ? 0 : this.cursorDelay; + + this.abortCursorAnimation(); + this._currentCursorOpacity = 1; + this._cursorTimeout2 = setTimeout(function() { + _this._tick(); + }, delay); + }, + + /** + * Aborts cursor animation and clears all timeouts + */ + abortCursorAnimation: function() { + var shouldClear = this._currentTickState || this._currentTickCompleteState, + canvas = this.canvas; + this._currentTickState && this._currentTickState.abort(); + this._currentTickCompleteState && this._currentTickCompleteState.abort(); + + clearTimeout(this._cursorTimeout1); + clearTimeout(this._cursorTimeout2); + + this._currentCursorOpacity = 0; + // to clear just itext area we need to transform the context + // it may not be worth it + if (shouldClear && canvas) { + canvas.clearContext(canvas.contextTop || canvas.contextContainer); + } + + }, + + /** + * Selects entire text + * @return {fabric.IText} thisArg + * @chainable + */ + selectAll: function() { + this.selectionStart = 0; + this.selectionEnd = this._text.length; + this._fireSelectionChanged(); + this._updateTextarea(); + return this; + }, + + /** + * Returns selected text + * @return {String} + */ + getSelectedText: function() { + return this._text.slice(this.selectionStart, this.selectionEnd).join(''); + }, + + /** + * Find new selection index representing start of current word according to current selection index + * @param {Number} startFrom Current selection index + * @return {Number} New selection index + */ + findWordBoundaryLeft: function(startFrom) { + var offset = 0, index = startFrom - 1; + + // remove space before cursor first + if (this._reSpace.test(this._text[index])) { + while (this._reSpace.test(this._text[index])) { + offset++; + index--; + } + } + while (/\S/.test(this._text[index]) && index > -1) { + offset++; + index--; + } + + return startFrom - offset; + }, + + /** + * Find new selection index representing end of current word according to current selection index + * @param {Number} startFrom Current selection index + * @return {Number} New selection index + */ + findWordBoundaryRight: function(startFrom) { + var offset = 0, index = startFrom; + + // remove space after cursor first + if (this._reSpace.test(this._text[index])) { + while (this._reSpace.test(this._text[index])) { + offset++; + index++; + } + } + while (/\S/.test(this._text[index]) && index < this._text.length) { + offset++; + index++; + } + + return startFrom + offset; + }, + + /** + * Find new selection index representing start of current line according to current selection index + * @param {Number} startFrom Current selection index + * @return {Number} New selection index + */ + findLineBoundaryLeft: function(startFrom) { + var offset = 0, index = startFrom - 1; + + while (!/\n/.test(this._text[index]) && index > -1) { + offset++; + index--; + } + + return startFrom - offset; + }, + + /** + * Find new selection index representing end of current line according to current selection index + * @param {Number} startFrom Current selection index + * @return {Number} New selection index + */ + findLineBoundaryRight: function(startFrom) { + var offset = 0, index = startFrom; + + while (!/\n/.test(this._text[index]) && index < this._text.length) { + offset++; + index++; + } + + return startFrom + offset; + }, + + /** + * Finds index corresponding to beginning or end of a word + * @param {Number} selectionStart Index of a character + * @param {Number} direction 1 or -1 + * @return {Number} Index of the beginning or end of a word + */ + searchWordBoundary: function(selectionStart, direction) { + var text = this._text, + index = this._reSpace.test(text[selectionStart]) ? selectionStart - 1 : selectionStart, + _char = text[index], + // wrong + reNonWord = fabric.reNonWord; + + while (!reNonWord.test(_char) && index > 0 && index < text.length) { + index += direction; + _char = text[index]; + } + if (reNonWord.test(_char)) { + index += direction === 1 ? 0 : 1; + } + return index; + }, + + /** + * Selects a word based on the index + * @param {Number} selectionStart Index of a character + */ + selectWord: function(selectionStart) { + selectionStart = selectionStart || this.selectionStart; + var newSelectionStart = this.searchWordBoundary(selectionStart, -1), /* search backwards */ + newSelectionEnd = this.searchWordBoundary(selectionStart, 1); /* search forward */ + + this.selectionStart = newSelectionStart; + this.selectionEnd = newSelectionEnd; + this._fireSelectionChanged(); + this._updateTextarea(); + this.renderCursorOrSelection(); + }, + + /** + * Selects a line based on the index + * @param {Number} selectionStart Index of a character + * @return {fabric.IText} thisArg + * @chainable + */ + selectLine: function(selectionStart) { + selectionStart = selectionStart || this.selectionStart; + var newSelectionStart = this.findLineBoundaryLeft(selectionStart), + newSelectionEnd = this.findLineBoundaryRight(selectionStart); + + this.selectionStart = newSelectionStart; + this.selectionEnd = newSelectionEnd; + this._fireSelectionChanged(); + this._updateTextarea(); + return this; + }, + + /** + * Enters editing state + * @return {fabric.IText} thisArg + * @chainable + */ + enterEditing: function(e) { + if (this.isEditing || !this.editable) { + return; + } + + if (this.canvas) { + this.canvas.calcOffset(); + this.exitEditingOnOthers(this.canvas); + } + + this.isEditing = true; + + this.initHiddenTextarea(e); + this.hiddenTextarea.focus(); + this.hiddenTextarea.value = this.text; + this._updateTextarea(); + this._saveEditingProps(); + this._setEditingProps(); + this._textBeforeEdit = this.text; + + this._tick(); + this.fire('editing:entered'); + this._fireSelectionChanged(); + if (!this.canvas) { + return this; + } + this.canvas.fire('text:editing:entered', { target: this }); + this.initMouseMoveHandler(); + this.canvas.requestRenderAll(); + return this; + }, + + exitEditingOnOthers: function(canvas) { + if (canvas._iTextInstances) { + canvas._iTextInstances.forEach(function(obj) { + obj.selected = false; + if (obj.isEditing) { + obj.exitEditing(); + } + }); + } + }, + + /** + * Initializes "mousemove" event handler + */ + initMouseMoveHandler: function() { + this.canvas.on('mouse:move', this.mouseMoveHandler); + }, + + /** + * @private + */ + mouseMoveHandler: function(options) { + if (!this.__isMousedown || !this.isEditing) { + return; + } + + // regain focus + document.activeElement !== this.hiddenTextarea && this.hiddenTextarea.focus(); + + var newSelectionStart = this.getSelectionStartFromPointer(options.e), + currentStart = this.selectionStart, + currentEnd = this.selectionEnd; + if ( + (newSelectionStart !== this.__selectionStartOnMouseDown || currentStart === currentEnd) + && + (currentStart === newSelectionStart || currentEnd === newSelectionStart) + ) { + return; + } + if (newSelectionStart > this.__selectionStartOnMouseDown) { + this.selectionStart = this.__selectionStartOnMouseDown; + this.selectionEnd = newSelectionStart; + } + else { + this.selectionStart = newSelectionStart; + this.selectionEnd = this.__selectionStartOnMouseDown; + } + if (this.selectionStart !== currentStart || this.selectionEnd !== currentEnd) { + this.restartCursorIfNeeded(); + this._fireSelectionChanged(); + this._updateTextarea(); + this.renderCursorOrSelection(); + } + }, + + /** + * @private + */ + _setEditingProps: function() { + this.hoverCursor = 'text'; + + if (this.canvas) { + this.canvas.defaultCursor = this.canvas.moveCursor = 'text'; + } + + this.borderColor = this.editingBorderColor; + this.hasControls = this.selectable = false; + this.lockMovementX = this.lockMovementY = true; + }, + + /** + * convert from textarea to grapheme indexes + */ + fromStringToGraphemeSelection: function(start, end, text) { + var smallerTextStart = text.slice(0, start), + graphemeStart = fabric.util.string.graphemeSplit(smallerTextStart).length; + if (start === end) { + return { selectionStart: graphemeStart, selectionEnd: graphemeStart }; + } + var smallerTextEnd = text.slice(start, end), + graphemeEnd = fabric.util.string.graphemeSplit(smallerTextEnd).length; + return { selectionStart: graphemeStart, selectionEnd: graphemeStart + graphemeEnd }; + }, + + /** + * convert from fabric to textarea values + */ + fromGraphemeToStringSelection: function(start, end, _text) { + var smallerTextStart = _text.slice(0, start), + graphemeStart = smallerTextStart.join('').length; + if (start === end) { + return { selectionStart: graphemeStart, selectionEnd: graphemeStart }; + } + var smallerTextEnd = _text.slice(start, end), + graphemeEnd = smallerTextEnd.join('').length; + return { selectionStart: graphemeStart, selectionEnd: graphemeStart + graphemeEnd }; + }, + + /** + * @private + */ + _updateTextarea: function() { + this.cursorOffsetCache = { }; + if (!this.hiddenTextarea) { + return; + } + if (!this.inCompositionMode) { + var newSelection = this.fromGraphemeToStringSelection(this.selectionStart, this.selectionEnd, this._text); + this.hiddenTextarea.selectionStart = newSelection.selectionStart; + this.hiddenTextarea.selectionEnd = newSelection.selectionEnd; + } + this.updateTextareaPosition(); + }, + + /** + * @private + */ + updateFromTextArea: function() { + if (!this.hiddenTextarea) { + return; + } + this.cursorOffsetCache = { }; + this.text = this.hiddenTextarea.value; + if (this._shouldClearDimensionCache()) { + this.initDimensions(); + this.setCoords(); + } + var newSelection = this.fromStringToGraphemeSelection( + this.hiddenTextarea.selectionStart, this.hiddenTextarea.selectionEnd, this.hiddenTextarea.value); + this.selectionEnd = this.selectionStart = newSelection.selectionEnd; + if (!this.inCompositionMode) { + this.selectionStart = newSelection.selectionStart; + } + this.updateTextareaPosition(); + }, + + /** + * @private + */ + updateTextareaPosition: function() { + if (this.selectionStart === this.selectionEnd) { + var style = this._calcTextareaPosition(); + this.hiddenTextarea.style.left = style.left; + this.hiddenTextarea.style.top = style.top; + } + }, + + /** + * @private + * @return {Object} style contains style for hiddenTextarea + */ + _calcTextareaPosition: function() { + if (!this.canvas) { + return { x: 1, y: 1 }; + } + var desiredPosition = this.inCompositionMode ? this.compositionStart : this.selectionStart, + boundaries = this._getCursorBoundaries(desiredPosition), + cursorLocation = this.get2DCursorLocation(desiredPosition), + lineIndex = cursorLocation.lineIndex, + charIndex = cursorLocation.charIndex, + charHeight = this.getValueOfPropertyAt(lineIndex, charIndex, 'fontSize') * this.lineHeight, + leftOffset = boundaries.leftOffset, + m = this.calcTransformMatrix(), + p = { + x: boundaries.left + leftOffset, + y: boundaries.top + boundaries.topOffset + charHeight + }, + retinaScaling = this.canvas.getRetinaScaling(), + upperCanvas = this.canvas.upperCanvasEl, + upperCanvasWidth = upperCanvas.width / retinaScaling, + upperCanvasHeight = upperCanvas.height / retinaScaling, + maxWidth = upperCanvasWidth - charHeight, + maxHeight = upperCanvasHeight - charHeight, + scaleX = upperCanvas.clientWidth / upperCanvasWidth, + scaleY = upperCanvas.clientHeight / upperCanvasHeight; + + p = fabric.util.transformPoint(p, m); + p = fabric.util.transformPoint(p, this.canvas.viewportTransform); + p.x *= scaleX; + p.y *= scaleY; + if (p.x < 0) { + p.x = 0; + } + if (p.x > maxWidth) { + p.x = maxWidth; + } + if (p.y < 0) { + p.y = 0; + } + if (p.y > maxHeight) { + p.y = maxHeight; + } + + // add canvas offset on document + p.x += this.canvas._offset.left; + p.y += this.canvas._offset.top; + + return { left: p.x + 'px', top: p.y + 'px', fontSize: charHeight + 'px', charHeight: charHeight }; + }, + + /** + * @private + */ + _saveEditingProps: function() { + this._savedProps = { + hasControls: this.hasControls, + borderColor: this.borderColor, + lockMovementX: this.lockMovementX, + lockMovementY: this.lockMovementY, + hoverCursor: this.hoverCursor, + selectable: this.selectable, + defaultCursor: this.canvas && this.canvas.defaultCursor, + moveCursor: this.canvas && this.canvas.moveCursor + }; + }, + + /** + * @private + */ + _restoreEditingProps: function() { + if (!this._savedProps) { + return; + } + + this.hoverCursor = this._savedProps.hoverCursor; + this.hasControls = this._savedProps.hasControls; + this.borderColor = this._savedProps.borderColor; + this.selectable = this._savedProps.selectable; + this.lockMovementX = this._savedProps.lockMovementX; + this.lockMovementY = this._savedProps.lockMovementY; + + if (this.canvas) { + this.canvas.defaultCursor = this._savedProps.defaultCursor; + this.canvas.moveCursor = this._savedProps.moveCursor; + } + }, + + /** + * Exits from editing state + * @return {fabric.IText} thisArg + * @chainable + */ + exitEditing: function() { + var isTextChanged = (this._textBeforeEdit !== this.text); + var hiddenTextarea = this.hiddenTextarea; + this.selected = false; + this.isEditing = false; + + this.selectionEnd = this.selectionStart; + + if (hiddenTextarea) { + hiddenTextarea.blur && hiddenTextarea.blur(); + hiddenTextarea.parentNode && hiddenTextarea.parentNode.removeChild(hiddenTextarea); + } + this.hiddenTextarea = null; + this.abortCursorAnimation(); + this._restoreEditingProps(); + this._currentCursorOpacity = 0; + if (this._shouldClearDimensionCache()) { + this.initDimensions(); + this.setCoords(); + } + this.fire('editing:exited'); + isTextChanged && this.fire('modified'); + if (this.canvas) { + this.canvas.off('mouse:move', this.mouseMoveHandler); + this.canvas.fire('text:editing:exited', { target: this }); + isTextChanged && this.canvas.fire('object:modified', { target: this }); + } + return this; + }, + + /** + * @private + */ + _removeExtraneousStyles: function() { + for (var prop in this.styles) { + if (!this._textLines[prop]) { + delete this.styles[prop]; + } + } + }, + + /** + * remove and reflow a style block from start to end. + * @param {Number} start linear start position for removal (included in removal) + * @param {Number} end linear end position for removal ( excluded from removal ) + */ + removeStyleFromTo: function(start, end) { + var cursorStart = this.get2DCursorLocation(start, true), + cursorEnd = this.get2DCursorLocation(end, true), + lineStart = cursorStart.lineIndex, + charStart = cursorStart.charIndex, + lineEnd = cursorEnd.lineIndex, + charEnd = cursorEnd.charIndex, + i, styleObj; + if (lineStart !== lineEnd) { + // step1 remove the trailing of lineStart + if (this.styles[lineStart]) { + for (i = charStart; i < this._unwrappedTextLines[lineStart].length; i++) { + delete this.styles[lineStart][i]; + } + } + // step2 move the trailing of lineEnd to lineStart if needed + if (this.styles[lineEnd]) { + for (i = charEnd; i < this._unwrappedTextLines[lineEnd].length; i++) { + styleObj = this.styles[lineEnd][i]; + if (styleObj) { + this.styles[lineStart] || (this.styles[lineStart] = { }); + this.styles[lineStart][charStart + i - charEnd] = styleObj; + } + } + } + // step3 detects lines will be completely removed. + for (i = lineStart + 1; i <= lineEnd; i++) { + delete this.styles[i]; + } + // step4 shift remaining lines. + this.shiftLineStyles(lineEnd, lineStart - lineEnd); + } + else { + // remove and shift left on the same line + if (this.styles[lineStart]) { + styleObj = this.styles[lineStart]; + var diff = charEnd - charStart, numericChar, _char; + for (i = charStart; i < charEnd; i++) { + delete styleObj[i]; + } + for (_char in this.styles[lineStart]) { + numericChar = parseInt(_char, 10); + if (numericChar >= charEnd) { + styleObj[numericChar - diff] = styleObj[_char]; + delete styleObj[_char]; + } + } + } + } + }, + + /** + * Shifts line styles up or down + * @param {Number} lineIndex Index of a line + * @param {Number} offset Can any number? + */ + shiftLineStyles: function(lineIndex, offset) { + // shift all line styles by offset upward or downward + // do not clone deep. we need new array, not new style objects + var clonedStyles = clone(this.styles); + for (var line in this.styles) { + var numericLine = parseInt(line, 10); + if (numericLine > lineIndex) { + this.styles[numericLine + offset] = clonedStyles[numericLine]; + if (!clonedStyles[numericLine - offset]) { + delete this.styles[numericLine]; + } + } + } + }, + + restartCursorIfNeeded: function() { + if (!this._currentTickState || this._currentTickState.isAborted + || !this._currentTickCompleteState || this._currentTickCompleteState.isAborted + ) { + this.initDelayedCursor(); + } + }, + + /** + * Handle insertion of more consecutive style lines for when one or more + * newlines gets added to the text. Since current style needs to be shifted + * first we shift the current style of the number lines needed, then we add + * new lines from the last to the first. + * @param {Number} lineIndex Index of a line + * @param {Number} charIndex Index of a char + * @param {Number} qty number of lines to add + * @param {Array} copiedStyle Array of objects styles + */ + insertNewlineStyleObject: function(lineIndex, charIndex, qty, copiedStyle) { + var currentCharStyle, + newLineStyles = {}, + somethingAdded = false, + isEndOfLine = this._unwrappedTextLines[lineIndex].length === charIndex; + + qty || (qty = 1); + this.shiftLineStyles(lineIndex, qty); + if (this.styles[lineIndex]) { + currentCharStyle = this.styles[lineIndex][charIndex === 0 ? charIndex : charIndex - 1]; + } + // we clone styles of all chars + // after cursor onto the current line + for (var index in this.styles[lineIndex]) { + var numIndex = parseInt(index, 10); + if (numIndex >= charIndex) { + somethingAdded = true; + newLineStyles[numIndex - charIndex] = this.styles[lineIndex][index]; + // remove lines from the previous line since they're on a new line now + if (!(isEndOfLine && charIndex === 0)) { + delete this.styles[lineIndex][index]; + } + } + } + var styleCarriedOver = false; + if (somethingAdded && !isEndOfLine) { + // if is end of line, the extra style we copied + // is probably not something we want + this.styles[lineIndex + qty] = newLineStyles; + styleCarriedOver = true; + } + if (styleCarriedOver) { + // skip the last line of since we already prepared it. + qty--; + } + // for the all the lines or all the other lines + // we clone current char style onto the next (otherwise empty) line + while (qty > 0) { + if (copiedStyle && copiedStyle[qty - 1]) { + this.styles[lineIndex + qty] = { 0: clone(copiedStyle[qty - 1]) }; + } + else if (currentCharStyle) { + this.styles[lineIndex + qty] = { 0: clone(currentCharStyle) }; + } + else { + delete this.styles[lineIndex + qty]; + } + qty--; + } + this._forceClearCache = true; + }, + + /** + * Inserts style object for a given line/char index + * @param {Number} lineIndex Index of a line + * @param {Number} charIndex Index of a char + * @param {Number} quantity number Style object to insert, if given + * @param {Array} copiedStyle array of style objects + */ + insertCharStyleObject: function(lineIndex, charIndex, quantity, copiedStyle) { + if (!this.styles) { + this.styles = {}; + } + var currentLineStyles = this.styles[lineIndex], + currentLineStylesCloned = currentLineStyles ? clone(currentLineStyles) : {}; + + quantity || (quantity = 1); + // shift all char styles by quantity forward + // 0,1,2,3 -> (charIndex=2) -> 0,1,3,4 -> (insert 2) -> 0,1,2,3,4 + for (var index in currentLineStylesCloned) { + var numericIndex = parseInt(index, 10); + if (numericIndex >= charIndex) { + currentLineStyles[numericIndex + quantity] = currentLineStylesCloned[numericIndex]; + // only delete the style if there was nothing moved there + if (!currentLineStylesCloned[numericIndex - quantity]) { + delete currentLineStyles[numericIndex]; + } + } + } + this._forceClearCache = true; + if (copiedStyle) { + while (quantity--) { + if (!Object.keys(copiedStyle[quantity]).length) { + continue; + } + if (!this.styles[lineIndex]) { + this.styles[lineIndex] = {}; + } + this.styles[lineIndex][charIndex + quantity] = clone(copiedStyle[quantity]); + } + return; + } + if (!currentLineStyles) { + return; + } + var newStyle = currentLineStyles[charIndex ? charIndex - 1 : 1]; + while (newStyle && quantity--) { + this.styles[lineIndex][charIndex + quantity] = clone(newStyle); + } + }, + + /** + * Inserts style object(s) + * @param {Array} insertedText Characters at the location where style is inserted + * @param {Number} start cursor index for inserting style + * @param {Array} [copiedStyle] array of style objects to insert. + */ + insertNewStyleBlock: function(insertedText, start, copiedStyle) { + var cursorLoc = this.get2DCursorLocation(start, true), + addedLines = [0], linesLength = 0; + // get an array of how many char per lines are being added. + for (var i = 0; i < insertedText.length; i++) { + if (insertedText[i] === '\n') { + linesLength++; + addedLines[linesLength] = 0; + } + else { + addedLines[linesLength]++; + } + } + // for the first line copy the style from the current char position. + if (addedLines[0] > 0) { + this.insertCharStyleObject(cursorLoc.lineIndex, cursorLoc.charIndex, addedLines[0], copiedStyle); + copiedStyle = copiedStyle && copiedStyle.slice(addedLines[0] + 1); + } + linesLength && this.insertNewlineStyleObject( + cursorLoc.lineIndex, cursorLoc.charIndex + addedLines[0], linesLength); + for (var i = 1; i < linesLength; i++) { + if (addedLines[i] > 0) { + this.insertCharStyleObject(cursorLoc.lineIndex + i, 0, addedLines[i], copiedStyle); + } + else if (copiedStyle) { + // this test is required in order to close #6841 + // when a pasted buffer begins with a newline then + // this.styles[cursorLoc.lineIndex + i] and copiedStyle[0] + // may be undefined for some reason + if (this.styles[cursorLoc.lineIndex + i] && copiedStyle[0]) { + this.styles[cursorLoc.lineIndex + i][0] = copiedStyle[0]; + } + } + copiedStyle = copiedStyle && copiedStyle.slice(addedLines[i] + 1); + } + // we use i outside the loop to get it like linesLength + if (addedLines[i] > 0) { + this.insertCharStyleObject(cursorLoc.lineIndex + i, 0, addedLines[i], copiedStyle); + } + }, + + /** + * Set the selectionStart and selectionEnd according to the new position of cursor + * mimic the key - mouse navigation when shift is pressed. + */ + setSelectionStartEndWithShift: function(start, end, newSelection) { + if (newSelection <= start) { + if (end === start) { + this._selectionDirection = 'left'; + } + else if (this._selectionDirection === 'right') { + this._selectionDirection = 'left'; + this.selectionEnd = start; + } + this.selectionStart = newSelection; + } + else if (newSelection > start && newSelection < end) { + if (this._selectionDirection === 'right') { + this.selectionEnd = newSelection; + } + else { + this.selectionStart = newSelection; + } + } + else { + // newSelection is > selection start and end + if (end === start) { + this._selectionDirection = 'right'; + } + else if (this._selectionDirection === 'left') { + this._selectionDirection = 'right'; + this.selectionStart = end; + } + this.selectionEnd = newSelection; + } + }, + + setSelectionInBoundaries: function() { + var length = this.text.length; + if (this.selectionStart > length) { + this.selectionStart = length; + } + else if (this.selectionStart < 0) { + this.selectionStart = 0; + } + if (this.selectionEnd > length) { + this.selectionEnd = length; + } + else if (this.selectionEnd < 0) { + this.selectionEnd = 0; + } + } + }); +})(); + + +fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.prototype */ { + /** + * Initializes "dbclick" event handler + */ + initDoubleClickSimulation: function() { + + // for double click + this.__lastClickTime = +new Date(); + + // for triple click + this.__lastLastClickTime = +new Date(); + + this.__lastPointer = { }; + + this.on('mousedown', this.onMouseDown); + }, + + /** + * Default event handler to simulate triple click + * @private + */ + onMouseDown: function(options) { + if (!this.canvas) { + return; + } + this.__newClickTime = +new Date(); + var newPointer = options.pointer; + if (this.isTripleClick(newPointer)) { + this.fire('tripleclick', options); + this._stopEvent(options.e); + } + this.__lastLastClickTime = this.__lastClickTime; + this.__lastClickTime = this.__newClickTime; + this.__lastPointer = newPointer; + this.__lastIsEditing = this.isEditing; + this.__lastSelected = this.selected; + }, + + isTripleClick: function(newPointer) { + return this.__newClickTime - this.__lastClickTime < 500 && + this.__lastClickTime - this.__lastLastClickTime < 500 && + this.__lastPointer.x === newPointer.x && + this.__lastPointer.y === newPointer.y; + }, + + /** + * @private + */ + _stopEvent: function(e) { + e.preventDefault && e.preventDefault(); + e.stopPropagation && e.stopPropagation(); + }, + + /** + * Initializes event handlers related to cursor or selection + */ + initCursorSelectionHandlers: function() { + this.initMousedownHandler(); + this.initMouseupHandler(); + this.initClicks(); + }, + + /** + * Default handler for double click, select a word + */ + doubleClickHandler: function(options) { + if (!this.isEditing) { + return; + } + this.selectWord(this.getSelectionStartFromPointer(options.e)); + }, + + /** + * Default handler for triple click, select a line + */ + tripleClickHandler: function(options) { + if (!this.isEditing) { + return; + } + this.selectLine(this.getSelectionStartFromPointer(options.e)); + }, + + /** + * Initializes double and triple click event handlers + */ + initClicks: function() { + this.on('mousedblclick', this.doubleClickHandler); + this.on('tripleclick', this.tripleClickHandler); + }, + + /** + * Default event handler for the basic functionalities needed on _mouseDown + * can be overridden to do something different. + * Scope of this implementation is: find the click position, set selectionStart + * find selectionEnd, initialize the drawing of either cursor or selection area + * initializing a mousedDown on a text area will cancel fabricjs knowledge of + * current compositionMode. It will be set to false. + */ + _mouseDownHandler: function(options) { + if (!this.canvas || !this.editable || (options.e.button && options.e.button !== 1)) { + return; + } + + this.__isMousedown = true; + + if (this.selected) { + this.inCompositionMode = false; + this.setCursorByClick(options.e); + } + + if (this.isEditing) { + this.__selectionStartOnMouseDown = this.selectionStart; + if (this.selectionStart === this.selectionEnd) { + this.abortCursorAnimation(); + } + this.renderCursorOrSelection(); + } + }, + + /** + * Default event handler for the basic functionalities needed on mousedown:before + * can be overridden to do something different. + * Scope of this implementation is: verify the object is already selected when mousing down + */ + _mouseDownHandlerBefore: function(options) { + if (!this.canvas || !this.editable || (options.e.button && options.e.button !== 1)) { + return; + } + // we want to avoid that an object that was selected and then becomes unselectable, + // may trigger editing mode in some way. + this.selected = this === this.canvas._activeObject; + }, + + /** + * Initializes "mousedown" event handler + */ + initMousedownHandler: function() { + this.on('mousedown', this._mouseDownHandler); + this.on('mousedown:before', this._mouseDownHandlerBefore); + }, + + /** + * Initializes "mouseup" event handler + */ + initMouseupHandler: function() { + this.on('mouseup', this.mouseUpHandler); + }, + + /** + * standard handler for mouse up, overridable + * @private + */ + mouseUpHandler: function(options) { + this.__isMousedown = false; + if (!this.editable || this.group || + (options.transform && options.transform.actionPerformed) || + (options.e.button && options.e.button !== 1)) { + return; + } + + if (this.canvas) { + var currentActive = this.canvas._activeObject; + if (currentActive && currentActive !== this) { + // avoid running this logic when there is an active object + // this because is possible with shift click and fast clicks, + // to rapidly deselect and reselect this object and trigger an enterEdit + return; + } + } + + if (this.__lastSelected && !this.__corner) { + this.selected = false; + this.__lastSelected = false; + this.enterEditing(options.e); + if (this.selectionStart === this.selectionEnd) { + this.initDelayedCursor(true); + } + else { + this.renderCursorOrSelection(); + } + } + else { + this.selected = true; + } + }, + + /** + * Changes cursor location in a text depending on passed pointer (x/y) object + * @param {Event} e Event object + */ + setCursorByClick: function(e) { + var newSelection = this.getSelectionStartFromPointer(e), + start = this.selectionStart, end = this.selectionEnd; + if (e.shiftKey) { + this.setSelectionStartEndWithShift(start, end, newSelection); + } + else { + this.selectionStart = newSelection; + this.selectionEnd = newSelection; + } + if (this.isEditing) { + this._fireSelectionChanged(); + this._updateTextarea(); + } + }, + + /** + * Returns index of a character corresponding to where an object was clicked + * @param {Event} e Event object + * @return {Number} Index of a character + */ + getSelectionStartFromPointer: function(e) { + var mouseOffset = this.getLocalPointer(e), + prevWidth = 0, + width = 0, + height = 0, + charIndex = 0, + lineIndex = 0, + lineLeftOffset, + line; + for (var i = 0, len = this._textLines.length; i < len; i++) { + if (height <= mouseOffset.y) { + height += this.getHeightOfLine(i) * this.scaleY; + lineIndex = i; + if (i > 0) { + charIndex += this._textLines[i - 1].length + this.missingNewlineOffset(i - 1); + } + } + else { + break; + } + } + lineLeftOffset = this._getLineLeftOffset(lineIndex); + width = lineLeftOffset * this.scaleX; + line = this._textLines[lineIndex]; + // handling of RTL: in order to get things work correctly, + // we assume RTL writing is mirrored compared to LTR writing. + // so in position detection we mirror the X offset, and when is time + // of rendering it, we mirror it again. + if (this.direction === 'rtl') { + mouseOffset.x = this.width * this.scaleX - mouseOffset.x + width; + } + for (var j = 0, jlen = line.length; j < jlen; j++) { + prevWidth = width; + // i removed something about flipX here, check. + width += this.__charBounds[lineIndex][j].kernedWidth * this.scaleX; + if (width <= mouseOffset.x) { + charIndex++; + } + else { + break; + } + } + return this._getNewSelectionStartFromOffset(mouseOffset, prevWidth, width, charIndex, jlen); + }, + + /** + * @private + */ + _getNewSelectionStartFromOffset: function(mouseOffset, prevWidth, width, index, jlen) { + // we need Math.abs because when width is after the last char, the offset is given as 1, while is 0 + var distanceBtwLastCharAndCursor = mouseOffset.x - prevWidth, + distanceBtwNextCharAndCursor = width - mouseOffset.x, + offset = distanceBtwNextCharAndCursor > distanceBtwLastCharAndCursor || + distanceBtwNextCharAndCursor < 0 ? 0 : 1, + newSelectionStart = index + offset; + // if object is horizontally flipped, mirror cursor location from the end + if (this.flipX) { + newSelectionStart = jlen - newSelectionStart; + } + + if (newSelectionStart > this._text.length) { + newSelectionStart = this._text.length; + } + + return newSelectionStart; + } +}); + + +fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.prototype */ { + + /** + * Initializes hidden textarea (needed to bring up keyboard in iOS) + */ + initHiddenTextarea: function() { + this.hiddenTextarea = fabric.document.createElement('textarea'); + this.hiddenTextarea.setAttribute('autocapitalize', 'off'); + this.hiddenTextarea.setAttribute('autocorrect', 'off'); + this.hiddenTextarea.setAttribute('autocomplete', 'off'); + this.hiddenTextarea.setAttribute('spellcheck', 'false'); + this.hiddenTextarea.setAttribute('data-fabric-hiddentextarea', ''); + this.hiddenTextarea.setAttribute('wrap', 'off'); + var style = this._calcTextareaPosition(); + // line-height: 1px; was removed from the style to fix this: + // https://bugs.chromium.org/p/chromium/issues/detail?id=870966 + this.hiddenTextarea.style.cssText = 'position: absolute; top: ' + style.top + + '; left: ' + style.left + '; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px;' + + ' padding-top: ' + style.fontSize + ';'; + + if (this.hiddenTextareaContainer) { + this.hiddenTextareaContainer.appendChild(this.hiddenTextarea); + } + else { + fabric.document.body.appendChild(this.hiddenTextarea); + } + + fabric.util.addListener(this.hiddenTextarea, 'keydown', this.onKeyDown.bind(this)); + fabric.util.addListener(this.hiddenTextarea, 'keyup', this.onKeyUp.bind(this)); + fabric.util.addListener(this.hiddenTextarea, 'input', this.onInput.bind(this)); + fabric.util.addListener(this.hiddenTextarea, 'copy', this.copy.bind(this)); + fabric.util.addListener(this.hiddenTextarea, 'cut', this.copy.bind(this)); + fabric.util.addListener(this.hiddenTextarea, 'paste', this.paste.bind(this)); + fabric.util.addListener(this.hiddenTextarea, 'compositionstart', this.onCompositionStart.bind(this)); + fabric.util.addListener(this.hiddenTextarea, 'compositionupdate', this.onCompositionUpdate.bind(this)); + fabric.util.addListener(this.hiddenTextarea, 'compositionend', this.onCompositionEnd.bind(this)); + + if (!this._clickHandlerInitialized && this.canvas) { + fabric.util.addListener(this.canvas.upperCanvasEl, 'click', this.onClick.bind(this)); + this._clickHandlerInitialized = true; + } + }, + + /** + * For functionalities on keyDown + * Map a special key to a function of the instance/prototype + * If you need different behaviour for ESC or TAB or arrows, you have to change + * this map setting the name of a function that you build on the fabric.Itext or + * your prototype. + * the map change will affect all Instances unless you need for only some text Instances + * in that case you have to clone this object and assign your Instance. + * this.keysMap = fabric.util.object.clone(this.keysMap); + * The function must be in fabric.Itext.prototype.myFunction And will receive event as args[0] + */ + keysMap: { + 9: 'exitEditing', + 27: 'exitEditing', + 33: 'moveCursorUp', + 34: 'moveCursorDown', + 35: 'moveCursorRight', + 36: 'moveCursorLeft', + 37: 'moveCursorLeft', + 38: 'moveCursorUp', + 39: 'moveCursorRight', + 40: 'moveCursorDown', + }, + + keysMapRtl: { + 9: 'exitEditing', + 27: 'exitEditing', + 33: 'moveCursorUp', + 34: 'moveCursorDown', + 35: 'moveCursorLeft', + 36: 'moveCursorRight', + 37: 'moveCursorRight', + 38: 'moveCursorUp', + 39: 'moveCursorLeft', + 40: 'moveCursorDown', + }, + + /** + * For functionalities on keyUp + ctrl || cmd + */ + ctrlKeysMapUp: { + 67: 'copy', + 88: 'cut' + }, + + /** + * For functionalities on keyDown + ctrl || cmd + */ + ctrlKeysMapDown: { + 65: 'selectAll' + }, + + onClick: function() { + // No need to trigger click event here, focus is enough to have the keyboard appear on Android + this.hiddenTextarea && this.hiddenTextarea.focus(); + }, + + /** + * Handles keydown event + * only used for arrows and combination of modifier keys. + * @param {Event} e Event object + */ + onKeyDown: function(e) { + if (!this.isEditing) { + return; + } + var keyMap = this.direction === 'rtl' ? this.keysMapRtl : this.keysMap; + if (e.keyCode in keyMap) { + this[keyMap[e.keyCode]](e); + } + else if ((e.keyCode in this.ctrlKeysMapDown) && (e.ctrlKey || e.metaKey)) { + this[this.ctrlKeysMapDown[e.keyCode]](e); + } + else { + return; + } + e.stopImmediatePropagation(); + e.preventDefault(); + if (e.keyCode >= 33 && e.keyCode <= 40) { + // if i press an arrow key just update selection + this.inCompositionMode = false; + this.clearContextTop(); + this.renderCursorOrSelection(); + } + else { + this.canvas && this.canvas.requestRenderAll(); + } + }, + + /** + * Handles keyup event + * We handle KeyUp because ie11 and edge have difficulties copy/pasting + * if a copy/cut event fired, keyup is dismissed + * @param {Event} e Event object + */ + onKeyUp: function(e) { + if (!this.isEditing || this._copyDone || this.inCompositionMode) { + this._copyDone = false; + return; + } + if ((e.keyCode in this.ctrlKeysMapUp) && (e.ctrlKey || e.metaKey)) { + this[this.ctrlKeysMapUp[e.keyCode]](e); + } + else { + return; + } + e.stopImmediatePropagation(); + e.preventDefault(); + this.canvas && this.canvas.requestRenderAll(); + }, + + /** + * Handles onInput event + * @param {Event} e Event object + */ + onInput: function(e) { + var fromPaste = this.fromPaste; + this.fromPaste = false; + e && e.stopPropagation(); + if (!this.isEditing) { + return; + } + // decisions about style changes. + var nextText = this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText, + charCount = this._text.length, + nextCharCount = nextText.length, + removedText, insertedText, + charDiff = nextCharCount - charCount, + selectionStart = this.selectionStart, selectionEnd = this.selectionEnd, + selection = selectionStart !== selectionEnd, + copiedStyle, removeFrom, removeTo; + if (this.hiddenTextarea.value === '') { + this.styles = { }; + this.updateFromTextArea(); + this.fire('changed'); + if (this.canvas) { + this.canvas.fire('text:changed', { target: this }); + this.canvas.requestRenderAll(); + } + return; + } + + var textareaSelection = this.fromStringToGraphemeSelection( + this.hiddenTextarea.selectionStart, + this.hiddenTextarea.selectionEnd, + this.hiddenTextarea.value + ); + var backDelete = selectionStart > textareaSelection.selectionStart; + + if (selection) { + removedText = this._text.slice(selectionStart, selectionEnd); + charDiff += selectionEnd - selectionStart; + } + else if (nextCharCount < charCount) { + if (backDelete) { + removedText = this._text.slice(selectionEnd + charDiff, selectionEnd); + } + else { + removedText = this._text.slice(selectionStart, selectionStart - charDiff); + } + } + insertedText = nextText.slice(textareaSelection.selectionEnd - charDiff, textareaSelection.selectionEnd); + if (removedText && removedText.length) { + if (insertedText.length) { + // let's copy some style before deleting. + // we want to copy the style before the cursor OR the style at the cursor if selection + // is bigger than 0. + copiedStyle = this.getSelectionStyles(selectionStart, selectionStart + 1, false); + // now duplicate the style one for each inserted text. + copiedStyle = insertedText.map(function() { + // this return an array of references, but that is fine since we are + // copying the style later. + return copiedStyle[0]; + }); + } + if (selection) { + removeFrom = selectionStart; + removeTo = selectionEnd; + } + else if (backDelete) { + // detect differences between forwardDelete and backDelete + removeFrom = selectionEnd - removedText.length; + removeTo = selectionEnd; + } + else { + removeFrom = selectionEnd; + removeTo = selectionEnd + removedText.length; + } + this.removeStyleFromTo(removeFrom, removeTo); + } + if (insertedText.length) { + if (fromPaste && insertedText.join('') === fabric.copiedText && !fabric.disableStyleCopyPaste) { + copiedStyle = fabric.copiedTextStyle; + } + this.insertNewStyleBlock(insertedText, selectionStart, copiedStyle); + } + this.updateFromTextArea(); + this.fire('changed'); + if (this.canvas) { + this.canvas.fire('text:changed', { target: this }); + this.canvas.requestRenderAll(); + } + }, + /** + * Composition start + */ + onCompositionStart: function() { + this.inCompositionMode = true; + }, + + /** + * Composition end + */ + onCompositionEnd: function() { + this.inCompositionMode = false; + }, + + // /** + // * Composition update + // */ + onCompositionUpdate: function(e) { + this.compositionStart = e.target.selectionStart; + this.compositionEnd = e.target.selectionEnd; + this.updateTextareaPosition(); + }, + + /** + * Copies selected text + * @param {Event} e Event object + */ + copy: function() { + if (this.selectionStart === this.selectionEnd) { + //do not cut-copy if no selection + return; + } + + fabric.copiedText = this.getSelectedText(); + if (!fabric.disableStyleCopyPaste) { + fabric.copiedTextStyle = this.getSelectionStyles(this.selectionStart, this.selectionEnd, true); + } + else { + fabric.copiedTextStyle = null; + } + this._copyDone = true; + }, + + /** + * Pastes text + * @param {Event} e Event object + */ + paste: function() { + this.fromPaste = true; + }, + + /** + * @private + * @param {Event} e Event object + * @return {Object} Clipboard data object + */ + _getClipboardData: function(e) { + return (e && e.clipboardData) || fabric.window.clipboardData; + }, + + /** + * Finds the width in pixels before the cursor on the same line + * @private + * @param {Number} lineIndex + * @param {Number} charIndex + * @return {Number} widthBeforeCursor width before cursor + */ + _getWidthBeforeCursor: function(lineIndex, charIndex) { + var widthBeforeCursor = this._getLineLeftOffset(lineIndex), bound; + + if (charIndex > 0) { + bound = this.__charBounds[lineIndex][charIndex - 1]; + widthBeforeCursor += bound.left + bound.width; + } + return widthBeforeCursor; + }, + + /** + * Gets start offset of a selection + * @param {Event} e Event object + * @param {Boolean} isRight + * @return {Number} + */ + getDownCursorOffset: function(e, isRight) { + var selectionProp = this._getSelectionForOffset(e, isRight), + cursorLocation = this.get2DCursorLocation(selectionProp), + lineIndex = cursorLocation.lineIndex; + // if on last line, down cursor goes to end of line + if (lineIndex === this._textLines.length - 1 || e.metaKey || e.keyCode === 34) { + // move to the end of a text + return this._text.length - selectionProp; + } + var charIndex = cursorLocation.charIndex, + widthBeforeCursor = this._getWidthBeforeCursor(lineIndex, charIndex), + indexOnOtherLine = this._getIndexOnLine(lineIndex + 1, widthBeforeCursor), + textAfterCursor = this._textLines[lineIndex].slice(charIndex); + return textAfterCursor.length + indexOnOtherLine + 1 + this.missingNewlineOffset(lineIndex); + }, + + /** + * private + * Helps finding if the offset should be counted from Start or End + * @param {Event} e Event object + * @param {Boolean} isRight + * @return {Number} + */ + _getSelectionForOffset: function(e, isRight) { + if (e.shiftKey && this.selectionStart !== this.selectionEnd && isRight) { + return this.selectionEnd; + } + else { + return this.selectionStart; + } + }, + + /** + * @param {Event} e Event object + * @param {Boolean} isRight + * @return {Number} + */ + getUpCursorOffset: function(e, isRight) { + var selectionProp = this._getSelectionForOffset(e, isRight), + cursorLocation = this.get2DCursorLocation(selectionProp), + lineIndex = cursorLocation.lineIndex; + if (lineIndex === 0 || e.metaKey || e.keyCode === 33) { + // if on first line, up cursor goes to start of line + return -selectionProp; + } + var charIndex = cursorLocation.charIndex, + widthBeforeCursor = this._getWidthBeforeCursor(lineIndex, charIndex), + indexOnOtherLine = this._getIndexOnLine(lineIndex - 1, widthBeforeCursor), + textBeforeCursor = this._textLines[lineIndex].slice(0, charIndex), + missingNewlineOffset = this.missingNewlineOffset(lineIndex - 1); + // return a negative offset + return -this._textLines[lineIndex - 1].length + + indexOnOtherLine - textBeforeCursor.length + (1 - missingNewlineOffset); + }, + + /** + * for a given width it founds the matching character. + * @private + */ + _getIndexOnLine: function(lineIndex, width) { + + var line = this._textLines[lineIndex], + lineLeftOffset = this._getLineLeftOffset(lineIndex), + widthOfCharsOnLine = lineLeftOffset, + indexOnLine = 0, charWidth, foundMatch; + + for (var j = 0, jlen = line.length; j < jlen; j++) { + charWidth = this.__charBounds[lineIndex][j].width; + widthOfCharsOnLine += charWidth; + if (widthOfCharsOnLine > width) { + foundMatch = true; + var leftEdge = widthOfCharsOnLine - charWidth, + rightEdge = widthOfCharsOnLine, + offsetFromLeftEdge = Math.abs(leftEdge - width), + offsetFromRightEdge = Math.abs(rightEdge - width); + + indexOnLine = offsetFromRightEdge < offsetFromLeftEdge ? j : (j - 1); + break; + } + } + + // reached end + if (!foundMatch) { + indexOnLine = line.length - 1; + } + + return indexOnLine; + }, + + + /** + * Moves cursor down + * @param {Event} e Event object + */ + moveCursorDown: function(e) { + if (this.selectionStart >= this._text.length && this.selectionEnd >= this._text.length) { + return; + } + this._moveCursorUpOrDown('Down', e); + }, + + /** + * Moves cursor up + * @param {Event} e Event object + */ + moveCursorUp: function(e) { + if (this.selectionStart === 0 && this.selectionEnd === 0) { + return; + } + this._moveCursorUpOrDown('Up', e); + }, + + /** + * Moves cursor up or down, fires the events + * @param {String} direction 'Up' or 'Down' + * @param {Event} e Event object + */ + _moveCursorUpOrDown: function(direction, e) { + // getUpCursorOffset + // getDownCursorOffset + var action = 'get' + direction + 'CursorOffset', + offset = this[action](e, this._selectionDirection === 'right'); + if (e.shiftKey) { + this.moveCursorWithShift(offset); + } + else { + this.moveCursorWithoutShift(offset); + } + if (offset !== 0) { + this.setSelectionInBoundaries(); + this.abortCursorAnimation(); + this._currentCursorOpacity = 1; + this.initDelayedCursor(); + this._fireSelectionChanged(); + this._updateTextarea(); + } + }, + + /** + * Moves cursor with shift + * @param {Number} offset + */ + moveCursorWithShift: function(offset) { + var newSelection = this._selectionDirection === 'left' + ? this.selectionStart + offset + : this.selectionEnd + offset; + this.setSelectionStartEndWithShift(this.selectionStart, this.selectionEnd, newSelection); + return offset !== 0; + }, + + /** + * Moves cursor up without shift + * @param {Number} offset + */ + moveCursorWithoutShift: function(offset) { + if (offset < 0) { + this.selectionStart += offset; + this.selectionEnd = this.selectionStart; + } + else { + this.selectionEnd += offset; + this.selectionStart = this.selectionEnd; + } + return offset !== 0; + }, + + /** + * Moves cursor left + * @param {Event} e Event object + */ + moveCursorLeft: function(e) { + if (this.selectionStart === 0 && this.selectionEnd === 0) { + return; + } + this._moveCursorLeftOrRight('Left', e); + }, + + /** + * @private + * @return {Boolean} true if a change happened + */ + _move: function(e, prop, direction) { + var newValue; + if (e.altKey) { + newValue = this['findWordBoundary' + direction](this[prop]); + } + else if (e.metaKey || e.keyCode === 35 || e.keyCode === 36 ) { + newValue = this['findLineBoundary' + direction](this[prop]); + } + else { + this[prop] += direction === 'Left' ? -1 : 1; + return true; + } + if (typeof newValue !== 'undefined' && this[prop] !== newValue) { + this[prop] = newValue; + return true; + } + }, + + /** + * @private + */ + _moveLeft: function(e, prop) { + return this._move(e, prop, 'Left'); + }, + + /** + * @private + */ + _moveRight: function(e, prop) { + return this._move(e, prop, 'Right'); + }, + + /** + * Moves cursor left without keeping selection + * @param {Event} e + */ + moveCursorLeftWithoutShift: function(e) { + var change = true; + this._selectionDirection = 'left'; + + // only move cursor when there is no selection, + // otherwise we discard it, and leave cursor on same place + if (this.selectionEnd === this.selectionStart && this.selectionStart !== 0) { + change = this._moveLeft(e, 'selectionStart'); + + } + this.selectionEnd = this.selectionStart; + return change; + }, + + /** + * Moves cursor left while keeping selection + * @param {Event} e + */ + moveCursorLeftWithShift: function(e) { + if (this._selectionDirection === 'right' && this.selectionStart !== this.selectionEnd) { + return this._moveLeft(e, 'selectionEnd'); + } + else if (this.selectionStart !== 0){ + this._selectionDirection = 'left'; + return this._moveLeft(e, 'selectionStart'); + } + }, + + /** + * Moves cursor right + * @param {Event} e Event object + */ + moveCursorRight: function(e) { + if (this.selectionStart >= this._text.length && this.selectionEnd >= this._text.length) { + return; + } + this._moveCursorLeftOrRight('Right', e); + }, + + /** + * Moves cursor right or Left, fires event + * @param {String} direction 'Left', 'Right' + * @param {Event} e Event object + */ + _moveCursorLeftOrRight: function(direction, e) { + var actionName = 'moveCursor' + direction + 'With'; + this._currentCursorOpacity = 1; + + if (e.shiftKey) { + actionName += 'Shift'; + } + else { + actionName += 'outShift'; + } + if (this[actionName](e)) { + this.abortCursorAnimation(); + this.initDelayedCursor(); + this._fireSelectionChanged(); + this._updateTextarea(); + } + }, + + /** + * Moves cursor right while keeping selection + * @param {Event} e + */ + moveCursorRightWithShift: function(e) { + if (this._selectionDirection === 'left' && this.selectionStart !== this.selectionEnd) { + return this._moveRight(e, 'selectionStart'); + } + else if (this.selectionEnd !== this._text.length) { + this._selectionDirection = 'right'; + return this._moveRight(e, 'selectionEnd'); + } + }, + + /** + * Moves cursor right without keeping selection + * @param {Event} e Event object + */ + moveCursorRightWithoutShift: function(e) { + var changed = true; + this._selectionDirection = 'right'; + + if (this.selectionStart === this.selectionEnd) { + changed = this._moveRight(e, 'selectionStart'); + this.selectionEnd = this.selectionStart; + } + else { + this.selectionStart = this.selectionEnd; + } + return changed; + }, + + /** + * Removes characters from start/end + * start/end ar per grapheme position in _text array. + * + * @param {Number} start + * @param {Number} end default to start + 1 + */ + removeChars: function(start, end) { + if (typeof end === 'undefined') { + end = start + 1; + } + this.removeStyleFromTo(start, end); + this._text.splice(start, end - start); + this.text = this._text.join(''); + this.set('dirty', true); + if (this._shouldClearDimensionCache()) { + this.initDimensions(); + this.setCoords(); + } + this._removeExtraneousStyles(); + }, + + /** + * insert characters at start position, before start position. + * start equal 1 it means the text get inserted between actual grapheme 0 and 1 + * if style array is provided, it must be as the same length of text in graphemes + * if end is provided and is bigger than start, old text is replaced. + * start/end ar per grapheme position in _text array. + * + * @param {String} text text to insert + * @param {Array} style array of style objects + * @param {Number} start + * @param {Number} end default to start + 1 + */ + insertChars: function(text, style, start, end) { + if (typeof end === 'undefined') { + end = start; + } + if (end > start) { + this.removeStyleFromTo(start, end); + } + var graphemes = fabric.util.string.graphemeSplit(text); + this.insertNewStyleBlock(graphemes, start, style); + this._text = [].concat(this._text.slice(0, start), graphemes, this._text.slice(end)); + this.text = this._text.join(''); + this.set('dirty', true); + if (this._shouldClearDimensionCache()) { + this.initDimensions(); + this.setCoords(); + } + this._removeExtraneousStyles(); + }, + +}); + + +/* _TO_SVG_START_ */ +(function() { + var toFixed = fabric.util.toFixed, + multipleSpacesRegex = / +/g; + + fabric.util.object.extend(fabric.Text.prototype, /** @lends fabric.Text.prototype */ { + + /** + * Returns SVG representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + _toSVG: function() { + var offsets = this._getSVGLeftTopOffsets(), + textAndBg = this._getSVGTextAndBg(offsets.textTop, offsets.textLeft); + return this._wrapSVGTextAndBg(textAndBg); + }, + + /** + * Returns svg representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + toSVG: function(reviver) { + return this._createBaseSVGMarkup( + this._toSVG(), + { reviver: reviver, noStyle: true, withShadow: true } + ); + }, + + /** + * @private + */ + _getSVGLeftTopOffsets: function() { + return { + textLeft: -this.width / 2, + textTop: -this.height / 2, + lineTop: this.getHeightOfLine(0) + }; + }, + + /** + * @private + */ + _wrapSVGTextAndBg: function(textAndBg) { + var noShadow = true, + textDecoration = this.getSvgTextDecoration(this); + return [ + textAndBg.textBgRects.join(''), + '\t\t', + textAndBg.textSpans.join(''), + '\n' + ]; + }, + + /** + * @private + * @param {Number} textTopOffset Text top offset + * @param {Number} textLeftOffset Text left offset + * @return {Object} + */ + _getSVGTextAndBg: function(textTopOffset, textLeftOffset) { + var textSpans = [], + textBgRects = [], + height = textTopOffset, lineOffset; + // bounding-box background + this._setSVGBg(textBgRects); + + // text and text-background + for (var i = 0, len = this._textLines.length; i < len; i++) { + lineOffset = this._getLineLeftOffset(i); + if (this.textBackgroundColor || this.styleHas('textBackgroundColor', i)) { + this._setSVGTextLineBg(textBgRects, i, textLeftOffset + lineOffset, height); + } + this._setSVGTextLineText(textSpans, i, textLeftOffset + lineOffset, height); + height += this.getHeightOfLine(i); + } + + return { + textSpans: textSpans, + textBgRects: textBgRects + }; + }, + + /** + * @private + */ + _createTextCharSpan: function(_char, styleDecl, left, top) { + var shouldUseWhitespace = _char !== _char.trim() || _char.match(multipleSpacesRegex), + styleProps = this.getSvgSpanStyles(styleDecl, shouldUseWhitespace), + fillStyles = styleProps ? 'style="' + styleProps + '"' : '', + dy = styleDecl.deltaY, dySpan = '', + NUM_FRACTION_DIGITS = fabric.Object.NUM_FRACTION_DIGITS; + if (dy) { + dySpan = ' dy="' + toFixed(dy, NUM_FRACTION_DIGITS) + '" '; + } + return [ + '', + fabric.util.string.escapeXml(_char), + '' + ].join(''); + }, + + _setSVGTextLineText: function(textSpans, lineIndex, textLeftOffset, textTopOffset) { + // set proper line offset + var lineHeight = this.getHeightOfLine(lineIndex), + isJustify = this.textAlign.indexOf('justify') !== -1, + actualStyle, + nextStyle, + charsToRender = '', + charBox, style, + boxWidth = 0, + line = this._textLines[lineIndex], + timeToRender; + + textTopOffset += lineHeight * (1 - this._fontSizeFraction) / this.lineHeight; + for (var i = 0, len = line.length - 1; i <= len; i++) { + timeToRender = i === len || this.charSpacing; + charsToRender += line[i]; + charBox = this.__charBounds[lineIndex][i]; + if (boxWidth === 0) { + textLeftOffset += charBox.kernedWidth - charBox.width; + boxWidth += charBox.width; + } + else { + boxWidth += charBox.kernedWidth; + } + if (isJustify && !timeToRender) { + if (this._reSpaceAndTab.test(line[i])) { + timeToRender = true; + } + } + if (!timeToRender) { + // if we have charSpacing, we render char by char + actualStyle = actualStyle || this.getCompleteStyleDeclaration(lineIndex, i); + nextStyle = this.getCompleteStyleDeclaration(lineIndex, i + 1); + timeToRender = fabric.util.hasStyleChanged(actualStyle, nextStyle, true); + } + if (timeToRender) { + style = this._getStyleDeclaration(lineIndex, i) || { }; + textSpans.push(this._createTextCharSpan(charsToRender, style, textLeftOffset, textTopOffset)); + charsToRender = ''; + actualStyle = nextStyle; + textLeftOffset += boxWidth; + boxWidth = 0; + } + } + }, + + _pushTextBgRect: function(textBgRects, color, left, top, width, height) { + var NUM_FRACTION_DIGITS = fabric.Object.NUM_FRACTION_DIGITS; + textBgRects.push( + '\t\t\n'); + }, + + _setSVGTextLineBg: function(textBgRects, i, leftOffset, textTopOffset) { + var line = this._textLines[i], + heightOfLine = this.getHeightOfLine(i) / this.lineHeight, + boxWidth = 0, + boxStart = 0, + charBox, currentColor, + lastColor = this.getValueOfPropertyAt(i, 0, 'textBackgroundColor'); + for (var j = 0, jlen = line.length; j < jlen; j++) { + charBox = this.__charBounds[i][j]; + currentColor = this.getValueOfPropertyAt(i, j, 'textBackgroundColor'); + if (currentColor !== lastColor) { + lastColor && this._pushTextBgRect(textBgRects, lastColor, leftOffset + boxStart, + textTopOffset, boxWidth, heightOfLine); + boxStart = charBox.left; + boxWidth = charBox.width; + lastColor = currentColor; + } + else { + boxWidth += charBox.kernedWidth; + } + } + currentColor && this._pushTextBgRect(textBgRects, currentColor, leftOffset + boxStart, + textTopOffset, boxWidth, heightOfLine); + }, + + /** + * Adobe Illustrator (at least CS5) is unable to render rgba()-based fill values + * we work around it by "moving" alpha channel into opacity attribute and setting fill's alpha to 1 + * + * @private + * @param {*} value + * @return {String} + */ + _getFillAttributes: function(value) { + var fillColor = (value && typeof value === 'string') ? new fabric.Color(value) : ''; + if (!fillColor || !fillColor.getSource() || fillColor.getAlpha() === 1) { + return 'fill="' + value + '"'; + } + return 'opacity="' + fillColor.getAlpha() + '" fill="' + fillColor.setAlpha(1).toRgb() + '"'; + }, + + /** + * @private + */ + _getSVGLineTopOffset: function(lineIndex) { + var lineTopOffset = 0, lastHeight = 0; + for (var j = 0; j < lineIndex; j++) { + lineTopOffset += this.getHeightOfLine(j); + } + lastHeight = this.getHeightOfLine(j); + return { + lineTop: lineTopOffset, + offset: (this._fontSizeMult - this._fontSizeFraction) * lastHeight / (this.lineHeight * this._fontSizeMult) + }; + }, + + /** + * Returns styles-string for svg-export + * @param {Boolean} skipShadow a boolean to skip shadow filter output + * @return {String} + */ + getSvgStyles: function(skipShadow) { + var svgStyle = fabric.Object.prototype.getSvgStyles.call(this, skipShadow); + return svgStyle + ' white-space: pre;'; + }, + }); +})(); +/* _TO_SVG_END_ */ + + +(function(global) { + + 'use strict'; + + var fabric = global.fabric || (global.fabric = {}); + + /** + * Textbox class, based on IText, allows the user to resize the text rectangle + * and wraps lines automatically. Textboxes have their Y scaling locked, the + * user can only change width. Height is adjusted automatically based on the + * wrapping of lines. + * @class fabric.Textbox + * @extends fabric.IText + * @mixes fabric.Observable + * @return {fabric.Textbox} thisArg + * @see {@link fabric.Textbox#initialize} for constructor definition + */ + fabric.Textbox = fabric.util.createClass(fabric.IText, fabric.Observable, { + + /** + * Type of an object + * @type String + * @default + */ + type: 'textbox', + + /** + * Minimum width of textbox, in pixels. + * @type Number + * @default + */ + minWidth: 20, + + /** + * Minimum calculated width of a textbox, in pixels. + * fixed to 2 so that an empty textbox cannot go to 0 + * and is still selectable without text. + * @type Number + * @default + */ + dynamicMinWidth: 2, + + /** + * Cached array of text wrapping. + * @type Array + */ + __cachedLines: null, + + /** + * Override standard Object class values + */ + lockScalingFlip: true, + + /** + * Override standard Object class values + * Textbox needs this on false + */ + noScaleCache: false, + + /** + * Properties which when set cause object to change dimensions + * @type Object + * @private + */ + _dimensionAffectingProps: fabric.Text.prototype._dimensionAffectingProps.concat('width'), + + /** + * Use this regular expression to split strings in breakable lines + * @private + */ + _wordJoiners: /[ \t\r]/, + + /** + * Use this boolean property in order to split strings that have no white space concept. + * this is a cheap way to help with chinese/japanese + * @type Boolean + * @since 2.6.0 + */ + splitByGrapheme: false, + + /** + * Unlike superclass's version of this function, Textbox does not update + * its width. + * @private + * @override + */ + initDimensions: function() { + if (this.__skipDimension) { + return; + } + this.isEditing && this.initDelayedCursor(); + this.clearContextTop(); + this._clearCache(); + // clear dynamicMinWidth as it will be different after we re-wrap line + this.dynamicMinWidth = 0; + // wrap lines + this._styleMap = this._generateStyleMap(this._splitText()); + // if after wrapping, the width is smaller than dynamicMinWidth, change the width and re-wrap + if (this.dynamicMinWidth > this.width) { + this._set('width', this.dynamicMinWidth); + } + if (this.textAlign.indexOf('justify') !== -1) { + // once text is measured we need to make space fatter to make justified text. + this.enlargeSpaces(); + } + // clear cache and re-calculate height + this.height = this.calcTextHeight(); + this.saveState({ propertySet: '_dimensionAffectingProps' }); + }, + + /** + * Generate an object that translates the style object so that it is + * broken up by visual lines (new lines and automatic wrapping). + * The original text styles object is broken up by actual lines (new lines only), + * which is only sufficient for Text / IText + * @private + */ + _generateStyleMap: function(textInfo) { + var realLineCount = 0, + realLineCharCount = 0, + charCount = 0, + map = {}; + + for (var i = 0; i < textInfo.graphemeLines.length; i++) { + if (textInfo.graphemeText[charCount] === '\n' && i > 0) { + realLineCharCount = 0; + charCount++; + realLineCount++; + } + else if (!this.splitByGrapheme && this._reSpaceAndTab.test(textInfo.graphemeText[charCount]) && i > 0) { + // this case deals with space's that are removed from end of lines when wrapping + realLineCharCount++; + charCount++; + } + + map[i] = { line: realLineCount, offset: realLineCharCount }; + + charCount += textInfo.graphemeLines[i].length; + realLineCharCount += textInfo.graphemeLines[i].length; + } + + return map; + }, + + /** + * Returns true if object has a style property or has it on a specified line + * @param {Number} lineIndex + * @return {Boolean} + */ + styleHas: function(property, lineIndex) { + if (this._styleMap && !this.isWrapping) { + var map = this._styleMap[lineIndex]; + if (map) { + lineIndex = map.line; + } + } + return fabric.Text.prototype.styleHas.call(this, property, lineIndex); + }, + + /** + * Returns true if object has no styling or no styling in a line + * @param {Number} lineIndex , lineIndex is on wrapped lines. + * @return {Boolean} + */ + isEmptyStyles: function(lineIndex) { + if (!this.styles) { + return true; + } + var offset = 0, nextLineIndex = lineIndex + 1, nextOffset, obj, shouldLimit = false, + map = this._styleMap[lineIndex], mapNextLine = this._styleMap[lineIndex + 1]; + if (map) { + lineIndex = map.line; + offset = map.offset; + } + if (mapNextLine) { + nextLineIndex = mapNextLine.line; + shouldLimit = nextLineIndex === lineIndex; + nextOffset = mapNextLine.offset; + } + obj = typeof lineIndex === 'undefined' ? this.styles : { line: this.styles[lineIndex] }; + for (var p1 in obj) { + for (var p2 in obj[p1]) { + if (p2 >= offset && (!shouldLimit || p2 < nextOffset)) { + // eslint-disable-next-line no-unused-vars + for (var p3 in obj[p1][p2]) { + return false; + } + } + } + } + return true; + }, + + /** + * @param {Number} lineIndex + * @param {Number} charIndex + * @private + */ + _getStyleDeclaration: function(lineIndex, charIndex) { + if (this._styleMap && !this.isWrapping) { + var map = this._styleMap[lineIndex]; + if (!map) { + return null; + } + lineIndex = map.line; + charIndex = map.offset + charIndex; + } + return this.callSuper('_getStyleDeclaration', lineIndex, charIndex); + }, + + /** + * @param {Number} lineIndex + * @param {Number} charIndex + * @param {Object} style + * @private + */ + _setStyleDeclaration: function(lineIndex, charIndex, style) { + var map = this._styleMap[lineIndex]; + lineIndex = map.line; + charIndex = map.offset + charIndex; + + this.styles[lineIndex][charIndex] = style; + }, + + /** + * @param {Number} lineIndex + * @param {Number} charIndex + * @private + */ + _deleteStyleDeclaration: function(lineIndex, charIndex) { + var map = this._styleMap[lineIndex]; + lineIndex = map.line; + charIndex = map.offset + charIndex; + delete this.styles[lineIndex][charIndex]; + }, + + /** + * probably broken need a fix + * Returns the real style line that correspond to the wrapped lineIndex line + * Used just to verify if the line does exist or not. + * @param {Number} lineIndex + * @returns {Boolean} if the line exists or not + * @private + */ + _getLineStyle: function(lineIndex) { + var map = this._styleMap[lineIndex]; + return !!this.styles[map.line]; + }, + + /** + * Set the line style to an empty object so that is initialized + * @param {Number} lineIndex + * @param {Object} style + * @private + */ + _setLineStyle: function(lineIndex) { + var map = this._styleMap[lineIndex]; + this.styles[map.line] = {}; + }, + + /** + * Wraps text using the 'width' property of Textbox. First this function + * splits text on newlines, so we preserve newlines entered by the user. + * Then it wraps each line using the width of the Textbox by calling + * _wrapLine(). + * @param {Array} lines The string array of text that is split into lines + * @param {Number} desiredWidth width you want to wrap to + * @returns {Array} Array of lines + */ + _wrapText: function(lines, desiredWidth) { + var wrapped = [], i; + this.isWrapping = true; + for (i = 0; i < lines.length; i++) { + wrapped = wrapped.concat(this._wrapLine(lines[i], i, desiredWidth)); + } + this.isWrapping = false; + return wrapped; + }, + + /** + * Helper function to measure a string of text, given its lineIndex and charIndex offset + * it gets called when charBounds are not available yet. + * @param {CanvasRenderingContext2D} ctx + * @param {String} text + * @param {number} lineIndex + * @param {number} charOffset + * @returns {number} + * @private + */ + _measureWord: function(word, lineIndex, charOffset) { + var width = 0, prevGrapheme, skipLeft = true; + charOffset = charOffset || 0; + for (var i = 0, len = word.length; i < len; i++) { + var box = this._getGraphemeBox(word[i], lineIndex, i + charOffset, prevGrapheme, skipLeft); + width += box.kernedWidth; + prevGrapheme = word[i]; + } + return width; + }, + + /** + * Wraps a line of text using the width of the Textbox and a context. + * @param {Array} line The grapheme array that represent the line + * @param {Number} lineIndex + * @param {Number} desiredWidth width you want to wrap the line to + * @param {Number} reservedSpace space to remove from wrapping for custom functionalities + * @returns {Array} Array of line(s) into which the given text is wrapped + * to. + */ + _wrapLine: function(_line, lineIndex, desiredWidth, reservedSpace) { + var lineWidth = 0, + splitByGrapheme = this.splitByGrapheme, + graphemeLines = [], + line = [], + // spaces in different languages? + words = splitByGrapheme ? fabric.util.string.graphemeSplit(_line) : _line.split(this._wordJoiners), + word = '', + offset = 0, + infix = splitByGrapheme ? '' : ' ', + wordWidth = 0, + infixWidth = 0, + largestWordWidth = 0, + lineJustStarted = true, + additionalSpace = this._getWidthOfCharSpacing(), + reservedSpace = reservedSpace || 0; + // fix a difference between split and graphemeSplit + if (words.length === 0) { + words.push([]); + } + desiredWidth -= reservedSpace; + for (var i = 0; i < words.length; i++) { + // if using splitByGrapheme words are already in graphemes. + word = splitByGrapheme ? words[i] : fabric.util.string.graphemeSplit(words[i]); + wordWidth = this._measureWord(word, lineIndex, offset); + offset += word.length; + + lineWidth += infixWidth + wordWidth - additionalSpace; + if (lineWidth > desiredWidth && !lineJustStarted) { + graphemeLines.push(line); + line = []; + lineWidth = wordWidth; + lineJustStarted = true; + } + else { + lineWidth += additionalSpace; + } + + if (!lineJustStarted && !splitByGrapheme) { + line.push(infix); + } + line = line.concat(word); + + infixWidth = splitByGrapheme ? 0 : this._measureWord([infix], lineIndex, offset); + offset++; + lineJustStarted = false; + // keep track of largest word + if (wordWidth > largestWordWidth) { + largestWordWidth = wordWidth; + } + } + + i && graphemeLines.push(line); + + if (largestWordWidth + reservedSpace > this.dynamicMinWidth) { + this.dynamicMinWidth = largestWordWidth - additionalSpace + reservedSpace; + } + return graphemeLines; + }, + + /** + * Detect if the text line is ended with an hard break + * text and itext do not have wrapping, return false + * @param {Number} lineIndex text to split + * @return {Boolean} + */ + isEndOfWrapping: function(lineIndex) { + if (!this._styleMap[lineIndex + 1]) { + // is last line, return true; + return true; + } + if (this._styleMap[lineIndex + 1].line !== this._styleMap[lineIndex].line) { + // this is last line before a line break, return true; + return true; + } + return false; + }, + + /** + * Detect if a line has a linebreak and so we need to account for it when moving + * and counting style. + * @return Number + */ + missingNewlineOffset: function(lineIndex) { + if (this.splitByGrapheme) { + return this.isEndOfWrapping(lineIndex) ? 1 : 0; + } + return 1; + }, + + /** + * Gets lines of text to render in the Textbox. This function calculates + * text wrapping on the fly every time it is called. + * @param {String} text text to split + * @returns {Array} Array of lines in the Textbox. + * @override + */ + _splitTextIntoLines: function(text) { + var newText = fabric.Text.prototype._splitTextIntoLines.call(this, text), + graphemeLines = this._wrapText(newText.lines, this.width), + lines = new Array(graphemeLines.length); + for (var i = 0; i < graphemeLines.length; i++) { + lines[i] = graphemeLines[i].join(''); + } + newText.lines = lines; + newText.graphemeLines = graphemeLines; + return newText; + }, + + getMinWidth: function() { + return Math.max(this.minWidth, this.dynamicMinWidth); + }, + + _removeExtraneousStyles: function() { + var linesToKeep = {}; + for (var prop in this._styleMap) { + if (this._textLines[prop]) { + linesToKeep[this._styleMap[prop].line] = 1; + } + } + for (var prop in this.styles) { + if (!linesToKeep[prop]) { + delete this.styles[prop]; + } + } + }, + + /** + * Returns object representation of an instance + * @method toObject + * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output + * @return {Object} object representation of an instance + */ + toObject: function(propertiesToInclude) { + return this.callSuper('toObject', ['minWidth', 'splitByGrapheme'].concat(propertiesToInclude)); + } + }); + + /** + * Returns fabric.Textbox instance from an object representation + * @static + * @memberOf fabric.Textbox + * @param {Object} object Object to create an instance from + * @param {Function} [callback] Callback to invoke when an fabric.Textbox instance is created + */ + fabric.Textbox.fromObject = function(object, callback) { + var styles = fabric.util.stylesFromArray(object.styles, object.text); + //copy object to prevent mutation + var objCopy = Object.assign({}, object, { styles: styles }); + return fabric.Object._fromObject('Textbox', objCopy, callback, 'text'); + }; +})(typeof exports !== 'undefined' ? exports : this); + + +(function() { + + var controlsUtils = fabric.controlsUtils, + scaleSkewStyleHandler = controlsUtils.scaleSkewCursorStyleHandler, + scaleStyleHandler = controlsUtils.scaleCursorStyleHandler, + scalingEqually = controlsUtils.scalingEqually, + scalingYOrSkewingX = controlsUtils.scalingYOrSkewingX, + scalingXOrSkewingY = controlsUtils.scalingXOrSkewingY, + scaleOrSkewActionName = controlsUtils.scaleOrSkewActionName, + objectControls = fabric.Object.prototype.controls; + + objectControls.ml = new fabric.Control({ + x: -0.5, + y: 0, + cursorStyleHandler: scaleSkewStyleHandler, + actionHandler: scalingXOrSkewingY, + getActionName: scaleOrSkewActionName, + }); + + objectControls.mr = new fabric.Control({ + x: 0.5, + y: 0, + cursorStyleHandler: scaleSkewStyleHandler, + actionHandler: scalingXOrSkewingY, + getActionName: scaleOrSkewActionName, + }); + + objectControls.mb = new fabric.Control({ + x: 0, + y: 0.5, + cursorStyleHandler: scaleSkewStyleHandler, + actionHandler: scalingYOrSkewingX, + getActionName: scaleOrSkewActionName, + }); + + objectControls.mt = new fabric.Control({ + x: 0, + y: -0.5, + cursorStyleHandler: scaleSkewStyleHandler, + actionHandler: scalingYOrSkewingX, + getActionName: scaleOrSkewActionName, + }); + + objectControls.tl = new fabric.Control({ + x: -0.5, + y: -0.5, + cursorStyleHandler: scaleStyleHandler, + actionHandler: scalingEqually + }); + + objectControls.tr = new fabric.Control({ + x: 0.5, + y: -0.5, + cursorStyleHandler: scaleStyleHandler, + actionHandler: scalingEqually + }); + + objectControls.bl = new fabric.Control({ + x: -0.5, + y: 0.5, + cursorStyleHandler: scaleStyleHandler, + actionHandler: scalingEqually + }); + + objectControls.br = new fabric.Control({ + x: 0.5, + y: 0.5, + cursorStyleHandler: scaleStyleHandler, + actionHandler: scalingEqually + }); + + objectControls.mtr = new fabric.Control({ + x: 0, + y: -0.5, + actionHandler: controlsUtils.rotationWithSnapping, + cursorStyleHandler: controlsUtils.rotationStyleHandler, + offsetY: -40, + withConnection: true, + actionName: 'rotate', + }); + + if (fabric.Textbox) { + // this is breaking the prototype inheritance, no time / ideas to fix it. + // is important to document that if you want to have all objects to have a + // specific custom control, you have to add it to Object prototype and to Textbox + // prototype. The controls are shared as references. So changes to control `tr` + // can still apply to all objects if needed. + var textBoxControls = fabric.Textbox.prototype.controls = { }; + + textBoxControls.mtr = objectControls.mtr; + textBoxControls.tr = objectControls.tr; + textBoxControls.br = objectControls.br; + textBoxControls.tl = objectControls.tl; + textBoxControls.bl = objectControls.bl; + textBoxControls.mt = objectControls.mt; + textBoxControls.mb = objectControls.mb; + + textBoxControls.mr = new fabric.Control({ + x: 0.5, + y: 0, + actionHandler: controlsUtils.changeWidth, + cursorStyleHandler: scaleSkewStyleHandler, + actionName: 'resizing', + }); + + textBoxControls.ml = new fabric.Control({ + x: -0.5, + y: 0, + actionHandler: controlsUtils.changeWidth, + cursorStyleHandler: scaleSkewStyleHandler, + actionName: 'resizing', + }); + } +})(); + diff --git a/front/public/vender/fonts/mui.ttf b/front/public/vender/fonts/mui.ttf new file mode 100644 index 0000000000000000000000000000000000000000..45d3b04a371f3351b6dea69de647aa6b394c282b GIT binary patch literal 29884 zcmdUYd3;>edGyng1C%5n z2oT2xLP;PAB*Dp-l#u3Y#*j3WP$E*&CMj*xFH4iAi$j2>ZPKK_A1Q5$#@}=9j4T;Q znza1Wv1abM_nv)um*;)YF`0K=2l@QrQV-rl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6bzb}8k_BnrjXAVA3kl^$_rUkvO)=<3AjO@w3H+)3yG&iI#5Co3Z6TD zK>?$wL~$iYj9v$CkAX6zbhSOHel)YwdR)@5NDN~vg??+nBxo&lSZ?Ac-=} zRw$3qK5N$CaSv{;%$7PY#-8CfR_s|T#A9D&g?QBc*;3cVsB`?rih95b@u>4wh(|q` zE#)poJ;ZOUsE4f(k9x!k@u*j4TT1GIl2AW+6DQvQC&!;8U)?s1BdYE#{(%bhdcOf8 zIRfUKI#JR`4Fm7>sqvD$efM;!J6dWi&Oq+k3F=i{=2w+iYUBx=q9L|CVYBmJ-G$%c z<6@&Wx(#ofve4)z!pONazk|%dZy{aa^CZ1+XGy&0oCKJJkpB;f C=Z*>h literal 0 HcmV?d00001 diff --git a/front/public/vender/jquery/jquery.base64.js b/front/public/vender/jquery/jquery.base64.js new file mode 100644 index 0000000..8cda79d --- /dev/null +++ b/front/public/vender/jquery/jquery.base64.js @@ -0,0 +1,190 @@ +/*jslint adsafe: false, bitwise: true, browser: true, cap: false, css: false, + debug: false, devel: true, eqeqeq: true, es5: false, evil: false, + forin: false, fragment: false, immed: true, laxbreak: false, newcap: true, + nomen: false, on: false, onevar: true, passfail: false, plusplus: true, + regexp: false, rhino: true, safe: false, strict: false, sub: false, + undef: true, white: false, widget: false, windows: false */ +/*global jQuery: false, window: false */ +"use strict"; + +/* + * Original code (c) 2010 Nick Galbreath + * http://code.google.com/p/stringencoders/source/browse/#svn/trunk/javascript + * + * jQuery port (c) 2010 Carlo Zottmann + * http://github.com/carlo/jquery-base64 + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. +*/ + +/* base64 encode/decode compatible with window.btoa/atob + * + * window.atob/btoa is a Firefox extension to convert binary data (the "b") + * to base64 (ascii, the "a"). + * + * It is also found in Safari and Chrome. It is not available in IE. + * + * if (!window.btoa) window.btoa = $.base64.encode + * if (!window.atob) window.atob = $.base64.decode + * + * The original spec's for atob/btoa are a bit lacking + * https://developer.mozilla.org/en/DOM/window.atob + * https://developer.mozilla.org/en/DOM/window.btoa + * + * window.btoa and $.base64.encode takes a string where charCodeAt is [0,255] + * If any character is not [0,255], then an exception is thrown. + * + * window.atob and $.base64.decode take a base64-encoded string + * If the input length is not a multiple of 4, or contains invalid characters + * then an exception is thrown. + */ + +jQuery.base64 = ( function( $ ) { + + var _PADCHAR = "=", + _ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", + _VERSION = "1.0"; + + + function _getbyte64( s, i ) { + // This is oddly fast, except on Chrome/V8. + // Minimal or no improvement in performance by using a + // object with properties mapping chars to value (eg. 'A': 0) + + var idx = _ALPHA.indexOf( s.charAt( i ) ); + + if ( idx === -1 ) { + throw "Cannot decode base64"; + } + + return idx; + } + + + function _decode( s ) { + var pads = 0, + i, + b10, + imax = s.length, + x = []; + + s = String( s ); + + if ( imax === 0 ) { + return s; + } + + if ( imax % 4 !== 0 ) { + throw "Cannot decode base64"; + } + + if ( s.charAt( imax - 1 ) === _PADCHAR ) { + pads = 1; + + if ( s.charAt( imax - 2 ) === _PADCHAR ) { + pads = 2; + } + + // either way, we want to ignore this last block + imax -= 4; + } + + for ( i = 0; i < imax; i += 4 ) { + b10 = ( _getbyte64( s, i ) << 18 ) | ( _getbyte64( s, i + 1 ) << 12 ) | ( _getbyte64( s, i + 2 ) << 6 ) | _getbyte64( s, i + 3 ); + x.push( String.fromCharCode( b10 >> 16, ( b10 >> 8 ) & 0xff, b10 & 0xff ) ); + } + + switch ( pads ) { + case 1: + b10 = ( _getbyte64( s, i ) << 18 ) | ( _getbyte64( s, i + 1 ) << 12 ) | ( _getbyte64( s, i + 2 ) << 6 ); + x.push( String.fromCharCode( b10 >> 16, ( b10 >> 8 ) & 0xff ) ); + break; + + case 2: + b10 = ( _getbyte64( s, i ) << 18) | ( _getbyte64( s, i + 1 ) << 12 ); + x.push( String.fromCharCode( b10 >> 16 ) ); + break; + } + + return x.join( "" ); + } + + + function _getbyte( s, i ) { + var x = s.charCodeAt( i ); + + if ( x > 255 ) { + throw "INVALID_CHARACTER_ERR: DOM Exception 5"; + } + + return x; + } + + + function _encode( s ) { + if ( arguments.length !== 1 ) { + throw "SyntaxError: exactly one argument required"; + } + + s = String( s ); + + var i, + b10, + x = [], + imax = s.length - s.length % 3; + + if ( s.length === 0 ) { + return s; + } + + for ( i = 0; i < imax; i += 3 ) { + b10 = ( _getbyte( s, i ) << 16 ) | ( _getbyte( s, i + 1 ) << 8 ) | _getbyte( s, i + 2 ); + x.push( _ALPHA.charAt( b10 >> 18 ) ); + x.push( _ALPHA.charAt( ( b10 >> 12 ) & 0x3F ) ); + x.push( _ALPHA.charAt( ( b10 >> 6 ) & 0x3f ) ); + x.push( _ALPHA.charAt( b10 & 0x3f ) ); + } + + switch ( s.length - imax ) { + case 1: + b10 = _getbyte( s, i ) << 16; + x.push( _ALPHA.charAt( b10 >> 18 ) + _ALPHA.charAt( ( b10 >> 12 ) & 0x3F ) + _PADCHAR + _PADCHAR ); + break; + + case 2: + b10 = ( _getbyte( s, i ) << 16 ) | ( _getbyte( s, i + 1 ) << 8 ); + x.push( _ALPHA.charAt( b10 >> 18 ) + _ALPHA.charAt( ( b10 >> 12 ) & 0x3F ) + _ALPHA.charAt( ( b10 >> 6 ) & 0x3f ) + _PADCHAR ); + break; + } + + return x.join( "" ); + } + + + return { + decode: _decode, + encode: _encode, + VERSION: _VERSION + }; + +}( jQuery ) ); + diff --git a/front/public/vender/jquery/jquery.js b/front/public/vender/jquery/jquery.js new file mode 100644 index 0000000..e0966d1 --- /dev/null +++ b/front/public/vender/jquery/jquery.js @@ -0,0 +1,10872 @@ +/*! + * jQuery JavaScript Library v3.5.1 + * https://jquery.com/ + * + * Includes Sizzle.js + * https://sizzlejs.com/ + * + * Copyright JS Foundation and other contributors + * Released under the MIT license + * https://jquery.org/license + * + * Date: 2020-05-04T22:49Z + */ +( function( global, factory ) { + + "use strict"; + + if ( typeof module === "object" && typeof module.exports === "object" ) { + + // For CommonJS and CommonJS-like environments where a proper `window` + // is present, execute the factory and get jQuery. + // For environments that do not have a `window` with a `document` + // (such as Node.js), expose a factory as module.exports. + // This accentuates the need for the creation of a real `window`. + // e.g. var jQuery = require("jquery")(window); + // See ticket #14549 for more info. + module.exports = global.document ? + factory( global, true ) : + function( w ) { + if ( !w.document ) { + throw new Error( "jQuery requires a window with a document" ); + } + return factory( w ); + }; + } else { + factory( global ); + } + +// Pass this if window is not defined yet +} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) { + +// Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1 +// throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode +// arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common +// enough that all such attempts are guarded in a try block. + "use strict"; + + var arr = []; + + var getProto = Object.getPrototypeOf; + + var slice = arr.slice; + + var flat = arr.flat ? function( array ) { + return arr.flat.call( array ); + } : function( array ) { + return arr.concat.apply( [], array ); + }; + + + var push = arr.push; + + var indexOf = arr.indexOf; + + var class2type = {}; + + var toString = class2type.toString; + + var hasOwn = class2type.hasOwnProperty; + + var fnToString = hasOwn.toString; + + var ObjectFunctionString = fnToString.call( Object ); + + var support = {}; + + var isFunction = function isFunction( obj ) { + + // Support: Chrome <=57, Firefox <=52 + // In some browsers, typeof returns "function" for HTML elements + // (i.e., `typeof document.createElement( "object" ) === "function"`). + // We don't want to classify *any* DOM node as a function. + return typeof obj === "function" && typeof obj.nodeType !== "number"; + }; + + + var isWindow = function isWindow( obj ) { + return obj != null && obj === obj.window; + }; + + + var document = window.document; + + + + var preservedScriptAttributes = { + type: true, + src: true, + nonce: true, + noModule: true + }; + + function DOMEval( code, node, doc ) { + doc = doc || document; + + var i, val, + script = doc.createElement( "script" ); + + script.text = code; + if ( node ) { + for ( i in preservedScriptAttributes ) { + + // Support: Firefox 64+, Edge 18+ + // Some browsers don't support the "nonce" property on scripts. + // On the other hand, just using `getAttribute` is not enough as + // the `nonce` attribute is reset to an empty string whenever it + // becomes browsing-context connected. + // See https://github.com/whatwg/html/issues/2369 + // See https://html.spec.whatwg.org/#nonce-attributes + // The `node.getAttribute` check was added for the sake of + // `jQuery.globalEval` so that it can fake a nonce-containing node + // via an object. + val = node[ i ] || node.getAttribute && node.getAttribute( i ); + if ( val ) { + script.setAttribute( i, val ); + } + } + } + doc.head.appendChild( script ).parentNode.removeChild( script ); + } + + + function toType( obj ) { + if ( obj == null ) { + return obj + ""; + } + + // Support: Android <=2.3 only (functionish RegExp) + return typeof obj === "object" || typeof obj === "function" ? + class2type[ toString.call( obj ) ] || "object" : + typeof obj; + } + /* global Symbol */ +// Defining this global in .eslintrc.json would create a danger of using the global +// unguarded in another place, it seems safer to define global only for this module + + + + var + version = "3.5.1", + + // Define a local copy of jQuery + jQuery = function( selector, context ) { + + // The jQuery object is actually just the init constructor 'enhanced' + // Need init if jQuery is called (just allow error to be thrown if not included) + return new jQuery.fn.init( selector, context ); + }; + + jQuery.fn = jQuery.prototype = { + + // The current version of jQuery being used + jquery: version, + + constructor: jQuery, + + // The default length of a jQuery object is 0 + length: 0, + + toArray: function() { + return slice.call( this ); + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + + // Return all the elements in a clean array + if ( num == null ) { + return slice.call( this ); + } + + // Return just the one element from the set + return num < 0 ? this[ num + this.length ] : this[ num ]; + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems ) { + + // Build a new jQuery matched element set + var ret = jQuery.merge( this.constructor(), elems ); + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + + // Return the newly-formed element set + return ret; + }, + + // Execute a callback for every element in the matched set. + each: function( callback ) { + return jQuery.each( this, callback ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map( this, function( elem, i ) { + return callback.call( elem, i, elem ); + } ) ); + }, + + slice: function() { + return this.pushStack( slice.apply( this, arguments ) ); + }, + + first: function() { + return this.eq( 0 ); + }, + + last: function() { + return this.eq( -1 ); + }, + + even: function() { + return this.pushStack( jQuery.grep( this, function( _elem, i ) { + return ( i + 1 ) % 2; + } ) ); + }, + + odd: function() { + return this.pushStack( jQuery.grep( this, function( _elem, i ) { + return i % 2; + } ) ); + }, + + eq: function( i ) { + var len = this.length, + j = +i + ( i < 0 ? len : 0 ); + return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] ); + }, + + end: function() { + return this.prevObject || this.constructor(); + }, + + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push: push, + sort: arr.sort, + splice: arr.splice + }; + + jQuery.extend = jQuery.fn.extend = function() { + var options, name, src, copy, copyIsArray, clone, + target = arguments[ 0 ] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + + // Skip the boolean and the target + target = arguments[ i ] || {}; + i++; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !isFunction( target ) ) { + target = {}; + } + + // Extend jQuery itself if only one argument is passed + if ( i === length ) { + target = this; + i--; + } + + for ( ; i < length; i++ ) { + + // Only deal with non-null/undefined values + if ( ( options = arguments[ i ] ) != null ) { + + // Extend the base object + for ( name in options ) { + copy = options[ name ]; + + // Prevent Object.prototype pollution + // Prevent never-ending loop + if ( name === "__proto__" || target === copy ) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if ( deep && copy && ( jQuery.isPlainObject( copy ) || + ( copyIsArray = Array.isArray( copy ) ) ) ) { + src = target[ name ]; + + // Ensure proper type for the source value + if ( copyIsArray && !Array.isArray( src ) ) { + clone = []; + } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) { + clone = {}; + } else { + clone = src; + } + copyIsArray = false; + + // Never move original objects, clone them + target[ name ] = jQuery.extend( deep, clone, copy ); + + // Don't bring in undefined values + } else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + + // Return the modified object + return target; + }; + + jQuery.extend( { + + // Unique for each copy of jQuery on the page + expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), + + // Assume jQuery is ready without the ready module + isReady: true, + + error: function( msg ) { + throw new Error( msg ); + }, + + noop: function() {}, + + isPlainObject: function( obj ) { + var proto, Ctor; + + // Detect obvious negatives + // Use toString instead of jQuery.type to catch host objects + if ( !obj || toString.call( obj ) !== "[object Object]" ) { + return false; + } + + proto = getProto( obj ); + + // Objects with no prototype (e.g., `Object.create( null )`) are plain + if ( !proto ) { + return true; + } + + // Objects with prototype are plain iff they were constructed by a global Object function + Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor; + return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString; + }, + + isEmptyObject: function( obj ) { + var name; + + for ( name in obj ) { + return false; + } + return true; + }, + + // Evaluates a script in a provided context; falls back to the global one + // if not specified. + globalEval: function( code, options, doc ) { + DOMEval( code, { nonce: options && options.nonce }, doc ); + }, + + each: function( obj, callback ) { + var length, i = 0; + + if ( isArrayLike( obj ) ) { + length = obj.length; + for ( ; i < length; i++ ) { + if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { + break; + } + } + } else { + for ( i in obj ) { + if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { + break; + } + } + } + + return obj; + }, + + // results is for internal usage only + makeArray: function( arr, results ) { + var ret = results || []; + + if ( arr != null ) { + if ( isArrayLike( Object( arr ) ) ) { + jQuery.merge( ret, + typeof arr === "string" ? + [ arr ] : arr + ); + } else { + push.call( ret, arr ); + } + } + + return ret; + }, + + inArray: function( elem, arr, i ) { + return arr == null ? -1 : indexOf.call( arr, elem, i ); + }, + + // Support: Android <=4.0 only, PhantomJS 1 only + // push.apply(_, arraylike) throws on ancient WebKit + merge: function( first, second ) { + var len = +second.length, + j = 0, + i = first.length; + + for ( ; j < len; j++ ) { + first[ i++ ] = second[ j ]; + } + + first.length = i; + + return first; + }, + + grep: function( elems, callback, invert ) { + var callbackInverse, + matches = [], + i = 0, + length = elems.length, + callbackExpect = !invert; + + // Go through the array, only saving the items + // that pass the validator function + for ( ; i < length; i++ ) { + callbackInverse = !callback( elems[ i ], i ); + if ( callbackInverse !== callbackExpect ) { + matches.push( elems[ i ] ); + } + } + + return matches; + }, + + // arg is for internal usage only + map: function( elems, callback, arg ) { + var length, value, + i = 0, + ret = []; + + // Go through the array, translating each of the items to their new values + if ( isArrayLike( elems ) ) { + length = elems.length; + for ( ; i < length; i++ ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret.push( value ); + } + } + + // Go through every key on the object, + } else { + for ( i in elems ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret.push( value ); + } + } + } + + // Flatten any nested arrays + return flat( ret ); + }, + + // A global GUID counter for objects + guid: 1, + + // jQuery.support is not used in Core but other projects attach their + // properties to it so it needs to exist. + support: support + } ); + + if ( typeof Symbol === "function" ) { + jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; + } + +// Populate the class2type map + jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), + function( _i, name ) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); + } ); + + function isArrayLike( obj ) { + + // Support: real iOS 8.2 only (not reproducible in simulator) + // `in` check used to prevent JIT error (gh-2145) + // hasOwn isn't used here due to false negatives + // regarding Nodelist length in IE + var length = !!obj && "length" in obj && obj.length, + type = toType( obj ); + + if ( isFunction( obj ) || isWindow( obj ) ) { + return false; + } + + return type === "array" || length === 0 || + typeof length === "number" && length > 0 && ( length - 1 ) in obj; + } + var Sizzle = + /*! + * Sizzle CSS Selector Engine v2.3.5 + * https://sizzlejs.com/ + * + * Copyright JS Foundation and other contributors + * Released under the MIT license + * https://js.foundation/ + * + * Date: 2020-03-14 + */ + ( function( window ) { + var i, + support, + Expr, + getText, + isXML, + tokenize, + compile, + select, + outermostContext, + sortInput, + hasDuplicate, + + // Local document vars + setDocument, + document, + docElem, + documentIsHTML, + rbuggyQSA, + rbuggyMatches, + matches, + contains, + + // Instance-specific data + expando = "sizzle" + 1 * new Date(), + preferredDoc = window.document, + dirruns = 0, + done = 0, + classCache = createCache(), + tokenCache = createCache(), + compilerCache = createCache(), + nonnativeSelectorCache = createCache(), + sortOrder = function( a, b ) { + if ( a === b ) { + hasDuplicate = true; + } + return 0; + }, + + // Instance methods + hasOwn = ( {} ).hasOwnProperty, + arr = [], + pop = arr.pop, + pushNative = arr.push, + push = arr.push, + slice = arr.slice, + + // Use a stripped-down indexOf as it's faster than native + // https://jsperf.com/thor-indexof-vs-for/5 + indexOf = function( list, elem ) { + var i = 0, + len = list.length; + for ( ; i < len; i++ ) { + if ( list[ i ] === elem ) { + return i; + } + } + return -1; + }, + + booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|" + + "ismap|loop|multiple|open|readonly|required|scoped", + + // Regular expressions + + // http://www.w3.org/TR/css3-selectors/#whitespace + whitespace = "[\\x20\\t\\r\\n\\f]", + + // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram + identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace + + "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+", + + // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors + attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + + + // Operator (capture 2) + "*([*^$|!~]?=)" + whitespace + + + // "Attribute values must be CSS identifiers [capture 5] + // or strings [capture 3 or capture 4]" + "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + + whitespace + "*\\]", + + pseudos = ":(" + identifier + ")(?:\\((" + + + // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: + // 1. quoted (capture 3; capture 4 or capture 5) + "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + + + // 2. simple (capture 6) + "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + + + // 3. anything else (capture 2) + ".*" + + ")\\)|)", + + // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter + rwhitespace = new RegExp( whitespace + "+", "g" ), + rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + + whitespace + "+$", "g" ), + + rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), + rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + + "*" ), + rdescend = new RegExp( whitespace + "|>" ), + + rpseudo = new RegExp( pseudos ), + ridentifier = new RegExp( "^" + identifier + "$" ), + + matchExpr = { + "ID": new RegExp( "^#(" + identifier + ")" ), + "CLASS": new RegExp( "^\\.(" + identifier + ")" ), + "TAG": new RegExp( "^(" + identifier + "|[*])" ), + "ATTR": new RegExp( "^" + attributes ), + "PSEUDO": new RegExp( "^" + pseudos ), + "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + + whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + + whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), + "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), + + // For use in libraries implementing .is() + // We use this for POS matching in `select` + "needsContext": new RegExp( "^" + whitespace + + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) + }, + + rhtml = /HTML$/i, + rinputs = /^(?:input|select|textarea|button)$/i, + rheader = /^h\d$/i, + + rnative = /^[^{]+\{\s*\[native \w/, + + // Easily-parseable/retrievable ID or TAG or CLASS selectors + rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, + + rsibling = /[+~]/, + + // CSS escapes + // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters + runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g" ), + funescape = function( escape, nonHex ) { + var high = "0x" + escape.slice( 1 ) - 0x10000; + + return nonHex ? + + // Strip the backslash prefix from a non-hex escape sequence + nonHex : + + // Replace a hexadecimal escape sequence with the encoded Unicode code point + // Support: IE <=11+ + // For values outside the Basic Multilingual Plane (BMP), manually construct a + // surrogate pair + high < 0 ? + String.fromCharCode( high + 0x10000 ) : + String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); + }, + + // CSS string/identifier serialization + // https://drafts.csswg.org/cssom/#common-serializing-idioms + rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g, + fcssescape = function( ch, asCodePoint ) { + if ( asCodePoint ) { + + // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER + if ( ch === "\0" ) { + return "\uFFFD"; + } + + // Control characters and (dependent upon position) numbers get escaped as code points + return ch.slice( 0, -1 ) + "\\" + + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; + } + + // Other potentially-special ASCII characters get backslash-escaped + return "\\" + ch; + }, + + // Used for iframes + // See setDocument() + // Removing the function wrapper causes a "Permission Denied" + // error in IE + unloadHandler = function() { + setDocument(); + }, + + inDisabledFieldset = addCombinator( + function( elem ) { + return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset"; + }, + { dir: "parentNode", next: "legend" } + ); + +// Optimize for push.apply( _, NodeList ) + try { + push.apply( + ( arr = slice.call( preferredDoc.childNodes ) ), + preferredDoc.childNodes + ); + + // Support: Android<4.0 + // Detect silently failing push.apply + // eslint-disable-next-line no-unused-expressions + arr[ preferredDoc.childNodes.length ].nodeType; + } catch ( e ) { + push = { apply: arr.length ? + + // Leverage slice if possible + function( target, els ) { + pushNative.apply( target, slice.call( els ) ); + } : + + // Support: IE<9 + // Otherwise append directly + function( target, els ) { + var j = target.length, + i = 0; + + // Can't trust NodeList.length + while ( ( target[ j++ ] = els[ i++ ] ) ) {} + target.length = j - 1; + } + }; + } + + function Sizzle( selector, context, results, seed ) { + var m, i, elem, nid, match, groups, newSelector, + newContext = context && context.ownerDocument, + + // nodeType defaults to 9, since context defaults to document + nodeType = context ? context.nodeType : 9; + + results = results || []; + + // Return early from calls with invalid selector or context + if ( typeof selector !== "string" || !selector || + nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { + + return results; + } + + // Try to shortcut find operations (as opposed to filters) in HTML documents + if ( !seed ) { + setDocument( context ); + context = context || document; + + if ( documentIsHTML ) { + + // If the selector is sufficiently simple, try using a "get*By*" DOM method + // (excepting DocumentFragment context, where the methods don't exist) + if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) { + + // ID selector + if ( ( m = match[ 1 ] ) ) { + + // Document context + if ( nodeType === 9 ) { + if ( ( elem = context.getElementById( m ) ) ) { + + // Support: IE, Opera, Webkit + // TODO: identify versions + // getElementById can match elements by name instead of ID + if ( elem.id === m ) { + results.push( elem ); + return results; + } + } else { + return results; + } + + // Element context + } else { + + // Support: IE, Opera, Webkit + // TODO: identify versions + // getElementById can match elements by name instead of ID + if ( newContext && ( elem = newContext.getElementById( m ) ) && + contains( context, elem ) && + elem.id === m ) { + + results.push( elem ); + return results; + } + } + + // Type selector + } else if ( match[ 2 ] ) { + push.apply( results, context.getElementsByTagName( selector ) ); + return results; + + // Class selector + } else if ( ( m = match[ 3 ] ) && support.getElementsByClassName && + context.getElementsByClassName ) { + + push.apply( results, context.getElementsByClassName( m ) ); + return results; + } + } + + // Take advantage of querySelectorAll + if ( support.qsa && + !nonnativeSelectorCache[ selector + " " ] && + ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) && + + // Support: IE 8 only + // Exclude object elements + ( nodeType !== 1 || context.nodeName.toLowerCase() !== "object" ) ) { + + newSelector = selector; + newContext = context; + + // qSA considers elements outside a scoping root when evaluating child or + // descendant combinators, which is not what we want. + // In such cases, we work around the behavior by prefixing every selector in the + // list with an ID selector referencing the scope context. + // The technique has to be used as well when a leading combinator is used + // as such selectors are not recognized by querySelectorAll. + // Thanks to Andrew Dupont for this technique. + if ( nodeType === 1 && + ( rdescend.test( selector ) || rcombinators.test( selector ) ) ) { + + // Expand context for sibling selectors + newContext = rsibling.test( selector ) && testContext( context.parentNode ) || + context; + + // We can use :scope instead of the ID hack if the browser + // supports it & if we're not changing the context. + if ( newContext !== context || !support.scope ) { + + // Capture the context ID, setting it first if necessary + if ( ( nid = context.getAttribute( "id" ) ) ) { + nid = nid.replace( rcssescape, fcssescape ); + } else { + context.setAttribute( "id", ( nid = expando ) ); + } + } + + // Prefix every selector in the list + groups = tokenize( selector ); + i = groups.length; + while ( i-- ) { + groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " + + toSelector( groups[ i ] ); + } + newSelector = groups.join( "," ); + } + + try { + push.apply( results, + newContext.querySelectorAll( newSelector ) + ); + return results; + } catch ( qsaError ) { + nonnativeSelectorCache( selector, true ); + } finally { + if ( nid === expando ) { + context.removeAttribute( "id" ); + } + } + } + } + } + + // All others + return select( selector.replace( rtrim, "$1" ), context, results, seed ); + } + + /** + * Create key-value caches of limited size + * @returns {function(string, object)} Returns the Object data after storing it on itself with + * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) + * deleting the oldest entry + */ + function createCache() { + var keys = []; + + function cache( key, value ) { + + // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) + if ( keys.push( key + " " ) > Expr.cacheLength ) { + + // Only keep the most recent entries + delete cache[ keys.shift() ]; + } + return ( cache[ key + " " ] = value ); + } + return cache; + } + + /** + * Mark a function for special use by Sizzle + * @param {Function} fn The function to mark + */ + function markFunction( fn ) { + fn[ expando ] = true; + return fn; + } + + /** + * Support testing using an element + * @param {Function} fn Passed the created element and returns a boolean result + */ + function assert( fn ) { + var el = document.createElement( "fieldset" ); + + try { + return !!fn( el ); + } catch ( e ) { + return false; + } finally { + + // Remove from its parent by default + if ( el.parentNode ) { + el.parentNode.removeChild( el ); + } + + // release memory in IE + el = null; + } + } + + /** + * Adds the same handler for all of the specified attrs + * @param {String} attrs Pipe-separated list of attributes + * @param {Function} handler The method that will be applied + */ + function addHandle( attrs, handler ) { + var arr = attrs.split( "|" ), + i = arr.length; + + while ( i-- ) { + Expr.attrHandle[ arr[ i ] ] = handler; + } + } + + /** + * Checks document order of two siblings + * @param {Element} a + * @param {Element} b + * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b + */ + function siblingCheck( a, b ) { + var cur = b && a, + diff = cur && a.nodeType === 1 && b.nodeType === 1 && + a.sourceIndex - b.sourceIndex; + + // Use IE sourceIndex if available on both nodes + if ( diff ) { + return diff; + } + + // Check if b follows a + if ( cur ) { + while ( ( cur = cur.nextSibling ) ) { + if ( cur === b ) { + return -1; + } + } + } + + return a ? 1 : -1; + } + + /** + * Returns a function to use in pseudos for input types + * @param {String} type + */ + function createInputPseudo( type ) { + return function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === type; + }; + } + + /** + * Returns a function to use in pseudos for buttons + * @param {String} type + */ + function createButtonPseudo( type ) { + return function( elem ) { + var name = elem.nodeName.toLowerCase(); + return ( name === "input" || name === "button" ) && elem.type === type; + }; + } + + /** + * Returns a function to use in pseudos for :enabled/:disabled + * @param {Boolean} disabled true for :disabled; false for :enabled + */ + function createDisabledPseudo( disabled ) { + + // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable + return function( elem ) { + + // Only certain elements can match :enabled or :disabled + // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled + // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled + if ( "form" in elem ) { + + // Check for inherited disabledness on relevant non-disabled elements: + // * listed form-associated elements in a disabled fieldset + // https://html.spec.whatwg.org/multipage/forms.html#category-listed + // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled + // * option elements in a disabled optgroup + // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled + // All such elements have a "form" property. + if ( elem.parentNode && elem.disabled === false ) { + + // Option elements defer to a parent optgroup if present + if ( "label" in elem ) { + if ( "label" in elem.parentNode ) { + return elem.parentNode.disabled === disabled; + } else { + return elem.disabled === disabled; + } + } + + // Support: IE 6 - 11 + // Use the isDisabled shortcut property to check for disabled fieldset ancestors + return elem.isDisabled === disabled || + + // Where there is no isDisabled, check manually + /* jshint -W018 */ + elem.isDisabled !== !disabled && + inDisabledFieldset( elem ) === disabled; + } + + return elem.disabled === disabled; + + // Try to winnow out elements that can't be disabled before trusting the disabled property. + // Some victims get caught in our net (label, legend, menu, track), but it shouldn't + // even exist on them, let alone have a boolean value. + } else if ( "label" in elem ) { + return elem.disabled === disabled; + } + + // Remaining elements are neither :enabled nor :disabled + return false; + }; + } + + /** + * Returns a function to use in pseudos for positionals + * @param {Function} fn + */ + function createPositionalPseudo( fn ) { + return markFunction( function( argument ) { + argument = +argument; + return markFunction( function( seed, matches ) { + var j, + matchIndexes = fn( [], seed.length, argument ), + i = matchIndexes.length; + + // Match elements found at the specified indexes + while ( i-- ) { + if ( seed[ ( j = matchIndexes[ i ] ) ] ) { + seed[ j ] = !( matches[ j ] = seed[ j ] ); + } + } + } ); + } ); + } + + /** + * Checks a node for validity as a Sizzle context + * @param {Element|Object=} context + * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value + */ + function testContext( context ) { + return context && typeof context.getElementsByTagName !== "undefined" && context; + } + +// Expose support vars for convenience + support = Sizzle.support = {}; + + /** + * Detects XML nodes + * @param {Element|Object} elem An element or a document + * @returns {Boolean} True iff elem is a non-HTML XML node + */ + isXML = Sizzle.isXML = function( elem ) { + var namespace = elem.namespaceURI, + docElem = ( elem.ownerDocument || elem ).documentElement; + + // Support: IE <=8 + // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes + // https://bugs.jquery.com/ticket/4833 + return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" ); + }; + + /** + * Sets document-related variables once based on the current document + * @param {Element|Object} [doc] An element or document object to use to set the document + * @returns {Object} Returns the current document + */ + setDocument = Sizzle.setDocument = function( node ) { + var hasCompare, subWindow, + doc = node ? node.ownerDocument || node : preferredDoc; + + // Return early if doc is invalid or already selected + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) { + return document; + } + + // Update global variables + document = doc; + docElem = document.documentElement; + documentIsHTML = !isXML( document ); + + // Support: IE 9 - 11+, Edge 12 - 18+ + // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( preferredDoc != document && + ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) { + + // Support: IE 11, Edge + if ( subWindow.addEventListener ) { + subWindow.addEventListener( "unload", unloadHandler, false ); + + // Support: IE 9 - 10 only + } else if ( subWindow.attachEvent ) { + subWindow.attachEvent( "onunload", unloadHandler ); + } + } + + // Support: IE 8 - 11+, Edge 12 - 18+, Chrome <=16 - 25 only, Firefox <=3.6 - 31 only, + // Safari 4 - 5 only, Opera <=11.6 - 12.x only + // IE/Edge & older browsers don't support the :scope pseudo-class. + // Support: Safari 6.0 only + // Safari 6.0 supports :scope but it's an alias of :root there. + support.scope = assert( function( el ) { + docElem.appendChild( el ).appendChild( document.createElement( "div" ) ); + return typeof el.querySelectorAll !== "undefined" && + !el.querySelectorAll( ":scope fieldset div" ).length; + } ); + + /* Attributes + ---------------------------------------------------------------------- */ + + // Support: IE<8 + // Verify that getAttribute really returns attributes and not properties + // (excepting IE8 booleans) + support.attributes = assert( function( el ) { + el.className = "i"; + return !el.getAttribute( "className" ); + } ); + + /* getElement(s)By* + ---------------------------------------------------------------------- */ + + // Check if getElementsByTagName("*") returns only elements + support.getElementsByTagName = assert( function( el ) { + el.appendChild( document.createComment( "" ) ); + return !el.getElementsByTagName( "*" ).length; + } ); + + // Support: IE<9 + support.getElementsByClassName = rnative.test( document.getElementsByClassName ); + + // Support: IE<10 + // Check if getElementById returns elements by name + // The broken getElementById methods don't pick up programmatically-set names, + // so use a roundabout getElementsByName test + support.getById = assert( function( el ) { + docElem.appendChild( el ).id = expando; + return !document.getElementsByName || !document.getElementsByName( expando ).length; + } ); + + // ID filter and find + if ( support.getById ) { + Expr.filter[ "ID" ] = function( id ) { + var attrId = id.replace( runescape, funescape ); + return function( elem ) { + return elem.getAttribute( "id" ) === attrId; + }; + }; + Expr.find[ "ID" ] = function( id, context ) { + if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { + var elem = context.getElementById( id ); + return elem ? [ elem ] : []; + } + }; + } else { + Expr.filter[ "ID" ] = function( id ) { + var attrId = id.replace( runescape, funescape ); + return function( elem ) { + var node = typeof elem.getAttributeNode !== "undefined" && + elem.getAttributeNode( "id" ); + return node && node.value === attrId; + }; + }; + + // Support: IE 6 - 7 only + // getElementById is not reliable as a find shortcut + Expr.find[ "ID" ] = function( id, context ) { + if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { + var node, i, elems, + elem = context.getElementById( id ); + + if ( elem ) { + + // Verify the id attribute + node = elem.getAttributeNode( "id" ); + if ( node && node.value === id ) { + return [ elem ]; + } + + // Fall back on getElementsByName + elems = context.getElementsByName( id ); + i = 0; + while ( ( elem = elems[ i++ ] ) ) { + node = elem.getAttributeNode( "id" ); + if ( node && node.value === id ) { + return [ elem ]; + } + } + } + + return []; + } + }; + } + + // Tag + Expr.find[ "TAG" ] = support.getElementsByTagName ? + function( tag, context ) { + if ( typeof context.getElementsByTagName !== "undefined" ) { + return context.getElementsByTagName( tag ); + + // DocumentFragment nodes don't have gEBTN + } else if ( support.qsa ) { + return context.querySelectorAll( tag ); + } + } : + + function( tag, context ) { + var elem, + tmp = [], + i = 0, + + // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too + results = context.getElementsByTagName( tag ); + + // Filter out possible comments + if ( tag === "*" ) { + while ( ( elem = results[ i++ ] ) ) { + if ( elem.nodeType === 1 ) { + tmp.push( elem ); + } + } + + return tmp; + } + return results; + }; + + // Class + Expr.find[ "CLASS" ] = support.getElementsByClassName && function( className, context ) { + if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { + return context.getElementsByClassName( className ); + } + }; + + /* QSA/matchesSelector + ---------------------------------------------------------------------- */ + + // QSA and matchesSelector support + + // matchesSelector(:active) reports false when true (IE9/Opera 11.5) + rbuggyMatches = []; + + // qSa(:focus) reports false when true (Chrome 21) + // We allow this because of a bug in IE8/9 that throws an error + // whenever `document.activeElement` is accessed on an iframe + // So, we allow :focus to pass through QSA all the time to avoid the IE error + // See https://bugs.jquery.com/ticket/13378 + rbuggyQSA = []; + + if ( ( support.qsa = rnative.test( document.querySelectorAll ) ) ) { + + // Build QSA regex + // Regex strategy adopted from Diego Perini + assert( function( el ) { + + var input; + + // Select is set to empty string on purpose + // This is to test IE's treatment of not explicitly + // setting a boolean content attribute, + // since its presence should be enough + // https://bugs.jquery.com/ticket/12359 + docElem.appendChild( el ).innerHTML = "" + + ""; + + // Support: IE8, Opera 11-12.16 + // Nothing should be selected when empty strings follow ^= or $= or *= + // The test attribute must be unknown in Opera but "safe" for WinRT + // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section + if ( el.querySelectorAll( "[msallowcapture^='']" ).length ) { + rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); + } + + // Support: IE8 + // Boolean attributes and "value" are not treated correctly + if ( !el.querySelectorAll( "[selected]" ).length ) { + rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); + } + + // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+ + if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) { + rbuggyQSA.push( "~=" ); + } + + // Support: IE 11+, Edge 15 - 18+ + // IE 11/Edge don't find elements on a `[name='']` query in some cases. + // Adding a temporary attribute to the document before the selection works + // around the issue. + // Interestingly, IE 10 & older don't seem to have the issue. + input = document.createElement( "input" ); + input.setAttribute( "name", "" ); + el.appendChild( input ); + if ( !el.querySelectorAll( "[name='']" ).length ) { + rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" + + whitespace + "*(?:''|\"\")" ); + } + + // Webkit/Opera - :checked should return selected option elements + // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + // IE8 throws error here and will not see later tests + if ( !el.querySelectorAll( ":checked" ).length ) { + rbuggyQSA.push( ":checked" ); + } + + // Support: Safari 8+, iOS 8+ + // https://bugs.webkit.org/show_bug.cgi?id=136851 + // In-page `selector#id sibling-combinator selector` fails + if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) { + rbuggyQSA.push( ".#.+[+~]" ); + } + + // Support: Firefox <=3.6 - 5 only + // Old Firefox doesn't throw on a badly-escaped identifier. + el.querySelectorAll( "\\\f" ); + rbuggyQSA.push( "[\\r\\n\\f]" ); + } ); + + assert( function( el ) { + el.innerHTML = "" + + ""; + + // Support: Windows 8 Native Apps + // The type and name attributes are restricted during .innerHTML assignment + var input = document.createElement( "input" ); + input.setAttribute( "type", "hidden" ); + el.appendChild( input ).setAttribute( "name", "D" ); + + // Support: IE8 + // Enforce case-sensitivity of name attribute + if ( el.querySelectorAll( "[name=d]" ).length ) { + rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); + } + + // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) + // IE8 throws error here and will not see later tests + if ( el.querySelectorAll( ":enabled" ).length !== 2 ) { + rbuggyQSA.push( ":enabled", ":disabled" ); + } + + // Support: IE9-11+ + // IE's :disabled selector does not pick up the children of disabled fieldsets + docElem.appendChild( el ).disabled = true; + if ( el.querySelectorAll( ":disabled" ).length !== 2 ) { + rbuggyQSA.push( ":enabled", ":disabled" ); + } + + // Support: Opera 10 - 11 only + // Opera 10-11 does not throw on post-comma invalid pseudos + el.querySelectorAll( "*,:x" ); + rbuggyQSA.push( ",.*:" ); + } ); + } + + if ( ( support.matchesSelector = rnative.test( ( matches = docElem.matches || + docElem.webkitMatchesSelector || + docElem.mozMatchesSelector || + docElem.oMatchesSelector || + docElem.msMatchesSelector ) ) ) ) { + + assert( function( el ) { + + // Check to see if it's possible to do matchesSelector + // on a disconnected node (IE 9) + support.disconnectedMatch = matches.call( el, "*" ); + + // This should fail with an exception + // Gecko does not error, returns false instead + matches.call( el, "[s!='']:x" ); + rbuggyMatches.push( "!=", pseudos ); + } ); + } + + rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) ); + rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join( "|" ) ); + + /* Contains + ---------------------------------------------------------------------- */ + hasCompare = rnative.test( docElem.compareDocumentPosition ); + + // Element contains another + // Purposefully self-exclusive + // As in, an element does not contain itself + contains = hasCompare || rnative.test( docElem.contains ) ? + function( a, b ) { + var adown = a.nodeType === 9 ? a.documentElement : a, + bup = b && b.parentNode; + return a === bup || !!( bup && bup.nodeType === 1 && ( + adown.contains ? + adown.contains( bup ) : + a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 + ) ); + } : + function( a, b ) { + if ( b ) { + while ( ( b = b.parentNode ) ) { + if ( b === a ) { + return true; + } + } + } + return false; + }; + + /* Sorting + ---------------------------------------------------------------------- */ + + // Document order sorting + sortOrder = hasCompare ? + function( a, b ) { + + // Flag for duplicate removal + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + // Sort on method existence if only one input has compareDocumentPosition + var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; + if ( compare ) { + return compare; + } + + // Calculate position if both inputs belong to the same document + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ? + a.compareDocumentPosition( b ) : + + // Otherwise we know they are disconnected + 1; + + // Disconnected nodes + if ( compare & 1 || + ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) { + + // Choose the first element that is related to our preferred document + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( a == document || a.ownerDocument == preferredDoc && + contains( preferredDoc, a ) ) { + return -1; + } + + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( b == document || b.ownerDocument == preferredDoc && + contains( preferredDoc, b ) ) { + return 1; + } + + // Maintain original order + return sortInput ? + ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : + 0; + } + + return compare & 4 ? -1 : 1; + } : + function( a, b ) { + + // Exit early if the nodes are identical + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + var cur, + i = 0, + aup = a.parentNode, + bup = b.parentNode, + ap = [ a ], + bp = [ b ]; + + // Parentless nodes are either documents or disconnected + if ( !aup || !bup ) { + + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + /* eslint-disable eqeqeq */ + return a == document ? -1 : + b == document ? 1 : + /* eslint-enable eqeqeq */ + aup ? -1 : + bup ? 1 : + sortInput ? + ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : + 0; + + // If the nodes are siblings, we can do a quick check + } else if ( aup === bup ) { + return siblingCheck( a, b ); + } + + // Otherwise we need full lists of their ancestors for comparison + cur = a; + while ( ( cur = cur.parentNode ) ) { + ap.unshift( cur ); + } + cur = b; + while ( ( cur = cur.parentNode ) ) { + bp.unshift( cur ); + } + + // Walk down the tree looking for a discrepancy + while ( ap[ i ] === bp[ i ] ) { + i++; + } + + return i ? + + // Do a sibling check if the nodes have a common ancestor + siblingCheck( ap[ i ], bp[ i ] ) : + + // Otherwise nodes in our document sort first + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + /* eslint-disable eqeqeq */ + ap[ i ] == preferredDoc ? -1 : + bp[ i ] == preferredDoc ? 1 : + /* eslint-enable eqeqeq */ + 0; + }; + + return document; + }; + + Sizzle.matches = function( expr, elements ) { + return Sizzle( expr, null, null, elements ); + }; + + Sizzle.matchesSelector = function( elem, expr ) { + setDocument( elem ); + + if ( support.matchesSelector && documentIsHTML && + !nonnativeSelectorCache[ expr + " " ] && + ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && + ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { + + try { + var ret = matches.call( elem, expr ); + + // IE 9's matchesSelector returns false on disconnected nodes + if ( ret || support.disconnectedMatch || + + // As well, disconnected nodes are said to be in a document + // fragment in IE 9 + elem.document && elem.document.nodeType !== 11 ) { + return ret; + } + } catch ( e ) { + nonnativeSelectorCache( expr, true ); + } + } + + return Sizzle( expr, document, null, [ elem ] ).length > 0; + }; + + Sizzle.contains = function( context, elem ) { + + // Set document vars if needed + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( ( context.ownerDocument || context ) != document ) { + setDocument( context ); + } + return contains( context, elem ); + }; + + Sizzle.attr = function( elem, name ) { + + // Set document vars if needed + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( ( elem.ownerDocument || elem ) != document ) { + setDocument( elem ); + } + + var fn = Expr.attrHandle[ name.toLowerCase() ], + + // Don't get fooled by Object.prototype properties (jQuery #13807) + val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? + fn( elem, name, !documentIsHTML ) : + undefined; + + return val !== undefined ? + val : + support.attributes || !documentIsHTML ? + elem.getAttribute( name ) : + ( val = elem.getAttributeNode( name ) ) && val.specified ? + val.value : + null; + }; + + Sizzle.escape = function( sel ) { + return ( sel + "" ).replace( rcssescape, fcssescape ); + }; + + Sizzle.error = function( msg ) { + throw new Error( "Syntax error, unrecognized expression: " + msg ); + }; + + /** + * Document sorting and removing duplicates + * @param {ArrayLike} results + */ + Sizzle.uniqueSort = function( results ) { + var elem, + duplicates = [], + j = 0, + i = 0; + + // Unless we *know* we can detect duplicates, assume their presence + hasDuplicate = !support.detectDuplicates; + sortInput = !support.sortStable && results.slice( 0 ); + results.sort( sortOrder ); + + if ( hasDuplicate ) { + while ( ( elem = results[ i++ ] ) ) { + if ( elem === results[ i ] ) { + j = duplicates.push( i ); + } + } + while ( j-- ) { + results.splice( duplicates[ j ], 1 ); + } + } + + // Clear input after sorting to release objects + // See https://github.com/jquery/sizzle/pull/225 + sortInput = null; + + return results; + }; + + /** + * Utility function for retrieving the text value of an array of DOM nodes + * @param {Array|Element} elem + */ + getText = Sizzle.getText = function( elem ) { + var node, + ret = "", + i = 0, + nodeType = elem.nodeType; + + if ( !nodeType ) { + + // If no nodeType, this is expected to be an array + while ( ( node = elem[ i++ ] ) ) { + + // Do not traverse comment nodes + ret += getText( node ); + } + } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { + + // Use textContent for elements + // innerText usage removed for consistency of new lines (jQuery #11153) + if ( typeof elem.textContent === "string" ) { + return elem.textContent; + } else { + + // Traverse its children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { + ret += getText( elem ); + } + } + } else if ( nodeType === 3 || nodeType === 4 ) { + return elem.nodeValue; + } + + // Do not include comment or processing instruction nodes + + return ret; + }; + + Expr = Sizzle.selectors = { + + // Can be adjusted by the user + cacheLength: 50, + + createPseudo: markFunction, + + match: matchExpr, + + attrHandle: {}, + + find: {}, + + relative: { + ">": { dir: "parentNode", first: true }, + " ": { dir: "parentNode" }, + "+": { dir: "previousSibling", first: true }, + "~": { dir: "previousSibling" } + }, + + preFilter: { + "ATTR": function( match ) { + match[ 1 ] = match[ 1 ].replace( runescape, funescape ); + + // Move the given value to match[3] whether quoted or unquoted + match[ 3 ] = ( match[ 3 ] || match[ 4 ] || + match[ 5 ] || "" ).replace( runescape, funescape ); + + if ( match[ 2 ] === "~=" ) { + match[ 3 ] = " " + match[ 3 ] + " "; + } + + return match.slice( 0, 4 ); + }, + + "CHILD": function( match ) { + + /* matches from matchExpr["CHILD"] + 1 type (only|nth|...) + 2 what (child|of-type) + 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) + 4 xn-component of xn+y argument ([+-]?\d*n|) + 5 sign of xn-component + 6 x of xn-component + 7 sign of y-component + 8 y of y-component + */ + match[ 1 ] = match[ 1 ].toLowerCase(); + + if ( match[ 1 ].slice( 0, 3 ) === "nth" ) { + + // nth-* requires argument + if ( !match[ 3 ] ) { + Sizzle.error( match[ 0 ] ); + } + + // numeric x and y parameters for Expr.filter.CHILD + // remember that false/true cast respectively to 0/1 + match[ 4 ] = +( match[ 4 ] ? + match[ 5 ] + ( match[ 6 ] || 1 ) : + 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" ) ); + match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" ); + + // other types prohibit arguments + } else if ( match[ 3 ] ) { + Sizzle.error( match[ 0 ] ); + } + + return match; + }, + + "PSEUDO": function( match ) { + var excess, + unquoted = !match[ 6 ] && match[ 2 ]; + + if ( matchExpr[ "CHILD" ].test( match[ 0 ] ) ) { + return null; + } + + // Accept quoted arguments as-is + if ( match[ 3 ] ) { + match[ 2 ] = match[ 4 ] || match[ 5 ] || ""; + + // Strip excess characters from unquoted arguments + } else if ( unquoted && rpseudo.test( unquoted ) && + + // Get excess from tokenize (recursively) + ( excess = tokenize( unquoted, true ) ) && + + // advance to the next closing parenthesis + ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) { + + // excess is a negative index + match[ 0 ] = match[ 0 ].slice( 0, excess ); + match[ 2 ] = unquoted.slice( 0, excess ); + } + + // Return only captures needed by the pseudo filter method (type and argument) + return match.slice( 0, 3 ); + } + }, + + filter: { + + "TAG": function( nodeNameSelector ) { + var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); + return nodeNameSelector === "*" ? + function() { + return true; + } : + function( elem ) { + return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; + }; + }, + + "CLASS": function( className ) { + var pattern = classCache[ className + " " ]; + + return pattern || + ( pattern = new RegExp( "(^|" + whitespace + + ")" + className + "(" + whitespace + "|$)" ) ) && classCache( + className, function( elem ) { + return pattern.test( + typeof elem.className === "string" && elem.className || + typeof elem.getAttribute !== "undefined" && + elem.getAttribute( "class" ) || + "" + ); + } ); + }, + + "ATTR": function( name, operator, check ) { + return function( elem ) { + var result = Sizzle.attr( elem, name ); + + if ( result == null ) { + return operator === "!="; + } + if ( !operator ) { + return true; + } + + result += ""; + + /* eslint-disable max-len */ + + return operator === "=" ? result === check : + operator === "!=" ? result !== check : + operator === "^=" ? check && result.indexOf( check ) === 0 : + operator === "*=" ? check && result.indexOf( check ) > -1 : + operator === "$=" ? check && result.slice( -check.length ) === check : + operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : + operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : + false; + /* eslint-enable max-len */ + + }; + }, + + "CHILD": function( type, what, _argument, first, last ) { + var simple = type.slice( 0, 3 ) !== "nth", + forward = type.slice( -4 ) !== "last", + ofType = what === "of-type"; + + return first === 1 && last === 0 ? + + // Shortcut for :nth-*(n) + function( elem ) { + return !!elem.parentNode; + } : + + function( elem, _context, xml ) { + var cache, uniqueCache, outerCache, node, nodeIndex, start, + dir = simple !== forward ? "nextSibling" : "previousSibling", + parent = elem.parentNode, + name = ofType && elem.nodeName.toLowerCase(), + useCache = !xml && !ofType, + diff = false; + + if ( parent ) { + + // :(first|last|only)-(child|of-type) + if ( simple ) { + while ( dir ) { + node = elem; + while ( ( node = node[ dir ] ) ) { + if ( ofType ? + node.nodeName.toLowerCase() === name : + node.nodeType === 1 ) { + + return false; + } + } + + // Reverse direction for :only-* (if we haven't yet done so) + start = dir = type === "only" && !start && "nextSibling"; + } + return true; + } + + start = [ forward ? parent.firstChild : parent.lastChild ]; + + // non-xml :nth-child(...) stores cache data on `parent` + if ( forward && useCache ) { + + // Seek `elem` from a previously-cached index + + // ...in a gzip-friendly way + node = parent; + outerCache = node[ expando ] || ( node[ expando ] = {} ); + + // Support: IE <9 only + // Defend against cloned attroperties (jQuery gh-1709) + uniqueCache = outerCache[ node.uniqueID ] || + ( outerCache[ node.uniqueID ] = {} ); + + cache = uniqueCache[ type ] || []; + nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; + diff = nodeIndex && cache[ 2 ]; + node = nodeIndex && parent.childNodes[ nodeIndex ]; + + while ( ( node = ++nodeIndex && node && node[ dir ] || + + // Fallback to seeking `elem` from the start + ( diff = nodeIndex = 0 ) || start.pop() ) ) { + + // When found, cache indexes on `parent` and break + if ( node.nodeType === 1 && ++diff && node === elem ) { + uniqueCache[ type ] = [ dirruns, nodeIndex, diff ]; + break; + } + } + + } else { + + // Use previously-cached element index if available + if ( useCache ) { + + // ...in a gzip-friendly way + node = elem; + outerCache = node[ expando ] || ( node[ expando ] = {} ); + + // Support: IE <9 only + // Defend against cloned attroperties (jQuery gh-1709) + uniqueCache = outerCache[ node.uniqueID ] || + ( outerCache[ node.uniqueID ] = {} ); + + cache = uniqueCache[ type ] || []; + nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; + diff = nodeIndex; + } + + // xml :nth-child(...) + // or :nth-last-child(...) or :nth(-last)?-of-type(...) + if ( diff === false ) { + + // Use the same loop as above to seek `elem` from the start + while ( ( node = ++nodeIndex && node && node[ dir ] || + ( diff = nodeIndex = 0 ) || start.pop() ) ) { + + if ( ( ofType ? + node.nodeName.toLowerCase() === name : + node.nodeType === 1 ) && + ++diff ) { + + // Cache the index of each encountered element + if ( useCache ) { + outerCache = node[ expando ] || + ( node[ expando ] = {} ); + + // Support: IE <9 only + // Defend against cloned attroperties (jQuery gh-1709) + uniqueCache = outerCache[ node.uniqueID ] || + ( outerCache[ node.uniqueID ] = {} ); + + uniqueCache[ type ] = [ dirruns, diff ]; + } + + if ( node === elem ) { + break; + } + } + } + } + } + + // Incorporate the offset, then check against cycle size + diff -= last; + return diff === first || ( diff % first === 0 && diff / first >= 0 ); + } + }; + }, + + "PSEUDO": function( pseudo, argument ) { + + // pseudo-class names are case-insensitive + // http://www.w3.org/TR/selectors/#pseudo-classes + // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters + // Remember that setFilters inherits from pseudos + var args, + fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || + Sizzle.error( "unsupported pseudo: " + pseudo ); + + // The user may use createPseudo to indicate that + // arguments are needed to create the filter function + // just as Sizzle does + if ( fn[ expando ] ) { + return fn( argument ); + } + + // But maintain support for old signatures + if ( fn.length > 1 ) { + args = [ pseudo, pseudo, "", argument ]; + return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? + markFunction( function( seed, matches ) { + var idx, + matched = fn( seed, argument ), + i = matched.length; + while ( i-- ) { + idx = indexOf( seed, matched[ i ] ); + seed[ idx ] = !( matches[ idx ] = matched[ i ] ); + } + } ) : + function( elem ) { + return fn( elem, 0, args ); + }; + } + + return fn; + } + }, + + pseudos: { + + // Potentially complex pseudos + "not": markFunction( function( selector ) { + + // Trim the selector passed to compile + // to avoid treating leading and trailing + // spaces as combinators + var input = [], + results = [], + matcher = compile( selector.replace( rtrim, "$1" ) ); + + return matcher[ expando ] ? + markFunction( function( seed, matches, _context, xml ) { + var elem, + unmatched = matcher( seed, null, xml, [] ), + i = seed.length; + + // Match elements unmatched by `matcher` + while ( i-- ) { + if ( ( elem = unmatched[ i ] ) ) { + seed[ i ] = !( matches[ i ] = elem ); + } + } + } ) : + function( elem, _context, xml ) { + input[ 0 ] = elem; + matcher( input, null, xml, results ); + + // Don't keep the element (issue #299) + input[ 0 ] = null; + return !results.pop(); + }; + } ), + + "has": markFunction( function( selector ) { + return function( elem ) { + return Sizzle( selector, elem ).length > 0; + }; + } ), + + "contains": markFunction( function( text ) { + text = text.replace( runescape, funescape ); + return function( elem ) { + return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1; + }; + } ), + + // "Whether an element is represented by a :lang() selector + // is based solely on the element's language value + // being equal to the identifier C, + // or beginning with the identifier C immediately followed by "-". + // The matching of C against the element's language value is performed case-insensitively. + // The identifier C does not have to be a valid language name." + // http://www.w3.org/TR/selectors/#lang-pseudo + "lang": markFunction( function( lang ) { + + // lang value must be a valid identifier + if ( !ridentifier.test( lang || "" ) ) { + Sizzle.error( "unsupported lang: " + lang ); + } + lang = lang.replace( runescape, funescape ).toLowerCase(); + return function( elem ) { + var elemLang; + do { + if ( ( elemLang = documentIsHTML ? + elem.lang : + elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) { + + elemLang = elemLang.toLowerCase(); + return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; + } + } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 ); + return false; + }; + } ), + + // Miscellaneous + "target": function( elem ) { + var hash = window.location && window.location.hash; + return hash && hash.slice( 1 ) === elem.id; + }, + + "root": function( elem ) { + return elem === docElem; + }, + + "focus": function( elem ) { + return elem === document.activeElement && + ( !document.hasFocus || document.hasFocus() ) && + !!( elem.type || elem.href || ~elem.tabIndex ); + }, + + // Boolean properties + "enabled": createDisabledPseudo( false ), + "disabled": createDisabledPseudo( true ), + + "checked": function( elem ) { + + // In CSS3, :checked should return both checked and selected elements + // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + var nodeName = elem.nodeName.toLowerCase(); + return ( nodeName === "input" && !!elem.checked ) || + ( nodeName === "option" && !!elem.selected ); + }, + + "selected": function( elem ) { + + // Accessing this property makes selected-by-default + // options in Safari work properly + if ( elem.parentNode ) { + // eslint-disable-next-line no-unused-expressions + elem.parentNode.selectedIndex; + } + + return elem.selected === true; + }, + + // Contents + "empty": function( elem ) { + + // http://www.w3.org/TR/selectors/#empty-pseudo + // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), + // but not by others (comment: 8; processing instruction: 7; etc.) + // nodeType < 6 works because attributes (2) do not appear as children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { + if ( elem.nodeType < 6 ) { + return false; + } + } + return true; + }, + + "parent": function( elem ) { + return !Expr.pseudos[ "empty" ]( elem ); + }, + + // Element/input types + "header": function( elem ) { + return rheader.test( elem.nodeName ); + }, + + "input": function( elem ) { + return rinputs.test( elem.nodeName ); + }, + + "button": function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === "button" || name === "button"; + }, + + "text": function( elem ) { + var attr; + return elem.nodeName.toLowerCase() === "input" && + elem.type === "text" && + + // Support: IE<8 + // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" + ( ( attr = elem.getAttribute( "type" ) ) == null || + attr.toLowerCase() === "text" ); + }, + + // Position-in-collection + "first": createPositionalPseudo( function() { + return [ 0 ]; + } ), + + "last": createPositionalPseudo( function( _matchIndexes, length ) { + return [ length - 1 ]; + } ), + + "eq": createPositionalPseudo( function( _matchIndexes, length, argument ) { + return [ argument < 0 ? argument + length : argument ]; + } ), + + "even": createPositionalPseudo( function( matchIndexes, length ) { + var i = 0; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + } ), + + "odd": createPositionalPseudo( function( matchIndexes, length ) { + var i = 1; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + } ), + + "lt": createPositionalPseudo( function( matchIndexes, length, argument ) { + var i = argument < 0 ? + argument + length : + argument > length ? + length : + argument; + for ( ; --i >= 0; ) { + matchIndexes.push( i ); + } + return matchIndexes; + } ), + + "gt": createPositionalPseudo( function( matchIndexes, length, argument ) { + var i = argument < 0 ? argument + length : argument; + for ( ; ++i < length; ) { + matchIndexes.push( i ); + } + return matchIndexes; + } ) + } + }; + + Expr.pseudos[ "nth" ] = Expr.pseudos[ "eq" ]; + +// Add button/input type pseudos + for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { + Expr.pseudos[ i ] = createInputPseudo( i ); + } + for ( i in { submit: true, reset: true } ) { + Expr.pseudos[ i ] = createButtonPseudo( i ); + } + +// Easy API for creating new setFilters + function setFilters() {} + setFilters.prototype = Expr.filters = Expr.pseudos; + Expr.setFilters = new setFilters(); + + tokenize = Sizzle.tokenize = function( selector, parseOnly ) { + var matched, match, tokens, type, + soFar, groups, preFilters, + cached = tokenCache[ selector + " " ]; + + if ( cached ) { + return parseOnly ? 0 : cached.slice( 0 ); + } + + soFar = selector; + groups = []; + preFilters = Expr.preFilter; + + while ( soFar ) { + + // Comma and first run + if ( !matched || ( match = rcomma.exec( soFar ) ) ) { + if ( match ) { + + // Don't consume trailing commas as valid + soFar = soFar.slice( match[ 0 ].length ) || soFar; + } + groups.push( ( tokens = [] ) ); + } + + matched = false; + + // Combinators + if ( ( match = rcombinators.exec( soFar ) ) ) { + matched = match.shift(); + tokens.push( { + value: matched, + + // Cast descendant combinators to space + type: match[ 0 ].replace( rtrim, " " ) + } ); + soFar = soFar.slice( matched.length ); + } + + // Filters + for ( type in Expr.filter ) { + if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] || + ( match = preFilters[ type ]( match ) ) ) ) { + matched = match.shift(); + tokens.push( { + value: matched, + type: type, + matches: match + } ); + soFar = soFar.slice( matched.length ); + } + } + + if ( !matched ) { + break; + } + } + + // Return the length of the invalid excess + // if we're just parsing + // Otherwise, throw an error or return tokens + return parseOnly ? + soFar.length : + soFar ? + Sizzle.error( selector ) : + + // Cache the tokens + tokenCache( selector, groups ).slice( 0 ); + }; + + function toSelector( tokens ) { + var i = 0, + len = tokens.length, + selector = ""; + for ( ; i < len; i++ ) { + selector += tokens[ i ].value; + } + return selector; + } + + function addCombinator( matcher, combinator, base ) { + var dir = combinator.dir, + skip = combinator.next, + key = skip || dir, + checkNonElements = base && key === "parentNode", + doneName = done++; + + return combinator.first ? + + // Check against closest ancestor/preceding element + function( elem, context, xml ) { + while ( ( elem = elem[ dir ] ) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + return matcher( elem, context, xml ); + } + } + return false; + } : + + // Check against all ancestor/preceding elements + function( elem, context, xml ) { + var oldCache, uniqueCache, outerCache, + newCache = [ dirruns, doneName ]; + + // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching + if ( xml ) { + while ( ( elem = elem[ dir ] ) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + if ( matcher( elem, context, xml ) ) { + return true; + } + } + } + } else { + while ( ( elem = elem[ dir ] ) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + outerCache = elem[ expando ] || ( elem[ expando ] = {} ); + + // Support: IE <9 only + // Defend against cloned attroperties (jQuery gh-1709) + uniqueCache = outerCache[ elem.uniqueID ] || + ( outerCache[ elem.uniqueID ] = {} ); + + if ( skip && skip === elem.nodeName.toLowerCase() ) { + elem = elem[ dir ] || elem; + } else if ( ( oldCache = uniqueCache[ key ] ) && + oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { + + // Assign to newCache so results back-propagate to previous elements + return ( newCache[ 2 ] = oldCache[ 2 ] ); + } else { + + // Reuse newcache so results back-propagate to previous elements + uniqueCache[ key ] = newCache; + + // A match means we're done; a fail means we have to keep checking + if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) { + return true; + } + } + } + } + } + return false; + }; + } + + function elementMatcher( matchers ) { + return matchers.length > 1 ? + function( elem, context, xml ) { + var i = matchers.length; + while ( i-- ) { + if ( !matchers[ i ]( elem, context, xml ) ) { + return false; + } + } + return true; + } : + matchers[ 0 ]; + } + + function multipleContexts( selector, contexts, results ) { + var i = 0, + len = contexts.length; + for ( ; i < len; i++ ) { + Sizzle( selector, contexts[ i ], results ); + } + return results; + } + + function condense( unmatched, map, filter, context, xml ) { + var elem, + newUnmatched = [], + i = 0, + len = unmatched.length, + mapped = map != null; + + for ( ; i < len; i++ ) { + if ( ( elem = unmatched[ i ] ) ) { + if ( !filter || filter( elem, context, xml ) ) { + newUnmatched.push( elem ); + if ( mapped ) { + map.push( i ); + } + } + } + } + + return newUnmatched; + } + + function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { + if ( postFilter && !postFilter[ expando ] ) { + postFilter = setMatcher( postFilter ); + } + if ( postFinder && !postFinder[ expando ] ) { + postFinder = setMatcher( postFinder, postSelector ); + } + return markFunction( function( seed, results, context, xml ) { + var temp, i, elem, + preMap = [], + postMap = [], + preexisting = results.length, + + // Get initial elements from seed or context + elems = seed || multipleContexts( + selector || "*", + context.nodeType ? [ context ] : context, + [] + ), + + // Prefilter to get matcher input, preserving a map for seed-results synchronization + matcherIn = preFilter && ( seed || !selector ) ? + condense( elems, preMap, preFilter, context, xml ) : + elems, + + matcherOut = matcher ? + + // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, + postFinder || ( seed ? preFilter : preexisting || postFilter ) ? + + // ...intermediate processing is necessary + [] : + + // ...otherwise use results directly + results : + matcherIn; + + // Find primary matches + if ( matcher ) { + matcher( matcherIn, matcherOut, context, xml ); + } + + // Apply postFilter + if ( postFilter ) { + temp = condense( matcherOut, postMap ); + postFilter( temp, [], context, xml ); + + // Un-match failing elements by moving them back to matcherIn + i = temp.length; + while ( i-- ) { + if ( ( elem = temp[ i ] ) ) { + matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem ); + } + } + } + + if ( seed ) { + if ( postFinder || preFilter ) { + if ( postFinder ) { + + // Get the final matcherOut by condensing this intermediate into postFinder contexts + temp = []; + i = matcherOut.length; + while ( i-- ) { + if ( ( elem = matcherOut[ i ] ) ) { + + // Restore matcherIn since elem is not yet a final match + temp.push( ( matcherIn[ i ] = elem ) ); + } + } + postFinder( null, ( matcherOut = [] ), temp, xml ); + } + + // Move matched elements from seed to results to keep them synchronized + i = matcherOut.length; + while ( i-- ) { + if ( ( elem = matcherOut[ i ] ) && + ( temp = postFinder ? indexOf( seed, elem ) : preMap[ i ] ) > -1 ) { + + seed[ temp ] = !( results[ temp ] = elem ); + } + } + } + + // Add elements to results, through postFinder if defined + } else { + matcherOut = condense( + matcherOut === results ? + matcherOut.splice( preexisting, matcherOut.length ) : + matcherOut + ); + if ( postFinder ) { + postFinder( null, results, matcherOut, xml ); + } else { + push.apply( results, matcherOut ); + } + } + } ); + } + + function matcherFromTokens( tokens ) { + var checkContext, matcher, j, + len = tokens.length, + leadingRelative = Expr.relative[ tokens[ 0 ].type ], + implicitRelative = leadingRelative || Expr.relative[ " " ], + i = leadingRelative ? 1 : 0, + + // The foundational matcher ensures that elements are reachable from top-level context(s) + matchContext = addCombinator( function( elem ) { + return elem === checkContext; + }, implicitRelative, true ), + matchAnyContext = addCombinator( function( elem ) { + return indexOf( checkContext, elem ) > -1; + }, implicitRelative, true ), + matchers = [ function( elem, context, xml ) { + var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( + ( checkContext = context ).nodeType ? + matchContext( elem, context, xml ) : + matchAnyContext( elem, context, xml ) ); + + // Avoid hanging onto element (issue #299) + checkContext = null; + return ret; + } ]; + + for ( ; i < len; i++ ) { + if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) { + matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ]; + } else { + matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches ); + + // Return special upon seeing a positional matcher + if ( matcher[ expando ] ) { + + // Find the next relative operator (if any) for proper handling + j = ++i; + for ( ; j < len; j++ ) { + if ( Expr.relative[ tokens[ j ].type ] ) { + break; + } + } + return setMatcher( + i > 1 && elementMatcher( matchers ), + i > 1 && toSelector( + + // If the preceding token was a descendant combinator, insert an implicit any-element `*` + tokens + .slice( 0, i - 1 ) + .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } ) + ).replace( rtrim, "$1" ), + matcher, + i < j && matcherFromTokens( tokens.slice( i, j ) ), + j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ), + j < len && toSelector( tokens ) + ); + } + matchers.push( matcher ); + } + } + + return elementMatcher( matchers ); + } + + function matcherFromGroupMatchers( elementMatchers, setMatchers ) { + var bySet = setMatchers.length > 0, + byElement = elementMatchers.length > 0, + superMatcher = function( seed, context, xml, results, outermost ) { + var elem, j, matcher, + matchedCount = 0, + i = "0", + unmatched = seed && [], + setMatched = [], + contextBackup = outermostContext, + + // We must always have either seed elements or outermost context + elems = seed || byElement && Expr.find[ "TAG" ]( "*", outermost ), + + // Use integer dirruns iff this is the outermost matcher + dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ), + len = elems.length; + + if ( outermost ) { + + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + outermostContext = context == document || context || outermost; + } + + // Add elements passing elementMatchers directly to results + // Support: IE<9, Safari + // Tolerate NodeList properties (IE: "length"; Safari: ) matching elements by id + for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) { + if ( byElement && elem ) { + j = 0; + + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( !context && elem.ownerDocument != document ) { + setDocument( elem ); + xml = !documentIsHTML; + } + while ( ( matcher = elementMatchers[ j++ ] ) ) { + if ( matcher( elem, context || document, xml ) ) { + results.push( elem ); + break; + } + } + if ( outermost ) { + dirruns = dirrunsUnique; + } + } + + // Track unmatched elements for set filters + if ( bySet ) { + + // They will have gone through all possible matchers + if ( ( elem = !matcher && elem ) ) { + matchedCount--; + } + + // Lengthen the array for every element, matched or not + if ( seed ) { + unmatched.push( elem ); + } + } + } + + // `i` is now the count of elements visited above, and adding it to `matchedCount` + // makes the latter nonnegative. + matchedCount += i; + + // Apply set filters to unmatched elements + // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount` + // equals `i`), unless we didn't visit _any_ elements in the above loop because we have + // no element matchers and no seed. + // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that + // case, which will result in a "00" `matchedCount` that differs from `i` but is also + // numerically zero. + if ( bySet && i !== matchedCount ) { + j = 0; + while ( ( matcher = setMatchers[ j++ ] ) ) { + matcher( unmatched, setMatched, context, xml ); + } + + if ( seed ) { + + // Reintegrate element matches to eliminate the need for sorting + if ( matchedCount > 0 ) { + while ( i-- ) { + if ( !( unmatched[ i ] || setMatched[ i ] ) ) { + setMatched[ i ] = pop.call( results ); + } + } + } + + // Discard index placeholder values to get only actual matches + setMatched = condense( setMatched ); + } + + // Add matches to results + push.apply( results, setMatched ); + + // Seedless set matches succeeding multiple successful matchers stipulate sorting + if ( outermost && !seed && setMatched.length > 0 && + ( matchedCount + setMatchers.length ) > 1 ) { + + Sizzle.uniqueSort( results ); + } + } + + // Override manipulation of globals by nested matchers + if ( outermost ) { + dirruns = dirrunsUnique; + outermostContext = contextBackup; + } + + return unmatched; + }; + + return bySet ? + markFunction( superMatcher ) : + superMatcher; + } + + compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { + var i, + setMatchers = [], + elementMatchers = [], + cached = compilerCache[ selector + " " ]; + + if ( !cached ) { + + // Generate a function of recursive functions that can be used to check each element + if ( !match ) { + match = tokenize( selector ); + } + i = match.length; + while ( i-- ) { + cached = matcherFromTokens( match[ i ] ); + if ( cached[ expando ] ) { + setMatchers.push( cached ); + } else { + elementMatchers.push( cached ); + } + } + + // Cache the compiled function + cached = compilerCache( + selector, + matcherFromGroupMatchers( elementMatchers, setMatchers ) + ); + + // Save selector and tokenization + cached.selector = selector; + } + return cached; + }; + + /** + * A low-level selection function that works with Sizzle's compiled + * selector functions + * @param {String|Function} selector A selector or a pre-compiled + * selector function built with Sizzle.compile + * @param {Element} context + * @param {Array} [results] + * @param {Array} [seed] A set of elements to match against + */ + select = Sizzle.select = function( selector, context, results, seed ) { + var i, tokens, token, type, find, + compiled = typeof selector === "function" && selector, + match = !seed && tokenize( ( selector = compiled.selector || selector ) ); + + results = results || []; + + // Try to minimize operations if there is only one selector in the list and no seed + // (the latter of which guarantees us context) + if ( match.length === 1 ) { + + // Reduce context if the leading compound selector is an ID + tokens = match[ 0 ] = match[ 0 ].slice( 0 ); + if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" && + context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) { + + context = ( Expr.find[ "ID" ]( token.matches[ 0 ] + .replace( runescape, funescape ), context ) || [] )[ 0 ]; + if ( !context ) { + return results; + + // Precompiled matchers will still verify ancestry, so step up a level + } else if ( compiled ) { + context = context.parentNode; + } + + selector = selector.slice( tokens.shift().value.length ); + } + + // Fetch a seed set for right-to-left matching + i = matchExpr[ "needsContext" ].test( selector ) ? 0 : tokens.length; + while ( i-- ) { + token = tokens[ i ]; + + // Abort if we hit a combinator + if ( Expr.relative[ ( type = token.type ) ] ) { + break; + } + if ( ( find = Expr.find[ type ] ) ) { + + // Search, expanding context for leading sibling combinators + if ( ( seed = find( + token.matches[ 0 ].replace( runescape, funescape ), + rsibling.test( tokens[ 0 ].type ) && testContext( context.parentNode ) || + context + ) ) ) { + + // If seed is empty or no tokens remain, we can return early + tokens.splice( i, 1 ); + selector = seed.length && toSelector( tokens ); + if ( !selector ) { + push.apply( results, seed ); + return results; + } + + break; + } + } + } + } + + // Compile and execute a filtering function if one is not provided + // Provide `match` to avoid retokenization if we modified the selector above + ( compiled || compile( selector, match ) )( + seed, + context, + !documentIsHTML, + results, + !context || rsibling.test( selector ) && testContext( context.parentNode ) || context + ); + return results; + }; + +// One-time assignments + +// Sort stability + support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando; + +// Support: Chrome 14-35+ +// Always assume duplicates if they aren't passed to the comparison function + support.detectDuplicates = !!hasDuplicate; + +// Initialize against the default document + setDocument(); + +// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) +// Detached nodes confoundingly follow *each other* + support.sortDetached = assert( function( el ) { + + // Should return 1, but returns 4 (following) + return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1; + } ); + +// Support: IE<8 +// Prevent attribute/property "interpolation" +// https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx + if ( !assert( function( el ) { + el.innerHTML = ""; + return el.firstChild.getAttribute( "href" ) === "#"; + } ) ) { + addHandle( "type|href|height|width", function( elem, name, isXML ) { + if ( !isXML ) { + return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); + } + } ); + } + +// Support: IE<9 +// Use defaultValue in place of getAttribute("value") + if ( !support.attributes || !assert( function( el ) { + el.innerHTML = ""; + el.firstChild.setAttribute( "value", "" ); + return el.firstChild.getAttribute( "value" ) === ""; + } ) ) { + addHandle( "value", function( elem, _name, isXML ) { + if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { + return elem.defaultValue; + } + } ); + } + +// Support: IE<9 +// Use getAttributeNode to fetch booleans when getAttribute lies + if ( !assert( function( el ) { + return el.getAttribute( "disabled" ) == null; + } ) ) { + addHandle( booleans, function( elem, name, isXML ) { + var val; + if ( !isXML ) { + return elem[ name ] === true ? name.toLowerCase() : + ( val = elem.getAttributeNode( name ) ) && val.specified ? + val.value : + null; + } + } ); + } + + return Sizzle; + + } )( window ); + + + + jQuery.find = Sizzle; + jQuery.expr = Sizzle.selectors; + +// Deprecated + jQuery.expr[ ":" ] = jQuery.expr.pseudos; + jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort; + jQuery.text = Sizzle.getText; + jQuery.isXMLDoc = Sizzle.isXML; + jQuery.contains = Sizzle.contains; + jQuery.escapeSelector = Sizzle.escape; + + + + + var dir = function( elem, dir, until ) { + var matched = [], + truncate = until !== undefined; + + while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { + if ( elem.nodeType === 1 ) { + if ( truncate && jQuery( elem ).is( until ) ) { + break; + } + matched.push( elem ); + } + } + return matched; + }; + + + var siblings = function( n, elem ) { + var matched = []; + + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + matched.push( n ); + } + } + + return matched; + }; + + + var rneedsContext = jQuery.expr.match.needsContext; + + + + function nodeName( elem, name ) { + + return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); + + }; + var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i ); + + + +// Implement the identical functionality for filter and not + function winnow( elements, qualifier, not ) { + if ( isFunction( qualifier ) ) { + return jQuery.grep( elements, function( elem, i ) { + return !!qualifier.call( elem, i, elem ) !== not; + } ); + } + + // Single element + if ( qualifier.nodeType ) { + return jQuery.grep( elements, function( elem ) { + return ( elem === qualifier ) !== not; + } ); + } + + // Arraylike of elements (jQuery, arguments, Array) + if ( typeof qualifier !== "string" ) { + return jQuery.grep( elements, function( elem ) { + return ( indexOf.call( qualifier, elem ) > -1 ) !== not; + } ); + } + + // Filtered directly for both simple and complex selectors + return jQuery.filter( qualifier, elements, not ); + } + + jQuery.filter = function( expr, elems, not ) { + var elem = elems[ 0 ]; + + if ( not ) { + expr = ":not(" + expr + ")"; + } + + if ( elems.length === 1 && elem.nodeType === 1 ) { + return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : []; + } + + return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { + return elem.nodeType === 1; + } ) ); + }; + + jQuery.fn.extend( { + find: function( selector ) { + var i, ret, + len = this.length, + self = this; + + if ( typeof selector !== "string" ) { + return this.pushStack( jQuery( selector ).filter( function() { + for ( i = 0; i < len; i++ ) { + if ( jQuery.contains( self[ i ], this ) ) { + return true; + } + } + } ) ); + } + + ret = this.pushStack( [] ); + + for ( i = 0; i < len; i++ ) { + jQuery.find( selector, self[ i ], ret ); + } + + return len > 1 ? jQuery.uniqueSort( ret ) : ret; + }, + filter: function( selector ) { + return this.pushStack( winnow( this, selector || [], false ) ); + }, + not: function( selector ) { + return this.pushStack( winnow( this, selector || [], true ) ); + }, + is: function( selector ) { + return !!winnow( + this, + + // If this is a positional/relative selector, check membership in the returned set + // so $("p:first").is("p:last") won't return true for a doc with two "p". + typeof selector === "string" && rneedsContext.test( selector ) ? + jQuery( selector ) : + selector || [], + false + ).length; + } + } ); + + +// Initialize a jQuery object + + +// A central reference to the root jQuery(document) + var rootjQuery, + + // A simple way to check for HTML strings + // Prioritize #id over to avoid XSS via location.hash (#9521) + // Strict HTML recognition (#11290: must start with <) + // Shortcut simple #id case for speed + rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/, + + init = jQuery.fn.init = function( selector, context, root ) { + var match, elem; + + // HANDLE: $(""), $(null), $(undefined), $(false) + if ( !selector ) { + return this; + } + + // Method init() accepts an alternate rootjQuery + // so migrate can support jQuery.sub (gh-2101) + root = root || rootjQuery; + + // Handle HTML strings + if ( typeof selector === "string" ) { + if ( selector[ 0 ] === "<" && + selector[ selector.length - 1 ] === ">" && + selector.length >= 3 ) { + + // Assume that strings that start and end with <> are HTML and skip the regex check + match = [ null, selector, null ]; + + } else { + match = rquickExpr.exec( selector ); + } + + // Match html or make sure no context is specified for #id + if ( match && ( match[ 1 ] || !context ) ) { + + // HANDLE: $(html) -> $(array) + if ( match[ 1 ] ) { + context = context instanceof jQuery ? context[ 0 ] : context; + + // Option to run scripts is true for back-compat + // Intentionally let the error be thrown if parseHTML is not present + jQuery.merge( this, jQuery.parseHTML( + match[ 1 ], + context && context.nodeType ? context.ownerDocument || context : document, + true + ) ); + + // HANDLE: $(html, props) + if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { + for ( match in context ) { + + // Properties of context are called as methods if possible + if ( isFunction( this[ match ] ) ) { + this[ match ]( context[ match ] ); + + // ...and otherwise set as attributes + } else { + this.attr( match, context[ match ] ); + } + } + } + + return this; + + // HANDLE: $(#id) + } else { + elem = document.getElementById( match[ 2 ] ); + + if ( elem ) { + + // Inject the element directly into the jQuery object + this[ 0 ] = elem; + this.length = 1; + } + return this; + } + + // HANDLE: $(expr, $(...)) + } else if ( !context || context.jquery ) { + return ( context || root ).find( selector ); + + // HANDLE: $(expr, context) + // (which is just equivalent to: $(context).find(expr) + } else { + return this.constructor( context ).find( selector ); + } + + // HANDLE: $(DOMElement) + } else if ( selector.nodeType ) { + this[ 0 ] = selector; + this.length = 1; + return this; + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( isFunction( selector ) ) { + return root.ready !== undefined ? + root.ready( selector ) : + + // Execute immediately if ready is not present + selector( jQuery ); + } + + return jQuery.makeArray( selector, this ); + }; + +// Give the init function the jQuery prototype for later instantiation + init.prototype = jQuery.fn; + +// Initialize central reference + rootjQuery = jQuery( document ); + + + var rparentsprev = /^(?:parents|prev(?:Until|All))/, + + // Methods guaranteed to produce a unique set when starting from a unique set + guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; + + jQuery.fn.extend( { + has: function( target ) { + var targets = jQuery( target, this ), + l = targets.length; + + return this.filter( function() { + var i = 0; + for ( ; i < l; i++ ) { + if ( jQuery.contains( this, targets[ i ] ) ) { + return true; + } + } + } ); + }, + + closest: function( selectors, context ) { + var cur, + i = 0, + l = this.length, + matched = [], + targets = typeof selectors !== "string" && jQuery( selectors ); + + // Positional selectors never match, since there's no _selection_ context + if ( !rneedsContext.test( selectors ) ) { + for ( ; i < l; i++ ) { + for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) { + + // Always skip document fragments + if ( cur.nodeType < 11 && ( targets ? + targets.index( cur ) > -1 : + + // Don't pass non-elements to Sizzle + cur.nodeType === 1 && + jQuery.find.matchesSelector( cur, selectors ) ) ) { + + matched.push( cur ); + break; + } + } + } + } + + return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched ); + }, + + // Determine the position of an element within the set + index: function( elem ) { + + // No argument, return index in parent + if ( !elem ) { + return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; + } + + // Index in selector + if ( typeof elem === "string" ) { + return indexOf.call( jQuery( elem ), this[ 0 ] ); + } + + // Locate the position of the desired element + return indexOf.call( this, + + // If it receives a jQuery object, the first element is used + elem.jquery ? elem[ 0 ] : elem + ); + }, + + add: function( selector, context ) { + return this.pushStack( + jQuery.uniqueSort( + jQuery.merge( this.get(), jQuery( selector, context ) ) + ) + ); + }, + + addBack: function( selector ) { + return this.add( selector == null ? + this.prevObject : this.prevObject.filter( selector ) + ); + } + } ); + + function sibling( cur, dir ) { + while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {} + return cur; + } + + jQuery.each( { + parent: function( elem ) { + var parent = elem.parentNode; + return parent && parent.nodeType !== 11 ? parent : null; + }, + parents: function( elem ) { + return dir( elem, "parentNode" ); + }, + parentsUntil: function( elem, _i, until ) { + return dir( elem, "parentNode", until ); + }, + next: function( elem ) { + return sibling( elem, "nextSibling" ); + }, + prev: function( elem ) { + return sibling( elem, "previousSibling" ); + }, + nextAll: function( elem ) { + return dir( elem, "nextSibling" ); + }, + prevAll: function( elem ) { + return dir( elem, "previousSibling" ); + }, + nextUntil: function( elem, _i, until ) { + return dir( elem, "nextSibling", until ); + }, + prevUntil: function( elem, _i, until ) { + return dir( elem, "previousSibling", until ); + }, + siblings: function( elem ) { + return siblings( ( elem.parentNode || {} ).firstChild, elem ); + }, + children: function( elem ) { + return siblings( elem.firstChild ); + }, + contents: function( elem ) { + if ( elem.contentDocument != null && + + // Support: IE 11+ + // elements with no `data` attribute has an object + // `contentDocument` with a `null` prototype. + getProto( elem.contentDocument ) ) { + + return elem.contentDocument; + } + + // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only + // Treat the template element as a regular one in browsers that + // don't support it. + if ( nodeName( elem, "template" ) ) { + elem = elem.content || elem; + } + + return jQuery.merge( [], elem.childNodes ); + } + }, function( name, fn ) { + jQuery.fn[ name ] = function( until, selector ) { + var matched = jQuery.map( this, fn, until ); + + if ( name.slice( -5 ) !== "Until" ) { + selector = until; + } + + if ( selector && typeof selector === "string" ) { + matched = jQuery.filter( selector, matched ); + } + + if ( this.length > 1 ) { + + // Remove duplicates + if ( !guaranteedUnique[ name ] ) { + jQuery.uniqueSort( matched ); + } + + // Reverse order for parents* and prev-derivatives + if ( rparentsprev.test( name ) ) { + matched.reverse(); + } + } + + return this.pushStack( matched ); + }; + } ); + var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g ); + + + +// Convert String-formatted options into Object-formatted ones + function createOptions( options ) { + var object = {}; + jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) { + object[ flag ] = true; + } ); + return object; + } + + /* + * Create a callback list using the following parameters: + * + * options: an optional list of space-separated options that will change how + * the callback list behaves or a more traditional option object + * + * By default a callback list will act like an event callback list and can be + * "fired" multiple times. + * + * Possible options: + * + * once: will ensure the callback list can only be fired once (like a Deferred) + * + * memory: will keep track of previous values and will call any callback added + * after the list has been fired right away with the latest "memorized" + * values (like a Deferred) + * + * unique: will ensure a callback can only be added once (no duplicate in the list) + * + * stopOnFalse: interrupt callings when a callback returns false + * + */ + jQuery.Callbacks = function( options ) { + + // Convert options from String-formatted to Object-formatted if needed + // (we check in cache first) + options = typeof options === "string" ? + createOptions( options ) : + jQuery.extend( {}, options ); + + var // Flag to know if list is currently firing + firing, + + // Last fire value for non-forgettable lists + memory, + + // Flag to know if list was already fired + fired, + + // Flag to prevent firing + locked, + + // Actual callback list + list = [], + + // Queue of execution data for repeatable lists + queue = [], + + // Index of currently firing callback (modified by add/remove as needed) + firingIndex = -1, + + // Fire callbacks + fire = function() { + + // Enforce single-firing + locked = locked || options.once; + + // Execute callbacks for all pending executions, + // respecting firingIndex overrides and runtime changes + fired = firing = true; + for ( ; queue.length; firingIndex = -1 ) { + memory = queue.shift(); + while ( ++firingIndex < list.length ) { + + // Run callback and check for early termination + if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && + options.stopOnFalse ) { + + // Jump to end and forget the data so .add doesn't re-fire + firingIndex = list.length; + memory = false; + } + } + } + + // Forget the data if we're done with it + if ( !options.memory ) { + memory = false; + } + + firing = false; + + // Clean up if we're done firing for good + if ( locked ) { + + // Keep an empty list if we have data for future add calls + if ( memory ) { + list = []; + + // Otherwise, this object is spent + } else { + list = ""; + } + } + }, + + // Actual Callbacks object + self = { + + // Add a callback or a collection of callbacks to the list + add: function() { + if ( list ) { + + // If we have memory from a past run, we should fire after adding + if ( memory && !firing ) { + firingIndex = list.length - 1; + queue.push( memory ); + } + + ( function add( args ) { + jQuery.each( args, function( _, arg ) { + if ( isFunction( arg ) ) { + if ( !options.unique || !self.has( arg ) ) { + list.push( arg ); + } + } else if ( arg && arg.length && toType( arg ) !== "string" ) { + + // Inspect recursively + add( arg ); + } + } ); + } )( arguments ); + + if ( memory && !firing ) { + fire(); + } + } + return this; + }, + + // Remove a callback from the list + remove: function() { + jQuery.each( arguments, function( _, arg ) { + var index; + while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { + list.splice( index, 1 ); + + // Handle firing indexes + if ( index <= firingIndex ) { + firingIndex--; + } + } + } ); + return this; + }, + + // Check if a given callback is in the list. + // If no argument is given, return whether or not list has callbacks attached. + has: function( fn ) { + return fn ? + jQuery.inArray( fn, list ) > -1 : + list.length > 0; + }, + + // Remove all callbacks from the list + empty: function() { + if ( list ) { + list = []; + } + return this; + }, + + // Disable .fire and .add + // Abort any current/pending executions + // Clear all callbacks and values + disable: function() { + locked = queue = []; + list = memory = ""; + return this; + }, + disabled: function() { + return !list; + }, + + // Disable .fire + // Also disable .add unless we have memory (since it would have no effect) + // Abort any pending executions + lock: function() { + locked = queue = []; + if ( !memory && !firing ) { + list = memory = ""; + } + return this; + }, + locked: function() { + return !!locked; + }, + + // Call all callbacks with the given context and arguments + fireWith: function( context, args ) { + if ( !locked ) { + args = args || []; + args = [ context, args.slice ? args.slice() : args ]; + queue.push( args ); + if ( !firing ) { + fire(); + } + } + return this; + }, + + // Call all the callbacks with the given arguments + fire: function() { + self.fireWith( this, arguments ); + return this; + }, + + // To know if the callbacks have already been called at least once + fired: function() { + return !!fired; + } + }; + + return self; + }; + + + function Identity( v ) { + return v; + } + function Thrower( ex ) { + throw ex; + } + + function adoptValue( value, resolve, reject, noValue ) { + var method; + + try { + + // Check for promise aspect first to privilege synchronous behavior + if ( value && isFunction( ( method = value.promise ) ) ) { + method.call( value ).done( resolve ).fail( reject ); + + // Other thenables + } else if ( value && isFunction( ( method = value.then ) ) ) { + method.call( value, resolve, reject ); + + // Other non-thenables + } else { + + // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer: + // * false: [ value ].slice( 0 ) => resolve( value ) + // * true: [ value ].slice( 1 ) => resolve() + resolve.apply( undefined, [ value ].slice( noValue ) ); + } + + // For Promises/A+, convert exceptions into rejections + // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in + // Deferred#then to conditionally suppress rejection. + } catch ( value ) { + + // Support: Android 4.0 only + // Strict mode functions invoked without .call/.apply get global-object context + reject.apply( undefined, [ value ] ); + } + } + + jQuery.extend( { + + Deferred: function( func ) { + var tuples = [ + + // action, add listener, callbacks, + // ... .then handlers, argument index, [final state] + [ "notify", "progress", jQuery.Callbacks( "memory" ), + jQuery.Callbacks( "memory" ), 2 ], + [ "resolve", "done", jQuery.Callbacks( "once memory" ), + jQuery.Callbacks( "once memory" ), 0, "resolved" ], + [ "reject", "fail", jQuery.Callbacks( "once memory" ), + jQuery.Callbacks( "once memory" ), 1, "rejected" ] + ], + state = "pending", + promise = { + state: function() { + return state; + }, + always: function() { + deferred.done( arguments ).fail( arguments ); + return this; + }, + "catch": function( fn ) { + return promise.then( null, fn ); + }, + + // Keep pipe for back-compat + pipe: function( /* fnDone, fnFail, fnProgress */ ) { + var fns = arguments; + + return jQuery.Deferred( function( newDefer ) { + jQuery.each( tuples, function( _i, tuple ) { + + // Map tuples (progress, done, fail) to arguments (done, fail, progress) + var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ]; + + // deferred.progress(function() { bind to newDefer or newDefer.notify }) + // deferred.done(function() { bind to newDefer or newDefer.resolve }) + // deferred.fail(function() { bind to newDefer or newDefer.reject }) + deferred[ tuple[ 1 ] ]( function() { + var returned = fn && fn.apply( this, arguments ); + if ( returned && isFunction( returned.promise ) ) { + returned.promise() + .progress( newDefer.notify ) + .done( newDefer.resolve ) + .fail( newDefer.reject ); + } else { + newDefer[ tuple[ 0 ] + "With" ]( + this, + fn ? [ returned ] : arguments + ); + } + } ); + } ); + fns = null; + } ).promise(); + }, + then: function( onFulfilled, onRejected, onProgress ) { + var maxDepth = 0; + function resolve( depth, deferred, handler, special ) { + return function() { + var that = this, + args = arguments, + mightThrow = function() { + var returned, then; + + // Support: Promises/A+ section 2.3.3.3.3 + // https://promisesaplus.com/#point-59 + // Ignore double-resolution attempts + if ( depth < maxDepth ) { + return; + } + + returned = handler.apply( that, args ); + + // Support: Promises/A+ section 2.3.1 + // https://promisesaplus.com/#point-48 + if ( returned === deferred.promise() ) { + throw new TypeError( "Thenable self-resolution" ); + } + + // Support: Promises/A+ sections 2.3.3.1, 3.5 + // https://promisesaplus.com/#point-54 + // https://promisesaplus.com/#point-75 + // Retrieve `then` only once + then = returned && + + // Support: Promises/A+ section 2.3.4 + // https://promisesaplus.com/#point-64 + // Only check objects and functions for thenability + ( typeof returned === "object" || + typeof returned === "function" ) && + returned.then; + + // Handle a returned thenable + if ( isFunction( then ) ) { + + // Special processors (notify) just wait for resolution + if ( special ) { + then.call( + returned, + resolve( maxDepth, deferred, Identity, special ), + resolve( maxDepth, deferred, Thrower, special ) + ); + + // Normal processors (resolve) also hook into progress + } else { + + // ...and disregard older resolution values + maxDepth++; + + then.call( + returned, + resolve( maxDepth, deferred, Identity, special ), + resolve( maxDepth, deferred, Thrower, special ), + resolve( maxDepth, deferred, Identity, + deferred.notifyWith ) + ); + } + + // Handle all other returned values + } else { + + // Only substitute handlers pass on context + // and multiple values (non-spec behavior) + if ( handler !== Identity ) { + that = undefined; + args = [ returned ]; + } + + // Process the value(s) + // Default process is resolve + ( special || deferred.resolveWith )( that, args ); + } + }, + + // Only normal processors (resolve) catch and reject exceptions + process = special ? + mightThrow : + function() { + try { + mightThrow(); + } catch ( e ) { + + if ( jQuery.Deferred.exceptionHook ) { + jQuery.Deferred.exceptionHook( e, + process.stackTrace ); + } + + // Support: Promises/A+ section 2.3.3.3.4.1 + // https://promisesaplus.com/#point-61 + // Ignore post-resolution exceptions + if ( depth + 1 >= maxDepth ) { + + // Only substitute handlers pass on context + // and multiple values (non-spec behavior) + if ( handler !== Thrower ) { + that = undefined; + args = [ e ]; + } + + deferred.rejectWith( that, args ); + } + } + }; + + // Support: Promises/A+ section 2.3.3.3.1 + // https://promisesaplus.com/#point-57 + // Re-resolve promises immediately to dodge false rejection from + // subsequent errors + if ( depth ) { + process(); + } else { + + // Call an optional hook to record the stack, in case of exception + // since it's otherwise lost when execution goes async + if ( jQuery.Deferred.getStackHook ) { + process.stackTrace = jQuery.Deferred.getStackHook(); + } + window.setTimeout( process ); + } + }; + } + + return jQuery.Deferred( function( newDefer ) { + + // progress_handlers.add( ... ) + tuples[ 0 ][ 3 ].add( + resolve( + 0, + newDefer, + isFunction( onProgress ) ? + onProgress : + Identity, + newDefer.notifyWith + ) + ); + + // fulfilled_handlers.add( ... ) + tuples[ 1 ][ 3 ].add( + resolve( + 0, + newDefer, + isFunction( onFulfilled ) ? + onFulfilled : + Identity + ) + ); + + // rejected_handlers.add( ... ) + tuples[ 2 ][ 3 ].add( + resolve( + 0, + newDefer, + isFunction( onRejected ) ? + onRejected : + Thrower + ) + ); + } ).promise(); + }, + + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + return obj != null ? jQuery.extend( obj, promise ) : promise; + } + }, + deferred = {}; + + // Add list-specific methods + jQuery.each( tuples, function( i, tuple ) { + var list = tuple[ 2 ], + stateString = tuple[ 5 ]; + + // promise.progress = list.add + // promise.done = list.add + // promise.fail = list.add + promise[ tuple[ 1 ] ] = list.add; + + // Handle state + if ( stateString ) { + list.add( + function() { + + // state = "resolved" (i.e., fulfilled) + // state = "rejected" + state = stateString; + }, + + // rejected_callbacks.disable + // fulfilled_callbacks.disable + tuples[ 3 - i ][ 2 ].disable, + + // rejected_handlers.disable + // fulfilled_handlers.disable + tuples[ 3 - i ][ 3 ].disable, + + // progress_callbacks.lock + tuples[ 0 ][ 2 ].lock, + + // progress_handlers.lock + tuples[ 0 ][ 3 ].lock + ); + } + + // progress_handlers.fire + // fulfilled_handlers.fire + // rejected_handlers.fire + list.add( tuple[ 3 ].fire ); + + // deferred.notify = function() { deferred.notifyWith(...) } + // deferred.resolve = function() { deferred.resolveWith(...) } + // deferred.reject = function() { deferred.rejectWith(...) } + deferred[ tuple[ 0 ] ] = function() { + deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments ); + return this; + }; + + // deferred.notifyWith = list.fireWith + // deferred.resolveWith = list.fireWith + // deferred.rejectWith = list.fireWith + deferred[ tuple[ 0 ] + "With" ] = list.fireWith; + } ); + + // Make the deferred a promise + promise.promise( deferred ); + + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + + // All done! + return deferred; + }, + + // Deferred helper + when: function( singleValue ) { + var + + // count of uncompleted subordinates + remaining = arguments.length, + + // count of unprocessed arguments + i = remaining, + + // subordinate fulfillment data + resolveContexts = Array( i ), + resolveValues = slice.call( arguments ), + + // the master Deferred + master = jQuery.Deferred(), + + // subordinate callback factory + updateFunc = function( i ) { + return function( value ) { + resolveContexts[ i ] = this; + resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; + if ( !( --remaining ) ) { + master.resolveWith( resolveContexts, resolveValues ); + } + }; + }; + + // Single- and empty arguments are adopted like Promise.resolve + if ( remaining <= 1 ) { + adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject, + !remaining ); + + // Use .then() to unwrap secondary thenables (cf. gh-3000) + if ( master.state() === "pending" || + isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) { + + return master.then(); + } + } + + // Multiple arguments are aggregated like Promise.all array elements + while ( i-- ) { + adoptValue( resolveValues[ i ], updateFunc( i ), master.reject ); + } + + return master.promise(); + } + } ); + + +// These usually indicate a programmer mistake during development, +// warn about them ASAP rather than swallowing them by default. + var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/; + + jQuery.Deferred.exceptionHook = function( error, stack ) { + + // Support: IE 8 - 9 only + // Console exists when dev tools are open, which can happen at any time + if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) { + window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack ); + } + }; + + + + + jQuery.readyException = function( error ) { + window.setTimeout( function() { + throw error; + } ); + }; + + + + +// The deferred used on DOM ready + var readyList = jQuery.Deferred(); + + jQuery.fn.ready = function( fn ) { + + readyList + .then( fn ) + + // Wrap jQuery.readyException in a function so that the lookup + // happens at the time of error handling instead of callback + // registration. + .catch( function( error ) { + jQuery.readyException( error ); + } ); + + return this; + }; + + jQuery.extend( { + + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, + + // Handle when the DOM is ready + ready: function( wait ) { + + // Abort if there are pending holds or we're already ready + if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { + return; + } + + // Remember that the DOM is ready + jQuery.isReady = true; + + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + + // If there are functions bound, to execute + readyList.resolveWith( document, [ jQuery ] ); + } + } ); + + jQuery.ready.then = readyList.then; + +// The ready event handler and self cleanup method + function completed() { + document.removeEventListener( "DOMContentLoaded", completed ); + window.removeEventListener( "load", completed ); + jQuery.ready(); + } + +// Catch cases where $(document).ready() is called +// after the browser event has already occurred. +// Support: IE <=9 - 10 only +// Older IE sometimes signals "interactive" too soon + if ( document.readyState === "complete" || + ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { + + // Handle it asynchronously to allow scripts the opportunity to delay ready + window.setTimeout( jQuery.ready ); + + } else { + + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", completed ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", completed ); + } + + + + +// Multifunctional method to get and set values of a collection +// The value/s can optionally be executed if it's a function + var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { + var i = 0, + len = elems.length, + bulk = key == null; + + // Sets many values + if ( toType( key ) === "object" ) { + chainable = true; + for ( i in key ) { + access( elems, fn, i, key[ i ], true, emptyGet, raw ); + } + + // Sets one value + } else if ( value !== undefined ) { + chainable = true; + + if ( !isFunction( value ) ) { + raw = true; + } + + if ( bulk ) { + + // Bulk operations run against the entire set + if ( raw ) { + fn.call( elems, value ); + fn = null; + + // ...except when executing function values + } else { + bulk = fn; + fn = function( elem, _key, value ) { + return bulk.call( jQuery( elem ), value ); + }; + } + } + + if ( fn ) { + for ( ; i < len; i++ ) { + fn( + elems[ i ], key, raw ? + value : + value.call( elems[ i ], i, fn( elems[ i ], key ) ) + ); + } + } + } + + if ( chainable ) { + return elems; + } + + // Gets + if ( bulk ) { + return fn.call( elems ); + } + + return len ? fn( elems[ 0 ], key ) : emptyGet; + }; + + +// Matches dashed string for camelizing + var rmsPrefix = /^-ms-/, + rdashAlpha = /-([a-z])/g; + +// Used by camelCase as callback to replace() + function fcamelCase( _all, letter ) { + return letter.toUpperCase(); + } + +// Convert dashed to camelCase; used by the css and data modules +// Support: IE <=9 - 11, Edge 12 - 15 +// Microsoft forgot to hump their vendor prefix (#9572) + function camelCase( string ) { + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); + } + var acceptData = function( owner ) { + + // Accepts only: + // - Node + // - Node.ELEMENT_NODE + // - Node.DOCUMENT_NODE + // - Object + // - Any + return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); + }; + + + + + function Data() { + this.expando = jQuery.expando + Data.uid++; + } + + Data.uid = 1; + + Data.prototype = { + + cache: function( owner ) { + + // Check if the owner object already has a cache + var value = owner[ this.expando ]; + + // If not, create one + if ( !value ) { + value = {}; + + // We can accept data for non-element nodes in modern browsers, + // but we should not, see #8335. + // Always return an empty object. + if ( acceptData( owner ) ) { + + // If it is a node unlikely to be stringify-ed or looped over + // use plain assignment + if ( owner.nodeType ) { + owner[ this.expando ] = value; + + // Otherwise secure it in a non-enumerable property + // configurable must be true to allow the property to be + // deleted when data is removed + } else { + Object.defineProperty( owner, this.expando, { + value: value, + configurable: true + } ); + } + } + } + + return value; + }, + set: function( owner, data, value ) { + var prop, + cache = this.cache( owner ); + + // Handle: [ owner, key, value ] args + // Always use camelCase key (gh-2257) + if ( typeof data === "string" ) { + cache[ camelCase( data ) ] = value; + + // Handle: [ owner, { properties } ] args + } else { + + // Copy the properties one-by-one to the cache object + for ( prop in data ) { + cache[ camelCase( prop ) ] = data[ prop ]; + } + } + return cache; + }, + get: function( owner, key ) { + return key === undefined ? + this.cache( owner ) : + + // Always use camelCase key (gh-2257) + owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ]; + }, + access: function( owner, key, value ) { + + // In cases where either: + // + // 1. No key was specified + // 2. A string key was specified, but no value provided + // + // Take the "read" path and allow the get method to determine + // which value to return, respectively either: + // + // 1. The entire cache object + // 2. The data stored at the key + // + if ( key === undefined || + ( ( key && typeof key === "string" ) && value === undefined ) ) { + + return this.get( owner, key ); + } + + // When the key is not a string, or both a key and value + // are specified, set or extend (existing objects) with either: + // + // 1. An object of properties + // 2. A key and value + // + this.set( owner, key, value ); + + // Since the "set" path can have two possible entry points + // return the expected data based on which path was taken[*] + return value !== undefined ? value : key; + }, + remove: function( owner, key ) { + var i, + cache = owner[ this.expando ]; + + if ( cache === undefined ) { + return; + } + + if ( key !== undefined ) { + + // Support array or space separated string of keys + if ( Array.isArray( key ) ) { + + // If key is an array of keys... + // We always set camelCase keys, so remove that. + key = key.map( camelCase ); + } else { + key = camelCase( key ); + + // If a key with the spaces exists, use it. + // Otherwise, create an array by matching non-whitespace + key = key in cache ? + [ key ] : + ( key.match( rnothtmlwhite ) || [] ); + } + + i = key.length; + + while ( i-- ) { + delete cache[ key[ i ] ]; + } + } + + // Remove the expando if there's no more data + if ( key === undefined || jQuery.isEmptyObject( cache ) ) { + + // Support: Chrome <=35 - 45 + // Webkit & Blink performance suffers when deleting properties + // from DOM nodes, so set to undefined instead + // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted) + if ( owner.nodeType ) { + owner[ this.expando ] = undefined; + } else { + delete owner[ this.expando ]; + } + } + }, + hasData: function( owner ) { + var cache = owner[ this.expando ]; + return cache !== undefined && !jQuery.isEmptyObject( cache ); + } + }; + var dataPriv = new Data(); + + var dataUser = new Data(); + + + +// Implementation Summary +// +// 1. Enforce API surface and semantic compatibility with 1.9.x branch +// 2. Improve the module's maintainability by reducing the storage +// paths to a single mechanism. +// 3. Use the same single mechanism to support "private" and "user" data. +// 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) +// 5. Avoid exposing implementation details on user objects (eg. expando properties) +// 6. Provide a clear path for implementation upgrade to WeakMap in 2014 + + var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, + rmultiDash = /[A-Z]/g; + + function getData( data ) { + if ( data === "true" ) { + return true; + } + + if ( data === "false" ) { + return false; + } + + if ( data === "null" ) { + return null; + } + + // Only convert to a number if it doesn't change the string + if ( data === +data + "" ) { + return +data; + } + + if ( rbrace.test( data ) ) { + return JSON.parse( data ); + } + + return data; + } + + function dataAttr( elem, key, data ) { + var name; + + // If nothing was found internally, try to fetch any + // data from the HTML5 data-* attribute + if ( data === undefined && elem.nodeType === 1 ) { + name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase(); + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = getData( data ); + } catch ( e ) {} + + // Make sure we set the data so it isn't changed later + dataUser.set( elem, key, data ); + } else { + data = undefined; + } + } + return data; + } + + jQuery.extend( { + hasData: function( elem ) { + return dataUser.hasData( elem ) || dataPriv.hasData( elem ); + }, + + data: function( elem, name, data ) { + return dataUser.access( elem, name, data ); + }, + + removeData: function( elem, name ) { + dataUser.remove( elem, name ); + }, + + // TODO: Now that all calls to _data and _removeData have been replaced + // with direct calls to dataPriv methods, these can be deprecated. + _data: function( elem, name, data ) { + return dataPriv.access( elem, name, data ); + }, + + _removeData: function( elem, name ) { + dataPriv.remove( elem, name ); + } + } ); + + jQuery.fn.extend( { + data: function( key, value ) { + var i, name, data, + elem = this[ 0 ], + attrs = elem && elem.attributes; + + // Gets all values + if ( key === undefined ) { + if ( this.length ) { + data = dataUser.get( elem ); + + if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) { + i = attrs.length; + while ( i-- ) { + + // Support: IE 11 only + // The attrs elements can be null (#14894) + if ( attrs[ i ] ) { + name = attrs[ i ].name; + if ( name.indexOf( "data-" ) === 0 ) { + name = camelCase( name.slice( 5 ) ); + dataAttr( elem, name, data[ name ] ); + } + } + } + dataPriv.set( elem, "hasDataAttrs", true ); + } + } + + return data; + } + + // Sets multiple values + if ( typeof key === "object" ) { + return this.each( function() { + dataUser.set( this, key ); + } ); + } + + return access( this, function( value ) { + var data; + + // The calling jQuery object (element matches) is not empty + // (and therefore has an element appears at this[ 0 ]) and the + // `value` parameter was not undefined. An empty jQuery object + // will result in `undefined` for elem = this[ 0 ] which will + // throw an exception if an attempt to read a data cache is made. + if ( elem && value === undefined ) { + + // Attempt to get data from the cache + // The key will always be camelCased in Data + data = dataUser.get( elem, key ); + if ( data !== undefined ) { + return data; + } + + // Attempt to "discover" the data in + // HTML5 custom data-* attrs + data = dataAttr( elem, key ); + if ( data !== undefined ) { + return data; + } + + // We tried really hard, but the data doesn't exist. + return; + } + + // Set the data... + this.each( function() { + + // We always store the camelCased key + dataUser.set( this, key, value ); + } ); + }, null, value, arguments.length > 1, null, true ); + }, + + removeData: function( key ) { + return this.each( function() { + dataUser.remove( this, key ); + } ); + } + } ); + + + jQuery.extend( { + queue: function( elem, type, data ) { + var queue; + + if ( elem ) { + type = ( type || "fx" ) + "queue"; + queue = dataPriv.get( elem, type ); + + // Speed up dequeue by getting out quickly if this is just a lookup + if ( data ) { + if ( !queue || Array.isArray( data ) ) { + queue = dataPriv.access( elem, type, jQuery.makeArray( data ) ); + } else { + queue.push( data ); + } + } + return queue || []; + } + }, + + dequeue: function( elem, type ) { + type = type || "fx"; + + var queue = jQuery.queue( elem, type ), + startLength = queue.length, + fn = queue.shift(), + hooks = jQuery._queueHooks( elem, type ), + next = function() { + jQuery.dequeue( elem, type ); + }; + + // If the fx queue is dequeued, always remove the progress sentinel + if ( fn === "inprogress" ) { + fn = queue.shift(); + startLength--; + } + + if ( fn ) { + + // Add a progress sentinel to prevent the fx queue from being + // automatically dequeued + if ( type === "fx" ) { + queue.unshift( "inprogress" ); + } + + // Clear up the last queue stop function + delete hooks.stop; + fn.call( elem, next, hooks ); + } + + if ( !startLength && hooks ) { + hooks.empty.fire(); + } + }, + + // Not public - generate a queueHooks object, or return the current one + _queueHooks: function( elem, type ) { + var key = type + "queueHooks"; + return dataPriv.get( elem, key ) || dataPriv.access( elem, key, { + empty: jQuery.Callbacks( "once memory" ).add( function() { + dataPriv.remove( elem, [ type + "queue", key ] ); + } ) + } ); + } + } ); + + jQuery.fn.extend( { + queue: function( type, data ) { + var setter = 2; + + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + setter--; + } + + if ( arguments.length < setter ) { + return jQuery.queue( this[ 0 ], type ); + } + + return data === undefined ? + this : + this.each( function() { + var queue = jQuery.queue( this, type, data ); + + // Ensure a hooks for this queue + jQuery._queueHooks( this, type ); + + if ( type === "fx" && queue[ 0 ] !== "inprogress" ) { + jQuery.dequeue( this, type ); + } + } ); + }, + dequeue: function( type ) { + return this.each( function() { + jQuery.dequeue( this, type ); + } ); + }, + clearQueue: function( type ) { + return this.queue( type || "fx", [] ); + }, + + // Get a promise resolved when queues of a certain type + // are emptied (fx is the type by default) + promise: function( type, obj ) { + var tmp, + count = 1, + defer = jQuery.Deferred(), + elements = this, + i = this.length, + resolve = function() { + if ( !( --count ) ) { + defer.resolveWith( elements, [ elements ] ); + } + }; + + if ( typeof type !== "string" ) { + obj = type; + type = undefined; + } + type = type || "fx"; + + while ( i-- ) { + tmp = dataPriv.get( elements[ i ], type + "queueHooks" ); + if ( tmp && tmp.empty ) { + count++; + tmp.empty.add( resolve ); + } + } + resolve(); + return defer.promise( obj ); + } + } ); + var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source; + + var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); + + + var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; + + var documentElement = document.documentElement; + + + + var isAttached = function( elem ) { + return jQuery.contains( elem.ownerDocument, elem ); + }, + composed = { composed: true }; + + // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only + // Check attachment across shadow DOM boundaries when possible (gh-3504) + // Support: iOS 10.0-10.2 only + // Early iOS 10 versions support `attachShadow` but not `getRootNode`, + // leading to errors. We need to check for `getRootNode`. + if ( documentElement.getRootNode ) { + isAttached = function( elem ) { + return jQuery.contains( elem.ownerDocument, elem ) || + elem.getRootNode( composed ) === elem.ownerDocument; + }; + } + var isHiddenWithinTree = function( elem, el ) { + + // isHiddenWithinTree might be called from jQuery#filter function; + // in that case, element will be second argument + elem = el || elem; + + // Inline style trumps all + return elem.style.display === "none" || + elem.style.display === "" && + + // Otherwise, check computed style + // Support: Firefox <=43 - 45 + // Disconnected elements can have computed display: none, so first confirm that elem is + // in the document. + isAttached( elem ) && + + jQuery.css( elem, "display" ) === "none"; + }; + + + + function adjustCSS( elem, prop, valueParts, tween ) { + var adjusted, scale, + maxIterations = 20, + currentValue = tween ? + function() { + return tween.cur(); + } : + function() { + return jQuery.css( elem, prop, "" ); + }, + initial = currentValue(), + unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), + + // Starting value computation is required for potential unit mismatches + initialInUnit = elem.nodeType && + ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && + rcssNum.exec( jQuery.css( elem, prop ) ); + + if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { + + // Support: Firefox <=54 + // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144) + initial = initial / 2; + + // Trust units reported by jQuery.css + unit = unit || initialInUnit[ 3 ]; + + // Iteratively approximate from a nonzero starting point + initialInUnit = +initial || 1; + + while ( maxIterations-- ) { + + // Evaluate and update our best guess (doubling guesses that zero out). + // Finish if the scale equals or crosses 1 (making the old*new product non-positive). + jQuery.style( elem, prop, initialInUnit + unit ); + if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) { + maxIterations = 0; + } + initialInUnit = initialInUnit / scale; + + } + + initialInUnit = initialInUnit * 2; + jQuery.style( elem, prop, initialInUnit + unit ); + + // Make sure we update the tween properties later on + valueParts = valueParts || []; + } + + if ( valueParts ) { + initialInUnit = +initialInUnit || +initial || 0; + + // Apply relative offset (+=/-=) if specified + adjusted = valueParts[ 1 ] ? + initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : + +valueParts[ 2 ]; + if ( tween ) { + tween.unit = unit; + tween.start = initialInUnit; + tween.end = adjusted; + } + } + return adjusted; + } + + + var defaultDisplayMap = {}; + + function getDefaultDisplay( elem ) { + var temp, + doc = elem.ownerDocument, + nodeName = elem.nodeName, + display = defaultDisplayMap[ nodeName ]; + + if ( display ) { + return display; + } + + temp = doc.body.appendChild( doc.createElement( nodeName ) ); + display = jQuery.css( temp, "display" ); + + temp.parentNode.removeChild( temp ); + + if ( display === "none" ) { + display = "block"; + } + defaultDisplayMap[ nodeName ] = display; + + return display; + } + + function showHide( elements, show ) { + var display, elem, + values = [], + index = 0, + length = elements.length; + + // Determine new display value for elements that need to change + for ( ; index < length; index++ ) { + elem = elements[ index ]; + if ( !elem.style ) { + continue; + } + + display = elem.style.display; + if ( show ) { + + // Since we force visibility upon cascade-hidden elements, an immediate (and slow) + // check is required in this first loop unless we have a nonempty display value (either + // inline or about-to-be-restored) + if ( display === "none" ) { + values[ index ] = dataPriv.get( elem, "display" ) || null; + if ( !values[ index ] ) { + elem.style.display = ""; + } + } + if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) { + values[ index ] = getDefaultDisplay( elem ); + } + } else { + if ( display !== "none" ) { + values[ index ] = "none"; + + // Remember what we're overwriting + dataPriv.set( elem, "display", display ); + } + } + } + + // Set the display of the elements in a second loop to avoid constant reflow + for ( index = 0; index < length; index++ ) { + if ( values[ index ] != null ) { + elements[ index ].style.display = values[ index ]; + } + } + + return elements; + } + + jQuery.fn.extend( { + show: function() { + return showHide( this, true ); + }, + hide: function() { + return showHide( this ); + }, + toggle: function( state ) { + if ( typeof state === "boolean" ) { + return state ? this.show() : this.hide(); + } + + return this.each( function() { + if ( isHiddenWithinTree( this ) ) { + jQuery( this ).show(); + } else { + jQuery( this ).hide(); + } + } ); + } + } ); + var rcheckableType = ( /^(?:checkbox|radio)$/i ); + + var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i ); + + var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i ); + + + + ( function() { + var fragment = document.createDocumentFragment(), + div = fragment.appendChild( document.createElement( "div" ) ), + input = document.createElement( "input" ); + + // Support: Android 4.0 - 4.3 only + // Check state lost if the name is set (#11217) + // Support: Windows Web Apps (WWA) + // `name` and `type` must use .setAttribute for WWA (#14901) + input.setAttribute( "type", "radio" ); + input.setAttribute( "checked", "checked" ); + input.setAttribute( "name", "t" ); + + div.appendChild( input ); + + // Support: Android <=4.1 only + // Older WebKit doesn't clone checked state correctly in fragments + support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; + + // Support: IE <=11 only + // Make sure textarea (and checkbox) defaultValue is properly cloned + div.innerHTML = ""; + support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; + + // Support: IE <=9 only + // IE <=9 replaces "; + support.option = !!div.lastChild; + } )(); + + +// We have to close these tags to support XHTML (#13200) + var wrapMap = { + + // XHTML parsers do not magically insert elements in the + // same way that tag soup parsers do. So we cannot shorten + // this by omitting or other required elements. + thead: [ 1, "", "
                    " ], + col: [ 2, "", "
                    " ], + tr: [ 2, "", "
                    " ], + td: [ 3, "", "
                    " ], + + _default: [ 0, "", "" ] + }; + + wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; + wrapMap.th = wrapMap.td; + +// Support: IE <=9 only + if ( !support.option ) { + wrapMap.optgroup = wrapMap.option = [ 1, "" ]; + } + + + function getAll( context, tag ) { + + // Support: IE <=9 - 11 only + // Use typeof to avoid zero-argument method invocation on host objects (#15151) + var ret; + + if ( typeof context.getElementsByTagName !== "undefined" ) { + ret = context.getElementsByTagName( tag || "*" ); + + } else if ( typeof context.querySelectorAll !== "undefined" ) { + ret = context.querySelectorAll( tag || "*" ); + + } else { + ret = []; + } + + if ( tag === undefined || tag && nodeName( context, tag ) ) { + return jQuery.merge( [ context ], ret ); + } + + return ret; + } + + +// Mark scripts as having already been evaluated + function setGlobalEval( elems, refElements ) { + var i = 0, + l = elems.length; + + for ( ; i < l; i++ ) { + dataPriv.set( + elems[ i ], + "globalEval", + !refElements || dataPriv.get( refElements[ i ], "globalEval" ) + ); + } + } + + + var rhtml = /<|&#?\w+;/; + + function buildFragment( elems, context, scripts, selection, ignored ) { + var elem, tmp, tag, wrap, attached, j, + fragment = context.createDocumentFragment(), + nodes = [], + i = 0, + l = elems.length; + + for ( ; i < l; i++ ) { + elem = elems[ i ]; + + if ( elem || elem === 0 ) { + + // Add nodes directly + if ( toType( elem ) === "object" ) { + + // Support: Android <=4.0 only, PhantomJS 1 only + // push.apply(_, arraylike) throws on ancient WebKit + jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); + + // Convert non-html into a text node + } else if ( !rhtml.test( elem ) ) { + nodes.push( context.createTextNode( elem ) ); + + // Convert html into DOM nodes + } else { + tmp = tmp || fragment.appendChild( context.createElement( "div" ) ); + + // Deserialize a standard representation + tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); + wrap = wrapMap[ tag ] || wrapMap._default; + tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ]; + + // Descend through wrappers to the right content + j = wrap[ 0 ]; + while ( j-- ) { + tmp = tmp.lastChild; + } + + // Support: Android <=4.0 only, PhantomJS 1 only + // push.apply(_, arraylike) throws on ancient WebKit + jQuery.merge( nodes, tmp.childNodes ); + + // Remember the top-level container + tmp = fragment.firstChild; + + // Ensure the created nodes are orphaned (#12392) + tmp.textContent = ""; + } + } + } + + // Remove wrapper from fragment + fragment.textContent = ""; + + i = 0; + while ( ( elem = nodes[ i++ ] ) ) { + + // Skip elements already in the context collection (trac-4087) + if ( selection && jQuery.inArray( elem, selection ) > -1 ) { + if ( ignored ) { + ignored.push( elem ); + } + continue; + } + + attached = isAttached( elem ); + + // Append to fragment + tmp = getAll( fragment.appendChild( elem ), "script" ); + + // Preserve script evaluation history + if ( attached ) { + setGlobalEval( tmp ); + } + + // Capture executables + if ( scripts ) { + j = 0; + while ( ( elem = tmp[ j++ ] ) ) { + if ( rscriptType.test( elem.type || "" ) ) { + scripts.push( elem ); + } + } + } + } + + return fragment; + } + + + var + rkeyEvent = /^key/, + rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/, + rtypenamespace = /^([^.]*)(?:\.(.+)|)/; + + function returnTrue() { + return true; + } + + function returnFalse() { + return false; + } + +// Support: IE <=9 - 11+ +// focus() and blur() are asynchronous, except when they are no-op. +// So expect focus to be synchronous when the element is already active, +// and blur to be synchronous when the element is not already active. +// (focus and blur are always synchronous in other supported browsers, +// this just defines when we can count on it). + function expectSync( elem, type ) { + return ( elem === safeActiveElement() ) === ( type === "focus" ); + } + +// Support: IE <=9 only +// Accessing document.activeElement can throw unexpectedly +// https://bugs.jquery.com/ticket/13393 + function safeActiveElement() { + try { + return document.activeElement; + } catch ( err ) { } + } + + function on( elem, types, selector, data, fn, one ) { + var origFn, type; + + // Types can be a map of types/handlers + if ( typeof types === "object" ) { + + // ( types-Object, selector, data ) + if ( typeof selector !== "string" ) { + + // ( types-Object, data ) + data = data || selector; + selector = undefined; + } + for ( type in types ) { + on( elem, type, selector, data, types[ type ], one ); + } + return elem; + } + + if ( data == null && fn == null ) { + + // ( types, fn ) + fn = selector; + data = selector = undefined; + } else if ( fn == null ) { + if ( typeof selector === "string" ) { + + // ( types, selector, fn ) + fn = data; + data = undefined; + } else { + + // ( types, data, fn ) + fn = data; + data = selector; + selector = undefined; + } + } + if ( fn === false ) { + fn = returnFalse; + } else if ( !fn ) { + return elem; + } + + if ( one === 1 ) { + origFn = fn; + fn = function( event ) { + + // Can use an empty set, since event contains the info + jQuery().off( event ); + return origFn.apply( this, arguments ); + }; + + // Use same guid so caller can remove using origFn + fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); + } + return elem.each( function() { + jQuery.event.add( this, types, fn, data, selector ); + } ); + } + + /* + * Helper functions for managing events -- not part of the public interface. + * Props to Dean Edwards' addEvent library for many of the ideas. + */ + jQuery.event = { + + global: {}, + + add: function( elem, types, handler, data, selector ) { + + var handleObjIn, eventHandle, tmp, + events, t, handleObj, + special, handlers, type, namespaces, origType, + elemData = dataPriv.get( elem ); + + // Only attach events to objects that accept data + if ( !acceptData( elem ) ) { + return; + } + + // Caller can pass in an object of custom data in lieu of the handler + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + selector = handleObjIn.selector; + } + + // Ensure that invalid selectors throw exceptions at attach time + // Evaluate against documentElement in case elem is a non-element node (e.g., document) + if ( selector ) { + jQuery.find.matchesSelector( documentElement, selector ); + } + + // Make sure that the handler has a unique ID, used to find/remove it later + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } + + // Init the element's event structure and main handler, if this is the first + if ( !( events = elemData.events ) ) { + events = elemData.events = Object.create( null ); + } + if ( !( eventHandle = elemData.handle ) ) { + eventHandle = elemData.handle = function( e ) { + + // Discard the second event of a jQuery.event.trigger() and + // when an event is called after a page has unloaded + return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? + jQuery.event.dispatch.apply( elem, arguments ) : undefined; + }; + } + + // Handle multiple events separated by a space + types = ( types || "" ).match( rnothtmlwhite ) || [ "" ]; + t = types.length; + while ( t-- ) { + tmp = rtypenamespace.exec( types[ t ] ) || []; + type = origType = tmp[ 1 ]; + namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); + + // There *must* be a type, no attaching namespace-only handlers + if ( !type ) { + continue; + } + + // If event changes its type, use the special event handlers for the changed type + special = jQuery.event.special[ type ] || {}; + + // If selector defined, determine special event api type, otherwise given type + type = ( selector ? special.delegateType : special.bindType ) || type; + + // Update special based on newly reset type + special = jQuery.event.special[ type ] || {}; + + // handleObj is passed to all event handlers + handleObj = jQuery.extend( { + type: type, + origType: origType, + data: data, + handler: handler, + guid: handler.guid, + selector: selector, + needsContext: selector && jQuery.expr.match.needsContext.test( selector ), + namespace: namespaces.join( "." ) + }, handleObjIn ); + + // Init the event handler queue if we're the first + if ( !( handlers = events[ type ] ) ) { + handlers = events[ type ] = []; + handlers.delegateCount = 0; + + // Only use addEventListener if the special events handler returns false + if ( !special.setup || + special.setup.call( elem, data, namespaces, eventHandle ) === false ) { + + if ( elem.addEventListener ) { + elem.addEventListener( type, eventHandle ); + } + } + } + + if ( special.add ) { + special.add.call( elem, handleObj ); + + if ( !handleObj.handler.guid ) { + handleObj.handler.guid = handler.guid; + } + } + + // Add to the element's handler list, delegates in front + if ( selector ) { + handlers.splice( handlers.delegateCount++, 0, handleObj ); + } else { + handlers.push( handleObj ); + } + + // Keep track of which events have ever been used, for event optimization + jQuery.event.global[ type ] = true; + } + + }, + + // Detach an event or set of events from an element + remove: function( elem, types, handler, selector, mappedTypes ) { + + var j, origCount, tmp, + events, t, handleObj, + special, handlers, type, namespaces, origType, + elemData = dataPriv.hasData( elem ) && dataPriv.get( elem ); + + if ( !elemData || !( events = elemData.events ) ) { + return; + } + + // Once for each type.namespace in types; type may be omitted + types = ( types || "" ).match( rnothtmlwhite ) || [ "" ]; + t = types.length; + while ( t-- ) { + tmp = rtypenamespace.exec( types[ t ] ) || []; + type = origType = tmp[ 1 ]; + namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); + + // Unbind all events (on this namespace, if provided) for the element + if ( !type ) { + for ( type in events ) { + jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); + } + continue; + } + + special = jQuery.event.special[ type ] || {}; + type = ( selector ? special.delegateType : special.bindType ) || type; + handlers = events[ type ] || []; + tmp = tmp[ 2 ] && + new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ); + + // Remove matching events + origCount = j = handlers.length; + while ( j-- ) { + handleObj = handlers[ j ]; + + if ( ( mappedTypes || origType === handleObj.origType ) && + ( !handler || handler.guid === handleObj.guid ) && + ( !tmp || tmp.test( handleObj.namespace ) ) && + ( !selector || selector === handleObj.selector || + selector === "**" && handleObj.selector ) ) { + handlers.splice( j, 1 ); + + if ( handleObj.selector ) { + handlers.delegateCount--; + } + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + } + + // Remove generic event handler if we removed something and no more handlers exist + // (avoids potential for endless recursion during removal of special event handlers) + if ( origCount && !handlers.length ) { + if ( !special.teardown || + special.teardown.call( elem, namespaces, elemData.handle ) === false ) { + + jQuery.removeEvent( elem, type, elemData.handle ); + } + + delete events[ type ]; + } + } + + // Remove data and the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + dataPriv.remove( elem, "handle events" ); + } + }, + + dispatch: function( nativeEvent ) { + + var i, j, ret, matched, handleObj, handlerQueue, + args = new Array( arguments.length ), + + // Make a writable jQuery.Event from the native event object + event = jQuery.event.fix( nativeEvent ), + + handlers = ( + dataPriv.get( this, "events" ) || Object.create( null ) + )[ event.type ] || [], + special = jQuery.event.special[ event.type ] || {}; + + // Use the fix-ed jQuery.Event rather than the (read-only) native event + args[ 0 ] = event; + + for ( i = 1; i < arguments.length; i++ ) { + args[ i ] = arguments[ i ]; + } + + event.delegateTarget = this; + + // Call the preDispatch hook for the mapped type, and let it bail if desired + if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { + return; + } + + // Determine handlers + handlerQueue = jQuery.event.handlers.call( this, event, handlers ); + + // Run delegates first; they may want to stop propagation beneath us + i = 0; + while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) { + event.currentTarget = matched.elem; + + j = 0; + while ( ( handleObj = matched.handlers[ j++ ] ) && + !event.isImmediatePropagationStopped() ) { + + // If the event is namespaced, then each handler is only invoked if it is + // specially universal or its namespaces are a superset of the event's. + if ( !event.rnamespace || handleObj.namespace === false || + event.rnamespace.test( handleObj.namespace ) ) { + + event.handleObj = handleObj; + event.data = handleObj.data; + + ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle || + handleObj.handler ).apply( matched.elem, args ); + + if ( ret !== undefined ) { + if ( ( event.result = ret ) === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + } + } + } + + // Call the postDispatch hook for the mapped type + if ( special.postDispatch ) { + special.postDispatch.call( this, event ); + } + + return event.result; + }, + + handlers: function( event, handlers ) { + var i, handleObj, sel, matchedHandlers, matchedSelectors, + handlerQueue = [], + delegateCount = handlers.delegateCount, + cur = event.target; + + // Find delegate handlers + if ( delegateCount && + + // Support: IE <=9 + // Black-hole SVG instance trees (trac-13180) + cur.nodeType && + + // Support: Firefox <=42 + // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861) + // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click + // Support: IE 11 only + // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343) + !( event.type === "click" && event.button >= 1 ) ) { + + for ( ; cur !== this; cur = cur.parentNode || this ) { + + // Don't check non-elements (#13208) + // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) + if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) { + matchedHandlers = []; + matchedSelectors = {}; + for ( i = 0; i < delegateCount; i++ ) { + handleObj = handlers[ i ]; + + // Don't conflict with Object.prototype properties (#13203) + sel = handleObj.selector + " "; + + if ( matchedSelectors[ sel ] === undefined ) { + matchedSelectors[ sel ] = handleObj.needsContext ? + jQuery( sel, this ).index( cur ) > -1 : + jQuery.find( sel, this, null, [ cur ] ).length; + } + if ( matchedSelectors[ sel ] ) { + matchedHandlers.push( handleObj ); + } + } + if ( matchedHandlers.length ) { + handlerQueue.push( { elem: cur, handlers: matchedHandlers } ); + } + } + } + } + + // Add the remaining (directly-bound) handlers + cur = this; + if ( delegateCount < handlers.length ) { + handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } ); + } + + return handlerQueue; + }, + + addProp: function( name, hook ) { + Object.defineProperty( jQuery.Event.prototype, name, { + enumerable: true, + configurable: true, + + get: isFunction( hook ) ? + function() { + if ( this.originalEvent ) { + return hook( this.originalEvent ); + } + } : + function() { + if ( this.originalEvent ) { + return this.originalEvent[ name ]; + } + }, + + set: function( value ) { + Object.defineProperty( this, name, { + enumerable: true, + configurable: true, + writable: true, + value: value + } ); + } + } ); + }, + + fix: function( originalEvent ) { + return originalEvent[ jQuery.expando ] ? + originalEvent : + new jQuery.Event( originalEvent ); + }, + + special: { + load: { + + // Prevent triggered image.load events from bubbling to window.load + noBubble: true + }, + click: { + + // Utilize native event to ensure correct state for checkable inputs + setup: function( data ) { + + // For mutual compressibility with _default, replace `this` access with a local var. + // `|| data` is dead code meant only to preserve the variable through minification. + var el = this || data; + + // Claim the first handler + if ( rcheckableType.test( el.type ) && + el.click && nodeName( el, "input" ) ) { + + // dataPriv.set( el, "click", ... ) + leverageNative( el, "click", returnTrue ); + } + + // Return false to allow normal processing in the caller + return false; + }, + trigger: function( data ) { + + // For mutual compressibility with _default, replace `this` access with a local var. + // `|| data` is dead code meant only to preserve the variable through minification. + var el = this || data; + + // Force setup before triggering a click + if ( rcheckableType.test( el.type ) && + el.click && nodeName( el, "input" ) ) { + + leverageNative( el, "click" ); + } + + // Return non-false to allow normal event-path propagation + return true; + }, + + // For cross-browser consistency, suppress native .click() on links + // Also prevent it if we're currently inside a leveraged native-event stack + _default: function( event ) { + var target = event.target; + return rcheckableType.test( target.type ) && + target.click && nodeName( target, "input" ) && + dataPriv.get( target, "click" ) || + nodeName( target, "a" ); + } + }, + + beforeunload: { + postDispatch: function( event ) { + + // Support: Firefox 20+ + // Firefox doesn't alert if the returnValue field is not set. + if ( event.result !== undefined && event.originalEvent ) { + event.originalEvent.returnValue = event.result; + } + } + } + } + }; + +// Ensure the presence of an event listener that handles manually-triggered +// synthetic events by interrupting progress until reinvoked in response to +// *native* events that it fires directly, ensuring that state changes have +// already occurred before other listeners are invoked. + function leverageNative( el, type, expectSync ) { + + // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add + if ( !expectSync ) { + if ( dataPriv.get( el, type ) === undefined ) { + jQuery.event.add( el, type, returnTrue ); + } + return; + } + + // Register the controller as a special universal handler for all event namespaces + dataPriv.set( el, type, false ); + jQuery.event.add( el, type, { + namespace: false, + handler: function( event ) { + var notAsync, result, + saved = dataPriv.get( this, type ); + + if ( ( event.isTrigger & 1 ) && this[ type ] ) { + + // Interrupt processing of the outer synthetic .trigger()ed event + // Saved data should be false in such cases, but might be a leftover capture object + // from an async native handler (gh-4350) + if ( !saved.length ) { + + // Store arguments for use when handling the inner native event + // There will always be at least one argument (an event object), so this array + // will not be confused with a leftover capture object. + saved = slice.call( arguments ); + dataPriv.set( this, type, saved ); + + // Trigger the native event and capture its result + // Support: IE <=9 - 11+ + // focus() and blur() are asynchronous + notAsync = expectSync( this, type ); + this[ type ](); + result = dataPriv.get( this, type ); + if ( saved !== result || notAsync ) { + dataPriv.set( this, type, false ); + } else { + result = {}; + } + if ( saved !== result ) { + + // Cancel the outer synthetic event + event.stopImmediatePropagation(); + event.preventDefault(); + return result.value; + } + + // If this is an inner synthetic event for an event with a bubbling surrogate + // (focus or blur), assume that the surrogate already propagated from triggering the + // native event and prevent that from happening again here. + // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the + // bubbling surrogate propagates *after* the non-bubbling base), but that seems + // less bad than duplication. + } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) { + event.stopPropagation(); + } + + // If this is a native event triggered above, everything is now in order + // Fire an inner synthetic event with the original arguments + } else if ( saved.length ) { + + // ...and capture the result + dataPriv.set( this, type, { + value: jQuery.event.trigger( + + // Support: IE <=9 - 11+ + // Extend with the prototype to reset the above stopImmediatePropagation() + jQuery.extend( saved[ 0 ], jQuery.Event.prototype ), + saved.slice( 1 ), + this + ) + } ); + + // Abort handling of the native event + event.stopImmediatePropagation(); + } + } + } ); + } + + jQuery.removeEvent = function( elem, type, handle ) { + + // This "if" is needed for plain objects + if ( elem.removeEventListener ) { + elem.removeEventListener( type, handle ); + } + }; + + jQuery.Event = function( src, props ) { + + // Allow instantiation without the 'new' keyword + if ( !( this instanceof jQuery.Event ) ) { + return new jQuery.Event( src, props ); + } + + // Event object + if ( src && src.type ) { + this.originalEvent = src; + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = src.defaultPrevented || + src.defaultPrevented === undefined && + + // Support: Android <=2.3 only + src.returnValue === false ? + returnTrue : + returnFalse; + + // Create target properties + // Support: Safari <=6 - 7 only + // Target should not be a text node (#504, #13143) + this.target = ( src.target && src.target.nodeType === 3 ) ? + src.target.parentNode : + src.target; + + this.currentTarget = src.currentTarget; + this.relatedTarget = src.relatedTarget; + + // Event type + } else { + this.type = src; + } + + // Put explicitly provided properties onto the event object + if ( props ) { + jQuery.extend( this, props ); + } + + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || Date.now(); + + // Mark it as fixed + this[ jQuery.expando ] = true; + }; + +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding +// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html + jQuery.Event.prototype = { + constructor: jQuery.Event, + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse, + isSimulated: false, + + preventDefault: function() { + var e = this.originalEvent; + + this.isDefaultPrevented = returnTrue; + + if ( e && !this.isSimulated ) { + e.preventDefault(); + } + }, + stopPropagation: function() { + var e = this.originalEvent; + + this.isPropagationStopped = returnTrue; + + if ( e && !this.isSimulated ) { + e.stopPropagation(); + } + }, + stopImmediatePropagation: function() { + var e = this.originalEvent; + + this.isImmediatePropagationStopped = returnTrue; + + if ( e && !this.isSimulated ) { + e.stopImmediatePropagation(); + } + + this.stopPropagation(); + } + }; + +// Includes all common event props including KeyEvent and MouseEvent specific props + jQuery.each( { + altKey: true, + bubbles: true, + cancelable: true, + changedTouches: true, + ctrlKey: true, + detail: true, + eventPhase: true, + metaKey: true, + pageX: true, + pageY: true, + shiftKey: true, + view: true, + "char": true, + code: true, + charCode: true, + key: true, + keyCode: true, + button: true, + buttons: true, + clientX: true, + clientY: true, + offsetX: true, + offsetY: true, + pointerId: true, + pointerType: true, + screenX: true, + screenY: true, + targetTouches: true, + toElement: true, + touches: true, + + which: function( event ) { + var button = event.button; + + // Add which for key events + if ( event.which == null && rkeyEvent.test( event.type ) ) { + return event.charCode != null ? event.charCode : event.keyCode; + } + + // Add which for click: 1 === left; 2 === middle; 3 === right + if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) { + if ( button & 1 ) { + return 1; + } + + if ( button & 2 ) { + return 3; + } + + if ( button & 4 ) { + return 2; + } + + return 0; + } + + return event.which; + } + }, jQuery.event.addProp ); + + jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) { + jQuery.event.special[ type ] = { + + // Utilize native event if possible so blur/focus sequence is correct + setup: function() { + + // Claim the first handler + // dataPriv.set( this, "focus", ... ) + // dataPriv.set( this, "blur", ... ) + leverageNative( this, type, expectSync ); + + // Return false to allow normal processing in the caller + return false; + }, + trigger: function() { + + // Force setup before trigger + leverageNative( this, type ); + + // Return non-false to allow normal event-path propagation + return true; + }, + + delegateType: delegateType + }; + } ); + +// Create mouseenter/leave events using mouseover/out and event-time checks +// so that event delegation works in jQuery. +// Do the same for pointerenter/pointerleave and pointerover/pointerout +// +// Support: Safari 7 only +// Safari sends mouseenter too often; see: +// https://bugs.chromium.org/p/chromium/issues/detail?id=470258 +// for the description of the bug (it existed in older Chrome versions as well). + jQuery.each( { + mouseenter: "mouseover", + mouseleave: "mouseout", + pointerenter: "pointerover", + pointerleave: "pointerout" + }, function( orig, fix ) { + jQuery.event.special[ orig ] = { + delegateType: fix, + bindType: fix, + + handle: function( event ) { + var ret, + target = this, + related = event.relatedTarget, + handleObj = event.handleObj; + + // For mouseenter/leave call the handler if related is outside the target. + // NB: No relatedTarget if the mouse left/entered the browser window + if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) { + event.type = handleObj.origType; + ret = handleObj.handler.apply( this, arguments ); + event.type = fix; + } + return ret; + } + }; + } ); + + jQuery.fn.extend( { + + on: function( types, selector, data, fn ) { + return on( this, types, selector, data, fn ); + }, + one: function( types, selector, data, fn ) { + return on( this, types, selector, data, fn, 1 ); + }, + off: function( types, selector, fn ) { + var handleObj, type; + if ( types && types.preventDefault && types.handleObj ) { + + // ( event ) dispatched jQuery.Event + handleObj = types.handleObj; + jQuery( types.delegateTarget ).off( + handleObj.namespace ? + handleObj.origType + "." + handleObj.namespace : + handleObj.origType, + handleObj.selector, + handleObj.handler + ); + return this; + } + if ( typeof types === "object" ) { + + // ( types-object [, selector] ) + for ( type in types ) { + this.off( type, selector, types[ type ] ); + } + return this; + } + if ( selector === false || typeof selector === "function" ) { + + // ( types [, fn] ) + fn = selector; + selector = undefined; + } + if ( fn === false ) { + fn = returnFalse; + } + return this.each( function() { + jQuery.event.remove( this, types, fn, selector ); + } ); + } + } ); + + + var + + // Support: IE <=10 - 11, Edge 12 - 13 only + // In IE/Edge using regex groups here causes severe slowdowns. + // See https://connect.microsoft.com/IE/feedback/details/1736512/ + rnoInnerhtml = /\s*$/g; + +// Prefer a tbody over its parent table for containing new rows + function manipulationTarget( elem, content ) { + if ( nodeName( elem, "table" ) && + nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) { + + return jQuery( elem ).children( "tbody" )[ 0 ] || elem; + } + + return elem; + } + +// Replace/restore the type attribute of script elements for safe DOM manipulation + function disableScript( elem ) { + elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type; + return elem; + } + function restoreScript( elem ) { + if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) { + elem.type = elem.type.slice( 5 ); + } else { + elem.removeAttribute( "type" ); + } + + return elem; + } + + function cloneCopyEvent( src, dest ) { + var i, l, type, pdataOld, udataOld, udataCur, events; + + if ( dest.nodeType !== 1 ) { + return; + } + + // 1. Copy private data: events, handlers, etc. + if ( dataPriv.hasData( src ) ) { + pdataOld = dataPriv.get( src ); + events = pdataOld.events; + + if ( events ) { + dataPriv.remove( dest, "handle events" ); + + for ( type in events ) { + for ( i = 0, l = events[ type ].length; i < l; i++ ) { + jQuery.event.add( dest, type, events[ type ][ i ] ); + } + } + } + } + + // 2. Copy user data + if ( dataUser.hasData( src ) ) { + udataOld = dataUser.access( src ); + udataCur = jQuery.extend( {}, udataOld ); + + dataUser.set( dest, udataCur ); + } + } + +// Fix IE bugs, see support tests + function fixInput( src, dest ) { + var nodeName = dest.nodeName.toLowerCase(); + + // Fails to persist the checked state of a cloned checkbox or radio button. + if ( nodeName === "input" && rcheckableType.test( src.type ) ) { + dest.checked = src.checked; + + // Fails to return the selected option to the default selected state when cloning options + } else if ( nodeName === "input" || nodeName === "textarea" ) { + dest.defaultValue = src.defaultValue; + } + } + + function domManip( collection, args, callback, ignored ) { + + // Flatten any nested arrays + args = flat( args ); + + var fragment, first, scripts, hasScripts, node, doc, + i = 0, + l = collection.length, + iNoClone = l - 1, + value = args[ 0 ], + valueIsFunction = isFunction( value ); + + // We can't cloneNode fragments that contain checked, in WebKit + if ( valueIsFunction || + ( l > 1 && typeof value === "string" && + !support.checkClone && rchecked.test( value ) ) ) { + return collection.each( function( index ) { + var self = collection.eq( index ); + if ( valueIsFunction ) { + args[ 0 ] = value.call( this, index, self.html() ); + } + domManip( self, args, callback, ignored ); + } ); + } + + if ( l ) { + fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored ); + first = fragment.firstChild; + + if ( fragment.childNodes.length === 1 ) { + fragment = first; + } + + // Require either new content or an interest in ignored elements to invoke the callback + if ( first || ignored ) { + scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); + hasScripts = scripts.length; + + // Use the original fragment for the last item + // instead of the first because it can end up + // being emptied incorrectly in certain situations (#8070). + for ( ; i < l; i++ ) { + node = fragment; + + if ( i !== iNoClone ) { + node = jQuery.clone( node, true, true ); + + // Keep references to cloned scripts for later restoration + if ( hasScripts ) { + + // Support: Android <=4.0 only, PhantomJS 1 only + // push.apply(_, arraylike) throws on ancient WebKit + jQuery.merge( scripts, getAll( node, "script" ) ); + } + } + + callback.call( collection[ i ], node, i ); + } + + if ( hasScripts ) { + doc = scripts[ scripts.length - 1 ].ownerDocument; + + // Reenable scripts + jQuery.map( scripts, restoreScript ); + + // Evaluate executable scripts on first document insertion + for ( i = 0; i < hasScripts; i++ ) { + node = scripts[ i ]; + if ( rscriptType.test( node.type || "" ) && + !dataPriv.access( node, "globalEval" ) && + jQuery.contains( doc, node ) ) { + + if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) { + + // Optional AJAX dependency, but won't run scripts if not present + if ( jQuery._evalUrl && !node.noModule ) { + jQuery._evalUrl( node.src, { + nonce: node.nonce || node.getAttribute( "nonce" ) + }, doc ); + } + } else { + DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc ); + } + } + } + } + } + } + + return collection; + } + + function remove( elem, selector, keepData ) { + var node, + nodes = selector ? jQuery.filter( selector, elem ) : elem, + i = 0; + + for ( ; ( node = nodes[ i ] ) != null; i++ ) { + if ( !keepData && node.nodeType === 1 ) { + jQuery.cleanData( getAll( node ) ); + } + + if ( node.parentNode ) { + if ( keepData && isAttached( node ) ) { + setGlobalEval( getAll( node, "script" ) ); + } + node.parentNode.removeChild( node ); + } + } + + return elem; + } + + jQuery.extend( { + htmlPrefilter: function( html ) { + return html; + }, + + clone: function( elem, dataAndEvents, deepDataAndEvents ) { + var i, l, srcElements, destElements, + clone = elem.cloneNode( true ), + inPage = isAttached( elem ); + + // Fix IE cloning issues + if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && + !jQuery.isXMLDoc( elem ) ) { + + // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2 + destElements = getAll( clone ); + srcElements = getAll( elem ); + + for ( i = 0, l = srcElements.length; i < l; i++ ) { + fixInput( srcElements[ i ], destElements[ i ] ); + } + } + + // Copy the events from the original to the clone + if ( dataAndEvents ) { + if ( deepDataAndEvents ) { + srcElements = srcElements || getAll( elem ); + destElements = destElements || getAll( clone ); + + for ( i = 0, l = srcElements.length; i < l; i++ ) { + cloneCopyEvent( srcElements[ i ], destElements[ i ] ); + } + } else { + cloneCopyEvent( elem, clone ); + } + } + + // Preserve script evaluation history + destElements = getAll( clone, "script" ); + if ( destElements.length > 0 ) { + setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); + } + + // Return the cloned set + return clone; + }, + + cleanData: function( elems ) { + var data, elem, type, + special = jQuery.event.special, + i = 0; + + for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) { + if ( acceptData( elem ) ) { + if ( ( data = elem[ dataPriv.expando ] ) ) { + if ( data.events ) { + for ( type in data.events ) { + if ( special[ type ] ) { + jQuery.event.remove( elem, type ); + + // This is a shortcut to avoid jQuery.event.remove's overhead + } else { + jQuery.removeEvent( elem, type, data.handle ); + } + } + } + + // Support: Chrome <=35 - 45+ + // Assign undefined instead of using delete, see Data#remove + elem[ dataPriv.expando ] = undefined; + } + if ( elem[ dataUser.expando ] ) { + + // Support: Chrome <=35 - 45+ + // Assign undefined instead of using delete, see Data#remove + elem[ dataUser.expando ] = undefined; + } + } + } + } + } ); + + jQuery.fn.extend( { + detach: function( selector ) { + return remove( this, selector, true ); + }, + + remove: function( selector ) { + return remove( this, selector ); + }, + + text: function( value ) { + return access( this, function( value ) { + return value === undefined ? + jQuery.text( this ) : + this.empty().each( function() { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + this.textContent = value; + } + } ); + }, null, value, arguments.length ); + }, + + append: function() { + return domManip( this, arguments, function( elem ) { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + var target = manipulationTarget( this, elem ); + target.appendChild( elem ); + } + } ); + }, + + prepend: function() { + return domManip( this, arguments, function( elem ) { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + var target = manipulationTarget( this, elem ); + target.insertBefore( elem, target.firstChild ); + } + } ); + }, + + before: function() { + return domManip( this, arguments, function( elem ) { + if ( this.parentNode ) { + this.parentNode.insertBefore( elem, this ); + } + } ); + }, + + after: function() { + return domManip( this, arguments, function( elem ) { + if ( this.parentNode ) { + this.parentNode.insertBefore( elem, this.nextSibling ); + } + } ); + }, + + empty: function() { + var elem, + i = 0; + + for ( ; ( elem = this[ i ] ) != null; i++ ) { + if ( elem.nodeType === 1 ) { + + // Prevent memory leaks + jQuery.cleanData( getAll( elem, false ) ); + + // Remove any remaining nodes + elem.textContent = ""; + } + } + + return this; + }, + + clone: function( dataAndEvents, deepDataAndEvents ) { + dataAndEvents = dataAndEvents == null ? false : dataAndEvents; + deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; + + return this.map( function() { + return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); + } ); + }, + + html: function( value ) { + return access( this, function( value ) { + var elem = this[ 0 ] || {}, + i = 0, + l = this.length; + + if ( value === undefined && elem.nodeType === 1 ) { + return elem.innerHTML; + } + + // See if we can take a shortcut and just use innerHTML + if ( typeof value === "string" && !rnoInnerhtml.test( value ) && + !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { + + value = jQuery.htmlPrefilter( value ); + + try { + for ( ; i < l; i++ ) { + elem = this[ i ] || {}; + + // Remove element nodes and prevent memory leaks + if ( elem.nodeType === 1 ) { + jQuery.cleanData( getAll( elem, false ) ); + elem.innerHTML = value; + } + } + + elem = 0; + + // If using innerHTML throws an exception, use the fallback method + } catch ( e ) {} + } + + if ( elem ) { + this.empty().append( value ); + } + }, null, value, arguments.length ); + }, + + replaceWith: function() { + var ignored = []; + + // Make the changes, replacing each non-ignored context element with the new content + return domManip( this, arguments, function( elem ) { + var parent = this.parentNode; + + if ( jQuery.inArray( this, ignored ) < 0 ) { + jQuery.cleanData( getAll( this ) ); + if ( parent ) { + parent.replaceChild( elem, this ); + } + } + + // Force callback invocation + }, ignored ); + } + } ); + + jQuery.each( { + appendTo: "append", + prependTo: "prepend", + insertBefore: "before", + insertAfter: "after", + replaceAll: "replaceWith" + }, function( name, original ) { + jQuery.fn[ name ] = function( selector ) { + var elems, + ret = [], + insert = jQuery( selector ), + last = insert.length - 1, + i = 0; + + for ( ; i <= last; i++ ) { + elems = i === last ? this : this.clone( true ); + jQuery( insert[ i ] )[ original ]( elems ); + + // Support: Android <=4.0 only, PhantomJS 1 only + // .get() because push.apply(_, arraylike) throws on ancient WebKit + push.apply( ret, elems.get() ); + } + + return this.pushStack( ret ); + }; + } ); + var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); + + var getStyles = function( elem ) { + + // Support: IE <=11 only, Firefox <=30 (#15098, #14150) + // IE throws on elements created in popups + // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" + var view = elem.ownerDocument.defaultView; + + if ( !view || !view.opener ) { + view = window; + } + + return view.getComputedStyle( elem ); + }; + + var swap = function( elem, options, callback ) { + var ret, name, + old = {}; + + // Remember the old values, and insert the new ones + for ( name in options ) { + old[ name ] = elem.style[ name ]; + elem.style[ name ] = options[ name ]; + } + + ret = callback.call( elem ); + + // Revert the old values + for ( name in options ) { + elem.style[ name ] = old[ name ]; + } + + return ret; + }; + + + var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); + + + + ( function() { + + // Executing both pixelPosition & boxSizingReliable tests require only one layout + // so they're executed at the same time to save the second computation. + function computeStyleTests() { + + // This is a singleton, we need to execute it only once + if ( !div ) { + return; + } + + container.style.cssText = "position:absolute;left:-11111px;width:60px;" + + "margin-top:1px;padding:0;border:0"; + div.style.cssText = + "position:relative;display:block;box-sizing:border-box;overflow:scroll;" + + "margin:auto;border:1px;padding:1px;" + + "width:60%;top:1%"; + documentElement.appendChild( container ).appendChild( div ); + + var divStyle = window.getComputedStyle( div ); + pixelPositionVal = divStyle.top !== "1%"; + + // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44 + reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12; + + // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3 + // Some styles come back with percentage values, even though they shouldn't + div.style.right = "60%"; + pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36; + + // Support: IE 9 - 11 only + // Detect misreporting of content dimensions for box-sizing:border-box elements + boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36; + + // Support: IE 9 only + // Detect overflow:scroll screwiness (gh-3699) + // Support: Chrome <=64 + // Don't get tricked when zoom affects offsetWidth (gh-4029) + div.style.position = "absolute"; + scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12; + + documentElement.removeChild( container ); + + // Nullify the div so it wouldn't be stored in the memory and + // it will also be a sign that checks already performed + div = null; + } + + function roundPixelMeasures( measure ) { + return Math.round( parseFloat( measure ) ); + } + + var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal, + reliableTrDimensionsVal, reliableMarginLeftVal, + container = document.createElement( "div" ), + div = document.createElement( "div" ); + + // Finish early in limited (non-browser) environments + if ( !div.style ) { + return; + } + + // Support: IE <=9 - 11 only + // Style of cloned element affects source element cloned (#8908) + div.style.backgroundClip = "content-box"; + div.cloneNode( true ).style.backgroundClip = ""; + support.clearCloneStyle = div.style.backgroundClip === "content-box"; + + jQuery.extend( support, { + boxSizingReliable: function() { + computeStyleTests(); + return boxSizingReliableVal; + }, + pixelBoxStyles: function() { + computeStyleTests(); + return pixelBoxStylesVal; + }, + pixelPosition: function() { + computeStyleTests(); + return pixelPositionVal; + }, + reliableMarginLeft: function() { + computeStyleTests(); + return reliableMarginLeftVal; + }, + scrollboxSize: function() { + computeStyleTests(); + return scrollboxSizeVal; + }, + + // Support: IE 9 - 11+, Edge 15 - 18+ + // IE/Edge misreport `getComputedStyle` of table rows with width/height + // set in CSS while `offset*` properties report correct values. + // Behavior in IE 9 is more subtle than in newer versions & it passes + // some versions of this test; make sure not to make it pass there! + reliableTrDimensions: function() { + var table, tr, trChild, trStyle; + if ( reliableTrDimensionsVal == null ) { + table = document.createElement( "table" ); + tr = document.createElement( "tr" ); + trChild = document.createElement( "div" ); + + table.style.cssText = "position:absolute;left:-11111px"; + tr.style.height = "1px"; + trChild.style.height = "9px"; + + documentElement + .appendChild( table ) + .appendChild( tr ) + .appendChild( trChild ); + + trStyle = window.getComputedStyle( tr ); + reliableTrDimensionsVal = parseInt( trStyle.height ) > 3; + + documentElement.removeChild( table ); + } + return reliableTrDimensionsVal; + } + } ); + } )(); + + + function curCSS( elem, name, computed ) { + var width, minWidth, maxWidth, ret, + + // Support: Firefox 51+ + // Retrieving style before computed somehow + // fixes an issue with getting wrong values + // on detached elements + style = elem.style; + + computed = computed || getStyles( elem ); + + // getPropertyValue is needed for: + // .css('filter') (IE 9 only, #12537) + // .css('--customProperty) (#3144) + if ( computed ) { + ret = computed.getPropertyValue( name ) || computed[ name ]; + + if ( ret === "" && !isAttached( elem ) ) { + ret = jQuery.style( elem, name ); + } + + // A tribute to the "awesome hack by Dean Edwards" + // Android Browser returns percentage for some values, + // but width seems to be reliably pixels. + // This is against the CSSOM draft spec: + // https://drafts.csswg.org/cssom/#resolved-values + if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) { + + // Remember the original values + width = style.width; + minWidth = style.minWidth; + maxWidth = style.maxWidth; + + // Put in the new values to get a computed value out + style.minWidth = style.maxWidth = style.width = ret; + ret = computed.width; + + // Revert the changed values + style.width = width; + style.minWidth = minWidth; + style.maxWidth = maxWidth; + } + } + + return ret !== undefined ? + + // Support: IE <=9 - 11 only + // IE returns zIndex value as an integer. + ret + "" : + ret; + } + + + function addGetHookIf( conditionFn, hookFn ) { + + // Define the hook, we'll check on the first run if it's really needed. + return { + get: function() { + if ( conditionFn() ) { + + // Hook not needed (or it's not possible to use it due + // to missing dependency), remove it. + delete this.get; + return; + } + + // Hook needed; redefine it so that the support test is not executed again. + return ( this.get = hookFn ).apply( this, arguments ); + } + }; + } + + + var cssPrefixes = [ "Webkit", "Moz", "ms" ], + emptyStyle = document.createElement( "div" ).style, + vendorProps = {}; + +// Return a vendor-prefixed property or undefined + function vendorPropName( name ) { + + // Check for vendor prefixed names + var capName = name[ 0 ].toUpperCase() + name.slice( 1 ), + i = cssPrefixes.length; + + while ( i-- ) { + name = cssPrefixes[ i ] + capName; + if ( name in emptyStyle ) { + return name; + } + } + } + +// Return a potentially-mapped jQuery.cssProps or vendor prefixed property + function finalPropName( name ) { + var final = jQuery.cssProps[ name ] || vendorProps[ name ]; + + if ( final ) { + return final; + } + if ( name in emptyStyle ) { + return name; + } + return vendorProps[ name ] = vendorPropName( name ) || name; + } + + + var + + // Swappable if display is none or starts with table + // except "table", "table-cell", or "table-caption" + // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display + rdisplayswap = /^(none|table(?!-c[ea]).+)/, + rcustomProp = /^--/, + cssShow = { position: "absolute", visibility: "hidden", display: "block" }, + cssNormalTransform = { + letterSpacing: "0", + fontWeight: "400" + }; + + function setPositiveNumber( _elem, value, subtract ) { + + // Any relative (+/-) values have already been + // normalized at this point + var matches = rcssNum.exec( value ); + return matches ? + + // Guard against undefined "subtract", e.g., when used as in cssHooks + Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) : + value; + } + + function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) { + var i = dimension === "width" ? 1 : 0, + extra = 0, + delta = 0; + + // Adjustment may not be necessary + if ( box === ( isBorderBox ? "border" : "content" ) ) { + return 0; + } + + for ( ; i < 4; i += 2 ) { + + // Both box models exclude margin + if ( box === "margin" ) { + delta += jQuery.css( elem, box + cssExpand[ i ], true, styles ); + } + + // If we get here with a content-box, we're seeking "padding" or "border" or "margin" + if ( !isBorderBox ) { + + // Add padding + delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); + + // For "border" or "margin", add border + if ( box !== "padding" ) { + delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); + + // But still keep track of it otherwise + } else { + extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); + } + + // If we get here with a border-box (content + padding + border), we're seeking "content" or + // "padding" or "margin" + } else { + + // For "content", subtract padding + if ( box === "content" ) { + delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); + } + + // For "content" or "padding", subtract border + if ( box !== "margin" ) { + delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); + } + } + } + + // Account for positive content-box scroll gutter when requested by providing computedVal + if ( !isBorderBox && computedVal >= 0 ) { + + // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border + // Assuming integer scroll gutter, subtract the rest and round down + delta += Math.max( 0, Math.ceil( + elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - + computedVal - + delta - + extra - + 0.5 + + // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter + // Use an explicit zero to avoid NaN (gh-3964) + ) ) || 0; + } + + return delta; + } + + function getWidthOrHeight( elem, dimension, extra ) { + + // Start with computed style + var styles = getStyles( elem ), + + // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322). + // Fake content-box until we know it's needed to know the true value. + boxSizingNeeded = !support.boxSizingReliable() || extra, + isBorderBox = boxSizingNeeded && + jQuery.css( elem, "boxSizing", false, styles ) === "border-box", + valueIsBorderBox = isBorderBox, + + val = curCSS( elem, dimension, styles ), + offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ); + + // Support: Firefox <=54 + // Return a confounding non-pixel value or feign ignorance, as appropriate. + if ( rnumnonpx.test( val ) ) { + if ( !extra ) { + return val; + } + val = "auto"; + } + + + // Support: IE 9 - 11 only + // Use offsetWidth/offsetHeight for when box sizing is unreliable. + // In those cases, the computed value can be trusted to be border-box. + if ( ( !support.boxSizingReliable() && isBorderBox || + + // Support: IE 10 - 11+, Edge 15 - 18+ + // IE/Edge misreport `getComputedStyle` of table rows with width/height + // set in CSS while `offset*` properties report correct values. + // Interestingly, in some cases IE 9 doesn't suffer from this issue. + !support.reliableTrDimensions() && nodeName( elem, "tr" ) || + + // Fall back to offsetWidth/offsetHeight when value is "auto" + // This happens for inline elements with no explicit setting (gh-3571) + val === "auto" || + + // Support: Android <=4.1 - 4.3 only + // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602) + !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) && + + // Make sure the element is visible & connected + elem.getClientRects().length ) { + + isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; + + // Where available, offsetWidth/offsetHeight approximate border box dimensions. + // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the + // retrieved value as a content box dimension. + valueIsBorderBox = offsetProp in elem; + if ( valueIsBorderBox ) { + val = elem[ offsetProp ]; + } + } + + // Normalize "" and auto + val = parseFloat( val ) || 0; + + // Adjust for the element's box model + return ( val + + boxModelAdjustment( + elem, + dimension, + extra || ( isBorderBox ? "border" : "content" ), + valueIsBorderBox, + styles, + + // Provide the current computed size to request scroll gutter calculation (gh-3589) + val + ) + ) + "px"; + } + + jQuery.extend( { + + // Add in style property hooks for overriding the default + // behavior of getting and setting a style property + cssHooks: { + opacity: { + get: function( elem, computed ) { + if ( computed ) { + + // We should always get a number back from opacity + var ret = curCSS( elem, "opacity" ); + return ret === "" ? "1" : ret; + } + } + } + }, + + // Don't automatically add "px" to these possibly-unitless properties + cssNumber: { + "animationIterationCount": true, + "columnCount": true, + "fillOpacity": true, + "flexGrow": true, + "flexShrink": true, + "fontWeight": true, + "gridArea": true, + "gridColumn": true, + "gridColumnEnd": true, + "gridColumnStart": true, + "gridRow": true, + "gridRowEnd": true, + "gridRowStart": true, + "lineHeight": true, + "opacity": true, + "order": true, + "orphans": true, + "widows": true, + "zIndex": true, + "zoom": true + }, + + // Add in properties whose names you wish to fix before + // setting or getting the value + cssProps: {}, + + // Get and set the style property on a DOM Node + style: function( elem, name, value, extra ) { + + // Don't set styles on text and comment nodes + if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { + return; + } + + // Make sure that we're working with the right name + var ret, type, hooks, + origName = camelCase( name ), + isCustomProp = rcustomProp.test( name ), + style = elem.style; + + // Make sure that we're working with the right name. We don't + // want to query the value if it is a CSS custom property + // since they are user-defined. + if ( !isCustomProp ) { + name = finalPropName( origName ); + } + + // Gets hook for the prefixed version, then unprefixed version + hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; + + // Check if we're setting a value + if ( value !== undefined ) { + type = typeof value; + + // Convert "+=" or "-=" to relative numbers (#7345) + if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) { + value = adjustCSS( elem, name, ret ); + + // Fixes bug #9237 + type = "number"; + } + + // Make sure that null and NaN values aren't set (#7116) + if ( value == null || value !== value ) { + return; + } + + // If a number was passed in, add the unit (except for certain CSS properties) + // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append + // "px" to a few hardcoded values. + if ( type === "number" && !isCustomProp ) { + value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); + } + + // background-* props affect original clone's values + if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { + style[ name ] = "inherit"; + } + + // If a hook was provided, use that value, otherwise just set the specified value + if ( !hooks || !( "set" in hooks ) || + ( value = hooks.set( elem, value, extra ) ) !== undefined ) { + + if ( isCustomProp ) { + style.setProperty( name, value ); + } else { + style[ name ] = value; + } + } + + } else { + + // If a hook was provided get the non-computed value from there + if ( hooks && "get" in hooks && + ( ret = hooks.get( elem, false, extra ) ) !== undefined ) { + + return ret; + } + + // Otherwise just get the value from the style object + return style[ name ]; + } + }, + + css: function( elem, name, extra, styles ) { + var val, num, hooks, + origName = camelCase( name ), + isCustomProp = rcustomProp.test( name ); + + // Make sure that we're working with the right name. We don't + // want to modify the value if it is a CSS custom property + // since they are user-defined. + if ( !isCustomProp ) { + name = finalPropName( origName ); + } + + // Try prefixed name followed by the unprefixed name + hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; + + // If a hook was provided get the computed value from there + if ( hooks && "get" in hooks ) { + val = hooks.get( elem, true, extra ); + } + + // Otherwise, if a way to get the computed value exists, use that + if ( val === undefined ) { + val = curCSS( elem, name, styles ); + } + + // Convert "normal" to computed value + if ( val === "normal" && name in cssNormalTransform ) { + val = cssNormalTransform[ name ]; + } + + // Make numeric if forced or a qualifier was provided and val looks numeric + if ( extra === "" || extra ) { + num = parseFloat( val ); + return extra === true || isFinite( num ) ? num || 0 : val; + } + + return val; + } + } ); + + jQuery.each( [ "height", "width" ], function( _i, dimension ) { + jQuery.cssHooks[ dimension ] = { + get: function( elem, computed, extra ) { + if ( computed ) { + + // Certain elements can have dimension info if we invisibly show them + // but it must have a current display style that would benefit + return rdisplayswap.test( jQuery.css( elem, "display" ) ) && + + // Support: Safari 8+ + // Table columns in Safari have non-zero offsetWidth & zero + // getBoundingClientRect().width unless display is changed. + // Support: IE <=11 only + // Running getBoundingClientRect on a disconnected node + // in IE throws an error. + ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ? + swap( elem, cssShow, function() { + return getWidthOrHeight( elem, dimension, extra ); + } ) : + getWidthOrHeight( elem, dimension, extra ); + } + }, + + set: function( elem, value, extra ) { + var matches, + styles = getStyles( elem ), + + // Only read styles.position if the test has a chance to fail + // to avoid forcing a reflow. + scrollboxSizeBuggy = !support.scrollboxSize() && + styles.position === "absolute", + + // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991) + boxSizingNeeded = scrollboxSizeBuggy || extra, + isBorderBox = boxSizingNeeded && + jQuery.css( elem, "boxSizing", false, styles ) === "border-box", + subtract = extra ? + boxModelAdjustment( + elem, + dimension, + extra, + isBorderBox, + styles + ) : + 0; + + // Account for unreliable border-box dimensions by comparing offset* to computed and + // faking a content-box to get border and padding (gh-3699) + if ( isBorderBox && scrollboxSizeBuggy ) { + subtract -= Math.ceil( + elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - + parseFloat( styles[ dimension ] ) - + boxModelAdjustment( elem, dimension, "border", false, styles ) - + 0.5 + ); + } + + // Convert to pixels if value adjustment is needed + if ( subtract && ( matches = rcssNum.exec( value ) ) && + ( matches[ 3 ] || "px" ) !== "px" ) { + + elem.style[ dimension ] = value; + value = jQuery.css( elem, dimension ); + } + + return setPositiveNumber( elem, value, subtract ); + } + }; + } ); + + jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft, + function( elem, computed ) { + if ( computed ) { + return ( parseFloat( curCSS( elem, "marginLeft" ) ) || + elem.getBoundingClientRect().left - + swap( elem, { marginLeft: 0 }, function() { + return elem.getBoundingClientRect().left; + } ) + ) + "px"; + } + } + ); + +// These hooks are used by animate to expand properties + jQuery.each( { + margin: "", + padding: "", + border: "Width" + }, function( prefix, suffix ) { + jQuery.cssHooks[ prefix + suffix ] = { + expand: function( value ) { + var i = 0, + expanded = {}, + + // Assumes a single number if not a string + parts = typeof value === "string" ? value.split( " " ) : [ value ]; + + for ( ; i < 4; i++ ) { + expanded[ prefix + cssExpand[ i ] + suffix ] = + parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; + } + + return expanded; + } + }; + + if ( prefix !== "margin" ) { + jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; + } + } ); + + jQuery.fn.extend( { + css: function( name, value ) { + return access( this, function( elem, name, value ) { + var styles, len, + map = {}, + i = 0; + + if ( Array.isArray( name ) ) { + styles = getStyles( elem ); + len = name.length; + + for ( ; i < len; i++ ) { + map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); + } + + return map; + } + + return value !== undefined ? + jQuery.style( elem, name, value ) : + jQuery.css( elem, name ); + }, name, value, arguments.length > 1 ); + } + } ); + + + function Tween( elem, options, prop, end, easing ) { + return new Tween.prototype.init( elem, options, prop, end, easing ); + } + jQuery.Tween = Tween; + + Tween.prototype = { + constructor: Tween, + init: function( elem, options, prop, end, easing, unit ) { + this.elem = elem; + this.prop = prop; + this.easing = easing || jQuery.easing._default; + this.options = options; + this.start = this.now = this.cur(); + this.end = end; + this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); + }, + cur: function() { + var hooks = Tween.propHooks[ this.prop ]; + + return hooks && hooks.get ? + hooks.get( this ) : + Tween.propHooks._default.get( this ); + }, + run: function( percent ) { + var eased, + hooks = Tween.propHooks[ this.prop ]; + + if ( this.options.duration ) { + this.pos = eased = jQuery.easing[ this.easing ]( + percent, this.options.duration * percent, 0, 1, this.options.duration + ); + } else { + this.pos = eased = percent; + } + this.now = ( this.end - this.start ) * eased + this.start; + + if ( this.options.step ) { + this.options.step.call( this.elem, this.now, this ); + } + + if ( hooks && hooks.set ) { + hooks.set( this ); + } else { + Tween.propHooks._default.set( this ); + } + return this; + } + }; + + Tween.prototype.init.prototype = Tween.prototype; + + Tween.propHooks = { + _default: { + get: function( tween ) { + var result; + + // Use a property on the element directly when it is not a DOM element, + // or when there is no matching style property that exists. + if ( tween.elem.nodeType !== 1 || + tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) { + return tween.elem[ tween.prop ]; + } + + // Passing an empty string as a 3rd parameter to .css will automatically + // attempt a parseFloat and fallback to a string if the parse fails. + // Simple values such as "10px" are parsed to Float; + // complex values such as "rotate(1rad)" are returned as-is. + result = jQuery.css( tween.elem, tween.prop, "" ); + + // Empty strings, null, undefined and "auto" are converted to 0. + return !result || result === "auto" ? 0 : result; + }, + set: function( tween ) { + + // Use step hook for back compat. + // Use cssHook if its there. + // Use .style if available and use plain properties where available. + if ( jQuery.fx.step[ tween.prop ] ) { + jQuery.fx.step[ tween.prop ]( tween ); + } else if ( tween.elem.nodeType === 1 && ( + jQuery.cssHooks[ tween.prop ] || + tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) { + jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); + } else { + tween.elem[ tween.prop ] = tween.now; + } + } + } + }; + +// Support: IE <=9 only +// Panic based approach to setting things on disconnected nodes + Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { + set: function( tween ) { + if ( tween.elem.nodeType && tween.elem.parentNode ) { + tween.elem[ tween.prop ] = tween.now; + } + } + }; + + jQuery.easing = { + linear: function( p ) { + return p; + }, + swing: function( p ) { + return 0.5 - Math.cos( p * Math.PI ) / 2; + }, + _default: "swing" + }; + + jQuery.fx = Tween.prototype.init; + +// Back compat <1.8 extension point + jQuery.fx.step = {}; + + + + + var + fxNow, inProgress, + rfxtypes = /^(?:toggle|show|hide)$/, + rrun = /queueHooks$/; + + function schedule() { + if ( inProgress ) { + if ( document.hidden === false && window.requestAnimationFrame ) { + window.requestAnimationFrame( schedule ); + } else { + window.setTimeout( schedule, jQuery.fx.interval ); + } + + jQuery.fx.tick(); + } + } + +// Animations created synchronously will run synchronously + function createFxNow() { + window.setTimeout( function() { + fxNow = undefined; + } ); + return ( fxNow = Date.now() ); + } + +// Generate parameters to create a standard animation + function genFx( type, includeWidth ) { + var which, + i = 0, + attrs = { height: type }; + + // If we include width, step value is 1 to do all cssExpand values, + // otherwise step value is 2 to skip over Left and Right + includeWidth = includeWidth ? 1 : 0; + for ( ; i < 4; i += 2 - includeWidth ) { + which = cssExpand[ i ]; + attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; + } + + if ( includeWidth ) { + attrs.opacity = attrs.width = type; + } + + return attrs; + } + + function createTween( value, prop, animation ) { + var tween, + collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ), + index = 0, + length = collection.length; + for ( ; index < length; index++ ) { + if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) { + + // We're done with this property + return tween; + } + } + } + + function defaultPrefilter( elem, props, opts ) { + var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display, + isBox = "width" in props || "height" in props, + anim = this, + orig = {}, + style = elem.style, + hidden = elem.nodeType && isHiddenWithinTree( elem ), + dataShow = dataPriv.get( elem, "fxshow" ); + + // Queue-skipping animations hijack the fx hooks + if ( !opts.queue ) { + hooks = jQuery._queueHooks( elem, "fx" ); + if ( hooks.unqueued == null ) { + hooks.unqueued = 0; + oldfire = hooks.empty.fire; + hooks.empty.fire = function() { + if ( !hooks.unqueued ) { + oldfire(); + } + }; + } + hooks.unqueued++; + + anim.always( function() { + + // Ensure the complete handler is called before this completes + anim.always( function() { + hooks.unqueued--; + if ( !jQuery.queue( elem, "fx" ).length ) { + hooks.empty.fire(); + } + } ); + } ); + } + + // Detect show/hide animations + for ( prop in props ) { + value = props[ prop ]; + if ( rfxtypes.test( value ) ) { + delete props[ prop ]; + toggle = toggle || value === "toggle"; + if ( value === ( hidden ? "hide" : "show" ) ) { + + // Pretend to be hidden if this is a "show" and + // there is still data from a stopped show/hide + if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { + hidden = true; + + // Ignore all other no-op show/hide data + } else { + continue; + } + } + orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); + } + } + + // Bail out if this is a no-op like .hide().hide() + propTween = !jQuery.isEmptyObject( props ); + if ( !propTween && jQuery.isEmptyObject( orig ) ) { + return; + } + + // Restrict "overflow" and "display" styles during box animations + if ( isBox && elem.nodeType === 1 ) { + + // Support: IE <=9 - 11, Edge 12 - 15 + // Record all 3 overflow attributes because IE does not infer the shorthand + // from identically-valued overflowX and overflowY and Edge just mirrors + // the overflowX value there. + opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; + + // Identify a display type, preferring old show/hide data over the CSS cascade + restoreDisplay = dataShow && dataShow.display; + if ( restoreDisplay == null ) { + restoreDisplay = dataPriv.get( elem, "display" ); + } + display = jQuery.css( elem, "display" ); + if ( display === "none" ) { + if ( restoreDisplay ) { + display = restoreDisplay; + } else { + + // Get nonempty value(s) by temporarily forcing visibility + showHide( [ elem ], true ); + restoreDisplay = elem.style.display || restoreDisplay; + display = jQuery.css( elem, "display" ); + showHide( [ elem ] ); + } + } + + // Animate inline elements as inline-block + if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) { + if ( jQuery.css( elem, "float" ) === "none" ) { + + // Restore the original display value at the end of pure show/hide animations + if ( !propTween ) { + anim.done( function() { + style.display = restoreDisplay; + } ); + if ( restoreDisplay == null ) { + display = style.display; + restoreDisplay = display === "none" ? "" : display; + } + } + style.display = "inline-block"; + } + } + } + + if ( opts.overflow ) { + style.overflow = "hidden"; + anim.always( function() { + style.overflow = opts.overflow[ 0 ]; + style.overflowX = opts.overflow[ 1 ]; + style.overflowY = opts.overflow[ 2 ]; + } ); + } + + // Implement show/hide animations + propTween = false; + for ( prop in orig ) { + + // General show/hide setup for this element animation + if ( !propTween ) { + if ( dataShow ) { + if ( "hidden" in dataShow ) { + hidden = dataShow.hidden; + } + } else { + dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } ); + } + + // Store hidden/visible for toggle so `.stop().toggle()` "reverses" + if ( toggle ) { + dataShow.hidden = !hidden; + } + + // Show elements before animating them + if ( hidden ) { + showHide( [ elem ], true ); + } + + /* eslint-disable no-loop-func */ + + anim.done( function() { + + /* eslint-enable no-loop-func */ + + // The final step of a "hide" animation is actually hiding the element + if ( !hidden ) { + showHide( [ elem ] ); + } + dataPriv.remove( elem, "fxshow" ); + for ( prop in orig ) { + jQuery.style( elem, prop, orig[ prop ] ); + } + } ); + } + + // Per-property setup + propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); + if ( !( prop in dataShow ) ) { + dataShow[ prop ] = propTween.start; + if ( hidden ) { + propTween.end = propTween.start; + propTween.start = 0; + } + } + } + } + + function propFilter( props, specialEasing ) { + var index, name, easing, value, hooks; + + // camelCase, specialEasing and expand cssHook pass + for ( index in props ) { + name = camelCase( index ); + easing = specialEasing[ name ]; + value = props[ index ]; + if ( Array.isArray( value ) ) { + easing = value[ 1 ]; + value = props[ index ] = value[ 0 ]; + } + + if ( index !== name ) { + props[ name ] = value; + delete props[ index ]; + } + + hooks = jQuery.cssHooks[ name ]; + if ( hooks && "expand" in hooks ) { + value = hooks.expand( value ); + delete props[ name ]; + + // Not quite $.extend, this won't overwrite existing keys. + // Reusing 'index' because we have the correct "name" + for ( index in value ) { + if ( !( index in props ) ) { + props[ index ] = value[ index ]; + specialEasing[ index ] = easing; + } + } + } else { + specialEasing[ name ] = easing; + } + } + } + + function Animation( elem, properties, options ) { + var result, + stopped, + index = 0, + length = Animation.prefilters.length, + deferred = jQuery.Deferred().always( function() { + + // Don't match elem in the :animated selector + delete tick.elem; + } ), + tick = function() { + if ( stopped ) { + return false; + } + var currentTime = fxNow || createFxNow(), + remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), + + // Support: Android 2.3 only + // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497) + temp = remaining / animation.duration || 0, + percent = 1 - temp, + index = 0, + length = animation.tweens.length; + + for ( ; index < length; index++ ) { + animation.tweens[ index ].run( percent ); + } + + deferred.notifyWith( elem, [ animation, percent, remaining ] ); + + // If there's more to do, yield + if ( percent < 1 && length ) { + return remaining; + } + + // If this was an empty animation, synthesize a final progress notification + if ( !length ) { + deferred.notifyWith( elem, [ animation, 1, 0 ] ); + } + + // Resolve the animation and report its conclusion + deferred.resolveWith( elem, [ animation ] ); + return false; + }, + animation = deferred.promise( { + elem: elem, + props: jQuery.extend( {}, properties ), + opts: jQuery.extend( true, { + specialEasing: {}, + easing: jQuery.easing._default + }, options ), + originalProperties: properties, + originalOptions: options, + startTime: fxNow || createFxNow(), + duration: options.duration, + tweens: [], + createTween: function( prop, end ) { + var tween = jQuery.Tween( elem, animation.opts, prop, end, + animation.opts.specialEasing[ prop ] || animation.opts.easing ); + animation.tweens.push( tween ); + return tween; + }, + stop: function( gotoEnd ) { + var index = 0, + + // If we are going to the end, we want to run all the tweens + // otherwise we skip this part + length = gotoEnd ? animation.tweens.length : 0; + if ( stopped ) { + return this; + } + stopped = true; + for ( ; index < length; index++ ) { + animation.tweens[ index ].run( 1 ); + } + + // Resolve when we played the last frame; otherwise, reject + if ( gotoEnd ) { + deferred.notifyWith( elem, [ animation, 1, 0 ] ); + deferred.resolveWith( elem, [ animation, gotoEnd ] ); + } else { + deferred.rejectWith( elem, [ animation, gotoEnd ] ); + } + return this; + } + } ), + props = animation.props; + + propFilter( props, animation.opts.specialEasing ); + + for ( ; index < length; index++ ) { + result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts ); + if ( result ) { + if ( isFunction( result.stop ) ) { + jQuery._queueHooks( animation.elem, animation.opts.queue ).stop = + result.stop.bind( result ); + } + return result; + } + } + + jQuery.map( props, createTween, animation ); + + if ( isFunction( animation.opts.start ) ) { + animation.opts.start.call( elem, animation ); + } + + // Attach callbacks from options + animation + .progress( animation.opts.progress ) + .done( animation.opts.done, animation.opts.complete ) + .fail( animation.opts.fail ) + .always( animation.opts.always ); + + jQuery.fx.timer( + jQuery.extend( tick, { + elem: elem, + anim: animation, + queue: animation.opts.queue + } ) + ); + + return animation; + } + + jQuery.Animation = jQuery.extend( Animation, { + + tweeners: { + "*": [ function( prop, value ) { + var tween = this.createTween( prop, value ); + adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween ); + return tween; + } ] + }, + + tweener: function( props, callback ) { + if ( isFunction( props ) ) { + callback = props; + props = [ "*" ]; + } else { + props = props.match( rnothtmlwhite ); + } + + var prop, + index = 0, + length = props.length; + + for ( ; index < length; index++ ) { + prop = props[ index ]; + Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || []; + Animation.tweeners[ prop ].unshift( callback ); + } + }, + + prefilters: [ defaultPrefilter ], + + prefilter: function( callback, prepend ) { + if ( prepend ) { + Animation.prefilters.unshift( callback ); + } else { + Animation.prefilters.push( callback ); + } + } + } ); + + jQuery.speed = function( speed, easing, fn ) { + var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { + complete: fn || !fn && easing || + isFunction( speed ) && speed, + duration: speed, + easing: fn && easing || easing && !isFunction( easing ) && easing + }; + + // Go to the end state if fx are off + if ( jQuery.fx.off ) { + opt.duration = 0; + + } else { + if ( typeof opt.duration !== "number" ) { + if ( opt.duration in jQuery.fx.speeds ) { + opt.duration = jQuery.fx.speeds[ opt.duration ]; + + } else { + opt.duration = jQuery.fx.speeds._default; + } + } + } + + // Normalize opt.queue - true/undefined/null -> "fx" + if ( opt.queue == null || opt.queue === true ) { + opt.queue = "fx"; + } + + // Queueing + opt.old = opt.complete; + + opt.complete = function() { + if ( isFunction( opt.old ) ) { + opt.old.call( this ); + } + + if ( opt.queue ) { + jQuery.dequeue( this, opt.queue ); + } + }; + + return opt; + }; + + jQuery.fn.extend( { + fadeTo: function( speed, to, easing, callback ) { + + // Show any hidden elements after setting opacity to 0 + return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show() + + // Animate to the value specified + .end().animate( { opacity: to }, speed, easing, callback ); + }, + animate: function( prop, speed, easing, callback ) { + var empty = jQuery.isEmptyObject( prop ), + optall = jQuery.speed( speed, easing, callback ), + doAnimation = function() { + + // Operate on a copy of prop so per-property easing won't be lost + var anim = Animation( this, jQuery.extend( {}, prop ), optall ); + + // Empty animations, or finishing resolves immediately + if ( empty || dataPriv.get( this, "finish" ) ) { + anim.stop( true ); + } + }; + doAnimation.finish = doAnimation; + + return empty || optall.queue === false ? + this.each( doAnimation ) : + this.queue( optall.queue, doAnimation ); + }, + stop: function( type, clearQueue, gotoEnd ) { + var stopQueue = function( hooks ) { + var stop = hooks.stop; + delete hooks.stop; + stop( gotoEnd ); + }; + + if ( typeof type !== "string" ) { + gotoEnd = clearQueue; + clearQueue = type; + type = undefined; + } + if ( clearQueue ) { + this.queue( type || "fx", [] ); + } + + return this.each( function() { + var dequeue = true, + index = type != null && type + "queueHooks", + timers = jQuery.timers, + data = dataPriv.get( this ); + + if ( index ) { + if ( data[ index ] && data[ index ].stop ) { + stopQueue( data[ index ] ); + } + } else { + for ( index in data ) { + if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { + stopQueue( data[ index ] ); + } + } + } + + for ( index = timers.length; index--; ) { + if ( timers[ index ].elem === this && + ( type == null || timers[ index ].queue === type ) ) { + + timers[ index ].anim.stop( gotoEnd ); + dequeue = false; + timers.splice( index, 1 ); + } + } + + // Start the next in the queue if the last step wasn't forced. + // Timers currently will call their complete callbacks, which + // will dequeue but only if they were gotoEnd. + if ( dequeue || !gotoEnd ) { + jQuery.dequeue( this, type ); + } + } ); + }, + finish: function( type ) { + if ( type !== false ) { + type = type || "fx"; + } + return this.each( function() { + var index, + data = dataPriv.get( this ), + queue = data[ type + "queue" ], + hooks = data[ type + "queueHooks" ], + timers = jQuery.timers, + length = queue ? queue.length : 0; + + // Enable finishing flag on private data + data.finish = true; + + // Empty the queue first + jQuery.queue( this, type, [] ); + + if ( hooks && hooks.stop ) { + hooks.stop.call( this, true ); + } + + // Look for any active animations, and finish them + for ( index = timers.length; index--; ) { + if ( timers[ index ].elem === this && timers[ index ].queue === type ) { + timers[ index ].anim.stop( true ); + timers.splice( index, 1 ); + } + } + + // Look for any animations in the old queue and finish them + for ( index = 0; index < length; index++ ) { + if ( queue[ index ] && queue[ index ].finish ) { + queue[ index ].finish.call( this ); + } + } + + // Turn off finishing flag + delete data.finish; + } ); + } + } ); + + jQuery.each( [ "toggle", "show", "hide" ], function( _i, name ) { + var cssFn = jQuery.fn[ name ]; + jQuery.fn[ name ] = function( speed, easing, callback ) { + return speed == null || typeof speed === "boolean" ? + cssFn.apply( this, arguments ) : + this.animate( genFx( name, true ), speed, easing, callback ); + }; + } ); + +// Generate shortcuts for custom animations + jQuery.each( { + slideDown: genFx( "show" ), + slideUp: genFx( "hide" ), + slideToggle: genFx( "toggle" ), + fadeIn: { opacity: "show" }, + fadeOut: { opacity: "hide" }, + fadeToggle: { opacity: "toggle" } + }, function( name, props ) { + jQuery.fn[ name ] = function( speed, easing, callback ) { + return this.animate( props, speed, easing, callback ); + }; + } ); + + jQuery.timers = []; + jQuery.fx.tick = function() { + var timer, + i = 0, + timers = jQuery.timers; + + fxNow = Date.now(); + + for ( ; i < timers.length; i++ ) { + timer = timers[ i ]; + + // Run the timer and safely remove it when done (allowing for external removal) + if ( !timer() && timers[ i ] === timer ) { + timers.splice( i--, 1 ); + } + } + + if ( !timers.length ) { + jQuery.fx.stop(); + } + fxNow = undefined; + }; + + jQuery.fx.timer = function( timer ) { + jQuery.timers.push( timer ); + jQuery.fx.start(); + }; + + jQuery.fx.interval = 13; + jQuery.fx.start = function() { + if ( inProgress ) { + return; + } + + inProgress = true; + schedule(); + }; + + jQuery.fx.stop = function() { + inProgress = null; + }; + + jQuery.fx.speeds = { + slow: 600, + fast: 200, + + // Default speed + _default: 400 + }; + + +// Based off of the plugin by Clint Helfers, with permission. +// https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/ + jQuery.fn.delay = function( time, type ) { + time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; + type = type || "fx"; + + return this.queue( type, function( next, hooks ) { + var timeout = window.setTimeout( next, time ); + hooks.stop = function() { + window.clearTimeout( timeout ); + }; + } ); + }; + + + ( function() { + var input = document.createElement( "input" ), + select = document.createElement( "select" ), + opt = select.appendChild( document.createElement( "option" ) ); + + input.type = "checkbox"; + + // Support: Android <=4.3 only + // Default value for a checkbox should be "on" + support.checkOn = input.value !== ""; + + // Support: IE <=11 only + // Must access selectedIndex to make default options select + support.optSelected = opt.selected; + + // Support: IE <=11 only + // An input loses its value after becoming a radio + input = document.createElement( "input" ); + input.value = "t"; + input.type = "radio"; + support.radioValue = input.value === "t"; + } )(); + + + var boolHook, + attrHandle = jQuery.expr.attrHandle; + + jQuery.fn.extend( { + attr: function( name, value ) { + return access( this, jQuery.attr, name, value, arguments.length > 1 ); + }, + + removeAttr: function( name ) { + return this.each( function() { + jQuery.removeAttr( this, name ); + } ); + } + } ); + + jQuery.extend( { + attr: function( elem, name, value ) { + var ret, hooks, + nType = elem.nodeType; + + // Don't get/set attributes on text, comment and attribute nodes + if ( nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + // Fallback to prop when attributes are not supported + if ( typeof elem.getAttribute === "undefined" ) { + return jQuery.prop( elem, name, value ); + } + + // Attribute hooks are determined by the lowercase version + // Grab necessary hook if one is defined + if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { + hooks = jQuery.attrHooks[ name.toLowerCase() ] || + ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined ); + } + + if ( value !== undefined ) { + if ( value === null ) { + jQuery.removeAttr( elem, name ); + return; + } + + if ( hooks && "set" in hooks && + ( ret = hooks.set( elem, value, name ) ) !== undefined ) { + return ret; + } + + elem.setAttribute( name, value + "" ); + return value; + } + + if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { + return ret; + } + + ret = jQuery.find.attr( elem, name ); + + // Non-existent attributes return null, we normalize to undefined + return ret == null ? undefined : ret; + }, + + attrHooks: { + type: { + set: function( elem, value ) { + if ( !support.radioValue && value === "radio" && + nodeName( elem, "input" ) ) { + var val = elem.value; + elem.setAttribute( "type", value ); + if ( val ) { + elem.value = val; + } + return value; + } + } + } + }, + + removeAttr: function( elem, value ) { + var name, + i = 0, + + // Attribute names can contain non-HTML whitespace characters + // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 + attrNames = value && value.match( rnothtmlwhite ); + + if ( attrNames && elem.nodeType === 1 ) { + while ( ( name = attrNames[ i++ ] ) ) { + elem.removeAttribute( name ); + } + } + } + } ); + +// Hooks for boolean attributes + boolHook = { + set: function( elem, value, name ) { + if ( value === false ) { + + // Remove boolean attributes when set to false + jQuery.removeAttr( elem, name ); + } else { + elem.setAttribute( name, name ); + } + return name; + } + }; + + jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) { + var getter = attrHandle[ name ] || jQuery.find.attr; + + attrHandle[ name ] = function( elem, name, isXML ) { + var ret, handle, + lowercaseName = name.toLowerCase(); + + if ( !isXML ) { + + // Avoid an infinite loop by temporarily removing this function from the getter + handle = attrHandle[ lowercaseName ]; + attrHandle[ lowercaseName ] = ret; + ret = getter( elem, name, isXML ) != null ? + lowercaseName : + null; + attrHandle[ lowercaseName ] = handle; + } + return ret; + }; + } ); + + + + + var rfocusable = /^(?:input|select|textarea|button)$/i, + rclickable = /^(?:a|area)$/i; + + jQuery.fn.extend( { + prop: function( name, value ) { + return access( this, jQuery.prop, name, value, arguments.length > 1 ); + }, + + removeProp: function( name ) { + return this.each( function() { + delete this[ jQuery.propFix[ name ] || name ]; + } ); + } + } ); + + jQuery.extend( { + prop: function( elem, name, value ) { + var ret, hooks, + nType = elem.nodeType; + + // Don't get/set properties on text, comment and attribute nodes + if ( nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { + + // Fix name and attach hooks + name = jQuery.propFix[ name ] || name; + hooks = jQuery.propHooks[ name ]; + } + + if ( value !== undefined ) { + if ( hooks && "set" in hooks && + ( ret = hooks.set( elem, value, name ) ) !== undefined ) { + return ret; + } + + return ( elem[ name ] = value ); + } + + if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { + return ret; + } + + return elem[ name ]; + }, + + propHooks: { + tabIndex: { + get: function( elem ) { + + // Support: IE <=9 - 11 only + // elem.tabIndex doesn't always return the + // correct value when it hasn't been explicitly set + // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ + // Use proper attribute retrieval(#12072) + var tabindex = jQuery.find.attr( elem, "tabindex" ); + + if ( tabindex ) { + return parseInt( tabindex, 10 ); + } + + if ( + rfocusable.test( elem.nodeName ) || + rclickable.test( elem.nodeName ) && + elem.href + ) { + return 0; + } + + return -1; + } + } + }, + + propFix: { + "for": "htmlFor", + "class": "className" + } + } ); + +// Support: IE <=11 only +// Accessing the selectedIndex property +// forces the browser to respect setting selected +// on the option +// The getter ensures a default option is selected +// when in an optgroup +// eslint rule "no-unused-expressions" is disabled for this code +// since it considers such accessions noop + if ( !support.optSelected ) { + jQuery.propHooks.selected = { + get: function( elem ) { + + /* eslint no-unused-expressions: "off" */ + + var parent = elem.parentNode; + if ( parent && parent.parentNode ) { + parent.parentNode.selectedIndex; + } + return null; + }, + set: function( elem ) { + + /* eslint no-unused-expressions: "off" */ + + var parent = elem.parentNode; + if ( parent ) { + parent.selectedIndex; + + if ( parent.parentNode ) { + parent.parentNode.selectedIndex; + } + } + } + }; + } + + jQuery.each( [ + "tabIndex", + "readOnly", + "maxLength", + "cellSpacing", + "cellPadding", + "rowSpan", + "colSpan", + "useMap", + "frameBorder", + "contentEditable" + ], function() { + jQuery.propFix[ this.toLowerCase() ] = this; + } ); + + + + + // Strip and collapse whitespace according to HTML spec + // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace + function stripAndCollapse( value ) { + var tokens = value.match( rnothtmlwhite ) || []; + return tokens.join( " " ); + } + + + function getClass( elem ) { + return elem.getAttribute && elem.getAttribute( "class" ) || ""; + } + + function classesToArray( value ) { + if ( Array.isArray( value ) ) { + return value; + } + if ( typeof value === "string" ) { + return value.match( rnothtmlwhite ) || []; + } + return []; + } + + jQuery.fn.extend( { + addClass: function( value ) { + var classes, elem, cur, curValue, clazz, j, finalValue, + i = 0; + + if ( isFunction( value ) ) { + return this.each( function( j ) { + jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); + } ); + } + + classes = classesToArray( value ); + + if ( classes.length ) { + while ( ( elem = this[ i++ ] ) ) { + curValue = getClass( elem ); + cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); + + if ( cur ) { + j = 0; + while ( ( clazz = classes[ j++ ] ) ) { + if ( cur.indexOf( " " + clazz + " " ) < 0 ) { + cur += clazz + " "; + } + } + + // Only assign if different to avoid unneeded rendering. + finalValue = stripAndCollapse( cur ); + if ( curValue !== finalValue ) { + elem.setAttribute( "class", finalValue ); + } + } + } + } + + return this; + }, + + removeClass: function( value ) { + var classes, elem, cur, curValue, clazz, j, finalValue, + i = 0; + + if ( isFunction( value ) ) { + return this.each( function( j ) { + jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); + } ); + } + + if ( !arguments.length ) { + return this.attr( "class", "" ); + } + + classes = classesToArray( value ); + + if ( classes.length ) { + while ( ( elem = this[ i++ ] ) ) { + curValue = getClass( elem ); + + // This expression is here for better compressibility (see addClass) + cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); + + if ( cur ) { + j = 0; + while ( ( clazz = classes[ j++ ] ) ) { + + // Remove *all* instances + while ( cur.indexOf( " " + clazz + " " ) > -1 ) { + cur = cur.replace( " " + clazz + " ", " " ); + } + } + + // Only assign if different to avoid unneeded rendering. + finalValue = stripAndCollapse( cur ); + if ( curValue !== finalValue ) { + elem.setAttribute( "class", finalValue ); + } + } + } + } + + return this; + }, + + toggleClass: function( value, stateVal ) { + var type = typeof value, + isValidValue = type === "string" || Array.isArray( value ); + + if ( typeof stateVal === "boolean" && isValidValue ) { + return stateVal ? this.addClass( value ) : this.removeClass( value ); + } + + if ( isFunction( value ) ) { + return this.each( function( i ) { + jQuery( this ).toggleClass( + value.call( this, i, getClass( this ), stateVal ), + stateVal + ); + } ); + } + + return this.each( function() { + var className, i, self, classNames; + + if ( isValidValue ) { + + // Toggle individual class names + i = 0; + self = jQuery( this ); + classNames = classesToArray( value ); + + while ( ( className = classNames[ i++ ] ) ) { + + // Check each className given, space separated list + if ( self.hasClass( className ) ) { + self.removeClass( className ); + } else { + self.addClass( className ); + } + } + + // Toggle whole class name + } else if ( value === undefined || type === "boolean" ) { + className = getClass( this ); + if ( className ) { + + // Store className if set + dataPriv.set( this, "__className__", className ); + } + + // If the element has a class name or if we're passed `false`, + // then remove the whole classname (if there was one, the above saved it). + // Otherwise bring back whatever was previously saved (if anything), + // falling back to the empty string if nothing was stored. + if ( this.setAttribute ) { + this.setAttribute( "class", + className || value === false ? + "" : + dataPriv.get( this, "__className__" ) || "" + ); + } + } + } ); + }, + + hasClass: function( selector ) { + var className, elem, + i = 0; + + className = " " + selector + " "; + while ( ( elem = this[ i++ ] ) ) { + if ( elem.nodeType === 1 && + ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) { + return true; + } + } + + return false; + } + } ); + + + + + var rreturn = /\r/g; + + jQuery.fn.extend( { + val: function( value ) { + var hooks, ret, valueIsFunction, + elem = this[ 0 ]; + + if ( !arguments.length ) { + if ( elem ) { + hooks = jQuery.valHooks[ elem.type ] || + jQuery.valHooks[ elem.nodeName.toLowerCase() ]; + + if ( hooks && + "get" in hooks && + ( ret = hooks.get( elem, "value" ) ) !== undefined + ) { + return ret; + } + + ret = elem.value; + + // Handle most common string cases + if ( typeof ret === "string" ) { + return ret.replace( rreturn, "" ); + } + + // Handle cases where value is null/undef or number + return ret == null ? "" : ret; + } + + return; + } + + valueIsFunction = isFunction( value ); + + return this.each( function( i ) { + var val; + + if ( this.nodeType !== 1 ) { + return; + } + + if ( valueIsFunction ) { + val = value.call( this, i, jQuery( this ).val() ); + } else { + val = value; + } + + // Treat null/undefined as ""; convert numbers to string + if ( val == null ) { + val = ""; + + } else if ( typeof val === "number" ) { + val += ""; + + } else if ( Array.isArray( val ) ) { + val = jQuery.map( val, function( value ) { + return value == null ? "" : value + ""; + } ); + } + + hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; + + // If set returns undefined, fall back to normal setting + if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) { + this.value = val; + } + } ); + } + } ); + + jQuery.extend( { + valHooks: { + option: { + get: function( elem ) { + + var val = jQuery.find.attr( elem, "value" ); + return val != null ? + val : + + // Support: IE <=10 - 11 only + // option.text throws exceptions (#14686, #14858) + // Strip and collapse whitespace + // https://html.spec.whatwg.org/#strip-and-collapse-whitespace + stripAndCollapse( jQuery.text( elem ) ); + } + }, + select: { + get: function( elem ) { + var value, option, i, + options = elem.options, + index = elem.selectedIndex, + one = elem.type === "select-one", + values = one ? null : [], + max = one ? index + 1 : options.length; + + if ( index < 0 ) { + i = max; + + } else { + i = one ? index : 0; + } + + // Loop through all the selected options + for ( ; i < max; i++ ) { + option = options[ i ]; + + // Support: IE <=9 only + // IE8-9 doesn't update selected after form reset (#2551) + if ( ( option.selected || i === index ) && + + // Don't return options that are disabled or in a disabled optgroup + !option.disabled && + ( !option.parentNode.disabled || + !nodeName( option.parentNode, "optgroup" ) ) ) { + + // Get the specific value for the option + value = jQuery( option ).val(); + + // We don't need an array for one selects + if ( one ) { + return value; + } + + // Multi-Selects return an array + values.push( value ); + } + } + + return values; + }, + + set: function( elem, value ) { + var optionSet, option, + options = elem.options, + values = jQuery.makeArray( value ), + i = options.length; + + while ( i-- ) { + option = options[ i ]; + + /* eslint-disable no-cond-assign */ + + if ( option.selected = + jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 + ) { + optionSet = true; + } + + /* eslint-enable no-cond-assign */ + } + + // Force browsers to behave consistently when non-matching value is set + if ( !optionSet ) { + elem.selectedIndex = -1; + } + return values; + } + } + } + } ); + +// Radios and checkboxes getter/setter + jQuery.each( [ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = { + set: function( elem, value ) { + if ( Array.isArray( value ) ) { + return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 ); + } + } + }; + if ( !support.checkOn ) { + jQuery.valHooks[ this ].get = function( elem ) { + return elem.getAttribute( "value" ) === null ? "on" : elem.value; + }; + } + } ); + + + + +// Return jQuery for attributes-only inclusion + + + support.focusin = "onfocusin" in window; + + + var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, + stopPropagationCallback = function( e ) { + e.stopPropagation(); + }; + + jQuery.extend( jQuery.event, { + + trigger: function( event, data, elem, onlyHandlers ) { + + var i, cur, tmp, bubbleType, ontype, handle, special, lastElement, + eventPath = [ elem || document ], + type = hasOwn.call( event, "type" ) ? event.type : event, + namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : []; + + cur = lastElement = tmp = elem = elem || document; + + // Don't do events on text and comment nodes + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + return; + } + + // focus/blur morphs to focusin/out; ensure we're not firing them right now + if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { + return; + } + + if ( type.indexOf( "." ) > -1 ) { + + // Namespaced trigger; create a regexp to match event type in handle() + namespaces = type.split( "." ); + type = namespaces.shift(); + namespaces.sort(); + } + ontype = type.indexOf( ":" ) < 0 && "on" + type; + + // Caller can pass in a jQuery.Event object, Object, or just an event type string + event = event[ jQuery.expando ] ? + event : + new jQuery.Event( type, typeof event === "object" && event ); + + // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) + event.isTrigger = onlyHandlers ? 2 : 3; + event.namespace = namespaces.join( "." ); + event.rnamespace = event.namespace ? + new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) : + null; + + // Clean up the event in case it is being reused + event.result = undefined; + if ( !event.target ) { + event.target = elem; + } + + // Clone any incoming data and prepend the event, creating the handler arg list + data = data == null ? + [ event ] : + jQuery.makeArray( data, [ event ] ); + + // Allow special events to draw outside the lines + special = jQuery.event.special[ type ] || {}; + if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { + return; + } + + // Determine event propagation path in advance, per W3C events spec (#9951) + // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) + if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) { + + bubbleType = special.delegateType || type; + if ( !rfocusMorph.test( bubbleType + type ) ) { + cur = cur.parentNode; + } + for ( ; cur; cur = cur.parentNode ) { + eventPath.push( cur ); + tmp = cur; + } + + // Only add window if we got to document (e.g., not plain obj or detached DOM) + if ( tmp === ( elem.ownerDocument || document ) ) { + eventPath.push( tmp.defaultView || tmp.parentWindow || window ); + } + } + + // Fire handlers on the event path + i = 0; + while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) { + lastElement = cur; + event.type = i > 1 ? + bubbleType : + special.bindType || type; + + // jQuery handler + handle = ( + dataPriv.get( cur, "events" ) || Object.create( null ) + )[ event.type ] && + dataPriv.get( cur, "handle" ); + if ( handle ) { + handle.apply( cur, data ); + } + + // Native handler + handle = ontype && cur[ ontype ]; + if ( handle && handle.apply && acceptData( cur ) ) { + event.result = handle.apply( cur, data ); + if ( event.result === false ) { + event.preventDefault(); + } + } + } + event.type = type; + + // If nobody prevented the default action, do it now + if ( !onlyHandlers && !event.isDefaultPrevented() ) { + + if ( ( !special._default || + special._default.apply( eventPath.pop(), data ) === false ) && + acceptData( elem ) ) { + + // Call a native DOM method on the target with the same name as the event. + // Don't do default actions on window, that's where global variables be (#6170) + if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) { + + // Don't re-trigger an onFOO event when we call its FOO() method + tmp = elem[ ontype ]; + + if ( tmp ) { + elem[ ontype ] = null; + } + + // Prevent re-triggering of the same event, since we already bubbled it above + jQuery.event.triggered = type; + + if ( event.isPropagationStopped() ) { + lastElement.addEventListener( type, stopPropagationCallback ); + } + + elem[ type ](); + + if ( event.isPropagationStopped() ) { + lastElement.removeEventListener( type, stopPropagationCallback ); + } + + jQuery.event.triggered = undefined; + + if ( tmp ) { + elem[ ontype ] = tmp; + } + } + } + } + + return event.result; + }, + + // Piggyback on a donor event to simulate a different one + // Used only for `focus(in | out)` events + simulate: function( type, elem, event ) { + var e = jQuery.extend( + new jQuery.Event(), + event, + { + type: type, + isSimulated: true + } + ); + + jQuery.event.trigger( e, null, elem ); + } + + } ); + + jQuery.fn.extend( { + + trigger: function( type, data ) { + return this.each( function() { + jQuery.event.trigger( type, data, this ); + } ); + }, + triggerHandler: function( type, data ) { + var elem = this[ 0 ]; + if ( elem ) { + return jQuery.event.trigger( type, data, elem, true ); + } + } + } ); + + +// Support: Firefox <=44 +// Firefox doesn't have focus(in | out) events +// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787 +// +// Support: Chrome <=48 - 49, Safari <=9.0 - 9.1 +// focus(in | out) events fire after focus & blur events, +// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order +// Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857 + if ( !support.focusin ) { + jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) { + + // Attach a single capturing handler on the document while someone wants focusin/focusout + var handler = function( event ) { + jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) ); + }; + + jQuery.event.special[ fix ] = { + setup: function() { + + // Handle: regular nodes (via `this.ownerDocument`), window + // (via `this.document`) & document (via `this`). + var doc = this.ownerDocument || this.document || this, + attaches = dataPriv.access( doc, fix ); + + if ( !attaches ) { + doc.addEventListener( orig, handler, true ); + } + dataPriv.access( doc, fix, ( attaches || 0 ) + 1 ); + }, + teardown: function() { + var doc = this.ownerDocument || this.document || this, + attaches = dataPriv.access( doc, fix ) - 1; + + if ( !attaches ) { + doc.removeEventListener( orig, handler, true ); + dataPriv.remove( doc, fix ); + + } else { + dataPriv.access( doc, fix, attaches ); + } + } + }; + } ); + } + var location = window.location; + + var nonce = { guid: Date.now() }; + + var rquery = ( /\?/ ); + + + +// Cross-browser xml parsing + jQuery.parseXML = function( data ) { + var xml; + if ( !data || typeof data !== "string" ) { + return null; + } + + // Support: IE 9 - 11 only + // IE throws on parseFromString with invalid input. + try { + xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" ); + } catch ( e ) { + xml = undefined; + } + + if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) { + jQuery.error( "Invalid XML: " + data ); + } + return xml; + }; + + + var + rbracket = /\[\]$/, + rCRLF = /\r?\n/g, + rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, + rsubmittable = /^(?:input|select|textarea|keygen)/i; + + function buildParams( prefix, obj, traditional, add ) { + var name; + + if ( Array.isArray( obj ) ) { + + // Serialize array item. + jQuery.each( obj, function( i, v ) { + if ( traditional || rbracket.test( prefix ) ) { + + // Treat each array item as a scalar. + add( prefix, v ); + + } else { + + // Item is non-scalar (array or object), encode its numeric index. + buildParams( + prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]", + v, + traditional, + add + ); + } + } ); + + } else if ( !traditional && toType( obj ) === "object" ) { + + // Serialize object item. + for ( name in obj ) { + buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); + } + + } else { + + // Serialize scalar item. + add( prefix, obj ); + } + } + +// Serialize an array of form elements or a set of +// key/values into a query string + jQuery.param = function( a, traditional ) { + var prefix, + s = [], + add = function( key, valueOrFunction ) { + + // If value is a function, invoke it and use its return value + var value = isFunction( valueOrFunction ) ? + valueOrFunction() : + valueOrFunction; + + s[ s.length ] = encodeURIComponent( key ) + "=" + + encodeURIComponent( value == null ? "" : value ); + }; + + if ( a == null ) { + return ""; + } + + // If an array was passed in, assume that it is an array of form elements. + if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { + + // Serialize the form elements + jQuery.each( a, function() { + add( this.name, this.value ); + } ); + + } else { + + // If traditional, encode the "old" way (the way 1.3.2 or older + // did it), otherwise encode params recursively. + for ( prefix in a ) { + buildParams( prefix, a[ prefix ], traditional, add ); + } + } + + // Return the resulting serialization + return s.join( "&" ); + }; + + jQuery.fn.extend( { + serialize: function() { + return jQuery.param( this.serializeArray() ); + }, + serializeArray: function() { + return this.map( function() { + + // Can add propHook for "elements" to filter or add form elements + var elements = jQuery.prop( this, "elements" ); + return elements ? jQuery.makeArray( elements ) : this; + } ) + .filter( function() { + var type = this.type; + + // Use .is( ":disabled" ) so that fieldset[disabled] works + return this.name && !jQuery( this ).is( ":disabled" ) && + rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && + ( this.checked || !rcheckableType.test( type ) ); + } ) + .map( function( _i, elem ) { + var val = jQuery( this ).val(); + + if ( val == null ) { + return null; + } + + if ( Array.isArray( val ) ) { + return jQuery.map( val, function( val ) { + return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; + } ); + } + + return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; + } ).get(); + } + } ); + + + var + r20 = /%20/g, + rhash = /#.*$/, + rantiCache = /([?&])_=[^&]*/, + rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, + + // #7653, #8125, #8152: local protocol detection + rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, + rnoContent = /^(?:GET|HEAD)$/, + rprotocol = /^\/\//, + + /* Prefilters + * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) + * 2) These are called: + * - BEFORE asking for a transport + * - AFTER param serialization (s.data is a string if s.processData is true) + * 3) key is the dataType + * 4) the catchall symbol "*" can be used + * 5) execution will start with transport dataType and THEN continue down to "*" if needed + */ + prefilters = {}, + + /* Transports bindings + * 1) key is the dataType + * 2) the catchall symbol "*" can be used + * 3) selection will start with transport dataType and THEN go to "*" if needed + */ + transports = {}, + + // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression + allTypes = "*/".concat( "*" ), + + // Anchor tag for parsing the document origin + originAnchor = document.createElement( "a" ); + originAnchor.href = location.href; + +// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport + function addToPrefiltersOrTransports( structure ) { + + // dataTypeExpression is optional and defaults to "*" + return function( dataTypeExpression, func ) { + + if ( typeof dataTypeExpression !== "string" ) { + func = dataTypeExpression; + dataTypeExpression = "*"; + } + + var dataType, + i = 0, + dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || []; + + if ( isFunction( func ) ) { + + // For each dataType in the dataTypeExpression + while ( ( dataType = dataTypes[ i++ ] ) ) { + + // Prepend if requested + if ( dataType[ 0 ] === "+" ) { + dataType = dataType.slice( 1 ) || "*"; + ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func ); + + // Otherwise append + } else { + ( structure[ dataType ] = structure[ dataType ] || [] ).push( func ); + } + } + } + }; + } + +// Base inspection function for prefilters and transports + function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) { + + var inspected = {}, + seekingTransport = ( structure === transports ); + + function inspect( dataType ) { + var selected; + inspected[ dataType ] = true; + jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { + var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); + if ( typeof dataTypeOrTransport === "string" && + !seekingTransport && !inspected[ dataTypeOrTransport ] ) { + + options.dataTypes.unshift( dataTypeOrTransport ); + inspect( dataTypeOrTransport ); + return false; + } else if ( seekingTransport ) { + return !( selected = dataTypeOrTransport ); + } + } ); + return selected; + } + + return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" ); + } + +// A special extend for ajax options +// that takes "flat" options (not to be deep extended) +// Fixes #9887 + function ajaxExtend( target, src ) { + var key, deep, + flatOptions = jQuery.ajaxSettings.flatOptions || {}; + + for ( key in src ) { + if ( src[ key ] !== undefined ) { + ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; + } + } + if ( deep ) { + jQuery.extend( true, target, deep ); + } + + return target; + } + + /* Handles responses to an ajax request: + * - finds the right dataType (mediates between content-type and expected dataType) + * - returns the corresponding response + */ + function ajaxHandleResponses( s, jqXHR, responses ) { + + var ct, type, finalDataType, firstDataType, + contents = s.contents, + dataTypes = s.dataTypes; + + // Remove auto dataType and get content-type in the process + while ( dataTypes[ 0 ] === "*" ) { + dataTypes.shift(); + if ( ct === undefined ) { + ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" ); + } + } + + // Check if we're dealing with a known content-type + if ( ct ) { + for ( type in contents ) { + if ( contents[ type ] && contents[ type ].test( ct ) ) { + dataTypes.unshift( type ); + break; + } + } + } + + // Check to see if we have a response for the expected dataType + if ( dataTypes[ 0 ] in responses ) { + finalDataType = dataTypes[ 0 ]; + } else { + + // Try convertible dataTypes + for ( type in responses ) { + if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) { + finalDataType = type; + break; + } + if ( !firstDataType ) { + firstDataType = type; + } + } + + // Or just use first one + finalDataType = finalDataType || firstDataType; + } + + // If we found a dataType + // We add the dataType to the list if needed + // and return the corresponding response + if ( finalDataType ) { + if ( finalDataType !== dataTypes[ 0 ] ) { + dataTypes.unshift( finalDataType ); + } + return responses[ finalDataType ]; + } + } + + /* Chain conversions given the request and the original response + * Also sets the responseXXX fields on the jqXHR instance + */ + function ajaxConvert( s, response, jqXHR, isSuccess ) { + var conv2, current, conv, tmp, prev, + converters = {}, + + // Work with a copy of dataTypes in case we need to modify it for conversion + dataTypes = s.dataTypes.slice(); + + // Create converters map with lowercased keys + if ( dataTypes[ 1 ] ) { + for ( conv in s.converters ) { + converters[ conv.toLowerCase() ] = s.converters[ conv ]; + } + } + + current = dataTypes.shift(); + + // Convert to each sequential dataType + while ( current ) { + + if ( s.responseFields[ current ] ) { + jqXHR[ s.responseFields[ current ] ] = response; + } + + // Apply the dataFilter if provided + if ( !prev && isSuccess && s.dataFilter ) { + response = s.dataFilter( response, s.dataType ); + } + + prev = current; + current = dataTypes.shift(); + + if ( current ) { + + // There's only work to do if current dataType is non-auto + if ( current === "*" ) { + + current = prev; + + // Convert response if prev dataType is non-auto and differs from current + } else if ( prev !== "*" && prev !== current ) { + + // Seek a direct converter + conv = converters[ prev + " " + current ] || converters[ "* " + current ]; + + // If none found, seek a pair + if ( !conv ) { + for ( conv2 in converters ) { + + // If conv2 outputs current + tmp = conv2.split( " " ); + if ( tmp[ 1 ] === current ) { + + // If prev can be converted to accepted input + conv = converters[ prev + " " + tmp[ 0 ] ] || + converters[ "* " + tmp[ 0 ] ]; + if ( conv ) { + + // Condense equivalence converters + if ( conv === true ) { + conv = converters[ conv2 ]; + + // Otherwise, insert the intermediate dataType + } else if ( converters[ conv2 ] !== true ) { + current = tmp[ 0 ]; + dataTypes.unshift( tmp[ 1 ] ); + } + break; + } + } + } + } + + // Apply converter (if not an equivalence) + if ( conv !== true ) { + + // Unless errors are allowed to bubble, catch and return them + if ( conv && s.throws ) { + response = conv( response ); + } else { + try { + response = conv( response ); + } catch ( e ) { + return { + state: "parsererror", + error: conv ? e : "No conversion from " + prev + " to " + current + }; + } + } + } + } + } + } + + return { state: "success", data: response }; + } + + jQuery.extend( { + + // Counter for holding the number of active queries + active: 0, + + // Last-Modified header cache for next request + lastModified: {}, + etag: {}, + + ajaxSettings: { + url: location.href, + type: "GET", + isLocal: rlocalProtocol.test( location.protocol ), + global: true, + processData: true, + async: true, + contentType: "application/x-www-form-urlencoded; charset=UTF-8", + + /* + timeout: 0, + data: null, + dataType: null, + username: null, + password: null, + cache: null, + throws: false, + traditional: false, + headers: {}, + */ + + accepts: { + "*": allTypes, + 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" + }, + + // Data converters + // Keys separate source (or catchall "*") and destination types with a single space + converters: { + + // Convert anything to text + "* text": String, + + // Text to html (true = no transformation) + "text html": true, + + // Evaluate text as a json expression + "text json": JSON.parse, + + // Parse text as xml + "text xml": jQuery.parseXML + }, + + // For options that shouldn't be deep extended: + // you can add your own custom options here if + // and when you create one that shouldn't be + // deep extended (see ajaxExtend) + flatOptions: { + url: true, + context: true + } + }, + + // Creates a full fledged settings object into target + // with both ajaxSettings and settings fields. + // If target is omitted, writes into ajaxSettings. + ajaxSetup: function( target, settings ) { + return settings ? + + // Building a settings object + ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) : + + // Extending ajaxSettings + ajaxExtend( jQuery.ajaxSettings, target ); + }, + + ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), + ajaxTransport: addToPrefiltersOrTransports( transports ), + + // Main method + ajax: function( url, options ) { + + // If url is an object, simulate pre-1.5 signature + if ( typeof url === "object" ) { + options = url; + url = undefined; + } + + // Force options to be an object + options = options || {}; + + var transport, + + // URL without anti-cache param + cacheURL, + + // Response headers + responseHeadersString, + responseHeaders, + + // timeout handle + timeoutTimer, + + // Url cleanup var + urlAnchor, + + // Request state (becomes false upon send and true upon completion) + completed, + + // To know if global events are to be dispatched + fireGlobals, + + // Loop variable + i, + + // uncached part of the url + uncached, + + // Create the final options object + s = jQuery.ajaxSetup( {}, options ), + + // Callbacks context + callbackContext = s.context || s, + + // Context for global events is callbackContext if it is a DOM node or jQuery collection + globalEventContext = s.context && + ( callbackContext.nodeType || callbackContext.jquery ) ? + jQuery( callbackContext ) : + jQuery.event, + + // Deferreds + deferred = jQuery.Deferred(), + completeDeferred = jQuery.Callbacks( "once memory" ), + + // Status-dependent callbacks + statusCode = s.statusCode || {}, + + // Headers (they are sent all at once) + requestHeaders = {}, + requestHeadersNames = {}, + + // Default abort message + strAbort = "canceled", + + // Fake xhr + jqXHR = { + readyState: 0, + + // Builds headers hashtable if needed + getResponseHeader: function( key ) { + var match; + if ( completed ) { + if ( !responseHeaders ) { + responseHeaders = {}; + while ( ( match = rheaders.exec( responseHeadersString ) ) ) { + responseHeaders[ match[ 1 ].toLowerCase() + " " ] = + ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] ) + .concat( match[ 2 ] ); + } + } + match = responseHeaders[ key.toLowerCase() + " " ]; + } + return match == null ? null : match.join( ", " ); + }, + + // Raw string + getAllResponseHeaders: function() { + return completed ? responseHeadersString : null; + }, + + // Caches the header + setRequestHeader: function( name, value ) { + if ( completed == null ) { + name = requestHeadersNames[ name.toLowerCase() ] = + requestHeadersNames[ name.toLowerCase() ] || name; + requestHeaders[ name ] = value; + } + return this; + }, + + // Overrides response content-type header + overrideMimeType: function( type ) { + if ( completed == null ) { + s.mimeType = type; + } + return this; + }, + + // Status-dependent callbacks + statusCode: function( map ) { + var code; + if ( map ) { + if ( completed ) { + + // Execute the appropriate callbacks + jqXHR.always( map[ jqXHR.status ] ); + } else { + + // Lazy-add the new callbacks in a way that preserves old ones + for ( code in map ) { + statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; + } + } + } + return this; + }, + + // Cancel the request + abort: function( statusText ) { + var finalText = statusText || strAbort; + if ( transport ) { + transport.abort( finalText ); + } + done( 0, finalText ); + return this; + } + }; + + // Attach deferreds + deferred.promise( jqXHR ); + + // Add protocol if not provided (prefilters might expect it) + // Handle falsy url in the settings object (#10093: consistency with old signature) + // We also use the url parameter if available + s.url = ( ( url || s.url || location.href ) + "" ) + .replace( rprotocol, location.protocol + "//" ); + + // Alias method option to type as per ticket #12004 + s.type = options.method || options.type || s.method || s.type; + + // Extract dataTypes list + s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ]; + + // A cross-domain request is in order when the origin doesn't match the current origin. + if ( s.crossDomain == null ) { + urlAnchor = document.createElement( "a" ); + + // Support: IE <=8 - 11, Edge 12 - 15 + // IE throws exception on accessing the href property if url is malformed, + // e.g. http://example.com:80x/ + try { + urlAnchor.href = s.url; + + // Support: IE <=8 - 11 only + // Anchor's host property isn't correctly set when s.url is relative + urlAnchor.href = urlAnchor.href; + s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !== + urlAnchor.protocol + "//" + urlAnchor.host; + } catch ( e ) { + + // If there is an error parsing the URL, assume it is crossDomain, + // it can be rejected by the transport if it is invalid + s.crossDomain = true; + } + } + + // Convert data if not already a string + if ( s.data && s.processData && typeof s.data !== "string" ) { + s.data = jQuery.param( s.data, s.traditional ); + } + + // Apply prefilters + inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); + + // If request was aborted inside a prefilter, stop there + if ( completed ) { + return jqXHR; + } + + // We can fire global events as of now if asked to + // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118) + fireGlobals = jQuery.event && s.global; + + // Watch for a new set of requests + if ( fireGlobals && jQuery.active++ === 0 ) { + jQuery.event.trigger( "ajaxStart" ); + } + + // Uppercase the type + s.type = s.type.toUpperCase(); + + // Determine if request has content + s.hasContent = !rnoContent.test( s.type ); + + // Save the URL in case we're toying with the If-Modified-Since + // and/or If-None-Match header later on + // Remove hash to simplify url manipulation + cacheURL = s.url.replace( rhash, "" ); + + // More options handling for requests with no content + if ( !s.hasContent ) { + + // Remember the hash so we can put it back + uncached = s.url.slice( cacheURL.length ); + + // If data is available and should be processed, append data to url + if ( s.data && ( s.processData || typeof s.data === "string" ) ) { + cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data; + + // #9682: remove data so that it's not used in an eventual retry + delete s.data; + } + + // Add or update anti-cache param if needed + if ( s.cache === false ) { + cacheURL = cacheURL.replace( rantiCache, "$1" ); + uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) + + uncached; + } + + // Put hash and anti-cache on the URL that will be requested (gh-1732) + s.url = cacheURL + uncached; + + // Change '%20' to '+' if this is encoded form body content (gh-2658) + } else if ( s.data && s.processData && + ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) { + s.data = s.data.replace( r20, "+" ); + } + + // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. + if ( s.ifModified ) { + if ( jQuery.lastModified[ cacheURL ] ) { + jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] ); + } + if ( jQuery.etag[ cacheURL ] ) { + jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] ); + } + } + + // Set the correct header, if data is being sent + if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { + jqXHR.setRequestHeader( "Content-Type", s.contentType ); + } + + // Set the Accepts header for the server, depending on the dataType + jqXHR.setRequestHeader( + "Accept", + s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ? + s.accepts[ s.dataTypes[ 0 ] ] + + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : + s.accepts[ "*" ] + ); + + // Check for headers option + for ( i in s.headers ) { + jqXHR.setRequestHeader( i, s.headers[ i ] ); + } + + // Allow custom headers/mimetypes and early abort + if ( s.beforeSend && + ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) { + + // Abort if not done already and return + return jqXHR.abort(); + } + + // Aborting is no longer a cancellation + strAbort = "abort"; + + // Install callbacks on deferreds + completeDeferred.add( s.complete ); + jqXHR.done( s.success ); + jqXHR.fail( s.error ); + + // Get transport + transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); + + // If no transport, we auto-abort + if ( !transport ) { + done( -1, "No Transport" ); + } else { + jqXHR.readyState = 1; + + // Send global event + if ( fireGlobals ) { + globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); + } + + // If request was aborted inside ajaxSend, stop there + if ( completed ) { + return jqXHR; + } + + // Timeout + if ( s.async && s.timeout > 0 ) { + timeoutTimer = window.setTimeout( function() { + jqXHR.abort( "timeout" ); + }, s.timeout ); + } + + try { + completed = false; + transport.send( requestHeaders, done ); + } catch ( e ) { + + // Rethrow post-completion exceptions + if ( completed ) { + throw e; + } + + // Propagate others as results + done( -1, e ); + } + } + + // Callback for when everything is done + function done( status, nativeStatusText, responses, headers ) { + var isSuccess, success, error, response, modified, + statusText = nativeStatusText; + + // Ignore repeat invocations + if ( completed ) { + return; + } + + completed = true; + + // Clear timeout if it exists + if ( timeoutTimer ) { + window.clearTimeout( timeoutTimer ); + } + + // Dereference transport for early garbage collection + // (no matter how long the jqXHR object will be used) + transport = undefined; + + // Cache response headers + responseHeadersString = headers || ""; + + // Set readyState + jqXHR.readyState = status > 0 ? 4 : 0; + + // Determine if successful + isSuccess = status >= 200 && status < 300 || status === 304; + + // Get response data + if ( responses ) { + response = ajaxHandleResponses( s, jqXHR, responses ); + } + + // Use a noop converter for missing script + if ( !isSuccess && jQuery.inArray( "script", s.dataTypes ) > -1 ) { + s.converters[ "text script" ] = function() {}; + } + + // Convert no matter what (that way responseXXX fields are always set) + response = ajaxConvert( s, response, jqXHR, isSuccess ); + + // If successful, handle type chaining + if ( isSuccess ) { + + // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. + if ( s.ifModified ) { + modified = jqXHR.getResponseHeader( "Last-Modified" ); + if ( modified ) { + jQuery.lastModified[ cacheURL ] = modified; + } + modified = jqXHR.getResponseHeader( "etag" ); + if ( modified ) { + jQuery.etag[ cacheURL ] = modified; + } + } + + // if no content + if ( status === 204 || s.type === "HEAD" ) { + statusText = "nocontent"; + + // if not modified + } else if ( status === 304 ) { + statusText = "notmodified"; + + // If we have data, let's convert it + } else { + statusText = response.state; + success = response.data; + error = response.error; + isSuccess = !error; + } + } else { + + // Extract error from statusText and normalize for non-aborts + error = statusText; + if ( status || !statusText ) { + statusText = "error"; + if ( status < 0 ) { + status = 0; + } + } + } + + // Set data for the fake xhr object + jqXHR.status = status; + jqXHR.statusText = ( nativeStatusText || statusText ) + ""; + + // Success/Error + if ( isSuccess ) { + deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); + } else { + deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); + } + + // Status-dependent callbacks + jqXHR.statusCode( statusCode ); + statusCode = undefined; + + if ( fireGlobals ) { + globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError", + [ jqXHR, s, isSuccess ? success : error ] ); + } + + // Complete + completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); + + if ( fireGlobals ) { + globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); + + // Handle the global AJAX counter + if ( !( --jQuery.active ) ) { + jQuery.event.trigger( "ajaxStop" ); + } + } + } + + return jqXHR; + }, + + getJSON: function( url, data, callback ) { + return jQuery.get( url, data, callback, "json" ); + }, + + getScript: function( url, callback ) { + return jQuery.get( url, undefined, callback, "script" ); + } + } ); + + jQuery.each( [ "get", "post" ], function( _i, method ) { + jQuery[ method ] = function( url, data, callback, type ) { + + // Shift arguments if data argument was omitted + if ( isFunction( data ) ) { + type = type || callback; + callback = data; + data = undefined; + } + + // The url can be an options object (which then must have .url) + return jQuery.ajax( jQuery.extend( { + url: url, + type: method, + dataType: type, + data: data, + success: callback + }, jQuery.isPlainObject( url ) && url ) ); + }; + } ); + + jQuery.ajaxPrefilter( function( s ) { + var i; + for ( i in s.headers ) { + if ( i.toLowerCase() === "content-type" ) { + s.contentType = s.headers[ i ] || ""; + } + } + } ); + + + jQuery._evalUrl = function( url, options, doc ) { + return jQuery.ajax( { + url: url, + + // Make this explicit, since user can override this through ajaxSetup (#11264) + type: "GET", + dataType: "script", + cache: true, + async: false, + global: false, + + // Only evaluate the response if it is successful (gh-4126) + // dataFilter is not invoked for failure responses, so using it instead + // of the default converter is kludgy but it works. + converters: { + "text script": function() {} + }, + dataFilter: function( response ) { + jQuery.globalEval( response, options, doc ); + } + } ); + }; + + + jQuery.fn.extend( { + wrapAll: function( html ) { + var wrap; + + if ( this[ 0 ] ) { + if ( isFunction( html ) ) { + html = html.call( this[ 0 ] ); + } + + // The elements to wrap the target around + wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); + + if ( this[ 0 ].parentNode ) { + wrap.insertBefore( this[ 0 ] ); + } + + wrap.map( function() { + var elem = this; + + while ( elem.firstElementChild ) { + elem = elem.firstElementChild; + } + + return elem; + } ).append( this ); + } + + return this; + }, + + wrapInner: function( html ) { + if ( isFunction( html ) ) { + return this.each( function( i ) { + jQuery( this ).wrapInner( html.call( this, i ) ); + } ); + } + + return this.each( function() { + var self = jQuery( this ), + contents = self.contents(); + + if ( contents.length ) { + contents.wrapAll( html ); + + } else { + self.append( html ); + } + } ); + }, + + wrap: function( html ) { + var htmlIsFunction = isFunction( html ); + + return this.each( function( i ) { + jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html ); + } ); + }, + + unwrap: function( selector ) { + this.parent( selector ).not( "body" ).each( function() { + jQuery( this ).replaceWith( this.childNodes ); + } ); + return this; + } + } ); + + + jQuery.expr.pseudos.hidden = function( elem ) { + return !jQuery.expr.pseudos.visible( elem ); + }; + jQuery.expr.pseudos.visible = function( elem ) { + return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length ); + }; + + + + + jQuery.ajaxSettings.xhr = function() { + try { + return new window.XMLHttpRequest(); + } catch ( e ) {} + }; + + var xhrSuccessStatus = { + + // File protocol always yields status code 0, assume 200 + 0: 200, + + // Support: IE <=9 only + // #1450: sometimes IE returns 1223 when it should be 204 + 1223: 204 + }, + xhrSupported = jQuery.ajaxSettings.xhr(); + + support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); + support.ajax = xhrSupported = !!xhrSupported; + + jQuery.ajaxTransport( function( options ) { + var callback, errorCallback; + + // Cross domain only allowed if supported through XMLHttpRequest + if ( support.cors || xhrSupported && !options.crossDomain ) { + return { + send: function( headers, complete ) { + var i, + xhr = options.xhr(); + + xhr.open( + options.type, + options.url, + options.async, + options.username, + options.password + ); + + // Apply custom fields if provided + if ( options.xhrFields ) { + for ( i in options.xhrFields ) { + xhr[ i ] = options.xhrFields[ i ]; + } + } + + // Override mime type if needed + if ( options.mimeType && xhr.overrideMimeType ) { + xhr.overrideMimeType( options.mimeType ); + } + + // X-Requested-With header + // For cross-domain requests, seeing as conditions for a preflight are + // akin to a jigsaw puzzle, we simply never set it to be sure. + // (it can always be set on a per-request basis or even using ajaxSetup) + // For same-domain requests, won't change header if already provided. + if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) { + headers[ "X-Requested-With" ] = "XMLHttpRequest"; + } + + // Set headers + for ( i in headers ) { + xhr.setRequestHeader( i, headers[ i ] ); + } + + // Callback + callback = function( type ) { + return function() { + if ( callback ) { + callback = errorCallback = xhr.onload = + xhr.onerror = xhr.onabort = xhr.ontimeout = + xhr.onreadystatechange = null; + + if ( type === "abort" ) { + xhr.abort(); + } else if ( type === "error" ) { + + // Support: IE <=9 only + // On a manual native abort, IE9 throws + // errors on any property access that is not readyState + if ( typeof xhr.status !== "number" ) { + complete( 0, "error" ); + } else { + complete( + + // File: protocol always yields status 0; see #8605, #14207 + xhr.status, + xhr.statusText + ); + } + } else { + complete( + xhrSuccessStatus[ xhr.status ] || xhr.status, + xhr.statusText, + + // Support: IE <=9 only + // IE9 has no XHR2 but throws on binary (trac-11426) + // For XHR2 non-text, let the caller handle it (gh-2498) + ( xhr.responseType || "text" ) !== "text" || + typeof xhr.responseText !== "string" ? + { binary: xhr.response } : + { text: xhr.responseText }, + xhr.getAllResponseHeaders() + ); + } + } + }; + }; + + // Listen to events + xhr.onload = callback(); + errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" ); + + // Support: IE 9 only + // Use onreadystatechange to replace onabort + // to handle uncaught aborts + if ( xhr.onabort !== undefined ) { + xhr.onabort = errorCallback; + } else { + xhr.onreadystatechange = function() { + + // Check readyState before timeout as it changes + if ( xhr.readyState === 4 ) { + + // Allow onerror to be called first, + // but that will not handle a native abort + // Also, save errorCallback to a variable + // as xhr.onerror cannot be accessed + window.setTimeout( function() { + if ( callback ) { + errorCallback(); + } + } ); + } + }; + } + + // Create the abort callback + callback = callback( "abort" ); + + try { + + // Do send the request (this may raise an exception) + xhr.send( options.hasContent && options.data || null ); + } catch ( e ) { + + // #14683: Only rethrow if this hasn't been notified as an error yet + if ( callback ) { + throw e; + } + } + }, + + abort: function() { + if ( callback ) { + callback(); + } + } + }; + } + } ); + + + + +// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432) + jQuery.ajaxPrefilter( function( s ) { + if ( s.crossDomain ) { + s.contents.script = false; + } + } ); + +// Install script dataType + jQuery.ajaxSetup( { + accepts: { + script: "text/javascript, application/javascript, " + + "application/ecmascript, application/x-ecmascript" + }, + contents: { + script: /\b(?:java|ecma)script\b/ + }, + converters: { + "text script": function( text ) { + jQuery.globalEval( text ); + return text; + } + } + } ); + +// Handle cache's special case and crossDomain + jQuery.ajaxPrefilter( "script", function( s ) { + if ( s.cache === undefined ) { + s.cache = false; + } + if ( s.crossDomain ) { + s.type = "GET"; + } + } ); + +// Bind script tag hack transport + jQuery.ajaxTransport( "script", function( s ) { + + // This transport only deals with cross domain or forced-by-attrs requests + if ( s.crossDomain || s.scriptAttrs ) { + var script, callback; + return { + send: function( _, complete ) { + script = jQuery( "