diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..23d9c36a --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +16.13.2 diff --git a/API/Backend/Config/models/config.js b/API/Backend/Config/models/config.js index a516407e..75e9a36f 100644 --- a/API/Backend/Config/models/config.js +++ b/API/Backend/Config/models/config.js @@ -11,22 +11,22 @@ var Config = sequelize.define( mission: { type: Sequelize.STRING, unique: false, - allowNull: false + allowNull: false, }, config: { type: Sequelize.JSON, allowNull: true, - defaultValue: {} + defaultValue: {}, }, version: { type: Sequelize.DataTypes.INTEGER, unique: false, - allowNull: false - } + allowNull: false, + }, }, { timestamps: true, - updatedAt: false + updatedAt: false, } ); diff --git a/API/Backend/Config/routes/configs.js b/API/Backend/Config/routes/configs.js index b7388d7b..5b3ea1da 100644 --- a/API/Backend/Config/routes/configs.js +++ b/API/Backend/Config/routes/configs.js @@ -6,16 +6,19 @@ require("dotenv").config(); const express = require("express"); const router = express.Router(); const execFile = require("child_process").execFile; +const Sequelize = require("sequelize"); +const { sequelize } = require("../../../connection"); const logger = require("../../../logger"); const Config = require("../models/config"); const config_template = require("../../../templates/config_template"); const validate = require("../validate"); +const populateUUIDs = require("../uuids"); const Utils = require("../../../utils.js"); const websocket = require("../../../websocket.js"); -const WebSocket = require('isomorphic-ws'); +const WebSocket = require("isomorphic-ws"); const fs = require("fs"); const deepmerge = require("deepmerge"); @@ -250,6 +253,13 @@ function upsert(req, res, next, cb, info) { let hasVersion = false; req.body = req.body || {}; + info = info || { + type: "upsert", + }; + info.route = "config"; + info.id = req.body.id; + info.mission = req.body.mission; + if (req.body.version != null) hasVersion = true; let versionConfig = null; @@ -294,6 +304,32 @@ function upsert(req, res, next, cb, info) { } } else configJSON = req.body.config; } + + const { newlyAddedUUIDs, allNewUUIDs } = populateUUIDs(configJSON); + + // Do not update the config if there are duplicate or bad UUIDs + const badUUIDs = newlyAddedUUIDs + .filter((i) => { + return "replacesBadUUID" in i; + }) + .map((i) => i.replacesBadUUID); + + if (badUUIDs.length > 0) { + if (cb) + cb({ + status: "failure", + message: "There are duplicate or bad UUIDs.", + badUUIDs, + }); + else + res.send({ + status: "failure", + message: "There are duplicate or bad UUIDs.", + badUUIDs, + }); + return; + } + const validation = validate(configJSON); if (!validation.valid) { @@ -332,20 +368,53 @@ function upsert(req, res, next, cb, info) { status: "success", mission: created.mission, version: created.version, + newlyAddedUUIDs: newlyAddedUUIDs, }); else res.send({ status: "success", mission: created.mission, version: created.version, + newlyAddedUUIDs: newlyAddedUUIDs, }); - openWebSocket(req.body, { - status: "success", - mission: created.mission, - version: created.version, - }, info, - forceClientUpdate - ); + + if (info && info.layerName) { + // Find the layer UUID instead of passing back the layer's display name + let isArray = true; + let infoLayerNames = info.layerName; + if (!Array.isArray(info.layerName)) { + infoLayerNames = []; + infoLayerNames.push(info.layerName); + isArray = false; + } + + for (let i in infoLayerNames) { + const found = allNewUUIDs.findIndex( + (x) => x.name == infoLayerNames[i] + ); + if (found > -1) { + const result = allNewUUIDs[found]; + infoLayerNames[i] = result.uuid; + allNewUUIDs.splice(found, 1); + } + } + + if (!isArray) { + info.layerName = infoLayerNames[0]; + } + } + + openWebSocket( + req.body, + { + status: "success", + mission: created.mission, + version: created.version, + newlyAddedUUIDs: newlyAddedUUIDs, + }, + info, + forceClientUpdate + ); return null; }) .catch((err) => { @@ -382,20 +451,36 @@ if (fullAccess) }); router.get("/missions", function (req, res, next) { - Config.aggregate("mission", "DISTINCT", { plain: false }) - .then((missions) => { - let allMissions = []; - for (let i = 0; i < missions.length; i++) - allMissions.push(missions[i].DISTINCT); - allMissions.sort(); - res.send({ status: "success", missions: allMissions }); - return null; - }) - .catch((err) => { - logger("error", "Failed to find missions.", req.originalUrl, req, err); - res.send({ status: "failure", message: "Failed to find missions." }); - return null; - }); + if (req.query.full === "true") { + sequelize + .query( + "SELECT DISTINCT ON (mission) mission, version, config FROM configs ORDER BY mission ASC" + ) + .spread((results) => { + res.send({ status: "success", missions: results }); + return null; + }) + .catch((err) => { + logger("error", "Failed to find missions.", req.originalUrl, req, err); + res.send({ status: "failure", message: "Failed to find missions." }); + return null; + }); + } else { + Config.aggregate("mission", "DISTINCT", { plain: false }) + .then((missions) => { + let allMissions = []; + for (let i = 0; i < missions.length; i++) + allMissions.push(missions[i].DISTINCT); + allMissions.sort(); + res.send({ status: "success", missions: allMissions }); + return null; + }) + .catch((err) => { + logger("error", "Failed to find missions.", req.originalUrl, req, err); + res.send({ status: "failure", message: "Failed to find missions." }); + return null; + }); + } return null; }); @@ -577,12 +662,15 @@ if (fullAccess) function openWebSocket(body, response, info, forceClientUpdate) { if ( !process.env.hasOwnProperty("ENABLE_MMGIS_WEBSOCKETS") || - process.env.ENABLE_MMGIS_WEBSOCKETS != "true") { - return + process.env.ENABLE_MMGIS_WEBSOCKETS != "true" + ) { + return; } const port = parseInt(process.env.PORT || "8888", 10); - const path = `ws://localhost:${port}/` + const path = `ws://localhost:${port}${ + process.env.WEBSOCKET_ROOT_PATH || process.env.ROOT_PATH || "" + }/`; const ws = new WebSocket(path); ws.onopen = function () { const data = { @@ -591,7 +679,7 @@ function openWebSocket(body, response, info, forceClientUpdate) { forceClientUpdate, }; ws.send(JSON.stringify(data)); - } + }; } // === Quick API Functions === @@ -599,7 +687,7 @@ function addLayer(req, res, next, cb, forceConfig, caller = "addLayer") { const exampleBody = { mission: "{mission_name}", layer: { - name: "{new_unique_layer_name}", + name: "{new_layer_name}", type: "header || vector || vectortile || query || model || tile || data", "more...": "...", }, @@ -683,18 +771,55 @@ function addLayer(req, res, next, cb, forceConfig, caller = "addLayer") { ); } - const didSet = Utils.setIn( - config.layers, - `${placementPath}${placementIndex}`, - req.body.layer, - true, - true - ); + let didSet = false; + + // Input can be object or array + if (Array.isArray(req.body.layer)) { + for (let i in req.body.layer) { + // This adds the proposed_uuid key to all of the new layers/sublayers to be added that have + // user defined UUIDs. We remove the proposed_uuid key after using it to check for unique UUIDs. + Utils.traverseLayers([req.body.layer[i]], (layer) => { + if (layer.uuid != null) { + layer.proposed_uuid = layer.uuid; + } + }); + + didSet = Utils.setIn( + config.layers, + `${placementPath}${placementIndex}`, + req.body.layer[i], + true, + true + ); + + placementIndex += 1; + } + } else { + // This adds the proposed_uuid key to all of the new layers/sublayers to be added that have + // user defined UUIDs. We remove the proposed_uuid key after using it to check for unique UUIDs. + Utils.traverseLayers([req.body.layer], (layer) => { + if (layer.uuid != null) { + layer.proposed_uuid = layer.uuid; + } + }); + + didSet = Utils.setIn( + config.layers, + `${placementPath}${placementIndex}`, + req.body.layer, + true, + true + ); + } if (didSet) { upsert( { - body: { mission: req.body.mission, config: config, forceClientUpdate: req.body.forceClientUpdate }, + body: { + mission: req.body.mission, + config: config, + forceClientUpdate: req.body.forceClientUpdate, + }, }, null, null, @@ -706,6 +831,7 @@ function addLayer(req, res, next, cb, forceConfig, caller = "addLayer") { message: `Added layer to the ${response.mission} mission. Configuration versioned ${response.version}.`, mission: response.mission, version: response.version, + newlyAddedUUIDs: response.newlyAddedUUIDs, }); } else { res.send({ @@ -713,6 +839,7 @@ function addLayer(req, res, next, cb, forceConfig, caller = "addLayer") { message: `Added layer to the ${response.mission} mission. Configuration versioned ${response.version}.`, mission: response.mission, version: response.version, + newlyAddedUUIDs: response.newlyAddedUUIDs, }); } } else { @@ -721,7 +848,9 @@ function addLayer(req, res, next, cb, forceConfig, caller = "addLayer") { }, { type: caller, - layerName: req.body.layer.name, + layerName: Array.isArray(req.body.layer) + ? req.body.layer.map((i) => i.name) + : req.body.layer.name, } ); } else if (cb) @@ -764,7 +893,7 @@ if (fullAccess) router.post("/updateLayer", function (req, res, next) { const exampleBody = { mission: "{mission_name}", - layerName: "{existing_layer_name}", + layerUUID: "{existing_layer_uuid}", layer: { "...": "...", }, @@ -785,10 +914,10 @@ if (fullAccess) }); return; } - if (req.body.layerName == null) { + if (req.body.layerUUID == null) { res.send({ status: "failure", - message: `Required parameter 'layerName' is unset. (a layer.name is not sufficient)`, + message: `Required parameter 'layerUUID' is unset. (a layer.uuid is not sufficient)`, example: exampleBody, }); return; @@ -821,7 +950,7 @@ if (fullAccess) let placementIndex = req.body.placement?.index; Utils.traverseLayers(config.layers, (layer, path, index) => { - if (layer.name === req.body.layerName) { + if (layer.uuid === req.body.layerUUID) { existingLayer = JSON.parse(JSON.stringify(layer)); if (placementPath == null) placementPath = path; if (placementIndex == null) placementIndex = index; @@ -832,7 +961,7 @@ if (fullAccess) if (existingLayer == null) { res.send({ status: "failure", - message: `Layer ${req.body.layerName} not found. Cannot update.`, + message: `Layer ${req.body.layerUUID} not found. Cannot update.`, }); return; } @@ -862,7 +991,7 @@ if (fullAccess) if (resp.status === "success") { res.send({ status: "success", - message: `Updated layer '${req.body.layerName}' in the ${resp.mission} mission. Configuration versioned ${resp.version}.`, + message: `Updated layer '${req.body.layerUUID}' in the ${resp.mission} mission. Configuration versioned ${resp.version}.`, }); } else { resp.message = `Update layer failed with: ${resp.message}`; @@ -876,14 +1005,14 @@ if (fullAccess) } catch (err) { logger( "error", - `Failed to update layer: ${req.body.layerName}.`, + `Failed to update layer: ${req.body.layerUUID}.`, req.originalUrl, req, err ); res.send({ status: "failure", - message: `Failed to update layer: ${req.body.layerName}. Uncaught reason.`, + message: `Failed to update layer: ${req.body.layerUUID}. Uncaught reason.`, }); } } @@ -894,7 +1023,7 @@ if (fullAccess) function removeLayer(req, res, next, cb) { const exampleBody = { mission: "{mission_name}", - layerName: "{existing_layer_name}", + layerUUID: "{existing_layer_uuid}", "forceClientUpdate?": "{true}; default false", }; @@ -906,10 +1035,10 @@ function removeLayer(req, res, next, cb) { }); return; } - if (req.body.layerName == null) { + if (req.body.layerUUID == null) { res.send({ status: "failure", - message: `Required parameter 'layerName' is unset.`, + message: `Required parameter 'layerUUID' is unset.`, example: exampleBody, }); return; @@ -928,14 +1057,29 @@ function removeLayer(req, res, next, cb) { res.send(config); } else { try { + let layerUUIDs = []; + + // Input can be object or array + if (!Array.isArray(req.body.layerUUID)) { + layerUUIDs.push(req.body.layerUUID); + } else { + layerUUIDs = [...req.body.layerUUID]; + } + let didRemove = false; - Utils.traverseLayers(config.layers, (layer, path, index) => { - if (layer.name === req.body.layerName) { - didRemove = true; - return "remove"; + const removedUUIDs = Utils.traverseLayers( + config.layers, + (layer, path, index) => { + if (layerUUIDs.includes(layer.uuid)) { + didRemove = true; + return "remove"; + } } - }); + ); + const unableToRemoveUUIDs = layerUUIDs.filter( + (i) => !removedUUIDs.map((x) => x.uuid).includes(i) + ); if (didRemove) { upsert( { @@ -951,24 +1095,36 @@ function removeLayer(req, res, next, cb) { if (resp.status === "success") { res.send({ status: "success", - message: `Successfully removed layer '${req.body.layerName}'.`, + message: `Successfully removed layer${ + removedUUIDs.length >= 1 ? "s" : "" + }. Configuration versioned ${resp.version}.`, + removedUUIDs: removedUUIDs, + unableToRemoveUUIDs: unableToRemoveUUIDs, }); } else { res.send({ status: "failure", - message: `Failed to remove layer '${req.body.layerName}': ${resp.message}`, + message: `Failed to remove layer${ + layerUUIDs.length >= 1 ? "s" : "" + }: ${resp.message}.`, + unableToRemoveUUIDs: layerUUIDs, }); } }, { - type: 'removeLayer', - layerName: req.body.layerName, + type: "removeLayer", + layerName: layerUUIDs.filter((i) => + removedUUIDs.map((x) => x.uuid).includes(i) + ), } ); } else { res.send({ status: "failure", - message: `Failed to remove layer '${req.body.layerName}'. Layer not found.`, + message: `Failed to remove layer${ + layerUUIDs.length >= 1 ? "s" : "" + }. Layer${layerUUIDs.length >= 1 ? "s" : ""} not found.`, + unableToRemoveUUIDs: layerUUIDs, }); } } catch (err) {} @@ -981,7 +1137,7 @@ if (fullAccess) * /removeLayer * body: { "mission": "", - "layerName": "" + "layerUUID": "" "forceClientUpdate?": true } */ diff --git a/API/Backend/Config/setup.js b/API/Backend/Config/setup.js index cc71f7a0..ebff217d 100644 --- a/API/Backend/Config/setup.js +++ b/API/Backend/Config/setup.js @@ -9,7 +9,7 @@ let setup = { process.env.HIDE_CONFIG != "true" ) { s.app.get( - "/configure", + s.ROOT_PATH + "/configure", s.ensureGroup(s.permissions.users), s.ensureAdmin(true), (req, res) => { @@ -18,13 +18,24 @@ let setup = { user: user, AUTH: process.env.AUTH, NODE_ENV: process.env.NODE_ENV, + PORT: process.env.PORT || "8888", + ENABLE_CONFIG_WEBSOCKETS: process.env.ENABLE_CONFIG_WEBSOCKETS, + ENABLE_CONFIG_OVERRIDE: process.env.ENABLE_CONFIG_OVERRIDE, + ROOT_PATH: + process.env.NODE_ENV === "development" + ? "" + : process.env.ROOT_PATH || "", + WEBSOCKET_ROOT_PATH: + process.env.NODE_ENV === "development" + ? "" + : process.env.WEBSOCKET_ROOT_PATH || "", }); } ); } s.app.use( - "/API/configure", + s.ROOT_PATH + "/API/configure", s.ensureAdmin(), s.checkHeadersCodeInjection, s.setContentType, diff --git a/API/Backend/Config/uuids.js b/API/Backend/Config/uuids.js new file mode 100644 index 00000000..0d761abf --- /dev/null +++ b/API/Backend/Config/uuids.js @@ -0,0 +1,61 @@ +const Utils = require("../../utils.js"); + +const { v4: uuidv4, validate: uuidValidate } = require("uuid"); + +const populateUUIDs = (config) => { + const newlyAddedUUIDs = []; + const definedUUIDs = []; + const allNewUUIDs = []; + + // Track of all of the previously defined UUIDs (i.e. ignore the UUIDs of the newly added layers) + Utils.traverseLayers(config.layers, (layer) => { + if (layer.uuid != null && !layer.proposed_uuid) { + definedUUIDs.push(layer.uuid); + } + }); + + Utils.traverseLayers(config.layers, (layer) => { + if (layer.uuid == null) { + layer.uuid = uuidv4(); + newlyAddedUUIDs.push({ + name: layer.name, + uuid: layer.uuid, + }); + allNewUUIDs.push({ + name: layer.name, + uuid: layer.uuid, + }); + } else if ( + !uuidValidate(layer.uuid) || + definedUUIDs.includes(layer.proposed_uuid) + ) { + const badUUID = layer.uuid; + layer.uuid = uuidv4(); + newlyAddedUUIDs.push({ + name: layer.name, + uuid: layer.uuid, + replacesBadUUID: badUUID, + }); + allNewUUIDs.push({ + name: layer.name, + uuid: layer.uuid, + }); + } else { + if (!definedUUIDs.includes(layer.uuid)) { + definedUUIDs.push(layer.uuid); + allNewUUIDs.push({ + name: layer.name, + uuid: layer.uuid, + }); + } + } + + if (layer.proposed_uuid) { + delete layer.proposed_uuid; + } + }); + + return { newlyAddedUUIDs, allNewUUIDs }; +}; + +module.exports = populateUUIDs; diff --git a/API/Backend/Config/validate.js b/API/Backend/Config/validate.js index 5df39c36..d1d11ffd 100644 --- a/API/Backend/Config/validate.js +++ b/API/Backend/Config/validate.js @@ -39,6 +39,7 @@ const validateStructure = (config) => { const validateLayers = (config) => { let errs = []; + let existingUUIDs = []; Utils.traverseLayers(config.layers, (layer) => { // Check layer name const validNameErrs = isValidLayerName(layer.name); @@ -90,10 +91,17 @@ const validateLayers = (config) => { err(`Unknown layer type: '${layer.type}'`, ["layers[layer].type"]) ); } - }); - errs = errs.concat(hasDuplicateLayerNames(config)); - errs = errs.concat(hasNonHeaderWithSublayers(config)); + if (layer.uuid != null) { + if (existingUUIDs.includes(layer.uuid)) { + errs = errs.concat([ + err( + `Found a layer with duplicate uuid: ${layer.name} - ${layer.uuid}` + ), + ]); + } else existingUUIDs.push(layer.uuid); + } + }); return errs; }; @@ -291,34 +299,6 @@ const hasNonHeaderWithSublayers = (config) => { return errs; }; -const hasDuplicateLayerNames = (config) => { - let allNames = []; - - depthTraversal(config.layers, 0); - - function depthTraversal(node, depth) { - for (var i = 0; i < node.length; i++) { - allNames.push(node[i].name); - //Add other feature information while we're at it - if (node[i].sublayers != null && node[i].sublayers.length > 0) { - depthTraversal(node[i].sublayers, depth + 1); - } - } - } - - let unique = []; - const errs = []; - allNames.forEach((name) => { - if (!unique.includes(name)) unique.push(name); - else - errs.push( - err(`Found duplicate layer name: '${name}'`, ["layers[layer].name"]) - ); - }); - - return errs; -}; - const fillInMissingFieldsWithDefaults = (layer) => { if (layer.type != "header") { layer.initialOpacity = diff --git a/API/Backend/Datasets/models/datasets.js b/API/Backend/Datasets/models/datasets.js index d7ad863a..4ee65c89 100644 --- a/API/Backend/Datasets/models/datasets.js +++ b/API/Backend/Datasets/models/datasets.js @@ -9,17 +9,17 @@ const attributes = { name: { type: Sequelize.STRING, unique: true, - allowNull: false + allowNull: false, }, table: { type: Sequelize.STRING, unique: true, - allowNull: false - } + allowNull: false, + }, }; const options = { - timestamps: true + timestamps: true, }; // setup User model and its fields. @@ -30,20 +30,20 @@ function makeNewDatasetTable(name, columns, success, failure) { let attributes = {}; - columns.forEach(element => { + columns.forEach((element) => { attributes[element] = { type: Sequelize.STRING, unique: false, - allowNull: true + allowNull: true, }; }); const options = { - timestamps: false + timestamps: false, }; Datasets.findOne({ where: { name: name } }) - .then(result => { + .then((result) => { if (result) { let DatasetTable = sequelize.define( result.dataValues.table, @@ -54,16 +54,16 @@ function makeNewDatasetTable(name, columns, success, failure) { { updatedAt: new Date().toISOString() }, { where: { name: name }, silent: true } ) - .then(r => { + .then((r) => { success({ name: result.dataValues.name, table: result.dataValues.table, - tableObj: DatasetTable + tableObj: DatasetTable, }); return null; }) - .catch(err => { + .catch((err) => { logger( "error", "Failed to update datasets.", @@ -73,19 +73,19 @@ function makeNewDatasetTable(name, columns, success, failure) { ); failure({ status: "failure", - message: "Failed to update datasets" + message: "Failed to update datasets", }); }); } else { sequelize .query("SELECT COUNT(*) FROM datasets") - .spread(results => { + .spread((results) => { let newTable = "d" + (parseInt(results[0].count) + 1) + "_datasets"; Datasets.create({ name: name, - table: newTable + table: newTable, }) - .then(created => { + .then((created) => { let DatasetTable = sequelize.define( newTable, attributes, @@ -97,11 +97,11 @@ function makeNewDatasetTable(name, columns, success, failure) { success({ name: name, table: newTable, - tableObj: DatasetTable + tableObj: DatasetTable, }); return null; }) - .catch(err => { + .catch((err) => { logger( "error", "Failed to sync dataset table.", @@ -111,13 +111,13 @@ function makeNewDatasetTable(name, columns, success, failure) { ); failure({ status: "failure", - message: "Failed to sync" + message: "Failed to sync", }); }); return null; }) - .catch(err => { + .catch((err) => { logger( "error", "Failed to create dataset table.", @@ -127,12 +127,12 @@ function makeNewDatasetTable(name, columns, success, failure) { ); failure({ status: "failure", - message: "Failed to create" + message: "Failed to create", }); }); return null; }) - .catch(err => { + .catch((err) => { logger( "error", "Failed to count existing datasets.", @@ -142,14 +142,14 @@ function makeNewDatasetTable(name, columns, success, failure) { ); failure({ status: "failure", - message: "Failed to count existing datasets" + message: "Failed to count existing datasets", }); }); } return null; }) - .catch(err => { + .catch((err) => { logger( "error", "Failed to find existing datasets.", @@ -161,7 +161,7 @@ function makeNewDatasetTable(name, columns, success, failure) { status: "failure", message: "Failed to find existing datasets", error: error, - name: name + name: name, }); }); } @@ -169,5 +169,5 @@ function makeNewDatasetTable(name, columns, success, failure) { // export User model for use in other files. module.exports = { Datasets: Datasets, - makeNewDatasetTable: makeNewDatasetTable + makeNewDatasetTable: makeNewDatasetTable, }; diff --git a/API/Backend/Datasets/routes/datasets.js b/API/Backend/Datasets/routes/datasets.js index 46490473..12e56f86 100644 --- a/API/Backend/Datasets/routes/datasets.js +++ b/API/Backend/Datasets/routes/datasets.js @@ -17,7 +17,7 @@ const Datasets = datasets.Datasets; const makeNewDatasetTable = datasets.makeNewDatasetTable; //Returns dataset rows based on search -router.post("/get", function(req, res, next) { +router.post("/get", function (req, res, next) { get(req, res, next); }); function get(req, res, next) { @@ -30,13 +30,13 @@ function get(req, res, next) { if (i >= queries.length) { res.send({ status: "success", - body: results + body: results, }); return; } //First Find the table name Datasets.findOne({ where: { name: queries[i].dataset } }) - .then(result => { + .then((result) => { if (result) { const column = queries[i].column .replace(/[`~!@#$%^&*|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "") @@ -50,20 +50,20 @@ function get(req, res, next) { '"=:search ORDER BY id ASC LIMIT 100', { replacements: { - search: queries[i].search - } + search: queries[i].search, + }, } ) - .spread(r => { + .spread((r) => { results.push({ ...queries[i], table: result.dataValues.table, - results: r + results: r, }); loopedGet(i + 1); return null; }) - .catch(err => { + .catch((err) => { loopedGet(i + 1); return null; }); @@ -72,7 +72,7 @@ function get(req, res, next) { } return null; }) - .catch(err => { + .catch((err) => { loopedGet(i + 1); return null; }); @@ -80,9 +80,9 @@ function get(req, res, next) { } //Returns a list of entries in the datasets table -router.post("/entries", function(req, res, next) { +router.post("/entries", function (req, res, next) { Datasets.findAll() - .then(sets => { + .then((sets) => { if (sets && sets.length > 0) { let entries = []; for (let i = 0; i < sets.length; i++) { @@ -90,18 +90,18 @@ router.post("/entries", function(req, res, next) { } res.send({ status: "success", - body: { entries: entries } + body: { entries: entries }, }); } else { res.send({ - status: "failure" + status: "failure", }); } }) - .catch(err => { + .catch((err) => { logger("error", "Failure finding datasets.", req.originalUrl, req, err); res.send({ - status: "failure" + status: "failure", }); }); }); @@ -111,10 +111,10 @@ router.post("/entries", function(req, res, next) { * req.body.key * req.body.value */ -router.post("/search", function(req, res, next) { +router.post("/search", function (req, res, next) { //First Find the table name Datasets.findOne({ where: { name: req.body.layer } }) - .then(result => { + .then((result) => { if (result) { let table = result.dataValues.table; @@ -126,11 +126,11 @@ router.post("/search", function(req, res, next) { { replacements: { key: req.body.key, - value: req.body.value.replace(/[`;'"]/gi, "") - } + value: req.body.value.replace(/[`;'"]/gi, ""), + }, } ) - .spread(results => { + .spread((results) => { let r = []; for (let i = 0; i < results.length; i++) { let feature = JSON.parse(results[i].st_asgeojson); @@ -140,12 +140,12 @@ router.post("/search", function(req, res, next) { res.send({ status: "success", - body: r + body: r, }); return null; }) - .catch(err => { + .catch((err) => { logger( "error", "SQL error search through dataset.", @@ -155,34 +155,34 @@ router.post("/search", function(req, res, next) { ); res.send({ status: "failure", - message: "SQL error." + message: "SQL error.", }); }); } else { res.send({ status: "failure", - message: "Layer not found." + message: "Layer not found.", }); } return null; }) - .catch(err => { + .catch((err) => { logger("error", "Failure finding dataset.", req.originalUrl, req, err); res.send({ - status: "failure" + status: "failure", }); }); }); -router.post("/upload", function(req, res, next) { +router.post("/upload", function (req, res, next) { // Disable timeout req.setTimeout(0); let fields = { name: null, header: null, - upsert: null + upsert: null, }; let tableName = null; @@ -196,26 +196,33 @@ router.post("/upload", function(req, res, next) { let uploaded = ""; let uploadFinished = false; const busboy = new Busboy({ headers: req.headers }); - busboy.on("file", function(fieldname, file, filename, encoding, mimetype) { - file.on("data", function(data) { + busboy.on("file", function (fieldname, file, filename, encoding, mimetype) { + file.on("data", function (data) { uploaded += data.toString("utf8"); populateNext(); }); - file.on("end", function() {}); + file.on("end", function () {}); }); - busboy.on("field", function( - fieldname, - val, - fieldnameTruncated, - valTruncated, - encoding, - mimetype - ) { - fields[fieldname] = val; - if (fields.name != null && fields.header != null && fields.upsert != null) - begin(); - }); - busboy.on("finish", function() { + busboy.on( + "field", + function ( + fieldname, + val, + fieldnameTruncated, + valTruncated, + encoding, + mimetype + ) { + fields[fieldname] = val; + if ( + fields.name != null && + fields.header != null && + fields.upsert != null + ) + begin(); + } + ); + busboy.on("finish", function () { uploadFinished = true; populateInterval = setInterval(populateNext, 100); }); @@ -231,7 +238,7 @@ router.post("/upload", function(req, res, next) { clearInterval(populateInterval); if (fields.upsert === "true") { let condition = ""; - fields.header.forEach(elm => { + fields.header.forEach((elm) => { elm = elm.replace(/[`~!@#$%^&*|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, ""); condition += ' AND ( a."' + @@ -264,11 +271,11 @@ router.post("/upload", function(req, res, next) { " out of " + totalPopulates + " chunks successfully uploaded. Data has been upserted too.", - body: {} + body: {}, }); res.end(); }) - .catch(err => { + .catch((err) => { logger( "error", "Upload but failed to remove duplicated rows.", @@ -278,7 +285,7 @@ router.post("/upload", function(req, res, next) { ); res.send({ status: "failed", - message: "Upload but failed to remove duplicated rows." + message: "Upload but failed to remove duplicated rows.", }); }); } else { @@ -290,7 +297,7 @@ router.post("/upload", function(req, res, next) { " out of " + totalPopulates + " chunks successfully uploaded", - body: {} + body: {}, }); res.end(); } @@ -313,7 +320,7 @@ router.post("/upload", function(req, res, next) { csv.push(r); } totalPopulates++; - populateDatasetTable(tableObj, csv, function(success) { + populateDatasetTable(tableObj, csv, function (success) { working = false; if (success) successfulPopulates++; }); @@ -328,18 +335,18 @@ router.post("/upload", function(req, res, next) { } catch (err) { res.send({ status: "failed", - message: "The field 'header' is not valid json array." + message: "The field 'header' is not valid json array.", }); res.end(); return; } - makeNewDatasetTable(fields.name, fields.header, function(result) { + makeNewDatasetTable(fields.name, fields.header, function (result) { let checkEnding = result.table.split("_"); if (checkEnding[checkEnding.length - 1] !== "datasets") { logger("error", "Malformed table name.", req.originalUrl, req); res.send({ status: "failed", - message: "Malformed table name" + message: "Malformed table name", }); return; } @@ -354,7 +361,7 @@ router.post("/upload", function(req, res, next) { .then(() => { tableObj = result.tableObj; }) - .catch(err => { + .catch((err) => { logger("error", "Recreation error.", req.originalUrl, req, err); res.send(result); }); @@ -364,12 +371,12 @@ router.post("/upload", function(req, res, next) { function populateDatasetTable(Table, csv, cb) { Table.bulkCreate(csv, { - returning: true + returning: true, }) - .then(function(response) { + .then(function (response) { cb(true); }) - .catch(function(err) { + .catch(function (err) { logger( "error", "Datasets: Failed to populate a dataset table!", @@ -383,20 +390,20 @@ router.post("/upload", function(req, res, next) { } }); -router.post("/recreate", function(req, res, next) { +router.post("/recreate", function (req, res, next) { // Disable timeout req.setTimeout(0); makeNewDatasetTable( req.body.name || req.fields.name, req.body.header || JSON.parse(req.fields.header), - function(result) { + function (result) { let checkEnding = result.table.split("_"); if (checkEnding[checkEnding.length - 1] !== "datasets") { logger("error", "Malformed table name.", req.originalUrl, req); res.send({ status: "failed", - message: "Malformed table name" + message: "Malformed table name", }); return; } @@ -408,18 +415,18 @@ router.post("/recreate", function(req, res, next) { populateDatasetTable( result.tableObj, JSON.parse(req.body.csv), - function(success) { + function (success) { res.send({ status: success == true ? "success" : "failure", message: "", - body: {} + body: {}, }); } ); return null; }) - .catch(err => { + .catch((err) => { logger("error", "Recreation error.", req.originalUrl, req, err); res.send(result); }); @@ -427,29 +434,29 @@ router.post("/recreate", function(req, res, next) { populateDatasetTable( result.tableObj, JSON.parse(req.body.csv), - function(success) { + function (success) { res.send({ status: success == true ? "success" : "failure", message: "", - body: {} + body: {}, }); } ); } }, - function(result) { + function (result) { res.send(result); } ); function populateDatasetTable(Table, csv, cb) { Table.bulkCreate(csv, { - returning: true + returning: true, }) - .then(function(response) { + .then(function (response) { cb(true); }) - .catch(function(err) { + .catch(function (err) { logger( "error", "Datasets: Failed to populate a dataset table!", diff --git a/API/Backend/Datasets/setup.js b/API/Backend/Datasets/setup.js index ef6a8b97..71d506d8 100644 --- a/API/Backend/Datasets/setup.js +++ b/API/Backend/Datasets/setup.js @@ -1,9 +1,9 @@ const router = require("./routes/datasets"); let setup = { //Once the app initializes - onceInit: s => { + onceInit: (s) => { s.app.use( - "/API/datasets", + s.ROOT_PATH + "/API/datasets", s.ensureAdmin(), s.checkHeadersCodeInjection, s.setContentType, @@ -11,9 +11,9 @@ let setup = { ); }, //Once the server starts - onceStarted: s => {}, + onceStarted: (s) => {}, //Once all tables sync - onceSynced: s => {} + onceSynced: (s) => {}, }; module.exports = setup; diff --git a/API/Backend/Draw/models/filehistories.js b/API/Backend/Draw/models/filehistories.js index dc5a01cb..034d20b2 100644 --- a/API/Backend/Draw/models/filehistories.js +++ b/API/Backend/Draw/models/filehistories.js @@ -25,28 +25,33 @@ require("dotenv").config(); const attributes = { file_id: { type: Sequelize.INTEGER, - allowNull: false + allowNull: false, }, history_id: { type: Sequelize.INTEGER, - allowNull: false + allowNull: false, }, time: { type: Sequelize.BIGINT, - allowNull: false + allowNull: false, }, action_index: { type: Sequelize.INTEGER, - allowNull: false + allowNull: false, }, history: { type: Sequelize.DataTypes.ARRAY(Sequelize.DataTypes.INTEGER), - allowNull: true - } + allowNull: true, + }, + author: { + type: Sequelize.STRING, + unique: false, + allowNull: true, + }, }; const options = { - timestamps: false + timestamps: false, }; // setup Filehistories model and its fields. @@ -57,5 +62,27 @@ var FilehistoriesTEST = sequelize.define( options ); +// Adds to the table, never removes +const up = async () => { + // author column + await sequelize + .query( + `ALTER TABLE file_histories ADD COLUMN IF NOT EXISTS author varchar(255) NULL;` + ) + .then(() => { + return null; + }) + .catch((err) => { + logger( + "error", + `Failed to adding file_histories.author column. DB tables may be out of sync!`, + "file_histories", + null, + err + ); + return null; + }); +}; + // export Filehistories model for use in other files. -module.exports = { Filehistories, FilehistoriesTEST }; +module.exports = { Filehistories, FilehistoriesTEST, up }; diff --git a/API/Backend/Draw/models/publishedstore.js b/API/Backend/Draw/models/publishedstore.js index 60d4a8d1..4a178577 100644 --- a/API/Backend/Draw/models/publishedstore.js +++ b/API/Backend/Draw/models/publishedstore.js @@ -11,21 +11,21 @@ var PublishedStore = sequelize.define( name: { type: Sequelize.STRING, unique: false, - allowNull: false + allowNull: false, }, value: { type: Sequelize.TEXT, allowNull: true, - defaultValue: "" + defaultValue: "", }, time: { type: Sequelize.BIGINT, - allowNull: false - } + allowNull: false, + }, }, { timestamps: false, - updatedAt: false + updatedAt: false, } ); diff --git a/API/Backend/Draw/models/userfeatures.js b/API/Backend/Draw/models/userfeatures.js index 5580c021..2bdf49dd 100644 --- a/API/Backend/Draw/models/userfeatures.js +++ b/API/Backend/Draw/models/userfeatures.js @@ -25,12 +25,12 @@ require("dotenv").config(); const attributes = { file_id: { type: Sequelize.INTEGER, - allowNull: false + allowNull: false, }, level: { type: Sequelize.INTEGER, unique: false, - allowNull: false + allowNull: false, }, intent: { type: Sequelize.ENUM, @@ -44,24 +44,24 @@ const attributes = { "line", "point", "text", - "arrow" + "arrow", ], allowNull: true, - defaultValue: null + defaultValue: null, }, properties: { type: Sequelize.JSON, allowNull: true, - defaultValue: {} + defaultValue: {}, }, geom: { type: Sequelize.GEOMETRY, - allowNull: true - } + allowNull: true, + }, }; const options = { - timestamps: false + timestamps: false, }; var Userfeatures = sequelize.define("user_features", attributes, options); diff --git a/API/Backend/Draw/models/userfiles.js b/API/Backend/Draw/models/userfiles.js index c562c88e..f701f743 100644 --- a/API/Backend/Draw/models/userfiles.js +++ b/API/Backend/Draw/models/userfiles.js @@ -79,6 +79,21 @@ const attributes = { defaultValue: "0", unique: false, }, + template: { + type: Sequelize.JSON, + allowNull: true, + defaultValue: null, + }, + publicity_type: { + type: Sequelize.STRING, + unique: false, + allowNull: true, + }, + public_editors: { + type: Sequelize.ARRAY(Sequelize.TEXT), + unique: false, + allowNull: true, + }, }; const options = { @@ -128,5 +143,65 @@ const makeMasterFiles = (intents) => { } }; +// Adds to the table, never removes +const up = async () => { + // template column + await sequelize + .query( + `ALTER TABLE user_files ADD COLUMN IF NOT EXISTS template json NULL;` + ) + .then(() => { + return null; + }) + .catch((err) => { + logger( + "error", + `Failed to adding user_files.template column. DB tables may be out of sync!`, + "user_files", + null, + err + ); + return null; + }); + + // publicity_type column + await sequelize + .query( + `ALTER TABLE user_files ADD COLUMN IF NOT EXISTS publicity_type varchar(255) NULL;` + ) + .then(() => { + return null; + }) + .catch((err) => { + logger( + "error", + `Failed to adding user_files.publicity_type column. DB tables may be out of sync!`, + "user_files", + null, + err + ); + return null; + }); + + // public_editors column + await sequelize + .query( + `ALTER TABLE user_files ADD COLUMN IF NOT EXISTS public_editors text[] NULL;` + ) + .then(() => { + return null; + }) + .catch((err) => { + logger( + "error", + `Failed to adding user_files.public_editors column. DB tables may be out of sync!`, + "user_files", + null, + err + ); + return null; + }); +}; + // export User model for use in other files. -module.exports = { Userfiles, UserfilesTEST, makeMasterFiles }; +module.exports = { Userfiles, UserfilesTEST, makeMasterFiles, up }; diff --git a/API/Backend/Draw/routes/draw.js b/API/Backend/Draw/routes/draw.js index 903d2971..c2dc8fab 100644 --- a/API/Backend/Draw/routes/draw.js +++ b/API/Backend/Draw/routes/draw.js @@ -2,7 +2,7 @@ const express = require("express"); const logger = require("../../../logger"); const database = require("../../../database"); const Sequelize = require("sequelize"); -const uuidv4 = require("uuid/v4"); +const { v4: uuidv4 } = require("uuid"); const fhistories = require("../models/filehistories"); const Filehistories = fhistories.Filehistories; const FilehistoriesTEST = fhistories.FilehistoriesTEST; @@ -12,6 +12,10 @@ const UserfilesTEST = ufiles.UserfilesTEST; const uf = require("../models/userfeatures"); const Userfeatures = uf.Userfeatures; const UserfeaturesTEST = uf.UserfeaturesTEST; + +const filesutils = require("./filesutils"); +const getfile = filesutils.getfile; + const { sequelize } = require("../../../connection"); const router = express.Router(); @@ -49,6 +53,7 @@ const pushToHistory = ( time, undoToTime, action_index, + user, successCallback, failureCallback ) => { @@ -85,6 +90,7 @@ const pushToHistory = ( time: time, action_index: action_index, history: h, + author: user, }; // Insert new entry into the history table Table.create(newHistoryEntry) @@ -252,6 +258,7 @@ const clipOver = function ( time, null, 5, + req.user, () => { if (typeof successCallback === "function") successCallback(); }, @@ -392,6 +399,7 @@ const clipUnder = function ( time, null, 7, + req.user, () => { if (typeof successCallback === "function") successCallback(); }, @@ -440,6 +448,137 @@ const clipUnder = function ( failureCallback(err); }); }; + +const _templateConform = (req, from) => { + return new Promise((resolve, reject) => { + req.body.id = req.body.file_id; + + getfile(req, { + send: (r) => { + if (r.status === "success") { + const geojson = r.body.geojson; + const template = + r.body.file?.[0]?.dataValues?.template?.template || []; + const existingProperties = JSON.parse(req.body.properties || "{}"); + const templaterProperties = {}; + + template.forEach((t, idx) => { + switch (t.type) { + case "incrementer": + const nextIncrement = _getNextIncrement( + existingProperties[t.field], + t, + geojson.features, + existingProperties, + from + ); + if (nextIncrement.error != null) { + reject(nextIncrement.error); + return; + } else templaterProperties[t.field] = nextIncrement.newValue; + break; + default: + } + }); + + req.body.properties = JSON.stringify({ + ...existingProperties, + ...templaterProperties, + }); + } + resolve(); + return; + }, + }); + + function _getNextIncrement(value, t, layer, existingProperties) { + const response = { + newValue: value, + error: null, + }; + + let usedValues = []; + const split = (t._default || t.default).split("#"); + const start = split[0]; + const end = split[1]; + + for (let i = 0; i < layer.length; i++) { + if (layer[i] == null) continue; + let geojson = layer[i]; + if (geojson?.properties?.[t.field] != null) { + let featuresVal = geojson?.properties?.[t.field]; + + featuresVal = featuresVal.replace(start, "").replace(end, ""); + + if (featuresVal !== "#") { + featuresVal = parseInt(featuresVal); + usedValues.push(featuresVal); + } + } + } + + if ((response.newValue || "").indexOf("#") !== -1) { + // Actually increment the incrementer for the first time + let bestVal = 0; + usedValues.sort(function (a, b) { + return a - b; + }); + usedValues = [...new Set(usedValues)]; // makes it unique + usedValues.forEach((v) => { + if (bestVal === v) bestVal++; + }); + response.newValue = response.newValue.replace("#", bestVal); + } else if (existingProperties) { + let numVal = response.newValue.replace(start, "").replace(end, ""); + if (numVal != "#") { + numVal = parseInt(numVal); + if (existingProperties[t.field] === response.newValue) { + // In case of a resave, make sure the id exists only once + let count = 0; + usedValues.forEach((v) => { + if (numVal === v) count++; + }); + if (count > 1) + response.error = `Incrementing field: '${t.field}' is not unique`; + } else { + // In case a manual change, make sure the id is unique + if (usedValues.indexOf(numVal) !== -1) + response.error = `Incrementing field: '${t.field}' is not unique`; + } + } + } + + // Check that the field still matches the surrounding string + const incRegex = new RegExp(`^${start}\\d+${end}$`); + if (incRegex.test(response.newValue) == false) { + response.error = `Incrementing field: '${t.field}' must follow syntax: '${start}{#}${end}'`; + } + + // Check that incrementer is unique + let numMatches = 0; + for (let i = 0; i < layer.length; i++) { + if (layer[i] == null) continue; + let geojson = layer[i]; + if (geojson?.properties?.[t.field] != null) { + let featuresVal = geojson?.properties?.[t.field]; + if ( + (value || "").indexOf("#") == -1 && + response.newValue === featuresVal && + geojson?.properties?.uuid != existingProperties.uuid + ) { + numMatches++; + } + } + } + // If we're are editing and the value did not change, allow a single match + if (numMatches > 0) { + response.error = `Incrementing field: '${t.field}' is not unique`; + } + + return response; + } + }); +}; /** * Adds a feature * { @@ -453,13 +592,23 @@ const clipUnder = function ( * geometry: <geometry> (required) * } */ -const add = function ( +const add = async function ( req, res, successCallback, failureCallback1, failureCallback2 ) { + let failedTemplate = false; + await _templateConform(req, "add").catch((err) => { + failedTemplate = err; + }); + if (failedTemplate !== false) { + if (typeof failureCallback2 === "function") + failureCallback2(failedTemplate); + return; + } + let Files = req.body.test === "true" ? UserfilesTEST : Userfiles; let Features = req.body.test === "true" ? UserfeaturesTEST : Userfeatures; let Histories = req.body.test === "true" ? FilehistoriesTEST : Filehistories; @@ -475,13 +624,28 @@ const add = function ( Files.findOne({ where: { id: req.body.file_id, - [Sequelize.Op.or]: { - file_owner: req.user, - [Sequelize.Op.and]: { - file_owner: "group", - file_owner_group: { [Sequelize.Op.overlap]: groups }, + [Sequelize.Op.or]: [ + { file_owner: req.user }, + { + [Sequelize.Op.and]: { + file_owner: "group", + file_owner_group: { [Sequelize.Op.overlap]: groups }, + }, }, - }, + { + [Sequelize.Op.and]: { + public: "1", + publicity_type: "list_edit", + public_editors: { [Sequelize.Op.contains]: [req.user] }, + }, + }, + { + [Sequelize.Op.and]: { + public: "1", + publicity_type: "all_edit", + }, + }, + ], }, }).then((file) => { if (!file) { @@ -581,6 +745,7 @@ const add = function ( time, null, 0, + req.user, () => { if (typeof successCallback === "function") successCallback(created.id, created.intent); @@ -650,7 +815,16 @@ router.post("/add", function (req, res, next) { * geometry: <geometry> (optional) * } */ -const edit = function (req, res, successCallback, failureCallback) { +const edit = async function (req, res, successCallback, failureCallback) { + let failedTemplate = false; + await _templateConform(req, "edit").catch((err) => { + failedTemplate = err; + }); + if (failedTemplate !== false) { + if (typeof failureCallback === "function") failureCallback(failedTemplate); + return; + } + let Files = req.body.test === "true" ? UserfilesTEST : Userfiles; let Features = req.body.test === "true" ? UserfeaturesTEST : Userfeatures; let Histories = req.body.test === "true" ? FilehistoriesTEST : Filehistories; @@ -665,13 +839,28 @@ const edit = function (req, res, successCallback, failureCallback) { Files.findOne({ where: { id: req.body.file_id, - [Sequelize.Op.or]: { - file_owner: req.user, - [Sequelize.Op.and]: { - file_owner: "group", - file_owner_group: { [Sequelize.Op.overlap]: groups }, + [Sequelize.Op.or]: [ + { file_owner: req.user }, + { + [Sequelize.Op.and]: { + file_owner: "group", + file_owner_group: { [Sequelize.Op.overlap]: groups }, + }, }, - }, + { + [Sequelize.Op.and]: { + public: "1", + publicity_type: "list_edit", + public_editors: { [Sequelize.Op.contains]: [req.user] }, + }, + }, + { + [Sequelize.Op.and]: { + public: "1", + publicity_type: "all_edit", + }, + }, + ], }, }) .then((file) => { @@ -749,6 +938,7 @@ const edit = function (req, res, successCallback, failureCallback) { time, null, 1, + req.user, () => { successCallback(createdId, createdUUID, createdIntent); }, @@ -796,7 +986,9 @@ router.post("/edit", function (req, res) { res.send({ status: "failure", message: "Failed to edit feature.", - body: {}, + body: { + error: err, + }, }); } ); @@ -822,13 +1014,28 @@ router.post("/remove", function (req, res, next) { Files.findOne({ where: { id: req.body.file_id, - [Sequelize.Op.or]: { - file_owner: req.user, - [Sequelize.Op.and]: { - file_owner: "group", - file_owner_group: { [Sequelize.Op.overlap]: groups }, + [Sequelize.Op.or]: [ + { file_owner: req.user }, + { + [Sequelize.Op.and]: { + file_owner: "group", + file_owner_group: { [Sequelize.Op.overlap]: groups }, + }, }, - }, + { + [Sequelize.Op.and]: { + public: "1", + publicity_type: "list_edit", + public_editors: { [Sequelize.Op.contains]: [req.user] }, + }, + }, + { + [Sequelize.Op.and]: { + public: "1", + publicity_type: "all_edit", + }, + }, + ], }, }).then((file) => { if (!file) { @@ -861,6 +1068,7 @@ router.post("/remove", function (req, res, next) { time, null, 2, + req.user, () => { logger("info", "Feature removed.", req.originalUrl, req); res.send({ @@ -927,13 +1135,28 @@ router.post("/undo", function (req, res, next) { Files.findOne({ where: { id: req.body.file_id, - [Sequelize.Op.or]: { - file_owner: req.user, - [Sequelize.Op.and]: { - file_owner: "group", - file_owner_group: { [Sequelize.Op.overlap]: groups }, + [Sequelize.Op.or]: [ + { file_owner: req.user }, + { + [Sequelize.Op.and]: { + file_owner: "group", + file_owner_group: { [Sequelize.Op.overlap]: groups }, + }, }, - }, + { + [Sequelize.Op.and]: { + public: "1", + publicity_type: "list_edit", + public_editors: { [Sequelize.Op.contains]: [req.user] }, + }, + }, + { + [Sequelize.Op.and]: { + public: "1", + publicity_type: "all_edit", + }, + }, + ], }, }).then((file) => { if (!file) { @@ -992,6 +1215,7 @@ router.post("/undo", function (req, res, next) { time, req.body.undo_time, 3, + req.user, () => { logger("info", "Undo successful.", req.originalUrl, req); res.send({ @@ -1052,13 +1276,28 @@ router.post("/merge", function (req, res, next) { Files.findOne({ where: { id: req.body.file_id, - [Sequelize.Op.or]: { - file_owner: req.user, - [Sequelize.Op.and]: { - file_owner: "group", - file_owner_group: { [Sequelize.Op.overlap]: groups }, + [Sequelize.Op.or]: [ + { file_owner: req.user }, + { + [Sequelize.Op.and]: { + file_owner: "group", + file_owner_group: { [Sequelize.Op.overlap]: groups }, + }, }, - }, + { + [Sequelize.Op.and]: { + public: "1", + publicity_type: "list_edit", + public_editors: { [Sequelize.Op.contains]: [req.user] }, + }, + }, + { + [Sequelize.Op.and]: { + public: "1", + publicity_type: "all_edit", + }, + }, + ], }, }).then((file) => { if (!file) { @@ -1131,6 +1370,7 @@ router.post("/merge", function (req, res, next) { time, null, 6, + req.user, () => { logger( "info", @@ -1216,13 +1456,28 @@ router.post("/split", function (req, res, next) { Files.findOne({ where: { id: req.body.file_id, - [Sequelize.Op.or]: { - file_owner: req.user, - [Sequelize.Op.and]: { - file_owner: "group", - file_owner_group: { [Sequelize.Op.overlap]: groups }, + [Sequelize.Op.or]: [ + { file_owner: req.user }, + { + [Sequelize.Op.and]: { + file_owner: "group", + file_owner_group: { [Sequelize.Op.overlap]: groups }, + }, }, - }, + { + [Sequelize.Op.and]: { + public: "1", + publicity_type: "list_edit", + public_editors: { [Sequelize.Op.contains]: [req.user] }, + }, + }, + { + [Sequelize.Op.and]: { + public: "1", + publicity_type: "all_edit", + }, + }, + ], }, }) .then((file) => { @@ -1290,6 +1545,7 @@ router.post("/split", function (req, res, next) { time, null, 8, + req.user, () => { res.send({ status: "success", diff --git a/API/Backend/Draw/routes/files.js b/API/Backend/Draw/routes/files.js index 16c72689..6262b169 100644 --- a/API/Backend/Draw/routes/files.js +++ b/API/Backend/Draw/routes/files.js @@ -48,14 +48,25 @@ router.post("/", function (req, res, next) { router.post("/getfiles", function (req, res, next) { let Table = req.body.test === "true" ? UserfilesTEST : Userfiles; + const orWhere = [ + { + file_owner: req.user, + }, + { public: "1" }, + { + public: + req.leadGroupName != null && + req.groups != null && + req.groups[req.leadGroupName] === true + ? "0" + : "1", + }, + ]; Table.findAll({ where: { //file_owner is req.user or public is '0' hidden: "0", - [Sequelize.Op.or]: { - file_owner: req.user, - public: "1", - }, + [Sequelize.Op.or]: orWhere, }, }) .then((files) => { @@ -131,7 +142,9 @@ router.post("/make", function (req, res, next) { file_description: req.body.file_description, intent: req.body.intent, public: "1", + publicity_type: "read_only", hidden: "0", + template: req.body.template ? JSON.parse(req.body.template) : null, }; // Insert new userfile into the user_files table @@ -410,6 +423,9 @@ router.post("/restore", function (req, res, next) { * file_name: <string> (optional) * file_description: <string> (optional) * public: <0|1> (optional) + * template: <json> (optional) + * publicity_type: <string> (optional) + * public_editors: <string[]> (optional) * } */ router.post("/change", function (req, res, next) { @@ -432,6 +448,29 @@ router.post("/change", function (req, res, next) { ) { toUpdateTo.public = req.body.public; } + if (req.body.hasOwnProperty("template") && req.body.template != null) { + try { + toUpdateTo.template = JSON.parse(req.body.template); + } catch (err) {} + } + if ( + req.body.hasOwnProperty("publicity_type") && + [null, "read_only", "list_edit", "all_edit"].includes( + req.body.publicity_type + ) + ) { + toUpdateTo.publicity_type = req.body.publicity_type; + } + if (req.body.hasOwnProperty("public_editors")) { + try { + let public_editors = null; + if (typeof req.body.public_editors === "string") + public_editors = req.body.public_editors + .split(",") + .map((e) => e.trim()); + toUpdateTo.public_editors = public_editors; + } catch (err) {} + } let updateObj = { where: { diff --git a/API/Backend/Draw/setup.js b/API/Backend/Draw/setup.js index 90df3c54..d74efb19 100644 --- a/API/Backend/Draw/setup.js +++ b/API/Backend/Draw/setup.js @@ -1,12 +1,14 @@ const routeFiles = require("./routes/files"); const routerFiles = routeFiles.router; const routerDraw = require("./routes/draw").router; +const ufiles = require("./models/userfiles"); +const file_histories = require("./models/filehistories"); let setup = { //Once the app initializes onceInit: (s) => { s.app.use( - "/API/files", + s.ROOT_PATH + "/API/files", s.ensureUser(), s.checkHeadersCodeInjection, s.setContentType, @@ -15,7 +17,7 @@ let setup = { ); s.app.use( - "/API/draw", + s.ROOT_PATH + "/API/draw", s.ensureUser(), s.checkHeadersCodeInjection, s.setContentType, @@ -27,6 +29,12 @@ let setup = { onceStarted: (s) => {}, //Once all tables sync onceSynced: (s) => { + if (typeof file_histories.up === "function") { + file_histories.up(); + } + if (typeof ufiles.up === "function") { + ufiles.up(); + } routeFiles.makeMasterFiles([ "roi", "campaign", diff --git a/API/Backend/Geodatasets/setup.js b/API/Backend/Geodatasets/setup.js index 7320668c..f0769561 100644 --- a/API/Backend/Geodatasets/setup.js +++ b/API/Backend/Geodatasets/setup.js @@ -2,9 +2,9 @@ const router = require("./routes/geodatasets"); let setup = { //Once the app initializes - onceInit: s => { + onceInit: (s) => { s.app.use( - "/API/geodatasets", + s.ROOT_PATH + "/API/geodatasets", s.ensureAdmin(), s.checkHeadersCodeInjection, s.setContentType, @@ -12,9 +12,9 @@ let setup = { ); }, //Once the server starts - onceStarted: s => {}, + onceStarted: (s) => {}, //Once all tables sync - onceSynced: s => {} + onceSynced: (s) => {}, }; module.exports = setup; diff --git a/API/Backend/LongTermToken/setup.js b/API/Backend/LongTermToken/setup.js index 30f25272..4eed3591 100644 --- a/API/Backend/LongTermToken/setup.js +++ b/API/Backend/LongTermToken/setup.js @@ -1,9 +1,9 @@ const router = require("./routes/longtermtokens"); let setup = { //Once the app initializes - onceInit: s => { + onceInit: (s) => { s.app.use( - "/API/longtermtoken", + s.ROOT_PATH + "/API/longtermtoken", s.ensureAdmin(false, true), s.checkHeadersCodeInjection, s.setContentType, @@ -11,9 +11,9 @@ let setup = { ); }, //Once the server starts - onceStarted: s => {}, + onceStarted: (s) => {}, //Once all tables sync - onceSynced: s => {} + onceSynced: (s) => {}, }; module.exports = setup; diff --git a/API/Backend/Shortener/setup.js b/API/Backend/Shortener/setup.js index 99890f50..d7d248ae 100644 --- a/API/Backend/Shortener/setup.js +++ b/API/Backend/Shortener/setup.js @@ -2,9 +2,9 @@ const router = require("./routes/shortener"); let setup = { //Once the app initializes - onceInit: s => { + onceInit: (s) => { s.app.use( - "/API/shortener", + s.ROOT_PATH + "/API/shortener", s.ensureUser(), s.checkHeadersCodeInjection, s.setContentType, @@ -12,9 +12,9 @@ let setup = { ); }, //Once the server starts - onceStarted: s => {}, + onceStarted: (s) => {}, //Once all tables sync - onceSynced: s => {} + onceSynced: (s) => {}, }; module.exports = setup; diff --git a/API/Backend/Users/models/user.js b/API/Backend/Users/models/user.js index 75902637..81df9ff9 100644 --- a/API/Backend/Users/models/user.js +++ b/API/Backend/Users/models/user.js @@ -12,7 +12,7 @@ var User = sequelize.define( username: { type: Sequelize.STRING, unique: true, - allowNull: false + allowNull: false, }, email: { type: Sequelize.STRING, @@ -20,52 +20,52 @@ var User = sequelize.define( allowNull: true, validate: { isEmail: true, - isUnique: function(value, next) { + isUnique: function (value, next) { var self = this; User.findOne({ where: { email: value } }) - .then(function(user) { + .then(function (user) { // reject if a different user wants to use the same email if (user && self.id !== user.id) { return next("User exists!"); } return next(); }) - .catch(function(err) { + .catch(function (err) { return next(err); }); - } - } + }, + }, }, password: { type: Sequelize.STRING, - allowNull: false + allowNull: false, }, permission: { type: Sequelize.ENUM, values: ["000", "001", "010", "011", "100", "101", "110", "111"], allowNull: false, - defaultValue: "000" + defaultValue: "000", }, token: { type: Sequelize.DataTypes.STRING(2048), - allowNull: true - } + allowNull: true, + }, }, { hooks: { - beforeCreate: user => { + beforeCreate: (user) => { const salt = bcrypt.genSaltSync(); user.password = bcrypt.hashSync(user.password, salt); - } - } + }, + }, }, { - timestamps: true + timestamps: true, } ); // Instance Method for validating user's password -User.prototype.validPassword = function(password, user) { +User.prototype.validPassword = function (password, user) { return bcrypt.compareSync(password, user.password); }; diff --git a/API/Backend/Users/routes/users.js b/API/Backend/Users/routes/users.js index 6f7451f2..cfae2239 100644 --- a/API/Backend/Users/routes/users.js +++ b/API/Backend/Users/routes/users.js @@ -85,51 +85,56 @@ router.post("/signup", function (req, res, next) { if (!user) { User.create(newUser) .then((created) => { - // Save the user's info in the session - req.session.user = created.username; - req.session.uid = created.id; - req.session.token = crypto.randomBytes(128).toString("hex"); + clearLoginSession(req); + req.session.regenerate((err) => { + // Save the user's info in the session + req.session.user = created.username; + req.session.uid = created.id; + req.session.token = crypto.randomBytes(128).toString("hex"); + req.session.permission = created.permission; - User.update( - { - token: req.session.token, - }, - { - where: { - id: created.id, - username: created.username, - }, - } - ) - .then(() => { - logger( - "info", - req.body.username + " signed up.", - req.originalUrl, - req - ); - res.send({ - status: "success", - username: created.username, + User.update( + { token: req.session.token, - groups: getUserGroups(created.username, req.leadGroupName), - }); - return null; - }) - .catch((err) => { - logger( - "error", - "Only partially signed up.", - req.originalUrl, - req, - err - ); - res.send({ - status: "failure", - message: "Only partially signed up. Try logging in.", + }, + { + where: { + id: created.id, + username: created.username, + }, + } + ) + .then(() => { + logger( + "info", + req.body.username + " signed up.", + req.originalUrl, + req + ); + res.send({ + status: "success", + username: created.username, + token: req.session.token, + groups: getUserGroups(created.username, req.leadGroupName), + }); + return null; + }) + .catch((err) => { + logger( + "error", + "Only partially signed up.", + req.originalUrl, + req, + err + ); + res.send({ + status: "failure", + message: "Only partially signed up. Try logging in.", + }); + return null; }); - return null; - }); + return null; + }); return null; }) .catch((err) => { @@ -153,104 +158,118 @@ router.post("/signup", function (req, res, next) { * User login */ router.post("/login", function (req, res) { - let MMGISUser = req.cookies.MMGISUser - ? JSON.parse(req.cookies.MMGISUser) - : false; - let username = req.body.username || (MMGISUser ? MMGISUser.username : null); + clearLoginSession(req); - if (username == null) { - res.send({ status: "failure", message: "No username provided." }); - return; - } + req.session.regenerate((err) => { + let MMGISUser = req.cookies.MMGISUser + ? JSON.parse(req.cookies.MMGISUser) + : false; + let username = req.body.username || (MMGISUser ? MMGISUser.username : null); - User.findOne({ - where: { - username: username, - }, - attributes: ["id", "username", "email", "password", "permission"], - }) - .then((user) => { - if (!user) { - res.send({ - status: "failure", - message: "Invalid username or password.", - }); - } else { - function pass(err, result, again) { - if (result) { - // Save the user's info in the session - req.session.user = user.username; - req.session.uid = user.id; - req.session.token = crypto.randomBytes(128).toString("hex"); - req.session.permission = user.permission; + if (username == null) { + res.send({ status: "failure", message: "No username provided." }); + return; + } - User.update( - { - token: req.session.token, - }, - { - where: { - id: user.id, - username: user.username, - }, - } - ) - .then(() => { - res.send({ - status: "success", - username: user.username, + User.findOne({ + where: { + username: username, + }, + attributes: ["id", "username", "email", "password", "permission"], + }) + .then((user) => { + if (!user) { + res.send({ + status: "failure", + message: "Invalid username or password.", + }); + } else { + function pass(err, result, again) { + if (result) { + // Save the user's info in the session + req.session.user = user.username; + req.session.uid = user.id; + req.session.token = crypto.randomBytes(128).toString("hex"); + req.session.permission = user.permission; + + User.update( + { token: req.session.token, - groups: getUserGroups(user.username, req.leadGroupName), + }, + { + where: { + id: user.id, + username: user.username, + }, + } + ) + .then(() => { + req.session.save(() => { + res.send({ + status: "success", + username: user.username, + token: req.session.token, + groups: getUserGroups(user.username, req.leadGroupName), + additional: + process.env.THIRD_PARTY_COOKIES === "true" + ? `; SameSite=None;${ + process.env.NODE_ENV === "production" + ? " Secure" + : "" + }` + : "", + }); + }); + return null; + }) + .catch((err) => { + res.send({ status: "failure", message: "Login failed." }); + return null; }); + return null; + } else { + res.send({ + status: "failure", + message: "Invalid username or password.", + }); + return null; + } + } + + if (req.body.useToken && MMGISUser) { + if (MMGISUser.token == null) { + res.send({ status: "failure", message: "Bad token." }); + return null; + } + User.findOne({ + where: { + username: MMGISUser.username, + token: MMGISUser.token, + }, + }) + .then((user) => { + if (!user) { + res.send({ status: "failure", message: "Bad token." }); + } else { + pass(null, true, true); + } return null; }) .catch((err) => { - res.send({ status: "failure", message: "Login failed." }); - return null; + res.send({ status: "failure", message: "Bad token." }); }); return null; } else { - res.send({ - status: "failure", - message: "Invalid username or password.", - }); - return null; - } - } - - if (req.body.useToken && MMGISUser) { - if (MMGISUser.token == null) { - res.send({ status: "failure", message: "Bad token." }); - return null; + bcrypt.compare(req.body.password, user.password, pass); } - User.findOne({ - where: { - username: MMGISUser.username, - token: MMGISUser.token, - }, - }) - .then((user) => { - if (!user) { - res.send({ status: "failure", message: "Bad token." }); - } else { - pass(null, true, true); - } - return null; - }) - .catch((err) => { - res.send({ status: "failure", message: "Bad token." }); - }); return null; - } else { - bcrypt.compare(req.body.password, user.password, pass); } return null; - } - return null; - }) - .catch((err) => { - res.send({ status: "failure", message: "Bad token." }); - }); + }) + .catch((err) => { + res.send({ status: "failure", message: "Bad token." }); + }); + }); return null; }); @@ -259,10 +278,7 @@ router.post("/logout", function (req, res) { ? JSON.parse(req.cookies.MMGISUser) : false; - req.session.user = "guest"; - req.session.uid = null; - req.session.token = null; - req.session.permission = null; + clearLoginSession(req); if (MMGISUser == false) { res.send({ status: "failure", message: "No user." }); @@ -279,7 +295,11 @@ router.post("/logout", function (req, res) { } ) .then(() => { - res.send({ status: "success" }); + req.session.save(() => { + req.session.regenerate((err) => { + res.send({ status: "success" }); + }); + }); return null; }) .catch((err) => { @@ -290,6 +310,30 @@ router.post("/logout", function (req, res) { } }); +router.get("/logged_in", function (req, res) { + if ( + typeof req.session.permission === "string" && + req.session.permission[req.session.permission.length - 1] === "1" + ) + res.send({ + status: "success", + message: `'${req.session.user}' is logged in to this session.`, + body: { + loggedIn: true, + user: req.session.user, + }, + }); + else + res.send({ + status: "failure", + message: `No user is logged in to this session.`, + body: { + loggedIn: false, + user: null, + }, + }); +}); + function getUserGroups(user, leadGroupName) { let leads = process.env.LEADS ? JSON.parse(process.env.LEADS) : []; let groups = {}; @@ -299,4 +343,11 @@ function getUserGroups(user, leadGroupName) { return Object.keys(groups); } +function clearLoginSession(req) { + req.session.user = "guest"; + req.session.uid = null; + req.session.token = null; + req.session.permission = null; +} + module.exports = router; diff --git a/API/Backend/Users/setup.js b/API/Backend/Users/setup.js index 761549c3..19167d99 100644 --- a/API/Backend/Users/setup.js +++ b/API/Backend/Users/setup.js @@ -3,7 +3,7 @@ const router = require("./routes/users"); let setup = { //Once the app initializes onceInit: (s) => { - s.app.use("/API/users", s.checkHeadersCodeInjection, router); + s.app.use(s.ROOT_PATH + "/API/users", s.checkHeadersCodeInjection, router); }, //Once the server starts onceStarted: (s) => {}, diff --git a/API/Backend/Utils/routes/utils.js b/API/Backend/Utils/routes/utils.js index 04051eab..065812c3 100644 --- a/API/Backend/Utils/routes/utils.js +++ b/API/Backend/Utils/routes/utils.js @@ -87,7 +87,8 @@ router.get("/queryTilesetTimes", function (req, res, next) { const split = name.split("Z-"); let t = split.shift(); const n = split.join(""); - t = t.replace(/_/g, ":") + "Z"; + t = t.replace(/_/g, ":"); + if (t[t.length - 1] !== "Z") t += "Z"; dirStore[relUrlSplit[0]].dirs.push({ t: t, n: n }); }); diff --git a/API/Backend/Utils/setup.js b/API/Backend/Utils/setup.js index 8cbd4281..344d9d1c 100644 --- a/API/Backend/Utils/setup.js +++ b/API/Backend/Utils/setup.js @@ -2,7 +2,12 @@ const router = require("./routes/utils"); let setup = { //Once the app initializes onceInit: (s) => { - s.app.use("/API/utils", s.ensureUser(), s.setContentType, router); + s.app.use( + s.ROOT_PATH + "/API/utils", + s.ensureUser(), + s.setContentType, + router + ); }, //Once the server starts onceStarted: (s) => {}, diff --git a/API/Backend/Webhooks/processes/triggerwebhooks.js b/API/Backend/Webhooks/processes/triggerwebhooks.js index 152aa630..77135b45 100644 --- a/API/Backend/Webhooks/processes/triggerwebhooks.js +++ b/API/Backend/Webhooks/processes/triggerwebhooks.js @@ -80,16 +80,18 @@ function drawFileUpdate(webhook, payload) { }, }; - var response = {}; + const response = {}; response.send = function (res) { - var webhookHeader = JSON.parse(webhook.header); - var webhookBody = JSON.parse(webhook.body); - var file_name = res.body?.file[0]?.file_name || null; - var geojson = res.body.geojson; + const webhookHeader = JSON.parse(webhook.header); + const webhookBody = JSON.parse(webhook.body); + const file_name = res.body?.file[0]?.file_name || null; + const file_owner = res.body?.file[0]?.file_owner || null; + const geojson = res.body.geojson; const injectableVariables = { file_id, file_name, + file_owner, geojson, }; @@ -97,7 +99,7 @@ function drawFileUpdate(webhook, payload) { buildBody(webhookBody, injectableVariables); // Build the url - var url = buildUrl(webhook.url, injectableVariables); + const url = buildUrl(webhook.url, injectableVariables); // Push to the remote webhook pushToRemote(url, webhook.type, webhookHeader, webhookBody); @@ -128,8 +130,8 @@ function buildBody(webhookBody, injectableVariables) { } function drawFileDelete(webhook, payload) { - var file_id = payload.id; - var data = { + const file_id = payload.id; + const data = { body: { id: payload.id, quick_published: false, @@ -141,23 +143,29 @@ function drawFileDelete(webhook, payload) { }, }; - var response = {}; + const response = {}; response.send = function (res) { - var webhookHeader = JSON.parse(webhook.header); - var geojson = res.body.geojson; - var file_name = res.body?.file[0]?.file_name || null; + const webhookHeader = JSON.parse(webhook.header); + const webhookBody = JSON.parse(webhook.body); + const geojson = res.body.geojson; + const file_name = res.body?.file[0]?.file_name || null; + const file_owner = res.body?.file[0]?.file_owner || null; const injectableVariables = { file_id, file_name, + file_owner, geojson, }; + // Build the body + buildBody(webhookBody, injectableVariables); + // Build the url - var url = buildUrl(webhook.url, injectableVariables); + const url = buildUrl(webhook.url, injectableVariables); // Push to the remote webhook - pushToRemote(url, webhook.type, webhookHeader, {}); + pushToRemote(url, webhook.type, webhookHeader, webhookBody); }; getfile(data, response); diff --git a/API/Backend/Webhooks/setup.js b/API/Backend/Webhooks/setup.js index 54a8a3c0..3991e015 100644 --- a/API/Backend/Webhooks/setup.js +++ b/API/Backend/Webhooks/setup.js @@ -6,10 +6,14 @@ const routerTestWebhooks = require("./routes/testwebhooks"); let setup = { //Once the app initializes onceInit: (s) => { - s.app.use("/API/webhooks", s.checkHeadersCodeInjection, routerWebhooks); + s.app.use( + s.ROOT_PATH + "/API/webhooks", + s.checkHeadersCodeInjection, + routerWebhooks + ); if (process.env.NODE_ENV === "development") { s.app.use( - "/API/testwebhooks", + s.ROOT_PATH + "/API/testwebhooks", s.checkHeadersCodeInjection, routerTestWebhooks ); diff --git a/API/Backend/setupTemplate.js b/API/Backend/setupTemplate.js index 4b9a6090..59f567a5 100644 --- a/API/Backend/setupTemplate.js +++ b/API/Backend/setupTemplate.js @@ -2,12 +2,12 @@ const router = require("./routes/your_router"); let setup = { //Once the app initializes - onceInit: s => {}, + onceInit: (s) => {}, //Once the server starts - onceStarted: s => {}, + onceStarted: (s) => {}, //Once all tables sync - onceSynced: s => {}, - envs: [{ name: "ENV_VAR", description: "", required: false, private: false }] + onceSynced: (s) => {}, + envs: [{ name: "ENV_VAR", description: "", required: false, private: false }], }; module.exports = setup; diff --git a/API/connection.js b/API/connection.js index a5fd9aeb..b2f1522c 100644 --- a/API/connection.js +++ b/API/connection.js @@ -15,8 +15,8 @@ const sequelize = new Sequelize( max: 10, min: 0, acquire: 30000, - idle: 10000 - } + idle: 10000, + }, } ); @@ -30,7 +30,7 @@ sequelize "connection" ); }) - .catch(err => { + .catch((err) => { logger( "infrastructure_error", "Unable to connect to the database.", diff --git a/API/templates/config_template.js b/API/templates/config_template.js index 0d841a7c..5552331d 100644 --- a/API/templates/config_template.js +++ b/API/templates/config_template.js @@ -24,8 +24,13 @@ module.exports = { look: { pagename: "MMGIS", minimalist: false, + topbar: true, + toolbar: true, + scalebar: true, + coordinates: true, zoomcontrol: false, graticule: false, + miscellaneous: true, bodycolor: "", topbarcolor: "", toolbarcolor: "", @@ -39,7 +44,7 @@ module.exports = { helpurl: "", }, panels: ["viewer", "map", "globe"], - time:["enabled"], + time: ["enabled"], tools: [ { name: "Layers", diff --git a/API/utils.js b/API/utils.js index a9898c52..4cd52697 100644 --- a/API/utils.js +++ b/API/utils.js @@ -59,13 +59,18 @@ const Utils = { return true; }, traverseLayers: function (layers, onLayer) { + let removedUUIDs = []; depthTraversal(layers, 0, []); function depthTraversal(node, depth, path) { for (var i = 0; i < node.length; i++) { const ret = onLayer(node[i], path, i); - if (ret === "remove") { - node.splice(i, 1); + const removed = node.splice(i, 1); + if (removed.length > 0) { + // Find and store the UUIDs of the sublayers of the removed layer + const removedSubLayerUUIDs = Utils.findSubLayerUUIDs(removed); + removedUUIDs = removedUUIDs.concat(removedSubLayerUUIDs); + } i--; } //Add other feature information while we're at it @@ -82,6 +87,41 @@ const Utils = { } } } + + // Returns array of removed layer UUIDs, including all removed sublayer UUIDs + return removedUUIDs; + }, + findSubLayerUUIDs: function (layers) { + const UUIDs = []; + Utils.traverseLayers(layers, (layer) => { + UUIDs.push({ name: layer.name, uuid: layer.uuid }); + return; + }); + return UUIDs; + }, + // From https://javascript.plainenglish.io/4-ways-to-compare-objects-in-javascript-97fe9b2a949c + isEqual(obj1, obj2, isSimple) { + if (isSimple) { + return JSON.stringify(obj1) === JSON.stringify(obj2); + } else { + let props1 = Object.getOwnPropertyNames(obj1); + let props2 = Object.getOwnPropertyNames(obj2); + if (props1.length != props2.length) { + return false; + } + for (let i = 0; i < props1.length; i++) { + let prop = props1[i]; + let bothAreObjects = + typeof obj1[prop] === "object" && typeof obj2[prop] === "object"; + if ( + (!bothAreObjects && obj1[prop] !== obj2[prop]) || + (bothAreObjects && !Utils.isEqual(obj1[prop], obj2[prop])) + ) { + return false; + } + } + return true; + } }, }; diff --git a/API/websocket.js b/API/websocket.js index 103e741e..55a3cb64 100644 --- a/API/websocket.js +++ b/API/websocket.js @@ -1,66 +1,71 @@ -const WebSocket = require('isomorphic-ws'); +const WebSocket = require("isomorphic-ws"); const logger = require("./logger"); const websocket = { - wss: null, - init: function (server) { - logger( - "info", - "Trying to init websocket...", - "websocket", - null, - "" - ); + wss: null, + init: function (server) { + logger("info", "Trying to init websocket...", "websocket", null, ""); - if (!server === null) { - logger( - "websocket_error", - "server parameter not defined.", - "error", - null, - "" - ); - return null - } + if (!server === null) { + logger( + "websocket_error", + "server parameter not defined.", + "error", + null, + "" + ); + return null; + } - logger( - "info", - "Server is valid so still trying to init websocket...", - "websocket", - null, - "" - ); + logger( + "info", + "Server is valid so still trying to init websocket...", + "websocket", + null, + "" + ); - const wss = new WebSocket.Server({ server }); - websocket.wss = wss; + const wss = new WebSocket.Server({ noServer: true }); + websocket.wss = wss; - // Broadcast to all clients - wss.broadcast = function broadcast(data, isBinary) { - wss.clients.forEach(client => { - if (client.readyState === WebSocket.OPEN && data !== undefined) { - client.send(data, { binary: isBinary }); - } - }); - }; + // Broadcast to all clients + wss.broadcast = function broadcast(data, isBinary) { + wss.clients.forEach((client) => { + if (client.readyState === WebSocket.OPEN && data !== undefined) { + client.send(data, { binary: isBinary }); + } + }); + }; - wss.on('connection', (ws) => { - ws.on('message', (message) => { - wss.broadcast(message); - }); - }); + wss.on("connection", (ws) => { + ws.on("message", (message) => { + wss.broadcast(message); + }); + }); - wss.on('close', () => { - logger( - "info", - "Websocket disconnected...", - "websocket", - null, - "" - ); - websocket.wss = null - }); - } -} + server.on("upgrade", function upgrade(request, socket, head) { + const pathname = request.url; + try { + if ( + pathname === + (process.env.WEBSOCKET_ROOT_PATH || process.env.ROOT_PATH || "") + "/" + ) { + wss.handleUpgrade(request, socket, head, function done(ws) { + wss.emit("connection", ws, request); + }); + } else { + socket.destroy(); + } + } catch (err) { + socket.destroy(); + } + }); + wss.on("close", () => { + logger("info", "Websocket disconnected...", "websocket", null, ""); + websocket.wss = null; + }); + }, +}; module.exports = { websocket }; diff --git a/CHANGELOG.md b/CHANGELOG.md index 73fe2eae..5813d37e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,60 @@ # MMGIS Changelog +## 2.9.0 + +_Sept 5, 2023_ + +#### Summary + +This release makes Layer IDs based on UUIDs instead of their layer names, greatly improves support for the dimension of time, adds property templates and group editing to DrawTool files, adds ability to link features together, upgrades our tiling scripts, and streamlines installations among other things. + +#### Added + +- Examples of wrapping MMGIS in an IFrame under `/examples` +- A full features TimeUI/Timeline Scrubber +- The InfoTool scans for and makes clickable url links +- Support for Composite Time Tiles that merge tiles across a time range on-the-fly on the backend +- Configurable Context Menu actions +- Polygons can have right-click context menu actions and form links with their WKT strings +- A GitHub workflow now builds [MMGIS docker images](https://github.com/NASA-AMMOS/MMGIS/pkgs/container/mmgis) +- The ability to pair features from one layer to another and render those paired targets in the Photosphere view. +- Optional Websocket verification to the configure page to notify of concurrent users. +- Ability to export the "working" configuration JSON from the configure page +- GET `/api/configure/missions` now supports the `full` parameter to return all configuration objects as well +- DrawTool users can enforce property template on their files +- Adds a `MAIN_MISSION` ENV that skips the landing page even if there are many missions +- Grouping editing for DrawTool files +- All endpoints can use longtermtokens +- The LegendTool can optionally be exposed as a togglable popup as well as other improvements +- Various additions to the `mmgisAPI` +- Upgraded gdal2customtiles to use gdal 3.5.2 and to support tiling in any projection +- GeoJSON validation on layers. +- GeoJSON data can be an empty [] +- Clicking intersects all features making impossible-to-reach features accessible through the InfoTool +- The DrawTool is integrated with time. + +#### Changed + +- Layers use UUIDs and identifiers instead of their layer names (backwards-compatibility still maintained) +- The ENV `PUBLIC_URL` is deprecated in fovar of the new `ROOT_PATH`. Unlike `PUBLIC_URL`, `ROOT_PATH` can fully be changed at runtime +- Database and POSTGIS extension are automatically created if they don't exist +- Upgraded the configure page's jquery from `1.11.1` to `3.6.1` + +#### Fixed + +- `ENABLE_MMGIS_WEBSOCKETS` name in sample.env +- Websockets try to reconnect and with exponential backoff +- Various issues regarding time layers +- Various issues regarding WMS layers +- MMGIS can now work with NodeJS 18+ +- Bug where initially on annotations features have no click events +- Bug where having the cursor over an annotation on the Map prevented pans and zooms +- Fixed the `angleUnit` property for image layer attachments +- Cloning a layer in the configure page +- Issue where logging in with AUTH=local would infinitely reload + +--- + ## 2.8.0 _Nov 14, 2022_ diff --git a/README.md b/README.md index 8308fe3a..ce1daab4 100644 --- a/README.md +++ b/README.md @@ -35,20 +35,13 @@ ### System Requirements -1. Install the latest version of [Node.js v14.9.0+](https://nodejs.org/en/download/). Developed with v16.13.2. Note that v18+ of Node.js fails to build. +1. Install the latest version of [Node.js v16.13.2+](https://nodejs.org/en/download/). 1. Install [PostgreSQL v10.14+](https://www.enterprisedb.com/downloads/postgres-postgresql-downloads). Detailed [install instructions](https://www.postgresqltutorial.com/postgresql-getting-started/) for all platforms. 1. Install [PostGIS 2.5+](https://postgis.net/install/). From the above install, you can use the 'Application Stack Builder' to install PostGIS or the default [PostGIS install instructions](https://postgis.net/install/) for all platforms. 1. Make a new PostgreSQL database and remember the user, password and database name. Use 'pgsl' or the 'SQL Shell' to log into Postgres. It will prompt you for the username and password made during the install. - Issue the following commands: - `CREATE DATABASE mmgis;` - `\c mmgis` - `CREATE EXTENSION postgis;` - `exit` - In the above `\c` attaches to the database and `CREATE EXTENSION` enables PostGIS by creating a spatial reference table within that database. - 1. GDAL and Python are weaker dependencies (desirable but, without them, not everything will work) - GDAL [2.+](https://gdal.org/download.html) with Python bindings (Windows users may find [these](https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal) helpful) @@ -150,7 +143,7 @@ This repo contains a `docker-compose.yml` file that defines a service for the ap ### License: Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0) -Copyright (c) 2022, California Institute of Technology ("Caltech"). U.S. Government sponsorship acknowledged. +Copyright (c) 2023, California Institute of Technology ("Caltech"). U.S. Government sponsorship acknowledged. All rights reserved. diff --git a/auxiliary/gdal2customtiles/gdal2customtiles.py b/auxiliary/gdal2customtiles/gdal2customtiles.py index 2e4c1655..c07f7726 100644 --- a/auxiliary/gdal2customtiles/gdal2customtiles.py +++ b/auxiliary/gdal2customtiles/gdal2customtiles.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # ****************************************************************************** # $Id$ @@ -11,12 +11,11 @@ # - support of global tiles (Spherical Mercator) for compatibility # with interactive web maps a la Google Maps # Author: Klokan Petr Pridal, klokan at klokan dot cz -# Web: http://www.klokan.cz/projects/gdal2tiles/ -# GUI: http://www.maptiler.org/ # ############################################################################### # Copyright (c) 2008, Klokan Petr Pridal -# Copyright (c) 2010-2013, Even Rouault <even dot rouault at mines-paris dot org> +# Copyright (c) 2010-2013, Even Rouault <even dot rouault at spatialys.com> +# Copyright (c) 2021, Idan Miara <idan@miara.com> # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -37,25 +36,36 @@ # DEALINGS IN THE SOFTWARE. # ****************************************************************************** +from __future__ import division, print_function +import struct + +import contextlib +import glob +import json import math +import optparse import os +import shutil +import stat import sys +import tempfile +import threading +from functools import partial +from typing import Any, List, NoReturn, Optional, Tuple +from uuid import uuid4 +from xml.etree import ElementTree -from osgeo import gdal -from osgeo import osr - -import struct # 1bto4b +from osgeo import gdal, osr +Options = Any -def binary(num): # 1bto4b - # 1bto4b +# MMGIS +def binary(num): return ''.join(bin(c).replace('0b', '').rjust(8, '0') for c in struct.pack('!f', num)) -# 1bto4b - def getTilePxBounds(self, tx, ty, tz, ds): - querysize = self.tilesize + querysize = self.tile_size if self.isRasterBounded: # 'raster' profile: # tilesize in raster coordinates for actual zoom @@ -63,7 +73,7 @@ def getTilePxBounds(self, tx, ty, tz, ds): xsize = self.out_ds.fWorldXSize ysize = self.out_ds.fWorldYSize if tz >= self.tmaxz: - querysize = self.tilesize + querysize = self.tile_size rx = (tx) * tsize - self.out_ds.fRasterXOriginWorld #print("rx", rx) @@ -77,27 +87,27 @@ def getTilePxBounds(self, tx, ty, tz, ds): self.out_ds.fRasterYOriginWorld wx, wy = 0, 0 - wxsize = int(rxsize/float(tsize) * self.tilesize) - wysize = int(rysize/float(tsize) * self.tilesize) - if wysize != self.tilesize: - wy = self.tilesize - wysize + wxsize = int(rxsize/float(tsize) * self.tile_size) + wysize = int(rysize/float(tsize) * self.tile_size) + if wysize != self.tile_size: + wy = self.tile_size - wysize if rx < 0: rxsize = tsize + rx wx = -rx - wxsize = int(rxsize/float(tsize) * self.tilesize) + wxsize = int(rxsize/float(tsize) * self.tile_size) rx = 0 if ry < 0: rysize = tsize + ry wy = -ry - wysize = int(rysize/float(tsize) * self.tilesize) + wysize = int(rysize/float(tsize) * self.tile_size) ry = 0 if rx + rxsize > self.out_ds.fRasterXSizeWorld: rxsize = self.out_ds.fRasterXSizeWorld - rx - wxsize = int(rxsize/float(tsize) * self.tilesize) + wxsize = int(rxsize/float(tsize) * self.tile_size) if ry + rysize > self.out_ds.fRasterYSizeWorld: rysize = self.out_ds.fRasterYSizeWorld - ry - wysize = int(rysize/float(tsize) * self.tilesize) + wysize = int(rysize/float(tsize) * self.tile_size) # Convert rx, ry back to non-world coordinates rx = int(float(self.out_ds.RasterXSize) * @@ -119,19 +129,246 @@ def getTilePxBounds(self, tx, ty, tz, ds): try: - from PIL import Image import numpy + from PIL import Image + import osgeo.gdal_array as gdalarray -except Exception: + + numpy_available = True +except ImportError: # 'antialias' resampling is not available - pass + numpy_available = False __version__ = "$Id$" -resampling_list = ('average', 'near', 'bilinear', 'cubic', - 'cubicspline', 'lanczos', 'antialias') -profile_list = ('mercator', 'geodetic', 'raster') -webviewer_list = ('all', 'google', 'openlayers', 'leaflet', 'none') +resampling_list = ( + "average", + "near", + "near-composite", + "bilinear", + "cubic", + "cubicspline", + "lanczos", + "antialias", + "mode", + "max", + "min", + "med", + "q1", + "q3", +) +webviewer_list = ("all", "google", "openlayers", "leaflet", "mapml", "none") + + +def makedirs(path): + """Wrapper for os.makedirs() that can work with /vsi files too""" + if path.startswith("/vsi"): + if gdal.MkdirRecursive(path, 0o755) != 0: + raise Exception(f"Cannot create {path}") + else: + os.makedirs(path, exist_ok=True) + + +def isfile(path): + """Wrapper for os.path.isfile() that can work with /vsi files too""" + if path.startswith("/vsi"): + stat_res = gdal.VSIStatL(path) + if stat is None: + return False + return stat.S_ISREG(stat_res.mode) + else: + return os.path.isfile(path) + + +class VSIFile: + """Expose a simplistic file-like API for a /vsi file""" + + def __init__(self, filename, f): + self.filename = filename + self.f = f + + def write(self, content): + if gdal.VSIFWriteL(content, 1, len(content), self.f) != len(content): + raise Exception("Error while writing into %s" % self.filename) + + +@contextlib.contextmanager +def my_open(filename, mode): + """Wrapper for open() built-in method that can work with /vsi files too""" + if filename.startswith("/vsi"): + f = gdal.VSIFOpenL(filename, mode) + if f is None: + raise Exception(f"Cannot open {filename} in {mode}") + try: + yield VSIFile(filename, f) + finally: + if gdal.VSIFCloseL(f) != 0: + raise Exception(f"Cannot close {filename}") + else: + yield open(filename, mode) + + +class UnsupportedTileMatrixSet(Exception): + pass + + +class TileMatrixSet(object): + def __init__(self) -> None: + self.identifier = None + self.srs = None + self.topleft_x = None + self.topleft_y = None + self.matrix_width = None # at zoom 0 + self.matrix_height = None # at zoom 0 + self.tile_size = None + self.resolution = None # at zoom 0 + self.level_count = None + + def GeorefCoordToTileCoord(self, x, y, z, overriden_tile_size): + res = self.resolution * self.tile_size / overriden_tile_size / (2**z) + tx = int((x - self.topleft_x) / (res * overriden_tile_size)) + # In default mode, we use a bottom-y origin + ty = int( + ( + y + - ( + self.topleft_y + - self.matrix_height * self.tile_size * self.resolution + ) + ) + / (res * overriden_tile_size) + ) + return tx, ty + + def ZoomForPixelSize(self, pixelSize, overriden_tile_size): + "Maximal scaledown zoom of the pyramid closest to the pixelSize." + + for i in range(self.level_count): + res = self.resolution * self.tile_size / \ + overriden_tile_size / (2**i) + if pixelSize > res: + return max(0, i - 1) # We don't want to scale up + return self.level_count - 1 + + def PixelsToMeters(self, px, py, zoom, overriden_tile_size): + "Converts pixel coordinates in given zoom level of pyramid to EPSG:3857" + + res = self.resolution * self.tile_size / \ + overriden_tile_size / (2**zoom) + mx = px * res + self.topleft_x + my = py * res + ( + self.topleft_y - self.matrix_height * self.tile_size * self.resolution + ) + return mx, my + + def TileBounds(self, tx, ty, zoom, overriden_tile_size): + "Returns bounds of the given tile in georef coordinates" + + minx, miny = self.PixelsToMeters( + tx * overriden_tile_size, + ty * overriden_tile_size, + zoom, + overriden_tile_size, + ) + maxx, maxy = self.PixelsToMeters( + (tx + 1) * overriden_tile_size, + (ty + 1) * overriden_tile_size, + zoom, + overriden_tile_size, + ) + return (minx, miny, maxx, maxy) + + @staticmethod + def parse(j: dict) -> "TileMatrixSet": + assert "identifier" in j + assert "supportedCRS" in j + assert "tileMatrix" in j + assert isinstance(j["tileMatrix"], list) + srs = osr.SpatialReference() + assert srs.SetFromUserInput(str(j["supportedCRS"])) == 0 + swapaxis = srs.EPSGTreatsAsLatLong() or srs.EPSGTreatsAsNorthingEasting() + metersPerUnit = 1.0 + if srs.IsProjected(): + metersPerUnit = srs.GetLinearUnits() + elif srs.IsGeographic(): + metersPerUnit = srs.GetSemiMajor() * math.pi / 180 + tms = TileMatrixSet() + tms.srs = srs + tms.identifier = str(j["identifier"]) + for i, tileMatrix in enumerate(j["tileMatrix"]): + assert "topLeftCorner" in tileMatrix + assert isinstance(tileMatrix["topLeftCorner"], list) + topLeftCorner = tileMatrix["topLeftCorner"] + assert len(topLeftCorner) == 2 + assert "scaleDenominator" in tileMatrix + assert "tileWidth" in tileMatrix + assert "tileHeight" in tileMatrix + + topleft_x = topLeftCorner[0] + topleft_y = topLeftCorner[1] + tileWidth = tileMatrix["tileWidth"] + tileHeight = tileMatrix["tileHeight"] + if tileWidth != tileHeight: + raise UnsupportedTileMatrixSet("Only square tiles supported") + # Convention in OGC TileMatrixSet definition. See gcore/tilematrixset.cpp + resolution = tileMatrix["scaleDenominator"] * \ + 0.28e-3 / metersPerUnit + if swapaxis: + topleft_x, topleft_y = topleft_y, topleft_x + if i == 0: + tms.topleft_x = topleft_x + tms.topleft_y = topleft_y + tms.resolution = resolution + tms.tile_size = tileWidth + + assert "matrixWidth" in tileMatrix + assert "matrixHeight" in tileMatrix + tms.matrix_width = tileMatrix["matrixWidth"] + tms.matrix_height = tileMatrix["matrixHeight"] + else: + if topleft_x != tms.topleft_x or topleft_y != tms.topleft_y: + raise UnsupportedTileMatrixSet( + "All levels should have same origin") + if abs(tms.resolution / (1 << i) - resolution) > 1e-8 * resolution: + raise UnsupportedTileMatrixSet( + "Only resolutions varying as power-of-two supported" + ) + if tileWidth != tms.tile_size: + raise UnsupportedTileMatrixSet( + "All levels should have same tile size" + ) + tms.level_count = len(j["tileMatrix"]) + return tms + + +tmsMap = {} + +profile_list = ["mercator", "geodetic", "raster"] + +# Read additional tile matrix sets from GDAL data directory +filename = gdal.FindFile("gdal", "tms_MapML_APSTILE.json") +if filename and False: + dirname = os.path.dirname(filename) + for tmsfilename in glob.glob(os.path.join(dirname, "tms_*.json")): + data = open(tmsfilename, "rb").read() + try: + j = json.loads(data.decode("utf-8")) + except Exception: + j = None + if j is None: + print("Cannot parse " + tmsfilename) + continue + try: + tms = TileMatrixSet.parse(j) + except UnsupportedTileMatrixSet: + continue + except Exception: + print("Cannot parse " + tmsfilename) + continue + tmsMap[tms.identifier] = tms + profile_list.append(tms.identifier) + +threadLocal = threading.local() # ============================================================================= # ============================================================================= @@ -201,8 +438,7 @@ class GlobalMercator(object): What is the coordinate extent of Earth in EPSG:3857? - [-20037508.342789244, -20037508.342789244, - 20037508.342789244, 20037508.342789244] + [-20037508.342789244, -20037508.342789244, 20037508.342789244, 20037508.342789244] Constant 20037508.342789244 comes from the circumference of the Earth in meters, which is 40 thousand kilometers, the coordinate origin is in the middle of extent. In fact you can calculate the constant as: 2 * math.pi * 6378137 / 2.0 @@ -272,11 +508,11 @@ class GlobalMercator(object): AUTHORITY["EPSG","9001"]]] """ - def __init__(self, tileSize=256): + def __init__(self, tile_size: int = 256) -> None: "Initialize the TMS Global Mercator pyramid" - self.tileSize = tileSize - self.initialResolution = 2 * math.pi * 6378137 / self.tileSize - # 156543.03392804062 for tileSize 256 pixels + self.tile_size = tile_size + self.initialResolution = 2 * math.pi * 6378137 / self.tile_size + # 156543.03392804062 for tile_size 256 pixels self.originShift = 2 * math.pi * 6378137 / 2.0 # 20037508.342789244 @@ -296,8 +532,11 @@ def MetersToLatLon(self, mx, my): lon = (mx / self.originShift) * 180.0 lat = (my / self.originShift) * 180.0 - lat = 180 / math.pi * \ - (2 * math.atan(math.exp(lat * math.pi / 180.0)) - math.pi / 2.0) + lat = ( + 180 + / math.pi + * (2 * math.atan(math.exp(lat * math.pi / 180.0)) - math.pi / 2.0) + ) return lat, lon def PixelsToMeters(self, px, py, zoom): @@ -319,14 +558,14 @@ def MetersToPixels(self, mx, my, zoom): def PixelsToTile(self, px, py): "Returns a tile covering region in given pixel coordinates" - tx = int(math.ceil(px / float(self.tileSize)) - 1) - ty = int(math.ceil(py / float(self.tileSize)) - 1) + tx = int(math.ceil(px / float(self.tile_size)) - 1) + ty = int(math.ceil(py / float(self.tile_size)) - 1) return tx, ty def PixelsToRaster(self, px, py, zoom): "Move the origin of pixel coordinates to top-left corner" - mapSize = self.tileSize << zoom + mapSize = self.tile_size << zoom return px, mapSize - py def MetersToTile(self, mx, my, zoom): @@ -339,9 +578,10 @@ def TileBounds(self, tx, ty, zoom): "Returns bounds of the given tile in EPSG:3857 coordinates" minx, miny = self.PixelsToMeters( - tx*self.tileSize, ty*self.tileSize, zoom) + tx * self.tile_size, ty * self.tile_size, zoom) maxx, maxy = self.PixelsToMeters( - (tx+1)*self.tileSize, (ty+1)*self.tileSize, zoom) + (tx + 1) * self.tile_size, (ty + 1) * self.tile_size, zoom + ) return (minx, miny, maxx, maxy) def TileLatLonBounds(self, tx, ty, zoom): @@ -356,7 +596,7 @@ def TileLatLonBounds(self, tx, ty, zoom): def Resolution(self, zoom): "Resolution (meters/pixel) for given zoom level (measured at Equator)" - # return (2 * math.pi * 6378137) / (self.tileSize * 2**zoom) + # return (2 * math.pi * 6378137) / (self.tile_size * 2**zoom) return self.initialResolution / (2**zoom) def ZoomForPixelSize(self, pixelSize): @@ -364,10 +604,8 @@ def ZoomForPixelSize(self, pixelSize): for i in range(MAXZOOMLEVEL): if pixelSize > self.Resolution(i): - if i != -1: - return i-1 - else: - return 0 # We don't want to scale up + return max(0, i - 1) # We don't want to scale up + return MAXZOOMLEVEL - 1 def GoogleTile(self, tx, ty, zoom): "Converts TMS tile coordinates to Google Tile coordinates" @@ -382,7 +620,7 @@ def QuadTree(self, tx, ty, zoom): ty = (2**zoom - 1) - ty for i in range(zoom, 0, -1): digit = 0 - mask = 1 << (i-1) + mask = 1 << (i - 1) if (tx & mask) != 0: digit += 1 if (ty & mask) != 0: @@ -427,17 +665,17 @@ class GlobalGeodetic(object): WMS, KML Web Clients, Google Earth TileMapService """ - def __init__(self, tmscompatible, tileSize=256): - self.tileSize = tileSize - if tmscompatible is not None: + def __init__(self, tmscompatible: Optional[bool], tile_size: int = 256) -> None: + self.tile_size = tile_size + if tmscompatible: # Defaults the resolution factor to 0.703125 (2 tiles @ level 0) # Adhers to OSGeo TMS spec # http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification#global-geodetic - self.resFact = 180.0 / self.tileSize + self.resFact = 180.0 / self.tile_size else: # Defaults the resolution factor to 1.40625 (1 tile @ level 0) # Adheres OpenLayers, MapProxy, etc default resolution for WMTS - self.resFact = 360.0 / self.tileSize + self.resFact = 360.0 / self.tile_size def LonLatToPixels(self, lon, lat, zoom): "Converts lon/lat to pixel coordinates in given zoom of the EPSG:4326 pyramid" @@ -450,8 +688,8 @@ def LonLatToPixels(self, lon, lat, zoom): def PixelsToTile(self, px, py): "Returns coordinates of the tile covering region in pixel coordinates" - tx = int(math.ceil(px / float(self.tileSize)) - 1) - ty = int(math.ceil(py / float(self.tileSize)) - 1) + tx = int(math.ceil(px / float(self.tile_size)) - 1) + ty = int(math.ceil(py / float(self.tile_size)) - 1) return tx, ty def LonLatToTile(self, lon, lat, zoom): @@ -470,19 +708,17 @@ def ZoomForPixelSize(self, pixelSize): for i in range(MAXZOOMLEVEL): if pixelSize > self.Resolution(i): - if i != 0: - return i-1 - else: - return 0 # We don't want to scale up + return max(0, i - 1) # We don't want to scale up + return MAXZOOMLEVEL - 1 def TileBounds(self, tx, ty, zoom): "Returns bounds of the given tile" res = self.resFact / 2**zoom return ( - tx*self.tileSize*res - 180, - ty*self.tileSize*res - 90, - (tx+1)*self.tileSize*res - 180, - (ty+1)*self.tileSize*res - 90 + tx * self.tile_size * res - 180, + ty * self.tile_size * res - 90, + (tx + 1) * self.tile_size * res - 180, + (ty + 1) * self.tile_size * res - 90, ) def TileLatLonBounds(self, tx, ty, zoom): @@ -497,13 +733,13 @@ class Zoomify(object): ---------------------------------------- """ - def __init__(self, width, height, tilesize=256, tileformat='jpg'): + def __init__(self, width, height, tile_size=256, tileformat="jpg"): """Initialization of the Zoomify tile tree""" - self.tilesize = tilesize + self.tile_size = tile_size self.tileformat = tileformat imagesize = (width, height) - tiles = (math.ceil(width / tilesize), math.ceil(height / tilesize)) + tiles = (math.ceil(width / tile_size), math.ceil(height / tile_size)) # Size (in tiles) for each tier of pyramid. self.tierSizeInTiles = [] @@ -513,11 +749,13 @@ def __init__(self, width, height, tilesize=256, tileformat='jpg'): self.tierImageSize = [] self.tierImageSize.append(imagesize) - while (imagesize[0] > tilesize or imagesize[1] > tilesize): + while imagesize[0] > tile_size or imagesize[1] > tile_size: imagesize = (math.floor( imagesize[0] / 2), math.floor(imagesize[1] / 2)) - tiles = (math.ceil(imagesize[0] / tilesize), - math.ceil(imagesize[1] / tilesize)) + tiles = ( + math.ceil(imagesize[0] / tile_size), + math.ceil(imagesize[1] / tile_size), + ) self.tierSizeInTiles.append(tiles) self.tierImageSize.append(imagesize) @@ -530,10 +768,10 @@ def __init__(self, width, height, tilesize=256, tileformat='jpg'): # Number of tiles up to the given tier of pyramid. self.tileCountUpToTier = [] self.tileCountUpToTier[0] = 0 - for i in range(1, self.numberOfTiers+1): + for i in range(1, self.numberOfTiers + 1): self.tileCountUpToTier.append( - self.tierSizeInTiles[i-1][0] * self.tierSizeInTiles[i-1][1] + - self.tileCountUpToTier[i-1] + self.tierSizeInTiles[i - 1][0] * self.tierSizeInTiles[i - 1][1] + + self.tileCountUpToTier[i - 1] ) def tilefilename(self, x, y, z): @@ -541,759 +779,1961 @@ def tilefilename(self, x, y, z): tileIndex = x + y * \ self.tierSizeInTiles[z][0] + self.tileCountUpToTier[z] - return os.path.join("TileGroup%.0f" % math.floor(tileIndex / 256), - "%s-%s-%s.%s" % (z, x, y, self.tileformat)) + return os.path.join( + "TileGroup%.0f" % math.floor(tileIndex / 256), + "%s-%s-%s.%s" % (z, x, y, self.tileformat), + ) -class Gdal2TilesError(Exception): +class GDALError(Exception): pass -class GDAL2Tiles(object): +def exit_with_error(message: str, details: str = "") -> NoReturn: + # Message printing and exit code kept from the way it worked using the OptionParser (in case + # someone parses the error output) + sys.stderr.write("Usage: gdal2tiles.py [options] input_file [output]\n\n") + sys.stderr.write("gdal2tiles.py: error: %s\n" % message) + if details: + sys.stderr.write("\n\n%s\n" % details) - def process(self): - """The main processing function, runs all the main steps of processing""" + sys.exit(2) - # Opening and preprocessing of the input file - self.open_input() - # Generation of main metadata files and HTML viewers - self.generate_metadata() +def set_cache_max(cache_in_bytes: int) -> None: + # We set the maximum using `SetCacheMax` and `GDAL_CACHEMAX` to support both fork and spawn as multiprocessing start methods. + # https://github.com/OSGeo/gdal/pull/2112 + os.environ["GDAL_CACHEMAX"] = "%d" % int(cache_in_bytes / 1024 / 1024) + gdal.SetCacheMax(cache_in_bytes) - # 1bto4b - if self.isDEMtile: - for z in range(self.tminz, self.tmaxz + int(abs(math.log(self.tilesize, 2) - 8))): # 1bto4b - self.generate_base_tiles(z) - print(' Zoom ' + str(z) + ' tiles done!') - else: - # Generation of the lowest tiles - self.generate_base_tiles(self.tmaxz) - # Generation of the overview tiles (higher in the pyramid) - self.generate_overview_tiles() +def generate_kml( + tx, ty, tz, tileext, tile_size, tileswne, options, children=None, **args +): + """ + Template for the KML. Returns filled string. + """ + if not children: + children = [] + + args["tx"], args["ty"], args["tz"] = tx, ty, tz + args["tileformat"] = tileext + if "tile_size" not in args: + args["tile_size"] = tile_size + + if "minlodpixels" not in args: + args["minlodpixels"] = int(args["tile_size"] / 2) + if "maxlodpixels" not in args: + args["maxlodpixels"] = int(args["tile_size"] * 8) + if children == []: + args["maxlodpixels"] = -1 + + if tx is None: + tilekml = False + args["xml_escaped_title"] = gdal.EscapeString( + options.title, gdal.CPLES_XML) + else: + tilekml = True + args["realtiley"] = GDAL2Tiles.getYTile(ty, tz, options) + args["xml_escaped_title"] = "%d/%d/%d.kml" % ( + tz, tx, args["realtiley"]) + args["south"], args["west"], args["north"], args["east"] = tileswne( + tx, ty, tz) + + if tx == 0: + args["drawOrder"] = 2 * tz + 1 + elif tx is not None: + args["drawOrder"] = 2 * tz + else: + args["drawOrder"] = 0 - def error(self, msg, details=""): - """Print an error message and stop the processing""" - if details: - self.parser.error(msg + "\n\n" + details) + url = options.url + if not url: + if tilekml: + url = "../../" else: - self.parser.error(msg) - - def progressbar(self, complete=0.0): - """Print progressbar for float value 0..1""" - gdal.TermProgress_nocb(complete) - - def gettempfilename(self, suffix): - """Returns a temporary filename""" - if '_' in os.environ: - # tempfile.mktemp() crashes on some Wine versions (the one of Ubuntu 12.04 particularly) - if os.environ['_'].find('wine') >= 0: - tmpdir = '.' - if 'TMP' in os.environ: - tmpdir = os.environ['TMP'] - import time - import random - random.seed(time.time()) - random_part = 'file%d' % random.randint(0, 1000000000) - return os.path.join(tmpdir, random_part + suffix) - - import tempfile - return tempfile.mktemp(suffix) - - def stop(self): - """Stop the rendering immediately""" - self.stopped = True - - def __init__(self, arguments): - """Constructor function - initialization""" - self.out_drv = None - self.mem_drv = None - self.in_ds = None - self.out_ds = None - self.out_srs = None - self.nativezoom = None - self.tminmax = None - self.tsize = None - self.mercator = None - self.geodetic = None - self.alphaband = None - self.dataBandsCount = None - self.out_gt = None - self.tileswne = None - self.swne = None - self.ominx = None - self.omaxx = None - self.omaxy = None - self.ominy = None - - # MMGIS - self.isRasterBounded = False - - # 1bto4b - self.isDEMtile = False + url = "" + + s = ( + """<?xml version="1.0" encoding="utf-8"?> +<kml xmlns="http://www.opengis.net/kml/2.2"> + <Document> + <name>%(xml_escaped_title)s</name> + <description></description> + <Style> + <ListStyle id="hideChildren"> + <listItemType>checkHideChildren</listItemType> + </ListStyle> + </Style>""" + % args + ) + if tilekml: + s += ( + """ + <Region> + <LatLonAltBox> + <north>%(north).14f</north> + <south>%(south).14f</south> + <east>%(east).14f</east> + <west>%(west).14f</west> + </LatLonAltBox> + <Lod> + <minLodPixels>%(minlodpixels)d</minLodPixels> + <maxLodPixels>%(maxlodpixels)d</maxLodPixels> + </Lod> + </Region> + <GroundOverlay> + <drawOrder>%(drawOrder)d</drawOrder> + <Icon> + <href>%(realtiley)d.%(tileformat)s</href> + </Icon> + <LatLonBox> + <north>%(north).14f</north> + <south>%(south).14f</south> + <east>%(east).14f</east> + <west>%(west).14f</west> + </LatLonBox> + </GroundOverlay> +""" + % args + ) - # MMGIS - self.fminx = None - self.fmaxx = None - self.fminy = None - self.fmaxy = None - self.fPixelSize = None + for cx, cy, cz in children: + csouth, cwest, cnorth, ceast = tileswne(cx, cy, cz) + ytile = GDAL2Tiles.getYTile(cy, cz, options) + s += """ + <NetworkLink> + <name>%d/%d/%d.%s</name> + <Region> + <LatLonAltBox> + <north>%.14f</north> + <south>%.14f</south> + <east>%.14f</east> + <west>%.14f</west> + </LatLonAltBox> + <Lod> + <minLodPixels>%d</minLodPixels> + <maxLodPixels>-1</maxLodPixels> + </Lod> + </Region> + <Link> + <href>%s%d/%d/%d.kml</href> + <viewRefreshMode>onRegion</viewRefreshMode> + <viewFormat/> + </Link> + </NetworkLink> + """ % ( + cz, + cx, + ytile, + args["tileformat"], + cnorth, + csouth, + ceast, + cwest, + args["minlodpixels"], + url, + cz, + cx, + ytile, + ) - self.stopped = False - self.input = None - self.output = None + s += """ </Document> +</kml> + """ + return s - # Tile format - self.tilesize = 256 - self.tiledriver = 'PNG' - self.tileext = 'png' - # Should we read bigger window of the input raster and scale it down? - # Note: Modified later by open_input() - # Not for 'near' resampling - # Not for Wavelet based drivers (JPEG2000, ECW, MrSID) - # Not for 'raster' profile - self.scaledquery = True - # How big should be query window be for scaling down - # Later on reset according the chosen resampling algorightm - self.querysize = 4 * self.tilesize +def scale_query_to_tile(dsquery, dstile, options, tilefilename=""): + """Scales down query dataset to the tile dataset""" - # Should we use Read on the input file for generating overview tiles? - # Note: Modified later by open_input() - # Otherwise the overview tiles are generated from existing underlying tiles - self.overviewquery = False + querysize = dsquery.RasterXSize + tile_size = dstile.RasterXSize + tilebands = dstile.RasterCount - # RUN THE ARGUMENT PARSER: + if options.resampling == "average": - self.optparse_init() - self.options, self.args = self.parser.parse_args(args=arguments) - if not self.args: - self.error("No input file specified") + # Function: gdal.RegenerateOverview() + for i in range(1, tilebands + 1): + # Black border around NODATA + res = gdal.RegenerateOverview( + dsquery.GetRasterBand(i), dstile.GetRasterBand(i), "average" + ) + if res != 0: + exit_with_error( + "RegenerateOverview() failed on %s, error %d" % (tilefilename, res) + ) - # POSTPROCESSING OF PARSED ARGUMENTS: + elif options.resampling == "antialias" and numpy_available: - # Workaround for old versions of GDAL - try: - if ((self.options.verbose and self.options.resampling == 'near') or - gdal.TermProgress_nocb): - pass - except Exception: - self.error( - "This version of GDAL is not supported. Please upgrade to 1.6+.") + if tilefilename.startswith("/vsi"): + raise Exception( + "Outputting to /vsi file systems with antialias mode is not supported" + ) - # Is output directory the last argument? + # Scaling by PIL (Python Imaging Library) - improved Lanczos + array = numpy.zeros((querysize, querysize, tilebands), numpy.uint8) + for i in range(tilebands): + array[:, :, i] = gdalarray.BandReadAsArray( + dsquery.GetRasterBand(i + 1), 0, 0, querysize, querysize + ) + im = Image.fromarray(array, "RGBA") # Always four bands + im1 = im.resize((tile_size, tile_size), Image.LANCZOS) + if os.path.exists(tilefilename): + im0 = Image.open(tilefilename) + im1 = Image.composite(im1, im0, im1) + + params = {} + if options.tiledriver == "WEBP": + if options.webp_lossless: + params["lossless"] = True + else: + params["quality"] = options.webp_quality + im1.save(tilefilename, options.tiledriver, **params) - # Test output directory, if it doesn't exist - if (os.path.isdir(self.args[-1]) or - (len(self.args) > 1 and not os.path.exists(self.args[-1]))): - self.output = self.args[-1] - self.args = self.args[:-1] + # MMGIS + elif options.resampling == "near-composite" and numpy_available: - # More files on the input not directly supported yet + if tilefilename.startswith("/vsi"): + raise Exception( + "Outputting to /vsi file systems with near-composite mode is not supported" + ) - if (len(self.args) > 1): - self.error("Processing of several input files is not supported.", - "Please first use a tool like gdal_vrtmerge.py or gdal_merge.py on the " - "files: gdal_vrtmerge.py -o merged.vrt %s" % " ".join(self.args)) + # Scaling by PIL (Python Imaging Library) - nearest + array = numpy.zeros((querysize, querysize, tilebands), numpy.uint8) + for i in range(tilebands): + array[:, :, i] = gdalarray.BandReadAsArray( + dsquery.GetRasterBand(i + 1), 0, 0, querysize, querysize + ) + im = Image.fromarray(array, "RGBA") # Always four bands + im1 = im.resize((tile_size, tile_size), Image.NEAREST) + + if os.path.exists(tilefilename): + im0 = Image.open(tilefilename) + + # Make mask, nodatas to alpha + nodataPixel = False + if options.srcnodata is not None: + f = str(binary(float(options.srcnodata))) + nodataPixel = [int(f[:8], 2), int(f[8:16], 2), + (int(f[16:24], 2)), int(f[24:], 2)] + + if nodataPixel is not False: + for rowI in range(len(array)): + for pixelI in range(len(array[rowI])): + if array[rowI][pixelI][0] == nodataPixel[0] and array[rowI][pixelI][1] == nodataPixel[1] and array[rowI][pixelI][2] == nodataPixel[2] and array[rowI][pixelI][3] == nodataPixel[3]: + array[rowI][pixelI] = [0, 0, 0, 0] + elif array[rowI][pixelI][0] == 0 and array[rowI][pixelI][1] == 0 and array[rowI][pixelI][2] == 0 and array[rowI][pixelI][3] == 0: + array[rowI][pixelI] = [0, 0, 0, 0] + else: + array[rowI][pixelI] = [255, 255, 255, 255] - self.input = self.args[0] + imMask = Image.fromarray(array, "RGBA") # Always four bands + im1Mask = imMask.resize((tile_size, tile_size), Image.NEAREST) - # MMGIS - if self.options.extentworld: - extentworld = self.options.extentworld.split(",") - self.isRasterBounded = True - self.fminx = float(extentworld[0]) - self.fmaxx = float(extentworld[2]) - self.fminy = float(extentworld[3]) - self.fmaxy = float(extentworld[1]) - self.fPixelSize = float(extentworld[4]) + im1 = Image.composite(im1, im0, im1Mask) - # 1bto4b - if self.options.isDEMtile: - self.isDEMtile = True - self.tilesize = 32 - self.querysize = 4 * self.tilesize - - # Default values for not given options - - if not self.output: - # Directory with input filename without extension in actual directory - self.output = os.path.splitext(os.path.basename(self.input))[0] - - if not self.options.title: - self.options.title = os.path.basename(self.input) - - if self.options.url and not self.options.url.endswith('/'): - self.options.url += '/' - if self.options.url: - self.options.url += os.path.basename(self.output) + '/' - - # Supported options - - self.resampling = None - - if self.options.resampling == 'average': - try: - if gdal.RegenerateOverview: - pass - except Exception: - self.error("'average' resampling algorithm is not available.", - "Please use -r 'near' argument or upgrade to newer version of GDAL.") - - elif self.options.resampling == 'antialias': - try: - if numpy: # pylint:disable=W0125 - pass - except Exception: - self.error("'antialias' resampling algorithm is not available.", - "Install PIL (Python Imaging Library) and numpy.") - - elif self.options.resampling == 'near': - self.resampling = gdal.GRA_NearestNeighbour - self.querysize = self.tilesize - - elif self.options.resampling == 'bilinear': - self.resampling = gdal.GRA_Bilinear - self.querysize = self.tilesize * 2 - - elif self.options.resampling == 'cubic': - self.resampling = gdal.GRA_Cubic - - elif self.options.resampling == 'cubicspline': - self.resampling = gdal.GRA_CubicSpline - - elif self.options.resampling == 'lanczos': - self.resampling = gdal.GRA_Lanczos - - # User specified zoom levels - self.tminz = None - self.tmaxz = None - if self.options.zoom: - minmax = self.options.zoom.split('-', 1) - minmax.extend(['']) - zoom_min, zoom_max = minmax[:2] - self.tminz = int(zoom_min) - if zoom_max: - self.tmaxz = int(zoom_max) + params = {} + if options.tiledriver == "WEBP": + if options.webp_lossless: + params["lossless"] = True else: - self.tmaxz = int(zoom_min) + params["quality"] = options.webp_quality + im1.save(tilefilename, options.tiledriver, **params) - # KML generation - self.kml = self.options.kml + else: + if options.resampling == "near": + gdal_resampling = gdal.GRA_NearestNeighbour - # Check if the input filename is full ascii or not - try: - os.path.basename(self.input).encode('ascii') - except UnicodeEncodeError: - full_ascii = False - else: - full_ascii = True - - # LC_CTYPE check - if not full_ascii and 'UTF-8' not in os.environ.get("LC_CTYPE", ""): - if not self.options.quiet: - print("\nWARNING: " - "You are running gdal2tiles.py with a LC_CTYPE environment variable that is " - "not UTF-8 compatible, and your input file contains non-ascii characters. " - "The generated sample googlemaps, openlayers or " - "leaflet files might contain some invalid characters as a result\n") - - # Output the results - if self.options.verbose: - print("Options:", self.options) - print("Input:", self.input) - print("Output:", self.output) - print("Cache: %s MB" % (gdal.GetCacheMax() / 1024 / 1024)) - print('') - - def optparse_init(self): - """Prepare the option parser for input (argv)""" - - from optparse import OptionParser, OptionGroup - usage = "Usage: %prog [options] input_file(s) [output]" - p = OptionParser(usage, version="%prog " + __version__) - p.add_option("-p", "--profile", dest='profile', - type='choice', choices=profile_list, - help=("Tile cutting profile (%s) - default 'mercator' " - "(Google Maps compatible)" % ",".join(profile_list))) - p.add_option("-r", "--resampling", dest="resampling", - type='choice', choices=resampling_list, - help="Resampling method (%s) - default 'average'" % ",".join(resampling_list)) - p.add_option('-s', '--s_srs', dest="s_srs", metavar="SRS", - help="The spatial reference system used for the source input data") - p.add_option('-z', '--zoom', dest="zoom", - help="Zoom levels to render (format:'2-5' or '10').") - p.add_option('-e', '--resume', dest="resume", action="store_true", - help="Resume mode. Generate only missing files.") - p.add_option('-a', '--srcnodata', dest="srcnodata", metavar="NODATA", - help="NODATA transparency value to assign to the input data") - p.add_option('-d', '--tmscompatible', dest="tmscompatible", action="store_true", - help=("When using the geodetic profile, specifies the base resolution " - "as 0.703125 or 2 tiles at zoom level 0.")) - p.add_option("-v", "--verbose", - action="store_true", dest="verbose", - help="Print status messages to stdout") - p.add_option("-q", "--quiet", - action="store_true", dest="quiet", - help="Disable messages and status to stdout") - # MMGIS - p.add_option("-x", "--extentworld", dest="extentworld", - help="The full world meter extent (comma-separated as minx,maxx,miny,maxy,pixelsize) of an inner raster profile.") - # 1bto4b - p.add_option("-m", "--dem", action="store_true", dest="isDEMtile", - help="Indicate if the input is a Digital Elevation Model") - # KML options - g = OptionGroup(p, "KML (Google Earth) options", - "Options for generated Google Earth SuperOverlay metadata") - g.add_option("-k", "--force-kml", dest='kml', action="store_true", - help=("Generate KML for Google Earth - default for 'geodetic' profile and " - "'raster' in EPSG:4326. For a dataset with different projection use " - "with caution!")) - g.add_option("-n", "--no-kml", dest='kml', action="store_false", - help="Avoid automatic generation of KML files for EPSG:4326") - g.add_option("-u", "--url", dest='url', - help="URL address where the generated tiles are going to be published") - p.add_option_group(g) - - # HTML options - g = OptionGroup(p, "Web viewer options", - "Options for generated HTML viewers a la Google Maps") - g.add_option("-w", "--webviewer", dest='webviewer', type='choice', choices=webviewer_list, - help="Web viewer to generate (%s) - default 'all'" % ",".join(webviewer_list)) - g.add_option("-t", "--title", dest='title', - help="Title of the map") - g.add_option("-c", "--copyright", dest='copyright', - help="Copyright for the map") - g.add_option("-g", "--googlekey", dest='googlekey', - help="Google Maps API key from http://code.google.com/apis/maps/signup.html") - g.add_option("-b", "--bingkey", dest='bingkey', - help="Bing Maps API key from https://www.bingmapsportal.com/") - p.add_option_group(g) - - p.set_defaults(verbose=False, profile="mercator", kml=False, url='', - webviewer='all', copyright='', resampling='average', resume=False, - googlekey='INSERT_YOUR_KEY_HERE', bingkey='INSERT_YOUR_KEY_HERE') - - self.parser = p + elif options.resampling == "bilinear": + gdal_resampling = gdal.GRA_Bilinear - # ------------------------------------------------------------------------- - def open_input(self): - """Initialization of the input raster, reprojection if necessary""" - gdal.AllRegister() + elif options.resampling == "cubic": + gdal_resampling = gdal.GRA_Cubic - self.out_drv = gdal.GetDriverByName(self.tiledriver) - self.mem_drv = gdal.GetDriverByName('MEM') + elif options.resampling == "cubicspline": + gdal_resampling = gdal.GRA_CubicSpline - if not self.out_drv: - raise Exception("The '%s' driver was not found, is it available in this GDAL build?", - self.tiledriver) - if not self.mem_drv: - raise Exception( - "The 'MEM' driver was not found, is it available in this GDAL build?") + elif options.resampling == "lanczos": + gdal_resampling = gdal.GRA_Lanczos - # Open the input file + elif options.resampling == "mode": + gdal_resampling = gdal.GRA_Mode - if self.input: - self.in_ds = gdal.Open(self.input, gdal.GA_ReadOnly) - else: - raise Exception("No input file was specified") + elif options.resampling == "max": + gdal_resampling = gdal.GRA_Max - if self.options.verbose: - print("Input file:", - "( %sP x %sL - %s bands)" % (self.in_ds.RasterXSize, self.in_ds.RasterYSize, - self.in_ds.RasterCount)) + elif options.resampling == "min": + gdal_resampling = gdal.GRA_Min - if not self.in_ds: - # Note: GDAL prints the ERROR message too - self.error( - "It is not possible to open the input file '%s'." % self.input) + elif options.resampling == "med": + gdal_resampling = gdal.GRA_Med - # Read metadata from the input file - if self.in_ds.RasterCount == 0: - self.error("Input file '%s' has no raster band" % self.input) - - if self.in_ds.GetRasterBand(1).GetRasterColorTable(): - self.error("Please convert this file to RGB/RGBA and run gdal2tiles on the result.", - "From paletted file you can create RGBA file (temp.vrt) by:\n" - "gdal_translate -of vrt -expand rgba %s temp.vrt\n" - "then run:\n" - "gdal2tiles temp.vrt" % self.input) - - # Get NODATA value - in_nodata = [] - for i in range(1, self.in_ds.RasterCount+1): - if self.in_ds.GetRasterBand(i).GetNoDataValue() is not None: - in_nodata.append(self.in_ds.GetRasterBand(i).GetNoDataValue()) - if self.options.srcnodata: - nds = list(map(float, self.options.srcnodata.split(','))) - if len(nds) < self.in_ds.RasterCount: - in_nodata = ( - nds * self.in_ds.RasterCount)[:self.in_ds.RasterCount] - else: - in_nodata = nds + elif options.resampling == "q1": + gdal_resampling = gdal.GRA_Q1 - if self.options.verbose: - print("NODATA: %s" % in_nodata) + elif options.resampling == "q3": + gdal_resampling = gdal.GRA_Q3 - if self.options.verbose: - print("Preprocessed file:", - "( %sP x %sL - %s bands)" % (self.in_ds.RasterXSize, self.in_ds.RasterYSize, - self.in_ds.RasterCount)) + # Other algorithms are implemented by gdal.ReprojectImage(). + dsquery.SetGeoTransform( + ( + 0.0, + tile_size / float(querysize), + 0.0, + 0.0, + 0.0, + tile_size / float(querysize), + ) + ) + dstile.SetGeoTransform((0.0, 1.0, 0.0, 0.0, 0.0, 1.0)) - in_srs = None + res = gdal.ReprojectImage(dsquery, dstile, None, None, gdal_resampling) + if res != 0: + exit_with_error( + "ReprojectImage() failed on %s, error %d" % (tilefilename, res) + ) - if self.options.s_srs: - in_srs = osr.SpatialReference() - in_srs.SetFromUserInput(self.options.s_srs) - in_srs_wkt = in_srs.ExportToWkt() - else: - in_srs_wkt = self.in_ds.GetProjection() - if not in_srs_wkt and self.in_ds.GetGCPCount() != 0: - in_srs_wkt = self.in_ds.GetGCPProjection() - if in_srs_wkt: - in_srs = osr.SpatialReference() - in_srs.ImportFromWkt(in_srs_wkt) - - self.out_srs = osr.SpatialReference() - - if self.options.profile == 'mercator': - self.out_srs.ImportFromEPSG(3857) - elif self.options.profile == 'geodetic': - self.out_srs.ImportFromEPSG(4326) + +def setup_no_data_values(input_dataset: gdal.Dataset, options: Options) -> List[float]: + """ + Extract the NODATA values from the dataset or use the passed arguments as override if any + """ + in_nodata = [] + if options.srcnodata: + nds = list(map(float, options.srcnodata.split(","))) + if len(nds) < input_dataset.RasterCount: + in_nodata = ( + nds * input_dataset.RasterCount)[: input_dataset.RasterCount] else: - self.out_srs = in_srs + in_nodata = nds + else: + for i in range(1, input_dataset.RasterCount + 1): + band = input_dataset.GetRasterBand(i) + raster_no_data = band.GetNoDataValue() + if raster_no_data is not None: + # Ignore nodata values that are not in the range of the band data type (see https://github.com/OSGeo/gdal/pull/2299) + if band.DataType == gdal.GDT_Byte and ( + raster_no_data != int(raster_no_data) + or raster_no_data < 0 + or raster_no_data > 255 + ): + # We should possibly do similar check for other data types + in_nodata = [] + break + in_nodata.append(raster_no_data) - # Are the reference systems the same? Reproject if necessary. + if options.verbose: + print("NODATA: %s" % in_nodata) - self.out_ds = None + return in_nodata - if self.options.profile in ('mercator', 'geodetic'): - if ((self.in_ds.GetGeoTransform() == (0.0, 1.0, 0.0, 0.0, 0.0, 1.0)) and - (self.in_ds.GetGCPCount() == 0)): - self.error("There is no georeference - neither affine transformation (worldfile) " - "nor GCPs. You can generate only 'raster' profile tiles.", - "Either gdal2tiles with parameter -p 'raster' or use another GIS " - "software for georeference e.g. gdal_transform -gcp / -a_ullr / -a_srs") +def setup_input_srs( + input_dataset: gdal.Dataset, options: Options +) -> Tuple[Optional[osr.SpatialReference], Optional[str]]: + """ + Determines and returns the Input Spatial Reference System (SRS) as an osr object and as a + WKT representation - if in_srs: - if ((in_srs.ExportToProj4() != self.out_srs.ExportToProj4()) or - (self.in_ds.GetGCPCount() != 0)): - # Generation of VRT dataset in tile projection, - # default 'nearest neighbour' warping - self.out_ds = gdal.AutoCreateWarpedVRT( - self.in_ds, in_srs_wkt, self.out_srs.ExportToWkt()) + Uses in priority the one passed in the command line arguments. If None, tries to extract them + from the input dataset + """ - if self.options.verbose: - print("Warping of the raster by AutoCreateWarpedVRT " - "(result saved into 'tiles.vrt')") - self.out_ds.GetDriver().CreateCopy("tiles.vrt", self.out_ds) - - # Correction of AutoCreateWarpedVRT for NODATA values - if in_nodata != []: - tempfilename = self.gettempfilename('-gdal2tiles.vrt') - self.out_ds.GetDriver().CreateCopy(tempfilename, self.out_ds) - # open as a text file - s = open(tempfilename).read() - # Add the warping options - s = s.replace( - "<GDALWarpOptions>", - """ - <GDALWarpOptions> - <Option name="INIT_DEST">NO_DATA</Option> - <Option name="UNIFIED_SRC_NODATA">YES</Option> - """) - # replace BandMapping tag for NODATA bands.... - for i in range(len(in_nodata)): - s = s.replace( - '<BandMapping src="%i" dst="%i"/>' % ( - (i+1), (i+1)), - """ - <BandMapping src="%i" dst="%i"> - <SrcNoDataReal>%i</SrcNoDataReal> - <SrcNoDataImag>0</SrcNoDataImag> - <DstNoDataReal>%i</DstNoDataReal> - <DstNoDataImag>0</DstNoDataImag> - </BandMapping> - """ % ((i+1), (i+1), in_nodata[i], in_nodata[i])) - # save the corrected VRT - open(tempfilename, "w").write(s) - # open by GDAL as self.out_ds - self.out_ds = gdal.Open(tempfilename) - # delete the temporary file - os.unlink(tempfilename) - - # set NODATA_VALUE metadata - self.out_ds.SetMetadataItem( - 'NODATA_VALUES', ' '.join([str(i) for i in in_nodata])) - - if self.options.verbose: - print("Modified warping result saved into 'tiles1.vrt'") - open("tiles1.vrt", "w").write(s) - - # Correction of AutoCreateWarpedVRT for Mono (1 band) and RGB (3 bands) files - # without NODATA: - # equivalent of gdalwarp -dstalpha - if in_nodata == [] and self.out_ds.RasterCount in [1, 3]: - tempfilename = self.gettempfilename('-gdal2tiles.vrt') - self.out_ds.GetDriver().CreateCopy(tempfilename, self.out_ds) - # open as a text file - s = open(tempfilename).read() - # Add the warping options - s = s.replace( - "<BlockXSize>", - """ - <VRTRasterBand dataType="Byte" band="%i" subClass="VRTWarpedRasterBand"> - <ColorInterp>Alpha</ColorInterp> - </VRTRasterBand> - <BlockXSize> - """ % (self.out_ds.RasterCount + 1)) - s = s.replace( - "</GDALWarpOptions>", - """ - <DstAlphaBand>%i</DstAlphaBand> - </GDALWarpOptions> - """ % (self.out_ds.RasterCount + 1)) - s = s.replace( - "</WorkingDataType>", - """ - </WorkingDataType> - <Option name="INIT_DEST">0</Option> - """) - # save the corrected VRT - open(tempfilename, "w").write(s) - # open by GDAL as self.out_ds - self.out_ds = gdal.Open(tempfilename) - # delete the temporary file - os.unlink(tempfilename) - - if self.options.verbose: - print( - "Modified -dstalpha warping result saved into 'tiles1.vrt'") - open("tiles1.vrt", "w").write(s) - s = ''' - ''' + input_srs = None + input_srs_wkt = None - else: - self.error("Input file has unknown SRS.", - "Use --s_srs ESPG:xyz (or similar) to provide source reference system.") - - if self.out_ds and self.options.verbose: - print("Projected file:", "tiles.vrt", "( %sP x %sL - %s bands)" % ( - self.out_ds.RasterXSize, self.out_ds.RasterYSize, self.out_ds.RasterCount)) - - if not self.out_ds: - self.out_ds = self.in_ds - - # - # Here we should have a raster (out_ds) in the correct Spatial Reference system - # - - # Get alpha band (either directly or from NODATA value) - self.alphaband = self.out_ds.GetRasterBand(1).GetMaskBand() - if ((self.alphaband.GetMaskFlags() & gdal.GMF_ALPHA) or - self.out_ds.RasterCount == 4 or - self.out_ds.RasterCount == 2): - self.dataBandsCount = self.out_ds.RasterCount - 1 - else: - self.dataBandsCount = self.out_ds.RasterCount + if options.s_srs: + input_srs = osr.SpatialReference() + input_srs.SetFromUserInput(options.s_srs) + input_srs_wkt = input_srs.ExportToWkt() + else: + input_srs_wkt = input_dataset.GetProjection() + if not input_srs_wkt and input_dataset.GetGCPCount() != 0: + input_srs_wkt = input_dataset.GetGCPProjection() + if input_srs_wkt: + input_srs = osr.SpatialReference() + input_srs.ImportFromWkt(input_srs_wkt) - # KML test - isepsg4326 = False - srs4326 = osr.SpatialReference() - srs4326.ImportFromEPSG(4326) - if self.out_srs and srs4326.ExportToProj4() == self.out_srs.ExportToProj4(): - self.kml = True - isepsg4326 = True - if self.options.verbose: - print("KML autotest OK!") + if input_srs is not None: + input_srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER) - # Read the georeference - self.out_gt = self.out_ds.GetGeoTransform() + return input_srs, input_srs_wkt - # Test the size of the pixel - # Report error in case rotation/skew is in geotransform (possible only in 'raster' profile) - if (self.out_gt[2], self.out_gt[4]) != (0, 0): - self.error("Georeference of the raster contains rotation or skew. " - "Such raster is not supported. Please use gdalwarp first.") +def setup_output_srs( + input_srs: Optional[osr.SpatialReference], options: Options +) -> Optional[osr.SpatialReference]: + """ + Setup the desired SRS (based on options) + """ + output_srs = osr.SpatialReference() + + if options.profile == "mercator": + output_srs.ImportFromEPSG(3857) + elif options.profile == "geodetic": + output_srs.ImportFromEPSG(4326) + elif options.profile == "raster": + output_srs = input_srs + else: + output_srs = tmsMap[options.profile].srs.Clone() - # Here we expect: pixel is square, no rotation on the raster + if output_srs: + output_srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER) - # Output Bounds - coordinates in the output SRS - self.ominx = self.out_gt[0] - self.omaxx = self.out_gt[0] + self.out_ds.RasterXSize * self.out_gt[1] - self.omaxy = self.out_gt[3] - self.ominy = self.out_gt[3] - self.out_ds.RasterYSize * self.out_gt[1] + return output_srs - # Note: maybe round(x, 14) to avoid the gdal_translate behaviour, when 0 becomes -1e-15 - # MMGIS - def linearScale(domain, rang, value): - return ( - ((rang[1] - rang[0]) * (value - domain[0])) / - (domain[1] - domain[0]) + - rang[0] - ) - # MMGIS - self.out_ds.fRasterXSize = self.out_ds.RasterXSize - self.out_ds.fRasterYSize = self.out_ds.RasterYSize - self.out_ds.fRasterXOrigin = 0 - self.out_ds.fRasterYOrigin = 0 - self.out_ds.PixelSize = self.out_gt[1] - self.out_ds.fPixelSize = self.fPixelSize - # print("ominx", self.ominx, "omaxx", self.omaxx, "ominy", self.ominy, "omaxy", self.omaxy) - # print("fminx", self.fminx, "fmaxx", self.fmaxx, "fminy", self.fminy, "fmaxy", self.fmaxy) - if self.isRasterBounded: - self.out_ds.fRasterXSize = int(math.floor(self.out_ds.RasterXSize * (self.fmaxx - self.fminx) / ( - self.omaxx - self.ominx) * (self.out_ds.PixelSize / self.out_ds.fPixelSize))) - self.out_ds.fRasterYSize = int(math.ceil(self.out_ds.RasterYSize * (self.fmaxy - self.fminy) / ( - self.omaxy - self.ominy) * (self.out_ds.PixelSize / self.out_ds.fPixelSize))) - self.out_ds.fRasterXSizeRaw = int(math.floor( - self.out_ds.RasterXSize * (self.fmaxx - self.fminx) / (self.omaxx - self.ominx))) - self.out_ds.fRasterYSizeRaw = int(math.ceil( - self.out_ds.RasterYSize * (self.fmaxy - self.fminy) / (self.omaxy - self.ominy))) - # print("Full Raster Size: ", self.out_ds.fRasterXSize, self.out_ds.fRasterYSize ) - self.out_ds.fRasterXOrigin = int(math.floor(linearScale( - [self.fminx, self.fmaxx], [0, self.out_ds.fRasterXSize], self.out_gt[0]))) - self.out_ds.fRasterYOrigin = int(math.ceil(linearScale( - [self.fminy, self.fmaxy], [self.out_ds.fRasterYSize, 0], self.out_gt[3]))) - self.out_ds.fRasterXOriginRaw = int(math.floor(linearScale([self.fminx, self.fmaxx], [ - 0, self.out_ds.fRasterXSize], self.out_gt[0]) * (self.out_ds.fPixelSize / self.out_ds.PixelSize))) - self.out_ds.fRasterYOriginRaw = int(math.ceil(linearScale([self.fminy, self.fmaxy], [ - self.out_ds.fRasterYSize, 0], self.out_gt[3]) * (self.out_ds.fPixelSize / self.out_ds.PixelSize))) - self.out_ds.fRasterXWidth = int(math.floor(linearScale( - [self.fminx, self.fmaxx], [0, self.out_ds.fRasterXSize], self.omaxx))) - self.out_ds.fRasterXOrigin - self.out_ds.fRasterYHeight = int(math.ceil(linearScale( - [self.fminy, self.fmaxy], [0, self.out_ds.fRasterYSize], self.omaxy))) - self.out_ds.fRasterYOrigin +def has_georeference(dataset: gdal.Dataset) -> bool: + return ( + dataset.GetGeoTransform() != (0.0, 1.0, 0.0, 0.0, 0.0, 1.0) + or dataset.GetGCPCount() != 0 + ) - if self.options.verbose: - print("Bounds (output srs):", round(self.ominx, 13), - self.ominy, self.omaxx, self.omaxy) - # print("Input Raster Size: ", self.out_ds.RasterXSize, self.out_ds.RasterYSize) - # print("fmaxx-fminx", self.fmaxx - self.fminx, "omaxx-ominx", self.omaxx - self.ominx, "fmaxy-fminy", self.fmaxy - self.fminy, "omaxy-ominy", self.omaxy - self.ominy) - # print("Full Raster Size: ", self.out_ds.fRasterXSize, self.out_ds.fRasterYSize) - # print("Full Raster Size Raw: ", self.out_ds.fRasterXSizeRaw, self.out_ds.fRasterYSizeRaw) - # print("Raster Origin: ", self.out_ds.fRasterXOrigin, self.out_ds.fRasterYOrigin) - # print("Raster Origin Raw: ", self.out_ds.fRasterXOriginRaw, self.out_ds.fRasterYOriginRaw) - # print("Raster Width Height: ", self.out_ds.fRasterXWidth, self.out_ds.fRasterYHeight) +def reproject_dataset( + from_dataset: gdal.Dataset, + from_srs: Optional[osr.SpatialReference], + to_srs: Optional[osr.SpatialReference], + options: Optional[Options] = None, +) -> gdal.Dataset: + """ + Returns the input dataset in the expected "destination" SRS. + If the dataset is already in the correct SRS, returns it unmodified + """ + if not from_srs or not to_srs: + raise GDALError( + "from and to SRS must be defined to reproject the dataset") + + if (from_srs.ExportToProj4() != to_srs.ExportToProj4()) or ( + from_dataset.GetGCPCount() != 0 + ): + + if ( + from_srs.IsGeographic() + and to_srs.GetAuthorityName(None) == "EPSG" + and to_srs.GetAuthorityCode(None) == "3857" + ): + from_gt = from_dataset.GetGeoTransform(can_return_null=True) + if from_gt and from_gt[2] == 0 and from_gt[4] == 0 and from_gt[5] < 0: + maxlat = from_gt[3] + minlat = from_gt[3] + from_dataset.RasterYSize * from_gt[5] + MAX_LAT = 85.0511287798066 + adjustBounds = False + if maxlat > MAX_LAT: + maxlat = MAX_LAT + adjustBounds = True + if minlat < -MAX_LAT: + minlat = -MAX_LAT + adjustBounds = True + if adjustBounds: + ct = osr.CoordinateTransformation(from_srs, to_srs) + west, south = ct.TransformPoint(from_gt[0], minlat)[:2] + east, north = ct.TransformPoint( + from_gt[0] + from_dataset.RasterXSize * + from_gt[1], maxlat + )[:2] + return gdal.Warp( + "", + from_dataset, + format="VRT", + outputBounds=[west, south, east, north], + dstSRS="EPSG:3857", + ) + + to_dataset = gdal.AutoCreateWarpedVRT( + from_dataset, from_srs.ExportToWkt(), to_srs.ExportToWkt() + ) - # Calculating ranges for tiles in different zoom levels - if self.options.profile == 'mercator': + if options and options.verbose: + print( + "Warping of the raster by AutoCreateWarpedVRT (result saved into 'tiles.vrt')" + ) + to_dataset.GetDriver().CreateCopy("tiles.vrt", to_dataset) - self.mercator = GlobalMercator() + return to_dataset + else: + return from_dataset - # Function which generates SWNE in LatLong for given tile - self.tileswne = self.mercator.TileLatLonBounds - # Generate table with min max tile coordinates for all zoomlevels - self.tminmax = list(range(0, 32)) - for tz in range(0, 32): - tminx, tminy = self.mercator.MetersToTile( - self.ominx, self.ominy, tz) - tmaxx, tmaxy = self.mercator.MetersToTile( - self.omaxx, self.omaxy, tz) - # crop tiles extending world limits (+-180,+-90) - tminx, tminy = max(0, tminx), max(0, tminy) - tmaxx, tmaxy = min(2**tz-1, tmaxx), min(2**tz-1, tmaxy) - self.tminmax[tz] = (tminx, tminy, tmaxx, tmaxy) +def add_gdal_warp_options_to_string(vrt_string, warp_options): + if not warp_options: + return vrt_string - # TODO: Maps crossing 180E (Alaska?) + vrt_root = ElementTree.fromstring(vrt_string) + options = vrt_root.find("GDALWarpOptions") - # Get the minimal zoom level (map covers area equivalent to one tile) - if self.tminz is None: - self.tminz = self.mercator.ZoomForPixelSize( - self.out_gt[1] * max(self.out_ds.RasterXSize, - self.out_ds.RasterYSize) / float(self.tilesize)) + if options is None: + return vrt_string - # Get the maximal zoom level - # (closest possible zoom level up on the resolution of raster) - if self.tmaxz is None: - self.tmaxz = self.mercator.ZoomForPixelSize(self.out_gt[1]) + for key, value in warp_options.items(): + tb = ElementTree.TreeBuilder() + tb.start("Option", {"name": key}) + tb.data(value) + tb.end("Option") + elem = tb.close() + options.insert(0, elem) - if self.options.verbose: - print("Bounds (latlong):", - self.mercator.MetersToLatLon(self.ominx, self.ominy), - self.mercator.MetersToLatLon(self.omaxx, self.omaxy)) - print('MinZoomLevel:', self.tminz) - print("MaxZoomLevel:", - self.tmaxz, - "(", - self.mercator.Resolution(self.tmaxz), - ")") + return ElementTree.tostring(vrt_root).decode() - if self.options.profile == 'geodetic': - self.geodetic = GlobalGeodetic(self.options.tmscompatible) +def update_no_data_values( + warped_vrt_dataset: gdal.Dataset, + nodata_values: List[float], + options: Optional[Options] = None, +) -> gdal.Dataset: + """ + Takes an array of NODATA values and forces them on the WarpedVRT file dataset passed + """ + # TODO: gbataille - Seems that I forgot tests there + assert nodata_values != [] + + vrt_string = warped_vrt_dataset.GetMetadata("xml:VRT")[0] + + vrt_string = add_gdal_warp_options_to_string( + vrt_string, {"INIT_DEST": "NO_DATA", "UNIFIED_SRC_NODATA": "YES"} + ) + + # TODO: gbataille - check the need for this replacement. Seems to work without + # # replace BandMapping tag for NODATA bands.... + # for i in range(len(nodata_values)): + # s = s.replace( + # '<BandMapping src="%i" dst="%i"/>' % ((i+1), (i+1)), + # """ + # <BandMapping src="%i" dst="%i"> + # <SrcNoDataReal>%i</SrcNoDataReal> + # <SrcNoDataImag>0</SrcNoDataImag> + # <DstNoDataReal>%i</DstNoDataReal> + # <DstNoDataImag>0</DstNoDataImag> + # </BandMapping> + # """ % ((i+1), (i+1), nodata_values[i], nodata_values[i])) + + corrected_dataset = gdal.Open(vrt_string) + + # set NODATA_VALUE metadata + corrected_dataset.SetMetadataItem( + "NODATA_VALUES", " ".join([str(i) for i in nodata_values]) + ) + + if options and options.verbose: + print("Modified warping result saved into 'tiles1.vrt'") + + with open("tiles1.vrt", "w") as f: + f.write(corrected_dataset.GetMetadata("xml:VRT")[0]) + + return corrected_dataset + + +def add_alpha_band_to_string_vrt(vrt_string: str) -> str: + # TODO: gbataille - Old code speak of this being equivalent to gdalwarp -dstalpha + # To be checked + + vrt_root = ElementTree.fromstring(vrt_string) + + index = 0 + nb_bands = 0 + for subelem in list(vrt_root): + if subelem.tag == "VRTRasterBand": + nb_bands += 1 + color_node = subelem.find("./ColorInterp") + if color_node is not None and color_node.text == "Alpha": + raise Exception("Alpha band already present") + else: + if nb_bands: + # This means that we are one element after the Band definitions + break + + index += 1 + + tb = ElementTree.TreeBuilder() + tb.start( + "VRTRasterBand", + { + "dataType": "Byte", + "band": str(nb_bands + 1), + "subClass": "VRTWarpedRasterBand", + }, + ) + tb.start("ColorInterp", {}) + tb.data("Alpha") + tb.end("ColorInterp") + tb.end("VRTRasterBand") + elem = tb.close() + + vrt_root.insert(index, elem) + + warp_options = vrt_root.find(".//GDALWarpOptions") + tb = ElementTree.TreeBuilder() + tb.start("DstAlphaBand", {}) + tb.data(str(nb_bands + 1)) + tb.end("DstAlphaBand") + elem = tb.close() + warp_options.append(elem) + + # TODO: gbataille - this is a GDALWarpOptions. Why put it in a specific place? + tb = ElementTree.TreeBuilder() + tb.start("Option", {"name": "INIT_DEST"}) + tb.data("0") + tb.end("Option") + elem = tb.close() + warp_options.append(elem) + + return ElementTree.tostring(vrt_root).decode() + + +def update_alpha_value_for_non_alpha_inputs( + warped_vrt_dataset: gdal.Dataset, options: Optional[Options] = None +) -> gdal.Dataset: + """ + Handles dataset with 1 or 3 bands, i.e. without alpha channel, in the case the nodata value has + not been forced by options + """ + if warped_vrt_dataset.RasterCount in [1, 3]: - # Function which generates SWNE in LatLong for given tile - self.tileswne = self.geodetic.TileLatLonBounds + vrt_string = warped_vrt_dataset.GetMetadata("xml:VRT")[0] - # Generate table with min max tile coordinates for all zoomlevels - self.tminmax = list(range(0, 32)) - for tz in range(0, 32): - tminx, tminy = self.geodetic.LonLatToTile( - self.ominx, self.ominy, tz) - tmaxx, tmaxy = self.geodetic.LonLatToTile( - self.omaxx, self.omaxy, tz) - # crop tiles extending world limits (+-180,+-90) - tminx, tminy = max(0, tminx), max(0, tminy) - tmaxx, tmaxy = min(2**(tz+1)-1, tmaxx), min(2**tz-1, tmaxy) - self.tminmax[tz] = (tminx, tminy, tmaxx, tmaxy) + vrt_string = add_alpha_band_to_string_vrt(vrt_string) - # TODO: Maps crossing 180E (Alaska?) + warped_vrt_dataset = gdal.Open(vrt_string) - # Get the maximal zoom level - # (closest possible zoom level up on the resolution of raster) - if self.tminz is None: - self.tminz = self.geodetic.ZoomForPixelSize( - self.out_gt[1] * max(self.out_ds.RasterXSize, - self.out_ds.RasterYSize) / float(self.tilesize)) + if options and options.verbose: + print("Modified -dstalpha warping result saved into 'tiles1.vrt'") - # Get the maximal zoom level - # (closest possible zoom level up on the resolution of raster) - if self.tmaxz is None: - self.tmaxz = self.geodetic.ZoomForPixelSize(self.out_gt[1]) + with open("tiles1.vrt", "w") as f: + f.write(warped_vrt_dataset.GetMetadata("xml:VRT")[0]) - if self.options.verbose: - print("Bounds (latlong):", self.ominx, - self.ominy, self.omaxx, self.omaxy) + return warped_vrt_dataset - # MMGIS - if self.options.profile == 'raster' and self.isRasterBounded: - def log2(x): - return math.log10(x) / math.log10(2) +def nb_data_bands(dataset: gdal.Dataset) -> int: + """ + Return the number of data (non-alpha) bands of a gdal dataset + """ + alphaband = dataset.GetRasterBand(1).GetMaskBand() + if ( + (alphaband.GetMaskFlags() & gdal.GMF_ALPHA) + or dataset.RasterCount == 4 + or dataset.RasterCount == 2 + ): + return dataset.RasterCount - 1 + return dataset.RasterCount + + +def _get_creation_options(options): + copts = [] + if options.tiledriver == "WEBP": + if options.webp_lossless: + copts = ["LOSSLESS=True"] + else: + copts = ["QUALITY=" + str(options.webp_quality)] + return copts - # MMGIS added 'f'* - self.nativezoom = int( - max(math.ceil(log2(self.out_ds.fRasterXSizeRaw/float(self.tilesize))), - math.ceil(log2(self.out_ds.fRasterYSizeRaw/float(self.tilesize))))) - self.basenativezoom = int( - max(math.ceil(log2(self.out_ds.fRasterXSize/float(self.tilesize))), - math.ceil(log2(self.out_ds.fRasterYSize/float(self.tilesize))))) +def create_base_tile(tile_job_info: "TileJobInfo", tile_detail: "TileDetail") -> None: + + dataBandsCount = tile_job_info.nb_data_bands + output = tile_job_info.output_file_path + tileext = tile_job_info.tile_extension + tile_size = tile_job_info.tile_size + options = tile_job_info.options + + cached_ds = getattr(threadLocal, "cached_ds", None) + if cached_ds and cached_ds.GetDescription() == tile_job_info.src_file: + ds = cached_ds + else: + ds = gdal.Open(tile_job_info.src_file, gdal.GA_ReadOnly) + threadLocal.cached_ds = ds + + mem_drv = gdal.GetDriverByName("MEM") + out_drv = gdal.GetDriverByName(tile_job_info.tile_driver) + alphaband = ds.GetRasterBand(1).GetMaskBand() + + tx = tile_detail.tx + ty = tile_detail.ty + tz = tile_detail.tz + rx = tile_detail.rx + ry = tile_detail.ry + rxsize = tile_detail.rxsize + rysize = tile_detail.rysize + wx = tile_detail.wx + wy = tile_detail.wy + wxsize = tile_detail.wxsize + wysize = tile_detail.wysize + querysize = tile_detail.querysize + + # MMGIS + isDEMtile = tile_detail.isDEMtile + + tilebands = dataBandsCount + 1 + + # MMGIS + if isDEMtile == True: + tilebands = 4 + + # Tile dataset in memory + tilefilename = os.path.join(output, str( + tz), str(tx), "%s.%s" % (ty, tileext)) + dstile = mem_drv.Create("", tile_size, tile_size, tilebands) + + data = alpha = None + + if options.verbose: + print( + "\tReadRaster Extent: ", (rx, ry, rxsize, + rysize), (wx, wy, wxsize, wysize) + ) + + # Query is in 'nearest neighbour' but can be bigger in then the tile_size + # We scale down the query to the tile_size by supplied algorithm. + if rxsize != 0 and rysize != 0 and wxsize != 0 and wysize != 0: + try: + alpha = alphaband.ReadRaster(rx, ry, rxsize, rysize, wxsize, wysize) + + # Detect totally transparent tile and skip its creation + if tile_job_info.exclude_transparent and len(alpha) == alpha.count( + "\x00".encode("ascii") + ): + return + + data = ds.ReadRaster( + rx, + ry, + rxsize, + rysize, + wxsize, + wysize, + band_list=list(range(1, dataBandsCount + 1)), + ) + except: + pass + + # The tile in memory is a transparent file by default. Write pixel values into it if + # any + if data: + # MMGIS + if isDEMtile: + dsquery = mem_drv.Create( + '', querysize, querysize, tilebands, gdal.GDT_Byte) # 1bto4b + + data = ds.GetRasterBand(1).ReadRaster( + rx, ry, rxsize, rysize, wxsize, wysize, buf_type=gdal.GDT_Float32) + + data = struct.unpack('f' * wxsize * wysize, data) + data1 = [] + data2 = [] + data3 = [] + data4 = [] + for f in data: + # Because 0 is a valid value in many datasets yet still special in images being fully transparent, + # we're going to encode zero's as 2^31 (2147483648) (79, 0, 0, 0) and have the reader parse it back to 0 + if f == 0: + f = pow(2, 31) + f = str(binary(f)) + data1.append(int(f[:8], 2)) + data2.append(int(f[8:16], 2)) + data3.append(int(f[16:24], 2)) + data4.append(int(f[24:], 2)) + + data1s = b'' + data2s = b'' + data3s = b'' + data4s = b'' + indx = 0 + for v in data1: + data1s += struct.pack('B', data1[indx]) + data2s += struct.pack('B', data2[indx]) + data3s += struct.pack('B', data3[indx]) + data4s += struct.pack('B', data4[indx]) + indx += 1 + + dsquery.WriteRaster( + wx, wy, wxsize, wysize, data1s, band_list=[1], buf_type=gdal.GDT_Byte) + dsquery.WriteRaster( + wx, wy, wxsize, wysize, data2s, band_list=[2], buf_type=gdal.GDT_Byte) + dsquery.WriteRaster( + wx, wy, wxsize, wysize, data3s, band_list=[3], buf_type=gdal.GDT_Byte) + dsquery.WriteRaster( + wx, wy, wxsize, wysize, data4s, band_list=[4], buf_type=gdal.GDT_Byte) + # sys.exit('done') + + scale_query_to_tile( + dsquery, dstile, options, tilefilename=tilefilename) + del dsquery + elif tile_size == querysize: + # Use the ReadRaster result directly in tiles ('nearest neighbour' query) + dstile.WriteRaster( + wx, + wy, + wxsize, + wysize, + data, + band_list=list(range(1, dataBandsCount + 1)), + ) + dstile.WriteRaster(wx, wy, wxsize, wysize, + alpha, band_list=[tilebands]) + + # Note: For source drivers based on WaveLet compression (JPEG2000, ECW, + # MrSID) the ReadRaster function returns high-quality raster (not ugly + # nearest neighbour) + # TODO: Use directly 'near' for WaveLet files + else: + # Big ReadRaster query in memory scaled to the tile_size - all but 'near' + # algo + dsquery = mem_drv.Create("", querysize, querysize, tilebands) + # TODO: fill the null value in case a tile without alpha is produced (now + # only png tiles are supported) + dsquery.WriteRaster( + wx, + wy, + wxsize, + wysize, + data, + band_list=list(range(1, dataBandsCount + 1)), + ) + dsquery.WriteRaster(wx, wy, wxsize, wysize, + alpha, band_list=[tilebands]) + + scale_query_to_tile(dsquery, dstile, options, + tilefilename=tilefilename) + del dsquery + + del data + + if options.resampling != "antialias" and options.resampling != "near-composite": + # Write a copy of tile to png/jpg + out_drv.CreateCopy( + tilefilename, dstile, strict=0, options=_get_creation_options(options) + ) + + del dstile + + # Create a KML file for this tile. + if tile_job_info.kml: + swne = get_tile_swne(tile_job_info, options) + if swne is not None: + kmlfilename = os.path.join( + output, + str(tz), + str(tx), + "%d.kml" % GDAL2Tiles.getYTile(ty, tz, options), + ) + if not options.resume or not isfile(kmlfilename): + with my_open(kmlfilename, "wb") as f: + f.write( + generate_kml( + tx, + ty, + tz, + tile_job_info.tile_extension, + tile_job_info.tile_size, + swne, + tile_job_info.options, + ).encode("utf-8") + ) + + +def create_overview_tile( + base_tz: int, + base_tiles: List[Tuple[int, int]], + output_folder: str, + tile_job_info: "TileJobInfo", + options: Options, +): + """Generating an overview tile from no more than 4 underlying tiles(base tiles)""" + overview_tz = base_tz - 1 + overview_tx = base_tiles[0][0] >> 1 + overview_ty = base_tiles[0][1] >> 1 + overview_ty_real = GDAL2Tiles.getYTile(overview_ty, overview_tz, options) + + tilefilename = os.path.join( + output_folder, + str(overview_tz), + str(overview_tx), + "%s.%s" % (overview_ty_real, tile_job_info.tile_extension), + ) + if options.verbose: + print(tilefilename) + if options.resume and isfile(tilefilename): + if options.verbose: + print("Tile generation skipped because of --resume") + return + + mem_driver = gdal.GetDriverByName("MEM") + tile_driver = tile_job_info.tile_driver + out_driver = gdal.GetDriverByName(tile_driver) + + tilebands = tile_job_info.nb_data_bands + 1 + + # MMGIS + if options.isDEMtile == True: + tilebands = 4 + + dsquery = mem_driver.Create( + "", 2 * tile_job_info.tile_size, 2 * tile_job_info.tile_size, tilebands + ) + # TODO: fill the null value + dstile = mem_driver.Create( + "", tile_job_info.tile_size, tile_job_info.tile_size, tilebands + ) + + usable_base_tiles = [] + + for base_tile in base_tiles: + base_tx = base_tile[0] + base_ty = base_tile[1] + base_ty_real = GDAL2Tiles.getYTile(base_ty, base_tz, options) + + base_tile_path = os.path.join( + output_folder, + str(base_tz), + str(base_tx), + "%s.%s" % (base_ty_real, tile_job_info.tile_extension), + ) + if not isfile(base_tile_path): + if options.verbose: + print("\tNo usable base tiles at path", base_tile_path) + continue + + dsquerytile = gdal.Open(base_tile_path, gdal.GA_ReadOnly) + + if base_tx % 2 == 0: + tileposx = 0 + else: + tileposx = tile_job_info.tile_size + + if options.xyz and options.profile == "raster": + if base_ty % 2 == 0: + tileposy = 0 + else: + tileposy = tile_job_info.tile_size + else: + if base_ty % 2 == 0: + tileposy = tile_job_info.tile_size + else: + tileposy = 0 + + if dsquerytile.RasterCount == tilebands - 1: + # assume that the alpha band is missing and add it + tmp_ds = mem_driver.CreateCopy("", dsquerytile, 0) + tmp_ds.AddBand() + mask = bytearray( + [255] * (tile_job_info.tile_size * tile_job_info.tile_size) + ) + tmp_ds.WriteRaster( + 0, + 0, + tile_job_info.tile_size, + tile_job_info.tile_size, + mask, + band_list=[tilebands], + ) + dsquerytile = tmp_ds + elif dsquerytile.RasterCount != tilebands: + raise Exception("Unexpected number of bands in base tile") + + base_data = dsquerytile.ReadRaster( + 0, 0, tile_job_info.tile_size, tile_job_info.tile_size + ) + + dsquery.WriteRaster( + tileposx, + tileposy, + tile_job_info.tile_size, + tile_job_info.tile_size, + base_data, + band_list=list(range(1, tilebands + 1)), + ) + + usable_base_tiles.append(base_tile) + + if not usable_base_tiles: + if options.verbose: + print("\tNo usable base tiles for overview zoom", base_tz, ", base tiles:", *base_tiles) + return + + scale_query_to_tile(dsquery, dstile, options, tilefilename=tilefilename) + # Write a copy of tile to png/jpg + if options.resampling != "antialias" and options.resampling != "near-composite": + # Write a copy of tile to png/jpg + out_driver.CreateCopy( + tilefilename, dstile, strict=0, options=_get_creation_options(options) + ) + # Remove useless side car file + aux_xml = tilefilename + ".aux.xml" + if gdal.VSIStatL(aux_xml) is not None: + gdal.Unlink(aux_xml) + + if options.verbose: + print("\tbuild from zoom", base_tz, " tiles:", *base_tiles) + + # Create a KML file for this tile. + if tile_job_info.kml: + swne = get_tile_swne(tile_job_info, options) + if swne is not None: + with my_open( + os.path.join( + output_folder, + "%d/%d/%d.kml" % (overview_tz, overview_tx, + overview_ty_real), + ), + "wb", + ) as f: + f.write( + generate_kml( + overview_tx, + overview_ty, + overview_tz, + tile_job_info.tile_extension, + tile_job_info.tile_size, + swne, + options, + [(t[0], t[1], base_tz) for t in base_tiles], + ).encode("utf-8") + ) + + +def group_overview_base_tiles( + base_tz: int, output_folder: str, tile_job_info: "TileJobInfo" +) -> List[List[Tuple[int, int]]]: + """Group base tiles that belong to the same overview tile""" + + overview_to_bases = {} + tminx, tminy, tmaxx, tmaxy = tile_job_info.tminmax[base_tz] + for ty in range(tmaxy, tminy - 1, -1): + overview_ty = ty >> 1 + for tx in range(tminx, tmaxx + 1): + overview_tx = tx >> 1 + base_tile = (tx, ty) + overview_tile = (overview_tx, overview_ty) + + if overview_tile not in overview_to_bases: + overview_to_bases[overview_tile] = [] + + overview_to_bases[overview_tile].append(base_tile) + + # Create directories for the tiles + overview_tz = base_tz - 1 + for tx in range(tminx, tmaxx + 1): + overview_tx = tx >> 1 + tiledirname = os.path.join( + output_folder, str(overview_tz), str(overview_tx)) + makedirs(tiledirname) + + return list(overview_to_bases.values()) + + +def count_overview_tiles(tile_job_info: "TileJobInfo") -> int: + tile_number = 0 + for tz in range(tile_job_info.tmaxz - 1, tile_job_info.tminz - 1, -1): + tminx, tminy, tmaxx, tmaxy = tile_job_info.tminmax[tz] + tile_number += (1 + abs(tmaxx - tminx)) * (1 + abs(tmaxy - tminy)) + + return tile_number + + +def optparse_init() -> optparse.OptionParser: + """Prepare the option parser for input (argv)""" + + usage = "Usage: %prog [options] input_file [output]" + p = optparse.OptionParser(usage, version="%prog " + __version__) + p.add_option( + "-p", + "--profile", + dest="profile", + type="choice", + choices=profile_list, + help=( + "Tile cutting profile (%s) - default 'mercator' " + "(Google Maps compatible)" % ",".join(profile_list) + ), + ) + p.add_option( + "-r", + "--resampling", + dest="resampling", + type="choice", + choices=resampling_list, + help="Resampling method (%s) - default 'average'" % ",".join(resampling_list), + ) + p.add_option( + "-s", + "--s_srs", + dest="s_srs", + metavar="SRS", + help="The spatial reference system used for the source input data", + ) + p.add_option( + "-z", + "--zoom", + dest="zoom", + help="Zoom levels to render (format:'2-5', '10-' or '10').", + ) + p.add_option( + "-e", + "--resume", + dest="resume", + action="store_true", + help="Resume mode. Generate only missing files.", + ) + p.add_option( + "-a", + "--srcnodata", + dest="srcnodata", + metavar="NODATA", + help="Value in the input dataset considered as transparent", + ) + p.add_option( + "-d", + "--tmscompatible", + dest="tmscompatible", + action="store_true", + help=( + "When using the geodetic profile, specifies the base resolution " + "as 0.703125 or 2 tiles at zoom level 0." + ), + ) + p.add_option( + "--xyz", + action="store_true", + dest="xyz", + help="Use XYZ tile numbering (OSM Slippy Map tiles) instead of TMS", + ) + p.add_option( + "-v", + "--verbose", + action="store_true", + dest="verbose", + help="Print status messages to stdout", + ) + p.add_option( + "-x", + "--exclude", + action="store_true", + dest="exclude_transparent", + help="Exclude transparent tiles from result tileset", + ) + p.add_option( + "-q", + "--quiet", + action="store_true", + dest="quiet", + help="Disable messages and status to stdout", + ) + # MMGIS + p.add_option("--extentworld", dest="extentworld", + help="The full world meter extent (comma-separated as minx,maxx,miny,maxy,pixelsize) of an inner raster profile.") + # MMGIS + p.add_option("--dem", action="store_true", dest="isDEMtile", + help="Indicate if the input is a Digital Elevation Model") + p.add_option( + "--processes", + dest="nb_processes", + type="int", + help="Number of processes to use for tiling", + ) + p.add_option( + "--mpi", + action="store_true", + dest="mpi", + help="Assume launched by mpiexec and ignore --processes. " + "User should set GDAL_CACHEMAX to size per process.", + ) + p.add_option( + "--tilesize", + dest="tilesize", + metavar="PIXELS", + type="int", + help="Width and height in pixel of a tile", + ) + p.add_option( + "--tiledriver", + dest="tiledriver", + choices=["PNG", "WEBP"], + default="PNG", + type="choice", + help="which tile driver to use for the tiles", + ) + + # KML options + g = optparse.OptionGroup( + p, + "KML (Google Earth) options", + "Options for generated Google Earth SuperOverlay metadata", + ) + g.add_option( + "-k", + "--force-kml", + dest="kml", + action="store_true", + help=( + "Generate KML for Google Earth - default for 'geodetic' profile and " + "'raster' in EPSG:4326. For a dataset with different projection use " + "with caution!" + ), + ) + g.add_option( + "-n", + "--no-kml", + dest="kml", + action="store_false", + help="Avoid automatic generation of KML files for EPSG:4326", + ) + g.add_option( + "-u", + "--url", + dest="url", + help="URL address where the generated tiles are going to be published", + ) + p.add_option_group(g) + + # HTML options + g = optparse.OptionGroup( + p, "Web viewer options", "Options for generated HTML viewers a la Google Maps" + ) + g.add_option( + "-w", + "--webviewer", + dest="webviewer", + type="choice", + choices=webviewer_list, + help="Web viewer to generate (%s) - default 'all'" % ",".join( + webviewer_list), + ) + g.add_option("-t", "--title", dest="title", help="Title of the map") + g.add_option("-c", "--copyright", dest="copyright", + help="Copyright for the map") + g.add_option( + "-g", + "--googlekey", + dest="googlekey", + help="Google Maps API key from https://developers.google.com/maps/faq?csw=1#using-google-maps-apis", + ) + g.add_option( + "-b", + "--bingkey", + dest="bingkey", + help="Bing Maps API key from https://www.bingmapsportal.com/", + ) + p.add_option_group(g) + + # MapML options + g = optparse.OptionGroup( + p, "MapML options", "Options for generated MapML file") + g.add_option( + "--mapml-template", + dest="mapml_template", + action="store_true", + help=( + "Filename of a template mapml file where variables will " + "be substituted. If not specified, the generic " + "template_tiles.mapml file from GDAL data resources " + "will be used" + ), + ) + p.add_option_group(g) + + # Webp options + g = optparse.OptionGroup(p, "WEBP options", "Options for WEBP tiledriver") + g.add_option( + "--webp-quality", + dest="webp_quality", + type=int, + default=75, + help="quality of webp image, integer between 1 and 100, default is 75", + ) + g.add_option( + "--webp-lossless", + dest="webp_lossless", + action="store_true", + help="use lossless compression for the webp image", + ) + p.add_option_group(g) + + p.set_defaults( + verbose=False, + profile="mercator", + kml=None, + url="", + webviewer="all", + copyright="", + resampling="average", + resume=False, + googlekey="INSERT_YOUR_KEY_HERE", + bingkey="INSERT_YOUR_KEY_HERE", + processes=1, + ) + + return p + + +def process_args(argv: List[str]) -> Tuple[str, str, Options]: + parser = optparse_init() + options, args = parser.parse_args(args=argv) + + # Args should be either an input file OR an input file and an output folder + if not args: + exit_with_error( + "You need to specify at least an input file as argument to the script" + ) + if len(args) > 2: + exit_with_error( + "Processing of several input files is not supported.", + "Please first use a tool like gdal_vrtmerge.py or gdal_merge.py on the " + "files: gdal_vrtmerge.py -o merged.vrt %s" % " ".join(args), + ) + + input_file = args[0] + if not isfile(input_file): + exit_with_error( + "The provided input file %s does not exist or is not a file" % input_file + ) + + if len(args) == 2: + output_folder = args[1] + else: + # Directory with input filename without extension in actual directory + output_folder = os.path.splitext(os.path.basename(input_file))[0] + + if options.webviewer == "mapml": + options.xyz = True + if options.profile == "geodetic": + options.tmscompatible = True + + options = options_post_processing(options, input_file, output_folder) + + return input_file, output_folder, options + + +def options_post_processing( + options: Options, input_file: str, output_folder: str +) -> Options: + if not options.title: + options.title = os.path.basename(input_file) + + # User specified zoom levels + tminz = None + tmaxz = None + if hasattr(options, "zoom") and options.zoom and isinstance(options.zoom, str): + minmax = options.zoom.split("-", 1) + zoom_min = minmax[0] + tminz = int(zoom_min) + + if len(minmax) == 2: + # Min-max zoom value + zoom_max = minmax[1] + if zoom_max: + # User-specified (non-automatically calculated) + tmaxz = int(zoom_max) + if tmaxz < tminz: + raise Exception( + "max zoom (%d) less than min zoom (%d)" % ( + tmaxz, tminz) + ) + else: + # Single zoom value (min = max) + tmaxz = tminz + options.zoom = [tminz, tmaxz] + + if options.url and not options.url.endswith("/"): + options.url += "/" + if options.url: + out_path = output_folder + if out_path.endswith("/"): + out_path = out_path[:-1] + options.url += os.path.basename(out_path) + "/" + + # Supported options + if options.resampling == "antialias" and not numpy_available: + exit_with_error( + "'antialias' resampling algorithm is not available.", + "Install PIL (Python Imaging Library) and numpy.", + ) + + if options.resampling == "near-composite" and not numpy_available: + exit_with_error( + "'near-composite' resampling algorithm is not available.", + "Install PIL (Python Imaging Library) and numpy.", + ) + + if options.tiledriver == "WEBP": + if gdal.GetDriverByName(options.tiledriver) is None: + exit_with_error("WEBP driver is not available") + + if not options.webp_lossless: + if options.webp_quality <= 0 or options.webp_quality > 100: + exit_with_error("webp_quality should be in the range [1-100]") + options.webp_quality = int(options.webp_quality) + + # Output the results + if options.verbose: + print("Options:", options) + print("Input:", input_file) + print("Output:", output_folder) + print("Cache: %s MB" % (gdal.GetCacheMax() / 1024 / 1024)) + print("") + + return options + + +class TileDetail(object): + tx = 0 + ty = 0 + tz = 0 + rx = 0 + ry = 0 + rxsize = 0 + rysize = 0 + wx = 0 + wy = 0 + wxsize = 0 + wysize = 0 + querysize = 0 + isDEMtile = False + + def __init__(self, **kwargs): + for key in kwargs: + if hasattr(self, key): + setattr(self, key, kwargs[key]) + + def __unicode__(self): + return "TileDetail %s\n%s\n%s\n" % (self.tx, self.ty, self.tz) + + def __str__(self): + return "TileDetail %s\n%s\n%s\n" % (self.tx, self.ty, self.tz) + + def __repr__(self): + return "TileDetail %s\n%s\n%s\n" % (self.tx, self.ty, self.tz) + + +class TileJobInfo(object): + """ + Plain object to hold tile job configuration for a dataset + """ + + src_file = "" + nb_data_bands = 0 + output_file_path = "" + tile_extension = "" + tile_size = 0 + tile_driver = None + kml = False + tminmax = [] + tminz = 0 + tmaxz = 0 + in_srs_wkt = 0 + out_geo_trans = [] + ominy = 0 + is_epsg_4326 = False + options = None + exclude_transparent = False + + def __init__(self, **kwargs): + for key in kwargs: + if hasattr(self, key): + setattr(self, key, kwargs[key]) + + def __unicode__(self): + return "TileJobInfo %s\n" % (self.src_file) + + def __str__(self): + return "TileJobInfo %s\n" % (self.src_file) + + def __repr__(self): + return "TileJobInfo %s\n" % (self.src_file) + + +class Gdal2TilesError(Exception): + pass + + +class GDAL2Tiles(object): + def __init__(self, input_file: str, output_folder: str, options: Options) -> None: + """Constructor function - initialization""" + self.out_drv = None + self.mem_drv = None + self.warped_input_dataset = None + self.out_srs = None + self.nativezoom = None + self.tminmax = None + self.tsize = None + self.mercator = None + self.geodetic = None + self.dataBandsCount = None + self.out_gt = None + self.tileswne = None + self.swne = None + self.ominx = None + self.omaxx = None + self.omaxy = None + self.ominy = None + + # MMGIS + self.isRasterBounded = False + self.isDEMtile = False + self.fminx = None + self.fmaxx = None + self.fminy = None + self.fmaxy = None + self.fPixelSize = None + + self.input_file = None + self.output_folder = None + + self.isepsg4326 = None + self.in_srs = None + self.in_srs_wkt = None + + # Tile format + self.tile_size = 256 + if options.isDEMtile: + self.tile_size = 32 + if options.tilesize: + self.tile_size = options.tilesize + + self.tiledriver = options.tiledriver + if options.tiledriver == "PNG": + self.tileext = "png" + else: + self.tileext = "webp" + if options.mpi: + makedirs(output_folder) + self.tmp_dir = tempfile.mkdtemp(dir=output_folder) + else: + self.tmp_dir = tempfile.mkdtemp() + self.tmp_vrt_filename = os.path.join( + self.tmp_dir, str(uuid4()) + ".vrt") + + # Should we read bigger window of the input raster and scale it down? + # Note: Modified later by open_input() + # Not for 'near' resampling + # Not for Wavelet based drivers (JPEG2000, ECW, MrSID) + # Not for 'raster' profile + self.scaledquery = True + # How big should be query window be for scaling down + # Later on reset according the chosen resampling algorithm + self.querysize = 4 * self.tile_size + + # Should we use Read on the input file for generating overview tiles? + # Note: Modified later by open_input() + # Otherwise the overview tiles are generated from existing underlying tiles + self.overviewquery = False + + self.input_file = input_file + self.output_folder = output_folder + self.options = options + + # MMGIS + if self.options.extentworld: + extentworld = self.options.extentworld.split(",") + self.isRasterBounded = True + self.fminx = float(extentworld[0]) + self.fmaxx = float(extentworld[2]) + self.fminy = float(extentworld[3]) + self.fmaxy = float(extentworld[1]) + self.fPixelSize = float(extentworld[4]) + + if self.options.resampling == "near": + self.querysize = self.tile_size + + elif self.options.resampling == "bilinear": + self.querysize = self.tile_size * 2 + + self.tminz, self.tmaxz = self.options.zoom + + # MMGIS + if self.options.isDEMtile: + self.isDEMtile = True + + # KML generation + self.kml = self.options.kml + + # ------------------------------------------------------------------------- + def open_input(self) -> None: + """Initialization of the input raster, reprojection if necessary""" + gdal.AllRegister() + + self.out_drv = gdal.GetDriverByName(self.tiledriver) + self.mem_drv = gdal.GetDriverByName("MEM") + + if not self.out_drv: + raise Exception( + "The '%s' driver was not found, is it available in this GDAL build?" + % self.tiledriver + ) + if not self.mem_drv: + raise Exception( + "The 'MEM' driver was not found, is it available in this GDAL build?" + ) + + # Open the input file + + if self.input_file: + input_dataset: gdal.Dataset = gdal.Open( + self.input_file, gdal.GA_ReadOnly) + else: + raise Exception("No input file was specified") + + if self.options.verbose: + print( + "Input file:", + "( %sP x %sL - %s bands)" + % ( + input_dataset.RasterXSize, + input_dataset.RasterYSize, + input_dataset.RasterCount, + ), + ) + + if not input_dataset: + # Note: GDAL prints the ERROR message too + exit_with_error( + "It is not possible to open the input file '%s'." % self.input_file + ) + + # Read metadata from the input file + if input_dataset.RasterCount == 0: + exit_with_error("Input file '%s' has no raster band" % + self.input_file) + + if input_dataset.GetRasterBand(1).GetRasterColorTable(): + exit_with_error( + "Please convert this file to RGB/RGBA and run gdal2tiles on the result.", + "From paletted file you can create RGBA file (temp.vrt) by:\n" + "gdal_translate -of vrt -expand rgba %s temp.vrt\n" + "then run:\n" + "gdal2tiles temp.vrt" % self.input_file, + ) + + if self.isDEMtile != True and input_dataset.GetRasterBand(1).DataType != gdal.GDT_Byte: + exit_with_error( + "Please convert this file to 8-bit and run gdal2tiles on the result.", + "To scale pixel values you can use:\n" + "gdal_translate -of VRT -ot Byte -scale %s temp.vrt\n" + "then run:\n" + "gdal2tiles temp.vrt" % self.input_file, + ) + + if self.isDEMtile == True and input_dataset.GetRasterBand(1).DataType != gdal.GDT_Float32: + exit_with_error( + "Please convert this file to 32-bit for its first band and run gdal2tiles on the result.", + ) + + in_nodata = setup_no_data_values(input_dataset, self.options) + + if self.options.verbose: + print( + "Preprocessed file:", + "( %sP x %sL - %s bands)" + % ( + input_dataset.RasterXSize, + input_dataset.RasterYSize, + input_dataset.RasterCount, + ), + ) + + self.in_srs, self.in_srs_wkt = setup_input_srs( + input_dataset, self.options) + + self.out_srs = setup_output_srs(self.in_srs, self.options) + + # If input and output reference systems are different, we reproject the input dataset into + # the output reference system for easier manipulation + + self.warped_input_dataset = None + + if self.options.profile != "raster": + + if not self.in_srs: + exit_with_error( + "Input file has unknown SRS.", + "Use --s_srs EPSG:xyz (or similar) to provide source reference system.", + ) + + if not has_georeference(input_dataset): + exit_with_error( + "There is no georeference - neither affine transformation (worldfile) " + "nor GCPs. You can generate only 'raster' profile tiles.", + "Either gdal2tiles with parameter -p 'raster' or use another GIS " + "software for georeference e.g. gdal_transform -gcp / -a_ullr / -a_srs", + ) + + if (self.in_srs.ExportToProj4() != self.out_srs.ExportToProj4()) or ( + input_dataset.GetGCPCount() != 0 + ): + self.warped_input_dataset = reproject_dataset( + input_dataset, self.in_srs, self.out_srs + ) + + if in_nodata: + self.warped_input_dataset = update_no_data_values( + self.warped_input_dataset, in_nodata, options=self.options + ) + else: + self.warped_input_dataset = update_alpha_value_for_non_alpha_inputs( + self.warped_input_dataset, options=self.options + ) + + if self.warped_input_dataset and self.options.verbose: + print( + "Projected file:", + "tiles.vrt", + "( %sP x %sL - %s bands)" + % ( + self.warped_input_dataset.RasterXSize, + self.warped_input_dataset.RasterYSize, + self.warped_input_dataset.RasterCount, + ), + ) + + if not self.warped_input_dataset: + self.warped_input_dataset = input_dataset + + gdal.GetDriverByName("VRT").CreateCopy( + self.tmp_vrt_filename, self.warped_input_dataset + ) + + self.dataBandsCount = nb_data_bands(self.warped_input_dataset) + + # KML test + self.isepsg4326 = False + srs4326 = osr.SpatialReference() + srs4326.ImportFromEPSG(4326) + srs4326.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER) + if self.out_srs and srs4326.ExportToProj4() == self.out_srs.ExportToProj4(): + self.isepsg4326 = True + if self.kml is None: + self.kml = True + if self.kml and self.options.verbose: + print("KML autotest OK!") + + if self.kml is None: + self.kml = False + + # Read the georeference + self.out_gt = self.warped_input_dataset.GetGeoTransform() + + # Test the size of the pixel + + # Report error in case rotation/skew is in geotransform (possible only in 'raster' profile) + if (self.out_gt[2], self.out_gt[4]) != (0, 0): + exit_with_error( + "Georeference of the raster contains rotation or skew. " + "Such raster is not supported. Please use gdalwarp first." + ) + + # Here we expect: pixel is square, no rotation on the raster + + # Output Bounds - coordinates in the output SRS + self.ominx = self.out_gt[0] + self.omaxx = ( + self.out_gt[0] + + self.warped_input_dataset.RasterXSize * self.out_gt[1] + ) + self.omaxy = self.out_gt[3] + self.ominy = ( + self.out_gt[3] - + self.warped_input_dataset.RasterYSize * self.out_gt[1] + ) + # Note: maybe round(x, 14) to avoid the gdal_translate behavior, when 0 becomes -1e-15 + + # MMGIS + def linearScale(domain, rang, value): + return ( + ((rang[1] - rang[0]) * (value - domain[0])) / + (domain[1] - domain[0]) + + rang[0] + ) + # MMGIS + self.warped_input_dataset.fRasterXSize = self.warped_input_dataset.RasterXSize + self.warped_input_dataset.fRasterYSize = self.warped_input_dataset.RasterYSize + self.warped_input_dataset.fRasterXOrigin = 0 + self.warped_input_dataset.fRasterYOrigin = 0 + self.warped_input_dataset.PixelSize = self.out_gt[1] + self.warped_input_dataset.fPixelSize = self.fPixelSize + + + if self.isRasterBounded: + self.warped_input_dataset.fRasterXSize = self.warped_input_dataset.RasterXSize * (self.fmaxx - self.fminx) / ( + self.omaxx - self.ominx) * (self.warped_input_dataset.PixelSize / self.warped_input_dataset.fPixelSize) + self.warped_input_dataset.fRasterYSize = self.warped_input_dataset.RasterYSize * (self.fmaxy - self.fminy) / ( + self.omaxy - self.ominy) * (self.warped_input_dataset.PixelSize / self.warped_input_dataset.fPixelSize) + self.warped_input_dataset.fRasterXSizeRaw = self.warped_input_dataset.RasterXSize * (self.fmaxx - self.fminx) / (self.omaxx - self.ominx) + self.warped_input_dataset.fRasterYSizeRaw = self.warped_input_dataset.RasterYSize * (self.fmaxy - self.fminy) / (self.omaxy - self.ominy) + self.warped_input_dataset.fRasterXOrigin = linearScale( + [self.fminx, self.fmaxx], [0, self.warped_input_dataset.fRasterXSize], self.out_gt[0]) + self.warped_input_dataset.fRasterYOrigin = linearScale( + [self.fminy, self.fmaxy], [self.warped_input_dataset.fRasterYSize, 0], self.out_gt[3]) + self.warped_input_dataset.fRasterXOriginRaw = linearScale([self.fminx, self.fmaxx], [ + 0, self.warped_input_dataset.fRasterXSize], self.out_gt[0]) * (self.warped_input_dataset.fPixelSize / self.warped_input_dataset.PixelSize) + self.warped_input_dataset.fRasterYOriginRaw = linearScale([self.fminy, self.fmaxy], [ + self.warped_input_dataset.fRasterYSize, 0], self.out_gt[3]) * (self.warped_input_dataset.fPixelSize / self.warped_input_dataset.PixelSize) + self.warped_input_dataset.fRasterXWidth = linearScale( + [self.fminx, self.fmaxx], [0, self.warped_input_dataset.fRasterXSize], self.omaxx) - linearScale( + [self.fminx, self.fmaxx], [0, self.warped_input_dataset.fRasterXSize], self.ominx) + self.warped_input_dataset.fRasterYHeight = linearScale( + [self.fminy, self.fmaxy], [0, self.warped_input_dataset.fRasterYSize], self.omaxy) - linearScale( + [self.fminy, self.fmaxy], [0, self.warped_input_dataset.fRasterYSize], self.ominy) + if self.options.verbose: + print("ominx", self.ominx, "omaxx", self.omaxx, "ominy", self.ominy, "omaxy", self.omaxy) + print("fminx", self.fminx, "fmaxx", self.fmaxx, "fminy", self.fminy, "fmaxy", self.fmaxy) + print("px_size", self.warped_input_dataset.PixelSize, "fpx_size", self.warped_input_dataset.fPixelSize) + print("Orig Raster Size: ", self.warped_input_dataset.RasterXSize, self.warped_input_dataset.RasterYSize ) + print("Full Raster Size: ", self.warped_input_dataset.fRasterXSize, self.warped_input_dataset.fRasterYSize ) + print("Full Raster Size Raw: ", self.warped_input_dataset.fRasterXSizeRaw, self.warped_input_dataset.fRasterYSizeRaw ) + print("Full Raster XY Origin: ", self.warped_input_dataset.fRasterXOrigin, self.warped_input_dataset.fRasterYOrigin ) + print("Full fRasterXYOriginRaw", self.warped_input_dataset.fRasterXOriginRaw, self.warped_input_dataset.fRasterYOriginRaw) + print("Full fRasterXWidth/Height", self.warped_input_dataset.fRasterXWidth, self.warped_input_dataset.fRasterYHeight) + print( + "Bounds (output srs):", + round(self.ominx, 13), + self.ominy, + self.omaxx, + self.omaxy, + ) + + # Calculating ranges for tiles in different zoom levels + if self.options.profile == "mercator": + + self.mercator = GlobalMercator(tile_size=self.tile_size) + + # Function which generates SWNE in LatLong for given tile + self.tileswne = self.mercator.TileLatLonBounds + + # Generate table with min max tile coordinates for all zoomlevels + self.tminmax = list(range(0, MAXZOOMLEVEL)) + for tz in range(0, MAXZOOMLEVEL): + tminx, tminy = self.mercator.MetersToTile( + self.ominx, self.ominy, tz) + tmaxx, tmaxy = self.mercator.MetersToTile( + self.omaxx, self.omaxy, tz) + # crop tiles extending world limits (+-180,+-90) + tminx, tminy = max(0, tminx), max(0, tminy) + tmaxx, tmaxy = min(2**tz - 1, tmaxx), min(2**tz - 1, tmaxy) + self.tminmax[tz] = (tminx, tminy, tmaxx, tmaxy) + + # TODO: Maps crossing 180E (Alaska?) + + # Get the minimal zoom level (map covers area equivalent to one tile) + if self.tminz is None: + self.tminz = self.mercator.ZoomForPixelSize( + self.out_gt[1] + * max( + self.warped_input_dataset.RasterXSize, + self.warped_input_dataset.RasterYSize, + ) + / float(self.tile_size) + ) + + # Get the maximal zoom level + # (closest possible zoom level up on the resolution of raster) + if self.tmaxz is None: + self.tmaxz = self.mercator.ZoomForPixelSize(self.out_gt[1]) + self.tmaxz = max(self.tminz, self.tmaxz) + + self.tminz = min(self.tminz, self.tmaxz) + + if self.options.verbose: + print( + "Bounds (latlong):", + self.mercator.MetersToLatLon(self.ominx, self.ominy), + self.mercator.MetersToLatLon(self.omaxx, self.omaxy), + ) + print("MinZoomLevel:", self.tminz) + print( + "MaxZoomLevel:", + self.tmaxz, + "(", + self.mercator.Resolution(self.tmaxz), + ")", + ) + + elif self.options.profile == "geodetic": + + self.geodetic = GlobalGeodetic( + self.options.tmscompatible, tile_size=self.tile_size + ) + + # Function which generates SWNE in LatLong for given tile + self.tileswne = self.geodetic.TileLatLonBounds + + # Generate table with min max tile coordinates for all zoomlevels + self.tminmax = list(range(0, MAXZOOMLEVEL)) + for tz in range(0, MAXZOOMLEVEL): + tminx, tminy = self.geodetic.LonLatToTile( + self.ominx, self.ominy, tz) + tmaxx, tmaxy = self.geodetic.LonLatToTile( + self.omaxx, self.omaxy, tz) + # crop tiles extending world limits (+-180,+-90) + tminx, tminy = max(0, tminx), max(0, tminy) + tmaxx, tmaxy = min(2 ** (tz + 1) - 1, + tmaxx), min(2**tz - 1, tmaxy) + self.tminmax[tz] = (tminx, tminy, tmaxx, tmaxy) + + # TODO: Maps crossing 180E (Alaska?) + + # Get the maximal zoom level + # (closest possible zoom level up on the resolution of raster) + if self.tminz is None: + self.tminz = self.geodetic.ZoomForPixelSize( + self.out_gt[1] + * max( + self.warped_input_dataset.RasterXSize, + self.warped_input_dataset.RasterYSize, + ) + / float(self.tile_size) + ) + + # Get the maximal zoom level + # (closest possible zoom level up on the resolution of raster) + if self.tmaxz is None: + self.tmaxz = self.geodetic.ZoomForPixelSize(self.out_gt[1]) + self.tmaxz = max(self.tminz, self.tmaxz) + + self.tminz = min(self.tminz, self.tmaxz) + + if self.options.verbose: + print( + "Bounds (latlong):", self.ominx, self.ominy, self.omaxx, self.omaxy + ) + + # MMGIS + elif self.options.profile == 'raster' and self.isRasterBounded: + + def log2(x): + return math.log10(x) / math.log10(2) # MMGIS - self.out_ds.fWorldXSize = int( - float(self.out_ds.fRasterXSize) * (2**(self.nativezoom - self.basenativezoom))) - self.out_ds.fWorldYSize = int( - float(self.out_ds.fRasterYSize) * (2**(self.nativezoom - self.basenativezoom))) - self.out_ds.fRasterXOriginWorld = int(float( - self.out_ds.fWorldXSize) * (float(self.out_ds.fRasterXOrigin) / self.out_ds.fRasterXSize)) - self.out_ds.fRasterYOriginWorld = int(float( - self.out_ds.fWorldYSize) * (float(self.out_ds.fRasterYOrigin) / self.out_ds.fRasterYSize)) - self.out_ds.fRasterXSizeWorld = int(float( - self.out_ds.fWorldXSize) * (float(self.out_ds.fRasterXWidth) / self.out_ds.fRasterXSize)) - self.out_ds.fRasterYSizeWorld = int(float( - self.out_ds.RasterYSize) * (float(self.out_ds.fRasterXSizeWorld) / self.out_ds.RasterXSize)) - # print("World Size", self.out_ds.fWorldXSize, self.out_ds.fWorldYSize) - # print("Raster Origin World", self.out_ds.fRasterXOriginWorld, self.out_ds.fRasterYOriginWorld) - # print("Raster Size World", self.out_ds.fRasterXSizeWorld, self.out_ds.fRasterYSizeWorld) + self.nativezoom = int( + max(math.ceil(log2(self.warped_input_dataset.fRasterXSizeRaw/float(self.tile_size))), + math.ceil(log2(self.warped_input_dataset.fRasterYSizeRaw/float(self.tile_size))))) + + self.basenativezoom = int( + max(math.ceil(log2(self.warped_input_dataset.fRasterXSize/float(self.tile_size))), + math.ceil(log2(self.warped_input_dataset.fRasterYSize/float(self.tile_size))))) + + # MMGIS + self.warped_input_dataset.fWorldXSize = float(self.warped_input_dataset.fRasterXSize) * (2**(self.nativezoom - self.basenativezoom)) + self.warped_input_dataset.fWorldYSize = float(self.warped_input_dataset.fRasterYSize) * (2**(self.nativezoom - self.basenativezoom)) + self.warped_input_dataset.fRasterXOriginWorld = float(self.warped_input_dataset.fWorldXSize) * (float(self.warped_input_dataset.fRasterXOrigin) / self.warped_input_dataset.fRasterXSize) + self.warped_input_dataset.fRasterYOriginWorld = float(self.warped_input_dataset.fWorldYSize) * (float(self.warped_input_dataset.fRasterYOrigin) / self.warped_input_dataset.fRasterYSize) + self.warped_input_dataset.fRasterXSizeWorld = float(self.warped_input_dataset.fWorldXSize) * (float(self.warped_input_dataset.fRasterXWidth) / self.warped_input_dataset.fRasterXSize) + self.warped_input_dataset.fRasterYSizeWorld = float(self.warped_input_dataset.RasterYSize) * (float(self.warped_input_dataset.fRasterXSizeWorld) / self.warped_input_dataset.RasterXSize) + + #self.warped_input_dataset.fRasterXSizeWorld = self.warped_input_dataset.RasterXSize + #self.warped_input_dataset.fRasterYSizeWorld = self.warped_input_dataset.RasterYSize + if self.options.verbose: + print("Raster Size Raw", self.warped_input_dataset.fRasterXSizeRaw, self.warped_input_dataset.fRasterYSizeRaw) + print("Raster Size", self.warped_input_dataset.RasterXSize, self.warped_input_dataset.RasterYSize) + print("Full Raster Size", self.warped_input_dataset.fRasterXSize, self.warped_input_dataset.fRasterYSize) + print("World Size", self.warped_input_dataset.fWorldXSize, self.warped_input_dataset.fWorldYSize) + print("Raster Origin", self.warped_input_dataset.fRasterXOrigin, self.warped_input_dataset.fRasterYOrigin) + print("Raster Origin World", self.warped_input_dataset.fRasterXOriginWorld, self.warped_input_dataset.fRasterYOriginWorld) + print("Raster Size World", self.warped_input_dataset.fRasterXSizeWorld, self.warped_input_dataset.fRasterYSizeWorld) if self.options.verbose: print("Native zoom of the raster:", self.nativezoom) + print("Base native zoom of the raster:", self.basenativezoom) + print("tile_size:", self.tile_size) # Get the minimal zoom level (whole raster in one tile) if self.tminz is None: @@ -1303,7 +2743,7 @@ def log2(x): if self.tmaxz is None: self.tmaxz = self.nativezoom - # MMGIS added 'f'* + # MMGIS # Generate table with min max tile coordinates for all zoomlevels self.tminmax = list(range(0, self.tmaxz+1)) self.tsize = list(range(0, self.tmaxz+1)) @@ -1311,37 +2751,46 @@ def log2(x): # print("Pixel Size Ratio:", (self.out_ds.fPixelSize / self.out_ds.PixelSize)) # print("nativezoom", self.nativezoom, "basenativezoom", self.basenativezoom, "tminz", self.tminz, "tmaxz", self.tmaxz) for tz in range(0, self.tmaxz+1): - tsize = 2.0**(self.tmaxz-tz)*self.tilesize - toffsetx = int(math.floor( - 2.0**(tz) * self.out_ds.fRasterXOriginRaw / self.out_ds.fRasterXSizeRaw)) - toffsety = int(math.floor( - 2.0**(tz) * (self.out_ds.fRasterYOriginRaw) / self.out_ds.fRasterYSizeRaw)) - # print("tsize", tsize, "toffsetx", toffsetx, "toffsety", toffsety) - toffsetx = int(math.floor( - self.out_ds.fRasterXOriginWorld / tsize)) - toffsety = int(math.floor( - self.out_ds.fRasterYOriginWorld / tsize)) - # print("tsize", tsize, "toffsetx", toffsetx, "toffsety", toffsety) - tmaxx = int(math.floor( - self.out_ds.fRasterXSizeWorld / tsize)) + toffsetx + 1 - - tmaxy = int(math.floor( - self.out_ds.fRasterYSizeWorld / tsize)) + toffsety + 1 - self.tsize[tz] = math.ceil(tsize) - #tminx = toffsetx - tminx = int(tmaxx - ((tmaxx - toffsetx) / (0.75))) - 1 - tminy = int(tmaxy - ((tmaxy - toffsety) / (0.75))) - 1 + + xRatio = self.warped_input_dataset.fRasterXSize / (2.0**(self.basenativezoom) * self.tile_size) + yRatio = self.warped_input_dataset.fRasterYSize / (2.0**(self.basenativezoom) * self.tile_size) + tilesWide = 2.0**(tz) + tminx = math.floor(linearScale([0, self.warped_input_dataset.fRasterXSize], [0, tilesWide], self.warped_input_dataset.fRasterXOrigin) * xRatio) + tminy = math.floor(linearScale([self.warped_input_dataset.fRasterYSize, 0], [0, tilesWide], self.warped_input_dataset.fRasterYOrigin + self.warped_input_dataset.fRasterYHeight) * yRatio) + tmaxx = math.ceil(linearScale([0, self.warped_input_dataset.fRasterXSize], [0, tilesWide], self.warped_input_dataset.fRasterXOrigin + self.warped_input_dataset.fRasterXWidth) * xRatio) + tmaxy = math.ceil(linearScale([self.warped_input_dataset.fRasterYSize, 0], [0, tilesWide], self.warped_input_dataset.fRasterYOrigin) * yRatio) + + self.tsize[tz] = math.ceil(2.0**(self.tmaxz-tz)*self.tile_size) self.tminmax[tz] = (tminx, tminy, tmaxx, tmaxy) - # print("tminx", tminx, "tminy", tminy, "tmaxx", tmaxx, "tmaxy", tmaxy, "tz", tz) - elif self.options.profile == 'raster': + if self.options.verbose: + print("tminx", tminx, "tminy", tminy, "tmaxx", tmaxx, "tmaxy", tmaxy, "tz", tz, "xRatio", xRatio, "yRatio", yRatio) + + elif self.options.profile == "raster": def log2(x): return math.log10(x) / math.log10(2) - self.nativezoom = int( - max(math.ceil(log2(self.out_ds.RasterXSize/float(self.tilesize))), - math.ceil(log2(self.out_ds.RasterYSize/float(self.tilesize))))) + + self.nativezoom = max( + 0, + int( + max( + math.ceil( + log2( + self.warped_input_dataset.RasterXSize + / float(self.tile_size) + ) + ), + math.ceil( + log2( + self.warped_input_dataset.RasterYSize + / float(self.tile_size) + ) + ), + ) + ), + ) if self.options.verbose: print("Native zoom of the raster:", self.nativezoom) @@ -1353,30 +2802,69 @@ def log2(x): # Get the maximal zoom level (native resolution of the raster) if self.tmaxz is None: self.tmaxz = self.nativezoom + self.tmaxz = max(self.tminz, self.tmaxz) + + elif self.tmaxz > self.nativezoom: + # If the user requests at a higher precision than the native + # one, generate an oversample temporary VRT file, and tile from + # it + oversample_factor = 1 << (self.tmaxz - self.nativezoom) + if self.options.resampling in ("average", "antialias", "near-composite"): + resampleAlg = "average" + elif self.options.resampling in ( + "near", + "bilinear", + "cubic", + "cubicspline", + "lanczos", + "mode", + ): + resampleAlg = self.options.resampling + else: + resampleAlg = "bilinear" # fallback + gdal.Translate( + self.tmp_vrt_filename, + input_dataset, + width=self.warped_input_dataset.RasterXSize * oversample_factor, + height=self.warped_input_dataset.RasterYSize * oversample_factor, + resampleAlg=resampleAlg, + ) + self.warped_input_dataset = gdal.Open(self.tmp_vrt_filename) + self.out_gt = self.warped_input_dataset.GetGeoTransform() + self.nativezoom = self.tmaxz # Generate table with min max tile coordinates for all zoomlevels - self.tminmax = list(range(0, self.tmaxz+1)) - self.tsize = list(range(0, self.tmaxz+1)) - for tz in range(0, self.tmaxz+1): - tsize = 2.0**(self.tmaxz-tz)*self.tilesize + self.tminmax = list(range(0, self.tmaxz + 1)) + self.tsize = list(range(0, self.tmaxz + 1)) + for tz in range(0, self.tmaxz + 1): + tsize = 2.0 ** (self.nativezoom - tz) * self.tile_size tminx, tminy = 0, 0 - tmaxx = int(math.ceil(self.out_ds.RasterXSize / tsize)) - 1 - tmaxy = int(math.ceil(self.out_ds.RasterYSize / tsize)) - 1 + tmaxx = ( + int(math.ceil(self.warped_input_dataset.RasterXSize / tsize)) - 1 + ) + tmaxy = ( + int(math.ceil(self.warped_input_dataset.RasterYSize / tsize)) - 1 + ) self.tsize[tz] = math.ceil(tsize) self.tminmax[tz] = (tminx, tminy, tmaxx, tmaxy) # Function which generates SWNE in LatLong for given tile - if self.kml and in_srs_wkt: - ct = osr.CoordinateTransformation(in_srs, srs4326) + if self.kml and self.in_srs_wkt: + ct = osr.CoordinateTransformation(self.in_srs, srs4326) def rastertileswne(x, y, z): - # X-pixel size in level - pixelsizex = (2**(self.tmaxz-z) * self.out_gt[1]) - west = self.out_gt[0] + x*self.tilesize*pixelsizex - east = west + self.tilesize*pixelsizex - south = self.ominy + y*self.tilesize*pixelsizex - north = south + self.tilesize*pixelsizex - if not isepsg4326: + pixelsizex = ( + 2 ** (self.tmaxz - z) * self.out_gt[1] + ) # X-pixel size in level + west = self.out_gt[0] + x * self.tile_size * pixelsizex + east = west + self.tile_size * pixelsizex + if self.options.xyz: + north = self.omaxy - y * self.tile_size * pixelsizex + south = north - self.tile_size * pixelsizex + else: + south = self.ominy + y * self.tile_size * pixelsizex + north = south + self.tile_size * pixelsizex + if not self.isepsg4326: # Transformation to EPSG:4326 (WGS84 datum) west, south = ct.TransformPoint(west, south)[:2] east, north = ct.TransformPoint(east, north)[:2] @@ -1384,18 +2872,67 @@ def rastertileswne(x, y, z): self.tileswne = rastertileswne else: - self.tileswne = lambda x, y, z: (0, 0, 0, 0) # noqa + self.tileswne = lambda x, y, z: (0, 0, 0, 0) # noqa - def generate_metadata(self): + else: + + tms = tmsMap[self.options.profile] + + # Function which generates SWNE in LatLong for given tile + self.tileswne = None # not implemented + + # Generate table with min max tile coordinates for all zoomlevels + self.tminmax = list(range(0, tms.level_count + 1)) + for tz in range(0, tms.level_count + 1): + tminx, tminy = tms.GeorefCoordToTileCoord( + self.ominx, self.ominy, tz, self.tile_size + ) + tmaxx, tmaxy = tms.GeorefCoordToTileCoord( + self.omaxx, self.omaxy, tz, self.tile_size + ) + tminx, tminy = max(0, tminx), max(0, tminy) + tmaxx, tmaxy = min(tms.matrix_width * 2**tz - 1, tmaxx), min( + tms.matrix_height * 2**tz - 1, tmaxy + ) + self.tminmax[tz] = (tminx, tminy, tmaxx, tmaxy) + + # Get the minimal zoom level (map covers area equivalent to one tile) + if self.tminz is None: + self.tminz = tms.ZoomForPixelSize( + self.out_gt[1] + * max( + self.warped_input_dataset.RasterXSize, + self.warped_input_dataset.RasterYSize, + ) + / float(self.tile_size), + self.tile_size, + ) + + # Get the maximal zoom level + # (closest possible zoom level up on the resolution of raster) + if self.tmaxz is None: + self.tmaxz = tms.ZoomForPixelSize( + self.out_gt[1], self.tile_size) + self.tmaxz = max(self.tminz, self.tmaxz) + + self.tminz = min(self.tminz, self.tmaxz) + + if self.options.verbose: + print( + "Bounds (georef):", self.ominx, self.ominy, self.omaxx, self.omaxy + ) + print("MinZoomLevel:", self.tminz) + print("MaxZoomLevel:", self.tmaxz) + + def generate_metadata(self) -> None: """ Generation of main metadata files and HTML viewers (metadata related to particular tiles are generated during the tile processing). """ - if not os.path.exists(self.output): - os.makedirs(self.output) + makedirs(self.output_folder) - if self.options.profile == 'mercator': + if self.options.profile == "mercator": south, west = self.mercator.MetersToLatLon(self.ominx, self.ominy) north, east = self.mercator.MetersToLatLon(self.omaxx, self.omaxy) @@ -1404,30 +2941,30 @@ def generate_metadata(self): self.swne = (south, west, north, east) # Generate googlemaps.html - if self.options.webviewer in ('all', 'google') and self.options.profile == 'mercator': - if (not self.options.resume or not - os.path.exists(os.path.join(self.output, 'googlemaps.html'))): - f = open(os.path.join(self.output, 'googlemaps.html'), 'wb') - f.write(self.generate_googlemaps().encode('utf-8')) - f.close() - - # Generate openlayers.html - if self.options.webviewer in ('all', 'openlayers'): - if (not self.options.resume or not - os.path.exists(os.path.join(self.output, 'openlayers.html'))): - f = open(os.path.join(self.output, 'openlayers.html'), 'wb') - f.write(self.generate_openlayers().encode('utf-8')) - f.close() + if ( + self.options.webviewer in ("all", "google") + and self.options.profile == "mercator" + ): + if not self.options.resume or not isfile( + os.path.join(self.output_folder, "googlemaps.html") + ): + with my_open( + os.path.join(self.output_folder, + "googlemaps.html"), "wb" + ) as f: + f.write(self.generate_googlemaps().encode("utf-8")) # Generate leaflet.html - if self.options.webviewer in ('all', 'leaflet'): - if (not self.options.resume or not - os.path.exists(os.path.join(self.output, 'leaflet.html'))): - f = open(os.path.join(self.output, 'leaflet.html'), 'wb') - f.write(self.generate_leaflet().encode('utf-8')) - f.close() + if self.options.webviewer in ("all", "leaflet"): + if not self.options.resume or not isfile( + os.path.join(self.output_folder, "leaflet.html") + ): + with my_open( + os.path.join(self.output_folder, "leaflet.html"), "wb" + ) as f: + f.write(self.generate_leaflet().encode("utf-8")) - elif self.options.profile == 'geodetic': + elif self.options.profile == "geodetic": west, south = self.ominx, self.ominy east, north = self.omaxx, self.omaxy @@ -1435,15 +2972,7 @@ def generate_metadata(self): north, east = min(90.0, north), min(180.0, east) self.swne = (south, west, north, east) - # Generate openlayers.html - if self.options.webviewer in ('all', 'openlayers'): - if (not self.options.resume or not - os.path.exists(os.path.join(self.output, 'openlayers.html'))): - f = open(os.path.join(self.output, 'openlayers.html'), 'wb') - f.write(self.generate_openlayers().encode('utf-8')) - f.close() - - elif self.options.profile == 'raster': + elif self.options.profile == "raster": west, south = self.ominx, self.ominy east, north = self.omaxx, self.omaxy @@ -1457,114 +2986,149 @@ def generate_metadata(self): self.swne = (south, west, north, east) - # Generate openlayers.html - if self.options.webviewer in ('all', 'openlayers'): - if (not self.options.resume or not - os.path.exists(os.path.join(self.output, 'openlayers.html'))): - f = open(os.path.join(self.output, 'openlayers.html'), 'wb') - f.write(self.generate_openlayers().encode('utf-8')) - f.close() + else: + self.swne = None + + # Generate openlayers.html + if self.options.webviewer in ("all", "openlayers"): + if not self.options.resume or not isfile( + os.path.join(self.output_folder, "openlayers.html") + ): + with my_open( + os.path.join(self.output_folder, "openlayers.html"), "wb" + ) as f: + f.write(self.generate_openlayers().encode("utf-8")) # Generate tilemapresource.xml. - if not self.options.resume or not os.path.exists(os.path.join(self.output, 'tilemapresource.xml')): - f = open(os.path.join(self.output, 'tilemapresource.xml'), 'wb') - f.write(self.generate_tilemapresource().encode('utf-8')) - f.close() + if ( + not self.options.xyz + and self.swne is not None + and ( + not self.options.resume + or not isfile(os.path.join(self.output_folder, "tilemapresource.xml")) + ) + ): + with my_open( + os.path.join(self.output_folder, "tilemapresource.xml"), "wb" + ) as f: + f.write(self.generate_tilemapresource().encode("utf-8")) + + # Generate mapml file + if ( + self.options.webviewer in ("all", "mapml") + and self.options.xyz + and self.options.profile != "raster" + and (self.options.profile != "geodetic" or self.options.tmscompatible) + and ( + not self.options.resume + or not isfile(os.path.join(self.output_folder, "mapml.mapml")) + ) + ): + with my_open(os.path.join(self.output_folder, "mapml.mapml"), "wb") as f: + f.write(self.generate_mapml().encode("utf-8")) - if self.kml: + if self.kml and self.tileswne is not None: # TODO: Maybe problem for not automatically generated tminz # The root KML should contain links to all tiles in the tminz level children = [] xmin, ymin, xmax, ymax = self.tminmax[self.tminz] - for x in range(xmin, xmax+1): - for y in range(ymin, ymax+1): + for x in range(xmin, xmax + 1): + for y in range(ymin, ymax + 1): children.append([x, y, self.tminz]) # Generate Root KML if self.kml: - if (not self.options.resume or not - os.path.exists(os.path.join(self.output, 'doc.kml'))): - f = open(os.path.join(self.output, 'doc.kml'), 'wb') - f.write(self.generate_kml( - None, None, None, children).encode('utf-8')) - f.close() - - def generate_base_tiles(self, tz): + if not self.options.resume or not isfile( + os.path.join(self.output_folder, "doc.kml") + ): + with my_open( + os.path.join(self.output_folder, "doc.kml"), "wb" + ) as f: + f.write( + generate_kml( + None, + None, + None, + self.tileext, + self.tile_size, + self.tileswne, + self.options, + children, + ).encode("utf-8") + ) + + def generate_base_tiles(self) -> Tuple[TileJobInfo, List[TileDetail]]: """ Generation of the base tiles (the lowest in the pyramid) directly from the input raster """ - if self.isDEMtile: - print("Generating Tiles at Zoom " + str(tz) + ": ") - if not self.options.quiet: print("Generating Base Tiles:") if self.options.verbose: - print('') + print("") print("Tiles generated from the max zoom level:") print("----------------------------------------") - print('') + print("") - ds = self.out_ds + # Set the bounds + tminx, tminy, tmaxx, tmaxy = self.tminmax[self.tmaxz] + ds = self.warped_input_dataset + tilebands = self.dataBandsCount + 1 querysize = self.querysize - - # 1bto4b - if self.isDEMtile: - tilebands = 4 - querysize = self.tilesize - else: - tilebands = self.dataBandsCount + 1 - tz = self.tmaxz - - try: - self.tminmax[tz] - except IndexError: - print(" Won't make zoom level " + str(tz)) - return - - # Set the bounds - tminx, tminy, tmaxx, tmaxy = self.tminmax[tz] + isDEMtile = self.isDEMtile if self.options.verbose: print("dataBandsCount: ", self.dataBandsCount) print("tilebands: ", tilebands) - tcount = (1+abs(tmaxx-tminx)) * (1+abs(tmaxy-tminy)) + tcount = (1 + abs(tmaxx - tminx)) * (1 + abs(tmaxy - tminy)) ti = 0 - for ty in range(tmaxy, tminy-1, -1): - for tx in range(tminx, tmaxx+1): + tile_details = [] + + tz = self.tmaxz + + #print('xyz', tmaxx, tminx, tmaxy, tminy, tz) + + # Create directories for the tiles + for tx in range(tminx, tmaxx + 1): + tiledirname = os.path.join(self.output_folder, str(tz), str(tx)) + makedirs(tiledirname) + + for ty in range(tmaxy, tminy - 1, -1): + for tx in range(tminx, tmaxx + 1): - if self.stopped: - break ti += 1 + ytile = GDAL2Tiles.getYTile(ty, tz, self.options) tilefilename = os.path.join( - self.output, str(tz), str(tx), "%s.%s" % (ty, self.tileext)) + self.output_folder, + str(tz), + str(tx), + "%s.%s" % (ytile, self.tileext), + ) if self.options.verbose: - print(ti, '/', tcount, tilefilename) + print(ti, "/", tcount, tilefilename) - if self.options.resume and os.path.exists(tilefilename): + if self.options.resume and isfile(tilefilename): if self.options.verbose: print("Tile generation skipped because of --resume") - else: - self.progressbar(ti / float(tcount)) continue - # Create directories for the tile - if not os.path.exists(os.path.dirname(tilefilename)): - os.makedirs(os.path.dirname(tilefilename)) - - if self.options.profile == 'mercator': + if self.options.profile == "mercator": # Tile bounds in EPSG:3857 b = self.mercator.TileBounds(tx, ty, tz) - elif self.options.profile == 'geodetic': + elif self.options.profile == "geodetic": b = self.geodetic.TileBounds(tx, ty, tz) + elif self.options.profile != "raster": + b = tmsMap[self.options.profile].TileBounds( + tx, ty, tz, self.tile_size + ) # Don't scale up by nearest neighbour, better change the querysize # to the native resolution (and return smaller query tile) for scaling - if self.options.profile in ('mercator', 'geodetic'): + if self.options.profile != "raster": rb, wb = self.geo_query(ds, b[0], b[3], b[2], b[1]) # Pixel size in the raster covering query geo extent @@ -1575,25 +3139,23 @@ def generate_base_tiles(self, tz): # Tile bounds in raster coordinates for ReadRaster query rb, wb = self.geo_query( - ds, b[0], b[3], b[2], b[1], querysize=querysize) + ds, b[0], b[3], b[2], b[1], querysize=querysize + ) rx, ry, rxsize, rysize = rb wx, wy, wxsize, wysize = wb - wxsize -= 1 # 1bto4b - wysize -= 1 # 1bto4b # MMGIS - elif self.isRasterBounded: # 'raster' profile: - + elif self.isRasterBounded: # 'raster' profile: # tilesize in raster coordinates for actual zoom tsize = int(self.tsize[tz]) - xsize = self.out_ds.fWorldXSize - ysize = self.out_ds.fWorldYSize + xsize = self.warped_input_dataset.fWorldXSize + ysize = self.warped_input_dataset.fWorldYSize if tz >= self.tmaxz: - querysize = self.tilesize + querysize = self.tile_size + + rx = (tx) * tsize - self.warped_input_dataset.fRasterXOriginWorld - rx = (tx) * tsize - self.out_ds.fRasterXOriginWorld - #print("rx", rx) rxsize = 0 rxsize = tsize @@ -1601,608 +3163,128 @@ def generate_base_tiles(self, tz): rysize = tsize ry = ysize - (ty * tsize) - rysize - \ - self.out_ds.fRasterYOriginWorld + self.warped_input_dataset.fRasterYOriginWorld wx, wy = 0, 0 - wxsize = int(rxsize/float(tsize) * self.tilesize) - wysize = int(rysize/float(tsize) * self.tilesize) - if wysize != self.tilesize: - wy = self.tilesize - wysize + wxsize = rxsize/float(tsize) * self.tile_size + wysize = rysize/float(tsize) * self.tile_size + if wysize != self.tile_size: + wy = self.tile_size - wysize if rx < 0: rxsize = tsize + rx wx = -rx - wxsize = int(rxsize/float(tsize) * self.tilesize) + wxsize = rxsize/float(tsize) * self.tile_size rx = 0 if ry < 0: rysize = tsize + ry wy = -ry - wysize = int(rysize/float(tsize) * self.tilesize) + wysize = rysize/float(tsize) * self.tile_size ry = 0 - if rx + rxsize > self.out_ds.fRasterXSizeWorld: - rxsize = self.out_ds.fRasterXSizeWorld - rx - wxsize = int(rxsize/float(tsize) * self.tilesize) - if ry + rysize > self.out_ds.fRasterYSizeWorld: - rysize = self.out_ds.fRasterYSizeWorld - ry - wysize = int(rysize/float(tsize) * self.tilesize) + if rx + rxsize > self.warped_input_dataset.fRasterXSizeWorld: + rxsize = self.warped_input_dataset.fRasterXSizeWorld - rx + wxsize = rxsize/float(tsize) * self.tile_size + if ry + rysize > self.warped_input_dataset.fRasterYSizeWorld: + rysize = self.warped_input_dataset.fRasterYSizeWorld - ry + wysize = rysize/float(tsize) * self.tile_size # Convert rx, ry back to non-world coordinates - rx = int(float(self.out_ds.RasterXSize) * - (float(rx) / self.out_ds.fRasterXSizeWorld)) - ry = int(float(self.out_ds.RasterYSize) * - (float(ry) / self.out_ds.fRasterYSizeWorld)) - rxsize = int(float(self.out_ds.RasterXSize) * - (float(rxsize) / self.out_ds.fRasterXSizeWorld)) - rysize = int(float(self.out_ds.RasterYSize) * - (float(rysize) / self.out_ds.fRasterYSizeWorld)) - - wxsize -= 1 # 1bto4b - wysize -= 1 # 1bto4b - - #print("Extent: ", (tx, ty, tz, tsize), (rx, ry, rxsize, rysize), (wx, wy, wxsize, wysize), (self.out_ds.fRasterXOrigin, self.out_ds.fRasterYOrigin)) - else: # 'raster' profile: - # tilesize in raster coordinates for actual zoom - tsize = int(self.tsize[tz]) - xsize = self.out_ds.RasterXSize # size of the raster in pixels - ysize = self.out_ds.RasterYSize - if tz >= self.tmaxz: - querysize = self.tilesize - - rx = (tx) * tsize + rx = float(self.warped_input_dataset.RasterXSize) * (float(rx) / self.warped_input_dataset.fRasterXSizeWorld) + ry = float(self.warped_input_dataset.RasterYSize) * (float(ry) / self.warped_input_dataset.fRasterYSizeWorld) + rxsize = float(self.warped_input_dataset.RasterXSize) * (float(rxsize) / self.warped_input_dataset.fRasterXSizeWorld) + rysize = float(self.warped_input_dataset.RasterYSize) * (float(rysize) / self.warped_input_dataset.fRasterYSizeWorld) + + if self.isDEMtile: + wxsize -= 1 # 1bto4b + wysize -= 1 # 1bto4b + + rx = round(rx) + ry = round(ry) + rxsize = math.floor(rxsize) + rysize = math.floor(rysize) + wx = round(wx) + wy = round(wy) + wxsize = round(wxsize) + wysize = round(wysize) + + + #print("Tile: ", (tz, tx, ty, tsize)) + #print("Read: ", (rx, ry, rxsize, rysize)) + #print("Write: ",(wx, wy, wxsize, wysize)) + else: # 'raster' profile: + + tsize = int( + self.tsize[tz] + ) # tile_size in raster coordinates for actual zoom + xsize = ( + self.warped_input_dataset.RasterXSize + ) # size of the raster in pixels + ysize = self.warped_input_dataset.RasterYSize + querysize = self.tile_size + + rx = tx * tsize rxsize = 0 if tx == tmaxx: rxsize = xsize % tsize if rxsize == 0: rxsize = tsize + ry = ty * tsize rysize = 0 if ty == tmaxy: rysize = ysize % tsize if rysize == 0: rysize = tsize - ry = ysize - (ty * tsize) - rysize wx, wy = 0, 0 - wxsize = int(rxsize/float(tsize) * self.tilesize) - wysize = int(rysize/float(tsize) * self.tilesize) - if wysize != self.tilesize: - wy = self.tilesize - wysize - - if self.options.verbose: - print("\tReadRaster Extent: ", - (rx, ry, rxsize, rysize), (wx, wy, wxsize, wysize)) - - # Query is in 'nearest neighbour' but can be bigger in then the tilesize - # We scale down the query to the tilesize by supplied algorithm. + wxsize = int(rxsize / float(tsize) * self.tile_size) + wysize = int(rysize / float(tsize) * self.tile_size) - # Tile dataset in memory + if not self.options.xyz: + ry = ysize - (ty * tsize) - rysize + if wysize != self.tile_size: + wy = self.tile_size - wysize - # 1bto4b - if self.isDEMtile: - dstile = self.mem_drv.Create( - '', self.tilesize, self.tilesize, tilebands, gdal.GDT_Byte) - else: - dstile = self.mem_drv.Create( - '', self.tilesize, self.tilesize, tilebands) - - data = alpha = None # Read the source raster if anything is going inside the tile as per the computed # geo_query - if rxsize != 0 and rysize != 0 and wxsize != 0 and wysize != 0: - # 1bto4b - if self.isDEMtile: - data = ds.GetRasterBand(1).ReadRaster( - rx, ry, rxsize, rysize, wxsize, wysize, buf_type=gdal.GDT_Float32) - else: - data = ds.ReadRaster(rx, ry, rxsize, rysize, wxsize, wysize, - band_list=list(range(1, self.dataBandsCount+1))) - alpha = self.alphaband.ReadRaster( - rx, ry, rxsize, rysize, wxsize, wysize) - - # The tile in memory is a transparent file by default. Write pixel values into it if - # any - if data: - # 1bto4b - both this full if and else - if self.isDEMtile: - if (wxsize * wysize) > 0: - data = struct.unpack('f' * wxsize * wysize, data) - else: - return - - if self.tilesize == querysize: - # Interpolate the values from four surrounding - - # This takes our 1d list of WxH data and pads it with a rect of none values - dataPad = list(data) - for i in reversed(range(1, wysize)): - dataPad.insert(wxsize * i, 0) - dataPad.insert(wxsize * i, 0) - for i in range(wxsize + 3): - dataPad.insert(0, 0) - for i in range(wxsize + 3): - dataPad.append(0) - - dataIn = [] - # Resample based on average of four - # averaging over: i, i + 1, i + wxsize, i + wxsize + 1 - for y in range(wysize+2 - 1): - for x in range(wxsize+2 - 1): - i = x+(y*(wxsize+2)) - nW = dataPad[i] - nE = dataPad[i+1] - sW = dataPad[i+(wxsize+2)] - sE = dataPad[i+(wxsize+2)+1] - dataIn.append((nW + nE + sW + sE)/float(4)) - - # Get the surrounding eight tiles - # Get NW - if tx - 1 >= tminx and ty + 1 <= tmaxy: - rxNW, ryNW, rxsizeNW, rysizeNW, wxsizeNW, wysizeNW = getTilePxBounds(self, - tx - 1, ty + 1, tz, ds) - wxsizeNW -= 1 - wysizeNW -= 1 - if wxsizeNW != 0 and wysizeNW != 0: - dataNW = ds.GetRasterBand(1).ReadRaster( - rxNW, ryNW, rxsizeNW, rysizeNW, wxsizeNW, wysizeNW, buf_type=gdal.GDT_Float32) - if dataNW is not None and (wxsizeNW * wysizeNW) > 0: - dataNW = struct.unpack( - 'f' * wxsizeNW * wysizeNW, dataNW) - else: - dataNW = None - else: - dataNW = None - - # Get N - if ty + 1 <= tmaxy: - rxN, ryN, rxsizeN, rysizeN, wxsizeN, wysizeN = getTilePxBounds( - self, tx, ty + 1, tz, ds) - wxsizeN -= 1 - wysizeN -= 1 - if wxsizeN != 0 and wysizeN != 0: - dataN = ds.GetRasterBand(1).ReadRaster( - rxN, ryN, rxsizeN, rysizeN, wxsizeN, wysizeN, buf_type=gdal.GDT_Float32) - if dataN is not None and (wxsizeN * wysizeN) > 0: - dataN = struct.unpack( - 'f' * wxsizeN * wysizeN, dataN) - else: - dataN = None - else: - dataN = None - # Get NE - if tx + 1 <= tmaxx and ty + 1 <= tmaxy: - rxNE, ryNE, rxsizeNE, rysizeNE, wxsizeNE, wysizeNE = getTilePxBounds( - self, tx + 1, ty + 1, tz, ds) - wxsizeNE -= 1 - wysizeNE -= 1 - if wxsizeNE != 0 and wysizeNE != 0: - dataNE = ds.GetRasterBand(1).ReadRaster( - rxNE, ryNE, rxsizeNE, rysizeNE, wxsizeNE, wysizeNE, buf_type=gdal.GDT_Float32) - if dataNE is not None and (wxsizeNE * wysizeNE) > 0: - dataNE = struct.unpack( - 'f' * wxsizeNE * wysizeNE, dataNE) - else: - dataNE = None - else: - dataNE = None - # Get E - if tx + 1 <= tmaxx: - rxE, ryE, rxsizeE, rysizeE, wxsizeE, wysizeE = getTilePxBounds( - self, tx + 1, ty, tz, ds) - wxsizeE -= 1 - wysizeE -= 1 - if wxsizeE != 0 and wysizeE != 0: - dataE = ds.GetRasterBand(1).ReadRaster( - rxE, ryE, rxsizeE, rysizeE, wxsizeE, wysizeE, buf_type=gdal.GDT_Float32) - if dataE is not None and (wxsizeE * wysizeE) > 0: - dataE = struct.unpack( - 'f' * wxsizeE * wysizeE, dataE) - else: - dataE = None - else: - dataE = None - # Get SE - if tx + 1 <= tmaxx and ty - 1 >= tminy: - rxSE, rySE, rxsizeSE, rysizeSE, wxsizeSE, wysizeSE = getTilePxBounds( - self, tx + 1, ty - 1, tz, ds) - wxsizeSE -= 1 - wysizeSE -= 1 - if wxsizeSE != 0 and wysizeSE != 0: - dataSE = ds.GetRasterBand(1).ReadRaster( - rxSE, rySE, rxsizeSE, rysizeSE, wxsizeSE, wysizeSE, buf_type=gdal.GDT_Float32) - if dataSE is not None and (wxsizeSE * wysizeSE) > 0: - dataSE = struct.unpack( - 'f' * wxsizeSE * wysizeSE, dataSE) - else: - dataSE = None - else: - dataSE = None - # Get S - if ty - 1 >= tminy: - rxS, ryS, rxsizeS, rysizeS, wxsizeS, wysizeS = getTilePxBounds( - self, tx, ty - 1, tz, ds) - wxsizeS -= 1 - wysizeS -= 1 - if wxsizeS != 0 and wysizeS != 0: - dataS = ds.GetRasterBand(1).ReadRaster( - rxS, ryS, rxsizeS, rysizeS, wxsizeS, wysizeS, buf_type=gdal.GDT_Float32) - if dataS is not None and (wxsizeS * wysizeS) > 0: - dataS = struct.unpack( - 'f' * wxsizeS * wysizeS, dataS) - else: - dataS = None - else: - dataS = None - # Get SW - if tx - 1 >= tminx and ty - 1 >= tminy: - rxSW, rySW, rxsizeSW, rysizeSW, wxsizeSW, wysizeSW = getTilePxBounds( - self, tx - 1, ty - 1, tz, ds) - wxsizeSW -= 1 - wysizeSW -= 1 - if wxsizeSW != 0 and wysizeSW != 0: - dataSW = ds.GetRasterBand(1).ReadRaster( - rxSW, rySW, rxsizeSW, rysizeSW, wxsizeSW, wysizeSW, buf_type=gdal.GDT_Float32) - if dataSW is not None and (wxsizeSW * wysizeSW) > 0: - dataSW = struct.unpack( - 'f' * wxsizeSW * wysizeSW, dataSW) - else: - dataSW = None - else: - dataSW = None - # Get W - if tx - 1 >= tminx: - rxW, ryW, rxsizeW, rysizeW, wxsizeW, wysizeW = getTilePxBounds( - self, tx - 1, ty, tz, ds) - wxsizeW -= 1 - wysizeW -= 1 - if wxsizeW != 0 and wysizeW != 0: - dataW = ds.GetRasterBand(1).ReadRaster( - rxW, ryW, rxsizeW, rysizeW, wxsizeW, wysizeW, buf_type=gdal.GDT_Float32) - if dataW is not None and (wxsizeW * wysizeW) > 0: - dataW = struct.unpack( - 'f' * wxsizeW * wysizeW, dataW) - else: - dataW = None - else: - dataW = None - - # NW (uses N, NW, W) - fN = fNE = fE = fSE = fS = fSW = fW = fNW = 0 - values = 1 - if dataN is not None: - fN = dataN[len(dataN)-wxsizeN] - values = values + 1 - if dataNW is not None: - fNW = dataNW[len(dataNW)-1] - values = values + 1 - if dataW is not None: - fW = dataW[wxsizeW-1] - values = values + 1 - dataIn[0] = ((dataIn[0]*4) + fN + - fNW + fW)/float(values) - - # NE (uses N, NE, E) - fN = fNE = fE = fSE = fS = fSW = fW = fNW = 0 - values = 1 - if dataN is not None: - fN = dataN[len(dataN)-1] - values = values + 1 - if dataNE is not None: - fNE = dataNE[len(dataNE)-wxsizeNE] - values = values + 1 - if dataE is not None: - fE = dataE[0] - values = values + 1 - dataIn[wxsize] = ( - (dataIn[wxsize]*4) + fN + fNE + fE)/float(values) - - # SE (uses S, SE, E) - fN = fNE = fE = fSE = fS = fSW = fW = fNW = 0 - values = 1 - if dataS is not None: - fS = dataS[wxsizeS-1] - values = values + 1 - if dataSE is not None: - fSE = dataSE[0] - values = values + 1 - if dataE is not None: - fE = dataE[len(dataE)-wxsizeE] - values = values + 1 - dataIn[len(dataIn)-1] = ((dataIn[len(dataIn)-1] - * 4) + fS + fSE + fE)/float(values) - - # SW (uses S, SW, W) - fN = fNE = fE = fSE = fS = fSW = fW = fNW = 0 - values = 1 - if dataS is not None: - fS = dataS[0] - values = values + 1 - if dataSW is not None: - fSW = dataSW[wxsizeSW-1] - values = values + 1 - if dataW is not None: - fW = dataW[len(dataW)-1] - values = values + 1 - dataIn[len( - dataIn)-wxsize-1] = ((dataIn[len(dataIn)-wxsize-1]*4) + fS + fSW + fW)/float(values) - - # Then the edges minus corners - # N - if dataN is not None: - for i in range(1, wxsize): - dataIn[i] = ( - (dataIn[i]*4) + dataN[len(dataN)-wxsizeN-1+i] + dataN[len(dataN)-wxsizeN-1+i+1])/float(4) - else: - for i in range(1, wxsize): - dataIn[i] = (dataIn[i]*4)/float(2) - - # E - if dataE is not None: - for i in range(1, wysize): - dataIn[((i+1)*(wxsize+1)-1)] = ((dataIn[((i+1)*(wxsize+1)-1)] - * 4) + dataE[(i-1)*wxsizeE] + dataE[i*wxsizeE])/float(4) - else: - for i in range(1, wysize): - dataIn[( - (i+1)*(wxsize+1)-1)] = (dataIn[((i+1)*(wxsize+1)-1)]*4)/float(2) - - # S - if dataS is not None: - for i in range(1, wxsize): - dataIn[len(dataIn)-wxsize-1+i] = ( - (dataIn[len(dataIn)-wxsize-1+i]*4) + dataS[i-1] + dataS[i])/float(4) - else: - for i in range(1, wxsize): - dataIn[len( - dataIn)-wxsize-1+i] = (dataIn[len(dataIn)-wxsize-1+i]*4)/float(2) - - # W - if dataW is not None: - for i in range(1, wysize): - dataIn[(i)*(wxsize+1)] = ((dataIn[(i)*(wxsize+1)]*4) + - dataW[i*wxsizeW-1] + dataW[(i+1)*wxsizeW-1])/float(4) - else: - for i in range(1, wysize): - dataIn[(i)*(wxsize+1)] = (dataIn[(i) - * (wxsize+1)]*4)/float(2) - - data1 = [] - data2 = [] - data3 = [] - data4 = [] - for f in dataIn: - f = str(binary(f)) - data1.append(int(f[:8], 2)) - data2.append(int(f[8:16], 2)) - data3.append(int(f[16:24], 2)) - data4.append(int(f[24:], 2)) - - data1s = b'' - data2s = b'' - data3s = b'' - data4s = b'' - indx = 0 - for v in data1: - data1s += struct.pack('B', data1[indx]) - data2s += struct.pack('B', data2[indx]) - data3s += struct.pack('B', data3[indx]) - data4s += struct.pack('B', data4[indx]) - indx += 1 - dstile.GetRasterBand(1).WriteRaster( - wx, wy, wxsize + 1, wysize + 1, data1s, buf_type=gdal.GDT_Byte) - dstile.GetRasterBand(2).WriteRaster( - wx, wy, wxsize + 1, wysize + 1, data2s, buf_type=gdal.GDT_Byte) - dstile.GetRasterBand(3).WriteRaster( - wx, wy, wxsize + 1, wysize + 1, data3s, buf_type=gdal.GDT_Byte) - dstile.GetRasterBand(4).WriteRaster( - wx, wy, wxsize + 1, wysize + 1, data4s, buf_type=gdal.GDT_Byte) - elif wxsize != 0 and wysize != 0: - # Big ReadRaster query in memory scaled to the tilesize - all but 'near' algo - dsquery = self.mem_drv.Create( - '', querysize, querysize, tilebands, gdal.GDT_Byte) # 1bto4b - # TODO: fill the null value in case a tile without alpha is produced (now only png tiles are supported) - # for i in range(1, tilebands+1): - # dsquery.GetRasterBand(1).Fill(tilenodata) - # dsquery.WriteRaster(wx, wy, wxsize, wysize, data, band_list=list(range(1,self.dataBandsCount+1)))###############1bto4b - # dsquery.WriteRaster(wx, wy, wxsize, wysize, alpha, band_list=[tilebands])###############################1bto4b - - # 1bto4b - data = ds.GetRasterBand(1).ReadRaster( - rx, ry, rxsize, rysize, wxsize, wysize, buf_type=gdal.GDT_Float32) - - data = struct.unpack('f' * wxsize * wysize, data) - data1 = [] - data2 = [] - data3 = [] - data4 = [] - for f in data: - f = str(binary(f)) - data1.append(int(f[:8], 2)) - data2.append(int(f[8:16], 2)) - data3.append(int(f[16:24], 2)) - data4.append(int(f[24:], 2)) - - data1s = b'' - data2s = b'' - data3s = b'' - data4s = b'' - indx = 0 - for v in data1: - data1s += struct.pack('B', data1[indx]) - data2s += struct.pack('B', data2[indx]) - data3s += struct.pack('B', data3[indx]) - data4s += struct.pack('B', data4[indx]) - indx += 1 - - dsquery.GetRasterBand(1).WriteRaster( - wx, wy, wxsize, wysize, data1s, buf_type=gdal.GDT_Byte) - dsquery.GetRasterBand(2).WriteRaster( - wx, wy, wxsize, wysize, data2s, buf_type=gdal.GDT_Byte) - dsquery.GetRasterBand(3).WriteRaster( - wx, wy, wxsize, wysize, data3s, buf_type=gdal.GDT_Byte) - dsquery.GetRasterBand(4).WriteRaster( - wx, wy, wxsize, wysize, data4s, buf_type=gdal.GDT_Byte) - # sys.exit('done') - # 1bto4b - - self.scale_query_to_tile( - dsquery, dstile, tilefilename) - del dsquery - - else: - if self.tilesize == querysize: - # Use the ReadRaster result directly in tiles ('nearest neighbour' query) - dstile.WriteRaster(wx, wy, wxsize, wysize, data, - band_list=list(range(1, self.dataBandsCount+1))) - dstile.WriteRaster( - wx, wy, wxsize, wysize, alpha, band_list=[tilebands]) - - # Note: For source drivers based on WaveLet compression (JPEG2000, ECW, - # MrSID) the ReadRaster function returns high-quality raster (not ugly - # nearest neighbour) - # TODO: Use directly 'near' for WaveLet files - else: - # Big ReadRaster query in memory scaled to the tilesize - all but 'near' - # algo - dsquery = self.mem_drv.Create( - '', querysize, querysize, tilebands) - # TODO: fill the null value in case a tile without alpha is produced (now - # only png tiles are supported) - dsquery.WriteRaster(wx, wy, wxsize, wysize, data, - band_list=list(range(1, self.dataBandsCount+1))) - dsquery.WriteRaster( - wx, wy, wxsize, wysize, alpha, band_list=[tilebands]) - - self.scale_query_to_tile( - dsquery, dstile, tilefilename) - del dsquery - - del data - - if self.options.resampling != 'antialias': - # Write a copy of tile to png/jpg - self.out_drv.CreateCopy(tilefilename, dstile, strict=0) - - del dstile - - # Create a KML file for this tile. - if self.kml: - kmlfilename = os.path.join( - self.output, str(tz), str(tx), '%d.kml' % ty) - if not self.options.resume or not os.path.exists(kmlfilename): - f = open(kmlfilename, 'wb') - f.write(self.generate_kml(tx, ty, tz).encode('utf-8')) - f.close() - - if not self.options.verbose and not self.options.quiet: - self.progressbar(ti / float(tcount)) - - def generate_overview_tiles(self): - """Generation of the overview tiles (higher in the pyramid) based on existing tiles""" - - if not self.options.quiet: - print("Generating Overview Tiles:") - - # 1bto4b - if self.isDEMtile: - tilebands = 4 - else: - tilebands = self.dataBandsCount + 1 - - # Usage of existing tiles: from 4 underlying tiles generate one as overview. - - tcount = 0 - for tz in range(self.tmaxz-1, self.tminz-1, -1): - tminx, tminy, tmaxx, tmaxy = self.tminmax[tz] - tcount += (1+abs(tmaxx-tminx)) * (1+abs(tmaxy-tminy)) - - ti = 0 - - for tz in range(self.tmaxz-1, self.tminz-1, -1): - tminx, tminy, tmaxx, tmaxy = self.tminmax[tz] - for ty in range(tmaxy, tminy-1, -1): - for tx in range(tminx, tmaxx+1): - - if self.stopped: - break - - ti += 1 - tilefilename = os.path.join(self.output, - str(tz), - str(tx), - "%s.%s" % (ty, self.tileext)) - - if self.options.verbose: - print(ti, '/', tcount, tilefilename) - - if self.options.resume and os.path.exists(tilefilename): - if self.options.verbose: - print("Tile generation skipped because of --resume") - else: - self.progressbar(ti / float(tcount)) - continue - - # Create directories for the tile - if not os.path.exists(os.path.dirname(tilefilename)): - os.makedirs(os.path.dirname(tilefilename)) - - dsquery = self.mem_drv.Create( - '', 2*self.tilesize, 2*self.tilesize, tilebands) - # TODO: fill the null value - dstile = self.mem_drv.Create( - '', self.tilesize, self.tilesize, tilebands) - - # TODO: Implement more clever walking on the tiles with cache functionality - # probably walk should start with reading of four tiles from top left corner - # Hilbert curve - - children = [] - # Read the tiles and write them to query window - for y in range(2*ty, 2*ty+2): - for x in range(2*tx, 2*tx+2): - minx, miny, maxx, maxy = self.tminmax[tz+1] - if x >= minx and x <= maxx and y >= miny and y <= maxy: - dsquerytile = gdal.Open( - os.path.join(self.output, str(tz+1), str(x), - "%s.%s" % (y, self.tileext)), - gdal.GA_ReadOnly) - if (ty == 0 and y == 1) or (ty != 0 and (y % (2*ty)) != 0): - tileposy = 0 - else: - tileposy = self.tilesize - if tx: - tileposx = x % (2*tx) * self.tilesize - elif tx == 0 and x == 1: - tileposx = self.tilesize - else: - tileposx = 0 - dsquery.WriteRaster( - tileposx, tileposy, self.tilesize, self.tilesize, - dsquerytile.ReadRaster( - 0, 0, self.tilesize, self.tilesize), - band_list=list(range(1, tilebands+1))) - children.append([x, y, tz+1]) - - self.scale_query_to_tile(dsquery, dstile, tilefilename) - # Write a copy of tile to png/jpg - if self.options.resampling != 'antialias': - # Write a copy of tile to png/jpg - self.out_drv.CreateCopy(tilefilename, dstile, strict=0) - - if self.options.verbose: - print("\tbuild from zoom", tz+1, - " tiles:", (2*tx, 2*ty), (2*tx+1, 2*ty), - (2*tx, 2*ty+1), (2*tx+1, 2*ty+1)) - - # Create a KML file for this tile. - if self.kml: - f = open(os.path.join( - self.output, '%d/%d/%d.kml' % (tz, tx, ty)), 'wb') - f.write(self.generate_kml( - tx, ty, tz, children).encode('utf-8')) - f.close() + tile_details.append( + TileDetail( + tx=tx, + ty=ytile, + tz=tz, + rx=rx, + ry=ry, + rxsize=rxsize, + rysize=rysize, + wx=wx, + wy=wy, + wxsize=wxsize, + wysize=wysize, + querysize=querysize, + isDEMtile=isDEMtile + ) + ) + + conf = TileJobInfo( + src_file=self.tmp_vrt_filename, + nb_data_bands=self.dataBandsCount, + output_file_path=self.output_folder, + tile_extension=self.tileext, + tile_driver=self.tiledriver, + tile_size=self.tile_size, + kml=self.kml, + tminmax=self.tminmax, + tminz=self.tminz, + tmaxz=self.tmaxz, + in_srs_wkt=self.in_srs_wkt, + out_geo_trans=self.out_gt, + ominy=self.ominy, + is_epsg_4326=self.isepsg4326, + options=self.options, + exclude_transparent=self.options.exclude_transparent, + ) - if not self.options.verbose and not self.options.quiet: - self.progressbar(ti / float(tcount)) + return conf, tile_details def geo_query(self, ds, ulx, uly, lrx, lry, querysize=0): """ @@ -2215,8 +3297,8 @@ def geo_query(self, ds, ulx, uly, lrx, lry, querysize=0): geotran = ds.GetGeoTransform() rx = int((ulx - geotran[0]) / geotran[1] + 0.001) ry = int((uly - geotran[3]) / geotran[5] + 0.001) - rxsize = int((lrx - ulx) / geotran[1] + 0.5) - rysize = int((lry - uly) / geotran[5] + 0.5) + rxsize = max(1, int((lrx - ulx) / geotran[1] + 0.5)) + rysize = max(1, int((lry - uly) / geotran[5] + 0.5)) if not querysize: wxsize, wysize = rxsize, rysize @@ -2231,7 +3313,7 @@ def geo_query(self, ds, ulx, uly, lrx, lry, querysize=0): wxsize = wxsize - wx rxsize = rxsize - int(rxsize * (float(rxshift) / rxsize)) rx = 0 - if rx+rxsize > ds.RasterXSize: + if rx + rxsize > ds.RasterXSize: wxsize = int(wxsize * (float(ds.RasterXSize - rx) / rxsize)) rxsize = ds.RasterXSize - rx @@ -2242,368 +3324,652 @@ def geo_query(self, ds, ulx, uly, lrx, lry, querysize=0): wysize = wysize - wy rysize = rysize - int(rysize * (float(ryshift) / rysize)) ry = 0 - if ry+rysize > ds.RasterYSize: + if ry + rysize > ds.RasterYSize: wysize = int(wysize * (float(ds.RasterYSize - ry) / rysize)) rysize = ds.RasterYSize - ry return (rx, ry, rxsize, rysize), (wx, wy, wxsize, wysize) - def scale_query_to_tile(self, dsquery, dstile, tilefilename=''): - """Scales down query dataset to the tile dataset""" - - querysize = dsquery.RasterXSize - tilesize = dstile.RasterXSize - tilebands = dstile.RasterCount - - if self.options.resampling == 'average': - - # Function: gdal.RegenerateOverview() - for i in range(1, tilebands+1): - # Black border around NODATA - res = gdal.RegenerateOverview(dsquery.GetRasterBand(i), dstile.GetRasterBand(i), - 'average') - if res != 0: - self.error("RegenerateOverview() failed on %s, error %d" % ( - tilefilename, res)) - - elif self.options.resampling == 'antialias': - - # Scaling by PIL (Python Imaging Library) - improved Lanczos - array = numpy.zeros((querysize, querysize, tilebands), numpy.uint8) - for i in range(tilebands): - array[:, :, i] = gdalarray.BandReadAsArray(dsquery.GetRasterBand(i+1), - 0, 0, querysize, querysize) - im = Image.fromarray(array, 'RGBA') # Always four bands - im1 = im.resize((tilesize, tilesize), Image.ANTIALIAS) - if os.path.exists(tilefilename): - im0 = Image.open(tilefilename) - im1 = Image.composite(im1, im0, im1) - im1.save(tilefilename, self.tiledriver) - - else: - - # Other algorithms are implemented by gdal.ReprojectImage(). - dsquery.SetGeoTransform((0.0, tilesize / float(querysize), 0.0, 0.0, 0.0, - tilesize / float(querysize))) - dstile.SetGeoTransform((0.0, 1.0, 0.0, 0.0, 0.0, 1.0)) - - res = gdal.ReprojectImage( - dsquery, dstile, None, None, self.resampling) - if res != 0: - self.error("ReprojectImage() failed on %s, error %d" % - (tilefilename, res)) - - def generate_tilemapresource(self): + def generate_tilemapresource(self) -> str: """ Template for tilemapresource.xml. Returns filled string. Expected variables: title, north, south, east, west, isepsg4326, projection, publishurl, - zoompixels, tilesize, tileformat, profile + zoompixels, tile_size, tileformat, profile """ args = {} - args['title'] = self.options.title - args['south'], args['west'], args['north'], args['east'] = self.swne - args['tilesize'] = self.tilesize - args['tileformat'] = self.tileext - args['publishurl'] = self.options.url - args['profile'] = self.options.profile - - if self.options.profile == 'mercator': - args['srs'] = "EPSG:3857" - elif self.options.profile == 'geodetic': - args['srs'] = "EPSG:4326" + args["xml_escaped_title"] = gdal.EscapeString( + self.options.title, gdal.CPLES_XML + ) + args["south"], args["west"], args["north"], args["east"] = self.swne + args["tile_size"] = self.tile_size + args["tileformat"] = self.tileext + args["publishurl"] = self.options.url + args["profile"] = self.options.profile + + if self.options.profile == "mercator": + args["srs"] = "EPSG:3857" + elif self.options.profile == "geodetic": + args["srs"] = "EPSG:4326" elif self.options.s_srs: - args['srs'] = self.options.s_srs + args["srs"] = self.options.s_srs elif self.out_srs: - args['srs'] = self.out_srs.ExportToWkt() + args["srs"] = self.out_srs.ExportToWkt() else: - args['srs'] = "" + args["srs"] = "" - s = """<?xml version="1.0" encoding="utf-8"?> + s = ( + """<?xml version="1.0" encoding="utf-8"?> <TileMap version="1.0.0" tilemapservice="http://tms.osgeo.org/1.0.0"> - <Title>%(title)s</Title> + <Title>%(xml_escaped_title)s</Title> <Abstract></Abstract> <SRS>%(srs)s</SRS> <BoundingBox minx="%(west).14f" miny="%(south).14f" maxx="%(east).14f" maxy="%(north).14f"/> <Origin x="%(west).14f" y="%(south).14f"/> - <TileFormat width="%(tilesize)d" height="%(tilesize)d" mime-type="image/%(tileformat)s" extension="%(tileformat)s"/> + <TileFormat width="%(tile_size)d" height="%(tile_size)d" mime-type="image/%(tileformat)s" extension="%(tileformat)s"/> <TileSets profile="%(profile)s"> -""" % args # noqa - for z in range(self.tminz, self.tmaxz+1): - if self.options.profile == 'raster': - s += """ <TileSet href="%s%d" units-per-pixel="%.14f" order="%d"/>\n""" % ( - args['publishurl'], z, (2**(self.nativezoom-z) * self.out_gt[1]), z) - elif self.options.profile == 'mercator': - s += """ <TileSet href="%s%d" units-per-pixel="%.14f" order="%d"/>\n""" % ( - args['publishurl'], z, 156543.0339/2**z, z) - elif self.options.profile == 'geodetic': - s += """ <TileSet href="%s%d" units-per-pixel="%.14f" order="%d"/>\n""" % ( - args['publishurl'], z, 0.703125/2**z, z) +""" + % args + ) # noqa + for z in range(self.tminz, self.tmaxz + 1): + if self.options.profile == "raster": + s += ( + """ <TileSet href="%s%d" units-per-pixel="%.14f" order="%d"/>\n""" + % ( + args["publishurl"], + z, + (2 ** (self.nativezoom - z) * self.out_gt[1]), + z, + ) + ) + elif self.options.profile == "mercator": + s += ( + """ <TileSet href="%s%d" units-per-pixel="%.14f" order="%d"/>\n""" + % (args["publishurl"], z, 156543.0339 / 2**z, z) + ) + elif self.options.profile == "geodetic": + s += ( + """ <TileSet href="%s%d" units-per-pixel="%.14f" order="%d"/>\n""" + % (args["publishurl"], z, 0.703125 / 2**z, z) + ) s += """ </TileSets> </TileMap> """ return s - def generate_kml(self, tx, ty, tz, children=None, **args): - """ - Template for the KML. Returns filled string. - """ - if not children: - children = [] - - args['tx'], args['ty'], args['tz'] = tx, ty, tz - args['tileformat'] = self.tileext - if 'tilesize' not in args: - args['tilesize'] = self.tilesize - - if 'minlodpixels' not in args: - args['minlodpixels'] = int(args['tilesize'] / 2) - if 'maxlodpixels' not in args: - args['maxlodpixels'] = int(args['tilesize'] * 8) - if children == []: - args['maxlodpixels'] = -1 - - if tx is None: - tilekml = False - args['title'] = self.options.title - else: - tilekml = True - args['title'] = "%d/%d/%d.kml" % (tz, tx, ty) - args['south'], args['west'], args['north'], args['east'] = self.tileswne( - tx, ty, tz) - - if tx == 0: - args['drawOrder'] = 2 * tz + 1 - elif tx is not None: - args['drawOrder'] = 2 * tz - else: - args['drawOrder'] = 0 - - url = self.options.url - if not url: - if tilekml: - url = "../../" - else: - url = "" - - s = """<?xml version="1.0" encoding="utf-8"?> - <kml xmlns="http://www.opengis.net/kml/2.2"> - <Document> - <name>%(title)s</name> - <description></description> - <Style> - <ListStyle id="hideChildren"> - <listItemType>checkHideChildren</listItemType> - </ListStyle> - </Style>""" % args - if tilekml: - s += """ - <Region> - <LatLonAltBox> - <north>%(north).14f</north> - <south>%(south).14f</south> - <east>%(east).14f</east> - <west>%(west).14f</west> - </LatLonAltBox> - <Lod> - <minLodPixels>%(minlodpixels)d</minLodPixels> - <maxLodPixels>%(maxlodpixels)d</maxLodPixels> - </Lod> - </Region> - <GroundOverlay> - <drawOrder>%(drawOrder)d</drawOrder> - <Icon> - <href>%(ty)d.%(tileformat)s</href> - </Icon> - <LatLonBox> - <north>%(north).14f</north> - <south>%(south).14f</south> - <east>%(east).14f</east> - <west>%(west).14f</west> - </LatLonBox> - </GroundOverlay> - """ % args - - for cx, cy, cz in children: - csouth, cwest, cnorth, ceast = self.tileswne(cx, cy, cz) - s += """ - <NetworkLink> - <name>%d/%d/%d.%s</name> - <Region> - <LatLonAltBox> - <north>%.14f</north> - <south>%.14f</south> - <east>%.14f</east> - <west>%.14f</west> - </LatLonAltBox> - <Lod> - <minLodPixels>%d</minLodPixels> - <maxLodPixels>-1</maxLodPixels> - </Lod> - </Region> - <Link> - <href>%s%d/%d/%d.kml</href> - <viewRefreshMode>onRegion</viewRefreshMode> - <viewFormat/> - </Link> - </NetworkLink> - """ % (cz, cx, cy, args['tileformat'], cnorth, csouth, ceast, cwest, - args['minlodpixels'], url, cz, cx, cy) - - s += """ </Document> - </kml> - """ - return s - - def generate_googlemaps(self): + def generate_googlemaps(self) -> str: """ Template for googlemaps.html implementing Overlay of tiles for 'mercator' profile. It returns filled string. Expected variables: - title, googlemapskey, north, south, east, west, minzoom, maxzoom, tilesize, tileformat, + title, googlemapskey, north, south, east, west, minzoom, maxzoom, tile_size, tileformat, publishurl """ args = {} - args['title'] = self.options.title - args['googlemapskey'] = self.options.googlekey - args['south'], args['west'], args['north'], args['east'] = self.swne - args['minzoom'] = self.tminz - args['maxzoom'] = self.tmaxz - args['tilesize'] = self.tilesize - args['tileformat'] = self.tileext - args['publishurl'] = self.options.url - args['copyright'] = self.options.copyright - - s = r"""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + args["xml_escaped_title"] = gdal.EscapeString( + self.options.title, gdal.CPLES_XML + ) + args["googlemapsurl"] = "https://maps.googleapis.com/maps/api/js" + if self.options.googlekey != "INSERT_YOUR_KEY_HERE": + args["googlemapsurl"] += "?key=" + self.options.googlekey + args["googlemapsurl_hint"] = "" + else: + args[ + "googlemapsurl_hint" + ] = "<!-- Replace URL below with https://maps.googleapis.com/maps/api/js?key=INSERT_YOUR_KEY_HERE -->" + args["south"], args["west"], args["north"], args["east"] = self.swne + args["minzoom"] = self.tminz + args["maxzoom"] = self.tmaxz + args["tile_size"] = self.tile_size + args["tileformat"] = self.tileext + args["publishurl"] = self.options.url + args["copyright"] = self.options.copyright + + # Logic below inspired from https://www.gavinharriss.com/code/opacity-control + # which borrowed on gdal2tiles itself to migrate from Google Maps V2 to V3 + + args[ + "custom_tile_overlay_js" + ] = """ +// Beginning of https://github.com/gavinharriss/google-maps-v3-opacity-control/blob/master/CustomTileOverlay.js +// with CustomTileOverlay.prototype.getTileUrl() method customized for gdal2tiles needs. + +/******************************************************************************* +Copyright (c) 2010-2012. Gavin Harriss +Site: http://www.gavinharriss.com/ +Originally developed for: http://www.topomap.co.nz/ +Licences: Creative Commons Attribution 3.0 New Zealand License +http://creativecommons.org/licenses/by/3.0/nz/ +******************************************************************************/ + +CustomTileOverlay = function (map, opacity) { + this.tileSize = new google.maps.Size(256, 256); // Change to tile size being used + + this.map = map; + this.opacity = opacity; + this.tiles = []; + + this.visible = false; + this.initialized = false; + + this.self = this; +} + +CustomTileOverlay.prototype = new google.maps.OverlayView(); + +CustomTileOverlay.prototype.getTile = function (p, z, ownerDocument) { + // If tile already exists then use it + for (var n = 0; n < this.tiles.length; n++) { + if (this.tiles[n].id == 't_' + p.x + '_' + p.y + '_' + z) { + return this.tiles[n]; + } + } + + // If tile doesn't exist then create it + var tile = ownerDocument.createElement('div'); + var tp = this.getTileUrlCoord(p, z); + tile.id = 't_' + tp.x + '_' + tp.y + '_' + z + tile.style.width = this.tileSize.width + 'px'; + tile.style.height = this.tileSize.height + 'px'; + tile.style.backgroundImage = 'url(' + this.getTileUrl(tp, z) + ')'; + tile.style.backgroundRepeat = 'no-repeat'; + + if (!this.visible) { + tile.style.display = 'none'; + } + + this.tiles.push(tile) + + this.setObjectOpacity(tile); + + return tile; +} + +// Save memory / speed up the display by deleting tiles out of view +// Essential for use on iOS devices such as iPhone and iPod! +CustomTileOverlay.prototype.deleteHiddenTiles = function (zoom) { + var bounds = this.map.getBounds(); + var tileNE = this.getTileUrlCoordFromLatLng(bounds.getNorthEast(), zoom); + var tileSW = this.getTileUrlCoordFromLatLng(bounds.getSouthWest(), zoom); + + var minX = tileSW.x - 1; + var maxX = tileNE.x + 1; + var minY = tileSW.y - 1; + var maxY = tileNE.y + 1; + + var tilesToKeep = []; + var tilesLength = this.tiles.length; + for (var i = 0; i < tilesLength; i++) { + var idParts = this.tiles[i].id.split("_"); + var tileX = Number(idParts[1]); + var tileY = Number(idParts[2]); + var tileZ = Number(idParts[3]); + if (( + (minX < maxX && (tileX >= minX && tileX <= maxX)) + || (minX > maxX && ((tileX >= minX && tileX <= (Math.pow(2, zoom) - 1)) || (tileX >= 0 && tileX <= maxX))) // Lapped the earth! + ) + && (tileY >= minY && tileY <= maxY) + && tileZ == zoom) { + tilesToKeep.push(this.tiles[i]); + } + else { + delete this.tiles[i]; + } + } + + this.tiles = tilesToKeep; +}; + +CustomTileOverlay.prototype.pointToTile = function (point, z) { + var projection = this.map.getProjection(); + var worldCoordinate = projection.fromLatLngToPoint(point); + var pixelCoordinate = new google.maps.Point(worldCoordinate.x * Math.pow(2, z), worldCoordinate.y * Math.pow(2, z)); + var tileCoordinate = new google.maps.Point(Math.floor(pixelCoordinate.x / this.tileSize.width), Math.floor(pixelCoordinate.y / this.tileSize.height)); + return tileCoordinate; +} + +CustomTileOverlay.prototype.getTileUrlCoordFromLatLng = function (latlng, zoom) { + return this.getTileUrlCoord(this.pointToTile(latlng, zoom), zoom) +} + +CustomTileOverlay.prototype.getTileUrlCoord = function (coord, zoom) { + var tileRange = 1 << zoom; + var y = tileRange - coord.y - 1; + var x = coord.x; + if (x < 0 || x >= tileRange) { + x = (x % tileRange + tileRange) % tileRange; + } + return new google.maps.Point(x, y); +} + +// Modified for gdal2tiles needs +CustomTileOverlay.prototype.getTileUrl = function (tile, zoom) { + + if ((zoom < mapMinZoom) || (zoom > mapMaxZoom)) { + return "https://gdal.org/resources/gdal2tiles/none.png"; + } + var ymax = 1 << zoom; + var y = ymax - tile.y -1; + var tileBounds = new google.maps.LatLngBounds( + fromMercatorPixelToLatLng( new google.maps.Point( (tile.x)*256, (y+1)*256 ) , zoom ), + fromMercatorPixelToLatLng( new google.maps.Point( (tile.x+1)*256, (y)*256 ) , zoom ) + ); + if (mapBounds.intersects(tileBounds)) { + return zoom+"/"+tile.x+"/"+tile.y+".png"; + } else { + return "https://gdal.org/resources/gdal2tiles/none.png"; + } + +} + +CustomTileOverlay.prototype.initialize = function () { + if (this.initialized) { + return; + } + var self = this.self; + this.map.overlayMapTypes.insertAt(0, self); + this.initialized = true; +} + +CustomTileOverlay.prototype.hide = function () { + this.visible = false; + + var tileCount = this.tiles.length; + for (var n = 0; n < tileCount; n++) { + this.tiles[n].style.display = 'none'; + } +} + +CustomTileOverlay.prototype.show = function () { + this.initialize(); + this.visible = true; + var tileCount = this.tiles.length; + for (var n = 0; n < tileCount; n++) { + this.tiles[n].style.display = ''; + } +} + +CustomTileOverlay.prototype.releaseTile = function (tile) { + tile = null; +} + +CustomTileOverlay.prototype.setOpacity = function (op) { + this.opacity = op; + + var tileCount = this.tiles.length; + for (var n = 0; n < tileCount; n++) { + this.setObjectOpacity(this.tiles[n]); + } +} + +CustomTileOverlay.prototype.setObjectOpacity = function (obj) { + if (this.opacity > 0) { + if (typeof (obj.style.filter) == 'string') { obj.style.filter = 'alpha(opacity:' + this.opacity + ')'; } + if (typeof (obj.style.KHTMLOpacity) == 'string') { obj.style.KHTMLOpacity = this.opacity / 100; } + if (typeof (obj.style.MozOpacity) == 'string') { obj.style.MozOpacity = this.opacity / 100; } + if (typeof (obj.style.opacity) == 'string') { obj.style.opacity = this.opacity / 100; } + } +} + +// End of https://github.com/gavinharriss/google-maps-v3-opacity-control/blob/master/CustomTileOverlay.js +""" + + args[ + "ext_draggable_object_js" + ] = """ +// Beginning of https://github.com/gavinharriss/google-maps-v3-opacity-control/blob/master/ExtDraggableObject.js + +/** + * @name ExtDraggableObject + * @version 1.0 + * @author Gabriel Schneider + * @copyright (c) 2009 Gabriel Schneider + * @fileoverview This sets up a given DOM element to be draggable + * around the page. + */ + +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Sets up a DOM element to be draggable. The options available + * within {@link ExtDraggableObjectOptions} are: top, left, container, + * draggingCursor, draggableCursor, intervalX, intervalY, + * toleranceX, toleranceY, restrictX, and restrictY. + * @param {HTMLElement} src The element to make draggable + * @param {ExtDraggableObjectOptions} [opts] options + * @constructor + */ +function ExtDraggableObject(src, opt_drag) { + var me = this; + var event_ = (window["GEvent"]||google.maps.Event||google.maps.event); + var opt_drag_=opt_drag||{}; + var draggingCursor_ = opt_drag_.draggingCursor||"default"; + var draggableCursor_ = opt_drag_.draggableCursor||"default"; + var moving_ = false, preventDefault_; + var currentX_, currentY_, formerY_, formerX_, formerMouseX_, formerMouseY_; + var top_, left_; + var mouseDownEvent_, mouseUpEvent_, mouseMoveEvent_; + var originalX_, originalY_; + var halfIntervalX_ = Math.round(opt_drag_.intervalX/2); + var halfIntervalY_ = Math.round(opt_drag_.intervalY/2); + var target_ = src.setCapture?src:document; + + if (typeof opt_drag_.intervalX !== "number") { + opt_drag_.intervalX = 1; + } + if (typeof opt_drag_.intervalY !== "number") { + opt_drag_.intervalY = 1; + } + if (typeof opt_drag_.toleranceX !== "number") { + opt_drag_.toleranceX = Infinity; + } + if (typeof opt_drag_.toleranceY !== "number") { + opt_drag_.toleranceY = Infinity; + } + + mouseDownEvent_ = event_.addDomListener(src, "mousedown", mouseDown_); + mouseUpEvent_ = event_.addDomListener(target_, "mouseup", mouseUp_); + + setCursor_(false); + if (opt_drag_.container) { + + } + src.style.position = "absolute"; + opt_drag_.left = opt_drag_.left||src.offsetLeft; + opt_drag_.top = opt_drag_.top||src.offsetTop; + opt_drag_.interval = opt_drag_.interval||1; + moveTo_(opt_drag_.left, opt_drag_.top, false); + + /** + * Set the cursor for {@link src} based on whether or not + * the element is currently being dragged. + * @param {Boolean} a Is the element being dragged? + * @private + */ + function setCursor_(a) { + if(a) { + src.style.cursor = draggingCursor_; + } else { + src.style.cursor = draggableCursor_; + } + } + + /** + * Moves the element {@link src} to the given + * location. + * @param {Number} x The left position to move to. + * @param {Number} y The top position to move to. + * @param {Boolean} prevent Prevent moving? + * @private + */ + function moveTo_(x, y, prevent) { + var roundedIntervalX_, roundedIntervalY_; + left_ = Math.round(x); + top_ = Math.round(y); + if (opt_drag_.intervalX>1) { + roundedIntervalX_ = Math.round(left_%opt_drag_.intervalX); + left_ = (roundedIntervalX_<halfIntervalX_)?(left_-roundedIntervalX_):(left_+(opt_drag_.intervalX-roundedIntervalX_)); + } + if (opt_drag_.intervalY>1) { + roundedIntervalY_ = Math.round(top_%opt_drag_.intervalY); + top_ = (roundedIntervalY_<halfIntervalY_)?(top_-roundedIntervalY_):(top_+(opt_drag_.intervalY-roundedIntervalY_)); + } + if (opt_drag_.container&&opt_drag_.container.offsetWidth) { + left_ = Math.max(0,Math.min(left_,opt_drag_.container.offsetWidth-src.offsetWidth)); + top_ = Math.max(0,Math.min(top_,opt_drag_.container.offsetHeight-src.offsetHeight)); + } + if (typeof currentX_ === "number") { + if (((left_-currentX_)>opt_drag_.toleranceX||(currentX_-(left_+src.offsetWidth))>opt_drag_.toleranceX)||((top_-currentY_)>opt_drag_.toleranceY||(currentY_-(top_+src.offsetHeight))>opt_drag_.toleranceY)) { + left_ = originalX_; + top_ = originalY_; + } + } + if(!opt_drag_.restrictX&&!prevent) { + src.style.left = left_ + "px"; + } + if(!opt_drag_.restrictY&&!prevent) { + src.style.top = top_ + "px"; + } + } + + /** + * Handles the mousemove event. + * @param {event} ev The event data sent by the browser. + * @private + */ + function mouseMove_(ev) { + var e=ev||event; + currentX_ = formerX_+((e.pageX||(e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft))-formerMouseX_); + currentY_ = formerY_+((e.pageY||(e.clientY+document.body.scrollTop+document.documentElement.scrollTop))-formerMouseY_); + formerX_ = currentX_; + formerY_ = currentY_; + formerMouseX_ = e.pageX||(e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft); + formerMouseY_ = e.pageY||(e.clientY+document.body.scrollTop+document.documentElement.scrollTop); + if (moving_) { + moveTo_(currentX_,currentY_, preventDefault_); + event_.trigger(me, "drag", {mouseX: formerMouseX_, mouseY: formerMouseY_, startLeft: originalX_, startTop: originalY_, event:e}); + } + } + + /** + * Handles the mousedown event. + * @param {event} ev The event data sent by the browser. + * @private + */ + function mouseDown_(ev) { + var e=ev||event; + setCursor_(true); + event_.trigger(me, "mousedown", e); + if (src.style.position !== "absolute") { + src.style.position = "absolute"; + return; + } + formerMouseX_ = e.pageX||(e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft); + formerMouseY_ = e.pageY||(e.clientY+document.body.scrollTop+document.documentElement.scrollTop); + originalX_ = src.offsetLeft; + originalY_ = src.offsetTop; + formerX_ = originalX_; + formerY_ = originalY_; + mouseMoveEvent_ = event_.addDomListener(target_, "mousemove", mouseMove_); + if (src.setCapture) { + src.setCapture(); + } + if (e.preventDefault) { + e.preventDefault(); + e.stopPropagation(); + } else { + e.cancelBubble=true; + e.returnValue=false; + } + moving_ = true; + event_.trigger(me, "dragstart", {mouseX: formerMouseX_, mouseY: formerMouseY_, startLeft: originalX_, startTop: originalY_, event:e}); + } + + /** + * Handles the mouseup event. + * @param {event} ev The event data sent by the browser. + * @private + */ + function mouseUp_(ev) { + var e=ev||event; + if (moving_) { + setCursor_(false); + event_.removeListener(mouseMoveEvent_); + if (src.releaseCapture) { + src.releaseCapture(); + } + moving_ = false; + event_.trigger(me, "dragend", {mouseX: formerMouseX_, mouseY: formerMouseY_, startLeft: originalX_, startTop: originalY_, event:e}); + } + currentX_ = currentY_ = null; + event_.trigger(me, "mouseup", e); + } + + /** + * Move the element {@link src} to the given location. + * @param {Point} point An object with an x and y property + * that represents the location to move to. + */ + me.moveTo = function(point) { + moveTo_(point.x, point.y, false); + }; + + /** + * Move the element {@link src} by the given amount. + * @param {Size} size An object with an x and y property + * that represents distance to move the element. + */ + me.moveBy = function(size) { + moveTo_(src.offsetLeft + size.width, src.offsetHeight + size.height, false); + } + + /** + * Sets the cursor for the dragging state. + * @param {String} cursor The name of the cursor to use. + */ + me.setDraggingCursor = function(cursor) { + draggingCursor_ = cursor; + setCursor_(moving_); + }; + + /** + * Sets the cursor for the draggable state. + * @param {String} cursor The name of the cursor to use. + */ + me.setDraggableCursor = function(cursor) { + draggableCursor_ = cursor; + setCursor_(moving_); + }; + + /** + * Returns the current left location. + * @return {Number} + */ + me.left = function() { + return left_; + }; + + /** + * Returns the current top location. + * @return {Number} + */ + me.top = function() { + return top_; + }; + + /** + * Returns the number of intervals the element has moved + * along the X axis. Useful for scrollbar type + * applications. + * @return {Number} + */ + me.valueX = function() { + var i = opt_drag_.intervalX||1; + return Math.round(left_ / i); + }; + + /** + * Returns the number of intervals the element has moved + * along the Y axis. Useful for scrollbar type + * applications. + * @return {Number} + */ + me.valueY = function() { + var i = opt_drag_.intervalY||1; + return Math.round(top_ / i); + }; + + /** + * Sets the left position of the draggable object based on + * intervalX. + * @param {Number} value The location to move to. + */ + me.setValueX = function(value) { + moveTo_(value * opt_drag_.intervalX, top_, false); + }; + + /** + * Sets the top position of the draggable object based on + * intervalY. + * @param {Number} value The location to move to. + */ + me.setValueY = function(value) { + moveTo_(left_, value * opt_drag_.intervalY, false); + }; + + /** + * Prevents the default movement behavior of the object. + * The object can still be moved by other methods. + */ + me.preventDefaultMovement = function(prevent) { + preventDefault_ = prevent; + }; +} + /** + * @name ExtDraggableObjectOptions + * @class This class represents the optional parameter passed into constructor of + * <code>ExtDraggableObject</code>. + * @property {Number} [top] Top pixel + * @property {Number} [left] Left pixel + * @property {HTMLElement} [container] HTMLElement as container. + * @property {String} [draggingCursor] Dragging Cursor + * @property {String} [draggableCursor] Draggable Cursor + * @property {Number} [intervalX] Interval in X direction + * @property {Number} [intervalY] Interval in Y direction + * @property {Number} [toleranceX] Tolerance X in pixel + * @property {Number} [toleranceY] Tolerance Y in pixel + * @property {Boolean} [restrictX] Whether to restrict move in X direction + * @property {Boolean} [restrictY] Whether to restrict move in Y direction + */ + + // End of https://github.com/gavinharriss/google-maps-v3-opacity-control/blob/master/ExtDraggableObject.js +""" + + s = ( + r"""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> <head> - <title>%(title)s</title> + <title>%(xml_escaped_title)s</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <meta http-equiv='imagetoolbar' content='no'/> <style type="text/css"> v\:* {behavior:url(#default#VML);} html, body { overflow: hidden; padding: 0; height: 100%%; width: 100%%; font-family: 'Lucida Grande',Geneva,Arial,Verdana,sans-serif; } body { margin: 10px; background: #fff; } h1 { margin: 0; padding: 6px; border:0; font-size: 20pt; } - # header { height: 43px; padding: 0; background-color: #eee; border: 1px solid #888; } - # subheader { height: 12px; text-align: right; font-size: 10px; color: #555;} - # map { height: 95%%; border: 1px solid #888; } + #header { height: 43px; padding: 0; background-color: #eee; border: 1px solid #888; } + #subheader { height: 12px; text-align: right; font-size: 10px; color: #555;} + #map { height: 95%%; border: 1px solid #888; } </style> - <script src='http://maps.google.com/maps?file=api&v=2&key=%(googlemapskey)s'></script> + %(googlemapsurl_hint)s + <script src='%(googlemapsurl)s'></script> <script> //<![CDATA[ - /* + /* * Constants for given map * TODO: read it from tilemapresource.xml */ - var mapBounds = new GLatLngBounds(new GLatLng(%(south)s, %(west)s), new GLatLng(%(north)s, %(east)s)); + var mapBounds = new google.maps.LatLngBounds( + new google.maps.LatLng(%(south)s, %(west)s), + new google.maps.LatLng(%(north)s, %(east)s)); var mapMinZoom = %(minzoom)s; var mapMaxZoom = %(maxzoom)s; - var opacity = 0.75; - var map; - var hybridOverlay; - - /* - * Create a Custom Opacity GControl - * http://www.maptiler.org/google-maps-overlay-opacity-control/ - */ - - var CTransparencyLENGTH = 58; - // maximum width that the knob can move (slide width minus knob width) - - function CTransparencyControl( overlay ) { - this.overlay = overlay; - this.opacity = overlay.getTileLayer().getOpacity(); - } - CTransparencyControl.prototype = new GControl(); - - // This function positions the slider to match the specified opacity - CTransparencyControl.prototype.setSlider = function(pos) { - var left = Math.round((CTransparencyLENGTH*pos)); - this.slide.left = left; - this.knob.style.left = left+"px"; - this.knob.style.top = "0px"; - } - - // This function reads the slider and sets the overlay opacity level - CTransparencyControl.prototype.setOpacity = function() { - // set the global variable - opacity = this.slide.left/CTransparencyLENGTH; - this.map.clearOverlays(); - this.map.addOverlay(this.overlay, { zPriority: 0 }); - if (this.map.getCurrentMapType() == G_HYBRID_MAP) { - this.map.addOverlay(hybridOverlay); - } - } - - // This gets called by the API when addControl(new CTransparencyControl()) - CTransparencyControl.prototype.initialize = function(map) { - var that=this; - this.map = map; - - // Is this MSIE, if so we need to use AlphaImageLoader - var agent = navigator.userAgent.toLowerCase(); - if ((agent.indexOf("msie") > -1) && (agent.indexOf("opera") < 1)){this.ie = true} else {this.ie = false} - - // create the background graphic as a <div> containing an image - var container = document.createElement("div"); - container.style.width="70px"; - container.style.height="21px"; - - // Handle transparent PNG files in MSIE - if (this.ie) { - var loader = "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://www.maptiler.org/img/opacity-slider.png', sizingMethod='crop');"; - container.innerHTML = '<div style="height:21px; width:70px; ' +loader+ '" ></div>'; - } else { - container.innerHTML = '<div style="height:21px; width:70px; background-image: url(http://www.maptiler.org/img/opacity-slider.png)" ></div>'; - } - - // create the knob as a GDraggableObject - // Handle transparent PNG files in MSIE - if (this.ie) { - var loader = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://www.maptiler.org/img/opacity-slider.png', sizingMethod='crop');"; - this.knob = document.createElement("div"); - this.knob.style.height="21px"; - this.knob.style.width="13px"; - this.knob.style.overflow="hidden"; - this.knob_img = document.createElement("div"); - this.knob_img.style.height="21px"; - this.knob_img.style.width="83px"; - this.knob_img.style.filter=loader; - this.knob_img.style.position="relative"; - this.knob_img.style.left="-70px"; - this.knob.appendChild(this.knob_img); - } else { - this.knob = document.createElement("div"); - this.knob.style.height="21px"; - this.knob.style.width="13px"; - this.knob.style.backgroundImage="url(http://www.maptiler.org/img/opacity-slider.png)"; - this.knob.style.backgroundPosition="-70px 0px"; - } - container.appendChild(this.knob); - this.slide=new GDraggableObject(this.knob, {container:container}); - this.slide.setDraggableCursor('pointer'); - this.slide.setDraggingCursor('pointer'); - this.container = container; - - // attach the control to the map - map.getContainer().appendChild(container); - - // init slider - this.setSlider(this.opacity); - // Listen for the slider being moved and set the opacity - GEvent.addListener(this.slide, "dragend", function() {that.setOpacity()}); - //GEvent.addListener(this.container, "click", function( x, y ) { alert(x, y) }); - - return container; - } - - // Set the default position for the control - CTransparencyControl.prototype.getDefaultPosition = function() { - return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 47)); - } + var initialOpacity = 0.75 * 100; + var map; /* * Full-screen Window Resize @@ -2637,157 +4003,236 @@ def generate_googlemaps(self): } + // getZoomByBounds(): adapted from https://stackoverflow.com/a/9982152 + /** + * Returns the zoom level at which the given rectangular region fits in the map view. + * The zoom level is computed for the currently selected map type. + * @param {google.maps.Map} map + * @param {google.maps.LatLngBounds} bounds + * @return {Number} zoom level + **/ + function getZoomByBounds( map, bounds ){ + var MAX_ZOOM = 21 ; + var MIN_ZOOM = 0 ; + + var ne= map.getProjection().fromLatLngToPoint( bounds.getNorthEast() ); + var sw= map.getProjection().fromLatLngToPoint( bounds.getSouthWest() ); + + var worldCoordWidth = Math.abs(ne.x-sw.x); + var worldCoordHeight = Math.abs(ne.y-sw.y); + //Fit padding in pixels + var FIT_PAD = 40; + for( var zoom = MAX_ZOOM; zoom >= MIN_ZOOM; --zoom ){ + if( worldCoordWidth*(1<<zoom)+2*FIT_PAD < map.getDiv().offsetWidth && + worldCoordHeight*(1<<zoom)+2*FIT_PAD < map.getDiv().offsetHeight ) + { + if( zoom > mapMaxZoom ) + zoom = mapMaxZoom; + return zoom; + } + } + return 0; + } + + function fromMercatorPixelToLatLng(pixel, zoom) + { + var CST = 6378137 * Math.PI; + var res = 2 * CST / 256 / Math.pow(2, zoom); + var X = -CST + pixel.x * res; + var Y = CST - pixel.y * res; + var lon = X / CST * 180; + var lat = Math.atan(Math.sinh(Y / CST * Math.PI)) / Math.PI * 180; + return new google.maps.LatLng(lat, lon); + } + + + var OPACITY_MAX_PIXELS = 57; // Width of opacity control image + + function createOpacityControl(map, opacity) { + var sliderImageUrl = "https://gdal.org/resources/gdal2tiles/opacity-slider.png"; + + // Create main div to hold the control. + var opacityDiv = document.createElement('DIV'); + var opacityDivMargin = 5; + opacityDiv.setAttribute("style", "margin:" + opacityDivMargin + "px;overflow-x:hidden;overflow-y:hidden;background:url(" + sliderImageUrl + ") no-repeat;width:71px;height:21px;cursor:pointer;"); + + // Create knob + var opacityKnobDiv = document.createElement('DIV'); + opacityKnobDiv.setAttribute("style", "padding:0;margin:0;overflow-x:hidden;overflow-y:hidden;background:url(" + sliderImageUrl + ") no-repeat -71px 0;width:14px;height:21px;"); + opacityDiv.appendChild(opacityKnobDiv); + + var opacityCtrlKnob = new ExtDraggableObject(opacityKnobDiv, { + restrictY: true, + container: opacityDiv + }); + + google.maps.event.addListener(opacityCtrlKnob, "dragend", function () { + setOpacity(opacityCtrlKnob.valueX()); + }); + + google.maps.event.addDomListener(opacityDiv, "click", function (e) { + var left = this.getBoundingClientRect().left; + var x = e.pageX - left - opacityDivMargin; + opacityCtrlKnob.setValueX(x); + setOpacity(x); + }); + + map.controls[google.maps.ControlPosition.TOP_RIGHT].push(opacityDiv); + + // Set initial value + var initialValue = OPACITY_MAX_PIXELS / (100 / opacity); + opacityCtrlKnob.setValueX(initialValue); + setOpacity(initialValue); + } + + function setOpacity(pixelX) { + // Range = 0 to OPACITY_MAX_PIXELS + var value = (100 / OPACITY_MAX_PIXELS) * pixelX; + if (value < 0) value = 0; + if (value == 0) { + if (overlay.visible == true) { + overlay.hide(); + } + } + else { + overlay.setOpacity(value); + if (overlay.visible == false) { + overlay.show(); + } + } + } + + function createCopyrightControl(map, copyright) { + const label = document.createElement("label"); + label.style.backgroundColor = "#ffffff"; + label.textContent = copyright; + + const div = document.createElement("div"); + div.appendChild(label); + + map.controls[google.maps.ControlPosition.BOTTOM_RIGHT].push(div); + } + + %(ext_draggable_object_js)s + /* * Main load function: */ function load() { - if (GBrowserIsCompatible()) { - - // Bug in the Google Maps: Copyright for Overlay is not correctly displayed - var gcr = GMapType.prototype.getCopyrights; - GMapType.prototype.getCopyrights = function(bounds,zoom) { - return ["%(copyright)s"].concat(gcr.call(this,bounds,zoom)); + var options = { + center: mapBounds.getCenter(), + zoom: mapMaxZoom, + mapTypeId: google.maps.MapTypeId.HYBRID, + + // Add map type control + mapTypeControl: true, + mapTypeControlOptions: { + style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR, + position: google.maps.ControlPosition.TOP_LEFT + }, + + // Add scale + scaleControl: true, + scaleControlOptions: { + position: google.maps.ControlPosition.BOTTOM_RIGHT } + }; - map = new GMap2( document.getElementById("map"), { backgroundColor: '#fff' } ); + map = new google.maps.Map( document.getElementById("map"), options); + google.maps.event.addListenerOnce(map, "projection_changed", function() { + map.setZoom(getZoomByBounds( map, mapBounds )); + }); - map.addMapType(G_PHYSICAL_MAP); - map.setMapType(G_PHYSICAL_MAP); + %(custom_tile_overlay_js)s - map.setCenter( mapBounds.getCenter(), map.getBoundsZoomLevel( mapBounds )); + overlay = new CustomTileOverlay(map, initialOpacity); + overlay.show(); - hybridOverlay = new GTileLayerOverlay( G_HYBRID_MAP.getTileLayers()[1] ); - GEvent.addListener(map, "maptypechanged", function() { - if (map.getCurrentMapType() == G_HYBRID_MAP) { - map.addOverlay(hybridOverlay); - } else { - map.removeOverlay(hybridOverlay); - } - } ); - - var tilelayer = new GTileLayer(GCopyrightCollection(''), mapMinZoom, mapMaxZoom); - var mercator = new GMercatorProjection(mapMaxZoom+1); - tilelayer.getTileUrl = function(tile,zoom) { - if ((zoom < mapMinZoom) || (zoom > mapMaxZoom)) { - return "http://www.maptiler.org/img/none.png"; - } - var ymax = 1 << zoom; - var y = ymax - tile.y -1; - var tileBounds = new GLatLngBounds( - mercator.fromPixelToLatLng( new GPoint( (tile.x)*256, (tile.y+1)*256 ) , zoom ), - mercator.fromPixelToLatLng( new GPoint( (tile.x+1)*256, (tile.y)*256 ) , zoom ) - ); - if (mapBounds.intersects(tileBounds)) { - return zoom+"/"+tile.x+"/"+y+".png"; - } else { - return "http://www.maptiler.org/img/none.png"; - } - } - // IE 7-: support for PNG alpha channel - // Unfortunately, the opacity for whole overlay is then not changeable, either or... - tilelayer.isPng = function() { return true;}; - tilelayer.getOpacity = function() { return opacity; } - - overlay = new GTileLayerOverlay( tilelayer ); - map.addOverlay(overlay); - - map.addControl(new GLargeMapControl()); - map.addControl(new GHierarchicalMapTypeControl()); - map.addControl(new CTransparencyControl( overlay )); - """ % args # noqa - if self.kml: - s += """ - map.addMapType(G_SATELLITE_3D_MAP); - map.getEarthInstance(getEarthInstanceCB); - """ - s += """ + google.maps.event.addListener(map, 'tilesloaded', function () { + overlay.deleteHiddenTiles(map.getZoom()); + }); - map.enableContinuousZoom(); - map.enableScrollWheelZoom(); + // Add opacity control and set initial value + createOpacityControl(map, initialOpacity); - map.setMapType(G_HYBRID_MAP); - } - resize(); - } - """ - if self.kml: - s += """ - function getEarthInstanceCB(object) { - var ge = object; - - if (ge) { - var url = document.location.toString(); - url = url.substr(0,url.lastIndexOf('/'))+'/doc.kml'; - var link = ge.createLink(""); - if ("%(publishurl)s") { link.setHref("%(publishurl)s/doc.kml") } - else { link.setHref(url) }; - var networkLink = ge.createNetworkLink(""); - networkLink.setName("TMS Map Overlay"); - networkLink.setFlyToView(true); - networkLink.setLink(link); - ge.getFeatures().appendChild(networkLink); - } else { - // alert("You should open a KML in Google Earth"); - // add div with the link to generated KML... - maybe JavaScript redirect to the URL of KML? - } + var copyright = "%(copyright)s"; + if( copyright != "" ) { + createCopyrightControl(map, copyright); + } + + resize(); } - """ % args # noqa - s += """ + onresize=function(){ resize(); }; //]]> </script> </head> <body onload="load()"> - <div id="header"><h1>%(title)s</h1></div> - <div id="subheader">Generated by <a href="http://www.klokan.cz/projects/gdal2tiles/">GDAL2Tiles</a>, Copyright © 2008 <a href="http://www.klokan.cz/">Klokan Petr Pridal</a>, <a href="http://www.gdal.org/">GDAL</a> & <a href="http://www.osgeo.org/">OSGeo</a> <a href="http://code.google.com/soc/">GSoC</a> + <div id="header"><h1>%(xml_escaped_title)s</h1></div> + <div id="subheader">Generated by <a href="https://gdal.org/programs/gdal2tiles.html">GDAL2Tiles</a>, Copyright © 2008 <a href="http://www.klokan.cz/">Klokan Petr Pridal</a>, <a href="https://gdal.org">GDAL</a> & <a href="http://www.osgeo.org/">OSGeo</a> <a href="http://code.google.com/soc/">GSoC</a> <!-- PLEASE, LET THIS NOTE ABOUT AUTHOR AND PROJECT SOMEWHERE ON YOUR WEBSITE, OR AT LEAST IN THE COMMENT IN HTML. THANK YOU --> </div> <div id="map"></div> </body> </html> - """ % args # noqa + """ + % args + ) # noqa + + # TODO? when there is self.kml, before the transition to GoogleMapsV3 API, + # we used to offer a way to display the KML file in Google Earth + # cf https://github.com/OSGeo/gdal/blob/32f32a69bbf5c408c6c8ac2cc6f1d915a7a1c576/swig/python/gdal-utils/osgeo_utils/gdal2tiles.py#L3203 to #L3243 return s - def generate_leaflet(self): + def generate_leaflet(self) -> str: """ Template for leaflet.html implementing overlay of tiles for 'mercator' profile. It returns filled string. Expected variables: - title, north, south, east, west, minzoom, maxzoom, tilesize, tileformat, publishurl + title, north, south, east, west, minzoom, maxzoom, tile_size, tileformat, publishurl """ args = {} - args['title'] = self.options.title.replace('"', '\\"') - args['htmltitle'] = self.options.title - args['south'], args['west'], args['north'], args['east'] = self.swne - args['centerlon'] = (args['north'] + args['south']) / 2. - args['centerlat'] = (args['west'] + args['east']) / 2. - args['minzoom'] = self.tminz - args['maxzoom'] = self.tmaxz - args['beginzoom'] = self.tmaxz - args['tilesize'] = self.tilesize # not used - args['tileformat'] = self.tileext - args['publishurl'] = self.options.url # not used - args['copyright'] = self.options.copyright.replace('"', '\\"') - - s = """<!DOCTYPE html> + args["double_quote_escaped_title"] = self.options.title.replace( + '"', '\\"') + args["xml_escaped_title"] = gdal.EscapeString( + self.options.title, gdal.CPLES_XML + ) + args["south"], args["west"], args["north"], args["east"] = self.swne + args["centerlon"] = (args["north"] + args["south"]) / 2.0 + args["centerlat"] = (args["west"] + args["east"]) / 2.0 + args["minzoom"] = self.tminz + args["maxzoom"] = self.tmaxz + args["beginzoom"] = self.tmaxz + args["tile_size"] = self.tile_size # not used + args["tileformat"] = self.tileext + args["publishurl"] = self.options.url # not used + args["copyright"] = self.options.copyright.replace('"', '\\"') + + if self.options.xyz: + args["tms"] = 0 + else: + args["tms"] = 1 + + s = ( + """<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' /> - <title>%(htmltitle)s</title> + <title>%(xml_escaped_title)s</title> <!-- Leaflet --> - <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.css" /> - <script src="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.js"></script> + <link rel="stylesheet" href="https://unpkg.com/leaflet@0.7.5/dist/leaflet.css" /> + <script src="https://unpkg.com/leaflet@0.7.5/dist/leaflet.js"></script> <style> body { margin:0; padding:0; } body, table, tr, td, th, div, h1, h2, input { font-family: "Calibri", "Trebuchet MS", "Ubuntu", Serif; font-size: 11pt; } - # map { position:absolute; top:0; bottom:0; width:100%%; } /* full size */ + #map { position:absolute; top:0; bottom:0; width:100%%; } /* full size */ .ctl { padding: 2px 10px 2px 10px; background: white; @@ -2816,19 +4261,19 @@ def generate_leaflet(self): // Base layers // .. OpenStreetMap - var osm = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'}); + var osm = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors', minZoom: %(minzoom)s, maxZoom: %(maxzoom)s}); // .. CartoDB Positron - var cartodb = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a href="http://cartodb.com/attributions">CartoDB</a>'}); + var cartodb = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a href="http://cartodb.com/attributions">CartoDB</a>', minZoom: %(minzoom)s, maxZoom: %(maxzoom)s}); // .. OSM Toner - var toner = L.tileLayer('http://{s}.tile.stamen.com/toner/{z}/{x}/{y}.png', {attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.'}); + var toner = L.tileLayer('http://{s}.tile.stamen.com/toner/{z}/{x}/{y}.png', {attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.', minZoom: %(minzoom)s, maxZoom: %(maxzoom)s}); // .. White background - var white = L.tileLayer("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAAA1BMVEX///+nxBvIAAAAH0lEQVQYGe3BAQ0AAADCIPunfg43YAAAAAAAAAAA5wIhAAAB9aK9BAAAAABJRU5ErkJggg=="); + var white = L.tileLayer("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAAA1BMVEX///+nxBvIAAAAH0lEQVQYGe3BAQ0AAADCIPunfg43YAAAAAAAAAAA5wIhAAAB9aK9BAAAAABJRU5ErkJggg==", {minZoom: %(minzoom)s, maxZoom: %(maxzoom)s}); // Overlay layers (TMS) - var lyr = L.tileLayer('./{z}/{x}/{y}.%(tileformat)s', {tms: true, opacity: 0.7, attribution: "%(copyright)s"}); + var lyr = L.tileLayer('./{z}/{x}/{y}.%(tileformat)s', {tms: %(tms)s, opacity: 0.7, attribution: "%(copyright)s", minZoom: %(minzoom)s, maxZoom: %(maxzoom)s}); // Map var map = L.map('map', { @@ -2850,12 +4295,12 @@ def generate_leaflet(self): return this._div; }; title.update = function(props) { - this._div.innerHTML = "%(title)s"; + this._div.innerHTML = "%(double_quote_escaped_title)s"; }; title.addTo(map); // Note - var src = 'Generated by <a href="http://www.klokan.cz/projects/gdal2tiles/">GDAL2Tiles</a>, Copyright © 2008 <a href="http://www.klokan.cz/">Klokan Petr Pridal</a>, <a href="http://www.gdal.org/">GDAL</a> & <a href="http://www.osgeo.org/">OSGeo</a> <a href="http://code.google.com/soc/">GSoC</a>'; + var src = 'Generated by <a href="https://gdal.org/programs/gdal2tiles.html">GDAL2Tiles</a>, Copyright © 2008 <a href="http://www.klokan.cz/">Klokan Petr Pridal</a>, <a href="https://gdal.org">GDAL</a> & <a href="http://www.osgeo.org/">OSGeo</a> <a href="http://code.google.com/soc/">GSoC</a>'; var title = L.control({position: 'bottomleft'}); title.onAdd = function(map) { this._div = L.DomUtil.create('div', 'ctl src'); @@ -2879,340 +4324,720 @@ def generate_leaflet(self): </body> </html> - """ % args # noqa + """ + % args + ) # noqa return s - def generate_openlayers(self): + def generate_openlayers(self) -> str: """ - Template for openlayers.html implementing overlay of available Spherical Mercator layers. + Template for openlayers.html, with the tiles as overlays, and base layers. - It returns filled string. Expected variables: - title, bingkey, north, south, east, west, minzoom, maxzoom, tilesize, tileformat, publishurl + It returns filled string. """ args = {} - args['title'] = self.options.title - args['bingkey'] = self.options.bingkey - args['south'], args['west'], args['north'], args['east'] = self.swne - args['minzoom'] = self.tminz - args['maxzoom'] = self.tmaxz - args['tilesize'] = self.tilesize - args['tileformat'] = self.tileext - args['publishurl'] = self.options.url - args['copyright'] = self.options.copyright - if self.options.tmscompatible: - args['tmsoffset'] = "-1" + args["xml_escaped_title"] = gdal.EscapeString( + self.options.title, gdal.CPLES_XML + ) + args["bingkey"] = self.options.bingkey + args["minzoom"] = self.tminz + args["maxzoom"] = self.tmaxz + args["tile_size"] = self.tile_size + args["tileformat"] = self.tileext + args["publishurl"] = self.options.url + args["copyright"] = self.options.copyright + if self.options.xyz: + args["sign_y"] = "" + else: + args["sign_y"] = "-" + + args["ominx"] = self.ominx + args["ominy"] = self.ominy + args["omaxx"] = self.omaxx + args["omaxy"] = self.omaxy + args["center_x"] = (self.ominx + self.omaxx) / 2 + args["center_y"] = (self.ominy + self.omaxy) / 2 + + s = ( + r"""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>%(xml_escaped_title)s</title> + <meta http-equiv='imagetoolbar' content='no'/> + <style type="text/css"> v\:* {behavior:url(#default#VML);} + html, body { overflow: hidden; padding: 0; height: 100%%; width: 100%%; font-family: 'Lucida Grande',Geneva,Arial,Verdana,sans-serif; } + body { margin: 10px; background: #fff; } + h1 { margin: 0; padding: 6px; border:0; font-size: 20pt; } + #header { height: 43px; padding: 0; background-color: #eee; border: 1px solid #888; } + #subheader { height: 12px; text-align: right; font-size: 10px; color: #555;} + #map { height: 90%%; border: 1px solid #888; } + </style> + <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@main/dist/en/v7.0.0/legacy/ol.css" type="text/css"> + <script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@main/dist/en/v7.0.0/legacy/ol.js"></script> + <script src="https://unpkg.com/ol-layerswitcher@3.5.0"></script> + <link rel="stylesheet" href="https://unpkg.com/ol-layerswitcher@3.5.0/src/ol-layerswitcher.css" /> +</head> +<body> + <div id="header"><h1>%(xml_escaped_title)s</h1></div> + <div id="subheader">Generated by <a href="https://gdal.org/programs/gdal2tiles.html">GDAL2Tiles</a> </div> + <div id="map" class="map"></div> + <div id="mouse-position"></div> + <script type="text/javascript"> + var mousePositionControl = new ol.control.MousePosition({ + className: 'custom-mouse-position', + target: document.getElementById('mouse-position'), + undefinedHTML: ' ' + }); + var map = new ol.Map({ + controls: ol.control.defaults.defaults().extend([mousePositionControl]), + target: 'map', +""" + % args + ) + + if self.options.profile == "mercator" or self.options.profile == "geodetic": + s += ( + """ + layers: [ + new ol.layer.Group({ + title: 'Base maps', + layers: [ + new ol.layer.Tile({ + title: 'OpenStreetMap', + type: 'base', + visible: true, + source: new ol.source.OSM() + }), + new ol.layer.Tile({ + title: 'Bing Roads', + type: 'base', + visible: false, + source: new ol.source.BingMaps({ + key: "%(bingkey)s", + imagerySet: 'Road' + }) + }), + new ol.layer.Tile({ + title: 'Bing Aerial', + type: 'base', + visible: false, + source: new ol.source.BingMaps({ + key: "%(bingkey)s", + imagerySet: 'Aerial' + }) + }), + new ol.layer.Tile({ + title: 'Bing Hybrid', + type: 'base', + visible: false, + source: new ol.source.BingMaps({ + key: "%(bingkey)s", + imagerySet: 'AerialWithLabels' + }) + }), + ] + }),""" + % args + ) # noqa + + if self.options.profile == "mercator": + s += ( + """ + new ol.layer.Group({ + title: 'Overlay', + layers: [ + new ol.layer.Tile({ + title: 'Overlay', + // opacity: 0.7, + extent: [%(ominx)f, %(ominy)f,%(omaxx)f, %(omaxy)f], + source: new ol.source.XYZ({ + attributions: '%(copyright)s', + minZoom: %(minzoom)d, + maxZoom: %(maxzoom)d, + url: './{z}/{x}/{%(sign_y)sy}.%(tileformat)s', + tileSize: [%(tile_size)d, %(tile_size)d] + }) + }), + ] + }),""" + % args + ) # noqa + + elif self.options.profile == "geodetic": + + if self.options.tmscompatible: + base_res = 180.0 / self.tile_size + else: + base_res = 360.0 / self.tile_size + resolutions = [base_res / 2**i for i in range(self.tmaxz + 1)] + args["resolutions"] = ( + "[" + ",".join("%.18g" % res for res in resolutions) + "]" + ) + + if self.options.xyz: + if self.options.tmscompatible: + args["origin"] = "[-180,90]" + else: + args["origin"] = "[-180,270]" + args["y_formula"] = "tileCoord[2]" + else: + args["origin"] = "[-180,-90]" + args["y_formula"] = "- 1 - tileCoord[2]" + + s += ( + """ + new ol.layer.Group({ + title: 'Overlay', + layers: [ + new ol.layer.Tile({ + title: 'Overlay', + // opacity: 0.7, + extent: [%(ominx)f, %(ominy)f,%(omaxx)f, %(omaxy)f], + source: new ol.source.TileImage({ + attributions: '%(copyright)s', + projection: 'EPSG:4326', + minZoom: %(minzoom)d, + maxZoom: %(maxzoom)d, + tileGrid: new ol.tilegrid.TileGrid({ + extent: [-180,-90,180,90], + origin: %(origin)s, + resolutions: %(resolutions)s, + tileSize: [%(tile_size)d, %(tile_size)d] + }), + tileUrlFunction: function(tileCoord) { + return ('./{z}/{x}/{y}.%(tileformat)s' + .replace('{z}', String(tileCoord[0])) + .replace('{x}', String(tileCoord[1])) + .replace('{y}', String(%(y_formula)s))); + }, + }) + }), + ] + }),""" + % args + ) # noqa + + elif self.options.profile == "raster": + + base_res = 2 ** (self.nativezoom) * self.out_gt[1] + resolutions = [base_res / 2**i for i in range(self.tmaxz + 1)] + args["maxres"] = resolutions[self.tminz] + args["resolutions"] = ( + "[" + ",".join("%.18g" % res for res in resolutions) + "]" + ) + args["tilegrid_extent"] = "[%.18g,%.18g,%.18g,%.18g]" % ( + self.ominx, + self.ominy, + self.omaxx, + self.omaxy, + ) + + if self.options.xyz: + args["origin"] = "[%.18g,%.18g]" % (self.ominx, self.omaxy) + args["y_formula"] = "tileCoord[2]" + else: + args["origin"] = "[%.18g,%.18g]" % (self.ominx, self.ominy) + args["y_formula"] = "- 1 - tileCoord[2]" + + s += ( + """ + layers: [ + new ol.layer.Group({ + title: 'Overlay', + layers: [ + new ol.layer.Tile({ + title: 'Overlay', + // opacity: 0.7, + source: new ol.source.TileImage({ + attributions: '%(copyright)s', + tileGrid: new ol.tilegrid.TileGrid({ + extent: %(tilegrid_extent)s, + origin: %(origin)s, + resolutions: %(resolutions)s, + tileSize: [%(tile_size)d, %(tile_size)d] + }), + tileUrlFunction: function(tileCoord) { + return ('./{z}/{x}/{y}.%(tileformat)s' + .replace('{z}', String(tileCoord[0])) + .replace('{x}', String(tileCoord[1])) + .replace('{y}', String(%(y_formula)s))); + }, + }) + }), + ] + }),""" + % args + ) # noqa + else: - args['tmsoffset'] = "" - if self.options.profile == 'raster': - args['rasterzoomlevels'] = self.tmaxz+1 - args['rastermaxresolution'] = 2**(self.nativezoom) * self.out_gt[1] - s = r"""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - <html xmlns="http://www.w3.org/1999/xhtml" - <head> - <title>%(title)s</title> - <meta http-equiv='imagetoolbar' content='no'/> - <style type="text/css"> v\:* {behavior:url(#default#VML);} - html, body { overflow: hidden; padding: 0; height: 100%%; width: 100%%; font-family: 'Lucida Grande',Geneva,Arial,Verdana,sans-serif; } - body { margin: 10px; background: #fff; } - h1 { margin: 0; padding: 6px; border:0; font-size: 20pt; } - # header { height: 43px; padding: 0; background-color: #eee; border: 1px solid #888; } - # subheader { height: 12px; text-align: right; font-size: 10px; color: #555;} - # map { height: 95%%; border: 1px solid #888; } - .olImageLoadError { display: none; } - .olControlLayerSwitcher .layersDiv { border-radius: 10px 0 0 10px; } - </style>""" % args # noqa - - if self.options.profile == 'mercator': + tms = tmsMap[self.options.profile] + base_res = tms.resolution + resolutions = [base_res / 2**i for i in range(self.tmaxz + 1)] + args["maxres"] = resolutions[self.tminz] + args["resolutions"] = ( + "[" + ",".join("%.18g" % res for res in resolutions) + "]" + ) + args["matrixsizes"] = ( + "[" + + ",".join( + "[%d,%d]" % (tms.matrix_width << i, tms.matrix_height << i) + for i in range(len(resolutions)) + ) + + "]" + ) + + if self.options.xyz: + args["origin"] = "[%.18g,%.18g]" % ( + tms.topleft_x, tms.topleft_y) + args["y_formula"] = "tileCoord[2]" + else: + args["origin"] = "[%.18g,%.18g]" % ( + tms.topleft_x, + tms.topleft_y - tms.resolution * tms.tile_size, + ) + args["y_formula"] = "- 1 - tileCoord[2]" + + args["tilegrid_extent"] = "[%.18g,%.18g,%.18g,%.18g]" % ( + tms.topleft_x, + tms.topleft_y - tms.matrix_height * tms.resolution * tms.tile_size, + tms.topleft_x + tms.matrix_width * tms.resolution * tms.tile_size, + tms.topleft_y, + ) + + s += ( + """ + layers: [ + new ol.layer.Group({ + title: 'Overlay', + layers: [ + new ol.layer.Tile({ + title: 'Overlay', + // opacity: 0.7, + extent: [%(ominx)f, %(ominy)f,%(omaxx)f, %(omaxy)f], + source: new ol.source.TileImage({ + attributions: '%(copyright)s', + minZoom: %(minzoom)d, + maxZoom: %(maxzoom)d, + tileGrid: new ol.tilegrid.TileGrid({ + extent: %(tilegrid_extent)s, + origin: %(origin)s, + resolutions: %(resolutions)s, + sizes: %(matrixsizes)s, + tileSize: [%(tile_size)d, %(tile_size)d] + }), + tileUrlFunction: function(tileCoord) { + return ('./{z}/{x}/{y}.%(tileformat)s' + .replace('{z}', String(tileCoord[0])) + .replace('{x}', String(tileCoord[1])) + .replace('{y}', String(%(y_formula)s))); + }, + }) + }), + ] + }),""" + % args + ) # noqa + + s += ( + """ + ], + view: new ol.View({ + center: [%(center_x)f, %(center_y)f],""" + % args + ) # noqa + + if self.options.profile in ("mercator", "geodetic"): + args["view_zoom"] = args["minzoom"] + if self.options.profile == "geodetic" and self.options.tmscompatible: + args["view_zoom"] += 1 + s += ( + """ + zoom: %(view_zoom)d,""" + % args + ) # noqa + else: + s += ( + """ + resolution: %(maxres)f,""" + % args + ) # noqa + + if self.options.profile == "geodetic": s += """ - <script src='http://maps.google.com/maps/api/js?sensor=false&v=3.7'></script> - """ % args + projection: 'EPSG:4326',""" + elif self.options.profile != "mercator": + if ( + self.in_srs + and self.in_srs.IsProjected() + and self.in_srs.GetAuthorityName(None) == "EPSG" + ): + s += """ + projection: new ol.proj.Projection({code: 'EPSG:%s', units:'m'}),""" % self.in_srs.GetAuthorityCode( + None + ) s += """ - <script src="http://www.openlayers.org/api/2.12/OpenLayers.js"></script> - <script> - var map; - var mapBounds = new OpenLayers.Bounds( %(west)s, %(south)s, %(east)s, %(north)s); - var mapMinZoom = %(minzoom)s; - var mapMaxZoom = %(maxzoom)s; - var emptyTileURL = "http://www.maptiler.org/img/none.png"; - OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3; - - function init(){""" % args - - if self.options.profile == 'mercator': + }) + });""" + if self.options.profile in ("mercator", "geodetic"): s += """ - var options = { - div: "map", - controls: [], - projection: "EPSG:3857", - displayProjection: new OpenLayers.Projection("EPSG:4326"), - numZoomLevels: 20 - }; - map = new OpenLayers.Map(options); - - // Create Google Mercator layers - var gmap = new OpenLayers.Layer.Google("Google Streets", - { - type: google.maps.MapTypeId.ROADMAP, - sphericalMercator: true - }); - var gsat = new OpenLayers.Layer.Google("Google Satellite", - { - type: google.maps.MapTypeId.SATELLITE, - sphericalMercator: true - }); - var ghyb = new OpenLayers.Layer.Google("Google Hybrid", - { - type: google.maps.MapTypeId.HYBRID, - sphericalMercator: true - }); - var gter = new OpenLayers.Layer.Google("Google Terrain", - { - type: google.maps.MapTypeId.TERRAIN, - sphericalMercator: true - }); - - // Create Bing layers - var broad = new OpenLayers.Layer.Bing({ - name: "Bing Roads", - key: "%(bingkey)s", - type: "Road", - sphericalMercator: true - }); - var baer = new OpenLayers.Layer.Bing({ - name: "Bing Aerial", - key: "%(bingkey)s", - type: "Aerial", - sphericalMercator: true - }); - var bhyb = new OpenLayers.Layer.Bing({ - name: "Bing Hybrid", - key: "%(bingkey)s", - type: "AerialWithLabels", - sphericalMercator: true - }); - - // Create OSM layer - var osm = new OpenLayers.Layer.OSM("OpenStreetMap"); - - // create TMS Overlay layer - var tmsoverlay = new OpenLayers.Layer.TMS("TMS Overlay", "", - { - serviceVersion: '.', - layername: '.', - alpha: true, - type: '%(tileformat)s', - isBaseLayer: false, - getURL: getURL - }); - if (OpenLayers.Util.alphaHack() == false) { - tmsoverlay.setOpacity(0.7); - } + map.addControl(new ol.control.LayerSwitcher());""" + s += """ + </script> +</body> +</html>""" - map.addLayers([gmap, gsat, ghyb, gter, - broad, baer, bhyb, - osm, tmsoverlay]); + return s - var switcherControl = new OpenLayers.Control.LayerSwitcher(); - map.addControl(switcherControl); - switcherControl.maximizeControl(); + def generate_mapml(self) -> str: - map.zoomToExtent(mapBounds.transform(map.displayProjection, map.projection)); - """ % args # noqa + if self.options.mapml_template: + template = self.options.mapml_template + else: + template = gdal.FindFile("gdal", "template_tiles.mapml") + s = open(template, "rb").read().decode("utf-8") - elif self.options.profile == 'geodetic': - s += """ - var options = { - div: "map", - controls: [], - projection: "EPSG:4326" - }; - map = new OpenLayers.Map(options); - - var wms = new OpenLayers.Layer.WMS("VMap0", - "http://tilecache.osgeo.org/wms-c/Basic.py?", - { - layers: 'basic', - format: 'image/png' - } - ); - var tmsoverlay = new OpenLayers.Layer.TMS("TMS Overlay", "", - { - serviceVersion: '.', - layername: '.', - alpha: true, - type: '%(tileformat)s', - isBaseLayer: false, - getURL: getURL - }); - if (OpenLayers.Util.alphaHack() == false) { - tmsoverlay.setOpacity(0.7); - } + if self.options.profile == "mercator": + tiling_scheme = "OSMTILE" + elif self.options.profile == "geodetic": + tiling_scheme = "WGS84" + else: + tiling_scheme = self.options.profile + + s = s.replace("${TILING_SCHEME}", tiling_scheme) + s = s.replace("${URL}", self.options.url if self.options.url else "./") + tminx, tminy, tmaxx, tmaxy = self.tminmax[self.tmaxz] + s = s.replace("${MINTILEX}", str(tminx)) + s = s.replace( + "${MINTILEY}", str(GDAL2Tiles.getYTile( + tmaxy, self.tmaxz, self.options)) + ) + s = s.replace("${MAXTILEX}", str(tmaxx)) + s = s.replace( + "${MAXTILEY}", str(GDAL2Tiles.getYTile( + tminy, self.tmaxz, self.options)) + ) + s = s.replace("${CURZOOM}", str(self.tmaxz)) + s = s.replace("${MINZOOM}", str(self.tminz)) + s = s.replace("${MAXZOOM}", str(self.tmaxz)) + s = s.replace("${TILEEXT}", str(self.tileext)) - map.addLayers([wms,tmsoverlay]); + return s - var switcherControl = new OpenLayers.Control.LayerSwitcher(); - map.addControl(switcherControl); - switcherControl.maximizeControl(); + @staticmethod + def getYTile(ty, tz, options): + """ + Calculates the y-tile number based on whether XYZ or TMS (default) system is used + :param ty: The y-tile number + :param tz: The z-tile number + :return: The transformed y-tile number + """ + if options.xyz and options.profile != "raster": + if options.profile in ("mercator", "geodetic"): + # Convert from TMS to XYZ numbering system + return (2**tz - 1) - ty - map.zoomToExtent(mapBounds); - """ % args # noqa + tms = tmsMap[options.profile] + return ( + tms.matrix_height * 2**tz - 1 + ) - ty # Convert from TMS to XYZ numbering system + + return ty + + +def worker_tile_details( + input_file: str, output_folder: str, options: Options +) -> Tuple[TileJobInfo, List[TileDetail]]: + gdal2tiles = GDAL2Tiles(input_file, output_folder, options) + gdal2tiles.open_input() + gdal2tiles.generate_metadata() + tile_job_info, tile_details = gdal2tiles.generate_base_tiles() + return tile_job_info, tile_details + + +class ProgressBar(object): + def __init__(self, total_items: int) -> None: + self.total_items = total_items + self.nb_items_done = 0 + self.current_progress = 0 + self.STEP = 2.5 + + def start(self) -> None: + sys.stdout.write("0") + + def log_progress(self, nb_items: int = 1) -> None: + self.nb_items_done += nb_items + progress = float(self.nb_items_done) / self.total_items * 100 + if progress >= self.current_progress + self.STEP: + done = False + while not done: + if self.current_progress + self.STEP <= progress: + self.current_progress += self.STEP + if self.current_progress % 10 == 0: + sys.stdout.write(str(int(self.current_progress))) + if self.current_progress == 100: + sys.stdout.write("\n") + else: + sys.stdout.write(".") + else: + done = True + sys.stdout.flush() + + def done(self) -> None: + sys.stdout.write("\r0...10...20...30...40...50...60...70...80...90...100\nDone!") + sys.stdout.flush() + + +def get_tile_swne(tile_job_info, options): + if options.profile == "mercator": + mercator = GlobalMercator() + tile_swne = mercator.TileLatLonBounds + elif options.profile == "geodetic": + geodetic = GlobalGeodetic(options.tmscompatible) + tile_swne = geodetic.TileLatLonBounds + elif options.profile == "raster": + srs4326 = osr.SpatialReference() + srs4326.ImportFromEPSG(4326) + srs4326.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER) + if tile_job_info.kml and tile_job_info.in_srs_wkt: + in_srs = osr.SpatialReference() + in_srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER) + in_srs.ImportFromWkt(tile_job_info.in_srs_wkt) + ct = osr.CoordinateTransformation(in_srs, srs4326) + + def rastertileswne(x, y, z): + pixelsizex = ( + 2 ** (tile_job_info.tmaxz - z) * + tile_job_info.out_geo_trans[1] + ) + west = ( + tile_job_info.out_geo_trans[0] + + x * tile_job_info.tile_size * pixelsizex + ) + east = west + tile_job_info.tile_size * pixelsizex + if options.xyz: + north = ( + tile_job_info.out_geo_trans[3] + - y * tile_job_info.tile_size * pixelsizex + ) + south = north - tile_job_info.tile_size * pixelsizex + else: + south = ( + tile_job_info.ominy + y * tile_job_info.tile_size * pixelsizex + ) + north = south + tile_job_info.tile_size * pixelsizex + if not tile_job_info.is_epsg_4326: + # Transformation to EPSG:4326 (WGS84 datum) + west, south = ct.TransformPoint(west, south)[:2] + east, north = ct.TransformPoint(east, north)[:2] + return south, west, north, east + + tile_swne = rastertileswne + else: + def tile_swne(x, y, z): return (0, 0, 0, 0) # noqa + else: + tile_swne = None - elif self.options.profile == 'raster': - s += """ - var options = { - div: "map", - controls: [], - maxExtent: new OpenLayers.Bounds(%(west)s, %(south)s, %(east)s, %(north)s), - maxResolution: %(rastermaxresolution)f, - numZoomLevels: %(rasterzoomlevels)d - }; - map = new OpenLayers.Map(options); - - var layer = new OpenLayers.Layer.TMS("TMS Layer", "", - { - serviceVersion: '.', - layername: '.', - alpha: true, - type: '%(tileformat)s', - getURL: getURL - }); - - map.addLayer(layer); - map.zoomToExtent(mapBounds); - """ % args # noqa + return tile_swne - s += """ - map.addControls([new OpenLayers.Control.PanZoomBar(), - new OpenLayers.Control.Navigation(), - new OpenLayers.Control.MousePosition(), - new OpenLayers.Control.ArgParser(), - new OpenLayers.Control.Attribution()]); - } - """ % args - - if self.options.profile == 'mercator': - s += """ - function getURL(bounds) { - bounds = this.adjustBounds(bounds); - var res = this.getServerResolution(); - var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w)); - var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h)); - var z = this.getServerZoom(); - if (this.map.baseLayer.CLASS_NAME === 'OpenLayers.Layer.Bing') { - z+=1; - } - var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type; - var url = this.url; - if (OpenLayers.Util.isArray(url)) { - url = this.selectUrl(path, url); - } - if (mapBounds.intersectsBounds(bounds) && (z >= mapMinZoom) && (z <= mapMaxZoom)) { - return url + path; - } else { - return emptyTileURL; - } - } - """ % args # noqa - elif self.options.profile == 'geodetic': - s += """ - function getURL(bounds) { - bounds = this.adjustBounds(bounds); - var res = this.getServerResolution(); - var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w)); - var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h)); - var z = this.getServerZoom()%(tmsoffset)s; - var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type; - var url = this.url; - if (OpenLayers.Util.isArray(url)) { - url = this.selectUrl(path, url); - } - if (mapBounds.intersectsBounds(bounds) && (z >= mapMinZoom) && (z <= mapMaxZoom)) { - return url + path; - } else { - return emptyTileURL; - } - } - """ % args # noqa +def single_threaded_tiling( + input_file: str, output_folder: str, options: Options +) -> None: + """ + Keep a single threaded version that stays clear of multiprocessing, for platforms that would not + support it + """ + if options.verbose: + print("Begin tiles details calc") + conf, tile_details = worker_tile_details( + input_file, output_folder, options) - elif self.options.profile == 'raster': - s += """ - function getURL(bounds) { - bounds = this.adjustBounds(bounds); - var res = this.getServerResolution(); - var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w)); - var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h)); - var z = this.getServerZoom(); - var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type; - var url = this.url; - if (OpenLayers.Util.isArray(url)) { - url = this.selectUrl(path, url); - } - if (mapBounds.intersectsBounds(bounds) && (z >= mapMinZoom) && (z <= mapMaxZoom)) { - return url + path; - } else { - return emptyTileURL; - } - } - """ % args # noqa + if options.verbose: + print("Tiles details calc complete.") - s += """ - function getWindowHeight() { - if (self.innerHeight) return self.innerHeight; - if (document.documentElement && document.documentElement.clientHeight) - return document.documentElement.clientHeight; - if (document.body) return document.body.clientHeight; - return 0; - } + if not options.verbose and not options.quiet: + base_progress_bar = ProgressBar(len(tile_details)) + base_progress_bar.start() - function getWindowWidth() { - if (self.innerWidth) return self.innerWidth; - if (document.documentElement && document.documentElement.clientWidth) - return document.documentElement.clientWidth; - if (document.body) return document.body.clientWidth; - return 0; - } + for tile_detail in tile_details: + create_base_tile(conf, tile_detail) - function resize() { - var map = document.getElementById("map"); - var header = document.getElementById("header"); - var subheader = document.getElementById("subheader"); - map.style.height = (getWindowHeight()-80) + "px"; - map.style.width = (getWindowWidth()-20) + "px"; - header.style.width = (getWindowWidth()-20) + "px"; - subheader.style.width = (getWindowWidth()-20) + "px"; - if (map.updateSize) { map.updateSize(); }; - } + if not options.verbose and not options.quiet: + base_progress_bar.log_progress() - onresize=function(){ resize(); }; + if getattr(threadLocal, "cached_ds", None): + del threadLocal.cached_ds - </script> - </head> - <body onload="init()"> - <div id="header"><h1>%(title)s</h1></div> - <div id="subheader">Generated by <a href="http://www.klokan.cz/projects/gdal2tiles/">GDAL2Tiles</a>, Copyright © 2008 <a href="http://www.klokan.cz/">Klokan Petr Pridal</a>, <a href="http://www.gdal.org/">GDAL</a> & <a href="http://www.osgeo.org/">OSGeo</a> <a href="http://code.google.com/soc/">GSoC</a> - <!-- PLEASE, LET THIS NOTE ABOUT AUTHOR AND PROJECT SOMEWHERE ON YOUR WEBSITE, OR AT LEAST IN THE COMMENT IN HTML. THANK YOU --> - </div> - <div id="map"></div> - <script type="text/javascript" >resize()</script> - </body> - </html>""" % args # noqa + if not options.quiet: + count = count_overview_tiles(conf) + if count: + print("Generating Overview Tiles:") - return s + if not options.verbose: + overview_progress_bar = ProgressBar(count) + overview_progress_bar.start() + for base_tz in range(conf.tmaxz, conf.tminz, -1): + base_tile_groups = group_overview_base_tiles( + base_tz, output_folder, conf) + for base_tiles in base_tile_groups: + create_overview_tile(base_tz, base_tiles, + output_folder, conf, options) + if not options.verbose and not options.quiet: + overview_progress_bar.log_progress() + + shutil.rmtree(os.path.dirname(conf.src_file)) + + if not options.verbose and not options.quiet: + overview_progress_bar.done() + + +def multi_threaded_tiling( + input_file: str, output_folder: str, options: Options, pool +) -> None: + nb_processes = options.nb_processes or 1 + + if options.verbose: + print("Begin tiles details calc") + + conf, tile_details = worker_tile_details( + input_file, output_folder, options) + + if options.verbose: + print("Tiles details calc complete.") + + if not options.verbose and not options.quiet: + base_progress_bar = ProgressBar(len(tile_details)) + base_progress_bar.start() + + # TODO: gbataille - check the confs for which each element is an array... one useless level? + # TODO: gbataille - assign an ID to each job for print in verbose mode "ReadRaster Extent ..." + chunksize = max(1, min(128, len(tile_details) // nb_processes)) + for _ in pool.imap_unordered( + partial(create_base_tile, conf), tile_details, chunksize=chunksize + ): + if not options.verbose and not options.quiet: + base_progress_bar.log_progress() + + if not options.quiet: + count = count_overview_tiles(conf) + if count: + print("Generating Overview Tiles:") + + if not options.verbose: + overview_progress_bar = ProgressBar(count) + overview_progress_bar.start() + + for base_tz in range(conf.tmaxz, conf.tminz, -1): + base_tile_groups = group_overview_base_tiles( + base_tz, output_folder, conf) + chunksize = max(1, min(128, len(base_tile_groups) // nb_processes)) + for _ in pool.imap_unordered( + partial( + create_overview_tile, + base_tz, + output_folder=output_folder, + tile_job_info=conf, + options=options, + ), + base_tile_groups, + chunksize=chunksize, + ): + if not options.verbose and not options.quiet: + overview_progress_bar.log_progress() + + shutil.rmtree(os.path.dirname(conf.src_file)) + + +class UseExceptions(object): + def __enter__(self): + self.old_used_exceptions = gdal.GetUseExceptions() + if not self.old_used_exceptions: + gdal.UseExceptions() + + def __exit__(self, type, value, tb): + if not self.old_used_exceptions: + gdal.DontUseExceptions() + + +class DividedCache(object): + def __init__(self, nb_processes): + self.nb_processes = nb_processes + + def __enter__(self): + self.gdal_cache_max = gdal.GetCacheMax() + # Make sure that all processes do not consume more than `gdal.GetCacheMax()` + gdal_cache_max_per_process = max( + 1024 * 1024, math.floor(self.gdal_cache_max / self.nb_processes) + ) + set_cache_max(gdal_cache_max_per_process) + + def __exit__(self, type, value, tb): + # Set the maximum cache back to the original value + set_cache_max(self.gdal_cache_max) + + +def main(argv: List[str] = sys.argv) -> int: + # TODO: gbataille - use mkdtemp to work in a temp directory + # TODO: gbataille - debug intermediate tiles.vrt not produced anymore? + # TODO: gbataille - Refactor generate overview tiles to not depend on self variables + + # For multiprocessing, we need to propagate the configuration options to + # the environment, so that forked processes can inherit them. + for i in range(len(argv)): + if argv[i] == "--config" and i + 2 < len(argv): + os.environ[argv[i + 1]] = argv[i + 2] + + if "--mpi" in argv: + from mpi4py import MPI + from mpi4py.futures import MPICommExecutor + + with UseExceptions(), MPICommExecutor(MPI.COMM_WORLD, root=0) as pool: + if pool is None: + return 0 + # add interface of multiprocessing.Pool to MPICommExecutor + pool.imap_unordered = partial(pool.map, unordered=True) + return submain(argv, pool, MPI.COMM_WORLD.Get_size()) + else: + return submain(argv) + + +def submain(argv: List[str], pool=None, pool_size=0) -> int: + argv = gdal.GeneralCmdLineProcessor(argv) + if argv is None: + return 0 + input_file, output_folder, options = process_args(argv[1:]) + if pool_size: + options.nb_processes = pool_size + nb_processes = options.nb_processes or 1 -def main(): - argv = gdal.GeneralCmdLineProcessor(sys.argv) - if argv: - gdal2tiles = GDAL2Tiles(argv[1:]) - gdal2tiles.process() + with UseExceptions(): + if pool is not None: # MPI + multi_threaded_tiling(input_file, output_folder, options, pool) + elif nb_processes == 1: + single_threaded_tiling(input_file, output_folder, options) + else: + # Trick inspired from https://stackoverflow.com/questions/45720153/python-multiprocessing-error-attributeerror-module-main-has-no-attribute + # and https://bugs.python.org/issue42949 + import __main__ + + if not hasattr(__main__, "__spec__"): + __main__.__spec__ = None + from multiprocessing import Pool + with DividedCache(nb_processes), Pool(processes=nb_processes) as pool: + multi_threaded_tiling(input_file, output_folder, options, pool) + + return 0 -if __name__ == '__main__': - main() # vim: set tabstop=4 shiftwidth=4 expandtab: + +# Running main() must be protected that way due to use of multiprocessing on Windows: +# https://docs.python.org/3/library/multiprocessing.html#the-spawn-and-forkserver-start-methods +if __name__ == "__main__": + sys.exit(main(sys.argv)) diff --git a/auxiliary/gdal2customtiles/legacy/gdal2customtiles.py b/auxiliary/gdal2customtiles/legacy/gdal2customtiles.py new file mode 100644 index 00000000..f698bebb --- /dev/null +++ b/auxiliary/gdal2customtiles/legacy/gdal2customtiles.py @@ -0,0 +1,3218 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# ****************************************************************************** +# $Id$ +# +# Project: Google Summer of Code 2007, 2008 (http://code.google.com/soc/) +# Support: BRGM (http://www.brgm.fr) +# Purpose: Convert a raster into TMS (Tile Map Service) tiles in a directory. +# - generate Google Earth metadata (KML SuperOverlay) +# - generate simple HTML viewer based on Google Maps and OpenLayers +# - support of global tiles (Spherical Mercator) for compatibility +# with interactive web maps a la Google Maps +# Author: Klokan Petr Pridal, klokan at klokan dot cz +# Web: http://www.klokan.cz/projects/gdal2tiles/ +# GUI: http://www.maptiler.org/ +# +############################################################################### +# Copyright (c) 2008, Klokan Petr Pridal +# Copyright (c) 2010-2013, Even Rouault <even dot rouault at mines-paris dot org> +# +# 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. +# ****************************************************************************** + +import math +import os +import sys + +from osgeo import gdal +from osgeo import osr + +import struct # 1bto4b + + +def binary(num): # 1bto4b + # 1bto4b + return ''.join(bin(c).replace('0b', '').rjust(8, '0') for c in struct.pack('!f', num)) + +# 1bto4b + +def getTilePxBounds(self, tx, ty, tz, ds): + + querysize = self.tilesize + + if self.isRasterBounded: # 'raster' profile: + # tilesize in raster coordinates for actual zoom + tsize = int(self.tsize[tz]) + xsize = self.out_ds.fWorldXSize + ysize = self.out_ds.fWorldYSize + if tz >= self.tmaxz: + querysize = self.tilesize + + rx = (tx) * tsize - self.out_ds.fRasterXOriginWorld + #print("rx", rx) + rxsize = 0 + rxsize = tsize + + rysize = 0 + rysize = tsize + + ry = ysize - (ty * tsize) - rysize - \ + self.out_ds.fRasterYOriginWorld + + wx, wy = 0, 0 + wxsize = int(rxsize/float(tsize) * self.tilesize) + wysize = int(rysize/float(tsize) * self.tilesize) + if wysize != self.tilesize: + wy = self.tilesize - wysize + + if rx < 0: + rxsize = tsize + rx + wx = -rx + wxsize = int(rxsize/float(tsize) * self.tilesize) + rx = 0 + if ry < 0: + rysize = tsize + ry + wy = -ry + wysize = int(rysize/float(tsize) * self.tilesize) + ry = 0 + if rx + rxsize > self.out_ds.fRasterXSizeWorld: + rxsize = self.out_ds.fRasterXSizeWorld - rx + wxsize = int(rxsize/float(tsize) * self.tilesize) + if ry + rysize > self.out_ds.fRasterYSizeWorld: + rysize = self.out_ds.fRasterYSizeWorld - ry + wysize = int(rysize/float(tsize) * self.tilesize) + + # Convert rx, ry back to non-world coordinates + rx = int(float(self.out_ds.RasterXSize) * + (float(rx) / self.out_ds.fRasterXSizeWorld)) + ry = int(float(self.out_ds.RasterYSize) * + (float(ry) / self.out_ds.fRasterYSizeWorld)) + rxsize = int(float(self.out_ds.RasterXSize) * + (float(rxsize) / self.out_ds.fRasterXSizeWorld)) + rysize = int(float(self.out_ds.RasterYSize) * + (float(rysize) / self.out_ds.fRasterYSizeWorld)) + else: + b = self.mercator.TileBounds(tx, ty, tz) + rb, wb = self.geo_query( + ds, b[0], b[3], b[2], b[1], querysize=querysize) + rx, ry, rxsize, rysize = rb + wx, wy, wxsize, wysize = wb + + return [rx, ry, rxsize, rysize, wxsize, wysize] + + +try: + from PIL import Image + import numpy + import osgeo.gdal_array as gdalarray +except Exception: + # 'antialias' resampling is not available + pass + +__version__ = "$Id$" + +resampling_list = ('average', 'near', 'bilinear', 'cubic', + 'cubicspline', 'lanczos', 'antialias') +profile_list = ('mercator', 'geodetic', 'raster') +webviewer_list = ('all', 'google', 'openlayers', 'leaflet', 'none') + +# ============================================================================= +# ============================================================================= +# ============================================================================= + +__doc__globalmaptiles = """ +globalmaptiles.py + +Global Map Tiles as defined in Tile Map Service (TMS) Profiles +============================================================== + +Functions necessary for generation of global tiles used on the web. +It contains classes implementing coordinate conversions for: + + - GlobalMercator (based on EPSG:3857) + for Google Maps, Yahoo Maps, Bing Maps compatible tiles + - GlobalGeodetic (based on EPSG:4326) + for OpenLayers Base Map and Google Earth compatible tiles + +More info at: + +http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification +http://wiki.osgeo.org/wiki/WMS_Tiling_Client_Recommendation +http://msdn.microsoft.com/en-us/library/bb259689.aspx +http://code.google.com/apis/maps/documentation/overlays.html#Google_Maps_Coordinates + +Created by Klokan Petr Pridal on 2008-07-03. +Google Summer of Code 2008, project GDAL2Tiles for OSGEO. + +In case you use this class in your product, translate it to another language +or find it useful for your project please let me know. +My email: klokan at klokan dot cz. +I would like to know where it was used. + +Class is available under the open-source GDAL license (www.gdal.org). +""" + +MAXZOOMLEVEL = 32 + + +class GlobalMercator(object): + r""" + TMS Global Mercator Profile + --------------------------- + + Functions necessary for generation of tiles in Spherical Mercator projection, + EPSG:3857. + + Such tiles are compatible with Google Maps, Bing Maps, Yahoo Maps, + UK Ordnance Survey OpenSpace API, ... + and you can overlay them on top of base maps of those web mapping applications. + + Pixel and tile coordinates are in TMS notation (origin [0,0] in bottom-left). + + What coordinate conversions do we need for TMS Global Mercator tiles:: + + LatLon <-> Meters <-> Pixels <-> Tile + + WGS84 coordinates Spherical Mercator Pixels in pyramid Tiles in pyramid + lat/lon XY in meters XY pixels Z zoom XYZ from TMS + EPSG:4326 EPSG:387 + .----. --------- -- TMS + / \ <-> | | <-> /----/ <-> Google + \ / | | /--------/ QuadTree + ----- --------- /------------/ + KML, public WebMapService Web Clients TileMapService + + What is the coordinate extent of Earth in EPSG:3857? + + [-20037508.342789244, -20037508.342789244, + 20037508.342789244, 20037508.342789244] + Constant 20037508.342789244 comes from the circumference of the Earth in meters, + which is 40 thousand kilometers, the coordinate origin is in the middle of extent. + In fact you can calculate the constant as: 2 * math.pi * 6378137 / 2.0 + $ echo 180 85 | gdaltransform -s_srs EPSG:4326 -t_srs EPSG:3857 + Polar areas with abs(latitude) bigger then 85.05112878 are clipped off. + + What are zoom level constants (pixels/meter) for pyramid with EPSG:3857? + + whole region is on top of pyramid (zoom=0) covered by 256x256 pixels tile, + every lower zoom level resolution is always divided by two + initialResolution = 20037508.342789244 * 2 / 256 = 156543.03392804062 + + What is the difference between TMS and Google Maps/QuadTree tile name convention? + + The tile raster itself is the same (equal extent, projection, pixel size), + there is just different identification of the same raster tile. + Tiles in TMS are counted from [0,0] in the bottom-left corner, id is XYZ. + Google placed the origin [0,0] to the top-left corner, reference is XYZ. + Microsoft is referencing tiles by a QuadTree name, defined on the website: + http://msdn2.microsoft.com/en-us/library/bb259689.aspx + + The lat/lon coordinates are using WGS84 datum, yes? + + Yes, all lat/lon we are mentioning should use WGS84 Geodetic Datum. + Well, the web clients like Google Maps are projecting those coordinates by + Spherical Mercator, so in fact lat/lon coordinates on sphere are treated as if + the were on the WGS84 ellipsoid. + + From MSDN documentation: + To simplify the calculations, we use the spherical form of projection, not + the ellipsoidal form. Since the projection is used only for map display, + and not for displaying numeric coordinates, we don't need the extra precision + of an ellipsoidal projection. The spherical projection causes approximately + 0.33 percent scale distortion in the Y direction, which is not visually + noticeable. + + How do I create a raster in EPSG:3857 and convert coordinates with PROJ.4? + + You can use standard GIS tools like gdalwarp, cs2cs or gdaltransform. + All of the tools supports -t_srs 'epsg:3857'. + + For other GIS programs check the exact definition of the projection: + More info at http://spatialreference.org/ref/user/google-projection/ + The same projection is designated as EPSG:3857. WKT definition is in the + official EPSG database. + + Proj4 Text: + +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 + +k=1.0 +units=m +nadgrids=@null +no_defs + + Human readable WKT format of EPSG:3857: + PROJCS["Google Maps Global Mercator", + GEOGCS["WGS 84", + DATUM["WGS_1984", + SPHEROID["WGS 84",6378137,298.257223563, + AUTHORITY["EPSG","7030"]], + AUTHORITY["EPSG","6326"]], + PRIMEM["Greenwich",0], + UNIT["degree",0.0174532925199433], + AUTHORITY["EPSG","4326"]], + PROJECTION["Mercator_1SP"], + PARAMETER["central_meridian",0], + PARAMETER["scale_factor",1], + PARAMETER["false_easting",0], + PARAMETER["false_northing",0], + UNIT["metre",1, + AUTHORITY["EPSG","9001"]]] + """ + + def __init__(self, tileSize=256): + "Initialize the TMS Global Mercator pyramid" + self.tileSize = tileSize + self.initialResolution = 2 * math.pi * 6378137 / self.tileSize + # 156543.03392804062 for tileSize 256 pixels + self.originShift = 2 * math.pi * 6378137 / 2.0 + # 20037508.342789244 + + def LatLonToMeters(self, lat, lon): + "Converts given lat/lon in WGS84 Datum to XY in Spherical Mercator EPSG:3857" + + mx = lon * self.originShift / 180.0 + my = math.log(math.tan((90 + lat) * math.pi / 360.0)) / \ + (math.pi / 180.0) + + my = my * self.originShift / 180.0 + return mx, my + + def MetersToLatLon(self, mx, my): + "Converts XY point from Spherical Mercator EPSG:3857 to lat/lon in WGS84 Datum" + + lon = (mx / self.originShift) * 180.0 + lat = (my / self.originShift) * 180.0 + + lat = 180 / math.pi * \ + (2 * math.atan(math.exp(lat * math.pi / 180.0)) - math.pi / 2.0) + return lat, lon + + def PixelsToMeters(self, px, py, zoom): + "Converts pixel coordinates in given zoom level of pyramid to EPSG:3857" + + res = self.Resolution(zoom) + mx = px * res - self.originShift + my = py * res - self.originShift + return mx, my + + def MetersToPixels(self, mx, my, zoom): + "Converts EPSG:3857 to pyramid pixel coordinates in given zoom level" + + res = self.Resolution(zoom) + px = (mx + self.originShift) / res + py = (my + self.originShift) / res + return px, py + + def PixelsToTile(self, px, py): + "Returns a tile covering region in given pixel coordinates" + + tx = int(math.ceil(px / float(self.tileSize)) - 1) + ty = int(math.ceil(py / float(self.tileSize)) - 1) + return tx, ty + + def PixelsToRaster(self, px, py, zoom): + "Move the origin of pixel coordinates to top-left corner" + + mapSize = self.tileSize << zoom + return px, mapSize - py + + def MetersToTile(self, mx, my, zoom): + "Returns tile for given mercator coordinates" + + px, py = self.MetersToPixels(mx, my, zoom) + return self.PixelsToTile(px, py) + + def TileBounds(self, tx, ty, zoom): + "Returns bounds of the given tile in EPSG:3857 coordinates" + + minx, miny = self.PixelsToMeters( + tx*self.tileSize, ty*self.tileSize, zoom) + maxx, maxy = self.PixelsToMeters( + (tx+1)*self.tileSize, (ty+1)*self.tileSize, zoom) + return (minx, miny, maxx, maxy) + + def TileLatLonBounds(self, tx, ty, zoom): + "Returns bounds of the given tile in latitude/longitude using WGS84 datum" + + bounds = self.TileBounds(tx, ty, zoom) + minLat, minLon = self.MetersToLatLon(bounds[0], bounds[1]) + maxLat, maxLon = self.MetersToLatLon(bounds[2], bounds[3]) + + return (minLat, minLon, maxLat, maxLon) + + def Resolution(self, zoom): + "Resolution (meters/pixel) for given zoom level (measured at Equator)" + + # return (2 * math.pi * 6378137) / (self.tileSize * 2**zoom) + return self.initialResolution / (2**zoom) + + def ZoomForPixelSize(self, pixelSize): + "Maximal scaledown zoom of the pyramid closest to the pixelSize." + + for i in range(MAXZOOMLEVEL): + if pixelSize > self.Resolution(i): + if i != -1: + return i-1 + else: + return 0 # We don't want to scale up + + def GoogleTile(self, tx, ty, zoom): + "Converts TMS tile coordinates to Google Tile coordinates" + + # coordinate origin is moved from bottom-left to top-left corner of the extent + return tx, (2**zoom - 1) - ty + + def QuadTree(self, tx, ty, zoom): + "Converts TMS tile coordinates to Microsoft QuadTree" + + quadKey = "" + ty = (2**zoom - 1) - ty + for i in range(zoom, 0, -1): + digit = 0 + mask = 1 << (i-1) + if (tx & mask) != 0: + digit += 1 + if (ty & mask) != 0: + digit += 2 + quadKey += str(digit) + + return quadKey + + +class GlobalGeodetic(object): + r""" + TMS Global Geodetic Profile + --------------------------- + + Functions necessary for generation of global tiles in Plate Carre projection, + EPSG:4326, "unprojected profile". + + Such tiles are compatible with Google Earth (as any other EPSG:4326 rasters) + and you can overlay the tiles on top of OpenLayers base map. + + Pixel and tile coordinates are in TMS notation (origin [0,0] in bottom-left). + + What coordinate conversions do we need for TMS Global Geodetic tiles? + + Global Geodetic tiles are using geodetic coordinates (latitude,longitude) + directly as planar coordinates XY (it is also called Unprojected or Plate + Carre). We need only scaling to pixel pyramid and cutting to tiles. + Pyramid has on top level two tiles, so it is not square but rectangle. + Area [-180,-90,180,90] is scaled to 512x256 pixels. + TMS has coordinate origin (for pixels and tiles) in bottom-left corner. + Rasters are in EPSG:4326 and therefore are compatible with Google Earth. + + LatLon <-> Pixels <-> Tiles + + WGS84 coordinates Pixels in pyramid Tiles in pyramid + lat/lon XY pixels Z zoom XYZ from TMS + EPSG:4326 + .----. ---- + / \ <-> /--------/ <-> TMS + \ / /--------------/ + ----- /--------------------/ + WMS, KML Web Clients, Google Earth TileMapService + """ + + def __init__(self, tmscompatible, tileSize=256): + self.tileSize = tileSize + if tmscompatible is not None: + # Defaults the resolution factor to 0.703125 (2 tiles @ level 0) + # Adhers to OSGeo TMS spec + # http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification#global-geodetic + self.resFact = 180.0 / self.tileSize + else: + # Defaults the resolution factor to 1.40625 (1 tile @ level 0) + # Adheres OpenLayers, MapProxy, etc default resolution for WMTS + self.resFact = 360.0 / self.tileSize + + def LonLatToPixels(self, lon, lat, zoom): + "Converts lon/lat to pixel coordinates in given zoom of the EPSG:4326 pyramid" + + res = self.resFact / 2**zoom + px = (180 + lon) / res + py = (90 + lat) / res + return px, py + + def PixelsToTile(self, px, py): + "Returns coordinates of the tile covering region in pixel coordinates" + + tx = int(math.ceil(px / float(self.tileSize)) - 1) + ty = int(math.ceil(py / float(self.tileSize)) - 1) + return tx, ty + + def LonLatToTile(self, lon, lat, zoom): + "Returns the tile for zoom which covers given lon/lat coordinates" + + px, py = self.LonLatToPixels(lon, lat, zoom) + return self.PixelsToTile(px, py) + + def Resolution(self, zoom): + "Resolution (arc/pixel) for given zoom level (measured at Equator)" + + return self.resFact / 2**zoom + + def ZoomForPixelSize(self, pixelSize): + "Maximal scaledown zoom of the pyramid closest to the pixelSize." + + for i in range(MAXZOOMLEVEL): + if pixelSize > self.Resolution(i): + if i != 0: + return i-1 + else: + return 0 # We don't want to scale up + + def TileBounds(self, tx, ty, zoom): + "Returns bounds of the given tile" + res = self.resFact / 2**zoom + return ( + tx*self.tileSize*res - 180, + ty*self.tileSize*res - 90, + (tx+1)*self.tileSize*res - 180, + (ty+1)*self.tileSize*res - 90 + ) + + def TileLatLonBounds(self, tx, ty, zoom): + "Returns bounds of the given tile in the SWNE form" + b = self.TileBounds(tx, ty, zoom) + return (b[1], b[0], b[3], b[2]) + + +class Zoomify(object): + """ + Tiles compatible with the Zoomify viewer + ---------------------------------------- + """ + + def __init__(self, width, height, tilesize=256, tileformat='jpg'): + """Initialization of the Zoomify tile tree""" + + self.tilesize = tilesize + self.tileformat = tileformat + imagesize = (width, height) + tiles = (math.ceil(width / tilesize), math.ceil(height / tilesize)) + + # Size (in tiles) for each tier of pyramid. + self.tierSizeInTiles = [] + self.tierSizeInTiles.append(tiles) + + # Image size in pixels for each pyramid tierself + self.tierImageSize = [] + self.tierImageSize.append(imagesize) + + while (imagesize[0] > tilesize or imagesize[1] > tilesize): + imagesize = (math.floor( + imagesize[0] / 2), math.floor(imagesize[1] / 2)) + tiles = (math.ceil(imagesize[0] / tilesize), + math.ceil(imagesize[1] / tilesize)) + self.tierSizeInTiles.append(tiles) + self.tierImageSize.append(imagesize) + + self.tierSizeInTiles.reverse() + self.tierImageSize.reverse() + + # Depth of the Zoomify pyramid, number of tiers (zoom levels) + self.numberOfTiers = len(self.tierSizeInTiles) + + # Number of tiles up to the given tier of pyramid. + self.tileCountUpToTier = [] + self.tileCountUpToTier[0] = 0 + for i in range(1, self.numberOfTiers+1): + self.tileCountUpToTier.append( + self.tierSizeInTiles[i-1][0] * self.tierSizeInTiles[i-1][1] + + self.tileCountUpToTier[i-1] + ) + + def tilefilename(self, x, y, z): + """Returns filename for tile with given coordinates""" + + tileIndex = x + y * \ + self.tierSizeInTiles[z][0] + self.tileCountUpToTier[z] + return os.path.join("TileGroup%.0f" % math.floor(tileIndex / 256), + "%s-%s-%s.%s" % (z, x, y, self.tileformat)) + + +class Gdal2TilesError(Exception): + pass + + +class GDAL2Tiles(object): + + def process(self): + """The main processing function, runs all the main steps of processing""" + + # Opening and preprocessing of the input file + self.open_input() + + # Generation of main metadata files and HTML viewers + self.generate_metadata() + + # 1bto4b + if self.isDEMtile: + for z in range(self.tminz, self.tmaxz + int(abs(math.log(self.tilesize, 2) - 8))): # 1bto4b + self.generate_base_tiles(z) + print(' Zoom ' + str(z) + ' tiles done!') + else: + # Generation of the lowest tiles + self.generate_base_tiles(self.tmaxz) + + # Generation of the overview tiles (higher in the pyramid) + self.generate_overview_tiles() + + def error(self, msg, details=""): + """Print an error message and stop the processing""" + if details: + self.parser.error(msg + "\n\n" + details) + else: + self.parser.error(msg) + + def progressbar(self, complete=0.0): + """Print progressbar for float value 0..1""" + gdal.TermProgress_nocb(complete) + + def gettempfilename(self, suffix): + """Returns a temporary filename""" + if '_' in os.environ: + # tempfile.mktemp() crashes on some Wine versions (the one of Ubuntu 12.04 particularly) + if os.environ['_'].find('wine') >= 0: + tmpdir = '.' + if 'TMP' in os.environ: + tmpdir = os.environ['TMP'] + import time + import random + random.seed(time.time()) + random_part = 'file%d' % random.randint(0, 1000000000) + return os.path.join(tmpdir, random_part + suffix) + + import tempfile + return tempfile.mktemp(suffix) + + def stop(self): + """Stop the rendering immediately""" + self.stopped = True + + def __init__(self, arguments): + """Constructor function - initialization""" + self.out_drv = None + self.mem_drv = None + self.in_ds = None + self.out_ds = None + self.out_srs = None + self.nativezoom = None + self.tminmax = None + self.tsize = None + self.mercator = None + self.geodetic = None + self.alphaband = None + self.dataBandsCount = None + self.out_gt = None + self.tileswne = None + self.swne = None + self.ominx = None + self.omaxx = None + self.omaxy = None + self.ominy = None + + # MMGIS + self.isRasterBounded = False + + # 1bto4b + self.isDEMtile = False + + # MMGIS + self.fminx = None + self.fmaxx = None + self.fminy = None + self.fmaxy = None + self.fPixelSize = None + + self.stopped = False + self.input = None + self.output = None + + # Tile format + self.tilesize = 256 + self.tiledriver = 'PNG' + self.tileext = 'png' + + # Should we read bigger window of the input raster and scale it down? + # Note: Modified later by open_input() + # Not for 'near' resampling + # Not for Wavelet based drivers (JPEG2000, ECW, MrSID) + # Not for 'raster' profile + self.scaledquery = True + # How big should be query window be for scaling down + # Later on reset according the chosen resampling algorightm + self.querysize = 4 * self.tilesize + + # Should we use Read on the input file for generating overview tiles? + # Note: Modified later by open_input() + # Otherwise the overview tiles are generated from existing underlying tiles + self.overviewquery = False + + # RUN THE ARGUMENT PARSER: + + self.optparse_init() + self.options, self.args = self.parser.parse_args(args=arguments) + if not self.args: + self.error("No input file specified") + + # POSTPROCESSING OF PARSED ARGUMENTS: + + # Workaround for old versions of GDAL + try: + if ((self.options.verbose and self.options.resampling == 'near') or + gdal.TermProgress_nocb): + pass + except Exception: + self.error( + "This version of GDAL is not supported. Please upgrade to 1.6+.") + + # Is output directory the last argument? + + # Test output directory, if it doesn't exist + if (os.path.isdir(self.args[-1]) or + (len(self.args) > 1 and not os.path.exists(self.args[-1]))): + self.output = self.args[-1] + self.args = self.args[:-1] + + # More files on the input not directly supported yet + + if (len(self.args) > 1): + self.error("Processing of several input files is not supported.", + "Please first use a tool like gdal_vrtmerge.py or gdal_merge.py on the " + "files: gdal_vrtmerge.py -o merged.vrt %s" % " ".join(self.args)) + + self.input = self.args[0] + + # MMGIS + if self.options.extentworld: + extentworld = self.options.extentworld.split(",") + self.isRasterBounded = True + self.fminx = float(extentworld[0]) + self.fmaxx = float(extentworld[2]) + self.fminy = float(extentworld[3]) + self.fmaxy = float(extentworld[1]) + self.fPixelSize = float(extentworld[4]) + + # 1bto4b + if self.options.isDEMtile: + self.isDEMtile = True + self.tilesize = 32 + self.querysize = 4 * self.tilesize + + # Default values for not given options + + if not self.output: + # Directory with input filename without extension in actual directory + self.output = os.path.splitext(os.path.basename(self.input))[0] + + if not self.options.title: + self.options.title = os.path.basename(self.input) + + if self.options.url and not self.options.url.endswith('/'): + self.options.url += '/' + if self.options.url: + self.options.url += os.path.basename(self.output) + '/' + + # Supported options + + self.resampling = None + + if self.options.resampling == 'average': + try: + if gdal.RegenerateOverview: + pass + except Exception: + self.error("'average' resampling algorithm is not available.", + "Please use -r 'near' argument or upgrade to newer version of GDAL.") + + elif self.options.resampling == 'antialias': + try: + if numpy: # pylint:disable=W0125 + pass + except Exception: + self.error("'antialias' resampling algorithm is not available.", + "Install PIL (Python Imaging Library) and numpy.") + + elif self.options.resampling == 'near': + self.resampling = gdal.GRA_NearestNeighbour + self.querysize = self.tilesize + + elif self.options.resampling == 'bilinear': + self.resampling = gdal.GRA_Bilinear + self.querysize = self.tilesize * 2 + + elif self.options.resampling == 'cubic': + self.resampling = gdal.GRA_Cubic + + elif self.options.resampling == 'cubicspline': + self.resampling = gdal.GRA_CubicSpline + + elif self.options.resampling == 'lanczos': + self.resampling = gdal.GRA_Lanczos + + # User specified zoom levels + self.tminz = None + self.tmaxz = None + if self.options.zoom: + minmax = self.options.zoom.split('-', 1) + minmax.extend(['']) + zoom_min, zoom_max = minmax[:2] + self.tminz = int(zoom_min) + if zoom_max: + self.tmaxz = int(zoom_max) + else: + self.tmaxz = int(zoom_min) + + # KML generation + self.kml = self.options.kml + + # Check if the input filename is full ascii or not + try: + os.path.basename(self.input).encode('ascii') + except UnicodeEncodeError: + full_ascii = False + else: + full_ascii = True + + # LC_CTYPE check + if not full_ascii and 'UTF-8' not in os.environ.get("LC_CTYPE", ""): + if not self.options.quiet: + print("\nWARNING: " + "You are running gdal2tiles.py with a LC_CTYPE environment variable that is " + "not UTF-8 compatible, and your input file contains non-ascii characters. " + "The generated sample googlemaps, openlayers or " + "leaflet files might contain some invalid characters as a result\n") + + # Output the results + if self.options.verbose: + print("Options:", self.options) + print("Input:", self.input) + print("Output:", self.output) + print("Cache: %s MB" % (gdal.GetCacheMax() / 1024 / 1024)) + print('') + + def optparse_init(self): + """Prepare the option parser for input (argv)""" + + from optparse import OptionParser, OptionGroup + usage = "Usage: %prog [options] input_file(s) [output]" + p = OptionParser(usage, version="%prog " + __version__) + p.add_option("-p", "--profile", dest='profile', + type='choice', choices=profile_list, + help=("Tile cutting profile (%s) - default 'mercator' " + "(Google Maps compatible)" % ",".join(profile_list))) + p.add_option("-r", "--resampling", dest="resampling", + type='choice', choices=resampling_list, + help="Resampling method (%s) - default 'average'" % ",".join(resampling_list)) + p.add_option('-s', '--s_srs', dest="s_srs", metavar="SRS", + help="The spatial reference system used for the source input data") + p.add_option('-z', '--zoom', dest="zoom", + help="Zoom levels to render (format:'2-5' or '10').") + p.add_option('-e', '--resume', dest="resume", action="store_true", + help="Resume mode. Generate only missing files.") + p.add_option('-a', '--srcnodata', dest="srcnodata", metavar="NODATA", + help="NODATA transparency value to assign to the input data") + p.add_option('-d', '--tmscompatible', dest="tmscompatible", action="store_true", + help=("When using the geodetic profile, specifies the base resolution " + "as 0.703125 or 2 tiles at zoom level 0.")) + p.add_option("-v", "--verbose", + action="store_true", dest="verbose", + help="Print status messages to stdout") + p.add_option("-q", "--quiet", + action="store_true", dest="quiet", + help="Disable messages and status to stdout") + # MMGIS + p.add_option("-x", "--extentworld", dest="extentworld", + help="The full world meter extent (comma-separated as minx,maxx,miny,maxy,pixelsize) of an inner raster profile.") + # 1bto4b + p.add_option("-m", "--dem", action="store_true", dest="isDEMtile", + help="Indicate if the input is a Digital Elevation Model") + # KML options + g = OptionGroup(p, "KML (Google Earth) options", + "Options for generated Google Earth SuperOverlay metadata") + g.add_option("-k", "--force-kml", dest='kml', action="store_true", + help=("Generate KML for Google Earth - default for 'geodetic' profile and " + "'raster' in EPSG:4326. For a dataset with different projection use " + "with caution!")) + g.add_option("-n", "--no-kml", dest='kml', action="store_false", + help="Avoid automatic generation of KML files for EPSG:4326") + g.add_option("-u", "--url", dest='url', + help="URL address where the generated tiles are going to be published") + p.add_option_group(g) + + # HTML options + g = OptionGroup(p, "Web viewer options", + "Options for generated HTML viewers a la Google Maps") + g.add_option("-w", "--webviewer", dest='webviewer', type='choice', choices=webviewer_list, + help="Web viewer to generate (%s) - default 'all'" % ",".join(webviewer_list)) + g.add_option("-t", "--title", dest='title', + help="Title of the map") + g.add_option("-c", "--copyright", dest='copyright', + help="Copyright for the map") + g.add_option("-g", "--googlekey", dest='googlekey', + help="Google Maps API key from http://code.google.com/apis/maps/signup.html") + g.add_option("-b", "--bingkey", dest='bingkey', + help="Bing Maps API key from https://www.bingmapsportal.com/") + p.add_option_group(g) + + p.set_defaults(verbose=False, profile="mercator", kml=False, url='', + webviewer='all', copyright='', resampling='average', resume=False, + googlekey='INSERT_YOUR_KEY_HERE', bingkey='INSERT_YOUR_KEY_HERE') + + self.parser = p + + # ------------------------------------------------------------------------- + def open_input(self): + """Initialization of the input raster, reprojection if necessary""" + gdal.AllRegister() + + self.out_drv = gdal.GetDriverByName(self.tiledriver) + self.mem_drv = gdal.GetDriverByName('MEM') + + if not self.out_drv: + raise Exception("The '%s' driver was not found, is it available in this GDAL build?", + self.tiledriver) + if not self.mem_drv: + raise Exception( + "The 'MEM' driver was not found, is it available in this GDAL build?") + + # Open the input file + + if self.input: + self.in_ds = gdal.Open(self.input, gdal.GA_ReadOnly) + else: + raise Exception("No input file was specified") + + if self.options.verbose: + print("Input file:", + "( %sP x %sL - %s bands)" % (self.in_ds.RasterXSize, self.in_ds.RasterYSize, + self.in_ds.RasterCount)) + + if not self.in_ds: + # Note: GDAL prints the ERROR message too + self.error( + "It is not possible to open the input file '%s'." % self.input) + + # Read metadata from the input file + if self.in_ds.RasterCount == 0: + self.error("Input file '%s' has no raster band" % self.input) + + if self.in_ds.GetRasterBand(1).GetRasterColorTable(): + self.error("Please convert this file to RGB/RGBA and run gdal2tiles on the result.", + "From paletted file you can create RGBA file (temp.vrt) by:\n" + "gdal_translate -of vrt -expand rgba %s temp.vrt\n" + "then run:\n" + "gdal2tiles temp.vrt" % self.input) + + # Get NODATA value + in_nodata = [] + for i in range(1, self.in_ds.RasterCount+1): + if self.in_ds.GetRasterBand(i).GetNoDataValue() is not None: + in_nodata.append(self.in_ds.GetRasterBand(i).GetNoDataValue()) + if self.options.srcnodata: + nds = list(map(float, self.options.srcnodata.split(','))) + if len(nds) < self.in_ds.RasterCount: + in_nodata = ( + nds * self.in_ds.RasterCount)[:self.in_ds.RasterCount] + else: + in_nodata = nds + + if self.options.verbose: + print("NODATA: %s" % in_nodata) + + if self.options.verbose: + print("Preprocessed file:", + "( %sP x %sL - %s bands)" % (self.in_ds.RasterXSize, self.in_ds.RasterYSize, + self.in_ds.RasterCount)) + + in_srs = None + + if self.options.s_srs: + in_srs = osr.SpatialReference() + in_srs.SetFromUserInput(self.options.s_srs) + in_srs_wkt = in_srs.ExportToWkt() + else: + in_srs_wkt = self.in_ds.GetProjection() + if not in_srs_wkt and self.in_ds.GetGCPCount() != 0: + in_srs_wkt = self.in_ds.GetGCPProjection() + if in_srs_wkt: + in_srs = osr.SpatialReference() + in_srs.ImportFromWkt(in_srs_wkt) + + self.out_srs = osr.SpatialReference() + + if self.options.profile == 'mercator': + self.out_srs.ImportFromEPSG(3857) + elif self.options.profile == 'geodetic': + self.out_srs.ImportFromEPSG(4326) + else: + self.out_srs = in_srs + + # Are the reference systems the same? Reproject if necessary. + + self.out_ds = None + + if self.options.profile in ('mercator', 'geodetic'): + + if ((self.in_ds.GetGeoTransform() == (0.0, 1.0, 0.0, 0.0, 0.0, 1.0)) and + (self.in_ds.GetGCPCount() == 0)): + self.error("There is no georeference - neither affine transformation (worldfile) " + "nor GCPs. You can generate only 'raster' profile tiles.", + "Either gdal2tiles with parameter -p 'raster' or use another GIS " + "software for georeference e.g. gdal_transform -gcp / -a_ullr / -a_srs") + + if in_srs: + if ((in_srs.ExportToProj4() != self.out_srs.ExportToProj4()) or + (self.in_ds.GetGCPCount() != 0)): + # Generation of VRT dataset in tile projection, + # default 'nearest neighbour' warping + self.out_ds = gdal.AutoCreateWarpedVRT( + self.in_ds, in_srs_wkt, self.out_srs.ExportToWkt()) + + if self.options.verbose: + print("Warping of the raster by AutoCreateWarpedVRT " + "(result saved into 'tiles.vrt')") + self.out_ds.GetDriver().CreateCopy("tiles.vrt", self.out_ds) + + # Correction of AutoCreateWarpedVRT for NODATA values + if in_nodata != []: + tempfilename = self.gettempfilename('-gdal2tiles.vrt') + self.out_ds.GetDriver().CreateCopy(tempfilename, self.out_ds) + # open as a text file + s = open(tempfilename).read() + # Add the warping options + s = s.replace( + "<GDALWarpOptions>", + """ + <GDALWarpOptions> + <Option name="INIT_DEST">NO_DATA</Option> + <Option name="UNIFIED_SRC_NODATA">YES</Option> + """) + # replace BandMapping tag for NODATA bands.... + for i in range(len(in_nodata)): + s = s.replace( + '<BandMapping src="%i" dst="%i"/>' % ( + (i+1), (i+1)), + """ + <BandMapping src="%i" dst="%i"> + <SrcNoDataReal>%i</SrcNoDataReal> + <SrcNoDataImag>0</SrcNoDataImag> + <DstNoDataReal>%i</DstNoDataReal> + <DstNoDataImag>0</DstNoDataImag> + </BandMapping> + """ % ((i+1), (i+1), in_nodata[i], in_nodata[i])) + # save the corrected VRT + open(tempfilename, "w").write(s) + # open by GDAL as self.out_ds + self.out_ds = gdal.Open(tempfilename) + # delete the temporary file + os.unlink(tempfilename) + + # set NODATA_VALUE metadata + self.out_ds.SetMetadataItem( + 'NODATA_VALUES', ' '.join([str(i) for i in in_nodata])) + + if self.options.verbose: + print("Modified warping result saved into 'tiles1.vrt'") + open("tiles1.vrt", "w").write(s) + + # Correction of AutoCreateWarpedVRT for Mono (1 band) and RGB (3 bands) files + # without NODATA: + # equivalent of gdalwarp -dstalpha + if in_nodata == [] and self.out_ds.RasterCount in [1, 3]: + tempfilename = self.gettempfilename('-gdal2tiles.vrt') + self.out_ds.GetDriver().CreateCopy(tempfilename, self.out_ds) + # open as a text file + s = open(tempfilename).read() + # Add the warping options + s = s.replace( + "<BlockXSize>", + """ + <VRTRasterBand dataType="Byte" band="%i" subClass="VRTWarpedRasterBand"> + <ColorInterp>Alpha</ColorInterp> + </VRTRasterBand> + <BlockXSize> + """ % (self.out_ds.RasterCount + 1)) + s = s.replace( + "</GDALWarpOptions>", + """ + <DstAlphaBand>%i</DstAlphaBand> + </GDALWarpOptions> + """ % (self.out_ds.RasterCount + 1)) + s = s.replace( + "</WorkingDataType>", + """ + </WorkingDataType> + <Option name="INIT_DEST">0</Option> + """) + # save the corrected VRT + open(tempfilename, "w").write(s) + # open by GDAL as self.out_ds + self.out_ds = gdal.Open(tempfilename) + # delete the temporary file + os.unlink(tempfilename) + + if self.options.verbose: + print( + "Modified -dstalpha warping result saved into 'tiles1.vrt'") + open("tiles1.vrt", "w").write(s) + s = ''' + ''' + + else: + self.error("Input file has unknown SRS.", + "Use --s_srs ESPG:xyz (or similar) to provide source reference system.") + + if self.out_ds and self.options.verbose: + print("Projected file:", "tiles.vrt", "( %sP x %sL - %s bands)" % ( + self.out_ds.RasterXSize, self.out_ds.RasterYSize, self.out_ds.RasterCount)) + + if not self.out_ds: + self.out_ds = self.in_ds + + # + # Here we should have a raster (out_ds) in the correct Spatial Reference system + # + + # Get alpha band (either directly or from NODATA value) + self.alphaband = self.out_ds.GetRasterBand(1).GetMaskBand() + if ((self.alphaband.GetMaskFlags() & gdal.GMF_ALPHA) or + self.out_ds.RasterCount == 4 or + self.out_ds.RasterCount == 2): + self.dataBandsCount = self.out_ds.RasterCount - 1 + else: + self.dataBandsCount = self.out_ds.RasterCount + + # KML test + isepsg4326 = False + srs4326 = osr.SpatialReference() + srs4326.ImportFromEPSG(4326) + if self.out_srs and srs4326.ExportToProj4() == self.out_srs.ExportToProj4(): + self.kml = True + isepsg4326 = True + if self.options.verbose: + print("KML autotest OK!") + + # Read the georeference + self.out_gt = self.out_ds.GetGeoTransform() + + # Test the size of the pixel + + # Report error in case rotation/skew is in geotransform (possible only in 'raster' profile) + if (self.out_gt[2], self.out_gt[4]) != (0, 0): + self.error("Georeference of the raster contains rotation or skew. " + "Such raster is not supported. Please use gdalwarp first.") + + # Here we expect: pixel is square, no rotation on the raster + + # Output Bounds - coordinates in the output SRS + self.ominx = self.out_gt[0] + self.omaxx = self.out_gt[0] + self.out_ds.RasterXSize * self.out_gt[1] + self.omaxy = self.out_gt[3] + self.ominy = self.out_gt[3] - self.out_ds.RasterYSize * self.out_gt[1] + + # Note: maybe round(x, 14) to avoid the gdal_translate behaviour, when 0 becomes -1e-15 + + # MMGIS + def linearScale(domain, rang, value): + return ( + ((rang[1] - rang[0]) * (value - domain[0])) / + (domain[1] - domain[0]) + + rang[0] + ) + # MMGIS + self.out_ds.fRasterXSize = self.out_ds.RasterXSize + self.out_ds.fRasterYSize = self.out_ds.RasterYSize + self.out_ds.fRasterXOrigin = 0 + self.out_ds.fRasterYOrigin = 0 + self.out_ds.PixelSize = self.out_gt[1] + self.out_ds.fPixelSize = self.fPixelSize + # print("ominx", self.ominx, "omaxx", self.omaxx, "ominy", self.ominy, "omaxy", self.omaxy) + # print("fminx", self.fminx, "fmaxx", self.fmaxx, "fminy", self.fminy, "fmaxy", self.fmaxy) + if self.isRasterBounded: + self.out_ds.fRasterXSize = int(math.floor(self.out_ds.RasterXSize * (self.fmaxx - self.fminx) / ( + self.omaxx - self.ominx) * (self.out_ds.PixelSize / self.out_ds.fPixelSize))) + self.out_ds.fRasterYSize = int(math.ceil(self.out_ds.RasterYSize * (self.fmaxy - self.fminy) / ( + self.omaxy - self.ominy) * (self.out_ds.PixelSize / self.out_ds.fPixelSize))) + self.out_ds.fRasterXSizeRaw = int(math.floor( + self.out_ds.RasterXSize * (self.fmaxx - self.fminx) / (self.omaxx - self.ominx))) + self.out_ds.fRasterYSizeRaw = int(math.ceil( + self.out_ds.RasterYSize * (self.fmaxy - self.fminy) / (self.omaxy - self.ominy))) + # print("Full Raster Size: ", self.out_ds.fRasterXSize, self.out_ds.fRasterYSize ) + self.out_ds.fRasterXOrigin = int(math.floor(linearScale( + [self.fminx, self.fmaxx], [0, self.out_ds.fRasterXSize], self.out_gt[0]))) + self.out_ds.fRasterYOrigin = int(math.ceil(linearScale( + [self.fminy, self.fmaxy], [self.out_ds.fRasterYSize, 0], self.out_gt[3]))) + self.out_ds.fRasterXOriginRaw = int(math.floor(linearScale([self.fminx, self.fmaxx], [ + 0, self.out_ds.fRasterXSize], self.out_gt[0]) * (self.out_ds.fPixelSize / self.out_ds.PixelSize))) + self.out_ds.fRasterYOriginRaw = int(math.ceil(linearScale([self.fminy, self.fmaxy], [ + self.out_ds.fRasterYSize, 0], self.out_gt[3]) * (self.out_ds.fPixelSize / self.out_ds.PixelSize))) + self.out_ds.fRasterXWidth = int(math.floor(linearScale( + [self.fminx, self.fmaxx], [0, self.out_ds.fRasterXSize], self.omaxx))) - self.out_ds.fRasterXOrigin + self.out_ds.fRasterYHeight = int(math.ceil(linearScale( + [self.fminy, self.fmaxy], [0, self.out_ds.fRasterYSize], self.omaxy))) - self.out_ds.fRasterYOrigin + + if self.options.verbose: + print("Bounds (output srs):", round(self.ominx, 13), + self.ominy, self.omaxx, self.omaxy) + + # print("Input Raster Size: ", self.out_ds.RasterXSize, self.out_ds.RasterYSize) + # print("fmaxx-fminx", self.fmaxx - self.fminx, "omaxx-ominx", self.omaxx - self.ominx, "fmaxy-fminy", self.fmaxy - self.fminy, "omaxy-ominy", self.omaxy - self.ominy) + # print("Full Raster Size: ", self.out_ds.fRasterXSize, self.out_ds.fRasterYSize) + # print("Full Raster Size Raw: ", self.out_ds.fRasterXSizeRaw, self.out_ds.fRasterYSizeRaw) + # print("Raster Origin: ", self.out_ds.fRasterXOrigin, self.out_ds.fRasterYOrigin) + # print("Raster Origin Raw: ", self.out_ds.fRasterXOriginRaw, self.out_ds.fRasterYOriginRaw) + # print("Raster Width Height: ", self.out_ds.fRasterXWidth, self.out_ds.fRasterYHeight) + + # Calculating ranges for tiles in different zoom levels + if self.options.profile == 'mercator': + + self.mercator = GlobalMercator() + + # Function which generates SWNE in LatLong for given tile + self.tileswne = self.mercator.TileLatLonBounds + + # Generate table with min max tile coordinates for all zoomlevels + self.tminmax = list(range(0, 32)) + for tz in range(0, 32): + tminx, tminy = self.mercator.MetersToTile( + self.ominx, self.ominy, tz) + tmaxx, tmaxy = self.mercator.MetersToTile( + self.omaxx, self.omaxy, tz) + # crop tiles extending world limits (+-180,+-90) + tminx, tminy = max(0, tminx), max(0, tminy) + tmaxx, tmaxy = min(2**tz-1, tmaxx), min(2**tz-1, tmaxy) + self.tminmax[tz] = (tminx, tminy, tmaxx, tmaxy) + + # TODO: Maps crossing 180E (Alaska?) + + # Get the minimal zoom level (map covers area equivalent to one tile) + if self.tminz is None: + self.tminz = self.mercator.ZoomForPixelSize( + self.out_gt[1] * max(self.out_ds.RasterXSize, + self.out_ds.RasterYSize) / float(self.tilesize)) + + # Get the maximal zoom level + # (closest possible zoom level up on the resolution of raster) + if self.tmaxz is None: + self.tmaxz = self.mercator.ZoomForPixelSize(self.out_gt[1]) + + if self.options.verbose: + print("Bounds (latlong):", + self.mercator.MetersToLatLon(self.ominx, self.ominy), + self.mercator.MetersToLatLon(self.omaxx, self.omaxy)) + print('MinZoomLevel:', self.tminz) + print("MaxZoomLevel:", + self.tmaxz, + "(", + self.mercator.Resolution(self.tmaxz), + ")") + + if self.options.profile == 'geodetic': + + self.geodetic = GlobalGeodetic(self.options.tmscompatible) + + # Function which generates SWNE in LatLong for given tile + self.tileswne = self.geodetic.TileLatLonBounds + + # Generate table with min max tile coordinates for all zoomlevels + self.tminmax = list(range(0, 32)) + for tz in range(0, 32): + tminx, tminy = self.geodetic.LonLatToTile( + self.ominx, self.ominy, tz) + tmaxx, tmaxy = self.geodetic.LonLatToTile( + self.omaxx, self.omaxy, tz) + # crop tiles extending world limits (+-180,+-90) + tminx, tminy = max(0, tminx), max(0, tminy) + tmaxx, tmaxy = min(2**(tz+1)-1, tmaxx), min(2**tz-1, tmaxy) + self.tminmax[tz] = (tminx, tminy, tmaxx, tmaxy) + + # TODO: Maps crossing 180E (Alaska?) + + # Get the maximal zoom level + # (closest possible zoom level up on the resolution of raster) + if self.tminz is None: + self.tminz = self.geodetic.ZoomForPixelSize( + self.out_gt[1] * max(self.out_ds.RasterXSize, + self.out_ds.RasterYSize) / float(self.tilesize)) + + # Get the maximal zoom level + # (closest possible zoom level up on the resolution of raster) + if self.tmaxz is None: + self.tmaxz = self.geodetic.ZoomForPixelSize(self.out_gt[1]) + + if self.options.verbose: + print("Bounds (latlong):", self.ominx, + self.ominy, self.omaxx, self.omaxy) + + # MMGIS + if self.options.profile == 'raster' and self.isRasterBounded: + + def log2(x): + return math.log10(x) / math.log10(2) + + # MMGIS added 'f'* + self.nativezoom = int( + max(math.ceil(log2(self.out_ds.fRasterXSizeRaw/float(self.tilesize))), + math.ceil(log2(self.out_ds.fRasterYSizeRaw/float(self.tilesize))))) + + self.basenativezoom = int( + max(math.ceil(log2(self.out_ds.fRasterXSize/float(self.tilesize))), + math.ceil(log2(self.out_ds.fRasterYSize/float(self.tilesize))))) + + # MMGIS + self.out_ds.fWorldXSize = int( + float(self.out_ds.fRasterXSize) * (2**(self.nativezoom - self.basenativezoom))) + self.out_ds.fWorldYSize = int( + float(self.out_ds.fRasterYSize) * (2**(self.nativezoom - self.basenativezoom))) + self.out_ds.fRasterXOriginWorld = int(float( + self.out_ds.fWorldXSize) * (float(self.out_ds.fRasterXOrigin) / self.out_ds.fRasterXSize)) + self.out_ds.fRasterYOriginWorld = int(float( + self.out_ds.fWorldYSize) * (float(self.out_ds.fRasterYOrigin) / self.out_ds.fRasterYSize)) + self.out_ds.fRasterXSizeWorld = int(float( + self.out_ds.fWorldXSize) * (float(self.out_ds.fRasterXWidth) / self.out_ds.fRasterXSize)) + self.out_ds.fRasterYSizeWorld = int(float( + self.out_ds.RasterYSize) * (float(self.out_ds.fRasterXSizeWorld) / self.out_ds.RasterXSize)) + # print("World Size", self.out_ds.fWorldXSize, self.out_ds.fWorldYSize) + # print("Raster Origin World", self.out_ds.fRasterXOriginWorld, self.out_ds.fRasterYOriginWorld) + # print("Raster Size World", self.out_ds.fRasterXSizeWorld, self.out_ds.fRasterYSizeWorld) + + if self.options.verbose: + print("Native zoom of the raster:", self.nativezoom) + + # Get the minimal zoom level (whole raster in one tile) + if self.tminz is None: + self.tminz = 0 + + # Get the maximal zoom level (native resolution of the raster) + if self.tmaxz is None: + self.tmaxz = self.nativezoom + + # MMGIS added 'f'* + # Generate table with min max tile coordinates for all zoomlevels + self.tminmax = list(range(0, self.tmaxz+1)) + self.tsize = list(range(0, self.tmaxz+1)) + # print("Raster Size:", self.out_ds.RasterXSize,self.out_ds.RasterYSize) + # print("Pixel Size Ratio:", (self.out_ds.fPixelSize / self.out_ds.PixelSize)) + # print("nativezoom", self.nativezoom, "basenativezoom", self.basenativezoom, "tminz", self.tminz, "tmaxz", self.tmaxz) + for tz in range(0, self.tmaxz+1): + tsize = 2.0**(self.tmaxz-tz)*self.tilesize + toffsetx = int(math.floor( + 2.0**(tz) * self.out_ds.fRasterXOriginRaw / self.out_ds.fRasterXSizeRaw)) + toffsety = int(math.floor( + 2.0**(tz) * (self.out_ds.fRasterYOriginRaw) / self.out_ds.fRasterYSizeRaw)) + # print("tsize", tsize, "toffsetx", toffsetx, "toffsety", toffsety) + toffsetx = int(math.floor( + self.out_ds.fRasterXOriginWorld / tsize)) + toffsety = int(math.floor( + self.out_ds.fRasterYOriginWorld / tsize)) + # print("tsize", tsize, "toffsetx", toffsetx, "toffsety", toffsety) + tmaxx = int(math.floor( + self.out_ds.fRasterXSizeWorld / tsize)) + toffsetx + 1 + + tmaxy = int(math.floor( + self.out_ds.fRasterYSizeWorld / tsize)) + toffsety + 1 + self.tsize[tz] = math.ceil(tsize) + #tminx = toffsetx + tminx = int(tmaxx - ((tmaxx - toffsetx) / (0.75))) - 1 + tminy = int(tmaxy - ((tmaxy - toffsety) / (0.75))) - 1 + + self.tminmax[tz] = (tminx, tminy, tmaxx, tmaxy) + # print("tminx", tminx, "tminy", tminy, "tmaxx", tmaxx, "tmaxy", tmaxy, "tz", tz) + + elif self.options.profile == 'raster': + + def log2(x): + return math.log10(x) / math.log10(2) + self.nativezoom = int( + max(math.ceil(log2(self.out_ds.RasterXSize/float(self.tilesize))), + math.ceil(log2(self.out_ds.RasterYSize/float(self.tilesize))))) + + if self.options.verbose: + print("Native zoom of the raster:", self.nativezoom) + + # Get the minimal zoom level (whole raster in one tile) + if self.tminz is None: + self.tminz = 0 + + # Get the maximal zoom level (native resolution of the raster) + if self.tmaxz is None: + self.tmaxz = self.nativezoom + + # Generate table with min max tile coordinates for all zoomlevels + self.tminmax = list(range(0, self.tmaxz+1)) + self.tsize = list(range(0, self.tmaxz+1)) + for tz in range(0, self.tmaxz+1): + tsize = 2.0**(self.tmaxz-tz)*self.tilesize + tminx, tminy = 0, 0 + tmaxx = int(math.ceil(self.out_ds.RasterXSize / tsize)) - 1 + tmaxy = int(math.ceil(self.out_ds.RasterYSize / tsize)) - 1 + self.tsize[tz] = math.ceil(tsize) + self.tminmax[tz] = (tminx, tminy, tmaxx, tmaxy) + + # Function which generates SWNE in LatLong for given tile + if self.kml and in_srs_wkt: + ct = osr.CoordinateTransformation(in_srs, srs4326) + + def rastertileswne(x, y, z): + # X-pixel size in level + pixelsizex = (2**(self.tmaxz-z) * self.out_gt[1]) + west = self.out_gt[0] + x*self.tilesize*pixelsizex + east = west + self.tilesize*pixelsizex + south = self.ominy + y*self.tilesize*pixelsizex + north = south + self.tilesize*pixelsizex + if not isepsg4326: + # Transformation to EPSG:4326 (WGS84 datum) + west, south = ct.TransformPoint(west, south)[:2] + east, north = ct.TransformPoint(east, north)[:2] + return south, west, north, east + + self.tileswne = rastertileswne + else: + self.tileswne = lambda x, y, z: (0, 0, 0, 0) # noqa + + def generate_metadata(self): + """ + Generation of main metadata files and HTML viewers (metadata related to particular + tiles are generated during the tile processing). + """ + + if not os.path.exists(self.output): + os.makedirs(self.output) + + if self.options.profile == 'mercator': + + south, west = self.mercator.MetersToLatLon(self.ominx, self.ominy) + north, east = self.mercator.MetersToLatLon(self.omaxx, self.omaxy) + south, west = max(-85.05112878, south), max(-180.0, west) + north, east = min(85.05112878, north), min(180.0, east) + self.swne = (south, west, north, east) + + # Generate googlemaps.html + if self.options.webviewer in ('all', 'google') and self.options.profile == 'mercator': + if (not self.options.resume or not + os.path.exists(os.path.join(self.output, 'googlemaps.html'))): + f = open(os.path.join(self.output, 'googlemaps.html'), 'wb') + f.write(self.generate_googlemaps().encode('utf-8')) + f.close() + + # Generate openlayers.html + if self.options.webviewer in ('all', 'openlayers'): + if (not self.options.resume or not + os.path.exists(os.path.join(self.output, 'openlayers.html'))): + f = open(os.path.join(self.output, 'openlayers.html'), 'wb') + f.write(self.generate_openlayers().encode('utf-8')) + f.close() + + # Generate leaflet.html + if self.options.webviewer in ('all', 'leaflet'): + if (not self.options.resume or not + os.path.exists(os.path.join(self.output, 'leaflet.html'))): + f = open(os.path.join(self.output, 'leaflet.html'), 'wb') + f.write(self.generate_leaflet().encode('utf-8')) + f.close() + + elif self.options.profile == 'geodetic': + + west, south = self.ominx, self.ominy + east, north = self.omaxx, self.omaxy + south, west = max(-90.0, south), max(-180.0, west) + north, east = min(90.0, north), min(180.0, east) + self.swne = (south, west, north, east) + + # Generate openlayers.html + if self.options.webviewer in ('all', 'openlayers'): + if (not self.options.resume or not + os.path.exists(os.path.join(self.output, 'openlayers.html'))): + f = open(os.path.join(self.output, 'openlayers.html'), 'wb') + f.write(self.generate_openlayers().encode('utf-8')) + f.close() + + elif self.options.profile == 'raster': + + west, south = self.ominx, self.ominy + east, north = self.omaxx, self.omaxy + + # MMGIS + if self.isRasterBounded: + west = self.fminx + east = self.fmaxx + south = self.fminy + north = self.fmaxy + + self.swne = (south, west, north, east) + + # Generate openlayers.html + if self.options.webviewer in ('all', 'openlayers'): + if (not self.options.resume or not + os.path.exists(os.path.join(self.output, 'openlayers.html'))): + f = open(os.path.join(self.output, 'openlayers.html'), 'wb') + f.write(self.generate_openlayers().encode('utf-8')) + f.close() + + # Generate tilemapresource.xml. + if not self.options.resume or not os.path.exists(os.path.join(self.output, 'tilemapresource.xml')): + f = open(os.path.join(self.output, 'tilemapresource.xml'), 'wb') + f.write(self.generate_tilemapresource().encode('utf-8')) + f.close() + + if self.kml: + # TODO: Maybe problem for not automatically generated tminz + # The root KML should contain links to all tiles in the tminz level + children = [] + xmin, ymin, xmax, ymax = self.tminmax[self.tminz] + for x in range(xmin, xmax+1): + for y in range(ymin, ymax+1): + children.append([x, y, self.tminz]) + # Generate Root KML + if self.kml: + if (not self.options.resume or not + os.path.exists(os.path.join(self.output, 'doc.kml'))): + f = open(os.path.join(self.output, 'doc.kml'), 'wb') + f.write(self.generate_kml( + None, None, None, children).encode('utf-8')) + f.close() + + def generate_base_tiles(self, tz): + """ + Generation of the base tiles (the lowest in the pyramid) directly from the input raster + """ + + if self.isDEMtile: + print("Generating Tiles at Zoom " + str(tz) + ": ") + + if not self.options.quiet: + print("Generating Base Tiles:") + + if self.options.verbose: + print('') + print("Tiles generated from the max zoom level:") + print("----------------------------------------") + print('') + + ds = self.out_ds + + querysize = self.querysize + + # 1bto4b + if self.isDEMtile: + tilebands = 4 + querysize = self.tilesize + else: + tilebands = self.dataBandsCount + 1 + tz = self.tmaxz + + try: + self.tminmax[tz] + except IndexError: + print(" Won't make zoom level " + str(tz)) + return + + # Set the bounds + tminx, tminy, tmaxx, tmaxy = self.tminmax[tz] + + if self.options.verbose: + print("dataBandsCount: ", self.dataBandsCount) + print("tilebands: ", tilebands) + + tcount = (1+abs(tmaxx-tminx)) * (1+abs(tmaxy-tminy)) + ti = 0 + + for ty in range(tmaxy, tminy-1, -1): + for tx in range(tminx, tmaxx+1): + + if self.stopped: + break + ti += 1 + tilefilename = os.path.join( + self.output, str(tz), str(tx), "%s.%s" % (ty, self.tileext)) + if self.options.verbose: + print(ti, '/', tcount, tilefilename) + + if self.options.resume and os.path.exists(tilefilename): + if self.options.verbose: + print("Tile generation skipped because of --resume") + else: + self.progressbar(ti / float(tcount)) + continue + + # Create directories for the tile + if not os.path.exists(os.path.dirname(tilefilename)): + os.makedirs(os.path.dirname(tilefilename)) + + if self.options.profile == 'mercator': + # Tile bounds in EPSG:3857 + b = self.mercator.TileBounds(tx, ty, tz) + elif self.options.profile == 'geodetic': + b = self.geodetic.TileBounds(tx, ty, tz) + + # Don't scale up by nearest neighbour, better change the querysize + # to the native resolution (and return smaller query tile) for scaling + + if self.options.profile in ('mercator', 'geodetic'): + rb, wb = self.geo_query(ds, b[0], b[3], b[2], b[1]) + + # Pixel size in the raster covering query geo extent + nativesize = wb[0] + wb[2] + if self.options.verbose: + print("\tNative Extent (querysize", + nativesize, "): ", rb, wb) + + # Tile bounds in raster coordinates for ReadRaster query + rb, wb = self.geo_query( + ds, b[0], b[3], b[2], b[1], querysize=querysize) + + rx, ry, rxsize, rysize = rb + wx, wy, wxsize, wysize = wb + wxsize -= 1 # 1bto4b + wysize -= 1 # 1bto4b + + # MMGIS + elif self.isRasterBounded: # 'raster' profile: + + # tilesize in raster coordinates for actual zoom + tsize = int(self.tsize[tz]) + xsize = self.out_ds.fWorldXSize + ysize = self.out_ds.fWorldYSize + if tz >= self.tmaxz: + querysize = self.tilesize + + rx = (tx) * tsize - self.out_ds.fRasterXOriginWorld + #print("rx", rx) + rxsize = 0 + rxsize = tsize + + rysize = 0 + rysize = tsize + + ry = ysize - (ty * tsize) - rysize - \ + self.out_ds.fRasterYOriginWorld + + wx, wy = 0, 0 + wxsize = int(rxsize/float(tsize) * self.tilesize) + wysize = int(rysize/float(tsize) * self.tilesize) + if wysize != self.tilesize: + wy = self.tilesize - wysize + + if rx < 0: + rxsize = tsize + rx + wx = -rx + wxsize = int(rxsize/float(tsize) * self.tilesize) + rx = 0 + if ry < 0: + rysize = tsize + ry + wy = -ry + wysize = int(rysize/float(tsize) * self.tilesize) + ry = 0 + if rx + rxsize > self.out_ds.fRasterXSizeWorld: + rxsize = self.out_ds.fRasterXSizeWorld - rx + wxsize = int(rxsize/float(tsize) * self.tilesize) + if ry + rysize > self.out_ds.fRasterYSizeWorld: + rysize = self.out_ds.fRasterYSizeWorld - ry + wysize = int(rysize/float(tsize) * self.tilesize) + + # Convert rx, ry back to non-world coordinates + rx = int(float(self.out_ds.RasterXSize) * + (float(rx) / self.out_ds.fRasterXSizeWorld)) + ry = int(float(self.out_ds.RasterYSize) * + (float(ry) / self.out_ds.fRasterYSizeWorld)) + rxsize = int(float(self.out_ds.RasterXSize) * + (float(rxsize) / self.out_ds.fRasterXSizeWorld)) + rysize = int(float(self.out_ds.RasterYSize) * + (float(rysize) / self.out_ds.fRasterYSizeWorld)) + + wxsize -= 1 # 1bto4b + wysize -= 1 # 1bto4b + + #print("Extent: ", (tx, ty, tz, tsize), (rx, ry, rxsize, rysize), (wx, wy, wxsize, wysize), (self.out_ds.fRasterXOrigin, self.out_ds.fRasterYOrigin)) + else: # 'raster' profile: + # tilesize in raster coordinates for actual zoom + tsize = int(self.tsize[tz]) + xsize = self.out_ds.RasterXSize # size of the raster in pixels + ysize = self.out_ds.RasterYSize + if tz >= self.tmaxz: + querysize = self.tilesize + + rx = (tx) * tsize + rxsize = 0 + if tx == tmaxx: + rxsize = xsize % tsize + if rxsize == 0: + rxsize = tsize + + rysize = 0 + if ty == tmaxy: + rysize = ysize % tsize + if rysize == 0: + rysize = tsize + ry = ysize - (ty * tsize) - rysize + + wx, wy = 0, 0 + wxsize = int(rxsize/float(tsize) * self.tilesize) + wysize = int(rysize/float(tsize) * self.tilesize) + if wysize != self.tilesize: + wy = self.tilesize - wysize + + if self.options.verbose: + print("\tReadRaster Extent: ", + (rx, ry, rxsize, rysize), (wx, wy, wxsize, wysize)) + + # Query is in 'nearest neighbour' but can be bigger in then the tilesize + # We scale down the query to the tilesize by supplied algorithm. + + # Tile dataset in memory + + # 1bto4b + if self.isDEMtile: + dstile = self.mem_drv.Create( + '', self.tilesize, self.tilesize, tilebands, gdal.GDT_Byte) + else: + dstile = self.mem_drv.Create( + '', self.tilesize, self.tilesize, tilebands) + + data = alpha = None + # Read the source raster if anything is going inside the tile as per the computed + # geo_query + if rxsize != 0 and rysize != 0 and wxsize != 0 and wysize != 0: + # 1bto4b + if self.isDEMtile: + data = ds.GetRasterBand(1).ReadRaster( + rx, ry, rxsize, rysize, wxsize, wysize, buf_type=gdal.GDT_Float32) + else: + data = ds.ReadRaster(rx, ry, rxsize, rysize, wxsize, wysize, + band_list=list(range(1, self.dataBandsCount+1))) + alpha = self.alphaband.ReadRaster( + rx, ry, rxsize, rysize, wxsize, wysize) + + # The tile in memory is a transparent file by default. Write pixel values into it if + # any + if data: + # 1bto4b - both this full if and else + if self.isDEMtile: + if (wxsize * wysize) > 0: + data = struct.unpack('f' * wxsize * wysize, data) + else: + return + + if self.tilesize == querysize: + # Interpolate the values from four surrounding + + # This takes our 1d list of WxH data and pads it with a rect of none values + dataPad = list(data) + for i in reversed(range(1, wysize)): + dataPad.insert(wxsize * i, 0) + dataPad.insert(wxsize * i, 0) + for i in range(wxsize + 3): + dataPad.insert(0, 0) + for i in range(wxsize + 3): + dataPad.append(0) + + dataIn = [] + # Resample based on average of four + # averaging over: i, i + 1, i + wxsize, i + wxsize + 1 + for y in range(wysize+2 - 1): + for x in range(wxsize+2 - 1): + i = x+(y*(wxsize+2)) + nW = dataPad[i] + nE = dataPad[i+1] + sW = dataPad[i+(wxsize+2)] + sE = dataPad[i+(wxsize+2)+1] + dataIn.append((nW + nE + sW + sE)/float(4)) + + # Get the surrounding eight tiles + # Get NW + if tx - 1 >= tminx and ty + 1 <= tmaxy: + rxNW, ryNW, rxsizeNW, rysizeNW, wxsizeNW, wysizeNW = getTilePxBounds(self, + tx - 1, ty + 1, tz, ds) + wxsizeNW -= 1 + wysizeNW -= 1 + if wxsizeNW != 0 and wysizeNW != 0: + dataNW = ds.GetRasterBand(1).ReadRaster( + rxNW, ryNW, rxsizeNW, rysizeNW, wxsizeNW, wysizeNW, buf_type=gdal.GDT_Float32) + if dataNW is not None and (wxsizeNW * wysizeNW) > 0: + dataNW = struct.unpack( + 'f' * wxsizeNW * wysizeNW, dataNW) + else: + dataNW = None + else: + dataNW = None + + # Get N + if ty + 1 <= tmaxy: + rxN, ryN, rxsizeN, rysizeN, wxsizeN, wysizeN = getTilePxBounds( + self, tx, ty + 1, tz, ds) + wxsizeN -= 1 + wysizeN -= 1 + if wxsizeN != 0 and wysizeN != 0: + dataN = ds.GetRasterBand(1).ReadRaster( + rxN, ryN, rxsizeN, rysizeN, wxsizeN, wysizeN, buf_type=gdal.GDT_Float32) + if dataN is not None and (wxsizeN * wysizeN) > 0: + dataN = struct.unpack( + 'f' * wxsizeN * wysizeN, dataN) + else: + dataN = None + else: + dataN = None + # Get NE + if tx + 1 <= tmaxx and ty + 1 <= tmaxy: + rxNE, ryNE, rxsizeNE, rysizeNE, wxsizeNE, wysizeNE = getTilePxBounds( + self, tx + 1, ty + 1, tz, ds) + wxsizeNE -= 1 + wysizeNE -= 1 + if wxsizeNE != 0 and wysizeNE != 0: + dataNE = ds.GetRasterBand(1).ReadRaster( + rxNE, ryNE, rxsizeNE, rysizeNE, wxsizeNE, wysizeNE, buf_type=gdal.GDT_Float32) + if dataNE is not None and (wxsizeNE * wysizeNE) > 0: + dataNE = struct.unpack( + 'f' * wxsizeNE * wysizeNE, dataNE) + else: + dataNE = None + else: + dataNE = None + # Get E + if tx + 1 <= tmaxx: + rxE, ryE, rxsizeE, rysizeE, wxsizeE, wysizeE = getTilePxBounds( + self, tx + 1, ty, tz, ds) + wxsizeE -= 1 + wysizeE -= 1 + if wxsizeE != 0 and wysizeE != 0: + dataE = ds.GetRasterBand(1).ReadRaster( + rxE, ryE, rxsizeE, rysizeE, wxsizeE, wysizeE, buf_type=gdal.GDT_Float32) + if dataE is not None and (wxsizeE * wysizeE) > 0: + dataE = struct.unpack( + 'f' * wxsizeE * wysizeE, dataE) + else: + dataE = None + else: + dataE = None + # Get SE + if tx + 1 <= tmaxx and ty - 1 >= tminy: + rxSE, rySE, rxsizeSE, rysizeSE, wxsizeSE, wysizeSE = getTilePxBounds( + self, tx + 1, ty - 1, tz, ds) + wxsizeSE -= 1 + wysizeSE -= 1 + if wxsizeSE != 0 and wysizeSE != 0: + dataSE = ds.GetRasterBand(1).ReadRaster( + rxSE, rySE, rxsizeSE, rysizeSE, wxsizeSE, wysizeSE, buf_type=gdal.GDT_Float32) + if dataSE is not None and (wxsizeSE * wysizeSE) > 0: + dataSE = struct.unpack( + 'f' * wxsizeSE * wysizeSE, dataSE) + else: + dataSE = None + else: + dataSE = None + # Get S + if ty - 1 >= tminy: + rxS, ryS, rxsizeS, rysizeS, wxsizeS, wysizeS = getTilePxBounds( + self, tx, ty - 1, tz, ds) + wxsizeS -= 1 + wysizeS -= 1 + if wxsizeS != 0 and wysizeS != 0: + dataS = ds.GetRasterBand(1).ReadRaster( + rxS, ryS, rxsizeS, rysizeS, wxsizeS, wysizeS, buf_type=gdal.GDT_Float32) + if dataS is not None and (wxsizeS * wysizeS) > 0: + dataS = struct.unpack( + 'f' * wxsizeS * wysizeS, dataS) + else: + dataS = None + else: + dataS = None + # Get SW + if tx - 1 >= tminx and ty - 1 >= tminy: + rxSW, rySW, rxsizeSW, rysizeSW, wxsizeSW, wysizeSW = getTilePxBounds( + self, tx - 1, ty - 1, tz, ds) + wxsizeSW -= 1 + wysizeSW -= 1 + if wxsizeSW != 0 and wysizeSW != 0: + dataSW = ds.GetRasterBand(1).ReadRaster( + rxSW, rySW, rxsizeSW, rysizeSW, wxsizeSW, wysizeSW, buf_type=gdal.GDT_Float32) + if dataSW is not None and (wxsizeSW * wysizeSW) > 0: + dataSW = struct.unpack( + 'f' * wxsizeSW * wysizeSW, dataSW) + else: + dataSW = None + else: + dataSW = None + # Get W + if tx - 1 >= tminx: + rxW, ryW, rxsizeW, rysizeW, wxsizeW, wysizeW = getTilePxBounds( + self, tx - 1, ty, tz, ds) + wxsizeW -= 1 + wysizeW -= 1 + if wxsizeW != 0 and wysizeW != 0: + dataW = ds.GetRasterBand(1).ReadRaster( + rxW, ryW, rxsizeW, rysizeW, wxsizeW, wysizeW, buf_type=gdal.GDT_Float32) + if dataW is not None and (wxsizeW * wysizeW) > 0: + dataW = struct.unpack( + 'f' * wxsizeW * wysizeW, dataW) + else: + dataW = None + else: + dataW = None + + # NW (uses N, NW, W) + fN = fNE = fE = fSE = fS = fSW = fW = fNW = 0 + values = 1 + if dataN is not None: + fN = dataN[len(dataN)-wxsizeN] + values = values + 1 + if dataNW is not None: + fNW = dataNW[len(dataNW)-1] + values = values + 1 + if dataW is not None: + fW = dataW[wxsizeW-1] + values = values + 1 + dataIn[0] = ((dataIn[0]*4) + fN + + fNW + fW)/float(values) + + # NE (uses N, NE, E) + fN = fNE = fE = fSE = fS = fSW = fW = fNW = 0 + values = 1 + if dataN is not None: + fN = dataN[len(dataN)-1] + values = values + 1 + if dataNE is not None: + fNE = dataNE[len(dataNE)-wxsizeNE] + values = values + 1 + if dataE is not None: + fE = dataE[0] + values = values + 1 + dataIn[wxsize] = ( + (dataIn[wxsize]*4) + fN + fNE + fE)/float(values) + + # SE (uses S, SE, E) + fN = fNE = fE = fSE = fS = fSW = fW = fNW = 0 + values = 1 + if dataS is not None: + fS = dataS[wxsizeS-1] + values = values + 1 + if dataSE is not None: + fSE = dataSE[0] + values = values + 1 + if dataE is not None: + fE = dataE[len(dataE)-wxsizeE] + values = values + 1 + dataIn[len(dataIn)-1] = ((dataIn[len(dataIn)-1] + * 4) + fS + fSE + fE)/float(values) + + # SW (uses S, SW, W) + fN = fNE = fE = fSE = fS = fSW = fW = fNW = 0 + values = 1 + if dataS is not None: + fS = dataS[0] + values = values + 1 + if dataSW is not None: + fSW = dataSW[wxsizeSW-1] + values = values + 1 + if dataW is not None: + fW = dataW[len(dataW)-1] + values = values + 1 + dataIn[len( + dataIn)-wxsize-1] = ((dataIn[len(dataIn)-wxsize-1]*4) + fS + fSW + fW)/float(values) + + # Then the edges minus corners + # N + if dataN is not None: + for i in range(1, wxsize): + dataIn[i] = ( + (dataIn[i]*4) + dataN[len(dataN)-wxsizeN-1+i] + dataN[len(dataN)-wxsizeN-1+i+1])/float(4) + else: + for i in range(1, wxsize): + dataIn[i] = (dataIn[i]*4)/float(2) + + # E + if dataE is not None: + for i in range(1, wysize): + dataIn[((i+1)*(wxsize+1)-1)] = ((dataIn[((i+1)*(wxsize+1)-1)] + * 4) + dataE[(i-1)*wxsizeE] + dataE[i*wxsizeE])/float(4) + else: + for i in range(1, wysize): + dataIn[( + (i+1)*(wxsize+1)-1)] = (dataIn[((i+1)*(wxsize+1)-1)]*4)/float(2) + + # S + if dataS is not None: + for i in range(1, wxsize): + dataIn[len(dataIn)-wxsize-1+i] = ( + (dataIn[len(dataIn)-wxsize-1+i]*4) + dataS[i-1] + dataS[i])/float(4) + else: + for i in range(1, wxsize): + dataIn[len( + dataIn)-wxsize-1+i] = (dataIn[len(dataIn)-wxsize-1+i]*4)/float(2) + + # W + if dataW is not None: + for i in range(1, wysize): + dataIn[(i)*(wxsize+1)] = ((dataIn[(i)*(wxsize+1)]*4) + + dataW[i*wxsizeW-1] + dataW[(i+1)*wxsizeW-1])/float(4) + else: + for i in range(1, wysize): + dataIn[(i)*(wxsize+1)] = (dataIn[(i) + * (wxsize+1)]*4)/float(2) + + data1 = [] + data2 = [] + data3 = [] + data4 = [] + for f in dataIn: + f = str(binary(f)) + data1.append(int(f[:8], 2)) + data2.append(int(f[8:16], 2)) + data3.append(int(f[16:24], 2)) + data4.append(int(f[24:], 2)) + + data1s = b'' + data2s = b'' + data3s = b'' + data4s = b'' + indx = 0 + for v in data1: + data1s += struct.pack('B', data1[indx]) + data2s += struct.pack('B', data2[indx]) + data3s += struct.pack('B', data3[indx]) + data4s += struct.pack('B', data4[indx]) + indx += 1 + dstile.GetRasterBand(1).WriteRaster( + wx, wy, wxsize + 1, wysize + 1, data1s, buf_type=gdal.GDT_Byte) + dstile.GetRasterBand(2).WriteRaster( + wx, wy, wxsize + 1, wysize + 1, data2s, buf_type=gdal.GDT_Byte) + dstile.GetRasterBand(3).WriteRaster( + wx, wy, wxsize + 1, wysize + 1, data3s, buf_type=gdal.GDT_Byte) + dstile.GetRasterBand(4).WriteRaster( + wx, wy, wxsize + 1, wysize + 1, data4s, buf_type=gdal.GDT_Byte) + elif wxsize != 0 and wysize != 0: + # Big ReadRaster query in memory scaled to the tilesize - all but 'near' algo + dsquery = self.mem_drv.Create( + '', querysize, querysize, tilebands, gdal.GDT_Byte) # 1bto4b + # TODO: fill the null value in case a tile without alpha is produced (now only png tiles are supported) + # for i in range(1, tilebands+1): + # dsquery.GetRasterBand(1).Fill(tilenodata) + # dsquery.WriteRaster(wx, wy, wxsize, wysize, data, band_list=list(range(1,self.dataBandsCount+1)))###############1bto4b + # dsquery.WriteRaster(wx, wy, wxsize, wysize, alpha, band_list=[tilebands])###############################1bto4b + + # 1bto4b + data = ds.GetRasterBand(1).ReadRaster( + rx, ry, rxsize, rysize, wxsize, wysize, buf_type=gdal.GDT_Float32) + + data = struct.unpack('f' * wxsize * wysize, data) + data1 = [] + data2 = [] + data3 = [] + data4 = [] + for f in data: + f = str(binary(f)) + data1.append(int(f[:8], 2)) + data2.append(int(f[8:16], 2)) + data3.append(int(f[16:24], 2)) + data4.append(int(f[24:], 2)) + + data1s = b'' + data2s = b'' + data3s = b'' + data4s = b'' + indx = 0 + for v in data1: + data1s += struct.pack('B', data1[indx]) + data2s += struct.pack('B', data2[indx]) + data3s += struct.pack('B', data3[indx]) + data4s += struct.pack('B', data4[indx]) + indx += 1 + + dsquery.GetRasterBand(1).WriteRaster( + wx, wy, wxsize, wysize, data1s, buf_type=gdal.GDT_Byte) + dsquery.GetRasterBand(2).WriteRaster( + wx, wy, wxsize, wysize, data2s, buf_type=gdal.GDT_Byte) + dsquery.GetRasterBand(3).WriteRaster( + wx, wy, wxsize, wysize, data3s, buf_type=gdal.GDT_Byte) + dsquery.GetRasterBand(4).WriteRaster( + wx, wy, wxsize, wysize, data4s, buf_type=gdal.GDT_Byte) + # sys.exit('done') + # 1bto4b + + self.scale_query_to_tile( + dsquery, dstile, tilefilename) + del dsquery + + else: + if self.tilesize == querysize: + # Use the ReadRaster result directly in tiles ('nearest neighbour' query) + dstile.WriteRaster(wx, wy, wxsize, wysize, data, + band_list=list(range(1, self.dataBandsCount+1))) + dstile.WriteRaster( + wx, wy, wxsize, wysize, alpha, band_list=[tilebands]) + + # Note: For source drivers based on WaveLet compression (JPEG2000, ECW, + # MrSID) the ReadRaster function returns high-quality raster (not ugly + # nearest neighbour) + # TODO: Use directly 'near' for WaveLet files + else: + # Big ReadRaster query in memory scaled to the tilesize - all but 'near' + # algo + dsquery = self.mem_drv.Create( + '', querysize, querysize, tilebands) + # TODO: fill the null value in case a tile without alpha is produced (now + # only png tiles are supported) + dsquery.WriteRaster(wx, wy, wxsize, wysize, data, + band_list=list(range(1, self.dataBandsCount+1))) + dsquery.WriteRaster( + wx, wy, wxsize, wysize, alpha, band_list=[tilebands]) + + self.scale_query_to_tile( + dsquery, dstile, tilefilename) + del dsquery + + del data + + if self.options.resampling != 'antialias': + # Write a copy of tile to png/jpg + self.out_drv.CreateCopy(tilefilename, dstile, strict=0) + + del dstile + + # Create a KML file for this tile. + if self.kml: + kmlfilename = os.path.join( + self.output, str(tz), str(tx), '%d.kml' % ty) + if not self.options.resume or not os.path.exists(kmlfilename): + f = open(kmlfilename, 'wb') + f.write(self.generate_kml(tx, ty, tz).encode('utf-8')) + f.close() + + if not self.options.verbose and not self.options.quiet: + self.progressbar(ti / float(tcount)) + + def generate_overview_tiles(self): + """Generation of the overview tiles (higher in the pyramid) based on existing tiles""" + + if not self.options.quiet: + print("Generating Overview Tiles:") + + # 1bto4b + if self.isDEMtile: + tilebands = 4 + else: + tilebands = self.dataBandsCount + 1 + + # Usage of existing tiles: from 4 underlying tiles generate one as overview. + + tcount = 0 + for tz in range(self.tmaxz-1, self.tminz-1, -1): + tminx, tminy, tmaxx, tmaxy = self.tminmax[tz] + tcount += (1+abs(tmaxx-tminx)) * (1+abs(tmaxy-tminy)) + + ti = 0 + + for tz in range(self.tmaxz-1, self.tminz-1, -1): + tminx, tminy, tmaxx, tmaxy = self.tminmax[tz] + for ty in range(tmaxy, tminy-1, -1): + for tx in range(tminx, tmaxx+1): + + if self.stopped: + break + + ti += 1 + tilefilename = os.path.join(self.output, + str(tz), + str(tx), + "%s.%s" % (ty, self.tileext)) + + if self.options.verbose: + print(ti, '/', tcount, tilefilename) + + if self.options.resume and os.path.exists(tilefilename): + if self.options.verbose: + print("Tile generation skipped because of --resume") + else: + self.progressbar(ti / float(tcount)) + continue + + # Create directories for the tile + if not os.path.exists(os.path.dirname(tilefilename)): + os.makedirs(os.path.dirname(tilefilename)) + + dsquery = self.mem_drv.Create( + '', 2*self.tilesize, 2*self.tilesize, tilebands) + # TODO: fill the null value + dstile = self.mem_drv.Create( + '', self.tilesize, self.tilesize, tilebands) + + # TODO: Implement more clever walking on the tiles with cache functionality + # probably walk should start with reading of four tiles from top left corner + # Hilbert curve + + children = [] + # Read the tiles and write them to query window + for y in range(2*ty, 2*ty+2): + for x in range(2*tx, 2*tx+2): + minx, miny, maxx, maxy = self.tminmax[tz+1] + if x >= minx and x <= maxx and y >= miny and y <= maxy: + dsquerytile = gdal.Open( + os.path.join(self.output, str(tz+1), str(x), + "%s.%s" % (y, self.tileext)), + gdal.GA_ReadOnly) + if (ty == 0 and y == 1) or (ty != 0 and (y % (2*ty)) != 0): + tileposy = 0 + else: + tileposy = self.tilesize + if tx: + tileposx = x % (2*tx) * self.tilesize + elif tx == 0 and x == 1: + tileposx = self.tilesize + else: + tileposx = 0 + dsquery.WriteRaster( + tileposx, tileposy, self.tilesize, self.tilesize, + dsquerytile.ReadRaster( + 0, 0, self.tilesize, self.tilesize), + band_list=list(range(1, tilebands+1))) + children.append([x, y, tz+1]) + + self.scale_query_to_tile(dsquery, dstile, tilefilename) + # Write a copy of tile to png/jpg + if self.options.resampling != 'antialias': + # Write a copy of tile to png/jpg + self.out_drv.CreateCopy(tilefilename, dstile, strict=0) + + if self.options.verbose: + print("\tbuild from zoom", tz+1, + " tiles:", (2*tx, 2*ty), (2*tx+1, 2*ty), + (2*tx, 2*ty+1), (2*tx+1, 2*ty+1)) + + # Create a KML file for this tile. + if self.kml: + f = open(os.path.join( + self.output, '%d/%d/%d.kml' % (tz, tx, ty)), 'wb') + f.write(self.generate_kml( + tx, ty, tz, children).encode('utf-8')) + f.close() + + if not self.options.verbose and not self.options.quiet: + self.progressbar(ti / float(tcount)) + + def geo_query(self, ds, ulx, uly, lrx, lry, querysize=0): + """ + For given dataset and query in cartographic coordinates returns parameters for ReadRaster() + in raster coordinates and x/y shifts (for border tiles). If the querysize is not given, the + extent is returned in the native resolution of dataset ds. + + raises Gdal2TilesError if the dataset does not contain anything inside this geo_query + """ + geotran = ds.GetGeoTransform() + rx = int((ulx - geotran[0]) / geotran[1] + 0.001) + ry = int((uly - geotran[3]) / geotran[5] + 0.001) + rxsize = int((lrx - ulx) / geotran[1] + 0.5) + rysize = int((lry - uly) / geotran[5] + 0.5) + + if not querysize: + wxsize, wysize = rxsize, rysize + else: + wxsize, wysize = querysize, querysize + + # Coordinates should not go out of the bounds of the raster + wx = 0 + if rx < 0: + rxshift = abs(rx) + wx = int(wxsize * (float(rxshift) / rxsize)) + wxsize = wxsize - wx + rxsize = rxsize - int(rxsize * (float(rxshift) / rxsize)) + rx = 0 + if rx+rxsize > ds.RasterXSize: + wxsize = int(wxsize * (float(ds.RasterXSize - rx) / rxsize)) + rxsize = ds.RasterXSize - rx + + wy = 0 + if ry < 0: + ryshift = abs(ry) + wy = int(wysize * (float(ryshift) / rysize)) + wysize = wysize - wy + rysize = rysize - int(rysize * (float(ryshift) / rysize)) + ry = 0 + if ry+rysize > ds.RasterYSize: + wysize = int(wysize * (float(ds.RasterYSize - ry) / rysize)) + rysize = ds.RasterYSize - ry + + return (rx, ry, rxsize, rysize), (wx, wy, wxsize, wysize) + + def scale_query_to_tile(self, dsquery, dstile, tilefilename=''): + """Scales down query dataset to the tile dataset""" + + querysize = dsquery.RasterXSize + tilesize = dstile.RasterXSize + tilebands = dstile.RasterCount + + if self.options.resampling == 'average': + + # Function: gdal.RegenerateOverview() + for i in range(1, tilebands+1): + # Black border around NODATA + res = gdal.RegenerateOverview(dsquery.GetRasterBand(i), dstile.GetRasterBand(i), + 'average') + if res != 0: + self.error("RegenerateOverview() failed on %s, error %d" % ( + tilefilename, res)) + + elif self.options.resampling == 'antialias': + + # Scaling by PIL (Python Imaging Library) - improved Lanczos + array = numpy.zeros((querysize, querysize, tilebands), numpy.uint8) + for i in range(tilebands): + array[:, :, i] = gdalarray.BandReadAsArray(dsquery.GetRasterBand(i+1), + 0, 0, querysize, querysize) + im = Image.fromarray(array, 'RGBA') # Always four bands + im1 = im.resize((tilesize, tilesize), Image.ANTIALIAS) + if os.path.exists(tilefilename): + im0 = Image.open(tilefilename) + im1 = Image.composite(im1, im0, im1) + im1.save(tilefilename, self.tiledriver) + + else: + + # Other algorithms are implemented by gdal.ReprojectImage(). + dsquery.SetGeoTransform((0.0, tilesize / float(querysize), 0.0, 0.0, 0.0, + tilesize / float(querysize))) + dstile.SetGeoTransform((0.0, 1.0, 0.0, 0.0, 0.0, 1.0)) + + res = gdal.ReprojectImage( + dsquery, dstile, None, None, self.resampling) + if res != 0: + self.error("ReprojectImage() failed on %s, error %d" % + (tilefilename, res)) + + def generate_tilemapresource(self): + """ + Template for tilemapresource.xml. Returns filled string. Expected variables: + title, north, south, east, west, isepsg4326, projection, publishurl, + zoompixels, tilesize, tileformat, profile + """ + + args = {} + args['title'] = self.options.title + args['south'], args['west'], args['north'], args['east'] = self.swne + args['tilesize'] = self.tilesize + args['tileformat'] = self.tileext + args['publishurl'] = self.options.url + args['profile'] = self.options.profile + + if self.options.profile == 'mercator': + args['srs'] = "EPSG:3857" + elif self.options.profile == 'geodetic': + args['srs'] = "EPSG:4326" + elif self.options.s_srs: + args['srs'] = self.options.s_srs + elif self.out_srs: + args['srs'] = self.out_srs.ExportToWkt() + else: + args['srs'] = "" + + s = """<?xml version="1.0" encoding="utf-8"?> + <TileMap version="1.0.0" tilemapservice="http://tms.osgeo.org/1.0.0"> + <Title>%(title)s</Title> + <Abstract></Abstract> + <SRS>%(srs)s</SRS> + <BoundingBox minx="%(west).14f" miny="%(south).14f" maxx="%(east).14f" maxy="%(north).14f"/> + <Origin x="%(west).14f" y="%(south).14f"/> + <TileFormat width="%(tilesize)d" height="%(tilesize)d" mime-type="image/%(tileformat)s" extension="%(tileformat)s"/> + <TileSets profile="%(profile)s"> +""" % args # noqa + for z in range(self.tminz, self.tmaxz+1): + if self.options.profile == 'raster': + s += """ <TileSet href="%s%d" units-per-pixel="%.14f" order="%d"/>\n""" % ( + args['publishurl'], z, (2**(self.nativezoom-z) * self.out_gt[1]), z) + elif self.options.profile == 'mercator': + s += """ <TileSet href="%s%d" units-per-pixel="%.14f" order="%d"/>\n""" % ( + args['publishurl'], z, 156543.0339/2**z, z) + elif self.options.profile == 'geodetic': + s += """ <TileSet href="%s%d" units-per-pixel="%.14f" order="%d"/>\n""" % ( + args['publishurl'], z, 0.703125/2**z, z) + s += """ </TileSets> + </TileMap> + """ + return s + + def generate_kml(self, tx, ty, tz, children=None, **args): + """ + Template for the KML. Returns filled string. + """ + if not children: + children = [] + + args['tx'], args['ty'], args['tz'] = tx, ty, tz + args['tileformat'] = self.tileext + if 'tilesize' not in args: + args['tilesize'] = self.tilesize + + if 'minlodpixels' not in args: + args['minlodpixels'] = int(args['tilesize'] / 2) + if 'maxlodpixels' not in args: + args['maxlodpixels'] = int(args['tilesize'] * 8) + if children == []: + args['maxlodpixels'] = -1 + + if tx is None: + tilekml = False + args['title'] = self.options.title + else: + tilekml = True + args['title'] = "%d/%d/%d.kml" % (tz, tx, ty) + args['south'], args['west'], args['north'], args['east'] = self.tileswne( + tx, ty, tz) + + if tx == 0: + args['drawOrder'] = 2 * tz + 1 + elif tx is not None: + args['drawOrder'] = 2 * tz + else: + args['drawOrder'] = 0 + + url = self.options.url + if not url: + if tilekml: + url = "../../" + else: + url = "" + + s = """<?xml version="1.0" encoding="utf-8"?> + <kml xmlns="http://www.opengis.net/kml/2.2"> + <Document> + <name>%(title)s</name> + <description></description> + <Style> + <ListStyle id="hideChildren"> + <listItemType>checkHideChildren</listItemType> + </ListStyle> + </Style>""" % args + if tilekml: + s += """ + <Region> + <LatLonAltBox> + <north>%(north).14f</north> + <south>%(south).14f</south> + <east>%(east).14f</east> + <west>%(west).14f</west> + </LatLonAltBox> + <Lod> + <minLodPixels>%(minlodpixels)d</minLodPixels> + <maxLodPixels>%(maxlodpixels)d</maxLodPixels> + </Lod> + </Region> + <GroundOverlay> + <drawOrder>%(drawOrder)d</drawOrder> + <Icon> + <href>%(ty)d.%(tileformat)s</href> + </Icon> + <LatLonBox> + <north>%(north).14f</north> + <south>%(south).14f</south> + <east>%(east).14f</east> + <west>%(west).14f</west> + </LatLonBox> + </GroundOverlay> + """ % args + + for cx, cy, cz in children: + csouth, cwest, cnorth, ceast = self.tileswne(cx, cy, cz) + s += """ + <NetworkLink> + <name>%d/%d/%d.%s</name> + <Region> + <LatLonAltBox> + <north>%.14f</north> + <south>%.14f</south> + <east>%.14f</east> + <west>%.14f</west> + </LatLonAltBox> + <Lod> + <minLodPixels>%d</minLodPixels> + <maxLodPixels>-1</maxLodPixels> + </Lod> + </Region> + <Link> + <href>%s%d/%d/%d.kml</href> + <viewRefreshMode>onRegion</viewRefreshMode> + <viewFormat/> + </Link> + </NetworkLink> + """ % (cz, cx, cy, args['tileformat'], cnorth, csouth, ceast, cwest, + args['minlodpixels'], url, cz, cx, cy) + + s += """ </Document> + </kml> + """ + return s + + def generate_googlemaps(self): + """ + Template for googlemaps.html implementing Overlay of tiles for 'mercator' profile. + It returns filled string. Expected variables: + title, googlemapskey, north, south, east, west, minzoom, maxzoom, tilesize, tileformat, + publishurl + """ + args = {} + args['title'] = self.options.title + args['googlemapskey'] = self.options.googlekey + args['south'], args['west'], args['north'], args['east'] = self.swne + args['minzoom'] = self.tminz + args['maxzoom'] = self.tmaxz + args['tilesize'] = self.tilesize + args['tileformat'] = self.tileext + args['publishurl'] = self.options.url + args['copyright'] = self.options.copyright + + s = r"""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> + <head> + <title>%(title)s</title> + <meta http-equiv="content-type" content="text/html; charset=utf-8"/> + <meta http-equiv='imagetoolbar' content='no'/> + <style type="text/css"> v\:* {behavior:url(#default#VML);} + html, body { overflow: hidden; padding: 0; height: 100%%; width: 100%%; font-family: 'Lucida Grande',Geneva,Arial,Verdana,sans-serif; } + body { margin: 10px; background: #fff; } + h1 { margin: 0; padding: 6px; border:0; font-size: 20pt; } + # header { height: 43px; padding: 0; background-color: #eee; border: 1px solid #888; } + # subheader { height: 12px; text-align: right; font-size: 10px; color: #555;} + # map { height: 95%%; border: 1px solid #888; } + </style> + <script src='http://maps.google.com/maps?file=api&v=2&key=%(googlemapskey)s'></script> + <script> + //<![CDATA[ + + /* + * Constants for given map + * TODO: read it from tilemapresource.xml + */ + + var mapBounds = new GLatLngBounds(new GLatLng(%(south)s, %(west)s), new GLatLng(%(north)s, %(east)s)); + var mapMinZoom = %(minzoom)s; + var mapMaxZoom = %(maxzoom)s; + + var opacity = 0.75; + var map; + var hybridOverlay; + + /* + * Create a Custom Opacity GControl + * http://www.maptiler.org/google-maps-overlay-opacity-control/ + */ + + var CTransparencyLENGTH = 58; + // maximum width that the knob can move (slide width minus knob width) + + function CTransparencyControl( overlay ) { + this.overlay = overlay; + this.opacity = overlay.getTileLayer().getOpacity(); + } + CTransparencyControl.prototype = new GControl(); + + // This function positions the slider to match the specified opacity + CTransparencyControl.prototype.setSlider = function(pos) { + var left = Math.round((CTransparencyLENGTH*pos)); + this.slide.left = left; + this.knob.style.left = left+"px"; + this.knob.style.top = "0px"; + } + + // This function reads the slider and sets the overlay opacity level + CTransparencyControl.prototype.setOpacity = function() { + // set the global variable + opacity = this.slide.left/CTransparencyLENGTH; + this.map.clearOverlays(); + this.map.addOverlay(this.overlay, { zPriority: 0 }); + if (this.map.getCurrentMapType() == G_HYBRID_MAP) { + this.map.addOverlay(hybridOverlay); + } + } + + // This gets called by the API when addControl(new CTransparencyControl()) + CTransparencyControl.prototype.initialize = function(map) { + var that=this; + this.map = map; + + // Is this MSIE, if so we need to use AlphaImageLoader + var agent = navigator.userAgent.toLowerCase(); + if ((agent.indexOf("msie") > -1) && (agent.indexOf("opera") < 1)){this.ie = true} else {this.ie = false} + + // create the background graphic as a <div> containing an image + var container = document.createElement("div"); + container.style.width="70px"; + container.style.height="21px"; + + // Handle transparent PNG files in MSIE + if (this.ie) { + var loader = "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://www.maptiler.org/img/opacity-slider.png', sizingMethod='crop');"; + container.innerHTML = '<div style="height:21px; width:70px; ' +loader+ '" ></div>'; + } else { + container.innerHTML = '<div style="height:21px; width:70px; background-image: url(http://www.maptiler.org/img/opacity-slider.png)" ></div>'; + } + + // create the knob as a GDraggableObject + // Handle transparent PNG files in MSIE + if (this.ie) { + var loader = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://www.maptiler.org/img/opacity-slider.png', sizingMethod='crop');"; + this.knob = document.createElement("div"); + this.knob.style.height="21px"; + this.knob.style.width="13px"; + this.knob.style.overflow="hidden"; + this.knob_img = document.createElement("div"); + this.knob_img.style.height="21px"; + this.knob_img.style.width="83px"; + this.knob_img.style.filter=loader; + this.knob_img.style.position="relative"; + this.knob_img.style.left="-70px"; + this.knob.appendChild(this.knob_img); + } else { + this.knob = document.createElement("div"); + this.knob.style.height="21px"; + this.knob.style.width="13px"; + this.knob.style.backgroundImage="url(http://www.maptiler.org/img/opacity-slider.png)"; + this.knob.style.backgroundPosition="-70px 0px"; + } + container.appendChild(this.knob); + this.slide=new GDraggableObject(this.knob, {container:container}); + this.slide.setDraggableCursor('pointer'); + this.slide.setDraggingCursor('pointer'); + this.container = container; + + // attach the control to the map + map.getContainer().appendChild(container); + + // init slider + this.setSlider(this.opacity); + + // Listen for the slider being moved and set the opacity + GEvent.addListener(this.slide, "dragend", function() {that.setOpacity()}); + //GEvent.addListener(this.container, "click", function( x, y ) { alert(x, y) }); + + return container; + } + + // Set the default position for the control + CTransparencyControl.prototype.getDefaultPosition = function() { + return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 47)); + } + + /* + * Full-screen Window Resize + */ + + function getWindowHeight() { + if (self.innerHeight) return self.innerHeight; + if (document.documentElement && document.documentElement.clientHeight) + return document.documentElement.clientHeight; + if (document.body) return document.body.clientHeight; + return 0; + } + + function getWindowWidth() { + if (self.innerWidth) return self.innerWidth; + if (document.documentElement && document.documentElement.clientWidth) + return document.documentElement.clientWidth; + if (document.body) return document.body.clientWidth; + return 0; + } + + function resize() { + var map = document.getElementById("map"); + var header = document.getElementById("header"); + var subheader = document.getElementById("subheader"); + map.style.height = (getWindowHeight()-80) + "px"; + map.style.width = (getWindowWidth()-20) + "px"; + header.style.width = (getWindowWidth()-20) + "px"; + subheader.style.width = (getWindowWidth()-20) + "px"; + // map.checkResize(); + } + + + /* + * Main load function: + */ + + function load() { + + if (GBrowserIsCompatible()) { + + // Bug in the Google Maps: Copyright for Overlay is not correctly displayed + var gcr = GMapType.prototype.getCopyrights; + GMapType.prototype.getCopyrights = function(bounds,zoom) { + return ["%(copyright)s"].concat(gcr.call(this,bounds,zoom)); + } + + map = new GMap2( document.getElementById("map"), { backgroundColor: '#fff' } ); + + map.addMapType(G_PHYSICAL_MAP); + map.setMapType(G_PHYSICAL_MAP); + + map.setCenter( mapBounds.getCenter(), map.getBoundsZoomLevel( mapBounds )); + + hybridOverlay = new GTileLayerOverlay( G_HYBRID_MAP.getTileLayers()[1] ); + GEvent.addListener(map, "maptypechanged", function() { + if (map.getCurrentMapType() == G_HYBRID_MAP) { + map.addOverlay(hybridOverlay); + } else { + map.removeOverlay(hybridOverlay); + } + } ); + + var tilelayer = new GTileLayer(GCopyrightCollection(''), mapMinZoom, mapMaxZoom); + var mercator = new GMercatorProjection(mapMaxZoom+1); + tilelayer.getTileUrl = function(tile,zoom) { + if ((zoom < mapMinZoom) || (zoom > mapMaxZoom)) { + return "http://www.maptiler.org/img/none.png"; + } + var ymax = 1 << zoom; + var y = ymax - tile.y -1; + var tileBounds = new GLatLngBounds( + mercator.fromPixelToLatLng( new GPoint( (tile.x)*256, (tile.y+1)*256 ) , zoom ), + mercator.fromPixelToLatLng( new GPoint( (tile.x+1)*256, (tile.y)*256 ) , zoom ) + ); + if (mapBounds.intersects(tileBounds)) { + return zoom+"/"+tile.x+"/"+y+".png"; + } else { + return "http://www.maptiler.org/img/none.png"; + } + } + // IE 7-: support for PNG alpha channel + // Unfortunately, the opacity for whole overlay is then not changeable, either or... + tilelayer.isPng = function() { return true;}; + tilelayer.getOpacity = function() { return opacity; } + + overlay = new GTileLayerOverlay( tilelayer ); + map.addOverlay(overlay); + + map.addControl(new GLargeMapControl()); + map.addControl(new GHierarchicalMapTypeControl()); + map.addControl(new CTransparencyControl( overlay )); + """ % args # noqa + if self.kml: + s += """ + map.addMapType(G_SATELLITE_3D_MAP); + map.getEarthInstance(getEarthInstanceCB); + """ + s += """ + + map.enableContinuousZoom(); + map.enableScrollWheelZoom(); + + map.setMapType(G_HYBRID_MAP); + } + resize(); + } + """ + if self.kml: + s += """ + function getEarthInstanceCB(object) { + var ge = object; + + if (ge) { + var url = document.location.toString(); + url = url.substr(0,url.lastIndexOf('/'))+'/doc.kml'; + var link = ge.createLink(""); + if ("%(publishurl)s") { link.setHref("%(publishurl)s/doc.kml") } + else { link.setHref(url) }; + var networkLink = ge.createNetworkLink(""); + networkLink.setName("TMS Map Overlay"); + networkLink.setFlyToView(true); + networkLink.setLink(link); + ge.getFeatures().appendChild(networkLink); + } else { + // alert("You should open a KML in Google Earth"); + // add div with the link to generated KML... - maybe JavaScript redirect to the URL of KML? + } + } + """ % args # noqa + s += """ + onresize=function(){ resize(); }; + + //]]> + </script> + </head> + <body onload="load()"> + <div id="header"><h1>%(title)s</h1></div> + <div id="subheader">Generated by <a href="http://www.klokan.cz/projects/gdal2tiles/">GDAL2Tiles</a>, Copyright © 2008 <a href="http://www.klokan.cz/">Klokan Petr Pridal</a>, <a href="http://www.gdal.org/">GDAL</a> & <a href="http://www.osgeo.org/">OSGeo</a> <a href="http://code.google.com/soc/">GSoC</a> + <!-- PLEASE, LET THIS NOTE ABOUT AUTHOR AND PROJECT SOMEWHERE ON YOUR WEBSITE, OR AT LEAST IN THE COMMENT IN HTML. THANK YOU --> + </div> + <div id="map"></div> + </body> + </html> + """ % args # noqa + + return s + + def generate_leaflet(self): + """ + Template for leaflet.html implementing overlay of tiles for 'mercator' profile. + It returns filled string. Expected variables: + title, north, south, east, west, minzoom, maxzoom, tilesize, tileformat, publishurl + """ + + args = {} + args['title'] = self.options.title.replace('"', '\\"') + args['htmltitle'] = self.options.title + args['south'], args['west'], args['north'], args['east'] = self.swne + args['centerlon'] = (args['north'] + args['south']) / 2. + args['centerlat'] = (args['west'] + args['east']) / 2. + args['minzoom'] = self.tminz + args['maxzoom'] = self.tmaxz + args['beginzoom'] = self.tmaxz + args['tilesize'] = self.tilesize # not used + args['tileformat'] = self.tileext + args['publishurl'] = self.options.url # not used + args['copyright'] = self.options.copyright.replace('"', '\\"') + + s = """<!DOCTYPE html> + <html lang="en"> + <head> + <meta charset="utf-8"> + <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' /> + <title>%(htmltitle)s</title> + + <!-- Leaflet --> + <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.css" /> + <script src="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.js"></script> + + <style> + body { margin:0; padding:0; } + body, table, tr, td, th, div, h1, h2, input { font-family: "Calibri", "Trebuchet MS", "Ubuntu", Serif; font-size: 11pt; } + # map { position:absolute; top:0; bottom:0; width:100%%; } /* full size */ + .ctl { + padding: 2px 10px 2px 10px; + background: white; + background: rgba(255,255,255,0.9); + box-shadow: 0 0 15px rgba(0,0,0,0.2); + border-radius: 5px; + text-align: right; + } + .title { + font-size: 18pt; + font-weight: bold; + } + .src { + font-size: 10pt; + } + + </style> + + </head> + <body> + + <div id="map"></div> + + <script> + /* **** Leaflet **** */ + + // Base layers + // .. OpenStreetMap + var osm = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'}); + + // .. CartoDB Positron + var cartodb = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a href="http://cartodb.com/attributions">CartoDB</a>'}); + + // .. OSM Toner + var toner = L.tileLayer('http://{s}.tile.stamen.com/toner/{z}/{x}/{y}.png', {attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.'}); + + // .. White background + var white = L.tileLayer("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAAA1BMVEX///+nxBvIAAAAH0lEQVQYGe3BAQ0AAADCIPunfg43YAAAAAAAAAAA5wIhAAAB9aK9BAAAAABJRU5ErkJggg=="); + + // Overlay layers (TMS) + var lyr = L.tileLayer('./{z}/{x}/{y}.%(tileformat)s', {tms: true, opacity: 0.7, attribution: "%(copyright)s"}); + + // Map + var map = L.map('map', { + center: [%(centerlon)s, %(centerlat)s], + zoom: %(beginzoom)s, + minZoom: %(minzoom)s, + maxZoom: %(maxzoom)s, + layers: [osm] + }); + + var basemaps = {"OpenStreetMap": osm, "CartoDB Positron": cartodb, "Stamen Toner": toner, "Without background": white} + var overlaymaps = {"Layer": lyr} + + // Title + var title = L.control(); + title.onAdd = function(map) { + this._div = L.DomUtil.create('div', 'ctl title'); + this.update(); + return this._div; + }; + title.update = function(props) { + this._div.innerHTML = "%(title)s"; + }; + title.addTo(map); + + // Note + var src = 'Generated by <a href="http://www.klokan.cz/projects/gdal2tiles/">GDAL2Tiles</a>, Copyright © 2008 <a href="http://www.klokan.cz/">Klokan Petr Pridal</a>, <a href="http://www.gdal.org/">GDAL</a> & <a href="http://www.osgeo.org/">OSGeo</a> <a href="http://code.google.com/soc/">GSoC</a>'; + var title = L.control({position: 'bottomleft'}); + title.onAdd = function(map) { + this._div = L.DomUtil.create('div', 'ctl src'); + this.update(); + return this._div; + }; + title.update = function(props) { + this._div.innerHTML = src; + }; + title.addTo(map); + + + // Add base layers + L.control.layers(basemaps, overlaymaps, {collapsed: false}).addTo(map); + + // Fit to overlay bounds (SW and NE points with (lat, lon)) + map.fitBounds([[%(south)s, %(east)s], [%(north)s, %(west)s]]); + + </script> + + </body> + </html> + + """ % args # noqa + + return s + + def generate_openlayers(self): + """ + Template for openlayers.html implementing overlay of available Spherical Mercator layers. + + It returns filled string. Expected variables: + title, bingkey, north, south, east, west, minzoom, maxzoom, tilesize, tileformat, publishurl + """ + + args = {} + args['title'] = self.options.title + args['bingkey'] = self.options.bingkey + args['south'], args['west'], args['north'], args['east'] = self.swne + args['minzoom'] = self.tminz + args['maxzoom'] = self.tmaxz + args['tilesize'] = self.tilesize + args['tileformat'] = self.tileext + args['publishurl'] = self.options.url + args['copyright'] = self.options.copyright + if self.options.tmscompatible: + args['tmsoffset'] = "-1" + else: + args['tmsoffset'] = "" + if self.options.profile == 'raster': + args['rasterzoomlevels'] = self.tmaxz+1 + args['rastermaxresolution'] = 2**(self.nativezoom) * self.out_gt[1] + + s = r"""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + <html xmlns="http://www.w3.org/1999/xhtml" + <head> + <title>%(title)s</title> + <meta http-equiv='imagetoolbar' content='no'/> + <style type="text/css"> v\:* {behavior:url(#default#VML);} + html, body { overflow: hidden; padding: 0; height: 100%%; width: 100%%; font-family: 'Lucida Grande',Geneva,Arial,Verdana,sans-serif; } + body { margin: 10px; background: #fff; } + h1 { margin: 0; padding: 6px; border:0; font-size: 20pt; } + # header { height: 43px; padding: 0; background-color: #eee; border: 1px solid #888; } + # subheader { height: 12px; text-align: right; font-size: 10px; color: #555;} + # map { height: 95%%; border: 1px solid #888; } + .olImageLoadError { display: none; } + .olControlLayerSwitcher .layersDiv { border-radius: 10px 0 0 10px; } + </style>""" % args # noqa + + if self.options.profile == 'mercator': + s += """ + <script src='http://maps.google.com/maps/api/js?sensor=false&v=3.7'></script> + """ % args + + s += """ + <script src="http://www.openlayers.org/api/2.12/OpenLayers.js"></script> + <script> + var map; + var mapBounds = new OpenLayers.Bounds( %(west)s, %(south)s, %(east)s, %(north)s); + var mapMinZoom = %(minzoom)s; + var mapMaxZoom = %(maxzoom)s; + var emptyTileURL = "http://www.maptiler.org/img/none.png"; + OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3; + + function init(){""" % args + + if self.options.profile == 'mercator': + s += """ + var options = { + div: "map", + controls: [], + projection: "EPSG:3857", + displayProjection: new OpenLayers.Projection("EPSG:4326"), + numZoomLevels: 20 + }; + map = new OpenLayers.Map(options); + + // Create Google Mercator layers + var gmap = new OpenLayers.Layer.Google("Google Streets", + { + type: google.maps.MapTypeId.ROADMAP, + sphericalMercator: true + }); + var gsat = new OpenLayers.Layer.Google("Google Satellite", + { + type: google.maps.MapTypeId.SATELLITE, + sphericalMercator: true + }); + var ghyb = new OpenLayers.Layer.Google("Google Hybrid", + { + type: google.maps.MapTypeId.HYBRID, + sphericalMercator: true + }); + var gter = new OpenLayers.Layer.Google("Google Terrain", + { + type: google.maps.MapTypeId.TERRAIN, + sphericalMercator: true + }); + + // Create Bing layers + var broad = new OpenLayers.Layer.Bing({ + name: "Bing Roads", + key: "%(bingkey)s", + type: "Road", + sphericalMercator: true + }); + var baer = new OpenLayers.Layer.Bing({ + name: "Bing Aerial", + key: "%(bingkey)s", + type: "Aerial", + sphericalMercator: true + }); + var bhyb = new OpenLayers.Layer.Bing({ + name: "Bing Hybrid", + key: "%(bingkey)s", + type: "AerialWithLabels", + sphericalMercator: true + }); + + // Create OSM layer + var osm = new OpenLayers.Layer.OSM("OpenStreetMap"); + + // create TMS Overlay layer + var tmsoverlay = new OpenLayers.Layer.TMS("TMS Overlay", "", + { + serviceVersion: '.', + layername: '.', + alpha: true, + type: '%(tileformat)s', + isBaseLayer: false, + getURL: getURL + }); + if (OpenLayers.Util.alphaHack() == false) { + tmsoverlay.setOpacity(0.7); + } + + map.addLayers([gmap, gsat, ghyb, gter, + broad, baer, bhyb, + osm, tmsoverlay]); + + var switcherControl = new OpenLayers.Control.LayerSwitcher(); + map.addControl(switcherControl); + switcherControl.maximizeControl(); + + map.zoomToExtent(mapBounds.transform(map.displayProjection, map.projection)); + """ % args # noqa + + elif self.options.profile == 'geodetic': + s += """ + var options = { + div: "map", + controls: [], + projection: "EPSG:4326" + }; + map = new OpenLayers.Map(options); + + var wms = new OpenLayers.Layer.WMS("VMap0", + "http://tilecache.osgeo.org/wms-c/Basic.py?", + { + layers: 'basic', + format: 'image/png' + } + ); + var tmsoverlay = new OpenLayers.Layer.TMS("TMS Overlay", "", + { + serviceVersion: '.', + layername: '.', + alpha: true, + type: '%(tileformat)s', + isBaseLayer: false, + getURL: getURL + }); + if (OpenLayers.Util.alphaHack() == false) { + tmsoverlay.setOpacity(0.7); + } + + map.addLayers([wms,tmsoverlay]); + + var switcherControl = new OpenLayers.Control.LayerSwitcher(); + map.addControl(switcherControl); + switcherControl.maximizeControl(); + + map.zoomToExtent(mapBounds); + """ % args # noqa + + elif self.options.profile == 'raster': + s += """ + var options = { + div: "map", + controls: [], + maxExtent: new OpenLayers.Bounds(%(west)s, %(south)s, %(east)s, %(north)s), + maxResolution: %(rastermaxresolution)f, + numZoomLevels: %(rasterzoomlevels)d + }; + map = new OpenLayers.Map(options); + + var layer = new OpenLayers.Layer.TMS("TMS Layer", "", + { + serviceVersion: '.', + layername: '.', + alpha: true, + type: '%(tileformat)s', + getURL: getURL + }); + + map.addLayer(layer); + map.zoomToExtent(mapBounds); + """ % args # noqa + + s += """ + map.addControls([new OpenLayers.Control.PanZoomBar(), + new OpenLayers.Control.Navigation(), + new OpenLayers.Control.MousePosition(), + new OpenLayers.Control.ArgParser(), + new OpenLayers.Control.Attribution()]); + } + """ % args + + if self.options.profile == 'mercator': + s += """ + function getURL(bounds) { + bounds = this.adjustBounds(bounds); + var res = this.getServerResolution(); + var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w)); + var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h)); + var z = this.getServerZoom(); + if (this.map.baseLayer.CLASS_NAME === 'OpenLayers.Layer.Bing') { + z+=1; + } + var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type; + var url = this.url; + if (OpenLayers.Util.isArray(url)) { + url = this.selectUrl(path, url); + } + if (mapBounds.intersectsBounds(bounds) && (z >= mapMinZoom) && (z <= mapMaxZoom)) { + return url + path; + } else { + return emptyTileURL; + } + } + """ % args # noqa + + elif self.options.profile == 'geodetic': + s += """ + function getURL(bounds) { + bounds = this.adjustBounds(bounds); + var res = this.getServerResolution(); + var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w)); + var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h)); + var z = this.getServerZoom()%(tmsoffset)s; + var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type; + var url = this.url; + if (OpenLayers.Util.isArray(url)) { + url = this.selectUrl(path, url); + } + if (mapBounds.intersectsBounds(bounds) && (z >= mapMinZoom) && (z <= mapMaxZoom)) { + return url + path; + } else { + return emptyTileURL; + } + } + """ % args # noqa + + elif self.options.profile == 'raster': + s += """ + function getURL(bounds) { + bounds = this.adjustBounds(bounds); + var res = this.getServerResolution(); + var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w)); + var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h)); + var z = this.getServerZoom(); + var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type; + var url = this.url; + if (OpenLayers.Util.isArray(url)) { + url = this.selectUrl(path, url); + } + if (mapBounds.intersectsBounds(bounds) && (z >= mapMinZoom) && (z <= mapMaxZoom)) { + return url + path; + } else { + return emptyTileURL; + } + } + """ % args # noqa + + s += """ + function getWindowHeight() { + if (self.innerHeight) return self.innerHeight; + if (document.documentElement && document.documentElement.clientHeight) + return document.documentElement.clientHeight; + if (document.body) return document.body.clientHeight; + return 0; + } + + function getWindowWidth() { + if (self.innerWidth) return self.innerWidth; + if (document.documentElement && document.documentElement.clientWidth) + return document.documentElement.clientWidth; + if (document.body) return document.body.clientWidth; + return 0; + } + + function resize() { + var map = document.getElementById("map"); + var header = document.getElementById("header"); + var subheader = document.getElementById("subheader"); + map.style.height = (getWindowHeight()-80) + "px"; + map.style.width = (getWindowWidth()-20) + "px"; + header.style.width = (getWindowWidth()-20) + "px"; + subheader.style.width = (getWindowWidth()-20) + "px"; + if (map.updateSize) { map.updateSize(); }; + } + + onresize=function(){ resize(); }; + + </script> + </head> + <body onload="init()"> + <div id="header"><h1>%(title)s</h1></div> + <div id="subheader">Generated by <a href="http://www.klokan.cz/projects/gdal2tiles/">GDAL2Tiles</a>, Copyright © 2008 <a href="http://www.klokan.cz/">Klokan Petr Pridal</a>, <a href="http://www.gdal.org/">GDAL</a> & <a href="http://www.osgeo.org/">OSGeo</a> <a href="http://code.google.com/soc/">GSoC</a> + <!-- PLEASE, LET THIS NOTE ABOUT AUTHOR AND PROJECT SOMEWHERE ON YOUR WEBSITE, OR AT LEAST IN THE COMMENT IN HTML. THANK YOU --> + </div> + <div id="map"></div> + <script type="text/javascript" >resize()</script> + </body> + </html>""" % args # noqa + + return s + + +def main(): + argv = gdal.GeneralCmdLineProcessor(sys.argv) + if argv: + gdal2tiles = GDAL2Tiles(argv[1:]) + gdal2tiles.process() + + +if __name__ == '__main__': + main() + +# vim: set tabstop=4 shiftwidth=4 expandtab: diff --git a/auxiliary/gdal2customtiles/gdal2customtiles_py27.py b/auxiliary/gdal2customtiles/legacy/gdal2customtiles_py27.py similarity index 97% rename from auxiliary/gdal2customtiles/gdal2customtiles_py27.py rename to auxiliary/gdal2customtiles/legacy/gdal2customtiles_py27.py index 8b6421d6..13082c6f 100644 --- a/auxiliary/gdal2customtiles/gdal2customtiles_py27.py +++ b/auxiliary/gdal2customtiles/legacy/gdal2customtiles_py27.py @@ -1,3218 +1,3218 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# ****************************************************************************** -# $Id$ -# -# Project: Google Summer of Code 2007, 2008 (http://code.google.com/soc/) -# Support: BRGM (http://www.brgm.fr) -# Purpose: Convert a raster into TMS (Tile Map Service) tiles in a directory. -# - generate Google Earth metadata (KML SuperOverlay) -# - generate simple HTML viewer based on Google Maps and OpenLayers -# - support of global tiles (Spherical Mercator) for compatibility -# with interactive web maps a la Google Maps -# Author: Klokan Petr Pridal, klokan at klokan dot cz -# Web: http://www.klokan.cz/projects/gdal2tiles/ -# GUI: http://www.maptiler.org/ -# -############################################################################### -# Copyright (c) 2008, Klokan Petr Pridal -# Copyright (c) 2010-2013, Even Rouault <even dot rouault at mines-paris dot org> -# -# 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. -# ****************************************************************************** - -import math -import os -import sys - -from osgeo import gdal -from osgeo import osr - -import struct # 1bto4b - - -def binary(num): # 1bto4b - # 1bto4b - return ''.join(bin(ord(c)).replace('0b', '').rjust(8, '0') for c in struct.pack('!f', num)) - -# 1bto4b - -def getTilePxBounds(self, tx, ty, tz, ds): - - querysize = self.tilesize - - if self.isRasterBounded: # 'raster' profile: - # tilesize in raster coordinates for actual zoom - tsize = int(self.tsize[tz]) - xsize = self.out_ds.fWorldXSize - ysize = self.out_ds.fWorldYSize - if tz >= self.tmaxz: - querysize = self.tilesize - - rx = (tx) * tsize - self.out_ds.fRasterXOriginWorld - #print("rx", rx) - rxsize = 0 - rxsize = tsize - - rysize = 0 - rysize = tsize - - ry = ysize - (ty * tsize) - rysize - \ - self.out_ds.fRasterYOriginWorld - - wx, wy = 0, 0 - wxsize = int(rxsize/float(tsize) * self.tilesize) - wysize = int(rysize/float(tsize) * self.tilesize) - if wysize != self.tilesize: - wy = self.tilesize - wysize - - if rx < 0: - rxsize = tsize + rx - wx = -rx - wxsize = int(rxsize/float(tsize) * self.tilesize) - rx = 0 - if ry < 0: - rysize = tsize + ry - wy = -ry - wysize = int(rysize/float(tsize) * self.tilesize) - ry = 0 - if rx + rxsize > self.out_ds.fRasterXSizeWorld: - rxsize = self.out_ds.fRasterXSizeWorld - rx - wxsize = int(rxsize/float(tsize) * self.tilesize) - if ry + rysize > self.out_ds.fRasterYSizeWorld: - rysize = self.out_ds.fRasterYSizeWorld - ry - wysize = int(rysize/float(tsize) * self.tilesize) - - # Convert rx, ry back to non-world coordinates - rx = int(float(self.out_ds.RasterXSize) * - (float(rx) / self.out_ds.fRasterXSizeWorld)) - ry = int(float(self.out_ds.RasterYSize) * - (float(ry) / self.out_ds.fRasterYSizeWorld)) - rxsize = int(float(self.out_ds.RasterXSize) * - (float(rxsize) / self.out_ds.fRasterXSizeWorld)) - rysize = int(float(self.out_ds.RasterYSize) * - (float(rysize) / self.out_ds.fRasterYSizeWorld)) - else: - b = self.mercator.TileBounds(tx, ty, tz) - rb, wb = self.geo_query( - ds, b[0], b[3], b[2], b[1], querysize=querysize) - rx, ry, rxsize, rysize = rb - wx, wy, wxsize, wysize = wb - - return [rx, ry, rxsize, rysize, wxsize, wysize] - - -try: - from PIL import Image - import numpy - import osgeo.gdal_array as gdalarray -except Exception: - # 'antialias' resampling is not available - pass - -__version__ = "$Id$" - -resampling_list = ('average', 'near', 'bilinear', 'cubic', - 'cubicspline', 'lanczos', 'antialias') -profile_list = ('mercator', 'geodetic', 'raster') -webviewer_list = ('all', 'google', 'openlayers', 'leaflet', 'none') - -# ============================================================================= -# ============================================================================= -# ============================================================================= - -__doc__globalmaptiles = """ -globalmaptiles.py - -Global Map Tiles as defined in Tile Map Service (TMS) Profiles -============================================================== - -Functions necessary for generation of global tiles used on the web. -It contains classes implementing coordinate conversions for: - - - GlobalMercator (based on EPSG:3857) - for Google Maps, Yahoo Maps, Bing Maps compatible tiles - - GlobalGeodetic (based on EPSG:4326) - for OpenLayers Base Map and Google Earth compatible tiles - -More info at: - -http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification -http://wiki.osgeo.org/wiki/WMS_Tiling_Client_Recommendation -http://msdn.microsoft.com/en-us/library/bb259689.aspx -http://code.google.com/apis/maps/documentation/overlays.html#Google_Maps_Coordinates - -Created by Klokan Petr Pridal on 2008-07-03. -Google Summer of Code 2008, project GDAL2Tiles for OSGEO. - -In case you use this class in your product, translate it to another language -or find it useful for your project please let me know. -My email: klokan at klokan dot cz. -I would like to know where it was used. - -Class is available under the open-source GDAL license (www.gdal.org). -""" - -MAXZOOMLEVEL = 32 - - -class GlobalMercator(object): - r""" - TMS Global Mercator Profile - --------------------------- - - Functions necessary for generation of tiles in Spherical Mercator projection, - EPSG:3857. - - Such tiles are compatible with Google Maps, Bing Maps, Yahoo Maps, - UK Ordnance Survey OpenSpace API, ... - and you can overlay them on top of base maps of those web mapping applications. - - Pixel and tile coordinates are in TMS notation (origin [0,0] in bottom-left). - - What coordinate conversions do we need for TMS Global Mercator tiles:: - - LatLon <-> Meters <-> Pixels <-> Tile - - WGS84 coordinates Spherical Mercator Pixels in pyramid Tiles in pyramid - lat/lon XY in meters XY pixels Z zoom XYZ from TMS - EPSG:4326 EPSG:387 - .----. --------- -- TMS - / \ <-> | | <-> /----/ <-> Google - \ / | | /--------/ QuadTree - ----- --------- /------------/ - KML, public WebMapService Web Clients TileMapService - - What is the coordinate extent of Earth in EPSG:3857? - - [-20037508.342789244, -20037508.342789244, - 20037508.342789244, 20037508.342789244] - Constant 20037508.342789244 comes from the circumference of the Earth in meters, - which is 40 thousand kilometers, the coordinate origin is in the middle of extent. - In fact you can calculate the constant as: 2 * math.pi * 6378137 / 2.0 - $ echo 180 85 | gdaltransform -s_srs EPSG:4326 -t_srs EPSG:3857 - Polar areas with abs(latitude) bigger then 85.05112878 are clipped off. - - What are zoom level constants (pixels/meter) for pyramid with EPSG:3857? - - whole region is on top of pyramid (zoom=0) covered by 256x256 pixels tile, - every lower zoom level resolution is always divided by two - initialResolution = 20037508.342789244 * 2 / 256 = 156543.03392804062 - - What is the difference between TMS and Google Maps/QuadTree tile name convention? - - The tile raster itself is the same (equal extent, projection, pixel size), - there is just different identification of the same raster tile. - Tiles in TMS are counted from [0,0] in the bottom-left corner, id is XYZ. - Google placed the origin [0,0] to the top-left corner, reference is XYZ. - Microsoft is referencing tiles by a QuadTree name, defined on the website: - http://msdn2.microsoft.com/en-us/library/bb259689.aspx - - The lat/lon coordinates are using WGS84 datum, yes? - - Yes, all lat/lon we are mentioning should use WGS84 Geodetic Datum. - Well, the web clients like Google Maps are projecting those coordinates by - Spherical Mercator, so in fact lat/lon coordinates on sphere are treated as if - the were on the WGS84 ellipsoid. - - From MSDN documentation: - To simplify the calculations, we use the spherical form of projection, not - the ellipsoidal form. Since the projection is used only for map display, - and not for displaying numeric coordinates, we don't need the extra precision - of an ellipsoidal projection. The spherical projection causes approximately - 0.33 percent scale distortion in the Y direction, which is not visually - noticeable. - - How do I create a raster in EPSG:3857 and convert coordinates with PROJ.4? - - You can use standard GIS tools like gdalwarp, cs2cs or gdaltransform. - All of the tools supports -t_srs 'epsg:3857'. - - For other GIS programs check the exact definition of the projection: - More info at http://spatialreference.org/ref/user/google-projection/ - The same projection is designated as EPSG:3857. WKT definition is in the - official EPSG database. - - Proj4 Text: - +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 - +k=1.0 +units=m +nadgrids=@null +no_defs - - Human readable WKT format of EPSG:3857: - PROJCS["Google Maps Global Mercator", - GEOGCS["WGS 84", - DATUM["WGS_1984", - SPHEROID["WGS 84",6378137,298.257223563, - AUTHORITY["EPSG","7030"]], - AUTHORITY["EPSG","6326"]], - PRIMEM["Greenwich",0], - UNIT["degree",0.0174532925199433], - AUTHORITY["EPSG","4326"]], - PROJECTION["Mercator_1SP"], - PARAMETER["central_meridian",0], - PARAMETER["scale_factor",1], - PARAMETER["false_easting",0], - PARAMETER["false_northing",0], - UNIT["metre",1, - AUTHORITY["EPSG","9001"]]] - """ - - def __init__(self, tileSize=256): - "Initialize the TMS Global Mercator pyramid" - self.tileSize = tileSize - self.initialResolution = 2 * math.pi * 6378137 / self.tileSize - # 156543.03392804062 for tileSize 256 pixels - self.originShift = 2 * math.pi * 6378137 / 2.0 - # 20037508.342789244 - - def LatLonToMeters(self, lat, lon): - "Converts given lat/lon in WGS84 Datum to XY in Spherical Mercator EPSG:3857" - - mx = lon * self.originShift / 180.0 - my = math.log(math.tan((90 + lat) * math.pi / 360.0)) / \ - (math.pi / 180.0) - - my = my * self.originShift / 180.0 - return mx, my - - def MetersToLatLon(self, mx, my): - "Converts XY point from Spherical Mercator EPSG:3857 to lat/lon in WGS84 Datum" - - lon = (mx / self.originShift) * 180.0 - lat = (my / self.originShift) * 180.0 - - lat = 180 / math.pi * \ - (2 * math.atan(math.exp(lat * math.pi / 180.0)) - math.pi / 2.0) - return lat, lon - - def PixelsToMeters(self, px, py, zoom): - "Converts pixel coordinates in given zoom level of pyramid to EPSG:3857" - - res = self.Resolution(zoom) - mx = px * res - self.originShift - my = py * res - self.originShift - return mx, my - - def MetersToPixels(self, mx, my, zoom): - "Converts EPSG:3857 to pyramid pixel coordinates in given zoom level" - - res = self.Resolution(zoom) - px = (mx + self.originShift) / res - py = (my + self.originShift) / res - return px, py - - def PixelsToTile(self, px, py): - "Returns a tile covering region in given pixel coordinates" - - tx = int(math.ceil(px / float(self.tileSize)) - 1) - ty = int(math.ceil(py / float(self.tileSize)) - 1) - return tx, ty - - def PixelsToRaster(self, px, py, zoom): - "Move the origin of pixel coordinates to top-left corner" - - mapSize = self.tileSize << zoom - return px, mapSize - py - - def MetersToTile(self, mx, my, zoom): - "Returns tile for given mercator coordinates" - - px, py = self.MetersToPixels(mx, my, zoom) - return self.PixelsToTile(px, py) - - def TileBounds(self, tx, ty, zoom): - "Returns bounds of the given tile in EPSG:3857 coordinates" - - minx, miny = self.PixelsToMeters( - tx*self.tileSize, ty*self.tileSize, zoom) - maxx, maxy = self.PixelsToMeters( - (tx+1)*self.tileSize, (ty+1)*self.tileSize, zoom) - return (minx, miny, maxx, maxy) - - def TileLatLonBounds(self, tx, ty, zoom): - "Returns bounds of the given tile in latitude/longitude using WGS84 datum" - - bounds = self.TileBounds(tx, ty, zoom) - minLat, minLon = self.MetersToLatLon(bounds[0], bounds[1]) - maxLat, maxLon = self.MetersToLatLon(bounds[2], bounds[3]) - - return (minLat, minLon, maxLat, maxLon) - - def Resolution(self, zoom): - "Resolution (meters/pixel) for given zoom level (measured at Equator)" - - # return (2 * math.pi * 6378137) / (self.tileSize * 2**zoom) - return self.initialResolution / (2**zoom) - - def ZoomForPixelSize(self, pixelSize): - "Maximal scaledown zoom of the pyramid closest to the pixelSize." - - for i in range(MAXZOOMLEVEL): - if pixelSize > self.Resolution(i): - if i != -1: - return i-1 - else: - return 0 # We don't want to scale up - - def GoogleTile(self, tx, ty, zoom): - "Converts TMS tile coordinates to Google Tile coordinates" - - # coordinate origin is moved from bottom-left to top-left corner of the extent - return tx, (2**zoom - 1) - ty - - def QuadTree(self, tx, ty, zoom): - "Converts TMS tile coordinates to Microsoft QuadTree" - - quadKey = "" - ty = (2**zoom - 1) - ty - for i in range(zoom, 0, -1): - digit = 0 - mask = 1 << (i-1) - if (tx & mask) != 0: - digit += 1 - if (ty & mask) != 0: - digit += 2 - quadKey += str(digit) - - return quadKey - - -class GlobalGeodetic(object): - r""" - TMS Global Geodetic Profile - --------------------------- - - Functions necessary for generation of global tiles in Plate Carre projection, - EPSG:4326, "unprojected profile". - - Such tiles are compatible with Google Earth (as any other EPSG:4326 rasters) - and you can overlay the tiles on top of OpenLayers base map. - - Pixel and tile coordinates are in TMS notation (origin [0,0] in bottom-left). - - What coordinate conversions do we need for TMS Global Geodetic tiles? - - Global Geodetic tiles are using geodetic coordinates (latitude,longitude) - directly as planar coordinates XY (it is also called Unprojected or Plate - Carre). We need only scaling to pixel pyramid and cutting to tiles. - Pyramid has on top level two tiles, so it is not square but rectangle. - Area [-180,-90,180,90] is scaled to 512x256 pixels. - TMS has coordinate origin (for pixels and tiles) in bottom-left corner. - Rasters are in EPSG:4326 and therefore are compatible with Google Earth. - - LatLon <-> Pixels <-> Tiles - - WGS84 coordinates Pixels in pyramid Tiles in pyramid - lat/lon XY pixels Z zoom XYZ from TMS - EPSG:4326 - .----. ---- - / \ <-> /--------/ <-> TMS - \ / /--------------/ - ----- /--------------------/ - WMS, KML Web Clients, Google Earth TileMapService - """ - - def __init__(self, tmscompatible, tileSize=256): - self.tileSize = tileSize - if tmscompatible is not None: - # Defaults the resolution factor to 0.703125 (2 tiles @ level 0) - # Adhers to OSGeo TMS spec - # http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification#global-geodetic - self.resFact = 180.0 / self.tileSize - else: - # Defaults the resolution factor to 1.40625 (1 tile @ level 0) - # Adheres OpenLayers, MapProxy, etc default resolution for WMTS - self.resFact = 360.0 / self.tileSize - - def LonLatToPixels(self, lon, lat, zoom): - "Converts lon/lat to pixel coordinates in given zoom of the EPSG:4326 pyramid" - - res = self.resFact / 2**zoom - px = (180 + lon) / res - py = (90 + lat) / res - return px, py - - def PixelsToTile(self, px, py): - "Returns coordinates of the tile covering region in pixel coordinates" - - tx = int(math.ceil(px / float(self.tileSize)) - 1) - ty = int(math.ceil(py / float(self.tileSize)) - 1) - return tx, ty - - def LonLatToTile(self, lon, lat, zoom): - "Returns the tile for zoom which covers given lon/lat coordinates" - - px, py = self.LonLatToPixels(lon, lat, zoom) - return self.PixelsToTile(px, py) - - def Resolution(self, zoom): - "Resolution (arc/pixel) for given zoom level (measured at Equator)" - - return self.resFact / 2**zoom - - def ZoomForPixelSize(self, pixelSize): - "Maximal scaledown zoom of the pyramid closest to the pixelSize." - - for i in range(MAXZOOMLEVEL): - if pixelSize > self.Resolution(i): - if i != 0: - return i-1 - else: - return 0 # We don't want to scale up - - def TileBounds(self, tx, ty, zoom): - "Returns bounds of the given tile" - res = self.resFact / 2**zoom - return ( - tx*self.tileSize*res - 180, - ty*self.tileSize*res - 90, - (tx+1)*self.tileSize*res - 180, - (ty+1)*self.tileSize*res - 90 - ) - - def TileLatLonBounds(self, tx, ty, zoom): - "Returns bounds of the given tile in the SWNE form" - b = self.TileBounds(tx, ty, zoom) - return (b[1], b[0], b[3], b[2]) - - -class Zoomify(object): - """ - Tiles compatible with the Zoomify viewer - ---------------------------------------- - """ - - def __init__(self, width, height, tilesize=256, tileformat='jpg'): - """Initialization of the Zoomify tile tree""" - - self.tilesize = tilesize - self.tileformat = tileformat - imagesize = (width, height) - tiles = (math.ceil(width / tilesize), math.ceil(height / tilesize)) - - # Size (in tiles) for each tier of pyramid. - self.tierSizeInTiles = [] - self.tierSizeInTiles.append(tiles) - - # Image size in pixels for each pyramid tierself - self.tierImageSize = [] - self.tierImageSize.append(imagesize) - - while (imagesize[0] > tilesize or imagesize[1] > tilesize): - imagesize = (math.floor( - imagesize[0] / 2), math.floor(imagesize[1] / 2)) - tiles = (math.ceil(imagesize[0] / tilesize), - math.ceil(imagesize[1] / tilesize)) - self.tierSizeInTiles.append(tiles) - self.tierImageSize.append(imagesize) - - self.tierSizeInTiles.reverse() - self.tierImageSize.reverse() - - # Depth of the Zoomify pyramid, number of tiers (zoom levels) - self.numberOfTiers = len(self.tierSizeInTiles) - - # Number of tiles up to the given tier of pyramid. - self.tileCountUpToTier = [] - self.tileCountUpToTier[0] = 0 - for i in range(1, self.numberOfTiers+1): - self.tileCountUpToTier.append( - self.tierSizeInTiles[i-1][0] * self.tierSizeInTiles[i-1][1] + - self.tileCountUpToTier[i-1] - ) - - def tilefilename(self, x, y, z): - """Returns filename for tile with given coordinates""" - - tileIndex = x + y * \ - self.tierSizeInTiles[z][0] + self.tileCountUpToTier[z] - return os.path.join("TileGroup%.0f" % math.floor(tileIndex / 256), - "%s-%s-%s.%s" % (z, x, y, self.tileformat)) - - -class Gdal2TilesError(Exception): - pass - - -class GDAL2Tiles(object): - - def process(self): - """The main processing function, runs all the main steps of processing""" - - # Opening and preprocessing of the input file - self.open_input() - - # Generation of main metadata files and HTML viewers - self.generate_metadata() - - # 1bto4b - if self.isDEMtile: - for z in range(self.tminz, self.tmaxz + int(abs(math.log(self.tilesize, 2) - 8))): # 1bto4b - self.generate_base_tiles(z) - print(' Zoom ' + str(z) + ' tiles done!') - else: - # Generation of the lowest tiles - self.generate_base_tiles(self.tmaxz) - - # Generation of the overview tiles (higher in the pyramid) - self.generate_overview_tiles() - - def error(self, msg, details=""): - """Print an error message and stop the processing""" - if details: - self.parser.error(msg + "\n\n" + details) - else: - self.parser.error(msg) - - def progressbar(self, complete=0.0): - """Print progressbar for float value 0..1""" - gdal.TermProgress_nocb(complete) - - def gettempfilename(self, suffix): - """Returns a temporary filename""" - if '_' in os.environ: - # tempfile.mktemp() crashes on some Wine versions (the one of Ubuntu 12.04 particularly) - if os.environ['_'].find('wine') >= 0: - tmpdir = '.' - if 'TMP' in os.environ: - tmpdir = os.environ['TMP'] - import time - import random - random.seed(time.time()) - random_part = 'file%d' % random.randint(0, 1000000000) - return os.path.join(tmpdir, random_part + suffix) - - import tempfile - return tempfile.mktemp(suffix) - - def stop(self): - """Stop the rendering immediately""" - self.stopped = True - - def __init__(self, arguments): - """Constructor function - initialization""" - self.out_drv = None - self.mem_drv = None - self.in_ds = None - self.out_ds = None - self.out_srs = None - self.nativezoom = None - self.tminmax = None - self.tsize = None - self.mercator = None - self.geodetic = None - self.alphaband = None - self.dataBandsCount = None - self.out_gt = None - self.tileswne = None - self.swne = None - self.ominx = None - self.omaxx = None - self.omaxy = None - self.ominy = None - - # MMGIS - self.isRasterBounded = False - - # 1bto4b - self.isDEMtile = False - - # MMGIS - self.fminx = None - self.fmaxx = None - self.fminy = None - self.fmaxy = None - self.fPixelSize = None - - self.stopped = False - self.input = None - self.output = None - - # Tile format - self.tilesize = 256 - self.tiledriver = 'PNG' - self.tileext = 'png' - - # Should we read bigger window of the input raster and scale it down? - # Note: Modified later by open_input() - # Not for 'near' resampling - # Not for Wavelet based drivers (JPEG2000, ECW, MrSID) - # Not for 'raster' profile - self.scaledquery = True - # How big should be query window be for scaling down - # Later on reset according the chosen resampling algorightm - self.querysize = 4 * self.tilesize - - # Should we use Read on the input file for generating overview tiles? - # Note: Modified later by open_input() - # Otherwise the overview tiles are generated from existing underlying tiles - self.overviewquery = False - - # RUN THE ARGUMENT PARSER: - - self.optparse_init() - self.options, self.args = self.parser.parse_args(args=arguments) - if not self.args: - self.error("No input file specified") - - # POSTPROCESSING OF PARSED ARGUMENTS: - - # Workaround for old versions of GDAL - try: - if ((self.options.verbose and self.options.resampling == 'near') or - gdal.TermProgress_nocb): - pass - except Exception: - self.error( - "This version of GDAL is not supported. Please upgrade to 1.6+.") - - # Is output directory the last argument? - - # Test output directory, if it doesn't exist - if (os.path.isdir(self.args[-1]) or - (len(self.args) > 1 and not os.path.exists(self.args[-1]))): - self.output = self.args[-1] - self.args = self.args[:-1] - - # More files on the input not directly supported yet - - if (len(self.args) > 1): - self.error("Processing of several input files is not supported.", - "Please first use a tool like gdal_vrtmerge.py or gdal_merge.py on the " - "files: gdal_vrtmerge.py -o merged.vrt %s" % " ".join(self.args)) - - self.input = self.args[0] - - # MMGIS - if self.options.extentworld: - extentworld = self.options.extentworld.split(",") - self.isRasterBounded = True - self.fminx = float(extentworld[0]) - self.fmaxx = float(extentworld[2]) - self.fminy = float(extentworld[3]) - self.fmaxy = float(extentworld[1]) - self.fPixelSize = float(extentworld[4]) - - # 1bto4b - if self.options.isDEMtile: - self.isDEMtile = True - self.tilesize = 32 - self.querysize = 4 * self.tilesize - - # Default values for not given options - - if not self.output: - # Directory with input filename without extension in actual directory - self.output = os.path.splitext(os.path.basename(self.input))[0] - - if not self.options.title: - self.options.title = os.path.basename(self.input) - - if self.options.url and not self.options.url.endswith('/'): - self.options.url += '/' - if self.options.url: - self.options.url += os.path.basename(self.output) + '/' - - # Supported options - - self.resampling = None - - if self.options.resampling == 'average': - try: - if gdal.RegenerateOverview: - pass - except Exception: - self.error("'average' resampling algorithm is not available.", - "Please use -r 'near' argument or upgrade to newer version of GDAL.") - - elif self.options.resampling == 'antialias': - try: - if numpy: # pylint:disable=W0125 - pass - except Exception: - self.error("'antialias' resampling algorithm is not available.", - "Install PIL (Python Imaging Library) and numpy.") - - elif self.options.resampling == 'near': - self.resampling = gdal.GRA_NearestNeighbour - self.querysize = self.tilesize - - elif self.options.resampling == 'bilinear': - self.resampling = gdal.GRA_Bilinear - self.querysize = self.tilesize * 2 - - elif self.options.resampling == 'cubic': - self.resampling = gdal.GRA_Cubic - - elif self.options.resampling == 'cubicspline': - self.resampling = gdal.GRA_CubicSpline - - elif self.options.resampling == 'lanczos': - self.resampling = gdal.GRA_Lanczos - - # User specified zoom levels - self.tminz = None - self.tmaxz = None - if self.options.zoom: - minmax = self.options.zoom.split('-', 1) - minmax.extend(['']) - zoom_min, zoom_max = minmax[:2] - self.tminz = int(zoom_min) - if zoom_max: - self.tmaxz = int(zoom_max) - else: - self.tmaxz = int(zoom_min) - - # KML generation - self.kml = self.options.kml - - # Check if the input filename is full ascii or not - try: - os.path.basename(self.input).encode('ascii') - except UnicodeEncodeError: - full_ascii = False - else: - full_ascii = True - - # LC_CTYPE check - if not full_ascii and 'UTF-8' not in os.environ.get("LC_CTYPE", ""): - if not self.options.quiet: - print("\nWARNING: " - "You are running gdal2tiles.py with a LC_CTYPE environment variable that is " - "not UTF-8 compatible, and your input file contains non-ascii characters. " - "The generated sample googlemaps, openlayers or " - "leaflet files might contain some invalid characters as a result\n") - - # Output the results - if self.options.verbose: - print("Options:", self.options) - print("Input:", self.input) - print("Output:", self.output) - print("Cache: %s MB" % (gdal.GetCacheMax() / 1024 / 1024)) - print('') - - def optparse_init(self): - """Prepare the option parser for input (argv)""" - - from optparse import OptionParser, OptionGroup - usage = "Usage: %prog [options] input_file(s) [output]" - p = OptionParser(usage, version="%prog " + __version__) - p.add_option("-p", "--profile", dest='profile', - type='choice', choices=profile_list, - help=("Tile cutting profile (%s) - default 'mercator' " - "(Google Maps compatible)" % ",".join(profile_list))) - p.add_option("-r", "--resampling", dest="resampling", - type='choice', choices=resampling_list, - help="Resampling method (%s) - default 'average'" % ",".join(resampling_list)) - p.add_option('-s', '--s_srs', dest="s_srs", metavar="SRS", - help="The spatial reference system used for the source input data") - p.add_option('-z', '--zoom', dest="zoom", - help="Zoom levels to render (format:'2-5' or '10').") - p.add_option('-e', '--resume', dest="resume", action="store_true", - help="Resume mode. Generate only missing files.") - p.add_option('-a', '--srcnodata', dest="srcnodata", metavar="NODATA", - help="NODATA transparency value to assign to the input data") - p.add_option('-d', '--tmscompatible', dest="tmscompatible", action="store_true", - help=("When using the geodetic profile, specifies the base resolution " - "as 0.703125 or 2 tiles at zoom level 0.")) - p.add_option("-v", "--verbose", - action="store_true", dest="verbose", - help="Print status messages to stdout") - p.add_option("-q", "--quiet", - action="store_true", dest="quiet", - help="Disable messages and status to stdout") - # MMGIS - p.add_option("-x", "--extentworld", dest="extentworld", - help="The full world meter extent (comma-separated as minx,maxx,miny,maxy,pixelsize) of an inner raster profile.") - # 1bto4b - p.add_option("-m", "--dem", action="store_true", dest="isDEMtile", - help="Indicate if the input is a Digital Elevation Model") - # KML options - g = OptionGroup(p, "KML (Google Earth) options", - "Options for generated Google Earth SuperOverlay metadata") - g.add_option("-k", "--force-kml", dest='kml', action="store_true", - help=("Generate KML for Google Earth - default for 'geodetic' profile and " - "'raster' in EPSG:4326. For a dataset with different projection use " - "with caution!")) - g.add_option("-n", "--no-kml", dest='kml', action="store_false", - help="Avoid automatic generation of KML files for EPSG:4326") - g.add_option("-u", "--url", dest='url', - help="URL address where the generated tiles are going to be published") - p.add_option_group(g) - - # HTML options - g = OptionGroup(p, "Web viewer options", - "Options for generated HTML viewers a la Google Maps") - g.add_option("-w", "--webviewer", dest='webviewer', type='choice', choices=webviewer_list, - help="Web viewer to generate (%s) - default 'all'" % ",".join(webviewer_list)) - g.add_option("-t", "--title", dest='title', - help="Title of the map") - g.add_option("-c", "--copyright", dest='copyright', - help="Copyright for the map") - g.add_option("-g", "--googlekey", dest='googlekey', - help="Google Maps API key from http://code.google.com/apis/maps/signup.html") - g.add_option("-b", "--bingkey", dest='bingkey', - help="Bing Maps API key from https://www.bingmapsportal.com/") - p.add_option_group(g) - - p.set_defaults(verbose=False, profile="mercator", kml=False, url='', - webviewer='all', copyright='', resampling='average', resume=False, - googlekey='INSERT_YOUR_KEY_HERE', bingkey='INSERT_YOUR_KEY_HERE') - - self.parser = p - - # ------------------------------------------------------------------------- - def open_input(self): - """Initialization of the input raster, reprojection if necessary""" - gdal.AllRegister() - - self.out_drv = gdal.GetDriverByName(self.tiledriver) - self.mem_drv = gdal.GetDriverByName('MEM') - - if not self.out_drv: - raise Exception("The '%s' driver was not found, is it available in this GDAL build?", - self.tiledriver) - if not self.mem_drv: - raise Exception( - "The 'MEM' driver was not found, is it available in this GDAL build?") - - # Open the input file - - if self.input: - self.in_ds = gdal.Open(self.input, gdal.GA_ReadOnly) - else: - raise Exception("No input file was specified") - - if self.options.verbose: - print("Input file:", - "( %sP x %sL - %s bands)" % (self.in_ds.RasterXSize, self.in_ds.RasterYSize, - self.in_ds.RasterCount)) - - if not self.in_ds: - # Note: GDAL prints the ERROR message too - self.error( - "It is not possible to open the input file '%s'." % self.input) - - # Read metadata from the input file - if self.in_ds.RasterCount == 0: - self.error("Input file '%s' has no raster band" % self.input) - - if self.in_ds.GetRasterBand(1).GetRasterColorTable(): - self.error("Please convert this file to RGB/RGBA and run gdal2tiles on the result.", - "From paletted file you can create RGBA file (temp.vrt) by:\n" - "gdal_translate -of vrt -expand rgba %s temp.vrt\n" - "then run:\n" - "gdal2tiles temp.vrt" % self.input) - - # Get NODATA value - in_nodata = [] - for i in range(1, self.in_ds.RasterCount+1): - if self.in_ds.GetRasterBand(i).GetNoDataValue() is not None: - in_nodata.append(self.in_ds.GetRasterBand(i).GetNoDataValue()) - if self.options.srcnodata: - nds = list(map(float, self.options.srcnodata.split(','))) - if len(nds) < self.in_ds.RasterCount: - in_nodata = ( - nds * self.in_ds.RasterCount)[:self.in_ds.RasterCount] - else: - in_nodata = nds - - if self.options.verbose: - print("NODATA: %s" % in_nodata) - - if self.options.verbose: - print("Preprocessed file:", - "( %sP x %sL - %s bands)" % (self.in_ds.RasterXSize, self.in_ds.RasterYSize, - self.in_ds.RasterCount)) - - in_srs = None - - if self.options.s_srs: - in_srs = osr.SpatialReference() - in_srs.SetFromUserInput(self.options.s_srs) - in_srs_wkt = in_srs.ExportToWkt() - else: - in_srs_wkt = self.in_ds.GetProjection() - if not in_srs_wkt and self.in_ds.GetGCPCount() != 0: - in_srs_wkt = self.in_ds.GetGCPProjection() - if in_srs_wkt: - in_srs = osr.SpatialReference() - in_srs.ImportFromWkt(in_srs_wkt) - - self.out_srs = osr.SpatialReference() - - if self.options.profile == 'mercator': - self.out_srs.ImportFromEPSG(3857) - elif self.options.profile == 'geodetic': - self.out_srs.ImportFromEPSG(4326) - else: - self.out_srs = in_srs - - # Are the reference systems the same? Reproject if necessary. - - self.out_ds = None - - if self.options.profile in ('mercator', 'geodetic'): - - if ((self.in_ds.GetGeoTransform() == (0.0, 1.0, 0.0, 0.0, 0.0, 1.0)) and - (self.in_ds.GetGCPCount() == 0)): - self.error("There is no georeference - neither affine transformation (worldfile) " - "nor GCPs. You can generate only 'raster' profile tiles.", - "Either gdal2tiles with parameter -p 'raster' or use another GIS " - "software for georeference e.g. gdal_transform -gcp / -a_ullr / -a_srs") - - if in_srs: - if ((in_srs.ExportToProj4() != self.out_srs.ExportToProj4()) or - (self.in_ds.GetGCPCount() != 0)): - # Generation of VRT dataset in tile projection, - # default 'nearest neighbour' warping - self.out_ds = gdal.AutoCreateWarpedVRT( - self.in_ds, in_srs_wkt, self.out_srs.ExportToWkt()) - - if self.options.verbose: - print("Warping of the raster by AutoCreateWarpedVRT " - "(result saved into 'tiles.vrt')") - self.out_ds.GetDriver().CreateCopy("tiles.vrt", self.out_ds) - - # Correction of AutoCreateWarpedVRT for NODATA values - if in_nodata != []: - tempfilename = self.gettempfilename('-gdal2tiles.vrt') - self.out_ds.GetDriver().CreateCopy(tempfilename, self.out_ds) - # open as a text file - s = open(tempfilename).read() - # Add the warping options - s = s.replace( - "<GDALWarpOptions>", - """ - <GDALWarpOptions> - <Option name="INIT_DEST">NO_DATA</Option> - <Option name="UNIFIED_SRC_NODATA">YES</Option> - """) - # replace BandMapping tag for NODATA bands.... - for i in range(len(in_nodata)): - s = s.replace( - '<BandMapping src="%i" dst="%i"/>' % ( - (i+1), (i+1)), - """ - <BandMapping src="%i" dst="%i"> - <SrcNoDataReal>%i</SrcNoDataReal> - <SrcNoDataImag>0</SrcNoDataImag> - <DstNoDataReal>%i</DstNoDataReal> - <DstNoDataImag>0</DstNoDataImag> - </BandMapping> - """ % ((i+1), (i+1), in_nodata[i], in_nodata[i])) - # save the corrected VRT - open(tempfilename, "w").write(s) - # open by GDAL as self.out_ds - self.out_ds = gdal.Open(tempfilename) - # delete the temporary file - os.unlink(tempfilename) - - # set NODATA_VALUE metadata - self.out_ds.SetMetadataItem( - 'NODATA_VALUES', ' '.join([str(i) for i in in_nodata])) - - if self.options.verbose: - print("Modified warping result saved into 'tiles1.vrt'") - open("tiles1.vrt", "w").write(s) - - # Correction of AutoCreateWarpedVRT for Mono (1 band) and RGB (3 bands) files - # without NODATA: - # equivalent of gdalwarp -dstalpha - if in_nodata == [] and self.out_ds.RasterCount in [1, 3]: - tempfilename = self.gettempfilename('-gdal2tiles.vrt') - self.out_ds.GetDriver().CreateCopy(tempfilename, self.out_ds) - # open as a text file - s = open(tempfilename).read() - # Add the warping options - s = s.replace( - "<BlockXSize>", - """ - <VRTRasterBand dataType="Byte" band="%i" subClass="VRTWarpedRasterBand"> - <ColorInterp>Alpha</ColorInterp> - </VRTRasterBand> - <BlockXSize> - """ % (self.out_ds.RasterCount + 1)) - s = s.replace( - "</GDALWarpOptions>", - """ - <DstAlphaBand>%i</DstAlphaBand> - </GDALWarpOptions> - """ % (self.out_ds.RasterCount + 1)) - s = s.replace( - "</WorkingDataType>", - """ - </WorkingDataType> - <Option name="INIT_DEST">0</Option> - """) - # save the corrected VRT - open(tempfilename, "w").write(s) - # open by GDAL as self.out_ds - self.out_ds = gdal.Open(tempfilename) - # delete the temporary file - os.unlink(tempfilename) - - if self.options.verbose: - print( - "Modified -dstalpha warping result saved into 'tiles1.vrt'") - open("tiles1.vrt", "w").write(s) - s = ''' - ''' - - else: - self.error("Input file has unknown SRS.", - "Use --s_srs ESPG:xyz (or similar) to provide source reference system.") - - if self.out_ds and self.options.verbose: - print("Projected file:", "tiles.vrt", "( %sP x %sL - %s bands)" % ( - self.out_ds.RasterXSize, self.out_ds.RasterYSize, self.out_ds.RasterCount)) - - if not self.out_ds: - self.out_ds = self.in_ds - - # - # Here we should have a raster (out_ds) in the correct Spatial Reference system - # - - # Get alpha band (either directly or from NODATA value) - self.alphaband = self.out_ds.GetRasterBand(1).GetMaskBand() - if ((self.alphaband.GetMaskFlags() & gdal.GMF_ALPHA) or - self.out_ds.RasterCount == 4 or - self.out_ds.RasterCount == 2): - self.dataBandsCount = self.out_ds.RasterCount - 1 - else: - self.dataBandsCount = self.out_ds.RasterCount - - # KML test - isepsg4326 = False - srs4326 = osr.SpatialReference() - srs4326.ImportFromEPSG(4326) - if self.out_srs and srs4326.ExportToProj4() == self.out_srs.ExportToProj4(): - self.kml = True - isepsg4326 = True - if self.options.verbose: - print("KML autotest OK!") - - # Read the georeference - self.out_gt = self.out_ds.GetGeoTransform() - - # Test the size of the pixel - - # Report error in case rotation/skew is in geotransform (possible only in 'raster' profile) - if (self.out_gt[2], self.out_gt[4]) != (0, 0): - self.error("Georeference of the raster contains rotation or skew. " - "Such raster is not supported. Please use gdalwarp first.") - - # Here we expect: pixel is square, no rotation on the raster - - # Output Bounds - coordinates in the output SRS - self.ominx = self.out_gt[0] - self.omaxx = self.out_gt[0] + self.out_ds.RasterXSize * self.out_gt[1] - self.omaxy = self.out_gt[3] - self.ominy = self.out_gt[3] - self.out_ds.RasterYSize * self.out_gt[1] - - # Note: maybe round(x, 14) to avoid the gdal_translate behaviour, when 0 becomes -1e-15 - - # MMGIS - def linearScale(domain, rang, value): - return ( - ((rang[1] - rang[0]) * (value - domain[0])) / - (domain[1] - domain[0]) + - rang[0] - ) - # MMGIS - self.out_ds.fRasterXSize = self.out_ds.RasterXSize - self.out_ds.fRasterYSize = self.out_ds.RasterYSize - self.out_ds.fRasterXOrigin = 0 - self.out_ds.fRasterYOrigin = 0 - self.out_ds.PixelSize = self.out_gt[1] - self.out_ds.fPixelSize = self.fPixelSize - # print("ominx", self.ominx, "omaxx", self.omaxx, "ominy", self.ominy, "omaxy", self.omaxy) - # print("fminx", self.fminx, "fmaxx", self.fmaxx, "fminy", self.fminy, "fmaxy", self.fmaxy) - if self.isRasterBounded: - self.out_ds.fRasterXSize = int(math.floor(self.out_ds.RasterXSize * (self.fmaxx - self.fminx) / ( - self.omaxx - self.ominx) * (self.out_ds.PixelSize / self.out_ds.fPixelSize))) - self.out_ds.fRasterYSize = int(math.ceil(self.out_ds.RasterYSize * (self.fmaxy - self.fminy) / ( - self.omaxy - self.ominy) * (self.out_ds.PixelSize / self.out_ds.fPixelSize))) - self.out_ds.fRasterXSizeRaw = int(math.floor( - self.out_ds.RasterXSize * (self.fmaxx - self.fminx) / (self.omaxx - self.ominx))) - self.out_ds.fRasterYSizeRaw = int(math.ceil( - self.out_ds.RasterYSize * (self.fmaxy - self.fminy) / (self.omaxy - self.ominy))) - # print("Full Raster Size: ", self.out_ds.fRasterXSize, self.out_ds.fRasterYSize ) - self.out_ds.fRasterXOrigin = int(math.floor(linearScale( - [self.fminx, self.fmaxx], [0, self.out_ds.fRasterXSize], self.out_gt[0]))) - self.out_ds.fRasterYOrigin = int(math.ceil(linearScale( - [self.fminy, self.fmaxy], [self.out_ds.fRasterYSize, 0], self.out_gt[3]))) - self.out_ds.fRasterXOriginRaw = int(math.floor(linearScale([self.fminx, self.fmaxx], [ - 0, self.out_ds.fRasterXSize], self.out_gt[0]) * (self.out_ds.fPixelSize / self.out_ds.PixelSize))) - self.out_ds.fRasterYOriginRaw = int(math.ceil(linearScale([self.fminy, self.fmaxy], [ - self.out_ds.fRasterYSize, 0], self.out_gt[3]) * (self.out_ds.fPixelSize / self.out_ds.PixelSize))) - self.out_ds.fRasterXWidth = int(math.floor(linearScale( - [self.fminx, self.fmaxx], [0, self.out_ds.fRasterXSize], self.omaxx))) - self.out_ds.fRasterXOrigin - self.out_ds.fRasterYHeight = int(math.ceil(linearScale( - [self.fminy, self.fmaxy], [0, self.out_ds.fRasterYSize], self.omaxy))) - self.out_ds.fRasterYOrigin - - if self.options.verbose: - print("Bounds (output srs):", round(self.ominx, 13), - self.ominy, self.omaxx, self.omaxy) - - # print("Input Raster Size: ", self.out_ds.RasterXSize, self.out_ds.RasterYSize) - # print("fmaxx-fminx", self.fmaxx - self.fminx, "omaxx-ominx", self.omaxx - self.ominx, "fmaxy-fminy", self.fmaxy - self.fminy, "omaxy-ominy", self.omaxy - self.ominy) - # print("Full Raster Size: ", self.out_ds.fRasterXSize, self.out_ds.fRasterYSize) - # print("Full Raster Size Raw: ", self.out_ds.fRasterXSizeRaw, self.out_ds.fRasterYSizeRaw) - # print("Raster Origin: ", self.out_ds.fRasterXOrigin, self.out_ds.fRasterYOrigin) - # print("Raster Origin Raw: ", self.out_ds.fRasterXOriginRaw, self.out_ds.fRasterYOriginRaw) - # print("Raster Width Height: ", self.out_ds.fRasterXWidth, self.out_ds.fRasterYHeight) - - # Calculating ranges for tiles in different zoom levels - if self.options.profile == 'mercator': - - self.mercator = GlobalMercator() - - # Function which generates SWNE in LatLong for given tile - self.tileswne = self.mercator.TileLatLonBounds - - # Generate table with min max tile coordinates for all zoomlevels - self.tminmax = list(range(0, 32)) - for tz in range(0, 32): - tminx, tminy = self.mercator.MetersToTile( - self.ominx, self.ominy, tz) - tmaxx, tmaxy = self.mercator.MetersToTile( - self.omaxx, self.omaxy, tz) - # crop tiles extending world limits (+-180,+-90) - tminx, tminy = max(0, tminx), max(0, tminy) - tmaxx, tmaxy = min(2**tz-1, tmaxx), min(2**tz-1, tmaxy) - self.tminmax[tz] = (tminx, tminy, tmaxx, tmaxy) - - # TODO: Maps crossing 180E (Alaska?) - - # Get the minimal zoom level (map covers area equivalent to one tile) - if self.tminz is None: - self.tminz = self.mercator.ZoomForPixelSize( - self.out_gt[1] * max(self.out_ds.RasterXSize, - self.out_ds.RasterYSize) / float(self.tilesize)) - - # Get the maximal zoom level - # (closest possible zoom level up on the resolution of raster) - if self.tmaxz is None: - self.tmaxz = self.mercator.ZoomForPixelSize(self.out_gt[1]) - - if self.options.verbose: - print("Bounds (latlong):", - self.mercator.MetersToLatLon(self.ominx, self.ominy), - self.mercator.MetersToLatLon(self.omaxx, self.omaxy)) - print('MinZoomLevel:', self.tminz) - print("MaxZoomLevel:", - self.tmaxz, - "(", - self.mercator.Resolution(self.tmaxz), - ")") - - if self.options.profile == 'geodetic': - - self.geodetic = GlobalGeodetic(self.options.tmscompatible) - - # Function which generates SWNE in LatLong for given tile - self.tileswne = self.geodetic.TileLatLonBounds - - # Generate table with min max tile coordinates for all zoomlevels - self.tminmax = list(range(0, 32)) - for tz in range(0, 32): - tminx, tminy = self.geodetic.LonLatToTile( - self.ominx, self.ominy, tz) - tmaxx, tmaxy = self.geodetic.LonLatToTile( - self.omaxx, self.omaxy, tz) - # crop tiles extending world limits (+-180,+-90) - tminx, tminy = max(0, tminx), max(0, tminy) - tmaxx, tmaxy = min(2**(tz+1)-1, tmaxx), min(2**tz-1, tmaxy) - self.tminmax[tz] = (tminx, tminy, tmaxx, tmaxy) - - # TODO: Maps crossing 180E (Alaska?) - - # Get the maximal zoom level - # (closest possible zoom level up on the resolution of raster) - if self.tminz is None: - self.tminz = self.geodetic.ZoomForPixelSize( - self.out_gt[1] * max(self.out_ds.RasterXSize, - self.out_ds.RasterYSize) / float(self.tilesize)) - - # Get the maximal zoom level - # (closest possible zoom level up on the resolution of raster) - if self.tmaxz is None: - self.tmaxz = self.geodetic.ZoomForPixelSize(self.out_gt[1]) - - if self.options.verbose: - print("Bounds (latlong):", self.ominx, - self.ominy, self.omaxx, self.omaxy) - - # MMGIS - if self.options.profile == 'raster' and self.isRasterBounded: - - def log2(x): - return math.log10(x) / math.log10(2) - - # MMGIS added 'f'* - self.nativezoom = int( - max(math.ceil(log2(self.out_ds.fRasterXSizeRaw/float(self.tilesize))), - math.ceil(log2(self.out_ds.fRasterYSizeRaw/float(self.tilesize))))) - - self.basenativezoom = int( - max(math.ceil(log2(self.out_ds.fRasterXSize/float(self.tilesize))), - math.ceil(log2(self.out_ds.fRasterYSize/float(self.tilesize))))) - - # MMGIS - self.out_ds.fWorldXSize = int( - float(self.out_ds.fRasterXSize) * (2**(self.nativezoom - self.basenativezoom))) - self.out_ds.fWorldYSize = int( - float(self.out_ds.fRasterYSize) * (2**(self.nativezoom - self.basenativezoom))) - self.out_ds.fRasterXOriginWorld = int(float( - self.out_ds.fWorldXSize) * (float(self.out_ds.fRasterXOrigin) / self.out_ds.fRasterXSize)) - self.out_ds.fRasterYOriginWorld = int(float( - self.out_ds.fWorldYSize) * (float(self.out_ds.fRasterYOrigin) / self.out_ds.fRasterYSize)) - self.out_ds.fRasterXSizeWorld = int(float( - self.out_ds.fWorldXSize) * (float(self.out_ds.fRasterXWidth) / self.out_ds.fRasterXSize)) - self.out_ds.fRasterYSizeWorld = int(float( - self.out_ds.RasterYSize) * (float(self.out_ds.fRasterXSizeWorld) / self.out_ds.RasterXSize)) - # print("World Size", self.out_ds.fWorldXSize, self.out_ds.fWorldYSize) - # print("Raster Origin World", self.out_ds.fRasterXOriginWorld, self.out_ds.fRasterYOriginWorld) - # print("Raster Size World", self.out_ds.fRasterXSizeWorld, self.out_ds.fRasterYSizeWorld) - - if self.options.verbose: - print("Native zoom of the raster:", self.nativezoom) - - # Get the minimal zoom level (whole raster in one tile) - if self.tminz is None: - self.tminz = 0 - - # Get the maximal zoom level (native resolution of the raster) - if self.tmaxz is None: - self.tmaxz = self.nativezoom - - # MMGIS added 'f'* - # Generate table with min max tile coordinates for all zoomlevels - self.tminmax = list(range(0, self.tmaxz+1)) - self.tsize = list(range(0, self.tmaxz+1)) - # print("Raster Size:", self.out_ds.RasterXSize,self.out_ds.RasterYSize) - # print("Pixel Size Ratio:", (self.out_ds.fPixelSize / self.out_ds.PixelSize)) - # print("nativezoom", self.nativezoom, "basenativezoom", self.basenativezoom, "tminz", self.tminz, "tmaxz", self.tmaxz) - for tz in range(0, self.tmaxz+1): - tsize = 2.0**(self.tmaxz-tz)*self.tilesize - toffsetx = int(math.floor( - 2.0**(tz) * self.out_ds.fRasterXOriginRaw / self.out_ds.fRasterXSizeRaw)) - toffsety = int(math.floor( - 2.0**(tz) * (self.out_ds.fRasterYOriginRaw) / self.out_ds.fRasterYSizeRaw)) - # print("tsize", tsize, "toffsetx", toffsetx, "toffsety", toffsety) - toffsetx = int(math.floor( - self.out_ds.fRasterXOriginWorld / tsize)) - toffsety = int(math.floor( - self.out_ds.fRasterYOriginWorld / tsize)) - # print("tsize", tsize, "toffsetx", toffsetx, "toffsety", toffsety) - tmaxx = int(math.floor( - self.out_ds.fRasterXSizeWorld / tsize)) + toffsetx + 1 - - tmaxy = int(math.floor( - self.out_ds.fRasterYSizeWorld / tsize)) + toffsety + 1 - self.tsize[tz] = math.ceil(tsize) - #tminx = toffsetx - tminx = int(tmaxx - ((tmaxx - toffsetx) / (0.75))) - 1 - tminy = int(tmaxy - ((tmaxy - toffsety) / (0.75))) - 1 - - self.tminmax[tz] = (tminx, tminy, tmaxx, tmaxy) - # print("tminx", tminx, "tminy", tminy, "tmaxx", tmaxx, "tmaxy", tmaxy, "tz", tz) - - elif self.options.profile == 'raster': - - def log2(x): - return math.log10(x) / math.log10(2) - self.nativezoom = int( - max(math.ceil(log2(self.out_ds.RasterXSize/float(self.tilesize))), - math.ceil(log2(self.out_ds.RasterYSize/float(self.tilesize))))) - - if self.options.verbose: - print("Native zoom of the raster:", self.nativezoom) - - # Get the minimal zoom level (whole raster in one tile) - if self.tminz is None: - self.tminz = 0 - - # Get the maximal zoom level (native resolution of the raster) - if self.tmaxz is None: - self.tmaxz = self.nativezoom - - # Generate table with min max tile coordinates for all zoomlevels - self.tminmax = list(range(0, self.tmaxz+1)) - self.tsize = list(range(0, self.tmaxz+1)) - for tz in range(0, self.tmaxz+1): - tsize = 2.0**(self.tmaxz-tz)*self.tilesize - tminx, tminy = 0, 0 - tmaxx = int(math.ceil(self.out_ds.RasterXSize / tsize)) - 1 - tmaxy = int(math.ceil(self.out_ds.RasterYSize / tsize)) - 1 - self.tsize[tz] = math.ceil(tsize) - self.tminmax[tz] = (tminx, tminy, tmaxx, tmaxy) - - # Function which generates SWNE in LatLong for given tile - if self.kml and in_srs_wkt: - ct = osr.CoordinateTransformation(in_srs, srs4326) - - def rastertileswne(x, y, z): - # X-pixel size in level - pixelsizex = (2**(self.tmaxz-z) * self.out_gt[1]) - west = self.out_gt[0] + x*self.tilesize*pixelsizex - east = west + self.tilesize*pixelsizex - south = self.ominy + y*self.tilesize*pixelsizex - north = south + self.tilesize*pixelsizex - if not isepsg4326: - # Transformation to EPSG:4326 (WGS84 datum) - west, south = ct.TransformPoint(west, south)[:2] - east, north = ct.TransformPoint(east, north)[:2] - return south, west, north, east - - self.tileswne = rastertileswne - else: - self.tileswne = lambda x, y, z: (0, 0, 0, 0) # noqa - - def generate_metadata(self): - """ - Generation of main metadata files and HTML viewers (metadata related to particular - tiles are generated during the tile processing). - """ - - if not os.path.exists(self.output): - os.makedirs(self.output) - - if self.options.profile == 'mercator': - - south, west = self.mercator.MetersToLatLon(self.ominx, self.ominy) - north, east = self.mercator.MetersToLatLon(self.omaxx, self.omaxy) - south, west = max(-85.05112878, south), max(-180.0, west) - north, east = min(85.05112878, north), min(180.0, east) - self.swne = (south, west, north, east) - - # Generate googlemaps.html - if self.options.webviewer in ('all', 'google') and self.options.profile == 'mercator': - if (not self.options.resume or not - os.path.exists(os.path.join(self.output, 'googlemaps.html'))): - f = open(os.path.join(self.output, 'googlemaps.html'), 'wb') - f.write(self.generate_googlemaps().encode('utf-8')) - f.close() - - # Generate openlayers.html - if self.options.webviewer in ('all', 'openlayers'): - if (not self.options.resume or not - os.path.exists(os.path.join(self.output, 'openlayers.html'))): - f = open(os.path.join(self.output, 'openlayers.html'), 'wb') - f.write(self.generate_openlayers().encode('utf-8')) - f.close() - - # Generate leaflet.html - if self.options.webviewer in ('all', 'leaflet'): - if (not self.options.resume or not - os.path.exists(os.path.join(self.output, 'leaflet.html'))): - f = open(os.path.join(self.output, 'leaflet.html'), 'wb') - f.write(self.generate_leaflet().encode('utf-8')) - f.close() - - elif self.options.profile == 'geodetic': - - west, south = self.ominx, self.ominy - east, north = self.omaxx, self.omaxy - south, west = max(-90.0, south), max(-180.0, west) - north, east = min(90.0, north), min(180.0, east) - self.swne = (south, west, north, east) - - # Generate openlayers.html - if self.options.webviewer in ('all', 'openlayers'): - if (not self.options.resume or not - os.path.exists(os.path.join(self.output, 'openlayers.html'))): - f = open(os.path.join(self.output, 'openlayers.html'), 'wb') - f.write(self.generate_openlayers().encode('utf-8')) - f.close() - - elif self.options.profile == 'raster': - - west, south = self.ominx, self.ominy - east, north = self.omaxx, self.omaxy - - # MMGIS - if self.isRasterBounded: - west = self.fminx - east = self.fmaxx - south = self.fminy - north = self.fmaxy - - self.swne = (south, west, north, east) - - # Generate openlayers.html - if self.options.webviewer in ('all', 'openlayers'): - if (not self.options.resume or not - os.path.exists(os.path.join(self.output, 'openlayers.html'))): - f = open(os.path.join(self.output, 'openlayers.html'), 'wb') - f.write(self.generate_openlayers().encode('utf-8')) - f.close() - - # Generate tilemapresource.xml. - if not self.options.resume or not os.path.exists(os.path.join(self.output, 'tilemapresource.xml')): - f = open(os.path.join(self.output, 'tilemapresource.xml'), 'wb') - f.write(self.generate_tilemapresource().encode('utf-8')) - f.close() - - if self.kml: - # TODO: Maybe problem for not automatically generated tminz - # The root KML should contain links to all tiles in the tminz level - children = [] - xmin, ymin, xmax, ymax = self.tminmax[self.tminz] - for x in range(xmin, xmax+1): - for y in range(ymin, ymax+1): - children.append([x, y, self.tminz]) - # Generate Root KML - if self.kml: - if (not self.options.resume or not - os.path.exists(os.path.join(self.output, 'doc.kml'))): - f = open(os.path.join(self.output, 'doc.kml'), 'wb') - f.write(self.generate_kml( - None, None, None, children).encode('utf-8')) - f.close() - - def generate_base_tiles(self, tz): - """ - Generation of the base tiles (the lowest in the pyramid) directly from the input raster - """ - - if self.isDEMtile: - print("Generating Tiles at Zoom " + str(tz) + ": ") - - if not self.options.quiet: - print("Generating Base Tiles:") - - if self.options.verbose: - print('') - print("Tiles generated from the max zoom level:") - print("----------------------------------------") - print('') - - ds = self.out_ds - - querysize = self.querysize - - # 1bto4b - if self.isDEMtile: - tilebands = 4 - querysize = self.tilesize - else: - tilebands = self.dataBandsCount + 1 - tz = self.tmaxz - - try: - self.tminmax[tz] - except IndexError: - print(" Won't make zoom level " + str(tz)) - return - - # Set the bounds - tminx, tminy, tmaxx, tmaxy = self.tminmax[tz] - - if self.options.verbose: - print("dataBandsCount: ", self.dataBandsCount) - print("tilebands: ", tilebands) - - tcount = (1+abs(tmaxx-tminx)) * (1+abs(tmaxy-tminy)) - ti = 0 - - for ty in range(tmaxy, tminy-1, -1): - for tx in range(tminx, tmaxx+1): - - if self.stopped: - break - ti += 1 - tilefilename = os.path.join( - self.output, str(tz), str(tx), "%s.%s" % (ty, self.tileext)) - if self.options.verbose: - print(ti, '/', tcount, tilefilename) - - if self.options.resume and os.path.exists(tilefilename): - if self.options.verbose: - print("Tile generation skipped because of --resume") - else: - self.progressbar(ti / float(tcount)) - continue - - # Create directories for the tile - if not os.path.exists(os.path.dirname(tilefilename)): - os.makedirs(os.path.dirname(tilefilename)) - - if self.options.profile == 'mercator': - # Tile bounds in EPSG:3857 - b = self.mercator.TileBounds(tx, ty, tz) - elif self.options.profile == 'geodetic': - b = self.geodetic.TileBounds(tx, ty, tz) - - # Don't scale up by nearest neighbour, better change the querysize - # to the native resolution (and return smaller query tile) for scaling - - if self.options.profile in ('mercator', 'geodetic'): - rb, wb = self.geo_query(ds, b[0], b[3], b[2], b[1]) - - # Pixel size in the raster covering query geo extent - nativesize = wb[0] + wb[2] - if self.options.verbose: - print("\tNative Extent (querysize", - nativesize, "): ", rb, wb) - - # Tile bounds in raster coordinates for ReadRaster query - rb, wb = self.geo_query( - ds, b[0], b[3], b[2], b[1], querysize=querysize) - - rx, ry, rxsize, rysize = rb - wx, wy, wxsize, wysize = wb - wxsize -= 1 # 1bto4b - wysize -= 1 # 1bto4b - - # MMGIS - elif self.isRasterBounded: # 'raster' profile: - - # tilesize in raster coordinates for actual zoom - tsize = int(self.tsize[tz]) - xsize = self.out_ds.fWorldXSize - ysize = self.out_ds.fWorldYSize - if tz >= self.tmaxz: - querysize = self.tilesize - - rx = (tx) * tsize - self.out_ds.fRasterXOriginWorld - #print("rx", rx) - rxsize = 0 - rxsize = tsize - - rysize = 0 - rysize = tsize - - ry = ysize - (ty * tsize) - rysize - \ - self.out_ds.fRasterYOriginWorld - - wx, wy = 0, 0 - wxsize = int(rxsize/float(tsize) * self.tilesize) - wysize = int(rysize/float(tsize) * self.tilesize) - if wysize != self.tilesize: - wy = self.tilesize - wysize - - if rx < 0: - rxsize = tsize + rx - wx = -rx - wxsize = int(rxsize/float(tsize) * self.tilesize) - rx = 0 - if ry < 0: - rysize = tsize + ry - wy = -ry - wysize = int(rysize/float(tsize) * self.tilesize) - ry = 0 - if rx + rxsize > self.out_ds.fRasterXSizeWorld: - rxsize = self.out_ds.fRasterXSizeWorld - rx - wxsize = int(rxsize/float(tsize) * self.tilesize) - if ry + rysize > self.out_ds.fRasterYSizeWorld: - rysize = self.out_ds.fRasterYSizeWorld - ry - wysize = int(rysize/float(tsize) * self.tilesize) - - # Convert rx, ry back to non-world coordinates - rx = int(float(self.out_ds.RasterXSize) * - (float(rx) / self.out_ds.fRasterXSizeWorld)) - ry = int(float(self.out_ds.RasterYSize) * - (float(ry) / self.out_ds.fRasterYSizeWorld)) - rxsize = int(float(self.out_ds.RasterXSize) * - (float(rxsize) / self.out_ds.fRasterXSizeWorld)) - rysize = int(float(self.out_ds.RasterYSize) * - (float(rysize) / self.out_ds.fRasterYSizeWorld)) - - wxsize -= 1 # 1bto4b - wysize -= 1 # 1bto4b - - #print("Extent: ", (tx, ty, tz, tsize), (rx, ry, rxsize, rysize), (wx, wy, wxsize, wysize), (self.out_ds.fRasterXOrigin, self.out_ds.fRasterYOrigin)) - else: # 'raster' profile: - # tilesize in raster coordinates for actual zoom - tsize = int(self.tsize[tz]) - xsize = self.out_ds.RasterXSize # size of the raster in pixels - ysize = self.out_ds.RasterYSize - if tz >= self.tmaxz: - querysize = self.tilesize - - rx = (tx) * tsize - rxsize = 0 - if tx == tmaxx: - rxsize = xsize % tsize - if rxsize == 0: - rxsize = tsize - - rysize = 0 - if ty == tmaxy: - rysize = ysize % tsize - if rysize == 0: - rysize = tsize - ry = ysize - (ty * tsize) - rysize - - wx, wy = 0, 0 - wxsize = int(rxsize/float(tsize) * self.tilesize) - wysize = int(rysize/float(tsize) * self.tilesize) - if wysize != self.tilesize: - wy = self.tilesize - wysize - - if self.options.verbose: - print("\tReadRaster Extent: ", - (rx, ry, rxsize, rysize), (wx, wy, wxsize, wysize)) - - # Query is in 'nearest neighbour' but can be bigger in then the tilesize - # We scale down the query to the tilesize by supplied algorithm. - - # Tile dataset in memory - - # 1bto4b - if self.isDEMtile: - dstile = self.mem_drv.Create( - '', self.tilesize, self.tilesize, tilebands, gdal.GDT_Byte) - else: - dstile = self.mem_drv.Create( - '', self.tilesize, self.tilesize, tilebands) - - data = alpha = None - # Read the source raster if anything is going inside the tile as per the computed - # geo_query - if rxsize != 0 and rysize != 0 and wxsize != 0 and wysize != 0: - # 1bto4b - if self.isDEMtile: - data = ds.GetRasterBand(1).ReadRaster( - rx, ry, rxsize, rysize, wxsize, wysize, buf_type=gdal.GDT_Float32) - else: - data = ds.ReadRaster(rx, ry, rxsize, rysize, wxsize, wysize, - band_list=list(range(1, self.dataBandsCount+1))) - alpha = self.alphaband.ReadRaster( - rx, ry, rxsize, rysize, wxsize, wysize) - - # The tile in memory is a transparent file by default. Write pixel values into it if - # any - if data: - # 1bto4b - both this full if and else - if self.isDEMtile: - if (wxsize * wysize) > 0: - data = struct.unpack('f' * wxsize * wysize, data) - else: - return - - if self.tilesize == querysize: - # Interpolate the values from four surrounding - - # This takes our 1d list of WxH data and pads it with a rect of none values - dataPad = list(data) - for i in reversed(range(1, wysize)): - dataPad.insert(wxsize * i, 0) - dataPad.insert(wxsize * i, 0) - for i in range(wxsize + 3): - dataPad.insert(0, 0) - for i in range(wxsize + 3): - dataPad.append(0) - - dataIn = [] - # Resample based on average of four - # averaging over: i, i + 1, i + wxsize, i + wxsize + 1 - for y in range(wysize+2 - 1): - for x in range(wxsize+2 - 1): - i = x+(y*(wxsize+2)) - nW = dataPad[i] - nE = dataPad[i+1] - sW = dataPad[i+(wxsize+2)] - sE = dataPad[i+(wxsize+2)+1] - dataIn.append((nW + nE + sW + sE)/float(4)) - - # Get the surrounding eight tiles - # Get NW - if tx - 1 >= tminx and ty + 1 <= tmaxy: - rxNW, ryNW, rxsizeNW, rysizeNW, wxsizeNW, wysizeNW = getTilePxBounds(self, - tx - 1, ty + 1, tz, ds) - wxsizeNW -= 1 - wysizeNW -= 1 - if wxsizeNW != 0 and wysizeNW != 0: - dataNW = ds.GetRasterBand(1).ReadRaster( - rxNW, ryNW, rxsizeNW, rysizeNW, wxsizeNW, wysizeNW, buf_type=gdal.GDT_Float32) - if dataNW is not None and (wxsizeNW * wysizeNW) > 0: - dataNW = struct.unpack( - 'f' * wxsizeNW * wysizeNW, dataNW) - else: - dataNW = None - else: - dataNW = None - - # Get N - if ty + 1 <= tmaxy: - rxN, ryN, rxsizeN, rysizeN, wxsizeN, wysizeN = getTilePxBounds( - self, tx, ty + 1, tz, ds) - wxsizeN -= 1 - wysizeN -= 1 - if wxsizeN != 0 and wysizeN != 0: - dataN = ds.GetRasterBand(1).ReadRaster( - rxN, ryN, rxsizeN, rysizeN, wxsizeN, wysizeN, buf_type=gdal.GDT_Float32) - if dataN is not None and (wxsizeN * wysizeN) > 0: - dataN = struct.unpack( - 'f' * wxsizeN * wysizeN, dataN) - else: - dataN = None - else: - dataN = None - # Get NE - if tx + 1 <= tmaxx and ty + 1 <= tmaxy: - rxNE, ryNE, rxsizeNE, rysizeNE, wxsizeNE, wysizeNE = getTilePxBounds( - self, tx + 1, ty + 1, tz, ds) - wxsizeNE -= 1 - wysizeNE -= 1 - if wxsizeNE != 0 and wysizeNE != 0: - dataNE = ds.GetRasterBand(1).ReadRaster( - rxNE, ryNE, rxsizeNE, rysizeNE, wxsizeNE, wysizeNE, buf_type=gdal.GDT_Float32) - if dataNE is not None and (wxsizeNE * wysizeNE) > 0: - dataNE = struct.unpack( - 'f' * wxsizeNE * wysizeNE, dataNE) - else: - dataNE = None - else: - dataNE = None - # Get E - if tx + 1 <= tmaxx: - rxE, ryE, rxsizeE, rysizeE, wxsizeE, wysizeE = getTilePxBounds( - self, tx + 1, ty, tz, ds) - wxsizeE -= 1 - wysizeE -= 1 - if wxsizeE != 0 and wysizeE != 0: - dataE = ds.GetRasterBand(1).ReadRaster( - rxE, ryE, rxsizeE, rysizeE, wxsizeE, wysizeE, buf_type=gdal.GDT_Float32) - if dataE is not None and (wxsizeE * wysizeE) > 0: - dataE = struct.unpack( - 'f' * wxsizeE * wysizeE, dataE) - else: - dataE = None - else: - dataE = None - # Get SE - if tx + 1 <= tmaxx and ty - 1 >= tminy: - rxSE, rySE, rxsizeSE, rysizeSE, wxsizeSE, wysizeSE = getTilePxBounds( - self, tx + 1, ty - 1, tz, ds) - wxsizeSE -= 1 - wysizeSE -= 1 - if wxsizeSE != 0 and wysizeSE != 0: - dataSE = ds.GetRasterBand(1).ReadRaster( - rxSE, rySE, rxsizeSE, rysizeSE, wxsizeSE, wysizeSE, buf_type=gdal.GDT_Float32) - if dataSE is not None and (wxsizeSE * wysizeSE) > 0: - dataSE = struct.unpack( - 'f' * wxsizeSE * wysizeSE, dataSE) - else: - dataSE = None - else: - dataSE = None - # Get S - if ty - 1 >= tminy: - rxS, ryS, rxsizeS, rysizeS, wxsizeS, wysizeS = getTilePxBounds( - self, tx, ty - 1, tz, ds) - wxsizeS -= 1 - wysizeS -= 1 - if wxsizeS != 0 and wysizeS != 0: - dataS = ds.GetRasterBand(1).ReadRaster( - rxS, ryS, rxsizeS, rysizeS, wxsizeS, wysizeS, buf_type=gdal.GDT_Float32) - if dataS is not None and (wxsizeS * wysizeS) > 0: - dataS = struct.unpack( - 'f' * wxsizeS * wysizeS, dataS) - else: - dataS = None - else: - dataS = None - # Get SW - if tx - 1 >= tminx and ty - 1 >= tminy: - rxSW, rySW, rxsizeSW, rysizeSW, wxsizeSW, wysizeSW = getTilePxBounds( - self, tx - 1, ty - 1, tz, ds) - wxsizeSW -= 1 - wysizeSW -= 1 - if wxsizeSW != 0 and wysizeSW != 0: - dataSW = ds.GetRasterBand(1).ReadRaster( - rxSW, rySW, rxsizeSW, rysizeSW, wxsizeSW, wysizeSW, buf_type=gdal.GDT_Float32) - if dataSW is not None and (wxsizeSW * wysizeSW) > 0: - dataSW = struct.unpack( - 'f' * wxsizeSW * wysizeSW, dataSW) - else: - dataSW = None - else: - dataSW = None - # Get W - if tx - 1 >= tminx: - rxW, ryW, rxsizeW, rysizeW, wxsizeW, wysizeW = getTilePxBounds( - self, tx - 1, ty, tz, ds) - wxsizeW -= 1 - wysizeW -= 1 - if wxsizeW != 0 and wysizeW != 0: - dataW = ds.GetRasterBand(1).ReadRaster( - rxW, ryW, rxsizeW, rysizeW, wxsizeW, wysizeW, buf_type=gdal.GDT_Float32) - if dataW is not None and (wxsizeW * wysizeW) > 0: - dataW = struct.unpack( - 'f' * wxsizeW * wysizeW, dataW) - else: - dataW = None - else: - dataW = None - - # NW (uses N, NW, W) - fN = fNE = fE = fSE = fS = fSW = fW = fNW = 0 - values = 1 - if dataN is not None: - fN = dataN[len(dataN)-wxsizeN] - values = values + 1 - if dataNW is not None: - fNW = dataNW[len(dataNW)-1] - values = values + 1 - if dataW is not None: - fW = dataW[wxsizeW-1] - values = values + 1 - dataIn[0] = ((dataIn[0]*4) + fN + - fNW + fW)/float(values) - - # NE (uses N, NE, E) - fN = fNE = fE = fSE = fS = fSW = fW = fNW = 0 - values = 1 - if dataN is not None: - fN = dataN[len(dataN)-1] - values = values + 1 - if dataNE is not None: - fNE = dataNE[len(dataNE)-wxsizeNE] - values = values + 1 - if dataE is not None: - fE = dataE[0] - values = values + 1 - dataIn[wxsize] = ( - (dataIn[wxsize]*4) + fN + fNE + fE)/float(values) - - # SE (uses S, SE, E) - fN = fNE = fE = fSE = fS = fSW = fW = fNW = 0 - values = 1 - if dataS is not None: - fS = dataS[wxsizeS-1] - values = values + 1 - if dataSE is not None: - fSE = dataSE[0] - values = values + 1 - if dataE is not None: - fE = dataE[len(dataE)-wxsizeE] - values = values + 1 - dataIn[len(dataIn)-1] = ((dataIn[len(dataIn)-1] - * 4) + fS + fSE + fE)/float(values) - - # SW (uses S, SW, W) - fN = fNE = fE = fSE = fS = fSW = fW = fNW = 0 - values = 1 - if dataS is not None: - fS = dataS[0] - values = values + 1 - if dataSW is not None: - fSW = dataSW[wxsizeSW-1] - values = values + 1 - if dataW is not None: - fW = dataW[len(dataW)-1] - values = values + 1 - dataIn[len( - dataIn)-wxsize-1] = ((dataIn[len(dataIn)-wxsize-1]*4) + fS + fSW + fW)/float(values) - - # Then the edges minus corners - # N - if dataN is not None: - for i in range(1, wxsize): - dataIn[i] = ( - (dataIn[i]*4) + dataN[len(dataN)-wxsizeN-1+i] + dataN[len(dataN)-wxsizeN-1+i+1])/float(4) - else: - for i in range(1, wxsize): - dataIn[i] = (dataIn[i]*4)/float(2) - - # E - if dataE is not None: - for i in range(1, wysize): - dataIn[((i+1)*(wxsize+1)-1)] = ((dataIn[((i+1)*(wxsize+1)-1)] - * 4) + dataE[(i-1)*wxsizeE] + dataE[i*wxsizeE])/float(4) - else: - for i in range(1, wysize): - dataIn[( - (i+1)*(wxsize+1)-1)] = (dataIn[((i+1)*(wxsize+1)-1)]*4)/float(2) - - # S - if dataS is not None: - for i in range(1, wxsize): - dataIn[len(dataIn)-wxsize-1+i] = ( - (dataIn[len(dataIn)-wxsize-1+i]*4) + dataS[i-1] + dataS[i])/float(4) - else: - for i in range(1, wxsize): - dataIn[len( - dataIn)-wxsize-1+i] = (dataIn[len(dataIn)-wxsize-1+i]*4)/float(2) - - # W - if dataW is not None: - for i in range(1, wysize): - dataIn[(i)*(wxsize+1)] = ((dataIn[(i)*(wxsize+1)]*4) + - dataW[i*wxsizeW-1] + dataW[(i+1)*wxsizeW-1])/float(4) - else: - for i in range(1, wysize): - dataIn[(i)*(wxsize+1)] = (dataIn[(i) - * (wxsize+1)]*4)/float(2) - - data1 = [] - data2 = [] - data3 = [] - data4 = [] - for f in dataIn: - f = str(binary(f)) - data1.append(int(f[:8], 2)) - data2.append(int(f[8:16], 2)) - data3.append(int(f[16:24], 2)) - data4.append(int(f[24:], 2)) - - data1s = '' - data2s = '' - data3s = '' - data4s = '' - indx = 0 - for v in data1: - data1s += struct.pack('B', data1[indx]) - data2s += struct.pack('B', data2[indx]) - data3s += struct.pack('B', data3[indx]) - data4s += struct.pack('B', data4[indx]) - indx += 1 - dstile.GetRasterBand(1).WriteRaster( - wx, wy, wxsize + 1, wysize + 1, data1s, buf_type=gdal.GDT_Byte) - dstile.GetRasterBand(2).WriteRaster( - wx, wy, wxsize + 1, wysize + 1, data2s, buf_type=gdal.GDT_Byte) - dstile.GetRasterBand(3).WriteRaster( - wx, wy, wxsize + 1, wysize + 1, data3s, buf_type=gdal.GDT_Byte) - dstile.GetRasterBand(4).WriteRaster( - wx, wy, wxsize + 1, wysize + 1, data4s, buf_type=gdal.GDT_Byte) - elif wxsize != 0 and wysize != 0: - # Big ReadRaster query in memory scaled to the tilesize - all but 'near' algo - dsquery = self.mem_drv.Create( - '', querysize, querysize, tilebands, gdal.GDT_Byte) # 1bto4b - # TODO: fill the null value in case a tile without alpha is produced (now only png tiles are supported) - # for i in range(1, tilebands+1): - # dsquery.GetRasterBand(1).Fill(tilenodata) - # dsquery.WriteRaster(wx, wy, wxsize, wysize, data, band_list=list(range(1,self.dataBandsCount+1)))###############1bto4b - # dsquery.WriteRaster(wx, wy, wxsize, wysize, alpha, band_list=[tilebands])###############################1bto4b - - # 1bto4b - data = ds.GetRasterBand(1).ReadRaster( - rx, ry, rxsize, rysize, wxsize, wysize, buf_type=gdal.GDT_Float32) - - data = struct.unpack('f' * wxsize * wysize, data) - data1 = [] - data2 = [] - data3 = [] - data4 = [] - for f in data: - f = str(binary(f)) - data1.append(int(f[:8], 2)) - data2.append(int(f[8:16], 2)) - data3.append(int(f[16:24], 2)) - data4.append(int(f[24:], 2)) - - data1s = '' - data2s = '' - data3s = '' - data4s = '' - indx = 0 - for v in data1: - data1s += struct.pack('B', data1[indx]) - data2s += struct.pack('B', data2[indx]) - data3s += struct.pack('B', data3[indx]) - data4s += struct.pack('B', data4[indx]) - indx += 1 - - dsquery.GetRasterBand(1).WriteRaster( - wx, wy, wxsize, wysize, data1s, buf_type=gdal.GDT_Byte) - dsquery.GetRasterBand(2).WriteRaster( - wx, wy, wxsize, wysize, data2s, buf_type=gdal.GDT_Byte) - dsquery.GetRasterBand(3).WriteRaster( - wx, wy, wxsize, wysize, data3s, buf_type=gdal.GDT_Byte) - dsquery.GetRasterBand(4).WriteRaster( - wx, wy, wxsize, wysize, data4s, buf_type=gdal.GDT_Byte) - # sys.exit('done') - # 1bto4b - - self.scale_query_to_tile( - dsquery, dstile, tilefilename) - del dsquery - - else: - if self.tilesize == querysize: - # Use the ReadRaster result directly in tiles ('nearest neighbour' query) - dstile.WriteRaster(wx, wy, wxsize, wysize, data, - band_list=list(range(1, self.dataBandsCount+1))) - dstile.WriteRaster( - wx, wy, wxsize, wysize, alpha, band_list=[tilebands]) - - # Note: For source drivers based on WaveLet compression (JPEG2000, ECW, - # MrSID) the ReadRaster function returns high-quality raster (not ugly - # nearest neighbour) - # TODO: Use directly 'near' for WaveLet files - else: - # Big ReadRaster query in memory scaled to the tilesize - all but 'near' - # algo - dsquery = self.mem_drv.Create( - '', querysize, querysize, tilebands) - # TODO: fill the null value in case a tile without alpha is produced (now - # only png tiles are supported) - dsquery.WriteRaster(wx, wy, wxsize, wysize, data, - band_list=list(range(1, self.dataBandsCount+1))) - dsquery.WriteRaster( - wx, wy, wxsize, wysize, alpha, band_list=[tilebands]) - - self.scale_query_to_tile( - dsquery, dstile, tilefilename) - del dsquery - - del data - - if self.options.resampling != 'antialias': - # Write a copy of tile to png/jpg - self.out_drv.CreateCopy(tilefilename, dstile, strict=0) - - del dstile - - # Create a KML file for this tile. - if self.kml: - kmlfilename = os.path.join( - self.output, str(tz), str(tx), '%d.kml' % ty) - if not self.options.resume or not os.path.exists(kmlfilename): - f = open(kmlfilename, 'wb') - f.write(self.generate_kml(tx, ty, tz).encode('utf-8')) - f.close() - - if not self.options.verbose and not self.options.quiet: - self.progressbar(ti / float(tcount)) - - def generate_overview_tiles(self): - """Generation of the overview tiles (higher in the pyramid) based on existing tiles""" - - if not self.options.quiet: - print("Generating Overview Tiles:") - - # 1bto4b - if self.isDEMtile: - tilebands = 4 - else: - tilebands = self.dataBandsCount + 1 - - # Usage of existing tiles: from 4 underlying tiles generate one as overview. - - tcount = 0 - for tz in range(self.tmaxz-1, self.tminz-1, -1): - tminx, tminy, tmaxx, tmaxy = self.tminmax[tz] - tcount += (1+abs(tmaxx-tminx)) * (1+abs(tmaxy-tminy)) - - ti = 0 - - for tz in range(self.tmaxz-1, self.tminz-1, -1): - tminx, tminy, tmaxx, tmaxy = self.tminmax[tz] - for ty in range(tmaxy, tminy-1, -1): - for tx in range(tminx, tmaxx+1): - - if self.stopped: - break - - ti += 1 - tilefilename = os.path.join(self.output, - str(tz), - str(tx), - "%s.%s" % (ty, self.tileext)) - - if self.options.verbose: - print(ti, '/', tcount, tilefilename) - - if self.options.resume and os.path.exists(tilefilename): - if self.options.verbose: - print("Tile generation skipped because of --resume") - else: - self.progressbar(ti / float(tcount)) - continue - - # Create directories for the tile - if not os.path.exists(os.path.dirname(tilefilename)): - os.makedirs(os.path.dirname(tilefilename)) - - dsquery = self.mem_drv.Create( - '', 2*self.tilesize, 2*self.tilesize, tilebands) - # TODO: fill the null value - dstile = self.mem_drv.Create( - '', self.tilesize, self.tilesize, tilebands) - - # TODO: Implement more clever walking on the tiles with cache functionality - # probably walk should start with reading of four tiles from top left corner - # Hilbert curve - - children = [] - # Read the tiles and write them to query window - for y in range(2*ty, 2*ty+2): - for x in range(2*tx, 2*tx+2): - minx, miny, maxx, maxy = self.tminmax[tz+1] - if x >= minx and x <= maxx and y >= miny and y <= maxy: - dsquerytile = gdal.Open( - os.path.join(self.output, str(tz+1), str(x), - "%s.%s" % (y, self.tileext)), - gdal.GA_ReadOnly) - if (ty == 0 and y == 1) or (ty != 0 and (y % (2*ty)) != 0): - tileposy = 0 - else: - tileposy = self.tilesize - if tx: - tileposx = x % (2*tx) * self.tilesize - elif tx == 0 and x == 1: - tileposx = self.tilesize - else: - tileposx = 0 - dsquery.WriteRaster( - tileposx, tileposy, self.tilesize, self.tilesize, - dsquerytile.ReadRaster( - 0, 0, self.tilesize, self.tilesize), - band_list=list(range(1, tilebands+1))) - children.append([x, y, tz+1]) - - self.scale_query_to_tile(dsquery, dstile, tilefilename) - # Write a copy of tile to png/jpg - if self.options.resampling != 'antialias': - # Write a copy of tile to png/jpg - self.out_drv.CreateCopy(tilefilename, dstile, strict=0) - - if self.options.verbose: - print("\tbuild from zoom", tz+1, - " tiles:", (2*tx, 2*ty), (2*tx+1, 2*ty), - (2*tx, 2*ty+1), (2*tx+1, 2*ty+1)) - - # Create a KML file for this tile. - if self.kml: - f = open(os.path.join( - self.output, '%d/%d/%d.kml' % (tz, tx, ty)), 'wb') - f.write(self.generate_kml( - tx, ty, tz, children).encode('utf-8')) - f.close() - - if not self.options.verbose and not self.options.quiet: - self.progressbar(ti / float(tcount)) - - def geo_query(self, ds, ulx, uly, lrx, lry, querysize=0): - """ - For given dataset and query in cartographic coordinates returns parameters for ReadRaster() - in raster coordinates and x/y shifts (for border tiles). If the querysize is not given, the - extent is returned in the native resolution of dataset ds. - - raises Gdal2TilesError if the dataset does not contain anything inside this geo_query - """ - geotran = ds.GetGeoTransform() - rx = int((ulx - geotran[0]) / geotran[1] + 0.001) - ry = int((uly - geotran[3]) / geotran[5] + 0.001) - rxsize = int((lrx - ulx) / geotran[1] + 0.5) - rysize = int((lry - uly) / geotran[5] + 0.5) - - if not querysize: - wxsize, wysize = rxsize, rysize - else: - wxsize, wysize = querysize, querysize - - # Coordinates should not go out of the bounds of the raster - wx = 0 - if rx < 0: - rxshift = abs(rx) - wx = int(wxsize * (float(rxshift) / rxsize)) - wxsize = wxsize - wx - rxsize = rxsize - int(rxsize * (float(rxshift) / rxsize)) - rx = 0 - if rx+rxsize > ds.RasterXSize: - wxsize = int(wxsize * (float(ds.RasterXSize - rx) / rxsize)) - rxsize = ds.RasterXSize - rx - - wy = 0 - if ry < 0: - ryshift = abs(ry) - wy = int(wysize * (float(ryshift) / rysize)) - wysize = wysize - wy - rysize = rysize - int(rysize * (float(ryshift) / rysize)) - ry = 0 - if ry+rysize > ds.RasterYSize: - wysize = int(wysize * (float(ds.RasterYSize - ry) / rysize)) - rysize = ds.RasterYSize - ry - - return (rx, ry, rxsize, rysize), (wx, wy, wxsize, wysize) - - def scale_query_to_tile(self, dsquery, dstile, tilefilename=''): - """Scales down query dataset to the tile dataset""" - - querysize = dsquery.RasterXSize - tilesize = dstile.RasterXSize - tilebands = dstile.RasterCount - - if self.options.resampling == 'average': - - # Function: gdal.RegenerateOverview() - for i in range(1, tilebands+1): - # Black border around NODATA - res = gdal.RegenerateOverview(dsquery.GetRasterBand(i), dstile.GetRasterBand(i), - 'average') - if res != 0: - self.error("RegenerateOverview() failed on %s, error %d" % ( - tilefilename, res)) - - elif self.options.resampling == 'antialias': - - # Scaling by PIL (Python Imaging Library) - improved Lanczos - array = numpy.zeros((querysize, querysize, tilebands), numpy.uint8) - for i in range(tilebands): - array[:, :, i] = gdalarray.BandReadAsArray(dsquery.GetRasterBand(i+1), - 0, 0, querysize, querysize) - im = Image.fromarray(array, 'RGBA') # Always four bands - im1 = im.resize((tilesize, tilesize), Image.ANTIALIAS) - if os.path.exists(tilefilename): - im0 = Image.open(tilefilename) - im1 = Image.composite(im1, im0, im1) - im1.save(tilefilename, self.tiledriver) - - else: - - # Other algorithms are implemented by gdal.ReprojectImage(). - dsquery.SetGeoTransform((0.0, tilesize / float(querysize), 0.0, 0.0, 0.0, - tilesize / float(querysize))) - dstile.SetGeoTransform((0.0, 1.0, 0.0, 0.0, 0.0, 1.0)) - - res = gdal.ReprojectImage( - dsquery, dstile, None, None, self.resampling) - if res != 0: - self.error("ReprojectImage() failed on %s, error %d" % - (tilefilename, res)) - - def generate_tilemapresource(self): - """ - Template for tilemapresource.xml. Returns filled string. Expected variables: - title, north, south, east, west, isepsg4326, projection, publishurl, - zoompixels, tilesize, tileformat, profile - """ - - args = {} - args['title'] = self.options.title - args['south'], args['west'], args['north'], args['east'] = self.swne - args['tilesize'] = self.tilesize - args['tileformat'] = self.tileext - args['publishurl'] = self.options.url - args['profile'] = self.options.profile - - if self.options.profile == 'mercator': - args['srs'] = "EPSG:3857" - elif self.options.profile == 'geodetic': - args['srs'] = "EPSG:4326" - elif self.options.s_srs: - args['srs'] = self.options.s_srs - elif self.out_srs: - args['srs'] = self.out_srs.ExportToWkt() - else: - args['srs'] = "" - - s = """<?xml version="1.0" encoding="utf-8"?> - <TileMap version="1.0.0" tilemapservice="http://tms.osgeo.org/1.0.0"> - <Title>%(title)s</Title> - <Abstract></Abstract> - <SRS>%(srs)s</SRS> - <BoundingBox minx="%(west).14f" miny="%(south).14f" maxx="%(east).14f" maxy="%(north).14f"/> - <Origin x="%(west).14f" y="%(south).14f"/> - <TileFormat width="%(tilesize)d" height="%(tilesize)d" mime-type="image/%(tileformat)s" extension="%(tileformat)s"/> - <TileSets profile="%(profile)s"> -""" % args # noqa - for z in range(self.tminz, self.tmaxz+1): - if self.options.profile == 'raster': - s += """ <TileSet href="%s%d" units-per-pixel="%.14f" order="%d"/>\n""" % ( - args['publishurl'], z, (2**(self.nativezoom-z) * self.out_gt[1]), z) - elif self.options.profile == 'mercator': - s += """ <TileSet href="%s%d" units-per-pixel="%.14f" order="%d"/>\n""" % ( - args['publishurl'], z, 156543.0339/2**z, z) - elif self.options.profile == 'geodetic': - s += """ <TileSet href="%s%d" units-per-pixel="%.14f" order="%d"/>\n""" % ( - args['publishurl'], z, 0.703125/2**z, z) - s += """ </TileSets> - </TileMap> - """ - return s - - def generate_kml(self, tx, ty, tz, children=None, **args): - """ - Template for the KML. Returns filled string. - """ - if not children: - children = [] - - args['tx'], args['ty'], args['tz'] = tx, ty, tz - args['tileformat'] = self.tileext - if 'tilesize' not in args: - args['tilesize'] = self.tilesize - - if 'minlodpixels' not in args: - args['minlodpixels'] = int(args['tilesize'] / 2) - if 'maxlodpixels' not in args: - args['maxlodpixels'] = int(args['tilesize'] * 8) - if children == []: - args['maxlodpixels'] = -1 - - if tx is None: - tilekml = False - args['title'] = self.options.title - else: - tilekml = True - args['title'] = "%d/%d/%d.kml" % (tz, tx, ty) - args['south'], args['west'], args['north'], args['east'] = self.tileswne( - tx, ty, tz) - - if tx == 0: - args['drawOrder'] = 2 * tz + 1 - elif tx is not None: - args['drawOrder'] = 2 * tz - else: - args['drawOrder'] = 0 - - url = self.options.url - if not url: - if tilekml: - url = "../../" - else: - url = "" - - s = """<?xml version="1.0" encoding="utf-8"?> - <kml xmlns="http://www.opengis.net/kml/2.2"> - <Document> - <name>%(title)s</name> - <description></description> - <Style> - <ListStyle id="hideChildren"> - <listItemType>checkHideChildren</listItemType> - </ListStyle> - </Style>""" % args - if tilekml: - s += """ - <Region> - <LatLonAltBox> - <north>%(north).14f</north> - <south>%(south).14f</south> - <east>%(east).14f</east> - <west>%(west).14f</west> - </LatLonAltBox> - <Lod> - <minLodPixels>%(minlodpixels)d</minLodPixels> - <maxLodPixels>%(maxlodpixels)d</maxLodPixels> - </Lod> - </Region> - <GroundOverlay> - <drawOrder>%(drawOrder)d</drawOrder> - <Icon> - <href>%(ty)d.%(tileformat)s</href> - </Icon> - <LatLonBox> - <north>%(north).14f</north> - <south>%(south).14f</south> - <east>%(east).14f</east> - <west>%(west).14f</west> - </LatLonBox> - </GroundOverlay> - """ % args - - for cx, cy, cz in children: - csouth, cwest, cnorth, ceast = self.tileswne(cx, cy, cz) - s += """ - <NetworkLink> - <name>%d/%d/%d.%s</name> - <Region> - <LatLonAltBox> - <north>%.14f</north> - <south>%.14f</south> - <east>%.14f</east> - <west>%.14f</west> - </LatLonAltBox> - <Lod> - <minLodPixels>%d</minLodPixels> - <maxLodPixels>-1</maxLodPixels> - </Lod> - </Region> - <Link> - <href>%s%d/%d/%d.kml</href> - <viewRefreshMode>onRegion</viewRefreshMode> - <viewFormat/> - </Link> - </NetworkLink> - """ % (cz, cx, cy, args['tileformat'], cnorth, csouth, ceast, cwest, - args['minlodpixels'], url, cz, cx, cy) - - s += """ </Document> - </kml> - """ - return s - - def generate_googlemaps(self): - """ - Template for googlemaps.html implementing Overlay of tiles for 'mercator' profile. - It returns filled string. Expected variables: - title, googlemapskey, north, south, east, west, minzoom, maxzoom, tilesize, tileformat, - publishurl - """ - args = {} - args['title'] = self.options.title - args['googlemapskey'] = self.options.googlekey - args['south'], args['west'], args['north'], args['east'] = self.swne - args['minzoom'] = self.tminz - args['maxzoom'] = self.tmaxz - args['tilesize'] = self.tilesize - args['tileformat'] = self.tileext - args['publishurl'] = self.options.url - args['copyright'] = self.options.copyright - - s = r"""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> - <head> - <title>%(title)s</title> - <meta http-equiv="content-type" content="text/html; charset=utf-8"/> - <meta http-equiv='imagetoolbar' content='no'/> - <style type="text/css"> v\:* {behavior:url(#default#VML);} - html, body { overflow: hidden; padding: 0; height: 100%%; width: 100%%; font-family: 'Lucida Grande',Geneva,Arial,Verdana,sans-serif; } - body { margin: 10px; background: #fff; } - h1 { margin: 0; padding: 6px; border:0; font-size: 20pt; } - # header { height: 43px; padding: 0; background-color: #eee; border: 1px solid #888; } - # subheader { height: 12px; text-align: right; font-size: 10px; color: #555;} - # map { height: 95%%; border: 1px solid #888; } - </style> - <script src='http://maps.google.com/maps?file=api&v=2&key=%(googlemapskey)s'></script> - <script> - //<![CDATA[ - - /* - * Constants for given map - * TODO: read it from tilemapresource.xml - */ - - var mapBounds = new GLatLngBounds(new GLatLng(%(south)s, %(west)s), new GLatLng(%(north)s, %(east)s)); - var mapMinZoom = %(minzoom)s; - var mapMaxZoom = %(maxzoom)s; - - var opacity = 0.75; - var map; - var hybridOverlay; - - /* - * Create a Custom Opacity GControl - * http://www.maptiler.org/google-maps-overlay-opacity-control/ - */ - - var CTransparencyLENGTH = 58; - // maximum width that the knob can move (slide width minus knob width) - - function CTransparencyControl( overlay ) { - this.overlay = overlay; - this.opacity = overlay.getTileLayer().getOpacity(); - } - CTransparencyControl.prototype = new GControl(); - - // This function positions the slider to match the specified opacity - CTransparencyControl.prototype.setSlider = function(pos) { - var left = Math.round((CTransparencyLENGTH*pos)); - this.slide.left = left; - this.knob.style.left = left+"px"; - this.knob.style.top = "0px"; - } - - // This function reads the slider and sets the overlay opacity level - CTransparencyControl.prototype.setOpacity = function() { - // set the global variable - opacity = this.slide.left/CTransparencyLENGTH; - this.map.clearOverlays(); - this.map.addOverlay(this.overlay, { zPriority: 0 }); - if (this.map.getCurrentMapType() == G_HYBRID_MAP) { - this.map.addOverlay(hybridOverlay); - } - } - - // This gets called by the API when addControl(new CTransparencyControl()) - CTransparencyControl.prototype.initialize = function(map) { - var that=this; - this.map = map; - - // Is this MSIE, if so we need to use AlphaImageLoader - var agent = navigator.userAgent.toLowerCase(); - if ((agent.indexOf("msie") > -1) && (agent.indexOf("opera") < 1)){this.ie = true} else {this.ie = false} - - // create the background graphic as a <div> containing an image - var container = document.createElement("div"); - container.style.width="70px"; - container.style.height="21px"; - - // Handle transparent PNG files in MSIE - if (this.ie) { - var loader = "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://www.maptiler.org/img/opacity-slider.png', sizingMethod='crop');"; - container.innerHTML = '<div style="height:21px; width:70px; ' +loader+ '" ></div>'; - } else { - container.innerHTML = '<div style="height:21px; width:70px; background-image: url(http://www.maptiler.org/img/opacity-slider.png)" ></div>'; - } - - // create the knob as a GDraggableObject - // Handle transparent PNG files in MSIE - if (this.ie) { - var loader = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://www.maptiler.org/img/opacity-slider.png', sizingMethod='crop');"; - this.knob = document.createElement("div"); - this.knob.style.height="21px"; - this.knob.style.width="13px"; - this.knob.style.overflow="hidden"; - this.knob_img = document.createElement("div"); - this.knob_img.style.height="21px"; - this.knob_img.style.width="83px"; - this.knob_img.style.filter=loader; - this.knob_img.style.position="relative"; - this.knob_img.style.left="-70px"; - this.knob.appendChild(this.knob_img); - } else { - this.knob = document.createElement("div"); - this.knob.style.height="21px"; - this.knob.style.width="13px"; - this.knob.style.backgroundImage="url(http://www.maptiler.org/img/opacity-slider.png)"; - this.knob.style.backgroundPosition="-70px 0px"; - } - container.appendChild(this.knob); - this.slide=new GDraggableObject(this.knob, {container:container}); - this.slide.setDraggableCursor('pointer'); - this.slide.setDraggingCursor('pointer'); - this.container = container; - - // attach the control to the map - map.getContainer().appendChild(container); - - // init slider - this.setSlider(this.opacity); - - // Listen for the slider being moved and set the opacity - GEvent.addListener(this.slide, "dragend", function() {that.setOpacity()}); - //GEvent.addListener(this.container, "click", function( x, y ) { alert(x, y) }); - - return container; - } - - // Set the default position for the control - CTransparencyControl.prototype.getDefaultPosition = function() { - return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 47)); - } - - /* - * Full-screen Window Resize - */ - - function getWindowHeight() { - if (self.innerHeight) return self.innerHeight; - if (document.documentElement && document.documentElement.clientHeight) - return document.documentElement.clientHeight; - if (document.body) return document.body.clientHeight; - return 0; - } - - function getWindowWidth() { - if (self.innerWidth) return self.innerWidth; - if (document.documentElement && document.documentElement.clientWidth) - return document.documentElement.clientWidth; - if (document.body) return document.body.clientWidth; - return 0; - } - - function resize() { - var map = document.getElementById("map"); - var header = document.getElementById("header"); - var subheader = document.getElementById("subheader"); - map.style.height = (getWindowHeight()-80) + "px"; - map.style.width = (getWindowWidth()-20) + "px"; - header.style.width = (getWindowWidth()-20) + "px"; - subheader.style.width = (getWindowWidth()-20) + "px"; - // map.checkResize(); - } - - - /* - * Main load function: - */ - - function load() { - - if (GBrowserIsCompatible()) { - - // Bug in the Google Maps: Copyright for Overlay is not correctly displayed - var gcr = GMapType.prototype.getCopyrights; - GMapType.prototype.getCopyrights = function(bounds,zoom) { - return ["%(copyright)s"].concat(gcr.call(this,bounds,zoom)); - } - - map = new GMap2( document.getElementById("map"), { backgroundColor: '#fff' } ); - - map.addMapType(G_PHYSICAL_MAP); - map.setMapType(G_PHYSICAL_MAP); - - map.setCenter( mapBounds.getCenter(), map.getBoundsZoomLevel( mapBounds )); - - hybridOverlay = new GTileLayerOverlay( G_HYBRID_MAP.getTileLayers()[1] ); - GEvent.addListener(map, "maptypechanged", function() { - if (map.getCurrentMapType() == G_HYBRID_MAP) { - map.addOverlay(hybridOverlay); - } else { - map.removeOverlay(hybridOverlay); - } - } ); - - var tilelayer = new GTileLayer(GCopyrightCollection(''), mapMinZoom, mapMaxZoom); - var mercator = new GMercatorProjection(mapMaxZoom+1); - tilelayer.getTileUrl = function(tile,zoom) { - if ((zoom < mapMinZoom) || (zoom > mapMaxZoom)) { - return "http://www.maptiler.org/img/none.png"; - } - var ymax = 1 << zoom; - var y = ymax - tile.y -1; - var tileBounds = new GLatLngBounds( - mercator.fromPixelToLatLng( new GPoint( (tile.x)*256, (tile.y+1)*256 ) , zoom ), - mercator.fromPixelToLatLng( new GPoint( (tile.x+1)*256, (tile.y)*256 ) , zoom ) - ); - if (mapBounds.intersects(tileBounds)) { - return zoom+"/"+tile.x+"/"+y+".png"; - } else { - return "http://www.maptiler.org/img/none.png"; - } - } - // IE 7-: support for PNG alpha channel - // Unfortunately, the opacity for whole overlay is then not changeable, either or... - tilelayer.isPng = function() { return true;}; - tilelayer.getOpacity = function() { return opacity; } - - overlay = new GTileLayerOverlay( tilelayer ); - map.addOverlay(overlay); - - map.addControl(new GLargeMapControl()); - map.addControl(new GHierarchicalMapTypeControl()); - map.addControl(new CTransparencyControl( overlay )); - """ % args # noqa - if self.kml: - s += """ - map.addMapType(G_SATELLITE_3D_MAP); - map.getEarthInstance(getEarthInstanceCB); - """ - s += """ - - map.enableContinuousZoom(); - map.enableScrollWheelZoom(); - - map.setMapType(G_HYBRID_MAP); - } - resize(); - } - """ - if self.kml: - s += """ - function getEarthInstanceCB(object) { - var ge = object; - - if (ge) { - var url = document.location.toString(); - url = url.substr(0,url.lastIndexOf('/'))+'/doc.kml'; - var link = ge.createLink(""); - if ("%(publishurl)s") { link.setHref("%(publishurl)s/doc.kml") } - else { link.setHref(url) }; - var networkLink = ge.createNetworkLink(""); - networkLink.setName("TMS Map Overlay"); - networkLink.setFlyToView(true); - networkLink.setLink(link); - ge.getFeatures().appendChild(networkLink); - } else { - // alert("You should open a KML in Google Earth"); - // add div with the link to generated KML... - maybe JavaScript redirect to the URL of KML? - } - } - """ % args # noqa - s += """ - onresize=function(){ resize(); }; - - //]]> - </script> - </head> - <body onload="load()"> - <div id="header"><h1>%(title)s</h1></div> - <div id="subheader">Generated by <a href="http://www.klokan.cz/projects/gdal2tiles/">GDAL2Tiles</a>, Copyright © 2008 <a href="http://www.klokan.cz/">Klokan Petr Pridal</a>, <a href="http://www.gdal.org/">GDAL</a> & <a href="http://www.osgeo.org/">OSGeo</a> <a href="http://code.google.com/soc/">GSoC</a> - <!-- PLEASE, LET THIS NOTE ABOUT AUTHOR AND PROJECT SOMEWHERE ON YOUR WEBSITE, OR AT LEAST IN THE COMMENT IN HTML. THANK YOU --> - </div> - <div id="map"></div> - </body> - </html> - """ % args # noqa - - return s - - def generate_leaflet(self): - """ - Template for leaflet.html implementing overlay of tiles for 'mercator' profile. - It returns filled string. Expected variables: - title, north, south, east, west, minzoom, maxzoom, tilesize, tileformat, publishurl - """ - - args = {} - args['title'] = self.options.title.replace('"', '\\"') - args['htmltitle'] = self.options.title - args['south'], args['west'], args['north'], args['east'] = self.swne - args['centerlon'] = (args['north'] + args['south']) / 2. - args['centerlat'] = (args['west'] + args['east']) / 2. - args['minzoom'] = self.tminz - args['maxzoom'] = self.tmaxz - args['beginzoom'] = self.tmaxz - args['tilesize'] = self.tilesize # not used - args['tileformat'] = self.tileext - args['publishurl'] = self.options.url # not used - args['copyright'] = self.options.copyright.replace('"', '\\"') - - s = """<!DOCTYPE html> - <html lang="en"> - <head> - <meta charset="utf-8"> - <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' /> - <title>%(htmltitle)s</title> - - <!-- Leaflet --> - <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.css" /> - <script src="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.js"></script> - - <style> - body { margin:0; padding:0; } - body, table, tr, td, th, div, h1, h2, input { font-family: "Calibri", "Trebuchet MS", "Ubuntu", Serif; font-size: 11pt; } - # map { position:absolute; top:0; bottom:0; width:100%%; } /* full size */ - .ctl { - padding: 2px 10px 2px 10px; - background: white; - background: rgba(255,255,255,0.9); - box-shadow: 0 0 15px rgba(0,0,0,0.2); - border-radius: 5px; - text-align: right; - } - .title { - font-size: 18pt; - font-weight: bold; - } - .src { - font-size: 10pt; - } - - </style> - - </head> - <body> - - <div id="map"></div> - - <script> - /* **** Leaflet **** */ - - // Base layers - // .. OpenStreetMap - var osm = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'}); - - // .. CartoDB Positron - var cartodb = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a href="http://cartodb.com/attributions">CartoDB</a>'}); - - // .. OSM Toner - var toner = L.tileLayer('http://{s}.tile.stamen.com/toner/{z}/{x}/{y}.png', {attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.'}); - - // .. White background - var white = L.tileLayer("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAAA1BMVEX///+nxBvIAAAAH0lEQVQYGe3BAQ0AAADCIPunfg43YAAAAAAAAAAA5wIhAAAB9aK9BAAAAABJRU5ErkJggg=="); - - // Overlay layers (TMS) - var lyr = L.tileLayer('./{z}/{x}/{y}.%(tileformat)s', {tms: true, opacity: 0.7, attribution: "%(copyright)s"}); - - // Map - var map = L.map('map', { - center: [%(centerlon)s, %(centerlat)s], - zoom: %(beginzoom)s, - minZoom: %(minzoom)s, - maxZoom: %(maxzoom)s, - layers: [osm] - }); - - var basemaps = {"OpenStreetMap": osm, "CartoDB Positron": cartodb, "Stamen Toner": toner, "Without background": white} - var overlaymaps = {"Layer": lyr} - - // Title - var title = L.control(); - title.onAdd = function(map) { - this._div = L.DomUtil.create('div', 'ctl title'); - this.update(); - return this._div; - }; - title.update = function(props) { - this._div.innerHTML = "%(title)s"; - }; - title.addTo(map); - - // Note - var src = 'Generated by <a href="http://www.klokan.cz/projects/gdal2tiles/">GDAL2Tiles</a>, Copyright © 2008 <a href="http://www.klokan.cz/">Klokan Petr Pridal</a>, <a href="http://www.gdal.org/">GDAL</a> & <a href="http://www.osgeo.org/">OSGeo</a> <a href="http://code.google.com/soc/">GSoC</a>'; - var title = L.control({position: 'bottomleft'}); - title.onAdd = function(map) { - this._div = L.DomUtil.create('div', 'ctl src'); - this.update(); - return this._div; - }; - title.update = function(props) { - this._div.innerHTML = src; - }; - title.addTo(map); - - - // Add base layers - L.control.layers(basemaps, overlaymaps, {collapsed: false}).addTo(map); - - // Fit to overlay bounds (SW and NE points with (lat, lon)) - map.fitBounds([[%(south)s, %(east)s], [%(north)s, %(west)s]]); - - </script> - - </body> - </html> - - """ % args # noqa - - return s - - def generate_openlayers(self): - """ - Template for openlayers.html implementing overlay of available Spherical Mercator layers. - - It returns filled string. Expected variables: - title, bingkey, north, south, east, west, minzoom, maxzoom, tilesize, tileformat, publishurl - """ - - args = {} - args['title'] = self.options.title - args['bingkey'] = self.options.bingkey - args['south'], args['west'], args['north'], args['east'] = self.swne - args['minzoom'] = self.tminz - args['maxzoom'] = self.tmaxz - args['tilesize'] = self.tilesize - args['tileformat'] = self.tileext - args['publishurl'] = self.options.url - args['copyright'] = self.options.copyright - if self.options.tmscompatible: - args['tmsoffset'] = "-1" - else: - args['tmsoffset'] = "" - if self.options.profile == 'raster': - args['rasterzoomlevels'] = self.tmaxz+1 - args['rastermaxresolution'] = 2**(self.nativezoom) * self.out_gt[1] - - s = r"""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - <html xmlns="http://www.w3.org/1999/xhtml" - <head> - <title>%(title)s</title> - <meta http-equiv='imagetoolbar' content='no'/> - <style type="text/css"> v\:* {behavior:url(#default#VML);} - html, body { overflow: hidden; padding: 0; height: 100%%; width: 100%%; font-family: 'Lucida Grande',Geneva,Arial,Verdana,sans-serif; } - body { margin: 10px; background: #fff; } - h1 { margin: 0; padding: 6px; border:0; font-size: 20pt; } - # header { height: 43px; padding: 0; background-color: #eee; border: 1px solid #888; } - # subheader { height: 12px; text-align: right; font-size: 10px; color: #555;} - # map { height: 95%%; border: 1px solid #888; } - .olImageLoadError { display: none; } - .olControlLayerSwitcher .layersDiv { border-radius: 10px 0 0 10px; } - </style>""" % args # noqa - - if self.options.profile == 'mercator': - s += """ - <script src='http://maps.google.com/maps/api/js?sensor=false&v=3.7'></script> - """ % args - - s += """ - <script src="http://www.openlayers.org/api/2.12/OpenLayers.js"></script> - <script> - var map; - var mapBounds = new OpenLayers.Bounds( %(west)s, %(south)s, %(east)s, %(north)s); - var mapMinZoom = %(minzoom)s; - var mapMaxZoom = %(maxzoom)s; - var emptyTileURL = "http://www.maptiler.org/img/none.png"; - OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3; - - function init(){""" % args - - if self.options.profile == 'mercator': - s += """ - var options = { - div: "map", - controls: [], - projection: "EPSG:3857", - displayProjection: new OpenLayers.Projection("EPSG:4326"), - numZoomLevels: 20 - }; - map = new OpenLayers.Map(options); - - // Create Google Mercator layers - var gmap = new OpenLayers.Layer.Google("Google Streets", - { - type: google.maps.MapTypeId.ROADMAP, - sphericalMercator: true - }); - var gsat = new OpenLayers.Layer.Google("Google Satellite", - { - type: google.maps.MapTypeId.SATELLITE, - sphericalMercator: true - }); - var ghyb = new OpenLayers.Layer.Google("Google Hybrid", - { - type: google.maps.MapTypeId.HYBRID, - sphericalMercator: true - }); - var gter = new OpenLayers.Layer.Google("Google Terrain", - { - type: google.maps.MapTypeId.TERRAIN, - sphericalMercator: true - }); - - // Create Bing layers - var broad = new OpenLayers.Layer.Bing({ - name: "Bing Roads", - key: "%(bingkey)s", - type: "Road", - sphericalMercator: true - }); - var baer = new OpenLayers.Layer.Bing({ - name: "Bing Aerial", - key: "%(bingkey)s", - type: "Aerial", - sphericalMercator: true - }); - var bhyb = new OpenLayers.Layer.Bing({ - name: "Bing Hybrid", - key: "%(bingkey)s", - type: "AerialWithLabels", - sphericalMercator: true - }); - - // Create OSM layer - var osm = new OpenLayers.Layer.OSM("OpenStreetMap"); - - // create TMS Overlay layer - var tmsoverlay = new OpenLayers.Layer.TMS("TMS Overlay", "", - { - serviceVersion: '.', - layername: '.', - alpha: true, - type: '%(tileformat)s', - isBaseLayer: false, - getURL: getURL - }); - if (OpenLayers.Util.alphaHack() == false) { - tmsoverlay.setOpacity(0.7); - } - - map.addLayers([gmap, gsat, ghyb, gter, - broad, baer, bhyb, - osm, tmsoverlay]); - - var switcherControl = new OpenLayers.Control.LayerSwitcher(); - map.addControl(switcherControl); - switcherControl.maximizeControl(); - - map.zoomToExtent(mapBounds.transform(map.displayProjection, map.projection)); - """ % args # noqa - - elif self.options.profile == 'geodetic': - s += """ - var options = { - div: "map", - controls: [], - projection: "EPSG:4326" - }; - map = new OpenLayers.Map(options); - - var wms = new OpenLayers.Layer.WMS("VMap0", - "http://tilecache.osgeo.org/wms-c/Basic.py?", - { - layers: 'basic', - format: 'image/png' - } - ); - var tmsoverlay = new OpenLayers.Layer.TMS("TMS Overlay", "", - { - serviceVersion: '.', - layername: '.', - alpha: true, - type: '%(tileformat)s', - isBaseLayer: false, - getURL: getURL - }); - if (OpenLayers.Util.alphaHack() == false) { - tmsoverlay.setOpacity(0.7); - } - - map.addLayers([wms,tmsoverlay]); - - var switcherControl = new OpenLayers.Control.LayerSwitcher(); - map.addControl(switcherControl); - switcherControl.maximizeControl(); - - map.zoomToExtent(mapBounds); - """ % args # noqa - - elif self.options.profile == 'raster': - s += """ - var options = { - div: "map", - controls: [], - maxExtent: new OpenLayers.Bounds(%(west)s, %(south)s, %(east)s, %(north)s), - maxResolution: %(rastermaxresolution)f, - numZoomLevels: %(rasterzoomlevels)d - }; - map = new OpenLayers.Map(options); - - var layer = new OpenLayers.Layer.TMS("TMS Layer", "", - { - serviceVersion: '.', - layername: '.', - alpha: true, - type: '%(tileformat)s', - getURL: getURL - }); - - map.addLayer(layer); - map.zoomToExtent(mapBounds); - """ % args # noqa - - s += """ - map.addControls([new OpenLayers.Control.PanZoomBar(), - new OpenLayers.Control.Navigation(), - new OpenLayers.Control.MousePosition(), - new OpenLayers.Control.ArgParser(), - new OpenLayers.Control.Attribution()]); - } - """ % args - - if self.options.profile == 'mercator': - s += """ - function getURL(bounds) { - bounds = this.adjustBounds(bounds); - var res = this.getServerResolution(); - var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w)); - var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h)); - var z = this.getServerZoom(); - if (this.map.baseLayer.CLASS_NAME === 'OpenLayers.Layer.Bing') { - z+=1; - } - var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type; - var url = this.url; - if (OpenLayers.Util.isArray(url)) { - url = this.selectUrl(path, url); - } - if (mapBounds.intersectsBounds(bounds) && (z >= mapMinZoom) && (z <= mapMaxZoom)) { - return url + path; - } else { - return emptyTileURL; - } - } - """ % args # noqa - - elif self.options.profile == 'geodetic': - s += """ - function getURL(bounds) { - bounds = this.adjustBounds(bounds); - var res = this.getServerResolution(); - var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w)); - var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h)); - var z = this.getServerZoom()%(tmsoffset)s; - var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type; - var url = this.url; - if (OpenLayers.Util.isArray(url)) { - url = this.selectUrl(path, url); - } - if (mapBounds.intersectsBounds(bounds) && (z >= mapMinZoom) && (z <= mapMaxZoom)) { - return url + path; - } else { - return emptyTileURL; - } - } - """ % args # noqa - - elif self.options.profile == 'raster': - s += """ - function getURL(bounds) { - bounds = this.adjustBounds(bounds); - var res = this.getServerResolution(); - var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w)); - var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h)); - var z = this.getServerZoom(); - var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type; - var url = this.url; - if (OpenLayers.Util.isArray(url)) { - url = this.selectUrl(path, url); - } - if (mapBounds.intersectsBounds(bounds) && (z >= mapMinZoom) && (z <= mapMaxZoom)) { - return url + path; - } else { - return emptyTileURL; - } - } - """ % args # noqa - - s += """ - function getWindowHeight() { - if (self.innerHeight) return self.innerHeight; - if (document.documentElement && document.documentElement.clientHeight) - return document.documentElement.clientHeight; - if (document.body) return document.body.clientHeight; - return 0; - } - - function getWindowWidth() { - if (self.innerWidth) return self.innerWidth; - if (document.documentElement && document.documentElement.clientWidth) - return document.documentElement.clientWidth; - if (document.body) return document.body.clientWidth; - return 0; - } - - function resize() { - var map = document.getElementById("map"); - var header = document.getElementById("header"); - var subheader = document.getElementById("subheader"); - map.style.height = (getWindowHeight()-80) + "px"; - map.style.width = (getWindowWidth()-20) + "px"; - header.style.width = (getWindowWidth()-20) + "px"; - subheader.style.width = (getWindowWidth()-20) + "px"; - if (map.updateSize) { map.updateSize(); }; - } - - onresize=function(){ resize(); }; - - </script> - </head> - <body onload="init()"> - <div id="header"><h1>%(title)s</h1></div> - <div id="subheader">Generated by <a href="http://www.klokan.cz/projects/gdal2tiles/">GDAL2Tiles</a>, Copyright © 2008 <a href="http://www.klokan.cz/">Klokan Petr Pridal</a>, <a href="http://www.gdal.org/">GDAL</a> & <a href="http://www.osgeo.org/">OSGeo</a> <a href="http://code.google.com/soc/">GSoC</a> - <!-- PLEASE, LET THIS NOTE ABOUT AUTHOR AND PROJECT SOMEWHERE ON YOUR WEBSITE, OR AT LEAST IN THE COMMENT IN HTML. THANK YOU --> - </div> - <div id="map"></div> - <script type="text/javascript" >resize()</script> - </body> - </html>""" % args # noqa - - return s - - -def main(): - argv = gdal.GeneralCmdLineProcessor(sys.argv) - if argv: - gdal2tiles = GDAL2Tiles(argv[1:]) - gdal2tiles.process() - - -if __name__ == '__main__': - main() - -# vim: set tabstop=4 shiftwidth=4 expandtab: +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# ****************************************************************************** +# $Id$ +# +# Project: Google Summer of Code 2007, 2008 (http://code.google.com/soc/) +# Support: BRGM (http://www.brgm.fr) +# Purpose: Convert a raster into TMS (Tile Map Service) tiles in a directory. +# - generate Google Earth metadata (KML SuperOverlay) +# - generate simple HTML viewer based on Google Maps and OpenLayers +# - support of global tiles (Spherical Mercator) for compatibility +# with interactive web maps a la Google Maps +# Author: Klokan Petr Pridal, klokan at klokan dot cz +# Web: http://www.klokan.cz/projects/gdal2tiles/ +# GUI: http://www.maptiler.org/ +# +############################################################################### +# Copyright (c) 2008, Klokan Petr Pridal +# Copyright (c) 2010-2013, Even Rouault <even dot rouault at mines-paris dot org> +# +# 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. +# ****************************************************************************** + +import math +import os +import sys + +from osgeo import gdal +from osgeo import osr + +import struct # 1bto4b + + +def binary(num): # 1bto4b + # 1bto4b + return ''.join(bin(ord(c)).replace('0b', '').rjust(8, '0') for c in struct.pack('!f', num)) + +# 1bto4b + +def getTilePxBounds(self, tx, ty, tz, ds): + + querysize = self.tilesize + + if self.isRasterBounded: # 'raster' profile: + # tilesize in raster coordinates for actual zoom + tsize = int(self.tsize[tz]) + xsize = self.out_ds.fWorldXSize + ysize = self.out_ds.fWorldYSize + if tz >= self.tmaxz: + querysize = self.tilesize + + rx = (tx) * tsize - self.out_ds.fRasterXOriginWorld + #print("rx", rx) + rxsize = 0 + rxsize = tsize + + rysize = 0 + rysize = tsize + + ry = ysize - (ty * tsize) - rysize - \ + self.out_ds.fRasterYOriginWorld + + wx, wy = 0, 0 + wxsize = int(rxsize/float(tsize) * self.tilesize) + wysize = int(rysize/float(tsize) * self.tilesize) + if wysize != self.tilesize: + wy = self.tilesize - wysize + + if rx < 0: + rxsize = tsize + rx + wx = -rx + wxsize = int(rxsize/float(tsize) * self.tilesize) + rx = 0 + if ry < 0: + rysize = tsize + ry + wy = -ry + wysize = int(rysize/float(tsize) * self.tilesize) + ry = 0 + if rx + rxsize > self.out_ds.fRasterXSizeWorld: + rxsize = self.out_ds.fRasterXSizeWorld - rx + wxsize = int(rxsize/float(tsize) * self.tilesize) + if ry + rysize > self.out_ds.fRasterYSizeWorld: + rysize = self.out_ds.fRasterYSizeWorld - ry + wysize = int(rysize/float(tsize) * self.tilesize) + + # Convert rx, ry back to non-world coordinates + rx = int(float(self.out_ds.RasterXSize) * + (float(rx) / self.out_ds.fRasterXSizeWorld)) + ry = int(float(self.out_ds.RasterYSize) * + (float(ry) / self.out_ds.fRasterYSizeWorld)) + rxsize = int(float(self.out_ds.RasterXSize) * + (float(rxsize) / self.out_ds.fRasterXSizeWorld)) + rysize = int(float(self.out_ds.RasterYSize) * + (float(rysize) / self.out_ds.fRasterYSizeWorld)) + else: + b = self.mercator.TileBounds(tx, ty, tz) + rb, wb = self.geo_query( + ds, b[0], b[3], b[2], b[1], querysize=querysize) + rx, ry, rxsize, rysize = rb + wx, wy, wxsize, wysize = wb + + return [rx, ry, rxsize, rysize, wxsize, wysize] + + +try: + from PIL import Image + import numpy + import osgeo.gdal_array as gdalarray +except Exception: + # 'antialias' resampling is not available + pass + +__version__ = "$Id$" + +resampling_list = ('average', 'near', 'bilinear', 'cubic', + 'cubicspline', 'lanczos', 'antialias') +profile_list = ('mercator', 'geodetic', 'raster') +webviewer_list = ('all', 'google', 'openlayers', 'leaflet', 'none') + +# ============================================================================= +# ============================================================================= +# ============================================================================= + +__doc__globalmaptiles = """ +globalmaptiles.py + +Global Map Tiles as defined in Tile Map Service (TMS) Profiles +============================================================== + +Functions necessary for generation of global tiles used on the web. +It contains classes implementing coordinate conversions for: + + - GlobalMercator (based on EPSG:3857) + for Google Maps, Yahoo Maps, Bing Maps compatible tiles + - GlobalGeodetic (based on EPSG:4326) + for OpenLayers Base Map and Google Earth compatible tiles + +More info at: + +http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification +http://wiki.osgeo.org/wiki/WMS_Tiling_Client_Recommendation +http://msdn.microsoft.com/en-us/library/bb259689.aspx +http://code.google.com/apis/maps/documentation/overlays.html#Google_Maps_Coordinates + +Created by Klokan Petr Pridal on 2008-07-03. +Google Summer of Code 2008, project GDAL2Tiles for OSGEO. + +In case you use this class in your product, translate it to another language +or find it useful for your project please let me know. +My email: klokan at klokan dot cz. +I would like to know where it was used. + +Class is available under the open-source GDAL license (www.gdal.org). +""" + +MAXZOOMLEVEL = 32 + + +class GlobalMercator(object): + r""" + TMS Global Mercator Profile + --------------------------- + + Functions necessary for generation of tiles in Spherical Mercator projection, + EPSG:3857. + + Such tiles are compatible with Google Maps, Bing Maps, Yahoo Maps, + UK Ordnance Survey OpenSpace API, ... + and you can overlay them on top of base maps of those web mapping applications. + + Pixel and tile coordinates are in TMS notation (origin [0,0] in bottom-left). + + What coordinate conversions do we need for TMS Global Mercator tiles:: + + LatLon <-> Meters <-> Pixels <-> Tile + + WGS84 coordinates Spherical Mercator Pixels in pyramid Tiles in pyramid + lat/lon XY in meters XY pixels Z zoom XYZ from TMS + EPSG:4326 EPSG:387 + .----. --------- -- TMS + / \ <-> | | <-> /----/ <-> Google + \ / | | /--------/ QuadTree + ----- --------- /------------/ + KML, public WebMapService Web Clients TileMapService + + What is the coordinate extent of Earth in EPSG:3857? + + [-20037508.342789244, -20037508.342789244, + 20037508.342789244, 20037508.342789244] + Constant 20037508.342789244 comes from the circumference of the Earth in meters, + which is 40 thousand kilometers, the coordinate origin is in the middle of extent. + In fact you can calculate the constant as: 2 * math.pi * 6378137 / 2.0 + $ echo 180 85 | gdaltransform -s_srs EPSG:4326 -t_srs EPSG:3857 + Polar areas with abs(latitude) bigger then 85.05112878 are clipped off. + + What are zoom level constants (pixels/meter) for pyramid with EPSG:3857? + + whole region is on top of pyramid (zoom=0) covered by 256x256 pixels tile, + every lower zoom level resolution is always divided by two + initialResolution = 20037508.342789244 * 2 / 256 = 156543.03392804062 + + What is the difference between TMS and Google Maps/QuadTree tile name convention? + + The tile raster itself is the same (equal extent, projection, pixel size), + there is just different identification of the same raster tile. + Tiles in TMS are counted from [0,0] in the bottom-left corner, id is XYZ. + Google placed the origin [0,0] to the top-left corner, reference is XYZ. + Microsoft is referencing tiles by a QuadTree name, defined on the website: + http://msdn2.microsoft.com/en-us/library/bb259689.aspx + + The lat/lon coordinates are using WGS84 datum, yes? + + Yes, all lat/lon we are mentioning should use WGS84 Geodetic Datum. + Well, the web clients like Google Maps are projecting those coordinates by + Spherical Mercator, so in fact lat/lon coordinates on sphere are treated as if + the were on the WGS84 ellipsoid. + + From MSDN documentation: + To simplify the calculations, we use the spherical form of projection, not + the ellipsoidal form. Since the projection is used only for map display, + and not for displaying numeric coordinates, we don't need the extra precision + of an ellipsoidal projection. The spherical projection causes approximately + 0.33 percent scale distortion in the Y direction, which is not visually + noticeable. + + How do I create a raster in EPSG:3857 and convert coordinates with PROJ.4? + + You can use standard GIS tools like gdalwarp, cs2cs or gdaltransform. + All of the tools supports -t_srs 'epsg:3857'. + + For other GIS programs check the exact definition of the projection: + More info at http://spatialreference.org/ref/user/google-projection/ + The same projection is designated as EPSG:3857. WKT definition is in the + official EPSG database. + + Proj4 Text: + +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 + +k=1.0 +units=m +nadgrids=@null +no_defs + + Human readable WKT format of EPSG:3857: + PROJCS["Google Maps Global Mercator", + GEOGCS["WGS 84", + DATUM["WGS_1984", + SPHEROID["WGS 84",6378137,298.257223563, + AUTHORITY["EPSG","7030"]], + AUTHORITY["EPSG","6326"]], + PRIMEM["Greenwich",0], + UNIT["degree",0.0174532925199433], + AUTHORITY["EPSG","4326"]], + PROJECTION["Mercator_1SP"], + PARAMETER["central_meridian",0], + PARAMETER["scale_factor",1], + PARAMETER["false_easting",0], + PARAMETER["false_northing",0], + UNIT["metre",1, + AUTHORITY["EPSG","9001"]]] + """ + + def __init__(self, tileSize=256): + "Initialize the TMS Global Mercator pyramid" + self.tileSize = tileSize + self.initialResolution = 2 * math.pi * 6378137 / self.tileSize + # 156543.03392804062 for tileSize 256 pixels + self.originShift = 2 * math.pi * 6378137 / 2.0 + # 20037508.342789244 + + def LatLonToMeters(self, lat, lon): + "Converts given lat/lon in WGS84 Datum to XY in Spherical Mercator EPSG:3857" + + mx = lon * self.originShift / 180.0 + my = math.log(math.tan((90 + lat) * math.pi / 360.0)) / \ + (math.pi / 180.0) + + my = my * self.originShift / 180.0 + return mx, my + + def MetersToLatLon(self, mx, my): + "Converts XY point from Spherical Mercator EPSG:3857 to lat/lon in WGS84 Datum" + + lon = (mx / self.originShift) * 180.0 + lat = (my / self.originShift) * 180.0 + + lat = 180 / math.pi * \ + (2 * math.atan(math.exp(lat * math.pi / 180.0)) - math.pi / 2.0) + return lat, lon + + def PixelsToMeters(self, px, py, zoom): + "Converts pixel coordinates in given zoom level of pyramid to EPSG:3857" + + res = self.Resolution(zoom) + mx = px * res - self.originShift + my = py * res - self.originShift + return mx, my + + def MetersToPixels(self, mx, my, zoom): + "Converts EPSG:3857 to pyramid pixel coordinates in given zoom level" + + res = self.Resolution(zoom) + px = (mx + self.originShift) / res + py = (my + self.originShift) / res + return px, py + + def PixelsToTile(self, px, py): + "Returns a tile covering region in given pixel coordinates" + + tx = int(math.ceil(px / float(self.tileSize)) - 1) + ty = int(math.ceil(py / float(self.tileSize)) - 1) + return tx, ty + + def PixelsToRaster(self, px, py, zoom): + "Move the origin of pixel coordinates to top-left corner" + + mapSize = self.tileSize << zoom + return px, mapSize - py + + def MetersToTile(self, mx, my, zoom): + "Returns tile for given mercator coordinates" + + px, py = self.MetersToPixels(mx, my, zoom) + return self.PixelsToTile(px, py) + + def TileBounds(self, tx, ty, zoom): + "Returns bounds of the given tile in EPSG:3857 coordinates" + + minx, miny = self.PixelsToMeters( + tx*self.tileSize, ty*self.tileSize, zoom) + maxx, maxy = self.PixelsToMeters( + (tx+1)*self.tileSize, (ty+1)*self.tileSize, zoom) + return (minx, miny, maxx, maxy) + + def TileLatLonBounds(self, tx, ty, zoom): + "Returns bounds of the given tile in latitude/longitude using WGS84 datum" + + bounds = self.TileBounds(tx, ty, zoom) + minLat, minLon = self.MetersToLatLon(bounds[0], bounds[1]) + maxLat, maxLon = self.MetersToLatLon(bounds[2], bounds[3]) + + return (minLat, minLon, maxLat, maxLon) + + def Resolution(self, zoom): + "Resolution (meters/pixel) for given zoom level (measured at Equator)" + + # return (2 * math.pi * 6378137) / (self.tileSize * 2**zoom) + return self.initialResolution / (2**zoom) + + def ZoomForPixelSize(self, pixelSize): + "Maximal scaledown zoom of the pyramid closest to the pixelSize." + + for i in range(MAXZOOMLEVEL): + if pixelSize > self.Resolution(i): + if i != -1: + return i-1 + else: + return 0 # We don't want to scale up + + def GoogleTile(self, tx, ty, zoom): + "Converts TMS tile coordinates to Google Tile coordinates" + + # coordinate origin is moved from bottom-left to top-left corner of the extent + return tx, (2**zoom - 1) - ty + + def QuadTree(self, tx, ty, zoom): + "Converts TMS tile coordinates to Microsoft QuadTree" + + quadKey = "" + ty = (2**zoom - 1) - ty + for i in range(zoom, 0, -1): + digit = 0 + mask = 1 << (i-1) + if (tx & mask) != 0: + digit += 1 + if (ty & mask) != 0: + digit += 2 + quadKey += str(digit) + + return quadKey + + +class GlobalGeodetic(object): + r""" + TMS Global Geodetic Profile + --------------------------- + + Functions necessary for generation of global tiles in Plate Carre projection, + EPSG:4326, "unprojected profile". + + Such tiles are compatible with Google Earth (as any other EPSG:4326 rasters) + and you can overlay the tiles on top of OpenLayers base map. + + Pixel and tile coordinates are in TMS notation (origin [0,0] in bottom-left). + + What coordinate conversions do we need for TMS Global Geodetic tiles? + + Global Geodetic tiles are using geodetic coordinates (latitude,longitude) + directly as planar coordinates XY (it is also called Unprojected or Plate + Carre). We need only scaling to pixel pyramid and cutting to tiles. + Pyramid has on top level two tiles, so it is not square but rectangle. + Area [-180,-90,180,90] is scaled to 512x256 pixels. + TMS has coordinate origin (for pixels and tiles) in bottom-left corner. + Rasters are in EPSG:4326 and therefore are compatible with Google Earth. + + LatLon <-> Pixels <-> Tiles + + WGS84 coordinates Pixels in pyramid Tiles in pyramid + lat/lon XY pixels Z zoom XYZ from TMS + EPSG:4326 + .----. ---- + / \ <-> /--------/ <-> TMS + \ / /--------------/ + ----- /--------------------/ + WMS, KML Web Clients, Google Earth TileMapService + """ + + def __init__(self, tmscompatible, tileSize=256): + self.tileSize = tileSize + if tmscompatible is not None: + # Defaults the resolution factor to 0.703125 (2 tiles @ level 0) + # Adhers to OSGeo TMS spec + # http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification#global-geodetic + self.resFact = 180.0 / self.tileSize + else: + # Defaults the resolution factor to 1.40625 (1 tile @ level 0) + # Adheres OpenLayers, MapProxy, etc default resolution for WMTS + self.resFact = 360.0 / self.tileSize + + def LonLatToPixels(self, lon, lat, zoom): + "Converts lon/lat to pixel coordinates in given zoom of the EPSG:4326 pyramid" + + res = self.resFact / 2**zoom + px = (180 + lon) / res + py = (90 + lat) / res + return px, py + + def PixelsToTile(self, px, py): + "Returns coordinates of the tile covering region in pixel coordinates" + + tx = int(math.ceil(px / float(self.tileSize)) - 1) + ty = int(math.ceil(py / float(self.tileSize)) - 1) + return tx, ty + + def LonLatToTile(self, lon, lat, zoom): + "Returns the tile for zoom which covers given lon/lat coordinates" + + px, py = self.LonLatToPixels(lon, lat, zoom) + return self.PixelsToTile(px, py) + + def Resolution(self, zoom): + "Resolution (arc/pixel) for given zoom level (measured at Equator)" + + return self.resFact / 2**zoom + + def ZoomForPixelSize(self, pixelSize): + "Maximal scaledown zoom of the pyramid closest to the pixelSize." + + for i in range(MAXZOOMLEVEL): + if pixelSize > self.Resolution(i): + if i != 0: + return i-1 + else: + return 0 # We don't want to scale up + + def TileBounds(self, tx, ty, zoom): + "Returns bounds of the given tile" + res = self.resFact / 2**zoom + return ( + tx*self.tileSize*res - 180, + ty*self.tileSize*res - 90, + (tx+1)*self.tileSize*res - 180, + (ty+1)*self.tileSize*res - 90 + ) + + def TileLatLonBounds(self, tx, ty, zoom): + "Returns bounds of the given tile in the SWNE form" + b = self.TileBounds(tx, ty, zoom) + return (b[1], b[0], b[3], b[2]) + + +class Zoomify(object): + """ + Tiles compatible with the Zoomify viewer + ---------------------------------------- + """ + + def __init__(self, width, height, tilesize=256, tileformat='jpg'): + """Initialization of the Zoomify tile tree""" + + self.tilesize = tilesize + self.tileformat = tileformat + imagesize = (width, height) + tiles = (math.ceil(width / tilesize), math.ceil(height / tilesize)) + + # Size (in tiles) for each tier of pyramid. + self.tierSizeInTiles = [] + self.tierSizeInTiles.append(tiles) + + # Image size in pixels for each pyramid tierself + self.tierImageSize = [] + self.tierImageSize.append(imagesize) + + while (imagesize[0] > tilesize or imagesize[1] > tilesize): + imagesize = (math.floor( + imagesize[0] / 2), math.floor(imagesize[1] / 2)) + tiles = (math.ceil(imagesize[0] / tilesize), + math.ceil(imagesize[1] / tilesize)) + self.tierSizeInTiles.append(tiles) + self.tierImageSize.append(imagesize) + + self.tierSizeInTiles.reverse() + self.tierImageSize.reverse() + + # Depth of the Zoomify pyramid, number of tiers (zoom levels) + self.numberOfTiers = len(self.tierSizeInTiles) + + # Number of tiles up to the given tier of pyramid. + self.tileCountUpToTier = [] + self.tileCountUpToTier[0] = 0 + for i in range(1, self.numberOfTiers+1): + self.tileCountUpToTier.append( + self.tierSizeInTiles[i-1][0] * self.tierSizeInTiles[i-1][1] + + self.tileCountUpToTier[i-1] + ) + + def tilefilename(self, x, y, z): + """Returns filename for tile with given coordinates""" + + tileIndex = x + y * \ + self.tierSizeInTiles[z][0] + self.tileCountUpToTier[z] + return os.path.join("TileGroup%.0f" % math.floor(tileIndex / 256), + "%s-%s-%s.%s" % (z, x, y, self.tileformat)) + + +class Gdal2TilesError(Exception): + pass + + +class GDAL2Tiles(object): + + def process(self): + """The main processing function, runs all the main steps of processing""" + + # Opening and preprocessing of the input file + self.open_input() + + # Generation of main metadata files and HTML viewers + self.generate_metadata() + + # 1bto4b + if self.isDEMtile: + for z in range(self.tminz, self.tmaxz + int(abs(math.log(self.tilesize, 2) - 8))): # 1bto4b + self.generate_base_tiles(z) + print(' Zoom ' + str(z) + ' tiles done!') + else: + # Generation of the lowest tiles + self.generate_base_tiles(self.tmaxz) + + # Generation of the overview tiles (higher in the pyramid) + self.generate_overview_tiles() + + def error(self, msg, details=""): + """Print an error message and stop the processing""" + if details: + self.parser.error(msg + "\n\n" + details) + else: + self.parser.error(msg) + + def progressbar(self, complete=0.0): + """Print progressbar for float value 0..1""" + gdal.TermProgress_nocb(complete) + + def gettempfilename(self, suffix): + """Returns a temporary filename""" + if '_' in os.environ: + # tempfile.mktemp() crashes on some Wine versions (the one of Ubuntu 12.04 particularly) + if os.environ['_'].find('wine') >= 0: + tmpdir = '.' + if 'TMP' in os.environ: + tmpdir = os.environ['TMP'] + import time + import random + random.seed(time.time()) + random_part = 'file%d' % random.randint(0, 1000000000) + return os.path.join(tmpdir, random_part + suffix) + + import tempfile + return tempfile.mktemp(suffix) + + def stop(self): + """Stop the rendering immediately""" + self.stopped = True + + def __init__(self, arguments): + """Constructor function - initialization""" + self.out_drv = None + self.mem_drv = None + self.in_ds = None + self.out_ds = None + self.out_srs = None + self.nativezoom = None + self.tminmax = None + self.tsize = None + self.mercator = None + self.geodetic = None + self.alphaband = None + self.dataBandsCount = None + self.out_gt = None + self.tileswne = None + self.swne = None + self.ominx = None + self.omaxx = None + self.omaxy = None + self.ominy = None + + # MMGIS + self.isRasterBounded = False + + # 1bto4b + self.isDEMtile = False + + # MMGIS + self.fminx = None + self.fmaxx = None + self.fminy = None + self.fmaxy = None + self.fPixelSize = None + + self.stopped = False + self.input = None + self.output = None + + # Tile format + self.tilesize = 256 + self.tiledriver = 'PNG' + self.tileext = 'png' + + # Should we read bigger window of the input raster and scale it down? + # Note: Modified later by open_input() + # Not for 'near' resampling + # Not for Wavelet based drivers (JPEG2000, ECW, MrSID) + # Not for 'raster' profile + self.scaledquery = True + # How big should be query window be for scaling down + # Later on reset according the chosen resampling algorightm + self.querysize = 4 * self.tilesize + + # Should we use Read on the input file for generating overview tiles? + # Note: Modified later by open_input() + # Otherwise the overview tiles are generated from existing underlying tiles + self.overviewquery = False + + # RUN THE ARGUMENT PARSER: + + self.optparse_init() + self.options, self.args = self.parser.parse_args(args=arguments) + if not self.args: + self.error("No input file specified") + + # POSTPROCESSING OF PARSED ARGUMENTS: + + # Workaround for old versions of GDAL + try: + if ((self.options.verbose and self.options.resampling == 'near') or + gdal.TermProgress_nocb): + pass + except Exception: + self.error( + "This version of GDAL is not supported. Please upgrade to 1.6+.") + + # Is output directory the last argument? + + # Test output directory, if it doesn't exist + if (os.path.isdir(self.args[-1]) or + (len(self.args) > 1 and not os.path.exists(self.args[-1]))): + self.output = self.args[-1] + self.args = self.args[:-1] + + # More files on the input not directly supported yet + + if (len(self.args) > 1): + self.error("Processing of several input files is not supported.", + "Please first use a tool like gdal_vrtmerge.py or gdal_merge.py on the " + "files: gdal_vrtmerge.py -o merged.vrt %s" % " ".join(self.args)) + + self.input = self.args[0] + + # MMGIS + if self.options.extentworld: + extentworld = self.options.extentworld.split(",") + self.isRasterBounded = True + self.fminx = float(extentworld[0]) + self.fmaxx = float(extentworld[2]) + self.fminy = float(extentworld[3]) + self.fmaxy = float(extentworld[1]) + self.fPixelSize = float(extentworld[4]) + + # 1bto4b + if self.options.isDEMtile: + self.isDEMtile = True + self.tilesize = 32 + self.querysize = 4 * self.tilesize + + # Default values for not given options + + if not self.output: + # Directory with input filename without extension in actual directory + self.output = os.path.splitext(os.path.basename(self.input))[0] + + if not self.options.title: + self.options.title = os.path.basename(self.input) + + if self.options.url and not self.options.url.endswith('/'): + self.options.url += '/' + if self.options.url: + self.options.url += os.path.basename(self.output) + '/' + + # Supported options + + self.resampling = None + + if self.options.resampling == 'average': + try: + if gdal.RegenerateOverview: + pass + except Exception: + self.error("'average' resampling algorithm is not available.", + "Please use -r 'near' argument or upgrade to newer version of GDAL.") + + elif self.options.resampling == 'antialias': + try: + if numpy: # pylint:disable=W0125 + pass + except Exception: + self.error("'antialias' resampling algorithm is not available.", + "Install PIL (Python Imaging Library) and numpy.") + + elif self.options.resampling == 'near': + self.resampling = gdal.GRA_NearestNeighbour + self.querysize = self.tilesize + + elif self.options.resampling == 'bilinear': + self.resampling = gdal.GRA_Bilinear + self.querysize = self.tilesize * 2 + + elif self.options.resampling == 'cubic': + self.resampling = gdal.GRA_Cubic + + elif self.options.resampling == 'cubicspline': + self.resampling = gdal.GRA_CubicSpline + + elif self.options.resampling == 'lanczos': + self.resampling = gdal.GRA_Lanczos + + # User specified zoom levels + self.tminz = None + self.tmaxz = None + if self.options.zoom: + minmax = self.options.zoom.split('-', 1) + minmax.extend(['']) + zoom_min, zoom_max = minmax[:2] + self.tminz = int(zoom_min) + if zoom_max: + self.tmaxz = int(zoom_max) + else: + self.tmaxz = int(zoom_min) + + # KML generation + self.kml = self.options.kml + + # Check if the input filename is full ascii or not + try: + os.path.basename(self.input).encode('ascii') + except UnicodeEncodeError: + full_ascii = False + else: + full_ascii = True + + # LC_CTYPE check + if not full_ascii and 'UTF-8' not in os.environ.get("LC_CTYPE", ""): + if not self.options.quiet: + print("\nWARNING: " + "You are running gdal2tiles.py with a LC_CTYPE environment variable that is " + "not UTF-8 compatible, and your input file contains non-ascii characters. " + "The generated sample googlemaps, openlayers or " + "leaflet files might contain some invalid characters as a result\n") + + # Output the results + if self.options.verbose: + print("Options:", self.options) + print("Input:", self.input) + print("Output:", self.output) + print("Cache: %s MB" % (gdal.GetCacheMax() / 1024 / 1024)) + print('') + + def optparse_init(self): + """Prepare the option parser for input (argv)""" + + from optparse import OptionParser, OptionGroup + usage = "Usage: %prog [options] input_file(s) [output]" + p = OptionParser(usage, version="%prog " + __version__) + p.add_option("-p", "--profile", dest='profile', + type='choice', choices=profile_list, + help=("Tile cutting profile (%s) - default 'mercator' " + "(Google Maps compatible)" % ",".join(profile_list))) + p.add_option("-r", "--resampling", dest="resampling", + type='choice', choices=resampling_list, + help="Resampling method (%s) - default 'average'" % ",".join(resampling_list)) + p.add_option('-s', '--s_srs', dest="s_srs", metavar="SRS", + help="The spatial reference system used for the source input data") + p.add_option('-z', '--zoom', dest="zoom", + help="Zoom levels to render (format:'2-5' or '10').") + p.add_option('-e', '--resume', dest="resume", action="store_true", + help="Resume mode. Generate only missing files.") + p.add_option('-a', '--srcnodata', dest="srcnodata", metavar="NODATA", + help="NODATA transparency value to assign to the input data") + p.add_option('-d', '--tmscompatible', dest="tmscompatible", action="store_true", + help=("When using the geodetic profile, specifies the base resolution " + "as 0.703125 or 2 tiles at zoom level 0.")) + p.add_option("-v", "--verbose", + action="store_true", dest="verbose", + help="Print status messages to stdout") + p.add_option("-q", "--quiet", + action="store_true", dest="quiet", + help="Disable messages and status to stdout") + # MMGIS + p.add_option("-x", "--extentworld", dest="extentworld", + help="The full world meter extent (comma-separated as minx,maxx,miny,maxy,pixelsize) of an inner raster profile.") + # 1bto4b + p.add_option("-m", "--dem", action="store_true", dest="isDEMtile", + help="Indicate if the input is a Digital Elevation Model") + # KML options + g = OptionGroup(p, "KML (Google Earth) options", + "Options for generated Google Earth SuperOverlay metadata") + g.add_option("-k", "--force-kml", dest='kml', action="store_true", + help=("Generate KML for Google Earth - default for 'geodetic' profile and " + "'raster' in EPSG:4326. For a dataset with different projection use " + "with caution!")) + g.add_option("-n", "--no-kml", dest='kml', action="store_false", + help="Avoid automatic generation of KML files for EPSG:4326") + g.add_option("-u", "--url", dest='url', + help="URL address where the generated tiles are going to be published") + p.add_option_group(g) + + # HTML options + g = OptionGroup(p, "Web viewer options", + "Options for generated HTML viewers a la Google Maps") + g.add_option("-w", "--webviewer", dest='webviewer', type='choice', choices=webviewer_list, + help="Web viewer to generate (%s) - default 'all'" % ",".join(webviewer_list)) + g.add_option("-t", "--title", dest='title', + help="Title of the map") + g.add_option("-c", "--copyright", dest='copyright', + help="Copyright for the map") + g.add_option("-g", "--googlekey", dest='googlekey', + help="Google Maps API key from http://code.google.com/apis/maps/signup.html") + g.add_option("-b", "--bingkey", dest='bingkey', + help="Bing Maps API key from https://www.bingmapsportal.com/") + p.add_option_group(g) + + p.set_defaults(verbose=False, profile="mercator", kml=False, url='', + webviewer='all', copyright='', resampling='average', resume=False, + googlekey='INSERT_YOUR_KEY_HERE', bingkey='INSERT_YOUR_KEY_HERE') + + self.parser = p + + # ------------------------------------------------------------------------- + def open_input(self): + """Initialization of the input raster, reprojection if necessary""" + gdal.AllRegister() + + self.out_drv = gdal.GetDriverByName(self.tiledriver) + self.mem_drv = gdal.GetDriverByName('MEM') + + if not self.out_drv: + raise Exception("The '%s' driver was not found, is it available in this GDAL build?", + self.tiledriver) + if not self.mem_drv: + raise Exception( + "The 'MEM' driver was not found, is it available in this GDAL build?") + + # Open the input file + + if self.input: + self.in_ds = gdal.Open(self.input, gdal.GA_ReadOnly) + else: + raise Exception("No input file was specified") + + if self.options.verbose: + print("Input file:", + "( %sP x %sL - %s bands)" % (self.in_ds.RasterXSize, self.in_ds.RasterYSize, + self.in_ds.RasterCount)) + + if not self.in_ds: + # Note: GDAL prints the ERROR message too + self.error( + "It is not possible to open the input file '%s'." % self.input) + + # Read metadata from the input file + if self.in_ds.RasterCount == 0: + self.error("Input file '%s' has no raster band" % self.input) + + if self.in_ds.GetRasterBand(1).GetRasterColorTable(): + self.error("Please convert this file to RGB/RGBA and run gdal2tiles on the result.", + "From paletted file you can create RGBA file (temp.vrt) by:\n" + "gdal_translate -of vrt -expand rgba %s temp.vrt\n" + "then run:\n" + "gdal2tiles temp.vrt" % self.input) + + # Get NODATA value + in_nodata = [] + for i in range(1, self.in_ds.RasterCount+1): + if self.in_ds.GetRasterBand(i).GetNoDataValue() is not None: + in_nodata.append(self.in_ds.GetRasterBand(i).GetNoDataValue()) + if self.options.srcnodata: + nds = list(map(float, self.options.srcnodata.split(','))) + if len(nds) < self.in_ds.RasterCount: + in_nodata = ( + nds * self.in_ds.RasterCount)[:self.in_ds.RasterCount] + else: + in_nodata = nds + + if self.options.verbose: + print("NODATA: %s" % in_nodata) + + if self.options.verbose: + print("Preprocessed file:", + "( %sP x %sL - %s bands)" % (self.in_ds.RasterXSize, self.in_ds.RasterYSize, + self.in_ds.RasterCount)) + + in_srs = None + + if self.options.s_srs: + in_srs = osr.SpatialReference() + in_srs.SetFromUserInput(self.options.s_srs) + in_srs_wkt = in_srs.ExportToWkt() + else: + in_srs_wkt = self.in_ds.GetProjection() + if not in_srs_wkt and self.in_ds.GetGCPCount() != 0: + in_srs_wkt = self.in_ds.GetGCPProjection() + if in_srs_wkt: + in_srs = osr.SpatialReference() + in_srs.ImportFromWkt(in_srs_wkt) + + self.out_srs = osr.SpatialReference() + + if self.options.profile == 'mercator': + self.out_srs.ImportFromEPSG(3857) + elif self.options.profile == 'geodetic': + self.out_srs.ImportFromEPSG(4326) + else: + self.out_srs = in_srs + + # Are the reference systems the same? Reproject if necessary. + + self.out_ds = None + + if self.options.profile in ('mercator', 'geodetic'): + + if ((self.in_ds.GetGeoTransform() == (0.0, 1.0, 0.0, 0.0, 0.0, 1.0)) and + (self.in_ds.GetGCPCount() == 0)): + self.error("There is no georeference - neither affine transformation (worldfile) " + "nor GCPs. You can generate only 'raster' profile tiles.", + "Either gdal2tiles with parameter -p 'raster' or use another GIS " + "software for georeference e.g. gdal_transform -gcp / -a_ullr / -a_srs") + + if in_srs: + if ((in_srs.ExportToProj4() != self.out_srs.ExportToProj4()) or + (self.in_ds.GetGCPCount() != 0)): + # Generation of VRT dataset in tile projection, + # default 'nearest neighbour' warping + self.out_ds = gdal.AutoCreateWarpedVRT( + self.in_ds, in_srs_wkt, self.out_srs.ExportToWkt()) + + if self.options.verbose: + print("Warping of the raster by AutoCreateWarpedVRT " + "(result saved into 'tiles.vrt')") + self.out_ds.GetDriver().CreateCopy("tiles.vrt", self.out_ds) + + # Correction of AutoCreateWarpedVRT for NODATA values + if in_nodata != []: + tempfilename = self.gettempfilename('-gdal2tiles.vrt') + self.out_ds.GetDriver().CreateCopy(tempfilename, self.out_ds) + # open as a text file + s = open(tempfilename).read() + # Add the warping options + s = s.replace( + "<GDALWarpOptions>", + """ + <GDALWarpOptions> + <Option name="INIT_DEST">NO_DATA</Option> + <Option name="UNIFIED_SRC_NODATA">YES</Option> + """) + # replace BandMapping tag for NODATA bands.... + for i in range(len(in_nodata)): + s = s.replace( + '<BandMapping src="%i" dst="%i"/>' % ( + (i+1), (i+1)), + """ + <BandMapping src="%i" dst="%i"> + <SrcNoDataReal>%i</SrcNoDataReal> + <SrcNoDataImag>0</SrcNoDataImag> + <DstNoDataReal>%i</DstNoDataReal> + <DstNoDataImag>0</DstNoDataImag> + </BandMapping> + """ % ((i+1), (i+1), in_nodata[i], in_nodata[i])) + # save the corrected VRT + open(tempfilename, "w").write(s) + # open by GDAL as self.out_ds + self.out_ds = gdal.Open(tempfilename) + # delete the temporary file + os.unlink(tempfilename) + + # set NODATA_VALUE metadata + self.out_ds.SetMetadataItem( + 'NODATA_VALUES', ' '.join([str(i) for i in in_nodata])) + + if self.options.verbose: + print("Modified warping result saved into 'tiles1.vrt'") + open("tiles1.vrt", "w").write(s) + + # Correction of AutoCreateWarpedVRT for Mono (1 band) and RGB (3 bands) files + # without NODATA: + # equivalent of gdalwarp -dstalpha + if in_nodata == [] and self.out_ds.RasterCount in [1, 3]: + tempfilename = self.gettempfilename('-gdal2tiles.vrt') + self.out_ds.GetDriver().CreateCopy(tempfilename, self.out_ds) + # open as a text file + s = open(tempfilename).read() + # Add the warping options + s = s.replace( + "<BlockXSize>", + """ + <VRTRasterBand dataType="Byte" band="%i" subClass="VRTWarpedRasterBand"> + <ColorInterp>Alpha</ColorInterp> + </VRTRasterBand> + <BlockXSize> + """ % (self.out_ds.RasterCount + 1)) + s = s.replace( + "</GDALWarpOptions>", + """ + <DstAlphaBand>%i</DstAlphaBand> + </GDALWarpOptions> + """ % (self.out_ds.RasterCount + 1)) + s = s.replace( + "</WorkingDataType>", + """ + </WorkingDataType> + <Option name="INIT_DEST">0</Option> + """) + # save the corrected VRT + open(tempfilename, "w").write(s) + # open by GDAL as self.out_ds + self.out_ds = gdal.Open(tempfilename) + # delete the temporary file + os.unlink(tempfilename) + + if self.options.verbose: + print( + "Modified -dstalpha warping result saved into 'tiles1.vrt'") + open("tiles1.vrt", "w").write(s) + s = ''' + ''' + + else: + self.error("Input file has unknown SRS.", + "Use --s_srs ESPG:xyz (or similar) to provide source reference system.") + + if self.out_ds and self.options.verbose: + print("Projected file:", "tiles.vrt", "( %sP x %sL - %s bands)" % ( + self.out_ds.RasterXSize, self.out_ds.RasterYSize, self.out_ds.RasterCount)) + + if not self.out_ds: + self.out_ds = self.in_ds + + # + # Here we should have a raster (out_ds) in the correct Spatial Reference system + # + + # Get alpha band (either directly or from NODATA value) + self.alphaband = self.out_ds.GetRasterBand(1).GetMaskBand() + if ((self.alphaband.GetMaskFlags() & gdal.GMF_ALPHA) or + self.out_ds.RasterCount == 4 or + self.out_ds.RasterCount == 2): + self.dataBandsCount = self.out_ds.RasterCount - 1 + else: + self.dataBandsCount = self.out_ds.RasterCount + + # KML test + isepsg4326 = False + srs4326 = osr.SpatialReference() + srs4326.ImportFromEPSG(4326) + if self.out_srs and srs4326.ExportToProj4() == self.out_srs.ExportToProj4(): + self.kml = True + isepsg4326 = True + if self.options.verbose: + print("KML autotest OK!") + + # Read the georeference + self.out_gt = self.out_ds.GetGeoTransform() + + # Test the size of the pixel + + # Report error in case rotation/skew is in geotransform (possible only in 'raster' profile) + if (self.out_gt[2], self.out_gt[4]) != (0, 0): + self.error("Georeference of the raster contains rotation or skew. " + "Such raster is not supported. Please use gdalwarp first.") + + # Here we expect: pixel is square, no rotation on the raster + + # Output Bounds - coordinates in the output SRS + self.ominx = self.out_gt[0] + self.omaxx = self.out_gt[0] + self.out_ds.RasterXSize * self.out_gt[1] + self.omaxy = self.out_gt[3] + self.ominy = self.out_gt[3] - self.out_ds.RasterYSize * self.out_gt[1] + + # Note: maybe round(x, 14) to avoid the gdal_translate behaviour, when 0 becomes -1e-15 + + # MMGIS + def linearScale(domain, rang, value): + return ( + ((rang[1] - rang[0]) * (value - domain[0])) / + (domain[1] - domain[0]) + + rang[0] + ) + # MMGIS + self.out_ds.fRasterXSize = self.out_ds.RasterXSize + self.out_ds.fRasterYSize = self.out_ds.RasterYSize + self.out_ds.fRasterXOrigin = 0 + self.out_ds.fRasterYOrigin = 0 + self.out_ds.PixelSize = self.out_gt[1] + self.out_ds.fPixelSize = self.fPixelSize + # print("ominx", self.ominx, "omaxx", self.omaxx, "ominy", self.ominy, "omaxy", self.omaxy) + # print("fminx", self.fminx, "fmaxx", self.fmaxx, "fminy", self.fminy, "fmaxy", self.fmaxy) + if self.isRasterBounded: + self.out_ds.fRasterXSize = int(math.floor(self.out_ds.RasterXSize * (self.fmaxx - self.fminx) / ( + self.omaxx - self.ominx) * (self.out_ds.PixelSize / self.out_ds.fPixelSize))) + self.out_ds.fRasterYSize = int(math.ceil(self.out_ds.RasterYSize * (self.fmaxy - self.fminy) / ( + self.omaxy - self.ominy) * (self.out_ds.PixelSize / self.out_ds.fPixelSize))) + self.out_ds.fRasterXSizeRaw = int(math.floor( + self.out_ds.RasterXSize * (self.fmaxx - self.fminx) / (self.omaxx - self.ominx))) + self.out_ds.fRasterYSizeRaw = int(math.ceil( + self.out_ds.RasterYSize * (self.fmaxy - self.fminy) / (self.omaxy - self.ominy))) + # print("Full Raster Size: ", self.out_ds.fRasterXSize, self.out_ds.fRasterYSize ) + self.out_ds.fRasterXOrigin = int(math.floor(linearScale( + [self.fminx, self.fmaxx], [0, self.out_ds.fRasterXSize], self.out_gt[0]))) + self.out_ds.fRasterYOrigin = int(math.ceil(linearScale( + [self.fminy, self.fmaxy], [self.out_ds.fRasterYSize, 0], self.out_gt[3]))) + self.out_ds.fRasterXOriginRaw = int(math.floor(linearScale([self.fminx, self.fmaxx], [ + 0, self.out_ds.fRasterXSize], self.out_gt[0]) * (self.out_ds.fPixelSize / self.out_ds.PixelSize))) + self.out_ds.fRasterYOriginRaw = int(math.ceil(linearScale([self.fminy, self.fmaxy], [ + self.out_ds.fRasterYSize, 0], self.out_gt[3]) * (self.out_ds.fPixelSize / self.out_ds.PixelSize))) + self.out_ds.fRasterXWidth = int(math.floor(linearScale( + [self.fminx, self.fmaxx], [0, self.out_ds.fRasterXSize], self.omaxx))) - self.out_ds.fRasterXOrigin + self.out_ds.fRasterYHeight = int(math.ceil(linearScale( + [self.fminy, self.fmaxy], [0, self.out_ds.fRasterYSize], self.omaxy))) - self.out_ds.fRasterYOrigin + + if self.options.verbose: + print("Bounds (output srs):", round(self.ominx, 13), + self.ominy, self.omaxx, self.omaxy) + + # print("Input Raster Size: ", self.out_ds.RasterXSize, self.out_ds.RasterYSize) + # print("fmaxx-fminx", self.fmaxx - self.fminx, "omaxx-ominx", self.omaxx - self.ominx, "fmaxy-fminy", self.fmaxy - self.fminy, "omaxy-ominy", self.omaxy - self.ominy) + # print("Full Raster Size: ", self.out_ds.fRasterXSize, self.out_ds.fRasterYSize) + # print("Full Raster Size Raw: ", self.out_ds.fRasterXSizeRaw, self.out_ds.fRasterYSizeRaw) + # print("Raster Origin: ", self.out_ds.fRasterXOrigin, self.out_ds.fRasterYOrigin) + # print("Raster Origin Raw: ", self.out_ds.fRasterXOriginRaw, self.out_ds.fRasterYOriginRaw) + # print("Raster Width Height: ", self.out_ds.fRasterXWidth, self.out_ds.fRasterYHeight) + + # Calculating ranges for tiles in different zoom levels + if self.options.profile == 'mercator': + + self.mercator = GlobalMercator() + + # Function which generates SWNE in LatLong for given tile + self.tileswne = self.mercator.TileLatLonBounds + + # Generate table with min max tile coordinates for all zoomlevels + self.tminmax = list(range(0, 32)) + for tz in range(0, 32): + tminx, tminy = self.mercator.MetersToTile( + self.ominx, self.ominy, tz) + tmaxx, tmaxy = self.mercator.MetersToTile( + self.omaxx, self.omaxy, tz) + # crop tiles extending world limits (+-180,+-90) + tminx, tminy = max(0, tminx), max(0, tminy) + tmaxx, tmaxy = min(2**tz-1, tmaxx), min(2**tz-1, tmaxy) + self.tminmax[tz] = (tminx, tminy, tmaxx, tmaxy) + + # TODO: Maps crossing 180E (Alaska?) + + # Get the minimal zoom level (map covers area equivalent to one tile) + if self.tminz is None: + self.tminz = self.mercator.ZoomForPixelSize( + self.out_gt[1] * max(self.out_ds.RasterXSize, + self.out_ds.RasterYSize) / float(self.tilesize)) + + # Get the maximal zoom level + # (closest possible zoom level up on the resolution of raster) + if self.tmaxz is None: + self.tmaxz = self.mercator.ZoomForPixelSize(self.out_gt[1]) + + if self.options.verbose: + print("Bounds (latlong):", + self.mercator.MetersToLatLon(self.ominx, self.ominy), + self.mercator.MetersToLatLon(self.omaxx, self.omaxy)) + print('MinZoomLevel:', self.tminz) + print("MaxZoomLevel:", + self.tmaxz, + "(", + self.mercator.Resolution(self.tmaxz), + ")") + + if self.options.profile == 'geodetic': + + self.geodetic = GlobalGeodetic(self.options.tmscompatible) + + # Function which generates SWNE in LatLong for given tile + self.tileswne = self.geodetic.TileLatLonBounds + + # Generate table with min max tile coordinates for all zoomlevels + self.tminmax = list(range(0, 32)) + for tz in range(0, 32): + tminx, tminy = self.geodetic.LonLatToTile( + self.ominx, self.ominy, tz) + tmaxx, tmaxy = self.geodetic.LonLatToTile( + self.omaxx, self.omaxy, tz) + # crop tiles extending world limits (+-180,+-90) + tminx, tminy = max(0, tminx), max(0, tminy) + tmaxx, tmaxy = min(2**(tz+1)-1, tmaxx), min(2**tz-1, tmaxy) + self.tminmax[tz] = (tminx, tminy, tmaxx, tmaxy) + + # TODO: Maps crossing 180E (Alaska?) + + # Get the maximal zoom level + # (closest possible zoom level up on the resolution of raster) + if self.tminz is None: + self.tminz = self.geodetic.ZoomForPixelSize( + self.out_gt[1] * max(self.out_ds.RasterXSize, + self.out_ds.RasterYSize) / float(self.tilesize)) + + # Get the maximal zoom level + # (closest possible zoom level up on the resolution of raster) + if self.tmaxz is None: + self.tmaxz = self.geodetic.ZoomForPixelSize(self.out_gt[1]) + + if self.options.verbose: + print("Bounds (latlong):", self.ominx, + self.ominy, self.omaxx, self.omaxy) + + # MMGIS + if self.options.profile == 'raster' and self.isRasterBounded: + + def log2(x): + return math.log10(x) / math.log10(2) + + # MMGIS added 'f'* + self.nativezoom = int( + max(math.ceil(log2(self.out_ds.fRasterXSizeRaw/float(self.tilesize))), + math.ceil(log2(self.out_ds.fRasterYSizeRaw/float(self.tilesize))))) + + self.basenativezoom = int( + max(math.ceil(log2(self.out_ds.fRasterXSize/float(self.tilesize))), + math.ceil(log2(self.out_ds.fRasterYSize/float(self.tilesize))))) + + # MMGIS + self.out_ds.fWorldXSize = int( + float(self.out_ds.fRasterXSize) * (2**(self.nativezoom - self.basenativezoom))) + self.out_ds.fWorldYSize = int( + float(self.out_ds.fRasterYSize) * (2**(self.nativezoom - self.basenativezoom))) + self.out_ds.fRasterXOriginWorld = int(float( + self.out_ds.fWorldXSize) * (float(self.out_ds.fRasterXOrigin) / self.out_ds.fRasterXSize)) + self.out_ds.fRasterYOriginWorld = int(float( + self.out_ds.fWorldYSize) * (float(self.out_ds.fRasterYOrigin) / self.out_ds.fRasterYSize)) + self.out_ds.fRasterXSizeWorld = int(float( + self.out_ds.fWorldXSize) * (float(self.out_ds.fRasterXWidth) / self.out_ds.fRasterXSize)) + self.out_ds.fRasterYSizeWorld = int(float( + self.out_ds.RasterYSize) * (float(self.out_ds.fRasterXSizeWorld) / self.out_ds.RasterXSize)) + # print("World Size", self.out_ds.fWorldXSize, self.out_ds.fWorldYSize) + # print("Raster Origin World", self.out_ds.fRasterXOriginWorld, self.out_ds.fRasterYOriginWorld) + # print("Raster Size World", self.out_ds.fRasterXSizeWorld, self.out_ds.fRasterYSizeWorld) + + if self.options.verbose: + print("Native zoom of the raster:", self.nativezoom) + + # Get the minimal zoom level (whole raster in one tile) + if self.tminz is None: + self.tminz = 0 + + # Get the maximal zoom level (native resolution of the raster) + if self.tmaxz is None: + self.tmaxz = self.nativezoom + + # MMGIS added 'f'* + # Generate table with min max tile coordinates for all zoomlevels + self.tminmax = list(range(0, self.tmaxz+1)) + self.tsize = list(range(0, self.tmaxz+1)) + # print("Raster Size:", self.out_ds.RasterXSize,self.out_ds.RasterYSize) + # print("Pixel Size Ratio:", (self.out_ds.fPixelSize / self.out_ds.PixelSize)) + # print("nativezoom", self.nativezoom, "basenativezoom", self.basenativezoom, "tminz", self.tminz, "tmaxz", self.tmaxz) + for tz in range(0, self.tmaxz+1): + tsize = 2.0**(self.tmaxz-tz)*self.tilesize + toffsetx = int(math.floor( + 2.0**(tz) * self.out_ds.fRasterXOriginRaw / self.out_ds.fRasterXSizeRaw)) + toffsety = int(math.floor( + 2.0**(tz) * (self.out_ds.fRasterYOriginRaw) / self.out_ds.fRasterYSizeRaw)) + # print("tsize", tsize, "toffsetx", toffsetx, "toffsety", toffsety) + toffsetx = int(math.floor( + self.out_ds.fRasterXOriginWorld / tsize)) + toffsety = int(math.floor( + self.out_ds.fRasterYOriginWorld / tsize)) + # print("tsize", tsize, "toffsetx", toffsetx, "toffsety", toffsety) + tmaxx = int(math.floor( + self.out_ds.fRasterXSizeWorld / tsize)) + toffsetx + 1 + + tmaxy = int(math.floor( + self.out_ds.fRasterYSizeWorld / tsize)) + toffsety + 1 + self.tsize[tz] = math.ceil(tsize) + #tminx = toffsetx + tminx = int(tmaxx - ((tmaxx - toffsetx) / (0.75))) - 1 + tminy = int(tmaxy - ((tmaxy - toffsety) / (0.75))) - 1 + + self.tminmax[tz] = (tminx, tminy, tmaxx, tmaxy) + # print("tminx", tminx, "tminy", tminy, "tmaxx", tmaxx, "tmaxy", tmaxy, "tz", tz) + + elif self.options.profile == 'raster': + + def log2(x): + return math.log10(x) / math.log10(2) + self.nativezoom = int( + max(math.ceil(log2(self.out_ds.RasterXSize/float(self.tilesize))), + math.ceil(log2(self.out_ds.RasterYSize/float(self.tilesize))))) + + if self.options.verbose: + print("Native zoom of the raster:", self.nativezoom) + + # Get the minimal zoom level (whole raster in one tile) + if self.tminz is None: + self.tminz = 0 + + # Get the maximal zoom level (native resolution of the raster) + if self.tmaxz is None: + self.tmaxz = self.nativezoom + + # Generate table with min max tile coordinates for all zoomlevels + self.tminmax = list(range(0, self.tmaxz+1)) + self.tsize = list(range(0, self.tmaxz+1)) + for tz in range(0, self.tmaxz+1): + tsize = 2.0**(self.tmaxz-tz)*self.tilesize + tminx, tminy = 0, 0 + tmaxx = int(math.ceil(self.out_ds.RasterXSize / tsize)) - 1 + tmaxy = int(math.ceil(self.out_ds.RasterYSize / tsize)) - 1 + self.tsize[tz] = math.ceil(tsize) + self.tminmax[tz] = (tminx, tminy, tmaxx, tmaxy) + + # Function which generates SWNE in LatLong for given tile + if self.kml and in_srs_wkt: + ct = osr.CoordinateTransformation(in_srs, srs4326) + + def rastertileswne(x, y, z): + # X-pixel size in level + pixelsizex = (2**(self.tmaxz-z) * self.out_gt[1]) + west = self.out_gt[0] + x*self.tilesize*pixelsizex + east = west + self.tilesize*pixelsizex + south = self.ominy + y*self.tilesize*pixelsizex + north = south + self.tilesize*pixelsizex + if not isepsg4326: + # Transformation to EPSG:4326 (WGS84 datum) + west, south = ct.TransformPoint(west, south)[:2] + east, north = ct.TransformPoint(east, north)[:2] + return south, west, north, east + + self.tileswne = rastertileswne + else: + self.tileswne = lambda x, y, z: (0, 0, 0, 0) # noqa + + def generate_metadata(self): + """ + Generation of main metadata files and HTML viewers (metadata related to particular + tiles are generated during the tile processing). + """ + + if not os.path.exists(self.output): + os.makedirs(self.output) + + if self.options.profile == 'mercator': + + south, west = self.mercator.MetersToLatLon(self.ominx, self.ominy) + north, east = self.mercator.MetersToLatLon(self.omaxx, self.omaxy) + south, west = max(-85.05112878, south), max(-180.0, west) + north, east = min(85.05112878, north), min(180.0, east) + self.swne = (south, west, north, east) + + # Generate googlemaps.html + if self.options.webviewer in ('all', 'google') and self.options.profile == 'mercator': + if (not self.options.resume or not + os.path.exists(os.path.join(self.output, 'googlemaps.html'))): + f = open(os.path.join(self.output, 'googlemaps.html'), 'wb') + f.write(self.generate_googlemaps().encode('utf-8')) + f.close() + + # Generate openlayers.html + if self.options.webviewer in ('all', 'openlayers'): + if (not self.options.resume or not + os.path.exists(os.path.join(self.output, 'openlayers.html'))): + f = open(os.path.join(self.output, 'openlayers.html'), 'wb') + f.write(self.generate_openlayers().encode('utf-8')) + f.close() + + # Generate leaflet.html + if self.options.webviewer in ('all', 'leaflet'): + if (not self.options.resume or not + os.path.exists(os.path.join(self.output, 'leaflet.html'))): + f = open(os.path.join(self.output, 'leaflet.html'), 'wb') + f.write(self.generate_leaflet().encode('utf-8')) + f.close() + + elif self.options.profile == 'geodetic': + + west, south = self.ominx, self.ominy + east, north = self.omaxx, self.omaxy + south, west = max(-90.0, south), max(-180.0, west) + north, east = min(90.0, north), min(180.0, east) + self.swne = (south, west, north, east) + + # Generate openlayers.html + if self.options.webviewer in ('all', 'openlayers'): + if (not self.options.resume or not + os.path.exists(os.path.join(self.output, 'openlayers.html'))): + f = open(os.path.join(self.output, 'openlayers.html'), 'wb') + f.write(self.generate_openlayers().encode('utf-8')) + f.close() + + elif self.options.profile == 'raster': + + west, south = self.ominx, self.ominy + east, north = self.omaxx, self.omaxy + + # MMGIS + if self.isRasterBounded: + west = self.fminx + east = self.fmaxx + south = self.fminy + north = self.fmaxy + + self.swne = (south, west, north, east) + + # Generate openlayers.html + if self.options.webviewer in ('all', 'openlayers'): + if (not self.options.resume or not + os.path.exists(os.path.join(self.output, 'openlayers.html'))): + f = open(os.path.join(self.output, 'openlayers.html'), 'wb') + f.write(self.generate_openlayers().encode('utf-8')) + f.close() + + # Generate tilemapresource.xml. + if not self.options.resume or not os.path.exists(os.path.join(self.output, 'tilemapresource.xml')): + f = open(os.path.join(self.output, 'tilemapresource.xml'), 'wb') + f.write(self.generate_tilemapresource().encode('utf-8')) + f.close() + + if self.kml: + # TODO: Maybe problem for not automatically generated tminz + # The root KML should contain links to all tiles in the tminz level + children = [] + xmin, ymin, xmax, ymax = self.tminmax[self.tminz] + for x in range(xmin, xmax+1): + for y in range(ymin, ymax+1): + children.append([x, y, self.tminz]) + # Generate Root KML + if self.kml: + if (not self.options.resume or not + os.path.exists(os.path.join(self.output, 'doc.kml'))): + f = open(os.path.join(self.output, 'doc.kml'), 'wb') + f.write(self.generate_kml( + None, None, None, children).encode('utf-8')) + f.close() + + def generate_base_tiles(self, tz): + """ + Generation of the base tiles (the lowest in the pyramid) directly from the input raster + """ + + if self.isDEMtile: + print("Generating Tiles at Zoom " + str(tz) + ": ") + + if not self.options.quiet: + print("Generating Base Tiles:") + + if self.options.verbose: + print('') + print("Tiles generated from the max zoom level:") + print("----------------------------------------") + print('') + + ds = self.out_ds + + querysize = self.querysize + + # 1bto4b + if self.isDEMtile: + tilebands = 4 + querysize = self.tilesize + else: + tilebands = self.dataBandsCount + 1 + tz = self.tmaxz + + try: + self.tminmax[tz] + except IndexError: + print(" Won't make zoom level " + str(tz)) + return + + # Set the bounds + tminx, tminy, tmaxx, tmaxy = self.tminmax[tz] + + if self.options.verbose: + print("dataBandsCount: ", self.dataBandsCount) + print("tilebands: ", tilebands) + + tcount = (1+abs(tmaxx-tminx)) * (1+abs(tmaxy-tminy)) + ti = 0 + + for ty in range(tmaxy, tminy-1, -1): + for tx in range(tminx, tmaxx+1): + + if self.stopped: + break + ti += 1 + tilefilename = os.path.join( + self.output, str(tz), str(tx), "%s.%s" % (ty, self.tileext)) + if self.options.verbose: + print(ti, '/', tcount, tilefilename) + + if self.options.resume and os.path.exists(tilefilename): + if self.options.verbose: + print("Tile generation skipped because of --resume") + else: + self.progressbar(ti / float(tcount)) + continue + + # Create directories for the tile + if not os.path.exists(os.path.dirname(tilefilename)): + os.makedirs(os.path.dirname(tilefilename)) + + if self.options.profile == 'mercator': + # Tile bounds in EPSG:3857 + b = self.mercator.TileBounds(tx, ty, tz) + elif self.options.profile == 'geodetic': + b = self.geodetic.TileBounds(tx, ty, tz) + + # Don't scale up by nearest neighbour, better change the querysize + # to the native resolution (and return smaller query tile) for scaling + + if self.options.profile in ('mercator', 'geodetic'): + rb, wb = self.geo_query(ds, b[0], b[3], b[2], b[1]) + + # Pixel size in the raster covering query geo extent + nativesize = wb[0] + wb[2] + if self.options.verbose: + print("\tNative Extent (querysize", + nativesize, "): ", rb, wb) + + # Tile bounds in raster coordinates for ReadRaster query + rb, wb = self.geo_query( + ds, b[0], b[3], b[2], b[1], querysize=querysize) + + rx, ry, rxsize, rysize = rb + wx, wy, wxsize, wysize = wb + wxsize -= 1 # 1bto4b + wysize -= 1 # 1bto4b + + # MMGIS + elif self.isRasterBounded: # 'raster' profile: + + # tilesize in raster coordinates for actual zoom + tsize = int(self.tsize[tz]) + xsize = self.out_ds.fWorldXSize + ysize = self.out_ds.fWorldYSize + if tz >= self.tmaxz: + querysize = self.tilesize + + rx = (tx) * tsize - self.out_ds.fRasterXOriginWorld + #print("rx", rx) + rxsize = 0 + rxsize = tsize + + rysize = 0 + rysize = tsize + + ry = ysize - (ty * tsize) - rysize - \ + self.out_ds.fRasterYOriginWorld + + wx, wy = 0, 0 + wxsize = int(rxsize/float(tsize) * self.tilesize) + wysize = int(rysize/float(tsize) * self.tilesize) + if wysize != self.tilesize: + wy = self.tilesize - wysize + + if rx < 0: + rxsize = tsize + rx + wx = -rx + wxsize = int(rxsize/float(tsize) * self.tilesize) + rx = 0 + if ry < 0: + rysize = tsize + ry + wy = -ry + wysize = int(rysize/float(tsize) * self.tilesize) + ry = 0 + if rx + rxsize > self.out_ds.fRasterXSizeWorld: + rxsize = self.out_ds.fRasterXSizeWorld - rx + wxsize = int(rxsize/float(tsize) * self.tilesize) + if ry + rysize > self.out_ds.fRasterYSizeWorld: + rysize = self.out_ds.fRasterYSizeWorld - ry + wysize = int(rysize/float(tsize) * self.tilesize) + + # Convert rx, ry back to non-world coordinates + rx = int(float(self.out_ds.RasterXSize) * + (float(rx) / self.out_ds.fRasterXSizeWorld)) + ry = int(float(self.out_ds.RasterYSize) * + (float(ry) / self.out_ds.fRasterYSizeWorld)) + rxsize = int(float(self.out_ds.RasterXSize) * + (float(rxsize) / self.out_ds.fRasterXSizeWorld)) + rysize = int(float(self.out_ds.RasterYSize) * + (float(rysize) / self.out_ds.fRasterYSizeWorld)) + + wxsize -= 1 # 1bto4b + wysize -= 1 # 1bto4b + + #print("Extent: ", (tx, ty, tz, tsize), (rx, ry, rxsize, rysize), (wx, wy, wxsize, wysize), (self.out_ds.fRasterXOrigin, self.out_ds.fRasterYOrigin)) + else: # 'raster' profile: + # tilesize in raster coordinates for actual zoom + tsize = int(self.tsize[tz]) + xsize = self.out_ds.RasterXSize # size of the raster in pixels + ysize = self.out_ds.RasterYSize + if tz >= self.tmaxz: + querysize = self.tilesize + + rx = (tx) * tsize + rxsize = 0 + if tx == tmaxx: + rxsize = xsize % tsize + if rxsize == 0: + rxsize = tsize + + rysize = 0 + if ty == tmaxy: + rysize = ysize % tsize + if rysize == 0: + rysize = tsize + ry = ysize - (ty * tsize) - rysize + + wx, wy = 0, 0 + wxsize = int(rxsize/float(tsize) * self.tilesize) + wysize = int(rysize/float(tsize) * self.tilesize) + if wysize != self.tilesize: + wy = self.tilesize - wysize + + if self.options.verbose: + print("\tReadRaster Extent: ", + (rx, ry, rxsize, rysize), (wx, wy, wxsize, wysize)) + + # Query is in 'nearest neighbour' but can be bigger in then the tilesize + # We scale down the query to the tilesize by supplied algorithm. + + # Tile dataset in memory + + # 1bto4b + if self.isDEMtile: + dstile = self.mem_drv.Create( + '', self.tilesize, self.tilesize, tilebands, gdal.GDT_Byte) + else: + dstile = self.mem_drv.Create( + '', self.tilesize, self.tilesize, tilebands) + + data = alpha = None + # Read the source raster if anything is going inside the tile as per the computed + # geo_query + if rxsize != 0 and rysize != 0 and wxsize != 0 and wysize != 0: + # 1bto4b + if self.isDEMtile: + data = ds.GetRasterBand(1).ReadRaster( + rx, ry, rxsize, rysize, wxsize, wysize, buf_type=gdal.GDT_Float32) + else: + data = ds.ReadRaster(rx, ry, rxsize, rysize, wxsize, wysize, + band_list=list(range(1, self.dataBandsCount+1))) + alpha = self.alphaband.ReadRaster( + rx, ry, rxsize, rysize, wxsize, wysize) + + # The tile in memory is a transparent file by default. Write pixel values into it if + # any + if data: + # 1bto4b - both this full if and else + if self.isDEMtile: + if (wxsize * wysize) > 0: + data = struct.unpack('f' * wxsize * wysize, data) + else: + return + + if self.tilesize == querysize: + # Interpolate the values from four surrounding + + # This takes our 1d list of WxH data and pads it with a rect of none values + dataPad = list(data) + for i in reversed(range(1, wysize)): + dataPad.insert(wxsize * i, 0) + dataPad.insert(wxsize * i, 0) + for i in range(wxsize + 3): + dataPad.insert(0, 0) + for i in range(wxsize + 3): + dataPad.append(0) + + dataIn = [] + # Resample based on average of four + # averaging over: i, i + 1, i + wxsize, i + wxsize + 1 + for y in range(wysize+2 - 1): + for x in range(wxsize+2 - 1): + i = x+(y*(wxsize+2)) + nW = dataPad[i] + nE = dataPad[i+1] + sW = dataPad[i+(wxsize+2)] + sE = dataPad[i+(wxsize+2)+1] + dataIn.append((nW + nE + sW + sE)/float(4)) + + # Get the surrounding eight tiles + # Get NW + if tx - 1 >= tminx and ty + 1 <= tmaxy: + rxNW, ryNW, rxsizeNW, rysizeNW, wxsizeNW, wysizeNW = getTilePxBounds(self, + tx - 1, ty + 1, tz, ds) + wxsizeNW -= 1 + wysizeNW -= 1 + if wxsizeNW != 0 and wysizeNW != 0: + dataNW = ds.GetRasterBand(1).ReadRaster( + rxNW, ryNW, rxsizeNW, rysizeNW, wxsizeNW, wysizeNW, buf_type=gdal.GDT_Float32) + if dataNW is not None and (wxsizeNW * wysizeNW) > 0: + dataNW = struct.unpack( + 'f' * wxsizeNW * wysizeNW, dataNW) + else: + dataNW = None + else: + dataNW = None + + # Get N + if ty + 1 <= tmaxy: + rxN, ryN, rxsizeN, rysizeN, wxsizeN, wysizeN = getTilePxBounds( + self, tx, ty + 1, tz, ds) + wxsizeN -= 1 + wysizeN -= 1 + if wxsizeN != 0 and wysizeN != 0: + dataN = ds.GetRasterBand(1).ReadRaster( + rxN, ryN, rxsizeN, rysizeN, wxsizeN, wysizeN, buf_type=gdal.GDT_Float32) + if dataN is not None and (wxsizeN * wysizeN) > 0: + dataN = struct.unpack( + 'f' * wxsizeN * wysizeN, dataN) + else: + dataN = None + else: + dataN = None + # Get NE + if tx + 1 <= tmaxx and ty + 1 <= tmaxy: + rxNE, ryNE, rxsizeNE, rysizeNE, wxsizeNE, wysizeNE = getTilePxBounds( + self, tx + 1, ty + 1, tz, ds) + wxsizeNE -= 1 + wysizeNE -= 1 + if wxsizeNE != 0 and wysizeNE != 0: + dataNE = ds.GetRasterBand(1).ReadRaster( + rxNE, ryNE, rxsizeNE, rysizeNE, wxsizeNE, wysizeNE, buf_type=gdal.GDT_Float32) + if dataNE is not None and (wxsizeNE * wysizeNE) > 0: + dataNE = struct.unpack( + 'f' * wxsizeNE * wysizeNE, dataNE) + else: + dataNE = None + else: + dataNE = None + # Get E + if tx + 1 <= tmaxx: + rxE, ryE, rxsizeE, rysizeE, wxsizeE, wysizeE = getTilePxBounds( + self, tx + 1, ty, tz, ds) + wxsizeE -= 1 + wysizeE -= 1 + if wxsizeE != 0 and wysizeE != 0: + dataE = ds.GetRasterBand(1).ReadRaster( + rxE, ryE, rxsizeE, rysizeE, wxsizeE, wysizeE, buf_type=gdal.GDT_Float32) + if dataE is not None and (wxsizeE * wysizeE) > 0: + dataE = struct.unpack( + 'f' * wxsizeE * wysizeE, dataE) + else: + dataE = None + else: + dataE = None + # Get SE + if tx + 1 <= tmaxx and ty - 1 >= tminy: + rxSE, rySE, rxsizeSE, rysizeSE, wxsizeSE, wysizeSE = getTilePxBounds( + self, tx + 1, ty - 1, tz, ds) + wxsizeSE -= 1 + wysizeSE -= 1 + if wxsizeSE != 0 and wysizeSE != 0: + dataSE = ds.GetRasterBand(1).ReadRaster( + rxSE, rySE, rxsizeSE, rysizeSE, wxsizeSE, wysizeSE, buf_type=gdal.GDT_Float32) + if dataSE is not None and (wxsizeSE * wysizeSE) > 0: + dataSE = struct.unpack( + 'f' * wxsizeSE * wysizeSE, dataSE) + else: + dataSE = None + else: + dataSE = None + # Get S + if ty - 1 >= tminy: + rxS, ryS, rxsizeS, rysizeS, wxsizeS, wysizeS = getTilePxBounds( + self, tx, ty - 1, tz, ds) + wxsizeS -= 1 + wysizeS -= 1 + if wxsizeS != 0 and wysizeS != 0: + dataS = ds.GetRasterBand(1).ReadRaster( + rxS, ryS, rxsizeS, rysizeS, wxsizeS, wysizeS, buf_type=gdal.GDT_Float32) + if dataS is not None and (wxsizeS * wysizeS) > 0: + dataS = struct.unpack( + 'f' * wxsizeS * wysizeS, dataS) + else: + dataS = None + else: + dataS = None + # Get SW + if tx - 1 >= tminx and ty - 1 >= tminy: + rxSW, rySW, rxsizeSW, rysizeSW, wxsizeSW, wysizeSW = getTilePxBounds( + self, tx - 1, ty - 1, tz, ds) + wxsizeSW -= 1 + wysizeSW -= 1 + if wxsizeSW != 0 and wysizeSW != 0: + dataSW = ds.GetRasterBand(1).ReadRaster( + rxSW, rySW, rxsizeSW, rysizeSW, wxsizeSW, wysizeSW, buf_type=gdal.GDT_Float32) + if dataSW is not None and (wxsizeSW * wysizeSW) > 0: + dataSW = struct.unpack( + 'f' * wxsizeSW * wysizeSW, dataSW) + else: + dataSW = None + else: + dataSW = None + # Get W + if tx - 1 >= tminx: + rxW, ryW, rxsizeW, rysizeW, wxsizeW, wysizeW = getTilePxBounds( + self, tx - 1, ty, tz, ds) + wxsizeW -= 1 + wysizeW -= 1 + if wxsizeW != 0 and wysizeW != 0: + dataW = ds.GetRasterBand(1).ReadRaster( + rxW, ryW, rxsizeW, rysizeW, wxsizeW, wysizeW, buf_type=gdal.GDT_Float32) + if dataW is not None and (wxsizeW * wysizeW) > 0: + dataW = struct.unpack( + 'f' * wxsizeW * wysizeW, dataW) + else: + dataW = None + else: + dataW = None + + # NW (uses N, NW, W) + fN = fNE = fE = fSE = fS = fSW = fW = fNW = 0 + values = 1 + if dataN is not None: + fN = dataN[len(dataN)-wxsizeN] + values = values + 1 + if dataNW is not None: + fNW = dataNW[len(dataNW)-1] + values = values + 1 + if dataW is not None: + fW = dataW[wxsizeW-1] + values = values + 1 + dataIn[0] = ((dataIn[0]*4) + fN + + fNW + fW)/float(values) + + # NE (uses N, NE, E) + fN = fNE = fE = fSE = fS = fSW = fW = fNW = 0 + values = 1 + if dataN is not None: + fN = dataN[len(dataN)-1] + values = values + 1 + if dataNE is not None: + fNE = dataNE[len(dataNE)-wxsizeNE] + values = values + 1 + if dataE is not None: + fE = dataE[0] + values = values + 1 + dataIn[wxsize] = ( + (dataIn[wxsize]*4) + fN + fNE + fE)/float(values) + + # SE (uses S, SE, E) + fN = fNE = fE = fSE = fS = fSW = fW = fNW = 0 + values = 1 + if dataS is not None: + fS = dataS[wxsizeS-1] + values = values + 1 + if dataSE is not None: + fSE = dataSE[0] + values = values + 1 + if dataE is not None: + fE = dataE[len(dataE)-wxsizeE] + values = values + 1 + dataIn[len(dataIn)-1] = ((dataIn[len(dataIn)-1] + * 4) + fS + fSE + fE)/float(values) + + # SW (uses S, SW, W) + fN = fNE = fE = fSE = fS = fSW = fW = fNW = 0 + values = 1 + if dataS is not None: + fS = dataS[0] + values = values + 1 + if dataSW is not None: + fSW = dataSW[wxsizeSW-1] + values = values + 1 + if dataW is not None: + fW = dataW[len(dataW)-1] + values = values + 1 + dataIn[len( + dataIn)-wxsize-1] = ((dataIn[len(dataIn)-wxsize-1]*4) + fS + fSW + fW)/float(values) + + # Then the edges minus corners + # N + if dataN is not None: + for i in range(1, wxsize): + dataIn[i] = ( + (dataIn[i]*4) + dataN[len(dataN)-wxsizeN-1+i] + dataN[len(dataN)-wxsizeN-1+i+1])/float(4) + else: + for i in range(1, wxsize): + dataIn[i] = (dataIn[i]*4)/float(2) + + # E + if dataE is not None: + for i in range(1, wysize): + dataIn[((i+1)*(wxsize+1)-1)] = ((dataIn[((i+1)*(wxsize+1)-1)] + * 4) + dataE[(i-1)*wxsizeE] + dataE[i*wxsizeE])/float(4) + else: + for i in range(1, wysize): + dataIn[( + (i+1)*(wxsize+1)-1)] = (dataIn[((i+1)*(wxsize+1)-1)]*4)/float(2) + + # S + if dataS is not None: + for i in range(1, wxsize): + dataIn[len(dataIn)-wxsize-1+i] = ( + (dataIn[len(dataIn)-wxsize-1+i]*4) + dataS[i-1] + dataS[i])/float(4) + else: + for i in range(1, wxsize): + dataIn[len( + dataIn)-wxsize-1+i] = (dataIn[len(dataIn)-wxsize-1+i]*4)/float(2) + + # W + if dataW is not None: + for i in range(1, wysize): + dataIn[(i)*(wxsize+1)] = ((dataIn[(i)*(wxsize+1)]*4) + + dataW[i*wxsizeW-1] + dataW[(i+1)*wxsizeW-1])/float(4) + else: + for i in range(1, wysize): + dataIn[(i)*(wxsize+1)] = (dataIn[(i) + * (wxsize+1)]*4)/float(2) + + data1 = [] + data2 = [] + data3 = [] + data4 = [] + for f in dataIn: + f = str(binary(f)) + data1.append(int(f[:8], 2)) + data2.append(int(f[8:16], 2)) + data3.append(int(f[16:24], 2)) + data4.append(int(f[24:], 2)) + + data1s = '' + data2s = '' + data3s = '' + data4s = '' + indx = 0 + for v in data1: + data1s += struct.pack('B', data1[indx]) + data2s += struct.pack('B', data2[indx]) + data3s += struct.pack('B', data3[indx]) + data4s += struct.pack('B', data4[indx]) + indx += 1 + dstile.GetRasterBand(1).WriteRaster( + wx, wy, wxsize + 1, wysize + 1, data1s, buf_type=gdal.GDT_Byte) + dstile.GetRasterBand(2).WriteRaster( + wx, wy, wxsize + 1, wysize + 1, data2s, buf_type=gdal.GDT_Byte) + dstile.GetRasterBand(3).WriteRaster( + wx, wy, wxsize + 1, wysize + 1, data3s, buf_type=gdal.GDT_Byte) + dstile.GetRasterBand(4).WriteRaster( + wx, wy, wxsize + 1, wysize + 1, data4s, buf_type=gdal.GDT_Byte) + elif wxsize != 0 and wysize != 0: + # Big ReadRaster query in memory scaled to the tilesize - all but 'near' algo + dsquery = self.mem_drv.Create( + '', querysize, querysize, tilebands, gdal.GDT_Byte) # 1bto4b + # TODO: fill the null value in case a tile without alpha is produced (now only png tiles are supported) + # for i in range(1, tilebands+1): + # dsquery.GetRasterBand(1).Fill(tilenodata) + # dsquery.WriteRaster(wx, wy, wxsize, wysize, data, band_list=list(range(1,self.dataBandsCount+1)))###############1bto4b + # dsquery.WriteRaster(wx, wy, wxsize, wysize, alpha, band_list=[tilebands])###############################1bto4b + + # 1bto4b + data = ds.GetRasterBand(1).ReadRaster( + rx, ry, rxsize, rysize, wxsize, wysize, buf_type=gdal.GDT_Float32) + + data = struct.unpack('f' * wxsize * wysize, data) + data1 = [] + data2 = [] + data3 = [] + data4 = [] + for f in data: + f = str(binary(f)) + data1.append(int(f[:8], 2)) + data2.append(int(f[8:16], 2)) + data3.append(int(f[16:24], 2)) + data4.append(int(f[24:], 2)) + + data1s = '' + data2s = '' + data3s = '' + data4s = '' + indx = 0 + for v in data1: + data1s += struct.pack('B', data1[indx]) + data2s += struct.pack('B', data2[indx]) + data3s += struct.pack('B', data3[indx]) + data4s += struct.pack('B', data4[indx]) + indx += 1 + + dsquery.GetRasterBand(1).WriteRaster( + wx, wy, wxsize, wysize, data1s, buf_type=gdal.GDT_Byte) + dsquery.GetRasterBand(2).WriteRaster( + wx, wy, wxsize, wysize, data2s, buf_type=gdal.GDT_Byte) + dsquery.GetRasterBand(3).WriteRaster( + wx, wy, wxsize, wysize, data3s, buf_type=gdal.GDT_Byte) + dsquery.GetRasterBand(4).WriteRaster( + wx, wy, wxsize, wysize, data4s, buf_type=gdal.GDT_Byte) + # sys.exit('done') + # 1bto4b + + self.scale_query_to_tile( + dsquery, dstile, tilefilename) + del dsquery + + else: + if self.tilesize == querysize: + # Use the ReadRaster result directly in tiles ('nearest neighbour' query) + dstile.WriteRaster(wx, wy, wxsize, wysize, data, + band_list=list(range(1, self.dataBandsCount+1))) + dstile.WriteRaster( + wx, wy, wxsize, wysize, alpha, band_list=[tilebands]) + + # Note: For source drivers based on WaveLet compression (JPEG2000, ECW, + # MrSID) the ReadRaster function returns high-quality raster (not ugly + # nearest neighbour) + # TODO: Use directly 'near' for WaveLet files + else: + # Big ReadRaster query in memory scaled to the tilesize - all but 'near' + # algo + dsquery = self.mem_drv.Create( + '', querysize, querysize, tilebands) + # TODO: fill the null value in case a tile without alpha is produced (now + # only png tiles are supported) + dsquery.WriteRaster(wx, wy, wxsize, wysize, data, + band_list=list(range(1, self.dataBandsCount+1))) + dsquery.WriteRaster( + wx, wy, wxsize, wysize, alpha, band_list=[tilebands]) + + self.scale_query_to_tile( + dsquery, dstile, tilefilename) + del dsquery + + del data + + if self.options.resampling != 'antialias': + # Write a copy of tile to png/jpg + self.out_drv.CreateCopy(tilefilename, dstile, strict=0) + + del dstile + + # Create a KML file for this tile. + if self.kml: + kmlfilename = os.path.join( + self.output, str(tz), str(tx), '%d.kml' % ty) + if not self.options.resume or not os.path.exists(kmlfilename): + f = open(kmlfilename, 'wb') + f.write(self.generate_kml(tx, ty, tz).encode('utf-8')) + f.close() + + if not self.options.verbose and not self.options.quiet: + self.progressbar(ti / float(tcount)) + + def generate_overview_tiles(self): + """Generation of the overview tiles (higher in the pyramid) based on existing tiles""" + + if not self.options.quiet: + print("Generating Overview Tiles:") + + # 1bto4b + if self.isDEMtile: + tilebands = 4 + else: + tilebands = self.dataBandsCount + 1 + + # Usage of existing tiles: from 4 underlying tiles generate one as overview. + + tcount = 0 + for tz in range(self.tmaxz-1, self.tminz-1, -1): + tminx, tminy, tmaxx, tmaxy = self.tminmax[tz] + tcount += (1+abs(tmaxx-tminx)) * (1+abs(tmaxy-tminy)) + + ti = 0 + + for tz in range(self.tmaxz-1, self.tminz-1, -1): + tminx, tminy, tmaxx, tmaxy = self.tminmax[tz] + for ty in range(tmaxy, tminy-1, -1): + for tx in range(tminx, tmaxx+1): + + if self.stopped: + break + + ti += 1 + tilefilename = os.path.join(self.output, + str(tz), + str(tx), + "%s.%s" % (ty, self.tileext)) + + if self.options.verbose: + print(ti, '/', tcount, tilefilename) + + if self.options.resume and os.path.exists(tilefilename): + if self.options.verbose: + print("Tile generation skipped because of --resume") + else: + self.progressbar(ti / float(tcount)) + continue + + # Create directories for the tile + if not os.path.exists(os.path.dirname(tilefilename)): + os.makedirs(os.path.dirname(tilefilename)) + + dsquery = self.mem_drv.Create( + '', 2*self.tilesize, 2*self.tilesize, tilebands) + # TODO: fill the null value + dstile = self.mem_drv.Create( + '', self.tilesize, self.tilesize, tilebands) + + # TODO: Implement more clever walking on the tiles with cache functionality + # probably walk should start with reading of four tiles from top left corner + # Hilbert curve + + children = [] + # Read the tiles and write them to query window + for y in range(2*ty, 2*ty+2): + for x in range(2*tx, 2*tx+2): + minx, miny, maxx, maxy = self.tminmax[tz+1] + if x >= minx and x <= maxx and y >= miny and y <= maxy: + dsquerytile = gdal.Open( + os.path.join(self.output, str(tz+1), str(x), + "%s.%s" % (y, self.tileext)), + gdal.GA_ReadOnly) + if (ty == 0 and y == 1) or (ty != 0 and (y % (2*ty)) != 0): + tileposy = 0 + else: + tileposy = self.tilesize + if tx: + tileposx = x % (2*tx) * self.tilesize + elif tx == 0 and x == 1: + tileposx = self.tilesize + else: + tileposx = 0 + dsquery.WriteRaster( + tileposx, tileposy, self.tilesize, self.tilesize, + dsquerytile.ReadRaster( + 0, 0, self.tilesize, self.tilesize), + band_list=list(range(1, tilebands+1))) + children.append([x, y, tz+1]) + + self.scale_query_to_tile(dsquery, dstile, tilefilename) + # Write a copy of tile to png/jpg + if self.options.resampling != 'antialias': + # Write a copy of tile to png/jpg + self.out_drv.CreateCopy(tilefilename, dstile, strict=0) + + if self.options.verbose: + print("\tbuild from zoom", tz+1, + " tiles:", (2*tx, 2*ty), (2*tx+1, 2*ty), + (2*tx, 2*ty+1), (2*tx+1, 2*ty+1)) + + # Create a KML file for this tile. + if self.kml: + f = open(os.path.join( + self.output, '%d/%d/%d.kml' % (tz, tx, ty)), 'wb') + f.write(self.generate_kml( + tx, ty, tz, children).encode('utf-8')) + f.close() + + if not self.options.verbose and not self.options.quiet: + self.progressbar(ti / float(tcount)) + + def geo_query(self, ds, ulx, uly, lrx, lry, querysize=0): + """ + For given dataset and query in cartographic coordinates returns parameters for ReadRaster() + in raster coordinates and x/y shifts (for border tiles). If the querysize is not given, the + extent is returned in the native resolution of dataset ds. + + raises Gdal2TilesError if the dataset does not contain anything inside this geo_query + """ + geotran = ds.GetGeoTransform() + rx = int((ulx - geotran[0]) / geotran[1] + 0.001) + ry = int((uly - geotran[3]) / geotran[5] + 0.001) + rxsize = int((lrx - ulx) / geotran[1] + 0.5) + rysize = int((lry - uly) / geotran[5] + 0.5) + + if not querysize: + wxsize, wysize = rxsize, rysize + else: + wxsize, wysize = querysize, querysize + + # Coordinates should not go out of the bounds of the raster + wx = 0 + if rx < 0: + rxshift = abs(rx) + wx = int(wxsize * (float(rxshift) / rxsize)) + wxsize = wxsize - wx + rxsize = rxsize - int(rxsize * (float(rxshift) / rxsize)) + rx = 0 + if rx+rxsize > ds.RasterXSize: + wxsize = int(wxsize * (float(ds.RasterXSize - rx) / rxsize)) + rxsize = ds.RasterXSize - rx + + wy = 0 + if ry < 0: + ryshift = abs(ry) + wy = int(wysize * (float(ryshift) / rysize)) + wysize = wysize - wy + rysize = rysize - int(rysize * (float(ryshift) / rysize)) + ry = 0 + if ry+rysize > ds.RasterYSize: + wysize = int(wysize * (float(ds.RasterYSize - ry) / rysize)) + rysize = ds.RasterYSize - ry + + return (rx, ry, rxsize, rysize), (wx, wy, wxsize, wysize) + + def scale_query_to_tile(self, dsquery, dstile, tilefilename=''): + """Scales down query dataset to the tile dataset""" + + querysize = dsquery.RasterXSize + tilesize = dstile.RasterXSize + tilebands = dstile.RasterCount + + if self.options.resampling == 'average': + + # Function: gdal.RegenerateOverview() + for i in range(1, tilebands+1): + # Black border around NODATA + res = gdal.RegenerateOverview(dsquery.GetRasterBand(i), dstile.GetRasterBand(i), + 'average') + if res != 0: + self.error("RegenerateOverview() failed on %s, error %d" % ( + tilefilename, res)) + + elif self.options.resampling == 'antialias': + + # Scaling by PIL (Python Imaging Library) - improved Lanczos + array = numpy.zeros((querysize, querysize, tilebands), numpy.uint8) + for i in range(tilebands): + array[:, :, i] = gdalarray.BandReadAsArray(dsquery.GetRasterBand(i+1), + 0, 0, querysize, querysize) + im = Image.fromarray(array, 'RGBA') # Always four bands + im1 = im.resize((tilesize, tilesize), Image.ANTIALIAS) + if os.path.exists(tilefilename): + im0 = Image.open(tilefilename) + im1 = Image.composite(im1, im0, im1) + im1.save(tilefilename, self.tiledriver) + + else: + + # Other algorithms are implemented by gdal.ReprojectImage(). + dsquery.SetGeoTransform((0.0, tilesize / float(querysize), 0.0, 0.0, 0.0, + tilesize / float(querysize))) + dstile.SetGeoTransform((0.0, 1.0, 0.0, 0.0, 0.0, 1.0)) + + res = gdal.ReprojectImage( + dsquery, dstile, None, None, self.resampling) + if res != 0: + self.error("ReprojectImage() failed on %s, error %d" % + (tilefilename, res)) + + def generate_tilemapresource(self): + """ + Template for tilemapresource.xml. Returns filled string. Expected variables: + title, north, south, east, west, isepsg4326, projection, publishurl, + zoompixels, tilesize, tileformat, profile + """ + + args = {} + args['title'] = self.options.title + args['south'], args['west'], args['north'], args['east'] = self.swne + args['tilesize'] = self.tilesize + args['tileformat'] = self.tileext + args['publishurl'] = self.options.url + args['profile'] = self.options.profile + + if self.options.profile == 'mercator': + args['srs'] = "EPSG:3857" + elif self.options.profile == 'geodetic': + args['srs'] = "EPSG:4326" + elif self.options.s_srs: + args['srs'] = self.options.s_srs + elif self.out_srs: + args['srs'] = self.out_srs.ExportToWkt() + else: + args['srs'] = "" + + s = """<?xml version="1.0" encoding="utf-8"?> + <TileMap version="1.0.0" tilemapservice="http://tms.osgeo.org/1.0.0"> + <Title>%(title)s</Title> + <Abstract></Abstract> + <SRS>%(srs)s</SRS> + <BoundingBox minx="%(west).14f" miny="%(south).14f" maxx="%(east).14f" maxy="%(north).14f"/> + <Origin x="%(west).14f" y="%(south).14f"/> + <TileFormat width="%(tilesize)d" height="%(tilesize)d" mime-type="image/%(tileformat)s" extension="%(tileformat)s"/> + <TileSets profile="%(profile)s"> +""" % args # noqa + for z in range(self.tminz, self.tmaxz+1): + if self.options.profile == 'raster': + s += """ <TileSet href="%s%d" units-per-pixel="%.14f" order="%d"/>\n""" % ( + args['publishurl'], z, (2**(self.nativezoom-z) * self.out_gt[1]), z) + elif self.options.profile == 'mercator': + s += """ <TileSet href="%s%d" units-per-pixel="%.14f" order="%d"/>\n""" % ( + args['publishurl'], z, 156543.0339/2**z, z) + elif self.options.profile == 'geodetic': + s += """ <TileSet href="%s%d" units-per-pixel="%.14f" order="%d"/>\n""" % ( + args['publishurl'], z, 0.703125/2**z, z) + s += """ </TileSets> + </TileMap> + """ + return s + + def generate_kml(self, tx, ty, tz, children=None, **args): + """ + Template for the KML. Returns filled string. + """ + if not children: + children = [] + + args['tx'], args['ty'], args['tz'] = tx, ty, tz + args['tileformat'] = self.tileext + if 'tilesize' not in args: + args['tilesize'] = self.tilesize + + if 'minlodpixels' not in args: + args['minlodpixels'] = int(args['tilesize'] / 2) + if 'maxlodpixels' not in args: + args['maxlodpixels'] = int(args['tilesize'] * 8) + if children == []: + args['maxlodpixels'] = -1 + + if tx is None: + tilekml = False + args['title'] = self.options.title + else: + tilekml = True + args['title'] = "%d/%d/%d.kml" % (tz, tx, ty) + args['south'], args['west'], args['north'], args['east'] = self.tileswne( + tx, ty, tz) + + if tx == 0: + args['drawOrder'] = 2 * tz + 1 + elif tx is not None: + args['drawOrder'] = 2 * tz + else: + args['drawOrder'] = 0 + + url = self.options.url + if not url: + if tilekml: + url = "../../" + else: + url = "" + + s = """<?xml version="1.0" encoding="utf-8"?> + <kml xmlns="http://www.opengis.net/kml/2.2"> + <Document> + <name>%(title)s</name> + <description></description> + <Style> + <ListStyle id="hideChildren"> + <listItemType>checkHideChildren</listItemType> + </ListStyle> + </Style>""" % args + if tilekml: + s += """ + <Region> + <LatLonAltBox> + <north>%(north).14f</north> + <south>%(south).14f</south> + <east>%(east).14f</east> + <west>%(west).14f</west> + </LatLonAltBox> + <Lod> + <minLodPixels>%(minlodpixels)d</minLodPixels> + <maxLodPixels>%(maxlodpixels)d</maxLodPixels> + </Lod> + </Region> + <GroundOverlay> + <drawOrder>%(drawOrder)d</drawOrder> + <Icon> + <href>%(ty)d.%(tileformat)s</href> + </Icon> + <LatLonBox> + <north>%(north).14f</north> + <south>%(south).14f</south> + <east>%(east).14f</east> + <west>%(west).14f</west> + </LatLonBox> + </GroundOverlay> + """ % args + + for cx, cy, cz in children: + csouth, cwest, cnorth, ceast = self.tileswne(cx, cy, cz) + s += """ + <NetworkLink> + <name>%d/%d/%d.%s</name> + <Region> + <LatLonAltBox> + <north>%.14f</north> + <south>%.14f</south> + <east>%.14f</east> + <west>%.14f</west> + </LatLonAltBox> + <Lod> + <minLodPixels>%d</minLodPixels> + <maxLodPixels>-1</maxLodPixels> + </Lod> + </Region> + <Link> + <href>%s%d/%d/%d.kml</href> + <viewRefreshMode>onRegion</viewRefreshMode> + <viewFormat/> + </Link> + </NetworkLink> + """ % (cz, cx, cy, args['tileformat'], cnorth, csouth, ceast, cwest, + args['minlodpixels'], url, cz, cx, cy) + + s += """ </Document> + </kml> + """ + return s + + def generate_googlemaps(self): + """ + Template for googlemaps.html implementing Overlay of tiles for 'mercator' profile. + It returns filled string. Expected variables: + title, googlemapskey, north, south, east, west, minzoom, maxzoom, tilesize, tileformat, + publishurl + """ + args = {} + args['title'] = self.options.title + args['googlemapskey'] = self.options.googlekey + args['south'], args['west'], args['north'], args['east'] = self.swne + args['minzoom'] = self.tminz + args['maxzoom'] = self.tmaxz + args['tilesize'] = self.tilesize + args['tileformat'] = self.tileext + args['publishurl'] = self.options.url + args['copyright'] = self.options.copyright + + s = r"""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> + <head> + <title>%(title)s</title> + <meta http-equiv="content-type" content="text/html; charset=utf-8"/> + <meta http-equiv='imagetoolbar' content='no'/> + <style type="text/css"> v\:* {behavior:url(#default#VML);} + html, body { overflow: hidden; padding: 0; height: 100%%; width: 100%%; font-family: 'Lucida Grande',Geneva,Arial,Verdana,sans-serif; } + body { margin: 10px; background: #fff; } + h1 { margin: 0; padding: 6px; border:0; font-size: 20pt; } + # header { height: 43px; padding: 0; background-color: #eee; border: 1px solid #888; } + # subheader { height: 12px; text-align: right; font-size: 10px; color: #555;} + # map { height: 95%%; border: 1px solid #888; } + </style> + <script src='http://maps.google.com/maps?file=api&v=2&key=%(googlemapskey)s'></script> + <script> + //<![CDATA[ + + /* + * Constants for given map + * TODO: read it from tilemapresource.xml + */ + + var mapBounds = new GLatLngBounds(new GLatLng(%(south)s, %(west)s), new GLatLng(%(north)s, %(east)s)); + var mapMinZoom = %(minzoom)s; + var mapMaxZoom = %(maxzoom)s; + + var opacity = 0.75; + var map; + var hybridOverlay; + + /* + * Create a Custom Opacity GControl + * http://www.maptiler.org/google-maps-overlay-opacity-control/ + */ + + var CTransparencyLENGTH = 58; + // maximum width that the knob can move (slide width minus knob width) + + function CTransparencyControl( overlay ) { + this.overlay = overlay; + this.opacity = overlay.getTileLayer().getOpacity(); + } + CTransparencyControl.prototype = new GControl(); + + // This function positions the slider to match the specified opacity + CTransparencyControl.prototype.setSlider = function(pos) { + var left = Math.round((CTransparencyLENGTH*pos)); + this.slide.left = left; + this.knob.style.left = left+"px"; + this.knob.style.top = "0px"; + } + + // This function reads the slider and sets the overlay opacity level + CTransparencyControl.prototype.setOpacity = function() { + // set the global variable + opacity = this.slide.left/CTransparencyLENGTH; + this.map.clearOverlays(); + this.map.addOverlay(this.overlay, { zPriority: 0 }); + if (this.map.getCurrentMapType() == G_HYBRID_MAP) { + this.map.addOverlay(hybridOverlay); + } + } + + // This gets called by the API when addControl(new CTransparencyControl()) + CTransparencyControl.prototype.initialize = function(map) { + var that=this; + this.map = map; + + // Is this MSIE, if so we need to use AlphaImageLoader + var agent = navigator.userAgent.toLowerCase(); + if ((agent.indexOf("msie") > -1) && (agent.indexOf("opera") < 1)){this.ie = true} else {this.ie = false} + + // create the background graphic as a <div> containing an image + var container = document.createElement("div"); + container.style.width="70px"; + container.style.height="21px"; + + // Handle transparent PNG files in MSIE + if (this.ie) { + var loader = "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://www.maptiler.org/img/opacity-slider.png', sizingMethod='crop');"; + container.innerHTML = '<div style="height:21px; width:70px; ' +loader+ '" ></div>'; + } else { + container.innerHTML = '<div style="height:21px; width:70px; background-image: url(http://www.maptiler.org/img/opacity-slider.png)" ></div>'; + } + + // create the knob as a GDraggableObject + // Handle transparent PNG files in MSIE + if (this.ie) { + var loader = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://www.maptiler.org/img/opacity-slider.png', sizingMethod='crop');"; + this.knob = document.createElement("div"); + this.knob.style.height="21px"; + this.knob.style.width="13px"; + this.knob.style.overflow="hidden"; + this.knob_img = document.createElement("div"); + this.knob_img.style.height="21px"; + this.knob_img.style.width="83px"; + this.knob_img.style.filter=loader; + this.knob_img.style.position="relative"; + this.knob_img.style.left="-70px"; + this.knob.appendChild(this.knob_img); + } else { + this.knob = document.createElement("div"); + this.knob.style.height="21px"; + this.knob.style.width="13px"; + this.knob.style.backgroundImage="url(http://www.maptiler.org/img/opacity-slider.png)"; + this.knob.style.backgroundPosition="-70px 0px"; + } + container.appendChild(this.knob); + this.slide=new GDraggableObject(this.knob, {container:container}); + this.slide.setDraggableCursor('pointer'); + this.slide.setDraggingCursor('pointer'); + this.container = container; + + // attach the control to the map + map.getContainer().appendChild(container); + + // init slider + this.setSlider(this.opacity); + + // Listen for the slider being moved and set the opacity + GEvent.addListener(this.slide, "dragend", function() {that.setOpacity()}); + //GEvent.addListener(this.container, "click", function( x, y ) { alert(x, y) }); + + return container; + } + + // Set the default position for the control + CTransparencyControl.prototype.getDefaultPosition = function() { + return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 47)); + } + + /* + * Full-screen Window Resize + */ + + function getWindowHeight() { + if (self.innerHeight) return self.innerHeight; + if (document.documentElement && document.documentElement.clientHeight) + return document.documentElement.clientHeight; + if (document.body) return document.body.clientHeight; + return 0; + } + + function getWindowWidth() { + if (self.innerWidth) return self.innerWidth; + if (document.documentElement && document.documentElement.clientWidth) + return document.documentElement.clientWidth; + if (document.body) return document.body.clientWidth; + return 0; + } + + function resize() { + var map = document.getElementById("map"); + var header = document.getElementById("header"); + var subheader = document.getElementById("subheader"); + map.style.height = (getWindowHeight()-80) + "px"; + map.style.width = (getWindowWidth()-20) + "px"; + header.style.width = (getWindowWidth()-20) + "px"; + subheader.style.width = (getWindowWidth()-20) + "px"; + // map.checkResize(); + } + + + /* + * Main load function: + */ + + function load() { + + if (GBrowserIsCompatible()) { + + // Bug in the Google Maps: Copyright for Overlay is not correctly displayed + var gcr = GMapType.prototype.getCopyrights; + GMapType.prototype.getCopyrights = function(bounds,zoom) { + return ["%(copyright)s"].concat(gcr.call(this,bounds,zoom)); + } + + map = new GMap2( document.getElementById("map"), { backgroundColor: '#fff' } ); + + map.addMapType(G_PHYSICAL_MAP); + map.setMapType(G_PHYSICAL_MAP); + + map.setCenter( mapBounds.getCenter(), map.getBoundsZoomLevel( mapBounds )); + + hybridOverlay = new GTileLayerOverlay( G_HYBRID_MAP.getTileLayers()[1] ); + GEvent.addListener(map, "maptypechanged", function() { + if (map.getCurrentMapType() == G_HYBRID_MAP) { + map.addOverlay(hybridOverlay); + } else { + map.removeOverlay(hybridOverlay); + } + } ); + + var tilelayer = new GTileLayer(GCopyrightCollection(''), mapMinZoom, mapMaxZoom); + var mercator = new GMercatorProjection(mapMaxZoom+1); + tilelayer.getTileUrl = function(tile,zoom) { + if ((zoom < mapMinZoom) || (zoom > mapMaxZoom)) { + return "http://www.maptiler.org/img/none.png"; + } + var ymax = 1 << zoom; + var y = ymax - tile.y -1; + var tileBounds = new GLatLngBounds( + mercator.fromPixelToLatLng( new GPoint( (tile.x)*256, (tile.y+1)*256 ) , zoom ), + mercator.fromPixelToLatLng( new GPoint( (tile.x+1)*256, (tile.y)*256 ) , zoom ) + ); + if (mapBounds.intersects(tileBounds)) { + return zoom+"/"+tile.x+"/"+y+".png"; + } else { + return "http://www.maptiler.org/img/none.png"; + } + } + // IE 7-: support for PNG alpha channel + // Unfortunately, the opacity for whole overlay is then not changeable, either or... + tilelayer.isPng = function() { return true;}; + tilelayer.getOpacity = function() { return opacity; } + + overlay = new GTileLayerOverlay( tilelayer ); + map.addOverlay(overlay); + + map.addControl(new GLargeMapControl()); + map.addControl(new GHierarchicalMapTypeControl()); + map.addControl(new CTransparencyControl( overlay )); + """ % args # noqa + if self.kml: + s += """ + map.addMapType(G_SATELLITE_3D_MAP); + map.getEarthInstance(getEarthInstanceCB); + """ + s += """ + + map.enableContinuousZoom(); + map.enableScrollWheelZoom(); + + map.setMapType(G_HYBRID_MAP); + } + resize(); + } + """ + if self.kml: + s += """ + function getEarthInstanceCB(object) { + var ge = object; + + if (ge) { + var url = document.location.toString(); + url = url.substr(0,url.lastIndexOf('/'))+'/doc.kml'; + var link = ge.createLink(""); + if ("%(publishurl)s") { link.setHref("%(publishurl)s/doc.kml") } + else { link.setHref(url) }; + var networkLink = ge.createNetworkLink(""); + networkLink.setName("TMS Map Overlay"); + networkLink.setFlyToView(true); + networkLink.setLink(link); + ge.getFeatures().appendChild(networkLink); + } else { + // alert("You should open a KML in Google Earth"); + // add div with the link to generated KML... - maybe JavaScript redirect to the URL of KML? + } + } + """ % args # noqa + s += """ + onresize=function(){ resize(); }; + + //]]> + </script> + </head> + <body onload="load()"> + <div id="header"><h1>%(title)s</h1></div> + <div id="subheader">Generated by <a href="http://www.klokan.cz/projects/gdal2tiles/">GDAL2Tiles</a>, Copyright © 2008 <a href="http://www.klokan.cz/">Klokan Petr Pridal</a>, <a href="http://www.gdal.org/">GDAL</a> & <a href="http://www.osgeo.org/">OSGeo</a> <a href="http://code.google.com/soc/">GSoC</a> + <!-- PLEASE, LET THIS NOTE ABOUT AUTHOR AND PROJECT SOMEWHERE ON YOUR WEBSITE, OR AT LEAST IN THE COMMENT IN HTML. THANK YOU --> + </div> + <div id="map"></div> + </body> + </html> + """ % args # noqa + + return s + + def generate_leaflet(self): + """ + Template for leaflet.html implementing overlay of tiles for 'mercator' profile. + It returns filled string. Expected variables: + title, north, south, east, west, minzoom, maxzoom, tilesize, tileformat, publishurl + """ + + args = {} + args['title'] = self.options.title.replace('"', '\\"') + args['htmltitle'] = self.options.title + args['south'], args['west'], args['north'], args['east'] = self.swne + args['centerlon'] = (args['north'] + args['south']) / 2. + args['centerlat'] = (args['west'] + args['east']) / 2. + args['minzoom'] = self.tminz + args['maxzoom'] = self.tmaxz + args['beginzoom'] = self.tmaxz + args['tilesize'] = self.tilesize # not used + args['tileformat'] = self.tileext + args['publishurl'] = self.options.url # not used + args['copyright'] = self.options.copyright.replace('"', '\\"') + + s = """<!DOCTYPE html> + <html lang="en"> + <head> + <meta charset="utf-8"> + <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' /> + <title>%(htmltitle)s</title> + + <!-- Leaflet --> + <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.css" /> + <script src="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.js"></script> + + <style> + body { margin:0; padding:0; } + body, table, tr, td, th, div, h1, h2, input { font-family: "Calibri", "Trebuchet MS", "Ubuntu", Serif; font-size: 11pt; } + # map { position:absolute; top:0; bottom:0; width:100%%; } /* full size */ + .ctl { + padding: 2px 10px 2px 10px; + background: white; + background: rgba(255,255,255,0.9); + box-shadow: 0 0 15px rgba(0,0,0,0.2); + border-radius: 5px; + text-align: right; + } + .title { + font-size: 18pt; + font-weight: bold; + } + .src { + font-size: 10pt; + } + + </style> + + </head> + <body> + + <div id="map"></div> + + <script> + /* **** Leaflet **** */ + + // Base layers + // .. OpenStreetMap + var osm = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'}); + + // .. CartoDB Positron + var cartodb = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a href="http://cartodb.com/attributions">CartoDB</a>'}); + + // .. OSM Toner + var toner = L.tileLayer('http://{s}.tile.stamen.com/toner/{z}/{x}/{y}.png', {attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.'}); + + // .. White background + var white = L.tileLayer("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAAA1BMVEX///+nxBvIAAAAH0lEQVQYGe3BAQ0AAADCIPunfg43YAAAAAAAAAAA5wIhAAAB9aK9BAAAAABJRU5ErkJggg=="); + + // Overlay layers (TMS) + var lyr = L.tileLayer('./{z}/{x}/{y}.%(tileformat)s', {tms: true, opacity: 0.7, attribution: "%(copyright)s"}); + + // Map + var map = L.map('map', { + center: [%(centerlon)s, %(centerlat)s], + zoom: %(beginzoom)s, + minZoom: %(minzoom)s, + maxZoom: %(maxzoom)s, + layers: [osm] + }); + + var basemaps = {"OpenStreetMap": osm, "CartoDB Positron": cartodb, "Stamen Toner": toner, "Without background": white} + var overlaymaps = {"Layer": lyr} + + // Title + var title = L.control(); + title.onAdd = function(map) { + this._div = L.DomUtil.create('div', 'ctl title'); + this.update(); + return this._div; + }; + title.update = function(props) { + this._div.innerHTML = "%(title)s"; + }; + title.addTo(map); + + // Note + var src = 'Generated by <a href="http://www.klokan.cz/projects/gdal2tiles/">GDAL2Tiles</a>, Copyright © 2008 <a href="http://www.klokan.cz/">Klokan Petr Pridal</a>, <a href="http://www.gdal.org/">GDAL</a> & <a href="http://www.osgeo.org/">OSGeo</a> <a href="http://code.google.com/soc/">GSoC</a>'; + var title = L.control({position: 'bottomleft'}); + title.onAdd = function(map) { + this._div = L.DomUtil.create('div', 'ctl src'); + this.update(); + return this._div; + }; + title.update = function(props) { + this._div.innerHTML = src; + }; + title.addTo(map); + + + // Add base layers + L.control.layers(basemaps, overlaymaps, {collapsed: false}).addTo(map); + + // Fit to overlay bounds (SW and NE points with (lat, lon)) + map.fitBounds([[%(south)s, %(east)s], [%(north)s, %(west)s]]); + + </script> + + </body> + </html> + + """ % args # noqa + + return s + + def generate_openlayers(self): + """ + Template for openlayers.html implementing overlay of available Spherical Mercator layers. + + It returns filled string. Expected variables: + title, bingkey, north, south, east, west, minzoom, maxzoom, tilesize, tileformat, publishurl + """ + + args = {} + args['title'] = self.options.title + args['bingkey'] = self.options.bingkey + args['south'], args['west'], args['north'], args['east'] = self.swne + args['minzoom'] = self.tminz + args['maxzoom'] = self.tmaxz + args['tilesize'] = self.tilesize + args['tileformat'] = self.tileext + args['publishurl'] = self.options.url + args['copyright'] = self.options.copyright + if self.options.tmscompatible: + args['tmsoffset'] = "-1" + else: + args['tmsoffset'] = "" + if self.options.profile == 'raster': + args['rasterzoomlevels'] = self.tmaxz+1 + args['rastermaxresolution'] = 2**(self.nativezoom) * self.out_gt[1] + + s = r"""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + <html xmlns="http://www.w3.org/1999/xhtml" + <head> + <title>%(title)s</title> + <meta http-equiv='imagetoolbar' content='no'/> + <style type="text/css"> v\:* {behavior:url(#default#VML);} + html, body { overflow: hidden; padding: 0; height: 100%%; width: 100%%; font-family: 'Lucida Grande',Geneva,Arial,Verdana,sans-serif; } + body { margin: 10px; background: #fff; } + h1 { margin: 0; padding: 6px; border:0; font-size: 20pt; } + # header { height: 43px; padding: 0; background-color: #eee; border: 1px solid #888; } + # subheader { height: 12px; text-align: right; font-size: 10px; color: #555;} + # map { height: 95%%; border: 1px solid #888; } + .olImageLoadError { display: none; } + .olControlLayerSwitcher .layersDiv { border-radius: 10px 0 0 10px; } + </style>""" % args # noqa + + if self.options.profile == 'mercator': + s += """ + <script src='http://maps.google.com/maps/api/js?sensor=false&v=3.7'></script> + """ % args + + s += """ + <script src="http://www.openlayers.org/api/2.12/OpenLayers.js"></script> + <script> + var map; + var mapBounds = new OpenLayers.Bounds( %(west)s, %(south)s, %(east)s, %(north)s); + var mapMinZoom = %(minzoom)s; + var mapMaxZoom = %(maxzoom)s; + var emptyTileURL = "http://www.maptiler.org/img/none.png"; + OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3; + + function init(){""" % args + + if self.options.profile == 'mercator': + s += """ + var options = { + div: "map", + controls: [], + projection: "EPSG:3857", + displayProjection: new OpenLayers.Projection("EPSG:4326"), + numZoomLevels: 20 + }; + map = new OpenLayers.Map(options); + + // Create Google Mercator layers + var gmap = new OpenLayers.Layer.Google("Google Streets", + { + type: google.maps.MapTypeId.ROADMAP, + sphericalMercator: true + }); + var gsat = new OpenLayers.Layer.Google("Google Satellite", + { + type: google.maps.MapTypeId.SATELLITE, + sphericalMercator: true + }); + var ghyb = new OpenLayers.Layer.Google("Google Hybrid", + { + type: google.maps.MapTypeId.HYBRID, + sphericalMercator: true + }); + var gter = new OpenLayers.Layer.Google("Google Terrain", + { + type: google.maps.MapTypeId.TERRAIN, + sphericalMercator: true + }); + + // Create Bing layers + var broad = new OpenLayers.Layer.Bing({ + name: "Bing Roads", + key: "%(bingkey)s", + type: "Road", + sphericalMercator: true + }); + var baer = new OpenLayers.Layer.Bing({ + name: "Bing Aerial", + key: "%(bingkey)s", + type: "Aerial", + sphericalMercator: true + }); + var bhyb = new OpenLayers.Layer.Bing({ + name: "Bing Hybrid", + key: "%(bingkey)s", + type: "AerialWithLabels", + sphericalMercator: true + }); + + // Create OSM layer + var osm = new OpenLayers.Layer.OSM("OpenStreetMap"); + + // create TMS Overlay layer + var tmsoverlay = new OpenLayers.Layer.TMS("TMS Overlay", "", + { + serviceVersion: '.', + layername: '.', + alpha: true, + type: '%(tileformat)s', + isBaseLayer: false, + getURL: getURL + }); + if (OpenLayers.Util.alphaHack() == false) { + tmsoverlay.setOpacity(0.7); + } + + map.addLayers([gmap, gsat, ghyb, gter, + broad, baer, bhyb, + osm, tmsoverlay]); + + var switcherControl = new OpenLayers.Control.LayerSwitcher(); + map.addControl(switcherControl); + switcherControl.maximizeControl(); + + map.zoomToExtent(mapBounds.transform(map.displayProjection, map.projection)); + """ % args # noqa + + elif self.options.profile == 'geodetic': + s += """ + var options = { + div: "map", + controls: [], + projection: "EPSG:4326" + }; + map = new OpenLayers.Map(options); + + var wms = new OpenLayers.Layer.WMS("VMap0", + "http://tilecache.osgeo.org/wms-c/Basic.py?", + { + layers: 'basic', + format: 'image/png' + } + ); + var tmsoverlay = new OpenLayers.Layer.TMS("TMS Overlay", "", + { + serviceVersion: '.', + layername: '.', + alpha: true, + type: '%(tileformat)s', + isBaseLayer: false, + getURL: getURL + }); + if (OpenLayers.Util.alphaHack() == false) { + tmsoverlay.setOpacity(0.7); + } + + map.addLayers([wms,tmsoverlay]); + + var switcherControl = new OpenLayers.Control.LayerSwitcher(); + map.addControl(switcherControl); + switcherControl.maximizeControl(); + + map.zoomToExtent(mapBounds); + """ % args # noqa + + elif self.options.profile == 'raster': + s += """ + var options = { + div: "map", + controls: [], + maxExtent: new OpenLayers.Bounds(%(west)s, %(south)s, %(east)s, %(north)s), + maxResolution: %(rastermaxresolution)f, + numZoomLevels: %(rasterzoomlevels)d + }; + map = new OpenLayers.Map(options); + + var layer = new OpenLayers.Layer.TMS("TMS Layer", "", + { + serviceVersion: '.', + layername: '.', + alpha: true, + type: '%(tileformat)s', + getURL: getURL + }); + + map.addLayer(layer); + map.zoomToExtent(mapBounds); + """ % args # noqa + + s += """ + map.addControls([new OpenLayers.Control.PanZoomBar(), + new OpenLayers.Control.Navigation(), + new OpenLayers.Control.MousePosition(), + new OpenLayers.Control.ArgParser(), + new OpenLayers.Control.Attribution()]); + } + """ % args + + if self.options.profile == 'mercator': + s += """ + function getURL(bounds) { + bounds = this.adjustBounds(bounds); + var res = this.getServerResolution(); + var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w)); + var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h)); + var z = this.getServerZoom(); + if (this.map.baseLayer.CLASS_NAME === 'OpenLayers.Layer.Bing') { + z+=1; + } + var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type; + var url = this.url; + if (OpenLayers.Util.isArray(url)) { + url = this.selectUrl(path, url); + } + if (mapBounds.intersectsBounds(bounds) && (z >= mapMinZoom) && (z <= mapMaxZoom)) { + return url + path; + } else { + return emptyTileURL; + } + } + """ % args # noqa + + elif self.options.profile == 'geodetic': + s += """ + function getURL(bounds) { + bounds = this.adjustBounds(bounds); + var res = this.getServerResolution(); + var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w)); + var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h)); + var z = this.getServerZoom()%(tmsoffset)s; + var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type; + var url = this.url; + if (OpenLayers.Util.isArray(url)) { + url = this.selectUrl(path, url); + } + if (mapBounds.intersectsBounds(bounds) && (z >= mapMinZoom) && (z <= mapMaxZoom)) { + return url + path; + } else { + return emptyTileURL; + } + } + """ % args # noqa + + elif self.options.profile == 'raster': + s += """ + function getURL(bounds) { + bounds = this.adjustBounds(bounds); + var res = this.getServerResolution(); + var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w)); + var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h)); + var z = this.getServerZoom(); + var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type; + var url = this.url; + if (OpenLayers.Util.isArray(url)) { + url = this.selectUrl(path, url); + } + if (mapBounds.intersectsBounds(bounds) && (z >= mapMinZoom) && (z <= mapMaxZoom)) { + return url + path; + } else { + return emptyTileURL; + } + } + """ % args # noqa + + s += """ + function getWindowHeight() { + if (self.innerHeight) return self.innerHeight; + if (document.documentElement && document.documentElement.clientHeight) + return document.documentElement.clientHeight; + if (document.body) return document.body.clientHeight; + return 0; + } + + function getWindowWidth() { + if (self.innerWidth) return self.innerWidth; + if (document.documentElement && document.documentElement.clientWidth) + return document.documentElement.clientWidth; + if (document.body) return document.body.clientWidth; + return 0; + } + + function resize() { + var map = document.getElementById("map"); + var header = document.getElementById("header"); + var subheader = document.getElementById("subheader"); + map.style.height = (getWindowHeight()-80) + "px"; + map.style.width = (getWindowWidth()-20) + "px"; + header.style.width = (getWindowWidth()-20) + "px"; + subheader.style.width = (getWindowWidth()-20) + "px"; + if (map.updateSize) { map.updateSize(); }; + } + + onresize=function(){ resize(); }; + + </script> + </head> + <body onload="init()"> + <div id="header"><h1>%(title)s</h1></div> + <div id="subheader">Generated by <a href="http://www.klokan.cz/projects/gdal2tiles/">GDAL2Tiles</a>, Copyright © 2008 <a href="http://www.klokan.cz/">Klokan Petr Pridal</a>, <a href="http://www.gdal.org/">GDAL</a> & <a href="http://www.osgeo.org/">OSGeo</a> <a href="http://code.google.com/soc/">GSoC</a> + <!-- PLEASE, LET THIS NOTE ABOUT AUTHOR AND PROJECT SOMEWHERE ON YOUR WEBSITE, OR AT LEAST IN THE COMMENT IN HTML. THANK YOU --> + </div> + <div id="map"></div> + <script type="text/javascript" >resize()</script> + </body> + </html>""" % args # noqa + + return s + + +def main(): + argv = gdal.GeneralCmdLineProcessor(sys.argv) + if argv: + gdal2tiles = GDAL2Tiles(argv[1:]) + gdal2tiles.process() + + +if __name__ == '__main__': + main() + +# vim: set tabstop=4 shiftwidth=4 expandtab: diff --git a/auxiliary/gdal2customtiles/gdal2tiles_3.5.2.py b/auxiliary/gdal2customtiles/legacy/gdal2tiles_3.5.2.py similarity index 100% rename from auxiliary/gdal2customtiles/gdal2tiles_3.5.2.py rename to auxiliary/gdal2customtiles/legacy/gdal2tiles_3.5.2.py diff --git a/auxiliary/gdal2customtiles/rasters2customtiles_3.5.2.py b/auxiliary/gdal2customtiles/legacy/rasters2customtiles_3.5.2.py similarity index 100% rename from auxiliary/gdal2customtiles/rasters2customtiles_3.5.2.py rename to auxiliary/gdal2customtiles/legacy/rasters2customtiles_3.5.2.py diff --git a/auxiliary/gdal2customtiles/legacy/readme.md b/auxiliary/gdal2customtiles/legacy/readme.md new file mode 100644 index 00000000..91152fd2 --- /dev/null +++ b/auxiliary/gdal2customtiles/legacy/readme.md @@ -0,0 +1,68 @@ +# gdal2customtiles + +This wraps together: + +- gdal2tiles4extent.py +- gdal2tiles1bto4b_v3.py + +--- + +## Raster Extents: + +Tile partial world rasters. + +**Requires:** + +- `-p raster` + - This is necessary for generating tiles with a custom extent. +- `-x` OR `--extentworld` followed by values `ulx,uly,lrx,lry,pixel_resolution` + - The extentworld is the full bounding area of the projection for the planetary body. The extentworld is the full bounding area of the projection for the planetary body. Units are in meters using upper left (ul) and lower right (lr) order. These values are reported from gdalinfo. Units are in meters using upper left (ul) and lower right (lr) order. These values are reported from gdalinfo. Values are separated by commas with no spaces. + +**Example:** + +``` +python gdal2customtiles.py -p raster --extentworld -4022404.001,4022036.893,-4022036.893,4022404.001,367.108150109358121 input.tif output_dir +``` + +_Notes:_ + +- Only works if set zoom (-z 0-10) encompasses the native zoom of the raster. +- 'ERROR 5's are expected. + +--- + +## Digital Elevation Model Tiles: + +Generate Digital Elevation Maps (DEMs) tiles. + +Any 32-bit image data can be encoded into the RGBA channels of a PNG. MMGIS uses this file type to create terrain meshes as well as for a data layer. + +- Certain resampling methods can corrupt `--dem` results. + +**Requires:** + +- `-m` or `--dem` + +**Example:** + +``` +python gdal2customtiles.py -p raster --extentworld -4022404.001,4022036.893,-4022036.893,4022404.001,367.108150109358121 --dem inputdem.tif output_dir +``` + +_Notes:_ + +- Does not include the convenience of rasterstotiles.py yet. +- Can only tile 32-bit images with --dem option. + +## gdal2tiles_3.5.2.py + +- `rasters2customtiles_3.5.2.py` and `gdal2tiles_3.5.2.py` support only the `--dem` option (and not `--raster` yet). `-m` no longer works and must be `--dem`. Tested with gdal 3.4.3. Upgraded to support multi-processes. See `python rasters2customtiles_3.5.2.py --help`. Unlike `gda2customtiles.py`, does not seam-match DEM tiles (better for Data Layers and Viewshed Tool, bad for 3D Globe). +- Adds the resampling algorithm `near-composite` that uses nearest-neighbor and ovarlays the new tile onto the old tile (if any in output directory) +- Certain resampling methods can corrupt `--dem` results. +- To support the value 0, all 0 data values get mapped to to the value 2^31 (2147483648) (RGBA=79,0,0,0) and then decoded by the MMGIS reader back to 0. This avoids clashes with other nondata-like values writing to 0,0,0,0 in the outputted pngs. + +**Example:** + +``` +python gdal2tiles_3.5.2.py --dem input.tif output_dir --srcnodata=-9999 -r near-composite --tilesize=128 +``` diff --git a/auxiliary/gdal2customtiles/rasters2customtiles.py b/auxiliary/gdal2customtiles/rasters2customtiles.py new file mode 100644 index 00000000..d89444d9 --- /dev/null +++ b/auxiliary/gdal2customtiles/rasters2customtiles.py @@ -0,0 +1,151 @@ +import sys +import subprocess +import optparse +from osgeo import gdal, osr + + +def optparse_init() -> optparse.OptionParser: + """Prepare the option parser for input (argv)""" + + usage = "Usage: %prog [options] input_file [output]" + p = optparse.OptionParser(usage) + p.add_option( + "--dem", + action="store_true", + dest="isDEMtile", + help="Indicate if the input is a Digital Elevation Model" + ) + p.add_option( + "--processes", + dest="processes", + type="int", + help="Number of processes to use for tiling", + ) + p.add_option( + "--tilesize", + dest="tilesize", + metavar="PIXELS", + type="int", + help="Width and height in pixel of a tile. Defaults to 256 (or 32 for --dem)", + ) + p.add_option( + "-z", + "--zoom", + dest="zoom", + help="Zoom levels to render (format:'2-5', '10-' or '10').", + ) + p.add_option( + "-e", + "--resume", + dest="resume", + action="store_true", + help="Resume mode. Generate only missing files.", + ) + p.add_option( + "-a", + "--srcnodata", + dest="srcnodata", + metavar="NODATA", + help="Value in the input dataset considered as transparent", + ) + return p + + +def GetExtent(gt, cols, rows): + ''' Return list of corner coordinates from a geotransform + + @type gt: C{tuple/list} + @param gt: geotransform + @type cols: C{int} + @param cols: number of columns in the dataset + @type rows: C{int} + @param rows: number of rows in the dataset + @rtype: C{[float,...,float]} + @return: coordinates of each corner + ''' + ext = [] + xarr = [0, cols] + yarr = [0, rows] + + for px in xarr: + for py in yarr: + x = gt[0]+(px*gt[1])+(py*gt[2]) + y = gt[3]+(px*gt[4])+(py*gt[5]) + ext.append([x, y]) + yarr.reverse() + return ext + + +def ReprojectCoords(coords, src_srs, tgt_srs): + ''' Reproject a list of x,y coordinates. + + @type geom: C{tuple/list} + @param geom: List of [[x,y],...[x,y]] coordinates + @type src_srs: C{osr.SpatialReference} + @param src_srs: OSR SpatialReference object + @type tgt_srs: C{osr.SpatialReference} + @param tgt_srs: OSR SpatialReference object + @rtype: C{tuple/list} + @return: List of transformed [[x,y],...[x,y]] coordinates + ''' + trans_coords = [] + transform = osr.CoordinateTransformation(src_srs, tgt_srs) + for x, y in coords: + x, y, z = transform.TransformPoint(x, y) + trans_coords.append([x, y]) + return trans_coords + + +def AutoGdalTranslate(geo_extent, cols, rows, raster): + gdal_translate = "gdal_translate -of VRT -a_srs EPSG:4326 -gcp 0 0 " + str(geo_extent[0][0]) + " " + str(geo_extent[0][1]) + " -gcp " + str(cols) + " 0 " + str(geo_extent[3][0]) + " " + str( + geo_extent[3][1]) + " -gcp " + str(cols) + " " + str(rows) + " " + str(geo_extent[2][0]) + " " + str(geo_extent[2][1]) + " " + raster + " " + raster[:-4] + ".vrt" + print(f"Running: {gdal_translate}\n") + subprocess.Popen(gdal_translate) + + +def AutoGdal2Tiles(raster, options, outputdir): + dem = "" + if options.isDEMtile is True: + dem = " --dem" + processes = "" + if options.processes is not None: + processes = f" --processes={options.processes}" + tilesize = "" + if options.tilesize is not None: + tilesize = f" --tilesize={options.tilesize}" + zoom = "" + if options.zoom is not None: + zoom = f" --zoom={options.zoom}" + resume = "" + if options.resume is True: + resume = " --resume" + srcnodata = " --srcnodata=0,0,0" + if options.srcnodata is not None: + srcnodata = f" --srcnodata={options.srcnodata}" + output = "" + if outputdir is not None: + output = f" {outputdir}" + gdal2tiles = f"python gdal2customtiles.py -n{dem}{processes}{tilesize}{zoom}{resume}{srcnodata} {raster[:-4]}.vrt{output}" + print(f"Running: {gdal2tiles}\n") + subprocess.Popen(gdal2tiles) + + +parser = optparse_init() +options, args = parser.parse_args(args=sys.argv) + +raster = args[1] +ds = gdal.Open(raster) + +gt = ds.GetGeoTransform() +cols = ds.RasterXSize +rows = ds.RasterYSize +extent = GetExtent(gt, cols, rows) + +src_srs = osr.SpatialReference() +src_srs.ImportFromWkt(ds.GetProjection()) +tgt_srs = src_srs.CloneGeogCS() + +geo_extent = ReprojectCoords(extent, src_srs, tgt_srs) + +AutoGdalTranslate(geo_extent, cols, rows, raster) +AutoGdal2Tiles(raster, options, args[2]) diff --git a/auxiliary/gdal2customtiles/readme.md b/auxiliary/gdal2customtiles/readme.md index bc83600f..da1cab9e 100644 --- a/auxiliary/gdal2customtiles/readme.md +++ b/auxiliary/gdal2customtiles/readme.md @@ -1,33 +1,38 @@ -# gdal2customtiles +# gdal2customtiles.py -This wraps together: +_Python 3.10.5_ -- gdal2tiles4extent.py -- gdal2tiles1bto4b_v3.py +Accepts all [gdal2tiles.py](https://gdal.org/programs/gdal2tiles.html) options. Built off of GDAL 3.5.2 and tested with GDAL 3.4.3, it adds the following new features and capabilities. --- ## Raster Extents: -Tile partial world rasters. +Tile partial world rasters. Useful for tiling non-mercator and non-geodetic projected data. **Requires:** - `-p raster` - This is necessary for generating tiles with a custom extent. -- `-x` OR `--extentworld` followed by values `ulx,uly,lrx,lry,pixel_resolution` +- `--extentworld` followed by values `ulx,uly,lrx,lry,pixel_resolution` - The extentworld is the full bounding area of the projection for the planetary body. The extentworld is the full bounding area of the projection for the planetary body. Units are in meters using upper left (ul) and lower right (lr) order. These values are reported from gdalinfo. Units are in meters using upper left (ul) and lower right (lr) order. These values are reported from gdalinfo. Values are separated by commas with no spaces. -**Example:** +#### Example: ``` -python gdal2customtiles.py -p raster --extentworld -4022404.001,4022036.893,-4022036.893,4022404.001,367.108150109358121 input.tif output_dir +python gdal2customtiles.py -p raster --extentworld -931100.000,931100.000,931100.000,-931100.000,100 inputs/WAC_GLOBAL_P900S0000_100M.tif outputs/WAC_GLOBAL_P900S0000_100M +python gdal2customtiles.py -p raster --extentworld -931100.000,931100.000,931100.000,-931100.000,100 inputs/ldem_87s_5mpp_hillshade.tif outputs/ldem_87s_5mpp_hillshade ``` +- `WAC_GLOBAL_P900S0000_100M.tif` is in Lunar South Polar projection (IAU2000:30120). Its data covers the full bounds of that projection's world-space (it's world extent/"extentworld") thus we use its bounds and pixel resolution directly from its metadata: `--extentworld -931100.000,931100.000,931100.000,-931100.000,100` + + - _Note: If your basemap does not cover the full world-space, you would need to compute the world-space's bounds and its resolution relative to your datasets_ + +- `ldem_87s_5mpp_hillshade.tif` is also in Lunar South Polar projection (IAU2000:30120). Its data only covers a small region of the projection's world-space. We still use the previous `--extentworld -931100.000,931100.000,931100.000,-931100.000,100` + _Notes:_ - Only works if set zoom (-z 0-10) encompasses the native zoom of the raster. -- 'ERROR 5's are expected. --- @@ -35,9 +40,7 @@ _Notes:_ Generate Digital Elevation Maps (DEMs) tiles. -Any 32-bit image data can be encoded into the RGBA channels of a PNG. MMGIS uses this file type to create terrain meshes as well as for a data layer. - -- Certain resampling methods can corrupt `--dem` results. +Any 32-bit image data can be encoded into the RGBA channels of a PNG. MMGIS uses this file type to create terrain meshes as well as for Data Layers. **Requires:** @@ -51,18 +54,33 @@ python gdal2customtiles.py -p raster --extentworld -4022404.001,4022036.893,-402 _Notes:_ -- Does not include the convenience of rasterstotiles.py yet. - Can only tile 32-bit images with --dem option. - -## gdal2tiles_3.5.2.py - -- `rasters2customtiles_3.5.2.py` and `gdal2tiles_3.5.2.py` support only the `--dem` option (and not `--raster` yet). `-m` no longer works and must be `--dem`. Tested with gdal 3.4.3. Upgraded to support multi-processes. See `python rasters2customtiles_3.5.2.py --help`. Unlike `gda2customtiles.py`, does not seam-match DEM tiles (better for Data Layers and Viewshed Tool, bad for 3D Globe). -- Adds the resampling algorithm `near-composite` that uses nearest-neighbor and ovarlays the new tile onto the old tile (if any in output directory) +- Current `--dem` tiles do not seam-match tile edges. This may or may not be desired (not seam-matching is better for Data Layers and the Viewshed Tool, but bad for MMGIS' 3D Globe/LithoSphere). If seam-matching is desired use `legacy/gdal2customtiles.py` or `legacy/gdal2customtiles_py27.py` - Certain resampling methods can corrupt `--dem` results. - To support the value 0, all 0 data values get mapped to to the value 2^31 (2147483648) (RGBA=79,0,0,0) and then decoded by the MMGIS reader back to 0. This avoids clashes with other nondata-like values writing to 0,0,0,0 in the outputted pngs. +--- + +## Compositing Tiles: + +Adds the resampling algorithm `near-composite` that uses nearest-neighbor resampling and overlays the new tile onto the old tile (if any in output directory). This makes it possible to accumulate or combine tilesets at the indivdual tile image level. Data in tiles can be overwritten by this process so be cognizant of run order and input extents. + **Example:** ``` -python gdal2tiles_3.5.2.py --dem input.tif output_dir --srcnodata=-9999 -r near-composite --tilesize=128 +python gdal2customtiles.py -r near-composite --srcnodata=-9999 --processes=40 --tilesize=128 --dem input_A.tif output_dir +python gdal2customtiles.py -r near-composite --srcnodata=-9999 --processes=40 --tilesize=128 --dem input_B.tif output_dir ``` + +_Notes:_ + +- Nodata values are treated as transparent and will not overwrite existing pixels in the output tile images. + +--- + +# raster2customtiles.py + +A convience script that wraps gda2customtiles.py. Translates the input data into EPSG:4326 and sets proper ground control points. Might be outdated. Use gdal2customtiles directly for the most control. + +**Usage:** +`rasters2customtiles.py [options] input_file [output]` or see `--help` diff --git a/config/css/config.css b/config/css/config.css index f369b8fa..fa9b8e5d 100644 --- a/config/css/config.css +++ b/config/css/config.css @@ -312,6 +312,9 @@ textarea { margin: 0px 161px 0px 173px; border-bottom: 2px solid #1565c0 !important; } +.col > .CodeMirror { + margin: 0px; +} #missions { margin: 5px 0px; @@ -442,19 +445,34 @@ textarea { display: flex; justify-content: space-between; } +.modal .layerHelp { + height: 35px; + padding: 0px 6px; + margin-right: 12px; + cursor: pointer; + color: #039be5; + transition: color 0.1s cubic-bezier(0.39, 0.575, 0.565, 1); +} .modal .clone { height: 35px; cursor: pointer; + margin-left: 12px; color: #777; transition: color 0.1s cubic-bezier(0.39, 0.575, 0.565, 1); } .modal .clone:hover { color: #000; } +#modal_uuid { + text-align: center; + margin: 20px 0px; + font-size: 14px; + color: #555; +} #toast-container { pointer-events: none; - top: 110px !important; + top: 48px !important; right: 6px !important; } diff --git a/config/css/jquery-ui.css b/config/css/jquery-ui.css index 90aa9a11..d394bd2d 100644 --- a/config/css/jquery-ui.css +++ b/config/css/jquery-ui.css @@ -1,1225 +1,1315 @@ -/*! jQuery UI - v1.11.4 - 2015-03-11 -* http://jqueryui.com -* Includes: core.css, accordion.css, autocomplete.css, button.css, datepicker.css, dialog.css, draggable.css, menu.css, progressbar.css, resizable.css, selectable.css, selectmenu.css, slider.css, sortable.css, spinner.css, tabs.css, tooltip.css, theme.css -* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Verdana%2CArial%2Csans-serif&fwDefault=normal&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=cccccc&bgTextureHeader=highlight_soft&bgImgOpacityHeader=75&borderColorHeader=aaaaaa&fcHeader=222222&iconColorHeader=222222&bgColorContent=ffffff&bgTextureContent=flat&bgImgOpacityContent=75&borderColorContent=aaaaaa&fcContent=222222&iconColorContent=222222&bgColorDefault=e6e6e6&bgTextureDefault=glass&bgImgOpacityDefault=75&borderColorDefault=d3d3d3&fcDefault=555555&iconColorDefault=888888&bgColorHover=dadada&bgTextureHover=glass&bgImgOpacityHover=75&borderColorHover=999999&fcHover=212121&iconColorHover=454545&bgColorActive=ffffff&bgTextureActive=glass&bgImgOpacityActive=65&borderColorActive=aaaaaa&fcActive=212121&iconColorActive=454545&bgColorHighlight=fbf9ee&bgTextureHighlight=glass&bgImgOpacityHighlight=55&borderColorHighlight=fcefa1&fcHighlight=363636&iconColorHighlight=2e83ff&bgColorError=fef1ec&bgTextureError=glass&bgImgOpacityError=95&borderColorError=cd0a0a&fcError=cd0a0a&iconColorError=cd0a0a&bgColorOverlay=aaaaaa&bgTextureOverlay=flat&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=aaaaaa&bgTextureShadow=flat&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px -* Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */ - -/* Layout helpers -----------------------------------*/ -.ui-helper-hidden { - display: none; -} -.ui-helper-hidden-accessible { - border: 0; - clip: rect(0 0 0 0); - height: 1px; - margin: -1px; - overflow: hidden; - padding: 0; - position: absolute; - width: 1px; -} -.ui-helper-reset { - margin: 0; - padding: 0; - border: 0; - outline: 0; - line-height: 1.3; - text-decoration: none; - font-size: 100%; - list-style: none; -} -.ui-helper-clearfix:before, -.ui-helper-clearfix:after { - content: ""; - display: table; - border-collapse: collapse; -} -.ui-helper-clearfix:after { - clear: both; -} -.ui-helper-clearfix { - min-height: 0; /* support: IE7 */ -} -.ui-helper-zfix { - width: 100%; - height: 100%; - top: 0; - left: 0; - position: absolute; - opacity: 0; - filter:Alpha(Opacity=0); /* support: IE8 */ -} - -.ui-front { - z-index: 100; -} - - -/* Interaction Cues -----------------------------------*/ -.ui-state-disabled { - cursor: default !important; -} - - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { - display: block; - text-indent: -99999px; - overflow: hidden; - background-repeat: no-repeat; -} - - -/* Misc visuals -----------------------------------*/ - -/* Overlays */ -.ui-widget-overlay { - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; -} -.ui-accordion .ui-accordion-header { - display: block; - cursor: pointer; - position: relative; - margin: 2px 0 0 0; - padding: .5em .5em .5em .7em; - min-height: 0; /* support: IE7 */ - font-size: 100%; -} -.ui-accordion .ui-accordion-icons { - padding-left: 2.2em; -} -.ui-accordion .ui-accordion-icons .ui-accordion-icons { - padding-left: 2.2em; -} -.ui-accordion .ui-accordion-header .ui-accordion-header-icon { - position: absolute; - left: .5em; - top: 50%; - margin-top: -8px; -} -.ui-accordion .ui-accordion-content { - padding: 1em 2.2em; - border-top: 0; - overflow: auto; -} -.ui-autocomplete { - position: absolute; - top: 0; - left: 0; - cursor: default; -} -.ui-button { - display: inline-block; - position: relative; - padding: 0; - line-height: normal; - margin-right: .1em; - cursor: pointer; - vertical-align: middle; - text-align: center; - overflow: visible; /* removes extra width in IE */ -} -.ui-button, -.ui-button:link, -.ui-button:visited, -.ui-button:hover, -.ui-button:active { - text-decoration: none; -} -/* to make room for the icon, a width needs to be set here */ -.ui-button-icon-only { - width: 2.2em; -} -/* button elements seem to need a little more width */ -button.ui-button-icon-only { - width: 2.4em; -} -.ui-button-icons-only { - width: 3.4em; -} -button.ui-button-icons-only { - width: 3.7em; -} - -/* button text element */ -.ui-button .ui-button-text { - display: block; - line-height: normal; -} -.ui-button-text-only .ui-button-text { - padding: .4em 1em; -} -.ui-button-icon-only .ui-button-text, -.ui-button-icons-only .ui-button-text { - padding: .4em; - text-indent: -9999999px; -} -.ui-button-text-icon-primary .ui-button-text, -.ui-button-text-icons .ui-button-text { - padding: .4em 1em .4em 2.1em; -} -.ui-button-text-icon-secondary .ui-button-text, -.ui-button-text-icons .ui-button-text { - padding: .4em 2.1em .4em 1em; -} -.ui-button-text-icons .ui-button-text { - padding-left: 2.1em; - padding-right: 2.1em; -} -/* no icon support for input elements, provide padding by default */ -input.ui-button { - padding: .4em 1em; -} - -/* button icon element(s) */ -.ui-button-icon-only .ui-icon, -.ui-button-text-icon-primary .ui-icon, -.ui-button-text-icon-secondary .ui-icon, -.ui-button-text-icons .ui-icon, -.ui-button-icons-only .ui-icon { - position: absolute; - top: 50%; - margin-top: -8px; -} -.ui-button-icon-only .ui-icon { - left: 50%; - margin-left: -8px; -} -.ui-button-text-icon-primary .ui-button-icon-primary, -.ui-button-text-icons .ui-button-icon-primary, -.ui-button-icons-only .ui-button-icon-primary { - left: .5em; -} -.ui-button-text-icon-secondary .ui-button-icon-secondary, -.ui-button-text-icons .ui-button-icon-secondary, -.ui-button-icons-only .ui-button-icon-secondary { - right: .5em; -} - -/* button sets */ -.ui-buttonset { - margin-right: 7px; -} -.ui-buttonset .ui-button { - margin-left: 0; - margin-right: -.3em; -} - -/* workarounds */ -/* reset extra padding in Firefox, see h5bp.com/l */ -input.ui-button::-moz-focus-inner, -button.ui-button::-moz-focus-inner { - border: 0; - padding: 0; -} -.ui-datepicker { - width: 17em; - padding: .2em .2em 0; - display: none; -} -.ui-datepicker .ui-datepicker-header { - position: relative; - padding: .2em 0; -} -.ui-datepicker .ui-datepicker-prev, -.ui-datepicker .ui-datepicker-next { - position: absolute; - top: 2px; - width: 1.8em; - height: 1.8em; -} -.ui-datepicker .ui-datepicker-prev-hover, -.ui-datepicker .ui-datepicker-next-hover { - top: 1px; -} -.ui-datepicker .ui-datepicker-prev { - left: 2px; -} -.ui-datepicker .ui-datepicker-next { - right: 2px; -} -.ui-datepicker .ui-datepicker-prev-hover { - left: 1px; -} -.ui-datepicker .ui-datepicker-next-hover { - right: 1px; -} -.ui-datepicker .ui-datepicker-prev span, -.ui-datepicker .ui-datepicker-next span { - display: block; - position: absolute; - left: 50%; - margin-left: -8px; - top: 50%; - margin-top: -8px; -} -.ui-datepicker .ui-datepicker-title { - margin: 0 2.3em; - line-height: 1.8em; - text-align: center; -} -.ui-datepicker .ui-datepicker-title select { - font-size: 1em; - margin: 1px 0; -} -.ui-datepicker select.ui-datepicker-month, -.ui-datepicker select.ui-datepicker-year { - width: 45%; -} -.ui-datepicker table { - width: 100%; - font-size: .9em; - border-collapse: collapse; - margin: 0 0 .4em; -} -.ui-datepicker th { - padding: .7em .3em; - text-align: center; - font-weight: bold; - border: 0; -} -.ui-datepicker td { - border: 0; - padding: 1px; -} -.ui-datepicker td span, -.ui-datepicker td a { - display: block; - padding: .2em; - text-align: right; - text-decoration: none; -} -.ui-datepicker .ui-datepicker-buttonpane { - background-image: none; - margin: .7em 0 0 0; - padding: 0 .2em; - border-left: 0; - border-right: 0; - border-bottom: 0; -} -.ui-datepicker .ui-datepicker-buttonpane button { - float: right; - margin: .5em .2em .4em; - cursor: pointer; - padding: .2em .6em .3em .6em; - width: auto; - overflow: visible; -} -.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { - float: left; -} - -/* with multiple calendars */ -.ui-datepicker.ui-datepicker-multi { - width: auto; -} -.ui-datepicker-multi .ui-datepicker-group { - float: left; -} -.ui-datepicker-multi .ui-datepicker-group table { - width: 95%; - margin: 0 auto .4em; -} -.ui-datepicker-multi-2 .ui-datepicker-group { - width: 50%; -} -.ui-datepicker-multi-3 .ui-datepicker-group { - width: 33.3%; -} -.ui-datepicker-multi-4 .ui-datepicker-group { - width: 25%; -} -.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header, -.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { - border-left-width: 0; -} -.ui-datepicker-multi .ui-datepicker-buttonpane { - clear: left; -} -.ui-datepicker-row-break { - clear: both; - width: 100%; - font-size: 0; -} - -/* RTL support */ -.ui-datepicker-rtl { - direction: rtl; -} -.ui-datepicker-rtl .ui-datepicker-prev { - right: 2px; - left: auto; -} -.ui-datepicker-rtl .ui-datepicker-next { - left: 2px; - right: auto; -} -.ui-datepicker-rtl .ui-datepicker-prev:hover { - right: 1px; - left: auto; -} -.ui-datepicker-rtl .ui-datepicker-next:hover { - left: 1px; - right: auto; -} -.ui-datepicker-rtl .ui-datepicker-buttonpane { - clear: right; -} -.ui-datepicker-rtl .ui-datepicker-buttonpane button { - float: left; -} -.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current, -.ui-datepicker-rtl .ui-datepicker-group { - float: right; -} -.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header, -.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { - border-right-width: 0; - border-left-width: 1px; -} -.ui-dialog { - overflow: hidden; - position: absolute; - top: 0; - left: 0; - padding: .2em; - outline: 0; -} -.ui-dialog .ui-dialog-titlebar { - padding: .4em 1em; - position: relative; -} -.ui-dialog .ui-dialog-title { - float: left; - margin: .1em 0; - white-space: nowrap; - width: 90%; - overflow: hidden; - text-overflow: ellipsis; -} -.ui-dialog .ui-dialog-titlebar-close { - position: absolute; - right: .3em; - top: 50%; - width: 20px; - margin: -10px 0 0 0; - padding: 1px; - height: 20px; -} -.ui-dialog .ui-dialog-content { - position: relative; - border: 0; - padding: .5em 1em; - background: none; - overflow: auto; -} -.ui-dialog .ui-dialog-buttonpane { - text-align: left; - border-width: 1px 0 0 0; - background-image: none; - margin-top: .5em; - padding: .3em 1em .5em .4em; -} -.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { - float: right; -} -.ui-dialog .ui-dialog-buttonpane button { - margin: .5em .4em .5em 0; - cursor: pointer; -} -.ui-dialog .ui-resizable-se { - width: 12px; - height: 12px; - right: -5px; - bottom: -5px; - background-position: 16px 16px; -} -.ui-draggable .ui-dialog-titlebar { - cursor: move; -} -.ui-draggable-handle { - -ms-touch-action: none; - touch-action: none; -} -.ui-menu { - list-style: none; - padding: 0; - margin: 0; - display: block; - outline: none; -} -.ui-menu .ui-menu { - position: absolute; -} -.ui-menu .ui-menu-item { - position: relative; - margin: 0; - padding: 3px 1em 3px .4em; - cursor: pointer; - min-height: 0; /* support: IE7 */ - /* support: IE10, see #8844 */ - list-style-image: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"); -} -.ui-menu .ui-menu-divider { - margin: 5px 0; - height: 0; - font-size: 0; - line-height: 0; - border-width: 1px 0 0 0; -} -.ui-menu .ui-state-focus, -.ui-menu .ui-state-active { - margin: -1px; -} - -/* icon support */ -.ui-menu-icons { - position: relative; -} -.ui-menu-icons .ui-menu-item { - padding-left: 2em; -} - -/* left-aligned */ -.ui-menu .ui-icon { - position: absolute; - top: 0; - bottom: 0; - left: .2em; - margin: auto 0; -} - -/* right-aligned */ -.ui-menu .ui-menu-icon { - left: auto; - right: 0; -} -.ui-progressbar { - height: 2em; - text-align: left; - overflow: hidden; -} -.ui-progressbar .ui-progressbar-value { - margin: -1px; - height: 100%; -} -.ui-progressbar .ui-progressbar-overlay { - background: url("data:image/gif;base64,R0lGODlhKAAoAIABAAAAAP///yH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAQABACwAAAAAKAAoAAACkYwNqXrdC52DS06a7MFZI+4FHBCKoDeWKXqymPqGqxvJrXZbMx7Ttc+w9XgU2FB3lOyQRWET2IFGiU9m1frDVpxZZc6bfHwv4c1YXP6k1Vdy292Fb6UkuvFtXpvWSzA+HycXJHUXiGYIiMg2R6W459gnWGfHNdjIqDWVqemH2ekpObkpOlppWUqZiqr6edqqWQAAIfkECQEAAQAsAAAAACgAKAAAApSMgZnGfaqcg1E2uuzDmmHUBR8Qil95hiPKqWn3aqtLsS18y7G1SzNeowWBENtQd+T1JktP05nzPTdJZlR6vUxNWWjV+vUWhWNkWFwxl9VpZRedYcflIOLafaa28XdsH/ynlcc1uPVDZxQIR0K25+cICCmoqCe5mGhZOfeYSUh5yJcJyrkZWWpaR8doJ2o4NYq62lAAACH5BAkBAAEALAAAAAAoACgAAAKVDI4Yy22ZnINRNqosw0Bv7i1gyHUkFj7oSaWlu3ovC8GxNso5fluz3qLVhBVeT/Lz7ZTHyxL5dDalQWPVOsQWtRnuwXaFTj9jVVh8pma9JjZ4zYSj5ZOyma7uuolffh+IR5aW97cHuBUXKGKXlKjn+DiHWMcYJah4N0lYCMlJOXipGRr5qdgoSTrqWSq6WFl2ypoaUAAAIfkECQEAAQAsAAAAACgAKAAAApaEb6HLgd/iO7FNWtcFWe+ufODGjRfoiJ2akShbueb0wtI50zm02pbvwfWEMWBQ1zKGlLIhskiEPm9R6vRXxV4ZzWT2yHOGpWMyorblKlNp8HmHEb/lCXjcW7bmtXP8Xt229OVWR1fod2eWqNfHuMjXCPkIGNileOiImVmCOEmoSfn3yXlJWmoHGhqp6ilYuWYpmTqKUgAAIfkECQEAAQAsAAAAACgAKAAAApiEH6kb58biQ3FNWtMFWW3eNVcojuFGfqnZqSebuS06w5V80/X02pKe8zFwP6EFWOT1lDFk8rGERh1TTNOocQ61Hm4Xm2VexUHpzjymViHrFbiELsefVrn6XKfnt2Q9G/+Xdie499XHd2g4h7ioOGhXGJboGAnXSBnoBwKYyfioubZJ2Hn0RuRZaflZOil56Zp6iioKSXpUAAAh+QQJAQABACwAAAAAKAAoAAACkoQRqRvnxuI7kU1a1UU5bd5tnSeOZXhmn5lWK3qNTWvRdQxP8qvaC+/yaYQzXO7BMvaUEmJRd3TsiMAgswmNYrSgZdYrTX6tSHGZO73ezuAw2uxuQ+BbeZfMxsexY35+/Qe4J1inV0g4x3WHuMhIl2jXOKT2Q+VU5fgoSUI52VfZyfkJGkha6jmY+aaYdirq+lQAACH5BAkBAAEALAAAAAAoACgAAAKWBIKpYe0L3YNKToqswUlvznigd4wiR4KhZrKt9Upqip61i9E3vMvxRdHlbEFiEXfk9YARYxOZZD6VQ2pUunBmtRXo1Lf8hMVVcNl8JafV38aM2/Fu5V16Bn63r6xt97j09+MXSFi4BniGFae3hzbH9+hYBzkpuUh5aZmHuanZOZgIuvbGiNeomCnaxxap2upaCZsq+1kAACH5BAkBAAEALAAAAAAoACgAAAKXjI8By5zf4kOxTVrXNVlv1X0d8IGZGKLnNpYtm8Lr9cqVeuOSvfOW79D9aDHizNhDJidFZhNydEahOaDH6nomtJjp1tutKoNWkvA6JqfRVLHU/QUfau9l2x7G54d1fl995xcIGAdXqMfBNadoYrhH+Mg2KBlpVpbluCiXmMnZ2Sh4GBqJ+ckIOqqJ6LmKSllZmsoq6wpQAAAh+QQJAQABACwAAAAAKAAoAAAClYx/oLvoxuJDkU1a1YUZbJ59nSd2ZXhWqbRa2/gF8Gu2DY3iqs7yrq+xBYEkYvFSM8aSSObE+ZgRl1BHFZNr7pRCavZ5BW2142hY3AN/zWtsmf12p9XxxFl2lpLn1rseztfXZjdIWIf2s5dItwjYKBgo9yg5pHgzJXTEeGlZuenpyPmpGQoKOWkYmSpaSnqKileI2FAAACH5BAkBAAEALAAAAAAoACgAAAKVjB+gu+jG4kORTVrVhRlsnn2dJ3ZleFaptFrb+CXmO9OozeL5VfP99HvAWhpiUdcwkpBH3825AwYdU8xTqlLGhtCosArKMpvfa1mMRae9VvWZfeB2XfPkeLmm18lUcBj+p5dnN8jXZ3YIGEhYuOUn45aoCDkp16hl5IjYJvjWKcnoGQpqyPlpOhr3aElaqrq56Bq7VAAAOw=="); - height: 100%; - filter: alpha(opacity=25); /* support: IE8 */ - opacity: 0.25; -} -.ui-progressbar-indeterminate .ui-progressbar-value { - background-image: none; -} -.ui-resizable { - position: relative; -} -.ui-resizable-handle { - position: absolute; - font-size: 0.1px; - display: block; - -ms-touch-action: none; - touch-action: none; -} -.ui-resizable-disabled .ui-resizable-handle, -.ui-resizable-autohide .ui-resizable-handle { - display: none; -} -.ui-resizable-n { - cursor: n-resize; - height: 7px; - width: 100%; - top: -5px; - left: 0; -} -.ui-resizable-s { - cursor: s-resize; - height: 7px; - width: 100%; - bottom: -5px; - left: 0; -} -.ui-resizable-e { - cursor: e-resize; - width: 7px; - right: -5px; - top: 0; - height: 100%; -} -.ui-resizable-w { - cursor: w-resize; - width: 7px; - left: -5px; - top: 0; - height: 100%; -} -.ui-resizable-se { - cursor: se-resize; - width: 12px; - height: 12px; - right: 1px; - bottom: 1px; -} -.ui-resizable-sw { - cursor: sw-resize; - width: 9px; - height: 9px; - left: -5px; - bottom: -5px; -} -.ui-resizable-nw { - cursor: nw-resize; - width: 9px; - height: 9px; - left: -5px; - top: -5px; -} -.ui-resizable-ne { - cursor: ne-resize; - width: 9px; - height: 9px; - right: -5px; - top: -5px; -} -.ui-selectable { - -ms-touch-action: none; - touch-action: none; -} -.ui-selectable-helper { - position: absolute; - z-index: 100; - border: 1px dotted black; -} -.ui-selectmenu-menu { - padding: 0; - margin: 0; - position: absolute; - top: 0; - left: 0; - display: none; -} -.ui-selectmenu-menu .ui-menu { - overflow: auto; - /* Support: IE7 */ - overflow-x: hidden; - padding-bottom: 1px; -} -.ui-selectmenu-menu .ui-menu .ui-selectmenu-optgroup { - font-size: 1em; - font-weight: bold; - line-height: 1.5; - padding: 2px 0.4em; - margin: 0.5em 0 0 0; - height: auto; - border: 0; -} -.ui-selectmenu-open { - display: block; -} -.ui-selectmenu-button { - display: inline-block; - overflow: hidden; - position: relative; - text-decoration: none; - cursor: pointer; -} -.ui-selectmenu-button span.ui-icon { - right: 0.5em; - left: auto; - margin-top: -8px; - position: absolute; - top: 50%; -} -.ui-selectmenu-button span.ui-selectmenu-text { - text-align: left; - padding: 0.4em 2.1em 0.4em 1em; - display: block; - line-height: 1.4; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} -.ui-slider { - position: relative; - text-align: left; -} -.ui-slider .ui-slider-handle { - position: absolute; - z-index: 2; - width: 1.2em; - height: 1.2em; - cursor: default; - -ms-touch-action: none; - touch-action: none; -} -.ui-slider .ui-slider-range { - position: absolute; - z-index: 1; - font-size: .7em; - display: block; - border: 0; - background-position: 0 0; -} - -/* support: IE8 - See #6727 */ -.ui-slider.ui-state-disabled .ui-slider-handle, -.ui-slider.ui-state-disabled .ui-slider-range { - filter: inherit; -} - -.ui-slider-horizontal { - height: .8em; -} -.ui-slider-horizontal .ui-slider-handle { - top: -.3em; - margin-left: -.6em; -} -.ui-slider-horizontal .ui-slider-range { - top: 0; - height: 100%; -} -.ui-slider-horizontal .ui-slider-range-min { - left: 0; -} -.ui-slider-horizontal .ui-slider-range-max { - right: 0; -} - -.ui-slider-vertical { - width: .8em; - height: 100px; -} -.ui-slider-vertical .ui-slider-handle { - left: -.3em; - margin-left: 0; - margin-bottom: -.6em; -} -.ui-slider-vertical .ui-slider-range { - left: 0; - width: 100%; -} -.ui-slider-vertical .ui-slider-range-min { - bottom: 0; -} -.ui-slider-vertical .ui-slider-range-max { - top: 0; -} -.ui-sortable-handle { - -ms-touch-action: none; - touch-action: none; -} -.ui-spinner { - position: relative; - display: inline-block; - overflow: hidden; - padding: 0; - vertical-align: middle; -} -.ui-spinner-input { - border: none; - background: none; - color: inherit; - padding: 0; - margin: .2em 0; - vertical-align: middle; - margin-left: .4em; - margin-right: 22px; -} -.ui-spinner-button { - width: 16px; - height: 50%; - font-size: .5em; - padding: 0; - margin: 0; - text-align: center; - position: absolute; - cursor: default; - display: block; - overflow: hidden; - right: 0; -} -/* more specificity required here to override default borders */ -.ui-spinner a.ui-spinner-button { - border-top: none; - border-bottom: none; - border-right: none; -} -/* vertically center icon */ -.ui-spinner .ui-icon { - position: absolute; - margin-top: -8px; - top: 50%; - left: 0; -} -.ui-spinner-up { - top: 0; -} -.ui-spinner-down { - bottom: 0; -} - -/* TR overrides */ -.ui-spinner .ui-icon-triangle-1-s { - /* need to fix icons sprite */ - background-position: -65px -16px; -} -.ui-tabs { - position: relative;/* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */ - padding: .2em; -} -.ui-tabs .ui-tabs-nav { - margin: 0; - padding: .2em .2em 0; -} -.ui-tabs .ui-tabs-nav li { - list-style: none; - float: left; - position: relative; - top: 0; - margin: 1px .2em 0 0; - border-bottom-width: 0; - padding: 0; - white-space: nowrap; -} -.ui-tabs .ui-tabs-nav .ui-tabs-anchor { - float: left; - padding: .5em 1em; - text-decoration: none; -} -.ui-tabs .ui-tabs-nav li.ui-tabs-active { - margin-bottom: -1px; - padding-bottom: 1px; -} -.ui-tabs .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor, -.ui-tabs .ui-tabs-nav li.ui-state-disabled .ui-tabs-anchor, -.ui-tabs .ui-tabs-nav li.ui-tabs-loading .ui-tabs-anchor { - cursor: text; -} -.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor { - cursor: pointer; -} -.ui-tabs .ui-tabs-panel { - display: block; - border-width: 0; - padding: 1em 1.4em; - background: none; -} -.ui-tooltip { - padding: 8px; - position: absolute; - z-index: 9999; - max-width: 300px; - -webkit-box-shadow: 0 0 5px #aaa; - box-shadow: 0 0 5px #aaa; -} -body .ui-tooltip { - border-width: 2px; -} - -/* Component containers -----------------------------------*/ -.ui-widget { - font-family: Verdana,Arial,sans-serif; - font-size: 1.1em; -} -.ui-widget .ui-widget { - font-size: 1em; -} -.ui-widget input, -.ui-widget select, -.ui-widget textarea, -.ui-widget button { - font-family: Verdana,Arial,sans-serif; - font-size: 1em; -} -.ui-widget-content { - border: 1px solid #aaaaaa; - background: #ffffff url("images/ui-bg_flat_75_ffffff_40x100.png") 50% 50% repeat-x; - color: #222222; -} -.ui-widget-content a { - color: #222222; -} -.ui-widget-header { - border: 1px solid #aaaaaa; - background: #cccccc url("images/ui-bg_highlight-soft_75_cccccc_1x100.png") 50% 50% repeat-x; - color: #222222; - font-weight: bold; -} -.ui-widget-header a { - color: #222222; -} - -/* Interaction states -----------------------------------*/ -.ui-state-default, -.ui-widget-content .ui-state-default, -.ui-widget-header .ui-state-default { - border: 1px solid #d3d3d3; - background: #e6e6e6 url("images/ui-bg_glass_75_e6e6e6_1x400.png") 50% 50% repeat-x; - font-weight: normal; - color: #555555; -} -.ui-state-default a, -.ui-state-default a:link, -.ui-state-default a:visited { - color: #555555; - text-decoration: none; -} -.ui-state-hover, -.ui-widget-content .ui-state-hover, -.ui-widget-header .ui-state-hover, -.ui-state-focus, -.ui-widget-content .ui-state-focus, -.ui-widget-header .ui-state-focus { - border: 1px solid #999999; - background: #dadada url("images/ui-bg_glass_75_dadada_1x400.png") 50% 50% repeat-x; - font-weight: normal; - color: #212121; -} -.ui-state-hover a, -.ui-state-hover a:hover, -.ui-state-hover a:link, -.ui-state-hover a:visited, -.ui-state-focus a, -.ui-state-focus a:hover, -.ui-state-focus a:link, -.ui-state-focus a:visited { - color: #212121; - text-decoration: none; -} -.ui-state-active, -.ui-widget-content .ui-state-active, -.ui-widget-header .ui-state-active { - border: 1px solid #aaaaaa; - background: #ffffff url("images/ui-bg_glass_65_ffffff_1x400.png") 50% 50% repeat-x; - font-weight: normal; - color: #212121; -} -.ui-state-active a, -.ui-state-active a:link, -.ui-state-active a:visited { - color: #212121; - text-decoration: none; -} - -/* Interaction Cues -----------------------------------*/ -.ui-state-highlight, -.ui-widget-content .ui-state-highlight, -.ui-widget-header .ui-state-highlight { - border: 1px solid #fcefa1; - background: #fbf9ee url("images/ui-bg_glass_55_fbf9ee_1x400.png") 50% 50% repeat-x; - color: #363636; -} -.ui-state-highlight a, -.ui-widget-content .ui-state-highlight a, -.ui-widget-header .ui-state-highlight a { - color: #363636; -} -.ui-state-error, -.ui-widget-content .ui-state-error, -.ui-widget-header .ui-state-error { - border: 1px solid #cd0a0a; - background: #fef1ec url("images/ui-bg_glass_95_fef1ec_1x400.png") 50% 50% repeat-x; - color: #cd0a0a; -} -.ui-state-error a, -.ui-widget-content .ui-state-error a, -.ui-widget-header .ui-state-error a { - color: #cd0a0a; -} -.ui-state-error-text, -.ui-widget-content .ui-state-error-text, -.ui-widget-header .ui-state-error-text { - color: #cd0a0a; -} -.ui-priority-primary, -.ui-widget-content .ui-priority-primary, -.ui-widget-header .ui-priority-primary { - font-weight: bold; -} -.ui-priority-secondary, -.ui-widget-content .ui-priority-secondary, -.ui-widget-header .ui-priority-secondary { - opacity: .7; - filter:Alpha(Opacity=70); /* support: IE8 */ - font-weight: normal; -} -.ui-state-disabled, -.ui-widget-content .ui-state-disabled, -.ui-widget-header .ui-state-disabled { - opacity: .35; - filter:Alpha(Opacity=35); /* support: IE8 */ - background-image: none; -} -.ui-state-disabled .ui-icon { - filter:Alpha(Opacity=35); /* support: IE8 - See #6059 */ -} - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { - width: 16px; - height: 16px; -} -.ui-icon, -.ui-widget-content .ui-icon { - background-image: url("images/ui-icons_222222_256x240.png"); -} -.ui-widget-header .ui-icon { - background-image: url("images/ui-icons_222222_256x240.png"); -} -.ui-state-default .ui-icon { - background-image: url("images/ui-icons_888888_256x240.png"); -} -.ui-state-hover .ui-icon, -.ui-state-focus .ui-icon { - background-image: url("images/ui-icons_454545_256x240.png"); -} -.ui-state-active .ui-icon { - background-image: url("images/ui-icons_454545_256x240.png"); -} -.ui-state-highlight .ui-icon { - background-image: url("images/ui-icons_2e83ff_256x240.png"); -} -.ui-state-error .ui-icon, -.ui-state-error-text .ui-icon { - background-image: url("images/ui-icons_cd0a0a_256x240.png"); -} - -/* positioning */ -.ui-icon-blank { background-position: 16px 16px; } -.ui-icon-carat-1-n { background-position: 0 0; } -.ui-icon-carat-1-ne { background-position: -16px 0; } -.ui-icon-carat-1-e { background-position: -32px 0; } -.ui-icon-carat-1-se { background-position: -48px 0; } -.ui-icon-carat-1-s { background-position: -64px 0; } -.ui-icon-carat-1-sw { background-position: -80px 0; } -.ui-icon-carat-1-w { background-position: -96px 0; } -.ui-icon-carat-1-nw { background-position: -112px 0; } -.ui-icon-carat-2-n-s { background-position: -128px 0; } -.ui-icon-carat-2-e-w { background-position: -144px 0; } -.ui-icon-triangle-1-n { background-position: 0 -16px; } -.ui-icon-triangle-1-ne { background-position: -16px -16px; } -.ui-icon-triangle-1-e { background-position: -32px -16px; } -.ui-icon-triangle-1-se { background-position: -48px -16px; } -.ui-icon-triangle-1-s { background-position: -64px -16px; } -.ui-icon-triangle-1-sw { background-position: -80px -16px; } -.ui-icon-triangle-1-w { background-position: -96px -16px; } -.ui-icon-triangle-1-nw { background-position: -112px -16px; } -.ui-icon-triangle-2-n-s { background-position: -128px -16px; } -.ui-icon-triangle-2-e-w { background-position: -144px -16px; } -.ui-icon-arrow-1-n { background-position: 0 -32px; } -.ui-icon-arrow-1-ne { background-position: -16px -32px; } -.ui-icon-arrow-1-e { background-position: -32px -32px; } -.ui-icon-arrow-1-se { background-position: -48px -32px; } -.ui-icon-arrow-1-s { background-position: -64px -32px; } -.ui-icon-arrow-1-sw { background-position: -80px -32px; } -.ui-icon-arrow-1-w { background-position: -96px -32px; } -.ui-icon-arrow-1-nw { background-position: -112px -32px; } -.ui-icon-arrow-2-n-s { background-position: -128px -32px; } -.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } -.ui-icon-arrow-2-e-w { background-position: -160px -32px; } -.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } -.ui-icon-arrowstop-1-n { background-position: -192px -32px; } -.ui-icon-arrowstop-1-e { background-position: -208px -32px; } -.ui-icon-arrowstop-1-s { background-position: -224px -32px; } -.ui-icon-arrowstop-1-w { background-position: -240px -32px; } -.ui-icon-arrowthick-1-n { background-position: 0 -48px; } -.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } -.ui-icon-arrowthick-1-e { background-position: -32px -48px; } -.ui-icon-arrowthick-1-se { background-position: -48px -48px; } -.ui-icon-arrowthick-1-s { background-position: -64px -48px; } -.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } -.ui-icon-arrowthick-1-w { background-position: -96px -48px; } -.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } -.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } -.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } -.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } -.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } -.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } -.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } -.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } -.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } -.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } -.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } -.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } -.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } -.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } -.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } -.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } -.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } -.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } -.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } -.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } -.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } -.ui-icon-arrow-4 { background-position: 0 -80px; } -.ui-icon-arrow-4-diag { background-position: -16px -80px; } -.ui-icon-extlink { background-position: -32px -80px; } -.ui-icon-newwin { background-position: -48px -80px; } -.ui-icon-refresh { background-position: -64px -80px; } -.ui-icon-shuffle { background-position: -80px -80px; } -.ui-icon-transfer-e-w { background-position: -96px -80px; } -.ui-icon-transferthick-e-w { background-position: -112px -80px; } -.ui-icon-folder-collapsed { background-position: 0 -96px; } -.ui-icon-folder-open { background-position: -16px -96px; } -.ui-icon-document { background-position: -32px -96px; } -.ui-icon-document-b { background-position: -48px -96px; } -.ui-icon-note { background-position: -64px -96px; } -.ui-icon-mail-closed { background-position: -80px -96px; } -.ui-icon-mail-open { background-position: -96px -96px; } -.ui-icon-suitcase { background-position: -112px -96px; } -.ui-icon-comment { background-position: -128px -96px; } -.ui-icon-person { background-position: -144px -96px; } -.ui-icon-print { background-position: -160px -96px; } -.ui-icon-trash { background-position: -176px -96px; } -.ui-icon-locked { background-position: -192px -96px; } -.ui-icon-unlocked { background-position: -208px -96px; } -.ui-icon-bookmark { background-position: -224px -96px; } -.ui-icon-tag { background-position: -240px -96px; } -.ui-icon-home { background-position: 0 -112px; } -.ui-icon-flag { background-position: -16px -112px; } -.ui-icon-calendar { background-position: -32px -112px; } -.ui-icon-cart { background-position: -48px -112px; } -.ui-icon-pencil { background-position: -64px -112px; } -.ui-icon-clock { background-position: -80px -112px; } -.ui-icon-disk { background-position: -96px -112px; } -.ui-icon-calculator { background-position: -112px -112px; } -.ui-icon-zoomin { background-position: -128px -112px; } -.ui-icon-zoomout { background-position: -144px -112px; } -.ui-icon-search { background-position: -160px -112px; } -.ui-icon-wrench { background-position: -176px -112px; } -.ui-icon-gear { background-position: -192px -112px; } -.ui-icon-heart { background-position: -208px -112px; } -.ui-icon-star { background-position: -224px -112px; } -.ui-icon-link { background-position: -240px -112px; } -.ui-icon-cancel { background-position: 0 -128px; } -.ui-icon-plus { background-position: -16px -128px; } -.ui-icon-plusthick { background-position: -32px -128px; } -.ui-icon-minus { background-position: -48px -128px; } -.ui-icon-minusthick { background-position: -64px -128px; } -.ui-icon-close { background-position: -80px -128px; } -.ui-icon-closethick { background-position: -96px -128px; } -.ui-icon-key { background-position: -112px -128px; } -.ui-icon-lightbulb { background-position: -128px -128px; } -.ui-icon-scissors { background-position: -144px -128px; } -.ui-icon-clipboard { background-position: -160px -128px; } -.ui-icon-copy { background-position: -176px -128px; } -.ui-icon-contact { background-position: -192px -128px; } -.ui-icon-image { background-position: -208px -128px; } -.ui-icon-video { background-position: -224px -128px; } -.ui-icon-script { background-position: -240px -128px; } -.ui-icon-alert { background-position: 0 -144px; } -.ui-icon-info { background-position: -16px -144px; } -.ui-icon-notice { background-position: -32px -144px; } -.ui-icon-help { background-position: -48px -144px; } -.ui-icon-check { background-position: -64px -144px; } -.ui-icon-bullet { background-position: -80px -144px; } -.ui-icon-radio-on { background-position: -96px -144px; } -.ui-icon-radio-off { background-position: -112px -144px; } -.ui-icon-pin-w { background-position: -128px -144px; } -.ui-icon-pin-s { background-position: -144px -144px; } -.ui-icon-play { background-position: 0 -160px; } -.ui-icon-pause { background-position: -16px -160px; } -.ui-icon-seek-next { background-position: -32px -160px; } -.ui-icon-seek-prev { background-position: -48px -160px; } -.ui-icon-seek-end { background-position: -64px -160px; } -.ui-icon-seek-start { background-position: -80px -160px; } -/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ -.ui-icon-seek-first { background-position: -80px -160px; } -.ui-icon-stop { background-position: -96px -160px; } -.ui-icon-eject { background-position: -112px -160px; } -.ui-icon-volume-off { background-position: -128px -160px; } -.ui-icon-volume-on { background-position: -144px -160px; } -.ui-icon-power { background-position: 0 -176px; } -.ui-icon-signal-diag { background-position: -16px -176px; } -.ui-icon-signal { background-position: -32px -176px; } -.ui-icon-battery-0 { background-position: -48px -176px; } -.ui-icon-battery-1 { background-position: -64px -176px; } -.ui-icon-battery-2 { background-position: -80px -176px; } -.ui-icon-battery-3 { background-position: -96px -176px; } -.ui-icon-circle-plus { background-position: 0 -192px; } -.ui-icon-circle-minus { background-position: -16px -192px; } -.ui-icon-circle-close { background-position: -32px -192px; } -.ui-icon-circle-triangle-e { background-position: -48px -192px; } -.ui-icon-circle-triangle-s { background-position: -64px -192px; } -.ui-icon-circle-triangle-w { background-position: -80px -192px; } -.ui-icon-circle-triangle-n { background-position: -96px -192px; } -.ui-icon-circle-arrow-e { background-position: -112px -192px; } -.ui-icon-circle-arrow-s { background-position: -128px -192px; } -.ui-icon-circle-arrow-w { background-position: -144px -192px; } -.ui-icon-circle-arrow-n { background-position: -160px -192px; } -.ui-icon-circle-zoomin { background-position: -176px -192px; } -.ui-icon-circle-zoomout { background-position: -192px -192px; } -.ui-icon-circle-check { background-position: -208px -192px; } -.ui-icon-circlesmall-plus { background-position: 0 -208px; } -.ui-icon-circlesmall-minus { background-position: -16px -208px; } -.ui-icon-circlesmall-close { background-position: -32px -208px; } -.ui-icon-squaresmall-plus { background-position: -48px -208px; } -.ui-icon-squaresmall-minus { background-position: -64px -208px; } -.ui-icon-squaresmall-close { background-position: -80px -208px; } -.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } -.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } -.ui-icon-grip-solid-vertical { background-position: -32px -224px; } -.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } -.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } -.ui-icon-grip-diagonal-se { background-position: -80px -224px; } - - -/* Misc visuals -----------------------------------*/ - -/* Corner radius */ -.ui-corner-all, -.ui-corner-top, -.ui-corner-left, -.ui-corner-tl { - border-top-left-radius: 4px; -} -.ui-corner-all, -.ui-corner-top, -.ui-corner-right, -.ui-corner-tr { - border-top-right-radius: 4px; -} -.ui-corner-all, -.ui-corner-bottom, -.ui-corner-left, -.ui-corner-bl { - border-bottom-left-radius: 4px; -} -.ui-corner-all, -.ui-corner-bottom, -.ui-corner-right, -.ui-corner-br { - border-bottom-right-radius: 4px; -} - -/* Overlays */ -.ui-widget-overlay { - background: #aaaaaa url("images/ui-bg_flat_0_aaaaaa_40x100.png") 50% 50% repeat-x; - opacity: .3; - filter: Alpha(Opacity=30); /* support: IE8 */ -} -.ui-widget-shadow { - margin: -8px 0 0 -8px; - padding: 8px; - background: #aaaaaa url("images/ui-bg_flat_0_aaaaaa_40x100.png") 50% 50% repeat-x; - opacity: .3; - filter: Alpha(Opacity=30); /* support: IE8 */ - border-radius: 8px; -} +/*! jQuery UI - v1.13.2 - 2022-07-14 +* http://jqueryui.com +* Includes: core.css, accordion.css, autocomplete.css, menu.css, button.css, controlgroup.css, checkboxradio.css, datepicker.css, dialog.css, draggable.css, resizable.css, progressbar.css, selectable.css, selectmenu.css, slider.css, sortable.css, spinner.css, tabs.css, tooltip.css, theme.css +* To view and modify this theme, visit http://jqueryui.com/themeroller/?bgShadowXPos=&bgOverlayXPos=&bgErrorXPos=&bgHighlightXPos=&bgContentXPos=&bgHeaderXPos=&bgActiveXPos=&bgHoverXPos=&bgDefaultXPos=&bgShadowYPos=&bgOverlayYPos=&bgErrorYPos=&bgHighlightYPos=&bgContentYPos=&bgHeaderYPos=&bgActiveYPos=&bgHoverYPos=&bgDefaultYPos=&bgShadowRepeat=&bgOverlayRepeat=&bgErrorRepeat=&bgHighlightRepeat=&bgContentRepeat=&bgHeaderRepeat=&bgActiveRepeat=&bgHoverRepeat=&bgDefaultRepeat=&iconsHover=url(%22images%2Fui-icons_555555_256x240.png%22)&iconsHighlight=url(%22images%2Fui-icons_777620_256x240.png%22)&iconsHeader=url(%22images%2Fui-icons_444444_256x240.png%22)&iconsError=url(%22images%2Fui-icons_cc0000_256x240.png%22)&iconsDefault=url(%22images%2Fui-icons_777777_256x240.png%22)&iconsContent=url(%22images%2Fui-icons_444444_256x240.png%22)&iconsActive=url(%22images%2Fui-icons_ffffff_256x240.png%22)&bgImgUrlShadow=&bgImgUrlOverlay=&bgImgUrlHover=&bgImgUrlHighlight=&bgImgUrlHeader=&bgImgUrlError=&bgImgUrlDefault=&bgImgUrlContent=&bgImgUrlActive=&opacityFilterShadow=Alpha(Opacity%3D30)&opacityFilterOverlay=Alpha(Opacity%3D30)&opacityShadowPerc=30&opacityOverlayPerc=30&iconColorHover=%23555555&iconColorHighlight=%23777620&iconColorHeader=%23444444&iconColorError=%23cc0000&iconColorDefault=%23777777&iconColorContent=%23444444&iconColorActive=%23ffffff&bgImgOpacityShadow=0&bgImgOpacityOverlay=0&bgImgOpacityError=95&bgImgOpacityHighlight=55&bgImgOpacityContent=75&bgImgOpacityHeader=75&bgImgOpacityActive=65&bgImgOpacityHover=75&bgImgOpacityDefault=75&bgTextureShadow=flat&bgTextureOverlay=flat&bgTextureError=flat&bgTextureHighlight=flat&bgTextureContent=flat&bgTextureHeader=flat&bgTextureActive=flat&bgTextureHover=flat&bgTextureDefault=flat&cornerRadius=3px&fwDefault=normal&ffDefault=Arial%2CHelvetica%2Csans-serif&fsDefault=1em&cornerRadiusShadow=8px&thicknessShadow=5px&offsetLeftShadow=0px&offsetTopShadow=0px&opacityShadow=.3&bgColorShadow=%23666666&opacityOverlay=.3&bgColorOverlay=%23aaaaaa&fcError=%235f3f3f&borderColorError=%23f1a899&bgColorError=%23fddfdf&fcHighlight=%23777620&borderColorHighlight=%23dad55e&bgColorHighlight=%23fffa90&fcContent=%23333333&borderColorContent=%23dddddd&bgColorContent=%23ffffff&fcHeader=%23333333&borderColorHeader=%23dddddd&bgColorHeader=%23e9e9e9&fcActive=%23ffffff&borderColorActive=%23003eff&bgColorActive=%23007fff&fcHover=%232b2b2b&borderColorHover=%23cccccc&bgColorHover=%23ededed&fcDefault=%23454545&borderColorDefault=%23c5c5c5&bgColorDefault=%23f6f6f6 +* Copyright jQuery Foundation and other contributors; Licensed MIT */ + +/* Layout helpers +----------------------------------*/ +.ui-helper-hidden { + display: none; +} +.ui-helper-hidden-accessible { + border: 0; + clip: rect(0 0 0 0); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; +} +.ui-helper-reset { + margin: 0; + padding: 0; + border: 0; + outline: 0; + line-height: 1.3; + text-decoration: none; + font-size: 100%; + list-style: none; +} +.ui-helper-clearfix:before, +.ui-helper-clearfix:after { + content: ""; + display: table; + border-collapse: collapse; +} +.ui-helper-clearfix:after { + clear: both; +} +.ui-helper-zfix { + width: 100%; + height: 100%; + top: 0; + left: 0; + position: absolute; + opacity: 0; + -ms-filter: "alpha(opacity=0)"; /* support: IE8 */ +} + +.ui-front { + z-index: 100; +} + + +/* Interaction Cues +----------------------------------*/ +.ui-state-disabled { + cursor: default !important; + pointer-events: none; +} + + +/* Icons +----------------------------------*/ +.ui-icon { + display: inline-block; + vertical-align: middle; + margin-top: -.25em; + position: relative; + text-indent: -99999px; + overflow: hidden; + background-repeat: no-repeat; +} + +.ui-widget-icon-block { + left: 50%; + margin-left: -8px; + display: block; +} + +/* Misc visuals +----------------------------------*/ + +/* Overlays */ +.ui-widget-overlay { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; +} +.ui-accordion .ui-accordion-header { + display: block; + cursor: pointer; + position: relative; + margin: 2px 0 0 0; + padding: .5em .5em .5em .7em; + font-size: 100%; +} +.ui-accordion .ui-accordion-content { + padding: 1em 2.2em; + border-top: 0; + overflow: auto; +} +.ui-autocomplete { + position: absolute; + top: 0; + left: 0; + cursor: default; +} +.ui-menu { + list-style: none; + padding: 0; + margin: 0; + display: block; + outline: 0; +} +.ui-menu .ui-menu { + position: absolute; +} +.ui-menu .ui-menu-item { + margin: 0; + cursor: pointer; + /* support: IE10, see #8844 */ + list-style-image: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"); +} +.ui-menu .ui-menu-item-wrapper { + position: relative; + padding: 3px 1em 3px .4em; +} +.ui-menu .ui-menu-divider { + margin: 5px 0; + height: 0; + font-size: 0; + line-height: 0; + border-width: 1px 0 0 0; +} +.ui-menu .ui-state-focus, +.ui-menu .ui-state-active { + margin: -1px; +} + +/* icon support */ +.ui-menu-icons { + position: relative; +} +.ui-menu-icons .ui-menu-item-wrapper { + padding-left: 2em; +} + +/* left-aligned */ +.ui-menu .ui-icon { + position: absolute; + top: 0; + bottom: 0; + left: .2em; + margin: auto 0; +} + +/* right-aligned */ +.ui-menu .ui-menu-icon { + left: auto; + right: 0; +} +.ui-button { + padding: .4em 1em; + display: inline-block; + position: relative; + line-height: normal; + margin-right: .1em; + cursor: pointer; + vertical-align: middle; + text-align: center; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + + /* Support: IE <= 11 */ + overflow: visible; +} + +.ui-button, +.ui-button:link, +.ui-button:visited, +.ui-button:hover, +.ui-button:active { + text-decoration: none; +} + +/* to make room for the icon, a width needs to be set here */ +.ui-button-icon-only { + width: 2em; + box-sizing: border-box; + text-indent: -9999px; + white-space: nowrap; +} + +/* no icon support for input elements */ +input.ui-button.ui-button-icon-only { + text-indent: 0; +} + +/* button icon element(s) */ +.ui-button-icon-only .ui-icon { + position: absolute; + top: 50%; + left: 50%; + margin-top: -8px; + margin-left: -8px; +} + +.ui-button.ui-icon-notext .ui-icon { + padding: 0; + width: 2.1em; + height: 2.1em; + text-indent: -9999px; + white-space: nowrap; + +} + +input.ui-button.ui-icon-notext .ui-icon { + width: auto; + height: auto; + text-indent: 0; + white-space: normal; + padding: .4em 1em; +} + +/* workarounds */ +/* Support: Firefox 5 - 40 */ +input.ui-button::-moz-focus-inner, +button.ui-button::-moz-focus-inner { + border: 0; + padding: 0; +} +.ui-controlgroup { + vertical-align: middle; + display: inline-block; +} +.ui-controlgroup > .ui-controlgroup-item { + float: left; + margin-left: 0; + margin-right: 0; +} +.ui-controlgroup > .ui-controlgroup-item:focus, +.ui-controlgroup > .ui-controlgroup-item.ui-visual-focus { + z-index: 9999; +} +.ui-controlgroup-vertical > .ui-controlgroup-item { + display: block; + float: none; + width: 100%; + margin-top: 0; + margin-bottom: 0; + text-align: left; +} +.ui-controlgroup-vertical .ui-controlgroup-item { + box-sizing: border-box; +} +.ui-controlgroup .ui-controlgroup-label { + padding: .4em 1em; +} +.ui-controlgroup .ui-controlgroup-label span { + font-size: 80%; +} +.ui-controlgroup-horizontal .ui-controlgroup-label + .ui-controlgroup-item { + border-left: none; +} +.ui-controlgroup-vertical .ui-controlgroup-label + .ui-controlgroup-item { + border-top: none; +} +.ui-controlgroup-horizontal .ui-controlgroup-label.ui-widget-content { + border-right: none; +} +.ui-controlgroup-vertical .ui-controlgroup-label.ui-widget-content { + border-bottom: none; +} + +/* Spinner specific style fixes */ +.ui-controlgroup-vertical .ui-spinner-input { + + /* Support: IE8 only, Android < 4.4 only */ + width: 75%; + width: calc( 100% - 2.4em ); +} +.ui-controlgroup-vertical .ui-spinner .ui-spinner-up { + border-top-style: solid; +} + +.ui-checkboxradio-label .ui-icon-background { + box-shadow: inset 1px 1px 1px #ccc; + border-radius: .12em; + border: none; +} +.ui-checkboxradio-radio-label .ui-icon-background { + width: 16px; + height: 16px; + border-radius: 1em; + overflow: visible; + border: none; +} +.ui-checkboxradio-radio-label.ui-checkboxradio-checked .ui-icon, +.ui-checkboxradio-radio-label.ui-checkboxradio-checked:hover .ui-icon { + background-image: none; + width: 8px; + height: 8px; + border-width: 4px; + border-style: solid; +} +.ui-checkboxradio-disabled { + pointer-events: none; +} +.ui-datepicker { + width: 17em; + padding: .2em .2em 0; + display: none; +} +.ui-datepicker .ui-datepicker-header { + position: relative; + padding: .2em 0; +} +.ui-datepicker .ui-datepicker-prev, +.ui-datepicker .ui-datepicker-next { + position: absolute; + top: 2px; + width: 1.8em; + height: 1.8em; +} +.ui-datepicker .ui-datepicker-prev-hover, +.ui-datepicker .ui-datepicker-next-hover { + top: 1px; +} +.ui-datepicker .ui-datepicker-prev { + left: 2px; +} +.ui-datepicker .ui-datepicker-next { + right: 2px; +} +.ui-datepicker .ui-datepicker-prev-hover { + left: 1px; +} +.ui-datepicker .ui-datepicker-next-hover { + right: 1px; +} +.ui-datepicker .ui-datepicker-prev span, +.ui-datepicker .ui-datepicker-next span { + display: block; + position: absolute; + left: 50%; + margin-left: -8px; + top: 50%; + margin-top: -8px; +} +.ui-datepicker .ui-datepicker-title { + margin: 0 2.3em; + line-height: 1.8em; + text-align: center; +} +.ui-datepicker .ui-datepicker-title select { + font-size: 1em; + margin: 1px 0; +} +.ui-datepicker select.ui-datepicker-month, +.ui-datepicker select.ui-datepicker-year { + width: 45%; +} +.ui-datepicker table { + width: 100%; + font-size: .9em; + border-collapse: collapse; + margin: 0 0 .4em; +} +.ui-datepicker th { + padding: .7em .3em; + text-align: center; + font-weight: bold; + border: 0; +} +.ui-datepicker td { + border: 0; + padding: 1px; +} +.ui-datepicker td span, +.ui-datepicker td a { + display: block; + padding: .2em; + text-align: right; + text-decoration: none; +} +.ui-datepicker .ui-datepicker-buttonpane { + background-image: none; + margin: .7em 0 0 0; + padding: 0 .2em; + border-left: 0; + border-right: 0; + border-bottom: 0; +} +.ui-datepicker .ui-datepicker-buttonpane button { + float: right; + margin: .5em .2em .4em; + cursor: pointer; + padding: .2em .6em .3em .6em; + width: auto; + overflow: visible; +} +.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { + float: left; +} + +/* with multiple calendars */ +.ui-datepicker.ui-datepicker-multi { + width: auto; +} +.ui-datepicker-multi .ui-datepicker-group { + float: left; +} +.ui-datepicker-multi .ui-datepicker-group table { + width: 95%; + margin: 0 auto .4em; +} +.ui-datepicker-multi-2 .ui-datepicker-group { + width: 50%; +} +.ui-datepicker-multi-3 .ui-datepicker-group { + width: 33.3%; +} +.ui-datepicker-multi-4 .ui-datepicker-group { + width: 25%; +} +.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header, +.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { + border-left-width: 0; +} +.ui-datepicker-multi .ui-datepicker-buttonpane { + clear: left; +} +.ui-datepicker-row-break { + clear: both; + width: 100%; + font-size: 0; +} + +/* RTL support */ +.ui-datepicker-rtl { + direction: rtl; +} +.ui-datepicker-rtl .ui-datepicker-prev { + right: 2px; + left: auto; +} +.ui-datepicker-rtl .ui-datepicker-next { + left: 2px; + right: auto; +} +.ui-datepicker-rtl .ui-datepicker-prev:hover { + right: 1px; + left: auto; +} +.ui-datepicker-rtl .ui-datepicker-next:hover { + left: 1px; + right: auto; +} +.ui-datepicker-rtl .ui-datepicker-buttonpane { + clear: right; +} +.ui-datepicker-rtl .ui-datepicker-buttonpane button { + float: left; +} +.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current, +.ui-datepicker-rtl .ui-datepicker-group { + float: right; +} +.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header, +.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { + border-right-width: 0; + border-left-width: 1px; +} + +/* Icons */ +.ui-datepicker .ui-icon { + display: block; + text-indent: -99999px; + overflow: hidden; + background-repeat: no-repeat; + left: .5em; + top: .3em; +} +.ui-dialog { + position: absolute; + top: 0; + left: 0; + padding: .2em; + outline: 0; +} +.ui-dialog .ui-dialog-titlebar { + padding: .4em 1em; + position: relative; +} +.ui-dialog .ui-dialog-title { + float: left; + margin: .1em 0; + white-space: nowrap; + width: 90%; + overflow: hidden; + text-overflow: ellipsis; +} +.ui-dialog .ui-dialog-titlebar-close { + position: absolute; + right: .3em; + top: 50%; + width: 20px; + margin: -10px 0 0 0; + padding: 1px; + height: 20px; +} +.ui-dialog .ui-dialog-content { + position: relative; + border: 0; + padding: .5em 1em; + background: none; + overflow: auto; +} +.ui-dialog .ui-dialog-buttonpane { + text-align: left; + border-width: 1px 0 0 0; + background-image: none; + margin-top: .5em; + padding: .3em 1em .5em .4em; +} +.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { + float: right; +} +.ui-dialog .ui-dialog-buttonpane button { + margin: .5em .4em .5em 0; + cursor: pointer; +} +.ui-dialog .ui-resizable-n { + height: 2px; + top: 0; +} +.ui-dialog .ui-resizable-e { + width: 2px; + right: 0; +} +.ui-dialog .ui-resizable-s { + height: 2px; + bottom: 0; +} +.ui-dialog .ui-resizable-w { + width: 2px; + left: 0; +} +.ui-dialog .ui-resizable-se, +.ui-dialog .ui-resizable-sw, +.ui-dialog .ui-resizable-ne, +.ui-dialog .ui-resizable-nw { + width: 7px; + height: 7px; +} +.ui-dialog .ui-resizable-se { + right: 0; + bottom: 0; +} +.ui-dialog .ui-resizable-sw { + left: 0; + bottom: 0; +} +.ui-dialog .ui-resizable-ne { + right: 0; + top: 0; +} +.ui-dialog .ui-resizable-nw { + left: 0; + top: 0; +} +.ui-draggable .ui-dialog-titlebar { + cursor: move; +} +.ui-draggable-handle { + -ms-touch-action: none; + touch-action: none; +} +.ui-resizable { + position: relative; +} +.ui-resizable-handle { + position: absolute; + font-size: 0.1px; + display: block; + -ms-touch-action: none; + touch-action: none; +} +.ui-resizable-disabled .ui-resizable-handle, +.ui-resizable-autohide .ui-resizable-handle { + display: none; +} +.ui-resizable-n { + cursor: n-resize; + height: 7px; + width: 100%; + top: -5px; + left: 0; +} +.ui-resizable-s { + cursor: s-resize; + height: 7px; + width: 100%; + bottom: -5px; + left: 0; +} +.ui-resizable-e { + cursor: e-resize; + width: 7px; + right: -5px; + top: 0; + height: 100%; +} +.ui-resizable-w { + cursor: w-resize; + width: 7px; + left: -5px; + top: 0; + height: 100%; +} +.ui-resizable-se { + cursor: se-resize; + width: 12px; + height: 12px; + right: 1px; + bottom: 1px; +} +.ui-resizable-sw { + cursor: sw-resize; + width: 9px; + height: 9px; + left: -5px; + bottom: -5px; +} +.ui-resizable-nw { + cursor: nw-resize; + width: 9px; + height: 9px; + left: -5px; + top: -5px; +} +.ui-resizable-ne { + cursor: ne-resize; + width: 9px; + height: 9px; + right: -5px; + top: -5px; +} +.ui-progressbar { + height: 2em; + text-align: left; + overflow: hidden; +} +.ui-progressbar .ui-progressbar-value { + margin: -1px; + height: 100%; +} +.ui-progressbar .ui-progressbar-overlay { + background: url("data:image/gif;base64,R0lGODlhKAAoAIABAAAAAP///yH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAQABACwAAAAAKAAoAAACkYwNqXrdC52DS06a7MFZI+4FHBCKoDeWKXqymPqGqxvJrXZbMx7Ttc+w9XgU2FB3lOyQRWET2IFGiU9m1frDVpxZZc6bfHwv4c1YXP6k1Vdy292Fb6UkuvFtXpvWSzA+HycXJHUXiGYIiMg2R6W459gnWGfHNdjIqDWVqemH2ekpObkpOlppWUqZiqr6edqqWQAAIfkECQEAAQAsAAAAACgAKAAAApSMgZnGfaqcg1E2uuzDmmHUBR8Qil95hiPKqWn3aqtLsS18y7G1SzNeowWBENtQd+T1JktP05nzPTdJZlR6vUxNWWjV+vUWhWNkWFwxl9VpZRedYcflIOLafaa28XdsH/ynlcc1uPVDZxQIR0K25+cICCmoqCe5mGhZOfeYSUh5yJcJyrkZWWpaR8doJ2o4NYq62lAAACH5BAkBAAEALAAAAAAoACgAAAKVDI4Yy22ZnINRNqosw0Bv7i1gyHUkFj7oSaWlu3ovC8GxNso5fluz3qLVhBVeT/Lz7ZTHyxL5dDalQWPVOsQWtRnuwXaFTj9jVVh8pma9JjZ4zYSj5ZOyma7uuolffh+IR5aW97cHuBUXKGKXlKjn+DiHWMcYJah4N0lYCMlJOXipGRr5qdgoSTrqWSq6WFl2ypoaUAAAIfkECQEAAQAsAAAAACgAKAAAApaEb6HLgd/iO7FNWtcFWe+ufODGjRfoiJ2akShbueb0wtI50zm02pbvwfWEMWBQ1zKGlLIhskiEPm9R6vRXxV4ZzWT2yHOGpWMyorblKlNp8HmHEb/lCXjcW7bmtXP8Xt229OVWR1fod2eWqNfHuMjXCPkIGNileOiImVmCOEmoSfn3yXlJWmoHGhqp6ilYuWYpmTqKUgAAIfkECQEAAQAsAAAAACgAKAAAApiEH6kb58biQ3FNWtMFWW3eNVcojuFGfqnZqSebuS06w5V80/X02pKe8zFwP6EFWOT1lDFk8rGERh1TTNOocQ61Hm4Xm2VexUHpzjymViHrFbiELsefVrn6XKfnt2Q9G/+Xdie499XHd2g4h7ioOGhXGJboGAnXSBnoBwKYyfioubZJ2Hn0RuRZaflZOil56Zp6iioKSXpUAAAh+QQJAQABACwAAAAAKAAoAAACkoQRqRvnxuI7kU1a1UU5bd5tnSeOZXhmn5lWK3qNTWvRdQxP8qvaC+/yaYQzXO7BMvaUEmJRd3TsiMAgswmNYrSgZdYrTX6tSHGZO73ezuAw2uxuQ+BbeZfMxsexY35+/Qe4J1inV0g4x3WHuMhIl2jXOKT2Q+VU5fgoSUI52VfZyfkJGkha6jmY+aaYdirq+lQAACH5BAkBAAEALAAAAAAoACgAAAKWBIKpYe0L3YNKToqswUlvznigd4wiR4KhZrKt9Upqip61i9E3vMvxRdHlbEFiEXfk9YARYxOZZD6VQ2pUunBmtRXo1Lf8hMVVcNl8JafV38aM2/Fu5V16Bn63r6xt97j09+MXSFi4BniGFae3hzbH9+hYBzkpuUh5aZmHuanZOZgIuvbGiNeomCnaxxap2upaCZsq+1kAACH5BAkBAAEALAAAAAAoACgAAAKXjI8By5zf4kOxTVrXNVlv1X0d8IGZGKLnNpYtm8Lr9cqVeuOSvfOW79D9aDHizNhDJidFZhNydEahOaDH6nomtJjp1tutKoNWkvA6JqfRVLHU/QUfau9l2x7G54d1fl995xcIGAdXqMfBNadoYrhH+Mg2KBlpVpbluCiXmMnZ2Sh4GBqJ+ckIOqqJ6LmKSllZmsoq6wpQAAAh+QQJAQABACwAAAAAKAAoAAAClYx/oLvoxuJDkU1a1YUZbJ59nSd2ZXhWqbRa2/gF8Gu2DY3iqs7yrq+xBYEkYvFSM8aSSObE+ZgRl1BHFZNr7pRCavZ5BW2142hY3AN/zWtsmf12p9XxxFl2lpLn1rseztfXZjdIWIf2s5dItwjYKBgo9yg5pHgzJXTEeGlZuenpyPmpGQoKOWkYmSpaSnqKileI2FAAACH5BAkBAAEALAAAAAAoACgAAAKVjB+gu+jG4kORTVrVhRlsnn2dJ3ZleFaptFrb+CXmO9OozeL5VfP99HvAWhpiUdcwkpBH3825AwYdU8xTqlLGhtCosArKMpvfa1mMRae9VvWZfeB2XfPkeLmm18lUcBj+p5dnN8jXZ3YIGEhYuOUn45aoCDkp16hl5IjYJvjWKcnoGQpqyPlpOhr3aElaqrq56Bq7VAAAOw=="); + height: 100%; + -ms-filter: "alpha(opacity=25)"; /* support: IE8 */ + opacity: 0.25; +} +.ui-progressbar-indeterminate .ui-progressbar-value { + background-image: none; +} +.ui-selectable { + -ms-touch-action: none; + touch-action: none; +} +.ui-selectable-helper { + position: absolute; + z-index: 100; + border: 1px dotted black; +} +.ui-selectmenu-menu { + padding: 0; + margin: 0; + position: absolute; + top: 0; + left: 0; + display: none; +} +.ui-selectmenu-menu .ui-menu { + overflow: auto; + overflow-x: hidden; + padding-bottom: 1px; +} +.ui-selectmenu-menu .ui-menu .ui-selectmenu-optgroup { + font-size: 1em; + font-weight: bold; + line-height: 1.5; + padding: 2px 0.4em; + margin: 0.5em 0 0 0; + height: auto; + border: 0; +} +.ui-selectmenu-open { + display: block; +} +.ui-selectmenu-text { + display: block; + margin-right: 20px; + overflow: hidden; + text-overflow: ellipsis; +} +.ui-selectmenu-button.ui-button { + text-align: left; + white-space: nowrap; + width: 14em; +} +.ui-selectmenu-icon.ui-icon { + float: right; + margin-top: 0; +} +.ui-slider { + position: relative; + text-align: left; +} +.ui-slider .ui-slider-handle { + position: absolute; + z-index: 2; + width: 1.2em; + height: 1.2em; + cursor: pointer; + -ms-touch-action: none; + touch-action: none; +} +.ui-slider .ui-slider-range { + position: absolute; + z-index: 1; + font-size: .7em; + display: block; + border: 0; + background-position: 0 0; +} + +/* support: IE8 - See #6727 */ +.ui-slider.ui-state-disabled .ui-slider-handle, +.ui-slider.ui-state-disabled .ui-slider-range { + filter: inherit; +} + +.ui-slider-horizontal { + height: .8em; +} +.ui-slider-horizontal .ui-slider-handle { + top: -.3em; + margin-left: -.6em; +} +.ui-slider-horizontal .ui-slider-range { + top: 0; + height: 100%; +} +.ui-slider-horizontal .ui-slider-range-min { + left: 0; +} +.ui-slider-horizontal .ui-slider-range-max { + right: 0; +} + +.ui-slider-vertical { + width: .8em; + height: 100px; +} +.ui-slider-vertical .ui-slider-handle { + left: -.3em; + margin-left: 0; + margin-bottom: -.6em; +} +.ui-slider-vertical .ui-slider-range { + left: 0; + width: 100%; +} +.ui-slider-vertical .ui-slider-range-min { + bottom: 0; +} +.ui-slider-vertical .ui-slider-range-max { + top: 0; +} +.ui-sortable-handle { + -ms-touch-action: none; + touch-action: none; +} +.ui-spinner { + position: relative; + display: inline-block; + overflow: hidden; + padding: 0; + vertical-align: middle; +} +.ui-spinner-input { + border: none; + background: none; + color: inherit; + padding: .222em 0; + margin: .2em 0; + vertical-align: middle; + margin-left: .4em; + margin-right: 2em; +} +.ui-spinner-button { + width: 1.6em; + height: 50%; + font-size: .5em; + padding: 0; + margin: 0; + text-align: center; + position: absolute; + cursor: default; + display: block; + overflow: hidden; + right: 0; +} +/* more specificity required here to override default borders */ +.ui-spinner a.ui-spinner-button { + border-top-style: none; + border-bottom-style: none; + border-right-style: none; +} +.ui-spinner-up { + top: 0; +} +.ui-spinner-down { + bottom: 0; +} +.ui-tabs { + position: relative;/* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */ + padding: .2em; +} +.ui-tabs .ui-tabs-nav { + margin: 0; + padding: .2em .2em 0; +} +.ui-tabs .ui-tabs-nav li { + list-style: none; + float: left; + position: relative; + top: 0; + margin: 1px .2em 0 0; + border-bottom-width: 0; + padding: 0; + white-space: nowrap; +} +.ui-tabs .ui-tabs-nav .ui-tabs-anchor { + float: left; + padding: .5em 1em; + text-decoration: none; +} +.ui-tabs .ui-tabs-nav li.ui-tabs-active { + margin-bottom: -1px; + padding-bottom: 1px; +} +.ui-tabs .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor, +.ui-tabs .ui-tabs-nav li.ui-state-disabled .ui-tabs-anchor, +.ui-tabs .ui-tabs-nav li.ui-tabs-loading .ui-tabs-anchor { + cursor: text; +} +.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor { + cursor: pointer; +} +.ui-tabs .ui-tabs-panel { + display: block; + border-width: 0; + padding: 1em 1.4em; + background: none; +} +.ui-tooltip { + padding: 8px; + position: absolute; + z-index: 9999; + max-width: 300px; +} +body .ui-tooltip { + border-width: 2px; +} + +/* Component containers +----------------------------------*/ +.ui-widget { + font-family: Arial,Helvetica,sans-serif; + font-size: 1em; +} +.ui-widget .ui-widget { + font-size: 1em; +} +.ui-widget input, +.ui-widget select, +.ui-widget textarea, +.ui-widget button { + font-family: Arial,Helvetica,sans-serif; + font-size: 1em; +} +.ui-widget.ui-widget-content { + border: 1px solid #c5c5c5; +} +.ui-widget-content { + border: 1px solid #dddddd; + background: #ffffff; + color: #333333; +} +.ui-widget-content a { + color: #333333; +} +.ui-widget-header { + border: 1px solid #dddddd; + background: #e9e9e9; + color: #333333; + font-weight: bold; +} +.ui-widget-header a { + color: #333333; +} + +/* Interaction states +----------------------------------*/ +.ui-state-default, +.ui-widget-content .ui-state-default, +.ui-widget-header .ui-state-default, +.ui-button, + +/* We use html here because we need a greater specificity to make sure disabled +works properly when clicked or hovered */ +html .ui-button.ui-state-disabled:hover, +html .ui-button.ui-state-disabled:active { + border: 1px solid #c5c5c5; + background: #f6f6f6; + font-weight: normal; + color: #454545; +} +.ui-state-default a, +.ui-state-default a:link, +.ui-state-default a:visited, +a.ui-button, +a:link.ui-button, +a:visited.ui-button, +.ui-button { + color: #454545; + text-decoration: none; +} +.ui-state-hover, +.ui-widget-content .ui-state-hover, +.ui-widget-header .ui-state-hover, +.ui-state-focus, +.ui-widget-content .ui-state-focus, +.ui-widget-header .ui-state-focus, +.ui-button:hover, +.ui-button:focus { + border: 1px solid #cccccc; + background: #ededed; + font-weight: normal; + color: #2b2b2b; +} +.ui-state-hover a, +.ui-state-hover a:hover, +.ui-state-hover a:link, +.ui-state-hover a:visited, +.ui-state-focus a, +.ui-state-focus a:hover, +.ui-state-focus a:link, +.ui-state-focus a:visited, +a.ui-button:hover, +a.ui-button:focus { + color: #2b2b2b; + text-decoration: none; +} + +.ui-visual-focus { + box-shadow: 0 0 3px 1px rgb(94, 158, 214); +} +.ui-state-active, +.ui-widget-content .ui-state-active, +.ui-widget-header .ui-state-active, +a.ui-button:active, +.ui-button:active, +.ui-button.ui-state-active:hover { + border: 1px solid #003eff; + background: #007fff; + font-weight: normal; + color: #ffffff; +} +.ui-icon-background, +.ui-state-active .ui-icon-background { + border: #003eff; + background-color: #ffffff; +} +.ui-state-active a, +.ui-state-active a:link, +.ui-state-active a:visited { + color: #ffffff; + text-decoration: none; +} + +/* Interaction Cues +----------------------------------*/ +.ui-state-highlight, +.ui-widget-content .ui-state-highlight, +.ui-widget-header .ui-state-highlight { + border: 1px solid #dad55e; + background: #fffa90; + color: #777620; +} +.ui-state-checked { + border: 1px solid #dad55e; + background: #fffa90; +} +.ui-state-highlight a, +.ui-widget-content .ui-state-highlight a, +.ui-widget-header .ui-state-highlight a { + color: #777620; +} +.ui-state-error, +.ui-widget-content .ui-state-error, +.ui-widget-header .ui-state-error { + border: 1px solid #f1a899; + background: #fddfdf; + color: #5f3f3f; +} +.ui-state-error a, +.ui-widget-content .ui-state-error a, +.ui-widget-header .ui-state-error a { + color: #5f3f3f; +} +.ui-state-error-text, +.ui-widget-content .ui-state-error-text, +.ui-widget-header .ui-state-error-text { + color: #5f3f3f; +} +.ui-priority-primary, +.ui-widget-content .ui-priority-primary, +.ui-widget-header .ui-priority-primary { + font-weight: bold; +} +.ui-priority-secondary, +.ui-widget-content .ui-priority-secondary, +.ui-widget-header .ui-priority-secondary { + opacity: .7; + -ms-filter: "alpha(opacity=70)"; /* support: IE8 */ + font-weight: normal; +} +.ui-state-disabled, +.ui-widget-content .ui-state-disabled, +.ui-widget-header .ui-state-disabled { + opacity: .35; + -ms-filter: "alpha(opacity=35)"; /* support: IE8 */ + background-image: none; +} +.ui-state-disabled .ui-icon { + -ms-filter: "alpha(opacity=35)"; /* support: IE8 - See #6059 */ +} + +/* Icons +----------------------------------*/ + +/* states and images */ +.ui-icon { + width: 16px; + height: 16px; +} +.ui-icon, +.ui-widget-content .ui-icon { + background-image: url("images/ui-icons_444444_256x240.png"); +} +.ui-widget-header .ui-icon { + background-image: url("images/ui-icons_444444_256x240.png"); +} +.ui-state-hover .ui-icon, +.ui-state-focus .ui-icon, +.ui-button:hover .ui-icon, +.ui-button:focus .ui-icon { + background-image: url("images/ui-icons_555555_256x240.png"); +} +.ui-state-active .ui-icon, +.ui-button:active .ui-icon { + background-image: url("images/ui-icons_ffffff_256x240.png"); +} +.ui-state-highlight .ui-icon, +.ui-button .ui-state-highlight.ui-icon { + background-image: url("images/ui-icons_777620_256x240.png"); +} +.ui-state-error .ui-icon, +.ui-state-error-text .ui-icon { + background-image: url("images/ui-icons_cc0000_256x240.png"); +} +.ui-button .ui-icon { + background-image: url("images/ui-icons_777777_256x240.png"); +} + +/* positioning */ +/* Three classes needed to override `.ui-button:hover .ui-icon` */ +.ui-icon-blank.ui-icon-blank.ui-icon-blank { + background-image: none; +} +.ui-icon-caret-1-n { background-position: 0 0; } +.ui-icon-caret-1-ne { background-position: -16px 0; } +.ui-icon-caret-1-e { background-position: -32px 0; } +.ui-icon-caret-1-se { background-position: -48px 0; } +.ui-icon-caret-1-s { background-position: -65px 0; } +.ui-icon-caret-1-sw { background-position: -80px 0; } +.ui-icon-caret-1-w { background-position: -96px 0; } +.ui-icon-caret-1-nw { background-position: -112px 0; } +.ui-icon-caret-2-n-s { background-position: -128px 0; } +.ui-icon-caret-2-e-w { background-position: -144px 0; } +.ui-icon-triangle-1-n { background-position: 0 -16px; } +.ui-icon-triangle-1-ne { background-position: -16px -16px; } +.ui-icon-triangle-1-e { background-position: -32px -16px; } +.ui-icon-triangle-1-se { background-position: -48px -16px; } +.ui-icon-triangle-1-s { background-position: -65px -16px; } +.ui-icon-triangle-1-sw { background-position: -80px -16px; } +.ui-icon-triangle-1-w { background-position: -96px -16px; } +.ui-icon-triangle-1-nw { background-position: -112px -16px; } +.ui-icon-triangle-2-n-s { background-position: -128px -16px; } +.ui-icon-triangle-2-e-w { background-position: -144px -16px; } +.ui-icon-arrow-1-n { background-position: 0 -32px; } +.ui-icon-arrow-1-ne { background-position: -16px -32px; } +.ui-icon-arrow-1-e { background-position: -32px -32px; } +.ui-icon-arrow-1-se { background-position: -48px -32px; } +.ui-icon-arrow-1-s { background-position: -65px -32px; } +.ui-icon-arrow-1-sw { background-position: -80px -32px; } +.ui-icon-arrow-1-w { background-position: -96px -32px; } +.ui-icon-arrow-1-nw { background-position: -112px -32px; } +.ui-icon-arrow-2-n-s { background-position: -128px -32px; } +.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } +.ui-icon-arrow-2-e-w { background-position: -160px -32px; } +.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } +.ui-icon-arrowstop-1-n { background-position: -192px -32px; } +.ui-icon-arrowstop-1-e { background-position: -208px -32px; } +.ui-icon-arrowstop-1-s { background-position: -224px -32px; } +.ui-icon-arrowstop-1-w { background-position: -240px -32px; } +.ui-icon-arrowthick-1-n { background-position: 1px -48px; } +.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } +.ui-icon-arrowthick-1-e { background-position: -32px -48px; } +.ui-icon-arrowthick-1-se { background-position: -48px -48px; } +.ui-icon-arrowthick-1-s { background-position: -64px -48px; } +.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } +.ui-icon-arrowthick-1-w { background-position: -96px -48px; } +.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } +.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } +.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } +.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } +.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } +.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } +.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } +.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } +.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } +.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } +.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } +.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } +.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } +.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } +.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } +.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } +.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } +.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } +.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } +.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } +.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } +.ui-icon-arrow-4 { background-position: 0 -80px; } +.ui-icon-arrow-4-diag { background-position: -16px -80px; } +.ui-icon-extlink { background-position: -32px -80px; } +.ui-icon-newwin { background-position: -48px -80px; } +.ui-icon-refresh { background-position: -64px -80px; } +.ui-icon-shuffle { background-position: -80px -80px; } +.ui-icon-transfer-e-w { background-position: -96px -80px; } +.ui-icon-transferthick-e-w { background-position: -112px -80px; } +.ui-icon-folder-collapsed { background-position: 0 -96px; } +.ui-icon-folder-open { background-position: -16px -96px; } +.ui-icon-document { background-position: -32px -96px; } +.ui-icon-document-b { background-position: -48px -96px; } +.ui-icon-note { background-position: -64px -96px; } +.ui-icon-mail-closed { background-position: -80px -96px; } +.ui-icon-mail-open { background-position: -96px -96px; } +.ui-icon-suitcase { background-position: -112px -96px; } +.ui-icon-comment { background-position: -128px -96px; } +.ui-icon-person { background-position: -144px -96px; } +.ui-icon-print { background-position: -160px -96px; } +.ui-icon-trash { background-position: -176px -96px; } +.ui-icon-locked { background-position: -192px -96px; } +.ui-icon-unlocked { background-position: -208px -96px; } +.ui-icon-bookmark { background-position: -224px -96px; } +.ui-icon-tag { background-position: -240px -96px; } +.ui-icon-home { background-position: 0 -112px; } +.ui-icon-flag { background-position: -16px -112px; } +.ui-icon-calendar { background-position: -32px -112px; } +.ui-icon-cart { background-position: -48px -112px; } +.ui-icon-pencil { background-position: -64px -112px; } +.ui-icon-clock { background-position: -80px -112px; } +.ui-icon-disk { background-position: -96px -112px; } +.ui-icon-calculator { background-position: -112px -112px; } +.ui-icon-zoomin { background-position: -128px -112px; } +.ui-icon-zoomout { background-position: -144px -112px; } +.ui-icon-search { background-position: -160px -112px; } +.ui-icon-wrench { background-position: -176px -112px; } +.ui-icon-gear { background-position: -192px -112px; } +.ui-icon-heart { background-position: -208px -112px; } +.ui-icon-star { background-position: -224px -112px; } +.ui-icon-link { background-position: -240px -112px; } +.ui-icon-cancel { background-position: 0 -128px; } +.ui-icon-plus { background-position: -16px -128px; } +.ui-icon-plusthick { background-position: -32px -128px; } +.ui-icon-minus { background-position: -48px -128px; } +.ui-icon-minusthick { background-position: -64px -128px; } +.ui-icon-close { background-position: -80px -128px; } +.ui-icon-closethick { background-position: -96px -128px; } +.ui-icon-key { background-position: -112px -128px; } +.ui-icon-lightbulb { background-position: -128px -128px; } +.ui-icon-scissors { background-position: -144px -128px; } +.ui-icon-clipboard { background-position: -160px -128px; } +.ui-icon-copy { background-position: -176px -128px; } +.ui-icon-contact { background-position: -192px -128px; } +.ui-icon-image { background-position: -208px -128px; } +.ui-icon-video { background-position: -224px -128px; } +.ui-icon-script { background-position: -240px -128px; } +.ui-icon-alert { background-position: 0 -144px; } +.ui-icon-info { background-position: -16px -144px; } +.ui-icon-notice { background-position: -32px -144px; } +.ui-icon-help { background-position: -48px -144px; } +.ui-icon-check { background-position: -64px -144px; } +.ui-icon-bullet { background-position: -80px -144px; } +.ui-icon-radio-on { background-position: -96px -144px; } +.ui-icon-radio-off { background-position: -112px -144px; } +.ui-icon-pin-w { background-position: -128px -144px; } +.ui-icon-pin-s { background-position: -144px -144px; } +.ui-icon-play { background-position: 0 -160px; } +.ui-icon-pause { background-position: -16px -160px; } +.ui-icon-seek-next { background-position: -32px -160px; } +.ui-icon-seek-prev { background-position: -48px -160px; } +.ui-icon-seek-end { background-position: -64px -160px; } +.ui-icon-seek-start { background-position: -80px -160px; } +/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ +.ui-icon-seek-first { background-position: -80px -160px; } +.ui-icon-stop { background-position: -96px -160px; } +.ui-icon-eject { background-position: -112px -160px; } +.ui-icon-volume-off { background-position: -128px -160px; } +.ui-icon-volume-on { background-position: -144px -160px; } +.ui-icon-power { background-position: 0 -176px; } +.ui-icon-signal-diag { background-position: -16px -176px; } +.ui-icon-signal { background-position: -32px -176px; } +.ui-icon-battery-0 { background-position: -48px -176px; } +.ui-icon-battery-1 { background-position: -64px -176px; } +.ui-icon-battery-2 { background-position: -80px -176px; } +.ui-icon-battery-3 { background-position: -96px -176px; } +.ui-icon-circle-plus { background-position: 0 -192px; } +.ui-icon-circle-minus { background-position: -16px -192px; } +.ui-icon-circle-close { background-position: -32px -192px; } +.ui-icon-circle-triangle-e { background-position: -48px -192px; } +.ui-icon-circle-triangle-s { background-position: -64px -192px; } +.ui-icon-circle-triangle-w { background-position: -80px -192px; } +.ui-icon-circle-triangle-n { background-position: -96px -192px; } +.ui-icon-circle-arrow-e { background-position: -112px -192px; } +.ui-icon-circle-arrow-s { background-position: -128px -192px; } +.ui-icon-circle-arrow-w { background-position: -144px -192px; } +.ui-icon-circle-arrow-n { background-position: -160px -192px; } +.ui-icon-circle-zoomin { background-position: -176px -192px; } +.ui-icon-circle-zoomout { background-position: -192px -192px; } +.ui-icon-circle-check { background-position: -208px -192px; } +.ui-icon-circlesmall-plus { background-position: 0 -208px; } +.ui-icon-circlesmall-minus { background-position: -16px -208px; } +.ui-icon-circlesmall-close { background-position: -32px -208px; } +.ui-icon-squaresmall-plus { background-position: -48px -208px; } +.ui-icon-squaresmall-minus { background-position: -64px -208px; } +.ui-icon-squaresmall-close { background-position: -80px -208px; } +.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } +.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } +.ui-icon-grip-solid-vertical { background-position: -32px -224px; } +.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } +.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } +.ui-icon-grip-diagonal-se { background-position: -80px -224px; } + + +/* Misc visuals +----------------------------------*/ + +/* Corner radius */ +.ui-corner-all, +.ui-corner-top, +.ui-corner-left, +.ui-corner-tl { + border-top-left-radius: 3px; +} +.ui-corner-all, +.ui-corner-top, +.ui-corner-right, +.ui-corner-tr { + border-top-right-radius: 3px; +} +.ui-corner-all, +.ui-corner-bottom, +.ui-corner-left, +.ui-corner-bl { + border-bottom-left-radius: 3px; +} +.ui-corner-all, +.ui-corner-bottom, +.ui-corner-right, +.ui-corner-br { + border-bottom-right-radius: 3px; +} + +/* Overlays */ +.ui-widget-overlay { + background: #aaaaaa; + opacity: .003; + -ms-filter: Alpha(Opacity=.3); /* support: IE8 */ +} +.ui-widget-shadow { + -webkit-box-shadow: 0px 0px 5px #666666; + box-shadow: 0px 0px 5px #666666; +} diff --git a/config/js/config.js b/config/js/config.js index bf7920ad..d9d492cd 100644 --- a/config/js/config.js +++ b/config/js/config.js @@ -1,11 +1,15 @@ //So that each layer bar will always have a unique id var grandLayerCounter = 0; var mission = ""; +var configId = -1; +var lockConfig = false; +var lockConfigCount = false; //The active mission filepath var missionPath = ""; var tData; var editors; var layerEditors; +var tabEditors; var usingCustomProjection; var availableKinds = []; @@ -27,7 +31,9 @@ function initialize() { url: calls.logout.url, data: {}, success: function (data) { - window.location = "/"; + // Remove last directory from pathname + const path = window.location.pathname.split("/"); + window.location.href = path.slice(0, path.length - 1).join("/") || "/"; }, }); }); @@ -130,6 +136,7 @@ function initialize() { editors = {}; layerEditors = {}; + tabEditors = {}; for (var i = 0; i < tData.length; i++) { // prettier-ignore @@ -197,6 +204,39 @@ function initialize() { } } + // Setup tabEditors + tabEditors["coordinatesVariables"] = CodeMirror.fromTextArea( + document.getElementById("coordinatesVariables"), + { + path: "js/codemirror/codemirror-5.19.0/", + mode: "javascript", + theme: "elegant", + viewportMargin: Infinity, + lineNumbers: true, + autoRefresh: true, + matchBrackets: true, + } + ); + $("#coordinatesVariables_example").html( + JSON.stringify( + { + rightClickMenuActions: [ + { + name: "The text for this menu entry when users right-click", + link: "https://domain?I={ll[0]}&will={ll[1]}&replace={ll[2]}&these={en[0]}&brackets={en[1]}&for={cproj[0]}&you={sproj[0]}&with={rxy[0]}&coordinates={site[2]}", + }, + { + name: "WKT text insertions. Do so only for polygons.", + link: "https://domain?regularWKT={wkt}&wkt_where_commas_are_replaced_with_underscores={wkt_}", + for: "polygon", + }, + ], + }, + null, + 4 + ) || "" + ); + //Make materialize initialize tabs $("ul.tabs#missions").tabs(); @@ -228,6 +268,7 @@ function initialize() { mission = $(this).find("a").html(); missionPath = calls.missionPath + mission + "/config.json"; + configId = parseInt(Math.random() * 100000); $.ajax({ type: calls.get.type, @@ -240,6 +281,12 @@ function initialize() { if (data.status == "success") { var cData = data.config; + clearLockConfig(); + + for (var e in tabEditors) { + tabEditors[e].setValue(""); + } + //overall $("#overall_mission_name").text(mission); @@ -492,6 +539,11 @@ function initialize() { $( `.coordinates_coordMain[value="${cData.coordinates?.coordmain}"]` ).prop("checked", true); + tabEditors["coordinatesVariables"].setValue( + cData.coordinates?.variables + ? JSON.stringify(cData.coordinates?.variables, null, 4) + : "" + ); //look $("#tab_look #look_pagename").val("MMGIS"); @@ -499,15 +551,33 @@ function initialize() { $("#tab_look #look_pagename").val(cData.look.pagename); } $("#tab_look input").prop("checked", false); - if (cData.look && cData.look.minimalist == true) { + if (cData.look && cData.look.minimalist != false) { $("#tab_look #look_minimalist").prop("checked", true); } - if (cData.look && cData.look.zoomcontrol == true) { + if (cData.look && cData.look.topbar != false) { + $("#tab_look #look_topbar").prop("checked", true); + } + if (cData.look && cData.look.toolbar != false) { + $("#tab_look #look_toolbar").prop("checked", true); + } + if (cData.look && cData.look.scalebar != false) { + $("#tab_look #look_scalebar").prop("checked", true); + } + if (cData.look && cData.look.coordinates != false) { + $("#tab_look #look_coordinates").prop("checked", true); + } + if (cData.look && cData.look.zoomcontrol != false) { $("#tab_look #look_zoomcontrol").prop("checked", true); } - if (cData.look && cData.look.graticule == true) { + if (cData.look && cData.look.graticule != false) { $("#tab_look #look_graticule").prop("checked", true); } + if (cData.look && cData.look.miscellaneous != false) { + $("#tab_look #look_miscellaneous").prop("checked", true); + } + if (cData.look && cData.look.settings != false) { + $("#tab_look #look_settings").prop("checked", true); + } //look colors $("#tab_look #look_primarycolor").val( @@ -558,6 +628,12 @@ function initialize() { ) { $("#tab_look #look_fullscreen").prop("checked", true); } + if (cData.look && cData.look.info == true) { + $("#tab_look #look_info").prop("checked", true); + } + $("#tab_look #look_infourl").val( + cData.look ? cData.look.infourl : "" + ); if ( cData.look && (cData.look.help == true || cData.look.help == null) @@ -601,10 +677,26 @@ function initialize() { "checked", cData.time.visible ? true : false ); + $("#tab_time #time_initiallyOpen").prop( + "checked", + cData.time.initiallyOpen ? true : false + ); } $("#tab_time #time_format").val( cData.time ? cData.time.format : "%Y-%m-%dT%H:%M:%SZ" ); + $("#tab_time #time_initialstart").val( + cData.time ? cData.time.initialstart : "" + ); + $("#tab_time #time_initialend").val( + cData.time ? cData.time.initialend : "now" + ); + $("#tab_time #time_initialwindowstart").val( + cData.time ? cData.time.initialwindowstart : "" + ); + $("#tab_time #time_initialwindowend").val( + cData.time ? cData.time.initialwindowend : "now" + ); //tools //uncheck all tools @@ -786,6 +878,17 @@ function initialize() { $("#deleteMissionName").val(""); }); + //Download working config button + $("#download_working_config").on("click", function () { + downloadObject( + save("returnJSON"), + mission + "_config_WORKING", + ".json", + true + ); + toast("success", "Download Successful."); + }); + //Save changes button $("#save_changes").on("click", save); } @@ -870,7 +973,10 @@ function makeLayerBarAndModal(d, level, options) { vtLayerSetStylesEl = "block", timeEl = "block", timeTypeEl = "block", + timeStartPropEl = "block", + timeEndPropEl = "block", timeFormatEl = "block", + timeCompositeTileEl = "block", timeRefreshEl = "none", timeIncrementEl = "none", shapeEl = "none", @@ -889,11 +995,11 @@ function makeLayerBarAndModal(d, level, options) { maxnzEl = "none"; maxzEl = "none"; strcolEl = "none"; filcolEl = "none"; weightEl = "none"; opacityEl = "none"; radiusEl = "none"; variableEl = "none"; xmlEl = "none"; bbEl = "none"; vtLayerEl = "none"; vtIdEl = "none"; vtKeyEl = "none"; vtLayerSetStylesEl = "none"; - timeEl = "none"; timeTypeEl = "none"; timeFormatEl = "none"; timeRefreshEl = "none"; timeIncrementEl = "none"; shapeEl = "none"; + timeEl = "none"; timeTypeEl = "none"; timeStartPropEl = "none"; timeEndPropEl = "none"; timeFormatEl = "none"; timeCompositeTileEl = "none"; timeRefreshEl = "none"; timeIncrementEl = "none"; shapeEl = "none"; queryEndpointEl = "none"; queryTypeEl = "none"; break; case "tile": - nameEl = "block"; kindEl = "none"; typeEl = "block"; urlEl = "block"; demtileurlEl = "block"; demparserEl = "block"; controlledEl = "none"; + nameEl = "block"; kindEl = "none"; typeEl = "block"; urlEl = "block"; demtileurlEl = "block"; demparserEl = "block"; controlledEl = "block"; descriptionEl = "block"; tagsEl = "block"; legendEl = "block"; visEl = "block"; viscutEl = "none"; initOpacEl = "block"; togwheadEl = "block"; minzEl = "block"; layer3dEl = "none"; tileformatEl = "block"; @@ -902,7 +1008,7 @@ function makeLayerBarAndModal(d, level, options) { maxnzEl = "block"; maxzEl = "block"; strcolEl = "none"; filcolEl = "none"; weightEl = "none"; opacityEl = "none"; radiusEl = "none"; variableEl = "none"; xmlEl = "block"; bbEl = "block"; vtLayerEl = "none"; vtIdEl = "none"; vtKeyEl = "none"; vtLayerSetStylesEl = "none"; - timeEl = "block"; timeTypeEl = "block"; timeFormatEl = "block"; timeRefreshEl = "none"; timeIncrementEl = "none"; shapeEl = "none"; + timeEl = "block"; timeTypeEl = "block"; timeStartPropEl = "none"; timeEndPropEl = "none"; timeFormatEl = "block"; timeCompositeTileEl = "block"; timeRefreshEl = "none"; timeIncrementEl = "none"; shapeEl = "none"; queryEndpointEl = "none"; queryTypeEl = "none"; break; case "vectortile": @@ -915,7 +1021,7 @@ function makeLayerBarAndModal(d, level, options) { maxnzEl = "block"; maxzEl = "block"; strcolEl = "none"; filcolEl = "none"; weightEl = "none"; opacityEl = "none"; radiusEl = "none"; variableEl = "block"; xmlEl = "none"; bbEl = "none"; vtLayerEl = "block"; vtIdEl = "block"; vtKeyEl = "block"; vtLayerSetStylesEl = "block"; - timeEl = "block"; timeTypeEl = "block"; timeFormatEl = "block"; timeRefreshEl = "none"; timeIncrementEl = "none"; shapeEl = "block"; + timeEl = "block"; timeTypeEl = "block"; timeStartPropEl = "none"; timeEndPropEl = "none"; timeFormatEl = "block"; timeCompositeTileEl = "none"; timeRefreshEl = "none"; timeIncrementEl = "none"; shapeEl = "block"; queryEndpointEl = "none"; queryTypeEl = "none"; break; case "data": @@ -928,7 +1034,7 @@ function makeLayerBarAndModal(d, level, options) { maxnzEl = "block"; maxzEl = "block"; strcolEl = "none"; filcolEl = "none"; weightEl = "none"; opacityEl = "none"; radiusEl = "none"; variableEl = "block"; xmlEl = "block"; bbEl = "block"; vtLayerEl = "none"; vtIdEl = "none"; vtKeyEl = "none"; vtLayerSetStylesEl = "none"; - timeEl = "block"; timeTypeEl = "block"; timeFormatEl = "block"; timeRefreshEl = "none"; timeIncrementEl = "none"; shapeEl = "none"; + timeEl = "block"; timeTypeEl = "block"; timeStartPropEl = "none"; timeEndPropEl = "none"; timeFormatEl = "block"; timeCompositeTileEl = "none"; timeRefreshEl = "none"; timeIncrementEl = "none"; shapeEl = "none"; queryEndpointEl = "none"; queryTypeEl = "none"; break; case "query": @@ -941,7 +1047,7 @@ function makeLayerBarAndModal(d, level, options) { maxnzEl = "none"; maxzEl = "none"; strcolEl = "block"; filcolEl = "block"; weightEl = "block"; opacityEl = "block"; radiusEl = "block"; variableEl = "block"; xmlEl = "none"; bbEl = "none"; vtLayerEl = "none"; vtIdEl = "none"; vtKeyEl = "none"; vtLayerSetStylesEl = "none"; - timeEl = "none"; timeTypeEl = "none"; timeFormatEl = "none"; timeRefreshEl = "none"; timeIncrementEl = "none"; shapeEl = "none"; + timeEl = "none"; timeTypeEl = "none"; timeStartPropEl = "none"; timeEndPropEl = "none"; timeFormatEl = "none"; timeCompositeTileEl = "none"; timeRefreshEl = "none"; timeIncrementEl = "none"; shapeEl = "none"; queryEndpointEl = "block"; queryTypeEl = "block"; break; case "vector": @@ -954,7 +1060,7 @@ function makeLayerBarAndModal(d, level, options) { maxnzEl = "none"; maxzEl = "block"; strcolEl = "block"; filcolEl = "block"; weightEl = "block"; opacityEl = "block"; radiusEl = "block"; variableEl = "block"; xmlEl = "none"; bbEl = "none"; vtLayerEl = "none"; vtIdEl = "none"; vtKeyEl = "none"; vtLayerSetStylesEl = "none"; - timeEl = "block"; timeTypeEl = "block"; timeFormatEl = "block"; timeRefreshEl = "none"; timeIncrementEl = "none"; shapeEl = "block"; + timeEl = "block"; timeTypeEl = "block"; timeStartPropEl = "block"; timeEndPropEl = "block"; timeFormatEl = "block"; timeCompositeTileEl = "none"; timeRefreshEl = "none"; timeIncrementEl = "none"; shapeEl = "block"; break; case "model": nameEl = "block"; kindEl = "none"; typeEl = "block"; urlEl = "block"; demtileurlEl = "none"; demparserEl = "none"; controlledEl = "none"; @@ -966,7 +1072,7 @@ function makeLayerBarAndModal(d, level, options) { maxnzEl = "none"; maxzEl = "none"; strcolEl = "none"; filcolEl = "none"; weightEl = "none"; opacityEl = "none"; radiusEl = "none"; variableEl = "none"; xmlEl = "none"; bbEl = "none"; vtLayerEl = "none"; vtIdEl = "none"; vtKeyEl = "none"; vtLayerSetStylesEl = "none"; - timeEl = "block"; timeTypeEl = "block"; timeFormatEl = "block"; timeRefreshEl = "none"; timeIncrementEl = "none"; shapeEl = "none"; + timeEl = "block"; timeTypeEl = "block"; timeStartPropEl = "none"; timeEndPropEl = "none"; timeFormatEl = "block"; timeCompositeTileEl = "none"; timeRefreshEl = "none"; timeIncrementEl = "none"; shapeEl = "none"; queryEndpointEl = "none"; queryTypeEl = "none"; break; default: @@ -1097,20 +1203,36 @@ function makeLayerBarAndModal(d, level, options) { timeFalseSel = "selected"; } - var timeGlobalSel = "", - timeIndividualSel = ""; + var timeRequerySel = "", + timeLocalSel = ""; if (typeof d.time != "undefined") { switch (d.time.type) { - case "global": - timeGlobalSel = "selected"; + case "requery": + timeRequerySel = "selected"; break; - case "individual": - timeIndividualSel = "selected"; + case "local": + timeLocalSel = "selected"; + break; + default: + } + } else { + timeRequerySel = "selected"; + } + + var timeCompositeTileTrueSel = "", + timeCompositeTileFalseSel = ""; + if (typeof d.time != "undefined") { + switch (d.time.compositeTile) { + case true: + case "true": + timeCompositeTileTrueSel = "selected"; break; default: + timeCompositeTileFalseSel = "selected"; + break; } } else { - timeGlobalSel = "selected"; + timeCompositeTileFalseSel = "selected"; } var togwheadTrueSel = "", @@ -1219,23 +1341,26 @@ function makeLayerBarAndModal(d, level, options) { "<div class='modal-content' style='padding-bottom: 0; margin-bottom: " + ((d.type === 'header') ? '260px' : '0') + ";'>" + "<div class='modal-title'>" + "<h4 id='modal_name'>" + d.name + "</h4>" + + "<div style='display: flex;'>" + + "<div class='layerHelp'><a href='https://nasa-ammos.github.io/MMGIS/configure/layers' target='__blank' rel='noopener'><i class='mdi mdi-help mdi-24px' title='Layer Configuration Docs'></i></a></div>" + "<div class='clone'><i class='mdi mdi-content-duplicate mdi-24px' title='Clone Layer'></i></div>" + + "</div>" + "</div>" + "<p>" + "<div class='row' style='margin-bottom: 0px;'>" + - "<div id='nameEl' class='input-field col s" + (kindEl == 'none' ? 8 : 6) + " push-s1' style='display: " + nameEl + "'>" + + "<div id='nameEl' class='input-field col s" + (kindEl == 'none' ? 8 : 6) + " push-s0' style='display: " + nameEl + "'>" + "<input id='Name" + n + "' type='text' class='validate' value='" + unescape(d.name) + "'>" + "<label for='Name" + n + "'>Layer Name</label>" + "</div>" + - "<div id='kindEl' class='input-field col s2 push-s1' style='display: " + kindEl + "'>" + + "<div id='kindEl' class='input-field col s2 push-s0' style='display: " + kindEl + "'>" + "<select>" + "<option value='none' " + (d.kind == 'none' || d.kind == null ? 'selected' : '') + ">None</option>" + kindsOptions.join('') + "</select>" + "<label>Kind of Layer</label>" + "</div>" + - "<div id='typeEl' class='input-field col s2 push-s1' style='display: " + typeEl + "'>" + + "<div id='typeEl' class='input-field col s2 push-s0' style='display: " + typeEl + "'>" + "<select>" + "<optgroup label='Pseudo Layers'>" + "<option value='header' " + headerSel + ">Header</option>" + @@ -1251,14 +1376,21 @@ function makeLayerBarAndModal(d, level, options) { "</select>" + "<label>Layer Type</label>" + "</div>" + + "<div id='visEl' class='input-field col s2 push-s0' style='display: " + visEl + "'>" + + "<select>" + + "<option value='true' " + visTrueSel + ">True</option>" + + "<option value='false' " + visFalseSel + ">False</option>" + + "</select>" + + "<label>Initial Visibility</label>" + + "</div>" + "</div>" + "<div class='row' style='margin-bottom: 0px;'>" + - "<div id='urlEl' class='input-field col s8 push-s1' style='display: " + urlEl + "'>" + + `<div id='urlEl' class='input-field col s${tileformatEl != 'none' ? 8 : 10} push-s0' style='display: ` + urlEl + "'>" + "<input id='Url" + n + "' type='text' class='validate' value='" + d.url + "'>" + "<label for='Url" + n + "'>URL</label>" + "</div>" + - "<div id='tileformatEl' class='input-field col s2 push-s1' style='display: " + tileformatEl + "'>" + + "<div id='tileformatEl' class='input-field col s2 push-s0' style='display: " + tileformatEl + "'>" + "<select>" + "<option value='tms' " + tileformatTMSSel + ">TMS</option>" + "<option value='wmts' " + tileformatWMTSSel + ">WMTS</option>" + @@ -1266,7 +1398,7 @@ function makeLayerBarAndModal(d, level, options) { "</select>" + "<label style='cursor: default;' title='TMS and WMTS: Append \"/{z}/{x}/{y}.png\" to URL\n\nWMS: After service, append \"?layer=<your_layer_name><,another_if_you _want>\" to the URL\nTo override WMS parameters append \"&<wms_param>=<value>\" again to the URL after the layers list.\n\nAll brackets included, quotes are not and <> require custom input.'>Tile Format <i class='mdi mdi-information mdi-14px'></i></label>" + "</div>" + - "<div id='controlledEl' class='input-field col s3 push-s1' style='display: " + controlledEl + "'>" + + "<div id='controlledEl' class='input-field col s2 push-s0' style='display: " + controlledEl + "'>" + "<input id='Controlled" + n + "' type='checkbox' class='filled-in checkbox-color'" + (d.controlled ? 'checked' : '') + "/>" + "<label for='Controlled" + n + "' style='color: black;'>" + "Controlled" + "</label>" + "</div>" + @@ -1274,11 +1406,11 @@ function makeLayerBarAndModal(d, level, options) { // Query Core "<div class='row' style='margin-bottom: 0px;'>" + - "<div id='queryEndpointEl' class='input-field col s8 push-s1' style='display: " + queryEndpointEl + "'>" + + "<div id='queryEndpointEl' class='input-field col s10 push-s0' style='display: " + queryEndpointEl + "'>" + "<input id='QueryEndpoint" + n + "' type='text' class='validate' value='" + (d.query != null ? unescape(d.query.endpoint) : '') + "'>" + "<label for='QueryEndpoint" + n + "'>Endpoint</label>" + "</div>" + - "<div id='queryTypeEl' class='input-field col s2 push-s1' style='display: " + queryTypeEl + "'>" + + "<div id='queryTypeEl' class='input-field col s2 push-s0' style='display: " + queryTypeEl + "'>" + "<select>" + "<option value='elasticsearch' " + queryTypeESSel + ">ElasticSearch</option>" + "</select>" + @@ -1288,48 +1420,48 @@ function makeLayerBarAndModal(d, level, options) { //Model Position "<div class='row' style='margin-bottom: 0px;'>" + - "<div id='modelLonEl' class='input-field col s3 push-s1' style='display: " + modelLonEl + "'>" + + "<div id='modelLonEl' class='input-field col s4 push-s0' style='display: " + modelLonEl + "'>" + "<input id='Longitude" + n + "' type='text' class='validate' value='" + d.position.longitude + "'>" + "<label for='Longitude" + n + "'>Longitude</label>" + "</div>" + - "<div id='modelLatEl' class='input-field col s3 push-s1' style='display: " + modelLatEl + "'>" + + "<div id='modelLatEl' class='input-field col s4 push-s0' style='display: " + modelLatEl + "'>" + "<input id='Latitude" + n + "' type='text' class='validate' value='" + d.position.latitude + "'>" + "<label for='Latitude" + n + "'>Latitude</label>" + "</div>" + - "<div id='modelElevEl' class='input-field col s4 push-s1' style='display: " + modelElevEl + "'>" + + "<div id='modelElevEl' class='input-field col s4 push-s0' style='display: " + modelElevEl + "'>" + "<input id='Elevation" + n + "' type='text' class='validate' value='" + d.position.elevation + "'>" + "<label for='Elevation" + n + "'>Elevation (meters)</label>" + "</div>" + "</div>" + //Model Rotation "<div class='row' style='margin-bottom: 0px;'>" + - "<div id='modelRotXEl' class='input-field col s4 push-s1' style='display: " + modelRotXEl + "'>" + + "<div id='modelRotXEl' class='input-field col s4 push-s0' style='display: " + modelRotXEl + "'>" + "<input id='RotationX" + n + "' type='text' class='validate' value='" + d.rotation.x + "'>" + "<label for='RotationX" + n + "'>Rotation X (radians)</label>" + "</div>" + - "<div id='modelRotYEl' class='input-field col s3 push-s1' style='display: " + modelRotYEl + "'>" + + "<div id='modelRotYEl' class='input-field col s4 push-s0' style='display: " + modelRotYEl + "'>" + "<input id='RotationY" + n + "' type='text' class='validate' value='" + d.rotation.y + "'>" + "<label for='RotationY" + n + "'>Rotation Y</label>" + "</div>" + - "<div id='modelRotZEl' class='input-field col s3 push-s1' style='display: " + modelRotZEl + "'>" + + "<div id='modelRotZEl' class='input-field col s4 push-s0' style='display: " + modelRotZEl + "'>" + "<input id='RotationZ" + n + "' type='text' class='validate' value='" + d.rotation.z + "'>" + "<label for='RotationZ" + n + "'>Rotation Z</label>" + "</div>" + "</div>" + //Model Scale "<div class='row' style='margin-bottom: 0px;'>" + - "<div id='modelScaleEl' class='input-field col s3 push-s1' style='display: " + modelScaleEl + "'>" + + "<div id='modelScaleEl' class='input-field col s4 push-s0' style='display: " + modelScaleEl + "'>" + "<input id='Scale" + n + "' type='text' class='validate' value='" + d.scale + "'>" + "<label for='Scale" + n + "'>Scale</label>" + "</div>" + "</div>" + "<div class='row' style='margin-bottom: 0px;'>" + - "<div id='demtileurlEl' class='input-field col s8 push-s1' style='display: " + demtileurlEl + "'>" + + "<div id='demtileurlEl' class='input-field col s10 push-s0' style='display: " + demtileurlEl + "'>" + "<input id='DemTileUrl" + n + "' type='text' class='validate' value='" + d.demtileurl + "'>" + "<label for='DemTileUrl" + n + "'>DEM Tile URL</label>" + "</div>" + - "<div id='demparserEl' class='input-field col s2 push-s1' style='display: " + demparserEl + "'>" + + "<div id='demparserEl' class='input-field col s2 push-s0' style='display: " + demparserEl + "'>" + "<select>" + "<option value='' " + demparserRGBASel + ">RGBA</option>" + "<option value='tif' " + demparserTifSel + ">Tif</option>" + @@ -1339,59 +1471,52 @@ function makeLayerBarAndModal(d, level, options) { "</div>" + "<div class='row' style='margin-bottom: 12px;'>" + - "<div id='descriptionEl' class='input-field col s10 push-s1' style='display: " + descriptionEl + "'>" + + "<div id='descriptionEl' class='input-field col s12 push-s0' style='display: " + descriptionEl + "'>" + "<span>Description: (markdown)</span>" + "<textarea id='LayerDescription" + n + "'></textarea>" + "</div>" + "</div>" + "<div class='row' style='margin-bottom: 0px;'>" + - "<div id='tagsEl' class='input-field col s9 push-s1' style='display: " + tagsEl + "'>" + + "<div id='tagsEl' class='input-field col s11 push-s0' style='display: " + tagsEl + "'>" + "<input id='LayerTags" + n + "' type='text' class='validate' value='" + (d.tags ? d.tags.join(',') : '') + "'>" + "<label for='LayerTags" + n + "'>Tags (comma-separated, <cat>:<tag> for category)</label>" + "</div>" + - `<div class='col s1 push-s1' style='display: ${tagsEl}; text-align: center; margin-top: 39px; color: #333; background: #ddd; cursor: pointer;' onclick='alert("Existing Tags:\\n\\n${options?.tagList ? Object.keys(options.tagList).map((t) => `${t} (${options.tagList[t]})`).join('\\n') : ''}");'>Existing Tags<i class='mdi mdi-tags mdi-18px'></i></div>` + + `<div class='col s1 push-s0' style='display: ${tagsEl}; text-align: center; margin-top: 39px; color: #333; background: #ddd; cursor: pointer;' onclick='alert("Existing Tags:\\n\\n${options?.tagList ? Object.keys(options.tagList).map((t) => `${t} (${options.tagList[t]})`).join('\\n') : ''}");'>Existing Tags<i class='mdi mdi-tags mdi-18px'></i></div>` + "</div>" + "<div class='row' style='margin-bottom: 0px;'>" + - "<div id='legendEl' class='input-field col s10 push-s1' style='display: " + legendEl + "'>" + + "<div id='legendEl' class='input-field col s12 push-s0' style='display: " + legendEl + "'>" + "<input id='Legend" + n + "' type='text' class='validate' value='" + d.legend + "'>" + "<label for='Legend" + n + "'>Legend URL</label>" + "</div>" + "</div>" + "<div class='row' style='margin-bottom: 0px;'>" + - "<div id='togwheadEl' class='input-field col s2 push-s1' style='display: " + /*togwheadEl*/ 'none' + "'>" + + "<div id='togwheadEl' class='input-field col s2 push-s0' style='display: " + /*togwheadEl*/ 'none' + "'>" + "<select>" + "<option value='true' " + togwheadTrueSel + ">True</option>" + "<option value='false' " + togwheadFalseSel + ">False</option>" + "</select>" + "<label>Toggles with Header</label>" + "</div>" + - "<div id='minzEl' class='input-field col s2 push-s1' style='display: " + minzEl + "'>" + + "<div id='minzEl' class='input-field col s2 push-s0' style='display: " + minzEl + "'>" + "<input id='Minz" + n + "' type='text' class='validate' value='" + d.minZoom + "'>" + "<label for='Minz" + n + "'>Minimum Zoom</label>" + "</div>" + - "<div id='maxnzEl' class='input-field col s2 push-s1' style='display: " + maxnzEl + "'>" + + "<div id='maxnzEl' class='input-field col s2 push-s0' style='display: " + maxnzEl + "'>" + "<input id='Maxnz" + n + "' type='text' class='validate' value='" + d.maxNativeZoom + "'>" + "<label for='Maxnz" + n + "'>Maximum Native Zoom</label>" + "</div>" + - "<div id='maxzEl' class='input-field col s2 push-s1' style='display: " + maxzEl + "'>" + + "<div id='maxzEl' class='input-field col s2 push-s0' style='display: " + maxzEl + "'>" + "<input id='Maxz" + n + "' type='text' class='validate' value='" + d.maxZoom + "'>" + "<label for='Maxz" + n + "'>Maximum Zoom</label>" + "</div>" + - "<div id='visEl' class='input-field col s2 push-s1' style='display: " + visEl + "'>" + - "<select>" + - "<option value='true' " + visTrueSel + ">True</option>" + - "<option value='false' " + visFalseSel + ">False</option>" + - "</select>" + - "<label>Initial Visibility</label>" + - "</div>" + - "<div id='initOpacEl' class='input-field col s2 push-s1' style='display: " + initOpacEl + "'>" + + "<div id='initOpacEl' class='input-field col s2 push-s0' style='display: " + initOpacEl + "'>" + "<input id='InitialOpacity" + n + "' type='text' class='validate' value='" + ( d.initialOpacity == null ? 1 : d.initialOpacity ) + "'>" + "<label for='InitialOpacity" + n + "'>Initial Opacity [0 - 1]</label>" + "</div>" + - "<div id='layer3dEl' class='input-field col s2 push-s1' style='display: " + layer3dEl + "'>" + + "<div id='layer3dEl' class='input-field col s2 push-s0' style='display: " + layer3dEl + "'>" + "<select>" + "<option value='clamped' " + layer3dClampedSel + ">Clamped</option>" + "<option value='vector' " + layer3dVectorSel + ">Vector</option>" + @@ -1401,7 +1526,7 @@ function makeLayerBarAndModal(d, level, options) { "</div>" + "<div class='row' style='margin-bottom: 0px;'>" + - "<div id='bbEl' class='input-field col s10 push-s1' style='display: " + bbEl + "'>" + + "<div id='bbEl' class='input-field col s12 push-s0' style='display: " + bbEl + "'>" + "<input id='bb" + n + "' type='text' class='validate' value='" + d.boundingBox + "'>" + "<label for='bb" + n + "'>Bounding Box [minx, miny, maxx, maxy]</label>" + "</div>" + @@ -1409,29 +1534,44 @@ function makeLayerBarAndModal(d, level, options) { // Time options "<div class='row' style='margin-bottom: 0px;'>" + - "<div id='timeEl' class='input-field col s2 push-s1' style='display: " + timeEl + "'>" + + "<div id='timeEl' class='input-field col s2 push-s0' style='display: " + timeEl + "'>" + "<select>" + "<option value='true' " + timeTrueSel + ">True</option>" + "<option value='false' " + timeFalseSel + ">False</option>" + "</select>" + "<label>Time Enabled</label>" + "</div>" + - "<div id='timeTypeEl' class='input-field col s2 push-s1' style='display: " + timeTypeEl + "'>" + + "<div id='timeTypeEl' class='input-field col s2 push-s0' style='display: " + timeTypeEl + "'>" + "<select>" + - "<option value='global' " + timeGlobalSel + ">Global</option>" + - "<option value='individual' " + timeIndividualSel + ">Individual</option>" + + "<option value='requery' " + timeRequerySel + ">Requery</option>" + + "<option value='local' " + timeLocalSel + ">Local</option>" + "</select>" + - "<label>Time Type</label>" + + "<label style='cursor: default;' title='Requery: Will rerequest the entire layer with updated {time-like} parameters.\nLocal: Just filter the existing features based on the specified time properties.'>Time Type <i class='mdi mdi-information mdi-14px'></i></label>" + + "</div>" + + "<div id='timeStartPropEl' class='input-field col s3 push-s0' style='display: " + timeStartPropEl + "'>" + + "<input id='TimeStartProp" + n + "' type='text' class='validate' value='" + ((typeof d.time != "undefined") ? d.time.startProp || "" : "") + "'>" + + "<label for='TimeStartProp" + n + "'>Start Time Property Name</label>" + "</div>" + - "<div id='timeFormatEl' class='input-field col s5 push-s1' style='display: " + timeFormatEl + "'>" + + "<div id='timeEndPropEl' class='input-field col s3 push-s0' style='display: " + timeEndPropEl + "'>" + + "<input id='TimeEndProp" + n + "' type='text' class='validate' value='" + ((typeof d.time != "undefined") ? d.time.endProp || "" : "") + "'>" + + "<label for='TimeEndProp" + n + "'>Main Time Property Name (End)</label>" + + "</div>" + + "<div id='timeFormatEl' class='input-field col s2 push-s0' style='display: " + timeFormatEl + "'>" + "<input id='TimeFormat" + n + "' type='text' class='validate' value='" + ((typeof d.time != "undefined") ? d.time.format : "%Y-%m-%dT%H:%M:%SZ") + "'>" + "<label for='TimeFormat" + n + "'>Time Format</label>" + "</div>" + - "<div id='timeRefreshEl' class='input-field col s2 push-s1' style='display: " + timeRefreshEl + "'>" + + "<div id='timeCompositeTileEl' class='input-field col s2 push-s0' style='display: " + timeCompositeTileEl + "'>" + + "<select>" + + "<option value='true' " + timeCompositeTileTrueSel + ">True</option>" + + "<option value='false' " + timeCompositeTileFalseSel + ">False</option>" + + "</select>" + + "<label style='cursor: default;' title='True: MMGIS-served TMS Time Tiles will be merged/collapsed together historically before being served.\nFalse: MMGIS-served Time Tiles just pull the single, latest, best-matched tile.'>Composited Time Tile <i class='mdi mdi-information mdi-14px'></i></label>" + + "</div>" + + "<div id='timeRefreshEl' class='input-field col s2 push-s0' style='display: " + timeRefreshEl + "'>" + "<input id='TimeRefresh" + n + "' type='text' class='validate' value='" + ((typeof d.time != "undefined") ? d.time.refresh : "") + "'>" + "<label for='TimeRefresh" + n + "'>Time Refresh</label>" + "</div>" + - "<div id='timeIncrementEl' class='input-field col s2 push-s1' style='display: " + timeIncrementEl + "'>" + + "<div id='timeIncrementEl' class='input-field col s2 push-s0' style='display: " + timeIncrementEl + "'>" + "<input id='TimeIncrement" + n + "' type='text' class='validate' value='" + ((typeof d.time != "undefined") ? d.time.increment : "") + "'>" + "<label for='TimeIncrement" + n + "'>Time Increment</label>" + "</div>" + @@ -1439,18 +1579,18 @@ function makeLayerBarAndModal(d, level, options) { //Vector tile options "<div class='row' style='margin-bottom: 0px;'>" + - "<div id='vtIdEl' class='input-field col s5 push-s1' style='display: " + vtIdEl + "'>" + + "<div id='vtIdEl' class='input-field col s6 push-s0' style='display: " + vtIdEl + "'>" + "<input id='vtId" + n + "' type='text' class='validate' value='" + dStyle.vtId + "'>" + "<label for='vtId" + n + "'>Vector Tile Feature Unique Id Key</label>" + "</div>" + - "<div id='vtKeyEl' class='input-field col s5 push-s1' style='display: " + vtKeyEl + "'>" + + "<div id='vtKeyEl' class='input-field col s6 push-s0' style='display: " + vtKeyEl + "'>" + "<input id='vtKey" + n + "' type='text' class='validate' value='" + dStyle.vtKey + "'>" + "<label for='vtKey" + n + "'>Use Key as Name</label>" + "</div>" + "</div>" + "<div class='row' style='margin-bottom: 0px;'>" + - "<div id='vtLayerEl' class='input-field col s10 push-s1' style='display: " + vtLayerEl + "'>" + + "<div id='vtLayerEl' class='input-field col s12 push-s0' style='display: " + vtLayerEl + "'>" + "<span>Vector Tile Stylings:</span>" + "<textarea id='t" + n + "_var'></textarea>" + "</div>" + @@ -1458,30 +1598,30 @@ function makeLayerBarAndModal(d, level, options) { //Style "<div class='row' style='margin-bottom: 0px;'>" + - "<div id='strcolEl' class='input-field col s2 push-s1' style='display: " + strcolEl + "'>" + + "<div id='strcolEl' class='input-field col s3 push-s0' style='display: " + strcolEl + "'>" + "<input id='Strcol" + n + "' type='text' class='validate' value='" + dStyle.color + "'>" + "<label for='Strcol" + n + "'>Stroke Color</label>" + "</div>" + - "<div id='filcolEl' class='input-field col s2 push-s1' style='display: " + filcolEl + "'>" + + "<div id='filcolEl' class='input-field col s3 push-s0' style='display: " + filcolEl + "'>" + "<input id='Filcol" + n + "' type='text' class='validate' value='" + dStyle.fillColor + "'>" + "<label for='Filcol" + n + "'>Fill Color</label>" + "</div>" + - "<div id='weightEl' class='input-field col s2 push-s1' style='display: " + weightEl + "'>" + + "<div id='weightEl' class='input-field col s2 push-s0' style='display: " + weightEl + "'>" + "<input id='Weight" + n + "' type='text' class='validate' value='" + dStyle.weight + "'>" + "<label for='Weight" + n + "'>Stroke Weight</label>" + "</div>" + - "<div id='opacityEl' class='input-field col s2 push-s1' style='display: " + opacityEl + "'>" + + "<div id='opacityEl' class='input-field col s2 push-s0' style='display: " + opacityEl + "'>" + "<input id='Opacity" + n + "' type='text' class='validate' value='" + dStyle.fillOpacity + "'>" + "<label for='Opacity" + n + "'>Fill Opacity</label>" + "</div>" + - "<div id='radiusEl' class='input-field col s2 push-s1' style='display: " + radiusEl + "'>" + + "<div id='radiusEl' class='input-field col s2 push-s0' style='display: " + radiusEl + "'>" + "<input id='Radius" + n + "' type='text' class='validate' value='" + ( d.radius || "" ) + "'>" + "<label for='Radius" + n + "'>Radius</label>" + "</div>" + "</div>" + "<div class='row' style='margin-bottom: 0px;'>" + - "<div id='shapeEl' class='input-field col s2 push-s1' style='display: " + shapeEl + "'>" + + "<div id='shapeEl' class='input-field col s3 push-s0' style='display: " + shapeEl + "'>" + "<select>" + "<option value='none' " + shapNoneSel + ">Default</option>" + "<option value='circle' " + shapCircleSel + ">Circle</option>" + @@ -1499,13 +1639,14 @@ function makeLayerBarAndModal(d, level, options) { "</div>" + "<div class='row' style='margin-bottom: 0px;'>" + - "<div id='variableEl' class='input-field col s10 push-s1' style='display: " + variableEl + "'>" + + "<div id='variableEl' class='input-field col s12 push-s0' style='display: " + variableEl + "'>" + "<span>Raw Variables:</span>" + "<textarea id='Variable" + n + "'></textarea>" + "</div>" + "</div>" + "</p>" + + `<div id='modal_uuid' value='${d.uuid}'>Layer UUID: ` + d.uuid + "</div>" + "</div>" + "<div class='modal-footer' style='background-color: " + barColor + "; display: flex; justify-content: space-between;'>" + @@ -1645,7 +1786,7 @@ function mmgisLinkModalsToLayersTypeChange(e) { maxnzEl = "block", maxzEl = "block", strcolEl = "block", filcolEl = "block", weightEl = "block", opacityEl = "block", radiusEl = "block", variableEl = "block", vtLayerEl = "none", vtIdEl = "none", vtKeyEl = "none", vtLayerSetStylesEl = "none", - timeEl = 'block', timeTypeEl = 'block', timeFormatEl = 'block', timeRefreshEl = 'none', timeIncrementEl = 'none', + timeEl = 'block', timeTypeEl = 'block', timeStartPropEl = 'block', timeEndPropEl = 'block', timeFormatEl = 'block', timeCompositeTileEl = 'block', timeRefreshEl = 'none', timeIncrementEl = 'none', shapeEl = 'block', queryEndpointEl = "none", queryTypeEl = "none"; //Kind of a repeat of above =\ @@ -1660,11 +1801,11 @@ function mmgisLinkModalsToLayersTypeChange(e) { maxzEl = "none"; strcolEl = "none"; filcolEl = "none"; weightEl = "none"; opacityEl = "none"; radiusEl = "none"; variableEl = "none"; xmlEl = "none"; bbEl = "none"; vtLayerEl = "none"; vtIdEl = "none"; vtKeyEl = "none"; vtLayerSetStylesEl = "none"; - timeEl = 'none'; timeTypeEl = 'none'; timeFormatEl = 'none'; timeRefreshEl = 'none'; timeIncrementEl = 'none'; + timeEl = 'none'; timeTypeEl = 'none'; timeStartPropEl = 'none'; timeEndPropEl = 'none'; timeFormatEl = 'none'; timeCompositeTileEl = 'none'; timeRefreshEl = 'none'; timeIncrementEl = 'none'; shapeEl = 'none'; queryEndpointEl = "none"; queryTypeEl = "none"; break; case "tile": barColor = "rgb(119, 15, 189)"; - nameEl = "block"; kindEl = "none"; typeEl = "block"; urlEl = "block"; demtileurlEl = "block"; demparserEl = "block"; controlledEl = "none"; + nameEl = "block"; kindEl = "none"; typeEl = "block"; urlEl = "block"; demtileurlEl = "block"; demparserEl = "block"; controlledEl = "block"; descriptionEl = "block"; tagsEl = "block"; legendEl = "block"; tileformatEl = "block"; visEl = "block"; viscutEl = "none"; initOpacEl = "block"; togwheadEl = "block"; minzEl = "block"; maxnzEl = "block"; layer3dEl = "none"; modelLonEl = "none"; modelLatEl = "none"; modelElevEl = "none"; @@ -1672,7 +1813,7 @@ function mmgisLinkModalsToLayersTypeChange(e) { maxzEl = "block"; strcolEl = "none"; filcolEl = "none"; weightEl = "none"; opacityEl = "none"; radiusEl = "none"; variableEl = "none"; xmlEl = "block"; bbEl = "block"; vtLayerEl = "none"; vtIdEl = "none"; vtKeyEl = "none"; vtLayerSetStylesEl = "none"; - timeEl = 'block'; timeTypeEl = 'block'; timeFormatEl = 'block'; timeRefreshEl = 'none'; timeIncrementEl = 'none'; + timeEl = 'block'; timeTypeEl = 'block'; timeStartPropEl = 'none'; timeEndPropEl = 'none'; timeFormatEl = 'block'; timeCompositeTileEl = 'block'; timeRefreshEl = 'none'; timeIncrementEl = 'none'; shapeEl = 'none'; queryEndpointEl = "none"; queryTypeEl = "none"; break; case "vectortile": barColor = "#bd0f8e"; @@ -1684,7 +1825,7 @@ function mmgisLinkModalsToLayersTypeChange(e) { maxzEl = "block"; strcolEl = "none"; filcolEl = "none"; weightEl = "none"; opacityEl = "none"; radiusEl = "none"; variableEl = "block"; xmlEl = "none"; bbEl = "none"; vtLayerEl = "block"; vtIdEl = "block"; vtKeyEl = "block"; vtLayerSetStylesEl = "block"; - timeEl = 'block'; timeTypeEl = 'block'; timeFormatEl = 'block'; timeRefreshEl = 'none'; timeIncrementEl = 'none'; + timeEl = 'block'; timeTypeEl = 'block'; timeStartPropEl = 'none'; timeEndPropEl = 'none'; timeFormatEl = 'block'; timeCompositeTileEl = 'none'; timeRefreshEl = 'none'; timeIncrementEl = 'none'; shapeEl = 'block'; queryEndpointEl = "none"; queryTypeEl = "none"; break; case "data": barColor = "rgb(189, 15, 50)"; @@ -1696,7 +1837,7 @@ function mmgisLinkModalsToLayersTypeChange(e) { maxzEl = "block"; strcolEl = "none"; filcolEl = "none"; weightEl = "none"; opacityEl = "none"; radiusEl = "none"; variableEl = "block"; xmlEl = "block"; bbEl = "block"; vtLayerEl = "none"; vtIdEl = "none"; vtKeyEl = "none"; vtLayerSetStylesEl = "none"; - timeEl = 'block'; timeTypeEl = 'block'; timeFormatEl = 'block'; timeRefreshEl = 'none'; timeIncrementEl = 'none'; + timeEl = 'block'; timeTypeEl = 'block'; timeStartPropEl = 'none'; timeEndPropEl = 'none'; timeFormatEl = 'block'; timeCompositeTileEl = 'none'; timeRefreshEl = 'none'; timeIncrementEl = 'none'; shapeEl = 'none'; queryEndpointEl = "none"; queryTypeEl = "none"; break; case "query": barColor = "#0fbd4d"; @@ -1708,7 +1849,7 @@ function mmgisLinkModalsToLayersTypeChange(e) { maxzEl = "none"; strcolEl = "block"; filcolEl = "block"; weightEl = "block"; opacityEl = "block"; radiusEl = "block"; variableEl = "block"; xmlEl = "none"; bbEl = "none"; vtLayerEl = "none"; vtIdEl = "none"; vtKeyEl = "none"; vtLayerSetStylesEl = "none"; - timeEl = 'none'; timeTypeEl = 'none'; timeFormatEl = 'none'; timeRefreshEl = 'none'; timeIncrementEl = 'none'; + timeEl = 'none'; timeTypeEl = 'none'; timeStartPropEl = 'none'; timeEndPropEl = 'none'; timeFormatEl = 'none'; timeCompositeTileEl = 'none'; timeRefreshEl = 'none'; timeIncrementEl = 'none'; shapeEl = 'none'; queryEndpointEl = "block"; queryTypeEl = "block"; break; case "vector": barColor = "rgb(15, 119, 189)"; @@ -1720,7 +1861,7 @@ function mmgisLinkModalsToLayersTypeChange(e) { maxzEl = "block"; strcolEl = "block"; filcolEl = "block"; weightEl = "block"; opacityEl = "block"; radiusEl = "block"; variableEl = "block"; xmlEl = "none"; bbEl = "none"; vtLayerEl = "none"; vtIdEl = "none"; vtKeyEl = "none"; vtLayerSetStylesEl = "none"; - timeEl = 'block'; timeTypeEl = 'block'; timeFormatEl = 'block'; timeRefreshEl = 'none'; timeIncrementEl = 'none'; + timeEl = 'block'; timeTypeEl = 'block'; timeStartPropEl = 'block'; timeEndPropEl = 'block'; timeFormatEl = 'block'; timeCompositeTileEl = 'none'; timeRefreshEl = 'none'; timeIncrementEl = 'none'; shapeEl = 'block'; queryEndpointEl = "none"; queryTypeEl = "none"; break; case "model": barColor = "rgb(189, 189, 15)"; @@ -1732,7 +1873,7 @@ function mmgisLinkModalsToLayersTypeChange(e) { maxzEl = "none"; strcolEl = "none"; filcolEl = "none"; weightEl = "none"; opacityEl = "none"; radiusEl = "none"; variableEl = "none"; xmlEl = "none"; bbEl = "none"; vtLayerEl = "none"; vtIdEl = "none"; vtKeyEl = "none"; vtLayerSetStylesEl = "none"; - timeEl = 'block'; timeTypeEl = 'block'; timeFormatEl = 'block'; timeRefreshEl = 'none'; timeIncrementEl = 'none'; + timeEl = 'block'; timeTypeEl = 'block'; timeStartPropEl = 'none'; timeEndPropEl = 'none'; timeFormatEl = 'block'; timeCompositeTileEl = 'none'; timeRefreshEl = 'none'; timeIncrementEl = 'none'; shapeEl = 'none'; queryEndpointEl = "none"; queryTypeEl = "none"; break; default: @@ -1787,7 +1928,10 @@ function mmgisLinkModalsToLayersTypeChange(e) { mainThis.find("#vtLayerSetStylesEl").css("display", vtLayerSetStylesEl); mainThis.find("#timeEl").css("display", timeEl); mainThis.find("#timeTypeEl").css("display", timeTypeEl); + mainThis.find("#timeStartPropEl").css("display", timeStartPropEl); + mainThis.find("#timeEndPropEl").css("display", timeEndPropEl); mainThis.find("#timeFormatEl").css("display", timeFormatEl); + mainThis.find("#timeCompositeTileEl").css("display", timeCompositeTileEl); mainThis.find("#timeRefreshEl").css("display", timeRefreshEl); mainThis.find("#timeIncrementEl").css("display", timeIncrementEl); mainThis.find("#shapeEl").css("display", shapeEl); @@ -1818,13 +1962,12 @@ function mmgisLinkModalsToLayersDeleteClick(e) { } function mmgisLinkModalsToLayersCloneClick(e) { - var mainThis = $(this).parent().parent().parent(); + var mainThis = $(this).parent().parent().parent().parent(); var mainId = mainThis.attr("id"); mainId = mainId.substring(mainId.indexOf("_") + 1); - makeLayerBarAndModal( - dataOfLastUsedLayerSlot[mainId], - dataOfLastUsedLayerSlot[mainId].__level - ); + const cloned = JSON.parse(JSON.stringify(dataOfLastUsedLayerSlot[mainId])); + delete cloned.uuid; + makeLayerBarAndModal(cloned, cloned.__level); refresh(); } @@ -1852,7 +1995,7 @@ function materializeDraggableMouseUp(e) { //Save Changes //Reconstructs JSON from html (doesn't modify the initial json directly) -function save() { +function save(returnJSON) { if (missionPath.length > 0) { var json = { msv: {}, @@ -1983,12 +2126,23 @@ function save() { ).val(); json.coordinates["coordmain"] = $(`.coordinates_coordMain:checked`).val() || "ll"; + json.coordinates["variables"] = JSON.parse( + tabEditors["coordinatesVariables"].getValue() || "{}" + ); //Look json.look["pagename"] = $("#tab_look #look_pagename").val(); json.look["minimalist"] = $("#tab_look #look_minimalist").prop("checked"); + json.look["topbar"] = $("#tab_look #look_topbar").prop("checked"); + json.look["toolbar"] = $("#tab_look #look_toolbar").prop("checked"); + json.look["scalebar"] = $("#tab_look #look_scalebar").prop("checked"); + json.look["coordinates"] = $("#tab_look #look_coordinates").prop("checked"); json.look["zoomcontrol"] = $("#tab_look #look_zoomcontrol").prop("checked"); json.look["graticule"] = $("#tab_look #look_graticule").prop("checked"); + json.look["miscellaneous"] = $("#tab_look #look_miscellaneous").prop( + "checked" + ); + json.look["settings"] = $("#tab_look #look_settings").prop("checked"); //look colors json.look["primarycolor"] = $("#tab_look #look_primarycolor").val(); json.look["secondarycolor"] = $("#tab_look #look_secondarycolor").val(); @@ -2003,6 +2157,8 @@ function save() { json.look["copylink"] = $("#tab_look #look_copylink").prop("checked"); json.look["screenshot"] = $("#tab_look #look_screenshot").prop("checked"); json.look["fullscreen"] = $("#tab_look #look_fullscreen").prop("checked"); + json.look["info"] = $("#tab_look #look_info").prop("checked"); + json.look["infourl"] = $("#tab_look #look_infourl").val(); json.look["help"] = $("#tab_look #look_help").prop("checked"); json.look["logourl"] = $("#tab_look #look_logourl").val(); json.look["helpurl"] = $("#tab_look #look_helpurl").val(); @@ -2036,11 +2192,29 @@ function save() { } else { json.time.visible = false; } + if ($("#tab_time #time_initiallyOpen").prop("checked")) { + json.time.initiallyOpen = true; + } else { + json.time.initiallyOpen = false; + } json.time.format = $("#tab_time #time_format").val(); + json.time.initialstart = $("#tab_time #time_initialstart").val(); + json.time.initialend = $("#tab_time #time_initialend").val(); + json.time.initialwindowstart = $( + "#tab_time #time_initialwindowstart" + ).val(); + json.time.initialwindowend = $("#tab_time #time_initialwindowend").val(); + //Tools for (var i = 0; i < tData.length; i++) { if ($("#tab_tools #tools_" + tData[i].name).prop("checked")) { - var toolsjson = { name: "", icon: "", js: "" }; + var toolsjson = { + name: "", + icon: "", + js: "", + }; + if (tData[i].separatedTool === true) toolsjson.separatedTool = true; + toolsjson.name = tData[i].name; toolsjson.icon = $("#t" + tData[i].name + "icon input").val(); toolsjson.js = tData[i].name + "Tool"; @@ -2056,9 +2230,18 @@ function save() { ); return; } - toolsjson["variables"] = JSON.parse( - editors[tData[i].name].getValue() - ); + try { + toolsjson["variables"] = JSON.parse( + editors[tData[i].name].getValue() + ); + } catch (err) { + toast( + "error", + `Error: ${tData[i].name} tool json is badly formed.`, + 5000 + ); + return; + } } } json.tools.push(toolsjson); @@ -2163,7 +2346,12 @@ function save() { .find("#timeTypeEl select option:selected") .text() .toLowerCase(); + var modalTimeStartProp = modal.find("#timeStartPropEl input").val(); + var modalTimeEndProp = modal.find("#timeEndPropEl input").val(); var modalTimeFormat = modal.find("#timeFormatEl input").val(); + var modalTimeCompositeTile = modal + .find("#timeCompositeTileEl select option:selected") + .val(); var modalShape = modal.find("#shapeEl select option:selected").val(); const modalQueryEndpoint = modal.find("#queryEndpointEl input").val(); @@ -2172,6 +2360,10 @@ function save() { .val(); layerObject.name = modalName; + layerObject.uuid = modal.find("#modal_uuid").attr("value"); + if (layerObject.uuid === "" || layerObject.uuid === "undefined") + layerObject.uuid = null; + if ( modalType == "vectortile" || modalType == "vector" || @@ -2306,13 +2498,16 @@ function save() { // time properties layerObject.time = {}; layerObject.time.enabled = modalTime; // static or timed - layerObject.time.type = modalTimeType; // 'global or individual' + layerObject.time.type = modalTimeType; // 'requery or local' layerObject.time.isRelative = true; // absolute or relative layerObject.time.current = new Date().toISOString().split(".")[0] + "Z"; // initial time layerObject.time.start = ""; // initial start layerObject.time.end = ""; // initial end + layerObject.time.startProp = modalTimeStartProp; + layerObject.time.endProp = modalTimeEndProp; layerObject.time.format = modalTimeFormat; // time string format + layerObject.time.compositeTile = modalTimeCompositeTile == "true"; layerObject.time.refresh = "1 hours"; // refresh when the layer becomes stale layerObject.time.increment = "5 minutes"; // time bar steps } @@ -2350,7 +2545,8 @@ function save() { }); //SAVE HERE - saveConfig(json); + if (returnJSON === "returnJSON") return json; + else saveConfig(json); } else { toast("warning", "No Mission selected.", 5000); } @@ -2394,12 +2590,35 @@ function addMission() { } function saveConfig(json) { + if (lockConfig === true) { + if (lockConfigCount != false) { + toast( + "error", + `This configuartion changed while you were working on it. Cannot save without refresh or ${lockConfigCount} more attempt${ + lockConfigCount != 1 ? "s" : "" + } at saving to force it.`, + 5000 + ); + lockConfigCount--; + if (lockConfigCount <= 0) { + clearLockConfig(); + } + } else { + toast( + "error", + `This configuartion changed while you were working on it. Cannot save without refresh.`, + 5000 + ); + } + return; + } $.ajax({ type: calls.upsert.type, url: calls.upsert.url, data: { mission: mission, config: JSON.stringify(json), + id: configId, }, success: function (data) { if (data.status == "success") { @@ -2546,6 +2765,15 @@ function layerPopulateVariable(modalId, layerType) { if (layerEditors[modalId]) { var currentLayerVars = JSON.parse(layerEditors[modalId].getValue() || "{}"); + currentLayerVars.legend = currentLayerVars.legend || [ + { + color: "#999", + strokecolor: "black", + shape: "circle", + value: "Example", + }, + ]; + if (layerType == "data") { currentLayerVars = currentLayerVars.shader ? { shader: currentLayerVars.shader } @@ -2558,7 +2786,8 @@ function layerPopulateVariable(modalId, layerType) { }, }; } else if (layerType == "query") { - currentLayerVars.useKeyAsName = currentLayerVars.useKeyAsName || "prop"; + currentLayerVars.useKeyAsName = + currentLayerVars.useKeyAsName || "prop || [prop1, prop2, ...]"; currentLayerVars.links = currentLayerVars.links || [ { name: "example", @@ -2592,7 +2821,8 @@ function layerPopulateVariable(modalId, layerType) { size: 1000, }; } else { - currentLayerVars.useKeyAsName = currentLayerVars.useKeyAsName || "prop"; + currentLayerVars.useKeyAsName = + currentLayerVars.useKeyAsName || "prop || [prop1, prop2, ...]"; currentLayerVars.hideMainFeature = currentLayerVars.hideMainFeature || false; @@ -2602,6 +2832,15 @@ function layerPopulateVariable(modalId, layerType) { theme: "default || solid", size: "default || large", }, + pairings: { + initialVisibility: false, + layers: ["Array of layer names to pair"], + pairProp: + "path.to.pair.prop.for.this.layer.and.all.paired.layers.to.link.on", + style: { + any_normal_style_field: "to_style_connective_lines", + }, + }, }; currentLayerVars.coordinateAttachments = currentLayerVars.coordinateAttachments || { @@ -2801,6 +3040,7 @@ function populateVersions(versions) { data: { mission: $(this).attr("mission"), version: $(this).attr("version"), + id: configId, }, success: function (data) { if (data.status == "success") { @@ -2919,7 +3159,7 @@ function getDuplicatedNames(json) { } let toastId = 0; -function toast(type, message, duration) { +function toast(type, message, duration, className) { let color = "#000000"; switch (type) { case "success": @@ -2935,8 +3175,47 @@ function toast(type, message, duration) { return; } const id = `toast_${type}_${toastId}`; - Materialize.toast(`<span id='${id}'>${message}</span>`, duration || 4000); + Materialize.toast( + `<span id='${id}'${ + className != null ? ` class='${className}'` : "" + }>${message}</span>`, + duration || 4000 + ); $(`#${id}`).parent().css("background-color", color); toastId++; } + +const lockConfigTypes = { + main: null, + disconnect: null, +}; +function setLockConfig(type) { + clearLockConfig(type); + lockConfig = true; + lockConfigTypes[type || "main"] = false; + lockConfigCount = mmgisglobal.ENABLE_CONFIG_OVERRIDE === "true" ? 4 : false; + + toast( + "warning", + type === "disconnect" + ? "Websocket disconnected. You will not be able to save until it reconnects." + : "This configuration changed while you were working on it. You must refresh.", + 100000000000, + "lockConfigToast" + ); +} +function clearLockConfig(type) { + lockConfigTypes[type || "main"] = false; + + let canUnlock = true; + Object.keys(lockConfigTypes).forEach((k) => { + if (lockConfigTypes[k] === true) canUnlock = false; + }); + if (canUnlock) { + lockConfig = false; + document + .querySelectorAll(".lockConfigToast") + .forEach((el) => el.parentNode.remove()); + } +} diff --git a/config/js/jquery-ui.js b/config/js/jquery-ui.js index ce8b2491..50b036f4 100644 --- a/config/js/jquery-ui.js +++ b/config/js/jquery-ui.js @@ -1,16617 +1,6 @@ -/*! jQuery UI - v1.11.4 - 2015-03-11 -* http://jqueryui.com -* Includes: core.js, widget.js, mouse.js, position.js, accordion.js, autocomplete.js, button.js, datepicker.js, dialog.js, draggable.js, droppable.js, effect.js, effect-blind.js, effect-bounce.js, effect-clip.js, effect-drop.js, effect-explode.js, effect-fade.js, effect-fold.js, effect-highlight.js, effect-puff.js, effect-pulsate.js, effect-scale.js, effect-shake.js, effect-size.js, effect-slide.js, effect-transfer.js, menu.js, progressbar.js, resizable.js, selectable.js, selectmenu.js, slider.js, sortable.js, spinner.js, tabs.js, tooltip.js -* Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */ - -(function( factory ) { - if ( typeof define === "function" && define.amd ) { - - // AMD. Register as an anonymous module. - define([ "jquery" ], factory ); - } else { - - // Browser globals - factory( jQuery ); - } -}(function( $ ) { -/*! - * jQuery UI Core 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/category/ui-core/ - */ - - -// $.ui might exist from components with no dependencies, e.g., $.ui.position -$.ui = $.ui || {}; - -$.extend( $.ui, { - version: "1.11.4", - - keyCode: { - BACKSPACE: 8, - COMMA: 188, - DELETE: 46, - DOWN: 40, - END: 35, - ENTER: 13, - ESCAPE: 27, - HOME: 36, - LEFT: 37, - PAGE_DOWN: 34, - PAGE_UP: 33, - PERIOD: 190, - RIGHT: 39, - SPACE: 32, - TAB: 9, - UP: 38 - } -}); - -// plugins -$.fn.extend({ - scrollParent: function( includeHidden ) { - var position = this.css( "position" ), - excludeStaticParent = position === "absolute", - overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/, - scrollParent = this.parents().filter( function() { - var parent = $( this ); - if ( excludeStaticParent && parent.css( "position" ) === "static" ) { - return false; - } - return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) ); - }).eq( 0 ); - - return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent; - }, - - uniqueId: (function() { - var uuid = 0; - - return function() { - return this.each(function() { - if ( !this.id ) { - this.id = "ui-id-" + ( ++uuid ); - } - }); - }; - })(), - - removeUniqueId: function() { - return this.each(function() { - if ( /^ui-id-\d+$/.test( this.id ) ) { - $( this ).removeAttr( "id" ); - } - }); - } -}); - -// selectors -function focusable( element, isTabIndexNotNaN ) { - var map, mapName, img, - nodeName = element.nodeName.toLowerCase(); - if ( "area" === nodeName ) { - map = element.parentNode; - mapName = map.name; - if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) { - return false; - } - img = $( "img[usemap='#" + mapName + "']" )[ 0 ]; - return !!img && visible( img ); - } - return ( /^(input|select|textarea|button|object)$/.test( nodeName ) ? - !element.disabled : - "a" === nodeName ? - element.href || isTabIndexNotNaN : - isTabIndexNotNaN) && - // the element and all of its ancestors must be visible - visible( element ); -} - -function visible( element ) { - return $.expr.filters.visible( element ) && - !$( element ).parents().addBack().filter(function() { - return $.css( this, "visibility" ) === "hidden"; - }).length; -} - -$.extend( $.expr[ ":" ], { - data: $.expr.createPseudo ? - $.expr.createPseudo(function( dataName ) { - return function( elem ) { - return !!$.data( elem, dataName ); - }; - }) : - // support: jQuery <1.8 - function( elem, i, match ) { - return !!$.data( elem, match[ 3 ] ); - }, - - focusable: function( element ) { - return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) ); - }, - - tabbable: function( element ) { - var tabIndex = $.attr( element, "tabindex" ), - isTabIndexNaN = isNaN( tabIndex ); - return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN ); - } -}); - -// support: jQuery <1.8 -if ( !$( "<a>" ).outerWidth( 1 ).jquery ) { - $.each( [ "Width", "Height" ], function( i, name ) { - var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ], - type = name.toLowerCase(), - orig = { - innerWidth: $.fn.innerWidth, - innerHeight: $.fn.innerHeight, - outerWidth: $.fn.outerWidth, - outerHeight: $.fn.outerHeight - }; - - function reduce( elem, size, border, margin ) { - $.each( side, function() { - size -= parseFloat( $.css( elem, "padding" + this ) ) || 0; - if ( border ) { - size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0; - } - if ( margin ) { - size -= parseFloat( $.css( elem, "margin" + this ) ) || 0; - } - }); - return size; - } - - $.fn[ "inner" + name ] = function( size ) { - if ( size === undefined ) { - return orig[ "inner" + name ].call( this ); - } - - return this.each(function() { - $( this ).css( type, reduce( this, size ) + "px" ); - }); - }; - - $.fn[ "outer" + name] = function( size, margin ) { - if ( typeof size !== "number" ) { - return orig[ "outer" + name ].call( this, size ); - } - - return this.each(function() { - $( this).css( type, reduce( this, size, true, margin ) + "px" ); - }); - }; - }); -} - -// support: jQuery <1.8 -if ( !$.fn.addBack ) { - $.fn.addBack = function( selector ) { - return this.add( selector == null ? - this.prevObject : this.prevObject.filter( selector ) - ); - }; -} - -// support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413) -if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) { - $.fn.removeData = (function( removeData ) { - return function( key ) { - if ( arguments.length ) { - return removeData.call( this, $.camelCase( key ) ); - } else { - return removeData.call( this ); - } - }; - })( $.fn.removeData ); -} - -// deprecated -$.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() ); - -$.fn.extend({ - focus: (function( orig ) { - return function( delay, fn ) { - return typeof delay === "number" ? - this.each(function() { - var elem = this; - setTimeout(function() { - $( elem ).focus(); - if ( fn ) { - fn.call( elem ); - } - }, delay ); - }) : - orig.apply( this, arguments ); - }; - })( $.fn.focus ), - - disableSelection: (function() { - var eventType = "onselectstart" in document.createElement( "div" ) ? - "selectstart" : - "mousedown"; - - return function() { - return this.bind( eventType + ".ui-disableSelection", function( event ) { - event.preventDefault(); - }); - }; - })(), - - enableSelection: function() { - return this.unbind( ".ui-disableSelection" ); - }, - - zIndex: function( zIndex ) { - if ( zIndex !== undefined ) { - return this.css( "zIndex", zIndex ); - } - - if ( this.length ) { - var elem = $( this[ 0 ] ), position, value; - while ( elem.length && elem[ 0 ] !== document ) { - // Ignore z-index if position is set to a value where z-index is ignored by the browser - // This makes behavior of this function consistent across browsers - // WebKit always returns auto if the element is positioned - position = elem.css( "position" ); - if ( position === "absolute" || position === "relative" || position === "fixed" ) { - // IE returns 0 when zIndex is not specified - // other browsers return a string - // we ignore the case of nested elements with an explicit value of 0 - // <div style="z-index: -10;"><div style="z-index: 0;"></div></div> - value = parseInt( elem.css( "zIndex" ), 10 ); - if ( !isNaN( value ) && value !== 0 ) { - return value; - } - } - elem = elem.parent(); - } - } - - return 0; - } -}); - -// $.ui.plugin is deprecated. Use $.widget() extensions instead. -$.ui.plugin = { - add: function( module, option, set ) { - var i, - proto = $.ui[ module ].prototype; - for ( i in set ) { - proto.plugins[ i ] = proto.plugins[ i ] || []; - proto.plugins[ i ].push( [ option, set[ i ] ] ); - } - }, - call: function( instance, name, args, allowDisconnected ) { - var i, - set = instance.plugins[ name ]; - - if ( !set ) { - return; - } - - if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) { - return; - } - - for ( i = 0; i < set.length; i++ ) { - if ( instance.options[ set[ i ][ 0 ] ] ) { - set[ i ][ 1 ].apply( instance.element, args ); - } - } - } -}; - - -/*! - * jQuery UI Widget 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/jQuery.widget/ - */ - - -var widget_uuid = 0, - widget_slice = Array.prototype.slice; - -$.cleanData = (function( orig ) { - return function( elems ) { - var events, elem, i; - for ( i = 0; (elem = elems[i]) != null; i++ ) { - try { - - // Only trigger remove when necessary to save time - events = $._data( elem, "events" ); - if ( events && events.remove ) { - $( elem ).triggerHandler( "remove" ); - } - - // http://bugs.jquery.com/ticket/8235 - } catch ( e ) {} - } - orig( elems ); - }; -})( $.cleanData ); - -$.widget = function( name, base, prototype ) { - var fullName, existingConstructor, constructor, basePrototype, - // proxiedPrototype allows the provided prototype to remain unmodified - // so that it can be used as a mixin for multiple widgets (#8876) - proxiedPrototype = {}, - namespace = name.split( "." )[ 0 ]; - - name = name.split( "." )[ 1 ]; - fullName = namespace + "-" + name; - - if ( !prototype ) { - prototype = base; - base = $.Widget; - } - - // create selector for plugin - $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) { - return !!$.data( elem, fullName ); - }; - - $[ namespace ] = $[ namespace ] || {}; - existingConstructor = $[ namespace ][ name ]; - constructor = $[ namespace ][ name ] = function( options, element ) { - // allow instantiation without "new" keyword - if ( !this._createWidget ) { - return new constructor( options, element ); - } - - // allow instantiation without initializing for simple inheritance - // must use "new" keyword (the code above always passes args) - if ( arguments.length ) { - this._createWidget( options, element ); - } - }; - // extend with the existing constructor to carry over any static properties - $.extend( constructor, existingConstructor, { - version: prototype.version, - // copy the object used to create the prototype in case we need to - // redefine the widget later - _proto: $.extend( {}, prototype ), - // track widgets that inherit from this widget in case this widget is - // redefined after a widget inherits from it - _childConstructors: [] - }); - - basePrototype = new base(); - // we need to make the options hash a property directly on the new instance - // otherwise we'll modify the options hash on the prototype that we're - // inheriting from - basePrototype.options = $.widget.extend( {}, basePrototype.options ); - $.each( prototype, function( prop, value ) { - if ( !$.isFunction( value ) ) { - proxiedPrototype[ prop ] = value; - return; - } - proxiedPrototype[ prop ] = (function() { - var _super = function() { - return base.prototype[ prop ].apply( this, arguments ); - }, - _superApply = function( args ) { - return base.prototype[ prop ].apply( this, args ); - }; - return function() { - var __super = this._super, - __superApply = this._superApply, - returnValue; - - this._super = _super; - this._superApply = _superApply; - - returnValue = value.apply( this, arguments ); - - this._super = __super; - this._superApply = __superApply; - - return returnValue; - }; - })(); - }); - constructor.prototype = $.widget.extend( basePrototype, { - // TODO: remove support for widgetEventPrefix - // always use the name + a colon as the prefix, e.g., draggable:start - // don't prefix for widgets that aren't DOM-based - widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name - }, proxiedPrototype, { - constructor: constructor, - namespace: namespace, - widgetName: name, - widgetFullName: fullName - }); - - // If this widget is being redefined then we need to find all widgets that - // are inheriting from it and redefine all of them so that they inherit from - // the new version of this widget. We're essentially trying to replace one - // level in the prototype chain. - if ( existingConstructor ) { - $.each( existingConstructor._childConstructors, function( i, child ) { - var childPrototype = child.prototype; - - // redefine the child widget using the same prototype that was - // originally used, but inherit from the new version of the base - $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto ); - }); - // remove the list of existing child constructors from the old constructor - // so the old child constructors can be garbage collected - delete existingConstructor._childConstructors; - } else { - base._childConstructors.push( constructor ); - } - - $.widget.bridge( name, constructor ); - - return constructor; -}; - -$.widget.extend = function( target ) { - var input = widget_slice.call( arguments, 1 ), - inputIndex = 0, - inputLength = input.length, - key, - value; - for ( ; inputIndex < inputLength; inputIndex++ ) { - for ( key in input[ inputIndex ] ) { - value = input[ inputIndex ][ key ]; - if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) { - // Clone objects - if ( $.isPlainObject( value ) ) { - target[ key ] = $.isPlainObject( target[ key ] ) ? - $.widget.extend( {}, target[ key ], value ) : - // Don't extend strings, arrays, etc. with objects - $.widget.extend( {}, value ); - // Copy everything else by reference - } else { - target[ key ] = value; - } - } - } - } - return target; -}; - -$.widget.bridge = function( name, object ) { - var fullName = object.prototype.widgetFullName || name; - $.fn[ name ] = function( options ) { - var isMethodCall = typeof options === "string", - args = widget_slice.call( arguments, 1 ), - returnValue = this; - - if ( isMethodCall ) { - this.each(function() { - var methodValue, - instance = $.data( this, fullName ); - if ( options === "instance" ) { - returnValue = instance; - return false; - } - if ( !instance ) { - return $.error( "cannot call methods on " + name + " prior to initialization; " + - "attempted to call method '" + options + "'" ); - } - if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) { - return $.error( "no such method '" + options + "' for " + name + " widget instance" ); - } - methodValue = instance[ options ].apply( instance, args ); - if ( methodValue !== instance && methodValue !== undefined ) { - returnValue = methodValue && methodValue.jquery ? - returnValue.pushStack( methodValue.get() ) : - methodValue; - return false; - } - }); - } else { - - // Allow multiple hashes to be passed on init - if ( args.length ) { - options = $.widget.extend.apply( null, [ options ].concat(args) ); - } - - this.each(function() { - var instance = $.data( this, fullName ); - if ( instance ) { - instance.option( options || {} ); - if ( instance._init ) { - instance._init(); - } - } else { - $.data( this, fullName, new object( options, this ) ); - } - }); - } - - return returnValue; - }; -}; - -$.Widget = function( /* options, element */ ) {}; -$.Widget._childConstructors = []; - -$.Widget.prototype = { - widgetName: "widget", - widgetEventPrefix: "", - defaultElement: "<div>", - options: { - disabled: false, - - // callbacks - create: null - }, - _createWidget: function( options, element ) { - element = $( element || this.defaultElement || this )[ 0 ]; - this.element = $( element ); - this.uuid = widget_uuid++; - this.eventNamespace = "." + this.widgetName + this.uuid; - - this.bindings = $(); - this.hoverable = $(); - this.focusable = $(); - - if ( element !== this ) { - $.data( element, this.widgetFullName, this ); - this._on( true, this.element, { - remove: function( event ) { - if ( event.target === element ) { - this.destroy(); - } - } - }); - this.document = $( element.style ? - // element within the document - element.ownerDocument : - // element is window or document - element.document || element ); - this.window = $( this.document[0].defaultView || this.document[0].parentWindow ); - } - - this.options = $.widget.extend( {}, - this.options, - this._getCreateOptions(), - options ); - - this._create(); - this._trigger( "create", null, this._getCreateEventData() ); - this._init(); - }, - _getCreateOptions: $.noop, - _getCreateEventData: $.noop, - _create: $.noop, - _init: $.noop, - - destroy: function() { - this._destroy(); - // we can probably remove the unbind calls in 2.0 - // all event bindings should go through this._on() - this.element - .unbind( this.eventNamespace ) - .removeData( this.widgetFullName ) - // support: jquery <1.6.3 - // http://bugs.jquery.com/ticket/9413 - .removeData( $.camelCase( this.widgetFullName ) ); - this.widget() - .unbind( this.eventNamespace ) - .removeAttr( "aria-disabled" ) - .removeClass( - this.widgetFullName + "-disabled " + - "ui-state-disabled" ); - - // clean up events and states - this.bindings.unbind( this.eventNamespace ); - this.hoverable.removeClass( "ui-state-hover" ); - this.focusable.removeClass( "ui-state-focus" ); - }, - _destroy: $.noop, - - widget: function() { - return this.element; - }, - - option: function( key, value ) { - var options = key, - parts, - curOption, - i; - - if ( arguments.length === 0 ) { - // don't return a reference to the internal hash - return $.widget.extend( {}, this.options ); - } - - if ( typeof key === "string" ) { - // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } - options = {}; - parts = key.split( "." ); - key = parts.shift(); - if ( parts.length ) { - curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] ); - for ( i = 0; i < parts.length - 1; i++ ) { - curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {}; - curOption = curOption[ parts[ i ] ]; - } - key = parts.pop(); - if ( arguments.length === 1 ) { - return curOption[ key ] === undefined ? null : curOption[ key ]; - } - curOption[ key ] = value; - } else { - if ( arguments.length === 1 ) { - return this.options[ key ] === undefined ? null : this.options[ key ]; - } - options[ key ] = value; - } - } - - this._setOptions( options ); - - return this; - }, - _setOptions: function( options ) { - var key; - - for ( key in options ) { - this._setOption( key, options[ key ] ); - } - - return this; - }, - _setOption: function( key, value ) { - this.options[ key ] = value; - - if ( key === "disabled" ) { - this.widget() - .toggleClass( this.widgetFullName + "-disabled", !!value ); - - // If the widget is becoming disabled, then nothing is interactive - if ( value ) { - this.hoverable.removeClass( "ui-state-hover" ); - this.focusable.removeClass( "ui-state-focus" ); - } - } - - return this; - }, - - enable: function() { - return this._setOptions({ disabled: false }); - }, - disable: function() { - return this._setOptions({ disabled: true }); - }, - - _on: function( suppressDisabledCheck, element, handlers ) { - var delegateElement, - instance = this; - - // no suppressDisabledCheck flag, shuffle arguments - if ( typeof suppressDisabledCheck !== "boolean" ) { - handlers = element; - element = suppressDisabledCheck; - suppressDisabledCheck = false; - } - - // no element argument, shuffle and use this.element - if ( !handlers ) { - handlers = element; - element = this.element; - delegateElement = this.widget(); - } else { - element = delegateElement = $( element ); - this.bindings = this.bindings.add( element ); - } - - $.each( handlers, function( event, handler ) { - function handlerProxy() { - // allow widgets to customize the disabled handling - // - disabled as an array instead of boolean - // - disabled class as method for disabling individual parts - if ( !suppressDisabledCheck && - ( instance.options.disabled === true || - $( this ).hasClass( "ui-state-disabled" ) ) ) { - return; - } - return ( typeof handler === "string" ? instance[ handler ] : handler ) - .apply( instance, arguments ); - } - - // copy the guid so direct unbinding works - if ( typeof handler !== "string" ) { - handlerProxy.guid = handler.guid = - handler.guid || handlerProxy.guid || $.guid++; - } - - var match = event.match( /^([\w:-]*)\s*(.*)$/ ), - eventName = match[1] + instance.eventNamespace, - selector = match[2]; - if ( selector ) { - delegateElement.delegate( selector, eventName, handlerProxy ); - } else { - element.bind( eventName, handlerProxy ); - } - }); - }, - - _off: function( element, eventName ) { - eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + - this.eventNamespace; - element.unbind( eventName ).undelegate( eventName ); - - // Clear the stack to avoid memory leaks (#10056) - this.bindings = $( this.bindings.not( element ).get() ); - this.focusable = $( this.focusable.not( element ).get() ); - this.hoverable = $( this.hoverable.not( element ).get() ); - }, - - _delay: function( handler, delay ) { - function handlerProxy() { - return ( typeof handler === "string" ? instance[ handler ] : handler ) - .apply( instance, arguments ); - } - var instance = this; - return setTimeout( handlerProxy, delay || 0 ); - }, - - _hoverable: function( element ) { - this.hoverable = this.hoverable.add( element ); - this._on( element, { - mouseenter: function( event ) { - $( event.currentTarget ).addClass( "ui-state-hover" ); - }, - mouseleave: function( event ) { - $( event.currentTarget ).removeClass( "ui-state-hover" ); - } - }); - }, - - _focusable: function( element ) { - this.focusable = this.focusable.add( element ); - this._on( element, { - focusin: function( event ) { - $( event.currentTarget ).addClass( "ui-state-focus" ); - }, - focusout: function( event ) { - $( event.currentTarget ).removeClass( "ui-state-focus" ); - } - }); - }, - - _trigger: function( type, event, data ) { - var prop, orig, - callback = this.options[ type ]; - - data = data || {}; - event = $.Event( event ); - event.type = ( type === this.widgetEventPrefix ? - type : - this.widgetEventPrefix + type ).toLowerCase(); - // the original event may come from any element - // so we need to reset the target on the new event - event.target = this.element[ 0 ]; - - // copy original event properties over to the new event - orig = event.originalEvent; - if ( orig ) { - for ( prop in orig ) { - if ( !( prop in event ) ) { - event[ prop ] = orig[ prop ]; - } - } - } - - this.element.trigger( event, data ); - return !( $.isFunction( callback ) && - callback.apply( this.element[0], [ event ].concat( data ) ) === false || - event.isDefaultPrevented() ); - } -}; - -$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { - $.Widget.prototype[ "_" + method ] = function( element, options, callback ) { - if ( typeof options === "string" ) { - options = { effect: options }; - } - var hasOptions, - effectName = !options ? - method : - options === true || typeof options === "number" ? - defaultEffect : - options.effect || defaultEffect; - options = options || {}; - if ( typeof options === "number" ) { - options = { duration: options }; - } - hasOptions = !$.isEmptyObject( options ); - options.complete = callback; - if ( options.delay ) { - element.delay( options.delay ); - } - if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) { - element[ method ]( options ); - } else if ( effectName !== method && element[ effectName ] ) { - element[ effectName ]( options.duration, options.easing, callback ); - } else { - element.queue(function( next ) { - $( this )[ method ](); - if ( callback ) { - callback.call( element[ 0 ] ); - } - next(); - }); - } - }; -}); - -var widget = $.widget; - - -/*! - * jQuery UI Mouse 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/mouse/ - */ - - -var mouseHandled = false; -$( document ).mouseup( function() { - mouseHandled = false; -}); - -var mouse = $.widget("ui.mouse", { - version: "1.11.4", - options: { - cancel: "input,textarea,button,select,option", - distance: 1, - delay: 0 - }, - _mouseInit: function() { - var that = this; - - this.element - .bind("mousedown." + this.widgetName, function(event) { - return that._mouseDown(event); - }) - .bind("click." + this.widgetName, function(event) { - if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) { - $.removeData(event.target, that.widgetName + ".preventClickEvent"); - event.stopImmediatePropagation(); - return false; - } - }); - - this.started = false; - }, - - // TODO: make sure destroying one instance of mouse doesn't mess with - // other instances of mouse - _mouseDestroy: function() { - this.element.unbind("." + this.widgetName); - if ( this._mouseMoveDelegate ) { - this.document - .unbind("mousemove." + this.widgetName, this._mouseMoveDelegate) - .unbind("mouseup." + this.widgetName, this._mouseUpDelegate); - } - }, - - _mouseDown: function(event) { - // don't let more than one widget handle mouseStart - if ( mouseHandled ) { - return; - } - - this._mouseMoved = false; - - // we may have missed mouseup (out of window) - (this._mouseStarted && this._mouseUp(event)); - - this._mouseDownEvent = event; - - var that = this, - btnIsLeft = (event.which === 1), - // event.target.nodeName works around a bug in IE 8 with - // disabled inputs (#7620) - elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false); - if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) { - return true; - } - - this.mouseDelayMet = !this.options.delay; - if (!this.mouseDelayMet) { - this._mouseDelayTimer = setTimeout(function() { - that.mouseDelayMet = true; - }, this.options.delay); - } - - if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { - this._mouseStarted = (this._mouseStart(event) !== false); - if (!this._mouseStarted) { - event.preventDefault(); - return true; - } - } - - // Click event may never have fired (Gecko & Opera) - if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) { - $.removeData(event.target, this.widgetName + ".preventClickEvent"); - } - - // these delegates are required to keep context - this._mouseMoveDelegate = function(event) { - return that._mouseMove(event); - }; - this._mouseUpDelegate = function(event) { - return that._mouseUp(event); - }; - - this.document - .bind( "mousemove." + this.widgetName, this._mouseMoveDelegate ) - .bind( "mouseup." + this.widgetName, this._mouseUpDelegate ); - - event.preventDefault(); - - mouseHandled = true; - return true; - }, - - _mouseMove: function(event) { - // Only check for mouseups outside the document if you've moved inside the document - // at least once. This prevents the firing of mouseup in the case of IE<9, which will - // fire a mousemove event if content is placed under the cursor. See #7778 - // Support: IE <9 - if ( this._mouseMoved ) { - // IE mouseup check - mouseup happened when mouse was out of window - if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) { - return this._mouseUp(event); - - // Iframe mouseup check - mouseup occurred in another document - } else if ( !event.which ) { - return this._mouseUp( event ); - } - } - - if ( event.which || event.button ) { - this._mouseMoved = true; - } - - if (this._mouseStarted) { - this._mouseDrag(event); - return event.preventDefault(); - } - - if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { - this._mouseStarted = - (this._mouseStart(this._mouseDownEvent, event) !== false); - (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event)); - } - - return !this._mouseStarted; - }, - - _mouseUp: function(event) { - this.document - .unbind( "mousemove." + this.widgetName, this._mouseMoveDelegate ) - .unbind( "mouseup." + this.widgetName, this._mouseUpDelegate ); - - if (this._mouseStarted) { - this._mouseStarted = false; - - if (event.target === this._mouseDownEvent.target) { - $.data(event.target, this.widgetName + ".preventClickEvent", true); - } - - this._mouseStop(event); - } - - mouseHandled = false; - return false; - }, - - _mouseDistanceMet: function(event) { - return (Math.max( - Math.abs(this._mouseDownEvent.pageX - event.pageX), - Math.abs(this._mouseDownEvent.pageY - event.pageY) - ) >= this.options.distance - ); - }, - - _mouseDelayMet: function(/* event */) { - return this.mouseDelayMet; - }, - - // These are placeholder methods, to be overriden by extending plugin - _mouseStart: function(/* event */) {}, - _mouseDrag: function(/* event */) {}, - _mouseStop: function(/* event */) {}, - _mouseCapture: function(/* event */) { return true; } -}); - - -/*! - * jQuery UI Position 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/position/ - */ - -(function() { - -$.ui = $.ui || {}; - -var cachedScrollbarWidth, supportsOffsetFractions, - max = Math.max, - abs = Math.abs, - round = Math.round, - rhorizontal = /left|center|right/, - rvertical = /top|center|bottom/, - roffset = /[\+\-]\d+(\.[\d]+)?%?/, - rposition = /^\w+/, - rpercent = /%$/, - _position = $.fn.position; - -function getOffsets( offsets, width, height ) { - return [ - parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ), - parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 ) - ]; -} - -function parseCss( element, property ) { - return parseInt( $.css( element, property ), 10 ) || 0; -} - -function getDimensions( elem ) { - var raw = elem[0]; - if ( raw.nodeType === 9 ) { - return { - width: elem.width(), - height: elem.height(), - offset: { top: 0, left: 0 } - }; - } - if ( $.isWindow( raw ) ) { - return { - width: elem.width(), - height: elem.height(), - offset: { top: elem.scrollTop(), left: elem.scrollLeft() } - }; - } - if ( raw.preventDefault ) { - return { - width: 0, - height: 0, - offset: { top: raw.pageY, left: raw.pageX } - }; - } - return { - width: elem.outerWidth(), - height: elem.outerHeight(), - offset: elem.offset() - }; -} - -$.position = { - scrollbarWidth: function() { - if ( cachedScrollbarWidth !== undefined ) { - return cachedScrollbarWidth; - } - var w1, w2, - div = $( "<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ), - innerDiv = div.children()[0]; - - $( "body" ).append( div ); - w1 = innerDiv.offsetWidth; - div.css( "overflow", "scroll" ); - - w2 = innerDiv.offsetWidth; - - if ( w1 === w2 ) { - w2 = div[0].clientWidth; - } - - div.remove(); - - return (cachedScrollbarWidth = w1 - w2); - }, - getScrollInfo: function( within ) { - var overflowX = within.isWindow || within.isDocument ? "" : - within.element.css( "overflow-x" ), - overflowY = within.isWindow || within.isDocument ? "" : - within.element.css( "overflow-y" ), - hasOverflowX = overflowX === "scroll" || - ( overflowX === "auto" && within.width < within.element[0].scrollWidth ), - hasOverflowY = overflowY === "scroll" || - ( overflowY === "auto" && within.height < within.element[0].scrollHeight ); - return { - width: hasOverflowY ? $.position.scrollbarWidth() : 0, - height: hasOverflowX ? $.position.scrollbarWidth() : 0 - }; - }, - getWithinInfo: function( element ) { - var withinElement = $( element || window ), - isWindow = $.isWindow( withinElement[0] ), - isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9; - return { - element: withinElement, - isWindow: isWindow, - isDocument: isDocument, - offset: withinElement.offset() || { left: 0, top: 0 }, - scrollLeft: withinElement.scrollLeft(), - scrollTop: withinElement.scrollTop(), - - // support: jQuery 1.6.x - // jQuery 1.6 doesn't support .outerWidth/Height() on documents or windows - width: isWindow || isDocument ? withinElement.width() : withinElement.outerWidth(), - height: isWindow || isDocument ? withinElement.height() : withinElement.outerHeight() - }; - } -}; - -$.fn.position = function( options ) { - if ( !options || !options.of ) { - return _position.apply( this, arguments ); - } - - // make a copy, we don't want to modify arguments - options = $.extend( {}, options ); - - var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions, - target = $( options.of ), - within = $.position.getWithinInfo( options.within ), - scrollInfo = $.position.getScrollInfo( within ), - collision = ( options.collision || "flip" ).split( " " ), - offsets = {}; - - dimensions = getDimensions( target ); - if ( target[0].preventDefault ) { - // force left top to allow flipping - options.at = "left top"; - } - targetWidth = dimensions.width; - targetHeight = dimensions.height; - targetOffset = dimensions.offset; - // clone to reuse original targetOffset later - basePosition = $.extend( {}, targetOffset ); - - // force my and at to have valid horizontal and vertical positions - // if a value is missing or invalid, it will be converted to center - $.each( [ "my", "at" ], function() { - var pos = ( options[ this ] || "" ).split( " " ), - horizontalOffset, - verticalOffset; - - if ( pos.length === 1) { - pos = rhorizontal.test( pos[ 0 ] ) ? - pos.concat( [ "center" ] ) : - rvertical.test( pos[ 0 ] ) ? - [ "center" ].concat( pos ) : - [ "center", "center" ]; - } - pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center"; - pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center"; - - // calculate offsets - horizontalOffset = roffset.exec( pos[ 0 ] ); - verticalOffset = roffset.exec( pos[ 1 ] ); - offsets[ this ] = [ - horizontalOffset ? horizontalOffset[ 0 ] : 0, - verticalOffset ? verticalOffset[ 0 ] : 0 - ]; - - // reduce to just the positions without the offsets - options[ this ] = [ - rposition.exec( pos[ 0 ] )[ 0 ], - rposition.exec( pos[ 1 ] )[ 0 ] - ]; - }); - - // normalize collision option - if ( collision.length === 1 ) { - collision[ 1 ] = collision[ 0 ]; - } - - if ( options.at[ 0 ] === "right" ) { - basePosition.left += targetWidth; - } else if ( options.at[ 0 ] === "center" ) { - basePosition.left += targetWidth / 2; - } - - if ( options.at[ 1 ] === "bottom" ) { - basePosition.top += targetHeight; - } else if ( options.at[ 1 ] === "center" ) { - basePosition.top += targetHeight / 2; - } - - atOffset = getOffsets( offsets.at, targetWidth, targetHeight ); - basePosition.left += atOffset[ 0 ]; - basePosition.top += atOffset[ 1 ]; - - return this.each(function() { - var collisionPosition, using, - elem = $( this ), - elemWidth = elem.outerWidth(), - elemHeight = elem.outerHeight(), - marginLeft = parseCss( this, "marginLeft" ), - marginTop = parseCss( this, "marginTop" ), - collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width, - collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height, - position = $.extend( {}, basePosition ), - myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() ); - - if ( options.my[ 0 ] === "right" ) { - position.left -= elemWidth; - } else if ( options.my[ 0 ] === "center" ) { - position.left -= elemWidth / 2; - } - - if ( options.my[ 1 ] === "bottom" ) { - position.top -= elemHeight; - } else if ( options.my[ 1 ] === "center" ) { - position.top -= elemHeight / 2; - } - - position.left += myOffset[ 0 ]; - position.top += myOffset[ 1 ]; - - // if the browser doesn't support fractions, then round for consistent results - if ( !supportsOffsetFractions ) { - position.left = round( position.left ); - position.top = round( position.top ); - } - - collisionPosition = { - marginLeft: marginLeft, - marginTop: marginTop - }; - - $.each( [ "left", "top" ], function( i, dir ) { - if ( $.ui.position[ collision[ i ] ] ) { - $.ui.position[ collision[ i ] ][ dir ]( position, { - targetWidth: targetWidth, - targetHeight: targetHeight, - elemWidth: elemWidth, - elemHeight: elemHeight, - collisionPosition: collisionPosition, - collisionWidth: collisionWidth, - collisionHeight: collisionHeight, - offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ], - my: options.my, - at: options.at, - within: within, - elem: elem - }); - } - }); - - if ( options.using ) { - // adds feedback as second argument to using callback, if present - using = function( props ) { - var left = targetOffset.left - position.left, - right = left + targetWidth - elemWidth, - top = targetOffset.top - position.top, - bottom = top + targetHeight - elemHeight, - feedback = { - target: { - element: target, - left: targetOffset.left, - top: targetOffset.top, - width: targetWidth, - height: targetHeight - }, - element: { - element: elem, - left: position.left, - top: position.top, - width: elemWidth, - height: elemHeight - }, - horizontal: right < 0 ? "left" : left > 0 ? "right" : "center", - vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle" - }; - if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) { - feedback.horizontal = "center"; - } - if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) { - feedback.vertical = "middle"; - } - if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) { - feedback.important = "horizontal"; - } else { - feedback.important = "vertical"; - } - options.using.call( this, props, feedback ); - }; - } - - elem.offset( $.extend( position, { using: using } ) ); - }); -}; - -$.ui.position = { - fit: { - left: function( position, data ) { - var within = data.within, - withinOffset = within.isWindow ? within.scrollLeft : within.offset.left, - outerWidth = within.width, - collisionPosLeft = position.left - data.collisionPosition.marginLeft, - overLeft = withinOffset - collisionPosLeft, - overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset, - newOverRight; - - // element is wider than within - if ( data.collisionWidth > outerWidth ) { - // element is initially over the left side of within - if ( overLeft > 0 && overRight <= 0 ) { - newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset; - position.left += overLeft - newOverRight; - // element is initially over right side of within - } else if ( overRight > 0 && overLeft <= 0 ) { - position.left = withinOffset; - // element is initially over both left and right sides of within - } else { - if ( overLeft > overRight ) { - position.left = withinOffset + outerWidth - data.collisionWidth; - } else { - position.left = withinOffset; - } - } - // too far left -> align with left edge - } else if ( overLeft > 0 ) { - position.left += overLeft; - // too far right -> align with right edge - } else if ( overRight > 0 ) { - position.left -= overRight; - // adjust based on position and margin - } else { - position.left = max( position.left - collisionPosLeft, position.left ); - } - }, - top: function( position, data ) { - var within = data.within, - withinOffset = within.isWindow ? within.scrollTop : within.offset.top, - outerHeight = data.within.height, - collisionPosTop = position.top - data.collisionPosition.marginTop, - overTop = withinOffset - collisionPosTop, - overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset, - newOverBottom; - - // element is taller than within - if ( data.collisionHeight > outerHeight ) { - // element is initially over the top of within - if ( overTop > 0 && overBottom <= 0 ) { - newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset; - position.top += overTop - newOverBottom; - // element is initially over bottom of within - } else if ( overBottom > 0 && overTop <= 0 ) { - position.top = withinOffset; - // element is initially over both top and bottom of within - } else { - if ( overTop > overBottom ) { - position.top = withinOffset + outerHeight - data.collisionHeight; - } else { - position.top = withinOffset; - } - } - // too far up -> align with top - } else if ( overTop > 0 ) { - position.top += overTop; - // too far down -> align with bottom edge - } else if ( overBottom > 0 ) { - position.top -= overBottom; - // adjust based on position and margin - } else { - position.top = max( position.top - collisionPosTop, position.top ); - } - } - }, - flip: { - left: function( position, data ) { - var within = data.within, - withinOffset = within.offset.left + within.scrollLeft, - outerWidth = within.width, - offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left, - collisionPosLeft = position.left - data.collisionPosition.marginLeft, - overLeft = collisionPosLeft - offsetLeft, - overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft, - myOffset = data.my[ 0 ] === "left" ? - -data.elemWidth : - data.my[ 0 ] === "right" ? - data.elemWidth : - 0, - atOffset = data.at[ 0 ] === "left" ? - data.targetWidth : - data.at[ 0 ] === "right" ? - -data.targetWidth : - 0, - offset = -2 * data.offset[ 0 ], - newOverRight, - newOverLeft; - - if ( overLeft < 0 ) { - newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset; - if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) { - position.left += myOffset + atOffset + offset; - } - } else if ( overRight > 0 ) { - newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft; - if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) { - position.left += myOffset + atOffset + offset; - } - } - }, - top: function( position, data ) { - var within = data.within, - withinOffset = within.offset.top + within.scrollTop, - outerHeight = within.height, - offsetTop = within.isWindow ? within.scrollTop : within.offset.top, - collisionPosTop = position.top - data.collisionPosition.marginTop, - overTop = collisionPosTop - offsetTop, - overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop, - top = data.my[ 1 ] === "top", - myOffset = top ? - -data.elemHeight : - data.my[ 1 ] === "bottom" ? - data.elemHeight : - 0, - atOffset = data.at[ 1 ] === "top" ? - data.targetHeight : - data.at[ 1 ] === "bottom" ? - -data.targetHeight : - 0, - offset = -2 * data.offset[ 1 ], - newOverTop, - newOverBottom; - if ( overTop < 0 ) { - newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset; - if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) { - position.top += myOffset + atOffset + offset; - } - } else if ( overBottom > 0 ) { - newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop; - if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) { - position.top += myOffset + atOffset + offset; - } - } - } - }, - flipfit: { - left: function() { - $.ui.position.flip.left.apply( this, arguments ); - $.ui.position.fit.left.apply( this, arguments ); - }, - top: function() { - $.ui.position.flip.top.apply( this, arguments ); - $.ui.position.fit.top.apply( this, arguments ); - } - } -}; - -// fraction support test -(function() { - var testElement, testElementParent, testElementStyle, offsetLeft, i, - body = document.getElementsByTagName( "body" )[ 0 ], - div = document.createElement( "div" ); - - //Create a "fake body" for testing based on method used in jQuery.support - testElement = document.createElement( body ? "div" : "body" ); - testElementStyle = { - visibility: "hidden", - width: 0, - height: 0, - border: 0, - margin: 0, - background: "none" - }; - if ( body ) { - $.extend( testElementStyle, { - position: "absolute", - left: "-1000px", - top: "-1000px" - }); - } - for ( i in testElementStyle ) { - testElement.style[ i ] = testElementStyle[ i ]; - } - testElement.appendChild( div ); - testElementParent = body || document.documentElement; - testElementParent.insertBefore( testElement, testElementParent.firstChild ); - - div.style.cssText = "position: absolute; left: 10.7432222px;"; - - offsetLeft = $( div ).offset().left; - supportsOffsetFractions = offsetLeft > 10 && offsetLeft < 11; - - testElement.innerHTML = ""; - testElementParent.removeChild( testElement ); -})(); - -})(); - -var position = $.ui.position; - - -/*! - * jQuery UI Accordion 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/accordion/ - */ - - -var accordion = $.widget( "ui.accordion", { - version: "1.11.4", - options: { - active: 0, - animate: {}, - collapsible: false, - event: "click", - header: "> li > :first-child,> :not(li):even", - heightStyle: "auto", - icons: { - activeHeader: "ui-icon-triangle-1-s", - header: "ui-icon-triangle-1-e" - }, - - // callbacks - activate: null, - beforeActivate: null - }, - - hideProps: { - borderTopWidth: "hide", - borderBottomWidth: "hide", - paddingTop: "hide", - paddingBottom: "hide", - height: "hide" - }, - - showProps: { - borderTopWidth: "show", - borderBottomWidth: "show", - paddingTop: "show", - paddingBottom: "show", - height: "show" - }, - - _create: function() { - var options = this.options; - this.prevShow = this.prevHide = $(); - this.element.addClass( "ui-accordion ui-widget ui-helper-reset" ) - // ARIA - .attr( "role", "tablist" ); - - // don't allow collapsible: false and active: false / null - if ( !options.collapsible && (options.active === false || options.active == null) ) { - options.active = 0; - } - - this._processPanels(); - // handle negative values - if ( options.active < 0 ) { - options.active += this.headers.length; - } - this._refresh(); - }, - - _getCreateEventData: function() { - return { - header: this.active, - panel: !this.active.length ? $() : this.active.next() - }; - }, - - _createIcons: function() { - var icons = this.options.icons; - if ( icons ) { - $( "<span>" ) - .addClass( "ui-accordion-header-icon ui-icon " + icons.header ) - .prependTo( this.headers ); - this.active.children( ".ui-accordion-header-icon" ) - .removeClass( icons.header ) - .addClass( icons.activeHeader ); - this.headers.addClass( "ui-accordion-icons" ); - } - }, - - _destroyIcons: function() { - this.headers - .removeClass( "ui-accordion-icons" ) - .children( ".ui-accordion-header-icon" ) - .remove(); - }, - - _destroy: function() { - var contents; - - // clean up main element - this.element - .removeClass( "ui-accordion ui-widget ui-helper-reset" ) - .removeAttr( "role" ); - - // clean up headers - this.headers - .removeClass( "ui-accordion-header ui-accordion-header-active ui-state-default " + - "ui-corner-all ui-state-active ui-state-disabled ui-corner-top" ) - .removeAttr( "role" ) - .removeAttr( "aria-expanded" ) - .removeAttr( "aria-selected" ) - .removeAttr( "aria-controls" ) - .removeAttr( "tabIndex" ) - .removeUniqueId(); - - this._destroyIcons(); - - // clean up content panels - contents = this.headers.next() - .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom " + - "ui-accordion-content ui-accordion-content-active ui-state-disabled" ) - .css( "display", "" ) - .removeAttr( "role" ) - .removeAttr( "aria-hidden" ) - .removeAttr( "aria-labelledby" ) - .removeUniqueId(); - - if ( this.options.heightStyle !== "content" ) { - contents.css( "height", "" ); - } - }, - - _setOption: function( key, value ) { - if ( key === "active" ) { - // _activate() will handle invalid values and update this.options - this._activate( value ); - return; - } - - if ( key === "event" ) { - if ( this.options.event ) { - this._off( this.headers, this.options.event ); - } - this._setupEvents( value ); - } - - this._super( key, value ); - - // setting collapsible: false while collapsed; open first panel - if ( key === "collapsible" && !value && this.options.active === false ) { - this._activate( 0 ); - } - - if ( key === "icons" ) { - this._destroyIcons(); - if ( value ) { - this._createIcons(); - } - } - - // #5332 - opacity doesn't cascade to positioned elements in IE - // so we need to add the disabled class to the headers and panels - if ( key === "disabled" ) { - this.element - .toggleClass( "ui-state-disabled", !!value ) - .attr( "aria-disabled", value ); - this.headers.add( this.headers.next() ) - .toggleClass( "ui-state-disabled", !!value ); - } - }, - - _keydown: function( event ) { - if ( event.altKey || event.ctrlKey ) { - return; - } - - var keyCode = $.ui.keyCode, - length = this.headers.length, - currentIndex = this.headers.index( event.target ), - toFocus = false; - - switch ( event.keyCode ) { - case keyCode.RIGHT: - case keyCode.DOWN: - toFocus = this.headers[ ( currentIndex + 1 ) % length ]; - break; - case keyCode.LEFT: - case keyCode.UP: - toFocus = this.headers[ ( currentIndex - 1 + length ) % length ]; - break; - case keyCode.SPACE: - case keyCode.ENTER: - this._eventHandler( event ); - break; - case keyCode.HOME: - toFocus = this.headers[ 0 ]; - break; - case keyCode.END: - toFocus = this.headers[ length - 1 ]; - break; - } - - if ( toFocus ) { - $( event.target ).attr( "tabIndex", -1 ); - $( toFocus ).attr( "tabIndex", 0 ); - toFocus.focus(); - event.preventDefault(); - } - }, - - _panelKeyDown: function( event ) { - if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) { - $( event.currentTarget ).prev().focus(); - } - }, - - refresh: function() { - var options = this.options; - this._processPanels(); - - // was collapsed or no panel - if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) { - options.active = false; - this.active = $(); - // active false only when collapsible is true - } else if ( options.active === false ) { - this._activate( 0 ); - // was active, but active panel is gone - } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) { - // all remaining panel are disabled - if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) { - options.active = false; - this.active = $(); - // activate previous panel - } else { - this._activate( Math.max( 0, options.active - 1 ) ); - } - // was active, active panel still exists - } else { - // make sure active index is correct - options.active = this.headers.index( this.active ); - } - - this._destroyIcons(); - - this._refresh(); - }, - - _processPanels: function() { - var prevHeaders = this.headers, - prevPanels = this.panels; - - this.headers = this.element.find( this.options.header ) - .addClass( "ui-accordion-header ui-state-default ui-corner-all" ); - - this.panels = this.headers.next() - .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" ) - .filter( ":not(.ui-accordion-content-active)" ) - .hide(); - - // Avoid memory leaks (#10056) - if ( prevPanels ) { - this._off( prevHeaders.not( this.headers ) ); - this._off( prevPanels.not( this.panels ) ); - } - }, - - _refresh: function() { - var maxHeight, - options = this.options, - heightStyle = options.heightStyle, - parent = this.element.parent(); - - this.active = this._findActive( options.active ) - .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" ) - .removeClass( "ui-corner-all" ); - this.active.next() - .addClass( "ui-accordion-content-active" ) - .show(); - - this.headers - .attr( "role", "tab" ) - .each(function() { - var header = $( this ), - headerId = header.uniqueId().attr( "id" ), - panel = header.next(), - panelId = panel.uniqueId().attr( "id" ); - header.attr( "aria-controls", panelId ); - panel.attr( "aria-labelledby", headerId ); - }) - .next() - .attr( "role", "tabpanel" ); - - this.headers - .not( this.active ) - .attr({ - "aria-selected": "false", - "aria-expanded": "false", - tabIndex: -1 - }) - .next() - .attr({ - "aria-hidden": "true" - }) - .hide(); - - // make sure at least one header is in the tab order - if ( !this.active.length ) { - this.headers.eq( 0 ).attr( "tabIndex", 0 ); - } else { - this.active.attr({ - "aria-selected": "true", - "aria-expanded": "true", - tabIndex: 0 - }) - .next() - .attr({ - "aria-hidden": "false" - }); - } - - this._createIcons(); - - this._setupEvents( options.event ); - - if ( heightStyle === "fill" ) { - maxHeight = parent.height(); - this.element.siblings( ":visible" ).each(function() { - var elem = $( this ), - position = elem.css( "position" ); - - if ( position === "absolute" || position === "fixed" ) { - return; - } - maxHeight -= elem.outerHeight( true ); - }); - - this.headers.each(function() { - maxHeight -= $( this ).outerHeight( true ); - }); - - this.headers.next() - .each(function() { - $( this ).height( Math.max( 0, maxHeight - - $( this ).innerHeight() + $( this ).height() ) ); - }) - .css( "overflow", "auto" ); - } else if ( heightStyle === "auto" ) { - maxHeight = 0; - this.headers.next() - .each(function() { - maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() ); - }) - .height( maxHeight ); - } - }, - - _activate: function( index ) { - var active = this._findActive( index )[ 0 ]; - - // trying to activate the already active panel - if ( active === this.active[ 0 ] ) { - return; - } - - // trying to collapse, simulate a click on the currently active header - active = active || this.active[ 0 ]; - - this._eventHandler({ - target: active, - currentTarget: active, - preventDefault: $.noop - }); - }, - - _findActive: function( selector ) { - return typeof selector === "number" ? this.headers.eq( selector ) : $(); - }, - - _setupEvents: function( event ) { - var events = { - keydown: "_keydown" - }; - if ( event ) { - $.each( event.split( " " ), function( index, eventName ) { - events[ eventName ] = "_eventHandler"; - }); - } - - this._off( this.headers.add( this.headers.next() ) ); - this._on( this.headers, events ); - this._on( this.headers.next(), { keydown: "_panelKeyDown" }); - this._hoverable( this.headers ); - this._focusable( this.headers ); - }, - - _eventHandler: function( event ) { - var options = this.options, - active = this.active, - clicked = $( event.currentTarget ), - clickedIsActive = clicked[ 0 ] === active[ 0 ], - collapsing = clickedIsActive && options.collapsible, - toShow = collapsing ? $() : clicked.next(), - toHide = active.next(), - eventData = { - oldHeader: active, - oldPanel: toHide, - newHeader: collapsing ? $() : clicked, - newPanel: toShow - }; - - event.preventDefault(); - - if ( - // click on active header, but not collapsible - ( clickedIsActive && !options.collapsible ) || - // allow canceling activation - ( this._trigger( "beforeActivate", event, eventData ) === false ) ) { - return; - } - - options.active = collapsing ? false : this.headers.index( clicked ); - - // when the call to ._toggle() comes after the class changes - // it causes a very odd bug in IE 8 (see #6720) - this.active = clickedIsActive ? $() : clicked; - this._toggle( eventData ); - - // switch classes - // corner classes on the previously active header stay after the animation - active.removeClass( "ui-accordion-header-active ui-state-active" ); - if ( options.icons ) { - active.children( ".ui-accordion-header-icon" ) - .removeClass( options.icons.activeHeader ) - .addClass( options.icons.header ); - } - - if ( !clickedIsActive ) { - clicked - .removeClass( "ui-corner-all" ) - .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" ); - if ( options.icons ) { - clicked.children( ".ui-accordion-header-icon" ) - .removeClass( options.icons.header ) - .addClass( options.icons.activeHeader ); - } - - clicked - .next() - .addClass( "ui-accordion-content-active" ); - } - }, - - _toggle: function( data ) { - var toShow = data.newPanel, - toHide = this.prevShow.length ? this.prevShow : data.oldPanel; - - // handle activating a panel during the animation for another activation - this.prevShow.add( this.prevHide ).stop( true, true ); - this.prevShow = toShow; - this.prevHide = toHide; - - if ( this.options.animate ) { - this._animate( toShow, toHide, data ); - } else { - toHide.hide(); - toShow.show(); - this._toggleComplete( data ); - } - - toHide.attr({ - "aria-hidden": "true" - }); - toHide.prev().attr({ - "aria-selected": "false", - "aria-expanded": "false" - }); - // if we're switching panels, remove the old header from the tab order - // if we're opening from collapsed state, remove the previous header from the tab order - // if we're collapsing, then keep the collapsing header in the tab order - if ( toShow.length && toHide.length ) { - toHide.prev().attr({ - "tabIndex": -1, - "aria-expanded": "false" - }); - } else if ( toShow.length ) { - this.headers.filter(function() { - return parseInt( $( this ).attr( "tabIndex" ), 10 ) === 0; - }) - .attr( "tabIndex", -1 ); - } - - toShow - .attr( "aria-hidden", "false" ) - .prev() - .attr({ - "aria-selected": "true", - "aria-expanded": "true", - tabIndex: 0 - }); - }, - - _animate: function( toShow, toHide, data ) { - var total, easing, duration, - that = this, - adjust = 0, - boxSizing = toShow.css( "box-sizing" ), - down = toShow.length && - ( !toHide.length || ( toShow.index() < toHide.index() ) ), - animate = this.options.animate || {}, - options = down && animate.down || animate, - complete = function() { - that._toggleComplete( data ); - }; - - if ( typeof options === "number" ) { - duration = options; - } - if ( typeof options === "string" ) { - easing = options; - } - // fall back from options to animation in case of partial down settings - easing = easing || options.easing || animate.easing; - duration = duration || options.duration || animate.duration; - - if ( !toHide.length ) { - return toShow.animate( this.showProps, duration, easing, complete ); - } - if ( !toShow.length ) { - return toHide.animate( this.hideProps, duration, easing, complete ); - } - - total = toShow.show().outerHeight(); - toHide.animate( this.hideProps, { - duration: duration, - easing: easing, - step: function( now, fx ) { - fx.now = Math.round( now ); - } - }); - toShow - .hide() - .animate( this.showProps, { - duration: duration, - easing: easing, - complete: complete, - step: function( now, fx ) { - fx.now = Math.round( now ); - if ( fx.prop !== "height" ) { - if ( boxSizing === "content-box" ) { - adjust += fx.now; - } - } else if ( that.options.heightStyle !== "content" ) { - fx.now = Math.round( total - toHide.outerHeight() - adjust ); - adjust = 0; - } - } - }); - }, - - _toggleComplete: function( data ) { - var toHide = data.oldPanel; - - toHide - .removeClass( "ui-accordion-content-active" ) - .prev() - .removeClass( "ui-corner-top" ) - .addClass( "ui-corner-all" ); - - // Work around for rendering bug in IE (#5421) - if ( toHide.length ) { - toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className; - } - this._trigger( "activate", null, data ); - } -}); - - -/*! - * jQuery UI Menu 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/menu/ - */ - - -var menu = $.widget( "ui.menu", { - version: "1.11.4", - defaultElement: "<ul>", - delay: 300, - options: { - icons: { - submenu: "ui-icon-carat-1-e" - }, - items: "> *", - menus: "ul", - position: { - my: "left-1 top", - at: "right top" - }, - role: "menu", - - // callbacks - blur: null, - focus: null, - select: null - }, - - _create: function() { - this.activeMenu = this.element; - - // Flag used to prevent firing of the click handler - // as the event bubbles up through nested menus - this.mouseHandled = false; - this.element - .uniqueId() - .addClass( "ui-menu ui-widget ui-widget-content" ) - .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length ) - .attr({ - role: this.options.role, - tabIndex: 0 - }); - - if ( this.options.disabled ) { - this.element - .addClass( "ui-state-disabled" ) - .attr( "aria-disabled", "true" ); - } - - this._on({ - // Prevent focus from sticking to links inside menu after clicking - // them (focus should always stay on UL during navigation). - "mousedown .ui-menu-item": function( event ) { - event.preventDefault(); - }, - "click .ui-menu-item": function( event ) { - var target = $( event.target ); - if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) { - this.select( event ); - - // Only set the mouseHandled flag if the event will bubble, see #9469. - if ( !event.isPropagationStopped() ) { - this.mouseHandled = true; - } - - // Open submenu on click - if ( target.has( ".ui-menu" ).length ) { - this.expand( event ); - } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) { - - // Redirect focus to the menu - this.element.trigger( "focus", [ true ] ); - - // If the active item is on the top level, let it stay active. - // Otherwise, blur the active item since it is no longer visible. - if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) { - clearTimeout( this.timer ); - } - } - } - }, - "mouseenter .ui-menu-item": function( event ) { - // Ignore mouse events while typeahead is active, see #10458. - // Prevents focusing the wrong item when typeahead causes a scroll while the mouse - // is over an item in the menu - if ( this.previousFilter ) { - return; - } - var target = $( event.currentTarget ); - // Remove ui-state-active class from siblings of the newly focused menu item - // to avoid a jump caused by adjacent elements both having a class with a border - target.siblings( ".ui-state-active" ).removeClass( "ui-state-active" ); - this.focus( event, target ); - }, - mouseleave: "collapseAll", - "mouseleave .ui-menu": "collapseAll", - focus: function( event, keepActiveItem ) { - // If there's already an active item, keep it active - // If not, activate the first item - var item = this.active || this.element.find( this.options.items ).eq( 0 ); - - if ( !keepActiveItem ) { - this.focus( event, item ); - } - }, - blur: function( event ) { - this._delay(function() { - if ( !$.contains( this.element[0], this.document[0].activeElement ) ) { - this.collapseAll( event ); - } - }); - }, - keydown: "_keydown" - }); - - this.refresh(); - - // Clicks outside of a menu collapse any open menus - this._on( this.document, { - click: function( event ) { - if ( this._closeOnDocumentClick( event ) ) { - this.collapseAll( event ); - } - - // Reset the mouseHandled flag - this.mouseHandled = false; - } - }); - }, - - _destroy: function() { - // Destroy (sub)menus - this.element - .removeAttr( "aria-activedescendant" ) - .find( ".ui-menu" ).addBack() - .removeClass( "ui-menu ui-widget ui-widget-content ui-menu-icons ui-front" ) - .removeAttr( "role" ) - .removeAttr( "tabIndex" ) - .removeAttr( "aria-labelledby" ) - .removeAttr( "aria-expanded" ) - .removeAttr( "aria-hidden" ) - .removeAttr( "aria-disabled" ) - .removeUniqueId() - .show(); - - // Destroy menu items - this.element.find( ".ui-menu-item" ) - .removeClass( "ui-menu-item" ) - .removeAttr( "role" ) - .removeAttr( "aria-disabled" ) - .removeUniqueId() - .removeClass( "ui-state-hover" ) - .removeAttr( "tabIndex" ) - .removeAttr( "role" ) - .removeAttr( "aria-haspopup" ) - .children().each( function() { - var elem = $( this ); - if ( elem.data( "ui-menu-submenu-carat" ) ) { - elem.remove(); - } - }); - - // Destroy menu dividers - this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" ); - }, - - _keydown: function( event ) { - var match, prev, character, skip, - preventDefault = true; - - switch ( event.keyCode ) { - case $.ui.keyCode.PAGE_UP: - this.previousPage( event ); - break; - case $.ui.keyCode.PAGE_DOWN: - this.nextPage( event ); - break; - case $.ui.keyCode.HOME: - this._move( "first", "first", event ); - break; - case $.ui.keyCode.END: - this._move( "last", "last", event ); - break; - case $.ui.keyCode.UP: - this.previous( event ); - break; - case $.ui.keyCode.DOWN: - this.next( event ); - break; - case $.ui.keyCode.LEFT: - this.collapse( event ); - break; - case $.ui.keyCode.RIGHT: - if ( this.active && !this.active.is( ".ui-state-disabled" ) ) { - this.expand( event ); - } - break; - case $.ui.keyCode.ENTER: - case $.ui.keyCode.SPACE: - this._activate( event ); - break; - case $.ui.keyCode.ESCAPE: - this.collapse( event ); - break; - default: - preventDefault = false; - prev = this.previousFilter || ""; - character = String.fromCharCode( event.keyCode ); - skip = false; - - clearTimeout( this.filterTimer ); - - if ( character === prev ) { - skip = true; - } else { - character = prev + character; - } - - match = this._filterMenuItems( character ); - match = skip && match.index( this.active.next() ) !== -1 ? - this.active.nextAll( ".ui-menu-item" ) : - match; - - // If no matches on the current filter, reset to the last character pressed - // to move down the menu to the first item that starts with that character - if ( !match.length ) { - character = String.fromCharCode( event.keyCode ); - match = this._filterMenuItems( character ); - } - - if ( match.length ) { - this.focus( event, match ); - this.previousFilter = character; - this.filterTimer = this._delay(function() { - delete this.previousFilter; - }, 1000 ); - } else { - delete this.previousFilter; - } - } - - if ( preventDefault ) { - event.preventDefault(); - } - }, - - _activate: function( event ) { - if ( !this.active.is( ".ui-state-disabled" ) ) { - if ( this.active.is( "[aria-haspopup='true']" ) ) { - this.expand( event ); - } else { - this.select( event ); - } - } - }, - - refresh: function() { - var menus, items, - that = this, - icon = this.options.icons.submenu, - submenus = this.element.find( this.options.menus ); - - this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length ); - - // Initialize nested menus - submenus.filter( ":not(.ui-menu)" ) - .addClass( "ui-menu ui-widget ui-widget-content ui-front" ) - .hide() - .attr({ - role: this.options.role, - "aria-hidden": "true", - "aria-expanded": "false" - }) - .each(function() { - var menu = $( this ), - item = menu.parent(), - submenuCarat = $( "<span>" ) - .addClass( "ui-menu-icon ui-icon " + icon ) - .data( "ui-menu-submenu-carat", true ); - - item - .attr( "aria-haspopup", "true" ) - .prepend( submenuCarat ); - menu.attr( "aria-labelledby", item.attr( "id" ) ); - }); - - menus = submenus.add( this.element ); - items = menus.find( this.options.items ); - - // Initialize menu-items containing spaces and/or dashes only as dividers - items.not( ".ui-menu-item" ).each(function() { - var item = $( this ); - if ( that._isDivider( item ) ) { - item.addClass( "ui-widget-content ui-menu-divider" ); - } - }); - - // Don't refresh list items that are already adapted - items.not( ".ui-menu-item, .ui-menu-divider" ) - .addClass( "ui-menu-item" ) - .uniqueId() - .attr({ - tabIndex: -1, - role: this._itemRole() - }); - - // Add aria-disabled attribute to any disabled menu item - items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" ); - - // If the active item has been removed, blur the menu - if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) { - this.blur(); - } - }, - - _itemRole: function() { - return { - menu: "menuitem", - listbox: "option" - }[ this.options.role ]; - }, - - _setOption: function( key, value ) { - if ( key === "icons" ) { - this.element.find( ".ui-menu-icon" ) - .removeClass( this.options.icons.submenu ) - .addClass( value.submenu ); - } - if ( key === "disabled" ) { - this.element - .toggleClass( "ui-state-disabled", !!value ) - .attr( "aria-disabled", value ); - } - this._super( key, value ); - }, - - focus: function( event, item ) { - var nested, focused; - this.blur( event, event && event.type === "focus" ); - - this._scrollIntoView( item ); - - this.active = item.first(); - focused = this.active.addClass( "ui-state-focus" ).removeClass( "ui-state-active" ); - // Only update aria-activedescendant if there's a role - // otherwise we assume focus is managed elsewhere - if ( this.options.role ) { - this.element.attr( "aria-activedescendant", focused.attr( "id" ) ); - } - - // Highlight active parent menu item, if any - this.active - .parent() - .closest( ".ui-menu-item" ) - .addClass( "ui-state-active" ); - - if ( event && event.type === "keydown" ) { - this._close(); - } else { - this.timer = this._delay(function() { - this._close(); - }, this.delay ); - } - - nested = item.children( ".ui-menu" ); - if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) { - this._startOpening(nested); - } - this.activeMenu = item.parent(); - - this._trigger( "focus", event, { item: item } ); - }, - - _scrollIntoView: function( item ) { - var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight; - if ( this._hasScroll() ) { - borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0; - paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0; - offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop; - scroll = this.activeMenu.scrollTop(); - elementHeight = this.activeMenu.height(); - itemHeight = item.outerHeight(); - - if ( offset < 0 ) { - this.activeMenu.scrollTop( scroll + offset ); - } else if ( offset + itemHeight > elementHeight ) { - this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight ); - } - } - }, - - blur: function( event, fromFocus ) { - if ( !fromFocus ) { - clearTimeout( this.timer ); - } - - if ( !this.active ) { - return; - } - - this.active.removeClass( "ui-state-focus" ); - this.active = null; - - this._trigger( "blur", event, { item: this.active } ); - }, - - _startOpening: function( submenu ) { - clearTimeout( this.timer ); - - // Don't open if already open fixes a Firefox bug that caused a .5 pixel - // shift in the submenu position when mousing over the carat icon - if ( submenu.attr( "aria-hidden" ) !== "true" ) { - return; - } - - this.timer = this._delay(function() { - this._close(); - this._open( submenu ); - }, this.delay ); - }, - - _open: function( submenu ) { - var position = $.extend({ - of: this.active - }, this.options.position ); - - clearTimeout( this.timer ); - this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) ) - .hide() - .attr( "aria-hidden", "true" ); - - submenu - .show() - .removeAttr( "aria-hidden" ) - .attr( "aria-expanded", "true" ) - .position( position ); - }, - - collapseAll: function( event, all ) { - clearTimeout( this.timer ); - this.timer = this._delay(function() { - // If we were passed an event, look for the submenu that contains the event - var currentMenu = all ? this.element : - $( event && event.target ).closest( this.element.find( ".ui-menu" ) ); - - // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway - if ( !currentMenu.length ) { - currentMenu = this.element; - } - - this._close( currentMenu ); - - this.blur( event ); - this.activeMenu = currentMenu; - }, this.delay ); - }, - - // With no arguments, closes the currently active menu - if nothing is active - // it closes all menus. If passed an argument, it will search for menus BELOW - _close: function( startMenu ) { - if ( !startMenu ) { - startMenu = this.active ? this.active.parent() : this.element; - } - - startMenu - .find( ".ui-menu" ) - .hide() - .attr( "aria-hidden", "true" ) - .attr( "aria-expanded", "false" ) - .end() - .find( ".ui-state-active" ).not( ".ui-state-focus" ) - .removeClass( "ui-state-active" ); - }, - - _closeOnDocumentClick: function( event ) { - return !$( event.target ).closest( ".ui-menu" ).length; - }, - - _isDivider: function( item ) { - - // Match hyphen, em dash, en dash - return !/[^\-\u2014\u2013\s]/.test( item.text() ); - }, - - collapse: function( event ) { - var newItem = this.active && - this.active.parent().closest( ".ui-menu-item", this.element ); - if ( newItem && newItem.length ) { - this._close(); - this.focus( event, newItem ); - } - }, - - expand: function( event ) { - var newItem = this.active && - this.active - .children( ".ui-menu " ) - .find( this.options.items ) - .first(); - - if ( newItem && newItem.length ) { - this._open( newItem.parent() ); - - // Delay so Firefox will not hide activedescendant change in expanding submenu from AT - this._delay(function() { - this.focus( event, newItem ); - }); - } - }, - - next: function( event ) { - this._move( "next", "first", event ); - }, - - previous: function( event ) { - this._move( "prev", "last", event ); - }, - - isFirstItem: function() { - return this.active && !this.active.prevAll( ".ui-menu-item" ).length; - }, - - isLastItem: function() { - return this.active && !this.active.nextAll( ".ui-menu-item" ).length; - }, - - _move: function( direction, filter, event ) { - var next; - if ( this.active ) { - if ( direction === "first" || direction === "last" ) { - next = this.active - [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" ) - .eq( -1 ); - } else { - next = this.active - [ direction + "All" ]( ".ui-menu-item" ) - .eq( 0 ); - } - } - if ( !next || !next.length || !this.active ) { - next = this.activeMenu.find( this.options.items )[ filter ](); - } - - this.focus( event, next ); - }, - - nextPage: function( event ) { - var item, base, height; - - if ( !this.active ) { - this.next( event ); - return; - } - if ( this.isLastItem() ) { - return; - } - if ( this._hasScroll() ) { - base = this.active.offset().top; - height = this.element.height(); - this.active.nextAll( ".ui-menu-item" ).each(function() { - item = $( this ); - return item.offset().top - base - height < 0; - }); - - this.focus( event, item ); - } else { - this.focus( event, this.activeMenu.find( this.options.items ) - [ !this.active ? "first" : "last" ]() ); - } - }, - - previousPage: function( event ) { - var item, base, height; - if ( !this.active ) { - this.next( event ); - return; - } - if ( this.isFirstItem() ) { - return; - } - if ( this._hasScroll() ) { - base = this.active.offset().top; - height = this.element.height(); - this.active.prevAll( ".ui-menu-item" ).each(function() { - item = $( this ); - return item.offset().top - base + height > 0; - }); - - this.focus( event, item ); - } else { - this.focus( event, this.activeMenu.find( this.options.items ).first() ); - } - }, - - _hasScroll: function() { - return this.element.outerHeight() < this.element.prop( "scrollHeight" ); - }, - - select: function( event ) { - // TODO: It should never be possible to not have an active item at this - // point, but the tests don't trigger mouseenter before click. - this.active = this.active || $( event.target ).closest( ".ui-menu-item" ); - var ui = { item: this.active }; - if ( !this.active.has( ".ui-menu" ).length ) { - this.collapseAll( event, true ); - } - this._trigger( "select", event, ui ); - }, - - _filterMenuItems: function(character) { - var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ), - regex = new RegExp( "^" + escapedCharacter, "i" ); - - return this.activeMenu - .find( this.options.items ) - - // Only match on items, not dividers or other content (#10571) - .filter( ".ui-menu-item" ) - .filter(function() { - return regex.test( $.trim( $( this ).text() ) ); - }); - } -}); - - -/*! - * jQuery UI Autocomplete 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/autocomplete/ - */ - - -$.widget( "ui.autocomplete", { - version: "1.11.4", - defaultElement: "<input>", - options: { - appendTo: null, - autoFocus: false, - delay: 300, - minLength: 1, - position: { - my: "left top", - at: "left bottom", - collision: "none" - }, - source: null, - - // callbacks - change: null, - close: null, - focus: null, - open: null, - response: null, - search: null, - select: null - }, - - requestIndex: 0, - pending: 0, - - _create: function() { - // Some browsers only repeat keydown events, not keypress events, - // so we use the suppressKeyPress flag to determine if we've already - // handled the keydown event. #7269 - // Unfortunately the code for & in keypress is the same as the up arrow, - // so we use the suppressKeyPressRepeat flag to avoid handling keypress - // events when we know the keydown event was used to modify the - // search term. #7799 - var suppressKeyPress, suppressKeyPressRepeat, suppressInput, - nodeName = this.element[ 0 ].nodeName.toLowerCase(), - isTextarea = nodeName === "textarea", - isInput = nodeName === "input"; - - this.isMultiLine = - // Textareas are always multi-line - isTextarea ? true : - // Inputs are always single-line, even if inside a contentEditable element - // IE also treats inputs as contentEditable - isInput ? false : - // All other element types are determined by whether or not they're contentEditable - this.element.prop( "isContentEditable" ); - - this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ]; - this.isNewMenu = true; - - this.element - .addClass( "ui-autocomplete-input" ) - .attr( "autocomplete", "off" ); - - this._on( this.element, { - keydown: function( event ) { - if ( this.element.prop( "readOnly" ) ) { - suppressKeyPress = true; - suppressInput = true; - suppressKeyPressRepeat = true; - return; - } - - suppressKeyPress = false; - suppressInput = false; - suppressKeyPressRepeat = false; - var keyCode = $.ui.keyCode; - switch ( event.keyCode ) { - case keyCode.PAGE_UP: - suppressKeyPress = true; - this._move( "previousPage", event ); - break; - case keyCode.PAGE_DOWN: - suppressKeyPress = true; - this._move( "nextPage", event ); - break; - case keyCode.UP: - suppressKeyPress = true; - this._keyEvent( "previous", event ); - break; - case keyCode.DOWN: - suppressKeyPress = true; - this._keyEvent( "next", event ); - break; - case keyCode.ENTER: - // when menu is open and has focus - if ( this.menu.active ) { - // #6055 - Opera still allows the keypress to occur - // which causes forms to submit - suppressKeyPress = true; - event.preventDefault(); - this.menu.select( event ); - } - break; - case keyCode.TAB: - if ( this.menu.active ) { - this.menu.select( event ); - } - break; - case keyCode.ESCAPE: - if ( this.menu.element.is( ":visible" ) ) { - if ( !this.isMultiLine ) { - this._value( this.term ); - } - this.close( event ); - // Different browsers have different default behavior for escape - // Single press can mean undo or clear - // Double press in IE means clear the whole form - event.preventDefault(); - } - break; - default: - suppressKeyPressRepeat = true; - // search timeout should be triggered before the input value is changed - this._searchTimeout( event ); - break; - } - }, - keypress: function( event ) { - if ( suppressKeyPress ) { - suppressKeyPress = false; - if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) { - event.preventDefault(); - } - return; - } - if ( suppressKeyPressRepeat ) { - return; - } - - // replicate some key handlers to allow them to repeat in Firefox and Opera - var keyCode = $.ui.keyCode; - switch ( event.keyCode ) { - case keyCode.PAGE_UP: - this._move( "previousPage", event ); - break; - case keyCode.PAGE_DOWN: - this._move( "nextPage", event ); - break; - case keyCode.UP: - this._keyEvent( "previous", event ); - break; - case keyCode.DOWN: - this._keyEvent( "next", event ); - break; - } - }, - input: function( event ) { - if ( suppressInput ) { - suppressInput = false; - event.preventDefault(); - return; - } - this._searchTimeout( event ); - }, - focus: function() { - this.selectedItem = null; - this.previous = this._value(); - }, - blur: function( event ) { - if ( this.cancelBlur ) { - delete this.cancelBlur; - return; - } - - clearTimeout( this.searching ); - this.close( event ); - this._change( event ); - } - }); - - this._initSource(); - this.menu = $( "<ul>" ) - .addClass( "ui-autocomplete ui-front" ) - .appendTo( this._appendTo() ) - .menu({ - // disable ARIA support, the live region takes care of that - role: null - }) - .hide() - .menu( "instance" ); - - this._on( this.menu.element, { - mousedown: function( event ) { - // prevent moving focus out of the text field - event.preventDefault(); - - // IE doesn't prevent moving focus even with event.preventDefault() - // so we set a flag to know when we should ignore the blur event - this.cancelBlur = true; - this._delay(function() { - delete this.cancelBlur; - }); - - // clicking on the scrollbar causes focus to shift to the body - // but we can't detect a mouseup or a click immediately afterward - // so we have to track the next mousedown and close the menu if - // the user clicks somewhere outside of the autocomplete - var menuElement = this.menu.element[ 0 ]; - if ( !$( event.target ).closest( ".ui-menu-item" ).length ) { - this._delay(function() { - var that = this; - this.document.one( "mousedown", function( event ) { - if ( event.target !== that.element[ 0 ] && - event.target !== menuElement && - !$.contains( menuElement, event.target ) ) { - that.close(); - } - }); - }); - } - }, - menufocus: function( event, ui ) { - var label, item; - // support: Firefox - // Prevent accidental activation of menu items in Firefox (#7024 #9118) - if ( this.isNewMenu ) { - this.isNewMenu = false; - if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) { - this.menu.blur(); - - this.document.one( "mousemove", function() { - $( event.target ).trigger( event.originalEvent ); - }); - - return; - } - } - - item = ui.item.data( "ui-autocomplete-item" ); - if ( false !== this._trigger( "focus", event, { item: item } ) ) { - // use value to match what will end up in the input, if it was a key event - if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) { - this._value( item.value ); - } - } - - // Announce the value in the liveRegion - label = ui.item.attr( "aria-label" ) || item.value; - if ( label && $.trim( label ).length ) { - this.liveRegion.children().hide(); - $( "<div>" ).text( label ).appendTo( this.liveRegion ); - } - }, - menuselect: function( event, ui ) { - var item = ui.item.data( "ui-autocomplete-item" ), - previous = this.previous; - - // only trigger when focus was lost (click on menu) - if ( this.element[ 0 ] !== this.document[ 0 ].activeElement ) { - this.element.focus(); - this.previous = previous; - // #6109 - IE triggers two focus events and the second - // is asynchronous, so we need to reset the previous - // term synchronously and asynchronously :-( - this._delay(function() { - this.previous = previous; - this.selectedItem = item; - }); - } - - if ( false !== this._trigger( "select", event, { item: item } ) ) { - this._value( item.value ); - } - // reset the term after the select event - // this allows custom select handling to work properly - this.term = this._value(); - - this.close( event ); - this.selectedItem = item; - } - }); - - this.liveRegion = $( "<span>", { - role: "status", - "aria-live": "assertive", - "aria-relevant": "additions" - }) - .addClass( "ui-helper-hidden-accessible" ) - .appendTo( this.document[ 0 ].body ); - - // turning off autocomplete prevents the browser from remembering the - // value when navigating through history, so we re-enable autocomplete - // if the page is unloaded before the widget is destroyed. #7790 - this._on( this.window, { - beforeunload: function() { - this.element.removeAttr( "autocomplete" ); - } - }); - }, - - _destroy: function() { - clearTimeout( this.searching ); - this.element - .removeClass( "ui-autocomplete-input" ) - .removeAttr( "autocomplete" ); - this.menu.element.remove(); - this.liveRegion.remove(); - }, - - _setOption: function( key, value ) { - this._super( key, value ); - if ( key === "source" ) { - this._initSource(); - } - if ( key === "appendTo" ) { - this.menu.element.appendTo( this._appendTo() ); - } - if ( key === "disabled" && value && this.xhr ) { - this.xhr.abort(); - } - }, - - _appendTo: function() { - var element = this.options.appendTo; - - if ( element ) { - element = element.jquery || element.nodeType ? - $( element ) : - this.document.find( element ).eq( 0 ); - } - - if ( !element || !element[ 0 ] ) { - element = this.element.closest( ".ui-front" ); - } - - if ( !element.length ) { - element = this.document[ 0 ].body; - } - - return element; - }, - - _initSource: function() { - var array, url, - that = this; - if ( $.isArray( this.options.source ) ) { - array = this.options.source; - this.source = function( request, response ) { - response( $.ui.autocomplete.filter( array, request.term ) ); - }; - } else if ( typeof this.options.source === "string" ) { - url = this.options.source; - this.source = function( request, response ) { - if ( that.xhr ) { - that.xhr.abort(); - } - that.xhr = $.ajax({ - url: url, - data: request, - dataType: "json", - success: function( data ) { - response( data ); - }, - error: function() { - response([]); - } - }); - }; - } else { - this.source = this.options.source; - } - }, - - _searchTimeout: function( event ) { - clearTimeout( this.searching ); - this.searching = this._delay(function() { - - // Search if the value has changed, or if the user retypes the same value (see #7434) - var equalValues = this.term === this._value(), - menuVisible = this.menu.element.is( ":visible" ), - modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey; - - if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) { - this.selectedItem = null; - this.search( null, event ); - } - }, this.options.delay ); - }, - - search: function( value, event ) { - value = value != null ? value : this._value(); - - // always save the actual value, not the one passed as an argument - this.term = this._value(); - - if ( value.length < this.options.minLength ) { - return this.close( event ); - } - - if ( this._trigger( "search", event ) === false ) { - return; - } - - return this._search( value ); - }, - - _search: function( value ) { - this.pending++; - this.element.addClass( "ui-autocomplete-loading" ); - this.cancelSearch = false; - - this.source( { term: value }, this._response() ); - }, - - _response: function() { - var index = ++this.requestIndex; - - return $.proxy(function( content ) { - if ( index === this.requestIndex ) { - this.__response( content ); - } - - this.pending--; - if ( !this.pending ) { - this.element.removeClass( "ui-autocomplete-loading" ); - } - }, this ); - }, - - __response: function( content ) { - if ( content ) { - content = this._normalize( content ); - } - this._trigger( "response", null, { content: content } ); - if ( !this.options.disabled && content && content.length && !this.cancelSearch ) { - this._suggest( content ); - this._trigger( "open" ); - } else { - // use ._close() instead of .close() so we don't cancel future searches - this._close(); - } - }, - - close: function( event ) { - this.cancelSearch = true; - this._close( event ); - }, - - _close: function( event ) { - if ( this.menu.element.is( ":visible" ) ) { - this.menu.element.hide(); - this.menu.blur(); - this.isNewMenu = true; - this._trigger( "close", event ); - } - }, - - _change: function( event ) { - if ( this.previous !== this._value() ) { - this._trigger( "change", event, { item: this.selectedItem } ); - } - }, - - _normalize: function( items ) { - // assume all items have the right format when the first item is complete - if ( items.length && items[ 0 ].label && items[ 0 ].value ) { - return items; - } - return $.map( items, function( item ) { - if ( typeof item === "string" ) { - return { - label: item, - value: item - }; - } - return $.extend( {}, item, { - label: item.label || item.value, - value: item.value || item.label - }); - }); - }, - - _suggest: function( items ) { - var ul = this.menu.element.empty(); - this._renderMenu( ul, items ); - this.isNewMenu = true; - this.menu.refresh(); - - // size and position menu - ul.show(); - this._resizeMenu(); - ul.position( $.extend({ - of: this.element - }, this.options.position ) ); - - if ( this.options.autoFocus ) { - this.menu.next(); - } - }, - - _resizeMenu: function() { - var ul = this.menu.element; - ul.outerWidth( Math.max( - // Firefox wraps long text (possibly a rounding bug) - // so we add 1px to avoid the wrapping (#7513) - ul.width( "" ).outerWidth() + 1, - this.element.outerWidth() - ) ); - }, - - _renderMenu: function( ul, items ) { - var that = this; - $.each( items, function( index, item ) { - that._renderItemData( ul, item ); - }); - }, - - _renderItemData: function( ul, item ) { - return this._renderItem( ul, item ).data( "ui-autocomplete-item", item ); - }, - - _renderItem: function( ul, item ) { - return $( "<li>" ).text( item.label ).appendTo( ul ); - }, - - _move: function( direction, event ) { - if ( !this.menu.element.is( ":visible" ) ) { - this.search( null, event ); - return; - } - if ( this.menu.isFirstItem() && /^previous/.test( direction ) || - this.menu.isLastItem() && /^next/.test( direction ) ) { - - if ( !this.isMultiLine ) { - this._value( this.term ); - } - - this.menu.blur(); - return; - } - this.menu[ direction ]( event ); - }, - - widget: function() { - return this.menu.element; - }, - - _value: function() { - return this.valueMethod.apply( this.element, arguments ); - }, - - _keyEvent: function( keyEvent, event ) { - if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) { - this._move( keyEvent, event ); - - // prevents moving cursor to beginning/end of the text field in some browsers - event.preventDefault(); - } - } -}); - -$.extend( $.ui.autocomplete, { - escapeRegex: function( value ) { - return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ); - }, - filter: function( array, term ) { - var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" ); - return $.grep( array, function( value ) { - return matcher.test( value.label || value.value || value ); - }); - } -}); - -// live region extension, adding a `messages` option -// NOTE: This is an experimental API. We are still investigating -// a full solution for string manipulation and internationalization. -$.widget( "ui.autocomplete", $.ui.autocomplete, { - options: { - messages: { - noResults: "No search results.", - results: function( amount ) { - return amount + ( amount > 1 ? " results are" : " result is" ) + - " available, use up and down arrow keys to navigate."; - } - } - }, - - __response: function( content ) { - var message; - this._superApply( arguments ); - if ( this.options.disabled || this.cancelSearch ) { - return; - } - if ( content && content.length ) { - message = this.options.messages.results( content.length ); - } else { - message = this.options.messages.noResults; - } - this.liveRegion.children().hide(); - $( "<div>" ).text( message ).appendTo( this.liveRegion ); - } -}); - -var autocomplete = $.ui.autocomplete; - - -/*! - * jQuery UI Button 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/button/ - */ - - -var lastActive, - baseClasses = "ui-button ui-widget ui-state-default ui-corner-all", - typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only", - formResetHandler = function() { - var form = $( this ); - setTimeout(function() { - form.find( ":ui-button" ).button( "refresh" ); - }, 1 ); - }, - radioGroup = function( radio ) { - var name = radio.name, - form = radio.form, - radios = $( [] ); - if ( name ) { - name = name.replace( /'/g, "\\'" ); - if ( form ) { - radios = $( form ).find( "[name='" + name + "'][type=radio]" ); - } else { - radios = $( "[name='" + name + "'][type=radio]", radio.ownerDocument ) - .filter(function() { - return !this.form; - }); - } - } - return radios; - }; - -$.widget( "ui.button", { - version: "1.11.4", - defaultElement: "<button>", - options: { - disabled: null, - text: true, - label: null, - icons: { - primary: null, - secondary: null - } - }, - _create: function() { - this.element.closest( "form" ) - .unbind( "reset" + this.eventNamespace ) - .bind( "reset" + this.eventNamespace, formResetHandler ); - - if ( typeof this.options.disabled !== "boolean" ) { - this.options.disabled = !!this.element.prop( "disabled" ); - } else { - this.element.prop( "disabled", this.options.disabled ); - } - - this._determineButtonType(); - this.hasTitle = !!this.buttonElement.attr( "title" ); - - var that = this, - options = this.options, - toggleButton = this.type === "checkbox" || this.type === "radio", - activeClass = !toggleButton ? "ui-state-active" : ""; - - if ( options.label === null ) { - options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html()); - } - - this._hoverable( this.buttonElement ); - - this.buttonElement - .addClass( baseClasses ) - .attr( "role", "button" ) - .bind( "mouseenter" + this.eventNamespace, function() { - if ( options.disabled ) { - return; - } - if ( this === lastActive ) { - $( this ).addClass( "ui-state-active" ); - } - }) - .bind( "mouseleave" + this.eventNamespace, function() { - if ( options.disabled ) { - return; - } - $( this ).removeClass( activeClass ); - }) - .bind( "click" + this.eventNamespace, function( event ) { - if ( options.disabled ) { - event.preventDefault(); - event.stopImmediatePropagation(); - } - }); - - // Can't use _focusable() because the element that receives focus - // and the element that gets the ui-state-focus class are different - this._on({ - focus: function() { - this.buttonElement.addClass( "ui-state-focus" ); - }, - blur: function() { - this.buttonElement.removeClass( "ui-state-focus" ); - } - }); - - if ( toggleButton ) { - this.element.bind( "change" + this.eventNamespace, function() { - that.refresh(); - }); - } - - if ( this.type === "checkbox" ) { - this.buttonElement.bind( "click" + this.eventNamespace, function() { - if ( options.disabled ) { - return false; - } - }); - } else if ( this.type === "radio" ) { - this.buttonElement.bind( "click" + this.eventNamespace, function() { - if ( options.disabled ) { - return false; - } - $( this ).addClass( "ui-state-active" ); - that.buttonElement.attr( "aria-pressed", "true" ); - - var radio = that.element[ 0 ]; - radioGroup( radio ) - .not( radio ) - .map(function() { - return $( this ).button( "widget" )[ 0 ]; - }) - .removeClass( "ui-state-active" ) - .attr( "aria-pressed", "false" ); - }); - } else { - this.buttonElement - .bind( "mousedown" + this.eventNamespace, function() { - if ( options.disabled ) { - return false; - } - $( this ).addClass( "ui-state-active" ); - lastActive = this; - that.document.one( "mouseup", function() { - lastActive = null; - }); - }) - .bind( "mouseup" + this.eventNamespace, function() { - if ( options.disabled ) { - return false; - } - $( this ).removeClass( "ui-state-active" ); - }) - .bind( "keydown" + this.eventNamespace, function(event) { - if ( options.disabled ) { - return false; - } - if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) { - $( this ).addClass( "ui-state-active" ); - } - }) - // see #8559, we bind to blur here in case the button element loses - // focus between keydown and keyup, it would be left in an "active" state - .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() { - $( this ).removeClass( "ui-state-active" ); - }); - - if ( this.buttonElement.is("a") ) { - this.buttonElement.keyup(function(event) { - if ( event.keyCode === $.ui.keyCode.SPACE ) { - // TODO pass through original event correctly (just as 2nd argument doesn't work) - $( this ).click(); - } - }); - } - } - - this._setOption( "disabled", options.disabled ); - this._resetButton(); - }, - - _determineButtonType: function() { - var ancestor, labelSelector, checked; - - if ( this.element.is("[type=checkbox]") ) { - this.type = "checkbox"; - } else if ( this.element.is("[type=radio]") ) { - this.type = "radio"; - } else if ( this.element.is("input") ) { - this.type = "input"; - } else { - this.type = "button"; - } - - if ( this.type === "checkbox" || this.type === "radio" ) { - // we don't search against the document in case the element - // is disconnected from the DOM - ancestor = this.element.parents().last(); - labelSelector = "label[for='" + this.element.attr("id") + "']"; - this.buttonElement = ancestor.find( labelSelector ); - if ( !this.buttonElement.length ) { - ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings(); - this.buttonElement = ancestor.filter( labelSelector ); - if ( !this.buttonElement.length ) { - this.buttonElement = ancestor.find( labelSelector ); - } - } - this.element.addClass( "ui-helper-hidden-accessible" ); - - checked = this.element.is( ":checked" ); - if ( checked ) { - this.buttonElement.addClass( "ui-state-active" ); - } - this.buttonElement.prop( "aria-pressed", checked ); - } else { - this.buttonElement = this.element; - } - }, - - widget: function() { - return this.buttonElement; - }, - - _destroy: function() { - this.element - .removeClass( "ui-helper-hidden-accessible" ); - this.buttonElement - .removeClass( baseClasses + " ui-state-active " + typeClasses ) - .removeAttr( "role" ) - .removeAttr( "aria-pressed" ) - .html( this.buttonElement.find(".ui-button-text").html() ); - - if ( !this.hasTitle ) { - this.buttonElement.removeAttr( "title" ); - } - }, - - _setOption: function( key, value ) { - this._super( key, value ); - if ( key === "disabled" ) { - this.widget().toggleClass( "ui-state-disabled", !!value ); - this.element.prop( "disabled", !!value ); - if ( value ) { - if ( this.type === "checkbox" || this.type === "radio" ) { - this.buttonElement.removeClass( "ui-state-focus" ); - } else { - this.buttonElement.removeClass( "ui-state-focus ui-state-active" ); - } - } - return; - } - this._resetButton(); - }, - - refresh: function() { - //See #8237 & #8828 - var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" ); - - if ( isDisabled !== this.options.disabled ) { - this._setOption( "disabled", isDisabled ); - } - if ( this.type === "radio" ) { - radioGroup( this.element[0] ).each(function() { - if ( $( this ).is( ":checked" ) ) { - $( this ).button( "widget" ) - .addClass( "ui-state-active" ) - .attr( "aria-pressed", "true" ); - } else { - $( this ).button( "widget" ) - .removeClass( "ui-state-active" ) - .attr( "aria-pressed", "false" ); - } - }); - } else if ( this.type === "checkbox" ) { - if ( this.element.is( ":checked" ) ) { - this.buttonElement - .addClass( "ui-state-active" ) - .attr( "aria-pressed", "true" ); - } else { - this.buttonElement - .removeClass( "ui-state-active" ) - .attr( "aria-pressed", "false" ); - } - } - }, - - _resetButton: function() { - if ( this.type === "input" ) { - if ( this.options.label ) { - this.element.val( this.options.label ); - } - return; - } - var buttonElement = this.buttonElement.removeClass( typeClasses ), - buttonText = $( "<span></span>", this.document[0] ) - .addClass( "ui-button-text" ) - .html( this.options.label ) - .appendTo( buttonElement.empty() ) - .text(), - icons = this.options.icons, - multipleIcons = icons.primary && icons.secondary, - buttonClasses = []; - - if ( icons.primary || icons.secondary ) { - if ( this.options.text ) { - buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) ); - } - - if ( icons.primary ) { - buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" ); - } - - if ( icons.secondary ) { - buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" ); - } - - if ( !this.options.text ) { - buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" ); - - if ( !this.hasTitle ) { - buttonElement.attr( "title", $.trim( buttonText ) ); - } - } - } else { - buttonClasses.push( "ui-button-text-only" ); - } - buttonElement.addClass( buttonClasses.join( " " ) ); - } -}); - -$.widget( "ui.buttonset", { - version: "1.11.4", - options: { - items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)" - }, - - _create: function() { - this.element.addClass( "ui-buttonset" ); - }, - - _init: function() { - this.refresh(); - }, - - _setOption: function( key, value ) { - if ( key === "disabled" ) { - this.buttons.button( "option", key, value ); - } - - this._super( key, value ); - }, - - refresh: function() { - var rtl = this.element.css( "direction" ) === "rtl", - allButtons = this.element.find( this.options.items ), - existingButtons = allButtons.filter( ":ui-button" ); - - // Initialize new buttons - allButtons.not( ":ui-button" ).button(); - - // Refresh existing buttons - existingButtons.button( "refresh" ); - - this.buttons = allButtons - .map(function() { - return $( this ).button( "widget" )[ 0 ]; - }) - .removeClass( "ui-corner-all ui-corner-left ui-corner-right" ) - .filter( ":first" ) - .addClass( rtl ? "ui-corner-right" : "ui-corner-left" ) - .end() - .filter( ":last" ) - .addClass( rtl ? "ui-corner-left" : "ui-corner-right" ) - .end() - .end(); - }, - - _destroy: function() { - this.element.removeClass( "ui-buttonset" ); - this.buttons - .map(function() { - return $( this ).button( "widget" )[ 0 ]; - }) - .removeClass( "ui-corner-left ui-corner-right" ) - .end() - .button( "destroy" ); - } -}); - -var button = $.ui.button; - - -/*! - * jQuery UI Datepicker 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/datepicker/ - */ - - -$.extend($.ui, { datepicker: { version: "1.11.4" } }); - -var datepicker_instActive; - -function datepicker_getZindex( elem ) { - var position, value; - while ( elem.length && elem[ 0 ] !== document ) { - // Ignore z-index if position is set to a value where z-index is ignored by the browser - // This makes behavior of this function consistent across browsers - // WebKit always returns auto if the element is positioned - position = elem.css( "position" ); - if ( position === "absolute" || position === "relative" || position === "fixed" ) { - // IE returns 0 when zIndex is not specified - // other browsers return a string - // we ignore the case of nested elements with an explicit value of 0 - // <div style="z-index: -10;"><div style="z-index: 0;"></div></div> - value = parseInt( elem.css( "zIndex" ), 10 ); - if ( !isNaN( value ) && value !== 0 ) { - return value; - } - } - elem = elem.parent(); - } - - return 0; -} -/* Date picker manager. - Use the singleton instance of this class, $.datepicker, to interact with the date picker. - Settings for (groups of) date pickers are maintained in an instance object, - allowing multiple different settings on the same page. */ - -function Datepicker() { - this._curInst = null; // The current instance in use - this._keyEvent = false; // If the last event was a key event - this._disabledInputs = []; // List of date picker inputs that have been disabled - this._datepickerShowing = false; // True if the popup picker is showing , false if not - this._inDialog = false; // True if showing within a "dialog", false if not - this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division - this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class - this._appendClass = "ui-datepicker-append"; // The name of the append marker class - this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class - this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class - this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class - this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class - this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class - this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class - this.regional = []; // Available regional settings, indexed by language code - this.regional[""] = { // Default regional settings - closeText: "Done", // Display text for close link - prevText: "Prev", // Display text for previous month link - nextText: "Next", // Display text for next month link - currentText: "Today", // Display text for current month link - monthNames: ["January","February","March","April","May","June", - "July","August","September","October","November","December"], // Names of months for drop-down and formatting - monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting - dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting - dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting - dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday - weekHeader: "Wk", // Column header for week of the year - dateFormat: "mm/dd/yy", // See format options on parseDate - firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ... - isRTL: false, // True if right-to-left language, false if left-to-right - showMonthAfterYear: false, // True if the year select precedes month, false for month then year - yearSuffix: "" // Additional text to append to the year in the month headers - }; - this._defaults = { // Global defaults for all the date picker instances - showOn: "focus", // "focus" for popup on focus, - // "button" for trigger button, or "both" for either - showAnim: "fadeIn", // Name of jQuery animation for popup - showOptions: {}, // Options for enhanced animations - defaultDate: null, // Used when field is blank: actual date, - // +/-number for offset from today, null for today - appendText: "", // Display text following the input box, e.g. showing the format - buttonText: "...", // Text for trigger button - buttonImage: "", // URL for trigger button image - buttonImageOnly: false, // True if the image appears alone, false if it appears on a button - hideIfNoPrevNext: false, // True to hide next/previous month links - // if not applicable, false to just disable them - navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links - gotoCurrent: false, // True if today link goes back to current selection instead - changeMonth: false, // True if month can be selected directly, false if only prev/next - changeYear: false, // True if year can be selected directly, false if only prev/next - yearRange: "c-10:c+10", // Range of years to display in drop-down, - // either relative to today's year (-nn:+nn), relative to currently displayed year - // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n) - showOtherMonths: false, // True to show dates in other months, false to leave blank - selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable - showWeek: false, // True to show week of the year, false to not show it - calculateWeek: this.iso8601Week, // How to calculate the week of the year, - // takes a Date and returns the number of the week for it - shortYearCutoff: "+10", // Short year values < this are in the current century, - // > this are in the previous century, - // string value starting with "+" for current year + value - minDate: null, // The earliest selectable date, or null for no limit - maxDate: null, // The latest selectable date, or null for no limit - duration: "fast", // Duration of display/closure - beforeShowDay: null, // Function that takes a date and returns an array with - // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "", - // [2] = cell title (optional), e.g. $.datepicker.noWeekends - beforeShow: null, // Function that takes an input field and - // returns a set of custom settings for the date picker - onSelect: null, // Define a callback function when a date is selected - onChangeMonthYear: null, // Define a callback function when the month or year is changed - onClose: null, // Define a callback function when the datepicker is closed - numberOfMonths: 1, // Number of months to show at a time - showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0) - stepMonths: 1, // Number of months to step back/forward - stepBigMonths: 12, // Number of months to step back/forward for the big links - altField: "", // Selector for an alternate field to store selected dates into - altFormat: "", // The date format to use for the alternate field - constrainInput: true, // The input is constrained by the current date format - showButtonPanel: false, // True to show button panel, false to not show it - autoSize: false, // True to size the input for the date format, false to leave as is - disabled: false // The initial disabled state - }; - $.extend(this._defaults, this.regional[""]); - this.regional.en = $.extend( true, {}, this.regional[ "" ]); - this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en ); - this.dpDiv = datepicker_bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")); -} - -$.extend(Datepicker.prototype, { - /* Class name added to elements to indicate already configured with a date picker. */ - markerClassName: "hasDatepicker", - - //Keep track of the maximum number of rows displayed (see #7043) - maxRows: 4, - - // TODO rename to "widget" when switching to widget factory - _widgetDatepicker: function() { - return this.dpDiv; - }, - - /* Override the default settings for all instances of the date picker. - * @param settings object - the new settings to use as defaults (anonymous object) - * @return the manager object - */ - setDefaults: function(settings) { - datepicker_extendRemove(this._defaults, settings || {}); - return this; - }, - - /* Attach the date picker to a jQuery selection. - * @param target element - the target input field or division or span - * @param settings object - the new settings to use for this date picker instance (anonymous) - */ - _attachDatepicker: function(target, settings) { - var nodeName, inline, inst; - nodeName = target.nodeName.toLowerCase(); - inline = (nodeName === "div" || nodeName === "span"); - if (!target.id) { - this.uuid += 1; - target.id = "dp" + this.uuid; - } - inst = this._newInst($(target), inline); - inst.settings = $.extend({}, settings || {}); - if (nodeName === "input") { - this._connectDatepicker(target, inst); - } else if (inline) { - this._inlineDatepicker(target, inst); - } - }, - - /* Create a new instance object. */ - _newInst: function(target, inline) { - var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars - return {id: id, input: target, // associated target - selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection - drawMonth: 0, drawYear: 0, // month being drawn - inline: inline, // is datepicker inline or not - dpDiv: (!inline ? this.dpDiv : // presentation div - datepicker_bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))}; - }, - - /* Attach the date picker to an input field. */ - _connectDatepicker: function(target, inst) { - var input = $(target); - inst.append = $([]); - inst.trigger = $([]); - if (input.hasClass(this.markerClassName)) { - return; - } - this._attachments(input, inst); - input.addClass(this.markerClassName).keydown(this._doKeyDown). - keypress(this._doKeyPress).keyup(this._doKeyUp); - this._autoSize(inst); - $.data(target, "datepicker", inst); - //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665) - if( inst.settings.disabled ) { - this._disableDatepicker( target ); - } - }, - - /* Make attachments based on settings. */ - _attachments: function(input, inst) { - var showOn, buttonText, buttonImage, - appendText = this._get(inst, "appendText"), - isRTL = this._get(inst, "isRTL"); - - if (inst.append) { - inst.append.remove(); - } - if (appendText) { - inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>"); - input[isRTL ? "before" : "after"](inst.append); - } - - input.unbind("focus", this._showDatepicker); - - if (inst.trigger) { - inst.trigger.remove(); - } - - showOn = this._get(inst, "showOn"); - if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field - input.focus(this._showDatepicker); - } - if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked - buttonText = this._get(inst, "buttonText"); - buttonImage = this._get(inst, "buttonImage"); - inst.trigger = $(this._get(inst, "buttonImageOnly") ? - $("<img/>").addClass(this._triggerClass). - attr({ src: buttonImage, alt: buttonText, title: buttonText }) : - $("<button type='button'></button>").addClass(this._triggerClass). - html(!buttonImage ? buttonText : $("<img/>").attr( - { src:buttonImage, alt:buttonText, title:buttonText }))); - input[isRTL ? "before" : "after"](inst.trigger); - inst.trigger.click(function() { - if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) { - $.datepicker._hideDatepicker(); - } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) { - $.datepicker._hideDatepicker(); - $.datepicker._showDatepicker(input[0]); - } else { - $.datepicker._showDatepicker(input[0]); - } - return false; - }); - } - }, - - /* Apply the maximum length for the date format. */ - _autoSize: function(inst) { - if (this._get(inst, "autoSize") && !inst.inline) { - var findMax, max, maxI, i, - date = new Date(2009, 12 - 1, 20), // Ensure double digits - dateFormat = this._get(inst, "dateFormat"); - - if (dateFormat.match(/[DM]/)) { - findMax = function(names) { - max = 0; - maxI = 0; - for (i = 0; i < names.length; i++) { - if (names[i].length > max) { - max = names[i].length; - maxI = i; - } - } - return maxI; - }; - date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ? - "monthNames" : "monthNamesShort")))); - date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ? - "dayNames" : "dayNamesShort"))) + 20 - date.getDay()); - } - inst.input.attr("size", this._formatDate(inst, date).length); - } - }, - - /* Attach an inline date picker to a div. */ - _inlineDatepicker: function(target, inst) { - var divSpan = $(target); - if (divSpan.hasClass(this.markerClassName)) { - return; - } - divSpan.addClass(this.markerClassName).append(inst.dpDiv); - $.data(target, "datepicker", inst); - this._setDate(inst, this._getDefaultDate(inst), true); - this._updateDatepicker(inst); - this._updateAlternate(inst); - //If disabled option is true, disable the datepicker before showing it (see ticket #5665) - if( inst.settings.disabled ) { - this._disableDatepicker( target ); - } - // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements - // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height - inst.dpDiv.css( "display", "block" ); - }, - - /* Pop-up the date picker in a "dialog" box. - * @param input element - ignored - * @param date string or Date - the initial date to display - * @param onSelect function - the function to call when a date is selected - * @param settings object - update the dialog date picker instance's settings (anonymous object) - * @param pos int[2] - coordinates for the dialog's position within the screen or - * event - with x/y coordinates or - * leave empty for default (screen centre) - * @return the manager object - */ - _dialogDatepicker: function(input, date, onSelect, settings, pos) { - var id, browserWidth, browserHeight, scrollX, scrollY, - inst = this._dialogInst; // internal instance - - if (!inst) { - this.uuid += 1; - id = "dp" + this.uuid; - this._dialogInput = $("<input type='text' id='" + id + - "' style='position: absolute; top: -100px; width: 0px;'/>"); - this._dialogInput.keydown(this._doKeyDown); - $("body").append(this._dialogInput); - inst = this._dialogInst = this._newInst(this._dialogInput, false); - inst.settings = {}; - $.data(this._dialogInput[0], "datepicker", inst); - } - datepicker_extendRemove(inst.settings, settings || {}); - date = (date && date.constructor === Date ? this._formatDate(inst, date) : date); - this._dialogInput.val(date); - - this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null); - if (!this._pos) { - browserWidth = document.documentElement.clientWidth; - browserHeight = document.documentElement.clientHeight; - scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; - scrollY = document.documentElement.scrollTop || document.body.scrollTop; - this._pos = // should use actual width/height below - [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY]; - } - - // move input on screen for focus, but hidden behind dialog - this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px"); - inst.settings.onSelect = onSelect; - this._inDialog = true; - this.dpDiv.addClass(this._dialogClass); - this._showDatepicker(this._dialogInput[0]); - if ($.blockUI) { - $.blockUI(this.dpDiv); - } - $.data(this._dialogInput[0], "datepicker", inst); - return this; - }, - - /* Detach a datepicker from its control. - * @param target element - the target input field or division or span - */ - _destroyDatepicker: function(target) { - var nodeName, - $target = $(target), - inst = $.data(target, "datepicker"); - - if (!$target.hasClass(this.markerClassName)) { - return; - } - - nodeName = target.nodeName.toLowerCase(); - $.removeData(target, "datepicker"); - if (nodeName === "input") { - inst.append.remove(); - inst.trigger.remove(); - $target.removeClass(this.markerClassName). - unbind("focus", this._showDatepicker). - unbind("keydown", this._doKeyDown). - unbind("keypress", this._doKeyPress). - unbind("keyup", this._doKeyUp); - } else if (nodeName === "div" || nodeName === "span") { - $target.removeClass(this.markerClassName).empty(); - } - - if ( datepicker_instActive === inst ) { - datepicker_instActive = null; - } - }, - - /* Enable the date picker to a jQuery selection. - * @param target element - the target input field or division or span - */ - _enableDatepicker: function(target) { - var nodeName, inline, - $target = $(target), - inst = $.data(target, "datepicker"); - - if (!$target.hasClass(this.markerClassName)) { - return; - } - - nodeName = target.nodeName.toLowerCase(); - if (nodeName === "input") { - target.disabled = false; - inst.trigger.filter("button"). - each(function() { this.disabled = false; }).end(). - filter("img").css({opacity: "1.0", cursor: ""}); - } else if (nodeName === "div" || nodeName === "span") { - inline = $target.children("." + this._inlineClass); - inline.children().removeClass("ui-state-disabled"); - inline.find("select.ui-datepicker-month, select.ui-datepicker-year"). - prop("disabled", false); - } - this._disabledInputs = $.map(this._disabledInputs, - function(value) { return (value === target ? null : value); }); // delete entry - }, - - /* Disable the date picker to a jQuery selection. - * @param target element - the target input field or division or span - */ - _disableDatepicker: function(target) { - var nodeName, inline, - $target = $(target), - inst = $.data(target, "datepicker"); - - if (!$target.hasClass(this.markerClassName)) { - return; - } - - nodeName = target.nodeName.toLowerCase(); - if (nodeName === "input") { - target.disabled = true; - inst.trigger.filter("button"). - each(function() { this.disabled = true; }).end(). - filter("img").css({opacity: "0.5", cursor: "default"}); - } else if (nodeName === "div" || nodeName === "span") { - inline = $target.children("." + this._inlineClass); - inline.children().addClass("ui-state-disabled"); - inline.find("select.ui-datepicker-month, select.ui-datepicker-year"). - prop("disabled", true); - } - this._disabledInputs = $.map(this._disabledInputs, - function(value) { return (value === target ? null : value); }); // delete entry - this._disabledInputs[this._disabledInputs.length] = target; - }, - - /* Is the first field in a jQuery collection disabled as a datepicker? - * @param target element - the target input field or division or span - * @return boolean - true if disabled, false if enabled - */ - _isDisabledDatepicker: function(target) { - if (!target) { - return false; - } - for (var i = 0; i < this._disabledInputs.length; i++) { - if (this._disabledInputs[i] === target) { - return true; - } - } - return false; - }, - - /* Retrieve the instance data for the target control. - * @param target element - the target input field or division or span - * @return object - the associated instance data - * @throws error if a jQuery problem getting data - */ - _getInst: function(target) { - try { - return $.data(target, "datepicker"); - } - catch (err) { - throw "Missing instance data for this datepicker"; - } - }, - - /* Update or retrieve the settings for a date picker attached to an input field or division. - * @param target element - the target input field or division or span - * @param name object - the new settings to update or - * string - the name of the setting to change or retrieve, - * when retrieving also "all" for all instance settings or - * "defaults" for all global defaults - * @param value any - the new value for the setting - * (omit if above is an object or to retrieve a value) - */ - _optionDatepicker: function(target, name, value) { - var settings, date, minDate, maxDate, - inst = this._getInst(target); - - if (arguments.length === 2 && typeof name === "string") { - return (name === "defaults" ? $.extend({}, $.datepicker._defaults) : - (inst ? (name === "all" ? $.extend({}, inst.settings) : - this._get(inst, name)) : null)); - } - - settings = name || {}; - if (typeof name === "string") { - settings = {}; - settings[name] = value; - } - - if (inst) { - if (this._curInst === inst) { - this._hideDatepicker(); - } - - date = this._getDateDatepicker(target, true); - minDate = this._getMinMaxDate(inst, "min"); - maxDate = this._getMinMaxDate(inst, "max"); - datepicker_extendRemove(inst.settings, settings); - // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided - if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) { - inst.settings.minDate = this._formatDate(inst, minDate); - } - if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) { - inst.settings.maxDate = this._formatDate(inst, maxDate); - } - if ( "disabled" in settings ) { - if ( settings.disabled ) { - this._disableDatepicker(target); - } else { - this._enableDatepicker(target); - } - } - this._attachments($(target), inst); - this._autoSize(inst); - this._setDate(inst, date); - this._updateAlternate(inst); - this._updateDatepicker(inst); - } - }, - - // change method deprecated - _changeDatepicker: function(target, name, value) { - this._optionDatepicker(target, name, value); - }, - - /* Redraw the date picker attached to an input field or division. - * @param target element - the target input field or division or span - */ - _refreshDatepicker: function(target) { - var inst = this._getInst(target); - if (inst) { - this._updateDatepicker(inst); - } - }, - - /* Set the dates for a jQuery selection. - * @param target element - the target input field or division or span - * @param date Date - the new date - */ - _setDateDatepicker: function(target, date) { - var inst = this._getInst(target); - if (inst) { - this._setDate(inst, date); - this._updateDatepicker(inst); - this._updateAlternate(inst); - } - }, - - /* Get the date(s) for the first entry in a jQuery selection. - * @param target element - the target input field or division or span - * @param noDefault boolean - true if no default date is to be used - * @return Date - the current date - */ - _getDateDatepicker: function(target, noDefault) { - var inst = this._getInst(target); - if (inst && !inst.inline) { - this._setDateFromField(inst, noDefault); - } - return (inst ? this._getDate(inst) : null); - }, - - /* Handle keystrokes. */ - _doKeyDown: function(event) { - var onSelect, dateStr, sel, - inst = $.datepicker._getInst(event.target), - handled = true, - isRTL = inst.dpDiv.is(".ui-datepicker-rtl"); - - inst._keyEvent = true; - if ($.datepicker._datepickerShowing) { - switch (event.keyCode) { - case 9: $.datepicker._hideDatepicker(); - handled = false; - break; // hide on tab out - case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." + - $.datepicker._currentClass + ")", inst.dpDiv); - if (sel[0]) { - $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]); - } - - onSelect = $.datepicker._get(inst, "onSelect"); - if (onSelect) { - dateStr = $.datepicker._formatDate(inst); - - // trigger custom callback - onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); - } else { - $.datepicker._hideDatepicker(); - } - - return false; // don't submit the form - case 27: $.datepicker._hideDatepicker(); - break; // hide on escape - case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ? - -$.datepicker._get(inst, "stepBigMonths") : - -$.datepicker._get(inst, "stepMonths")), "M"); - break; // previous month/year on page up/+ ctrl - case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ? - +$.datepicker._get(inst, "stepBigMonths") : - +$.datepicker._get(inst, "stepMonths")), "M"); - break; // next month/year on page down/+ ctrl - case 35: if (event.ctrlKey || event.metaKey) { - $.datepicker._clearDate(event.target); - } - handled = event.ctrlKey || event.metaKey; - break; // clear on ctrl or command +end - case 36: if (event.ctrlKey || event.metaKey) { - $.datepicker._gotoToday(event.target); - } - handled = event.ctrlKey || event.metaKey; - break; // current on ctrl or command +home - case 37: if (event.ctrlKey || event.metaKey) { - $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D"); - } - handled = event.ctrlKey || event.metaKey; - // -1 day on ctrl or command +left - if (event.originalEvent.altKey) { - $.datepicker._adjustDate(event.target, (event.ctrlKey ? - -$.datepicker._get(inst, "stepBigMonths") : - -$.datepicker._get(inst, "stepMonths")), "M"); - } - // next month/year on alt +left on Mac - break; - case 38: if (event.ctrlKey || event.metaKey) { - $.datepicker._adjustDate(event.target, -7, "D"); - } - handled = event.ctrlKey || event.metaKey; - break; // -1 week on ctrl or command +up - case 39: if (event.ctrlKey || event.metaKey) { - $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D"); - } - handled = event.ctrlKey || event.metaKey; - // +1 day on ctrl or command +right - if (event.originalEvent.altKey) { - $.datepicker._adjustDate(event.target, (event.ctrlKey ? - +$.datepicker._get(inst, "stepBigMonths") : - +$.datepicker._get(inst, "stepMonths")), "M"); - } - // next month/year on alt +right - break; - case 40: if (event.ctrlKey || event.metaKey) { - $.datepicker._adjustDate(event.target, +7, "D"); - } - handled = event.ctrlKey || event.metaKey; - break; // +1 week on ctrl or command +down - default: handled = false; - } - } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home - $.datepicker._showDatepicker(this); - } else { - handled = false; - } - - if (handled) { - event.preventDefault(); - event.stopPropagation(); - } - }, - - /* Filter entered characters - based on date format. */ - _doKeyPress: function(event) { - var chars, chr, - inst = $.datepicker._getInst(event.target); - - if ($.datepicker._get(inst, "constrainInput")) { - chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat")); - chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode); - return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1); - } - }, - - /* Synchronise manual entry and field/alternate field. */ - _doKeyUp: function(event) { - var date, - inst = $.datepicker._getInst(event.target); - - if (inst.input.val() !== inst.lastVal) { - try { - date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"), - (inst.input ? inst.input.val() : null), - $.datepicker._getFormatConfig(inst)); - - if (date) { // only if valid - $.datepicker._setDateFromField(inst); - $.datepicker._updateAlternate(inst); - $.datepicker._updateDatepicker(inst); - } - } - catch (err) { - } - } - return true; - }, - - /* Pop-up the date picker for a given input field. - * If false returned from beforeShow event handler do not show. - * @param input element - the input field attached to the date picker or - * event - if triggered by focus - */ - _showDatepicker: function(input) { - input = input.target || input; - if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger - input = $("input", input.parentNode)[0]; - } - - if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here - return; - } - - var inst, beforeShow, beforeShowSettings, isFixed, - offset, showAnim, duration; - - inst = $.datepicker._getInst(input); - if ($.datepicker._curInst && $.datepicker._curInst !== inst) { - $.datepicker._curInst.dpDiv.stop(true, true); - if ( inst && $.datepicker._datepickerShowing ) { - $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] ); - } - } - - beforeShow = $.datepicker._get(inst, "beforeShow"); - beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {}; - if(beforeShowSettings === false){ - return; - } - datepicker_extendRemove(inst.settings, beforeShowSettings); - - inst.lastVal = null; - $.datepicker._lastInput = input; - $.datepicker._setDateFromField(inst); - - if ($.datepicker._inDialog) { // hide cursor - input.value = ""; - } - if (!$.datepicker._pos) { // position below input - $.datepicker._pos = $.datepicker._findPos(input); - $.datepicker._pos[1] += input.offsetHeight; // add the height - } - - isFixed = false; - $(input).parents().each(function() { - isFixed |= $(this).css("position") === "fixed"; - return !isFixed; - }); - - offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]}; - $.datepicker._pos = null; - //to avoid flashes on Firefox - inst.dpDiv.empty(); - // determine sizing offscreen - inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"}); - $.datepicker._updateDatepicker(inst); - // fix width for dynamic number of date pickers - // and adjust position before showing - offset = $.datepicker._checkOffset(inst, offset, isFixed); - inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ? - "static" : (isFixed ? "fixed" : "absolute")), display: "none", - left: offset.left + "px", top: offset.top + "px"}); - - if (!inst.inline) { - showAnim = $.datepicker._get(inst, "showAnim"); - duration = $.datepicker._get(inst, "duration"); - inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 ); - $.datepicker._datepickerShowing = true; - - if ( $.effects && $.effects.effect[ showAnim ] ) { - inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration); - } else { - inst.dpDiv[showAnim || "show"](showAnim ? duration : null); - } - - if ( $.datepicker._shouldFocusInput( inst ) ) { - inst.input.focus(); - } - - $.datepicker._curInst = inst; - } - }, - - /* Generate the date picker content. */ - _updateDatepicker: function(inst) { - this.maxRows = 4; //Reset the max number of rows being displayed (see #7043) - datepicker_instActive = inst; // for delegate hover events - inst.dpDiv.empty().append(this._generateHTML(inst)); - this._attachHandlers(inst); - - var origyearshtml, - numMonths = this._getNumberOfMonths(inst), - cols = numMonths[1], - width = 17, - activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" ); - - if ( activeCell.length > 0 ) { - datepicker_handleMouseover.apply( activeCell.get( 0 ) ); - } - - inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width(""); - if (cols > 1) { - inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em"); - } - inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") + - "Class"]("ui-datepicker-multi"); - inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") + - "Class"]("ui-datepicker-rtl"); - - if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) { - inst.input.focus(); - } - - // deffered render of the years select (to avoid flashes on Firefox) - if( inst.yearshtml ){ - origyearshtml = inst.yearshtml; - setTimeout(function(){ - //assure that inst.yearshtml didn't change. - if( origyearshtml === inst.yearshtml && inst.yearshtml ){ - inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml); - } - origyearshtml = inst.yearshtml = null; - }, 0); - } - }, - - // #6694 - don't focus the input if it's already focused - // this breaks the change event in IE - // Support: IE and jQuery <1.9 - _shouldFocusInput: function( inst ) { - return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" ); - }, - - /* Check positioning to remain on screen. */ - _checkOffset: function(inst, offset, isFixed) { - var dpWidth = inst.dpDiv.outerWidth(), - dpHeight = inst.dpDiv.outerHeight(), - inputWidth = inst.input ? inst.input.outerWidth() : 0, - inputHeight = inst.input ? inst.input.outerHeight() : 0, - viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()), - viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop()); - - offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0); - offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0; - offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0; - - // now check if datepicker is showing outside window viewport - move to a better place if so. - offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ? - Math.abs(offset.left + dpWidth - viewWidth) : 0); - offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ? - Math.abs(dpHeight + inputHeight) : 0); - - return offset; - }, - - /* Find an object's position on the screen. */ - _findPos: function(obj) { - var position, - inst = this._getInst(obj), - isRTL = this._get(inst, "isRTL"); - - while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) { - obj = obj[isRTL ? "previousSibling" : "nextSibling"]; - } - - position = $(obj).offset(); - return [position.left, position.top]; - }, - - /* Hide the date picker from view. - * @param input element - the input field attached to the date picker - */ - _hideDatepicker: function(input) { - var showAnim, duration, postProcess, onClose, - inst = this._curInst; - - if (!inst || (input && inst !== $.data(input, "datepicker"))) { - return; - } - - if (this._datepickerShowing) { - showAnim = this._get(inst, "showAnim"); - duration = this._get(inst, "duration"); - postProcess = function() { - $.datepicker._tidyDialog(inst); - }; - - // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed - if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) { - inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess); - } else { - inst.dpDiv[(showAnim === "slideDown" ? "slideUp" : - (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess); - } - - if (!showAnim) { - postProcess(); - } - this._datepickerShowing = false; - - onClose = this._get(inst, "onClose"); - if (onClose) { - onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]); - } - - this._lastInput = null; - if (this._inDialog) { - this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" }); - if ($.blockUI) { - $.unblockUI(); - $("body").append(this.dpDiv); - } - } - this._inDialog = false; - } - }, - - /* Tidy up after a dialog display. */ - _tidyDialog: function(inst) { - inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar"); - }, - - /* Close date picker if clicked elsewhere. */ - _checkExternalClick: function(event) { - if (!$.datepicker._curInst) { - return; - } - - var $target = $(event.target), - inst = $.datepicker._getInst($target[0]); - - if ( ( ( $target[0].id !== $.datepicker._mainDivId && - $target.parents("#" + $.datepicker._mainDivId).length === 0 && - !$target.hasClass($.datepicker.markerClassName) && - !$target.closest("." + $.datepicker._triggerClass).length && - $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) || - ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) { - $.datepicker._hideDatepicker(); - } - }, - - /* Adjust one of the date sub-fields. */ - _adjustDate: function(id, offset, period) { - var target = $(id), - inst = this._getInst(target[0]); - - if (this._isDisabledDatepicker(target[0])) { - return; - } - this._adjustInstDate(inst, offset + - (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning - period); - this._updateDatepicker(inst); - }, - - /* Action for current link. */ - _gotoToday: function(id) { - var date, - target = $(id), - inst = this._getInst(target[0]); - - if (this._get(inst, "gotoCurrent") && inst.currentDay) { - inst.selectedDay = inst.currentDay; - inst.drawMonth = inst.selectedMonth = inst.currentMonth; - inst.drawYear = inst.selectedYear = inst.currentYear; - } else { - date = new Date(); - inst.selectedDay = date.getDate(); - inst.drawMonth = inst.selectedMonth = date.getMonth(); - inst.drawYear = inst.selectedYear = date.getFullYear(); - } - this._notifyChange(inst); - this._adjustDate(target); - }, - - /* Action for selecting a new month/year. */ - _selectMonthYear: function(id, select, period) { - var target = $(id), - inst = this._getInst(target[0]); - - inst["selected" + (period === "M" ? "Month" : "Year")] = - inst["draw" + (period === "M" ? "Month" : "Year")] = - parseInt(select.options[select.selectedIndex].value,10); - - this._notifyChange(inst); - this._adjustDate(target); - }, - - /* Action for selecting a day. */ - _selectDay: function(id, month, year, td) { - var inst, - target = $(id); - - if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) { - return; - } - - inst = this._getInst(target[0]); - inst.selectedDay = inst.currentDay = $("a", td).html(); - inst.selectedMonth = inst.currentMonth = month; - inst.selectedYear = inst.currentYear = year; - this._selectDate(id, this._formatDate(inst, - inst.currentDay, inst.currentMonth, inst.currentYear)); - }, - - /* Erase the input field and hide the date picker. */ - _clearDate: function(id) { - var target = $(id); - this._selectDate(target, ""); - }, - - /* Update the input field with the selected date. */ - _selectDate: function(id, dateStr) { - var onSelect, - target = $(id), - inst = this._getInst(target[0]); - - dateStr = (dateStr != null ? dateStr : this._formatDate(inst)); - if (inst.input) { - inst.input.val(dateStr); - } - this._updateAlternate(inst); - - onSelect = this._get(inst, "onSelect"); - if (onSelect) { - onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback - } else if (inst.input) { - inst.input.trigger("change"); // fire the change event - } - - if (inst.inline){ - this._updateDatepicker(inst); - } else { - this._hideDatepicker(); - this._lastInput = inst.input[0]; - if (typeof(inst.input[0]) !== "object") { - inst.input.focus(); // restore focus - } - this._lastInput = null; - } - }, - - /* Update any alternate field to synchronise with the main field. */ - _updateAlternate: function(inst) { - var altFormat, date, dateStr, - altField = this._get(inst, "altField"); - - if (altField) { // update alternate field too - altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat"); - date = this._getDate(inst); - dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst)); - $(altField).each(function() { $(this).val(dateStr); }); - } - }, - - /* Set as beforeShowDay function to prevent selection of weekends. - * @param date Date - the date to customise - * @return [boolean, string] - is this date selectable?, what is its CSS class? - */ - noWeekends: function(date) { - var day = date.getDay(); - return [(day > 0 && day < 6), ""]; - }, - - /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition. - * @param date Date - the date to get the week for - * @return number - the number of the week within the year that contains this date - */ - iso8601Week: function(date) { - var time, - checkDate = new Date(date.getTime()); - - // Find Thursday of this week starting on Monday - checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7)); - - time = checkDate.getTime(); - checkDate.setMonth(0); // Compare with Jan 1 - checkDate.setDate(1); - return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1; - }, - - /* Parse a string value into a date object. - * See formatDate below for the possible formats. - * - * @param format string - the expected format of the date - * @param value string - the date in the above format - * @param settings Object - attributes include: - * shortYearCutoff number - the cutoff year for determining the century (optional) - * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional) - * dayNames string[7] - names of the days from Sunday (optional) - * monthNamesShort string[12] - abbreviated names of the months (optional) - * monthNames string[12] - names of the months (optional) - * @return Date - the extracted date value or null if value is blank - */ - parseDate: function (format, value, settings) { - if (format == null || value == null) { - throw "Invalid arguments"; - } - - value = (typeof value === "object" ? value.toString() : value + ""); - if (value === "") { - return null; - } - - var iFormat, dim, extra, - iValue = 0, - shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff, - shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp : - new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)), - dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort, - dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames, - monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort, - monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames, - year = -1, - month = -1, - day = -1, - doy = -1, - literal = false, - date, - // Check whether a format character is doubled - lookAhead = function(match) { - var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match); - if (matches) { - iFormat++; - } - return matches; - }, - // Extract a number from the string value - getNumber = function(match) { - var isDoubled = lookAhead(match), - size = (match === "@" ? 14 : (match === "!" ? 20 : - (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))), - minSize = (match === "y" ? size : 1), - digits = new RegExp("^\\d{" + minSize + "," + size + "}"), - num = value.substring(iValue).match(digits); - if (!num) { - throw "Missing number at position " + iValue; - } - iValue += num[0].length; - return parseInt(num[0], 10); - }, - // Extract a name from the string value and convert to an index - getName = function(match, shortNames, longNames) { - var index = -1, - names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) { - return [ [k, v] ]; - }).sort(function (a, b) { - return -(a[1].length - b[1].length); - }); - - $.each(names, function (i, pair) { - var name = pair[1]; - if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) { - index = pair[0]; - iValue += name.length; - return false; - } - }); - if (index !== -1) { - return index + 1; - } else { - throw "Unknown name at position " + iValue; - } - }, - // Confirm that a literal character matches the string value - checkLiteral = function() { - if (value.charAt(iValue) !== format.charAt(iFormat)) { - throw "Unexpected literal at position " + iValue; - } - iValue++; - }; - - for (iFormat = 0; iFormat < format.length; iFormat++) { - if (literal) { - if (format.charAt(iFormat) === "'" && !lookAhead("'")) { - literal = false; - } else { - checkLiteral(); - } - } else { - switch (format.charAt(iFormat)) { - case "d": - day = getNumber("d"); - break; - case "D": - getName("D", dayNamesShort, dayNames); - break; - case "o": - doy = getNumber("o"); - break; - case "m": - month = getNumber("m"); - break; - case "M": - month = getName("M", monthNamesShort, monthNames); - break; - case "y": - year = getNumber("y"); - break; - case "@": - date = new Date(getNumber("@")); - year = date.getFullYear(); - month = date.getMonth() + 1; - day = date.getDate(); - break; - case "!": - date = new Date((getNumber("!") - this._ticksTo1970) / 10000); - year = date.getFullYear(); - month = date.getMonth() + 1; - day = date.getDate(); - break; - case "'": - if (lookAhead("'")){ - checkLiteral(); - } else { - literal = true; - } - break; - default: - checkLiteral(); - } - } - } - - if (iValue < value.length){ - extra = value.substr(iValue); - if (!/^\s+/.test(extra)) { - throw "Extra/unparsed characters found in date: " + extra; - } - } - - if (year === -1) { - year = new Date().getFullYear(); - } else if (year < 100) { - year += new Date().getFullYear() - new Date().getFullYear() % 100 + - (year <= shortYearCutoff ? 0 : -100); - } - - if (doy > -1) { - month = 1; - day = doy; - do { - dim = this._getDaysInMonth(year, month - 1); - if (day <= dim) { - break; - } - month++; - day -= dim; - } while (true); - } - - date = this._daylightSavingAdjust(new Date(year, month - 1, day)); - if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) { - throw "Invalid date"; // E.g. 31/02/00 - } - return date; - }, - - /* Standard date formats. */ - ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601) - COOKIE: "D, dd M yy", - ISO_8601: "yy-mm-dd", - RFC_822: "D, d M y", - RFC_850: "DD, dd-M-y", - RFC_1036: "D, d M y", - RFC_1123: "D, d M yy", - RFC_2822: "D, d M yy", - RSS: "D, d M y", // RFC 822 - TICKS: "!", - TIMESTAMP: "@", - W3C: "yy-mm-dd", // ISO 8601 - - _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) + - Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000), - - /* Format a date object into a string value. - * The format can be combinations of the following: - * d - day of month (no leading zero) - * dd - day of month (two digit) - * o - day of year (no leading zeros) - * oo - day of year (three digit) - * D - day name short - * DD - day name long - * m - month of year (no leading zero) - * mm - month of year (two digit) - * M - month name short - * MM - month name long - * y - year (two digit) - * yy - year (four digit) - * @ - Unix timestamp (ms since 01/01/1970) - * ! - Windows ticks (100ns since 01/01/0001) - * "..." - literal text - * '' - single quote - * - * @param format string - the desired format of the date - * @param date Date - the date value to format - * @param settings Object - attributes include: - * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional) - * dayNames string[7] - names of the days from Sunday (optional) - * monthNamesShort string[12] - abbreviated names of the months (optional) - * monthNames string[12] - names of the months (optional) - * @return string - the date in the above format - */ - formatDate: function (format, date, settings) { - if (!date) { - return ""; - } - - var iFormat, - dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort, - dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames, - monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort, - monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames, - // Check whether a format character is doubled - lookAhead = function(match) { - var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match); - if (matches) { - iFormat++; - } - return matches; - }, - // Format a number, with leading zero if necessary - formatNumber = function(match, value, len) { - var num = "" + value; - if (lookAhead(match)) { - while (num.length < len) { - num = "0" + num; - } - } - return num; - }, - // Format a name, short or long as requested - formatName = function(match, value, shortNames, longNames) { - return (lookAhead(match) ? longNames[value] : shortNames[value]); - }, - output = "", - literal = false; - - if (date) { - for (iFormat = 0; iFormat < format.length; iFormat++) { - if (literal) { - if (format.charAt(iFormat) === "'" && !lookAhead("'")) { - literal = false; - } else { - output += format.charAt(iFormat); - } - } else { - switch (format.charAt(iFormat)) { - case "d": - output += formatNumber("d", date.getDate(), 2); - break; - case "D": - output += formatName("D", date.getDay(), dayNamesShort, dayNames); - break; - case "o": - output += formatNumber("o", - Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3); - break; - case "m": - output += formatNumber("m", date.getMonth() + 1, 2); - break; - case "M": - output += formatName("M", date.getMonth(), monthNamesShort, monthNames); - break; - case "y": - output += (lookAhead("y") ? date.getFullYear() : - (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100); - break; - case "@": - output += date.getTime(); - break; - case "!": - output += date.getTime() * 10000 + this._ticksTo1970; - break; - case "'": - if (lookAhead("'")) { - output += "'"; - } else { - literal = true; - } - break; - default: - output += format.charAt(iFormat); - } - } - } - } - return output; - }, - - /* Extract all possible characters from the date format. */ - _possibleChars: function (format) { - var iFormat, - chars = "", - literal = false, - // Check whether a format character is doubled - lookAhead = function(match) { - var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match); - if (matches) { - iFormat++; - } - return matches; - }; - - for (iFormat = 0; iFormat < format.length; iFormat++) { - if (literal) { - if (format.charAt(iFormat) === "'" && !lookAhead("'")) { - literal = false; - } else { - chars += format.charAt(iFormat); - } - } else { - switch (format.charAt(iFormat)) { - case "d": case "m": case "y": case "@": - chars += "0123456789"; - break; - case "D": case "M": - return null; // Accept anything - case "'": - if (lookAhead("'")) { - chars += "'"; - } else { - literal = true; - } - break; - default: - chars += format.charAt(iFormat); - } - } - } - return chars; - }, - - /* Get a setting value, defaulting if necessary. */ - _get: function(inst, name) { - return inst.settings[name] !== undefined ? - inst.settings[name] : this._defaults[name]; - }, - - /* Parse existing date and initialise date picker. */ - _setDateFromField: function(inst, noDefault) { - if (inst.input.val() === inst.lastVal) { - return; - } - - var dateFormat = this._get(inst, "dateFormat"), - dates = inst.lastVal = inst.input ? inst.input.val() : null, - defaultDate = this._getDefaultDate(inst), - date = defaultDate, - settings = this._getFormatConfig(inst); - - try { - date = this.parseDate(dateFormat, dates, settings) || defaultDate; - } catch (event) { - dates = (noDefault ? "" : dates); - } - inst.selectedDay = date.getDate(); - inst.drawMonth = inst.selectedMonth = date.getMonth(); - inst.drawYear = inst.selectedYear = date.getFullYear(); - inst.currentDay = (dates ? date.getDate() : 0); - inst.currentMonth = (dates ? date.getMonth() : 0); - inst.currentYear = (dates ? date.getFullYear() : 0); - this._adjustInstDate(inst); - }, - - /* Retrieve the default date shown on opening. */ - _getDefaultDate: function(inst) { - return this._restrictMinMax(inst, - this._determineDate(inst, this._get(inst, "defaultDate"), new Date())); - }, - - /* A date may be specified as an exact value or a relative one. */ - _determineDate: function(inst, date, defaultDate) { - var offsetNumeric = function(offset) { - var date = new Date(); - date.setDate(date.getDate() + offset); - return date; - }, - offsetString = function(offset) { - try { - return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"), - offset, $.datepicker._getFormatConfig(inst)); - } - catch (e) { - // Ignore - } - - var date = (offset.toLowerCase().match(/^c/) ? - $.datepicker._getDate(inst) : null) || new Date(), - year = date.getFullYear(), - month = date.getMonth(), - day = date.getDate(), - pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g, - matches = pattern.exec(offset); - - while (matches) { - switch (matches[2] || "d") { - case "d" : case "D" : - day += parseInt(matches[1],10); break; - case "w" : case "W" : - day += parseInt(matches[1],10) * 7; break; - case "m" : case "M" : - month += parseInt(matches[1],10); - day = Math.min(day, $.datepicker._getDaysInMonth(year, month)); - break; - case "y": case "Y" : - year += parseInt(matches[1],10); - day = Math.min(day, $.datepicker._getDaysInMonth(year, month)); - break; - } - matches = pattern.exec(offset); - } - return new Date(year, month, day); - }, - newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) : - (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime())))); - - newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate); - if (newDate) { - newDate.setHours(0); - newDate.setMinutes(0); - newDate.setSeconds(0); - newDate.setMilliseconds(0); - } - return this._daylightSavingAdjust(newDate); - }, - - /* Handle switch to/from daylight saving. - * Hours may be non-zero on daylight saving cut-over: - * > 12 when midnight changeover, but then cannot generate - * midnight datetime, so jump to 1AM, otherwise reset. - * @param date (Date) the date to check - * @return (Date) the corrected date - */ - _daylightSavingAdjust: function(date) { - if (!date) { - return null; - } - date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0); - return date; - }, - - /* Set the date(s) directly. */ - _setDate: function(inst, date, noChange) { - var clear = !date, - origMonth = inst.selectedMonth, - origYear = inst.selectedYear, - newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date())); - - inst.selectedDay = inst.currentDay = newDate.getDate(); - inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth(); - inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear(); - if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) { - this._notifyChange(inst); - } - this._adjustInstDate(inst); - if (inst.input) { - inst.input.val(clear ? "" : this._formatDate(inst)); - } - }, - - /* Retrieve the date(s) directly. */ - _getDate: function(inst) { - var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null : - this._daylightSavingAdjust(new Date( - inst.currentYear, inst.currentMonth, inst.currentDay))); - return startDate; - }, - - /* Attach the onxxx handlers. These are declared statically so - * they work with static code transformers like Caja. - */ - _attachHandlers: function(inst) { - var stepMonths = this._get(inst, "stepMonths"), - id = "#" + inst.id.replace( /\\\\/g, "\\" ); - inst.dpDiv.find("[data-handler]").map(function () { - var handler = { - prev: function () { - $.datepicker._adjustDate(id, -stepMonths, "M"); - }, - next: function () { - $.datepicker._adjustDate(id, +stepMonths, "M"); - }, - hide: function () { - $.datepicker._hideDatepicker(); - }, - today: function () { - $.datepicker._gotoToday(id); - }, - selectDay: function () { - $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this); - return false; - }, - selectMonth: function () { - $.datepicker._selectMonthYear(id, this, "M"); - return false; - }, - selectYear: function () { - $.datepicker._selectMonthYear(id, this, "Y"); - return false; - } - }; - $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]); - }); - }, - - /* Generate the HTML for the current state of the date picker. */ - _generateHTML: function(inst) { - var maxDraw, prevText, prev, nextText, next, currentText, gotoDate, - controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin, - monthNames, monthNamesShort, beforeShowDay, showOtherMonths, - selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate, - cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows, - printDate, dRow, tbody, daySettings, otherMonth, unselectable, - tempDate = new Date(), - today = this._daylightSavingAdjust( - new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time - isRTL = this._get(inst, "isRTL"), - showButtonPanel = this._get(inst, "showButtonPanel"), - hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"), - navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"), - numMonths = this._getNumberOfMonths(inst), - showCurrentAtPos = this._get(inst, "showCurrentAtPos"), - stepMonths = this._get(inst, "stepMonths"), - isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1), - currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) : - new Date(inst.currentYear, inst.currentMonth, inst.currentDay))), - minDate = this._getMinMaxDate(inst, "min"), - maxDate = this._getMinMaxDate(inst, "max"), - drawMonth = inst.drawMonth - showCurrentAtPos, - drawYear = inst.drawYear; - - if (drawMonth < 0) { - drawMonth += 12; - drawYear--; - } - if (maxDate) { - maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(), - maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate())); - maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw); - while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) { - drawMonth--; - if (drawMonth < 0) { - drawMonth = 11; - drawYear--; - } - } - } - inst.drawMonth = drawMonth; - inst.drawYear = drawYear; - - prevText = this._get(inst, "prevText"); - prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText, - this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)), - this._getFormatConfig(inst))); - - prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ? - "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" + - " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" : - (hideIfNoPrevNext ? "" : "<a class='ui-datepicker-prev ui-corner-all ui-state-disabled' title='"+ prevText +"'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>")); - - nextText = this._get(inst, "nextText"); - nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText, - this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)), - this._getFormatConfig(inst))); - - next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ? - "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" + - " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" : - (hideIfNoPrevNext ? "" : "<a class='ui-datepicker-next ui-corner-all ui-state-disabled' title='"+ nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>")); - - currentText = this._get(inst, "currentText"); - gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today); - currentText = (!navigationAsDateFormat ? currentText : - this.formatDate(currentText, gotoDate, this._getFormatConfig(inst))); - - controls = (!inst.inline ? "<button type='button' class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all' data-handler='hide' data-event='click'>" + - this._get(inst, "closeText") + "</button>" : ""); - - buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") + - (this._isInRange(inst, gotoDate) ? "<button type='button' class='ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all' data-handler='today' data-event='click'" + - ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : ""; - - firstDay = parseInt(this._get(inst, "firstDay"),10); - firstDay = (isNaN(firstDay) ? 0 : firstDay); - - showWeek = this._get(inst, "showWeek"); - dayNames = this._get(inst, "dayNames"); - dayNamesMin = this._get(inst, "dayNamesMin"); - monthNames = this._get(inst, "monthNames"); - monthNamesShort = this._get(inst, "monthNamesShort"); - beforeShowDay = this._get(inst, "beforeShowDay"); - showOtherMonths = this._get(inst, "showOtherMonths"); - selectOtherMonths = this._get(inst, "selectOtherMonths"); - defaultDate = this._getDefaultDate(inst); - html = ""; - dow; - for (row = 0; row < numMonths[0]; row++) { - group = ""; - this.maxRows = 4; - for (col = 0; col < numMonths[1]; col++) { - selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay)); - cornerClass = " ui-corner-all"; - calender = ""; - if (isMultiMonth) { - calender += "<div class='ui-datepicker-group"; - if (numMonths[1] > 1) { - switch (col) { - case 0: calender += " ui-datepicker-group-first"; - cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break; - case numMonths[1]-1: calender += " ui-datepicker-group-last"; - cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break; - default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break; - } - } - calender += "'>"; - } - calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" + - (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") + - (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") + - this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate, - row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers - "</div><table class='ui-datepicker-calendar'><thead>" + - "<tr>"; - thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : ""); - for (dow = 0; dow < 7; dow++) { // days of the week - day = (dow + firstDay) % 7; - thead += "<th scope='col'" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" + - "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>"; - } - calender += thead + "</tr></thead><tbody>"; - daysInMonth = this._getDaysInMonth(drawYear, drawMonth); - if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) { - inst.selectedDay = Math.min(inst.selectedDay, daysInMonth); - } - leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7; - curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate - numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043) - this.maxRows = numRows; - printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays)); - for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows - calender += "<tr>"; - tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" + - this._get(inst, "calculateWeek")(printDate) + "</td>"); - for (dow = 0; dow < 7; dow++) { // create date picker days - daySettings = (beforeShowDay ? - beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]); - otherMonth = (printDate.getMonth() !== drawMonth); - unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] || - (minDate && printDate < minDate) || (maxDate && printDate > maxDate); - tbody += "<td class='" + - ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends - (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months - ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key - (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ? - // or defaultDate is current printedDate and defaultDate is selectedDate - " " + this._dayOverClass : "") + // highlight selected day - (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days - (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates - (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day - (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different) - ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "'") + "'" : "") + // cell title - (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions - (otherMonth && !showOtherMonths ? " " : // display for other months - (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" + - (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") + - (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day - (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months - "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date - printDate.setDate(printDate.getDate() + 1); - printDate = this._daylightSavingAdjust(printDate); - } - calender += tbody + "</tr>"; - } - drawMonth++; - if (drawMonth > 11) { - drawMonth = 0; - drawYear++; - } - calender += "</tbody></table>" + (isMultiMonth ? "</div>" + - ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : ""); - group += calender; - } - html += group; - } - html += buttonPanel; - inst._keyEvent = false; - return html; - }, - - /* Generate the month and year header. */ - _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate, - secondary, monthNames, monthNamesShort) { - - var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear, - changeMonth = this._get(inst, "changeMonth"), - changeYear = this._get(inst, "changeYear"), - showMonthAfterYear = this._get(inst, "showMonthAfterYear"), - html = "<div class='ui-datepicker-title'>", - monthHtml = ""; - - // month selection - if (secondary || !changeMonth) { - monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>"; - } else { - inMinYear = (minDate && minDate.getFullYear() === drawYear); - inMaxYear = (maxDate && maxDate.getFullYear() === drawYear); - monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>"; - for ( month = 0; month < 12; month++) { - if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) { - monthHtml += "<option value='" + month + "'" + - (month === drawMonth ? " selected='selected'" : "") + - ">" + monthNamesShort[month] + "</option>"; - } - } - monthHtml += "</select>"; - } - - if (!showMonthAfterYear) { - html += monthHtml + (secondary || !(changeMonth && changeYear) ? " " : ""); - } - - // year selection - if ( !inst.yearshtml ) { - inst.yearshtml = ""; - if (secondary || !changeYear) { - html += "<span class='ui-datepicker-year'>" + drawYear + "</span>"; - } else { - // determine range of years to display - years = this._get(inst, "yearRange").split(":"); - thisYear = new Date().getFullYear(); - determineYear = function(value) { - var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) : - (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) : - parseInt(value, 10))); - return (isNaN(year) ? thisYear : year); - }; - year = determineYear(years[0]); - endYear = Math.max(year, determineYear(years[1] || "")); - year = (minDate ? Math.max(year, minDate.getFullYear()) : year); - endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear); - inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>"; - for (; year <= endYear; year++) { - inst.yearshtml += "<option value='" + year + "'" + - (year === drawYear ? " selected='selected'" : "") + - ">" + year + "</option>"; - } - inst.yearshtml += "</select>"; - - html += inst.yearshtml; - inst.yearshtml = null; - } - } - - html += this._get(inst, "yearSuffix"); - if (showMonthAfterYear) { - html += (secondary || !(changeMonth && changeYear) ? " " : "") + monthHtml; - } - html += "</div>"; // Close datepicker_header - return html; - }, - - /* Adjust one of the date sub-fields. */ - _adjustInstDate: function(inst, offset, period) { - var year = inst.drawYear + (period === "Y" ? offset : 0), - month = inst.drawMonth + (period === "M" ? offset : 0), - day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0), - date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day))); - - inst.selectedDay = date.getDate(); - inst.drawMonth = inst.selectedMonth = date.getMonth(); - inst.drawYear = inst.selectedYear = date.getFullYear(); - if (period === "M" || period === "Y") { - this._notifyChange(inst); - } - }, - - /* Ensure a date is within any min/max bounds. */ - _restrictMinMax: function(inst, date) { - var minDate = this._getMinMaxDate(inst, "min"), - maxDate = this._getMinMaxDate(inst, "max"), - newDate = (minDate && date < minDate ? minDate : date); - return (maxDate && newDate > maxDate ? maxDate : newDate); - }, - - /* Notify change of month/year. */ - _notifyChange: function(inst) { - var onChange = this._get(inst, "onChangeMonthYear"); - if (onChange) { - onChange.apply((inst.input ? inst.input[0] : null), - [inst.selectedYear, inst.selectedMonth + 1, inst]); - } - }, - - /* Determine the number of months to show. */ - _getNumberOfMonths: function(inst) { - var numMonths = this._get(inst, "numberOfMonths"); - return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths)); - }, - - /* Determine the current maximum date - ensure no time components are set. */ - _getMinMaxDate: function(inst, minMax) { - return this._determineDate(inst, this._get(inst, minMax + "Date"), null); - }, - - /* Find the number of days in a given month. */ - _getDaysInMonth: function(year, month) { - return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate(); - }, - - /* Find the day of the week of the first of a month. */ - _getFirstDayOfMonth: function(year, month) { - return new Date(year, month, 1).getDay(); - }, - - /* Determines if we should allow a "next/prev" month display change. */ - _canAdjustMonth: function(inst, offset, curYear, curMonth) { - var numMonths = this._getNumberOfMonths(inst), - date = this._daylightSavingAdjust(new Date(curYear, - curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1)); - - if (offset < 0) { - date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth())); - } - return this._isInRange(inst, date); - }, - - /* Is the given date in the accepted range? */ - _isInRange: function(inst, date) { - var yearSplit, currentYear, - minDate = this._getMinMaxDate(inst, "min"), - maxDate = this._getMinMaxDate(inst, "max"), - minYear = null, - maxYear = null, - years = this._get(inst, "yearRange"); - if (years){ - yearSplit = years.split(":"); - currentYear = new Date().getFullYear(); - minYear = parseInt(yearSplit[0], 10); - maxYear = parseInt(yearSplit[1], 10); - if ( yearSplit[0].match(/[+\-].*/) ) { - minYear += currentYear; - } - if ( yearSplit[1].match(/[+\-].*/) ) { - maxYear += currentYear; - } - } - - return ((!minDate || date.getTime() >= minDate.getTime()) && - (!maxDate || date.getTime() <= maxDate.getTime()) && - (!minYear || date.getFullYear() >= minYear) && - (!maxYear || date.getFullYear() <= maxYear)); - }, - - /* Provide the configuration settings for formatting/parsing. */ - _getFormatConfig: function(inst) { - var shortYearCutoff = this._get(inst, "shortYearCutoff"); - shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff : - new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10)); - return {shortYearCutoff: shortYearCutoff, - dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"), - monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")}; - }, - - /* Format the given date for display. */ - _formatDate: function(inst, day, month, year) { - if (!day) { - inst.currentDay = inst.selectedDay; - inst.currentMonth = inst.selectedMonth; - inst.currentYear = inst.selectedYear; - } - var date = (day ? (typeof day === "object" ? day : - this._daylightSavingAdjust(new Date(year, month, day))) : - this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay))); - return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst)); - } -}); - -/* - * Bind hover events for datepicker elements. - * Done via delegate so the binding only occurs once in the lifetime of the parent div. - * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker. - */ -function datepicker_bindHover(dpDiv) { - var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a"; - return dpDiv.delegate(selector, "mouseout", function() { - $(this).removeClass("ui-state-hover"); - if (this.className.indexOf("ui-datepicker-prev") !== -1) { - $(this).removeClass("ui-datepicker-prev-hover"); - } - if (this.className.indexOf("ui-datepicker-next") !== -1) { - $(this).removeClass("ui-datepicker-next-hover"); - } - }) - .delegate( selector, "mouseover", datepicker_handleMouseover ); -} - -function datepicker_handleMouseover() { - if (!$.datepicker._isDisabledDatepicker( datepicker_instActive.inline? datepicker_instActive.dpDiv.parent()[0] : datepicker_instActive.input[0])) { - $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"); - $(this).addClass("ui-state-hover"); - if (this.className.indexOf("ui-datepicker-prev") !== -1) { - $(this).addClass("ui-datepicker-prev-hover"); - } - if (this.className.indexOf("ui-datepicker-next") !== -1) { - $(this).addClass("ui-datepicker-next-hover"); - } - } -} - -/* jQuery extend now ignores nulls! */ -function datepicker_extendRemove(target, props) { - $.extend(target, props); - for (var name in props) { - if (props[name] == null) { - target[name] = props[name]; - } - } - return target; -} - -/* Invoke the datepicker functionality. - @param options string - a command, optionally followed by additional parameters or - Object - settings for attaching new datepicker functionality - @return jQuery object */ -$.fn.datepicker = function(options){ - - /* Verify an empty collection wasn't passed - Fixes #6976 */ - if ( !this.length ) { - return this; - } - - /* Initialise the date picker. */ - if (!$.datepicker.initialized) { - $(document).mousedown($.datepicker._checkExternalClick); - $.datepicker.initialized = true; - } - - /* Append datepicker main container to body if not exist. */ - if ($("#"+$.datepicker._mainDivId).length === 0) { - $("body").append($.datepicker.dpDiv); - } - - var otherArgs = Array.prototype.slice.call(arguments, 1); - if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) { - return $.datepicker["_" + options + "Datepicker"]. - apply($.datepicker, [this[0]].concat(otherArgs)); - } - if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") { - return $.datepicker["_" + options + "Datepicker"]. - apply($.datepicker, [this[0]].concat(otherArgs)); - } - return this.each(function() { - typeof options === "string" ? - $.datepicker["_" + options + "Datepicker"]. - apply($.datepicker, [this].concat(otherArgs)) : - $.datepicker._attachDatepicker(this, options); - }); -}; - -$.datepicker = new Datepicker(); // singleton instance -$.datepicker.initialized = false; -$.datepicker.uuid = new Date().getTime(); -$.datepicker.version = "1.11.4"; - -var datepicker = $.datepicker; - - -/*! - * jQuery UI Draggable 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/draggable/ - */ - - -$.widget("ui.draggable", $.ui.mouse, { - version: "1.11.4", - widgetEventPrefix: "drag", - options: { - addClasses: true, - appendTo: "parent", - axis: false, - connectToSortable: false, - containment: false, - cursor: "auto", - cursorAt: false, - grid: false, - handle: false, - helper: "original", - iframeFix: false, - opacity: false, - refreshPositions: false, - revert: false, - revertDuration: 500, - scope: "default", - scroll: true, - scrollSensitivity: 20, - scrollSpeed: 20, - snap: false, - snapMode: "both", - snapTolerance: 20, - stack: false, - zIndex: false, - - // callbacks - drag: null, - start: null, - stop: null - }, - _create: function() { - - if ( this.options.helper === "original" ) { - this._setPositionRelative(); - } - if (this.options.addClasses){ - this.element.addClass("ui-draggable"); - } - if (this.options.disabled){ - this.element.addClass("ui-draggable-disabled"); - } - this._setHandleClassName(); - - this._mouseInit(); - }, - - _setOption: function( key, value ) { - this._super( key, value ); - if ( key === "handle" ) { - this._removeHandleClassName(); - this._setHandleClassName(); - } - }, - - _destroy: function() { - if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) { - this.destroyOnClear = true; - return; - } - this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" ); - this._removeHandleClassName(); - this._mouseDestroy(); - }, - - _mouseCapture: function(event) { - var o = this.options; - - this._blurActiveElement( event ); - - // among others, prevent a drag on a resizable-handle - if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) { - return false; - } - - //Quit if we're not on a valid handle - this.handle = this._getHandle(event); - if (!this.handle) { - return false; - } - - this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix ); - - return true; - - }, - - _blockFrames: function( selector ) { - this.iframeBlocks = this.document.find( selector ).map(function() { - var iframe = $( this ); - - return $( "<div>" ) - .css( "position", "absolute" ) - .appendTo( iframe.parent() ) - .outerWidth( iframe.outerWidth() ) - .outerHeight( iframe.outerHeight() ) - .offset( iframe.offset() )[ 0 ]; - }); - }, - - _unblockFrames: function() { - if ( this.iframeBlocks ) { - this.iframeBlocks.remove(); - delete this.iframeBlocks; - } - }, - - _blurActiveElement: function( event ) { - var document = this.document[ 0 ]; - - // Only need to blur if the event occurred on the draggable itself, see #10527 - if ( !this.handleElement.is( event.target ) ) { - return; - } - - // support: IE9 - // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe> - try { - - // Support: IE9, IE10 - // If the <body> is blurred, IE will switch windows, see #9520 - if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) { - - // Blur any element that currently has focus, see #4261 - $( document.activeElement ).blur(); - } - } catch ( error ) {} - }, - - _mouseStart: function(event) { - - var o = this.options; - - //Create and append the visible helper - this.helper = this._createHelper(event); - - this.helper.addClass("ui-draggable-dragging"); - - //Cache the helper size - this._cacheHelperProportions(); - - //If ddmanager is used for droppables, set the global draggable - if ($.ui.ddmanager) { - $.ui.ddmanager.current = this; - } - - /* - * - Position generation - - * This block generates everything position related - it's the core of draggables. - */ - - //Cache the margins of the original element - this._cacheMargins(); - - //Store the helper's css position - this.cssPosition = this.helper.css( "position" ); - this.scrollParent = this.helper.scrollParent( true ); - this.offsetParent = this.helper.offsetParent(); - this.hasFixedAncestor = this.helper.parents().filter(function() { - return $( this ).css( "position" ) === "fixed"; - }).length > 0; - - //The element's absolute position on the page minus margins - this.positionAbs = this.element.offset(); - this._refreshOffsets( event ); - - //Generate the original position - this.originalPosition = this.position = this._generatePosition( event, false ); - this.originalPageX = event.pageX; - this.originalPageY = event.pageY; - - //Adjust the mouse offset relative to the helper if "cursorAt" is supplied - (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt)); - - //Set a containment if given in the options - this._setContainment(); - - //Trigger event + callbacks - if (this._trigger("start", event) === false) { - this._clear(); - return false; - } - - //Recache the helper size - this._cacheHelperProportions(); - - //Prepare the droppable offsets - if ($.ui.ddmanager && !o.dropBehaviour) { - $.ui.ddmanager.prepareOffsets(this, event); - } - - // Reset helper's right/bottom css if they're set and set explicit width/height instead - // as this prevents resizing of elements with right/bottom set (see #7772) - this._normalizeRightBottom(); - - this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position - - //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003) - if ( $.ui.ddmanager ) { - $.ui.ddmanager.dragStart(this, event); - } - - return true; - }, - - _refreshOffsets: function( event ) { - this.offset = { - top: this.positionAbs.top - this.margins.top, - left: this.positionAbs.left - this.margins.left, - scroll: false, - parent: this._getParentOffset(), - relative: this._getRelativeOffset() - }; - - this.offset.click = { - left: event.pageX - this.offset.left, - top: event.pageY - this.offset.top - }; - }, - - _mouseDrag: function(event, noPropagation) { - // reset any necessary cached properties (see #5009) - if ( this.hasFixedAncestor ) { - this.offset.parent = this._getParentOffset(); - } - - //Compute the helpers position - this.position = this._generatePosition( event, true ); - this.positionAbs = this._convertPositionTo("absolute"); - - //Call plugins and callbacks and use the resulting position if something is returned - if (!noPropagation) { - var ui = this._uiHash(); - if (this._trigger("drag", event, ui) === false) { - this._mouseUp({}); - return false; - } - this.position = ui.position; - } - - this.helper[ 0 ].style.left = this.position.left + "px"; - this.helper[ 0 ].style.top = this.position.top + "px"; - - if ($.ui.ddmanager) { - $.ui.ddmanager.drag(this, event); - } - - return false; - }, - - _mouseStop: function(event) { - - //If we are using droppables, inform the manager about the drop - var that = this, - dropped = false; - if ($.ui.ddmanager && !this.options.dropBehaviour) { - dropped = $.ui.ddmanager.drop(this, event); - } - - //if a drop comes from outside (a sortable) - if (this.dropped) { - dropped = this.dropped; - this.dropped = false; - } - - if ((this.options.revert === "invalid" && !dropped) || (this.options.revert === "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) { - $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() { - if (that._trigger("stop", event) !== false) { - that._clear(); - } - }); - } else { - if (this._trigger("stop", event) !== false) { - this._clear(); - } - } - - return false; - }, - - _mouseUp: function( event ) { - this._unblockFrames(); - - //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003) - if ( $.ui.ddmanager ) { - $.ui.ddmanager.dragStop(this, event); - } - - // Only need to focus if the event occurred on the draggable itself, see #10527 - if ( this.handleElement.is( event.target ) ) { - // The interaction is over; whether or not the click resulted in a drag, focus the element - this.element.focus(); - } - - return $.ui.mouse.prototype._mouseUp.call(this, event); - }, - - cancel: function() { - - if (this.helper.is(".ui-draggable-dragging")) { - this._mouseUp({}); - } else { - this._clear(); - } - - return this; - - }, - - _getHandle: function(event) { - return this.options.handle ? - !!$( event.target ).closest( this.element.find( this.options.handle ) ).length : - true; - }, - - _setHandleClassName: function() { - this.handleElement = this.options.handle ? - this.element.find( this.options.handle ) : this.element; - this.handleElement.addClass( "ui-draggable-handle" ); - }, - - _removeHandleClassName: function() { - this.handleElement.removeClass( "ui-draggable-handle" ); - }, - - _createHelper: function(event) { - - var o = this.options, - helperIsFunction = $.isFunction( o.helper ), - helper = helperIsFunction ? - $( o.helper.apply( this.element[ 0 ], [ event ] ) ) : - ( o.helper === "clone" ? - this.element.clone().removeAttr( "id" ) : - this.element ); - - if (!helper.parents("body").length) { - helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo)); - } - - // http://bugs.jqueryui.com/ticket/9446 - // a helper function can return the original element - // which wouldn't have been set to relative in _create - if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) { - this._setPositionRelative(); - } - - if (helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) { - helper.css("position", "absolute"); - } - - return helper; - - }, - - _setPositionRelative: function() { - if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) { - this.element[ 0 ].style.position = "relative"; - } - }, - - _adjustOffsetFromHelper: function(obj) { - if (typeof obj === "string") { - obj = obj.split(" "); - } - if ($.isArray(obj)) { - obj = { left: +obj[0], top: +obj[1] || 0 }; - } - if ("left" in obj) { - this.offset.click.left = obj.left + this.margins.left; - } - if ("right" in obj) { - this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; - } - if ("top" in obj) { - this.offset.click.top = obj.top + this.margins.top; - } - if ("bottom" in obj) { - this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; - } - }, - - _isRootNode: function( element ) { - return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ]; - }, - - _getParentOffset: function() { - - //Get the offsetParent and cache its position - var po = this.offsetParent.offset(), - document = this.document[ 0 ]; - - // This is a special case where we need to modify a offset calculated on start, since the following happened: - // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent - // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that - // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag - if (this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) { - po.left += this.scrollParent.scrollLeft(); - po.top += this.scrollParent.scrollTop(); - } - - if ( this._isRootNode( this.offsetParent[ 0 ] ) ) { - po = { top: 0, left: 0 }; - } - - return { - top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0), - left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0) - }; - - }, - - _getRelativeOffset: function() { - if ( this.cssPosition !== "relative" ) { - return { top: 0, left: 0 }; - } - - var p = this.element.position(), - scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ); - - return { - top: p.top - ( parseInt(this.helper.css( "top" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ), - left: p.left - ( parseInt(this.helper.css( "left" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 ) - }; - - }, - - _cacheMargins: function() { - this.margins = { - left: (parseInt(this.element.css("marginLeft"), 10) || 0), - top: (parseInt(this.element.css("marginTop"), 10) || 0), - right: (parseInt(this.element.css("marginRight"), 10) || 0), - bottom: (parseInt(this.element.css("marginBottom"), 10) || 0) - }; - }, - - _cacheHelperProportions: function() { - this.helperProportions = { - width: this.helper.outerWidth(), - height: this.helper.outerHeight() - }; - }, - - _setContainment: function() { - - var isUserScrollable, c, ce, - o = this.options, - document = this.document[ 0 ]; - - this.relativeContainer = null; - - if ( !o.containment ) { - this.containment = null; - return; - } - - if ( o.containment === "window" ) { - this.containment = [ - $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left, - $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top, - $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left, - $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top - ]; - return; - } - - if ( o.containment === "document") { - this.containment = [ - 0, - 0, - $( document ).width() - this.helperProportions.width - this.margins.left, - ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top - ]; - return; - } - - if ( o.containment.constructor === Array ) { - this.containment = o.containment; - return; - } - - if ( o.containment === "parent" ) { - o.containment = this.helper[ 0 ].parentNode; - } - - c = $( o.containment ); - ce = c[ 0 ]; - - if ( !ce ) { - return; - } - - isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) ); - - this.containment = [ - ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ), - ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ), - ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - - ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - - ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) - - this.helperProportions.width - - this.margins.left - - this.margins.right, - ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - - ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) - - ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) - - this.helperProportions.height - - this.margins.top - - this.margins.bottom - ]; - this.relativeContainer = c; - }, - - _convertPositionTo: function(d, pos) { - - if (!pos) { - pos = this.position; - } - - var mod = d === "absolute" ? 1 : -1, - scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ); - - return { - top: ( - pos.top + // The absolute mouse position - this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border) - ( ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod) - ), - left: ( - pos.left + // The absolute mouse position - this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border) - ( ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod) - ) - }; - - }, - - _generatePosition: function( event, constrainPosition ) { - - var containment, co, top, left, - o = this.options, - scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ), - pageX = event.pageX, - pageY = event.pageY; - - // Cache the scroll - if ( !scrollIsRootNode || !this.offset.scroll ) { - this.offset.scroll = { - top: this.scrollParent.scrollTop(), - left: this.scrollParent.scrollLeft() - }; - } - - /* - * - Position constraining - - * Constrain the position to a mix of grid, containment. - */ - - // If we are not dragging yet, we won't check for options - if ( constrainPosition ) { - if ( this.containment ) { - if ( this.relativeContainer ){ - co = this.relativeContainer.offset(); - containment = [ - this.containment[ 0 ] + co.left, - this.containment[ 1 ] + co.top, - this.containment[ 2 ] + co.left, - this.containment[ 3 ] + co.top - ]; - } else { - containment = this.containment; - } - - if (event.pageX - this.offset.click.left < containment[0]) { - pageX = containment[0] + this.offset.click.left; - } - if (event.pageY - this.offset.click.top < containment[1]) { - pageY = containment[1] + this.offset.click.top; - } - if (event.pageX - this.offset.click.left > containment[2]) { - pageX = containment[2] + this.offset.click.left; - } - if (event.pageY - this.offset.click.top > containment[3]) { - pageY = containment[3] + this.offset.click.top; - } - } - - if (o.grid) { - //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950) - top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY; - pageY = containment ? ((top - this.offset.click.top >= containment[1] || top - this.offset.click.top > containment[3]) ? top : ((top - this.offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; - - left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX; - pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; - } - - if ( o.axis === "y" ) { - pageX = this.originalPageX; - } - - if ( o.axis === "x" ) { - pageY = this.originalPageY; - } - } - - return { - top: ( - pageY - // The absolute mouse position - this.offset.click.top - // Click offset (relative to the element) - this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.top + // The offsetParent's offset without borders (offset + border) - ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) - ), - left: ( - pageX - // The absolute mouse position - this.offset.click.left - // Click offset (relative to the element) - this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.left + // The offsetParent's offset without borders (offset + border) - ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) - ) - }; - - }, - - _clear: function() { - this.helper.removeClass("ui-draggable-dragging"); - if (this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) { - this.helper.remove(); - } - this.helper = null; - this.cancelHelperRemoval = false; - if ( this.destroyOnClear ) { - this.destroy(); - } - }, - - _normalizeRightBottom: function() { - if ( this.options.axis !== "y" && this.helper.css( "right" ) !== "auto" ) { - this.helper.width( this.helper.width() ); - this.helper.css( "right", "auto" ); - } - if ( this.options.axis !== "x" && this.helper.css( "bottom" ) !== "auto" ) { - this.helper.height( this.helper.height() ); - this.helper.css( "bottom", "auto" ); - } - }, - - // From now on bulk stuff - mainly helpers - - _trigger: function( type, event, ui ) { - ui = ui || this._uiHash(); - $.ui.plugin.call( this, type, [ event, ui, this ], true ); - - // Absolute position and offset (see #6884 ) have to be recalculated after plugins - if ( /^(drag|start|stop)/.test( type ) ) { - this.positionAbs = this._convertPositionTo( "absolute" ); - ui.offset = this.positionAbs; - } - return $.Widget.prototype._trigger.call( this, type, event, ui ); - }, - - plugins: {}, - - _uiHash: function() { - return { - helper: this.helper, - position: this.position, - originalPosition: this.originalPosition, - offset: this.positionAbs - }; - } - -}); - -$.ui.plugin.add( "draggable", "connectToSortable", { - start: function( event, ui, draggable ) { - var uiSortable = $.extend( {}, ui, { - item: draggable.element - }); - - draggable.sortables = []; - $( draggable.options.connectToSortable ).each(function() { - var sortable = $( this ).sortable( "instance" ); - - if ( sortable && !sortable.options.disabled ) { - draggable.sortables.push( sortable ); - - // refreshPositions is called at drag start to refresh the containerCache - // which is used in drag. This ensures it's initialized and synchronized - // with any changes that might have happened on the page since initialization. - sortable.refreshPositions(); - sortable._trigger("activate", event, uiSortable); - } - }); - }, - stop: function( event, ui, draggable ) { - var uiSortable = $.extend( {}, ui, { - item: draggable.element - }); - - draggable.cancelHelperRemoval = false; - - $.each( draggable.sortables, function() { - var sortable = this; - - if ( sortable.isOver ) { - sortable.isOver = 0; - - // Allow this sortable to handle removing the helper - draggable.cancelHelperRemoval = true; - sortable.cancelHelperRemoval = false; - - // Use _storedCSS To restore properties in the sortable, - // as this also handles revert (#9675) since the draggable - // may have modified them in unexpected ways (#8809) - sortable._storedCSS = { - position: sortable.placeholder.css( "position" ), - top: sortable.placeholder.css( "top" ), - left: sortable.placeholder.css( "left" ) - }; - - sortable._mouseStop(event); - - // Once drag has ended, the sortable should return to using - // its original helper, not the shared helper from draggable - sortable.options.helper = sortable.options._helper; - } else { - // Prevent this Sortable from removing the helper. - // However, don't set the draggable to remove the helper - // either as another connected Sortable may yet handle the removal. - sortable.cancelHelperRemoval = true; - - sortable._trigger( "deactivate", event, uiSortable ); - } - }); - }, - drag: function( event, ui, draggable ) { - $.each( draggable.sortables, function() { - var innermostIntersecting = false, - sortable = this; - - // Copy over variables that sortable's _intersectsWith uses - sortable.positionAbs = draggable.positionAbs; - sortable.helperProportions = draggable.helperProportions; - sortable.offset.click = draggable.offset.click; - - if ( sortable._intersectsWith( sortable.containerCache ) ) { - innermostIntersecting = true; - - $.each( draggable.sortables, function() { - // Copy over variables that sortable's _intersectsWith uses - this.positionAbs = draggable.positionAbs; - this.helperProportions = draggable.helperProportions; - this.offset.click = draggable.offset.click; - - if ( this !== sortable && - this._intersectsWith( this.containerCache ) && - $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) { - innermostIntersecting = false; - } - - return innermostIntersecting; - }); - } - - if ( innermostIntersecting ) { - // If it intersects, we use a little isOver variable and set it once, - // so that the move-in stuff gets fired only once. - if ( !sortable.isOver ) { - sortable.isOver = 1; - - // Store draggable's parent in case we need to reappend to it later. - draggable._parent = ui.helper.parent(); - - sortable.currentItem = ui.helper - .appendTo( sortable.element ) - .data( "ui-sortable-item", true ); - - // Store helper option to later restore it - sortable.options._helper = sortable.options.helper; - - sortable.options.helper = function() { - return ui.helper[ 0 ]; - }; - - // Fire the start events of the sortable with our passed browser event, - // and our own helper (so it doesn't create a new one) - event.target = sortable.currentItem[ 0 ]; - sortable._mouseCapture( event, true ); - sortable._mouseStart( event, true, true ); - - // Because the browser event is way off the new appended portlet, - // modify necessary variables to reflect the changes - sortable.offset.click.top = draggable.offset.click.top; - sortable.offset.click.left = draggable.offset.click.left; - sortable.offset.parent.left -= draggable.offset.parent.left - - sortable.offset.parent.left; - sortable.offset.parent.top -= draggable.offset.parent.top - - sortable.offset.parent.top; - - draggable._trigger( "toSortable", event ); - - // Inform draggable that the helper is in a valid drop zone, - // used solely in the revert option to handle "valid/invalid". - draggable.dropped = sortable.element; - - // Need to refreshPositions of all sortables in the case that - // adding to one sortable changes the location of the other sortables (#9675) - $.each( draggable.sortables, function() { - this.refreshPositions(); - }); - - // hack so receive/update callbacks work (mostly) - draggable.currentItem = draggable.element; - sortable.fromOutside = draggable; - } - - if ( sortable.currentItem ) { - sortable._mouseDrag( event ); - // Copy the sortable's position because the draggable's can potentially reflect - // a relative position, while sortable is always absolute, which the dragged - // element has now become. (#8809) - ui.position = sortable.position; - } - } else { - // If it doesn't intersect with the sortable, and it intersected before, - // we fake the drag stop of the sortable, but make sure it doesn't remove - // the helper by using cancelHelperRemoval. - if ( sortable.isOver ) { - - sortable.isOver = 0; - sortable.cancelHelperRemoval = true; - - // Calling sortable's mouseStop would trigger a revert, - // so revert must be temporarily false until after mouseStop is called. - sortable.options._revert = sortable.options.revert; - sortable.options.revert = false; - - sortable._trigger( "out", event, sortable._uiHash( sortable ) ); - sortable._mouseStop( event, true ); - - // restore sortable behaviors that were modfied - // when the draggable entered the sortable area (#9481) - sortable.options.revert = sortable.options._revert; - sortable.options.helper = sortable.options._helper; - - if ( sortable.placeholder ) { - sortable.placeholder.remove(); - } - - // Restore and recalculate the draggable's offset considering the sortable - // may have modified them in unexpected ways. (#8809, #10669) - ui.helper.appendTo( draggable._parent ); - draggable._refreshOffsets( event ); - ui.position = draggable._generatePosition( event, true ); - - draggable._trigger( "fromSortable", event ); - - // Inform draggable that the helper is no longer in a valid drop zone - draggable.dropped = false; - - // Need to refreshPositions of all sortables just in case removing - // from one sortable changes the location of other sortables (#9675) - $.each( draggable.sortables, function() { - this.refreshPositions(); - }); - } - } - }); - } -}); - -$.ui.plugin.add("draggable", "cursor", { - start: function( event, ui, instance ) { - var t = $( "body" ), - o = instance.options; - - if (t.css("cursor")) { - o._cursor = t.css("cursor"); - } - t.css("cursor", o.cursor); - }, - stop: function( event, ui, instance ) { - var o = instance.options; - if (o._cursor) { - $("body").css("cursor", o._cursor); - } - } -}); - -$.ui.plugin.add("draggable", "opacity", { - start: function( event, ui, instance ) { - var t = $( ui.helper ), - o = instance.options; - if (t.css("opacity")) { - o._opacity = t.css("opacity"); - } - t.css("opacity", o.opacity); - }, - stop: function( event, ui, instance ) { - var o = instance.options; - if (o._opacity) { - $(ui.helper).css("opacity", o._opacity); - } - } -}); - -$.ui.plugin.add("draggable", "scroll", { - start: function( event, ui, i ) { - if ( !i.scrollParentNotHidden ) { - i.scrollParentNotHidden = i.helper.scrollParent( false ); - } - - if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) { - i.overflowOffset = i.scrollParentNotHidden.offset(); - } - }, - drag: function( event, ui, i ) { - - var o = i.options, - scrolled = false, - scrollParent = i.scrollParentNotHidden[ 0 ], - document = i.document[ 0 ]; - - if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) { - if ( !o.axis || o.axis !== "x" ) { - if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < o.scrollSensitivity ) { - scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed; - } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) { - scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed; - } - } - - if ( !o.axis || o.axis !== "y" ) { - if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < o.scrollSensitivity ) { - scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed; - } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) { - scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed; - } - } - - } else { - - if (!o.axis || o.axis !== "x") { - if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) { - scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); - } else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) { - scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); - } - } - - if (!o.axis || o.axis !== "y") { - if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) { - scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed); - } else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) { - scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed); - } - } - - } - - if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) { - $.ui.ddmanager.prepareOffsets(i, event); - } - - } -}); - -$.ui.plugin.add("draggable", "snap", { - start: function( event, ui, i ) { - - var o = i.options; - - i.snapElements = []; - - $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() { - var $t = $(this), - $o = $t.offset(); - if (this !== i.element[0]) { - i.snapElements.push({ - item: this, - width: $t.outerWidth(), height: $t.outerHeight(), - top: $o.top, left: $o.left - }); - } - }); - - }, - drag: function( event, ui, inst ) { - - var ts, bs, ls, rs, l, r, t, b, i, first, - o = inst.options, - d = o.snapTolerance, - x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width, - y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height; - - for (i = inst.snapElements.length - 1; i >= 0; i--){ - - l = inst.snapElements[i].left - inst.margins.left; - r = l + inst.snapElements[i].width; - t = inst.snapElements[i].top - inst.margins.top; - b = t + inst.snapElements[i].height; - - if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) { - if (inst.snapElements[i].snapping) { - (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); - } - inst.snapElements[i].snapping = false; - continue; - } - - if (o.snapMode !== "inner") { - ts = Math.abs(t - y2) <= d; - bs = Math.abs(b - y1) <= d; - ls = Math.abs(l - x2) <= d; - rs = Math.abs(r - x1) <= d; - if (ts) { - ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top; - } - if (bs) { - ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top; - } - if (ls) { - ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left; - } - if (rs) { - ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left; - } - } - - first = (ts || bs || ls || rs); - - if (o.snapMode !== "outer") { - ts = Math.abs(t - y1) <= d; - bs = Math.abs(b - y2) <= d; - ls = Math.abs(l - x1) <= d; - rs = Math.abs(r - x2) <= d; - if (ts) { - ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top; - } - if (bs) { - ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top; - } - if (ls) { - ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left; - } - if (rs) { - ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left; - } - } - - if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) { - (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); - } - inst.snapElements[i].snapping = (ts || bs || ls || rs || first); - - } - - } -}); - -$.ui.plugin.add("draggable", "stack", { - start: function( event, ui, instance ) { - var min, - o = instance.options, - group = $.makeArray($(o.stack)).sort(function(a, b) { - return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0); - }); - - if (!group.length) { return; } - - min = parseInt($(group[0]).css("zIndex"), 10) || 0; - $(group).each(function(i) { - $(this).css("zIndex", min + i); - }); - this.css("zIndex", (min + group.length)); - } -}); - -$.ui.plugin.add("draggable", "zIndex", { - start: function( event, ui, instance ) { - var t = $( ui.helper ), - o = instance.options; - - if (t.css("zIndex")) { - o._zIndex = t.css("zIndex"); - } - t.css("zIndex", o.zIndex); - }, - stop: function( event, ui, instance ) { - var o = instance.options; - - if (o._zIndex) { - $(ui.helper).css("zIndex", o._zIndex); - } - } -}); - -var draggable = $.ui.draggable; - - -/*! - * jQuery UI Resizable 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/resizable/ - */ - - -$.widget("ui.resizable", $.ui.mouse, { - version: "1.11.4", - widgetEventPrefix: "resize", - options: { - alsoResize: false, - animate: false, - animateDuration: "slow", - animateEasing: "swing", - aspectRatio: false, - autoHide: false, - containment: false, - ghost: false, - grid: false, - handles: "e,s,se", - helper: false, - maxHeight: null, - maxWidth: null, - minHeight: 10, - minWidth: 10, - // See #7960 - zIndex: 90, - - // callbacks - resize: null, - start: null, - stop: null - }, - - _num: function( value ) { - return parseInt( value, 10 ) || 0; - }, - - _isNumber: function( value ) { - return !isNaN( parseInt( value, 10 ) ); - }, - - _hasScroll: function( el, a ) { - - if ( $( el ).css( "overflow" ) === "hidden") { - return false; - } - - var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop", - has = false; - - if ( el[ scroll ] > 0 ) { - return true; - } - - // TODO: determine which cases actually cause this to happen - // if the element doesn't have the scroll set, see if it's possible to - // set the scroll - el[ scroll ] = 1; - has = ( el[ scroll ] > 0 ); - el[ scroll ] = 0; - return has; - }, - - _create: function() { - - var n, i, handle, axis, hname, - that = this, - o = this.options; - this.element.addClass("ui-resizable"); - - $.extend(this, { - _aspectRatio: !!(o.aspectRatio), - aspectRatio: o.aspectRatio, - originalElement: this.element, - _proportionallyResizeElements: [], - _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null - }); - - // Wrap the element if it cannot hold child nodes - if (this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)) { - - this.element.wrap( - $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({ - position: this.element.css("position"), - width: this.element.outerWidth(), - height: this.element.outerHeight(), - top: this.element.css("top"), - left: this.element.css("left") - }) - ); - - this.element = this.element.parent().data( - "ui-resizable", this.element.resizable( "instance" ) - ); - - this.elementIsWrapper = true; - - this.element.css({ - marginLeft: this.originalElement.css("marginLeft"), - marginTop: this.originalElement.css("marginTop"), - marginRight: this.originalElement.css("marginRight"), - marginBottom: this.originalElement.css("marginBottom") - }); - this.originalElement.css({ - marginLeft: 0, - marginTop: 0, - marginRight: 0, - marginBottom: 0 - }); - // support: Safari - // Prevent Safari textarea resize - this.originalResizeStyle = this.originalElement.css("resize"); - this.originalElement.css("resize", "none"); - - this._proportionallyResizeElements.push( this.originalElement.css({ - position: "static", - zoom: 1, - display: "block" - }) ); - - // support: IE9 - // avoid IE jump (hard set the margin) - this.originalElement.css({ margin: this.originalElement.css("margin") }); - - this._proportionallyResize(); - } - - this.handles = o.handles || - ( !$(".ui-resizable-handle", this.element).length ? - "e,s,se" : { - n: ".ui-resizable-n", - e: ".ui-resizable-e", - s: ".ui-resizable-s", - w: ".ui-resizable-w", - se: ".ui-resizable-se", - sw: ".ui-resizable-sw", - ne: ".ui-resizable-ne", - nw: ".ui-resizable-nw" - } ); - - this._handles = $(); - if ( this.handles.constructor === String ) { - - if ( this.handles === "all") { - this.handles = "n,e,s,w,se,sw,ne,nw"; - } - - n = this.handles.split(","); - this.handles = {}; - - for (i = 0; i < n.length; i++) { - - handle = $.trim(n[i]); - hname = "ui-resizable-" + handle; - axis = $("<div class='ui-resizable-handle " + hname + "'></div>"); - - axis.css({ zIndex: o.zIndex }); - - // TODO : What's going on here? - if ("se" === handle) { - axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se"); - } - - this.handles[handle] = ".ui-resizable-" + handle; - this.element.append(axis); - } - - } - - this._renderAxis = function(target) { - - var i, axis, padPos, padWrapper; - - target = target || this.element; - - for (i in this.handles) { - - if (this.handles[i].constructor === String) { - this.handles[i] = this.element.children( this.handles[ i ] ).first().show(); - } else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) { - this.handles[ i ] = $( this.handles[ i ] ); - this._on( this.handles[ i ], { "mousedown": that._mouseDown }); - } - - if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)) { - - axis = $(this.handles[i], this.element); - - padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth(); - - padPos = [ "padding", - /ne|nw|n/.test(i) ? "Top" : - /se|sw|s/.test(i) ? "Bottom" : - /^e$/.test(i) ? "Right" : "Left" ].join(""); - - target.css(padPos, padWrapper); - - this._proportionallyResize(); - } - - this._handles = this._handles.add( this.handles[ i ] ); - } - }; - - // TODO: make renderAxis a prototype function - this._renderAxis(this.element); - - this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) ); - this._handles.disableSelection(); - - this._handles.mouseover(function() { - if (!that.resizing) { - if (this.className) { - axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i); - } - that.axis = axis && axis[1] ? axis[1] : "se"; - } - }); - - if (o.autoHide) { - this._handles.hide(); - $(this.element) - .addClass("ui-resizable-autohide") - .mouseenter(function() { - if (o.disabled) { - return; - } - $(this).removeClass("ui-resizable-autohide"); - that._handles.show(); - }) - .mouseleave(function() { - if (o.disabled) { - return; - } - if (!that.resizing) { - $(this).addClass("ui-resizable-autohide"); - that._handles.hide(); - } - }); - } - - this._mouseInit(); - }, - - _destroy: function() { - - this._mouseDestroy(); - - var wrapper, - _destroy = function(exp) { - $(exp) - .removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing") - .removeData("resizable") - .removeData("ui-resizable") - .unbind(".resizable") - .find(".ui-resizable-handle") - .remove(); - }; - - // TODO: Unwrap at same DOM position - if (this.elementIsWrapper) { - _destroy(this.element); - wrapper = this.element; - this.originalElement.css({ - position: wrapper.css("position"), - width: wrapper.outerWidth(), - height: wrapper.outerHeight(), - top: wrapper.css("top"), - left: wrapper.css("left") - }).insertAfter( wrapper ); - wrapper.remove(); - } - - this.originalElement.css("resize", this.originalResizeStyle); - _destroy(this.originalElement); - - return this; - }, - - _mouseCapture: function(event) { - var i, handle, - capture = false; - - for (i in this.handles) { - handle = $(this.handles[i])[0]; - if (handle === event.target || $.contains(handle, event.target)) { - capture = true; - } - } - - return !this.options.disabled && capture; - }, - - _mouseStart: function(event) { - - var curleft, curtop, cursor, - o = this.options, - el = this.element; - - this.resizing = true; - - this._renderProxy(); - - curleft = this._num(this.helper.css("left")); - curtop = this._num(this.helper.css("top")); - - if (o.containment) { - curleft += $(o.containment).scrollLeft() || 0; - curtop += $(o.containment).scrollTop() || 0; - } - - this.offset = this.helper.offset(); - this.position = { left: curleft, top: curtop }; - - this.size = this._helper ? { - width: this.helper.width(), - height: this.helper.height() - } : { - width: el.width(), - height: el.height() - }; - - this.originalSize = this._helper ? { - width: el.outerWidth(), - height: el.outerHeight() - } : { - width: el.width(), - height: el.height() - }; - - this.sizeDiff = { - width: el.outerWidth() - el.width(), - height: el.outerHeight() - el.height() - }; - - this.originalPosition = { left: curleft, top: curtop }; - this.originalMousePosition = { left: event.pageX, top: event.pageY }; - - this.aspectRatio = (typeof o.aspectRatio === "number") ? - o.aspectRatio : - ((this.originalSize.width / this.originalSize.height) || 1); - - cursor = $(".ui-resizable-" + this.axis).css("cursor"); - $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor); - - el.addClass("ui-resizable-resizing"); - this._propagate("start", event); - return true; - }, - - _mouseDrag: function(event) { - - var data, props, - smp = this.originalMousePosition, - a = this.axis, - dx = (event.pageX - smp.left) || 0, - dy = (event.pageY - smp.top) || 0, - trigger = this._change[a]; - - this._updatePrevProperties(); - - if (!trigger) { - return false; - } - - data = trigger.apply(this, [ event, dx, dy ]); - - this._updateVirtualBoundaries(event.shiftKey); - if (this._aspectRatio || event.shiftKey) { - data = this._updateRatio(data, event); - } - - data = this._respectSize(data, event); - - this._updateCache(data); - - this._propagate("resize", event); - - props = this._applyChanges(); - - if ( !this._helper && this._proportionallyResizeElements.length ) { - this._proportionallyResize(); - } - - if ( !$.isEmptyObject( props ) ) { - this._updatePrevProperties(); - this._trigger( "resize", event, this.ui() ); - this._applyChanges(); - } - - return false; - }, - - _mouseStop: function(event) { - - this.resizing = false; - var pr, ista, soffseth, soffsetw, s, left, top, - o = this.options, that = this; - - if (this._helper) { - - pr = this._proportionallyResizeElements; - ista = pr.length && (/textarea/i).test(pr[0].nodeName); - soffseth = ista && this._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height; - soffsetw = ista ? 0 : that.sizeDiff.width; - - s = { - width: (that.helper.width() - soffsetw), - height: (that.helper.height() - soffseth) - }; - left = (parseInt(that.element.css("left"), 10) + - (that.position.left - that.originalPosition.left)) || null; - top = (parseInt(that.element.css("top"), 10) + - (that.position.top - that.originalPosition.top)) || null; - - if (!o.animate) { - this.element.css($.extend(s, { top: top, left: left })); - } - - that.helper.height(that.size.height); - that.helper.width(that.size.width); - - if (this._helper && !o.animate) { - this._proportionallyResize(); - } - } - - $("body").css("cursor", "auto"); - - this.element.removeClass("ui-resizable-resizing"); - - this._propagate("stop", event); - - if (this._helper) { - this.helper.remove(); - } - - return false; - - }, - - _updatePrevProperties: function() { - this.prevPosition = { - top: this.position.top, - left: this.position.left - }; - this.prevSize = { - width: this.size.width, - height: this.size.height - }; - }, - - _applyChanges: function() { - var props = {}; - - if ( this.position.top !== this.prevPosition.top ) { - props.top = this.position.top + "px"; - } - if ( this.position.left !== this.prevPosition.left ) { - props.left = this.position.left + "px"; - } - if ( this.size.width !== this.prevSize.width ) { - props.width = this.size.width + "px"; - } - if ( this.size.height !== this.prevSize.height ) { - props.height = this.size.height + "px"; - } - - this.helper.css( props ); - - return props; - }, - - _updateVirtualBoundaries: function(forceAspectRatio) { - var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b, - o = this.options; - - b = { - minWidth: this._isNumber(o.minWidth) ? o.minWidth : 0, - maxWidth: this._isNumber(o.maxWidth) ? o.maxWidth : Infinity, - minHeight: this._isNumber(o.minHeight) ? o.minHeight : 0, - maxHeight: this._isNumber(o.maxHeight) ? o.maxHeight : Infinity - }; - - if (this._aspectRatio || forceAspectRatio) { - pMinWidth = b.minHeight * this.aspectRatio; - pMinHeight = b.minWidth / this.aspectRatio; - pMaxWidth = b.maxHeight * this.aspectRatio; - pMaxHeight = b.maxWidth / this.aspectRatio; - - if (pMinWidth > b.minWidth) { - b.minWidth = pMinWidth; - } - if (pMinHeight > b.minHeight) { - b.minHeight = pMinHeight; - } - if (pMaxWidth < b.maxWidth) { - b.maxWidth = pMaxWidth; - } - if (pMaxHeight < b.maxHeight) { - b.maxHeight = pMaxHeight; - } - } - this._vBoundaries = b; - }, - - _updateCache: function(data) { - this.offset = this.helper.offset(); - if (this._isNumber(data.left)) { - this.position.left = data.left; - } - if (this._isNumber(data.top)) { - this.position.top = data.top; - } - if (this._isNumber(data.height)) { - this.size.height = data.height; - } - if (this._isNumber(data.width)) { - this.size.width = data.width; - } - }, - - _updateRatio: function( data ) { - - var cpos = this.position, - csize = this.size, - a = this.axis; - - if (this._isNumber(data.height)) { - data.width = (data.height * this.aspectRatio); - } else if (this._isNumber(data.width)) { - data.height = (data.width / this.aspectRatio); - } - - if (a === "sw") { - data.left = cpos.left + (csize.width - data.width); - data.top = null; - } - if (a === "nw") { - data.top = cpos.top + (csize.height - data.height); - data.left = cpos.left + (csize.width - data.width); - } - - return data; - }, - - _respectSize: function( data ) { - - var o = this._vBoundaries, - a = this.axis, - ismaxw = this._isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), - ismaxh = this._isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height), - isminw = this._isNumber(data.width) && o.minWidth && (o.minWidth > data.width), - isminh = this._isNumber(data.height) && o.minHeight && (o.minHeight > data.height), - dw = this.originalPosition.left + this.originalSize.width, - dh = this.position.top + this.size.height, - cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a); - if (isminw) { - data.width = o.minWidth; - } - if (isminh) { - data.height = o.minHeight; - } - if (ismaxw) { - data.width = o.maxWidth; - } - if (ismaxh) { - data.height = o.maxHeight; - } - - if (isminw && cw) { - data.left = dw - o.minWidth; - } - if (ismaxw && cw) { - data.left = dw - o.maxWidth; - } - if (isminh && ch) { - data.top = dh - o.minHeight; - } - if (ismaxh && ch) { - data.top = dh - o.maxHeight; - } - - // Fixing jump error on top/left - bug #2330 - if (!data.width && !data.height && !data.left && data.top) { - data.top = null; - } else if (!data.width && !data.height && !data.top && data.left) { - data.left = null; - } - - return data; - }, - - _getPaddingPlusBorderDimensions: function( element ) { - var i = 0, - widths = [], - borders = [ - element.css( "borderTopWidth" ), - element.css( "borderRightWidth" ), - element.css( "borderBottomWidth" ), - element.css( "borderLeftWidth" ) - ], - paddings = [ - element.css( "paddingTop" ), - element.css( "paddingRight" ), - element.css( "paddingBottom" ), - element.css( "paddingLeft" ) - ]; - - for ( ; i < 4; i++ ) { - widths[ i ] = ( parseInt( borders[ i ], 10 ) || 0 ); - widths[ i ] += ( parseInt( paddings[ i ], 10 ) || 0 ); - } - - return { - height: widths[ 0 ] + widths[ 2 ], - width: widths[ 1 ] + widths[ 3 ] - }; - }, - - _proportionallyResize: function() { - - if (!this._proportionallyResizeElements.length) { - return; - } - - var prel, - i = 0, - element = this.helper || this.element; - - for ( ; i < this._proportionallyResizeElements.length; i++) { - - prel = this._proportionallyResizeElements[i]; - - // TODO: Seems like a bug to cache this.outerDimensions - // considering that we are in a loop. - if (!this.outerDimensions) { - this.outerDimensions = this._getPaddingPlusBorderDimensions( prel ); - } - - prel.css({ - height: (element.height() - this.outerDimensions.height) || 0, - width: (element.width() - this.outerDimensions.width) || 0 - }); - - } - - }, - - _renderProxy: function() { - - var el = this.element, o = this.options; - this.elementOffset = el.offset(); - - if (this._helper) { - - this.helper = this.helper || $("<div style='overflow:hidden;'></div>"); - - this.helper.addClass(this._helper).css({ - width: this.element.outerWidth() - 1, - height: this.element.outerHeight() - 1, - position: "absolute", - left: this.elementOffset.left + "px", - top: this.elementOffset.top + "px", - zIndex: ++o.zIndex //TODO: Don't modify option - }); - - this.helper - .appendTo("body") - .disableSelection(); - - } else { - this.helper = this.element; - } - - }, - - _change: { - e: function(event, dx) { - return { width: this.originalSize.width + dx }; - }, - w: function(event, dx) { - var cs = this.originalSize, sp = this.originalPosition; - return { left: sp.left + dx, width: cs.width - dx }; - }, - n: function(event, dx, dy) { - var cs = this.originalSize, sp = this.originalPosition; - return { top: sp.top + dy, height: cs.height - dy }; - }, - s: function(event, dx, dy) { - return { height: this.originalSize.height + dy }; - }, - se: function(event, dx, dy) { - return $.extend(this._change.s.apply(this, arguments), - this._change.e.apply(this, [ event, dx, dy ])); - }, - sw: function(event, dx, dy) { - return $.extend(this._change.s.apply(this, arguments), - this._change.w.apply(this, [ event, dx, dy ])); - }, - ne: function(event, dx, dy) { - return $.extend(this._change.n.apply(this, arguments), - this._change.e.apply(this, [ event, dx, dy ])); - }, - nw: function(event, dx, dy) { - return $.extend(this._change.n.apply(this, arguments), - this._change.w.apply(this, [ event, dx, dy ])); - } - }, - - _propagate: function(n, event) { - $.ui.plugin.call(this, n, [ event, this.ui() ]); - (n !== "resize" && this._trigger(n, event, this.ui())); - }, - - plugins: {}, - - ui: function() { - return { - originalElement: this.originalElement, - element: this.element, - helper: this.helper, - position: this.position, - size: this.size, - originalSize: this.originalSize, - originalPosition: this.originalPosition - }; - } - -}); - -/* - * Resizable Extensions - */ - -$.ui.plugin.add("resizable", "animate", { - - stop: function( event ) { - var that = $(this).resizable( "instance" ), - o = that.options, - pr = that._proportionallyResizeElements, - ista = pr.length && (/textarea/i).test(pr[0].nodeName), - soffseth = ista && that._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height, - soffsetw = ista ? 0 : that.sizeDiff.width, - style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) }, - left = (parseInt(that.element.css("left"), 10) + - (that.position.left - that.originalPosition.left)) || null, - top = (parseInt(that.element.css("top"), 10) + - (that.position.top - that.originalPosition.top)) || null; - - that.element.animate( - $.extend(style, top && left ? { top: top, left: left } : {}), { - duration: o.animateDuration, - easing: o.animateEasing, - step: function() { - - var data = { - width: parseInt(that.element.css("width"), 10), - height: parseInt(that.element.css("height"), 10), - top: parseInt(that.element.css("top"), 10), - left: parseInt(that.element.css("left"), 10) - }; - - if (pr && pr.length) { - $(pr[0]).css({ width: data.width, height: data.height }); - } - - // propagating resize, and updating values for each animation step - that._updateCache(data); - that._propagate("resize", event); - - } - } - ); - } - -}); - -$.ui.plugin.add( "resizable", "containment", { - - start: function() { - var element, p, co, ch, cw, width, height, - that = $( this ).resizable( "instance" ), - o = that.options, - el = that.element, - oc = o.containment, - ce = ( oc instanceof $ ) ? oc.get( 0 ) : ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc; - - if ( !ce ) { - return; - } - - that.containerElement = $( ce ); - - if ( /document/.test( oc ) || oc === document ) { - that.containerOffset = { - left: 0, - top: 0 - }; - that.containerPosition = { - left: 0, - top: 0 - }; - - that.parentData = { - element: $( document ), - left: 0, - top: 0, - width: $( document ).width(), - height: $( document ).height() || document.body.parentNode.scrollHeight - }; - } else { - element = $( ce ); - p = []; - $([ "Top", "Right", "Left", "Bottom" ]).each(function( i, name ) { - p[ i ] = that._num( element.css( "padding" + name ) ); - }); - - that.containerOffset = element.offset(); - that.containerPosition = element.position(); - that.containerSize = { - height: ( element.innerHeight() - p[ 3 ] ), - width: ( element.innerWidth() - p[ 1 ] ) - }; - - co = that.containerOffset; - ch = that.containerSize.height; - cw = that.containerSize.width; - width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw ); - height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ; - - that.parentData = { - element: ce, - left: co.left, - top: co.top, - width: width, - height: height - }; - } - }, - - resize: function( event ) { - var woset, hoset, isParent, isOffsetRelative, - that = $( this ).resizable( "instance" ), - o = that.options, - co = that.containerOffset, - cp = that.position, - pRatio = that._aspectRatio || event.shiftKey, - cop = { - top: 0, - left: 0 - }, - ce = that.containerElement, - continueResize = true; - - if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) { - cop = co; - } - - if ( cp.left < ( that._helper ? co.left : 0 ) ) { - that.size.width = that.size.width + - ( that._helper ? - ( that.position.left - co.left ) : - ( that.position.left - cop.left ) ); - - if ( pRatio ) { - that.size.height = that.size.width / that.aspectRatio; - continueResize = false; - } - that.position.left = o.helper ? co.left : 0; - } - - if ( cp.top < ( that._helper ? co.top : 0 ) ) { - that.size.height = that.size.height + - ( that._helper ? - ( that.position.top - co.top ) : - that.position.top ); - - if ( pRatio ) { - that.size.width = that.size.height * that.aspectRatio; - continueResize = false; - } - that.position.top = that._helper ? co.top : 0; - } - - isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 ); - isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) ); - - if ( isParent && isOffsetRelative ) { - that.offset.left = that.parentData.left + that.position.left; - that.offset.top = that.parentData.top + that.position.top; - } else { - that.offset.left = that.element.offset().left; - that.offset.top = that.element.offset().top; - } - - woset = Math.abs( that.sizeDiff.width + - (that._helper ? - that.offset.left - cop.left : - (that.offset.left - co.left)) ); - - hoset = Math.abs( that.sizeDiff.height + - (that._helper ? - that.offset.top - cop.top : - (that.offset.top - co.top)) ); - - if ( woset + that.size.width >= that.parentData.width ) { - that.size.width = that.parentData.width - woset; - if ( pRatio ) { - that.size.height = that.size.width / that.aspectRatio; - continueResize = false; - } - } - - if ( hoset + that.size.height >= that.parentData.height ) { - that.size.height = that.parentData.height - hoset; - if ( pRatio ) { - that.size.width = that.size.height * that.aspectRatio; - continueResize = false; - } - } - - if ( !continueResize ) { - that.position.left = that.prevPosition.left; - that.position.top = that.prevPosition.top; - that.size.width = that.prevSize.width; - that.size.height = that.prevSize.height; - } - }, - - stop: function() { - var that = $( this ).resizable( "instance" ), - o = that.options, - co = that.containerOffset, - cop = that.containerPosition, - ce = that.containerElement, - helper = $( that.helper ), - ho = helper.offset(), - w = helper.outerWidth() - that.sizeDiff.width, - h = helper.outerHeight() - that.sizeDiff.height; - - if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) { - $( this ).css({ - left: ho.left - cop.left - co.left, - width: w, - height: h - }); - } - - if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) { - $( this ).css({ - left: ho.left - cop.left - co.left, - width: w, - height: h - }); - } - } -}); - -$.ui.plugin.add("resizable", "alsoResize", { - - start: function() { - var that = $(this).resizable( "instance" ), - o = that.options; - - $(o.alsoResize).each(function() { - var el = $(this); - el.data("ui-resizable-alsoresize", { - width: parseInt(el.width(), 10), height: parseInt(el.height(), 10), - left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10) - }); - }); - }, - - resize: function(event, ui) { - var that = $(this).resizable( "instance" ), - o = that.options, - os = that.originalSize, - op = that.originalPosition, - delta = { - height: (that.size.height - os.height) || 0, - width: (that.size.width - os.width) || 0, - top: (that.position.top - op.top) || 0, - left: (that.position.left - op.left) || 0 - }; - - $(o.alsoResize).each(function() { - var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {}, - css = el.parents(ui.originalElement[0]).length ? - [ "width", "height" ] : - [ "width", "height", "top", "left" ]; - - $.each(css, function(i, prop) { - var sum = (start[prop] || 0) + (delta[prop] || 0); - if (sum && sum >= 0) { - style[prop] = sum || null; - } - }); - - el.css(style); - }); - }, - - stop: function() { - $(this).removeData("resizable-alsoresize"); - } -}); - -$.ui.plugin.add("resizable", "ghost", { - - start: function() { - - var that = $(this).resizable( "instance" ), o = that.options, cs = that.size; - - that.ghost = that.originalElement.clone(); - that.ghost - .css({ - opacity: 0.25, - display: "block", - position: "relative", - height: cs.height, - width: cs.width, - margin: 0, - left: 0, - top: 0 - }) - .addClass("ui-resizable-ghost") - .addClass(typeof o.ghost === "string" ? o.ghost : ""); - - that.ghost.appendTo(that.helper); - - }, - - resize: function() { - var that = $(this).resizable( "instance" ); - if (that.ghost) { - that.ghost.css({ - position: "relative", - height: that.size.height, - width: that.size.width - }); - } - }, - - stop: function() { - var that = $(this).resizable( "instance" ); - if (that.ghost && that.helper) { - that.helper.get(0).removeChild(that.ghost.get(0)); - } - } - -}); - -$.ui.plugin.add("resizable", "grid", { - - resize: function() { - var outerDimensions, - that = $(this).resizable( "instance" ), - o = that.options, - cs = that.size, - os = that.originalSize, - op = that.originalPosition, - a = that.axis, - grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid, - gridX = (grid[0] || 1), - gridY = (grid[1] || 1), - ox = Math.round((cs.width - os.width) / gridX) * gridX, - oy = Math.round((cs.height - os.height) / gridY) * gridY, - newWidth = os.width + ox, - newHeight = os.height + oy, - isMaxWidth = o.maxWidth && (o.maxWidth < newWidth), - isMaxHeight = o.maxHeight && (o.maxHeight < newHeight), - isMinWidth = o.minWidth && (o.minWidth > newWidth), - isMinHeight = o.minHeight && (o.minHeight > newHeight); - - o.grid = grid; - - if (isMinWidth) { - newWidth += gridX; - } - if (isMinHeight) { - newHeight += gridY; - } - if (isMaxWidth) { - newWidth -= gridX; - } - if (isMaxHeight) { - newHeight -= gridY; - } - - if (/^(se|s|e)$/.test(a)) { - that.size.width = newWidth; - that.size.height = newHeight; - } else if (/^(ne)$/.test(a)) { - that.size.width = newWidth; - that.size.height = newHeight; - that.position.top = op.top - oy; - } else if (/^(sw)$/.test(a)) { - that.size.width = newWidth; - that.size.height = newHeight; - that.position.left = op.left - ox; - } else { - if ( newHeight - gridY <= 0 || newWidth - gridX <= 0) { - outerDimensions = that._getPaddingPlusBorderDimensions( this ); - } - - if ( newHeight - gridY > 0 ) { - that.size.height = newHeight; - that.position.top = op.top - oy; - } else { - newHeight = gridY - outerDimensions.height; - that.size.height = newHeight; - that.position.top = op.top + os.height - newHeight; - } - if ( newWidth - gridX > 0 ) { - that.size.width = newWidth; - that.position.left = op.left - ox; - } else { - newWidth = gridX - outerDimensions.width; - that.size.width = newWidth; - that.position.left = op.left + os.width - newWidth; - } - } - } - -}); - -var resizable = $.ui.resizable; - - -/*! - * jQuery UI Dialog 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/dialog/ - */ - - -var dialog = $.widget( "ui.dialog", { - version: "1.11.4", - options: { - appendTo: "body", - autoOpen: true, - buttons: [], - closeOnEscape: true, - closeText: "Close", - dialogClass: "", - draggable: true, - hide: null, - height: "auto", - maxHeight: null, - maxWidth: null, - minHeight: 150, - minWidth: 150, - modal: false, - position: { - my: "center", - at: "center", - of: window, - collision: "fit", - // Ensure the titlebar is always visible - using: function( pos ) { - var topOffset = $( this ).css( pos ).offset().top; - if ( topOffset < 0 ) { - $( this ).css( "top", pos.top - topOffset ); - } - } - }, - resizable: true, - show: null, - title: null, - width: 300, - - // callbacks - beforeClose: null, - close: null, - drag: null, - dragStart: null, - dragStop: null, - focus: null, - open: null, - resize: null, - resizeStart: null, - resizeStop: null - }, - - sizeRelatedOptions: { - buttons: true, - height: true, - maxHeight: true, - maxWidth: true, - minHeight: true, - minWidth: true, - width: true - }, - - resizableRelatedOptions: { - maxHeight: true, - maxWidth: true, - minHeight: true, - minWidth: true - }, - - _create: function() { - this.originalCss = { - display: this.element[ 0 ].style.display, - width: this.element[ 0 ].style.width, - minHeight: this.element[ 0 ].style.minHeight, - maxHeight: this.element[ 0 ].style.maxHeight, - height: this.element[ 0 ].style.height - }; - this.originalPosition = { - parent: this.element.parent(), - index: this.element.parent().children().index( this.element ) - }; - this.originalTitle = this.element.attr( "title" ); - this.options.title = this.options.title || this.originalTitle; - - this._createWrapper(); - - this.element - .show() - .removeAttr( "title" ) - .addClass( "ui-dialog-content ui-widget-content" ) - .appendTo( this.uiDialog ); - - this._createTitlebar(); - this._createButtonPane(); - - if ( this.options.draggable && $.fn.draggable ) { - this._makeDraggable(); - } - if ( this.options.resizable && $.fn.resizable ) { - this._makeResizable(); - } - - this._isOpen = false; - - this._trackFocus(); - }, - - _init: function() { - if ( this.options.autoOpen ) { - this.open(); - } - }, - - _appendTo: function() { - var element = this.options.appendTo; - if ( element && (element.jquery || element.nodeType) ) { - return $( element ); - } - return this.document.find( element || "body" ).eq( 0 ); - }, - - _destroy: function() { - var next, - originalPosition = this.originalPosition; - - this._untrackInstance(); - this._destroyOverlay(); - - this.element - .removeUniqueId() - .removeClass( "ui-dialog-content ui-widget-content" ) - .css( this.originalCss ) - // Without detaching first, the following becomes really slow - .detach(); - - this.uiDialog.stop( true, true ).remove(); - - if ( this.originalTitle ) { - this.element.attr( "title", this.originalTitle ); - } - - next = originalPosition.parent.children().eq( originalPosition.index ); - // Don't try to place the dialog next to itself (#8613) - if ( next.length && next[ 0 ] !== this.element[ 0 ] ) { - next.before( this.element ); - } else { - originalPosition.parent.append( this.element ); - } - }, - - widget: function() { - return this.uiDialog; - }, - - disable: $.noop, - enable: $.noop, - - close: function( event ) { - var activeElement, - that = this; - - if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) { - return; - } - - this._isOpen = false; - this._focusedElement = null; - this._destroyOverlay(); - this._untrackInstance(); - - if ( !this.opener.filter( ":focusable" ).focus().length ) { - - // support: IE9 - // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe> - try { - activeElement = this.document[ 0 ].activeElement; - - // Support: IE9, IE10 - // If the <body> is blurred, IE will switch windows, see #4520 - if ( activeElement && activeElement.nodeName.toLowerCase() !== "body" ) { - - // Hiding a focused element doesn't trigger blur in WebKit - // so in case we have nothing to focus on, explicitly blur the active element - // https://bugs.webkit.org/show_bug.cgi?id=47182 - $( activeElement ).blur(); - } - } catch ( error ) {} - } - - this._hide( this.uiDialog, this.options.hide, function() { - that._trigger( "close", event ); - }); - }, - - isOpen: function() { - return this._isOpen; - }, - - moveToTop: function() { - this._moveToTop(); - }, - - _moveToTop: function( event, silent ) { - var moved = false, - zIndices = this.uiDialog.siblings( ".ui-front:visible" ).map(function() { - return +$( this ).css( "z-index" ); - }).get(), - zIndexMax = Math.max.apply( null, zIndices ); - - if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) { - this.uiDialog.css( "z-index", zIndexMax + 1 ); - moved = true; - } - - if ( moved && !silent ) { - this._trigger( "focus", event ); - } - return moved; - }, - - open: function() { - var that = this; - if ( this._isOpen ) { - if ( this._moveToTop() ) { - this._focusTabbable(); - } - return; - } - - this._isOpen = true; - this.opener = $( this.document[ 0 ].activeElement ); - - this._size(); - this._position(); - this._createOverlay(); - this._moveToTop( null, true ); - - // Ensure the overlay is moved to the top with the dialog, but only when - // opening. The overlay shouldn't move after the dialog is open so that - // modeless dialogs opened after the modal dialog stack properly. - if ( this.overlay ) { - this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 ); - } - - this._show( this.uiDialog, this.options.show, function() { - that._focusTabbable(); - that._trigger( "focus" ); - }); - - // Track the dialog immediately upon openening in case a focus event - // somehow occurs outside of the dialog before an element inside the - // dialog is focused (#10152) - this._makeFocusTarget(); - - this._trigger( "open" ); - }, - - _focusTabbable: function() { - // Set focus to the first match: - // 1. An element that was focused previously - // 2. First element inside the dialog matching [autofocus] - // 3. Tabbable element inside the content element - // 4. Tabbable element inside the buttonpane - // 5. The close button - // 6. The dialog itself - var hasFocus = this._focusedElement; - if ( !hasFocus ) { - hasFocus = this.element.find( "[autofocus]" ); - } - if ( !hasFocus.length ) { - hasFocus = this.element.find( ":tabbable" ); - } - if ( !hasFocus.length ) { - hasFocus = this.uiDialogButtonPane.find( ":tabbable" ); - } - if ( !hasFocus.length ) { - hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" ); - } - if ( !hasFocus.length ) { - hasFocus = this.uiDialog; - } - hasFocus.eq( 0 ).focus(); - }, - - _keepFocus: function( event ) { - function checkFocus() { - var activeElement = this.document[0].activeElement, - isActive = this.uiDialog[0] === activeElement || - $.contains( this.uiDialog[0], activeElement ); - if ( !isActive ) { - this._focusTabbable(); - } - } - event.preventDefault(); - checkFocus.call( this ); - // support: IE - // IE <= 8 doesn't prevent moving focus even with event.preventDefault() - // so we check again later - this._delay( checkFocus ); - }, - - _createWrapper: function() { - this.uiDialog = $("<div>") - .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " + - this.options.dialogClass ) - .hide() - .attr({ - // Setting tabIndex makes the div focusable - tabIndex: -1, - role: "dialog" - }) - .appendTo( this._appendTo() ); - - this._on( this.uiDialog, { - keydown: function( event ) { - if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode && - event.keyCode === $.ui.keyCode.ESCAPE ) { - event.preventDefault(); - this.close( event ); - return; - } - - // prevent tabbing out of dialogs - if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) { - return; - } - var tabbables = this.uiDialog.find( ":tabbable" ), - first = tabbables.filter( ":first" ), - last = tabbables.filter( ":last" ); - - if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) { - this._delay(function() { - first.focus(); - }); - event.preventDefault(); - } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) { - this._delay(function() { - last.focus(); - }); - event.preventDefault(); - } - }, - mousedown: function( event ) { - if ( this._moveToTop( event ) ) { - this._focusTabbable(); - } - } - }); - - // We assume that any existing aria-describedby attribute means - // that the dialog content is marked up properly - // otherwise we brute force the content as the description - if ( !this.element.find( "[aria-describedby]" ).length ) { - this.uiDialog.attr({ - "aria-describedby": this.element.uniqueId().attr( "id" ) - }); - } - }, - - _createTitlebar: function() { - var uiDialogTitle; - - this.uiDialogTitlebar = $( "<div>" ) - .addClass( "ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" ) - .prependTo( this.uiDialog ); - this._on( this.uiDialogTitlebar, { - mousedown: function( event ) { - // Don't prevent click on close button (#8838) - // Focusing a dialog that is partially scrolled out of view - // causes the browser to scroll it into view, preventing the click event - if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) { - // Dialog isn't getting focus when dragging (#8063) - this.uiDialog.focus(); - } - } - }); - - // support: IE - // Use type="button" to prevent enter keypresses in textboxes from closing the - // dialog in IE (#9312) - this.uiDialogTitlebarClose = $( "<button type='button'></button>" ) - .button({ - label: this.options.closeText, - icons: { - primary: "ui-icon-closethick" - }, - text: false - }) - .addClass( "ui-dialog-titlebar-close" ) - .appendTo( this.uiDialogTitlebar ); - this._on( this.uiDialogTitlebarClose, { - click: function( event ) { - event.preventDefault(); - this.close( event ); - } - }); - - uiDialogTitle = $( "<span>" ) - .uniqueId() - .addClass( "ui-dialog-title" ) - .prependTo( this.uiDialogTitlebar ); - this._title( uiDialogTitle ); - - this.uiDialog.attr({ - "aria-labelledby": uiDialogTitle.attr( "id" ) - }); - }, - - _title: function( title ) { - if ( !this.options.title ) { - title.html( " " ); - } - title.text( this.options.title ); - }, - - _createButtonPane: function() { - this.uiDialogButtonPane = $( "<div>" ) - .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" ); - - this.uiButtonSet = $( "<div>" ) - .addClass( "ui-dialog-buttonset" ) - .appendTo( this.uiDialogButtonPane ); - - this._createButtons(); - }, - - _createButtons: function() { - var that = this, - buttons = this.options.buttons; - - // if we already have a button pane, remove it - this.uiDialogButtonPane.remove(); - this.uiButtonSet.empty(); - - if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) { - this.uiDialog.removeClass( "ui-dialog-buttons" ); - return; - } - - $.each( buttons, function( name, props ) { - var click, buttonOptions; - props = $.isFunction( props ) ? - { click: props, text: name } : - props; - // Default to a non-submitting button - props = $.extend( { type: "button" }, props ); - // Change the context for the click callback to be the main element - click = props.click; - props.click = function() { - click.apply( that.element[ 0 ], arguments ); - }; - buttonOptions = { - icons: props.icons, - text: props.showText - }; - delete props.icons; - delete props.showText; - $( "<button></button>", props ) - .button( buttonOptions ) - .appendTo( that.uiButtonSet ); - }); - this.uiDialog.addClass( "ui-dialog-buttons" ); - this.uiDialogButtonPane.appendTo( this.uiDialog ); - }, - - _makeDraggable: function() { - var that = this, - options = this.options; - - function filteredUi( ui ) { - return { - position: ui.position, - offset: ui.offset - }; - } - - this.uiDialog.draggable({ - cancel: ".ui-dialog-content, .ui-dialog-titlebar-close", - handle: ".ui-dialog-titlebar", - containment: "document", - start: function( event, ui ) { - $( this ).addClass( "ui-dialog-dragging" ); - that._blockFrames(); - that._trigger( "dragStart", event, filteredUi( ui ) ); - }, - drag: function( event, ui ) { - that._trigger( "drag", event, filteredUi( ui ) ); - }, - stop: function( event, ui ) { - var left = ui.offset.left - that.document.scrollLeft(), - top = ui.offset.top - that.document.scrollTop(); - - options.position = { - my: "left top", - at: "left" + (left >= 0 ? "+" : "") + left + " " + - "top" + (top >= 0 ? "+" : "") + top, - of: that.window - }; - $( this ).removeClass( "ui-dialog-dragging" ); - that._unblockFrames(); - that._trigger( "dragStop", event, filteredUi( ui ) ); - } - }); - }, - - _makeResizable: function() { - var that = this, - options = this.options, - handles = options.resizable, - // .ui-resizable has position: relative defined in the stylesheet - // but dialogs have to use absolute or fixed positioning - position = this.uiDialog.css("position"), - resizeHandles = typeof handles === "string" ? - handles : - "n,e,s,w,se,sw,ne,nw"; - - function filteredUi( ui ) { - return { - originalPosition: ui.originalPosition, - originalSize: ui.originalSize, - position: ui.position, - size: ui.size - }; - } - - this.uiDialog.resizable({ - cancel: ".ui-dialog-content", - containment: "document", - alsoResize: this.element, - maxWidth: options.maxWidth, - maxHeight: options.maxHeight, - minWidth: options.minWidth, - minHeight: this._minHeight(), - handles: resizeHandles, - start: function( event, ui ) { - $( this ).addClass( "ui-dialog-resizing" ); - that._blockFrames(); - that._trigger( "resizeStart", event, filteredUi( ui ) ); - }, - resize: function( event, ui ) { - that._trigger( "resize", event, filteredUi( ui ) ); - }, - stop: function( event, ui ) { - var offset = that.uiDialog.offset(), - left = offset.left - that.document.scrollLeft(), - top = offset.top - that.document.scrollTop(); - - options.height = that.uiDialog.height(); - options.width = that.uiDialog.width(); - options.position = { - my: "left top", - at: "left" + (left >= 0 ? "+" : "") + left + " " + - "top" + (top >= 0 ? "+" : "") + top, - of: that.window - }; - $( this ).removeClass( "ui-dialog-resizing" ); - that._unblockFrames(); - that._trigger( "resizeStop", event, filteredUi( ui ) ); - } - }) - .css( "position", position ); - }, - - _trackFocus: function() { - this._on( this.widget(), { - focusin: function( event ) { - this._makeFocusTarget(); - this._focusedElement = $( event.target ); - } - }); - }, - - _makeFocusTarget: function() { - this._untrackInstance(); - this._trackingInstances().unshift( this ); - }, - - _untrackInstance: function() { - var instances = this._trackingInstances(), - exists = $.inArray( this, instances ); - if ( exists !== -1 ) { - instances.splice( exists, 1 ); - } - }, - - _trackingInstances: function() { - var instances = this.document.data( "ui-dialog-instances" ); - if ( !instances ) { - instances = []; - this.document.data( "ui-dialog-instances", instances ); - } - return instances; - }, - - _minHeight: function() { - var options = this.options; - - return options.height === "auto" ? - options.minHeight : - Math.min( options.minHeight, options.height ); - }, - - _position: function() { - // Need to show the dialog to get the actual offset in the position plugin - var isVisible = this.uiDialog.is( ":visible" ); - if ( !isVisible ) { - this.uiDialog.show(); - } - this.uiDialog.position( this.options.position ); - if ( !isVisible ) { - this.uiDialog.hide(); - } - }, - - _setOptions: function( options ) { - var that = this, - resize = false, - resizableOptions = {}; - - $.each( options, function( key, value ) { - that._setOption( key, value ); - - if ( key in that.sizeRelatedOptions ) { - resize = true; - } - if ( key in that.resizableRelatedOptions ) { - resizableOptions[ key ] = value; - } - }); - - if ( resize ) { - this._size(); - this._position(); - } - if ( this.uiDialog.is( ":data(ui-resizable)" ) ) { - this.uiDialog.resizable( "option", resizableOptions ); - } - }, - - _setOption: function( key, value ) { - var isDraggable, isResizable, - uiDialog = this.uiDialog; - - if ( key === "dialogClass" ) { - uiDialog - .removeClass( this.options.dialogClass ) - .addClass( value ); - } - - if ( key === "disabled" ) { - return; - } - - this._super( key, value ); - - if ( key === "appendTo" ) { - this.uiDialog.appendTo( this._appendTo() ); - } - - if ( key === "buttons" ) { - this._createButtons(); - } - - if ( key === "closeText" ) { - this.uiDialogTitlebarClose.button({ - // Ensure that we always pass a string - label: "" + value - }); - } - - if ( key === "draggable" ) { - isDraggable = uiDialog.is( ":data(ui-draggable)" ); - if ( isDraggable && !value ) { - uiDialog.draggable( "destroy" ); - } - - if ( !isDraggable && value ) { - this._makeDraggable(); - } - } - - if ( key === "position" ) { - this._position(); - } - - if ( key === "resizable" ) { - // currently resizable, becoming non-resizable - isResizable = uiDialog.is( ":data(ui-resizable)" ); - if ( isResizable && !value ) { - uiDialog.resizable( "destroy" ); - } - - // currently resizable, changing handles - if ( isResizable && typeof value === "string" ) { - uiDialog.resizable( "option", "handles", value ); - } - - // currently non-resizable, becoming resizable - if ( !isResizable && value !== false ) { - this._makeResizable(); - } - } - - if ( key === "title" ) { - this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) ); - } - }, - - _size: function() { - // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content - // divs will both have width and height set, so we need to reset them - var nonContentHeight, minContentHeight, maxContentHeight, - options = this.options; - - // Reset content sizing - this.element.show().css({ - width: "auto", - minHeight: 0, - maxHeight: "none", - height: 0 - }); - - if ( options.minWidth > options.width ) { - options.width = options.minWidth; - } - - // reset wrapper sizing - // determine the height of all the non-content elements - nonContentHeight = this.uiDialog.css({ - height: "auto", - width: options.width - }) - .outerHeight(); - minContentHeight = Math.max( 0, options.minHeight - nonContentHeight ); - maxContentHeight = typeof options.maxHeight === "number" ? - Math.max( 0, options.maxHeight - nonContentHeight ) : - "none"; - - if ( options.height === "auto" ) { - this.element.css({ - minHeight: minContentHeight, - maxHeight: maxContentHeight, - height: "auto" - }); - } else { - this.element.height( Math.max( 0, options.height - nonContentHeight ) ); - } - - if ( this.uiDialog.is( ":data(ui-resizable)" ) ) { - this.uiDialog.resizable( "option", "minHeight", this._minHeight() ); - } - }, - - _blockFrames: function() { - this.iframeBlocks = this.document.find( "iframe" ).map(function() { - var iframe = $( this ); - - return $( "<div>" ) - .css({ - position: "absolute", - width: iframe.outerWidth(), - height: iframe.outerHeight() - }) - .appendTo( iframe.parent() ) - .offset( iframe.offset() )[0]; - }); - }, - - _unblockFrames: function() { - if ( this.iframeBlocks ) { - this.iframeBlocks.remove(); - delete this.iframeBlocks; - } - }, - - _allowInteraction: function( event ) { - if ( $( event.target ).closest( ".ui-dialog" ).length ) { - return true; - } - - // TODO: Remove hack when datepicker implements - // the .ui-front logic (#8989) - return !!$( event.target ).closest( ".ui-datepicker" ).length; - }, - - _createOverlay: function() { - if ( !this.options.modal ) { - return; - } - - // We use a delay in case the overlay is created from an - // event that we're going to be cancelling (#2804) - var isOpening = true; - this._delay(function() { - isOpening = false; - }); - - if ( !this.document.data( "ui-dialog-overlays" ) ) { - - // Prevent use of anchors and inputs - // Using _on() for an event handler shared across many instances is - // safe because the dialogs stack and must be closed in reverse order - this._on( this.document, { - focusin: function( event ) { - if ( isOpening ) { - return; - } - - if ( !this._allowInteraction( event ) ) { - event.preventDefault(); - this._trackingInstances()[ 0 ]._focusTabbable(); - } - } - }); - } - - this.overlay = $( "<div>" ) - .addClass( "ui-widget-overlay ui-front" ) - .appendTo( this._appendTo() ); - this._on( this.overlay, { - mousedown: "_keepFocus" - }); - this.document.data( "ui-dialog-overlays", - (this.document.data( "ui-dialog-overlays" ) || 0) + 1 ); - }, - - _destroyOverlay: function() { - if ( !this.options.modal ) { - return; - } - - if ( this.overlay ) { - var overlays = this.document.data( "ui-dialog-overlays" ) - 1; - - if ( !overlays ) { - this.document - .unbind( "focusin" ) - .removeData( "ui-dialog-overlays" ); - } else { - this.document.data( "ui-dialog-overlays", overlays ); - } - - this.overlay.remove(); - this.overlay = null; - } - } -}); - - -/*! - * jQuery UI Droppable 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/droppable/ - */ - - -$.widget( "ui.droppable", { - version: "1.11.4", - widgetEventPrefix: "drop", - options: { - accept: "*", - activeClass: false, - addClasses: true, - greedy: false, - hoverClass: false, - scope: "default", - tolerance: "intersect", - - // callbacks - activate: null, - deactivate: null, - drop: null, - out: null, - over: null - }, - _create: function() { - - var proportions, - o = this.options, - accept = o.accept; - - this.isover = false; - this.isout = true; - - this.accept = $.isFunction( accept ) ? accept : function( d ) { - return d.is( accept ); - }; - - this.proportions = function( /* valueToWrite */ ) { - if ( arguments.length ) { - // Store the droppable's proportions - proportions = arguments[ 0 ]; - } else { - // Retrieve or derive the droppable's proportions - return proportions ? - proportions : - proportions = { - width: this.element[ 0 ].offsetWidth, - height: this.element[ 0 ].offsetHeight - }; - } - }; - - this._addToManager( o.scope ); - - o.addClasses && this.element.addClass( "ui-droppable" ); - - }, - - _addToManager: function( scope ) { - // Add the reference and positions to the manager - $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || []; - $.ui.ddmanager.droppables[ scope ].push( this ); - }, - - _splice: function( drop ) { - var i = 0; - for ( ; i < drop.length; i++ ) { - if ( drop[ i ] === this ) { - drop.splice( i, 1 ); - } - } - }, - - _destroy: function() { - var drop = $.ui.ddmanager.droppables[ this.options.scope ]; - - this._splice( drop ); - - this.element.removeClass( "ui-droppable ui-droppable-disabled" ); - }, - - _setOption: function( key, value ) { - - if ( key === "accept" ) { - this.accept = $.isFunction( value ) ? value : function( d ) { - return d.is( value ); - }; - } else if ( key === "scope" ) { - var drop = $.ui.ddmanager.droppables[ this.options.scope ]; - - this._splice( drop ); - this._addToManager( value ); - } - - this._super( key, value ); - }, - - _activate: function( event ) { - var draggable = $.ui.ddmanager.current; - if ( this.options.activeClass ) { - this.element.addClass( this.options.activeClass ); - } - if ( draggable ){ - this._trigger( "activate", event, this.ui( draggable ) ); - } - }, - - _deactivate: function( event ) { - var draggable = $.ui.ddmanager.current; - if ( this.options.activeClass ) { - this.element.removeClass( this.options.activeClass ); - } - if ( draggable ){ - this._trigger( "deactivate", event, this.ui( draggable ) ); - } - }, - - _over: function( event ) { - - var draggable = $.ui.ddmanager.current; - - // Bail if draggable and droppable are same element - if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) { - return; - } - - if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) { - if ( this.options.hoverClass ) { - this.element.addClass( this.options.hoverClass ); - } - this._trigger( "over", event, this.ui( draggable ) ); - } - - }, - - _out: function( event ) { - - var draggable = $.ui.ddmanager.current; - - // Bail if draggable and droppable are same element - if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) { - return; - } - - if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) { - if ( this.options.hoverClass ) { - this.element.removeClass( this.options.hoverClass ); - } - this._trigger( "out", event, this.ui( draggable ) ); - } - - }, - - _drop: function( event, custom ) { - - var draggable = custom || $.ui.ddmanager.current, - childrenIntersection = false; - - // Bail if draggable and droppable are same element - if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) { - return false; - } - - this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each(function() { - var inst = $( this ).droppable( "instance" ); - if ( - inst.options.greedy && - !inst.options.disabled && - inst.options.scope === draggable.options.scope && - inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) && - $.ui.intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance, event ) - ) { childrenIntersection = true; return false; } - }); - if ( childrenIntersection ) { - return false; - } - - if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) { - if ( this.options.activeClass ) { - this.element.removeClass( this.options.activeClass ); - } - if ( this.options.hoverClass ) { - this.element.removeClass( this.options.hoverClass ); - } - this._trigger( "drop", event, this.ui( draggable ) ); - return this.element; - } - - return false; - - }, - - ui: function( c ) { - return { - draggable: ( c.currentItem || c.element ), - helper: c.helper, - position: c.position, - offset: c.positionAbs - }; - } - -}); - -$.ui.intersect = (function() { - function isOverAxis( x, reference, size ) { - return ( x >= reference ) && ( x < ( reference + size ) ); - } - - return function( draggable, droppable, toleranceMode, event ) { - - if ( !droppable.offset ) { - return false; - } - - var x1 = ( draggable.positionAbs || draggable.position.absolute ).left + draggable.margins.left, - y1 = ( draggable.positionAbs || draggable.position.absolute ).top + draggable.margins.top, - x2 = x1 + draggable.helperProportions.width, - y2 = y1 + draggable.helperProportions.height, - l = droppable.offset.left, - t = droppable.offset.top, - r = l + droppable.proportions().width, - b = t + droppable.proportions().height; - - switch ( toleranceMode ) { - case "fit": - return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b ); - case "intersect": - return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half - x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half - t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half - y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half - case "pointer": - return isOverAxis( event.pageY, t, droppable.proportions().height ) && isOverAxis( event.pageX, l, droppable.proportions().width ); - case "touch": - return ( - ( y1 >= t && y1 <= b ) || // Top edge touching - ( y2 >= t && y2 <= b ) || // Bottom edge touching - ( y1 < t && y2 > b ) // Surrounded vertically - ) && ( - ( x1 >= l && x1 <= r ) || // Left edge touching - ( x2 >= l && x2 <= r ) || // Right edge touching - ( x1 < l && x2 > r ) // Surrounded horizontally - ); - default: - return false; - } - }; -})(); - -/* - This manager tracks offsets of draggables and droppables -*/ -$.ui.ddmanager = { - current: null, - droppables: { "default": [] }, - prepareOffsets: function( t, event ) { - - var i, j, - m = $.ui.ddmanager.droppables[ t.options.scope ] || [], - type = event ? event.type : null, // workaround for #2317 - list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack(); - - droppablesLoop: for ( i = 0; i < m.length; i++ ) { - - // No disabled and non-accepted - if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], ( t.currentItem || t.element ) ) ) ) { - continue; - } - - // Filter out elements in the current dragged item - for ( j = 0; j < list.length; j++ ) { - if ( list[ j ] === m[ i ].element[ 0 ] ) { - m[ i ].proportions().height = 0; - continue droppablesLoop; - } - } - - m[ i ].visible = m[ i ].element.css( "display" ) !== "none"; - if ( !m[ i ].visible ) { - continue; - } - - // Activate the droppable if used directly from draggables - if ( type === "mousedown" ) { - m[ i ]._activate.call( m[ i ], event ); - } - - m[ i ].offset = m[ i ].element.offset(); - m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight }); - - } - - }, - drop: function( draggable, event ) { - - var dropped = false; - // Create a copy of the droppables in case the list changes during the drop (#9116) - $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() { - - if ( !this.options ) { - return; - } - if ( !this.options.disabled && this.visible && $.ui.intersect( draggable, this, this.options.tolerance, event ) ) { - dropped = this._drop.call( this, event ) || dropped; - } - - if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) { - this.isout = true; - this.isover = false; - this._deactivate.call( this, event ); - } - - }); - return dropped; - - }, - dragStart: function( draggable, event ) { - // Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003) - draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() { - if ( !draggable.options.refreshPositions ) { - $.ui.ddmanager.prepareOffsets( draggable, event ); - } - }); - }, - drag: function( draggable, event ) { - - // If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse. - if ( draggable.options.refreshPositions ) { - $.ui.ddmanager.prepareOffsets( draggable, event ); - } - - // Run through all droppables and check their positions based on specific tolerance options - $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() { - - if ( this.options.disabled || this.greedyChild || !this.visible ) { - return; - } - - var parentInstance, scope, parent, - intersects = $.ui.intersect( draggable, this, this.options.tolerance, event ), - c = !intersects && this.isover ? "isout" : ( intersects && !this.isover ? "isover" : null ); - if ( !c ) { - return; - } - - if ( this.options.greedy ) { - // find droppable parents with same scope - scope = this.options.scope; - parent = this.element.parents( ":data(ui-droppable)" ).filter(function() { - return $( this ).droppable( "instance" ).options.scope === scope; - }); - - if ( parent.length ) { - parentInstance = $( parent[ 0 ] ).droppable( "instance" ); - parentInstance.greedyChild = ( c === "isover" ); - } - } - - // we just moved into a greedy child - if ( parentInstance && c === "isover" ) { - parentInstance.isover = false; - parentInstance.isout = true; - parentInstance._out.call( parentInstance, event ); - } - - this[ c ] = true; - this[c === "isout" ? "isover" : "isout"] = false; - this[c === "isover" ? "_over" : "_out"].call( this, event ); - - // we just moved out of a greedy child - if ( parentInstance && c === "isout" ) { - parentInstance.isout = false; - parentInstance.isover = true; - parentInstance._over.call( parentInstance, event ); - } - }); - - }, - dragStop: function( draggable, event ) { - draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" ); - // Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003) - if ( !draggable.options.refreshPositions ) { - $.ui.ddmanager.prepareOffsets( draggable, event ); - } - } -}; - -var droppable = $.ui.droppable; - - -/*! - * jQuery UI Effects 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/category/effects-core/ - */ - - -var dataSpace = "ui-effects-", - - // Create a local jQuery because jQuery Color relies on it and the - // global may not exist with AMD and a custom build (#10199) - jQuery = $; - -$.effects = { - effect: {} -}; - -/*! - * jQuery Color Animations v2.1.2 - * https://github.com/jquery/jquery-color - * - * Copyright 2014 jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * Date: Wed Jan 16 08:47:09 2013 -0600 - */ -(function( jQuery, undefined ) { - - var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor", - - // plusequals test for += 100 -= 100 - rplusequals = /^([\-+])=\s*(\d+\.?\d*)/, - // a set of RE's that can match strings and generate color tuples. - stringParsers = [ { - re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, - parse: function( execResult ) { - return [ - execResult[ 1 ], - execResult[ 2 ], - execResult[ 3 ], - execResult[ 4 ] - ]; - } - }, { - re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, - parse: function( execResult ) { - return [ - execResult[ 1 ] * 2.55, - execResult[ 2 ] * 2.55, - execResult[ 3 ] * 2.55, - execResult[ 4 ] - ]; - } - }, { - // this regex ignores A-F because it's compared against an already lowercased string - re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/, - parse: function( execResult ) { - return [ - parseInt( execResult[ 1 ], 16 ), - parseInt( execResult[ 2 ], 16 ), - parseInt( execResult[ 3 ], 16 ) - ]; - } - }, { - // this regex ignores A-F because it's compared against an already lowercased string - re: /#([a-f0-9])([a-f0-9])([a-f0-9])/, - parse: function( execResult ) { - return [ - parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ), - parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ), - parseInt( execResult[ 3 ] + execResult[ 3 ], 16 ) - ]; - } - }, { - re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, - space: "hsla", - parse: function( execResult ) { - return [ - execResult[ 1 ], - execResult[ 2 ] / 100, - execResult[ 3 ] / 100, - execResult[ 4 ] - ]; - } - } ], - - // jQuery.Color( ) - color = jQuery.Color = function( color, green, blue, alpha ) { - return new jQuery.Color.fn.parse( color, green, blue, alpha ); - }, - spaces = { - rgba: { - props: { - red: { - idx: 0, - type: "byte" - }, - green: { - idx: 1, - type: "byte" - }, - blue: { - idx: 2, - type: "byte" - } - } - }, - - hsla: { - props: { - hue: { - idx: 0, - type: "degrees" - }, - saturation: { - idx: 1, - type: "percent" - }, - lightness: { - idx: 2, - type: "percent" - } - } - } - }, - propTypes = { - "byte": { - floor: true, - max: 255 - }, - "percent": { - max: 1 - }, - "degrees": { - mod: 360, - floor: true - } - }, - support = color.support = {}, - - // element for support tests - supportElem = jQuery( "<p>" )[ 0 ], - - // colors = jQuery.Color.names - colors, - - // local aliases of functions called often - each = jQuery.each; - -// determine rgba support immediately -supportElem.style.cssText = "background-color:rgba(1,1,1,.5)"; -support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1; - -// define cache name and alpha properties -// for rgba and hsla spaces -each( spaces, function( spaceName, space ) { - space.cache = "_" + spaceName; - space.props.alpha = { - idx: 3, - type: "percent", - def: 1 - }; -}); - -function clamp( value, prop, allowEmpty ) { - var type = propTypes[ prop.type ] || {}; - - if ( value == null ) { - return (allowEmpty || !prop.def) ? null : prop.def; - } - - // ~~ is an short way of doing floor for positive numbers - value = type.floor ? ~~value : parseFloat( value ); - - // IE will pass in empty strings as value for alpha, - // which will hit this case - if ( isNaN( value ) ) { - return prop.def; - } - - if ( type.mod ) { - // we add mod before modding to make sure that negatives values - // get converted properly: -10 -> 350 - return (value + type.mod) % type.mod; - } - - // for now all property types without mod have min and max - return 0 > value ? 0 : type.max < value ? type.max : value; -} - -function stringParse( string ) { - var inst = color(), - rgba = inst._rgba = []; - - string = string.toLowerCase(); - - each( stringParsers, function( i, parser ) { - var parsed, - match = parser.re.exec( string ), - values = match && parser.parse( match ), - spaceName = parser.space || "rgba"; - - if ( values ) { - parsed = inst[ spaceName ]( values ); - - // if this was an rgba parse the assignment might happen twice - // oh well.... - inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ]; - rgba = inst._rgba = parsed._rgba; - - // exit each( stringParsers ) here because we matched - return false; - } - }); - - // Found a stringParser that handled it - if ( rgba.length ) { - - // if this came from a parsed string, force "transparent" when alpha is 0 - // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0) - if ( rgba.join() === "0,0,0,0" ) { - jQuery.extend( rgba, colors.transparent ); - } - return inst; - } - - // named colors - return colors[ string ]; -} - -color.fn = jQuery.extend( color.prototype, { - parse: function( red, green, blue, alpha ) { - if ( red === undefined ) { - this._rgba = [ null, null, null, null ]; - return this; - } - if ( red.jquery || red.nodeType ) { - red = jQuery( red ).css( green ); - green = undefined; - } - - var inst = this, - type = jQuery.type( red ), - rgba = this._rgba = []; - - // more than 1 argument specified - assume ( red, green, blue, alpha ) - if ( green !== undefined ) { - red = [ red, green, blue, alpha ]; - type = "array"; - } - - if ( type === "string" ) { - return this.parse( stringParse( red ) || colors._default ); - } - - if ( type === "array" ) { - each( spaces.rgba.props, function( key, prop ) { - rgba[ prop.idx ] = clamp( red[ prop.idx ], prop ); - }); - return this; - } - - if ( type === "object" ) { - if ( red instanceof color ) { - each( spaces, function( spaceName, space ) { - if ( red[ space.cache ] ) { - inst[ space.cache ] = red[ space.cache ].slice(); - } - }); - } else { - each( spaces, function( spaceName, space ) { - var cache = space.cache; - each( space.props, function( key, prop ) { - - // if the cache doesn't exist, and we know how to convert - if ( !inst[ cache ] && space.to ) { - - // if the value was null, we don't need to copy it - // if the key was alpha, we don't need to copy it either - if ( key === "alpha" || red[ key ] == null ) { - return; - } - inst[ cache ] = space.to( inst._rgba ); - } - - // this is the only case where we allow nulls for ALL properties. - // call clamp with alwaysAllowEmpty - inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true ); - }); - - // everything defined but alpha? - if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) { - // use the default of 1 - inst[ cache ][ 3 ] = 1; - if ( space.from ) { - inst._rgba = space.from( inst[ cache ] ); - } - } - }); - } - return this; - } - }, - is: function( compare ) { - var is = color( compare ), - same = true, - inst = this; - - each( spaces, function( _, space ) { - var localCache, - isCache = is[ space.cache ]; - if (isCache) { - localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || []; - each( space.props, function( _, prop ) { - if ( isCache[ prop.idx ] != null ) { - same = ( isCache[ prop.idx ] === localCache[ prop.idx ] ); - return same; - } - }); - } - return same; - }); - return same; - }, - _space: function() { - var used = [], - inst = this; - each( spaces, function( spaceName, space ) { - if ( inst[ space.cache ] ) { - used.push( spaceName ); - } - }); - return used.pop(); - }, - transition: function( other, distance ) { - var end = color( other ), - spaceName = end._space(), - space = spaces[ spaceName ], - startColor = this.alpha() === 0 ? color( "transparent" ) : this, - start = startColor[ space.cache ] || space.to( startColor._rgba ), - result = start.slice(); - - end = end[ space.cache ]; - each( space.props, function( key, prop ) { - var index = prop.idx, - startValue = start[ index ], - endValue = end[ index ], - type = propTypes[ prop.type ] || {}; - - // if null, don't override start value - if ( endValue === null ) { - return; - } - // if null - use end - if ( startValue === null ) { - result[ index ] = endValue; - } else { - if ( type.mod ) { - if ( endValue - startValue > type.mod / 2 ) { - startValue += type.mod; - } else if ( startValue - endValue > type.mod / 2 ) { - startValue -= type.mod; - } - } - result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop ); - } - }); - return this[ spaceName ]( result ); - }, - blend: function( opaque ) { - // if we are already opaque - return ourself - if ( this._rgba[ 3 ] === 1 ) { - return this; - } - - var rgb = this._rgba.slice(), - a = rgb.pop(), - blend = color( opaque )._rgba; - - return color( jQuery.map( rgb, function( v, i ) { - return ( 1 - a ) * blend[ i ] + a * v; - })); - }, - toRgbaString: function() { - var prefix = "rgba(", - rgba = jQuery.map( this._rgba, function( v, i ) { - return v == null ? ( i > 2 ? 1 : 0 ) : v; - }); - - if ( rgba[ 3 ] === 1 ) { - rgba.pop(); - prefix = "rgb("; - } - - return prefix + rgba.join() + ")"; - }, - toHslaString: function() { - var prefix = "hsla(", - hsla = jQuery.map( this.hsla(), function( v, i ) { - if ( v == null ) { - v = i > 2 ? 1 : 0; - } - - // catch 1 and 2 - if ( i && i < 3 ) { - v = Math.round( v * 100 ) + "%"; - } - return v; - }); - - if ( hsla[ 3 ] === 1 ) { - hsla.pop(); - prefix = "hsl("; - } - return prefix + hsla.join() + ")"; - }, - toHexString: function( includeAlpha ) { - var rgba = this._rgba.slice(), - alpha = rgba.pop(); - - if ( includeAlpha ) { - rgba.push( ~~( alpha * 255 ) ); - } - - return "#" + jQuery.map( rgba, function( v ) { - - // default to 0 when nulls exist - v = ( v || 0 ).toString( 16 ); - return v.length === 1 ? "0" + v : v; - }).join(""); - }, - toString: function() { - return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString(); - } -}); -color.fn.parse.prototype = color.fn; - -// hsla conversions adapted from: -// https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021 - -function hue2rgb( p, q, h ) { - h = ( h + 1 ) % 1; - if ( h * 6 < 1 ) { - return p + ( q - p ) * h * 6; - } - if ( h * 2 < 1) { - return q; - } - if ( h * 3 < 2 ) { - return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6; - } - return p; -} - -spaces.hsla.to = function( rgba ) { - if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) { - return [ null, null, null, rgba[ 3 ] ]; - } - var r = rgba[ 0 ] / 255, - g = rgba[ 1 ] / 255, - b = rgba[ 2 ] / 255, - a = rgba[ 3 ], - max = Math.max( r, g, b ), - min = Math.min( r, g, b ), - diff = max - min, - add = max + min, - l = add * 0.5, - h, s; - - if ( min === max ) { - h = 0; - } else if ( r === max ) { - h = ( 60 * ( g - b ) / diff ) + 360; - } else if ( g === max ) { - h = ( 60 * ( b - r ) / diff ) + 120; - } else { - h = ( 60 * ( r - g ) / diff ) + 240; - } - - // chroma (diff) == 0 means greyscale which, by definition, saturation = 0% - // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add) - if ( diff === 0 ) { - s = 0; - } else if ( l <= 0.5 ) { - s = diff / add; - } else { - s = diff / ( 2 - add ); - } - return [ Math.round(h) % 360, s, l, a == null ? 1 : a ]; -}; - -spaces.hsla.from = function( hsla ) { - if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) { - return [ null, null, null, hsla[ 3 ] ]; - } - var h = hsla[ 0 ] / 360, - s = hsla[ 1 ], - l = hsla[ 2 ], - a = hsla[ 3 ], - q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s, - p = 2 * l - q; - - return [ - Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ), - Math.round( hue2rgb( p, q, h ) * 255 ), - Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ), - a - ]; -}; - -each( spaces, function( spaceName, space ) { - var props = space.props, - cache = space.cache, - to = space.to, - from = space.from; - - // makes rgba() and hsla() - color.fn[ spaceName ] = function( value ) { - - // generate a cache for this space if it doesn't exist - if ( to && !this[ cache ] ) { - this[ cache ] = to( this._rgba ); - } - if ( value === undefined ) { - return this[ cache ].slice(); - } - - var ret, - type = jQuery.type( value ), - arr = ( type === "array" || type === "object" ) ? value : arguments, - local = this[ cache ].slice(); - - each( props, function( key, prop ) { - var val = arr[ type === "object" ? key : prop.idx ]; - if ( val == null ) { - val = local[ prop.idx ]; - } - local[ prop.idx ] = clamp( val, prop ); - }); - - if ( from ) { - ret = color( from( local ) ); - ret[ cache ] = local; - return ret; - } else { - return color( local ); - } - }; - - // makes red() green() blue() alpha() hue() saturation() lightness() - each( props, function( key, prop ) { - // alpha is included in more than one space - if ( color.fn[ key ] ) { - return; - } - color.fn[ key ] = function( value ) { - var vtype = jQuery.type( value ), - fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ), - local = this[ fn ](), - cur = local[ prop.idx ], - match; - - if ( vtype === "undefined" ) { - return cur; - } - - if ( vtype === "function" ) { - value = value.call( this, cur ); - vtype = jQuery.type( value ); - } - if ( value == null && prop.empty ) { - return this; - } - if ( vtype === "string" ) { - match = rplusequals.exec( value ); - if ( match ) { - value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 ); - } - } - local[ prop.idx ] = value; - return this[ fn ]( local ); - }; - }); -}); - -// add cssHook and .fx.step function for each named hook. -// accept a space separated string of properties -color.hook = function( hook ) { - var hooks = hook.split( " " ); - each( hooks, function( i, hook ) { - jQuery.cssHooks[ hook ] = { - set: function( elem, value ) { - var parsed, curElem, - backgroundColor = ""; - - if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) { - value = color( parsed || value ); - if ( !support.rgba && value._rgba[ 3 ] !== 1 ) { - curElem = hook === "backgroundColor" ? elem.parentNode : elem; - while ( - (backgroundColor === "" || backgroundColor === "transparent") && - curElem && curElem.style - ) { - try { - backgroundColor = jQuery.css( curElem, "backgroundColor" ); - curElem = curElem.parentNode; - } catch ( e ) { - } - } - - value = value.blend( backgroundColor && backgroundColor !== "transparent" ? - backgroundColor : - "_default" ); - } - - value = value.toRgbaString(); - } - try { - elem.style[ hook ] = value; - } catch ( e ) { - // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit' - } - } - }; - jQuery.fx.step[ hook ] = function( fx ) { - if ( !fx.colorInit ) { - fx.start = color( fx.elem, hook ); - fx.end = color( fx.end ); - fx.colorInit = true; - } - jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) ); - }; - }); - -}; - -color.hook( stepHooks ); - -jQuery.cssHooks.borderColor = { - expand: function( value ) { - var expanded = {}; - - each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) { - expanded[ "border" + part + "Color" ] = value; - }); - return expanded; - } -}; - -// Basic color names only. -// Usage of any of the other color names requires adding yourself or including -// jquery.color.svg-names.js. -colors = jQuery.Color.names = { - // 4.1. Basic color keywords - aqua: "#00ffff", - black: "#000000", - blue: "#0000ff", - fuchsia: "#ff00ff", - gray: "#808080", - green: "#008000", - lime: "#00ff00", - maroon: "#800000", - navy: "#000080", - olive: "#808000", - purple: "#800080", - red: "#ff0000", - silver: "#c0c0c0", - teal: "#008080", - white: "#ffffff", - yellow: "#ffff00", - - // 4.2.3. "transparent" color keyword - transparent: [ null, null, null, 0 ], - - _default: "#ffffff" -}; - -})( jQuery ); - -/******************************************************************************/ -/****************************** CLASS ANIMATIONS ******************************/ -/******************************************************************************/ -(function() { - -var classAnimationActions = [ "add", "remove", "toggle" ], - shorthandStyles = { - border: 1, - borderBottom: 1, - borderColor: 1, - borderLeft: 1, - borderRight: 1, - borderTop: 1, - borderWidth: 1, - margin: 1, - padding: 1 - }; - -$.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) { - $.fx.step[ prop ] = function( fx ) { - if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) { - jQuery.style( fx.elem, prop, fx.end ); - fx.setAttr = true; - } - }; -}); - -function getElementStyles( elem ) { - var key, len, - style = elem.ownerDocument.defaultView ? - elem.ownerDocument.defaultView.getComputedStyle( elem, null ) : - elem.currentStyle, - styles = {}; - - if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) { - len = style.length; - while ( len-- ) { - key = style[ len ]; - if ( typeof style[ key ] === "string" ) { - styles[ $.camelCase( key ) ] = style[ key ]; - } - } - // support: Opera, IE <9 - } else { - for ( key in style ) { - if ( typeof style[ key ] === "string" ) { - styles[ key ] = style[ key ]; - } - } - } - - return styles; -} - -function styleDifference( oldStyle, newStyle ) { - var diff = {}, - name, value; - - for ( name in newStyle ) { - value = newStyle[ name ]; - if ( oldStyle[ name ] !== value ) { - if ( !shorthandStyles[ name ] ) { - if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) { - diff[ name ] = value; - } - } - } - } - - return diff; -} - -// support: jQuery <1.8 -if ( !$.fn.addBack ) { - $.fn.addBack = function( selector ) { - return this.add( selector == null ? - this.prevObject : this.prevObject.filter( selector ) - ); - }; -} - -$.effects.animateClass = function( value, duration, easing, callback ) { - var o = $.speed( duration, easing, callback ); - - return this.queue( function() { - var animated = $( this ), - baseClass = animated.attr( "class" ) || "", - applyClassChange, - allAnimations = o.children ? animated.find( "*" ).addBack() : animated; - - // map the animated objects to store the original styles. - allAnimations = allAnimations.map(function() { - var el = $( this ); - return { - el: el, - start: getElementStyles( this ) - }; - }); - - // apply class change - applyClassChange = function() { - $.each( classAnimationActions, function(i, action) { - if ( value[ action ] ) { - animated[ action + "Class" ]( value[ action ] ); - } - }); - }; - applyClassChange(); - - // map all animated objects again - calculate new styles and diff - allAnimations = allAnimations.map(function() { - this.end = getElementStyles( this.el[ 0 ] ); - this.diff = styleDifference( this.start, this.end ); - return this; - }); - - // apply original class - animated.attr( "class", baseClass ); - - // map all animated objects again - this time collecting a promise - allAnimations = allAnimations.map(function() { - var styleInfo = this, - dfd = $.Deferred(), - opts = $.extend({}, o, { - queue: false, - complete: function() { - dfd.resolve( styleInfo ); - } - }); - - this.el.animate( this.diff, opts ); - return dfd.promise(); - }); - - // once all animations have completed: - $.when.apply( $, allAnimations.get() ).done(function() { - - // set the final class - applyClassChange(); - - // for each animated element, - // clear all css properties that were animated - $.each( arguments, function() { - var el = this.el; - $.each( this.diff, function(key) { - el.css( key, "" ); - }); - }); - - // this is guarnteed to be there if you use jQuery.speed() - // it also handles dequeuing the next anim... - o.complete.call( animated[ 0 ] ); - }); - }); -}; - -$.fn.extend({ - addClass: (function( orig ) { - return function( classNames, speed, easing, callback ) { - return speed ? - $.effects.animateClass.call( this, - { add: classNames }, speed, easing, callback ) : - orig.apply( this, arguments ); - }; - })( $.fn.addClass ), - - removeClass: (function( orig ) { - return function( classNames, speed, easing, callback ) { - return arguments.length > 1 ? - $.effects.animateClass.call( this, - { remove: classNames }, speed, easing, callback ) : - orig.apply( this, arguments ); - }; - })( $.fn.removeClass ), - - toggleClass: (function( orig ) { - return function( classNames, force, speed, easing, callback ) { - if ( typeof force === "boolean" || force === undefined ) { - if ( !speed ) { - // without speed parameter - return orig.apply( this, arguments ); - } else { - return $.effects.animateClass.call( this, - (force ? { add: classNames } : { remove: classNames }), - speed, easing, callback ); - } - } else { - // without force parameter - return $.effects.animateClass.call( this, - { toggle: classNames }, force, speed, easing ); - } - }; - })( $.fn.toggleClass ), - - switchClass: function( remove, add, speed, easing, callback) { - return $.effects.animateClass.call( this, { - add: add, - remove: remove - }, speed, easing, callback ); - } -}); - -})(); - -/******************************************************************************/ -/*********************************** EFFECTS **********************************/ -/******************************************************************************/ - -(function() { - -$.extend( $.effects, { - version: "1.11.4", - - // Saves a set of properties in a data storage - save: function( element, set ) { - for ( var i = 0; i < set.length; i++ ) { - if ( set[ i ] !== null ) { - element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] ); - } - } - }, - - // Restores a set of previously saved properties from a data storage - restore: function( element, set ) { - var val, i; - for ( i = 0; i < set.length; i++ ) { - if ( set[ i ] !== null ) { - val = element.data( dataSpace + set[ i ] ); - // support: jQuery 1.6.2 - // http://bugs.jquery.com/ticket/9917 - // jQuery 1.6.2 incorrectly returns undefined for any falsy value. - // We can't differentiate between "" and 0 here, so we just assume - // empty string since it's likely to be a more common value... - if ( val === undefined ) { - val = ""; - } - element.css( set[ i ], val ); - } - } - }, - - setMode: function( el, mode ) { - if (mode === "toggle") { - mode = el.is( ":hidden" ) ? "show" : "hide"; - } - return mode; - }, - - // Translates a [top,left] array into a baseline value - // this should be a little more flexible in the future to handle a string & hash - getBaseline: function( origin, original ) { - var y, x; - switch ( origin[ 0 ] ) { - case "top": y = 0; break; - case "middle": y = 0.5; break; - case "bottom": y = 1; break; - default: y = origin[ 0 ] / original.height; - } - switch ( origin[ 1 ] ) { - case "left": x = 0; break; - case "center": x = 0.5; break; - case "right": x = 1; break; - default: x = origin[ 1 ] / original.width; - } - return { - x: x, - y: y - }; - }, - - // Wraps the element around a wrapper that copies position properties - createWrapper: function( element ) { - - // if the element is already wrapped, return it - if ( element.parent().is( ".ui-effects-wrapper" )) { - return element.parent(); - } - - // wrap the element - var props = { - width: element.outerWidth(true), - height: element.outerHeight(true), - "float": element.css( "float" ) - }, - wrapper = $( "<div></div>" ) - .addClass( "ui-effects-wrapper" ) - .css({ - fontSize: "100%", - background: "transparent", - border: "none", - margin: 0, - padding: 0 - }), - // Store the size in case width/height are defined in % - Fixes #5245 - size = { - width: element.width(), - height: element.height() - }, - active = document.activeElement; - - // support: Firefox - // Firefox incorrectly exposes anonymous content - // https://bugzilla.mozilla.org/show_bug.cgi?id=561664 - try { - active.id; - } catch ( e ) { - active = document.body; - } - - element.wrap( wrapper ); - - // Fixes #7595 - Elements lose focus when wrapped. - if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { - $( active ).focus(); - } - - wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element - - // transfer positioning properties to the wrapper - if ( element.css( "position" ) === "static" ) { - wrapper.css({ position: "relative" }); - element.css({ position: "relative" }); - } else { - $.extend( props, { - position: element.css( "position" ), - zIndex: element.css( "z-index" ) - }); - $.each([ "top", "left", "bottom", "right" ], function(i, pos) { - props[ pos ] = element.css( pos ); - if ( isNaN( parseInt( props[ pos ], 10 ) ) ) { - props[ pos ] = "auto"; - } - }); - element.css({ - position: "relative", - top: 0, - left: 0, - right: "auto", - bottom: "auto" - }); - } - element.css(size); - - return wrapper.css( props ).show(); - }, - - removeWrapper: function( element ) { - var active = document.activeElement; - - if ( element.parent().is( ".ui-effects-wrapper" ) ) { - element.parent().replaceWith( element ); - - // Fixes #7595 - Elements lose focus when wrapped. - if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { - $( active ).focus(); - } - } - - return element; - }, - - setTransition: function( element, list, factor, value ) { - value = value || {}; - $.each( list, function( i, x ) { - var unit = element.cssUnit( x ); - if ( unit[ 0 ] > 0 ) { - value[ x ] = unit[ 0 ] * factor + unit[ 1 ]; - } - }); - return value; - } -}); - -// return an effect options object for the given parameters: -function _normalizeArguments( effect, options, speed, callback ) { - - // allow passing all options as the first parameter - if ( $.isPlainObject( effect ) ) { - options = effect; - effect = effect.effect; - } - - // convert to an object - effect = { effect: effect }; - - // catch (effect, null, ...) - if ( options == null ) { - options = {}; - } - - // catch (effect, callback) - if ( $.isFunction( options ) ) { - callback = options; - speed = null; - options = {}; - } - - // catch (effect, speed, ?) - if ( typeof options === "number" || $.fx.speeds[ options ] ) { - callback = speed; - speed = options; - options = {}; - } - - // catch (effect, options, callback) - if ( $.isFunction( speed ) ) { - callback = speed; - speed = null; - } - - // add options to effect - if ( options ) { - $.extend( effect, options ); - } - - speed = speed || options.duration; - effect.duration = $.fx.off ? 0 : - typeof speed === "number" ? speed : - speed in $.fx.speeds ? $.fx.speeds[ speed ] : - $.fx.speeds._default; - - effect.complete = callback || options.complete; - - return effect; -} - -function standardAnimationOption( option ) { - // Valid standard speeds (nothing, number, named speed) - if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) { - return true; - } - - // Invalid strings - treat as "normal" speed - if ( typeof option === "string" && !$.effects.effect[ option ] ) { - return true; - } - - // Complete callback - if ( $.isFunction( option ) ) { - return true; - } - - // Options hash (but not naming an effect) - if ( typeof option === "object" && !option.effect ) { - return true; - } - - // Didn't match any standard API - return false; -} - -$.fn.extend({ - effect: function( /* effect, options, speed, callback */ ) { - var args = _normalizeArguments.apply( this, arguments ), - mode = args.mode, - queue = args.queue, - effectMethod = $.effects.effect[ args.effect ]; - - if ( $.fx.off || !effectMethod ) { - // delegate to the original method (e.g., .show()) if possible - if ( mode ) { - return this[ mode ]( args.duration, args.complete ); - } else { - return this.each( function() { - if ( args.complete ) { - args.complete.call( this ); - } - }); - } - } - - function run( next ) { - var elem = $( this ), - complete = args.complete, - mode = args.mode; - - function done() { - if ( $.isFunction( complete ) ) { - complete.call( elem[0] ); - } - if ( $.isFunction( next ) ) { - next(); - } - } - - // If the element already has the correct final state, delegate to - // the core methods so the internal tracking of "olddisplay" works. - if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) { - elem[ mode ](); - done(); - } else { - effectMethod.call( elem[0], args, done ); - } - } - - return queue === false ? this.each( run ) : this.queue( queue || "fx", run ); - }, - - show: (function( orig ) { - return function( option ) { - if ( standardAnimationOption( option ) ) { - return orig.apply( this, arguments ); - } else { - var args = _normalizeArguments.apply( this, arguments ); - args.mode = "show"; - return this.effect.call( this, args ); - } - }; - })( $.fn.show ), - - hide: (function( orig ) { - return function( option ) { - if ( standardAnimationOption( option ) ) { - return orig.apply( this, arguments ); - } else { - var args = _normalizeArguments.apply( this, arguments ); - args.mode = "hide"; - return this.effect.call( this, args ); - } - }; - })( $.fn.hide ), - - toggle: (function( orig ) { - return function( option ) { - if ( standardAnimationOption( option ) || typeof option === "boolean" ) { - return orig.apply( this, arguments ); - } else { - var args = _normalizeArguments.apply( this, arguments ); - args.mode = "toggle"; - return this.effect.call( this, args ); - } - }; - })( $.fn.toggle ), - - // helper functions - cssUnit: function(key) { - var style = this.css( key ), - val = []; - - $.each( [ "em", "px", "%", "pt" ], function( i, unit ) { - if ( style.indexOf( unit ) > 0 ) { - val = [ parseFloat( style ), unit ]; - } - }); - return val; - } -}); - -})(); - -/******************************************************************************/ -/*********************************** EASING ***********************************/ -/******************************************************************************/ - -(function() { - -// based on easing equations from Robert Penner (http://www.robertpenner.com/easing) - -var baseEasings = {}; - -$.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) { - baseEasings[ name ] = function( p ) { - return Math.pow( p, i + 2 ); - }; -}); - -$.extend( baseEasings, { - Sine: function( p ) { - return 1 - Math.cos( p * Math.PI / 2 ); - }, - Circ: function( p ) { - return 1 - Math.sqrt( 1 - p * p ); - }, - Elastic: function( p ) { - return p === 0 || p === 1 ? p : - -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 ); - }, - Back: function( p ) { - return p * p * ( 3 * p - 2 ); - }, - Bounce: function( p ) { - var pow2, - bounce = 4; - - while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {} - return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 ); - } -}); - -$.each( baseEasings, function( name, easeIn ) { - $.easing[ "easeIn" + name ] = easeIn; - $.easing[ "easeOut" + name ] = function( p ) { - return 1 - easeIn( 1 - p ); - }; - $.easing[ "easeInOut" + name ] = function( p ) { - return p < 0.5 ? - easeIn( p * 2 ) / 2 : - 1 - easeIn( p * -2 + 2 ) / 2; - }; -}); - -})(); - -var effect = $.effects; - - -/*! - * jQuery UI Effects Blind 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/blind-effect/ - */ - - -var effectBlind = $.effects.effect.blind = function( o, done ) { - // Create element - var el = $( this ), - rvertical = /up|down|vertical/, - rpositivemotion = /up|left|vertical|horizontal/, - props = [ "position", "top", "bottom", "left", "right", "height", "width" ], - mode = $.effects.setMode( el, o.mode || "hide" ), - direction = o.direction || "up", - vertical = rvertical.test( direction ), - ref = vertical ? "height" : "width", - ref2 = vertical ? "top" : "left", - motion = rpositivemotion.test( direction ), - animation = {}, - show = mode === "show", - wrapper, distance, margin; - - // if already wrapped, the wrapper's properties are my property. #6245 - if ( el.parent().is( ".ui-effects-wrapper" ) ) { - $.effects.save( el.parent(), props ); - } else { - $.effects.save( el, props ); - } - el.show(); - wrapper = $.effects.createWrapper( el ).css({ - overflow: "hidden" - }); - - distance = wrapper[ ref ](); - margin = parseFloat( wrapper.css( ref2 ) ) || 0; - - animation[ ref ] = show ? distance : 0; - if ( !motion ) { - el - .css( vertical ? "bottom" : "right", 0 ) - .css( vertical ? "top" : "left", "auto" ) - .css({ position: "absolute" }); - - animation[ ref2 ] = show ? margin : distance + margin; - } - - // start at 0 if we are showing - if ( show ) { - wrapper.css( ref, 0 ); - if ( !motion ) { - wrapper.css( ref2, margin + distance ); - } - } - - // Animate - wrapper.animate( animation, { - duration: o.duration, - easing: o.easing, - queue: false, - complete: function() { - if ( mode === "hide" ) { - el.hide(); - } - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - done(); - } - }); -}; - - -/*! - * jQuery UI Effects Bounce 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/bounce-effect/ - */ - - -var effectBounce = $.effects.effect.bounce = function( o, done ) { - var el = $( this ), - props = [ "position", "top", "bottom", "left", "right", "height", "width" ], - - // defaults: - mode = $.effects.setMode( el, o.mode || "effect" ), - hide = mode === "hide", - show = mode === "show", - direction = o.direction || "up", - distance = o.distance, - times = o.times || 5, - - // number of internal animations - anims = times * 2 + ( show || hide ? 1 : 0 ), - speed = o.duration / anims, - easing = o.easing, - - // utility: - ref = ( direction === "up" || direction === "down" ) ? "top" : "left", - motion = ( direction === "up" || direction === "left" ), - i, - upAnim, - downAnim, - - // we will need to re-assemble the queue to stack our animations in place - queue = el.queue(), - queuelen = queue.length; - - // Avoid touching opacity to prevent clearType and PNG issues in IE - if ( show || hide ) { - props.push( "opacity" ); - } - - $.effects.save( el, props ); - el.show(); - $.effects.createWrapper( el ); // Create Wrapper - - // default distance for the BIGGEST bounce is the outer Distance / 3 - if ( !distance ) { - distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3; - } - - if ( show ) { - downAnim = { opacity: 1 }; - downAnim[ ref ] = 0; - - // if we are showing, force opacity 0 and set the initial position - // then do the "first" animation - el.css( "opacity", 0 ) - .css( ref, motion ? -distance * 2 : distance * 2 ) - .animate( downAnim, speed, easing ); - } - - // start at the smallest distance if we are hiding - if ( hide ) { - distance = distance / Math.pow( 2, times - 1 ); - } - - downAnim = {}; - downAnim[ ref ] = 0; - // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here - for ( i = 0; i < times; i++ ) { - upAnim = {}; - upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance; - - el.animate( upAnim, speed, easing ) - .animate( downAnim, speed, easing ); - - distance = hide ? distance * 2 : distance / 2; - } - - // Last Bounce when Hiding - if ( hide ) { - upAnim = { opacity: 0 }; - upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance; - - el.animate( upAnim, speed, easing ); - } - - el.queue(function() { - if ( hide ) { - el.hide(); - } - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - done(); - }); - - // inject all the animations we just queued to be first in line (after "inprogress") - if ( queuelen > 1) { - queue.splice.apply( queue, - [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); - } - el.dequeue(); - -}; - - -/*! - * jQuery UI Effects Clip 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/clip-effect/ - */ - - -var effectClip = $.effects.effect.clip = function( o, done ) { - // Create element - var el = $( this ), - props = [ "position", "top", "bottom", "left", "right", "height", "width" ], - mode = $.effects.setMode( el, o.mode || "hide" ), - show = mode === "show", - direction = o.direction || "vertical", - vert = direction === "vertical", - size = vert ? "height" : "width", - position = vert ? "top" : "left", - animation = {}, - wrapper, animate, distance; - - // Save & Show - $.effects.save( el, props ); - el.show(); - - // Create Wrapper - wrapper = $.effects.createWrapper( el ).css({ - overflow: "hidden" - }); - animate = ( el[0].tagName === "IMG" ) ? wrapper : el; - distance = animate[ size ](); - - // Shift - if ( show ) { - animate.css( size, 0 ); - animate.css( position, distance / 2 ); - } - - // Create Animation Object: - animation[ size ] = show ? distance : 0; - animation[ position ] = show ? 0 : distance / 2; - - // Animate - animate.animate( animation, { - queue: false, - duration: o.duration, - easing: o.easing, - complete: function() { - if ( !show ) { - el.hide(); - } - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - done(); - } - }); - -}; - - -/*! - * jQuery UI Effects Drop 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/drop-effect/ - */ - - -var effectDrop = $.effects.effect.drop = function( o, done ) { - - var el = $( this ), - props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ], - mode = $.effects.setMode( el, o.mode || "hide" ), - show = mode === "show", - direction = o.direction || "left", - ref = ( direction === "up" || direction === "down" ) ? "top" : "left", - motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg", - animation = { - opacity: show ? 1 : 0 - }, - distance; - - // Adjust - $.effects.save( el, props ); - el.show(); - $.effects.createWrapper( el ); - - distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2; - - if ( show ) { - el - .css( "opacity", 0 ) - .css( ref, motion === "pos" ? -distance : distance ); - } - - // Animation - animation[ ref ] = ( show ? - ( motion === "pos" ? "+=" : "-=" ) : - ( motion === "pos" ? "-=" : "+=" ) ) + - distance; - - // Animate - el.animate( animation, { - queue: false, - duration: o.duration, - easing: o.easing, - complete: function() { - if ( mode === "hide" ) { - el.hide(); - } - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - done(); - } - }); -}; - - -/*! - * jQuery UI Effects Explode 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/explode-effect/ - */ - - -var effectExplode = $.effects.effect.explode = function( o, done ) { - - var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3, - cells = rows, - el = $( this ), - mode = $.effects.setMode( el, o.mode || "hide" ), - show = mode === "show", - - // show and then visibility:hidden the element before calculating offset - offset = el.show().css( "visibility", "hidden" ).offset(), - - // width and height of a piece - width = Math.ceil( el.outerWidth() / cells ), - height = Math.ceil( el.outerHeight() / rows ), - pieces = [], - - // loop - i, j, left, top, mx, my; - - // children animate complete: - function childComplete() { - pieces.push( this ); - if ( pieces.length === rows * cells ) { - animComplete(); - } - } - - // clone the element for each row and cell. - for ( i = 0; i < rows ; i++ ) { // ===> - top = offset.top + i * height; - my = i - ( rows - 1 ) / 2 ; - - for ( j = 0; j < cells ; j++ ) { // ||| - left = offset.left + j * width; - mx = j - ( cells - 1 ) / 2 ; - - // Create a clone of the now hidden main element that will be absolute positioned - // within a wrapper div off the -left and -top equal to size of our pieces - el - .clone() - .appendTo( "body" ) - .wrap( "<div></div>" ) - .css({ - position: "absolute", - visibility: "visible", - left: -j * width, - top: -i * height - }) - - // select the wrapper - make it overflow: hidden and absolute positioned based on - // where the original was located +left and +top equal to the size of pieces - .parent() - .addClass( "ui-effects-explode" ) - .css({ - position: "absolute", - overflow: "hidden", - width: width, - height: height, - left: left + ( show ? mx * width : 0 ), - top: top + ( show ? my * height : 0 ), - opacity: show ? 0 : 1 - }).animate({ - left: left + ( show ? 0 : mx * width ), - top: top + ( show ? 0 : my * height ), - opacity: show ? 1 : 0 - }, o.duration || 500, o.easing, childComplete ); - } - } - - function animComplete() { - el.css({ - visibility: "visible" - }); - $( pieces ).remove(); - if ( !show ) { - el.hide(); - } - done(); - } -}; - - -/*! - * jQuery UI Effects Fade 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/fade-effect/ - */ - - -var effectFade = $.effects.effect.fade = function( o, done ) { - var el = $( this ), - mode = $.effects.setMode( el, o.mode || "toggle" ); - - el.animate({ - opacity: mode - }, { - queue: false, - duration: o.duration, - easing: o.easing, - complete: done - }); -}; - - -/*! - * jQuery UI Effects Fold 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/fold-effect/ - */ - - -var effectFold = $.effects.effect.fold = function( o, done ) { - - // Create element - var el = $( this ), - props = [ "position", "top", "bottom", "left", "right", "height", "width" ], - mode = $.effects.setMode( el, o.mode || "hide" ), - show = mode === "show", - hide = mode === "hide", - size = o.size || 15, - percent = /([0-9]+)%/.exec( size ), - horizFirst = !!o.horizFirst, - widthFirst = show !== horizFirst, - ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ], - duration = o.duration / 2, - wrapper, distance, - animation1 = {}, - animation2 = {}; - - $.effects.save( el, props ); - el.show(); - - // Create Wrapper - wrapper = $.effects.createWrapper( el ).css({ - overflow: "hidden" - }); - distance = widthFirst ? - [ wrapper.width(), wrapper.height() ] : - [ wrapper.height(), wrapper.width() ]; - - if ( percent ) { - size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ]; - } - if ( show ) { - wrapper.css( horizFirst ? { - height: 0, - width: size - } : { - height: size, - width: 0 - }); - } - - // Animation - animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size; - animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0; - - // Animate - wrapper - .animate( animation1, duration, o.easing ) - .animate( animation2, duration, o.easing, function() { - if ( hide ) { - el.hide(); - } - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - done(); - }); - -}; - - -/*! - * jQuery UI Effects Highlight 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/highlight-effect/ - */ - - -var effectHighlight = $.effects.effect.highlight = function( o, done ) { - var elem = $( this ), - props = [ "backgroundImage", "backgroundColor", "opacity" ], - mode = $.effects.setMode( elem, o.mode || "show" ), - animation = { - backgroundColor: elem.css( "backgroundColor" ) - }; - - if (mode === "hide") { - animation.opacity = 0; - } - - $.effects.save( elem, props ); - - elem - .show() - .css({ - backgroundImage: "none", - backgroundColor: o.color || "#ffff99" - }) - .animate( animation, { - queue: false, - duration: o.duration, - easing: o.easing, - complete: function() { - if ( mode === "hide" ) { - elem.hide(); - } - $.effects.restore( elem, props ); - done(); - } - }); -}; - - -/*! - * jQuery UI Effects Size 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/size-effect/ - */ - - -var effectSize = $.effects.effect.size = function( o, done ) { - - // Create element - var original, baseline, factor, - el = $( this ), - props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ], - - // Always restore - props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ], - - // Copy for children - props2 = [ "width", "height", "overflow" ], - cProps = [ "fontSize" ], - vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ], - hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ], - - // Set options - mode = $.effects.setMode( el, o.mode || "effect" ), - restore = o.restore || mode !== "effect", - scale = o.scale || "both", - origin = o.origin || [ "middle", "center" ], - position = el.css( "position" ), - props = restore ? props0 : props1, - zero = { - height: 0, - width: 0, - outerHeight: 0, - outerWidth: 0 - }; - - if ( mode === "show" ) { - el.show(); - } - original = { - height: el.height(), - width: el.width(), - outerHeight: el.outerHeight(), - outerWidth: el.outerWidth() - }; - - if ( o.mode === "toggle" && mode === "show" ) { - el.from = o.to || zero; - el.to = o.from || original; - } else { - el.from = o.from || ( mode === "show" ? zero : original ); - el.to = o.to || ( mode === "hide" ? zero : original ); - } - - // Set scaling factor - factor = { - from: { - y: el.from.height / original.height, - x: el.from.width / original.width - }, - to: { - y: el.to.height / original.height, - x: el.to.width / original.width - } - }; - - // Scale the css box - if ( scale === "box" || scale === "both" ) { - - // Vertical props scaling - if ( factor.from.y !== factor.to.y ) { - props = props.concat( vProps ); - el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from ); - el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to ); - } - - // Horizontal props scaling - if ( factor.from.x !== factor.to.x ) { - props = props.concat( hProps ); - el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from ); - el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to ); - } - } - - // Scale the content - if ( scale === "content" || scale === "both" ) { - - // Vertical props scaling - if ( factor.from.y !== factor.to.y ) { - props = props.concat( cProps ).concat( props2 ); - el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from ); - el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to ); - } - } - - $.effects.save( el, props ); - el.show(); - $.effects.createWrapper( el ); - el.css( "overflow", "hidden" ).css( el.from ); - - // Adjust - if (origin) { // Calculate baseline shifts - baseline = $.effects.getBaseline( origin, original ); - el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y; - el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x; - el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y; - el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x; - } - el.css( el.from ); // set top & left - - // Animate - if ( scale === "content" || scale === "both" ) { // Scale the children - - // Add margins/font-size - vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps); - hProps = hProps.concat([ "marginLeft", "marginRight" ]); - props2 = props0.concat(vProps).concat(hProps); - - el.find( "*[width]" ).each( function() { - var child = $( this ), - c_original = { - height: child.height(), - width: child.width(), - outerHeight: child.outerHeight(), - outerWidth: child.outerWidth() - }; - if (restore) { - $.effects.save(child, props2); - } - - child.from = { - height: c_original.height * factor.from.y, - width: c_original.width * factor.from.x, - outerHeight: c_original.outerHeight * factor.from.y, - outerWidth: c_original.outerWidth * factor.from.x - }; - child.to = { - height: c_original.height * factor.to.y, - width: c_original.width * factor.to.x, - outerHeight: c_original.height * factor.to.y, - outerWidth: c_original.width * factor.to.x - }; - - // Vertical props scaling - if ( factor.from.y !== factor.to.y ) { - child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from ); - child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to ); - } - - // Horizontal props scaling - if ( factor.from.x !== factor.to.x ) { - child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from ); - child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to ); - } - - // Animate children - child.css( child.from ); - child.animate( child.to, o.duration, o.easing, function() { - - // Restore children - if ( restore ) { - $.effects.restore( child, props2 ); - } - }); - }); - } - - // Animate - el.animate( el.to, { - queue: false, - duration: o.duration, - easing: o.easing, - complete: function() { - if ( el.to.opacity === 0 ) { - el.css( "opacity", el.from.opacity ); - } - if ( mode === "hide" ) { - el.hide(); - } - $.effects.restore( el, props ); - if ( !restore ) { - - // we need to calculate our new positioning based on the scaling - if ( position === "static" ) { - el.css({ - position: "relative", - top: el.to.top, - left: el.to.left - }); - } else { - $.each([ "top", "left" ], function( idx, pos ) { - el.css( pos, function( _, str ) { - var val = parseInt( str, 10 ), - toRef = idx ? el.to.left : el.to.top; - - // if original was "auto", recalculate the new value from wrapper - if ( str === "auto" ) { - return toRef + "px"; - } - - return val + toRef + "px"; - }); - }); - } - } - - $.effects.removeWrapper( el ); - done(); - } - }); - -}; - - -/*! - * jQuery UI Effects Scale 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/scale-effect/ - */ - - -var effectScale = $.effects.effect.scale = function( o, done ) { - - // Create element - var el = $( this ), - options = $.extend( true, {}, o ), - mode = $.effects.setMode( el, o.mode || "effect" ), - percent = parseInt( o.percent, 10 ) || - ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ), - direction = o.direction || "both", - origin = o.origin, - original = { - height: el.height(), - width: el.width(), - outerHeight: el.outerHeight(), - outerWidth: el.outerWidth() - }, - factor = { - y: direction !== "horizontal" ? (percent / 100) : 1, - x: direction !== "vertical" ? (percent / 100) : 1 - }; - - // We are going to pass this effect to the size effect: - options.effect = "size"; - options.queue = false; - options.complete = done; - - // Set default origin and restore for show/hide - if ( mode !== "effect" ) { - options.origin = origin || [ "middle", "center" ]; - options.restore = true; - } - - options.from = o.from || ( mode === "show" ? { - height: 0, - width: 0, - outerHeight: 0, - outerWidth: 0 - } : original ); - options.to = { - height: original.height * factor.y, - width: original.width * factor.x, - outerHeight: original.outerHeight * factor.y, - outerWidth: original.outerWidth * factor.x - }; - - // Fade option to support puff - if ( options.fade ) { - if ( mode === "show" ) { - options.from.opacity = 0; - options.to.opacity = 1; - } - if ( mode === "hide" ) { - options.from.opacity = 1; - options.to.opacity = 0; - } - } - - // Animate - el.effect( options ); - -}; - - -/*! - * jQuery UI Effects Puff 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/puff-effect/ - */ - - -var effectPuff = $.effects.effect.puff = function( o, done ) { - var elem = $( this ), - mode = $.effects.setMode( elem, o.mode || "hide" ), - hide = mode === "hide", - percent = parseInt( o.percent, 10 ) || 150, - factor = percent / 100, - original = { - height: elem.height(), - width: elem.width(), - outerHeight: elem.outerHeight(), - outerWidth: elem.outerWidth() - }; - - $.extend( o, { - effect: "scale", - queue: false, - fade: true, - mode: mode, - complete: done, - percent: hide ? percent : 100, - from: hide ? - original : - { - height: original.height * factor, - width: original.width * factor, - outerHeight: original.outerHeight * factor, - outerWidth: original.outerWidth * factor - } - }); - - elem.effect( o ); -}; - - -/*! - * jQuery UI Effects Pulsate 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/pulsate-effect/ - */ - - -var effectPulsate = $.effects.effect.pulsate = function( o, done ) { - var elem = $( this ), - mode = $.effects.setMode( elem, o.mode || "show" ), - show = mode === "show", - hide = mode === "hide", - showhide = ( show || mode === "hide" ), - - // showing or hiding leaves of the "last" animation - anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ), - duration = o.duration / anims, - animateTo = 0, - queue = elem.queue(), - queuelen = queue.length, - i; - - if ( show || !elem.is(":visible")) { - elem.css( "opacity", 0 ).show(); - animateTo = 1; - } - - // anims - 1 opacity "toggles" - for ( i = 1; i < anims; i++ ) { - elem.animate({ - opacity: animateTo - }, duration, o.easing ); - animateTo = 1 - animateTo; - } - - elem.animate({ - opacity: animateTo - }, duration, o.easing); - - elem.queue(function() { - if ( hide ) { - elem.hide(); - } - done(); - }); - - // We just queued up "anims" animations, we need to put them next in the queue - if ( queuelen > 1 ) { - queue.splice.apply( queue, - [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); - } - elem.dequeue(); -}; - - -/*! - * jQuery UI Effects Shake 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/shake-effect/ - */ - - -var effectShake = $.effects.effect.shake = function( o, done ) { - - var el = $( this ), - props = [ "position", "top", "bottom", "left", "right", "height", "width" ], - mode = $.effects.setMode( el, o.mode || "effect" ), - direction = o.direction || "left", - distance = o.distance || 20, - times = o.times || 3, - anims = times * 2 + 1, - speed = Math.round( o.duration / anims ), - ref = (direction === "up" || direction === "down") ? "top" : "left", - positiveMotion = (direction === "up" || direction === "left"), - animation = {}, - animation1 = {}, - animation2 = {}, - i, - - // we will need to re-assemble the queue to stack our animations in place - queue = el.queue(), - queuelen = queue.length; - - $.effects.save( el, props ); - el.show(); - $.effects.createWrapper( el ); - - // Animation - animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance; - animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2; - animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2; - - // Animate - el.animate( animation, speed, o.easing ); - - // Shakes - for ( i = 1; i < times; i++ ) { - el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing ); - } - el - .animate( animation1, speed, o.easing ) - .animate( animation, speed / 2, o.easing ) - .queue(function() { - if ( mode === "hide" ) { - el.hide(); - } - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - done(); - }); - - // inject all the animations we just queued to be first in line (after "inprogress") - if ( queuelen > 1) { - queue.splice.apply( queue, - [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); - } - el.dequeue(); - -}; - - -/*! - * jQuery UI Effects Slide 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/slide-effect/ - */ - - -var effectSlide = $.effects.effect.slide = function( o, done ) { - - // Create element - var el = $( this ), - props = [ "position", "top", "bottom", "left", "right", "width", "height" ], - mode = $.effects.setMode( el, o.mode || "show" ), - show = mode === "show", - direction = o.direction || "left", - ref = (direction === "up" || direction === "down") ? "top" : "left", - positiveMotion = (direction === "up" || direction === "left"), - distance, - animation = {}; - - // Adjust - $.effects.save( el, props ); - el.show(); - distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ); - - $.effects.createWrapper( el ).css({ - overflow: "hidden" - }); - - if ( show ) { - el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance ); - } - - // Animation - animation[ ref ] = ( show ? - ( positiveMotion ? "+=" : "-=") : - ( positiveMotion ? "-=" : "+=")) + - distance; - - // Animate - el.animate( animation, { - queue: false, - duration: o.duration, - easing: o.easing, - complete: function() { - if ( mode === "hide" ) { - el.hide(); - } - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - done(); - } - }); -}; - - -/*! - * jQuery UI Effects Transfer 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/transfer-effect/ - */ - - -var effectTransfer = $.effects.effect.transfer = function( o, done ) { - var elem = $( this ), - target = $( o.to ), - targetFixed = target.css( "position" ) === "fixed", - body = $("body"), - fixTop = targetFixed ? body.scrollTop() : 0, - fixLeft = targetFixed ? body.scrollLeft() : 0, - endPosition = target.offset(), - animation = { - top: endPosition.top - fixTop, - left: endPosition.left - fixLeft, - height: target.innerHeight(), - width: target.innerWidth() - }, - startPosition = elem.offset(), - transfer = $( "<div class='ui-effects-transfer'></div>" ) - .appendTo( document.body ) - .addClass( o.className ) - .css({ - top: startPosition.top - fixTop, - left: startPosition.left - fixLeft, - height: elem.innerHeight(), - width: elem.innerWidth(), - position: targetFixed ? "fixed" : "absolute" - }) - .animate( animation, o.duration, o.easing, function() { - transfer.remove(); - done(); - }); -}; - - -/*! - * jQuery UI Progressbar 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/progressbar/ - */ - - -var progressbar = $.widget( "ui.progressbar", { - version: "1.11.4", - options: { - max: 100, - value: 0, - - change: null, - complete: null - }, - - min: 0, - - _create: function() { - // Constrain initial value - this.oldValue = this.options.value = this._constrainedValue(); - - this.element - .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" ) - .attr({ - // Only set static values, aria-valuenow and aria-valuemax are - // set inside _refreshValue() - role: "progressbar", - "aria-valuemin": this.min - }); - - this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" ) - .appendTo( this.element ); - - this._refreshValue(); - }, - - _destroy: function() { - this.element - .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" ) - .removeAttr( "role" ) - .removeAttr( "aria-valuemin" ) - .removeAttr( "aria-valuemax" ) - .removeAttr( "aria-valuenow" ); - - this.valueDiv.remove(); - }, - - value: function( newValue ) { - if ( newValue === undefined ) { - return this.options.value; - } - - this.options.value = this._constrainedValue( newValue ); - this._refreshValue(); - }, - - _constrainedValue: function( newValue ) { - if ( newValue === undefined ) { - newValue = this.options.value; - } - - this.indeterminate = newValue === false; - - // sanitize value - if ( typeof newValue !== "number" ) { - newValue = 0; - } - - return this.indeterminate ? false : - Math.min( this.options.max, Math.max( this.min, newValue ) ); - }, - - _setOptions: function( options ) { - // Ensure "value" option is set after other values (like max) - var value = options.value; - delete options.value; - - this._super( options ); - - this.options.value = this._constrainedValue( value ); - this._refreshValue(); - }, - - _setOption: function( key, value ) { - if ( key === "max" ) { - // Don't allow a max less than min - value = Math.max( this.min, value ); - } - if ( key === "disabled" ) { - this.element - .toggleClass( "ui-state-disabled", !!value ) - .attr( "aria-disabled", value ); - } - this._super( key, value ); - }, - - _percentage: function() { - return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min ); - }, - - _refreshValue: function() { - var value = this.options.value, - percentage = this._percentage(); - - this.valueDiv - .toggle( this.indeterminate || value > this.min ) - .toggleClass( "ui-corner-right", value === this.options.max ) - .width( percentage.toFixed(0) + "%" ); - - this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate ); - - if ( this.indeterminate ) { - this.element.removeAttr( "aria-valuenow" ); - if ( !this.overlayDiv ) { - this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv ); - } - } else { - this.element.attr({ - "aria-valuemax": this.options.max, - "aria-valuenow": value - }); - if ( this.overlayDiv ) { - this.overlayDiv.remove(); - this.overlayDiv = null; - } - } - - if ( this.oldValue !== value ) { - this.oldValue = value; - this._trigger( "change" ); - } - if ( value === this.options.max ) { - this._trigger( "complete" ); - } - } -}); - - -/*! - * jQuery UI Selectable 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/selectable/ - */ - - -var selectable = $.widget("ui.selectable", $.ui.mouse, { - version: "1.11.4", - options: { - appendTo: "body", - autoRefresh: true, - distance: 0, - filter: "*", - tolerance: "touch", - - // callbacks - selected: null, - selecting: null, - start: null, - stop: null, - unselected: null, - unselecting: null - }, - _create: function() { - var selectees, - that = this; - - this.element.addClass("ui-selectable"); - - this.dragged = false; - - // cache selectee children based on filter - this.refresh = function() { - selectees = $(that.options.filter, that.element[0]); - selectees.addClass("ui-selectee"); - selectees.each(function() { - var $this = $(this), - pos = $this.offset(); - $.data(this, "selectable-item", { - element: this, - $element: $this, - left: pos.left, - top: pos.top, - right: pos.left + $this.outerWidth(), - bottom: pos.top + $this.outerHeight(), - startselected: false, - selected: $this.hasClass("ui-selected"), - selecting: $this.hasClass("ui-selecting"), - unselecting: $this.hasClass("ui-unselecting") - }); - }); - }; - this.refresh(); - - this.selectees = selectees.addClass("ui-selectee"); - - this._mouseInit(); - - this.helper = $("<div class='ui-selectable-helper'></div>"); - }, - - _destroy: function() { - this.selectees - .removeClass("ui-selectee") - .removeData("selectable-item"); - this.element - .removeClass("ui-selectable ui-selectable-disabled"); - this._mouseDestroy(); - }, - - _mouseStart: function(event) { - var that = this, - options = this.options; - - this.opos = [ event.pageX, event.pageY ]; - - if (this.options.disabled) { - return; - } - - this.selectees = $(options.filter, this.element[0]); - - this._trigger("start", event); - - $(options.appendTo).append(this.helper); - // position helper (lasso) - this.helper.css({ - "left": event.pageX, - "top": event.pageY, - "width": 0, - "height": 0 - }); - - if (options.autoRefresh) { - this.refresh(); - } - - this.selectees.filter(".ui-selected").each(function() { - var selectee = $.data(this, "selectable-item"); - selectee.startselected = true; - if (!event.metaKey && !event.ctrlKey) { - selectee.$element.removeClass("ui-selected"); - selectee.selected = false; - selectee.$element.addClass("ui-unselecting"); - selectee.unselecting = true; - // selectable UNSELECTING callback - that._trigger("unselecting", event, { - unselecting: selectee.element - }); - } - }); - - $(event.target).parents().addBack().each(function() { - var doSelect, - selectee = $.data(this, "selectable-item"); - if (selectee) { - doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected"); - selectee.$element - .removeClass(doSelect ? "ui-unselecting" : "ui-selected") - .addClass(doSelect ? "ui-selecting" : "ui-unselecting"); - selectee.unselecting = !doSelect; - selectee.selecting = doSelect; - selectee.selected = doSelect; - // selectable (UN)SELECTING callback - if (doSelect) { - that._trigger("selecting", event, { - selecting: selectee.element - }); - } else { - that._trigger("unselecting", event, { - unselecting: selectee.element - }); - } - return false; - } - }); - - }, - - _mouseDrag: function(event) { - - this.dragged = true; - - if (this.options.disabled) { - return; - } - - var tmp, - that = this, - options = this.options, - x1 = this.opos[0], - y1 = this.opos[1], - x2 = event.pageX, - y2 = event.pageY; - - if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; } - if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; } - this.helper.css({ left: x1, top: y1, width: x2 - x1, height: y2 - y1 }); - - this.selectees.each(function() { - var selectee = $.data(this, "selectable-item"), - hit = false; - - //prevent helper from being selected if appendTo: selectable - if (!selectee || selectee.element === that.element[0]) { - return; - } - - if (options.tolerance === "touch") { - hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) ); - } else if (options.tolerance === "fit") { - hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2); - } - - if (hit) { - // SELECT - if (selectee.selected) { - selectee.$element.removeClass("ui-selected"); - selectee.selected = false; - } - if (selectee.unselecting) { - selectee.$element.removeClass("ui-unselecting"); - selectee.unselecting = false; - } - if (!selectee.selecting) { - selectee.$element.addClass("ui-selecting"); - selectee.selecting = true; - // selectable SELECTING callback - that._trigger("selecting", event, { - selecting: selectee.element - }); - } - } else { - // UNSELECT - if (selectee.selecting) { - if ((event.metaKey || event.ctrlKey) && selectee.startselected) { - selectee.$element.removeClass("ui-selecting"); - selectee.selecting = false; - selectee.$element.addClass("ui-selected"); - selectee.selected = true; - } else { - selectee.$element.removeClass("ui-selecting"); - selectee.selecting = false; - if (selectee.startselected) { - selectee.$element.addClass("ui-unselecting"); - selectee.unselecting = true; - } - // selectable UNSELECTING callback - that._trigger("unselecting", event, { - unselecting: selectee.element - }); - } - } - if (selectee.selected) { - if (!event.metaKey && !event.ctrlKey && !selectee.startselected) { - selectee.$element.removeClass("ui-selected"); - selectee.selected = false; - - selectee.$element.addClass("ui-unselecting"); - selectee.unselecting = true; - // selectable UNSELECTING callback - that._trigger("unselecting", event, { - unselecting: selectee.element - }); - } - } - } - }); - - return false; - }, - - _mouseStop: function(event) { - var that = this; - - this.dragged = false; - - $(".ui-unselecting", this.element[0]).each(function() { - var selectee = $.data(this, "selectable-item"); - selectee.$element.removeClass("ui-unselecting"); - selectee.unselecting = false; - selectee.startselected = false; - that._trigger("unselected", event, { - unselected: selectee.element - }); - }); - $(".ui-selecting", this.element[0]).each(function() { - var selectee = $.data(this, "selectable-item"); - selectee.$element.removeClass("ui-selecting").addClass("ui-selected"); - selectee.selecting = false; - selectee.selected = true; - selectee.startselected = true; - that._trigger("selected", event, { - selected: selectee.element - }); - }); - this._trigger("stop", event); - - this.helper.remove(); - - return false; - } - -}); - - -/*! - * jQuery UI Selectmenu 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/selectmenu - */ - - -var selectmenu = $.widget( "ui.selectmenu", { - version: "1.11.4", - defaultElement: "<select>", - options: { - appendTo: null, - disabled: null, - icons: { - button: "ui-icon-triangle-1-s" - }, - position: { - my: "left top", - at: "left bottom", - collision: "none" - }, - width: null, - - // callbacks - change: null, - close: null, - focus: null, - open: null, - select: null - }, - - _create: function() { - var selectmenuId = this.element.uniqueId().attr( "id" ); - this.ids = { - element: selectmenuId, - button: selectmenuId + "-button", - menu: selectmenuId + "-menu" - }; - - this._drawButton(); - this._drawMenu(); - - if ( this.options.disabled ) { - this.disable(); - } - }, - - _drawButton: function() { - var that = this; - - // Associate existing label with the new button - this.label = $( "label[for='" + this.ids.element + "']" ).attr( "for", this.ids.button ); - this._on( this.label, { - click: function( event ) { - this.button.focus(); - event.preventDefault(); - } - }); - - // Hide original select element - this.element.hide(); - - // Create button - this.button = $( "<span>", { - "class": "ui-selectmenu-button ui-widget ui-state-default ui-corner-all", - tabindex: this.options.disabled ? -1 : 0, - id: this.ids.button, - role: "combobox", - "aria-expanded": "false", - "aria-autocomplete": "list", - "aria-owns": this.ids.menu, - "aria-haspopup": "true" - }) - .insertAfter( this.element ); - - $( "<span>", { - "class": "ui-icon " + this.options.icons.button - }) - .prependTo( this.button ); - - this.buttonText = $( "<span>", { - "class": "ui-selectmenu-text" - }) - .appendTo( this.button ); - - this._setText( this.buttonText, this.element.find( "option:selected" ).text() ); - this._resizeButton(); - - this._on( this.button, this._buttonEvents ); - this.button.one( "focusin", function() { - - // Delay rendering the menu items until the button receives focus. - // The menu may have already been rendered via a programmatic open. - if ( !that.menuItems ) { - that._refreshMenu(); - } - }); - this._hoverable( this.button ); - this._focusable( this.button ); - }, - - _drawMenu: function() { - var that = this; - - // Create menu - this.menu = $( "<ul>", { - "aria-hidden": "true", - "aria-labelledby": this.ids.button, - id: this.ids.menu - }); - - // Wrap menu - this.menuWrap = $( "<div>", { - "class": "ui-selectmenu-menu ui-front" - }) - .append( this.menu ) - .appendTo( this._appendTo() ); - - // Initialize menu widget - this.menuInstance = this.menu - .menu({ - role: "listbox", - select: function( event, ui ) { - event.preventDefault(); - - // support: IE8 - // If the item was selected via a click, the text selection - // will be destroyed in IE - that._setSelection(); - - that._select( ui.item.data( "ui-selectmenu-item" ), event ); - }, - focus: function( event, ui ) { - var item = ui.item.data( "ui-selectmenu-item" ); - - // Prevent inital focus from firing and check if its a newly focused item - if ( that.focusIndex != null && item.index !== that.focusIndex ) { - that._trigger( "focus", event, { item: item } ); - if ( !that.isOpen ) { - that._select( item, event ); - } - } - that.focusIndex = item.index; - - that.button.attr( "aria-activedescendant", - that.menuItems.eq( item.index ).attr( "id" ) ); - } - }) - .menu( "instance" ); - - // Adjust menu styles to dropdown - this.menu - .addClass( "ui-corner-bottom" ) - .removeClass( "ui-corner-all" ); - - // Don't close the menu on mouseleave - this.menuInstance._off( this.menu, "mouseleave" ); - - // Cancel the menu's collapseAll on document click - this.menuInstance._closeOnDocumentClick = function() { - return false; - }; - - // Selects often contain empty items, but never contain dividers - this.menuInstance._isDivider = function() { - return false; - }; - }, - - refresh: function() { - this._refreshMenu(); - this._setText( this.buttonText, this._getSelectedItem().text() ); - if ( !this.options.width ) { - this._resizeButton(); - } - }, - - _refreshMenu: function() { - this.menu.empty(); - - var item, - options = this.element.find( "option" ); - - if ( !options.length ) { - return; - } - - this._parseOptions( options ); - this._renderMenu( this.menu, this.items ); - - this.menuInstance.refresh(); - this.menuItems = this.menu.find( "li" ).not( ".ui-selectmenu-optgroup" ); - - item = this._getSelectedItem(); - - // Update the menu to have the correct item focused - this.menuInstance.focus( null, item ); - this._setAria( item.data( "ui-selectmenu-item" ) ); - - // Set disabled state - this._setOption( "disabled", this.element.prop( "disabled" ) ); - }, - - open: function( event ) { - if ( this.options.disabled ) { - return; - } - - // If this is the first time the menu is being opened, render the items - if ( !this.menuItems ) { - this._refreshMenu(); - } else { - - // Menu clears focus on close, reset focus to selected item - this.menu.find( ".ui-state-focus" ).removeClass( "ui-state-focus" ); - this.menuInstance.focus( null, this._getSelectedItem() ); - } - - this.isOpen = true; - this._toggleAttr(); - this._resizeMenu(); - this._position(); - - this._on( this.document, this._documentClick ); - - this._trigger( "open", event ); - }, - - _position: function() { - this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) ); - }, - - close: function( event ) { - if ( !this.isOpen ) { - return; - } - - this.isOpen = false; - this._toggleAttr(); - - this.range = null; - this._off( this.document ); - - this._trigger( "close", event ); - }, - - widget: function() { - return this.button; - }, - - menuWidget: function() { - return this.menu; - }, - - _renderMenu: function( ul, items ) { - var that = this, - currentOptgroup = ""; - - $.each( items, function( index, item ) { - if ( item.optgroup !== currentOptgroup ) { - $( "<li>", { - "class": "ui-selectmenu-optgroup ui-menu-divider" + - ( item.element.parent( "optgroup" ).prop( "disabled" ) ? - " ui-state-disabled" : - "" ), - text: item.optgroup - }) - .appendTo( ul ); - - currentOptgroup = item.optgroup; - } - - that._renderItemData( ul, item ); - }); - }, - - _renderItemData: function( ul, item ) { - return this._renderItem( ul, item ).data( "ui-selectmenu-item", item ); - }, - - _renderItem: function( ul, item ) { - var li = $( "<li>" ); - - if ( item.disabled ) { - li.addClass( "ui-state-disabled" ); - } - this._setText( li, item.label ); - - return li.appendTo( ul ); - }, - - _setText: function( element, value ) { - if ( value ) { - element.text( value ); - } else { - element.html( " " ); - } - }, - - _move: function( direction, event ) { - var item, next, - filter = ".ui-menu-item"; - - if ( this.isOpen ) { - item = this.menuItems.eq( this.focusIndex ); - } else { - item = this.menuItems.eq( this.element[ 0 ].selectedIndex ); - filter += ":not(.ui-state-disabled)"; - } - - if ( direction === "first" || direction === "last" ) { - next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 ); - } else { - next = item[ direction + "All" ]( filter ).eq( 0 ); - } - - if ( next.length ) { - this.menuInstance.focus( event, next ); - } - }, - - _getSelectedItem: function() { - return this.menuItems.eq( this.element[ 0 ].selectedIndex ); - }, - - _toggle: function( event ) { - this[ this.isOpen ? "close" : "open" ]( event ); - }, - - _setSelection: function() { - var selection; - - if ( !this.range ) { - return; - } - - if ( window.getSelection ) { - selection = window.getSelection(); - selection.removeAllRanges(); - selection.addRange( this.range ); - - // support: IE8 - } else { - this.range.select(); - } - - // support: IE - // Setting the text selection kills the button focus in IE, but - // restoring the focus doesn't kill the selection. - this.button.focus(); - }, - - _documentClick: { - mousedown: function( event ) { - if ( !this.isOpen ) { - return; - } - - if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" + this.ids.button ).length ) { - this.close( event ); - } - } - }, - - _buttonEvents: { - - // Prevent text selection from being reset when interacting with the selectmenu (#10144) - mousedown: function() { - var selection; - - if ( window.getSelection ) { - selection = window.getSelection(); - if ( selection.rangeCount ) { - this.range = selection.getRangeAt( 0 ); - } - - // support: IE8 - } else { - this.range = document.selection.createRange(); - } - }, - - click: function( event ) { - this._setSelection(); - this._toggle( event ); - }, - - keydown: function( event ) { - var preventDefault = true; - switch ( event.keyCode ) { - case $.ui.keyCode.TAB: - case $.ui.keyCode.ESCAPE: - this.close( event ); - preventDefault = false; - break; - case $.ui.keyCode.ENTER: - if ( this.isOpen ) { - this._selectFocusedItem( event ); - } - break; - case $.ui.keyCode.UP: - if ( event.altKey ) { - this._toggle( event ); - } else { - this._move( "prev", event ); - } - break; - case $.ui.keyCode.DOWN: - if ( event.altKey ) { - this._toggle( event ); - } else { - this._move( "next", event ); - } - break; - case $.ui.keyCode.SPACE: - if ( this.isOpen ) { - this._selectFocusedItem( event ); - } else { - this._toggle( event ); - } - break; - case $.ui.keyCode.LEFT: - this._move( "prev", event ); - break; - case $.ui.keyCode.RIGHT: - this._move( "next", event ); - break; - case $.ui.keyCode.HOME: - case $.ui.keyCode.PAGE_UP: - this._move( "first", event ); - break; - case $.ui.keyCode.END: - case $.ui.keyCode.PAGE_DOWN: - this._move( "last", event ); - break; - default: - this.menu.trigger( event ); - preventDefault = false; - } - - if ( preventDefault ) { - event.preventDefault(); - } - } - }, - - _selectFocusedItem: function( event ) { - var item = this.menuItems.eq( this.focusIndex ); - if ( !item.hasClass( "ui-state-disabled" ) ) { - this._select( item.data( "ui-selectmenu-item" ), event ); - } - }, - - _select: function( item, event ) { - var oldIndex = this.element[ 0 ].selectedIndex; - - // Change native select element - this.element[ 0 ].selectedIndex = item.index; - this._setText( this.buttonText, item.label ); - this._setAria( item ); - this._trigger( "select", event, { item: item } ); - - if ( item.index !== oldIndex ) { - this._trigger( "change", event, { item: item } ); - } - - this.close( event ); - }, - - _setAria: function( item ) { - var id = this.menuItems.eq( item.index ).attr( "id" ); - - this.button.attr({ - "aria-labelledby": id, - "aria-activedescendant": id - }); - this.menu.attr( "aria-activedescendant", id ); - }, - - _setOption: function( key, value ) { - if ( key === "icons" ) { - this.button.find( "span.ui-icon" ) - .removeClass( this.options.icons.button ) - .addClass( value.button ); - } - - this._super( key, value ); - - if ( key === "appendTo" ) { - this.menuWrap.appendTo( this._appendTo() ); - } - - if ( key === "disabled" ) { - this.menuInstance.option( "disabled", value ); - this.button - .toggleClass( "ui-state-disabled", value ) - .attr( "aria-disabled", value ); - - this.element.prop( "disabled", value ); - if ( value ) { - this.button.attr( "tabindex", -1 ); - this.close(); - } else { - this.button.attr( "tabindex", 0 ); - } - } - - if ( key === "width" ) { - this._resizeButton(); - } - }, - - _appendTo: function() { - var element = this.options.appendTo; - - if ( element ) { - element = element.jquery || element.nodeType ? - $( element ) : - this.document.find( element ).eq( 0 ); - } - - if ( !element || !element[ 0 ] ) { - element = this.element.closest( ".ui-front" ); - } - - if ( !element.length ) { - element = this.document[ 0 ].body; - } - - return element; - }, - - _toggleAttr: function() { - this.button - .toggleClass( "ui-corner-top", this.isOpen ) - .toggleClass( "ui-corner-all", !this.isOpen ) - .attr( "aria-expanded", this.isOpen ); - this.menuWrap.toggleClass( "ui-selectmenu-open", this.isOpen ); - this.menu.attr( "aria-hidden", !this.isOpen ); - }, - - _resizeButton: function() { - var width = this.options.width; - - if ( !width ) { - width = this.element.show().outerWidth(); - this.element.hide(); - } - - this.button.outerWidth( width ); - }, - - _resizeMenu: function() { - this.menu.outerWidth( Math.max( - this.button.outerWidth(), - - // support: IE10 - // IE10 wraps long text (possibly a rounding bug) - // so we add 1px to avoid the wrapping - this.menu.width( "" ).outerWidth() + 1 - ) ); - }, - - _getCreateOptions: function() { - return { disabled: this.element.prop( "disabled" ) }; - }, - - _parseOptions: function( options ) { - var data = []; - options.each(function( index, item ) { - var option = $( item ), - optgroup = option.parent( "optgroup" ); - data.push({ - element: option, - index: index, - value: option.val(), - label: option.text(), - optgroup: optgroup.attr( "label" ) || "", - disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" ) - }); - }); - this.items = data; - }, - - _destroy: function() { - this.menuWrap.remove(); - this.button.remove(); - this.element.show(); - this.element.removeUniqueId(); - this.label.attr( "for", this.ids.element ); - } -}); - - -/*! - * jQuery UI Slider 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/slider/ - */ - - -var slider = $.widget( "ui.slider", $.ui.mouse, { - version: "1.11.4", - widgetEventPrefix: "slide", - - options: { - animate: false, - distance: 0, - max: 100, - min: 0, - orientation: "horizontal", - range: false, - step: 1, - value: 0, - values: null, - - // callbacks - change: null, - slide: null, - start: null, - stop: null - }, - - // number of pages in a slider - // (how many times can you page up/down to go through the whole range) - numPages: 5, - - _create: function() { - this._keySliding = false; - this._mouseSliding = false; - this._animateOff = true; - this._handleIndex = null; - this._detectOrientation(); - this._mouseInit(); - this._calculateNewMax(); - - this.element - .addClass( "ui-slider" + - " ui-slider-" + this.orientation + - " ui-widget" + - " ui-widget-content" + - " ui-corner-all"); - - this._refresh(); - this._setOption( "disabled", this.options.disabled ); - - this._animateOff = false; - }, - - _refresh: function() { - this._createRange(); - this._createHandles(); - this._setupEvents(); - this._refreshValue(); - }, - - _createHandles: function() { - var i, handleCount, - options = this.options, - existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ), - handle = "<span class='ui-slider-handle ui-state-default ui-corner-all' tabindex='0'></span>", - handles = []; - - handleCount = ( options.values && options.values.length ) || 1; - - if ( existingHandles.length > handleCount ) { - existingHandles.slice( handleCount ).remove(); - existingHandles = existingHandles.slice( 0, handleCount ); - } - - for ( i = existingHandles.length; i < handleCount; i++ ) { - handles.push( handle ); - } - - this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) ); - - this.handle = this.handles.eq( 0 ); - - this.handles.each(function( i ) { - $( this ).data( "ui-slider-handle-index", i ); - }); - }, - - _createRange: function() { - var options = this.options, - classes = ""; - - if ( options.range ) { - if ( options.range === true ) { - if ( !options.values ) { - options.values = [ this._valueMin(), this._valueMin() ]; - } else if ( options.values.length && options.values.length !== 2 ) { - options.values = [ options.values[0], options.values[0] ]; - } else if ( $.isArray( options.values ) ) { - options.values = options.values.slice(0); - } - } - - if ( !this.range || !this.range.length ) { - this.range = $( "<div></div>" ) - .appendTo( this.element ); - - classes = "ui-slider-range" + - // note: this isn't the most fittingly semantic framework class for this element, - // but worked best visually with a variety of themes - " ui-widget-header ui-corner-all"; - } else { - this.range.removeClass( "ui-slider-range-min ui-slider-range-max" ) - // Handle range switching from true to min/max - .css({ - "left": "", - "bottom": "" - }); - } - - this.range.addClass( classes + - ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) ); - } else { - if ( this.range ) { - this.range.remove(); - } - this.range = null; - } - }, - - _setupEvents: function() { - this._off( this.handles ); - this._on( this.handles, this._handleEvents ); - this._hoverable( this.handles ); - this._focusable( this.handles ); - }, - - _destroy: function() { - this.handles.remove(); - if ( this.range ) { - this.range.remove(); - } - - this.element - .removeClass( "ui-slider" + - " ui-slider-horizontal" + - " ui-slider-vertical" + - " ui-widget" + - " ui-widget-content" + - " ui-corner-all" ); - - this._mouseDestroy(); - }, - - _mouseCapture: function( event ) { - var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle, - that = this, - o = this.options; - - if ( o.disabled ) { - return false; - } - - this.elementSize = { - width: this.element.outerWidth(), - height: this.element.outerHeight() - }; - this.elementOffset = this.element.offset(); - - position = { x: event.pageX, y: event.pageY }; - normValue = this._normValueFromMouse( position ); - distance = this._valueMax() - this._valueMin() + 1; - this.handles.each(function( i ) { - var thisDistance = Math.abs( normValue - that.values(i) ); - if (( distance > thisDistance ) || - ( distance === thisDistance && - (i === that._lastChangedValue || that.values(i) === o.min ))) { - distance = thisDistance; - closestHandle = $( this ); - index = i; - } - }); - - allowed = this._start( event, index ); - if ( allowed === false ) { - return false; - } - this._mouseSliding = true; - - this._handleIndex = index; - - closestHandle - .addClass( "ui-state-active" ) - .focus(); - - offset = closestHandle.offset(); - mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" ); - this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : { - left: event.pageX - offset.left - ( closestHandle.width() / 2 ), - top: event.pageY - offset.top - - ( closestHandle.height() / 2 ) - - ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) - - ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) + - ( parseInt( closestHandle.css("marginTop"), 10 ) || 0) - }; - - if ( !this.handles.hasClass( "ui-state-hover" ) ) { - this._slide( event, index, normValue ); - } - this._animateOff = true; - return true; - }, - - _mouseStart: function() { - return true; - }, - - _mouseDrag: function( event ) { - var position = { x: event.pageX, y: event.pageY }, - normValue = this._normValueFromMouse( position ); - - this._slide( event, this._handleIndex, normValue ); - - return false; - }, - - _mouseStop: function( event ) { - this.handles.removeClass( "ui-state-active" ); - this._mouseSliding = false; - - this._stop( event, this._handleIndex ); - this._change( event, this._handleIndex ); - - this._handleIndex = null; - this._clickOffset = null; - this._animateOff = false; - - return false; - }, - - _detectOrientation: function() { - this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal"; - }, - - _normValueFromMouse: function( position ) { - var pixelTotal, - pixelMouse, - percentMouse, - valueTotal, - valueMouse; - - if ( this.orientation === "horizontal" ) { - pixelTotal = this.elementSize.width; - pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 ); - } else { - pixelTotal = this.elementSize.height; - pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 ); - } - - percentMouse = ( pixelMouse / pixelTotal ); - if ( percentMouse > 1 ) { - percentMouse = 1; - } - if ( percentMouse < 0 ) { - percentMouse = 0; - } - if ( this.orientation === "vertical" ) { - percentMouse = 1 - percentMouse; - } - - valueTotal = this._valueMax() - this._valueMin(); - valueMouse = this._valueMin() + percentMouse * valueTotal; - - return this._trimAlignValue( valueMouse ); - }, - - _start: function( event, index ) { - var uiHash = { - handle: this.handles[ index ], - value: this.value() - }; - if ( this.options.values && this.options.values.length ) { - uiHash.value = this.values( index ); - uiHash.values = this.values(); - } - return this._trigger( "start", event, uiHash ); - }, - - _slide: function( event, index, newVal ) { - var otherVal, - newValues, - allowed; - - if ( this.options.values && this.options.values.length ) { - otherVal = this.values( index ? 0 : 1 ); - - if ( ( this.options.values.length === 2 && this.options.range === true ) && - ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) ) - ) { - newVal = otherVal; - } - - if ( newVal !== this.values( index ) ) { - newValues = this.values(); - newValues[ index ] = newVal; - // A slide can be canceled by returning false from the slide callback - allowed = this._trigger( "slide", event, { - handle: this.handles[ index ], - value: newVal, - values: newValues - } ); - otherVal = this.values( index ? 0 : 1 ); - if ( allowed !== false ) { - this.values( index, newVal ); - } - } - } else { - if ( newVal !== this.value() ) { - // A slide can be canceled by returning false from the slide callback - allowed = this._trigger( "slide", event, { - handle: this.handles[ index ], - value: newVal - } ); - if ( allowed !== false ) { - this.value( newVal ); - } - } - } - }, - - _stop: function( event, index ) { - var uiHash = { - handle: this.handles[ index ], - value: this.value() - }; - if ( this.options.values && this.options.values.length ) { - uiHash.value = this.values( index ); - uiHash.values = this.values(); - } - - this._trigger( "stop", event, uiHash ); - }, - - _change: function( event, index ) { - if ( !this._keySliding && !this._mouseSliding ) { - var uiHash = { - handle: this.handles[ index ], - value: this.value() - }; - if ( this.options.values && this.options.values.length ) { - uiHash.value = this.values( index ); - uiHash.values = this.values(); - } - - //store the last changed value index for reference when handles overlap - this._lastChangedValue = index; - - this._trigger( "change", event, uiHash ); - } - }, - - value: function( newValue ) { - if ( arguments.length ) { - this.options.value = this._trimAlignValue( newValue ); - this._refreshValue(); - this._change( null, 0 ); - return; - } - - return this._value(); - }, - - values: function( index, newValue ) { - var vals, - newValues, - i; - - if ( arguments.length > 1 ) { - this.options.values[ index ] = this._trimAlignValue( newValue ); - this._refreshValue(); - this._change( null, index ); - return; - } - - if ( arguments.length ) { - if ( $.isArray( arguments[ 0 ] ) ) { - vals = this.options.values; - newValues = arguments[ 0 ]; - for ( i = 0; i < vals.length; i += 1 ) { - vals[ i ] = this._trimAlignValue( newValues[ i ] ); - this._change( null, i ); - } - this._refreshValue(); - } else { - if ( this.options.values && this.options.values.length ) { - return this._values( index ); - } else { - return this.value(); - } - } - } else { - return this._values(); - } - }, - - _setOption: function( key, value ) { - var i, - valsLength = 0; - - if ( key === "range" && this.options.range === true ) { - if ( value === "min" ) { - this.options.value = this._values( 0 ); - this.options.values = null; - } else if ( value === "max" ) { - this.options.value = this._values( this.options.values.length - 1 ); - this.options.values = null; - } - } - - if ( $.isArray( this.options.values ) ) { - valsLength = this.options.values.length; - } - - if ( key === "disabled" ) { - this.element.toggleClass( "ui-state-disabled", !!value ); - } - - this._super( key, value ); - - switch ( key ) { - case "orientation": - this._detectOrientation(); - this.element - .removeClass( "ui-slider-horizontal ui-slider-vertical" ) - .addClass( "ui-slider-" + this.orientation ); - this._refreshValue(); - - // Reset positioning from previous orientation - this.handles.css( value === "horizontal" ? "bottom" : "left", "" ); - break; - case "value": - this._animateOff = true; - this._refreshValue(); - this._change( null, 0 ); - this._animateOff = false; - break; - case "values": - this._animateOff = true; - this._refreshValue(); - for ( i = 0; i < valsLength; i += 1 ) { - this._change( null, i ); - } - this._animateOff = false; - break; - case "step": - case "min": - case "max": - this._animateOff = true; - this._calculateNewMax(); - this._refreshValue(); - this._animateOff = false; - break; - case "range": - this._animateOff = true; - this._refresh(); - this._animateOff = false; - break; - } - }, - - //internal value getter - // _value() returns value trimmed by min and max, aligned by step - _value: function() { - var val = this.options.value; - val = this._trimAlignValue( val ); - - return val; - }, - - //internal values getter - // _values() returns array of values trimmed by min and max, aligned by step - // _values( index ) returns single value trimmed by min and max, aligned by step - _values: function( index ) { - var val, - vals, - i; - - if ( arguments.length ) { - val = this.options.values[ index ]; - val = this._trimAlignValue( val ); - - return val; - } else if ( this.options.values && this.options.values.length ) { - // .slice() creates a copy of the array - // this copy gets trimmed by min and max and then returned - vals = this.options.values.slice(); - for ( i = 0; i < vals.length; i += 1) { - vals[ i ] = this._trimAlignValue( vals[ i ] ); - } - - return vals; - } else { - return []; - } - }, - - // returns the step-aligned value that val is closest to, between (inclusive) min and max - _trimAlignValue: function( val ) { - if ( val <= this._valueMin() ) { - return this._valueMin(); - } - if ( val >= this._valueMax() ) { - return this._valueMax(); - } - var step = ( this.options.step > 0 ) ? this.options.step : 1, - valModStep = (val - this._valueMin()) % step, - alignValue = val - valModStep; - - if ( Math.abs(valModStep) * 2 >= step ) { - alignValue += ( valModStep > 0 ) ? step : ( -step ); - } - - // Since JavaScript has problems with large floats, round - // the final value to 5 digits after the decimal point (see #4124) - return parseFloat( alignValue.toFixed(5) ); - }, - - _calculateNewMax: function() { - var max = this.options.max, - min = this._valueMin(), - step = this.options.step, - aboveMin = Math.floor( ( +( max - min ).toFixed( this._precision() ) ) / step ) * step; - max = aboveMin + min; - this.max = parseFloat( max.toFixed( this._precision() ) ); - }, - - _precision: function() { - var precision = this._precisionOf( this.options.step ); - if ( this.options.min !== null ) { - precision = Math.max( precision, this._precisionOf( this.options.min ) ); - } - return precision; - }, - - _precisionOf: function( num ) { - var str = num.toString(), - decimal = str.indexOf( "." ); - return decimal === -1 ? 0 : str.length - decimal - 1; - }, - - _valueMin: function() { - return this.options.min; - }, - - _valueMax: function() { - return this.max; - }, - - _refreshValue: function() { - var lastValPercent, valPercent, value, valueMin, valueMax, - oRange = this.options.range, - o = this.options, - that = this, - animate = ( !this._animateOff ) ? o.animate : false, - _set = {}; - - if ( this.options.values && this.options.values.length ) { - this.handles.each(function( i ) { - valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100; - _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%"; - $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate ); - if ( that.options.range === true ) { - if ( that.orientation === "horizontal" ) { - if ( i === 0 ) { - that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate ); - } - if ( i === 1 ) { - that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } ); - } - } else { - if ( i === 0 ) { - that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate ); - } - if ( i === 1 ) { - that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } ); - } - } - } - lastValPercent = valPercent; - }); - } else { - value = this.value(); - valueMin = this._valueMin(); - valueMax = this._valueMax(); - valPercent = ( valueMax !== valueMin ) ? - ( value - valueMin ) / ( valueMax - valueMin ) * 100 : - 0; - _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%"; - this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate ); - - if ( oRange === "min" && this.orientation === "horizontal" ) { - this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate ); - } - if ( oRange === "max" && this.orientation === "horizontal" ) { - this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } ); - } - if ( oRange === "min" && this.orientation === "vertical" ) { - this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate ); - } - if ( oRange === "max" && this.orientation === "vertical" ) { - this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } ); - } - } - }, - - _handleEvents: { - keydown: function( event ) { - var allowed, curVal, newVal, step, - index = $( event.target ).data( "ui-slider-handle-index" ); - - switch ( event.keyCode ) { - case $.ui.keyCode.HOME: - case $.ui.keyCode.END: - case $.ui.keyCode.PAGE_UP: - case $.ui.keyCode.PAGE_DOWN: - case $.ui.keyCode.UP: - case $.ui.keyCode.RIGHT: - case $.ui.keyCode.DOWN: - case $.ui.keyCode.LEFT: - event.preventDefault(); - if ( !this._keySliding ) { - this._keySliding = true; - $( event.target ).addClass( "ui-state-active" ); - allowed = this._start( event, index ); - if ( allowed === false ) { - return; - } - } - break; - } - - step = this.options.step; - if ( this.options.values && this.options.values.length ) { - curVal = newVal = this.values( index ); - } else { - curVal = newVal = this.value(); - } - - switch ( event.keyCode ) { - case $.ui.keyCode.HOME: - newVal = this._valueMin(); - break; - case $.ui.keyCode.END: - newVal = this._valueMax(); - break; - case $.ui.keyCode.PAGE_UP: - newVal = this._trimAlignValue( - curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages ) - ); - break; - case $.ui.keyCode.PAGE_DOWN: - newVal = this._trimAlignValue( - curVal - ( (this._valueMax() - this._valueMin()) / this.numPages ) ); - break; - case $.ui.keyCode.UP: - case $.ui.keyCode.RIGHT: - if ( curVal === this._valueMax() ) { - return; - } - newVal = this._trimAlignValue( curVal + step ); - break; - case $.ui.keyCode.DOWN: - case $.ui.keyCode.LEFT: - if ( curVal === this._valueMin() ) { - return; - } - newVal = this._trimAlignValue( curVal - step ); - break; - } - - this._slide( event, index, newVal ); - }, - keyup: function( event ) { - var index = $( event.target ).data( "ui-slider-handle-index" ); - - if ( this._keySliding ) { - this._keySliding = false; - this._stop( event, index ); - this._change( event, index ); - $( event.target ).removeClass( "ui-state-active" ); - } - } - } -}); - - -/*! - * jQuery UI Sortable 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/sortable/ - */ - - -var sortable = $.widget("ui.sortable", $.ui.mouse, { - version: "1.11.4", - widgetEventPrefix: "sort", - ready: false, - options: { - appendTo: "parent", - axis: false, - connectWith: false, - containment: false, - cursor: "auto", - cursorAt: false, - dropOnEmpty: true, - forcePlaceholderSize: false, - forceHelperSize: false, - grid: false, - handle: false, - helper: "original", - items: "> *", - opacity: false, - placeholder: false, - revert: false, - scroll: true, - scrollSensitivity: 20, - scrollSpeed: 20, - scope: "default", - tolerance: "intersect", - zIndex: 1000, - - // callbacks - activate: null, - beforeStop: null, - change: null, - deactivate: null, - out: null, - over: null, - receive: null, - remove: null, - sort: null, - start: null, - stop: null, - update: null - }, - - _isOverAxis: function( x, reference, size ) { - return ( x >= reference ) && ( x < ( reference + size ) ); - }, - - _isFloating: function( item ) { - return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display")); - }, - - _create: function() { - this.containerCache = {}; - this.element.addClass("ui-sortable"); - - //Get the items - this.refresh(); - - //Let's determine the parent's offset - this.offset = this.element.offset(); - - //Initialize mouse events for interaction - this._mouseInit(); - - this._setHandleClassName(); - - //We're ready to go - this.ready = true; - - }, - - _setOption: function( key, value ) { - this._super( key, value ); - - if ( key === "handle" ) { - this._setHandleClassName(); - } - }, - - _setHandleClassName: function() { - this.element.find( ".ui-sortable-handle" ).removeClass( "ui-sortable-handle" ); - $.each( this.items, function() { - ( this.instance.options.handle ? - this.item.find( this.instance.options.handle ) : this.item ) - .addClass( "ui-sortable-handle" ); - }); - }, - - _destroy: function() { - this.element - .removeClass( "ui-sortable ui-sortable-disabled" ) - .find( ".ui-sortable-handle" ) - .removeClass( "ui-sortable-handle" ); - this._mouseDestroy(); - - for ( var i = this.items.length - 1; i >= 0; i-- ) { - this.items[i].item.removeData(this.widgetName + "-item"); - } - - return this; - }, - - _mouseCapture: function(event, overrideHandle) { - var currentItem = null, - validHandle = false, - that = this; - - if (this.reverting) { - return false; - } - - if(this.options.disabled || this.options.type === "static") { - return false; - } - - //We have to refresh the items data once first - this._refreshItems(event); - - //Find out if the clicked node (or one of its parents) is a actual item in this.items - $(event.target).parents().each(function() { - if($.data(this, that.widgetName + "-item") === that) { - currentItem = $(this); - return false; - } - }); - if($.data(event.target, that.widgetName + "-item") === that) { - currentItem = $(event.target); - } - - if(!currentItem) { - return false; - } - if(this.options.handle && !overrideHandle) { - $(this.options.handle, currentItem).find("*").addBack().each(function() { - if(this === event.target) { - validHandle = true; - } - }); - if(!validHandle) { - return false; - } - } - - this.currentItem = currentItem; - this._removeCurrentsFromItems(); - return true; - - }, - - _mouseStart: function(event, overrideHandle, noActivation) { - - var i, body, - o = this.options; - - this.currentContainer = this; - - //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture - this.refreshPositions(); - - //Create and append the visible helper - this.helper = this._createHelper(event); - - //Cache the helper size - this._cacheHelperProportions(); - - /* - * - Position generation - - * This block generates everything position related - it's the core of draggables. - */ - - //Cache the margins of the original element - this._cacheMargins(); - - //Get the next scrolling parent - this.scrollParent = this.helper.scrollParent(); - - //The element's absolute position on the page minus margins - this.offset = this.currentItem.offset(); - this.offset = { - top: this.offset.top - this.margins.top, - left: this.offset.left - this.margins.left - }; - - $.extend(this.offset, { - click: { //Where the click happened, relative to the element - left: event.pageX - this.offset.left, - top: event.pageY - this.offset.top - }, - parent: this._getParentOffset(), - relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper - }); - - // Only after we got the offset, we can change the helper's position to absolute - // TODO: Still need to figure out a way to make relative sorting possible - this.helper.css("position", "absolute"); - this.cssPosition = this.helper.css("position"); - - //Generate the original position - this.originalPosition = this._generatePosition(event); - this.originalPageX = event.pageX; - this.originalPageY = event.pageY; - - //Adjust the mouse offset relative to the helper if "cursorAt" is supplied - (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt)); - - //Cache the former DOM position - this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] }; - - //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way - if(this.helper[0] !== this.currentItem[0]) { - this.currentItem.hide(); - } - - //Create the placeholder - this._createPlaceholder(); - - //Set a containment if given in the options - if(o.containment) { - this._setContainment(); - } - - if( o.cursor && o.cursor !== "auto" ) { // cursor option - body = this.document.find( "body" ); - - // support: IE - this.storedCursor = body.css( "cursor" ); - body.css( "cursor", o.cursor ); - - this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body ); - } - - if(o.opacity) { // opacity option - if (this.helper.css("opacity")) { - this._storedOpacity = this.helper.css("opacity"); - } - this.helper.css("opacity", o.opacity); - } - - if(o.zIndex) { // zIndex option - if (this.helper.css("zIndex")) { - this._storedZIndex = this.helper.css("zIndex"); - } - this.helper.css("zIndex", o.zIndex); - } - - //Prepare scrolling - if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") { - this.overflowOffset = this.scrollParent.offset(); - } - - //Call callbacks - this._trigger("start", event, this._uiHash()); - - //Recache the helper size - if(!this._preserveHelperProportions) { - this._cacheHelperProportions(); - } - - - //Post "activate" events to possible containers - if( !noActivation ) { - for ( i = this.containers.length - 1; i >= 0; i-- ) { - this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) ); - } - } - - //Prepare possible droppables - if($.ui.ddmanager) { - $.ui.ddmanager.current = this; - } - - if ($.ui.ddmanager && !o.dropBehaviour) { - $.ui.ddmanager.prepareOffsets(this, event); - } - - this.dragging = true; - - this.helper.addClass("ui-sortable-helper"); - this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position - return true; - - }, - - _mouseDrag: function(event) { - var i, item, itemElement, intersection, - o = this.options, - scrolled = false; - - //Compute the helpers position - this.position = this._generatePosition(event); - this.positionAbs = this._convertPositionTo("absolute"); - - if (!this.lastPositionAbs) { - this.lastPositionAbs = this.positionAbs; - } - - //Do scrolling - if(this.options.scroll) { - if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") { - - if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) { - this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed; - } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) { - this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed; - } - - if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) { - this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed; - } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) { - this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed; - } - - } else { - - if(event.pageY - this.document.scrollTop() < o.scrollSensitivity) { - scrolled = this.document.scrollTop(this.document.scrollTop() - o.scrollSpeed); - } else if(this.window.height() - (event.pageY - this.document.scrollTop()) < o.scrollSensitivity) { - scrolled = this.document.scrollTop(this.document.scrollTop() + o.scrollSpeed); - } - - if(event.pageX - this.document.scrollLeft() < o.scrollSensitivity) { - scrolled = this.document.scrollLeft(this.document.scrollLeft() - o.scrollSpeed); - } else if(this.window.width() - (event.pageX - this.document.scrollLeft()) < o.scrollSensitivity) { - scrolled = this.document.scrollLeft(this.document.scrollLeft() + o.scrollSpeed); - } - - } - - if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) { - $.ui.ddmanager.prepareOffsets(this, event); - } - } - - //Regenerate the absolute position used for position checks - this.positionAbs = this._convertPositionTo("absolute"); - - //Set the helper position - if(!this.options.axis || this.options.axis !== "y") { - this.helper[0].style.left = this.position.left+"px"; - } - if(!this.options.axis || this.options.axis !== "x") { - this.helper[0].style.top = this.position.top+"px"; - } - - //Rearrange - for (i = this.items.length - 1; i >= 0; i--) { - - //Cache variables and intersection, continue if no intersection - item = this.items[i]; - itemElement = item.item[0]; - intersection = this._intersectsWithPointer(item); - if (!intersection) { - continue; - } - - // Only put the placeholder inside the current Container, skip all - // items from other containers. This works because when moving - // an item from one container to another the - // currentContainer is switched before the placeholder is moved. - // - // Without this, moving items in "sub-sortables" can cause - // the placeholder to jitter between the outer and inner container. - if (item.instance !== this.currentContainer) { - continue; - } - - // cannot intersect with itself - // no useless actions that have been done before - // no action if the item moved is the parent of the item checked - if (itemElement !== this.currentItem[0] && - this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement && - !$.contains(this.placeholder[0], itemElement) && - (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true) - ) { - - this.direction = intersection === 1 ? "down" : "up"; - - if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) { - this._rearrange(event, item); - } else { - break; - } - - this._trigger("change", event, this._uiHash()); - break; - } - } - - //Post events to containers - this._contactContainers(event); - - //Interconnect with droppables - if($.ui.ddmanager) { - $.ui.ddmanager.drag(this, event); - } - - //Call callbacks - this._trigger("sort", event, this._uiHash()); - - this.lastPositionAbs = this.positionAbs; - return false; - - }, - - _mouseStop: function(event, noPropagation) { - - if(!event) { - return; - } - - //If we are using droppables, inform the manager about the drop - if ($.ui.ddmanager && !this.options.dropBehaviour) { - $.ui.ddmanager.drop(this, event); - } - - if(this.options.revert) { - var that = this, - cur = this.placeholder.offset(), - axis = this.options.axis, - animation = {}; - - if ( !axis || axis === "x" ) { - animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollLeft); - } - if ( !axis || axis === "y" ) { - animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollTop); - } - this.reverting = true; - $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() { - that._clear(event); - }); - } else { - this._clear(event, noPropagation); - } - - return false; - - }, - - cancel: function() { - - if(this.dragging) { - - this._mouseUp({ target: null }); - - if(this.options.helper === "original") { - this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"); - } else { - this.currentItem.show(); - } - - //Post deactivating events to containers - for (var i = this.containers.length - 1; i >= 0; i--){ - this.containers[i]._trigger("deactivate", null, this._uiHash(this)); - if(this.containers[i].containerCache.over) { - this.containers[i]._trigger("out", null, this._uiHash(this)); - this.containers[i].containerCache.over = 0; - } - } - - } - - if (this.placeholder) { - //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! - if(this.placeholder[0].parentNode) { - this.placeholder[0].parentNode.removeChild(this.placeholder[0]); - } - if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) { - this.helper.remove(); - } - - $.extend(this, { - helper: null, - dragging: false, - reverting: false, - _noFinalSort: null - }); - - if(this.domPosition.prev) { - $(this.domPosition.prev).after(this.currentItem); - } else { - $(this.domPosition.parent).prepend(this.currentItem); - } - } - - return this; - - }, - - serialize: function(o) { - - var items = this._getItemsAsjQuery(o && o.connected), - str = []; - o = o || {}; - - $(items).each(function() { - var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/)); - if (res) { - str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2])); - } - }); - - if(!str.length && o.key) { - str.push(o.key + "="); - } - - return str.join("&"); - - }, - - toArray: function(o) { - - var items = this._getItemsAsjQuery(o && o.connected), - ret = []; - - o = o || {}; - - items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); }); - return ret; - - }, - - /* Be careful with the following core functions */ - _intersectsWith: function(item) { - - var x1 = this.positionAbs.left, - x2 = x1 + this.helperProportions.width, - y1 = this.positionAbs.top, - y2 = y1 + this.helperProportions.height, - l = item.left, - r = l + item.width, - t = item.top, - b = t + item.height, - dyClick = this.offset.click.top, - dxClick = this.offset.click.left, - isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ), - isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ), - isOverElement = isOverElementHeight && isOverElementWidth; - - if ( this.options.tolerance === "pointer" || - this.options.forcePointerForContainers || - (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"]) - ) { - return isOverElement; - } else { - - return (l < x1 + (this.helperProportions.width / 2) && // Right Half - x2 - (this.helperProportions.width / 2) < r && // Left Half - t < y1 + (this.helperProportions.height / 2) && // Bottom Half - y2 - (this.helperProportions.height / 2) < b ); // Top Half - - } - }, - - _intersectsWithPointer: function(item) { - - var isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height), - isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width), - isOverElement = isOverElementHeight && isOverElementWidth, - verticalDirection = this._getDragVerticalDirection(), - horizontalDirection = this._getDragHorizontalDirection(); - - if (!isOverElement) { - return false; - } - - return this.floating ? - ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 ) - : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) ); - - }, - - _intersectsWithSides: function(item) { - - var isOverBottomHalf = this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height), - isOverRightHalf = this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width), - verticalDirection = this._getDragVerticalDirection(), - horizontalDirection = this._getDragHorizontalDirection(); - - if (this.floating && horizontalDirection) { - return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf)); - } else { - return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf)); - } - - }, - - _getDragVerticalDirection: function() { - var delta = this.positionAbs.top - this.lastPositionAbs.top; - return delta !== 0 && (delta > 0 ? "down" : "up"); - }, - - _getDragHorizontalDirection: function() { - var delta = this.positionAbs.left - this.lastPositionAbs.left; - return delta !== 0 && (delta > 0 ? "right" : "left"); - }, - - refresh: function(event) { - this._refreshItems(event); - this._setHandleClassName(); - this.refreshPositions(); - return this; - }, - - _connectWith: function() { - var options = this.options; - return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith; - }, - - _getItemsAsjQuery: function(connected) { - - var i, j, cur, inst, - items = [], - queries = [], - connectWith = this._connectWith(); - - if(connectWith && connected) { - for (i = connectWith.length - 1; i >= 0; i--){ - cur = $(connectWith[i], this.document[0]); - for ( j = cur.length - 1; j >= 0; j--){ - inst = $.data(cur[j], this.widgetFullName); - if(inst && inst !== this && !inst.options.disabled) { - queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), inst]); - } - } - } - } - - queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]); - - function addItems() { - items.push( this ); - } - for (i = queries.length - 1; i >= 0; i--){ - queries[i][0].each( addItems ); - } - - return $(items); - - }, - - _removeCurrentsFromItems: function() { - - var list = this.currentItem.find(":data(" + this.widgetName + "-item)"); - - this.items = $.grep(this.items, function (item) { - for (var j=0; j < list.length; j++) { - if(list[j] === item.item[0]) { - return false; - } - } - return true; - }); - - }, - - _refreshItems: function(event) { - - this.items = []; - this.containers = [this]; - - var i, j, cur, inst, targetData, _queries, item, queriesLength, - items = this.items, - queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]], - connectWith = this._connectWith(); - - if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down - for (i = connectWith.length - 1; i >= 0; i--){ - cur = $(connectWith[i], this.document[0]); - for (j = cur.length - 1; j >= 0; j--){ - inst = $.data(cur[j], this.widgetFullName); - if(inst && inst !== this && !inst.options.disabled) { - queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]); - this.containers.push(inst); - } - } - } - } - - for (i = queries.length - 1; i >= 0; i--) { - targetData = queries[i][1]; - _queries = queries[i][0]; - - for (j=0, queriesLength = _queries.length; j < queriesLength; j++) { - item = $(_queries[j]); - - item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager) - - items.push({ - item: item, - instance: targetData, - width: 0, height: 0, - left: 0, top: 0 - }); - } - } - - }, - - refreshPositions: function(fast) { - - // Determine whether items are being displayed horizontally - this.floating = this.items.length ? - this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) : - false; - - //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change - if(this.offsetParent && this.helper) { - this.offset.parent = this._getParentOffset(); - } - - var i, item, t, p; - - for (i = this.items.length - 1; i >= 0; i--){ - item = this.items[i]; - - //We ignore calculating positions of all connected containers when we're not over them - if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) { - continue; - } - - t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item; - - if (!fast) { - item.width = t.outerWidth(); - item.height = t.outerHeight(); - } - - p = t.offset(); - item.left = p.left; - item.top = p.top; - } - - if(this.options.custom && this.options.custom.refreshContainers) { - this.options.custom.refreshContainers.call(this); - } else { - for (i = this.containers.length - 1; i >= 0; i--){ - p = this.containers[i].element.offset(); - this.containers[i].containerCache.left = p.left; - this.containers[i].containerCache.top = p.top; - this.containers[i].containerCache.width = this.containers[i].element.outerWidth(); - this.containers[i].containerCache.height = this.containers[i].element.outerHeight(); - } - } - - return this; - }, - - _createPlaceholder: function(that) { - that = that || this; - var className, - o = that.options; - - if(!o.placeholder || o.placeholder.constructor === String) { - className = o.placeholder; - o.placeholder = { - element: function() { - - var nodeName = that.currentItem[0].nodeName.toLowerCase(), - element = $( "<" + nodeName + ">", that.document[0] ) - .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder") - .removeClass("ui-sortable-helper"); - - if ( nodeName === "tbody" ) { - that._createTrPlaceholder( - that.currentItem.find( "tr" ).eq( 0 ), - $( "<tr>", that.document[ 0 ] ).appendTo( element ) - ); - } else if ( nodeName === "tr" ) { - that._createTrPlaceholder( that.currentItem, element ); - } else if ( nodeName === "img" ) { - element.attr( "src", that.currentItem.attr( "src" ) ); - } - - if ( !className ) { - element.css( "visibility", "hidden" ); - } - - return element; - }, - update: function(container, p) { - - // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that - // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified - if(className && !o.forcePlaceholderSize) { - return; - } - - //If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item - if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); } - if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); } - } - }; - } - - //Create the placeholder - that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem)); - - //Append it after the actual current item - that.currentItem.after(that.placeholder); - - //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317) - o.placeholder.update(that, that.placeholder); - - }, - - _createTrPlaceholder: function( sourceTr, targetTr ) { - var that = this; - - sourceTr.children().each(function() { - $( "<td> </td>", that.document[ 0 ] ) - .attr( "colspan", $( this ).attr( "colspan" ) || 1 ) - .appendTo( targetTr ); - }); - }, - - _contactContainers: function(event) { - var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis, - innermostContainer = null, - innermostIndex = null; - - // get innermost container that intersects with item - for (i = this.containers.length - 1; i >= 0; i--) { - - // never consider a container that's located within the item itself - if($.contains(this.currentItem[0], this.containers[i].element[0])) { - continue; - } - - if(this._intersectsWith(this.containers[i].containerCache)) { - - // if we've already found a container and it's more "inner" than this, then continue - if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) { - continue; - } - - innermostContainer = this.containers[i]; - innermostIndex = i; - - } else { - // container doesn't intersect. trigger "out" event if necessary - if(this.containers[i].containerCache.over) { - this.containers[i]._trigger("out", event, this._uiHash(this)); - this.containers[i].containerCache.over = 0; - } - } - - } - - // if no intersecting containers found, return - if(!innermostContainer) { - return; - } - - // move the item into the container if it's not there already - if(this.containers.length === 1) { - if (!this.containers[innermostIndex].containerCache.over) { - this.containers[innermostIndex]._trigger("over", event, this._uiHash(this)); - this.containers[innermostIndex].containerCache.over = 1; - } - } else { - - //When entering a new container, we will find the item with the least distance and append our item near it - dist = 10000; - itemWithLeastDistance = null; - floating = innermostContainer.floating || this._isFloating(this.currentItem); - posProperty = floating ? "left" : "top"; - sizeProperty = floating ? "width" : "height"; - axis = floating ? "clientX" : "clientY"; - - for (j = this.items.length - 1; j >= 0; j--) { - if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) { - continue; - } - if(this.items[j].item[0] === this.currentItem[0]) { - continue; - } - - cur = this.items[j].item.offset()[posProperty]; - nearBottom = false; - if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) { - nearBottom = true; - } - - if ( Math.abs( event[ axis ] - cur ) < dist ) { - dist = Math.abs( event[ axis ] - cur ); - itemWithLeastDistance = this.items[ j ]; - this.direction = nearBottom ? "up": "down"; - } - } - - //Check if dropOnEmpty is enabled - if(!itemWithLeastDistance && !this.options.dropOnEmpty) { - return; - } - - if(this.currentContainer === this.containers[innermostIndex]) { - if ( !this.currentContainer.containerCache.over ) { - this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() ); - this.currentContainer.containerCache.over = 1; - } - return; - } - - itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true); - this._trigger("change", event, this._uiHash()); - this.containers[innermostIndex]._trigger("change", event, this._uiHash(this)); - this.currentContainer = this.containers[innermostIndex]; - - //Update the placeholder - this.options.placeholder.update(this.currentContainer, this.placeholder); - - this.containers[innermostIndex]._trigger("over", event, this._uiHash(this)); - this.containers[innermostIndex].containerCache.over = 1; - } - - - }, - - _createHelper: function(event) { - - var o = this.options, - helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem); - - //Add the helper to the DOM if that didn't happen already - if(!helper.parents("body").length) { - $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]); - } - - if(helper[0] === this.currentItem[0]) { - this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") }; - } - - if(!helper[0].style.width || o.forceHelperSize) { - helper.width(this.currentItem.width()); - } - if(!helper[0].style.height || o.forceHelperSize) { - helper.height(this.currentItem.height()); - } - - return helper; - - }, - - _adjustOffsetFromHelper: function(obj) { - if (typeof obj === "string") { - obj = obj.split(" "); - } - if ($.isArray(obj)) { - obj = {left: +obj[0], top: +obj[1] || 0}; - } - if ("left" in obj) { - this.offset.click.left = obj.left + this.margins.left; - } - if ("right" in obj) { - this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; - } - if ("top" in obj) { - this.offset.click.top = obj.top + this.margins.top; - } - if ("bottom" in obj) { - this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; - } - }, - - _getParentOffset: function() { - - - //Get the offsetParent and cache its position - this.offsetParent = this.helper.offsetParent(); - var po = this.offsetParent.offset(); - - // This is a special case where we need to modify a offset calculated on start, since the following happened: - // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent - // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that - // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag - if(this.cssPosition === "absolute" && this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) { - po.left += this.scrollParent.scrollLeft(); - po.top += this.scrollParent.scrollTop(); - } - - // This needs to be actually done for all browsers, since pageX/pageY includes this information - // with an ugly IE fix - if( this.offsetParent[0] === this.document[0].body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) { - po = { top: 0, left: 0 }; - } - - return { - top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), - left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) - }; - - }, - - _getRelativeOffset: function() { - - if(this.cssPosition === "relative") { - var p = this.currentItem.position(); - return { - top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(), - left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft() - }; - } else { - return { top: 0, left: 0 }; - } - - }, - - _cacheMargins: function() { - this.margins = { - left: (parseInt(this.currentItem.css("marginLeft"),10) || 0), - top: (parseInt(this.currentItem.css("marginTop"),10) || 0) - }; - }, - - _cacheHelperProportions: function() { - this.helperProportions = { - width: this.helper.outerWidth(), - height: this.helper.outerHeight() - }; - }, - - _setContainment: function() { - - var ce, co, over, - o = this.options; - if(o.containment === "parent") { - o.containment = this.helper[0].parentNode; - } - if(o.containment === "document" || o.containment === "window") { - this.containment = [ - 0 - this.offset.relative.left - this.offset.parent.left, - 0 - this.offset.relative.top - this.offset.parent.top, - o.containment === "document" ? this.document.width() : this.window.width() - this.helperProportions.width - this.margins.left, - (o.containment === "document" ? this.document.width() : this.window.height() || this.document[0].body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top - ]; - } - - if(!(/^(document|window|parent)$/).test(o.containment)) { - ce = $(o.containment)[0]; - co = $(o.containment).offset(); - over = ($(ce).css("overflow") !== "hidden"); - - this.containment = [ - co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left, - co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top, - co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left, - co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - ]; - } - - }, - - _convertPositionTo: function(d, pos) { - - if(!pos) { - pos = this.position; - } - var mod = d === "absolute" ? 1 : -1, - scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, - scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); - - return { - top: ( - pos.top + // The absolute mouse position - this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border) - ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod) - ), - left: ( - pos.left + // The absolute mouse position - this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border) - ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod) - ) - }; - - }, - - _generatePosition: function(event) { - - var top, left, - o = this.options, - pageX = event.pageX, - pageY = event.pageY, - scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); - - // This is another very weird special case that only happens for relative elements: - // 1. If the css position is relative - // 2. and the scroll parent is the document or similar to the offset parent - // we have to refresh the relative offset during the scroll so there are no jumps - if(this.cssPosition === "relative" && !(this.scrollParent[0] !== this.document[0] && this.scrollParent[0] !== this.offsetParent[0])) { - this.offset.relative = this._getRelativeOffset(); - } - - /* - * - Position constraining - - * Constrain the position to a mix of grid, containment. - */ - - if(this.originalPosition) { //If we are not dragging yet, we won't check for options - - if(this.containment) { - if(event.pageX - this.offset.click.left < this.containment[0]) { - pageX = this.containment[0] + this.offset.click.left; - } - if(event.pageY - this.offset.click.top < this.containment[1]) { - pageY = this.containment[1] + this.offset.click.top; - } - if(event.pageX - this.offset.click.left > this.containment[2]) { - pageX = this.containment[2] + this.offset.click.left; - } - if(event.pageY - this.offset.click.top > this.containment[3]) { - pageY = this.containment[3] + this.offset.click.top; - } - } - - if(o.grid) { - top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1]; - pageY = this.containment ? ( (top - this.offset.click.top >= this.containment[1] && top - this.offset.click.top <= this.containment[3]) ? top : ((top - this.offset.click.top >= this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; - - left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0]; - pageX = this.containment ? ( (left - this.offset.click.left >= this.containment[0] && left - this.offset.click.left <= this.containment[2]) ? left : ((left - this.offset.click.left >= this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; - } - - } - - return { - top: ( - pageY - // The absolute mouse position - this.offset.click.top - // Click offset (relative to the element) - this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.top + // The offsetParent's offset without borders (offset + border) - ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) )) - ), - left: ( - pageX - // The absolute mouse position - this.offset.click.left - // Click offset (relative to the element) - this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.left + // The offsetParent's offset without borders (offset + border) - ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() )) - ) - }; - - }, - - _rearrange: function(event, i, a, hardRefresh) { - - a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction === "down" ? i.item[0] : i.item[0].nextSibling)); - - //Various things done here to improve the performance: - // 1. we create a setTimeout, that calls refreshPositions - // 2. on the instance, we have a counter variable, that get's higher after every append - // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same - // 4. this lets only the last addition to the timeout stack through - this.counter = this.counter ? ++this.counter : 1; - var counter = this.counter; - - this._delay(function() { - if(counter === this.counter) { - this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove - } - }); - - }, - - _clear: function(event, noPropagation) { - - this.reverting = false; - // We delay all events that have to be triggered to after the point where the placeholder has been removed and - // everything else normalized again - var i, - delayedTriggers = []; - - // We first have to update the dom position of the actual currentItem - // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088) - if(!this._noFinalSort && this.currentItem.parent().length) { - this.placeholder.before(this.currentItem); - } - this._noFinalSort = null; - - if(this.helper[0] === this.currentItem[0]) { - for(i in this._storedCSS) { - if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") { - this._storedCSS[i] = ""; - } - } - this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"); - } else { - this.currentItem.show(); - } - - if(this.fromOutside && !noPropagation) { - delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); }); - } - if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) { - delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed - } - - // Check if the items Container has Changed and trigger appropriate - // events. - if (this !== this.currentContainer) { - if(!noPropagation) { - delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); }); - delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer)); - delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer)); - } - } - - - //Post events to containers - function delayEvent( type, instance, container ) { - return function( event ) { - container._trigger( type, event, instance._uiHash( instance ) ); - }; - } - for (i = this.containers.length - 1; i >= 0; i--){ - if (!noPropagation) { - delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) ); - } - if(this.containers[i].containerCache.over) { - delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) ); - this.containers[i].containerCache.over = 0; - } - } - - //Do what was originally in plugins - if ( this.storedCursor ) { - this.document.find( "body" ).css( "cursor", this.storedCursor ); - this.storedStylesheet.remove(); - } - if(this._storedOpacity) { - this.helper.css("opacity", this._storedOpacity); - } - if(this._storedZIndex) { - this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex); - } - - this.dragging = false; - - if(!noPropagation) { - this._trigger("beforeStop", event, this._uiHash()); - } - - //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! - this.placeholder[0].parentNode.removeChild(this.placeholder[0]); - - if ( !this.cancelHelperRemoval ) { - if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) { - this.helper.remove(); - } - this.helper = null; - } - - if(!noPropagation) { - for (i=0; i < delayedTriggers.length; i++) { - delayedTriggers[i].call(this, event); - } //Trigger all delayed events - this._trigger("stop", event, this._uiHash()); - } - - this.fromOutside = false; - return !this.cancelHelperRemoval; - - }, - - _trigger: function() { - if ($.Widget.prototype._trigger.apply(this, arguments) === false) { - this.cancel(); - } - }, - - _uiHash: function(_inst) { - var inst = _inst || this; - return { - helper: inst.helper, - placeholder: inst.placeholder || $([]), - position: inst.position, - originalPosition: inst.originalPosition, - offset: inst.positionAbs, - item: inst.currentItem, - sender: _inst ? _inst.element : null - }; - } - -}); - - -/*! - * jQuery UI Spinner 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/spinner/ - */ - - -function spinner_modifier( fn ) { - return function() { - var previous = this.element.val(); - fn.apply( this, arguments ); - this._refresh(); - if ( previous !== this.element.val() ) { - this._trigger( "change" ); - } - }; -} - -var spinner = $.widget( "ui.spinner", { - version: "1.11.4", - defaultElement: "<input>", - widgetEventPrefix: "spin", - options: { - culture: null, - icons: { - down: "ui-icon-triangle-1-s", - up: "ui-icon-triangle-1-n" - }, - incremental: true, - max: null, - min: null, - numberFormat: null, - page: 10, - step: 1, - - change: null, - spin: null, - start: null, - stop: null - }, - - _create: function() { - // handle string values that need to be parsed - this._setOption( "max", this.options.max ); - this._setOption( "min", this.options.min ); - this._setOption( "step", this.options.step ); - - // Only format if there is a value, prevents the field from being marked - // as invalid in Firefox, see #9573. - if ( this.value() !== "" ) { - // Format the value, but don't constrain. - this._value( this.element.val(), true ); - } - - this._draw(); - this._on( this._events ); - this._refresh(); - - // turning off autocomplete prevents the browser from remembering the - // value when navigating through history, so we re-enable autocomplete - // if the page is unloaded before the widget is destroyed. #7790 - this._on( this.window, { - beforeunload: function() { - this.element.removeAttr( "autocomplete" ); - } - }); - }, - - _getCreateOptions: function() { - var options = {}, - element = this.element; - - $.each( [ "min", "max", "step" ], function( i, option ) { - var value = element.attr( option ); - if ( value !== undefined && value.length ) { - options[ option ] = value; - } - }); - - return options; - }, - - _events: { - keydown: function( event ) { - if ( this._start( event ) && this._keydown( event ) ) { - event.preventDefault(); - } - }, - keyup: "_stop", - focus: function() { - this.previous = this.element.val(); - }, - blur: function( event ) { - if ( this.cancelBlur ) { - delete this.cancelBlur; - return; - } - - this._stop(); - this._refresh(); - if ( this.previous !== this.element.val() ) { - this._trigger( "change", event ); - } - }, - mousewheel: function( event, delta ) { - if ( !delta ) { - return; - } - if ( !this.spinning && !this._start( event ) ) { - return false; - } - - this._spin( (delta > 0 ? 1 : -1) * this.options.step, event ); - clearTimeout( this.mousewheelTimer ); - this.mousewheelTimer = this._delay(function() { - if ( this.spinning ) { - this._stop( event ); - } - }, 100 ); - event.preventDefault(); - }, - "mousedown .ui-spinner-button": function( event ) { - var previous; - - // We never want the buttons to have focus; whenever the user is - // interacting with the spinner, the focus should be on the input. - // If the input is focused then this.previous is properly set from - // when the input first received focus. If the input is not focused - // then we need to set this.previous based on the value before spinning. - previous = this.element[0] === this.document[0].activeElement ? - this.previous : this.element.val(); - function checkFocus() { - var isActive = this.element[0] === this.document[0].activeElement; - if ( !isActive ) { - this.element.focus(); - this.previous = previous; - // support: IE - // IE sets focus asynchronously, so we need to check if focus - // moved off of the input because the user clicked on the button. - this._delay(function() { - this.previous = previous; - }); - } - } - - // ensure focus is on (or stays on) the text field - event.preventDefault(); - checkFocus.call( this ); - - // support: IE - // IE doesn't prevent moving focus even with event.preventDefault() - // so we set a flag to know when we should ignore the blur event - // and check (again) if focus moved off of the input. - this.cancelBlur = true; - this._delay(function() { - delete this.cancelBlur; - checkFocus.call( this ); - }); - - if ( this._start( event ) === false ) { - return; - } - - this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event ); - }, - "mouseup .ui-spinner-button": "_stop", - "mouseenter .ui-spinner-button": function( event ) { - // button will add ui-state-active if mouse was down while mouseleave and kept down - if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) { - return; - } - - if ( this._start( event ) === false ) { - return false; - } - this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event ); - }, - // TODO: do we really want to consider this a stop? - // shouldn't we just stop the repeater and wait until mouseup before - // we trigger the stop event? - "mouseleave .ui-spinner-button": "_stop" - }, - - _draw: function() { - var uiSpinner = this.uiSpinner = this.element - .addClass( "ui-spinner-input" ) - .attr( "autocomplete", "off" ) - .wrap( this._uiSpinnerHtml() ) - .parent() - // add buttons - .append( this._buttonHtml() ); - - this.element.attr( "role", "spinbutton" ); - - // button bindings - this.buttons = uiSpinner.find( ".ui-spinner-button" ) - .attr( "tabIndex", -1 ) - .button() - .removeClass( "ui-corner-all" ); - - // IE 6 doesn't understand height: 50% for the buttons - // unless the wrapper has an explicit height - if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) && - uiSpinner.height() > 0 ) { - uiSpinner.height( uiSpinner.height() ); - } - - // disable spinner if element was already disabled - if ( this.options.disabled ) { - this.disable(); - } - }, - - _keydown: function( event ) { - var options = this.options, - keyCode = $.ui.keyCode; - - switch ( event.keyCode ) { - case keyCode.UP: - this._repeat( null, 1, event ); - return true; - case keyCode.DOWN: - this._repeat( null, -1, event ); - return true; - case keyCode.PAGE_UP: - this._repeat( null, options.page, event ); - return true; - case keyCode.PAGE_DOWN: - this._repeat( null, -options.page, event ); - return true; - } - - return false; - }, - - _uiSpinnerHtml: function() { - return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>"; - }, - - _buttonHtml: function() { - return "" + - "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" + - "<span class='ui-icon " + this.options.icons.up + "'>▲</span>" + - "</a>" + - "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" + - "<span class='ui-icon " + this.options.icons.down + "'>▼</span>" + - "</a>"; - }, - - _start: function( event ) { - if ( !this.spinning && this._trigger( "start", event ) === false ) { - return false; - } - - if ( !this.counter ) { - this.counter = 1; - } - this.spinning = true; - return true; - }, - - _repeat: function( i, steps, event ) { - i = i || 500; - - clearTimeout( this.timer ); - this.timer = this._delay(function() { - this._repeat( 40, steps, event ); - }, i ); - - this._spin( steps * this.options.step, event ); - }, - - _spin: function( step, event ) { - var value = this.value() || 0; - - if ( !this.counter ) { - this.counter = 1; - } - - value = this._adjustValue( value + step * this._increment( this.counter ) ); - - if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) { - this._value( value ); - this.counter++; - } - }, - - _increment: function( i ) { - var incremental = this.options.incremental; - - if ( incremental ) { - return $.isFunction( incremental ) ? - incremental( i ) : - Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 ); - } - - return 1; - }, - - _precision: function() { - var precision = this._precisionOf( this.options.step ); - if ( this.options.min !== null ) { - precision = Math.max( precision, this._precisionOf( this.options.min ) ); - } - return precision; - }, - - _precisionOf: function( num ) { - var str = num.toString(), - decimal = str.indexOf( "." ); - return decimal === -1 ? 0 : str.length - decimal - 1; - }, - - _adjustValue: function( value ) { - var base, aboveMin, - options = this.options; - - // make sure we're at a valid step - // - find out where we are relative to the base (min or 0) - base = options.min !== null ? options.min : 0; - aboveMin = value - base; - // - round to the nearest step - aboveMin = Math.round(aboveMin / options.step) * options.step; - // - rounding is based on 0, so adjust back to our base - value = base + aboveMin; - - // fix precision from bad JS floating point math - value = parseFloat( value.toFixed( this._precision() ) ); - - // clamp the value - if ( options.max !== null && value > options.max) { - return options.max; - } - if ( options.min !== null && value < options.min ) { - return options.min; - } - - return value; - }, - - _stop: function( event ) { - if ( !this.spinning ) { - return; - } - - clearTimeout( this.timer ); - clearTimeout( this.mousewheelTimer ); - this.counter = 0; - this.spinning = false; - this._trigger( "stop", event ); - }, - - _setOption: function( key, value ) { - if ( key === "culture" || key === "numberFormat" ) { - var prevValue = this._parse( this.element.val() ); - this.options[ key ] = value; - this.element.val( this._format( prevValue ) ); - return; - } - - if ( key === "max" || key === "min" || key === "step" ) { - if ( typeof value === "string" ) { - value = this._parse( value ); - } - } - if ( key === "icons" ) { - this.buttons.first().find( ".ui-icon" ) - .removeClass( this.options.icons.up ) - .addClass( value.up ); - this.buttons.last().find( ".ui-icon" ) - .removeClass( this.options.icons.down ) - .addClass( value.down ); - } - - this._super( key, value ); - - if ( key === "disabled" ) { - this.widget().toggleClass( "ui-state-disabled", !!value ); - this.element.prop( "disabled", !!value ); - this.buttons.button( value ? "disable" : "enable" ); - } - }, - - _setOptions: spinner_modifier(function( options ) { - this._super( options ); - }), - - _parse: function( val ) { - if ( typeof val === "string" && val !== "" ) { - val = window.Globalize && this.options.numberFormat ? - Globalize.parseFloat( val, 10, this.options.culture ) : +val; - } - return val === "" || isNaN( val ) ? null : val; - }, - - _format: function( value ) { - if ( value === "" ) { - return ""; - } - return window.Globalize && this.options.numberFormat ? - Globalize.format( value, this.options.numberFormat, this.options.culture ) : - value; - }, - - _refresh: function() { - this.element.attr({ - "aria-valuemin": this.options.min, - "aria-valuemax": this.options.max, - // TODO: what should we do with values that can't be parsed? - "aria-valuenow": this._parse( this.element.val() ) - }); - }, - - isValid: function() { - var value = this.value(); - - // null is invalid - if ( value === null ) { - return false; - } - - // if value gets adjusted, it's invalid - return value === this._adjustValue( value ); - }, - - // update the value without triggering change - _value: function( value, allowAny ) { - var parsed; - if ( value !== "" ) { - parsed = this._parse( value ); - if ( parsed !== null ) { - if ( !allowAny ) { - parsed = this._adjustValue( parsed ); - } - value = this._format( parsed ); - } - } - this.element.val( value ); - this._refresh(); - }, - - _destroy: function() { - this.element - .removeClass( "ui-spinner-input" ) - .prop( "disabled", false ) - .removeAttr( "autocomplete" ) - .removeAttr( "role" ) - .removeAttr( "aria-valuemin" ) - .removeAttr( "aria-valuemax" ) - .removeAttr( "aria-valuenow" ); - this.uiSpinner.replaceWith( this.element ); - }, - - stepUp: spinner_modifier(function( steps ) { - this._stepUp( steps ); - }), - _stepUp: function( steps ) { - if ( this._start() ) { - this._spin( (steps || 1) * this.options.step ); - this._stop(); - } - }, - - stepDown: spinner_modifier(function( steps ) { - this._stepDown( steps ); - }), - _stepDown: function( steps ) { - if ( this._start() ) { - this._spin( (steps || 1) * -this.options.step ); - this._stop(); - } - }, - - pageUp: spinner_modifier(function( pages ) { - this._stepUp( (pages || 1) * this.options.page ); - }), - - pageDown: spinner_modifier(function( pages ) { - this._stepDown( (pages || 1) * this.options.page ); - }), - - value: function( newVal ) { - if ( !arguments.length ) { - return this._parse( this.element.val() ); - } - spinner_modifier( this._value ).call( this, newVal ); - }, - - widget: function() { - return this.uiSpinner; - } -}); - - -/*! - * jQuery UI Tabs 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/tabs/ - */ - - -var tabs = $.widget( "ui.tabs", { - version: "1.11.4", - delay: 300, - options: { - active: null, - collapsible: false, - event: "click", - heightStyle: "content", - hide: null, - show: null, - - // callbacks - activate: null, - beforeActivate: null, - beforeLoad: null, - load: null - }, - - _isLocal: (function() { - var rhash = /#.*$/; - - return function( anchor ) { - var anchorUrl, locationUrl; - - // support: IE7 - // IE7 doesn't normalize the href property when set via script (#9317) - anchor = anchor.cloneNode( false ); - - anchorUrl = anchor.href.replace( rhash, "" ); - locationUrl = location.href.replace( rhash, "" ); - - // decoding may throw an error if the URL isn't UTF-8 (#9518) - try { - anchorUrl = decodeURIComponent( anchorUrl ); - } catch ( error ) {} - try { - locationUrl = decodeURIComponent( locationUrl ); - } catch ( error ) {} - - return anchor.hash.length > 1 && anchorUrl === locationUrl; - }; - })(), - - _create: function() { - var that = this, - options = this.options; - - this.running = false; - - this.element - .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" ) - .toggleClass( "ui-tabs-collapsible", options.collapsible ); - - this._processTabs(); - options.active = this._initialActive(); - - // Take disabling tabs via class attribute from HTML - // into account and update option properly. - if ( $.isArray( options.disabled ) ) { - options.disabled = $.unique( options.disabled.concat( - $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) { - return that.tabs.index( li ); - }) - ) ).sort(); - } - - // check for length avoids error when initializing empty list - if ( this.options.active !== false && this.anchors.length ) { - this.active = this._findActive( options.active ); - } else { - this.active = $(); - } - - this._refresh(); - - if ( this.active.length ) { - this.load( options.active ); - } - }, - - _initialActive: function() { - var active = this.options.active, - collapsible = this.options.collapsible, - locationHash = location.hash.substring( 1 ); - - if ( active === null ) { - // check the fragment identifier in the URL - if ( locationHash ) { - this.tabs.each(function( i, tab ) { - if ( $( tab ).attr( "aria-controls" ) === locationHash ) { - active = i; - return false; - } - }); - } - - // check for a tab marked active via a class - if ( active === null ) { - active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) ); - } - - // no active tab, set to false - if ( active === null || active === -1 ) { - active = this.tabs.length ? 0 : false; - } - } - - // handle numbers: negative, out of range - if ( active !== false ) { - active = this.tabs.index( this.tabs.eq( active ) ); - if ( active === -1 ) { - active = collapsible ? false : 0; - } - } - - // don't allow collapsible: false and active: false - if ( !collapsible && active === false && this.anchors.length ) { - active = 0; - } - - return active; - }, - - _getCreateEventData: function() { - return { - tab: this.active, - panel: !this.active.length ? $() : this._getPanelForTab( this.active ) - }; - }, - - _tabKeydown: function( event ) { - var focusedTab = $( this.document[0].activeElement ).closest( "li" ), - selectedIndex = this.tabs.index( focusedTab ), - goingForward = true; - - if ( this._handlePageNav( event ) ) { - return; - } - - switch ( event.keyCode ) { - case $.ui.keyCode.RIGHT: - case $.ui.keyCode.DOWN: - selectedIndex++; - break; - case $.ui.keyCode.UP: - case $.ui.keyCode.LEFT: - goingForward = false; - selectedIndex--; - break; - case $.ui.keyCode.END: - selectedIndex = this.anchors.length - 1; - break; - case $.ui.keyCode.HOME: - selectedIndex = 0; - break; - case $.ui.keyCode.SPACE: - // Activate only, no collapsing - event.preventDefault(); - clearTimeout( this.activating ); - this._activate( selectedIndex ); - return; - case $.ui.keyCode.ENTER: - // Toggle (cancel delayed activation, allow collapsing) - event.preventDefault(); - clearTimeout( this.activating ); - // Determine if we should collapse or activate - this._activate( selectedIndex === this.options.active ? false : selectedIndex ); - return; - default: - return; - } - - // Focus the appropriate tab, based on which key was pressed - event.preventDefault(); - clearTimeout( this.activating ); - selectedIndex = this._focusNextTab( selectedIndex, goingForward ); - - // Navigating with control/command key will prevent automatic activation - if ( !event.ctrlKey && !event.metaKey ) { - - // Update aria-selected immediately so that AT think the tab is already selected. - // Otherwise AT may confuse the user by stating that they need to activate the tab, - // but the tab will already be activated by the time the announcement finishes. - focusedTab.attr( "aria-selected", "false" ); - this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" ); - - this.activating = this._delay(function() { - this.option( "active", selectedIndex ); - }, this.delay ); - } - }, - - _panelKeydown: function( event ) { - if ( this._handlePageNav( event ) ) { - return; - } - - // Ctrl+up moves focus to the current tab - if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) { - event.preventDefault(); - this.active.focus(); - } - }, - - // Alt+page up/down moves focus to the previous/next tab (and activates) - _handlePageNav: function( event ) { - if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) { - this._activate( this._focusNextTab( this.options.active - 1, false ) ); - return true; - } - if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) { - this._activate( this._focusNextTab( this.options.active + 1, true ) ); - return true; - } - }, - - _findNextTab: function( index, goingForward ) { - var lastTabIndex = this.tabs.length - 1; - - function constrain() { - if ( index > lastTabIndex ) { - index = 0; - } - if ( index < 0 ) { - index = lastTabIndex; - } - return index; - } - - while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) { - index = goingForward ? index + 1 : index - 1; - } - - return index; - }, - - _focusNextTab: function( index, goingForward ) { - index = this._findNextTab( index, goingForward ); - this.tabs.eq( index ).focus(); - return index; - }, - - _setOption: function( key, value ) { - if ( key === "active" ) { - // _activate() will handle invalid values and update this.options - this._activate( value ); - return; - } - - if ( key === "disabled" ) { - // don't use the widget factory's disabled handling - this._setupDisabled( value ); - return; - } - - this._super( key, value); - - if ( key === "collapsible" ) { - this.element.toggleClass( "ui-tabs-collapsible", value ); - // Setting collapsible: false while collapsed; open first panel - if ( !value && this.options.active === false ) { - this._activate( 0 ); - } - } - - if ( key === "event" ) { - this._setupEvents( value ); - } - - if ( key === "heightStyle" ) { - this._setupHeightStyle( value ); - } - }, - - _sanitizeSelector: function( hash ) { - return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : ""; - }, - - refresh: function() { - var options = this.options, - lis = this.tablist.children( ":has(a[href])" ); - - // get disabled tabs from class attribute from HTML - // this will get converted to a boolean if needed in _refresh() - options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) { - return lis.index( tab ); - }); - - this._processTabs(); - - // was collapsed or no tabs - if ( options.active === false || !this.anchors.length ) { - options.active = false; - this.active = $(); - // was active, but active tab is gone - } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) { - // all remaining tabs are disabled - if ( this.tabs.length === options.disabled.length ) { - options.active = false; - this.active = $(); - // activate previous tab - } else { - this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) ); - } - // was active, active tab still exists - } else { - // make sure active index is correct - options.active = this.tabs.index( this.active ); - } - - this._refresh(); - }, - - _refresh: function() { - this._setupDisabled( this.options.disabled ); - this._setupEvents( this.options.event ); - this._setupHeightStyle( this.options.heightStyle ); - - this.tabs.not( this.active ).attr({ - "aria-selected": "false", - "aria-expanded": "false", - tabIndex: -1 - }); - this.panels.not( this._getPanelForTab( this.active ) ) - .hide() - .attr({ - "aria-hidden": "true" - }); - - // Make sure one tab is in the tab order - if ( !this.active.length ) { - this.tabs.eq( 0 ).attr( "tabIndex", 0 ); - } else { - this.active - .addClass( "ui-tabs-active ui-state-active" ) - .attr({ - "aria-selected": "true", - "aria-expanded": "true", - tabIndex: 0 - }); - this._getPanelForTab( this.active ) - .show() - .attr({ - "aria-hidden": "false" - }); - } - }, - - _processTabs: function() { - var that = this, - prevTabs = this.tabs, - prevAnchors = this.anchors, - prevPanels = this.panels; - - this.tablist = this._getList() - .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" ) - .attr( "role", "tablist" ) - - // Prevent users from focusing disabled tabs via click - .delegate( "> li", "mousedown" + this.eventNamespace, function( event ) { - if ( $( this ).is( ".ui-state-disabled" ) ) { - event.preventDefault(); - } - }) - - // support: IE <9 - // Preventing the default action in mousedown doesn't prevent IE - // from focusing the element, so if the anchor gets focused, blur. - // We don't have to worry about focusing the previously focused - // element since clicking on a non-focusable element should focus - // the body anyway. - .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() { - if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) { - this.blur(); - } - }); - - this.tabs = this.tablist.find( "> li:has(a[href])" ) - .addClass( "ui-state-default ui-corner-top" ) - .attr({ - role: "tab", - tabIndex: -1 - }); - - this.anchors = this.tabs.map(function() { - return $( "a", this )[ 0 ]; - }) - .addClass( "ui-tabs-anchor" ) - .attr({ - role: "presentation", - tabIndex: -1 - }); - - this.panels = $(); - - this.anchors.each(function( i, anchor ) { - var selector, panel, panelId, - anchorId = $( anchor ).uniqueId().attr( "id" ), - tab = $( anchor ).closest( "li" ), - originalAriaControls = tab.attr( "aria-controls" ); - - // inline tab - if ( that._isLocal( anchor ) ) { - selector = anchor.hash; - panelId = selector.substring( 1 ); - panel = that.element.find( that._sanitizeSelector( selector ) ); - // remote tab - } else { - // If the tab doesn't already have aria-controls, - // generate an id by using a throw-away element - panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id; - selector = "#" + panelId; - panel = that.element.find( selector ); - if ( !panel.length ) { - panel = that._createPanel( panelId ); - panel.insertAfter( that.panels[ i - 1 ] || that.tablist ); - } - panel.attr( "aria-live", "polite" ); - } - - if ( panel.length) { - that.panels = that.panels.add( panel ); - } - if ( originalAriaControls ) { - tab.data( "ui-tabs-aria-controls", originalAriaControls ); - } - tab.attr({ - "aria-controls": panelId, - "aria-labelledby": anchorId - }); - panel.attr( "aria-labelledby", anchorId ); - }); - - this.panels - .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" ) - .attr( "role", "tabpanel" ); - - // Avoid memory leaks (#10056) - if ( prevTabs ) { - this._off( prevTabs.not( this.tabs ) ); - this._off( prevAnchors.not( this.anchors ) ); - this._off( prevPanels.not( this.panels ) ); - } - }, - - // allow overriding how to find the list for rare usage scenarios (#7715) - _getList: function() { - return this.tablist || this.element.find( "ol,ul" ).eq( 0 ); - }, - - _createPanel: function( id ) { - return $( "<div>" ) - .attr( "id", id ) - .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" ) - .data( "ui-tabs-destroy", true ); - }, - - _setupDisabled: function( disabled ) { - if ( $.isArray( disabled ) ) { - if ( !disabled.length ) { - disabled = false; - } else if ( disabled.length === this.anchors.length ) { - disabled = true; - } - } - - // disable tabs - for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) { - if ( disabled === true || $.inArray( i, disabled ) !== -1 ) { - $( li ) - .addClass( "ui-state-disabled" ) - .attr( "aria-disabled", "true" ); - } else { - $( li ) - .removeClass( "ui-state-disabled" ) - .removeAttr( "aria-disabled" ); - } - } - - this.options.disabled = disabled; - }, - - _setupEvents: function( event ) { - var events = {}; - if ( event ) { - $.each( event.split(" "), function( index, eventName ) { - events[ eventName ] = "_eventHandler"; - }); - } - - this._off( this.anchors.add( this.tabs ).add( this.panels ) ); - // Always prevent the default action, even when disabled - this._on( true, this.anchors, { - click: function( event ) { - event.preventDefault(); - } - }); - this._on( this.anchors, events ); - this._on( this.tabs, { keydown: "_tabKeydown" } ); - this._on( this.panels, { keydown: "_panelKeydown" } ); - - this._focusable( this.tabs ); - this._hoverable( this.tabs ); - }, - - _setupHeightStyle: function( heightStyle ) { - var maxHeight, - parent = this.element.parent(); - - if ( heightStyle === "fill" ) { - maxHeight = parent.height(); - maxHeight -= this.element.outerHeight() - this.element.height(); - - this.element.siblings( ":visible" ).each(function() { - var elem = $( this ), - position = elem.css( "position" ); - - if ( position === "absolute" || position === "fixed" ) { - return; - } - maxHeight -= elem.outerHeight( true ); - }); - - this.element.children().not( this.panels ).each(function() { - maxHeight -= $( this ).outerHeight( true ); - }); - - this.panels.each(function() { - $( this ).height( Math.max( 0, maxHeight - - $( this ).innerHeight() + $( this ).height() ) ); - }) - .css( "overflow", "auto" ); - } else if ( heightStyle === "auto" ) { - maxHeight = 0; - this.panels.each(function() { - maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() ); - }).height( maxHeight ); - } - }, - - _eventHandler: function( event ) { - var options = this.options, - active = this.active, - anchor = $( event.currentTarget ), - tab = anchor.closest( "li" ), - clickedIsActive = tab[ 0 ] === active[ 0 ], - collapsing = clickedIsActive && options.collapsible, - toShow = collapsing ? $() : this._getPanelForTab( tab ), - toHide = !active.length ? $() : this._getPanelForTab( active ), - eventData = { - oldTab: active, - oldPanel: toHide, - newTab: collapsing ? $() : tab, - newPanel: toShow - }; - - event.preventDefault(); - - if ( tab.hasClass( "ui-state-disabled" ) || - // tab is already loading - tab.hasClass( "ui-tabs-loading" ) || - // can't switch durning an animation - this.running || - // click on active header, but not collapsible - ( clickedIsActive && !options.collapsible ) || - // allow canceling activation - ( this._trigger( "beforeActivate", event, eventData ) === false ) ) { - return; - } - - options.active = collapsing ? false : this.tabs.index( tab ); - - this.active = clickedIsActive ? $() : tab; - if ( this.xhr ) { - this.xhr.abort(); - } - - if ( !toHide.length && !toShow.length ) { - $.error( "jQuery UI Tabs: Mismatching fragment identifier." ); - } - - if ( toShow.length ) { - this.load( this.tabs.index( tab ), event ); - } - this._toggle( event, eventData ); - }, - - // handles show/hide for selecting tabs - _toggle: function( event, eventData ) { - var that = this, - toShow = eventData.newPanel, - toHide = eventData.oldPanel; - - this.running = true; - - function complete() { - that.running = false; - that._trigger( "activate", event, eventData ); - } - - function show() { - eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" ); - - if ( toShow.length && that.options.show ) { - that._show( toShow, that.options.show, complete ); - } else { - toShow.show(); - complete(); - } - } - - // start out by hiding, then showing, then completing - if ( toHide.length && this.options.hide ) { - this._hide( toHide, this.options.hide, function() { - eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" ); - show(); - }); - } else { - eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" ); - toHide.hide(); - show(); - } - - toHide.attr( "aria-hidden", "true" ); - eventData.oldTab.attr({ - "aria-selected": "false", - "aria-expanded": "false" - }); - // If we're switching tabs, remove the old tab from the tab order. - // If we're opening from collapsed state, remove the previous tab from the tab order. - // If we're collapsing, then keep the collapsing tab in the tab order. - if ( toShow.length && toHide.length ) { - eventData.oldTab.attr( "tabIndex", -1 ); - } else if ( toShow.length ) { - this.tabs.filter(function() { - return $( this ).attr( "tabIndex" ) === 0; - }) - .attr( "tabIndex", -1 ); - } - - toShow.attr( "aria-hidden", "false" ); - eventData.newTab.attr({ - "aria-selected": "true", - "aria-expanded": "true", - tabIndex: 0 - }); - }, - - _activate: function( index ) { - var anchor, - active = this._findActive( index ); - - // trying to activate the already active panel - if ( active[ 0 ] === this.active[ 0 ] ) { - return; - } - - // trying to collapse, simulate a click on the current active header - if ( !active.length ) { - active = this.active; - } - - anchor = active.find( ".ui-tabs-anchor" )[ 0 ]; - this._eventHandler({ - target: anchor, - currentTarget: anchor, - preventDefault: $.noop - }); - }, - - _findActive: function( index ) { - return index === false ? $() : this.tabs.eq( index ); - }, - - _getIndex: function( index ) { - // meta-function to give users option to provide a href string instead of a numerical index. - if ( typeof index === "string" ) { - index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) ); - } - - return index; - }, - - _destroy: function() { - if ( this.xhr ) { - this.xhr.abort(); - } - - this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" ); - - this.tablist - .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" ) - .removeAttr( "role" ); - - this.anchors - .removeClass( "ui-tabs-anchor" ) - .removeAttr( "role" ) - .removeAttr( "tabIndex" ) - .removeUniqueId(); - - this.tablist.unbind( this.eventNamespace ); - - this.tabs.add( this.panels ).each(function() { - if ( $.data( this, "ui-tabs-destroy" ) ) { - $( this ).remove(); - } else { - $( this ) - .removeClass( "ui-state-default ui-state-active ui-state-disabled " + - "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" ) - .removeAttr( "tabIndex" ) - .removeAttr( "aria-live" ) - .removeAttr( "aria-busy" ) - .removeAttr( "aria-selected" ) - .removeAttr( "aria-labelledby" ) - .removeAttr( "aria-hidden" ) - .removeAttr( "aria-expanded" ) - .removeAttr( "role" ); - } - }); - - this.tabs.each(function() { - var li = $( this ), - prev = li.data( "ui-tabs-aria-controls" ); - if ( prev ) { - li - .attr( "aria-controls", prev ) - .removeData( "ui-tabs-aria-controls" ); - } else { - li.removeAttr( "aria-controls" ); - } - }); - - this.panels.show(); - - if ( this.options.heightStyle !== "content" ) { - this.panels.css( "height", "" ); - } - }, - - enable: function( index ) { - var disabled = this.options.disabled; - if ( disabled === false ) { - return; - } - - if ( index === undefined ) { - disabled = false; - } else { - index = this._getIndex( index ); - if ( $.isArray( disabled ) ) { - disabled = $.map( disabled, function( num ) { - return num !== index ? num : null; - }); - } else { - disabled = $.map( this.tabs, function( li, num ) { - return num !== index ? num : null; - }); - } - } - this._setupDisabled( disabled ); - }, - - disable: function( index ) { - var disabled = this.options.disabled; - if ( disabled === true ) { - return; - } - - if ( index === undefined ) { - disabled = true; - } else { - index = this._getIndex( index ); - if ( $.inArray( index, disabled ) !== -1 ) { - return; - } - if ( $.isArray( disabled ) ) { - disabled = $.merge( [ index ], disabled ).sort(); - } else { - disabled = [ index ]; - } - } - this._setupDisabled( disabled ); - }, - - load: function( index, event ) { - index = this._getIndex( index ); - var that = this, - tab = this.tabs.eq( index ), - anchor = tab.find( ".ui-tabs-anchor" ), - panel = this._getPanelForTab( tab ), - eventData = { - tab: tab, - panel: panel - }, - complete = function( jqXHR, status ) { - if ( status === "abort" ) { - that.panels.stop( false, true ); - } - - tab.removeClass( "ui-tabs-loading" ); - panel.removeAttr( "aria-busy" ); - - if ( jqXHR === that.xhr ) { - delete that.xhr; - } - }; - - // not remote - if ( this._isLocal( anchor[ 0 ] ) ) { - return; - } - - this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) ); - - // support: jQuery <1.8 - // jQuery <1.8 returns false if the request is canceled in beforeSend, - // but as of 1.8, $.ajax() always returns a jqXHR object. - if ( this.xhr && this.xhr.statusText !== "canceled" ) { - tab.addClass( "ui-tabs-loading" ); - panel.attr( "aria-busy", "true" ); - - this.xhr - .done(function( response, status, jqXHR ) { - // support: jQuery <1.8 - // http://bugs.jquery.com/ticket/11778 - setTimeout(function() { - panel.html( response ); - that._trigger( "load", event, eventData ); - - complete( jqXHR, status ); - }, 1 ); - }) - .fail(function( jqXHR, status ) { - // support: jQuery <1.8 - // http://bugs.jquery.com/ticket/11778 - setTimeout(function() { - complete( jqXHR, status ); - }, 1 ); - }); - } - }, - - _ajaxSettings: function( anchor, event, eventData ) { - var that = this; - return { - url: anchor.attr( "href" ), - beforeSend: function( jqXHR, settings ) { - return that._trigger( "beforeLoad", event, - $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) ); - } - }; - }, - - _getPanelForTab: function( tab ) { - var id = $( tab ).attr( "aria-controls" ); - return this.element.find( this._sanitizeSelector( "#" + id ) ); - } -}); - - -/*! - * jQuery UI Tooltip 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/tooltip/ - */ - - -var tooltip = $.widget( "ui.tooltip", { - version: "1.11.4", - options: { - content: function() { - // support: IE<9, Opera in jQuery <1.7 - // .text() can't accept undefined, so coerce to a string - var title = $( this ).attr( "title" ) || ""; - // Escape title, since we're going from an attribute to raw HTML - return $( "<a>" ).text( title ).html(); - }, - hide: true, - // Disabled elements have inconsistent behavior across browsers (#8661) - items: "[title]:not([disabled])", - position: { - my: "left top+15", - at: "left bottom", - collision: "flipfit flip" - }, - show: true, - tooltipClass: null, - track: false, - - // callbacks - close: null, - open: null - }, - - _addDescribedBy: function( elem, id ) { - var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ); - describedby.push( id ); - elem - .data( "ui-tooltip-id", id ) - .attr( "aria-describedby", $.trim( describedby.join( " " ) ) ); - }, - - _removeDescribedBy: function( elem ) { - var id = elem.data( "ui-tooltip-id" ), - describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ), - index = $.inArray( id, describedby ); - - if ( index !== -1 ) { - describedby.splice( index, 1 ); - } - - elem.removeData( "ui-tooltip-id" ); - describedby = $.trim( describedby.join( " " ) ); - if ( describedby ) { - elem.attr( "aria-describedby", describedby ); - } else { - elem.removeAttr( "aria-describedby" ); - } - }, - - _create: function() { - this._on({ - mouseover: "open", - focusin: "open" - }); - - // IDs of generated tooltips, needed for destroy - this.tooltips = {}; - - // IDs of parent tooltips where we removed the title attribute - this.parents = {}; - - if ( this.options.disabled ) { - this._disable(); - } - - // Append the aria-live region so tooltips announce correctly - this.liveRegion = $( "<div>" ) - .attr({ - role: "log", - "aria-live": "assertive", - "aria-relevant": "additions" - }) - .addClass( "ui-helper-hidden-accessible" ) - .appendTo( this.document[ 0 ].body ); - }, - - _setOption: function( key, value ) { - var that = this; - - if ( key === "disabled" ) { - this[ value ? "_disable" : "_enable" ](); - this.options[ key ] = value; - // disable element style changes - return; - } - - this._super( key, value ); - - if ( key === "content" ) { - $.each( this.tooltips, function( id, tooltipData ) { - that._updateContent( tooltipData.element ); - }); - } - }, - - _disable: function() { - var that = this; - - // close open tooltips - $.each( this.tooltips, function( id, tooltipData ) { - var event = $.Event( "blur" ); - event.target = event.currentTarget = tooltipData.element[ 0 ]; - that.close( event, true ); - }); - - // remove title attributes to prevent native tooltips - this.element.find( this.options.items ).addBack().each(function() { - var element = $( this ); - if ( element.is( "[title]" ) ) { - element - .data( "ui-tooltip-title", element.attr( "title" ) ) - .removeAttr( "title" ); - } - }); - }, - - _enable: function() { - // restore title attributes - this.element.find( this.options.items ).addBack().each(function() { - var element = $( this ); - if ( element.data( "ui-tooltip-title" ) ) { - element.attr( "title", element.data( "ui-tooltip-title" ) ); - } - }); - }, - - open: function( event ) { - var that = this, - target = $( event ? event.target : this.element ) - // we need closest here due to mouseover bubbling, - // but always pointing at the same event target - .closest( this.options.items ); - - // No element to show a tooltip for or the tooltip is already open - if ( !target.length || target.data( "ui-tooltip-id" ) ) { - return; - } - - if ( target.attr( "title" ) ) { - target.data( "ui-tooltip-title", target.attr( "title" ) ); - } - - target.data( "ui-tooltip-open", true ); - - // kill parent tooltips, custom or native, for hover - if ( event && event.type === "mouseover" ) { - target.parents().each(function() { - var parent = $( this ), - blurEvent; - if ( parent.data( "ui-tooltip-open" ) ) { - blurEvent = $.Event( "blur" ); - blurEvent.target = blurEvent.currentTarget = this; - that.close( blurEvent, true ); - } - if ( parent.attr( "title" ) ) { - parent.uniqueId(); - that.parents[ this.id ] = { - element: this, - title: parent.attr( "title" ) - }; - parent.attr( "title", "" ); - } - }); - } - - this._registerCloseHandlers( event, target ); - this._updateContent( target, event ); - }, - - _updateContent: function( target, event ) { - var content, - contentOption = this.options.content, - that = this, - eventType = event ? event.type : null; - - if ( typeof contentOption === "string" ) { - return this._open( event, target, contentOption ); - } - - content = contentOption.call( target[0], function( response ) { - - // IE may instantly serve a cached response for ajax requests - // delay this call to _open so the other call to _open runs first - that._delay(function() { - - // Ignore async response if tooltip was closed already - if ( !target.data( "ui-tooltip-open" ) ) { - return; - } - - // jQuery creates a special event for focusin when it doesn't - // exist natively. To improve performance, the native event - // object is reused and the type is changed. Therefore, we can't - // rely on the type being correct after the event finished - // bubbling, so we set it back to the previous value. (#8740) - if ( event ) { - event.type = eventType; - } - this._open( event, target, response ); - }); - }); - if ( content ) { - this._open( event, target, content ); - } - }, - - _open: function( event, target, content ) { - var tooltipData, tooltip, delayedShow, a11yContent, - positionOption = $.extend( {}, this.options.position ); - - if ( !content ) { - return; - } - - // Content can be updated multiple times. If the tooltip already - // exists, then just update the content and bail. - tooltipData = this._find( target ); - if ( tooltipData ) { - tooltipData.tooltip.find( ".ui-tooltip-content" ).html( content ); - return; - } - - // if we have a title, clear it to prevent the native tooltip - // we have to check first to avoid defining a title if none exists - // (we don't want to cause an element to start matching [title]) - // - // We use removeAttr only for key events, to allow IE to export the correct - // accessible attributes. For mouse events, set to empty string to avoid - // native tooltip showing up (happens only when removing inside mouseover). - if ( target.is( "[title]" ) ) { - if ( event && event.type === "mouseover" ) { - target.attr( "title", "" ); - } else { - target.removeAttr( "title" ); - } - } - - tooltipData = this._tooltip( target ); - tooltip = tooltipData.tooltip; - this._addDescribedBy( target, tooltip.attr( "id" ) ); - tooltip.find( ".ui-tooltip-content" ).html( content ); - - // Support: Voiceover on OS X, JAWS on IE <= 9 - // JAWS announces deletions even when aria-relevant="additions" - // Voiceover will sometimes re-read the entire log region's contents from the beginning - this.liveRegion.children().hide(); - if ( content.clone ) { - a11yContent = content.clone(); - a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" ); - } else { - a11yContent = content; - } - $( "<div>" ).html( a11yContent ).appendTo( this.liveRegion ); - - function position( event ) { - positionOption.of = event; - if ( tooltip.is( ":hidden" ) ) { - return; - } - tooltip.position( positionOption ); - } - if ( this.options.track && event && /^mouse/.test( event.type ) ) { - this._on( this.document, { - mousemove: position - }); - // trigger once to override element-relative positioning - position( event ); - } else { - tooltip.position( $.extend({ - of: target - }, this.options.position ) ); - } - - tooltip.hide(); - - this._show( tooltip, this.options.show ); - // Handle tracking tooltips that are shown with a delay (#8644). As soon - // as the tooltip is visible, position the tooltip using the most recent - // event. - if ( this.options.show && this.options.show.delay ) { - delayedShow = this.delayedShow = setInterval(function() { - if ( tooltip.is( ":visible" ) ) { - position( positionOption.of ); - clearInterval( delayedShow ); - } - }, $.fx.interval ); - } - - this._trigger( "open", event, { tooltip: tooltip } ); - }, - - _registerCloseHandlers: function( event, target ) { - var events = { - keyup: function( event ) { - if ( event.keyCode === $.ui.keyCode.ESCAPE ) { - var fakeEvent = $.Event(event); - fakeEvent.currentTarget = target[0]; - this.close( fakeEvent, true ); - } - } - }; - - // Only bind remove handler for delegated targets. Non-delegated - // tooltips will handle this in destroy. - if ( target[ 0 ] !== this.element[ 0 ] ) { - events.remove = function() { - this._removeTooltip( this._find( target ).tooltip ); - }; - } - - if ( !event || event.type === "mouseover" ) { - events.mouseleave = "close"; - } - if ( !event || event.type === "focusin" ) { - events.focusout = "close"; - } - this._on( true, target, events ); - }, - - close: function( event ) { - var tooltip, - that = this, - target = $( event ? event.currentTarget : this.element ), - tooltipData = this._find( target ); - - // The tooltip may already be closed - if ( !tooltipData ) { - - // We set ui-tooltip-open immediately upon open (in open()), but only set the - // additional data once there's actually content to show (in _open()). So even if the - // tooltip doesn't have full data, we always remove ui-tooltip-open in case we're in - // the period between open() and _open(). - target.removeData( "ui-tooltip-open" ); - return; - } - - tooltip = tooltipData.tooltip; - - // disabling closes the tooltip, so we need to track when we're closing - // to avoid an infinite loop in case the tooltip becomes disabled on close - if ( tooltipData.closing ) { - return; - } - - // Clear the interval for delayed tracking tooltips - clearInterval( this.delayedShow ); - - // only set title if we had one before (see comment in _open()) - // If the title attribute has changed since open(), don't restore - if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) { - target.attr( "title", target.data( "ui-tooltip-title" ) ); - } - - this._removeDescribedBy( target ); - - tooltipData.hiding = true; - tooltip.stop( true ); - this._hide( tooltip, this.options.hide, function() { - that._removeTooltip( $( this ) ); - }); - - target.removeData( "ui-tooltip-open" ); - this._off( target, "mouseleave focusout keyup" ); - - // Remove 'remove' binding only on delegated targets - if ( target[ 0 ] !== this.element[ 0 ] ) { - this._off( target, "remove" ); - } - this._off( this.document, "mousemove" ); - - if ( event && event.type === "mouseleave" ) { - $.each( this.parents, function( id, parent ) { - $( parent.element ).attr( "title", parent.title ); - delete that.parents[ id ]; - }); - } - - tooltipData.closing = true; - this._trigger( "close", event, { tooltip: tooltip } ); - if ( !tooltipData.hiding ) { - tooltipData.closing = false; - } - }, - - _tooltip: function( element ) { - var tooltip = $( "<div>" ) - .attr( "role", "tooltip" ) - .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " + - ( this.options.tooltipClass || "" ) ), - id = tooltip.uniqueId().attr( "id" ); - - $( "<div>" ) - .addClass( "ui-tooltip-content" ) - .appendTo( tooltip ); - - tooltip.appendTo( this.document[0].body ); - - return this.tooltips[ id ] = { - element: element, - tooltip: tooltip - }; - }, - - _find: function( target ) { - var id = target.data( "ui-tooltip-id" ); - return id ? this.tooltips[ id ] : null; - }, - - _removeTooltip: function( tooltip ) { - tooltip.remove(); - delete this.tooltips[ tooltip.attr( "id" ) ]; - }, - - _destroy: function() { - var that = this; - - // close open tooltips - $.each( this.tooltips, function( id, tooltipData ) { - // Delegate to close method to handle common cleanup - var event = $.Event( "blur" ), - element = tooltipData.element; - event.target = event.currentTarget = element[ 0 ]; - that.close( event, true ); - - // Remove immediately; destroying an open tooltip doesn't use the - // hide animation - $( "#" + id ).remove(); - - // Restore the title - if ( element.data( "ui-tooltip-title" ) ) { - // If the title attribute has changed since open(), don't restore - if ( !element.attr( "title" ) ) { - element.attr( "title", element.data( "ui-tooltip-title" ) ); - } - element.removeData( "ui-tooltip-title" ); - } - }); - this.liveRegion.remove(); - } -}); - - - -})); \ No newline at end of file +/*! jQuery UI - v1.13.2 - 2022-07-14 +* http://jqueryui.com +* Includes: widget.js, position.js, data.js, disable-selection.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js, effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect-fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effects/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-size.js, effects/effect-slide.js, effects/effect-transfer.js, focusable.js, form-reset-mixin.js, jquery-patch.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio.js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable.js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, widgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, widgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js +* Copyright jQuery Foundation and other contributors; Licensed MIT */ + +!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)}(function(V){"use strict";V.ui=V.ui||{};V.ui.version="1.13.2";var n,i=0,a=Array.prototype.hasOwnProperty,r=Array.prototype.slice;V.cleanData=(n=V.cleanData,function(t){for(var e,i,s=0;null!=(i=t[s]);s++)(e=V._data(i,"events"))&&e.remove&&V(i).triggerHandler("remove");n(t)}),V.widget=function(t,i,e){var s,n,o,a={},r=t.split(".")[0],l=r+"-"+(t=t.split(".")[1]);return e||(e=i,i=V.Widget),Array.isArray(e)&&(e=V.extend.apply(null,[{}].concat(e))),V.expr.pseudos[l.toLowerCase()]=function(t){return!!V.data(t,l)},V[r]=V[r]||{},s=V[r][t],n=V[r][t]=function(t,e){if(!this||!this._createWidget)return new n(t,e);arguments.length&&this._createWidget(t,e)},V.extend(n,s,{version:e.version,_proto:V.extend({},e),_childConstructors:[]}),(o=new i).options=V.widget.extend({},o.options),V.each(e,function(e,s){function n(){return i.prototype[e].apply(this,arguments)}function o(t){return i.prototype[e].apply(this,t)}a[e]="function"==typeof s?function(){var t,e=this._super,i=this._superApply;return this._super=n,this._superApply=o,t=s.apply(this,arguments),this._super=e,this._superApply=i,t}:s}),n.prototype=V.widget.extend(o,{widgetEventPrefix:s&&o.widgetEventPrefix||t},a,{constructor:n,namespace:r,widgetName:t,widgetFullName:l}),s?(V.each(s._childConstructors,function(t,e){var i=e.prototype;V.widget(i.namespace+"."+i.widgetName,n,e._proto)}),delete s._childConstructors):i._childConstructors.push(n),V.widget.bridge(t,n),n},V.widget.extend=function(t){for(var e,i,s=r.call(arguments,1),n=0,o=s.length;n<o;n++)for(e in s[n])i=s[n][e],a.call(s[n],e)&&void 0!==i&&(V.isPlainObject(i)?t[e]=V.isPlainObject(t[e])?V.widget.extend({},t[e],i):V.widget.extend({},i):t[e]=i);return t},V.widget.bridge=function(o,e){var a=e.prototype.widgetFullName||o;V.fn[o]=function(i){var t="string"==typeof i,s=r.call(arguments,1),n=this;return t?this.length||"instance"!==i?this.each(function(){var t,e=V.data(this,a);return"instance"===i?(n=e,!1):e?"function"!=typeof e[i]||"_"===i.charAt(0)?V.error("no such method '"+i+"' for "+o+" widget instance"):(t=e[i].apply(e,s))!==e&&void 0!==t?(n=t&&t.jquery?n.pushStack(t.get()):t,!1):void 0:V.error("cannot call methods on "+o+" prior to initialization; attempted to call method '"+i+"'")}):n=void 0:(s.length&&(i=V.widget.extend.apply(null,[i].concat(s))),this.each(function(){var t=V.data(this,a);t?(t.option(i||{}),t._init&&t._init()):V.data(this,a,new e(i,this))})),n}},V.Widget=function(){},V.Widget._childConstructors=[],V.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{classes:{},disabled:!1,create:null},_createWidget:function(t,e){e=V(e||this.defaultElement||this)[0],this.element=V(e),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=V(),this.hoverable=V(),this.focusable=V(),this.classesElementLookup={},e!==this&&(V.data(e,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===e&&this.destroy()}}),this.document=V(e.style?e.ownerDocument:e.document||e),this.window=V(this.document[0].defaultView||this.document[0].parentWindow)),this.options=V.widget.extend({},this.options,this._getCreateOptions(),t),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:V.noop,_create:V.noop,_init:V.noop,destroy:function(){var i=this;this._destroy(),V.each(this.classesElementLookup,function(t,e){i._removeClass(e,t)}),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:V.noop,widget:function(){return this.element},option:function(t,e){var i,s,n,o=t;if(0===arguments.length)return V.widget.extend({},this.options);if("string"==typeof t)if(o={},t=(i=t.split(".")).shift(),i.length){for(s=o[t]=V.widget.extend({},this.options[t]),n=0;n<i.length-1;n++)s[i[n]]=s[i[n]]||{},s=s[i[n]];if(t=i.pop(),1===arguments.length)return void 0===s[t]?null:s[t];s[t]=e}else{if(1===arguments.length)return void 0===this.options[t]?null:this.options[t];o[t]=e}return this._setOptions(o),this},_setOptions:function(t){for(var e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return"classes"===t&&this._setOptionClasses(e),this.options[t]=e,"disabled"===t&&this._setOptionDisabled(e),this},_setOptionClasses:function(t){var e,i,s;for(e in t)s=this.classesElementLookup[e],t[e]!==this.options.classes[e]&&s&&s.length&&(i=V(s.get()),this._removeClass(s,e),i.addClass(this._classes({element:i,keys:e,classes:t,add:!0})))},_setOptionDisabled:function(t){this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,!!t),t&&(this._removeClass(this.hoverable,null,"ui-state-hover"),this._removeClass(this.focusable,null,"ui-state-focus"))},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_classes:function(n){var o=[],a=this;function t(t,e){for(var i,s=0;s<t.length;s++)i=a.classesElementLookup[t[s]]||V(),i=n.add?(function(){var i=[];n.element.each(function(t,e){V.map(a.classesElementLookup,function(t){return t}).some(function(t){return t.is(e)})||i.push(e)}),a._on(V(i),{remove:"_untrackClassesElement"})}(),V(V.uniqueSort(i.get().concat(n.element.get())))):V(i.not(n.element).get()),a.classesElementLookup[t[s]]=i,o.push(t[s]),e&&n.classes[t[s]]&&o.push(n.classes[t[s]])}return(n=V.extend({element:this.element,classes:this.options.classes||{}},n)).keys&&t(n.keys.match(/\S+/g)||[],!0),n.extra&&t(n.extra.match(/\S+/g)||[]),o.join(" ")},_untrackClassesElement:function(i){var s=this;V.each(s.classesElementLookup,function(t,e){-1!==V.inArray(i.target,e)&&(s.classesElementLookup[t]=V(e.not(i.target).get()))}),this._off(V(i.target))},_removeClass:function(t,e,i){return this._toggleClass(t,e,i,!1)},_addClass:function(t,e,i){return this._toggleClass(t,e,i,!0)},_toggleClass:function(t,e,i,s){var n="string"==typeof t||null===t,i={extra:n?e:i,keys:n?t:e,element:n?this.element:t,add:s="boolean"==typeof s?s:i};return i.element.toggleClass(this._classes(i),s),this},_on:function(n,o,t){var a,r=this;"boolean"!=typeof n&&(t=o,o=n,n=!1),t?(o=a=V(o),this.bindings=this.bindings.add(o)):(t=o,o=this.element,a=this.widget()),V.each(t,function(t,e){function i(){if(n||!0!==r.options.disabled&&!V(this).hasClass("ui-state-disabled"))return("string"==typeof e?r[e]:e).apply(r,arguments)}"string"!=typeof e&&(i.guid=e.guid=e.guid||i.guid||V.guid++);var s=t.match(/^([\w:-]*)\s*(.*)$/),t=s[1]+r.eventNamespace,s=s[2];s?a.on(t,s,i):o.on(t,i)})},_off:function(t,e){e=(e||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,t.off(e),this.bindings=V(this.bindings.not(t).get()),this.focusable=V(this.focusable.not(t).get()),this.hoverable=V(this.hoverable.not(t).get())},_delay:function(t,e){var i=this;return setTimeout(function(){return("string"==typeof t?i[t]:t).apply(i,arguments)},e||0)},_hoverable:function(t){this.hoverable=this.hoverable.add(t),this._on(t,{mouseenter:function(t){this._addClass(V(t.currentTarget),null,"ui-state-hover")},mouseleave:function(t){this._removeClass(V(t.currentTarget),null,"ui-state-hover")}})},_focusable:function(t){this.focusable=this.focusable.add(t),this._on(t,{focusin:function(t){this._addClass(V(t.currentTarget),null,"ui-state-focus")},focusout:function(t){this._removeClass(V(t.currentTarget),null,"ui-state-focus")}})},_trigger:function(t,e,i){var s,n,o=this.options[t];if(i=i||{},(e=V.Event(e)).type=(t===this.widgetEventPrefix?t:this.widgetEventPrefix+t).toLowerCase(),e.target=this.element[0],n=e.originalEvent)for(s in n)s in e||(e[s]=n[s]);return this.element.trigger(e,i),!("function"==typeof o&&!1===o.apply(this.element[0],[e].concat(i))||e.isDefaultPrevented())}},V.each({show:"fadeIn",hide:"fadeOut"},function(o,a){V.Widget.prototype["_"+o]=function(e,t,i){var s,n=(t="string"==typeof t?{effect:t}:t)?!0!==t&&"number"!=typeof t&&t.effect||a:o;"number"==typeof(t=t||{})?t={duration:t}:!0===t&&(t={}),s=!V.isEmptyObject(t),t.complete=i,t.delay&&e.delay(t.delay),s&&V.effects&&V.effects.effect[n]?e[o](t):n!==o&&e[n]?e[n](t.duration,t.easing,i):e.queue(function(t){V(this)[o](),i&&i.call(e[0]),t()})}});var s,x,k,o,l,h,c,u,C;V.widget;function D(t,e,i){return[parseFloat(t[0])*(u.test(t[0])?e/100:1),parseFloat(t[1])*(u.test(t[1])?i/100:1)]}function I(t,e){return parseInt(V.css(t,e),10)||0}function T(t){return null!=t&&t===t.window}x=Math.max,k=Math.abs,o=/left|center|right/,l=/top|center|bottom/,h=/[\+\-]\d+(\.[\d]+)?%?/,c=/^\w+/,u=/%$/,C=V.fn.position,V.position={scrollbarWidth:function(){if(void 0!==s)return s;var t,e=V("<div style='display:block;position:absolute;width:200px;height:200px;overflow:hidden;'><div style='height:300px;width:auto;'></div></div>"),i=e.children()[0];return V("body").append(e),t=i.offsetWidth,e.css("overflow","scroll"),t===(i=i.offsetWidth)&&(i=e[0].clientWidth),e.remove(),s=t-i},getScrollInfo:function(t){var e=t.isWindow||t.isDocument?"":t.element.css("overflow-x"),i=t.isWindow||t.isDocument?"":t.element.css("overflow-y"),e="scroll"===e||"auto"===e&&t.width<t.element[0].scrollWidth;return{width:"scroll"===i||"auto"===i&&t.height<t.element[0].scrollHeight?V.position.scrollbarWidth():0,height:e?V.position.scrollbarWidth():0}},getWithinInfo:function(t){var e=V(t||window),i=T(e[0]),s=!!e[0]&&9===e[0].nodeType;return{element:e,isWindow:i,isDocument:s,offset:!i&&!s?V(t).offset():{left:0,top:0},scrollLeft:e.scrollLeft(),scrollTop:e.scrollTop(),width:e.outerWidth(),height:e.outerHeight()}}},V.fn.position=function(u){if(!u||!u.of)return C.apply(this,arguments);var d,p,f,g,m,t,_="string"==typeof(u=V.extend({},u)).of?V(document).find(u.of):V(u.of),v=V.position.getWithinInfo(u.within),b=V.position.getScrollInfo(v),y=(u.collision||"flip").split(" "),w={},e=9===(t=(e=_)[0]).nodeType?{width:e.width(),height:e.height(),offset:{top:0,left:0}}:T(t)?{width:e.width(),height:e.height(),offset:{top:e.scrollTop(),left:e.scrollLeft()}}:t.preventDefault?{width:0,height:0,offset:{top:t.pageY,left:t.pageX}}:{width:e.outerWidth(),height:e.outerHeight(),offset:e.offset()};return _[0].preventDefault&&(u.at="left top"),p=e.width,f=e.height,m=V.extend({},g=e.offset),V.each(["my","at"],function(){var t,e,i=(u[this]||"").split(" ");(i=1===i.length?o.test(i[0])?i.concat(["center"]):l.test(i[0])?["center"].concat(i):["center","center"]:i)[0]=o.test(i[0])?i[0]:"center",i[1]=l.test(i[1])?i[1]:"center",t=h.exec(i[0]),e=h.exec(i[1]),w[this]=[t?t[0]:0,e?e[0]:0],u[this]=[c.exec(i[0])[0],c.exec(i[1])[0]]}),1===y.length&&(y[1]=y[0]),"right"===u.at[0]?m.left+=p:"center"===u.at[0]&&(m.left+=p/2),"bottom"===u.at[1]?m.top+=f:"center"===u.at[1]&&(m.top+=f/2),d=D(w.at,p,f),m.left+=d[0],m.top+=d[1],this.each(function(){var i,t,a=V(this),r=a.outerWidth(),l=a.outerHeight(),e=I(this,"marginLeft"),s=I(this,"marginTop"),n=r+e+I(this,"marginRight")+b.width,o=l+s+I(this,"marginBottom")+b.height,h=V.extend({},m),c=D(w.my,a.outerWidth(),a.outerHeight());"right"===u.my[0]?h.left-=r:"center"===u.my[0]&&(h.left-=r/2),"bottom"===u.my[1]?h.top-=l:"center"===u.my[1]&&(h.top-=l/2),h.left+=c[0],h.top+=c[1],i={marginLeft:e,marginTop:s},V.each(["left","top"],function(t,e){V.ui.position[y[t]]&&V.ui.position[y[t]][e](h,{targetWidth:p,targetHeight:f,elemWidth:r,elemHeight:l,collisionPosition:i,collisionWidth:n,collisionHeight:o,offset:[d[0]+c[0],d[1]+c[1]],my:u.my,at:u.at,within:v,elem:a})}),u.using&&(t=function(t){var e=g.left-h.left,i=e+p-r,s=g.top-h.top,n=s+f-l,o={target:{element:_,left:g.left,top:g.top,width:p,height:f},element:{element:a,left:h.left,top:h.top,width:r,height:l},horizontal:i<0?"left":0<e?"right":"center",vertical:n<0?"top":0<s?"bottom":"middle"};p<r&&k(e+i)<p&&(o.horizontal="center"),f<l&&k(s+n)<f&&(o.vertical="middle"),x(k(e),k(i))>x(k(s),k(n))?o.important="horizontal":o.important="vertical",u.using.call(this,t,o)}),a.offset(V.extend(h,{using:t}))})},V.ui.position={fit:{left:function(t,e){var i=e.within,s=i.isWindow?i.scrollLeft:i.offset.left,n=i.width,o=t.left-e.collisionPosition.marginLeft,a=s-o,r=o+e.collisionWidth-n-s;e.collisionWidth>n?0<a&&r<=0?(i=t.left+a+e.collisionWidth-n-s,t.left+=a-i):t.left=!(0<r&&a<=0)&&r<a?s+n-e.collisionWidth:s:0<a?t.left+=a:0<r?t.left-=r:t.left=x(t.left-o,t.left)},top:function(t,e){var i=e.within,s=i.isWindow?i.scrollTop:i.offset.top,n=e.within.height,o=t.top-e.collisionPosition.marginTop,a=s-o,r=o+e.collisionHeight-n-s;e.collisionHeight>n?0<a&&r<=0?(i=t.top+a+e.collisionHeight-n-s,t.top+=a-i):t.top=!(0<r&&a<=0)&&r<a?s+n-e.collisionHeight:s:0<a?t.top+=a:0<r?t.top-=r:t.top=x(t.top-o,t.top)}},flip:{left:function(t,e){var i=e.within,s=i.offset.left+i.scrollLeft,n=i.width,o=i.isWindow?i.scrollLeft:i.offset.left,a=t.left-e.collisionPosition.marginLeft,r=a-o,l=a+e.collisionWidth-n-o,h="left"===e.my[0]?-e.elemWidth:"right"===e.my[0]?e.elemWidth:0,i="left"===e.at[0]?e.targetWidth:"right"===e.at[0]?-e.targetWidth:0,a=-2*e.offset[0];r<0?((s=t.left+h+i+a+e.collisionWidth-n-s)<0||s<k(r))&&(t.left+=h+i+a):0<l&&(0<(o=t.left-e.collisionPosition.marginLeft+h+i+a-o)||k(o)<l)&&(t.left+=h+i+a)},top:function(t,e){var i=e.within,s=i.offset.top+i.scrollTop,n=i.height,o=i.isWindow?i.scrollTop:i.offset.top,a=t.top-e.collisionPosition.marginTop,r=a-o,l=a+e.collisionHeight-n-o,h="top"===e.my[1]?-e.elemHeight:"bottom"===e.my[1]?e.elemHeight:0,i="top"===e.at[1]?e.targetHeight:"bottom"===e.at[1]?-e.targetHeight:0,a=-2*e.offset[1];r<0?((s=t.top+h+i+a+e.collisionHeight-n-s)<0||s<k(r))&&(t.top+=h+i+a):0<l&&(0<(o=t.top-e.collisionPosition.marginTop+h+i+a-o)||k(o)<l)&&(t.top+=h+i+a)}},flipfit:{left:function(){V.ui.position.flip.left.apply(this,arguments),V.ui.position.fit.left.apply(this,arguments)},top:function(){V.ui.position.flip.top.apply(this,arguments),V.ui.position.fit.top.apply(this,arguments)}}};V.ui.position,V.extend(V.expr.pseudos,{data:V.expr.createPseudo?V.expr.createPseudo(function(e){return function(t){return!!V.data(t,e)}}):function(t,e,i){return!!V.data(t,i[3])}}),V.fn.extend({disableSelection:(t="onselectstart"in document.createElement("div")?"selectstart":"mousedown",function(){return this.on(t+".ui-disableSelection",function(t){t.preventDefault()})}),enableSelection:function(){return this.off(".ui-disableSelection")}});var t,d=V,p={},e=p.toString,f=/^([\-+])=\s*(\d+\.?\d*)/,g=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(t){return[t[1],t[2],t[3],t[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(t){return[2.55*t[1],2.55*t[2],2.55*t[3],t[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})?/,parse:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16),t[4]?(parseInt(t[4],16)/255).toFixed(2):1]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])([a-f0-9])?/,parse:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16),t[4]?(parseInt(t[4]+t[4],16)/255).toFixed(2):1]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(t){return[t[1],t[2]/100,t[3]/100,t[4]]}}],m=d.Color=function(t,e,i,s){return new d.Color.fn.parse(t,e,i,s)},_={rgba:{props:{red:{idx:0,type:"byte"},green:{idx:1,type:"byte"},blue:{idx:2,type:"byte"}}},hsla:{props:{hue:{idx:0,type:"degrees"},saturation:{idx:1,type:"percent"},lightness:{idx:2,type:"percent"}}}},v={byte:{floor:!0,max:255},percent:{max:1},degrees:{mod:360,floor:!0}},b=m.support={},y=d("<p>")[0],w=d.each;function P(t){return null==t?t+"":"object"==typeof t?p[e.call(t)]||"object":typeof t}function M(t,e,i){var s=v[e.type]||{};return null==t?i||!e.def?null:e.def:(t=s.floor?~~t:parseFloat(t),isNaN(t)?e.def:s.mod?(t+s.mod)%s.mod:Math.min(s.max,Math.max(0,t)))}function S(s){var n=m(),o=n._rgba=[];return s=s.toLowerCase(),w(g,function(t,e){var i=e.re.exec(s),i=i&&e.parse(i),e=e.space||"rgba";if(i)return i=n[e](i),n[_[e].cache]=i[_[e].cache],o=n._rgba=i._rgba,!1}),o.length?("0,0,0,0"===o.join()&&d.extend(o,B.transparent),n):B[s]}function H(t,e,i){return 6*(i=(i+1)%1)<1?t+(e-t)*i*6:2*i<1?e:3*i<2?t+(e-t)*(2/3-i)*6:t}y.style.cssText="background-color:rgba(1,1,1,.5)",b.rgba=-1<y.style.backgroundColor.indexOf("rgba"),w(_,function(t,e){e.cache="_"+t,e.props.alpha={idx:3,type:"percent",def:1}}),d.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(t,e){p["[object "+e+"]"]=e.toLowerCase()}),(m.fn=d.extend(m.prototype,{parse:function(n,t,e,i){if(void 0===n)return this._rgba=[null,null,null,null],this;(n.jquery||n.nodeType)&&(n=d(n).css(t),t=void 0);var o=this,s=P(n),a=this._rgba=[];return void 0!==t&&(n=[n,t,e,i],s="array"),"string"===s?this.parse(S(n)||B._default):"array"===s?(w(_.rgba.props,function(t,e){a[e.idx]=M(n[e.idx],e)}),this):"object"===s?(w(_,n instanceof m?function(t,e){n[e.cache]&&(o[e.cache]=n[e.cache].slice())}:function(t,i){var s=i.cache;w(i.props,function(t,e){if(!o[s]&&i.to){if("alpha"===t||null==n[t])return;o[s]=i.to(o._rgba)}o[s][e.idx]=M(n[t],e,!0)}),o[s]&&d.inArray(null,o[s].slice(0,3))<0&&(null==o[s][3]&&(o[s][3]=1),i.from&&(o._rgba=i.from(o[s])))}),this):void 0},is:function(t){var n=m(t),o=!0,a=this;return w(_,function(t,e){var i,s=n[e.cache];return s&&(i=a[e.cache]||e.to&&e.to(a._rgba)||[],w(e.props,function(t,e){if(null!=s[e.idx])return o=s[e.idx]===i[e.idx]})),o}),o},_space:function(){var i=[],s=this;return w(_,function(t,e){s[e.cache]&&i.push(t)}),i.pop()},transition:function(t,a){var e=(h=m(t))._space(),i=_[e],t=0===this.alpha()?m("transparent"):this,r=t[i.cache]||i.to(t._rgba),l=r.slice(),h=h[i.cache];return w(i.props,function(t,e){var i=e.idx,s=r[i],n=h[i],o=v[e.type]||{};null!==n&&(null===s?l[i]=n:(o.mod&&(n-s>o.mod/2?s+=o.mod:s-n>o.mod/2&&(s-=o.mod)),l[i]=M((n-s)*a+s,e)))}),this[e](l)},blend:function(t){if(1===this._rgba[3])return this;var e=this._rgba.slice(),i=e.pop(),s=m(t)._rgba;return m(d.map(e,function(t,e){return(1-i)*s[e]+i*t}))},toRgbaString:function(){var t="rgba(",e=d.map(this._rgba,function(t,e){return null!=t?t:2<e?1:0});return 1===e[3]&&(e.pop(),t="rgb("),t+e.join()+")"},toHslaString:function(){var t="hsla(",e=d.map(this.hsla(),function(t,e){return null==t&&(t=2<e?1:0),t=e&&e<3?Math.round(100*t)+"%":t});return 1===e[3]&&(e.pop(),t="hsl("),t+e.join()+")"},toHexString:function(t){var e=this._rgba.slice(),i=e.pop();return t&&e.push(~~(255*i)),"#"+d.map(e,function(t){return 1===(t=(t||0).toString(16)).length?"0"+t:t}).join("")},toString:function(){return 0===this._rgba[3]?"transparent":this.toRgbaString()}})).parse.prototype=m.fn,_.hsla.to=function(t){if(null==t[0]||null==t[1]||null==t[2])return[null,null,null,t[3]];var e=t[0]/255,i=t[1]/255,s=t[2]/255,n=t[3],o=Math.max(e,i,s),a=Math.min(e,i,s),r=o-a,l=o+a,t=.5*l,i=a===o?0:e===o?60*(i-s)/r+360:i===o?60*(s-e)/r+120:60*(e-i)/r+240,l=0==r?0:t<=.5?r/l:r/(2-l);return[Math.round(i)%360,l,t,null==n?1:n]},_.hsla.from=function(t){if(null==t[0]||null==t[1]||null==t[2])return[null,null,null,t[3]];var e=t[0]/360,i=t[1],s=t[2],t=t[3],i=s<=.5?s*(1+i):s+i-s*i,s=2*s-i;return[Math.round(255*H(s,i,e+1/3)),Math.round(255*H(s,i,e)),Math.round(255*H(s,i,e-1/3)),t]},w(_,function(l,t){var e=t.props,o=t.cache,a=t.to,r=t.from;m.fn[l]=function(t){if(a&&!this[o]&&(this[o]=a(this._rgba)),void 0===t)return this[o].slice();var i=P(t),s="array"===i||"object"===i?t:arguments,n=this[o].slice();return w(e,function(t,e){t=s["object"===i?t:e.idx];null==t&&(t=n[e.idx]),n[e.idx]=M(t,e)}),r?((t=m(r(n)))[o]=n,t):m(n)},w(e,function(a,r){m.fn[a]||(m.fn[a]=function(t){var e,i=P(t),s="alpha"===a?this._hsla?"hsla":"rgba":l,n=this[s](),o=n[r.idx];return"undefined"===i?o:("function"===i&&(i=P(t=t.call(this,o))),null==t&&r.empty?this:("string"===i&&(e=f.exec(t))&&(t=o+parseFloat(e[2])*("+"===e[1]?1:-1)),n[r.idx]=t,this[s](n)))})})}),(m.hook=function(t){t=t.split(" ");w(t,function(t,o){d.cssHooks[o]={set:function(t,e){var i,s,n="";if("transparent"!==e&&("string"!==P(e)||(i=S(e)))){if(e=m(i||e),!b.rgba&&1!==e._rgba[3]){for(s="backgroundColor"===o?t.parentNode:t;(""===n||"transparent"===n)&&s&&s.style;)try{n=d.css(s,"backgroundColor"),s=s.parentNode}catch(t){}e=e.blend(n&&"transparent"!==n?n:"_default")}e=e.toRgbaString()}try{t.style[o]=e}catch(t){}}},d.fx.step[o]=function(t){t.colorInit||(t.start=m(t.elem,o),t.end=m(t.end),t.colorInit=!0),d.cssHooks[o].set(t.elem,t.start.transition(t.end,t.pos))}})})("backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor"),d.cssHooks.borderColor={expand:function(i){var s={};return w(["Top","Right","Bottom","Left"],function(t,e){s["border"+e+"Color"]=i}),s}};var z,A,O,N,E,W,F,L,R,Y,B=d.Color.names={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00",transparent:[null,null,null,0],_default:"#ffffff"},j="ui-effects-",q="ui-effects-style",K="ui-effects-animated";function U(t){var e,i,s=t.ownerDocument.defaultView?t.ownerDocument.defaultView.getComputedStyle(t,null):t.currentStyle,n={};if(s&&s.length&&s[0]&&s[s[0]])for(i=s.length;i--;)"string"==typeof s[e=s[i]]&&(n[e.replace(/-([\da-z])/gi,function(t,e){return e.toUpperCase()})]=s[e]);else for(e in s)"string"==typeof s[e]&&(n[e]=s[e]);return n}function X(t,e,i,s){return t={effect:t=V.isPlainObject(t)?(e=t).effect:t},"function"==typeof(e=null==e?{}:e)&&(s=e,i=null,e={}),"number"!=typeof e&&!V.fx.speeds[e]||(s=i,i=e,e={}),"function"==typeof i&&(s=i,i=null),e&&V.extend(t,e),i=i||e.duration,t.duration=V.fx.off?0:"number"==typeof i?i:i in V.fx.speeds?V.fx.speeds[i]:V.fx.speeds._default,t.complete=s||e.complete,t}function $(t){return!t||"number"==typeof t||V.fx.speeds[t]||("string"==typeof t&&!V.effects.effect[t]||("function"==typeof t||"object"==typeof t&&!t.effect))}function G(t,e){var i=e.outerWidth(),e=e.outerHeight(),t=/^rect\((-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto)\)$/.exec(t)||["",0,i,e,0];return{top:parseFloat(t[1])||0,right:"auto"===t[2]?i:parseFloat(t[2]),bottom:"auto"===t[3]?e:parseFloat(t[3]),left:parseFloat(t[4])||0}}V.effects={effect:{}},N=["add","remove","toggle"],E={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1},V.each(["borderLeftStyle","borderRightStyle","borderBottomStyle","borderTopStyle"],function(t,e){V.fx.step[e]=function(t){("none"!==t.end&&!t.setAttr||1===t.pos&&!t.setAttr)&&(d.style(t.elem,e,t.end),t.setAttr=!0)}}),V.fn.addBack||(V.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),V.effects.animateClass=function(n,t,e,i){var o=V.speed(t,e,i);return this.queue(function(){var i=V(this),t=i.attr("class")||"",e=(e=o.children?i.find("*").addBack():i).map(function(){return{el:V(this),start:U(this)}}),s=function(){V.each(N,function(t,e){n[e]&&i[e+"Class"](n[e])})};s(),e=e.map(function(){return this.end=U(this.el[0]),this.diff=function(t,e){var i,s,n={};for(i in e)s=e[i],t[i]!==s&&(E[i]||!V.fx.step[i]&&isNaN(parseFloat(s))||(n[i]=s));return n}(this.start,this.end),this}),i.attr("class",t),e=e.map(function(){var t=this,e=V.Deferred(),i=V.extend({},o,{queue:!1,complete:function(){e.resolve(t)}});return this.el.animate(this.diff,i),e.promise()}),V.when.apply(V,e.get()).done(function(){s(),V.each(arguments,function(){var e=this.el;V.each(this.diff,function(t){e.css(t,"")})}),o.complete.call(i[0])})})},V.fn.extend({addClass:(O=V.fn.addClass,function(t,e,i,s){return e?V.effects.animateClass.call(this,{add:t},e,i,s):O.apply(this,arguments)}),removeClass:(A=V.fn.removeClass,function(t,e,i,s){return 1<arguments.length?V.effects.animateClass.call(this,{remove:t},e,i,s):A.apply(this,arguments)}),toggleClass:(z=V.fn.toggleClass,function(t,e,i,s,n){return"boolean"==typeof e||void 0===e?i?V.effects.animateClass.call(this,e?{add:t}:{remove:t},i,s,n):z.apply(this,arguments):V.effects.animateClass.call(this,{toggle:t},e,i,s)}),switchClass:function(t,e,i,s,n){return V.effects.animateClass.call(this,{add:e,remove:t},i,s,n)}}),V.expr&&V.expr.pseudos&&V.expr.pseudos.animated&&(V.expr.pseudos.animated=(W=V.expr.pseudos.animated,function(t){return!!V(t).data(K)||W(t)})),!1!==V.uiBackCompat&&V.extend(V.effects,{save:function(t,e){for(var i=0,s=e.length;i<s;i++)null!==e[i]&&t.data(j+e[i],t[0].style[e[i]])},restore:function(t,e){for(var i,s=0,n=e.length;s<n;s++)null!==e[s]&&(i=t.data(j+e[s]),t.css(e[s],i))},setMode:function(t,e){return e="toggle"===e?t.is(":hidden")?"show":"hide":e},createWrapper:function(i){if(i.parent().is(".ui-effects-wrapper"))return i.parent();var s={width:i.outerWidth(!0),height:i.outerHeight(!0),float:i.css("float")},t=V("<div></div>").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),e={width:i.width(),height:i.height()},n=document.activeElement;try{n.id}catch(t){n=document.body}return i.wrap(t),i[0]!==n&&!V.contains(i[0],n)||V(n).trigger("focus"),t=i.parent(),"static"===i.css("position")?(t.css({position:"relative"}),i.css({position:"relative"})):(V.extend(s,{position:i.css("position"),zIndex:i.css("z-index")}),V.each(["top","left","bottom","right"],function(t,e){s[e]=i.css(e),isNaN(parseInt(s[e],10))&&(s[e]="auto")}),i.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})),i.css(e),t.css(s).show()},removeWrapper:function(t){var e=document.activeElement;return t.parent().is(".ui-effects-wrapper")&&(t.parent().replaceWith(t),t[0]!==e&&!V.contains(t[0],e)||V(e).trigger("focus")),t}}),V.extend(V.effects,{version:"1.13.2",define:function(t,e,i){return i||(i=e,e="effect"),V.effects.effect[t]=i,V.effects.effect[t].mode=e,i},scaledDimensions:function(t,e,i){if(0===e)return{height:0,width:0,outerHeight:0,outerWidth:0};var s="horizontal"!==i?(e||100)/100:1,e="vertical"!==i?(e||100)/100:1;return{height:t.height()*e,width:t.width()*s,outerHeight:t.outerHeight()*e,outerWidth:t.outerWidth()*s}},clipToBox:function(t){return{width:t.clip.right-t.clip.left,height:t.clip.bottom-t.clip.top,left:t.clip.left,top:t.clip.top}},unshift:function(t,e,i){var s=t.queue();1<e&&s.splice.apply(s,[1,0].concat(s.splice(e,i))),t.dequeue()},saveStyle:function(t){t.data(q,t[0].style.cssText)},restoreStyle:function(t){t[0].style.cssText=t.data(q)||"",t.removeData(q)},mode:function(t,e){t=t.is(":hidden");return"toggle"===e&&(e=t?"show":"hide"),e=(t?"hide"===e:"show"===e)?"none":e},getBaseline:function(t,e){var i,s;switch(t[0]){case"top":i=0;break;case"middle":i=.5;break;case"bottom":i=1;break;default:i=t[0]/e.height}switch(t[1]){case"left":s=0;break;case"center":s=.5;break;case"right":s=1;break;default:s=t[1]/e.width}return{x:s,y:i}},createPlaceholder:function(t){var e,i=t.css("position"),s=t.position();return t.css({marginTop:t.css("marginTop"),marginBottom:t.css("marginBottom"),marginLeft:t.css("marginLeft"),marginRight:t.css("marginRight")}).outerWidth(t.outerWidth()).outerHeight(t.outerHeight()),/^(static|relative)/.test(i)&&(i="absolute",e=V("<"+t[0].nodeName+">").insertAfter(t).css({display:/^(inline|ruby)/.test(t.css("display"))?"inline-block":"block",visibility:"hidden",marginTop:t.css("marginTop"),marginBottom:t.css("marginBottom"),marginLeft:t.css("marginLeft"),marginRight:t.css("marginRight"),float:t.css("float")}).outerWidth(t.outerWidth()).outerHeight(t.outerHeight()).addClass("ui-effects-placeholder"),t.data(j+"placeholder",e)),t.css({position:i,left:s.left,top:s.top}),e},removePlaceholder:function(t){var e=j+"placeholder",i=t.data(e);i&&(i.remove(),t.removeData(e))},cleanUp:function(t){V.effects.restoreStyle(t),V.effects.removePlaceholder(t)},setTransition:function(s,t,n,o){return o=o||{},V.each(t,function(t,e){var i=s.cssUnit(e);0<i[0]&&(o[e]=i[0]*n+i[1])}),o}}),V.fn.extend({effect:function(){function t(t){var e=V(this),i=V.effects.mode(e,r)||o;e.data(K,!0),l.push(i),o&&("show"===i||i===o&&"hide"===i)&&e.show(),o&&"none"===i||V.effects.saveStyle(e),"function"==typeof t&&t()}var s=X.apply(this,arguments),n=V.effects.effect[s.effect],o=n.mode,e=s.queue,i=e||"fx",a=s.complete,r=s.mode,l=[];return V.fx.off||!n?r?this[r](s.duration,a):this.each(function(){a&&a.call(this)}):!1===e?this.each(t).each(h):this.queue(i,t).queue(i,h);function h(t){var e=V(this);function i(){"function"==typeof a&&a.call(e[0]),"function"==typeof t&&t()}s.mode=l.shift(),!1===V.uiBackCompat||o?"none"===s.mode?(e[r](),i()):n.call(e[0],s,function(){e.removeData(K),V.effects.cleanUp(e),"hide"===s.mode&&e.hide(),i()}):(e.is(":hidden")?"hide"===r:"show"===r)?(e[r](),i()):n.call(e[0],s,i)}},show:(R=V.fn.show,function(t){if($(t))return R.apply(this,arguments);t=X.apply(this,arguments);return t.mode="show",this.effect.call(this,t)}),hide:(L=V.fn.hide,function(t){if($(t))return L.apply(this,arguments);t=X.apply(this,arguments);return t.mode="hide",this.effect.call(this,t)}),toggle:(F=V.fn.toggle,function(t){if($(t)||"boolean"==typeof t)return F.apply(this,arguments);t=X.apply(this,arguments);return t.mode="toggle",this.effect.call(this,t)}),cssUnit:function(t){var i=this.css(t),s=[];return V.each(["em","px","%","pt"],function(t,e){0<i.indexOf(e)&&(s=[parseFloat(i),e])}),s},cssClip:function(t){return t?this.css("clip","rect("+t.top+"px "+t.right+"px "+t.bottom+"px "+t.left+"px)"):G(this.css("clip"),this)},transfer:function(t,e){var i=V(this),s=V(t.to),n="fixed"===s.css("position"),o=V("body"),a=n?o.scrollTop():0,r=n?o.scrollLeft():0,o=s.offset(),o={top:o.top-a,left:o.left-r,height:s.innerHeight(),width:s.innerWidth()},s=i.offset(),l=V("<div class='ui-effects-transfer'></div>");l.appendTo("body").addClass(t.className).css({top:s.top-a,left:s.left-r,height:i.innerHeight(),width:i.innerWidth(),position:n?"fixed":"absolute"}).animate(o,t.duration,t.easing,function(){l.remove(),"function"==typeof e&&e()})}}),V.fx.step.clip=function(t){t.clipInit||(t.start=V(t.elem).cssClip(),"string"==typeof t.end&&(t.end=G(t.end,t.elem)),t.clipInit=!0),V(t.elem).cssClip({top:t.pos*(t.end.top-t.start.top)+t.start.top,right:t.pos*(t.end.right-t.start.right)+t.start.right,bottom:t.pos*(t.end.bottom-t.start.bottom)+t.start.bottom,left:t.pos*(t.end.left-t.start.left)+t.start.left})},Y={},V.each(["Quad","Cubic","Quart","Quint","Expo"],function(e,t){Y[t]=function(t){return Math.pow(t,e+2)}}),V.extend(Y,{Sine:function(t){return 1-Math.cos(t*Math.PI/2)},Circ:function(t){return 1-Math.sqrt(1-t*t)},Elastic:function(t){return 0===t||1===t?t:-Math.pow(2,8*(t-1))*Math.sin((80*(t-1)-7.5)*Math.PI/15)},Back:function(t){return t*t*(3*t-2)},Bounce:function(t){for(var e,i=4;t<((e=Math.pow(2,--i))-1)/11;);return 1/Math.pow(4,3-i)-7.5625*Math.pow((3*e-2)/22-t,2)}}),V.each(Y,function(t,e){V.easing["easeIn"+t]=e,V.easing["easeOut"+t]=function(t){return 1-e(1-t)},V.easing["easeInOut"+t]=function(t){return t<.5?e(2*t)/2:1-e(-2*t+2)/2}});y=V.effects,V.effects.define("blind","hide",function(t,e){var i={up:["bottom","top"],vertical:["bottom","top"],down:["top","bottom"],left:["right","left"],horizontal:["right","left"],right:["left","right"]},s=V(this),n=t.direction||"up",o=s.cssClip(),a={clip:V.extend({},o)},r=V.effects.createPlaceholder(s);a.clip[i[n][0]]=a.clip[i[n][1]],"show"===t.mode&&(s.cssClip(a.clip),r&&r.css(V.effects.clipToBox(a)),a.clip=o),r&&r.animate(V.effects.clipToBox(a),t.duration,t.easing),s.animate(a,{queue:!1,duration:t.duration,easing:t.easing,complete:e})}),V.effects.define("bounce",function(t,e){var i,s,n=V(this),o=t.mode,a="hide"===o,r="show"===o,l=t.direction||"up",h=t.distance,c=t.times||5,o=2*c+(r||a?1:0),u=t.duration/o,d=t.easing,p="up"===l||"down"===l?"top":"left",f="up"===l||"left"===l,g=0,t=n.queue().length;for(V.effects.createPlaceholder(n),l=n.css(p),h=h||n["top"==p?"outerHeight":"outerWidth"]()/3,r&&((s={opacity:1})[p]=l,n.css("opacity",0).css(p,f?2*-h:2*h).animate(s,u,d)),a&&(h/=Math.pow(2,c-1)),(s={})[p]=l;g<c;g++)(i={})[p]=(f?"-=":"+=")+h,n.animate(i,u,d).animate(s,u,d),h=a?2*h:h/2;a&&((i={opacity:0})[p]=(f?"-=":"+=")+h,n.animate(i,u,d)),n.queue(e),V.effects.unshift(n,t,1+o)}),V.effects.define("clip","hide",function(t,e){var i={},s=V(this),n=t.direction||"vertical",o="both"===n,a=o||"horizontal"===n,o=o||"vertical"===n,n=s.cssClip();i.clip={top:o?(n.bottom-n.top)/2:n.top,right:a?(n.right-n.left)/2:n.right,bottom:o?(n.bottom-n.top)/2:n.bottom,left:a?(n.right-n.left)/2:n.left},V.effects.createPlaceholder(s),"show"===t.mode&&(s.cssClip(i.clip),i.clip=n),s.animate(i,{queue:!1,duration:t.duration,easing:t.easing,complete:e})}),V.effects.define("drop","hide",function(t,e){var i=V(this),s="show"===t.mode,n=t.direction||"left",o="up"===n||"down"===n?"top":"left",a="up"===n||"left"===n?"-=":"+=",r="+="==a?"-=":"+=",l={opacity:0};V.effects.createPlaceholder(i),n=t.distance||i["top"==o?"outerHeight":"outerWidth"](!0)/2,l[o]=a+n,s&&(i.css(l),l[o]=r+n,l.opacity=1),i.animate(l,{queue:!1,duration:t.duration,easing:t.easing,complete:e})}),V.effects.define("explode","hide",function(t,e){var i,s,n,o,a,r,l=t.pieces?Math.round(Math.sqrt(t.pieces)):3,h=l,c=V(this),u="show"===t.mode,d=c.show().css("visibility","hidden").offset(),p=Math.ceil(c.outerWidth()/h),f=Math.ceil(c.outerHeight()/l),g=[];function m(){g.push(this),g.length===l*h&&(c.css({visibility:"visible"}),V(g).remove(),e())}for(i=0;i<l;i++)for(o=d.top+i*f,r=i-(l-1)/2,s=0;s<h;s++)n=d.left+s*p,a=s-(h-1)/2,c.clone().appendTo("body").wrap("<div></div>").css({position:"absolute",visibility:"visible",left:-s*p,top:-i*f}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:p,height:f,left:n+(u?a*p:0),top:o+(u?r*f:0),opacity:u?0:1}).animate({left:n+(u?0:a*p),top:o+(u?0:r*f),opacity:u?1:0},t.duration||500,t.easing,m)}),V.effects.define("fade","toggle",function(t,e){var i="show"===t.mode;V(this).css("opacity",i?0:1).animate({opacity:i?1:0},{queue:!1,duration:t.duration,easing:t.easing,complete:e})}),V.effects.define("fold","hide",function(e,t){var i=V(this),s=e.mode,n="show"===s,o="hide"===s,a=e.size||15,r=/([0-9]+)%/.exec(a),l=!!e.horizFirst?["right","bottom"]:["bottom","right"],h=e.duration/2,c=V.effects.createPlaceholder(i),u=i.cssClip(),d={clip:V.extend({},u)},p={clip:V.extend({},u)},f=[u[l[0]],u[l[1]]],s=i.queue().length;r&&(a=parseInt(r[1],10)/100*f[o?0:1]),d.clip[l[0]]=a,p.clip[l[0]]=a,p.clip[l[1]]=0,n&&(i.cssClip(p.clip),c&&c.css(V.effects.clipToBox(p)),p.clip=u),i.queue(function(t){c&&c.animate(V.effects.clipToBox(d),h,e.easing).animate(V.effects.clipToBox(p),h,e.easing),t()}).animate(d,h,e.easing).animate(p,h,e.easing).queue(t),V.effects.unshift(i,s,4)}),V.effects.define("highlight","show",function(t,e){var i=V(this),s={backgroundColor:i.css("backgroundColor")};"hide"===t.mode&&(s.opacity=0),V.effects.saveStyle(i),i.css({backgroundImage:"none",backgroundColor:t.color||"#ffff99"}).animate(s,{queue:!1,duration:t.duration,easing:t.easing,complete:e})}),V.effects.define("size",function(s,e){var n,i=V(this),t=["fontSize"],o=["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"],a=["borderLeftWidth","borderRightWidth","paddingLeft","paddingRight"],r=s.mode,l="effect"!==r,h=s.scale||"both",c=s.origin||["middle","center"],u=i.css("position"),d=i.position(),p=V.effects.scaledDimensions(i),f=s.from||p,g=s.to||V.effects.scaledDimensions(i,0);V.effects.createPlaceholder(i),"show"===r&&(r=f,f=g,g=r),n={from:{y:f.height/p.height,x:f.width/p.width},to:{y:g.height/p.height,x:g.width/p.width}},"box"!==h&&"both"!==h||(n.from.y!==n.to.y&&(f=V.effects.setTransition(i,o,n.from.y,f),g=V.effects.setTransition(i,o,n.to.y,g)),n.from.x!==n.to.x&&(f=V.effects.setTransition(i,a,n.from.x,f),g=V.effects.setTransition(i,a,n.to.x,g))),"content"!==h&&"both"!==h||n.from.y!==n.to.y&&(f=V.effects.setTransition(i,t,n.from.y,f),g=V.effects.setTransition(i,t,n.to.y,g)),c&&(c=V.effects.getBaseline(c,p),f.top=(p.outerHeight-f.outerHeight)*c.y+d.top,f.left=(p.outerWidth-f.outerWidth)*c.x+d.left,g.top=(p.outerHeight-g.outerHeight)*c.y+d.top,g.left=(p.outerWidth-g.outerWidth)*c.x+d.left),delete f.outerHeight,delete f.outerWidth,i.css(f),"content"!==h&&"both"!==h||(o=o.concat(["marginTop","marginBottom"]).concat(t),a=a.concat(["marginLeft","marginRight"]),i.find("*[width]").each(function(){var t=V(this),e=V.effects.scaledDimensions(t),i={height:e.height*n.from.y,width:e.width*n.from.x,outerHeight:e.outerHeight*n.from.y,outerWidth:e.outerWidth*n.from.x},e={height:e.height*n.to.y,width:e.width*n.to.x,outerHeight:e.height*n.to.y,outerWidth:e.width*n.to.x};n.from.y!==n.to.y&&(i=V.effects.setTransition(t,o,n.from.y,i),e=V.effects.setTransition(t,o,n.to.y,e)),n.from.x!==n.to.x&&(i=V.effects.setTransition(t,a,n.from.x,i),e=V.effects.setTransition(t,a,n.to.x,e)),l&&V.effects.saveStyle(t),t.css(i),t.animate(e,s.duration,s.easing,function(){l&&V.effects.restoreStyle(t)})})),i.animate(g,{queue:!1,duration:s.duration,easing:s.easing,complete:function(){var t=i.offset();0===g.opacity&&i.css("opacity",f.opacity),l||(i.css("position","static"===u?"relative":u).offset(t),V.effects.saveStyle(i)),e()}})}),V.effects.define("scale",function(t,e){var i=V(this),s=t.mode,s=parseInt(t.percent,10)||(0===parseInt(t.percent,10)||"effect"!==s?0:100),s=V.extend(!0,{from:V.effects.scaledDimensions(i),to:V.effects.scaledDimensions(i,s,t.direction||"both"),origin:t.origin||["middle","center"]},t);t.fade&&(s.from.opacity=1,s.to.opacity=0),V.effects.effect.size.call(this,s,e)}),V.effects.define("puff","hide",function(t,e){t=V.extend(!0,{},t,{fade:!0,percent:parseInt(t.percent,10)||150});V.effects.effect.scale.call(this,t,e)}),V.effects.define("pulsate","show",function(t,e){var i=V(this),s=t.mode,n="show"===s,o=2*(t.times||5)+(n||"hide"===s?1:0),a=t.duration/o,r=0,l=1,s=i.queue().length;for(!n&&i.is(":visible")||(i.css("opacity",0).show(),r=1);l<o;l++)i.animate({opacity:r},a,t.easing),r=1-r;i.animate({opacity:r},a,t.easing),i.queue(e),V.effects.unshift(i,s,1+o)}),V.effects.define("shake",function(t,e){var i=1,s=V(this),n=t.direction||"left",o=t.distance||20,a=t.times||3,r=2*a+1,l=Math.round(t.duration/r),h="up"===n||"down"===n?"top":"left",c="up"===n||"left"===n,u={},d={},p={},n=s.queue().length;for(V.effects.createPlaceholder(s),u[h]=(c?"-=":"+=")+o,d[h]=(c?"+=":"-=")+2*o,p[h]=(c?"-=":"+=")+2*o,s.animate(u,l,t.easing);i<a;i++)s.animate(d,l,t.easing).animate(p,l,t.easing);s.animate(d,l,t.easing).animate(u,l/2,t.easing).queue(e),V.effects.unshift(s,n,1+r)}),V.effects.define("slide","show",function(t,e){var i,s,n=V(this),o={up:["bottom","top"],down:["top","bottom"],left:["right","left"],right:["left","right"]},a=t.mode,r=t.direction||"left",l="up"===r||"down"===r?"top":"left",h="up"===r||"left"===r,c=t.distance||n["top"==l?"outerHeight":"outerWidth"](!0),u={};V.effects.createPlaceholder(n),i=n.cssClip(),s=n.position()[l],u[l]=(h?-1:1)*c+s,u.clip=n.cssClip(),u.clip[o[r][1]]=u.clip[o[r][0]],"show"===a&&(n.cssClip(u.clip),n.css(l,u[l]),u.clip=i,u[l]=s),n.animate(u,{queue:!1,duration:t.duration,easing:t.easing,complete:e})}),y=!1!==V.uiBackCompat?V.effects.define("transfer",function(t,e){V(this).transfer(t,e)}):y;V.ui.focusable=function(t,e){var i,s,n,o,a=t.nodeName.toLowerCase();return"area"===a?(s=(i=t.parentNode).name,!(!t.href||!s||"map"!==i.nodeName.toLowerCase())&&(0<(s=V("img[usemap='#"+s+"']")).length&&s.is(":visible"))):(/^(input|select|textarea|button|object)$/.test(a)?(n=!t.disabled)&&(o=V(t).closest("fieldset")[0])&&(n=!o.disabled):n="a"===a&&t.href||e,n&&V(t).is(":visible")&&function(t){var e=t.css("visibility");for(;"inherit"===e;)t=t.parent(),e=t.css("visibility");return"visible"===e}(V(t)))},V.extend(V.expr.pseudos,{focusable:function(t){return V.ui.focusable(t,null!=V.attr(t,"tabindex"))}});var Q,J;V.ui.focusable,V.fn._form=function(){return"string"==typeof this[0].form?this.closest("form"):V(this[0].form)},V.ui.formResetMixin={_formResetHandler:function(){var e=V(this);setTimeout(function(){var t=e.data("ui-form-reset-instances");V.each(t,function(){this.refresh()})})},_bindFormResetHandler:function(){var t;this.form=this.element._form(),this.form.length&&((t=this.form.data("ui-form-reset-instances")||[]).length||this.form.on("reset.ui-form-reset",this._formResetHandler),t.push(this),this.form.data("ui-form-reset-instances",t))},_unbindFormResetHandler:function(){var t;this.form.length&&((t=this.form.data("ui-form-reset-instances")).splice(V.inArray(this,t),1),t.length?this.form.data("ui-form-reset-instances",t):this.form.removeData("ui-form-reset-instances").off("reset.ui-form-reset"))}};V.expr.pseudos||(V.expr.pseudos=V.expr[":"]),V.uniqueSort||(V.uniqueSort=V.unique),V.escapeSelector||(Q=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g,J=function(t,e){return e?"\0"===t?"�":t.slice(0,-1)+"\\"+t.charCodeAt(t.length-1).toString(16)+" ":"\\"+t},V.escapeSelector=function(t){return(t+"").replace(Q,J)}),V.fn.even&&V.fn.odd||V.fn.extend({even:function(){return this.filter(function(t){return t%2==0})},odd:function(){return this.filter(function(t){return t%2==1})}});var Z;V.ui.keyCode={BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38},V.fn.labels=function(){var t,e,i;return this.length?this[0].labels&&this[0].labels.length?this.pushStack(this[0].labels):(e=this.eq(0).parents("label"),(t=this.attr("id"))&&(i=(i=this.eq(0).parents().last()).add((i.length?i:this).siblings()),t="label[for='"+V.escapeSelector(t)+"']",e=e.add(i.find(t).addBack(t))),this.pushStack(e)):this.pushStack([])},V.fn.scrollParent=function(t){var e=this.css("position"),i="absolute"===e,s=t?/(auto|scroll|hidden)/:/(auto|scroll)/,t=this.parents().filter(function(){var t=V(this);return(!i||"static"!==t.css("position"))&&s.test(t.css("overflow")+t.css("overflow-y")+t.css("overflow-x"))}).eq(0);return"fixed"!==e&&t.length?t:V(this[0].ownerDocument||document)},V.extend(V.expr.pseudos,{tabbable:function(t){var e=V.attr(t,"tabindex"),i=null!=e;return(!i||0<=e)&&V.ui.focusable(t,i)}}),V.fn.extend({uniqueId:(Z=0,function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++Z)})}),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&V(this).removeAttr("id")})}}),V.widget("ui.accordion",{version:"1.13.2",options:{active:0,animate:{},classes:{"ui-accordion-header":"ui-corner-top","ui-accordion-header-collapsed":"ui-corner-all","ui-accordion-content":"ui-corner-bottom"},collapsible:!1,event:"click",header:function(t){return t.find("> li > :first-child").add(t.find("> :not(li)").even())},heightStyle:"auto",icons:{activeHeader:"ui-icon-triangle-1-s",header:"ui-icon-triangle-1-e"},activate:null,beforeActivate:null},hideProps:{borderTopWidth:"hide",borderBottomWidth:"hide",paddingTop:"hide",paddingBottom:"hide",height:"hide"},showProps:{borderTopWidth:"show",borderBottomWidth:"show",paddingTop:"show",paddingBottom:"show",height:"show"},_create:function(){var t=this.options;this.prevShow=this.prevHide=V(),this._addClass("ui-accordion","ui-widget ui-helper-reset"),this.element.attr("role","tablist"),t.collapsible||!1!==t.active&&null!=t.active||(t.active=0),this._processPanels(),t.active<0&&(t.active+=this.headers.length),this._refresh()},_getCreateEventData:function(){return{header:this.active,panel:this.active.length?this.active.next():V()}},_createIcons:function(){var t,e=this.options.icons;e&&(t=V("<span>"),this._addClass(t,"ui-accordion-header-icon","ui-icon "+e.header),t.prependTo(this.headers),t=this.active.children(".ui-accordion-header-icon"),this._removeClass(t,e.header)._addClass(t,null,e.activeHeader)._addClass(this.headers,"ui-accordion-icons"))},_destroyIcons:function(){this._removeClass(this.headers,"ui-accordion-icons"),this.headers.children(".ui-accordion-header-icon").remove()},_destroy:function(){var t;this.element.removeAttr("role"),this.headers.removeAttr("role aria-expanded aria-selected aria-controls tabIndex").removeUniqueId(),this._destroyIcons(),t=this.headers.next().css("display","").removeAttr("role aria-hidden aria-labelledby").removeUniqueId(),"content"!==this.options.heightStyle&&t.css("height","")},_setOption:function(t,e){"active"!==t?("event"===t&&(this.options.event&&this._off(this.headers,this.options.event),this._setupEvents(e)),this._super(t,e),"collapsible"!==t||e||!1!==this.options.active||this._activate(0),"icons"===t&&(this._destroyIcons(),e&&this._createIcons())):this._activate(e)},_setOptionDisabled:function(t){this._super(t),this.element.attr("aria-disabled",t),this._toggleClass(null,"ui-state-disabled",!!t),this._toggleClass(this.headers.add(this.headers.next()),null,"ui-state-disabled",!!t)},_keydown:function(t){if(!t.altKey&&!t.ctrlKey){var e=V.ui.keyCode,i=this.headers.length,s=this.headers.index(t.target),n=!1;switch(t.keyCode){case e.RIGHT:case e.DOWN:n=this.headers[(s+1)%i];break;case e.LEFT:case e.UP:n=this.headers[(s-1+i)%i];break;case e.SPACE:case e.ENTER:this._eventHandler(t);break;case e.HOME:n=this.headers[0];break;case e.END:n=this.headers[i-1]}n&&(V(t.target).attr("tabIndex",-1),V(n).attr("tabIndex",0),V(n).trigger("focus"),t.preventDefault())}},_panelKeyDown:function(t){t.keyCode===V.ui.keyCode.UP&&t.ctrlKey&&V(t.currentTarget).prev().trigger("focus")},refresh:function(){var t=this.options;this._processPanels(),!1===t.active&&!0===t.collapsible||!this.headers.length?(t.active=!1,this.active=V()):!1===t.active?this._activate(0):this.active.length&&!V.contains(this.element[0],this.active[0])?this.headers.length===this.headers.find(".ui-state-disabled").length?(t.active=!1,this.active=V()):this._activate(Math.max(0,t.active-1)):t.active=this.headers.index(this.active),this._destroyIcons(),this._refresh()},_processPanels:function(){var t=this.headers,e=this.panels;"function"==typeof this.options.header?this.headers=this.options.header(this.element):this.headers=this.element.find(this.options.header),this._addClass(this.headers,"ui-accordion-header ui-accordion-header-collapsed","ui-state-default"),this.panels=this.headers.next().filter(":not(.ui-accordion-content-active)").hide(),this._addClass(this.panels,"ui-accordion-content","ui-helper-reset ui-widget-content"),e&&(this._off(t.not(this.headers)),this._off(e.not(this.panels)))},_refresh:function(){var i,t=this.options,e=t.heightStyle,s=this.element.parent();this.active=this._findActive(t.active),this._addClass(this.active,"ui-accordion-header-active","ui-state-active")._removeClass(this.active,"ui-accordion-header-collapsed"),this._addClass(this.active.next(),"ui-accordion-content-active"),this.active.next().show(),this.headers.attr("role","tab").each(function(){var t=V(this),e=t.uniqueId().attr("id"),i=t.next(),s=i.uniqueId().attr("id");t.attr("aria-controls",s),i.attr("aria-labelledby",e)}).next().attr("role","tabpanel"),this.headers.not(this.active).attr({"aria-selected":"false","aria-expanded":"false",tabIndex:-1}).next().attr({"aria-hidden":"true"}).hide(),this.active.length?this.active.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0}).next().attr({"aria-hidden":"false"}):this.headers.eq(0).attr("tabIndex",0),this._createIcons(),this._setupEvents(t.event),"fill"===e?(i=s.height(),this.element.siblings(":visible").each(function(){var t=V(this),e=t.css("position");"absolute"!==e&&"fixed"!==e&&(i-=t.outerHeight(!0))}),this.headers.each(function(){i-=V(this).outerHeight(!0)}),this.headers.next().each(function(){V(this).height(Math.max(0,i-V(this).innerHeight()+V(this).height()))}).css("overflow","auto")):"auto"===e&&(i=0,this.headers.next().each(function(){var t=V(this).is(":visible");t||V(this).show(),i=Math.max(i,V(this).css("height","").height()),t||V(this).hide()}).height(i))},_activate:function(t){t=this._findActive(t)[0];t!==this.active[0]&&(t=t||this.active[0],this._eventHandler({target:t,currentTarget:t,preventDefault:V.noop}))},_findActive:function(t){return"number"==typeof t?this.headers.eq(t):V()},_setupEvents:function(t){var i={keydown:"_keydown"};t&&V.each(t.split(" "),function(t,e){i[e]="_eventHandler"}),this._off(this.headers.add(this.headers.next())),this._on(this.headers,i),this._on(this.headers.next(),{keydown:"_panelKeyDown"}),this._hoverable(this.headers),this._focusable(this.headers)},_eventHandler:function(t){var e=this.options,i=this.active,s=V(t.currentTarget),n=s[0]===i[0],o=n&&e.collapsible,a=o?V():s.next(),r=i.next(),a={oldHeader:i,oldPanel:r,newHeader:o?V():s,newPanel:a};t.preventDefault(),n&&!e.collapsible||!1===this._trigger("beforeActivate",t,a)||(e.active=!o&&this.headers.index(s),this.active=n?V():s,this._toggle(a),this._removeClass(i,"ui-accordion-header-active","ui-state-active"),e.icons&&(i=i.children(".ui-accordion-header-icon"),this._removeClass(i,null,e.icons.activeHeader)._addClass(i,null,e.icons.header)),n||(this._removeClass(s,"ui-accordion-header-collapsed")._addClass(s,"ui-accordion-header-active","ui-state-active"),e.icons&&(n=s.children(".ui-accordion-header-icon"),this._removeClass(n,null,e.icons.header)._addClass(n,null,e.icons.activeHeader)),this._addClass(s.next(),"ui-accordion-content-active")))},_toggle:function(t){var e=t.newPanel,i=this.prevShow.length?this.prevShow:t.oldPanel;this.prevShow.add(this.prevHide).stop(!0,!0),this.prevShow=e,this.prevHide=i,this.options.animate?this._animate(e,i,t):(i.hide(),e.show(),this._toggleComplete(t)),i.attr({"aria-hidden":"true"}),i.prev().attr({"aria-selected":"false","aria-expanded":"false"}),e.length&&i.length?i.prev().attr({tabIndex:-1,"aria-expanded":"false"}):e.length&&this.headers.filter(function(){return 0===parseInt(V(this).attr("tabIndex"),10)}).attr("tabIndex",-1),e.attr("aria-hidden","false").prev().attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0})},_animate:function(t,i,e){var s,n,o,a=this,r=0,l=t.css("box-sizing"),h=t.length&&(!i.length||t.index()<i.index()),c=this.options.animate||{},u=h&&c.down||c,h=function(){a._toggleComplete(e)};return n=(n="string"==typeof u?u:n)||u.easing||c.easing,o=(o="number"==typeof u?u:o)||u.duration||c.duration,i.length?t.length?(s=t.show().outerHeight(),i.animate(this.hideProps,{duration:o,easing:n,step:function(t,e){e.now=Math.round(t)}}),void t.hide().animate(this.showProps,{duration:o,easing:n,complete:h,step:function(t,e){e.now=Math.round(t),"height"!==e.prop?"content-box"===l&&(r+=e.now):"content"!==a.options.heightStyle&&(e.now=Math.round(s-i.outerHeight()-r),r=0)}})):i.animate(this.hideProps,o,n,h):t.animate(this.showProps,o,n,h)},_toggleComplete:function(t){var e=t.oldPanel,i=e.prev();this._removeClass(e,"ui-accordion-content-active"),this._removeClass(i,"ui-accordion-header-active")._addClass(i,"ui-accordion-header-collapsed"),e.length&&(e.parent()[0].className=e.parent()[0].className),this._trigger("activate",null,t)}}),V.ui.safeActiveElement=function(e){var i;try{i=e.activeElement}catch(t){i=e.body}return i=!(i=i||e.body).nodeName?e.body:i},V.widget("ui.menu",{version:"1.13.2",defaultElement:"<ul>",delay:300,options:{icons:{submenu:"ui-icon-caret-1-e"},items:"> *",menus:"ul",position:{my:"left top",at:"right top"},role:"menu",blur:null,focus:null,select:null},_create:function(){this.activeMenu=this.element,this.mouseHandled=!1,this.lastMousePosition={x:null,y:null},this.element.uniqueId().attr({role:this.options.role,tabIndex:0}),this._addClass("ui-menu","ui-widget ui-widget-content"),this._on({"mousedown .ui-menu-item":function(t){t.preventDefault(),this._activateItem(t)},"click .ui-menu-item":function(t){var e=V(t.target),i=V(V.ui.safeActiveElement(this.document[0]));!this.mouseHandled&&e.not(".ui-state-disabled").length&&(this.select(t),t.isPropagationStopped()||(this.mouseHandled=!0),e.has(".ui-menu").length?this.expand(t):!this.element.is(":focus")&&i.closest(".ui-menu").length&&(this.element.trigger("focus",[!0]),this.active&&1===this.active.parents(".ui-menu").length&&clearTimeout(this.timer)))},"mouseenter .ui-menu-item":"_activateItem","mousemove .ui-menu-item":"_activateItem",mouseleave:"collapseAll","mouseleave .ui-menu":"collapseAll",focus:function(t,e){var i=this.active||this._menuItems().first();e||this.focus(t,i)},blur:function(t){this._delay(function(){V.contains(this.element[0],V.ui.safeActiveElement(this.document[0]))||this.collapseAll(t)})},keydown:"_keydown"}),this.refresh(),this._on(this.document,{click:function(t){this._closeOnDocumentClick(t)&&this.collapseAll(t,!0),this.mouseHandled=!1}})},_activateItem:function(t){var e,i;this.previousFilter||t.clientX===this.lastMousePosition.x&&t.clientY===this.lastMousePosition.y||(this.lastMousePosition={x:t.clientX,y:t.clientY},e=V(t.target).closest(".ui-menu-item"),i=V(t.currentTarget),e[0]===i[0]&&(i.is(".ui-state-active")||(this._removeClass(i.siblings().children(".ui-state-active"),null,"ui-state-active"),this.focus(t,i))))},_destroy:function(){var t=this.element.find(".ui-menu-item").removeAttr("role aria-disabled").children(".ui-menu-item-wrapper").removeUniqueId().removeAttr("tabIndex role aria-haspopup");this.element.removeAttr("aria-activedescendant").find(".ui-menu").addBack().removeAttr("role aria-labelledby aria-expanded aria-hidden aria-disabled tabIndex").removeUniqueId().show(),t.children().each(function(){var t=V(this);t.data("ui-menu-submenu-caret")&&t.remove()})},_keydown:function(t){var e,i,s,n=!0;switch(t.keyCode){case V.ui.keyCode.PAGE_UP:this.previousPage(t);break;case V.ui.keyCode.PAGE_DOWN:this.nextPage(t);break;case V.ui.keyCode.HOME:this._move("first","first",t);break;case V.ui.keyCode.END:this._move("last","last",t);break;case V.ui.keyCode.UP:this.previous(t);break;case V.ui.keyCode.DOWN:this.next(t);break;case V.ui.keyCode.LEFT:this.collapse(t);break;case V.ui.keyCode.RIGHT:this.active&&!this.active.is(".ui-state-disabled")&&this.expand(t);break;case V.ui.keyCode.ENTER:case V.ui.keyCode.SPACE:this._activate(t);break;case V.ui.keyCode.ESCAPE:this.collapse(t);break;default:e=this.previousFilter||"",s=n=!1,i=96<=t.keyCode&&t.keyCode<=105?(t.keyCode-96).toString():String.fromCharCode(t.keyCode),clearTimeout(this.filterTimer),i===e?s=!0:i=e+i,e=this._filterMenuItems(i),(e=s&&-1!==e.index(this.active.next())?this.active.nextAll(".ui-menu-item"):e).length||(i=String.fromCharCode(t.keyCode),e=this._filterMenuItems(i)),e.length?(this.focus(t,e),this.previousFilter=i,this.filterTimer=this._delay(function(){delete this.previousFilter},1e3)):delete this.previousFilter}n&&t.preventDefault()},_activate:function(t){this.active&&!this.active.is(".ui-state-disabled")&&(this.active.children("[aria-haspopup='true']").length?this.expand(t):this.select(t))},refresh:function(){var t,e,s=this,n=this.options.icons.submenu,i=this.element.find(this.options.menus);this._toggleClass("ui-menu-icons",null,!!this.element.find(".ui-icon").length),e=i.filter(":not(.ui-menu)").hide().attr({role:this.options.role,"aria-hidden":"true","aria-expanded":"false"}).each(function(){var t=V(this),e=t.prev(),i=V("<span>").data("ui-menu-submenu-caret",!0);s._addClass(i,"ui-menu-icon","ui-icon "+n),e.attr("aria-haspopup","true").prepend(i),t.attr("aria-labelledby",e.attr("id"))}),this._addClass(e,"ui-menu","ui-widget ui-widget-content ui-front"),(t=i.add(this.element).find(this.options.items)).not(".ui-menu-item").each(function(){var t=V(this);s._isDivider(t)&&s._addClass(t,"ui-menu-divider","ui-widget-content")}),i=(e=t.not(".ui-menu-item, .ui-menu-divider")).children().not(".ui-menu").uniqueId().attr({tabIndex:-1,role:this._itemRole()}),this._addClass(e,"ui-menu-item")._addClass(i,"ui-menu-item-wrapper"),t.filter(".ui-state-disabled").attr("aria-disabled","true"),this.active&&!V.contains(this.element[0],this.active[0])&&this.blur()},_itemRole:function(){return{menu:"menuitem",listbox:"option"}[this.options.role]},_setOption:function(t,e){var i;"icons"===t&&(i=this.element.find(".ui-menu-icon"),this._removeClass(i,null,this.options.icons.submenu)._addClass(i,null,e.submenu)),this._super(t,e)},_setOptionDisabled:function(t){this._super(t),this.element.attr("aria-disabled",String(t)),this._toggleClass(null,"ui-state-disabled",!!t)},focus:function(t,e){var i;this.blur(t,t&&"focus"===t.type),this._scrollIntoView(e),this.active=e.first(),i=this.active.children(".ui-menu-item-wrapper"),this._addClass(i,null,"ui-state-active"),this.options.role&&this.element.attr("aria-activedescendant",i.attr("id")),i=this.active.parent().closest(".ui-menu-item").children(".ui-menu-item-wrapper"),this._addClass(i,null,"ui-state-active"),t&&"keydown"===t.type?this._close():this.timer=this._delay(function(){this._close()},this.delay),(i=e.children(".ui-menu")).length&&t&&/^mouse/.test(t.type)&&this._startOpening(i),this.activeMenu=e.parent(),this._trigger("focus",t,{item:e})},_scrollIntoView:function(t){var e,i,s;this._hasScroll()&&(i=parseFloat(V.css(this.activeMenu[0],"borderTopWidth"))||0,s=parseFloat(V.css(this.activeMenu[0],"paddingTop"))||0,e=t.offset().top-this.activeMenu.offset().top-i-s,i=this.activeMenu.scrollTop(),s=this.activeMenu.height(),t=t.outerHeight(),e<0?this.activeMenu.scrollTop(i+e):s<e+t&&this.activeMenu.scrollTop(i+e-s+t))},blur:function(t,e){e||clearTimeout(this.timer),this.active&&(this._removeClass(this.active.children(".ui-menu-item-wrapper"),null,"ui-state-active"),this._trigger("blur",t,{item:this.active}),this.active=null)},_startOpening:function(t){clearTimeout(this.timer),"true"===t.attr("aria-hidden")&&(this.timer=this._delay(function(){this._close(),this._open(t)},this.delay))},_open:function(t){var e=V.extend({of:this.active},this.options.position);clearTimeout(this.timer),this.element.find(".ui-menu").not(t.parents(".ui-menu")).hide().attr("aria-hidden","true"),t.show().removeAttr("aria-hidden").attr("aria-expanded","true").position(e)},collapseAll:function(e,i){clearTimeout(this.timer),this.timer=this._delay(function(){var t=i?this.element:V(e&&e.target).closest(this.element.find(".ui-menu"));t.length||(t=this.element),this._close(t),this.blur(e),this._removeClass(t.find(".ui-state-active"),null,"ui-state-active"),this.activeMenu=t},i?0:this.delay)},_close:function(t){(t=t||(this.active?this.active.parent():this.element)).find(".ui-menu").hide().attr("aria-hidden","true").attr("aria-expanded","false")},_closeOnDocumentClick:function(t){return!V(t.target).closest(".ui-menu").length},_isDivider:function(t){return!/[^\-\u2014\u2013\s]/.test(t.text())},collapse:function(t){var e=this.active&&this.active.parent().closest(".ui-menu-item",this.element);e&&e.length&&(this._close(),this.focus(t,e))},expand:function(t){var e=this.active&&this._menuItems(this.active.children(".ui-menu")).first();e&&e.length&&(this._open(e.parent()),this._delay(function(){this.focus(t,e)}))},next:function(t){this._move("next","first",t)},previous:function(t){this._move("prev","last",t)},isFirstItem:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},isLastItem:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},_menuItems:function(t){return(t||this.element).find(this.options.items).filter(".ui-menu-item")},_move:function(t,e,i){var s;(s=this.active?"first"===t||"last"===t?this.active["first"===t?"prevAll":"nextAll"](".ui-menu-item").last():this.active[t+"All"](".ui-menu-item").first():s)&&s.length&&this.active||(s=this._menuItems(this.activeMenu)[e]()),this.focus(i,s)},nextPage:function(t){var e,i,s;this.active?this.isLastItem()||(this._hasScroll()?(i=this.active.offset().top,s=this.element.innerHeight(),0===V.fn.jquery.indexOf("3.2.")&&(s+=this.element[0].offsetHeight-this.element.outerHeight()),this.active.nextAll(".ui-menu-item").each(function(){return(e=V(this)).offset().top-i-s<0}),this.focus(t,e)):this.focus(t,this._menuItems(this.activeMenu)[this.active?"last":"first"]())):this.next(t)},previousPage:function(t){var e,i,s;this.active?this.isFirstItem()||(this._hasScroll()?(i=this.active.offset().top,s=this.element.innerHeight(),0===V.fn.jquery.indexOf("3.2.")&&(s+=this.element[0].offsetHeight-this.element.outerHeight()),this.active.prevAll(".ui-menu-item").each(function(){return 0<(e=V(this)).offset().top-i+s}),this.focus(t,e)):this.focus(t,this._menuItems(this.activeMenu).first())):this.next(t)},_hasScroll:function(){return this.element.outerHeight()<this.element.prop("scrollHeight")},select:function(t){this.active=this.active||V(t.target).closest(".ui-menu-item");var e={item:this.active};this.active.has(".ui-menu").length||this.collapseAll(t,!0),this._trigger("select",t,e)},_filterMenuItems:function(t){var t=t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&"),e=new RegExp("^"+t,"i");return this.activeMenu.find(this.options.items).filter(".ui-menu-item").filter(function(){return e.test(String.prototype.trim.call(V(this).children(".ui-menu-item-wrapper").text()))})}});V.widget("ui.autocomplete",{version:"1.13.2",defaultElement:"<input>",options:{appendTo:null,autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null,change:null,close:null,focus:null,open:null,response:null,search:null,select:null},requestIndex:0,pending:0,liveRegionTimer:null,_create:function(){var i,s,n,t=this.element[0].nodeName.toLowerCase(),e="textarea"===t,t="input"===t;this.isMultiLine=e||!t&&this._isContentEditable(this.element),this.valueMethod=this.element[e||t?"val":"text"],this.isNewMenu=!0,this._addClass("ui-autocomplete-input"),this.element.attr("autocomplete","off"),this._on(this.element,{keydown:function(t){if(this.element.prop("readOnly"))s=n=i=!0;else{s=n=i=!1;var e=V.ui.keyCode;switch(t.keyCode){case e.PAGE_UP:i=!0,this._move("previousPage",t);break;case e.PAGE_DOWN:i=!0,this._move("nextPage",t);break;case e.UP:i=!0,this._keyEvent("previous",t);break;case e.DOWN:i=!0,this._keyEvent("next",t);break;case e.ENTER:this.menu.active&&(i=!0,t.preventDefault(),this.menu.select(t));break;case e.TAB:this.menu.active&&this.menu.select(t);break;case e.ESCAPE:this.menu.element.is(":visible")&&(this.isMultiLine||this._value(this.term),this.close(t),t.preventDefault());break;default:s=!0,this._searchTimeout(t)}}},keypress:function(t){if(i)return i=!1,void(this.isMultiLine&&!this.menu.element.is(":visible")||t.preventDefault());if(!s){var e=V.ui.keyCode;switch(t.keyCode){case e.PAGE_UP:this._move("previousPage",t);break;case e.PAGE_DOWN:this._move("nextPage",t);break;case e.UP:this._keyEvent("previous",t);break;case e.DOWN:this._keyEvent("next",t)}}},input:function(t){if(n)return n=!1,void t.preventDefault();this._searchTimeout(t)},focus:function(){this.selectedItem=null,this.previous=this._value()},blur:function(t){clearTimeout(this.searching),this.close(t),this._change(t)}}),this._initSource(),this.menu=V("<ul>").appendTo(this._appendTo()).menu({role:null}).hide().attr({unselectable:"on"}).menu("instance"),this._addClass(this.menu.element,"ui-autocomplete","ui-front"),this._on(this.menu.element,{mousedown:function(t){t.preventDefault()},menufocus:function(t,e){var i,s;if(this.isNewMenu&&(this.isNewMenu=!1,t.originalEvent&&/^mouse/.test(t.originalEvent.type)))return this.menu.blur(),void this.document.one("mousemove",function(){V(t.target).trigger(t.originalEvent)});s=e.item.data("ui-autocomplete-item"),!1!==this._trigger("focus",t,{item:s})&&t.originalEvent&&/^key/.test(t.originalEvent.type)&&this._value(s.value),(i=e.item.attr("aria-label")||s.value)&&String.prototype.trim.call(i).length&&(clearTimeout(this.liveRegionTimer),this.liveRegionTimer=this._delay(function(){this.liveRegion.html(V("<div>").text(i))},100))},menuselect:function(t,e){var i=e.item.data("ui-autocomplete-item"),s=this.previous;this.element[0]!==V.ui.safeActiveElement(this.document[0])&&(this.element.trigger("focus"),this.previous=s,this._delay(function(){this.previous=s,this.selectedItem=i})),!1!==this._trigger("select",t,{item:i})&&this._value(i.value),this.term=this._value(),this.close(t),this.selectedItem=i}}),this.liveRegion=V("<div>",{role:"status","aria-live":"assertive","aria-relevant":"additions"}).appendTo(this.document[0].body),this._addClass(this.liveRegion,null,"ui-helper-hidden-accessible"),this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_destroy:function(){clearTimeout(this.searching),this.element.removeAttr("autocomplete"),this.menu.element.remove(),this.liveRegion.remove()},_setOption:function(t,e){this._super(t,e),"source"===t&&this._initSource(),"appendTo"===t&&this.menu.element.appendTo(this._appendTo()),"disabled"===t&&e&&this.xhr&&this.xhr.abort()},_isEventTargetInWidget:function(t){var e=this.menu.element[0];return t.target===this.element[0]||t.target===e||V.contains(e,t.target)},_closeOnClickOutside:function(t){this._isEventTargetInWidget(t)||this.close()},_appendTo:function(){var t=this.options.appendTo;return t=!(t=!(t=t&&(t.jquery||t.nodeType?V(t):this.document.find(t).eq(0)))||!t[0]?this.element.closest(".ui-front, dialog"):t).length?this.document[0].body:t},_initSource:function(){var i,s,n=this;Array.isArray(this.options.source)?(i=this.options.source,this.source=function(t,e){e(V.ui.autocomplete.filter(i,t.term))}):"string"==typeof this.options.source?(s=this.options.source,this.source=function(t,e){n.xhr&&n.xhr.abort(),n.xhr=V.ajax({url:s,data:t,dataType:"json",success:function(t){e(t)},error:function(){e([])}})}):this.source=this.options.source},_searchTimeout:function(s){clearTimeout(this.searching),this.searching=this._delay(function(){var t=this.term===this._value(),e=this.menu.element.is(":visible"),i=s.altKey||s.ctrlKey||s.metaKey||s.shiftKey;t&&(e||i)||(this.selectedItem=null,this.search(null,s))},this.options.delay)},search:function(t,e){return t=null!=t?t:this._value(),this.term=this._value(),t.length<this.options.minLength?this.close(e):!1!==this._trigger("search",e)?this._search(t):void 0},_search:function(t){this.pending++,this._addClass("ui-autocomplete-loading"),this.cancelSearch=!1,this.source({term:t},this._response())},_response:function(){var e=++this.requestIndex;return function(t){e===this.requestIndex&&this.__response(t),this.pending--,this.pending||this._removeClass("ui-autocomplete-loading")}.bind(this)},__response:function(t){t=t&&this._normalize(t),this._trigger("response",null,{content:t}),!this.options.disabled&&t&&t.length&&!this.cancelSearch?(this._suggest(t),this._trigger("open")):this._close()},close:function(t){this.cancelSearch=!0,this._close(t)},_close:function(t){this._off(this.document,"mousedown"),this.menu.element.is(":visible")&&(this.menu.element.hide(),this.menu.blur(),this.isNewMenu=!0,this._trigger("close",t))},_change:function(t){this.previous!==this._value()&&this._trigger("change",t,{item:this.selectedItem})},_normalize:function(t){return t.length&&t[0].label&&t[0].value?t:V.map(t,function(t){return"string"==typeof t?{label:t,value:t}:V.extend({},t,{label:t.label||t.value,value:t.value||t.label})})},_suggest:function(t){var e=this.menu.element.empty();this._renderMenu(e,t),this.isNewMenu=!0,this.menu.refresh(),e.show(),this._resizeMenu(),e.position(V.extend({of:this.element},this.options.position)),this.options.autoFocus&&this.menu.next(),this._on(this.document,{mousedown:"_closeOnClickOutside"})},_resizeMenu:function(){var t=this.menu.element;t.outerWidth(Math.max(t.width("").outerWidth()+1,this.element.outerWidth()))},_renderMenu:function(i,t){var s=this;V.each(t,function(t,e){s._renderItemData(i,e)})},_renderItemData:function(t,e){return this._renderItem(t,e).data("ui-autocomplete-item",e)},_renderItem:function(t,e){return V("<li>").append(V("<div>").text(e.label)).appendTo(t)},_move:function(t,e){if(this.menu.element.is(":visible"))return this.menu.isFirstItem()&&/^previous/.test(t)||this.menu.isLastItem()&&/^next/.test(t)?(this.isMultiLine||this._value(this.term),void this.menu.blur()):void this.menu[t](e);this.search(null,e)},widget:function(){return this.menu.element},_value:function(){return this.valueMethod.apply(this.element,arguments)},_keyEvent:function(t,e){this.isMultiLine&&!this.menu.element.is(":visible")||(this._move(t,e),e.preventDefault())},_isContentEditable:function(t){if(!t.length)return!1;var e=t.prop("contentEditable");return"inherit"===e?this._isContentEditable(t.parent()):"true"===e}}),V.extend(V.ui.autocomplete,{escapeRegex:function(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")},filter:function(t,e){var i=new RegExp(V.ui.autocomplete.escapeRegex(e),"i");return V.grep(t,function(t){return i.test(t.label||t.value||t)})}}),V.widget("ui.autocomplete",V.ui.autocomplete,{options:{messages:{noResults:"No search results.",results:function(t){return t+(1<t?" results are":" result is")+" available, use up and down arrow keys to navigate."}}},__response:function(t){var e;this._superApply(arguments),this.options.disabled||this.cancelSearch||(e=t&&t.length?this.options.messages.results(t.length):this.options.messages.noResults,clearTimeout(this.liveRegionTimer),this.liveRegionTimer=this._delay(function(){this.liveRegion.html(V("<div>").text(e))},100))}});V.ui.autocomplete;var tt=/ui-corner-([a-z]){2,6}/g;V.widget("ui.controlgroup",{version:"1.13.2",defaultElement:"<div>",options:{direction:"horizontal",disabled:null,onlyVisible:!0,items:{button:"input[type=button], input[type=submit], input[type=reset], button, a",controlgroupLabel:".ui-controlgroup-label",checkboxradio:"input[type='checkbox'], input[type='radio']",selectmenu:"select",spinner:".ui-spinner-input"}},_create:function(){this._enhance()},_enhance:function(){this.element.attr("role","toolbar"),this.refresh()},_destroy:function(){this._callChildMethod("destroy"),this.childWidgets.removeData("ui-controlgroup-data"),this.element.removeAttr("role"),this.options.items.controlgroupLabel&&this.element.find(this.options.items.controlgroupLabel).find(".ui-controlgroup-label-contents").contents().unwrap()},_initWidgets:function(){var o=this,a=[];V.each(this.options.items,function(s,t){var e,n={};if(t)return"controlgroupLabel"===s?((e=o.element.find(t)).each(function(){var t=V(this);t.children(".ui-controlgroup-label-contents").length||t.contents().wrapAll("<span class='ui-controlgroup-label-contents'></span>")}),o._addClass(e,null,"ui-widget ui-widget-content ui-state-default"),void(a=a.concat(e.get()))):void(V.fn[s]&&(n=o["_"+s+"Options"]?o["_"+s+"Options"]("middle"):{classes:{}},o.element.find(t).each(function(){var t=V(this),e=t[s]("instance"),i=V.widget.extend({},n);"button"===s&&t.parent(".ui-spinner").length||((e=e||t[s]()[s]("instance"))&&(i.classes=o._resolveClassesValues(i.classes,e)),t[s](i),i=t[s]("widget"),V.data(i[0],"ui-controlgroup-data",e||t[s]("instance")),a.push(i[0]))})))}),this.childWidgets=V(V.uniqueSort(a)),this._addClass(this.childWidgets,"ui-controlgroup-item")},_callChildMethod:function(e){this.childWidgets.each(function(){var t=V(this).data("ui-controlgroup-data");t&&t[e]&&t[e]()})},_updateCornerClass:function(t,e){e=this._buildSimpleOptions(e,"label").classes.label;this._removeClass(t,null,"ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-corner-all"),this._addClass(t,null,e)},_buildSimpleOptions:function(t,e){var i="vertical"===this.options.direction,s={classes:{}};return s.classes[e]={middle:"",first:"ui-corner-"+(i?"top":"left"),last:"ui-corner-"+(i?"bottom":"right"),only:"ui-corner-all"}[t],s},_spinnerOptions:function(t){t=this._buildSimpleOptions(t,"ui-spinner");return t.classes["ui-spinner-up"]="",t.classes["ui-spinner-down"]="",t},_buttonOptions:function(t){return this._buildSimpleOptions(t,"ui-button")},_checkboxradioOptions:function(t){return this._buildSimpleOptions(t,"ui-checkboxradio-label")},_selectmenuOptions:function(t){var e="vertical"===this.options.direction;return{width:e&&"auto",classes:{middle:{"ui-selectmenu-button-open":"","ui-selectmenu-button-closed":""},first:{"ui-selectmenu-button-open":"ui-corner-"+(e?"top":"tl"),"ui-selectmenu-button-closed":"ui-corner-"+(e?"top":"left")},last:{"ui-selectmenu-button-open":e?"":"ui-corner-tr","ui-selectmenu-button-closed":"ui-corner-"+(e?"bottom":"right")},only:{"ui-selectmenu-button-open":"ui-corner-top","ui-selectmenu-button-closed":"ui-corner-all"}}[t]}},_resolveClassesValues:function(i,s){var n={};return V.each(i,function(t){var e=s.options.classes[t]||"",e=String.prototype.trim.call(e.replace(tt,""));n[t]=(e+" "+i[t]).replace(/\s+/g," ")}),n},_setOption:function(t,e){"direction"===t&&this._removeClass("ui-controlgroup-"+this.options.direction),this._super(t,e),"disabled"!==t?this.refresh():this._callChildMethod(e?"disable":"enable")},refresh:function(){var n,o=this;this._addClass("ui-controlgroup ui-controlgroup-"+this.options.direction),"horizontal"===this.options.direction&&this._addClass(null,"ui-helper-clearfix"),this._initWidgets(),n=this.childWidgets,(n=this.options.onlyVisible?n.filter(":visible"):n).length&&(V.each(["first","last"],function(t,e){var i,s=n[e]().data("ui-controlgroup-data");s&&o["_"+s.widgetName+"Options"]?((i=o["_"+s.widgetName+"Options"](1===n.length?"only":e)).classes=o._resolveClassesValues(i.classes,s),s.element[s.widgetName](i)):o._updateCornerClass(n[e](),e)}),this._callChildMethod("refresh"))}});V.widget("ui.checkboxradio",[V.ui.formResetMixin,{version:"1.13.2",options:{disabled:null,label:null,icon:!0,classes:{"ui-checkboxradio-label":"ui-corner-all","ui-checkboxradio-icon":"ui-corner-all"}},_getCreateOptions:function(){var t,e=this._super()||{};return this._readType(),t=this.element.labels(),this.label=V(t[t.length-1]),this.label.length||V.error("No label found for checkboxradio widget"),this.originalLabel="",(t=this.label.contents().not(this.element[0])).length&&(this.originalLabel+=t.clone().wrapAll("<div></div>").parent().html()),this.originalLabel&&(e.label=this.originalLabel),null!=(t=this.element[0].disabled)&&(e.disabled=t),e},_create:function(){var t=this.element[0].checked;this._bindFormResetHandler(),null==this.options.disabled&&(this.options.disabled=this.element[0].disabled),this._setOption("disabled",this.options.disabled),this._addClass("ui-checkboxradio","ui-helper-hidden-accessible"),this._addClass(this.label,"ui-checkboxradio-label","ui-button ui-widget"),"radio"===this.type&&this._addClass(this.label,"ui-checkboxradio-radio-label"),this.options.label&&this.options.label!==this.originalLabel?this._updateLabel():this.originalLabel&&(this.options.label=this.originalLabel),this._enhance(),t&&this._addClass(this.label,"ui-checkboxradio-checked","ui-state-active"),this._on({change:"_toggleClasses",focus:function(){this._addClass(this.label,null,"ui-state-focus ui-visual-focus")},blur:function(){this._removeClass(this.label,null,"ui-state-focus ui-visual-focus")}})},_readType:function(){var t=this.element[0].nodeName.toLowerCase();this.type=this.element[0].type,"input"===t&&/radio|checkbox/.test(this.type)||V.error("Can't create checkboxradio on element.nodeName="+t+" and element.type="+this.type)},_enhance:function(){this._updateIcon(this.element[0].checked)},widget:function(){return this.label},_getRadioGroup:function(){var t=this.element[0].name,e="input[name='"+V.escapeSelector(t)+"']";return t?(this.form.length?V(this.form[0].elements).filter(e):V(e).filter(function(){return 0===V(this)._form().length})).not(this.element):V([])},_toggleClasses:function(){var t=this.element[0].checked;this._toggleClass(this.label,"ui-checkboxradio-checked","ui-state-active",t),this.options.icon&&"checkbox"===this.type&&this._toggleClass(this.icon,null,"ui-icon-check ui-state-checked",t)._toggleClass(this.icon,null,"ui-icon-blank",!t),"radio"===this.type&&this._getRadioGroup().each(function(){var t=V(this).checkboxradio("instance");t&&t._removeClass(t.label,"ui-checkboxradio-checked","ui-state-active")})},_destroy:function(){this._unbindFormResetHandler(),this.icon&&(this.icon.remove(),this.iconSpace.remove())},_setOption:function(t,e){if("label"!==t||e){if(this._super(t,e),"disabled"===t)return this._toggleClass(this.label,null,"ui-state-disabled",e),void(this.element[0].disabled=e);this.refresh()}},_updateIcon:function(t){var e="ui-icon ui-icon-background ";this.options.icon?(this.icon||(this.icon=V("<span>"),this.iconSpace=V("<span> </span>"),this._addClass(this.iconSpace,"ui-checkboxradio-icon-space")),"checkbox"===this.type?(e+=t?"ui-icon-check ui-state-checked":"ui-icon-blank",this._removeClass(this.icon,null,t?"ui-icon-blank":"ui-icon-check")):e+="ui-icon-blank",this._addClass(this.icon,"ui-checkboxradio-icon",e),t||this._removeClass(this.icon,null,"ui-icon-check ui-state-checked"),this.icon.prependTo(this.label).after(this.iconSpace)):void 0!==this.icon&&(this.icon.remove(),this.iconSpace.remove(),delete this.icon)},_updateLabel:function(){var t=this.label.contents().not(this.element[0]);this.icon&&(t=t.not(this.icon[0])),(t=this.iconSpace?t.not(this.iconSpace[0]):t).remove(),this.label.append(this.options.label)},refresh:function(){var t=this.element[0].checked,e=this.element[0].disabled;this._updateIcon(t),this._toggleClass(this.label,"ui-checkboxradio-checked","ui-state-active",t),null!==this.options.label&&this._updateLabel(),e!==this.options.disabled&&this._setOptions({disabled:e})}}]);var et;V.ui.checkboxradio;V.widget("ui.button",{version:"1.13.2",defaultElement:"<button>",options:{classes:{"ui-button":"ui-corner-all"},disabled:null,icon:null,iconPosition:"beginning",label:null,showLabel:!0},_getCreateOptions:function(){var t,e=this._super()||{};return this.isInput=this.element.is("input"),null!=(t=this.element[0].disabled)&&(e.disabled=t),this.originalLabel=this.isInput?this.element.val():this.element.html(),this.originalLabel&&(e.label=this.originalLabel),e},_create:function(){!this.option.showLabel&!this.options.icon&&(this.options.showLabel=!0),null==this.options.disabled&&(this.options.disabled=this.element[0].disabled||!1),this.hasTitle=!!this.element.attr("title"),this.options.label&&this.options.label!==this.originalLabel&&(this.isInput?this.element.val(this.options.label):this.element.html(this.options.label)),this._addClass("ui-button","ui-widget"),this._setOption("disabled",this.options.disabled),this._enhance(),this.element.is("a")&&this._on({keyup:function(t){t.keyCode===V.ui.keyCode.SPACE&&(t.preventDefault(),this.element[0].click?this.element[0].click():this.element.trigger("click"))}})},_enhance:function(){this.element.is("button")||this.element.attr("role","button"),this.options.icon&&(this._updateIcon("icon",this.options.icon),this._updateTooltip())},_updateTooltip:function(){this.title=this.element.attr("title"),this.options.showLabel||this.title||this.element.attr("title",this.options.label)},_updateIcon:function(t,e){var i="iconPosition"!==t,s=i?this.options.iconPosition:e,t="top"===s||"bottom"===s;this.icon?i&&this._removeClass(this.icon,null,this.options.icon):(this.icon=V("<span>"),this._addClass(this.icon,"ui-button-icon","ui-icon"),this.options.showLabel||this._addClass("ui-button-icon-only")),i&&this._addClass(this.icon,null,e),this._attachIcon(s),t?(this._addClass(this.icon,null,"ui-widget-icon-block"),this.iconSpace&&this.iconSpace.remove()):(this.iconSpace||(this.iconSpace=V("<span> </span>"),this._addClass(this.iconSpace,"ui-button-icon-space")),this._removeClass(this.icon,null,"ui-wiget-icon-block"),this._attachIconSpace(s))},_destroy:function(){this.element.removeAttr("role"),this.icon&&this.icon.remove(),this.iconSpace&&this.iconSpace.remove(),this.hasTitle||this.element.removeAttr("title")},_attachIconSpace:function(t){this.icon[/^(?:end|bottom)/.test(t)?"before":"after"](this.iconSpace)},_attachIcon:function(t){this.element[/^(?:end|bottom)/.test(t)?"append":"prepend"](this.icon)},_setOptions:function(t){var e=(void 0===t.showLabel?this.options:t).showLabel,i=(void 0===t.icon?this.options:t).icon;e||i||(t.showLabel=!0),this._super(t)},_setOption:function(t,e){"icon"===t&&(e?this._updateIcon(t,e):this.icon&&(this.icon.remove(),this.iconSpace&&this.iconSpace.remove())),"iconPosition"===t&&this._updateIcon(t,e),"showLabel"===t&&(this._toggleClass("ui-button-icon-only",null,!e),this._updateTooltip()),"label"===t&&(this.isInput?this.element.val(e):(this.element.html(e),this.icon&&(this._attachIcon(this.options.iconPosition),this._attachIconSpace(this.options.iconPosition)))),this._super(t,e),"disabled"===t&&(this._toggleClass(null,"ui-state-disabled",e),(this.element[0].disabled=e)&&this.element.trigger("blur"))},refresh:function(){var t=this.element.is("input, button")?this.element[0].disabled:this.element.hasClass("ui-button-disabled");t!==this.options.disabled&&this._setOptions({disabled:t}),this._updateTooltip()}}),!1!==V.uiBackCompat&&(V.widget("ui.button",V.ui.button,{options:{text:!0,icons:{primary:null,secondary:null}},_create:function(){this.options.showLabel&&!this.options.text&&(this.options.showLabel=this.options.text),!this.options.showLabel&&this.options.text&&(this.options.text=this.options.showLabel),this.options.icon||!this.options.icons.primary&&!this.options.icons.secondary?this.options.icon&&(this.options.icons.primary=this.options.icon):this.options.icons.primary?this.options.icon=this.options.icons.primary:(this.options.icon=this.options.icons.secondary,this.options.iconPosition="end"),this._super()},_setOption:function(t,e){"text"!==t?("showLabel"===t&&(this.options.text=e),"icon"===t&&(this.options.icons.primary=e),"icons"===t&&(e.primary?(this._super("icon",e.primary),this._super("iconPosition","beginning")):e.secondary&&(this._super("icon",e.secondary),this._super("iconPosition","end"))),this._superApply(arguments)):this._super("showLabel",e)}}),V.fn.button=(et=V.fn.button,function(i){var t="string"==typeof i,s=Array.prototype.slice.call(arguments,1),n=this;return t?this.length||"instance"!==i?this.each(function(){var t=V(this).attr("type"),e=V.data(this,"ui-"+("checkbox"!==t&&"radio"!==t?"button":"checkboxradio"));return"instance"===i?(n=e,!1):e?"function"!=typeof e[i]||"_"===i.charAt(0)?V.error("no such method '"+i+"' for button widget instance"):(t=e[i].apply(e,s))!==e&&void 0!==t?(n=t&&t.jquery?n.pushStack(t.get()):t,!1):void 0:V.error("cannot call methods on button prior to initialization; attempted to call method '"+i+"'")}):n=void 0:(s.length&&(i=V.widget.extend.apply(null,[i].concat(s))),this.each(function(){var t=V(this).attr("type"),e="checkbox"!==t&&"radio"!==t?"button":"checkboxradio",t=V.data(this,"ui-"+e);t?(t.option(i||{}),t._init&&t._init()):"button"!=e?V(this).checkboxradio(V.extend({icon:!1},i)):et.call(V(this),i)})),n}),V.fn.buttonset=function(){return V.ui.controlgroup||V.error("Controlgroup widget missing"),"option"===arguments[0]&&"items"===arguments[1]&&arguments[2]?this.controlgroup.apply(this,[arguments[0],"items.button",arguments[2]]):"option"===arguments[0]&&"items"===arguments[1]?this.controlgroup.apply(this,[arguments[0],"items.button"]):("object"==typeof arguments[0]&&arguments[0].items&&(arguments[0].items={button:arguments[0].items}),this.controlgroup.apply(this,arguments))});var it;V.ui.button;function st(){this._curInst=null,this._keyEvent=!1,this._disabledInputs=[],this._datepickerShowing=!1,this._inDialog=!1,this._mainDivId="ui-datepicker-div",this._inlineClass="ui-datepicker-inline",this._appendClass="ui-datepicker-append",this._triggerClass="ui-datepicker-trigger",this._dialogClass="ui-datepicker-dialog",this._disableClass="ui-datepicker-disabled",this._unselectableClass="ui-datepicker-unselectable",this._currentClass="ui-datepicker-current-day",this._dayOverClass="ui-datepicker-days-cell-over",this.regional=[],this.regional[""]={closeText:"Done",prevText:"Prev",nextText:"Next",currentText:"Today",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],weekHeader:"Wk",dateFormat:"mm/dd/yy",firstDay:0,isRTL:!1,showMonthAfterYear:!1,yearSuffix:"",selectMonthLabel:"Select month",selectYearLabel:"Select year"},this._defaults={showOn:"focus",showAnim:"fadeIn",showOptions:{},defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:!1,hideIfNoPrevNext:!1,navigationAsDateFormat:!1,gotoCurrent:!1,changeMonth:!1,changeYear:!1,yearRange:"c-10:c+10",showOtherMonths:!1,selectOtherMonths:!1,showWeek:!1,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",minDate:null,maxDate:null,duration:"fast",beforeShowDay:null,beforeShow:null,onSelect:null,onChangeMonthYear:null,onClose:null,onUpdateDatepicker:null,numberOfMonths:1,showCurrentAtPos:0,stepMonths:1,stepBigMonths:12,altField:"",altFormat:"",constrainInput:!0,showButtonPanel:!1,autoSize:!1,disabled:!1},V.extend(this._defaults,this.regional[""]),this.regional.en=V.extend(!0,{},this.regional[""]),this.regional["en-US"]=V.extend(!0,{},this.regional.en),this.dpDiv=nt(V("<div id='"+this._mainDivId+"' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"))}function nt(t){var e="button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";return t.on("mouseout",e,function(){V(this).removeClass("ui-state-hover"),-1!==this.className.indexOf("ui-datepicker-prev")&&V(this).removeClass("ui-datepicker-prev-hover"),-1!==this.className.indexOf("ui-datepicker-next")&&V(this).removeClass("ui-datepicker-next-hover")}).on("mouseover",e,ot)}function ot(){V.datepicker._isDisabledDatepicker((it.inline?it.dpDiv.parent():it.input)[0])||(V(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"),V(this).addClass("ui-state-hover"),-1!==this.className.indexOf("ui-datepicker-prev")&&V(this).addClass("ui-datepicker-prev-hover"),-1!==this.className.indexOf("ui-datepicker-next")&&V(this).addClass("ui-datepicker-next-hover"))}function at(t,e){for(var i in V.extend(t,e),e)null==e[i]&&(t[i]=e[i]);return t}V.extend(V.ui,{datepicker:{version:"1.13.2"}}),V.extend(st.prototype,{markerClassName:"hasDatepicker",maxRows:4,_widgetDatepicker:function(){return this.dpDiv},setDefaults:function(t){return at(this._defaults,t||{}),this},_attachDatepicker:function(t,e){var i,s=t.nodeName.toLowerCase(),n="div"===s||"span"===s;t.id||(this.uuid+=1,t.id="dp"+this.uuid),(i=this._newInst(V(t),n)).settings=V.extend({},e||{}),"input"===s?this._connectDatepicker(t,i):n&&this._inlineDatepicker(t,i)},_newInst:function(t,e){return{id:t[0].id.replace(/([^A-Za-z0-9_\-])/g,"\\\\$1"),input:t,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:e,dpDiv:e?nt(V("<div class='"+this._inlineClass+" ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")):this.dpDiv}},_connectDatepicker:function(t,e){var i=V(t);e.append=V([]),e.trigger=V([]),i.hasClass(this.markerClassName)||(this._attachments(i,e),i.addClass(this.markerClassName).on("keydown",this._doKeyDown).on("keypress",this._doKeyPress).on("keyup",this._doKeyUp),this._autoSize(e),V.data(t,"datepicker",e),e.settings.disabled&&this._disableDatepicker(t))},_attachments:function(t,e){var i,s=this._get(e,"appendText"),n=this._get(e,"isRTL");e.append&&e.append.remove(),s&&(e.append=V("<span>").addClass(this._appendClass).text(s),t[n?"before":"after"](e.append)),t.off("focus",this._showDatepicker),e.trigger&&e.trigger.remove(),"focus"!==(i=this._get(e,"showOn"))&&"both"!==i||t.on("focus",this._showDatepicker),"button"!==i&&"both"!==i||(s=this._get(e,"buttonText"),i=this._get(e,"buttonImage"),this._get(e,"buttonImageOnly")?e.trigger=V("<img>").addClass(this._triggerClass).attr({src:i,alt:s,title:s}):(e.trigger=V("<button type='button'>").addClass(this._triggerClass),i?e.trigger.html(V("<img>").attr({src:i,alt:s,title:s})):e.trigger.text(s)),t[n?"before":"after"](e.trigger),e.trigger.on("click",function(){return V.datepicker._datepickerShowing&&V.datepicker._lastInput===t[0]?V.datepicker._hideDatepicker():(V.datepicker._datepickerShowing&&V.datepicker._lastInput!==t[0]&&V.datepicker._hideDatepicker(),V.datepicker._showDatepicker(t[0])),!1}))},_autoSize:function(t){var e,i,s,n,o,a;this._get(t,"autoSize")&&!t.inline&&(o=new Date(2009,11,20),(a=this._get(t,"dateFormat")).match(/[DM]/)&&(e=function(t){for(n=s=i=0;n<t.length;n++)t[n].length>i&&(i=t[n].length,s=n);return s},o.setMonth(e(this._get(t,a.match(/MM/)?"monthNames":"monthNamesShort"))),o.setDate(e(this._get(t,a.match(/DD/)?"dayNames":"dayNamesShort"))+20-o.getDay())),t.input.attr("size",this._formatDate(t,o).length))},_inlineDatepicker:function(t,e){var i=V(t);i.hasClass(this.markerClassName)||(i.addClass(this.markerClassName).append(e.dpDiv),V.data(t,"datepicker",e),this._setDate(e,this._getDefaultDate(e),!0),this._updateDatepicker(e),this._updateAlternate(e),e.settings.disabled&&this._disableDatepicker(t),e.dpDiv.css("display","block"))},_dialogDatepicker:function(t,e,i,s,n){var o,a=this._dialogInst;return a||(this.uuid+=1,o="dp"+this.uuid,this._dialogInput=V("<input type='text' id='"+o+"' style='position: absolute; top: -100px; width: 0px;'/>"),this._dialogInput.on("keydown",this._doKeyDown),V("body").append(this._dialogInput),(a=this._dialogInst=this._newInst(this._dialogInput,!1)).settings={},V.data(this._dialogInput[0],"datepicker",a)),at(a.settings,s||{}),e=e&&e.constructor===Date?this._formatDate(a,e):e,this._dialogInput.val(e),this._pos=n?n.length?n:[n.pageX,n.pageY]:null,this._pos||(o=document.documentElement.clientWidth,s=document.documentElement.clientHeight,e=document.documentElement.scrollLeft||document.body.scrollLeft,n=document.documentElement.scrollTop||document.body.scrollTop,this._pos=[o/2-100+e,s/2-150+n]),this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px"),a.settings.onSelect=i,this._inDialog=!0,this.dpDiv.addClass(this._dialogClass),this._showDatepicker(this._dialogInput[0]),V.blockUI&&V.blockUI(this.dpDiv),V.data(this._dialogInput[0],"datepicker",a),this},_destroyDatepicker:function(t){var e,i=V(t),s=V.data(t,"datepicker");i.hasClass(this.markerClassName)&&(e=t.nodeName.toLowerCase(),V.removeData(t,"datepicker"),"input"===e?(s.append.remove(),s.trigger.remove(),i.removeClass(this.markerClassName).off("focus",this._showDatepicker).off("keydown",this._doKeyDown).off("keypress",this._doKeyPress).off("keyup",this._doKeyUp)):"div"!==e&&"span"!==e||i.removeClass(this.markerClassName).empty(),it===s&&(it=null,this._curInst=null))},_enableDatepicker:function(e){var t,i=V(e),s=V.data(e,"datepicker");i.hasClass(this.markerClassName)&&("input"===(t=e.nodeName.toLowerCase())?(e.disabled=!1,s.trigger.filter("button").each(function(){this.disabled=!1}).end().filter("img").css({opacity:"1.0",cursor:""})):"div"!==t&&"span"!==t||((i=i.children("."+this._inlineClass)).children().removeClass("ui-state-disabled"),i.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled",!1)),this._disabledInputs=V.map(this._disabledInputs,function(t){return t===e?null:t}))},_disableDatepicker:function(e){var t,i=V(e),s=V.data(e,"datepicker");i.hasClass(this.markerClassName)&&("input"===(t=e.nodeName.toLowerCase())?(e.disabled=!0,s.trigger.filter("button").each(function(){this.disabled=!0}).end().filter("img").css({opacity:"0.5",cursor:"default"})):"div"!==t&&"span"!==t||((i=i.children("."+this._inlineClass)).children().addClass("ui-state-disabled"),i.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled",!0)),this._disabledInputs=V.map(this._disabledInputs,function(t){return t===e?null:t}),this._disabledInputs[this._disabledInputs.length]=e)},_isDisabledDatepicker:function(t){if(!t)return!1;for(var e=0;e<this._disabledInputs.length;e++)if(this._disabledInputs[e]===t)return!0;return!1},_getInst:function(t){try{return V.data(t,"datepicker")}catch(t){throw"Missing instance data for this datepicker"}},_optionDatepicker:function(t,e,i){var s,n,o=this._getInst(t);if(2===arguments.length&&"string"==typeof e)return"defaults"===e?V.extend({},V.datepicker._defaults):o?"all"===e?V.extend({},o.settings):this._get(o,e):null;s=e||{},"string"==typeof e&&((s={})[e]=i),o&&(this._curInst===o&&this._hideDatepicker(),n=this._getDateDatepicker(t,!0),e=this._getMinMaxDate(o,"min"),i=this._getMinMaxDate(o,"max"),at(o.settings,s),null!==e&&void 0!==s.dateFormat&&void 0===s.minDate&&(o.settings.minDate=this._formatDate(o,e)),null!==i&&void 0!==s.dateFormat&&void 0===s.maxDate&&(o.settings.maxDate=this._formatDate(o,i)),"disabled"in s&&(s.disabled?this._disableDatepicker(t):this._enableDatepicker(t)),this._attachments(V(t),o),this._autoSize(o),this._setDate(o,n),this._updateAlternate(o),this._updateDatepicker(o))},_changeDatepicker:function(t,e,i){this._optionDatepicker(t,e,i)},_refreshDatepicker:function(t){t=this._getInst(t);t&&this._updateDatepicker(t)},_setDateDatepicker:function(t,e){t=this._getInst(t);t&&(this._setDate(t,e),this._updateDatepicker(t),this._updateAlternate(t))},_getDateDatepicker:function(t,e){t=this._getInst(t);return t&&!t.inline&&this._setDateFromField(t,e),t?this._getDate(t):null},_doKeyDown:function(t){var e,i,s=V.datepicker._getInst(t.target),n=!0,o=s.dpDiv.is(".ui-datepicker-rtl");if(s._keyEvent=!0,V.datepicker._datepickerShowing)switch(t.keyCode){case 9:V.datepicker._hideDatepicker(),n=!1;break;case 13:return(i=V("td."+V.datepicker._dayOverClass+":not(."+V.datepicker._currentClass+")",s.dpDiv))[0]&&V.datepicker._selectDay(t.target,s.selectedMonth,s.selectedYear,i[0]),(e=V.datepicker._get(s,"onSelect"))?(i=V.datepicker._formatDate(s),e.apply(s.input?s.input[0]:null,[i,s])):V.datepicker._hideDatepicker(),!1;case 27:V.datepicker._hideDatepicker();break;case 33:V.datepicker._adjustDate(t.target,t.ctrlKey?-V.datepicker._get(s,"stepBigMonths"):-V.datepicker._get(s,"stepMonths"),"M");break;case 34:V.datepicker._adjustDate(t.target,t.ctrlKey?+V.datepicker._get(s,"stepBigMonths"):+V.datepicker._get(s,"stepMonths"),"M");break;case 35:(t.ctrlKey||t.metaKey)&&V.datepicker._clearDate(t.target),n=t.ctrlKey||t.metaKey;break;case 36:(t.ctrlKey||t.metaKey)&&V.datepicker._gotoToday(t.target),n=t.ctrlKey||t.metaKey;break;case 37:(t.ctrlKey||t.metaKey)&&V.datepicker._adjustDate(t.target,o?1:-1,"D"),n=t.ctrlKey||t.metaKey,t.originalEvent.altKey&&V.datepicker._adjustDate(t.target,t.ctrlKey?-V.datepicker._get(s,"stepBigMonths"):-V.datepicker._get(s,"stepMonths"),"M");break;case 38:(t.ctrlKey||t.metaKey)&&V.datepicker._adjustDate(t.target,-7,"D"),n=t.ctrlKey||t.metaKey;break;case 39:(t.ctrlKey||t.metaKey)&&V.datepicker._adjustDate(t.target,o?-1:1,"D"),n=t.ctrlKey||t.metaKey,t.originalEvent.altKey&&V.datepicker._adjustDate(t.target,t.ctrlKey?+V.datepicker._get(s,"stepBigMonths"):+V.datepicker._get(s,"stepMonths"),"M");break;case 40:(t.ctrlKey||t.metaKey)&&V.datepicker._adjustDate(t.target,7,"D"),n=t.ctrlKey||t.metaKey;break;default:n=!1}else 36===t.keyCode&&t.ctrlKey?V.datepicker._showDatepicker(this):n=!1;n&&(t.preventDefault(),t.stopPropagation())},_doKeyPress:function(t){var e,i=V.datepicker._getInst(t.target);if(V.datepicker._get(i,"constrainInput"))return e=V.datepicker._possibleChars(V.datepicker._get(i,"dateFormat")),i=String.fromCharCode(null==t.charCode?t.keyCode:t.charCode),t.ctrlKey||t.metaKey||i<" "||!e||-1<e.indexOf(i)},_doKeyUp:function(t){t=V.datepicker._getInst(t.target);if(t.input.val()!==t.lastVal)try{V.datepicker.parseDate(V.datepicker._get(t,"dateFormat"),t.input?t.input.val():null,V.datepicker._getFormatConfig(t))&&(V.datepicker._setDateFromField(t),V.datepicker._updateAlternate(t),V.datepicker._updateDatepicker(t))}catch(t){}return!0},_showDatepicker:function(t){var e,i,s,n;"input"!==(t=t.target||t).nodeName.toLowerCase()&&(t=V("input",t.parentNode)[0]),V.datepicker._isDisabledDatepicker(t)||V.datepicker._lastInput===t||(n=V.datepicker._getInst(t),V.datepicker._curInst&&V.datepicker._curInst!==n&&(V.datepicker._curInst.dpDiv.stop(!0,!0),n&&V.datepicker._datepickerShowing&&V.datepicker._hideDatepicker(V.datepicker._curInst.input[0])),!1!==(i=(s=V.datepicker._get(n,"beforeShow"))?s.apply(t,[t,n]):{})&&(at(n.settings,i),n.lastVal=null,V.datepicker._lastInput=t,V.datepicker._setDateFromField(n),V.datepicker._inDialog&&(t.value=""),V.datepicker._pos||(V.datepicker._pos=V.datepicker._findPos(t),V.datepicker._pos[1]+=t.offsetHeight),e=!1,V(t).parents().each(function(){return!(e|="fixed"===V(this).css("position"))}),s={left:V.datepicker._pos[0],top:V.datepicker._pos[1]},V.datepicker._pos=null,n.dpDiv.empty(),n.dpDiv.css({position:"absolute",display:"block",top:"-1000px"}),V.datepicker._updateDatepicker(n),s=V.datepicker._checkOffset(n,s,e),n.dpDiv.css({position:V.datepicker._inDialog&&V.blockUI?"static":e?"fixed":"absolute",display:"none",left:s.left+"px",top:s.top+"px"}),n.inline||(i=V.datepicker._get(n,"showAnim"),s=V.datepicker._get(n,"duration"),n.dpDiv.css("z-index",function(t){for(var e,i;t.length&&t[0]!==document;){if(("absolute"===(e=t.css("position"))||"relative"===e||"fixed"===e)&&(i=parseInt(t.css("zIndex"),10),!isNaN(i)&&0!==i))return i;t=t.parent()}return 0}(V(t))+1),V.datepicker._datepickerShowing=!0,V.effects&&V.effects.effect[i]?n.dpDiv.show(i,V.datepicker._get(n,"showOptions"),s):n.dpDiv[i||"show"](i?s:null),V.datepicker._shouldFocusInput(n)&&n.input.trigger("focus"),V.datepicker._curInst=n)))},_updateDatepicker:function(t){this.maxRows=4,(it=t).dpDiv.empty().append(this._generateHTML(t)),this._attachHandlers(t);var e,i=this._getNumberOfMonths(t),s=i[1],n=t.dpDiv.find("."+this._dayOverClass+" a"),o=V.datepicker._get(t,"onUpdateDatepicker");0<n.length&&ot.apply(n.get(0)),t.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width(""),1<s&&t.dpDiv.addClass("ui-datepicker-multi-"+s).css("width",17*s+"em"),t.dpDiv[(1!==i[0]||1!==i[1]?"add":"remove")+"Class"]("ui-datepicker-multi"),t.dpDiv[(this._get(t,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl"),t===V.datepicker._curInst&&V.datepicker._datepickerShowing&&V.datepicker._shouldFocusInput(t)&&t.input.trigger("focus"),t.yearshtml&&(e=t.yearshtml,setTimeout(function(){e===t.yearshtml&&t.yearshtml&&t.dpDiv.find("select.ui-datepicker-year").first().replaceWith(t.yearshtml),e=t.yearshtml=null},0)),o&&o.apply(t.input?t.input[0]:null,[t])},_shouldFocusInput:function(t){return t.input&&t.input.is(":visible")&&!t.input.is(":disabled")&&!t.input.is(":focus")},_checkOffset:function(t,e,i){var s=t.dpDiv.outerWidth(),n=t.dpDiv.outerHeight(),o=t.input?t.input.outerWidth():0,a=t.input?t.input.outerHeight():0,r=document.documentElement.clientWidth+(i?0:V(document).scrollLeft()),l=document.documentElement.clientHeight+(i?0:V(document).scrollTop());return e.left-=this._get(t,"isRTL")?s-o:0,e.left-=i&&e.left===t.input.offset().left?V(document).scrollLeft():0,e.top-=i&&e.top===t.input.offset().top+a?V(document).scrollTop():0,e.left-=Math.min(e.left,e.left+s>r&&s<r?Math.abs(e.left+s-r):0),e.top-=Math.min(e.top,e.top+n>l&&n<l?Math.abs(n+a):0),e},_findPos:function(t){for(var e=this._getInst(t),i=this._get(e,"isRTL");t&&("hidden"===t.type||1!==t.nodeType||V.expr.pseudos.hidden(t));)t=t[i?"previousSibling":"nextSibling"];return[(e=V(t).offset()).left,e.top]},_hideDatepicker:function(t){var e,i,s=this._curInst;!s||t&&s!==V.data(t,"datepicker")||this._datepickerShowing&&(e=this._get(s,"showAnim"),i=this._get(s,"duration"),t=function(){V.datepicker._tidyDialog(s)},V.effects&&(V.effects.effect[e]||V.effects[e])?s.dpDiv.hide(e,V.datepicker._get(s,"showOptions"),i,t):s.dpDiv["slideDown"===e?"slideUp":"fadeIn"===e?"fadeOut":"hide"](e?i:null,t),e||t(),this._datepickerShowing=!1,(t=this._get(s,"onClose"))&&t.apply(s.input?s.input[0]:null,[s.input?s.input.val():"",s]),this._lastInput=null,this._inDialog&&(this._dialogInput.css({position:"absolute",left:"0",top:"-100px"}),V.blockUI&&(V.unblockUI(),V("body").append(this.dpDiv))),this._inDialog=!1)},_tidyDialog:function(t){t.dpDiv.removeClass(this._dialogClass).off(".ui-datepicker-calendar")},_checkExternalClick:function(t){var e;V.datepicker._curInst&&(e=V(t.target),t=V.datepicker._getInst(e[0]),(e[0].id===V.datepicker._mainDivId||0!==e.parents("#"+V.datepicker._mainDivId).length||e.hasClass(V.datepicker.markerClassName)||e.closest("."+V.datepicker._triggerClass).length||!V.datepicker._datepickerShowing||V.datepicker._inDialog&&V.blockUI)&&(!e.hasClass(V.datepicker.markerClassName)||V.datepicker._curInst===t)||V.datepicker._hideDatepicker())},_adjustDate:function(t,e,i){var s=V(t),t=this._getInst(s[0]);this._isDisabledDatepicker(s[0])||(this._adjustInstDate(t,e,i),this._updateDatepicker(t))},_gotoToday:function(t){var e=V(t),i=this._getInst(e[0]);this._get(i,"gotoCurrent")&&i.currentDay?(i.selectedDay=i.currentDay,i.drawMonth=i.selectedMonth=i.currentMonth,i.drawYear=i.selectedYear=i.currentYear):(t=new Date,i.selectedDay=t.getDate(),i.drawMonth=i.selectedMonth=t.getMonth(),i.drawYear=i.selectedYear=t.getFullYear()),this._notifyChange(i),this._adjustDate(e)},_selectMonthYear:function(t,e,i){var s=V(t),t=this._getInst(s[0]);t["selected"+("M"===i?"Month":"Year")]=t["draw"+("M"===i?"Month":"Year")]=parseInt(e.options[e.selectedIndex].value,10),this._notifyChange(t),this._adjustDate(s)},_selectDay:function(t,e,i,s){var n=V(t);V(s).hasClass(this._unselectableClass)||this._isDisabledDatepicker(n[0])||((n=this._getInst(n[0])).selectedDay=n.currentDay=parseInt(V("a",s).attr("data-date")),n.selectedMonth=n.currentMonth=e,n.selectedYear=n.currentYear=i,this._selectDate(t,this._formatDate(n,n.currentDay,n.currentMonth,n.currentYear)))},_clearDate:function(t){t=V(t);this._selectDate(t,"")},_selectDate:function(t,e){var i=V(t),t=this._getInst(i[0]);e=null!=e?e:this._formatDate(t),t.input&&t.input.val(e),this._updateAlternate(t),(i=this._get(t,"onSelect"))?i.apply(t.input?t.input[0]:null,[e,t]):t.input&&t.input.trigger("change"),t.inline?this._updateDatepicker(t):(this._hideDatepicker(),this._lastInput=t.input[0],"object"!=typeof t.input[0]&&t.input.trigger("focus"),this._lastInput=null)},_updateAlternate:function(t){var e,i,s=this._get(t,"altField");s&&(e=this._get(t,"altFormat")||this._get(t,"dateFormat"),i=this._getDate(t),t=this.formatDate(e,i,this._getFormatConfig(t)),V(document).find(s).val(t))},noWeekends:function(t){t=t.getDay();return[0<t&&t<6,""]},iso8601Week:function(t){var e=new Date(t.getTime());return e.setDate(e.getDate()+4-(e.getDay()||7)),t=e.getTime(),e.setMonth(0),e.setDate(1),Math.floor(Math.round((t-e)/864e5)/7)+1},parseDate:function(e,n,t){if(null==e||null==n)throw"Invalid arguments";if(""===(n="object"==typeof n?n.toString():n+""))return null;for(var i,s,o,a=0,r=(t?t.shortYearCutoff:null)||this._defaults.shortYearCutoff,r="string"!=typeof r?r:(new Date).getFullYear()%100+parseInt(r,10),l=(t?t.dayNamesShort:null)||this._defaults.dayNamesShort,h=(t?t.dayNames:null)||this._defaults.dayNames,c=(t?t.monthNamesShort:null)||this._defaults.monthNamesShort,u=(t?t.monthNames:null)||this._defaults.monthNames,d=-1,p=-1,f=-1,g=-1,m=!1,_=function(t){t=w+1<e.length&&e.charAt(w+1)===t;return t&&w++,t},v=function(t){var e=_(t),e="@"===t?14:"!"===t?20:"y"===t&&e?4:"o"===t?3:2,e=new RegExp("^\\d{"+("y"===t?e:1)+","+e+"}"),e=n.substring(a).match(e);if(!e)throw"Missing number at position "+a;return a+=e[0].length,parseInt(e[0],10)},b=function(t,e,i){var s=-1,e=V.map(_(t)?i:e,function(t,e){return[[e,t]]}).sort(function(t,e){return-(t[1].length-e[1].length)});if(V.each(e,function(t,e){var i=e[1];if(n.substr(a,i.length).toLowerCase()===i.toLowerCase())return s=e[0],a+=i.length,!1}),-1!==s)return s+1;throw"Unknown name at position "+a},y=function(){if(n.charAt(a)!==e.charAt(w))throw"Unexpected literal at position "+a;a++},w=0;w<e.length;w++)if(m)"'"!==e.charAt(w)||_("'")?y():m=!1;else switch(e.charAt(w)){case"d":f=v("d");break;case"D":b("D",l,h);break;case"o":g=v("o");break;case"m":p=v("m");break;case"M":p=b("M",c,u);break;case"y":d=v("y");break;case"@":d=(o=new Date(v("@"))).getFullYear(),p=o.getMonth()+1,f=o.getDate();break;case"!":d=(o=new Date((v("!")-this._ticksTo1970)/1e4)).getFullYear(),p=o.getMonth()+1,f=o.getDate();break;case"'":_("'")?y():m=!0;break;default:y()}if(a<n.length&&(s=n.substr(a),!/^\s+/.test(s)))throw"Extra/unparsed characters found in date: "+s;if(-1===d?d=(new Date).getFullYear():d<100&&(d+=(new Date).getFullYear()-(new Date).getFullYear()%100+(d<=r?0:-100)),-1<g)for(p=1,f=g;;){if(f<=(i=this._getDaysInMonth(d,p-1)))break;p++,f-=i}if((o=this._daylightSavingAdjust(new Date(d,p-1,f))).getFullYear()!==d||o.getMonth()+1!==p||o.getDate()!==f)throw"Invalid date";return o},ATOM:"yy-mm-dd",COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",TICKS:"!",TIMESTAMP:"@",W3C:"yy-mm-dd",_ticksTo1970:24*(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925))*60*60*1e7,formatDate:function(e,t,i){if(!t)return"";function s(t,e,i){var s=""+e;if(c(t))for(;s.length<i;)s="0"+s;return s}function n(t,e,i,s){return(c(t)?s:i)[e]}var o,a=(i?i.dayNamesShort:null)||this._defaults.dayNamesShort,r=(i?i.dayNames:null)||this._defaults.dayNames,l=(i?i.monthNamesShort:null)||this._defaults.monthNamesShort,h=(i?i.monthNames:null)||this._defaults.monthNames,c=function(t){t=o+1<e.length&&e.charAt(o+1)===t;return t&&o++,t},u="",d=!1;if(t)for(o=0;o<e.length;o++)if(d)"'"!==e.charAt(o)||c("'")?u+=e.charAt(o):d=!1;else switch(e.charAt(o)){case"d":u+=s("d",t.getDate(),2);break;case"D":u+=n("D",t.getDay(),a,r);break;case"o":u+=s("o",Math.round((new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()-new Date(t.getFullYear(),0,0).getTime())/864e5),3);break;case"m":u+=s("m",t.getMonth()+1,2);break;case"M":u+=n("M",t.getMonth(),l,h);break;case"y":u+=c("y")?t.getFullYear():(t.getFullYear()%100<10?"0":"")+t.getFullYear()%100;break;case"@":u+=t.getTime();break;case"!":u+=1e4*t.getTime()+this._ticksTo1970;break;case"'":c("'")?u+="'":d=!0;break;default:u+=e.charAt(o)}return u},_possibleChars:function(e){for(var t="",i=!1,s=function(t){t=n+1<e.length&&e.charAt(n+1)===t;return t&&n++,t},n=0;n<e.length;n++)if(i)"'"!==e.charAt(n)||s("'")?t+=e.charAt(n):i=!1;else switch(e.charAt(n)){case"d":case"m":case"y":case"@":t+="0123456789";break;case"D":case"M":return null;case"'":s("'")?t+="'":i=!0;break;default:t+=e.charAt(n)}return t},_get:function(t,e){return(void 0!==t.settings[e]?t.settings:this._defaults)[e]},_setDateFromField:function(t,e){if(t.input.val()!==t.lastVal){var i=this._get(t,"dateFormat"),s=t.lastVal=t.input?t.input.val():null,n=this._getDefaultDate(t),o=n,a=this._getFormatConfig(t);try{o=this.parseDate(i,s,a)||n}catch(t){s=e?"":s}t.selectedDay=o.getDate(),t.drawMonth=t.selectedMonth=o.getMonth(),t.drawYear=t.selectedYear=o.getFullYear(),t.currentDay=s?o.getDate():0,t.currentMonth=s?o.getMonth():0,t.currentYear=s?o.getFullYear():0,this._adjustInstDate(t)}},_getDefaultDate:function(t){return this._restrictMinMax(t,this._determineDate(t,this._get(t,"defaultDate"),new Date))},_determineDate:function(r,t,e){var i,s,t=null==t||""===t?e:"string"==typeof t?function(t){try{return V.datepicker.parseDate(V.datepicker._get(r,"dateFormat"),t,V.datepicker._getFormatConfig(r))}catch(t){}for(var e=(t.toLowerCase().match(/^c/)?V.datepicker._getDate(r):null)||new Date,i=e.getFullYear(),s=e.getMonth(),n=e.getDate(),o=/([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,a=o.exec(t);a;){switch(a[2]||"d"){case"d":case"D":n+=parseInt(a[1],10);break;case"w":case"W":n+=7*parseInt(a[1],10);break;case"m":case"M":s+=parseInt(a[1],10),n=Math.min(n,V.datepicker._getDaysInMonth(i,s));break;case"y":case"Y":i+=parseInt(a[1],10),n=Math.min(n,V.datepicker._getDaysInMonth(i,s))}a=o.exec(t)}return new Date(i,s,n)}(t):"number"==typeof t?isNaN(t)?e:(i=t,(s=new Date).setDate(s.getDate()+i),s):new Date(t.getTime());return(t=t&&"Invalid Date"===t.toString()?e:t)&&(t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0)),this._daylightSavingAdjust(t)},_daylightSavingAdjust:function(t){return t?(t.setHours(12<t.getHours()?t.getHours()+2:0),t):null},_setDate:function(t,e,i){var s=!e,n=t.selectedMonth,o=t.selectedYear,e=this._restrictMinMax(t,this._determineDate(t,e,new Date));t.selectedDay=t.currentDay=e.getDate(),t.drawMonth=t.selectedMonth=t.currentMonth=e.getMonth(),t.drawYear=t.selectedYear=t.currentYear=e.getFullYear(),n===t.selectedMonth&&o===t.selectedYear||i||this._notifyChange(t),this._adjustInstDate(t),t.input&&t.input.val(s?"":this._formatDate(t))},_getDate:function(t){return!t.currentYear||t.input&&""===t.input.val()?null:this._daylightSavingAdjust(new Date(t.currentYear,t.currentMonth,t.currentDay))},_attachHandlers:function(t){var e=this._get(t,"stepMonths"),i="#"+t.id.replace(/\\\\/g,"\\");t.dpDiv.find("[data-handler]").map(function(){var t={prev:function(){V.datepicker._adjustDate(i,-e,"M")},next:function(){V.datepicker._adjustDate(i,+e,"M")},hide:function(){V.datepicker._hideDatepicker()},today:function(){V.datepicker._gotoToday(i)},selectDay:function(){return V.datepicker._selectDay(i,+this.getAttribute("data-month"),+this.getAttribute("data-year"),this),!1},selectMonth:function(){return V.datepicker._selectMonthYear(i,this,"M"),!1},selectYear:function(){return V.datepicker._selectMonthYear(i,this,"Y"),!1}};V(this).on(this.getAttribute("data-event"),t[this.getAttribute("data-handler")])})},_generateHTML:function(t){var e,i,s,n,o,a,r,l,h,c,u,d,p,f,g,m,_,v,b,y,w,x,k,C,D,I,T,P,M,S,H,z,A=new Date,O=this._daylightSavingAdjust(new Date(A.getFullYear(),A.getMonth(),A.getDate())),N=this._get(t,"isRTL"),E=this._get(t,"showButtonPanel"),W=this._get(t,"hideIfNoPrevNext"),F=this._get(t,"navigationAsDateFormat"),L=this._getNumberOfMonths(t),R=this._get(t,"showCurrentAtPos"),A=this._get(t,"stepMonths"),Y=1!==L[0]||1!==L[1],B=this._daylightSavingAdjust(t.currentDay?new Date(t.currentYear,t.currentMonth,t.currentDay):new Date(9999,9,9)),j=this._getMinMaxDate(t,"min"),q=this._getMinMaxDate(t,"max"),K=t.drawMonth-R,U=t.drawYear;if(K<0&&(K+=12,U--),q)for(e=this._daylightSavingAdjust(new Date(q.getFullYear(),q.getMonth()-L[0]*L[1]+1,q.getDate())),e=j&&e<j?j:e;this._daylightSavingAdjust(new Date(U,K,1))>e;)--K<0&&(K=11,U--);for(t.drawMonth=K,t.drawYear=U,R=this._get(t,"prevText"),R=F?this.formatDate(R,this._daylightSavingAdjust(new Date(U,K-A,1)),this._getFormatConfig(t)):R,i=this._canAdjustMonth(t,-1,U,K)?V("<a>").attr({class:"ui-datepicker-prev ui-corner-all","data-handler":"prev","data-event":"click",title:R}).append(V("<span>").addClass("ui-icon ui-icon-circle-triangle-"+(N?"e":"w")).text(R))[0].outerHTML:W?"":V("<a>").attr({class:"ui-datepicker-prev ui-corner-all ui-state-disabled",title:R}).append(V("<span>").addClass("ui-icon ui-icon-circle-triangle-"+(N?"e":"w")).text(R))[0].outerHTML,R=this._get(t,"nextText"),R=F?this.formatDate(R,this._daylightSavingAdjust(new Date(U,K+A,1)),this._getFormatConfig(t)):R,s=this._canAdjustMonth(t,1,U,K)?V("<a>").attr({class:"ui-datepicker-next ui-corner-all","data-handler":"next","data-event":"click",title:R}).append(V("<span>").addClass("ui-icon ui-icon-circle-triangle-"+(N?"w":"e")).text(R))[0].outerHTML:W?"":V("<a>").attr({class:"ui-datepicker-next ui-corner-all ui-state-disabled",title:R}).append(V("<span>").attr("class","ui-icon ui-icon-circle-triangle-"+(N?"w":"e")).text(R))[0].outerHTML,A=this._get(t,"currentText"),W=this._get(t,"gotoCurrent")&&t.currentDay?B:O,A=F?this.formatDate(A,W,this._getFormatConfig(t)):A,R="",t.inline||(R=V("<button>").attr({type:"button",class:"ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all","data-handler":"hide","data-event":"click"}).text(this._get(t,"closeText"))[0].outerHTML),F="",E&&(F=V("<div class='ui-datepicker-buttonpane ui-widget-content'>").append(N?R:"").append(this._isInRange(t,W)?V("<button>").attr({type:"button",class:"ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all","data-handler":"today","data-event":"click"}).text(A):"").append(N?"":R)[0].outerHTML),n=parseInt(this._get(t,"firstDay"),10),n=isNaN(n)?0:n,o=this._get(t,"showWeek"),a=this._get(t,"dayNames"),r=this._get(t,"dayNamesMin"),l=this._get(t,"monthNames"),h=this._get(t,"monthNamesShort"),c=this._get(t,"beforeShowDay"),u=this._get(t,"showOtherMonths"),d=this._get(t,"selectOtherMonths"),p=this._getDefaultDate(t),f="",m=0;m<L[0];m++){for(_="",this.maxRows=4,v=0;v<L[1];v++){if(b=this._daylightSavingAdjust(new Date(U,K,t.selectedDay)),y=" ui-corner-all",w="",Y){if(w+="<div class='ui-datepicker-group",1<L[1])switch(v){case 0:w+=" ui-datepicker-group-first",y=" ui-corner-"+(N?"right":"left");break;case L[1]-1:w+=" ui-datepicker-group-last",y=" ui-corner-"+(N?"left":"right");break;default:w+=" ui-datepicker-group-middle",y=""}w+="'>"}for(w+="<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix"+y+"'>"+(/all|left/.test(y)&&0===m?N?s:i:"")+(/all|right/.test(y)&&0===m?N?i:s:"")+this._generateMonthYearHeader(t,K,U,j,q,0<m||0<v,l,h)+"</div><table class='ui-datepicker-calendar'><thead><tr>",x=o?"<th class='ui-datepicker-week-col'>"+this._get(t,"weekHeader")+"</th>":"",g=0;g<7;g++)x+="<th scope='col'"+(5<=(g+n+6)%7?" class='ui-datepicker-week-end'":"")+"><span title='"+a[k=(g+n)%7]+"'>"+r[k]+"</span></th>";for(w+=x+"</tr></thead><tbody>",D=this._getDaysInMonth(U,K),U===t.selectedYear&&K===t.selectedMonth&&(t.selectedDay=Math.min(t.selectedDay,D)),C=(this._getFirstDayOfMonth(U,K)-n+7)%7,D=Math.ceil((C+D)/7),I=Y&&this.maxRows>D?this.maxRows:D,this.maxRows=I,T=this._daylightSavingAdjust(new Date(U,K,1-C)),P=0;P<I;P++){for(w+="<tr>",M=o?"<td class='ui-datepicker-week-col'>"+this._get(t,"calculateWeek")(T)+"</td>":"",g=0;g<7;g++)S=c?c.apply(t.input?t.input[0]:null,[T]):[!0,""],z=(H=T.getMonth()!==K)&&!d||!S[0]||j&&T<j||q&&q<T,M+="<td class='"+(5<=(g+n+6)%7?" ui-datepicker-week-end":"")+(H?" ui-datepicker-other-month":"")+(T.getTime()===b.getTime()&&K===t.selectedMonth&&t._keyEvent||p.getTime()===T.getTime()&&p.getTime()===b.getTime()?" "+this._dayOverClass:"")+(z?" "+this._unselectableClass+" ui-state-disabled":"")+(H&&!u?"":" "+S[1]+(T.getTime()===B.getTime()?" "+this._currentClass:"")+(T.getTime()===O.getTime()?" ui-datepicker-today":""))+"'"+(H&&!u||!S[2]?"":" title='"+S[2].replace(/'/g,"'")+"'")+(z?"":" data-handler='selectDay' data-event='click' data-month='"+T.getMonth()+"' data-year='"+T.getFullYear()+"'")+">"+(H&&!u?" ":z?"<span class='ui-state-default'>"+T.getDate()+"</span>":"<a class='ui-state-default"+(T.getTime()===O.getTime()?" ui-state-highlight":"")+(T.getTime()===B.getTime()?" ui-state-active":"")+(H?" ui-priority-secondary":"")+"' href='#' aria-current='"+(T.getTime()===B.getTime()?"true":"false")+"' data-date='"+T.getDate()+"'>"+T.getDate()+"</a>")+"</td>",T.setDate(T.getDate()+1),T=this._daylightSavingAdjust(T);w+=M+"</tr>"}11<++K&&(K=0,U++),_+=w+="</tbody></table>"+(Y?"</div>"+(0<L[0]&&v===L[1]-1?"<div class='ui-datepicker-row-break'></div>":""):"")}f+=_}return f+=F,t._keyEvent=!1,f},_generateMonthYearHeader:function(t,e,i,s,n,o,a,r){var l,h,c,u,d,p,f=this._get(t,"changeMonth"),g=this._get(t,"changeYear"),m=this._get(t,"showMonthAfterYear"),_=this._get(t,"selectMonthLabel"),v=this._get(t,"selectYearLabel"),b="<div class='ui-datepicker-title'>",y="";if(o||!f)y+="<span class='ui-datepicker-month'>"+a[e]+"</span>";else{for(l=s&&s.getFullYear()===i,h=n&&n.getFullYear()===i,y+="<select class='ui-datepicker-month' aria-label='"+_+"' data-handler='selectMonth' data-event='change'>",c=0;c<12;c++)(!l||c>=s.getMonth())&&(!h||c<=n.getMonth())&&(y+="<option value='"+c+"'"+(c===e?" selected='selected'":"")+">"+r[c]+"</option>");y+="</select>"}if(m||(b+=y+(!o&&f&&g?"":" ")),!t.yearshtml)if(t.yearshtml="",o||!g)b+="<span class='ui-datepicker-year'>"+i+"</span>";else{for(a=this._get(t,"yearRange").split(":"),u=(new Date).getFullYear(),d=(_=function(t){t=t.match(/c[+\-].*/)?i+parseInt(t.substring(1),10):t.match(/[+\-].*/)?u+parseInt(t,10):parseInt(t,10);return isNaN(t)?u:t})(a[0]),p=Math.max(d,_(a[1]||"")),d=s?Math.max(d,s.getFullYear()):d,p=n?Math.min(p,n.getFullYear()):p,t.yearshtml+="<select class='ui-datepicker-year' aria-label='"+v+"' data-handler='selectYear' data-event='change'>";d<=p;d++)t.yearshtml+="<option value='"+d+"'"+(d===i?" selected='selected'":"")+">"+d+"</option>";t.yearshtml+="</select>",b+=t.yearshtml,t.yearshtml=null}return b+=this._get(t,"yearSuffix"),m&&(b+=(!o&&f&&g?"":" ")+y),b+="</div>"},_adjustInstDate:function(t,e,i){var s=t.selectedYear+("Y"===i?e:0),n=t.selectedMonth+("M"===i?e:0),e=Math.min(t.selectedDay,this._getDaysInMonth(s,n))+("D"===i?e:0),e=this._restrictMinMax(t,this._daylightSavingAdjust(new Date(s,n,e)));t.selectedDay=e.getDate(),t.drawMonth=t.selectedMonth=e.getMonth(),t.drawYear=t.selectedYear=e.getFullYear(),"M"!==i&&"Y"!==i||this._notifyChange(t)},_restrictMinMax:function(t,e){var i=this._getMinMaxDate(t,"min"),t=this._getMinMaxDate(t,"max"),e=i&&e<i?i:e;return t&&t<e?t:e},_notifyChange:function(t){var e=this._get(t,"onChangeMonthYear");e&&e.apply(t.input?t.input[0]:null,[t.selectedYear,t.selectedMonth+1,t])},_getNumberOfMonths:function(t){t=this._get(t,"numberOfMonths");return null==t?[1,1]:"number"==typeof t?[1,t]:t},_getMinMaxDate:function(t,e){return this._determineDate(t,this._get(t,e+"Date"),null)},_getDaysInMonth:function(t,e){return 32-this._daylightSavingAdjust(new Date(t,e,32)).getDate()},_getFirstDayOfMonth:function(t,e){return new Date(t,e,1).getDay()},_canAdjustMonth:function(t,e,i,s){var n=this._getNumberOfMonths(t),n=this._daylightSavingAdjust(new Date(i,s+(e<0?e:n[0]*n[1]),1));return e<0&&n.setDate(this._getDaysInMonth(n.getFullYear(),n.getMonth())),this._isInRange(t,n)},_isInRange:function(t,e){var i=this._getMinMaxDate(t,"min"),s=this._getMinMaxDate(t,"max"),n=null,o=null,a=this._get(t,"yearRange");return a&&(t=a.split(":"),a=(new Date).getFullYear(),n=parseInt(t[0],10),o=parseInt(t[1],10),t[0].match(/[+\-].*/)&&(n+=a),t[1].match(/[+\-].*/)&&(o+=a)),(!i||e.getTime()>=i.getTime())&&(!s||e.getTime()<=s.getTime())&&(!n||e.getFullYear()>=n)&&(!o||e.getFullYear()<=o)},_getFormatConfig:function(t){var e=this._get(t,"shortYearCutoff");return{shortYearCutoff:e="string"!=typeof e?e:(new Date).getFullYear()%100+parseInt(e,10),dayNamesShort:this._get(t,"dayNamesShort"),dayNames:this._get(t,"dayNames"),monthNamesShort:this._get(t,"monthNamesShort"),monthNames:this._get(t,"monthNames")}},_formatDate:function(t,e,i,s){e||(t.currentDay=t.selectedDay,t.currentMonth=t.selectedMonth,t.currentYear=t.selectedYear);e=e?"object"==typeof e?e:this._daylightSavingAdjust(new Date(s,i,e)):this._daylightSavingAdjust(new Date(t.currentYear,t.currentMonth,t.currentDay));return this.formatDate(this._get(t,"dateFormat"),e,this._getFormatConfig(t))}}),V.fn.datepicker=function(t){if(!this.length)return this;V.datepicker.initialized||(V(document).on("mousedown",V.datepicker._checkExternalClick),V.datepicker.initialized=!0),0===V("#"+V.datepicker._mainDivId).length&&V("body").append(V.datepicker.dpDiv);var e=Array.prototype.slice.call(arguments,1);return"string"==typeof t&&("isDisabled"===t||"getDate"===t||"widget"===t)||"option"===t&&2===arguments.length&&"string"==typeof arguments[1]?V.datepicker["_"+t+"Datepicker"].apply(V.datepicker,[this[0]].concat(e)):this.each(function(){"string"==typeof t?V.datepicker["_"+t+"Datepicker"].apply(V.datepicker,[this].concat(e)):V.datepicker._attachDatepicker(this,t)})},V.datepicker=new st,V.datepicker.initialized=!1,V.datepicker.uuid=(new Date).getTime(),V.datepicker.version="1.13.2";V.datepicker,V.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase());var rt=!1;V(document).on("mouseup",function(){rt=!1});V.widget("ui.mouse",{version:"1.13.2",options:{cancel:"input, textarea, button, select, option",distance:1,delay:0},_mouseInit:function(){var e=this;this.element.on("mousedown."+this.widgetName,function(t){return e._mouseDown(t)}).on("click."+this.widgetName,function(t){if(!0===V.data(t.target,e.widgetName+".preventClickEvent"))return V.removeData(t.target,e.widgetName+".preventClickEvent"),t.stopImmediatePropagation(),!1}),this.started=!1},_mouseDestroy:function(){this.element.off("."+this.widgetName),this._mouseMoveDelegate&&this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(t){if(!rt){this._mouseMoved=!1,this._mouseStarted&&this._mouseUp(t),this._mouseDownEvent=t;var e=this,i=1===t.which,s=!("string"!=typeof this.options.cancel||!t.target.nodeName)&&V(t.target).closest(this.options.cancel).length;return i&&!s&&this._mouseCapture(t)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){e.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=!1!==this._mouseStart(t),!this._mouseStarted)?(t.preventDefault(),!0):(!0===V.data(t.target,this.widgetName+".preventClickEvent")&&V.removeData(t.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(t){return e._mouseMove(t)},this._mouseUpDelegate=function(t){return e._mouseUp(t)},this.document.on("mousemove."+this.widgetName,this._mouseMoveDelegate).on("mouseup."+this.widgetName,this._mouseUpDelegate),t.preventDefault(),rt=!0)):!0}},_mouseMove:function(t){if(this._mouseMoved){if(V.ui.ie&&(!document.documentMode||document.documentMode<9)&&!t.button)return this._mouseUp(t);if(!t.which)if(t.originalEvent.altKey||t.originalEvent.ctrlKey||t.originalEvent.metaKey||t.originalEvent.shiftKey)this.ignoreMissingWhich=!0;else if(!this.ignoreMissingWhich)return this._mouseUp(t)}return(t.which||t.button)&&(this._mouseMoved=!0),this._mouseStarted?(this._mouseDrag(t),t.preventDefault()):(this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=!1!==this._mouseStart(this._mouseDownEvent,t),this._mouseStarted?this._mouseDrag(t):this._mouseUp(t)),!this._mouseStarted)},_mouseUp:function(t){this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,t.target===this._mouseDownEvent.target&&V.data(t.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(t)),this._mouseDelayTimer&&(clearTimeout(this._mouseDelayTimer),delete this._mouseDelayTimer),this.ignoreMissingWhich=!1,rt=!1,t.preventDefault()},_mouseDistanceMet:function(t){return Math.max(Math.abs(this._mouseDownEvent.pageX-t.pageX),Math.abs(this._mouseDownEvent.pageY-t.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}}),V.ui.plugin={add:function(t,e,i){var s,n=V.ui[t].prototype;for(s in i)n.plugins[s]=n.plugins[s]||[],n.plugins[s].push([e,i[s]])},call:function(t,e,i,s){var n,o=t.plugins[e];if(o&&(s||t.element[0].parentNode&&11!==t.element[0].parentNode.nodeType))for(n=0;n<o.length;n++)t.options[o[n][0]]&&o[n][1].apply(t.element,i)}},V.ui.safeBlur=function(t){t&&"body"!==t.nodeName.toLowerCase()&&V(t).trigger("blur")};V.widget("ui.draggable",V.ui.mouse,{version:"1.13.2",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1,drag:null,start:null,stop:null},_create:function(){"original"===this.options.helper&&this._setPositionRelative(),this.options.addClasses&&this._addClass("ui-draggable"),this._setHandleClassName(),this._mouseInit()},_setOption:function(t,e){this._super(t,e),"handle"===t&&(this._removeHandleClassName(),this._setHandleClassName())},_destroy:function(){(this.helper||this.element).is(".ui-draggable-dragging")?this.destroyOnClear=!0:(this._removeHandleClassName(),this._mouseDestroy())},_mouseCapture:function(t){var e=this.options;return!(this.helper||e.disabled||0<V(t.target).closest(".ui-resizable-handle").length)&&(this.handle=this._getHandle(t),!!this.handle&&(this._blurActiveElement(t),this._blockFrames(!0===e.iframeFix?"iframe":e.iframeFix),!0))},_blockFrames:function(t){this.iframeBlocks=this.document.find(t).map(function(){var t=V(this);return V("<div>").css("position","absolute").appendTo(t.parent()).outerWidth(t.outerWidth()).outerHeight(t.outerHeight()).offset(t.offset())[0]})},_unblockFrames:function(){this.iframeBlocks&&(this.iframeBlocks.remove(),delete this.iframeBlocks)},_blurActiveElement:function(t){var e=V.ui.safeActiveElement(this.document[0]);V(t.target).closest(e).length||V.ui.safeBlur(e)},_mouseStart:function(t){var e=this.options;return this.helper=this._createHelper(t),this._addClass(this.helper,"ui-draggable-dragging"),this._cacheHelperProportions(),V.ui.ddmanager&&(V.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(!0),this.offsetParent=this.helper.offsetParent(),this.hasFixedAncestor=0<this.helper.parents().filter(function(){return"fixed"===V(this).css("position")}).length,this.positionAbs=this.element.offset(),this._refreshOffsets(t),this.originalPosition=this.position=this._generatePosition(t,!1),this.originalPageX=t.pageX,this.originalPageY=t.pageY,e.cursorAt&&this._adjustOffsetFromHelper(e.cursorAt),this._setContainment(),!1===this._trigger("start",t)?(this._clear(),!1):(this._cacheHelperProportions(),V.ui.ddmanager&&!e.dropBehaviour&&V.ui.ddmanager.prepareOffsets(this,t),this._mouseDrag(t,!0),V.ui.ddmanager&&V.ui.ddmanager.dragStart(this,t),!0)},_refreshOffsets:function(t){this.offset={top:this.positionAbs.top-this.margins.top,left:this.positionAbs.left-this.margins.left,scroll:!1,parent:this._getParentOffset(),relative:this._getRelativeOffset()},this.offset.click={left:t.pageX-this.offset.left,top:t.pageY-this.offset.top}},_mouseDrag:function(t,e){if(this.hasFixedAncestor&&(this.offset.parent=this._getParentOffset()),this.position=this._generatePosition(t,!0),this.positionAbs=this._convertPositionTo("absolute"),!e){e=this._uiHash();if(!1===this._trigger("drag",t,e))return this._mouseUp(new V.Event("mouseup",t)),!1;this.position=e.position}return this.helper[0].style.left=this.position.left+"px",this.helper[0].style.top=this.position.top+"px",V.ui.ddmanager&&V.ui.ddmanager.drag(this,t),!1},_mouseStop:function(t){var e=this,i=!1;return V.ui.ddmanager&&!this.options.dropBehaviour&&(i=V.ui.ddmanager.drop(this,t)),this.dropped&&(i=this.dropped,this.dropped=!1),"invalid"===this.options.revert&&!i||"valid"===this.options.revert&&i||!0===this.options.revert||"function"==typeof this.options.revert&&this.options.revert.call(this.element,i)?V(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){!1!==e._trigger("stop",t)&&e._clear()}):!1!==this._trigger("stop",t)&&this._clear(),!1},_mouseUp:function(t){return this._unblockFrames(),V.ui.ddmanager&&V.ui.ddmanager.dragStop(this,t),this.handleElement.is(t.target)&&this.element.trigger("focus"),V.ui.mouse.prototype._mouseUp.call(this,t)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp(new V.Event("mouseup",{target:this.element[0]})):this._clear(),this},_getHandle:function(t){return!this.options.handle||!!V(t.target).closest(this.element.find(this.options.handle)).length},_setHandleClassName:function(){this.handleElement=this.options.handle?this.element.find(this.options.handle):this.element,this._addClass(this.handleElement,"ui-draggable-handle")},_removeHandleClassName:function(){this._removeClass(this.handleElement,"ui-draggable-handle")},_createHelper:function(t){var e=this.options,i="function"==typeof e.helper,t=i?V(e.helper.apply(this.element[0],[t])):"clone"===e.helper?this.element.clone().removeAttr("id"):this.element;return t.parents("body").length||t.appendTo("parent"===e.appendTo?this.element[0].parentNode:e.appendTo),i&&t[0]===this.element[0]&&this._setPositionRelative(),t[0]===this.element[0]||/(fixed|absolute)/.test(t.css("position"))||t.css("position","absolute"),t},_setPositionRelative:function(){/^(?:r|a|f)/.test(this.element.css("position"))||(this.element[0].style.position="relative")},_adjustOffsetFromHelper:function(t){"string"==typeof t&&(t=t.split(" ")),"left"in(t=Array.isArray(t)?{left:+t[0],top:+t[1]||0}:t)&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_isRootNode:function(t){return/(html|body)/i.test(t.tagName)||t===this.document[0]},_getParentOffset:function(){var t=this.offsetParent.offset(),e=this.document[0];return"absolute"===this.cssPosition&&this.scrollParent[0]!==e&&V.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop()),{top:(t=this._isRootNode(this.offsetParent[0])?{top:0,left:0}:t).top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"!==this.cssPosition)return{top:0,left:0};var t=this.element.position(),e=this._isRootNode(this.scrollParent[0]);return{top:t.top-(parseInt(this.helper.css("top"),10)||0)+(e?0:this.scrollParent.scrollTop()),left:t.left-(parseInt(this.helper.css("left"),10)||0)+(e?0:this.scrollParent.scrollLeft())}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t,e,i,s=this.options,n=this.document[0];this.relativeContainer=null,s.containment?"window"!==s.containment?"document"!==s.containment?s.containment.constructor!==Array?("parent"===s.containment&&(s.containment=this.helper[0].parentNode),(i=(e=V(s.containment))[0])&&(t=/(scroll|auto)/.test(e.css("overflow")),this.containment=[(parseInt(e.css("borderLeftWidth"),10)||0)+(parseInt(e.css("paddingLeft"),10)||0),(parseInt(e.css("borderTopWidth"),10)||0)+(parseInt(e.css("paddingTop"),10)||0),(t?Math.max(i.scrollWidth,i.offsetWidth):i.offsetWidth)-(parseInt(e.css("borderRightWidth"),10)||0)-(parseInt(e.css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(t?Math.max(i.scrollHeight,i.offsetHeight):i.offsetHeight)-(parseInt(e.css("borderBottomWidth"),10)||0)-(parseInt(e.css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relativeContainer=e)):this.containment=s.containment:this.containment=[0,0,V(n).width()-this.helperProportions.width-this.margins.left,(V(n).height()||n.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]:this.containment=[V(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,V(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,V(window).scrollLeft()+V(window).width()-this.helperProportions.width-this.margins.left,V(window).scrollTop()+(V(window).height()||n.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]:this.containment=null},_convertPositionTo:function(t,e){e=e||this.position;var i="absolute"===t?1:-1,t=this._isRootNode(this.scrollParent[0]);return{top:e.top+this.offset.relative.top*i+this.offset.parent.top*i-("fixed"===this.cssPosition?-this.offset.scroll.top:t?0:this.offset.scroll.top)*i,left:e.left+this.offset.relative.left*i+this.offset.parent.left*i-("fixed"===this.cssPosition?-this.offset.scroll.left:t?0:this.offset.scroll.left)*i}},_generatePosition:function(t,e){var i,s=this.options,n=this._isRootNode(this.scrollParent[0]),o=t.pageX,a=t.pageY;return n&&this.offset.scroll||(this.offset.scroll={top:this.scrollParent.scrollTop(),left:this.scrollParent.scrollLeft()}),e&&(this.containment&&(i=this.relativeContainer?(i=this.relativeContainer.offset(),[this.containment[0]+i.left,this.containment[1]+i.top,this.containment[2]+i.left,this.containment[3]+i.top]):this.containment,t.pageX-this.offset.click.left<i[0]&&(o=i[0]+this.offset.click.left),t.pageY-this.offset.click.top<i[1]&&(a=i[1]+this.offset.click.top),t.pageX-this.offset.click.left>i[2]&&(o=i[2]+this.offset.click.left),t.pageY-this.offset.click.top>i[3]&&(a=i[3]+this.offset.click.top)),s.grid&&(t=s.grid[1]?this.originalPageY+Math.round((a-this.originalPageY)/s.grid[1])*s.grid[1]:this.originalPageY,a=!i||t-this.offset.click.top>=i[1]||t-this.offset.click.top>i[3]?t:t-this.offset.click.top>=i[1]?t-s.grid[1]:t+s.grid[1],t=s.grid[0]?this.originalPageX+Math.round((o-this.originalPageX)/s.grid[0])*s.grid[0]:this.originalPageX,o=!i||t-this.offset.click.left>=i[0]||t-this.offset.click.left>i[2]?t:t-this.offset.click.left>=i[0]?t-s.grid[0]:t+s.grid[0]),"y"===s.axis&&(o=this.originalPageX),"x"===s.axis&&(a=this.originalPageY)),{top:a-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.offset.scroll.top:n?0:this.offset.scroll.top),left:o-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.offset.scroll.left:n?0:this.offset.scroll.left)}},_clear:function(){this._removeClass(this.helper,"ui-draggable-dragging"),this.helper[0]===this.element[0]||this.cancelHelperRemoval||this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1,this.destroyOnClear&&this.destroy()},_trigger:function(t,e,i){return i=i||this._uiHash(),V.ui.plugin.call(this,t,[e,i,this],!0),/^(drag|start|stop)/.test(t)&&(this.positionAbs=this._convertPositionTo("absolute"),i.offset=this.positionAbs),V.Widget.prototype._trigger.call(this,t,e,i)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),V.ui.plugin.add("draggable","connectToSortable",{start:function(e,t,i){var s=V.extend({},t,{item:i.element});i.sortables=[],V(i.options.connectToSortable).each(function(){var t=V(this).sortable("instance");t&&!t.options.disabled&&(i.sortables.push(t),t.refreshPositions(),t._trigger("activate",e,s))})},stop:function(e,t,i){var s=V.extend({},t,{item:i.element});i.cancelHelperRemoval=!1,V.each(i.sortables,function(){var t=this;t.isOver?(t.isOver=0,i.cancelHelperRemoval=!0,t.cancelHelperRemoval=!1,t._storedCSS={position:t.placeholder.css("position"),top:t.placeholder.css("top"),left:t.placeholder.css("left")},t._mouseStop(e),t.options.helper=t.options._helper):(t.cancelHelperRemoval=!0,t._trigger("deactivate",e,s))})},drag:function(i,s,n){V.each(n.sortables,function(){var t=!1,e=this;e.positionAbs=n.positionAbs,e.helperProportions=n.helperProportions,e.offset.click=n.offset.click,e._intersectsWith(e.containerCache)&&(t=!0,V.each(n.sortables,function(){return this.positionAbs=n.positionAbs,this.helperProportions=n.helperProportions,this.offset.click=n.offset.click,t=this!==e&&this._intersectsWith(this.containerCache)&&V.contains(e.element[0],this.element[0])?!1:t})),t?(e.isOver||(e.isOver=1,n._parent=s.helper.parent(),e.currentItem=s.helper.appendTo(e.element).data("ui-sortable-item",!0),e.options._helper=e.options.helper,e.options.helper=function(){return s.helper[0]},i.target=e.currentItem[0],e._mouseCapture(i,!0),e._mouseStart(i,!0,!0),e.offset.click.top=n.offset.click.top,e.offset.click.left=n.offset.click.left,e.offset.parent.left-=n.offset.parent.left-e.offset.parent.left,e.offset.parent.top-=n.offset.parent.top-e.offset.parent.top,n._trigger("toSortable",i),n.dropped=e.element,V.each(n.sortables,function(){this.refreshPositions()}),n.currentItem=n.element,e.fromOutside=n),e.currentItem&&(e._mouseDrag(i),s.position=e.position)):e.isOver&&(e.isOver=0,e.cancelHelperRemoval=!0,e.options._revert=e.options.revert,e.options.revert=!1,e._trigger("out",i,e._uiHash(e)),e._mouseStop(i,!0),e.options.revert=e.options._revert,e.options.helper=e.options._helper,e.placeholder&&e.placeholder.remove(),s.helper.appendTo(n._parent),n._refreshOffsets(i),s.position=n._generatePosition(i,!0),n._trigger("fromSortable",i),n.dropped=!1,V.each(n.sortables,function(){this.refreshPositions()}))})}}),V.ui.plugin.add("draggable","cursor",{start:function(t,e,i){var s=V("body"),i=i.options;s.css("cursor")&&(i._cursor=s.css("cursor")),s.css("cursor",i.cursor)},stop:function(t,e,i){i=i.options;i._cursor&&V("body").css("cursor",i._cursor)}}),V.ui.plugin.add("draggable","opacity",{start:function(t,e,i){e=V(e.helper),i=i.options;e.css("opacity")&&(i._opacity=e.css("opacity")),e.css("opacity",i.opacity)},stop:function(t,e,i){i=i.options;i._opacity&&V(e.helper).css("opacity",i._opacity)}}),V.ui.plugin.add("draggable","scroll",{start:function(t,e,i){i.scrollParentNotHidden||(i.scrollParentNotHidden=i.helper.scrollParent(!1)),i.scrollParentNotHidden[0]!==i.document[0]&&"HTML"!==i.scrollParentNotHidden[0].tagName&&(i.overflowOffset=i.scrollParentNotHidden.offset())},drag:function(t,e,i){var s=i.options,n=!1,o=i.scrollParentNotHidden[0],a=i.document[0];o!==a&&"HTML"!==o.tagName?(s.axis&&"x"===s.axis||(i.overflowOffset.top+o.offsetHeight-t.pageY<s.scrollSensitivity?o.scrollTop=n=o.scrollTop+s.scrollSpeed:t.pageY-i.overflowOffset.top<s.scrollSensitivity&&(o.scrollTop=n=o.scrollTop-s.scrollSpeed)),s.axis&&"y"===s.axis||(i.overflowOffset.left+o.offsetWidth-t.pageX<s.scrollSensitivity?o.scrollLeft=n=o.scrollLeft+s.scrollSpeed:t.pageX-i.overflowOffset.left<s.scrollSensitivity&&(o.scrollLeft=n=o.scrollLeft-s.scrollSpeed))):(s.axis&&"x"===s.axis||(t.pageY-V(a).scrollTop()<s.scrollSensitivity?n=V(a).scrollTop(V(a).scrollTop()-s.scrollSpeed):V(window).height()-(t.pageY-V(a).scrollTop())<s.scrollSensitivity&&(n=V(a).scrollTop(V(a).scrollTop()+s.scrollSpeed))),s.axis&&"y"===s.axis||(t.pageX-V(a).scrollLeft()<s.scrollSensitivity?n=V(a).scrollLeft(V(a).scrollLeft()-s.scrollSpeed):V(window).width()-(t.pageX-V(a).scrollLeft())<s.scrollSensitivity&&(n=V(a).scrollLeft(V(a).scrollLeft()+s.scrollSpeed)))),!1!==n&&V.ui.ddmanager&&!s.dropBehaviour&&V.ui.ddmanager.prepareOffsets(i,t)}}),V.ui.plugin.add("draggable","snap",{start:function(t,e,i){var s=i.options;i.snapElements=[],V(s.snap.constructor!==String?s.snap.items||":data(ui-draggable)":s.snap).each(function(){var t=V(this),e=t.offset();this!==i.element[0]&&i.snapElements.push({item:this,width:t.outerWidth(),height:t.outerHeight(),top:e.top,left:e.left})})},drag:function(t,e,i){for(var s,n,o,a,r,l,h,c,u,d=i.options,p=d.snapTolerance,f=e.offset.left,g=f+i.helperProportions.width,m=e.offset.top,_=m+i.helperProportions.height,v=i.snapElements.length-1;0<=v;v--)l=(r=i.snapElements[v].left-i.margins.left)+i.snapElements[v].width,c=(h=i.snapElements[v].top-i.margins.top)+i.snapElements[v].height,g<r-p||l+p<f||_<h-p||c+p<m||!V.contains(i.snapElements[v].item.ownerDocument,i.snapElements[v].item)?(i.snapElements[v].snapping&&i.options.snap.release&&i.options.snap.release.call(i.element,t,V.extend(i._uiHash(),{snapItem:i.snapElements[v].item})),i.snapElements[v].snapping=!1):("inner"!==d.snapMode&&(s=Math.abs(h-_)<=p,n=Math.abs(c-m)<=p,o=Math.abs(r-g)<=p,a=Math.abs(l-f)<=p,s&&(e.position.top=i._convertPositionTo("relative",{top:h-i.helperProportions.height,left:0}).top),n&&(e.position.top=i._convertPositionTo("relative",{top:c,left:0}).top),o&&(e.position.left=i._convertPositionTo("relative",{top:0,left:r-i.helperProportions.width}).left),a&&(e.position.left=i._convertPositionTo("relative",{top:0,left:l}).left)),u=s||n||o||a,"outer"!==d.snapMode&&(s=Math.abs(h-m)<=p,n=Math.abs(c-_)<=p,o=Math.abs(r-f)<=p,a=Math.abs(l-g)<=p,s&&(e.position.top=i._convertPositionTo("relative",{top:h,left:0}).top),n&&(e.position.top=i._convertPositionTo("relative",{top:c-i.helperProportions.height,left:0}).top),o&&(e.position.left=i._convertPositionTo("relative",{top:0,left:r}).left),a&&(e.position.left=i._convertPositionTo("relative",{top:0,left:l-i.helperProportions.width}).left)),!i.snapElements[v].snapping&&(s||n||o||a||u)&&i.options.snap.snap&&i.options.snap.snap.call(i.element,t,V.extend(i._uiHash(),{snapItem:i.snapElements[v].item})),i.snapElements[v].snapping=s||n||o||a||u)}}),V.ui.plugin.add("draggable","stack",{start:function(t,e,i){var s,i=i.options,i=V.makeArray(V(i.stack)).sort(function(t,e){return(parseInt(V(t).css("zIndex"),10)||0)-(parseInt(V(e).css("zIndex"),10)||0)});i.length&&(s=parseInt(V(i[0]).css("zIndex"),10)||0,V(i).each(function(t){V(this).css("zIndex",s+t)}),this.css("zIndex",s+i.length))}}),V.ui.plugin.add("draggable","zIndex",{start:function(t,e,i){e=V(e.helper),i=i.options;e.css("zIndex")&&(i._zIndex=e.css("zIndex")),e.css("zIndex",i.zIndex)},stop:function(t,e,i){i=i.options;i._zIndex&&V(e.helper).css("zIndex",i._zIndex)}});V.ui.draggable;V.widget("ui.resizable",V.ui.mouse,{version:"1.13.2",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,classes:{"ui-resizable-se":"ui-icon ui-icon-gripsmall-diagonal-se"},containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:90,resize:null,start:null,stop:null},_num:function(t){return parseFloat(t)||0},_isNumber:function(t){return!isNaN(parseFloat(t))},_hasScroll:function(t,e){if("hidden"===V(t).css("overflow"))return!1;var i=e&&"left"===e?"scrollLeft":"scrollTop",e=!1;if(0<t[i])return!0;try{t[i]=1,e=0<t[i],t[i]=0}catch(t){}return e},_create:function(){var t,e=this.options,i=this;this._addClass("ui-resizable"),V.extend(this,{_aspectRatio:!!e.aspectRatio,aspectRatio:e.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:e.helper||e.ghost||e.animate?e.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)&&(this.element.wrap(V("<div class='ui-wrapper'></div>").css({overflow:"hidden",position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.resizable("instance")),this.elementIsWrapper=!0,t={marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom"),marginLeft:this.originalElement.css("marginLeft")},this.element.css(t),this.originalElement.css("margin",0),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css(t),this._proportionallyResize()),this._setupHandles(),e.autoHide&&V(this.element).on("mouseenter",function(){e.disabled||(i._removeClass("ui-resizable-autohide"),i._handles.show())}).on("mouseleave",function(){e.disabled||i.resizing||(i._addClass("ui-resizable-autohide"),i._handles.hide())}),this._mouseInit()},_destroy:function(){this._mouseDestroy(),this._addedHandles.remove();function t(t){V(t).removeData("resizable").removeData("ui-resizable").off(".resizable")}var e;return this.elementIsWrapper&&(t(this.element),e=this.element,this.originalElement.css({position:e.css("position"),width:e.outerWidth(),height:e.outerHeight(),top:e.css("top"),left:e.css("left")}).insertAfter(e),e.remove()),this.originalElement.css("resize",this.originalResizeStyle),t(this.originalElement),this},_setOption:function(t,e){switch(this._super(t,e),t){case"handles":this._removeHandles(),this._setupHandles();break;case"aspectRatio":this._aspectRatio=!!e}},_setupHandles:function(){var t,e,i,s,n,o=this.options,a=this;if(this.handles=o.handles||(V(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this._handles=V(),this._addedHandles=V(),this.handles.constructor===String)for("all"===this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw"),i=this.handles.split(","),this.handles={},e=0;e<i.length;e++)s="ui-resizable-"+(t=String.prototype.trim.call(i[e])),n=V("<div>"),this._addClass(n,"ui-resizable-handle "+s),n.css({zIndex:o.zIndex}),this.handles[t]=".ui-resizable-"+t,this.element.children(this.handles[t]).length||(this.element.append(n),this._addedHandles=this._addedHandles.add(n));this._renderAxis=function(t){var e,i,s;for(e in t=t||this.element,this.handles)this.handles[e].constructor===String?this.handles[e]=this.element.children(this.handles[e]).first().show():(this.handles[e].jquery||this.handles[e].nodeType)&&(this.handles[e]=V(this.handles[e]),this._on(this.handles[e],{mousedown:a._mouseDown})),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)&&(i=V(this.handles[e],this.element),s=/sw|ne|nw|se|n|s/.test(e)?i.outerHeight():i.outerWidth(),i=["padding",/ne|nw|n/.test(e)?"Top":/se|sw|s/.test(e)?"Bottom":/^e$/.test(e)?"Right":"Left"].join(""),t.css(i,s),this._proportionallyResize()),this._handles=this._handles.add(this.handles[e])},this._renderAxis(this.element),this._handles=this._handles.add(this.element.find(".ui-resizable-handle")),this._handles.disableSelection(),this._handles.on("mouseover",function(){a.resizing||(this.className&&(n=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),a.axis=n&&n[1]?n[1]:"se")}),o.autoHide&&(this._handles.hide(),this._addClass("ui-resizable-autohide"))},_removeHandles:function(){this._addedHandles.remove()},_mouseCapture:function(t){var e,i,s=!1;for(e in this.handles)(i=V(this.handles[e])[0])!==t.target&&!V.contains(i,t.target)||(s=!0);return!this.options.disabled&&s},_mouseStart:function(t){var e,i,s=this.options,n=this.element;return this.resizing=!0,this._renderProxy(),e=this._num(this.helper.css("left")),i=this._num(this.helper.css("top")),s.containment&&(e+=V(s.containment).scrollLeft()||0,i+=V(s.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:e,top:i},this.size=this._helper?{width:this.helper.width(),height:this.helper.height()}:{width:n.width(),height:n.height()},this.originalSize=this._helper?{width:n.outerWidth(),height:n.outerHeight()}:{width:n.width(),height:n.height()},this.sizeDiff={width:n.outerWidth()-n.width(),height:n.outerHeight()-n.height()},this.originalPosition={left:e,top:i},this.originalMousePosition={left:t.pageX,top:t.pageY},this.aspectRatio="number"==typeof s.aspectRatio?s.aspectRatio:this.originalSize.width/this.originalSize.height||1,s=V(".ui-resizable-"+this.axis).css("cursor"),V("body").css("cursor","auto"===s?this.axis+"-resize":s),this._addClass("ui-resizable-resizing"),this._propagate("start",t),!0},_mouseDrag:function(t){var e=this.originalMousePosition,i=this.axis,s=t.pageX-e.left||0,e=t.pageY-e.top||0,i=this._change[i];return this._updatePrevProperties(),i&&(e=i.apply(this,[t,s,e]),this._updateVirtualBoundaries(t.shiftKey),(this._aspectRatio||t.shiftKey)&&(e=this._updateRatio(e,t)),e=this._respectSize(e,t),this._updateCache(e),this._propagate("resize",t),e=this._applyChanges(),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),V.isEmptyObject(e)||(this._updatePrevProperties(),this._trigger("resize",t,this.ui()),this._applyChanges())),!1},_mouseStop:function(t){this.resizing=!1;var e,i,s,n=this.options,o=this;return this._helper&&(s=(e=(i=this._proportionallyResizeElements).length&&/textarea/i.test(i[0].nodeName))&&this._hasScroll(i[0],"left")?0:o.sizeDiff.height,i=e?0:o.sizeDiff.width,e={width:o.helper.width()-i,height:o.helper.height()-s},i=parseFloat(o.element.css("left"))+(o.position.left-o.originalPosition.left)||null,s=parseFloat(o.element.css("top"))+(o.position.top-o.originalPosition.top)||null,n.animate||this.element.css(V.extend(e,{top:s,left:i})),o.helper.height(o.size.height),o.helper.width(o.size.width),this._helper&&!n.animate&&this._proportionallyResize()),V("body").css("cursor","auto"),this._removeClass("ui-resizable-resizing"),this._propagate("stop",t),this._helper&&this.helper.remove(),!1},_updatePrevProperties:function(){this.prevPosition={top:this.position.top,left:this.position.left},this.prevSize={width:this.size.width,height:this.size.height}},_applyChanges:function(){var t={};return this.position.top!==this.prevPosition.top&&(t.top=this.position.top+"px"),this.position.left!==this.prevPosition.left&&(t.left=this.position.left+"px"),this.size.width!==this.prevSize.width&&(t.width=this.size.width+"px"),this.size.height!==this.prevSize.height&&(t.height=this.size.height+"px"),this.helper.css(t),t},_updateVirtualBoundaries:function(t){var e,i,s=this.options,n={minWidth:this._isNumber(s.minWidth)?s.minWidth:0,maxWidth:this._isNumber(s.maxWidth)?s.maxWidth:1/0,minHeight:this._isNumber(s.minHeight)?s.minHeight:0,maxHeight:this._isNumber(s.maxHeight)?s.maxHeight:1/0};(this._aspectRatio||t)&&(e=n.minHeight*this.aspectRatio,i=n.minWidth/this.aspectRatio,s=n.maxHeight*this.aspectRatio,t=n.maxWidth/this.aspectRatio,e>n.minWidth&&(n.minWidth=e),i>n.minHeight&&(n.minHeight=i),s<n.maxWidth&&(n.maxWidth=s),t<n.maxHeight&&(n.maxHeight=t)),this._vBoundaries=n},_updateCache:function(t){this.offset=this.helper.offset(),this._isNumber(t.left)&&(this.position.left=t.left),this._isNumber(t.top)&&(this.position.top=t.top),this._isNumber(t.height)&&(this.size.height=t.height),this._isNumber(t.width)&&(this.size.width=t.width)},_updateRatio:function(t){var e=this.position,i=this.size,s=this.axis;return this._isNumber(t.height)?t.width=t.height*this.aspectRatio:this._isNumber(t.width)&&(t.height=t.width/this.aspectRatio),"sw"===s&&(t.left=e.left+(i.width-t.width),t.top=null),"nw"===s&&(t.top=e.top+(i.height-t.height),t.left=e.left+(i.width-t.width)),t},_respectSize:function(t){var e=this._vBoundaries,i=this.axis,s=this._isNumber(t.width)&&e.maxWidth&&e.maxWidth<t.width,n=this._isNumber(t.height)&&e.maxHeight&&e.maxHeight<t.height,o=this._isNumber(t.width)&&e.minWidth&&e.minWidth>t.width,a=this._isNumber(t.height)&&e.minHeight&&e.minHeight>t.height,r=this.originalPosition.left+this.originalSize.width,l=this.originalPosition.top+this.originalSize.height,h=/sw|nw|w/.test(i),i=/nw|ne|n/.test(i);return o&&(t.width=e.minWidth),a&&(t.height=e.minHeight),s&&(t.width=e.maxWidth),n&&(t.height=e.maxHeight),o&&h&&(t.left=r-e.minWidth),s&&h&&(t.left=r-e.maxWidth),a&&i&&(t.top=l-e.minHeight),n&&i&&(t.top=l-e.maxHeight),t.width||t.height||t.left||!t.top?t.width||t.height||t.top||!t.left||(t.left=null):t.top=null,t},_getPaddingPlusBorderDimensions:function(t){for(var e=0,i=[],s=[t.css("borderTopWidth"),t.css("borderRightWidth"),t.css("borderBottomWidth"),t.css("borderLeftWidth")],n=[t.css("paddingTop"),t.css("paddingRight"),t.css("paddingBottom"),t.css("paddingLeft")];e<4;e++)i[e]=parseFloat(s[e])||0,i[e]+=parseFloat(n[e])||0;return{height:i[0]+i[2],width:i[1]+i[3]}},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var t,e=0,i=this.helper||this.element;e<this._proportionallyResizeElements.length;e++)t=this._proportionallyResizeElements[e],this.outerDimensions||(this.outerDimensions=this._getPaddingPlusBorderDimensions(t)),t.css({height:i.height()-this.outerDimensions.height||0,width:i.width()-this.outerDimensions.width||0})},_renderProxy:function(){var t=this.element,e=this.options;this.elementOffset=t.offset(),this._helper?(this.helper=this.helper||V("<div></div>").css({overflow:"hidden"}),this._addClass(this.helper,this._helper),this.helper.css({width:this.element.outerWidth(),height:this.element.outerHeight(),position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++e.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element},_change:{e:function(t,e){return{width:this.originalSize.width+e}},w:function(t,e){var i=this.originalSize;return{left:this.originalPosition.left+e,width:i.width-e}},n:function(t,e,i){var s=this.originalSize;return{top:this.originalPosition.top+i,height:s.height-i}},s:function(t,e,i){return{height:this.originalSize.height+i}},se:function(t,e,i){return V.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[t,e,i]))},sw:function(t,e,i){return V.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[t,e,i]))},ne:function(t,e,i){return V.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[t,e,i]))},nw:function(t,e,i){return V.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[t,e,i]))}},_propagate:function(t,e){V.ui.plugin.call(this,t,[e,this.ui()]),"resize"!==t&&this._trigger(t,e,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),V.ui.plugin.add("resizable","animate",{stop:function(e){var i=V(this).resizable("instance"),t=i.options,s=i._proportionallyResizeElements,n=s.length&&/textarea/i.test(s[0].nodeName),o=n&&i._hasScroll(s[0],"left")?0:i.sizeDiff.height,a=n?0:i.sizeDiff.width,n={width:i.size.width-a,height:i.size.height-o},a=parseFloat(i.element.css("left"))+(i.position.left-i.originalPosition.left)||null,o=parseFloat(i.element.css("top"))+(i.position.top-i.originalPosition.top)||null;i.element.animate(V.extend(n,o&&a?{top:o,left:a}:{}),{duration:t.animateDuration,easing:t.animateEasing,step:function(){var t={width:parseFloat(i.element.css("width")),height:parseFloat(i.element.css("height")),top:parseFloat(i.element.css("top")),left:parseFloat(i.element.css("left"))};s&&s.length&&V(s[0]).css({width:t.width,height:t.height}),i._updateCache(t),i._propagate("resize",e)}})}}),V.ui.plugin.add("resizable","containment",{start:function(){var i,s,n=V(this).resizable("instance"),t=n.options,e=n.element,o=t.containment,a=o instanceof V?o.get(0):/parent/.test(o)?e.parent().get(0):o;a&&(n.containerElement=V(a),/document/.test(o)||o===document?(n.containerOffset={left:0,top:0},n.containerPosition={left:0,top:0},n.parentData={element:V(document),left:0,top:0,width:V(document).width(),height:V(document).height()||document.body.parentNode.scrollHeight}):(i=V(a),s=[],V(["Top","Right","Left","Bottom"]).each(function(t,e){s[t]=n._num(i.css("padding"+e))}),n.containerOffset=i.offset(),n.containerPosition=i.position(),n.containerSize={height:i.innerHeight()-s[3],width:i.innerWidth()-s[1]},t=n.containerOffset,e=n.containerSize.height,o=n.containerSize.width,o=n._hasScroll(a,"left")?a.scrollWidth:o,e=n._hasScroll(a)?a.scrollHeight:e,n.parentData={element:a,left:t.left,top:t.top,width:o,height:e}))},resize:function(t){var e=V(this).resizable("instance"),i=e.options,s=e.containerOffset,n=e.position,o=e._aspectRatio||t.shiftKey,a={top:0,left:0},r=e.containerElement,t=!0;r[0]!==document&&/static/.test(r.css("position"))&&(a=s),n.left<(e._helper?s.left:0)&&(e.size.width=e.size.width+(e._helper?e.position.left-s.left:e.position.left-a.left),o&&(e.size.height=e.size.width/e.aspectRatio,t=!1),e.position.left=i.helper?s.left:0),n.top<(e._helper?s.top:0)&&(e.size.height=e.size.height+(e._helper?e.position.top-s.top:e.position.top),o&&(e.size.width=e.size.height*e.aspectRatio,t=!1),e.position.top=e._helper?s.top:0),i=e.containerElement.get(0)===e.element.parent().get(0),n=/relative|absolute/.test(e.containerElement.css("position")),i&&n?(e.offset.left=e.parentData.left+e.position.left,e.offset.top=e.parentData.top+e.position.top):(e.offset.left=e.element.offset().left,e.offset.top=e.element.offset().top),n=Math.abs(e.sizeDiff.width+(e._helper?e.offset.left-a.left:e.offset.left-s.left)),s=Math.abs(e.sizeDiff.height+(e._helper?e.offset.top-a.top:e.offset.top-s.top)),n+e.size.width>=e.parentData.width&&(e.size.width=e.parentData.width-n,o&&(e.size.height=e.size.width/e.aspectRatio,t=!1)),s+e.size.height>=e.parentData.height&&(e.size.height=e.parentData.height-s,o&&(e.size.width=e.size.height*e.aspectRatio,t=!1)),t||(e.position.left=e.prevPosition.left,e.position.top=e.prevPosition.top,e.size.width=e.prevSize.width,e.size.height=e.prevSize.height)},stop:function(){var t=V(this).resizable("instance"),e=t.options,i=t.containerOffset,s=t.containerPosition,n=t.containerElement,o=V(t.helper),a=o.offset(),r=o.outerWidth()-t.sizeDiff.width,o=o.outerHeight()-t.sizeDiff.height;t._helper&&!e.animate&&/relative/.test(n.css("position"))&&V(this).css({left:a.left-s.left-i.left,width:r,height:o}),t._helper&&!e.animate&&/static/.test(n.css("position"))&&V(this).css({left:a.left-s.left-i.left,width:r,height:o})}}),V.ui.plugin.add("resizable","alsoResize",{start:function(){var t=V(this).resizable("instance").options;V(t.alsoResize).each(function(){var t=V(this);t.data("ui-resizable-alsoresize",{width:parseFloat(t.width()),height:parseFloat(t.height()),left:parseFloat(t.css("left")),top:parseFloat(t.css("top"))})})},resize:function(t,i){var e=V(this).resizable("instance"),s=e.options,n=e.originalSize,o=e.originalPosition,a={height:e.size.height-n.height||0,width:e.size.width-n.width||0,top:e.position.top-o.top||0,left:e.position.left-o.left||0};V(s.alsoResize).each(function(){var t=V(this),s=V(this).data("ui-resizable-alsoresize"),n={},e=t.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];V.each(e,function(t,e){var i=(s[e]||0)+(a[e]||0);i&&0<=i&&(n[e]=i||null)}),t.css(n)})},stop:function(){V(this).removeData("ui-resizable-alsoresize")}}),V.ui.plugin.add("resizable","ghost",{start:function(){var t=V(this).resizable("instance"),e=t.size;t.ghost=t.originalElement.clone(),t.ghost.css({opacity:.25,display:"block",position:"relative",height:e.height,width:e.width,margin:0,left:0,top:0}),t._addClass(t.ghost,"ui-resizable-ghost"),!1!==V.uiBackCompat&&"string"==typeof t.options.ghost&&t.ghost.addClass(this.options.ghost),t.ghost.appendTo(t.helper)},resize:function(){var t=V(this).resizable("instance");t.ghost&&t.ghost.css({position:"relative",height:t.size.height,width:t.size.width})},stop:function(){var t=V(this).resizable("instance");t.ghost&&t.helper&&t.helper.get(0).removeChild(t.ghost.get(0))}}),V.ui.plugin.add("resizable","grid",{resize:function(){var t,e=V(this).resizable("instance"),i=e.options,s=e.size,n=e.originalSize,o=e.originalPosition,a=e.axis,r="number"==typeof i.grid?[i.grid,i.grid]:i.grid,l=r[0]||1,h=r[1]||1,c=Math.round((s.width-n.width)/l)*l,u=Math.round((s.height-n.height)/h)*h,d=n.width+c,p=n.height+u,f=i.maxWidth&&i.maxWidth<d,g=i.maxHeight&&i.maxHeight<p,m=i.minWidth&&i.minWidth>d,s=i.minHeight&&i.minHeight>p;i.grid=r,m&&(d+=l),s&&(p+=h),f&&(d-=l),g&&(p-=h),/^(se|s|e)$/.test(a)?(e.size.width=d,e.size.height=p):/^(ne)$/.test(a)?(e.size.width=d,e.size.height=p,e.position.top=o.top-u):/^(sw)$/.test(a)?(e.size.width=d,e.size.height=p,e.position.left=o.left-c):((p-h<=0||d-l<=0)&&(t=e._getPaddingPlusBorderDimensions(this)),0<p-h?(e.size.height=p,e.position.top=o.top-u):(p=h-t.height,e.size.height=p,e.position.top=o.top+n.height-p),0<d-l?(e.size.width=d,e.position.left=o.left-c):(d=l-t.width,e.size.width=d,e.position.left=o.left+n.width-d))}});V.ui.resizable;V.widget("ui.dialog",{version:"1.13.2",options:{appendTo:"body",autoOpen:!0,buttons:[],classes:{"ui-dialog":"ui-corner-all","ui-dialog-titlebar":"ui-corner-all"},closeOnEscape:!0,closeText:"Close",draggable:!0,hide:null,height:"auto",maxHeight:null,maxWidth:null,minHeight:150,minWidth:150,modal:!1,position:{my:"center",at:"center",of:window,collision:"fit",using:function(t){var e=V(this).css(t).offset().top;e<0&&V(this).css("top",t.top-e)}},resizable:!0,show:null,title:null,width:300,beforeClose:null,close:null,drag:null,dragStart:null,dragStop:null,focus:null,open:null,resize:null,resizeStart:null,resizeStop:null},sizeRelatedOptions:{buttons:!0,height:!0,maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0,width:!0},resizableRelatedOptions:{maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0},_create:function(){this.originalCss={display:this.element[0].style.display,width:this.element[0].style.width,minHeight:this.element[0].style.minHeight,maxHeight:this.element[0].style.maxHeight,height:this.element[0].style.height},this.originalPosition={parent:this.element.parent(),index:this.element.parent().children().index(this.element)},this.originalTitle=this.element.attr("title"),null==this.options.title&&null!=this.originalTitle&&(this.options.title=this.originalTitle),this.options.disabled&&(this.options.disabled=!1),this._createWrapper(),this.element.show().removeAttr("title").appendTo(this.uiDialog),this._addClass("ui-dialog-content","ui-widget-content"),this._createTitlebar(),this._createButtonPane(),this.options.draggable&&V.fn.draggable&&this._makeDraggable(),this.options.resizable&&V.fn.resizable&&this._makeResizable(),this._isOpen=!1,this._trackFocus()},_init:function(){this.options.autoOpen&&this.open()},_appendTo:function(){var t=this.options.appendTo;return t&&(t.jquery||t.nodeType)?V(t):this.document.find(t||"body").eq(0)},_destroy:function(){var t,e=this.originalPosition;this._untrackInstance(),this._destroyOverlay(),this.element.removeUniqueId().css(this.originalCss).detach(),this.uiDialog.remove(),this.originalTitle&&this.element.attr("title",this.originalTitle),(t=e.parent.children().eq(e.index)).length&&t[0]!==this.element[0]?t.before(this.element):e.parent.append(this.element)},widget:function(){return this.uiDialog},disable:V.noop,enable:V.noop,close:function(t){var e=this;this._isOpen&&!1!==this._trigger("beforeClose",t)&&(this._isOpen=!1,this._focusedElement=null,this._destroyOverlay(),this._untrackInstance(),this.opener.filter(":focusable").trigger("focus").length||V.ui.safeBlur(V.ui.safeActiveElement(this.document[0])),this._hide(this.uiDialog,this.options.hide,function(){e._trigger("close",t)}))},isOpen:function(){return this._isOpen},moveToTop:function(){this._moveToTop()},_moveToTop:function(t,e){var i=!1,s=this.uiDialog.siblings(".ui-front:visible").map(function(){return+V(this).css("z-index")}).get(),s=Math.max.apply(null,s);return s>=+this.uiDialog.css("z-index")&&(this.uiDialog.css("z-index",s+1),i=!0),i&&!e&&this._trigger("focus",t),i},open:function(){var t=this;this._isOpen?this._moveToTop()&&this._focusTabbable():(this._isOpen=!0,this.opener=V(V.ui.safeActiveElement(this.document[0])),this._size(),this._position(),this._createOverlay(),this._moveToTop(null,!0),this.overlay&&this.overlay.css("z-index",this.uiDialog.css("z-index")-1),this._show(this.uiDialog,this.options.show,function(){t._focusTabbable(),t._trigger("focus")}),this._makeFocusTarget(),this._trigger("open"))},_focusTabbable:function(){var t=this._focusedElement;(t=!(t=!(t=!(t=!(t=t||this.element.find("[autofocus]")).length?this.element.find(":tabbable"):t).length?this.uiDialogButtonPane.find(":tabbable"):t).length?this.uiDialogTitlebarClose.filter(":tabbable"):t).length?this.uiDialog:t).eq(0).trigger("focus")},_restoreTabbableFocus:function(){var t=V.ui.safeActiveElement(this.document[0]);this.uiDialog[0]===t||V.contains(this.uiDialog[0],t)||this._focusTabbable()},_keepFocus:function(t){t.preventDefault(),this._restoreTabbableFocus(),this._delay(this._restoreTabbableFocus)},_createWrapper:function(){this.uiDialog=V("<div>").hide().attr({tabIndex:-1,role:"dialog"}).appendTo(this._appendTo()),this._addClass(this.uiDialog,"ui-dialog","ui-widget ui-widget-content ui-front"),this._on(this.uiDialog,{keydown:function(t){if(this.options.closeOnEscape&&!t.isDefaultPrevented()&&t.keyCode&&t.keyCode===V.ui.keyCode.ESCAPE)return t.preventDefault(),void this.close(t);var e,i,s;t.keyCode!==V.ui.keyCode.TAB||t.isDefaultPrevented()||(e=this.uiDialog.find(":tabbable"),i=e.first(),s=e.last(),t.target!==s[0]&&t.target!==this.uiDialog[0]||t.shiftKey?t.target!==i[0]&&t.target!==this.uiDialog[0]||!t.shiftKey||(this._delay(function(){s.trigger("focus")}),t.preventDefault()):(this._delay(function(){i.trigger("focus")}),t.preventDefault()))},mousedown:function(t){this._moveToTop(t)&&this._focusTabbable()}}),this.element.find("[aria-describedby]").length||this.uiDialog.attr({"aria-describedby":this.element.uniqueId().attr("id")})},_createTitlebar:function(){var t;this.uiDialogTitlebar=V("<div>"),this._addClass(this.uiDialogTitlebar,"ui-dialog-titlebar","ui-widget-header ui-helper-clearfix"),this._on(this.uiDialogTitlebar,{mousedown:function(t){V(t.target).closest(".ui-dialog-titlebar-close")||this.uiDialog.trigger("focus")}}),this.uiDialogTitlebarClose=V("<button type='button'></button>").button({label:V("<a>").text(this.options.closeText).html(),icon:"ui-icon-closethick",showLabel:!1}).appendTo(this.uiDialogTitlebar),this._addClass(this.uiDialogTitlebarClose,"ui-dialog-titlebar-close"),this._on(this.uiDialogTitlebarClose,{click:function(t){t.preventDefault(),this.close(t)}}),t=V("<span>").uniqueId().prependTo(this.uiDialogTitlebar),this._addClass(t,"ui-dialog-title"),this._title(t),this.uiDialogTitlebar.prependTo(this.uiDialog),this.uiDialog.attr({"aria-labelledby":t.attr("id")})},_title:function(t){this.options.title?t.text(this.options.title):t.html(" ")},_createButtonPane:function(){this.uiDialogButtonPane=V("<div>"),this._addClass(this.uiDialogButtonPane,"ui-dialog-buttonpane","ui-widget-content ui-helper-clearfix"),this.uiButtonSet=V("<div>").appendTo(this.uiDialogButtonPane),this._addClass(this.uiButtonSet,"ui-dialog-buttonset"),this._createButtons()},_createButtons:function(){var s=this,t=this.options.buttons;this.uiDialogButtonPane.remove(),this.uiButtonSet.empty(),V.isEmptyObject(t)||Array.isArray(t)&&!t.length?this._removeClass(this.uiDialog,"ui-dialog-buttons"):(V.each(t,function(t,e){var i;e=V.extend({type:"button"},e="function"==typeof e?{click:e,text:t}:e),i=e.click,t={icon:e.icon,iconPosition:e.iconPosition,showLabel:e.showLabel,icons:e.icons,text:e.text},delete e.click,delete e.icon,delete e.iconPosition,delete e.showLabel,delete e.icons,"boolean"==typeof e.text&&delete e.text,V("<button></button>",e).button(t).appendTo(s.uiButtonSet).on("click",function(){i.apply(s.element[0],arguments)})}),this._addClass(this.uiDialog,"ui-dialog-buttons"),this.uiDialogButtonPane.appendTo(this.uiDialog))},_makeDraggable:function(){var n=this,o=this.options;function a(t){return{position:t.position,offset:t.offset}}this.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(t,e){n._addClass(V(this),"ui-dialog-dragging"),n._blockFrames(),n._trigger("dragStart",t,a(e))},drag:function(t,e){n._trigger("drag",t,a(e))},stop:function(t,e){var i=e.offset.left-n.document.scrollLeft(),s=e.offset.top-n.document.scrollTop();o.position={my:"left top",at:"left"+(0<=i?"+":"")+i+" top"+(0<=s?"+":"")+s,of:n.window},n._removeClass(V(this),"ui-dialog-dragging"),n._unblockFrames(),n._trigger("dragStop",t,a(e))}})},_makeResizable:function(){var n=this,o=this.options,t=o.resizable,e=this.uiDialog.css("position"),t="string"==typeof t?t:"n,e,s,w,se,sw,ne,nw";function a(t){return{originalPosition:t.originalPosition,originalSize:t.originalSize,position:t.position,size:t.size}}this.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:this.element,maxWidth:o.maxWidth,maxHeight:o.maxHeight,minWidth:o.minWidth,minHeight:this._minHeight(),handles:t,start:function(t,e){n._addClass(V(this),"ui-dialog-resizing"),n._blockFrames(),n._trigger("resizeStart",t,a(e))},resize:function(t,e){n._trigger("resize",t,a(e))},stop:function(t,e){var i=n.uiDialog.offset(),s=i.left-n.document.scrollLeft(),i=i.top-n.document.scrollTop();o.height=n.uiDialog.height(),o.width=n.uiDialog.width(),o.position={my:"left top",at:"left"+(0<=s?"+":"")+s+" top"+(0<=i?"+":"")+i,of:n.window},n._removeClass(V(this),"ui-dialog-resizing"),n._unblockFrames(),n._trigger("resizeStop",t,a(e))}}).css("position",e)},_trackFocus:function(){this._on(this.widget(),{focusin:function(t){this._makeFocusTarget(),this._focusedElement=V(t.target)}})},_makeFocusTarget:function(){this._untrackInstance(),this._trackingInstances().unshift(this)},_untrackInstance:function(){var t=this._trackingInstances(),e=V.inArray(this,t);-1!==e&&t.splice(e,1)},_trackingInstances:function(){var t=this.document.data("ui-dialog-instances");return t||this.document.data("ui-dialog-instances",t=[]),t},_minHeight:function(){var t=this.options;return"auto"===t.height?t.minHeight:Math.min(t.minHeight,t.height)},_position:function(){var t=this.uiDialog.is(":visible");t||this.uiDialog.show(),this.uiDialog.position(this.options.position),t||this.uiDialog.hide()},_setOptions:function(t){var i=this,s=!1,n={};V.each(t,function(t,e){i._setOption(t,e),t in i.sizeRelatedOptions&&(s=!0),t in i.resizableRelatedOptions&&(n[t]=e)}),s&&(this._size(),this._position()),this.uiDialog.is(":data(ui-resizable)")&&this.uiDialog.resizable("option",n)},_setOption:function(t,e){var i,s=this.uiDialog;"disabled"!==t&&(this._super(t,e),"appendTo"===t&&this.uiDialog.appendTo(this._appendTo()),"buttons"===t&&this._createButtons(),"closeText"===t&&this.uiDialogTitlebarClose.button({label:V("<a>").text(""+this.options.closeText).html()}),"draggable"===t&&((i=s.is(":data(ui-draggable)"))&&!e&&s.draggable("destroy"),!i&&e&&this._makeDraggable()),"position"===t&&this._position(),"resizable"===t&&((i=s.is(":data(ui-resizable)"))&&!e&&s.resizable("destroy"),i&&"string"==typeof e&&s.resizable("option","handles",e),i||!1===e||this._makeResizable()),"title"===t&&this._title(this.uiDialogTitlebar.find(".ui-dialog-title")))},_size:function(){var t,e,i,s=this.options;this.element.show().css({width:"auto",minHeight:0,maxHeight:"none",height:0}),s.minWidth>s.width&&(s.width=s.minWidth),t=this.uiDialog.css({height:"auto",width:s.width}).outerHeight(),e=Math.max(0,s.minHeight-t),i="number"==typeof s.maxHeight?Math.max(0,s.maxHeight-t):"none","auto"===s.height?this.element.css({minHeight:e,maxHeight:i,height:"auto"}):this.element.height(Math.max(0,s.height-t)),this.uiDialog.is(":data(ui-resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())},_blockFrames:function(){this.iframeBlocks=this.document.find("iframe").map(function(){var t=V(this);return V("<div>").css({position:"absolute",width:t.outerWidth(),height:t.outerHeight()}).appendTo(t.parent()).offset(t.offset())[0]})},_unblockFrames:function(){this.iframeBlocks&&(this.iframeBlocks.remove(),delete this.iframeBlocks)},_allowInteraction:function(t){return!!V(t.target).closest(".ui-dialog").length||!!V(t.target).closest(".ui-datepicker").length},_createOverlay:function(){var i,s;this.options.modal&&(i=V.fn.jquery.substring(0,4),s=!0,this._delay(function(){s=!1}),this.document.data("ui-dialog-overlays")||this.document.on("focusin.ui-dialog",function(t){var e;s||((e=this._trackingInstances()[0])._allowInteraction(t)||(t.preventDefault(),e._focusTabbable(),"3.4."!==i&&"3.5."!==i||e._delay(e._restoreTabbableFocus)))}.bind(this)),this.overlay=V("<div>").appendTo(this._appendTo()),this._addClass(this.overlay,null,"ui-widget-overlay ui-front"),this._on(this.overlay,{mousedown:"_keepFocus"}),this.document.data("ui-dialog-overlays",(this.document.data("ui-dialog-overlays")||0)+1))},_destroyOverlay:function(){var t;this.options.modal&&this.overlay&&((t=this.document.data("ui-dialog-overlays")-1)?this.document.data("ui-dialog-overlays",t):(this.document.off("focusin.ui-dialog"),this.document.removeData("ui-dialog-overlays")),this.overlay.remove(),this.overlay=null)}}),!1!==V.uiBackCompat&&V.widget("ui.dialog",V.ui.dialog,{options:{dialogClass:""},_createWrapper:function(){this._super(),this.uiDialog.addClass(this.options.dialogClass)},_setOption:function(t,e){"dialogClass"===t&&this.uiDialog.removeClass(this.options.dialogClass).addClass(e),this._superApply(arguments)}});V.ui.dialog;function lt(t,e,i){return e<=t&&t<e+i}V.widget("ui.droppable",{version:"1.13.2",widgetEventPrefix:"drop",options:{accept:"*",addClasses:!0,greedy:!1,scope:"default",tolerance:"intersect",activate:null,deactivate:null,drop:null,out:null,over:null},_create:function(){var t,e=this.options,i=e.accept;this.isover=!1,this.isout=!0,this.accept="function"==typeof i?i:function(t){return t.is(i)},this.proportions=function(){if(!arguments.length)return t=t||{width:this.element[0].offsetWidth,height:this.element[0].offsetHeight};t=arguments[0]},this._addToManager(e.scope),e.addClasses&&this._addClass("ui-droppable")},_addToManager:function(t){V.ui.ddmanager.droppables[t]=V.ui.ddmanager.droppables[t]||[],V.ui.ddmanager.droppables[t].push(this)},_splice:function(t){for(var e=0;e<t.length;e++)t[e]===this&&t.splice(e,1)},_destroy:function(){var t=V.ui.ddmanager.droppables[this.options.scope];this._splice(t)},_setOption:function(t,e){var i;"accept"===t?this.accept="function"==typeof e?e:function(t){return t.is(e)}:"scope"===t&&(i=V.ui.ddmanager.droppables[this.options.scope],this._splice(i),this._addToManager(e)),this._super(t,e)},_activate:function(t){var e=V.ui.ddmanager.current;this._addActiveClass(),e&&this._trigger("activate",t,this.ui(e))},_deactivate:function(t){var e=V.ui.ddmanager.current;this._removeActiveClass(),e&&this._trigger("deactivate",t,this.ui(e))},_over:function(t){var e=V.ui.ddmanager.current;e&&(e.currentItem||e.element)[0]!==this.element[0]&&this.accept.call(this.element[0],e.currentItem||e.element)&&(this._addHoverClass(),this._trigger("over",t,this.ui(e)))},_out:function(t){var e=V.ui.ddmanager.current;e&&(e.currentItem||e.element)[0]!==this.element[0]&&this.accept.call(this.element[0],e.currentItem||e.element)&&(this._removeHoverClass(),this._trigger("out",t,this.ui(e)))},_drop:function(e,t){var i=t||V.ui.ddmanager.current,s=!1;return!(!i||(i.currentItem||i.element)[0]===this.element[0])&&(this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function(){var t=V(this).droppable("instance");if(t.options.greedy&&!t.options.disabled&&t.options.scope===i.options.scope&&t.accept.call(t.element[0],i.currentItem||i.element)&&V.ui.intersect(i,V.extend(t,{offset:t.element.offset()}),t.options.tolerance,e))return!(s=!0)}),!s&&(!!this.accept.call(this.element[0],i.currentItem||i.element)&&(this._removeActiveClass(),this._removeHoverClass(),this._trigger("drop",e,this.ui(i)),this.element)))},ui:function(t){return{draggable:t.currentItem||t.element,helper:t.helper,position:t.position,offset:t.positionAbs}},_addHoverClass:function(){this._addClass("ui-droppable-hover")},_removeHoverClass:function(){this._removeClass("ui-droppable-hover")},_addActiveClass:function(){this._addClass("ui-droppable-active")},_removeActiveClass:function(){this._removeClass("ui-droppable-active")}}),V.ui.intersect=function(t,e,i,s){if(!e.offset)return!1;var n=(t.positionAbs||t.position.absolute).left+t.margins.left,o=(t.positionAbs||t.position.absolute).top+t.margins.top,a=n+t.helperProportions.width,r=o+t.helperProportions.height,l=e.offset.left,h=e.offset.top,c=l+e.proportions().width,u=h+e.proportions().height;switch(i){case"fit":return l<=n&&a<=c&&h<=o&&r<=u;case"intersect":return l<n+t.helperProportions.width/2&&a-t.helperProportions.width/2<c&&h<o+t.helperProportions.height/2&&r-t.helperProportions.height/2<u;case"pointer":return lt(s.pageY,h,e.proportions().height)&<(s.pageX,l,e.proportions().width);case"touch":return(h<=o&&o<=u||h<=r&&r<=u||o<h&&u<r)&&(l<=n&&n<=c||l<=a&&a<=c||n<l&&c<a);default:return!1}},!(V.ui.ddmanager={current:null,droppables:{default:[]},prepareOffsets:function(t,e){var i,s,n=V.ui.ddmanager.droppables[t.options.scope]||[],o=e?e.type:null,a=(t.currentItem||t.element).find(":data(ui-droppable)").addBack();t:for(i=0;i<n.length;i++)if(!(n[i].options.disabled||t&&!n[i].accept.call(n[i].element[0],t.currentItem||t.element))){for(s=0;s<a.length;s++)if(a[s]===n[i].element[0]){n[i].proportions().height=0;continue t}n[i].visible="none"!==n[i].element.css("display"),n[i].visible&&("mousedown"===o&&n[i]._activate.call(n[i],e),n[i].offset=n[i].element.offset(),n[i].proportions({width:n[i].element[0].offsetWidth,height:n[i].element[0].offsetHeight}))}},drop:function(t,e){var i=!1;return V.each((V.ui.ddmanager.droppables[t.options.scope]||[]).slice(),function(){this.options&&(!this.options.disabled&&this.visible&&V.ui.intersect(t,this,this.options.tolerance,e)&&(i=this._drop.call(this,e)||i),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],t.currentItem||t.element)&&(this.isout=!0,this.isover=!1,this._deactivate.call(this,e)))}),i},dragStart:function(t,e){t.element.parentsUntil("body").on("scroll.droppable",function(){t.options.refreshPositions||V.ui.ddmanager.prepareOffsets(t,e)})},drag:function(n,o){n.options.refreshPositions&&V.ui.ddmanager.prepareOffsets(n,o),V.each(V.ui.ddmanager.droppables[n.options.scope]||[],function(){var t,e,i,s;this.options.disabled||this.greedyChild||!this.visible||(s=!(i=V.ui.intersect(n,this,this.options.tolerance,o))&&this.isover?"isout":i&&!this.isover?"isover":null)&&(this.options.greedy&&(e=this.options.scope,(i=this.element.parents(":data(ui-droppable)").filter(function(){return V(this).droppable("instance").options.scope===e})).length&&((t=V(i[0]).droppable("instance")).greedyChild="isover"===s)),t&&"isover"===s&&(t.isover=!1,t.isout=!0,t._out.call(t,o)),this[s]=!0,this["isout"===s?"isover":"isout"]=!1,this["isover"===s?"_over":"_out"].call(this,o),t&&"isout"===s&&(t.isout=!1,t.isover=!0,t._over.call(t,o)))})},dragStop:function(t,e){t.element.parentsUntil("body").off("scroll.droppable"),t.options.refreshPositions||V.ui.ddmanager.prepareOffsets(t,e)}})!==V.uiBackCompat&&V.widget("ui.droppable",V.ui.droppable,{options:{hoverClass:!1,activeClass:!1},_addActiveClass:function(){this._super(),this.options.activeClass&&this.element.addClass(this.options.activeClass)},_removeActiveClass:function(){this._super(),this.options.activeClass&&this.element.removeClass(this.options.activeClass)},_addHoverClass:function(){this._super(),this.options.hoverClass&&this.element.addClass(this.options.hoverClass)},_removeHoverClass:function(){this._super(),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass)}});V.ui.droppable,V.widget("ui.progressbar",{version:"1.13.2",options:{classes:{"ui-progressbar":"ui-corner-all","ui-progressbar-value":"ui-corner-left","ui-progressbar-complete":"ui-corner-right"},max:100,value:0,change:null,complete:null},min:0,_create:function(){this.oldValue=this.options.value=this._constrainedValue(),this.element.attr({role:"progressbar","aria-valuemin":this.min}),this._addClass("ui-progressbar","ui-widget ui-widget-content"),this.valueDiv=V("<div>").appendTo(this.element),this._addClass(this.valueDiv,"ui-progressbar-value","ui-widget-header"),this._refreshValue()},_destroy:function(){this.element.removeAttr("role aria-valuemin aria-valuemax aria-valuenow"),this.valueDiv.remove()},value:function(t){if(void 0===t)return this.options.value;this.options.value=this._constrainedValue(t),this._refreshValue()},_constrainedValue:function(t){return void 0===t&&(t=this.options.value),this.indeterminate=!1===t,"number"!=typeof t&&(t=0),!this.indeterminate&&Math.min(this.options.max,Math.max(this.min,t))},_setOptions:function(t){var e=t.value;delete t.value,this._super(t),this.options.value=this._constrainedValue(e),this._refreshValue()},_setOption:function(t,e){"max"===t&&(e=Math.max(this.min,e)),this._super(t,e)},_setOptionDisabled:function(t){this._super(t),this.element.attr("aria-disabled",t),this._toggleClass(null,"ui-state-disabled",!!t)},_percentage:function(){return this.indeterminate?100:100*(this.options.value-this.min)/(this.options.max-this.min)},_refreshValue:function(){var t=this.options.value,e=this._percentage();this.valueDiv.toggle(this.indeterminate||t>this.min).width(e.toFixed(0)+"%"),this._toggleClass(this.valueDiv,"ui-progressbar-complete",null,t===this.options.max)._toggleClass("ui-progressbar-indeterminate",null,this.indeterminate),this.indeterminate?(this.element.removeAttr("aria-valuenow"),this.overlayDiv||(this.overlayDiv=V("<div>").appendTo(this.valueDiv),this._addClass(this.overlayDiv,"ui-progressbar-overlay"))):(this.element.attr({"aria-valuemax":this.options.max,"aria-valuenow":t}),this.overlayDiv&&(this.overlayDiv.remove(),this.overlayDiv=null)),this.oldValue!==t&&(this.oldValue=t,this._trigger("change")),t===this.options.max&&this._trigger("complete")}}),V.widget("ui.selectable",V.ui.mouse,{version:"1.13.2",options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch",selected:null,selecting:null,start:null,stop:null,unselected:null,unselecting:null},_create:function(){var i=this;this._addClass("ui-selectable"),this.dragged=!1,this.refresh=function(){i.elementPos=V(i.element[0]).offset(),i.selectees=V(i.options.filter,i.element[0]),i._addClass(i.selectees,"ui-selectee"),i.selectees.each(function(){var t=V(this),e=t.offset(),e={left:e.left-i.elementPos.left,top:e.top-i.elementPos.top};V.data(this,"selectable-item",{element:this,$element:t,left:e.left,top:e.top,right:e.left+t.outerWidth(),bottom:e.top+t.outerHeight(),startselected:!1,selected:t.hasClass("ui-selected"),selecting:t.hasClass("ui-selecting"),unselecting:t.hasClass("ui-unselecting")})})},this.refresh(),this._mouseInit(),this.helper=V("<div>"),this._addClass(this.helper,"ui-selectable-helper")},_destroy:function(){this.selectees.removeData("selectable-item"),this._mouseDestroy()},_mouseStart:function(i){var s=this,t=this.options;this.opos=[i.pageX,i.pageY],this.elementPos=V(this.element[0]).offset(),this.options.disabled||(this.selectees=V(t.filter,this.element[0]),this._trigger("start",i),V(t.appendTo).append(this.helper),this.helper.css({left:i.pageX,top:i.pageY,width:0,height:0}),t.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var t=V.data(this,"selectable-item");t.startselected=!0,i.metaKey||i.ctrlKey||(s._removeClass(t.$element,"ui-selected"),t.selected=!1,s._addClass(t.$element,"ui-unselecting"),t.unselecting=!0,s._trigger("unselecting",i,{unselecting:t.element}))}),V(i.target).parents().addBack().each(function(){var t,e=V.data(this,"selectable-item");if(e)return t=!i.metaKey&&!i.ctrlKey||!e.$element.hasClass("ui-selected"),s._removeClass(e.$element,t?"ui-unselecting":"ui-selected")._addClass(e.$element,t?"ui-selecting":"ui-unselecting"),e.unselecting=!t,e.selecting=t,(e.selected=t)?s._trigger("selecting",i,{selecting:e.element}):s._trigger("unselecting",i,{unselecting:e.element}),!1}))},_mouseDrag:function(s){if(this.dragged=!0,!this.options.disabled){var t,n=this,o=this.options,a=this.opos[0],r=this.opos[1],l=s.pageX,h=s.pageY;return l<a&&(t=l,l=a,a=t),h<r&&(t=h,h=r,r=t),this.helper.css({left:a,top:r,width:l-a,height:h-r}),this.selectees.each(function(){var t=V.data(this,"selectable-item"),e=!1,i={};t&&t.element!==n.element[0]&&(i.left=t.left+n.elementPos.left,i.right=t.right+n.elementPos.left,i.top=t.top+n.elementPos.top,i.bottom=t.bottom+n.elementPos.top,"touch"===o.tolerance?e=!(i.left>l||i.right<a||i.top>h||i.bottom<r):"fit"===o.tolerance&&(e=i.left>a&&i.right<l&&i.top>r&&i.bottom<h),e?(t.selected&&(n._removeClass(t.$element,"ui-selected"),t.selected=!1),t.unselecting&&(n._removeClass(t.$element,"ui-unselecting"),t.unselecting=!1),t.selecting||(n._addClass(t.$element,"ui-selecting"),t.selecting=!0,n._trigger("selecting",s,{selecting:t.element}))):(t.selecting&&((s.metaKey||s.ctrlKey)&&t.startselected?(n._removeClass(t.$element,"ui-selecting"),t.selecting=!1,n._addClass(t.$element,"ui-selected"),t.selected=!0):(n._removeClass(t.$element,"ui-selecting"),t.selecting=!1,t.startselected&&(n._addClass(t.$element,"ui-unselecting"),t.unselecting=!0),n._trigger("unselecting",s,{unselecting:t.element}))),t.selected&&(s.metaKey||s.ctrlKey||t.startselected||(n._removeClass(t.$element,"ui-selected"),t.selected=!1,n._addClass(t.$element,"ui-unselecting"),t.unselecting=!0,n._trigger("unselecting",s,{unselecting:t.element})))))}),!1}},_mouseStop:function(e){var i=this;return this.dragged=!1,V(".ui-unselecting",this.element[0]).each(function(){var t=V.data(this,"selectable-item");i._removeClass(t.$element,"ui-unselecting"),t.unselecting=!1,t.startselected=!1,i._trigger("unselected",e,{unselected:t.element})}),V(".ui-selecting",this.element[0]).each(function(){var t=V.data(this,"selectable-item");i._removeClass(t.$element,"ui-selecting")._addClass(t.$element,"ui-selected"),t.selecting=!1,t.selected=!0,t.startselected=!0,i._trigger("selected",e,{selected:t.element})}),this._trigger("stop",e),this.helper.remove(),!1}}),V.widget("ui.selectmenu",[V.ui.formResetMixin,{version:"1.13.2",defaultElement:"<select>",options:{appendTo:null,classes:{"ui-selectmenu-button-open":"ui-corner-top","ui-selectmenu-button-closed":"ui-corner-all"},disabled:null,icons:{button:"ui-icon-triangle-1-s"},position:{my:"left top",at:"left bottom",collision:"none"},width:!1,change:null,close:null,focus:null,open:null,select:null},_create:function(){var t=this.element.uniqueId().attr("id");this.ids={element:t,button:t+"-button",menu:t+"-menu"},this._drawButton(),this._drawMenu(),this._bindFormResetHandler(),this._rendered=!1,this.menuItems=V()},_drawButton:function(){var t,e=this,i=this._parseOption(this.element.find("option:selected"),this.element[0].selectedIndex);this.labels=this.element.labels().attr("for",this.ids.button),this._on(this.labels,{click:function(t){this.button.trigger("focus"),t.preventDefault()}}),this.element.hide(),this.button=V("<span>",{tabindex:this.options.disabled?-1:0,id:this.ids.button,role:"combobox","aria-expanded":"false","aria-autocomplete":"list","aria-owns":this.ids.menu,"aria-haspopup":"true",title:this.element.attr("title")}).insertAfter(this.element),this._addClass(this.button,"ui-selectmenu-button ui-selectmenu-button-closed","ui-button ui-widget"),t=V("<span>").appendTo(this.button),this._addClass(t,"ui-selectmenu-icon","ui-icon "+this.options.icons.button),this.buttonItem=this._renderButtonItem(i).appendTo(this.button),!1!==this.options.width&&this._resizeButton(),this._on(this.button,this._buttonEvents),this.button.one("focusin",function(){e._rendered||e._refreshMenu()})},_drawMenu:function(){var i=this;this.menu=V("<ul>",{"aria-hidden":"true","aria-labelledby":this.ids.button,id:this.ids.menu}),this.menuWrap=V("<div>").append(this.menu),this._addClass(this.menuWrap,"ui-selectmenu-menu","ui-front"),this.menuWrap.appendTo(this._appendTo()),this.menuInstance=this.menu.menu({classes:{"ui-menu":"ui-corner-bottom"},role:"listbox",select:function(t,e){t.preventDefault(),i._setSelection(),i._select(e.item.data("ui-selectmenu-item"),t)},focus:function(t,e){e=e.item.data("ui-selectmenu-item");null!=i.focusIndex&&e.index!==i.focusIndex&&(i._trigger("focus",t,{item:e}),i.isOpen||i._select(e,t)),i.focusIndex=e.index,i.button.attr("aria-activedescendant",i.menuItems.eq(e.index).attr("id"))}}).menu("instance"),this.menuInstance._off(this.menu,"mouseleave"),this.menuInstance._closeOnDocumentClick=function(){return!1},this.menuInstance._isDivider=function(){return!1}},refresh:function(){this._refreshMenu(),this.buttonItem.replaceWith(this.buttonItem=this._renderButtonItem(this._getSelectedItem().data("ui-selectmenu-item")||{})),null===this.options.width&&this._resizeButton()},_refreshMenu:function(){var t=this.element.find("option");this.menu.empty(),this._parseOptions(t),this._renderMenu(this.menu,this.items),this.menuInstance.refresh(),this.menuItems=this.menu.find("li").not(".ui-selectmenu-optgroup").find(".ui-menu-item-wrapper"),this._rendered=!0,t.length&&(t=this._getSelectedItem(),this.menuInstance.focus(null,t),this._setAria(t.data("ui-selectmenu-item")),this._setOption("disabled",this.element.prop("disabled")))},open:function(t){this.options.disabled||(this._rendered?(this._removeClass(this.menu.find(".ui-state-active"),null,"ui-state-active"),this.menuInstance.focus(null,this._getSelectedItem())):this._refreshMenu(),this.menuItems.length&&(this.isOpen=!0,this._toggleAttr(),this._resizeMenu(),this._position(),this._on(this.document,this._documentClick),this._trigger("open",t)))},_position:function(){this.menuWrap.position(V.extend({of:this.button},this.options.position))},close:function(t){this.isOpen&&(this.isOpen=!1,this._toggleAttr(),this.range=null,this._off(this.document),this._trigger("close",t))},widget:function(){return this.button},menuWidget:function(){return this.menu},_renderButtonItem:function(t){var e=V("<span>");return this._setText(e,t.label),this._addClass(e,"ui-selectmenu-text"),e},_renderMenu:function(s,t){var n=this,o="";V.each(t,function(t,e){var i;e.optgroup!==o&&(i=V("<li>",{text:e.optgroup}),n._addClass(i,"ui-selectmenu-optgroup","ui-menu-divider"+(e.element.parent("optgroup").prop("disabled")?" ui-state-disabled":"")),i.appendTo(s),o=e.optgroup),n._renderItemData(s,e)})},_renderItemData:function(t,e){return this._renderItem(t,e).data("ui-selectmenu-item",e)},_renderItem:function(t,e){var i=V("<li>"),s=V("<div>",{title:e.element.attr("title")});return e.disabled&&this._addClass(i,null,"ui-state-disabled"),this._setText(s,e.label),i.append(s).appendTo(t)},_setText:function(t,e){e?t.text(e):t.html(" ")},_move:function(t,e){var i,s=".ui-menu-item";this.isOpen?i=this.menuItems.eq(this.focusIndex).parent("li"):(i=this.menuItems.eq(this.element[0].selectedIndex).parent("li"),s+=":not(.ui-state-disabled)"),(s="first"===t||"last"===t?i["first"===t?"prevAll":"nextAll"](s).eq(-1):i[t+"All"](s).eq(0)).length&&this.menuInstance.focus(e,s)},_getSelectedItem:function(){return this.menuItems.eq(this.element[0].selectedIndex).parent("li")},_toggle:function(t){this[this.isOpen?"close":"open"](t)},_setSelection:function(){var t;this.range&&(window.getSelection?((t=window.getSelection()).removeAllRanges(),t.addRange(this.range)):this.range.select(),this.button.trigger("focus"))},_documentClick:{mousedown:function(t){this.isOpen&&(V(t.target).closest(".ui-selectmenu-menu, #"+V.escapeSelector(this.ids.button)).length||this.close(t))}},_buttonEvents:{mousedown:function(){var t;window.getSelection?(t=window.getSelection()).rangeCount&&(this.range=t.getRangeAt(0)):this.range=document.selection.createRange()},click:function(t){this._setSelection(),this._toggle(t)},keydown:function(t){var e=!0;switch(t.keyCode){case V.ui.keyCode.TAB:case V.ui.keyCode.ESCAPE:this.close(t),e=!1;break;case V.ui.keyCode.ENTER:this.isOpen&&this._selectFocusedItem(t);break;case V.ui.keyCode.UP:t.altKey?this._toggle(t):this._move("prev",t);break;case V.ui.keyCode.DOWN:t.altKey?this._toggle(t):this._move("next",t);break;case V.ui.keyCode.SPACE:this.isOpen?this._selectFocusedItem(t):this._toggle(t);break;case V.ui.keyCode.LEFT:this._move("prev",t);break;case V.ui.keyCode.RIGHT:this._move("next",t);break;case V.ui.keyCode.HOME:case V.ui.keyCode.PAGE_UP:this._move("first",t);break;case V.ui.keyCode.END:case V.ui.keyCode.PAGE_DOWN:this._move("last",t);break;default:this.menu.trigger(t),e=!1}e&&t.preventDefault()}},_selectFocusedItem:function(t){var e=this.menuItems.eq(this.focusIndex).parent("li");e.hasClass("ui-state-disabled")||this._select(e.data("ui-selectmenu-item"),t)},_select:function(t,e){var i=this.element[0].selectedIndex;this.element[0].selectedIndex=t.index,this.buttonItem.replaceWith(this.buttonItem=this._renderButtonItem(t)),this._setAria(t),this._trigger("select",e,{item:t}),t.index!==i&&this._trigger("change",e,{item:t}),this.close(e)},_setAria:function(t){t=this.menuItems.eq(t.index).attr("id");this.button.attr({"aria-labelledby":t,"aria-activedescendant":t}),this.menu.attr("aria-activedescendant",t)},_setOption:function(t,e){var i;"icons"===t&&(i=this.button.find("span.ui-icon"),this._removeClass(i,null,this.options.icons.button)._addClass(i,null,e.button)),this._super(t,e),"appendTo"===t&&this.menuWrap.appendTo(this._appendTo()),"width"===t&&this._resizeButton()},_setOptionDisabled:function(t){this._super(t),this.menuInstance.option("disabled",t),this.button.attr("aria-disabled",t),this._toggleClass(this.button,null,"ui-state-disabled",t),this.element.prop("disabled",t),t?(this.button.attr("tabindex",-1),this.close()):this.button.attr("tabindex",0)},_appendTo:function(){var t=this.options.appendTo;return t=!(t=!(t=t&&(t.jquery||t.nodeType?V(t):this.document.find(t).eq(0)))||!t[0]?this.element.closest(".ui-front, dialog"):t).length?this.document[0].body:t},_toggleAttr:function(){this.button.attr("aria-expanded",this.isOpen),this._removeClass(this.button,"ui-selectmenu-button-"+(this.isOpen?"closed":"open"))._addClass(this.button,"ui-selectmenu-button-"+(this.isOpen?"open":"closed"))._toggleClass(this.menuWrap,"ui-selectmenu-open",null,this.isOpen),this.menu.attr("aria-hidden",!this.isOpen)},_resizeButton:function(){var t=this.options.width;!1!==t?(null===t&&(t=this.element.show().outerWidth(),this.element.hide()),this.button.outerWidth(t)):this.button.css("width","")},_resizeMenu:function(){this.menu.outerWidth(Math.max(this.button.outerWidth(),this.menu.width("").outerWidth()+1))},_getCreateOptions:function(){var t=this._super();return t.disabled=this.element.prop("disabled"),t},_parseOptions:function(t){var i=this,s=[];t.each(function(t,e){e.hidden||s.push(i._parseOption(V(e),t))}),this.items=s},_parseOption:function(t,e){var i=t.parent("optgroup");return{element:t,index:e,value:t.val(),label:t.text(),optgroup:i.attr("label")||"",disabled:i.prop("disabled")||t.prop("disabled")}},_destroy:function(){this._unbindFormResetHandler(),this.menuWrap.remove(),this.button.remove(),this.element.show(),this.element.removeUniqueId(),this.labels.attr("for",this.ids.element)}}]),V.widget("ui.slider",V.ui.mouse,{version:"1.13.2",widgetEventPrefix:"slide",options:{animate:!1,classes:{"ui-slider":"ui-corner-all","ui-slider-handle":"ui-corner-all","ui-slider-range":"ui-corner-all ui-widget-header"},distance:0,max:100,min:0,orientation:"horizontal",range:!1,step:1,value:0,values:null,change:null,slide:null,start:null,stop:null},numPages:5,_create:function(){this._keySliding=!1,this._mouseSliding=!1,this._animateOff=!0,this._handleIndex=null,this._detectOrientation(),this._mouseInit(),this._calculateNewMax(),this._addClass("ui-slider ui-slider-"+this.orientation,"ui-widget ui-widget-content"),this._refresh(),this._animateOff=!1},_refresh:function(){this._createRange(),this._createHandles(),this._setupEvents(),this._refreshValue()},_createHandles:function(){var t,e=this.options,i=this.element.find(".ui-slider-handle"),s=[],n=e.values&&e.values.length||1;for(i.length>n&&(i.slice(n).remove(),i=i.slice(0,n)),t=i.length;t<n;t++)s.push("<span tabindex='0'></span>");this.handles=i.add(V(s.join("")).appendTo(this.element)),this._addClass(this.handles,"ui-slider-handle","ui-state-default"),this.handle=this.handles.eq(0),this.handles.each(function(t){V(this).data("ui-slider-handle-index",t).attr("tabIndex",0)})},_createRange:function(){var t=this.options;t.range?(!0===t.range&&(t.values?t.values.length&&2!==t.values.length?t.values=[t.values[0],t.values[0]]:Array.isArray(t.values)&&(t.values=t.values.slice(0)):t.values=[this._valueMin(),this._valueMin()]),this.range&&this.range.length?(this._removeClass(this.range,"ui-slider-range-min ui-slider-range-max"),this.range.css({left:"",bottom:""})):(this.range=V("<div>").appendTo(this.element),this._addClass(this.range,"ui-slider-range")),"min"!==t.range&&"max"!==t.range||this._addClass(this.range,"ui-slider-range-"+t.range)):(this.range&&this.range.remove(),this.range=null)},_setupEvents:function(){this._off(this.handles),this._on(this.handles,this._handleEvents),this._hoverable(this.handles),this._focusable(this.handles)},_destroy:function(){this.handles.remove(),this.range&&this.range.remove(),this._mouseDestroy()},_mouseCapture:function(t){var i,s,n,o,e,a,r=this,l=this.options;return!l.disabled&&(this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()},this.elementOffset=this.element.offset(),a={x:t.pageX,y:t.pageY},i=this._normValueFromMouse(a),s=this._valueMax()-this._valueMin()+1,this.handles.each(function(t){var e=Math.abs(i-r.values(t));(e<s||s===e&&(t===r._lastChangedValue||r.values(t)===l.min))&&(s=e,n=V(this),o=t)}),!1!==this._start(t,o)&&(this._mouseSliding=!0,this._handleIndex=o,this._addClass(n,null,"ui-state-active"),n.trigger("focus"),e=n.offset(),a=!V(t.target).parents().addBack().is(".ui-slider-handle"),this._clickOffset=a?{left:0,top:0}:{left:t.pageX-e.left-n.width()/2,top:t.pageY-e.top-n.height()/2-(parseInt(n.css("borderTopWidth"),10)||0)-(parseInt(n.css("borderBottomWidth"),10)||0)+(parseInt(n.css("marginTop"),10)||0)},this.handles.hasClass("ui-state-hover")||this._slide(t,o,i),this._animateOff=!0))},_mouseStart:function(){return!0},_mouseDrag:function(t){var e={x:t.pageX,y:t.pageY},e=this._normValueFromMouse(e);return this._slide(t,this._handleIndex,e),!1},_mouseStop:function(t){return this._removeClass(this.handles,null,"ui-state-active"),this._mouseSliding=!1,this._stop(t,this._handleIndex),this._change(t,this._handleIndex),this._handleIndex=null,this._clickOffset=null,this._animateOff=!1},_detectOrientation:function(){this.orientation="vertical"===this.options.orientation?"vertical":"horizontal"},_normValueFromMouse:function(t){var e,t="horizontal"===this.orientation?(e=this.elementSize.width,t.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(e=this.elementSize.height,t.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)),t=t/e;return(t=1<t?1:t)<0&&(t=0),"vertical"===this.orientation&&(t=1-t),e=this._valueMax()-this._valueMin(),e=this._valueMin()+t*e,this._trimAlignValue(e)},_uiHash:function(t,e,i){var s={handle:this.handles[t],handleIndex:t,value:void 0!==e?e:this.value()};return this._hasMultipleValues()&&(s.value=void 0!==e?e:this.values(t),s.values=i||this.values()),s},_hasMultipleValues:function(){return this.options.values&&this.options.values.length},_start:function(t,e){return this._trigger("start",t,this._uiHash(e))},_slide:function(t,e,i){var s,n=this.value(),o=this.values();this._hasMultipleValues()&&(s=this.values(e?0:1),n=this.values(e),2===this.options.values.length&&!0===this.options.range&&(i=0===e?Math.min(s,i):Math.max(s,i)),o[e]=i),i!==n&&!1!==this._trigger("slide",t,this._uiHash(e,i,o))&&(this._hasMultipleValues()?this.values(e,i):this.value(i))},_stop:function(t,e){this._trigger("stop",t,this._uiHash(e))},_change:function(t,e){this._keySliding||this._mouseSliding||(this._lastChangedValue=e,this._trigger("change",t,this._uiHash(e)))},value:function(t){return arguments.length?(this.options.value=this._trimAlignValue(t),this._refreshValue(),void this._change(null,0)):this._value()},values:function(t,e){var i,s,n;if(1<arguments.length)return this.options.values[t]=this._trimAlignValue(e),this._refreshValue(),void this._change(null,t);if(!arguments.length)return this._values();if(!Array.isArray(t))return this._hasMultipleValues()?this._values(t):this.value();for(i=this.options.values,s=t,n=0;n<i.length;n+=1)i[n]=this._trimAlignValue(s[n]),this._change(null,n);this._refreshValue()},_setOption:function(t,e){var i,s=0;switch("range"===t&&!0===this.options.range&&("min"===e?(this.options.value=this._values(0),this.options.values=null):"max"===e&&(this.options.value=this._values(this.options.values.length-1),this.options.values=null)),Array.isArray(this.options.values)&&(s=this.options.values.length),this._super(t,e),t){case"orientation":this._detectOrientation(),this._removeClass("ui-slider-horizontal ui-slider-vertical")._addClass("ui-slider-"+this.orientation),this._refreshValue(),this.options.range&&this._refreshRange(e),this.handles.css("horizontal"===e?"bottom":"left","");break;case"value":this._animateOff=!0,this._refreshValue(),this._change(null,0),this._animateOff=!1;break;case"values":for(this._animateOff=!0,this._refreshValue(),i=s-1;0<=i;i--)this._change(null,i);this._animateOff=!1;break;case"step":case"min":case"max":this._animateOff=!0,this._calculateNewMax(),this._refreshValue(),this._animateOff=!1;break;case"range":this._animateOff=!0,this._refresh(),this._animateOff=!1}},_setOptionDisabled:function(t){this._super(t),this._toggleClass(null,"ui-state-disabled",!!t)},_value:function(){var t=this.options.value;return t=this._trimAlignValue(t)},_values:function(t){var e,i;if(arguments.length)return t=this.options.values[t],t=this._trimAlignValue(t);if(this._hasMultipleValues()){for(e=this.options.values.slice(),i=0;i<e.length;i+=1)e[i]=this._trimAlignValue(e[i]);return e}return[]},_trimAlignValue:function(t){if(t<=this._valueMin())return this._valueMin();if(t>=this._valueMax())return this._valueMax();var e=0<this.options.step?this.options.step:1,i=(t-this._valueMin())%e,t=t-i;return 2*Math.abs(i)>=e&&(t+=0<i?e:-e),parseFloat(t.toFixed(5))},_calculateNewMax:function(){var t=this.options.max,e=this._valueMin(),i=this.options.step;(t=Math.round((t-e)/i)*i+e)>this.options.max&&(t-=i),this.max=parseFloat(t.toFixed(this._precision()))},_precision:function(){var t=this._precisionOf(this.options.step);return t=null!==this.options.min?Math.max(t,this._precisionOf(this.options.min)):t},_precisionOf:function(t){var e=t.toString(),t=e.indexOf(".");return-1===t?0:e.length-t-1},_valueMin:function(){return this.options.min},_valueMax:function(){return this.max},_refreshRange:function(t){"vertical"===t&&this.range.css({width:"",left:""}),"horizontal"===t&&this.range.css({height:"",bottom:""})},_refreshValue:function(){var e,i,t,s,n,o=this.options.range,a=this.options,r=this,l=!this._animateOff&&a.animate,h={};this._hasMultipleValues()?this.handles.each(function(t){i=(r.values(t)-r._valueMin())/(r._valueMax()-r._valueMin())*100,h["horizontal"===r.orientation?"left":"bottom"]=i+"%",V(this).stop(1,1)[l?"animate":"css"](h,a.animate),!0===r.options.range&&("horizontal"===r.orientation?(0===t&&r.range.stop(1,1)[l?"animate":"css"]({left:i+"%"},a.animate),1===t&&r.range[l?"animate":"css"]({width:i-e+"%"},{queue:!1,duration:a.animate})):(0===t&&r.range.stop(1,1)[l?"animate":"css"]({bottom:i+"%"},a.animate),1===t&&r.range[l?"animate":"css"]({height:i-e+"%"},{queue:!1,duration:a.animate}))),e=i}):(t=this.value(),s=this._valueMin(),n=this._valueMax(),i=n!==s?(t-s)/(n-s)*100:0,h["horizontal"===this.orientation?"left":"bottom"]=i+"%",this.handle.stop(1,1)[l?"animate":"css"](h,a.animate),"min"===o&&"horizontal"===this.orientation&&this.range.stop(1,1)[l?"animate":"css"]({width:i+"%"},a.animate),"max"===o&&"horizontal"===this.orientation&&this.range.stop(1,1)[l?"animate":"css"]({width:100-i+"%"},a.animate),"min"===o&&"vertical"===this.orientation&&this.range.stop(1,1)[l?"animate":"css"]({height:i+"%"},a.animate),"max"===o&&"vertical"===this.orientation&&this.range.stop(1,1)[l?"animate":"css"]({height:100-i+"%"},a.animate))},_handleEvents:{keydown:function(t){var e,i,s,n=V(t.target).data("ui-slider-handle-index");switch(t.keyCode){case V.ui.keyCode.HOME:case V.ui.keyCode.END:case V.ui.keyCode.PAGE_UP:case V.ui.keyCode.PAGE_DOWN:case V.ui.keyCode.UP:case V.ui.keyCode.RIGHT:case V.ui.keyCode.DOWN:case V.ui.keyCode.LEFT:if(t.preventDefault(),!this._keySliding&&(this._keySliding=!0,this._addClass(V(t.target),null,"ui-state-active"),!1===this._start(t,n)))return}switch(s=this.options.step,e=i=this._hasMultipleValues()?this.values(n):this.value(),t.keyCode){case V.ui.keyCode.HOME:i=this._valueMin();break;case V.ui.keyCode.END:i=this._valueMax();break;case V.ui.keyCode.PAGE_UP:i=this._trimAlignValue(e+(this._valueMax()-this._valueMin())/this.numPages);break;case V.ui.keyCode.PAGE_DOWN:i=this._trimAlignValue(e-(this._valueMax()-this._valueMin())/this.numPages);break;case V.ui.keyCode.UP:case V.ui.keyCode.RIGHT:if(e===this._valueMax())return;i=this._trimAlignValue(e+s);break;case V.ui.keyCode.DOWN:case V.ui.keyCode.LEFT:if(e===this._valueMin())return;i=this._trimAlignValue(e-s)}this._slide(t,n,i)},keyup:function(t){var e=V(t.target).data("ui-slider-handle-index");this._keySliding&&(this._keySliding=!1,this._stop(t,e),this._change(t,e),this._removeClass(V(t.target),null,"ui-state-active"))}}}),V.widget("ui.sortable",V.ui.mouse,{version:"1.13.2",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_isOverAxis:function(t,e,i){return e<=t&&t<e+i},_isFloating:function(t){return/left|right/.test(t.css("float"))||/inline|table-cell/.test(t.css("display"))},_create:function(){this.containerCache={},this._addClass("ui-sortable"),this.refresh(),this.offset=this.element.offset(),this._mouseInit(),this._setHandleClassName(),this.ready=!0},_setOption:function(t,e){this._super(t,e),"handle"===t&&this._setHandleClassName()},_setHandleClassName:function(){var t=this;this._removeClass(this.element.find(".ui-sortable-handle"),"ui-sortable-handle"),V.each(this.items,function(){t._addClass(this.instance.options.handle?this.item.find(this.instance.options.handle):this.item,"ui-sortable-handle")})},_destroy:function(){this._mouseDestroy();for(var t=this.items.length-1;0<=t;t--)this.items[t].item.removeData(this.widgetName+"-item");return this},_mouseCapture:function(t,e){var i=null,s=!1,n=this;return!this.reverting&&(!this.options.disabled&&"static"!==this.options.type&&(this._refreshItems(t),V(t.target).parents().each(function(){if(V.data(this,n.widgetName+"-item")===n)return i=V(this),!1}),!!(i=V.data(t.target,n.widgetName+"-item")===n?V(t.target):i)&&(!(this.options.handle&&!e&&(V(this.options.handle,i).find("*").addBack().each(function(){this===t.target&&(s=!0)}),!s))&&(this.currentItem=i,this._removeCurrentsFromItems(),!0))))},_mouseStart:function(t,e,i){var s,n,o=this.options;if((this.currentContainer=this).refreshPositions(),this.appendTo=V("parent"!==o.appendTo?o.appendTo:this.currentItem.parent()),this.helper=this._createHelper(t),this._cacheHelperProportions(),this._cacheMargins(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},V.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),o.cursorAt&&this._adjustOffsetFromHelper(o.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!==this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),this.scrollParent=this.placeholder.scrollParent(),V.extend(this.offset,{parent:this._getParentOffset()}),o.containment&&this._setContainment(),o.cursor&&"auto"!==o.cursor&&(n=this.document.find("body"),this.storedCursor=n.css("cursor"),n.css("cursor",o.cursor),this.storedStylesheet=V("<style>*{ cursor: "+o.cursor+" !important; }</style>").appendTo(n)),o.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",o.zIndex)),o.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",o.opacity)),this.scrollParent[0]!==this.document[0]&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",t,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!i)for(s=this.containers.length-1;0<=s;s--)this.containers[s]._trigger("activate",t,this._uiHash(this));return V.ui.ddmanager&&(V.ui.ddmanager.current=this),V.ui.ddmanager&&!o.dropBehaviour&&V.ui.ddmanager.prepareOffsets(this,t),this.dragging=!0,this._addClass(this.helper,"ui-sortable-helper"),this.helper.parent().is(this.appendTo)||(this.helper.detach().appendTo(this.appendTo),this.offset.parent=this._getParentOffset()),this.position=this.originalPosition=this._generatePosition(t),this.originalPageX=t.pageX,this.originalPageY=t.pageY,this.lastPositionAbs=this.positionAbs=this._convertPositionTo("absolute"),this._mouseDrag(t),!0},_scroll:function(t){var e=this.options,i=!1;return this.scrollParent[0]!==this.document[0]&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-t.pageY<e.scrollSensitivity?this.scrollParent[0].scrollTop=i=this.scrollParent[0].scrollTop+e.scrollSpeed:t.pageY-this.overflowOffset.top<e.scrollSensitivity&&(this.scrollParent[0].scrollTop=i=this.scrollParent[0].scrollTop-e.scrollSpeed),this.overflowOffset.left+this.scrollParent[0].offsetWidth-t.pageX<e.scrollSensitivity?this.scrollParent[0].scrollLeft=i=this.scrollParent[0].scrollLeft+e.scrollSpeed:t.pageX-this.overflowOffset.left<e.scrollSensitivity&&(this.scrollParent[0].scrollLeft=i=this.scrollParent[0].scrollLeft-e.scrollSpeed)):(t.pageY-this.document.scrollTop()<e.scrollSensitivity?i=this.document.scrollTop(this.document.scrollTop()-e.scrollSpeed):this.window.height()-(t.pageY-this.document.scrollTop())<e.scrollSensitivity&&(i=this.document.scrollTop(this.document.scrollTop()+e.scrollSpeed)),t.pageX-this.document.scrollLeft()<e.scrollSensitivity?i=this.document.scrollLeft(this.document.scrollLeft()-e.scrollSpeed):this.window.width()-(t.pageX-this.document.scrollLeft())<e.scrollSensitivity&&(i=this.document.scrollLeft(this.document.scrollLeft()+e.scrollSpeed))),i},_mouseDrag:function(t){var e,i,s,n,o=this.options;for(this.position=this._generatePosition(t),this.positionAbs=this._convertPositionTo("absolute"),this.options.axis&&"y"===this.options.axis||(this.helper[0].style.left=this.position.left+"px"),this.options.axis&&"x"===this.options.axis||(this.helper[0].style.top=this.position.top+"px"),o.scroll&&!1!==this._scroll(t)&&(this._refreshItemPositions(!0),V.ui.ddmanager&&!o.dropBehaviour&&V.ui.ddmanager.prepareOffsets(this,t)),this.dragDirection={vertical:this._getDragVerticalDirection(),horizontal:this._getDragHorizontalDirection()},e=this.items.length-1;0<=e;e--)if(s=(i=this.items[e]).item[0],(n=this._intersectsWithPointer(i))&&i.instance===this.currentContainer&&!(s===this.currentItem[0]||this.placeholder[1===n?"next":"prev"]()[0]===s||V.contains(this.placeholder[0],s)||"semi-dynamic"===this.options.type&&V.contains(this.element[0],s))){if(this.direction=1===n?"down":"up","pointer"!==this.options.tolerance&&!this._intersectsWithSides(i))break;this._rearrange(t,i),this._trigger("change",t,this._uiHash());break}return this._contactContainers(t),V.ui.ddmanager&&V.ui.ddmanager.drag(this,t),this._trigger("sort",t,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(t,e){var i,s,n,o;if(t)return V.ui.ddmanager&&!this.options.dropBehaviour&&V.ui.ddmanager.drop(this,t),this.options.revert?(s=(i=this).placeholder.offset(),o={},(n=this.options.axis)&&"x"!==n||(o.left=s.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]===this.document[0].body?0:this.offsetParent[0].scrollLeft)),n&&"y"!==n||(o.top=s.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]===this.document[0].body?0:this.offsetParent[0].scrollTop)),this.reverting=!0,V(this.helper).animate(o,parseInt(this.options.revert,10)||500,function(){i._clear(t)})):this._clear(t,e),!1},cancel:function(){if(this.dragging){this._mouseUp(new V.Event("mouseup",{target:null})),"original"===this.options.helper?(this.currentItem.css(this._storedCSS),this._removeClass(this.currentItem,"ui-sortable-helper")):this.currentItem.show();for(var t=this.containers.length-1;0<=t;t--)this.containers[t]._trigger("deactivate",null,this._uiHash(this)),this.containers[t].containerCache.over&&(this.containers[t]._trigger("out",null,this._uiHash(this)),this.containers[t].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!==this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),V.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?V(this.domPosition.prev).after(this.currentItem):V(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(e){var t=this._getItemsAsjQuery(e&&e.connected),i=[];return e=e||{},V(t).each(function(){var t=(V(e.item||this).attr(e.attribute||"id")||"").match(e.expression||/(.+)[\-=_](.+)/);t&&i.push((e.key||t[1]+"[]")+"="+(e.key&&e.expression?t[1]:t[2]))}),!i.length&&e.key&&i.push(e.key+"="),i.join("&")},toArray:function(t){var e=this._getItemsAsjQuery(t&&t.connected),i=[];return t=t||{},e.each(function(){i.push(V(t.item||this).attr(t.attribute||"id")||"")}),i},_intersectsWith:function(t){var e=this.positionAbs.left,i=e+this.helperProportions.width,s=this.positionAbs.top,n=s+this.helperProportions.height,o=t.left,a=o+t.width,r=t.top,l=r+t.height,h=this.offset.click.top,c=this.offset.click.left,h="x"===this.options.axis||r<s+h&&s+h<l,c="y"===this.options.axis||o<e+c&&e+c<a;return"pointer"===this.options.tolerance||this.options.forcePointerForContainers||"pointer"!==this.options.tolerance&&this.helperProportions[this.floating?"width":"height"]>t[this.floating?"width":"height"]?h&&c:o<e+this.helperProportions.width/2&&i-this.helperProportions.width/2<a&&r<s+this.helperProportions.height/2&&n-this.helperProportions.height/2<l},_intersectsWithPointer:function(t){var e="x"===this.options.axis||this._isOverAxis(this.positionAbs.top+this.offset.click.top,t.top,t.height),t="y"===this.options.axis||this._isOverAxis(this.positionAbs.left+this.offset.click.left,t.left,t.width);return!(!e||!t)&&(e=this.dragDirection.vertical,t=this.dragDirection.horizontal,this.floating?"right"===t||"down"===e?2:1:e&&("down"===e?2:1))},_intersectsWithSides:function(t){var e=this._isOverAxis(this.positionAbs.top+this.offset.click.top,t.top+t.height/2,t.height),i=this._isOverAxis(this.positionAbs.left+this.offset.click.left,t.left+t.width/2,t.width),s=this.dragDirection.vertical,t=this.dragDirection.horizontal;return this.floating&&t?"right"===t&&i||"left"===t&&!i:s&&("down"===s&&e||"up"===s&&!e)},_getDragVerticalDirection:function(){var t=this.positionAbs.top-this.lastPositionAbs.top;return 0!=t&&(0<t?"down":"up")},_getDragHorizontalDirection:function(){var t=this.positionAbs.left-this.lastPositionAbs.left;return 0!=t&&(0<t?"right":"left")},refresh:function(t){return this._refreshItems(t),this._setHandleClassName(),this.refreshPositions(),this},_connectWith:function(){var t=this.options;return t.connectWith.constructor===String?[t.connectWith]:t.connectWith},_getItemsAsjQuery:function(t){var e,i,s,n,o=[],a=[],r=this._connectWith();if(r&&t)for(e=r.length-1;0<=e;e--)for(i=(s=V(r[e],this.document[0])).length-1;0<=i;i--)(n=V.data(s[i],this.widgetFullName))&&n!==this&&!n.options.disabled&&a.push(["function"==typeof n.options.items?n.options.items.call(n.element):V(n.options.items,n.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),n]);function l(){o.push(this)}for(a.push(["function"==typeof this.options.items?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):V(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]),e=a.length-1;0<=e;e--)a[e][0].each(l);return V(o)},_removeCurrentsFromItems:function(){var i=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=V.grep(this.items,function(t){for(var e=0;e<i.length;e++)if(i[e]===t.item[0])return!1;return!0})},_refreshItems:function(t){this.items=[],this.containers=[this];var e,i,s,n,o,a,r,l,h=this.items,c=[["function"==typeof this.options.items?this.options.items.call(this.element[0],t,{item:this.currentItem}):V(this.options.items,this.element),this]],u=this._connectWith();if(u&&this.ready)for(e=u.length-1;0<=e;e--)for(i=(s=V(u[e],this.document[0])).length-1;0<=i;i--)(n=V.data(s[i],this.widgetFullName))&&n!==this&&!n.options.disabled&&(c.push(["function"==typeof n.options.items?n.options.items.call(n.element[0],t,{item:this.currentItem}):V(n.options.items,n.element),n]),this.containers.push(n));for(e=c.length-1;0<=e;e--)for(o=c[e][1],l=(a=c[e][i=0]).length;i<l;i++)(r=V(a[i])).data(this.widgetName+"-item",o),h.push({item:r,instance:o,width:0,height:0,left:0,top:0})},_refreshItemPositions:function(t){for(var e,i,s=this.items.length-1;0<=s;s--)e=this.items[s],this.currentContainer&&e.instance!==this.currentContainer&&e.item[0]!==this.currentItem[0]||(i=this.options.toleranceElement?V(this.options.toleranceElement,e.item):e.item,t||(e.width=i.outerWidth(),e.height=i.outerHeight()),i=i.offset(),e.left=i.left,e.top=i.top)},refreshPositions:function(t){var e,i;if(this.floating=!!this.items.length&&("x"===this.options.axis||this._isFloating(this.items[0].item)),this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset()),this._refreshItemPositions(t),this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(e=this.containers.length-1;0<=e;e--)i=this.containers[e].element.offset(),this.containers[e].containerCache.left=i.left,this.containers[e].containerCache.top=i.top,this.containers[e].containerCache.width=this.containers[e].element.outerWidth(),this.containers[e].containerCache.height=this.containers[e].element.outerHeight();return this},_createPlaceholder:function(i){var s,n,o=(i=i||this).options;o.placeholder&&o.placeholder.constructor!==String||(s=o.placeholder,n=i.currentItem[0].nodeName.toLowerCase(),o.placeholder={element:function(){var t=V("<"+n+">",i.document[0]);return i._addClass(t,"ui-sortable-placeholder",s||i.currentItem[0].className)._removeClass(t,"ui-sortable-helper"),"tbody"===n?i._createTrPlaceholder(i.currentItem.find("tr").eq(0),V("<tr>",i.document[0]).appendTo(t)):"tr"===n?i._createTrPlaceholder(i.currentItem,t):"img"===n&&t.attr("src",i.currentItem.attr("src")),s||t.css("visibility","hidden"),t},update:function(t,e){s&&!o.forcePlaceholderSize||(e.height()&&(!o.forcePlaceholderSize||"tbody"!==n&&"tr"!==n)||e.height(i.currentItem.innerHeight()-parseInt(i.currentItem.css("paddingTop")||0,10)-parseInt(i.currentItem.css("paddingBottom")||0,10)),e.width()||e.width(i.currentItem.innerWidth()-parseInt(i.currentItem.css("paddingLeft")||0,10)-parseInt(i.currentItem.css("paddingRight")||0,10)))}}),i.placeholder=V(o.placeholder.element.call(i.element,i.currentItem)),i.currentItem.after(i.placeholder),o.placeholder.update(i,i.placeholder)},_createTrPlaceholder:function(t,e){var i=this;t.children().each(function(){V("<td> </td>",i.document[0]).attr("colspan",V(this).attr("colspan")||1).appendTo(e)})},_contactContainers:function(t){for(var e,i,s,n,o,a,r,l,h,c=null,u=null,d=this.containers.length-1;0<=d;d--)V.contains(this.currentItem[0],this.containers[d].element[0])||(this._intersectsWith(this.containers[d].containerCache)?c&&V.contains(this.containers[d].element[0],c.element[0])||(c=this.containers[d],u=d):this.containers[d].containerCache.over&&(this.containers[d]._trigger("out",t,this._uiHash(this)),this.containers[d].containerCache.over=0));if(c)if(1===this.containers.length)this.containers[u].containerCache.over||(this.containers[u]._trigger("over",t,this._uiHash(this)),this.containers[u].containerCache.over=1);else{for(i=1e4,s=null,n=(l=c.floating||this._isFloating(this.currentItem))?"left":"top",o=l?"width":"height",h=l?"pageX":"pageY",e=this.items.length-1;0<=e;e--)V.contains(this.containers[u].element[0],this.items[e].item[0])&&this.items[e].item[0]!==this.currentItem[0]&&(a=this.items[e].item.offset()[n],r=!1,t[h]-a>this.items[e][o]/2&&(r=!0),Math.abs(t[h]-a)<i&&(i=Math.abs(t[h]-a),s=this.items[e],this.direction=r?"up":"down"));(s||this.options.dropOnEmpty)&&(this.currentContainer!==this.containers[u]?(s?this._rearrange(t,s,null,!0):this._rearrange(t,null,this.containers[u].element,!0),this._trigger("change",t,this._uiHash()),this.containers[u]._trigger("change",t,this._uiHash(this)),this.currentContainer=this.containers[u],this.options.placeholder.update(this.currentContainer,this.placeholder),this.scrollParent=this.placeholder.scrollParent(),this.scrollParent[0]!==this.document[0]&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this.containers[u]._trigger("over",t,this._uiHash(this)),this.containers[u].containerCache.over=1):this.currentContainer.containerCache.over||(this.containers[u]._trigger("over",t,this._uiHash()),this.currentContainer.containerCache.over=1))}},_createHelper:function(t){var e=this.options,t="function"==typeof e.helper?V(e.helper.apply(this.element[0],[t,this.currentItem])):"clone"===e.helper?this.currentItem.clone():this.currentItem;return t.parents("body").length||this.appendTo[0].appendChild(t[0]),t[0]===this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),t[0].style.width&&!e.forceHelperSize||t.width(this.currentItem.width()),t[0].style.height&&!e.forceHelperSize||t.height(this.currentItem.height()),t},_adjustOffsetFromHelper:function(t){"string"==typeof t&&(t=t.split(" ")),"left"in(t=Array.isArray(t)?{left:+t[0],top:+t[1]||0}:t)&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var t=this.offsetParent.offset();return"absolute"===this.cssPosition&&this.scrollParent[0]!==this.document[0]&&V.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop()),{top:(t=this.offsetParent[0]===this.document[0].body||this.offsetParent[0].tagName&&"html"===this.offsetParent[0].tagName.toLowerCase()&&V.ui.ie?{top:0,left:0}:t).top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"!==this.cssPosition)return{top:0,left:0};var t=this.currentItem.position();return{top:t.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:t.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t,e,i=this.options;"parent"===i.containment&&(i.containment=this.helper[0].parentNode),"document"!==i.containment&&"window"!==i.containment||(this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,"document"===i.containment?this.document.width():this.window.width()-this.helperProportions.width-this.margins.left,("document"===i.containment?this.document.height()||document.body.parentNode.scrollHeight:this.window.height()||this.document[0].body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]),/^(document|window|parent)$/.test(i.containment)||(t=V(i.containment)[0],e=V(i.containment).offset(),i="hidden"!==V(t).css("overflow"),this.containment=[e.left+(parseInt(V(t).css("borderLeftWidth"),10)||0)+(parseInt(V(t).css("paddingLeft"),10)||0)-this.margins.left,e.top+(parseInt(V(t).css("borderTopWidth"),10)||0)+(parseInt(V(t).css("paddingTop"),10)||0)-this.margins.top,e.left+(i?Math.max(t.scrollWidth,t.offsetWidth):t.offsetWidth)-(parseInt(V(t).css("borderLeftWidth"),10)||0)-(parseInt(V(t).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,e.top+(i?Math.max(t.scrollHeight,t.offsetHeight):t.offsetHeight)-(parseInt(V(t).css("borderTopWidth"),10)||0)-(parseInt(V(t).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top])},_convertPositionTo:function(t,e){e=e||this.position;var i="absolute"===t?1:-1,s="absolute"!==this.cssPosition||this.scrollParent[0]!==this.document[0]&&V.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,t=/(html|body)/i.test(s[0].tagName);return{top:e.top+this.offset.relative.top*i+this.offset.parent.top*i-("fixed"===this.cssPosition?-this.scrollParent.scrollTop():t?0:s.scrollTop())*i,left:e.left+this.offset.relative.left*i+this.offset.parent.left*i-("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():t?0:s.scrollLeft())*i}},_generatePosition:function(t){var e=this.options,i=t.pageX,s=t.pageY,n="absolute"!==this.cssPosition||this.scrollParent[0]!==this.document[0]&&V.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,o=/(html|body)/i.test(n[0].tagName);return"relative"!==this.cssPosition||this.scrollParent[0]!==this.document[0]&&this.scrollParent[0]!==this.offsetParent[0]||(this.offset.relative=this._getRelativeOffset()),this.originalPosition&&(this.containment&&(t.pageX-this.offset.click.left<this.containment[0]&&(i=this.containment[0]+this.offset.click.left),t.pageY-this.offset.click.top<this.containment[1]&&(s=this.containment[1]+this.offset.click.top),t.pageX-this.offset.click.left>this.containment[2]&&(i=this.containment[2]+this.offset.click.left),t.pageY-this.offset.click.top>this.containment[3]&&(s=this.containment[3]+this.offset.click.top)),e.grid&&(t=this.originalPageY+Math.round((s-this.originalPageY)/e.grid[1])*e.grid[1],s=!this.containment||t-this.offset.click.top>=this.containment[1]&&t-this.offset.click.top<=this.containment[3]?t:t-this.offset.click.top>=this.containment[1]?t-e.grid[1]:t+e.grid[1],t=this.originalPageX+Math.round((i-this.originalPageX)/e.grid[0])*e.grid[0],i=!this.containment||t-this.offset.click.left>=this.containment[0]&&t-this.offset.click.left<=this.containment[2]?t:t-this.offset.click.left>=this.containment[0]?t-e.grid[0]:t+e.grid[0])),{top:s-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():o?0:n.scrollTop()),left:i-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():o?0:n.scrollLeft())}},_rearrange:function(t,e,i,s){i?i[0].appendChild(this.placeholder[0]):e.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?e.item[0]:e.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var n=this.counter;this._delay(function(){n===this.counter&&this.refreshPositions(!s)})},_clear:function(t,e){this.reverting=!1;var i,s=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(i in this._storedCSS)"auto"!==this._storedCSS[i]&&"static"!==this._storedCSS[i]||(this._storedCSS[i]="");this.currentItem.css(this._storedCSS),this._removeClass(this.currentItem,"ui-sortable-helper")}else this.currentItem.show();function n(e,i,s){return function(t){s._trigger(e,t,i._uiHash(i))}}for(this.fromOutside&&!e&&s.push(function(t){this._trigger("receive",t,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||e||s.push(function(t){this._trigger("update",t,this._uiHash())}),this!==this.currentContainer&&(e||(s.push(function(t){this._trigger("remove",t,this._uiHash())}),s.push(function(e){return function(t){e._trigger("receive",t,this._uiHash(this))}}.call(this,this.currentContainer)),s.push(function(e){return function(t){e._trigger("update",t,this._uiHash(this))}}.call(this,this.currentContainer)))),i=this.containers.length-1;0<=i;i--)e||s.push(n("deactivate",this,this.containers[i])),this.containers[i].containerCache.over&&(s.push(n("out",this,this.containers[i])),this.containers[i].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,e||this._trigger("beforeStop",t,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.cancelHelperRemoval||(this.helper[0]!==this.currentItem[0]&&this.helper.remove(),this.helper=null),!e){for(i=0;i<s.length;i++)s[i].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!this.cancelHelperRemoval},_trigger:function(){!1===V.Widget.prototype._trigger.apply(this,arguments)&&this.cancel()},_uiHash:function(t){var e=t||this;return{helper:e.helper,placeholder:e.placeholder||V([]),position:e.position,originalPosition:e.originalPosition,offset:e.positionAbs,item:e.currentItem,sender:t?t.element:null}}});function ht(e){return function(){var t=this.element.val();e.apply(this,arguments),this._refresh(),t!==this.element.val()&&this._trigger("change")}}V.widget("ui.spinner",{version:"1.13.2",defaultElement:"<input>",widgetEventPrefix:"spin",options:{classes:{"ui-spinner":"ui-corner-all","ui-spinner-down":"ui-corner-br","ui-spinner-up":"ui-corner-tr"},culture:null,icons:{down:"ui-icon-triangle-1-s",up:"ui-icon-triangle-1-n"},incremental:!0,max:null,min:null,numberFormat:null,page:10,step:1,change:null,spin:null,start:null,stop:null},_create:function(){this._setOption("max",this.options.max),this._setOption("min",this.options.min),this._setOption("step",this.options.step),""!==this.value()&&this._value(this.element.val(),!0),this._draw(),this._on(this._events),this._refresh(),this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_getCreateOptions:function(){var s=this._super(),n=this.element;return V.each(["min","max","step"],function(t,e){var i=n.attr(e);null!=i&&i.length&&(s[e]=i)}),s},_events:{keydown:function(t){this._start(t)&&this._keydown(t)&&t.preventDefault()},keyup:"_stop",focus:function(){this.previous=this.element.val()},blur:function(t){this.cancelBlur?delete this.cancelBlur:(this._stop(),this._refresh(),this.previous!==this.element.val()&&this._trigger("change",t))},mousewheel:function(t,e){var i=V.ui.safeActiveElement(this.document[0]);if(this.element[0]===i&&e){if(!this.spinning&&!this._start(t))return!1;this._spin((0<e?1:-1)*this.options.step,t),clearTimeout(this.mousewheelTimer),this.mousewheelTimer=this._delay(function(){this.spinning&&this._stop(t)},100),t.preventDefault()}},"mousedown .ui-spinner-button":function(t){var e;function i(){this.element[0]===V.ui.safeActiveElement(this.document[0])||(this.element.trigger("focus"),this.previous=e,this._delay(function(){this.previous=e}))}e=this.element[0]===V.ui.safeActiveElement(this.document[0])?this.previous:this.element.val(),t.preventDefault(),i.call(this),this.cancelBlur=!0,this._delay(function(){delete this.cancelBlur,i.call(this)}),!1!==this._start(t)&&this._repeat(null,V(t.currentTarget).hasClass("ui-spinner-up")?1:-1,t)},"mouseup .ui-spinner-button":"_stop","mouseenter .ui-spinner-button":function(t){if(V(t.currentTarget).hasClass("ui-state-active"))return!1!==this._start(t)&&void this._repeat(null,V(t.currentTarget).hasClass("ui-spinner-up")?1:-1,t)},"mouseleave .ui-spinner-button":"_stop"},_enhance:function(){this.uiSpinner=this.element.attr("autocomplete","off").wrap("<span>").parent().append("<a></a><a></a>")},_draw:function(){this._enhance(),this._addClass(this.uiSpinner,"ui-spinner","ui-widget ui-widget-content"),this._addClass("ui-spinner-input"),this.element.attr("role","spinbutton"),this.buttons=this.uiSpinner.children("a").attr("tabIndex",-1).attr("aria-hidden",!0).button({classes:{"ui-button":""}}),this._removeClass(this.buttons,"ui-corner-all"),this._addClass(this.buttons.first(),"ui-spinner-button ui-spinner-up"),this._addClass(this.buttons.last(),"ui-spinner-button ui-spinner-down"),this.buttons.first().button({icon:this.options.icons.up,showLabel:!1}),this.buttons.last().button({icon:this.options.icons.down,showLabel:!1}),this.buttons.height()>Math.ceil(.5*this.uiSpinner.height())&&0<this.uiSpinner.height()&&this.uiSpinner.height(this.uiSpinner.height())},_keydown:function(t){var e=this.options,i=V.ui.keyCode;switch(t.keyCode){case i.UP:return this._repeat(null,1,t),!0;case i.DOWN:return this._repeat(null,-1,t),!0;case i.PAGE_UP:return this._repeat(null,e.page,t),!0;case i.PAGE_DOWN:return this._repeat(null,-e.page,t),!0}return!1},_start:function(t){return!(!this.spinning&&!1===this._trigger("start",t))&&(this.counter||(this.counter=1),this.spinning=!0)},_repeat:function(t,e,i){t=t||500,clearTimeout(this.timer),this.timer=this._delay(function(){this._repeat(40,e,i)},t),this._spin(e*this.options.step,i)},_spin:function(t,e){var i=this.value()||0;this.counter||(this.counter=1),i=this._adjustValue(i+t*this._increment(this.counter)),this.spinning&&!1===this._trigger("spin",e,{value:i})||(this._value(i),this.counter++)},_increment:function(t){var e=this.options.incremental;return e?"function"==typeof e?e(t):Math.floor(t*t*t/5e4-t*t/500+17*t/200+1):1},_precision:function(){var t=this._precisionOf(this.options.step);return t=null!==this.options.min?Math.max(t,this._precisionOf(this.options.min)):t},_precisionOf:function(t){var e=t.toString(),t=e.indexOf(".");return-1===t?0:e.length-t-1},_adjustValue:function(t){var e=this.options,i=null!==e.min?e.min:0,s=t-i;return t=i+Math.round(s/e.step)*e.step,t=parseFloat(t.toFixed(this._precision())),null!==e.max&&t>e.max?e.max:null!==e.min&&t<e.min?e.min:t},_stop:function(t){this.spinning&&(clearTimeout(this.timer),clearTimeout(this.mousewheelTimer),this.counter=0,this.spinning=!1,this._trigger("stop",t))},_setOption:function(t,e){var i;if("culture"===t||"numberFormat"===t)return i=this._parse(this.element.val()),this.options[t]=e,void this.element.val(this._format(i));"max"!==t&&"min"!==t&&"step"!==t||"string"==typeof e&&(e=this._parse(e)),"icons"===t&&(i=this.buttons.first().find(".ui-icon"),this._removeClass(i,null,this.options.icons.up),this._addClass(i,null,e.up),i=this.buttons.last().find(".ui-icon"),this._removeClass(i,null,this.options.icons.down),this._addClass(i,null,e.down)),this._super(t,e)},_setOptionDisabled:function(t){this._super(t),this._toggleClass(this.uiSpinner,null,"ui-state-disabled",!!t),this.element.prop("disabled",!!t),this.buttons.button(t?"disable":"enable")},_setOptions:ht(function(t){this._super(t)}),_parse:function(t){return""===(t="string"==typeof t&&""!==t?window.Globalize&&this.options.numberFormat?Globalize.parseFloat(t,10,this.options.culture):+t:t)||isNaN(t)?null:t},_format:function(t){return""===t?"":window.Globalize&&this.options.numberFormat?Globalize.format(t,this.options.numberFormat,this.options.culture):t},_refresh:function(){this.element.attr({"aria-valuemin":this.options.min,"aria-valuemax":this.options.max,"aria-valuenow":this._parse(this.element.val())})},isValid:function(){var t=this.value();return null!==t&&t===this._adjustValue(t)},_value:function(t,e){var i;""!==t&&null!==(i=this._parse(t))&&(e||(i=this._adjustValue(i)),t=this._format(i)),this.element.val(t),this._refresh()},_destroy:function(){this.element.prop("disabled",!1).removeAttr("autocomplete role aria-valuemin aria-valuemax aria-valuenow"),this.uiSpinner.replaceWith(this.element)},stepUp:ht(function(t){this._stepUp(t)}),_stepUp:function(t){this._start()&&(this._spin((t||1)*this.options.step),this._stop())},stepDown:ht(function(t){this._stepDown(t)}),_stepDown:function(t){this._start()&&(this._spin((t||1)*-this.options.step),this._stop())},pageUp:ht(function(t){this._stepUp((t||1)*this.options.page)}),pageDown:ht(function(t){this._stepDown((t||1)*this.options.page)}),value:function(t){if(!arguments.length)return this._parse(this.element.val());ht(this._value).call(this,t)},widget:function(){return this.uiSpinner}}),!1!==V.uiBackCompat&&V.widget("ui.spinner",V.ui.spinner,{_enhance:function(){this.uiSpinner=this.element.attr("autocomplete","off").wrap(this._uiSpinnerHtml()).parent().append(this._buttonHtml())},_uiSpinnerHtml:function(){return"<span>"},_buttonHtml:function(){return"<a></a><a></a>"}});var ct;V.ui.spinner;V.widget("ui.tabs",{version:"1.13.2",delay:300,options:{active:null,classes:{"ui-tabs":"ui-corner-all","ui-tabs-nav":"ui-corner-all","ui-tabs-panel":"ui-corner-bottom","ui-tabs-tab":"ui-corner-top"},collapsible:!1,event:"click",heightStyle:"content",hide:null,show:null,activate:null,beforeActivate:null,beforeLoad:null,load:null},_isLocal:(ct=/#.*$/,function(t){var e=t.href.replace(ct,""),i=location.href.replace(ct,"");try{e=decodeURIComponent(e)}catch(t){}try{i=decodeURIComponent(i)}catch(t){}return 1<t.hash.length&&e===i}),_create:function(){var e=this,t=this.options;this.running=!1,this._addClass("ui-tabs","ui-widget ui-widget-content"),this._toggleClass("ui-tabs-collapsible",null,t.collapsible),this._processTabs(),t.active=this._initialActive(),Array.isArray(t.disabled)&&(t.disabled=V.uniqueSort(t.disabled.concat(V.map(this.tabs.filter(".ui-state-disabled"),function(t){return e.tabs.index(t)}))).sort()),!1!==this.options.active&&this.anchors.length?this.active=this._findActive(t.active):this.active=V(),this._refresh(),this.active.length&&this.load(t.active)},_initialActive:function(){var i=this.options.active,t=this.options.collapsible,s=location.hash.substring(1);return null===i&&(s&&this.tabs.each(function(t,e){if(V(e).attr("aria-controls")===s)return i=t,!1}),null!==(i=null===i?this.tabs.index(this.tabs.filter(".ui-tabs-active")):i)&&-1!==i||(i=!!this.tabs.length&&0)),!1!==i&&-1===(i=this.tabs.index(this.tabs.eq(i)))&&(i=!t&&0),i=!t&&!1===i&&this.anchors.length?0:i},_getCreateEventData:function(){return{tab:this.active,panel:this.active.length?this._getPanelForTab(this.active):V()}},_tabKeydown:function(t){var e=V(V.ui.safeActiveElement(this.document[0])).closest("li"),i=this.tabs.index(e),s=!0;if(!this._handlePageNav(t)){switch(t.keyCode){case V.ui.keyCode.RIGHT:case V.ui.keyCode.DOWN:i++;break;case V.ui.keyCode.UP:case V.ui.keyCode.LEFT:s=!1,i--;break;case V.ui.keyCode.END:i=this.anchors.length-1;break;case V.ui.keyCode.HOME:i=0;break;case V.ui.keyCode.SPACE:return t.preventDefault(),clearTimeout(this.activating),void this._activate(i);case V.ui.keyCode.ENTER:return t.preventDefault(),clearTimeout(this.activating),void this._activate(i!==this.options.active&&i);default:return}t.preventDefault(),clearTimeout(this.activating),i=this._focusNextTab(i,s),t.ctrlKey||t.metaKey||(e.attr("aria-selected","false"),this.tabs.eq(i).attr("aria-selected","true"),this.activating=this._delay(function(){this.option("active",i)},this.delay))}},_panelKeydown:function(t){this._handlePageNav(t)||t.ctrlKey&&t.keyCode===V.ui.keyCode.UP&&(t.preventDefault(),this.active.trigger("focus"))},_handlePageNav:function(t){return t.altKey&&t.keyCode===V.ui.keyCode.PAGE_UP?(this._activate(this._focusNextTab(this.options.active-1,!1)),!0):t.altKey&&t.keyCode===V.ui.keyCode.PAGE_DOWN?(this._activate(this._focusNextTab(this.options.active+1,!0)),!0):void 0},_findNextTab:function(t,e){var i=this.tabs.length-1;for(;-1!==V.inArray(t=(t=i<t?0:t)<0?i:t,this.options.disabled);)t=e?t+1:t-1;return t},_focusNextTab:function(t,e){return t=this._findNextTab(t,e),this.tabs.eq(t).trigger("focus"),t},_setOption:function(t,e){"active"!==t?(this._super(t,e),"collapsible"===t&&(this._toggleClass("ui-tabs-collapsible",null,e),e||!1!==this.options.active||this._activate(0)),"event"===t&&this._setupEvents(e),"heightStyle"===t&&this._setupHeightStyle(e)):this._activate(e)},_sanitizeSelector:function(t){return t?t.replace(/[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g,"\\$&"):""},refresh:function(){var t=this.options,e=this.tablist.children(":has(a[href])");t.disabled=V.map(e.filter(".ui-state-disabled"),function(t){return e.index(t)}),this._processTabs(),!1!==t.active&&this.anchors.length?this.active.length&&!V.contains(this.tablist[0],this.active[0])?this.tabs.length===t.disabled.length?(t.active=!1,this.active=V()):this._activate(this._findNextTab(Math.max(0,t.active-1),!1)):t.active=this.tabs.index(this.active):(t.active=!1,this.active=V()),this._refresh()},_refresh:function(){this._setOptionDisabled(this.options.disabled),this._setupEvents(this.options.event),this._setupHeightStyle(this.options.heightStyle),this.tabs.not(this.active).attr({"aria-selected":"false","aria-expanded":"false",tabIndex:-1}),this.panels.not(this._getPanelForTab(this.active)).hide().attr({"aria-hidden":"true"}),this.active.length?(this.active.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0}),this._addClass(this.active,"ui-tabs-active","ui-state-active"),this._getPanelForTab(this.active).show().attr({"aria-hidden":"false"})):this.tabs.eq(0).attr("tabIndex",0)},_processTabs:function(){var l=this,t=this.tabs,e=this.anchors,i=this.panels;this.tablist=this._getList().attr("role","tablist"),this._addClass(this.tablist,"ui-tabs-nav","ui-helper-reset ui-helper-clearfix ui-widget-header"),this.tablist.on("mousedown"+this.eventNamespace,"> li",function(t){V(this).is(".ui-state-disabled")&&t.preventDefault()}).on("focus"+this.eventNamespace,".ui-tabs-anchor",function(){V(this).closest("li").is(".ui-state-disabled")&&this.blur()}),this.tabs=this.tablist.find("> li:has(a[href])").attr({role:"tab",tabIndex:-1}),this._addClass(this.tabs,"ui-tabs-tab","ui-state-default"),this.anchors=this.tabs.map(function(){return V("a",this)[0]}).attr({tabIndex:-1}),this._addClass(this.anchors,"ui-tabs-anchor"),this.panels=V(),this.anchors.each(function(t,e){var i,s,n,o=V(e).uniqueId().attr("id"),a=V(e).closest("li"),r=a.attr("aria-controls");l._isLocal(e)?(n=(i=e.hash).substring(1),s=l.element.find(l._sanitizeSelector(i))):(n=a.attr("aria-controls")||V({}).uniqueId()[0].id,(s=l.element.find(i="#"+n)).length||(s=l._createPanel(n)).insertAfter(l.panels[t-1]||l.tablist),s.attr("aria-live","polite")),s.length&&(l.panels=l.panels.add(s)),r&&a.data("ui-tabs-aria-controls",r),a.attr({"aria-controls":n,"aria-labelledby":o}),s.attr("aria-labelledby",o)}),this.panels.attr("role","tabpanel"),this._addClass(this.panels,"ui-tabs-panel","ui-widget-content"),t&&(this._off(t.not(this.tabs)),this._off(e.not(this.anchors)),this._off(i.not(this.panels)))},_getList:function(){return this.tablist||this.element.find("ol, ul").eq(0)},_createPanel:function(t){return V("<div>").attr("id",t).data("ui-tabs-destroy",!0)},_setOptionDisabled:function(t){var e,i;for(Array.isArray(t)&&(t.length?t.length===this.anchors.length&&(t=!0):t=!1),i=0;e=this.tabs[i];i++)e=V(e),!0===t||-1!==V.inArray(i,t)?(e.attr("aria-disabled","true"),this._addClass(e,null,"ui-state-disabled")):(e.removeAttr("aria-disabled"),this._removeClass(e,null,"ui-state-disabled"));this.options.disabled=t,this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,!0===t)},_setupEvents:function(t){var i={};t&&V.each(t.split(" "),function(t,e){i[e]="_eventHandler"}),this._off(this.anchors.add(this.tabs).add(this.panels)),this._on(!0,this.anchors,{click:function(t){t.preventDefault()}}),this._on(this.anchors,i),this._on(this.tabs,{keydown:"_tabKeydown"}),this._on(this.panels,{keydown:"_panelKeydown"}),this._focusable(this.tabs),this._hoverable(this.tabs)},_setupHeightStyle:function(t){var i,e=this.element.parent();"fill"===t?(i=e.height(),i-=this.element.outerHeight()-this.element.height(),this.element.siblings(":visible").each(function(){var t=V(this),e=t.css("position");"absolute"!==e&&"fixed"!==e&&(i-=t.outerHeight(!0))}),this.element.children().not(this.panels).each(function(){i-=V(this).outerHeight(!0)}),this.panels.each(function(){V(this).height(Math.max(0,i-V(this).innerHeight()+V(this).height()))}).css("overflow","auto")):"auto"===t&&(i=0,this.panels.each(function(){i=Math.max(i,V(this).height("").height())}).height(i))},_eventHandler:function(t){var e=this.options,i=this.active,s=V(t.currentTarget).closest("li"),n=s[0]===i[0],o=n&&e.collapsible,a=o?V():this._getPanelForTab(s),r=i.length?this._getPanelForTab(i):V(),i={oldTab:i,oldPanel:r,newTab:o?V():s,newPanel:a};t.preventDefault(),s.hasClass("ui-state-disabled")||s.hasClass("ui-tabs-loading")||this.running||n&&!e.collapsible||!1===this._trigger("beforeActivate",t,i)||(e.active=!o&&this.tabs.index(s),this.active=n?V():s,this.xhr&&this.xhr.abort(),r.length||a.length||V.error("jQuery UI Tabs: Mismatching fragment identifier."),a.length&&this.load(this.tabs.index(s),t),this._toggle(t,i))},_toggle:function(t,e){var i=this,s=e.newPanel,n=e.oldPanel;function o(){i.running=!1,i._trigger("activate",t,e)}function a(){i._addClass(e.newTab.closest("li"),"ui-tabs-active","ui-state-active"),s.length&&i.options.show?i._show(s,i.options.show,o):(s.show(),o())}this.running=!0,n.length&&this.options.hide?this._hide(n,this.options.hide,function(){i._removeClass(e.oldTab.closest("li"),"ui-tabs-active","ui-state-active"),a()}):(this._removeClass(e.oldTab.closest("li"),"ui-tabs-active","ui-state-active"),n.hide(),a()),n.attr("aria-hidden","true"),e.oldTab.attr({"aria-selected":"false","aria-expanded":"false"}),s.length&&n.length?e.oldTab.attr("tabIndex",-1):s.length&&this.tabs.filter(function(){return 0===V(this).attr("tabIndex")}).attr("tabIndex",-1),s.attr("aria-hidden","false"),e.newTab.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0})},_activate:function(t){var t=this._findActive(t);t[0]!==this.active[0]&&(t=(t=!t.length?this.active:t).find(".ui-tabs-anchor")[0],this._eventHandler({target:t,currentTarget:t,preventDefault:V.noop}))},_findActive:function(t){return!1===t?V():this.tabs.eq(t)},_getIndex:function(t){return t="string"==typeof t?this.anchors.index(this.anchors.filter("[href$='"+V.escapeSelector(t)+"']")):t},_destroy:function(){this.xhr&&this.xhr.abort(),this.tablist.removeAttr("role").off(this.eventNamespace),this.anchors.removeAttr("role tabIndex").removeUniqueId(),this.tabs.add(this.panels).each(function(){V.data(this,"ui-tabs-destroy")?V(this).remove():V(this).removeAttr("role tabIndex aria-live aria-busy aria-selected aria-labelledby aria-hidden aria-expanded")}),this.tabs.each(function(){var t=V(this),e=t.data("ui-tabs-aria-controls");e?t.attr("aria-controls",e).removeData("ui-tabs-aria-controls"):t.removeAttr("aria-controls")}),this.panels.show(),"content"!==this.options.heightStyle&&this.panels.css("height","")},enable:function(i){var t=this.options.disabled;!1!==t&&(t=void 0!==i&&(i=this._getIndex(i),Array.isArray(t)?V.map(t,function(t){return t!==i?t:null}):V.map(this.tabs,function(t,e){return e!==i?e:null})),this._setOptionDisabled(t))},disable:function(t){var e=this.options.disabled;if(!0!==e){if(void 0===t)e=!0;else{if(t=this._getIndex(t),-1!==V.inArray(t,e))return;e=Array.isArray(e)?V.merge([t],e).sort():[t]}this._setOptionDisabled(e)}},load:function(t,s){t=this._getIndex(t);function n(t,e){"abort"===e&&o.panels.stop(!1,!0),o._removeClass(i,"ui-tabs-loading"),a.removeAttr("aria-busy"),t===o.xhr&&delete o.xhr}var o=this,i=this.tabs.eq(t),t=i.find(".ui-tabs-anchor"),a=this._getPanelForTab(i),r={tab:i,panel:a};this._isLocal(t[0])||(this.xhr=V.ajax(this._ajaxSettings(t,s,r)),this.xhr&&"canceled"!==this.xhr.statusText&&(this._addClass(i,"ui-tabs-loading"),a.attr("aria-busy","true"),this.xhr.done(function(t,e,i){setTimeout(function(){a.html(t),o._trigger("load",s,r),n(i,e)},1)}).fail(function(t,e){setTimeout(function(){n(t,e)},1)})))},_ajaxSettings:function(t,i,s){var n=this;return{url:t.attr("href").replace(/#.*$/,""),beforeSend:function(t,e){return n._trigger("beforeLoad",i,V.extend({jqXHR:t,ajaxSettings:e},s))}}},_getPanelForTab:function(t){t=V(t).attr("aria-controls");return this.element.find(this._sanitizeSelector("#"+t))}}),!1!==V.uiBackCompat&&V.widget("ui.tabs",V.ui.tabs,{_processTabs:function(){this._superApply(arguments),this._addClass(this.tabs,"ui-tab")}});V.ui.tabs;V.widget("ui.tooltip",{version:"1.13.2",options:{classes:{"ui-tooltip":"ui-corner-all ui-widget-shadow"},content:function(){var t=V(this).attr("title");return V("<a>").text(t).html()},hide:!0,items:"[title]:not([disabled])",position:{my:"left top+15",at:"left bottom",collision:"flipfit flip"},show:!0,track:!1,close:null,open:null},_addDescribedBy:function(t,e){var i=(t.attr("aria-describedby")||"").split(/\s+/);i.push(e),t.data("ui-tooltip-id",e).attr("aria-describedby",String.prototype.trim.call(i.join(" ")))},_removeDescribedBy:function(t){var e=t.data("ui-tooltip-id"),i=(t.attr("aria-describedby")||"").split(/\s+/),e=V.inArray(e,i);-1!==e&&i.splice(e,1),t.removeData("ui-tooltip-id"),(i=String.prototype.trim.call(i.join(" ")))?t.attr("aria-describedby",i):t.removeAttr("aria-describedby")},_create:function(){this._on({mouseover:"open",focusin:"open"}),this.tooltips={},this.parents={},this.liveRegion=V("<div>").attr({role:"log","aria-live":"assertive","aria-relevant":"additions"}).appendTo(this.document[0].body),this._addClass(this.liveRegion,null,"ui-helper-hidden-accessible"),this.disabledTitles=V([])},_setOption:function(t,e){var i=this;this._super(t,e),"content"===t&&V.each(this.tooltips,function(t,e){i._updateContent(e.element)})},_setOptionDisabled:function(t){this[t?"_disable":"_enable"]()},_disable:function(){var s=this;V.each(this.tooltips,function(t,e){var i=V.Event("blur");i.target=i.currentTarget=e.element[0],s.close(i,!0)}),this.disabledTitles=this.disabledTitles.add(this.element.find(this.options.items).addBack().filter(function(){var t=V(this);if(t.is("[title]"))return t.data("ui-tooltip-title",t.attr("title")).removeAttr("title")}))},_enable:function(){this.disabledTitles.each(function(){var t=V(this);t.data("ui-tooltip-title")&&t.attr("title",t.data("ui-tooltip-title"))}),this.disabledTitles=V([])},open:function(t){var i=this,e=V(t?t.target:this.element).closest(this.options.items);e.length&&!e.data("ui-tooltip-id")&&(e.attr("title")&&e.data("ui-tooltip-title",e.attr("title")),e.data("ui-tooltip-open",!0),t&&"mouseover"===t.type&&e.parents().each(function(){var t,e=V(this);e.data("ui-tooltip-open")&&((t=V.Event("blur")).target=t.currentTarget=this,i.close(t,!0)),e.attr("title")&&(e.uniqueId(),i.parents[this.id]={element:this,title:e.attr("title")},e.attr("title",""))}),this._registerCloseHandlers(t,e),this._updateContent(e,t))},_updateContent:function(e,i){var t=this.options.content,s=this,n=i?i.type:null;if("string"==typeof t||t.nodeType||t.jquery)return this._open(i,e,t);(t=t.call(e[0],function(t){s._delay(function(){e.data("ui-tooltip-open")&&(i&&(i.type=n),this._open(i,e,t))})}))&&this._open(i,e,t)},_open:function(t,e,i){var s,n,o,a=V.extend({},this.options.position);function r(t){a.of=t,n.is(":hidden")||n.position(a)}i&&((s=this._find(e))?s.tooltip.find(".ui-tooltip-content").html(i):(e.is("[title]")&&(t&&"mouseover"===t.type?e.attr("title",""):e.removeAttr("title")),s=this._tooltip(e),n=s.tooltip,this._addDescribedBy(e,n.attr("id")),n.find(".ui-tooltip-content").html(i),this.liveRegion.children().hide(),(i=V("<div>").html(n.find(".ui-tooltip-content").html())).removeAttr("name").find("[name]").removeAttr("name"),i.removeAttr("id").find("[id]").removeAttr("id"),i.appendTo(this.liveRegion),this.options.track&&t&&/^mouse/.test(t.type)?(this._on(this.document,{mousemove:r}),r(t)):n.position(V.extend({of:e},this.options.position)),n.hide(),this._show(n,this.options.show),this.options.track&&this.options.show&&this.options.show.delay&&(o=this.delayedShow=setInterval(function(){n.is(":visible")&&(r(a.of),clearInterval(o))},13)),this._trigger("open",t,{tooltip:n})))},_registerCloseHandlers:function(t,e){var i={keyup:function(t){t.keyCode===V.ui.keyCode.ESCAPE&&((t=V.Event(t)).currentTarget=e[0],this.close(t,!0))}};e[0]!==this.element[0]&&(i.remove=function(){var t=this._find(e);t&&this._removeTooltip(t.tooltip)}),t&&"mouseover"!==t.type||(i.mouseleave="close"),t&&"focusin"!==t.type||(i.focusout="close"),this._on(!0,e,i)},close:function(t){var e,i=this,s=V(t?t.currentTarget:this.element),n=this._find(s);n?(e=n.tooltip,n.closing||(clearInterval(this.delayedShow),s.data("ui-tooltip-title")&&!s.attr("title")&&s.attr("title",s.data("ui-tooltip-title")),this._removeDescribedBy(s),n.hiding=!0,e.stop(!0),this._hide(e,this.options.hide,function(){i._removeTooltip(V(this))}),s.removeData("ui-tooltip-open"),this._off(s,"mouseleave focusout keyup"),s[0]!==this.element[0]&&this._off(s,"remove"),this._off(this.document,"mousemove"),t&&"mouseleave"===t.type&&V.each(this.parents,function(t,e){V(e.element).attr("title",e.title),delete i.parents[t]}),n.closing=!0,this._trigger("close",t,{tooltip:e}),n.hiding||(n.closing=!1))):s.removeData("ui-tooltip-open")},_tooltip:function(t){var e=V("<div>").attr("role","tooltip"),i=V("<div>").appendTo(e),s=e.uniqueId().attr("id");return this._addClass(i,"ui-tooltip-content"),this._addClass(e,"ui-tooltip","ui-widget ui-widget-content"),e.appendTo(this._appendTo(t)),this.tooltips[s]={element:t,tooltip:e}},_find:function(t){t=t.data("ui-tooltip-id");return t?this.tooltips[t]:null},_removeTooltip:function(t){clearInterval(this.delayedShow),t.remove(),delete this.tooltips[t.attr("id")]},_appendTo:function(t){t=t.closest(".ui-front, dialog");return t=!t.length?this.document[0].body:t},_destroy:function(){var s=this;V.each(this.tooltips,function(t,e){var i=V.Event("blur"),e=e.element;i.target=i.currentTarget=e[0],s.close(i,!0),V("#"+t).remove(),e.data("ui-tooltip-title")&&(e.attr("title")||e.attr("title",e.data("ui-tooltip-title")),e.removeData("ui-tooltip-title"))}),this.liveRegion.remove()}}),!1!==V.uiBackCompat&&V.widget("ui.tooltip",V.ui.tooltip,{options:{tooltipClass:null},_tooltip:function(){var t=this._superApply(arguments);return this.options.tooltipClass&&t.tooltip.addClass(this.options.tooltipClass),t}});V.ui.tooltip}); \ No newline at end of file diff --git a/config/js/jquery.min.js b/config/js/jquery.min.js index 8e88509e..2c69bc90 100644 --- a/config/js/jquery.min.js +++ b/config/js/jquery.min.js @@ -1,6 +1,2 @@ -/*! jQuery v1.11.3 | (c) 2005, 2015 jQuery Foundation, Inc. | jquery.org/license */ -!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.3",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)+1>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b="length"in a&&a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N=M.replace("w","w#"),O="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+N+"))|)"+L+"*\\]",P=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+O+")*)|.*)\\)|)",Q=new RegExp(L+"+","g"),R=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),S=new RegExp("^"+L+"*,"+L+"*"),T=new RegExp("^"+L+"*([>+~]|"+L+")"+L+"*"),U=new RegExp("="+L+"*([^\\]'\"]*?)"+L+"*\\]","g"),V=new RegExp(P),W=new RegExp("^"+N+"$"),X={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+O),PSEUDO:new RegExp("^"+P),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+L+"*(even|odd|(([+-]|)(\\d*)n|)"+L+"*(?:([+-]|)"+L+"*(\\d+)|))"+L+"*\\)|)","i"),bool:new RegExp("^(?:"+K+")$","i"),needsContext:new RegExp("^"+L+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+L+"*((?:-\\d)?\\d*)"+L+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,aa=/[+~]/,ba=/'|\\/g,ca=new RegExp("\\\\([\\da-f]{1,6}"+L+"?|("+L+")|.)","ig"),da=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},ea=function(){m()};try{H.apply(E=I.call(v.childNodes),v.childNodes),E[v.childNodes.length].nodeType}catch(fa){H={apply:E.length?function(a,b){G.apply(a,I.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function ga(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],k=b.nodeType,"string"!=typeof a||!a||1!==k&&9!==k&&11!==k)return d;if(!e&&p){if(11!==k&&(f=_.exec(a)))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return H.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName)return H.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=1!==k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(ba,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+ra(o[l]);w=aa.test(a)&&pa(b.parentNode)||b,x=o.join(",")}if(x)try{return H.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function ha(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ia(a){return a[u]=!0,a}function ja(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ka(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function la(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||C)-(~a.sourceIndex||C);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function na(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function oa(a){return ia(function(b){return b=+b,ia(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function pa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=ga.support={},f=ga.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=ga.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=g.documentElement,e=g.defaultView,e&&e!==e.top&&(e.addEventListener?e.addEventListener("unload",ea,!1):e.attachEvent&&e.attachEvent("onunload",ea)),p=!f(g),c.attributes=ja(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ja(function(a){return a.appendChild(g.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(g.getElementsByClassName),c.getById=ja(function(a){return o.appendChild(a).id=u,!g.getElementsByName||!g.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ca,da);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ca,da);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(g.querySelectorAll))&&(ja(function(a){o.appendChild(a).innerHTML="<a id='"+u+"'></a><select id='"+u+"-\f]' msallowcapture=''><option selected=''></option></select>",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+L+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+L+"*(?:value|"+K+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ja(function(a){var b=g.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+L+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ja(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",P)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===g||a.ownerDocument===v&&t(v,a)?-1:b===g||b.ownerDocument===v&&t(v,b)?1:k?J(k,a)-J(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,h=[a],i=[b];if(!e||!f)return a===g?-1:b===g?1:e?-1:f?1:k?J(k,a)-J(k,b):0;if(e===f)return la(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?la(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},g):n},ga.matches=function(a,b){return ga(a,null,null,b)},ga.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return ga(b,n,null,[a]).length>0},ga.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},ga.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&D.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},ga.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},ga.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=ga.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=ga.selectors={cacheLength:50,createPseudo:ia,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ca,da),a[3]=(a[3]||a[4]||a[5]||"").replace(ca,da),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||ga.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&ga.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ca,da).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+L+")"+a+"("+L+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=ga.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(Q," ")+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||ga.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ia(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=J(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ia(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?ia(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ia(function(a){return function(b){return ga(a,b).length>0}}),contains:ia(function(a){return a=a.replace(ca,da),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ia(function(a){return W.test(a||"")||ga.error("unsupported lang: "+a),a=a.replace(ca,da).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:oa(function(){return[0]}),last:oa(function(a,b){return[b-1]}),eq:oa(function(a,b,c){return[0>c?c+b:c]}),even:oa(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:oa(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:oa(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:oa(function(a,b,c){for(var d=0>c?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=ma(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=na(b);function qa(){}qa.prototype=d.filters=d.pseudos,d.setFilters=new qa,g=ga.tokenize=function(a,b){var c,e,f,g,h,i,j,k=z[a+" "];if(k)return b?0:k.slice(0);h=a,i=[],j=d.preFilter;while(h){(!c||(e=S.exec(h)))&&(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=T.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(R," ")}),h=h.slice(c.length));for(g in d.filter)!(e=X[g].exec(h))||j[g]&&!(e=j[g](e))||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?ga.error(a):z(a,i).slice(0)};function ra(a){for(var b=0,c=a.length,d="";c>b;b++)d+=a[b].value;return d}function sa(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function ta(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function ua(a,b,c){for(var d=0,e=b.length;e>d;d++)ga(a,b[d],c);return c}function va(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function wa(a,b,c,d,e,f){return d&&!d[u]&&(d=wa(d)),e&&!e[u]&&(e=wa(e,f)),ia(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||ua(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:va(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=va(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?J(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=va(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):H.apply(g,r)})}function xa(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=sa(function(a){return a===b},h,!0),l=sa(function(a){return J(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];f>i;i++)if(c=d.relative[a[i].type])m=[sa(ta(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return wa(i>1&&ta(m),i>1&&ra(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&xa(a.slice(i,e)),f>e&&xa(a=a.slice(e)),f>e&&ra(a))}m.push(c)}return ta(m)}function ya(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=F.call(i));s=va(s)}H.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&ga.uniqueSort(i)}return k&&(w=v,j=t),r};return c?ia(f):f}return h=ga.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=xa(b[c]),f[u]?d.push(f):e.push(f);f=A(a,ya(e,d)),f.selector=a}return f},i=ga.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(ca,da),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(ca,da),aa.test(j[0].type)&&pa(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&ra(j),!a)return H.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,aa.test(a)&&pa(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ja(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ja(function(a){return a.innerHTML="<a href='#'></a>","#"===a.firstChild.getAttribute("href")})||ka("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ja(function(a){return a.innerHTML="<input/>",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ka("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ja(function(a){return null==a.getAttribute("disabled")})||ka(K,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),ga}(a);m.find=s,m.expr=s.selectors,m.expr[":"]=m.expr.pseudos,m.unique=s.uniqueSort,m.text=s.getText,m.isXMLDoc=s.isXML,m.contains=s.contains;var t=m.expr.match.needsContext,u=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,v=/^.[^:#\[\.,]*$/;function w(a,b,c){if(m.isFunction(b))return m.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return m.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(v.test(b))return m.filter(b,a,c);b=m.filter(b,a)}return m.grep(a,function(a){return m.inArray(a,b)>=0!==c})}m.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?m.find.matchesSelector(d,a)?[d]:[]:m.find.matches(a,m.grep(b,function(a){return 1===a.nodeType}))},m.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(m(a).filter(function(){for(b=0;e>b;b++)if(m.contains(d[b],this))return!0}));for(b=0;e>b;b++)m.find(a,d[b],c);return c=this.pushStack(e>1?m.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(w(this,a||[],!1))},not:function(a){return this.pushStack(w(this,a||[],!0))},is:function(a){return!!w(this,"string"==typeof a&&t.test(a)?m(a):a||[],!1).length}});var x,y=a.document,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=m.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||x).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof m?b[0]:b,m.merge(this,m.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:y,!0)),u.test(c[1])&&m.isPlainObject(b))for(c in b)m.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}if(d=y.getElementById(c[2]),d&&d.parentNode){if(d.id!==c[2])return x.find(a);this.length=1,this[0]=d}return this.context=y,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):m.isFunction(a)?"undefined"!=typeof x.ready?x.ready(a):a(m):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),m.makeArray(a,this))};A.prototype=m.fn,x=m(y);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};m.extend({dir:function(a,b,c){var d=[],e=a[b];while(e&&9!==e.nodeType&&(void 0===c||1!==e.nodeType||!m(e).is(c)))1===e.nodeType&&d.push(e),e=e[b];return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),m.fn.extend({has:function(a){var b,c=m(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(m.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=t.test(a)||"string"!=typeof a?m(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&m.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?m.unique(f):f)},index:function(a){return a?"string"==typeof a?m.inArray(this[0],m(a)):m.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(m.unique(m.merge(this.get(),m(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}m.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return m.dir(a,"parentNode")},parentsUntil:function(a,b,c){return m.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return m.dir(a,"nextSibling")},prevAll:function(a){return m.dir(a,"previousSibling")},nextUntil:function(a,b,c){return m.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return m.dir(a,"previousSibling",c)},siblings:function(a){return m.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return m.sibling(a.firstChild)},contents:function(a){return m.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:m.merge([],a.childNodes)}},function(a,b){m.fn[a]=function(c,d){var e=m.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=m.filter(d,e)),this.length>1&&(C[a]||(e=m.unique(e)),B.test(a)&&(e=e.reverse())),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return m.each(a.match(E)||[],function(a,c){b[c]=!0}),b}m.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):m.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(c=a.memory&&l,d=!0,f=g||0,g=0,e=h.length,b=!0;h&&e>f;f++)if(h[f].apply(l[0],l[1])===!1&&a.stopOnFalse){c=!1;break}b=!1,h&&(i?i.length&&j(i.shift()):c?h=[]:k.disable())},k={add:function(){if(h){var d=h.length;!function f(b){m.each(b,function(b,c){var d=m.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&f(c)})}(arguments),b?e=h.length:c&&(g=d,j(c))}return this},remove:function(){return h&&m.each(arguments,function(a,c){var d;while((d=m.inArray(c,h,d))>-1)h.splice(d,1),b&&(e>=d&&e--,f>=d&&f--)}),this},has:function(a){return a?m.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],e=0,this},disable:function(){return h=i=c=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,c||k.disable(),this},locked:function(){return!i},fireWith:function(a,c){return!h||d&&!i||(c=c||[],c=[a,c.slice?c.slice():c],b?i.push(c):j(c)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},m.extend({Deferred:function(a){var b=[["resolve","done",m.Callbacks("once memory"),"resolved"],["reject","fail",m.Callbacks("once memory"),"rejected"],["notify","progress",m.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return m.Deferred(function(c){m.each(b,function(b,f){var g=m.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&m.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?m.extend(a,d):d}},e={};return d.pipe=d.then,m.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&m.isFunction(a.promise)?e:0,g=1===f?a:m.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&m.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;m.fn.ready=function(a){return m.ready.promise().done(a),this},m.extend({isReady:!1,readyWait:1,holdReady:function(a){a?m.readyWait++:m.ready(!0)},ready:function(a){if(a===!0?!--m.readyWait:!m.isReady){if(!y.body)return setTimeout(m.ready);m.isReady=!0,a!==!0&&--m.readyWait>0||(H.resolveWith(y,[m]),m.fn.triggerHandler&&(m(y).triggerHandler("ready"),m(y).off("ready")))}}});function I(){y.addEventListener?(y.removeEventListener("DOMContentLoaded",J,!1),a.removeEventListener("load",J,!1)):(y.detachEvent("onreadystatechange",J),a.detachEvent("onload",J))}function J(){(y.addEventListener||"load"===event.type||"complete"===y.readyState)&&(I(),m.ready())}m.ready.promise=function(b){if(!H)if(H=m.Deferred(),"complete"===y.readyState)setTimeout(m.ready);else if(y.addEventListener)y.addEventListener("DOMContentLoaded",J,!1),a.addEventListener("load",J,!1);else{y.attachEvent("onreadystatechange",J),a.attachEvent("onload",J);var c=!1;try{c=null==a.frameElement&&y.documentElement}catch(d){}c&&c.doScroll&&!function e(){if(!m.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}I(),m.ready()}}()}return H.promise(b)};var K="undefined",L;for(L in m(k))break;k.ownLast="0"!==L,k.inlineBlockNeedsLayout=!1,m(function(){var a,b,c,d;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",k.inlineBlockNeedsLayout=a=3===b.offsetWidth,a&&(c.style.zoom=1)),c.removeChild(d))}),function(){var a=y.createElement("div");if(null==k.deleteExpando){k.deleteExpando=!0;try{delete a.test}catch(b){k.deleteExpando=!1}}a=null}(),m.acceptData=function(a){var b=m.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};var M=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,N=/([A-Z])/g;function O(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(N,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:M.test(c)?m.parseJSON(c):c}catch(e){}m.data(a,b,c)}else c=void 0}return c}function P(a){var b;for(b in a)if(("data"!==b||!m.isEmptyObject(a[b]))&&"toJSON"!==b)return!1; - -return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h;if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?m.queue(this[0],a):void 0===b?this:this.each(function(){var c=m.queue(this,a,b);m._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&m.dequeue(this,a)})},dequeue:function(a){return this.each(function(){m.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=m.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=m._data(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var S=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=["Top","Right","Bottom","Left"],U=function(a,b){return a=b||a,"none"===m.css(a,"display")||!m.contains(a.ownerDocument,a)},V=m.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===m.type(c)){e=!0;for(h in c)m.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,m.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(m(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav></:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="<input type='radio' checked='checked' name='t'/>",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function aa(){return!0}function ba(){return!1}function ca(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=m.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof m===K||a&&m.event.triggered===a.type?void 0:m.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(E)||[""],h=b.length;while(h--)f=_.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=m.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=m.event.special[o]||{},l=m.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&m.expr.match.needsContext.test(e),namespace:p.join(".")},i),(n=g[o])||(n=g[o]=[],n.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?n.splice(n.delegateCount++,0,l):n.push(l),m.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m.hasData(a)&&m._data(a);if(r&&(k=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=_.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=m.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,n=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=n.length;while(f--)g=n[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(n.splice(f,1),g.selector&&n.delegateCount--,l.remove&&l.remove.call(a,g));i&&!n.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||m.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)m.event.remove(a,o+b[j],c,d,!0);m.isEmptyObject(k)&&(delete r.handle,m._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,o=[d||y],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||y,3!==d.nodeType&&8!==d.nodeType&&!$.test(p+m.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[m.expando]?b:new m.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:m.makeArray(c,[b]),k=m.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!m.isWindow(d)){for(i=k.delegateType||p,$.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||y)&&o.push(l.defaultView||l.parentWindow||a)}n=0;while((h=o[n++])&&!b.isPropagationStopped())b.type=n>1?i:k.bindType||p,f=(m._data(h,"events")||{})[b.type]&&m._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&m.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&m.acceptData(d)&&g&&d[p]&&!m.isWindow(d)){l=d[g],l&&(d[g]=null),m.event.triggered=p;try{d[p]()}catch(r){}m.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=m.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(m._data(this,"events")||{})[a.type]||[],k=m.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=m.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((m.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?m(c,this).index(i)>=0:m.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h<b.length&&g.push({elem:this,handlers:b.slice(h)}),g},fix:function(a){if(a[m.expando])return a;var b,c,d,e=a.type,f=a,g=this.fixHooks[e];g||(this.fixHooks[e]=g=Z.test(e)?this.mouseHooks:Y.test(e)?this.keyHooks:{}),d=g.props?this.props.concat(g.props):this.props,a=new m.Event(f),b=d.length;while(b--)c=d[b],a[c]=f[c];return a.target||(a.target=f.srcElement||y),3===a.target.nodeType&&(a.target=a.target.parentNode),a.metaKey=!!a.metaKey,g.filter?g.filter(a,f):a},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return null==a.which&&(a.which=null!=b.charCode?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,b){var c,d,e,f=b.button,g=b.fromElement;return null==a.pageX&&null!=b.clientX&&(d=a.target.ownerDocument||y,e=d.documentElement,c=d.body,a.pageX=b.clientX+(e&&e.scrollLeft||c&&c.scrollLeft||0)-(e&&e.clientLeft||c&&c.clientLeft||0),a.pageY=b.clientY+(e&&e.scrollTop||c&&c.scrollTop||0)-(e&&e.clientTop||c&&c.clientTop||0)),!a.relatedTarget&&g&&(a.relatedTarget=g===a.target?b.toElement:g),a.which||void 0===f||(a.which=1&f?1:2&f?3:4&f?2:0),a}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==ca()&&this.focus)try{return this.focus(),!1}catch(a){}},delegateType:"focusin"},blur:{trigger:function(){return this===ca()&&this.blur?(this.blur(),!1):void 0},delegateType:"focusout"},click:{trigger:function(){return m.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):void 0},_default:function(a){return m.nodeName(a.target,"a")}},beforeunload:{postDispatch:function(a){void 0!==a.result&&a.originalEvent&&(a.originalEvent.returnValue=a.result)}}},simulate:function(a,b,c,d){var e=m.extend(new m.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?m.event.trigger(e,null,b):m.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},m.removeEvent=y.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){var d="on"+b;a.detachEvent&&(typeof a[d]===K&&(a[d]=null),a.detachEvent(d,c))},m.Event=function(a,b){return this instanceof m.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||void 0===a.defaultPrevented&&a.returnValue===!1?aa:ba):this.type=a,b&&m.extend(this,b),this.timeStamp=a&&a.timeStamp||m.now(),void(this[m.expando]=!0)):new m.Event(a,b)},m.Event.prototype={isDefaultPrevented:ba,isPropagationStopped:ba,isImmediatePropagationStopped:ba,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=aa,a&&(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=aa,a&&(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){var a=this.originalEvent;this.isImmediatePropagationStopped=aa,a&&a.stopImmediatePropagation&&a.stopImmediatePropagation(),this.stopPropagation()}},m.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(a,b){m.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return(!e||e!==d&&!m.contains(d,e))&&(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),k.submitBubbles||(m.event.special.submit={setup:function(){return m.nodeName(this,"form")?!1:void m.event.add(this,"click._submit keypress._submit",function(a){var b=a.target,c=m.nodeName(b,"input")||m.nodeName(b,"button")?b.form:void 0;c&&!m._data(c,"submitBubbles")&&(m.event.add(c,"submit._submit",function(a){a._submit_bubble=!0}),m._data(c,"submitBubbles",!0))})},postDispatch:function(a){a._submit_bubble&&(delete a._submit_bubble,this.parentNode&&!a.isTrigger&&m.event.simulate("submit",this.parentNode,a,!0))},teardown:function(){return m.nodeName(this,"form")?!1:void m.event.remove(this,"._submit")}}),k.changeBubbles||(m.event.special.change={setup:function(){return X.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(m.event.add(this,"propertychange._change",function(a){"checked"===a.originalEvent.propertyName&&(this._just_changed=!0)}),m.event.add(this,"click._change",function(a){this._just_changed&&!a.isTrigger&&(this._just_changed=!1),m.event.simulate("change",this,a,!0)})),!1):void m.event.add(this,"beforeactivate._change",function(a){var b=a.target;X.test(b.nodeName)&&!m._data(b,"changeBubbles")&&(m.event.add(b,"change._change",function(a){!this.parentNode||a.isSimulated||a.isTrigger||m.event.simulate("change",this.parentNode,a,!0)}),m._data(b,"changeBubbles",!0))})},handle:function(a){var b=a.target;return this!==b||a.isSimulated||a.isTrigger||"radio"!==b.type&&"checkbox"!==b.type?a.handleObj.handler.apply(this,arguments):void 0},teardown:function(){return m.event.remove(this,"._change"),!X.test(this.nodeName)}}),k.focusinBubbles||m.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){m.event.simulate(b,a.target,m.event.fix(a),!0)};m.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=m._data(d,b);e||d.addEventListener(a,c,!0),m._data(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=m._data(d,b)-1;e?m._data(d,b,e):(d.removeEventListener(a,c,!0),m._removeData(d,b))}}}),m.fn.extend({on:function(a,b,c,d,e){var f,g;if("object"==typeof a){"string"!=typeof b&&(c=c||b,b=void 0);for(f in a)this.on(f,b,c,a[f],e);return this}if(null==c&&null==d?(d=b,c=b=void 0):null==d&&("string"==typeof b?(d=c,c=void 0):(d=c,c=b,b=void 0)),d===!1)d=ba;else if(!d)return this;return 1===e&&(g=d,d=function(a){return m().off(a),g.apply(this,arguments)},d.guid=g.guid||(g.guid=m.guid++)),this.each(function(){m.event.add(this,a,d,c,b)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,b,c){var d,e;if(a&&a.preventDefault&&a.handleObj)return d=a.handleObj,m(a.delegateTarget).off(d.namespace?d.origType+"."+d.namespace:d.origType,d.selector,d.handler),this;if("object"==typeof a){for(e in a)this.off(e,b,a[e]);return this}return(b===!1||"function"==typeof b)&&(c=b,b=void 0),c===!1&&(c=ba),this.each(function(){m.event.remove(this,a,c,b)})},trigger:function(a,b){return this.each(function(){m.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];return c?m.event.trigger(a,b,c,!0):void 0}});function da(a){var b=ea.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}var ea="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",fa=/ jQuery\d+="(?:null|\d+)"/g,ga=new RegExp("<(?:"+ea+")[\\s/>]","i"),ha=/^\s+/,ia=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,ja=/<([\w:]+)/,ka=/<tbody/i,la=/<|&#?\w+;/,ma=/<(?:script|style|link)/i,na=/checked\s*(?:[^=]|=\s*.checked.)/i,oa=/^$|\/(?:java|ecma)script/i,pa=/^true\/(.*)/,qa=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ra={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:k.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},sa=da(y),ta=sa.appendChild(y.createElement("div"));ra.optgroup=ra.option,ra.tbody=ra.tfoot=ra.colgroup=ra.caption=ra.thead,ra.th=ra.td;function ua(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==K?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==K?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||m.nodeName(d,b)?f.push(d):m.merge(f,ua(d,b));return void 0===b||b&&m.nodeName(a,b)?m.merge([a],f):f}function va(a){W.test(a.type)&&(a.defaultChecked=a.checked)}function wa(a,b){return m.nodeName(a,"table")&&m.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function xa(a){return a.type=(null!==m.find.attr(a,"type"))+"/"+a.type,a}function ya(a){var b=pa.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function za(a,b){for(var c,d=0;null!=(c=a[d]);d++)m._data(c,"globalEval",!b||m._data(b[d],"globalEval"))}function Aa(a,b){if(1===b.nodeType&&m.hasData(a)){var c,d,e,f=m._data(a),g=m._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)m.event.add(b,c,h[c][d])}g.data&&(g.data=m.extend({},g.data))}}function Ba(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!k.noCloneEvent&&b[m.expando]){e=m._data(b);for(d in e.events)m.removeEvent(b,d,e.handle);b.removeAttribute(m.expando)}"script"===c&&b.text!==a.text?(xa(b).text=a.text,ya(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),k.html5Clone&&a.innerHTML&&!m.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&W.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}m.extend({clone:function(a,b,c){var d,e,f,g,h,i=m.contains(a.ownerDocument,a);if(k.html5Clone||m.isXMLDoc(a)||!ga.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(ta.innerHTML=a.outerHTML,ta.removeChild(f=ta.firstChild)),!(k.noCloneEvent&&k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||m.isXMLDoc(a)))for(d=ua(f),h=ua(a),g=0;null!=(e=h[g]);++g)d[g]&&Ba(e,d[g]);if(b)if(c)for(h=h||ua(a),d=d||ua(f),g=0;null!=(e=h[g]);g++)Aa(e,d[g]);else Aa(a,f);return d=ua(f,"script"),d.length>0&&za(d,!i&&ua(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,l,n=a.length,o=da(b),p=[],q=0;n>q;q++)if(f=a[q],f||0===f)if("object"===m.type(f))m.merge(p,f.nodeType?[f]:f);else if(la.test(f)){h=h||o.appendChild(b.createElement("div")),i=(ja.exec(f)||["",""])[1].toLowerCase(),l=ra[i]||ra._default,h.innerHTML=l[1]+f.replace(ia,"<$1></$2>")+l[2],e=l[0];while(e--)h=h.lastChild;if(!k.leadingWhitespace&&ha.test(f)&&p.push(b.createTextNode(ha.exec(f)[0])),!k.tbody){f="table"!==i||ka.test(f)?"<table>"!==l[1]||ka.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;while(e--)m.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j)}m.merge(p,h.childNodes),h.textContent="";while(h.firstChild)h.removeChild(h.firstChild);h=o.lastChild}else p.push(b.createTextNode(f));h&&o.removeChild(h),k.appendChecked||m.grep(ua(p,"input"),va),q=0;while(f=p[q++])if((!d||-1===m.inArray(f,d))&&(g=m.contains(f.ownerDocument,f),h=ua(o.appendChild(f),"script"),g&&za(h),c)){e=0;while(f=h[e++])oa.test(f.type||"")&&c.push(f)}return h=null,o},cleanData:function(a,b){for(var d,e,f,g,h=0,i=m.expando,j=m.cache,l=k.deleteExpando,n=m.event.special;null!=(d=a[h]);h++)if((b||m.acceptData(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)n[e]?m.event.remove(d,e):m.removeEvent(d,e,g.handle);j[f]&&(delete j[f],l?delete d[i]:typeof d.removeAttribute!==K?d.removeAttribute(i):d[i]=null,c.push(f))}}}),m.fn.extend({text:function(a){return V(this,function(a){return void 0===a?m.text(this):this.empty().append((this[0]&&this[0].ownerDocument||y).createTextNode(a))},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wa(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wa(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?m.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||m.cleanData(ua(c)),c.parentNode&&(b&&m.contains(c.ownerDocument,c)&&za(ua(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&m.cleanData(ua(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&m.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return m.clone(this,a,b)})},html:function(a){return V(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(fa,""):void 0;if(!("string"!=typeof a||ma.test(a)||!k.htmlSerialize&&ga.test(a)||!k.leadingWhitespace&&ha.test(a)||ra[(ja.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(ia,"<$1></$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(m.cleanData(ua(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,m.cleanData(ua(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,n=this,o=l-1,p=a[0],q=m.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&na.test(p))return this.each(function(c){var d=n.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(i=m.buildFragment(a,this[0].ownerDocument,!1,this),c=i.firstChild,1===i.childNodes.length&&(i=c),c)){for(g=m.map(ua(i,"script"),xa),f=g.length;l>j;j++)d=i,j!==o&&(d=m.clone(d,!0,!0),f&&m.merge(g,ua(d,"script"))),b.call(this[j],d,j);if(f)for(h=g[g.length-1].ownerDocument,m.map(g,ya),j=0;f>j;j++)d=g[j],oa.test(d.type||"")&&!m._data(d,"globalEval")&&m.contains(h,d)&&(d.src?m._evalUrl&&m._evalUrl(d.src):m.globalEval((d.text||d.textContent||d.innerHTML||"").replace(qa,"")));i=c=null}return this}}),m.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){m.fn[a]=function(a){for(var c,d=0,e=[],g=m(a),h=g.length-1;h>=d;d++)c=d===h?this:this.clone(!0),m(g[d])[b](c),f.apply(e,c.get());return this.pushStack(e)}});var Ca,Da={};function Ea(b,c){var d,e=m(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:m.css(e[0],"display");return e.detach(),f}function Fa(a){var b=y,c=Da[a];return c||(c=Ea(a,b),"none"!==c&&c||(Ca=(Ca||m("<iframe frameborder='0' width='0' height='0'/>")).appendTo(b.documentElement),b=(Ca[0].contentWindow||Ca[0].contentDocument).document,b.write(),b.close(),c=Ea(a,b),Ca.detach()),Da[a]=c),c}!function(){var a;k.shrinkWrapBlocks=function(){if(null!=a)return a;a=!1;var b,c,d;return c=y.getElementsByTagName("body")[0],c&&c.style?(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:1px;width:1px;zoom:1",b.appendChild(y.createElement("div")).style.width="5px",a=3!==b.offsetWidth),c.removeChild(d),a):void 0}}();var Ga=/^margin/,Ha=new RegExp("^("+S+")(?!px)[a-z%]+$","i"),Ia,Ja,Ka=/^(top|right|bottom|left)$/;a.getComputedStyle?(Ia=function(b){return b.ownerDocument.defaultView.opener?b.ownerDocument.defaultView.getComputedStyle(b,null):a.getComputedStyle(b,null)},Ja=function(a,b,c){var d,e,f,g,h=a.style;return c=c||Ia(a),g=c?c.getPropertyValue(b)||c[b]:void 0,c&&(""!==g||m.contains(a.ownerDocument,a)||(g=m.style(a,b)),Ha.test(g)&&Ga.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0===g?g:g+""}):y.documentElement.currentStyle&&(Ia=function(a){return a.currentStyle},Ja=function(a,b,c){var d,e,f,g,h=a.style;return c=c||Ia(a),g=c?c[b]:void 0,null==g&&h&&h[b]&&(g=h[b]),Ha.test(g)&&!Ka.test(b)&&(d=h.left,e=a.runtimeStyle,f=e&&e.left,f&&(e.left=a.currentStyle.left),h.left="fontSize"===b?"1em":g,g=h.pixelLeft+"px",h.left=d,f&&(e.left=f)),void 0===g?g:g+""||"auto"});function La(a,b){return{get:function(){var c=a();if(null!=c)return c?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d,e,f,g,h;if(b=y.createElement("div"),b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",d=b.getElementsByTagName("a")[0],c=d&&d.style){c.cssText="float:left;opacity:.5",k.opacity="0.5"===c.opacity,k.cssFloat=!!c.cssFloat,b.style.backgroundClip="content-box",b.cloneNode(!0).style.backgroundClip="",k.clearCloneStyle="content-box"===b.style.backgroundClip,k.boxSizing=""===c.boxSizing||""===c.MozBoxSizing||""===c.WebkitBoxSizing,m.extend(k,{reliableHiddenOffsets:function(){return null==g&&i(),g},boxSizingReliable:function(){return null==f&&i(),f},pixelPosition:function(){return null==e&&i(),e},reliableMarginRight:function(){return null==h&&i(),h}});function i(){var b,c,d,i;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),b.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute",e=f=!1,h=!0,a.getComputedStyle&&(e="1%"!==(a.getComputedStyle(b,null)||{}).top,f="4px"===(a.getComputedStyle(b,null)||{width:"4px"}).width,i=b.appendChild(y.createElement("div")),i.style.cssText=b.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",i.style.marginRight=i.style.width="0",b.style.width="1px",h=!parseFloat((a.getComputedStyle(i,null)||{}).marginRight),b.removeChild(i)),b.innerHTML="<table><tr><td></td><td>t</td></tr></table>",i=b.getElementsByTagName("td"),i[0].style.cssText="margin:0;border:0;padding:0;display:none",g=0===i[0].offsetHeight,g&&(i[0].style.display="",i[1].style.display="none",g=0===i[0].offsetHeight),c.removeChild(d))}}}(),m.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var Ma=/alpha\([^)]*\)/i,Na=/opacity\s*=\s*([^)]*)/,Oa=/^(none|table(?!-c[ea]).+)/,Pa=new RegExp("^("+S+")(.*)$","i"),Qa=new RegExp("^([+-])=("+S+")","i"),Ra={position:"absolute",visibility:"hidden",display:"block"},Sa={letterSpacing:"0",fontWeight:"400"},Ta=["Webkit","O","Moz","ms"];function Ua(a,b){if(b in a)return b;var c=b.charAt(0).toUpperCase()+b.slice(1),d=b,e=Ta.length;while(e--)if(b=Ta[e]+c,b in a)return b;return d}function Va(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=m._data(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&U(d)&&(f[g]=m._data(d,"olddisplay",Fa(d.nodeName)))):(e=U(d),(c&&"none"!==c||!e)&&m._data(d,"olddisplay",e?c:m.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}function Wa(a,b,c){var d=Pa.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Xa(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=m.css(a,c+T[f],!0,e)),d?("content"===c&&(g-=m.css(a,"padding"+T[f],!0,e)),"margin"!==c&&(g-=m.css(a,"border"+T[f]+"Width",!0,e))):(g+=m.css(a,"padding"+T[f],!0,e),"padding"!==c&&(g+=m.css(a,"border"+T[f]+"Width",!0,e)));return g}function Ya(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=Ia(a),g=k.boxSizing&&"border-box"===m.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=Ja(a,b,f),(0>e||null==e)&&(e=a.style[b]),Ha.test(e))return e;d=g&&(k.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Xa(a,b,c||(g?"border":"content"),d,f)+"px"}m.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=Ja(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":k.cssFloat?"cssFloat":"styleFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=m.camelCase(b),i=a.style;if(b=m.cssProps[h]||(m.cssProps[h]=Ua(i,h)),g=m.cssHooks[b]||m.cssHooks[h],void 0===c)return g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b];if(f=typeof c,"string"===f&&(e=Qa.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(m.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||m.cssNumber[h]||(c+="px"),k.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),!(g&&"set"in g&&void 0===(c=g.set(a,c,d)))))try{i[b]=c}catch(j){}}},css:function(a,b,c,d){var e,f,g,h=m.camelCase(b);return b=m.cssProps[h]||(m.cssProps[h]=Ua(a.style,h)),g=m.cssHooks[b]||m.cssHooks[h],g&&"get"in g&&(f=g.get(a,!0,c)),void 0===f&&(f=Ja(a,b,d)),"normal"===f&&b in Sa&&(f=Sa[b]),""===c||c?(e=parseFloat(f),c===!0||m.isNumeric(e)?e||0:f):f}}),m.each(["height","width"],function(a,b){m.cssHooks[b]={get:function(a,c,d){return c?Oa.test(m.css(a,"display"))&&0===a.offsetWidth?m.swap(a,Ra,function(){return Ya(a,b,d)}):Ya(a,b,d):void 0},set:function(a,c,d){var e=d&&Ia(a);return Wa(a,c,d?Xa(a,b,d,k.boxSizing&&"border-box"===m.css(a,"boxSizing",!1,e),e):0)}}}),k.opacity||(m.cssHooks.opacity={get:function(a,b){return Na.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=m.isNumeric(b)?"alpha(opacity="+100*b+")":"",f=d&&d.filter||c.filter||"";c.zoom=1,(b>=1||""===b)&&""===m.trim(f.replace(Ma,""))&&c.removeAttribute&&(c.removeAttribute("filter"),""===b||d&&!d.filter)||(c.filter=Ma.test(f)?f.replace(Ma,e):f+" "+e)}}),m.cssHooks.marginRight=La(k.reliableMarginRight,function(a,b){return b?m.swap(a,{display:"inline-block"},Ja,[a,"marginRight"]):void 0}),m.each({margin:"",padding:"",border:"Width"},function(a,b){m.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+T[d]+b]=f[d]||f[d-2]||f[0];return e}},Ga.test(a)||(m.cssHooks[a+b].set=Wa)}),m.fn.extend({css:function(a,b){return V(this,function(a,b,c){var d,e,f={},g=0;if(m.isArray(b)){for(d=Ia(a),e=b.length;e>g;g++)f[b[g]]=m.css(a,b[g],!1,d);return f}return void 0!==c?m.style(a,b,c):m.css(a,b)},a,b,arguments.length>1)},show:function(){return Va(this,!0)},hide:function(){return Va(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){U(this)?m(this).show():m(this).hide()})}});function Za(a,b,c,d,e){ -return new Za.prototype.init(a,b,c,d,e)}m.Tween=Za,Za.prototype={constructor:Za,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(m.cssNumber[c]?"":"px")},cur:function(){var a=Za.propHooks[this.prop];return a&&a.get?a.get(this):Za.propHooks._default.get(this)},run:function(a){var b,c=Za.propHooks[this.prop];return this.options.duration?this.pos=b=m.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):this.pos=b=a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Za.propHooks._default.set(this),this}},Za.prototype.init.prototype=Za.prototype,Za.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=m.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){m.fx.step[a.prop]?m.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[m.cssProps[a.prop]]||m.cssHooks[a.prop])?m.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Za.propHooks.scrollTop=Za.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},m.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},m.fx=Za.prototype.init,m.fx.step={};var $a,_a,ab=/^(?:toggle|show|hide)$/,bb=new RegExp("^(?:([+-])=|)("+S+")([a-z%]*)$","i"),cb=/queueHooks$/,db=[ib],eb={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=bb.exec(b),f=e&&e[3]||(m.cssNumber[a]?"":"px"),g=(m.cssNumber[a]||"px"!==f&&+d)&&bb.exec(m.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,m.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function fb(){return setTimeout(function(){$a=void 0}),$a=m.now()}function gb(a,b){var c,d={height:a},e=0;for(b=b?1:0;4>e;e+=2-b)c=T[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function hb(a,b,c){for(var d,e=(eb[b]||[]).concat(eb["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function ib(a,b,c){var d,e,f,g,h,i,j,l,n=this,o={},p=a.style,q=a.nodeType&&U(a),r=m._data(a,"fxshow");c.queue||(h=m._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,n.always(function(){n.always(function(){h.unqueued--,m.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[p.overflow,p.overflowX,p.overflowY],j=m.css(a,"display"),l="none"===j?m._data(a,"olddisplay")||Fa(a.nodeName):j,"inline"===l&&"none"===m.css(a,"float")&&(k.inlineBlockNeedsLayout&&"inline"!==Fa(a.nodeName)?p.zoom=1:p.display="inline-block")),c.overflow&&(p.overflow="hidden",k.shrinkWrapBlocks()||n.always(function(){p.overflow=c.overflow[0],p.overflowX=c.overflow[1],p.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],ab.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(q?"hide":"show")){if("show"!==e||!r||void 0===r[d])continue;q=!0}o[d]=r&&r[d]||m.style(a,d)}else j=void 0;if(m.isEmptyObject(o))"inline"===("none"===j?Fa(a.nodeName):j)&&(p.display=j);else{r?"hidden"in r&&(q=r.hidden):r=m._data(a,"fxshow",{}),f&&(r.hidden=!q),q?m(a).show():n.done(function(){m(a).hide()}),n.done(function(){var b;m._removeData(a,"fxshow");for(b in o)m.style(a,b,o[b])});for(d in o)g=hb(q?r[d]:0,d,n),d in r||(r[d]=g.start,q&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function jb(a,b){var c,d,e,f,g;for(c in a)if(d=m.camelCase(c),e=b[d],f=a[c],m.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=m.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function kb(a,b,c){var d,e,f=0,g=db.length,h=m.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=$a||fb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:m.extend({},b),opts:m.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:$a||fb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=m.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(jb(k,j.opts.specialEasing);g>f;f++)if(d=db[f].call(j,a,k,j.opts))return d;return m.map(k,hb,j),m.isFunction(j.opts.start)&&j.opts.start.call(a,j),m.fx.timer(m.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}m.Animation=m.extend(kb,{tweener:function(a,b){m.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],eb[c]=eb[c]||[],eb[c].unshift(b)},prefilter:function(a,b){b?db.unshift(a):db.push(a)}}),m.speed=function(a,b,c){var d=a&&"object"==typeof a?m.extend({},a):{complete:c||!c&&b||m.isFunction(a)&&a,duration:a,easing:c&&b||b&&!m.isFunction(b)&&b};return d.duration=m.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in m.fx.speeds?m.fx.speeds[d.duration]:m.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){m.isFunction(d.old)&&d.old.call(this),d.queue&&m.dequeue(this,d.queue)},d},m.fn.extend({fadeTo:function(a,b,c,d){return this.filter(U).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=m.isEmptyObject(a),f=m.speed(b,c,d),g=function(){var b=kb(this,m.extend({},a),f);(e||m._data(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=m.timers,g=m._data(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&cb.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&m.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=m._data(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=m.timers,g=d?d.length:0;for(c.finish=!0,m.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),m.each(["toggle","show","hide"],function(a,b){var c=m.fn[b];m.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(gb(b,!0),a,d,e)}}),m.each({slideDown:gb("show"),slideUp:gb("hide"),slideToggle:gb("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){m.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),m.timers=[],m.fx.tick=function(){var a,b=m.timers,c=0;for($a=m.now();c<b.length;c++)a=b[c],a()||b[c]!==a||b.splice(c--,1);b.length||m.fx.stop(),$a=void 0},m.fx.timer=function(a){m.timers.push(a),a()?m.fx.start():m.timers.pop()},m.fx.interval=13,m.fx.start=function(){_a||(_a=setInterval(m.fx.tick,m.fx.interval))},m.fx.stop=function(){clearInterval(_a),_a=null},m.fx.speeds={slow:600,fast:200,_default:400},m.fn.delay=function(a,b){return a=m.fx?m.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},function(){var a,b,c,d,e;b=y.createElement("div"),b.setAttribute("className","t"),b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",d=b.getElementsByTagName("a")[0],c=y.createElement("select"),e=c.appendChild(y.createElement("option")),a=b.getElementsByTagName("input")[0],d.style.cssText="top:1px",k.getSetAttribute="t"!==b.className,k.style=/top/.test(d.getAttribute("style")),k.hrefNormalized="/a"===d.getAttribute("href"),k.checkOn=!!a.value,k.optSelected=e.selected,k.enctype=!!y.createElement("form").enctype,c.disabled=!0,k.optDisabled=!e.disabled,a=y.createElement("input"),a.setAttribute("value",""),k.input=""===a.getAttribute("value"),a.value="t",a.setAttribute("type","radio"),k.radioValue="t"===a.value}();var lb=/\r/g;m.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=m.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,m(this).val()):a,null==e?e="":"number"==typeof e?e+="":m.isArray(e)&&(e=m.map(e,function(a){return null==a?"":a+""})),b=m.valHooks[this.type]||m.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=m.valHooks[e.type]||m.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(lb,""):null==c?"":c)}}}),m.extend({valHooks:{option:{get:function(a){var b=m.find.attr(a,"value");return null!=b?b:m.trim(m.text(a))}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(k.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&m.nodeName(c.parentNode,"optgroup"))){if(b=m(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=m.makeArray(b),g=e.length;while(g--)if(d=e[g],m.inArray(m.valHooks.option.get(d),f)>=0)try{d.selected=c=!0}catch(h){d.scrollHeight}else d.selected=!1;return c||(a.selectedIndex=-1),e}}}}),m.each(["radio","checkbox"],function(){m.valHooks[this]={set:function(a,b){return m.isArray(b)?a.checked=m.inArray(m(a).val(),b)>=0:void 0}},k.checkOn||(m.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var mb,nb,ob=m.expr.attrHandle,pb=/^(?:checked|selected)$/i,qb=k.getSetAttribute,rb=k.input;m.fn.extend({attr:function(a,b){return V(this,m.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){m.removeAttr(this,a)})}}),m.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===K?m.prop(a,b,c):(1===f&&m.isXMLDoc(a)||(b=b.toLowerCase(),d=m.attrHooks[b]||(m.expr.match.bool.test(b)?nb:mb)),void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=m.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void m.removeAttr(a,b))},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=m.propFix[c]||c,m.expr.match.bool.test(c)?rb&&qb||!pb.test(c)?a[d]=!1:a[m.camelCase("default-"+c)]=a[d]=!1:m.attr(a,c,""),a.removeAttribute(qb?c:d)},attrHooks:{type:{set:function(a,b){if(!k.radioValue&&"radio"===b&&m.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),nb={set:function(a,b,c){return b===!1?m.removeAttr(a,c):rb&&qb||!pb.test(c)?a.setAttribute(!qb&&m.propFix[c]||c,c):a[m.camelCase("default-"+c)]=a[c]=!0,c}},m.each(m.expr.match.bool.source.match(/\w+/g),function(a,b){var c=ob[b]||m.find.attr;ob[b]=rb&&qb||!pb.test(b)?function(a,b,d){var e,f;return d||(f=ob[b],ob[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,ob[b]=f),e}:function(a,b,c){return c?void 0:a[m.camelCase("default-"+b)]?b.toLowerCase():null}}),rb&&qb||(m.attrHooks.value={set:function(a,b,c){return m.nodeName(a,"input")?void(a.defaultValue=b):mb&&mb.set(a,b,c)}}),qb||(mb={set:function(a,b,c){var d=a.getAttributeNode(c);return d||a.setAttributeNode(d=a.ownerDocument.createAttribute(c)),d.value=b+="","value"===c||b===a.getAttribute(c)?b:void 0}},ob.id=ob.name=ob.coords=function(a,b,c){var d;return c?void 0:(d=a.getAttributeNode(b))&&""!==d.value?d.value:null},m.valHooks.button={get:function(a,b){var c=a.getAttributeNode(b);return c&&c.specified?c.value:void 0},set:mb.set},m.attrHooks.contenteditable={set:function(a,b,c){mb.set(a,""===b?!1:b,c)}},m.each(["width","height"],function(a,b){m.attrHooks[b]={set:function(a,c){return""===c?(a.setAttribute(b,"auto"),c):void 0}}})),k.style||(m.attrHooks.style={get:function(a){return a.style.cssText||void 0},set:function(a,b){return a.style.cssText=b+""}});var sb=/^(?:input|select|textarea|button|object)$/i,tb=/^(?:a|area)$/i;m.fn.extend({prop:function(a,b){return V(this,m.prop,a,b,arguments.length>1)},removeProp:function(a){return a=m.propFix[a]||a,this.each(function(){try{this[a]=void 0,delete this[a]}catch(b){}})}}),m.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!m.isXMLDoc(a),f&&(b=m.propFix[b]||b,e=m.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=m.find.attr(a,"tabindex");return b?parseInt(b,10):sb.test(a.nodeName)||tb.test(a.nodeName)&&a.href?0:-1}}}}),k.hrefNormalized||m.each(["href","src"],function(a,b){m.propHooks[b]={get:function(a){return a.getAttribute(b,4)}}}),k.optSelected||(m.propHooks.selected={get:function(a){var b=a.parentNode;return b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex),null}}),m.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){m.propFix[this.toLowerCase()]=this}),k.enctype||(m.propFix.enctype="encoding");var ub=/[\t\r\n\f]/g;m.fn.extend({addClass:function(a){var b,c,d,e,f,g,h=0,i=this.length,j="string"==typeof a&&a;if(m.isFunction(a))return this.each(function(b){m(this).addClass(a.call(this,b,this.className))});if(j)for(b=(a||"").match(E)||[];i>h;h++)if(c=this[h],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ub," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=m.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0,i=this.length,j=0===arguments.length||"string"==typeof a&&a;if(m.isFunction(a))return this.each(function(b){m(this).removeClass(a.call(this,b,this.className))});if(j)for(b=(a||"").match(E)||[];i>h;h++)if(c=this[h],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ub," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?m.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(m.isFunction(a)?function(c){m(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=m(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===K||"boolean"===c)&&(this.className&&m._data(this,"__className__",this.className),this.className=this.className||a===!1?"":m._data(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(ub," ").indexOf(b)>=0)return!0;return!1}}),m.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){m.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),m.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var vb=m.now(),wb=/\?/,xb=/(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;m.parseJSON=function(b){if(a.JSON&&a.JSON.parse)return a.JSON.parse(b+"");var c,d=null,e=m.trim(b+"");return e&&!m.trim(e.replace(xb,function(a,b,e,f){return c&&b&&(d=0),0===d?a:(c=e||b,d+=!f-!e,"")}))?Function("return "+e)():m.error("Invalid JSON: "+b)},m.parseXML=function(b){var c,d;if(!b||"string"!=typeof b)return null;try{a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b))}catch(e){c=void 0}return c&&c.documentElement&&!c.getElementsByTagName("parsererror").length||m.error("Invalid XML: "+b),c};var yb,zb,Ab=/#.*$/,Bb=/([?&])_=[^&]*/,Cb=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Db=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Eb=/^(?:GET|HEAD)$/,Fb=/^\/\//,Gb=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,Hb={},Ib={},Jb="*/".concat("*");try{zb=location.href}catch(Kb){zb=y.createElement("a"),zb.href="",zb=zb.href}yb=Gb.exec(zb.toLowerCase())||[];function Lb(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(m.isFunction(c))while(d=f[e++])"+"===d.charAt(0)?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function Mb(a,b,c,d){var e={},f=a===Ib;function g(h){var i;return e[h]=!0,m.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function Nb(a,b){var c,d,e=m.ajaxSettings.flatOptions||{};for(d in b)void 0!==b[d]&&((e[d]?a:c||(c={}))[d]=b[d]);return c&&m.extend(!0,a,c),a}function Ob(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===e&&(e=a.mimeType||b.getResponseHeader("Content-Type"));if(e)for(g in h)if(h[g]&&h[g].test(e)){i.unshift(g);break}if(i[0]in c)f=i[0];else{for(g in c){if(!i[0]||a.converters[g+" "+i[0]]){f=g;break}d||(d=g)}f=f||d}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function Pb(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}m.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:zb,type:"GET",isLocal:Db.test(yb[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Jb,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":m.parseJSON,"text xml":m.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?Nb(Nb(a,m.ajaxSettings),b):Nb(m.ajaxSettings,a)},ajaxPrefilter:Lb(Hb),ajaxTransport:Lb(Ib),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=m.ajaxSetup({},b),l=k.context||k,n=k.context&&(l.nodeType||l.jquery)?m(l):m.event,o=m.Deferred(),p=m.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!j){j={};while(b=Cb.exec(f))j[b[1].toLowerCase()]=b[2]}b=j[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?f:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return i&&i.abort(b),x(0,b),this}};if(o.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||zb)+"").replace(Ab,"").replace(Fb,yb[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=m.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(c=Gb.exec(k.url.toLowerCase()),k.crossDomain=!(!c||c[1]===yb[1]&&c[2]===yb[2]&&(c[3]||("http:"===c[1]?"80":"443"))===(yb[3]||("http:"===yb[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=m.param(k.data,k.traditional)),Mb(Hb,k,b,v),2===t)return v;h=m.event&&k.global,h&&0===m.active++&&m.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!Eb.test(k.type),e=k.url,k.hasContent||(k.data&&(e=k.url+=(wb.test(e)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=Bb.test(e)?e.replace(Bb,"$1_="+vb++):e+(wb.test(e)?"&":"?")+"_="+vb++)),k.ifModified&&(m.lastModified[e]&&v.setRequestHeader("If-Modified-Since",m.lastModified[e]),m.etag[e]&&v.setRequestHeader("If-None-Match",m.etag[e])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+Jb+"; q=0.01":""):k.accepts["*"]);for(d in k.headers)v.setRequestHeader(d,k.headers[d]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(d in{success:1,error:1,complete:1})v[d](k[d]);if(i=Mb(Ib,k,b,v)){v.readyState=1,h&&n.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,i.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,c,d){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),i=void 0,f=d||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,c&&(u=Ob(k,v,c)),u=Pb(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(m.lastModified[e]=w),w=v.getResponseHeader("etag"),w&&(m.etag[e]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?o.resolveWith(l,[r,x,v]):o.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,h&&n.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),h&&(n.trigger("ajaxComplete",[v,k]),--m.active||m.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return m.get(a,b,c,"json")},getScript:function(a,b){return m.get(a,void 0,b,"script")}}),m.each(["get","post"],function(a,b){m[b]=function(a,c,d,e){return m.isFunction(c)&&(e=e||d,d=c,c=void 0),m.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),m._evalUrl=function(a){return m.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},m.fn.extend({wrapAll:function(a){if(m.isFunction(a))return this.each(function(b){m(this).wrapAll(a.call(this,b))});if(this[0]){var b=m(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&1===a.firstChild.nodeType)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return this.each(m.isFunction(a)?function(b){m(this).wrapInner(a.call(this,b))}:function(){var b=m(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=m.isFunction(a);return this.each(function(c){m(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){m.nodeName(this,"body")||m(this).replaceWith(this.childNodes)}).end()}}),m.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0||!k.reliableHiddenOffsets()&&"none"===(a.style&&a.style.display||m.css(a,"display"))},m.expr.filters.visible=function(a){return!m.expr.filters.hidden(a)};var Qb=/%20/g,Rb=/\[\]$/,Sb=/\r?\n/g,Tb=/^(?:submit|button|image|reset|file)$/i,Ub=/^(?:input|select|textarea|keygen)/i;function Vb(a,b,c,d){var e;if(m.isArray(b))m.each(b,function(b,e){c||Rb.test(a)?d(a,e):Vb(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==m.type(b))d(a,b);else for(e in b)Vb(a+"["+e+"]",b[e],c,d)}m.param=function(a,b){var c,d=[],e=function(a,b){b=m.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=m.ajaxSettings&&m.ajaxSettings.traditional),m.isArray(a)||a.jquery&&!m.isPlainObject(a))m.each(a,function(){e(this.name,this.value)});else for(c in a)Vb(c,a[c],b,e);return d.join("&").replace(Qb,"+")},m.fn.extend({serialize:function(){return m.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=m.prop(this,"elements");return a?m.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!m(this).is(":disabled")&&Ub.test(this.nodeName)&&!Tb.test(a)&&(this.checked||!W.test(a))}).map(function(a,b){var c=m(this).val();return null==c?null:m.isArray(c)?m.map(c,function(a){return{name:b.name,value:a.replace(Sb,"\r\n")}}):{name:b.name,value:c.replace(Sb,"\r\n")}}).get()}}),m.ajaxSettings.xhr=void 0!==a.ActiveXObject?function(){return!this.isLocal&&/^(get|post|head|put|delete|options)$/i.test(this.type)&&Zb()||$b()}:Zb;var Wb=0,Xb={},Yb=m.ajaxSettings.xhr();a.attachEvent&&a.attachEvent("onunload",function(){for(var a in Xb)Xb[a](void 0,!0)}),k.cors=!!Yb&&"withCredentials"in Yb,Yb=k.ajax=!!Yb,Yb&&m.ajaxTransport(function(a){if(!a.crossDomain||k.cors){var b;return{send:function(c,d){var e,f=a.xhr(),g=++Wb;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)void 0!==c[e]&&f.setRequestHeader(e,c[e]+"");f.send(a.hasContent&&a.data||null),b=function(c,e){var h,i,j;if(b&&(e||4===f.readyState))if(delete Xb[g],b=void 0,f.onreadystatechange=m.noop,e)4!==f.readyState&&f.abort();else{j={},h=f.status,"string"==typeof f.responseText&&(j.text=f.responseText);try{i=f.statusText}catch(k){i=""}h||!a.isLocal||a.crossDomain?1223===h&&(h=204):h=j.text?200:404}j&&d(h,i,j,f.getAllResponseHeaders())},a.async?4===f.readyState?setTimeout(b):f.onreadystatechange=Xb[g]=b:b()},abort:function(){b&&b(void 0,!0)}}}});function Zb(){try{return new a.XMLHttpRequest}catch(b){}}function $b(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}m.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return m.globalEval(a),a}}}),m.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),m.ajaxTransport("script",function(a){if(a.crossDomain){var b,c=y.head||m("head")[0]||y.documentElement;return{send:function(d,e){b=y.createElement("script"),b.async=!0,a.scriptCharset&&(b.charset=a.scriptCharset),b.src=a.url,b.onload=b.onreadystatechange=function(a,c){(c||!b.readyState||/loaded|complete/.test(b.readyState))&&(b.onload=b.onreadystatechange=null,b.parentNode&&b.parentNode.removeChild(b),b=null,c||e(200,"success"))},c.insertBefore(b,c.firstChild)},abort:function(){b&&b.onload(void 0,!0)}}}});var _b=[],ac=/(=)\?(?=&|$)|\?\?/;m.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=_b.pop()||m.expando+"_"+vb++;return this[a]=!0,a}}),m.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(ac.test(b.url)?"url":"string"==typeof b.data&&!(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&ac.test(b.data)&&"data");return h||"jsonp"===b.dataTypes[0]?(e=b.jsonpCallback=m.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(ac,"$1"+e):b.jsonp!==!1&&(b.url+=(wb.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||m.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,_b.push(e)),g&&m.isFunction(f)&&f(g[0]),g=f=void 0}),"script"):void 0}),m.parseHTML=function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||y;var d=u.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=m.buildFragment([a],b,e),e&&e.length&&m(e).remove(),m.merge([],d.childNodes))};var bc=m.fn.load;m.fn.load=function(a,b,c){if("string"!=typeof a&&bc)return bc.apply(this,arguments);var d,e,f,g=this,h=a.indexOf(" ");return h>=0&&(d=m.trim(a.slice(h,a.length)),a=a.slice(0,h)),m.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(f="POST"),g.length>0&&m.ajax({url:a,type:f,dataType:"html",data:b}).done(function(a){e=arguments,g.html(d?m("<div>").append(m.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,e||[a.responseText,b,a])}),this},m.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){m.fn[b]=function(a){return this.on(b,a)}}),m.expr.filters.animated=function(a){return m.grep(m.timers,function(b){return a===b.elem}).length};var cc=a.document.documentElement;function dc(a){return m.isWindow(a)?a:9===a.nodeType?a.defaultView||a.parentWindow:!1}m.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=m.css(a,"position"),l=m(a),n={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=m.css(a,"top"),i=m.css(a,"left"),j=("absolute"===k||"fixed"===k)&&m.inArray("auto",[f,i])>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),m.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(n.top=b.top-h.top+g),null!=b.left&&(n.left=b.left-h.left+e),"using"in b?b.using.call(a,n):l.css(n)}},m.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){m.offset.setOffset(this,a,b)});var b,c,d={top:0,left:0},e=this[0],f=e&&e.ownerDocument;if(f)return b=f.documentElement,m.contains(b,e)?(typeof e.getBoundingClientRect!==K&&(d=e.getBoundingClientRect()),c=dc(f),{top:d.top+(c.pageYOffset||b.scrollTop)-(b.clientTop||0),left:d.left+(c.pageXOffset||b.scrollLeft)-(b.clientLeft||0)}):d},position:function(){if(this[0]){var a,b,c={top:0,left:0},d=this[0];return"fixed"===m.css(d,"position")?b=d.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),m.nodeName(a[0],"html")||(c=a.offset()),c.top+=m.css(a[0],"borderTopWidth",!0),c.left+=m.css(a[0],"borderLeftWidth",!0)),{top:b.top-c.top-m.css(d,"marginTop",!0),left:b.left-c.left-m.css(d,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||cc;while(a&&!m.nodeName(a,"html")&&"static"===m.css(a,"position"))a=a.offsetParent;return a||cc})}}),m.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,b){var c=/Y/.test(b);m.fn[a]=function(d){return V(this,function(a,d,e){var f=dc(a);return void 0===e?f?b in f?f[b]:f.document.documentElement[d]:a[d]:void(f?f.scrollTo(c?m(f).scrollLeft():e,c?e:m(f).scrollTop()):a[d]=e)},a,d,arguments.length,null)}}),m.each(["top","left"],function(a,b){m.cssHooks[b]=La(k.pixelPosition,function(a,c){return c?(c=Ja(a,b),Ha.test(c)?m(a).position()[b]+"px":c):void 0})}),m.each({Height:"height",Width:"width"},function(a,b){m.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){m.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return V(this,function(b,c,d){var e;return m.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?m.css(b,c,g):m.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),m.fn.size=function(){return this.length},m.fn.andSelf=m.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return m});var ec=a.jQuery,fc=a.$;return m.noConflict=function(b){return a.$===m&&(a.$=fc),b&&a.jQuery===m&&(a.jQuery=ec),m},typeof b===K&&(a.jQuery=a.$=m),m}); -//# sourceMappingURL=jquery.min.map \ No newline at end of file +/*! jQuery v3.6.1 | (c) OpenJS Foundation and other contributors | jquery.org/license */ +!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,y=n.hasOwnProperty,a=y.toString,l=a.call(Object),v={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.6.1",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0<t&&t-1 in e)}S.fn=S.prototype={jquery:f,constructor:S,length:0,toArray:function(){return s.call(this)},get:function(e){return null==e?s.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=S.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return S.each(this,e)},map:function(n){return this.pushStack(S.map(this,function(e,t){return n.call(e,t,e)}))},slice:function(){return this.pushStack(s.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(S.grep(this,function(e,t){return(t+1)%2}))},odd:function(){return this.pushStack(S.grep(this,function(e,t){return t%2}))},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(0<=n&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:u,sort:t.sort,splice:t.splice},S.extend=S.fn.extend=function(){var e,t,n,r,i,o,a=arguments[0]||{},s=1,u=arguments.length,l=!1;for("boolean"==typeof a&&(l=a,a=arguments[s]||{},s++),"object"==typeof a||m(a)||(a={}),s===u&&(a=this,s--);s<u;s++)if(null!=(e=arguments[s]))for(t in e)r=e[t],"__proto__"!==t&&a!==r&&(l&&r&&(S.isPlainObject(r)||(i=Array.isArray(r)))?(n=a[t],o=i&&!Array.isArray(n)?[]:i||S.isPlainObject(n)?n:{},i=!1,a[t]=S.extend(l,o,r)):void 0!==r&&(a[t]=r));return a},S.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==o.call(e))&&(!(t=r(e))||"function"==typeof(n=y.call(t,"constructor")&&t.constructor)&&a.call(n)===l)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e,t,n){b(e,{nonce:t&&t.nonce},n)},each:function(e,t){var n,r=0;if(p(e)){for(n=e.length;r<n;r++)if(!1===t.call(e[r],r,e[r]))break}else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},makeArray:function(e,t){var n=t||[];return null!=e&&(p(Object(e))?S.merge(n,"string"==typeof e?[e]:e):u.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:i.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r=[],i=0,o=e.length,a=!n;i<o;i++)!t(e[i],i)!==a&&r.push(e[i]);return r},map:function(e,t,n){var r,i,o=0,a=[];if(p(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&a.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&a.push(i);return g(a)},guid:1,support:v}),"function"==typeof Symbol&&(S.fn[Symbol.iterator]=t[Symbol.iterator]),S.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){n["[object "+t+"]"]=t.toLowerCase()});var d=function(n){var e,d,b,o,i,h,f,g,w,u,l,T,C,a,E,y,s,c,v,S="sizzle"+1*new Date,p=n.document,k=0,r=0,m=ue(),x=ue(),A=ue(),N=ue(),j=function(e,t){return e===t&&(l=!0),0},D={}.hasOwnProperty,t=[],q=t.pop,L=t.push,H=t.push,O=t.slice,P=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},R="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",I="(?:\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",W="\\["+M+"*("+I+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+I+"))|)"+M+"*\\]",F=":("+I+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+W+")*)|.*)\\)|)",$=new RegExp(M+"+","g"),B=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),_=new RegExp("^"+M+"*,"+M+"*"),z=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),ne=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(p.childNodes),p.childNodes),t[p.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&v(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+" "]&&(!y||!y.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&(U.test(t)||z.test(t))){(f=ee.test(t)&&ve(e.parentNode)||e)===e&&d.scope||((s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=S)),o=(l=h(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+xe(l[o]);c=l.join(",")}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){N(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return g(t.replace(B,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[S]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ye(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ve(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e&&e.namespaceURI,n=e&&(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:p;return r!=C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),p!=C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.scope=ce(function(e){return a.appendChild(e).appendChild(C.createElement("div")),"undefined"!=typeof e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=S,!C.getElementsByName||!C.getElementsByName(S).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],y=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){var t;a.appendChild(e).innerHTML="<a id='"+S+"'></a><select id='"+S+"-\r\\' msallowcapture=''><option selected=''></option></select>",e.querySelectorAll("[msallowcapture^='']").length&&y.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||y.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+S+"-]").length||y.push("~="),(t=C.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||y.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||y.push(":checked"),e.querySelectorAll("a#"+S+"+*").length||y.push(".#.+[+~]"),e.querySelectorAll("\\\f"),y.push("[\\r\\n\\f]")}),ce(function(e){e.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&y.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&y.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&y.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),y.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",F)}),y=y.length&&new RegExp(y.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),v=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},j=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e==C||e.ownerDocument==p&&v(p,e)?-1:t==C||t.ownerDocument==p&&v(p,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e==C?-1:t==C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]==p?-1:s[r]==p?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if(T(e),d.matchesSelector&&E&&!N[t+" "]&&(!s||!s.test(t))&&(!y||!y.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){N(t,!0)}return 0<se(t,C,null,[e]).length},se.contains=function(e,t){return(e.ownerDocument||e)!=C&&T(e),v(e,t)},se.attr=function(e,t){(e.ownerDocument||e)!=C&&T(e);var n=b.attrHandle[t.toLowerCase()],r=n&&D.call(b.attrHandle,t.toLowerCase())?n(e,t,!E):void 0;return void 0!==r?r:d.attributes||!E?e.getAttribute(t):(r=e.getAttributeNode(t))&&r.specified?r.value:null},se.escape=function(e){return(e+"").replace(re,ie)},se.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},se.uniqueSort=function(e){var t,n=[],r=0,i=0;if(l=!d.detectDuplicates,u=!d.sortStable&&e.slice(0),e.sort(j),l){while(t=e[i++])t===e[i]&&(r=n.push(i));while(r--)e.splice(n[r],1)}return u=null,e},o=se.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=o(e)}else if(3===i||4===i)return e.nodeValue}else while(t=e[r++])n+=o(t);return n},(b=se.selectors={cacheLength:50,createPseudo:le,match:G,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=m[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&m(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1<t.indexOf(i):"$="===r?i&&t.slice(-i.length)===i:"~="===r?-1<(" "+t.replace($," ")+" ").indexOf(i):"|="===r&&(t===i||t.slice(0,i.length+1)===i+"-"))}},CHILD:function(h,e,t,g,y){var v="nth"!==h.slice(0,3),m="last"!==h.slice(-4),x="of-type"===e;return 1===g&&0===y?function(e){return!!e.parentNode}:function(e,t,n){var r,i,o,a,s,u,l=v!==m?"nextSibling":"previousSibling",c=e.parentNode,f=x&&e.nodeName.toLowerCase(),p=!n&&!x,d=!1;if(c){if(v){while(l){a=e;while(a=a[l])if(x?a.nodeName.toLowerCase()===f:1===a.nodeType)return!1;u=l="only"===h&&!u&&"nextSibling"}return!0}if(u=[m?c.firstChild:c.lastChild],m&&p){d=(s=(r=(i=(o=(a=c)[S]||(a[S]={}))[a.uniqueID]||(o[a.uniqueID]={}))[h]||[])[0]===k&&r[1])&&r[2],a=s&&c.childNodes[s];while(a=++s&&a&&a[l]||(d=s=0)||u.pop())if(1===a.nodeType&&++d&&a===e){i[h]=[k,s,d];break}}else if(p&&(d=s=(r=(i=(o=(a=e)[S]||(a[S]={}))[a.uniqueID]||(o[a.uniqueID]={}))[h]||[])[0]===k&&r[1]),!1===d)while(a=++s&&a&&a[l]||(d=s=0)||u.pop())if((x?a.nodeName.toLowerCase()===f:1===a.nodeType)&&++d&&(p&&((i=(o=a[S]||(a[S]={}))[a.uniqueID]||(o[a.uniqueID]={}))[h]=[k,d]),a===e))break;return(d-=y)===g||d%g==0&&0<=d/g}}},PSEUDO:function(e,o){var t,a=b.pseudos[e]||b.setFilters[e.toLowerCase()]||se.error("unsupported pseudo: "+e);return a[S]?a(o):1<a.length?(t=[e,e,"",o],b.setFilters.hasOwnProperty(e.toLowerCase())?le(function(e,t){var n,r=a(e,o),i=r.length;while(i--)e[n=P(e,r[i])]=!(t[n]=r[i])}):function(e){return a(e,0,t)}):a}},pseudos:{not:le(function(e){var r=[],i=[],s=f(e.replace(B,"$1"));return s[S]?le(function(e,t,n,r){var i,o=s(e,null,r,[]),a=e.length;while(a--)(i=o[a])&&(e[a]=!(t[a]=i))}):function(e,t,n){return r[0]=e,s(r,null,n,i),r[0]=null,!i.pop()}}),has:le(function(t){return function(e){return 0<se(t,e).length}}),contains:le(function(t){return t=t.replace(te,ne),function(e){return-1<(e.textContent||o(e)).indexOf(t)}}),lang:le(function(n){return V.test(n||"")||se.error("unsupported lang: "+n),n=n.replace(te,ne).toLowerCase(),function(e){var t;do{if(t=E?e.lang:e.getAttribute("xml:lang")||e.getAttribute("lang"))return(t=t.toLowerCase())===n||0===t.indexOf(n+"-")}while((e=e.parentNode)&&1===e.nodeType);return!1}}),target:function(e){var t=n.location&&n.location.hash;return t&&t.slice(1)===e.id},root:function(e){return e===a},focus:function(e){return e===C.activeElement&&(!C.hasFocus||C.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:ge(!1),disabled:ge(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!b.pseudos.empty(e)},header:function(e){return J.test(e.nodeName)},input:function(e){return Q.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:ye(function(){return[0]}),last:ye(function(e,t){return[t-1]}),eq:ye(function(e,t,n){return[n<0?n+t:n]}),even:ye(function(e,t){for(var n=0;n<t;n+=2)e.push(n);return e}),odd:ye(function(e,t){for(var n=1;n<t;n+=2)e.push(n);return e}),lt:ye(function(e,t,n){for(var r=n<0?n+t:t<n?t:n;0<=--r;)e.push(r);return e}),gt:ye(function(e,t,n){for(var r=n<0?n+t:n;++r<t;)e.push(r);return e})}}).pseudos.nth=b.pseudos.eq,{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})b.pseudos[e]=de(e);for(e in{submit:!0,reset:!0})b.pseudos[e]=he(e);function me(){}function xe(e){for(var t=0,n=e.length,r="";t<n;t++)r+=e[t].value;return r}function be(s,e,t){var u=e.dir,l=e.next,c=l||u,f=t&&"parentNode"===c,p=r++;return e.first?function(e,t,n){while(e=e[u])if(1===e.nodeType||f)return s(e,t,n);return!1}:function(e,t,n){var r,i,o,a=[k,p];if(n){while(e=e[u])if((1===e.nodeType||f)&&s(e,t,n))return!0}else while(e=e[u])if(1===e.nodeType||f)if(i=(o=e[S]||(e[S]={}))[e.uniqueID]||(o[e.uniqueID]={}),l&&l===e.nodeName.toLowerCase())e=e[u]||e;else{if((r=i[c])&&r[0]===k&&r[1]===p)return a[2]=r[2];if((i[c]=a)[2]=s(e,t,n))return!0}return!1}}function we(i){return 1<i.length?function(e,t,n){var r=i.length;while(r--)if(!i[r](e,t,n))return!1;return!0}:i[0]}function Te(e,t,n,r,i){for(var o,a=[],s=0,u=e.length,l=null!=t;s<u;s++)(o=e[s])&&(n&&!n(o,r,i)||(a.push(o),l&&t.push(s)));return a}function Ce(d,h,g,y,v,e){return y&&!y[S]&&(y=Ce(y)),v&&!v[S]&&(v=Ce(v,e)),le(function(e,t,n,r){var i,o,a,s=[],u=[],l=t.length,c=e||function(e,t,n){for(var r=0,i=t.length;r<i;r++)se(e,t[r],n);return n}(h||"*",n.nodeType?[n]:n,[]),f=!d||!e&&h?c:Te(c,s,d,n,r),p=g?v||(e?d:l||y)?[]:t:f;if(g&&g(f,p,n,r),y){i=Te(p,u),y(i,[],n,r),o=i.length;while(o--)(a=i[o])&&(p[u[o]]=!(f[u[o]]=a))}if(e){if(v||d){if(v){i=[],o=p.length;while(o--)(a=p[o])&&i.push(f[o]=a);v(null,p=[],i,r)}o=p.length;while(o--)(a=p[o])&&-1<(i=v?P(e,a):s[o])&&(e[i]=!(t[i]=a))}}else p=Te(p===t?p.splice(l,p.length):p),v?v(null,t,p,r):H.apply(t,p)})}function Ee(e){for(var i,t,n,r=e.length,o=b.relative[e[0].type],a=o||b.relative[" "],s=o?1:0,u=be(function(e){return e===i},a,!0),l=be(function(e){return-1<P(i,e)},a,!0),c=[function(e,t,n){var r=!o&&(n||t!==w)||((i=t).nodeType?u(e,t,n):l(e,t,n));return i=null,r}];s<r;s++)if(t=b.relative[e[s].type])c=[be(we(c),t)];else{if((t=b.filter[e[s].type].apply(null,e[s].matches))[S]){for(n=++s;n<r;n++)if(b.relative[e[n].type])break;return Ce(1<s&&we(c),1<s&&xe(e.slice(0,s-1).concat({value:" "===e[s-2].type?"*":""})).replace(B,"$1"),t,s<n&&Ee(e.slice(s,n)),n<r&&Ee(e=e.slice(n)),n<r&&xe(e))}c.push(t)}return we(c)}return me.prototype=b.filters=b.pseudos,b.setFilters=new me,h=se.tokenize=function(e,t){var n,r,i,o,a,s,u,l=x[e+" "];if(l)return t?0:l.slice(0);a=e,s=[],u=b.preFilter;while(a){for(o in n&&!(r=_.exec(a))||(r&&(a=a.slice(r[0].length)||a),s.push(i=[])),n=!1,(r=z.exec(a))&&(n=r.shift(),i.push({value:n,type:r[0].replace(B," ")}),a=a.slice(n.length)),b.filter)!(r=G[o].exec(a))||u[o]&&!(r=u[o](r))||(n=r.shift(),i.push({value:n,type:o,matches:r}),a=a.slice(n.length));if(!n)break}return t?a.length:a?se.error(e):x(e,s).slice(0)},f=se.compile=function(e,t){var n,y,v,m,x,r,i=[],o=[],a=A[e+" "];if(!a){t||(t=h(e)),n=t.length;while(n--)(a=Ee(t[n]))[S]?i.push(a):o.push(a);(a=A(e,(y=o,m=0<(v=i).length,x=0<y.length,r=function(e,t,n,r,i){var o,a,s,u=0,l="0",c=e&&[],f=[],p=w,d=e||x&&b.find.TAG("*",i),h=k+=null==p?1:Math.random()||.1,g=d.length;for(i&&(w=t==C||t||i);l!==g&&null!=(o=d[l]);l++){if(x&&o){a=0,t||o.ownerDocument==C||(T(o),n=!E);while(s=y[a++])if(s(o,t||C,n)){r.push(o);break}i&&(k=h)}m&&((o=!s&&o)&&u--,e&&c.push(o))}if(u+=l,m&&l!==u){a=0;while(s=v[a++])s(c,f,t,n);if(e){if(0<u)while(l--)c[l]||f[l]||(f[l]=q.call(r));f=Te(f)}H.apply(r,f),i&&!e&&0<f.length&&1<u+v.length&&se.uniqueSort(r)}return i&&(k=h,w=p),c},m?le(r):r))).selector=e}return a},g=se.select=function(e,t,n,r){var i,o,a,s,u,l="function"==typeof e&&e,c=!r&&h(e=l.selector||e);if(n=n||[],1===c.length){if(2<(o=c[0]=c[0].slice(0)).length&&"ID"===(a=o[0]).type&&9===t.nodeType&&E&&b.relative[o[1].type]){if(!(t=(b.find.ID(a.matches[0].replace(te,ne),t)||[])[0]))return n;l&&(t=t.parentNode),e=e.slice(o.shift().value.length)}i=G.needsContext.test(e)?0:o.length;while(i--){if(a=o[i],b.relative[s=a.type])break;if((u=b.find[s])&&(r=u(a.matches[0].replace(te,ne),ee.test(o[0].type)&&ve(t.parentNode)||t))){if(o.splice(i,1),!(e=r.length&&xe(o)))return H.apply(n,r),n;break}}}return(l||f(e,c))(r,t,!E,n,!t||ee.test(e)&&ve(t.parentNode)||t),n},d.sortStable=S.split("").sort(j).join("")===S,d.detectDuplicates=!!l,T(),d.sortDetached=ce(function(e){return 1&e.compareDocumentPosition(C.createElement("fieldset"))}),ce(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||fe("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),d.attributes&&ce(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||fe("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),ce(function(e){return null==e.getAttribute("disabled")})||fe(R,function(e,t,n){var r;if(!n)return!0===e[t]?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),se}(C);S.find=d,S.expr=d.selectors,S.expr[":"]=S.expr.pseudos,S.uniqueSort=S.unique=d.uniqueSort,S.text=d.getText,S.isXMLDoc=d.isXML,S.contains=d.contains,S.escapeSelector=d.escape;var h=function(e,t,n){var r=[],i=void 0!==n;while((e=e[t])&&9!==e.nodeType)if(1===e.nodeType){if(i&&S(e).is(n))break;r.push(e)}return r},T=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},k=S.expr.match.needsContext;function A(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var N=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?S.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?S.grep(e,function(e){return e===n!==r}):"string"!=typeof n?S.grep(e,function(e){return-1<i.call(n,e)!==r}):S.filter(n,e,r)}S.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?S.find.matchesSelector(r,e)?[r]:[]:S.find.matches(e,S.grep(t,function(e){return 1===e.nodeType}))},S.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(S(e).filter(function(){for(t=0;t<r;t++)if(S.contains(i[t],this))return!0}));for(n=this.pushStack([]),t=0;t<r;t++)S.find(e,i[t],n);return 1<r?S.uniqueSort(n):n},filter:function(e){return this.pushStack(j(this,e||[],!1))},not:function(e){return this.pushStack(j(this,e||[],!0))},is:function(e){return!!j(this,"string"==typeof e&&k.test(e)?S(e):e||[],!1).length}});var D,q=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(S.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||D,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof S?t[0]:t,S.merge(this,S.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),N.test(r[1])&&S.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(S):S.makeArray(e,this)}).prototype=S.fn,D=S(E);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){while((e=e[t])&&1!==e.nodeType);return e}S.fn.extend({has:function(e){var t=S(e,this),n=t.length;return this.filter(function(){for(var e=0;e<n;e++)if(S.contains(this,t[e]))return!0})},closest:function(e,t){var n,r=0,i=this.length,o=[],a="string"!=typeof e&&S(e);if(!k.test(e))for(;r<i;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(n.nodeType<11&&(a?-1<a.index(n):1===n.nodeType&&S.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(1<o.length?S.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?i.call(S(e),this[0]):i.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(S.uniqueSort(S.merge(this.get(),S(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),S.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return h(e,"parentNode")},parentsUntil:function(e,t,n){return h(e,"parentNode",n)},next:function(e){return O(e,"nextSibling")},prev:function(e){return O(e,"previousSibling")},nextAll:function(e){return h(e,"nextSibling")},prevAll:function(e){return h(e,"previousSibling")},nextUntil:function(e,t,n){return h(e,"nextSibling",n)},prevUntil:function(e,t,n){return h(e,"previousSibling",n)},siblings:function(e){return T((e.parentNode||{}).firstChild,e)},children:function(e){return T(e.firstChild)},contents:function(e){return null!=e.contentDocument&&r(e.contentDocument)?e.contentDocument:(A(e,"template")&&(e=e.content||e),S.merge([],e.childNodes))}},function(r,i){S.fn[r]=function(e,t){var n=S.map(this,i,e);return"Until"!==r.slice(-5)&&(t=e),t&&"string"==typeof t&&(n=S.filter(t,n)),1<this.length&&(H[r]||S.uniqueSort(n),L.test(r)&&n.reverse()),this.pushStack(n)}});var P=/[^\x20\t\r\n\f]+/g;function R(e){return e}function M(e){throw e}function I(e,t,n,r){var i;try{e&&m(i=e.promise)?i.call(e).done(t).fail(n):e&&m(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n.apply(void 0,[e])}}S.Callbacks=function(r){var e,n;r="string"==typeof r?(e=r,n={},S.each(e.match(P)||[],function(e,t){n[t]=!0}),n):S.extend({},r);var i,t,o,a,s=[],u=[],l=-1,c=function(){for(a=a||r.once,o=i=!0;u.length;l=-1){t=u.shift();while(++l<s.length)!1===s[l].apply(t[0],t[1])&&r.stopOnFalse&&(l=s.length,t=!1)}r.memory||(t=!1),i=!1,a&&(s=t?[]:"")},f={add:function(){return s&&(t&&!i&&(l=s.length-1,u.push(t)),function n(e){S.each(e,function(e,t){m(t)?r.unique&&f.has(t)||s.push(t):t&&t.length&&"string"!==w(t)&&n(t)})}(arguments),t&&!i&&c()),this},remove:function(){return S.each(arguments,function(e,t){var n;while(-1<(n=S.inArray(t,s,n)))s.splice(n,1),n<=l&&l--}),this},has:function(e){return e?-1<S.inArray(e,s):0<s.length},empty:function(){return s&&(s=[]),this},disable:function(){return a=u=[],s=t="",this},disabled:function(){return!s},lock:function(){return a=u=[],t||i||(s=t=""),this},locked:function(){return!!a},fireWith:function(e,t){return a||(t=[e,(t=t||[]).slice?t.slice():t],u.push(t),i||c()),this},fire:function(){return f.fireWith(this,arguments),this},fired:function(){return!!o}};return f},S.extend({Deferred:function(e){var o=[["notify","progress",S.Callbacks("memory"),S.Callbacks("memory"),2],["resolve","done",S.Callbacks("once memory"),S.Callbacks("once memory"),0,"resolved"],["reject","fail",S.Callbacks("once memory"),S.Callbacks("once memory"),1,"rejected"]],i="pending",a={state:function(){return i},always:function(){return s.done(arguments).fail(arguments),this},"catch":function(e){return a.then(null,e)},pipe:function(){var i=arguments;return S.Deferred(function(r){S.each(o,function(e,t){var n=m(i[t[4]])&&i[t[4]];s[t[1]](function(){var e=n&&n.apply(this,arguments);e&&m(e.promise)?e.promise().progress(r.notify).done(r.resolve).fail(r.reject):r[t[0]+"With"](this,n?[e]:arguments)})}),i=null}).promise()},then:function(t,n,r){var u=0;function l(i,o,a,s){return function(){var n=this,r=arguments,e=function(){var e,t;if(!(i<u)){if((e=a.apply(n,r))===o.promise())throw new TypeError("Thenable self-resolution");t=e&&("object"==typeof e||"function"==typeof e)&&e.then,m(t)?s?t.call(e,l(u,o,R,s),l(u,o,M,s)):(u++,t.call(e,l(u,o,R,s),l(u,o,M,s),l(u,o,R,o.notifyWith))):(a!==R&&(n=void 0,r=[e]),(s||o.resolveWith)(n,r))}},t=s?e:function(){try{e()}catch(e){S.Deferred.exceptionHook&&S.Deferred.exceptionHook(e,t.stackTrace),u<=i+1&&(a!==M&&(n=void 0,r=[e]),o.rejectWith(n,r))}};i?t():(S.Deferred.getStackHook&&(t.stackTrace=S.Deferred.getStackHook()),C.setTimeout(t))}}return S.Deferred(function(e){o[0][3].add(l(0,e,m(r)?r:R,e.notifyWith)),o[1][3].add(l(0,e,m(t)?t:R)),o[2][3].add(l(0,e,m(n)?n:M))}).promise()},promise:function(e){return null!=e?S.extend(e,a):a}},s={};return S.each(o,function(e,t){var n=t[2],r=t[5];a[t[1]]=n.add,r&&n.add(function(){i=r},o[3-e][2].disable,o[3-e][3].disable,o[0][2].lock,o[0][3].lock),n.add(t[3].fire),s[t[0]]=function(){return s[t[0]+"With"](this===s?void 0:this,arguments),this},s[t[0]+"With"]=n.fireWith}),a.promise(s),e&&e.call(s,s),s},when:function(e){var n=arguments.length,t=n,r=Array(t),i=s.call(arguments),o=S.Deferred(),a=function(t){return function(e){r[t]=this,i[t]=1<arguments.length?s.call(arguments):e,--n||o.resolveWith(r,i)}};if(n<=1&&(I(e,o.done(a(t)).resolve,o.reject,!n),"pending"===o.state()||m(i[t]&&i[t].then)))return o.then();while(t--)I(i[t],a(t),o.reject);return o.promise()}});var W=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;S.Deferred.exceptionHook=function(e,t){C.console&&C.console.warn&&e&&W.test(e.name)&&C.console.warn("jQuery.Deferred exception: "+e.message,e.stack,t)},S.readyException=function(e){C.setTimeout(function(){throw e})};var F=S.Deferred();function $(){E.removeEventListener("DOMContentLoaded",$),C.removeEventListener("load",$),S.ready()}S.fn.ready=function(e){return F.then(e)["catch"](function(e){S.readyException(e)}),this},S.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--S.readyWait:S.isReady)||(S.isReady=!0)!==e&&0<--S.readyWait||F.resolveWith(E,[S])}}),S.ready.then=F.then,"complete"===E.readyState||"loading"!==E.readyState&&!E.documentElement.doScroll?C.setTimeout(S.ready):(E.addEventListener("DOMContentLoaded",$),C.addEventListener("load",$));var B=function(e,t,n,r,i,o,a){var s=0,u=e.length,l=null==n;if("object"===w(n))for(s in i=!0,n)B(e,t,s,n[s],!0,o,a);else if(void 0!==r&&(i=!0,m(r)||(a=!0),l&&(a?(t.call(e,r),t=null):(l=t,t=function(e,t,n){return l.call(S(e),n)})),t))for(;s<u;s++)t(e[s],n,a?r:r.call(e[s],s,t(e[s],n)));return i?e:l?t.call(e):u?t(e[0],n):o},_=/^-ms-/,z=/-([a-z])/g;function U(e,t){return t.toUpperCase()}function X(e){return e.replace(_,"ms-").replace(z,U)}var V=function(e){return 1===e.nodeType||9===e.nodeType||!+e.nodeType};function G(){this.expando=S.expando+G.uid++}G.uid=1,G.prototype={cache:function(e){var t=e[this.expando];return t||(t={},V(e)&&(e.nodeType?e[this.expando]=t:Object.defineProperty(e,this.expando,{value:t,configurable:!0}))),t},set:function(e,t,n){var r,i=this.cache(e);if("string"==typeof t)i[X(t)]=n;else for(r in t)i[X(r)]=t[r];return i},get:function(e,t){return void 0===t?this.cache(e):e[this.expando]&&e[this.expando][X(t)]},access:function(e,t,n){return void 0===t||t&&"string"==typeof t&&void 0===n?this.get(e,t):(this.set(e,t,n),void 0!==n?n:t)},remove:function(e,t){var n,r=e[this.expando];if(void 0!==r){if(void 0!==t){n=(t=Array.isArray(t)?t.map(X):(t=X(t))in r?[t]:t.match(P)||[]).length;while(n--)delete r[t[n]]}(void 0===t||S.isEmptyObject(r))&&(e.nodeType?e[this.expando]=void 0:delete e[this.expando])}},hasData:function(e){var t=e[this.expando];return void 0!==t&&!S.isEmptyObject(t)}};var Y=new G,Q=new G,J=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,K=/[A-Z]/g;function Z(e,t,n){var r,i;if(void 0===n&&1===e.nodeType)if(r="data-"+t.replace(K,"-$&").toLowerCase(),"string"==typeof(n=e.getAttribute(r))){try{n="true"===(i=n)||"false"!==i&&("null"===i?null:i===+i+""?+i:J.test(i)?JSON.parse(i):i)}catch(e){}Q.set(e,t,n)}else n=void 0;return n}S.extend({hasData:function(e){return Q.hasData(e)||Y.hasData(e)},data:function(e,t,n){return Q.access(e,t,n)},removeData:function(e,t){Q.remove(e,t)},_data:function(e,t,n){return Y.access(e,t,n)},_removeData:function(e,t){Y.remove(e,t)}}),S.fn.extend({data:function(n,e){var t,r,i,o=this[0],a=o&&o.attributes;if(void 0===n){if(this.length&&(i=Q.get(o),1===o.nodeType&&!Y.get(o,"hasDataAttrs"))){t=a.length;while(t--)a[t]&&0===(r=a[t].name).indexOf("data-")&&(r=X(r.slice(5)),Z(o,r,i[r]));Y.set(o,"hasDataAttrs",!0)}return i}return"object"==typeof n?this.each(function(){Q.set(this,n)}):B(this,function(e){var t;if(o&&void 0===e)return void 0!==(t=Q.get(o,n))?t:void 0!==(t=Z(o,n))?t:void 0;this.each(function(){Q.set(this,n,e)})},null,e,1<arguments.length,null,!0)},removeData:function(e){return this.each(function(){Q.remove(this,e)})}}),S.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=Y.get(e,t),n&&(!r||Array.isArray(n)?r=Y.access(e,t,S.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=S.queue(e,t),r=n.length,i=n.shift(),o=S._queueHooks(e,t);"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,function(){S.dequeue(e,t)},o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return Y.get(e,n)||Y.access(e,n,{empty:S.Callbacks("once memory").add(function(){Y.remove(e,[t+"queue",n])})})}}),S.fn.extend({queue:function(t,n){var e=2;return"string"!=typeof t&&(n=t,t="fx",e--),arguments.length<e?S.queue(this[0],t):void 0===n?this:this.each(function(){var e=S.queue(this,t,n);S._queueHooks(this,t),"fx"===t&&"inprogress"!==e[0]&&S.dequeue(this,t)})},dequeue:function(e){return this.each(function(){S.dequeue(this,e)})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,t){var n,r=1,i=S.Deferred(),o=this,a=this.length,s=function(){--r||i.resolveWith(o,[o])};"string"!=typeof e&&(t=e,e=void 0),e=e||"fx";while(a--)(n=Y.get(o[a],e+"queueHooks"))&&n.empty&&(r++,n.empty.add(s));return s(),i.promise(t)}});var ee=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,te=new RegExp("^(?:([+-])=|)("+ee+")([a-z%]*)$","i"),ne=["Top","Right","Bottom","Left"],re=E.documentElement,ie=function(e){return S.contains(e.ownerDocument,e)},oe={composed:!0};re.getRootNode&&(ie=function(e){return S.contains(e.ownerDocument,e)||e.getRootNode(oe)===e.ownerDocument});var ae=function(e,t){return"none"===(e=t||e).style.display||""===e.style.display&&ie(e)&&"none"===S.css(e,"display")};function se(e,t,n,r){var i,o,a=20,s=r?function(){return r.cur()}:function(){return S.css(e,t,"")},u=s(),l=n&&n[3]||(S.cssNumber[t]?"":"px"),c=e.nodeType&&(S.cssNumber[t]||"px"!==l&&+u)&&te.exec(S.css(e,t));if(c&&c[3]!==l){u/=2,l=l||c[3],c=+u||1;while(a--)S.style(e,t,c+l),(1-o)*(1-(o=s()/u||.5))<=0&&(a=0),c/=o;c*=2,S.style(e,t,c+l),n=n||[]}return n&&(c=+c||+u||0,i=n[1]?c+(n[1]+1)*n[2]:+n[2],r&&(r.unit=l,r.start=c,r.end=i)),i}var ue={};function le(e,t){for(var n,r,i,o,a,s,u,l=[],c=0,f=e.length;c<f;c++)(r=e[c]).style&&(n=r.style.display,t?("none"===n&&(l[c]=Y.get(r,"display")||null,l[c]||(r.style.display="")),""===r.style.display&&ae(r)&&(l[c]=(u=a=o=void 0,a=(i=r).ownerDocument,s=i.nodeName,(u=ue[s])||(o=a.body.appendChild(a.createElement(s)),u=S.css(o,"display"),o.parentNode.removeChild(o),"none"===u&&(u="block"),ue[s]=u)))):"none"!==n&&(l[c]="none",Y.set(r,"display",n)));for(c=0;c<f;c++)null!=l[c]&&(e[c].style.display=l[c]);return e}S.fn.extend({show:function(){return le(this,!0)},hide:function(){return le(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){ae(this)?S(this).show():S(this).hide()})}});var ce,fe,pe=/^(?:checkbox|radio)$/i,de=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i;ce=E.createDocumentFragment().appendChild(E.createElement("div")),(fe=E.createElement("input")).setAttribute("type","radio"),fe.setAttribute("checked","checked"),fe.setAttribute("name","t"),ce.appendChild(fe),v.checkClone=ce.cloneNode(!0).cloneNode(!0).lastChild.checked,ce.innerHTML="<textarea>x</textarea>",v.noCloneChecked=!!ce.cloneNode(!0).lastChild.defaultValue,ce.innerHTML="<option></option>",v.option=!!ce.lastChild;var ge={thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};function ye(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ve(e,t){for(var n=0,r=e.length;n<r;n++)Y.set(e[n],"globalEval",!t||Y.get(t[n],"globalEval"))}ge.tbody=ge.tfoot=ge.colgroup=ge.caption=ge.thead,ge.th=ge.td,v.option||(ge.optgroup=ge.option=[1,"<select multiple='multiple'>","</select>"]);var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d<h;d++)if((o=e[d])||0===o)if("object"===w(o))S.merge(p,o.nodeType?[o]:o);else if(me.test(o)){a=a||f.appendChild(t.createElement("div")),s=(de.exec(o)||["",""])[1].toLowerCase(),u=ge[s]||ge._default,a.innerHTML=u[1]+S.htmlPrefilter(o)+u[2],c=u[0];while(c--)a=a.lastChild;S.merge(p,a.childNodes),(a=f.firstChild).textContent=""}else p.push(t.createTextNode(o));f.textContent="",d=0;while(o=p[d++])if(r&&-1<S.inArray(o,r))i&&i.push(o);else if(l=ie(o),a=ye(f.appendChild(o),"script"),l&&ve(a),n){c=0;while(o=a[c++])he.test(o.type||"")&&n.push(o)}return f}var be=/^([^.]*)(?:\.(.+)|)/;function we(){return!0}function Te(){return!1}function Ce(e,t){return e===function(){try{return E.activeElement}catch(e){}}()==("focus"===t)}function Ee(e,t,n,r,i,o){var a,s;if("object"==typeof t){for(s in"string"!=typeof n&&(r=r||n,n=void 0),t)Ee(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=Te;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return S().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=S.guid++)),e.each(function(){S.event.add(this,t,i,r,n)})}function Se(e,i,o){o?(Y.set(e,i,!1),S.event.add(e,i,{namespace:!1,handler:function(e){var t,n,r=Y.get(this,i);if(1&e.isTrigger&&this[i]){if(r.length)(S.event.special[i]||{}).delegateType&&e.stopPropagation();else if(r=s.call(arguments),Y.set(this,i,r),t=o(this,i),this[i](),r!==(n=Y.get(this,i))||t?Y.set(this,i,!1):n={},r!==n)return e.stopImmediatePropagation(),e.preventDefault(),n&&n.value}else r.length&&(Y.set(this,i,{value:S.event.trigger(S.extend(r[0],S.Event.prototype),r.slice(1),this)}),e.stopImmediatePropagation())}})):void 0===Y.get(e,i)&&S.event.add(e,i,we)}S.event={global:{},add:function(t,e,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=Y.get(t);if(V(t)){n.handler&&(n=(o=n).handler,i=o.selector),i&&S.find.matchesSelector(re,i),n.guid||(n.guid=S.guid++),(u=y.events)||(u=y.events=Object.create(null)),(a=y.handle)||(a=y.handle=function(e){return"undefined"!=typeof S&&S.event.triggered!==e.type?S.event.dispatch.apply(t,arguments):void 0}),l=(e=(e||"").match(P)||[""]).length;while(l--)d=g=(s=be.exec(e[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=S.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=S.event.special[d]||{},c=S.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&S.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(t,r,h,a)||t.addEventListener&&t.addEventListener(d,a)),f.add&&(f.add.call(t,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),S.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=Y.hasData(e)&&Y.get(e);if(y&&(u=y.events)){l=(t=(t||"").match(P)||[""]).length;while(l--)if(d=g=(s=be.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d){f=S.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,y.handle)||S.removeEvent(e,d,y.handle),delete u[d])}else for(d in u)S.event.remove(e,d+t[l],n,r,!0);S.isEmptyObject(u)&&Y.remove(e,"handle events")}},dispatch:function(e){var t,n,r,i,o,a,s=new Array(arguments.length),u=S.event.fix(e),l=(Y.get(this,"events")||Object.create(null))[u.type]||[],c=S.event.special[u.type]||{};for(s[0]=u,t=1;t<arguments.length;t++)s[t]=arguments[t];if(u.delegateTarget=this,!c.preDispatch||!1!==c.preDispatch.call(this,u)){a=S.event.handlers.call(this,u,l),t=0;while((i=a[t++])&&!u.isPropagationStopped()){u.currentTarget=i.elem,n=0;while((o=i.handlers[n++])&&!u.isImmediatePropagationStopped())u.rnamespace&&!1!==o.namespace&&!u.rnamespace.test(o.namespace)||(u.handleObj=o,u.data=o.data,void 0!==(r=((S.event.special[o.origType]||{}).handle||o.handler).apply(i.elem,s))&&!1===(u.result=r)&&(u.preventDefault(),u.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,u),u.result}},handlers:function(e,t){var n,r,i,o,a,s=[],u=t.delegateCount,l=e.target;if(u&&l.nodeType&&!("click"===e.type&&1<=e.button))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(o=[],a={},n=0;n<u;n++)void 0===a[i=(r=t[n]).selector+" "]&&(a[i]=r.needsContext?-1<S(i,this).index(l):S.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}return l=this,u<t.length&&s.push({elem:l,handlers:t.slice(u)}),s},addProp:function(t,e){Object.defineProperty(S.Event.prototype,t,{enumerable:!0,configurable:!0,get:m(e)?function(){if(this.originalEvent)return e(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[t]},set:function(e){Object.defineProperty(this,t,{enumerable:!0,configurable:!0,writable:!0,value:e})}})},fix:function(e){return e[S.expando]?e:new S.Event(e)},special:{load:{noBubble:!0},click:{setup:function(e){var t=this||e;return pe.test(t.type)&&t.click&&A(t,"input")&&Se(t,"click",we),!1},trigger:function(e){var t=this||e;return pe.test(t.type)&&t.click&&A(t,"input")&&Se(t,"click"),!0},_default:function(e){var t=e.target;return pe.test(t.type)&&t.click&&A(t,"input")&&Y.get(t,"click")||A(t,"a")}},beforeunload:{postDispatch:function(e){void 0!==e.result&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}}}},S.removeEvent=function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n)},S.Event=function(e,t){if(!(this instanceof S.Event))return new S.Event(e,t);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||void 0===e.defaultPrevented&&!1===e.returnValue?we:Te,this.target=e.target&&3===e.target.nodeType?e.target.parentNode:e.target,this.currentTarget=e.currentTarget,this.relatedTarget=e.relatedTarget):this.type=e,t&&S.extend(this,t),this.timeStamp=e&&e.timeStamp||Date.now(),this[S.expando]=!0},S.Event.prototype={constructor:S.Event,isDefaultPrevented:Te,isPropagationStopped:Te,isImmediatePropagationStopped:Te,isSimulated:!1,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=we,e&&!this.isSimulated&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=we,e&&!this.isSimulated&&e.stopPropagation()},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=we,e&&!this.isSimulated&&e.stopImmediatePropagation(),this.stopPropagation()}},S.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,"char":!0,code:!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:!0},S.event.addProp),S.each({focus:"focusin",blur:"focusout"},function(t,e){S.event.special[t]={setup:function(){return Se(this,t,Ce),!1},trigger:function(){return Se(this,t),!0},_default:function(e){return Y.get(e.target,t)},delegateType:e}}),S.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(e,i){S.event.special[e]={delegateType:i,bindType:i,handle:function(e){var t,n=e.relatedTarget,r=e.handleObj;return n&&(n===this||S.contains(this,n))||(e.type=r.origType,t=r.handler.apply(this,arguments),e.type=i),t}}}),S.fn.extend({on:function(e,t,n,r){return Ee(this,e,t,n,r)},one:function(e,t,n,r){return Ee(this,e,t,n,r,1)},off:function(e,t,n){var r,i;if(e&&e.preventDefault&&e.handleObj)return r=e.handleObj,S(e.delegateTarget).off(r.namespace?r.origType+"."+r.namespace:r.origType,r.selector,r.handler),this;if("object"==typeof e){for(i in e)this.off(i,t,e[i]);return this}return!1!==t&&"function"!=typeof t||(n=t,t=void 0),!1===n&&(n=Te),this.each(function(){S.event.remove(this,e,n,t)})}});var ke=/<script|<style|<link/i,Ae=/checked\s*(?:[^=]|=\s*.checked.)/i,Ne=/^\s*<!\[CDATA\[|\]\]>\s*$/g;function je(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&S(e).children("tbody")[0]||e}function De(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function qe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Le(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(Y.hasData(e)&&(s=Y.get(e).events))for(i in Y.remove(t,"handle events"),s)for(n=0,r=s[i].length;n<r;n++)S.event.add(t,i,s[i][n]);Q.hasData(e)&&(o=Q.access(e),a=S.extend({},o),Q.set(t,a))}}function He(n,r,i,o){r=g(r);var e,t,a,s,u,l,c=0,f=n.length,p=f-1,d=r[0],h=m(d);if(h||1<f&&"string"==typeof d&&!v.checkClone&&Ae.test(d))return n.each(function(e){var t=n.eq(e);h&&(r[0]=d.call(this,e,t.html())),He(t,r,i,o)});if(f&&(t=(e=xe(r,n[0].ownerDocument,!1,n,o)).firstChild,1===e.childNodes.length&&(e=t),t||o)){for(s=(a=S.map(ye(e,"script"),De)).length;c<f;c++)u=e,c!==p&&(u=S.clone(u,!0,!0),s&&S.merge(a,ye(u,"script"))),i.call(n[c],u,c);if(s)for(l=a[a.length-1].ownerDocument,S.map(a,qe),c=0;c<s;c++)u=a[c],he.test(u.type||"")&&!Y.access(u,"globalEval")&&S.contains(l,u)&&(u.src&&"module"!==(u.type||"").toLowerCase()?S._evalUrl&&!u.noModule&&S._evalUrl(u.src,{nonce:u.nonce||u.getAttribute("nonce")},l):b(u.textContent.replace(Ne,""),u,l))}return n}function Oe(e,t,n){for(var r,i=t?S.filter(t,e):e,o=0;null!=(r=i[o]);o++)n||1!==r.nodeType||S.cleanData(ye(r)),r.parentNode&&(n&&ie(r)&&ve(ye(r,"script")),r.parentNode.removeChild(r));return e}S.extend({htmlPrefilter:function(e){return e},clone:function(e,t,n){var r,i,o,a,s,u,l,c=e.cloneNode(!0),f=ie(e);if(!(v.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||S.isXMLDoc(e)))for(a=ye(c),r=0,i=(o=ye(e)).length;r<i;r++)s=o[r],u=a[r],void 0,"input"===(l=u.nodeName.toLowerCase())&&pe.test(s.type)?u.checked=s.checked:"input"!==l&&"textarea"!==l||(u.defaultValue=s.defaultValue);if(t)if(n)for(o=o||ye(e),a=a||ye(c),r=0,i=o.length;r<i;r++)Le(o[r],a[r]);else Le(e,c);return 0<(a=ye(c,"script")).length&&ve(a,!f&&ye(e,"script")),c},cleanData:function(e){for(var t,n,r,i=S.event.special,o=0;void 0!==(n=e[o]);o++)if(V(n)){if(t=n[Y.expando]){if(t.events)for(r in t.events)i[r]?S.event.remove(n,r):S.removeEvent(n,r,t.handle);n[Y.expando]=void 0}n[Q.expando]&&(n[Q.expando]=void 0)}}}),S.fn.extend({detach:function(e){return Oe(this,e,!0)},remove:function(e){return Oe(this,e)},text:function(e){return B(this,function(e){return void 0===e?S.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return He(this,arguments,function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||je(this,e).appendChild(e)})},prepend:function(){return He(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=je(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return He(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return He(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(S.cleanData(ye(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return S.clone(this,e,t)})},html:function(e){return B(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!ke.test(e)&&!ge[(de.exec(e)||["",""])[1].toLowerCase()]){e=S.htmlPrefilter(e);try{for(;n<r;n++)1===(t=this[n]||{}).nodeType&&(S.cleanData(ye(t,!1)),t.innerHTML=e);t=0}catch(e){}}t&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var n=[];return He(this,arguments,function(e){var t=this.parentNode;S.inArray(this,n)<0&&(S.cleanData(ye(this)),t&&t.replaceChild(e,this))},n)}}),S.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,a){S.fn[e]=function(e){for(var t,n=[],r=S(e),i=r.length-1,o=0;o<=i;o++)t=o===i?this:this.clone(!0),S(r[o])[a](t),u.apply(n,t.get());return this.pushStack(n)}});var Pe=new RegExp("^("+ee+")(?!px)[a-z%]+$","i"),Re=/^--/,Me=function(e){var t=e.ownerDocument.defaultView;return t&&t.opener||(t=C),t.getComputedStyle(e)},Ie=function(e,t,n){var r,i,o={};for(i in t)o[i]=e.style[i],e.style[i]=t[i];for(i in r=n.call(e),t)e.style[i]=o[i];return r},We=new RegExp(ne.join("|"),"i"),Fe="[\\x20\\t\\r\\n\\f]",$e=new RegExp("^"+Fe+"+|((?:^|[^\\\\])(?:\\\\.)*)"+Fe+"+$","g");function Be(e,t,n){var r,i,o,a,s=Re.test(t),u=e.style;return(n=n||Me(e))&&(a=n.getPropertyValue(t)||n[t],s&&(a=a.replace($e,"$1")),""!==a||ie(e)||(a=S.style(e,t)),!v.pixelBoxStyles()&&Pe.test(a)&&We.test(t)&&(r=u.width,i=u.minWidth,o=u.maxWidth,u.minWidth=u.maxWidth=u.width=a,a=n.width,u.width=r,u.minWidth=i,u.maxWidth=o)),void 0!==a?a+"":a}function _e(e,t){return{get:function(){if(!e())return(this.get=t).apply(this,arguments);delete this.get}}}!function(){function e(){if(l){u.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",l.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",re.appendChild(u).appendChild(l);var e=C.getComputedStyle(l);n="1%"!==e.top,s=12===t(e.marginLeft),l.style.right="60%",o=36===t(e.right),r=36===t(e.width),l.style.position="absolute",i=12===t(l.offsetWidth/3),re.removeChild(u),l=null}}function t(e){return Math.round(parseFloat(e))}var n,r,i,o,a,s,u=E.createElement("div"),l=E.createElement("div");l.style&&(l.style.backgroundClip="content-box",l.cloneNode(!0).style.backgroundClip="",v.clearCloneStyle="content-box"===l.style.backgroundClip,S.extend(v,{boxSizingReliable:function(){return e(),r},pixelBoxStyles:function(){return e(),o},pixelPosition:function(){return e(),n},reliableMarginLeft:function(){return e(),s},scrollboxSize:function(){return e(),i},reliableTrDimensions:function(){var e,t,n,r;return null==a&&(e=E.createElement("table"),t=E.createElement("tr"),n=E.createElement("div"),e.style.cssText="position:absolute;left:-11111px;border-collapse:separate",t.style.cssText="border:1px solid",t.style.height="1px",n.style.height="9px",n.style.display="block",re.appendChild(e).appendChild(t).appendChild(n),r=C.getComputedStyle(t),a=parseInt(r.height,10)+parseInt(r.borderTopWidth,10)+parseInt(r.borderBottomWidth,10)===t.offsetHeight,re.removeChild(e)),a}}))}();var ze=["Webkit","Moz","ms"],Ue=E.createElement("div").style,Xe={};function Ve(e){var t=S.cssProps[e]||Xe[e];return t||(e in Ue?e:Xe[e]=function(e){var t=e[0].toUpperCase()+e.slice(1),n=ze.length;while(n--)if((e=ze[n]+t)in Ue)return e}(e)||e)}var Ge=/^(none|table(?!-c[ea]).+)/,Ye={position:"absolute",visibility:"hidden",display:"block"},Qe={letterSpacing:"0",fontWeight:"400"};function Je(e,t,n){var r=te.exec(t);return r?Math.max(0,r[2]-(n||0))+(r[3]||"px"):t}function Ke(e,t,n,r,i,o){var a="width"===t?1:0,s=0,u=0;if(n===(r?"border":"content"))return 0;for(;a<4;a+=2)"margin"===n&&(u+=S.css(e,n+ne[a],!0,i)),r?("content"===n&&(u-=S.css(e,"padding"+ne[a],!0,i)),"margin"!==n&&(u-=S.css(e,"border"+ne[a]+"Width",!0,i))):(u+=S.css(e,"padding"+ne[a],!0,i),"padding"!==n?u+=S.css(e,"border"+ne[a]+"Width",!0,i):s+=S.css(e,"border"+ne[a]+"Width",!0,i));return!r&&0<=o&&(u+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-o-u-s-.5))||0),u}function Ze(e,t,n){var r=Me(e),i=(!v.boxSizingReliable()||n)&&"border-box"===S.css(e,"boxSizing",!1,r),o=i,a=Be(e,t,r),s="offset"+t[0].toUpperCase()+t.slice(1);if(Pe.test(a)){if(!n)return a;a="auto"}return(!v.boxSizingReliable()&&i||!v.reliableTrDimensions()&&A(e,"tr")||"auto"===a||!parseFloat(a)&&"inline"===S.css(e,"display",!1,r))&&e.getClientRects().length&&(i="border-box"===S.css(e,"boxSizing",!1,r),(o=s in e)&&(a=e[s])),(a=parseFloat(a)||0)+Ke(e,t,n||(i?"border":"content"),o,r,a)+"px"}function et(e,t,n,r,i){return new et.prototype.init(e,t,n,r,i)}S.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Be(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=X(t),u=Re.test(t),l=e.style;if(u||(t=Ve(s)),a=S.cssHooks[t]||S.cssHooks[s],void 0===n)return a&&"get"in a&&void 0!==(i=a.get(e,!1,r))?i:l[t];"string"===(o=typeof n)&&(i=te.exec(n))&&i[1]&&(n=se(e,t,i),o="number"),null!=n&&n==n&&("number"!==o||u||(n+=i&&i[3]||(S.cssNumber[s]?"":"px")),v.clearCloneStyle||""!==n||0!==t.indexOf("background")||(l[t]="inherit"),a&&"set"in a&&void 0===(n=a.set(e,n,r))||(u?l.setProperty(t,n):l[t]=n))}},css:function(e,t,n,r){var i,o,a,s=X(t);return Re.test(t)||(t=Ve(s)),(a=S.cssHooks[t]||S.cssHooks[s])&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=Be(e,t,r)),"normal"===i&&t in Qe&&(i=Qe[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),S.each(["height","width"],function(e,u){S.cssHooks[u]={get:function(e,t,n){if(t)return!Ge.test(S.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?Ze(e,u,n):Ie(e,Ye,function(){return Ze(e,u,n)})},set:function(e,t,n){var r,i=Me(e),o=!v.scrollboxSize()&&"absolute"===i.position,a=(o||n)&&"border-box"===S.css(e,"boxSizing",!1,i),s=n?Ke(e,u,n,a,i):0;return a&&o&&(s-=Math.ceil(e["offset"+u[0].toUpperCase()+u.slice(1)]-parseFloat(i[u])-Ke(e,u,"border",!1,i)-.5)),s&&(r=te.exec(t))&&"px"!==(r[3]||"px")&&(e.style[u]=t,t=S.css(e,u)),Je(0,t,s)}}}),S.cssHooks.marginLeft=_e(v.reliableMarginLeft,function(e,t){if(t)return(parseFloat(Be(e,"marginLeft"))||e.getBoundingClientRect().left-Ie(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),S.each({margin:"",padding:"",border:"Width"},function(i,o){S.cssHooks[i+o]={expand:function(e){for(var t=0,n={},r="string"==typeof e?e.split(" "):[e];t<4;t++)n[i+ne[t]+o]=r[t]||r[t-2]||r[0];return n}},"margin"!==i&&(S.cssHooks[i+o].set=Je)}),S.fn.extend({css:function(e,t){return B(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=Me(e),i=t.length;a<i;a++)o[t[a]]=S.css(e,t[a],!1,r);return o}return void 0!==n?S.style(e,t,n):S.css(e,t)},e,t,1<arguments.length)}}),((S.Tween=et).prototype={constructor:et,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||S.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(S.cssNumber[n]?"":"px")},cur:function(){var e=et.propHooks[this.prop];return e&&e.get?e.get(this):et.propHooks._default.get(this)},run:function(e){var t,n=et.propHooks[this.prop];return this.options.duration?this.pos=t=S.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):et.propHooks._default.set(this),this}}).init.prototype=et.prototype,(et.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=S.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){S.fx.step[e.prop]?S.fx.step[e.prop](e):1!==e.elem.nodeType||!S.cssHooks[e.prop]&&null==e.elem.style[Ve(e.prop)]?e.elem[e.prop]=e.now:S.style(e.elem,e.prop,e.now+e.unit)}}}).scrollTop=et.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},S.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},S.fx=et.prototype.init,S.fx.step={};var tt,nt,rt,it,ot=/^(?:toggle|show|hide)$/,at=/queueHooks$/;function st(){nt&&(!1===E.hidden&&C.requestAnimationFrame?C.requestAnimationFrame(st):C.setTimeout(st,S.fx.interval),S.fx.tick())}function ut(){return C.setTimeout(function(){tt=void 0}),tt=Date.now()}function lt(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)i["margin"+(n=ne[r])]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function ct(e,t,n){for(var r,i=(ft.tweeners[t]||[]).concat(ft.tweeners["*"]),o=0,a=i.length;o<a;o++)if(r=i[o].call(n,t,e))return r}function ft(o,e,t){var n,a,r=0,i=ft.prefilters.length,s=S.Deferred().always(function(){delete u.elem}),u=function(){if(a)return!1;for(var e=tt||ut(),t=Math.max(0,l.startTime+l.duration-e),n=1-(t/l.duration||0),r=0,i=l.tweens.length;r<i;r++)l.tweens[r].run(n);return s.notifyWith(o,[l,n,t]),n<1&&i?t:(i||s.notifyWith(o,[l,1,0]),s.resolveWith(o,[l]),!1)},l=s.promise({elem:o,props:S.extend({},e),opts:S.extend(!0,{specialEasing:{},easing:S.easing._default},t),originalProperties:e,originalOptions:t,startTime:tt||ut(),duration:t.duration,tweens:[],createTween:function(e,t){var n=S.Tween(o,l.opts,e,t,l.opts.specialEasing[e]||l.opts.easing);return l.tweens.push(n),n},stop:function(e){var t=0,n=e?l.tweens.length:0;if(a)return this;for(a=!0;t<n;t++)l.tweens[t].run(1);return e?(s.notifyWith(o,[l,1,0]),s.resolveWith(o,[l,e])):s.rejectWith(o,[l,e]),this}}),c=l.props;for(!function(e,t){var n,r,i,o,a;for(n in e)if(i=t[r=X(n)],o=e[n],Array.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),(a=S.cssHooks[r])&&"expand"in a)for(n in o=a.expand(o),delete e[r],o)n in e||(e[n]=o[n],t[n]=i);else t[r]=i}(c,l.opts.specialEasing);r<i;r++)if(n=ft.prefilters[r].call(l,o,c,l.opts))return m(n.stop)&&(S._queueHooks(l.elem,l.opts.queue).stop=n.stop.bind(n)),n;return S.map(c,ct,l),m(l.opts.start)&&l.opts.start.call(o,l),l.progress(l.opts.progress).done(l.opts.done,l.opts.complete).fail(l.opts.fail).always(l.opts.always),S.fx.timer(S.extend(u,{elem:o,anim:l,queue:l.opts.queue})),l}S.Animation=S.extend(ft,{tweeners:{"*":[function(e,t){var n=this.createTween(e,t);return se(n.elem,e,te.exec(t),n),n}]},tweener:function(e,t){m(e)?(t=e,e=["*"]):e=e.match(P);for(var n,r=0,i=e.length;r<i;r++)n=e[r],ft.tweeners[n]=ft.tweeners[n]||[],ft.tweeners[n].unshift(t)},prefilters:[function(e,t,n){var r,i,o,a,s,u,l,c,f="width"in t||"height"in t,p=this,d={},h=e.style,g=e.nodeType&&ae(e),y=Y.get(e,"fxshow");for(r in n.queue||(null==(a=S._queueHooks(e,"fx")).unqueued&&(a.unqueued=0,s=a.empty.fire,a.empty.fire=function(){a.unqueued||s()}),a.unqueued++,p.always(function(){p.always(function(){a.unqueued--,S.queue(e,"fx").length||a.empty.fire()})})),t)if(i=t[r],ot.test(i)){if(delete t[r],o=o||"toggle"===i,i===(g?"hide":"show")){if("show"!==i||!y||void 0===y[r])continue;g=!0}d[r]=y&&y[r]||S.style(e,r)}if((u=!S.isEmptyObject(t))||!S.isEmptyObject(d))for(r in f&&1===e.nodeType&&(n.overflow=[h.overflow,h.overflowX,h.overflowY],null==(l=y&&y.display)&&(l=Y.get(e,"display")),"none"===(c=S.css(e,"display"))&&(l?c=l:(le([e],!0),l=e.style.display||l,c=S.css(e,"display"),le([e]))),("inline"===c||"inline-block"===c&&null!=l)&&"none"===S.css(e,"float")&&(u||(p.done(function(){h.display=l}),null==l&&(c=h.display,l="none"===c?"":c)),h.display="inline-block")),n.overflow&&(h.overflow="hidden",p.always(function(){h.overflow=n.overflow[0],h.overflowX=n.overflow[1],h.overflowY=n.overflow[2]})),u=!1,d)u||(y?"hidden"in y&&(g=y.hidden):y=Y.access(e,"fxshow",{display:l}),o&&(y.hidden=!g),g&&le([e],!0),p.done(function(){for(r in g||le([e]),Y.remove(e,"fxshow"),d)S.style(e,r,d[r])})),u=ct(g?y[r]:0,r,p),r in y||(y[r]=u.start,g&&(u.end=u.start,u.start=0))}],prefilter:function(e,t){t?ft.prefilters.unshift(e):ft.prefilters.push(e)}}),S.speed=function(e,t,n){var r=e&&"object"==typeof e?S.extend({},e):{complete:n||!n&&t||m(e)&&e,duration:e,easing:n&&t||t&&!m(t)&&t};return S.fx.off?r.duration=0:"number"!=typeof r.duration&&(r.duration in S.fx.speeds?r.duration=S.fx.speeds[r.duration]:r.duration=S.fx.speeds._default),null!=r.queue&&!0!==r.queue||(r.queue="fx"),r.old=r.complete,r.complete=function(){m(r.old)&&r.old.call(this),r.queue&&S.dequeue(this,r.queue)},r},S.fn.extend({fadeTo:function(e,t,n,r){return this.filter(ae).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(t,e,n,r){var i=S.isEmptyObject(t),o=S.speed(e,n,r),a=function(){var e=ft(this,S.extend({},t),o);(i||Y.get(this,"finish"))&&e.stop(!0)};return a.finish=a,i||!1===o.queue?this.each(a):this.queue(o.queue,a)},stop:function(i,e,o){var a=function(e){var t=e.stop;delete e.stop,t(o)};return"string"!=typeof i&&(o=e,e=i,i=void 0),e&&this.queue(i||"fx",[]),this.each(function(){var e=!0,t=null!=i&&i+"queueHooks",n=S.timers,r=Y.get(this);if(t)r[t]&&r[t].stop&&a(r[t]);else for(t in r)r[t]&&r[t].stop&&at.test(t)&&a(r[t]);for(t=n.length;t--;)n[t].elem!==this||null!=i&&n[t].queue!==i||(n[t].anim.stop(o),e=!1,n.splice(t,1));!e&&o||S.dequeue(this,i)})},finish:function(a){return!1!==a&&(a=a||"fx"),this.each(function(){var e,t=Y.get(this),n=t[a+"queue"],r=t[a+"queueHooks"],i=S.timers,o=n?n.length:0;for(t.finish=!0,S.queue(this,a,[]),r&&r.stop&&r.stop.call(this,!0),e=i.length;e--;)i[e].elem===this&&i[e].queue===a&&(i[e].anim.stop(!0),i.splice(e,1));for(e=0;e<o;e++)n[e]&&n[e].finish&&n[e].finish.call(this);delete t.finish})}}),S.each(["toggle","show","hide"],function(e,r){var i=S.fn[r];S.fn[r]=function(e,t,n){return null==e||"boolean"==typeof e?i.apply(this,arguments):this.animate(lt(r,!0),e,t,n)}}),S.each({slideDown:lt("show"),slideUp:lt("hide"),slideToggle:lt("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,r){S.fn[e]=function(e,t,n){return this.animate(r,e,t,n)}}),S.timers=[],S.fx.tick=function(){var e,t=0,n=S.timers;for(tt=Date.now();t<n.length;t++)(e=n[t])()||n[t]!==e||n.splice(t--,1);n.length||S.fx.stop(),tt=void 0},S.fx.timer=function(e){S.timers.push(e),S.fx.start()},S.fx.interval=13,S.fx.start=function(){nt||(nt=!0,st())},S.fx.stop=function(){nt=null},S.fx.speeds={slow:600,fast:200,_default:400},S.fn.delay=function(r,e){return r=S.fx&&S.fx.speeds[r]||r,e=e||"fx",this.queue(e,function(e,t){var n=C.setTimeout(e,r);t.stop=function(){C.clearTimeout(n)}})},rt=E.createElement("input"),it=E.createElement("select").appendChild(E.createElement("option")),rt.type="checkbox",v.checkOn=""!==rt.value,v.optSelected=it.selected,(rt=E.createElement("input")).value="t",rt.type="radio",v.radioValue="t"===rt.value;var pt,dt=S.expr.attrHandle;S.fn.extend({attr:function(e,t){return B(this,S.attr,e,t,1<arguments.length)},removeAttr:function(e){return this.each(function(){S.removeAttr(this,e)})}}),S.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return"undefined"==typeof e.getAttribute?S.prop(e,t,n):(1===o&&S.isXMLDoc(e)||(i=S.attrHooks[t.toLowerCase()]||(S.expr.match.bool.test(t)?pt:void 0)),void 0!==n?null===n?void S.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:null==(r=S.find.attr(e,t))?void 0:r)},attrHooks:{type:{set:function(e,t){if(!v.radioValue&&"radio"===t&&A(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(P);if(i&&1===e.nodeType)while(n=i[r++])e.removeAttribute(n)}}),pt={set:function(e,t,n){return!1===t?S.removeAttr(e,n):e.setAttribute(n,n),n}},S.each(S.expr.match.bool.source.match(/\w+/g),function(e,t){var a=dt[t]||S.find.attr;dt[t]=function(e,t,n){var r,i,o=t.toLowerCase();return n||(i=dt[o],dt[o]=r,r=null!=a(e,t,n)?o:null,dt[o]=i),r}});var ht=/^(?:input|select|textarea|button)$/i,gt=/^(?:a|area)$/i;function yt(e){return(e.match(P)||[]).join(" ")}function vt(e){return e.getAttribute&&e.getAttribute("class")||""}function mt(e){return Array.isArray(e)?e:"string"==typeof e&&e.match(P)||[]}S.fn.extend({prop:function(e,t){return B(this,S.prop,e,t,1<arguments.length)},removeProp:function(e){return this.each(function(){delete this[S.propFix[e]||e]})}}),S.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&S.isXMLDoc(e)||(t=S.propFix[t]||t,i=S.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=S.find.attr(e,"tabindex");return t?parseInt(t,10):ht.test(e.nodeName)||gt.test(e.nodeName)&&e.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),v.optSelected||(S.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),S.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){S.propFix[this.toLowerCase()]=this}),S.fn.extend({addClass:function(t){var e,n,r,i,o,a;return m(t)?this.each(function(e){S(this).addClass(t.call(this,e,vt(this)))}):(e=mt(t)).length?this.each(function(){if(r=vt(this),n=1===this.nodeType&&" "+yt(r)+" "){for(o=0;o<e.length;o++)i=e[o],n.indexOf(" "+i+" ")<0&&(n+=i+" ");a=yt(n),r!==a&&this.setAttribute("class",a)}}):this},removeClass:function(t){var e,n,r,i,o,a;return m(t)?this.each(function(e){S(this).removeClass(t.call(this,e,vt(this)))}):arguments.length?(e=mt(t)).length?this.each(function(){if(r=vt(this),n=1===this.nodeType&&" "+yt(r)+" "){for(o=0;o<e.length;o++){i=e[o];while(-1<n.indexOf(" "+i+" "))n=n.replace(" "+i+" "," ")}a=yt(n),r!==a&&this.setAttribute("class",a)}}):this:this.attr("class","")},toggleClass:function(t,n){var e,r,i,o,a=typeof t,s="string"===a||Array.isArray(t);return m(t)?this.each(function(e){S(this).toggleClass(t.call(this,e,vt(this),n),n)}):"boolean"==typeof n&&s?n?this.addClass(t):this.removeClass(t):(e=mt(t),this.each(function(){if(s)for(o=S(this),i=0;i<e.length;i++)r=e[i],o.hasClass(r)?o.removeClass(r):o.addClass(r);else void 0!==t&&"boolean"!==a||((r=vt(this))&&Y.set(this,"__className__",r),this.setAttribute&&this.setAttribute("class",r||!1===t?"":Y.get(this,"__className__")||""))}))},hasClass:function(e){var t,n,r=0;t=" "+e+" ";while(n=this[r++])if(1===n.nodeType&&-1<(" "+yt(vt(n))+" ").indexOf(t))return!0;return!1}});var xt=/\r/g;S.fn.extend({val:function(n){var r,e,i,t=this[0];return arguments.length?(i=m(n),this.each(function(e){var t;1===this.nodeType&&(null==(t=i?n.call(this,e,S(this).val()):n)?t="":"number"==typeof t?t+="":Array.isArray(t)&&(t=S.map(t,function(e){return null==e?"":e+""})),(r=S.valHooks[this.type]||S.valHooks[this.nodeName.toLowerCase()])&&"set"in r&&void 0!==r.set(this,t,"value")||(this.value=t))})):t?(r=S.valHooks[t.type]||S.valHooks[t.nodeName.toLowerCase()])&&"get"in r&&void 0!==(e=r.get(t,"value"))?e:"string"==typeof(e=t.value)?e.replace(xt,""):null==e?"":e:void 0}}),S.extend({valHooks:{option:{get:function(e){var t=S.find.attr(e,"value");return null!=t?t:yt(S.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r<u;r++)if(((n=i[r]).selected||r===o)&&!n.disabled&&(!n.parentNode.disabled||!A(n.parentNode,"optgroup"))){if(t=S(n).val(),a)return t;s.push(t)}return s},set:function(e,t){var n,r,i=e.options,o=S.makeArray(t),a=i.length;while(a--)((r=i[a]).selected=-1<S.inArray(S.valHooks.option.get(r),o))&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),S.each(["radio","checkbox"],function(){S.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=-1<S.inArray(S(e).val(),t)}},v.checkOn||(S.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})}),v.focusin="onfocusin"in C;var bt=/^(?:focusinfocus|focusoutblur)$/,wt=function(e){e.stopPropagation()};S.extend(S.event,{trigger:function(e,t,n,r){var i,o,a,s,u,l,c,f,p=[n||E],d=y.call(e,"type")?e.type:e,h=y.call(e,"namespace")?e.namespace.split("."):[];if(o=f=a=n=n||E,3!==n.nodeType&&8!==n.nodeType&&!bt.test(d+S.event.triggered)&&(-1<d.indexOf(".")&&(d=(h=d.split(".")).shift(),h.sort()),u=d.indexOf(":")<0&&"on"+d,(e=e[S.expando]?e:new S.Event(d,"object"==typeof e&&e)).isTrigger=r?2:3,e.namespace=h.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=n),t=null==t?[e]:S.makeArray(t,[e]),c=S.event.special[d]||{},r||!c.trigger||!1!==c.trigger.apply(n,t))){if(!r&&!c.noBubble&&!x(n)){for(s=c.delegateType||d,bt.test(s+d)||(o=o.parentNode);o;o=o.parentNode)p.push(o),a=o;a===(n.ownerDocument||E)&&p.push(a.defaultView||a.parentWindow||C)}i=0;while((o=p[i++])&&!e.isPropagationStopped())f=o,e.type=1<i?s:c.bindType||d,(l=(Y.get(o,"events")||Object.create(null))[e.type]&&Y.get(o,"handle"))&&l.apply(o,t),(l=u&&o[u])&&l.apply&&V(o)&&(e.result=l.apply(o,t),!1===e.result&&e.preventDefault());return e.type=d,r||e.isDefaultPrevented()||c._default&&!1!==c._default.apply(p.pop(),t)||!V(n)||u&&m(n[d])&&!x(n)&&((a=n[u])&&(n[u]=null),S.event.triggered=d,e.isPropagationStopped()&&f.addEventListener(d,wt),n[d](),e.isPropagationStopped()&&f.removeEventListener(d,wt),S.event.triggered=void 0,a&&(n[u]=a)),e.result}},simulate:function(e,t,n){var r=S.extend(new S.Event,n,{type:e,isSimulated:!0});S.event.trigger(r,null,t)}}),S.fn.extend({trigger:function(e,t){return this.each(function(){S.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return S.event.trigger(e,t,n,!0)}}),v.focusin||S.each({focus:"focusin",blur:"focusout"},function(n,r){var i=function(e){S.event.simulate(r,e.target,S.event.fix(e))};S.event.special[r]={setup:function(){var e=this.ownerDocument||this.document||this,t=Y.access(e,r);t||e.addEventListener(n,i,!0),Y.access(e,r,(t||0)+1)},teardown:function(){var e=this.ownerDocument||this.document||this,t=Y.access(e,r)-1;t?Y.access(e,r,t):(e.removeEventListener(n,i,!0),Y.remove(e,r))}}});var Tt=C.location,Ct={guid:Date.now()},Et=/\?/;S.parseXML=function(e){var t,n;if(!e||"string"!=typeof e)return null;try{t=(new C.DOMParser).parseFromString(e,"text/xml")}catch(e){}return n=t&&t.getElementsByTagName("parsererror")[0],t&&!n||S.error("Invalid XML: "+(n?S.map(n.childNodes,function(e){return e.textContent}).join("\n"):e)),t};var St=/\[\]$/,kt=/\r?\n/g,At=/^(?:submit|button|image|reset|file)$/i,Nt=/^(?:input|select|textarea|keygen)/i;function jt(n,e,r,i){var t;if(Array.isArray(e))S.each(e,function(e,t){r||St.test(n)?i(n,t):jt(n+"["+("object"==typeof t&&null!=t?e:"")+"]",t,r,i)});else if(r||"object"!==w(e))i(n,e);else for(t in e)jt(n+"["+t+"]",e[t],r,i)}S.param=function(e,t){var n,r=[],i=function(e,t){var n=m(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(null==e)return"";if(Array.isArray(e)||e.jquery&&!S.isPlainObject(e))S.each(e,function(){i(this.name,this.value)});else for(n in e)jt(n,e[n],t,i);return r.join("&")},S.fn.extend({serialize:function(){return S.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=S.prop(this,"elements");return e?S.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!S(this).is(":disabled")&&Nt.test(this.nodeName)&&!At.test(e)&&(this.checked||!pe.test(e))}).map(function(e,t){var n=S(this).val();return null==n?null:Array.isArray(n)?S.map(n,function(e){return{name:t.name,value:e.replace(kt,"\r\n")}}):{name:t.name,value:n.replace(kt,"\r\n")}}).get()}});var Dt=/%20/g,qt=/#.*$/,Lt=/([?&])_=[^&]*/,Ht=/^(.*?):[ \t]*([^\r\n]*)$/gm,Ot=/^(?:GET|HEAD)$/,Pt=/^\/\//,Rt={},Mt={},It="*/".concat("*"),Wt=E.createElement("a");function Ft(o){return function(e,t){"string"!=typeof e&&(t=e,e="*");var n,r=0,i=e.toLowerCase().match(P)||[];if(m(t))while(n=i[r++])"+"===n[0]?(n=n.slice(1)||"*",(o[n]=o[n]||[]).unshift(t)):(o[n]=o[n]||[]).push(t)}}function $t(t,i,o,a){var s={},u=t===Mt;function l(e){var r;return s[e]=!0,S.each(t[e]||[],function(e,t){var n=t(i,o,a);return"string"!=typeof n||u||s[n]?u?!(r=n):void 0:(i.dataTypes.unshift(n),l(n),!1)}),r}return l(i.dataTypes[0])||!s["*"]&&l("*")}function Bt(e,t){var n,r,i=S.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&S.extend(!0,e,r),e}Wt.href=Tt.href,S.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Tt.href,type:"GET",isLocal:/^(?:about|app|app-storage|.+-extension|file|res|widget):$/.test(Tt.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":It,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":S.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?Bt(Bt(e,S.ajaxSettings),t):Bt(S.ajaxSettings,e)},ajaxPrefilter:Ft(Rt),ajaxTransport:Ft(Mt),ajax:function(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};var c,f,p,n,d,r,h,g,i,o,y=S.ajaxSetup({},t),v=y.context||y,m=y.context&&(v.nodeType||v.jquery)?S(v):S.event,x=S.Deferred(),b=S.Callbacks("once memory"),w=y.statusCode||{},a={},s={},u="canceled",T={readyState:0,getResponseHeader:function(e){var t;if(h){if(!n){n={};while(t=Ht.exec(p))n[t[1].toLowerCase()+" "]=(n[t[1].toLowerCase()+" "]||[]).concat(t[2])}t=n[e.toLowerCase()+" "]}return null==t?null:t.join(", ")},getAllResponseHeaders:function(){return h?p:null},setRequestHeader:function(e,t){return null==h&&(e=s[e.toLowerCase()]=s[e.toLowerCase()]||e,a[e]=t),this},overrideMimeType:function(e){return null==h&&(y.mimeType=e),this},statusCode:function(e){var t;if(e)if(h)T.always(e[T.status]);else for(t in e)w[t]=[w[t],e[t]];return this},abort:function(e){var t=e||u;return c&&c.abort(t),l(0,t),this}};if(x.promise(T),y.url=((e||y.url||Tt.href)+"").replace(Pt,Tt.protocol+"//"),y.type=t.method||t.type||y.method||y.type,y.dataTypes=(y.dataType||"*").toLowerCase().match(P)||[""],null==y.crossDomain){r=E.createElement("a");try{r.href=y.url,r.href=r.href,y.crossDomain=Wt.protocol+"//"+Wt.host!=r.protocol+"//"+r.host}catch(e){y.crossDomain=!0}}if(y.data&&y.processData&&"string"!=typeof y.data&&(y.data=S.param(y.data,y.traditional)),$t(Rt,y,t,T),h)return T;for(i in(g=S.event&&y.global)&&0==S.active++&&S.event.trigger("ajaxStart"),y.type=y.type.toUpperCase(),y.hasContent=!Ot.test(y.type),f=y.url.replace(qt,""),y.hasContent?y.data&&y.processData&&0===(y.contentType||"").indexOf("application/x-www-form-urlencoded")&&(y.data=y.data.replace(Dt,"+")):(o=y.url.slice(f.length),y.data&&(y.processData||"string"==typeof y.data)&&(f+=(Et.test(f)?"&":"?")+y.data,delete y.data),!1===y.cache&&(f=f.replace(Lt,"$1"),o=(Et.test(f)?"&":"?")+"_="+Ct.guid+++o),y.url=f+o),y.ifModified&&(S.lastModified[f]&&T.setRequestHeader("If-Modified-Since",S.lastModified[f]),S.etag[f]&&T.setRequestHeader("If-None-Match",S.etag[f])),(y.data&&y.hasContent&&!1!==y.contentType||t.contentType)&&T.setRequestHeader("Content-Type",y.contentType),T.setRequestHeader("Accept",y.dataTypes[0]&&y.accepts[y.dataTypes[0]]?y.accepts[y.dataTypes[0]]+("*"!==y.dataTypes[0]?", "+It+"; q=0.01":""):y.accepts["*"]),y.headers)T.setRequestHeader(i,y.headers[i]);if(y.beforeSend&&(!1===y.beforeSend.call(v,T,y)||h))return T.abort();if(u="abort",b.add(y.complete),T.done(y.success),T.fail(y.error),c=$t(Mt,y,t,T)){if(T.readyState=1,g&&m.trigger("ajaxSend",[T,y]),h)return T;y.async&&0<y.timeout&&(d=C.setTimeout(function(){T.abort("timeout")},y.timeout));try{h=!1,c.send(a,l)}catch(e){if(h)throw e;l(-1,e)}}else l(-1,"No Transport");function l(e,t,n,r){var i,o,a,s,u,l=t;h||(h=!0,d&&C.clearTimeout(d),c=void 0,p=r||"",T.readyState=0<e?4:0,i=200<=e&&e<300||304===e,n&&(s=function(e,t,n){var r,i,o,a,s=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}(y,T,n)),!i&&-1<S.inArray("script",y.dataTypes)&&S.inArray("json",y.dataTypes)<0&&(y.converters["text script"]=function(){}),s=function(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o]))for(i in l)if((s=i.split(" "))[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}if(!0!==a)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}(y,s,T,i),i?(y.ifModified&&((u=T.getResponseHeader("Last-Modified"))&&(S.lastModified[f]=u),(u=T.getResponseHeader("etag"))&&(S.etag[f]=u)),204===e||"HEAD"===y.type?l="nocontent":304===e?l="notmodified":(l=s.state,o=s.data,i=!(a=s.error))):(a=l,!e&&l||(l="error",e<0&&(e=0))),T.status=e,T.statusText=(t||l)+"",i?x.resolveWith(v,[o,l,T]):x.rejectWith(v,[T,l,a]),T.statusCode(w),w=void 0,g&&m.trigger(i?"ajaxSuccess":"ajaxError",[T,y,i?o:a]),b.fireWith(v,[T,l]),g&&(m.trigger("ajaxComplete",[T,y]),--S.active||S.event.trigger("ajaxStop")))}return T},getJSON:function(e,t,n){return S.get(e,t,n,"json")},getScript:function(e,t){return S.get(e,void 0,t,"script")}}),S.each(["get","post"],function(e,i){S[i]=function(e,t,n,r){return m(t)&&(r=r||n,n=t,t=void 0),S.ajax(S.extend({url:e,type:i,dataType:r,data:t,success:n},S.isPlainObject(e)&&e))}}),S.ajaxPrefilter(function(e){var t;for(t in e.headers)"content-type"===t.toLowerCase()&&(e.contentType=e.headers[t]||"")}),S._evalUrl=function(e,t,n){return S.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(e){S.globalEval(e,t,n)}})},S.fn.extend({wrapAll:function(e){var t;return this[0]&&(m(e)&&(e=e.call(this[0])),t=S(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstElementChild)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(n){return m(n)?this.each(function(e){S(this).wrapInner(n.call(this,e))}):this.each(function(){var e=S(this),t=e.contents();t.length?t.wrapAll(n):e.append(n)})},wrap:function(t){var n=m(t);return this.each(function(e){S(this).wrapAll(n?t.call(this,e):t)})},unwrap:function(e){return this.parent(e).not("body").each(function(){S(this).replaceWith(this.childNodes)}),this}}),S.expr.pseudos.hidden=function(e){return!S.expr.pseudos.visible(e)},S.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},S.ajaxSettings.xhr=function(){try{return new C.XMLHttpRequest}catch(e){}};var _t={0:200,1223:204},zt=S.ajaxSettings.xhr();v.cors=!!zt&&"withCredentials"in zt,v.ajax=zt=!!zt,S.ajaxTransport(function(i){var o,a;if(v.cors||zt&&!i.crossDomain)return{send:function(e,t){var n,r=i.xhr();if(r.open(i.type,i.url,i.async,i.username,i.password),i.xhrFields)for(n in i.xhrFields)r[n]=i.xhrFields[n];for(n in i.mimeType&&r.overrideMimeType&&r.overrideMimeType(i.mimeType),i.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest"),e)r.setRequestHeader(n,e[n]);o=function(e){return function(){o&&(o=a=r.onload=r.onerror=r.onabort=r.ontimeout=r.onreadystatechange=null,"abort"===e?r.abort():"error"===e?"number"!=typeof r.status?t(0,"error"):t(r.status,r.statusText):t(_t[r.status]||r.status,r.statusText,"text"!==(r.responseType||"text")||"string"!=typeof r.responseText?{binary:r.response}:{text:r.responseText},r.getAllResponseHeaders()))}},r.onload=o(),a=r.onerror=r.ontimeout=o("error"),void 0!==r.onabort?r.onabort=a:r.onreadystatechange=function(){4===r.readyState&&C.setTimeout(function(){o&&a()})},o=o("abort");try{r.send(i.hasContent&&i.data||null)}catch(e){if(o)throw e}},abort:function(){o&&o()}}}),S.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),S.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return S.globalEval(e),e}}}),S.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),S.ajaxTransport("script",function(n){var r,i;if(n.crossDomain||n.scriptAttrs)return{send:function(e,t){r=S("<script>").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var Ut,Xt=[],Vt=/(=)\?(?=&|$)|\?\?/;S.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Xt.pop()||S.expando+"_"+Ct.guid++;return this[e]=!0,e}}),S.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Vt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Vt.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Vt,"$1"+r):!1!==e.jsonp&&(e.url+=(Et.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||S.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?S(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Xt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),v.createHTMLDocument=((Ut=E.implementation.createHTMLDocument("").body).innerHTML="<form></form><form></form>",2===Ut.childNodes.length),S.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(v.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=N.exec(e))?[t.createElement(i[1])]:(i=xe([e],t,o),o&&o.length&&S(o).remove(),S.merge([],i.childNodes)));var r,i,o},S.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1<s&&(r=yt(e.slice(s)),e=e.slice(0,s)),m(t)?(n=t,t=void 0):t&&"object"==typeof t&&(i="POST"),0<a.length&&S.ajax({url:e,type:i||"GET",dataType:"html",data:t}).done(function(e){o=arguments,a.html(r?S("<div>").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return B(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=_e(v.pixelPosition,function(e,t){if(t)return t=Be(e,n),Pe.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return B(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0<arguments.length?this.on(n,null,e,t):this.trigger(n)}});var Gt=/^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;S.proxy=function(e,t){var n,r,i;if("string"==typeof t&&(n=e[t],t=e,e=n),m(e))return r=s.call(arguments,2),(i=function(){return e.apply(t||this,r.concat(s.call(arguments)))}).guid=e.guid=e.guid||S.guid++,i},S.holdReady=function(e){e?S.readyWait++:S.ready(!0)},S.isArray=Array.isArray,S.parseJSON=JSON.parse,S.nodeName=A,S.isFunction=m,S.isWindow=x,S.camelCase=X,S.type=w,S.now=Date.now,S.isNumeric=function(e){var t=S.type(e);return("number"===t||"string"===t)&&!isNaN(e-parseFloat(e))},S.trim=function(e){return null==e?"":(e+"").replace(Gt,"$1")},"function"==typeof define&&define.amd&&define("jquery",[],function(){return S});var Yt=C.jQuery,Qt=C.$;return S.noConflict=function(e){return C.$===S&&(C.$=Qt),e&&C.jQuery===S&&(C.jQuery=Yt),S},"undefined"==typeof e&&(C.jQuery=C.$=S),S}); diff --git a/config/js/webhooks.js b/config/js/webhooks.js index 905ed2b8..de4a3608 100644 --- a/config/js/webhooks.js +++ b/config/js/webhooks.js @@ -6,21 +6,20 @@ var Webhooks = { init: function () { // prettier-ignore var markup = [ - "<div class='webhooks'>", - "<div class='title'>Webhooks</div>", - "<div class='row' id='webhooksParent'/>", - "<div class='row' id='addNewWebhook'>", - "<a class='btn waves-effect col s3 push-s9' style='color: black; background: white;'>Add Webhook<i class='mdi mdi-plus mdi-24px' style='float: right; margin-top: 1px;'></i></a>", - "</div>", - "<div class='row'>", - "<a class='btn waves-effect waves-light light-green darken-3 col s1 push-s9' id='saveWebhookChanges' style='text-align: left; padding: 0; padding-left: 10px; line-height: 37px; width: 220px; border-radius: 0px; position: fixed; bottom: 10px; right: 10px; z-index: 21; background: #1565C0 !important;'>", - "Save Changes", - "<i class='mdi mdi-content-save mdi-24px' style='position: absolute; right: 7px; margin-top: -2px;'/>", - "</a>", - "</div>", - - "</div>" - ].join('\n'); + "<div class='webhooks'>", + "<div class='title'>Webhooks</div>", + "<div class='row' id='webhooksParent'/>", + "<div class='row' id='addNewWebhook'>", + "<a class='btn waves-effect col s3 push-s9' style='color: black; background: white;'>Add Webhook<i class='mdi mdi-plus mdi-24px' style='float: right; margin-top: 1px;'></i></a>", + "</div>", + "<div class='row'>", + "<a class='btn waves-effect waves-light light-green darken-3 col s1 push-s9' id='saveWebhookChanges' style='text-align: left; padding: 0; padding-left: 10px; line-height: 37px; width: 220px; border-radius: 0px; position: fixed; bottom: 10px; right: 10px; z-index: 21; background: #1565C0 !important;'>", + "Save Changes", + "<i class='mdi mdi-content-save mdi-24px' style='position: absolute; right: 7px; margin-top: -2px;'></i>", + "</a>", + "</div>", + "</div>" + ].join('\n'); $(".container_webhooks").html(markup); @@ -127,7 +126,7 @@ function makeWebhookCard(data) { "</li>" + "<li class='row'>" + "<div class='inject-label input-field col s9' id='webhookUrlEl'>" + - "<label>Valid injectable variables for URL and Body fields: {file_id}, {file_name}, {geojson}</label>" + + "<label>Valid injectable variables for URL and Body fields: {file_id}, {file_name}, {file_owner}, {geojson}</label>" + "</div>" + "<div class='col s3 push-s1' id='deleteWebhook_" + webhooksCounter +"'>" + "<a class='btn waves-effect' style='color: black; background: white;'>Delete<i class='mdi mdi-delete mdi-24px' style='float: right; margin-top: 1px;'></i></a>" + @@ -203,7 +202,7 @@ function saveWebhookChanges() { var json = { webhooks: [] }; $("#webhooksParent") - .children("div") + .find(".card") .each(function () { var webhookId = $(this).attr("webhookId"); var action = $(this).find("#webhookAction").val(); @@ -226,7 +225,6 @@ function saveWebhookChanges() { body, }); }); - saveWebhookConfig(json); } diff --git a/config/js/websocket.js b/config/js/websocket.js new file mode 100644 index 00000000..e582fdb4 --- /dev/null +++ b/config/js/websocket.js @@ -0,0 +1,69 @@ +const Websocket = { + initialWebSocketRetryInterval: 60000, // 1 minute + webSocketRetryInterval: 60000, // Start with this time and double if disconnected + webSocketPingInterval: null, + init: function () { + if (typeof window.setLockConfig === "function") + window.clearLockConfig("disconnect"); + + const port = parseInt(window.mmgisglobal.PORT || "8888", 10); + const protocol = + window.location.protocol.indexOf("https") !== -1 ? "wss" : "ws"; + + const path = + window.mmgisglobal.NODE_ENV === "development" + ? `${protocol}://localhost:${port}${ + window.mmgisglobal.WEBSOCKET_ROOT_PATH || + window.mmgisglobal.ROOT_PATH || + "" + }/` + : `${protocol}://${window.location.host}${ + window.mmgisglobal.WEBSOCKET_ROOT_PATH || + window.mmgisglobal.ROOT_PATH || + "" + }/`; + + // Create WebSocket connection. + const socket = new WebSocket(path); + + // Connection opened + socket.addEventListener("open", (event) => { + Websocket.webSocketRetryInterval = + Websocket.initialWebSocketRetryInterval; + clearInterval(Websocket.webSocketPingInterval); + }); + + // Listen for messages + socket.addEventListener("message", (event) => { + try { + const data = JSON.parse(event.data); + if ( + data?.info?.route === "config" && + parseInt(data?.info?.id || -1) !== window.configId && + data?.info?.mission === window.mission + ) { + if (typeof window.setLockConfig === "function") + window.setLockConfig(); + } + } catch (err) {} + }); + + socket.addEventListener("close", (event) => { + if (typeof window.setLockConfig === "function") + window.setLockConfig("disconnect"); + + clearInterval(Websocket.webSocketPingInterval); + Websocket.webSocketPingInterval = setInterval( + Websocket.init, + Websocket.webSocketRetryInterval + ); // 1 minute + Websocket.webSocketRetryInterval *= 2; + }); + }, +}; + +if ( + mmgisglobal.ENABLE_CONFIG_WEBSOCKETS === "true" || + mmgisglobal.ENABLE_CONFIG_WEBSOCKETS === true +) + Websocket.init(); diff --git a/config/login/adminlogin.css b/config/login/adminlogin.css index a7d36612..bdd6ff1b 100644 --- a/config/login/adminlogin.css +++ b/config/login/adminlogin.css @@ -1,11 +1,6 @@ -@font-face { - font-family: "Source Sans Pro"; - src: url(/public/fonts/sourcesanspro/SourceSansPro-Regular.ttf); -} - body, html { - font-family: "Source Sans Pro", sans-serif; + font-family: sans-serif; background-color: #1a1a1a; padding: 0; margin: 0; @@ -27,7 +22,7 @@ html { } .box h4 { - font-family: "Source Sans Pro", sans-serif; + font-family: sans-serif; color: #08aeea; font-size: 18px; margin-top: 94px; @@ -39,7 +34,7 @@ html { } .box h5 { - font-family: "Source Sans Pro", sans-serif; + font-family: sans-serif; font-size: 13px; color: #a1a4ad; letter-spacing: 1.5px; @@ -94,7 +89,7 @@ a:hover { cursor: pointer; text-align: center; user-select: none; - font-family: "Source Sans Pro", sans-serif; + font-family: sans-serif; line-height: 49px; } diff --git a/config/login/adminlogin.js b/config/login/adminlogin.js index e78e1284..e46638ff 100644 --- a/config/login/adminlogin.js +++ b/config/login/adminlogin.js @@ -98,14 +98,6 @@ function setupLogin() { }); } -// Is used in views/configure.pug -function back() { - window.location = window.location.substring( - 0, - window.location.lastIndexOf("/") - ); -} - $(document).ready(function () { $(document).on("keypress", function (e) { if (e.which == 13) { @@ -132,6 +124,8 @@ $(document).ready(function () { }); $("#backIcon").on("click", function () { - window.location.href = "/"; + // Remove last directory from pathname + const path = window.location.pathname.split("/"); + window.location.href = path.slice(0, path.length - 1).join("/") || "/"; }); }); diff --git a/config/pre/RefreshAuth.js b/config/pre/RefreshAuth.js new file mode 100644 index 00000000..c2449447 --- /dev/null +++ b/config/pre/RefreshAuth.js @@ -0,0 +1,117 @@ +//function from https://stackoverflow.com/questions/6312993/javascript-seconds-to-time-string-with-format-hhmmss +String.prototype.toHHMMSS = function () { + var sec_num = parseInt(this, 10) // don't forget the second param + var hours = Math.floor(sec_num / 3600) + var minutes = Math.floor((sec_num - hours * 3600) / 60) + var seconds = sec_num - hours * 3600 - minutes * 60 + + if (hours < 10) { + hours = '0' + hours + } + if (minutes < 10) { + minutes = '0' + minutes + } + if (seconds < 10) { + seconds = '0' + seconds + } + return hours + ':' + minutes + ':' + seconds +} + +//set interval that checks valid sso +//every 4:30min checks if the token will expire in less than 5min +//refreshes if the user moved their mouse in the past 20min +if (mmgisglobal.SERVER == 'node' && mmgisglobal.AUTH == 'csso') { + console.log( + '%cAUTH_REFRESH ON', + 'background: #006280; padding: 0px 4px 0px 4px;' + ) + //Add your own login/logout redirects + function ssologout() { + window.location.href = '/ssologoutredirect' + } + function ssologin() { + window.location.href = + '/ssologinredirect?redirect=' + window.location.href + } + + mmgisglobal.lastInteraction = Math.floor(Date.now() / 1000) + var _refreshAuth_checkEvery = 60000 * 10 //milliseconds + var _refreshAuth_expiringLessThan = 60 * 11 //seconds + var _refreshAuth_interactedPast = 60000 * 30 //milliseconds + + function ssorefresh() { + var request = new XMLHttpRequest() + request.open('Post', '/ssostatus', true) + request.onload = function () { + if (request.status >= 200 && request.status < 400) { + var result = request.responseText + result = JSON.parse(result) + + var now = Math.floor(Date.now() / 1000) + + if (mmgisglobal.SHOW_AUTH_TIMEOUT) { + var append = false + + var elm = document.getElementById('AUTH_TIMEOUT') + if (elm == null) { + elm = document.createElement('div') + append = true + } + elm.id = 'AUTH_TIMEOUT' + elm.style.cssText = + 'position:fixed;left:225px;bottom:0px;z-index:11000;font-family:monospace;font-size:11px;color:#121626;' + elm.innerHTML = + 'Authentication expiring in ' + + (result.exp - now).toString().toHHMMSS() + + '<div onclick="ssologin()" style="cursor:pointer;">Login again to renew</div>' + + if (append) document.body.appendChild(elm) + } + + if (result.authenticated) { + if ( + mmgisglobal.lastInteraction + + _refreshAuth_interactedPast <= + now + ) { + ssologout() + } else if ( + now + _refreshAuth_expiringLessThan >= + result.inactivity_timeout + ) { + var refresh = new XMLHttpRequest() + refresh.open('Post', '/ssorefreshtimeout', true) + refresh.onload = function () { + if (refresh.status >= 200 && refresh.status < 400) { + var result = refresh.responseText + result = JSON.parse(result) + if (!result.success) { + ssologout() + } + } else { + ssologout() + } + } + refresh.onerror = function () { + ssologout() + } + refresh.send() + } + } else { + ssologout() + } + } else { + ssologout() + } + } + + request.onerror = function () { + ssologout() + } + + request.send() + } + + ssorefresh() + setInterval(ssorefresh, _refreshAuth_checkEvery) +} diff --git a/configuration/env.js b/configuration/env.js index ca8084f3..12089203 100644 --- a/configuration/env.js +++ b/configuration/env.js @@ -78,6 +78,14 @@ function getClientEnvironment(publicUrl) { // This should only be used as an escape hatch. Normally you would put // images into the `src` and `import` them in code to get their paths. PUBLIC_URL: publicUrl, + ROOT_PATH: + (process.env.NODE_ENV || "development") === "development" + ? "" + : process.env.ROOT_PATH || "", + WEBSOCKET_ROOT_PATH: + (process.env.NODE_ENV || "development") === "development" + ? "" + : process.env.WEBSOCKET_ROOT_PATH || "", // We support configuring the sockjs pathname during development. // These settings let a developer run multiple simultaneous projects. // They are used as the connection `hostname`, `pathname` and `port` @@ -95,6 +103,9 @@ function getClientEnvironment(publicUrl) { }), PORT: process.env.PORT, ENABLE_MMGIS_WEBSOCKETS: process.env.ENABLE_MMGIS_WEBSOCKETS, + MAIN_MISSION: process.env.MAIN_MISSION, + THIRD_PARTY_COOKIES: process.env.THIRD_PARTY_COOKIES || "", + SKIP_CLIENT_INITIAL_LOGIN: process.env.SKIP_CLIENT_INITIAL_LOGIN || "", } ); // Stringify all values so we can feed into webpack DefinePlugin diff --git a/configuration/paths.js b/configuration/paths.js index 3af4da84..73716ede 100644 --- a/configuration/paths.js +++ b/configuration/paths.js @@ -20,7 +20,7 @@ const publicUrlOrPath = getPublicUrlOrPath( process.env.NODE_ENV === "development" ? null : require(resolveApp("package.json")).homepage, - process.env.PUBLIC_URL + "./build" // Force process.env.PUBLIC_URL ); const moduleFileExtensions = [ diff --git a/configuration/webpack.config.js b/configuration/webpack.config.js index 3249b1b6..e95fe994 100644 --- a/configuration/webpack.config.js +++ b/configuration/webpack.config.js @@ -24,13 +24,20 @@ const getClientEnvironment = require("./env"); const ModuleNotFoundPlugin = require("react-dev-utils/ModuleNotFoundPlugin"); const ForkTsCheckerWebpackPlugin = require("react-dev-utils/ForkTsCheckerWebpackPlugin"); const typescriptFormatter = require("react-dev-utils/typescriptFormatter"); -const BundleAnalyzerPlugin = - require("webpack-bundle-analyzer").BundleAnalyzerPlugin; +const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); const postcssNormalize = require("postcss-normalize"); const appPackageJson = require(paths.appPackageJson); +// This is a hack so that node v18+ can run. +// "md4" hashes are no longer supported so before everything runs, we override them to be "sha256" +const crypto = require("crypto"); +const crypto_orig_createHash = crypto.createHash; +crypto.createHash = (algorithm) => + crypto_orig_createHash(algorithm === "md4" ? "sha256" : algorithm); +// end hack + // Source maps are resource heavy and can cause out of memory issue for large source files. const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== "false"; // Some apps do not need the benefits of saving a web request, so not inlining the chunk @@ -86,11 +93,11 @@ module.exports = function (webpackEnv) { : { publicPath: paths.publicUrlOrPath }, }, isEnvProduction && - process.env.PUBLIC_URL && { + { loader: "string-replace-loader", options: { search: /url\(\/public\//g, - replace: `url(${process.env.PUBLIC_URL}/`, + replace: `url(../../../public/`, }, }, { diff --git a/docker-compose-env.yml b/docker-compose-env.yml new file mode 100644 index 00000000..751d6f46 --- /dev/null +++ b/docker-compose-env.yml @@ -0,0 +1,38 @@ +version: "3" +services: + mmgis: + image: mmgis:development + depends_on: + - mmgis.db + environment: + - SERVER=node + - PORT=8888 + - AUTH=none + - NODE_ENV=development + - SECRET= + - VERBOSE_LOGGING=false + - DB_HOST=localhost + - DB_PORT=5432 + - DB_NAME=MMGIS + - DB_USER=postgres + - DB_PASS=somethingsimple + - HIDE_CONFIG=false + - CONFIGCONFIG_PATH= + - FORCE_CONFIG_PATH= + - FRAME_ANCESTORS= + - FRAME_SRC= + - LEADS=["ADMIN"] + - ENABLE_MMGIS_WEBSOCKETS=true + - ENABLE_CONFIG_WEBSOCKETS=true + - ENABLE_CONFIG_OVERRIDE=false + - MAIN_MISSION= + volumes: + - /var/www/html/Missions/:/usr/src/app/Missions + mmgis.db: + image: postgis/postgis:10-2.5-alpine + env_file: .env + ports: + - 5432:5432 + restart: on-failure + volumes: + - mmgis-db:/var/lib/postgresql/data diff --git a/docs/_config.yml b/docs/_config.yml index 49c41a94..5bf8d9ba 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -32,6 +32,10 @@ remote_theme: pmarsceill/just-the-docs color_scheme: dark plugins: - jekyll-feed +# Aux links for the upper right navigation +aux_links: + "MMGIS on GitHub": + - "https://github.com/NASA-AMMOS/MMGIS" # Exclude from processing. # The following items will not be processed, by default. # Any item listed under the `exclude:` key here will be automatically added to diff --git a/docs/pages/APIs/Backend/Backend.md b/docs/pages/APIs/Backend/Backend.md new file mode 100644 index 00000000..c79b6b80 --- /dev/null +++ b/docs/pages/APIs/Backend/Backend.md @@ -0,0 +1,116 @@ +--- +layout: page +title: Backend API +permalink: /apis/backend +has_children: false +nav_order: 4 +parent: APIs +--- + +An incomplete list of supported backend endpoints. See more in [Configure REST API](/MMGIS/apis/configure). + +## Users Endpoints + +### POST /api/users/login + +### POST /api/users/signup + +--- + +### GET /api/users/logged_in + +Checks whether a user is currently logged in to the current client's session. Uses cookie token. + +#### Parameters + +_NONE_ + +#### Returns + +##### If logged in _(200)_: + +```javascript +{ + status: "success", + message: `'{user}' is logged in to this session.`, + body: { + loggedIn: true, + user: `{user}` + } +} +``` + +##### If **not** logged in _(200)_: + +```javascript +{ + status: "failure", + message: `No user is logged in to this session.`, + body: { + loggedIn: false, + user: null + } +} +``` + +--- + +### POST /api/users/logout + +## Utility Endpoints + +### POST /api/utils/getbands + +### POST /api/utils/getprofile + +### GET /api/utils/queryTilesetTimes + +## Draw Endpoints + +### POST /api/draw/add + +### POST /api/draw/edit + +### POST /api/draw/remove + +### POST /api/draw/undo + +### POST /api/draw/merge + +### POST /api/draw/split + +## Files Endpoints + +### POST /api/files/getfiles + +### POST /api/files/getfile + +### POST /api/files/make + +### POST /api/files/remove + +### POST /api/files/restore + +### POST /api/files/change + +### POST /api/files/modifykeyword + +### GET /api/files/compile + +### POST /api/files/publish + +### POST /api/files/gethistory + +## URL Shortener Endpoints + +### POST /api/shortener/shorten + +### POST /api/shortener/expand + +## Geo/Datasets Endpoints + +### POST /api/datasets/get + +### POST /api/geodatasets/get + +### POST /api/geodatasets/search diff --git a/docs/pages/APIs/Configure/Configure_REST_API.md b/docs/pages/APIs/Configure/Configure_REST_API.md index dc277523..e1ceb3c9 100644 --- a/docs/pages/APIs/Configure/Configure_REST_API.md +++ b/docs/pages/APIs/Configure/Configure_REST_API.md @@ -45,10 +45,32 @@ To use the Configure API through HTTP requests, an API Token must be used for au Gets a list of all configured missions. _Auth token not needed._ +| Parameter | Type | Required | Default | Description | +| :-------: | :-------: | :------: | :-----: | :-------------------------------------------------------------------------: | +| **full** | _boolean_ | false | N/A | If true, returns versions and configuration objects alongside mission names | + #### Example `curl -X GET http://localhost:8889/api/configure/missions` +```javascript +=> {status: "success", missions: ["Mission1", "Mission2"]} +``` + +`curl -X GET http://localhost:8889/api/configure/missions?full=true` + +```javascript +=> { + status: "success", + missions: [ + { + mission: "name", version: 99, config: {} + }, + ... + ] +} +``` + --- ### GET /versions @@ -111,13 +133,13 @@ Sets a mission's configuration object. Only complete configuration objects are a Adds a single layer to a mission's configuration object. A wrapping helper to `upsert`. -| Parameter | Type | Required | Default | Description | -| :-------------------: | :-------: | :------: | :-----: | :----------------------------------------------------------------------------------------------------------------: | -| **mission** | _string_ | true | N/A | Mission name | -| **layer** | _object_ | true | N/A | Full new layer configuration object. See browser console-network tab responses for examples. | -| **placement.path** | _string_ | false | '' | A path to a header in 'layers' to place the new layer. A simple path ('sublayers' are added). Defaults to no group | -| **placement.index** | _number_ | false | end | Index in 'layers' (or path) to place the new layer. Out of range placement indices are best fit. | -| **forceClientUpdate** | _boolean_ | false | false | Push the change out to clients. | +| Parameter | Type | Required | Default | Description | +| :-------------------: | :-----------------: | :------: | :-----: | :-------------------------------------------------------------------------------------------------------------------------------------------: | +| **mission** | _string_ | true | N/A | Mission name | +| **layer** | _object_ or _array_ | true | N/A | Full new layer configuration object or array of full new layer configuration objects. See browser console-network tab responses for examples. | +| **placement.path** | _string_ | false | '' | A path to a header in 'layers' to place the new layer. A simple path ('sublayers' are added). Defaults to no group | +| **placement.index** | _number_ | false | end | Index in 'layers' (or path) to place the new layer. Out of range placement indices are best fit. | +| **forceClientUpdate** | _boolean_ | false | false | Push the change out to clients. | #### Example @@ -132,7 +154,7 @@ Updates a single layer. Specified layer values are deep merged and overwrite exi | Parameter | Type | Required | Default | Description | | :-------------------: | :-------: | :------: | :-----: | :----------------------------------------------------------------------------------------------------------------: | | **mission** | _string_ | true | N/A | Mission name | -| **layerName** | _string_ | true | N/A | Layer to update | +| **layerUUID** | _string_ | true | N/A | Layer to update | | **layer** | _object_ | true | N/A | A partial layer configuration object. See browser console-network tab responses for examples. | | **placement.path** | _string_ | false | '' | A path to a header in 'layers' to place the new layer. A simple path ('sublayers' are added). Defaults to no group | | **placement.index** | _number_ | false | end | Index in 'layers' (or path) to place the new layer. Out of range placement indices are best fit. | @@ -140,7 +162,7 @@ Updates a single layer. Specified layer values are deep merged and overwrite exi #### Example -`curl -X POST -H "Authorization:Bearer <token>" -H "Content-Type: application/json" -d '{"mission":"Test", "layerName":"name", "layer":{}}' http://localhost:8889/api/configure/updateLayer` +`curl -X POST -H "Authorization:Bearer <token>" -H "Content-Type: application/json" -d '{"mission":"Test", "layerUUID":"uuid", "layer":{}}' http://localhost:8889/api/configure/updateLayer` --- @@ -148,15 +170,15 @@ Updates a single layer. Specified layer values are deep merged and overwrite exi Removes a single layer from the configuration object. -| Parameter | Type | Required | Default | Description | -| :-------------------: | :-------: | :------: | :-----: | :-----------------------------: | -| **mission** | _string_ | true | N/A | Mission name | -| **layerName** | _string_ | true | N/A | Layer to update | -| **forceClientUpdate** | _boolean_ | false | false | Push the change out to clients. | +| Parameter | Type | Required | Default | Description | +| :-------------------: | :-----------------: | :------: | :-----: | :--------------------------------------------------------------: | +| **mission** | _string_ | true | N/A | Mission name | +| **layerUUID** | _string_ or _array_ | true | N/A | Layer to remove as string or array of layers as string to remove | +| **forceClientUpdate** | _boolean_ | false | false | Push the change out to clients. | #### Example -`curl -X POST -H "Authorization:Bearer <token>" -H "Content-Type: application/json" -d '{"mission":"Test", "layerName":"name"}' http://localhost:8889/api/configure/removeLayer` +`curl -X POST -H "Authorization:Bearer <token>" -H "Content-Type: application/json" -d '{"mission":"Test", "layerUUID":"name"}' http://localhost:8889/api/configure/removeLayer` --- diff --git a/docs/pages/APIs/JavaScript/JavaScript.md b/docs/pages/APIs/JavaScript/JavaScript.md new file mode 100644 index 00000000..c2764e8f --- /dev/null +++ b/docs/pages/APIs/JavaScript/JavaScript.md @@ -0,0 +1,8 @@ +--- +layout: page +title: JavaScript API +permalink: /apis/javascript +has_children: true +nav_order: 4 +parent: APIs +--- diff --git a/docs/pages/APIs/JavaScript/JavaScript_API.md b/docs/pages/APIs/JavaScript/Main/Main.md similarity index 64% rename from docs/pages/APIs/JavaScript/JavaScript_API.md rename to docs/pages/APIs/JavaScript/Main/Main.md index 9016c1ef..a1610a7c 100644 --- a/docs/pages/APIs/JavaScript/JavaScript_API.md +++ b/docs/pages/APIs/JavaScript/Main/Main.md @@ -1,23 +1,185 @@ --- layout: page -title: JavaScript API +title: Main permalink: /apis/javascript -parent: APIs +parent: JavaScript API +grand_parent: APIs --- # JavaScript API The `src/essence/mmgisAPI/mmgisAPI.js` file exposes functions that can be called using the global `window.mmgisAPI` object. +#### _Contents_ + +- [Layer Control](#layer-control) + - [addLayer(layerObj, placement)](#addlayerlayerobj-placement) + - [removeLayer(layerUUID)](#removelayerlayeruuid) + - [clearVectorLayer(layerUUID)](#clearvectorlayerlayeruuid) + - [updateVectorLayer(layerUUID, inputData)](#updatevectorlayerlayeruuid-inputdata) + - [trimVectorLayerKeepBeforeTime(layerUUID, keepBeforeTime, timePropPath)](#trimvectorlayerkeepbeforetimelayeruuid-keepbeforetime-timeproppath) + - [trimVectorLayerKeepAfterTime(layerUUID, keepBeforeTime, timePropPath)](#trimvectorlayerkeepaftertimelayeruuid-keepbeforetime-timeproppath) + - [keepFirstN(layerUUID, keepLastN)](#keepfirstnlayeruuid-keeplastn) + - [keepLastN(layerUUID, keepLastN)](#keeplastnlayeruuid-keeplastn) + - [trimLineString(layerUUID, time, timeProp, trimN, startOrEnd)](#trimlinestringlayeruuid-time-timeprop-trimn-startorend) + - [appendLineString(layerUUID, inputData, timeProp)](#appendlinestringlayeruuid-inputdata-timeprop) + - [reloadLayer(layer, evenIfOff, evenIfControlled)](#reloadlayerlayer-evenifoff-evenifcontrolled) + - [asLayerUUID(uuid)](#asLayerUUIDuuid) +- [Time Control](#time-control) + - [toggleTimeUI(visibility)](#toggletimeuivisibility) + - [setTime(startTime, endTime, isRelative, timeOffset, currentTime)](#settimestarttime-endtime-isrelative-timeoffset-currenttime) + - [setLayerTime(layer, startTime, endTime)](#setlayertimelayer-starttime-endtime) + - [getTime()](#gettime) + - [getStartTime()](#getstarttime) + - [getEndTime()](#getendtime) + - [getLayerStartTime(layer)](#getlayerstarttimelayer) + - [getLayerEndTime(layer)](#getlayerendtimelayer) + - [reloadTimeLayers()](#reloadtimelayers) + - [setLayersTimeStatus(color)](#setlayerstimestatuscolor) + - [setLayerTimeStatus(layer, color)](#setlayertimestatuslayer-color) + - [updateLayersTime()](#updatelayerstime) +- [Event Listeners](#event-listeners) + - [addEventListener(eventName, functionReference)](#addeventlistenereventname-functionreference) + - [removeEventListener(eventName, functionReference)](#removeeventlistenereventname-functionreference) +- [Map Feature Information](#map-feature-information) + - [map](#map) + - [featuresContained()](#featurescontained) + - [getActiveFeature()](#getactivefeature) + - [selectFeature(layerUUID, options)](#selectfeaturelayeruuid-options) + - [getVisibleLayers()](#getvisiblelayers) + - [getLayers()](#getlayers) + - [getLayerConfigs(match)](#getlayerconfigsmatch) + - [toggleLayer(layerUUID, on)](#toggleLayerlayeruuid-on) +- [Miscellaneous Features](#miscellaneous-features) + - [writeCoordinateURL()](#writecoordinateurl) + - [onLoaded(onLoadCallback)](#onloadedonloadcallback) + - [getActiveTool()](#getactivetool) + - [setLoginToken(username, token)](#setlogintoken) + - [project(lnglat)](#projectlnglat) + - [unproject(xy)](#unprojectxy) + +--- + ## Layer Control -### clearVectorLayer(layerName) +### addLayer(layerObj, placement) + +Adds a layer to the map. This adds a layer to client as if it were coming from the configuration. This layer becomes accessible via the LayersTool and well as on the globe. This does not add the layer to the mission's configuration. + +For a more "temporary" layer, use Leaflet directly through `L.{leafletLayer}.addTo(mmgisAPI.map)`. See [here](https://leafletjs.com/reference.html) for reference on how to construct Leafletjs layers. + +#### Function parameters + +- `layerObj` - the full mmgis layer object configuration (`GET http://localhost:8889/api/configure/get?mission={mission}` to get sample layer objects from the existing configuration). At minimum `layerObj.name` and `layerObj.type` are required. + - `layerObj.name` - A unique name/uuid for the layer + - `layerObj.type` - One of the support MMGIS layer types: `data, header, model, query, tile, or vector` +- `placement` - _optionaL_ - Where in the list/tree to add this layer relative to other layers. + - `placement.path` - A path to a header in 'layers' to place the new layer. A simple path ('sublayers' are added). Defaults to no group. Use a dot-notated string for nestings. + - `placement.index` - Index in 'layers' (or path) to place the new layer. Out of range placement indices are best fit. + +Returns a `Promise` when the layer is added and loaded. + +The following is an example of how to call the `addLayer` function: + +```javascript +window.mmgisAPI.addLayer({ name: "Sample Header", type: "header" }).then(() => { + console.log("added and loaded"); +}); + +window.mmgisAPI + .addLayer( + { + name: "New Waypoints", + kind: "waypoint", + shape: "none", + type: "vector", + url: "Layers/Waypoints/waypoints.json", + demparser: "", + controlled: false, + layer3dType: "clamped", + description: + "### Overview\n\nIure iure quas doloremque sequi pariatur repudiandae. Provident similique in illum deleniti qui consequuntur iste aut. Quia accusamus dolorem beatae et aut.\n\nVero cum ullam cumque optio laborum. Qui corporis incidunt accusamus voluptatem. Quam eos et expedita. Quidem et velit fuga et delectus veniam.\n\n- Vel ex voluptatem dicta\n- Dolor et itaque quidem\n- Vero cum ullam cumque [optio laborum](www.duckduckgo.com)\n\nDolor et itaque quidem. Dolorem ut nemo porro rerum. Rerum voluptas quo sit velit voluptatibus perspiciatis ipsum. Vel ex voluptatem dicta. Et porro harum maiores. Quae consequatur exercitationem numquam.\n", + tags: ["rover", "science", "telem:45B", "location"], + legend: "Layers/Waypoints/legend.csv", + visibility: true, + initialOpacity: 1, + togglesWithHeader: true, + style: { + className: "waypoints", + color: "#FFF", + fillColor: "#000", + weight: 2, + fillOpacity: 1, + opacity: 1, + }, + variables: { + useKeyAsName: "sol_site_p", + layerAttachments: { + labels: { + initialVisibility: false, + theme: "default", + size: "large", + }, + }, + markerAttachments: { + bearing: { + angleProp: "yaw_rad", + angleUnit: "rad", + color: "#FFFFFF", + }, + }, + search: "(sol_site_p)", + }, + radius: 8, + time: { + enabled: false, + type: "requery", + isRelative: true, + current: "2023-02-07T17:58:53Z", + start: "", + end: "", + startProp: "", + endProp: "", + format: "%Y-%m-%dT%H:%M:%SZ", + compositeTile: false, + refresh: "1 hours", + increment: "5 minutes", + }, + uuid: "7f6396c3-eef1-401a-9e99-790ed102efff", + }, + { path: "Features", index: 0 } + ) + .then(() => { + console.log("loaded"); + }) + .catch((errMsg) => { + console.log(errMsg); + }); +``` + +### removeLayer(layerUUID) + +Removes a layer from the map. + +#### Function parameters + +- `layerUUID` - The name/uuid of the layer to remove. + +Returns `true` if found and removed, otherwise `false` + +The following is an example of how to call the `removeLayer` function: + +```javascript +window.mmgisAPI.removeLayer("Sample Header"); // => true +``` + +### clearVectorLayer(layerUUID) This function clears an existing vector layer with a specified name #### Function parameters -- `layerName` - name of layer to clear +- `layerUUID` - name of layer to clear The following is an example of how to call the `clearVectorLayer` function: @@ -25,13 +187,13 @@ The following is an example of how to call the `clearVectorLayer` function: window.mmgisAPI.clearVectorLayer("Waypoints"); ``` -### updateVectorLayer(layerName, inputData) +### updateVectorLayer(layerUUID, inputData) This function updates an existing vector layer with a specified name and valid GeoJSON data #### Function parameters -- `layerName` - name of layer to update +- `layerUUID` - name of layer to update - `inputData` - valid GeoJSON data - `keepN` - number of features to keep. A value less than or equal to 0 keeps all previous features @@ -58,13 +220,13 @@ window.mmgisAPI.updateVectorLayer( ); ``` -### trimVectorLayerKeepBeforeTime(layerName, keepBeforeTime, timePropPath) +### trimVectorLayerKeepBeforeTime(layerUUID, keepBeforeTime, timePropPath) This function removes features on a specified layer after a specified time #### Function parameters -- `layerName` - name of layer to update +- `layerUUID` - name of layer to update - `keepBeforeTime` - absolute time in the format of YYYY-MM-DDThh:mm:ssZ; will keep all features before this time - `timePropPath` - name of time property to compare with the time specified by keepAfterTime @@ -78,13 +240,13 @@ window.mmgisAPI.trimVectorLayerKeepBeforeTime( ); ``` -### trimVectorLayerKeepAfterTime(layerName, keepAfterTime, timePropPath) +### trimVectorLayerKeepAfterTime(layerUUID, keepAfterTime, timePropPath) This function removes features on a specified layer before a specified time #### Function parameters -- `layerName` - name of layer to update +- `layerUUID` - name of layer to update - `keepAfterTime` - absolute time in the format of YYYY-MM-DDThh:mm:ssZ; will keep all features after this time - `timePropPath` - name of time property to compare with the time specified by keepAfterTime @@ -98,13 +260,13 @@ window.mmgisAPI.trimVectorLayerKeepAfterTime( ); ``` -### keepFirstN(layerName, keepLastN) +### keepFirstN(layerUUID, keepLastN) This function removes features on a specified layer starting from the tail of of the features list to keep the specified number of existing features. This function is not aware of time and will only keep the previous N number of features based on the order the features were added to the layer. #### Function parameters -- `layerName` - name of layer to update +- `layerUUID` - name of layer to update - `keepFirstN` - number of features to keep from the beginning of the features list. A value less than or equal to 0 keeps all previous features The following is an example of how to call the `keepFirstN` function: @@ -113,13 +275,13 @@ The following is an example of how to call the `keepFirstN` function: window.mmgisAPI.keepFirstN("Waypoints", 2); ``` -### keepLastN(layerName, keepLastN) +### keepLastN(layerUUID, keepLastN) This function removes features on a specified layer starting from the beginning of the features list to keep the specified number of existing features. This function is not aware of time and will only keep the previous N number of features based on the order the features were added to the layer. #### Function parameters -- `layerName` - name of layer to update +- `layerUUID` - name of layer to update - `keepLastN` - number of features to keep from the tail end of the features list. A value less than or equal to 0 keeps all previous features The following is an example of how to call the `keepLastN` function: @@ -128,7 +290,7 @@ The following is an example of how to call the `keepLastN` function: window.mmgisAPI.keepLastN("Waypoints", 2); ``` -### trimLineString(layerName, time, timeProp, trimN, startOrEnd) +### trimLineString(layerUUID, time, timeProp, trimN, startOrEnd) This function is used to trim a specified number of vertices on a specified layer containing GeoJson LineString features. This makes the following assumptions: @@ -137,7 +299,7 @@ This function is used to trim a specified number of vertices on a specified laye #### Function parameters -- `layerName` - name of layer to update +- `layerUUID` - name of layer to update - `time` - absolute time in the format of YYYY-MM-DDThh:mm:ssZ; represents start time if trimming from the beginning, otherwise represents the end time - `timeProp` - key representing the time property to be updated in the layer - `trimN` - number of vertices to trim @@ -165,13 +327,13 @@ window.mmgisAPI.trimLineString( ); ``` -### appendLineString(layerName, inputData, timeProp) +### appendLineString(layerUUID, inputData, timeProp) This function appends input data with a GeoJson Feature that contains a LineString. The LineString vertices from the input data is appended as vertices to the last Feature in the layer. The input data should also contain a property with `timeProp` as the key, representing the new end time for the updated data. #### Function parameters -- `layerName` - name of layer to update +- `layerUUID` - name of layer to update - `inputData` - GeoJson data containing a single Feature containing a LineString - `timeProp` - key representing the time property to be updated in the layer @@ -205,13 +367,15 @@ window.mmgisAPI.appendLineString( ); ``` -### reloadLayer(layer) +### reloadLayer(layer, evenIfOff, evenIfControlled) This function will reload the given layer by re-fetching the data and re-drawing on the map. #### Function parameters - `layer` - The layer name string or a layer object +- `evenIfOff` - _boolean_ | If true, reloads the layer even if the layer is not active +- `evenIfControlled` - _boolean_ | If true, reloads the layer even if it's a "Controlled" layer The following is an example of how to call the `reloadLayer` function: @@ -219,6 +383,24 @@ The following is an example of how to call the `reloadLayer` function: window.mmgisAPI.reloadLayer("Earthquakes"); ``` +### asLayerUUID(uuid) + +If `uuid` is a valid uuid, it is returned. If not but it's a valid layer Name, it will return the first corresponding uuid. If still not, returns null. + +#### Function parameters + +- `uuid` - A layer UUID or layer Name + +The following is an example of how to call the `asLayerUUID` function: + +```javascript +window.mmgisAPI.asLayerUUID("4d04b08d-4d13-4ff5-ad3c-f78e9b6425e4"); +// returns 4d04b08d-4d13-4ff5-ad3c-f78e9b6425e4 + +window.mmgisAPI.asLayerUUID("Earthquakes"); +// returns 4d04b08d-4d13-4ff5-ad3c-f78e9b6425e4 +``` + ## Time Control ### toggleTimeUI(visibility) @@ -416,7 +598,7 @@ window.mmgisAPI.updateLayersTime(); ### addEventListener(eventName, functionReference) -This function adds a map event or MMGIS action listener added using the MMGIS API. This function takes in one of the following events: `onPan`, `onZoom`, `onClick`, `toolChange`, `layerVisibilityChange`. The MMGIS action listener (`toolChange`, `layerVisibilityChange`, `websocketChange`) functions are called with an `event` parameter. +This function adds a map event or MMGIS action listener added using the MMGIS API. This function takes in one of the following events: `onPan`, `onZoom`, `onClick`, `toolChange`, `layerVisibilityChange`. The MMGIS action listener (`toolChange`, `layerVisibilityChange`, `websocketChange`, `toggleSeparatedTool`) functions are called with an `event` parameter. #### Function parameters @@ -478,7 +660,7 @@ The following is an example of how to call the `map` object: window.mmgisAPI.map; ``` -### featuresContained +### featuresContained() This function returns an array of all features in the current map view. The return value is an object containing layer names as keys and values as arrays with all features (as GeoJson Feature objects) contained in the current map view @@ -488,7 +670,7 @@ The following is an example of how to call the `featuresContained` function: window.mmgisAPI.featuresContained(); ``` -### getActiveFeature +### getActiveFeature() This function returns the currently active feature (i.e. feature thats clicked and displayed in the InfoTool). The return value is the currently selected active feature as an object with the layer name as key and value as an array containing the GeoJson Feature object (MMGIS only allows the section of a single feature). @@ -498,7 +680,7 @@ The following is an example of how to call the `getActiveFeature` function: window.mmgisAPI.getActiveFeature(); ``` -### selectFeature +### selectFeature(layerUUID, options) This function selects a vector layer feature. It supports selections either from: @@ -508,7 +690,7 @@ This function selects a vector layer feature. It supports selections either from #### Function Parameters -- `layerName` - _string_ - Name of the vector layer to select a feature in. +- `layerUUID` - _string_ - UUID or Name of the vector layer to select a feature in. - `options` - _{}_ - `layerId` - (optional) - A leaflet layer id - `lon` - (optional) - Longitude - needs `lat` set @@ -521,7 +703,9 @@ This function selects a vector layer feature. It supports selections either from The following is an example of how to call the `selectFeature` function: ```javascript -window.mmgisAPI.selectFeature("Waypoints", { layerId: 600 }); +window.mmgisAPI.selectFeature("3343d4f5-12a6-4849-910c-3fa6f09aeef3", { + layerId: 600, +}); window.mmgisAPI.selectFeature("Waypoints", { lon: 137, lat: -4 }); @@ -533,7 +717,7 @@ window.mmgisAPI.selectFeature("Waypoints", { }); ``` -### getVisibleLayers +### getVisibleLayers() This function returns an object with the visibility state of all layers @@ -543,7 +727,7 @@ The following is an example of how to call the `getVisibleLayers` function: window.mmgisAPI.getVisibleLayers(); ``` -### getLayers +### getLayers() This function returns all the configuration set Leaflet Map layers. If a layer has not yet been loaded, its value with be false. @@ -553,7 +737,7 @@ The following is an example of how to call the `getLayers` function: window.mmgisAPI.getLayers(); ``` -### getLayerConfigs +### getLayerConfigs(match) This function returns all the layer configuration objects. @@ -574,13 +758,13 @@ window.mmgisAPI.getLayerConfigs({ "style.color": "brown" }); // => { Layer1: {..., style: {..., color: "brown"}}} ``` -### toggleLayer +### toggleLayer(layerUUID, on) This function sets the visibility state for a named layer #### Function parameters -- `layerName` - name of layer to toggle visibility +- `layerUUID` - name of layer to toggle visibility - `on` - (optional) Set `true` if the visibility should be on or `false` if visibility should be off. If not set, the current visibility state will switch to the opposite state. The following is an example of how to call the `toggleLayer` function: @@ -595,7 +779,7 @@ window.mmgisAPI.toggleLayer('Layer 1') ## Miscellaneous Features -### writeCoordinateURL +### writeCoordinateURL() This function writes out the current view as a URL. This programmatically returns the long form of the 'Copy Link' feature and does not save a short URL to the database. @@ -605,7 +789,7 @@ The following is an example of how to call the `writeCoordinateURL` function: window.mmgisAPI.writeCoordinateURL(); ``` -### onLoaded +### onLoaded(onLoadCallback) This function calls the callback function once MMGIS has finished loading. @@ -628,7 +812,7 @@ window.mmgisAPI.onLoaded(() => { }); ``` -### getActiveTool +### getActiveTool() This function returns an object with the currently active tool and the name of the active tool. @@ -638,7 +822,17 @@ The following is an example of how to call the `getActiveTool` function: window.mmgisAPI.getActiveTool(); ``` -### project +### initialLogin() + +Performs the initial login call to relogin returning users. Pairable with the ENV `SKIP_CLIENT_INITIAL_LOGIN=`. + +The following is an example of how to call the `initialLogin` function: + +```javascript +window.mmgisAPI.initialLogin(); +``` + +### project(lnglat) This function convert a Longitude, Latitude object into X, Y (i.e. Easting, Northing) coordinates. It uses the map's base projection and the proj4 library to perform the transformation. @@ -651,7 +845,7 @@ window.mmgisAPI.project({ lng: 137, lat: -4 }); // returns {x: 8120633.560692952, y: -237291.62355915268} ``` -### unproject +### unproject(xy) This function is the inverse of the `project` function. It takes in a X, Y object and returns a Longitude, Latitude. @@ -661,3 +855,56 @@ The following is an example of how to call the `unproject` function: window.mmgisAPI.unproject({ x: 8120633.560692952, y: -237291.62355915268 }); // returns {lat: -4.000000000000019, lng: 137} ``` + +### overwriteLegends(legends) + +This function can be used to overwrite the contents displayed in the LegendTool. This can be useful when used with the `toolChange` event listener in the mmgisAPI. + +#### Function parameters + +- `legends` - An array of objects, where each object must contain the following keys: legend, layerUUID, display*name, opacity. The value for the legend key should be in the same format as what is stored in the layers data under the `_legend` key (i.e. `L*.layers.data[layerName].\_legend`). layerUUID and display_name should be strings and opacity should be a number between 0 and 1. + +The following is an example of how to call the `overwriteLegends` function: + +```javascript +const legends = [ + { + color: "#00e400", + strokecolor: "#000000", + shape: "continuous", + value: "0 - 54", + }, + { + color: "#ffff00", + strokecolor: "#000000", + shape: "continuous", + value: "54 - 154", + }, + { + color: "#ff7e00", + strokecolor: "#000000", + shape: "continuous", + value: "154 - 254", + }, + { + color: "#8f3f97", + strokecolor: "#000000", + shape: "continuous", + value: "254 - 354", + }, + { + color: "#8f3f97", + strokecolor: "#000000", + shape: "continuous", + value: "354 - 424", + }, + { + color: "#7e0023", + strokecolor: "#000000", + shape: "continuous", + value: "> 424", + }, +]; + +window.mmgisAPI.overwriteLegends(legends); +``` diff --git a/docs/pages/APIs/JavaScript/Utils/Utils.md b/docs/pages/APIs/JavaScript/Utils/Utils.md new file mode 100644 index 00000000..f40c71e2 --- /dev/null +++ b/docs/pages/APIs/JavaScript/Utils/Utils.md @@ -0,0 +1,613 @@ +--- +layout: page +title: Utils +permalink: /apis/javascript/utils +parent: JavaScript API +grand_parent: APIs +--- + +# JavaScript API Utils + +The `src/essence/mmgisAPI/mmgisAPI.js` file exposes functions that can be called using the global `window.mmgisAPI` object. + +#### _Contents_ + +- [Object Manipulation](#object-manipulation) +- [String Manipulation](#string-manipulation) +- [Geo-Spatial](#geo-spatial) +- [GeoJSON](#geojson) +- [Color](#color) +- [Download](#download) +- [Misc](#misc) + +--- + +## Object Manipulation + +### `arrayAverage(array, key)` + +Returns the average value of an array of numbers. +If array is an array of objects, the optional key can be set to say which key to average. + +### `arrayUnique(array)` + +Returns an array without duplicates. + +### `chunkArray(arr, size)` + +Breaks an array in multiple arrays of some size. A 2D array is returned. + +### `clone(obj)` + +Deep clones an object. + +### `diff(arr1, arr2)` + +Returns an array of only the matching elements between two arrays. + +### `getIn(obj, keyArray, notSetValue)` + +Traverses an object with an array of keys. Pre-object chaining. + +#### Example + +```javascript +mmgisAPI.utils.getIn({ a: { b: { c: 1 } } }, "a.b.c"); // => 1 +mmgisAPI.utils.getIn({ a: { b: { c: 1 } } }, "a.b.c.d", null); // => null +mmgisAPI.utils.getIn({ a: { b: { c: 1 } } }, ["a", "b", "c"]); // => 1 +``` + +### `getKeyByValue(obj, value)` + +Given an flat object, returns the first key with the specified value. + +### `getMinMaxOfArray(arrayOfNumbers)` + +Returns the minimum and maximum values of an array of numbers. + +### `getValueByKeyCaseInsensitive(key, obj)` + +Returns the value of a flat object's while matching keys case-insensitively. + +### `identicalElements(arr)` + +Returns true if all elements of the array are the same (empty is false). + +### `isEmpty(obj)` + +Returns true if the object is empty. + +### `isEqual(obj1, obj2, isSimple)` + +Compares two objects to see if they're equal. Setting isSimple will simply compare both object's `JSON.stringify` value. + +### `noNullLength(arr)` + +Returns the length of an array minus all its `null` values. + +### `objectArrayIndexOfKeyWithValue(objectArray, key, value)` + +Returns the index of an array of objects with a matching key-value pair (-1 if not found). + +### `pad(num, size)` + +Pads a number or string with leading zeros such that the returned string is of length `size`. + +### `removeDuplicatesInArray(arr)` + +Returns the array without duplicates. + +### `removeDuplicatesInArrayOfObjects(arr)` + +Returns the array of objects without duplicates. Object matching happens with `JSON.stringify`. + +### `stitchArrays(keyArray, valueArray)` + +Combines an array of keys and a separate corresponding array of values together into an object. + +### `uniqueArray(arr)` + +Returns the array without duplicates. + +## String Manipulation + +### `bracketReplace(str, obj)` + +Shortcut method for quickly populating bracketed `{}` parameters in a string. + +#### Example + +```javascript +mmgisAPI.utils.bracketReplace("{a} {b}", { a: "hello", b: "world" }); // => 'hello world' +``` + +### `cleanString(str)` + +Removes common non-alphanumeric symbols from a string. + +### `fileNameFromPath(path)` + +Returns the filename (minus extension) from a filepath. + +#### Example + +```javascript +mmgisAPI.utils.fileNameFromPath("/path/to/an/image/that/says/hello/world.png"); // => world +mmgisAPI.utils.fileNameFromPath("/path/to/an/image/that/says/hello/world"); // => world +mmgisAPI.utils.fileNameFromPath("world"); // => world +``` + +### `getExtension(string)` + +Gets the extension of a string (without periods). + +#### Example + +```javascript +mmgisAPI.utils.getExtension("file.json"); // => 'json' +``` + +### `isStringNumeric(str)` + +Returns true if `str` is a string and can be parsed to a float. + +#### Example + +```javascript +mmgisAPI.utils.isStringNumeric("5.4"); // => true +mmgisAPI.utils.isStringNumeric("v5.4"); // => false +mmgisAPI.utils.isStringNumeric("5.4v"); // => false +mmgisAPI.utils.isStringNumeric(5.4); // => false +``` + +### `isUrlAbsolute(url)` + +Checks whether a given URL is absolute. + +#### Example + +```javascript +mmgisAPI.utils.isUrlAbsolute("file.json"); // => false +mmgisAPI.utils.isUrlAbsolute("http://file.json"); // => true +mmgisAPI.utils.isUrlAbsolute("file://file.json"); // => true +mmgisAPI.utils.isUrlAbsolute("s3-us-west-2.amazonaws.com/file.json"); // => false +mmgisAPI.utils.isUrlAbsolute("../file.json"); // => false +``` + +### `isValidUrl(str)` + +Checks whether a given URL is valid. Uses anchor element `<a>` to perform test. + +### `monthNumberToName(monthNumber)` + +Given a month `[0, 11]`, returns its three character string ('Jan', 'Feb', ...) + +### `numberToWords(n)` + +Given a number `[0, 16]`, return its name in lowercase. + +### `prettifyName(name)` + +Returns the name with underscores as spaces and all word capitalized. + +### `sanitize(str)` + +Removes the following symbols from the string: `<, >, {, }, ;`. + +### `timestampToDate(timestamp)` + +Given a timestamp, returns the UTC date in the following format: `MMM dd, YYYY HH:MM:SS` + +### `toEllipsisString(str, length)` + +Given a string, does not let it exceed `length` and truncates and adds "..." if it does. + +## Geo-Spatial + +### `areaOfTriangle(aX, aY, bX, bY, cX, cY)` + +Returns the 2D area of the triangle defined by the three points. + +### `bearingBetweenTwoLatLngs(lat1, lng1, lat2, lng2)` + +Finds the bearing/angle from the first latlng to the second. 0 is north and travels clock-wise. + +#### Example + +```javascript +mmgisAPI.utils.bearingBetweenTwoLatLngs(0, 0, 1, 0); // => 0 +mmgisAPI.utils.bearingBetweenTwoLatLngs(0, 0, 0, 1); // => 90 +``` + +### `boundingBoxToFeature(nE, sW)` + +Turns a bounding box specified by {lat, lng} corners into a geojson feature. + +#### Function parameters + +- `nE` - _{lat, lng}_ pair for the northeast bounding box corner +- `sW` - _{lat, lng}_ pair for the southwest bounding box corner + +### `circleFeatureFromTwoLngLats(lnglatCenter, lnglatRadius, steps, crs)` + +Creates a GeoJSON circle feature based on a center point and a point on the edge. + +#### Function parameters + +- `lnglatCenter` - _{lng, lat}_ - the lat,lng point of the circle's center. +- `lnglatRadius` - _{lng, lat}_ - a lat,lng point on the circle's edge. +- `steps` - _number_ - number of vertices that make up the circumference. +- `crs?` - _CRS Object_ - if a crs is passed, the circle will be map-projection-based and not screen-based. + +If crs is passed, circle will be map-projection-based and not screen based. + +### `closestPoint(p, pts)` + +Given a point p and series of points, finds the point that's closest to p. Returns a point with points. + +#### Function parameters + +- `p` - _{x, y}_ - source point +- `pts` - _[[[x,y], [x,y]], [[x, y]]]_ - MultiLineString + +### `closestToSegment(p, v, w)` + +Given a point p and two line endpoints, finds the closest position on the line of p. + +#### Function parameters + +- `p` - _{x, y}_ +- `v` - _{x, y}_ +- `w` - _{x, y}_ + +### `closestToSegments(p, lines)` + +Like `closestToSegment()` but accepts multiple lines. +`lines` is of form: `[[[x1, y1], [x2, y2]], [[x1, y1],[x2, y2]], ... ]` + +### `coordinateDepthTraversal(array, onEachLeaf)` + +Iterates depth-first through a coordinates array. `onEachLeaf` provides a callback for each coordinate. + +### `degreesToMeters(degrees)` + +Using the currently configured major planetary radius, converts degrees to equatorial meters. + +### `destinationFromBearing(lat, lng, bearing, distance, round_off)` + +Given a source point, a bearing and a distance, finds the destination point. + +### `distanceFormula(x1, y1, x2, y2)` + +Standard distance formula between two points. + +### `doBoundingBoxesIntersect(a, b)` + +Returns a boolean whether two bounding boxes of the form `[minX, minY, maxX, maxY]` intersect. + +### `getEarthToPlanetRatio()` + +Returns `6371000 / majorRadius`. Sometimes useful when making Earth-centric code generic. + +### `getFeatureArea(feature, displayFriendly)` + +Given a GeoJSON feature, computes its area in meters. If `displayFriendly` is true, returns the area to a fixed decimal place and with units. + +### `getFeatureLength(feature, displayFriendly)` + +Given a 'LineString', 'MultiLineString' or 'Polygon' feature, computes it's length/perimeter in meters. If `displayFriendly` is true, returns the area to a fixed decimal place and with units. + +### `getPtSomeDistBetween2OtherPts(x0, y0, x1, y1, d)` + +Given two points, finds a point `d` distance from the first towards the seconds. + +#### Example + +```javascript +mmgisAPI.utils.getPtSomeDistBetween2OtherPts(0, 0, 0, 1, 0.2); // => {x: 0, y: 0.2} +``` + +### `inclinationBetweenTwoLatLngs(lat1, lng1, elev1, lat2, lng2, elev2)` + +Computes the inclination/elevation angle between two latlngelv points. This function does not account for planetary curvature. + +### `interpolatePointsPerun(p1, p2, p)` + +Given two `{x: , y: }` points, return the point `p` percent from `p1` to `p2`. `p` is from 0 to 1. + +#### Example + +```javascript +mmgisAPI.utils.interpolatePointsPerun({ x: 0, y: 0 }, { x: 0, y: 1 }, 0.6); // => {x: 0, y: 0.6, z: 0} +``` + +### `lat2tileUnfloored(lat, zoom)` + +Returns the mercator tile Y coordinate at that latitude and at the zoom. + +### `lineOfSight1D(heightArray, observerHeight, targetHeight)` + +Performs a line of sight viewshed in one dimension. + +#### Function parameters + +- `heightArray` - Array of elevation values, length should be >2, observer at index 0 +- `observerHeight` - How many units tall is the observer. - number - default 0 +- `targetHeight` - How high off the surface are we checking viewability. Leave at 0 for seeing the surface. - number - default 0 + +### `linearScale(domain, range, value)` + +Given `domain` and `range` min-max arrays, maps `value` from the `domain` space into the `range` space. + +#### Example + +```javascript +mmgisAPI.utils.linearScale([-1, 1], [0, 100], 0); // => 50 +``` + +### `lngLatDistBetween(lon1, lat1, lon2, lat2)` + +Given two lnglats, returns the distance in meters between them. Uses the haversine formula. + +### `lon2tileUnfloored(lon, zoom)` + +Returns the mercator tile X coordinate at that longitude and at the zoom. + +### `lonLatToVector3nr(lon, lat, height)` + +Converts a longitude, latitude and height into 3D vector space. `nr` in the function name indicates `no radius` -- `height` is the distance from the center without the planetary radius added to it. + +### `marsEarthSurfaceAreaRatio()` + +Returns the ratio of Mars' to Earth's surface areas. Sometimes useful when making Earth-centric code generic. + +### `metersToDegrees(meters)` + +Using the currently configured major planetary radius, converts equatorial meters to degrees. + +### `pointsInPoint(point, layer)` + +Given a point `[lng, lat]` and a leaflet `layer`, returns all Point features in that layer with the same lng, lat value. Useful for finding overlapping points. + +### `rotatePoint(pt, center, angle)` + +2D rotate a point about another point a certain angle. `pt` is `{x: ,y: }`, `center` is `[x,y]` and `angle` is in radians. + +### `rotatePoint3D(pt, angle, center)` + +3D rotates a point about another point a certain angle. Rotates X then Z then Y. + +#### Function parameters + +- `pt` - Point to rotate - `{x: , y: , z: }` +- `center` - Point to rotate around - `{x: , y: , z: }` - default `{x: 0, y: 0, z: 0}` +- `angle` - Angles to rotate in radians - `{x: , y: , z: }` + +### `setRadius(which, radius)` + +Sets the major or minor radius in MMGIS. Use this only if you know what you're doing. + +#### Function parameters + +- `which` - 'major' or `minor` +- `radius` - Radius in meters + +### `subdivideLine(line, meters)` + +Subdivides a LineString's coordinates such that they are no more than `meters` meters apart. + +### `tileContains(xyz, z, useLast)` + +Given an xyz and z, gets all tiles on zoom level z that are contained in xyz. Return arrays of `[x,y,z]`s contained + +#### Function parameters + +- `xyz` - the tile to get the contents of - `[x,y,z]` +- `z` - the zoom level of tiles to get - number +- `useLast` - use lastTileContains. lastTileContains stores the last three calls and results to speed up performance - boolean - default false + +### `tileIsContained(xyzContainer, xyzContained, useLast)` + +Returns true if tile `xyzContainer` contains the tile `xyzContained` + +#### Function parameters + +- `xyzContainer` - `[x,y,z]` +- `xyzContained` - `[x,y,z]` +- `useLast` - use lastTileContains. lastTileContains stores the last three calls and results to speed up performance - boolean - default false + +### `tilesWithin(xyz, z)` + +Gets all tiles with tile xyz `{x: , y: , z:}` at zoom z. + +### `toEllipse(lnglat, axes, crs, options)` + +Returns an ellipse with major and minor axes and rotation about a point. Adapted from turf.js' ellipse function. + +#### Function parameters + +- `lnglat` - `{lng: lat:}` +- `axes` - `{x: y:}` +- `crs` - Perhaps `window.mmgisglobal.customCRS` - `{crs_object}` +- `options` - `{units: 'meters', steps: 32, angle: 0}` + +## GeoJSON + +### `geoJSONFeatureMetersToDegrees(feature)` + +Given a GeoJSON feature defined with meter coordinates, converts them to latitude and longitude and returns the feature. + +### `GeoJSONStringify(geojson)` + +Turns `geojson` into a pretty print string. + +### `geojsonAddSpatialProperties(geojson)` + +For LineStrings and MultiLineStrings adds `properties.length2D` metadata. For Polygons adds `properties.perimeter2D` and `properties.area2D` metadata. + +### `getBaseGeoJSON(featuresArray)` + +Returns a generic geojson template: + +```javascript +{ + type: 'FeatureCollection', + crs: { + type: 'name', + properties: { name: 'urn:ogc:def:crs:OGC:1.3:CRS84' }, + }, + features: featuresArray -- [], +} +``` + +### `invertGeoJSONLatLngs(feature)` + +Given a feature with incorrect longitude, latitude coordinate order, swaps them. + +### `sortGeoJSONFeatures(geojson)` + +Sorts a GeoJSON's features such that when rendering, points draw on top of lines and lines draw on top of polygons. Ensures features are clickable. + +## Color + +### `getColorFromRangeByPercent(colors, percent, asRGBString)` + +Gets a color along a gradient + +#### Function parameters + +- `colors` - Evenly spaced rgb: `[ [r,g,b], [r,g,b], [r,g,b] ]` +- `percent` - Is 0 to 1 +- `asRGBSting` - If true, returns `rgb(r,g,b)` instead of `[r,g,b]` + +### `hexToRGB(hex)` + +Converts a hex color to rgb `{r: , g: , b: }` + +### `hexToRGBA(hex, a)` + +Converts a hex color and alpha to rgba `{r: , g: , b: , a: }` + +### `intToRGB(i)` + +Turns an integer into a hex color. `0 = #000000` and `16777215 = #FFFFFF`. (16777215 == 16^6 - 1) + +### `isColor(strColor)` + +Checks whether a given string is a valid css color. + +### `makeColorGrid(x, y)` + +Makes a grid of gradient colors x rows by y columns. + +### `rgb2hex(rgb)` + +Converts an `rgb()` or `rgba()` string to a hex color. + +### `RGBAto32(rgba)` + +Turns an rgba `{r: , g: , b: , a: }` into a float32 value by `[8 red bits][8 green bits][8 blue bits][8 alpha bits]`. + +### `rgbObjToStr(rgb, hasAlpha)` + +Converts an rgb or rgba object `{r: , g: , b: , a: }` into an rgb or rgba string `rgba()`. + +### `rgbToArray(rgb)` + +Turns an rgb or rgba string `rgba()` into an array `[r,g,b,a]`. + +### `stringToColor(str)` + +Given a valid color string, return a hex color. + +#### Example + +```javascript +mmgisAPI.utils.stringToColor("red"); // => '#91b801' +``` + +### `validTextColour(stringToTest)` + +Returns `true` if `stringToTest` is a valid css color string. + +## Download + +### `copyToClipboard(text)` + +Copies input to user's clipboard. + +### `csvToJSON(csv)` + +Converts CSV into an array of objects. + +### `downloadArrayAsCSV(headers, array, exportName)` + +Downloads a header and a 2D array as a CSV. + +#### Function parameters + +- `headers` - `['x','y','z']` +- `array` - `[[0,1,2],[3,4,5],...]` +- `exportName` - Name of file to be exported. Without `.csv` extension. + +### `downloadCanvas(canvasId, name, callback)` + +Given the HTML Id of a canvas element, downloads it. + +### `downloadObject(exportObj, exportName, exportExt)` + +Exports a JSON object. `.geojson` and `.json` `exportExt`s will attempt to pretty-print the object while keeping individual features contained to a single line. + +## Misc + +### `dynamicSort(property)` + +Alphabetically sort an array of objects by some specific key `property`. + +### `getBase64Transparent256Tile()` + +Returns a 256 x 256 pixel blank png in base64. + +### `getBrowser()` + +Gets the user's current browser. + +### `getTextShadowString(color, opacity, weight)` + +Mocks a text border for use with the text-shadow css property. Weight can be no more than `2`. + +### `getTimeStartsBetweenTimestamps(startTime, endTime, unit)` + +Returns an array of timestamps between startTime and endTime timestamps that fall along the unit. + +#### Example + +```javascript +mmgisAPI.utils.getTimeStartsBetweenTimestamps(0, 10000000, "day"); +/* => +[ + { "ts": 0, "label": 1 }, + { "ts": 86400000, "label": 2 } +] +*/ +``` + +### `isInZoomRange(minZoom, maxZoom, zoom)` + +A simple function to check whether we're inside a zoom range. + +### `mod(n, m)` + +A mod that works with negatives. A true modulo and not just a remainder. + +### `range(a, b)` + +Returns an array of ints from a to b inclusively. + +### `toHost()` + +Returns MMGIS to the root page. + +### `toHostForceLanding()` + +Returns MMGIS to the root page and forces it to stay. In cases of a single mission, MMGIS would otherwise directly navigate to it. diff --git a/docs/pages/Configure/Formats/Time_Tiles/Time_Tiles.md b/docs/pages/Configure/Formats/Time_Tiles/Time_Tiles.md index 72143861..1b61019c 100644 --- a/docs/pages/Configure/Formats/Time_Tiles/Time_Tiles.md +++ b/docs/pages/Configure/Formats/Time_Tiles/Time_Tiles.md @@ -16,17 +16,25 @@ A `{t}` parameter is added to the full tileset path. `.../layer/{t}/{z}/{x}/{y}. Examples: -- /Missions/MSL/Layers/ExampleTimeTiles/2022-09-07T00_00_00/16/57776/31916.png -- /Missions/MSL/Layers/ExampleTimeTiles/2022-10-07T00_00_00/16/57776/31916.png -- /Missions/MSL/Layers/ExampleTimeTiles/2022-11-07T00_00_00/16/57776/31916.png +- /Missions/MSL/Layers/ExampleTimeTiles/2022-09-07T00_00_00Z/16/57776/31916.png +- /Missions/MSL/Layers/ExampleTimeTiles/2022-10-07T00_00_00Z/16/57776/31916.png +- /Missions/MSL/Layers/ExampleTimeTiles/2022-11-07T00_00_00Z/16/57776/31916.png Additionally `{t}` may be appended with a name. The `time` is accessed by splitting on the new delimiter `Z-` and taking the first element. -Example: +Examples: + +- /Missions/MSL/Layers/ExampleTimeTiles/2022-09-07T00_00_00Z--LosAngeles/16/57776/31916.png +- /Missions/MSL/Layers/ExampleTimeTiles/2022-10-07T00_00_00Z--NewYork/16/57776/31916.png +- /Missions/MSL/Layers/ExampleTimeTiles/2022-11-07T00_00_00Z--London/16/57776/31916.png + +Time ranges are supported as well. Join start and ending times with `-to-`. + +Examples: -- /Missions/MSL/Layers/ExampleTimeTiles/2022-09-07T00_00_00Z-LosAngeles/16/57776/31916.png -- /Missions/MSL/Layers/ExampleTimeTiles/2022-10-07T00_00_00Z-NewYork/16/57776/31916.png -- /Missions/MSL/Layers/ExampleTimeTiles/2022-11-07T00_00_00Z-London/16/57776/31916.png +- /Missions/MSL/Layers/ExampleTimeTiles/2022-09-07T00_00_00Z-to-2022-10-01T00_00_00Z/16/57776/31916.png +- /Missions/MSL/Layers/ExampleTimeTiles/2022-10-07T00_00_00Z-to-2022-11-01T00_00_00Z/16/57776/31916.png +- /Missions/MSL/Layers/ExampleTimeTiles/2022-11-07T00_00_00Z-to-2022-12-01T00_00_00Z--London/16/57776/31916.png ## Configuration diff --git a/docs/pages/Configure/Layers/Model/Model.md b/docs/pages/Configure/Layers/Model/Model.md index 8d291dd6..2fd3790b 100644 --- a/docs/pages/Configure/Layers/Model/Model.md +++ b/docs/pages/Configure/Layers/Model/Model.md @@ -154,7 +154,7 @@ Vector Layer Raw Variables ```json { - "useKeyAsName": "Name", + "useKeyAsName": "propKey || [propKey1, propKey2, ...]", "markerAttachments": { "model": { "pathProp": "images.0.url", diff --git a/docs/pages/Configure/Layers/Query/Query.md b/docs/pages/Configure/Layers/Query/Query.md index 0f8e157b..9e4ebdd7 100644 --- a/docs/pages/Configure/Layers/Query/Query.md +++ b/docs/pages/Configure/Layers/Query/Query.md @@ -72,7 +72,7 @@ Example: ```javascript { - "useKeyAsName": "name", + "useKeyAsName": "propKey || [propKey1, propKey2, ...]", "datasetLinks": [ { "prop": "{prop}", @@ -116,7 +116,7 @@ Example: } ``` -- `useNameAsKey`: The property key whose value should be the hover text of each feature. If left unset, the hover key and value will be the first one listed in the feature's properties. +- `useKeyAsName`: The property key whose value should be the hover text of each feature. If left unset, the hover key and value will be the first one listed in the feature's properties. This may also be an array of keys. - `links`: Configure deep links to other sites based on the properties on a selected feature. This requires the "Minimalist" option in the Look Tab to be unchecked. Upon clicking a feature, a list of deep links are put into the top bar and can be clicked on to navigate to any other page. - `name`: The name of the deep link. It should be unique. - `link`: A url template. Curly brackets are included. On feature click, all `{prop}` are replaced with the corresponding `features[i].properties.prop` value. Multiple `{prop}` are supported as are access to nested props using dot notation `{stores.food.candy}`. diff --git a/docs/pages/Configure/Layers/Tile/Tile.md b/docs/pages/Configure/Layers/Tile/Tile.md index 50af074e..bb5b82d4 100644 --- a/docs/pages/Configure/Layers/Tile/Tile.md +++ b/docs/pages/Configure/Layers/Tile/Tile.md @@ -37,7 +37,7 @@ The format of the tiles. - TMS: Tile Map Service tiles are 256x256 sized images hierarchically organized by zoom level and referenced with x and y coordinates. These are the standard format for web tiles and are the format that MMGIS's auxiliary tiling scripts output. Append `/{z}/{x}/{y}.png` to your `URL`. - WMTS: Web Map Tile Service is the same exact concept as TMS but it has an inverted Y-axis. Just like TMS, append `/{z}/{x}/{y}.png` to your `URL`. -- WMS: Web Map Service tiles are a popular way of publishing maps by professional GIS software. This format is similar to the previous two formats, but more generic and not so well optimized for use in web maps. A WMS image is defined by the coordinates of its corners. A layer (or list of layers) should be provided as an options by appending `?layers=<your_layer_name><,another_if_you _want>` to your `URL`. To override WMS parameters append `&<wms_param>=<value>` again to the `URL` after the "layers" parameters. +- WMS: Web Map Service tiles are a popular way of publishing maps by professional GIS software. This format is similar to the previous two formats, but more generic and not so well optimized for use in web maps. A WMS image is defined by the coordinates of its corners. A layer (or list of layers) should be provided as an options by appending `?layers=<your_layer_name><,another_if_you _want>` to your `URL`. To override WMS parameters append `&<wms_param>=<value>` again to the `URL` after the "layers" parameters. If desired, use `&TILESIZE=` to change the tile size of the request and layer away from the default of 256. _Example URL: `http://ows.mundialis.de/services/service?layers=TOPO-WMS,OSM-Overlay-WMS`_ #### Initial Visibility @@ -87,3 +87,9 @@ Whether the layer should use global time values or function independently with i _type:_ string _optional_ The string format to be used in the URL for `{time}`. Defaults to `%Y-%m-%dT%H:%M:%SZ`. + +#### Composited Time Tile + +_type:_ boolean + +When using MMGIS-served time tiles (time enabled, `{t}` in the url, tiles served under /Missions in the format described in Time_Tiles), whether to composite/merge each tile with with the other tiles are the same location across the time query. This is useful when Time Tile data is sparse. It is a more expensive operation. If your Time Tiles are complete (no alpha in a tile), leave this False as merging tiles historically would have no effect. diff --git a/docs/pages/Configure/Layers/Vector/Vector.md b/docs/pages/Configure/Layers/Vector/Vector.md index e9c77f10..450abbc2 100644 --- a/docs/pages/Configure/Layers/Vector/Vector.md +++ b/docs/pages/Configure/Layers/Vector/Vector.md @@ -30,6 +30,8 @@ A file path that points to a geojson. If the path is relative, it will be relati _type:_ bool Whether the layer can be dynamically updated or not. If true, the layer can be dynamically updated and the URL is not required. +If true and a URL is set and Time Enabled is true, the initial url query will be performed. + #### Legend _type:_ string @@ -55,10 +57,22 @@ A value from 0 to 1 of the layer's initial opacity. 1 is fully opaque. _type:_ bool True if the layer is time enabled. URLs that contain `{starttime}` or `{endtime}` will be dynamically replaced by their set values when the layer is fetched. +If true and a URL is set and Controlled is true, only the initial url query will be performed. + #### Time Type -_type:_ enum [Global, Individual] -Whether the layer should use global time values or function independently with its own time values. +_type:_ enum [Requery, Local] +When the time changes, whether the layer should Requery the source or filter the layer Locally (based on feature properties. Note that) + +#### Start Time Property Name + +_type:_ string _optional_ +Optional and only in use if `Time Enabled = true` and `Time Type = Local`. The starting time property path. Setting this is addition to `Main Time Property Name` casts the feature's time over a range instead of as a single point in time. Can use dot-notation for nested path. Can be a unix timestamp or an ISO time (end the ISO with a `Z` to designate that it should be treated as a UTC time). + +#### Main Time Property Name + +_type:_ string +Required in `Time Enabled = true` and `Time Type = Local`. The main time property path. Can use dot-notation for nested path. Can be a unix timestamp or an ISO time (end the ISO with a `Z` to designate that it should be treated as a UTC time). #### Time Format @@ -112,7 +126,7 @@ Example: ```javascript { - "useKeyAsName": "name", + "useKeyAsName": "propKey || [propKey1, propKey2, ...]", "hideMainFeature": false, "datasetLinks": [ { @@ -140,6 +154,22 @@ Example: "initialVisibility": false, "theme": "default || solid", "size": "default || large" + }, + "pairings": { + "initialVisibility": false, + "layers": ["Array of layer names to pair"], + "originOffsetOrder": [ + "X", + "Y", + "Z" + ], + "pairProp": + "path.to.pair.prop.for.this.layer.and.all.paired.layers.to.link.on", + "layersAzProp": "optional.prop.path.to.azimuth.value.in.all.paired.layers", + "layersElProp": "optional.prop.path.to.elevation.value.in.all.paired.layers", + "style": { + "any_normal_style_field": "to_style_connective_lines", + } } }, "coordinateAttachments": { @@ -221,7 +251,7 @@ Example: } ``` -- `useNameAsKey`: The property key whose value should be the hover text of each feature. If left unset, the hover key and value will be the first one listed in the feature's properties. +- `useKeyAsName`: The property key whose value should be the hover text of each feature. If left unset, the hover key and value will be the first one listed in the feature's properties. This may also be an array of keys. - `hideMainFeature`: If true, hides all typically rendered features. This is useful if showing only `*Attachments` sublayers is desired. Default false - `datasetLinks`: Datasets are csvs uploaded from the "Manage Datasets" page accessible on the lower left. Every time a feature from this layer is clicked with datasetLinks configured, it will request the data from the server and include it with it's regular geojson properties. This is especially useful when single features need a lot of metadata to perform a task as it loads it only as needed. - `prop`: This is a property key already within the features properties. It's value will be searched for in the specified dataset column. @@ -240,6 +270,14 @@ Example: - `initialVisibility`: Whether the label sublayer is initially on. Users can toggle sublayers on and off in the layer settings in the LayersTool. - `theme`: Label theme. Either `default` or `solid`. Default is white text with a black border. Solid is white text with a dark-grey background box. - `size`: Label size. Either `default` or `large`. Default is 14px, large is 16px. + - `pairings`: Links cross-layer features together. Features paired to this layer will attempt to compute the azimuth-elevation relationship between the two to draw in the Viewer's PhotoSphere. Additionally, on the Map, a line will be drawn between the two features. + - `initialVisibility`: Whether the pairing line sublayer is initially on. Users can toggle sublayers on and off in the layer settings in the LayersTool. + - `layers`: An array of names of other layers. Note: Do not use css shorthand color names ("blue", "maroon", ...) in the paired layers styles as they won't parse properly when drawing in the PhotoSphere. + - `originOffsetOrder`: In many cases, a marker's center is not the camera's center. Within a feature's `properties.images` objects, `originOffset` can be defined. `originOffsetOrder` describes the XYZ order and signage that `originOffset` should be read in. Possible values are `X, -X, Y, -Y, Z, -Z`. + - `pairProp`: The dot notated path to the feature properties that contains the property to pair on. This layer and all paired layers need this property to properly pair up. A feature in this layer is said to be paired with a feature of one of the other specified layers, if and only if the values of this property in both features matches. + - `layersAzProp`: The dot notated path to the feature properties that contains the features' azimuth. If unset, the azimuth will be calculated through the feature's longitude, latitude, elevation coordinates. + - `layersElProp`:The dot notated path to the feature properties that contains the features' elevation. If unset, the elevation will be calculated through the feature's longitude, latitude, elevation coordinates. + - `style`: A style object to change the style of the connective lines on the Map between features. (Ex. { "color": "#00000", "weight": 5}) - `coordinateAttachments`: Attachment layers for each coordinate of every feature. - `marker`: Place a marker at every coordinate of every feature. - `initialVisibility`: Whether the coordinate marker sublayer is initially on. Users can toggle sublayers on and off in the layer settings in the LayersTool. @@ -250,7 +288,7 @@ Example: - `fillOpacity`: Opacity of marker fill. Default 1 - `radius`: Integer for radius of marker. - `markerAttachments`: An object for attaching dynamic items to point features. - - `bearing`: Sets the bearing direction of this layer's point markers (or markerIcons if set). Overrides the layer's shape dropdown value. + - `bearing`: Sets the bearing direction (clockwise from north) of this layer's point markers (or markerIcons if set). Overrides the layer's shape dropdown value. - `angleProp`: The dot notated path to the feature properties that contains the desired rotation angle. Ex. `headings.yaw`. - `angleUnit`: Unit of the value of `angleProp`. Either `deg` or `rad`. - `color`: A css color for the directional arrow for non-markerIcon bearings. diff --git a/docs/pages/Configure/Tabs/Coordinates/Coordinates_Tab.md b/docs/pages/Configure/Tabs/Coordinates/Coordinates_Tab.md index 97b31fe0..f50a61c9 100644 --- a/docs/pages/Configure/Tabs/Coordinates/Coordinates_Tab.md +++ b/docs/pages/Configure/Tabs/Coordinates/Coordinates_Tab.md @@ -37,3 +37,35 @@ Check to display Y, X, -Z coordinates to users relative to point features they h #### With Elevation Check to query for and append elevation values to the lower-right coordinates as users mouse around. DEM URL must be set. + +#### Raw Variables + +All raw variables are optional. + +Example: + +```javascript +{ + "rightClickMenuActions": [ + { + "name": "The text for this menu entry when users right-click", + "link": "https://domain?I={ll[0]}&will={ll[1]}&replace={ll[2]}&these={en[0]}&brackets={en[1]}&for={cproj[0]}&you={sproj[0]}&with={rxy[0]}&coordinates={site[2]}" + }, + { + "name": "WKT text insertions. Do so only for polygons.", + "link": "https://domain?regularWKT={wkt}&wkt_where_commas_are_replaced_with_underscores={wkt_}", + "for": "polygon" + } + ] +} +``` + +- `rightClickMenuActions`: When right-clicking on the Map or Globe, a custom context-menu appears. By default it only offers "Copy Coordinates". By adding objects to the `rightClickMenuActions` array, entries can be added to the context-menu to send users to links with parameters populated with the current coordinates. + - `name`: The button text for this action in the right-click context-menu. + - `link`: A url template. Curly brackets are included. The available coordinate parameters (with array index in brackets and assuming they are enabled) are: + - `ll`: `[longitude, latitude, elevation]` - Longitude Latitude + - `en`: `[easting, northing, elevation]` - Easting Northing + - `cproj`: `[easting, northing, elevation]` - Projected + - `sproj`: `[easting, northing, elevation]` - Secondary Projected + - `rxy`: `[x, y, z]` - Relative + - `site`: `[y, x, -z]` - Local Level diff --git a/docs/pages/Configure/Tabs/Look/Look_Tab.md b/docs/pages/Configure/Tabs/Look/Look_Tab.md index 0011aea5..d2f635c4 100644 --- a/docs/pages/Configure/Tabs/Look/Look_Tab.md +++ b/docs/pages/Configure/Tabs/Look/Look_Tab.md @@ -10,22 +10,40 @@ grand_parent: Configure Configure the look of MMGIS's UI for the mission +### Rebranding + #### Page Name Sets the browser tab title and, if the UI is not minimalist, sets the title in the top bar. Defaults to `MMGIS` -#### Minimalist UI +### User Interface + +Toggles user interface elements on or off. + +#### Minimalist UI (DISABLED) If checked, hides the top bar. The top bar contains descriptive elements and interactions as well as a search bar. Checking this may cause other setups to be irrelevant. -#### Zoom Control +#### Tob Bar + +#### Tool Bar + +#### Scale Bar + +#### Coordinates + +#### Map Zoom Control If checked, adds `+` and `-` zoom buttons to the top right of the Map. -#### Graticule +#### Map Graticule Displays a grid of longitudinal and latitudinal lines over the Map. +#### Miscellaneous + +### Colors + #### Body Color Sets the background color of MMGIS to a [CSS color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value). Might have little impact. @@ -46,7 +64,9 @@ Sets the background of the Map to a [CSS color](https://developer.mozilla.org/en Sets the highlight of active vector features to a [CSS color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value). -#### Swap +### Secondary Tools + +#### Swap (DISABLED) If checked, adds a button in the tool bar that enables users to switch seamlessly between missions. This functionality may be buggy and break things depending on the missions switched to and from. It's recommended to return to the landing page to switch between missions or to extensively test swapping between your missions before enabling Swap. @@ -62,6 +82,8 @@ If checked, adds a button in the tool bar that enables users to screenshot the c If checked, adds a button in the tool bar that enables users to quickly enter and exit fullscreen mode. +### User Help + #### Help If checked, adds a button in the tool bar that links to help documentation. That link can be specified below in Help URL. diff --git a/docs/pages/Configure/Tabs/Panels/Panels_Tab.md b/docs/pages/Configure/Tabs/Panels/Panels_Tab.md index ead2b41f..780fd621 100644 --- a/docs/pages/Configure/Tabs/Panels/Panels_Tab.md +++ b/docs/pages/Configure/Tabs/Panels/Panels_Tab.md @@ -52,7 +52,8 @@ The Viewer sits to the left of the main Map. It can be expanded by clicking the "azmax": 48.5537, "elmin": -75.0502, "elmax": 6.95029, - "elzero": 149.584 + "elzero": 149.584, + "originOffset": [-0.675,-0.5778,-1.946123] } ] } @@ -80,13 +81,14 @@ A Deep Zoom Image is a format of tiled imagery used to render massive images. Po This deprojects a cylindrical mosaic by wrapping it to a 3D sphere (think Google StreetView). To do this, additional parameters are needed. -- rows: Y-axis pixel dimension. -- columns: X-axis pixel dimension. -- azmin: The azimuth in degrees of the left side of the image. Values are between 0 and 360 with 0 being north and 90 being east. -- azmax: The azimuth in degrees of the right side of the image. Values are between 0 and 360 with 0 being north and 90 being east. -- elmin: The elevation in degrees of the bottom of the image. Values are between -90 and 90 with -90 being straight down and 90 being straight up. -- elmax: The elevation in degrees of the top of the image. Values are between -90 and 90 with -90 being straight down and 90 being straight up. -- elzero: The number of pixels from the top of the image where the elevation is zero. +- `rows`: Y-axis pixel dimension. +- `columns`: X-axis pixel dimension. +- `azmin`: The azimuth in degrees of the left side of the image. Values are between 0 and 360 with 0 being north and 90 being east. +- `azmax`: The azimuth in degrees of the right side of the image. Values are between 0 and 360 with 0 being north and 90 being east. +- `elmin`: The elevation in degrees of the bottom of the image. Values are between -90 and 90 with -90 being straight down and 90 being straight up. +- `elmax`: The elevation in degrees of the top of the image. Values are between -90 and 90 with -90 being straight down and 90 being straight up. +- `elzero`: The number of pixels from the top of the image where the elevation is zero. +- `originOffset`: If not centered on the feature, the vector offset in meters from the feature's center. If not in [X, Y, Z] order, the coordinate order of this vector can be redefined in the `layerAttachments.pairings.originOffsetOrder` field in the layer's raw variables. _Note: Extremely large mosaics may need to be scaled down ahead of time._ diff --git a/docs/pages/Configure/Tabs/Time/Time_Tab.md b/docs/pages/Configure/Tabs/Time/Time_Tab.md index 86619160..6bb6d04c 100644 --- a/docs/pages/Configure/Tabs/Time/Time_Tab.md +++ b/docs/pages/Configure/Tabs/Time/Time_Tab.md @@ -16,10 +16,38 @@ This enables the user interface for Time. If disabled, global time will not be u ### Visible -Whether or not the Time user interface should be visible. +Whether or not the Time user interface should be visible. This allows time to be enabled while restricting users from using its UI. + +### Initially Open + +If enabled and visible, the Time UI will be initially open on the bottom of the screen. ## Time Format The time format to be displayed on the Time UI. Uses D3 time format specifiers: https://github.com/d3/d3-time-format Default: `%Y-%m-%dT%H:%M:%SZ` + +## Initial Start Time + +The initial start time. Should be before `Initial End Time`. + +Default: 1 month before `Initial End Time` + +## Initial End Time + +The initial end time. Should be after `Initial Start Time`. Use `now` to have the end time be the present. + +Default: `now` + +## Initial Window Start Time + +This does not control the time range for queries. This only allows the initial time window of the time line to differ from just being the Start Time to the End Time. A use-case for this would be to set the window times to fit the full extent of the temporal data but only set the Initial Start and End Times as a subset of that so as not to query everything on load. + +Default: `Initial Start Time` + +## Initial Window End Time + +This does not control the time range for queries. This only allows the initial time window of the time line to differ from just being the Start Time to the End Time. Should be after `Initial Window End Time` Use `now` to have the end time be the present. + +Default: `Initial End Time` diff --git a/docs/pages/Scripts/scripts.markdown b/docs/pages/Scripts/scripts.markdown index 7f0cf86a..5c2ec7f4 100644 --- a/docs/pages/Scripts/scripts.markdown +++ b/docs/pages/Scripts/scripts.markdown @@ -7,46 +7,53 @@ nav_order: 8 # Scripts -Supporting scripts for LithoSphere can be found within `/scripts` at the project's root. Scripts can help with processing and formatting data. Only the significant ones will be detailed below and otherwise check them from READMEs. +On the supporting scripts inside `/auxiliary`. -## gdal2customtiles.py +Scripts can help with processing and formatting data. Only the significant ones will be detailed below and otherwise check them from READMEs. -This wraps together: +# gdal2customtiles.py -- gdal2tiles4extent.py -- gdal2tiles1bto4b_v3.py +_Python 3.10.5_ + +Accepts all [gdal2tiles.py](https://gdal.org/programs/gdal2tiles.html) options. Built off of GDAL 3.5.2 and tested with GDAL 3.4.3, it adds the following new features and capabilities. --- -### Raster Extents: +## Raster Extents: -Tile partial world rasters. +Tile partial world rasters. Useful for tiling non-mercator and non-geodetic projected data. **Requires:** - `-p raster` - This is necessary for generating tiles with a custom extent. -- `-x` OR `--extentworld` followed by values `ulx,uly,lrx,lry,pixel_resolution` +- `--extentworld` followed by values `ulx,uly,lrx,lry,pixel_resolution` - The extentworld is the full bounding area of the projection for the planetary body. The extentworld is the full bounding area of the projection for the planetary body. Units are in meters using upper left (ul) and lower right (lr) order. These values are reported from gdalinfo. Units are in meters using upper left (ul) and lower right (lr) order. These values are reported from gdalinfo. Values are separated by commas with no spaces. -**Example:** +#### Example: ``` -python gdal2customtiles.py -p raster --extentworld -4022404.001,4022036.893,-4022036.893,4022404.001,367.108150109358121 input.tif output_dir +python gdal2customtiles.py -p raster --extentworld -931100.000,931100.000,931100.000,-931100.000,100 inputs/WAC_GLOBAL_P900S0000_100M.tif outputs/WAC_GLOBAL_P900S0000_100M +python gdal2customtiles.py -p raster --extentworld -931100.000,931100.000,931100.000,-931100.000,100 inputs/ldem_87s_5mpp_hillshade.tif outputs/ldem_87s_5mpp_hillshade ``` +- `WAC_GLOBAL_P900S0000_100M.tif` is in Lunar South Polar projection (IAU2000:30120). Its data covers the full bounds of that projection's world-space (it's world extent/"extentworld") thus we use its bounds and pixel resolution directly from its metadata: `--extentworld -931100.000,931100.000,931100.000,-931100.000,100` + + - _Note: If your basemap does not cover the full world-space, you would need to compute the world-space's bounds and its resolution relative to your datasets_ + +- `ldem_87s_5mpp_hillshade.tif` is also in Lunar South Polar projection (IAU2000:30120). Its data only covers a small region of the projection's world-space. We still use the previous `--extentworld -931100.000,931100.000,931100.000,-931100.000,100` + _Notes:_ - Only works if set zoom (-z 0-10) encompasses the native zoom of the raster. -- 'ERROR 5's are expected. --- -### Digital Elevation Model Tiles: +## Digital Elevation Model Tiles: Generate Digital Elevation Maps (DEMs) tiles. -Any 32-bit image data can be encoded into the RGBA channels of a PNG. MMGIS uses this file type to create terrain meshes as well as for a data layer. +Any 32-bit image data can be encoded into the RGBA channels of a PNG. MMGIS uses this file type to create terrain meshes as well as for Data Layers. **Requires:** @@ -60,5 +67,35 @@ python gdal2customtiles.py -p raster --extentworld -4022404.001,4022036.893,-402 _Notes:_ -- Does not include the convenience of rasterstotiles.py yet. - Can only tile 32-bit images with --dem option. +- Current `--dem` tiles do not seam-match tile edges. This may or may not be desired (not seam-matching is better for Data Layers and the Viewshed Tool, but bad for MMGIS' 3D Globe/LithoSphere). If seam-matching is desired use `legacy/gdal2customtiles.py` or `legacy/gdal2customtiles_py27.py` +- Certain resampling methods can corrupt `--dem` results. +- To support the value 0, all 0 data values get mapped to to the value 2^31 (2147483648) (RGBA=79,0,0,0) and then decoded by the MMGIS reader back to 0. This avoids clashes with other nondata-like values writing to 0,0,0,0 in the outputted pngs. + +--- + +## Compositing Tiles: + +Adds the resampling algorithm `near-composite` that uses nearest-neighbor resampling and overlays the new tile onto the old tile (if any in output directory). This makes it possible to accumulate or combine tilesets at the indivdual tile image level. Data in tiles can be overwritten by this process so be cognizant of run order and input extents. + +**Example:** + +``` +python gdal2customtiles.py -r near-composite --srcnodata=-9999 --processes=40 --tilesize=128 --dem input_A.tif output_dir +python gdal2customtiles.py -r near-composite --srcnodata=-9999 --processes=40 --tilesize=128 --dem input_B.tif output_dir +``` + +_Notes:_ + +- Nodata values are treated as transparent and will not overwrite existing pixels in the output tile images. + +--- + +# raster2customtiles.py + +_Python 3.10.5_ + +A convience script that wraps gda2customtiles.py. Translates the input data into EPSG:4326 and sets proper ground control points. Might be outdated. Use gdal2customtiles directly for the most control. + +**Usage:** +`rasters2customtiles.py [options] input_file [output]` or see `--help` diff --git a/docs/pages/Setup/ENVs/ENVs.md b/docs/pages/Setup/ENVs/ENVs.md index 4128314a..a8a90cd8 100644 --- a/docs/pages/Setup/ENVs/ENVs.md +++ b/docs/pages/Setup/ENVs/ENVs.md @@ -74,11 +74,23 @@ Potentially logs a bunch of extra stuff for development purposes | bool | defaul #### `FRAME_ANCESTORS=` -Sets the `Content-Security-Policy: frame-ancestors` header to allow the embedding of MMGIS in the specified external sites | string[] | default `null` +Sets the `Content-Security-Policy: frame-ancestors` header to allow the embedding of MMGIS in the specified external sites | string[] | default `null` | ex. FRAME_ANCESTORS='["http://localhost:8888"]' -#### `PUBLIC_URL=` +#### `FRAME_SRC=` -Set MMGIS to be deployed under a subpath. Use full and absolute paths only to the project's build directory. For example if serving at the subpath 'mmgis/' is desired, set PUBLIC_URL to 'https://{domain}/mmgis/build'. Changing PUBLIC_URL required a rebuild. | string | default `null` (domain root build '/build') +Sets the `Content-Security-Policy: frame-src` header to allow the embedding iframes from external origins into MMGIS | string[] | default `null` | ex. FRAME_SRC='["http://localhost:8888"]' + +#### `THIRD_PARTY_COOKIES=` + +Sets "SameSite=None; Secure" on the login cookie. Useful when using AUTH=local as an iframe within a cross-origin page. | boolean | default `false` + +#### `ROOT_PATH=` + +Set MMGIS to be deployed under a subpath. For example if serving at the subpath 'https://{domain}/path/where/I/serve/mmgis' is desired, set `ROOT_PATH=/path/where/I/serve/mmgis`. If no subpath, leave blank. | string | default `""` + +#### `WEBSOCKET_ROOT_PATH=` + +Overrides ROOT_PATH's use when the client connects via websocket. Websocket url: `${ws_protocol}://${window.location.host}${WEBSOCKET_ROOT_PATH || ROOT_PATH || ''}/` | string | default `""` #### `CLEARANCE_NUMBER=` @@ -104,6 +116,22 @@ When not using AUTH=csso, this is a list of usernames to be treated as leads (us LDAP group of leads (users with elevated permissions) | string | default `''` -#### `ENABLE_MMGIS_SOCKETS=` +#### `ENABLE_MMGIS_WEBSOCKETS=` If true, enables the backend MMGIS websockets to tell clients to update layers | boolean | default `false` + +#### `ENABLE_CONFIG_WEBSOCKETS=` + +If true, notifications are sent to /configure users whenever the current mission's configuration object changes out from under them and thne puts (overridable) limits on saving | boolean | default `false` + +#### `ENABLE_CONFIG_OVERRIDE=` + +For use when `ENABLE_CONFIG_WEBSOCKETS=true` (if `ENABLE_CONFIG_WEBSOCKETS=false`, all saves will freely overwrite already). If true, gives /configure users the ability to override changes made to the configuration while they were working on it with their own. | boolean | default `false` + +#### `MAIN_MISSION=` + +If the new MAIN_MISSION ENV is set to a valid mission, skip the landing page and go straight to that mission. Other missions will still be accessible by either forcing the landing page (clicking the top-left M logo) or by going to a link directly. | string | default `''` + +#### `SKIP_CLIENT_INITIAL_LOGIN=` + +If true, MMGIS will not auto-login returning users. This can be useful when login is managed someplace else. The initial login process can be manually triggered with `mmgisAPI.initialLogin()` | boolean | default `false` diff --git a/docs/pages/Setup/Installation/Installation.md b/docs/pages/Setup/Installation/Installation.md index a0be1053..0040f488 100644 --- a/docs/pages/Setup/Installation/Installation.md +++ b/docs/pages/Setup/Installation/Installation.md @@ -10,7 +10,7 @@ nav_order: 1 ### System Requirements -1. Install the latest version of [Node.js v14.9.0+](https://nodejs.org/en/download/). +1. Install the latest version of [Node.js v16.13.2+](https://nodejs.org/en/download/). 1. Install [PostgreSQL v10.14+](https://www.enterprisedb.com/downloads/postgres-postgresql-downloads). Detailed [install instructions](https://www.postgresqltutorial.com/postgresql-getting-started/) for all platforms. 1. Install [PostGIS 2.5+](https://postgis.net/install/). From the above install, you can use the 'Application Stack Builder' to install PostGIS or the default [PostGIS install instructions](https://postgis.net/install/) for all platforms. diff --git a/docs/pages/Tools/Draw/Draw.md b/docs/pages/Tools/Draw/Draw.md index c886edc9..8921623d 100644 --- a/docs/pages/Tools/Draw/Draw.md +++ b/docs/pages/Tools/Draw/Draw.md @@ -34,7 +34,77 @@ There are five files that are group editable with the correct permission. The gr "done" ], "hoverLengthOnLines": false - "leadsCanEditFileInfo": false + "leadsCanEditFileInfo": false, + "templates": { + "example_1": [ + { + "type": "slider", + "field": "a", + "min": 0, + "max": 100, + "step": 1, + "default": 0 + }, + { + "type": "number", + "field": "b", + "min": 0, + "max": 100, + "step": 1, + "required": true, + "default": 3 + }, + { + "type": "text", + "field": "c", + "minLength": 2, + "maxLength": 4, + "required": true, + "regex": null, + "default": null + }, + { + "type": "textarea", + "field": "d", + "maxLength": 10, + "required": true, + "default": "hi" + }, + { + "type": "checkbox", + "field": "e", + "default": true + }, + { + "type": "dropdown", + "field": "f", + "items": [ + "Yes", + "No", + "Maybe" + ], + "default": "No" + }, + { + "type": "incrementer", + "field": "g", + "default": "ID-#" + }, + { + "type": "date", + "field": "h", + "format": "YYYY-MM-DDTHH:mm:ss", + "default": "2000-01-01T00:00:00" // Can be "NOW", "STARTTIME" or "ENDTIME" too for dynamic defaults + } + ], + "example_2": [ + { + "type": "checkbox", + "field": "i", + "default": false + } + ] + } } ``` @@ -42,10 +112,11 @@ _"intents"_: The names in quotes will be the group file names. _"preferredTags"_: Users can attach tags or keyword to files to organize them. Preferred Tags are curated tags and promoted over user generated ones. _"hoverLengthOnLines"_: If true, the hover text for line features will include the total length of the line in meters. _"leadsCanEditFileInfo"_: If true, lead roles can edit the file info, (name, description, tags, folder, make private) of any user's public file. +_"templates"_: Templates create forms for feature properties. For instance, all features in a given draw file could, in the feature's edit panel, have the field "Reviewed" be togglable via a checkbox. Users may make their own templates too but the ones configured here are promoted and cannot be delete. ## Tool Use -The Draw Tool has three panels: one for making files and controlling the intial feature creation, another for editing features and their properties, and lastly a panel for controlling the edit history. You can navigate between the panels by clicking on the icons at the top: Pencil icon (default) for panel 1, Shapes icon for panel 2, and Clock icon for panel 3. +The Draw Tool has three panels: one for making files and controlling the initial feature creation, another for editing features and their properties, and lastly a panel for controlling the edit history. You can navigate between the panels by clicking on the icons at the top: Pencil icon (default) for panel 1, Shapes icon for panel 2, and Clock icon for panel 3. ### Panels @@ -59,7 +130,7 @@ This panel creates files, manages them, and is where you initially make features #### Panel 2 -The shapes panel shows all the currently drawn features is a list. It serves as a quick way to view, select (and group select with CTRL and SHIFT) and navigate to the cooresponding features on the map. The bottom section allows users to copy selected features to other files. +The shapes panel shows all the currently drawn features is a list. It serves as a quick way to view, select (and group select with CTRL and SHIFT) and navigate to the corresponding features on the map. The bottom section allows users to copy selected features to other files. #### Panel 3 diff --git a/docs/pages/Tools/Identifier/Identifier.md b/docs/pages/Tools/Identifier/Identifier.md index cad41952..9799ed0e 100644 --- a/docs/pages/Tools/Identifier/Identifier.md +++ b/docs/pages/Tools/Identifier/Identifier.md @@ -7,7 +7,7 @@ parent: Tools # Identifier -Mouse over to query underlying datasets. This will read the raw values from a georeferenced dataset, which can be any bitdepth (8,16,32). You can set up multiple file to return values from. +Mouse over to query underlying datasets. This will read the raw values from a geo-referenced dataset, which can be any bit-depth (8,16,32). You can set up multiple file to return values from. ### Raw Variables diff --git a/docs/pages/Tools/Legend/Legend.md b/docs/pages/Tools/Legend/Legend.md index 80111b4c..be75ec89 100644 --- a/docs/pages/Tools/Legend/Legend.md +++ b/docs/pages/Tools/Legend/Legend.md @@ -7,9 +7,19 @@ parent: Tools # Legend -A layer can be configured with a legend by pointing its Legend field to a .csv file. The Legend Tool renders symbologies and gradient scales for any properly configured on layer. +A layer can be configured with a legend by pointing its Legend field to a .csv file or by including a JSON `legend` array into the layer's Raw Variables. The Legend Tool renders symbologies and gradient scales for any properly configured on layer. -The Legend Tool takes no raw variable configurations in the Tools Tab. +On the Configure page, under Tools, you can specify additional options: + +* displayOnStart: Whether the expanded legend should automatically be displayed on start (`true`/`false`) +* justification: The legend will display on the right side of the screen if set to `right`, otherwise default to the left side + +```javascript +{ + "displayOnStart": true, + "justification": "right" +} +``` ### legend.csv example: @@ -30,9 +40,108 @@ The Legend Tool takes no raw variable configurations in the Tools Tab. crimson,cyan,square,possibly indigo,#FFF,rect,contain +### Raw Variables examples: + +```json +{ + "legend": [ + { + "color": "purple", + "strokecolor": "#000", + "shape": "discreet", + "value": "This" + }, + { + "color": "cyan", + "strokecolor": "#000", + "shape": "discreet", + "value": "is" + }, + { + "color": "lime", + "strokecolor": "#000", + "shape": "discreet", + "value": "a" + }, + { + "color": " yellow", + "strokecolor": "#000", + "shape": "discreet", + "value": "sentential" + }, + { + "color": "orange", + "strokecolor": "#000", + "shape": "discreet", + "value": "example" + }, + { + "color": "red", + "strokecolor": "#000", + "shape": "discreet", + "value": "of" + }, + { + "color": "purple", + "strokecolor": "#000", + "shape": "continuous", + "value": "what" + }, + { + "color": "red", + "strokecolor": "#000", + "shape": "continuous", + "value": "values" + }, + { + "color": "white", + "strokecolor": "#000", + "shape": "continuous", + "value": "the" + }, + { + "color": "blue", + "strokecolor": "#000", + "shape": "continuous", + "value": "legend" + }, + { + "color": "pink", + "strokecolor": "#000", + "shape": "circle", + "value": "csv" + }, + { + "color": "green", + "strokecolor": "#000", + "shape": "discreet", + "value": "files" + }, + { + "color": " orange", + "strokecolor": "#000", + "shape": "discreet", + "value": "could" + }, + { + "color": "crimson", + "strokecolor": "cyan", + "shape": "square", + "value": "possibly" + }, + { + "color": "indigo", + "strokecolor": "#FFF", + "shape": "rect", + "value": "contain" + } + ] +} +``` + #### header -THe header must be `color,strokecolor,shape,value`. +The header/properties must be `color,strokecolor,shape,value`. #### color @@ -46,6 +155,6 @@ Any [CSS color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) to Can be either `circle`, `square`, `rect`, `discreet` and `continuous`. Discreet and continuous describe scales. These scales are broken into groups by a change in shape value. For instance, "discreet, discreet, discreet, circle, discreet, discreet" represents a discreet scales of three colors, a circle and then a discreet scale of two colors. -### value +#### value A string value for the legend entry. diff --git a/documentation/docs.js b/documentation/docs.js index 58403063..bbc338b9 100644 --- a/documentation/docs.js +++ b/documentation/docs.js @@ -1,51 +1,8 @@ //Form nav -let pages = [ - "README", - "JavaScript_API", - "AR_and_VR", - "Deep_Linking", - "Development", - "ENVs", -]; -let configure = [ - "Configure", - "Overall_Tab", - "Initial_Tab", - "Layers_Tab", - "Tools_Tab", - "Projection_Tab", - "Look_Tab", - "Panels_Tab", - "Time_Tab", - "Kinds", - "Vector_Styling", - "Layer_URLs", - "Keys", - "Manage_Datasets", - "Manage_Geodatasets", - "Remote_Virtual_Layer", -]; -let layers = [ - "Data", - "Header", - "Model", - "Query", - "Tile", - "Vector_Tile", - "Vector", -]; -let tools = [ - "Chemistry", - "Draw", - "Identifier", - "Info", - "Isochrone", - "Layers", - "Legend", - "Measure", - "Sites", - "Viewshed", -]; +let pages = ["README"]; +let configure = []; +let layers = []; +let tools = []; let apis = [ { name: "Main", path: "../api/docs/main" }, { name: "Spatial", path: "../api/docs/spatial/" }, diff --git a/documentation/pages/markdowns/AR_and_VR.md b/documentation/pages/markdowns/AR_and_VR.md deleted file mode 100644 index 1661394e..00000000 --- a/documentation/pages/markdowns/AR_and_VR.md +++ /dev/null @@ -1,120 +0,0 @@ -# AR and VR - -MMGIS offers several immersive ways to better view and understand data through use of virtual and augmented reality. - -- [Photosphere](#photosphere) - - [Requires](#photosphere-requires) - - [Usage](#photosphere-using) - - [Development](#photosphere-code) -- [Headset VR](#headset-vr) - - [Requires](#globevr-requires) - - [Usage](#globevr-using) - - [Development](#globevr-code) -- [Globe AR](#globe-ar) - - [Requires](#globear-requires) - - [Usage](#globear-using) - - [Development](#globear-code) - ---- - -### Photosphere - -The Viewer's photosphere supports device orientation controls to navigate around its wrapped imagery. - -<h4 id="photosphere-requires">Requires</h4> - -- A smartphone with an accelerometer -- A modern mobile browser (developed on Chrome) - _Caveat_: Some browsers on IPhone at the time of development failed to render high resolution photospheres. - -<h4 id="photosphere-using">Usage</h4> - -Select a point with mosaic imagery (such as a Waypoint from the MSL mission). Open the Viewer by clicking the left thumb-tab. The bottom-left corner contains a fairly transparent icon of a rotating smartphone; click it to enable device orientation controls. You can now move you phone around to view the photosphere imagery! - -<h4 id="photosphere-code">Development</h4> - -Uses three.js' [Device Orientation Controls](https://github.com/mrdoob/three.js/blob/dev/examples/js/controls/DeviceOrientationControls.js) - ---- - -### Headset VR - -Both the Viewer and Globe have basic support for headset VR. Controls are not supported. The support for Headset VR doesn't get much farther than simply looking around. - -<h4 id="globevr-requires">Requires</h4> - -_Note_: VR is a quickly moving technology and processes become outdated rather quickly. Check online first to see how to set up GearVR or Oculus for WebVR. - -- A [GearVR](https://www.oculus.com/gear-vr/) headset -- A supported GearVR smartphone -- Samsung internet GearVR browser - -OR - -- An [Oculus Rift](https://www.oculus.com/) headset -- An Oculus Sensor -- A USB gamepad such as an XBox controller -- The [Oculus Desktop App](https://www.oculus.com/setup/) -- [Steam](https://store.steampowered.com/) with SteamVR -- Oculus' default Firefox browser - -<h4 id="globevr-using">Usage</h4> - -Within a VR browser select a point with mosaic imagery (such as a Waypoint from the MSL mission). Open the Viewer by clicking the left thumb-tab or open the Globe by clicking the right thumb-tab. The bottom-right corner contains a fairly transparent icon of a headset; click it to enter VR and click it again if you wish to exit. You can now look around in VR! - -<h4 id="globevr-code">Development</h4> - -Uses three.js' vr configurations paired with the headset's utilization of [WebVR](https://webvr.info/). - ---- - -### Globe AR - -The Globe has the ability to render terrain such that looking through the phone shows it placed in the user's real world surroundings. Users can then replace, rotate, scale, pan and zoom the terrain. This technology is still experimental but we're confident it'll become standardized within the coming year or so. - -<h4 id="globear-requires">Requires</h4> - -- A smartphone with ARCore installed and a mobile browser that recognizes and uses it - - This may not be possible. Current technology (Sept 2018) is only barely starting to support this out-of-the-box. - -OR - -- Follow [this ReadMe's](https://github.com/google-ar/WebARonARCore) installation for Android - - The Globe AR was developed using this experimental browser on a Samsung S8 smartphone - -<h4 id="globear-using">Usage</h4> - -Open your AR supported browser and navigate to https://miplmmgis.nasa.gov/mmgis/MMGIS. Choose a mission and open the globe panel. In the globe panel there's a semi-transparent icon of an eye. Click it to enable AR. _Note_: You may need to allow the page to access you camera first. Point the camera around the room so it can identify surfaces. - -Buttons (clockwise and starting from the bottom left corner): - -- _Placement mode_: This rounded square should begin filled in. When it's filled in, a magenta square will try to land on the nearest found surface. Clicking anywhere in the middle of the screen will reposition the terrain to that location. Click this button to toggle this mode off for now; you can always retoggle it to place again. -- _Height slider_: The slider just above simply lets you move the terrain up or down for greater placement control. -- _Scale_: This upper-left plus and minus lets you scale the terrain up and down. Press and hold to change scales more quickly. Scalings don't update until these buttons are released. -- _Zoom_: This upper-right plus and minus change the zoom level. This effectively changes the resolution of the terrain. -- _Exit AR_: Finally the eye icon in the lower left exits out of the AR mode. - -Joysticks: -While outside of placement mode (this bottom-left square unfilled) each side of the screen corresponds to a joystick. -_Rotate_: Hold down the left side of the screen and drag your finger around to rotate the terrain. -_Pan_: Hold down the right side of the screen and drag you finger around to pan. - -<h4 id="globear-code">Development</h4> - -Developed on a Samsung S8 Android smartphone and with a Windows 7 computer. - -1. The site must be served across `HTTPS`. -1. Enable developer access through the phone's settings. -1. Download the experimental AR browser and ARCore from the [WebARonARCore](https://github.com/google-ar/WebARonARCore) repository. - -1. Allow the computer to read data off the phone if prompted. -1. For your computer to properly recognize the phone, install [Minimal ADB and Fastboot](https://forum.xda-developers.com/showthread.php?t=2588979). -1. With the phone plugged in to your computer, navigate to its install directory and run `adb devices`. - -1. With the phone still plugged in, open the experimental `WebARonARCore` browser on the phone. -1. Open Chrome and open the developer console. -1. Click the three vertical dots menu and choose "More tools" and click "Remote devices" -1. Wait for Chrome to identify any devices. _Note_: If there many devices, you may need to `ctrl -` to zoom out and find the phone as there isn't a scrollbar. -1. Click on the device corresponding to the phone and then click "Inspect" - -You should now see the emulation of the phone as well as its console outputs. diff --git a/documentation/pages/markdowns/Chemistry.md b/documentation/pages/markdowns/Chemistry.md deleted file mode 100644 index b35ad28f..00000000 --- a/documentation/pages/markdowns/Chemistry.md +++ /dev/null @@ -1,36 +0,0 @@ -# Chemistry - -Graphs a feature's oxide percentages by shot number. - -### Setup Example - -1. Within the configure page's layers tab create a new layer with Kind of Layer set to Chemistry Tool. -1. Set it's URL to a geojson file or geodataset where each feature contains a property called "TARGET". This "TARGET" should correspond to the "Target" in the next step. -1. Upload a csv dataset called "ccam_single_shots" that contains a column for "Target", "ShotNumber", "Al2O3", "CaO", "FeOT", "K2O", "MgO", "Na2O", "SiO2" and "TiO2" -1. Use the following for the layer's raw variables: - - ```javascript - { - "datasetLinks": [ - { - "prop": "TARGET", - "dataset": "ccam_single_shots", - "column": "Target", - "type": "" - } - ], - "chemistry": [ - "Al2O3", - "CaO", - "FeOT", - "K2O", - "MgO", - "Na2O", - "SiO2", - "TiO2" - ] - } - ``` - - - `datasetLinks` is saying: When a user clicks on a feature of this layer, query the MMGIS database. Look for the dataset called "ccam_single_shots" and look at the column "Target". Return back every row of the dataset where the feature's property "TARGET"s value equals that of "Target". - - `chemistry` describes which chemistry columns to use as percentages and it what order. diff --git a/documentation/pages/markdowns/Configure.md b/documentation/pages/markdowns/Configure.md deleted file mode 100644 index e4e49ae7..00000000 --- a/documentation/pages/markdowns/Configure.md +++ /dev/null @@ -1,44 +0,0 @@ -# Configure - -A key feature of MMGIS is that it's Multi-Mission and thus configurable. The configuration page is where you can create new missions and add tools and layers to your mission. A mission named `Test` is included as a sample so that you can view how it was configured. To enable it, create a new mission named "Test". - -## Getting Started - -#### Navigating to Configure - -The configuration in accessible through the browser by appending `configure` to the page's URL like so: - -`https://path-to-MMGIS/configure` - -Login in with your admin account. If this is your first visit to the page, sign up for an admin account and then re-enter the credentials. - -#### Navigation Panel - -When first opening the page, it'll be mostly blank except for a title and a navigation panel. - -- The first button in the navigation bar is named `New Mission` which opens a tab that enables you to create a new mission. -- All the buttons below correspond to a preexisting missions. Clicking on one opens up the configurations tabs for that mission. -- At the very bottom are additional pages that manage datasets that can be stored in the database. - -#### Creating a New Mission - -Missions can be thought of as separate instances of MMGIS. If there is more than one mission configured, a landing page will enable the selection of them. - -1. Click on `New Mission` -1. Enter a Mission Name (this cannot match any preexisting mission names) -1. By default, a templated mission directory will be created in the `Missions` folder. If you'd rather not have this happen, uncheck the option. Relative URLs will still default there though. -1. Click `Make Mission` - -You should see a success message and the page should reload. The reloaded page should now show your mission in the navigation panel and be accessible through the landing page or by going to `https://path-to-MMGIS/?mission=[new mission name]` or, if it's the only mission, at `https://path-to-MMGIS`. - -## Configuring A Mission - -Once you select a mission, you'll be presented with a view with tabs at the top. Each tab modifies some aspect of MMGIS is explained in detail in its corresponding documentation page. - -## Saving Changes - -To save changes, click `Save Changes` at the bottom right. - -If all went well, it should say `Save Successful`. If not, explanations will pop up in the top right. - -_If you switch missions tabs or close the page before saving, your changes will be lost!_ diff --git a/documentation/pages/markdowns/Data.md b/documentation/pages/markdowns/Data.md deleted file mode 100644 index 9651e714..00000000 --- a/documentation/pages/markdowns/Data.md +++ /dev/null @@ -1,94 +0,0 @@ -# Data Layers - -Data layers use WebGL shaders to generate tiles on the fly. - -#### Layer Name - -_type:_ string -The unique display name and identifier of the layer. It must be unique and contain no special characters. - -#### URL - -_type:_ string -A relative to the mission directoty or absolute file path to a Digital Elevation Map tileset generated by `auxillary/1bto4b/rasterstotiles1bto4b.py` - -#### Legend - -_type:_ string -An absolute or relative file path pointing to a `legend.csv` that describes the symbology of the layer. Please see the Legend Tool to see how to form a `legend.csv`. - -#### Initial Visibility - -_type:_ bool -Whether the layer is on initially. - -#### Minimum Zoom - -_type:_ integer -The lowest (smallest number) zoom level of the tile set. -_Note: This field can be automatically populate with "Populate from XML". "Populate from XML" uses looks for a `tilemapresource.xml` in the tileset directory specified by the URL field._ - -#### Maximum Native Zoom - -_type:_ integer -The highest (largest number) zoom level of the tile set. -_Note: This field can be automatically populate with "Populate from XML". "Populate from XML" uses looks for a `tilemapresource.xml` in the tileset directory specified by the URL field._ - -#### Maximum Zoom - -_type:_ integer -The highest (largest number) zoom level to see in MMGIS. This value is at least as high as Maximum Native Zoom. This allows zooms level higher than that of the tileset. Instead of rendering new tile image, it scales them in instead. - -#### Bounding Box - -_type:_ string _optional_ -A comma separated string defining the tileset's `minimumLonDeg,minimumLatDeg,maximumLonDeg,maximumLatDeg`. Setting a bounding box improves performance by limiting requests for tiles to only those that fit the bounds. -_Note: This field can be automatically populate with "Populate from XML". "Populate from XML" uses looks for a `tilemapresource.xml` in the tileset directory specified by the URL field._ - -#### Time Enabled - -_type:_ bool -True if the layer is time enabled. URLs that contain `{starttime}` or `{endtime}` will be dynamically replaced by their set values when the layer is fetched. - -#### Time Type - -_type:_ enum [Global, Individual] -Whether the layer should use global time values or function independently with its own time values. - -#### Time Format - -_type:_ string _optional_ -The string format to be used in the URL for `{starttime}` and `{endtime}`. Defaults to `YYYY-MM-DDTHH:mm:ssZ`. - -#### Raw Variables - -Data layers need a configured `shader` raw variable to be effective. Supported shader types are as follows: - -- "colorize": Allows users to apply and configure dynamic color ramps to the data. Uses the current minimum and maximum viewport data values to adjust color ramps into the most relevant range. - - units: A string to append to user displayed data values. - - noDataValues: Values to exclude from minimum and maximum calculations. - - sigfigs: How many significant figures to round user displayed values. - - ramps: An array of arrays of hex color strings. "transparent" is a special keyword for a fully transparent ramp color. -- "image": (Default) Simply shows the underlying raw data in an image form. Mainly for testing, it can also be useful for development for internal pass-tile-canvas-instead-of-url layers. - -Example: - -```javascript -{ - "shader": { - "type": "colorize", - "units": "m", - "noDataValues": [ - 0 - ], - "sigfigs": 3, - "ramps": [ - [ - "#FF0000", - "transparent", - "#0000FF" - ] - ] - } -} -``` diff --git a/documentation/pages/markdowns/Deep_Linking.md b/documentation/pages/markdowns/Deep_Linking.md deleted file mode 100644 index 8dd67c52..00000000 --- a/documentation/pages/markdowns/Deep_Linking.md +++ /dev/null @@ -1,167 +0,0 @@ -# Deep Linking - -The main state of MMGIS can be saved and shared by manipulating the URL. The following parameters describe the specifics of that state. Additionally there's a green "Copy Link" icon in the MMGIS toolbar that constructs these URLs. Those URLs are initially shortened but can be navigated to to view their expanded form in the address bar. - -## Parameters - -### mission=<br>`<mission name>` - -The mission to navigate to. - -- _form:_ `<string>` -- _dependencies_: NONE -- _unset:_ Will direct to a landing page to choose a mission. If there exists only one configured mission, then automatically go to it. - -### site=<br>`<site code>` - -The site described in the SitesTool to navigate to. - -- _form:_ `<string>` -- _dependencies_: SitesTool -- _unset:_ If the SitesTool is enable and has sites, it will default to the first defined site. - -### mapLon=<br>`<longitude>` - -- _form:_ `<float>` -- _dependencies_: mapLat, mapZoom -- _unset:_ Will default to the initial view - -### mapLat=<br>`<latitude>` - -- _form:_ `<float>` -- _dependencies_: mapLon, mapZoom -- _unset:_ Will default to the initial view - -### mapZoom=<br>`<zoom level>` - -- _form:_ `<positive integer>` -- _dependencies_: mapLon, mapLat -- _unset:_ Will default to the initial view - -### globeLon=<br>`<longitude>` - -- _form:_ `<float>` -- _dependencies_: globeLat, globeZoom -- _unset:_ Will default to the initial view - -### globeLat=<br>`<latitude>` - -- _form:_ `<float>` -- _dependencies_: globeLon, globeZoom -- _unset:_ Will default to the initial view - -### globeZoom=<br>`<zoom level>` - -- _form:_ `<positive integer>` -- _dependencies_: globeLon, globeLat -- _unset:_ Will default to the initial view - -### globeCamera=<br>`<posX>,<posY>,<posZ>,<tarX>,<tarY>,<tarZ>` - -Defines the 3d coordinates [posX, posY, posZ] of where the Globe camera is position and points the Globe camera to look at [tarX, tarY, tarZ]. The Globe view is always centered at 0,y,0 with the y-axis up. - -- _form:_ `<float,float,float,float,float,float>` -- _dependencies_: NONE -- _unset:_ Will default to an initial top-down view - -### panePercents=<br>`<viewerPercent>,<mapPercent>,<globePercent>` - -How much to open each panel. _All three values should add up to 100_. `0,100,0` would be the map covering the whole screen. `0,50,50` would be the screen split half way between the map and globe. - -- _form:_ `<float,float,float>` -- _dependencies_: NONE -- _unset:_ Will default to `0,100,0` - -### on=<br>`<name>$<opacity>,<name>$<opacity>...` - -The name of the layer that's on and its opacity. When using the on parameter, all unlisted layers are deemed off. If a site is defined in the URL, the site's layers will turn on regardless. - -- _form:_ `<string$float,string$float,string$float,...>` -- _dependencies_: NONE -- _unset:_ Only layers visible by default will be on - -### centerPin=<br>`<hoverText>` - -If a map latitude and longitude is set and centerPin has a value, then render a pin on the map at the its center. The value of centerPin becomes the pin/marker's mouse over text. If centerPin=true (or ''), then there is no mouse over text for the pin. This parameter is useful when you want to link to a specific coordinate on the map and maintain its location for the user rather than just setting the initial map view. - -- _form:_ `<hoverText> || true || ''` -- _dependencies_: mapLon, mapLat -- _unset:_ No center point pin will be displayed - -### selected=<br>`<layer name>,<lat>,<lon>,<view (opt)>,<zoom level (opt)>`<br>`<layer name>,<key>,<value>,<view (opt)>,<zoom level (opt)>` - -The feature of a layer to have selected. If `lat` and `lon` are both numbers, the first _point_ in `layer name` with coordinates `lat` `lon` will be selected. Otherwise it'll be treated as a `key` `value` search. Under `key` `value` the first _feature_ in `layer name` whose `properties.<key>` matches `value` gets selected. `key` supports nested properties with dot notation ("buildings.stores.candy"). The selected `layer name` layer will always be turned on regardless of what the other parameters may say. `view` and `zoom level` are _optional_. If `view` is set to "go", the selection would not only be made but also panned to. `zoom level` sets the zoom of `view's` "go". If `zoom level` is unset but `view` is set, it will default to the `Zoom Level of Map Scale` configuration value if set or finally the `Initial Zoom Level` configuration variable. - -- _form:_ `<string,float,float,string,integer | string,string,string,string,integer>` -- _dependencies_: NONE -- _unset:_ No feature will be selected - -### viewerImg=<br>`<index>` - -The index of the list of image products within the viewer. The viewer will only be populated with this list if a feature with image products is selected. The viewer captures any image, dzi, obj URLs found within the selected point's metadata to form this list. - -- _form:_ `<integer>` -- _dependencies_: NONE -- _unset:_ Will default to the first image (if any) - -### viewerLoc=<br>`<posX>,<posY>,<w>,<h>` (boundingbox for images)<br>`<tarX>,<tarY>,<tarZ>,<fov>` (target and field of view for photosphere)<br>`<posX>,<posY>,<posZ>,<tarX>,<tarY>,<tarZ>` (position and target for models) - -- Bounding box is a top-left origined bounding box. -- Photosphere describes the camera's target and its field of view. Field of view in the photosphere is effectively zoom. -- Model is of the same form as `globeCamera` - -The view of the image. The viewer supports regular images, spherically projected images and models and this parameter should match the view type of the image at `viewImg`s index. - -- _form:_ `<float,float,integer,integer | float,float,float,float | float,float,float,float,float,float>` -- _dependencies_: NONE -- _unset:_ Will default to an initial view - -### forcelanding=<br>`<boolean>` - -If no `mission` is set in the URL, there exists only one configured mission and `forcelanding` is set to "true", then the landing page will not automatically redirect to the only configured mission. - -- _form:_ `<boolean>` -- _dependencies_: mission is unset -- _unset:_ The landing page will redirect to the only mission if there exists only one configured mission - -### startTime=<br>`<start time>` - -Sets the start time for the time control feature. - -- _form:_ `<string>` -- _dependencies_: Time control -- _unset:_ Will default to current time if time control feature is enabled - -### endTime=<br>`<end time>` - -Sets the end time for the time control feature. - -- _form:_ `<string>` -- _dependencies_: Time control -- _unset:_ Will default to current time if time control feature is enabled - -## Examples - -#### General - -``` -https://<domain>/?mission=MSL&site=GAC&mapLon=137.36826181411746&mapLat=-4.676391308143136&mapZoom=16&globeLon=137.3738&globeLat=-4.674800000000008&globeZoom=16&globeCamera=673.9200228913286,3890.288691365299,-1563,0,4423.768073682673,0&panePercents=32.64331210191082,45.1167728237792,22.23991507430998&on=ChemCam$1.00,Waypoints$0.57,Traverse$1.00,GPR_1$1.00,HiRISE$1.00,Aeolis%20Palus$1.00&selected=Waypoints,-4.675793594577601,137.36642934025107&viewerImg=0&viewerLoc=0.04430,0.05091,-0.03785,37.5 -``` - -#### Selecting and navigating to a feature in a layer named `Published Strategic Targets` by its property `uuid` - -``` -https://<domain>/?mission=<mission>&selected=Published%20Strategic%20Targets,uuid,a6222bca-6c51-4647-b28c-70b5e2d05886,go -``` - -#### Selecting and navigating to a feature in a layer named `Tactical Targets` by its nested property `data.uuid` - -``` -https://<domain>/?mission=<mission>&selected=Tactical%20Targets,data.uuid,170e096a-75c9-4db5-be64-d713e3a40955,go -``` - -#### Selecting and navigating to a feature in a layer named `End of Drive` by its property `site_pos` - -``` -https://<domain>/?mission=<mission>&selected=End%20of%2Drive,site_pos,<site>_<pos>,go -``` diff --git a/documentation/pages/markdowns/Development.md b/documentation/pages/markdowns/Development.md deleted file mode 100644 index b6a95305..00000000 --- a/documentation/pages/markdowns/Development.md +++ /dev/null @@ -1,188 +0,0 @@ -# Development - -### NOT UP TO DATE if MMGIS2+ (require.js removed, webpack added, react supported) - -MMGIS is written in JavaScript and uses [Require.js](http://requirejs.org/) as an architectural platform for the front end and [Node.js](https://nodejs.org/). - -##### Contents - -- [Developing A New Tool](#developing-a-new-tool) - - [Setup](#setup) - - [Developing](#developing) - - [Overview](#overview) - - [Template Walkthrough](#template-walkthrough) -- [Developing A New Backend](#developing-a-new-tool) - - [Setup](#setup) - - [Developing](#developing) - - [Overview](#overview) - - [Template Walkthrough](#template-walkthrough) - ---- - -## Developing A New Tool - -### Setup - -New tools are automatically found and included on start. - -1. Go to `scripts/essence/Tools` - 1. Create a new directory here with the name of your new tool - 1. Copy and paste `New Tool Template.js` into your new directory - 1. Rename the pasted file to `[Your Tool's Name]Tool.js` -1. Restart the server with `npm start` - -1. Use the `/configure` page to enable the tool in your development environment - -### Developing - -#### Overview - -Ideally all the code for a tool will be in its `[Tool's Name]Tool.js` and built off of the `New Tool Template.js`. - -- All tools must return an object with `make` and `destroy` functions. - - `make` is called when the user clicks on the tool's icon while `destroy` is called when the user clicks on any other tool's icon. -- Tools should work independently of one another. -- Tools should only change the `#tools` div or something in the viewer, map and/or globe. - -#### Template Walkthrough - -An in-depth walkthrough of `New Tool Template.js`: - -```javascript -define( [ 'jquery', 'd3', 'Formulae_', 'Layers_', 'Globe_', 'Map_', 'Viewer_' ], -function ( $ , d3 , F_ , L_ , Globe_ , Map_ , Viewer_ ) { -``` - -This is the main module container form for require.js. Here, by default, jquery, d3, Formulae\_, Layers\_, Globe\_, Map\_ and Viewer\_ are brought in. You can access those module objects by typing their corresponding function parameter (i.e. jquery's is \$) and using the normal dot notation: `F_.hexToRGB( '#000' );`. - -- jquery: DOM manipulator -- d3: DOM manipulator -- Formulae\_: A collection of mathy formulas such as bearings between coordinates or a true modulo function -- Layers\_: Manages MMGIS' data and layers such as get layers by name and toggling layers on and off -- Globe\_: The 3D globe panel -- Map\_: The 2D map -- Viewer\_: The image viewer - -```javascript -var markup = [].join("\n"); -``` - -Since tools are dynamically added to the DOM, it may be easier to directly write the tool HTML into `markup` where each element is its own line and then add that markup to the `#tools` div. - -```javascript -var NewToolTemplate = { - MMGISInterface: null, - make: function () { - this.MMGISInterface = new interfaceWithMMGIS(); - }, - destroy: function () { - this.MMGISInterface.separateFromMMGIS(); - }, -}; -``` - -This is the object the tool must return. `NewToolTemplate` should be renamed to `[Tool's Name]Tool`. `MMGISInterface` just helps keep the DOM elements and stylings separate. `make` is called right when the user activates the tool. Because tools all share the same div, each time a tool is made it must recreate its DOM. `destroy` is called right when the user activates another tool. Feel free to add other functions to this object or outside of it. - -```javascript -function interfaceWithMMGIS() { - this.separateFromMMGIS = function () { - separateFromMMGIS(); - }; - - //MMGIS should always have a div with id 'tools' - var tools = d3.select("#tools"); - //Clear it - tools.selectAll("*").remove(); - //Add a semantic container - tools = tools - .append("div") - .attr("class", "center aligned ui padded grid") - .style("height", "100%"); - //Add the markup to tools or do it manually - //tools.html( markup ); - - //Add event functions and whatnot - - //Share everything. Don't take things that aren't yours. - // Put things back where you found them. - function separateFromMMGIS() {} -} -``` - -`interfaceWithMMGIS` just clears the `#tools` div and adds a semantic-ui grid and is called immediately once the object is invoked. `separateFromMMGIS` is then called later from `destroy`. - -```javascript -return NewToolTemplate; -``` - -Return the NewToolTemplate or whatever its name was changed to. - -## Developing A New Backend - -### Setup - -New backends are automatically found and included on start. - -1. Go to `API/Backend` - 1. Create a new directory here with the name of your new backend - 1. Copy and paste `setupTemplate.js` into your new directory - 1. Rename the pasted file to `setup.js` - 1. Edit `setup.js` based on the development guide below -1. Restart the server with `npm start` - -### Developing - -#### Overview - -All the code for a backend must stay in its `API/Backend/[name]` directory. - -- Backends should work independently of one another. -- Use the existing backends as a reference point. - -#### Template Walkthrough - -```javascript -const router = require("./routes/your_router"); -``` - -Write scripts within you backend directory and import them. Most backends follow the directory structure: - -- API/Backend/[name] - - models/ - - routes/ - - setup.js - -``` -let setup = { - //Once the app initializes - onceInit: s => {}, - //Once the server starts - onceStarted: s => {}, - //Once all tables sync - onceSynced: s => {}, - envs: [{ name: "ENV_VAR", description: "", required: false, private: false }] -}; -``` - -onceInit() is called immediately on `npm start` -onceStarted() is called once the http server starts up -onceSynced() is called once all table are created/has their existence verified. - -The s parameter is an object containing the app and middleware. A common form to attach an API within a `setup.js` is to fill onceInit() with: - -```javascript -onceInit: (s) => { - s.app.use( - "/API/example", - s.ensureUser(), - s.checkHeadersCodeInjection, - s.setContentType, - s.stopGuests, - importedRouter - ); -}; -``` - -`envs` help document which environment values the backend uses and logs errors if required environment variables aren't set. Variables that end with `_HOST` are for URLs and upon start up they'll be pinged and there status will be logged. - -Please refer to the existing backend directories for further examples. diff --git a/documentation/pages/markdowns/Draw.md b/documentation/pages/markdowns/Draw.md deleted file mode 100644 index fb8ec891..00000000 --- a/documentation/pages/markdowns/Draw.md +++ /dev/null @@ -1,49 +0,0 @@ -# Draw - -The Draw tool is an advanced vector data creation and editing tool supporting a multi-user environment. Users can create and manage their own files which can have points, lines, and polygons as well as arrows and text to support annotation. Files can be viewed between users and features copied from one file to another. - -## Tool Configuration - -There are five files that are group editable with the correct permission. The group authentication is set an environment variable in the .env file during startup. These files are meant as collaborative layers that a only a few people will manage and contribute to do to the potential of race conditions on who did the last edit. - -### Example Tool Tab Variables - -```javascript -{ - "intents": [ - "Polygon_1_Alias", - "Polygon_2_Alias", - "Polygon_3_Alias", - "Line_Alias", - "Point_Alias" - ], - "preferredTags": [ - "campaign1", - "campaign2", - "science1", - "science2", - "plan1", - "plan2", - "done" - ], - "hoverLengthOnLines": false -} -``` - -_"intents"_: The names in quotes will be the group file names. -_"preferredTags"_: Users can attach tags or keyword to files to organize them. Preferred Tags are curated tags and promoted over user generated ones. -_"hoverLengthOnLines"_: If true, the hover text for line features will include the total length of the line in meters. - -## Tool Use - -The Draw Tool has three panels: one for making files and controlling the intial feature creation, another for editing features and their properties, and lastly a panel for controlling the edit history. You can navigate between the panels by clicking on the icons at the top: Pencil icon (default) for panel 1, Shapes icon for panel 2, and Clock icon for panel 3. - -### Panel 1 - - -This panel creates files, manages them, and is where you initially make features. - -- To create a file, type in a new file name where it says "New File" at the top. The feature type defaults to "Map", which can hold all the different vector types (point, line, polygon) and annotations (arrows and text). Left-click the '+' sign or hit return in the 'New File' area to create the file. It will appear below the 'Lead Maps' Other -  - - diff --git a/documentation/pages/markdowns/ENVs.md b/documentation/pages/markdowns/ENVs.md deleted file mode 100644 index 44d36a30..00000000 --- a/documentation/pages/markdowns/ENVs.md +++ /dev/null @@ -1,98 +0,0 @@ -# Environment Variables - -Environment variables are set within `MMGIS/.env`. A sample file `MMGIS/sample.env` is provided. On startup, erroneous .env setups are logged. - -## Required Variables - -#### `SERVER=` - -The kind of server running (apache is deprecated) | string enum | default `''` - -- _node:_ A node express server running NodeJS > 10.10 -- _apache (deprecated):_ Served through Apache. Some or all functionality may not work - -#### `AUTH=` - -The kind of authentication method used | string enum | default `''` - -- _off:_ No authentication. Users cannot sign up or log in. Tools that require log in will not work. -- _none:_ No authentication. Users can still sign up and log in from within MMGIS. -- _local:_ Anyone without credentials is blocked. The Admin must log in, create accounts and pass out the credentials. -- _csso:_ Use a Cloud Single Sign On service that's proxied in front of MMGIS. - -#### `NODE_ENV=` - -Instance type | string enum | default `production` - -- _production:_ -- _development:_ Shows configure and documentation links on the landing page for convenience - -#### `SECRET=` - -Some random string | string | default `null` - -#### `DB_HOST=` - -URL of Postgres database | string | default `null` - -#### `DB_PORT=` - -Port for Postgres database | string | default `null` - -#### `DB_NAME=` - -Name of Postgres database | string | default `null` - -#### `DB_USER=` - -User of Postgres database | string | default `null` - -#### `DB_PASS=` - -Password of Postgres database | string | default `null` - -#### `CSSO_GROUPS=` - -A list of CSSO LDAP groups that have access | string[] | default `[]` - -## Optional Variables - -#### `PORT=` - -Port to run on | positive integer | default `3000` - -#### `VERBOSE_LOGGING=` - -Potentially logs a bunch of extra stuff for development purposes | bool | default `false` - -#### `FRAME_ANCESTORS=` - -Sets the `Content-Security-Policy: frame-ancestors` header to allow the embedding of MMGIS in the specified external sites | string[] | default `null` - -#### `PUBLIC_URL=` - -Set MMGIS to be deployed under a subpath. Use full and absolute paths only to the project's build directory. For example if serving at the subpath 'mmgis/' is desired, set PUBLIC_URL to 'https://{domain}/mmgis/build'. Changing PUBLIC_URL required a rebuild. | string | default `null` (domain root build '/build') - -#### `CLEARANCE_NUMBER=` - -Sets a clearance for the website | string | default `CL##-####` - -#### `DISABLE_LINK_SHORTENER=` - -If true, users that use the 'Copy Link' feature will receive a full-length deep link. Writing new short links will be disabled but expanding existing ones will still work. | bool | default `false` - -#### `HIDE_CONFIG=` - -Make the configure page inaccessible to everyone | bool | default `false` - -#### `FORCE_CONFIG_PATH=` - -The path to a json config file that acts as the only configured mission for the instance | string | default `''` - -#### `LEADS=` - -When not using AUTH=csso, this is a list of usernames to be treated as leads (users with elevated permissions) | string[] | default `[]` - -#### `CSSO_LEAD_GROUP=` - -LDAP group of leads (users with elevated permissions) | string | default `''` diff --git a/documentation/pages/markdowns/Header.md b/documentation/pages/markdowns/Header.md deleted file mode 100644 index c38a30b6..00000000 --- a/documentation/pages/markdowns/Header.md +++ /dev/null @@ -1,13 +0,0 @@ -# Header - -Header layers contain no content but allows other layers to be grouped underneath it much like a directory. - -#### Layer Name - -_type:_ string -The unique display name and identifier of the layer. It must be unique and contain no special characters. - -#### Initial Visibility - -_type:_ bool -Whether the contents of this header are possibly visible initially. diff --git a/documentation/pages/markdowns/Identifier.md b/documentation/pages/markdowns/Identifier.md deleted file mode 100644 index da0b36ad..00000000 --- a/documentation/pages/markdowns/Identifier.md +++ /dev/null @@ -1,25 +0,0 @@ -# Identifier - -Mouse over to query underlying datasets. This will read the raw values from a georeferenced dataset, which can be any bitdepth (8,16,32). You can set up multiple file to return values from. - -### Raw Variables - -The following is an example of the Sites Tool's Tool Tab configuration: - -```javascript -{ - "Layer_Name": { - "url": "(str) path_to_data/data.tif", - "bands": "(int) how many bands to query from", - "sigfigs": "(int) how many digits after the decimal", - "unit": "(str) whatever string unit" - }, - "...": {} -} -``` - -- `Layer_Name`: This is the layer name exactly as it appears in the Layers section in the configuration. -- `url`: This can be a relative path to a file under the Mission name or a full url path. The former is preferred is the file is large. -- `bands`: Allows you to specify how many bands to return data from. Default is 1. -- `sigfigs`: Sets the decimal precision. -- `unit`: A string that is appended to your returned value. e.g. " m" would be appended on a raw value ("41") and show "41 m". If it was "m", it would return "41m", without a space. diff --git a/documentation/pages/markdowns/Info.md b/documentation/pages/markdowns/Info.md deleted file mode 100644 index fbf2f2cc..00000000 --- a/documentation/pages/markdowns/Info.md +++ /dev/null @@ -1,15 +0,0 @@ -# Info - -Display the geojson properties field of a clicked point. Any clicked feature will open the Info tool and display the data in JSON formatting. Some layer 'kinds' disable opening the Info tool and displaying data automatically, like the "Waypoints" kind layer. - -To activate, left-click on the tool and then click on a feature in the Map view. The feature properties and geometry will be displayed on a panel on the left side of the web page. Left-clicking the Info icon will close the panel. - -### Example Tool Tab Variables - -```javascript -{ - "sortAlphabetically": true -} -``` - -_"sortAlphabetically"_: Whether to sort properties alphabetically or not. Defaults to true. diff --git a/documentation/pages/markdowns/Initial_Tab.md b/documentation/pages/markdowns/Initial_Tab.md deleted file mode 100644 index dbf6d987..00000000 --- a/documentation/pages/markdowns/Initial_Tab.md +++ /dev/null @@ -1,36 +0,0 @@ -# Initial Tab - -Values that describe the initial state of MMGIS on page load. - -#### Mission Name and Folder - -Renames the mission and it's mission folder. -_disabled_ - -#### Initial Site - -If an initial site code is specified, the regular initial view location and visible layers will be overridden by those of the site. The sites and site codes must be configured within the tools tab and the Sites Tool must be enable beforehand. - -#### Initial Latitude - -The starting latitude value in decimal degrees. - -#### Initial Longitude - -The starting longitude in decimal degrees. - -#### Initial Zoom - -The starting zoom in [zoom level](https://wiki.openstreetmap.org/wiki/Zoom_levels). - -#### Planet Radius Major - -Meters from the planet's center to it's equator - -#### Planet Radius Minor - -Meters from the planet's center to a pole - -#### Zoom Level of Map Scale - -An integer to be the default map zoom level. This is not the initial zoom but rather a preferred zoom level that functions will default to if they can't determine an ideal zoom themselves. Setting this value also adds a button above the scale bar to quickly zoom to it. diff --git a/documentation/pages/markdowns/Isochrone.md b/documentation/pages/markdowns/Isochrone.md deleted file mode 100644 index 35a5a188..00000000 --- a/documentation/pages/markdowns/Isochrone.md +++ /dev/null @@ -1,78 +0,0 @@ -# Isochrone - -The Isochrone tool shades regions of the map based on traverse time (or other "costs") from user-defined source points. Analysis is done by one of several selectable models and based on user-defined constraints. Hover over the generated shape to view the least-cost path to any given point from the start point. Users may view multiple isochrones simultaneously, and change the size, resolution, color ramp, color steps, and opacity of each one. - -## Tool Configuration - -### Example - -```javascript -{ - "data": { - "DEM": [ - { - "name": "Unique Name 1", - "tileurl": "Layers/Example/{z}/{x}/{y}.png", - "minZoom": 8, - "maxNativeZoom": 18, - "resolution": 256, - "interpolateSeams": true - }, - { "...": "..." } - ], - "slope": [ - { "...": "..." } - ], - "cost": [ - { "...": "..." } - ] - }, - "interpolateSeams": false, - "models": ["Traverse Time", "Isodistance", "..."] -} -``` - -_**data**_ - Each key in the "data" field should be the name of a type of data to be used in analysis. Examples of data types may include "DEM", "slope", "obstacle", "cost", or "shade". Values are an array of data source objects. - -Data source objects must include a unique _**name**_, a _**tileurl**_, _**minZoom**_ and _**maxNativeZoom**_, and a _**resolution**_ indicating a power of 2 tile size between 32 and 256. Sources may also include an optional _**interpolateSeams**_ property, indicating per-source whether to correct tile seams (see global `interpolateSeams` property, below). Tiles should be in the same format as a DEM tileset (see `/auxiliary/1bto4b`). Note that the tool has no means of verifying that the tileset it is pointed to contains the right kind of data, so configure carefully. - -Each model may require one or more of these data types to operate. Users will be prompted to select one of the configured sources for each of these data types. If no valid sources are configured for a data type a model needs, the tool will display an error message. - -_**interpolateSeams**_ - Because `1bto4b` generates tiles with matching edges, data loaded and passed to models may have "seams," or regularly-spaced pairs of identical rows and columns. Depending on the data type and model, these seams may or may not cause inaccurate results. The default behavior of the tool is therefore to attempt to correct these seams. Set this property to false to disable this behavior for all sources that do not explicitly set their own `interpolateSeams` property to `true`. - -_**models**_ - An optional list of models to make available. If not configured, a default list will be used. - -## Tool Use - -With the isochrone tool active, click on the map to generate an isochrone starting from the clicked point. This isochrone will update dynamically as its properties are changed. Hover over the isochrone to view least-cost paths and total accumulated costs at any shaded point. Note that while many isochrones may be visible at once, only one "focused" isochrone will render least-cost paths. An isochrone may be brought into "focus" by clicking its marker on the map, its name in the toolbar, or by modifying any of its properties. - -### General Properties -General display options available to all isochrones. - -_**Max Radius**_ - The radius of data to fetch around the start point. Note that, depending on the max cost setting, isochrones may run into this boundary. If the edge of the isochrone appears jagged, this property should be increased. - -_**Color**_ - Selects a color ramp for the isochrone. - -_**Opacity**_ - Changes the opacity of the isochrone. - -_**Steps**_ - Picks the number of color steps in the isochrone, to reveal contours inside the shape. Set to 0 for a continuous ramp. - -_**Model**_ - Selects which model to use to generate the isochrone. See `/src/essence/Tools/Isochrone/models` to create custom models. - -### Data Properties -Options related to how data is retrieved and displayed. - -_**Resolution**_ - Changes the resolution of the isochrone. This number represents the zoom level at which the resulting layer will be rendered. - -**Data Sources** - Options to set the source for every data set required by the selected model. If no valid source has been listed for one or more required data set, an error message will appear and the isochrone will not render. - -### Model properties -Options specific to the selected model. - -**Max Cost** - This section will always include a max cost option, in units relevant to the selected model. This represents the cost to reach the edges of the isochrone from the start point, and will thus determine the ultimate size of the shape. - -This section may have additional options specified by the selected model. - -## Technical - -The Isochrone tool runs a version of Dijkstra's algorithm on tiled data to generate results. In this implementation, every pixel is a vertex which is implicitly connected by an edge to 16 of its neighbors: its 8 immediate neighbors, plus neigbors that can be reached by the "knight's move" - i.e. the move a knight makes on a chessboard. Analysis is performed entirely in-browser in JavaScript. diff --git a/documentation/pages/markdowns/JavaScript_API.md b/documentation/pages/markdowns/JavaScript_API.md deleted file mode 100644 index 2001a08e..00000000 --- a/documentation/pages/markdowns/JavaScript_API.md +++ /dev/null @@ -1,557 +0,0 @@ -# JavaScript API - -The `src/essence/mmgisAPI/mmgisAPI.js` file exposes functions that can be called using the global `window.mmgisAPI` object. - -## Layer Control - -### clearVectorLayer(layerName) - -This function clears an existing vector layer with a specified name - -#### Function parameters - -- `layerName` - name of layer to clear - -The following is an example of how to call the `clearVectorLayer` function: - -```javascript -window.mmgisAPI.clearVectorLayer("Waypoints"); -``` - -### updateVectorLayer(layerName, inputData) - -This function updates an existing vector layer with a specified name and valid GeoJSON data - -#### Function parameters - -- `layerName` - name of layer to update -- `inputData` - valid GeoJSON data -- `keepN` - number of features to keep. A value less than or equal to 0 keeps all previous features - -The following is an example of how to call the `updateVectorLayer` function: - -```javascript -window.mmgisAPI.updateVectorLayer( - "Waypoints", - { - type: "Feature", - properties: { - sol: 690, - site: 39, - pos: 726, - SCLK_START: 458746227.91, - SCLK_END: 458748923.8, - }, - geometry: { - type: "Point", - coordinates: [137.38361, -4.658036, -4461.908691], - }, - }, - 5 -); -``` - -### trimVectorLayerKeepBeforeTime(layerName, keepBeforeTime, timePropPath) - -This function removes features on a specified layer after a specified time - -#### Function parameters - -- `layerName` - name of layer to update -- `keepBeforeTime` - absolute time in the format of YYYY-MM-DDThh:mm:ssZ; will keep all features before this time -- `timePropPath` - name of time property to compare with the time specified by keepAfterTime - -The following is an example of how to call the `trimVectorLayerKeepBeforeTime` function: - -```javascript -window.mmgisAPI.trimVectorLayerKeepBeforeTime( - "Waypoints", - "2021-12-01T15:10:00.000Z", - "time" -); -``` - -### trimVectorLayerKeepAfterTime(layerName, keepAfterTime, timePropPath) - -This function removes features on a specified layer before a specified time - -#### Function parameters - -- `layerName` - name of layer to update -- `keepAfterTime` - absolute time in the format of YYYY-MM-DDThh:mm:ssZ; will keep all features after this time -- `timePropPath` - name of time property to compare with the time specified by keepAfterTime - -The following is an example of how to call the `trimVectorLayerKeepAfterTime` function: - -```javascript -window.mmgisAPI.trimVectorLayerKeepAfterTime( - "Waypoints", - "2021-12-01T15:10:00.000Z", - "time" -); -``` - -### keepFirstN(layerName, keepLastN) - -This function removes features on a specified layer starting from the tail of of the features list to keep the specified number of existing features. This function is not aware of time and will only keep the previous N number of features based on the order the features were added to the layer. - -#### Function parameters - -- `layerName` - name of layer to update -- `keepFirstN` - number of features to keep from the beginning of the features list. A value less than or equal to 0 keeps all previous features - -The following is an example of how to call the `keepFirstN` function: - -```javascript -window.mmgisAPI.keepFirstN("Waypoints", 2); -``` - -### keepLastN(layerName, keepLastN) - -This function removes features on a specified layer starting from the beginning of the features list to keep the specified number of existing features. This function is not aware of time and will only keep the previous N number of features based on the order the features were added to the layer. - -#### Function parameters - -- `layerName` - name of layer to update -- `keepLastN` - number of features to keep from the tail end of the features list. A value less than or equal to 0 keeps all previous features - -The following is an example of how to call the `keepLastN` function: - -```javascript -window.mmgisAPI.keepLastN("Waypoints", 2); -``` - -### trimLineString(layerName, time, timeProp, trimN, startOrEnd) - -This function is used to trim a specified number of vertices on a specified layer containing GeoJson LineString features. This makes the following assumptions: - -- If trimming from the beginning of the layer, the time in the `time` parameter must be after the start time of the first feature in the layer -- If trimming from the end of the layer, the time in the `time` parameter must be before the end time of the last feature in the layer - -#### Function parameters - -- `layerName` - name of layer to update -- `time` - absolute time in the format of YYYY-MM-DDThh:mm:ssZ; represents start time if trimming from the beginning, otherwise represents the end time -- `timeProp` - key representing the time property to be updated in the layer -- `trimN` - number of vertices to trim -- `startOrEnd` - direction to trim from; value can only be one of the following options: start, end - -The following are examples of how to call the `trimLineString` function: - -```javascript -window.mmgisAPI.trimLineString( - "Traverse", - "2021-12-01T15:03:00.000Z", - "start_time", - 7, - "start" -); -``` - -```javascript -window.mmgisAPI.trimLineString( - "Traverse", - "2021-12-01T15:13:00.000Z", - "end_time", - 7, - "end" -); -``` - -### appendLineString(layerName, inputData, timeProp) - -This function appends input data with a GeoJson Feature that contains a LineString. The LineString vertices from the input data is appended as vertices to the last Feature in the layer. The input data should also contain a property with `timeProp` as the key, representing the new end time for the updated data. - -#### Function parameters - -- `layerName` - name of layer to update -- `inputData` - GeoJson data containing a single Feature containing a LineString -- `timeProp` - key representing the time property to be updated in the layer - -The following is an example of how to call the `appendLineString` function: - -```javascript -window.mmgisAPI.appendLineString( - "Traverse", - { - type: "Feature", - properties: { - name: 2, - Length_m: 0, - COLOR: 0, - route: 0, - start_time: "2021-12-01T15:10:00.000Z", - end_time: "2021-12-01T15:20:00.000Z", - }, - geometry: { - type: "LineString", - coordinates: [ - [145.862136, -73.208439], - [135.063782, -71.898251], - [130.828697, -75.540527], - [122.767247, -72.658683], - [120.133499, -75.018059], - ], - }, - }, - "end_time" -); -``` - -## reloadLayer(layer) - -This function will reload the given layer by re-fetching the data and re-drawing on the map. - -#### Function parameters - -- `layer` - The layer name string or a layer object - -The following is an example of how to call the `reloadLayer` function: - -```javascript -window.mmgisAPI.reloadLayer("Earthquakes"); -``` - -## Time Control - -## toggleTimeUI(visibility) - -This function toggles the visibility of ancillary Time Control User Interface. It is useful in situations where time functions are controlled by an external application. - -#### Function parameters - -- `visibility` - Time UI is visibile if true and hidden if false - -The following is an example of how to call the `toggleTimeUI` function: - -```javascript -window.mmgisAPI.toggleTimeUI(false); -``` - -## setTime(startTime, endTime, isRelative, timeOffset) - -This function sets the global time properties for all of MMGIS. All time enabled layers that are configured to use the `Global` time type will be updated by this function. - -Note that layers will not be refreshed on the map until `reloadTimeLayers()` (or `reloadLayer()` for individual layers) is called. - -#### Function parameters - -- `startTime` - Can be either `YYYY-MM-DDThh:mm:ssZ` if absolute, or `hh:mm:ss` or seconds if relative -- `endTime` - Can be either `YYYY-MM-DDThh:mm:ssZ` if absolute, or `hh:mm:ss` or seconds if relative -- `isRelative` - If true, startTime and endTime are relative to the current UTC time -- `timeOffset` - An offset to use for the current UTC time; can be either a string in `hh:mm:ss` format or an integer value in seconds - -The following are examples of how to call the `setTime` function: - -```javascript -window.mmgisAPI.setTime("2021-05-13T01:00:00Z", "2021-05-13T07:00:00Z", false); - -window.mmgisAPI.setTime("02:00:00", "00:00:00", true, "01:00:00"); - -window.mmgisAPI.setTime(7200, 0, true, 3600); -``` - -## setLayerTime(layer, startTime, endTime) - -This function sets the start and end time for a single layer. It can be used to override the global time for the layer. Note that `setTime` also updates the times for layers that use the `Global` time type. - -For layers that use a single time, `endTime` is used (i.e., `{time}=={endTime}`) - -Note that the layer will not be refreshed on the map until `reloadTimeLayers()` (or `reloadLayer()` for individual layers) is called. - -#### Function parameters - -- `layer` - The layer name string or a layer object -- `startTime` - The start time in `YYYY-MM-DDThh:mm:ssZ` format -- `endTime` - The end time in `YYYY-MM-DDThh:mm:ssZ` format - -The following is an example of how to call the `setLayerTime` function: - -```javascript -window.mmgisAPI.setLayerTime( - "Earthquakes", - "2021-05-01T00:00:00Z", - "2021-05-13T23:59:59Z" -); -``` - -## getTime() - -Returns the current time on the map with offset included in `YYYY-MM-DDThh:mm:ssZ` format. - -The following is an example of how to call the `getTime` function: - -```javascript -window.mmgisAPI.getTime(); - -("2021-05-14T02:06:29Z"); -``` - -## getStartTime() - -Returns the global start time on the map with offset included in `YYYY-MM-DDThh:mm:ssZ` format. - -The following is an example of how to call the `getStartTime` function: - -```javascript -window.mmgisAPI.getStartTime(); - -("2021-05-14T01:06:29Z"); -``` - -## getEndTime() - -Returns the global end time on the map with offset included in `YYYY-MM-DDThh:mm:ssZ` format. - -The following is an example of how to call the `getEndTime` function: - -```javascript -window.mmgisAPI.getEndTime(); - -("2021-05-14T03:06:29Z"); -``` - -## getLayerStartTime(layer) - -Returns the start time set for an individual in `YYYY-MM-DDThh:mm:ssZ` format. - -#### Function parameters - -- `layer` - The layer name string or a layer object - -The following is an example of how to call the `getLayerStartTime` function: - -```javascript -window.mmgisAPI.getStartTime("Earthquakes"); - -("2021-05-01T00:00:00Z"); -``` - -## getLayerEndTime(layer) - -Returns the end time set for an individual in `YYYY-MM-DDThh:mm:ssZ` format. - -#### Function parameters - -- `layer` - The layer name string or a layer object - -The following is an example of how to call the `getLayerEndTime` function: - -```javascript -window.mmgisAPI.getEndTime("Earthquakes"); - -("2021-05-13T23:59:59Z"); -``` - -## reloadTimeLayers() - -This function will reload every layer that is time-enabled by re-fetching the data and re-drawing on the map. It should be called after `setTime` or `setLayerTime`. It will return a list of layers that were reloaded. - -The following is an example of how to call the `reloadTimeLayers` function: - -```javascript -window.mmgisAPI.reloadTimeLayers()[("Lunaserv", "Earthquakes")]; -``` - -## setLayersTimeStatus(color) - -This function will set the status icon color (e.g. to indicate staleness) for all global time enabled layers. It returns a list of the layers that were updated. - -#### Function parameters - -- `color` - The name of a color of hex RGB value - -The following is an example of how to call the `reloadLayer` function: - -```javascript -window.mmgisAPI.setLayersTimeStatus("#ff0000")[("Lunaserv", "Earthquakes")]; - -window.mmgisAPI.setLayersTimeStatus("green")[("Lunaserv", "Earthquakes")]; -``` - -## setLayerTimeStatus(layer, color) - -This function will set the status icon color (e.g. to indicate staleness) for the specified time enabled layers. - -#### Function parameters - -- `layer` - The layer name string or a layer object -- `color` - The name of a color of hex RGB value - -The following is an example of how to call the `reloadLayer` function: - -```javascript -window.mmgisAPI.setLayerTimeStatus("Earthquakes", "#ff0000"); - -window.mmgisAPI.setLayerTimeStatus("Earthquakes", "green"); -``` - -## updateLayersTime() - -This function will synchronize every global time enabled layer with the current global times. Similar to `setTime` but used internally to update values when users change values on the Time UI. Unlikely to be needed elsewhere except for potential edge cases where re-synchronization may be necessary. - -The following is an example of how to call the `updateLayersTime` function: - -```javascript -window.mmgisAPI.updateLayersTime(); -``` - -## Event Listeners - -### addEventListener(eventName, functionReference) - -This function adds a map event or MMGIS action listener added using the MMGIS API. This function takes in one of the following events: `onPan`, `onZoom`, `onClick`, `toolChange`, `layerVisibilityChange`. The MMGIS action listener (`toolChange`, `layerVisibilityChange`, `websocketChange`) functions are called with an `event` parameter. - -#### Function parameters - -- `eventName` - name of event to add listener to. Available events: `onPan`, `onZoom`, `onClick` -- `functionReference` - function reference to listener event callback function. `null` value removes all functions for a given `eventName` - -The following is an example of how to call the `addEventListener` function: - -```javascript -function listener() { - const featuresContained = window.mmgisAPI.featuresContained(); - console.log("featuresContained", featuresContained); - - const activeFeature = window.mmgisAPI.getActiveFeature(); - console.log("activeFeature", activeFeature); -} - -window.mmgisAPI.addEventListener("onPan", listener); - -function mmgisListener(event) { - console.log("event", event); -} - -window.mmgisAPI.addEventListener("toolChange", mmgisListener); -``` - -### removeEventListener(eventName, functionReference) - -This function removes a map event or MMGIS action listener added using the MMGIS API. - -#### Function parameters - -- `eventName` - name of event to remove listener from. Available events: `onPan`, `onZoom`, `onClick`, `toolChange`, `layerVisibilityChange` -- `functionReference` - function reference to listener event callback function. `null` value removes all functions for a given `eventName` - -The following is an example of how to call the `removeEventListener` function: - -```javascript -function listener() { - const featuresContained = window.mmgisAPI.featuresContained(); - console.log("featuresContained", featuresContained); - - const activeFeature = window.mmgisAPI.getActiveFeature(); - console.log("activeFeature", activeFeature); -} - -window.mmgisAPI.removeEventListener("onPan", listener); -``` - -## Map Feature Information - -### map - -This is an object which exposes the Leaflet map object. - -The following is an example of how to call the `map` object: - -```javascript -window.mmgisAPI.map; -``` - -### featuresContained - -This function returns an array of all features in the current map view. The return value is an object containing layer names as keys and values as arrays with all features (as GeoJson Feature objects) contained in the current map view - -The following is an example of how to call the `featuresContained` function: - -```javascript -window.mmgisAPI.featuresContained(); -``` - -### getActiveFeature - -This function returns the currently active feature (i.e. feature thats clicked and displayed in the InfoTool). The return value is the currently selected active feature as an object with the layer name as key and value as an array containing the GeoJson Feature object (MMGIS only allows the section of a single feature). - -The following is an example of how to call the `getActiveFeature` function: - -```javascript -window.mmgisAPI.getActiveFeature(); -``` - -### getVisibleLayers - -This function returns an object with the visiblity state of all layers - -The following is an example of how to call the `getVisibleLayers` function: - -```javascript -window.mmgisAPI.getVisibleLayers(); -``` - -### toggleLayer - -This function sets the visibility state for a named layer - -#### Function parameters - -- `layerName` - name of layer to toggle visiblity -- `on` - (optional) Set `true` if the visibility should be on or `false` if visibility should be off. If not set, the current visiblity state will switch to the opposite state. - -The following is an example of how to call the `toggleLayer` function: - -```javascript -# Set 'Layer 1' to be visible -window.mmgisAPI.toggleLayer('Layer 1', true) - -# Toggle the visibility state of 'Layer 1' -window.mmgisAPI.toggleLayer('Layer 1') -``` - -## Miscellaneous Features - -### writeCoordinateURL - -This function writes out the current view as a URL. This programmatically returns the long form of the 'Copy Link' feature and does not save a short URL to the database. - -The following is an example of how to call the `writeCoordinateURL` function: - -```javascript -window.mmgisAPI.writeCoordinateURL(); -``` - -### onLoaded - -This function calls the callback function once MMGIS has finished loading. - -- `onLoadCallback` - callback function that is called when MMGIS has finished loading - -The following is an example of how to call the `onLoaded` function: - -```javascript -window.mmgisAPI.onLoaded(() => { - // Add listener with MMGIS API now that MMGIS has finished loading - function listener() { - const featuresContained = window.mmgisAPI.featuresContained(); - console.log("featuresContained", featuresContained); - - const activeFeature = window.mmgisAPI.getActiveFeature(); - console.log("activeFeature", activeFeature); - } - - window.mmgisAPI.addEventListener("onPan", listener); -}); -``` - -### getActiveTool - -This function returns an object with the currently active tool and the name of the active tool. - -The following is an example of how to call the `getActiveTool` function: - -```javascript -window.mmgisAPI.getActiveTool(); -``` diff --git a/documentation/pages/markdowns/Keys.md b/documentation/pages/markdowns/Keys.md deleted file mode 100644 index aaedd31d..00000000 --- a/documentation/pages/markdowns/Keys.md +++ /dev/null @@ -1,11 +0,0 @@ -# Keys - -### General Usage - -Make any (currently limited to only those listed below) configuration API call with the header "Authorization:Bearer <token>" included. - -### Uploading CSVs - -``` -curl -i -X POST -H "Authorization:Bearer <token>" -F "name={dataset_name}" -F "upsert=true" -F "header=["File","Target","ShotNumber","Distance(m)","LaserPower","SpectrumTotal","SiO2","TiO2","Al2O3","FeOT","MgO","CaO","Na2O","K2O","Total","SiO2_RMSEP","TiO2_RMSEP","Al2O3_RMSEP","FeOT_RMSEP","MgO_RMSEP","CaO_RMSEP","Na2O_RMSEP","K2O_RMSEP"]" -F "data=@{path/to.csv};type=text/csv" http://localhost:8888/api/datasets/upload -``` diff --git a/documentation/pages/markdowns/Kinds.md b/documentation/pages/markdowns/Kinds.md deleted file mode 100644 index 48f73254..00000000 --- a/documentation/pages/markdowns/Kinds.md +++ /dev/null @@ -1,59 +0,0 @@ -# Kinds - -- The Kind of layer a layer is describes what happens when a feature of that layer is clicked on. -- Internally, Kinds are treated as quasi-tools. Instead of adding a Tool to a mission, you add a Kind to a layer. - -### None - -By default and if available, the clicked feature highlights, sends its metadata to the Info Tool and gets briefly described in the top bar. All Kinds have this behavior by default as well. - -### Info - -Works just like the None Kind but automatically opens the Info Tool too (if it's on and included). - -### Waypoint - -This Kind is very specific to the Curiosity Rover and only works on point features. It takes hardcoded rover dimensions, `public/images/rovers/CuriosityTopDownOrthoSmall.png` and the geojson feature property `yaw_rad` to orient a to scale Curiosity Rover image under the clicked point. - -The Waypoint Kind only applies to point features and uses the `markerAttachments.image` and `markerAttachments.model` layer raw variables. When `show` is set to "click" (or undefined), clicking on a point will draw an image in the Map and a model in the Globe. Both image and model can be set, scaled and rotated dynamically. The Waypoint Kind is specifically useful for rover images and models. See [Vector Layer Raw Variables](Layers_Tab#raw-variables-2) for more information about the image and model marker attachments. - -```javascript -markerAttachments: { - image: { - initialVisibility: true, - path: "url to top-down ortho image. ex. public/images/rovers/PerseveranceTopDown.png", - pathProp: "path to image. take priority over path", - widthMeters: 2.6924, - widthPixels: 420, - heightPixels: 600, - angleProp: "path.to.angle.prop", - angleUnit: "deg || rad", - show: "click || always", - }, - model: { - path: "path to mode (.dae, .glb, .gltf, .obj)", - pathProp: "path to model. take priority over path", - mtlPath: "if .obj, path to material file (.mtl)", - yawProp: "path.to.yaw.prop", - yawUnit: "deg || rad", - invertYaw: false, - pitchProp: "path.to.pitch.prop", - pitchUnit: "deg || rad", - invertPitch: true, - rollProp: "path.to.roll.prop", - rollUnit: "deg || rad", - invertRoll: false, - elevationProp: "path.to.elev.prop", - scaleProp: "path.to.scale.prop", - show: "click || always", - } -} -``` - -### Chemistry Tool - -This Kind is used for the Chemistry Tool. Because chemistry data can be big and it's advise to link to it via a dataset, this Kind waits - -### Draw Tool - -Uses a read only version of the Draw Tool's edit panel and forces the Info Tool open. The main use case for this is to be used with the published Draw Tool layer (setting the vector layer's URL to `api:publishedall`). diff --git a/documentation/pages/markdowns/Layer_URLs.md b/documentation/pages/markdowns/Layer_URLs.md deleted file mode 100644 index cf3fdc5e..00000000 --- a/documentation/pages/markdowns/Layer_URLs.md +++ /dev/null @@ -1,28 +0,0 @@ -# Layer URLs - -Layers in the Configure CMS can take in a variety of URLs aside from standard absolute and relative ones. Visit the Layers Tab page for more information about constructing standard URLs. - -## API - -### `api:publishedall` - -_For a vector layer._ -Grabs all features published via the DrawTool - -### `api:published:<file_intent>` - -_For a vector layer._ -Grabs all features published via the DrawTool of a certain intent. -Possible values are: `roi, campaign, campsite, signpost, trail, all` - -### `api:tacticaltargets` - -_For a vector layer._ -If applicable, grabs all ingested tactical targets. - -## GeoDatasets - -### `geodatasets:<geodataset_name>` - -_For a vector or vectortile layer._ -Grab features uploaded to the CMS as a geodataset (a geojson dataset). _Case Sensitive_ diff --git a/documentation/pages/markdowns/Layers.md b/documentation/pages/markdowns/Layers.md deleted file mode 100644 index ba9e6a0e..00000000 --- a/documentation/pages/markdowns/Layers.md +++ /dev/null @@ -1,3 +0,0 @@ -# Layers - -Allows users to toggle on and off layers, download them and change some parameters such as opacity. diff --git a/documentation/pages/markdowns/Layers_Tab.md b/documentation/pages/markdowns/Layers_Tab.md deleted file mode 100644 index 064ce908..00000000 --- a/documentation/pages/markdowns/Layers_Tab.md +++ /dev/null @@ -1,50 +0,0 @@ -# Layers Tab - -Add, alter and remove Layers: - -"Saving Changes" will catch most structural mistakes made here and will inform you of what's wrong. It will not verify anything further such as whether a layer's data exists or whether the raw variables entered are valid. - -##### Contents - -- [Adding Layers](#adding-layers) -- [Cloning Layers](#cloning-layers) -- [Removing Layers](#removing-layers) -- [Layer Structure](#layer-structure) -- [Configuring Individual Layers](#configuring-individual-layers) -- [Layer Types](#layer-types) - -## Adding Layers - -- Scroll to the bottom of the page and click "Add Layer +" - - This will add a blank `header` layer named "Name Layer" to the bottom of the layers list. - -## Cloning Layers - -- Clicking a layer brings up its form. At the top right of this form there is a button to clone the layer. Clicking it clones the layer and adds it to the bottom of the layers list. Because layer names must be unique, the layer name of the newly cloned layer must be changed before saving changes can be successful. - -## Removing Layers - -- Clicking a layer brings up its form. A the bottom left of this form there is a button to delete the layer. There is no additional warning prompt. - -## Layer Structure - -- The layer at the top of the layers list renders on top of all other layers. The layer second from the top of the list of layers renders on top of all other layers except the first one. And so on. -- Layers can be reordered by clicking and dragging them vertically to a new position. If you're dealing with a long list of layers, use the mouse-wheel while holding a layer to move it more quickly. -- Layers can also be clicked and dragged horizontally. If a layer is indented, it will be grouped under the header above it. Headers can be indented/nested within other headers too. - -## Configuring Individual Layers - -- Clicking a layer brings of a form to change its parameters. -- Layers can be broken up by 6 types and can be set with the "Layer Type" field. - ---- - -## Layer Types - -- [Header](?page=Header) -- [Tile](?page=Tile) -- [Vector Tile](?page=Vector_Tile) -- [Data](?page=Data) -- [Query](?page=Query) -- [Vector](?page=Vector) -- [Model](?page=Model) diff --git a/documentation/pages/markdowns/Legend.md b/documentation/pages/markdowns/Legend.md deleted file mode 100644 index d51c619b..00000000 --- a/documentation/pages/markdowns/Legend.md +++ /dev/null @@ -1,44 +0,0 @@ -# Legend - -A layer can be configured with a legend by pointing its Legend field to a .csv file. The Legend Tool renders symbologies and gradient scales for any properly configured on layer. - -The Legend Tool takes no raw variable configurations in the Tools Tab. - -### legend.csv example: - - color,strokecolor,shape,value - purple,#000,discreet,This - cyan,#000,discreet,is - lime,#000,discreet,a - yellow,#000,discreet,sentential - orange,#000,discreet,example - red,#000,discreet,of - purple,#000,continuous,what - red,#000,continuous,values - white,#000,continuous,the - blue,#000,continuous,legend - pink,#000,circle,csv - green,#000,discreet,files - orange,#000,discreet,could - crimson,cyan,square,possibly - indigo,#FFF,rect,contain - -#### header - -THe header must be `color,strokecolor,shape,value`. - -#### color - -Any [CSS color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) to use as the main fill color. - -#### strokecolor - -Any [CSS color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) to use as the stroke/border color. _Note: discreet and continuous shapes have no borders._ - -#### shape - -Can be either `circle`, `square`, `rect`, `discreet` and `continuous`. Discreet and continuous describe scales. These scales are broken into groups by a change in shape value. For instance, "discreet, discreet, discreet, circle, discreet, discreet" represents a discreet scales of three colors, a circle and then a discreet scale of two colors. - -### value - -A string value for the legend entry. diff --git a/documentation/pages/markdowns/Look_Tab.md b/documentation/pages/markdowns/Look_Tab.md deleted file mode 100644 index cc810774..00000000 --- a/documentation/pages/markdowns/Look_Tab.md +++ /dev/null @@ -1,67 +0,0 @@ -# Look Tab - -Configure the look of MMGIS's UI for the mission - -#### Page Name - -Sets the browser tab title and, if the UI is not minimalist, sets the title in the top bar. Defaults to `MMGIS` - -#### Minimalist UI - -If checked, hides the top bar. The top bar contains descriptive elements and interactions as well as a search bar. Checking this may cause other setups to be irrelevant. - -#### Zoom Control - -If checked, adds `+` and `-` zoom buttons to the top right of the Map. - -#### Graticule - -_Deprecated. Library license was not permissive._ - -#### Body Color - -Sets the background color of MMGIS to a [CSS color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value). Might have little impact. - -#### TopBar Color - -Sets the color of the top bar to a [CSS color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value). Minimalist UI needs to be unchecked to see impact. - -#### ToolBar Color - -Sets the color of vertical tool bar to a [CSS color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value). - -#### Map Color - -Sets the background of the Map to a [CSS color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value). The color is seen in regions of the 2D map where there is no data. - -#### Highlight Color - -Sets the highlight of active vector features to a [CSS color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value). - -#### Swap - -If checked, adds a button in the tool bar that enables users to switch seamlessly between missions. This functionality may be buggy and break things depending on the missions switched to and from. It's recommended to return to the landing page to switch between missions or to extensively test swapping between your missions before enabling Swap. - -#### Copy Link - -If checked, adds a button in the tool bar that enables users to create a shortened deep link of their current view in MMGIS. The link is automatically copied to their clipboard for easy sharing. - -#### Screenshot - -If checked, adds a button in the tool bar that enables users to screenshot the current view of the 2D Map. Because this works by rerendering all of HTML and CSS into an image, there may be missing or misplaced elements in the image. - -#### Fullscreen - -If checked, adds a button in the tool bar that enables users to quickly enter and exit fullscreen mode. - -#### Help - -If checked, adds a button in the tool bar that links to help documentation. That link can be specified below in Help URL. - -#### Square Logo Image URL - -A URL to a new logo if the default MMGIS is unwanted. The logo should be reasonably sized, square and centered. - -#### Help URL - -The URL to take users to in they click the help icon in the bottom left. Help above should be checked on. diff --git a/documentation/pages/markdowns/Manage_Datasets.md b/documentation/pages/markdowns/Manage_Datasets.md deleted file mode 100644 index b265ffe8..00000000 --- a/documentation/pages/markdowns/Manage_Datasets.md +++ /dev/null @@ -1,11 +0,0 @@ -# Manage Datasets - -Instead of attaching massive amounts of data as geojson properties, you can use datasets to fetch the necessary data on feature click. - -Upload a CSV and then link to them within a layer's variables with: - -``` -"datasetLinks": [{"prop": "{geojson_property_to_match}","dataset": "{dataset_name}","column": "{dataset_column_name}"}] -``` - -_Note:_ All matching rows will be returned — not just the first. diff --git a/documentation/pages/markdowns/Manage_Geodatasets.md b/documentation/pages/markdowns/Manage_Geodatasets.md deleted file mode 100644 index 20acdb6e..00000000 --- a/documentation/pages/markdowns/Manage_Geodatasets.md +++ /dev/null @@ -1,7 +0,0 @@ -# Manage GeoDatasets - -Instead of using flat geojson files to serve data, you can upload them into your database from here. - -Link to them with `geodatasets:{name}` as the layer URL. - -You can freely switch to the "Vector Tile" Layer Type too. diff --git a/documentation/pages/markdowns/Measure.md b/documentation/pages/markdowns/Measure.md deleted file mode 100644 index 3693ce34..00000000 --- a/documentation/pages/markdowns/Measure.md +++ /dev/null @@ -1,23 +0,0 @@ -# Measure - -Measure distances, angles, and generates elevation profiles. - - - -On the Configure page, under Tools, you can specify which digital elevation model (DEM) will be used to create profiles from: - -```javascript -{ - "dem": "Layers/ConamaraChaos_DEM_simpcyl_meters.tif" -} -``` - -At this time, only one DEM can be specified. This DEM should be georeferenced (i.e. have a projection defined). - -A remote DEM may be specified using a GDAL XML description file. See [Remote Virtual Layer](?page=Remote_Virtual_Layer) for more information. - -## Tool Use - -- To make a measurement, left-click on the Measure Tool (graph icon), then left-click on the Map to create an anchor point for the measurement. As you move the mouse, the distance and angle (positive clockwise angle from north (i.e. top of map)) will read out and the distance will "rubber band" as you move. If you left-click again, the tool will display an elevation cross-section/profile. Mousing over the profile will show the raw elevation value at the samples points as well as a small yellow ball displayed between the two points on the map that correspond to where you are on the profile. If you left-click on the map at a new location, a new profile will be created between that point and the previous one. The total distance and section distance will be shown. -- The tool default to 100 samples evenly spaced between between the two points You can increase/decrease that sampling amount within the tool. -- Click the 'Download' test in the Measure Tool to download the raw values used in the profile as a comma-separated-value (CSV) file. It will include the easting, northing, and elevation values pulled from the DEM. diff --git a/documentation/pages/markdowns/Model.md b/documentation/pages/markdowns/Model.md deleted file mode 100644 index 918f42b5..00000000 --- a/documentation/pages/markdowns/Model.md +++ /dev/null @@ -1,77 +0,0 @@ -# Model Layer - -A 3D Model for the Globe - -#### Layer Name - -_type:_ string -The unique display name and identifier of the layer. It must be unique and contain no special characters. - -#### URL - -_type:_ string -A file path that points to a .dae or .obj. If the path is relative, it will be relative to the mission's directory. - -#### Longitude - -_type:_ float -The longitude in decimal degrees at which to place the model. - -#### Latitude - -_type:_ float -The latitude in decimal degrees at which to place the model. - -#### Elevation - -_type:_ float -The elevation in meters at which to place the model. - -#### Rotation X - -_type:_ float _optional_ -An x-axis rotation in radians to orient the model. - -#### Rotation Y - -_type:_ float _optional_ -A y-axis rotation in radians to orient the model. - -#### Rotation Z - -_type:_ float _optional_ -A z-axis rotation in radians to orient the model. - -#### Scale - -_type:_ float _optional_ -A scaling factor to resize the model. - -#### Initial Visibility - -_type:_ bool -Whether the layer is on initially. - -#### Initial Opacity - -_type:_ float -A value from 0 to 1 of the layer's initial opacity. 1 is fully opaque. - -#### Time Enabled - -_type:_ bool -True if the layer is time enabled. URLs that contain `{starttime}` or `{endtime}` will be dynamically replaced by their set values when the layer is fetched. - -#### Time Type - -_type:_ enum [Global, Individual] -Whether the layer should use global time values or function independently with its own time values. - -#### Time Format - -_type:_ string _optional_ -The string format to be used in the URL for `{starttime}` and `{endtime}`. Defaults to `YYYY-MM-DDTHH:mm:ssZ`. - ---- - -_Note:_ Additional vector layer stylings can be found on the [Vector Styling](Vector_Styling) page. diff --git a/documentation/pages/markdowns/Overall_Tab.md b/documentation/pages/markdowns/Overall_Tab.md deleted file mode 100644 index 8c36213a..00000000 --- a/documentation/pages/markdowns/Overall_Tab.md +++ /dev/null @@ -1,9 +0,0 @@ -# Overall Tab - -This tab shows a history of the mission's configuration. From here you can: - -- SET a previous configuration to be the current configuration -- Download a configuration as a .json -- Clone the mission to duplicate it -- Upload a custom config.json -- Delete the mission (which will not delete its missions folder data) diff --git a/documentation/pages/markdowns/Panels_Tab.md b/documentation/pages/markdowns/Panels_Tab.md deleted file mode 100644 index 41d86ecf..00000000 --- a/documentation/pages/markdowns/Panels_Tab.md +++ /dev/null @@ -1,91 +0,0 @@ -# Panels Tab - -## Viewer - -The Viewer sits to the left of the main Map. It can be expanded by clicking the double arrow in the middle left of the page. The Viewer can render images, DZIs, mosaics and models attached to layer features. A feature is configured to use the Viewer on click through an array under `properties` called `images`. Other tools may use the Viewer in their own way. - -```javascript -"properties": { - "name": "Example", - "description": "An example showcases the images array.", - "images": [ - { - "name": "Regular Image Example", - "url": "http://www.jpl.nasa.gov/assets/images/logo_nasa_trio_black@2x.png", - "type": "image" - }, - { - "url": "http://mars.jpl.nasa.gov/msl-raw-images/msss/00582/mrdi/0582MD0002120000101703E01_DXXX.jpg", - "type": "image" - }, - { - "url": "Layers/GPR/Data/GPR_radargram.jpg", - "type": "radargram" - }, - { - "name": "Model Example", - "url": "Data/models/example_model.obj", - "texture": "Data/models/example_texture.jpg", - "type": "image", - "isModel": true - }, - { - "name": "DZI Example", - "url": "Data/dzc_output.xml", - "isDZI": true - }, - { - "name": "Panorama Example", - "url": "Data/Mosaics/N_L000_1384_ILT055CYL_S_0940_UNCORM1.jpg", - "isPanoramic": true, - "rows": 1753, - "columns": 6666, - "azmin": 96.7294, - "azmax": 48.5537, - "elmin": -75.0502, - "elmax": 6.95029, - "elzero": 149.584 - } - ] -} -``` - -_Note: The first image in the images array is loaded on feature click._ - -### Regular Image - -A standard image. Simply provide a url. If a name is not set, the file name is used instead. - -### Radargram - -Renders as a standard image. The Curtain Tool will find this type and use it. - -### Model - -A 3D model viewer. Supports .obj and .dae. - -### DZI - -A Deep Zoom Image is a format of tiled imagery used to render massive images. Point the url to the .xml within the DZI's directory. Ways to create DZIs can be found [here](https://openseadragon.github.io/examples/creating-zooming-images/). - -### Panoramic - -This deprojects a cylindrical mosaic by wrapping it to a 3D sphere (think Google StreetView). To do this, additional parameters are needed. - -- rows: Y-axis pixel dimension. -- columns: X-axis pixel dimension. -- azmin: The azimuth in degrees of the left side of the image. Values are between 0 and 360 with 0 being north and 90 being east. -- azmax: The azimuth in degrees of the right side of the image. Values are between 0 and 360 with 0 being north and 90 being east. -- elmin: The elevation in degrees of the bottom of the image. Values are between -90 and 90 with -90 being straight down and 90 being straight up. -- elmax: The elevation in degrees of the top of the image. Values are between -90 and 90 with -90 being straight down and 90 being straight up. -- elzero: The number of pixels from the top of the image where the elevation is zero. - -_Note: Extremely large mosaics may need to be scaled down ahead of time._ - -## Map - -The main 2D Map. It cannot be disabled. - -## Globe - -The Globe sits to the right of the main Map. It can be expanded by clicking the double arrow in the middle right of the page. It renders a 3D view of the Map. Elevation data is brought into it by generating DEM tiles and setting the DEM URL in the layers' configurations. Digital Elevation Map tilesets can be generated with `auxillary/1bto4b/rasterstotiles1bto4b.py` diff --git a/documentation/pages/markdowns/Projection_Tab.md b/documentation/pages/markdowns/Projection_Tab.md deleted file mode 100644 index b377760e..00000000 --- a/documentation/pages/markdowns/Projection_Tab.md +++ /dev/null @@ -1,19 +0,0 @@ -# Projection Tab - -MMGIS supports tilesets in non-Web Mercator projections. The Projections Tab enables the configuration of a new projection for the given mission. All tilesets should be in agreement with the projection. Small issues with the settings here can have huge impacts on how the tilesets are rendered in MMGIS. - -#### EPSG - -A code representing a spatial reference system. [EPSGs](https://www.spatialreference.org/ref/epsg/) - -#### Proj4 String - -Please see [PROJ projections](https://proj.org/operations/projections/index.html). - -#### Globe Projections - -_Deprecated. Globe uses Proj4 String now._ - -#### Path to tilemapresource.xml - -Set the path to the tilemapresource.xml that was created with the tileset and click "Populate from XML". diff --git a/documentation/pages/markdowns/Query.md b/documentation/pages/markdowns/Query.md deleted file mode 100644 index 7f982b1e..00000000 --- a/documentation/pages/markdowns/Query.md +++ /dev/null @@ -1,122 +0,0 @@ -# Query Layer - -A user queryable layer whose data comes from an external search endpoint. Currently only supports ElasticSearch. - -#### Layer Name - -_type:_ string -The unique display name and identifier of the layer. It must be unique and contain no special characters. - -#### Endpoint - -_type:_ string -A file path that points to a search endpoint. Currently only supports ElasticSearch. - -#### Type - -_type:_ enum -Endpoint type. - -#### Stroke Color - -_type:_ CSS color string or a prop _optional_ -The border color of each feature. If the feature is a line, this field is the color of the line. See the Vector Styling page for more. Colors can be as follows: - -- A named color - - crimson, blue, rebeccapurple -- A hex color - - #FFF - - #A58101 -- An rgb color - - rgb(255,89,45) -- An hsl color - - hsl(130, 26%, 34%) -- Based on a feature's color property - - `prop:geojson_property_key` will set the feature's color to the values of `features[i].properties.geojson_property_key` - - If that property is not a valid CSS color and is a string, it will use a random and consistent color based on its hash. - -#### Fill Color - -_type:_ CSS color string or a prop _optional_ -The fill color of each feature. See Stroke Color for color options. See the Vector Styling page for more. - -#### Stroke Weight - -_type:_ positive integer _optional_ -The thickness of the stroke/border in pixels. See the Vector Styling page for more. - -#### Fill Opacity - -_type:_ float _optional_ -A value from 0 to 1 of Fill Color's opacity. 1 is fully opaque. See the Vector Styling page for more. -_Note: It's also possible to set the opacities of colors directly with #CCDDEEFF, rgba() and hsla()._ - -#### Radius - -_type:_ positive integer _optional_ -When a point feature is encountered, this value will be it's radius in pixels. - -#### Raw Variables - -Clicking "Set Default Variables" will add a template of all possible raw variables (without overwriting ones that are already set). All raw variables are optional. - -Example: - -```javascript -{ - "useKeyAsName": "name", - "datasetLinks": [ - { - "prop": "{prop}", - "dataset": "{dataset}", - "column": "{column}", - "type": "{none || images}" - } - ], - "links": [ - { - "name": "example", - "link": "url/?param={prop}" - } - ], - "query": { - "bodyWrapper": "before{BODY}after`, - "stringifyBody": "boolean - should the body be stringified", - "withCredentials": "boolean - send cookie credentials with the request", - "esResponses": - "boolean - is the es responses nested in a responses object", - "headers": { - "Content-Type": "application/x-ndjson", - }, - "fields": { "field1": "max_agg_size_number(0 for no agging)", "field2": 0 }, - "geoshapeProp": "propName of es geoshape field for spatial searches", - "must": [ - { - "match": { - "fieldName": "fieldValue", - }, - }, - ], - "size": 1000, - }; -} -``` - -- `useNameAsKey`: The property key whose value should be the hover text of each feature. If left unset, the hover key and value will be the first one listed in the feature's properties. -- `links`: Configure deep links to other sites based on the properties on a selected feature. This requires the "Minimalist" option in the Look Tab to be unchecked. Upon clicking a feature, a list of deep links are put into the top bar and can be clicked on to navigate to any other page. - - `name`: The name of the deep link. It should be unique. - - `link`: A url template. Curly brackets are included. On feature click, all `{prop}` are replaced with the corresponding `features[i].properties.prop` value. Multiple `{prop}` are supported as are access to nested props using dot notation `{stores.food.candy}`. - - `which`: This only supports the value `last` at this point. - - `icon`: Any [Material Design Icon](http://materialdesignicons.com/) name - - `value`: A name to display. All `{prop}`s will be replaced by their corresponding `features[which].properties[prop]` value. -- `query`: An object detailing how a query should be formed. - - `bodyWrapper`: An optional string to wrapper the request body in. The body replaces `{BODY}` in the string. Use `stringifyBody` if you use `bodyWrapper`. - - `stringifyBody`: Sends the request body as a string. - - `withCredentials`: Sends cookie credentials along with the request. - - `esResponses`: If true, data would be looked for in 'responses.0.data.hits.hits' instead of 'data.hits.hits' - - `headers`: Header object for the requests. - - `fields`: Property fields that we want the user to be able to search upon. - - `geoshapeProp`: The property field of the search result's geoshape feature. - - `must`: A 'must' stanza to always concatenate with the user's own filtered must. - - `size`: Max number of results to show. ES has a default hard limit of 10k. -- _Other high level raw variable fields might still be applicable here but are untested._ diff --git a/documentation/pages/markdowns/Remote_Virtual_Layer.md b/documentation/pages/markdowns/Remote_Virtual_Layer.md deleted file mode 100644 index 2c103855..00000000 --- a/documentation/pages/markdowns/Remote_Virtual_Layer.md +++ /dev/null @@ -1,79 +0,0 @@ -# Remote Virtual Layers - -A remote virtual layer can be supported via various GDAL drivers. The most common is the [GDAL WMS Driver](https://gdal.org/drivers/raster/wms.html). This allows MMGIS to treat remote datasets as if they were local. - -## GDAL XML Desciption File Template - -Here is a template of a GDAL XML Description file that may be used to access a remote DEM for the [Measure Tool](?page=Measure). - -```xml -<GDAL_WMS> - <Service name="WMS"> - <!-- recommend Version 1.1.1; Version 1.3 uses different bounding box definition --> - <Version>1.1.1</Version> - <!-- root URL of WMS service --> - <ServerUrl>http://localhost/map/?</ServerUrl> - <!-- projection of the source dataset --> - <SRS>IAU2000%3A30166%2C31.1492746341015%2C-85.391176037601</SRS> - <ImageFormat>image/tiff</ImageFormat> - <!-- name of one or more WMS layers--> - <Layers>some_dem_layer</Layers> - </Service> - <DataWindow> - <!-- the values below should match the full bounds of the dataset --> - <UpperLeftX>-2091.701</UpperLeftX> - <UpperLeftY>3505.141</UpperLeftY> - <LowerRightX>6119.299</LowerRightX> - <LowerRightY>-3638.859</LowerRightY> - <!-- recommend native sizes of the dataset, but may be reduced if full resolution is not needed (results in faster queries, but lower data precision) --> - <SizeX>8211</SizeX> - <SizeY>7144</SizeY> - </DataWindow> - <!-- the desired output project, which should match the MMGIS map --> - <Projection>+proj=stere +lat_0=-85.391176037601 +lon_0=31.1492746341015 +k=1 +x_0=0 +y_0=0 +a=1737400 +b=1737400 +units=m +no_defs</Projection> - <BandsCount>1</BandsCount> - <!-- *Important* to ensure that DataType matches the source data --> - <DataType>Float32</DataType> - <!-- GDAL creates a local cache for faster access; highly recommend to include --> - <Cache> - <!-- set an expiration value to prevent the cached data from filling up local storage --> - <Expires>604800</Expires> - <!-- a directory with write permissions to store cached data; defaults to ./gdalwmscache if not provided --> - <Path>./gdalwmscache</Path> - </Cache> -</GDAL_WMS> -``` - -## GDAL Local Caching - -If the `<Cache>` tag is included in the XML description file, GDAL will by default create a directory named `gdalwmscache` at the root location of MMGIS (directory must have write permissions for this to work). It is highly recommended to include this capability to significantly improve performance. Initial queries to a remote dataset may take several seconds, but subsequent queries that hit the cache are just as fast as accessing a local file. - -## Remote XML Description File - -Typically, an XML description file is generated locally for any dataset that is to be accessed remotely. This file can be place in the mission's Data/ directly for easy access by MMGIS. - -However, it is also possible to access a remote XML description file on another server. This can enable more control for dynamic access. This is accomplished via GDAL's `/vsicurl/` prefix to access network locations. For example, instead of specifying a local XML description file for a DEM like so: - -```javascript -{ - "dem": "data/description.xml" -} -``` - -A remote XML description file can be specified like this: - -```javascript -{ - "dem": "/vsicurl/http://localhost/description.xml" -} -``` - -Other `vsi*` options exist for commercial cloud storage such as S3: `/vsis3/` - -Note: for directly accessing cloud-optimized GeoTIFFs, the XML description file is unnecessary and can be bypassed altogether by using the `/vsis3/` prefix and referencing the remote file path. - -See GDAL documentation for more information about virtual file systems: https://gdal.org/user/virtual_file_systems.html#network-based-file-systems - -## More Information - -For more details about the XML description file, see the official GDAL documentation here: https://gdal.org/drivers/raster/wms.html#xml-description-file diff --git a/documentation/pages/markdowns/Sites.md b/documentation/pages/markdowns/Sites.md deleted file mode 100644 index 42b08669..00000000 --- a/documentation/pages/markdowns/Sites.md +++ /dev/null @@ -1,37 +0,0 @@ -# Sites - -Provides a way to navigate to specified latitude, longitude, zoom locations on the map. - -### Raw Variables - -The following is an example of the Sites Tool's Tool Tab configuration: - -```javascript -{ - "sites": [ - { - "name": "Gale Crater Overview", - "code": "GCO", - "view": [ - -4.6748, - 137.3738, - 11 - ] - }, - { - "name": "Gale Crater", - "code": "GAC1", - "view": [ - -4.6248, - 137.3738, - 16 - ] - } - ] -} -``` - -- `sites`: An array of objects required to add sites. -- `name`: A display name users see when selecting sites. -- `code`: A unique code to identify the site. -- `view`: An array as `[latitude, longitude, zoom]`. diff --git a/documentation/pages/markdowns/Tile.md b/documentation/pages/markdowns/Tile.md deleted file mode 100644 index a21ba636..00000000 --- a/documentation/pages/markdowns/Tile.md +++ /dev/null @@ -1,81 +0,0 @@ -# Tile Layer - -Tile layers are hierarchical raster imagery. - -#### Layer Name - -_type:_ string -The unique display name and identifier of the layer. It must be unique and contain no special characters. - -#### URL - -_type:_ string -A file path that points to a tileset's directory. If the path is relative, it will be relative to the mission's directory. The URL must contain a proper placeholder ending such as: `{z}/{x}/{y}.png`. See the "Tile Format" section below for more details. - -#### DEM Tile URL - -_type:_ string _optional_ -A file path like URL but pointing to a Digital Elevation Map tileset generated by `auxillary/1bto4b/rasterstotiles1bto4b.py` This is responsible for 3D data in the globe. It would be ideal if this tileset can match the extents of its corresponding raster and has either no nodata or has nodata far lower than that of its lowest point. - -#### Legend - -_type:_ string -An absolute or relative file path pointing to a `legend.csv` that describes the symbology of the layer. Please see the Legend Tool to see how to form a `legend.csv`. - -#### Tile Format - -_type:_ enum [TMS, WMTS, WMS] -The format of the tiles. - -- TMS: Tile Map Service tiles are 256x256 sized images hierarchically organized by zoom level and referenced with x and y coordinates. These are the standard format for web tiles and are the format that MMGIS's auxiliary tiling scripts output. Append `/{z}/{x}/{y}.png` to your `URL`. -- WMTS: Web Map Tile Service is the same exact concept as TMS but it has an inverted Y-axis. Just like TMS, append `/{z}/{x}/{y}.png` to your `URL`. -- WMS: Web Map Service tiles are a popular way of publishing maps by professional GIS software. This format is similar to the previous two formats, but more generic and not so well optimized for use in web maps. A WMS image is defined by the coordinates of its corners. A layer (or list of layers) should be provided as an options by appending `?layers=<your_layer_name><,another_if_you _want>` to your `URL`. To override WMS parameters append `&<wms_param>=<value>` again to the `URL` after the "layers" parameters. - _Example URL: `http://ows.mundialis.de/services/service?layers=TOPO-WMS,OSM-Overlay-WMS`_ - -#### Initial Visibility - -_type:_ bool -Whether the layer is on initially. - -#### Initial Opacity - -_type:_ float -A value from 0 to 1 of the layer's initial opacity. 1 is fully opaque. - -#### Minimum Zoom - -_type:_ integer -The lowest (smallest number) zoom level of the tile set. -_Note: This field can be automatically populate with "Populate from XML". "Populate from XML" uses looks for a `tilemapresource.xml` in the tileset directory specified by the URL field._ - -#### Maximum Native Zoom - -_type:_ integer -The highest (largest number) zoom level of the tile set. -_Note: This field can be automatically populate with "Populate from XML". "Populate from XML" uses looks for a `tilemapresource.xml` in the tileset directory specified by the URL field._ - -#### Maximum Zoom - -_type:_ integer -The highest (largest number) zoom level to see in MMGIS. This value is at least as high as Maximum Native Zoom. This allows zooms level higher than that of the tileset. Instead of rendering new tile image, it scales them in instead. - -#### Bounding Box - -_type:_ string _optional_ -A comma separated string defining the tileset's `minimumLonDeg,minimumLatDeg,maximumLonDeg,maximumLatDeg`. Setting a bounding box improves performance by limiting requests for tiles to only those that fit the bounds. -_Note: This field can be automatically populate with "Populate from XML". "Populate from XML" uses looks for a `tilemapresource.xml` in the tileset directory specified by the URL field._ - -#### Time Enabled - -_type:_ bool -True if the layer is time enabled. URLs that contain `{time}` will be dynamically replaced by their set values when the layer is fetched. - -#### Time Type - -_type:_ enum [Global, Individual] -Whether the layer should use global time values or function independently with its own time values. - -#### Time Format - -_type:_ string _optional_ -The string format to be used in the URL for `{time}`. Defaults to `%Y-%m-%dT%H:%M:%SZ`. diff --git a/documentation/pages/markdowns/Time_Tab.md b/documentation/pages/markdowns/Time_Tab.md deleted file mode 100644 index c0d2cc69..00000000 --- a/documentation/pages/markdowns/Time_Tab.md +++ /dev/null @@ -1,17 +0,0 @@ -# Time Tab - -## User Interface - -### Enabled - -This enables the user interface for Time. If disabled, global time will not be used - -### Visible - -Whether or not the Time user interface should be visible. - -## Time Format - -The time format to be displayed on the Time UI. Uses D3 time format specifiers: https://github.com/d3/d3-time-format - -Default: `%Y-%m-%dT%H:%M:%SZ` diff --git a/documentation/pages/markdowns/Tools_Tab.md b/documentation/pages/markdowns/Tools_Tab.md deleted file mode 100644 index baa2e24b..00000000 --- a/documentation/pages/markdowns/Tools_Tab.md +++ /dev/null @@ -1,7 +0,0 @@ -# Tools Tab - -This tab allows you to toggle and customize tools: - -- Each tool has a checkbox to toggle it on and off, a description and way to change icons. - - Icons are currently from Material Design Icons and can be found [here](https://materialdesignicons.com/). -- Some tools have a json text editor underneath them. This signifies that this tool needs more information to work and makes the tool itself configurable. Clicking on the tool's description will bring up an example json with an explanation. For more information, visit the Tool's documentation page. diff --git a/documentation/pages/markdowns/Vector.md b/documentation/pages/markdowns/Vector.md deleted file mode 100644 index 0019ceb7..00000000 --- a/documentation/pages/markdowns/Vector.md +++ /dev/null @@ -1,250 +0,0 @@ -# Vector Layer - -A [geojson](https://geojson.org/) layer. - -#### Layer Name - -_type:_ string -The unique display name and identifier of the layer. It must be unique and contain no special characters. - -#### Kind of Layer - -_type:_ enum -A special kind of interaction for the layer. Please see the Kinds page for more. - -#### URL - -_type:_ string -A file path that points to a geojson. If the path is relative, it will be relative to the mission's directory. The URL must contain a proper placeholder ending such as: `{z}/{x}/{y}.png`. Alternatively vectors can be served with Geodatasets. Simply go to "Manage Geodatasets" at the bottom left, upload a geojson and link to it in this URL field with "geodatasets:{geodataset\*name}" - -#### Controlled - -_type:_ bool -Whether the layer can be dynamically updated or not. If true, the layer can be dynamically updated and the URL is not required. - -#### Legend - -_type:_ string -An absolute or relative file path pointing to a `legend.csv` that describes the symbology of the layer. Please see the Legend Tool to see how to form a `legend.csv`. - -#### Initial Visibility - -_type:_ bool -Whether the layer is on initially. - -#### Visibility Cutoff - -_type:_ integer _optional_ -If set, this vector layer will be hidden if the current zoom level is less than or equal to that of the visibility cutoff. `Visibility Cutoff * -1` will invert its visibility condition. This is useful when the dataset is dense, local to a one region, or irrelevant when far away and the desired range of zoom levels is large. - -#### Initial Opacity - -_type:_ float -A value from 0 to 1 of the layer's initial opacity. 1 is fully opaque. - -#### Time Enabled - -_type:_ bool -True if the layer is time enabled. URLs that contain `{starttime}` or `{endtime}` will be dynamically replaced by their set values when the layer is fetched. - -#### Time Type - -_type:_ enum [Global, Individual] -Whether the layer should use global time values or function independently with its own time values. - -#### Time Format - -_type:_ string _optional_ -The string format to be used in the URL for `{starttime}` and `{endtime}`. Defaults to `YYYY-MM-DDTHH:mm:ssZ`. - -#### Stroke Color - -_type:_ CSS color string or a prop _optional_ -The border color of each feature. If the feature is a line, this field is the color of the line. See the Vector Styling page for more. Colors can be as follows: - -- A named color - - crimson, blue, rebeccapurple -- A hex color - - #FFF - - #A58101 -- An rgb color - - rgb(255,89,45) -- An hsl color - - hsl(130, 26%, 34%) -- Based on a feature's color property - - `prop:geojson_property_key` will set the feature's color to the values of `features[i].properties.geojson_property_key` - - If that property is not a valid CSS color and is a string, it will use a random and consistent color based on its hash. - -#### Fill Color - -_type:_ CSS color string or a prop _optional_ -The fill color of each feature. See Stroke Color for color options. See the Vector Styling page for more. - -#### Stroke Weight - -_type:_ positive integer _optional_ -The thickness of the stroke/border in pixels. See the Vector Styling page for more. - -#### Fill Opacity - -_type:_ float _optional_ -A value from 0 to 1 of Fill Color's opacity. 1 is fully opaque. See the Vector Styling page for more. -_Note: It's also possible to set the opacities of colors directly with #CCDDEEFF, rgba() and hsla()._ - -#### Radius - -_type:_ positive integer _optional_ -When a point feature is encountered, this value will be it's radius in pixels. - -#### Raw Variables - -Clicking "Set Default Variables" will add a template of all possible raw variables (without overwriting ones that are already set). All raw variables are optional. - -Example: - -```javascript -{ - "useKeyAsName": "name", - "datasetLinks": [ - { - "prop": "{prop}", - "dataset": "{dataset}", - "column": "{column}", - "type": "{none || images}" - } - ], - "links": [ - { - "name": "example", - "link": "url/?param={prop}" - } - ], - "info": [ - { - "which": "last", - "icon": "material design icon", - "value": "Prop: {prop}" - } - ], - "markerAttachments": { - "bearing": { - "angleProp": "path.to.angle.prop", - "angleUnit": "deg || rad", - "color": "#FFFFFF", - }, - "uncertainty": { - "initialVisibility": true, - "xAxisProp": "path.to.x.prop", - "yAxisProp": "path.to.y.prop", - "axisUnit": "meters || kilometers", - "angleProp": "path.to.angle.prop", - "angleUnit": "deg || rad", - "color": "#888888", - "color3d": "#FFFF00", - "depth3d": 8 - }, - "image": { - "initialVisibility": true, - "path": "url to top-down ortho image. ex. public/images/rovers/PerseveranceTopDown.png", - "pathProp": "path to image. take priority over path", - "widthMeters": 2.6924, - "widthPixels": 420, - "heightPixels": 600, - "angleProp": "path.to.angle.prop", - "angleUnit": "deg || rad", - "show": "click || always", - }, - "model": { - "path": "path to model (.dae, .glb, .gltf, .obj)", - "pathProp": "path to model. take priority over path", - "mtlPath": "if .obj, path to material file (.mtl)", - "yawProp": "path.to.yaw.prop", - "yawUnit": "deg || rad", - "invertYaw": false, - "pitchProp": "path.to.pitch.prop", - "pitchUnit": "deg || rad", - "invertPitch": true, - "rollProp": "path.to.roll.prop", - "rollUnit": "deg || rad", - "invertRoll": false, - "elevationProp": "path.to.elev.prop", - "scaleProp": "path.to.scale.prop", - "show": "click || always", - "onlyLastN": false - }, - }, - "markerIcon": { //See: https://leafletjs.com/reference-1.7.1.html#icon-l-icon - "iconUrl": "pathToMainIconImage.png", - "shadowUrl": "(opt)pathToShadowImage.png", - "iconSize": [38, 95], // size of the icon - "shadowSize": [50, 64], // size of the shadow - "iconAnchor": [22, 94], // point of the icon which will correspond to marker's location - "shadowAnchor": [4, 62], // the same for the shadow - }. - "search": "(prop1) round(prop2.1) rmunder(prop_3)" -} -``` - -- `useNameAsKey`: The property key whose value should be the hover text of each feature. If left unset, the hover key and value will be the first one listed in the feature's properties. -- `datasetLinks`: Datasets are csvs uploaded from the "Manage Datasets" page accessible on the lower left. Every time a feature from this layer is clicked with datasetLinks configured, it will request the data from the server and include it with it's regular geojson properties. This is especially useful when single features need a lot of metadata to perform a task as it loads it only as needed. - - `prop`: This is a property key already within the features properties. It's value will be searched for in the specified dataset column. - - `dataset`: The name of a dataset to link to. A list of datasets can be found in the "Manage Datasets" page. - - `column`: This is a column/csv header name within the dataset. If the value of the prop key matches the value in this column, the entire row will be return. All rows that match are returned. - - `type`: Unused. -- `links`: Configure deep links to other sites based on the properties on a selected feature. This requires the "Minimalist" option in the Look Tab to be unchecked. Upon clicking a feature, a list of deep links are put into the top bar and can be clicked on to navigate to any other page. - - `name`: The name of the deep link. It should be unique. - - `link`: A url template. Curly brackets are included. On feature click, all `{prop}` are replaced with the corresponding `features[i].properties.prop` value. Multiple `{prop}` are supported as are access to nested props using dot notation `{stores.food.candy}`. -- `info`: Creates an informational record at the top of the page. The first use case was showing the value of the latest sol. Clicking this record pans to the feature specified by `which`. This requires the "Minimalist" option in the Look Tab to be unchecked. This is used on startup and not when a user selects a feature in this layer. - - `which`: This only supports the value `last` at this point. - - `icon`: Any [Material Design Icon](http://materialdesignicons.com/) name - - `value`: A name to display. All `{prop}`s will be replaced by their corresponding `features[which].properties[prop]` value. -- `markerBearing`: Sets the bearing direction of this layer's point markers (or markerIcons if set). `{unit}` is either `deg` or `rad` and `{prop}` is the dot notated path to the feature properties that contains the desired rotation angle. Ex. `deg:headings.yaw`. -- `markerAttachments`: An object for attaching dynamic items to point features. - - `bearing`: Sets the bearing direction of this layer's point markers (or markerIcons if set). Overrides the layer's shape dropdown value. - - `angleProp`: The dot notated path to the feature properties that contains the desired rotation angle. Ex. `headings.yaw`. - - `angleUnit`: Unit of the value of `angleProp`. Either `deg` or `rad`. - - `color`: A css color for the directional arrow for non-markerIcon bearings. - - `uncertainty`: A sublayer feature that places ellipses about point features to indicate positional uncertainty - - `initialVisibility`: Whether the uncertainty sublayer is initially on. Users can toggle sublayers on and off in the layer settings in the LayersTool. - - `xAxisProp`: Prop path to the x axis radius value of the ellipse. - - `yAxisProp`: Prop path to the y axis radius value of the ellipse. - - `axisUnit`: "meters || kilometers", - - `angleProp`: Prop path to the rotation of the ellipse. - - `angleUnit`: "deg || rad" - - `color`: A css fill color. Will be made more transparent than set. Default 'white' - - `fillOpacity`: Map and clamped ellipse fill opacity. 0 to 1. Default 0.25 - - `strokeColor`: Map and clamped ellipse stroke/border color. Default 'black' - - `weight`: Map and clamped ellipse stroke/border weight/thickness. Default 1 - - `opacity`: Overall Map and clamped ellipse opacity. Default 0.8 - - `color3d`: 3d curtain ellipse color. Can be an array for a vertical gradient: ["rgba(0,0,0,0)", "#26A8FF"] - - `depth3d`: Depth in meters for 3d ellipse curve. Default 2 - - `opacity3d`: 3d curtain ellipse opacity - - `image`: Places a scaled and orientated image under each marker. A sublayer. - - `initialVisibility`: Whether the image sublayer is initially on. Users can toggle sublayers on and off in the layer settings in the LayersTool. - - `path`: A url to a (preferably) top-down north-facing orthographic image. - - `pathProp`: A prop path to an image url. Take priority over path. Useful if the path is feature specific. - - `widthMeters`: Width of image in meters in order to calculate scale. - - `widthPixels`: Image width in pixels. - - `heightPixels`: Image height in pixel. - - `angleProp`: Prop path to the rotation of the image. - - `angleUnit`: "deg || rad" - - `show`: "click || always". If set to "always", overrides the Waypoints Kind (if set) and always renders the image under the marker. "click" just shows the image on click and requires the layer to have the Waypoints Kind. - - `model`: - - `path`: Path to model (.dae, .glb, .gltf, .obj) - - `pathProp`: A prop path to a model. Takes priority over path. Useful if model is feature specific. - - `mtlPath`: If .obj, the path to its material file (.mtl) - - `yawProp`: Prop path to the model's yaw. If this value is a number, uses it directly. - - `yawUnit`: "deg || rad" - - `invertYaw`: Boolean that, if true, multiplies yaw by -1. - - `pitchProp`: Prop path to the model's pitch. If this value is a number, uses it directly. - - `pitchUnit`: "deg || rad" - - `invertPitch`: Boolean that, if true, multiplies pitch by -1. - - `rollProp`: Prop path to the model's roll. If this value is a number, uses it directly. - - `rollUnit`: "deg || rad" - - `invertRoll`: Boolean that, if true, multiplies roll by -1. - - `elevationProp`: Prop path to the model's elevation (in meters). If this value is a number, uses it directly. Default 0. - - `scaleProp`: Prop path to the model's scale. If this value is a number, uses it directly. Default 1. - - `show`: "click || always" - - `onlyLastN`: If false, shows models at all points. If a number, only shows models for the last n points. -- `markerIcon`: Uses an icon image instead of an svg for all of the layer's point markers. If you're using this as a bearing marker, make sure the base icon is pointing north. -- `search`: This requires the "Minimalist" option in the Look Tab to be unchecked. When set, this layer will become searchable through the search bar at the top. The search will look for and autocomplete on the properties specified. All properties are enclosed by parentheses and space-separated. `round` can be used like a function to round the property beforehand. `rmunder` works similarly but removes all underscores instead. diff --git a/documentation/pages/markdowns/Vector_Styling.md b/documentation/pages/markdowns/Vector_Styling.md deleted file mode 100644 index 19ba6de3..00000000 --- a/documentation/pages/markdowns/Vector_Styling.md +++ /dev/null @@ -1,57 +0,0 @@ -# Vector Styling - -There are two main ways to style a GeoJSON Vector Layer: - -1. Changing a Vector Layer's configuration style fields -1. Adding a style object into a feature's `"properties"` object inside a GeoJSON file. - -The priorities of stylings are as follows (from highest to lowest): - -1. Vector Layer configuration style fields with `prop:geojson_property_key` entered - - `prop:geojson_property_key` will set the feature's color to the values of `features[i].properties.geojson_property_key` -2. Style Object per feature - Example: - - ```javascript - "properties": { - "style": { - "fillColor": "#b3b300", - "fillOpacity": 1, - "color": "black", - "opacity": 1, - "weight": 2, - "radius": 10, - "dashArray": "20", - "lineCap": "square", - "lineJoin": "miter", - "noclick": true, - "nointeraction": true - } - } - ``` - - All are optional, including the `"style"` object entirely. - - - `fillColor`: The internal color of the feature. - - `fillOpacity`: The opacity of the `fillColor`. Alternatively, `fillColor` could hold a color with alpha itself such as `rgba(255,0,0,0.5)` or `hsl(170, 80%, 50%, 0.1)`. - - `color`: The color of the stroke/border of the feature. If the feature is a line, this is its main color. - - `opacity`: The opacity of the stroke/border. If the feature is a line, this is its main opacity. Alternatively, `color` could hold a color with alpha itself such as `rgba(255,0,0,0.5)` or `hsl(170, 80%, 50%, 0.1)`. - - `weight`: The thickness in pixels of the stroke/border. - - `radius`: If the feature type is a point, the radius in pixels of that point. - - `dashArray`: A dashed border. See [stroke-dasharray](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray). - - `lineCap`: How to cap off the ends of lines. See [stroke-linecap](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linecap). - - `lineJoin`: How to join line segments. See [stroke-linejoin](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linejoin). - - `noclick`: True sets the feature to be unclickable. - - `nointeraction`: True sets the feature to have no interactions (no click, no hover, can click through). - -3. Vector Layer configuration style fields (non-`prop:geojson_property_key`) - - A named color - - crimson, blue, rebeccapurple - - A hex color - - #FFF, #A58101 - - An rgb color - - rgb(255,89,45) - - An hsl color - - hsl(130, 26%, 34%) - - See [CSS colors](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) for a complete list. -4. A default black or blue. diff --git a/documentation/pages/markdowns/Vector_Tile.md b/documentation/pages/markdowns/Vector_Tile.md deleted file mode 100644 index a0e43a47..00000000 --- a/documentation/pages/markdowns/Vector_Tile.md +++ /dev/null @@ -1,111 +0,0 @@ -# Vector Tile Layer - -A mix between Tile and Vector. Useful when rendering tons of features since features are rendered based on viewport instead of all at once at the start. - -#### Layer Name - -_type:_ string -The unique display name and identifier of the layer. It must be unique and contain no special characters. - -#### Kind of Layer - -_type:_ enum -A special kind of interaction for the layer. Please see the Kinds page for more. - -#### URL - -_type:_ string -A file path that points to a vector tileset's directory. If the path is relative, it will be relative to the mission's directory. The URL must contain a proper placeholder ending such as: `{z}/{x}/{y}.png`. Alternatively vector tiles can be generated and served in real time with Geodatasets. Simply go to "Manage Geodatasets" at the bottom left, upload a geojson and link to it in this URL field with "geodatasets:{geodataset*name}" -\_Note: If the vector tile layer contains points, the layer will break. A known workaround is to buffer all points.* - -#### DEM Tile URL - -_type:_ string _optional_ -A file path like URL but pointing to a Digital Elevation Map tileset generated by `auxillary/1bto4b/rasterstotiles1bto4b.py` This is responsible for 3D data in the globe. It would be ideal if this tileset can match the extents of its corresponding raster and has either no nodata or has nodata far lower than that of its lowest point. - -#### Legend - -_type:_ string -An absolute or relative file path pointing to a `legend.csv` that describes the symbology of the layer. Please see the Legend Tool to see how to form a `legend.csv`. - -#### Tile Format - -_type:_ enum [TMS, WMTS, WMS] -The format of the tiles. - -- TMS: Tile Map Service tiles are 256x256 sized images hierarchically organized by zoom level and referenced with x and y coordinates. These are the standard format for web tiles and are the format that MMGIS's auxiliary tiling scripts output. Append `/{z}/{x}/{y}.png` to your `URL`. -- WMTS: Web Map Tile Service is the same exact concept as TMS but it has an inverted Y-axis. Just like TMS, append `/{z}/{x}/{y}.png` to your `URL`. -- WMS: Web Map Service tiles are a popular way of publishing maps by professional GIS software. This format is similar to the previous two formats, but more generic and not so well optimized for use in web maps. A WMS image is defined by the coordinates of its corners. A layer (or list of layers) should be provided as an options by appending `?layers=<your_layer_name><,another_if_you _want>` to your `URL`. To override WMS parameters append `&<wms_param>=<value>` again to the `URL` after the "layers" parameters. - _Example URL: `http://ows.mundialis.de/services/service?layers=TOPO-WMS,OSM-Overlay-WMS`_ - -#### Initial Visibility - -_type:_ bool -Whether the layer is on initially. - -#### Initial Opacity - -_type:_ float -A value from 0 to 1 of the layer's initial opacity. 1 is fully opaque. - -#### Minimum Zoom - -_type:_ integer -The lowest (smallest number) zoom level of the tile set. -_Note: This field can be automatically populate with "Populate from XML". "Populate from XML" uses looks for a `tilemapresource.xml` in the tileset directory specified by the URL field._ - -#### Maximum Native Zoom - -_type:_ integer -The highest (largest number) zoom level of the tile set. -_Note: This field can be automatically populate with "Populate from XML". "Populate from XML" uses looks for a `tilemapresource.xml` in the tileset directory specified by the URL field._ - -#### Maximum Zoom - -_type:_ integer -The highest (largest number) zoom level to see in MMGIS. This value is at least as high as Maximum Native Zoom. This allows zooms level higher than that of the tileset. Instead of rendering new tile image, it scales them in instead. - -#### Time Enabled - -_type:_ bool -True if the layer is time enabled. URLs that contain `{time}` will be dynamically replaced by their set values when the layer is fetched. - -#### Time Type - -_type:_ enum [Global, Individual] -Whether the layer should use global time values or function independently with its own time values. - -#### Time Format - -_type:_ string _optional_ -The string format to be used in the URL for `{time}`. Defaults to `YYYY-MM-DDTHH:mm:ssZ`. - -#### Vector Tile Feature Unique Id Key - -_type:_ string -Each feature of the vector tileset needs a property with a unique value to identify it. This required field is the name of that property. - -#### Use Key as Name - -_type:_ string _optional_ -The property key whose value should be the hover text of each feature. This is the same as the `useKeyAsName` raw variable within Vector layers - -#### Raw Variables - -Vector Tiles are styled differently than Vectors. Raw variables here takes an object that maps internal vector tile layer names to styles. All raw variables are optional. - -Example: - -```javascript -{ - "<internal_vector_tile_layer_name>": { - "color": "#FFFFFF", - "fill": true, - "fillColor": "rgb(0, 125, 200)", - "fillOpacity": 0.5, - "opacity": 1, - "radius": 4, - "weight": 2 - } -} -``` diff --git a/documentation/pages/markdowns/Viewshed.md b/documentation/pages/markdowns/Viewshed.md deleted file mode 100644 index dafb3a68..00000000 --- a/documentation/pages/markdowns/Viewshed.md +++ /dev/null @@ -1,80 +0,0 @@ -# Viewshed - -The Viewshed tool renders dynamic tilesets based on line-of-sight visibilities from user defined source points. Users can change viewshed colors, opacities, source heights, fields of views and visualize multiple viewsheds simultaneously. - -## Tool Configuration - -### Example - -```javascript -{ - "data": [ - { - "name": "Unique Name 1", - "demtileurl": "Layers/Example/demtileset/{z}/{x}/{y}.png", - "minZoom": 8, - "maxNativeZoom": 18 - }, - { "...": "..." } - ], - "curvature": false, - "cameraPresets": [ - { - "name": "CAM A", - "height": 2, - "azCenter": 0, - "azFOV": 70, - "elCenter": -10, - "elFOV": 30 - }, - { "...": "..." } - ] -} -``` - -_**data**_ - At minimum, the Viewshed tool requires at least one "data" source. A data source describes a DEM tileset (see /auxiliary/1bto4b) and allows users to select it by name to generate viewsheds over. - -_**curvature**_ - Optionally setting this to false disables the account of drop-off based on planetary curvature when calculating viewsheds. If unset or set to true, the configured Major Radius will be used during generations. - -_**cameraPresets**_ - Are optional but, if set, require only "name" to be defined. Setting these allows users to quickly navigate to preset camera parameters. "height", "azCenter", "azFOV", "elCenter" and "elFOV" are all optional and are all of type number. - -## Tool Use - -### Options - -Users can modify the following parameters per viewshed: - -_**Data**_ - Changes the dataset to perform the viewshed on. - -_**Color**_ - Changes the color of the viewshed. - -_**Opacity**_ - Changes the opacity of the viewshed. - -_**Resolution**_ - Because viewshedding requires a lot of data which can slow things down, four resolutions of data are provided. Ultra, the highest resolution, matches the resolution of the current raster tiles based on zoom. For example if the raster basemap is at 200 meters/pixel, an ultra viewshed would be generated with 200 meters/pixel (or highest available) digital elevation map (DEM) data. The resolution of the DEM impacts the accuracy of the generated viewshed. High is half the resolution of ultra, Medium, the default, is half the resolution of high, and low is half the resolution of medium. Due to performance issues both ultra and high resolutions require manual regeneration upon changes to viewshed parameters or regions. - -_**Reverse**_ - Normally viewsheds color the visible regions. Reversing the viewshed colors everything except the visible regions. - -_**Camera Preset**_ - Using values configured for the Viewshed Tool, sets other parameters to mock a camera. - -_**Height**_ - The distance, in meters, that the viewshed source point sits above the surface. - -_**FOV (Az)**_ - The azimuthal (horizontal) field of view. - -_**FOV (El)**_ - The elevational (vertical) field of view. - -_**Center Azimuth**_ - The azimuthal look-at angle. 0deg (North) -> 360deg (North) increasing clockwise. The generated viewshed will encompass the range such that half its FOV falls on either half of its angle. - -_**Center Elevation**_ - The elevational look-at angle. -90deg(Down) -> 90deg (Up). The generated viewshed will encompass the range such that half its FOV falls on both top and bottom halves of its angle. - -_**Latitude**_ - The latitude of the viewshed's source point. - -_**Longitude**_ - The longitude of the viewshed's source point. - -## Technical - -- The accuracy of the Viewshed tool has been independently verified within ArcGIS. -- Viewsheds are generated entirely in-browser in JavaScript using tiled data. - - The algorithm is derived from ["Generating Viewsheds without Using Sightlines. Wang, Jianjun, Robinson, Gary J., and White, Kevin. Photogrammetric Engineering and Remote Sensing. p81"](https://www.asprs.org/wp-content/uploads/pers/2000journal/january/2000_jan_87-90.pdf) with implementation guidance from [gdal_viewshed](https://github.com/OSGeo/gdal/blob/master/gdal/alg/viewshed.cpp). - - The algorithm is somewhat special to our DEM tile format in how it deal seam boundaries and stitches tiles together. - - An additional data manager was written to query for all tiles necessary to render the viewshed for the current screen. - - Azimuth and elevation fields-of-views and look-ats are new. diff --git a/examples/ReactWrappedIframe/index.html b/examples/ReactWrappedIframe/index.html new file mode 100644 index 00000000..74306d1a --- /dev/null +++ b/examples/ReactWrappedIframe/index.html @@ -0,0 +1,217 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <title>React Wrapped iframe</title> + <meta charset="utf-8" /> + <meta + name="viewport" + content="width=device-width,user-scalable=no,minimum-scale=1,maximum-scale=1" + /> + <meta name="theme-color" content="#1d1f20" /> + <meta + name="description" + content="A web-based mapping and localization solution for science operation on planetary missions." + /> + <script src="../lib/react.development.js"></script> + <script src="../lib/react-dom.development.js"></script> + <script src="../lib/babel.min.js"></script> + <style> + body, + html { + background: #1d1f20; + overflow: hidden; + margin: 0; + padding: 0; + width: 100%; + height: 100%; + box-sizing: border-box; + font-family: sans-serif; + } + iframe { + width: 100%; + height: 100%; + border: none; + } + ul { + list-style-type: none; + margin: 0; + padding: 0; + } + ul li { + width: 40px; + text-align: center; + padding: 10px 0px; + } + p { + font-size: 14px; + } + #root { + width: 100%; + height: 100%; + } + .App { + width: 100%; + height: 100%; + display: flex; + flex-flow: column; + } + .TopBar { + width: 100%; + height: 40px; + background: white; + font-weight: bold; + padding: 10px; + box-sizing: border-box; + border-bottom: 1px solid #ddd; + } + .main { + display: flex; + height: calc(100vh - 40px); + width: 100%; + } + .Toolbar { + height: 100%; + width: 40px; + background: white; + box-sizing: border-box; + border-right: 1px solid #ddd; + } + .Panel { + height: 100%; + background: #f5f5f5; + padding: 10px; + box-sizing: border-box; + overflow-y: auto; + } + .MMGIS { + flex: 1; + } + .layer { + height: 10px; + margin: 2px 0px; + padding-left: 6px; + line-height: 12px; + cursor: pointer; + width: 220px; + text-align: left; + } + .layer.on { + border-left: 12px solid green; + } + .layer.off { + border-left: 12px solid red; + } + </style> + </head> + <body> + <div id="root"></div> + + <!-- + <div id="main"> + <div id="top"></div> + <div id="middle"> + <div id="left"></div> + <div id="center"> + <iframe src="http://localhost:8888" title="MMGIS"></iframe> + </div> + <div id="right"></div> + </div> + <div id="bottom"></div> + </div> + --> + </body> + <footer> + <script type="text/babel"> + function TopBar() { + return <div className="TopBar">React Wrapped Iframe</div>; + } + + function Toolbar() { + return ( + <div className="Toolbar"> + <ul> + <li>A</li> + <li>B</li> + <li>C</li> + <li>D</li> + </ul> + </div> + ); + } + function Panel(props) { + const { width } = props; + return ( + <div className="Panel" style={{ width: `${width || 250}px` }}> + {props.children} + </div> + ); + } + function MMGIS() { + React.useEffect(() => { + const MMGISIframe = document.getElementById("MMGISIframe"); + MMGISIframe.addEventListener("load", function () { + window.mmgisAPI = this.contentWindow.mmgisAPI; + }); + MMGISIframe.src = "http://localhost:8888?mission=MSL"; + }, []); + return ( + <div className="MMGIS"> + <iframe id="MMGISIframe"></iframe> + </div> + ); + } + + function App() { + const [availableLayers, setAvailableLayers] = React.useState(null); + return ( + <div className="App"> + <TopBar /> + <div className="main"> + <Toolbar /> + <Panel width={300}> + {availableLayers == null && ( + <button + onClick={() => { + setAvailableLayers(mmgisAPI.getVisibleLayers()); + }} + > + Show Layers + </button> + )} + <ul> + {availableLayers && + Object.keys(availableLayers).map((layerName, i) => ( + <li + key={i} + className={`layer ${ + availableLayers[layerName] ? "on" : "off" + }`} + onClick={async () => { + await mmgisAPI.toggleLayer(layerName); + setAvailableLayers(mmgisAPI.getVisibleLayers()); + }} + > + {layerName} + </li> + ))} + </ul> + </Panel> + <MMGIS /> + <Panel width={400}> + <h3>How to run this example:</h3> + <p>Add .env: FRAME_ANCESTORS='["http://localhost:8888"]'</p> + <p>Add .env: FRAME_SRC='["http://localhost:8888"]'</p> + <p>`npm run build`</p> + <p>`npm run start:prod:with_examples`</p> + <p> + Go to: localhost:8888/examples/ReactWrappedIframe/index.html + </p> + </Panel> + </div> + </div> + ); + } + ReactDOM.render(<App />, document.getElementById("root")); + </script> + </footer> +</html> diff --git a/examples/WrappedIframe/index.html b/examples/WrappedIframe/index.html new file mode 100644 index 00000000..9c383b07 --- /dev/null +++ b/examples/WrappedIframe/index.html @@ -0,0 +1,84 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <title>Wrapped iframe</title> + <meta charset="utf-8" /> + <meta + name="viewport" + content="width=device-width,user-scalable=no,minimum-scale=1,maximum-scale=1" + /> + <meta name="theme-color" content="#1d1f20" /> + <meta + name="description" + content="A web-based mapping and localization solution for science operation on planetary missions." + /> + <style> + body, + html { + background: #1d1f20; + overflow: hidden; + margin: 0; + padding: 0; + width: 100%; + height: 100%; + box-sizing: border-box; + } + iframe { + width: 100%; + height: 100%; + border: none; + } + #root { + width: 100vw; + height: 100vh; + overflow: hidden; + display: flex; + flex-flow: column; + } + #top { + width: 100%; + height: 40px; + background: #222; + } + #middle { + width: 100%; + flex: 1; + display: flex; + } + #bottom { + width: 100%; + height: 40px; + background: #222; + } + #left { + height: 100%; + width: 300px; + background: #333; + } + #center { + height: 100%; + flex: 1; + } + #right { + height: 100%; + width: 200px; + background: #333; + } + </style> + </head> + <body> + <noscript>You need to enable JavaScript to run this app.</noscript> + <div id="root"> + <div id="top"></div> + <div id="middle"> + <div id="left"></div> + <div id="center"> + <iframe src="http://localhost:8888" title="MMGIS"></iframe> + </div> + <div id="right"></div> + </div> + <div id="bottom"></div> + </div> + </body> + <footer></footer> +</html> diff --git a/examples/lib/babel.min.js b/examples/lib/babel.min.js new file mode 100644 index 00000000..10757768 --- /dev/null +++ b/examples/lib/babel.min.js @@ -0,0 +1,25 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Babel=t():e.Babel=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}(function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(typeof e[t]){case"function":break;case"object":e[t]=function(t){var r=t.slice(1),n=e[t[0]];return function(e,t,i){n.apply(this,[e,t,i].concat(r))}}(e[t]);break;default:e[t]=e[e[t]]}return e}([function(e,t,r){"use strict";function n(e,t){return g(t)&&"string"==typeof t[0]?e.hasOwnProperty(t[0])?[e[t[0]]].concat(t.slice(1)):void 0:"string"==typeof t?e[t]:t}function i(e){var t=(e.presets||[]).map(function(e){var t=n(E,e);if(!t)throw new Error('Invalid preset specified in Babel options: "'+e+'"');return g(t)&&"object"===h(t[0])&&t[0].hasOwnProperty("buildPreset")&&(t[0]=d({},t[0],{buildPreset:t[0].buildPreset})),t}),r=(e.plugins||[]).map(function(e){var t=n(b,e);if(!t)throw new Error('Invalid plugin specified in Babel options: "'+e+'"');return t});return d({babelrc:!1},e,{presets:t,plugins:r})}function s(e,t){return y.transform(e,i(t))}function a(e,t,r){return y.transformFromAst(e,t,i(r))}function o(e,t){b.hasOwnProperty(e)&&console.warn('A plugin named "'+e+'" is already registered, it will be overridden'),b[e]=t}function u(e){Object.keys(e).forEach(function(t){return o(t,e[t])})}function l(e,t){E.hasOwnProperty(e)&&console.warn('A preset named "'+e+'" is already registered, it will be overridden'),E[e]=t}function c(e){Object.keys(e).forEach(function(t){return l(t,e[t])})}function f(e){(0,v.runScripts)(s,e)}function p(){window.removeEventListener("DOMContentLoaded",f)}Object.defineProperty(t,"__esModule",{value:!0}),t.version=t.buildExternalHelpers=t.availablePresets=t.availablePlugins=void 0;var d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.transform=s,t.transformFromAst=a,t.registerPlugin=o,t.registerPlugins=u,t.registerPreset=l,t.registerPresets=c,t.transformScriptTags=f,t.disableScriptTags=p;var m=r(290),y=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(m),v=r(629),g=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},b=t.availablePlugins={},E=t.availablePresets={};t.buildExternalHelpers=y.buildExternalHelpers;u({"check-es2015-constants":r(66),"external-helpers":r(322),"inline-replace-variables":r(323),"syntax-async-functions":r(67),"syntax-async-generators":r(195),"syntax-class-constructor-call":r(196),"syntax-class-properties":r(197),"syntax-decorators":r(125),"syntax-do-expressions":r(198),"syntax-exponentiation-operator":r(199),"syntax-export-extensions":r(200),"syntax-flow":r(126),"syntax-function-bind":r(201),"syntax-function-sent":r(325),"syntax-jsx":r(127),"syntax-object-rest-spread":r(202),"syntax-trailing-function-commas":r(128),"transform-async-functions":r(326),"transform-async-to-generator":r(129),"transform-async-to-module-method":r(328),"transform-class-constructor-call":r(203),"transform-class-properties":r(204),"transform-decorators":r(205),"transform-decorators-legacy":r(329).default,"transform-do-expressions":r(206),"transform-es2015-arrow-functions":r(68),"transform-es2015-block-scoped-functions":r(69),"transform-es2015-block-scoping":r(70),"transform-es2015-classes":r(71),"transform-es2015-computed-properties":r(72),"transform-es2015-destructuring":r(73),"transform-es2015-duplicate-keys":r(130),"transform-es2015-for-of":r(74),"transform-es2015-function-name":r(75),"transform-es2015-instanceof":r(332),"transform-es2015-literals":r(76),"transform-es2015-modules-amd":r(131),"transform-es2015-modules-commonjs":r(77),"transform-es2015-modules-systemjs":r(208),"transform-es2015-modules-umd":r(209),"transform-es2015-object-super":r(78),"transform-es2015-parameters":r(79),"transform-es2015-shorthand-properties":r(80),"transform-es2015-spread":r(81),"transform-es2015-sticky-regex":r(82),"transform-es2015-template-literals":r(83),"transform-es2015-typeof-symbol":r(84),"transform-es2015-unicode-regex":r(85),"transform-es3-member-expression-literals":r(336),"transform-es3-property-literals":r(337),"transform-es5-property-mutators":r(338),"transform-eval":r(339),"transform-exponentiation-operator":r(132),"transform-export-extensions":r(210),"transform-flow-comments":r(340),"transform-flow-strip-types":r(211),"transform-function-bind":r(212),"transform-jscript":r(341),"transform-object-assign":r(342),"transform-object-rest-spread":r(213),"transform-object-set-prototype-of-to-assign":r(343),"transform-proto-to-assign":r(344),"transform-react-constant-elements":r(345),"transform-react-display-name":r(214),"transform-react-inline-elements":r(346),"transform-react-jsx":r(215),"transform-react-jsx-compat":r(347),"transform-react-jsx-self":r(349),"transform-react-jsx-source":r(350),"transform-regenerator":r(86),"transform-runtime":r(353),"transform-strict-mode":r(216),"undeclared-variables-check":r(354)}),c({es2015:r(217),es2016:r(218),es2017:r(219),latest:r(356),react:r(357),"stage-0":r(358),"stage-1":r(220),"stage-2":r(221),"stage-3":r(222),"es2015-no-commonjs":{plugins:[r(83),r(76),r(75),r(68),r(69),r(71),r(78),r(80),r(72),r(74),r(82),r(85),r(66),r(81),r(79),r(73),r(70),r(84),[r(86),{async:!1,asyncGenerators:!1}]]},"es2015-loose":{plugins:[[r(83),{loose:!0}],r(76),r(75),r(68),r(69),[r(71),{loose:!0}],r(78),r(80),r(130),[r(72),{loose:!0}],[r(74),{loose:!0}],r(82),r(85),r(66),[r(81),{loose:!0}],r(79),[r(73),{loose:!0}],r(70),r(84),[r(77),{loose:!0}],[r(86),{async:!1,asyncGenerators:!1}]]}});t.version="6.26.0";"undefined"!=typeof window&&window&&window.addEventListener&&window.addEventListener("DOMContentLoaded",function(){return f()},!1)},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){var t=z["is"+e];t||(t=z["is"+e]=function(t,r){return z.is(e,t,r)}),z["assert"+e]=function(r,n){if(n=n||{},!t(r,n))throw new Error("Expected type "+(0,I.default)(e)+" with option "+(0,I.default)(n))}}function s(e,t,r){return!!t&&(!!a(t.type,e)&&(void 0===r||z.shallowEqual(t,r)))}function a(e,t){if(e===t)return!0;if(z.ALIAS_KEYS[t])return!1;var r=z.FLIPPED_ALIAS_KEYS[t];if(r){if(r[0]===e)return!0;for(var n=r,i=Array.isArray(n),s=0,n=i?n:(0,T.default)(n);;){var a;if(i){if(s>=n.length)break;a=n[s++]}else{if(s=n.next(),s.done)break;a=s.value}if(e===a)return!0}}return!1}function o(e,t,r){if(e){var n=z.NODE_FIELDS[e.type];if(n){var i=n[t];i&&i.validate&&(i.optional&&null==r||i.validate(e,t,r))}}}function u(e,t){for(var r=(0,B.default)(t),n=r,i=Array.isArray(n),s=0,n=i?n:(0,T.default)(n);;){var a;if(i){if(s>=n.length)break;a=n[s++]}else{if(s=n.next(),s.done)break;a=s.value}var o=a;if(e[o]!==t[o])return!1}return!0}function l(e,t,r){return e.object=z.memberExpression(e.object,e.property,e.computed),e.property=t,e.computed=!!r,e}function c(e,t){return e.object=z.memberExpression(t,e.object),e}function f(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"body";return e[t]=z.toBlock(e[t],e)}function p(e){if(!e)return e;var t={};for(var r in e)"_"!==r[0]&&(t[r]=e[r]);return t}function d(e){var t=p(e);return delete t.loc,t}function h(e){if(!e)return e;var t={};for(var r in e)if("_"!==r[0]){var n=e[r];n&&(n.type?n=z.cloneDeep(n):Array.isArray(n)&&(n=n.map(z.cloneDeep))),t[r]=n}return t}function m(e,t){var r=e.split(".");return function(e){if(!z.isMemberExpression(e))return!1;for(var n=[e],i=0;n.length;){var s=n.shift();if(t&&i===r.length)return!0;if(z.isIdentifier(s)){if(r[i]!==s.name)return!1}else{if(!z.isStringLiteral(s)){if(z.isMemberExpression(s)){if(s.computed&&!z.isStringLiteral(s.property))return!1;n.push(s.object),n.push(s.property);continue}return!1}if(r[i]!==s.value)return!1}if(++i>r.length)return!1}return!0}}function y(e){for(var t=z.COMMENT_KEYS,r=Array.isArray(t),n=0,t=r?t:(0,T.default)(t);;){var i;if(r){if(n>=t.length)break;i=t[n++]}else{if(n=t.next(),n.done)break;i=n.value}delete e[i]}return e}function v(e,t){return g(e,t),b(e,t),E(e,t),e}function g(e,t){x("trailingComments",e,t)}function b(e,t){x("leadingComments",e,t)}function E(e,t){x("innerComments",e,t)}function x(e,t,r){t&&r&&(t[e]=(0,K.default)([].concat(t[e],r[e]).filter(Boolean)))}function A(e,t){if(!e||!t)return e;for(var r=z.INHERIT_KEYS.optional,n=Array.isArray(r),i=0,r=n?r:(0,T.default)(r);;){var s;if(n){if(i>=r.length)break;s=r[i++]}else{if(i=r.next(),i.done)break;s=i.value}var a=s;null==e[a]&&(e[a]=t[a])}for(var o in t)"_"===o[0]&&(e[o]=t[o]);for(var u=z.INHERIT_KEYS.force,l=Array.isArray(u),c=0,u=l?u:(0,T.default)(u);;){var f;if(l){if(c>=u.length)break;f=u[c++]}else{if(c=u.next(),c.done)break;f=c.value}var p=f;e[p]=t[p]}return z.inheritsComments(e,t),e}function S(e){if(!_(e))throw new TypeError("Not a valid node "+(e&&e.type))}function _(e){return!(!e||!H.VISITOR_KEYS[e.type])}function D(e,t,r){if(e){var n=z.VISITOR_KEYS[e.type];if(n){r=r||{},t(e,r);for(var i=n,s=Array.isArray(i),a=0,i=s?i:(0,T.default)(i);;){var o;if(s){if(a>=i.length)break;o=i[a++]}else{if(a=i.next(),a.done)break;o=a.value}var u=o,l=e[u];if(Array.isArray(l))for(var c=l,f=Array.isArray(c),p=0,c=f?c:(0,T.default)(c);;){var d;if(f){if(p>=c.length)break;d=c[p++]}else{if(p=c.next(),p.done)break;d=p.value}var h=d;D(h,t,r)}else D(l,t,r)}}}}function C(e,t){t=t||{};for(var r=t.preserveComments?Z:ee,n=r,i=Array.isArray(n),s=0,n=i?n:(0,T.default)(n);;){var a;if(i){if(s>=n.length)break;a=n[s++]}else{if(s=n.next(),s.done)break;a=s.value}var o=a;null!=e[o]&&(e[o]=void 0)}for(var u in e)"_"===u[0]&&null!=e[u]&&(e[u]=void 0);for(var l=(0,k.default)(e),c=l,f=Array.isArray(c),p=0,c=f?c:(0,T.default)(c);;){var d;if(f){if(p>=c.length)break;d=c[p++]}else{if(p=c.next(),p.done)break;d=p.value}e[d]=null}}function w(e,t){return D(e,C,t),e}t.__esModule=!0,t.createTypeAnnotationBasedOnTypeof=t.removeTypeDuplicates=t.createUnionTypeAnnotation=t.valueToNode=t.toBlock=t.toExpression=t.toStatement=t.toBindingIdentifierName=t.toIdentifier=t.toKeyAlias=t.toSequenceExpression=t.toComputedKey=t.isNodesEquivalent=t.isImmutable=t.isScope=t.isSpecifierDefault=t.isVar=t.isBlockScoped=t.isLet=t.isValidIdentifier=t.isReferenced=t.isBinding=t.getOuterBindingIdentifiers=t.getBindingIdentifiers=t.TYPES=t.react=t.DEPRECATED_KEYS=t.BUILDER_KEYS=t.NODE_FIELDS=t.ALIAS_KEYS=t.VISITOR_KEYS=t.NOT_LOCAL_BINDING=t.BLOCK_SCOPED_SYMBOL=t.INHERIT_KEYS=t.UNARY_OPERATORS=t.STRING_UNARY_OPERATORS=t.NUMBER_UNARY_OPERATORS=t.BOOLEAN_UNARY_OPERATORS=t.BINARY_OPERATORS=t.NUMBER_BINARY_OPERATORS=t.BOOLEAN_BINARY_OPERATORS=t.COMPARISON_BINARY_OPERATORS=t.EQUALITY_BINARY_OPERATORS=t.BOOLEAN_NUMBER_BINARY_OPERATORS=t.UPDATE_OPERATORS=t.LOGICAL_OPERATORS=t.COMMENT_KEYS=t.FOR_INIT_KEYS=t.FLATTENABLE_KEYS=t.STATEMENT_OR_BLOCK_KEYS=void 0;var P=r(360),k=n(P),F=r(2),T=n(F),O=r(14),B=n(O),R=r(35),I=n(R),M=r(135);Object.defineProperty(t,"STATEMENT_OR_BLOCK_KEYS",{enumerable:!0,get:function(){return M.STATEMENT_OR_BLOCK_KEYS}}),Object.defineProperty(t,"FLATTENABLE_KEYS",{enumerable:!0,get:function(){return M.FLATTENABLE_KEYS}}),Object.defineProperty(t,"FOR_INIT_KEYS",{enumerable:!0,get:function(){return M.FOR_INIT_KEYS}}),Object.defineProperty(t,"COMMENT_KEYS",{enumerable:!0,get:function(){return M.COMMENT_KEYS}}),Object.defineProperty(t,"LOGICAL_OPERATORS",{enumerable:!0,get:function(){return M.LOGICAL_OPERATORS}}),Object.defineProperty(t,"UPDATE_OPERATORS",{enumerable:!0,get:function(){return M.UPDATE_OPERATORS}}),Object.defineProperty(t,"BOOLEAN_NUMBER_BINARY_OPERATORS",{enumerable:!0,get:function(){return M.BOOLEAN_NUMBER_BINARY_OPERATORS}}),Object.defineProperty(t,"EQUALITY_BINARY_OPERATORS",{enumerable:!0,get:function(){return M.EQUALITY_BINARY_OPERATORS}}),Object.defineProperty(t,"COMPARISON_BINARY_OPERATORS",{enumerable:!0,get:function(){return M.COMPARISON_BINARY_OPERATORS}}),Object.defineProperty(t,"BOOLEAN_BINARY_OPERATORS",{enumerable:!0,get:function(){return M.BOOLEAN_BINARY_OPERATORS}}),Object.defineProperty(t,"NUMBER_BINARY_OPERATORS",{enumerable:!0,get:function(){return M.NUMBER_BINARY_OPERATORS}}),Object.defineProperty(t,"BINARY_OPERATORS",{enumerable:!0,get:function(){return M.BINARY_OPERATORS}}),Object.defineProperty(t,"BOOLEAN_UNARY_OPERATORS",{enumerable:!0,get:function(){return M.BOOLEAN_UNARY_OPERATORS}}),Object.defineProperty(t,"NUMBER_UNARY_OPERATORS",{enumerable:!0,get:function(){return M.NUMBER_UNARY_OPERATORS}}),Object.defineProperty(t,"STRING_UNARY_OPERATORS",{enumerable:!0,get:function(){return M.STRING_UNARY_OPERATORS}}),Object.defineProperty(t,"UNARY_OPERATORS",{enumerable:!0,get:function(){return M.UNARY_OPERATORS}}),Object.defineProperty(t,"INHERIT_KEYS",{enumerable:!0,get:function(){return M.INHERIT_KEYS}}),Object.defineProperty(t,"BLOCK_SCOPED_SYMBOL",{enumerable:!0,get:function(){return M.BLOCK_SCOPED_SYMBOL}}),Object.defineProperty(t,"NOT_LOCAL_BINDING",{enumerable:!0,get:function(){return M.NOT_LOCAL_BINDING}}),t.is=s,t.isType=a,t.validate=o,t.shallowEqual=u,t.appendToMemberExpression=l,t.prependToMemberExpression=c,t.ensureBlock=f,t.clone=p,t.cloneWithoutLoc=d,t.cloneDeep=h,t.buildMatchMemberExpression=m,t.removeComments=y,t.inheritsComments=v,t.inheritTrailingComments=g,t.inheritLeadingComments=b,t.inheritInnerComments=E,t.inherits=A,t.assertNode=S,t.isNode=_,t.traverseFast=D,t.removeProperties=C,t.removePropertiesDeep=w;var N=r(226);Object.defineProperty(t,"getBindingIdentifiers",{enumerable:!0,get:function(){return N.getBindingIdentifiers}}),Object.defineProperty(t,"getOuterBindingIdentifiers",{enumerable:!0,get:function(){return N.getOuterBindingIdentifiers}});var L=r(395);Object.defineProperty(t,"isBinding",{enumerable:!0,get:function(){return L.isBinding}}),Object.defineProperty(t,"isReferenced",{enumerable:!0,get:function(){return L.isReferenced}}),Object.defineProperty(t,"isValidIdentifier",{enumerable:!0,get:function(){return L.isValidIdentifier}}),Object.defineProperty(t,"isLet",{enumerable:!0,get:function(){return L.isLet}}),Object.defineProperty(t,"isBlockScoped",{enumerable:!0,get:function(){return L.isBlockScoped}}),Object.defineProperty(t,"isVar",{enumerable:!0,get:function(){return L.isVar}}),Object.defineProperty(t,"isSpecifierDefault",{enumerable:!0,get:function(){return L.isSpecifierDefault}}),Object.defineProperty(t,"isScope",{enumerable:!0,get:function(){return L.isScope}}),Object.defineProperty(t,"isImmutable",{enumerable:!0,get:function(){return L.isImmutable}}),Object.defineProperty(t,"isNodesEquivalent",{enumerable:!0,get:function(){return L.isNodesEquivalent}});var j=r(385);Object.defineProperty(t,"toComputedKey",{enumerable:!0,get:function(){return j.toComputedKey}}),Object.defineProperty(t,"toSequenceExpression",{enumerable:!0,get:function(){return j.toSequenceExpression}}),Object.defineProperty(t,"toKeyAlias",{enumerable:!0,get:function(){return j.toKeyAlias}}),Object.defineProperty(t,"toIdentifier",{enumerable:!0,get:function(){return j.toIdentifier}}),Object.defineProperty(t,"toBindingIdentifierName",{enumerable:!0,get:function(){return j.toBindingIdentifierName}}),Object.defineProperty(t,"toStatement",{enumerable:!0,get:function(){return j.toStatement}}),Object.defineProperty(t,"toExpression",{enumerable:!0,get:function(){return j.toExpression}}),Object.defineProperty(t,"toBlock",{enumerable:!0,get:function(){return j.toBlock}}),Object.defineProperty(t,"valueToNode",{enumerable:!0,get:function(){return j.valueToNode}});var U=r(393);Object.defineProperty(t,"createUnionTypeAnnotation",{enumerable:!0,get:function(){return U.createUnionTypeAnnotation}}),Object.defineProperty(t,"removeTypeDuplicates",{enumerable:!0,get:function(){return U.removeTypeDuplicates}}),Object.defineProperty(t,"createTypeAnnotationBasedOnTypeof",{enumerable:!0,get:function(){return U.createTypeAnnotationBasedOnTypeof}});var V=r(624),G=n(V),W=r(109),Y=n(W),q=r(600),K=n(q);r(390);var H=r(26),J=r(394),X=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(J),z=t;t.VISITOR_KEYS=H.VISITOR_KEYS,t.ALIAS_KEYS=H.ALIAS_KEYS,t.NODE_FIELDS=H.NODE_FIELDS,t.BUILDER_KEYS=H.BUILDER_KEYS,t.DEPRECATED_KEYS=H.DEPRECATED_KEYS,t.react=X;for(var $ in z.VISITOR_KEYS)i($);z.FLIPPED_ALIAS_KEYS={},(0,B.default)(z.ALIAS_KEYS).forEach(function(e){z.ALIAS_KEYS[e].forEach(function(t){(z.FLIPPED_ALIAS_KEYS[t]=z.FLIPPED_ALIAS_KEYS[t]||[]).push(e)})}),(0,B.default)(z.FLIPPED_ALIAS_KEYS).forEach(function(e){z[e.toUpperCase()+"_TYPES"]=z.FLIPPED_ALIAS_KEYS[e],i(e)});t.TYPES=(0,B.default)(z.VISITOR_KEYS).concat((0,B.default)(z.FLIPPED_ALIAS_KEYS)).concat((0,B.default)(z.DEPRECATED_KEYS));(0,B.default)(z.BUILDER_KEYS).forEach(function(e){function t(){if(arguments.length>r.length)throw new Error("t."+e+": Too many arguments passed. Received "+arguments.length+" but can receive no more than "+r.length);var t={};t.type=e;for(var n=0,i=r,s=Array.isArray(i),a=0,i=s?i:(0,T.default)(i);;){var u;if(s){if(a>=i.length)break;u=i[a++]}else{if(a=i.next(),a.done)break;u=a.value}var l=u,c=z.NODE_FIELDS[e][l],f=arguments[n++];void 0===f&&(f=(0,Y.default)(c.default)),t[l]=f}for(var p in t)o(t,p,t[p]);return t}var r=z.BUILDER_KEYS[e];z[e]=t,z[e[0].toLowerCase()+e.slice(1)]=t});for(var Q in z.DEPRECATED_KEYS)!function(e){function t(t){return function(){return console.trace("The node type "+e+" has been renamed to "+r),t.apply(this,arguments)}}var r=z.DEPRECATED_KEYS[e];z[e]=z[e[0].toLowerCase()+e.slice(1)]=t(z[r]),z["is"+e]=t(z["is"+r]),z["assert"+e]=t(z["assert"+r])}(Q);(0,G.default)(z),(0,G.default)(z.VISITOR_KEYS);var Z=["tokens","start","end","loc","raw","rawValue"],ee=z.COMMENT_KEYS.concat(["comments"]).concat(Z)},function(e,t,r){"use strict";e.exports={default:r(404),__esModule:!0}},function(e,t){"use strict";t.__esModule=!0,t.default=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}function s(e,t){e=(0,l.default)(e);var r=e,n=r.program;return t.length&&(0,m.default)(e,A,null,t),n.body.length>1?n.body:n.body[0]}t.__esModule=!0;var a=r(10),o=i(a);t.default=function(e,t){var r=void 0;try{throw new Error}catch(e){e.stack&&(r=e.stack.split("\n").slice(1).join("\n"))}t=(0,f.default)({allowReturnOutsideFunction:!0,allowSuperOutsideMethod:!0,preserveComments:!1},t);var n=function(){var i=void 0;try{i=v.parse(e,t),i=m.default.removeProperties(i,{preserveComments:t.preserveComments}),m.default.cheap(i,function(e){e[E]=!0})}catch(e){throw e.stack=e.stack+"from\n"+r,e}return n=function(){return i},i};return function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return s(n(),t)}};var u=r(574),l=i(u),c=r(174),f=i(c),p=r(274),d=i(p),h=r(7),m=i(h),y=r(89),v=n(y),g=r(1),b=n(g),E="_fromTemplate",x=(0,o.default)(),A={noScope:!0,enter:function(e,t){var r=e.node;if(r[x])return e.skip();b.isExpressionStatement(r)&&(r=r.expression);var n=void 0;if(b.isIdentifier(r)&&r[E])if((0,d.default)(t[0],r.name))n=t[0][r.name];else if("$"===r.name[0]){var i=+r.name.slice(1);t[i]&&(n=t[i])}null===n&&e.remove(),n&&(n[x]=!0,e.replaceInline(n))},exit:function(e){var t=e.node;t.loc||m.default.clearNode(t)}};e.exports=t.default},function(e,t){"use strict";var r=e.exports={version:"2.5.0"};"number"==typeof __e&&(__e=r)},function(e,t){"use strict";var r=Array.isArray;e.exports=r},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}function s(e,t,r,n,i){if(e){if(t||(t={}),!t.noScope&&!r&&"Program"!==e.type&&"File"!==e.type)throw new Error(v.get("traverseNeedsParent",e.type));m.explode(t),s.node(e,t,r,n,i)}}function a(e,t){e.node.type===t.type&&(t.has=!0,e.stop())}t.__esModule=!0,t.visitors=t.Hub=t.Scope=t.NodePath=void 0;var o=r(2),u=i(o),l=r(36);Object.defineProperty(t,"NodePath",{enumerable:!0,get:function(){return i(l).default}});var c=r(134);Object.defineProperty(t,"Scope",{enumerable:!0,get:function(){return i(c).default}});var f=r(223);Object.defineProperty(t,"Hub",{enumerable:!0,get:function(){return i(f).default}}),t.default=s;var p=r(367),d=i(p),h=r(384),m=n(h),y=r(20),v=n(y),g=r(111),b=i(g),E=r(1),x=n(E),A=r(88),S=n(A);t.visitors=m,s.visitors=m,s.verify=m.verify,s.explode=m.explode,s.NodePath=r(36),s.Scope=r(134),s.Hub=r(223),s.cheap=function(e,t){return x.traverseFast(e,t)},s.node=function(e,t,r,n,i,s){var a=x.VISITOR_KEYS[e.type];if(a)for(var o=new d.default(r,t,n,i),l=a,c=Array.isArray(l),f=0,l=c?l:(0,u.default)(l);;){var p;if(c){if(f>=l.length)break;p=l[f++]}else{if(f=l.next(),f.done)break;p=f.value}var h=p;if((!s||!s[h])&&o.visit(e,h))return}},s.clearNode=function(e,t){x.removeProperties(e,t),S.path.delete(e)},s.removeProperties=function(e,t){return x.traverseFast(e,s.clearNode,t),e},s.hasType=function(e,t,r,n){if((0,b.default)(n,e.type))return!1;if(e.type===r)return!0;var i={has:!1,type:r};return s(e,{blacklist:n,enter:a},t,i),i.has},s.clearCache=function(){S.clear()},s.clearCache.clearPath=S.clearPath,s.clearCache.clearScope=S.clearScope,s.copyCache=function(e,t){S.path.has(e)&&S.path.set(t,S.path.get(e))}},function(e,t){"use strict";function r(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function i(e){if(c===setTimeout)return setTimeout(e,0);if((c===r||!c)&&setTimeout)return c=setTimeout,setTimeout(e,0);try{return c(e,0)}catch(t){try{return c.call(null,e,0)}catch(t){return c.call(this,e,0)}}}function s(e){if(f===clearTimeout)return clearTimeout(e);if((f===n||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(e);try{return f(e)}catch(t){try{return f.call(null,e)}catch(t){return f.call(this,e)}}}function a(){m&&d&&(m=!1,d.length?h=d.concat(h):y=-1,h.length&&o())}function o(){if(!m){var e=i(a);m=!0;for(var t=h.length;t;){for(d=h,h=[];++y<t;)d&&d[y].run();y=-1,t=h.length}d=null,m=!1,s(e)}}function u(e,t){this.fun=e,this.array=t}function l(){}var c,f,p=e.exports={};!function(){try{c="function"==typeof setTimeout?setTimeout:r}catch(e){c=r}try{f="function"==typeof clearTimeout?clearTimeout:n}catch(e){f=n}}();var d,h=[],m=!1,y=-1;p.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];h.push(new u(e,t)),1!==h.length||m||i(o)},u.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=l,p.addListener=l,p.once=l,p.off=l,p.removeListener=l,p.removeAllListeners=l,p.emit=l,p.prependListener=l,p.prependOnceListener=l,p.listeners=function(e){return[]},p.binding=function(e){throw new Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(e){throw new Error("process.chdir is not supported")},p.umask=function(){return 0}},function(e,t,r){"use strict";e.exports={default:r(409),__esModule:!0}},function(e,t,r){"use strict";e.exports={default:r(414),__esModule:!0}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.__esModule=!0;var s=r(363),a=n(s),o=r(10),u=n(o),l="function"==typeof u.default&&"symbol"===i(a.default)?function(e){return void 0===e?"undefined":i(e)}:function(e){return e&&"function"==typeof u.default&&e.constructor===u.default&&e!==u.default.prototype?"symbol":void 0===e?"undefined":i(e)};t.default="function"==typeof u.default&&"symbol"===l(a.default)?function(e){return void 0===e?"undefined":l(e)}:function(e){return e&&"function"==typeof u.default&&e.constructor===u.default&&e!==u.default.prototype?"symbol":void 0===e?"undefined":l(e)}},function(e,t,r){"use strict";var n=r(15),i=r(5),s=r(43),a=r(29),o=function e(t,r,o){var u,l,c,f=t&e.F,p=t&e.G,d=t&e.S,h=t&e.P,m=t&e.B,y=t&e.W,v=p?i:i[r]||(i[r]={}),g=v.prototype,b=p?n:d?n[r]:(n[r]||{}).prototype;p&&(o=r);for(u in o)(l=!f&&b&&void 0!==b[u])&&u in v||(c=l?b[u]:o[u],v[u]=p&&"function"!=typeof b[u]?o[u]:m&&l?s(c,n):y&&b[u]==c?function(e){var t=function(t,r,n){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,r)}return new e(t,r,n)}return e.apply(this,arguments)};return t.prototype=e.prototype,t}(c):h&&"function"==typeof c?s(Function.call,c):c,h&&((v.virtual||(v.virtual={}))[u]=c,t&e.R&&g&&!g[u]&&a(g,u,c)))};o.F=1,o.G=2,o.S=4,o.P=8,o.B=16,o.W=32,o.U=64,o.R=128,e.exports=o},function(e,t,r){"use strict";var n=r(151)("wks"),i=r(95),s=r(15).Symbol,a="function"==typeof s;(e.exports=function(e){return n[e]||(n[e]=a&&s[e]||(a?s:i)("Symbol."+e))}).store=n},function(e,t,r){"use strict";e.exports={default:r(411),__esModule:!0}},function(e,t){"use strict";var r=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(e,t){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.exports=function(e){return"object"===(void 0===e?"undefined":r(e))?null!==e:"function"==typeof e}},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=r(261),s="object"==("undefined"==typeof self?"undefined":n(self))&&self&&self.Object===Object&&self,a=i||s||Function("return this")();e.exports=a},function(e,t){"use strict";function r(e){var t=void 0===e?"undefined":n(e);return null!=e&&("object"==t||"function"==t)}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.exports=r},function(e,t,r){(function(e){"use strict";function r(e,t){for(var r=0,n=e.length-1;n>=0;n--){var i=e[n];"."===i?e.splice(n,1):".."===i?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}function n(e,t){if(e.filter)return e.filter(t);for(var r=[],n=0;n<e.length;n++)t(e[n],n,e)&&r.push(e[n]);return r}var i=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,s=function(e){return i.exec(e).slice(1)};t.resolve=function(){for(var t="",i=!1,s=arguments.length-1;s>=-1&&!i;s--){var a=s>=0?arguments[s]:e.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(t=a+"/"+t,i="/"===a.charAt(0))}return t=r(n(t.split("/"),function(e){return!!e}),!i).join("/"),(i?"/":"")+t||"."},t.normalize=function(e){var i=t.isAbsolute(e),s="/"===a(e,-1);return e=r(n(e.split("/"),function(e){return!!e}),!i).join("/"),e||i||(e="."),e&&s&&(e+="/"),(i?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(n(e,function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},t.relative=function(e,r){function n(e){for(var t=0;t<e.length&&""===e[t];t++);for(var r=e.length-1;r>=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=t.resolve(e).substr(1),r=t.resolve(r).substr(1);for(var i=n(e.split("/")),s=n(r.split("/")),a=Math.min(i.length,s.length),o=a,u=0;u<a;u++)if(i[u]!==s[u]){o=u;break}for(var l=[],u=o;u<i.length;u++)l.push("..");return l=l.concat(s.slice(o)),l.join("/")},t.sep="/",t.delimiter=":",t.dirname=function(e){var t=s(e),r=t[0],n=t[1];return r||n?(n&&(n=n.substr(0,n.length-1)),r+n):"."},t.basename=function(e,t){var r=s(e)[2];return t&&r.substr(-1*t.length)===t&&(r=r.substr(0,r.length-t.length)),r},t.extname=function(e){return s(e)[3]};var a="b"==="ab".substr(-1)?function(e,t,r){return e.substr(t,r)}:function(e,t,r){return t<0&&(t=e.length+t),e.substr(t,r)}}).call(t,r(8))},function(e,t,r){"use strict";function n(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var s=l[e];if(!s)throw new ReferenceError("Unknown message "+(0,a.default)(e));return r=i(r),s.replace(/\$(\d+)/g,function(e,t){return r[t-1]})}function i(e){return e.map(function(e){if(null!=e&&e.inspect)return e.inspect();try{return(0,a.default)(e)||e+""}catch(t){return u.inspect(e)}})}t.__esModule=!0,t.MESSAGES=void 0;var s=r(35),a=function(e){return e&&e.__esModule?e:{default:e}}(s);t.get=n,t.parseArgs=i;var o=r(117),u=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(o),l=t.MESSAGES={tailCallReassignmentDeopt:"Function reference has been reassigned, so it will probably be dereferenced, therefore we can't optimise this with confidence",classesIllegalBareSuper:"Illegal use of bare super",classesIllegalSuperCall:"Direct super call is illegal in non-constructor, use super.$1() instead",scopeDuplicateDeclaration:"Duplicate declaration $1",settersNoRest:"Setters aren't allowed to have a rest",noAssignmentsInForHead:"No assignments allowed in for-in/of head",expectedMemberExpressionOrIdentifier:"Expected type MemberExpression or Identifier",invalidParentForThisNode:"We don't know how to handle this node within the current parent - please open an issue",readOnly:"$1 is read-only",unknownForHead:"Unknown node type $1 in ForStatement",didYouMean:"Did you mean $1?",codeGeneratorDeopt:"Note: The code generator has deoptimised the styling of $1 as it exceeds the max of $2.",missingTemplatesDirectory:"no templates directory - this is most likely the result of a broken `npm publish`. Please report to https://github.com/babel/babel/issues",unsupportedOutputType:"Unsupported output type $1",illegalMethodName:"Illegal method name $1",lostTrackNodePath:"We lost track of this node's position, likely because the AST was directly manipulated",modulesIllegalExportName:"Illegal export $1",modulesDuplicateDeclarations:"Duplicate module declarations with the same source but in different scopes",undeclaredVariable:"Reference to undeclared variable $1",undeclaredVariableType:"Referencing a type alias outside of a type annotation",undeclaredVariableSuggestion:"Reference to undeclared variable $1 - did you mean $2?",traverseNeedsParent:"You must pass a scope and parentPath unless traversing a Program/File. Instead of that you tried to traverse a $1 node without passing scope and parentPath.",traverseVerifyRootFunction:"You passed `traverse()` a function when it expected a visitor object, are you sure you didn't mean `{ enter: Function }`?",traverseVerifyVisitorProperty:"You passed `traverse()` a visitor object with the property $1 that has the invalid property $2",traverseVerifyNodeType:"You gave us a visitor for the node type $1 but it's not a valid type",pluginNotObject:"Plugin $2 specified in $1 was expected to return an object when invoked but returned $3",pluginNotFunction:"Plugin $2 specified in $1 was expected to return a function but returned $3", +pluginUnknown:"Unknown plugin $1 specified in $2 at $3, attempted to resolve relative to $4",pluginInvalidProperty:"Plugin $2 specified in $1 provided an invalid property of $3"}},function(e,t,r){"use strict";var n=r(16);e.exports=function(e){if(!n(e))throw TypeError(e+" is not an object!");return e}},function(e,t,r){"use strict";e.exports=!r(27)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(e,t,r){"use strict";var n=r(21),i=r(231),s=r(154),a=Object.defineProperty;t.f=r(22)?Object.defineProperty:function(e,t,r){if(n(e),t=s(t,!0),n(r),i)try{return a(e,t,r)}catch(e){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(e[t]=r.value),e}},function(e,t,r){"use strict";function n(e){return null!=e&&s(e.length)&&!i(e)}var i=r(175),s=r(176);e.exports=n},function(e,t){"use strict";function r(e){return null!=e&&"object"==(void 0===e?"undefined":n(e))}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.exports=r},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){return Array.isArray(e)?"array":null===e?"null":void 0===e?"undefined":void 0===e?"undefined":(0,v.default)(e)}function s(e){function t(t,r,n){if(Array.isArray(n))for(var i=0;i<n.length;i++)e(t,r+"["+i+"]",n[i])}return t.each=e,t}function a(){function e(e,t,n){if(r.indexOf(n)<0)throw new TypeError("Property "+t+" expected value to be one of "+(0,m.default)(r)+" but got "+(0,m.default)(n))}for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return e.oneOf=r,e}function o(){function e(e,t,n){for(var i=!1,s=r,a=Array.isArray(s),o=0,s=a?s:(0,d.default)(s);;){var u;if(a){if(o>=s.length)break;u=s[o++]}else{if(o=s.next(),o.done)break;u=o.value}var l=u;if(b.is(l,n)){i=!0;break}}if(!i)throw new TypeError("Property "+t+" of "+e.type+" expected node to be of a type "+(0,m.default)(r)+" but instead got "+(0,m.default)(n&&n.type))}for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return e.oneOfNodeTypes=r,e}function u(){function e(e,t,n){for(var s=!1,a=r,o=Array.isArray(a),u=0,a=o?a:(0,d.default)(a);;){var l;if(o){if(u>=a.length)break;l=a[u++]}else{if(u=a.next(),u.done)break;l=u.value}var c=l;if(i(n)===c||b.is(c,n)){s=!0;break}}if(!s)throw new TypeError("Property "+t+" of "+e.type+" expected node to be of a type "+(0,m.default)(r)+" but instead got "+(0,m.default)(n&&n.type))}for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return e.oneOfNodeOrValueTypes=r,e}function l(e){function t(t,r,n){if(i(n)!==e)throw new TypeError("Property "+r+" expected type of "+e+" but got "+i(n))}return t.type=e,t}function c(){function e(){for(var e=r,t=Array.isArray(e),n=0,e=t?e:(0,d.default)(e);;){var i;if(t){if(n>=e.length)break;i=e[n++]}else{if(n=e.next(),n.done)break;i=n.value}i.apply(void 0,arguments)}}for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return e.chainOf=r,e}function f(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.inherits&&D[t.inherits]||{};t.fields=t.fields||r.fields||{},t.visitor=t.visitor||r.visitor||[],t.aliases=t.aliases||r.aliases||[],t.builder=t.builder||r.builder||t.visitor||[],t.deprecatedAlias&&(_[t.deprecatedAlias]=e);for(var n=t.visitor.concat(t.builder),s=Array.isArray(n),a=0,n=s?n:(0,d.default)(n);;){var o;if(s){if(a>=n.length)break;o=n[a++]}else{if(a=n.next(),a.done)break;o=a.value}var u=o;t.fields[u]=t.fields[u]||{}}for(var c in t.fields){var f=t.fields[c];-1===t.builder.indexOf(c)&&(f.optional=!0),void 0===f.default?f.default=null:f.validate||(f.validate=l(i(f.default)))}E[e]=t.visitor,S[e]=t.builder,A[e]=t.fields,x[e]=t.aliases,D[e]=t}t.__esModule=!0,t.DEPRECATED_KEYS=t.BUILDER_KEYS=t.NODE_FIELDS=t.ALIAS_KEYS=t.VISITOR_KEYS=void 0;var p=r(2),d=n(p),h=r(35),m=n(h),y=r(11),v=n(y);t.assertEach=s,t.assertOneOf=a,t.assertNodeType=o,t.assertNodeOrValueType=u,t.assertValueType=l,t.chain=c,t.default=f;var g=r(1),b=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(g),E=t.VISITOR_KEYS={},x=t.ALIAS_KEYS={},A=t.NODE_FIELDS={},S=t.BUILDER_KEYS={},_=t.DEPRECATED_KEYS={},D={}},function(e,t){"use strict";e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,t){"use strict";var r={}.hasOwnProperty;e.exports=function(e,t){return r.call(e,t)}},function(e,t,r){"use strict";var n=r(23),i=r(92);e.exports=r(22)?function(e,t,r){return n.f(e,t,i(1,r))}:function(e,t,r){return e[t]=r,e}},function(e,t,r){"use strict";function n(e){return null==e?void 0===e?u:o:l&&l in Object(e)?s(e):a(e)}var i=r(45),s=r(534),a=r(559),o="[object Null]",u="[object Undefined]",l=i?i.toStringTag:void 0;e.exports=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=!r;r||(r={});for(var o=-1,u=t.length;++o<u;){var l=t[o],c=n?n(r[l],e[l],l,r,e):void 0;void 0===c&&(c=e[l]),a?s(r,l,c):i(r,l,c)}return r}var i=r(162),s=r(163);e.exports=n},function(e,t,r){"use strict";function n(e){return a(e)?i(e):s(e)}var i=r(245),s=r(500),a=r(24);e.exports=n},function(e,t){"use strict";e.exports={filename:{type:"filename",description:"filename to use when reading from stdin - this will be used in source-maps, errors etc",default:"unknown",shorthand:"f"},filenameRelative:{hidden:!0,type:"string"},inputSourceMap:{hidden:!0},env:{hidden:!0,default:{}},mode:{description:"",hidden:!0},retainLines:{type:"boolean",default:!1,description:"retain line numbers - will result in really ugly code"},highlightCode:{description:"enable/disable ANSI syntax highlighting of code frames (on by default)",type:"boolean",default:!0},suppressDeprecationMessages:{type:"boolean",default:!1,hidden:!0},presets:{type:"list",description:"",default:[]},plugins:{type:"list",default:[],description:""},ignore:{type:"list",description:"list of glob paths to **not** compile",default:[]},only:{type:"list",description:"list of glob paths to **only** compile"},code:{hidden:!0,default:!0,type:"boolean"},metadata:{hidden:!0,default:!0,type:"boolean"},ast:{hidden:!0,default:!0,type:"boolean"},extends:{type:"string",hidden:!0},comments:{type:"boolean",default:!0,description:"write comments to generated output (true by default)"},shouldPrintComment:{hidden:!0,description:"optional callback to control whether a comment should be inserted, when this is used the comments option is ignored"},wrapPluginVisitorMethod:{hidden:!0,description:"optional callback to wrap all visitor methods"},compact:{type:"booleanString",default:"auto",description:"do not include superfluous whitespace characters and line terminators [true|false|auto]"},minified:{type:"boolean",default:!1,description:"save as much bytes when printing [true|false]"},sourceMap:{alias:"sourceMaps",hidden:!0},sourceMaps:{type:"booleanString",description:"[true|false|inline]",default:!1,shorthand:"s"},sourceMapTarget:{type:"string",description:"set `file` on returned source map"},sourceFileName:{type:"string",description:"set `sources[0]` on returned source map"},sourceRoot:{type:"filename",description:"the root from which all sources are relative"},babelrc:{description:"Whether or not to look up .babelrc and .babelignore files",type:"boolean",default:!0},sourceType:{description:"",default:"module"},auxiliaryCommentBefore:{type:"string",description:"print a comment before any injected non-user code"},auxiliaryCommentAfter:{type:"string",description:"print a comment after any injected non-user code"},resolveModuleSource:{hidden:!0},getModuleId:{hidden:!0},moduleRoot:{type:"filename",description:"optional prefix for the AMD module formatter that will be prepend to the filename on module definitions"},moduleIds:{type:"boolean",default:!1,shorthand:"M",description:"insert an explicit id for modules"},moduleId:{description:"specify a custom name for module ids",type:"string"},passPerPreset:{description:"Whether to spawn a traversal pass per a preset. By default all presets are merged.",type:"boolean",default:!1,hidden:!0},parserOpts:{description:"Options to pass into the parser, or to change parsers (parserOpts.parser)",default:!1},generatorOpts:{description:"Options to pass into the generator, or to change generators (generatorOpts.generator)",default:!1}}},function(e,t,r){(function(n){"use strict";function i(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function s(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var a=r(366),o=s(a),u=r(35),l=s(u),c=r(87),f=s(c),p=r(2),d=s(p),h=r(11),m=s(h),y=r(3),v=s(y),g=r(182),b=i(g),E=r(65),x=s(E),A=r(20),S=i(A),_=r(52),D=r(184),C=s(D),w=r(185),P=s(w),k=r(575),F=s(k),T=r(109),O=s(T),B=r(293),R=s(B),I=r(33),M=s(I),N=r(54),L=s(N),j=r(51),U=s(j),V=r(19),G=s(V),W=function(){function e(t){(0,v.default)(this,e),this.resolvedConfigs=[],this.options=e.createBareOptions(),this.log=t}return e.memoisePluginContainer=function(t,r,n,i){for(var s=e.memoisedPlugins,a=Array.isArray(s),o=0,s=a?s:(0,d.default)(s);;){var u;if(a){if(o>=s.length)break;u=s[o++]}else{if(o=s.next(),o.done)break;u=o.value}var l=u;if(l.container===t)return l.plugin}var c=void 0;if(c="function"==typeof t?t(b):t,"object"===(void 0===c?"undefined":(0,m.default)(c))){var f=new x.default(c,i);return e.memoisedPlugins.push({container:t,plugin:f}),f}throw new TypeError(S.get("pluginNotObject",r,n,void 0===c?"undefined":(0,m.default)(c))+r+n)},e.createBareOptions=function(){var e={};for(var t in M.default){var r=M.default[t];e[t]=(0,O.default)(r.default)}return e},e.normalisePlugin=function(t,r,n,i){if(!((t=t.__esModule?t.default:t)instanceof x.default)){if("function"!=typeof t&&"object"!==(void 0===t?"undefined":(0,m.default)(t)))throw new TypeError(S.get("pluginNotFunction",r,n,void 0===t?"undefined":(0,m.default)(t)));t=e.memoisePluginContainer(t,r,n,i)}return t.init(r,n),t},e.normalisePlugins=function(t,n,i){return i.map(function(i,s){var a=void 0,o=void 0;if(!i)throw new TypeError("Falsy value found in plugins");Array.isArray(i)?(a=i[0],o=i[1]):a=i;var u="string"==typeof a?a:t+"$"+s;if("string"==typeof a){var l=(0,C.default)(a,n);if(!l)throw new ReferenceError(S.get("pluginUnknown",a,t,s,n));a=r(179)(l)}return a=e.normalisePlugin(a,t,s,u),[a,o]})},e.prototype.mergeOptions=function(t){var r=this,i=t.options,s=t.extending,a=t.alias,o=t.loc,u=t.dirname;if(a=a||"foreign",i){("object"!==(void 0===i?"undefined":(0,m.default)(i))||Array.isArray(i))&&this.log.error("Invalid options type for "+a,TypeError);var l=(0,F.default)(i,function(e){if(e instanceof x.default)return e});u=u||n.cwd(),o=o||a;for(var c in l){if(!M.default[c]&&this.log)if(L.default[c])this.log.error("Using removed Babel 5 option: "+a+"."+c+" - "+L.default[c].message,ReferenceError);else{var p="Unknown option: "+a+"."+c+". Check out http://babeljs.io/docs/usage/options/ for more information about options.";this.log.error(p+"\n\nA common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:\n\nInvalid:\n `{ presets: [{option: value}] }`\nValid:\n `{ presets: [['presetName', {option: value}]] }`\n\nFor more detailed information on preset configuration, please see http://babeljs.io/docs/plugins/#pluginpresets-options.",ReferenceError)}}(0,_.normaliseOptions)(l),l.plugins&&(l.plugins=e.normalisePlugins(o,u,l.plugins)),l.presets&&(l.passPerPreset?l.presets=this.resolvePresets(l.presets,u,function(e,t){r.mergeOptions({options:e,extending:e,alias:t,loc:t,dirname:u})}):(this.mergePresets(l.presets,u),delete l.presets)),i===s?(0,f.default)(s,l):(0,R.default)(s||this.options,l)}},e.prototype.mergePresets=function(e,t){var r=this;this.resolvePresets(e,t,function(e,t){r.mergeOptions({options:e,alias:t,loc:t,dirname:G.default.dirname(t||"")})})},e.prototype.resolvePresets=function(e,t,n){return e.map(function(e){var i=void 0;if(Array.isArray(e)){if(e.length>2)throw new Error("Unexpected extra options "+(0,l.default)(e.slice(2))+" passed to preset.");var s=e;e=s[0],i=s[1]}var a=void 0;try{if("string"==typeof e){if(!(a=(0,P.default)(e,t)))throw new Error("Couldn't find preset "+(0,l.default)(e)+" relative to directory "+(0,l.default)(t));e=r(179)(a)}if("object"===(void 0===e?"undefined":(0,m.default)(e))&&e.__esModule)if(e.default)e=e.default;else{var u=e,c=(u.__esModule,(0,o.default)(u,["__esModule"]));e=c}if("object"===(void 0===e?"undefined":(0,m.default)(e))&&e.buildPreset&&(e=e.buildPreset),"function"!=typeof e&&void 0!==i)throw new Error("Options "+(0,l.default)(i)+" passed to "+(a||"a preset")+" which does not accept options.");if("function"==typeof e&&(e=e(b,i,{dirname:t})),"object"!==(void 0===e?"undefined":(0,m.default)(e)))throw new Error("Unsupported preset format: "+e+".");n&&n(e,a)}catch(e){throw a&&(e.message+=" (While processing preset: "+(0,l.default)(a)+")"),e}return e})},e.prototype.normaliseOptions=function(){var e=this.options;for(var t in M.default){var r=M.default[t],n=e[t];!n&&r.optional||(r.alias?e[r.alias]=e[r.alias]||n:e[t]=n)}},e.prototype.init=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=(0,U.default)(e,this.log),r=Array.isArray(t),n=0,t=r?t:(0,d.default)(t);;){var i;if(r){if(n>=t.length)break;i=t[n++]}else{if(n=t.next(),n.done)break;i=n.value}var s=i;this.mergeOptions(s)}return this.normaliseOptions(e),this.options},e}();t.default=W,W.memoisedPlugins=[],e.exports=t.default}).call(t,r(8))},function(e,t,r){"use strict";e.exports={default:r(405),__esModule:!0}},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var s=r(2),a=i(s),o=r(3),u=i(o),l=r(224),c=n(l),f=r(239),p=i(f),d=r(466),h=i(d),m=r(7),y=i(m),v=r(174),g=i(v),b=r(134),E=i(b),x=r(1),A=n(x),S=r(88),_=(0,p.default)("babel"),D=function(){function e(t,r){(0,u.default)(this,e),this.parent=r,this.hub=t,this.contexts=[],this.data={},this.shouldSkip=!1,this.shouldStop=!1,this.removed=!1,this.state=null,this.opts=null,this.skipKeys=null,this.parentPath=null,this.context=null,this.container=null,this.listKey=null,this.inList=!1,this.parentKey=null,this.key=null,this.node=null,this.scope=null,this.type=null,this.typeAnnotation=null}return e.get=function(t){var r=t.hub,n=t.parentPath,i=t.parent,s=t.container,a=t.listKey,o=t.key;!r&&n&&(r=n.hub),(0,h.default)(i,"To get a node path the parent needs to exist");var u=s[o],l=S.path.get(i)||[];S.path.has(i)||S.path.set(i,l);for(var c=void 0,f=0;f<l.length;f++){var p=l[f];if(p.node===u){c=p;break}}return c||(c=new e(r,i),l.push(c)),c.setup(n,s,a,o),c},e.prototype.getScope=function(e){var t=e;return this.isScope()&&(t=new E.default(this,e)),t},e.prototype.setData=function(e,t){return this.data[e]=t},e.prototype.getData=function(e,t){var r=this.data[e];return!r&&t&&(r=this.data[e]=t),r},e.prototype.buildCodeFrameError=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:SyntaxError;return this.hub.file.buildCodeFrameError(this.node,e,t)},e.prototype.traverse=function(e,t){(0,y.default)(this.node,e,this.scope,t,this)},e.prototype.mark=function(e,t){this.hub.file.metadata.marked.push({type:e,message:t,loc:this.node.loc})},e.prototype.set=function(e,t){A.validate(this.node,e,t),this.node[e]=t},e.prototype.getPathLocation=function(){var e=[],t=this;do{var r=t.key;t.inList&&(r=t.listKey+"["+r+"]"),e.unshift(r)}while(t=t.parentPath);return e.join(".")},e.prototype.debug=function(e){_.enabled&&_(this.getPathLocation()+" "+this.type+": "+e())},e}();t.default=D,(0,g.default)(D.prototype,r(368)),(0,g.default)(D.prototype,r(374)),(0,g.default)(D.prototype,r(382)),(0,g.default)(D.prototype,r(372)),(0,g.default)(D.prototype,r(371)),(0,g.default)(D.prototype,r(377)),(0,g.default)(D.prototype,r(370)),(0,g.default)(D.prototype,r(381)),(0,g.default)(D.prototype,r(380)),(0,g.default)(D.prototype,r(373)),(0,g.default)(D.prototype,r(369));for(var C=A.TYPES,w=Array.isArray(C),P=0,C=w?C:(0,a.default)(C);;){var k;if("break"===function(){if(w){if(P>=C.length)return"break";k=C[P++]}else{if(P=C.next(),P.done)return"break";k=P.value}var e=k,t="is"+e;D.prototype[t]=function(e){return A[t](this.node,e)},D.prototype["assert"+e]=function(r){if(!this[t](r))throw new TypeError("Expected node path of type "+e)}}())break}for(var F in c){(function(e){if("_"===e[0])return"continue";A.TYPES.indexOf(e)<0&&A.TYPES.push(e);var t=c[e];D.prototype["is"+e]=function(e){return t.checkPath(this,e)}})(F)}e.exports=t.default},function(e,t,r){"use strict";var n=r(142),i=r(140);e.exports=function(e){return n(i(e))}},function(e,t,r){"use strict";function n(e,t){var r=s(e,t);return i(r)?r:void 0}var i=r(497),s=r(535);e.exports=n},function(e,t){"use strict";e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t,r,n){if(e.selfReference){if(!n.hasBinding(r.name)||n.hasGlobal(r.name)){if(!f.isFunction(t))return;var i=p;t.generator&&(i=d);var s=i({FUNCTION:t,FUNCTION_ID:r,FUNCTION_KEY:n.generateUidIdentifier(r.name)}).expression;s.callee._skipModulesRemap=!0;for(var a=s.callee.body.body[0].params,u=0,l=(0,o.default)(t);u<l;u++)a.push(n.generateUidIdentifier("x"));return s}n.rename(r.name)}t.id=r,n.getProgramParent().references[r.name]=!0}function s(e,t,r){var n={selfAssignment:!1,selfReference:!1,outerDeclar:r.getBindingIdentifier(t),references:[],name:t},i=r.getOwnBinding(t);return i?"param"===i.kind&&(n.selfReference=!0):(n.outerDeclar||r.hasGlobal(t))&&r.traverse(e,h,n),n}t.__esModule=!0,t.default=function(e){var t=e.node,r=e.parent,n=e.scope,a=e.id;if(!t.id){if(!f.isObjectProperty(r)&&!f.isObjectMethod(r,{kind:"method"})||r.computed&&!f.isLiteral(r.key)){if(f.isVariableDeclarator(r)){if(a=r.id,f.isIdentifier(a)){var o=n.parent.getBinding(a.name);if(o&&o.constant&&n.getBinding(a.name)===o)return t.id=a,void(t.id[f.NOT_LOCAL_BINDING]=!0)}}else if(f.isAssignmentExpression(r))a=r.left;else if(!a)return}else a=r.key;var u=void 0;if(a&&f.isLiteral(a))u=a.value;else{if(!a||!f.isIdentifier(a))return;u=a.name}u=f.toBindingIdentifierName(u),a=f.identifier(u),a[f.NOT_LOCAL_BINDING]=!0;return i(s(t,u,n),t,a,n)||t}};var a=r(189),o=n(a),u=r(4),l=n(u),c=r(1),f=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(c),p=(0,l.default)("\n (function (FUNCTION_KEY) {\n function FUNCTION_ID() {\n return FUNCTION_KEY.apply(this, arguments);\n }\n\n FUNCTION_ID.toString = function () {\n return FUNCTION_KEY.toString();\n }\n\n return FUNCTION_ID;\n })(FUNCTION)\n"),d=(0,l.default)("\n (function (FUNCTION_KEY) {\n function* FUNCTION_ID() {\n return yield* FUNCTION_KEY.apply(this, arguments);\n }\n\n FUNCTION_ID.toString = function () {\n return FUNCTION_KEY.toString();\n };\n\n return FUNCTION_ID;\n })(FUNCTION)\n"),h={"ReferencedIdentifier|BindingIdentifier":function(e,t){if(e.node.name===t.name){e.scope.getBindingIdentifier(t.name)===t.outerDeclar&&(t.selfReference=!0,e.stop())}}};e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(361),s=n(i),a=r(9),o=n(a),u=r(11),l=n(u);t.default=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":(0,l.default)(t)));e.prototype=(0,o.default)(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(s.default?(0,s.default)(e,t):e.__proto__=t)}},function(e,t,r){"use strict";t.__esModule=!0;var n=r(11),i=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":(0,i.default)(t))&&"function"!=typeof t?e:t}},function(e,t,r){"use strict";var n=r(227);e.exports=function(e,t,r){if(n(e),void 0===t)return e;switch(r){case 1:return function(r){return e.call(t,r)};case 2:return function(r,n){return e.call(t,r,n)};case 3:return function(r,n,i){return e.call(t,r,n,i)}}return function(){return e.apply(t,arguments)}}},function(e,t,r){"use strict";var n=r(237),i=r(141);e.exports=Object.keys||function(e){return n(e,i)}},function(e,t,r){"use strict";var n=r(17),i=n.Symbol;e.exports=i},function(e,t){"use strict";function r(e,t){return e===t||e!==e&&t!==t}e.exports=r},function(e,t,r){"use strict";function n(e){return a(e)?i(e,!0):s(e)}var i=r(245),s=r(501),a=r(24);e.exports=n},function(e,t,r){"use strict";function n(e){var t=i(e),r=t%1;return t===t?r?t-r:t:0}var i=r(597);e.exports=n},function(e,t){(function(t){e.exports=t}).call(t,{})},function(e,t,r){(function(e){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.File=void 0;var s=r(2),a=i(s),o=r(9),u=i(o),l=r(87),c=i(l),f=r(3),p=i(f),d=r(42),h=i(d),m=r(41),y=i(m),v=r(194),g=i(v),b=r(121),E=n(b),x=r(403),A=i(x),S=r(34),_=i(S),D=r(299),C=i(D),w=r(7),P=i(w),k=r(288),F=i(k),T=r(186),O=i(T),B=r(181),R=i(B),I=r(273),M=i(I),N=r(120),L=i(N),j=r(119),U=i(j),V=r(89),G=r(122),W=n(G),Y=r(19),q=i(Y),K=r(1),H=n(K),J=r(118),X=i(J),z=r(296),$=i(z),Q=r(297),Z=i(Q),ee=/^#!.*/,te=[[$.default],[Z.default]],re={enter:function(e,t){var r=e.node.loc;r&&(t.loc=r,e.stop())}},ne=function(t){function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments[1];(0,p.default)(this,n);var i=(0,h.default)(this,t.call(this));return i.pipeline=r,i.log=new L.default(i,e.filename||"unknown"),i.opts=i.initOptions(e),i.parserOpts={sourceType:i.opts.sourceType,sourceFileName:i.opts.filename,plugins:[]},i.pluginVisitors=[],i.pluginPasses=[],i.buildPluginsForOptions(i.opts),i.opts.passPerPreset&&(i.perPresetOpts=[],i.opts.presets.forEach(function(e){var t=(0,c.default)((0,u.default)(i.opts),e);i.perPresetOpts.push(t),i.buildPluginsForOptions(t)})),i.metadata={usedHelpers:[],marked:[],modules:{imports:[],exports:{exported:[],specifiers:[]}}},i.dynamicImportTypes={},i.dynamicImportIds={},i.dynamicImports=[],i.declarations={},i.usedHelpers={},i.path=null,i.ast={},i.code="",i.shebang="",i.hub=new w.Hub(i),i}return(0,y.default)(n,t),n.prototype.getMetadata=function(){for(var e=!1,t=this.ast.program.body,r=Array.isArray(t),n=0,t=r?t:(0,a.default)(t);;){var i;if(r){if(n>=t.length)break;i=t[n++]}else{if(n=t.next(),n.done)break;i=n.value}var s=i;if(H.isModuleDeclaration(s)){e=!0;break}}e&&this.path.traverse(E,this)},n.prototype.initOptions=function(e){e=new _.default(this.log,this.pipeline).init(e),e.inputSourceMap&&(e.sourceMaps=!0),e.moduleId&&(e.moduleIds=!0),e.basename=q.default.basename(e.filename,q.default.extname(e.filename)),e.ignore=W.arrayify(e.ignore,W.regexify),e.only&&(e.only=W.arrayify(e.only,W.regexify)),(0,M.default)(e,{moduleRoot:e.sourceRoot}),(0,M.default)(e,{sourceRoot:e.moduleRoot}),(0,M.default)(e,{filenameRelative:e.filename});var t=q.default.basename(e.filenameRelative);return(0,M.default)(e,{sourceFileName:t,sourceMapTarget:t}),e},n.prototype.buildPluginsForOptions=function(e){if(Array.isArray(e.plugins)){for(var t=e.plugins.concat(te),r=[],n=[],i=t,s=Array.isArray(i),o=0,i=s?i:(0,a.default)(i);;){var u;if(s){if(o>=i.length)break;u=i[o++]}else{if(o=i.next(),o.done)break;u=o.value}var l=u,c=l[0],f=l[1];r.push(c.visitor),n.push(new C.default(this,c,f)),c.manipulateOptions&&c.manipulateOptions(e,this.parserOpts,this)}this.pluginVisitors.push(r),this.pluginPasses.push(n)}},n.prototype.getModuleName=function(){var e=this.opts;if(!e.moduleIds)return null;if(null!=e.moduleId&&!e.getModuleId)return e.moduleId;var t=e.filenameRelative,r="";if(null!=e.moduleRoot&&(r=e.moduleRoot+"/"),!e.filenameRelative)return r+e.filename.replace(/^\//,"");if(null!=e.sourceRoot){var n=new RegExp("^"+e.sourceRoot+"/?");t=t.replace(n,"")}return t=t.replace(/\.(\w*?)$/,""),r+=t,r=r.replace(/\\/g,"/"),e.getModuleId?e.getModuleId(r)||r:r},n.prototype.resolveModuleSource=function(e){var t=this.opts.resolveModuleSource;return t&&(e=t(e,this.opts.filename)),e},n.prototype.addImport=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,n=e+":"+t,i=this.dynamicImportIds[n];if(!i){e=this.resolveModuleSource(e),i=this.dynamicImportIds[n]=this.scope.generateUidIdentifier(r);var s=[];"*"===t?s.push(H.importNamespaceSpecifier(i)):"default"===t?s.push(H.importDefaultSpecifier(i)):s.push(H.importSpecifier(i,H.identifier(t)));var a=H.importDeclaration(s,H.stringLiteral(e));a._blockHoist=3,this.path.unshiftContainer("body",a)}return i},n.prototype.addHelper=function(e){var t=this.declarations[e];if(t)return t;this.usedHelpers[e]||(this.metadata.usedHelpers.push(e),this.usedHelpers[e]=!0);var r=this.get("helperGenerator"),n=this.get("helpersNamespace");if(r){var i=r(e);if(i)return i}else if(n)return H.memberExpression(n,H.identifier(e));var s=(0,g.default)(e),a=this.declarations[e]=this.scope.generateUidIdentifier(e);return H.isFunctionExpression(s)&&!s.id?(s.body._compact=!0,s._generated=!0,s.id=a,s.type="FunctionDeclaration",this.path.unshiftContainer("body",s)):(s._compact=!0,this.scope.push({id:a,init:s,unique:!0})),a},n.prototype.addTemplateObject=function(e,t,r){var n=r.elements.map(function(e){return e.value}),i=e+"_"+r.elements.length+"_"+n.join(","),s=this.declarations[i];if(s)return s;var a=this.declarations[i]=this.scope.generateUidIdentifier("templateObject"),o=this.addHelper(e),u=H.callExpression(o,[t,r]);return u._compact=!0,this.scope.push({id:a,init:u,_blockHoist:1.9}),a},n.prototype.buildCodeFrameError=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:SyntaxError,n=e&&(e.loc||e._loc),i=new r(t);return n?i.loc=n.start:((0,P.default)(e,re,this.scope,i),i.message+=" (This is an error on an internal node. Probably an internal error",i.loc&&(i.message+=". Location has been estimated."),i.message+=")"),i},n.prototype.mergeSourceMap=function(e){var t=this.opts.inputSourceMap;if(t){var r=new F.default.SourceMapConsumer(t),n=new F.default.SourceMapConsumer(e),i=new F.default.SourceMapGenerator({file:r.file,sourceRoot:r.sourceRoot}),s=n.sources[0];r.eachMapping(function(e){var t=n.generatedPositionFor({line:e.generatedLine,column:e.generatedColumn,source:s});null!=t.column&&i.addMapping({source:e.source,original:null==e.source?null:{line:e.originalLine,column:e.originalColumn},generated:t})});var a=i.toJSON();return t.mappings=a.mappings,t}return e},n.prototype.parse=function(t){var n=V.parse,i=this.opts.parserOpts;if(i&&(i=(0,c.default)({},this.parserOpts,i),i.parser)){if("string"==typeof i.parser){var s=q.default.dirname(this.opts.filename)||e.cwd(),a=(0,X.default)(i.parser,s);if(!a)throw new Error("Couldn't find parser "+i.parser+' with "parse" method relative to directory '+s);n=r(178)(a).parse}else n=i.parser;i.parser={parse:function(e){return(0,V.parse)(e,i)}}}this.log.debug("Parse start");var o=n(t,i||this.parserOpts);return this.log.debug("Parse stop"),o},n.prototype._addAst=function(e){this.path=w.NodePath.get({hub:this.hub,parentPath:null,parent:e,container:e,key:"program"}).setContext(),this.scope=this.path.scope,this.ast=e,this.getMetadata()},n.prototype.addAst=function(e){this.log.debug("Start set AST"),this._addAst(e),this.log.debug("End set AST")},n.prototype.transform=function(){for(var e=0;e<this.pluginPasses.length;e++){var t=this.pluginPasses[e];this.call("pre",t),this.log.debug("Start transform traverse");var r=P.default.visitors.merge(this.pluginVisitors[e],t,this.opts.wrapPluginVisitorMethod);(0,P.default)(this.ast,r,this.scope),this.log.debug("End transform traverse"),this.call("post",t)}return this.generate()},n.prototype.wrap=function(t,r){t+="";try{return this.shouldIgnore()?this.makeResult({code:t,ignored:!0}):r()}catch(r){if(r._babel)throw r;r._babel=!0;var n=r.message=this.opts.filename+": "+r.message,i=r.loc;if(i&&(r.codeFrame=(0,R.default)(t,i.line,i.column+1,this.opts),n+="\n"+r.codeFrame),e.browser&&(r.message=n),r.stack){var s=r.stack.replace(r.message,n);r.stack=s}throw r}},n.prototype.addCode=function(e){e=(e||"")+"",e=this.parseInputSourceMap(e),this.code=e},n.prototype.parseCode=function(){this.parseShebang();var e=this.parse(this.code);this.addAst(e)},n.prototype.shouldIgnore=function(){var e=this.opts;return W.shouldIgnore(e.filename,e.ignore,e.only)},n.prototype.call=function(e,t){for(var r=t,n=Array.isArray(r),i=0,r=n?r:(0,a.default)(r);;){var s;if(n){if(i>=r.length)break;s=r[i++]}else{if(i=r.next(),i.done)break;s=i.value}var o=s,u=o.plugin,l=u[e];l&&l.call(o,this)}},n.prototype.parseInputSourceMap=function(e){var t=this.opts;if(!1!==t.inputSourceMap){var r=A.default.fromSource(e);r&&(t.inputSourceMap=r.toObject(),e=A.default.removeComments(e))}return e},n.prototype.parseShebang=function(){var e=ee.exec(this.code);e&&(this.shebang=e[0],this.code=this.code.replace(ee,""))},n.prototype.makeResult=function(e){var t=e.code,r=e.map,n=e.ast,i=e.ignored,s={metadata:null,options:this.opts,ignored:!!i,code:null,ast:null,map:r||null};return this.opts.code&&(s.code=t),this.opts.ast&&(s.ast=n),this.opts.metadata&&(s.metadata=this.metadata),s},n.prototype.generate=function(){var t=this.opts,n=this.ast,i={ast:n};if(!t.code)return this.makeResult(i);var s=O.default;if(t.generatorOpts.generator&&"string"==typeof(s=t.generatorOpts.generator)){var a=q.default.dirname(this.opts.filename)||e.cwd(),o=(0,X.default)(s,a);if(!o)throw new Error("Couldn't find generator "+s+' with "print" method relative to directory '+a);s=r(178)(o).print}this.log.debug("Generation start");var u=s(n,t.generatorOpts?(0,c.default)(t,t.generatorOpts):t,this.code);return i.code=u.code,i.map=u.map,this.log.debug("Generation end"),this.shebang&&(i.code=this.shebang+"\n"+i.code),i.map&&(i.map=this.mergeSourceMap(i.map)),"inline"!==t.sourceMaps&&"both"!==t.sourceMaps||(i.code+="\n"+A.default.fromObject(i.map).toComment()),"inline"===t.sourceMaps&&(i.map=null),this.makeResult(i)},n}(U.default);t.default=ne,t.File=ne}).call(t,r(8))},function(e,t,r){(function(n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function s(e){var t=x[e];return null==t?x[e]=E.default.existsSync(e):t}function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1],r=e.filename,n=new S(t);return!1!==e.babelrc&&n.findConfigs(r),n.mergeConfig({options:e,alias:"base",dirname:r&&g.default.dirname(r)}),n.configs}t.__esModule=!0;var o=r(87),u=i(o),l=r(3),c=i(l);t.default=a;var f=r(118),p=i(f),d=r(470),h=i(d),m=r(604),y=i(m),v=r(19),g=i(v),b=r(115),E=i(b),x={},A={},S=function(){function e(t){(0,c.default)(this,e),this.resolvedConfigs=[],this.configs=[],this.log=t}return e.prototype.findConfigs=function(e){if(e){(0,y.default)(e)||(e=g.default.join(n.cwd(),e));for(var t=!1,r=!1;e!==(e=g.default.dirname(e));){if(!t){var i=g.default.join(e,".babelrc");s(i)&&(this.addConfig(i),t=!0);var a=g.default.join(e,"package.json");!t&&s(a)&&(t=this.addConfig(a,"babel",JSON))}if(!r){var o=g.default.join(e,".babelignore");s(o)&&(this.addIgnoreConfig(o),r=!0)}if(r&&t)return}}},e.prototype.addIgnoreConfig=function(e){var t=E.default.readFileSync(e,"utf8"),r=t.split("\n");r=r.map(function(e){return e.replace(/#(.*?)$/,"").trim()}).filter(function(e){return!!e}),r.length&&this.mergeConfig({options:{ignore:r},alias:e,dirname:g.default.dirname(e)})},e.prototype.addConfig=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:h.default;if(this.resolvedConfigs.indexOf(e)>=0)return!1 +;this.resolvedConfigs.push(e);var n=E.default.readFileSync(e,"utf8"),i=void 0;try{i=A[n]=A[n]||r.parse(n),t&&(i=i[t])}catch(t){throw t.message=e+": Error while parsing JSON - "+t.message,t}return this.mergeConfig({options:i,alias:e,dirname:g.default.dirname(e)}),!!i},e.prototype.mergeConfig=function(e){var t=e.options,r=e.alias,i=e.loc,s=e.dirname;if(!t)return!1;if(t=(0,u.default)({},t),s=s||n.cwd(),i=i||r,t.extends){var a=(0,p.default)(t.extends,s);a?this.addConfig(a):this.log&&this.log.error("Couldn't resolve extends clause of "+t.extends+" in "+r),delete t.extends}this.configs.push({options:t,alias:r,loc:i,dirname:s});var o=void 0,l=n.env.BABEL_ENV||"production"||"development";t.env&&(o=t.env[l],delete t.env),this.mergeConfig({options:o,alias:r+".env."+l,dirname:s})},e}();e.exports=t.default}).call(t,r(8))},function(e,t,r){"use strict";function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in e){var r=e[t];if(null!=r){var n=o.default[t];if(n&&n.alias&&(n=o.default[n.alias]),n){var i=s[n.type];i&&(r=i(r)),e[t]=r}}}return e}t.__esModule=!0,t.config=void 0,t.normaliseOptions=n;var i=r(53),s=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(i),a=r(33),o=function(e){return e&&e.__esModule?e:{default:e}}(a);t.config=o.default},function(e,t,r){"use strict";function n(e){return!!e}function i(e){return l.booleanify(e)}function s(e){return l.list(e)}t.__esModule=!0,t.filename=void 0,t.boolean=n,t.booleanString=i,t.list=s;var a=r(284),o=function(e){return e&&e.__esModule?e:{default:e}}(a),u=r(122),l=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(u);t.filename=o.default},function(e,t){"use strict";e.exports={auxiliaryComment:{message:"Use `auxiliaryCommentBefore` or `auxiliaryCommentAfter`"},blacklist:{message:"Put the specific transforms you want in the `plugins` option"},breakConfig:{message:"This is not a necessary option in Babel 6"},experimental:{message:"Put the specific transforms you want in the `plugins` option"},externalHelpers:{message:"Use the `external-helpers` plugin instead. Check out http://babeljs.io/docs/plugins/external-helpers/"},extra:{message:""},jsxPragma:{message:"use the `pragma` option in the `react-jsx` plugin . Check out http://babeljs.io/docs/plugins/transform-react-jsx/"},loose:{message:"Specify the `loose` option for the relevant plugin you are using or use a preset that sets the option."},metadataUsedHelpers:{message:"Not required anymore as this is enabled by default"},modules:{message:"Use the corresponding module transform plugin in the `plugins` option. Check out http://babeljs.io/docs/plugins/#modules"},nonStandard:{message:"Use the `react-jsx` and `flow-strip-types` plugins to support JSX and Flow. Also check out the react preset http://babeljs.io/docs/plugins/preset-react/"},optional:{message:"Put the specific transforms you want in the `plugins` option"},sourceMapName:{message:"Use the `sourceMapTarget` option"},stage:{message:"Check out the corresponding stage-x presets http://babeljs.io/docs/plugins/#presets"},whitelist:{message:"Put the specific transforms you want in the `plugins` option"}}},function(e,t,r){"use strict";var n=r(43),i=r(428),s=r(427),a=r(21),o=r(153),u=r(238),l={},c={},f=e.exports=function(e,t,r,f,p){var d,h,m,y,v=p?function(){return e}:u(e),g=n(r,f,t?2:1),b=0;if("function"!=typeof v)throw TypeError(e+" is not iterable!");if(s(v)){for(d=o(e.length);d>b;b++)if((y=t?g(a(h=e[b])[0],h[1]):g(e[b]))===l||y===c)return y}else for(m=v.call(e);!(h=m.next()).done;)if((y=i(m,g,h.value,t))===l||y===c)return y};f.BREAK=l,f.RETURN=c},function(e,t){"use strict";e.exports={}},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=r(95)("meta"),s=r(16),a=r(28),o=r(23).f,u=0,l=Object.isExtensible||function(){return!0},c=!r(27)(function(){return l(Object.preventExtensions({}))}),f=function(e){o(e,i,{value:{i:"O"+ ++u,w:{}}})},p=function(e,t){if(!s(e))return"symbol"==(void 0===e?"undefined":n(e))?e:("string"==typeof e?"S":"P")+e;if(!a(e,i)){if(!l(e))return"F";if(!t)return"E";f(e)}return e[i].i},d=function(e,t){if(!a(e,i)){if(!l(e))return!0;if(!t)return!1;f(e)}return e[i].w},h=function(e){return c&&m.NEED&&l(e)&&!a(e,i)&&f(e),e},m=e.exports={KEY:i,NEED:!1,fastKey:p,getWeak:d,onFreeze:h}},function(e,t,r){"use strict";var n=r(16);e.exports=function(e,t){if(!n(e)||e._t!==t)throw TypeError("Incompatible receiver, "+t+" required!");return e}},function(e,t,r){"use strict";r(440);for(var n=r(15),i=r(29),s=r(56),a=r(13)("toStringTag"),o="CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,TextTrackList,TouchList".split(","),u=0;u<o.length;u++){var l=o[u],c=n[l],f=c&&c.prototype;f&&!f[a]&&i(f,a,l),s[l]=s.Array}},function(e,t){"use strict";function r(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}e.exports=r},function(e,t,r){"use strict";function n(e){return"function"==typeof e?e:null==e?o:"object"==(void 0===e?"undefined":i(e))?u(e)?a(e[0],e[1]):s(e):l(e)}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s=r(502),a=r(503),o=r(110),u=r(6),l=r(592);e.exports=n},function(e,t,r){"use strict";function n(e){return"symbol"==(void 0===e?"undefined":i(e))||a(e)&&s(e)==o}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s=r(30),a=r(25),o="[object Symbol]";e.exports=n},function(e,t){"use strict";function r(e,t,r){if(t in e)return e[t];if(3===arguments.length)return r;throw new Error('"'+t+'" is a required argument.')}function n(e){var t=e.match(y);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}function i(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}function s(e){var r=e,s=n(e);if(s){if(!s.path)return e;r=s.path}for(var a,o=t.isAbsolute(r),u=r.split(/\/+/),l=0,c=u.length-1;c>=0;c--)a=u[c],"."===a?u.splice(c,1):".."===a?l++:l>0&&(""===a?(u.splice(c+1,l),l=0):(u.splice(c,2),l--));return r=u.join("/"),""===r&&(r=o?"/":"."),s?(s.path=r,i(s)):r}function a(e,t){""===e&&(e="."),""===t&&(t=".");var r=n(t),a=n(e);if(a&&(e=a.path||"/"),r&&!r.scheme)return a&&(r.scheme=a.scheme),i(r);if(r||t.match(v))return t;if(a&&!a.host&&!a.path)return a.host=t,i(a);var o="/"===t.charAt(0)?t:s(e.replace(/\/+$/,"")+"/"+t);return a?(a.path=o,i(a)):o}function o(e,t){""===e&&(e="."),e=e.replace(/\/$/,"");for(var r=0;0!==t.indexOf(e+"/");){var n=e.lastIndexOf("/");if(n<0)return t;if(e=e.slice(0,n),e.match(/^([^\/]+:\/)?\/*$/))return t;++r}return Array(r+1).join("../")+t.substr(e.length+1)}function u(e){return e}function l(e){return f(e)?"$"+e:e}function c(e){return f(e)?e.slice(1):e}function f(e){if(!e)return!1;var t=e.length;if(t<9)return!1;if(95!==e.charCodeAt(t-1)||95!==e.charCodeAt(t-2)||111!==e.charCodeAt(t-3)||116!==e.charCodeAt(t-4)||111!==e.charCodeAt(t-5)||114!==e.charCodeAt(t-6)||112!==e.charCodeAt(t-7)||95!==e.charCodeAt(t-8)||95!==e.charCodeAt(t-9))return!1;for(var r=t-10;r>=0;r--)if(36!==e.charCodeAt(r))return!1;return!0}function p(e,t,r){var n=e.source-t.source;return 0!==n?n:0!==(n=e.originalLine-t.originalLine)?n:0!==(n=e.originalColumn-t.originalColumn)||r?n:0!==(n=e.generatedColumn-t.generatedColumn)?n:(n=e.generatedLine-t.generatedLine,0!==n?n:e.name-t.name)}function d(e,t,r){var n=e.generatedLine-t.generatedLine;return 0!==n?n:0!==(n=e.generatedColumn-t.generatedColumn)||r?n:0!==(n=e.source-t.source)?n:0!==(n=e.originalLine-t.originalLine)?n:(n=e.originalColumn-t.originalColumn,0!==n?n:e.name-t.name)}function h(e,t){return e===t?0:e>t?1:-1}function m(e,t){var r=e.generatedLine-t.generatedLine;return 0!==r?r:0!==(r=e.generatedColumn-t.generatedColumn)?r:0!==(r=h(e.source,t.source))?r:0!==(r=e.originalLine-t.originalLine)?r:(r=e.originalColumn-t.originalColumn,0!==r?r:h(e.name,t.name))}t.getArg=r;var y=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/,v=/^data:.+\,.+$/;t.urlParse=n,t.urlGenerate=i,t.normalize=s,t.join=a,t.isAbsolute=function(e){return"/"===e.charAt(0)||!!e.match(y)},t.relative=o;var g=function(){return!("__proto__"in Object.create(null))}();t.toSetString=g?u:l,t.fromSetString=g?u:c,t.compareByOriginalPositions=p,t.compareByGeneratedPositionsDeflated=d,t.compareByGeneratedPositionsInflated=m},function(e,t,r){(function(t){"use strict";function n(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,s=Math.min(r,n);i<s;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0}function i(e){return t.Buffer&&"function"==typeof t.Buffer.isBuffer?t.Buffer.isBuffer(e):!(null==e||!e._isBuffer)}function s(e){return Object.prototype.toString.call(e)}function a(e){return!i(e)&&("function"==typeof t.ArrayBuffer&&("function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):!!e&&(e instanceof DataView||!!(e.buffer&&e.buffer instanceof ArrayBuffer))))}function o(e){if(x.isFunction(e)){if(_)return e.name;var t=e.toString(),r=t.match(C);return r&&r[1]}}function u(e,t){return"string"==typeof e?e.length<t?e:e.slice(0,t):e}function l(e){if(_||!x.isFunction(e))return x.inspect(e);var t=o(e);return"[Function"+(t?": "+t:"")+"]"}function c(e){return u(l(e.actual),128)+" "+e.operator+" "+u(l(e.expected),128)}function f(e,t,r,n,i){throw new D.AssertionError({message:r,actual:e,expected:t,operator:n,stackStartFunction:i})}function p(e,t){e||f(e,!0,t,"==",D.ok)}function d(e,t,r,o){if(e===t)return!0;if(i(e)&&i(t))return 0===n(e,t);if(x.isDate(e)&&x.isDate(t))return e.getTime()===t.getTime();if(x.isRegExp(e)&&x.isRegExp(t))return e.source===t.source&&e.global===t.global&&e.multiline===t.multiline&&e.lastIndex===t.lastIndex&&e.ignoreCase===t.ignoreCase;if(null!==e&&"object"===(void 0===e?"undefined":E(e))||null!==t&&"object"===(void 0===t?"undefined":E(t))){if(a(e)&&a(t)&&s(e)===s(t)&&!(e instanceof Float32Array||e instanceof Float64Array))return 0===n(new Uint8Array(e.buffer),new Uint8Array(t.buffer));if(i(e)!==i(t))return!1;o=o||{actual:[],expected:[]};var u=o.actual.indexOf(e);return-1!==u&&u===o.expected.indexOf(t)||(o.actual.push(e),o.expected.push(t),m(e,t,r,o))}return r?e===t:e==t}function h(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function m(e,t,r,n){if(null===e||void 0===e||null===t||void 0===t)return!1;if(x.isPrimitive(e)||x.isPrimitive(t))return e===t;if(r&&Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;var i=h(e),s=h(t);if(i&&!s||!i&&s)return!1;if(i)return e=S.call(e),t=S.call(t),d(e,t,r);var a,o,u=w(e),l=w(t);if(u.length!==l.length)return!1;for(u.sort(),l.sort(),o=u.length-1;o>=0;o--)if(u[o]!==l[o])return!1;for(o=u.length-1;o>=0;o--)if(a=u[o],!d(e[a],t[a],r,n))return!1;return!0}function y(e,t,r){d(e,t,!0)&&f(e,t,r,"notDeepStrictEqual",y)}function v(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function g(e){var t;try{e()}catch(e){t=e}return t}function b(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=g(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&f(i,r,"Missing expected exception"+n);var s="string"==typeof n,a=!e&&x.isError(i),o=!e&&i&&!r;if((a&&s&&v(i,r)||o)&&f(i,r,"Got unwanted exception"+n),e&&i&&r&&!v(i,r)||!e&&i)throw i}var E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},x=r(117),A=Object.prototype.hasOwnProperty,S=Array.prototype.slice,_=function(){return"foo"===function(){}.name}(),D=e.exports=p,C=/\s*function\s+([^\(\s]*)\s*/;D.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=c(this),this.generatedMessage=!0);var t=e.stackStartFunction||f;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var r=new Error;if(r.stack){var n=r.stack,i=o(t),s=n.indexOf("\n"+i);if(s>=0){var a=n.indexOf("\n",s+1);n=n.substring(a+1)}this.stack=n}}},x.inherits(D.AssertionError,Error),D.fail=f,D.ok=p,D.equal=function(e,t,r){e!=t&&f(e,t,r,"==",D.equal)},D.notEqual=function(e,t,r){e==t&&f(e,t,r,"!=",D.notEqual)},D.deepEqual=function(e,t,r){d(e,t,!1)||f(e,t,r,"deepEqual",D.deepEqual)},D.deepStrictEqual=function(e,t,r){d(e,t,!0)||f(e,t,r,"deepStrictEqual",D.deepStrictEqual)},D.notDeepEqual=function(e,t,r){d(e,t,!1)&&f(e,t,r,"notDeepEqual",D.notDeepEqual)},D.notDeepStrictEqual=y,D.strictEqual=function(e,t,r){e!==t&&f(e,t,r,"===",D.strictEqual)},D.notStrictEqual=function(e,t,r){e===t&&f(e,t,r,"!==",D.notStrictEqual)},D.throws=function(e,t,r){b(!0,e,t,r)},D.doesNotThrow=function(e,t,r){b(!1,e,t,r)},D.ifError=function(e){if(e)throw e};var w=Object.keys||function(e){var t=[];for(var r in e)A.call(e,r)&&t.push(r);return t}}).call(t,function(){return this}())},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(2),s=n(i),a=r(3),o=n(a),u=r(42),l=n(u),c=r(41),f=n(c),p=r(34),d=n(p),h=r(20),m=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(h),y=r(119),v=n(y),g=r(7),b=n(g),E=r(174),x=n(E),A=r(109),S=n(A),_=["enter","exit"],D=function(e){function t(r,n){(0,o.default)(this,t);var i=(0,l.default)(this,e.call(this));return i.initialized=!1,i.raw=(0,x.default)({},r),i.key=i.take("name")||n,i.manipulateOptions=i.take("manipulateOptions"),i.post=i.take("post"),i.pre=i.take("pre"),i.visitor=i.normaliseVisitor((0,S.default)(i.take("visitor"))||{}),i}return(0,f.default)(t,e),t.prototype.take=function(e){var t=this.raw[e];return delete this.raw[e],t},t.prototype.chain=function(e,t){if(!e[t])return this[t];if(!this[t])return e[t];var r=[e[t],this[t]];return function(){for(var e=void 0,t=arguments.length,n=Array(t),i=0;i<t;i++)n[i]=arguments[i];for(var a=r,o=Array.isArray(a),u=0,a=o?a:(0,s.default)(a);;){var l;if(o){if(u>=a.length)break;l=a[u++]}else{if(u=a.next(),u.done)break;l=u.value}var c=l;if(c){var f=c.apply(this,n);null!=f&&(e=f)}}return e}},t.prototype.maybeInherit=function(e){var t=this.take("inherits");t&&(t=d.default.normalisePlugin(t,e,"inherits"),this.manipulateOptions=this.chain(t,"manipulateOptions"),this.post=this.chain(t,"post"),this.pre=this.chain(t,"pre"),this.visitor=b.default.visitors.merge([t.visitor,this.visitor]))},t.prototype.init=function(e,t){if(!this.initialized){this.initialized=!0,this.maybeInherit(e);for(var r in this.raw)throw new Error(m.get("pluginInvalidProperty",e,t,r))}},t.prototype.normaliseVisitor=function(e){for(var t=_,r=Array.isArray(t),n=0,t=r?t:(0,s.default)(t);;){var i;if(r){if(n>=t.length)break;i=t[n++]}else{if(n=t.next(),n.done)break;i=n.value}if(e[i])throw new Error("Plugins aren't allowed to specify catch-all enter/exit handlers. Please target individual nodes.")}return b.default.explode(e),e},t}(v.default);t.default=D,e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0;var n=r(2),i=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=function(e){var t=e.messages;return{visitor:{Scope:function(e){var r=e.scope;for(var n in r.bindings){var s=r.bindings[n];if("const"===s.kind||"module"===s.kind)for(var a=s.constantViolations,o=Array.isArray(a),u=0,a=o?a:(0,i.default)(a);;){var l;if(o){if(u>=a.length)break;l=a[u++]}else{if(u=a.next(),u.done)break;l=u.value}var c=l;throw c.buildCodeFrameError(t.get("readOnly",n))}}}}}},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(){return{manipulateOptions:function(e,t){t.plugins.push("asyncFunctions")}}},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(e){var t=e.types;return{visitor:{ArrowFunctionExpression:function(e,r){if(r.opts.spec){var n=e.node;if(n.shadow)return;n.shadow={this:!1},n.type="FunctionExpression";var i=t.thisExpression();i._forceShadow=e,e.ensureBlock(),e.get("body").unshiftContainer("body",t.expressionStatement(t.callExpression(r.addHelper("newArrowCheck"),[t.thisExpression(),i]))),e.replaceWith(t.callExpression(t.memberExpression(n,t.identifier("bind")),[t.thisExpression()]))}else e.arrowFunctionToShadowed()}}}},e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0;var n=r(2),i=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=function(e){function t(e,t){for(var n=t.get(e),s=n,a=Array.isArray(s),o=0,s=a?s:(0,i.default)(s);;){var u;if(a){if(o>=s.length)break;u=s[o++]}else{if(o=s.next(),o.done)break;u=o.value}var l=u,c=l.node;if(l.isFunctionDeclaration()){var f=r.variableDeclaration("let",[r.variableDeclarator(c.id,r.toExpression(c))]);f._blockHoist=2,c.id=null,l.replaceWith(f)}}}var r=e.types;return{visitor:{BlockStatement:function(e){var n=e.node,i=e.parent;r.isFunction(i,{body:n})||r.isExportDeclaration(i)||t("body",e)},SwitchCase:function(e){t("consequent",e)}}}},e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){return b.isLoop(e.parent)||b.isCatchClause(e.parent)}function s(e){return!!b.isVariableDeclaration(e)&&(!!e[b.BLOCK_SCOPED_SYMBOL]||("let"===e.kind||"const"===e.kind))}function a(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(t||(t=e.node),!b.isFor(r))for(var s=0;s<t.declarations.length;s++){var a=t.declarations[s];a.init=a.init||n.buildUndefinedNode()}if(t[b.BLOCK_SCOPED_SYMBOL]=!0,t.kind="var",i){var o=n.getFunctionParent(),u=e.getBindingIdentifiers();for(var l in u){var c=n.getOwnBinding(l);c&&(c.kind="var"),n.moveBindingTo(l,o)}}}function o(e){return b.isVariableDeclaration(e,{kind:"var"})&&!s(e)}function u(e){return b.isBreakStatement(e)?"break":b.isContinueStatement(e)?"continue":void 0}t.__esModule=!0;var l=r(10),c=n(l),f=r(9),p=n(f),d=r(3),h=n(d);t.default=function(){return{visitor:{VariableDeclaration:function(e,t){var r=e.node,n=e.parent,i=e.scope;if(s(r)&&(a(e,null,n,i,!0),r._tdzThis)){for(var o=[r],u=0;u<r.declarations.length;u++){var l=r.declarations[u];if(l.init){var c=b.assignmentExpression("=",l.id,l.init);c._ignoreBlockScopingTDZ=!0,o.push(b.expressionStatement(c))}l.init=t.addHelper("temporalUndefined")}r._blockHoist=2,e.isCompletionRecord()&&o.push(b.expressionStatement(i.buildUndefinedNode())),e.replaceWithMultiple(o)}},Loop:function(e,t){var r=e.node,n=e.parent,i=e.scope;b.ensureBlock(r);var s=new B(e,e.get("body"),n,i,t),a=s.run();a&&e.replaceWith(a)},CatchClause:function(e,t){var r=e.parent,n=e.scope;new B(null,e.get("body"),r,n,t).run()},"BlockStatement|SwitchStatement|Program":function(e,t){if(!i(e)){new B(null,e,e.parent,e.scope,t).run()}}}}};var m=r(7),y=n(m),v=r(330),g=r(1),b=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(g),E=r(280),x=n(E),A=r(578),S=n(A),_=r(4),D=n(_),C=(0,D.default)('\n if (typeof RETURN === "object") return RETURN.v;\n'),w=y.default.visitors.merge([{Loop:{enter:function(e,t){t.loopDepth++},exit:function(e,t){t.loopDepth--}},Function:function(e,t){return t.loopDepth>0&&e.traverse(P,t),e.skip()}},v.visitor]),P=y.default.visitors.merge([{ReferencedIdentifier:function(e,t){var r=t.letReferences[e.node.name];if(r){var n=e.scope.getBindingIdentifier(e.node.name);n&&n!==r||(t.closurify=!0)}}},v.visitor]),k={enter:function(e,t){var r=e.node;e.parent;if(e.isForStatement()){if(o(r.init)){var n=t.pushDeclar(r.init);1===n.length?r.init=n[0]:r.init=b.sequenceExpression(n)}}else if(e.isFor())o(r.left)&&(t.pushDeclar(r.left),r.left=r.left.declarations[0].id);else if(o(r))e.replaceWithMultiple(t.pushDeclar(r).map(function(e){return b.expressionStatement(e)}));else if(e.isFunction())return e.skip()}},F={LabeledStatement:function(e,t){var r=e.node;t.innerLabels.push(r.label.name)}},T={enter:function(e,t){if(e.isAssignmentExpression()||e.isUpdateExpression()){var r=e.getBindingIdentifiers();for(var n in r)t.outsideReferences[n]===e.scope.getBindingIdentifier(n)&&(t.reassignments[n]=!0)}}},O={Loop:function(e,t){var r=t.ignoreLabeless;t.ignoreLabeless=!0,e.traverse(O,t),t.ignoreLabeless=r,e.skip()},Function:function(e){e.skip()},SwitchCase:function(e,t){var r=t.inSwitchCase;t.inSwitchCase=!0,e.traverse(O,t),t.inSwitchCase=r,e.skip()},"BreakStatement|ContinueStatement|ReturnStatement":function(e,t){var r=e.node,n=e.parent,i=e.scope;if(!r[this.LOOP_IGNORE]){var s=void 0,a=u(r);if(a){if(r.label){if(t.innerLabels.indexOf(r.label.name)>=0)return;a=a+"|"+r.label.name}else{if(t.ignoreLabeless)return;if(t.inSwitchCase)return;if(b.isBreakStatement(r)&&b.isSwitchCase(n))return}t.hasBreakContinue=!0,t.map[a]=r,s=b.stringLiteral(a)}e.isReturnStatement()&&(t.hasReturn=!0,s=b.objectExpression([b.objectProperty(b.identifier("v"),r.argument||i.buildUndefinedNode())])),s&&(s=b.returnStatement(s),s[this.LOOP_IGNORE]=!0,e.skip(),e.replaceWith(b.inherits(s,r)))}}},B=function(){function e(t,r,n,i,s){(0,h.default)(this,e),this.parent=n,this.scope=i,this.file=s,this.blockPath=r,this.block=r.node,this.outsideLetReferences=(0,p.default)(null),this.hasLetReferences=!1,this.letReferences=(0,p.default)(null),this.body=[],t&&(this.loopParent=t.parent,this.loopLabel=b.isLabeledStatement(this.loopParent)&&this.loopParent.label,this.loopPath=t,this.loop=t.node)}return e.prototype.run=function(){var e=this.block;if(!e._letDone){e._letDone=!0;var t=this.getLetReferences();if(b.isFunction(this.parent)||b.isProgram(this.block))return void this.updateScopeInfo();if(this.hasLetReferences)return t?this.wrapClosure():this.remap(),this.updateScopeInfo(t),this.loopLabel&&!b.isLabeledStatement(this.loopParent)?b.labeledStatement(this.loopLabel,this.loop):void 0}},e.prototype.updateScopeInfo=function(e){var t=this.scope,r=t.getFunctionParent(),n=this.letReferences;for(var i in n){var s=n[i],a=t.getBinding(s.name);a&&("let"!==a.kind&&"const"!==a.kind||(a.kind="var",e?t.removeBinding(s.name):t.moveBindingTo(s.name,r)))}},e.prototype.remap=function(){var e=this.letReferences,t=this.scope;for(var r in e){var n=e[r];(t.parentHasBinding(r)||t.hasGlobal(r))&&(t.hasOwnBinding(r)&&t.rename(n.name),this.blockPath.scope.hasOwnBinding(r)&&this.blockPath.scope.rename(n.name))}},e.prototype.wrapClosure=function(){if(this.file.opts.throwIfClosureRequired)throw this.blockPath.buildCodeFrameError("Compiling let/const in this block would add a closure (throwIfClosureRequired).");var e=this.block,t=this.outsideLetReferences;if(this.loop)for(var r in t){var n=t[r];(this.scope.hasGlobal(n.name)||this.scope.parentHasBinding(n.name))&&(delete t[n.name],delete this.letReferences[n.name],this.scope.rename(n.name),this.letReferences[n.name]=n,t[n.name]=n)}this.has=this.checkLoop(),this.hoistVarDeclarations();var i=(0,x.default)(t),s=(0,x.default)(t),a=this.blockPath.isSwitchStatement(),o=b.functionExpression(null,i,b.blockStatement(a?[e]:e.body));o.shadow=!0,this.addContinuations(o);var u=o;this.loop&&(u=this.scope.generateUidIdentifier("loop"),this.loopPath.insertBefore(b.variableDeclaration("var",[b.variableDeclarator(u,o)])));var l=b.callExpression(u,s),c=this.scope.generateUidIdentifier("ret");y.default.hasType(o.body,this.scope,"YieldExpression",b.FUNCTION_TYPES)&&(o.generator=!0,l=b.yieldExpression(l,!0)),y.default.hasType(o.body,this.scope,"AwaitExpression",b.FUNCTION_TYPES)&&(o.async=!0,l=b.awaitExpression(l)),this.buildClosure(c,l),a?this.blockPath.replaceWithMultiple(this.body):e.body=this.body},e.prototype.buildClosure=function(e,t){var r=this.has;r.hasReturn||r.hasBreakContinue?this.buildHas(e,t):this.body.push(b.expressionStatement(t))},e.prototype.addContinuations=function(e){var t={reassignments:{},outsideReferences:this.outsideLetReferences};this.scope.traverse(e,T,t);for(var r=0;r<e.params.length;r++){var n=e.params[r];if(t.reassignments[n.name]){var i=this.scope.generateUidIdentifier(n.name);e.params[r]=i,this.scope.rename(n.name,i.name,e),e.body.body.push(b.expressionStatement(b.assignmentExpression("=",n,i)))}}},e.prototype.getLetReferences=function(){var e=this,t=this.block,r=[];if(this.loop){var n=this.loop.left||this.loop.init;s(n)&&(r.push(n),(0,S.default)(this.outsideLetReferences,b.getBindingIdentifiers(n)))}var i=function n(i,o){o=o||i.node,(b.isClassDeclaration(o)||b.isFunctionDeclaration(o)||s(o))&&(s(o)&&a(i,o,t,e.scope),r=r.concat(o.declarations||o)),b.isLabeledStatement(o)&&n(i.get("body"),o.body)};if(t.body)for(var o=0;o<t.body.length;o++){var u=this.blockPath.get("body")[o];i(u)}if(t.cases)for(var l=0;l<t.cases.length;l++)for(var c=t.cases[l].consequent,f=0;f<c.length;f++){var p=this.blockPath.get("cases")[l],d=c[f];i(p,d)}for(var h=0;h<r.length;h++){var m=r[h],y=b.getBindingIdentifiers(m,!1,!0);(0,S.default)(this.letReferences,y),this.hasLetReferences=!0}if(this.hasLetReferences){var v={letReferences:this.letReferences,closurify:!1,file:this.file,loopDepth:0},g=this.blockPath.find(function(e){return e.isLoop()||e.isFunction()});return g&&g.isLoop()&&v.loopDepth++,this.blockPath.traverse(w,v),v.closurify}},e.prototype.checkLoop=function(){var e={hasBreakContinue:!1,ignoreLabeless:!1,inSwitchCase:!1,innerLabels:[],hasReturn:!1,isLoop:!!this.loop,map:{},LOOP_IGNORE:(0,c.default)()};return this.blockPath.traverse(F,e),this.blockPath.traverse(O,e),e},e.prototype.hoistVarDeclarations=function(){this.blockPath.traverse(k,this)},e.prototype.pushDeclar=function(e){var t=[],r=b.getBindingIdentifiers(e);for(var n in r)t.push(b.variableDeclarator(r[n]));this.body.push(b.variableDeclaration(e.kind,t));for(var i=[],s=0;s<e.declarations.length;s++){var a=e.declarations[s];if(a.init){var o=b.assignmentExpression("=",a.id,a.init);i.push(b.inherits(o,a))}}return i},e.prototype.buildHas=function(e,t){var r=this.body;r.push(b.variableDeclaration("var",[b.variableDeclarator(e,t)]));var n=void 0,i=this.has,s=[];if(i.hasReturn&&(n=C({RETURN:e})),i.hasBreakContinue){for(var a in i.map)s.push(b.switchCase(b.stringLiteral(a),[i.map[a]]));if(i.hasReturn&&s.push(b.switchCase(null,[n])),1===s.length){var o=s[0];r.push(b.ifStatement(b.binaryExpression("===",e,o.test),o.consequent[0]))}else{if(this.loop)for(var u=0;u<s.length;u++){var l=s[u].consequent[0];b.isBreakStatement(l)&&!l.label&&(l.label=this.loopLabel=this.loopLabel||this.scope.generateUidIdentifier("loop"))}r.push(b.switchStatement(e,s))}}else i.hasReturn&&r.push(n)},e}();e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(10),s=n(i);t.default=function(e){var t=e.types,r=(0,s.default)();return{visitor:{ExportDefaultDeclaration:function(e){if(e.get("declaration").isClassDeclaration()){var r=e.node,n=r.declaration.id||e.scope.generateUidIdentifier("class");r.declaration.id=n,e.replaceWith(r.declaration),e.insertAfter(t.exportDefaultDeclaration(n))}},ClassDeclaration:function(e){var r=e.node,n=r.id||e.scope.generateUidIdentifier("class");e.replaceWith(t.variableDeclaration("let",[t.variableDeclarator(n,t.toExpression(r))]))},ClassExpression:function(e,t){var n=e.node;if(!n[r]){var i=(0,f.default)(e);if(i&&i!==n)return e.replaceWith(i);n[r]=!0;var s=l.default;t.opts.loose&&(s=o.default),e.replaceWith(new s(e,t.file).run())}}}}};var a=r(331),o=n(a),u=r(207),l=n(u),c=r(40),f=n(c);e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0;var n=r(2),i=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=function(e){function t(e){return o.isObjectProperty(e)?e.value:o.isObjectMethod(e)?o.functionExpression(null,e.params,e.body,e.generator,e.async):void 0}function r(e,r,i){"get"===r.kind&&"set"===r.kind?n(e,r,i):i.push(o.expressionStatement(o.assignmentExpression("=",o.memberExpression(e,r.key,r.computed||o.isLiteral(r.key)),t(r))))}function n(e,r){var n=(e.objId,e.body),i=e.getMutatorId,s=e.scope,a=!r.computed&&o.isIdentifier(r.key)?o.stringLiteral(r.key.name):r.key,u=s.maybeGenerateMemoised(a);u&&(n.push(o.expressionStatement(o.assignmentExpression("=",u,a))),a=u),n.push.apply(n,l({MUTATOR_MAP_REF:i(),KEY:a,VALUE:t(r),KIND:o.identifier(r.kind)}))}function s(e){for(var t=e.computedProps,s=Array.isArray(t),a=0,t=s?t:(0,i.default)(t);;){var o;if(s){if(a>=t.length)break;o=t[a++]}else{if(a=t.next(),a.done)break;o=a.value}var u=o;"get"===u.kind||"set"===u.kind?n(e,u):r(e.objId,u,e.body)}}function a(e){for(var s=e.objId,a=e.body,u=e.computedProps,l=e.state,c=u,f=Array.isArray(c),p=0,c=f?c:(0,i.default)(c);;){var d;if(f){if(p>=c.length)break;d=c[p++]}else{if(p=c.next(),p.done)break;d=p.value}var h=d,m=o.toComputedKey(h);if("get"===h.kind||"set"===h.kind)n(e,h);else if(o.isStringLiteral(m,{value:"__proto__"}))r(s,h,a);else{if(1===u.length)return o.callExpression(l.addHelper("defineProperty"),[e.initPropExpression,m,t(h)]);a.push(o.expressionStatement(o.callExpression(l.addHelper("defineProperty"),[s,m,t(h)])))}}}var o=e.types,u=e.template,l=u("\n MUTATOR_MAP_REF[KEY] = MUTATOR_MAP_REF[KEY] || {};\n MUTATOR_MAP_REF[KEY].KIND = VALUE;\n ");return{visitor:{ObjectExpression:{exit:function(e,t){for(var r=e.node,n=e.parent,u=e.scope,l=!1,c=r.properties,f=Array.isArray(c),p=0,c=f?c:(0,i.default)(c);;){var d;if(f){if(p>=c.length)break;d=c[p++]}else{if(p=c.next(),p.done)break;d=p.value}if(l=!0===d.computed)break}if(l){for(var h=[],m=[],y=!1,v=r.properties,g=Array.isArray(v),b=0,v=g?v:(0,i.default)(v);;){var E;if(g){if(b>=v.length)break;E=v[b++]}else{if(b=v.next(),b.done)break;E=b.value}var x=E;x.computed&&(y=!0),y?m.push(x):h.push(x)}var A=u.generateUidIdentifierBasedOnNode(n),S=o.objectExpression(h),_=[];_.push(o.variableDeclaration("var",[o.variableDeclarator(A,S)]));var D=a;t.opts.loose&&(D=s);var C=void 0,w=function(){return C||(C=u.generateUidIdentifier("mutatorMap"),_.push(o.variableDeclaration("var",[o.variableDeclarator(C,o.objectExpression([]))]))),C},P=D({scope:u,objId:A,body:_,computedProps:m,initPropExpression:S,getMutatorId:w,state:t});C&&_.push(o.expressionStatement(o.callExpression(t.addHelper("defineEnumerableProperties"),[A,C]))),P?e.replaceWith(P):(_.push(o.expressionStatement(A)),e.replaceWithMultiple(_))}}}}}},e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(3),s=n(i),a=r(2),o=n(a);t.default=function(e){function t(e){for(var t=e.declarations,r=Array.isArray(t),i=0,t=r?t:(0,o.default)(t);;){var s;if(r){if(i>=t.length)break;s=t[i++]}else{if(i=t.next(),i.done)break;s=i.value}var a=s;if(n.isPattern(a.id))return!0}return!1}function r(e){for(var t=e.elements,r=Array.isArray(t),i=0,t=r?t:(0,o.default)(t);;){var s;if(r){if(i>=t.length)break;s=t[i++]}else{if(i=t.next(),i.done)break;s=i.value}var a=s;if(n.isRestElement(a))return!0}return!1}var n=e.types,i={ReferencedIdentifier:function(e,t){t.bindings[e.node.name]&&(t.deopt=!0,e.stop())}},a=function(){function e(t){(0,s.default)(this,e),this.blockHoist=t.blockHoist,this.operator=t.operator,this.arrays={},this.nodes=t.nodes||[],this.scope=t.scope,this.file=t.file,this.kind=t.kind} +return e.prototype.buildVariableAssignment=function(e,t){var r=this.operator;n.isMemberExpression(e)&&(r="=");var i=void 0;return i=r?n.expressionStatement(n.assignmentExpression(r,e,t)):n.variableDeclaration(this.kind,[n.variableDeclarator(e,t)]),i._blockHoist=this.blockHoist,i},e.prototype.buildVariableDeclaration=function(e,t){var r=n.variableDeclaration("var",[n.variableDeclarator(e,t)]);return r._blockHoist=this.blockHoist,r},e.prototype.push=function(e,t){n.isObjectPattern(e)?this.pushObjectPattern(e,t):n.isArrayPattern(e)?this.pushArrayPattern(e,t):n.isAssignmentPattern(e)?this.pushAssignmentPattern(e,t):this.nodes.push(this.buildVariableAssignment(e,t))},e.prototype.toArray=function(e,t){return this.file.opts.loose||n.isIdentifier(e)&&this.arrays[e.name]?e:this.scope.toArray(e,t)},e.prototype.pushAssignmentPattern=function(e,t){var r=this.scope.generateUidIdentifierBasedOnNode(t),i=n.variableDeclaration("var",[n.variableDeclarator(r,t)]);i._blockHoist=this.blockHoist,this.nodes.push(i);var s=n.conditionalExpression(n.binaryExpression("===",r,n.identifier("undefined")),e.right,r),a=e.left;if(n.isPattern(a)){var o=n.expressionStatement(n.assignmentExpression("=",r,s));o._blockHoist=this.blockHoist,this.nodes.push(o),this.push(a,r)}else this.nodes.push(this.buildVariableAssignment(a,s))},e.prototype.pushObjectRest=function(e,t,r,i){for(var s=[],a=0;a<e.properties.length;a++){var o=e.properties[a];if(a>=i)break;if(!n.isRestProperty(o)){var u=o.key;n.isIdentifier(u)&&!o.computed&&(u=n.stringLiteral(o.key.name)),s.push(u)}}s=n.arrayExpression(s);var l=n.callExpression(this.file.addHelper("objectWithoutProperties"),[t,s]);this.nodes.push(this.buildVariableAssignment(r.argument,l))},e.prototype.pushObjectProperty=function(e,t){n.isLiteral(e.key)&&(e.computed=!0);var r=e.value,i=n.memberExpression(t,e.key,e.computed);n.isPattern(r)?this.push(r,i):this.nodes.push(this.buildVariableAssignment(r,i))},e.prototype.pushObjectPattern=function(e,t){if(e.properties.length||this.nodes.push(n.expressionStatement(n.callExpression(this.file.addHelper("objectDestructuringEmpty"),[t]))),e.properties.length>1&&!this.scope.isStatic(t)){var r=this.scope.generateUidIdentifierBasedOnNode(t);this.nodes.push(this.buildVariableDeclaration(r,t)),t=r}for(var i=0;i<e.properties.length;i++){var s=e.properties[i];n.isRestProperty(s)?this.pushObjectRest(e,t,s,i):this.pushObjectProperty(s,t)}},e.prototype.canUnpackArrayPattern=function(e,t){if(!n.isArrayExpression(t))return!1;if(!(e.elements.length>t.elements.length)){if(e.elements.length<t.elements.length&&!r(e))return!1;for(var s=e.elements,a=Array.isArray(s),u=0,s=a?s:(0,o.default)(s);;){var l;if(a){if(u>=s.length)break;l=s[u++]}else{if(u=s.next(),u.done)break;l=u.value}var c=l;if(!c)return!1;if(n.isMemberExpression(c))return!1}for(var f=t.elements,p=Array.isArray(f),d=0,f=p?f:(0,o.default)(f);;){var h;if(p){if(d>=f.length)break;h=f[d++]}else{if(d=f.next(),d.done)break;h=d.value}var m=h;if(n.isSpreadElement(m))return!1;if(n.isCallExpression(m))return!1;if(n.isMemberExpression(m))return!1}var y=n.getBindingIdentifiers(e),v={deopt:!1,bindings:y};return this.scope.traverse(t,i,v),!v.deopt}},e.prototype.pushUnpackedArrayPattern=function(e,t){for(var r=0;r<e.elements.length;r++){var i=e.elements[r];n.isRestElement(i)?this.push(i.argument,n.arrayExpression(t.elements.slice(r))):this.push(i,t.elements[r])}},e.prototype.pushArrayPattern=function(e,t){if(e.elements){if(this.canUnpackArrayPattern(e,t))return this.pushUnpackedArrayPattern(e,t);var i=!r(e)&&e.elements.length,s=this.toArray(t,i);n.isIdentifier(s)?t=s:(t=this.scope.generateUidIdentifierBasedOnNode(t),this.arrays[t.name]=!0,this.nodes.push(this.buildVariableDeclaration(t,s)));for(var a=0;a<e.elements.length;a++){var o=e.elements[a];if(o){var u=void 0;n.isRestElement(o)?(u=this.toArray(t),u=n.callExpression(n.memberExpression(u,n.identifier("slice")),[n.numericLiteral(a)]),o=o.argument):u=n.memberExpression(t,n.numericLiteral(a),!0),this.push(o,u)}}}},e.prototype.init=function(e,t){if(!n.isArrayExpression(t)&&!n.isMemberExpression(t)){var r=this.scope.maybeGenerateMemoised(t,!0);r&&(this.nodes.push(this.buildVariableDeclaration(r,t)),t=r)}return this.push(e,t),this.nodes},e}();return{visitor:{ExportNamedDeclaration:function(e){var r=e.get("declaration");if(r.isVariableDeclaration()&&t(r.node)){var i=[];for(var s in e.getOuterBindingIdentifiers(e)){var a=n.identifier(s);i.push(n.exportSpecifier(a,a))}e.replaceWith(r.node),e.insertAfter(n.exportNamedDeclaration(null,i))}},ForXStatement:function(e,t){var r=e.node,i=e.scope,s=r.left;if(n.isPattern(s)){var o=i.generateUidIdentifier("ref");return r.left=n.variableDeclaration("var",[n.variableDeclarator(o)]),e.ensureBlock(),void r.body.body.unshift(n.variableDeclaration("var",[n.variableDeclarator(s,o)]))}if(n.isVariableDeclaration(s)){var u=s.declarations[0].id;if(n.isPattern(u)){var l=i.generateUidIdentifier("ref");r.left=n.variableDeclaration(s.kind,[n.variableDeclarator(l,null)]);var c=[];new a({kind:s.kind,file:t,scope:i,nodes:c}).init(u,l),e.ensureBlock();var f=r.body;f.body=c.concat(f.body)}}},CatchClause:function(e,t){var r=e.node,i=e.scope,s=r.param;if(n.isPattern(s)){var o=i.generateUidIdentifier("ref");r.param=o;var u=[];new a({kind:"let",file:t,scope:i,nodes:u}).init(s,o),r.body.body=u.concat(r.body.body)}},AssignmentExpression:function(e,t){var r=e.node,i=e.scope;if(n.isPattern(r.left)){var s=[],o=new a({operator:r.operator,file:t,scope:i,nodes:s}),u=void 0;!e.isCompletionRecord()&&e.parentPath.isExpressionStatement()||(u=i.generateUidIdentifierBasedOnNode(r.right,"ref"),s.push(n.variableDeclaration("var",[n.variableDeclarator(u,r.right)])),n.isArrayExpression(r.right)&&(o.arrays[u.name]=!0)),o.init(r.left,u||r.right),u&&s.push(n.expressionStatement(u)),e.replaceWithMultiple(s)}},VariableDeclaration:function(e,r){var i=e.node,s=e.scope,u=e.parent;if(!n.isForXStatement(u)&&u&&e.container&&t(i)){for(var l=[],c=void 0,f=0;f<i.declarations.length;f++){c=i.declarations[f];var p=c.init,d=c.id,h=new a({blockHoist:i._blockHoist,nodes:l,scope:s,kind:i.kind,file:r});n.isPattern(d)?(h.init(d,p),+f!=i.declarations.length-1&&n.inherits(l[l.length-1],c)):l.push(n.inherits(h.buildVariableAssignment(c.id,c.init),c))}for(var m=[],y=l,v=Array.isArray(y),g=0,y=v?y:(0,o.default)(y);;){var b;if(v){if(g>=y.length)break;b=y[g++]}else{if(g=y.next(),g.done)break;b=g.value}var E=b,x=m[m.length-1];if(x&&n.isVariableDeclaration(x)&&n.isVariableDeclaration(E)&&x.kind===E.kind){var A;(A=x.declarations).push.apply(A,E.declarations)}else m.push(E)}for(var S=m,_=Array.isArray(S),D=0,S=_?S:(0,o.default)(S);;){var C;if(_){if(D>=S.length)break;C=S[D++]}else{if(D=S.next(),D.done)break;C=D.value}var w=C;if(w.declarations)for(var P=w.declarations,k=Array.isArray(P),F=0,P=k?P:(0,o.default)(P);;){var T;if(k){if(F>=P.length)break;T=P[F++]}else{if(F=P.next(),F.done)break;T=F.value}var O=T,B=O.id.name;s.bindings[B]&&(s.bindings[B].kind=w.kind)}}1===m.length?e.replaceWith(m[0]):e.replaceWithMultiple(m)}}}}},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(e){function t(e){var t=e.node,r=e.scope,n=[],i=t.right;if(!a.isIdentifier(i)||!r.hasBinding(i.name)){var s=r.generateUidIdentifier("arr");n.push(a.variableDeclaration("var",[a.variableDeclarator(s,i)])),i=s}var u=r.generateUidIdentifier("i"),l=o({BODY:t.body,KEY:u,ARR:i});a.inherits(l,t),a.ensureBlock(l);var c=a.memberExpression(i,u,!0),f=t.left;return a.isVariableDeclaration(f)?(f.declarations[0].init=c,l.body.body.unshift(f)):l.body.body.unshift(a.expressionStatement(a.assignmentExpression("=",f,c))),e.parentPath.isLabeledStatement()&&(l=a.labeledStatement(e.parentPath.node.label,l)),n.push(l),n}function r(e,t){var r=e.node,n=e.scope,s=e.parent,o=r.left,l=void 0,c=void 0;if(a.isIdentifier(o)||a.isPattern(o)||a.isMemberExpression(o))c=o;else{if(!a.isVariableDeclaration(o))throw t.buildCodeFrameError(o,i.get("unknownForHead",o.type));c=n.generateUidIdentifier("ref"),l=a.variableDeclaration(o.kind,[a.variableDeclarator(o.declarations[0].id,c)])}var f=n.generateUidIdentifier("iterator"),p=n.generateUidIdentifier("isArray"),d=u({LOOP_OBJECT:f,IS_ARRAY:p,OBJECT:r.right,INDEX:n.generateUidIdentifier("i"),ID:c});l||d.body.body.shift();var h=a.isLabeledStatement(s),m=void 0;return h&&(m=a.labeledStatement(s.label,d)),{replaceParent:h,declar:l,node:m||d,loop:d}}function n(e,t){var r=e.node,n=e.scope,s=e.parent,o=r.left,u=void 0,c=n.generateUidIdentifier("step"),f=a.memberExpression(c,a.identifier("value"));if(a.isIdentifier(o)||a.isPattern(o)||a.isMemberExpression(o))u=a.expressionStatement(a.assignmentExpression("=",o,f));else{if(!a.isVariableDeclaration(o))throw t.buildCodeFrameError(o,i.get("unknownForHead",o.type));u=a.variableDeclaration(o.kind,[a.variableDeclarator(o.declarations[0].id,f)])}var p=n.generateUidIdentifier("iterator"),d=l({ITERATOR_HAD_ERROR_KEY:n.generateUidIdentifier("didIteratorError"),ITERATOR_COMPLETION:n.generateUidIdentifier("iteratorNormalCompletion"),ITERATOR_ERROR_KEY:n.generateUidIdentifier("iteratorError"),ITERATOR_KEY:p,STEP_KEY:c,OBJECT:r.right,BODY:null}),h=a.isLabeledStatement(s),m=d[3].block.body,y=m[0];return h&&(m[0]=a.labeledStatement(s.label,y)),{replaceParent:h,declar:u,loop:y,node:d}}var i=e.messages,s=e.template,a=e.types,o=s("\n for (var KEY = 0; KEY < ARR.length; KEY++) BODY;\n "),u=s("\n for (var LOOP_OBJECT = OBJECT,\n IS_ARRAY = Array.isArray(LOOP_OBJECT),\n INDEX = 0,\n LOOP_OBJECT = IS_ARRAY ? LOOP_OBJECT : LOOP_OBJECT[Symbol.iterator]();;) {\n var ID;\n if (IS_ARRAY) {\n if (INDEX >= LOOP_OBJECT.length) break;\n ID = LOOP_OBJECT[INDEX++];\n } else {\n INDEX = LOOP_OBJECT.next();\n if (INDEX.done) break;\n ID = INDEX.value;\n }\n }\n "),l=s("\n var ITERATOR_COMPLETION = true;\n var ITERATOR_HAD_ERROR_KEY = false;\n var ITERATOR_ERROR_KEY = undefined;\n try {\n for (var ITERATOR_KEY = OBJECT[Symbol.iterator](), STEP_KEY; !(ITERATOR_COMPLETION = (STEP_KEY = ITERATOR_KEY.next()).done); ITERATOR_COMPLETION = true) {\n }\n } catch (err) {\n ITERATOR_HAD_ERROR_KEY = true;\n ITERATOR_ERROR_KEY = err;\n } finally {\n try {\n if (!ITERATOR_COMPLETION && ITERATOR_KEY.return) {\n ITERATOR_KEY.return();\n }\n } finally {\n if (ITERATOR_HAD_ERROR_KEY) {\n throw ITERATOR_ERROR_KEY;\n }\n }\n }\n ");return{visitor:{ForOfStatement:function(e,i){if(e.get("right").isArrayExpression())return e.parentPath.isLabeledStatement()?e.parentPath.replaceWithMultiple(t(e)):e.replaceWithMultiple(t(e));var s=n;i.opts.loose&&(s=r);var o=e.node,u=s(e,i),l=u.declar,c=u.loop,f=c.body;e.ensureBlock(),l&&f.body.push(l),f.body=f.body.concat(o.body.body),a.inherits(c,o),a.inherits(c.body,o.body),u.replaceParent?(e.parentPath.replaceWithMultiple(u.node),e.remove()):e.replaceWithMultiple(u.node)}}}},e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(){return{visitor:{FunctionExpression:{exit:function(e){if("value"!==e.key&&!e.parentPath.isObjectProperty()){var t=(0,i.default)(e);t&&e.replaceWith(t)}}},ObjectProperty:function(e){var t=e.get("value");if(t.isFunction()){var r=(0,i.default)(t);r&&t.replaceWith(r)}}}}};var n=r(40),i=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(){return{visitor:{NumericLiteral:function(e){var t=e.node;t.extra&&/^0[ob]/i.test(t.extra.raw)&&(t.extra=void 0)},StringLiteral:function(e){var t=e.node;t.extra&&/\\[u]/gi.test(t.extra.raw)&&(t.extra=void 0)}}}},e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(14),s=n(i),a=r(9),o=n(a),u=r(2),l=n(u),c=r(10),f=n(c);t.default=function(){var e=(0,f.default)(),t={ReferencedIdentifier:function(e){var t=e.node.name,r=this.remaps[t];if(r&&this.scope.getBinding(t)===e.scope.getBinding(t)){if(e.parentPath.isCallExpression({callee:e.node}))e.replaceWith(g.sequenceExpression([g.numericLiteral(0),r]));else if(e.isJSXIdentifier()&&g.isMemberExpression(r)){var n=r.object,i=r.property;e.replaceWith(g.JSXMemberExpression(g.JSXIdentifier(n.name),g.JSXIdentifier(i.name)))}else e.replaceWith(r);this.requeueInParent(e)}},AssignmentExpression:function(t){var r=t.node;if(!r[e]){var n=t.get("left");if(n.isIdentifier()){var i=n.node.name,s=this.exports[i];if(!s)return;if(this.scope.getBinding(i)!==t.scope.getBinding(i))return;r[e]=!0;for(var a=s,o=Array.isArray(a),u=0,a=o?a:(0,l.default)(a);;){var c;if(o){if(u>=a.length)break;c=a[u++]}else{if(u=a.next(),u.done)break;c=u.value}r=S(c,r).expression}t.replaceWith(r),this.requeueInParent(t)}else if(n.isObjectPattern())for(var f=n.node.properties,p=Array.isArray(f),d=0,f=p?f:(0,l.default)(f);;){var h;if(p){if(d>=f.length)break;h=f[d++]}else{if(d=f.next(),d.done)break;h=d.value}var m=h,y=m.value.name,v=this.exports[y];if(v){if(this.scope.getBinding(y)!==t.scope.getBinding(y))return;r[e]=!0,t.insertAfter(S(g.identifier(y),g.identifier(y)))}}else if(n.isArrayPattern())for(var b=n.node.elements,E=Array.isArray(b),x=0,b=E?b:(0,l.default)(b);;){var A;if(E){if(x>=b.length)break;A=b[x++]}else{if(x=b.next(),x.done)break;A=x.value}var _=A;if(_){var D=_.name,C=this.exports[D];if(C){if(this.scope.getBinding(D)!==t.scope.getBinding(D))return;r[e]=!0,t.insertAfter(S(g.identifier(D),g.identifier(D)))}}}}},UpdateExpression:function(e){var t=e.get("argument");if(t.isIdentifier()){var r=t.node.name;if(this.exports[r]&&this.scope.getBinding(r)===e.scope.getBinding(r)){var n=g.assignmentExpression(e.node.operator[0]+"=",t.node,g.numericLiteral(1));if(e.parentPath.isExpressionStatement()&&!e.isCompletionRecord()||e.node.prefix)return e.replaceWith(n),void this.requeueInParent(e);var i=[];i.push(n);var s=void 0;s="--"===e.node.operator?"+":"-",i.push(g.binaryExpression(s,t.node,g.numericLiteral(1))),e.replaceWithMultiple(g.sequenceExpression(i))}}}};return{inherits:y.default,visitor:{ThisExpression:function(e,t){this.ranCommonJS||!0===t.opts.allowTopLevelThis||e.findParent(function(e){return!e.is("shadow")&&D.indexOf(e.type)>=0})||e.replaceWith(g.identifier("undefined"))},Program:{exit:function(e){function r(t,r){var n=C[t];if(n)return n;var i=e.scope.generateUidIdentifier((0,p.basename)(t,(0,p.extname)(t))),s=g.variableDeclaration("var",[g.variableDeclarator(i,b(g.stringLiteral(t)).expression)]);return h[t]&&(s.loc=h[t].loc),"number"==typeof r&&r>0&&(s._blockHoist=r),v.push(s),C[t]=i}function n(e,t,r){var n=e[t]||[];e[t]=n.concat(r)}this.ranCommonJS=!0;var i=!!this.opts.strict,a=!!this.opts.noInterop,u=e.scope;u.rename("module"),u.rename("exports"),u.rename("require");for(var c=!1,f=!1,d=e.get("body"),h=(0,o.default)(null),m=(0,o.default)(null),y=(0,o.default)(null),v=[],D=(0,o.default)(null),C=(0,o.default)(null),w=d,P=Array.isArray(w),k=0,w=P?w:(0,l.default)(w);;){var F;if(P){if(k>=w.length)break;F=w[k++]}else{if(k=w.next(),k.done)break;F=k.value}var T=F;if(T.isExportDeclaration()){c=!0;for(var O=[].concat(T.get("declaration"),T.get("specifiers")),B=O,R=Array.isArray(B),I=0,B=R?B:(0,l.default)(B);;){var M;if(R){if(I>=B.length)break;M=B[I++]}else{if(I=B.next(),I.done)break;M=I.value}var N=M;if(N.getBindingIdentifiers().__esModule)throw N.buildCodeFrameError('Illegal export "__esModule"')}}if(T.isImportDeclaration()){var L;f=!0;var j=T.node.source.value,U=h[j]||{specifiers:[],maxBlockHoist:0,loc:T.node.loc};(L=U.specifiers).push.apply(L,T.node.specifiers),"number"==typeof T.node._blockHoist&&(U.maxBlockHoist=Math.max(T.node._blockHoist,U.maxBlockHoist)),h[j]=U,T.remove()}else if(T.isExportDefaultDeclaration()){var V=T.get("declaration");if(V.isFunctionDeclaration()){var G=V.node.id,W=g.identifier("default");G?(n(m,G.name,W),v.push(S(W,G)),T.replaceWith(V.node)):(v.push(S(W,g.toExpression(V.node))),T.remove())}else if(V.isClassDeclaration()){var Y=V.node.id,q=g.identifier("default");Y?(n(m,Y.name,q),T.replaceWithMultiple([V.node,S(q,Y)])):(T.replaceWith(S(q,g.toExpression(V.node))),T.parentPath.requeue(T.get("expression.left")))}else T.replaceWith(S(g.identifier("default"),V.node)),T.parentPath.requeue(T.get("expression.left"))}else if(T.isExportNamedDeclaration()){var K=T.get("declaration");if(K.node){if(K.isFunctionDeclaration()){var H=K.node.id;n(m,H.name,H),v.push(S(H,H)),T.replaceWith(K.node)}else if(K.isClassDeclaration()){var J=K.node.id;n(m,J.name,J),T.replaceWithMultiple([K.node,S(J,J)]),y[J.name]=!0}else if(K.isVariableDeclaration()){for(var X=K.get("declarations"),z=X,$=Array.isArray(z),Q=0,z=$?z:(0,l.default)(z);;){var Z;if($){if(Q>=z.length)break;Z=z[Q++]}else{if(Q=z.next(),Q.done)break;Z=Q.value}var ee=Z,te=ee.get("id"),re=ee.get("init"),ne=[];if(re.node||re.replaceWith(g.identifier("undefined")),te.isIdentifier())n(m,te.node.name,te.node),re.replaceWith(S(te.node,re.node).expression),y[te.node.name]=!0;else if(te.isObjectPattern())for(var ie=0;ie<te.node.properties.length;ie++){var se=te.node.properties[ie],ae=se.value;g.isAssignmentPattern(ae)?ae=ae.left:g.isRestProperty(se)&&(ae=se.argument),n(m,ae.name,ae),ne.push(S(ae,ae)),y[ae.name]=!0}else if(te.isArrayPattern()&&te.node.elements)for(var oe=0;oe<te.node.elements.length;oe++){var ue=te.node.elements[oe];if(ue){g.isAssignmentPattern(ue)?ue=ue.left:g.isRestElement(ue)&&(ue=ue.argument);var le=ue.name;n(m,le,ue),ne.push(S(ue,ue)),y[le]=!0}}T.insertAfter(ne)}T.replaceWith(K.node)}continue}var ce=T.get("specifiers"),fe=[],pe=T.node.source;if(pe)for(var de=r(pe.value,T.node._blockHoist),he=ce,me=Array.isArray(he),ye=0,he=me?he:(0,l.default)(he);;){var ve;if(me){if(ye>=he.length)break;ve=he[ye++]}else{if(ye=he.next(),ye.done)break;ve=ye.value}var ge=ve;ge.isExportNamespaceSpecifier()||ge.isExportDefaultSpecifier()||ge.isExportSpecifier()&&(a||"default"!==ge.node.local.name?v.push(x(g.stringLiteral(ge.node.exported.name),g.memberExpression(de,ge.node.local))):v.push(x(g.stringLiteral(ge.node.exported.name),g.memberExpression(g.callExpression(this.addHelper("interopRequireDefault"),[de]),ge.node.local))),y[ge.node.exported.name]=!0)}else for(var be=ce,Ee=Array.isArray(be),xe=0,be=Ee?be:(0,l.default)(be);;){var Ae;if(Ee){if(xe>=be.length)break;Ae=be[xe++]}else{if(xe=be.next(),xe.done)break;Ae=xe.value}var Se=Ae;Se.isExportSpecifier()&&(n(m,Se.node.local.name,Se.node.exported),y[Se.node.exported.name]=!0,fe.push(S(Se.node.exported,Se.node.local)))}T.replaceWithMultiple(fe)}else if(T.isExportAllDeclaration()){var _e=_({OBJECT:r(T.node.source.value,T.node._blockHoist)});_e.loc=T.node.loc,v.push(_e),T.remove()}}for(var De in h){var Ce=h[De],O=Ce.specifiers,we=Ce.maxBlockHoist;if(O.length){for(var Pe=r(De,we),ke=void 0,Fe=0;Fe<O.length;Fe++){var Te=O[Fe];if(g.isImportNamespaceSpecifier(Te)){if(i||a)D[Te.local.name]=Pe;else{var Oe=g.variableDeclaration("var",[g.variableDeclarator(Te.local,g.callExpression(this.addHelper("interopRequireWildcard"),[Pe]))]);we>0&&(Oe._blockHoist=we),v.push(Oe)}ke=Te.local}else g.isImportDefaultSpecifier(Te)&&(O[Fe]=g.importSpecifier(Te.local,g.identifier("default")))}for(var Be=O,Re=Array.isArray(Be),Ie=0,Be=Re?Be:(0,l.default)(Be);;){var Me;if(Re){if(Ie>=Be.length)break;Me=Be[Ie++]}else{if(Ie=Be.next(),Ie.done)break;Me=Ie.value}var Ne=Me;if(g.isImportSpecifier(Ne)){var Le=Pe;if("default"===Ne.imported.name)if(ke)Le=ke;else if(!a){Le=ke=e.scope.generateUidIdentifier(Pe.name);var je=g.variableDeclaration("var",[g.variableDeclarator(Le,g.callExpression(this.addHelper("interopRequireDefault"),[Pe]))]);we>0&&(je._blockHoist=we),v.push(je)}D[Ne.local.name]=g.memberExpression(Le,g.cloneWithoutLoc(Ne.imported))}}}else{var Ue=b(g.stringLiteral(De));Ue.loc=h[De].loc,v.push(Ue)}}if(f&&(0,s.default)(y).length)for(var Ve=(0,s.default)(y),Ge=0;Ge<Ve.length;Ge+=100)!function(e){var t=Ve.slice(e,e+100),r=g.identifier("undefined");t.forEach(function(e){r=S(g.identifier(e),r).expression});var n=g.expressionStatement(r);n._blockHoist=3,v.unshift(n)}(Ge);if(c&&!i){var We=E;this.opts.loose&&(We=A);var Ye=We();Ye._blockHoist=3,v.unshift(Ye)}e.unshiftContainer("body",v),e.traverse(t,{remaps:D,scope:u,exports:m,requeueInParent:function(t){return e.requeue(t)}})}}}}};var p=r(19),d=r(4),h=n(d),m=r(216),y=n(m),v=r(1),g=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(v),b=(0,h.default)("\n require($0);\n"),E=(0,h.default)('\n Object.defineProperty(exports, "__esModule", {\n value: true\n });\n'),x=(0,h.default)("\n Object.defineProperty(exports, $0, {\n enumerable: true,\n get: function () {\n return $1;\n }\n });\n"),A=(0,h.default)("\n exports.__esModule = true;\n"),S=(0,h.default)("\n exports.$0 = $1;\n"),_=(0,h.default)('\n Object.keys(OBJECT).forEach(function (key) {\n if (key === "default" || key === "__esModule") return;\n Object.defineProperty(exports, key, {\n enumerable: true,\n get: function () {\n return OBJECT[key];\n }\n });\n });\n'),D=["FunctionExpression","FunctionDeclaration","ClassProperty","ClassMethod","ObjectMethod"];e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(2),s=n(i),a=r(10),o=n(a);t.default=function(e){function t(e,t,r,n,i){new l.default({getObjectRef:n,methodNode:t,methodPath:e,isStatic:!0,scope:r,file:i}).replace()}var r=e.types,n=(0,o.default)();return{visitor:{Super:function(e){var t=e.findParent(function(e){return e.isObjectExpression()});t&&(t.node[n]=!0)},ObjectExpression:{exit:function(e,i){if(e.node[n]){for(var a=void 0,o=function(){return a=a||e.scope.generateUidIdentifier("obj")},u=e.get("properties"),l=u,c=Array.isArray(l),f=0,l=c?l:(0,s.default)(l);;){var p;if(c){if(f>=l.length)break;p=l[f++]}else{if(f=l.next(),f.done)break;p=f.value}var d=p;d.isObjectProperty()&&(d=d.get("value")),t(d,d.node,e.scope,o,i)}a&&(e.scope.push({id:a}),e.replaceWith(r.assignmentExpression("=",a,e.node)))}}}}}};var u=r(193),l=n(u);e.exports=t.default},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}t.__esModule=!0;var i=r(2),s=function(e){return e&&e.__esModule?e:{default:e}}(i);t.default=function(){return{visitor:a.visitors.merge([{ArrowFunctionExpression:function(e){for(var t=e.get("params"),r=t,n=Array.isArray(r),i=0,r=n?r:(0,s.default)(r);;){var a;if(n){if(i>=r.length)break;a=r[i++]}else{if(i=r.next(),i.done)break;a=i.value}var o=a;if(o.isRestElement()||o.isAssignmentPattern()){e.arrowFunctionToShadowed();break}}}},u.visitor,p.visitor,c.visitor])}};var a=r(7),o=r(334),u=n(o),l=r(333),c=n(l),f=r(335),p=n(f);e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(){return{visitor:{ObjectMethod:function(e){var t=e.node;if("method"===t.kind){var r=i.functionExpression(null,t.params,t.body,t.generator,t.async);r.returnType=t.returnType,e.replaceWith(i.objectProperty(t.key,r,t.computed))}},ObjectProperty:function(e){var t=e.node;t.shorthand&&(t.shorthand=!1)}}}};var n=r(1),i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(n);e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0;var n=r(2),i=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=function(e){function t(e,t,r){return r.opts.loose&&!s.isIdentifier(e.argument,{name:"arguments"})?e.argument:t.toArray(e.argument,!0)}function r(e){for(var t=0;t<e.length;t++)if(s.isSpreadElement(e[t]))return!0;return!1}function n(e,r,n){function a(){u.length&&(o.push(s.arrayExpression(u)),u=[])}for(var o=[],u=[],l=e,c=Array.isArray(l),f=0,l=c?l:(0,i.default)(l);;){var p;if(c){if(f>=l.length)break;p=l[f++]}else{if(f=l.next(),f.done)break;p=f.value}var d=p;s.isSpreadElement(d)?(a(),o.push(t(d,r,n))):u.push(d)}return a(),o}var s=e.types;return{visitor:{ArrayExpression:function(e,t){var i=e.node,a=e.scope,o=i.elements;if(r(o)){var u=n(o,a,t),l=u.shift();s.isArrayExpression(l)||(u.unshift(l),l=s.arrayExpression([])),e.replaceWith(s.callExpression(s.memberExpression(l,s.identifier("concat")),u))}},CallExpression:function(e,t){var i=e.node,a=e.scope,o=i.arguments;if(r(o)){var u=e.get("callee");if(!u.isSuper()){var l=s.identifier("undefined");i.arguments=[];var c=void 0;c=1===o.length&&"arguments"===o[0].argument.name?[o[0].argument]:n(o,a,t);var f=c.shift();c.length?i.arguments.push(s.callExpression(s.memberExpression(f,s.identifier("concat")),c)):i.arguments.push(f);var p=i.callee;if(u.isMemberExpression()){var d=a.maybeGenerateMemoised(p.object);d?(p.object=s.assignmentExpression("=",d,p.object),l=d):l=p.object,s.appendToMemberExpression(p,s.identifier("apply"))}else i.callee=s.memberExpression(i.callee,s.identifier("apply"));s.isSuper(l)&&(l=s.thisExpression()),i.arguments.unshift(l)}}},NewExpression:function(e,t){var i=e.node,a=e.scope,o=i.arguments;if(r(o)){var u=n(o,a,t),l=s.arrayExpression([s.nullLiteral()]);o=s.callExpression(s.memberExpression(l,s.identifier("concat")),u),e.replaceWith(s.newExpression(s.callExpression(s.memberExpression(s.memberExpression(s.memberExpression(s.identifier("Function"),s.identifier("prototype")),s.identifier("bind")),s.identifier("apply")),[i.callee,o]),[]))}}}}},e.exports=t.default},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}t.__esModule=!0,t.default=function(){return{visitor:{RegExpLiteral:function(e){var t=e.node;s.is(t,"y")&&e.replaceWith(o.newExpression(o.identifier("RegExp"),[o.stringLiteral(t.pattern),o.stringLiteral(t.flags)]))}}}};var i=r(192),s=n(i),a=r(1),o=n(a);e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0;var n=r(2),i=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=function(e){function t(e){return n.isLiteral(e)&&"string"==typeof e.value}function r(e,t){return n.binaryExpression("+",e,t)}var n=e.types;return{visitor:{TaggedTemplateExpression:function(e,t){for(var r=e.node,s=r.quasi,a=[],o=[],u=[],l=s.quasis,c=Array.isArray(l),f=0,l=c?l:(0,i.default)(l);;){var p;if(c){if(f>=l.length)break;p=l[f++]}else{if(f=l.next(),f.done)break;p=f.value}var d=p;o.push(n.stringLiteral(d.value.cooked)),u.push(n.stringLiteral(d.value.raw))}o=n.arrayExpression(o),u=n.arrayExpression(u);var h="taggedTemplateLiteral";t.opts.loose&&(h+="Loose");var m=t.file.addTemplateObject(h,o,u);a.push(m),a=a.concat(s.expressions),e.replaceWith(n.callExpression(r.tag,a))},TemplateLiteral:function(e,s){for(var a=[],o=e.get("expressions"),u=e.node.quasis,l=Array.isArray(u),c=0,u=l?u:(0,i.default)(u);;){var f;if(l){if(c>=u.length)break;f=u[c++]}else{if(c=u.next(),c.done)break;f=c.value}var p=f;a.push(n.stringLiteral(p.value.cooked));var d=o.shift();d&&(!s.opts.spec||d.isBaseType("string")||d.isBaseType("number")?a.push(d.node):a.push(n.callExpression(n.identifier("String"),[d.node])))}if(a=a.filter(function(e){return!n.isLiteral(e,{value:""})}),t(a[0])||t(a[1])||a.unshift(n.stringLiteral("")),a.length>1){for(var h=r(a.shift(),a.shift()),m=a,y=Array.isArray(m),v=0,m=y?m:(0,i.default)(m);;){var g;if(y){if(v>=m.length)break;g=m[v++]}else{if(v=m.next(),v.done)break;g=v.value}h=r(h,g)}e.replaceWith(h)}else e.replaceWith(a[0])}}}},e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0;var n=r(10),i=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=function(e){var t=e.types,r=(0,i.default)();return{visitor:{Scope:function(e){var t=e.scope;t.getBinding("Symbol")&&t.rename("Symbol")},UnaryExpression:function(e){var n=e.node,i=e.parent;if(!n[r]&&!e.find(function(e){return e.node&&!!e.node._generated})){if(e.parentPath.isBinaryExpression()&&t.EQUALITY_BINARY_OPERATORS.indexOf(i.operator)>=0){var s=e.getOpposite();if(s.isLiteral()&&"symbol"!==s.node.value&&"object"!==s.node.value)return}if("typeof"===n.operator){var a=t.callExpression(this.addHelper("typeof"),[n.argument]);if(e.get("argument").isIdentifier()){var o=t.stringLiteral("undefined"),u=t.unaryExpression("typeof",n.argument);u[r]=!0,e.replaceWith(t.conditionalExpression(t.binaryExpression("===",u,o),o,a))}else e.replaceWith(a)}}}}}},e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(){return{visitor:{RegExpLiteral:function(e){var t=e.node;a.is(t,"u")&&(t.pattern=(0,i.default)(t.pattern,t.flags),a.pullFlag(t,"u"))}}}};var n=r(612),i=function(e){return e&&e.__esModule?e:{default:e}}(n),s=r(192),a=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(s);e.exports=t.default},function(e,t,r){"use strict";e.exports=r(606)},function(e,t,r){"use strict";e.exports={default:r(408),__esModule:!0}},function(e,t,r){"use strict";function n(){i(),s()}function i(){t.path=u=new o.default}function s(){t.scope=l=new o.default}t.__esModule=!0,t.scope=t.path=void 0;var a=r(364),o=function(e){return e&&e.__esModule?e:{default:e}}(a);t.clear=n,t.clearPath=i,t.clearScope=s;var u=t.path=new o.default,l=t.scope=new o.default},function(e,t){"use strict";function r(e){return e=e.split(" "),function(t){return e.indexOf(t)>=0}}function n(e,t){for(var r=65536,n=0;n<t.length;n+=2){if((r+=t[n])>e)return!1;if((r+=t[n+1])>=e)return!0}}function i(e){return e<65?36===e:e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&x.test(String.fromCharCode(e)):n(e,S)))}function s(e){return e<48?36===e:e<58||!(e<65)&&(e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&A.test(String.fromCharCode(e)):n(e,S)||n(e,_))))}function a(e){var t={};for(var r in D)t[r]=e&&r in e?e[r]:D[r];return t}function o(e){return 10===e||13===e||8232===e||8233===e}function u(e,t){for(var r=1,n=0;;){N.lastIndex=n;var i=N.exec(e);if(!(i&&i.index<t))return new V(r,t-n);++r,n=i.index+i[0].length}}function l(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(55296+(e-65536>>10),56320+(e-65536&1023))}function c(e,t,r,n){return e.type=t,e.end=r,e.loc.end=n,this.processComment(e),e}function f(e){return e[e.length-1]}function p(e){return e&&"Property"===e.type&&"init"===e.kind&&!1===e.method}function d(e){return"JSXIdentifier"===e.type?e.name:"JSXNamespacedName"===e.type?e.namespace.name+":"+e.name.name:"JSXMemberExpression"===e.type?d(e.object)+"."+d(e.property):void 0}function h(e,t){return new J(t,e).parse()}function m(e,t){var r=new J(t,e);return r.options.strictMode&&(r.state.strict=!0),r.getExpression()}var y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.defineProperty(t,"__esModule",{value:!0});var v={6:r("enum await"),strict:r("implements interface let package private protected public static yield"),strictBind:r("eval arguments") +},g=r("break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this let const class extends export import yield super"),b="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠ-ࢴࢶ-ࢽऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿕ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞮꞰ-ꞷꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭥꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",E="·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣔ-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఃా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ഁ-ഃാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ංඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ູົຼ່-ໍ໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠐-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭ᳲ-᳴᳸᳹᷀-᷵᷻-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱꤀-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_",x=new RegExp("["+b+"]"),A=new RegExp("["+b+E+"]");b=E=null;var S=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,17,26,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,26,45,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,785,52,76,44,33,24,27,35,42,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,25,391,63,32,0,449,56,264,8,2,36,18,0,50,29,881,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,881,68,12,0,67,12,65,0,32,6124,20,754,9486,1,3071,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,10591,541],_=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,1306,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,52,0,13,2,49,13,10,2,4,9,83,11,7,0,161,11,6,9,7,3,57,0,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,87,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,423,9,838,7,2,7,17,9,57,21,2,13,19882,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239],D={sourceType:"script",sourceFilename:void 0,startLine:1,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowSuperOutsideMethod:!1,plugins:[],strictMode:null},C="function"==typeof Symbol&&"symbol"===y(Symbol.iterator)?function(e){return void 0===e?"undefined":y(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":y(e)},w=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},P=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":y(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},k=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":y(t))&&"function"!=typeof t?e:t},F=!0,T=function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};w(this,e),this.label=t,this.keyword=r.keyword,this.beforeExpr=!!r.beforeExpr,this.startsExpr=!!r.startsExpr,this.rightAssociative=!!r.rightAssociative,this.isLoop=!!r.isLoop,this.isAssign=!!r.isAssign,this.prefix=!!r.prefix,this.postfix=!!r.postfix,this.binop=r.binop||null,this.updateContext=null},O=function(e){function t(r){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return w(this,t),n.keyword=r,k(this,e.call(this,r,n))}return P(t,e),t}(T),B=function(e){function t(r,n){return w(this,t),k(this,e.call(this,r,{beforeExpr:F,binop:n}))}return P(t,e),t}(T),R={num:new T("num",{startsExpr:!0}),regexp:new T("regexp",{startsExpr:!0}),string:new T("string",{startsExpr:!0}),name:new T("name",{startsExpr:!0}),eof:new T("eof"),bracketL:new T("[",{beforeExpr:F,startsExpr:!0}),bracketR:new T("]"),braceL:new T("{",{beforeExpr:F,startsExpr:!0}),braceBarL:new T("{|",{beforeExpr:F,startsExpr:!0}),braceR:new T("}"),braceBarR:new T("|}"),parenL:new T("(",{beforeExpr:F,startsExpr:!0}),parenR:new T(")"),comma:new T(",",{beforeExpr:F}),semi:new T(";",{beforeExpr:F}),colon:new T(":",{beforeExpr:F}),doubleColon:new T("::",{beforeExpr:F}),dot:new T("."),question:new T("?",{beforeExpr:F}),arrow:new T("=>",{beforeExpr:F}),template:new T("template"),ellipsis:new T("...",{beforeExpr:F}),backQuote:new T("`",{startsExpr:!0}),dollarBraceL:new T("${",{beforeExpr:F,startsExpr:!0}),at:new T("@"),eq:new T("=",{beforeExpr:F,isAssign:!0}),assign:new T("_=",{beforeExpr:F,isAssign:!0}),incDec:new T("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new T("prefix",{beforeExpr:F,prefix:!0,startsExpr:!0}),logicalOR:new B("||",1),logicalAND:new B("&&",2),bitwiseOR:new B("|",3),bitwiseXOR:new B("^",4),bitwiseAND:new B("&",5),equality:new B("==/!=",6),relational:new B("</>",7),bitShift:new B("<</>>",8),plusMin:new T("+/-",{beforeExpr:F,binop:9,prefix:!0,startsExpr:!0}),modulo:new B("%",10),star:new B("*",10),slash:new B("/",10),exponent:new T("**",{beforeExpr:F,binop:11,rightAssociative:!0})},I={break:new O("break"),case:new O("case",{beforeExpr:F}),catch:new O("catch"),continue:new O("continue"),debugger:new O("debugger"),default:new O("default",{beforeExpr:F}),do:new O("do",{isLoop:!0,beforeExpr:F}),else:new O("else",{beforeExpr:F}),finally:new O("finally"),for:new O("for",{isLoop:!0}),function:new O("function",{startsExpr:!0}),if:new O("if"),return:new O("return",{beforeExpr:F}),switch:new O("switch"),throw:new O("throw",{beforeExpr:F}),try:new O("try"),var:new O("var"),let:new O("let"),const:new O("const"),while:new O("while",{isLoop:!0}),with:new O("with"),new:new O("new",{beforeExpr:F,startsExpr:!0}),this:new O("this",{startsExpr:!0}),super:new O("super",{startsExpr:!0}),class:new O("class"),extends:new O("extends",{beforeExpr:F}),export:new O("export"),import:new O("import",{startsExpr:!0}),yield:new O("yield",{beforeExpr:F,startsExpr:!0}),null:new O("null",{startsExpr:!0}),true:new O("true",{startsExpr:!0}),false:new O("false",{startsExpr:!0}),in:new O("in",{beforeExpr:F,binop:7}),instanceof:new O("instanceof",{beforeExpr:F,binop:7}),typeof:new O("typeof",{beforeExpr:F,prefix:!0,startsExpr:!0}),void:new O("void",{beforeExpr:F,prefix:!0,startsExpr:!0}),delete:new O("delete",{beforeExpr:F,prefix:!0,startsExpr:!0})};Object.keys(I).forEach(function(e){R["_"+e]=I[e]});var M=/\r\n?|\n|\u2028|\u2029/,N=new RegExp(M.source,"g"),L=/[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/,j=function e(t,r,n,i){w(this,e),this.token=t,this.isExpr=!!r,this.preserveSpace=!!n,this.override=i},U={braceStatement:new j("{",!1),braceExpression:new j("{",!0),templateQuasi:new j("${",!0),parenStatement:new j("(",!1),parenExpression:new j("(",!0),template:new j("`",!0,!0,function(e){return e.readTmplToken()}),functionExpression:new j("function",!0)};R.parenR.updateContext=R.braceR.updateContext=function(){if(1===this.state.context.length)return void(this.state.exprAllowed=!0);var e=this.state.context.pop();e===U.braceStatement&&this.curContext()===U.functionExpression?(this.state.context.pop(),this.state.exprAllowed=!1):e===U.templateQuasi?this.state.exprAllowed=!0:this.state.exprAllowed=!e.isExpr},R.name.updateContext=function(e){this.state.exprAllowed=!1,e!==R._let&&e!==R._const&&e!==R._var||M.test(this.input.slice(this.state.end))&&(this.state.exprAllowed=!0)},R.braceL.updateContext=function(e){this.state.context.push(this.braceIsBlock(e)?U.braceStatement:U.braceExpression),this.state.exprAllowed=!0},R.dollarBraceL.updateContext=function(){this.state.context.push(U.templateQuasi),this.state.exprAllowed=!0},R.parenL.updateContext=function(e){var t=e===R._if||e===R._for||e===R._with||e===R._while;this.state.context.push(t?U.parenStatement:U.parenExpression),this.state.exprAllowed=!0},R.incDec.updateContext=function(){},R._function.updateContext=function(){this.curContext()!==U.braceStatement&&this.state.context.push(U.functionExpression),this.state.exprAllowed=!1},R.backQuote.updateContext=function(){this.curContext()===U.template?this.state.context.pop():this.state.context.push(U.template),this.state.exprAllowed=!1};var V=function e(t,r){w(this,e),this.line=t,this.column=r},G=function e(t,r){w(this,e),this.start=t,this.end=r},W=function(){function e(){w(this,e)}return e.prototype.init=function(e,t){return this.strict=!1!==e.strictMode&&"module"===e.sourceType,this.input=t,this.potentialArrowAt=-1,this.inMethod=this.inFunction=this.inGenerator=this.inAsync=this.inPropertyName=this.inType=this.inClassProperty=this.noAnonFunctionType=!1,this.labels=[],this.decorators=[],this.tokens=[],this.comments=[],this.trailingComments=[],this.leadingComments=[],this.commentStack=[],this.pos=this.lineStart=0,this.curLine=e.startLine,this.type=R.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=[U.braceStatement],this.exprAllowed=!0,this.containsEsc=this.containsOctal=!1,this.octalPosition=null,this.invalidTemplateEscapePosition=null,this.exportedIdentifiers=[],this},e.prototype.curPosition=function(){return new V(this.curLine,this.pos-this.lineStart)},e.prototype.clone=function(t){var r=new e;for(var n in this){var i=this[n];t&&"context"!==n||!Array.isArray(i)||(i=i.slice()),r[n]=i}return r},e}(),Y=function e(t){w(this,e),this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,this.loc=new G(t.startLoc,t.endLoc)},q=function(){function e(t,r){w(this,e),this.state=new W,this.state.init(t,r)}return e.prototype.next=function(){this.isLookahead||this.state.tokens.push(new Y(this.state)),this.state.lastTokEnd=this.state.end,this.state.lastTokStart=this.state.start,this.state.lastTokEndLoc=this.state.endLoc,this.state.lastTokStartLoc=this.state.startLoc,this.nextToken()},e.prototype.eat=function(e){return!!this.match(e)&&(this.next(),!0)},e.prototype.match=function(e){return this.state.type===e},e.prototype.isKeyword=function(e){return g(e)},e.prototype.lookahead=function(){var e=this.state;this.state=e.clone(!0),this.isLookahead=!0,this.next(),this.isLookahead=!1;var t=this.state.clone(!0);return this.state=e,t},e.prototype.setStrict=function(e){if(this.state.strict=e,this.match(R.num)||this.match(R.string)){for(this.state.pos=this.state.start;this.state.pos<this.state.lineStart;)this.state.lineStart=this.input.lastIndexOf("\n",this.state.lineStart-2)+1,--this.state.curLine;this.nextToken()}},e.prototype.curContext=function(){return this.state.context[this.state.context.length-1]},e.prototype.nextToken=function(){var e=this.curContext();return e&&e.preserveSpace||this.skipSpace(),this.state.containsOctal=!1,this.state.octalPosition=null,this.state.start=this.state.pos,this.state.startLoc=this.state.curPosition(),this.state.pos>=this.input.length?this.finishToken(R.eof):e.override?e.override(this):this.readToken(this.fullCharCodeAtPos())},e.prototype.readToken=function(e){return i(e)||92===e?this.readWord():this.getTokenFromCode(e)},e.prototype.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.state.pos);return e<=55295||e>=57344?e:(e<<10)+this.input.charCodeAt(this.state.pos+1)-56613888},e.prototype.pushComment=function(e,t,r,n,i,s){var a={type:e?"CommentBlock":"CommentLine",value:t,start:r,end:n,loc:new G(i,s)};this.isLookahead||(this.state.tokens.push(a),this.state.comments.push(a),this.addComment(a))},e.prototype.skipBlockComment=function(){var e=this.state.curPosition(),t=this.state.pos,r=this.input.indexOf("*/",this.state.pos+=2);-1===r&&this.raise(this.state.pos-2,"Unterminated comment"),this.state.pos=r+2,N.lastIndex=t;for(var n=void 0;(n=N.exec(this.input))&&n.index<this.state.pos;)++this.state.curLine,this.state.lineStart=n.index+n[0].length;this.pushComment(!0,this.input.slice(t+2,r),t,this.state.pos,e,this.state.curPosition())},e.prototype.skipLineComment=function(e){for(var t=this.state.pos,r=this.state.curPosition(),n=this.input.charCodeAt(this.state.pos+=e);this.state.pos<this.input.length&&10!==n&&13!==n&&8232!==n&&8233!==n;)++this.state.pos,n=this.input.charCodeAt(this.state.pos);this.pushComment(!1,this.input.slice(t+e,this.state.pos),t,this.state.pos,r,this.state.curPosition())},e.prototype.skipSpace=function(){e:for(;this.state.pos<this.input.length;){var e=this.input.charCodeAt(this.state.pos);switch(e){case 32:case 160:++this.state.pos;break;case 13:10===this.input.charCodeAt(this.state.pos+1)&&++this.state.pos;case 10:case 8232:case 8233:++this.state.pos,++this.state.curLine,this.state.lineStart=this.state.pos;break;case 47:switch(this.input.charCodeAt(this.state.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(!(e>8&&e<14||e>=5760&&L.test(String.fromCharCode(e))))break e;++this.state.pos}}},e.prototype.finishToken=function(e,t){this.state.end=this.state.pos,this.state.endLoc=this.state.curPosition();var r=this.state.type;this.state.type=e,this.state.value=t,this.updateContext(r)},e.prototype.readToken_dot=function(){var e=this.input.charCodeAt(this.state.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.state.pos+2);return 46===e&&46===t?(this.state.pos+=3,this.finishToken(R.ellipsis)):(++this.state.pos,this.finishToken(R.dot))},e.prototype.readToken_slash=function(){return this.state.exprAllowed?(++this.state.pos,this.readRegexp()):61===this.input.charCodeAt(this.state.pos+1)?this.finishOp(R.assign,2):this.finishOp(R.slash,1)},e.prototype.readToken_mult_modulo=function(e){var t=42===e?R.star:R.modulo,r=1,n=this.input.charCodeAt(this.state.pos+1);return 42===n&&(r++,n=this.input.charCodeAt(this.state.pos+2),t=R.exponent),61===n&&(r++,t=R.assign),this.finishOp(t,r)},e.prototype.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.state.pos+1);return t===e?this.finishOp(124===e?R.logicalOR:R.logicalAND,2):61===t?this.finishOp(R.assign,2):124===e&&125===t&&this.hasPlugin("flow")?this.finishOp(R.braceBarR,2):this.finishOp(124===e?R.bitwiseOR:R.bitwiseAND,1)},e.prototype.readToken_caret=function(){return 61===this.input.charCodeAt(this.state.pos+1)?this.finishOp(R.assign,2):this.finishOp(R.bitwiseXOR,1)},e.prototype.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.state.pos+1);return t===e?45===t&&62===this.input.charCodeAt(this.state.pos+2)&&M.test(this.input.slice(this.state.lastTokEnd,this.state.pos))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(R.incDec,2):61===t?this.finishOp(R.assign,2):this.finishOp(R.plusMin,1)},e.prototype.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.state.pos+1),r=1;return t===e?(r=62===e&&62===this.input.charCodeAt(this.state.pos+2)?3:2,61===this.input.charCodeAt(this.state.pos+r)?this.finishOp(R.assign,r+1):this.finishOp(R.bitShift,r)):33===t&&60===e&&45===this.input.charCodeAt(this.state.pos+2)&&45===this.input.charCodeAt(this.state.pos+3)?(this.inModule&&this.unexpected(),this.skipLineComment(4),this.skipSpace(),this.nextToken()):(61===t&&(r=2),this.finishOp(R.relational,r))},e.prototype.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.state.pos+1);return 61===t?this.finishOp(R.equality,61===this.input.charCodeAt(this.state.pos+2)?3:2):61===e&&62===t?(this.state.pos+=2,this.finishToken(R.arrow)):this.finishOp(61===e?R.eq:R.prefix,1)},e.prototype.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.state.pos,this.finishToken(R.parenL);case 41:return++this.state.pos,this.finishToken(R.parenR);case 59:return++this.state.pos,this.finishToken(R.semi);case 44:return++this.state.pos,this.finishToken(R.comma);case 91:return++this.state.pos,this.finishToken(R.bracketL);case 93:return++this.state.pos,this.finishToken(R.bracketR);case 123:return this.hasPlugin("flow")&&124===this.input.charCodeAt(this.state.pos+1)?this.finishOp(R.braceBarL,2):(++this.state.pos,this.finishToken(R.braceL));case 125:return++this.state.pos,this.finishToken(R.braceR);case 58:return this.hasPlugin("functionBind")&&58===this.input.charCodeAt(this.state.pos+1)?this.finishOp(R.doubleColon,2):(++this.state.pos,this.finishToken(R.colon));case 63:return++this.state.pos,this.finishToken(R.question);case 64:return++this.state.pos,this.finishToken(R.at);case 96:return++this.state.pos,this.finishToken(R.backQuote);case 48:var t=this.input.charCodeAt(this.state.pos+1);if(120===t||88===t)return this.readRadixNumber(16);if(111===t||79===t)return this.readRadixNumber(8);if(98===t||66===t)return this.readRadixNumber(2);case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 126:return this.finishOp(R.prefix,1)}this.raise(this.state.pos,"Unexpected character '"+l(e)+"'")},e.prototype.finishOp=function(e,t){var r=this.input.slice(this.state.pos,this.state.pos+t);return this.state.pos+=t,this.finishToken(e,r)},e.prototype.readRegexp=function(){for(var e=this.state.pos,t=void 0,r=void 0;;){this.state.pos>=this.input.length&&this.raise(e,"Unterminated regular expression");var n=this.input.charAt(this.state.pos);if(M.test(n)&&this.raise(e,"Unterminated regular expression"),t)t=!1;else{if("["===n)r=!0;else if("]"===n&&r)r=!1;else if("/"===n&&!r)break;t="\\"===n}++this.state.pos}var i=this.input.slice(e,this.state.pos);++this.state.pos;var s=this.readWord1();if(s){/^[gmsiyu]*$/.test(s)||this.raise(e,"Invalid regular expression flag")}return this.finishToken(R.regexp,{pattern:i,flags:s})},e.prototype.readInt=function(e,t){for(var r=this.state.pos,n=0,i=0,s=null==t?1/0:t;i<s;++i){var a=this.input.charCodeAt(this.state.pos),o=void 0;if((o=a>=97?a-97+10:a>=65?a-65+10:a>=48&&a<=57?a-48:1/0)>=e)break;++this.state.pos,n=n*e+o}return this.state.pos===r||null!=t&&this.state.pos-r!==t?null:n},e.prototype.readRadixNumber=function(e){this.state.pos+=2;var t=this.readInt(e);return null==t&&this.raise(this.state.start+2,"Expected number in radix "+e),i(this.fullCharCodeAtPos())&&this.raise(this.state.pos,"Identifier directly after number"),this.finishToken(R.num,t)},e.prototype.readNumber=function(e){var t=this.state.pos,r=48===this.input.charCodeAt(t),n=!1;e||null!==this.readInt(10)||this.raise(t,"Invalid number"),r&&this.state.pos==t+1&&(r=!1);var s=this.input.charCodeAt(this.state.pos);46!==s||r||(++this.state.pos,this.readInt(10),n=!0,s=this.input.charCodeAt(this.state.pos)),69!==s&&101!==s||r||(s=this.input.charCodeAt(++this.state.pos),43!==s&&45!==s||++this.state.pos,null===this.readInt(10)&&this.raise(t,"Invalid number"),n=!0),i(this.fullCharCodeAtPos())&&this.raise(this.state.pos,"Identifier directly after number");var a=this.input.slice(t,this.state.pos),o=void 0;return n?o=parseFloat(a):r&&1!==a.length?this.state.strict?this.raise(t,"Invalid number"):o=/[89]/.test(a)?parseInt(a,10):parseInt(a,8):o=parseInt(a,10),this.finishToken(R.num,o)},e.prototype.readCodePoint=function(e){var t=this.input.charCodeAt(this.state.pos),r=void 0;if(123===t){var n=++this.state.pos;if(r=this.readHexChar(this.input.indexOf("}",this.state.pos)-this.state.pos,e),++this.state.pos,null===r)--this.state.invalidTemplateEscapePosition;else if(r>1114111){if(!e)return this.state.invalidTemplateEscapePosition=n-2,null;this.raise(n,"Code point out of bounds")}}else r=this.readHexChar(4,e);return r},e.prototype.readString=function(e){for(var t="",r=++this.state.pos;;){this.state.pos>=this.input.length&&this.raise(this.state.start,"Unterminated string constant");var n=this.input.charCodeAt(this.state.pos);if(n===e)break;92===n?(t+=this.input.slice(r,this.state.pos),t+=this.readEscapedChar(!1),r=this.state.pos):(o(n)&&this.raise(this.state.start,"Unterminated string constant"),++this.state.pos)}return t+=this.input.slice(r,this.state.pos++),this.finishToken(R.string,t)},e.prototype.readTmplToken=function(){for(var e="",t=this.state.pos,r=!1;;){this.state.pos>=this.input.length&&this.raise(this.state.start,"Unterminated template");var n=this.input.charCodeAt(this.state.pos);if(96===n||36===n&&123===this.input.charCodeAt(this.state.pos+1))return this.state.pos===this.state.start&&this.match(R.template)?36===n?(this.state.pos+=2,this.finishToken(R.dollarBraceL)):(++this.state.pos,this.finishToken(R.backQuote)):(e+=this.input.slice(t,this.state.pos),this.finishToken(R.template,r?null:e));if(92===n){e+=this.input.slice(t,this.state.pos);var i=this.readEscapedChar(!0);null===i?r=!0:e+=i,t=this.state.pos}else if(o(n)){switch(e+=this.input.slice(t,this.state.pos),++this.state.pos,n){case 13:10===this.input.charCodeAt(this.state.pos)&&++this.state.pos;case 10:e+="\n";break;default:e+=String.fromCharCode(n)}++this.state.curLine,this.state.lineStart=this.state.pos,t=this.state.pos}else++this.state.pos}},e.prototype.readEscapedChar=function(e){var t=!e,r=this.input.charCodeAt(++this.state.pos);switch(++this.state.pos,r){case 110:return"\n";case 114:return"\r";case 120:var n=this.readHexChar(2,t);return null===n?null:String.fromCharCode(n);case 117:var i=this.readCodePoint(t);return null===i?null:l(i);case 116:return"\t";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:10===this.input.charCodeAt(this.state.pos)&&++this.state.pos;case 10:return this.state.lineStart=this.state.pos,++this.state.curLine,"";default:if(r>=48&&r<=55){var s=this.state.pos-1,a=this.input.substr(this.state.pos-1,3).match(/^[0-7]+/)[0],o=parseInt(a,8);if(o>255&&(a=a.slice(0,-1),o=parseInt(a,8)),o>0){if(e)return this.state.invalidTemplateEscapePosition=s,null;this.state.strict?this.raise(s,"Octal literal in strict mode"):this.state.containsOctal||(this.state.containsOctal=!0,this.state.octalPosition=s)}return this.state.pos+=a.length-1,String.fromCharCode(o)}return String.fromCharCode(r)}},e.prototype.readHexChar=function(e,t){var r=this.state.pos,n=this.readInt(16,e);return null===n&&(t?this.raise(r,"Bad character escape sequence"):(this.state.pos=r-1,this.state.invalidTemplateEscapePosition=r-1)),n},e.prototype.readWord1=function(){this.state.containsEsc=!1;for(var e="",t=!0,r=this.state.pos;this.state.pos<this.input.length;){var n=this.fullCharCodeAtPos();if(s(n))this.state.pos+=n<=65535?1:2;else{if(92!==n)break;this.state.containsEsc=!0,e+=this.input.slice(r,this.state.pos);var a=this.state.pos;117!==this.input.charCodeAt(++this.state.pos)&&this.raise(this.state.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.state.pos;var o=this.readCodePoint(!0);(t?i:s)(o,!0)||this.raise(a,"Invalid Unicode escape"),e+=l(o),r=this.state.pos}t=!1}return e+this.input.slice(r,this.state.pos)},e.prototype.readWord=function(){var e=this.readWord1(),t=R.name;return!this.state.containsEsc&&this.isKeyword(e)&&(t=I[e]),this.finishToken(t,e)},e.prototype.braceIsBlock=function(e){if(e===R.colon){var t=this.curContext();if(t===U.braceStatement||t===U.braceExpression)return!t.isExpr}return e===R._return?M.test(this.input.slice(this.state.lastTokEnd,this.state.start)):e===R._else||e===R.semi||e===R.eof||e===R.parenR||(e===R.braceL?this.curContext()===U.braceStatement:!this.state.exprAllowed)},e.prototype.updateContext=function(e){var t=this.state.type,r=void 0;t.keyword&&e===R.dot?this.state.exprAllowed=!1:(r=t.updateContext)?r.call(this,e):this.state.exprAllowed=t.beforeExpr},e}(),K={},H=["jsx","doExpressions","objectRestSpread","decorators","classProperties","exportExtensions","asyncGenerators","functionBind","functionSent","dynamicImport","flow"],J=function(e){function t(r,n){w(this,t),r=a(r);var i=k(this,e.call(this,r,n));return i.options=r,i.inModule="module"===i.options.sourceType,i.input=n,i.plugins=i.loadPlugins(i.options.plugins),i.filename=r.sourceFilename,0===i.state.pos&&"#"===i.input[0]&&"!"===i.input[1]&&i.skipLineComment(2),i}return P(t,e),t.prototype.isReservedWord=function(e){return"await"===e?this.inModule:v[6](e)},t.prototype.hasPlugin=function(e){return!!(this.plugins["*"]&&H.indexOf(e)>-1)||!!this.plugins[e]},t.prototype.extend=function(e,t){this[e]=t(this[e])},t.prototype.loadAllPlugins=function(){var e=this,t=Object.keys(K).filter(function(e){return"flow"!==e&&"estree"!==e});t.push("flow"),t.forEach(function(t){var r=K[t];r&&r(e)})},t.prototype.loadPlugins=function(e){if(e.indexOf("*")>=0)return this.loadAllPlugins(),{"*":!0};var t={};e.indexOf("flow")>=0&&(e=e.filter(function(e){return"flow"!==e}),e.push("flow")),e.indexOf("estree")>=0&&(e=e.filter(function(e){return"estree"!==e}),e.unshift("estree"));for(var r=e,n=Array.isArray(r),i=0,r=n?r:r[Symbol.iterator]();;){var s;if(n){if(i>=r.length)break;s=r[i++]}else{if(i=r.next(),i.done)break;s=i.value}var a=s;if(!t[a]){t[a]=!0;var o=K[a];o&&o(this)}}return t},t.prototype.parse=function(){var e=this.startNode(),t=this.startNode();return this.nextToken(),this.parseTopLevel(e,t)},t}(q),X=J.prototype;X.addExtra=function(e,t,r){if(e){(e.extra=e.extra||{})[t]=r}},X.isRelational=function(e){return this.match(R.relational)&&this.state.value===e},X.expectRelational=function(e){this.isRelational(e)?this.next():this.unexpected(null,R.relational)},X.isContextual=function(e){return this.match(R.name)&&this.state.value===e},X.eatContextual=function(e){return this.state.value===e&&this.eat(R.name)},X.expectContextual=function(e,t){this.eatContextual(e)||this.unexpected(null,t)},X.canInsertSemicolon=function(){return this.match(R.eof)||this.match(R.braceR)||M.test(this.input.slice(this.state.lastTokEnd,this.state.start))},X.isLineTerminator=function(){return this.eat(R.semi)||this.canInsertSemicolon()},X.semicolon=function(){this.isLineTerminator()||this.unexpected(null,R.semi)},X.expect=function(e,t){return this.eat(e)||this.unexpected(t,e)},X.unexpected=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Unexpected token";t&&"object"===(void 0===t?"undefined":C(t))&&t.label&&(t="Unexpected token, expected "+t.label),this.raise(null!=e?e:this.state.start,t)};var z=J.prototype;z.parseTopLevel=function(e,t){return t.sourceType=this.options.sourceType,this.parseBlockBody(t,!0,!0,R.eof),e.program=this.finishNode(t,"Program"),e.comments=this.state.comments,e.tokens=this.state.tokens,this.finishNode(e,"File")};var $={kind:"loop"},Q={kind:"switch"};z.stmtToDirective=function(e){var t=e.expression,r=this.startNodeAt(t.start,t.loc.start),n=this.startNodeAt(e.start,e.loc.start),i=this.input.slice(t.start,t.end),s=r.value=i.slice(1,-1);return this.addExtra(r,"raw",i),this.addExtra(r,"rawValue",s),n.value=this.finishNodeAt(r,"DirectiveLiteral",t.end,t.loc.end),this.finishNodeAt(n,"Directive",e.end,e.loc.end)},z.parseStatement=function(e,t){this.match(R.at)&&this.parseDecorators(!0);var r=this.state.type,n=this.startNode();switch(r){case R._break:case R._continue:return this.parseBreakContinueStatement(n,r.keyword);case R._debugger:return this.parseDebuggerStatement(n);case R._do:return this.parseDoStatement(n);case R._for:return this.parseForStatement(n);case R._function:return e||this.unexpected(),this.parseFunctionStatement(n);case R._class:return e||this.unexpected(),this.parseClass(n,!0);case R._if:return this.parseIfStatement(n);case R._return:return this.parseReturnStatement(n);case R._switch:return this.parseSwitchStatement(n);case R._throw:return this.parseThrowStatement(n);case R._try:return this.parseTryStatement(n);case R._let:case R._const:e||this.unexpected();case R._var:return this.parseVarStatement(n,r);case R._while:return this.parseWhileStatement(n);case R._with:return this.parseWithStatement(n);case R.braceL:return this.parseBlock();case R.semi:return this.parseEmptyStatement(n);case R._export:case R._import:if(this.hasPlugin("dynamicImport")&&this.lookahead().type===R.parenL)break;return this.options.allowImportExportEverywhere||(t||this.raise(this.state.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.state.start,"'import' and 'export' may appear only with 'sourceType: \"module\"'")),r===R._import?this.parseImport(n):this.parseExport(n);case R.name:if("async"===this.state.value){var i=this.state.clone();if(this.next(),this.match(R._function)&&!this.canInsertSemicolon())return this.expect(R._function),this.parseFunction(n,!0,!1,!0);this.state=i}}var s=this.state.value,a=this.parseExpression();return r===R.name&&"Identifier"===a.type&&this.eat(R.colon)?this.parseLabeledStatement(n,s,a):this.parseExpressionStatement(n,a)},z.takeDecorators=function(e){this.state.decorators.length&&(e.decorators=this.state.decorators,this.state.decorators=[])},z.parseDecorators=function(e){for(;this.match(R.at);){var t=this.parseDecorator();this.state.decorators.push(t)}e&&this.match(R._export)||this.match(R._class)||this.raise(this.state.start,"Leading decorators must be attached to a class declaration")},z.parseDecorator=function(){this.hasPlugin("decorators")||this.unexpected();var e=this.startNode();return this.next(),e.expression=this.parseMaybeAssign(),this.finishNode(e,"Decorator")},z.parseBreakContinueStatement=function(e,t){var r="break"===t;this.next(),this.isLineTerminator()?e.label=null:this.match(R.name)?(e.label=this.parseIdentifier(),this.semicolon()):this.unexpected();var n=void 0;for(n=0;n<this.state.labels.length;++n){var i=this.state.labels[n];if(null==e.label||i.name===e.label.name){if(null!=i.kind&&(r||"loop"===i.kind))break;if(e.label&&r)break}}return n===this.state.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,r?"BreakStatement":"ContinueStatement")},z.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")},z.parseDoStatement=function(e){return this.next(),this.state.labels.push($),e.body=this.parseStatement(!1),this.state.labels.pop(),this.expect(R._while),e.test=this.parseParenExpression(),this.eat(R.semi),this.finishNode(e,"DoWhileStatement")},z.parseForStatement=function(e){this.next(),this.state.labels.push($);var t=!1;if(this.hasPlugin("asyncGenerators")&&this.state.inAsync&&this.isContextual("await")&&(t=!0,this.next()),this.expect(R.parenL),this.match(R.semi))return t&&this.unexpected(),this.parseFor(e,null);if(this.match(R._var)||this.match(R._let)||this.match(R._const)){var r=this.startNode(),n=this.state.type;return this.next(),(this.parseVar(r,!0,n),this.finishNode(r,"VariableDeclaration"),!this.match(R._in)&&!this.isContextual("of")||1!==r.declarations.length||r.declarations[0].init)?(t&&this.unexpected(), +this.parseFor(e,r)):this.parseForIn(e,r,t)}var i={start:0},s=this.parseExpression(!0,i);if(this.match(R._in)||this.isContextual("of")){var a=this.isContextual("of")?"for-of statement":"for-in statement";return this.toAssignable(s,void 0,a),this.checkLVal(s,void 0,void 0,a),this.parseForIn(e,s,t)}return i.start&&this.unexpected(i.start),t&&this.unexpected(),this.parseFor(e,s)},z.parseFunctionStatement=function(e){return this.next(),this.parseFunction(e,!0)},z.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement(!1),e.alternate=this.eat(R._else)?this.parseStatement(!1):null,this.finishNode(e,"IfStatement")},z.parseReturnStatement=function(e){return this.state.inFunction||this.options.allowReturnOutsideFunction||this.raise(this.state.start,"'return' outside of function"),this.next(),this.isLineTerminator()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")},z.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(R.braceL),this.state.labels.push(Q);for(var t,r=void 0;!this.match(R.braceR);)if(this.match(R._case)||this.match(R._default)){var n=this.match(R._case);r&&this.finishNode(r,"SwitchCase"),e.cases.push(r=this.startNode()),r.consequent=[],this.next(),n?r.test=this.parseExpression():(t&&this.raise(this.state.lastTokStart,"Multiple default clauses"),t=!0,r.test=null),this.expect(R.colon)}else r?r.consequent.push(this.parseStatement(!0)):this.unexpected();return r&&this.finishNode(r,"SwitchCase"),this.next(),this.state.labels.pop(),this.finishNode(e,"SwitchStatement")},z.parseThrowStatement=function(e){return this.next(),M.test(this.input.slice(this.state.lastTokEnd,this.state.start))&&this.raise(this.state.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var Z=[];z.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.match(R._catch)){var t=this.startNode();this.next(),this.expect(R.parenL),t.param=this.parseBindingAtom(),this.checkLVal(t.param,!0,Object.create(null),"catch clause"),this.expect(R.parenR),t.body=this.parseBlock(),e.handler=this.finishNode(t,"CatchClause")}return e.guardedHandlers=Z,e.finalizer=this.eat(R._finally)?this.parseBlock():null,e.handler||e.finalizer||this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")},z.parseVarStatement=function(e,t){return this.next(),this.parseVar(e,!1,t),this.semicolon(),this.finishNode(e,"VariableDeclaration")},z.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.state.labels.push($),e.body=this.parseStatement(!1),this.state.labels.pop(),this.finishNode(e,"WhileStatement")},z.parseWithStatement=function(e){return this.state.strict&&this.raise(this.state.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement(!1),this.finishNode(e,"WithStatement")},z.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")},z.parseLabeledStatement=function(e,t,r){for(var n=this.state.labels,i=Array.isArray(n),s=0,n=i?n:n[Symbol.iterator]();;){var a;if(i){if(s>=n.length)break;a=n[s++]}else{if(s=n.next(),s.done)break;a=s.value}a.name===t&&this.raise(r.start,"Label '"+t+"' is already declared")}for(var o=this.state.type.isLoop?"loop":this.match(R._switch)?"switch":null,u=this.state.labels.length-1;u>=0;u--){var l=this.state.labels[u];if(l.statementStart!==e.start)break;l.statementStart=this.state.start,l.kind=o}return this.state.labels.push({name:t,kind:o,statementStart:this.state.start}),e.body=this.parseStatement(!0),this.state.labels.pop(),e.label=r,this.finishNode(e,"LabeledStatement")},z.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")},z.parseBlock=function(e){var t=this.startNode();return this.expect(R.braceL),this.parseBlockBody(t,e,!1,R.braceR),this.finishNode(t,"BlockStatement")},z.isValidDirective=function(e){return"ExpressionStatement"===e.type&&"StringLiteral"===e.expression.type&&!e.expression.extra.parenthesized},z.parseBlockBody=function(e,t,r,n){e.body=[],e.directives=[];for(var i=!1,s=void 0,a=void 0;!this.eat(n);){i||!this.state.containsOctal||a||(a=this.state.octalPosition);var o=this.parseStatement(!0,r);if(t&&!i&&this.isValidDirective(o)){var u=this.stmtToDirective(o);e.directives.push(u),void 0===s&&"use strict"===u.value.value&&(s=this.state.strict,this.setStrict(!0),a&&this.raise(a,"Octal literal in strict mode"))}else i=!0,e.body.push(o)}!1===s&&this.setStrict(!1)},z.parseFor=function(e,t){return e.init=t,this.expect(R.semi),e.test=this.match(R.semi)?null:this.parseExpression(),this.expect(R.semi),e.update=this.match(R.parenR)?null:this.parseExpression(),this.expect(R.parenR),e.body=this.parseStatement(!1),this.state.labels.pop(),this.finishNode(e,"ForStatement")},z.parseForIn=function(e,t,r){var n=void 0;return r?(this.eatContextual("of"),n="ForAwaitStatement"):(n=this.match(R._in)?"ForInStatement":"ForOfStatement",this.next()),e.left=t,e.right=this.parseExpression(),this.expect(R.parenR),e.body=this.parseStatement(!1),this.state.labels.pop(),this.finishNode(e,n)},z.parseVar=function(e,t,r){for(e.declarations=[],e.kind=r.keyword;;){var n=this.startNode();if(this.parseVarHead(n),this.eat(R.eq)?n.init=this.parseMaybeAssign(t):r!==R._const||this.match(R._in)||this.isContextual("of")?"Identifier"===n.id.type||t&&(this.match(R._in)||this.isContextual("of"))?n.init=null:this.raise(this.state.lastTokEnd,"Complex binding patterns require an initialization value"):this.unexpected(),e.declarations.push(this.finishNode(n,"VariableDeclarator")),!this.eat(R.comma))break}return e},z.parseVarHead=function(e){e.id=this.parseBindingAtom(),this.checkLVal(e.id,!0,void 0,"variable declaration")},z.parseFunction=function(e,t,r,n,i){var s=this.state.inMethod;return this.state.inMethod=!1,this.initFunction(e,n),this.match(R.star)&&(e.async&&!this.hasPlugin("asyncGenerators")?this.unexpected():(e.generator=!0,this.next())),!t||i||this.match(R.name)||this.match(R._yield)||this.unexpected(),(this.match(R.name)||this.match(R._yield))&&(e.id=this.parseBindingIdentifier()),this.parseFunctionParams(e),this.parseFunctionBody(e,r),this.state.inMethod=s,this.finishNode(e,t?"FunctionDeclaration":"FunctionExpression")},z.parseFunctionParams=function(e){this.expect(R.parenL),e.params=this.parseBindingList(R.parenR)},z.parseClass=function(e,t,r){return this.next(),this.takeDecorators(e),this.parseClassId(e,t,r),this.parseClassSuper(e),this.parseClassBody(e),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")},z.isClassProperty=function(){return this.match(R.eq)||this.match(R.semi)||this.match(R.braceR)},z.isClassMethod=function(){return this.match(R.parenL)},z.isNonstaticConstructor=function(e){return!(e.computed||e.static||"constructor"!==e.key.name&&"constructor"!==e.key.value)},z.parseClassBody=function(e){var t=this.state.strict;this.state.strict=!0;var r=!1,n=!1,i=[],s=this.startNode();for(s.body=[],this.expect(R.braceL);!this.eat(R.braceR);)if(this.eat(R.semi))i.length>0&&this.raise(this.state.lastTokEnd,"Decorators must not be followed by a semicolon");else if(this.match(R.at))i.push(this.parseDecorator());else{var a=this.startNode();if(i.length&&(a.decorators=i,i=[]),a.static=!1,this.match(R.name)&&"static"===this.state.value){var o=this.parseIdentifier(!0);if(this.isClassMethod()){a.kind="method",a.computed=!1,a.key=o,this.parseClassMethod(s,a,!1,!1);continue}if(this.isClassProperty()){a.computed=!1,a.key=o,s.body.push(this.parseClassProperty(a));continue}a.static=!0}if(this.eat(R.star))a.kind="method",this.parsePropertyName(a),this.isNonstaticConstructor(a)&&this.raise(a.key.start,"Constructor can't be a generator"),a.computed||!a.static||"prototype"!==a.key.name&&"prototype"!==a.key.value||this.raise(a.key.start,"Classes may not have static property named prototype"),this.parseClassMethod(s,a,!0,!1);else{var u=this.match(R.name),l=this.parsePropertyName(a);if(a.computed||!a.static||"prototype"!==a.key.name&&"prototype"!==a.key.value||this.raise(a.key.start,"Classes may not have static property named prototype"),this.isClassMethod())this.isNonstaticConstructor(a)?(n?this.raise(l.start,"Duplicate constructor in the same class"):a.decorators&&this.raise(a.start,"You can't attach decorators to a class constructor"),n=!0,a.kind="constructor"):a.kind="method",this.parseClassMethod(s,a,!1,!1);else if(this.isClassProperty())this.isNonstaticConstructor(a)&&this.raise(a.key.start,"Classes may not have a non-static field named 'constructor'"),s.body.push(this.parseClassProperty(a));else if(u&&"async"===l.name&&!this.isLineTerminator()){var c=this.hasPlugin("asyncGenerators")&&this.eat(R.star);a.kind="method",this.parsePropertyName(a),this.isNonstaticConstructor(a)&&this.raise(a.key.start,"Constructor can't be an async function"),this.parseClassMethod(s,a,c,!0)}else!u||"get"!==l.name&&"set"!==l.name||this.isLineTerminator()&&this.match(R.star)?this.hasPlugin("classConstructorCall")&&u&&"call"===l.name&&this.match(R.name)&&"constructor"===this.state.value?(r?this.raise(a.start,"Duplicate constructor call in the same class"):a.decorators&&this.raise(a.start,"You can't attach decorators to a class constructor"),r=!0,a.kind="constructorCall",this.parsePropertyName(a),this.parseClassMethod(s,a,!1,!1)):this.isLineTerminator()?(this.isNonstaticConstructor(a)&&this.raise(a.key.start,"Classes may not have a non-static field named 'constructor'"),s.body.push(this.parseClassProperty(a))):this.unexpected():(a.kind=l.name,this.parsePropertyName(a),this.isNonstaticConstructor(a)&&this.raise(a.key.start,"Constructor can't have get/set modifier"),this.parseClassMethod(s,a,!1,!1),this.checkGetterSetterParamCount(a))}}i.length&&this.raise(this.state.start,"You have trailing decorators with no method"),e.body=this.finishNode(s,"ClassBody"),this.state.strict=t},z.parseClassProperty=function(e){return this.state.inClassProperty=!0,this.match(R.eq)?(this.hasPlugin("classProperties")||this.unexpected(),this.next(),e.value=this.parseMaybeAssign()):e.value=null,this.semicolon(),this.state.inClassProperty=!1,this.finishNode(e,"ClassProperty")},z.parseClassMethod=function(e,t,r,n){this.parseMethod(t,r,n),e.body.push(this.finishNode(t,"ClassMethod"))},z.parseClassId=function(e,t,r){this.match(R.name)?e.id=this.parseIdentifier():r||!t?e.id=null:this.unexpected()},z.parseClassSuper=function(e){e.superClass=this.eat(R._extends)?this.parseExprSubscripts():null},z.parseExport=function(e){if(this.next(),this.match(R.star)){var t=this.startNode();if(this.next(),!this.hasPlugin("exportExtensions")||!this.eatContextual("as"))return this.parseExportFrom(e,!0),this.finishNode(e,"ExportAllDeclaration");t.exported=this.parseIdentifier(),e.specifiers=[this.finishNode(t,"ExportNamespaceSpecifier")],this.parseExportSpecifiersMaybe(e),this.parseExportFrom(e,!0)}else if(this.hasPlugin("exportExtensions")&&this.isExportDefaultSpecifier()){var r=this.startNode();if(r.exported=this.parseIdentifier(!0),e.specifiers=[this.finishNode(r,"ExportDefaultSpecifier")],this.match(R.comma)&&this.lookahead().type===R.star){this.expect(R.comma);var n=this.startNode();this.expect(R.star),this.expectContextual("as"),n.exported=this.parseIdentifier(),e.specifiers.push(this.finishNode(n,"ExportNamespaceSpecifier"))}else this.parseExportSpecifiersMaybe(e);this.parseExportFrom(e,!0)}else{if(this.eat(R._default)){var i=this.startNode(),s=!1;return this.eat(R._function)?i=this.parseFunction(i,!0,!1,!1,!0):this.match(R._class)?i=this.parseClass(i,!0,!0):(s=!0,i=this.parseMaybeAssign()),e.declaration=i,s&&this.semicolon(),this.checkExport(e,!0,!0),this.finishNode(e,"ExportDefaultDeclaration")}this.shouldParseExportDeclaration()?(e.specifiers=[],e.source=null,e.declaration=this.parseExportDeclaration(e)):(e.declaration=null,e.specifiers=this.parseExportSpecifiers(),this.parseExportFrom(e))}return this.checkExport(e,!0),this.finishNode(e,"ExportNamedDeclaration")},z.parseExportDeclaration=function(){return this.parseStatement(!0)},z.isExportDefaultSpecifier=function(){if(this.match(R.name))return"async"!==this.state.value;if(!this.match(R._default))return!1;var e=this.lookahead();return e.type===R.comma||e.type===R.name&&"from"===e.value},z.parseExportSpecifiersMaybe=function(e){this.eat(R.comma)&&(e.specifiers=e.specifiers.concat(this.parseExportSpecifiers()))},z.parseExportFrom=function(e,t){this.eatContextual("from")?(e.source=this.match(R.string)?this.parseExprAtom():this.unexpected(),this.checkExport(e)):t?this.unexpected():e.source=null,this.semicolon()},z.shouldParseExportDeclaration=function(){return"var"===this.state.type.keyword||"const"===this.state.type.keyword||"let"===this.state.type.keyword||"function"===this.state.type.keyword||"class"===this.state.type.keyword||this.isContextual("async")},z.checkExport=function(e,t,r){if(t)if(r)this.checkDuplicateExports(e,"default");else if(e.specifiers&&e.specifiers.length)for(var n=e.specifiers,i=Array.isArray(n),s=0,n=i?n:n[Symbol.iterator]();;){var a;if(i){if(s>=n.length)break;a=n[s++]}else{if(s=n.next(),s.done)break;a=s.value}var o=a;this.checkDuplicateExports(o,o.exported.name)}else if(e.declaration)if("FunctionDeclaration"===e.declaration.type||"ClassDeclaration"===e.declaration.type)this.checkDuplicateExports(e,e.declaration.id.name);else if("VariableDeclaration"===e.declaration.type)for(var u=e.declaration.declarations,l=Array.isArray(u),c=0,u=l?u:u[Symbol.iterator]();;){var f;if(l){if(c>=u.length)break;f=u[c++]}else{if(c=u.next(),c.done)break;f=c.value}var p=f;this.checkDeclaration(p.id)}if(this.state.decorators.length){var d=e.declaration&&("ClassDeclaration"===e.declaration.type||"ClassExpression"===e.declaration.type);e.declaration&&d||this.raise(e.start,"You can only use decorators on an export when exporting a class"),this.takeDecorators(e.declaration)}},z.checkDeclaration=function(e){if("ObjectPattern"===e.type)for(var t=e.properties,r=Array.isArray(t),n=0,t=r?t:t[Symbol.iterator]();;){var i;if(r){if(n>=t.length)break;i=t[n++]}else{if(n=t.next(),n.done)break;i=n.value}var s=i;this.checkDeclaration(s)}else if("ArrayPattern"===e.type)for(var a=e.elements,o=Array.isArray(a),u=0,a=o?a:a[Symbol.iterator]();;){var l;if(o){if(u>=a.length)break;l=a[u++]}else{if(u=a.next(),u.done)break;l=u.value}var c=l;c&&this.checkDeclaration(c)}else"ObjectProperty"===e.type?this.checkDeclaration(e.value):"RestElement"===e.type||"RestProperty"===e.type?this.checkDeclaration(e.argument):"Identifier"===e.type&&this.checkDuplicateExports(e,e.name)},z.checkDuplicateExports=function(e,t){this.state.exportedIdentifiers.indexOf(t)>-1&&this.raiseDuplicateExportError(e,t),this.state.exportedIdentifiers.push(t)},z.raiseDuplicateExportError=function(e,t){this.raise(e.start,"default"===t?"Only one default export allowed per module.":"`"+t+"` has already been exported. Exported identifiers must be unique.")},z.parseExportSpecifiers=function(){var e=[],t=!0,r=void 0;for(this.expect(R.braceL);!this.eat(R.braceR);){if(t)t=!1;else if(this.expect(R.comma),this.eat(R.braceR))break;var n=this.match(R._default);n&&!r&&(r=!0);var i=this.startNode();i.local=this.parseIdentifier(n),i.exported=this.eatContextual("as")?this.parseIdentifier(!0):i.local.__clone(),e.push(this.finishNode(i,"ExportSpecifier"))}return r&&!this.isContextual("from")&&this.unexpected(),e},z.parseImport=function(e){return this.eat(R._import),this.match(R.string)?(e.specifiers=[],e.source=this.parseExprAtom()):(e.specifiers=[],this.parseImportSpecifiers(e),this.expectContextual("from"),e.source=this.match(R.string)?this.parseExprAtom():this.unexpected()),this.semicolon(),this.finishNode(e,"ImportDeclaration")},z.parseImportSpecifiers=function(e){var t=!0;if(this.match(R.name)){var r=this.state.start,n=this.state.startLoc;if(e.specifiers.push(this.parseImportSpecifierDefault(this.parseIdentifier(),r,n)),!this.eat(R.comma))return}if(this.match(R.star)){var i=this.startNode();return this.next(),this.expectContextual("as"),i.local=this.parseIdentifier(),this.checkLVal(i.local,!0,void 0,"import namespace specifier"),void e.specifiers.push(this.finishNode(i,"ImportNamespaceSpecifier"))}for(this.expect(R.braceL);!this.eat(R.braceR);){if(t)t=!1;else if(this.eat(R.colon)&&this.unexpected(null,"ES2015 named imports do not destructure. Use another statement for destructuring after the import."),this.expect(R.comma),this.eat(R.braceR))break;this.parseImportSpecifier(e)}},z.parseImportSpecifier=function(e){var t=this.startNode();t.imported=this.parseIdentifier(!0),this.eatContextual("as")?t.local=this.parseIdentifier():(this.checkReservedWord(t.imported.name,t.start,!0,!0),t.local=t.imported.__clone()),this.checkLVal(t.local,!0,void 0,"import specifier"),e.specifiers.push(this.finishNode(t,"ImportSpecifier"))},z.parseImportSpecifierDefault=function(e,t,r){var n=this.startNodeAt(t,r);return n.local=e,this.checkLVal(n.local,!0,void 0,"default import specifier"),this.finishNode(n,"ImportDefaultSpecifier")};var ee=J.prototype;ee.toAssignable=function(e,t,r){if(e)switch(e.type){case"Identifier":case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":break;case"ObjectExpression":e.type="ObjectPattern";for(var n=e.properties,i=Array.isArray(n),s=0,n=i?n:n[Symbol.iterator]();;){var a;if(i){if(s>=n.length)break;a=n[s++]}else{if(s=n.next(),s.done)break;a=s.value}var o=a;"ObjectMethod"===o.type?"get"===o.kind||"set"===o.kind?this.raise(o.key.start,"Object pattern can't contain getter or setter"):this.raise(o.key.start,"Object pattern can't contain methods"):this.toAssignable(o,t,"object destructuring pattern")}break;case"ObjectProperty":this.toAssignable(e.value,t,r);break;case"SpreadProperty":e.type="RestProperty";var u=e.argument;this.toAssignable(u,t,r);break;case"ArrayExpression":e.type="ArrayPattern",this.toAssignableList(e.elements,t,r);break;case"AssignmentExpression":"="===e.operator?(e.type="AssignmentPattern",delete e.operator):this.raise(e.left.end,"Only '=' operator can be used for specifying default value.");break;case"MemberExpression":if(!t)break;default:var l="Invalid left-hand side"+(r?" in "+r:"expression");this.raise(e.start,l)}return e},ee.toAssignableList=function(e,t,r){var n=e.length;if(n){var i=e[n-1];if(i&&"RestElement"===i.type)--n;else if(i&&"SpreadElement"===i.type){i.type="RestElement";var s=i.argument;this.toAssignable(s,t,r),"Identifier"!==s.type&&"MemberExpression"!==s.type&&"ArrayPattern"!==s.type&&this.unexpected(s.start),--n}}for(var a=0;a<n;a++){var o=e[a];o&&this.toAssignable(o,t,r)}return e},ee.toReferencedList=function(e){return e},ee.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")},ee.parseRest=function(){var e=this.startNode();return this.next(),e.argument=this.parseBindingIdentifier(),this.finishNode(e,"RestElement")},ee.shouldAllowYieldIdentifier=function(){return this.match(R._yield)&&!this.state.strict&&!this.state.inGenerator},ee.parseBindingIdentifier=function(){return this.parseIdentifier(this.shouldAllowYieldIdentifier())},ee.parseBindingAtom=function(){switch(this.state.type){case R._yield:(this.state.strict||this.state.inGenerator)&&this.unexpected();case R.name:return this.parseIdentifier(!0);case R.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(R.bracketR,!0),this.finishNode(e,"ArrayPattern");case R.braceL:return this.parseObj(!0);default:this.unexpected()}},ee.parseBindingList=function(e,t){for(var r=[],n=!0;!this.eat(e);)if(n?n=!1:this.expect(R.comma),t&&this.match(R.comma))r.push(null);else{if(this.eat(e))break;if(this.match(R.ellipsis)){r.push(this.parseAssignableListItemTypes(this.parseRest())),this.expect(e);break}for(var i=[];this.match(R.at);)i.push(this.parseDecorator());var s=this.parseMaybeDefault();i.length&&(s.decorators=i),this.parseAssignableListItemTypes(s),r.push(this.parseMaybeDefault(s.start,s.loc.start,s))}return r},ee.parseAssignableListItemTypes=function(e){return e},ee.parseMaybeDefault=function(e,t,r){if(t=t||this.state.startLoc,e=e||this.state.start,r=r||this.parseBindingAtom(),!this.eat(R.eq))return r;var n=this.startNodeAt(e,t);return n.left=r,n.right=this.parseMaybeAssign(),this.finishNode(n,"AssignmentPattern")},ee.checkLVal=function(e,t,r,n){switch(e.type){case"Identifier":if(this.checkReservedWord(e.name,e.start,!1,!0),r){var i="_"+e.name;r[i]?this.raise(e.start,"Argument name clash in strict mode"):r[i]=!0}break;case"MemberExpression":t&&this.raise(e.start,(t?"Binding":"Assigning to")+" member expression");break;case"ObjectPattern":for(var s=e.properties,a=Array.isArray(s),o=0,s=a?s:s[Symbol.iterator]();;){var u;if(a){if(o>=s.length)break;u=s[o++]}else{if(o=s.next(),o.done)break;u=o.value}var l=u;"ObjectProperty"===l.type&&(l=l.value),this.checkLVal(l,t,r,"object destructuring pattern")}break;case"ArrayPattern":for(var c=e.elements,f=Array.isArray(c),p=0,c=f?c:c[Symbol.iterator]();;){var d;if(f){if(p>=c.length)break;d=c[p++]}else{if(p=c.next(),p.done)break;d=p.value}var h=d;h&&this.checkLVal(h,t,r,"array destructuring pattern")}break;case"AssignmentPattern":this.checkLVal(e.left,t,r,"assignment pattern");break;case"RestProperty":this.checkLVal(e.argument,t,r,"rest property");break;case"RestElement":this.checkLVal(e.argument,t,r,"rest element");break;default:var m=(t?"Binding invalid":"Invalid")+" left-hand side"+(n?" in "+n:"expression");this.raise(e.start,m)}};var te=J.prototype;te.checkPropClash=function(e,t){if(!e.computed&&!e.kind){var r=e.key;"__proto__"===("Identifier"===r.type?r.name:String(r.value))&&(t.proto&&this.raise(r.start,"Redefinition of __proto__ property"),t.proto=!0)}},te.getExpression=function(){this.nextToken();var e=this.parseExpression();return this.match(R.eof)||this.unexpected(),e},te.parseExpression=function(e,t){var r=this.state.start,n=this.state.startLoc,i=this.parseMaybeAssign(e,t);if(this.match(R.comma)){var s=this.startNodeAt(r,n);for(s.expressions=[i];this.eat(R.comma);)s.expressions.push(this.parseMaybeAssign(e,t));return this.toReferencedList(s.expressions),this.finishNode(s,"SequenceExpression")}return i},te.parseMaybeAssign=function(e,t,r,n){var i=this.state.start,s=this.state.startLoc;if(this.match(R._yield)&&this.state.inGenerator){var a=this.parseYield();return r&&(a=r.call(this,a,i,s)),a}var o=void 0;t?o=!1:(t={start:0},o=!0),(this.match(R.parenL)||this.match(R.name))&&(this.state.potentialArrowAt=this.state.start);var u=this.parseMaybeConditional(e,t,n);if(r&&(u=r.call(this,u,i,s)),this.state.type.isAssign){var l=this.startNodeAt(i,s);if(l.operator=this.state.value,l.left=this.match(R.eq)?this.toAssignable(u,void 0,"assignment expression"):u,t.start=0,this.checkLVal(u,void 0,void 0,"assignment expression"),u.extra&&u.extra.parenthesized){var c=void 0;"ObjectPattern"===u.type?c="`({a}) = 0` use `({a} = 0)`":"ArrayPattern"===u.type&&(c="`([a]) = 0` use `([a] = 0)`"),c&&this.raise(u.start,"You're trying to assign to a parenthesized expression, eg. instead of "+c)}return this.next(),l.right=this.parseMaybeAssign(e),this.finishNode(l,"AssignmentExpression")}return o&&t.start&&this.unexpected(t.start),u},te.parseMaybeConditional=function(e,t,r){var n=this.state.start,i=this.state.startLoc,s=this.parseExprOps(e,t);return t&&t.start?s:this.parseConditional(s,e,n,i,r)},te.parseConditional=function(e,t,r,n){if(this.eat(R.question)){var i=this.startNodeAt(r,n);return i.test=e,i.consequent=this.parseMaybeAssign(),this.expect(R.colon),i.alternate=this.parseMaybeAssign(t),this.finishNode(i,"ConditionalExpression")}return e},te.parseExprOps=function(e,t){var r=this.state.start,n=this.state.startLoc,i=this.parseMaybeUnary(t);return t&&t.start?i:this.parseExprOp(i,r,n,-1,e)},te.parseExprOp=function(e,t,r,n,i){var s=this.state.type.binop;if(!(null==s||i&&this.match(R._in))&&s>n){var a=this.startNodeAt(t,r);a.left=e,a.operator=this.state.value,"**"!==a.operator||"UnaryExpression"!==e.type||!e.extra||e.extra.parenthesizedArgument||e.extra.parenthesized||this.raise(e.argument.start,"Illegal expression. Wrap left hand side or entire exponentiation in parentheses.");var o=this.state.type;this.next();var u=this.state.start,l=this.state.startLoc;return a.right=this.parseExprOp(this.parseMaybeUnary(),u,l,o.rightAssociative?s-1:s,i),this.finishNode(a,o===R.logicalOR||o===R.logicalAND?"LogicalExpression":"BinaryExpression"),this.parseExprOp(a,t,r,n,i)}return e},te.parseMaybeUnary=function(e){if(this.state.type.prefix){var t=this.startNode(),r=this.match(R.incDec);t.operator=this.state.value,t.prefix=!0,this.next();var n=this.state.type;return t.argument=this.parseMaybeUnary(),this.addExtra(t,"parenthesizedArgument",!(n!==R.parenL||t.argument.extra&&t.argument.extra.parenthesized)),e&&e.start&&this.unexpected(e.start),r?this.checkLVal(t.argument,void 0,void 0,"prefix operation"):this.state.strict&&"delete"===t.operator&&"Identifier"===t.argument.type&&this.raise(t.start,"Deleting local variable in strict mode"),this.finishNode(t,r?"UpdateExpression":"UnaryExpression")}var i=this.state.start,s=this.state.startLoc,a=this.parseExprSubscripts(e);if(e&&e.start)return a;for(;this.state.type.postfix&&!this.canInsertSemicolon();){var o=this.startNodeAt(i,s);o.operator=this.state.value,o.prefix=!1,o.argument=a,this.checkLVal(a,void 0,void 0,"postfix operation"),this.next(),a=this.finishNode(o,"UpdateExpression")}return a},te.parseExprSubscripts=function(e){var t=this.state.start,r=this.state.startLoc,n=this.state.potentialArrowAt,i=this.parseExprAtom(e);return"ArrowFunctionExpression"===i.type&&i.start===n?i:e&&e.start?i:this.parseSubscripts(i,t,r)},te.parseSubscripts=function(e,t,r,n){for(;;){if(!n&&this.eat(R.doubleColon)){var i=this.startNodeAt(t,r);return i.object=e,i.callee=this.parseNoCallExpr(),this.parseSubscripts(this.finishNode(i,"BindExpression"),t,r,n)}if(this.eat(R.dot)){var s=this.startNodeAt(t,r);s.object=e,s.property=this.parseIdentifier(!0),s.computed=!1,e=this.finishNode(s,"MemberExpression")}else if(this.eat(R.bracketL)){var a=this.startNodeAt(t,r);a.object=e,a.property=this.parseExpression(),a.computed=!0,this.expect(R.bracketR),e=this.finishNode(a,"MemberExpression")}else if(!n&&this.match(R.parenL)){var o=this.state.potentialArrowAt===e.start&&"Identifier"===e.type&&"async"===e.name&&!this.canInsertSemicolon();this.next();var u=this.startNodeAt(t,r);if(u.callee=e,u.arguments=this.parseCallExpressionArguments(R.parenR,o),"Import"===u.callee.type&&1!==u.arguments.length&&this.raise(u.start,"import() requires exactly one argument"),e=this.finishNode(u,"CallExpression"),o&&this.shouldParseAsyncArrow())return this.parseAsyncArrowFromCallExpression(this.startNodeAt(t,r),u);this.toReferencedList(u.arguments)}else{if(!this.match(R.backQuote))return e;var l=this.startNodeAt(t,r);l.tag=e,l.quasi=this.parseTemplate(!0),e=this.finishNode(l,"TaggedTemplateExpression")}}},te.parseCallExpressionArguments=function(e,t){for(var r=[],n=void 0,i=!0;!this.eat(e);){if(i)i=!1;else if(this.expect(R.comma),this.eat(e))break;this.match(R.parenL)&&!n&&(n=this.state.start),r.push(this.parseExprListItem(!1,t?{start:0}:void 0,t?{start:0}:void 0))}return t&&n&&this.shouldParseAsyncArrow()&&this.unexpected(),r},te.shouldParseAsyncArrow=function(){return this.match(R.arrow)},te.parseAsyncArrowFromCallExpression=function(e,t){return this.expect(R.arrow),this.parseArrowExpression(e,t.arguments,!0)},te.parseNoCallExpr=function(){var e=this.state.start,t=this.state.startLoc;return this.parseSubscripts(this.parseExprAtom(),e,t,!0)},te.parseExprAtom=function(e){var t=this.state.potentialArrowAt===this.state.start,r=void 0;switch(this.state.type){case R._super:return this.state.inMethod||this.state.inClassProperty||this.options.allowSuperOutsideMethod||this.raise(this.state.start,"'super' outside of function or class"),r=this.startNode(),this.next(),this.match(R.parenL)||this.match(R.bracketL)||this.match(R.dot)||this.unexpected(),this.match(R.parenL)&&"constructor"!==this.state.inMethod&&!this.options.allowSuperOutsideMethod&&this.raise(r.start,"super() outside of class constructor"),this.finishNode(r,"Super");case R._import:return this.hasPlugin("dynamicImport")||this.unexpected(),r=this.startNode(),this.next(),this.match(R.parenL)||this.unexpected(null,R.parenL),this.finishNode(r,"Import");case R._this:return r=this.startNode(),this.next(),this.finishNode(r,"ThisExpression");case R._yield:this.state.inGenerator&&this.unexpected();case R.name:r=this.startNode();var n="await"===this.state.value&&this.state.inAsync,i=this.shouldAllowYieldIdentifier(),s=this.parseIdentifier(n||i);if("await"===s.name){if(this.state.inAsync||this.inModule)return this.parseAwait(r)}else{if("async"===s.name&&this.match(R._function)&&!this.canInsertSemicolon())return this.next(),this.parseFunction(r,!1,!1,!0);if(t&&"async"===s.name&&this.match(R.name)){var a=[this.parseIdentifier()];return this.expect(R.arrow),this.parseArrowExpression(r,a,!0)}}return t&&!this.canInsertSemicolon()&&this.eat(R.arrow)?this.parseArrowExpression(r,[s]):s;case R._do:if(this.hasPlugin("doExpressions")){var o=this.startNode();this.next();var u=this.state.inFunction,l=this.state.labels;return this.state.labels=[],this.state.inFunction=!1,o.body=this.parseBlock(!1,!0),this.state.inFunction=u,this.state.labels=l,this.finishNode(o,"DoExpression")}case R.regexp:var c=this.state.value;return r=this.parseLiteral(c.value,"RegExpLiteral"),r.pattern=c.pattern,r.flags=c.flags,r;case R.num:return this.parseLiteral(this.state.value,"NumericLiteral");case R.string:return this.parseLiteral(this.state.value,"StringLiteral");case R._null:return r=this.startNode(),this.next(),this.finishNode(r,"NullLiteral");case R._true:case R._false:return r=this.startNode(),r.value=this.match(R._true),this.next(),this.finishNode(r,"BooleanLiteral");case R.parenL:return this.parseParenAndDistinguishExpression(null,null,t);case R.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(R.bracketR,!0,e),this.toReferencedList(r.elements),this.finishNode(r,"ArrayExpression");case R.braceL:return this.parseObj(!1,e);case R._function:return this.parseFunctionExpression();case R.at:this.parseDecorators();case R._class:return r=this.startNode(),this.takeDecorators(r),this.parseClass(r,!1);case R._new:return this.parseNew();case R.backQuote:return this.parseTemplate(!1);case R.doubleColon:r=this.startNode(),this.next(),r.object=null;var f=r.callee=this.parseNoCallExpr();if("MemberExpression"===f.type)return this.finishNode(r,"BindExpression");this.raise(f.start,"Binding should be performed on object property.");default:this.unexpected()}},te.parseFunctionExpression=function(){var e=this.startNode(),t=this.parseIdentifier(!0);return this.state.inGenerator&&this.eat(R.dot)&&this.hasPlugin("functionSent")?this.parseMetaProperty(e,t,"sent"):this.parseFunction(e,!1)},te.parseMetaProperty=function(e,t,r){return e.meta=t,e.property=this.parseIdentifier(!0),e.property.name!==r&&this.raise(e.property.start,"The only valid meta property for new is "+t.name+"."+r),this.finishNode(e,"MetaProperty")},te.parseLiteral=function(e,t,r,n){r=r||this.state.start,n=n||this.state.startLoc;var i=this.startNodeAt(r,n);return this.addExtra(i,"rawValue",e),this.addExtra(i,"raw",this.input.slice(r,this.state.end)),i.value=e,this.next(),this.finishNode(i,t)},te.parseParenExpression=function(){this.expect(R.parenL);var e=this.parseExpression();return this.expect(R.parenR),e},te.parseParenAndDistinguishExpression=function(e,t,r){e=e||this.state.start,t=t||this.state.startLoc;var n=void 0;this.expect(R.parenL);for(var i=this.state.start,s=this.state.startLoc,a=[],o={start:0},u={start:0},l=!0,c=void 0,f=void 0;!this.match(R.parenR);){if(l)l=!1;else if(this.expect(R.comma,u.start||null),this.match(R.parenR)){f=this.state.start;break} +if(this.match(R.ellipsis)){var p=this.state.start,d=this.state.startLoc;c=this.state.start,a.push(this.parseParenItem(this.parseRest(),p,d));break}a.push(this.parseMaybeAssign(!1,o,this.parseParenItem,u))}var h=this.state.start,m=this.state.startLoc;this.expect(R.parenR);var y=this.startNodeAt(e,t);if(r&&this.shouldParseArrow()&&(y=this.parseArrow(y))){for(var v=a,g=Array.isArray(v),b=0,v=g?v:v[Symbol.iterator]();;){var E;if(g){if(b>=v.length)break;E=v[b++]}else{if(b=v.next(),b.done)break;E=b.value}var x=E;x.extra&&x.extra.parenthesized&&this.unexpected(x.extra.parenStart)}return this.parseArrowExpression(y,a)}return a.length||this.unexpected(this.state.lastTokStart),f&&this.unexpected(f),c&&this.unexpected(c),o.start&&this.unexpected(o.start),u.start&&this.unexpected(u.start),a.length>1?(n=this.startNodeAt(i,s),n.expressions=a,this.toReferencedList(n.expressions),this.finishNodeAt(n,"SequenceExpression",h,m)):n=a[0],this.addExtra(n,"parenthesized",!0),this.addExtra(n,"parenStart",e),n},te.shouldParseArrow=function(){return!this.canInsertSemicolon()},te.parseArrow=function(e){if(this.eat(R.arrow))return e},te.parseParenItem=function(e){return e},te.parseNew=function(){var e=this.startNode(),t=this.parseIdentifier(!0);if(this.eat(R.dot)){var r=this.parseMetaProperty(e,t,"target");return this.state.inFunction||this.raise(r.property.start,"new.target can only be used in functions"),r}return e.callee=this.parseNoCallExpr(),this.eat(R.parenL)?(e.arguments=this.parseExprList(R.parenR),this.toReferencedList(e.arguments)):e.arguments=[],this.finishNode(e,"NewExpression")},te.parseTemplateElement=function(e){var t=this.startNode();return null===this.state.value&&(e&&this.hasPlugin("templateInvalidEscapes")?this.state.invalidTemplateEscapePosition=null:this.raise(this.state.invalidTemplateEscapePosition,"Invalid escape sequence in template")),t.value={raw:this.input.slice(this.state.start,this.state.end).replace(/\r\n?/g,"\n"),cooked:this.state.value},this.next(),t.tail=this.match(R.backQuote),this.finishNode(t,"TemplateElement")},te.parseTemplate=function(e){var t=this.startNode();this.next(),t.expressions=[];var r=this.parseTemplateElement(e);for(t.quasis=[r];!r.tail;)this.expect(R.dollarBraceL),t.expressions.push(this.parseExpression()),this.expect(R.braceR),t.quasis.push(r=this.parseTemplateElement(e));return this.next(),this.finishNode(t,"TemplateLiteral")},te.parseObj=function(e,t){var r=[],n=Object.create(null),i=!0,s=this.startNode();s.properties=[],this.next();for(var a=null;!this.eat(R.braceR);){if(i)i=!1;else if(this.expect(R.comma),this.eat(R.braceR))break;for(;this.match(R.at);)r.push(this.parseDecorator());var o=this.startNode(),u=!1,l=!1,c=void 0,f=void 0;if(r.length&&(o.decorators=r,r=[]),this.hasPlugin("objectRestSpread")&&this.match(R.ellipsis)){if(o=this.parseSpread(e?{start:0}:void 0),o.type=e?"RestProperty":"SpreadProperty",e&&this.toAssignable(o.argument,!0,"object pattern"),s.properties.push(o),!e)continue;var p=this.state.start;if(null===a){if(this.eat(R.braceR))break;if(this.match(R.comma)&&this.lookahead().type===R.braceR)continue;a=p;continue}this.unexpected(a,"Cannot have multiple rest elements when destructuring")}if(o.method=!1,o.shorthand=!1,(e||t)&&(c=this.state.start,f=this.state.startLoc),e||(u=this.eat(R.star)),!e&&this.isContextual("async")){u&&this.unexpected();var d=this.parseIdentifier();this.match(R.colon)||this.match(R.parenL)||this.match(R.braceR)||this.match(R.eq)||this.match(R.comma)?(o.key=d,o.computed=!1):(l=!0,this.hasPlugin("asyncGenerators")&&(u=this.eat(R.star)),this.parsePropertyName(o))}else this.parsePropertyName(o);this.parseObjPropValue(o,c,f,u,l,e,t),this.checkPropClash(o,n),o.shorthand&&this.addExtra(o,"shorthand",!0),s.properties.push(o)}return null!==a&&this.unexpected(a,"The rest element has to be the last element when destructuring"),r.length&&this.raise(this.state.start,"You have trailing decorators with no property"),this.finishNode(s,e?"ObjectPattern":"ObjectExpression")},te.isGetterOrSetterMethod=function(e,t){return!t&&!e.computed&&"Identifier"===e.key.type&&("get"===e.key.name||"set"===e.key.name)&&(this.match(R.string)||this.match(R.num)||this.match(R.bracketL)||this.match(R.name)||this.state.type.keyword)},te.checkGetterSetterParamCount=function(e){var t="get"===e.kind?0:1;if(e.params.length!==t){var r=e.start;"get"===e.kind?this.raise(r,"getter should have no params"):this.raise(r,"setter should have exactly one param")}},te.parseObjectMethod=function(e,t,r,n){return r||t||this.match(R.parenL)?(n&&this.unexpected(),e.kind="method",e.method=!0,this.parseMethod(e,t,r),this.finishNode(e,"ObjectMethod")):this.isGetterOrSetterMethod(e,n)?((t||r)&&this.unexpected(),e.kind=e.key.name,this.parsePropertyName(e),this.parseMethod(e),this.checkGetterSetterParamCount(e),this.finishNode(e,"ObjectMethod")):void 0},te.parseObjectProperty=function(e,t,r,n,i){return this.eat(R.colon)?(e.value=n?this.parseMaybeDefault(this.state.start,this.state.startLoc):this.parseMaybeAssign(!1,i),this.finishNode(e,"ObjectProperty")):e.computed||"Identifier"!==e.key.type?void 0:(this.checkReservedWord(e.key.name,e.key.start,!0,!0),n?e.value=this.parseMaybeDefault(t,r,e.key.__clone()):this.match(R.eq)&&i?(i.start||(i.start=this.state.start),e.value=this.parseMaybeDefault(t,r,e.key.__clone())):e.value=e.key.__clone(),e.shorthand=!0,this.finishNode(e,"ObjectProperty"))},te.parseObjPropValue=function(e,t,r,n,i,s,a){var o=this.parseObjectMethod(e,n,i,s)||this.parseObjectProperty(e,t,r,s,a);return o||this.unexpected(),o},te.parsePropertyName=function(e){if(this.eat(R.bracketL))e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(R.bracketR);else{e.computed=!1;var t=this.state.inPropertyName;this.state.inPropertyName=!0,e.key=this.match(R.num)||this.match(R.string)?this.parseExprAtom():this.parseIdentifier(!0),this.state.inPropertyName=t}return e.key},te.initFunction=function(e,t){e.id=null,e.generator=!1,e.expression=!1,e.async=!!t},te.parseMethod=function(e,t,r){var n=this.state.inMethod;return this.state.inMethod=e.kind||!0,this.initFunction(e,r),this.expect(R.parenL),e.params=this.parseBindingList(R.parenR),e.generator=!!t,this.parseFunctionBody(e),this.state.inMethod=n,e},te.parseArrowExpression=function(e,t,r){return this.initFunction(e,r),e.params=this.toAssignableList(t,!0,"arrow function parameters"),this.parseFunctionBody(e,!0),this.finishNode(e,"ArrowFunctionExpression")},te.isStrictBody=function(e,t){if(!t&&e.body.directives.length)for(var r=e.body.directives,n=Array.isArray(r),i=0,r=n?r:r[Symbol.iterator]();;){var s;if(n){if(i>=r.length)break;s=r[i++]}else{if(i=r.next(),i.done)break;s=i.value}var a=s;if("use strict"===a.value.value)return!0}return!1},te.parseFunctionBody=function(e,t){var r=t&&!this.match(R.braceL),n=this.state.inAsync;if(this.state.inAsync=e.async,r)e.body=this.parseMaybeAssign(),e.expression=!0;else{var i=this.state.inFunction,s=this.state.inGenerator,a=this.state.labels;this.state.inFunction=!0,this.state.inGenerator=e.generator,this.state.labels=[],e.body=this.parseBlock(!0),e.expression=!1,this.state.inFunction=i,this.state.inGenerator=s,this.state.labels=a}this.state.inAsync=n;var o=this.isStrictBody(e,r),u=this.state.strict||t||o;if(o&&e.id&&"Identifier"===e.id.type&&"yield"===e.id.name&&this.raise(e.id.start,"Binding yield in strict mode"),u){var l=Object.create(null),c=this.state.strict;o&&(this.state.strict=!0),e.id&&this.checkLVal(e.id,!0,void 0,"function name");for(var f=e.params,p=Array.isArray(f),d=0,f=p?f:f[Symbol.iterator]();;){var h;if(p){if(d>=f.length)break;h=f[d++]}else{if(d=f.next(),d.done)break;h=d.value}var m=h;o&&"Identifier"!==m.type&&this.raise(m.start,"Non-simple parameter in strict mode"),this.checkLVal(m,!0,l,"function parameter list")}this.state.strict=c}},te.parseExprList=function(e,t,r){for(var n=[],i=!0;!this.eat(e);){if(i)i=!1;else if(this.expect(R.comma),this.eat(e))break;n.push(this.parseExprListItem(t,r))}return n},te.parseExprListItem=function(e,t,r){return e&&this.match(R.comma)?null:this.match(R.ellipsis)?this.parseSpread(t):this.parseMaybeAssign(!1,t,this.parseParenItem,r)},te.parseIdentifier=function(e){var t=this.startNode();return e||this.checkReservedWord(this.state.value,this.state.start,!!this.state.type.keyword,!1),this.match(R.name)?t.name=this.state.value:this.state.type.keyword?t.name=this.state.type.keyword:this.unexpected(),!e&&"await"===t.name&&this.state.inAsync&&this.raise(t.start,"invalid use of await inside of an async function"),t.loc.identifierName=t.name,this.next(),this.finishNode(t,"Identifier")},te.checkReservedWord=function(e,t,r,n){(this.isReservedWord(e)||r&&this.isKeyword(e))&&this.raise(t,e+" is a reserved word"),this.state.strict&&(v.strict(e)||n&&v.strictBind(e))&&this.raise(t,e+" is a reserved word in strict mode")},te.parseAwait=function(e){return this.state.inAsync||this.unexpected(),this.match(R.star)&&this.raise(e.start,"await* has been removed from the async functions proposal. Use Promise.all() instead."),e.argument=this.parseMaybeUnary(),this.finishNode(e,"AwaitExpression")},te.parseYield=function(){var e=this.startNode();return this.next(),this.match(R.semi)||this.canInsertSemicolon()||!this.match(R.star)&&!this.state.type.startsExpr?(e.delegate=!1,e.argument=null):(e.delegate=this.eat(R.star),e.argument=this.parseMaybeAssign()),this.finishNode(e,"YieldExpression")};var re=J.prototype,ne=["leadingComments","trailingComments","innerComments"],ie=function(){function e(t,r,n){w(this,e),this.type="",this.start=t,this.end=0,this.loc=new G(r),n&&(this.loc.filename=n)}return e.prototype.__clone=function(){var t=new e;for(var r in this)ne.indexOf(r)<0&&(t[r]=this[r]);return t},e}();re.startNode=function(){return new ie(this.state.start,this.state.startLoc,this.filename)},re.startNodeAt=function(e,t){return new ie(e,t,this.filename)},re.finishNode=function(e,t){return c.call(this,e,t,this.state.lastTokEnd,this.state.lastTokEndLoc)},re.finishNodeAt=function(e,t,r,n){return c.call(this,e,t,r,n)},J.prototype.raise=function(e,t){var r=u(this.input,e);t+=" ("+r.line+":"+r.column+")";var n=new SyntaxError(t);throw n.pos=e,n.loc=r,n};var se=J.prototype;se.addComment=function(e){this.filename&&(e.loc.filename=this.filename),this.state.trailingComments.push(e),this.state.leadingComments.push(e)},se.processComment=function(e){if(!("Program"===e.type&&e.body.length>0)){var t=this.state.commentStack,r=void 0,n=void 0,i=void 0,s=void 0,a=void 0;if(this.state.trailingComments.length>0)this.state.trailingComments[0].start>=e.end?(i=this.state.trailingComments,this.state.trailingComments=[]):this.state.trailingComments.length=0;else{var o=f(t);t.length>0&&o.trailingComments&&o.trailingComments[0].start>=e.end&&(i=o.trailingComments,o.trailingComments=null)}for(t.length>0&&f(t).start>=e.start&&(r=t.pop());t.length>0&&f(t).start>=e.start;)n=t.pop();if(!n&&r&&(n=r),r&&this.state.leadingComments.length>0){var u=f(this.state.leadingComments);if("ObjectProperty"===r.type){if(u.start>=e.start&&this.state.commentPreviousNode){for(a=0;a<this.state.leadingComments.length;a++)this.state.leadingComments[a].end<this.state.commentPreviousNode.end&&(this.state.leadingComments.splice(a,1),a--);this.state.leadingComments.length>0&&(r.trailingComments=this.state.leadingComments,this.state.leadingComments=[])}}else if("CallExpression"===e.type&&e.arguments&&e.arguments.length){var l=f(e.arguments);l&&u.start>=l.start&&u.end<=e.end&&this.state.commentPreviousNode&&this.state.leadingComments.length>0&&(l.trailingComments=this.state.leadingComments,this.state.leadingComments=[])}}if(n){if(n.leadingComments)if(n!==e&&f(n.leadingComments).end<=e.start)e.leadingComments=n.leadingComments,n.leadingComments=null;else for(s=n.leadingComments.length-2;s>=0;--s)if(n.leadingComments[s].end<=e.start){e.leadingComments=n.leadingComments.splice(0,s+1);break}}else if(this.state.leadingComments.length>0)if(f(this.state.leadingComments).end<=e.start){if(this.state.commentPreviousNode)for(a=0;a<this.state.leadingComments.length;a++)this.state.leadingComments[a].end<this.state.commentPreviousNode.end&&(this.state.leadingComments.splice(a,1),a--);this.state.leadingComments.length>0&&(e.leadingComments=this.state.leadingComments,this.state.leadingComments=[])}else{for(s=0;s<this.state.leadingComments.length&&!(this.state.leadingComments[s].end>e.start);s++);e.leadingComments=this.state.leadingComments.slice(0,s),0===e.leadingComments.length&&(e.leadingComments=null),i=this.state.leadingComments.slice(s),0===i.length&&(i=null)}this.state.commentPreviousNode=e,i&&(i.length&&i[0].start>=e.start&&f(i).end<=e.end?e.innerComments=i:e.trailingComments=i),t.push(e)}};var ae=J.prototype;ae.estreeParseRegExpLiteral=function(e){var t=e.pattern,r=e.flags,n=null;try{n=new RegExp(t,r)}catch(e){}var i=this.estreeParseLiteral(n);return i.regex={pattern:t,flags:r},i},ae.estreeParseLiteral=function(e){return this.parseLiteral(e,"Literal")},ae.directiveToStmt=function(e){var t=e.value,r=this.startNodeAt(e.start,e.loc.start),n=this.startNodeAt(t.start,t.loc.start);return n.value=t.value,n.raw=t.extra.raw,r.expression=this.finishNodeAt(n,"Literal",t.end,t.loc.end),r.directive=t.extra.raw.slice(1,-1),this.finishNodeAt(r,"ExpressionStatement",e.end,e.loc.end)};var oe=function(e){e.extend("checkDeclaration",function(e){return function(t){p(t)?this.checkDeclaration(t.value):e.call(this,t)}}),e.extend("checkGetterSetterParamCount",function(){return function(e){var t="get"===e.kind?0:1;if(e.value.params.length!==t){var r=e.start;"get"===e.kind?this.raise(r,"getter should have no params"):this.raise(r,"setter should have exactly one param")}}}),e.extend("checkLVal",function(e){return function(t,r,n){var i=this;switch(t.type){case"ObjectPattern":t.properties.forEach(function(e){i.checkLVal("Property"===e.type?e.value:e,r,n,"object destructuring pattern")});break;default:for(var s=arguments.length,a=Array(s>3?s-3:0),o=3;o<s;o++)a[o-3]=arguments[o];e.call.apply(e,[this,t,r,n].concat(a))}}}),e.extend("checkPropClash",function(){return function(e,t){if(!e.computed&&p(e)){var r=e.key;"__proto__"===("Identifier"===r.type?r.name:String(r.value))&&(t.proto&&this.raise(r.start,"Redefinition of __proto__ property"),t.proto=!0)}}}),e.extend("isStrictBody",function(){return function(e,t){if(!t&&e.body.body.length>0)for(var r=e.body.body,n=Array.isArray(r),i=0,r=n?r:r[Symbol.iterator]();;){var s;if(n){if(i>=r.length)break;s=r[i++]}else{if(i=r.next(),i.done)break;s=i.value}var a=s;if("ExpressionStatement"!==a.type||"Literal"!==a.expression.type)break;if("use strict"===a.expression.value)return!0}return!1}}),e.extend("isValidDirective",function(){return function(e){return!("ExpressionStatement"!==e.type||"Literal"!==e.expression.type||"string"!=typeof e.expression.value||e.expression.extra&&e.expression.extra.parenthesized)}}),e.extend("stmtToDirective",function(e){return function(t){var r=e.call(this,t),n=t.expression.value;return r.value.value=n,r}}),e.extend("parseBlockBody",function(e){return function(t){for(var r=this,n=arguments.length,i=Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];e.call.apply(e,[this,t].concat(i)),t.directives.reverse().forEach(function(e){t.body.unshift(r.directiveToStmt(e))}),delete t.directives}}),e.extend("parseClassMethod",function(){return function(e,t,r,n){this.parseMethod(t,r,n),t.typeParameters&&(t.value.typeParameters=t.typeParameters,delete t.typeParameters),e.body.push(this.finishNode(t,"MethodDefinition"))}}),e.extend("parseExprAtom",function(e){return function(){switch(this.state.type){case R.regexp:return this.estreeParseRegExpLiteral(this.state.value);case R.num:case R.string:return this.estreeParseLiteral(this.state.value);case R._null:return this.estreeParseLiteral(null);case R._true:return this.estreeParseLiteral(!0);case R._false:return this.estreeParseLiteral(!1);default:for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return e.call.apply(e,[this].concat(r))}}}),e.extend("parseLiteral",function(e){return function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];var i=e.call.apply(e,[this].concat(r));return i.raw=i.extra.raw,delete i.extra,i}}),e.extend("parseMethod",function(e){return function(t){var r=this.startNode();r.kind=t.kind;for(var n=arguments.length,i=Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return r=e.call.apply(e,[this,r].concat(i)),delete r.kind,t.value=this.finishNode(r,"FunctionExpression"),t}}),e.extend("parseObjectMethod",function(e){return function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];var i=e.call.apply(e,[this].concat(r));return i&&("method"===i.kind&&(i.kind="init"),i.type="Property"),i}}),e.extend("parseObjectProperty",function(e){return function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];var i=e.call.apply(e,[this].concat(r));return i&&(i.kind="init",i.type="Property"),i}}),e.extend("toAssignable",function(e){return function(t,r){for(var n=arguments.length,i=Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];if(p(t))return this.toAssignable.apply(this,[t.value,r].concat(i)),t;if("ObjectExpression"===t.type){t.type="ObjectPattern";for(var a=t.properties,o=Array.isArray(a),u=0,a=o?a:a[Symbol.iterator]();;){var l;if(o){if(u>=a.length)break;l=a[u++]}else{if(u=a.next(),u.done)break;l=u.value}var c=l;"get"===c.kind||"set"===c.kind?this.raise(c.key.start,"Object pattern can't contain getter or setter"):c.method?this.raise(c.key.start,"Object pattern can't contain methods"):this.toAssignable(c,r,"object destructuring pattern")}return t}return e.call.apply(e,[this,t,r].concat(i))}})},ue=["any","mixed","empty","bool","boolean","number","string","void","null"],le=J.prototype;le.flowParseTypeInitialiser=function(e){var t=this.state.inType;this.state.inType=!0,this.expect(e||R.colon);var r=this.flowParseType();return this.state.inType=t,r},le.flowParsePredicate=function(){var e=this.startNode(),t=this.state.startLoc,r=this.state.start;this.expect(R.modulo);var n=this.state.startLoc;return this.expectContextual("checks"),t.line===n.line&&t.column===n.column-1||this.raise(r,"Spaces between ´%´ and ´checks´ are not allowed here."),this.eat(R.parenL)?(e.expression=this.parseExpression(),this.expect(R.parenR),this.finishNode(e,"DeclaredPredicate")):this.finishNode(e,"InferredPredicate")},le.flowParseTypeAndPredicateInitialiser=function(){var e=this.state.inType;this.state.inType=!0,this.expect(R.colon);var t=null,r=null;return this.match(R.modulo)?(this.state.inType=e,r=this.flowParsePredicate()):(t=this.flowParseType(),this.state.inType=e,this.match(R.modulo)&&(r=this.flowParsePredicate())),[t,r]},le.flowParseDeclareClass=function(e){return this.next(),this.flowParseInterfaceish(e,!0),this.finishNode(e,"DeclareClass")},le.flowParseDeclareFunction=function(e){this.next();var t=e.id=this.parseIdentifier(),r=this.startNode(),n=this.startNode();this.isRelational("<")?r.typeParameters=this.flowParseTypeParameterDeclaration():r.typeParameters=null,this.expect(R.parenL);var i=this.flowParseFunctionTypeParams();r.params=i.params,r.rest=i.rest,this.expect(R.parenR);var s=null,a=this.flowParseTypeAndPredicateInitialiser();return r.returnType=a[0],s=a[1],n.typeAnnotation=this.finishNode(r,"FunctionTypeAnnotation"),n.predicate=s,t.typeAnnotation=this.finishNode(n,"TypeAnnotation"),this.finishNode(t,t.type),this.semicolon(),this.finishNode(e,"DeclareFunction")},le.flowParseDeclare=function(e){return this.match(R._class)?this.flowParseDeclareClass(e):this.match(R._function)?this.flowParseDeclareFunction(e):this.match(R._var)?this.flowParseDeclareVariable(e):this.isContextual("module")?this.lookahead().type===R.dot?this.flowParseDeclareModuleExports(e):this.flowParseDeclareModule(e):this.isContextual("type")?this.flowParseDeclareTypeAlias(e):this.isContextual("opaque")?this.flowParseDeclareOpaqueType(e):this.isContextual("interface")?this.flowParseDeclareInterface(e):this.match(R._export)?this.flowParseDeclareExportDeclaration(e):void this.unexpected()},le.flowParseDeclareExportDeclaration=function(e){if(this.expect(R._export),this.isContextual("opaque"))return e.declaration=this.flowParseDeclare(this.startNode()),e.default=!1,this.finishNode(e,"DeclareExportDeclaration");throw this.unexpected()},le.flowParseDeclareVariable=function(e){return this.next(),e.id=this.flowParseTypeAnnotatableIdentifier(),this.semicolon(),this.finishNode(e,"DeclareVariable")},le.flowParseDeclareModule=function(e){this.next(),this.match(R.string)?e.id=this.parseExprAtom():e.id=this.parseIdentifier();var t=e.body=this.startNode(),r=t.body=[];for(this.expect(R.braceL);!this.match(R.braceR);){var n=this.startNode();if(this.match(R._import)){var i=this.lookahead();"type"!==i.value&&"typeof"!==i.value&&this.unexpected(null,"Imports within a `declare module` body must always be `import type` or `import typeof`"),this.parseImport(n)}else this.expectContextual("declare","Only declares and type imports are allowed inside declare module"),n=this.flowParseDeclare(n,!0);r.push(n)}return this.expect(R.braceR),this.finishNode(t,"BlockStatement"),this.finishNode(e,"DeclareModule")},le.flowParseDeclareModuleExports=function(e){return this.expectContextual("module"),this.expect(R.dot),this.expectContextual("exports"),e.typeAnnotation=this.flowParseTypeAnnotation(),this.semicolon(),this.finishNode(e,"DeclareModuleExports")},le.flowParseDeclareTypeAlias=function(e){return this.next(),this.flowParseTypeAlias(e),this.finishNode(e,"DeclareTypeAlias")},le.flowParseDeclareOpaqueType=function(e){return this.next(),this.flowParseOpaqueType(e,!0),this.finishNode(e,"DeclareOpaqueType")},le.flowParseDeclareInterface=function(e){return this.next(),this.flowParseInterfaceish(e),this.finishNode(e,"DeclareInterface")},le.flowParseInterfaceish=function(e){if(e.id=this.parseIdentifier(),this.isRelational("<")?e.typeParameters=this.flowParseTypeParameterDeclaration():e.typeParameters=null,e.extends=[],e.mixins=[],this.eat(R._extends))do{e.extends.push(this.flowParseInterfaceExtends())}while(this.eat(R.comma));if(this.isContextual("mixins")){this.next();do{e.mixins.push(this.flowParseInterfaceExtends())}while(this.eat(R.comma))}e.body=this.flowParseObjectType(!0,!1,!1)},le.flowParseInterfaceExtends=function(){var e=this.startNode();return e.id=this.flowParseQualifiedTypeIdentifier(),this.isRelational("<")?e.typeParameters=this.flowParseTypeParameterInstantiation():e.typeParameters=null,this.finishNode(e,"InterfaceExtends")},le.flowParseInterface=function(e){return this.flowParseInterfaceish(e,!1),this.finishNode(e,"InterfaceDeclaration")},le.flowParseRestrictedIdentifier=function(e){return ue.indexOf(this.state.value)>-1&&this.raise(this.state.start,"Cannot overwrite primitive type "+this.state.value),this.parseIdentifier(e)},le.flowParseTypeAlias=function(e){return e.id=this.flowParseRestrictedIdentifier(),this.isRelational("<")?e.typeParameters=this.flowParseTypeParameterDeclaration():e.typeParameters=null,e.right=this.flowParseTypeInitialiser(R.eq),this.semicolon(),this.finishNode(e,"TypeAlias")},le.flowParseOpaqueType=function(e,t){return this.expectContextual("type"),e.id=this.flowParseRestrictedIdentifier(),this.isRelational("<")?e.typeParameters=this.flowParseTypeParameterDeclaration():e.typeParameters=null,e.supertype=null,this.match(R.colon)&&(e.supertype=this.flowParseTypeInitialiser(R.colon)),e.impltype=null,t||(e.impltype=this.flowParseTypeInitialiser(R.eq)),this.semicolon(),this.finishNode(e,"OpaqueType")},le.flowParseTypeParameter=function(){var e=this.startNode(),t=this.flowParseVariance(),r=this.flowParseTypeAnnotatableIdentifier();return e.name=r.name,e.variance=t,e.bound=r.typeAnnotation,this.match(R.eq)&&(this.eat(R.eq),e.default=this.flowParseType()),this.finishNode(e,"TypeParameter")},le.flowParseTypeParameterDeclaration=function(){var e=this.state.inType,t=this.startNode();t.params=[],this.state.inType=!0,this.isRelational("<")||this.match(R.jsxTagStart)?this.next():this.unexpected();do{t.params.push(this.flowParseTypeParameter()),this.isRelational(">")||this.expect(R.comma)}while(!this.isRelational(">"));return this.expectRelational(">"),this.state.inType=e,this.finishNode(t,"TypeParameterDeclaration")},le.flowParseTypeParameterInstantiation=function(){var e=this.startNode(),t=this.state.inType;for(e.params=[],this.state.inType=!0,this.expectRelational("<");!this.isRelational(">");)e.params.push(this.flowParseType()),this.isRelational(">")||this.expect(R.comma);return this.expectRelational(">"),this.state.inType=t,this.finishNode(e,"TypeParameterInstantiation")},le.flowParseObjectPropertyKey=function(){return this.match(R.num)||this.match(R.string)?this.parseExprAtom():this.parseIdentifier(!0)},le.flowParseObjectTypeIndexer=function(e,t,r){return e.static=t,this.expect(R.bracketL),this.lookahead().type===R.colon?(e.id=this.flowParseObjectPropertyKey(),e.key=this.flowParseTypeInitialiser()):(e.id=null,e.key=this.flowParseType()),this.expect(R.bracketR),e.value=this.flowParseTypeInitialiser(),e.variance=r,this.flowObjectTypeSemicolon(),this.finishNode(e,"ObjectTypeIndexer")},le.flowParseObjectTypeMethodish=function(e){for(e.params=[],e.rest=null,e.typeParameters=null,this.isRelational("<")&&(e.typeParameters=this.flowParseTypeParameterDeclaration()),this.expect(R.parenL);!this.match(R.parenR)&&!this.match(R.ellipsis);)e.params.push(this.flowParseFunctionTypeParam()),this.match(R.parenR)||this.expect(R.comma);return this.eat(R.ellipsis)&&(e.rest=this.flowParseFunctionTypeParam()),this.expect(R.parenR),e.returnType=this.flowParseTypeInitialiser(),this.finishNode(e,"FunctionTypeAnnotation")},le.flowParseObjectTypeMethod=function(e,t,r,n){var i=this.startNodeAt(e,t);return i.value=this.flowParseObjectTypeMethodish(this.startNodeAt(e,t)),i.static=r,i.key=n,i.optional=!1,this.flowObjectTypeSemicolon(),this.finishNode(i,"ObjectTypeProperty")},le.flowParseObjectTypeCallProperty=function(e,t){var r=this.startNode();return e.static=t,e.value=this.flowParseObjectTypeMethodish(r),this.flowObjectTypeSemicolon(),this.finishNode(e,"ObjectTypeCallProperty")},le.flowParseObjectType=function(e,t,r){var n=this.state.inType;this.state.inType=!0;var i=this.startNode(),s=void 0,a=void 0,o=!1;i.callProperties=[],i.properties=[],i.indexers=[];var u=void 0,l=void 0;for(t&&this.match(R.braceBarL)?(this.expect(R.braceBarL),u=R.braceBarR,l=!0):(this.expect(R.braceL),u=R.braceR,l=!1),i.exact=l;!this.match(u);){var c=!1,f=this.state.start,p=this.state.startLoc;s=this.startNode(),e&&this.isContextual("static")&&this.lookahead().type!==R.colon&&(this.next(),o=!0);var d=this.state.start,h=this.flowParseVariance();this.match(R.bracketL)?i.indexers.push(this.flowParseObjectTypeIndexer(s,o,h)):this.match(R.parenL)||this.isRelational("<")?(h&&this.unexpected(d),i.callProperties.push(this.flowParseObjectTypeCallProperty(s,o))):this.match(R.ellipsis)?(r||this.unexpected(null,"Spread operator cannot appear in class or interface definitions"),h&&this.unexpected(h.start,"Spread properties cannot have variance"),this.expect(R.ellipsis),s.argument=this.flowParseType(),this.flowObjectTypeSemicolon(),i.properties.push(this.finishNode(s,"ObjectTypeSpreadProperty"))):(a=this.flowParseObjectPropertyKey(),this.isRelational("<")||this.match(R.parenL)?(h&&this.unexpected(h.start),i.properties.push(this.flowParseObjectTypeMethod(f,p,o,a))):(this.eat(R.question)&&(c=!0),s.key=a,s.value=this.flowParseTypeInitialiser(),s.optional=c,s.static=o,s.variance=h,this.flowObjectTypeSemicolon(),i.properties.push(this.finishNode(s,"ObjectTypeProperty")))),o=!1}this.expect(u);var m=this.finishNode(i,"ObjectTypeAnnotation");return this.state.inType=n,m},le.flowObjectTypeSemicolon=function(){this.eat(R.semi)||this.eat(R.comma)||this.match(R.braceR)||this.match(R.braceBarR)||this.unexpected()},le.flowParseQualifiedTypeIdentifier=function(e,t,r){e=e||this.state.start,t=t||this.state.startLoc;for(var n=r||this.parseIdentifier();this.eat(R.dot);){var i=this.startNodeAt(e,t);i.qualification=n,i.id=this.parseIdentifier(),n=this.finishNode(i,"QualifiedTypeIdentifier")}return n},le.flowParseGenericType=function(e,t,r){var n=this.startNodeAt(e,t);return n.typeParameters=null,n.id=this.flowParseQualifiedTypeIdentifier(e,t,r),this.isRelational("<")&&(n.typeParameters=this.flowParseTypeParameterInstantiation()),this.finishNode(n,"GenericTypeAnnotation")},le.flowParseTypeofType=function(){var e=this.startNode();return this.expect(R._typeof),e.argument=this.flowParsePrimaryType(),this.finishNode(e,"TypeofTypeAnnotation")},le.flowParseTupleType=function(){var e=this.startNode();for(e.types=[],this.expect(R.bracketL);this.state.pos<this.input.length&&!this.match(R.bracketR)&&(e.types.push(this.flowParseType()),!this.match(R.bracketR));)this.expect(R.comma);return this.expect(R.bracketR),this.finishNode(e,"TupleTypeAnnotation")},le.flowParseFunctionTypeParam=function(){var e=null,t=!1,r=null,n=this.startNode(),i=this.lookahead();return i.type===R.colon||i.type===R.question?(e=this.parseIdentifier(),this.eat(R.question)&&(t=!0),r=this.flowParseTypeInitialiser()):r=this.flowParseType(),n.name=e,n.optional=t,n.typeAnnotation=r,this.finishNode(n,"FunctionTypeParam")},le.reinterpretTypeAsFunctionTypeParam=function(e){var t=this.startNodeAt(e.start,e.loc.start);return t.name=null,t.optional=!1,t.typeAnnotation=e,this.finishNode(t,"FunctionTypeParam")},le.flowParseFunctionTypeParams=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t={params:e,rest:null};!this.match(R.parenR)&&!this.match(R.ellipsis);)t.params.push(this.flowParseFunctionTypeParam()),this.match(R.parenR)||this.expect(R.comma);return this.eat(R.ellipsis)&&(t.rest=this.flowParseFunctionTypeParam()),t},le.flowIdentToTypeAnnotation=function(e,t,r,n){switch(n.name){case"any":return this.finishNode(r,"AnyTypeAnnotation");case"void":return this.finishNode(r,"VoidTypeAnnotation");case"bool":case"boolean":return this.finishNode(r,"BooleanTypeAnnotation");case"mixed":return this.finishNode(r,"MixedTypeAnnotation");case"empty":return this.finishNode(r,"EmptyTypeAnnotation");case"number":return this.finishNode(r,"NumberTypeAnnotation");case"string":return this.finishNode(r,"StringTypeAnnotation");default:return this.flowParseGenericType(e,t,n)}},le.flowParsePrimaryType=function(){var e=this.state.start,t=this.state.startLoc,r=this.startNode(),n=void 0,i=void 0,s=!1,a=this.state.noAnonFunctionType;switch(this.state.type){case R.name:return this.flowIdentToTypeAnnotation(e,t,r,this.parseIdentifier());case R.braceL:return this.flowParseObjectType(!1,!1,!0);case R.braceBarL:return this.flowParseObjectType(!1,!0,!0);case R.bracketL:return this.flowParseTupleType();case R.relational:if("<"===this.state.value)return r.typeParameters=this.flowParseTypeParameterDeclaration(),this.expect(R.parenL),n=this.flowParseFunctionTypeParams(),r.params=n.params,r.rest=n.rest,this.expect(R.parenR),this.expect(R.arrow),r.returnType=this.flowParseType(),this.finishNode(r,"FunctionTypeAnnotation");break;case R.parenL:if(this.next(),!this.match(R.parenR)&&!this.match(R.ellipsis))if(this.match(R.name)){var o=this.lookahead().type;s=o!==R.question&&o!==R.colon}else s=!0;if(s){if(this.state.noAnonFunctionType=!1,i=this.flowParseType(),this.state.noAnonFunctionType=a,this.state.noAnonFunctionType||!(this.match(R.comma)||this.match(R.parenR)&&this.lookahead().type===R.arrow))return this.expect(R.parenR),i;this.eat(R.comma)}return n=i?this.flowParseFunctionTypeParams([this.reinterpretTypeAsFunctionTypeParam(i)]):this.flowParseFunctionTypeParams(),r.params=n.params,r.rest=n.rest,this.expect(R.parenR),this.expect(R.arrow),r.returnType=this.flowParseType(),r.typeParameters=null,this.finishNode(r,"FunctionTypeAnnotation");case R.string:return this.parseLiteral(this.state.value,"StringLiteralTypeAnnotation");case R._true:case R._false:return r.value=this.match(R._true),this.next(),this.finishNode(r,"BooleanLiteralTypeAnnotation");case R.plusMin:if("-"===this.state.value)return this.next(), +this.match(R.num)||this.unexpected(null,"Unexpected token, expected number"),this.parseLiteral(-this.state.value,"NumericLiteralTypeAnnotation",r.start,r.loc.start);this.unexpected();case R.num:return this.parseLiteral(this.state.value,"NumericLiteralTypeAnnotation");case R._null:return r.value=this.match(R._null),this.next(),this.finishNode(r,"NullLiteralTypeAnnotation");case R._this:return r.value=this.match(R._this),this.next(),this.finishNode(r,"ThisTypeAnnotation");case R.star:return this.next(),this.finishNode(r,"ExistentialTypeParam");default:if("typeof"===this.state.type.keyword)return this.flowParseTypeofType()}this.unexpected()},le.flowParsePostfixType=function(){for(var e=this.state.start,t=this.state.startLoc,r=this.flowParsePrimaryType();!this.canInsertSemicolon()&&this.match(R.bracketL);){var n=this.startNodeAt(e,t);n.elementType=r,this.expect(R.bracketL),this.expect(R.bracketR),r=this.finishNode(n,"ArrayTypeAnnotation")}return r},le.flowParsePrefixType=function(){var e=this.startNode();return this.eat(R.question)?(e.typeAnnotation=this.flowParsePrefixType(),this.finishNode(e,"NullableTypeAnnotation")):this.flowParsePostfixType()},le.flowParseAnonFunctionWithoutParens=function(){var e=this.flowParsePrefixType();if(!this.state.noAnonFunctionType&&this.eat(R.arrow)){var t=this.startNodeAt(e.start,e.loc.start);return t.params=[this.reinterpretTypeAsFunctionTypeParam(e)],t.rest=null,t.returnType=this.flowParseType(),t.typeParameters=null,this.finishNode(t,"FunctionTypeAnnotation")}return e},le.flowParseIntersectionType=function(){var e=this.startNode();this.eat(R.bitwiseAND);var t=this.flowParseAnonFunctionWithoutParens();for(e.types=[t];this.eat(R.bitwiseAND);)e.types.push(this.flowParseAnonFunctionWithoutParens());return 1===e.types.length?t:this.finishNode(e,"IntersectionTypeAnnotation")},le.flowParseUnionType=function(){var e=this.startNode();this.eat(R.bitwiseOR);var t=this.flowParseIntersectionType();for(e.types=[t];this.eat(R.bitwiseOR);)e.types.push(this.flowParseIntersectionType());return 1===e.types.length?t:this.finishNode(e,"UnionTypeAnnotation")},le.flowParseType=function(){var e=this.state.inType;this.state.inType=!0;var t=this.flowParseUnionType();return this.state.inType=e,t},le.flowParseTypeAnnotation=function(){var e=this.startNode();return e.typeAnnotation=this.flowParseTypeInitialiser(),this.finishNode(e,"TypeAnnotation")},le.flowParseTypeAndPredicateAnnotation=function(){var e=this.startNode(),t=this.flowParseTypeAndPredicateInitialiser();return e.typeAnnotation=t[0],e.predicate=t[1],this.finishNode(e,"TypeAnnotation")},le.flowParseTypeAnnotatableIdentifier=function(){var e=this.flowParseRestrictedIdentifier();return this.match(R.colon)&&(e.typeAnnotation=this.flowParseTypeAnnotation(),this.finishNode(e,e.type)),e},le.typeCastToParameter=function(e){return e.expression.typeAnnotation=e.typeAnnotation,this.finishNodeAt(e.expression,e.expression.type,e.typeAnnotation.end,e.typeAnnotation.loc.end)},le.flowParseVariance=function(){var e=null;return this.match(R.plusMin)&&("+"===this.state.value?e="plus":"-"===this.state.value&&(e="minus"),this.next()),e};var ce=function(e){e.extend("parseFunctionBody",function(e){return function(t,r){return this.match(R.colon)&&!r&&(t.returnType=this.flowParseTypeAndPredicateAnnotation()),e.call(this,t,r)}}),e.extend("parseStatement",function(e){return function(t,r){if(this.state.strict&&this.match(R.name)&&"interface"===this.state.value){var n=this.startNode();return this.next(),this.flowParseInterface(n)}return e.call(this,t,r)}}),e.extend("parseExpressionStatement",function(e){return function(t,r){if("Identifier"===r.type)if("declare"===r.name){if(this.match(R._class)||this.match(R.name)||this.match(R._function)||this.match(R._var)||this.match(R._export))return this.flowParseDeclare(t)}else if(this.match(R.name)){if("interface"===r.name)return this.flowParseInterface(t);if("type"===r.name)return this.flowParseTypeAlias(t);if("opaque"===r.name)return this.flowParseOpaqueType(t,!1)}return e.call(this,t,r)}}),e.extend("shouldParseExportDeclaration",function(e){return function(){return this.isContextual("type")||this.isContextual("interface")||this.isContextual("opaque")||e.call(this)}}),e.extend("isExportDefaultSpecifier",function(e){return function(){return(!this.match(R.name)||"type"!==this.state.value&&"interface"!==this.state.value&&"opaque"!==this.state.value)&&e.call(this)}}),e.extend("parseConditional",function(e){return function(t,r,n,i,s){if(s&&this.match(R.question)){var a=this.state.clone();try{return e.call(this,t,r,n,i)}catch(e){if(e instanceof SyntaxError)return this.state=a,s.start=e.pos||this.state.start,t;throw e}}return e.call(this,t,r,n,i)}}),e.extend("parseParenItem",function(e){return function(t,r,n){if(t=e.call(this,t,r,n),this.eat(R.question)&&(t.optional=!0),this.match(R.colon)){var i=this.startNodeAt(r,n);return i.expression=t,i.typeAnnotation=this.flowParseTypeAnnotation(),this.finishNode(i,"TypeCastExpression")}return t}}),e.extend("parseExport",function(e){return function(t){return t=e.call(this,t),"ExportNamedDeclaration"===t.type&&(t.exportKind=t.exportKind||"value"),t}}),e.extend("parseExportDeclaration",function(e){return function(t){if(this.isContextual("type")){t.exportKind="type";var r=this.startNode();return this.next(),this.match(R.braceL)?(t.specifiers=this.parseExportSpecifiers(),this.parseExportFrom(t),null):this.flowParseTypeAlias(r)}if(this.isContextual("opaque")){t.exportKind="type";var n=this.startNode();return this.next(),this.flowParseOpaqueType(n,!1)}if(this.isContextual("interface")){t.exportKind="type";var i=this.startNode();return this.next(),this.flowParseInterface(i)}return e.call(this,t)}}),e.extend("parseClassId",function(e){return function(t){e.apply(this,arguments),this.isRelational("<")&&(t.typeParameters=this.flowParseTypeParameterDeclaration())}}),e.extend("isKeyword",function(e){return function(t){return(!this.state.inType||"void"!==t)&&e.call(this,t)}}),e.extend("readToken",function(e){return function(t){return!this.state.inType||62!==t&&60!==t?e.call(this,t):this.finishOp(R.relational,1)}}),e.extend("jsx_readToken",function(e){return function(){if(!this.state.inType)return e.call(this)}}),e.extend("toAssignable",function(e){return function(t,r,n){return"TypeCastExpression"===t.type?e.call(this,this.typeCastToParameter(t),r,n):e.call(this,t,r,n)}}),e.extend("toAssignableList",function(e){return function(t,r,n){for(var i=0;i<t.length;i++){var s=t[i];s&&"TypeCastExpression"===s.type&&(t[i]=this.typeCastToParameter(s))}return e.call(this,t,r,n)}}),e.extend("toReferencedList",function(){return function(e){for(var t=0;t<e.length;t++){var r=e[t];r&&r._exprListItem&&"TypeCastExpression"===r.type&&this.raise(r.start,"Unexpected type cast")}return e}}),e.extend("parseExprListItem",function(e){return function(){for(var t=this.startNode(),r=arguments.length,n=Array(r),i=0;i<r;i++)n[i]=arguments[i];var s=e.call.apply(e,[this].concat(n));return this.match(R.colon)?(t._exprListItem=!0,t.expression=s,t.typeAnnotation=this.flowParseTypeAnnotation(),this.finishNode(t,"TypeCastExpression")):s}}),e.extend("checkLVal",function(e){return function(t){if("TypeCastExpression"!==t.type)return e.apply(this,arguments)}}),e.extend("parseClassProperty",function(e){return function(t){return delete t.variancePos,this.match(R.colon)&&(t.typeAnnotation=this.flowParseTypeAnnotation()),e.call(this,t)}}),e.extend("isClassMethod",function(e){return function(){return this.isRelational("<")||e.call(this)}}),e.extend("isClassProperty",function(e){return function(){return this.match(R.colon)||e.call(this)}}),e.extend("isNonstaticConstructor",function(e){return function(t){return!this.match(R.colon)&&e.call(this,t)}}),e.extend("parseClassMethod",function(e){return function(t,r){r.variance&&this.unexpected(r.variancePos),delete r.variance,delete r.variancePos,this.isRelational("<")&&(r.typeParameters=this.flowParseTypeParameterDeclaration());for(var n=arguments.length,i=Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];e.call.apply(e,[this,t,r].concat(i))}}),e.extend("parseClassSuper",function(e){return function(t,r){if(e.call(this,t,r),t.superClass&&this.isRelational("<")&&(t.superTypeParameters=this.flowParseTypeParameterInstantiation()),this.isContextual("implements")){this.next();var n=t.implements=[];do{var i=this.startNode();i.id=this.parseIdentifier(),this.isRelational("<")?i.typeParameters=this.flowParseTypeParameterInstantiation():i.typeParameters=null,n.push(this.finishNode(i,"ClassImplements"))}while(this.eat(R.comma))}}}),e.extend("parsePropertyName",function(e){return function(t){var r=this.state.start,n=this.flowParseVariance(),i=e.call(this,t);return t.variance=n,t.variancePos=r,i}}),e.extend("parseObjPropValue",function(e){return function(t){t.variance&&this.unexpected(t.variancePos),delete t.variance,delete t.variancePos;var r=void 0;this.isRelational("<")&&(r=this.flowParseTypeParameterDeclaration(),this.match(R.parenL)||this.unexpected()),e.apply(this,arguments),r&&((t.value||t).typeParameters=r)}}),e.extend("parseAssignableListItemTypes",function(){return function(e){return this.eat(R.question)&&(e.optional=!0),this.match(R.colon)&&(e.typeAnnotation=this.flowParseTypeAnnotation()),this.finishNode(e,e.type),e}}),e.extend("parseMaybeDefault",function(e){return function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];var i=e.apply(this,r);return"AssignmentPattern"===i.type&&i.typeAnnotation&&i.right.start<i.typeAnnotation.start&&this.raise(i.typeAnnotation.start,"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`"),i}}),e.extend("parseImportSpecifiers",function(e){return function(t){t.importKind="value";var r=null;if(this.match(R._typeof)?r="typeof":this.isContextual("type")&&(r="type"),r){var n=this.lookahead();(n.type===R.name&&"from"!==n.value||n.type===R.braceL||n.type===R.star)&&(this.next(),t.importKind=r)}e.call(this,t)}}),e.extend("parseImportSpecifier",function(){return function(e){var t=this.startNode(),r=this.state.start,n=this.parseIdentifier(!0),i=null;"type"===n.name?i="type":"typeof"===n.name&&(i="typeof");var s=!1;if(this.isContextual("as")){var a=this.parseIdentifier(!0);null===i||this.match(R.name)||this.state.type.keyword?(t.imported=n,t.importKind=null,t.local=this.parseIdentifier()):(t.imported=a,t.importKind=i,t.local=a.__clone())}else null!==i&&(this.match(R.name)||this.state.type.keyword)?(t.imported=this.parseIdentifier(!0),t.importKind=i,this.eatContextual("as")?t.local=this.parseIdentifier():(s=!0,t.local=t.imported.__clone())):(s=!0,t.imported=n,t.importKind=null,t.local=t.imported.__clone());"type"!==e.importKind&&"typeof"!==e.importKind||"type"!==t.importKind&&"typeof"!==t.importKind||this.raise(r,"`The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements`"),s&&this.checkReservedWord(t.local.name,t.start,!0,!0),this.checkLVal(t.local,!0,void 0,"import specifier"),e.specifiers.push(this.finishNode(t,"ImportSpecifier"))}}),e.extend("parseFunctionParams",function(e){return function(t){this.isRelational("<")&&(t.typeParameters=this.flowParseTypeParameterDeclaration()),e.call(this,t)}}),e.extend("parseVarHead",function(e){return function(t){e.call(this,t),this.match(R.colon)&&(t.id.typeAnnotation=this.flowParseTypeAnnotation(),this.finishNode(t.id,t.id.type))}}),e.extend("parseAsyncArrowFromCallExpression",function(e){return function(t,r){if(this.match(R.colon)){var n=this.state.noAnonFunctionType;this.state.noAnonFunctionType=!0,t.returnType=this.flowParseTypeAnnotation(),this.state.noAnonFunctionType=n}return e.call(this,t,r)}}),e.extend("shouldParseAsyncArrow",function(e){return function(){return this.match(R.colon)||e.call(this)}}),e.extend("parseMaybeAssign",function(e){return function(){for(var t=null,r=arguments.length,n=Array(r),i=0;i<r;i++)n[i]=arguments[i];if(R.jsxTagStart&&this.match(R.jsxTagStart)){var s=this.state.clone();try{return e.apply(this,n)}catch(e){if(!(e instanceof SyntaxError))throw e;this.state=s,this.state.context.length-=2,t=e}}if(null!=t||this.isRelational("<")){var a=void 0,o=void 0;try{o=this.flowParseTypeParameterDeclaration(),a=e.apply(this,n),a.typeParameters=o,a.start=o.start,a.loc.start=o.loc.start}catch(e){throw t||e}if("ArrowFunctionExpression"===a.type)return a;if(null!=t)throw t;this.raise(o.start,"Expected an arrow function after this type parameter declaration")}return e.apply(this,n)}}),e.extend("parseArrow",function(e){return function(t){if(this.match(R.colon)){var r=this.state.clone();try{var n=this.state.noAnonFunctionType;this.state.noAnonFunctionType=!0;var i=this.flowParseTypeAndPredicateAnnotation();this.state.noAnonFunctionType=n,this.canInsertSemicolon()&&this.unexpected(),this.match(R.arrow)||this.unexpected(),t.returnType=i}catch(e){if(!(e instanceof SyntaxError))throw e;this.state=r}}return e.call(this,t)}}),e.extend("shouldParseArrow",function(e){return function(){return this.match(R.colon)||e.call(this)}})},fe=String.fromCodePoint;if(!fe){var pe=String.fromCharCode,de=Math.floor;fe=function(){var e=[],t=void 0,r=void 0,n=-1,i=arguments.length;if(!i)return"";for(var s="";++n<i;){var a=Number(arguments[n]);if(!isFinite(a)||a<0||a>1114111||de(a)!=a)throw RangeError("Invalid code point: "+a);a<=65535?e.push(a):(a-=65536,t=55296+(a>>10),r=a%1024+56320,e.push(t,r)),(n+1==i||e.length>16384)&&(s+=pe.apply(null,e),e.length=0)}return s}}var he=fe,me={quot:'"',amp:"&",apos:"'",lt:"<",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",zwnj:"",zwj:"",lrm:"",rlm:"",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"},ye=/^[\da-fA-F]+$/,ve=/^\d+$/;U.j_oTag=new j("<tag",!1),U.j_cTag=new j("</tag",!1),U.j_expr=new j("<tag>...</tag>",!0,!0),R.jsxName=new T("jsxName"),R.jsxText=new T("jsxText",{beforeExpr:!0}),R.jsxTagStart=new T("jsxTagStart",{startsExpr:!0}),R.jsxTagEnd=new T("jsxTagEnd"),R.jsxTagStart.updateContext=function(){this.state.context.push(U.j_expr),this.state.context.push(U.j_oTag),this.state.exprAllowed=!1},R.jsxTagEnd.updateContext=function(e){var t=this.state.context.pop();t===U.j_oTag&&e===R.slash||t===U.j_cTag?(this.state.context.pop(),this.state.exprAllowed=this.curContext()===U.j_expr):this.state.exprAllowed=!0};var ge=J.prototype;ge.jsxReadToken=function(){for(var e="",t=this.state.pos;;){this.state.pos>=this.input.length&&this.raise(this.state.start,"Unterminated JSX contents");var r=this.input.charCodeAt(this.state.pos);switch(r){case 60:case 123:return this.state.pos===this.state.start?60===r&&this.state.exprAllowed?(++this.state.pos,this.finishToken(R.jsxTagStart)):this.getTokenFromCode(r):(e+=this.input.slice(t,this.state.pos),this.finishToken(R.jsxText,e));case 38:e+=this.input.slice(t,this.state.pos),e+=this.jsxReadEntity(),t=this.state.pos;break;default:o(r)?(e+=this.input.slice(t,this.state.pos),e+=this.jsxReadNewLine(!0),t=this.state.pos):++this.state.pos}}},ge.jsxReadNewLine=function(e){var t=this.input.charCodeAt(this.state.pos),r=void 0;return++this.state.pos,13===t&&10===this.input.charCodeAt(this.state.pos)?(++this.state.pos,r=e?"\n":"\r\n"):r=String.fromCharCode(t),++this.state.curLine,this.state.lineStart=this.state.pos,r},ge.jsxReadString=function(e){for(var t="",r=++this.state.pos;;){this.state.pos>=this.input.length&&this.raise(this.state.start,"Unterminated string constant");var n=this.input.charCodeAt(this.state.pos);if(n===e)break;38===n?(t+=this.input.slice(r,this.state.pos),t+=this.jsxReadEntity(),r=this.state.pos):o(n)?(t+=this.input.slice(r,this.state.pos),t+=this.jsxReadNewLine(!1),r=this.state.pos):++this.state.pos}return t+=this.input.slice(r,this.state.pos++),this.finishToken(R.string,t)},ge.jsxReadEntity=function(){for(var e="",t=0,r=void 0,n=this.input[this.state.pos],i=++this.state.pos;this.state.pos<this.input.length&&t++<10;){if(";"===(n=this.input[this.state.pos++])){"#"===e[0]?"x"===e[1]?(e=e.substr(2),ye.test(e)&&(r=he(parseInt(e,16)))):(e=e.substr(1),ve.test(e)&&(r=he(parseInt(e,10)))):r=me[e];break}e+=n}return r||(this.state.pos=i,"&")},ge.jsxReadWord=function(){var e=void 0,t=this.state.pos;do{e=this.input.charCodeAt(++this.state.pos)}while(s(e)||45===e);return this.finishToken(R.jsxName,this.input.slice(t,this.state.pos))},ge.jsxParseIdentifier=function(){var e=this.startNode();return this.match(R.jsxName)?e.name=this.state.value:this.state.type.keyword?e.name=this.state.type.keyword:this.unexpected(),this.next(),this.finishNode(e,"JSXIdentifier")},ge.jsxParseNamespacedName=function(){var e=this.state.start,t=this.state.startLoc,r=this.jsxParseIdentifier();if(!this.eat(R.colon))return r;var n=this.startNodeAt(e,t);return n.namespace=r,n.name=this.jsxParseIdentifier(),this.finishNode(n,"JSXNamespacedName")},ge.jsxParseElementName=function(){for(var e=this.state.start,t=this.state.startLoc,r=this.jsxParseNamespacedName();this.eat(R.dot);){var n=this.startNodeAt(e,t);n.object=r,n.property=this.jsxParseIdentifier(),r=this.finishNode(n,"JSXMemberExpression")}return r},ge.jsxParseAttributeValue=function(){var e=void 0;switch(this.state.type){case R.braceL:if(e=this.jsxParseExpressionContainer(),"JSXEmptyExpression"!==e.expression.type)return e;this.raise(e.start,"JSX attributes must only be assigned a non-empty expression");case R.jsxTagStart:case R.string:return e=this.parseExprAtom(),e.extra=null,e;default:this.raise(this.state.start,"JSX value should be either an expression or a quoted JSX text")}},ge.jsxParseEmptyExpression=function(){var e=this.startNodeAt(this.state.lastTokEnd,this.state.lastTokEndLoc);return this.finishNodeAt(e,"JSXEmptyExpression",this.state.start,this.state.startLoc)},ge.jsxParseSpreadChild=function(){var e=this.startNode();return this.expect(R.braceL),this.expect(R.ellipsis),e.expression=this.parseExpression(),this.expect(R.braceR),this.finishNode(e,"JSXSpreadChild")},ge.jsxParseExpressionContainer=function(){var e=this.startNode();return this.next(),this.match(R.braceR)?e.expression=this.jsxParseEmptyExpression():e.expression=this.parseExpression(),this.expect(R.braceR),this.finishNode(e,"JSXExpressionContainer")},ge.jsxParseAttribute=function(){var e=this.startNode();return this.eat(R.braceL)?(this.expect(R.ellipsis),e.argument=this.parseMaybeAssign(),this.expect(R.braceR),this.finishNode(e,"JSXSpreadAttribute")):(e.name=this.jsxParseNamespacedName(),e.value=this.eat(R.eq)?this.jsxParseAttributeValue():null,this.finishNode(e,"JSXAttribute"))},ge.jsxParseOpeningElementAt=function(e,t){var r=this.startNodeAt(e,t);for(r.attributes=[],r.name=this.jsxParseElementName();!this.match(R.slash)&&!this.match(R.jsxTagEnd);)r.attributes.push(this.jsxParseAttribute());return r.selfClosing=this.eat(R.slash),this.expect(R.jsxTagEnd),this.finishNode(r,"JSXOpeningElement")},ge.jsxParseClosingElementAt=function(e,t){var r=this.startNodeAt(e,t);return r.name=this.jsxParseElementName(),this.expect(R.jsxTagEnd),this.finishNode(r,"JSXClosingElement")},ge.jsxParseElementAt=function(e,t){var r=this.startNodeAt(e,t),n=[],i=this.jsxParseOpeningElementAt(e,t),s=null;if(!i.selfClosing){e:for(;;)switch(this.state.type){case R.jsxTagStart:if(e=this.state.start,t=this.state.startLoc,this.next(),this.eat(R.slash)){s=this.jsxParseClosingElementAt(e,t);break e}n.push(this.jsxParseElementAt(e,t));break;case R.jsxText:n.push(this.parseExprAtom());break;case R.braceL:this.lookahead().type===R.ellipsis?n.push(this.jsxParseSpreadChild()):n.push(this.jsxParseExpressionContainer());break;default:this.unexpected()}d(s.name)!==d(i.name)&&this.raise(s.start,"Expected corresponding JSX closing tag for <"+d(i.name)+">")}return r.openingElement=i,r.closingElement=s,r.children=n,this.match(R.relational)&&"<"===this.state.value&&this.raise(this.state.start,"Adjacent JSX elements must be wrapped in an enclosing tag"),this.finishNode(r,"JSXElement")},ge.jsxParseElement=function(){var e=this.state.start,t=this.state.startLoc;return this.next(),this.jsxParseElementAt(e,t)};var be=function(e){e.extend("parseExprAtom",function(e){return function(t){if(this.match(R.jsxText)){var r=this.parseLiteral(this.state.value,"JSXText");return r.extra=null,r}return this.match(R.jsxTagStart)?this.jsxParseElement():e.call(this,t)}}),e.extend("readToken",function(e){return function(t){if(this.state.inPropertyName)return e.call(this,t);var r=this.curContext();if(r===U.j_expr)return this.jsxReadToken();if(r===U.j_oTag||r===U.j_cTag){if(i(t))return this.jsxReadWord();if(62===t)return++this.state.pos,this.finishToken(R.jsxTagEnd);if((34===t||39===t)&&r===U.j_oTag)return this.jsxReadString(t)}return 60===t&&this.state.exprAllowed?(++this.state.pos,this.finishToken(R.jsxTagStart)):e.call(this,t)}}),e.extend("updateContext",function(e){return function(t){if(this.match(R.braceL)){var r=this.curContext();r===U.j_oTag?this.state.context.push(U.braceExpression):r===U.j_expr?this.state.context.push(U.templateQuasi):e.call(this,t),this.state.exprAllowed=!0}else{if(!this.match(R.slash)||t!==R.jsxTagStart)return e.call(this,t);this.state.context.length-=2,this.state.context.push(U.j_cTag),this.state.exprAllowed=!1}}})};K.estree=oe,K.flow=ce,K.jsx=be,t.parse=h,t.parseExpression=m,t.tokTypes=R},function(e,t,r){"use strict";var n=r(21),i=r(431),s=r(141),a=r(150)("IE_PROTO"),o=function(){},u=function(){var e,t=r(230)("iframe"),n=s.length;for(t.style.display="none",r(426).appendChild(t),t.src="javascript:",e=t.contentWindow.document,e.open(),e.write("<script>document.F=Object<\/script>"),e.close(),u=e.F;n--;)delete u.prototype[s[n]];return u()};e.exports=Object.create||function(e,t){var r;return null!==e?(o.prototype=n(e),r=new o,o.prototype=null,r[a]=e):r=u(),void 0===t?r:i(r,t)}},function(e,t){"use strict";t.f={}.propertyIsEnumerable},function(e,t){"use strict";e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,r){"use strict";var n=r(23).f,i=r(28),s=r(13)("toStringTag");e.exports=function(e,t,r){e&&!i(e=r?e:e.prototype,s)&&n(e,s,{configurable:!0,value:t})}},function(e,t,r){"use strict";var n=r(140);e.exports=function(e){return Object(n(e))}},function(e,t){"use strict";var r=0,n=Math.random();e.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++r+n).toString(36))}},function(e,t){"use strict"},function(e,t,r){"use strict";!function(){t.ast=r(461),t.code=r(240),t.keyword=r(462)}()},function(e,t,r){"use strict";function n(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}var i=r(546),s=r(547),a=r(548),o=r(549),u=r(550);n.prototype.clear=i,n.prototype.delete=s,n.prototype.get=a,n.prototype.has=o,n.prototype.set=u,e.exports=n},function(e,t,r){"use strict";function n(e){var t=this.__data__=new i(e);this.size=t.size}var i=r(98),s=r(565),a=r(566),o=r(567),u=r(568),l=r(569);n.prototype.clear=s,n.prototype.delete=a,n.prototype.get=o,n.prototype.has=u,n.prototype.set=l,e.exports=n},function(e,t,r){"use strict";function n(e,t){for(var r=e.length;r--;)if(i(e[r][0],t))return r;return-1}var i=r(46);e.exports=n},function(e,t,r){"use strict";function n(e,t){return a(s(e,t,i),e+"")}var i=r(110),s=r(560),a=r(563);e.exports=n},function(e,t){"use strict";function r(e){return function(t){return e(t)}}e.exports=r},function(e,t,r){"use strict";function n(e){return i(function(t,r){var n=-1,i=r.length,a=i>1?r[i-1]:void 0,o=i>2?r[2]:void 0;for(a=e.length>3&&"function"==typeof a?(i--,a):void 0,o&&s(r[0],r[1],o)&&(a=i<3?void 0:a,i=1),t=Object(t);++n<i;){var u=r[n];u&&e(t,u,n,a)}return t})}var i=r(101),s=r(172);e.exports=n},function(e,t,r){"use strict";function n(e,t){var r=e.__data__;return i(t)?r["string"==typeof t?"string":"hash"]:r.map}var i=r(544);e.exports=n},function(e,t){"use strict";function r(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||n)}var n=Object.prototype;e.exports=r},function(e,t,r){"use strict";var n=r(38),i=n(Object,"create");e.exports=i},function(e,t){"use strict";function r(e){var t=-1,r=Array(e.size);return e.forEach(function(e){r[++t]=e}),r}e.exports=r},function(e,t,r){"use strict";function n(e){if("string"==typeof e||i(e))return e;var t=e+"";return"0"==t&&1/e==-s?"-0":t}var i=r(62),s=1/0;e.exports=n},function(e,t,r){"use strict";function n(e){return i(e,s)}var i=r(164),s=4;e.exports=n},function(e,t){"use strict";function r(e){return e}e.exports=r},function(e,t,r){"use strict";function n(e,t,r,n){e=s(e)?e:u(e),r=r&&!n?o(r):0;var c=e.length;return r<0&&(r=l(c+r,0)),a(e)?r<=c&&e.indexOf(t,r)>-1:!!c&&i(e,t,r)>-1}var i=r(166),s=r(24),a=r(587),o=r(48),u=r(280),l=Math.max;e.exports=n},function(e,t,r){"use strict";var n=r(493),i=r(25),s=Object.prototype,a=s.hasOwnProperty,o=s.propertyIsEnumerable,u=n(function(){return arguments}())?n:function(e){return i(e)&&a.call(e,"callee")&&!o.call(e,"callee")};e.exports=u},function(e,t,r){(function(e){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=r(17),s=r(596),a="object"==n(t)&&t&&!t.nodeType&&t,o=a&&"object"==n(e)&&e&&!e.nodeType&&e,u=o&&o.exports===a,l=u?i.Buffer:void 0,c=l?l.isBuffer:void 0,f=c||s;e.exports=f}).call(t,r(39)(e))},function(e,t,r){"use strict";function n(e){return null==e?"":i(e)}var i=r(253);e.exports=n},96,function(e,t,r){"use strict";function n(e){return o.memberExpression(o.identifier("regeneratorRuntime"),o.identifier(e),!1)}function i(e){return e.isReferenced()||e.parentPath.isAssignmentExpression({left:e.node})}function s(e,t){t?e.replaceWith(t):e.remove()}t.__esModule=!0,t.runtimeProperty=n,t.isReference=i,t.replaceWithOrRemove=s;var a=r(1),o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(a)},function(e,t,r){(function(e,n){"use strict";function i(e,r){var n={seen:[],stylize:a};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),m(r)?n.showHidden=r:r&&t._extend(n,r),x(n.showHidden)&&(n.showHidden=!1),x(n.depth)&&(n.depth=2),x(n.colors)&&(n.colors=!1),x(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=s),u(n,e,n.depth)}function s(e,t){var r=i.styles[t];return r?"["+i.colors[r][0]+"m"+e+"["+i.colors[r][1]+"m":e}function a(e,t){return e}function o(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}function u(e,r,n){if(e.customInspect&&r&&C(r.inspect)&&r.inspect!==t.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,e);return b(i)||(i=u(e,i,n)),i}var s=l(e,r);if(s)return s;var a=Object.keys(r),m=o(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(r)),D(r)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return c(r);if(0===a.length){if(C(r)){var y=r.name?": "+r.name:"";return e.stylize("[Function"+y+"]","special")}if(A(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(_(r))return e.stylize(Date.prototype.toString.call(r),"date");if(D(r))return c(r)}var v="",g=!1,E=["{","}"];if(h(r)&&(g=!0,E=["[","]"]),C(r)){v=" [Function"+(r.name?": "+r.name:"")+"]"}if(A(r)&&(v=" "+RegExp.prototype.toString.call(r)),_(r)&&(v=" "+Date.prototype.toUTCString.call(r)),D(r)&&(v=" "+c(r)),0===a.length&&(!g||0==r.length))return E[0]+v+E[1];if(n<0)return A(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special");e.seen.push(r);var x;return x=g?f(e,r,n,m,a):a.map(function(t){return p(e,r,n,m,t,g)}),e.seen.pop(),d(x,v,E)}function l(e,t){if(x(t))return e.stylize("undefined","undefined");if(b(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}return g(t)?e.stylize(""+t,"number"):m(t)?e.stylize(""+t,"boolean"):y(t)?e.stylize("null","null"):void 0}function c(e){return"["+Error.prototype.toString.call(e)+"]"}function f(e,t,r,n,i){for(var s=[],a=0,o=t.length;a<o;++a)T(t,String(a))?s.push(p(e,t,r,n,String(a),!0)):s.push("");return i.forEach(function(i){i.match(/^\d+$/)||s.push(p(e,t,r,n,i,!0))}),s}function p(e,t,r,n,i,s){var a,o,l;if(l=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},l.get?o=l.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):l.set&&(o=e.stylize("[Setter]","special")),T(n,i)||(a="["+i+"]"),o||(e.seen.indexOf(l.value)<0?(o=y(r)?u(e,l.value,null):u(e,l.value,r-1),o.indexOf("\n")>-1&&(o=s?o.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+o.split("\n").map(function(e){return" "+e}).join("\n"))):o=e.stylize("[Circular]","special")),x(a)){if(s&&i.match(/^\d+$/))return o;a=JSON.stringify(""+i),a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+o}function d(e,t,r){var n=0;return e.reduce(function(e,t){return n++,t.indexOf("\n")>=0&&n++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}function h(e){return Array.isArray(e)}function m(e){return"boolean"==typeof e}function y(e){return null===e}function v(e){return null==e}function g(e){return"number"==typeof e}function b(e){return"string"==typeof e}function E(e){return"symbol"===(void 0===e?"undefined":O(e))}function x(e){return void 0===e}function A(e){return S(e)&&"[object RegExp]"===P(e)}function S(e){return"object"===(void 0===e?"undefined":O(e))&&null!==e}function _(e){return S(e)&&"[object Date]"===P(e)}function D(e){return S(e)&&("[object Error]"===P(e)||e instanceof Error)}function C(e){return"function"==typeof e}function w(e){ +return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"===(void 0===e?"undefined":O(e))||void 0===e}function P(e){return Object.prototype.toString.call(e)}function k(e){return e<10?"0"+e.toString(10):e.toString(10)}function F(){var e=new Date,t=[k(e.getHours()),k(e.getMinutes()),k(e.getSeconds())].join(":");return[e.getDate(),M[e.getMonth()],t].join(" ")}function T(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},B=/%[sdj%]/g;t.format=function(e){if(!b(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(i(arguments[r]));return t.join(" ")}for(var r=1,n=arguments,s=n.length,a=String(e).replace(B,function(e){if("%%"===e)return"%";if(r>=s)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),o=n[r];r<s;o=n[++r])y(o)||!S(o)?a+=" "+o:a+=" "+i(o);return a},t.deprecate=function(r,i){function s(){if(!a){if(n.throwDeprecation)throw new Error(i);n.traceDeprecation?console.trace(i):console.error(i),a=!0}return r.apply(this,arguments)}if(x(e.process))return function(){return t.deprecate(r,i).apply(this,arguments)};if(!0===n.noDeprecation)return r;var a=!1;return s};var R,I={};t.debuglog=function(e){if(x(R)&&(R=n.env.NODE_DEBUG||""),e=e.toUpperCase(),!I[e])if(new RegExp("\\b"+e+"\\b","i").test(R)){var r=n.pid;I[e]=function(){var n=t.format.apply(t,arguments);console.error("%s %d: %s",e,r,n)}}else I[e]=function(){};return I[e]},t.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=h,t.isBoolean=m,t.isNull=y,t.isNullOrUndefined=v,t.isNumber=g,t.isString=b,t.isSymbol=E,t.isUndefined=x,t.isRegExp=A,t.isObject=S,t.isDate=_,t.isError=D,t.isFunction=C,t.isPrimitive=w,t.isBuffer=r(627);var M=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];t.log=function(){console.log("%s - %s",F(),t.format.apply(t,arguments))},t.inherits=r(626),t._extend=function(e,t){if(!t||!S(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}}).call(t,function(){return this}(),r(8))},function(e,t,r){(function(n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var s=r(11),a=i(s);t.default=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.cwd();if("object"===(void 0===u.default?"undefined":(0,a.default)(u.default)))return null;var r=f[t];if(!r){r=new u.default;var i=c.default.join(t,".babelrc");r.id=i,r.filename=i,r.paths=u.default._nodeModulePaths(t),f[t]=r}try{return u.default._resolveFilename(e,r)}catch(e){return null}};var o=r(115),u=i(o),l=r(19),c=i(l),f={};e.exports=t.default}).call(t,r(8))},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(133),s=n(i),a=r(3),o=n(a),u=r(42),l=n(u),c=r(41),f=n(c),p=function(e){function t(){(0,o.default)(this,t);var r=(0,l.default)(this,e.call(this));return r.dynamicData={},r}return(0,f.default)(t,e),t.prototype.setDynamic=function(e,t){this.dynamicData[e]=t},t.prototype.get=function(t){if(this.has(t))return e.prototype.get.call(this,t);if(Object.prototype.hasOwnProperty.call(this.dynamicData,t)){var r=this.dynamicData[t]();return this.set(t,r),r}},t}(s.default);t.default=p,e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(3),s=n(i),a=r(239),o=n(a),u=(0,o.default)("babel:verbose"),l=(0,o.default)("babel"),c=[],f=function(){function e(t,r){(0,s.default)(this,e),this.filename=r,this.file=t}return e.prototype._buildMessage=function(e){var t="[BABEL] "+this.filename;return e&&(t+=": "+e),t},e.prototype.warn=function(e){console.warn(this._buildMessage(e))},e.prototype.error=function(e){throw new(arguments.length>1&&void 0!==arguments[1]?arguments[1]:Error)(this._buildMessage(e))},e.prototype.deprecate=function(e){this.file.opts&&this.file.opts.suppressDeprecationMessages||(e=this._buildMessage(e),c.indexOf(e)>=0||(c.push(e),console.error(e)))},e.prototype.verbose=function(e){u.enabled&&u(this._buildMessage(e))},e.prototype.debug=function(e){l.enabled&&l(this._buildMessage(e))},e.prototype.deopt=function(e,t){this.debug(t)},e}();t.default=f,e.exports=t.default},function(e,t,r){"use strict";function n(e,t){var r=e.node,n=r.source?r.source.value:null,i=t.metadata.modules.exports,s=e.get("declaration");if(s.isStatement()){var o=s.getBindingIdentifiers();for(var l in o)i.exported.push(l),i.specifiers.push({kind:"local",local:l,exported:e.isExportDefaultDeclaration()?"default":l})}if(e.isExportNamedDeclaration()&&r.specifiers)for(var c=r.specifiers,f=Array.isArray(c),p=0,c=f?c:(0,a.default)(c);;){var d;if(f){if(p>=c.length)break;d=c[p++]}else{if(p=c.next(),p.done)break;d=p.value}var h=d,m=h.exported.name;i.exported.push(m),u.isExportDefaultSpecifier(h)&&i.specifiers.push({kind:"external",local:m,exported:m,source:n}),u.isExportNamespaceSpecifier(h)&&i.specifiers.push({kind:"external-namespace",exported:m,source:n});var y=h.local;y&&(n&&i.specifiers.push({kind:"external",local:y.name,exported:m,source:n}),n||i.specifiers.push({kind:"local",local:y.name,exported:m}))}e.isExportAllDeclaration()&&i.specifiers.push({kind:"external-all",source:n})}function i(e){e.skip()}t.__esModule=!0,t.ImportDeclaration=t.ModuleDeclaration=void 0;var s=r(2),a=function(e){return e&&e.__esModule?e:{default:e}}(s);t.ExportDeclaration=n,t.Scope=i;var o=r(1),u=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(o);t.ModuleDeclaration={enter:function(e,t){var r=e.node;r.source&&(r.source.value=t.resolveModuleSource(r.source.value))}},t.ImportDeclaration={exit:function(e,t){var r=e.node,n=[],i=[];t.metadata.modules.imports.push({source:r.source.value,imported:i,specifiers:n});for(var s=e.get("specifiers"),o=Array.isArray(s),u=0,s=o?s:(0,a.default)(s);;){var l;if(o){if(u>=s.length)break;l=s[u++]}else{if(u=s.next(),u.done)break;l=u.value}var c=l,f=c.node.local.name;if(c.isImportDefaultSpecifier()&&(i.push("default"),n.push({kind:"named",imported:"default",local:f})),c.isImportSpecifier()){var p=c.node.imported.name;i.push(p),n.push({kind:"named",imported:p,local:f})}c.isImportNamespaceSpecifier()&&(i.push("*"),n.push({kind:"namespace",local:f}))}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){var r=t||i.EXTENSIONS,n=D.default.extname(e);return(0,x.default)(r,n)}function s(e){return e?Array.isArray(e)?e:"string"==typeof e?e.split(","):[e]:[]}function a(e){if(!e)return new RegExp(/.^/);if(Array.isArray(e)&&(e=new RegExp(e.map(m.default).join("|"),"i")),"string"==typeof e){e=(0,w.default)(e),((0,v.default)(e,"./")||(0,v.default)(e,"*/"))&&(e=e.slice(2)),(0,v.default)(e,"**/")&&(e=e.slice(3));var t=b.default.makeRe(e,{nocase:!0});return new RegExp(t.source.slice(1,-1),"i")}if((0,S.default)(e))return e;throw new TypeError("illegal type for regexify")}function o(e,t){return e?"boolean"==typeof e?o([e],t):"string"==typeof e?o(s(e),t):Array.isArray(e)?(t&&(e=e.map(t)),e):[e]:[]}function u(e){return"true"===e||1==e||!("false"===e||0==e||!e)&&e}function l(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments[2];if(e=e.replace(/\\/g,"/"),r){for(var n=r,i=Array.isArray(n),s=0,n=i?n:(0,p.default)(n);;){var a;if(i){if(s>=n.length)break;a=n[s++]}else{if(s=n.next(),s.done)break;a=s.value}if(c(a,e))return!1}return!0}if(t.length)for(var o=t,u=Array.isArray(o),l=0,o=u?o:(0,p.default)(o);;){var f;if(u){if(l>=o.length)break;f=o[l++]}else{if(l=o.next(),l.done)break;f=l.value}var d=f;if(c(d,e))return!0}return!1}function c(e,t){return"function"==typeof e?e(t):e.test(t)}t.__esModule=!0,t.inspect=t.inherits=void 0;var f=r(2),p=n(f),d=r(117);Object.defineProperty(t,"inherits",{enumerable:!0,get:function(){return d.inherits}}),Object.defineProperty(t,"inspect",{enumerable:!0,get:function(){return d.inspect}}),t.canCompile=i,t.list=s,t.regexify=a,t.arrayify=o,t.booleanify=u,t.shouldIgnore=l;var h=r(577),m=n(h),y=r(595),v=n(y),g=r(601),b=n(g),E=r(111),x=n(E),A=r(276),S=n(A),_=r(19),D=n(_),C=r(284),w=n(C);i.EXTENSIONS=[".js",".jsx",".es6",".es"]},function(e,t,r){"use strict";function n(e){e.variance&&("plus"===e.variance?this.token("+"):"minus"===e.variance&&this.token("-")),this.word(e.name)}function i(e){this.token("..."),this.print(e.argument,e)}function s(e){var t=e.properties;this.token("{"),this.printInnerComments(e),t.length&&(this.space(),this.printList(t,e,{indent:!0,statement:!0}),this.space()),this.token("}")}function a(e){this.printJoin(e.decorators,e),this._method(e)}function o(e){if(this.printJoin(e.decorators,e),e.computed)this.token("["),this.print(e.key,e),this.token("]");else{if(m.isAssignmentPattern(e.value)&&m.isIdentifier(e.key)&&e.key.name===e.value.left.name)return void this.print(e.value,e);if(this.print(e.key,e),e.shorthand&&m.isIdentifier(e.key)&&m.isIdentifier(e.value)&&e.key.name===e.value.name)return}this.token(":"),this.space(),this.print(e.value,e)}function u(e){var t=e.elements,r=t.length;this.token("["),this.printInnerComments(e);for(var n=0;n<t.length;n++){var i=t[n];i?(n>0&&this.space(),this.print(i,e),n<r-1&&this.token(",")):this.token(",")}this.token("]")}function l(e){this.word("/"+e.pattern+"/"+e.flags)}function c(e){this.word(e.value?"true":"false")}function f(){this.word("null")}function p(e){var t=this.getPossibleRaw(e),r=e.value+"";null==t?this.number(r):this.format.minified?this.number(t.length<r.length?t:r):this.number(t)}function d(e,t){var r=this.getPossibleRaw(e);if(!this.format.minified&&null!=r)return void this.token(r);var n={quotes:m.isJSX(t)?"double":this.format.quotes,wrap:!0};this.format.jsonCompatibleStrings&&(n.json=!0);var i=(0,v.default)(e.value,n);return this.token(i)}t.__esModule=!0,t.ArrayPattern=t.ObjectPattern=t.RestProperty=t.SpreadProperty=t.SpreadElement=void 0,t.Identifier=n,t.RestElement=i,t.ObjectExpression=s,t.ObjectMethod=a,t.ObjectProperty=o,t.ArrayExpression=u,t.RegExpLiteral=l,t.BooleanLiteral=c,t.NullLiteral=f,t.NumericLiteral=p,t.StringLiteral=d;var h=r(1),m=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(h),y=r(469),v=function(e){return e&&e.__esModule?e:{default:e}}(y);t.SpreadElement=i,t.SpreadProperty=i,t.RestProperty=i,t.ObjectPattern=s,t.ArrayPattern=u},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){var r=e.node,n=r.body;r.async=!1;var i=f.functionExpression(null,[],f.blockStatement(n.body),!0);i.shadow=!0,n.body=[f.returnStatement(f.callExpression(f.callExpression(t,[i]),[]))],r.generator=!1}function s(e,t){var r=e.node,n=e.isFunctionDeclaration(),i=r.id,s=h;e.isArrowFunctionExpression()?e.arrowFunctionToShadowed():!n&&i&&(s=m),r.async=!1,r.generator=!0,r.id=null,n&&(r.type="FunctionExpression");var a=f.callExpression(t,[r]),u=s({NAME:i,REF:e.scope.generateUidIdentifier("ref"),FUNCTION:a,PARAMS:r.params.reduce(function(t,r){return t.done=t.done||f.isAssignmentPattern(r)||f.isRestElement(r),t.done||t.params.push(e.scope.generateUidIdentifier("x")),t},{params:[],done:!1}).params}).expression;if(n){var l=f.variableDeclaration("let",[f.variableDeclarator(f.identifier(i.name),f.callExpression(u,[]))]);l._blockHoist=!0,e.replaceWith(l)}else{var c=u.body.body[1].argument;i||(0,o.default)({node:c,parent:e.parent,scope:e.scope}),!c||c.id||r.params.length?e.replaceWith(f.callExpression(u,[])):e.replaceWith(a)}}t.__esModule=!0,t.default=function(e,t,r){r||(r={wrapAsync:t},t=null),e.traverse(y,{file:t,wrapAwait:r.wrapAwait}),e.isClassMethod()||e.isObjectMethod()?i(e,r.wrapAsync):s(e,r.wrapAsync)};var a=r(40),o=n(a),u=r(4),l=n(u),c=r(1),f=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(c),p=r(320),d=n(p),h=(0,l.default)("\n (() => {\n var REF = FUNCTION;\n return function NAME(PARAMS) {\n return REF.apply(this, arguments);\n };\n })\n"),m=(0,l.default)("\n (() => {\n var REF = FUNCTION;\n function NAME(PARAMS) {\n return REF.apply(this, arguments);\n }\n return NAME;\n })\n"),y={Function:function(e){if(e.isArrowFunctionExpression()&&!e.node.async)return void e.arrowFunctionToShadowed();e.skip()},AwaitExpression:function(e,t){var r=e.node,n=t.wrapAwait;r.type="YieldExpression",n&&(r.argument=f.callExpression(n,[r.argument]))},ForAwaitStatement:function(e,t){var r=t.file,n=t.wrapAwait,i=e.node,s=(0,d.default)(e,{getAsyncIterator:r.addHelper("asyncIterator"),wrapAwait:n}),a=s.declar,o=s.loop,u=o.body;e.ensureBlock(),a&&u.body.push(a),u.body=u.body.concat(i.body.body),f.inherits(o,i),f.inherits(o.body,i.body),s.replaceParent?(e.parentPath.replaceWithMultiple(s.node),e.remove()):e.replaceWithMultiple(s.node)}};e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(){return{manipulateOptions:function(e,t){t.plugins.push("decorators")}}},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(){return{manipulateOptions:function(e,t){t.plugins.push("flow")}}},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(){return{manipulateOptions:function(e,t){t.plugins.push("jsx")}}},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(){return{manipulateOptions:function(e,t){t.plugins.push("trailingFunctionCommas")}}},e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(){return{inherits:r(67),visitor:{Function:function(e,t){e.node.async&&!e.node.generator&&(0,i.default)(e,t.file,{wrapAsync:t.addHelper("asyncToGenerator")})}}}};var n=r(124),i=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){return c.isIdentifier(e)?e.name:e.value.toString()}t.__esModule=!0;var s=r(2),a=n(s),o=r(9),u=n(o);t.default=function(){return{visitor:{ObjectExpression:function(e){for(var t=e.node,r=t.properties.filter(function(e){return!c.isSpreadProperty(e)&&!e.computed}),n=(0,u.default)(null),s=(0,u.default)(null),o=(0,u.default)(null),l=r,f=Array.isArray(l),p=0,l=f?l:(0,a.default)(l);;){var d;if(f){if(p>=l.length)break;d=l[p++]}else{if(p=l.next(),p.done)break;d=p.value}var h=d,m=i(h.key),y=!1;switch(h.kind){case"get":(n[m]||s[m])&&(y=!0),s[m]=!0;break;case"set":(n[m]||o[m])&&(y=!0),o[m]=!0;break;default:(n[m]||s[m]||o[m])&&(y=!0),n[m]=!0}y&&(h.computed=!0,h.key=c.stringLiteral(m))}}}}};var l=r(1),c=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(l);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(9),s=n(i);t.default=function(e){function t(e){if(!e.isCallExpression())return!1;if(!e.get("callee").isIdentifier({name:"require"}))return!1;if(e.scope.getBinding("require"))return!1;var t=e.get("arguments");return 1===t.length&&!!t[0].isStringLiteral()}var n=e.types,i={ReferencedIdentifier:function(e){var t=e.node,r=e.scope;"exports"!==t.name||r.getBinding("exports")||(this.hasExports=!0),"module"!==t.name||r.getBinding("module")||(this.hasModule=!0)},CallExpression:function(e){t(e)&&(this.bareSources.push(e.node.arguments[0]),e.remove())},VariableDeclarator:function(e){var r=e.get("id");if(r.isIdentifier()){var n=e.get("init");if(t(n)){var i=n.node.arguments[0];this.sourceNames[i.value]=!0,this.sources.push([r.node,i]),e.remove()}}}};return{inherits:r(77),pre:function(){this.sources=[],this.sourceNames=(0,s.default)(null),this.bareSources=[],this.hasExports=!1,this.hasModule=!1},visitor:{Program:{exit:function(e){var t=this;if(!this.ran){this.ran=!0,e.traverse(i,this);var r=this.sources.map(function(e){return e[0]}),s=this.sources.map(function(e){return e[1]});s=s.concat(this.bareSources.filter(function(e){return!t.sourceNames[e.value]}));var a=this.getModuleName();a&&(a=n.stringLiteral(a)),this.hasExports&&(s.unshift(n.stringLiteral("exports")),r.unshift(n.identifier("exports"))),this.hasModule&&(s.unshift(n.stringLiteral("module")),r.unshift(n.identifier("module")));var o=e.node,c=l({PARAMS:r,BODY:o.body});c.expression.body.directives=o.directives,o.directives=[],o.body=[u({MODULE_NAME:a,SOURCES:s,FACTORY:c})]}}}}}};var a=r(4),o=n(a),u=(0,o.default)("\n define(MODULE_NAME, [SOURCES], FACTORY);\n"),l=(0,o.default)("\n (function (PARAMS) {\n BODY;\n })\n");e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(e){var t=e.types;return{inherits:r(199),visitor:(0,i.default)({operator:"**",build:function(e,r){return t.callExpression(t.memberExpression(t.identifier("Math"),t.identifier("pow")),[e,r])}})}};var n=r(316),i=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=t.default},function(e,t,r){"use strict";e.exports={default:r(406),__esModule:!0}},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}function s(e,t,r){for(var n=I.scope.get(e.node)||[],i=n,s=Array.isArray(i),a=0,i=s?i:(0,y.default)(i);;){var o;if(s){if(a>=i.length)break;o=i[a++]}else{if(a=i.next(),a.done)break;o=a.value}var u=o;if(u.parent===t&&u.path===e)return u}n.push(r),I.scope.has(e.node)||I.scope.set(e.node,n)}function a(e,t){if(R.isModuleDeclaration(e))if(e.source)a(e.source,t);else if(e.specifiers&&e.specifiers.length)for(var r=e.specifiers,n=Array.isArray(r),i=0,r=n?r:(0,y.default)(r);;){var s;if(n){if(i>=r.length)break;s=r[i++]}else{if(i=r.next(),i.done)break;s=i.value}var o=s;a(o,t)}else e.declaration&&a(e.declaration,t);else if(R.isModuleSpecifier(e))a(e.local,t);else if(R.isMemberExpression(e))a(e.object,t),a(e.property,t);else if(R.isIdentifier(e))t.push(e.name);else if(R.isLiteral(e))t.push(e.value);else if(R.isCallExpression(e))a(e.callee,t);else if(R.isObjectExpression(e)||R.isObjectPattern(e))for(var u=e.properties,l=Array.isArray(u),c=0,u=l?u:(0,y.default)(u);;){var f;if(l){if(c>=u.length)break;f=u[c++]}else{if(c=u.next(),c.done)break;f=c.value}var p=f;a(p.key||p.argument,t)}}t.__esModule=!0;var o=r(14),u=i(o),l=r(9),c=i(l),f=r(133),p=i(f),d=r(3),h=i(d),m=r(2),y=i(m),v=r(111),g=i(v),b=r(278),E=i(b),x=r(383),A=i(x),S=r(7),_=i(S),D=r(273),C=i(D),w=r(20),P=n(w),k=r(225),F=i(k),T=r(463),O=i(T),B=r(1),R=n(B),I=r(88),M=0,N={For:function(e){for(var t=R.FOR_INIT_KEYS,r=Array.isArray(t),n=0,t=r?t:(0,y.default)(t);;){var i;if(r){if(n>=t.length)break;i=t[n++]}else{if(n=t.next(),n.done)break;i=n.value}var s=i,a=e.get(s);a.isVar()&&e.scope.getFunctionParent().registerBinding("var",a)}},Declaration:function(e){e.isBlockScoped()||e.isExportDeclaration()&&e.get("declaration").isDeclaration()||e.scope.getFunctionParent().registerDeclaration(e)},ReferencedIdentifier:function(e,t){t.references.push(e)},ForXStatement:function(e,t){var r=e.get("left");(r.isPattern()||r.isIdentifier())&&t.constantViolations.push(r)},ExportDeclaration:{exit:function(e){var t=e.node,r=e.scope,n=t.declaration;if(R.isClassDeclaration(n)||R.isFunctionDeclaration(n)){var i=n.id;if(!i)return;var s=r.getBinding(i.name);s&&s.reference(e)}else if(R.isVariableDeclaration(n))for(var a=n.declarations,o=Array.isArray(a),u=0,a=o?a:(0,y.default)(a);;){var l;if(o){if(u>=a.length)break;l=a[u++]}else{if(u=a.next(),u.done)break;l=u.value}var c=l,f=R.getBindingIdentifiers(c);for(var p in f){var d=r.getBinding(p);d&&d.reference(e)}}}},LabeledStatement:function(e){e.scope.getProgramParent().addGlobal(e.node),e.scope.getBlockParent().registerDeclaration(e)},AssignmentExpression:function(e,t){t.assignments.push(e)},UpdateExpression:function(e,t){t.constantViolations.push(e.get("argument"))},UnaryExpression:function(e,t){"delete"===e.node.operator&&t.constantViolations.push(e.get("argument"))},BlockScoped:function(e){var t=e.scope;t.path===e&&(t=t.parent),t.getBlockParent().registerDeclaration(e)},ClassDeclaration:function(e){var t=e.node.id;if(t){var r=t.name;e.scope.bindings[r]=e.scope.getBinding(r)}},Block:function(e){for(var t=e.get("body"),r=t,n=Array.isArray(r),i=0,r=n?r:(0,y.default)(r);;){var s;if(n){if(i>=r.length)break;s=r[i++]}else{if(i=r.next(),i.done)break;s=i.value}var a=s;a.isFunctionDeclaration()&&e.scope.getBlockParent().registerDeclaration(a)}}},L=0,j=function(){function e(t,r){if((0,h.default)(this,e),r&&r.block===t.node)return r;var n=s(t,r,this);if(n)return n;this.uid=L++,this.parent=r,this.hub=t.hub,this.parentBlock=t.parent,this.block=t.node,this.path=t,this.labels=new p.default}return e.prototype.traverse=function(e,t,r){(0,_.default)(e,t,this,r,this.path)},e.prototype.generateDeclaredUidIdentifier=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"temp",t=this.generateUidIdentifier(e);return this.push({id:t}),t},e.prototype.generateUidIdentifier=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"temp";return R.identifier(this.generateUid(e))},e.prototype.generateUid=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"temp";e=R.toIdentifier(e).replace(/^_+/,"").replace(/[0-9]+$/g,"");var t=void 0,r=0;do{t=this._generateUid(e,r),r++}while(this.hasLabel(t)||this.hasBinding(t)||this.hasGlobal(t)||this.hasReference(t));var n=this.getProgramParent();return n.references[t]=!0,n.uids[t]=!0,t},e.prototype._generateUid=function(e,t){var r=e;return t>1&&(r+=t),"_"+r},e.prototype.generateUidIdentifierBasedOnNode=function(e,t){var r=e;R.isAssignmentExpression(e)?r=e.left:R.isVariableDeclarator(e)?r=e.id:(R.isObjectProperty(r)||R.isObjectMethod(r))&&(r=r.key);var n=[];a(r,n);var i=n.join("$");return i=i.replace(/^_/,"")||t||"ref",this.generateUidIdentifier(i.slice(0,20))},e.prototype.isStatic=function(e){if(R.isThisExpression(e)||R.isSuper(e))return!0;if(R.isIdentifier(e)){var t=this.getBinding(e.name);return t?t.constant:this.hasBinding(e.name)}return!1},e.prototype.maybeGenerateMemoised=function(e,t){if(this.isStatic(e))return null;var r=this.generateUidIdentifierBasedOnNode(e);return t||this.push({id:r}),r},e.prototype.checkBlockScopedCollisions=function(e,t,r,n){if("param"!==t&&("hoisted"!==t||"let"!==e.kind)){if("let"===t||"let"===e.kind||"const"===e.kind||"module"===e.kind||"param"===e.kind&&("let"===t||"const"===t))throw this.hub.file.buildCodeFrameError(n,P.get("scopeDuplicateDeclaration",r),TypeError)}},e.prototype.rename=function(e,t,r){var n=this.getBinding(e);if(n)return t=t||this.generateUidIdentifier(e).name,new A.default(n,e,t).rename(r)},e.prototype._renameFromMap=function(e,t,r,n){e[t]&&(e[r]=n,e[t]=null)},e.prototype.dump=function(){var e=(0,E.default)("-",60);console.log(e);var t=this;do{console.log("#",t.block.type);for(var r in t.bindings){var n=t.bindings[r];console.log(" -",r,{constant:n.constant,references:n.references,violations:n.constantViolations.length,kind:n.kind})}}while(t=t.parent);console.log(e)},e.prototype.toArray=function(e,t){var r=this.hub.file;if(R.isIdentifier(e)){var n=this.getBinding(e.name);if(n&&n.constant&&n.path.isGenericType("Array"))return e}if(R.isArrayExpression(e))return e;if(R.isIdentifier(e,{name:"arguments"}))return R.callExpression(R.memberExpression(R.memberExpression(R.memberExpression(R.identifier("Array"),R.identifier("prototype")),R.identifier("slice")),R.identifier("call")),[e]);var i="toArray",s=[e];return!0===t?i="toConsumableArray":t&&(s.push(R.numericLiteral(t)),i="slicedToArray"),R.callExpression(r.addHelper(i),s)},e.prototype.hasLabel=function(e){return!!this.getLabel(e)},e.prototype.getLabel=function(e){return this.labels.get(e)},e.prototype.registerLabel=function(e){this.labels.set(e.node.label.name,e)},e.prototype.registerDeclaration=function(e){if(e.isLabeledStatement())this.registerLabel(e);else if(e.isFunctionDeclaration())this.registerBinding("hoisted",e.get("id"),e);else if(e.isVariableDeclaration())for(var t=e.get("declarations"),r=t,n=Array.isArray(r),i=0,r=n?r:(0,y.default)(r);;){var s;if(n){if(i>=r.length)break;s=r[i++]}else{if(i=r.next(),i.done)break;s=i.value}var a=s;this.registerBinding(e.node.kind,a)}else if(e.isClassDeclaration())this.registerBinding("let",e);else if(e.isImportDeclaration())for(var o=e.get("specifiers"),u=o,l=Array.isArray(u),c=0,u=l?u:(0,y.default)(u);;){var f;if(l){if(c>=u.length)break;f=u[c++]}else{if(c=u.next(),c.done)break;f=c.value}var p=f;this.registerBinding("module",p)}else if(e.isExportDeclaration()){var d=e.get("declaration");(d.isClassDeclaration()||d.isFunctionDeclaration()||d.isVariableDeclaration())&&this.registerDeclaration(d)}else this.registerBinding("unknown",e)},e.prototype.buildUndefinedNode=function(){return this.hasBinding("undefined")?R.unaryExpression("void",R.numericLiteral(0),!0):R.identifier("undefined")},e.prototype.registerConstantViolation=function(e){var t=e.getBindingIdentifiers();for(var r in t){var n=this.getBinding(r);n&&n.reassign(e)}},e.prototype.registerBinding=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t;if(!e)throw new ReferenceError("no `kind`");if(t.isVariableDeclaration())for(var n=t.get("declarations"),i=n,s=Array.isArray(i),a=0,i=s?i:(0,y.default)(i);;){var o;if(s){if(a>=i.length)break;o=i[a++]}else{if(a=i.next(),a.done)break;o=a.value}var u=o;this.registerBinding(e,u)}else{var l=this.getProgramParent(),c=t.getBindingIdentifiers(!0);for(var f in c)for(var p=c[f],d=Array.isArray(p),h=0,p=d?p:(0,y.default)(p);;){var m;if(d){if(h>=p.length)break;m=p[h++]}else{if(h=p.next(),h.done)break;m=h.value}var v=m,g=this.getOwnBinding(f);if(g){if(g.identifier===v)continue;this.checkBlockScopedCollisions(g,e,f,v)}g&&g.path.isFlow()&&(g=null),l.references[f]=!0,this.bindings[f]=new F.default({identifier:v,existing:g,scope:this,path:r,kind:e})}}},e.prototype.addGlobal=function(e){this.globals[e.name]=e},e.prototype.hasUid=function(e){var t=this;do{if(t.uids[e])return!0}while(t=t.parent);return!1},e.prototype.hasGlobal=function(e){var t=this;do{if(t.globals[e])return!0}while(t=t.parent);return!1},e.prototype.hasReference=function(e){var t=this;do{if(t.references[e])return!0}while(t=t.parent);return!1},e.prototype.isPure=function(e,t){if(R.isIdentifier(e)){var r=this.getBinding(e.name);return!!r&&(!t||r.constant)}if(R.isClass(e))return!(e.superClass&&!this.isPure(e.superClass,t))&&this.isPure(e.body,t);if(R.isClassBody(e)){for(var n=e.body,i=Array.isArray(n),s=0,n=i?n:(0,y.default)(n);;){var a;if(i){if(s>=n.length)break;a=n[s++]}else{if(s=n.next(),s.done)break;a=s.value}var o=a;if(!this.isPure(o,t))return!1}return!0}if(R.isBinary(e))return this.isPure(e.left,t)&&this.isPure(e.right,t);if(R.isArrayExpression(e)){for(var u=e.elements,l=Array.isArray(u),c=0,u=l?u:(0,y.default)(u);;){var f;if(l){if(c>=u.length)break;f=u[c++]}else{if(c=u.next(),c.done)break;f=c.value}var p=f;if(!this.isPure(p,t))return!1}return!0}if(R.isObjectExpression(e)){for(var d=e.properties,h=Array.isArray(d),m=0,d=h?d:(0,y.default)(d);;){var v;if(h){if(m>=d.length)break;v=d[m++]}else{if(m=d.next(),m.done)break;v=m.value}var g=v;if(!this.isPure(g,t))return!1}return!0}return R.isClassMethod(e)?!(e.computed&&!this.isPure(e.key,t))&&("get"!==e.kind&&"set"!==e.kind):R.isClassProperty(e)||R.isObjectProperty(e)?!(e.computed&&!this.isPure(e.key,t))&&this.isPure(e.value,t):R.isUnaryExpression(e)?this.isPure(e.argument,t):R.isPureish(e)},e.prototype.setData=function(e,t){return this.data[e]=t},e.prototype.getData=function(e){var t=this;do{var r=t.data[e];if(null!=r)return r}while(t=t.parent)},e.prototype.removeData=function(e){var t=this;do{null!=t.data[e]&&(t.data[e]=null)}while(t=t.parent)},e.prototype.init=function(){this.references||this.crawl()},e.prototype.crawl=function(){M++,this._crawl(),M--},e.prototype._crawl=function(){var e=this.path;if(this.references=(0,c.default)(null),this.bindings=(0,c.default)(null),this.globals=(0,c.default)(null),this.uids=(0,c.default)(null),this.data=(0,c.default)(null),e.isLoop())for(var t=R.FOR_INIT_KEYS,r=Array.isArray(t),n=0,t=r?t:(0,y.default)(t);;){var i;if(r){if(n>=t.length)break;i=t[n++]}else{if(n=t.next(),n.done)break;i=n.value}var s=i,a=e.get(s);a.isBlockScoped()&&this.registerBinding(a.node.kind,a)}if(e.isFunctionExpression()&&e.has("id")&&(e.get("id").node[R.NOT_LOCAL_BINDING]||this.registerBinding("local",e.get("id"),e)),e.isClassExpression()&&e.has("id")&&(e.get("id").node[R.NOT_LOCAL_BINDING]||this.registerBinding("local",e)),e.isFunction())for(var o=e.get("params"),u=o,l=Array.isArray(u),f=0,u=l?u:(0,y.default)(u);;){var p;if(l){if(f>=u.length)break;p=u[f++]}else{if(f=u.next(),f.done)break;p=f.value}var d=p;this.registerBinding("param",d)}if(e.isCatchClause()&&this.registerBinding("let",e),!this.getProgramParent().crawling){var h={references:[],constantViolations:[],assignments:[]};this.crawling=!0,e.traverse(N,h),this.crawling=!1;for(var m=h.assignments,v=Array.isArray(m),g=0,m=v?m:(0,y.default)(m);;){var b;if(v){if(g>=m.length)break;b=m[g++]}else{if(g=m.next(),g.done)break;b=g.value}var E=b,x=E.getBindingIdentifiers(),A=void 0;for(var S in x)E.scope.getBinding(S)||(A=A||E.scope.getProgramParent(),A.addGlobal(x[S]));E.scope.registerConstantViolation(E)}for(var _=h.references,D=Array.isArray(_),C=0,_=D?_:(0,y.default)(_);;){var w;if(D){if(C>=_.length)break;w=_[C++]}else{if(C=_.next(),C.done)break;w=C.value}var P=w,k=P.scope.getBinding(P.node.name);k?k.reference(P):P.scope.getProgramParent().addGlobal(P.node)}for(var F=h.constantViolations,T=Array.isArray(F),O=0,F=T?F:(0,y.default)(F);;){var B;if(T){if(O>=F.length)break;B=F[O++]}else{if(O=F.next(),O.done)break;B=O.value}var I=B;I.scope.registerConstantViolation(I)}}},e.prototype.push=function(e){var t=this.path;t.isBlockStatement()||t.isProgram()||(t=this.getBlockParent().path),t.isSwitchStatement()&&(t=this.getFunctionParent().path),(t.isLoop()||t.isCatchClause()||t.isFunction())&&(R.ensureBlock(t.node),t=t.get("body"));var r=e.unique,n=e.kind||"var",i=null==e._blockHoist?2:e._blockHoist,s="declaration:"+n+":"+i,a=!r&&t.getData(s);if(!a){var o=R.variableDeclaration(n,[]);o._generated=!0,o._blockHoist=i;a=t.unshiftContainer("body",[o])[0],r||t.setData(s,a)}var u=R.variableDeclarator(e.id,e.init);a.node.declarations.push(u),this.registerBinding(n,a.get("declarations").pop())},e.prototype.getProgramParent=function(){var e=this;do{if(e.path.isProgram())return e}while(e=e.parent);throw new Error("We couldn't find a Function or Program...")},e.prototype.getFunctionParent=function(){var e=this;do{if(e.path.isFunctionParent())return e}while(e=e.parent);throw new Error("We couldn't find a Function or Program...")},e.prototype.getBlockParent=function(){var e=this;do{if(e.path.isBlockParent())return e}while(e=e.parent);throw new Error("We couldn't find a BlockStatement, For, Switch, Function, Loop or Program...")},e.prototype.getAllBindings=function(){var e=(0,c.default)(null),t=this;do{(0,C.default)(e,t.bindings),t=t.parent}while(t);return e},e.prototype.getAllBindingsOfKind=function(){for(var e=(0,c.default)(null),t=arguments,r=Array.isArray(t),n=0,t=r?t:(0,y.default)(t);;){var i;if(r){if(n>=t.length)break;i=t[n++]}else{if(n=t.next(),n.done)break;i=n.value}var s=i,a=this;do{for(var o in a.bindings){var u=a.bindings[o];u.kind===s&&(e[o]=u)}a=a.parent}while(a)}return e},e.prototype.bindingIdentifierEquals=function(e,t){ +return this.getBindingIdentifier(e)===t},e.prototype.warnOnFlowBinding=function(e){return 0===M&&e&&e.path.isFlow()&&console.warn("\n You or one of the Babel plugins you are using are using Flow declarations as bindings.\n Support for this will be removed in version 7. To find out the caller, grep for this\n message and change it to a `console.trace()`.\n "),e},e.prototype.getBinding=function(e){var t=this;do{var r=t.getOwnBinding(e);if(r)return this.warnOnFlowBinding(r)}while(t=t.parent)},e.prototype.getOwnBinding=function(e){return this.warnOnFlowBinding(this.bindings[e])},e.prototype.getBindingIdentifier=function(e){var t=this.getBinding(e);return t&&t.identifier},e.prototype.getOwnBindingIdentifier=function(e){var t=this.bindings[e];return t&&t.identifier},e.prototype.hasOwnBinding=function(e){return!!this.getOwnBinding(e)},e.prototype.hasBinding=function(t,r){return!!t&&(!!this.hasOwnBinding(t)||(!!this.parentHasBinding(t,r)||(!!this.hasUid(t)||(!(r||!(0,g.default)(e.globals,t))||!(r||!(0,g.default)(e.contextVariables,t))))))},e.prototype.parentHasBinding=function(e,t){return this.parent&&this.parent.hasBinding(e,t)},e.prototype.moveBindingTo=function(e,t){var r=this.getBinding(e);r&&(r.scope.removeOwnBinding(e),r.scope=t,t.bindings[e]=r)},e.prototype.removeOwnBinding=function(e){delete this.bindings[e]},e.prototype.removeBinding=function(e){var t=this.getBinding(e);t&&t.scope.removeOwnBinding(e);var r=this;do{r.uids[e]&&(r.uids[e]=!1)}while(r=r.parent)},e}();j.globals=(0,u.default)(O.default.builtin),j.contextVariables=["arguments","undefined","Infinity","NaN"],t.default=j,e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.NOT_LOCAL_BINDING=t.BLOCK_SCOPED_SYMBOL=t.INHERIT_KEYS=t.UNARY_OPERATORS=t.STRING_UNARY_OPERATORS=t.NUMBER_UNARY_OPERATORS=t.BOOLEAN_UNARY_OPERATORS=t.BINARY_OPERATORS=t.NUMBER_BINARY_OPERATORS=t.BOOLEAN_BINARY_OPERATORS=t.COMPARISON_BINARY_OPERATORS=t.EQUALITY_BINARY_OPERATORS=t.BOOLEAN_NUMBER_BINARY_OPERATORS=t.UPDATE_OPERATORS=t.LOGICAL_OPERATORS=t.COMMENT_KEYS=t.FOR_INIT_KEYS=t.FLATTENABLE_KEYS=t.STATEMENT_OR_BLOCK_KEYS=void 0;var n=r(362),i=function(e){return e&&e.__esModule?e:{default:e}}(n),s=(t.STATEMENT_OR_BLOCK_KEYS=["consequent","body","alternate"],t.FLATTENABLE_KEYS=["body","expressions"],t.FOR_INIT_KEYS=["left","init"],t.COMMENT_KEYS=["leadingComments","trailingComments","innerComments"],t.LOGICAL_OPERATORS=["||","&&"],t.UPDATE_OPERATORS=["++","--"],t.BOOLEAN_NUMBER_BINARY_OPERATORS=[">","<",">=","<="]),a=t.EQUALITY_BINARY_OPERATORS=["==","===","!=","!=="],o=t.COMPARISON_BINARY_OPERATORS=[].concat(a,["in","instanceof"]),u=t.BOOLEAN_BINARY_OPERATORS=[].concat(o,s),l=t.NUMBER_BINARY_OPERATORS=["-","/","%","*","**","&","|",">>",">>>","<<","^"],c=(t.BINARY_OPERATORS=["+"].concat(l,u),t.BOOLEAN_UNARY_OPERATORS=["delete","!"]),f=t.NUMBER_UNARY_OPERATORS=["+","-","++","--","~"],p=t.STRING_UNARY_OPERATORS=["typeof"];t.UNARY_OPERATORS=["void"].concat(c,f,p),t.INHERIT_KEYS={optional:["typeAnnotation","typeParameters","returnType"],force:["start","loc","end"]},t.BLOCK_SCOPED_SYMBOL=(0,i.default)("var used to be block scoped"),t.NOT_LOCAL_BINDING=(0,i.default)("should not be considered a local binding")},function(e,t){"use strict";e.exports=function(e,t,r,n){if(!(e instanceof t)||void 0!==n&&n in e)throw TypeError(r+": incorrect invocation!");return e}},function(e,t,r){"use strict";var n=r(43),i=r(142),s=r(94),a=r(153),o=r(422);e.exports=function(e,t){var r=1==e,u=2==e,l=3==e,c=4==e,f=6==e,p=5==e||f,d=t||o;return function(t,o,h){for(var m,y,v=s(t),g=i(v),b=n(o,h,3),E=a(g.length),x=0,A=r?d(t,E):u?d(t,0):void 0;E>x;x++)if((p||x in g)&&(m=g[x],y=b(m,x,v),e))if(r)A[x]=y;else if(y)switch(e){case 3:return!0;case 5:return m;case 6:return x;case 2:A.push(m)}else if(c)return!1;return f?-1:l||c?c:A}}},function(e,t){"use strict";var r={}.toString;e.exports=function(e){return r.call(e).slice(8,-1)}},function(e,t,r){"use strict";var n=r(15),i=r(12),s=r(57),a=r(27),o=r(29),u=r(146),l=r(55),c=r(136),f=r(16),p=r(93),d=r(23).f,h=r(137)(0),m=r(22);e.exports=function(e,t,r,y,v,g){var b=n[e],E=b,x=v?"set":"add",A=E&&E.prototype,S={};return m&&"function"==typeof E&&(g||A.forEach&&!a(function(){(new E).entries().next()}))?(E=t(function(t,r){c(t,E,e,"_c"),t._c=new b,void 0!=r&&l(r,v,t[x],t)}),h("add,clear,delete,forEach,get,has,set,keys,values,entries,toJSON".split(","),function(e){var t="add"==e||"set"==e;e in A&&(!g||"clear"!=e)&&o(E.prototype,e,function(r,n){if(c(this,E,e),!t&&g&&!f(r))return"get"==e&&void 0;var i=this._c[e](0===r?0:r,n);return t?this:i})}),g||d(E.prototype,"size",{get:function(){return this._c.size}})):(E=y.getConstructor(t,e,v,x),u(E.prototype,r),s.NEED=!0),p(E,e),S[e]=E,i(i.G+i.W+i.F,S),g||y.setStrong(E,e,v),E}},function(e,t){"use strict";e.exports=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}},function(e,t){"use strict";e.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(e,t,r){"use strict";var n=r(138);e.exports=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==n(e)?e.split(""):Object(e)}},function(e,t,r){"use strict";var n=r(144),i=r(12),s=r(147),a=r(29),o=r(28),u=r(56),l=r(429),c=r(93),f=r(433),p=r(13)("iterator"),d=!([].keys&&"next"in[].keys()),h=function(){return this};e.exports=function(e,t,r,m,y,v,g){l(r,t,m);var b,E,x,A=function(e){if(!d&&e in C)return C[e];switch(e){case"keys":case"values":return function(){return new r(this,e)}}return function(){return new r(this,e)}},S=t+" Iterator",_="values"==y,D=!1,C=e.prototype,w=C[p]||C["@@iterator"]||y&&C[y],P=w||A(y),k=y?_?A("entries"):P:void 0,F="Array"==t?C.entries||w:w;if(F&&(x=f(F.call(new e)))!==Object.prototype&&x.next&&(c(x,S,!0),n||o(x,p)||a(x,p,h)),_&&w&&"values"!==w.name&&(D=!0,P=function(){return w.call(this)}),n&&!g||!d&&!D&&C[p]||a(C,p,P),u[t]=P,u[S]=h,y)if(b={values:_?P:A("values"),keys:v?P:A("keys"),entries:k},g)for(E in b)E in C||s(C,E,b[E]);else i(i.P+i.F*(d||D),t,b);return b}},function(e,t){"use strict";e.exports=!0},function(e,t){"use strict";t.f=Object.getOwnPropertySymbols},function(e,t,r){"use strict";var n=r(29);e.exports=function(e,t,r){for(var i in t)r&&e[i]?e[i]=t[i]:n(e,i,t[i]);return e}},function(e,t,r){"use strict";e.exports=r(29)},function(e,t,r){"use strict";var n=r(12),i=r(227),s=r(43),a=r(55);e.exports=function(e){n(n.S,e,{from:function(e){var t,r,n,o,u=arguments[1];return i(this),t=void 0!==u,t&&i(u),void 0==e?new this:(r=[],t?(n=0,o=s(u,arguments[2],2),a(e,!1,function(e){r.push(o(e,n++))})):a(e,!1,r.push,r),new this(r))}})}},function(e,t,r){"use strict";var n=r(12);e.exports=function(e){n(n.S,e,{of:function(){for(var e=arguments.length,t=Array(e);e--;)t[e]=arguments[e];return new this(t)}})}},function(e,t,r){"use strict";var n=r(151)("keys"),i=r(95);e.exports=function(e){return n[e]||(n[e]=i(e))}},function(e,t,r){"use strict";var n=r(15),i=n["__core-js_shared__"]||(n["__core-js_shared__"]={});e.exports=function(e){return i[e]||(i[e]={})}},function(e,t){"use strict";var r=Math.ceil,n=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?n:r)(e)}},function(e,t,r){"use strict";var n=r(152),i=Math.min;e.exports=function(e){return e>0?i(n(e),9007199254740991):0}},function(e,t,r){"use strict";var n=r(16);e.exports=function(e,t){if(!n(e))return e;var r,i;if(t&&"function"==typeof(r=e.toString)&&!n(i=r.call(e)))return i;if("function"==typeof(r=e.valueOf)&&!n(i=r.call(e)))return i;if(!t&&"function"==typeof(r=e.toString)&&!n(i=r.call(e)))return i;throw TypeError("Can't convert object to primitive value")}},function(e,t,r){"use strict";var n=r(15),i=r(5),s=r(144),a=r(156),o=r(23).f;e.exports=function(e){var t=i.Symbol||(i.Symbol=s?{}:n.Symbol||{});"_"==e.charAt(0)||e in t||o(t,e,{value:a.f(e)})}},function(e,t,r){"use strict";t.f=r(13)},function(e,t,r){"use strict";var n=r(437)(!0);r(143)(String,"String",function(e){this._t=String(e),this._i=0},function(){var e,t=this._t,r=this._i;return r>=t.length?{value:void 0,done:!0}:(e=n(t,r),this._i+=e.length,{value:e,done:!1})})},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=r(15),s=r(28),a=r(22),o=r(12),u=r(147),l=r(57).KEY,c=r(27),f=r(151),p=r(93),d=r(95),h=r(13),m=r(156),y=r(155),v=r(430),g=r(425),b=r(232),E=r(21),x=r(37),A=r(154),S=r(92),_=r(90),D=r(432),C=r(235),w=r(23),P=r(44),k=C.f,F=w.f,T=D.f,O=i.Symbol,B=i.JSON,R=B&&B.stringify,I=h("_hidden"),M=h("toPrimitive"),N={}.propertyIsEnumerable,L=f("symbol-registry"),j=f("symbols"),U=f("op-symbols"),V=Object.prototype,G="function"==typeof O,W=i.QObject,Y=!W||!W.prototype||!W.prototype.findChild,q=a&&c(function(){return 7!=_(F({},"a",{get:function(){return F(this,"a",{value:7}).a}})).a})?function(e,t,r){var n=k(V,t);n&&delete V[t],F(e,t,r),n&&e!==V&&F(V,t,n)}:F,K=function(e){var t=j[e]=_(O.prototype);return t._k=e,t},H=G&&"symbol"==n(O.iterator)?function(e){return"symbol"==(void 0===e?"undefined":n(e))}:function(e){return e instanceof O},J=function(e,t,r){return e===V&&J(U,t,r),E(e),t=A(t,!0),E(r),s(j,t)?(r.enumerable?(s(e,I)&&e[I][t]&&(e[I][t]=!1),r=_(r,{enumerable:S(0,!1)})):(s(e,I)||F(e,I,S(1,{})),e[I][t]=!0),q(e,t,r)):F(e,t,r)},X=function(e,t){E(e);for(var r,n=g(t=x(t)),i=0,s=n.length;s>i;)J(e,r=n[i++],t[r]);return e},z=function(e,t){return void 0===t?_(e):X(_(e),t)},$=function(e){var t=N.call(this,e=A(e,!0));return!(this===V&&s(j,e)&&!s(U,e))&&(!(t||!s(this,e)||!s(j,e)||s(this,I)&&this[I][e])||t)},Q=function(e,t){if(e=x(e),t=A(t,!0),e!==V||!s(j,t)||s(U,t)){var r=k(e,t);return!r||!s(j,t)||s(e,I)&&e[I][t]||(r.enumerable=!0),r}},Z=function(e){for(var t,r=T(x(e)),n=[],i=0;r.length>i;)s(j,t=r[i++])||t==I||t==l||n.push(t);return n},ee=function(e){for(var t,r=e===V,n=T(r?U:x(e)),i=[],a=0;n.length>a;)!s(j,t=n[a++])||r&&!s(V,t)||i.push(j[t]);return i};G||(O=function(){if(this instanceof O)throw TypeError("Symbol is not a constructor!");var e=d(arguments.length>0?arguments[0]:void 0),t=function t(r){this===V&&t.call(U,r),s(this,I)&&s(this[I],e)&&(this[I][e]=!1),q(this,e,S(1,r))};return a&&Y&&q(V,e,{configurable:!0,set:t}),K(e)},u(O.prototype,"toString",function(){return this._k}),C.f=Q,w.f=J,r(236).f=D.f=Z,r(91).f=$,r(145).f=ee,a&&!r(144)&&u(V,"propertyIsEnumerable",$,!0),m.f=function(e){return K(h(e))}),o(o.G+o.W+o.F*!G,{Symbol:O});for(var te="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),re=0;te.length>re;)h(te[re++]);for(var ne=P(h.store),ie=0;ne.length>ie;)y(ne[ie++]);o(o.S+o.F*!G,"Symbol",{for:function(e){return s(L,e+="")?L[e]:L[e]=O(e)},keyFor:function(e){if(H(e))return v(L,e);throw TypeError(e+" is not a symbol!")},useSetter:function(){Y=!0},useSimple:function(){Y=!1}}),o(o.S+o.F*!G,"Object",{create:z,defineProperty:J,defineProperties:X,getOwnPropertyDescriptor:Q,getOwnPropertyNames:Z,getOwnPropertySymbols:ee}),B&&o(o.S+o.F*(!G||c(function(){var e=O();return"[null]"!=R([e])||"{}"!=R({a:e})||"{}"!=R(Object(e))})),"JSON",{stringify:function(e){if(void 0!==e&&!H(e)){for(var t,r,n=[e],i=1;arguments.length>i;)n.push(arguments[i++]);return t=n[1],"function"==typeof t&&(r=t),!r&&b(t)||(t=function(e,t){if(r&&(t=r.call(this,e,t)),!H(t))return t}),n[1]=t,R.apply(B,n)}}}),O.prototype[M]||r(29)(O.prototype,M,O.prototype.valueOf),p(O,"Symbol"),p(Math,"Math",!0),p(i.JSON,"JSON",!0)},function(e,t,r){"use strict";var n=r(38),i=r(17),s=n(i,"Map");e.exports=s},function(e,t,r){"use strict";function n(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}var i=r(551),s=r(552),a=r(553),o=r(554),u=r(555);n.prototype.clear=i,n.prototype.delete=s,n.prototype.get=a,n.prototype.has=o,n.prototype.set=u,e.exports=n},function(e,t){"use strict";function r(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}e.exports=r},function(e,t,r){"use strict";function n(e,t,r){var n=e[t];o.call(e,t)&&s(n,r)&&(void 0!==r||t in e)||i(e,t,r)}var i=r(163),s=r(46),a=Object.prototype,o=a.hasOwnProperty;e.exports=n},function(e,t,r){"use strict";function n(e,t,r){"__proto__"==t&&i?i(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var i=r(259);e.exports=n},function(e,t,r){"use strict";function n(e,t,r,T,O,B){var R,I=t&S,M=t&_,N=t&D;if(r&&(R=O?r(e,T,O,B):r(e)),void 0!==R)return R;if(!x(e))return e;var L=b(e);if(L){if(R=y(e),!I)return c(e,R)}else{var j=m(e),U=j==w||j==P;if(E(e))return l(e,I);if(j==k||j==C||U&&!O){if(R=M||U?{}:g(e),!I)return M?p(e,u(R,e)):f(e,o(R,e))}else{if(!F[j])return O?e:{};R=v(e,j,n,I)}}B||(B=new i);var V=B.get(e);if(V)return V;B.set(e,R);var G=N?M?h:d:M?keysIn:A,W=L?void 0:G(e);return s(W||e,function(i,s){W&&(s=i,i=e[s]),a(R,s,n(i,t,r,s,e,B))}),R}var i=r(99),s=r(478),a=r(162),o=r(483),u=r(484),l=r(256),c=r(168),f=r(523),p=r(524),d=r(262),h=r(532),m=r(264),y=r(541),v=r(542),g=r(266),b=r(6),E=r(113),x=r(18),A=r(32),S=1,_=2,D=4,C="[object Arguments]",w="[object Function]",P="[object GeneratorFunction]",k="[object Object]",F={};F[C]=F["[object Array]"]=F["[object ArrayBuffer]"]=F["[object DataView]"]=F["[object Boolean]"]=F["[object Date]"]=F["[object Float32Array]"]=F["[object Float64Array]"]=F["[object Int8Array]"]=F["[object Int16Array]"]=F["[object Int32Array]"]=F["[object Map]"]=F["[object Number]"]=F[k]=F["[object RegExp]"]=F["[object Set]"]=F["[object String]"]=F["[object Symbol]"]=F["[object Uint8Array]"]=F["[object Uint8ClampedArray]"]=F["[object Uint16Array]"]=F["[object Uint32Array]"]=!0,F["[object Error]"]=F[w]=F["[object WeakMap]"]=!1,e.exports=n},function(e,t){"use strict";function r(e,t,r,n){for(var i=e.length,s=r+(n?1:-1);n?s--:++s<i;)if(t(e[s],s,e))return s;return-1}e.exports=r},function(e,t,r){"use strict";function n(e,t,r){return t===t?a(e,t,r):i(e,s,r)}var i=r(165),s=r(496),a=r(570);e.exports=n},function(e,t,r){"use strict";function n(e){var t=new e.constructor(e.byteLength);return new i(t).set(new i(e)),t}var i=r(243);e.exports=n},function(e,t){"use strict";function r(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}e.exports=r},function(e,t,r){"use strict";var n=r(271),i=n(Object.getPrototypeOf,Object);e.exports=i},function(e,t,r){"use strict";var n=r(479),i=r(279),s=Object.prototype,a=s.propertyIsEnumerable,o=Object.getOwnPropertySymbols,u=o?function(e){return null==e?[]:(e=Object(e),n(o(e),function(t){return a.call(e,t)}))}:i;e.exports=u},function(e,t){"use strict";function r(e,t){return!!(t=null==t?n:t)&&("number"==typeof e||i.test(e))&&e>-1&&e%1==0&&e<t}var n=9007199254740991,i=/^(?:0|[1-9]\d*)$/;e.exports=r},function(e,t,r){"use strict";function n(e,t,r){if(!u(r))return!1;var n=void 0===t?"undefined":i(t);return!!("number"==n?a(r)&&o(t,r.length):"string"==n&&t in r)&&s(r[t],e)}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s=r(46),a=r(24),o=r(171),u=r(18);e.exports=n},function(e,t,r){"use strict";function n(e,t){if(s(e))return!1;var r=void 0===e?"undefined":i(e);return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!a(e))||(u.test(e)||!o.test(e)||null!=t&&e in Object(t))}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s=r(6),a=r(62),o=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,u=/^\w*$/;e.exports=n},function(e,t,r){"use strict";var n=r(162),i=r(31),s=r(103),a=r(24),o=r(105),u=r(32),l=Object.prototype,c=l.hasOwnProperty,f=s(function(e,t){if(o(t)||a(t))return void i(t,u(t),e);for(var r in t)c.call(t,r)&&n(e,r,t[r])});e.exports=f},function(e,t,r){"use strict";function n(e){if(!s(e))return!1;var t=i(e);return t==o||t==u||t==a||t==l}var i=r(30),s=r(18),a="[object AsyncFunction]",o="[object Function]",u="[object GeneratorFunction]",l="[object Proxy]";e.exports=n},function(e,t){"use strict";function r(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=n}var n=9007199254740991;e.exports=r},function(e,t,r){"use strict";var n=r(499),i=r(102),s=r(270),a=s&&s.isTypedArray,o=a?i(a):n;e.exports=o},function(e,t,r){function n(e){return r(i(e))}function i(e){return s[e]||function(){throw new Error("Cannot find module '"+e+"'.")}()}var s={"./index":50,"./index.js":50,"./logger":120,"./logger.js":120,"./metadata":121,"./metadata.js":121,"./options/build-config-chain":51,"./options/build-config-chain.js":51,"./options/config":33,"./options/config.js":33,"./options/index":52,"./options/index.js":52,"./options/option-manager":34,"./options/option-manager.js":34,"./options/parsers":53,"./options/parsers.js":53,"./options/removed":54,"./options/removed.js":54};n.keys=function(){return Object.keys(s)},n.resolve=i,e.exports=n,n.id=178},function(e,t,r){function n(e){return r(i(e))}function i(e){return s[e]||function(){throw new Error("Cannot find module '"+e+"'.")}()}var s={"./build-config-chain":51,"./build-config-chain.js":51,"./config":33,"./config.js":33,"./index":52,"./index.js":52,"./option-manager":34,"./option-manager.js":34,"./parsers":53,"./parsers.js":53,"./removed":54,"./removed.js":54};n.keys=function(){return Object.keys(s)},n.resolve=i,e.exports=n,n.id=179},function(e,t){"use strict";e.exports=function(){return/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]/g}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){return{keyword:e.cyan,capitalized:e.yellow,jsx_tag:e.yellow,punctuator:e.yellow,number:e.magenta,string:e.green,regex:e.magenta,comment:e.grey,invalid:e.white.bgRed.bold,gutter:e.grey,marker:e.red.bold}}function s(e){var t=e.slice(-2),r=t[0],n=t[1],i=(0,o.matchToToken)(e);if("name"===i.type){if(c.default.keyword.isReservedWordES6(i.value))return"keyword";if(h.test(i.value)&&("<"===n[r-1]||"</"==n.substr(r-2,2)))return"jsx_tag";if(i.value[0]!==i.value[0].toLowerCase())return"capitalized"}return"punctuator"===i.type&&m.test(i.value)?"bracket":i.type}function a(e,t){return t.replace(u.default,function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];var i=s(r),a=e[i];return a?r[0].split(d).map(function(e){return a(e)}).join("\n"):r[0]})}t.__esModule=!0,t.default=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};r=Math.max(r,0);var s=n.highlightCode&&p.default.supportsColor||n.forceColor,o=p.default;n.forceColor&&(o=new p.default.constructor({enabled:!0}));var u=function(e,t){return s?e(t):t},l=i(o);s&&(e=a(l,e));var c=n.linesAbove||2,f=n.linesBelow||3,h=e.split(d),m=Math.max(t-(c+1),0),y=Math.min(h.length,t+f);t||r||(m=0,y=h.length);var v=String(y).length,g=h.slice(m,y).map(function(e,n){var i=m+1+n,s=(" "+i).slice(-v),a=" "+s+" | ";if(i===t){var o="";if(r){var c=e.slice(0,r-1).replace(/[^\t]/g," ");o=["\n ",u(l.gutter,a.replace(/\d/g," ")),c,u(l.marker,"^")].join("")}return[u(l.marker,">"),u(l.gutter,a),e,o].join("")}return" "+u(l.gutter,a)+e}).join("\n");return s?o.reset(g):g};var o=r(468),u=n(o),l=r(97),c=n(l),f=r(401),p=n(f),d=/\r\n|[\n\r\u2028\u2029]/,h=/^[a-z][\w-]*$/i,m=/^[()\[\]{}]$/;e.exports=t.default},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}function s(e){throw new Error("The ("+e+") Babel 5 plugin is being run with Babel 6.")}function a(e,t,r){"function"==typeof t&&(r=t,t={}),t.filename=e,y.default.readFile(e,function(e,n){var i=void 0;if(!e)try{i=F(n,t)}catch(t){e=t}e?r(e):r(null,i)})}function o(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.filename=e,F(y.default.readFileSync(e,"utf8"),t)}t.__esModule=!0,t.transformFromAst=t.transform=t.analyse=t.Pipeline=t.OptionManager=t.traverse=t.types=t.messages=t.util=t.version=t.resolvePreset=t.resolvePlugin=t.template=t.buildExternalHelpers=t.options=t.File=void 0;var u=r(50);Object.defineProperty(t,"File",{enumerable:!0,get:function(){return i(u).default}});var l=r(33);Object.defineProperty(t,"options",{enumerable:!0,get:function(){return i(l).default}});var c=r(295);Object.defineProperty(t,"buildExternalHelpers",{enumerable:!0,get:function(){return i(c).default}});var f=r(4);Object.defineProperty(t,"template",{enumerable:!0,get:function(){return i(f).default}});var p=r(184);Object.defineProperty(t,"resolvePlugin",{enumerable:!0,get:function(){return i(p).default}});var d=r(185);Object.defineProperty(t,"resolvePreset",{enumerable:!0,get:function(){return i(d).default}});var h=r(628);Object.defineProperty(t,"version",{enumerable:!0,get:function(){return h.version}}),t.Plugin=s,t.transformFile=a,t.transformFileSync=o;var m=r(115),y=i(m),v=r(122),g=n(v),b=r(20),E=n(b),x=r(1),A=n(x),S=r(7),_=i(S),D=r(34),C=i(D),w=r(298),P=i(w);t.util=g,t.messages=E,t.types=A,t.traverse=_.default,t.OptionManager=C.default,t.Pipeline=P.default;var k=new P.default,F=(t.analyse=k.analyse.bind(k),t.transform=k.transform.bind(k));t.transformFromAst=k.transformFromAst.bind(k)},function(e,t,r){"use strict";function n(e,t){return e.reduce(function(e,r){return e||(0,s.default)(r,t)},null)}t.__esModule=!0,t.default=n;var i=r(118),s=function(e){return e&&e.__esModule?e:{default:e}}(i);e.exports=t.default},function(e,t,r){(function(n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.cwd();return(0,o.default)((0,l.default)(e),t)}t.__esModule=!0,t.default=s;var a=r(183),o=i(a),u=r(291),l=i(u);e.exports=t.default}).call(t,r(8))},function(e,t,r){(function(n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.cwd();return(0,o.default)((0,l.default)(e),t)}t.__esModule=!0,t.default=s;var a=r(183),o=i(a),u=r(292),l=i(u);e.exports=t.default}).call(t,r(8))},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t,r){var n=" ";if(e&&"string"==typeof e){var i=(0,d.default)(e).indent;i&&" "!==i&&(n=i)}var a={auxiliaryCommentBefore:t.auxiliaryCommentBefore,auxiliaryCommentAfter:t.auxiliaryCommentAfter,shouldPrintComment:t.shouldPrintComment,retainLines:t.retainLines,retainFunctionParens:t.retainFunctionParens,comments:null==t.comments||t.comments,compact:t.compact,minified:t.minified,concise:t.concise,quotes:t.quotes||s(e,r),jsonCompatibleStrings:t.jsonCompatibleStrings,indent:{adjustMultilineComment:!0,style:n,base:0},flowCommaSeparator:t.flowCommaSeparator};return a.minified?(a.compact=!0,a.shouldPrintComment=a.shouldPrintComment||function(){return a.comments}):a.shouldPrintComment=a.shouldPrintComment||function(e){return a.comments||e.indexOf("@license")>=0||e.indexOf("@preserve")>=0},"auto"===a.compact&&(a.compact=e.length>5e5,a.compact&&console.error("[BABEL] "+v.get("codeGeneratorDeopt",t.filename,"500KB"))),a.compact&&(a.indent.adjustMultilineComment=!1),a}function s(e,t){if(!e)return"double";for(var r={single:0,double:0},n=0,i=0;i<t.length;i++){var s=t[i];if("string"===s.type.label){if("'"===e.slice(s.start,s.end)[0]?r.single++:r.double++,++n>=3)break}}return r.single>r.double?"single":"double"}t.__esModule=!0,t.CodeGenerator=void 0;var a=r(3),o=n(a),u=r(42),l=n(u),c=r(41),f=n(c);t.default=function(e,t,r){return new E(e,t,r).generate()};var p=r(459),d=n(p),h=r(313),m=n(h),y=r(20),v=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(y),g=r(312),b=n(g),E=function(e){function t(r){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=arguments[2];(0,o.default)(this,t);var a=r.tokens||[],u=i(s,n,a),c=n.sourceMaps?new m.default(n,s):null,f=(0,l.default)(this,e.call(this,u,c,a));return f.ast=r,f}return(0,f.default)(t,e),t.prototype.generate=function(){return e.prototype.generate.call(this,this.ast)},t}(b.default);t.CodeGenerator=function(){function e(t,r,n){(0,o.default)(this,e),this._generator=new E(t,r,n)}return e.prototype.generate=function(){return this._generator.generate()},e}()},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}function s(e){function t(e,t){var n=r[e];r[e]=n?function(e,r,i){var s=n(e,r,i);return null==s?t(e,r,i):s}:t}for(var r={},n=(0,m.default)(e),i=Array.isArray(n),s=0,n=i?n:(0,d.default)(n);;){var a;if(i){if(s>=n.length)break;a=n[s++]}else{if(s=n.next(),s.done)break;a=s.value}var o=a,u=x.FLIPPED_ALIAS_KEYS[o];if(u)for(var l=u,c=Array.isArray(l),f=0,l=c?l:(0,d.default)(l);;){var p;if(c){if(f>=l.length)break;p=l[f++]}else{if(f=l.next(),f.done)break;p=f.value}var h=p;t(h,e[o])}else t(o,e[o])}return r}function a(e,t,r,n){var i=e[t.type];return i?i(t,r,n):null}function o(e){return!!x.isCallExpression(e)||!!x.isMemberExpression(e)&&(o(e.object)||!e.computed&&o(e.property))}function u(e,t,r){if(!e)return 0;x.isExpressionStatement(e)&&(e=e.expression);var n=a(S,e,t);if(!n){var i=a(_,e,t);if(i)for(var s=0;s<i.length&&!(n=u(i[s],e,r));s++);}return n&&n[r]||0}function l(e,t){return u(e,t,"before")}function c(e,t){return u(e,t,"after")}function f(e,t,r){return!!t&&(!(!x.isNewExpression(t)||t.callee!==e||!o(e))||a(A,e,t,r))}t.__esModule=!0;var p=r(2),d=i(p),h=r(14),m=i(h);t.needsWhitespace=u,t.needsWhitespaceBefore=l,t.needsWhitespaceAfter=c,t.needsParens=f;var y=r(311),v=i(y),g=r(310),b=n(g),E=r(1),x=n(E),A=s(b),S=s(v.default.nodes),_=s(v.default.list)},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){return!v.isClassMethod(e)&&!v.isObjectMethod(e)||"get"!==e.kind&&"set"!==e.kind?"value":e.kind}function s(e,t,r,n,s){var a=v.toKeyAlias(t),o={};if((0,m.default)(e,a)&&(o=e[a]),e[a]=o,o._inherits=o._inherits||[],o._inherits.push(t),o._key=t.key,t.computed&&(o._computed=!0),t.decorators){var u=o.decorators=o.decorators||v.arrayExpression([]);u.elements=u.elements.concat(t.decorators.map(function(e){return e.expression}).reverse())}if(o.value||o.initializer)throw n.buildCodeFrameError(t,"Key conflict with sibling node");var l=void 0,c=void 0;(v.isObjectProperty(t)||v.isObjectMethod(t)||v.isClassMethod(t))&&(l=v.toComputedKey(t,t.key)),v.isObjectProperty(t)||v.isClassProperty(t)?c=t.value:(v.isObjectMethod(t)||v.isClassMethod(t))&&(c=v.functionExpression(null,t.params,t.body,t.generator,t.async),c.returnType=t.returnType);var f=i(t);return r&&"value"===f||(r=f),s&&v.isStringLiteral(l)&&("value"===r||"initializer"===r)&&v.isFunctionExpression(c)&&(c=(0,d.default)({id:l,node:c,scope:s})),c&&(v.inheritsComments(c,t),o[r]=c),o}function a(e){for(var t in e)if(e[t]._computed)return!0;return!1}function o(e){for(var t=v.arrayExpression([]),r=0;r<e.properties.length;r++){var n=e.properties[r],i=n.value;i.properties.unshift(v.objectProperty(v.identifier("key"),v.toComputedKey(n))),t.elements.push(i)}return t}function u(e){var t=v.objectExpression([]);return(0,f.default)(e).forEach(function(r){var n=e[r],i=v.objectExpression([]),s=v.objectProperty(n._key,i,n._computed);(0,f.default)(n).forEach(function(e){var t=n[e];if("_"!==e[0]){var r=t;(v.isClassMethod(t)||v.isClassProperty(t))&&(t=t.value);var s=v.objectProperty(v.identifier(e),t);v.inheritsComments(s,r),v.removeComments(r),i.properties.push(s)}}),t.properties.push(s)}),t}function l(e){return(0,f.default)(e).forEach(function(t){var r=e[t];r.value&&(r.writable=v.booleanLiteral(!0)),r.configurable=v.booleanLiteral(!0),r.enumerable=v.booleanLiteral(!0)}),u(e)}t.__esModule=!0;var c=r(14),f=n(c);t.push=s,t.hasComputed=a,t.toComputedObjectFromClass=o,t.toClassObject=u,t.toDefineObject=l;var p=r(40),d=n(p),h=r(274),m=n(h),y=r(1),v=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(y)},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(e){for(var t=e.params,r=0;r<t.length;r++){var n=t[r];if(i.isAssignmentPattern(n)||i.isRestElement(n))return r}return t.length};var n=r(1),i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(n);e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0;var n=r(2),i=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"var";e.traverse(o,{kind:r,emit:t})};var s=r(1),a=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(s),o={Scope:function(e,t){"let"===t.kind&&e.skip()},Function:function(e){e.skip()},VariableDeclaration:function(e,t){if(!t.kind||e.node.kind===t.kind){for(var r=[],n=e.get("declarations"),s=void 0,o=n,u=Array.isArray(o),l=0,o=u?o:(0,i.default)(o);;){var c;if(u){if(l>=o.length)break;c=o[l++]}else{if(l=o.next(),l.done)break;c=l.value}var f=c;s=f.node.id,f.node.init&&r.push(a.expressionStatement(a.assignmentExpression("=",f.node.id,f.node.init)));for(var p in f.getBindingIdentifiers())t.emit(a.identifier(p),p)}e.parentPath.isFor({left:e.node})?e.replaceWith(s):e.replaceWithMultiple(r)}}};e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(e,t,r){return 1===r.length&&i.isSpreadElement(r[0])&&i.isIdentifier(r[0].argument,{name:"arguments"})?i.callExpression(i.memberExpression(e,i.identifier("apply")),[t,r[0].argument]):i.callExpression(i.memberExpression(e,i.identifier("call")),[t].concat(r))};var n=r(1),i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(n);e.exports=t.default},function(e,t,r){"use strict";function n(e,t){return u.isRegExpLiteral(e)&&e.flags.indexOf(t)>=0}function i(e,t){var r=e.flags.split("");e.flags.indexOf(t)<0||((0,a.default)(r,t),e.flags=r.join(""))}t.__esModule=!0,t.is=n,t.pullFlag=i;var s=r(277),a=function(e){return e&&e.__esModule?e:{default:e}}(s),o=r(1),u=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(o)},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}function s(e,t){return!!v.isSuper(e)&&(!v.isMemberExpression(t,{computed:!1})&&!v.isCallExpression(t,{callee:e}))}function a(e){return v.isMemberExpression(e)&&v.isSuper(e.object)}function o(e,t){var r=t?e:v.memberExpression(e,v.identifier("prototype"));return v.logicalExpression("||",v.memberExpression(r,v.identifier("__proto__")),v.callExpression(v.memberExpression(v.identifier("Object"),v.identifier("getPrototypeOf")),[r]))}t.__esModule=!0;var u=r(3),l=i(u),c=r(10),f=i(c),p=r(191),d=i(p),h=r(20),m=n(h),y=r(1),v=n(y),g=(0,f.default)(),b={Function:function(e){e.inShadow("this")||e.skip()},ReturnStatement:function(e,t){e.inShadow("this")||t.returns.push(e)},ThisExpression:function(e,t){e.node[g]||t.thises.push(e)},enter:function(e,t){var r=t.specHandle;t.isLoose&&(r=t.looseHandle);var n=e.isCallExpression()&&e.get("callee").isSuper(),i=r.call(t,e);i&&(t.hasSuper=!0),n&&t.bareSupers.push(e),!0===i&&e.requeue(),!0!==i&&i&&(Array.isArray(i)?e.replaceWithMultiple(i):e.replaceWith(i))}},E=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];(0,l.default)(this,e),this.forceSuperMemoisation=t.forceSuperMemoisation,this.methodPath=t.methodPath, +this.methodNode=t.methodNode,this.superRef=t.superRef,this.isStatic=t.isStatic,this.hasSuper=!1,this.inClass=r,this.isLoose=t.isLoose,this.scope=this.methodPath.scope,this.file=t.file,this.opts=t,this.bareSupers=[],this.returns=[],this.thises=[]}return e.prototype.getObjectRef=function(){return this.opts.objectRef||this.opts.getObjectRef()},e.prototype.setSuperProperty=function(e,t,r){return v.callExpression(this.file.addHelper("set"),[o(this.getObjectRef(),this.isStatic),r?e:v.stringLiteral(e.name),t,v.thisExpression()])},e.prototype.getSuperProperty=function(e,t){return v.callExpression(this.file.addHelper("get"),[o(this.getObjectRef(),this.isStatic),t?e:v.stringLiteral(e.name),v.thisExpression()])},e.prototype.replace=function(){this.methodPath.traverse(b,this)},e.prototype.getLooseSuperProperty=function(e,t){var r=this.methodNode,n=this.superRef||v.identifier("Function");return t.property===e?void 0:v.isCallExpression(t,{callee:e})?void 0:v.isMemberExpression(t)&&!r.static?v.memberExpression(n,v.identifier("prototype")):n},e.prototype.looseHandle=function(e){var t=e.node;if(e.isSuper())return this.getLooseSuperProperty(t,e.parent);if(e.isCallExpression()){var r=t.callee;if(!v.isMemberExpression(r))return;if(!v.isSuper(r.object))return;return v.appendToMemberExpression(r,v.identifier("call")),t.arguments.unshift(v.thisExpression()),!0}},e.prototype.specHandleAssignmentExpression=function(e,t,r){return"="===r.operator?this.setSuperProperty(r.left.property,r.right,r.left.computed):(e=e||t.scope.generateUidIdentifier("ref"),[v.variableDeclaration("var",[v.variableDeclarator(e,r.left)]),v.expressionStatement(v.assignmentExpression("=",r.left,v.binaryExpression(r.operator[0],e,r.right)))])},e.prototype.specHandle=function(e){var t=void 0,r=void 0,n=void 0,i=e.parent,o=e.node;if(s(o,i))throw e.buildCodeFrameError(m.get("classesIllegalBareSuper"));if(v.isCallExpression(o)){var u=o.callee;if(v.isSuper(u))return;a(u)&&(t=u.property,r=u.computed,n=o.arguments)}else if(v.isMemberExpression(o)&&v.isSuper(o.object))t=o.property,r=o.computed;else{if(v.isUpdateExpression(o)&&a(o.argument)){var l=v.binaryExpression(o.operator[0],o.argument,v.numericLiteral(1));if(o.prefix)return this.specHandleAssignmentExpression(null,e,l);var c=e.scope.generateUidIdentifier("ref");return this.specHandleAssignmentExpression(c,e,l).concat(v.expressionStatement(c))}if(v.isAssignmentExpression(o)&&a(o.left))return this.specHandleAssignmentExpression(null,e,o)}if(t){var f=this.getSuperProperty(t,r);return n?this.optimiseCall(f,n):f}},e.prototype.optimiseCall=function(e,t){var r=v.thisExpression();return r[g]=!0,(0,d.default)(e,r,t)},e}();t.default=E,e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){var t=u.default[e];if(!t)throw new ReferenceError("Unknown helper "+e);return t().expression}t.__esModule=!0,t.list=void 0;var s=r(14),a=n(s);t.get=i;var o=r(321),u=n(o);t.list=(0,a.default)(u.default).map(function(e){return e.replace(/^_/,"")}).filter(function(e){return"__esModule"!==e});t.default=i},function(e,t){"use strict";t.__esModule=!0,t.default=function(){return{manipulateOptions:function(e,t){t.plugins.push("asyncGenerators")}}},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(){return{manipulateOptions:function(e,t){t.plugins.push("classConstructorCall")}}},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(){return{manipulateOptions:function(e,t){t.plugins.push("classProperties")}}},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(){return{manipulateOptions:function(e,t){t.plugins.push("doExpressions")}}},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(){return{manipulateOptions:function(e,t){t.plugins.push("exponentiationOperator")}}},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(){return{manipulateOptions:function(e,t){t.plugins.push("exportExtensions")}}},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(){return{manipulateOptions:function(e,t){t.plugins.push("functionBind")}}},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(){return{manipulateOptions:function(e,t){t.plugins.push("objectRestSpread")}}},e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(2),s=n(i),a=r(10),o=n(a);t.default=function(e){function t(e){for(var t=e.get("body.body"),r=t,n=Array.isArray(r),i=0,r=n?r:(0,s.default)(r);;){var a;if(n){if(i>=r.length)break;a=r[i++]}else{if(i=r.next(),i.done)break;a=i.value}var o=a;if("constructorCall"===o.node.kind)return o}return null}function n(e,t){var r=t,n=r.node,s=n.id||t.scope.generateUidIdentifier("class");t.parentPath.isExportDefaultDeclaration()&&(t=t.parentPath,t.insertAfter(i.exportDefaultDeclaration(s))),t.replaceWithMultiple(c({CLASS_REF:t.scope.generateUidIdentifier(s.name),CALL_REF:t.scope.generateUidIdentifier(s.name+"Call"),CALL:i.functionExpression(null,e.node.params,e.node.body),CLASS:i.toExpression(n),WRAPPER_REF:s})),e.remove()}var i=e.types,a=(0,o.default)();return{inherits:r(196),visitor:{Class:function(e){if(!e.node[a]){e.node[a]=!0;var r=t(e);r&&n(r,e)}}}}};var u=r(4),l=n(u),c=(0,l.default)("\n let CLASS_REF = CLASS;\n var CALL_REF = CALL;\n var WRAPPER_REF = function (...args) {\n if (this instanceof WRAPPER_REF) {\n return Reflect.construct(CLASS_REF, args);\n } else {\n return CALL_REF.apply(this, args);\n }\n };\n WRAPPER_REF.__proto__ = CLASS_REF;\n WRAPPER_REF;\n");e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(2),s=n(i);t.default=function(e){var t=e.types,n={Super:function(e){e.parentPath.isCallExpression({callee:e.node})&&this.push(e.parentPath)}},i={ReferencedIdentifier:function(e){this.scope.hasOwnBinding(e.node.name)&&(this.collision=!0,e.skip())}},a=(0,l.default)("\n Object.defineProperty(REF, KEY, {\n // configurable is false by default\n enumerable: true,\n writable: true,\n value: VALUE\n });\n "),u=function(e,r){var n=r.key,i=r.value,s=r.computed;return a({REF:e,KEY:t.isIdentifier(n)&&!s?t.stringLiteral(n.name):n,VALUE:i||t.identifier("undefined")})},c=function(e,r){var n=r.key,i=r.value,s=r.computed;return t.expressionStatement(t.assignmentExpression("=",t.memberExpression(e,n,s||t.isLiteral(n)),i))};return{inherits:r(197),visitor:{Class:function(e,r){for(var a=r.opts.spec?u:c,l=!!e.node.superClass,f=void 0,p=[],d=e.get("body"),h=d.get("body"),m=Array.isArray(h),y=0,h=m?h:(0,s.default)(h);;){var v;if(m){if(y>=h.length)break;v=h[y++]}else{if(y=h.next(),y.done)break;v=y.value}var g=v;g.isClassProperty()?p.push(g):g.isClassMethod({kind:"constructor"})&&(f=g)}if(p.length){var b=[],E=void 0;e.isClassExpression()||!e.node.id?((0,o.default)(e),E=e.scope.generateUidIdentifier("class")):E=e.node.id;for(var x=[],A=p,S=Array.isArray(A),_=0,A=S?A:(0,s.default)(A);;){var D;if(S){if(_>=A.length)break;D=A[_++]}else{if(_=A.next(),_.done)break;D=_.value}var C=D,w=C.node;if(!(w.decorators&&w.decorators.length>0)&&(r.opts.spec||w.value)){if(w.static)b.push(a(E,w));else{if(!w.value)continue;x.push(a(t.thisExpression(),w))}}}if(x.length){if(!f){var P=t.classMethod("constructor",t.identifier("constructor"),[],t.blockStatement([]));l&&(P.params=[t.restElement(t.identifier("args"))],P.body.body.push(t.returnStatement(t.callExpression(t.super(),[t.spreadElement(t.identifier("args"))]))));f=d.unshiftContainer("body",P)[0]}for(var k={collision:!1,scope:f.scope},F=p,T=Array.isArray(F),O=0,F=T?F:(0,s.default)(F);;){var B;if(T){if(O>=F.length)break;B=F[O++]}else{if(O=F.next(),O.done)break;B=O.value}if(B.traverse(i,k),k.collision)break}if(k.collision){var R=e.scope.generateUidIdentifier("initialiseProps");b.push(t.variableDeclaration("var",[t.variableDeclarator(R,t.functionExpression(null,[],t.blockStatement(x)))])),x=[t.expressionStatement(t.callExpression(t.memberExpression(R,t.identifier("call")),[t.thisExpression()]))]}if(l){var I=[];f.traverse(n,I);for(var M=I,N=Array.isArray(M),L=0,M=N?M:(0,s.default)(M);;){var j;if(N){if(L>=M.length)break;j=M[L++]}else{if(L=M.next(),L.done)break;j=L.value}j.insertAfter(x)}}else f.get("body").unshiftContainer("body",x)}for(var U=p,V=Array.isArray(U),G=0,U=V?U:(0,s.default)(U);;){var W;if(V){if(G>=U.length)break;W=U[G++]}else{if(G=U.next(),G.done)break;W=G.value}W.remove()}b.length&&(e.isClassExpression()?(e.scope.push({id:E}),e.replaceWith(t.assignmentExpression("=",E,e.node))):(e.node.id||(e.node.id=E),e.parentPath.isExportDeclaration()&&(e=e.parentPath)),e.insertAfter(b))}},ArrowFunctionExpression:function(e){var t=e.get("body");if(t.isClassExpression()){t.get("body").get("body").some(function(e){return e.isClassProperty()})&&e.ensureBlock()}}}}};var a=r(40),o=n(a),u=r(4),l=n(u);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(9),s=n(i),a=r(2),o=n(a);t.default=function(e){function t(e){return e.reverse().map(function(e){return e.expression})}function n(e,r,n){var i=[],a=e.node.decorators;if(a){e.node.decorators=null,a=t(a);for(var l=a,c=Array.isArray(l),f=0,l=c?l:(0,o.default)(l);;){var d;if(c){if(f>=l.length)break;d=l[f++]}else{if(f=l.next(),f.done)break;d=f.value}var h=d;i.push(p({CLASS_REF:r,DECORATOR:h}))}}for(var m=(0,s.default)(null),y=e.get("body.body"),v=Array.isArray(y),g=0,y=v?y:(0,o.default)(y);;){var b;if(v){if(g>=y.length)break;b=y[g++]}else{if(g=y.next(),g.done)break;b=g.value}var E=b;if(E.node.decorators){var x=u.toKeyAlias(E.node);m[x]=m[x]||[],m[x].push(E.node),E.remove()}}for(var A in m){m[A]}return i}function i(e){if(e.isClass()){if(e.node.decorators)return!0;for(var t=e.node.body.body,r=Array.isArray(t),n=0,t=r?t:(0,o.default)(t);;){var i;if(r){if(n>=t.length)break;i=t[n++]}else{if(n=t.next(),n.done)break;i=n.value}if(i.decorators)return!0}}else if(e.isObjectExpression())for(var s=e.node.properties,a=Array.isArray(s),u=0,s=a?s:(0,o.default)(s);;){var l;if(a){if(u>=s.length)break;l=s[u++]}else{if(u=s.next(),u.done)break;l=u.value}var c=l;if(c.decorators)return!0}return!1}function a(e){throw e.buildCodeFrameError('Decorators are not officially supported yet in 6.x pending a proposal update.\nHowever, if you need to use them you can install the legacy decorators transform with:\n\nnpm install babel-plugin-transform-decorators-legacy --save-dev\n\nand add the following line to your .babelrc file:\n\n{\n "plugins": ["transform-decorators-legacy"]\n}\n\nThe repo url is: https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy.\n ')}var u=e.types;return{inherits:r(125),visitor:{ClassExpression:function(e){if(i(e)){a(e),(0,f.default)(e);var t=e.scope.generateDeclaredUidIdentifier("ref"),r=[];r.push(u.assignmentExpression("=",t,e.node)),r=r.concat(n(e,t,this)),r.push(t),e.replaceWith(u.sequenceExpression(r))}},ClassDeclaration:function(e){if(i(e)){a(e),(0,f.default)(e);var t=e.node.id,r=[];r=r.concat(n(e,t,this).map(function(e){return u.expressionStatement(e)})),r.push(u.expressionStatement(t)),e.insertAfter(r)}},ObjectExpression:function(e){i(e)&&a(e)}}}};var u=r(4),l=n(u),c=r(319),f=n(c),p=(0,l.default)("\n CLASS_REF = DECORATOR(CLASS_REF) || CLASS_REF;\n");e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(){return{inherits:r(198),visitor:{DoExpression:function(e){var t=e.node.body.body;t.length?e.replaceWithMultiple(t):e.replaceWith(e.scope.buildUndefinedNode())}}}},e.exports=t.default},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var s=r(2),a=i(s),o=r(3),u=i(o),l=r(7),c=r(193),f=i(c),p=r(191),d=i(p),h=r(188),m=n(h),y=r(4),v=i(y),g=r(1),b=n(g),E=(0,v.default)("\n (function () {\n super(...arguments);\n })\n"),x={"FunctionExpression|FunctionDeclaration":function(e){e.is("shadow")||e.skip()},Method:function(e){e.skip()}},A=l.visitors.merge([x,{Super:function(e){if(this.isDerived&&!this.hasBareSuper&&!e.parentPath.isCallExpression({callee:e.node}))throw e.buildCodeFrameError("'super.*' is not allowed before super()")},CallExpression:{exit:function(e){if(e.get("callee").isSuper()&&(this.hasBareSuper=!0,!this.isDerived))throw e.buildCodeFrameError("super() is only allowed in a derived constructor")}},ThisExpression:function(e){if(this.isDerived&&!this.hasBareSuper&&!e.inShadow("this"))throw e.buildCodeFrameError("'this' is not allowed before super()")}}]),S=l.visitors.merge([x,{ThisExpression:function(e){this.superThises.push(e)}}]),_=function(){function e(t,r){(0,u.default)(this,e),this.parent=t.parent,this.scope=t.scope,this.node=t.node,this.path=t,this.file=r,this.clearDescriptors(),this.instancePropBody=[],this.instancePropRefs={},this.staticPropBody=[],this.body=[],this.bareSuperAfter=[],this.bareSupers=[],this.pushedConstructor=!1,this.pushedInherits=!1,this.isLoose=!1,this.superThises=[],this.classId=this.node.id,this.classRef=this.node.id?b.identifier(this.node.id.name):this.scope.generateUidIdentifier("class"),this.superName=this.node.superClass||b.identifier("Function"),this.isDerived=!!this.node.superClass}return e.prototype.run=function(){var e=this,t=this.superName,r=this.file,n=this.body,i=this.constructorBody=b.blockStatement([]);this.constructor=this.buildConstructor();var s=[],a=[];if(this.isDerived&&(a.push(t),t=this.scope.generateUidIdentifierBasedOnNode(t),s.push(t),this.superName=t),this.buildBody(),i.body.unshift(b.expressionStatement(b.callExpression(r.addHelper("classCallCheck"),[b.thisExpression(),this.classRef]))),n=n.concat(this.staticPropBody.map(function(t){return t(e.classRef)})),this.classId&&1===n.length)return b.toExpression(n[0]);n.push(b.returnStatement(this.classRef));var o=b.functionExpression(null,s,b.blockStatement(n));return o.shadow=!0,b.callExpression(o,a)},e.prototype.buildConstructor=function(){var e=b.functionDeclaration(this.classRef,[],this.constructorBody);return b.inherits(e,this.node),e},e.prototype.pushToMap=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"value",n=arguments[3],i=void 0;e.static?(this.hasStaticDescriptors=!0,i=this.staticMutatorMap):(this.hasInstanceDescriptors=!0,i=this.instanceMutatorMap);var s=m.push(i,e,r,this.file,n);return t&&(s.enumerable=b.booleanLiteral(!0)),s},e.prototype.constructorMeMaybe=function(){for(var e=!1,t=this.path.get("body.body"),r=t,n=Array.isArray(r),i=0,r=n?r:(0,a.default)(r);;){var s;if(n){if(i>=r.length)break;s=r[i++]}else{if(i=r.next(),i.done)break;s=i.value}if(e=s.equals("kind","constructor"))break}if(!e){var o=void 0,u=void 0;if(this.isDerived){var l=E().expression;o=l.params,u=l.body}else o=[],u=b.blockStatement([]);this.path.get("body").unshiftContainer("body",b.classMethod("constructor",b.identifier("constructor"),o,u))}},e.prototype.buildBody=function(){if(this.constructorMeMaybe(),this.pushBody(),this.verifyConstructor(),this.userConstructor){var e=this.constructorBody;e.body=e.body.concat(this.userConstructor.body.body),b.inherits(this.constructor,this.userConstructor),b.inherits(e,this.userConstructor.body)}this.pushDescriptors()},e.prototype.pushBody=function(){for(var e=this.path.get("body.body"),t=e,r=Array.isArray(t),n=0,t=r?t:(0,a.default)(t);;){var i;if(r){if(n>=t.length)break;i=t[n++]}else{if(n=t.next(),n.done)break;i=n.value}var s=i,o=s.node;if(s.isClassProperty())throw s.buildCodeFrameError("Missing class properties transform.");if(o.decorators)throw s.buildCodeFrameError("Method has decorators, put the decorator plugin before the classes one.");if(b.isClassMethod(o)){var u="constructor"===o.kind;if(u&&(s.traverse(A,this),!this.hasBareSuper&&this.isDerived))throw s.buildCodeFrameError("missing super() call in constructor");var l=new f.default({forceSuperMemoisation:u,methodPath:s,methodNode:o,objectRef:this.classRef,superRef:this.superName,isStatic:o.static,isLoose:this.isLoose,scope:this.scope,file:this.file},!0);l.replace(),u?this.pushConstructor(l,o,s):this.pushMethod(o,s)}}},e.prototype.clearDescriptors=function(){this.hasInstanceDescriptors=!1,this.hasStaticDescriptors=!1,this.instanceMutatorMap={},this.staticMutatorMap={}},e.prototype.pushDescriptors=function(){this.pushInherits();var e=this.body,t=void 0,r=void 0;if(this.hasInstanceDescriptors&&(t=m.toClassObject(this.instanceMutatorMap)),this.hasStaticDescriptors&&(r=m.toClassObject(this.staticMutatorMap)),t||r){t&&(t=m.toComputedObjectFromClass(t)),r&&(r=m.toComputedObjectFromClass(r));var n=b.nullLiteral(),i=[this.classRef,n,n,n,n];t&&(i[1]=t),r&&(i[2]=r),this.instanceInitializersId&&(i[3]=this.instanceInitializersId,e.unshift(this.buildObjectAssignment(this.instanceInitializersId))),this.staticInitializersId&&(i[4]=this.staticInitializersId,e.unshift(this.buildObjectAssignment(this.staticInitializersId)));for(var s=0,a=0;a<i.length;a++)i[a]!==n&&(s=a);i=i.slice(0,s+1),e.push(b.expressionStatement(b.callExpression(this.file.addHelper("createClass"),i)))}this.clearDescriptors()},e.prototype.buildObjectAssignment=function(e){return b.variableDeclaration("var",[b.variableDeclarator(e,b.objectExpression([]))])},e.prototype.wrapSuperCall=function(e,t,r,n){var i=e.node;this.isLoose?(i.arguments.unshift(b.thisExpression()),2===i.arguments.length&&b.isSpreadElement(i.arguments[1])&&b.isIdentifier(i.arguments[1].argument,{name:"arguments"})?(i.arguments[1]=i.arguments[1].argument,i.callee=b.memberExpression(t,b.identifier("apply"))):i.callee=b.memberExpression(t,b.identifier("call"))):i=(0,d.default)(b.logicalExpression("||",b.memberExpression(this.classRef,b.identifier("__proto__")),b.callExpression(b.memberExpression(b.identifier("Object"),b.identifier("getPrototypeOf")),[this.classRef])),b.thisExpression(),i.arguments);var s=b.callExpression(this.file.addHelper("possibleConstructorReturn"),[b.thisExpression(),i]),a=this.bareSuperAfter.map(function(e){return e(r)});e.parentPath.isExpressionStatement()&&e.parentPath.container===n.node.body&&n.node.body.length-1===e.parentPath.key?((this.superThises.length||a.length)&&(e.scope.push({id:r}),s=b.assignmentExpression("=",r,s)),a.length&&(s=b.toSequenceExpression([s].concat(a,[r]))),e.parentPath.replaceWith(b.returnStatement(s))):e.replaceWithMultiple([b.variableDeclaration("var",[b.variableDeclarator(r,s)])].concat(a,[b.expressionStatement(r)]))},e.prototype.verifyConstructor=function(){var e=this;if(this.isDerived){var t=this.userConstructorPath,r=t.get("body");t.traverse(S,this);for(var n=!!this.bareSupers.length,i=this.superName||b.identifier("Function"),s=t.scope.generateUidIdentifier("this"),o=this.bareSupers,u=Array.isArray(o),l=0,o=u?o:(0,a.default)(o);;){var c;if(u){if(l>=o.length)break;c=o[l++]}else{if(l=o.next(),l.done)break;c=l.value}var f=c;this.wrapSuperCall(f,i,s,r),n&&f.find(function(e){return e===t||(e.isLoop()||e.isConditional()?(n=!1,!0):void 0)})}for(var p=this.superThises,d=Array.isArray(p),h=0,p=d?p:(0,a.default)(p);;){var m;if(d){if(h>=p.length)break;m=p[h++]}else{if(h=p.next(),h.done)break;m=h.value}m.replaceWith(s)}var y=function(t){return b.callExpression(e.file.addHelper("possibleConstructorReturn"),[s].concat(t||[]))},v=r.get("body");v.length&&!v.pop().isReturnStatement()&&r.pushContainer("body",b.returnStatement(n?s:y()));for(var g=this.superReturns,E=Array.isArray(g),x=0,g=E?g:(0,a.default)(g);;){var A;if(E){if(x>=g.length)break;A=g[x++]}else{if(x=g.next(),x.done)break;A=x.value}var _=A;if(_.node.argument){var D=_.scope.generateDeclaredUidIdentifier("ret");_.get("argument").replaceWithMultiple([b.assignmentExpression("=",D,_.node.argument),y(D)])}else _.get("argument").replaceWith(y())}}},e.prototype.pushMethod=function(e,t){var r=t?t.scope:this.scope;"method"===e.kind&&this._processMethod(e,r)||this.pushToMap(e,!1,null,r)},e.prototype._processMethod=function(){return!1},e.prototype.pushConstructor=function(e,t,r){this.bareSupers=e.bareSupers,this.superReturns=e.returns,r.scope.hasOwnBinding(this.classRef.name)&&r.scope.rename(this.classRef.name);var n=this.constructor;this.userConstructorPath=r,this.userConstructor=t,this.hasConstructor=!0,b.inheritsComments(n,t),n._ignoreUserWhitespace=!0,n.params=t.params,b.inherits(n.body,t.body),n.body.directives=t.body.directives,this._pushConstructor()},e.prototype._pushConstructor=function(){this.pushedConstructor||(this.pushedConstructor=!0,(this.hasInstanceDescriptors||this.hasStaticDescriptors)&&this.pushDescriptors(),this.body.push(this.constructor),this.pushInherits())},e.prototype.pushInherits=function(){this.isDerived&&!this.pushedInherits&&(this.pushedInherits=!0,this.body.unshift(b.expressionStatement(b.callExpression(this.file.addHelper("inherits"),[this.classRef,this.superName]))))},e}();t.default=_,e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(9),s=n(i),a=r(2),o=n(a),u=r(10),l=n(u);t.default=function(e){var t=e.types,r=(0,l.default)(),n={"AssignmentExpression|UpdateExpression":function(e){if(!e.node[r]){e.node[r]=!0;var n=e.get(e.isAssignmentExpression()?"left":"argument");if(n.isIdentifier()){var i=n.node.name;if(this.scope.getBinding(i)===e.scope.getBinding(i)){var s=this.exports[i];if(s){var a=e.node,u=e.isUpdateExpression()&&!a.prefix;u&&("++"===a.operator?a=t.binaryExpression("+",a.argument,t.numericLiteral(1)):"--"===a.operator?a=t.binaryExpression("-",a.argument,t.numericLiteral(1)):u=!1);for(var l=s,c=Array.isArray(l),f=0,l=c?l:(0,o.default)(l);;){var p;if(c){if(f>=l.length)break;p=l[f++]}else{if(f=l.next(),f.done)break;p=f.value}var d=p;a=this.buildCall(d,a).expression}u&&(a=t.sequenceExpression([a,e.node])),e.replaceWith(a)}}}}}};return{visitor:{CallExpression:function(e,r){if(e.node.callee.type===y){var n=r.contextIdent;e.replaceWith(t.callExpression(t.memberExpression(n,t.identifier("import")),e.node.arguments))}},ReferencedIdentifier:function(e,r){"__moduleName"!=e.node.name||e.scope.hasBinding("__moduleName")||e.replaceWith(t.memberExpression(r.contextIdent,t.identifier("id")))},Program:{enter:function(e,t){t.contextIdent=e.scope.generateUidIdentifier("context")},exit:function(e,r){function i(e,t){p[e]=p[e]||[],p[e].push(t)}function a(e,t,r){var n=void 0;d.forEach(function(t){t.key===e&&(n=t)}),n||d.push(n={key:e,imports:[],exports:[]}),n[t]=n[t].concat(r)}function u(e,r){return t.expressionStatement(t.callExpression(l,[t.stringLiteral(e),r]))}for(var l=e.scope.generateUidIdentifier("export"),c=r.contextIdent,p=(0,s.default)(null),d=[],y=[],v=[],g=[],b=[],E=[],x=e.get("body"),A=!0,S=x,_=Array.isArray(S),D=0,S=_?S:(0,o.default)(S);;){var C;if(_){if(D>=S.length)break;C=S[D++]}else{if(D=S.next(),D.done)break;C=D.value}var w=C;if(w.isExportDeclaration()&&(w=w.get("declaration")),w.isVariableDeclaration()&&"var"!==w.node.kind){A=!1;break}}for(var P=x,k=Array.isArray(P),F=0,P=k?P:(0,o.default)(P);;){var T;if(k){if(F>=P.length)break;T=P[F++]}else{if(F=P.next(),F.done)break;T=F.value}var O=T;if(A&&O.isFunctionDeclaration())y.push(O.node),E.push(O);else if(O.isImportDeclaration()){var B=O.node.source.value;a(B,"imports",O.node.specifiers);for(var R in O.getBindingIdentifiers())O.scope.removeBinding(R),b.push(t.identifier(R));O.remove()}else if(O.isExportAllDeclaration())a(O.node.source.value,"exports",O.node),O.remove();else if(O.isExportDefaultDeclaration()){var I=O.get("declaration");if(I.isClassDeclaration()||I.isFunctionDeclaration()){var M=I.node.id,N=[];M?(N.push(I.node),N.push(u("default",M)),i(M.name,"default")):N.push(u("default",t.toExpression(I.node))),!A||I.isClassDeclaration()?O.replaceWithMultiple(N):(y=y.concat(N),E.push(O))}else O.replaceWith(u("default",I.node))}else if(O.isExportNamedDeclaration()){var L=O.get("declaration");if(L.node){O.replaceWith(L);var j=[],U=void 0;if(O.isFunction()){var V=L.node,G=V.id.name;if(A)i(G,G),y.push(V),y.push(u(G,V.id)),E.push(O);else{var W;W={},W[G]=V.id,U=W}}else U=L.getBindingIdentifiers();for(var Y in U)i(Y,Y),j.push(u(Y,t.identifier(Y)));O.insertAfter(j)}else{var q=O.node.specifiers;if(q&&q.length)if(O.node.source)a(O.node.source.value,"exports",q),O.remove();else{for(var K=[],H=q,J=Array.isArray(H),X=0,H=J?H:(0,o.default)(H);;){var z;if(J){if(X>=H.length)break;z=H[X++]}else{if(X=H.next(),X.done)break;z=X.value}var $=z;K.push(u($.exported.name,$.local)),i($.local.name,$.exported.name)}O.replaceWithMultiple(K)}}}}d.forEach(function(r){for(var n=[],i=e.scope.generateUidIdentifier(r.key),s=r.imports,a=Array.isArray(s),u=0,s=a?s:(0,o.default)(s);;){var c;if(a){if(u>=s.length)break;c=s[u++]}else{if(u=s.next(),u.done)break;c=u.value}var f=c;t.isImportNamespaceSpecifier(f)?n.push(t.expressionStatement(t.assignmentExpression("=",f.local,i))):t.isImportDefaultSpecifier(f)&&(f=t.importSpecifier(f.local,t.identifier("default"))),t.isImportSpecifier(f)&&n.push(t.expressionStatement(t.assignmentExpression("=",f.local,t.memberExpression(i,f.imported))))}if(r.exports.length){var p=e.scope.generateUidIdentifier("exportObj");n.push(t.variableDeclaration("var",[t.variableDeclarator(p,t.objectExpression([]))]));for(var d=r.exports,h=Array.isArray(d),y=0,d=h?d:(0,o.default)(d);;){var b;if(h){if(y>=d.length)break;b=d[y++]}else{if(y=d.next(),y.done)break;b=y.value}var E=b;t.isExportAllDeclaration(E)?n.push(m({KEY:e.scope.generateUidIdentifier("key"),EXPORT_OBJ:p,TARGET:i})):t.isExportSpecifier(E)&&n.push(t.expressionStatement(t.assignmentExpression("=",t.memberExpression(p,E.exported),t.memberExpression(i,E.local))))}n.push(t.expressionStatement(t.callExpression(l,[p])))}g.push(t.stringLiteral(r.key)),v.push(t.functionExpression(null,[i],t.blockStatement(n)))});var Q=this.getModuleName();Q&&(Q=t.stringLiteral(Q)),A&&(0,f.default)(e,function(e){return b.push(e)}),b.length&&y.unshift(t.variableDeclaration("var",b.map(function(e){return t.variableDeclarator(e)}))),e.traverse(n,{exports:p,buildCall:u,scope:e.scope});for(var Z=E,ee=Array.isArray(Z),te=0,Z=ee?Z:(0,o.default)(Z);;){var re;if(ee){if(te>=Z.length)break;re=Z[te++]}else{if(te=Z.next(),te.done)break;re=te.value}re.remove()}e.node.body=[h({SYSTEM_REGISTER:t.memberExpression(t.identifier(r.opts.systemGlobal||"System"),t.identifier("register")),BEFORE_BODY:y,MODULE_NAME:Q,SETTERS:v,SOURCES:g,BODY:e.node.body,EXPORT_IDENTIFIER:l,CONTEXT_IDENTIFIER:c})]}}}}};var c=r(190),f=n(c),p=r(4),d=n(p),h=(0,d.default)('\n SYSTEM_REGISTER(MODULE_NAME, [SOURCES], function (EXPORT_IDENTIFIER, CONTEXT_IDENTIFIER) {\n "use strict";\n BEFORE_BODY;\n return {\n setters: [SETTERS],\n execute: function () {\n BODY;\n }\n };\n });\n'),m=(0,d.default)('\n for (var KEY in TARGET) {\n if (KEY !== "default" && KEY !== "__esModule") EXPORT_OBJ[KEY] = TARGET[KEY];\n }\n'),y="Import";e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(e){function t(e){if(e.isExpressionStatement()){var t=e.get("expression");if(!t.isCallExpression())return!1;if(!t.get("callee").isIdentifier({name:"define"}))return!1;var r=t.get("arguments");return!(3===r.length&&!r.shift().isStringLiteral())&&(2===r.length&&(!!r.shift().isArrayExpression()&&!!r.shift().isFunctionExpression()))}}var i=e.types;return{inherits:r(131),visitor:{Program:{exit:function(e,r){var s=e.get("body").pop();if(t(s)){var l=s.node.expression,c=l.arguments,f=3===c.length?c.shift():null,p=l.arguments[0],d=l.arguments[1],h=r.opts.globals||{},m=p.elements.map(function(e){return"module"===e.value||"exports"===e.value?i.identifier(e.value):i.callExpression(i.identifier("require"),[e])}),y=p.elements.map(function(e){if("module"===e.value)return i.identifier("mod");if("exports"===e.value)return i.memberExpression(i.identifier("mod"),i.identifier("exports"));var t=void 0;if(r.opts.exactGlobals){var s=h[e.value];t=s?s.split(".").reduce(function(e,t){return i.memberExpression(e,i.identifier(t))},i.identifier("global")):i.memberExpression(i.identifier("global"),i.identifier(i.toIdentifier(e.value)))}else{var a=(0,n.basename)(e.value,(0,n.extname)(e.value)),o=h[a]||a;t=i.memberExpression(i.identifier("global"),i.identifier(i.toIdentifier(o)))}return t}),v=f?f.value:this.file.opts.basename,g=i.memberExpression(i.identifier("global"),i.identifier(i.toIdentifier(v))),b=null;if(r.opts.exactGlobals){var E=h[v];if(E){b=[];var x=E.split(".");g=x.slice(1).reduce(function(e,t){return b.push(a({GLOBAL_REFERENCE:e})),i.memberExpression(e,i.identifier(t))},i.memberExpression(i.identifier("global"),i.identifier(x[0])))}}var A=o({BROWSER_ARGUMENTS:y,PREREQUISITE_ASSIGNMENTS:b,GLOBAL_TO_ASSIGN:g});s.replaceWith(u({MODULE_NAME:f,AMD_ARGUMENTS:p,COMMON_ARGUMENTS:m,GLOBAL_EXPORT:A,FUNC:d}))}}}}}};var n=r(19),i=r(4),s=function(e){return e&&e.__esModule?e:{default:e}}(i),a=(0,s.default)("\n GLOBAL_REFERENCE = GLOBAL_REFERENCE || {}\n"),o=(0,s.default)("\n var mod = { exports: {} };\n factory(BROWSER_ARGUMENTS);\n PREREQUISITE_ASSIGNMENTS\n GLOBAL_TO_ASSIGN = mod.exports;\n"),u=(0,s.default)('\n (function (global, factory) {\n if (typeof define === "function" && define.amd) {\n define(MODULE_NAME, AMD_ARGUMENTS, factory);\n } else if (typeof exports !== "undefined") {\n factory(COMMON_ARGUMENTS);\n } else {\n GLOBAL_EXPORT\n }\n })(this, FUNC);\n');e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(e){function t(e,r,i){var s=e.specifiers[0];if(n.isExportNamespaceSpecifier(s)||n.isExportDefaultSpecifier(s)){var a=e.specifiers.shift(),o=i.generateUidIdentifier(a.exported.name),u=void 0;u=n.isExportNamespaceSpecifier(a)?n.importNamespaceSpecifier(o):n.importDefaultSpecifier(o),r.push(n.importDeclaration([u],e.source)),r.push(n.exportNamedDeclaration(null,[n.exportSpecifier(o,a.exported)])),t(e,r,i)}}var n=e.types;return{inherits:r(200),visitor:{ExportNamedDeclaration:function(e){var r=e.node,n=e.scope,i=[];t(r,i,n),i.length&&(r.specifiers.length>=1&&i.push(r),e.replaceWithMultiple(i))}}}},e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0;var n=r(2),i=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=function(e){var t=e.types;return{inherits:r(126),visitor:{Program:function(e,t){for(var r=t.file.ast.comments,n=r,s=Array.isArray(n),a=0,n=s?n:(0,i.default)(n);;){var o;if(s){if(a>=n.length)break;o=n[a++]}else{if(a=n.next(),a.done)break;o=a.value}var u=o;u.value.indexOf("@flow")>=0&&(u.value=u.value.replace("@flow",""),u.value.replace(/\*/g,"").trim()||(u.ignore=!0))}},Flow:function(e){e.remove()},ClassProperty:function(e){e.node.variance=null,e.node.typeAnnotation=null,e.node.value||e.remove()},Class:function(e){e.node.implements=null,e.get("body.body").forEach(function(e){e.isClassProperty()&&(e.node.typeAnnotation=null,e.node.value||e.remove())})},AssignmentPattern:function(e){e.node.left.optional=!1},Function:function(e){for(var t=e.node,r=0;r<t.params.length;r++){t.params[r].optional=!1}},TypeCastExpression:function(e){var r=e.node;do{r=r.expression}while(t.isTypeCastExpression(r));e.replaceWith(r)}}}},e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(e){function t(e){var t=e.path.getData("functionBind");return t||(t=e.generateDeclaredUidIdentifier("context"),e.path.setData("functionBind",t))}function n(e,t){var r=e.object||e.callee.object;return t.isStatic(r)&&r}function i(e,r){var i=n(e,r);if(i)return i;var a=t(r);return e.object?e.callee=s.sequenceExpression([s.assignmentExpression("=",a,e.object),e.callee]):e.callee.object=s.assignmentExpression("=",a,e.callee.object),a}var s=e.types;return{inherits:r(201),visitor:{CallExpression:function(e){var t=e.node,r=e.scope,n=t.callee;if(s.isBindExpression(n)){var a=i(n,r);t.callee=s.memberExpression(n.callee,s.identifier("call")),t.arguments.unshift(a)}},BindExpression:function(e){ +var t=e.node,r=e.scope,n=i(t,r);e.replaceWith(s.callExpression(s.memberExpression(t.callee,s.identifier("bind")),[n]))}}}},e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0;var n=r(2),i=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=function(e){function t(e){var t=!1;return e.traverse({RestProperty:function(){t=!0,e.stop()}}),t}function n(e){for(var t=e.properties,r=Array.isArray(t),n=0,t=r?t:(0,i.default)(t);;){var s;if(r){if(n>=t.length)break;s=t[n++]}else{if(n=t.next(),n.done)break;s=n.value}var a=s;if(o.isSpreadProperty(a))return!0}return!1}function s(e,t,r){for(var n=t.pop(),s=[],a=t,u=Array.isArray(a),l=0,a=u?a:(0,i.default)(a);;){var c;if(u){if(l>=a.length)break;c=a[l++]}else{if(l=a.next(),l.done)break;c=l.value}var f=c,p=f.key;o.isIdentifier(p)&&!f.computed&&(p=o.stringLiteral(f.key.name)),s.push(p)}return[n.argument,o.callExpression(e.addHelper("objectWithoutProperties"),[r,o.arrayExpression(s)])]}function a(e,r,n,i){if(r.isAssignmentPattern())return void a(e,r.get("left"),n,i);if(r.isObjectPattern()&&t(r)){var s=e.scope.generateUidIdentifier("ref"),u=o.variableDeclaration("let",[o.variableDeclarator(r.node,s)]);u._blockHoist=n?i-n:1,e.ensureBlock(),e.get("body").unshiftContainer("body",u),r.replaceWith(s)}}var o=e.types;return{inherits:r(202),visitor:{Function:function(e){for(var t=e.get("params"),r=0;r<t.length;r++)a(t[r].parentPath,t[r],r,t.length)},VariableDeclarator:function(e,t){if(e.get("id").isObjectPattern()){var r=e;e.get("id").traverse({RestProperty:function(e){if(this.originalPath.node.id.properties.length>1&&!o.isIdentifier(this.originalPath.node.init)){var n=e.scope.generateUidIdentifierBasedOnNode(this.originalPath.node.init,"ref");return this.originalPath.insertBefore(o.variableDeclarator(n,this.originalPath.node.init)),void this.originalPath.replaceWith(o.variableDeclarator(this.originalPath.node.id,n))}var i=this.originalPath.node.init,a=[];e.findParent(function(e){if(e.isObjectProperty())a.unshift(e.node.key.name);else if(e.isVariableDeclarator())return!0}),a.length&&a.forEach(function(e){i=o.memberExpression(i,o.identifier(e))});var u=s(t,e.parentPath.node.properties,i),l=u[0],c=u[1];r.insertAfter(o.variableDeclarator(l,c)),r=r.getSibling(r.key+1),0===e.parentPath.node.properties.length&&e.findParent(function(e){return e.isObjectProperty()||e.isVariableDeclarator()}).remove()}},{originalPath:e})}},ExportNamedDeclaration:function(e){var r=e.get("declaration");if(r.isVariableDeclaration()&&t(r)){var n=[];for(var i in e.getOuterBindingIdentifiers(e)){var s=o.identifier(i);n.push(o.exportSpecifier(s,s))}e.replaceWith(r.node),e.insertAfter(o.exportNamedDeclaration(null,n))}},CatchClause:function(e){var t=e.get("param");a(t.parentPath,t)},AssignmentExpression:function(e,r){var n=e.get("left");if(n.isObjectPattern()&&t(n)){var i=[],a=void 0;(e.isCompletionRecord()||e.parentPath.isExpressionStatement())&&(a=e.scope.generateUidIdentifierBasedOnNode(e.node.right,"ref"),i.push(o.variableDeclaration("var",[o.variableDeclarator(a,e.node.right)])));var u=s(r,e.node.left.properties,a),l=u[0],c=u[1],f=o.clone(e.node);f.right=a,i.push(o.expressionStatement(f)),i.push(o.toStatement(o.assignmentExpression("=",l,c))),a&&i.push(o.expressionStatement(a)),e.replaceWithMultiple(i)}},ForXStatement:function(e){var r=e.node,n=e.scope,i=e.get("left"),s=r.left;if(o.isObjectPattern(s)&&t(i)){var a=n.generateUidIdentifier("ref");return r.left=o.variableDeclaration("var",[o.variableDeclarator(a)]),e.ensureBlock(),void r.body.body.unshift(o.variableDeclaration("var",[o.variableDeclarator(s,a)]))}if(o.isVariableDeclaration(s)){var u=s.declarations[0].id;if(o.isObjectPattern(u)){var l=n.generateUidIdentifier("ref");r.left=o.variableDeclaration(s.kind,[o.variableDeclarator(l,null)]),e.ensureBlock(),r.body.body.unshift(o.variableDeclaration(r.left.kind,[o.variableDeclarator(u,l)]))}}},ObjectExpression:function(e,t){function r(){u.length&&(a.push(o.objectExpression(u)),u=[])}if(n(e.node)){var s=t.opts.useBuiltIns||!1;if("boolean"!=typeof s)throw new Error("transform-object-rest-spread currently only accepts a boolean option for useBuiltIns (defaults to false)");for(var a=[],u=[],l=e.node.properties,c=Array.isArray(l),f=0,l=c?l:(0,i.default)(l);;){var p;if(c){if(f>=l.length)break;p=l[f++]}else{if(f=l.next(),f.done)break;p=f.value}var d=p;o.isSpreadProperty(d)?(r(),a.push(d.argument)):u.push(d)}r(),o.isObjectExpression(a[0])||a.unshift(o.objectExpression([]));var h=s?o.memberExpression(o.identifier("Object"),o.identifier("assign")):t.addHelper("extends");e.replaceWith(o.callExpression(h,a))}}}}},e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(e){function t(e,t){for(var r=t.arguments[0].properties,i=!0,s=0;s<r.length;s++){var a=r[s],o=n.toComputedKey(a);if(n.isLiteral(o,{value:"displayName"})){i=!1;break}}i&&r.unshift(n.objectProperty(n.identifier("displayName"),n.stringLiteral(e)))}function r(e){if(!e||!n.isCallExpression(e))return!1;if(!s(e.callee)&&!a(e.callee))return!1;var t=e.arguments;if(1!==t.length)return!1;var r=t[0];return!!n.isObjectExpression(r)}var n=e.types,s=n.buildMatchMemberExpression("React.createClass"),a=function(e){return"createReactClass"===e.name};return{visitor:{ExportDefaultDeclaration:function(e,n){var s=e.node;if(r(s.declaration)){var a=n.file.opts.basename;"index"===a&&(a=i.default.basename(i.default.dirname(n.file.opts.filename))),t(a,s.declaration)}},CallExpression:function(e){var i=e.node;if(r(i)){var s=void 0;e.find(function(e){if(e.isAssignmentExpression())s=e.node.left;else if(e.isObjectProperty())s=e.node.key;else if(e.isVariableDeclarator())s=e.node.id;else if(e.isStatement())return!0;if(s)return!0}),s&&(n.isMemberExpression(s)&&(s=s.property),n.isIdentifier(s)&&t(s.name,i))}}}}};var n=r(19),i=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(2),s=n(i);t.default=function(e){var t=e.types,r=/\*?\s*@jsx\s+([^\s]+)/,n=(0,l.default)({pre:function(e){var r=e.tagName,n=e.args;t.react.isCompatTag(r)?n.push(t.stringLiteral(r)):n.push(e.tagExpr)},post:function(e,t){e.callee=t.get("jsxIdentifier")()}});return n.Program=function(e,n){for(var i=n.file,a=n.opts.pragma||"React.createElement",o=i.ast.comments,u=Array.isArray(o),l=0,o=u?o:(0,s.default)(o);;){var c;if(u){if(l>=o.length)break;c=o[l++]}else{if(l=o.next(),l.done)break;c=l.value}var f=c,p=r.exec(f.value);if(p){if("React.DOM"===(a=p[1]))throw i.buildCodeFrameError(f,"The @jsx React.DOM pragma has been deprecated as of React 0.12");break}}n.set("jsxIdentifier",function(){return a.split(".").map(function(e){return t.identifier(e)}).reduce(function(e,r){return t.memberExpression(e,r)})})},{inherits:o.default,visitor:n}};var a=r(127),o=n(a),u=r(351),l=n(u);e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0;var n=r(2),i=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=function(){return{visitor:{Program:function(e,t){if(!1!==t.opts.strict&&!1!==t.opts.strictMode){for(var r=e.node,n=r.directives,s=Array.isArray(n),o=0,n=s?n:(0,i.default)(n);;){var u;if(s){if(o>=n.length)break;u=n[o++]}else{if(o=n.next(),o.done)break;u=o.value}if("use strict"===u.value.value)return}e.unshiftContainer("directives",a.directive(a.directiveLiteral("use strict")))}}}}};var s=r(1),a=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(s);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=["commonjs","amd","umd","systemjs"],n=!1,i="commonjs",s=!1;if(void 0!==t&&(void 0!==t.loose&&(n=t.loose),void 0!==t.modules&&(i=t.modules),void 0!==t.spec&&(s=t.spec)),"boolean"!=typeof n)throw new Error("Preset es2015 'loose' option must be a boolean.");if("boolean"!=typeof s)throw new Error("Preset es2015 'spec' option must be a boolean.");if(!1!==i&&-1===r.indexOf(i))throw new Error("Preset es2015 'modules' option must be 'false' to indicate no modules\nor a module type which be be one of: 'commonjs' (default), 'amd', 'umd', 'systemjs'");var o={loose:n};return{plugins:[[a.default,{loose:n,spec:s}],u.default,c.default,[p.default,{spec:s}],h.default,[y.default,o],g.default,E.default,A.default,[_.default,o],[C.default,o],P.default,F.default,O.default,[R.default,o],M.default,[L.default,o],U.default,G.default,"commonjs"===i&&[Y.default,o],"systemjs"===i&&[K.default,o],"amd"===i&&[J.default,o],"umd"===i&&[z.default,o],[Q.default,{async:!1,asyncGenerators:!1}]].filter(Boolean)}}t.__esModule=!0;var s=r(83),a=n(s),o=r(76),u=n(o),l=r(75),c=n(l),f=r(68),p=n(f),d=r(69),h=n(d),m=r(71),y=n(m),v=r(78),g=n(v),b=r(80),E=n(b),x=r(130),A=n(x),S=r(72),_=n(S),D=r(74),C=n(D),w=r(82),P=n(w),k=r(85),F=n(k),T=r(66),O=n(T),B=r(81),R=n(B),I=r(79),M=n(I),N=r(73),L=n(N),j=r(70),U=n(j),V=r(84),G=n(V),W=r(77),Y=n(W),q=r(208),K=n(q),H=r(131),J=n(H),X=r(209),z=n(X),$=r(86),Q=n($),Z=i({});t.default=Z,Object.defineProperty(Z,"buildPreset",{configurable:!0,writable:!0,enumerable:!1,value:i}),e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0;var n=r(132),i=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default={plugins:[i.default]},e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(128),s=n(i),a=r(129),o=n(a);t.default={plugins:[s.default,o.default]},e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(221),s=n(i),a=r(203),o=n(a),u=r(210),l=n(u);t.default={presets:[s.default],plugins:[o.default,l.default]},e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(222),s=n(i),a=r(204),o=n(a),u=r(205),l=n(u),c=r(324),f=n(c);t.default={presets:[s.default],plugins:[f.default,o.default,l.default]},e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(128),s=n(i),a=r(129),o=n(a),u=r(132),l=n(u),c=r(213),f=n(c),p=r(327),d=n(p);t.default={plugins:[s.default,o.default,l.default,d.default,f.default]},e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0;var n=r(3),i=function(e){return e&&e.__esModule?e:{default:e}}(n),s=function e(t,r){(0,i.default)(this,e),this.file=t,this.options=r};t.default=s,e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.Flow=t.Pure=t.Generated=t.User=t.Var=t.BlockScoped=t.Referenced=t.Scope=t.Expression=t.Statement=t.BindingIdentifier=t.ReferencedMemberExpression=t.ReferencedIdentifier=void 0;var n=r(1),i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(n);t.ReferencedIdentifier={types:["Identifier","JSXIdentifier"],checkPath:function(e,t){var r=e.node,s=e.parent;if(!i.isIdentifier(r,t)&&!i.isJSXMemberExpression(s,t)){if(!i.isJSXIdentifier(r,t))return!1;if(n.react.isCompatTag(r.name))return!1}return i.isReferenced(r,s)}},t.ReferencedMemberExpression={types:["MemberExpression"],checkPath:function(e){var t=e.node,r=e.parent;return i.isMemberExpression(t)&&i.isReferenced(t,r)}},t.BindingIdentifier={types:["Identifier"],checkPath:function(e){var t=e.node,r=e.parent;return i.isIdentifier(t)&&i.isBinding(t,r)}},t.Statement={types:["Statement"],checkPath:function(e){var t=e.node,r=e.parent;if(i.isStatement(t)){if(i.isVariableDeclaration(t)){if(i.isForXStatement(r,{left:t}))return!1;if(i.isForStatement(r,{init:t}))return!1}return!0}return!1}},t.Expression={types:["Expression"],checkPath:function(e){return e.isIdentifier()?e.isReferencedIdentifier():i.isExpression(e.node)}},t.Scope={types:["Scopable"],checkPath:function(e){return i.isScope(e.node,e.parent)}},t.Referenced={checkPath:function(e){return i.isReferenced(e.node,e.parent)}},t.BlockScoped={checkPath:function(e){return i.isBlockScoped(e.node)}},t.Var={types:["VariableDeclaration"],checkPath:function(e){return i.isVar(e.node)}},t.User={checkPath:function(e){return e.node&&!!e.node.loc}},t.Generated={checkPath:function(e){return!e.isUser()}},t.Pure={checkPath:function(e,t){return e.scope.isPure(e.node,t)}},t.Flow={types:["Flow","ImportDeclaration","ExportDeclaration","ImportSpecifier"],checkPath:function(e){var t=e.node;return!!i.isFlow(t)||(i.isImportDeclaration(t)?"type"===t.importKind||"typeof"===t.importKind:i.isExportDeclaration(t)?"type"===t.exportKind:!!i.isImportSpecifier(t)&&("type"===t.importKind||"typeof"===t.importKind))}}},function(e,t,r){"use strict";t.__esModule=!0;var n=r(3),i=function(e){return e&&e.__esModule?e:{default:e}}(n),s=function(){function e(t){var r=t.existing,n=t.identifier,s=t.scope,a=t.path,o=t.kind;(0,i.default)(this,e),this.identifier=n,this.scope=s,this.path=a,this.kind=o,this.constantViolations=[],this.constant=!0,this.referencePaths=[],this.referenced=!1,this.references=0,this.clearValue(),r&&(this.constantViolations=[].concat(r.path,r.constantViolations,this.constantViolations))}return e.prototype.deoptValue=function(){this.clearValue(),this.hasDeoptedValue=!0},e.prototype.setValue=function(e){this.hasDeoptedValue||(this.hasValue=!0,this.value=e)},e.prototype.clearValue=function(){this.hasDeoptedValue=!1,this.hasValue=!1,this.value=null},e.prototype.reassign=function(e){this.constant=!1,-1===this.constantViolations.indexOf(e)&&this.constantViolations.push(e)},e.prototype.reference=function(e){-1===this.referencePaths.indexOf(e)&&(this.referenced=!0,this.references++,this.referencePaths.push(e))},e.prototype.dereference=function(){this.references--,this.referenced=!!this.references},e}();t.default=s,e.exports=t.default},function(e,t,r){"use strict";function n(e,t,r){for(var n=[].concat(e),i=(0,a.default)(null);n.length;){var s=n.shift();if(s){var o=u.getBindingIdentifiers.keys[s.type];if(u.isIdentifier(s))if(t){var l=i[s.name]=i[s.name]||[];l.push(s)}else i[s.name]=s;else if(u.isExportDeclaration(s))u.isDeclaration(s.declaration)&&n.push(s.declaration);else{if(r){if(u.isFunctionDeclaration(s)){n.push(s.id);continue}if(u.isFunctionExpression(s))continue}if(o)for(var c=0;c<o.length;c++){var f=o[c];s[f]&&(n=n.concat(s[f]))}}}}return i}function i(e,t){return n(e,t,!0)}t.__esModule=!0;var s=r(9),a=function(e){return e&&e.__esModule?e:{default:e}}(s);t.getBindingIdentifiers=n,t.getOuterBindingIdentifiers=i;var o=r(1),u=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(o);n.keys={DeclareClass:["id"],DeclareFunction:["id"],DeclareModule:["id"],DeclareVariable:["id"],InterfaceDeclaration:["id"],TypeAlias:["id"],OpaqueType:["id"],CatchClause:["param"],LabeledStatement:["label"],UnaryExpression:["argument"],AssignmentExpression:["left"],ImportSpecifier:["local"],ImportNamespaceSpecifier:["local"],ImportDefaultSpecifier:["local"],ImportDeclaration:["specifiers"],ExportSpecifier:["exported"],ExportNamespaceSpecifier:["exported"],ExportDefaultSpecifier:["exported"],FunctionDeclaration:["id","params"],FunctionExpression:["id","params"],ClassDeclaration:["id"],ClassExpression:["id"],RestElement:["argument"],UpdateExpression:["argument"],RestProperty:["argument"],ObjectProperty:["value"],AssignmentPattern:["left"],ArrayPattern:["elements"],ObjectPattern:["properties"],VariableDeclaration:["declarations"],VariableDeclarator:["id"]}},function(e,t){"use strict";e.exports=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}},function(e,t,r){"use strict";var n=r(138),i=r(13)("toStringTag"),s="Arguments"==n(function(){return arguments}()),a=function(e,t){try{return e[t]}catch(e){}};e.exports=function(e){var t,r,o;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=a(t=Object(e),i))?r:s?n(t):"Object"==(o=n(t))&&"function"==typeof t.callee?"Arguments":o}},function(e,t,r){"use strict";var n=r(146),i=r(57).getWeak,s=r(21),a=r(16),o=r(136),u=r(55),l=r(137),c=r(28),f=r(58),p=l(5),d=l(6),h=0,m=function(e){return e._l||(e._l=new y)},y=function(){this.a=[]},v=function(e,t){return p(e.a,function(e){return e[0]===t})};y.prototype={get:function(e){var t=v(this,e);if(t)return t[1]},has:function(e){return!!v(this,e)},set:function(e,t){var r=v(this,e);r?r[1]=t:this.a.push([e,t])},delete:function(e){var t=d(this.a,function(t){return t[0]===e});return~t&&this.a.splice(t,1),!!~t}},e.exports={getConstructor:function(e,t,r,s){var l=e(function(e,n){o(e,l,t,"_i"),e._t=t,e._i=h++,e._l=void 0,void 0!=n&&u(n,r,e[s],e)});return n(l.prototype,{delete:function(e){if(!a(e))return!1;var r=i(e);return!0===r?m(f(this,t)).delete(e):r&&c(r,this._i)&&delete r[this._i]},has:function(e){if(!a(e))return!1;var r=i(e);return!0===r?m(f(this,t)).has(e):r&&c(r,this._i)}}),l},def:function(e,t,r){var n=i(s(t),!0);return!0===n?m(e).set(t,r):n[e._i]=r,e},ufstore:m}},function(e,t,r){"use strict";var n=r(16),i=r(15).document,s=n(i)&&n(i.createElement);e.exports=function(e){return s?i.createElement(e):{}}},function(e,t,r){"use strict";e.exports=!r(22)&&!r(27)(function(){return 7!=Object.defineProperty(r(230)("div"),"a",{get:function(){return 7}}).a})},function(e,t,r){"use strict";var n=r(138);e.exports=Array.isArray||function(e){return"Array"==n(e)}},function(e,t){"use strict";e.exports=function(e,t){return{value:t,done:!!e}}},function(e,t,r){"use strict";var n=r(44),i=r(145),s=r(91),a=r(94),o=r(142),u=Object.assign;e.exports=!u||r(27)(function(){var e={},t={},r=Symbol(),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach(function(e){t[e]=e}),7!=u({},e)[r]||Object.keys(u({},t)).join("")!=n})?function(e,t){for(var r=a(e),u=arguments.length,l=1,c=i.f,f=s.f;u>l;)for(var p,d=o(arguments[l++]),h=c?n(d).concat(c(d)):n(d),m=h.length,y=0;m>y;)f.call(d,p=h[y++])&&(r[p]=d[p]);return r}:u},function(e,t,r){"use strict";var n=r(91),i=r(92),s=r(37),a=r(154),o=r(28),u=r(231),l=Object.getOwnPropertyDescriptor;t.f=r(22)?l:function(e,t){if(e=s(e),t=a(t,!0),u)try{return l(e,t)}catch(e){}if(o(e,t))return i(!n.f.call(e,t),e[t])}},function(e,t,r){"use strict";var n=r(237),i=r(141).concat("length","prototype");t.f=Object.getOwnPropertyNames||function(e){return n(e,i)}},function(e,t,r){"use strict";var n=r(28),i=r(37),s=r(420)(!1),a=r(150)("IE_PROTO");e.exports=function(e,t){var r,o=i(e),u=0,l=[];for(r in o)r!=a&&n(o,r)&&l.push(r);for(;t.length>u;)n(o,r=t[u++])&&(~s(l,r)||l.push(r));return l}},function(e,t,r){"use strict";var n=r(228),i=r(13)("iterator"),s=r(56);e.exports=r(5).getIteratorMethod=function(e){if(void 0!=e)return e[i]||e["@@iterator"]||s[n(e)]}},function(e,t,r){(function(n){"use strict";function i(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function s(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),r){var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var i=0,s=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(i++,"%c"===e&&(s=i))}),e.splice(s,0,n)}}function a(){return"object"===("undefined"==typeof console?"undefined":l(console))&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function o(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}}function u(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG),e}var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t=e.exports=r(458),t.log=a,t.formatArgs=s,t.save=o,t.load=u,t.useColors=i,t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(u())}).call(t,r(8))},function(e,t){"use strict";!function(){function t(e){return 48<=e&&e<=57}function r(e){return 48<=e&&e<=57||97<=e&&e<=102||65<=e&&e<=70}function n(e){return e>=48&&e<=55}function i(e){return 32===e||9===e||11===e||12===e||160===e||e>=5760&&d.indexOf(e)>=0}function s(e){return 10===e||13===e||8232===e||8233===e}function a(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(Math.floor((e-65536)/1024)+55296)+String.fromCharCode((e-65536)%1024+56320)}function o(e){return e<128?h[e]:p.NonAsciiIdentifierStart.test(a(e))}function u(e){return e<128?m[e]:p.NonAsciiIdentifierPart.test(a(e))}function l(e){return e<128?h[e]:f.NonAsciiIdentifierStart.test(a(e))}function c(e){return e<128?m[e]:f.NonAsciiIdentifierPart.test(a(e))}var f,p,d,h,m,y;for(p={NonAsciiIdentifierStart:/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,NonAsciiIdentifierPart:/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/},f={ +NonAsciiIdentifierStart:/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDE00-\uDE11\uDE13-\uDE2B\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDE00-\uDE2F\uDE44\uDE80-\uDEAA]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]/,NonAsciiIdentifierPart:/[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDD0-\uDDDA\uDE00-\uDE11\uDE13-\uDE37\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF01-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/},d=[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279],h=new Array(128),y=0;y<128;++y)h[y]=y>=97&&y<=122||y>=65&&y<=90||36===y||95===y;for(m=new Array(128),y=0;y<128;++y)m[y]=y>=97&&y<=122||y>=65&&y<=90||y>=48&&y<=57||36===y||95===y;e.exports={isDecimalDigit:t,isHexDigit:r,isOctalDigit:n,isWhiteSpace:i,isLineTerminator:s,isIdentifierStartES5:o,isIdentifierPartES5:u,isIdentifierStartES6:l,isIdentifierPartES6:c}}()},function(e,t,r){"use strict";var n=r(38),i=r(17),s=n(i,"Set");e.exports=s},function(e,t,r){"use strict";function n(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new i;++t<r;)this.add(e[t])}var i=r(160),s=r(561),a=r(562);n.prototype.add=n.prototype.push=s,n.prototype.has=a,e.exports=n},function(e,t,r){"use strict";var n=r(17),i=n.Uint8Array;e.exports=i},function(e,t){"use strict";function r(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}e.exports=r},function(e,t,r){"use strict";function n(e,t){var r=a(e),n=!r&&s(e),c=!r&&!n&&o(e),p=!r&&!n&&!c&&l(e),d=r||n||c||p,h=d?i(e.length,String):[],m=h.length;for(var y in e)!t&&!f.call(e,y)||d&&("length"==y||c&&("offset"==y||"parent"==y)||p&&("buffer"==y||"byteLength"==y||"byteOffset"==y)||u(y,m))||h.push(y);return h}var i=r(513),s=r(112),a=r(6),o=r(113),u=r(171),l=r(177),c=Object.prototype,f=c.hasOwnProperty;e.exports=n},function(e,t){"use strict";function r(e,t,r,n){var i=-1,s=null==e?0:e.length;for(n&&s&&(r=e[++i]);++i<s;)r=t(r,e[i],i,e);return r}e.exports=r},function(e,t,r){"use strict";function n(e,t,r){(void 0===r||s(e[t],r))&&(void 0!==r||t in e)||i(e,t,r)}var i=r(163),s=r(46);e.exports=n},function(e,t,r){"use strict";var n=r(527),i=n();e.exports=i},function(e,t,r){"use strict";function n(e,t){t=i(t,e);for(var r=0,n=t.length;null!=e&&r<n;)e=e[s(t[r++])];return r&&r==n?e:void 0}var i=r(255),s=r(108);e.exports=n},function(e,t,r){"use strict";function n(e,t,r){var n=t(e);return s(e)?n:i(n,r(e))}var i=r(161),s=r(6);e.exports=n},function(e,t,r){"use strict";function n(e,t,r,a,o){return e===t||(null==e||null==t||!s(e)&&!s(t)?e!==e&&t!==t:i(e,t,r,a,n,o))}var i=r(494),s=r(25);e.exports=n},function(e,t,r){"use strict";function n(e,t){var r=-1,n=s(e)?Array(e.length):[];return i(e,function(e,i,s){n[++r]=t(e,i,s)}),n}var i=r(487),s=r(24);e.exports=n},function(e,t,r){"use strict";function n(e){if("string"==typeof e)return e;if(a(e))return s(e,n)+"";if(o(e))return c?c.call(e):"";var t=e+"";return"0"==t&&1/e==-u?"-0":t}var i=r(45),s=r(60),a=r(6),o=r(62),u=1/0,l=i?i.prototype:void 0,c=l?l.toString:void 0;e.exports=n},function(e,t){"use strict";function r(e,t){return e.has(t)}e.exports=r},function(e,t,r){"use strict";function n(e,t){return i(e)?e:s(e,t)?[e]:a(o(e))}var i=r(6),s=r(173),a=r(571),o=r(114);e.exports=n},function(e,t,r){(function(e){"use strict";function n(e,t){if(t)return e.slice();var r=e.length,n=c?c(r):new e.constructor(r);return e.copy(n),n}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s=r(17),a="object"==i(t)&&t&&!t.nodeType&&t,o=a&&"object"==i(e)&&e&&!e.nodeType&&e,u=o&&o.exports===a,l=u?s.Buffer:void 0,c=l?l.allocUnsafe:void 0;e.exports=n}).call(t,r(39)(e))},function(e,t,r){"use strict";function n(e,t){var r=t?i(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}var i=r(167);e.exports=n},function(e,t,r){"use strict";function n(e){return function(t,r,n){var o=Object(t);if(!s(t)){var u=i(r,3);t=a(t),r=function(e){return u(o[e],e,o)}}var l=e(t,r,n);return l>-1?o[u?t[l]:l]:void 0}}var i=r(61),s=r(24),a=r(32);e.exports=n},function(e,t,r){"use strict";var n=r(38),i=function(){try{var e=n(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();e.exports=i},function(e,t,r){"use strict";function n(e,t,r,n,l,c){var f=r&o,p=e.length,d=t.length;if(p!=d&&!(f&&d>p))return!1;var h=c.get(e);if(h&&c.get(t))return h==t;var m=-1,y=!0,v=r&u?new i:void 0;for(c.set(e,t),c.set(t,e);++m<p;){var g=e[m],b=t[m];if(n)var E=f?n(b,g,m,t,e,c):n(g,b,m,e,t,c);if(void 0!==E){if(E)continue;y=!1;break}if(v){if(!s(t,function(e,t){if(!a(v,t)&&(g===e||l(g,e,r,n,c)))return v.push(t)})){y=!1;break}}else if(g!==b&&!l(g,b,r,n,c)){y=!1;break}}return c.delete(e),c.delete(t),y}var i=r(242),s=r(482),a=r(254),o=1,u=2;e.exports=n},function(e,t){(function(t){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n="object"==(void 0===t?"undefined":r(t))&&t&&t.Object===Object&&t;e.exports=n}).call(t,function(){return this}())},function(e,t,r){"use strict";function n(e){return i(e,a,s)}var i=r(250),s=r(170),a=r(32);e.exports=n},function(e,t,r){"use strict";var n=r(161),i=r(169),s=r(170),a=r(279),o=Object.getOwnPropertySymbols,u=o?function(e){for(var t=[];e;)n(t,s(e)),e=i(e);return t}:a;e.exports=u},function(e,t,r){"use strict";var n=r(472),i=r(159),s=r(474),a=r(241),o=r(475),u=r(30),l=r(272),c=l(n),f=l(i),p=l(s),d=l(a),h=l(o),m=u;(n&&"[object DataView]"!=m(new n(new ArrayBuffer(1)))||i&&"[object Map]"!=m(new i)||s&&"[object Promise]"!=m(s.resolve())||a&&"[object Set]"!=m(new a)||o&&"[object WeakMap]"!=m(new o))&&(m=function(e){var t=u(e),r="[object Object]"==t?e.constructor:void 0,n=r?l(r):"";if(n)switch(n){case c:return"[object DataView]";case f:return"[object Map]";case p:return"[object Promise]";case d:return"[object Set]";case h:return"[object WeakMap]"}return t}),e.exports=m},function(e,t,r){"use strict";function n(e,t,r){t=i(t,e);for(var n=-1,c=t.length,f=!1;++n<c;){var p=l(t[n]);if(!(f=null!=e&&r(e,p)))break;e=e[p]}return f||++n!=c?f:!!(c=null==e?0:e.length)&&u(c)&&o(p,c)&&(a(e)||s(e))}var i=r(255),s=r(112),a=r(6),o=r(171),u=r(176),l=r(108);e.exports=n},function(e,t,r){"use strict";function n(e){return"function"!=typeof e.constructor||a(e)?{}:i(s(e))}var i=r(486),s=r(169),a=r(105);e.exports=n},function(e,t,r){"use strict";function n(e){return e===e&&!i(e)}var i=r(18);e.exports=n},function(e,t){"use strict";function r(e){var t=-1,r=Array(e.size);return e.forEach(function(e,n){r[++t]=[n,e]}),r}e.exports=r},function(e,t){"use strict";function r(e,t){return function(r){return null!=r&&(r[e]===t&&(void 0!==t||e in Object(r)))}}e.exports=r},function(e,t,r){(function(e){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=r(261),s="object"==n(t)&&t&&!t.nodeType&&t,a=s&&"object"==n(e)&&e&&!e.nodeType&&e,o=a&&a.exports===s,u=o&&i.process,l=function(){try{return u&&u.binding&&u.binding("util")}catch(e){}}();e.exports=l}).call(t,r(39)(e))},function(e,t){"use strict";function r(e,t){return function(r){return e(t(r))}}e.exports=r},function(e,t){"use strict";function r(e){if(null!=e){try{return i.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var n=Function.prototype,i=n.toString;e.exports=r},function(e,t,r){"use strict";var n=r(244),i=r(573),s=r(101),a=r(529),o=s(function(e){return e.push(void 0,a),n(i,void 0,e)});e.exports=o},function(e,t,r){"use strict";function n(e,t){return null!=e&&s(e,t,i)}var i=r(490),s=r(265);e.exports=n},function(e,t,r){"use strict";function n(e){if(!a(e)||i(e)!=o)return!1;var t=s(e);if(null===t)return!0;var r=f.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&c.call(r)==p}var i=r(30),s=r(169),a=r(25),o="[object Object]",u=Function.prototype,l=Object.prototype,c=u.toString,f=l.hasOwnProperty,p=c.call(Object);e.exports=n},function(e,t,r){"use strict";var n=r(498),i=r(102),s=r(270),a=s&&s.isRegExp,o=a?i(a):n;e.exports=o},function(e,t,r){"use strict";var n=r(101),i=r(593),s=n(i);e.exports=s},function(e,t,r){"use strict";function n(e,t,r){return t=(r?s(e,t,r):void 0===t)?1:a(t),i(o(e),t)}var i=r(510),s=r(172),a=r(48),o=r(114);e.exports=n},function(e,t){"use strict";function r(){return[]}e.exports=r},function(e,t,r){"use strict";function n(e){return null==e?[]:i(e,s(e))}var i=r(515),s=r(32);e.exports=n},function(e,t){"use strict";function r(e,t,r){if(c)try{c.call(l,e,t,{value:r})}catch(n){e[t]=r}else e[t]=r}function n(e){return e&&(r(e,"call",e.call),r(e,"apply",e.apply)),e}function i(e){return f?f.call(l,e):(m.prototype=e||null,new m)}function s(){do{var e=a(h.call(d.call(y(),36),2))}while(p.call(v,e));return v[e]=e}function a(e){var t={};return t[e]=!0,Object.keys(t)[0]}function o(e){return i(null)}function u(e){function t(t){function n(r,n){if(r===u)return n?i=null:i||(i=e(t))}var i;r(t,a,n)}function n(e){return p.call(e,a)||t(e),e[a](u)}var a=s(),u=i(null);return e=e||o,n.forget=function(e){p.call(e,a)&&e[a](u,!0)},n}var l=Object,c=Object.defineProperty,f=Object.create;n(c),n(f);var p=n(Object.prototype.hasOwnProperty),d=n(Number.prototype.toString),h=n(String.prototype.slice),m=function(){},y=Math.random,v=i(null);t.makeUniqueKey=s;var g=Object.getOwnPropertyNames;Object.getOwnPropertyNames=function(e){for(var t=g(e),r=0,n=0,i=t.length;r<i;++r)p.call(v,t[r])||(r>n&&(t[n]=t[r]),++n);return t.length=n,t},t.makeAccessor=u},function(e,t,r){var n;(function(e,i){"use strict";var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(a){var o="object"==s(t)&&t,u="object"==s(e)&&e&&e.exports==o&&e,l="object"==(void 0===i?"undefined":s(i))&&i;l.global!==l&&l.window!==l||(a=l);var c={rangeOrder:"A range’s `stop` value must be greater than or equal to the `start` value.",codePointRange:"Invalid code point value. Code points range from U+000000 to U+10FFFF."},f=/\\x00([^0123456789]|$)/g,p={},d=p.hasOwnProperty,h=function(e,t){for(var r=-1,n=e.length;++r<n;)t(e[r],r)},m=p.toString,y=function(e){return"[object Array]"==m.call(e)},v=function(e){return"number"==typeof e||"[object Number]"==m.call(e)},g=function(e,t){var r=String(e);return r.length<t?("0000"+r).slice(-t):r},b=function(e){return Number(e).toString(16).toUpperCase()},E=[].slice,x=function(e){for(var t,r=-1,n=e.length,i=n-1,s=[],a=!0,o=0;++r<n;)if(t=e[r],a)s.push(t),o=t,a=!1;else if(t==o+1){if(r!=i){o=t;continue}a=!0,s.push(t+1)}else s.push(o+1,t),o=t;return a||s.push(t+1),s},A=function(e,t){for(var r,n,i=0,s=e.length;i<s;){if(r=e[i],n=e[i+1],t>=r&&t<n)return t==r?n==r+1?(e.splice(i,2),e):(e[i]=t+1,e):t==n-1?(e[i+1]=t,e):(e.splice(i,2,r,t,t+1,n),e);i+=2}return e},S=function(e,t,r){if(r<t)throw Error(c.rangeOrder);for(var n,i,s=0;s<e.length;){if(n=e[s],i=e[s+1]-1,n>r)return e;if(t<=n&&r>=i)e.splice(s,2);else{if(t>=n&&r<i)return t==n?(e[s]=r+1,e[s+1]=i+1,e):(e.splice(s,2,n,t,r+1,i+1),e);if(t>=n&&t<=i)e[s+1]=t;else if(r>=n&&r<=i)return e[s]=r+1,e;s+=2}}return e},_=function(e,t){var r,n,i=0,s=null,a=e.length;if(t<0||t>1114111)throw RangeError(c.codePointRange);for(;i<a;){if(r=e[i],n=e[i+1],t>=r&&t<n)return e;if(t==r-1)return e[i]=t,e;if(r>t)return e.splice(null!=s?s+2:0,0,t,t+1),e;if(t==n)return t+1==e[i+2]?(e.splice(i,4,r,e[i+3]),e):(e[i+1]=t+1,e);s=i,i+=2}return e.push(t,t+1),e},D=function(e,t){for(var r,n,i=0,s=e.slice(),a=t.length;i<a;)r=t[i],n=t[i+1]-1,s=r==n?_(s,r):w(s,r,n),i+=2;return s},C=function(e,t){for(var r,n,i=0,s=e.slice(),a=t.length;i<a;)r=t[i],n=t[i+1]-1,s=r==n?A(s,r):S(s,r,n),i+=2;return s},w=function(e,t,r){if(r<t)throw Error(c.rangeOrder);if(t<0||t>1114111||r<0||r>1114111)throw RangeError(c.codePointRange);for(var n,i,s=0,a=!1,o=e.length;s<o;){if(n=e[s],i=e[s+1],a){if(n==r+1)return e.splice(s-1,2),e;if(n>r)return e;n>=t&&n<=r&&(i>t&&i-1<=r?(e.splice(s,2),s-=2):(e.splice(s-1,2),s-=2))}else{if(n==r+1)return e[s]=t,e;if(n>r)return e.splice(s,0,t,r+1),e;if(t>=n&&t<i&&r+1<=i)return e;t>=n&&t<i||i==t?(e[s+1]=r+1,a=!0):t<=n&&r+1>=i&&(e[s]=t,e[s+1]=r+1,a=!0)}s+=2}return a||e.push(t,r+1),e},P=function(e,t){var r=0,n=e.length,i=e[r],s=e[n-1];if(n>=2&&(t<i||t>s))return!1;for(;r<n;){if(i=e[r],s=e[r+1],t>=i&&t<s)return!0;r+=2}return!1},k=function(e,t){for(var r,n=0,i=t.length,s=[];n<i;)r=t[n],P(e,r)&&s.push(r),++n;return x(s)},F=function(e){return!e.length},T=function(e){return 2==e.length&&e[0]+1==e[1]},O=function(e){for(var t,r,n=0,i=[],s=e.length;n<s;){for(t=e[n],r=e[n+1];t<r;)i.push(t),++t;n+=2}return i},B=Math.floor,R=function(e){return parseInt(B((e-65536)/1024)+55296,10)},I=function(e){return parseInt((e-65536)%1024+56320,10)},M=String.fromCharCode,N=function(e){return 9==e?"\\t":10==e?"\\n":12==e?"\\f":13==e?"\\r":92==e?"\\\\":36==e||e>=40&&e<=43||45==e||46==e||63==e||e>=91&&e<=94||e>=123&&e<=125?"\\"+M(e):e>=32&&e<=126?M(e):e<=255?"\\x"+g(b(e),2):"\\u"+g(b(e),4)},L=function(e){return e<=65535?N(e):"\\u{"+e.toString(16).toUpperCase()+"}"},j=function(e){var t,r=e.length,n=e.charCodeAt(0);return n>=55296&&n<=56319&&r>1?(t=e.charCodeAt(1),1024*(n-55296)+t-56320+65536):n},U=function(e){var t,r,n="",i=0,s=e.length;if(T(e))return N(e[0]);for(;i<s;)t=e[i],r=e[i+1]-1,n+=t==r?N(t):t+1==r?N(t)+N(r):N(t)+"-"+N(r),i+=2;return"["+n+"]"},V=function(e){var t,r,n="",i=0,s=e.length;if(T(e))return L(e[0]);for(;i<s;)t=e[i],r=e[i+1]-1,n+=t==r?L(t):t+1==r?L(t)+L(r):L(t)+"-"+L(r),i+=2;return"["+n+"]"},G=function(e){for(var t,r,n=[],i=[],s=[],a=[],o=0,u=e.length;o<u;)t=e[o],r=e[o+1]-1,t<55296?(r<55296&&s.push(t,r+1),r>=55296&&r<=56319&&(s.push(t,55296),n.push(55296,r+1)),r>=56320&&r<=57343&&(s.push(t,55296),n.push(55296,56320),i.push(56320,r+1)),r>57343&&(s.push(t,55296),n.push(55296,56320),i.push(56320,57344),r<=65535?s.push(57344,r+1):(s.push(57344,65536),a.push(65536,r+1)))):t>=55296&&t<=56319?(r>=55296&&r<=56319&&n.push(t,r+1),r>=56320&&r<=57343&&(n.push(t,56320),i.push(56320,r+1)),r>57343&&(n.push(t,56320),i.push(56320,57344),r<=65535?s.push(57344,r+1):(s.push(57344,65536),a.push(65536,r+1)))):t>=56320&&t<=57343?(r>=56320&&r<=57343&&i.push(t,r+1),r>57343&&(i.push(t,57344),r<=65535?s.push(57344,r+1):(s.push(57344,65536),a.push(65536,r+1)))):t>57343&&t<=65535?r<=65535?s.push(t,r+1):(s.push(t,65536),a.push(65536,r+1)):a.push(t,r+1),o+=2;return{loneHighSurrogates:n,loneLowSurrogates:i,bmp:s,astral:a}},W=function(e){for(var t,r,n,i,s,a,o=[],u=[],l=!1,c=-1,f=e.length;++c<f;)if(t=e[c],r=e[c+1]){for(n=t[0],i=t[1],s=r[0],a=r[1],u=i;s&&n[0]==s[0]&&n[1]==s[1];)u=T(a)?_(u,a[0]):w(u,a[0],a[1]-1),++c,t=e[c],n=t[0],i=t[1],r=e[c+1],s=r&&r[0],a=r&&r[1],l=!0;o.push([n,l?u:i]),l=!1}else o.push(t);return Y(o)},Y=function(e){if(1==e.length)return e;for(var t=-1,r=-1;++t<e.length;){var n=e[t],i=n[1],s=i[0],a=i[1];for(r=t;++r<e.length;){var o=e[r],u=o[1],l=u[0],c=u[1];s==l&&a==c&&(T(o[0])?n[0]=_(n[0],o[0][0]):n[0]=w(n[0],o[0][0],o[0][1]-1),e.splice(r,1),--r)}}return e},q=function(e){if(!e.length)return[];for(var t,r,n,i,s,a,o=0,u=[],l=e.length;o<l;){t=e[o],r=e[o+1]-1,n=R(t),i=I(t),s=R(r),a=I(r);var c=56320==i,f=57343==a,p=!1;n==s||c&&f?(u.push([[n,s+1],[i,a+1]]),p=!0):u.push([[n,n+1],[i,57344]]),!p&&n+1<s&&(f?(u.push([[n+1,s+1],[56320,a+1]]),p=!0):u.push([[n+1,s],[56320,57344]])),p||u.push([[s,s+1],[56320,a+1]]),o+=2}return W(u)},K=function(e){var t=[];return h(e,function(e){var r=e[0],n=e[1];t.push(U(r)+U(n))}),t.join("|")},H=function(e,t,r){if(r)return V(e);var n=[],i=G(e),s=i.loneHighSurrogates,a=i.loneLowSurrogates,o=i.bmp,u=i.astral,l=!F(s),c=!F(a),f=q(u);return t&&(o=D(o,s),l=!1,o=D(o,a),c=!1),F(o)||n.push(U(o)),f.length&&n.push(K(f)),l&&n.push(U(s)+"(?![\\uDC00-\\uDFFF])"),c&&n.push("(?:[^\\uD800-\\uDBFF]|^)"+U(a)),n.join("|")},J=function e(t){return arguments.length>1&&(t=E.call(arguments)),this instanceof e?(this.data=[],t?this.add(t):this):(new e).add(t)};J.version="1.3.2";var X=J.prototype;!function(e,t){var r;for(r in t)d.call(t,r)&&(e[r]=t[r])}(X,{add:function(e){var t=this;return null==e?t:e instanceof J?(t.data=D(t.data,e.data),t):(arguments.length>1&&(e=E.call(arguments)),y(e)?(h(e,function(e){t.add(e)}),t):(t.data=_(t.data,v(e)?e:j(e)),t))},remove:function(e){var t=this;return null==e?t:e instanceof J?(t.data=C(t.data,e.data),t):(arguments.length>1&&(e=E.call(arguments)),y(e)?(h(e,function(e){t.remove(e)}),t):(t.data=A(t.data,v(e)?e:j(e)),t))},addRange:function(e,t){var r=this;return r.data=w(r.data,v(e)?e:j(e),v(t)?t:j(t)),r},removeRange:function(e,t){var r=this,n=v(e)?e:j(e),i=v(t)?t:j(t);return r.data=S(r.data,n,i),r},intersection:function(e){var t=this,r=e instanceof J?O(e.data):e;return t.data=k(t.data,r),t},contains:function(e){return P(this.data,v(e)?e:j(e))},clone:function(){var e=new J;return e.data=this.data.slice(0),e},toString:function(e){var t=H(this.data,!!e&&e.bmpOnly,!!e&&e.hasUnicodeFlag);return t?t.replace(f,"\\0$1"):"[]"},toRegExp:function(e){var t=this.toString(e&&-1!=e.indexOf("u")?{hasUnicodeFlag:!0}:null);return RegExp(t,e||"")},valueOf:function(){return O(this.data)}}),X.toArray=X.valueOf,"object"==s(r(49))&&r(49)?void 0!==(n=function(){return J}.call(t,r,t,e))&&(e.exports=n):o&&!o.nodeType?u?u.exports=J:o.regenerate=J:a.regenerate=J}(void 0)}).call(t,r(39)(e),function(){return this}())},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}function s(e){p.default.ok(this instanceof s),h.assertIdentifier(e),this.nextTempId=0,this.contextId=e,this.listing=[],this.marked=[!0],this.finalLoc=a(),this.tryEntries=[],this.leapManager=new y.LeapManager(this)}function a(){return h.numericLiteral(-1)}function o(e){return new Error("all declarations should have been transformed into assignments before the Exploder began its work: "+(0,c.default)(e))}function u(e){var t=e.type +;return"normal"===t?!x.call(e,"target"):"break"===t||"continue"===t?!x.call(e,"value")&&h.isLiteral(e.target):("return"===t||"throw"===t)&&(x.call(e,"value")&&!x.call(e,"target"))}var l=r(35),c=i(l),f=r(64),p=i(f),d=r(1),h=n(d),m=r(607),y=n(m),v=r(608),g=n(v),b=r(116),E=n(b),x=Object.prototype.hasOwnProperty,A=s.prototype;t.Emitter=s,A.mark=function(e){h.assertLiteral(e);var t=this.listing.length;return-1===e.value?e.value=t:p.default.strictEqual(e.value,t),this.marked[t]=!0,e},A.emit=function(e){h.isExpression(e)&&(e=h.expressionStatement(e)),h.assertStatement(e),this.listing.push(e)},A.emitAssign=function(e,t){return this.emit(this.assign(e,t)),e},A.assign=function(e,t){return h.expressionStatement(h.assignmentExpression("=",e,t))},A.contextProperty=function(e,t){return h.memberExpression(this.contextId,t?h.stringLiteral(e):h.identifier(e),!!t)},A.stop=function(e){e&&this.setReturnValue(e),this.jump(this.finalLoc)},A.setReturnValue=function(e){h.assertExpression(e.value),this.emitAssign(this.contextProperty("rval"),this.explodeExpression(e))},A.clearPendingException=function(e,t){h.assertLiteral(e);var r=h.callExpression(this.contextProperty("catch",!0),[e]);t?this.emitAssign(t,r):this.emit(r)},A.jump=function(e){this.emitAssign(this.contextProperty("next"),e),this.emit(h.breakStatement())},A.jumpIf=function(e,t){h.assertExpression(e),h.assertLiteral(t),this.emit(h.ifStatement(e,h.blockStatement([this.assign(this.contextProperty("next"),t),h.breakStatement()])))},A.jumpIfNot=function(e,t){h.assertExpression(e),h.assertLiteral(t);var r=void 0;r=h.isUnaryExpression(e)&&"!"===e.operator?e.argument:h.unaryExpression("!",e),this.emit(h.ifStatement(r,h.blockStatement([this.assign(this.contextProperty("next"),t),h.breakStatement()])))},A.makeTempVar=function(){return this.contextProperty("t"+this.nextTempId++)},A.getContextFunction=function(e){return h.functionExpression(e||null,[this.contextId],h.blockStatement([this.getDispatchLoop()]),!1,!1)},A.getDispatchLoop=function(){var e=this,t=[],r=void 0,n=!1;return e.listing.forEach(function(i,s){e.marked.hasOwnProperty(s)&&(t.push(h.switchCase(h.numericLiteral(s),r=[])),n=!1),n||(r.push(i),h.isCompletionStatement(i)&&(n=!0))}),this.finalLoc.value=this.listing.length,t.push(h.switchCase(this.finalLoc,[]),h.switchCase(h.stringLiteral("end"),[h.returnStatement(h.callExpression(this.contextProperty("stop"),[]))])),h.whileStatement(h.numericLiteral(1),h.switchStatement(h.assignmentExpression("=",this.contextProperty("prev"),this.contextProperty("next")),t))},A.getTryLocsList=function(){if(0===this.tryEntries.length)return null;var e=0;return h.arrayExpression(this.tryEntries.map(function(t){var r=t.firstLoc.value;p.default.ok(r>=e,"try entries out of order"),e=r;var n=t.catchEntry,i=t.finallyEntry,s=[t.firstLoc,n?n.firstLoc:null];return i&&(s[2]=i.firstLoc,s[3]=i.afterLoc),h.arrayExpression(s)}))},A.explode=function(e,t){var r=e.node,n=this;if(h.assertNode(r),h.isDeclaration(r))throw o(r);if(h.isStatement(r))return n.explodeStatement(e);if(h.isExpression(r))return n.explodeExpression(e,t);switch(r.type){case"Program":return e.get("body").map(n.explodeStatement,n);case"VariableDeclarator":throw o(r);case"Property":case"SwitchCase":case"CatchClause":throw new Error(r.type+" nodes should be handled by their parents");default:throw new Error("unknown Node of type "+(0,c.default)(r.type))}},A.explodeStatement=function(e,t){var r=e.node,n=this,i=void 0,s=void 0,o=void 0;if(h.assertStatement(r),t?h.assertIdentifier(t):t=null,h.isBlockStatement(r))return void e.get("body").forEach(function(e){n.explodeStatement(e)});if(!g.containsLeap(r))return void n.emit(r);switch(r.type){case"ExpressionStatement":n.explodeExpression(e.get("expression"),!0);break;case"LabeledStatement":s=a(),n.leapManager.withEntry(new y.LabeledEntry(s,r.label),function(){n.explodeStatement(e.get("body"),r.label)}),n.mark(s);break;case"WhileStatement":i=a(),s=a(),n.mark(i),n.jumpIfNot(n.explodeExpression(e.get("test")),s),n.leapManager.withEntry(new y.LoopEntry(s,i,t),function(){n.explodeStatement(e.get("body"))}),n.jump(i),n.mark(s);break;case"DoWhileStatement":var u=a(),l=a();s=a(),n.mark(u),n.leapManager.withEntry(new y.LoopEntry(s,l,t),function(){n.explode(e.get("body"))}),n.mark(l),n.jumpIf(n.explodeExpression(e.get("test")),u),n.mark(s);break;case"ForStatement":o=a();var f=a();s=a(),r.init&&n.explode(e.get("init"),!0),n.mark(o),r.test&&n.jumpIfNot(n.explodeExpression(e.get("test")),s),n.leapManager.withEntry(new y.LoopEntry(s,f,t),function(){n.explodeStatement(e.get("body"))}),n.mark(f),r.update&&n.explode(e.get("update"),!0),n.jump(o),n.mark(s);break;case"TypeCastExpression":return n.explodeExpression(e.get("expression"));case"ForInStatement":o=a(),s=a();var d=n.makeTempVar();n.emitAssign(d,h.callExpression(E.runtimeProperty("keys"),[n.explodeExpression(e.get("right"))])),n.mark(o);var m=n.makeTempVar();n.jumpIf(h.memberExpression(h.assignmentExpression("=",m,h.callExpression(d,[])),h.identifier("done"),!1),s),n.emitAssign(r.left,h.memberExpression(m,h.identifier("value"),!1)),n.leapManager.withEntry(new y.LoopEntry(s,o,t),function(){n.explodeStatement(e.get("body"))}),n.jump(o),n.mark(s);break;case"BreakStatement":n.emitAbruptCompletion({type:"break",target:n.leapManager.getBreakLoc(r.label)});break;case"ContinueStatement":n.emitAbruptCompletion({type:"continue",target:n.leapManager.getContinueLoc(r.label)});break;case"SwitchStatement":var v=n.emitAssign(n.makeTempVar(),n.explodeExpression(e.get("discriminant")));s=a();for(var b=a(),x=b,A=[],_=r.cases||[],D=_.length-1;D>=0;--D){var C=_[D];h.assertSwitchCase(C),C.test?x=h.conditionalExpression(h.binaryExpression("===",v,C.test),A[D]=a(),x):A[D]=b}var w=e.get("discriminant");E.replaceWithOrRemove(w,x),n.jump(n.explodeExpression(w)),n.leapManager.withEntry(new y.SwitchEntry(s),function(){e.get("cases").forEach(function(e){var t=e.key;n.mark(A[t]),e.get("consequent").forEach(function(e){n.explodeStatement(e)})})}),n.mark(s),-1===b.value&&(n.mark(b),p.default.strictEqual(s.value,b.value));break;case"IfStatement":var P=r.alternate&&a();s=a(),n.jumpIfNot(n.explodeExpression(e.get("test")),P||s),n.explodeStatement(e.get("consequent")),P&&(n.jump(s),n.mark(P),n.explodeStatement(e.get("alternate"))),n.mark(s);break;case"ReturnStatement":n.emitAbruptCompletion({type:"return",value:n.explodeExpression(e.get("argument"))});break;case"WithStatement":throw new Error("WithStatement not supported in generator functions.");case"TryStatement":s=a();var k=r.handler,F=k&&a(),T=F&&new y.CatchEntry(F,k.param),O=r.finalizer&&a(),B=O&&new y.FinallyEntry(O,s),R=new y.TryEntry(n.getUnmarkedCurrentLoc(),T,B);n.tryEntries.push(R),n.updateContextPrevLoc(R.firstLoc),n.leapManager.withEntry(R,function(){if(n.explodeStatement(e.get("block")),F){O?n.jump(O):n.jump(s),n.updateContextPrevLoc(n.mark(F));var t=e.get("handler.body"),r=n.makeTempVar();n.clearPendingException(R.firstLoc,r),t.traverse(S,{safeParam:r,catchParamName:k.param.name}),n.leapManager.withEntry(T,function(){n.explodeStatement(t)})}O&&(n.updateContextPrevLoc(n.mark(O)),n.leapManager.withEntry(B,function(){n.explodeStatement(e.get("finalizer"))}),n.emit(h.returnStatement(h.callExpression(n.contextProperty("finish"),[B.firstLoc]))))}),n.mark(s);break;case"ThrowStatement":n.emit(h.throwStatement(n.explodeExpression(e.get("argument"))));break;default:throw new Error("unknown Statement of type "+(0,c.default)(r.type))}};var S={Identifier:function(e,t){e.node.name===t.catchParamName&&E.isReference(e)&&E.replaceWithOrRemove(e,t.safeParam)},Scope:function(e,t){e.scope.hasOwnBinding(t.catchParamName)&&e.skip()}};A.emitAbruptCompletion=function(e){u(e)||p.default.ok(!1,"invalid completion record: "+(0,c.default)(e)),p.default.notStrictEqual(e.type,"normal","normal completions are not abrupt");var t=[h.stringLiteral(e.type)];"break"===e.type||"continue"===e.type?(h.assertLiteral(e.target),t[1]=e.target):"return"!==e.type&&"throw"!==e.type||e.value&&(h.assertExpression(e.value),t[1]=e.value),this.emit(h.returnStatement(h.callExpression(this.contextProperty("abrupt"),t)))},A.getUnmarkedCurrentLoc=function(){return h.numericLiteral(this.listing.length)},A.updateContextPrevLoc=function(e){e?(h.assertLiteral(e),-1===e.value?e.value=this.listing.length:p.default.strictEqual(e.value,this.listing.length)):e=this.getUnmarkedCurrentLoc(),this.emitAssign(this.contextProperty("prev"),e)},A.explodeExpression=function(e,t){function r(e){if(h.assertExpression(e),!t)return e;s.emit(e)}function n(e,t,r){p.default.ok(!r||!e,"Ignoring the result of a child expression but forcing it to be assigned to a temporary variable?");var n=s.explodeExpression(t,r);return r||(e||l&&!h.isLiteral(n))&&(n=s.emitAssign(e||s.makeTempVar(),n)),n}var i=e.node;if(!i)return i;h.assertExpression(i);var s=this,o=void 0,u=void 0;if(!g.containsLeap(i))return r(i);var l=g.containsLeap.onlyChildren(i);switch(i.type){case"MemberExpression":return r(h.memberExpression(s.explodeExpression(e.get("object")),i.computed?n(null,e.get("property")):i.property,i.computed));case"CallExpression":var f=e.get("callee"),d=e.get("arguments"),m=void 0,y=[],v=!1;if(d.forEach(function(e){v=v||g.containsLeap(e.node)}),h.isMemberExpression(f.node))if(v){var b=n(s.makeTempVar(),f.get("object")),E=f.node.computed?n(null,f.get("property")):f.node.property;y.unshift(b),m=h.memberExpression(h.memberExpression(b,E,f.node.computed),h.identifier("call"),!1)}else m=s.explodeExpression(f);else m=n(null,f),h.isMemberExpression(m)&&(m=h.sequenceExpression([h.numericLiteral(0),m]));return d.forEach(function(e){y.push(n(null,e))}),r(h.callExpression(m,y));case"NewExpression":return r(h.newExpression(n(null,e.get("callee")),e.get("arguments").map(function(e){return n(null,e)})));case"ObjectExpression":return r(h.objectExpression(e.get("properties").map(function(e){return e.isObjectProperty()?h.objectProperty(e.node.key,n(null,e.get("value")),e.node.computed):e.node})));case"ArrayExpression":return r(h.arrayExpression(e.get("elements").map(function(e){return n(null,e)})));case"SequenceExpression":var x=i.expressions.length-1;return e.get("expressions").forEach(function(e){e.key===x?o=s.explodeExpression(e,t):s.explodeExpression(e,!0)}),o;case"LogicalExpression":u=a(),t||(o=s.makeTempVar());var A=n(o,e.get("left"));return"&&"===i.operator?s.jumpIfNot(A,u):(p.default.strictEqual(i.operator,"||"),s.jumpIf(A,u)),n(o,e.get("right"),t),s.mark(u),o;case"ConditionalExpression":var S=a();u=a();var _=s.explodeExpression(e.get("test"));return s.jumpIfNot(_,S),t||(o=s.makeTempVar()),n(o,e.get("consequent"),t),s.jump(u),s.mark(S),n(o,e.get("alternate"),t),s.mark(u),o;case"UnaryExpression":return r(h.unaryExpression(i.operator,s.explodeExpression(e.get("argument")),!!i.prefix));case"BinaryExpression":return r(h.binaryExpression(i.operator,n(null,e.get("left")),n(null,e.get("right"))));case"AssignmentExpression":return r(h.assignmentExpression(i.operator,s.explodeExpression(e.get("left")),s.explodeExpression(e.get("right"))));case"UpdateExpression":return r(h.updateExpression(i.operator,s.explodeExpression(e.get("argument")),i.prefix));case"YieldExpression":u=a();var D=i.argument&&s.explodeExpression(e.get("argument"));if(D&&i.delegate){var C=s.makeTempVar();return s.emit(h.returnStatement(h.callExpression(s.contextProperty("delegateYield"),[D,h.stringLiteral(C.property.name),u]))),s.mark(u),C}return s.emitAssign(s.contextProperty("next"),u),s.emit(h.returnStatement(D||null)),s.mark(u),s.contextProperty("sent");default:throw new Error("unknown Expression of type "+(0,c.default)(i.type))}}},function(e,t){"use strict";e.exports=function(e){var t=/^\\\\\?\\/.test(e),r=/[^\x00-\x80]+/.test(e);return t||r?e:e.replace(/\\/g,"/")}},function(e,t,r){"use strict";function n(){this._array=[],this._set=Object.create(null)}var i=r(63),s=Object.prototype.hasOwnProperty;n.fromArray=function(e,t){for(var r=new n,i=0,s=e.length;i<s;i++)r.add(e[i],t);return r},n.prototype.size=function(){return Object.getOwnPropertyNames(this._set).length},n.prototype.add=function(e,t){var r=i.toSetString(e),n=s.call(this._set,r),a=this._array.length;n&&!t||this._array.push(e),n||(this._set[r]=a)},n.prototype.has=function(e){var t=i.toSetString(e);return s.call(this._set,t)},n.prototype.indexOf=function(e){var t=i.toSetString(e);if(s.call(this._set,t))return this._set[t];throw new Error('"'+e+'" is not in the set.')},n.prototype.at=function(e){if(e>=0&&e<this._array.length)return this._array[e];throw new Error("No element indexed by "+e)},n.prototype.toArray=function(){return this._array.slice()},t.ArraySet=n},function(e,t,r){"use strict";function n(e){return e<0?1+(-e<<1):0+(e<<1)}function i(e){var t=1==(1&e),r=e>>1;return t?-r:r}var s=r(616);t.encode=function(e){var t,r="",i=n(e);do{t=31&i,i>>>=5,i>0&&(t|=32),r+=s.encode(t)}while(i>0);return r},t.decode=function(e,t,r){var n,a,o=e.length,u=0,l=0;do{if(t>=o)throw new Error("Expected more digits in base 64 VLQ value.");if(-1===(a=s.decode(e.charCodeAt(t++))))throw new Error("Invalid base64 digit: "+e.charAt(t-1));n=!!(32&a),a&=31,u+=a<<l,l+=5}while(n);r.value=i(u),r.rest=t}},function(e,t,r){"use strict";function n(e){e||(e={}),this._file=s.getArg(e,"file",null),this._sourceRoot=s.getArg(e,"sourceRoot",null),this._skipValidation=s.getArg(e,"skipValidation",!1),this._sources=new a,this._names=new a,this._mappings=new o,this._sourcesContents=null}var i=r(286),s=r(63),a=r(285).ArraySet,o=r(618).MappingList;n.prototype._version=3,n.fromSourceMap=function(e){var t=e.sourceRoot,r=new n({file:e.file,sourceRoot:t});return e.eachMapping(function(e){var n={generated:{line:e.generatedLine,column:e.generatedColumn}};null!=e.source&&(n.source=e.source,null!=t&&(n.source=s.relative(t,n.source)),n.original={line:e.originalLine,column:e.originalColumn},null!=e.name&&(n.name=e.name)),r.addMapping(n)}),e.sources.forEach(function(t){var n=e.sourceContentFor(t);null!=n&&r.setSourceContent(t,n)}),r},n.prototype.addMapping=function(e){var t=s.getArg(e,"generated"),r=s.getArg(e,"original",null),n=s.getArg(e,"source",null),i=s.getArg(e,"name",null);this._skipValidation||this._validateMapping(t,r,n,i),null!=n&&(n=String(n),this._sources.has(n)||this._sources.add(n)),null!=i&&(i=String(i),this._names.has(i)||this._names.add(i)),this._mappings.add({generatedLine:t.line,generatedColumn:t.column,originalLine:null!=r&&r.line,originalColumn:null!=r&&r.column,source:n,name:i})},n.prototype.setSourceContent=function(e,t){var r=e;null!=this._sourceRoot&&(r=s.relative(this._sourceRoot,r)),null!=t?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[s.toSetString(r)]=t):this._sourcesContents&&(delete this._sourcesContents[s.toSetString(r)],0===Object.keys(this._sourcesContents).length&&(this._sourcesContents=null))},n.prototype.applySourceMap=function(e,t,r){var n=t;if(null==t){if(null==e.file)throw new Error('SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map\'s "file" property. Both were omitted.');n=e.file}var i=this._sourceRoot;null!=i&&(n=s.relative(i,n));var o=new a,u=new a;this._mappings.unsortedForEach(function(t){if(t.source===n&&null!=t.originalLine){var a=e.originalPositionFor({line:t.originalLine,column:t.originalColumn});null!=a.source&&(t.source=a.source,null!=r&&(t.source=s.join(r,t.source)),null!=i&&(t.source=s.relative(i,t.source)),t.originalLine=a.line,t.originalColumn=a.column,null!=a.name&&(t.name=a.name))}var l=t.source;null==l||o.has(l)||o.add(l);var c=t.name;null==c||u.has(c)||u.add(c)},this),this._sources=o,this._names=u,e.sources.forEach(function(t){var n=e.sourceContentFor(t);null!=n&&(null!=r&&(t=s.join(r,t)),null!=i&&(t=s.relative(i,t)),this.setSourceContent(t,n))},this)},n.prototype._validateMapping=function(e,t,r,n){if((!(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0)||t||r||n)&&!(e&&"line"in e&&"column"in e&&t&&"line"in t&&"column"in t&&e.line>0&&e.column>=0&&t.line>0&&t.column>=0&&r))throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:r,original:t,name:n}))},n.prototype._serializeMappings=function(){for(var e,t,r,n,a=0,o=1,u=0,l=0,c=0,f=0,p="",d=this._mappings.toArray(),h=0,m=d.length;h<m;h++){if(t=d[h],e="",t.generatedLine!==o)for(a=0;t.generatedLine!==o;)e+=";",o++;else if(h>0){if(!s.compareByGeneratedPositionsInflated(t,d[h-1]))continue;e+=","}e+=i.encode(t.generatedColumn-a),a=t.generatedColumn,null!=t.source&&(n=this._sources.indexOf(t.source),e+=i.encode(n-f),f=n,e+=i.encode(t.originalLine-1-l),l=t.originalLine-1,e+=i.encode(t.originalColumn-u),u=t.originalColumn,null!=t.name&&(r=this._names.indexOf(t.name),e+=i.encode(r-c),c=r)),p+=e}return p},n.prototype._generateSourcesContent=function(e,t){return e.map(function(e){if(!this._sourcesContents)return null;null!=t&&(e=s.relative(t,e));var r=s.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,r)?this._sourcesContents[r]:null},this)},n.prototype.toJSON=function(){var e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return null!=this._file&&(e.file=this._file),null!=this._sourceRoot&&(e.sourceRoot=this._sourceRoot),this._sourcesContents&&(e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)),e},n.prototype.toString=function(){return JSON.stringify(this.toJSON())},t.SourceMapGenerator=n},function(e,t,r){"use strict";t.SourceMapGenerator=r(287).SourceMapGenerator,t.SourceMapConsumer=r(620).SourceMapConsumer,t.SourceNode=r(621).SourceNode},function(e,t,r){(function(e){"use strict";function t(){var e={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}};return e.colors.grey=e.colors.gray,Object.keys(e).forEach(function(t){var r=e[t];Object.keys(r).forEach(function(t){var n=r[t];e[t]=r[t]={open:"["+n[0]+"m",close:"["+n[1]+"m"}}),Object.defineProperty(e,t,{value:r,enumerable:!1})}),e}Object.defineProperty(e,"exports",{enumerable:!0,get:t})}).call(t,r(39)(e))},function(e,t,r){"use strict";e.exports=r(182)},function(e,t){"use strict";function r(e){return["babel-plugin-"+e,e]}t.__esModule=!0,t.default=r,e.exports=t.default},function(e,t){"use strict";function r(e){var t=["babel-preset-"+e,e],r=e.match(/^(@[^\/]+)\/(.+)$/);if(r){var n=r[1],i=r[2];t.push(n+"/babel-preset-"+i)}return t}t.__esModule=!0,t.default=r,e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(2),s=n(i);t.default=function(e,t){if(e&&t)return(0,o.default)(e,t,function(e,t){if(t&&Array.isArray(e)){for(var r=t.slice(0),n=e,i=Array.isArray(n),a=0,n=i?n:(0,s.default)(n);;){var o;if(i){if(a>=n.length)break;o=n[a++]}else{if(a=n.next(),a.done)break;o=a.value}var u=o;r.indexOf(u)<0&&r.push(u)}return r}})};var a=r(590),o=n(a);e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(e,t,r){if(e){if("Program"===e.type)return i.file(e,t||[],r||[]);if("File"===e.type)return e}throw new Error("Not a valid ast?")};var n=r(1),i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(n);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function s(e,t){var r=[],n=g.functionExpression(null,[g.identifier("global")],g.blockStatement(r)),i=g.program([g.expressionStatement(g.callExpression(n,[c.get("selfGlobal")]))]);return r.push(g.variableDeclaration("var",[g.variableDeclarator(e,g.assignmentExpression("=",g.memberExpression(g.identifier("global"),e),g.objectExpression([])))])),t(r),i}function a(e,t){var r=[];return r.push(g.variableDeclaration("var",[g.variableDeclarator(e,g.identifier("global"))])),t(r),g.program([b({FACTORY_PARAMETERS:g.identifier("global"),BROWSER_ARGUMENTS:g.assignmentExpression("=",g.memberExpression(g.identifier("root"),e),g.objectExpression([])),COMMON_ARGUMENTS:g.identifier("exports"),AMD_ARGUMENTS:g.arrayExpression([g.stringLiteral("exports")]),FACTORY_BODY:r,UMD_ROOT:g.identifier("this")})])}function o(e,t){var r=[];return r.push(g.variableDeclaration("var",[g.variableDeclarator(e,g.objectExpression([]))])),t(r),r.push(g.expressionStatement(e)),g.program(r)}function u(e,t,r){c.list.forEach(function(n){if(!(r&&r.indexOf(n)<0)){var i=g.identifier(n);e.push(g.expressionStatement(g.assignmentExpression("=",g.memberExpression(t,i),c.get(n))))}})}t.__esModule=!0,t.default=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"global",r=g.identifier("babelHelpers"),n=function(t){return u(t,r,e)},i=void 0,l={global:s,umd:a,var:o}[t];if(!l)throw new Error(h.get("unsupportedOutputType",t));return i=l(r,n),(0,p.default)(i).code};var l=r(194),c=i(l),f=r(186),p=n(f),d=r(20),h=i(d),m=r(4),y=n(m),v=r(1),g=i(v),b=(0,y.default)('\n (function (root, factory) {\n if (typeof define === "function" && define.amd) {\n define(AMD_ARGUMENTS, factory);\n } else if (typeof exports === "object") {\n factory(COMMON_ARGUMENTS);\n } else {\n factory(BROWSER_ARGUMENTS);\n }\n })(UMD_ROOT, function (FACTORY_PARAMETERS) {\n FACTORY_BODY\n });\n');e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(65),s=n(i),a=r(594),o=n(a);t.default=new s.default({name:"internal.blockHoist",visitor:{Block:{exit:function(e){for(var t=e.node,r=!1,n=0;n<t.body.length;n++){var i=t.body[n];if(i&&null!=i._blockHoist){r=!0;break}}r&&(t.body=(0,o.default)(t.body,function(e){var t=e&&e._blockHoist;return null==t&&(t=1),!0===t&&(t=2),-1*t}))}}}}),e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){return!!e.is("_forceShadow")||t}function s(e,t){var r=e.inShadow(t);if(i(e,r)){var n=e.node._shadowedFunctionLiteral,s=void 0,a=!1,o=e.find(function(t){if(t.parentPath&&t.parentPath.isClassProperty()&&"value"===t.key)return!0;if(e===t)return!1;if((t.isProgram()||t.isFunction())&&(s=s||t),t.isProgram())return a=!0,!0;if(t.isFunction()&&!t.isArrowFunctionExpression()){if(n){if(t===n||t.node===n.node)return!0}else if(!t.is("shadow"))return!0;return a=!0,!1}return!1});if(n&&o.isProgram()&&!n.isProgram()&&(o=e.findParent(function(e){return e.isProgram()||e.isFunction()})),o!==s&&a){var u=o.getData(t);if(u)return e.replaceWith(u);var l=e.scope.generateUidIdentifier(t);o.setData(t,l);var c=o.findParent(function(e){return e.isClass()}),p=!!(c&&c.node&&c.node.superClass);if("this"===t&&o.isMethod({kind:"constructor"})&&p)o.scope.push({id:l}),o.traverse(d,{id:l});else{var h="this"===t?f.thisExpression():f.identifier(t);n&&(h._shadowedFunctionLiteral=n),o.scope.push({id:l,init:h})}return e.replaceWith(l)}}}t.__esModule=!0;var a=r(10),o=n(a),u=r(65),l=n(u),c=r(1),f=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(c),p=(0,o.default)("super this bound"),d={CallExpression:function(e){if(e.get("callee").isSuper()){var t=e.node;t[p]||(t[p]=!0,e.replaceWith(f.assignmentExpression("=",this.id,t)))}}};t.default=new l.default({name:"internal.shadowFunctions",visitor:{ThisExpression:function(e){s(e,"this")},ReferencedIdentifier:function(e){"arguments"===e.node.name&&s(e,"arguments")}}}),e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(3),s=n(i),a=r(294),o=n(a),u=r(65),l=n(u),c=r(50),f=n(c),p=function(){function e(){(0,s.default)(this,e)}return e.prototype.lint=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.code=!1,t.mode="lint",this.transform(e,t)},e.prototype.pretransform=function(e,t){var r=new f.default(t,this);return r.wrap(e,function(){return r.addCode(e),r.parseCode(e),r})},e.prototype.transform=function(e,t){var r=new f.default(t,this);return r.wrap(e,function(){return r.addCode(e),r.parseCode(e),r.transform()})},e.prototype.analyse=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments[2];return t.code=!1,r&&(t.plugins=t.plugins||[],t.plugins.push(new l.default({visitor:r}))),this.transform(e,t).metadata},e.prototype.transformFromAst=function(e,t,r){e=(0,o.default)(e);var n=new f.default(r,this);return n.wrap(t,function(){return n.addCode(t),n.addAst(e),n.transform()})},e}();t.default=p,e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(3),s=n(i),a=r(42),o=n(a),u=r(41),l=n(u),c=r(119),f=n(c),p=r(50),d=(n(p),function(e){function t(r,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};(0,s.default)(this,t);var a=(0,o.default)(this,e.call(this));return a.plugin=n,a.key=n.key,a.file=r,a.opts=i,a}return(0,l.default)(t,e),t.prototype.addHelper=function(){var e;return(e=this.file).addHelper.apply(e,arguments)},t.prototype.addImport=function(){var e;return(e=this.file).addImport.apply(e,arguments)},t.prototype.getModuleName=function(){var e;return(e=this.file).getModuleName.apply(e,arguments)},t.prototype.buildCodeFrameError=function(){var e;return(e=this.file).buildCodeFrameError.apply(e,arguments)},t}(f.default));t.default=d,e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(3),s=n(i),a=r(625),o=n(a),u=/^[ \t]+$/,l=function(){function e(t){(0,s.default)(this,e),this._map=null,this._buf=[],this._last="",this._queue=[],this._position={line:1,column:0},this._sourcePosition={identifierName:null,line:null,column:null,filename:null},this._map=t}return e.prototype.get=function(){this._flush();var e=this._map,t={code:(0,o.default)(this._buf.join("")),map:null,rawMappings:e&&e.getRawMappings()};return e&&Object.defineProperty(t,"map",{configurable:!0,enumerable:!0,get:function(){return this.map=e.get()},set:function(e){Object.defineProperty(this,"map",{value:e,writable:!0})}}),t},e.prototype.append=function(e){this._flush();var t=this._sourcePosition,r=t.line,n=t.column,i=t.filename,s=t.identifierName;this._append(e,r,n,s,i)},e.prototype.queue=function(e){if("\n"===e)for(;this._queue.length>0&&u.test(this._queue[0][0]);)this._queue.shift();var t=this._sourcePosition,r=t.line,n=t.column,i=t.filename,s=t.identifierName;this._queue.unshift([e,r,n,s,i])},e.prototype._flush=function(){for(var e=void 0;e=this._queue.pop();)this._append.apply(this,e)},e.prototype._append=function(e,t,r,n,i){this._map&&"\n"!==e[0]&&this._map.mark(this._position.line,this._position.column,t,r,n,i),this._buf.push(e),this._last=e[e.length-1];for(var s=0;s<e.length;s++)"\n"===e[s]?(this._position.line++,this._position.column=0):this._position.column++},e.prototype.removeTrailingNewline=function(){this._queue.length>0&&"\n"===this._queue[0][0]&&this._queue.shift()},e.prototype.removeLastSemicolon=function(){this._queue.length>0&&";"===this._queue[0][0]&&this._queue.shift()},e.prototype.endsWith=function(e){if(1===e.length){var t=void 0;if(this._queue.length>0){var r=this._queue[0][0];t=r[r.length-1]}else t=this._last;return t===e}var n=this._last+this._queue.reduce(function(e,t){return t[0]+e},"");return e.length<=n.length&&n.slice(-e.length)===e},e.prototype.hasContent=function(){return this._queue.length>0||!!this._last},e.prototype.source=function(e,t){if(!e||t){var r=t?t[e]:null;this._sourcePosition.identifierName=t&&t.identifierName||null,this._sourcePosition.line=r?r.line:null,this._sourcePosition.column=r?r.column:null,this._sourcePosition.filename=t&&t.filename||null}},e.prototype.withSource=function(e,t,r){if(!this._map)return r();var n=this._sourcePosition.line,i=this._sourcePosition.column,s=this._sourcePosition.filename,a=this._sourcePosition.identifierName;this.source(e,t),r(),this._sourcePosition.line=n,this._sourcePosition.column=i,this._sourcePosition.filename=s,this._sourcePosition.identifierName=a},e.prototype.getCurrentColumn=function(){var e=this._queue.reduce(function(e,t){return t[0]+e},""),t=e.lastIndexOf("\n");return-1===t?this._position.column+e.length:e.length-1-t},e.prototype.getCurrentLine=function(){for(var e=this._queue.reduce(function(e,t){return t[0]+e},""),t=0,r=0;r<e.length;r++)"\n"===e[r]&&t++;return this._position.line+t},e}();t.default=l,e.exports=t.default},function(e,t,r){"use strict";function n(e){this.print(e.program,e)}function i(e){this.printInnerComments(e,!1),this.printSequence(e.directives,e),e.directives&&e.directives.length&&this.newline(),this.printSequence(e.body,e)}function s(e){this.token("{"),this.printInnerComments(e);var t=e.directives&&e.directives.length;e.body.length||t?(this.newline(),this.printSequence(e.directives,e,{indent:!0}),t&&this.newline(),this.printSequence(e.body,e,{indent:!0}),this.removeTrailingNewline(),this.source("end",e.loc),this.endsWith("\n")||this.newline(),this.rightBrace()):(this.source("end",e.loc),this.token("}"))}function a(){}function o(e){this.print(e.value,e),this.semicolon()}t.__esModule=!0,t.File=n,t.Program=i,t.BlockStatement=s,t.Noop=a,t.Directive=o;var u=r(123);Object.defineProperty(t,"DirectiveLiteral",{enumerable:!0,get:function(){return u.StringLiteral}})},function(e,t){"use strict";function r(e){this.printJoin(e.decorators,e),this.word("class"),e.id&&(this.space(),this.print(e.id,e)),this.print(e.typeParameters,e),e.superClass&&(this.space(),this.word("extends"),this.space(),this.print(e.superClass,e),this.print(e.superTypeParameters,e)),e.implements&&(this.space(),this.word("implements"),this.space(),this.printList(e.implements,e)),this.space(),this.print(e.body,e)}function n(e){this.token("{"),this.printInnerComments(e),0===e.body.length?this.token("}"):(this.newline(),this.indent(),this.printSequence(e.body,e),this.dedent(),this.endsWith("\n")||this.newline(),this.rightBrace())}function i(e){this.printJoin(e.decorators,e),e.static&&(this.word("static"),this.space()),e.computed?(this.token("["),this.print(e.key,e),this.token("]")):(this._variance(e),this.print(e.key,e)),this.print(e.typeAnnotation,e),e.value&&(this.space(),this.token("="),this.space(),this.print(e.value,e)),this.semicolon()}function s(e){this.printJoin(e.decorators,e),e.static&&(this.word("static"),this.space()),"constructorCall"===e.kind&&(this.word("call"),this.space()),this._method(e)}t.__esModule=!0,t.ClassDeclaration=r,t.ClassBody=n,t.ClassProperty=i,t.ClassMethod=s,t.ClassExpression=r},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function i(e){"void"===e.operator||"delete"===e.operator||"typeof"===e.operator?(this.word(e.operator),this.space()):this.token(e.operator),this.print(e.argument,e)}function s(e){this.word("do"),this.space(),this.print(e.body,e)}function a(e){this.token("("),this.print(e.expression,e),this.token(")")}function o(e){e.prefix?(this.token(e.operator),this.print(e.argument,e)):(this.print(e.argument,e),this.token(e.operator))}function u(e){this.print(e.test,e),this.space(),this.token("?"),this.space(),this.print(e.consequent,e),this.space(),this.token(":"),this.space(),this.print(e.alternate,e)}function l(e,t){this.word("new"),this.space(),this.print(e.callee,e),(0!==e.arguments.length||!this.format.minified||C.isCallExpression(t,{callee:e})||C.isMemberExpression(t)||C.isNewExpression(t))&&(this.token("("),this.printList(e.arguments,e),this.token(")"))}function c(e){this.printList(e.expressions,e)}function f(){ +this.word("this")}function p(){this.word("super")}function d(e){this.token("@"),this.print(e.expression,e),this.newline()}function h(){this.token(","),this.newline(),this.endsWith("\n")||this.space()}function m(e){this.print(e.callee,e),this.token("(");var t=e._prettyCall,r=void 0;t&&(r=h,this.newline(),this.indent()),this.printList(e.arguments,e,{separator:r}),t&&(this.newline(),this.dedent()),this.token(")")}function y(){this.word("import")}function v(e){return function(t){if(this.word(e),t.delegate&&this.token("*"),t.argument){this.space();var r=this.startTerminatorless();this.print(t.argument,t),this.endTerminatorless(r)}}}function g(){this.semicolon(!0)}function b(e){this.print(e.expression,e),this.semicolon()}function E(e){this.print(e.left,e),e.left.optional&&this.token("?"),this.print(e.left.typeAnnotation,e),this.space(),this.token("="),this.space(),this.print(e.right,e)}function x(e,t){var r=this.inForStatementInitCounter&&"in"===e.operator&&!P.needsParens(e,t);r&&this.token("("),this.print(e.left,e),this.space(),"in"===e.operator||"instanceof"===e.operator?this.word(e.operator):this.token(e.operator),this.space(),this.print(e.right,e),r&&this.token(")")}function A(e){this.print(e.object,e),this.token("::"),this.print(e.callee,e)}function S(e){if(this.print(e.object,e),!e.computed&&C.isMemberExpression(e.property))throw new TypeError("Got a MemberExpression for MemberExpression property");var t=e.computed;C.isLiteral(e.property)&&"number"==typeof e.property.value&&(t=!0),t?(this.token("["),this.print(e.property,e),this.token("]")):(this.token("."),this.print(e.property,e))}function _(e){this.print(e.meta,e),this.token("."),this.print(e.property,e)}t.__esModule=!0,t.LogicalExpression=t.BinaryExpression=t.AwaitExpression=t.YieldExpression=void 0,t.UnaryExpression=i,t.DoExpression=s,t.ParenthesizedExpression=a,t.UpdateExpression=o,t.ConditionalExpression=u,t.NewExpression=l,t.SequenceExpression=c,t.ThisExpression=f,t.Super=p,t.Decorator=d,t.CallExpression=m,t.Import=y,t.EmptyStatement=g,t.ExpressionStatement=b,t.AssignmentPattern=E,t.AssignmentExpression=x,t.BindExpression=A,t.MemberExpression=S,t.MetaProperty=_;var D=r(1),C=n(D),w=r(187),P=n(w);t.YieldExpression=v("yield"),t.AwaitExpression=v("await");t.BinaryExpression=x,t.LogicalExpression=x},function(e,t,r){"use strict";function n(){this.word("any")}function i(e){this.print(e.elementType,e),this.token("["),this.token("]")}function s(){this.word("boolean")}function a(e){this.word(e.value?"true":"false")}function o(){this.word("null")}function u(e,t){Q.isDeclareExportDeclaration(t)||(this.word("declare"),this.space()),this.word("class"),this.space(),this._interfaceish(e)}function l(e,t){Q.isDeclareExportDeclaration(t)||(this.word("declare"),this.space()),this.word("function"),this.space(),this.print(e.id,e),this.print(e.id.typeAnnotation.typeAnnotation,e),this.semicolon()}function c(e){this.word("declare"),this.space(),this.InterfaceDeclaration(e)}function f(e){this.word("declare"),this.space(),this.word("module"),this.space(),this.print(e.id,e),this.space(),this.print(e.body,e)}function p(e){this.word("declare"),this.space(),this.word("module"),this.token("."),this.word("exports"),this.print(e.typeAnnotation,e)}function d(e){this.word("declare"),this.space(),this.TypeAlias(e)}function h(e,t){Q.isDeclareExportDeclaration(t)||(this.word("declare"),this.space()),this.OpaqueType(e)}function m(e,t){Q.isDeclareExportDeclaration(t)||(this.word("declare"),this.space()),this.word("var"),this.space(),this.print(e.id,e),this.print(e.id.typeAnnotation,e),this.semicolon()}function y(e){this.word("declare"),this.space(),this.word("export"),this.space(),e.default&&(this.word("default"),this.space()),v.apply(this,arguments)}function v(e){if(e.declaration){var t=e.declaration;this.print(t,e),Q.isStatement(t)||this.semicolon()}else this.token("{"),e.specifiers.length&&(this.space(),this.printList(e.specifiers,e),this.space()),this.token("}"),e.source&&(this.space(),this.word("from"),this.space(),this.print(e.source,e)),this.semicolon()}function g(){this.token("*")}function b(e,t){this.print(e.typeParameters,e),this.token("("),this.printList(e.params,e),e.rest&&(e.params.length&&(this.token(","),this.space()),this.token("..."),this.print(e.rest,e)),this.token(")"),"ObjectTypeCallProperty"===t.type||"DeclareFunction"===t.type?this.token(":"):(this.space(),this.token("=>")),this.space(),this.print(e.returnType,e)}function E(e){this.print(e.name,e),e.optional&&this.token("?"),this.token(":"),this.space(),this.print(e.typeAnnotation,e)}function x(e){this.print(e.id,e),this.print(e.typeParameters,e)}function A(e){this.print(e.id,e),this.print(e.typeParameters,e),e.extends.length&&(this.space(),this.word("extends"),this.space(),this.printList(e.extends,e)),e.mixins&&e.mixins.length&&(this.space(),this.word("mixins"),this.space(),this.printList(e.mixins,e)),this.space(),this.print(e.body,e)}function S(e){"plus"===e.variance?this.token("+"):"minus"===e.variance&&this.token("-")}function _(e){this.word("interface"),this.space(),this._interfaceish(e)}function D(){this.space(),this.token("&"),this.space()}function C(e){this.printJoin(e.types,e,{separator:D})}function w(){this.word("mixed")}function P(){this.word("empty")}function k(e){this.token("?"),this.print(e.typeAnnotation,e)}function F(){this.word("number")}function T(){this.word("string")}function O(){this.word("this")}function B(e){this.token("["),this.printList(e.types,e),this.token("]")}function R(e){this.word("typeof"),this.space(),this.print(e.argument,e)}function I(e){this.word("type"),this.space(),this.print(e.id,e),this.print(e.typeParameters,e),this.space(),this.token("="),this.space(),this.print(e.right,e),this.semicolon()}function M(e){this.word("opaque"),this.space(),this.word("type"),this.space(),this.print(e.id,e),this.print(e.typeParameters,e),e.supertype&&(this.token(":"),this.space(),this.print(e.supertype,e)),e.impltype&&(this.space(),this.token("="),this.space(),this.print(e.impltype,e)),this.semicolon()}function N(e){this.token(":"),this.space(),e.optional&&this.token("?"),this.print(e.typeAnnotation,e)}function L(e){this._variance(e),this.word(e.name),e.bound&&this.print(e.bound,e),e.default&&(this.space(),this.token("="),this.space(),this.print(e.default,e))}function j(e){this.token("<"),this.printList(e.params,e,{}),this.token(">")}function U(e){var t=this;e.exact?this.token("{|"):this.token("{");var r=e.properties.concat(e.callProperties,e.indexers);r.length&&(this.space(),this.printJoin(r,e,{addNewlines:function(e){if(e&&!r[0])return 1},indent:!0,statement:!0,iterator:function(){1!==r.length&&(t.format.flowCommaSeparator?t.token(","):t.semicolon(),t.space())}}),this.space()),e.exact?this.token("|}"):this.token("}")}function V(e){e.static&&(this.word("static"),this.space()),this.print(e.value,e)}function G(e){e.static&&(this.word("static"),this.space()),this._variance(e),this.token("["),this.print(e.id,e),this.token(":"),this.space(),this.print(e.key,e),this.token("]"),this.token(":"),this.space(),this.print(e.value,e)}function W(e){e.static&&(this.word("static"),this.space()),this._variance(e),this.print(e.key,e),e.optional&&this.token("?"),this.token(":"),this.space(),this.print(e.value,e)}function Y(e){this.token("..."),this.print(e.argument,e)}function q(e){this.print(e.qualification,e),this.token("."),this.print(e.id,e)}function K(){this.space(),this.token("|"),this.space()}function H(e){this.printJoin(e.types,e,{separator:K})}function J(e){this.token("("),this.print(e.expression,e),this.print(e.typeAnnotation,e),this.token(")")}function X(){this.word("void")}t.__esModule=!0,t.TypeParameterDeclaration=t.StringLiteralTypeAnnotation=t.NumericLiteralTypeAnnotation=t.GenericTypeAnnotation=t.ClassImplements=void 0,t.AnyTypeAnnotation=n,t.ArrayTypeAnnotation=i,t.BooleanTypeAnnotation=s,t.BooleanLiteralTypeAnnotation=a,t.NullLiteralTypeAnnotation=o,t.DeclareClass=u,t.DeclareFunction=l,t.DeclareInterface=c,t.DeclareModule=f,t.DeclareModuleExports=p,t.DeclareTypeAlias=d,t.DeclareOpaqueType=h,t.DeclareVariable=m,t.DeclareExportDeclaration=y,t.ExistentialTypeParam=g,t.FunctionTypeAnnotation=b,t.FunctionTypeParam=E,t.InterfaceExtends=x,t._interfaceish=A,t._variance=S,t.InterfaceDeclaration=_,t.IntersectionTypeAnnotation=C,t.MixedTypeAnnotation=w,t.EmptyTypeAnnotation=P,t.NullableTypeAnnotation=k;var z=r(123);Object.defineProperty(t,"NumericLiteralTypeAnnotation",{enumerable:!0,get:function(){return z.NumericLiteral}}),Object.defineProperty(t,"StringLiteralTypeAnnotation",{enumerable:!0,get:function(){return z.StringLiteral}}),t.NumberTypeAnnotation=F,t.StringTypeAnnotation=T,t.ThisTypeAnnotation=O,t.TupleTypeAnnotation=B,t.TypeofTypeAnnotation=R,t.TypeAlias=I,t.OpaqueType=M,t.TypeAnnotation=N,t.TypeParameter=L,t.TypeParameterInstantiation=j,t.ObjectTypeAnnotation=U,t.ObjectTypeCallProperty=V,t.ObjectTypeIndexer=G,t.ObjectTypeProperty=W,t.ObjectTypeSpreadProperty=Y,t.QualifiedTypeIdentifier=q,t.UnionTypeAnnotation=H,t.TypeCastExpression=J,t.VoidTypeAnnotation=X;var $=r(1),Q=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}($);t.ClassImplements=x,t.GenericTypeAnnotation=x,t.TypeParameterDeclaration=j},function(e,t,r){"use strict";function n(e){this.print(e.name,e),e.value&&(this.token("="),this.print(e.value,e))}function i(e){this.word(e.name)}function s(e){this.print(e.namespace,e),this.token(":"),this.print(e.name,e)}function a(e){this.print(e.object,e),this.token("."),this.print(e.property,e)}function o(e){this.token("{"),this.token("..."),this.print(e.argument,e),this.token("}")}function u(e){this.token("{"),this.print(e.expression,e),this.token("}")}function l(e){this.token("{"),this.token("..."),this.print(e.expression,e),this.token("}")}function c(e){this.token(e.value)}function f(e){var t=e.openingElement;if(this.print(t,e),!t.selfClosing){this.indent();for(var r=e.children,n=Array.isArray(r),i=0,r=n?r:(0,v.default)(r);;){var s;if(n){if(i>=r.length)break;s=r[i++]}else{if(i=r.next(),i.done)break;s=i.value}var a=s;this.print(a,e)}this.dedent(),this.print(e.closingElement,e)}}function p(){this.space()}function d(e){this.token("<"),this.print(e.name,e),e.attributes.length>0&&(this.space(),this.printJoin(e.attributes,e,{separator:p})),e.selfClosing?(this.space(),this.token("/>")):this.token(">")}function h(e){this.token("</"),this.print(e.name,e),this.token(">")}function m(){}t.__esModule=!0;var y=r(2),v=function(e){return e&&e.__esModule?e:{default:e}}(y);t.JSXAttribute=n,t.JSXIdentifier=i,t.JSXNamespacedName=s,t.JSXMemberExpression=a,t.JSXSpreadAttribute=o,t.JSXExpressionContainer=u,t.JSXSpreadChild=l,t.JSXText=c,t.JSXElement=f,t.JSXOpeningElement=d,t.JSXClosingElement=h,t.JSXEmptyExpression=m},function(e,t,r){"use strict";function n(e){var t=this;this.print(e.typeParameters,e),this.token("("),this.printList(e.params,e,{iterator:function(e){e.optional&&t.token("?"),t.print(e.typeAnnotation,e)}}),this.token(")"),e.returnType&&this.print(e.returnType,e)}function i(e){var t=e.kind,r=e.key;"method"!==t&&"init"!==t||e.generator&&this.token("*"),"get"!==t&&"set"!==t||(this.word(t),this.space()),e.async&&(this.word("async"),this.space()),e.computed?(this.token("["),this.print(r,e),this.token("]")):this.print(r,e),this._params(e),this.space(),this.print(e.body,e)}function s(e){e.async&&(this.word("async"),this.space()),this.word("function"),e.generator&&this.token("*"),e.id?(this.space(),this.print(e.id,e)):this.space(),this._params(e),this.space(),this.print(e.body,e)}function a(e){e.async&&(this.word("async"),this.space());var t=e.params[0];1===e.params.length&&l.isIdentifier(t)&&!o(e,t)?this.print(t,e):this._params(e),this.space(),this.token("=>"),this.space(),this.print(e.body,e)}function o(e,t){return e.typeParameters||e.returnType||t.typeAnnotation||t.optional||t.trailingComments}t.__esModule=!0,t.FunctionDeclaration=void 0,t._params=n,t._method=i,t.FunctionExpression=s,t.ArrowFunctionExpression=a;var u=r(1),l=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(u);t.FunctionDeclaration=s},function(e,t,r){"use strict";function n(e){"type"!==e.importKind&&"typeof"!==e.importKind||(this.word(e.importKind),this.space()),this.print(e.imported,e),e.local&&e.local.name!==e.imported.name&&(this.space(),this.word("as"),this.space(),this.print(e.local,e))}function i(e){this.print(e.local,e)}function s(e){this.print(e.exported,e)}function a(e){this.print(e.local,e),e.exported&&e.local.name!==e.exported.name&&(this.space(),this.word("as"),this.space(),this.print(e.exported,e))}function o(e){this.token("*"),this.space(),this.word("as"),this.space(),this.print(e.exported,e)}function u(e){this.word("export"),this.space(),this.token("*"),this.space(),this.word("from"),this.space(),this.print(e.source,e),this.semicolon()}function l(){this.word("export"),this.space(),f.apply(this,arguments)}function c(){this.word("export"),this.space(),this.word("default"),this.space(),f.apply(this,arguments)}function f(e){if(e.declaration){var t=e.declaration;this.print(t,e),m.isStatement(t)||this.semicolon()}else{"type"===e.exportKind&&(this.word("type"),this.space());for(var r=e.specifiers.slice(0),n=!1;;){var i=r[0];if(!m.isExportDefaultSpecifier(i)&&!m.isExportNamespaceSpecifier(i))break;n=!0,this.print(r.shift(),e),r.length&&(this.token(","),this.space())}(r.length||!r.length&&!n)&&(this.token("{"),r.length&&(this.space(),this.printList(r,e),this.space()),this.token("}")),e.source&&(this.space(),this.word("from"),this.space(),this.print(e.source,e)),this.semicolon()}}function p(e){this.word("import"),this.space(),"type"!==e.importKind&&"typeof"!==e.importKind||(this.word(e.importKind),this.space());var t=e.specifiers.slice(0);if(t&&t.length){for(;;){var r=t[0];if(!m.isImportDefaultSpecifier(r)&&!m.isImportNamespaceSpecifier(r))break;this.print(t.shift(),e),t.length&&(this.token(","),this.space())}t.length&&(this.token("{"),this.space(),this.printList(t,e),this.space(),this.token("}")),this.space(),this.word("from"),this.space()}this.print(e.source,e),this.semicolon()}function d(e){this.token("*"),this.space(),this.word("as"),this.space(),this.print(e.local,e)}t.__esModule=!0,t.ImportSpecifier=n,t.ImportDefaultSpecifier=i,t.ExportDefaultSpecifier=s,t.ExportSpecifier=a,t.ExportNamespaceSpecifier=o,t.ExportAllDeclaration=u,t.ExportNamedDeclaration=l,t.ExportDefaultDeclaration=c,t.ImportDeclaration=p,t.ImportNamespaceSpecifier=d;var h=r(1),m=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(h)},function(e,t,r){"use strict";function n(e){this.word("with"),this.space(),this.token("("),this.print(e.object,e),this.token(")"),this.printBlock(e)}function i(e){this.word("if"),this.space(),this.token("("),this.print(e.test,e),this.token(")"),this.space();var t=e.alternate&&S.isIfStatement(s(e.consequent));t&&(this.token("{"),this.newline(),this.indent()),this.printAndIndentOnComments(e.consequent,e),t&&(this.dedent(),this.newline(),this.token("}")),e.alternate&&(this.endsWith("}")&&this.space(),this.word("else"),this.space(),this.printAndIndentOnComments(e.alternate,e))}function s(e){return S.isStatement(e.body)?s(e.body):e}function a(e){this.word("for"),this.space(),this.token("("),this.inForStatementInitCounter++,this.print(e.init,e),this.inForStatementInitCounter--,this.token(";"),e.test&&(this.space(),this.print(e.test,e)),this.token(";"),e.update&&(this.space(),this.print(e.update,e)),this.token(")"),this.printBlock(e)}function o(e){this.word("while"),this.space(),this.token("("),this.print(e.test,e),this.token(")"),this.printBlock(e)}function u(e){this.word("do"),this.space(),this.print(e.body,e),this.space(),this.word("while"),this.space(),this.token("("),this.print(e.test,e),this.token(")"),this.semicolon()}function l(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"label";return function(r){this.word(e);var n=r[t];if(n){this.space();var i=this.startTerminatorless();this.print(n,r),this.endTerminatorless(i)}this.semicolon()}}function c(e){this.print(e.label,e),this.token(":"),this.space(),this.print(e.body,e)}function f(e){this.word("try"),this.space(),this.print(e.block,e),this.space(),e.handlers?this.print(e.handlers[0],e):this.print(e.handler,e),e.finalizer&&(this.space(),this.word("finally"),this.space(),this.print(e.finalizer,e))}function p(e){this.word("catch"),this.space(),this.token("("),this.print(e.param,e),this.token(")"),this.space(),this.print(e.body,e)}function d(e){this.word("switch"),this.space(),this.token("("),this.print(e.discriminant,e),this.token(")"),this.space(),this.token("{"),this.printSequence(e.cases,e,{indent:!0,addNewlines:function(t,r){if(!t&&e.cases[e.cases.length-1]===r)return-1}}),this.token("}")}function h(e){e.test?(this.word("case"),this.space(),this.print(e.test,e),this.token(":")):(this.word("default"),this.token(":")),e.consequent.length&&(this.newline(),this.printSequence(e.consequent,e,{indent:!0}))}function m(){this.word("debugger"),this.semicolon()}function y(){if(this.token(","),this.newline(),this.endsWith("\n"))for(var e=0;e<4;e++)this.space(!0)}function v(){if(this.token(","),this.newline(),this.endsWith("\n"))for(var e=0;e<6;e++)this.space(!0)}function g(e,t){this.word(e.kind),this.space();var r=!1;if(!S.isFor(t))for(var n=e.declarations,i=Array.isArray(n),s=0,n=i?n:(0,x.default)(n);;){var a;if(i){if(s>=n.length)break;a=n[s++]}else{if(s=n.next(),s.done)break;a=s.value}var o=a;o.init&&(r=!0)}var u=void 0;r&&(u="const"===e.kind?v:y),this.printList(e.declarations,e,{separator:u}),(!S.isFor(t)||t.left!==e&&t.init!==e)&&this.semicolon()}function b(e){this.print(e.id,e),this.print(e.id.typeAnnotation,e),e.init&&(this.space(),this.token("="),this.space(),this.print(e.init,e))}t.__esModule=!0,t.ThrowStatement=t.BreakStatement=t.ReturnStatement=t.ContinueStatement=t.ForAwaitStatement=t.ForOfStatement=t.ForInStatement=void 0;var E=r(2),x=function(e){return e&&e.__esModule?e:{default:e}}(E);t.WithStatement=n,t.IfStatement=i,t.ForStatement=a,t.WhileStatement=o,t.DoWhileStatement=u,t.LabeledStatement=c,t.TryStatement=f,t.CatchClause=p,t.SwitchStatement=d,t.SwitchCase=h,t.DebuggerStatement=m,t.VariableDeclaration=g,t.VariableDeclarator=b;var A=r(1),S=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(A),_=function(e){return function(t){this.word("for"),this.space(),"await"===e&&(this.word("await"),this.space()),this.token("("),this.print(t.left,t),this.space(),this.word("await"===e?"of":e),this.space(),this.print(t.right,t),this.token(")"),this.printBlock(t)}};t.ForInStatement=_("in"),t.ForOfStatement=_("of"),t.ForAwaitStatement=_("await"),t.ContinueStatement=l("continue"),t.ReturnStatement=l("return","argument"),t.BreakStatement=l("break"),t.ThrowStatement=l("throw","argument")},function(e,t){"use strict";function r(e){this.print(e.tag,e),this.print(e.quasi,e)}function n(e,t){var r=t.quasis[0]===e,n=t.quasis[t.quasis.length-1]===e,i=(r?"`":"}")+e.value.raw+(n?"`":"${");this.token(i)}function i(e){for(var t=e.quasis,r=0;r<t.length;r++)this.print(t[r],e),r+1<t.length&&this.print(e.expressions[r],e)}t.__esModule=!0,t.TaggedTemplateExpression=r,t.TemplateElement=n,t.TemplateLiteral=i},function(e,t,r){"use strict";function n(e,t){return b.isArrayTypeAnnotation(t)}function i(e,t){return b.isMemberExpression(t)&&t.object===e}function s(e,t,r){return v(r,{considerArrow:!0})}function a(e,t,r){return v(r)}function o(e,t){if((b.isCallExpression(t)||b.isNewExpression(t))&&t.callee===e||b.isUnaryLike(t)||b.isMemberExpression(t)&&t.object===e||b.isAwaitExpression(t))return!0;if(b.isBinary(t)){var r=t.operator,n=E[r],i=e.operator,s=E[i];if(n===s&&t.right===e&&!b.isLogicalExpression(t)||n>s)return!0}return!1}function u(e,t){return"in"===e.operator&&(b.isVariableDeclarator(t)||b.isFor(t))}function l(e,t){return!(b.isForStatement(t)||b.isThrowStatement(t)||b.isReturnStatement(t)||b.isIfStatement(t)&&t.test===e||b.isWhileStatement(t)&&t.test===e||b.isForInStatement(t)&&t.right===e||b.isSwitchStatement(t)&&t.discriminant===e||b.isExpressionStatement(t)&&t.expression===e)}function c(e,t){return b.isBinary(t)||b.isUnaryLike(t)||b.isCallExpression(t)||b.isMemberExpression(t)||b.isNewExpression(t)||b.isConditionalExpression(t)&&e===t.test}function f(e,t,r){return v(r,{considerDefaultExports:!0})}function p(e,t){return b.isMemberExpression(t,{object:e})||b.isCallExpression(t,{callee:e})||b.isNewExpression(t,{callee:e})}function d(e,t,r){return v(r,{considerDefaultExports:!0})}function h(e,t){return!!(b.isExportDeclaration(t)||b.isBinaryExpression(t)||b.isLogicalExpression(t)||b.isUnaryExpression(t)||b.isTaggedTemplateExpression(t))||p(e,t)}function m(e,t){return!!(b.isUnaryLike(t)||b.isBinary(t)||b.isConditionalExpression(t,{test:e})||b.isAwaitExpression(t))||p(e,t)}function y(e){return!!b.isObjectPattern(e.left)||m.apply(void 0,arguments)}function v(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.considerArrow,n=void 0!==r&&r,i=t.considerDefaultExports,s=void 0!==i&&i,a=e.length-1,o=e[a];a--;for(var u=e[a];a>0;){if(b.isExpressionStatement(u,{expression:o})||b.isTaggedTemplateExpression(u)||s&&b.isExportDefaultDeclaration(u,{declaration:o})||n&&b.isArrowFunctionExpression(u,{body:o}))return!0;if(!(b.isCallExpression(u,{callee:o})||b.isSequenceExpression(u)&&u.expressions[0]===o||b.isMemberExpression(u,{object:o})||b.isConditional(u,{test:o})||b.isBinary(u,{left:o})||b.isAssignmentExpression(u,{left:o})))return!1;o=u,a--,u=e[a]}return!1}t.__esModule=!0,t.AwaitExpression=t.FunctionTypeAnnotation=void 0,t.NullableTypeAnnotation=n,t.UpdateExpression=i,t.ObjectExpression=s,t.DoExpression=a,t.Binary=o,t.BinaryExpression=u,t.SequenceExpression=l,t.YieldExpression=c,t.ClassExpression=f,t.UnaryLike=p,t.FunctionExpression=d,t.ArrowFunctionExpression=h,t.ConditionalExpression=m,t.AssignmentExpression=y;var g=r(1),b=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(g),E={"||":0,"&&":1,"|":2,"^":3,"&":4,"==":5,"===":5,"!=":5,"!==":5,"<":6,">":6,"<=":6,">=":6,in:6,instanceof:6,">>":7,"<<":7,">>>":7,"+":8,"-":8,"*":9,"/":9,"%":9,"**":10};t.FunctionTypeAnnotation=n,t.AwaitExpression=c},function(e,t,r){"use strict";function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l.isMemberExpression(e)?(n(e.object,t),e.computed&&n(e.property,t)):l.isBinary(e)||l.isAssignmentExpression(e)?(n(e.left,t),n(e.right,t)):l.isCallExpression(e)?(t.hasCall=!0,n(e.callee,t)):l.isFunction(e)?t.hasFunction=!0:l.isIdentifier(e)&&(t.hasHelper=t.hasHelper||i(e.callee)),t}function i(e){return l.isMemberExpression(e)?i(e.object)||i(e.property):l.isIdentifier(e)?"require"===e.name||"_"===e.name[0]:l.isCallExpression(e)?i(e.callee):!(!l.isBinary(e)&&!l.isAssignmentExpression(e))&&(l.isIdentifier(e.left)&&i(e.left)||i(e.right))}function s(e){return l.isLiteral(e)||l.isObjectExpression(e)||l.isArrayExpression(e)||l.isIdentifier(e)||l.isMemberExpression(e)}var a=r(588),o=function(e){return e&&e.__esModule?e:{default:e}}(a),u=r(1),l=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(u);t.nodes={AssignmentExpression:function(e){var t=n(e.right);if(t.hasCall&&t.hasHelper||t.hasFunction)return{before:t.hasFunction,after:!0}},SwitchCase:function(e,t){return{before:e.consequent.length||t.cases[0]===e}},LogicalExpression:function(e){if(l.isFunction(e.left)||l.isFunction(e.right))return{after:!0}},Literal:function(e){if("use strict"===e.value)return{after:!0}},CallExpression:function(e){if(l.isFunction(e.callee)||i(e))return{before:!0,after:!0}},VariableDeclaration:function(e){for(var t=0;t<e.declarations.length;t++){var r=e.declarations[t],a=i(r.id)&&!s(r.init);if(!a){var o=n(r.init);a=i(r.init)&&o.hasCall||o.hasFunction}if(a)return{before:!0,after:!0}}},IfStatement:function(e){if(l.isBlockStatement(e.consequent))return{before:!0,after:!0}}},t.nodes.ObjectProperty=t.nodes.ObjectTypeProperty=t.nodes.ObjectMethod=t.nodes.SpreadProperty=function(e,t){if(t.properties[0]===e)return{before:!0}},t.list={VariableDeclaration:function(e){return(0,o.default)(e.declarations,"init")},ArrayExpression:function(e){return e.elements},ObjectExpression:function(e){return e.properties}},[["Function",!0],["Class",!0],["Loop",!0],["LabeledStatement",!0],["SwitchStatement",!0],["TryStatement",!0]].forEach(function(e){var r=e[0],n=e[1];"boolean"==typeof n&&(n={after:n,before:n}),[r].concat(l.FLIPPED_ALIAS_KEYS[r]||[]).forEach(function(e){t.nodes[e]=function(){return n}})})},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}function s(){this.token(","),this.space()}t.__esModule=!0;var a=r(87),o=i(a),u=r(2),l=i(u),c=r(35),f=i(c),p=r(365),d=i(p),h=r(3),m=i(h),y=r(579),v=i(y),g=r(581),b=i(g),E=r(586),x=i(E),A=r(278),S=i(A),_=r(300),D=i(_),C=r(187),w=n(C),P=r(314),k=i(P),F=r(1),T=n(F),O=/e/i,B=/\.0+$/,R=/^0[box]/,I=function(){function e(t,r,n){(0,m.default)(this,e),this.inForStatementInitCounter=0,this._printStack=[],this._indent=0,this._insideAux=!1,this._printedCommentStarts={},this._parenPushNewlineState=null,this._printAuxAfterOnNextUserNode=!1,this._printedComments=new d.default,this._endsWithInteger=!1,this._endsWithWord=!1,this.format=t||{},this._buf=new D.default(r),this._whitespace=n.length>0?new k.default(n):null}return e.prototype.generate=function(e){return this.print(e),this._maybeAddAuxComment(),this._buf.get()},e.prototype.indent=function(){this.format.compact||this.format.concise||this._indent++},e.prototype.dedent=function(){this.format.compact||this.format.concise||this._indent--},e.prototype.semicolon=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._maybeAddAuxComment(),this._append(";",!e)},e.prototype.rightBrace=function(){this.format.minified&&this._buf.removeLastSemicolon(),this.token("}")},e.prototype.space=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.format.compact||(this._buf.hasContent()&&!this.endsWith(" ")&&!this.endsWith("\n")||e)&&this._space()},e.prototype.word=function(e){this._endsWithWord&&this._space(),this._maybeAddAuxComment(),this._append(e),this._endsWithWord=!0},e.prototype.number=function(e){this.word(e),this._endsWithInteger=(0,x.default)(+e)&&!R.test(e)&&!O.test(e)&&!B.test(e)&&"."!==e[e.length-1]},e.prototype.token=function(e){("--"===e&&this.endsWith("!")||"+"===e[0]&&this.endsWith("+")||"-"===e[0]&&this.endsWith("-")||"."===e[0]&&this._endsWithInteger)&&this._space(),this._maybeAddAuxComment(),this._append(e)},e.prototype.newline=function(e){if(!this.format.retainLines&&!this.format.compact){if(this.format.concise)return void this.space();if(!(this.endsWith("\n\n")||("number"!=typeof e&&(e=1),e=Math.min(2,e),(this.endsWith("{\n")||this.endsWith(":\n"))&&e--,e<=0)))for(var t=0;t<e;t++)this._newline()}},e.prototype.endsWith=function(e){return this._buf.endsWith(e)},e.prototype.removeTrailingNewline=function(){this._buf.removeTrailingNewline()},e.prototype.source=function(e,t){this._catchUp(e,t),this._buf.source(e,t)},e.prototype.withSource=function(e,t,r){this._catchUp(e,t),this._buf.withSource(e,t,r)},e.prototype._space=function(){this._append(" ",!0)},e.prototype._newline=function(){this._append("\n",!0)},e.prototype._append=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._maybeAddParen(e),this._maybeIndent(e),t?this._buf.queue(e):this._buf.append(e),this._endsWithWord=!1,this._endsWithInteger=!1},e.prototype._maybeIndent=function(e){this._indent&&this.endsWith("\n")&&"\n"!==e[0]&&this._buf.queue(this._getIndent())},e.prototype._maybeAddParen=function(e){var t=this._parenPushNewlineState;if(t){this._parenPushNewlineState=null;var r=void 0;for(r=0;r<e.length&&" "===e[r];r++);if(r!==e.length){var n=e[r];"\n"!==n&&"/"!==n||(this.token("("),this.indent(),t.printed=!0)}}},e.prototype._catchUp=function(e,t){if(this.format.retainLines){var r=t?t[e]:null;if(r&&null!==r.line)for(var n=r.line-this._buf.getCurrentLine(),i=0;i<n;i++)this._newline()}},e.prototype._getIndent=function(){return(0,S.default)(this.format.indent.style,this._indent)},e.prototype.startTerminatorless=function(){return this._parenPushNewlineState={printed:!1}},e.prototype.endTerminatorless=function(e){e.printed&&(this.dedent(),this.newline(),this.token(")"))},e.prototype.print=function(e,t){var r=this;if(e){var n=this.format.concise;e._compact&&(this.format.concise=!0);if(!this[e.type])throw new ReferenceError("unknown node of type "+(0,f.default)(e.type)+" with constructor "+(0,f.default)(e&&e.constructor.name));this._printStack.push(e);var i=this._insideAux;this._insideAux=!e.loc,this._maybeAddAuxComment(this._insideAux&&!i);var s=w.needsParens(e,t,this._printStack);this.format.retainFunctionParens&&"FunctionExpression"===e.type&&e.extra&&e.extra.parenthesized&&(s=!0),s&&this.token("("),this._printLeadingComments(e,t);var a=T.isProgram(e)||T.isFile(e)?null:e.loc;this.withSource("start",a,function(){r[e.type](e,t)}),this._printTrailingComments(e,t),s&&this.token(")"),this._printStack.pop(),this.format.concise=n,this._insideAux=i}},e.prototype._maybeAddAuxComment=function(e){e&&this._printAuxBeforeComment(),this._insideAux||this._printAuxAfterComment()},e.prototype._printAuxBeforeComment=function(){if(!this._printAuxAfterOnNextUserNode){this._printAuxAfterOnNextUserNode=!0;var e=this.format.auxiliaryCommentBefore;e&&this._printComment({type:"CommentBlock",value:e})}},e.prototype._printAuxAfterComment=function(){if(this._printAuxAfterOnNextUserNode){this._printAuxAfterOnNextUserNode=!1;var e=this.format.auxiliaryCommentAfter;e&&this._printComment({type:"CommentBlock",value:e})}},e.prototype.getPossibleRaw=function(e){var t=e.extra;if(t&&null!=t.raw&&null!=t.rawValue&&e.value===t.rawValue)return t.raw},e.prototype.printJoin=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e&&e.length){r.indent&&this.indent();for(var n={addNewlines:r.addNewlines},i=0;i<e.length;i++){var s=e[i];s&&(r.statement&&this._printNewline(!0,s,t,n),this.print(s,t),r.iterator&&r.iterator(s,i),r.separator&&i<e.length-1&&r.separator.call(this),r.statement&&this._printNewline(!1,s,t,n))}r.indent&&this.dedent()}},e.prototype.printAndIndentOnComments=function(e,t){var r=!!e.leadingComments;r&&this.indent(),this.print(e,t),r&&this.dedent()},e.prototype.printBlock=function(e){var t=e.body;T.isEmptyStatement(t)||this.space(),this.print(t,e)},e.prototype._printTrailingComments=function(e,t){this._printComments(this._getComments(!1,e,t))},e.prototype._printLeadingComments=function(e,t){this._printComments(this._getComments(!0,e,t))},e.prototype.printInnerComments=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e.innerComments&&(t&&this.indent(),this._printComments(e.innerComments),t&&this.dedent())},e.prototype.printSequence=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return r.statement=!0,this.printJoin(e,t,r)},e.prototype.printList=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return null==r.separator&&(r.separator=s),this.printJoin(e,t,r)},e.prototype._printNewline=function(e,t,r,n){var i=this;if(!this.format.retainLines&&!this.format.compact){if(this.format.concise)return void this.space();var s=0;if(null!=t.start&&!t._ignoreUserWhitespace&&this._whitespace)if(e){var a=t.leadingComments,o=a&&(0,v.default)(a,function(e){ +return!!e.loc&&i.format.shouldPrintComment(e.value)});s=this._whitespace.getNewlinesBefore(o||t)}else{var u=t.trailingComments,l=u&&(0,b.default)(u,function(e){return!!e.loc&&i.format.shouldPrintComment(e.value)});s=this._whitespace.getNewlinesAfter(l||t)}else{e||s++,n.addNewlines&&(s+=n.addNewlines(e,t)||0);var c=w.needsWhitespaceAfter;e&&(c=w.needsWhitespaceBefore),c(t,r)&&s++,this._buf.hasContent()||(s=0)}this.newline(s)}},e.prototype._getComments=function(e,t){return t&&(e?t.leadingComments:t.trailingComments)||[]},e.prototype._printComment=function(e){var t=this;if(this.format.shouldPrintComment(e.value)&&!e.ignore&&!this._printedComments.has(e)){if(this._printedComments.add(e),null!=e.start){if(this._printedCommentStarts[e.start])return;this._printedCommentStarts[e.start]=!0}this.newline(this._whitespace?this._whitespace.getNewlinesBefore(e):0),this.endsWith("[")||this.endsWith("{")||this.space();var r="CommentLine"===e.type?"//"+e.value+"\n":"/*"+e.value+"*/";if("CommentBlock"===e.type&&this.format.indent.adjustMultilineComment){var n=e.loc&&e.loc.start.column;if(n){var i=new RegExp("\\n\\s{1,"+n+"}","g");r=r.replace(i,"\n")}var s=Math.max(this._getIndent().length,this._buf.getCurrentColumn());r=r.replace(/\n(?!$)/g,"\n"+(0,S.default)(" ",s))}this.withSource("start",e.loc,function(){t._append(r)}),this.newline((this._whitespace?this._whitespace.getNewlinesAfter(e):0)+("CommentLine"===e.type?-1:0))}},e.prototype._printComments=function(e){if(e&&e.length)for(var t=e,r=Array.isArray(t),n=0,t=r?t:(0,l.default)(t);;){var i;if(r){if(n>=t.length)break;i=t[n++]}else{if(n=t.next(),n.done)break;i=n.value}var s=i;this._printComment(s)}},e}();t.default=I;for(var M=[r(309),r(303),r(308),r(302),r(306),r(307),r(123),r(304),r(301),r(305)],N=0;N<M.length;N++){var L=M[N];(0,o.default)(I.prototype,L)}e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(14),s=n(i),a=r(11),o=n(a),u=r(3),l=n(u),c=r(288),f=n(c),p=function(){function e(t,r){(0,l.default)(this,e),this._cachedMap=null,this._code=r,this._opts=t,this._rawMappings=[]}return e.prototype.get=function(){if(!this._cachedMap){var e=this._cachedMap=new f.default.SourceMapGenerator({file:this._opts.sourceMapTarget,sourceRoot:this._opts.sourceRoot}),t=this._code;"string"==typeof t?e.setSourceContent(this._opts.sourceFileName,t):"object"===(void 0===t?"undefined":(0,o.default)(t))&&(0,s.default)(t).forEach(function(r){e.setSourceContent(r,t[r])}),this._rawMappings.forEach(e.addMapping,e)}return this._cachedMap.toJSON()},e.prototype.getRawMappings=function(){return this._rawMappings.slice()},e.prototype.mark=function(e,t,r,n,i,s){this._lastGenLine!==e&&null===r||this._lastGenLine===e&&this._lastSourceLine===r&&this._lastSourceColumn===n||(this._cachedMap=null,this._lastGenLine=e,this._lastSourceLine=r,this._lastSourceColumn=n,this._rawMappings.push({name:i||void 0,generated:{line:e,column:t},source:null==r?void 0:s||this._opts.sourceFileName,original:null==r?void 0:{line:r,column:n}}))},e}();t.default=p,e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0;var n=r(3),i=function(e){return e&&e.__esModule?e:{default:e}}(n),s=function(){function e(t){(0,i.default)(this,e),this.tokens=t,this.used={}}return e.prototype.getNewlinesBefore=function(e){var t=void 0,r=void 0,n=this.tokens,i=this._findToken(function(t){return t.start-e.start},0,n.length);if(i>=0){for(;i&&e.start===n[i-1].start;)--i;t=n[i-1],r=n[i]}return this._getNewlinesBetween(t,r)},e.prototype.getNewlinesAfter=function(e){var t=void 0,r=void 0,n=this.tokens,i=this._findToken(function(t){return t.end-e.end},0,n.length);if(i>=0){for(;i&&e.end===n[i-1].end;)--i;t=n[i],r=n[i+1],","===r.type.label&&(r=n[i+2])}return r&&"eof"===r.type.label?1:this._getNewlinesBetween(t,r)},e.prototype._getNewlinesBetween=function(e,t){if(!t||!t.loc)return 0;for(var r=e?e.loc.end.line:1,n=t.loc.start.line,i=0,s=r;s<n;s++)void 0===this.used[s]&&(this.used[s]=!0,i++);return i},e.prototype._findToken=function(e,t,r){if(t>=r)return-1;var n=t+r>>>1,i=e(this.tokens[n]);return i<0?this._findToken(e,n+1,r):i>0?this._findToken(e,t,n):0===i?n:-1},e}();t.default=s,e.exports=t.default},function(e,t,r){"use strict";function n(e){for(var t=e,r=Array.isArray(t),n=0,t=r?t:(0,s.default)(t);;){var i;if(r){if(n>=t.length)break;i=t[n++]}else{if(n=t.next(),n.done)break;i=n.value}var a=i,u=a.node,l=u.expression;if(o.isMemberExpression(l)){var c=a.scope.maybeGenerateMemoised(l.object),f=void 0,p=[];c?(f=c,p.push(o.assignmentExpression("=",c,l.object))):f=l.object,p.push(o.callExpression(o.memberExpression(o.memberExpression(f,l.property,l.computed),o.identifier("bind")),[f])),1===p.length?u.expression=p[0]:u.expression=o.sequenceExpression(p)}}}t.__esModule=!0;var i=r(2),s=function(e){return e&&e.__esModule?e:{default:e}}(i);t.default=n;var a=r(1),o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(a);e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(e){function t(t){return t&&t.operator===e.operator+"="}function r(e,t){return a.assignmentExpression("=",e,t)}var n={};return n.ExpressionStatement=function(n,s){if(!n.isCompletionRecord()){var o=n.node.expression;if(t(o)){var u=[],l=(0,i.default)(o.left,u,s,n.scope,!0);u.push(a.expressionStatement(r(l.ref,e.build(l.uid,o.right)))),n.replaceWithMultiple(u)}}},n.AssignmentExpression=function(n,s){var a=n.node,o=n.scope;if(t(a)){var u=[],l=(0,i.default)(a.left,u,s,o);u.push(r(l.ref,e.build(l.uid,a.right))),n.replaceWithMultiple(u)}},n.BinaryExpression=function(t){var r=t.node;r.operator===e.operator&&t.replaceWith(e.build(r.left,r.right))},n};var n=r(318),i=function(e){return e&&e.__esModule?e:{default:e}}(n),s=r(1),a=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(s);e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.scope,r=e.node,n=a.functionExpression(null,[],r.body,r.generator,r.async),s=n,u=[];(0,i.default)(e,function(e){return t.push({id:e})});var l={foundThis:!1,foundArguments:!1};e.traverse(o,l),l.foundArguments&&(s=a.memberExpression(n,a.identifier("apply")),u=[],l.foundThis&&u.push(a.thisExpression()),l.foundArguments&&(l.foundThis||u.push(a.nullLiteral()),u.push(a.identifier("arguments"))));var c=a.callExpression(s,u);return r.generator&&(c=a.yieldExpression(c,!0)),a.returnStatement(c)};var n=r(190),i=function(e){return e&&e.__esModule?e:{default:e}}(n),s=r(1),a=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(s),o={enter:function(e,t){e.isThisExpression()&&(t.foundThis=!0),e.isReferencedIdentifier({name:"arguments"})&&(t.foundArguments=!0)},Function:function(e){e.skip()}};e.exports=t.default},function(e,t,r){"use strict";function n(e,t,r,n){var i=void 0;if(a.isSuper(e))return e;if(a.isIdentifier(e)){if(n.hasBinding(e.name))return e;i=e}else{if(!a.isMemberExpression(e))throw new Error("We can't explode this node type "+e.type);if(i=e.object,a.isSuper(i)||a.isIdentifier(i)&&n.hasBinding(i.name))return i}var s=n.generateUidIdentifierBasedOnNode(i);return t.push(a.variableDeclaration("var",[a.variableDeclarator(s,i)])),s}function i(e,t,r,n){var i=e.property,s=a.toComputedKey(e,i);if(a.isLiteral(s)&&a.isPureish(s))return s;var o=n.generateUidIdentifierBasedOnNode(i);return t.push(a.variableDeclaration("var",[a.variableDeclarator(o,i)])),o}t.__esModule=!0,t.default=function(e,t,r,s,o){var u=void 0;u=a.isIdentifier(e)&&o?e:n(e,t,r,s);var l=void 0,c=void 0;if(a.isIdentifier(e))l=e,c=u;else{var f=i(e,t,r,s),p=e.computed||a.isLiteral(f);c=l=a.memberExpression(u,f,p)}return{uid:c,ref:l}};var s=r(1),a=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(s);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(2),s=n(i);t.default=function(e){function t(t){if(t.node&&!t.isPure()){var r=e.scope.generateDeclaredUidIdentifier();n.push(l.assignmentExpression("=",r,t.node)),t.replaceWith(r)}}function r(e){if(Array.isArray(e)&&e.length){e=e.reverse(),(0,o.default)(e);for(var r=e,n=Array.isArray(r),i=0,r=n?r:(0,s.default)(r);;){var a;if(n){if(i>=r.length)break;a=r[i++]}else{if(i=r.next(),i.done)break;a=i.value}t(a)}}}e.assertClass();var n=[];t(e.get("superClass")),r(e.get("decorators"));for(var i=e.get("body.body"),a=i,u=Array.isArray(a),c=0,a=u?a:(0,s.default)(a);;){var f;if(u){if(c>=a.length)break;f=a[c++]}else{if(c=a.next(),c.done)break;f=c.value}var p=f;p.is("computed")&&t(p.get("key")),p.has("decorators")&&r(e.get("decorators"))}n&&e.insertBefore(n.map(function(e){return l.expressionStatement(e)}))};var a=r(315),o=n(a),u=r(1),l=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(u);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.default=function(e,t){var r=e.node,n=e.scope,i=e.parent,a=n.generateUidIdentifier("step"),o=n.generateUidIdentifier("value"),u=r.left,p=void 0;s.isIdentifier(u)||s.isPattern(u)||s.isMemberExpression(u)?p=s.expressionStatement(s.assignmentExpression("=",u,o)):s.isVariableDeclaration(u)&&(p=s.variableDeclaration(u.kind,[s.variableDeclarator(u.declarations[0].id,o)]));var d=c();(0,l.default)(d,f,null,{ITERATOR_HAD_ERROR_KEY:n.generateUidIdentifier("didIteratorError"),ITERATOR_COMPLETION:n.generateUidIdentifier("iteratorNormalCompletion"),ITERATOR_ERROR_KEY:n.generateUidIdentifier("iteratorError"),ITERATOR_KEY:n.generateUidIdentifier("iterator"),GET_ITERATOR:t.getAsyncIterator,OBJECT:r.right,STEP_VALUE:o,STEP_KEY:a,AWAIT:t.wrapAwait}),d=d.body.body;var h=s.isLabeledStatement(i),m=d[3].block.body,y=m[0];return h&&(m[0]=s.labeledStatement(i.label,y)),{replaceParent:h,node:d,declar:p,loop:y}};var i=r(1),s=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(i),a=r(4),o=n(a),u=r(7),l=n(u),c=(0,o.default)("\n function* wrapper() {\n var ITERATOR_COMPLETION = true;\n var ITERATOR_HAD_ERROR_KEY = false;\n var ITERATOR_ERROR_KEY = undefined;\n try {\n for (\n var ITERATOR_KEY = GET_ITERATOR(OBJECT), STEP_KEY, STEP_VALUE;\n (\n STEP_KEY = yield AWAIT(ITERATOR_KEY.next()),\n ITERATOR_COMPLETION = STEP_KEY.done,\n STEP_VALUE = yield AWAIT(STEP_KEY.value),\n !ITERATOR_COMPLETION\n );\n ITERATOR_COMPLETION = true) {\n }\n } catch (err) {\n ITERATOR_HAD_ERROR_KEY = true;\n ITERATOR_ERROR_KEY = err;\n } finally {\n try {\n if (!ITERATOR_COMPLETION && ITERATOR_KEY.return) {\n yield AWAIT(ITERATOR_KEY.return());\n }\n } finally {\n if (ITERATOR_HAD_ERROR_KEY) {\n throw ITERATOR_ERROR_KEY;\n }\n }\n }\n }\n"),f={noScope:!0,Identifier:function(e,t){e.node.name in t&&e.replaceInline(t[e.node.name])},CallExpression:function(e,t){var r=e.node.callee;s.isIdentifier(r)&&"AWAIT"===r.name&&!t.AWAIT&&e.replaceWith(e.node.arguments[0])}};e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0;var n=r(4),i=function(e){return e&&e.__esModule?e:{default:e}}(n),s={};t.default=s,s.typeof=(0,i.default)('\n (typeof Symbol === "function" && typeof Symbol.iterator === "symbol")\n ? function (obj) { return typeof obj; }\n : function (obj) {\n return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype\n ? "symbol"\n : typeof obj;\n };\n'),s.jsx=(0,i.default)('\n (function () {\n var REACT_ELEMENT_TYPE = (typeof Symbol === "function" && Symbol.for && Symbol.for("react.element")) || 0xeac7;\n\n return function createRawReactElement (type, props, key, children) {\n var defaultProps = type && type.defaultProps;\n var childrenLength = arguments.length - 3;\n\n if (!props && childrenLength !== 0) {\n // If we\'re going to assign props.children, we create a new object now\n // to avoid mutating defaultProps.\n props = {};\n }\n if (props && defaultProps) {\n for (var propName in defaultProps) {\n if (props[propName] === void 0) {\n props[propName] = defaultProps[propName];\n }\n }\n } else if (!props) {\n props = defaultProps || {};\n }\n\n if (childrenLength === 1) {\n props.children = children;\n } else if (childrenLength > 1) {\n var childArray = Array(childrenLength);\n for (var i = 0; i < childrenLength; i++) {\n childArray[i] = arguments[i + 3];\n }\n props.children = childArray;\n }\n\n return {\n $$typeof: REACT_ELEMENT_TYPE,\n type: type,\n key: key === undefined ? null : \'\' + key,\n ref: null,\n props: props,\n _owner: null,\n };\n };\n\n })()\n'),s.asyncIterator=(0,i.default)('\n (function (iterable) {\n if (typeof Symbol === "function") {\n if (Symbol.asyncIterator) {\n var method = iterable[Symbol.asyncIterator];\n if (method != null) return method.call(iterable);\n }\n if (Symbol.iterator) {\n return iterable[Symbol.iterator]();\n }\n }\n throw new TypeError("Object is not async iterable");\n })\n'),s.asyncGenerator=(0,i.default)('\n (function () {\n function AwaitValue(value) {\n this.value = value;\n }\n\n function AsyncGenerator(gen) {\n var front, back;\n\n function send(key, arg) {\n return new Promise(function (resolve, reject) {\n var request = {\n key: key,\n arg: arg,\n resolve: resolve,\n reject: reject,\n next: null\n };\n\n if (back) {\n back = back.next = request;\n } else {\n front = back = request;\n resume(key, arg);\n }\n });\n }\n\n function resume(key, arg) {\n try {\n var result = gen[key](arg)\n var value = result.value;\n if (value instanceof AwaitValue) {\n Promise.resolve(value.value).then(\n function (arg) { resume("next", arg); },\n function (arg) { resume("throw", arg); });\n } else {\n settle(result.done ? "return" : "normal", result.value);\n }\n } catch (err) {\n settle("throw", err);\n }\n }\n\n function settle(type, value) {\n switch (type) {\n case "return":\n front.resolve({ value: value, done: true });\n break;\n case "throw":\n front.reject(value);\n break;\n default:\n front.resolve({ value: value, done: false });\n break;\n }\n\n front = front.next;\n if (front) {\n resume(front.key, front.arg);\n } else {\n back = null;\n }\n }\n\n this._invoke = send;\n\n // Hide "return" method if generator return is not supported\n if (typeof gen.return !== "function") {\n this.return = undefined;\n }\n }\n\n if (typeof Symbol === "function" && Symbol.asyncIterator) {\n AsyncGenerator.prototype[Symbol.asyncIterator] = function () { return this; };\n }\n\n AsyncGenerator.prototype.next = function (arg) { return this._invoke("next", arg); };\n AsyncGenerator.prototype.throw = function (arg) { return this._invoke("throw", arg); };\n AsyncGenerator.prototype.return = function (arg) { return this._invoke("return", arg); };\n\n return {\n wrap: function (fn) {\n return function () {\n return new AsyncGenerator(fn.apply(this, arguments));\n };\n },\n await: function (value) {\n return new AwaitValue(value);\n }\n };\n\n })()\n'),s.asyncGeneratorDelegate=(0,i.default)('\n (function (inner, awaitWrap) {\n var iter = {}, waiting = false;\n\n function pump(key, value) {\n waiting = true;\n value = new Promise(function (resolve) { resolve(inner[key](value)); });\n return { done: false, value: awaitWrap(value) };\n };\n\n if (typeof Symbol === "function" && Symbol.iterator) {\n iter[Symbol.iterator] = function () { return this; };\n }\n\n iter.next = function (value) {\n if (waiting) {\n waiting = false;\n return value;\n }\n return pump("next", value);\n };\n\n if (typeof inner.throw === "function") {\n iter.throw = function (value) {\n if (waiting) {\n waiting = false;\n throw value;\n }\n return pump("throw", value);\n };\n }\n\n if (typeof inner.return === "function") {\n iter.return = function (value) {\n return pump("return", value);\n };\n }\n\n return iter;\n })\n'),s.asyncToGenerator=(0,i.default)('\n (function (fn) {\n return function () {\n var gen = fn.apply(this, arguments);\n return new Promise(function (resolve, reject) {\n function step(key, arg) {\n try {\n var info = gen[key](arg);\n var value = info.value;\n } catch (error) {\n reject(error);\n return;\n }\n\n if (info.done) {\n resolve(value);\n } else {\n return Promise.resolve(value).then(function (value) {\n step("next", value);\n }, function (err) {\n step("throw", err);\n });\n }\n }\n\n return step("next");\n });\n };\n })\n'),s.classCallCheck=(0,i.default)('\n (function (instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError("Cannot call a class as a function");\n }\n });\n'),s.createClass=(0,i.default)('\n (function() {\n function defineProperties(target, props) {\n for (var i = 0; i < props.length; i ++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if ("value" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n }\n\n return function (Constructor, protoProps, staticProps) {\n if (protoProps) defineProperties(Constructor.prototype, protoProps);\n if (staticProps) defineProperties(Constructor, staticProps);\n return Constructor;\n };\n })()\n'),s.defineEnumerableProperties=(0,i.default)('\n (function (obj, descs) {\n for (var key in descs) {\n var desc = descs[key];\n desc.configurable = desc.enumerable = true;\n if ("value" in desc) desc.writable = true;\n Object.defineProperty(obj, key, desc);\n }\n return obj;\n })\n'),s.defaults=(0,i.default)("\n (function (obj, defaults) {\n var keys = Object.getOwnPropertyNames(defaults);\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n var value = Object.getOwnPropertyDescriptor(defaults, key);\n if (value && value.configurable && obj[key] === undefined) {\n Object.defineProperty(obj, key, value);\n }\n }\n return obj;\n })\n"),s.defineProperty=(0,i.default)("\n (function (obj, key, value) {\n // Shortcircuit the slow defineProperty path when possible.\n // We are trying to avoid issues where setters defined on the\n // prototype cause side effects under the fast path of simple\n // assignment. By checking for existence of the property with\n // the in operator, we can optimize most of this overhead away.\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n });\n"),s.extends=(0,i.default)("\n Object.assign || (function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n })\n"),s.get=(0,i.default)('\n (function get(object, property, receiver) {\n if (object === null) object = Function.prototype;\n\n var desc = Object.getOwnPropertyDescriptor(object, property);\n\n if (desc === undefined) {\n var parent = Object.getPrototypeOf(object);\n\n if (parent === null) {\n return undefined;\n } else {\n return get(parent, property, receiver);\n }\n } else if ("value" in desc) {\n return desc.value;\n } else {\n var getter = desc.get;\n\n if (getter === undefined) {\n return undefined;\n }\n\n return getter.call(receiver);\n }\n });\n'),s.inherits=(0,i.default)('\n (function (subClass, superClass) {\n if (typeof superClass !== "function" && superClass !== null) {\n throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);\n }\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;\n })\n'),s.instanceof=(0,i.default)('\n (function (left, right) {\n if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {\n return right[Symbol.hasInstance](left);\n } else {\n return left instanceof right;\n }\n });\n'),s.interopRequireDefault=(0,i.default)("\n (function (obj) {\n return obj && obj.__esModule ? obj : { default: obj };\n })\n"),s.interopRequireWildcard=(0,i.default)("\n (function (obj) {\n if (obj && obj.__esModule) {\n return obj;\n } else {\n var newObj = {};\n if (obj != null) {\n for (var key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];\n }\n }\n newObj.default = obj;\n return newObj;\n }\n })\n"),s.newArrowCheck=(0,i.default)('\n (function (innerThis, boundThis) {\n if (innerThis !== boundThis) {\n throw new TypeError("Cannot instantiate an arrow function");\n }\n });\n'),s.objectDestructuringEmpty=(0,i.default)('\n (function (obj) {\n if (obj == null) throw new TypeError("Cannot destructure undefined");\n });\n'),s.objectWithoutProperties=(0,i.default)("\n (function (obj, keys) {\n var target = {};\n for (var i in obj) {\n if (keys.indexOf(i) >= 0) continue;\n if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;\n target[i] = obj[i];\n }\n return target;\n })\n"),s.possibleConstructorReturn=(0,i.default)('\n (function (self, call) {\n if (!self) {\n throw new ReferenceError("this hasn\'t been initialised - super() hasn\'t been called");\n }\n return call && (typeof call === "object" || typeof call === "function") ? call : self;\n });\n'),s.selfGlobal=(0,i.default)('\n typeof global === "undefined" ? self : global\n'),s.set=(0,i.default)('\n (function set(object, property, value, receiver) {\n var desc = Object.getOwnPropertyDescriptor(object, property);\n\n if (desc === undefined) {\n var parent = Object.getPrototypeOf(object);\n\n if (parent !== null) {\n set(parent, property, value, receiver);\n }\n } else if ("value" in desc && desc.writable) {\n desc.value = value;\n } else {\n var setter = desc.set;\n\n if (setter !== undefined) {\n setter.call(receiver, value);\n }\n }\n\n return value;\n });\n'),s.slicedToArray=(0,i.default)('\n (function () {\n // Broken out into a separate function to avoid deoptimizations due to the try/catch for the\n // array iterator case.\n function sliceIterator(arr, i) {\n // this is an expanded form of `for...of` that properly supports abrupt completions of\n // iterators etc. variable names have been minimised to reduce the size of this massive\n // helper. sometimes spec compliancy is annoying :(\n //\n // _n = _iteratorNormalCompletion\n // _d = _didIteratorError\n // _e = _iteratorError\n // _i = _iterator\n // _s = _step\n\n var _arr = [];\n var _n = true;\n var _d = false;\n var _e = undefined;\n try {\n for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i["return"]) _i["return"]();\n } finally {\n if (_d) throw _e;\n }\n }\n return _arr;\n }\n\n return function (arr, i) {\n if (Array.isArray(arr)) {\n return arr;\n } else if (Symbol.iterator in Object(arr)) {\n return sliceIterator(arr, i);\n } else {\n throw new TypeError("Invalid attempt to destructure non-iterable instance");\n }\n };\n })();\n'),s.slicedToArrayLoose=(0,i.default)('\n (function (arr, i) {\n if (Array.isArray(arr)) {\n return arr;\n } else if (Symbol.iterator in Object(arr)) {\n var _arr = [];\n for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {\n _arr.push(_step.value);\n if (i && _arr.length === i) break;\n }\n return _arr;\n } else {\n throw new TypeError("Invalid attempt to destructure non-iterable instance");\n }\n });\n'),s.taggedTemplateLiteral=(0,i.default)("\n (function (strings, raw) {\n return Object.freeze(Object.defineProperties(strings, {\n raw: { value: Object.freeze(raw) }\n }));\n });\n"),s.taggedTemplateLiteralLoose=(0,i.default)("\n (function (strings, raw) {\n strings.raw = raw;\n return strings;\n });\n"),s.temporalRef=(0,i.default)('\n (function (val, name, undef) {\n if (val === undef) {\n throw new ReferenceError(name + " is not defined - temporal dead zone");\n } else {\n return val;\n }\n })\n'),s.temporalUndefined=(0,i.default)("\n ({})\n"),s.toArray=(0,i.default)("\n (function (arr) {\n return Array.isArray(arr) ? arr : Array.from(arr);\n });\n"),s.toConsumableArray=(0,i.default)("\n (function (arr) {\n if (Array.isArray(arr)) {\n for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];\n return arr2;\n } else {\n return Array.from(arr);\n }\n });\n"),e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(e){var t=e.types;return{pre:function(e){e.set("helpersNamespace",t.identifier("babelHelpers"))}}},e.exports=t.default},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=r(89);e.exports=function(e){var t=e.types,r={};return{visitor:{Identifier:function(e,s){if("MemberExpression"!==e.parent.type&&"ClassMethod"!==e.parent.type&&!e.isPure()&&s.opts.hasOwnProperty(e.node.name)){var a=s.opts[e.node.name];void 0!==a&&null!==a||(a=t.identifier(String(a)));var o=void 0===a?"undefined":n(a);"string"===o||"boolean"===o?a={type:o,replacement:a}:t.isNode(a)?a={type:"node",replacement:a}:"object"===o&&"node"===a.type&&"string"==typeof a.replacement&&(a.replacement=r[a.replacement]?r[a.replacement]:i.parseExpression(a.replacement));var u=a.replacement;switch(a.type){case"boolean":e.replaceWith(t.booleanLiteral(u));break;case"node":t.isNode(u)&&e.replaceWith(u);break;default:var l=String(u);e.replaceWith(t.stringLiteral(l))}}}}}}},function(e,t){"use strict";t.__esModule=!0,t.default=function(){return{manipulateOptions:function(e,t){t.plugins.push("dynamicImport")}}},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(){return{manipulateOptions:function(e,t){t.plugins.push("functionSent")}}},e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(){return{inherits:r(67)}},e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(e){var t=e.types,n={Function:function(e){e.skip()},YieldExpression:function(e,r){var n=e.node;if(n.delegate){var i=r.addHelper("asyncGeneratorDelegate");n.argument=t.callExpression(i,[t.callExpression(r.addHelper("asyncIterator"),[n.argument]),t.memberExpression(r.addHelper("asyncGenerator"),t.identifier("await"))])}}};return{inherits:r(195),visitor:{Function:function(e,r){e.node.async&&e.node.generator&&(e.traverse(n,r),(0,i.default)(e,r.file,{wrapAsync:t.memberExpression(r.addHelper("asyncGenerator"),t.identifier("wrap")),wrapAwait:t.memberExpression(r.addHelper("asyncGenerator"),t.identifier("await"))}))}}}};var n=r(124),i=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(){return{inherits:r(67),visitor:{Function:function(e,t){e.node.async&&!e.node.generator&&(0,i.default)(e,t.file,{wrapAsync:t.addImport(t.opts.module,t.opts.method)})}}}};var n=r(124),i=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){function t(e,t){if(!t.applyDecoratedDescriptor){t.applyDecoratedDescriptor=e.scope.generateUidIdentifier("applyDecoratedDescriptor");var r=f({NAME:t.applyDecoratedDescriptor});e.scope.getProgramParent().path.unshiftContainer("body",r)}return t.applyDecoratedDescriptor}function n(e,t){if(!t.initializerDefineProp){t.initializerDefineProp=e.scope.generateUidIdentifier("initDefineProp");var r=c({NAME:t.initializerDefineProp});e.scope.getProgramParent().path.unshiftContainer("body",r)}return t.initializerDefineProp}function i(e,t){if(!t.initializerWarningHelper){t.initializerWarningHelper=e.scope.generateUidIdentifier("initializerWarningHelper");var r=l({NAME:t.initializerWarningHelper});e.scope.getProgramParent().path.unshiftContainer("body",r)}return t.initializerWarningHelper}function p(e){var t=(e.isClass()?[e].concat(e.get("body.body")):e.get("properties")).reduce(function(e,t){return e.concat(t.node.decorators||[])},[]),r=t.filter(function(e){return!v.isIdentifier(e.expression)});if(0!==r.length)return v.sequenceExpression(r.map(function(t){var r=t.expression,n=t.expression=e.scope.generateDeclaredUidIdentifier("dec");return v.assignmentExpression("=",n,r)}).concat([e.node]))}function d(e,t){var r=e.node.decorators||[];if(e.node.decorators=null,0!==r.length){var n=e.scope.generateDeclaredUidIdentifier("class");return r.map(function(e){return e.expression}).reverse().reduce(function(e,t){return s({CLASS_REF:n,DECORATOR:t,INNER:e}).expression},e.node)}}function h(e,t){if(e.node.body.body.some(function(e){return(e.decorators||[]).length>0}))return y(e,t,e.node.body.body)}function m(e,t){if(e.node.properties.some(function(e){return(e.decorators||[]).length>0}))return y(e,t,e.node.properties)}function y(e,r,n){var s=(e.scope.generateDeclaredUidIdentifier("desc"),e.scope.generateDeclaredUidIdentifier("value"), +e.scope.generateDeclaredUidIdentifier(e.isClass()?"class":"obj")),l=n.reduce(function(n,l){var c=l.decorators||[];if(l.decorators=null,0===c.length)return n;if(l.computed)throw e.buildCodeFrameError("Computed method/property decorators are not yet supported.");var f=v.isLiteral(l.key)?l.key:v.stringLiteral(l.key.name),p=e.isClass()&&!l.static?a({CLASS_REF:s}).expression:s;if(v.isClassProperty(l,{static:!1})){var d=e.scope.generateDeclaredUidIdentifier("descriptor"),h=l.value?v.functionExpression(null,[],v.blockStatement([v.returnStatement(l.value)])):v.nullLiteral();l.value=v.callExpression(i(e,r),[d,v.thisExpression()]),n=n.concat([v.assignmentExpression("=",d,v.callExpression(t(e,r),[p,f,v.arrayExpression(c.map(function(e){return e.expression})),v.objectExpression([v.objectProperty(v.identifier("enumerable"),v.booleanLiteral(!0)),v.objectProperty(v.identifier("initializer"),h)])]))])}else n=n.concat(v.callExpression(t(e,r),[p,f,v.arrayExpression(c.map(function(e){return e.expression})),v.isObjectProperty(l)||v.isClassProperty(l,{static:!0})?u({TEMP:e.scope.generateDeclaredUidIdentifier("init"),TARGET:p,PROPERTY:f}).expression:o({TARGET:p,PROPERTY:f}).expression,p]));return n},[]);return v.sequenceExpression([v.assignmentExpression("=",s,e.node),v.sequenceExpression(l),s])}var v=e.types;return{inherits:r(125),visitor:{ExportDefaultDeclaration:function(e){if(e.get("declaration").isClassDeclaration()){var t=e.node,r=t.declaration.id||e.scope.generateUidIdentifier("default");t.declaration.id=r,e.replaceWith(t.declaration),e.insertAfter(v.exportNamedDeclaration(null,[v.exportSpecifier(r,v.identifier("default"))]))}},ClassDeclaration:function(e){var t=e.node,r=t.id||e.scope.generateUidIdentifier("class");e.replaceWith(v.variableDeclaration("let",[v.variableDeclarator(r,v.toExpression(t))]))},ClassExpression:function(e,t){var r=p(e)||d(e,t)||h(e,t);r&&e.replaceWith(r)},ObjectExpression:function(e,t){var r=p(e)||m(e,t);r&&e.replaceWith(r)},AssignmentExpression:function(e,t){t.initializerWarningHelper&&e.get("left").isMemberExpression()&&e.get("left.property").isIdentifier()&&e.get("right").isCallExpression()&&e.get("right.callee").isIdentifier({name:t.initializerWarningHelper.name})&&e.replaceWith(v.callExpression(n(e,t),[e.get("left.object").node,v.stringLiteral(e.get("left.property").node.name),e.get("right.arguments")[0].node,e.get("right.arguments")[1].node]))}}}};var n=r(4),i=function(e){return e&&e.__esModule?e:{default:e}}(n),s=(0,i.default)("\n DECORATOR(CLASS_REF = INNER) || CLASS_REF;\n"),a=(0,i.default)("\n CLASS_REF.prototype;\n"),o=(0,i.default)("\n Object.getOwnPropertyDescriptor(TARGET, PROPERTY);\n"),u=(0,i.default)("\n (TEMP = Object.getOwnPropertyDescriptor(TARGET, PROPERTY), (TEMP = TEMP ? TEMP.value : undefined), {\n enumerable: true,\n configurable: true,\n writable: true,\n initializer: function(){\n return TEMP;\n }\n })\n"),l=(0,i.default)("\n function NAME(descriptor, context){\n throw new Error('Decorating class property failed. Please ensure that transform-class-properties is enabled.');\n }\n"),c=(0,i.default)("\n function NAME(target, property, descriptor, context){\n if (!descriptor) return;\n\n Object.defineProperty(target, property, {\n enumerable: descriptor.enumerable,\n configurable: descriptor.configurable,\n writable: descriptor.writable,\n value: descriptor.initializer ? descriptor.initializer.call(context) : void 0,\n });\n }\n"),f=(0,i.default)("\n function NAME(target, property, decorators, descriptor, context){\n var desc = {};\n Object['ke' + 'ys'](descriptor).forEach(function(key){\n desc[key] = descriptor[key];\n });\n desc.enumerable = !!desc.enumerable;\n desc.configurable = !!desc.configurable;\n if ('value' in desc || desc.initializer){\n desc.writable = true;\n }\n\n desc = decorators.slice().reverse().reduce(function(desc, decorator){\n return decorator(target, property, desc) || desc;\n }, desc);\n\n if (context && desc.initializer !== void 0){\n desc.value = desc.initializer ? desc.initializer.call(context) : void 0;\n desc.initializer = undefined;\n }\n\n if (desc.initializer === void 0){\n // This is a hack to avoid this being processed by 'transform-runtime'.\n // See issue #9.\n Object['define' + 'Property'](target, property, desc);\n desc = null;\n }\n\n return desc;\n }\n")},function(e,t,r){"use strict";function n(e,t){var r=t._guessExecutionStatusRelativeTo(e);return"before"===r?"inside":"after"===r?"outside":"maybe"}function i(e,t){return o.callExpression(t.addHelper("temporalRef"),[e,o.stringLiteral(e.name),t.addHelper("temporalUndefined")])}function s(e,t,r){var n=r.letReferences[e.name];return!!n&&t.getBindingIdentifier(e.name)===n}t.__esModule=!0,t.visitor=void 0;var a=r(1),o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(a);t.visitor={ReferencedIdentifier:function(e,t){if(this.file.opts.tdz){var r=e.node,a=e.parent,u=e.scope;if(!e.parentPath.isFor({left:r})&&s(r,u,t)){var l=u.getBinding(r.name).path,c=n(e,l);if("inside"!==c)if("maybe"===c){var f=i(r,t.file);if(l.parent._tdzThis=!0,e.skip(),e.parentPath.isUpdateExpression()){if(a._ignoreBlockScopingTDZ)return;e.parentPath.replaceWith(o.sequenceExpression([f,a]))}else e.replaceWith(f)}else"outside"===c&&e.replaceWith(o.throwStatement(o.inherits(o.newExpression(o.identifier("ReferenceError"),[o.stringLiteral(r.name+" is not defined - temporal dead zone")]),r)))}}},AssignmentExpression:{exit:function(e,t){if(this.file.opts.tdz){var r=e.node;if(!r._ignoreBlockScopingTDZ){var n=[],a=e.getBindingIdentifiers();for(var u in a){var l=a[u];s(l,e.scope,t)&&n.push(i(l,t.file))}n.length&&(r._ignoreBlockScopingTDZ=!0,n.push(r),e.replaceWithMultiple(n.map(o.expressionStatement)))}}}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(3),s=n(i),a=r(42),o=n(a),u=r(41),l=n(u),c=r(40),f=n(c),p=r(207),d=n(p),h=r(1),m=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(h),y=function(e){function t(){(0,s.default)(this,t);var r=(0,o.default)(this,e.apply(this,arguments));return r.isLoose=!0,r}return(0,l.default)(t,e),t.prototype._processMethod=function(e,t){if(!e.decorators){var r=this.classRef;e.static||(r=m.memberExpression(r,m.identifier("prototype")));var n=m.memberExpression(r,e.key,e.computed||m.isLiteral(e.key)),i=m.functionExpression(null,e.params,e.body,e.generator,e.async);i.returnType=e.returnType;var s=m.toComputedKey(e,e.key);m.isStringLiteral(s)&&(i=(0,f.default)({node:i,id:s,scope:t}));var a=m.expressionStatement(m.assignmentExpression("=",n,i));return m.inheritsComments(a,e),this.body.push(a),!0}},t}(d.default);t.default=y,e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(e){var t=e.types;return{visitor:{BinaryExpression:function(e){var r=e.node;"instanceof"===r.operator&&e.replaceWith(t.callExpression(this.addHelper("instanceof"),[r.left,r.right]))}}}},e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){for(var t=e.params,r=Array.isArray(t),n=0,t=r?t:(0,o.default)(t);;){var i;if(r){if(n>=t.length)break;i=t[n++]}else{if(n=t.next(),n.done)break;i=n.value}var s=i;if(!m.isIdentifier(s))return!0}return!1}function s(e,t){if(!e.hasOwnBinding(t.name))return!0;var r=e.getOwnBinding(t.name),n=r.kind;return"param"===n||"local"===n}t.__esModule=!0,t.visitor=void 0;var a=r(2),o=n(a),u=r(189),l=n(u),c=r(317),f=n(c),p=r(4),d=n(p),h=r(1),m=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(h),y=(0,d.default)("\n let VARIABLE_NAME =\n ARGUMENTS.length > ARGUMENT_KEY && ARGUMENTS[ARGUMENT_KEY] !== undefined ?\n ARGUMENTS[ARGUMENT_KEY]\n :\n DEFAULT_VALUE;\n"),v=(0,d.default)("\n let $0 = $1[$2];\n"),g={ReferencedIdentifier:function(e,t){var r=e.scope,n=e.node;"eval"!==n.name&&s(r,n)||(t.iife=!0,e.stop())},Scope:function(e){e.skip()}};t.visitor={Function:function(e){var t=e.node,r=e.scope;if(i(t)){e.ensureBlock();var n={iife:!1,scope:r},a=[],o=m.identifier("arguments");o._shadowedFunctionLiteral=e;for(var u=(0,l.default)(t),c=e.get("params"),p=0;p<c.length;p++){var d=c[p];if(d.isAssignmentPattern()){var h=d.get("left"),b=d.get("right");if(p>=u||h.isPattern()){var E=r.generateUidIdentifier("x");E._isDefaultPlaceholder=!0,t.params[p]=E}else t.params[p]=h.node;n.iife||(b.isIdentifier()&&!s(r,b.node)?n.iife=!0:b.traverse(g,n)),function(e,r,n){var i=y({VARIABLE_NAME:e,DEFAULT_VALUE:r,ARGUMENT_KEY:m.numericLiteral(n),ARGUMENTS:o});i._blockHoist=t.params.length-n,a.push(i)}(h.node,b.node,p)}else n.iife||d.isIdentifier()||d.traverse(g,n)}for(var x=u+1;x<t.params.length;x++){var A=t.params[x];if(!A._isDefaultPlaceholder){var S=v(A,o,m.numericLiteral(x));S._blockHoist=t.params.length-x,a.push(S)}}t.params=t.params.slice(0,u),n.iife?(a.push((0,f.default)(e,r)),e.set("body",m.blockStatement(a))):e.get("body").unshiftContainer("body",a)}}}},function(e,t,r){"use strict";t.__esModule=!0,t.visitor=void 0;var n=r(1),i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(n);t.visitor={Function:function(e){for(var t=e.get("params"),r=i.isRestElement(t[t.length-1])?1:0,n=t.length-r,s=0;s<n;s++){var a=t[s];if(a.isArrayPattern()||a.isObjectPattern()){var o=e.scope.generateUidIdentifier("ref"),u=i.variableDeclaration("let",[i.variableDeclarator(a.node,o)]);u._blockHoist=n-s,e.ensureBlock(),e.get("body").unshiftContainer("body",u),a.replaceWith(o)}}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){return p.isRestElement(e.params[e.params.length-1])}function s(e,t,r){var n=void 0;n=p.isNumericLiteral(e.parent.property)?p.numericLiteral(e.parent.property.value+r):0===r?e.parent.property:p.binaryExpression("+",e.parent.property,p.numericLiteral(r));var i=e.scope;if(i.isPure(n))e.parentPath.replaceWith(h({ARGUMENTS:t,INDEX:n}));else{var s=i.generateUidIdentifierBasedOnNode(n);i.push({id:s,kind:"var"}),e.parentPath.replaceWith(m({ARGUMENTS:t,INDEX:n,REF:s}))}}function a(e,t,r){r?e.parentPath.replaceWith(y({ARGUMENTS:t,OFFSET:p.numericLiteral(r)})):e.replaceWith(t)}t.__esModule=!0,t.visitor=void 0;var o=r(2),u=n(o),l=r(4),c=n(l),f=r(1),p=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(f),d=(0,c.default)("\n for (var LEN = ARGUMENTS.length,\n ARRAY = Array(ARRAY_LEN),\n KEY = START;\n KEY < LEN;\n KEY++) {\n ARRAY[ARRAY_KEY] = ARGUMENTS[KEY];\n }\n"),h=(0,c.default)("\n ARGUMENTS.length <= INDEX ? undefined : ARGUMENTS[INDEX]\n"),m=(0,c.default)("\n REF = INDEX, ARGUMENTS.length <= REF ? undefined : ARGUMENTS[REF]\n"),y=(0,c.default)("\n ARGUMENTS.length <= OFFSET ? 0 : ARGUMENTS.length - OFFSET\n"),v={Scope:function(e,t){e.scope.bindingIdentifierEquals(t.name,t.outerBinding)||e.skip()},Flow:function(e){e.isTypeCastExpression()||e.skip()},"Function|ClassProperty":function(e,t){var r=t.noOptimise;t.noOptimise=!0,e.traverse(v,t),t.noOptimise=r,e.skip()},ReferencedIdentifier:function(e,t){var r=e.node;if("arguments"===r.name&&(t.deopted=!0),r.name===t.name)if(t.noOptimise)t.deopted=!0;else{var n=e.parentPath;if("params"===n.listKey&&n.key<t.offset)return;if(n.isMemberExpression({object:r})){var i=n.parentPath,s=!t.deopted&&!(i.isAssignmentExpression()&&n.node===i.node.left||i.isLVal()||i.isForXStatement()||i.isUpdateExpression()||i.isUnaryExpression({operator:"delete"})||(i.isCallExpression()||i.isNewExpression())&&n.node===i.node.callee);if(s)if(n.node.computed){if(n.get("property").isBaseType("number"))return void t.candidates.push({cause:"indexGetter",path:e})}else if("length"===n.node.property.name)return void t.candidates.push({cause:"lengthGetter",path:e})}if(0===t.offset&&n.isSpreadElement()){var a=n.parentPath;if(a.isCallExpression()&&1===a.node.arguments.length)return void t.candidates.push({cause:"argSpread",path:e})}t.references.push(e)}},BindingIdentifier:function(e,t){e.node.name===t.name&&(t.deopted=!0)}};t.visitor={Function:function(e){var t=e.node,r=e.scope;if(i(t)){var n=t.params.pop().argument,o=p.identifier("arguments");o._shadowedFunctionLiteral=e;var l={references:[],offset:t.params.length,argumentsNode:o,outerBinding:r.getBindingIdentifier(n.name),candidates:[],name:n.name,deopted:!1};if(e.traverse(v,l),l.deopted||l.references.length){l.references=l.references.concat(l.candidates.map(function(e){return e.path})),l.deopted=l.deopted||!!t.shadow;var c=p.numericLiteral(t.params.length),f=r.generateUidIdentifier("key"),h=r.generateUidIdentifier("len"),m=f,y=h;t.params.length&&(m=p.binaryExpression("-",f,c),y=p.conditionalExpression(p.binaryExpression(">",h,c),p.binaryExpression("-",h,c),p.numericLiteral(0)));var g=d({ARGUMENTS:o,ARRAY_KEY:m,ARRAY_LEN:y,START:c,ARRAY:n,KEY:f,LEN:h});if(l.deopted)g._blockHoist=t.params.length+1,t.body.body.unshift(g);else{g._blockHoist=1;var b=e.getEarliestCommonAncestorFrom(l.references).getStatementParent();b.findParent(function(e){if(!e.isLoop())return e.isFunction();b=e}),b.insertBefore(g)}}else for(var E=l.candidates,x=Array.isArray(E),A=0,E=x?E:(0,u.default)(E);;){var S;if(x){if(A>=E.length)break;S=E[A++]}else{if(A=E.next(),A.done)break;S=A.value}var _=S,D=_.path,C=_.cause;switch(C){case"indexGetter":s(D,o,l.offset);break;case"lengthGetter":a(D,o,l.offset);break;default:D.replaceWith(o)}}}}}},function(e,t){"use strict";t.__esModule=!0,t.default=function(e){var t=e.types;return{visitor:{MemberExpression:{exit:function(e){var r=e.node,n=r.property;r.computed||!t.isIdentifier(n)||t.isValidIdentifier(n.name)||(r.property=t.stringLiteral(n.name),r.computed=!0)}}}}},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(e){var t=e.types;return{visitor:{ObjectProperty:{exit:function(e){var r=e.node,n=r.key;r.computed||!t.isIdentifier(n)||t.isValidIdentifier(n.name)||(r.key=t.stringLiteral(n.name))}}}}},e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0;var n=r(2),i=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=function(e){var t=e.types;return{visitor:{ObjectExpression:function(e,r){for(var n=e.node,s=!1,o=n.properties,u=Array.isArray(o),l=0,o=u?o:(0,i.default)(o);;){var c;if(u){if(l>=o.length)break;c=o[l++]}else{if(l=o.next(),l.done)break;c=l.value}var f=c;if("get"===f.kind||"set"===f.kind){s=!0;break}}if(s){var p={};n.properties=n.properties.filter(function(e){return!!(e.computed||"get"!==e.kind&&"set"!==e.kind)||(a.push(p,e,null,r),!1)}),e.replaceWith(t.callExpression(t.memberExpression(t.identifier("Object"),t.identifier("defineProperties")),[n,a.toDefineObject(p)]))}}}}};var s=r(188),a=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(s);e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(e){var t=e.parse,r=e.traverse;return{visitor:{CallExpression:function(e){if(e.get("callee").isIdentifier({name:"eval"})&&1===e.node.arguments.length){var n=e.get("arguments")[0].evaluate();if(!n.confident)return;var i=n.value;if("string"!=typeof i)return;var s=t(i);return r.removeProperties(s),s.program}}}}},e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(e){function t(e,t){e.addComment("trailing",n(e,t)),e.replaceWith(i.noop())}function n(e,t){var r=e.getSource().replace(/\*-\//g,"*-ESCAPED/").replace(/\*\//g,"*-/");return t&&t.optional&&(r="?"+r),":"!==r[0]&&(r=":: "+r),r}var i=e.types;return{inherits:r(126),visitor:{TypeCastExpression:function(e){var t=e.node;e.get("expression").addComment("trailing",n(e.get("typeAnnotation"))),e.replaceWith(i.parenthesizedExpression(t.expression))},Identifier:function(e){var t=e.node;t.optional&&!t.typeAnnotation&&e.addComment("trailing",":: ?")},AssignmentPattern:{exit:function(e){e.node.left.optional=!1}},Function:{exit:function(e){e.node.params.forEach(function(e){return e.optional=!1})}},ClassProperty:function(e){var r=e.node,n=e.parent;r.value||t(e,n)},"ExportNamedDeclaration|Flow":function(e){var r=e.node,n=e.parent;i.isExportNamedDeclaration(r)&&!i.isFlow(r.declaration)||t(e,n)},ImportDeclaration:function(e){var r=e.node,n=e.parent;i.isImportDeclaration(r)&&"type"!==r.importKind&&"typeof"!==r.importKind||t(e,n)}}}},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(e){var t=e.types;return{visitor:{FunctionExpression:{exit:function(e){var r=e.node;r.id&&(r._ignoreUserWhitespace=!0,e.replaceWith(t.callExpression(t.functionExpression(null,[],t.blockStatement([t.toStatement(r),t.returnStatement(r.id)])),[])))}}}}},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(){return{visitor:{CallExpression:function(e,t){e.get("callee").matchesPattern("Object.assign")&&(e.node.callee=t.addHelper("extends"))}}}},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(){return{visitor:{CallExpression:function(e,t){e.get("callee").matchesPattern("Object.setPrototypeOf")&&(e.node.callee=t.addHelper("defaults"))}}}},e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(2),s=n(i);t.default=function(e){function t(e){return i.isLiteral(i.toComputedKey(e,e.key),{value:"__proto__"})}function r(e){var t=e.left;return i.isMemberExpression(t)&&i.isLiteral(i.toComputedKey(t,t.property),{value:"__proto__"})}function n(e,t,r){return i.expressionStatement(i.callExpression(r.addHelper("defaults"),[t,e.right]))}var i=e.types;return{visitor:{AssignmentExpression:function(e,t){if(r(e.node)){var s=[],a=e.node.left.object,o=e.scope.maybeGenerateMemoised(a);o&&s.push(i.expressionStatement(i.assignmentExpression("=",o,a))),s.push(n(e.node,o||a,t)),o&&s.push(o),e.replaceWithMultiple(s)}},ExpressionStatement:function(e,t){var s=e.node.expression;i.isAssignmentExpression(s,{operator:"="})&&r(s)&&e.replaceWith(n(s,s.left.object,t))},ObjectExpression:function(e,r){for(var n=void 0,a=e.node,u=a.properties,l=Array.isArray(u),c=0,u=l?u:(0,s.default)(u);;){var f;if(l){if(c>=u.length)break;f=u[c++]}else{if(c=u.next(),c.done)break;f=c.value}var p=f;t(p)&&(n=p.value,(0,o.default)(a.properties,p))}if(n){var d=[i.objectExpression([]),n];a.properties.length&&d.push(a),e.replaceWith(i.callExpression(r.addHelper("extends"),d))}}}}};var a=r(277),o=n(a);e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0;var n=r(11),i=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=function(e){var t=e.types,r={enter:function(e,r){var n=function(){r.isImmutable=!1,e.stop()};if(e.isJSXClosingElement())return void e.skip();if(e.isJSXIdentifier({name:"ref"})&&e.parentPath.isJSXAttribute({name:e.node}))return n();if(!(e.isJSXIdentifier()||e.isIdentifier()||e.isJSXMemberExpression()||e.isImmutable())){if(e.isPure()){var s=e.evaluate();if(s.confident){var a=s.value;if(!(a&&"object"===(void 0===a?"undefined":(0,i.default)(a))||"function"==typeof a))return}else if(t.isIdentifier(s.deopt))return}n()}}};return{visitor:{JSXElement:function(e){if(!e.node._hoisted){var t={isImmutable:!0};e.traverse(r,t),t.isImmutable?e.hoist():e.node._hoisted=!0}}}}},e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0;var n=r(2),i=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=function(e){function t(e){for(var t=0;t<e.length;t++){var n=e[t];if(s.isJSXSpreadAttribute(n))return!0;if(r(n,"ref"))return!0}return!1}function r(e,t){return s.isJSXAttribute(e)&&s.isJSXIdentifier(e.name,{name:t})}function n(e){var t=e.value;return t?(s.isJSXExpressionContainer(t)&&(t=t.expression),t):s.identifier("true")}var s=e.types;return{visitor:{JSXElement:function(e,a){var o=e.node,u=o.openingElement;if(!t(u.attributes)){var l=s.objectExpression([]),c=null,f=u.name;s.isJSXIdentifier(f)&&s.react.isCompatTag(f.name)&&(f=s.stringLiteral(f.name));for(var p=u.attributes,d=Array.isArray(p),h=0,p=d?p:(0,i.default)(p);;){var m;if(d){if(h>=p.length)break;m=p[h++]}else{if(h=p.next(),h.done)break;m=h.value}var y=m;if(r(y,"key"))c=n(y);else{var v=y.name.name,g=s.isValidIdentifier(v)?s.identifier(v):s.stringLiteral(v);!function(e,t,r){e.push(s.objectProperty(t,r))}(l.properties,g,n(y))}}var b=[f,l];if(c||o.children.length){var E=s.react.buildChildren(o);b.push.apply(b,[c||s.unaryExpression("void",s.numericLiteral(0),!0)].concat(E))}var x=s.callExpression(a.addHelper("jsx"),b);e.replaceWith(x)}}}}},e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(e){var t=e.types;return{manipulateOptions:function(e,t){t.plugins.push("jsx")},visitor:(0,i.default)({pre:function(e){e.callee=e.tagExpr},post:function(e){t.react.isCompatTag(e.tagName)&&(e.call=t.callExpression(t.memberExpression(t.memberExpression(t.identifier("React"),t.identifier("DOM")),e.tagExpr,t.isLiteral(e.tagExpr)),e.args))}})}};var n=r(348),i=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(e){function t(e,r){if(a.isJSXIdentifier(e)){if("this"===e.name&&a.isReferenced(e,r))return a.thisExpression();if(!i.default.keyword.isIdentifierNameES6(e.name))return a.stringLiteral(e.name);e.type="Identifier"}else if(a.isJSXMemberExpression(e))return a.memberExpression(t(e.object,e),t(e.property,e));return e}function r(e){return a.isJSXExpressionContainer(e)?e.expression:e}function n(e){var t=r(e.value||a.booleanLiteral(!0));return a.isStringLiteral(t)&&!a.isJSXExpressionContainer(e.value)&&(t.value=t.value.replace(/\n\s+/g," ")),a.isValidIdentifier(e.name.name)?e.name.type="Identifier":e.name=a.stringLiteral(e.name.name),a.inherits(a.objectProperty(e.name,t),e)}function s(r,n){r.parent.children=a.react.buildChildren(r.parent);var i=t(r.node.name,r.node),s=[],u=void 0;a.isIdentifier(i)?u=i.name:a.isLiteral(i)&&(u=i.value);var l={tagExpr:i,tagName:u,args:s};e.pre&&e.pre(l,n);var c=r.node.attributes;return c=c.length?o(c,n):a.nullLiteral(),s.push(c),e.post&&e.post(l,n),l.call||a.callExpression(l.callee,s)}function o(e,t){function r(){i.length&&(s.push(a.objectExpression(i)),i=[])}var i=[],s=[],o=t.opts.useBuiltIns||!1;if("boolean"!=typeof o)throw new Error("transform-react-jsx currently only accepts a boolean option for useBuiltIns (defaults to false)");for(;e.length;){var u=e.shift();a.isJSXSpreadAttribute(u)?(r(),s.push(u.argument)):i.push(n(u))}if(r(),1===s.length)e=s[0];else{a.isObjectExpression(s[0])||s.unshift(a.objectExpression([]));var l=o?a.memberExpression(a.identifier("Object"),a.identifier("assign")):t.addHelper("extends");e=a.callExpression(l,s)}return e}var u={};return u.JSXNamespacedName=function(e){throw e.buildCodeFrameError("Namespace tags are not supported. ReactJSX is not XML.")},u.JSXElement={exit:function(e,t){var r=s(e.get("openingElement"),t);r.arguments=r.arguments.concat(e.node.children),r.arguments.length>=3&&(r._prettyCall=!0),e.replaceWith(a.inherits(r,e.node))}},u};var n=r(97),i=function(e){return e&&e.__esModule?e:{default:e}}(n),s=r(1),a=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(s);e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(e){var t=e.types;return{visitor:{JSXOpeningElement:function(e){var n=e.node,i=t.jSXIdentifier(r),s=t.thisExpression();n.attributes.push(t.jSXAttribute(i,t.jSXExpressionContainer(s)))}}}};var r="__self";e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(e){function t(e,t){var r=null!=t?i.numericLiteral(t):i.nullLiteral(),n=i.objectProperty(i.identifier("fileName"),e),s=i.objectProperty(i.identifier("lineNumber"),r);return i.objectExpression([n,s])}var i=e.types;return{visitor:{JSXOpeningElement:function(e,s){var a=i.jSXIdentifier(r),o=e.container.openingElement.loc;if(o){for(var u=e.container.openingElement.attributes,l=0;l<u.length;l++){var c=u[l].name;if(c&&c.name===r)return}if(!s.fileNameIdentifier){var f="unknown"!==s.file.log.filename?s.file.log.filename:null,p=e.scope.generateUidIdentifier(n);e.hub.file.scope.push({id:p,init:i.stringLiteral(f)}),s.fileNameIdentifier=p}var d=t(s.fileNameIdentifier,o.start.line);u.push(i.jSXAttribute(a,i.jSXExpressionContainer(d)))}}}}};var r="__source",n="_jsxFileName";e.exports=t.default},348,function(e,t){"use strict";e.exports={builtins:{Symbol:"symbol",Promise:"promise",Map:"map",WeakMap:"weak-map",Set:"set",WeakSet:"weak-set",Observable:"observable",setImmediate:"set-immediate",clearImmediate:"clear-immediate",asap:"asap"},methods:{Array:{concat:"array/concat",copyWithin:"array/copy-within",entries:"array/entries",every:"array/every",fill:"array/fill",filter:"array/filter",findIndex:"array/find-index",find:"array/find",forEach:"array/for-each",from:"array/from",includes:"array/includes",indexOf:"array/index-of",join:"array/join",keys:"array/keys",lastIndexOf:"array/last-index-of",map:"array/map",of:"array/of",pop:"array/pop",push:"array/push",reduceRight:"array/reduce-right",reduce:"array/reduce",reverse:"array/reverse",shift:"array/shift",slice:"array/slice",some:"array/some",sort:"array/sort",splice:"array/splice",unshift:"array/unshift",values:"array/values"},JSON:{stringify:"json/stringify"},Object:{assign:"object/assign",create:"object/create",defineProperties:"object/define-properties",defineProperty:"object/define-property",entries:"object/entries",freeze:"object/freeze",getOwnPropertyDescriptor:"object/get-own-property-descriptor",getOwnPropertyDescriptors:"object/get-own-property-descriptors",getOwnPropertyNames:"object/get-own-property-names",getOwnPropertySymbols:"object/get-own-property-symbols",getPrototypeOf:"object/get-prototype-of",isExtensible:"object/is-extensible",isFrozen:"object/is-frozen",isSealed:"object/is-sealed",is:"object/is",keys:"object/keys",preventExtensions:"object/prevent-extensions",seal:"object/seal",setPrototypeOf:"object/set-prototype-of",values:"object/values"},RegExp:{escape:"regexp/escape"},Math:{acosh:"math/acosh",asinh:"math/asinh",atanh:"math/atanh",cbrt:"math/cbrt",clz32:"math/clz32",cosh:"math/cosh",expm1:"math/expm1",fround:"math/fround",hypot:"math/hypot",imul:"math/imul",log10:"math/log10",log1p:"math/log1p",log2:"math/log2",sign:"math/sign",sinh:"math/sinh",tanh:"math/tanh",trunc:"math/trunc",iaddh:"math/iaddh",isubh:"math/isubh",imulh:"math/imulh",umulh:"math/umulh"},Symbol:{for:"symbol/for",hasInstance:"symbol/has-instance",isConcatSpreadable:"symbol/is-concat-spreadable",iterator:"symbol/iterator",keyFor:"symbol/key-for",match:"symbol/match",replace:"symbol/replace",search:"symbol/search",species:"symbol/species",split:"symbol/split",toPrimitive:"symbol/to-primitive",toStringTag:"symbol/to-string-tag",unscopables:"symbol/unscopables"},String:{at:"string/at",codePointAt:"string/code-point-at",endsWith:"string/ends-with",fromCodePoint:"string/from-code-point",includes:"string/includes",matchAll:"string/match-all",padLeft:"string/pad-left",padRight:"string/pad-right",padStart:"string/pad-start",padEnd:"string/pad-end",raw:"string/raw",repeat:"string/repeat",startsWith:"string/starts-with",trim:"string/trim",trimLeft:"string/trim-left",trimRight:"string/trim-right",trimStart:"string/trim-start",trimEnd:"string/trim-end"},Number:{EPSILON:"number/epsilon",isFinite:"number/is-finite",isInteger:"number/is-integer",isNaN:"number/is-nan",isSafeInteger:"number/is-safe-integer",MAX_SAFE_INTEGER:"number/max-safe-integer",MIN_SAFE_INTEGER:"number/min-safe-integer",parseFloat:"number/parse-float",parseInt:"number/parse-int"},Reflect:{apply:"reflect/apply",construct:"reflect/construct",defineProperty:"reflect/define-property",deleteProperty:"reflect/delete-property",enumerate:"reflect/enumerate",getOwnPropertyDescriptor:"reflect/get-own-property-descriptor",getPrototypeOf:"reflect/get-prototype-of",get:"reflect/get",has:"reflect/has",isExtensible:"reflect/is-extensible",ownKeys:"reflect/own-keys",preventExtensions:"reflect/prevent-extensions",setPrototypeOf:"reflect/set-prototype-of",set:"reflect/set",defineMetadata:"reflect/define-metadata",deleteMetadata:"reflect/delete-metadata",getMetadata:"reflect/get-metadata",getMetadataKeys:"reflect/get-metadata-keys",getOwnMetadata:"reflect/get-own-metadata",getOwnMetadataKeys:"reflect/get-own-metadata-keys",hasMetadata:"reflect/has-metadata",hasOwnMetadata:"reflect/has-own-metadata",metadata:"reflect/metadata"},System:{global:"system/global"},Error:{isError:"error/is-error"},Date:{},Function:{}}}},function(e,t,r){"use strict";t.__esModule=!0,t.definitions=void 0,t.default=function(e){function t(e){return e.moduleName||"babel-runtime"}function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var n=e.types,s=["interopRequireWildcard","interopRequireDefault"];return{pre:function(e){var r=t(this.opts);!1!==this.opts.helpers&&e.set("helperGenerator",function(t){if(s.indexOf(t)<0)return e.addImport(r+"/helpers/"+t,"default",t)}),this.setDynamic("regeneratorIdentifier",function(){return e.addImport(r+"/regenerator","default","regeneratorRuntime")})},visitor:{ReferencedIdentifier:function(e,s){var a=e.node,o=e.parent,u=e.scope;if("regeneratorRuntime"===a.name&&!1!==s.opts.regenerator)return void e.replaceWith(s.get("regeneratorIdentifier"));if(!1!==s.opts.polyfill&&!n.isMemberExpression(o)&&r(i.default.builtins,a.name)&&!u.getBindingIdentifier(a.name)){var l=t(s.opts);e.replaceWith(s.addImport(l+"/core-js/"+i.default.builtins[a.name],"default",a.name))}},CallExpression:function(e,r){if(!1!==r.opts.polyfill&&!e.node.arguments.length){var i=e.node.callee;if(n.isMemberExpression(i)&&i.computed&&e.get("callee.property").matchesPattern("Symbol.iterator")){var s=t(r.opts);e.replaceWith(n.callExpression(r.addImport(s+"/core-js/get-iterator","default","getIterator"),[i.object]))}}},BinaryExpression:function(e,r){if(!1!==r.opts.polyfill&&"in"===e.node.operator&&e.get("left").matchesPattern("Symbol.iterator")){var i=t(r.opts);e.replaceWith(n.callExpression(r.addImport(i+"/core-js/is-iterable","default","isIterable"),[e.node.right]))}},MemberExpression:{enter:function(e,s){if(!1!==s.opts.polyfill&&e.isReferenced()){var a=e.node,o=a.object,u=a.property;if(n.isReferenced(o,a)&&!a.computed&&r(i.default.methods,o.name)){var l=i.default.methods[o.name];if(r(l,u.name)&&!e.scope.getBindingIdentifier(o.name)){if("Object"===o.name&&"defineProperty"===u.name&&e.parentPath.isCallExpression()){var c=e.parentPath.node;if(3===c.arguments.length&&n.isLiteral(c.arguments[1]))return}var f=t(s.opts);e.replaceWith(s.addImport(f+"/core-js/"+l[u.name],"default",o.name+"$"+u.name))}}}},exit:function(e,s){if(!1!==s.opts.polyfill&&e.isReferenced()){var a=e.node,o=a.object;if(r(i.default.builtins,o.name)&&!e.scope.getBindingIdentifier(o.name)){var u=t(s.opts);e.replaceWith(n.memberExpression(s.addImport(u+"/core-js/"+i.default.builtins[o.name],"default",o.name),a.property,a.computed))}}}}}}};var n=r(352),i=function(e){return e&&e.__esModule?e:{default:e}}(n);t.definitions=i.default},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(e){var t=e.messages;return{visitor:{ReferencedIdentifier:function(e){var r=e.node,n=e.scope,s=n.getBinding(r.name) +;if(s&&"type"===s.kind&&!e.parentPath.isFlow())throw e.buildCodeFrameError(t.get("undeclaredVariableType",r.name),ReferenceError);if(!n.hasBinding(r.name)){var a=n.getAllBindings(),o=void 0,u=-1;for(var l in a){var c=(0,i.default)(r.name,l);c<=0||c>3||(c<=u||(o=l,u=c))}var f=void 0;throw f=o?t.get("undeclaredVariableSuggestion",r.name,o):t.get("undeclaredVariable",r.name),e.buildCodeFrameError(f,ReferenceError)}}}}};var n=r(471),i=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=t.default},function(e,t,r){"use strict";t.__esModule=!0;var n=r(211),i=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default={plugins:[i.default]},e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.default=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return{presets:[!1!==t.es2015&&[s.default.buildPreset,t.es2015],!1!==t.es2016&&o.default,!1!==t.es2017&&l.default].filter(Boolean)}};var i=r(217),s=n(i),a=r(218),o=n(a),u=r(219),l=n(u);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(355),s=n(i),a=r(215),o=n(a),u=r(127),l=n(u),c=r(214),f=n(c);t.default={presets:[s.default],plugins:[o.default,l.default,f.default],env:{development:{plugins:[]}}},e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(220),s=n(i),a=r(206),o=n(a),u=r(212),l=n(u);t.default={presets:[s.default],plugins:[o.default,l.default]},e.exports=t.default},function(e,t,r){"use strict";e.exports={default:r(407),__esModule:!0}},function(e,t,r){"use strict";e.exports={default:r(410),__esModule:!0}},function(e,t,r){"use strict";e.exports={default:r(412),__esModule:!0}},function(e,t,r){"use strict";e.exports={default:r(413),__esModule:!0}},function(e,t,r){"use strict";e.exports={default:r(415),__esModule:!0}},function(e,t,r){"use strict";e.exports={default:r(416),__esModule:!0}},function(e,t,r){"use strict";e.exports={default:r(417),__esModule:!0}},function(e,t){"use strict";t.__esModule=!0,t.default=function(e,t){var r={};for(var n in e)t.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(2),s=n(i),a=r(3),o=n(a),u=r(36),l=n(u),c=r(1),f=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(c),p=function(){function e(t,r,n,i){(0,o.default)(this,e),this.queue=null,this.parentPath=i,this.scope=t,this.state=n,this.opts=r}return e.prototype.shouldVisit=function(e){var t=this.opts;if(t.enter||t.exit)return!0;if(t[e.type])return!0;var r=f.VISITOR_KEYS[e.type];if(!r||!r.length)return!1;for(var n=r,i=Array.isArray(n),a=0,n=i?n:(0,s.default)(n);;){var o;if(i){if(a>=n.length)break;o=n[a++]}else{if(a=n.next(),a.done)break;o=a.value}if(e[o])return!0}return!1},e.prototype.create=function(e,t,r,n){return l.default.get({parentPath:this.parentPath,parent:e,container:t,key:r,listKey:n})},e.prototype.maybeQueue=function(e,t){if(this.trap)throw new Error("Infinite cycle detected");this.queue&&(t?this.queue.push(e):this.priorityQueue.push(e))},e.prototype.visitMultiple=function(e,t,r){if(0===e.length)return!1;for(var n=[],i=0;i<e.length;i++){var s=e[i];s&&this.shouldVisit(s)&&n.push(this.create(t,e,i,r))}return this.visitQueue(n)},e.prototype.visitSingle=function(e,t){return!!this.shouldVisit(e[t])&&this.visitQueue([this.create(e,e,t)])},e.prototype.visitQueue=function(e){this.queue=e,this.priorityQueue=[];for(var t=[],r=!1,n=e,i=Array.isArray(n),a=0,n=i?n:(0,s.default)(n);;){var o;if(i){if(a>=n.length)break;o=n[a++]}else{if(a=n.next(),a.done)break;o=a.value}var u=o;if(u.resync(),0!==u.contexts.length&&u.contexts[u.contexts.length-1]===this||u.pushContext(this),null!==u.key&&!(t.indexOf(u.node)>=0)){if(t.push(u.node),u.visit()){r=!0;break}if(this.priorityQueue.length&&(r=this.visitQueue(this.priorityQueue),this.priorityQueue=[],this.queue=e,r))break}}for(var l=e,c=Array.isArray(l),f=0,l=c?l:(0,s.default)(l);;){var p;if(c){if(f>=l.length)break;p=l[f++]}else{if(f=l.next(),f.done)break;p=f.value}p.popContext()}return this.queue=null,r},e.prototype.visit=function(e,t){var r=e[t];return!!r&&(Array.isArray(r)?this.visitMultiple(r,e,t):this.visitSingle(e,t))},e}();t.default=p,e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){for(var t=this;t=t.parentPath;)if(e(t))return t;return null}function s(e){var t=this;do{if(e(t))return t}while(t=t.parentPath);return null}function a(){return this.findParent(function(e){return e.isFunction()||e.isProgram()})}function o(){var e=this;do{if(Array.isArray(e.container))return e}while(e=e.parentPath)}function u(e){return this.getDeepestCommonAncestorFrom(e,function(e,t,r){for(var n=void 0,i=g.VISITOR_KEYS[e.type],s=r,a=Array.isArray(s),o=0,s=a?s:(0,y.default)(s);;){var u;if(a){if(o>=s.length)break;u=s[o++]}else{if(o=s.next(),o.done)break;u=o.value}var l=u,c=l[t+1];if(n)if(c.listKey&&n.listKey===c.listKey&&c.key<n.key)n=c;else{var f=i.indexOf(n.parentKey),p=i.indexOf(c.parentKey);f>p&&(n=c)}else n=c}return n})}function l(e,t){var r=this;if(!e.length)return this;if(1===e.length)return e[0];var n=1/0,i=void 0,s=void 0,a=e.map(function(e){var t=[];do{t.unshift(e)}while((e=e.parentPath)&&e!==r);return t.length<n&&(n=t.length),t}),o=a[0];e:for(var u=0;u<n;u++){for(var l=o[u],c=a,f=Array.isArray(c),p=0,c=f?c:(0,y.default)(c);;){var d;if(f){if(p>=c.length)break;d=c[p++]}else{if(p=c.next(),p.done)break;d=p.value}var h=d;if(h[u]!==l)break e}i=u,s=l}if(s)return t?t(s,i,a):s;throw new Error("Couldn't find intersection")}function c(){var e=this,t=[];do{t.push(e)}while(e=e.parentPath);return t}function f(e){return e.isDescendant(this)}function p(e){return!!this.findParent(function(t){return t===e})}function d(){for(var e=this;e;){for(var t=arguments,r=Array.isArray(t),n=0,t=r?t:(0,y.default)(t);;){var i;if(r){if(n>=t.length)break;i=t[n++]}else{if(n=t.next(),n.done)break;i=n.value}var s=i;if(e.node.type===s)return!0}e=e.parentPath}return!1}function h(e){var t=this.isFunction()?this:this.findParent(function(e){return e.isFunction()});if(t){if(t.isFunctionExpression()||t.isFunctionDeclaration()){var r=t.node.shadow;if(r&&(!e||!1!==r[e]))return t}else if(t.isArrowFunctionExpression())return t;return null}}t.__esModule=!0;var m=r(2),y=n(m);t.findParent=i,t.find=s,t.getFunctionParent=a,t.getStatementParent=o,t.getEarliestCommonAncestorFrom=u,t.getDeepestCommonAncestorFrom=l,t.getAncestry=c,t.isAncestor=f,t.isDescendant=p,t.inType=d,t.inShadow=h;var v=r(1),g=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(v),b=r(36);n(b)},function(e,t){"use strict";function r(){if("string"!=typeof this.key){var e=this.node;if(e){var t=e.trailingComments,r=e.leadingComments;if(t||r){var n=this.getSibling(this.key-1),i=this.getSibling(this.key+1);n.node||(n=i),i.node||(i=n),n.addComments("trailing",r),i.addComments("leading",t)}}}}function n(e,t,r){this.addComments(e,[{type:r?"CommentLine":"CommentBlock",value:t}])}function i(e,t){if(t){var r=this.node;if(r){var n=e+"Comments";r[n]?r[n]=r[n].concat(t):r[n]=t}}}t.__esModule=!0,t.shareCommentsWithSiblings=r,t.addComment=n,t.addComments=i},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){var t=this.opts;return this.debug(function(){return e}),!(!this.node||!this._call(t[e]))||!!this.node&&this._call(t[this.node.type]&&t[this.node.type][e])}function s(e){if(!e)return!1;for(var t=e,r=Array.isArray(t),n=0,t=r?t:(0,D.default)(t);;){var i;if(r){if(n>=t.length)break;i=t[n++]}else{if(n=t.next(),n.done)break;i=n.value}var s=i;if(s){var a=this.node;if(!a)return!0;if(s.call(this.state,this,this.state))throw new Error("Unexpected return value from visitor method "+s);if(this.node!==a)return!0;if(this.shouldStop||this.shouldSkip||this.removed)return!0}}return!1}function a(){var e=this.opts.blacklist;return e&&e.indexOf(this.node.type)>-1}function o(){return!!this.node&&(!this.isBlacklisted()&&((!this.opts.shouldSkip||!this.opts.shouldSkip(this))&&(this.call("enter")||this.shouldSkip?(this.debug(function(){return"Skip..."}),this.shouldStop):(this.debug(function(){return"Recursing into..."}),w.default.node(this.node,this.opts,this.scope,this.state,this,this.skipKeys),this.call("exit"),this.shouldStop))))}function u(){this.shouldSkip=!0}function l(e){this.skipKeys[e]=!0}function c(){this.shouldStop=!0,this.shouldSkip=!0}function f(){if(!this.opts||!this.opts.noScope){var e=this.context&&this.context.scope;if(!e)for(var t=this.parentPath;t&&!e;){if(t.opts&&t.opts.noScope)return;e=t.scope,t=t.parentPath}this.scope=this.getScope(e),this.scope&&this.scope.init()}}function p(e){return this.shouldSkip=!1,this.shouldStop=!1,this.removed=!1,this.skipKeys={},e&&(this.context=e,this.state=e.state,this.opts=e.opts),this.setScope(),this}function d(){this.removed||(this._resyncParent(),this._resyncList(),this._resyncKey())}function h(){this.parentPath&&(this.parent=this.parentPath.node)}function m(){if(this.container&&this.node!==this.container[this.key]){if(Array.isArray(this.container)){for(var e=0;e<this.container.length;e++)if(this.container[e]===this.node)return this.setKey(e)}else for(var t in this.container)if(this.container[t]===this.node)return this.setKey(t);this.key=null}}function y(){if(this.parent&&this.inList){var e=this.parent[this.listKey];this.container!==e&&(this.container=e||null)}}function v(){null!=this.key&&this.container&&this.container[this.key]===this.node||this._markRemoved()}function g(){this.contexts.pop(),this.setContext(this.contexts[this.contexts.length-1])}function b(e){this.contexts.push(e),this.setContext(e)}function E(e,t,r,n){this.inList=!!r,this.listKey=r,this.parentKey=r||n,this.container=t,this.parentPath=e||this.parentPath,this.setKey(n)}function x(e){this.key=e,this.node=this.container[this.key],this.type=this.node&&this.node.type}function A(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this;if(!e.removed)for(var t=this.contexts,r=t,n=Array.isArray(r),i=0,r=n?r:(0,D.default)(r);;){var s;if(n){if(i>=r.length)break;s=r[i++]}else{if(i=r.next(),i.done)break;s=i.value}var a=s;a.maybeQueue(e)}}function S(){for(var e=this,t=this.contexts;!t.length;)e=e.parentPath,t=e.contexts;return t}t.__esModule=!0;var _=r(2),D=n(_);t.call=i,t._call=s,t.isBlacklisted=a,t.visit=o,t.skip=u,t.skipKey=l,t.stop=c,t.setScope=f,t.setContext=p,t.resync=d,t._resyncParent=h,t._resyncKey=m,t._resyncList=y,t._resyncRemoved=v,t.popContext=g,t.pushContext=b,t.setup=E,t.setKey=x,t.requeue=A,t._getQueueContexts=S;var C=r(7),w=n(C)},function(e,t,r){"use strict";function n(){var e=this.node,t=void 0;if(this.isMemberExpression())t=e.property;else{if(!this.isProperty()&&!this.isMethod())throw new ReferenceError("todo");t=e.key}return e.computed||o.isIdentifier(t)&&(t=o.stringLiteral(t.name)),t}function i(){return o.ensureBlock(this.node)}function s(){if(this.isArrowFunctionExpression()){this.ensureBlock();var e=this.node;e.expression=!1,e.type="FunctionExpression",e.shadow=e.shadow||!0}}t.__esModule=!0,t.toComputedKey=n,t.ensureBlock=i,t.arrowFunctionToShadowed=s;var a=r(1),o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(a)},function(e,t,r){(function(e){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(){var e=this.evaluate();if(e.confident)return!!e.value}function s(){function t(e){i&&(s=e,i=!1)}function r(e){var r=e.node;if(a.has(r)){var s=a.get(r);return s.resolved?s.value:void t(e)}var o={resolved:!1};a.set(r,o);var u=n(e);return i&&(o.resolved=!0,o.value=u),u}function n(n){if(i){var s=n.node;if(n.isSequenceExpression()){var a=n.get("expressions");return r(a[a.length-1])}if(n.isStringLiteral()||n.isNumericLiteral()||n.isBooleanLiteral())return s.value;if(n.isNullLiteral())return null;if(n.isTemplateLiteral()){for(var u="",c=0,f=n.get("expressions"),h=s.quasis,m=Array.isArray(h),y=0,h=m?h:(0,l.default)(h);;){var v;if(m){if(y>=h.length)break;v=h[y++]}else{if(y=h.next(),y.done)break;v=y.value}var g=v;if(!i)break;u+=g.value.cooked;var b=f[c++];b&&(u+=String(r(b)))}if(!i)return;return u}if(n.isConditionalExpression()){var E=r(n.get("test"));if(!i)return;return r(E?n.get("consequent"):n.get("alternate"))}if(n.isExpressionWrapper())return r(n.get("expression"));if(n.isMemberExpression()&&!n.parentPath.isCallExpression({callee:s})){var x=n.get("property"),A=n.get("object");if(A.isLiteral()&&x.isIdentifier()){var S=A.node.value,_=void 0===S?"undefined":(0,o.default)(S);if("number"===_||"string"===_)return S[x.node.name]}}if(n.isReferencedIdentifier()){var D=n.scope.getBinding(s.name);if(D&&D.constantViolations.length>0)return t(D.path);if(D&&n.node.start<D.path.node.end)return t(D.path);if(D&&D.hasValue)return D.value;if("undefined"===s.name)return D?t(D.path):void 0;if("Infinity"===s.name)return D?t(D.path):1/0;if("NaN"===s.name)return D?t(D.path):NaN;var C=n.resolve();return C===n?t(n):r(C)}if(n.isUnaryExpression({prefix:!0})){if("void"===s.operator)return;var w=n.get("argument");if("typeof"===s.operator&&(w.isFunction()||w.isClass()))return"function";var P=r(w);if(!i)return;switch(s.operator){case"!":return!P;case"+":return+P;case"-":return-P;case"~":return~P;case"typeof":return void 0===P?"undefined":(0,o.default)(P)}}if(n.isArrayExpression()){for(var k=[],F=n.get("elements"),T=F,O=Array.isArray(T),B=0,T=O?T:(0,l.default)(T);;){var R;if(O){if(B>=T.length)break;R=T[B++]}else{if(B=T.next(),B.done)break;R=B.value}var I=R;if(I=I.evaluate(),!I.confident)return t(I);k.push(I.value)}return k}if(n.isObjectExpression()){for(var M={},N=n.get("properties"),L=N,j=Array.isArray(L),U=0,L=j?L:(0,l.default)(L);;){var V;if(j){if(U>=L.length)break;V=L[U++]}else{if(U=L.next(),U.done)break;V=U.value}var G=V;if(G.isObjectMethod()||G.isSpreadProperty())return t(G);var W=G.get("key"),Y=W;if(G.node.computed){if(Y=Y.evaluate(),!Y.confident)return t(W);Y=Y.value}else Y=Y.isIdentifier()?Y.node.name:Y.node.value;var q=G.get("value"),K=q.evaluate();if(!K.confident)return t(q);K=K.value,M[Y]=K}return M}if(n.isLogicalExpression()){var H=i,J=r(n.get("left")),X=i;i=H;var z=r(n.get("right")),$=i;switch(i=X&&$,s.operator){case"||":if(J&&X)return i=!0,J;if(!i)return;return J||z;case"&&":if((!J&&X||!z&&$)&&(i=!0),!i)return;return J&&z}}if(n.isBinaryExpression()){var Q=r(n.get("left"));if(!i)return;var Z=r(n.get("right"));if(!i)return;switch(s.operator){case"-":return Q-Z;case"+":return Q+Z;case"/":return Q/Z;case"*":return Q*Z;case"%":return Q%Z;case"**":return Math.pow(Q,Z);case"<":return Q<Z;case">":return Q>Z;case"<=":return Q<=Z;case">=":return Q>=Z;case"==":return Q==Z;case"!=":return Q!=Z;case"===":return Q===Z;case"!==":return Q!==Z;case"|":return Q|Z;case"&":return Q&Z;case"^":return Q^Z;case"<<":return Q<<Z;case">>":return Q>>Z;case">>>":return Q>>>Z}}if(n.isCallExpression()){var ee=n.get("callee"),te=void 0,re=void 0;if(ee.isIdentifier()&&!n.scope.getBinding(ee.node.name,!0)&&p.indexOf(ee.node.name)>=0&&(re=e[s.callee.name]),ee.isMemberExpression()){var ne=ee.get("object"),ie=ee.get("property");if(ne.isIdentifier()&&ie.isIdentifier()&&p.indexOf(ne.node.name)>=0&&d.indexOf(ie.node.name)<0&&(te=e[ne.node.name],re=te[ie.node.name]),ne.isLiteral()&&ie.isIdentifier()){var se=(0,o.default)(ne.node.value);"string"!==se&&"number"!==se||(te=ne.node.value,re=te[ie.node.name])}}if(re){var ae=n.get("arguments").map(r);if(!i)return;return re.apply(te,ae)}}t(n)}}var i=!0,s=void 0,a=new f.default,u=r(this);return i||(u=void 0),{confident:i,deopt:s,value:u}}t.__esModule=!0;var a=r(11),o=n(a),u=r(2),l=n(u),c=r(133),f=n(c);t.evaluateTruthy=i,t.evaluate=s;var p=["String","Number","Math"],d=["random"]}).call(t,function(){return this}())},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(){var e=this;do{if(!e.parentPath||Array.isArray(e.container)&&e.isStatement())break;e=e.parentPath}while(e);if(e&&(e.isProgram()||e.isFile()))throw new Error("File/Program node, we can't possibly find a statement parent to this");return e}function s(){return"left"===this.key?this.getSibling("right"):"right"===this.key?this.getSibling("left"):void 0}function a(){var e=[],t=function(t){t&&(e=e.concat(t.getCompletionRecords()))};if(this.isIfStatement())t(this.get("consequent")),t(this.get("alternate"));else if(this.isDoExpression()||this.isFor()||this.isWhile())t(this.get("body"));else if(this.isProgram()||this.isBlockStatement())t(this.get("body").pop());else{if(this.isFunction())return this.get("body").getCompletionRecords();this.isTryStatement()?(t(this.get("block")),t(this.get("handler")),t(this.get("finalizer"))):e.push(this)}return e}function o(e){return _.default.get({parentPath:this.parentPath,parent:this.parent,container:this.container,listKey:this.listKey,key:e})}function u(){return this.getSibling(this.key-1)}function l(){return this.getSibling(this.key+1)}function c(){for(var e=this.key,t=this.getSibling(++e),r=[];t.node;)r.push(t),t=this.getSibling(++e);return r}function f(){for(var e=this.key,t=this.getSibling(--e),r=[];t.node;)r.push(t),t=this.getSibling(--e);return r}function p(e,t){!0===t&&(t=this.context);var r=e.split(".");return 1===r.length?this._getKey(e,t):this._getPattern(r,t)}function d(e,t){var r=this,n=this.node,i=n[e];return Array.isArray(i)?i.map(function(s,a){return _.default.get({listKey:e,parentPath:r,parent:n,container:i,key:a}).setContext(t)}):_.default.get({parentPath:this,parent:n,container:n,key:e}).setContext(t)}function h(e,t){for(var r=this,n=e,i=Array.isArray(n),s=0,n=i?n:(0,A.default)(n);;){var a;if(i){if(s>=n.length)break;a=n[s++]}else{if(s=n.next(),s.done)break;a=s.value}var o=a;r="."===o?r.parentPath:Array.isArray(r)?r[o]:r.get(o,t)}return r}function m(e){return C.getBindingIdentifiers(this.node,e)}function y(e){return C.getOuterBindingIdentifiers(this.node,e)}function v(){for(var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this,n=[].concat(r),i=(0,E.default)(null);n.length;){var s=n.shift();if(s&&s.node){var a=C.getBindingIdentifiers.keys[s.node.type];if(s.isIdentifier())if(e){var o=i[s.node.name]=i[s.node.name]||[];o.push(s)}else i[s.node.name]=s;else if(s.isExportDeclaration()){var u=s.get("declaration");u.isDeclaration()&&n.push(u)}else{if(t){if(s.isFunctionDeclaration()){n.push(s.get("id"));continue}if(s.isFunctionExpression())continue}if(a)for(var l=0;l<a.length;l++){var c=a[l],f=s.get(c);(Array.isArray(f)||f.node)&&(n=n.concat(f))}}}}return i}function g(e){return this.getBindingIdentifierPaths(e,!0)}t.__esModule=!0;var b=r(9),E=n(b),x=r(2),A=n(x);t.getStatementParent=i,t.getOpposite=s,t.getCompletionRecords=a,t.getSibling=o,t.getPrevSibling=u,t.getNextSibling=l,t.getAllNextSiblings=c,t.getAllPrevSiblings=f,t.get=p,t._getKey=d,t._getPattern=h,t.getBindingIdentifiers=m,t.getOuterBindingIdentifiers=y,t.getBindingIdentifierPaths=v,t.getOuterBindingIdentifierPaths=g;var S=r(36),_=n(S),D=r(1),C=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(D)},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function i(){if(this.typeAnnotation)return this.typeAnnotation;var e=this._getTypeAnnotation()||y.anyTypeAnnotation();return y.isTypeAnnotation(e)&&(e=e.typeAnnotation),this.typeAnnotation=e}function s(){var e=this.node;{if(e){if(e.typeAnnotation)return e.typeAnnotation;var t=h[e.type];return t?t.call(this,e):(t=h[this.parentPath.type],t&&t.validParent?this.parentPath.getTypeAnnotation():void 0)}if("init"===this.key&&this.parentPath.isVariableDeclarator()){var r=this.parentPath.parentPath,n=r.parentPath;return"left"===r.key&&n.isForInStatement()?y.stringTypeAnnotation():"left"===r.key&&n.isForOfStatement()?y.anyTypeAnnotation():y.voidTypeAnnotation()}}}function a(e,t){return o(e,this.getTypeAnnotation(),t)}function o(e,t,r){if("string"===e)return y.isStringTypeAnnotation(t);if("number"===e)return y.isNumberTypeAnnotation(t);if("boolean"===e)return y.isBooleanTypeAnnotation(t);if("any"===e)return y.isAnyTypeAnnotation(t);if("mixed"===e)return y.isMixedTypeAnnotation(t);if("empty"===e)return y.isEmptyTypeAnnotation(t);if("void"===e)return y.isVoidTypeAnnotation(t);if(r)return!1;throw new Error("Unknown base type "+e)}function u(e){var t=this.getTypeAnnotation();if(y.isAnyTypeAnnotation(t))return!0;if(y.isUnionTypeAnnotation(t)){for(var r=t.types,n=Array.isArray(r),i=0,r=n?r:(0,p.default)(r);;){var s;if(n){if(i>=r.length)break;s=r[i++]}else{if(i=r.next(),i.done)break;s=i.value}var a=s;if(y.isAnyTypeAnnotation(a)||o(e,a,!0))return!0}return!1}return o(e,t,!0)}function l(e){var t=this.getTypeAnnotation();if(e=e.getTypeAnnotation(),!y.isAnyTypeAnnotation(t)&&y.isFlowBaseAnnotation(t))return e.type===t.type}function c(e){var t=this.getTypeAnnotation();return y.isGenericTypeAnnotation(t)&&y.isIdentifier(t.id,{name:e})}t.__esModule=!0;var f=r(2),p=function(e){return e&&e.__esModule?e:{default:e}}(f);t.getTypeAnnotation=i,t._getTypeAnnotation=s,t.isBaseType=a,t.couldBeBaseType=u,t.baseTypeStrictlyMatches=l,t.isGenericType=c;var d=r(376),h=n(d),m=r(1),y=n(m)},function(e,t,r){"use strict";function n(e,t){var r=e.scope.getBinding(t),n=[];e.typeAnnotation=f.unionTypeAnnotation(n);var s=[],a=i(r,e,s),u=o(e,t);if(u){var c=i(r,u.ifStatement);a=a.filter(function(e){return c.indexOf(e)<0}),n.push(u.typeAnnotation)}if(a.length){a=a.concat(s);for(var p=a,d=Array.isArray(p),h=0,p=d?p:(0,l.default)(p);;){var m;if(d){if(h>=p.length)break;m=p[h++]}else{if(h=p.next(),h.done)break;m=h.value}var y=m;n.push(y.getTypeAnnotation())}}if(n.length)return f.createUnionTypeAnnotation(n)}function i(e,t,r){var n=e.constantViolations.slice();return n.unshift(e.path),n.filter(function(e){e=e.resolve();var n=e._guessExecutionStatusRelativeTo(t);return r&&"function"===n&&r.push(e),"before"===n})}function s(e,t){var r=t.node.operator,n=t.get("right").resolve(),i=t.get("left").resolve(),s=void 0;if(i.isIdentifier({name:e})?s=n:n.isIdentifier({name:e})&&(s=i),s)return"==="===r?s.getTypeAnnotation():f.BOOLEAN_NUMBER_BINARY_OPERATORS.indexOf(r)>=0?f.numberTypeAnnotation():void 0;if("==="===r){var a=void 0,o=void 0;if(i.isUnaryExpression({operator:"typeof"})?(a=i,o=n):n.isUnaryExpression({operator:"typeof"})&&(a=n,o=i),(o||a)&&(o=o.resolve(),o.isLiteral())){if("string"==typeof o.node.value&&a.get("argument").isIdentifier({name:e}))return f.createTypeAnnotationBasedOnTypeof(o.node.value)}}}function a(e){for(var t=void 0;t=e.parentPath;){if(t.isIfStatement()||t.isConditionalExpression())return"test"===e.key?void 0:t;e=t}}function o(e,t){var r=a(e);if(r){var n=r.get("test"),i=[n],u=[];do{var l=i.shift().resolve();if(l.isLogicalExpression()&&(i.push(l.get("left")),i.push(l.get("right"))),l.isBinaryExpression()){var c=s(t,l);c&&u.push(c)}}while(i.length);return u.length?{typeAnnotation:f.createUnionTypeAnnotation(u),ifStatement:r}:o(r,t)}}t.__esModule=!0;var u=r(2),l=function(e){return e&&e.__esModule?e:{default:e}}(u);t.default=function(e){if(this.isReferenced()){var t=this.scope.getBinding(e.name);return t?t.identifier.typeAnnotation?t.identifier.typeAnnotation:n(this,e.name):"undefined"===e.name?f.voidTypeAnnotation():"NaN"===e.name||"Infinity"===e.name?f.numberTypeAnnotation():void e.name}};var c=r(1),f=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(c);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(){return this.get("id").isIdentifier()?this.get("init").getTypeAnnotation():void 0}function s(e){return e.typeAnnotation}function a(e){if(this.get("callee").isIdentifier())return k.genericTypeAnnotation(e.callee)}function o(){return k.stringTypeAnnotation()}function u(e){var t=e.operator;return"void"===t?k.voidTypeAnnotation():k.NUMBER_UNARY_OPERATORS.indexOf(t)>=0?k.numberTypeAnnotation():k.STRING_UNARY_OPERATORS.indexOf(t)>=0?k.stringTypeAnnotation():k.BOOLEAN_UNARY_OPERATORS.indexOf(t)>=0?k.booleanTypeAnnotation():void 0}function l(e){var t=e.operator;if(k.NUMBER_BINARY_OPERATORS.indexOf(t)>=0)return k.numberTypeAnnotation();if(k.BOOLEAN_BINARY_OPERATORS.indexOf(t)>=0)return k.booleanTypeAnnotation();if("+"===t){var r=this.get("right"),n=this.get("left");return n.isBaseType("number")&&r.isBaseType("number")?k.numberTypeAnnotation():n.isBaseType("string")||r.isBaseType("string")?k.stringTypeAnnotation():k.unionTypeAnnotation([k.stringTypeAnnotation(),k.numberTypeAnnotation()])}}function c(){return k.createUnionTypeAnnotation([this.get("left").getTypeAnnotation(),this.get("right").getTypeAnnotation()])}function f(){return k.createUnionTypeAnnotation([this.get("consequent").getTypeAnnotation(),this.get("alternate").getTypeAnnotation()])}function p(){return this.get("expressions").pop().getTypeAnnotation()}function d(){return this.get("right").getTypeAnnotation()}function h(e){var t=e.operator;if("++"===t||"--"===t)return k.numberTypeAnnotation()}function m(){return k.stringTypeAnnotation()}function y(){return k.numberTypeAnnotation()}function v(){return k.booleanTypeAnnotation()}function g(){return k.nullLiteralTypeAnnotation()}function b(){return k.genericTypeAnnotation(k.identifier("RegExp"))}function E(){return k.genericTypeAnnotation(k.identifier("Object"))}function x(){return k.genericTypeAnnotation(k.identifier("Array"))}function A(){return x()}function S(){return k.genericTypeAnnotation(k.identifier("Function"))}function _(){return C(this.get("callee"))}function D(){return C(this.get("tag"))}function C(e){if(e=e.resolve(),e.isFunction()){if(e.is("async"))return e.is("generator")?k.genericTypeAnnotation(k.identifier("AsyncIterator")):k.genericTypeAnnotation(k.identifier("Promise"));if(e.node.returnType)return e.node.returnType}}t.__esModule=!0,t.ClassDeclaration=t.ClassExpression=t.FunctionDeclaration=t.ArrowFunctionExpression=t.FunctionExpression=t.Identifier=void 0;var w=r(375);Object.defineProperty(t,"Identifier",{enumerable:!0,get:function(){return n(w).default}}),t.VariableDeclarator=i,t.TypeCastExpression=s,t.NewExpression=a,t.TemplateLiteral=o,t.UnaryExpression=u,t.BinaryExpression=l,t.LogicalExpression=c,t.ConditionalExpression=f,t.SequenceExpression=p,t.AssignmentExpression=d,t.UpdateExpression=h,t.StringLiteral=m,t.NumericLiteral=y,t.BooleanLiteral=v,t.NullLiteral=g,t.RegExpLiteral=b,t.ObjectExpression=E,t.ArrayExpression=x,t.RestElement=A,t.CallExpression=_,t.TaggedTemplateExpression=D;var P=r(1),k=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(P);s.validParent=!0,A.validParent=!0,t.FunctionExpression=S,t.ArrowFunctionExpression=S,t.FunctionDeclaration=S,t.ClassExpression=S,t.ClassDeclaration=S},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){function r(e){var t=n[s];return"*"===t||e===t}if(!this.isMemberExpression())return!1;for(var n=e.split("."),i=[this.node],s=0;i.length;){var a=i.shift();if(t&&s===n.length)return!0;if(C.isIdentifier(a)){if(!r(a.name))return!1}else if(C.isLiteral(a)){if(!r(a.value))return!1}else{if(C.isMemberExpression(a)){if(a.computed&&!C.isLiteral(a.property))return!1;i.unshift(a.property),i.unshift(a.object);continue}if(!C.isThisExpression(a))return!1;if(!r("this"))return!1}if(++s>n.length)return!1}return s===n.length}function s(e){var t=this.node&&this.node[e];return t&&Array.isArray(t)?!!t.length:!!t}function a(){return this.scope.isStatic(this.node)}function o(e){return!this.has(e)}function u(e,t){return this.node[e]===t}function l(e){return C.isType(this.type,e)}function c(){return("init"===this.key||"left"===this.key)&&this.parentPath.isFor()}function f(e){return!("body"!==this.key||!this.parentPath.isArrowFunctionExpression())&&(this.isExpression()?C.isBlockStatement(e):!!this.isBlockStatement()&&C.isExpression(e))}function p(e){var t=this,r=!0;do{var n=t.container;if(t.isFunction()&&!r)return!!e;if(r=!1,Array.isArray(n)&&t.key!==n.length-1)return!1}while((t=t.parentPath)&&!t.isProgram());return!0}function d(){return!this.parentPath.isLabeledStatement()&&!C.isBlockStatement(this.container)&&(0,_.default)(C.STATEMENT_OR_BLOCK_KEYS,this.key)}function h(e,t){if(!this.isReferencedIdentifier())return!1;var r=this.scope.getBinding(this.node.name);if(!r||"module"!==r.kind)return!1;var n=r.path,i=n.parentPath;return!!i.isImportDeclaration()&&(i.node.source.value===e&&(!t||(!(!n.isImportDefaultSpecifier()||"default"!==t)||(!(!n.isImportNamespaceSpecifier()||"*"!==t)||!(!n.isImportSpecifier()||n.node.imported.name!==t)))))}function m(){var e=this.node;return e.end?this.hub.file.code.slice(e.start,e.end):""}function y(e){return"after"!==this._guessExecutionStatusRelativeTo(e)}function v(e){var t=e.scope.getFunctionParent(),r=this.scope.getFunctionParent();if(t.node!==r.node){var n=this._guessExecutionStatusRelativeToDifferentFunctions(t);if(n)return n;e=t.path}var i=e.getAncestry();if(i.indexOf(this)>=0)return"after";var s=this.getAncestry(),a=void 0,o=void 0,u=void 0;for(u=0;u<s.length;u++){var l=s[u];if((o=i.indexOf(l))>=0){a=l;break}}if(!a)return"before";var c=i[o-1],f=s[u-1];return c&&f?c.listKey&&c.container===f.container?c.key>f.key?"before":"after":C.VISITOR_KEYS[c.type].indexOf(c.key)>C.VISITOR_KEYS[f.type].indexOf(f.key)?"before":"after":"before"}function g(e){var t=e.path;if(t.isFunctionDeclaration()){var r=t.scope.getBinding(t.node.id.name);if(!r.references)return"before";for(var n=r.referencePaths,i=n,s=Array.isArray(i),a=0,i=s?i:(0,A.default)(i);;){var o;if(s){if(a>=i.length)break;o=i[a++]}else{if(a=i.next(),a.done)break;o=a.value}var u=o;if("callee"!==u.key||!u.parentPath.isCallExpression())return}for(var l=void 0,c=n,f=Array.isArray(c),p=0,c=f?c:(0,A.default)(c);;){var d;if(f){if(p>=c.length)break;d=c[p++]}else{if(p=c.next(),p.done)break;d=p.value}var h=d;if(!!!h.find(function(e){return e.node===t.node})){var m=this._guessExecutionStatusRelativeTo(h);if(l){if(l!==m)return}else l=m}}return l}}function b(e,t){return this._resolve(e,t)||this}function E(e,t){if(!(t&&t.indexOf(this)>=0))if(t=t||[],t.push(this),this.isVariableDeclarator()){if(this.get("id").isIdentifier())return this.get("init").resolve(e,t)}else if(this.isReferencedIdentifier()){var r=this.scope.getBinding(this.node.name);if(!r)return;if(!r.constant)return;if("module"===r.kind)return;if(r.path!==this){var n=r.path.resolve(e,t);if(this.find(function(e){return e.node===n.node}))return;return n}}else{if(this.isTypeCastExpression())return this.get("expression").resolve(e,t);if(e&&this.isMemberExpression()){var i=this.toComputedKey();if(!C.isLiteral(i))return;var s=i.value,a=this.get("object").resolve(e,t);if(a.isObjectExpression())for(var o=a.get("properties"),u=o,l=Array.isArray(u),c=0,u=l?u:(0,A.default)(u);;){var f;if(l){if(c>=u.length)break;f=u[c++]}else{if(c=u.next(),c.done)break;f=c.value}var p=f;if(p.isProperty()){var d=p.get("key"),h=p.isnt("computed")&&d.isIdentifier({name:s});if(h=h||d.isLiteral({value:s}))return p.get("value").resolve(e,t)}}else if(a.isArrayExpression()&&!isNaN(+s)){var m=a.get("elements"),y=m[s];if(y)return y.resolve(e,t)}}}}t.__esModule=!0,t.is=void 0;var x=r(2),A=n(x);t.matchesPattern=i,t.has=s,t.isStatic=a,t.isnt=o,t.equals=u,t.isNodeType=l,t.canHaveVariableDeclarationOrExpression=c,t.canSwapBetweenExpressionAndStatement=f,t.isCompletionRecord=p,t.isStatementOrBlock=d,t.referencesImport=h,t.getSource=m, +t.willIMaybeExecuteBefore=y,t._guessExecutionStatusRelativeTo=v,t._guessExecutionStatusRelativeToDifferentFunctions=g,t.resolve=b,t._resolve=E;var S=r(111),_=n(S),D=r(1),C=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(D);t.is=s},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(2),s=n(i),a=r(3),o=n(a),u=r(1),l=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(u),c={ReferencedIdentifier:function(e,t){if(!e.isJSXIdentifier()||!u.react.isCompatTag(e.node.name)||e.parentPath.isJSXMemberExpression()){if("this"===e.node.name){var r=e.scope;do{if(r.path.isFunction()&&!r.path.isArrowFunctionExpression())break}while(r=r.parent);r&&t.breakOnScopePaths.push(r.path)}var n=e.scope.getBinding(e.node.name);n&&n===t.scope.getBinding(e.node.name)&&(t.bindings[e.node.name]=n)}}},f=function(){function e(t,r){(0,o.default)(this,e),this.breakOnScopePaths=[],this.bindings={},this.scopes=[],this.scope=r,this.path=t,this.attachAfter=!1}return e.prototype.isCompatibleScope=function(e){for(var t in this.bindings){var r=this.bindings[t];if(!e.bindingIdentifierEquals(t,r.identifier))return!1}return!0},e.prototype.getCompatibleScopes=function(){var e=this.path.scope;do{if(!this.isCompatibleScope(e))break;if(this.scopes.push(e),this.breakOnScopePaths.indexOf(e.path)>=0)break}while(e=e.parent)},e.prototype.getAttachmentPath=function(){var e=this._getAttachmentPath();if(e){var t=e.scope;if(t.path===e&&(t=e.scope.parent),t.path.isProgram()||t.path.isFunction())for(var r in this.bindings)if(t.hasOwnBinding(r)){var n=this.bindings[r];if("param"!==n.kind&&this.getAttachmentParentForPath(n.path).key>e.key){this.attachAfter=!0,e=n.path;for(var i=n.constantViolations,a=Array.isArray(i),o=0,i=a?i:(0,s.default)(i);;){var u;if(a){if(o>=i.length)break;u=i[o++]}else{if(o=i.next(),o.done)break;u=o.value}var l=u;this.getAttachmentParentForPath(l).key>e.key&&(e=l)}}}return e.parentPath.isExportDeclaration()&&(e=e.parentPath),e}},e.prototype._getAttachmentPath=function(){var e=this.scopes,t=e.pop();if(t){if(t.path.isFunction()){if(this.hasOwnParamBindings(t)){if(this.scope===t)return;return t.path.get("body").get("body")[0]}return this.getNextScopeAttachmentParent()}return t.path.isProgram()?this.getNextScopeAttachmentParent():void 0}},e.prototype.getNextScopeAttachmentParent=function(){var e=this.scopes.pop();if(e)return this.getAttachmentParentForPath(e.path)},e.prototype.getAttachmentParentForPath=function(e){do{if(!e.parentPath||Array.isArray(e.container)&&e.isStatement()||e.isVariableDeclarator()&&null!==e.parentPath.node&&e.parentPath.node.declarations.length>1)return e}while(e=e.parentPath)},e.prototype.hasOwnParamBindings=function(e){for(var t in this.bindings)if(e.hasOwnBinding(t)){var r=this.bindings[t];if("param"===r.kind&&r.constant)return!0}return!1},e.prototype.run=function(){var e=this.path.node;if(!e._hoisted){e._hoisted=!0,this.path.traverse(c,this),this.getCompatibleScopes();var t=this.getAttachmentPath();if(t&&t.getFunctionParent()!==this.path.getFunctionParent()){var r=t.scope.generateUidIdentifier("ref"),n=l.variableDeclarator(r,this.path.node);t[this.attachAfter?"insertAfter":"insertBefore"]([t.isVariableDeclarator()?n:l.variableDeclaration("var",[n])]);var i=this.path.parentPath;i.isJSXElement()&&this.path.container===i.node.children&&(r=l.JSXExpressionContainer(r)),this.path.replaceWith(r)}}},e}();t.default=f,e.exports=t.default},function(e,t){"use strict";t.__esModule=!0;t.hooks=[function(e,t){if("test"===e.key&&(t.isWhile()||t.isSwitchCase())||"declaration"===e.key&&t.isExportDeclaration()||"body"===e.key&&t.isLabeledStatement()||"declarations"===e.listKey&&t.isVariableDeclaration()&&1===t.node.declarations.length||"expression"===e.key&&t.isExpressionStatement())return t.remove(),!0},function(e,t){if(t.isSequenceExpression()&&1===t.node.expressions.length)return t.replaceWith(t.node.expressions[0]),!0},function(e,t){if(t.isBinary())return"left"===e.key?t.replaceWith(t.node.right):t.replaceWith(t.node.left),!0},function(e,t){if(t.isIfStatement()&&("consequent"===e.key||"alternate"===e.key)||"body"===e.key&&(t.isLoop()||t.isArrowFunctionExpression()))return e.replaceWith({type:"BlockStatement",body:[]}),!0}]},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){if(this._assertUnremoved(),e=this._verifyNodeList(e),this.parentPath.isExpressionStatement()||this.parentPath.isLabeledStatement())return this.parentPath.insertBefore(e);if(this.isNodeType("Expression")||this.parentPath.isForStatement()&&"init"===this.key)this.node&&e.push(this.node),this.replaceExpressionWithStatements(e);else{if(this._maybePopFromStatements(e),Array.isArray(this.container))return this._containerInsertBefore(e);if(!this.isStatementOrBlock())throw new Error("We don't know what to do with this node type. We were previously a Statement but we can't fit in here?");this.node&&e.push(this.node),this._replaceWith(D.blockStatement(e))}return[this]}function s(e,t){this.updateSiblingKeys(e,t.length);for(var r=[],n=0;n<t.length;n++){var i=e+n,s=t[n];if(this.container.splice(i,0,s),this.context){var a=this.context.create(this.parent,this.container,i,this.listKey);this.context.queue&&a.pushContext(this.context),r.push(a)}else r.push(S.default.get({parentPath:this.parentPath,parent:this.parent,container:this.container,listKey:this.listKey,key:i}))}for(var o=this._getQueueContexts(),u=r,l=Array.isArray(u),c=0,u=l?u:(0,g.default)(u);;){var f;if(l){if(c>=u.length)break;f=u[c++]}else{if(c=u.next(),c.done)break;f=c.value}var p=f;p.setScope(),p.debug(function(){return"Inserted."});for(var d=o,h=Array.isArray(d),m=0,d=h?d:(0,g.default)(d);;){var y;if(h){if(m>=d.length)break;y=d[m++]}else{if(m=d.next(),m.done)break;y=m.value}y.maybeQueue(p,!0)}}return r}function a(e){return this._containerInsert(this.key,e)}function o(e){return this._containerInsert(this.key+1,e)}function u(e){var t=e[e.length-1];(D.isIdentifier(t)||D.isExpressionStatement(t)&&D.isIdentifier(t.expression))&&!this.isCompletionRecord()&&e.pop()}function l(e){if(this._assertUnremoved(),e=this._verifyNodeList(e),this.parentPath.isExpressionStatement()||this.parentPath.isLabeledStatement())return this.parentPath.insertAfter(e);if(this.isNodeType("Expression")||this.parentPath.isForStatement()&&"init"===this.key){if(this.node){var t=this.scope.generateDeclaredUidIdentifier();e.unshift(D.expressionStatement(D.assignmentExpression("=",t,this.node))),e.push(D.expressionStatement(t))}this.replaceExpressionWithStatements(e)}else{if(this._maybePopFromStatements(e),Array.isArray(this.container))return this._containerInsertAfter(e);if(!this.isStatementOrBlock())throw new Error("We don't know what to do with this node type. We were previously a Statement but we can't fit in here?");this.node&&e.unshift(this.node),this._replaceWith(D.blockStatement(e))}return[this]}function c(e,t){if(this.parent)for(var r=b.path.get(this.parent),n=0;n<r.length;n++){var i=r[n];i.key>=e&&(i.key+=t)}}function f(e){if(!e)return[];e.constructor!==Array&&(e=[e]);for(var t=0;t<e.length;t++){var r=e[t],n=void 0;if(r?"object"!==(void 0===r?"undefined":(0,y.default)(r))?n="contains a non-object node":r.type?r instanceof S.default&&(n="has a NodePath when it expected a raw object"):n="without a type":n="has falsy node",n){var i=Array.isArray(r)?"array":void 0===r?"undefined":(0,y.default)(r);throw new Error("Node list "+n+" with the index of "+t+" and type of "+i)}}return e}function p(e,t){return this._assertUnremoved(),t=this._verifyNodeList(t),S.default.get({parentPath:this,parent:this.node,container:this.node[e],listKey:e,key:0}).insertBefore(t)}function d(e,t){this._assertUnremoved(),t=this._verifyNodeList(t);var r=this.node[e];return S.default.get({parentPath:this,parent:this.node,container:r,listKey:e,key:r.length}).replaceWithMultiple(t)}function h(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.scope;return new x.default(this,e).run()}t.__esModule=!0;var m=r(11),y=n(m),v=r(2),g=n(v);t.insertBefore=i,t._containerInsert=s,t._containerInsertBefore=a,t._containerInsertAfter=o,t._maybePopFromStatements=u,t.insertAfter=l,t.updateSiblingKeys=c,t._verifyNodeList=f,t.unshiftContainer=p,t.pushContainer=d,t.hoist=h;var b=r(88),E=r(378),x=n(E),A=r(36),S=n(A),_=r(1),D=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(_)},function(e,t,r){"use strict";function n(){if(this._assertUnremoved(),this.resync(),this._callRemovalHooks())return void this._markRemoved();this.shareCommentsWithSiblings(),this._remove(),this._markRemoved()}function i(){for(var e=c.hooks,t=Array.isArray(e),r=0,e=t?e:(0,l.default)(e);;){var n;if(t){if(r>=e.length)break;n=e[r++]}else{if(r=e.next(),r.done)break;n=r.value}if(n(this,this.parentPath))return!0}}function s(){Array.isArray(this.container)?(this.container.splice(this.key,1),this.updateSiblingKeys(this.key,-1)):this._replaceWith(null)}function a(){this.shouldSkip=!0,this.removed=!0,this.node=null}function o(){if(this.removed)throw this.buildCodeFrameError("NodePath has been removed so is read-only.")}t.__esModule=!0;var u=r(2),l=function(e){return e&&e.__esModule?e:{default:e}}(u);t.remove=n,t._callRemovalHooks=i,t._remove=s,t._markRemoved=a,t._assertUnremoved=o;var c=r(379)},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){this.resync(),e=this._verifyNodeList(e),E.inheritLeadingComments(e[0],this.node),E.inheritTrailingComments(e[e.length-1],this.node),this.node=this.container[this.key]=null,this.insertAfter(e),this.node?this.requeue():this.remove()}function s(e){this.resync();try{e="("+e+")",e=(0,g.parse)(e)}catch(r){var t=r.loc;throw t&&(r.message+=" - make sure this is an expression.",r.message+="\n"+(0,d.default)(e,t.line,t.column+1)),r}return e=e.program.body[0].expression,m.default.removeProperties(e),this.replaceWith(e)}function a(e){if(this.resync(),this.removed)throw new Error("You can't replace this node, we've already removed it");if(e instanceof v.default&&(e=e.node),!e)throw new Error("You passed `path.replaceWith()` a falsy node, use `path.remove()` instead");if(this.node!==e){if(this.isProgram()&&!E.isProgram(e))throw new Error("You can only replace a Program root node with another Program node");if(Array.isArray(e))throw new Error("Don't use `path.replaceWith()` with an array of nodes, use `path.replaceWithMultiple()`");if("string"==typeof e)throw new Error("Don't use `path.replaceWith()` with a source string, use `path.replaceWithSourceString()`");if(this.isNodeType("Statement")&&E.isExpression(e)&&(this.canHaveVariableDeclarationOrExpression()||this.canSwapBetweenExpressionAndStatement(e)||this.parentPath.isExportDefaultDeclaration()||(e=E.expressionStatement(e))),this.isNodeType("Expression")&&E.isStatement(e)&&!this.canHaveVariableDeclarationOrExpression()&&!this.canSwapBetweenExpressionAndStatement(e))return this.replaceExpressionWithStatements([e]);var t=this.node;t&&(E.inheritsComments(e,t),E.removeComments(t)),this._replaceWith(e),this.type=e.type,this.setScope(),this.requeue()}}function o(e){if(!this.container)throw new ReferenceError("Container is falsy");this.inList?E.validate(this.parent,this.key,[e]):E.validate(this.parent,this.key,e),this.debug(function(){return"Replace with "+(e&&e.type)}),this.node=this.container[this.key]=e}function u(e){this.resync();var t=E.toSequenceExpression(e,this.scope);if(E.isSequenceExpression(t)){var r=t.expressions;r.length>=2&&this.parentPath.isExpressionStatement()&&this._maybePopFromStatements(r),1===r.length?this.replaceWith(r[0]):this.replaceWith(t)}else{if(!t){var n=E.functionExpression(null,[],E.blockStatement(e));n.shadow=!0,this.replaceWith(E.callExpression(n,[])),this.traverse(x);for(var i=this.get("callee").getCompletionRecords(),s=i,a=Array.isArray(s),o=0,s=a?s:(0,f.default)(s);;){var u;if(a){if(o>=s.length)break;u=s[o++]}else{if(o=s.next(),o.done)break;u=o.value}var l=u;if(l.isExpressionStatement()){var c=l.findParent(function(e){return e.isLoop()});if(c){var p=c.getData("expressionReplacementReturnUid");if(p)p=E.identifier(p.name);else{var d=this.get("callee");p=d.scope.generateDeclaredUidIdentifier("ret"),d.get("body").pushContainer("body",E.returnStatement(p)),c.setData("expressionReplacementReturnUid",p)}l.get("expression").replaceWith(E.assignmentExpression("=",p,l.node.expression))}else l.replaceWith(E.returnStatement(l.node.expression))}}return this.node}this.replaceWith(t)}}function l(e){return this.resync(),Array.isArray(e)?Array.isArray(this.container)?(e=this._verifyNodeList(e),this._containerInsertAfter(e),this.remove()):this.replaceWithMultiple(e):this.replaceWith(e)}t.__esModule=!0;var c=r(2),f=n(c);t.replaceWithMultiple=i,t.replaceWithSourceString=s,t.replaceWith=a,t._replaceWith=o,t.replaceExpressionWithStatements=u,t.replaceInline=l;var p=r(181),d=n(p),h=r(7),m=n(h),y=r(36),v=n(y),g=r(89),b=r(1),E=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(b),x={Function:function(e){e.skip()},VariableDeclaration:function(e){if("var"===e.node.kind){var t=e.getBindingIdentifiers();for(var r in t)e.scope.push({id:t[r]});for(var n=[],i=e.node.declarations,s=Array.isArray(i),a=0,i=s?i:(0,f.default)(i);;){var o;if(s){if(a>=i.length)break;o=i[a++]}else{if(a=i.next(),a.done)break;o=a.value}var u=o;u.init&&n.push(E.expressionStatement(E.assignmentExpression("=",u.id,u.init)))}e.replaceWithMultiple(n)}}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(3),s=n(i),a=r(225),o=(n(a),r(1)),u=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(o),l={ReferencedIdentifier:function(e,t){var r=e.node;r.name===t.oldName&&(r.name=t.newName)},Scope:function(e,t){e.scope.bindingIdentifierEquals(t.oldName,t.binding.identifier)||e.skip()},"AssignmentExpression|Declaration":function(e,t){var r=e.getOuterBindingIdentifiers();for(var n in r)n===t.oldName&&(r[n].name=t.newName)}},c=function(){function e(t,r,n){(0,s.default)(this,e),this.newName=n,this.oldName=r,this.binding=t}return e.prototype.maybeConvertFromExportDeclaration=function(e){var t=e.parentPath.isExportDeclaration()&&e.parentPath;if(t){var r=t.isExportDefaultDeclaration();r&&(e.isFunctionDeclaration()||e.isClassDeclaration())&&!e.node.id&&(e.node.id=e.scope.generateUidIdentifier("default"));var n=e.getOuterBindingIdentifiers(),i=[];for(var s in n){var a=s===this.oldName?this.newName:s,o=r?"default":s;i.push(u.exportSpecifier(u.identifier(a),u.identifier(o)))}if(i.length){var l=u.exportNamedDeclaration(null,i);e.isFunctionDeclaration()&&(l._blockHoist=3),t.insertAfter(l),t.replaceWith(e.node)}}},e.prototype.rename=function(e){var t=this.binding,r=this.oldName,n=this.newName,i=t.scope,s=t.path,a=s.find(function(e){return e.isDeclaration()||e.isFunctionExpression()});a&&this.maybeConvertFromExportDeclaration(a),i.traverse(e||i.block,l,this),e||(i.removeOwnBinding(r),i.bindings[n]=t,this.binding.identifier.name=n),t.type},e}();t.default=c,e.exports=t.default},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}function s(e){if(e._exploded)return e;e._exploded=!0;for(var t in e)if(!d(t)){var r=t.split("|");if(1!==r.length){var n=e[t];delete e[t];for(var i=r,s=Array.isArray(i),o=0,i=s?i:(0,E.default)(i);;){var u;if(s){if(o>=i.length)break;u=i[o++]}else{if(o=i.next(),o.done)break;u=o.value}var l=u;e[l]=n}}}a(e),delete e.__esModule,c(e),f(e);for(var m=(0,g.default)(e),y=Array.isArray(m),v=0,m=y?m:(0,E.default)(m);;){var b;if(y){if(v>=m.length)break;b=m[v++]}else{if(v=m.next(),v.done)break;b=v.value}var x=b;if(!d(x)){var S=A[x];if(S){var _=e[x];for(var D in _)_[D]=p(S,_[D]);if(delete e[x],S.types)for(var w=S.types,k=Array.isArray(w),F=0,w=k?w:(0,E.default)(w);;){var T;if(k){if(F>=w.length)break;T=w[F++]}else{if(F=w.next(),F.done)break;T=F.value}var O=T;e[O]?h(e[O],_):e[O]=_}else h(e,_)}}}for(var B in e)if(!d(B)){var R=e[B],I=C.FLIPPED_ALIAS_KEYS[B],M=C.DEPRECATED_KEYS[B];if(M&&(console.trace("Visitor defined for "+B+" but it has been renamed to "+M),I=[M]),I){delete e[B];for(var N=I,L=Array.isArray(N),j=0,N=L?N:(0,E.default)(N);;){var U;if(L){if(j>=N.length)break;U=N[j++]}else{if(j=N.next(),j.done)break;U=j.value}var V=U,G=e[V];G?h(G,R):e[V]=(0,P.default)(R)}}}for(var W in e)d(W)||f(e[W]);return e}function a(e){if(!e._verified){if("function"==typeof e)throw new Error(_.get("traverseVerifyRootFunction"));for(var t in e)if("enter"!==t&&"exit"!==t||o(t,e[t]),!d(t)){if(C.TYPES.indexOf(t)<0)throw new Error(_.get("traverseVerifyNodeType",t));var r=e[t];if("object"===(void 0===r?"undefined":(0,y.default)(r)))for(var n in r){if("enter"!==n&&"exit"!==n)throw new Error(_.get("traverseVerifyVisitorProperty",t,n));o(t+"."+n,r[n])}}e._verified=!0}}function o(e,t){for(var r=[].concat(t),n=r,i=Array.isArray(n),s=0,n=i?n:(0,E.default)(n);;){var a;if(i){if(s>=n.length)break;a=n[s++]}else{if(s=n.next(),s.done)break;a=s.value}var o=a;if("function"!=typeof o)throw new TypeError("Non-function found defined in "+e+" with type "+(void 0===o?"undefined":(0,y.default)(o)))}}function u(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments[2],n={},i=0;i<e.length;i++){var a=e[i],o=t[i];s(a);for(var u in a){var c=a[u];(o||r)&&(c=l(c,o,r));h(n[u]=n[u]||{},c)}}return n}function l(e,t,r){var n={};for(var i in e){(function(i){var s=e[i];if(!Array.isArray(s))return"continue";s=s.map(function(e){var n=e;return t&&(n=function(r){return e.call(t,r,t)}),r&&(n=r(t.key,i,n)),n}),n[i]=s})(i)}return n}function c(e){for(var t in e)if(!d(t)){var r=e[t];"function"==typeof r&&(e[t]={enter:r})}}function f(e){e.enter&&!Array.isArray(e.enter)&&(e.enter=[e.enter]),e.exit&&!Array.isArray(e.exit)&&(e.exit=[e.exit])}function p(e,t){var r=function(r){if(e.checkPath(r))return t.apply(this,arguments)};return r.toString=function(){return t.toString()},r}function d(e){return"_"===e[0]||("enter"===e||"exit"===e||"shouldSkip"===e||("blacklist"===e||"noScope"===e||"skipKeys"===e))}function h(e,t){for(var r in t)e[r]=[].concat(e[r]||[],t[r])}t.__esModule=!0;var m=r(11),y=i(m),v=r(14),g=i(v),b=r(2),E=i(b);t.explode=s,t.verify=a,t.merge=u;var x=r(224),A=n(x),S=r(20),_=n(S),D=r(1),C=n(D),w=r(109),P=i(w)},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.key||e.property;return e.computed||D.isIdentifier(t)&&(t=D.stringLiteral(t.name)),t}function s(e,t,r){for(var n=[],i=!0,a=e,o=Array.isArray(a),u=0,a=o?a:(0,b.default)(a);;){var l;if(o){if(u>=a.length)break;l=a[u++]}else{if(u=a.next(),u.done)break;l=u.value}var c=l;if(i=!1,D.isExpression(c))n.push(c);else if(D.isExpressionStatement(c))n.push(c.expression);else if(D.isVariableDeclaration(c)){if("var"!==c.kind)return;for(var f=c.declarations,p=Array.isArray(f),d=0,f=p?f:(0,b.default)(f);;){var h;if(p){if(d>=f.length)break;h=f[d++]}else{if(d=f.next(),d.done)break;h=d.value}var m=h,y=D.getBindingIdentifiers(m);for(var v in y)r.push({kind:c.kind,id:y[v]});m.init&&n.push(D.assignmentExpression("=",m.id,m.init))}i=!0}else if(D.isIfStatement(c)){var g=c.consequent?s([c.consequent],t,r):t.buildUndefinedNode(),E=c.alternate?s([c.alternate],t,r):t.buildUndefinedNode();if(!g||!E)return;n.push(D.conditionalExpression(c.test,g,E))}else if(D.isBlockStatement(c)){var x=s(c.body,t,r);if(!x)return;n.push(x)}else{if(!D.isEmptyStatement(c))return;i=!0}}return i&&n.push(t.buildUndefinedNode()),1===n.length?n[0]:D.sequenceExpression(n)}function a(e,t){if(e&&e.length){var r=[],n=s(e,t,r);if(n){for(var i=r,a=Array.isArray(i),o=0,i=a?i:(0,b.default)(i);;){var u;if(a){if(o>=i.length)break;u=i[o++]}else{if(o=i.next(),o.done)break;u=o.value}var l=u;t.push(l)}return n}}}function o(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.key,r=void 0;return"method"===e.kind?o.increment()+"":(r=D.isIdentifier(t)?t.name:D.isStringLiteral(t)?(0,v.default)(t.value):(0,v.default)(D.removePropertiesDeep(D.cloneDeep(t))),e.computed&&(r="["+r+"]"),e.static&&(r="static:"+r),r)}function u(e){return e+="",e=e.replace(/[^a-zA-Z0-9$_]/g,"-"),e=e.replace(/^[-0-9]+/,""),e=e.replace(/[-\s]+(.)?/g,function(e,t){return t?t.toUpperCase():""}),D.isValidIdentifier(e)||(e="_"+e),e||"_"}function l(e){return e=u(e),"eval"!==e&&"arguments"!==e||(e="_"+e),e}function c(e,t){if(D.isStatement(e))return e;var r=!1,n=void 0;if(D.isClass(e))r=!0,n="ClassDeclaration";else if(D.isFunction(e))r=!0,n="FunctionDeclaration";else if(D.isAssignmentExpression(e))return D.expressionStatement(e);if(r&&!e.id&&(n=!1),!n){if(t)return!1;throw new Error("cannot turn "+e.type+" to a statement")}return e.type=n,e}function f(e){if(D.isExpressionStatement(e)&&(e=e.expression),D.isExpression(e))return e;if(D.isClass(e)?e.type="ClassExpression":D.isFunction(e)&&(e.type="FunctionExpression"),!D.isExpression(e))throw new Error("cannot turn "+e.type+" to an expression");return e}function p(e,t){return D.isBlockStatement(e)?e:(D.isEmptyStatement(e)&&(e=[]),Array.isArray(e)||(D.isStatement(e)||(e=D.isFunction(t)?D.returnStatement(e):D.expressionStatement(e)),e=[e]),D.blockStatement(e))}function d(e){if(void 0===e)return D.identifier("undefined");if(!0===e||!1===e)return D.booleanLiteral(e);if(null===e)return D.nullLiteral();if("string"==typeof e)return D.stringLiteral(e);if("number"==typeof e)return D.numericLiteral(e);if((0,S.default)(e)){var t=e.source,r=e.toString().match(/\/([a-z]+|)$/)[1];return D.regExpLiteral(t,r)}if(Array.isArray(e))return D.arrayExpression(e.map(D.valueToNode));if((0,x.default)(e)){var n=[];for(var i in e){var s=void 0;s=D.isValidIdentifier(i)?D.identifier(i):D.stringLiteral(i),n.push(D.objectProperty(s,D.valueToNode(e[i])))}return D.objectExpression(n)}throw new Error("don't know how to turn this value into a node")}t.__esModule=!0;var h=r(359),m=n(h),y=r(35),v=n(y),g=r(2),b=n(g);t.toComputedKey=i,t.toSequenceExpression=a,t.toKeyAlias=o,t.toIdentifier=u,t.toBindingIdentifierName=l,t.toStatement=c,t.toExpression=f,t.toBlock=p,t.valueToNode=d;var E=r(275),x=n(E),A=r(276),S=n(A),_=r(1),D=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(_);o.uid=0,o.increment=function(){return o.uid>=m.default?o.uid=0:o.uid++}},function(e,t,r){"use strict";var n=r(1),i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(n),s=r(135),a=r(26),o=function(e){return e&&e.__esModule?e:{default:e}}(a);(0,o.default)("ArrayExpression",{fields:{elements:{validate:(0,a.chain)((0,a.assertValueType)("array"),(0,a.assertEach)((0,a.assertNodeOrValueType)("null","Expression","SpreadElement"))),default:[]}},visitor:["elements"],aliases:["Expression"]}),(0,o.default)("AssignmentExpression",{fields:{operator:{validate:(0,a.assertValueType)("string")},left:{validate:(0,a.assertNodeType)("LVal")},right:{validate:(0,a.assertNodeType)("Expression")}},builder:["operator","left","right"],visitor:["left","right"],aliases:["Expression"]}),(0,o.default)("BinaryExpression",{builder:["operator","left","right"],fields:{operator:{validate:a.assertOneOf.apply(void 0,s.BINARY_OPERATORS)},left:{validate:(0,a.assertNodeType)("Expression")},right:{validate:(0,a.assertNodeType)("Expression")}},visitor:["left","right"],aliases:["Binary","Expression"]}),(0,o.default)("Directive",{visitor:["value"],fields:{value:{validate:(0,a.assertNodeType)("DirectiveLiteral")}}}),(0,o.default)("DirectiveLiteral",{builder:["value"],fields:{value:{validate:(0,a.assertValueType)("string")}}}),(0,o.default)("BlockStatement",{builder:["body","directives"],visitor:["directives","body"],fields:{directives:{validate:(0,a.chain)((0,a.assertValueType)("array"),(0,a.assertEach)((0,a.assertNodeType)("Directive"))),default:[]},body:{validate:(0,a.chain)((0,a.assertValueType)("array"),(0,a.assertEach)((0,a.assertNodeType)("Statement")))}},aliases:["Scopable","BlockParent","Block","Statement"]}),(0,o.default)("BreakStatement",{visitor:["label"],fields:{label:{validate:(0,a.assertNodeType)("Identifier"),optional:!0}},aliases:["Statement","Terminatorless","CompletionStatement"]}),(0,o.default)("CallExpression",{visitor:["callee","arguments"],fields:{callee:{validate:(0,a.assertNodeType)("Expression")},arguments:{validate:(0,a.chain)((0,a.assertValueType)("array"),(0,a.assertEach)((0,a.assertNodeType)("Expression","SpreadElement")))}},aliases:["Expression"]}),(0,o.default)("CatchClause",{visitor:["param","body"],fields:{param:{validate:(0,a.assertNodeType)("Identifier")},body:{validate:(0,a.assertNodeType)("BlockStatement")}},aliases:["Scopable"]}),(0,o.default)("ConditionalExpression",{visitor:["test","consequent","alternate"],fields:{test:{validate:(0,a.assertNodeType)("Expression")},consequent:{validate:(0,a.assertNodeType)("Expression")},alternate:{validate:(0,a.assertNodeType)("Expression")}},aliases:["Expression","Conditional"]}),(0,o.default)("ContinueStatement",{visitor:["label"],fields:{label:{validate:(0,a.assertNodeType)("Identifier"),optional:!0}},aliases:["Statement","Terminatorless","CompletionStatement"]}),(0,o.default)("DebuggerStatement",{aliases:["Statement"]}),(0,o.default)("DoWhileStatement",{visitor:["test","body"],fields:{test:{validate:(0,a.assertNodeType)("Expression")},body:{validate:(0,a.assertNodeType)("Statement")}},aliases:["Statement","BlockParent","Loop","While","Scopable"]}),(0,o.default)("EmptyStatement",{aliases:["Statement"]}),(0,o.default)("ExpressionStatement",{visitor:["expression"],fields:{expression:{validate:(0,a.assertNodeType)("Expression")}},aliases:["Statement","ExpressionWrapper"]}),(0,o.default)("File",{builder:["program","comments","tokens"],visitor:["program"],fields:{program:{validate:(0,a.assertNodeType)("Program")}}}),(0,o.default)("ForInStatement",{visitor:["left","right","body"],aliases:["Scopable","Statement","For","BlockParent","Loop","ForXStatement"],fields:{left:{validate:(0,a.assertNodeType)("VariableDeclaration","LVal")},right:{validate:(0,a.assertNodeType)("Expression")},body:{validate:(0,a.assertNodeType)("Statement")}}}),(0,o.default)("ForStatement",{visitor:["init","test","update","body"],aliases:["Scopable","Statement","For","BlockParent","Loop"],fields:{init:{validate:(0,a.assertNodeType)("VariableDeclaration","Expression"),optional:!0},test:{validate:(0,a.assertNodeType)("Expression"),optional:!0},update:{validate:(0,a.assertNodeType)("Expression"),optional:!0},body:{validate:(0,a.assertNodeType)("Statement")}}}),(0,o.default)("FunctionDeclaration",{builder:["id","params","body","generator","async"],visitor:["id","params","body","returnType","typeParameters"],fields:{id:{validate:(0,a.assertNodeType)("Identifier")},params:{validate:(0,a.chain)((0,a.assertValueType)("array"),(0,a.assertEach)((0,a.assertNodeType)("LVal")))},body:{validate:(0,a.assertNodeType)("BlockStatement")},generator:{default:!1,validate:(0,a.assertValueType)("boolean")},async:{default:!1,validate:(0,a.assertValueType)("boolean")}},aliases:["Scopable","Function","BlockParent","FunctionParent","Statement","Pureish","Declaration"]}),(0,o.default)("FunctionExpression",{inherits:"FunctionDeclaration",aliases:["Scopable","Function","BlockParent","FunctionParent","Expression","Pureish"],fields:{id:{validate:(0,a.assertNodeType)("Identifier"),optional:!0},params:{validate:(0,a.chain)((0,a.assertValueType)("array"),(0,a.assertEach)((0,a.assertNodeType)("LVal")))},body:{validate:(0,a.assertNodeType)("BlockStatement")},generator:{default:!1,validate:(0,a.assertValueType)("boolean")},async:{default:!1,validate:(0,a.assertValueType)("boolean")}}}),(0,o.default)("Identifier",{builder:["name"],visitor:["typeAnnotation"],aliases:["Expression","LVal"],fields:{name:{validate:function(e,t,r){i.isValidIdentifier(r)}},decorators:{validate:(0,a.chain)((0,a.assertValueType)("array"),(0,a.assertEach)((0,a.assertNodeType)("Decorator")))}}}),(0,o.default)("IfStatement",{visitor:["test","consequent","alternate"],aliases:["Statement","Conditional"],fields:{test:{validate:(0,a.assertNodeType)("Expression")},consequent:{validate:(0,a.assertNodeType)("Statement")},alternate:{optional:!0,validate:(0,a.assertNodeType)("Statement")}}}),(0,o.default)("LabeledStatement",{visitor:["label","body"],aliases:["Statement"],fields:{label:{validate:(0,a.assertNodeType)("Identifier")},body:{validate:(0,a.assertNodeType)("Statement")}}}),(0,o.default)("StringLiteral",{builder:["value"],fields:{value:{validate:(0,a.assertValueType)("string")}},aliases:["Expression","Pureish","Literal","Immutable"]}),(0,o.default)("NumericLiteral",{builder:["value"],deprecatedAlias:"NumberLiteral",fields:{value:{validate:(0,a.assertValueType)("number")}},aliases:["Expression","Pureish","Literal","Immutable"]}),(0,o.default)("NullLiteral",{aliases:["Expression","Pureish","Literal","Immutable"]}),(0,o.default)("BooleanLiteral",{builder:["value"],fields:{value:{validate:(0,a.assertValueType)("boolean")}},aliases:["Expression","Pureish","Literal","Immutable"]}),(0,o.default)("RegExpLiteral",{builder:["pattern","flags"],deprecatedAlias:"RegexLiteral",aliases:["Expression","Literal"],fields:{pattern:{validate:(0,a.assertValueType)("string")},flags:{validate:(0,a.assertValueType)("string"),default:""}}}),(0,o.default)("LogicalExpression",{builder:["operator","left","right"],visitor:["left","right"],aliases:["Binary","Expression"],fields:{operator:{validate:a.assertOneOf.apply(void 0,s.LOGICAL_OPERATORS)},left:{validate:(0,a.assertNodeType)("Expression")},right:{validate:(0,a.assertNodeType)("Expression")}}}),(0,o.default)("MemberExpression",{builder:["object","property","computed"],visitor:["object","property"],aliases:["Expression","LVal"],fields:{object:{validate:(0,a.assertNodeType)("Expression")},property:{validate:function(e,t,r){var n=e.computed?"Expression":"Identifier";(0,a.assertNodeType)(n)(e,t,r)}},computed:{default:!1}}}),(0,o.default)("NewExpression",{visitor:["callee","arguments"],aliases:["Expression"],fields:{callee:{validate:(0,a.assertNodeType)("Expression")},arguments:{validate:(0,a.chain)((0,a.assertValueType)("array"),(0,a.assertEach)((0,a.assertNodeType)("Expression","SpreadElement")))}}}),(0,o.default)("Program",{visitor:["directives","body"],builder:["body","directives"],fields:{directives:{validate:(0,a.chain)((0,a.assertValueType)("array"),(0,a.assertEach)((0,a.assertNodeType)("Directive"))),default:[]},body:{validate:(0,a.chain)((0,a.assertValueType)("array"),(0,a.assertEach)((0,a.assertNodeType)("Statement")))}},aliases:["Scopable","BlockParent","Block","FunctionParent"]}),(0,o.default)("ObjectExpression",{visitor:["properties"],aliases:["Expression"],fields:{properties:{validate:(0,a.chain)((0,a.assertValueType)("array"),(0,a.assertEach)((0,a.assertNodeType)("ObjectMethod","ObjectProperty","SpreadProperty")))}}}),(0,o.default)("ObjectMethod",{builder:["kind","key","params","body","computed"],fields:{kind:{validate:(0,a.chain)((0,a.assertValueType)("string"),(0,a.assertOneOf)("method","get","set")),default:"method"},computed:{validate:(0,a.assertValueType)("boolean"),default:!1},key:{validate:function(e,t,r){var n=e.computed?["Expression"]:["Identifier","StringLiteral","NumericLiteral"];a.assertNodeType.apply(void 0,n)(e,t,r)}},decorators:{validate:(0,a.chain)((0,a.assertValueType)("array"),(0,a.assertEach)((0,a.assertNodeType)("Decorator")))}, +body:{validate:(0,a.assertNodeType)("BlockStatement")},generator:{default:!1,validate:(0,a.assertValueType)("boolean")},async:{default:!1,validate:(0,a.assertValueType)("boolean")}},visitor:["key","params","body","decorators","returnType","typeParameters"],aliases:["UserWhitespacable","Function","Scopable","BlockParent","FunctionParent","Method","ObjectMember"]}),(0,o.default)("ObjectProperty",{builder:["key","value","computed","shorthand","decorators"],fields:{computed:{validate:(0,a.assertValueType)("boolean"),default:!1},key:{validate:function(e,t,r){var n=e.computed?["Expression"]:["Identifier","StringLiteral","NumericLiteral"];a.assertNodeType.apply(void 0,n)(e,t,r)}},value:{validate:(0,a.assertNodeType)("Expression","Pattern","RestElement")},shorthand:{validate:(0,a.assertValueType)("boolean"),default:!1},decorators:{validate:(0,a.chain)((0,a.assertValueType)("array"),(0,a.assertEach)((0,a.assertNodeType)("Decorator"))),optional:!0}},visitor:["key","value","decorators"],aliases:["UserWhitespacable","Property","ObjectMember"]}),(0,o.default)("RestElement",{visitor:["argument","typeAnnotation"],aliases:["LVal"],fields:{argument:{validate:(0,a.assertNodeType)("LVal")},decorators:{validate:(0,a.chain)((0,a.assertValueType)("array"),(0,a.assertEach)((0,a.assertNodeType)("Decorator")))}}}),(0,o.default)("ReturnStatement",{visitor:["argument"],aliases:["Statement","Terminatorless","CompletionStatement"],fields:{argument:{validate:(0,a.assertNodeType)("Expression"),optional:!0}}}),(0,o.default)("SequenceExpression",{visitor:["expressions"],fields:{expressions:{validate:(0,a.chain)((0,a.assertValueType)("array"),(0,a.assertEach)((0,a.assertNodeType)("Expression")))}},aliases:["Expression"]}),(0,o.default)("SwitchCase",{visitor:["test","consequent"],fields:{test:{validate:(0,a.assertNodeType)("Expression"),optional:!0},consequent:{validate:(0,a.chain)((0,a.assertValueType)("array"),(0,a.assertEach)((0,a.assertNodeType)("Statement")))}}}),(0,o.default)("SwitchStatement",{visitor:["discriminant","cases"],aliases:["Statement","BlockParent","Scopable"],fields:{discriminant:{validate:(0,a.assertNodeType)("Expression")},cases:{validate:(0,a.chain)((0,a.assertValueType)("array"),(0,a.assertEach)((0,a.assertNodeType)("SwitchCase")))}}}),(0,o.default)("ThisExpression",{aliases:["Expression"]}),(0,o.default)("ThrowStatement",{visitor:["argument"],aliases:["Statement","Terminatorless","CompletionStatement"],fields:{argument:{validate:(0,a.assertNodeType)("Expression")}}}),(0,o.default)("TryStatement",{visitor:["block","handler","finalizer"],aliases:["Statement"],fields:{body:{validate:(0,a.assertNodeType)("BlockStatement")},handler:{optional:!0,handler:(0,a.assertNodeType)("BlockStatement")},finalizer:{optional:!0,validate:(0,a.assertNodeType)("BlockStatement")}}}),(0,o.default)("UnaryExpression",{builder:["operator","argument","prefix"],fields:{prefix:{default:!0},argument:{validate:(0,a.assertNodeType)("Expression")},operator:{validate:a.assertOneOf.apply(void 0,s.UNARY_OPERATORS)}},visitor:["argument"],aliases:["UnaryLike","Expression"]}),(0,o.default)("UpdateExpression",{builder:["operator","argument","prefix"],fields:{prefix:{default:!1},argument:{validate:(0,a.assertNodeType)("Expression")},operator:{validate:a.assertOneOf.apply(void 0,s.UPDATE_OPERATORS)}},visitor:["argument"],aliases:["Expression"]}),(0,o.default)("VariableDeclaration",{builder:["kind","declarations"],visitor:["declarations"],aliases:["Statement","Declaration"],fields:{kind:{validate:(0,a.chain)((0,a.assertValueType)("string"),(0,a.assertOneOf)("var","let","const"))},declarations:{validate:(0,a.chain)((0,a.assertValueType)("array"),(0,a.assertEach)((0,a.assertNodeType)("VariableDeclarator")))}}}),(0,o.default)("VariableDeclarator",{visitor:["id","init"],fields:{id:{validate:(0,a.assertNodeType)("LVal")},init:{optional:!0,validate:(0,a.assertNodeType)("Expression")}}}),(0,o.default)("WhileStatement",{visitor:["test","body"],aliases:["Statement","BlockParent","Loop","While","Scopable"],fields:{test:{validate:(0,a.assertNodeType)("Expression")},body:{validate:(0,a.assertNodeType)("BlockStatement","Statement")}}}),(0,o.default)("WithStatement",{visitor:["object","body"],aliases:["Statement"],fields:{object:{object:(0,a.assertNodeType)("Expression")},body:{validate:(0,a.assertNodeType)("BlockStatement","Statement")}}})},function(e,t,r){"use strict";var n=r(26),i=function(e){return e&&e.__esModule?e:{default:e}}(n);(0,i.default)("AssignmentPattern",{visitor:["left","right"],aliases:["Pattern","LVal"],fields:{left:{validate:(0,n.assertNodeType)("Identifier")},right:{validate:(0,n.assertNodeType)("Expression")},decorators:{validate:(0,n.chain)((0,n.assertValueType)("array"),(0,n.assertEach)((0,n.assertNodeType)("Decorator")))}}}),(0,i.default)("ArrayPattern",{visitor:["elements","typeAnnotation"],aliases:["Pattern","LVal"],fields:{elements:{validate:(0,n.chain)((0,n.assertValueType)("array"),(0,n.assertEach)((0,n.assertNodeType)("Identifier","Pattern","RestElement")))},decorators:{validate:(0,n.chain)((0,n.assertValueType)("array"),(0,n.assertEach)((0,n.assertNodeType)("Decorator")))}}}),(0,i.default)("ArrowFunctionExpression",{builder:["params","body","async"],visitor:["params","body","returnType","typeParameters"],aliases:["Scopable","Function","BlockParent","FunctionParent","Expression","Pureish"],fields:{params:{validate:(0,n.chain)((0,n.assertValueType)("array"),(0,n.assertEach)((0,n.assertNodeType)("LVal")))},body:{validate:(0,n.assertNodeType)("BlockStatement","Expression")},async:{validate:(0,n.assertValueType)("boolean"),default:!1}}}),(0,i.default)("ClassBody",{visitor:["body"],fields:{body:{validate:(0,n.chain)((0,n.assertValueType)("array"),(0,n.assertEach)((0,n.assertNodeType)("ClassMethod","ClassProperty")))}}}),(0,i.default)("ClassDeclaration",{builder:["id","superClass","body","decorators"],visitor:["id","body","superClass","mixins","typeParameters","superTypeParameters","implements","decorators"],aliases:["Scopable","Class","Statement","Declaration","Pureish"],fields:{id:{validate:(0,n.assertNodeType)("Identifier")},body:{validate:(0,n.assertNodeType)("ClassBody")},superClass:{optional:!0,validate:(0,n.assertNodeType)("Expression")},decorators:{validate:(0,n.chain)((0,n.assertValueType)("array"),(0,n.assertEach)((0,n.assertNodeType)("Decorator")))}}}),(0,i.default)("ClassExpression",{inherits:"ClassDeclaration",aliases:["Scopable","Class","Expression","Pureish"],fields:{id:{optional:!0,validate:(0,n.assertNodeType)("Identifier")},body:{validate:(0,n.assertNodeType)("ClassBody")},superClass:{optional:!0,validate:(0,n.assertNodeType)("Expression")},decorators:{validate:(0,n.chain)((0,n.assertValueType)("array"),(0,n.assertEach)((0,n.assertNodeType)("Decorator")))}}}),(0,i.default)("ExportAllDeclaration",{visitor:["source"],aliases:["Statement","Declaration","ModuleDeclaration","ExportDeclaration"],fields:{source:{validate:(0,n.assertNodeType)("StringLiteral")}}}),(0,i.default)("ExportDefaultDeclaration",{visitor:["declaration"],aliases:["Statement","Declaration","ModuleDeclaration","ExportDeclaration"],fields:{declaration:{validate:(0,n.assertNodeType)("FunctionDeclaration","ClassDeclaration","Expression")}}}),(0,i.default)("ExportNamedDeclaration",{visitor:["declaration","specifiers","source"],aliases:["Statement","Declaration","ModuleDeclaration","ExportDeclaration"],fields:{declaration:{validate:(0,n.assertNodeType)("Declaration"),optional:!0},specifiers:{validate:(0,n.chain)((0,n.assertValueType)("array"),(0,n.assertEach)((0,n.assertNodeType)("ExportSpecifier")))},source:{validate:(0,n.assertNodeType)("StringLiteral"),optional:!0}}}),(0,i.default)("ExportSpecifier",{visitor:["local","exported"],aliases:["ModuleSpecifier"],fields:{local:{validate:(0,n.assertNodeType)("Identifier")},exported:{validate:(0,n.assertNodeType)("Identifier")}}}),(0,i.default)("ForOfStatement",{visitor:["left","right","body"],aliases:["Scopable","Statement","For","BlockParent","Loop","ForXStatement"],fields:{left:{validate:(0,n.assertNodeType)("VariableDeclaration","LVal")},right:{validate:(0,n.assertNodeType)("Expression")},body:{validate:(0,n.assertNodeType)("Statement")}}}),(0,i.default)("ImportDeclaration",{visitor:["specifiers","source"],aliases:["Statement","Declaration","ModuleDeclaration"],fields:{specifiers:{validate:(0,n.chain)((0,n.assertValueType)("array"),(0,n.assertEach)((0,n.assertNodeType)("ImportSpecifier","ImportDefaultSpecifier","ImportNamespaceSpecifier")))},source:{validate:(0,n.assertNodeType)("StringLiteral")}}}),(0,i.default)("ImportDefaultSpecifier",{visitor:["local"],aliases:["ModuleSpecifier"],fields:{local:{validate:(0,n.assertNodeType)("Identifier")}}}),(0,i.default)("ImportNamespaceSpecifier",{visitor:["local"],aliases:["ModuleSpecifier"],fields:{local:{validate:(0,n.assertNodeType)("Identifier")}}}),(0,i.default)("ImportSpecifier",{visitor:["local","imported"],aliases:["ModuleSpecifier"],fields:{local:{validate:(0,n.assertNodeType)("Identifier")},imported:{validate:(0,n.assertNodeType)("Identifier")},importKind:{validate:(0,n.assertOneOf)(null,"type","typeof")}}}),(0,i.default)("MetaProperty",{visitor:["meta","property"],aliases:["Expression"],fields:{meta:{validate:(0,n.assertValueType)("string")},property:{validate:(0,n.assertValueType)("string")}}}),(0,i.default)("ClassMethod",{aliases:["Function","Scopable","BlockParent","FunctionParent","Method"],builder:["kind","key","params","body","computed","static"],visitor:["key","params","body","decorators","returnType","typeParameters"],fields:{kind:{validate:(0,n.chain)((0,n.assertValueType)("string"),(0,n.assertOneOf)("get","set","method","constructor")),default:"method"},computed:{default:!1,validate:(0,n.assertValueType)("boolean")},static:{default:!1,validate:(0,n.assertValueType)("boolean")},key:{validate:function(e,t,r){var i=e.computed?["Expression"]:["Identifier","StringLiteral","NumericLiteral"];n.assertNodeType.apply(void 0,i)(e,t,r)}},params:{validate:(0,n.chain)((0,n.assertValueType)("array"),(0,n.assertEach)((0,n.assertNodeType)("LVal")))},body:{validate:(0,n.assertNodeType)("BlockStatement")},generator:{default:!1,validate:(0,n.assertValueType)("boolean")},async:{default:!1,validate:(0,n.assertValueType)("boolean")}}}),(0,i.default)("ObjectPattern",{visitor:["properties","typeAnnotation"],aliases:["Pattern","LVal"],fields:{properties:{validate:(0,n.chain)((0,n.assertValueType)("array"),(0,n.assertEach)((0,n.assertNodeType)("RestProperty","Property")))},decorators:{validate:(0,n.chain)((0,n.assertValueType)("array"),(0,n.assertEach)((0,n.assertNodeType)("Decorator")))}}}),(0,i.default)("SpreadElement",{visitor:["argument"],aliases:["UnaryLike"],fields:{argument:{validate:(0,n.assertNodeType)("Expression")}}}),(0,i.default)("Super",{aliases:["Expression"]}),(0,i.default)("TaggedTemplateExpression",{visitor:["tag","quasi"],aliases:["Expression"],fields:{tag:{validate:(0,n.assertNodeType)("Expression")},quasi:{validate:(0,n.assertNodeType)("TemplateLiteral")}}}),(0,i.default)("TemplateElement",{builder:["value","tail"],fields:{value:{},tail:{validate:(0,n.assertValueType)("boolean"),default:!1}}}),(0,i.default)("TemplateLiteral",{visitor:["quasis","expressions"],aliases:["Expression","Literal"],fields:{quasis:{validate:(0,n.chain)((0,n.assertValueType)("array"),(0,n.assertEach)((0,n.assertNodeType)("TemplateElement")))},expressions:{validate:(0,n.chain)((0,n.assertValueType)("array"),(0,n.assertEach)((0,n.assertNodeType)("Expression")))}}}),(0,i.default)("YieldExpression",{builder:["argument","delegate"],visitor:["argument"],aliases:["Expression","Terminatorless"],fields:{delegate:{validate:(0,n.assertValueType)("boolean"),default:!1},argument:{optional:!0,validate:(0,n.assertNodeType)("Expression")}}})},function(e,t,r){"use strict";var n=r(26),i=function(e){return e&&e.__esModule?e:{default:e}}(n);(0,i.default)("AwaitExpression",{builder:["argument"],visitor:["argument"],aliases:["Expression","Terminatorless"],fields:{argument:{validate:(0,n.assertNodeType)("Expression")}}}),(0,i.default)("ForAwaitStatement",{visitor:["left","right","body"],aliases:["Scopable","Statement","For","BlockParent","Loop","ForXStatement"],fields:{left:{validate:(0,n.assertNodeType)("VariableDeclaration","LVal")},right:{validate:(0,n.assertNodeType)("Expression")},body:{validate:(0,n.assertNodeType)("Statement")}}}),(0,i.default)("BindExpression",{visitor:["object","callee"],aliases:["Expression"],fields:{}}),(0,i.default)("Import",{aliases:["Expression"]}),(0,i.default)("Decorator",{visitor:["expression"],fields:{expression:{validate:(0,n.assertNodeType)("Expression")}}}),(0,i.default)("DoExpression",{visitor:["body"],aliases:["Expression"],fields:{body:{validate:(0,n.assertNodeType)("BlockStatement")}}}),(0,i.default)("ExportDefaultSpecifier",{visitor:["exported"],aliases:["ModuleSpecifier"],fields:{exported:{validate:(0,n.assertNodeType)("Identifier")}}}),(0,i.default)("ExportNamespaceSpecifier",{visitor:["exported"],aliases:["ModuleSpecifier"],fields:{exported:{validate:(0,n.assertNodeType)("Identifier")}}}),(0,i.default)("RestProperty",{visitor:["argument"],aliases:["UnaryLike"],fields:{argument:{validate:(0,n.assertNodeType)("LVal")}}}),(0,i.default)("SpreadProperty",{visitor:["argument"],aliases:["UnaryLike"],fields:{argument:{validate:(0,n.assertNodeType)("Expression")}}})},function(e,t,r){"use strict";var n=r(26),i=function(e){return e&&e.__esModule?e:{default:e}}(n);(0,i.default)("AnyTypeAnnotation",{aliases:["Flow","FlowBaseAnnotation"],fields:{}}),(0,i.default)("ArrayTypeAnnotation",{visitor:["elementType"],aliases:["Flow"],fields:{}}),(0,i.default)("BooleanTypeAnnotation",{aliases:["Flow","FlowBaseAnnotation"],fields:{}}),(0,i.default)("BooleanLiteralTypeAnnotation",{aliases:["Flow"],fields:{}}),(0,i.default)("NullLiteralTypeAnnotation",{aliases:["Flow","FlowBaseAnnotation"],fields:{}}),(0,i.default)("ClassImplements",{visitor:["id","typeParameters"],aliases:["Flow"],fields:{}}),(0,i.default)("ClassProperty",{visitor:["key","value","typeAnnotation","decorators"],builder:["key","value","typeAnnotation","decorators","computed"],aliases:["Property"],fields:{computed:{validate:(0,n.assertValueType)("boolean"),default:!1}}}),(0,i.default)("DeclareClass",{visitor:["id","typeParameters","extends","body"],aliases:["Flow","FlowDeclaration","Statement","Declaration"],fields:{}}),(0,i.default)("DeclareFunction",{visitor:["id"],aliases:["Flow","FlowDeclaration","Statement","Declaration"],fields:{}}),(0,i.default)("DeclareInterface",{visitor:["id","typeParameters","extends","body"],aliases:["Flow","FlowDeclaration","Statement","Declaration"],fields:{}}),(0,i.default)("DeclareModule",{visitor:["id","body"],aliases:["Flow","FlowDeclaration","Statement","Declaration"],fields:{}}),(0,i.default)("DeclareModuleExports",{visitor:["typeAnnotation"],aliases:["Flow","FlowDeclaration","Statement","Declaration"],fields:{}}),(0,i.default)("DeclareTypeAlias",{visitor:["id","typeParameters","right"],aliases:["Flow","FlowDeclaration","Statement","Declaration"],fields:{}}),(0,i.default)("DeclareOpaqueType",{visitor:["id","typeParameters","supertype"],aliases:["Flow","FlowDeclaration","Statement","Declaration"],fields:{}}),(0,i.default)("DeclareVariable",{visitor:["id"],aliases:["Flow","FlowDeclaration","Statement","Declaration"],fields:{}}),(0,i.default)("DeclareExportDeclaration",{visitor:["declaration","specifiers","source"],aliases:["Flow","FlowDeclaration","Statement","Declaration"],fields:{}}),(0,i.default)("ExistentialTypeParam",{aliases:["Flow"]}),(0,i.default)("FunctionTypeAnnotation",{visitor:["typeParameters","params","rest","returnType"],aliases:["Flow"],fields:{}}),(0,i.default)("FunctionTypeParam",{visitor:["name","typeAnnotation"],aliases:["Flow"],fields:{}}),(0,i.default)("GenericTypeAnnotation",{visitor:["id","typeParameters"],aliases:["Flow"],fields:{}}),(0,i.default)("InterfaceExtends",{visitor:["id","typeParameters"],aliases:["Flow"],fields:{}}),(0,i.default)("InterfaceDeclaration",{visitor:["id","typeParameters","extends","body"],aliases:["Flow","FlowDeclaration","Statement","Declaration"],fields:{}}),(0,i.default)("IntersectionTypeAnnotation",{visitor:["types"],aliases:["Flow"],fields:{}}),(0,i.default)("MixedTypeAnnotation",{aliases:["Flow","FlowBaseAnnotation"]}),(0,i.default)("EmptyTypeAnnotation",{aliases:["Flow","FlowBaseAnnotation"]}),(0,i.default)("NullableTypeAnnotation",{visitor:["typeAnnotation"],aliases:["Flow"],fields:{}}),(0,i.default)("NumericLiteralTypeAnnotation",{aliases:["Flow"],fields:{}}),(0,i.default)("NumberTypeAnnotation",{aliases:["Flow","FlowBaseAnnotation"],fields:{}}),(0,i.default)("StringLiteralTypeAnnotation",{aliases:["Flow"],fields:{}}),(0,i.default)("StringTypeAnnotation",{aliases:["Flow","FlowBaseAnnotation"],fields:{}}),(0,i.default)("ThisTypeAnnotation",{aliases:["Flow","FlowBaseAnnotation"],fields:{}}),(0,i.default)("TupleTypeAnnotation",{visitor:["types"],aliases:["Flow"],fields:{}}),(0,i.default)("TypeofTypeAnnotation",{visitor:["argument"],aliases:["Flow"],fields:{}}),(0,i.default)("TypeAlias",{visitor:["id","typeParameters","right"],aliases:["Flow","FlowDeclaration","Statement","Declaration"],fields:{}}),(0,i.default)("OpaqueType",{visitor:["id","typeParameters","impltype","supertype"],aliases:["Flow","FlowDeclaration","Statement","Declaration"],fields:{}}),(0,i.default)("TypeAnnotation",{visitor:["typeAnnotation"],aliases:["Flow"],fields:{}}),(0,i.default)("TypeCastExpression",{visitor:["expression","typeAnnotation"],aliases:["Flow","ExpressionWrapper","Expression"],fields:{}}),(0,i.default)("TypeParameter",{visitor:["bound"],aliases:["Flow"],fields:{}}),(0,i.default)("TypeParameterDeclaration",{visitor:["params"],aliases:["Flow"],fields:{}}),(0,i.default)("TypeParameterInstantiation",{visitor:["params"],aliases:["Flow"],fields:{}}),(0,i.default)("ObjectTypeAnnotation",{visitor:["properties","indexers","callProperties"],aliases:["Flow"],fields:{}}),(0,i.default)("ObjectTypeCallProperty",{visitor:["value"],aliases:["Flow","UserWhitespacable"],fields:{}}),(0,i.default)("ObjectTypeIndexer",{visitor:["id","key","value"],aliases:["Flow","UserWhitespacable"],fields:{}}),(0,i.default)("ObjectTypeProperty",{visitor:["key","value"],aliases:["Flow","UserWhitespacable"],fields:{}}),(0,i.default)("ObjectTypeSpreadProperty",{visitor:["argument"],aliases:["Flow","UserWhitespacable"],fields:{}}),(0,i.default)("QualifiedTypeIdentifier",{visitor:["id","qualification"],aliases:["Flow"],fields:{}}),(0,i.default)("UnionTypeAnnotation",{visitor:["types"],aliases:["Flow"],fields:{}}),(0,i.default)("VoidTypeAnnotation",{aliases:["Flow","FlowBaseAnnotation"],fields:{}})},function(e,t,r){"use strict";r(26),r(386),r(387),r(389),r(391),r(392),r(388)},function(e,t,r){"use strict";var n=r(26),i=function(e){return e&&e.__esModule?e:{default:e}}(n);(0,i.default)("JSXAttribute",{visitor:["name","value"],aliases:["JSX","Immutable"],fields:{name:{validate:(0,n.assertNodeType)("JSXIdentifier","JSXNamespacedName")},value:{optional:!0,validate:(0,n.assertNodeType)("JSXElement","StringLiteral","JSXExpressionContainer")}}}),(0,i.default)("JSXClosingElement",{visitor:["name"],aliases:["JSX","Immutable"],fields:{name:{validate:(0,n.assertNodeType)("JSXIdentifier","JSXMemberExpression")}}}),(0,i.default)("JSXElement",{builder:["openingElement","closingElement","children","selfClosing"],visitor:["openingElement","children","closingElement"],aliases:["JSX","Immutable","Expression"],fields:{openingElement:{validate:(0,n.assertNodeType)("JSXOpeningElement")},closingElement:{optional:!0,validate:(0,n.assertNodeType)("JSXClosingElement")},children:{validate:(0,n.chain)((0,n.assertValueType)("array"),(0,n.assertEach)((0,n.assertNodeType)("JSXText","JSXExpressionContainer","JSXSpreadChild","JSXElement")))}}}),(0,i.default)("JSXEmptyExpression",{aliases:["JSX","Expression"]}),(0,i.default)("JSXExpressionContainer",{visitor:["expression"],aliases:["JSX","Immutable"],fields:{expression:{validate:(0,n.assertNodeType)("Expression")}}}),(0,i.default)("JSXSpreadChild",{visitor:["expression"],aliases:["JSX","Immutable"],fields:{expression:{validate:(0,n.assertNodeType)("Expression")}}}),(0,i.default)("JSXIdentifier",{builder:["name"],aliases:["JSX","Expression"],fields:{name:{validate:(0,n.assertValueType)("string")}}}),(0,i.default)("JSXMemberExpression",{visitor:["object","property"],aliases:["JSX","Expression"],fields:{object:{validate:(0,n.assertNodeType)("JSXMemberExpression","JSXIdentifier")},property:{validate:(0,n.assertNodeType)("JSXIdentifier")}}}),(0,i.default)("JSXNamespacedName",{visitor:["namespace","name"],aliases:["JSX"],fields:{namespace:{validate:(0,n.assertNodeType)("JSXIdentifier")},name:{validate:(0,n.assertNodeType)("JSXIdentifier")}}}),(0,i.default)("JSXOpeningElement",{builder:["name","attributes","selfClosing"],visitor:["name","attributes"],aliases:["JSX","Immutable"],fields:{name:{validate:(0,n.assertNodeType)("JSXIdentifier","JSXMemberExpression")},selfClosing:{default:!1,validate:(0,n.assertValueType)("boolean")},attributes:{validate:(0,n.chain)((0,n.assertValueType)("array"),(0,n.assertEach)((0,n.assertNodeType)("JSXAttribute","JSXSpreadAttribute")))}}}),(0,i.default)("JSXSpreadAttribute",{visitor:["argument"],aliases:["JSX"],fields:{argument:{validate:(0,n.assertNodeType)("Expression")}}}),(0,i.default)("JSXText",{aliases:["JSX","Immutable"],builder:["value"],fields:{value:{validate:(0,n.assertValueType)("string")}}})},function(e,t,r){"use strict";var n=r(26),i=function(e){return e&&e.__esModule?e:{default:e}}(n);(0,i.default)("Noop",{visitor:[]}),(0,i.default)("ParenthesizedExpression",{visitor:["expression"],aliases:["Expression","ExpressionWrapper"],fields:{expression:{validate:(0,n.assertNodeType)("Expression")}}})},function(e,t,r){"use strict";function n(e){var t=i(e);return 1===t.length?t[0]:o.unionTypeAnnotation(t)}function i(e){for(var t={},r={},n=[],s=[],a=0;a<e.length;a++){var u=e[a];if(u&&!(s.indexOf(u)>=0)){if(o.isAnyTypeAnnotation(u))return[u];if(o.isFlowBaseAnnotation(u))r[u.type]=u;else if(o.isUnionTypeAnnotation(u))n.indexOf(u.types)<0&&(e=e.concat(u.types),n.push(u.types));else if(o.isGenericTypeAnnotation(u)){var l=u.id.name;if(t[l]){var c=t[l];c.typeParameters?u.typeParameters&&(c.typeParameters.params=i(c.typeParameters.params.concat(u.typeParameters.params))):c=u.typeParameters}else t[l]=u}else s.push(u)}}for(var f in r)s.push(r[f]);for(var p in t)s.push(t[p]);return s}function s(e){if("string"===e)return o.stringTypeAnnotation();if("number"===e)return o.numberTypeAnnotation();if("undefined"===e)return o.voidTypeAnnotation();if("boolean"===e)return o.booleanTypeAnnotation();if("function"===e)return o.genericTypeAnnotation(o.identifier("Function"));if("object"===e)return o.genericTypeAnnotation(o.identifier("Object"));if("symbol"===e)return o.genericTypeAnnotation(o.identifier("Symbol"));throw new Error("Invalid typeof value")}t.__esModule=!0,t.createUnionTypeAnnotation=n,t.removeTypeDuplicates=i,t.createTypeAnnotationBasedOnTypeof=s;var a=r(1),o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(a)},function(e,t,r){"use strict";function n(e){return!!e&&/^[a-z]|\-/.test(e)}function i(e,t){for(var r=e.value.split(/\r\n|\n|\r/),n=0,i=0;i<r.length;i++)r[i].match(/[^ \t]/)&&(n=i);for(var s="",a=0;a<r.length;a++){var u=r[a],l=0===a,c=a===r.length-1,f=a===n,p=u.replace(/\t/g," ");l||(p=p.replace(/^[ ]+/,"")),c||(p=p.replace(/[ ]+$/,"")),p&&(f||(p+=" "),s+=p)}s&&t.push(o.stringLiteral(s))}function s(e){for(var t=[],r=0;r<e.children.length;r++){var n=e.children[r];o.isJSXText(n)?i(n,t):(o.isJSXExpressionContainer(n)&&(n=n.expression),o.isJSXEmptyExpression(n)||t.push(n))}return t}t.__esModule=!0,t.isReactComponent=void 0,t.isCompatTag=n,t.buildChildren=s;var a=r(1),o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(a);t.isReactComponent=o.buildMatchMemberExpression("React.Component")},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){var r=E.getBindingIdentifiers.keys[t.type];if(r)for(var n=0;n<r.length;n++){var i=r[n],s=t[i];if(Array.isArray(s)){if(s.indexOf(e)>=0)return!0}else if(s===e)return!0}return!1}function s(e,t){switch(t.type){case"BindExpression":return t.object===e||t.callee===e;case"MemberExpression":case"JSXMemberExpression":return!(t.property!==e||!t.computed)||t.object===e;case"MetaProperty":return!1;case"ObjectProperty":if(t.key===e)return t.computed;case"VariableDeclarator":return t.id!==e;case"ArrowFunctionExpression":case"FunctionDeclaration":case"FunctionExpression":for(var r=t.params,n=Array.isArray(r),i=0,r=n?r:(0,b.default)(r);;){var s;if(n){if(i>=r.length)break;s=r[i++]}else{if(i=r.next(),i.done)break;s=i.value}if(s===e)return!1}return t.id!==e;case"ExportSpecifier":return!t.source&&t.local===e;case"ExportNamespaceSpecifier":case"ExportDefaultSpecifier":return!1;case"JSXAttribute":return t.name!==e;case"ClassProperty":return t.key===e?t.computed:t.value===e;case"ImportDefaultSpecifier":case"ImportNamespaceSpecifier":case"ImportSpecifier":return!1;case"ClassDeclaration":case"ClassExpression":return t.id!==e;case"ClassMethod":case"ObjectMethod":return t.key===e&&t.computed;case"LabeledStatement":return!1;case"CatchClause":return t.param!==e;case"RestElement":return!1;case"AssignmentExpression":case"AssignmentPattern":return t.right===e;case"ObjectPattern":case"ArrayPattern":return!1}return!0}function a(e){return"string"==typeof e&&!A.default.keyword.isReservedWordES6(e,!0)&&("await"!==e&&A.default.keyword.isIdentifierNameES6(e))}function o(e){return _.isVariableDeclaration(e)&&("var"!==e.kind||e[D.BLOCK_SCOPED_SYMBOL])}function u(e){return _.isFunctionDeclaration(e)||_.isClassDeclaration(e)||_.isLet(e)}function l(e){return _.isVariableDeclaration(e,{kind:"var"})&&!e[D.BLOCK_SCOPED_SYMBOL]}function c(e){return _.isImportDefaultSpecifier(e)||_.isIdentifier(e.imported||e.exported,{name:"default"})}function f(e,t){return(!_.isBlockStatement(e)||!_.isFunction(t,{body:e}))&&_.isScopable(e)}function p(e){return!!_.isType(e.type,"Immutable")||!!_.isIdentifier(e)&&"undefined"===e.name}function d(e,t){if("object"!==(void 0===e?"undefined":(0,v.default)(e))||"object"!==(void 0===e?"undefined":(0,v.default)(e))||null==e||null==t)return e===t;if(e.type!==t.type)return!1;for(var r=(0,m.default)(_.NODE_FIELDS[e.type]||e.type),n=r,i=Array.isArray(n),s=0,n=i?n:(0,b.default)(n);;){var a;if(i){if(s>=n.length)break;a=n[s++]}else{if(s=n.next(),s.done)break;a=s.value}var o=a;if((0,v.default)(e[o])!==(0,v.default)(t[o]))return!1;if(Array.isArray(e[o])){if(!Array.isArray(t[o]))return!1;if(e[o].length!==t[o].length)return!1;for(var u=0;u<e[o].length;u++)if(!d(e[o][u],t[o][u]))return!1}else if(!d(e[o],t[o]))return!1}return!0}t.__esModule=!0;var h=r(14),m=n(h),y=r(11),v=n(y),g=r(2),b=n(g);t.isBinding=i,t.isReferenced=s,t.isValidIdentifier=a,t.isLet=o,t.isBlockScoped=u,t.isVar=l,t.isSpecifierDefault=c,t.isScope=f,t.isImmutable=p,t.isNodesEquivalent=d;var E=r(226),x=r(97),A=n(x),S=r(1),_=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(S),D=r(135)},function(e,t){"use strict";function r(e,t,r){e instanceof RegExp&&(e=n(e,r)),t instanceof RegExp&&(t=n(t,r));var s=i(e,t,r);return s&&{start:s[0],end:s[1],pre:r.slice(0,s[0]),body:r.slice(s[0]+e.length,s[1]),post:r.slice(s[1]+t.length)}}function n(e,t){var r=t.match(e);return r?r[0]:null}function i(e,t,r){var n,i,s,a,o,u=r.indexOf(e),l=r.indexOf(t,u+1),c=u;if(u>=0&&l>0){for(n=[],s=r.length;c>=0&&!o;)c==u?(n.push(c),u=r.indexOf(e,c+1)):1==n.length?o=[n.pop(),l]:(i=n.pop(),i<s&&(s=i,a=l),l=r.indexOf(t,c+1)),c=u<l&&u>=0?u:l;n.length&&(o=[s,a])}return o}e.exports=r,r.range=i},function(e,t){"use strict";function r(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function n(e){return 3*e.length/4-r(e)}function i(e){var t,n,i,s,a,o=e.length;s=r(e),a=new c(3*o/4-s),n=s>0?o-4:o;var u=0;for(t=0;t<n;t+=4)i=l[e.charCodeAt(t)]<<18|l[e.charCodeAt(t+1)]<<12|l[e.charCodeAt(t+2)]<<6|l[e.charCodeAt(t+3)],a[u++]=i>>16&255,a[u++]=i>>8&255,a[u++]=255&i;return 2===s?(i=l[e.charCodeAt(t)]<<2|l[e.charCodeAt(t+1)]>>4,a[u++]=255&i):1===s&&(i=l[e.charCodeAt(t)]<<10|l[e.charCodeAt(t+1)]<<4|l[e.charCodeAt(t+2)]>>2,a[u++]=i>>8&255,a[u++]=255&i),a}function s(e){return u[e>>18&63]+u[e>>12&63]+u[e>>6&63]+u[63&e]}function a(e,t,r){for(var n,i=[],a=t;a<r;a+=3)n=(e[a]<<16)+(e[a+1]<<8)+e[a+2],i.push(s(n));return i.join("")}function o(e){for(var t,r=e.length,n=r%3,i="",s=[],o=0,l=r-n;o<l;o+=16383)s.push(a(e,o,o+16383>l?l:o+16383));return 1===n?(t=e[r-1],i+=u[t>>2],i+=u[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=u[t>>10],i+=u[t>>4&63],i+=u[t<<2&63],i+="="),s.push(i),s.join("")}t.byteLength=n,t.toByteArray=i,t.fromByteArray=o;for(var u=[],l=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,d=f.length;p<d;++p)u[p]=f[p],l[f.charCodeAt(p)]=p;l["-".charCodeAt(0)]=62,l["_".charCodeAt(0)]=63},function(e,t,r){"use strict";function n(e){return parseInt(e,10)==e?parseInt(e,10):e.charCodeAt(0)}function i(e){return e.split("\\\\").join(m).split("\\{").join(y).split("\\}").join(v).split("\\,").join(g).split("\\.").join(b)}function s(e){return e.split(m).join("\\").split(y).join("{").split(v).join("}").split(g).join(",").split(b).join(".")}function a(e){if(!e)return[""];var t=[],r=h("{","}",e);if(!r)return e.split(",");var n=r.pre,i=r.body,s=r.post,o=n.split(",");o[o.length-1]+="{"+i+"}";var u=a(s);return s.length&&(o[o.length-1]+=u.shift(),o.push.apply(o,u)),t.push.apply(t,o),t}function o(e){return e?("{}"===e.substr(0,2)&&(e="\\{\\}"+e.substr(2)),p(i(e),!0).map(s)):[]}function u(e){return"{"+e+"}"}function l(e){return/^-?0\d/.test(e)}function c(e,t){return e<=t}function f(e,t){return e>=t}function p(e,t){var r=[],i=h("{","}",e);if(!i||/\$$/.test(i.pre))return[e];var s=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),o=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),m=s||o,y=i.body.indexOf(",")>=0;if(!m&&!y)return i.post.match(/,.*\}/)?(e=i.pre+"{"+i.body+v+i.post,p(e)):[e];var g;if(m)g=i.body.split(/\.\./);else if(g=a(i.body),1===g.length&&(g=p(g[0],!1).map(u),1===g.length)){var b=i.post.length?p(i.post,!1):[""];return b.map(function(e){return i.pre+g[0]+e})}var E,x=i.pre,b=i.post.length?p(i.post,!1):[""];if(m){var A=n(g[0]),S=n(g[1]),_=Math.max(g[0].length,g[1].length),D=3==g.length?Math.abs(n(g[2])):1,C=c;S<A&&(D*=-1,C=f);var w=g.some(l);E=[];for(var P=A;C(P,S);P+=D){var k;if(o)"\\"===(k=String.fromCharCode(P))&&(k="");else if(k=String(P),w){var F=_-k.length;if(F>0){var T=new Array(F+1).join("0");k=P<0?"-"+T+k.slice(1):T+k}}E.push(k)}}else E=d(g,function(e){return p(e,!1)});for(var O=0;O<E.length;O++)for(var B=0;B<b.length;B++){var R=x+E[O]+b[B];(!t||m||R)&&r.push(R)}return r}var d=r(402),h=r(396);e.exports=o;var m="\0SLASH"+Math.random()+"\0",y="\0OPEN"+Math.random()+"\0",v="\0CLOSE"+Math.random()+"\0",g="\0COMMA"+Math.random()+"\0",b="\0PERIOD"+Math.random()+"\0"},function(e,t,r){(function(e){"use strict";function n(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function i(e,t){if(n()<t)throw new RangeError("Invalid typed array length");return s.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t),e.__proto__=s.prototype):(null===e&&(e=new s(t)),e.length=t),e}function s(e,t,r){if(!(s.TYPED_ARRAY_SUPPORT||this instanceof s))return new s(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return l(this,e)}return a(this,e,t,r)}function a(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number') +;return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?p(e,t,r,n):"string"==typeof t?c(e,t,r):d(e,t)}function o(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function u(e,t,r,n){return o(t),t<=0?i(e,t):void 0!==r?"string"==typeof n?i(e,t).fill(r,n):i(e,t).fill(r):i(e,t)}function l(e,t){if(o(t),e=i(e,t<0?0:0|h(t)),!s.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function c(e,t,r){if("string"==typeof r&&""!==r||(r="utf8"),!s.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|y(t,r);e=i(e,n);var a=e.write(t,r);return a!==n&&(e=e.slice(0,a)),e}function f(e,t){var r=t.length<0?0:0|h(t.length);e=i(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function p(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n),s.TYPED_ARRAY_SUPPORT?(e=t,e.__proto__=s.prototype):e=f(e,t),e}function d(e,t){if(s.isBuffer(t)){var r=0|h(t.length);return e=i(e,r),0===e.length?e:(t.copy(e,0,0,r),e)}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||X(t.length)?i(e,0):f(e,t);if("Buffer"===t.type&&Q(t.data))return f(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function h(e){if(e>=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|e}function m(e){return+e!=e&&(e=0),s.alloc(+e)}function y(e,t){if(s.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Y(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return H(e).length;default:if(n)return Y(e).length;t=(""+t).toLowerCase(),n=!0}}function v(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if(r>>>=0,t>>>=0,r<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return O(this,t,r);case"utf8":case"utf-8":return P(this,t,r);case"ascii":return F(this,t,r);case"latin1":case"binary":return T(this,t,r);case"base64":return w(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function g(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function b(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=s.from(t,n)),s.isBuffer(t))return 0===t.length?-1:E(e,t,r,n,i);if("number"==typeof t)return t&=255,s.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):E(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function E(e,t,r,n,i){function s(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}var a=1,o=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,o/=2,u/=2,r/=2}var l;if(i){var c=-1;for(l=r;l<o;l++)if(s(e,l)===s(t,-1===c?0:l-c)){if(-1===c&&(c=l),l-c+1===u)return c*a}else-1!==c&&(l-=l-c),c=-1}else for(r+u>o&&(r=o-u),l=r;l>=0;l--){for(var f=!0,p=0;p<u;p++)if(s(e,l+p)!==s(t,p)){f=!1;break}if(f)return l}return-1}function x(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var a=0;a<n;++a){var o=parseInt(t.substr(2*a,2),16);if(isNaN(o))return a;e[r+a]=o}return a}function A(e,t,r,n){return J(Y(t,e.length-r),e,r,n)}function S(e,t,r,n){return J(q(t),e,r,n)}function _(e,t,r,n){return S(e,t,r,n)}function D(e,t,r,n){return J(H(t),e,r,n)}function C(e,t,r,n){return J(K(t,e.length-r),e,r,n)}function w(e,t,r){return 0===t&&r===e.length?z.fromByteArray(e):z.fromByteArray(e.slice(t,r))}function P(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var s=e[i],a=null,o=s>239?4:s>223?3:s>191?2:1;if(i+o<=r){var u,l,c,f;switch(o){case 1:s<128&&(a=s);break;case 2:u=e[i+1],128==(192&u)&&(f=(31&s)<<6|63&u)>127&&(a=f);break;case 3:u=e[i+1],l=e[i+2],128==(192&u)&&128==(192&l)&&(f=(15&s)<<12|(63&u)<<6|63&l)>2047&&(f<55296||f>57343)&&(a=f);break;case 4:u=e[i+1],l=e[i+2],c=e[i+3],128==(192&u)&&128==(192&l)&&128==(192&c)&&(f=(15&s)<<18|(63&u)<<12|(63&l)<<6|63&c)>65535&&f<1114112&&(a=f)}}null===a?(a=65533,o=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|1023&a),n.push(a),i+=o}return k(n)}function k(e){var t=e.length;if(t<=Z)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Z));return r}function F(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function T(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function O(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",s=t;s<r;++s)i+=W(e[s]);return i}function B(e,t,r){for(var n=e.slice(t,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+256*n[s+1]);return i}function R(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function I(e,t,r,n,i,a){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<a)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function M(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,s=Math.min(e.length-r,2);i<s;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function N(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,s=Math.min(e.length-r,4);i<s;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function L(e,t,r,n,i,s){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function j(e,t,r,n,i){return i||L(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),$.write(e,t,r,n,23,4),r+4}function U(e,t,r,n,i){return i||L(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),$.write(e,t,r,n,52,8),r+8}function V(e){if(e=G(e).replace(ee,""),e.length<2)return"";for(;e.length%4!=0;)e+="=";return e}function G(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function W(e){return e<16?"0"+e.toString(16):e.toString(16)}function Y(e,t){t=t||1/0;for(var r,n=e.length,i=null,s=[],a=0;a<n;++a){if((r=e.charCodeAt(a))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function q(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}function K(e,t){for(var r,n,i,s=[],a=0;a<e.length&&!((t-=2)<0);++a)r=e.charCodeAt(a),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function H(e){return z.toByteArray(V(e))}function J(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function X(e){return e!==e}var z=r(397),$=r(465),Q=r(400);t.Buffer=s,t.SlowBuffer=m,t.INSPECT_MAX_BYTES=50,s.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=n(),s.poolSize=8192,s._augment=function(e){return e.__proto__=s.prototype,e},s.from=function(e,t,r){return a(null,e,t,r)},s.TYPED_ARRAY_SUPPORT&&(s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&s[Symbol.species]===s&&Object.defineProperty(s,Symbol.species,{value:null,configurable:!0})),s.alloc=function(e,t,r){return u(null,e,t,r)},s.allocUnsafe=function(e){return l(null,e)},s.allocUnsafeSlow=function(e){return l(null,e)},s.isBuffer=function(e){return!(null==e||!e._isBuffer)},s.compare=function(e,t){if(!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,a=Math.min(r,n);i<a;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},s.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(e,t){if(!Q(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return s.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=s.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var a=e[r];if(!s.isBuffer(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(n,i),i+=a.length}return n},s.byteLength=y,s.prototype._isBuffer=!0,s.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)g(this,t,t+1);return this},s.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)g(this,t,t+3),g(this,t+1,t+2);return this},s.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},s.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?P(this,0,e):v.apply(this,arguments)},s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===s.compare(this,e)},s.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"},s.prototype.compare=function(e,t,r,n,i){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;for(var a=i-n,o=r-t,u=Math.min(a,o),l=this.slice(n,i),c=e.slice(t,r),f=0;f<u;++f)if(l[f]!==c[f]){a=l[f],o=c[f];break}return a<o?-1:o<a?1:0},s.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},s.prototype.indexOf=function(e,t,r){return b(this,e,t,r,!0)},s.prototype.lastIndexOf=function(e,t,r){return b(this,e,t,r,!1)},s.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return x(this,e,t,r);case"utf8":case"utf-8":return A(this,e,t,r);case"ascii":return S(this,e,t,r);case"latin1":case"binary":return _(this,e,t,r);case"base64":return D(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Z=4096;s.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var n;if(s.TYPED_ARRAY_SUPPORT)n=this.subarray(e,t),n.__proto__=s.prototype;else{var i=t-e;n=new s(i,void 0);for(var a=0;a<i;++a)n[a]=this[a+e]}return n},s.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n},s.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},s.prototype.readUInt8=function(e,t){return t||R(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return t||R(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return t||R(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return t||R(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return t||R(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*t)),n},s.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=t,i=1,s=this[e+--n];n>0&&(i*=256);)s+=this[e+--n]*i;return i*=128,s>=i&&(s-=Math.pow(2,8*t)),s},s.prototype.readInt8=function(e,t){return t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){t||R(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(e,t){t||R(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(e,t){return t||R(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return t||R(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return t||R(e,4,this.length),$.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return t||R(e,4,this.length),$.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return t||R(e,8,this.length),$.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return t||R(e,8,this.length),$.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t|=0,r|=0,!n){I(this,e,t,r,Math.pow(2,8*r)-1,0)}var i=1,s=0;for(this[t]=255&e;++s<r&&(i*=256);)this[t+s]=e/i&255;return t+r},s.prototype.writeUIntBE=function(e,t,r,n){if(e=+e,t|=0,r|=0,!n){I(this,e,t,r,Math.pow(2,8*r)-1,0)}var i=r-1,s=1;for(this[t+i]=255&e;--i>=0&&(s*=256);)this[t+i]=e/s&255;return t+r},s.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,1,255,0),s.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):M(this,e,t,!0),t+2},s.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):M(this,e,t,!1),t+2},s.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):N(this,e,t,!0),t+4},s.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},s.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);I(this,e,t,r,i-1,-i)}var s=0,a=1,o=0;for(this[t]=255&e;++s<r&&(a*=256);)e<0&&0===o&&0!==this[t+s-1]&&(o=1),this[t+s]=(e/a>>0)-o&255;return t+r},s.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);I(this,e,t,r,i-1,-i)}var s=r-1,a=1,o=0;for(this[t+s]=255&e;--s>=0&&(a*=256);)e<0&&0===o&&0!==this[t+s+1]&&(o=1),this[t+s]=(e/a>>0)-o&255;return t+r},s.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,1,127,-128),s.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):M(this,e,t,!0),t+2},s.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):M(this,e,t,!1),t+2},s.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):N(this,e,t,!0),t+4},s.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},s.prototype.writeFloatLE=function(e,t,r){return j(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return j(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return U(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return U(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,a=n-r;if(this===e&&r<t&&t<n)for(i=a-1;i>=0;--i)e[i+t]=this[i+r];else if(a<1e3||!s.TYPED_ARRAY_SUPPORT)for(i=0;i<a;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+a),t);return a},s.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0);var a;if("number"==typeof e)for(a=t;a<r;++a)this[a]=e;else{var o=s.isBuffer(e)?e:Y(new s(e,n).toString()),u=o.length;for(a=0;a<r-t;++a)this[a+t]=o[a%u]}return this};var ee=/[^+\/0-9A-Za-z-_]/g}).call(t,function(){return this}())},function(e,t){"use strict";var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t,r){(function(t){"use strict";function n(e){this.enabled=e&&void 0!==e.enabled?e.enabled:c}function i(e){var t=function e(){return s.apply(e,arguments)};return t._styles=e,t.enabled=this.enabled,t.__proto__=h,t}function s(){var e=arguments,t=e.length,r=0!==t&&String(arguments[0]);if(t>1)for(var n=1;n<t;n++)r+=" "+e[n];if(!this.enabled||!r)return r;var i=this._styles,s=i.length,a=o.dim.open;for(!p||-1===i.indexOf("gray")&&-1===i.indexOf("grey")||(o.dim.open="");s--;){var u=o[i[s]];r=u.open+r.replace(u.closeRe,u.open)+u.close}return o.dim.open=a,r}var a=r(460),o=r(289),u=r(622),l=r(464),c=r(623),f=Object.defineProperties,p="win32"===t.platform&&!/^xterm/i.test(t.env.TERM);p&&(o.blue.open="[94m");var d=function(){var e={};return Object.keys(o).forEach(function(t){o[t].closeRe=new RegExp(a(o[t].close),"g"),e[t]={get:function(){return i.call(this,this._styles.concat(t))}}}),e}(),h=f(function(){},d);f(n.prototype,function(){var e={};return Object.keys(d).forEach(function(t){e[t]={get:function(){return i.call(this,[t])}}}),e}()),e.exports=new n,e.exports.styles=o,e.exports.hasColor=l,e.exports.stripColor=u,e.exports.supportsColor=c}).call(t,r(8))},function(e,t){"use strict";e.exports=function(e,t){for(var n=[],i=0;i<e.length;i++){var s=t(e[i],i);r(s)?n.push.apply(n,s):n.push(s)}return n};var r=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,r){(function(e){"use strict";function n(t){return new e(t,"base64").toString()}function i(e){return e.split(",").pop()}function s(e,r){var n=t.mapFileCommentRegex.exec(e),i=n[1]||n[2],s=u.resolve(r,i);try{return o.readFileSync(s,"utf8")}catch(e){throw new Error("An error occurred while trying to read the map file at "+s+"\n"+e)}}function a(e,t){t=t||{},t.isFileComment&&(e=s(e,t.commentFileDir)),t.hasComment&&(e=i(e)),t.isEncoded&&(e=n(e)),(t.isJSON||t.isEncoded)&&(e=JSON.parse(e)),this.sourcemap=e}var o=r(115),u=r(19);Object.defineProperty(t,"commentRegex",{get:function(){return/^\s*\/(?:\/|\*)[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/gm}}),Object.defineProperty(t,"mapFileCommentRegex",{get:function(){return/(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/){1}[ \t]*$)/gm}}),a.prototype.toJSON=function(e){return JSON.stringify(this.sourcemap,null,e)},a.prototype.toBase64=function(){var t=this.toJSON();return new e(t).toString("base64")},a.prototype.toComment=function(e){var t=this.toBase64(),r="sourceMappingURL=data:application/json;charset=utf-8;base64,"+t;return e&&e.multiline?"/*# "+r+" */":"//# "+r},a.prototype.toObject=function(){return JSON.parse(this.toJSON())},a.prototype.addProperty=function(e,t){if(this.sourcemap.hasOwnProperty(e))throw new Error("property %s already exists on the sourcemap, use set property instead");return this.setProperty(e,t)},a.prototype.setProperty=function(e,t){return this.sourcemap[e]=t,this},a.prototype.getProperty=function(e){return this.sourcemap[e]},t.fromObject=function(e){return new a(e)},t.fromJSON=function(e){return new a(e,{isJSON:!0})},t.fromBase64=function(e){return new a(e,{isEncoded:!0})},t.fromComment=function(e){return e=e.replace(/^\/\*/g,"//").replace(/\*\/$/g,""),new a(e,{isEncoded:!0,hasComment:!0})},t.fromMapFileComment=function(e,t){return new a(e,{commentFileDir:t,isFileComment:!0,isJSON:!0})},t.fromSource=function(e){var r=e.match(t.commentRegex);return r?t.fromComment(r.pop()):null},t.fromMapFileSource=function(e,r){var n=e.match(t.mapFileCommentRegex);return n?t.fromMapFileComment(n.pop(),r):null},t.removeComments=function(e){return e.replace(t.commentRegex,"")},t.removeMapFileComments=function(e){return e.replace(t.mapFileCommentRegex,"")},t.generateMapFileComment=function(e,t){var r="sourceMappingURL="+e;return t&&t.multiline?"/*# "+r+" */":"//# "+r}}).call(t,r(399).Buffer)},function(e,t,r){"use strict";r(59),r(157),e.exports=r(439)},function(e,t,r){"use strict";var n=r(5),i=n.JSON||(n.JSON={stringify:JSON.stringify});e.exports=function(e){return i.stringify.apply(i,arguments)}},function(e,t,r){"use strict";r(96),r(157),r(59),r(441),r(451),r(450),r(449),e.exports=r(5).Map},function(e,t,r){"use strict";r(442),e.exports=9007199254740991},function(e,t,r){"use strict";r(443),e.exports=r(5).Object.assign},function(e,t,r){"use strict";r(444);var n=r(5).Object;e.exports=function(e,t){return n.create(e,t)}},function(e,t,r){"use strict";r(158),e.exports=r(5).Object.getOwnPropertySymbols},function(e,t,r){"use strict";r(445),e.exports=r(5).Object.keys},function(e,t,r){"use strict";r(446),e.exports=r(5).Object.setPrototypeOf},function(e,t,r){"use strict";r(158),e.exports=r(5).Symbol.for},function(e,t,r){"use strict";r(158),r(96),r(452),r(453),e.exports=r(5).Symbol},function(e,t,r){"use strict";r(157),r(59),e.exports=r(156).f("iterator")},function(e,t,r){"use strict";r(96),r(59),r(447),r(455),r(454),e.exports=r(5).WeakMap},function(e,t,r){"use strict";r(96),r(59),r(448),r(457),r(456),e.exports=r(5).WeakSet},function(e,t){"use strict";e.exports=function(){}},function(e,t,r){"use strict";var n=r(55);e.exports=function(e,t){var r=[];return n(e,!1,r.push,r,t),r}},function(e,t,r){"use strict";var n=r(37),i=r(153),s=r(438);e.exports=function(e){return function(t,r,a){var o,u=n(t),l=i(u.length),c=s(a,l);if(e&&r!=r){for(;l>c;)if((o=u[c++])!=o)return!0}else for(;l>c;c++)if((e||c in u)&&u[c]===r)return e||c||0;return!e&&-1}}},function(e,t,r){"use strict";var n=r(16),i=r(232),s=r(13)("species");e.exports=function(e){var t;return i(e)&&(t=e.constructor,"function"!=typeof t||t!==Array&&!i(t.prototype)||(t=void 0),n(t)&&null===(t=t[s])&&(t=void 0)),void 0===t?Array:t}},function(e,t,r){"use strict";var n=r(421);e.exports=function(e,t){return new(n(e))(t)}},function(e,t,r){"use strict";var n=r(23).f,i=r(90),s=r(146),a=r(43),o=r(136),u=r(55),l=r(143),c=r(233),f=r(436),p=r(22),d=r(57).fastKey,h=r(58),m=p?"_s":"size",y=function(e,t){var r,n=d(t);if("F"!==n)return e._i[n];for(r=e._f;r;r=r.n)if(r.k==t)return r};e.exports={getConstructor:function(e,t,r,l){var c=e(function(e,n){o(e,c,t,"_i"),e._t=t,e._i=i(null),e._f=void 0,e._l=void 0,e[m]=0,void 0!=n&&u(n,r,e[l],e)});return s(c.prototype,{clear:function(){for(var e=h(this,t),r=e._i,n=e._f;n;n=n.n)n.r=!0,n.p&&(n.p=n.p.n=void 0),delete r[n.i];e._f=e._l=void 0,e[m]=0},delete:function(e){var r=h(this,t),n=y(r,e);if(n){var i=n.n,s=n.p;delete r._i[n.i],n.r=!0,s&&(s.n=i),i&&(i.p=s),r._f==n&&(r._f=i),r._l==n&&(r._l=s),r[m]--}return!!n},forEach:function(e){h(this,t);for(var r,n=a(e,arguments.length>1?arguments[1]:void 0,3);r=r?r.n:this._f;)for(n(r.v,r.k,this);r&&r.r;)r=r.p},has:function(e){return!!y(h(this,t),e)}}),p&&n(c.prototype,"size",{get:function(){return h(this,t)[m]}}),c},def:function(e,t,r){var n,i,s=y(e,t);return s?s.v=r:(e._l=s={i:i=d(t,!0),k:t,v:r,p:n=e._l,n:void 0,r:!1},e._f||(e._f=s),n&&(n.n=s),e[m]++,"F"!==i&&(e._i[i]=s)),e},getEntry:y,setStrong:function(e,t,r){l(e,t,function(e,r){this._t=h(e,t),this._k=r,this._l=void 0},function(){for(var e=this,t=e._k,r=e._l;r&&r.r;)r=r.p;return e._t&&(e._l=r=r?r.n:e._t._f)?"keys"==t?c(0,r.k):"values"==t?c(0,r.v):c(0,[r.k,r.v]):(e._t=void 0,c(1))},r?"entries":"values",!r,!0),f(t)}}},function(e,t,r){"use strict";var n=r(228),i=r(419);e.exports=function(e){return function(){if(n(this)!=e)throw TypeError(e+"#toJSON isn't generic");return i(this)}}},function(e,t,r){"use strict";var n=r(44),i=r(145),s=r(91);e.exports=function(e){var t=n(e),r=i.f;if(r)for(var a,o=r(e),u=s.f,l=0;o.length>l;)u.call(e,a=o[l++])&&t.push(a);return t}},function(e,t,r){"use strict";var n=r(15).document;e.exports=n&&n.documentElement},function(e,t,r){"use strict";var n=r(56),i=r(13)("iterator"),s=Array.prototype;e.exports=function(e){return void 0!==e&&(n.Array===e||s[i]===e)}},function(e,t,r){"use strict";var n=r(21);e.exports=function(e,t,r,i){try{return i?t(n(r)[0],r[1]):t(r)}catch(t){var s=e.return;throw void 0!==s&&n(s.call(e)),t}}},function(e,t,r){"use strict";var n=r(90),i=r(92),s=r(93),a={};r(29)(a,r(13)("iterator"),function(){return this}),e.exports=function(e,t,r){e.prototype=n(a,{next:i(1,r)}),s(e,t+" Iterator")}},function(e,t,r){"use strict";var n=r(44),i=r(37);e.exports=function(e,t){for(var r,s=i(e),a=n(s),o=a.length,u=0;o>u;)if(s[r=a[u++]]===t)return r}},function(e,t,r){"use strict";var n=r(23),i=r(21),s=r(44);e.exports=r(22)?Object.defineProperties:function(e,t){i(e);for(var r,a=s(t),o=a.length,u=0;o>u;)n.f(e,r=a[u++],t[r]);return e}},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=r(37),s=r(236).f,a={}.toString,o="object"==("undefined"==typeof window?"undefined":n(window))&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],u=function(e){try{return s(e)}catch(e){return o.slice()}};e.exports.f=function(e){return o&&"[object Window]"==a.call(e)?u(e):s(i(e))}},function(e,t,r){"use strict";var n=r(28),i=r(94),s=r(150)("IE_PROTO"),a=Object.prototype;e.exports=Object.getPrototypeOf||function(e){return e=i(e),n(e,s)?e[s]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?a:null}},function(e,t,r){"use strict";var n=r(12),i=r(5),s=r(27);e.exports=function(e,t){var r=(i.Object||{})[e]||Object[e],a={};a[e]=t(r),n(n.S+n.F*s(function(){r(1)}),"Object",a)}},function(e,t,r){"use strict";var n=r(16),i=r(21),s=function(e,t){if(i(e),!n(t)&&null!==t)throw TypeError(t+": can't set as prototype!")};e.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(e,t,n){try{n=r(43)(Function.call,r(235).f(Object.prototype,"__proto__").set,2),n(e,[]),t=!(e instanceof Array)}catch(e){t=!0}return function(e,r){return s(e,r),t?e.__proto__=r:n(e,r),e}}({},!1):void 0),check:s}},function(e,t,r){"use strict";var n=r(15),i=r(5),s=r(23),a=r(22),o=r(13)("species");e.exports=function(e){var t="function"==typeof i[e]?i[e]:n[e];a&&t&&!t[o]&&s.f(t,o,{configurable:!0,get:function(){return this}})}},function(e,t,r){"use strict";var n=r(152),i=r(140);e.exports=function(e){return function(t,r){var s,a,o=String(i(t)),u=n(r),l=o.length;return u<0||u>=l?e?"":void 0:(s=o.charCodeAt(u),s<55296||s>56319||u+1===l||(a=o.charCodeAt(u+1))<56320||a>57343?e?o.charAt(u):s:e?o.slice(u,u+2):a-56320+(s-55296<<10)+65536)}}},function(e,t,r){"use strict";var n=r(152),i=Math.max,s=Math.min;e.exports=function(e,t){return e=n(e),e<0?i(e+t,0):s(e,t)}},function(e,t,r){"use strict";var n=r(21),i=r(238);e.exports=r(5).getIterator=function(e){var t=i(e);if("function"!=typeof t)throw TypeError(e+" is not iterable!");return n(t.call(e))}},function(e,t,r){"use strict";var n=r(418),i=r(233),s=r(56),a=r(37);e.exports=r(143)(Array,"Array",function(e,t){this._t=a(e),this._i=0,this._k=t},function(){var e=this._t,t=this._k,r=this._i++;return!e||r>=e.length?(this._t=void 0,i(1)):"keys"==t?i(0,r):"values"==t?i(0,e[r]):i(0,[r,e[r]])},"values"),s.Arguments=s.Array,n("keys"),n("values"),n("entries")},function(e,t,r){"use strict";var n=r(423),i=r(58);e.exports=r(139)("Map",function(e){return function(){return e(this,arguments.length>0?arguments[0]:void 0)}},{get:function(e){var t=n.getEntry(i(this,"Map"),e);return t&&t.v},set:function(e,t){return n.def(i(this,"Map"),0===e?0:e,t)}},n,!0)},function(e,t,r){"use strict";var n=r(12);n(n.S,"Number",{MAX_SAFE_INTEGER:9007199254740991})},function(e,t,r){"use strict";var n=r(12);n(n.S+n.F,"Object",{assign:r(234)})},function(e,t,r){"use strict";var n=r(12);n(n.S,"Object",{create:r(90)})},function(e,t,r){"use strict";var n=r(94),i=r(44);r(434)("keys",function(){return function(e){return i(n(e))}})},function(e,t,r){"use strict";var n=r(12);n(n.S,"Object",{setPrototypeOf:r(435).set})},function(e,t,r){"use strict";var n,i=r(137)(0),s=r(147),a=r(57),o=r(234),u=r(229),l=r(16),c=r(27),f=r(58),p=a.getWeak,d=Object.isExtensible,h=u.ufstore,m={},y=function(e){return function(){return e(this,arguments.length>0?arguments[0]:void 0)}},v={get:function(e){if(l(e)){var t=p(e);return!0===t?h(f(this,"WeakMap")).get(e):t?t[this._i]:void 0}},set:function(e,t){return u.def(f(this,"WeakMap"),e,t)}},g=e.exports=r(139)("WeakMap",y,v,u,!0,!0);c(function(){return 7!=(new g).set((Object.freeze||Object)(m),7).get(m)})&&(n=u.getConstructor(y,"WeakMap"),o(n.prototype,v),a.NEED=!0,i(["delete","has","get","set"],function(e){var t=g.prototype,r=t[e];s(t,e,function(t,i){if(l(t)&&!d(t)){this._f||(this._f=new n);var s=this._f[e](t,i);return"set"==e?this:s}return r.call(this,t,i)})}))},function(e,t,r){"use strict" +;var n=r(229),i=r(58);r(139)("WeakSet",function(e){return function(){return e(this,arguments.length>0?arguments[0]:void 0)}},{add:function(e){return n.def(i(this,"WeakSet"),e,!0)}},n,!1,!0)},function(e,t,r){"use strict";r(148)("Map")},function(e,t,r){"use strict";r(149)("Map")},function(e,t,r){"use strict";var n=r(12);n(n.P+n.R,"Map",{toJSON:r(424)("Map")})},function(e,t,r){"use strict";r(155)("asyncIterator")},function(e,t,r){"use strict";r(155)("observable")},function(e,t,r){"use strict";r(148)("WeakMap")},function(e,t,r){"use strict";r(149)("WeakMap")},function(e,t,r){"use strict";r(148)("WeakSet")},function(e,t,r){"use strict";r(149)("WeakSet")},function(e,t,r){"use strict";function n(e){var r,n=0;for(r in e)n=(n<<5)-n+e.charCodeAt(r),n|=0;return t.colors[Math.abs(n)%t.colors.length]}function i(e){function r(){if(r.enabled){var e=r,n=+new Date,i=n-(l||n);e.diff=i,e.prev=l,e.curr=n,l=n;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var o=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,function(r,n){if("%%"===r)return r;o++;var i=t.formatters[n];if("function"==typeof i){var a=s[o];r=i.call(e,a),s.splice(o,1),o--}return r}),t.formatArgs.call(e,s);(r.log||t.log||console.log.bind(console)).apply(e,s)}}return r.namespace=e,r.enabled=t.enabled(e),r.useColors=t.useColors(),r.color=n(e),"function"==typeof t.init&&t.init(r),r}function s(e){t.save(e),t.names=[],t.skips=[];for(var r=("string"==typeof e?e:"").split(/[\s,]+/),n=r.length,i=0;i<n;i++)r[i]&&(e=r[i].replace(/\*/g,".*?"),"-"===e[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))}function a(){t.enable("")}function o(e){var r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1}function u(e){return e instanceof Error?e.stack||e.message:e}t=e.exports=i.debug=i.default=i,t.coerce=u,t.disable=a,t.enable=s,t.enabled=o,t.humanize=r(602),t.names=[],t.skips=[],t.formatters={};var l},function(e,t,r){"use strict";function n(e){var t=0,r=0,n=0;for(var i in e){var s=e[i],a=s[0],o=s[1];(a>r||a===r&&o>n)&&(r=a,n=o,t=Number(i))}return t}var i=r(615),s=/^(?:( )+|\t+)/;e.exports=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");var t,r,a=0,o=0,u=0,l={};e.split(/\n/g).forEach(function(e){if(e){var n,i=e.match(s);i?(n=i[0].length,i[1]?o++:a++):n=0;var c=n-u;u=n,c?(r=c>0,t=l[r?c:-c],t?t[0]++:t=l[c]=[1,0]):t&&(t[1]+=Number(r))}});var c,f,p=n(l);return p?o>=a?(c="space",f=i(" ",p)):(c="tab",f=i("\t",p)):(c=null,f=""),{amount:p,type:c,indent:f}}},function(e,t){"use strict";var r=/[|\\{}()[\]^$+*?.]/g;e.exports=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(r,"\\$&")}},function(e,t){"use strict";!function(){function t(e){if(null==e)return!1;switch(e.type){case"ArrayExpression":case"AssignmentExpression":case"BinaryExpression":case"CallExpression":case"ConditionalExpression":case"FunctionExpression":case"Identifier":case"Literal":case"LogicalExpression":case"MemberExpression":case"NewExpression":case"ObjectExpression":case"SequenceExpression":case"ThisExpression":case"UnaryExpression":case"UpdateExpression":return!0}return!1}function r(e){if(null==e)return!1;switch(e.type){case"DoWhileStatement":case"ForInStatement":case"ForStatement":case"WhileStatement":return!0}return!1}function n(e){if(null==e)return!1;switch(e.type){case"BlockStatement":case"BreakStatement":case"ContinueStatement":case"DebuggerStatement":case"DoWhileStatement":case"EmptyStatement":case"ExpressionStatement":case"ForInStatement":case"ForStatement":case"IfStatement":case"LabeledStatement":case"ReturnStatement":case"SwitchStatement":case"ThrowStatement":case"TryStatement":case"VariableDeclaration":case"WhileStatement":case"WithStatement":return!0}return!1}function i(e){return n(e)||null!=e&&"FunctionDeclaration"===e.type}function s(e){switch(e.type){case"IfStatement":return null!=e.alternate?e.alternate:e.consequent;case"LabeledStatement":case"ForStatement":case"ForInStatement":case"WhileStatement":case"WithStatement":return e.body}return null}function a(e){var t;if("IfStatement"!==e.type)return!1;if(null==e.alternate)return!1;t=e.consequent;do{if("IfStatement"===t.type&&null==t.alternate)return!0;t=s(t)}while(t);return!1}e.exports={isExpression:t,isStatement:n,isIterationStatement:r,isSourceElement:i,isProblematicIfStatement:a,trailingStatement:s}}()},function(e,t,r){"use strict";!function(){function t(e){switch(e){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"let":return!0;default:return!1}}function n(e,t){return!(!t&&"yield"===e)&&i(e,t)}function i(e,r){if(r&&t(e))return!0;switch(e.length){case 2:return"if"===e||"in"===e||"do"===e;case 3:return"var"===e||"for"===e||"new"===e||"try"===e;case 4:return"this"===e||"else"===e||"case"===e||"void"===e||"with"===e||"enum"===e;case 5:return"while"===e||"break"===e||"catch"===e||"throw"===e||"const"===e||"yield"===e||"class"===e||"super"===e;case 6:return"return"===e||"typeof"===e||"delete"===e||"switch"===e||"export"===e||"import"===e;case 7:return"default"===e||"finally"===e||"extends"===e;case 8:return"function"===e||"continue"===e||"debugger"===e;case 10:return"instanceof"===e;default:return!1}}function s(e,t){return"null"===e||"true"===e||"false"===e||n(e,t)}function a(e,t){return"null"===e||"true"===e||"false"===e||i(e,t)}function o(e){return"eval"===e||"arguments"===e}function u(e){var t,r,n;if(0===e.length)return!1;if(n=e.charCodeAt(0),!d.isIdentifierStartES5(n))return!1;for(t=1,r=e.length;t<r;++t)if(n=e.charCodeAt(t),!d.isIdentifierPartES5(n))return!1;return!0}function l(e,t){return 1024*(e-55296)+(t-56320)+65536}function c(e){var t,r,n,i,s;if(0===e.length)return!1;for(s=d.isIdentifierStartES6,t=0,r=e.length;t<r;++t){if(55296<=(n=e.charCodeAt(t))&&n<=56319){if(++t>=r)return!1;if(!(56320<=(i=e.charCodeAt(t))&&i<=57343))return!1;n=l(n,i)}if(!s(n))return!1;s=d.isIdentifierPartES6}return!0}function f(e,t){return u(e)&&!s(e,t)}function p(e,t){return c(e)&&!a(e,t)}var d=r(240);e.exports={isKeywordES5:n,isKeywordES6:i,isReservedWordES5:s,isReservedWordES6:a,isRestrictedWord:o,isIdentifierNameES5:u,isIdentifierNameES6:c,isIdentifierES5:f,isIdentifierES6:p}}()},function(e,t,r){"use strict";e.exports=r(630)},function(e,t,r){"use strict";var n=r(180),i=new RegExp(n().source);e.exports=i.test.bind(i)},function(e,t){"use strict";t.read=function(e,t,r,n,i){var s,a,o=8*i-n-1,u=(1<<o)-1,l=u>>1,c=-7,f=r?i-1:0,p=r?-1:1,d=e[t+f];for(f+=p,s=d&(1<<-c)-1,d>>=-c,c+=o;c>0;s=256*s+e[t+f],f+=p,c-=8);for(a=s&(1<<-c)-1,s>>=-c,c+=n;c>0;a=256*a+e[t+f],f+=p,c-=8);if(0===s)s=1-l;else{if(s===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),s-=l}return(d?-1:1)*a*Math.pow(2,s-n)},t.write=function(e,t,r,n,i,s){var a,o,u,l=8*s-i-1,c=(1<<l)-1,f=c>>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,h=n?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,a=c):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),t+=a+f>=1?p/u:p*Math.pow(2,1-f),t*u>=2&&(a++,u/=2),a+f>=c?(o=0,a=c):a+f>=1?(o=(t*u-1)*Math.pow(2,i),a+=f):(o=t*Math.pow(2,f-1)*Math.pow(2,i),a=0));i>=8;e[r+d]=255&o,d+=h,o/=256,i-=8);for(a=a<<i|o,l+=i;l>0;e[r+d]=255&a,d+=h,a/=256,l-=8);e[r+d-h]|=128*m}},function(e,t,r){"use strict";var n=function(e,t,r,n,i,s,a,o){if(!e){var u;if(void 0===t)u=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var l=[r,n,i,s,a,o],c=0;u=new Error(t.replace(/%s/g,function(){return l[c++]})),u.name="Invariant Violation"}throw u.framesToPop=1,u}};e.exports=n},function(e,t,r){"use strict";var n=r(603);e.exports=Number.isFinite||function(e){return!("number"!=typeof e||n(e)||e===1/0||e===-1/0)}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=/((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyu]{1,5}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g,t.matchToToken=function(e){var t={type:"invalid",value:e[0]};return e[1]?(t.type="string",t.closed=!(!e[3]&&!e[4])):e[5]?t.type="comment":e[6]?(t.type="comment",t.closed=!!e[7]):e[8]?t.type="regex":e[9]?t.type="number":e[10]?t.type="name":e[11]?t.type="punctuator":e[12]&&(t.type="whitespace"),t}},function(e,t,r){var n;(function(e,i){"use strict";var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(a){var o="object"==s(t)&&t,u="object"==s(e)&&e&&e.exports==o&&e,l="object"==(void 0===i?"undefined":s(i))&&i;l.global!==l&&l.window!==l||(a=l);var c={},f=c.hasOwnProperty,p=function(e,t){var r;for(r in e)f.call(e,r)&&t(r,e[r])},d=function(e,t){return t?(p(t,function(t,r){e[t]=r}),e):e},h=function(e,t){for(var r=e.length,n=-1;++n<r;)t(e[n])},m=c.toString,y=function(e){return"[object Array]"==m.call(e)},v=function(e){return"[object Object]"==m.call(e)},g=function(e){return"string"==typeof e||"[object String]"==m.call(e)},b=function(e){return"number"==typeof e||"[object Number]"==m.call(e)},E=function(e){return"function"==typeof e||"[object Function]"==m.call(e)},x=function(e){return"[object Map]"==m.call(e)},A=function(e){return"[object Set]"==m.call(e)},S={'"':'\\"',"'":"\\'","\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},_=/["'\\\b\f\n\r\t]/,D=/[0-9]/,C=/[ !#-&\(-\[\]-~]/,w=function e(t,r){var n={escapeEverything:!1,escapeEtago:!1,quotes:"single",wrap:!1,es6:!1,json:!1,compact:!0,lowercaseHex:!1,numbers:"decimal",indent:"\t",__indent__:"",__inline1__:!1,__inline2__:!1},i=r&&r.json;i&&(n.quotes="double",n.wrap=!0),r=d(n,r),"single"!=r.quotes&&"double"!=r.quotes&&(r.quotes="single");var s,a="double"==r.quotes?'"':"'",o=r.compact,u=r.indent,l=r.lowercaseHex,c="",f=r.__inline1__,m=r.__inline2__,w=o?"":"\n",P=!0,k="binary"==r.numbers,F="octal"==r.numbers,T="decimal"==r.numbers,O="hexadecimal"==r.numbers;if(i&&t&&E(t.toJSON)&&(t=t.toJSON()),!g(t)){if(x(t))return 0==t.size?"new Map()":(o||(r.__inline1__=!0),"new Map("+e(Array.from(t),r)+")");if(A(t))return 0==t.size?"new Set()":"new Set("+e(Array.from(t),r)+")";if(y(t))return s=[],r.wrap=!0,f?(r.__inline1__=!1,r.__inline2__=!0):(c=r.__indent__,u+=c,r.__indent__=u),h(t,function(t){P=!1,m&&(r.__inline2__=!1),s.push((o||m?"":u)+e(t,r))}),P?"[]":m?"["+s.join(", ")+"]":"["+w+s.join(","+w)+w+(o?"":c)+"]";if(!b(t))return v(t)?(s=[],r.wrap=!0,c=r.__indent__,u+=c,r.__indent__=u,p(t,function(t,n){P=!1,s.push((o?"":u)+e(t,r)+":"+(o?"":" ")+e(n,r))}),P?"{}":"{"+w+s.join(","+w)+w+(o?"":c)+"}"):i?JSON.stringify(t)||"null":String(t);if(i)return JSON.stringify(t);if(T)return String(t);if(O){var B=t.toString(16);return l||(B=B.toUpperCase()),"0x"+B}if(k)return"0b"+t.toString(2);if(F)return"0o"+t.toString(8)}var R,I,M,N=t,L=-1,j=N.length;for(s="";++L<j;){var U=N.charAt(L);if(r.es6&&(R=N.charCodeAt(L))>=55296&&R<=56319&&j>L+1&&(I=N.charCodeAt(L+1))>=56320&&I<=57343){M=1024*(R-55296)+I-56320+65536;var V=M.toString(16);l||(V=V.toUpperCase()),s+="\\u{"+V+"}",L++}else{if(!r.escapeEverything){if(C.test(U)){s+=U;continue}if('"'==U){s+=a==U?'\\"':U;continue}if("'"==U){s+=a==U?"\\'":U;continue}}if("\0"!=U||i||D.test(N.charAt(L+1)))if(_.test(U))s+=S[U];else{var G=U.charCodeAt(0),V=G.toString(16);l||(V=V.toUpperCase());var W=V.length>2||i,Y="\\"+(W?"u":"x")+("0000"+V).slice(W?-4:-2);s+=Y}else s+="\\0"}}return r.wrap&&(s=a+s+a),r.escapeEtago?s.replace(/<\/(script|style)/gi,"<\\/$1"):s};w.version="1.3.0","object"==s(r(49))&&r(49)?void 0!==(n=function(){return w}.call(t,r,t,e))&&(e.exports=n):o&&!o.nodeType?u?u.exports=w:o.jsesc=w:a.jsesc=w}(void 0)}).call(t,r(39)(e),function(){return this}())},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i="object"===n(t)?t:{};i.parse=function(){var e,t,r,i,s,a,o={"'":"'",'"':'"',"\\":"\\","/":"/","\n":"",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},u=[" ","\t","\r","\n","\v","\f"," ","\ufeff"],l=function(e){return""===e?"EOF":"'"+e+"'"},c=function(n){var i=new SyntaxError;throw i.message=n+" at line "+t+" column "+r+" of the JSON5 data. Still to read: "+JSON.stringify(s.substring(e-1,e+19)),i.at=e,i.lineNumber=t,i.columnNumber=r,i},f=function(n){return n&&n!==i&&c("Expected "+l(n)+" instead of "+l(i)),i=s.charAt(e),e++,r++,("\n"===i||"\r"===i&&"\n"!==p())&&(t++,r=0),i},p=function(){return s.charAt(e)},d=function(){var e=i;for("_"!==i&&"$"!==i&&(i<"a"||i>"z")&&(i<"A"||i>"Z")&&c("Bad identifier as unquoted key");f()&&("_"===i||"$"===i||i>="a"&&i<="z"||i>="A"&&i<="Z"||i>="0"&&i<="9");)e+=i;return e},h=function(){var e,t="",r="",n=10;if("-"!==i&&"+"!==i||(t=i,f(i)),"I"===i)return e=E(),("number"!=typeof e||isNaN(e))&&c("Unexpected word for number"),"-"===t?-e:e;if("N"===i)return e=E(),isNaN(e)||c("expected word to be NaN"),e;switch("0"===i&&(r+=i,f(),"x"===i||"X"===i?(r+=i,f(),n=16):i>="0"&&i<="9"&&c("Octal literal")),n){case 10:for(;i>="0"&&i<="9";)r+=i,f();if("."===i)for(r+=".";f()&&i>="0"&&i<="9";)r+=i;if("e"===i||"E"===i)for(r+=i,f(),"-"!==i&&"+"!==i||(r+=i,f());i>="0"&&i<="9";)r+=i,f();break;case 16:for(;i>="0"&&i<="9"||i>="A"&&i<="F"||i>="a"&&i<="f";)r+=i,f()}if(e="-"===t?-r:+r,isFinite(e))return e;c("Bad number")},m=function(){var e,t,r,n,s="";if('"'===i||"'"===i)for(r=i;f();){if(i===r)return f(),s;if("\\"===i)if(f(),"u"===i){for(n=0,t=0;t<4&&(e=parseInt(f(),16),isFinite(e));t+=1)n=16*n+e;s+=String.fromCharCode(n)}else if("\r"===i)"\n"===p()&&f();else{if("string"!=typeof o[i])break;s+=o[i]}else{if("\n"===i)break;s+=i}}c("Bad string")},y=function(){"/"!==i&&c("Not an inline comment");do{if(f(),"\n"===i||"\r"===i)return void f()}while(i)},v=function(){"*"!==i&&c("Not a block comment");do{for(f();"*"===i;)if(f("*"),"/"===i)return void f("/")}while(i);c("Unterminated block comment")},g=function(){"/"!==i&&c("Not a comment"),f("/"),"/"===i?y():"*"===i?v():c("Unrecognized comment")},b=function(){for(;i;)if("/"===i)g();else{if(!(u.indexOf(i)>=0))return;f()}},E=function(){switch(i){case"t":return f("t"),f("r"),f("u"),f("e"),!0;case"f":return f("f"),f("a"),f("l"),f("s"),f("e"),!1;case"n":return f("n"),f("u"),f("l"),f("l"),null;case"I":return f("I"),f("n"),f("f"),f("i"),f("n"),f("i"),f("t"),f("y"),1/0;case"N":return f("N"),f("a"),f("N"),NaN}c("Unexpected "+l(i))},x=function(){var e=[];if("["===i)for(f("["),b();i;){if("]"===i)return f("]"),e;if(","===i?c("Missing array element"):e.push(a()),b(),","!==i)return f("]"),e;f(","),b()}c("Bad array")},A=function(){var e,t={};if("{"===i)for(f("{"),b();i;){if("}"===i)return f("}"),t;if(e='"'===i||"'"===i?m():d(),b(),f(":"),t[e]=a(),b(),","!==i)return f("}"),t;f(","),b()}c("Bad object")};return a=function(){switch(b(),i){case"{":return A();case"[":return x();case'"':case"'":return m();case"-":case"+":case".":return h();default:return i>="0"&&i<="9"?h():E()}},function(o,u){var l;return s=String(o),e=0,t=1,r=1,i=" ",l=a(),b(),i&&c("Syntax error"),"function"==typeof u?function e(t,r){var i,s,a=t[r];if(a&&"object"===(void 0===a?"undefined":n(a)))for(i in a)Object.prototype.hasOwnProperty.call(a,i)&&(s=e(a,i),void 0!==s?a[i]=s:delete a[i]);return u.call(t,r,a)}({"":l},""):l}}(),i.stringify=function(e,t,r){function s(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||"_"===e||"$"===e}function a(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||"_"===e||"$"===e}function o(e){if("string"!=typeof e)return!1;if(!a(e[0]))return!1;for(var t=1,r=e.length;t<r;){if(!s(e[t]))return!1;t++}return!0}function u(e){return Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e)}function l(e){return"[object Date]"===Object.prototype.toString.call(e)}function c(e){for(var t=0;t<y.length;t++)if(y[t]===e)throw new TypeError("Converting circular structure to JSON")}function f(e,t,r){if(!e)return"";e.length>10&&(e=e.substring(0,10));for(var n=r?"":"\n",i=0;i<t;i++)n+=e;return n}function p(e){return v.lastIndex=0,v.test(e)?'"'+e.replace(v,function(e){var t=g[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function d(e,t,r){var i,s,a=h(e,t,r);switch(a&&!l(a)&&(a=a.valueOf()),void 0===a?"undefined":n(a)){case"boolean":return a.toString();case"number":return isNaN(a)||!isFinite(a)?"null":a.toString();case"string":return p(a.toString());case"object":if(null===a)return"null";if(u(a)){c(a),i="[",y.push(a);for(var v=0;v<a.length;v++)s=d(a,v,!1),i+=f(m,y.length),i+=null===s||void 0===s?"null":s,v<a.length-1?i+=",":m&&(i+="\n");y.pop(),a.length&&(i+=f(m,y.length,!0)),i+="]"}else{c(a),i="{";var g=!1;y.push(a);for(var b in a)if(a.hasOwnProperty(b)){var E=d(a,b,!1);r=!1,void 0!==E&&null!==E&&(i+=f(m,y.length),g=!0,t=o(b)?b:p(b),i+=t+":"+(m?" ":"")+E+",")}y.pop(),i=g?i.substring(0,i.length-1)+f(m,y.length)+"}":"{}"}return i;default:return}}if(t&&"function"!=typeof t&&!u(t))throw new Error("Replacer must be a function or an array");var h=function(e,r,n){var i=e[r];return i&&i.toJSON&&"function"==typeof i.toJSON&&(i=i.toJSON()),"function"==typeof t?t.call(e,r,i):t?n||u(e)||t.indexOf(r)>=0?i:void 0:i};i.isWord=o;var m,y=[];r&&("string"==typeof r?m=r:"number"==typeof r&&r>=0&&(m=f(" ",r,!0)));var v=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,g={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},b={"":e};return void 0===e?h(b,"",!0):d(b,"",!0)}},function(e,t){"use strict";var r=[],n=[];e.exports=function(e,t){if(e===t)return 0;var i=e.length,s=t.length;if(0===i)return s;if(0===s)return i;for(var a,o,u,l,c=0,f=0;c<i;)n[c]=e.charCodeAt(c),r[c]=++c;for(;f<s;)for(a=t.charCodeAt(f),u=f++,o=f,c=0;c<i;c++)l=a===n[c]?u:u+1,u=r[c],o=r[c]=u>o?l>o?o+1:l:l>u?u+1:l;return o}},function(e,t,r){"use strict";var n=r(38),i=r(17),s=n(i,"DataView");e.exports=s},function(e,t,r){"use strict";function n(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}var i=r(536),s=r(537),a=r(538),o=r(539),u=r(540);n.prototype.clear=i,n.prototype.delete=s,n.prototype.get=a,n.prototype.has=o,n.prototype.set=u,e.exports=n},function(e,t,r){"use strict";var n=r(38),i=r(17),s=n(i,"Promise");e.exports=s},function(e,t,r){"use strict";var n=r(38),i=r(17),s=n(i,"WeakMap");e.exports=s},function(e,t){"use strict";function r(e,t){return e.set(t[0],t[1]),e}e.exports=r},function(e,t){"use strict";function r(e,t){return e.add(t),e}e.exports=r},function(e,t){"use strict";function r(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););return e}e.exports=r},function(e,t){"use strict";function r(e,t){for(var r=-1,n=null==e?0:e.length,i=0,s=[];++r<n;){var a=e[r];t(a,r,e)&&(s[i++]=a)}return s}e.exports=r},function(e,t,r){"use strict";function n(e,t){return!!(null==e?0:e.length)&&i(e,t,0)>-1}var i=r(166);e.exports=n},function(e,t){"use strict";function r(e,t,r){for(var n=-1,i=null==e?0:e.length;++n<i;)if(r(t,e[n]))return!0;return!1}e.exports=r},function(e,t){"use strict";function r(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}e.exports=r},function(e,t,r){"use strict";function n(e,t){return e&&i(t,s(t),e)}var i=r(31),s=r(32);e.exports=n},function(e,t,r){"use strict";function n(e,t){return e&&i(t,s(t),e)}var i=r(31),s=r(47);e.exports=n},function(e,t){"use strict";function r(e,t,r){return e===e&&(void 0!==r&&(e=e<=r?e:r),void 0!==t&&(e=e>=t?e:t)),e}e.exports=r},function(e,t,r){"use strict";var n=r(18),i=Object.create,s=function(){function e(){}return function(t){if(!n(t))return{};if(i)return i(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}();e.exports=s},function(e,t,r){"use strict";var n=r(489),i=r(526),s=i(n);e.exports=s},function(e,t,r){"use strict";function n(e,t,r,a,o){var u=-1,l=e.length;for(r||(r=s),o||(o=[]);++u<l;){var c=e[u];t>0&&r(c)?t>1?n(c,t-1,r,a,o):i(o,c):a||(o[o.length]=c)}return o}var i=r(161),s=r(543);e.exports=n},function(e,t,r){"use strict";function n(e,t){return e&&i(e,t,s)}var i=r(248),s=r(32);e.exports=n},function(e,t){"use strict";function r(e,t){return null!=e&&i.call(e,t)}var n=Object.prototype,i=n.hasOwnProperty;e.exports=r},function(e,t){"use strict";function r(e,t){return null!=e&&t in Object(e)}e.exports=r},function(e,t){"use strict";function r(e,t,r,n){for(var i=r-1,s=e.length;++i<s;)if(n(e[i],t))return i;return-1}e.exports=r},function(e,t,r){"use strict";function n(e){return s(e)&&i(e)==a}var i=r(30),s=r(25),a="[object Arguments]";e.exports=n},function(e,t,r){"use strict";function n(e,t,r,n,y,g){var b=l(e),E=l(t),x=b?h:u(e),A=E?h:u(t);x=x==d?m:x,A=A==d?m:A;var S=x==m,_=A==m,D=x==A;if(D&&c(e)){if(!c(t))return!1;b=!0,S=!1}if(D&&!S)return g||(g=new i),b||f(e)?s(e,t,r,n,y,g):a(e,t,x,r,n,y,g);if(!(r&p)){var C=S&&v.call(e,"__wrapped__"),w=_&&v.call(t,"__wrapped__");if(C||w){var P=C?e.value():e,k=w?t.value():t;return g||(g=new i),y(P,k,r,n,g)}}return!!D&&(g||(g=new i),o(e,t,r,n,y,g))}var i=r(99),s=r(260),a=r(530),o=r(531),u=r(264),l=r(6),c=r(113),f=r(177),p=1,d="[object Arguments]",h="[object Array]",m="[object Object]",y=Object.prototype,v=y.hasOwnProperty;e.exports=n},function(e,t,r){"use strict";function n(e,t,r,n){var u=r.length,l=u,c=!n;if(null==e)return!l;for(e=Object(e);u--;){var f=r[u];if(c&&f[2]?f[1]!==e[f[0]]:!(f[0]in e))return!1}for(;++u<l;){f=r[u];var p=f[0],d=e[p],h=f[1];if(c&&f[2]){if(void 0===d&&!(p in e))return!1}else{var m=new i;if(n)var y=n(d,h,p,e,t,m);if(!(void 0===y?s(h,d,a|o,n,m):y))return!1}}return!0}var i=r(99),s=r(251),a=1,o=2;e.exports=n},function(e,t){"use strict";function r(e){return e!==e}e.exports=r},function(e,t,r){"use strict";function n(e){return!(!a(e)||s(e))&&(i(e)?h:l).test(o(e))}var i=r(175),s=r(545),a=r(18),o=r(272),u=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,c=Function.prototype,f=Object.prototype,p=c.toString,d=f.hasOwnProperty,h=RegExp("^"+p.call(d).replace(u,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=n},function(e,t,r){"use strict";function n(e){return s(e)&&i(e)==a}var i=r(30),s=r(25),a="[object RegExp]";e.exports=n},function(e,t,r){"use strict";function n(e){return a(e)&&s(e.length)&&!!o[i(e)]}var i=r(30),s=r(176),a=r(25),o={};o["[object Float32Array]"]=o["[object Float64Array]"]=o["[object Int8Array]"]=o["[object Int16Array]"]=o["[object Int32Array]"]=o["[object Uint8Array]"]=o["[object Uint8ClampedArray]"]=o["[object Uint16Array]"]=o["[object Uint32Array]"]=!0,o["[object Arguments]"]=o["[object Array]"]=o["[object ArrayBuffer]"]=o["[object Boolean]"]=o["[object DataView]"]=o["[object Date]"]=o["[object Error]"]=o["[object Function]"]=o["[object Map]"]=o["[object Number]"]=o["[object Object]"]=o["[object RegExp]"]=o["[object Set]"]=o["[object String]"]=o["[object WeakMap]"]=!1,e.exports=n},function(e,t,r){"use strict";function n(e){if(!i(e))return s(e);var t=[];for(var r in Object(e))o.call(e,r)&&"constructor"!=r&&t.push(r);return t}var i=r(105),s=r(557),a=Object.prototype,o=a.hasOwnProperty;e.exports=n},function(e,t,r){"use strict";function n(e){if(!i(e))return a(e);var t=s(e),r=[];for(var n in e)("constructor"!=n||!t&&u.call(e,n))&&r.push(n);return r}var i=r(18),s=r(105),a=r(558),o=Object.prototype,u=o.hasOwnProperty;e.exports=n},function(e,t,r){"use strict";function n(e){var t=s(e);return 1==t.length&&t[0][2]?a(t[0][0],t[0][1]):function(r){return r===e||i(r,e,t)}}var i=r(495),s=r(533),a=r(269);e.exports=n},function(e,t,r){"use strict";function n(e,t){return o(e)&&u(t)?l(c(e),t):function(r){var n=s(r,e);return void 0===n&&n===t?a(r,e):i(t,n,f|p)}}var i=r(251),s=r(583),a=r(584),o=r(173),u=r(267),l=r(269),c=r(108),f=1,p=2;e.exports=n},function(e,t,r){"use strict";function n(e,t,r,c,f){e!==t&&a(t,function(a,l){if(u(a))f||(f=new i),o(e,t,l,r,n,c,f);else{var p=c?c(e[l],a,l+"",e,t,f):void 0;void 0===p&&(p=a),s(e,l,p)}},l)}var i=r(99),s=r(247),a=r(248),o=r(505),u=r(18),l=r(47);e.exports=n},function(e,t,r){"use strict";function n(e,t,r,n,g,b,E){var x=e[r],A=t[r],S=E.get(A);if(S)return void i(e,r,S);var _=b?b(x,A,r+"",e,t,E):void 0,D=void 0===_;if(D){var C=c(A),w=!C&&p(A),P=!C&&!w&&y(A);_=A,C||w||P?c(x)?_=x:f(x)?_=o(x):w?(D=!1,_=s(A,!0)):P?(D=!1,_=a(A,!0)):_=[]:m(A)||l(A)?(_=x,l(x)?_=v(x):(!h(x)||n&&d(x))&&(_=u(A))):D=!1}D&&(E.set(A,_),g(_,A,n,b,E),E.delete(A)),i(e,r,_)}var i=r(247),s=r(256),a=r(257),o=r(168),u=r(266),l=r(112),c=r(6),f=r(585),p=r(113),d=r(175),h=r(18),m=r(275),y=r(177),v=r(599);e.exports=n},function(e,t,r){"use strict";function n(e,t,r){var n=-1;t=i(t.length?t:[c],u(s));var f=a(e,function(e,r,s){return{criteria:i(t,function(t){return t(e)}),index:++n,value:e}});return o(f,function(e,t){return l(e,t,r)})}var i=r(60),s=r(61),a=r(252),o=r(512),u=r(102),l=r(522),c=r(110);e.exports=n},function(e,t){"use strict";function r(e){return function(t){return null==t?void 0:t[e]}}e.exports=r},function(e,t,r){"use strict";function n(e){return function(t){return i(t,e)}}var i=r(249);e.exports=n},function(e,t,r){"use strict";function n(e,t,r,n){var l=n?a:s,f=-1,p=t.length,d=e;for(e===t&&(t=u(t)),r&&(d=i(e,o(r)));++f<p;)for(var h=0,m=t[f],y=r?r(m):m;(h=l(d,y,h,n))>-1;)d!==e&&c.call(d,h,1),c.call(e,h,1);return e}var i=r(60),s=r(166),a=r(492),o=r(102),u=r(168),l=Array.prototype,c=l.splice;e.exports=n},function(e,t){"use strict";function r(e,t){var r="";if(!e||t<1||t>n)return r;do{t%2&&(r+=e),(t=i(t/2))&&(e+=e)}while(t);return r}var n=9007199254740991,i=Math.floor;e.exports=r},function(e,t,r){"use strict";var n=r(576),i=r(259),s=r(110),a=i?function(e,t){return i(e,"toString",{configurable:!0,enumerable:!1,value:n(t),writable:!0})}:s;e.exports=a},function(e,t){"use strict";function r(e,t){var r=e.length;for(e.sort(t);r--;)e[r]=e[r].value;return e}e.exports=r},function(e,t){"use strict";function r(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}e.exports=r},function(e,t,r){"use strict";function n(e,t,r){var n=-1,f=s,p=e.length,d=!0,h=[],m=h;if(r)d=!1,f=a;else if(p>=c){var y=t?null:u(e);if(y)return l(y);d=!1,f=o,m=new i}else m=t?[]:h;e:for(;++n<p;){var v=e[n],g=t?t(v):v;if(v=r||0!==v?v:0,d&&g===g){for(var b=m.length;b--;)if(m[b]===g)continue e;t&&m.push(g),h.push(v)}else f(m,g,r)||(m!==h&&m.push(g),h.push(v))}return h}var i=r(242),s=r(480),a=r(481),o=r(254),u=r(528),l=r(107),c=200;e.exports=n},function(e,t,r){"use strict";function n(e,t){return i(t,function(t){return e[t]})}var i=r(60);e.exports=n},function(e,t,r){"use strict";function n(e,t){var r=t?i(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}var i=r(167);e.exports=n},function(e,t,r){"use strict";function n(e,t,r){var n=t?r(a(e),o):a(e);return s(n,i,new e.constructor)}var i=r(476),s=r(246),a=r(268),o=1;e.exports=n},function(e,t){"use strict";function r(e){var t=new e.constructor(e.source,n.exec(e));return t.lastIndex=e.lastIndex,t}var n=/\w*$/;e.exports=r},function(e,t,r){"use strict";function n(e,t,r){var n=t?r(a(e),o):a(e);return s(n,i,new e.constructor)}var i=r(477),s=r(246),a=r(107),o=1;e.exports=n},function(e,t,r){"use strict";function n(e){return a?Object(a.call(e)):{}}var i=r(45),s=i?i.prototype:void 0,a=s?s.valueOf:void 0;e.exports=n},function(e,t,r){"use strict";function n(e,t){if(e!==t){var r=void 0!==e,n=null===e,s=e===e,a=i(e),o=void 0!==t,u=null===t,l=t===t,c=i(t);if(!u&&!c&&!a&&e>t||a&&o&&l&&!u&&!c||n&&o&&l||!r&&l||!s)return 1;if(!n&&!a&&!c&&e<t||c&&r&&s&&!n&&!a||u&&r&&s||!o&&s||!l)return-1}return 0}var i=r(62);e.exports=n},function(e,t,r){"use strict";function n(e,t,r){for(var n=-1,s=e.criteria,a=t.criteria,o=s.length,u=r.length;++n<o;){var l=i(s[n],a[n]);if(l){if(n>=u)return l;return l*("desc"==r[n]?-1:1)}}return e.index-t.index}var i=r(521);e.exports=n},function(e,t,r){"use strict";function n(e,t){return i(e,s(e),t)}var i=r(31),s=r(170);e.exports=n},function(e,t,r){"use strict";function n(e,t){return i(e,s(e),t)}var i=r(31),s=r(263);e.exports=n},function(e,t,r){"use strict";var n=r(17),i=n["__core-js_shared__"];e.exports=i},function(e,t,r){"use strict";function n(e,t){return function(r,n){if(null==r)return r;if(!i(r))return e(r,n);for(var s=r.length,a=t?s:-1,o=Object(r);(t?a--:++a<s)&&!1!==n(o[a],a,o););return r}}var i=r(24);e.exports=n},function(e,t){"use strict";function r(e){return function(t,r,n){for(var i=-1,s=Object(t),a=n(t),o=a.length;o--;){var u=a[e?o:++i];if(!1===r(s[u],u,s))break}return t}}e.exports=r},function(e,t,r){"use strict";var n=r(241),i=r(591),s=r(107),a=n&&1/s(new n([,-0]))[1]==1/0?function(e){return new n(e)}:i;e.exports=a},function(e,t,r){"use strict";function n(e,t,r,n){return void 0===e||i(e,s[r])&&!a.call(n,r)?t:e}var i=r(46),s=Object.prototype,a=s.hasOwnProperty;e.exports=n},function(e,t,r){"use strict";function n(e,t,r,n,i,S,D){switch(r){case A:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case x:return!(e.byteLength!=t.byteLength||!S(new s(e),new s(t)));case p:case d:case y:return a(+e,+t);case h:return e.name==t.name&&e.message==t.message;case v:case b:return e==t+"";case m:var C=u;case g:var w=n&c;if(C||(C=l),e.size!=t.size&&!w)return!1;var P=D.get(e);if(P)return P==t;n|=f,D.set(e,t);var k=o(C(e),C(t),n,i,S,D);return D.delete(e),k;case E:if(_)return _.call(e)==_.call(t)}return!1}var i=r(45),s=r(243),a=r(46),o=r(260),u=r(268),l=r(107),c=1,f=2,p="[object Boolean]",d="[object Date]",h="[object Error]",m="[object Map]",y="[object Number]",v="[object RegExp]",g="[object Set]",b="[object String]",E="[object Symbol]",x="[object ArrayBuffer]",A="[object DataView]",S=i?i.prototype:void 0,_=S?S.valueOf:void 0;e.exports=n},function(e,t,r){"use strict";function n(e,t,r,n,a,u){var l=r&s,c=i(e),f=c.length;if(f!=i(t).length&&!l)return!1;for(var p=f;p--;){var d=c[p];if(!(l?d in t:o.call(t,d)))return!1}var h=u.get(e);if(h&&u.get(t))return h==t;var m=!0;u.set(e,t),u.set(t,e);for(var y=l;++p<f;){d=c[p];var v=e[d],g=t[d];if(n)var b=l?n(g,v,d,t,e,u):n(v,g,d,e,t,u);if(!(void 0===b?v===g||a(v,g,r,n,u):b)){m=!1;break}y||(y="constructor"==d)}if(m&&!y){var E=e.constructor,x=t.constructor;E!=x&&"constructor"in e&&"constructor"in t&&!("function"==typeof E&&E instanceof E&&"function"==typeof x&&x instanceof x)&&(m=!1)}return u.delete(e),u.delete(t),m}var i=r(262),s=1,a=Object.prototype,o=a.hasOwnProperty;e.exports=n},function(e,t,r){"use strict";function n(e){return i(e,a,s)}var i=r(250),s=r(263),a=r(47);e.exports=n},function(e,t,r){"use strict";function n(e){for(var t=s(e),r=t.length;r--;){var n=t[r],a=e[n];t[r]=[n,a,i(a)]}return t}var i=r(267),s=r(32);e.exports=n},function(e,t,r){"use strict";function n(e){var t=a.call(e,u),r=e[u];try{e[u]=void 0;var n=!0}catch(e){}var i=o.call(e);return n&&(t?e[u]=r:delete e[u]),i}var i=r(45),s=Object.prototype,a=s.hasOwnProperty,o=s.toString,u=i?i.toStringTag:void 0;e.exports=n},function(e,t){"use strict";function r(e,t){return null==e?void 0:e[t]}e.exports=r},function(e,t,r){"use strict";function n(){this.__data__=i?i(null):{},this.size=0}var i=r(106);e.exports=n},function(e,t){"use strict";function r(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}e.exports=r},function(e,t,r){"use strict";function n(e){var t=this.__data__;if(i){var r=t[e];return r===s?void 0:r}return o.call(t,e)?t[e]:void 0}var i=r(106),s="__lodash_hash_undefined__",a=Object.prototype,o=a.hasOwnProperty;e.exports=n},function(e,t,r){"use strict" +;function n(e){var t=this.__data__;return i?void 0!==t[e]:a.call(t,e)}var i=r(106),s=Object.prototype,a=s.hasOwnProperty;e.exports=n},function(e,t,r){"use strict";function n(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=i&&void 0===t?s:t,this}var i=r(106),s="__lodash_hash_undefined__";e.exports=n},function(e,t){"use strict";function r(e){var t=e.length,r=e.constructor(t);return t&&"string"==typeof e[0]&&i.call(e,"index")&&(r.index=e.index,r.input=e.input),r}var n=Object.prototype,i=n.hasOwnProperty;e.exports=r},function(e,t,r){"use strict";function n(e,t,r,n){var F=e.constructor;switch(t){case b:return i(e);case f:case p:return new F(+e);case E:return s(e,n);case x:case A:case S:case _:case D:case C:case w:case P:case k:return c(e,n);case d:return a(e,n,r);case h:case v:return new F(e);case m:return o(e);case y:return u(e,n,r);case g:return l(e)}}var i=r(167),s=r(516),a=r(517),o=r(518),u=r(519),l=r(520),c=r(257),f="[object Boolean]",p="[object Date]",d="[object Map]",h="[object Number]",m="[object RegExp]",y="[object Set]",v="[object String]",g="[object Symbol]",b="[object ArrayBuffer]",E="[object DataView]",x="[object Float32Array]",A="[object Float64Array]",S="[object Int8Array]",_="[object Int16Array]",D="[object Int32Array]",C="[object Uint8Array]",w="[object Uint8ClampedArray]",P="[object Uint16Array]",k="[object Uint32Array]";e.exports=n},function(e,t,r){"use strict";function n(e){return a(e)||s(e)||!!(o&&e&&e[o])}var i=r(45),s=r(112),a=r(6),o=i?i.isConcatSpreadable:void 0;e.exports=n},function(e,t){"use strict";function r(e){var t=void 0===e?"undefined":n(e);return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.exports=r},function(e,t,r){"use strict";function n(e){return!!s&&s in e}var i=r(525),s=function(){var e=/[^.]+$/.exec(i&&i.keys&&i.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();e.exports=n},function(e,t){"use strict";function r(){this.__data__=[],this.size=0}e.exports=r},function(e,t,r){"use strict";function n(e){var t=this.__data__,r=i(t,e);return!(r<0)&&(r==t.length-1?t.pop():a.call(t,r,1),--this.size,!0)}var i=r(100),s=Array.prototype,a=s.splice;e.exports=n},function(e,t,r){"use strict";function n(e){var t=this.__data__,r=i(t,e);return r<0?void 0:t[r][1]}var i=r(100);e.exports=n},function(e,t,r){"use strict";function n(e){return i(this.__data__,e)>-1}var i=r(100);e.exports=n},function(e,t,r){"use strict";function n(e,t){var r=this.__data__,n=i(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var i=r(100);e.exports=n},function(e,t,r){"use strict";function n(){this.size=0,this.__data__={hash:new i,map:new(a||s),string:new i}}var i=r(473),s=r(98),a=r(159);e.exports=n},function(e,t,r){"use strict";function n(e){var t=i(this,e).delete(e);return this.size-=t?1:0,t}var i=r(104);e.exports=n},function(e,t,r){"use strict";function n(e){return i(this,e).get(e)}var i=r(104);e.exports=n},function(e,t,r){"use strict";function n(e){return i(this,e).has(e)}var i=r(104);e.exports=n},function(e,t,r){"use strict";function n(e,t){var r=i(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var i=r(104);e.exports=n},function(e,t,r){"use strict";function n(e){var t=i(e,function(e){return r.size===s&&r.clear(),e}),r=t.cache;return t}var i=r(589),s=500;e.exports=n},function(e,t,r){"use strict";var n=r(271),i=n(Object.keys,Object);e.exports=i},function(e,t){"use strict";function r(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}e.exports=r},function(e,t){"use strict";function r(e){return i.call(e)}var n=Object.prototype,i=n.toString;e.exports=r},function(e,t,r){"use strict";function n(e,t,r){return t=s(void 0===t?e.length-1:t,0),function(){for(var n=arguments,a=-1,o=s(n.length-t,0),u=Array(o);++a<o;)u[a]=n[t+a];a=-1;for(var l=Array(t+1);++a<t;)l[a]=n[a];return l[t]=r(u),i(e,this,l)}}var i=r(244),s=Math.max;e.exports=n},function(e,t){"use strict";function r(e){return this.__data__.set(e,n),this}var n="__lodash_hash_undefined__";e.exports=r},function(e,t){"use strict";function r(e){return this.__data__.has(e)}e.exports=r},function(e,t,r){"use strict";var n=r(511),i=r(564),s=i(n);e.exports=s},function(e,t){"use strict";function r(e){var t=0,r=0;return function(){var a=s(),o=i-(a-r);if(r=a,o>0){if(++t>=n)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var n=800,i=16,s=Date.now;e.exports=r},function(e,t,r){"use strict";function n(){this.__data__=new i,this.size=0}var i=r(98);e.exports=n},function(e,t){"use strict";function r(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}e.exports=r},function(e,t){"use strict";function r(e){return this.__data__.get(e)}e.exports=r},function(e,t){"use strict";function r(e){return this.__data__.has(e)}e.exports=r},function(e,t,r){"use strict";function n(e,t){var r=this.__data__;if(r instanceof i){var n=r.__data__;if(!s||n.length<o-1)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new a(n)}return r.set(e,t),this.size=r.size,this}var i=r(98),s=r(159),a=r(160),o=200;e.exports=n},function(e,t){"use strict";function r(e,t,r){for(var n=r-1,i=e.length;++n<i;)if(e[n]===t)return n;return-1}e.exports=r},function(e,t,r){"use strict";var n=r(556),i=/^\./,s=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,a=/\\(\\)?/g,o=n(function(e){var t=[];return i.test(e)&&t.push(""),e.replace(s,function(e,r,n,i){t.push(n?i.replace(a,"$1"):r||e)}),t});e.exports=o},function(e,t,r){"use strict";var n=r(31),i=r(103),s=r(47),a=i(function(e,t){n(t,s(t),e)});e.exports=a},function(e,t,r){"use strict";var n=r(31),i=r(103),s=r(47),a=i(function(e,t,r,i){n(t,s(t),e,i)});e.exports=a},function(e,t,r){"use strict";function n(e){return i(e,s|a)}var i=r(164),s=1,a=4;e.exports=n},function(e,t,r){"use strict";function n(e,t){return t="function"==typeof t?t:void 0,i(e,s|a,t)}var i=r(164),s=1,a=4;e.exports=n},function(e,t){"use strict";function r(e){return function(){return e}}e.exports=r},function(e,t,r){"use strict";function n(e){return e=i(e),e&&a.test(e)?e.replace(s,"\\$&"):e}var i=r(114),s=/[\\^$.*+?()[\]{}|]/g,a=RegExp(s.source);e.exports=n},function(e,t,r){"use strict";e.exports=r(572)},function(e,t,r){"use strict";var n=r(258),i=r(580),s=n(i);e.exports=s},function(e,t,r){"use strict";function n(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var u=null==r?0:a(r);return u<0&&(u=o(n+u,0)),i(e,s(t,3),u)}var i=r(165),s=r(61),a=r(48),o=Math.max;e.exports=n},function(e,t,r){"use strict";var n=r(258),i=r(582),s=n(i);e.exports=s},function(e,t,r){"use strict";function n(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var l=n-1;return void 0!==r&&(l=a(r),l=r<0?o(n+l,0):u(l,n-1)),i(e,s(t,3),l,!0)}var i=r(165),s=r(61),a=r(48),o=Math.max,u=Math.min;e.exports=n},function(e,t,r){"use strict";function n(e,t,r){var n=null==e?void 0:i(e,t);return void 0===n?r:n}var i=r(249);e.exports=n},function(e,t,r){"use strict";function n(e,t){return null!=e&&s(e,t,i)}var i=r(491),s=r(265);e.exports=n},function(e,t,r){"use strict";function n(e){return s(e)&&i(e)}var i=r(24),s=r(25);e.exports=n},function(e,t,r){"use strict";function n(e){return"number"==typeof e&&e==i(e)}var i=r(48);e.exports=n},function(e,t,r){"use strict";function n(e){return"string"==typeof e||!s(e)&&a(e)&&i(e)==o}var i=r(30),s=r(6),a=r(25),o="[object String]";e.exports=n},function(e,t,r){"use strict";function n(e,t){return(o(e)?i:a)(e,s(t,3))}var i=r(60),s=r(61),a=r(252),o=r(6);e.exports=n},function(e,t,r){"use strict";function n(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError(s);var r=function r(){var n=arguments,i=t?t.apply(this,n):n[0],s=r.cache;if(s.has(i))return s.get(i);var a=e.apply(this,n);return r.cache=s.set(i,a)||s,a};return r.cache=new(n.Cache||i),r}var i=r(160),s="Expected a function";n.Cache=i,e.exports=n},function(e,t,r){"use strict";var n=r(504),i=r(103),s=i(function(e,t,r,i){n(e,t,r,i)});e.exports=s},function(e,t){"use strict";function r(){}e.exports=r},function(e,t,r){"use strict";function n(e){return a(e)?i(o(e)):s(e)}var i=r(507),s=r(508),a=r(173),o=r(108);e.exports=n},function(e,t,r){"use strict";function n(e,t){return e&&e.length&&t&&t.length?i(e,t):e}var i=r(509);e.exports=n},function(e,t,r){"use strict";var n=r(488),i=r(506),s=r(101),a=r(172),o=s(function(e,t){if(null==e)return[];var r=t.length;return r>1&&a(e,t[0],t[1])?t=[]:r>2&&a(t[0],t[1],t[2])&&(t=[t[0]]),i(e,n(t,1),[])});e.exports=o},function(e,t,r){"use strict";function n(e,t,r){return e=o(e),r=null==r?0:i(a(r),0,e.length),t=s(t),e.slice(r,r+t.length)==t}var i=r(485),s=r(253),a=r(48),o=r(114);e.exports=n},function(e,t){"use strict";function r(){return!1}e.exports=r},function(e,t,r){"use strict";function n(e){if(!e)return 0===e?e:0;if((e=i(e))===s||e===-s){return(e<0?-1:1)*a}return e===e?e:0}var i=r(598),s=1/0,a=1.7976931348623157e308;e.exports=n},function(e,t,r){"use strict";function n(e){if("number"==typeof e)return e;if(s(e))return a;if(i(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=i(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(o,"");var r=l.test(e);return r||c.test(e)?f(e.slice(2),r?2:8):u.test(e)?a:+e}var i=r(18),s=r(62),a=NaN,o=/^\s+|\s+$/g,u=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,c=/^0o[0-7]+$/i,f=parseInt;e.exports=n},function(e,t,r){"use strict";function n(e){return i(e,s(e))}var i=r(31),s=r(47);e.exports=n},function(e,t,r){"use strict";function n(e){return e&&e.length?i(e):[]}var i=r(514);e.exports=n},function(e,t,r){"use strict";function n(e,t){return t=t||{},function(r,n,i){return s(r,e,t)}}function i(e,t){e=e||{},t=t||{};var r={};return Object.keys(t).forEach(function(e){r[e]=t[e]}),Object.keys(e).forEach(function(t){r[t]=e[t]}),r}function s(e,t,r){if("string"!=typeof t)throw new TypeError("glob pattern string required");return r||(r={}),!(!r.nocomment&&"#"===t.charAt(0))&&(""===t.trim()?""===e:new a(t,r).match(e))}function a(e,t){if(!(this instanceof a))return new a(e,t);if("string"!=typeof e)throw new TypeError("glob pattern string required");t||(t={}),e=e.trim(),"/"!==m.sep&&(e=e.split(m.sep).join("/")),this.options=t,this.set=[],this.pattern=e,this.regexp=null,this.negate=!1,this.comment=!1,this.empty=!1,this.make()}function o(){if(!this._made){var e=this.pattern,t=this.options;if(!t.nocomment&&"#"===e.charAt(0))return void(this.comment=!0);if(!e)return void(this.empty=!0);this.parseNegate();var r=this.globSet=this.braceExpand();t.debug&&(this.debug=console.error),this.debug(this.pattern,r),r=this.globParts=r.map(function(e){return e.split(_)}),this.debug(this.pattern,r),r=r.map(function(e,t,r){return e.map(this.parse,this)},this),this.debug(this.pattern,r),r=r.filter(function(e){return-1===e.indexOf(!1)}),this.debug(this.pattern,r),this.set=r}}function u(){var e=this.pattern,t=!1,r=this.options,n=0;if(!r.nonegate){for(var i=0,s=e.length;i<s&&"!"===e.charAt(i);i++)t=!t,n++;n&&(this.pattern=e.substr(n)),this.negate=t}}function l(e,t){if(t||(t=this instanceof a?this.options:{}),void 0===(e=void 0===e?this.pattern:e))throw new TypeError("undefined pattern");return t.nobrace||!e.match(/\{.*\}/)?[e]:v(e)}function c(e,t){function r(){if(i){switch(i){case"*":a+=E,o=!0;break;case"?":a+=b,o=!0;break;default:a+="\\"+i}v.debug("clearStateChar %j %j",i,a),i=!1}}if(e.length>65536)throw new TypeError("pattern is too long");var n=this.options;if(!n.noglobstar&&"**"===e)return y;if(""===e)return"";for(var i,s,a="",o=!!n.nocase,u=!1,l=[],c=[],f=!1,p=-1,h=-1,m="."===e.charAt(0)?"":n.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",v=this,x=0,A=e.length;x<A&&(s=e.charAt(x));x++)if(this.debug("%s\t%s %s %j",e,x,a,s),u&&S[s])a+="\\"+s,u=!1;else switch(s){case"/":return!1;case"\\":r(),u=!0;continue;case"?":case"*":case"+":case"@":case"!":if(this.debug("%s\t%s %s %j <-- stateChar",e,x,a,s),f){this.debug(" in class"),"!"===s&&x===h+1&&(s="^"),a+=s;continue}v.debug("call clearStateChar %j",i),r(),i=s,n.noext&&r();continue;case"(":if(f){a+="(";continue}if(!i){a+="\\(";continue}l.push({type:i,start:x-1,reStart:a.length,open:g[i].open,close:g[i].close}),a+="!"===i?"(?:(?!(?:":"(?:",this.debug("plType %j %j",i,a),i=!1;continue;case")":if(f||!l.length){a+="\\)";continue}r(),o=!0;var _=l.pop();a+=_.close,"!"===_.type&&c.push(_),_.reEnd=a.length;continue;case"|":if(f||!l.length||u){a+="\\|",u=!1;continue}r(),a+="|";continue;case"[":if(r(),f){a+="\\"+s;continue}f=!0,h=x,p=a.length,a+=s;continue;case"]":if(x===h+1||!f){a+="\\"+s,u=!1;continue}if(f){var C=e.substring(h+1,x);try{RegExp("["+C+"]")}catch(e){var w=this.parse(C,D);a=a.substr(0,p)+"\\["+w[0]+"\\]",o=o||w[1],f=!1;continue}}o=!0,f=!1,a+=s;continue;default:r(),u?u=!1:!S[s]||"^"===s&&f||(a+="\\"),a+=s}for(f&&(C=e.substr(h+1),w=this.parse(C,D),a=a.substr(0,p)+"\\["+w[0],o=o||w[1]),_=l.pop();_;_=l.pop()){var P=a.slice(_.reStart+_.open.length);this.debug("setting tail",a,_),P=P.replace(/((?:\\{2}){0,64})(\\?)\|/g,function(e,t,r){return r||(r="\\"),t+t+r+"|"}),this.debug("tail=%j\n %s",P,P,_,a);var k="*"===_.type?E:"?"===_.type?b:"\\"+_.type;o=!0,a=a.slice(0,_.reStart)+k+"\\("+P}r(),u&&(a+="\\\\");var F=!1;switch(a.charAt(0)){case".":case"[":case"(":F=!0}for(var T=c.length-1;T>-1;T--){var O=c[T],B=a.slice(0,O.reStart),R=a.slice(O.reStart,O.reEnd-8),I=a.slice(O.reEnd-8,O.reEnd),M=a.slice(O.reEnd);I+=M;var N=B.split("(").length-1,L=M;for(x=0;x<N;x++)L=L.replace(/\)[+*?]?/,"");M=L;var j="";""===M&&t!==D&&(j="$");a=B+R+M+j+I}if(""!==a&&o&&(a="(?=.)"+a),F&&(a=m+a),t===D)return[a,o];if(!o)return d(e);var U=n.nocase?"i":"";try{var V=new RegExp("^"+a+"$",U)}catch(e){return new RegExp("$.")}return V._glob=e,V._src=a,V}function f(){if(this.regexp||!1===this.regexp)return this.regexp;var e=this.set;if(!e.length)return this.regexp=!1,this.regexp;var t=this.options,r=t.noglobstar?E:t.dot?x:A,n=t.nocase?"i":"",i=e.map(function(e){return e.map(function(e){return e===y?r:"string"==typeof e?h(e):e._src}).join("\\/")}).join("|");i="^(?:"+i+")$",this.negate&&(i="^(?!"+i+").*$");try{this.regexp=new RegExp(i,n)}catch(e){this.regexp=!1}return this.regexp}function p(e,t){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return""===e;if("/"===e&&t)return!0;var r=this.options;"/"!==m.sep&&(e=e.split(m.sep).join("/")),e=e.split(_),this.debug(this.pattern,"split",e);var n=this.set;this.debug(this.pattern,"set",n);var i,s;for(s=e.length-1;s>=0&&!(i=e[s]);s--);for(s=0;s<n.length;s++){var a=n[s],o=e;r.matchBase&&1===a.length&&(o=[i]);if(this.matchOne(o,a,t))return!!r.flipNegate||!this.negate}return!r.flipNegate&&this.negate}function d(e){return e.replace(/\\(.)/g,"$1")}function h(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}e.exports=s,s.Minimatch=a;var m={sep:"/"};try{m=r(19)}catch(e){}var y=s.GLOBSTAR=a.GLOBSTAR={},v=r(398),g={"!":{open:"(?:(?!(?:",close:"))[^/]*?)"},"?":{open:"(?:",close:")?"},"+":{open:"(?:",close:")+"},"*":{open:"(?:",close:")*"},"@":{open:"(?:",close:")"}},b="[^/]",E=b+"*?",x="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",A="(?:(?!(?:\\/|^)\\.).)*?",S=function(e){return e.split("").reduce(function(e,t){return e[t]=!0,e},{})}("().*{}+?[]^$\\!"),_=/\/+/;s.filter=n,s.defaults=function(e){if(!e||!Object.keys(e).length)return s;var t=s,r=function(r,n,s){return t.minimatch(r,n,i(e,s))};return r.Minimatch=function(r,n){return new t.Minimatch(r,i(e,n))},r},a.defaults=function(e){return e&&Object.keys(e).length?s.defaults(e).Minimatch:a},a.prototype.debug=function(){},a.prototype.make=o,a.prototype.parseNegate=u,s.braceExpand=function(e,t){return l(e,t)},a.prototype.braceExpand=l,a.prototype.parse=c;var D={};s.makeRe=function(e,t){return new a(e,t||{}).makeRe()},a.prototype.makeRe=f,s.match=function(e,t,r){r=r||{};var n=new a(t,r);return e=e.filter(function(e){return n.match(e)}),n.options.nonull&&!e.length&&e.push(t),e},a.prototype.match=p,a.prototype.matchOne=function(e,t,r){var n=this.options;this.debug("matchOne",{this:this,file:e,pattern:t}),this.debug("matchOne",e.length,t.length);for(var i=0,s=0,a=e.length,o=t.length;i<a&&s<o;i++,s++){this.debug("matchOne loop");var u=t[s],l=e[i];if(this.debug(t,u,l),!1===u)return!1;if(u===y){this.debug("GLOBSTAR",[t,u,l]);var c=i,f=s+1;if(f===o){for(this.debug("** at the end");i<a;i++)if("."===e[i]||".."===e[i]||!n.dot&&"."===e[i].charAt(0))return!1;return!0}for(;c<a;){var p=e[c];if(this.debug("\nglobstar while",e,c,t,f,p),this.matchOne(e.slice(c),t.slice(f),r))return this.debug("globstar found match!",c,a,p),!0;if("."===p||".."===p||!n.dot&&"."===p.charAt(0)){this.debug("dot detected!",e,c,t,f);break}this.debug("globstar swallow a segment, and continue"),c++}return!(!r||(this.debug("\n>>> no match, partial?",e,c,t,f),c!==a))}var d;if("string"==typeof u?(d=n.nocase?l.toLowerCase()===u.toLowerCase():l===u,this.debug("string match",u,l,d)):(d=l.match(u),this.debug("pattern match",u,l,d)),!d)return!1}if(i===a&&s===o)return!0;if(i===a)return r;if(s===o){return i===a-1&&""===e[i]}throw new Error("wtf?")}},function(e,t){"use strict";function r(e){if(e=String(e),!(e.length>100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*f;case"days":case"day":case"d":return r*c;case"hours":case"hour":case"hrs":case"hr":case"h":return r*l;case"minutes":case"minute":case"mins":case"min":case"m":return r*u;case"seconds":case"second":case"secs":case"sec":case"s":return r*o;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function n(e){return e>=c?Math.round(e/c)+"d":e>=l?Math.round(e/l)+"h":e>=u?Math.round(e/u)+"m":e>=o?Math.round(e/o)+"s":e+"ms"}function i(e){return s(e,c,"day")||s(e,l,"hour")||s(e,u,"minute")||s(e,o,"second")||e+" ms"}function s(e,t,r){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+r:Math.ceil(e/t)+" "+r+"s"}var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=1e3,u=60*o,l=60*u,c=24*l,f=365.25*c;e.exports=function(e,t){t=t||{};var s=void 0===e?"undefined":a(e);if("string"===s&&e.length>0)return r(e);if("number"===s&&!1===isNaN(e))return t.long?i(e):n(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t){"use strict";e.exports=Number.isNaN||function(e){return e!==e}},function(e,t,r){(function(t){"use strict";function r(e){return"/"===e.charAt(0)}function n(e){var t=/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/,r=t.exec(e),n=r[1]||"",i=Boolean(n&&":"!==n.charAt(1));return Boolean(r[2]||i)}e.exports="win32"===t.platform?n:r,e.exports.posix=r,e.exports.win32=n}).call(t,r(8))},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}var i=r(14),s=function(e){return e&&e.__esModule?e:{default:e}}(i),a=r(1),o=n(a),u=r(116),l=n(u),c=Object.prototype.hasOwnProperty;t.hoist=function(e){function t(e,t){o.assertVariableDeclaration(e);var n=[];return e.declarations.forEach(function(e){r[e.id.name]=o.identifier(e.id.name),e.init?n.push(o.assignmentExpression("=",e.id,e.init)):t&&n.push(e.id)}),0===n.length?null:1===n.length?n[0]:o.sequenceExpression(n)}o.assertFunction(e.node);var r={};e.get("body").traverse({VariableDeclaration:{exit:function(e){var r=t(e.node,!1);null===r?e.remove():l.replaceWithOrRemove(e,o.expressionStatement(r)),e.skip()}},ForStatement:function(e){var r=e.node.init;o.isVariableDeclaration(r)&&l.replaceWithOrRemove(e.get("init"),t(r,!1))},ForXStatement:function(e){var r=e.get("left");r.isVariableDeclaration()&&l.replaceWithOrRemove(r,t(r.node,!0))},FunctionDeclaration:function(e){var t=e.node;r[t.id.name]=t.id;var n=o.expressionStatement(o.assignmentExpression("=",t.id,o.functionExpression(t.id,t.params,t.body,t.generator,t.expression)));e.parentPath.isBlockStatement()?(e.parentPath.unshiftContainer("body",n),e.remove()):l.replaceWithOrRemove(e,n),e.skip()},FunctionExpression:function(e){e.skip()}});var n={};e.get("params").forEach(function(e){var t=e.node;o.isIdentifier(t)&&(n[t.name]=t)});var i=[];return(0,s.default)(r).forEach(function(e){c.call(n,e)||i.push(o.variableDeclarator(r[e],null))}),0===i.length?null:o.variableDeclaration("var",i)}},function(e,t,r){"use strict";t.__esModule=!0,t.default=function(){return r(610)}},function(e,t,r){"use strict";function n(){d.default.ok(this instanceof n)}function i(e){n.call(this),m.assertLiteral(e),this.returnLoc=e}function s(e,t,r){n.call(this),m.assertLiteral(e),m.assertLiteral(t),r?m.assertIdentifier(r):r=null,this.breakLoc=e,this.continueLoc=t,this.label=r}function a(e){n.call(this),m.assertLiteral(e),this.breakLoc=e}function o(e,t,r){n.call(this),m.assertLiteral(e),t?d.default.ok(t instanceof u):t=null,r?d.default.ok(r instanceof l):r=null,d.default.ok(t||r),this.firstLoc=e,this.catchEntry=t,this.finallyEntry=r}function u(e,t){n.call(this),m.assertLiteral(e),m.assertIdentifier(t),this.firstLoc=e,this.paramId=t}function l(e,t){n.call(this),m.assertLiteral(e),m.assertLiteral(t),this.firstLoc=e,this.afterLoc=t}function c(e,t){n.call(this),m.assertLiteral(e),m.assertIdentifier(t),this.breakLoc=e,this.label=t}function f(e){d.default.ok(this instanceof f);var t=r(283).Emitter;d.default.ok(e instanceof t),this.emitter=e,this.entryStack=[new i(e.finalLoc)]}var p=r(64),d=function(e){return e&&e.__esModule?e:{default:e}}(p),h=r(1),m=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(h),y=r(117);(0,y.inherits)(i,n),t.FunctionEntry=i,(0,y.inherits)(s,n),t.LoopEntry=s,(0,y.inherits)(a,n),t.SwitchEntry=a,(0,y.inherits)(o,n),t.TryEntry=o,(0,y.inherits)(u,n),t.CatchEntry=u,(0,y.inherits)(l,n),t.FinallyEntry=l,(0,y.inherits)(c,n),t.LabeledEntry=c;var v=f.prototype;t.LeapManager=f,v.withEntry=function(e,t){d.default.ok(e instanceof n),this.entryStack.push(e);try{t.call(this.emitter)}finally{var r=this.entryStack.pop();d.default.strictEqual(r,e)}},v._findLeapLocation=function(e,t){for(var r=this.entryStack.length-1;r>=0;--r){var n=this.entryStack[r],i=n[e];if(i)if(t){if(n.label&&n.label.name===t.name)return i}else if(!(n instanceof c))return i}return null},v.getBreakLoc=function(e){return this._findLeapLocation("breakLoc",e)},v.getContinueLoc=function(e){return this._findLeapLocation("continueLoc",e)}},function(e,t,r){"use strict";function n(e,t){function r(e){function t(e){return r||(Array.isArray(e)?e.some(t):o.isNode(e)&&(s.default.strictEqual(r,!1),r=n(e))),r}o.assertNode(e);var r=!1,i=o.VISITOR_KEYS[e.type];if(i)for(var a=0;a<i.length;a++){var u=i[a],l=e[u];t(l)}return r}function n(n){o.assertNode(n);var i=u(n);return l.call(i,e)?i[e]:l.call(c,n.type)?i[e]=!1:l.call(t,n.type)?i[e]=!0:i[e]=r(n)}return n.onlyChildren=r,n}var i=r(64),s=function(e){return e&&e.__esModule?e:{default:e}}(i),a=r(1),o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(a),u=r(281).makeAccessor(),l=Object.prototype.hasOwnProperty,c={FunctionExpression:!0,ArrowFunctionExpression:!0},f={CallExpression:!0,ForInStatement:!0,UnaryExpression:!0,BinaryExpression:!0,AssignmentExpression:!0,UpdateExpression:!0,NewExpression:!0},p={YieldExpression:!0,BreakStatement:!0,ContinueStatement:!0,ReturnStatement:!0,ThrowStatement:!0};for(var d in p)l.call(p,d)&&(f[d]=p[d]);t.hasSideEffects=n("hasSideEffects",f),t.containsLeap=n("containsLeap",p)},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function i(e){if(!e.node||!a.isFunction(e.node))throw new Error("replaceShorthandObjectMethod can only be called on Function AST node paths.");if(!a.isObjectMethod(e.node))return e;if(!e.node.generator)return e;var t=e.node.params.map(function(e){return a.cloneDeep(e)}),r=a.functionExpression(null,t,a.cloneDeep(e.node.body),e.node.generator,e.node.async);return u.replaceWithOrRemove(e,a.objectProperty(a.cloneDeep(e.node.key),r,e.node.computed,!1)),e.get("value")}t.__esModule=!0,t.default=i;var s=r(1),a=n(s),o=r(116),u=n(o)},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}function s(e){var t=e.node;return f.assertFunction(t),t.id||(t.id=e.scope.parent.generateUidIdentifier("callee")),t.generator&&f.isFunctionDeclaration(t)?a(e):t.id}function a(e){var t=e.node;f.assertIdentifier(t.id);var r=e.findParent(function(e){return e.isProgram()||e.isBlockStatement()});if(!r)return t.id;var n=r.node;l.default.ok(Array.isArray(n.body));var i=g(n);i.decl||(i.decl=f.variableDeclaration("var",[]),r.unshiftContainer("body",i.decl),i.declPath=r.get("body.0")),l.default.strictEqual(i.declPath.node,i.decl);var s=r.scope.generateUidIdentifier("marked"),a=f.callExpression(v.runtimeProperty("mark"),[t.id]),o=i.decl.declarations.push(f.variableDeclarator(s,a))-1,u=i.declPath.get("declarations."+o+".init");return l.default.strictEqual(u.node,a),u.addComment("leading","#__PURE__"),s}function o(e,t){var r={didRenameArguments:!1,argsId:t};return e.traverse(b,r),r.didRenameArguments}var u=r(64),l=i(u),c=r(1),f=n(c),p=r(605),d=r(283),h=r(609),m=i(h),y=r(116),v=n(y);t.name="regenerator-transform",t.visitor={Function:{exit:function(e,t){var r=e.node;if(r.generator){if(r.async){if(!1===t.opts.asyncGenerators)return}else if(!1===t.opts.generators)return}else{if(!r.async)return;if(!1===t.opts.async)return}e=(0,m.default)(e),r=e.node;var n=e.scope.generateUidIdentifier("context"),i=e.scope.generateUidIdentifier("args");e.ensureBlock();var a=e.get("body");r.async&&a.traverse(x),a.traverse(E,{context:n});var u=[],l=[];a.get("body").forEach(function(e){var t=e.node;f.isExpressionStatement(t)&&f.isStringLiteral(t.expression)?u.push(t):t&&null!=t._blockHoist?u.push(t):l.push(t)}),u.length>0&&(a.node.body=l);var c=s(e);f.assertIdentifier(r.id);var h=f.identifier(r.id.name+"$"),y=(0,p.hoist)(e);if(o(e,i)){y=y||f.variableDeclaration("var",[]);var g=f.identifier("arguments");g._shadowedFunctionLiteral=e,y.declarations.push(f.variableDeclarator(i,g))}var b=new d.Emitter(n);b.explode(e.get("body")),y&&y.declarations.length>0&&u.push(y);var A=[b.getContextFunction(h),r.generator?c:f.nullLiteral(),f.thisExpression()],S=b.getTryLocsList();S&&A.push(S);var _=f.callExpression(v.runtimeProperty(r.async?"async":"wrap"),A);u.push(f.returnStatement(_)),r.body=f.blockStatement(u);var D=a.node.directives;D&&(r.body.directives=D);var C=r.generator;C&&(r.generator=!1),r.async&&(r.async=!1),C&&f.isExpression(r)&&(v.replaceWithOrRemove(e,f.callExpression(v.runtimeProperty("mark"),[r])),e.addComment("leading","#__PURE__")),e.requeue()}}};var g=r(281).makeAccessor(),b={"FunctionExpression|FunctionDeclaration":function(e){e.skip()},Identifier:function(e,t){"arguments"===e.node.name&&v.isReference(e)&&(v.replaceWithOrRemove(e,t.argsId),t.didRenameArguments=!0)}},E={MetaProperty:function(e){var t=e.node;"function"===t.meta.name&&"sent"===t.property.name&&v.replaceWithOrRemove(e,f.memberExpression(this.context,f.identifier("_sent")))}},x={Function:function(e){e.skip()},AwaitExpression:function(e){var t=e.node.argument;v.replaceWithOrRemove(e,f.yieldExpression(f.callExpression(v.runtimeProperty("awrap"),[t]),!1))}}},function(e,t,r){"use strict";var n=r(282);t.REGULAR={d:n().addRange(48,57),D:n().addRange(0,47).addRange(58,65535),s:n(32,160,5760,8239,8287,12288,65279).addRange(9,13).addRange(8192,8202).addRange(8232,8233),S:n().addRange(0,8).addRange(14,31).addRange(33,159).addRange(161,5759).addRange(5761,8191).addRange(8203,8231).addRange(8234,8238).addRange(8240,8286).addRange(8288,12287).addRange(12289,65278).addRange(65280,65535),w:n(95).addRange(48,57).addRange(65,90).addRange(97,122),W:n(96).addRange(0,47).addRange(58,64).addRange(91,94).addRange(123,65535)},t.UNICODE={d:n().addRange(48,57),D:n().addRange(0,47).addRange(58,1114111),s:n(32,160,5760,8239,8287,12288,65279).addRange(9,13).addRange(8192,8202).addRange(8232,8233),S:n().addRange(0,8).addRange(14,31).addRange(33,159).addRange(161,5759).addRange(5761,8191).addRange(8203,8231).addRange(8234,8238).addRange(8240,8286).addRange(8288,12287).addRange(12289,65278).addRange(65280,1114111),w:n(95).addRange(48,57).addRange(65,90).addRange(97,122),W:n(96).addRange(0,47).addRange(58,64).addRange(91,94).addRange(123,1114111)},t.UNICODE_IGNORE_CASE={d:n().addRange(48,57),D:n().addRange(0,47).addRange(58,1114111),s:n(32,160,5760,8239,8287,12288,65279).addRange(9,13).addRange(8192,8202).addRange(8232,8233),S:n().addRange(0,8).addRange(14,31).addRange(33,159).addRange(161,5759).addRange(5761,8191).addRange(8203,8231).addRange(8234,8238).addRange(8240,8286).addRange(8288,12287).addRange(12289,65278).addRange(65280,1114111),w:n(95,383,8490).addRange(48,57).addRange(65,90).addRange(97,122),W:n(75,83,96).addRange(0,47).addRange(58,64).addRange(91,94).addRange(123,1114111)}},function(e,t,r){"use strict";function n(e){return S?A?m.UNICODE_IGNORE_CASE[e]:m.UNICODE[e]:m.REGULAR[e]}function i(e,t){return v.call(e,t)}function s(e,t){for(var r in t)e[r]=t[r]}function a(e,t){if(t){var r=p(t,"");switch(r.type){case"characterClass":case"group":case"value":break;default:r=o(r,t)}s(e,r)}}function o(e,t){return{type:"group",behavior:"ignore",body:[e],raw:"(?:"+t+")"}}function u(e){return!!i(h,e)&&h[e]}function l(e){var t=d();e.body.forEach(function(e){switch(e.type){case"value":if(t.add(e.codePoint),A&&S){var r=u(e.codePoint);r&&t.add(r)}break;case"characterClassRange":var i=e.min.codePoint,s=e.max.codePoint;t.addRange(i,s),A&&S&&t.iuAddRange(i,s);break;case"characterClassEscape":t.add(n(e.value));break;default:throw Error("Unknown term type: "+e.type)}});return e.negative&&(t=(S?g:b).clone().remove(t)),a(e,t.toString()),e}function c(e){switch(e.type){case"dot":a(e,(S?E:x).toString());break;case"characterClass":e=l(e);break;case"characterClassEscape":a(e,n(e.value).toString());break;case"alternative":case"disjunction":case"group":case"quantifier":e.body=e.body.map(c);break;case"value":var t=e.codePoint,r=d(t);if(A&&S){var i=u(t);i&&r.add(i)}a(e,r.toString());break;case"anchor":case"empty":case"group":case"reference":break;default:throw Error("Unknown term type: "+e.type)}return e}var f=r(613).generate,p=r(614).parse,d=r(282),h=r(631),m=r(611),y={},v=y.hasOwnProperty,g=d().addRange(0,1114111),b=d().addRange(0,65535),E=g.clone().remove(10,13,8232,8233),x=E.clone().intersection(b);d.prototype.iuAddRange=function(e,t){var r=this;do{var n=u(e);n&&r.add(n)}while(++e<=t);return r};var A=!1,S=!1;e.exports=function(e,t){var r=p(e,t);return A=!!t&&t.indexOf("i")>-1,S=!!t&&t.indexOf("u")>-1,s(r,c(r)),f(r)}},function(e,t,r){var n;(function(e,i){"use strict";var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};(function(){function a(){var e,t,r=[],n=-1,i=arguments.length;if(!i)return"";for(var s="";++n<i;){var a=Number(arguments[n]);if(!isFinite(a)||a<0||a>1114111||k(a)!=a)throw RangeError("Invalid code point: "+a);a<=65535?r.push(a):(a-=65536,e=55296+(a>>10),t=a%1024+56320,r.push(e,t)),(n+1==i||r.length>16384)&&(s+=P.apply(null,r),r.length=0)}return s}function o(e,t){if(-1==t.indexOf("|")){if(e==t)return;throw Error("Invalid node type: "+e)}if(t=o.hasOwnProperty(t)?o[t]:o[t]=RegExp("^(?:"+t+")$"),!t.test(e))throw Error("Invalid node type: "+e) +}function u(e){var t=e.type;if(u.hasOwnProperty(t)&&"function"==typeof u[t])return u[t](e);throw Error("Invalid node type: "+t)}function l(e){o(e.type,"alternative");var t=e.body,r=t?t.length:0;if(1==r)return x(t[0]);for(var n=-1,i="";++n<r;)i+=x(t[n]);return i}function c(e){switch(o(e.type,"anchor"),e.kind){case"start":return"^";case"end":return"$";case"boundary":return"\\b";case"not-boundary":return"\\B";default:throw Error("Invalid assertion")}}function f(e){return o(e.type,"anchor|characterClass|characterClassEscape|dot|group|reference|value"),u(e)}function p(e){o(e.type,"characterClass");var t=e.body,r=t?t.length:0,n=-1,i="[";for(e.negative&&(i+="^");++n<r;)i+=m(t[n]);return i+="]"}function d(e){return o(e.type,"characterClassEscape"),"\\"+e.value}function h(e){o(e.type,"characterClassRange");var t=e.min,r=e.max;if("characterClassRange"==t.type||"characterClassRange"==r.type)throw Error("Invalid character class range");return m(t)+"-"+m(r)}function m(e){return o(e.type,"anchor|characterClassEscape|characterClassRange|dot|value"),u(e)}function y(e){o(e.type,"disjunction");var t=e.body,r=t?t.length:0;if(0==r)throw Error("No body");if(1==r)return u(t[0]);for(var n=-1,i="";++n<r;)0!=n&&(i+="|"),i+=u(t[n]);return i}function v(e){return o(e.type,"dot"),"."}function g(e){o(e.type,"group");var t="(";switch(e.behavior){case"normal":break;case"ignore":t+="?:";break;case"lookahead":t+="?=";break;case"negativeLookahead":t+="?!";break;default:throw Error("Invalid behaviour: "+e.behaviour)}var r=e.body,n=r?r.length:0;if(1==n)t+=u(r[0]);else for(var i=-1;++i<n;)t+=u(r[i]);return t+=")"}function b(e){o(e.type,"quantifier");var t="",r=e.min,n=e.max;switch(n){case void 0:case null:switch(r){case 0:t="*";break;case 1:t="+";break;default:t="{"+r+",}"}break;default:t=r==n?"{"+r+"}":0==r&&1==n?"?":"{"+r+","+n+"}"}return e.greedy||(t+="?"),f(e.body[0])+t}function E(e){return o(e.type,"reference"),"\\"+e.matchIndex}function x(e){return o(e.type,"anchor|characterClass|characterClassEscape|empty|group|quantifier|reference|value"),u(e)}function A(e){o(e.type,"value");var t=e.kind,r=e.codePoint;switch(t){case"controlLetter":return"\\c"+a(r+64);case"hexadecimalEscape":return"\\x"+("00"+r.toString(16).toUpperCase()).slice(-2);case"identifier":return"\\"+a(r);case"null":return"\\"+r;case"octal":return"\\"+r.toString(8);case"singleEscape":switch(r){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 11:return"\\v";case 12:return"\\f";case 13:return"\\r";default:throw Error("Invalid codepoint: "+r)}case"symbol":return a(r);case"unicodeEscape":return"\\u"+("0000"+r.toString(16).toUpperCase()).slice(-4);case"unicodeCodePointEscape":return"\\u{"+r.toString(16).toUpperCase()+"}";default:throw Error("Unsupported node kind: "+t)}}var S={function:!0,object:!0},_=S["undefined"==typeof window?"undefined":s(window)]&&window||this,D=S[s(t)]&&t,C=S[s(e)]&&e&&!e.nodeType&&e,w=D&&C&&"object"==(void 0===i?"undefined":s(i))&&i;!w||w.global!==w&&w.window!==w&&w.self!==w||(_=w);var P=String.fromCharCode,k=Math.floor;u.alternative=l,u.anchor=c,u.characterClass=p,u.characterClassEscape=d,u.characterClassRange=h,u.disjunction=y,u.dot=v,u.group=g,u.quantifier=b,u.reference=E,u.value=A,"object"==s(r(49))&&r(49)?void 0!==(n=function(){return{generate:u}}.call(t,r,t,e))&&(e.exports=n):D&&C?D.generate=u:_.regjsgen={generate:u}}).call(void 0)}).call(t,r(39)(e),function(){return this}())},function(e,t){"use strict";!function(){function t(e,t){function r(t){return t.raw=e.substring(t.range[0],t.range[1]),t}function n(e,t){return e.range[0]=t,r(e)}function i(e,t){return r({type:"anchor",kind:e,range:[$-t,$]})}function s(e,t,n,i){return r({type:"value",kind:e,codePoint:t,range:[n,i]})}function a(e,t,r,n){return n=n||0,s(e,t,$-(r.length+n),$)}function o(e){var t=e[0],r=t.charCodeAt(0);if(z){var n;if(1===t.length&&r>=55296&&r<=56319&&(n=x().charCodeAt(0))>=56320&&n<=57343)return $++,s("symbol",1024*(r-55296)+n-56320+65536,$-2,$)}return s("symbol",r,$-1,$)}function u(e,t,n){return r({type:"disjunction",body:e,range:[t,n]})}function l(){return r({type:"dot",range:[$-1,$]})}function c(e){return r({type:"characterClassEscape",value:e,range:[$-2,$]})}function f(e){return r({type:"reference",matchIndex:parseInt(e,10),range:[$-1-e.length,$]})}function p(e,t,n,i){return r({type:"group",behavior:e,body:t,range:[n,i]})}function d(e,t,n,i){return null==i&&(n=$-1,i=$),r({type:"quantifier",min:e,max:t,greedy:!0,body:null,range:[n,i]})}function h(e,t,n){return r({type:"alternative",body:e,range:[t,n]})}function m(e,t,n,i){return r({type:"characterClass",body:e,negative:t,range:[n,i]})}function y(e,t,n,i){return e.codePoint>t.codePoint&&K("invalid range in character class",e.raw+"-"+t.raw,n,i),r({type:"characterClassRange",min:e,max:t,range:[n,i]})}function v(e){return"alternative"===e.type?e.body:[e]}function g(t){t=t||1;var r=e.substring($,$+t);return $+=t||1,r}function b(e){E(e)||K("character",e)}function E(t){if(e.indexOf(t,$)===$)return g(t.length)}function x(){return e[$]}function A(t){return e.indexOf(t,$)===$}function S(t){return e[$+1]===t}function _(t){var r=e.substring($),n=r.match(t);return n&&(n.range=[],n.range[0]=$,g(n[0].length),n.range[1]=$),n}function D(){var e=[],t=$;for(e.push(C());E("|");)e.push(C());return 1===e.length?e[0]:u(e,t,$)}function C(){for(var e,t=[],r=$;e=w();)t.push(e);return 1===t.length?t[0]:h(t,r,$)}function w(){if($>=e.length||A("|")||A(")"))return null;var t=k();if(t)return t;var r=T();r||K("Expected atom");var i=F()||!1;return i?(i.body=v(r),n(i,r.range[0]),i):r}function P(e,t,r,n){var i=null,s=$;if(E(e))i=t;else{if(!E(r))return!1;i=n}var a=D();a||K("Expected disjunction"),b(")");var o=p(i,v(a),s,$);return"normal"==i&&X&&J++,o}function k(){return E("^")?i("start",1):E("$")?i("end",1):E("\\b")?i("boundary",2):E("\\B")?i("not-boundary",2):P("(?=","lookahead","(?!","negativeLookahead")}function F(){var e,t,r,n,i=$;return E("*")?t=d(0):E("+")?t=d(1):E("?")?t=d(0,1):(e=_(/^\{([0-9]+)\}/))?(r=parseInt(e[1],10),t=d(r,r,e.range[0],e.range[1])):(e=_(/^\{([0-9]+),\}/))?(r=parseInt(e[1],10),t=d(r,void 0,e.range[0],e.range[1])):(e=_(/^\{([0-9]+),([0-9]+)\}/))&&(r=parseInt(e[1],10),n=parseInt(e[2],10),r>n&&K("numbers out of order in {} quantifier","",i,$),t=d(r,n,e.range[0],e.range[1])),t&&E("?")&&(t.greedy=!1,t.range[1]+=1),t}function T(){var e;return(e=_(/^[^^$\\.*+?(){[|]/))?o(e):E(".")?l():E("\\")?(e=R(),e||K("atomEscape"),e):(e=j())?e:P("(?:","ignore","(","normal")}function O(e){if(z){var t,n;if("unicodeEscape"==e.kind&&(t=e.codePoint)>=55296&&t<=56319&&A("\\")&&S("u")){var i=$;$++;var s=B();"unicodeEscape"==s.kind&&(n=s.codePoint)>=56320&&n<=57343?(e.range[1]=s.range[1],e.codePoint=1024*(t-55296)+n-56320+65536,e.type="value",e.kind="unicodeCodePointEscape",r(e)):$=i}}return e}function B(){return R(!0)}function R(e){var t,r=$;if(t=I())return t;if(e){if(E("b"))return a("singleEscape",8,"\\b");E("B")&&K("\\B not possible inside of CharacterClass","",r)}return t=M()}function I(){var e,t;if(e=_(/^(?!0)\d+/)){t=e[0];var r=parseInt(e[0],10);return r<=J?f(e[0]):(H.push(r),g(-e[0].length),(e=_(/^[0-7]{1,3}/))?a("octal",parseInt(e[0],8),e[0],1):(e=o(_(/^[89]/)),n(e,e.range[0]-1)))}return(e=_(/^[0-7]{1,3}/))?(t=e[0],/^0{1,3}$/.test(t)?a("null",0,"0",t.length+1):a("octal",parseInt(t,8),t,1)):!!(e=_(/^[dDsSwW]/))&&c(e[0])}function M(){var e;if(e=_(/^[fnrtv]/)){var t=0;switch(e[0]){case"t":t=9;break;case"n":t=10;break;case"v":t=11;break;case"f":t=12;break;case"r":t=13}return a("singleEscape",t,"\\"+e[0])}return(e=_(/^c([a-zA-Z])/))?a("controlLetter",e[1].charCodeAt(0)%32,e[1],2):(e=_(/^x([0-9a-fA-F]{2})/))?a("hexadecimalEscape",parseInt(e[1],16),e[1],2):(e=_(/^u([0-9a-fA-F]{4})/))?O(a("unicodeEscape",parseInt(e[1],16),e[1],2)):z&&(e=_(/^u\{([0-9a-fA-F]+)\}/))?a("unicodeCodePointEscape",parseInt(e[1],16),e[1],4):L()}function N(e){var t=new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮ̀-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁ҃-҇Ҋ-ԯԱ-Ֆՙա-և֑-ׇֽֿׁׂׅׄא-תװ-ײؐ-ؚؠ-٩ٮ-ۓە-ۜ۟-۪ۨ-ۼۿܐ-݊ݍ-ޱ߀-ߵߺࠀ-࠭ࡀ-࡛ࢠ-ࢲࣤ-ॣ०-९ॱ-ঃঅ-ঌএঐও-নপ-রলশ-হ়-ৄেৈো-ৎৗড়ঢ়য়-ৣ০-ৱਁ-ਃਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹ਼ਾ-ੂੇੈੋ-੍ੑਖ਼-ੜਫ਼੦-ੵઁ-ઃઅ-ઍએ-ઑઓ-નપ-રલળવ-હ઼-ૅે-ૉો-્ૐૠ-ૣ૦-૯ଁ-ଃଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହ଼-ୄେୈୋ-୍ୖୗଡ଼ଢ଼ୟ-ୣ୦-୯ୱஂஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹா-ூெ-ைொ-்ௐௗ௦-௯ఀ-ఃఅ-ఌఎ-ఐఒ-నప-హఽ-ౄె-ైొ-్ౕౖౘౙౠ-ౣ౦-౯ಁ-ಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹ಼-ೄೆ-ೈೊ-್ೕೖೞೠ-ೣ೦-೯ೱೲഁ-ഃഅ-ഌഎ-ഐഒ-ഺഽ-ൄെ-ൈൊ-ൎൗൠ-ൣ൦-൯ൺ-ൿංඃඅ-ඖක-නඳ-රලව-ෆ්ා-ුූෘ-ෟ෦-෯ෲෳก-ฺเ-๎๐-๙ກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙ໜ-ໟༀ༘༙༠-༩༹༵༷༾-ཇཉ-ཬཱ-྄྆-ྗྙ-ྼ࿆က-၉ၐ-ႝႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚ፝-፟ᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-᜔ᜠ-᜴ᝀ-ᝓᝠ-ᝬᝮ-ᝰᝲᝳក-៓ៗៜ៝០-៩᠋-᠍᠐-᠙ᠠ-ᡷᢀ-ᢪᢰ-ᣵᤀ-ᤞᤠ-ᤫᤰ-᤻᥆-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉ᧐-᧙ᨀ-ᨛᨠ-ᩞ᩠-᩿᩼-᪉᪐-᪙ᪧ᪰-᪽ᬀ-ᭋ᭐-᭙᭫-᭳ᮀ-᯳ᰀ-᰷᱀-᱉ᱍ-ᱽ᳐-᳔᳒-ᳶ᳸᳹ᴀ-᷵᷼-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ‿⁀⁔ⁱⁿₐ-ₜ⃐-⃥⃜⃡-⃰ℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯ⵿-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⷠ-ⷿⸯ々-〇〡-〯〱-〵〸-〼ぁ-ゖ゙゚ゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘫꙀ-꙯ꙴ-꙽ꙿ-ꚝꚟ-꛱ꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞭꞰꞱꟷ-ꠧꡀ-ꡳꢀ-꣄꣐-꣙꣠-ꣷꣻ꤀-꤭ꤰ-꥓ꥠ-ꥼꦀ-꧀ꧏ-꧙ꧠ-ꧾꨀ-ꨶꩀ-ꩍ꩐-꩙ꩠ-ꩶꩺ-ꫂꫛ-ꫝꫠ-ꫯꫲ-꫶ꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭟꭤꭥꯀ-ꯪ꯬꯭꯰-꯹가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻ︀-️︠-︭︳︴﹍-﹏ﹰ-ﹴﹶ-ﻼ0-9A-Z_a-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]");return 36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||92===e||e>=128&&t.test(String.fromCharCode(e))}function L(){var e;return N(x())?E("")?a("identifier",8204,""):E("")?a("identifier",8205,""):null:(e=g(),a("identifier",e.charCodeAt(0),e,1))}function j(){var e,t=$;return(e=_(/^\[\^/))?(e=U(),b("]"),m(e,!0,t,$)):E("[")?(e=U(),b("]"),m(e,!1,t,$)):null}function U(){var e;return A("]")?[]:(e=G(),e||K("nonEmptyClassRanges"),e)}function V(e){var t,r,n;if(A("-")&&!S("]")){b("-"),n=Y(),n||K("classAtom"),r=$;var i=U();return i||K("classRanges"),t=e.range[0],"empty"===i.type?[y(e,n,t,r)]:[y(e,n,t,r)].concat(i)}return n=W(),n||K("nonEmptyClassRangesNoDash"),[e].concat(n)}function G(){var e=Y();return e||K("classAtom"),A("]")?[e]:V(e)}function W(){var e=Y();return e||K("classAtom"),A("]")?e:V(e)}function Y(){return E("-")?o("-"):q()}function q(){var e;return(e=_(/^[^\\\]-]/))?o(e[0]):E("\\")?(e=B(),e||K("classEscape"),O(e)):void 0}function K(t,r,n,i){n=null==n?$:n,i=null==i?n:i;var s=Math.max(0,n-10),a=Math.min(i+10,e.length),o=" "+e.substring(s,a),u=" "+new Array(n-s+1).join(" ")+"^";throw SyntaxError(t+" at position "+n+(r?": "+r:"")+"\n"+o+"\n"+u)}var H=[],J=0,X=!0,z=-1!==(t||"").indexOf("u"),$=0;""===(e=String(e))&&(e="(?:)");var Q=D();Q.range[1]!==e.length&&K("Could not parse entire input - got stuck","",Q.range[1]);for(var Z=0;Z<H.length;Z++)if(H[Z]<=J)return $=0,X=!1,D();return Q}var r={parse:t};void 0!==e&&e.exports?e.exports=r:window.regjsparser=r}()},function(e,t,r){"use strict";var n=r(467);e.exports=function(e,t){if("string"!=typeof e)throw new TypeError("Expected `input` to be a string");if(t<0||!n(t))throw new TypeError("Expected `count` to be a positive finite number");var r="";do{1&t&&(r+=e),e+=e}while(t>>=1);return r}},function(e,t){"use strict";var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");t.encode=function(e){if(0<=e&&e<r.length)return r[e];throw new TypeError("Must be between 0 and 63: "+e)},t.decode=function(e){return 65<=e&&e<=90?e-65:97<=e&&e<=122?e-97+26:48<=e&&e<=57?e-48+52:43==e?62:47==e?63:-1}},function(e,t){"use strict";function r(e,n,i,s,a,o){var u=Math.floor((n-e)/2)+e,l=a(i,s[u],!0);return 0===l?u:l>0?n-u>1?r(u,n,i,s,a,o):o==t.LEAST_UPPER_BOUND?n<s.length?n:-1:u:u-e>1?r(e,u,i,s,a,o):o==t.LEAST_UPPER_BOUND?u:e<0?-1:e}t.GREATEST_LOWER_BOUND=1,t.LEAST_UPPER_BOUND=2,t.search=function(e,n,i,s){if(0===n.length)return-1;var a=r(-1,n.length,e,n,i,s||t.GREATEST_LOWER_BOUND);if(a<0)return-1;for(;a-1>=0&&0===i(n[a],n[a-1],!0);)--a;return a}},function(e,t,r){"use strict";function n(e,t){var r=e.generatedLine,n=t.generatedLine,i=e.generatedColumn,a=t.generatedColumn;return n>r||n==r&&a>=i||s.compareByGeneratedPositionsInflated(e,t)<=0}function i(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}var s=r(63);i.prototype.unsortedForEach=function(e,t){this._array.forEach(e,t)},i.prototype.add=function(e){n(this._last,e)?(this._last=e,this._array.push(e)):(this._sorted=!1,this._array.push(e))},i.prototype.toArray=function(){return this._sorted||(this._array.sort(s.compareByGeneratedPositionsInflated),this._sorted=!0),this._array},t.MappingList=i},function(e,t){"use strict";function r(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function n(e,t){return Math.round(e+Math.random()*(t-e))}function i(e,t,s,a){if(s<a){var o=n(s,a),u=s-1;r(e,o,a);for(var l=e[a],c=s;c<a;c++)t(e[c],l)<=0&&(u+=1,r(e,u,c));r(e,u+1,c);var f=u+1;i(e,t,s,f-1),i(e,t,f+1,a)}}t.quickSort=function(e,t){i(e,t,0,e.length-1)}},function(e,t,r){"use strict";function n(e){var t=e;return"string"==typeof e&&(t=JSON.parse(e.replace(/^\)\]\}'/,""))),null!=t.sections?new a(t):new i(t)}function i(e){var t=e;"string"==typeof e&&(t=JSON.parse(e.replace(/^\)\]\}'/,"")));var r=o.getArg(t,"version"),n=o.getArg(t,"sources"),i=o.getArg(t,"names",[]),s=o.getArg(t,"sourceRoot",null),a=o.getArg(t,"sourcesContent",null),u=o.getArg(t,"mappings"),c=o.getArg(t,"file",null);if(r!=this._version)throw new Error("Unsupported version: "+r);n=n.map(String).map(o.normalize).map(function(e){return s&&o.isAbsolute(s)&&o.isAbsolute(e)?o.relative(s,e):e}),this._names=l.fromArray(i.map(String),!0),this._sources=l.fromArray(n,!0),this.sourceRoot=s,this.sourcesContent=a,this._mappings=u,this.file=c}function s(){this.generatedLine=0,this.generatedColumn=0,this.source=null,this.originalLine=null,this.originalColumn=null,this.name=null}function a(e){var t=e;"string"==typeof e&&(t=JSON.parse(e.replace(/^\)\]\}'/,"")));var r=o.getArg(t,"version"),i=o.getArg(t,"sections");if(r!=this._version)throw new Error("Unsupported version: "+r);this._sources=new l,this._names=new l;var s={line:-1,column:0};this._sections=i.map(function(e){if(e.url)throw new Error("Support for url field in sections not implemented.");var t=o.getArg(e,"offset"),r=o.getArg(t,"line"),i=o.getArg(t,"column");if(r<s.line||r===s.line&&i<s.column)throw new Error("Section offsets must be ordered and non-overlapping.");return s=t,{generatedOffset:{generatedLine:r+1,generatedColumn:i+1},consumer:new n(o.getArg(e,"map"))}})}var o=r(63),u=r(617),l=r(285).ArraySet,c=r(286),f=r(619).quickSort;n.fromSourceMap=function(e){return i.fromSourceMap(e)},n.prototype._version=3,n.prototype.__generatedMappings=null,Object.defineProperty(n.prototype,"_generatedMappings",{get:function(){return this.__generatedMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__generatedMappings}}),n.prototype.__originalMappings=null,Object.defineProperty(n.prototype,"_originalMappings",{get:function(){return this.__originalMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__originalMappings}}),n.prototype._charIsMappingSeparator=function(e,t){var r=e.charAt(t);return";"===r||","===r},n.prototype._parseMappings=function(e,t){throw new Error("Subclasses must implement _parseMappings")},n.GENERATED_ORDER=1,n.ORIGINAL_ORDER=2,n.GREATEST_LOWER_BOUND=1,n.LEAST_UPPER_BOUND=2,n.prototype.eachMapping=function(e,t,r){var i,s=t||null,a=r||n.GENERATED_ORDER;switch(a){case n.GENERATED_ORDER:i=this._generatedMappings;break;case n.ORIGINAL_ORDER:i=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}var u=this.sourceRoot;i.map(function(e){var t=null===e.source?null:this._sources.at(e.source);return null!=t&&null!=u&&(t=o.join(u,t)),{source:t,generatedLine:e.generatedLine,generatedColumn:e.generatedColumn,originalLine:e.originalLine,originalColumn:e.originalColumn,name:null===e.name?null:this._names.at(e.name)}},this).forEach(e,s)},n.prototype.allGeneratedPositionsFor=function(e){var t=o.getArg(e,"line"),r={source:o.getArg(e,"source"),originalLine:t,originalColumn:o.getArg(e,"column",0)};if(null!=this.sourceRoot&&(r.source=o.relative(this.sourceRoot,r.source)),!this._sources.has(r.source))return[];r.source=this._sources.indexOf(r.source);var n=[],i=this._findMapping(r,this._originalMappings,"originalLine","originalColumn",o.compareByOriginalPositions,u.LEAST_UPPER_BOUND);if(i>=0){var s=this._originalMappings[i];if(void 0===e.column)for(var a=s.originalLine;s&&s.originalLine===a;)n.push({line:o.getArg(s,"generatedLine",null),column:o.getArg(s,"generatedColumn",null),lastColumn:o.getArg(s,"lastGeneratedColumn",null)}),s=this._originalMappings[++i];else for(var l=s.originalColumn;s&&s.originalLine===t&&s.originalColumn==l;)n.push({line:o.getArg(s,"generatedLine",null),column:o.getArg(s,"generatedColumn",null),lastColumn:o.getArg(s,"lastGeneratedColumn",null)}),s=this._originalMappings[++i]}return n},t.SourceMapConsumer=n,i.prototype=Object.create(n.prototype),i.prototype.consumer=n,i.fromSourceMap=function(e){var t=Object.create(i.prototype),r=t._names=l.fromArray(e._names.toArray(),!0),n=t._sources=l.fromArray(e._sources.toArray(),!0);t.sourceRoot=e._sourceRoot,t.sourcesContent=e._generateSourcesContent(t._sources.toArray(),t.sourceRoot),t.file=e._file;for(var a=e._mappings.toArray().slice(),u=t.__generatedMappings=[],c=t.__originalMappings=[],p=0,d=a.length;p<d;p++){var h=a[p],m=new s;m.generatedLine=h.generatedLine,m.generatedColumn=h.generatedColumn,h.source&&(m.source=n.indexOf(h.source),m.originalLine=h.originalLine,m.originalColumn=h.originalColumn,h.name&&(m.name=r.indexOf(h.name)),c.push(m)),u.push(m)}return f(t.__originalMappings,o.compareByOriginalPositions),t},i.prototype._version=3,Object.defineProperty(i.prototype,"sources",{get:function(){return this._sources.toArray().map(function(e){return null!=this.sourceRoot?o.join(this.sourceRoot,e):e},this)}}),i.prototype._parseMappings=function(e,t){for(var r,n,i,a,u,l=1,p=0,d=0,h=0,m=0,y=0,v=e.length,g=0,b={},E={},x=[],A=[];g<v;)if(";"===e.charAt(g))l++,g++,p=0;else if(","===e.charAt(g))g++;else{for(r=new s,r.generatedLine=l,a=g;a<v&&!this._charIsMappingSeparator(e,a);a++);if(n=e.slice(g,a),i=b[n])g+=n.length;else{for(i=[];g<a;)c.decode(e,g,E),u=E.value,g=E.rest,i.push(u);if(2===i.length)throw new Error("Found a source, but no line and column");if(3===i.length)throw new Error("Found a source and line, but no column");b[n]=i}r.generatedColumn=p+i[0],p=r.generatedColumn,i.length>1&&(r.source=m+i[1],m+=i[1],r.originalLine=d+i[2],d=r.originalLine,r.originalLine+=1,r.originalColumn=h+i[3],h=r.originalColumn,i.length>4&&(r.name=y+i[4],y+=i[4])),A.push(r),"number"==typeof r.originalLine&&x.push(r)}f(A,o.compareByGeneratedPositionsDeflated),this.__generatedMappings=A,f(x,o.compareByOriginalPositions),this.__originalMappings=x},i.prototype._findMapping=function(e,t,r,n,i,s){if(e[r]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+e[r]);if(e[n]<0)throw new TypeError("Column must be greater than or equal to 0, got "+e[n]);return u.search(e,t,i,s)},i.prototype.computeColumnSpans=function(){for(var e=0;e<this._generatedMappings.length;++e){var t=this._generatedMappings[e];if(e+1<this._generatedMappings.length){var r=this._generatedMappings[e+1];if(t.generatedLine===r.generatedLine){t.lastGeneratedColumn=r.generatedColumn-1;continue}}t.lastGeneratedColumn=1/0}},i.prototype.originalPositionFor=function(e){var t={generatedLine:o.getArg(e,"line"),generatedColumn:o.getArg(e,"column")},r=this._findMapping(t,this._generatedMappings,"generatedLine","generatedColumn",o.compareByGeneratedPositionsDeflated,o.getArg(e,"bias",n.GREATEST_LOWER_BOUND));if(r>=0){var i=this._generatedMappings[r];if(i.generatedLine===t.generatedLine){var s=o.getArg(i,"source",null);null!==s&&(s=this._sources.at(s),null!=this.sourceRoot&&(s=o.join(this.sourceRoot,s)));var a=o.getArg(i,"name",null);return null!==a&&(a=this._names.at(a)),{source:s,line:o.getArg(i,"originalLine",null),column:o.getArg(i,"originalColumn",null),name:a}}}return{source:null,line:null,column:null,name:null}},i.prototype.hasContentsOfAllSources=function(){return!!this.sourcesContent&&(this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some(function(e){return null==e}))},i.prototype.sourceContentFor=function(e,t){if(!this.sourcesContent)return null;if(null!=this.sourceRoot&&(e=o.relative(this.sourceRoot,e)),this._sources.has(e))return this.sourcesContent[this._sources.indexOf(e)];var r;if(null!=this.sourceRoot&&(r=o.urlParse(this.sourceRoot))){var n=e.replace(/^file:\/\//,"");if("file"==r.scheme&&this._sources.has(n))return this.sourcesContent[this._sources.indexOf(n)];if((!r.path||"/"==r.path)&&this._sources.has("/"+e))return this.sourcesContent[this._sources.indexOf("/"+e)]}if(t)return null;throw new Error('"'+e+'" is not in the SourceMap.')},i.prototype.generatedPositionFor=function(e){var t=o.getArg(e,"source");if(null!=this.sourceRoot&&(t=o.relative(this.sourceRoot,t)),!this._sources.has(t))return{line:null,column:null,lastColumn:null};t=this._sources.indexOf(t);var r={source:t,originalLine:o.getArg(e,"line"),originalColumn:o.getArg(e,"column")},i=this._findMapping(r,this._originalMappings,"originalLine","originalColumn",o.compareByOriginalPositions,o.getArg(e,"bias",n.GREATEST_LOWER_BOUND));if(i>=0){var s=this._originalMappings[i];if(s.source===r.source)return{line:o.getArg(s,"generatedLine",null),column:o.getArg(s,"generatedColumn",null),lastColumn:o.getArg(s,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}},t.BasicSourceMapConsumer=i,a.prototype=Object.create(n.prototype),a.prototype.constructor=n,a.prototype._version=3,Object.defineProperty(a.prototype,"sources",{get:function(){for(var e=[],t=0;t<this._sections.length;t++)for(var r=0;r<this._sections[t].consumer.sources.length;r++)e.push(this._sections[t].consumer.sources[r]);return e}}),a.prototype.originalPositionFor=function(e){var t={generatedLine:o.getArg(e,"line"),generatedColumn:o.getArg(e,"column")},r=u.search(t,this._sections,function(e,t){var r=e.generatedLine-t.generatedOffset.generatedLine;return r||e.generatedColumn-t.generatedOffset.generatedColumn}),n=this._sections[r];return n?n.consumer.originalPositionFor({line:t.generatedLine-(n.generatedOffset.generatedLine-1),column:t.generatedColumn-(n.generatedOffset.generatedLine===t.generatedLine?n.generatedOffset.generatedColumn-1:0),bias:e.bias}):{source:null,line:null,column:null,name:null}},a.prototype.hasContentsOfAllSources=function(){return this._sections.every(function(e){return e.consumer.hasContentsOfAllSources()})},a.prototype.sourceContentFor=function(e,t){for(var r=0;r<this._sections.length;r++){var n=this._sections[r],i=n.consumer.sourceContentFor(e,!0);if(i)return i}if(t)return null;throw new Error('"'+e+'" is not in the SourceMap.')},a.prototype.generatedPositionFor=function(e){for(var t=0;t<this._sections.length;t++){var r=this._sections[t];if(-1!==r.consumer.sources.indexOf(o.getArg(e,"source"))){var n=r.consumer.generatedPositionFor(e);if(n){return{line:n.line+(r.generatedOffset.generatedLine-1),column:n.column+(r.generatedOffset.generatedLine===n.line?r.generatedOffset.generatedColumn-1:0)}}}}return{line:null,column:null}},a.prototype._parseMappings=function(e,t){this.__generatedMappings=[],this.__originalMappings=[];for(var r=0;r<this._sections.length;r++)for(var n=this._sections[r],i=n.consumer._generatedMappings,s=0;s<i.length;s++){var a=i[s],u=n.consumer._sources.at(a.source);null!==n.consumer.sourceRoot&&(u=o.join(n.consumer.sourceRoot,u)),this._sources.add(u),u=this._sources.indexOf(u);var l=n.consumer._names.at(a.name);this._names.add(l),l=this._names.indexOf(l);var c={source:u,generatedLine:a.generatedLine+(n.generatedOffset.generatedLine-1),generatedColumn:a.generatedColumn+(n.generatedOffset.generatedLine===a.generatedLine?n.generatedOffset.generatedColumn-1:0),originalLine:a.originalLine,originalColumn:a.originalColumn,name:l};this.__generatedMappings.push(c),"number"==typeof c.originalLine&&this.__originalMappings.push(c)}f(this.__generatedMappings,o.compareByGeneratedPositionsDeflated),f(this.__originalMappings,o.compareByOriginalPositions)},t.IndexedSourceMapConsumer=a},function(e,t,r){"use strict";function n(e,t,r,n,i){this.children=[],this.sourceContents={},this.line=null==e?null:e,this.column=null==t?null:t,this.source=null==r?null:r,this.name=null==i?null:i,this[o]=!0,null!=n&&this.add(n)}var i=r(287).SourceMapGenerator,s=r(63),a=/(\r?\n)/,o="$$$isSourceNode$$$";n.fromStringWithSourceMap=function(e,t,r){function i(e,t){if(null===e||void 0===e.source)o.add(t);else{var i=r?s.join(r,e.source):e.source;o.add(new n(e.originalLine,e.originalColumn,i,t,e.name))}}var o=new n,u=e.split(a),l=function(){return u.shift()+(u.shift()||"")},c=1,f=0,p=null;return t.eachMapping(function(e){if(null!==p){if(!(c<e.generatedLine)){var t=u[0],r=t.substr(0,e.generatedColumn-f);return u[0]=t.substr(e.generatedColumn-f),f=e.generatedColumn,i(p,r),void(p=e)}i(p,l()),c++,f=0}for(;c<e.generatedLine;)o.add(l()),c++;if(f<e.generatedColumn){var t=u[0];o.add(t.substr(0,e.generatedColumn)),u[0]=t.substr(e.generatedColumn),f=e.generatedColumn}p=e},this),u.length>0&&(p&&i(p,l()),o.add(u.join(""))),t.sources.forEach(function(e){var n=t.sourceContentFor(e);null!=n&&(null!=r&&(e=s.join(r,e)),o.setSourceContent(e,n))}),o},n.prototype.add=function(e){if(Array.isArray(e))e.forEach(function(e){this.add(e)},this);else{if(!e[o]&&"string"!=typeof e)throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);e&&this.children.push(e)}return this},n.prototype.prepend=function(e){if(Array.isArray(e))for(var t=e.length-1;t>=0;t--)this.prepend(e[t]);else{if(!e[o]&&"string"!=typeof e)throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);this.children.unshift(e)}return this},n.prototype.walk=function(e){for(var t,r=0,n=this.children.length;r<n;r++)t=this.children[r],t[o]?t.walk(e):""!==t&&e(t,{source:this.source,line:this.line,column:this.column,name:this.name})},n.prototype.join=function(e){var t,r,n=this.children.length;if(n>0){for(t=[],r=0;r<n-1;r++)t.push(this.children[r]),t.push(e);t.push(this.children[r]),this.children=t}return this},n.prototype.replaceRight=function(e,t){var r=this.children[this.children.length-1];return r[o]?r.replaceRight(e,t):"string"==typeof r?this.children[this.children.length-1]=r.replace(e,t):this.children.push("".replace(e,t)),this},n.prototype.setSourceContent=function(e,t){this.sourceContents[s.toSetString(e)]=t},n.prototype.walkSourceContents=function(e){for(var t=0,r=this.children.length;t<r;t++)this.children[t][o]&&this.children[t].walkSourceContents(e);for(var n=Object.keys(this.sourceContents),t=0,r=n.length;t<r;t++)e(s.fromSetString(n[t]),this.sourceContents[n[t]])},n.prototype.toString=function(){var e="";return this.walk(function(t){e+=t}),e},n.prototype.toStringWithSourceMap=function(e){var t={code:"",line:1,column:0},r=new i(e),n=!1,s=null,a=null,o=null,u=null;return this.walk(function(e,i){t.code+=e,null!==i.source&&null!==i.line&&null!==i.column?(s===i.source&&a===i.line&&o===i.column&&u===i.name||r.addMapping({source:i.source,original:{line:i.line,column:i.column},generated:{line:t.line,column:t.column},name:i.name}),s=i.source,a=i.line,o=i.column,u=i.name,n=!0):n&&(r.addMapping({generated:{line:t.line,column:t.column}}),s=null,n=!1);for(var l=0,c=e.length;l<c;l++)10===e.charCodeAt(l)?(t.line++,t.column=0,l+1===c?(s=null,n=!1):n&&r.addMapping({source:i.source,original:{line:i.line,column:i.column},generated:{line:t.line,column:t.column},name:i.name})):t.column++}),this.walkSourceContents(function(e,t){r.setSourceContent(e,t)}),{code:t.code,map:r}},t.SourceNode=n},function(e,t,r){"use strict";var n=r(180)();e.exports=function(e){return"string"==typeof e?e.replace(n,""):e}},function(e,t,r){(function(t){"use strict";var r=t.argv,n=r.indexOf("--"),i=function(e){e="--"+e;var t=r.indexOf(e);return-1!==t&&(-1===n||t<n)};e.exports=function(){return"FORCE_COLOR"in t.env||!(i("no-color")||i("no-colors")||i("color=false"))&&(!!(i("color")||i("colors")||i("color=true")||i("color=always"))||!(t.stdout&&!t.stdout.isTTY)&&("win32"===t.platform||("COLORTERM"in t.env||"dumb"!==t.env.TERM&&!!/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(t.env.TERM))))}()}).call(t,r(8))},function(e,t){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.exports=function e(t){function n(){}function i(){return r(s.foo)}n.prototype=t;var s=new n;return i(),i(),t}},function(e,t){"use strict";e.exports=function(e){for(var t=e.length;/[\s\uFEFF\u00A0]/.test(e[t-1]);)t--;return e.slice(0,t)}},function(e,t){"use strict";"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},function(e,t){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.exports=function(e){return e&&"object"===(void 0===e?"undefined":r(e))&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.version="6.26.0"},function(e,t){"use strict";function r(e,t){var r=void 0;return null!=t.url?r=t.url:(r="Inline Babel script",++p>1&&(r+=" ("+p+")")),e(t.content,l({filename:r},n(t))).code}function n(e){return{presets:e.presets||["react","es2015"],plugins:e.plugins||["transform-class-properties","transform-object-rest-spread","transform-flow-strip-types"],sourceMaps:"inline"}}function i(e,t){var n=document.createElement("script");n.text=r(e,t),f.appendChild(n)}function s(e,t,r){var n=new XMLHttpRequest;return n.open("GET",e,!0),"overrideMimeType"in n&&n.overrideMimeType("text/plain"),n.onreadystatechange=function(){if(4===n.readyState){if(0!==n.status&&200!==n.status)throw r(),new Error("Could not load "+e);t(n.responseText)}},n.send(null)}function a(e,t){var r=e.getAttribute(t);return""===r?[]:r?r.split(",").map(function(e){return e.trim()}):null}function o(e,t){function r(){var t,r;for(r=0;r<o;r++)if(t=n[r],t.loaded&&!t.executed)t.executed=!0,i(e,t);else if(!t.loaded&&!t.error&&!t.async)break}var n=[],o=t.length;t.forEach(function(e,t){var i={async:e.hasAttribute("async"),error:!1,executed:!1,plugins:a(e,"data-plugins"),presets:a(e,"data-presets")};e.src?(n[t]=l({},i,{content:null,loaded:!1,url:e.src}),s(e.src,function(e){n[t].loaded=!0,n[t].content=e,r()},function(){n[t].error=!0,r()})):n[t]=l({},i,{content:e.innerHTML,loaded:!0,url:null})}),r()}function u(e,t){f=document.getElementsByTagName("head")[0],t||(t=document.getElementsByTagName("script"));for(var r=[],n=0;n<t.length;n++){var i=t.item(n),s=i.type.split(";")[0];-1!==c.indexOf(s)&&r.push(i)}0!==r.length&&(console.warn("You are using the in-browser Babel transformer. Be sure to precompile your scripts for production - https://babeljs.io/docs/setup/"),o(e,r))}Object.defineProperty(t,"__esModule",{value:!0});var l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e};t.runScripts=u;var c=["text/jsx","text/babel"],f=void 0,p=0},function(e,t){e.exports={builtin:{Array:!1,ArrayBuffer:!1,Boolean:!1,constructor:!1,DataView:!1,Date:!1,decodeURI:!1,decodeURIComponent:!1,encodeURI:!1,encodeURIComponent:!1,Error:!1,escape:!1,eval:!1,EvalError:!1,Float32Array:!1,Float64Array:!1,Function:!1,hasOwnProperty:!1,Infinity:!1,Int16Array:!1,Int32Array:!1,Int8Array:!1,isFinite:!1,isNaN:!1,isPrototypeOf:!1,JSON:!1,Map:!1,Math:!1,NaN:!1,Number:!1,Object:!1,parseFloat:!1,parseInt:!1,Promise:!1,propertyIsEnumerable:!1,Proxy:!1,RangeError:!1,ReferenceError:!1,Reflect:!1,RegExp:!1,Set:!1,String:!1,Symbol:!1,SyntaxError:!1,System:!1,toLocaleString:!1,toString:!1,TypeError:!1,Uint16Array:!1,Uint32Array:!1,Uint8Array:!1,Uint8ClampedArray:!1,undefined:!1,unescape:!1,URIError:!1, +valueOf:!1,WeakMap:!1,WeakSet:!1},es5:{Array:!1,Boolean:!1,constructor:!1,Date:!1,decodeURI:!1,decodeURIComponent:!1,encodeURI:!1,encodeURIComponent:!1,Error:!1,escape:!1,eval:!1,EvalError:!1,Function:!1,hasOwnProperty:!1,Infinity:!1,isFinite:!1,isNaN:!1,isPrototypeOf:!1,JSON:!1,Math:!1,NaN:!1,Number:!1,Object:!1,parseFloat:!1,parseInt:!1,propertyIsEnumerable:!1,RangeError:!1,ReferenceError:!1,RegExp:!1,String:!1,SyntaxError:!1,toLocaleString:!1,toString:!1,TypeError:!1,undefined:!1,unescape:!1,URIError:!1,valueOf:!1},es6:{Array:!1,ArrayBuffer:!1,Boolean:!1,constructor:!1,DataView:!1,Date:!1,decodeURI:!1,decodeURIComponent:!1,encodeURI:!1,encodeURIComponent:!1,Error:!1,escape:!1,eval:!1,EvalError:!1,Float32Array:!1,Float64Array:!1,Function:!1,hasOwnProperty:!1,Infinity:!1,Int16Array:!1,Int32Array:!1,Int8Array:!1,isFinite:!1,isNaN:!1,isPrototypeOf:!1,JSON:!1,Map:!1,Math:!1,NaN:!1,Number:!1,Object:!1,parseFloat:!1,parseInt:!1,Promise:!1,propertyIsEnumerable:!1,Proxy:!1,RangeError:!1,ReferenceError:!1,Reflect:!1,RegExp:!1,Set:!1,String:!1,Symbol:!1,SyntaxError:!1,System:!1,toLocaleString:!1,toString:!1,TypeError:!1,Uint16Array:!1,Uint32Array:!1,Uint8Array:!1,Uint8ClampedArray:!1,undefined:!1,unescape:!1,URIError:!1,valueOf:!1,WeakMap:!1,WeakSet:!1},browser:{addEventListener:!1,alert:!1,AnalyserNode:!1,Animation:!1,AnimationEffectReadOnly:!1,AnimationEffectTiming:!1,AnimationEffectTimingReadOnly:!1,AnimationEvent:!1,AnimationPlaybackEvent:!1,AnimationTimeline:!1,applicationCache:!1,ApplicationCache:!1,ApplicationCacheErrorEvent:!1,atob:!1,Attr:!1,Audio:!1,AudioBuffer:!1,AudioBufferSourceNode:!1,AudioContext:!1,AudioDestinationNode:!1,AudioListener:!1,AudioNode:!1,AudioParam:!1,AudioProcessingEvent:!1,AutocompleteErrorEvent:!1,BarProp:!1,BatteryManager:!1,BeforeUnloadEvent:!1,BiquadFilterNode:!1,Blob:!1,blur:!1,btoa:!1,Cache:!1,caches:!1,CacheStorage:!1,cancelAnimationFrame:!1,cancelIdleCallback:!1,CanvasGradient:!1,CanvasPattern:!1,CanvasRenderingContext2D:!1,CDATASection:!1,ChannelMergerNode:!1,ChannelSplitterNode:!1,CharacterData:!1,clearInterval:!1,clearTimeout:!1,clientInformation:!1,ClientRect:!1,ClientRectList:!1,ClipboardEvent:!1,close:!1,closed:!1,CloseEvent:!1,Comment:!1,CompositionEvent:!1,confirm:!1,console:!1,ConvolverNode:!1,createImageBitmap:!1,Credential:!1,CredentialsContainer:!1,crypto:!1,Crypto:!1,CryptoKey:!1,CSS:!1,CSSAnimation:!1,CSSFontFaceRule:!1,CSSImportRule:!1,CSSKeyframeRule:!1,CSSKeyframesRule:!1,CSSMediaRule:!1,CSSPageRule:!1,CSSRule:!1,CSSRuleList:!1,CSSStyleDeclaration:!1,CSSStyleRule:!1,CSSStyleSheet:!1,CSSSupportsRule:!1,CSSTransition:!1,CSSUnknownRule:!1,CSSViewportRule:!1,customElements:!1,CustomEvent:!1,DataTransfer:!1,DataTransferItem:!1,DataTransferItemList:!1,Debug:!1,defaultStatus:!1,defaultstatus:!1,DelayNode:!1,DeviceMotionEvent:!1,DeviceOrientationEvent:!1,devicePixelRatio:!1,dispatchEvent:!1,document:!1,Document:!1,DocumentFragment:!1,DocumentTimeline:!1,DocumentType:!1,DOMError:!1,DOMException:!1,DOMImplementation:!1,DOMParser:!1,DOMSettableTokenList:!1,DOMStringList:!1,DOMStringMap:!1,DOMTokenList:!1,DragEvent:!1,DynamicsCompressorNode:!1,Element:!1,ElementTimeControl:!1,ErrorEvent:!1,event:!1,Event:!1,EventSource:!1,EventTarget:!1,external:!1,FederatedCredential:!1,fetch:!1,File:!1,FileError:!1,FileList:!1,FileReader:!1,find:!1,focus:!1,FocusEvent:!1,FontFace:!1,FormData:!1,frameElement:!1,frames:!1,GainNode:!1,Gamepad:!1,GamepadButton:!1,GamepadEvent:!1,getComputedStyle:!1,getSelection:!1,HashChangeEvent:!1,Headers:!1,history:!1,History:!1,HTMLAllCollection:!1,HTMLAnchorElement:!1,HTMLAppletElement:!1,HTMLAreaElement:!1,HTMLAudioElement:!1,HTMLBaseElement:!1,HTMLBlockquoteElement:!1,HTMLBodyElement:!1,HTMLBRElement:!1,HTMLButtonElement:!1,HTMLCanvasElement:!1,HTMLCollection:!1,HTMLContentElement:!1,HTMLDataListElement:!1,HTMLDetailsElement:!1,HTMLDialogElement:!1,HTMLDirectoryElement:!1,HTMLDivElement:!1,HTMLDListElement:!1,HTMLDocument:!1,HTMLElement:!1,HTMLEmbedElement:!1,HTMLFieldSetElement:!1,HTMLFontElement:!1,HTMLFormControlsCollection:!1,HTMLFormElement:!1,HTMLFrameElement:!1,HTMLFrameSetElement:!1,HTMLHeadElement:!1,HTMLHeadingElement:!1,HTMLHRElement:!1,HTMLHtmlElement:!1,HTMLIFrameElement:!1,HTMLImageElement:!1,HTMLInputElement:!1,HTMLIsIndexElement:!1,HTMLKeygenElement:!1,HTMLLabelElement:!1,HTMLLayerElement:!1,HTMLLegendElement:!1,HTMLLIElement:!1,HTMLLinkElement:!1,HTMLMapElement:!1,HTMLMarqueeElement:!1,HTMLMediaElement:!1,HTMLMenuElement:!1,HTMLMetaElement:!1,HTMLMeterElement:!1,HTMLModElement:!1,HTMLObjectElement:!1,HTMLOListElement:!1,HTMLOptGroupElement:!1,HTMLOptionElement:!1,HTMLOptionsCollection:!1,HTMLOutputElement:!1,HTMLParagraphElement:!1,HTMLParamElement:!1,HTMLPictureElement:!1,HTMLPreElement:!1,HTMLProgressElement:!1,HTMLQuoteElement:!1,HTMLScriptElement:!1,HTMLSelectElement:!1,HTMLShadowElement:!1,HTMLSourceElement:!1,HTMLSpanElement:!1,HTMLStyleElement:!1,HTMLTableCaptionElement:!1,HTMLTableCellElement:!1,HTMLTableColElement:!1,HTMLTableElement:!1,HTMLTableRowElement:!1,HTMLTableSectionElement:!1,HTMLTemplateElement:!1,HTMLTextAreaElement:!1,HTMLTitleElement:!1,HTMLTrackElement:!1,HTMLUListElement:!1,HTMLUnknownElement:!1,HTMLVideoElement:!1,IDBCursor:!1,IDBCursorWithValue:!1,IDBDatabase:!1,IDBEnvironment:!1,IDBFactory:!1,IDBIndex:!1,IDBKeyRange:!1,IDBObjectStore:!1,IDBOpenDBRequest:!1,IDBRequest:!1,IDBTransaction:!1,IDBVersionChangeEvent:!1,Image:!1,ImageBitmap:!1,ImageData:!1,indexedDB:!1,innerHeight:!1,innerWidth:!1,InputEvent:!1,InputMethodContext:!1,IntersectionObserver:!1,IntersectionObserverEntry:!1,Intl:!1,KeyboardEvent:!1,KeyframeEffect:!1,KeyframeEffectReadOnly:!1,length:!1,localStorage:!1,location:!1,Location:!1,locationbar:!1,matchMedia:!1,MediaElementAudioSourceNode:!1,MediaEncryptedEvent:!1,MediaError:!1,MediaKeyError:!1,MediaKeyEvent:!1,MediaKeyMessageEvent:!1,MediaKeys:!1,MediaKeySession:!1,MediaKeyStatusMap:!1,MediaKeySystemAccess:!1,MediaList:!1,MediaQueryList:!1,MediaQueryListEvent:!1,MediaSource:!1,MediaRecorder:!1,MediaStream:!1,MediaStreamAudioDestinationNode:!1,MediaStreamAudioSourceNode:!1,MediaStreamEvent:!1,MediaStreamTrack:!1,menubar:!1,MessageChannel:!1,MessageEvent:!1,MessagePort:!1,MIDIAccess:!1,MIDIConnectionEvent:!1,MIDIInput:!1,MIDIInputMap:!1,MIDIMessageEvent:!1,MIDIOutput:!1,MIDIOutputMap:!1,MIDIPort:!1,MimeType:!1,MimeTypeArray:!1,MouseEvent:!1,moveBy:!1,moveTo:!1,MutationEvent:!1,MutationObserver:!1,MutationRecord:!1,name:!1,NamedNodeMap:!1,navigator:!1,Navigator:!1,Node:!1,NodeFilter:!1,NodeIterator:!1,NodeList:!1,Notification:!1,OfflineAudioCompletionEvent:!1,OfflineAudioContext:!1,offscreenBuffering:!1,onbeforeunload:!0,onblur:!0,onerror:!0,onfocus:!0,onload:!0,onresize:!0,onunload:!0,open:!1,openDatabase:!1,opener:!1,opera:!1,Option:!1,OscillatorNode:!1,outerHeight:!1,outerWidth:!1,PageTransitionEvent:!1,pageXOffset:!1,pageYOffset:!1,parent:!1,PasswordCredential:!1,Path2D:!1,performance:!1,Performance:!1,PerformanceEntry:!1,PerformanceMark:!1,PerformanceMeasure:!1,PerformanceNavigation:!1,PerformanceResourceTiming:!1,PerformanceTiming:!1,PeriodicWave:!1,Permissions:!1,PermissionStatus:!1,personalbar:!1,Plugin:!1,PluginArray:!1,PopStateEvent:!1,postMessage:!1,print:!1,ProcessingInstruction:!1,ProgressEvent:!1,PromiseRejectionEvent:!1,prompt:!1,PushManager:!1,PushSubscription:!1,RadioNodeList:!1,Range:!1,ReadableByteStream:!1,ReadableStream:!1,removeEventListener:!1,Request:!1,requestAnimationFrame:!1,requestIdleCallback:!1,resizeBy:!1,resizeTo:!1,Response:!1,RTCIceCandidate:!1,RTCSessionDescription:!1,RTCPeerConnection:!1,screen:!1,Screen:!1,screenLeft:!1,ScreenOrientation:!1,screenTop:!1,screenX:!1,screenY:!1,ScriptProcessorNode:!1,scroll:!1,scrollbars:!1,scrollBy:!1,scrollTo:!1,scrollX:!1,scrollY:!1,SecurityPolicyViolationEvent:!1,Selection:!1,self:!1,ServiceWorker:!1,ServiceWorkerContainer:!1,ServiceWorkerRegistration:!1,sessionStorage:!1,setInterval:!1,setTimeout:!1,ShadowRoot:!1,SharedKeyframeList:!1,SharedWorker:!1,showModalDialog:!1,SiteBoundCredential:!1,speechSynthesis:!1,SpeechSynthesisEvent:!1,SpeechSynthesisUtterance:!1,status:!1,statusbar:!1,stop:!1,Storage:!1,StorageEvent:!1,styleMedia:!1,StyleSheet:!1,StyleSheetList:!1,SubtleCrypto:!1,SVGAElement:!1,SVGAltGlyphDefElement:!1,SVGAltGlyphElement:!1,SVGAltGlyphItemElement:!1,SVGAngle:!1,SVGAnimateColorElement:!1,SVGAnimatedAngle:!1,SVGAnimatedBoolean:!1,SVGAnimatedEnumeration:!1,SVGAnimatedInteger:!1,SVGAnimatedLength:!1,SVGAnimatedLengthList:!1,SVGAnimatedNumber:!1,SVGAnimatedNumberList:!1,SVGAnimatedPathData:!1,SVGAnimatedPoints:!1,SVGAnimatedPreserveAspectRatio:!1,SVGAnimatedRect:!1,SVGAnimatedString:!1,SVGAnimatedTransformList:!1,SVGAnimateElement:!1,SVGAnimateMotionElement:!1,SVGAnimateTransformElement:!1,SVGAnimationElement:!1,SVGCircleElement:!1,SVGClipPathElement:!1,SVGColor:!1,SVGColorProfileElement:!1,SVGColorProfileRule:!1,SVGComponentTransferFunctionElement:!1,SVGCSSRule:!1,SVGCursorElement:!1,SVGDefsElement:!1,SVGDescElement:!1,SVGDiscardElement:!1,SVGDocument:!1,SVGElement:!1,SVGElementInstance:!1,SVGElementInstanceList:!1,SVGEllipseElement:!1,SVGEvent:!1,SVGExternalResourcesRequired:!1,SVGFEBlendElement:!1,SVGFEColorMatrixElement:!1,SVGFEComponentTransferElement:!1,SVGFECompositeElement:!1,SVGFEConvolveMatrixElement:!1,SVGFEDiffuseLightingElement:!1,SVGFEDisplacementMapElement:!1,SVGFEDistantLightElement:!1,SVGFEDropShadowElement:!1,SVGFEFloodElement:!1,SVGFEFuncAElement:!1,SVGFEFuncBElement:!1,SVGFEFuncGElement:!1,SVGFEFuncRElement:!1,SVGFEGaussianBlurElement:!1,SVGFEImageElement:!1,SVGFEMergeElement:!1,SVGFEMergeNodeElement:!1,SVGFEMorphologyElement:!1,SVGFEOffsetElement:!1,SVGFEPointLightElement:!1,SVGFESpecularLightingElement:!1,SVGFESpotLightElement:!1,SVGFETileElement:!1,SVGFETurbulenceElement:!1,SVGFilterElement:!1,SVGFilterPrimitiveStandardAttributes:!1,SVGFitToViewBox:!1,SVGFontElement:!1,SVGFontFaceElement:!1,SVGFontFaceFormatElement:!1,SVGFontFaceNameElement:!1,SVGFontFaceSrcElement:!1,SVGFontFaceUriElement:!1,SVGForeignObjectElement:!1,SVGGElement:!1,SVGGeometryElement:!1,SVGGlyphElement:!1,SVGGlyphRefElement:!1,SVGGradientElement:!1,SVGGraphicsElement:!1,SVGHKernElement:!1,SVGICCColor:!1,SVGImageElement:!1,SVGLangSpace:!1,SVGLength:!1,SVGLengthList:!1,SVGLinearGradientElement:!1,SVGLineElement:!1,SVGLocatable:!1,SVGMarkerElement:!1,SVGMaskElement:!1,SVGMatrix:!1,SVGMetadataElement:!1,SVGMissingGlyphElement:!1,SVGMPathElement:!1,SVGNumber:!1,SVGNumberList:!1,SVGPaint:!1,SVGPathElement:!1,SVGPathSeg:!1,SVGPathSegArcAbs:!1,SVGPathSegArcRel:!1,SVGPathSegClosePath:!1,SVGPathSegCurvetoCubicAbs:!1,SVGPathSegCurvetoCubicRel:!1,SVGPathSegCurvetoCubicSmoothAbs:!1,SVGPathSegCurvetoCubicSmoothRel:!1,SVGPathSegCurvetoQuadraticAbs:!1,SVGPathSegCurvetoQuadraticRel:!1,SVGPathSegCurvetoQuadraticSmoothAbs:!1,SVGPathSegCurvetoQuadraticSmoothRel:!1,SVGPathSegLinetoAbs:!1,SVGPathSegLinetoHorizontalAbs:!1,SVGPathSegLinetoHorizontalRel:!1,SVGPathSegLinetoRel:!1,SVGPathSegLinetoVerticalAbs:!1,SVGPathSegLinetoVerticalRel:!1,SVGPathSegList:!1,SVGPathSegMovetoAbs:!1,SVGPathSegMovetoRel:!1,SVGPatternElement:!1,SVGPoint:!1,SVGPointList:!1,SVGPolygonElement:!1,SVGPolylineElement:!1,SVGPreserveAspectRatio:!1,SVGRadialGradientElement:!1,SVGRect:!1,SVGRectElement:!1,SVGRenderingIntent:!1,SVGScriptElement:!1,SVGSetElement:!1,SVGStopElement:!1,SVGStringList:!1,SVGStylable:!1,SVGStyleElement:!1,SVGSVGElement:!1,SVGSwitchElement:!1,SVGSymbolElement:!1,SVGTests:!1,SVGTextContentElement:!1,SVGTextElement:!1,SVGTextPathElement:!1,SVGTextPositioningElement:!1,SVGTitleElement:!1,SVGTransform:!1,SVGTransformable:!1,SVGTransformList:!1,SVGTRefElement:!1,SVGTSpanElement:!1,SVGUnitTypes:!1,SVGURIReference:!1,SVGUseElement:!1,SVGViewElement:!1,SVGViewSpec:!1,SVGVKernElement:!1,SVGZoomAndPan:!1,SVGZoomEvent:!1,Text:!1,TextDecoder:!1,TextEncoder:!1,TextEvent:!1,TextMetrics:!1,TextTrack:!1,TextTrackCue:!1,TextTrackCueList:!1,TextTrackList:!1,TimeEvent:!1,TimeRanges:!1,toolbar:!1,top:!1,Touch:!1,TouchEvent:!1,TouchList:!1,TrackEvent:!1,TransitionEvent:!1,TreeWalker:!1,UIEvent:!1,URL:!1,URLSearchParams:!1,ValidityState:!1,VTTCue:!1,WaveShaperNode:!1,WebGLActiveInfo:!1,WebGLBuffer:!1,WebGLContextEvent:!1,WebGLFramebuffer:!1,WebGLProgram:!1,WebGLRenderbuffer:!1,WebGLRenderingContext:!1,WebGLShader:!1,WebGLShaderPrecisionFormat:!1,WebGLTexture:!1,WebGLUniformLocation:!1,WebSocket:!1,WheelEvent:!1,window:!1,Window:!1,Worker:!1,XDomainRequest:!1,XMLDocument:!1,XMLHttpRequest:!1,XMLHttpRequestEventTarget:!1,XMLHttpRequestProgressEvent:!1,XMLHttpRequestUpload:!1,XMLSerializer:!1,XPathEvaluator:!1,XPathException:!1,XPathExpression:!1,XPathNamespace:!1,XPathNSResolver:!1,XPathResult:!1,XSLTProcessor:!1},worker:{applicationCache:!1,atob:!1,Blob:!1,BroadcastChannel:!1,btoa:!1,Cache:!1,caches:!1,clearInterval:!1,clearTimeout:!1,close:!0,console:!1,fetch:!1,FileReaderSync:!1,FormData:!1,Headers:!1,IDBCursor:!1,IDBCursorWithValue:!1,IDBDatabase:!1,IDBFactory:!1,IDBIndex:!1,IDBKeyRange:!1,IDBObjectStore:!1,IDBOpenDBRequest:!1,IDBRequest:!1,IDBTransaction:!1,IDBVersionChangeEvent:!1,ImageData:!1,importScripts:!0,indexedDB:!1,location:!1,MessageChannel:!1,MessagePort:!1,name:!1,navigator:!1,Notification:!1,onclose:!0,onconnect:!0,onerror:!0,onlanguagechange:!0,onmessage:!0,onoffline:!0,ononline:!0,onrejectionhandled:!0,onunhandledrejection:!0,performance:!1,Performance:!1,PerformanceEntry:!1,PerformanceMark:!1,PerformanceMeasure:!1,PerformanceNavigation:!1,PerformanceResourceTiming:!1,PerformanceTiming:!1,postMessage:!0,Promise:!1,Request:!1,Response:!1,self:!0,ServiceWorkerRegistration:!1,setInterval:!1,setTimeout:!1,TextDecoder:!1,TextEncoder:!1,URL:!1,URLSearchParams:!1,WebSocket:!1,Worker:!1,XMLHttpRequest:!1},node:{__dirname:!1,__filename:!1,arguments:!1,Buffer:!1,clearImmediate:!1,clearInterval:!1,clearTimeout:!1,console:!1,exports:!0,GLOBAL:!1,global:!1,Intl:!1,module:!1,process:!1,require:!1,root:!1,setImmediate:!1,setInterval:!1,setTimeout:!1},commonjs:{exports:!0,module:!1,require:!1,global:!1},amd:{define:!1,require:!1},mocha:{after:!1,afterEach:!1,before:!1,beforeEach:!1,context:!1,describe:!1,it:!1,mocha:!1,run:!1,setup:!1,specify:!1,suite:!1,suiteSetup:!1,suiteTeardown:!1,teardown:!1,test:!1,xcontext:!1,xdescribe:!1,xit:!1,xspecify:!1},jasmine:{afterAll:!1,afterEach:!1,beforeAll:!1,beforeEach:!1,describe:!1,expect:!1,fail:!1,fdescribe:!1,fit:!1,it:!1,jasmine:!1,pending:!1,runs:!1,spyOn:!1,spyOnProperty:!1,waits:!1,waitsFor:!1,xdescribe:!1,xit:!1},jest:{afterAll:!1,afterEach:!1,beforeAll:!1,beforeEach:!1,check:!1,describe:!1,expect:!1,gen:!1,it:!1,fdescribe:!1,fit:!1,jest:!1,pit:!1,require:!1,test:!1,xdescribe:!1,xit:!1,xtest:!1},qunit:{asyncTest:!1,deepEqual:!1,equal:!1,expect:!1,module:!1,notDeepEqual:!1,notEqual:!1,notOk:!1,notPropEqual:!1,notStrictEqual:!1,ok:!1,propEqual:!1,QUnit:!1,raises:!1,start:!1,stop:!1,strictEqual:!1,test:!1,throws:!1},phantomjs:{console:!0,exports:!0,phantom:!0,require:!0,WebPage:!0},couch:{emit:!1,exports:!1,getRow:!1,log:!1,module:!1,provides:!1,require:!1,respond:!1,send:!1,start:!1,sum:!1},rhino:{defineClass:!1,deserialize:!1,gc:!1,help:!1,importClass:!1,importPackage:!1,java:!1,load:!1,loadClass:!1,Packages:!1,print:!1,quit:!1,readFile:!1,readUrl:!1,runCommand:!1,seal:!1,serialize:!1,spawn:!1,sync:!1,toint32:!1,version:!1},nashorn:{__DIR__:!1,__FILE__:!1,__LINE__:!1,com:!1,edu:!1,exit:!1,Java:!1,java:!1,javafx:!1,JavaImporter:!1,javax:!1,JSAdapter:!1,load:!1,loadWithNewGlobal:!1,org:!1,Packages:!1,print:!1,quit:!1},wsh:{ActiveXObject:!0,Enumerator:!0,GetObject:!0,ScriptEngine:!0,ScriptEngineBuildVersion:!0,ScriptEngineMajorVersion:!0,ScriptEngineMinorVersion:!0,VBArray:!0,WScript:!0,WSH:!0,XDomainRequest:!0},jquery:{$:!1,jQuery:!1},yui:{Y:!1,YUI:!1,YUI_config:!1},shelljs:{cat:!1,cd:!1,chmod:!1,config:!1,cp:!1,dirs:!1,echo:!1,env:!1,error:!1,exec:!1,exit:!1,find:!1,grep:!1,ls:!1,ln:!1,mkdir:!1,mv:!1,popd:!1,pushd:!1,pwd:!1,rm:!1,sed:!1,set:!1,target:!1,tempdir:!1,test:!1,touch:!1,which:!1},prototypejs:{$:!1,$$:!1,$A:!1,$break:!1,$continue:!1,$F:!1,$H:!1,$R:!1,$w:!1,Abstract:!1,Ajax:!1,Autocompleter:!1,Builder:!1,Class:!1,Control:!1,Draggable:!1,Draggables:!1,Droppables:!1,Effect:!1,Element:!1,Enumerable:!1,Event:!1,Field:!1,Form:!1,Hash:!1,Insertion:!1,ObjectRange:!1,PeriodicalExecuter:!1,Position:!1,Prototype:!1,Scriptaculous:!1,Selector:!1,Sortable:!1,SortableObserver:!1,Sound:!1,Template:!1,Toggle:!1,Try:!1},meteor:{$:!1,_:!1,Accounts:!1,AccountsClient:!1,AccountsServer:!1,AccountsCommon:!1,App:!1,Assets:!1,Blaze:!1,check:!1,Cordova:!1,DDP:!1,DDPServer:!1,DDPRateLimiter:!1,Deps:!1,EJSON:!1,Email:!1,HTTP:!1,Log:!1,Match:!1,Meteor:!1,Mongo:!1,MongoInternals:!1,Npm:!1,Package:!1,Plugin:!1,process:!1,Random:!1,ReactiveDict:!1,ReactiveVar:!1,Router:!1,ServiceConfiguration:!1,Session:!1,share:!1,Spacebars:!1,Template:!1,Tinytest:!1,Tracker:!1,UI:!1,Utils:!1,WebApp:!1,WebAppInternals:!1},mongo:{_isWindows:!1,_rand:!1,BulkWriteResult:!1,cat:!1,cd:!1,connect:!1,db:!1,getHostName:!1,getMemInfo:!1,hostname:!1,ISODate:!1,listFiles:!1,load:!1,ls:!1,md5sumFile:!1,mkdir:!1,Mongo:!1,NumberInt:!1,NumberLong:!1,ObjectId:!1,PlanCache:!1,print:!1,printjson:!1,pwd:!1,quit:!1,removeFile:!1,rs:!1,sh:!1,UUID:!1,version:!1,WriteResult:!1},applescript:{$:!1,Application:!1,Automation:!1,console:!1,delay:!1,Library:!1,ObjC:!1,ObjectSpecifier:!1,Path:!1,Progress:!1,Ref:!1},serviceworker:{caches:!1,Cache:!1,CacheStorage:!1,Client:!1,clients:!1,Clients:!1,ExtendableEvent:!1,ExtendableMessageEvent:!1,FetchEvent:!1,importScripts:!1,registration:!1,self:!1,ServiceWorker:!1,ServiceWorkerContainer:!1,ServiceWorkerGlobalScope:!1,ServiceWorkerMessageEvent:!1,ServiceWorkerRegistration:!1,skipWaiting:!1,WindowClient:!1},atomtest:{advanceClock:!1,fakeClearInterval:!1,fakeClearTimeout:!1,fakeSetInterval:!1,fakeSetTimeout:!1,resetTimeouts:!1,waitsForPromise:!1},embertest:{andThen:!1,click:!1,currentPath:!1,currentRouteName:!1,currentURL:!1,fillIn:!1,find:!1,findWithAssert:!1,keyEvent:!1,pauseTest:!1,resumeTest:!1,triggerEvent:!1,visit:!1},protractor:{$:!1,$$:!1,browser:!1,By:!1,by:!1,DartObject:!1,element:!1,protractor:!1},"shared-node-browser":{clearInterval:!1,clearTimeout:!1,console:!1,setInterval:!1,setTimeout:!1},webextensions:{browser:!1,chrome:!1,opr:!1},greasemonkey:{GM_addStyle:!1,GM_deleteValue:!1,GM_getResourceText:!1,GM_getResourceURL:!1,GM_getValue:!1,GM_info:!1,GM_listValues:!1,GM_log:!1,GM_openInTab:!1,GM_registerMenuCommand:!1,GM_setClipboard:!1,GM_setValue:!1,GM_xmlhttpRequest:!1,unsafeWindow:!1}}},function(e,t){e.exports={75:8490,83:383,107:8490,115:383,181:924,197:8491,383:83,452:453,453:452,455:456,456:455,458:459,459:458,497:498,498:497,837:8126,914:976,917:1013,920:1012,921:8126,922:1008,924:181,928:982,929:1009,931:962,934:981,937:8486,962:931,976:914,977:1012,981:934,982:928,1008:922,1009:929,1012:[920,977],1013:917,7776:7835,7835:7776,8126:[837,921],8486:937,8490:75,8491:197,66560:66600,66561:66601,66562:66602,66563:66603,66564:66604,66565:66605,66566:66606,66567:66607,66568:66608,66569:66609,66570:66610,66571:66611,66572:66612,66573:66613,66574:66614,66575:66615,66576:66616,66577:66617,66578:66618,66579:66619,66580:66620,66581:66621,66582:66622,66583:66623,66584:66624,66585:66625,66586:66626,66587:66627,66588:66628,66589:66629,66590:66630,66591:66631,66592:66632,66593:66633,66594:66634,66595:66635,66596:66636,66597:66637,66598:66638,66599:66639,66600:66560,66601:66561,66602:66562,66603:66563,66604:66564,66605:66565,66606:66566,66607:66567,66608:66568,66609:66569,66610:66570,66611:66571,66612:66572,66613:66573,66614:66574,66615:66575,66616:66576,66617:66577,66618:66578,66619:66579,66620:66580,66621:66581,66622:66582,66623:66583,66624:66584,66625:66585,66626:66586,66627:66587,66628:66588,66629:66589,66630:66590,66631:66591,66632:66592,66633:66593,66634:66594,66635:66595,66636:66596,66637:66597,66638:66598,66639:66599,68736:68800,68737:68801,68738:68802,68739:68803,68740:68804,68741:68805,68742:68806,68743:68807,68744:68808,68745:68809,68746:68810,68747:68811,68748:68812,68749:68813,68750:68814,68751:68815,68752:68816,68753:68817,68754:68818,68755:68819,68756:68820,68757:68821,68758:68822,68759:68823,68760:68824,68761:68825,68762:68826,68763:68827,68764:68828,68765:68829,68766:68830,68767:68831,68768:68832,68769:68833,68770:68834,68771:68835,68772:68836,68773:68837,68774:68838,68775:68839,68776:68840,68777:68841,68778:68842,68779:68843,68780:68844,68781:68845,68782:68846,68783:68847,68784:68848,68785:68849,68786:68850,68800:68736,68801:68737,68802:68738,68803:68739,68804:68740,68805:68741,68806:68742,68807:68743,68808:68744,68809:68745,68810:68746,68811:68747,68812:68748,68813:68749,68814:68750,68815:68751,68816:68752,68817:68753,68818:68754,68819:68755,68820:68756,68821:68757,68822:68758,68823:68759,68824:68760,68825:68761,68826:68762,68827:68763,68828:68764,68829:68765,68830:68766,68831:68767,68832:68768,68833:68769,68834:68770,68835:68771,68836:68772,68837:68773,68838:68774,68839:68775,68840:68776,68841:68777,68842:68778,68843:68779,68844:68780,68845:68781,68846:68782,68847:68783,68848:68784,68849:68785,68850:68786,71840:71872,71841:71873,71842:71874,71843:71875,71844:71876,71845:71877,71846:71878,71847:71879,71848:71880,71849:71881,71850:71882,71851:71883,71852:71884,71853:71885,71854:71886,71855:71887,71856:71888,71857:71889,71858:71890,71859:71891,71860:71892,71861:71893,71862:71894,71863:71895,71864:71896,71865:71897,71866:71898,71867:71899,71868:71900,71869:71901,71870:71902,71871:71903,71872:71840,71873:71841,71874:71842,71875:71843,71876:71844,71877:71845,71878:71846,71879:71847,71880:71848,71881:71849,71882:71850,71883:71851,71884:71852,71885:71853,71886:71854,71887:71855,71888:71856,71889:71857,71890:71858,71891:71859,71892:71860,71893:71861,71894:71862,71895:71863,71896:71864,71897:71865,71898:71866,71899:71867,71900:71868,71901:71869,71902:71870,71903:71871}}]))}); \ No newline at end of file diff --git a/examples/lib/react-dom.development.js b/examples/lib/react-dom.development.js new file mode 100644 index 00000000..45db5aa3 --- /dev/null +++ b/examples/lib/react-dom.development.js @@ -0,0 +1,26292 @@ +/** @license React v17.0.2 + * react-dom.development.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) : + typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) : + (global = global || self, factory(global.ReactDOM = {}, global.React)); +}(this, (function (exports, React) { 'use strict'; + + var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; + + // by calls to these methods by a Babel plugin. + // + // In PROD (or in packages without access to React internals), + // they are left as they are instead. + + function warn(format) { + { + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + printWarning('warn', format, args); + } + } + function error(format) { + { + for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + args[_key2 - 1] = arguments[_key2]; + } + + printWarning('error', format, args); + } + } + + function printWarning(level, format, args) { + // When changing this logic, you might want to also + // update consoleWithStackDev.www.js as well. + { + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); + + if (stack !== '') { + format += '%s'; + args = args.concat([stack]); + } + + var argsWithFormat = args.map(function (item) { + return '' + item; + }); // Careful: RN currently depends on this prefix + + argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it + // breaks IE9: https://github.com/facebook/react/issues/13610 + // eslint-disable-next-line react-internal/no-production-logging + + Function.prototype.apply.call(console[level], console, argsWithFormat); + } + } + + if (!React) { + { + throw Error( "ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM." ); + } + } + + var FunctionComponent = 0; + var ClassComponent = 1; + var IndeterminateComponent = 2; // Before we know whether it is function or class + + var HostRoot = 3; // Root of a host tree. Could be nested inside another node. + + var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. + + var HostComponent = 5; + var HostText = 6; + var Fragment = 7; + var Mode = 8; + var ContextConsumer = 9; + var ContextProvider = 10; + var ForwardRef = 11; + var Profiler = 12; + var SuspenseComponent = 13; + var MemoComponent = 14; + var SimpleMemoComponent = 15; + var LazyComponent = 16; + var IncompleteClassComponent = 17; + var DehydratedFragment = 18; + var SuspenseListComponent = 19; + var FundamentalComponent = 20; + var ScopeComponent = 21; + var Block = 22; + var OffscreenComponent = 23; + var LegacyHiddenComponent = 24; + + // Filter certain DOM attributes (e.g. src, href) if their values are empty strings. + + var enableProfilerTimer = true; // Record durations for commit and passive effects phases. + + var enableFundamentalAPI = false; // Experimental Scope support. + var enableNewReconciler = false; // Errors that are thrown while unmounting (or after in the case of passive effects) + var warnAboutStringRefs = false; + + var allNativeEvents = new Set(); + /** + * Mapping from registration name to event name + */ + + + var registrationNameDependencies = {}; + /** + * Mapping from lowercase registration names to the properly cased version, + * used to warn in the case of missing event handlers. Available + * only in true. + * @type {Object} + */ + + var possibleRegistrationNames = {} ; // Trust the developer to only use possibleRegistrationNames in true + + function registerTwoPhaseEvent(registrationName, dependencies) { + registerDirectEvent(registrationName, dependencies); + registerDirectEvent(registrationName + 'Capture', dependencies); + } + function registerDirectEvent(registrationName, dependencies) { + { + if (registrationNameDependencies[registrationName]) { + error('EventRegistry: More than one plugin attempted to publish the same ' + 'registration name, `%s`.', registrationName); + } + } + + registrationNameDependencies[registrationName] = dependencies; + + { + var lowerCasedName = registrationName.toLowerCase(); + possibleRegistrationNames[lowerCasedName] = registrationName; + + if (registrationName === 'onDoubleClick') { + possibleRegistrationNames.ondblclick = registrationName; + } + } + + for (var i = 0; i < dependencies.length; i++) { + allNativeEvents.add(dependencies[i]); + } + } + + var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined'); + + // A reserved attribute. + // It is handled by React separately and shouldn't be written to the DOM. + var RESERVED = 0; // A simple string attribute. + // Attributes that aren't in the filter are presumed to have this type. + + var STRING = 1; // A string attribute that accepts booleans in React. In HTML, these are called + // "enumerated" attributes with "true" and "false" as possible values. + // When true, it should be set to a "true" string. + // When false, it should be set to a "false" string. + + var BOOLEANISH_STRING = 2; // A real boolean attribute. + // When true, it should be present (set either to an empty string or its name). + // When false, it should be omitted. + + var BOOLEAN = 3; // An attribute that can be used as a flag as well as with a value. + // When true, it should be present (set either to an empty string or its name). + // When false, it should be omitted. + // For any other value, should be present with that value. + + var OVERLOADED_BOOLEAN = 4; // An attribute that must be numeric or parse as a numeric. + // When falsy, it should be removed. + + var NUMERIC = 5; // An attribute that must be positive numeric or parse as a positive numeric. + // When falsy, it should be removed. + + var POSITIVE_NUMERIC = 6; + + /* eslint-disable max-len */ + var ATTRIBUTE_NAME_START_CHAR = ":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD"; + /* eslint-enable max-len */ + + var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040"; + var ROOT_ATTRIBUTE_NAME = 'data-reactroot'; + var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$'); + var hasOwnProperty = Object.prototype.hasOwnProperty; + var illegalAttributeNameCache = {}; + var validatedAttributeNameCache = {}; + function isAttributeNameSafe(attributeName) { + if (hasOwnProperty.call(validatedAttributeNameCache, attributeName)) { + return true; + } + + if (hasOwnProperty.call(illegalAttributeNameCache, attributeName)) { + return false; + } + + if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) { + validatedAttributeNameCache[attributeName] = true; + return true; + } + + illegalAttributeNameCache[attributeName] = true; + + { + error('Invalid attribute name: `%s`', attributeName); + } + + return false; + } + function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) { + if (propertyInfo !== null) { + return propertyInfo.type === RESERVED; + } + + if (isCustomComponentTag) { + return false; + } + + if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) { + return true; + } + + return false; + } + function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) { + if (propertyInfo !== null && propertyInfo.type === RESERVED) { + return false; + } + + switch (typeof value) { + case 'function': // $FlowIssue symbol is perfectly valid here + + case 'symbol': + // eslint-disable-line + return true; + + case 'boolean': + { + if (isCustomComponentTag) { + return false; + } + + if (propertyInfo !== null) { + return !propertyInfo.acceptsBooleans; + } else { + var prefix = name.toLowerCase().slice(0, 5); + return prefix !== 'data-' && prefix !== 'aria-'; + } + } + + default: + return false; + } + } + function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) { + if (value === null || typeof value === 'undefined') { + return true; + } + + if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) { + return true; + } + + if (isCustomComponentTag) { + return false; + } + + if (propertyInfo !== null) { + + switch (propertyInfo.type) { + case BOOLEAN: + return !value; + + case OVERLOADED_BOOLEAN: + return value === false; + + case NUMERIC: + return isNaN(value); + + case POSITIVE_NUMERIC: + return isNaN(value) || value < 1; + } + } + + return false; + } + function getPropertyInfo(name) { + return properties.hasOwnProperty(name) ? properties[name] : null; + } + + function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL, removeEmptyString) { + this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN; + this.attributeName = attributeName; + this.attributeNamespace = attributeNamespace; + this.mustUseProperty = mustUseProperty; + this.propertyName = name; + this.type = type; + this.sanitizeURL = sanitizeURL; + this.removeEmptyString = removeEmptyString; + } // When adding attributes to this list, be sure to also add them to + // the `possibleStandardNames` module to ensure casing and incorrect + // name warnings. + + + var properties = {}; // These props are reserved by React. They shouldn't be written to the DOM. + + var reservedProps = ['children', 'dangerouslySetInnerHTML', // TODO: This prevents the assignment of defaultValue to regular + // elements (not just inputs). Now that ReactDOMInput assigns to the + // defaultValue property -- do we need this? + 'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style']; + reservedProps.forEach(function (name) { + properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty + name, // attributeName + null, // attributeNamespace + false, // sanitizeURL + false); + }); // A few React string attributes have a different name. + // This is a mapping from React prop names to the attribute names. + + [['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) { + var name = _ref[0], + attributeName = _ref[1]; + properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty + attributeName, // attributeName + null, // attributeNamespace + false, // sanitizeURL + false); + }); // These are "enumerated" HTML attributes that accept "true" and "false". + // In React, we let users pass `true` and `false` even though technically + // these aren't boolean attributes (they are coerced to strings). + + ['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) { + properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty + name.toLowerCase(), // attributeName + null, // attributeNamespace + false, // sanitizeURL + false); + }); // These are "enumerated" SVG attributes that accept "true" and "false". + // In React, we let users pass `true` and `false` even though technically + // these aren't boolean attributes (they are coerced to strings). + // Since these are SVG attributes, their attribute names are case-sensitive. + + ['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) { + properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty + name, // attributeName + null, // attributeNamespace + false, // sanitizeURL + false); + }); // These are HTML boolean attributes. + + ['allowFullScreen', 'async', // Note: there is a special case that prevents it from being written to the DOM + // on the client side because the browsers are inconsistent. Instead we call focus(). + 'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'disableRemotePlayback', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', // Microdata + 'itemScope'].forEach(function (name) { + properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty + name.toLowerCase(), // attributeName + null, // attributeNamespace + false, // sanitizeURL + false); + }); // These are the few React props that we set as DOM properties + // rather than attributes. These are all booleans. + + ['checked', // Note: `option.selected` is not updated if `select.multiple` is + // disabled with `removeAttribute`. We have special logic for handling this. + 'multiple', 'muted', 'selected' // NOTE: if you add a camelCased prop to this list, + // you'll need to set attributeName to name.toLowerCase() + // instead in the assignment below. + ].forEach(function (name) { + properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty + name, // attributeName + null, // attributeNamespace + false, // sanitizeURL + false); + }); // These are HTML attributes that are "overloaded booleans": they behave like + // booleans, but can also accept a string value. + + ['capture', 'download' // NOTE: if you add a camelCased prop to this list, + // you'll need to set attributeName to name.toLowerCase() + // instead in the assignment below. + ].forEach(function (name) { + properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty + name, // attributeName + null, // attributeNamespace + false, // sanitizeURL + false); + }); // These are HTML attributes that must be positive numbers. + + ['cols', 'rows', 'size', 'span' // NOTE: if you add a camelCased prop to this list, + // you'll need to set attributeName to name.toLowerCase() + // instead in the assignment below. + ].forEach(function (name) { + properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty + name, // attributeName + null, // attributeNamespace + false, // sanitizeURL + false); + }); // These are HTML attributes that must be numbers. + + ['rowSpan', 'start'].forEach(function (name) { + properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty + name.toLowerCase(), // attributeName + null, // attributeNamespace + false, // sanitizeURL + false); + }); + var CAMELIZE = /[\-\:]([a-z])/g; + + var capitalize = function (token) { + return token[1].toUpperCase(); + }; // This is a list of all SVG attributes that need special casing, namespacing, + // or boolean value assignment. Regular attributes that just accept strings + // and have the same names are omitted, just like in the HTML attribute filter. + // Some of these attributes can be hard to find. This list was created by + // scraping the MDN documentation. + + + ['accent-height', 'alignment-baseline', 'arabic-form', 'baseline-shift', 'cap-height', 'clip-path', 'clip-rule', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'dominant-baseline', 'enable-background', 'fill-opacity', 'fill-rule', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-name', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'horiz-adv-x', 'horiz-origin-x', 'image-rendering', 'letter-spacing', 'lighting-color', 'marker-end', 'marker-mid', 'marker-start', 'overline-position', 'overline-thickness', 'paint-order', 'panose-1', 'pointer-events', 'rendering-intent', 'shape-rendering', 'stop-color', 'stop-opacity', 'strikethrough-position', 'strikethrough-thickness', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-decoration', 'text-rendering', 'underline-position', 'underline-thickness', 'unicode-bidi', 'unicode-range', 'units-per-em', 'v-alphabetic', 'v-hanging', 'v-ideographic', 'v-mathematical', 'vector-effect', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'word-spacing', 'writing-mode', 'xmlns:xlink', 'x-height' // NOTE: if you add a camelCased prop to this list, + // you'll need to set attributeName to name.toLowerCase() + // instead in the assignment below. + ].forEach(function (attributeName) { + var name = attributeName.replace(CAMELIZE, capitalize); + properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty + attributeName, null, // attributeNamespace + false, // sanitizeURL + false); + }); // String SVG attributes with the xlink namespace. + + ['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type' // NOTE: if you add a camelCased prop to this list, + // you'll need to set attributeName to name.toLowerCase() + // instead in the assignment below. + ].forEach(function (attributeName) { + var name = attributeName.replace(CAMELIZE, capitalize); + properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty + attributeName, 'http://www.w3.org/1999/xlink', false, // sanitizeURL + false); + }); // String SVG attributes with the xml namespace. + + ['xml:base', 'xml:lang', 'xml:space' // NOTE: if you add a camelCased prop to this list, + // you'll need to set attributeName to name.toLowerCase() + // instead in the assignment below. + ].forEach(function (attributeName) { + var name = attributeName.replace(CAMELIZE, capitalize); + properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty + attributeName, 'http://www.w3.org/XML/1998/namespace', false, // sanitizeURL + false); + }); // These attribute exists both in HTML and SVG. + // The attribute name is case-sensitive in SVG so we can't just use + // the React name like we do for attributes that exist only in HTML. + + ['tabIndex', 'crossOrigin'].forEach(function (attributeName) { + properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty + attributeName.toLowerCase(), // attributeName + null, // attributeNamespace + false, // sanitizeURL + false); + }); // These attributes accept URLs. These must not allow javascript: URLS. + // These will also need to accept Trusted Types object in the future. + + var xlinkHref = 'xlinkHref'; + properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty + 'xlink:href', 'http://www.w3.org/1999/xlink', true, // sanitizeURL + false); + ['src', 'href', 'action', 'formAction'].forEach(function (attributeName) { + properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty + attributeName.toLowerCase(), // attributeName + null, // attributeNamespace + true, // sanitizeURL + true); + }); + + // and any newline or tab are filtered out as if they're not part of the URL. + // https://url.spec.whatwg.org/#url-parsing + // Tab or newline are defined as \r\n\t: + // https://infra.spec.whatwg.org/#ascii-tab-or-newline + // A C0 control is a code point in the range \u0000 NULL to \u001F + // INFORMATION SEPARATOR ONE, inclusive: + // https://infra.spec.whatwg.org/#c0-control-or-space + + /* eslint-disable max-len */ + + var isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i; + var didWarn = false; + + function sanitizeURL(url) { + { + if (!didWarn && isJavaScriptProtocol.test(url)) { + didWarn = true; + + error('A future version of React will block javascript: URLs as a security precaution. ' + 'Use event handlers instead if you can. If you need to generate unsafe HTML try ' + 'using dangerouslySetInnerHTML instead. React was passed %s.', JSON.stringify(url)); + } + } + } + + /** + * Get the value for a property on a node. Only used in DEV for SSR validation. + * The "expected" argument is used as a hint of what the expected value is. + * Some properties have multiple equivalent values. + */ + function getValueForProperty(node, name, expected, propertyInfo) { + { + if (propertyInfo.mustUseProperty) { + var propertyName = propertyInfo.propertyName; + return node[propertyName]; + } else { + if ( propertyInfo.sanitizeURL) { + // If we haven't fully disabled javascript: URLs, and if + // the hydration is successful of a javascript: URL, we + // still want to warn on the client. + sanitizeURL('' + expected); + } + + var attributeName = propertyInfo.attributeName; + var stringValue = null; + + if (propertyInfo.type === OVERLOADED_BOOLEAN) { + if (node.hasAttribute(attributeName)) { + var value = node.getAttribute(attributeName); + + if (value === '') { + return true; + } + + if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { + return value; + } + + if (value === '' + expected) { + return expected; + } + + return value; + } + } else if (node.hasAttribute(attributeName)) { + if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { + // We had an attribute but shouldn't have had one, so read it + // for the error message. + return node.getAttribute(attributeName); + } + + if (propertyInfo.type === BOOLEAN) { + // If this was a boolean, it doesn't matter what the value is + // the fact that we have it is the same as the expected. + return expected; + } // Even if this property uses a namespace we use getAttribute + // because we assume its namespaced name is the same as our config. + // To use getAttributeNS we need the local name which we don't have + // in our config atm. + + + stringValue = node.getAttribute(attributeName); + } + + if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { + return stringValue === null ? expected : stringValue; + } else if (stringValue === '' + expected) { + return expected; + } else { + return stringValue; + } + } + } + } + /** + * Get the value for a attribute on a node. Only used in DEV for SSR validation. + * The third argument is used as a hint of what the expected value is. Some + * attributes have multiple equivalent values. + */ + + function getValueForAttribute(node, name, expected) { + { + if (!isAttributeNameSafe(name)) { + return; + } // If the object is an opaque reference ID, it's expected that + // the next prop is different than the server value, so just return + // expected + + + if (isOpaqueHydratingObject(expected)) { + return expected; + } + + if (!node.hasAttribute(name)) { + return expected === undefined ? undefined : null; + } + + var value = node.getAttribute(name); + + if (value === '' + expected) { + return expected; + } + + return value; + } + } + /** + * Sets the value for a property on a node. + * + * @param {DOMElement} node + * @param {string} name + * @param {*} value + */ + + function setValueForProperty(node, name, value, isCustomComponentTag) { + var propertyInfo = getPropertyInfo(name); + + if (shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag)) { + return; + } + + if (shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)) { + value = null; + } // If the prop isn't in the special list, treat it as a simple attribute. + + + if (isCustomComponentTag || propertyInfo === null) { + if (isAttributeNameSafe(name)) { + var _attributeName = name; + + if (value === null) { + node.removeAttribute(_attributeName); + } else { + node.setAttribute(_attributeName, '' + value); + } + } + + return; + } + + var mustUseProperty = propertyInfo.mustUseProperty; + + if (mustUseProperty) { + var propertyName = propertyInfo.propertyName; + + if (value === null) { + var type = propertyInfo.type; + node[propertyName] = type === BOOLEAN ? false : ''; + } else { + // Contrary to `setAttribute`, object properties are properly + // `toString`ed by IE8/9. + node[propertyName] = value; + } + + return; + } // The rest are treated as attributes with special cases. + + + var attributeName = propertyInfo.attributeName, + attributeNamespace = propertyInfo.attributeNamespace; + + if (value === null) { + node.removeAttribute(attributeName); + } else { + var _type = propertyInfo.type; + var attributeValue; + + if (_type === BOOLEAN || _type === OVERLOADED_BOOLEAN && value === true) { + // If attribute type is boolean, we know for sure it won't be an execution sink + // and we won't require Trusted Type here. + attributeValue = ''; + } else { + // `setAttribute` with objects becomes only `[object]` in IE8/9, + // ('' + value) makes it output the correct toString()-value. + { + attributeValue = '' + value; + } + + if (propertyInfo.sanitizeURL) { + sanitizeURL(attributeValue.toString()); + } + } + + if (attributeNamespace) { + node.setAttributeNS(attributeNamespace, attributeName, attributeValue); + } else { + node.setAttribute(attributeName, attributeValue); + } + } + } + + var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; + var _assign = ReactInternals.assign; + + // ATTENTION + // When adding new symbols to this file, + // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' + // The Symbol used to tag the ReactElement-like types. If there is no native Symbol + // nor polyfill, then a plain number is used for performance. + var REACT_ELEMENT_TYPE = 0xeac7; + var REACT_PORTAL_TYPE = 0xeaca; + var REACT_FRAGMENT_TYPE = 0xeacb; + var REACT_STRICT_MODE_TYPE = 0xeacc; + var REACT_PROFILER_TYPE = 0xead2; + var REACT_PROVIDER_TYPE = 0xeacd; + var REACT_CONTEXT_TYPE = 0xeace; + var REACT_FORWARD_REF_TYPE = 0xead0; + var REACT_SUSPENSE_TYPE = 0xead1; + var REACT_SUSPENSE_LIST_TYPE = 0xead8; + var REACT_MEMO_TYPE = 0xead3; + var REACT_LAZY_TYPE = 0xead4; + var REACT_BLOCK_TYPE = 0xead9; + var REACT_SERVER_BLOCK_TYPE = 0xeada; + var REACT_FUNDAMENTAL_TYPE = 0xead5; + var REACT_SCOPE_TYPE = 0xead7; + var REACT_OPAQUE_ID_TYPE = 0xeae0; + var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1; + var REACT_OFFSCREEN_TYPE = 0xeae2; + var REACT_LEGACY_HIDDEN_TYPE = 0xeae3; + + if (typeof Symbol === 'function' && Symbol.for) { + var symbolFor = Symbol.for; + REACT_ELEMENT_TYPE = symbolFor('react.element'); + REACT_PORTAL_TYPE = symbolFor('react.portal'); + REACT_FRAGMENT_TYPE = symbolFor('react.fragment'); + REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode'); + REACT_PROFILER_TYPE = symbolFor('react.profiler'); + REACT_PROVIDER_TYPE = symbolFor('react.provider'); + REACT_CONTEXT_TYPE = symbolFor('react.context'); + REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref'); + REACT_SUSPENSE_TYPE = symbolFor('react.suspense'); + REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list'); + REACT_MEMO_TYPE = symbolFor('react.memo'); + REACT_LAZY_TYPE = symbolFor('react.lazy'); + REACT_BLOCK_TYPE = symbolFor('react.block'); + REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block'); + REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental'); + REACT_SCOPE_TYPE = symbolFor('react.scope'); + REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id'); + REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode'); + REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen'); + REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden'); + } + + var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; + var FAUX_ITERATOR_SYMBOL = '@@iterator'; + function getIteratorFn(maybeIterable) { + if (maybeIterable === null || typeof maybeIterable !== 'object') { + return null; + } + + var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; + + if (typeof maybeIterator === 'function') { + return maybeIterator; + } + + return null; + } + + // Helpers to patch console.logs to avoid logging during side-effect free + // replaying on render function. This currently only patches the object + // lazily which won't cover if the log function was extracted eagerly. + // We could also eagerly patch the method. + var disabledDepth = 0; + var prevLog; + var prevInfo; + var prevWarn; + var prevError; + var prevGroup; + var prevGroupCollapsed; + var prevGroupEnd; + + function disabledLog() {} + + disabledLog.__reactDisabledLog = true; + function disableLogs() { + { + if (disabledDepth === 0) { + /* eslint-disable react-internal/no-production-logging */ + prevLog = console.log; + prevInfo = console.info; + prevWarn = console.warn; + prevError = console.error; + prevGroup = console.group; + prevGroupCollapsed = console.groupCollapsed; + prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 + + var props = { + configurable: true, + enumerable: true, + value: disabledLog, + writable: true + }; // $FlowFixMe Flow thinks console is immutable. + + Object.defineProperties(console, { + info: props, + log: props, + warn: props, + error: props, + group: props, + groupCollapsed: props, + groupEnd: props + }); + /* eslint-enable react-internal/no-production-logging */ + } + + disabledDepth++; + } + } + function reenableLogs() { + { + disabledDepth--; + + if (disabledDepth === 0) { + /* eslint-disable react-internal/no-production-logging */ + var props = { + configurable: true, + enumerable: true, + writable: true + }; // $FlowFixMe Flow thinks console is immutable. + + Object.defineProperties(console, { + log: _assign({}, props, { + value: prevLog + }), + info: _assign({}, props, { + value: prevInfo + }), + warn: _assign({}, props, { + value: prevWarn + }), + error: _assign({}, props, { + value: prevError + }), + group: _assign({}, props, { + value: prevGroup + }), + groupCollapsed: _assign({}, props, { + value: prevGroupCollapsed + }), + groupEnd: _assign({}, props, { + value: prevGroupEnd + }) + }); + /* eslint-enable react-internal/no-production-logging */ + } + + if (disabledDepth < 0) { + error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.'); + } + } + } + + var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; + var prefix; + function describeBuiltInComponentFrame(name, source, ownerFn) { + { + if (prefix === undefined) { + // Extract the VM specific prefix used by each line. + try { + throw Error(); + } catch (x) { + var match = x.stack.trim().match(/\n( *(at )?)/); + prefix = match && match[1] || ''; + } + } // We use the prefix to ensure our stacks line up with native stack frames. + + + return '\n' + prefix + name; + } + } + var reentry = false; + var componentFrameCache; + + { + var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map; + componentFrameCache = new PossiblyWeakMap(); + } + + function describeNativeComponentFrame(fn, construct) { + // If something asked for a stack inside a fake render, it should get ignored. + if (!fn || reentry) { + return ''; + } + + { + var frame = componentFrameCache.get(fn); + + if (frame !== undefined) { + return frame; + } + } + + var control; + reentry = true; + var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined. + + Error.prepareStackTrace = undefined; + var previousDispatcher; + + { + previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function + // for warnings. + + ReactCurrentDispatcher.current = null; + disableLogs(); + } + + try { + // This should throw. + if (construct) { + // Something should be setting the props in the constructor. + var Fake = function () { + throw Error(); + }; // $FlowFixMe + + + Object.defineProperty(Fake.prototype, 'props', { + set: function () { + // We use a throwing setter instead of frozen or non-writable props + // because that won't throw in a non-strict mode function. + throw Error(); + } + }); + + if (typeof Reflect === 'object' && Reflect.construct) { + // We construct a different control for this case to include any extra + // frames added by the construct call. + try { + Reflect.construct(Fake, []); + } catch (x) { + control = x; + } + + Reflect.construct(fn, [], Fake); + } else { + try { + Fake.call(); + } catch (x) { + control = x; + } + + fn.call(Fake.prototype); + } + } else { + try { + throw Error(); + } catch (x) { + control = x; + } + + fn(); + } + } catch (sample) { + // This is inlined manually because closure doesn't do it for us. + if (sample && control && typeof sample.stack === 'string') { + // This extracts the first frame from the sample that isn't also in the control. + // Skipping one frame that we assume is the frame that calls the two. + var sampleLines = sample.stack.split('\n'); + var controlLines = control.stack.split('\n'); + var s = sampleLines.length - 1; + var c = controlLines.length - 1; + + while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) { + // We expect at least one stack frame to be shared. + // Typically this will be the root most one. However, stack frames may be + // cut off due to maximum stack limits. In this case, one maybe cut off + // earlier than the other. We assume that the sample is longer or the same + // and there for cut off earlier. So we should find the root most frame in + // the sample somewhere in the control. + c--; + } + + for (; s >= 1 && c >= 0; s--, c--) { + // Next we find the first one that isn't the same which should be the + // frame that called our sample function and the control. + if (sampleLines[s] !== controlLines[c]) { + // In V8, the first line is describing the message but other VMs don't. + // If we're about to return the first line, and the control is also on the same + // line, that's a pretty good indicator that our sample threw at same line as + // the control. I.e. before we entered the sample frame. So we ignore this result. + // This can happen if you passed a class to function component, or non-function. + if (s !== 1 || c !== 1) { + do { + s--; + c--; // We may still have similar intermediate frames from the construct call. + // The next one that isn't the same should be our match though. + + if (c < 0 || sampleLines[s] !== controlLines[c]) { + // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier. + var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); + + { + if (typeof fn === 'function') { + componentFrameCache.set(fn, _frame); + } + } // Return the line we found. + + + return _frame; + } + } while (s >= 1 && c >= 0); + } + + break; + } + } + } + } finally { + reentry = false; + + { + ReactCurrentDispatcher.current = previousDispatcher; + reenableLogs(); + } + + Error.prepareStackTrace = previousPrepareStackTrace; + } // Fallback to just using the name if we couldn't make it throw. + + + var name = fn ? fn.displayName || fn.name : ''; + var syntheticFrame = name ? describeBuiltInComponentFrame(name) : ''; + + { + if (typeof fn === 'function') { + componentFrameCache.set(fn, syntheticFrame); + } + } + + return syntheticFrame; + } + + function describeClassComponentFrame(ctor, source, ownerFn) { + { + return describeNativeComponentFrame(ctor, true); + } + } + function describeFunctionComponentFrame(fn, source, ownerFn) { + { + return describeNativeComponentFrame(fn, false); + } + } + + function shouldConstruct(Component) { + var prototype = Component.prototype; + return !!(prototype && prototype.isReactComponent); + } + + function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) { + + if (type == null) { + return ''; + } + + if (typeof type === 'function') { + { + return describeNativeComponentFrame(type, shouldConstruct(type)); + } + } + + if (typeof type === 'string') { + return describeBuiltInComponentFrame(type); + } + + switch (type) { + case REACT_SUSPENSE_TYPE: + return describeBuiltInComponentFrame('Suspense'); + + case REACT_SUSPENSE_LIST_TYPE: + return describeBuiltInComponentFrame('SuspenseList'); + } + + if (typeof type === 'object') { + switch (type.$$typeof) { + case REACT_FORWARD_REF_TYPE: + return describeFunctionComponentFrame(type.render); + + case REACT_MEMO_TYPE: + // Memo may contain any component type so we recursively resolve it. + return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn); + + case REACT_BLOCK_TYPE: + return describeFunctionComponentFrame(type._render); + + case REACT_LAZY_TYPE: + { + var lazyComponent = type; + var payload = lazyComponent._payload; + var init = lazyComponent._init; + + try { + // Lazy may contain any component type so we recursively resolve it. + return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn); + } catch (x) {} + } + } + } + + return ''; + } + + function describeFiber(fiber) { + var owner = fiber._debugOwner ? fiber._debugOwner.type : null ; + var source = fiber._debugSource ; + + switch (fiber.tag) { + case HostComponent: + return describeBuiltInComponentFrame(fiber.type); + + case LazyComponent: + return describeBuiltInComponentFrame('Lazy'); + + case SuspenseComponent: + return describeBuiltInComponentFrame('Suspense'); + + case SuspenseListComponent: + return describeBuiltInComponentFrame('SuspenseList'); + + case FunctionComponent: + case IndeterminateComponent: + case SimpleMemoComponent: + return describeFunctionComponentFrame(fiber.type); + + case ForwardRef: + return describeFunctionComponentFrame(fiber.type.render); + + case Block: + return describeFunctionComponentFrame(fiber.type._render); + + case ClassComponent: + return describeClassComponentFrame(fiber.type); + + default: + return ''; + } + } + + function getStackByFiberInDevAndProd(workInProgress) { + try { + var info = ''; + var node = workInProgress; + + do { + info += describeFiber(node); + node = node.return; + } while (node); + + return info; + } catch (x) { + return '\nError generating stack: ' + x.message + '\n' + x.stack; + } + } + + function getWrappedName(outerType, innerType, wrapperName) { + var functionName = innerType.displayName || innerType.name || ''; + return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName); + } + + function getContextName(type) { + return type.displayName || 'Context'; + } + + function getComponentName(type) { + if (type == null) { + // Host root, text node or just invalid type. + return null; + } + + { + if (typeof type.tag === 'number') { + error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.'); + } + } + + if (typeof type === 'function') { + return type.displayName || type.name || null; + } + + if (typeof type === 'string') { + return type; + } + + switch (type) { + case REACT_FRAGMENT_TYPE: + return 'Fragment'; + + case REACT_PORTAL_TYPE: + return 'Portal'; + + case REACT_PROFILER_TYPE: + return 'Profiler'; + + case REACT_STRICT_MODE_TYPE: + return 'StrictMode'; + + case REACT_SUSPENSE_TYPE: + return 'Suspense'; + + case REACT_SUSPENSE_LIST_TYPE: + return 'SuspenseList'; + } + + if (typeof type === 'object') { + switch (type.$$typeof) { + case REACT_CONTEXT_TYPE: + var context = type; + return getContextName(context) + '.Consumer'; + + case REACT_PROVIDER_TYPE: + var provider = type; + return getContextName(provider._context) + '.Provider'; + + case REACT_FORWARD_REF_TYPE: + return getWrappedName(type, type.render, 'ForwardRef'); + + case REACT_MEMO_TYPE: + return getComponentName(type.type); + + case REACT_BLOCK_TYPE: + return getComponentName(type._render); + + case REACT_LAZY_TYPE: + { + var lazyComponent = type; + var payload = lazyComponent._payload; + var init = lazyComponent._init; + + try { + return getComponentName(init(payload)); + } catch (x) { + return null; + } + } + } + } + + return null; + } + + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + var current = null; + var isRendering = false; + function getCurrentFiberOwnerNameInDevOrNull() { + { + if (current === null) { + return null; + } + + var owner = current._debugOwner; + + if (owner !== null && typeof owner !== 'undefined') { + return getComponentName(owner.type); + } + } + + return null; + } + + function getCurrentFiberStackInDev() { + { + if (current === null) { + return ''; + } // Safe because if current fiber exists, we are reconciling, + // and it is guaranteed to be the work-in-progress version. + + + return getStackByFiberInDevAndProd(current); + } + } + + function resetCurrentFiber() { + { + ReactDebugCurrentFrame.getCurrentStack = null; + current = null; + isRendering = false; + } + } + function setCurrentFiber(fiber) { + { + ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev; + current = fiber; + isRendering = false; + } + } + function setIsRendering(rendering) { + { + isRendering = rendering; + } + } + function getIsRendering() { + { + return isRendering; + } + } + + // Flow does not allow string concatenation of most non-string types. To work + // around this limitation, we use an opaque type that can only be obtained by + // passing the value through getToStringValue first. + function toString(value) { + return '' + value; + } + function getToStringValue(value) { + switch (typeof value) { + case 'boolean': + case 'number': + case 'object': + case 'string': + case 'undefined': + return value; + + default: + // function, symbol are assigned as empty strings + return ''; + } + } + + var hasReadOnlyValue = { + button: true, + checkbox: true, + image: true, + hidden: true, + radio: true, + reset: true, + submit: true + }; + function checkControlledValueProps(tagName, props) { + { + if (!(hasReadOnlyValue[props.type] || props.onChange || props.onInput || props.readOnly || props.disabled || props.value == null)) { + error('You provided a `value` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultValue`. Otherwise, ' + 'set either `onChange` or `readOnly`.'); + } + + if (!(props.onChange || props.readOnly || props.disabled || props.checked == null)) { + error('You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + 'set either `onChange` or `readOnly`.'); + } + } + } + + function isCheckable(elem) { + var type = elem.type; + var nodeName = elem.nodeName; + return nodeName && nodeName.toLowerCase() === 'input' && (type === 'checkbox' || type === 'radio'); + } + + function getTracker(node) { + return node._valueTracker; + } + + function detachTracker(node) { + node._valueTracker = null; + } + + function getValueFromNode(node) { + var value = ''; + + if (!node) { + return value; + } + + if (isCheckable(node)) { + value = node.checked ? 'true' : 'false'; + } else { + value = node.value; + } + + return value; + } + + function trackValueOnNode(node) { + var valueField = isCheckable(node) ? 'checked' : 'value'; + var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField); + var currentValue = '' + node[valueField]; // if someone has already defined a value or Safari, then bail + // and don't track value will cause over reporting of changes, + // but it's better then a hard failure + // (needed for certain tests that spyOn input values and Safari) + + if (node.hasOwnProperty(valueField) || typeof descriptor === 'undefined' || typeof descriptor.get !== 'function' || typeof descriptor.set !== 'function') { + return; + } + + var get = descriptor.get, + set = descriptor.set; + Object.defineProperty(node, valueField, { + configurable: true, + get: function () { + return get.call(this); + }, + set: function (value) { + currentValue = '' + value; + set.call(this, value); + } + }); // We could've passed this the first time + // but it triggers a bug in IE11 and Edge 14/15. + // Calling defineProperty() again should be equivalent. + // https://github.com/facebook/react/issues/11768 + + Object.defineProperty(node, valueField, { + enumerable: descriptor.enumerable + }); + var tracker = { + getValue: function () { + return currentValue; + }, + setValue: function (value) { + currentValue = '' + value; + }, + stopTracking: function () { + detachTracker(node); + delete node[valueField]; + } + }; + return tracker; + } + + function track(node) { + if (getTracker(node)) { + return; + } // TODO: Once it's just Fiber we can move this to node._wrapperState + + + node._valueTracker = trackValueOnNode(node); + } + function updateValueIfChanged(node) { + if (!node) { + return false; + } + + var tracker = getTracker(node); // if there is no tracker at this point it's unlikely + // that trying again will succeed + + if (!tracker) { + return true; + } + + var lastValue = tracker.getValue(); + var nextValue = getValueFromNode(node); + + if (nextValue !== lastValue) { + tracker.setValue(nextValue); + return true; + } + + return false; + } + + function getActiveElement(doc) { + doc = doc || (typeof document !== 'undefined' ? document : undefined); + + if (typeof doc === 'undefined') { + return null; + } + + try { + return doc.activeElement || doc.body; + } catch (e) { + return doc.body; + } + } + + var didWarnValueDefaultValue = false; + var didWarnCheckedDefaultChecked = false; + var didWarnControlledToUncontrolled = false; + var didWarnUncontrolledToControlled = false; + + function isControlled(props) { + var usesChecked = props.type === 'checkbox' || props.type === 'radio'; + return usesChecked ? props.checked != null : props.value != null; + } + /** + * Implements an <input> host component that allows setting these optional + * props: `checked`, `value`, `defaultChecked`, and `defaultValue`. + * + * If `checked` or `value` are not supplied (or null/undefined), user actions + * that affect the checked state or value will trigger updates to the element. + * + * If they are supplied (and not null/undefined), the rendered element will not + * trigger updates to the element. Instead, the props must change in order for + * the rendered element to be updated. + * + * The rendered element will be initialized as unchecked (or `defaultChecked`) + * with an empty value (or `defaultValue`). + * + * See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html + */ + + + function getHostProps(element, props) { + var node = element; + var checked = props.checked; + + var hostProps = _assign({}, props, { + defaultChecked: undefined, + defaultValue: undefined, + value: undefined, + checked: checked != null ? checked : node._wrapperState.initialChecked + }); + + return hostProps; + } + function initWrapperState(element, props) { + { + checkControlledValueProps('input', props); + + if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) { + error('%s contains an input of type %s with both checked and defaultChecked props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the checked prop, or the defaultChecked prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://reactjs.org/link/controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type); + + didWarnCheckedDefaultChecked = true; + } + + if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) { + error('%s contains an input of type %s with both value and defaultValue props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://reactjs.org/link/controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type); + + didWarnValueDefaultValue = true; + } + } + + var node = element; + var defaultValue = props.defaultValue == null ? '' : props.defaultValue; + node._wrapperState = { + initialChecked: props.checked != null ? props.checked : props.defaultChecked, + initialValue: getToStringValue(props.value != null ? props.value : defaultValue), + controlled: isControlled(props) + }; + } + function updateChecked(element, props) { + var node = element; + var checked = props.checked; + + if (checked != null) { + setValueForProperty(node, 'checked', checked, false); + } + } + function updateWrapper(element, props) { + var node = element; + + { + var controlled = isControlled(props); + + if (!node._wrapperState.controlled && controlled && !didWarnUncontrolledToControlled) { + error('A component is changing an uncontrolled input to be controlled. ' + 'This is likely caused by the value changing from undefined to ' + 'a defined value, which should not happen. ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components'); + + didWarnUncontrolledToControlled = true; + } + + if (node._wrapperState.controlled && !controlled && !didWarnControlledToUncontrolled) { + error('A component is changing a controlled input to be uncontrolled. ' + 'This is likely caused by the value changing from a defined to ' + 'undefined, which should not happen. ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components'); + + didWarnControlledToUncontrolled = true; + } + } + + updateChecked(element, props); + var value = getToStringValue(props.value); + var type = props.type; + + if (value != null) { + if (type === 'number') { + if (value === 0 && node.value === '' || // We explicitly want to coerce to number here if possible. + // eslint-disable-next-line + node.value != value) { + node.value = toString(value); + } + } else if (node.value !== toString(value)) { + node.value = toString(value); + } + } else if (type === 'submit' || type === 'reset') { + // Submit/reset inputs need the attribute removed completely to avoid + // blank-text buttons. + node.removeAttribute('value'); + return; + } + + { + // When syncing the value attribute, the value comes from a cascade of + // properties: + // 1. The value React property + // 2. The defaultValue React property + // 3. Otherwise there should be no change + if (props.hasOwnProperty('value')) { + setDefaultValue(node, props.type, value); + } else if (props.hasOwnProperty('defaultValue')) { + setDefaultValue(node, props.type, getToStringValue(props.defaultValue)); + } + } + + { + // When syncing the checked attribute, it only changes when it needs + // to be removed, such as transitioning from a checkbox into a text input + if (props.checked == null && props.defaultChecked != null) { + node.defaultChecked = !!props.defaultChecked; + } + } + } + function postMountWrapper(element, props, isHydrating) { + var node = element; // Do not assign value if it is already set. This prevents user text input + // from being lost during SSR hydration. + + if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) { + var type = props.type; + var isButton = type === 'submit' || type === 'reset'; // Avoid setting value attribute on submit/reset inputs as it overrides the + // default value provided by the browser. See: #12872 + + if (isButton && (props.value === undefined || props.value === null)) { + return; + } + + var initialValue = toString(node._wrapperState.initialValue); // Do not assign value if it is already set. This prevents user text input + // from being lost during SSR hydration. + + if (!isHydrating) { + { + // When syncing the value attribute, the value property should use + // the wrapperState._initialValue property. This uses: + // + // 1. The value React property when present + // 2. The defaultValue React property when present + // 3. An empty string + if (initialValue !== node.value) { + node.value = initialValue; + } + } + } + + { + // Otherwise, the value attribute is synchronized to the property, + // so we assign defaultValue to the same thing as the value property + // assignment step above. + node.defaultValue = initialValue; + } + } // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug + // this is needed to work around a chrome bug where setting defaultChecked + // will sometimes influence the value of checked (even after detachment). + // Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416 + // We need to temporarily unset name to avoid disrupting radio button groups. + + + var name = node.name; + + if (name !== '') { + node.name = ''; + } + + { + // When syncing the checked attribute, both the checked property and + // attribute are assigned at the same time using defaultChecked. This uses: + // + // 1. The checked React property when present + // 2. The defaultChecked React property when present + // 3. Otherwise, false + node.defaultChecked = !node.defaultChecked; + node.defaultChecked = !!node._wrapperState.initialChecked; + } + + if (name !== '') { + node.name = name; + } + } + function restoreControlledState(element, props) { + var node = element; + updateWrapper(node, props); + updateNamedCousins(node, props); + } + + function updateNamedCousins(rootNode, props) { + var name = props.name; + + if (props.type === 'radio' && name != null) { + var queryRoot = rootNode; + + while (queryRoot.parentNode) { + queryRoot = queryRoot.parentNode; + } // If `rootNode.form` was non-null, then we could try `form.elements`, + // but that sometimes behaves strangely in IE8. We could also try using + // `form.getElementsByName`, but that will only return direct children + // and won't include inputs that use the HTML5 `form=` attribute. Since + // the input might not even be in a form. It might not even be in the + // document. Let's just use the local `querySelectorAll` to ensure we don't + // miss anything. + + + var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]'); + + for (var i = 0; i < group.length; i++) { + var otherNode = group[i]; + + if (otherNode === rootNode || otherNode.form !== rootNode.form) { + continue; + } // This will throw if radio buttons rendered by different copies of React + // and the same name are rendered into the same form (same as #1939). + // That's probably okay; we don't support it just as we don't support + // mixing React radio buttons with non-React ones. + + + var otherProps = getFiberCurrentPropsFromNode(otherNode); + + if (!otherProps) { + { + throw Error( "ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported." ); + } + } // We need update the tracked value on the named cousin since the value + // was changed but the input saw no event or value set + + + updateValueIfChanged(otherNode); // If this is a controlled radio button group, forcing the input that + // was previously checked to update will cause it to be come re-checked + // as appropriate. + + updateWrapper(otherNode, otherProps); + } + } + } // In Chrome, assigning defaultValue to certain input types triggers input validation. + // For number inputs, the display value loses trailing decimal points. For email inputs, + // Chrome raises "The specified value <x> is not a valid email address". + // + // Here we check to see if the defaultValue has actually changed, avoiding these problems + // when the user is inputting text + // + // https://github.com/facebook/react/issues/7253 + + + function setDefaultValue(node, type, value) { + if ( // Focused number inputs synchronize on blur. See ChangeEventPlugin.js + type !== 'number' || getActiveElement(node.ownerDocument) !== node) { + if (value == null) { + node.defaultValue = toString(node._wrapperState.initialValue); + } else if (node.defaultValue !== toString(value)) { + node.defaultValue = toString(value); + } + } + } + + var didWarnSelectedSetOnOption = false; + var didWarnInvalidChild = false; + + function flattenChildren(children) { + var content = ''; // Flatten children. We'll warn if they are invalid + // during validateProps() which runs for hydration too. + // Note that this would throw on non-element objects. + // Elements are stringified (which is normally irrelevant + // but matters for <fbt>). + + React.Children.forEach(children, function (child) { + if (child == null) { + return; + } + + content += child; // Note: we don't warn about invalid children here. + // Instead, this is done separately below so that + // it happens during the hydration code path too. + }); + return content; + } + /** + * Implements an <option> host component that warns when `selected` is set. + */ + + + function validateProps(element, props) { + { + // This mirrors the code path above, but runs for hydration too. + // Warn about invalid children here so that client and hydration are consistent. + // TODO: this seems like it could cause a DEV-only throw for hydration + // if children contains a non-element object. We should try to avoid that. + if (typeof props.children === 'object' && props.children !== null) { + React.Children.forEach(props.children, function (child) { + if (child == null) { + return; + } + + if (typeof child === 'string' || typeof child === 'number') { + return; + } + + if (typeof child.type !== 'string') { + return; + } + + if (!didWarnInvalidChild) { + didWarnInvalidChild = true; + + error('Only strings and numbers are supported as <option> children.'); + } + }); + } // TODO: Remove support for `selected` in <option>. + + + if (props.selected != null && !didWarnSelectedSetOnOption) { + error('Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.'); + + didWarnSelectedSetOnOption = true; + } + } + } + function postMountWrapper$1(element, props) { + // value="" should make a value attribute (#6219) + if (props.value != null) { + element.setAttribute('value', toString(getToStringValue(props.value))); + } + } + function getHostProps$1(element, props) { + var hostProps = _assign({ + children: undefined + }, props); + + var content = flattenChildren(props.children); + + if (content) { + hostProps.children = content; + } + + return hostProps; + } + + var didWarnValueDefaultValue$1; + + { + didWarnValueDefaultValue$1 = false; + } + + function getDeclarationErrorAddendum() { + var ownerName = getCurrentFiberOwnerNameInDevOrNull(); + + if (ownerName) { + return '\n\nCheck the render method of `' + ownerName + '`.'; + } + + return ''; + } + + var valuePropNames = ['value', 'defaultValue']; + /** + * Validation function for `value` and `defaultValue`. + */ + + function checkSelectPropTypes(props) { + { + checkControlledValueProps('select', props); + + for (var i = 0; i < valuePropNames.length; i++) { + var propName = valuePropNames[i]; + + if (props[propName] == null) { + continue; + } + + var isArray = Array.isArray(props[propName]); + + if (props.multiple && !isArray) { + error('The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum()); + } else if (!props.multiple && isArray) { + error('The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum()); + } + } + } + } + + function updateOptions(node, multiple, propValue, setDefaultSelected) { + var options = node.options; + + if (multiple) { + var selectedValues = propValue; + var selectedValue = {}; + + for (var i = 0; i < selectedValues.length; i++) { + // Prefix to avoid chaos with special keys. + selectedValue['$' + selectedValues[i]] = true; + } + + for (var _i = 0; _i < options.length; _i++) { + var selected = selectedValue.hasOwnProperty('$' + options[_i].value); + + if (options[_i].selected !== selected) { + options[_i].selected = selected; + } + + if (selected && setDefaultSelected) { + options[_i].defaultSelected = true; + } + } + } else { + // Do not set `select.value` as exact behavior isn't consistent across all + // browsers for all cases. + var _selectedValue = toString(getToStringValue(propValue)); + + var defaultSelected = null; + + for (var _i2 = 0; _i2 < options.length; _i2++) { + if (options[_i2].value === _selectedValue) { + options[_i2].selected = true; + + if (setDefaultSelected) { + options[_i2].defaultSelected = true; + } + + return; + } + + if (defaultSelected === null && !options[_i2].disabled) { + defaultSelected = options[_i2]; + } + } + + if (defaultSelected !== null) { + defaultSelected.selected = true; + } + } + } + /** + * Implements a <select> host component that allows optionally setting the + * props `value` and `defaultValue`. If `multiple` is false, the prop must be a + * stringable. If `multiple` is true, the prop must be an array of stringables. + * + * If `value` is not supplied (or null/undefined), user actions that change the + * selected option will trigger updates to the rendered options. + * + * If it is supplied (and not null/undefined), the rendered options will not + * update in response to user actions. Instead, the `value` prop must change in + * order for the rendered options to update. + * + * If `defaultValue` is provided, any options with the supplied values will be + * selected. + */ + + + function getHostProps$2(element, props) { + return _assign({}, props, { + value: undefined + }); + } + function initWrapperState$1(element, props) { + var node = element; + + { + checkSelectPropTypes(props); + } + + node._wrapperState = { + wasMultiple: !!props.multiple + }; + + { + if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue$1) { + error('Select elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled select ' + 'element and remove one of these props. More info: ' + 'https://reactjs.org/link/controlled-components'); + + didWarnValueDefaultValue$1 = true; + } + } + } + function postMountWrapper$2(element, props) { + var node = element; + node.multiple = !!props.multiple; + var value = props.value; + + if (value != null) { + updateOptions(node, !!props.multiple, value, false); + } else if (props.defaultValue != null) { + updateOptions(node, !!props.multiple, props.defaultValue, true); + } + } + function postUpdateWrapper(element, props) { + var node = element; + var wasMultiple = node._wrapperState.wasMultiple; + node._wrapperState.wasMultiple = !!props.multiple; + var value = props.value; + + if (value != null) { + updateOptions(node, !!props.multiple, value, false); + } else if (wasMultiple !== !!props.multiple) { + // For simplicity, reapply `defaultValue` if `multiple` is toggled. + if (props.defaultValue != null) { + updateOptions(node, !!props.multiple, props.defaultValue, true); + } else { + // Revert the select back to its default unselected state. + updateOptions(node, !!props.multiple, props.multiple ? [] : '', false); + } + } + } + function restoreControlledState$1(element, props) { + var node = element; + var value = props.value; + + if (value != null) { + updateOptions(node, !!props.multiple, value, false); + } + } + + var didWarnValDefaultVal = false; + + /** + * Implements a <textarea> host component that allows setting `value`, and + * `defaultValue`. This differs from the traditional DOM API because value is + * usually set as PCDATA children. + * + * If `value` is not supplied (or null/undefined), user actions that affect the + * value will trigger updates to the element. + * + * If `value` is supplied (and not null/undefined), the rendered element will + * not trigger updates to the element. Instead, the `value` prop must change in + * order for the rendered element to be updated. + * + * The rendered element will be initialized with an empty value, the prop + * `defaultValue` if specified, or the children content (deprecated). + */ + function getHostProps$3(element, props) { + var node = element; + + if (!(props.dangerouslySetInnerHTML == null)) { + { + throw Error( "`dangerouslySetInnerHTML` does not make sense on <textarea>." ); + } + } // Always set children to the same thing. In IE9, the selection range will + // get reset if `textContent` is mutated. We could add a check in setTextContent + // to only set the value if/when the value differs from the node value (which would + // completely solve this IE9 bug), but Sebastian+Sophie seemed to like this + // solution. The value can be a boolean or object so that's why it's forced + // to be a string. + + + var hostProps = _assign({}, props, { + value: undefined, + defaultValue: undefined, + children: toString(node._wrapperState.initialValue) + }); + + return hostProps; + } + function initWrapperState$2(element, props) { + var node = element; + + { + checkControlledValueProps('textarea', props); + + if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) { + error('%s contains a textarea with both value and defaultValue props. ' + 'Textarea elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled textarea ' + 'and remove one of these props. More info: ' + 'https://reactjs.org/link/controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component'); + + didWarnValDefaultVal = true; + } + } + + var initialValue = props.value; // Only bother fetching default value if we're going to use it + + if (initialValue == null) { + var children = props.children, + defaultValue = props.defaultValue; + + if (children != null) { + { + error('Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.'); + } + + { + if (!(defaultValue == null)) { + { + throw Error( "If you supply `defaultValue` on a <textarea>, do not pass children." ); + } + } + + if (Array.isArray(children)) { + if (!(children.length <= 1)) { + { + throw Error( "<textarea> can only have at most one child." ); + } + } + + children = children[0]; + } + + defaultValue = children; + } + } + + if (defaultValue == null) { + defaultValue = ''; + } + + initialValue = defaultValue; + } + + node._wrapperState = { + initialValue: getToStringValue(initialValue) + }; + } + function updateWrapper$1(element, props) { + var node = element; + var value = getToStringValue(props.value); + var defaultValue = getToStringValue(props.defaultValue); + + if (value != null) { + // Cast `value` to a string to ensure the value is set correctly. While + // browsers typically do this as necessary, jsdom doesn't. + var newValue = toString(value); // To avoid side effects (such as losing text selection), only set value if changed + + if (newValue !== node.value) { + node.value = newValue; + } + + if (props.defaultValue == null && node.defaultValue !== newValue) { + node.defaultValue = newValue; + } + } + + if (defaultValue != null) { + node.defaultValue = toString(defaultValue); + } + } + function postMountWrapper$3(element, props) { + var node = element; // This is in postMount because we need access to the DOM node, which is not + // available until after the component has mounted. + + var textContent = node.textContent; // Only set node.value if textContent is equal to the expected + // initial value. In IE10/IE11 there is a bug where the placeholder attribute + // will populate textContent as well. + // https://developer.microsoft.com/microsoft-edge/platform/issues/101525/ + + if (textContent === node._wrapperState.initialValue) { + if (textContent !== '' && textContent !== null) { + node.value = textContent; + } + } + } + function restoreControlledState$2(element, props) { + // DOM component is still mounted; update + updateWrapper$1(element, props); + } + + var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'; + var MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; + var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; + var Namespaces = { + html: HTML_NAMESPACE, + mathml: MATH_NAMESPACE, + svg: SVG_NAMESPACE + }; // Assumes there is no parent namespace. + + function getIntrinsicNamespace(type) { + switch (type) { + case 'svg': + return SVG_NAMESPACE; + + case 'math': + return MATH_NAMESPACE; + + default: + return HTML_NAMESPACE; + } + } + function getChildNamespace(parentNamespace, type) { + if (parentNamespace == null || parentNamespace === HTML_NAMESPACE) { + // No (or default) parent namespace: potential entry point. + return getIntrinsicNamespace(type); + } + + if (parentNamespace === SVG_NAMESPACE && type === 'foreignObject') { + // We're leaving SVG. + return HTML_NAMESPACE; + } // By default, pass namespace below. + + + return parentNamespace; + } + + /* globals MSApp */ + + /** + * Create a function which has 'unsafe' privileges (required by windows8 apps) + */ + var createMicrosoftUnsafeLocalFunction = function (func) { + if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) { + return function (arg0, arg1, arg2, arg3) { + MSApp.execUnsafeLocalFunction(function () { + return func(arg0, arg1, arg2, arg3); + }); + }; + } else { + return func; + } + }; + + var reusableSVGContainer; + /** + * Set the innerHTML property of a node + * + * @param {DOMElement} node + * @param {string} html + * @internal + */ + + var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) { + if (node.namespaceURI === Namespaces.svg) { + + if (!('innerHTML' in node)) { + // IE does not have innerHTML for SVG nodes, so instead we inject the + // new markup in a temp node and then move the child nodes across into + // the target node + reusableSVGContainer = reusableSVGContainer || document.createElement('div'); + reusableSVGContainer.innerHTML = '<svg>' + html.valueOf().toString() + '</svg>'; + var svgNode = reusableSVGContainer.firstChild; + + while (node.firstChild) { + node.removeChild(node.firstChild); + } + + while (svgNode.firstChild) { + node.appendChild(svgNode.firstChild); + } + + return; + } + } + + node.innerHTML = html; + }); + + /** + * HTML nodeType values that represent the type of the node + */ + var ELEMENT_NODE = 1; + var TEXT_NODE = 3; + var COMMENT_NODE = 8; + var DOCUMENT_NODE = 9; + var DOCUMENT_FRAGMENT_NODE = 11; + + /** + * Set the textContent property of a node. For text updates, it's faster + * to set the `nodeValue` of the Text node directly instead of using + * `.textContent` which will remove the existing node and create a new one. + * + * @param {DOMElement} node + * @param {string} text + * @internal + */ + + var setTextContent = function (node, text) { + if (text) { + var firstChild = node.firstChild; + + if (firstChild && firstChild === node.lastChild && firstChild.nodeType === TEXT_NODE) { + firstChild.nodeValue = text; + return; + } + } + + node.textContent = text; + }; + + // List derived from Gecko source code: + // https://github.com/mozilla/gecko-dev/blob/4e638efc71/layout/style/test/property_database.js + var shorthandToLonghand = { + animation: ['animationDelay', 'animationDirection', 'animationDuration', 'animationFillMode', 'animationIterationCount', 'animationName', 'animationPlayState', 'animationTimingFunction'], + background: ['backgroundAttachment', 'backgroundClip', 'backgroundColor', 'backgroundImage', 'backgroundOrigin', 'backgroundPositionX', 'backgroundPositionY', 'backgroundRepeat', 'backgroundSize'], + backgroundPosition: ['backgroundPositionX', 'backgroundPositionY'], + border: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth', 'borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth', 'borderLeftColor', 'borderLeftStyle', 'borderLeftWidth', 'borderRightColor', 'borderRightStyle', 'borderRightWidth', 'borderTopColor', 'borderTopStyle', 'borderTopWidth'], + borderBlockEnd: ['borderBlockEndColor', 'borderBlockEndStyle', 'borderBlockEndWidth'], + borderBlockStart: ['borderBlockStartColor', 'borderBlockStartStyle', 'borderBlockStartWidth'], + borderBottom: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth'], + borderColor: ['borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor'], + borderImage: ['borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth'], + borderInlineEnd: ['borderInlineEndColor', 'borderInlineEndStyle', 'borderInlineEndWidth'], + borderInlineStart: ['borderInlineStartColor', 'borderInlineStartStyle', 'borderInlineStartWidth'], + borderLeft: ['borderLeftColor', 'borderLeftStyle', 'borderLeftWidth'], + borderRadius: ['borderBottomLeftRadius', 'borderBottomRightRadius', 'borderTopLeftRadius', 'borderTopRightRadius'], + borderRight: ['borderRightColor', 'borderRightStyle', 'borderRightWidth'], + borderStyle: ['borderBottomStyle', 'borderLeftStyle', 'borderRightStyle', 'borderTopStyle'], + borderTop: ['borderTopColor', 'borderTopStyle', 'borderTopWidth'], + borderWidth: ['borderBottomWidth', 'borderLeftWidth', 'borderRightWidth', 'borderTopWidth'], + columnRule: ['columnRuleColor', 'columnRuleStyle', 'columnRuleWidth'], + columns: ['columnCount', 'columnWidth'], + flex: ['flexBasis', 'flexGrow', 'flexShrink'], + flexFlow: ['flexDirection', 'flexWrap'], + font: ['fontFamily', 'fontFeatureSettings', 'fontKerning', 'fontLanguageOverride', 'fontSize', 'fontSizeAdjust', 'fontStretch', 'fontStyle', 'fontVariant', 'fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition', 'fontWeight', 'lineHeight'], + fontVariant: ['fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition'], + gap: ['columnGap', 'rowGap'], + grid: ['gridAutoColumns', 'gridAutoFlow', 'gridAutoRows', 'gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'], + gridArea: ['gridColumnEnd', 'gridColumnStart', 'gridRowEnd', 'gridRowStart'], + gridColumn: ['gridColumnEnd', 'gridColumnStart'], + gridColumnGap: ['columnGap'], + gridGap: ['columnGap', 'rowGap'], + gridRow: ['gridRowEnd', 'gridRowStart'], + gridRowGap: ['rowGap'], + gridTemplate: ['gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'], + listStyle: ['listStyleImage', 'listStylePosition', 'listStyleType'], + margin: ['marginBottom', 'marginLeft', 'marginRight', 'marginTop'], + marker: ['markerEnd', 'markerMid', 'markerStart'], + mask: ['maskClip', 'maskComposite', 'maskImage', 'maskMode', 'maskOrigin', 'maskPositionX', 'maskPositionY', 'maskRepeat', 'maskSize'], + maskPosition: ['maskPositionX', 'maskPositionY'], + outline: ['outlineColor', 'outlineStyle', 'outlineWidth'], + overflow: ['overflowX', 'overflowY'], + padding: ['paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop'], + placeContent: ['alignContent', 'justifyContent'], + placeItems: ['alignItems', 'justifyItems'], + placeSelf: ['alignSelf', 'justifySelf'], + textDecoration: ['textDecorationColor', 'textDecorationLine', 'textDecorationStyle'], + textEmphasis: ['textEmphasisColor', 'textEmphasisStyle'], + transition: ['transitionDelay', 'transitionDuration', 'transitionProperty', 'transitionTimingFunction'], + wordWrap: ['overflowWrap'] + }; + + /** + * CSS properties which accept numbers but are not in units of "px". + */ + var isUnitlessNumber = { + animationIterationCount: true, + borderImageOutset: true, + borderImageSlice: true, + borderImageWidth: true, + boxFlex: true, + boxFlexGroup: true, + boxOrdinalGroup: true, + columnCount: true, + columns: true, + flex: true, + flexGrow: true, + flexPositive: true, + flexShrink: true, + flexNegative: true, + flexOrder: true, + gridArea: true, + gridRow: true, + gridRowEnd: true, + gridRowSpan: true, + gridRowStart: true, + gridColumn: true, + gridColumnEnd: true, + gridColumnSpan: true, + gridColumnStart: true, + fontWeight: true, + lineClamp: true, + lineHeight: true, + opacity: true, + order: true, + orphans: true, + tabSize: true, + widows: true, + zIndex: true, + zoom: true, + // SVG-related properties + fillOpacity: true, + floodOpacity: true, + stopOpacity: true, + strokeDasharray: true, + strokeDashoffset: true, + strokeMiterlimit: true, + strokeOpacity: true, + strokeWidth: true + }; + /** + * @param {string} prefix vendor-specific prefix, eg: Webkit + * @param {string} key style name, eg: transitionDuration + * @return {string} style name prefixed with `prefix`, properly camelCased, eg: + * WebkitTransitionDuration + */ + + function prefixKey(prefix, key) { + return prefix + key.charAt(0).toUpperCase() + key.substring(1); + } + /** + * Support style names that may come passed in prefixed by adding permutations + * of vendor prefixes. + */ + + + var prefixes = ['Webkit', 'ms', 'Moz', 'O']; // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an + // infinite loop, because it iterates over the newly added props too. + + Object.keys(isUnitlessNumber).forEach(function (prop) { + prefixes.forEach(function (prefix) { + isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop]; + }); + }); + + /** + * Convert a value into the proper css writable value. The style name `name` + * should be logical (no hyphens), as specified + * in `CSSProperty.isUnitlessNumber`. + * + * @param {string} name CSS property name such as `topMargin`. + * @param {*} value CSS property value such as `10px`. + * @return {string} Normalized style value with dimensions applied. + */ + + function dangerousStyleValue(name, value, isCustomProperty) { + // Note that we've removed escapeTextForBrowser() calls here since the + // whole string will be escaped when the attribute is injected into + // the markup. If you provide unsafe user data here they can inject + // arbitrary CSS which may be problematic (I couldn't repro this): + // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet + // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/ + // This is not an XSS hole but instead a potential CSS injection issue + // which has lead to a greater discussion about how we're going to + // trust URLs moving forward. See #2115901 + var isEmpty = value == null || typeof value === 'boolean' || value === ''; + + if (isEmpty) { + return ''; + } + + if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) { + return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers + } + + return ('' + value).trim(); + } + + var uppercasePattern = /([A-Z])/g; + var msPattern = /^ms-/; + /** + * Hyphenates a camelcased CSS property name, for example: + * + * > hyphenateStyleName('backgroundColor') + * < "background-color" + * > hyphenateStyleName('MozTransition') + * < "-moz-transition" + * > hyphenateStyleName('msTransition') + * < "-ms-transition" + * + * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix + * is converted to `-ms-`. + */ + + function hyphenateStyleName(name) { + return name.replace(uppercasePattern, '-$1').toLowerCase().replace(msPattern, '-ms-'); + } + + var warnValidStyle = function () {}; + + { + // 'msTransform' is correct, but the other prefixes should be capitalized + var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/; + var msPattern$1 = /^-ms-/; + var hyphenPattern = /-(.)/g; // style values shouldn't contain a semicolon + + var badStyleValueWithSemicolonPattern = /;\s*$/; + var warnedStyleNames = {}; + var warnedStyleValues = {}; + var warnedForNaNValue = false; + var warnedForInfinityValue = false; + + var camelize = function (string) { + return string.replace(hyphenPattern, function (_, character) { + return character.toUpperCase(); + }); + }; + + var warnHyphenatedStyleName = function (name) { + if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { + return; + } + + warnedStyleNames[name] = true; + + error('Unsupported style property %s. Did you mean %s?', name, // As Andi Smith suggests + // (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix + // is converted to lowercase `ms`. + camelize(name.replace(msPattern$1, 'ms-'))); + }; + + var warnBadVendoredStyleName = function (name) { + if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { + return; + } + + warnedStyleNames[name] = true; + + error('Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1)); + }; + + var warnStyleValueWithSemicolon = function (name, value) { + if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) { + return; + } + + warnedStyleValues[value] = true; + + error("Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, '')); + }; + + var warnStyleValueIsNaN = function (name, value) { + if (warnedForNaNValue) { + return; + } + + warnedForNaNValue = true; + + error('`NaN` is an invalid value for the `%s` css style property.', name); + }; + + var warnStyleValueIsInfinity = function (name, value) { + if (warnedForInfinityValue) { + return; + } + + warnedForInfinityValue = true; + + error('`Infinity` is an invalid value for the `%s` css style property.', name); + }; + + warnValidStyle = function (name, value) { + if (name.indexOf('-') > -1) { + warnHyphenatedStyleName(name); + } else if (badVendoredStyleNamePattern.test(name)) { + warnBadVendoredStyleName(name); + } else if (badStyleValueWithSemicolonPattern.test(value)) { + warnStyleValueWithSemicolon(name, value); + } + + if (typeof value === 'number') { + if (isNaN(value)) { + warnStyleValueIsNaN(name, value); + } else if (!isFinite(value)) { + warnStyleValueIsInfinity(name, value); + } + } + }; + } + + var warnValidStyle$1 = warnValidStyle; + + /** + * Operations for dealing with CSS properties. + */ + + /** + * This creates a string that is expected to be equivalent to the style + * attribute generated by server-side rendering. It by-passes warnings and + * security checks so it's not safe to use this value for anything other than + * comparison. It is only used in DEV for SSR validation. + */ + + function createDangerousStringForStyles(styles) { + { + var serialized = ''; + var delimiter = ''; + + for (var styleName in styles) { + if (!styles.hasOwnProperty(styleName)) { + continue; + } + + var styleValue = styles[styleName]; + + if (styleValue != null) { + var isCustomProperty = styleName.indexOf('--') === 0; + serialized += delimiter + (isCustomProperty ? styleName : hyphenateStyleName(styleName)) + ':'; + serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty); + delimiter = ';'; + } + } + + return serialized || null; + } + } + /** + * Sets the value for multiple styles on a node. If a value is specified as + * '' (empty string), the corresponding style property will be unset. + * + * @param {DOMElement} node + * @param {object} styles + */ + + function setValueForStyles(node, styles) { + var style = node.style; + + for (var styleName in styles) { + if (!styles.hasOwnProperty(styleName)) { + continue; + } + + var isCustomProperty = styleName.indexOf('--') === 0; + + { + if (!isCustomProperty) { + warnValidStyle$1(styleName, styles[styleName]); + } + } + + var styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty); + + if (styleName === 'float') { + styleName = 'cssFloat'; + } + + if (isCustomProperty) { + style.setProperty(styleName, styleValue); + } else { + style[styleName] = styleValue; + } + } + } + + function isValueEmpty(value) { + return value == null || typeof value === 'boolean' || value === ''; + } + /** + * Given {color: 'red', overflow: 'hidden'} returns { + * color: 'color', + * overflowX: 'overflow', + * overflowY: 'overflow', + * }. This can be read as "the overflowY property was set by the overflow + * shorthand". That is, the values are the property that each was derived from. + */ + + + function expandShorthandMap(styles) { + var expanded = {}; + + for (var key in styles) { + var longhands = shorthandToLonghand[key] || [key]; + + for (var i = 0; i < longhands.length; i++) { + expanded[longhands[i]] = key; + } + } + + return expanded; + } + /** + * When mixing shorthand and longhand property names, we warn during updates if + * we expect an incorrect result to occur. In particular, we warn for: + * + * Updating a shorthand property (longhand gets overwritten): + * {font: 'foo', fontVariant: 'bar'} -> {font: 'baz', fontVariant: 'bar'} + * becomes .style.font = 'baz' + * Removing a shorthand property (longhand gets lost too): + * {font: 'foo', fontVariant: 'bar'} -> {fontVariant: 'bar'} + * becomes .style.font = '' + * Removing a longhand property (should revert to shorthand; doesn't): + * {font: 'foo', fontVariant: 'bar'} -> {font: 'foo'} + * becomes .style.fontVariant = '' + */ + + + function validateShorthandPropertyCollisionInDev(styleUpdates, nextStyles) { + { + if (!nextStyles) { + return; + } + + var expandedUpdates = expandShorthandMap(styleUpdates); + var expandedStyles = expandShorthandMap(nextStyles); + var warnedAbout = {}; + + for (var key in expandedUpdates) { + var originalKey = expandedUpdates[key]; + var correctOriginalKey = expandedStyles[key]; + + if (correctOriginalKey && originalKey !== correctOriginalKey) { + var warningKey = originalKey + ',' + correctOriginalKey; + + if (warnedAbout[warningKey]) { + continue; + } + + warnedAbout[warningKey] = true; + + error('%s a style property during rerender (%s) when a ' + 'conflicting property is set (%s) can lead to styling bugs. To ' + "avoid this, don't mix shorthand and non-shorthand properties " + 'for the same value; instead, replace the shorthand with ' + 'separate values.', isValueEmpty(styleUpdates[originalKey]) ? 'Removing' : 'Updating', originalKey, correctOriginalKey); + } + } + } + } + + // For HTML, certain tags should omit their close tag. We keep a list for + // those special-case tags. + var omittedCloseTags = { + area: true, + base: true, + br: true, + col: true, + embed: true, + hr: true, + img: true, + input: true, + keygen: true, + link: true, + meta: true, + param: true, + source: true, + track: true, + wbr: true // NOTE: menuitem's close tag should be omitted, but that causes problems. + + }; + + // `omittedCloseTags` except that `menuitem` should still have its closing tag. + + var voidElementTags = _assign({ + menuitem: true + }, omittedCloseTags); + + var HTML = '__html'; + + function assertValidProps(tag, props) { + if (!props) { + return; + } // Note the use of `==` which checks for null or undefined. + + + if (voidElementTags[tag]) { + if (!(props.children == null && props.dangerouslySetInnerHTML == null)) { + { + throw Error( tag + " is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`." ); + } + } + } + + if (props.dangerouslySetInnerHTML != null) { + if (!(props.children == null)) { + { + throw Error( "Can only set one of `children` or `props.dangerouslySetInnerHTML`." ); + } + } + + if (!(typeof props.dangerouslySetInnerHTML === 'object' && HTML in props.dangerouslySetInnerHTML)) { + { + throw Error( "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information." ); + } + } + } + + { + if (!props.suppressContentEditableWarning && props.contentEditable && props.children != null) { + error('A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.'); + } + } + + if (!(props.style == null || typeof props.style === 'object')) { + { + throw Error( "The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX." ); + } + } + } + + function isCustomComponent(tagName, props) { + if (tagName.indexOf('-') === -1) { + return typeof props.is === 'string'; + } + + switch (tagName) { + // These are reserved SVG and MathML elements. + // We don't mind this list too much because we expect it to never grow. + // The alternative is to track the namespace in a few places which is convoluted. + // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts + case 'annotation-xml': + case 'color-profile': + case 'font-face': + case 'font-face-src': + case 'font-face-uri': + case 'font-face-format': + case 'font-face-name': + case 'missing-glyph': + return false; + + default: + return true; + } + } + + // When adding attributes to the HTML or SVG allowed attribute list, be sure to + // also add them to this module to ensure casing and incorrect name + // warnings. + var possibleStandardNames = { + // HTML + accept: 'accept', + acceptcharset: 'acceptCharset', + 'accept-charset': 'acceptCharset', + accesskey: 'accessKey', + action: 'action', + allowfullscreen: 'allowFullScreen', + alt: 'alt', + as: 'as', + async: 'async', + autocapitalize: 'autoCapitalize', + autocomplete: 'autoComplete', + autocorrect: 'autoCorrect', + autofocus: 'autoFocus', + autoplay: 'autoPlay', + autosave: 'autoSave', + capture: 'capture', + cellpadding: 'cellPadding', + cellspacing: 'cellSpacing', + challenge: 'challenge', + charset: 'charSet', + checked: 'checked', + children: 'children', + cite: 'cite', + class: 'className', + classid: 'classID', + classname: 'className', + cols: 'cols', + colspan: 'colSpan', + content: 'content', + contenteditable: 'contentEditable', + contextmenu: 'contextMenu', + controls: 'controls', + controlslist: 'controlsList', + coords: 'coords', + crossorigin: 'crossOrigin', + dangerouslysetinnerhtml: 'dangerouslySetInnerHTML', + data: 'data', + datetime: 'dateTime', + default: 'default', + defaultchecked: 'defaultChecked', + defaultvalue: 'defaultValue', + defer: 'defer', + dir: 'dir', + disabled: 'disabled', + disablepictureinpicture: 'disablePictureInPicture', + disableremoteplayback: 'disableRemotePlayback', + download: 'download', + draggable: 'draggable', + enctype: 'encType', + enterkeyhint: 'enterKeyHint', + for: 'htmlFor', + form: 'form', + formmethod: 'formMethod', + formaction: 'formAction', + formenctype: 'formEncType', + formnovalidate: 'formNoValidate', + formtarget: 'formTarget', + frameborder: 'frameBorder', + headers: 'headers', + height: 'height', + hidden: 'hidden', + high: 'high', + href: 'href', + hreflang: 'hrefLang', + htmlfor: 'htmlFor', + httpequiv: 'httpEquiv', + 'http-equiv': 'httpEquiv', + icon: 'icon', + id: 'id', + innerhtml: 'innerHTML', + inputmode: 'inputMode', + integrity: 'integrity', + is: 'is', + itemid: 'itemID', + itemprop: 'itemProp', + itemref: 'itemRef', + itemscope: 'itemScope', + itemtype: 'itemType', + keyparams: 'keyParams', + keytype: 'keyType', + kind: 'kind', + label: 'label', + lang: 'lang', + list: 'list', + loop: 'loop', + low: 'low', + manifest: 'manifest', + marginwidth: 'marginWidth', + marginheight: 'marginHeight', + max: 'max', + maxlength: 'maxLength', + media: 'media', + mediagroup: 'mediaGroup', + method: 'method', + min: 'min', + minlength: 'minLength', + multiple: 'multiple', + muted: 'muted', + name: 'name', + nomodule: 'noModule', + nonce: 'nonce', + novalidate: 'noValidate', + open: 'open', + optimum: 'optimum', + pattern: 'pattern', + placeholder: 'placeholder', + playsinline: 'playsInline', + poster: 'poster', + preload: 'preload', + profile: 'profile', + radiogroup: 'radioGroup', + readonly: 'readOnly', + referrerpolicy: 'referrerPolicy', + rel: 'rel', + required: 'required', + reversed: 'reversed', + role: 'role', + rows: 'rows', + rowspan: 'rowSpan', + sandbox: 'sandbox', + scope: 'scope', + scoped: 'scoped', + scrolling: 'scrolling', + seamless: 'seamless', + selected: 'selected', + shape: 'shape', + size: 'size', + sizes: 'sizes', + span: 'span', + spellcheck: 'spellCheck', + src: 'src', + srcdoc: 'srcDoc', + srclang: 'srcLang', + srcset: 'srcSet', + start: 'start', + step: 'step', + style: 'style', + summary: 'summary', + tabindex: 'tabIndex', + target: 'target', + title: 'title', + type: 'type', + usemap: 'useMap', + value: 'value', + width: 'width', + wmode: 'wmode', + wrap: 'wrap', + // SVG + about: 'about', + accentheight: 'accentHeight', + 'accent-height': 'accentHeight', + accumulate: 'accumulate', + additive: 'additive', + alignmentbaseline: 'alignmentBaseline', + 'alignment-baseline': 'alignmentBaseline', + allowreorder: 'allowReorder', + alphabetic: 'alphabetic', + amplitude: 'amplitude', + arabicform: 'arabicForm', + 'arabic-form': 'arabicForm', + ascent: 'ascent', + attributename: 'attributeName', + attributetype: 'attributeType', + autoreverse: 'autoReverse', + azimuth: 'azimuth', + basefrequency: 'baseFrequency', + baselineshift: 'baselineShift', + 'baseline-shift': 'baselineShift', + baseprofile: 'baseProfile', + bbox: 'bbox', + begin: 'begin', + bias: 'bias', + by: 'by', + calcmode: 'calcMode', + capheight: 'capHeight', + 'cap-height': 'capHeight', + clip: 'clip', + clippath: 'clipPath', + 'clip-path': 'clipPath', + clippathunits: 'clipPathUnits', + cliprule: 'clipRule', + 'clip-rule': 'clipRule', + color: 'color', + colorinterpolation: 'colorInterpolation', + 'color-interpolation': 'colorInterpolation', + colorinterpolationfilters: 'colorInterpolationFilters', + 'color-interpolation-filters': 'colorInterpolationFilters', + colorprofile: 'colorProfile', + 'color-profile': 'colorProfile', + colorrendering: 'colorRendering', + 'color-rendering': 'colorRendering', + contentscripttype: 'contentScriptType', + contentstyletype: 'contentStyleType', + cursor: 'cursor', + cx: 'cx', + cy: 'cy', + d: 'd', + datatype: 'datatype', + decelerate: 'decelerate', + descent: 'descent', + diffuseconstant: 'diffuseConstant', + direction: 'direction', + display: 'display', + divisor: 'divisor', + dominantbaseline: 'dominantBaseline', + 'dominant-baseline': 'dominantBaseline', + dur: 'dur', + dx: 'dx', + dy: 'dy', + edgemode: 'edgeMode', + elevation: 'elevation', + enablebackground: 'enableBackground', + 'enable-background': 'enableBackground', + end: 'end', + exponent: 'exponent', + externalresourcesrequired: 'externalResourcesRequired', + fill: 'fill', + fillopacity: 'fillOpacity', + 'fill-opacity': 'fillOpacity', + fillrule: 'fillRule', + 'fill-rule': 'fillRule', + filter: 'filter', + filterres: 'filterRes', + filterunits: 'filterUnits', + floodopacity: 'floodOpacity', + 'flood-opacity': 'floodOpacity', + floodcolor: 'floodColor', + 'flood-color': 'floodColor', + focusable: 'focusable', + fontfamily: 'fontFamily', + 'font-family': 'fontFamily', + fontsize: 'fontSize', + 'font-size': 'fontSize', + fontsizeadjust: 'fontSizeAdjust', + 'font-size-adjust': 'fontSizeAdjust', + fontstretch: 'fontStretch', + 'font-stretch': 'fontStretch', + fontstyle: 'fontStyle', + 'font-style': 'fontStyle', + fontvariant: 'fontVariant', + 'font-variant': 'fontVariant', + fontweight: 'fontWeight', + 'font-weight': 'fontWeight', + format: 'format', + from: 'from', + fx: 'fx', + fy: 'fy', + g1: 'g1', + g2: 'g2', + glyphname: 'glyphName', + 'glyph-name': 'glyphName', + glyphorientationhorizontal: 'glyphOrientationHorizontal', + 'glyph-orientation-horizontal': 'glyphOrientationHorizontal', + glyphorientationvertical: 'glyphOrientationVertical', + 'glyph-orientation-vertical': 'glyphOrientationVertical', + glyphref: 'glyphRef', + gradienttransform: 'gradientTransform', + gradientunits: 'gradientUnits', + hanging: 'hanging', + horizadvx: 'horizAdvX', + 'horiz-adv-x': 'horizAdvX', + horizoriginx: 'horizOriginX', + 'horiz-origin-x': 'horizOriginX', + ideographic: 'ideographic', + imagerendering: 'imageRendering', + 'image-rendering': 'imageRendering', + in2: 'in2', + in: 'in', + inlist: 'inlist', + intercept: 'intercept', + k1: 'k1', + k2: 'k2', + k3: 'k3', + k4: 'k4', + k: 'k', + kernelmatrix: 'kernelMatrix', + kernelunitlength: 'kernelUnitLength', + kerning: 'kerning', + keypoints: 'keyPoints', + keysplines: 'keySplines', + keytimes: 'keyTimes', + lengthadjust: 'lengthAdjust', + letterspacing: 'letterSpacing', + 'letter-spacing': 'letterSpacing', + lightingcolor: 'lightingColor', + 'lighting-color': 'lightingColor', + limitingconeangle: 'limitingConeAngle', + local: 'local', + markerend: 'markerEnd', + 'marker-end': 'markerEnd', + markerheight: 'markerHeight', + markermid: 'markerMid', + 'marker-mid': 'markerMid', + markerstart: 'markerStart', + 'marker-start': 'markerStart', + markerunits: 'markerUnits', + markerwidth: 'markerWidth', + mask: 'mask', + maskcontentunits: 'maskContentUnits', + maskunits: 'maskUnits', + mathematical: 'mathematical', + mode: 'mode', + numoctaves: 'numOctaves', + offset: 'offset', + opacity: 'opacity', + operator: 'operator', + order: 'order', + orient: 'orient', + orientation: 'orientation', + origin: 'origin', + overflow: 'overflow', + overlineposition: 'overlinePosition', + 'overline-position': 'overlinePosition', + overlinethickness: 'overlineThickness', + 'overline-thickness': 'overlineThickness', + paintorder: 'paintOrder', + 'paint-order': 'paintOrder', + panose1: 'panose1', + 'panose-1': 'panose1', + pathlength: 'pathLength', + patterncontentunits: 'patternContentUnits', + patterntransform: 'patternTransform', + patternunits: 'patternUnits', + pointerevents: 'pointerEvents', + 'pointer-events': 'pointerEvents', + points: 'points', + pointsatx: 'pointsAtX', + pointsaty: 'pointsAtY', + pointsatz: 'pointsAtZ', + prefix: 'prefix', + preservealpha: 'preserveAlpha', + preserveaspectratio: 'preserveAspectRatio', + primitiveunits: 'primitiveUnits', + property: 'property', + r: 'r', + radius: 'radius', + refx: 'refX', + refy: 'refY', + renderingintent: 'renderingIntent', + 'rendering-intent': 'renderingIntent', + repeatcount: 'repeatCount', + repeatdur: 'repeatDur', + requiredextensions: 'requiredExtensions', + requiredfeatures: 'requiredFeatures', + resource: 'resource', + restart: 'restart', + result: 'result', + results: 'results', + rotate: 'rotate', + rx: 'rx', + ry: 'ry', + scale: 'scale', + security: 'security', + seed: 'seed', + shaperendering: 'shapeRendering', + 'shape-rendering': 'shapeRendering', + slope: 'slope', + spacing: 'spacing', + specularconstant: 'specularConstant', + specularexponent: 'specularExponent', + speed: 'speed', + spreadmethod: 'spreadMethod', + startoffset: 'startOffset', + stddeviation: 'stdDeviation', + stemh: 'stemh', + stemv: 'stemv', + stitchtiles: 'stitchTiles', + stopcolor: 'stopColor', + 'stop-color': 'stopColor', + stopopacity: 'stopOpacity', + 'stop-opacity': 'stopOpacity', + strikethroughposition: 'strikethroughPosition', + 'strikethrough-position': 'strikethroughPosition', + strikethroughthickness: 'strikethroughThickness', + 'strikethrough-thickness': 'strikethroughThickness', + string: 'string', + stroke: 'stroke', + strokedasharray: 'strokeDasharray', + 'stroke-dasharray': 'strokeDasharray', + strokedashoffset: 'strokeDashoffset', + 'stroke-dashoffset': 'strokeDashoffset', + strokelinecap: 'strokeLinecap', + 'stroke-linecap': 'strokeLinecap', + strokelinejoin: 'strokeLinejoin', + 'stroke-linejoin': 'strokeLinejoin', + strokemiterlimit: 'strokeMiterlimit', + 'stroke-miterlimit': 'strokeMiterlimit', + strokewidth: 'strokeWidth', + 'stroke-width': 'strokeWidth', + strokeopacity: 'strokeOpacity', + 'stroke-opacity': 'strokeOpacity', + suppresscontenteditablewarning: 'suppressContentEditableWarning', + suppresshydrationwarning: 'suppressHydrationWarning', + surfacescale: 'surfaceScale', + systemlanguage: 'systemLanguage', + tablevalues: 'tableValues', + targetx: 'targetX', + targety: 'targetY', + textanchor: 'textAnchor', + 'text-anchor': 'textAnchor', + textdecoration: 'textDecoration', + 'text-decoration': 'textDecoration', + textlength: 'textLength', + textrendering: 'textRendering', + 'text-rendering': 'textRendering', + to: 'to', + transform: 'transform', + typeof: 'typeof', + u1: 'u1', + u2: 'u2', + underlineposition: 'underlinePosition', + 'underline-position': 'underlinePosition', + underlinethickness: 'underlineThickness', + 'underline-thickness': 'underlineThickness', + unicode: 'unicode', + unicodebidi: 'unicodeBidi', + 'unicode-bidi': 'unicodeBidi', + unicoderange: 'unicodeRange', + 'unicode-range': 'unicodeRange', + unitsperem: 'unitsPerEm', + 'units-per-em': 'unitsPerEm', + unselectable: 'unselectable', + valphabetic: 'vAlphabetic', + 'v-alphabetic': 'vAlphabetic', + values: 'values', + vectoreffect: 'vectorEffect', + 'vector-effect': 'vectorEffect', + version: 'version', + vertadvy: 'vertAdvY', + 'vert-adv-y': 'vertAdvY', + vertoriginx: 'vertOriginX', + 'vert-origin-x': 'vertOriginX', + vertoriginy: 'vertOriginY', + 'vert-origin-y': 'vertOriginY', + vhanging: 'vHanging', + 'v-hanging': 'vHanging', + videographic: 'vIdeographic', + 'v-ideographic': 'vIdeographic', + viewbox: 'viewBox', + viewtarget: 'viewTarget', + visibility: 'visibility', + vmathematical: 'vMathematical', + 'v-mathematical': 'vMathematical', + vocab: 'vocab', + widths: 'widths', + wordspacing: 'wordSpacing', + 'word-spacing': 'wordSpacing', + writingmode: 'writingMode', + 'writing-mode': 'writingMode', + x1: 'x1', + x2: 'x2', + x: 'x', + xchannelselector: 'xChannelSelector', + xheight: 'xHeight', + 'x-height': 'xHeight', + xlinkactuate: 'xlinkActuate', + 'xlink:actuate': 'xlinkActuate', + xlinkarcrole: 'xlinkArcrole', + 'xlink:arcrole': 'xlinkArcrole', + xlinkhref: 'xlinkHref', + 'xlink:href': 'xlinkHref', + xlinkrole: 'xlinkRole', + 'xlink:role': 'xlinkRole', + xlinkshow: 'xlinkShow', + 'xlink:show': 'xlinkShow', + xlinktitle: 'xlinkTitle', + 'xlink:title': 'xlinkTitle', + xlinktype: 'xlinkType', + 'xlink:type': 'xlinkType', + xmlbase: 'xmlBase', + 'xml:base': 'xmlBase', + xmllang: 'xmlLang', + 'xml:lang': 'xmlLang', + xmlns: 'xmlns', + 'xml:space': 'xmlSpace', + xmlnsxlink: 'xmlnsXlink', + 'xmlns:xlink': 'xmlnsXlink', + xmlspace: 'xmlSpace', + y1: 'y1', + y2: 'y2', + y: 'y', + ychannelselector: 'yChannelSelector', + z: 'z', + zoomandpan: 'zoomAndPan' + }; + + var ariaProperties = { + 'aria-current': 0, + // state + 'aria-details': 0, + 'aria-disabled': 0, + // state + 'aria-hidden': 0, + // state + 'aria-invalid': 0, + // state + 'aria-keyshortcuts': 0, + 'aria-label': 0, + 'aria-roledescription': 0, + // Widget Attributes + 'aria-autocomplete': 0, + 'aria-checked': 0, + 'aria-expanded': 0, + 'aria-haspopup': 0, + 'aria-level': 0, + 'aria-modal': 0, + 'aria-multiline': 0, + 'aria-multiselectable': 0, + 'aria-orientation': 0, + 'aria-placeholder': 0, + 'aria-pressed': 0, + 'aria-readonly': 0, + 'aria-required': 0, + 'aria-selected': 0, + 'aria-sort': 0, + 'aria-valuemax': 0, + 'aria-valuemin': 0, + 'aria-valuenow': 0, + 'aria-valuetext': 0, + // Live Region Attributes + 'aria-atomic': 0, + 'aria-busy': 0, + 'aria-live': 0, + 'aria-relevant': 0, + // Drag-and-Drop Attributes + 'aria-dropeffect': 0, + 'aria-grabbed': 0, + // Relationship Attributes + 'aria-activedescendant': 0, + 'aria-colcount': 0, + 'aria-colindex': 0, + 'aria-colspan': 0, + 'aria-controls': 0, + 'aria-describedby': 0, + 'aria-errormessage': 0, + 'aria-flowto': 0, + 'aria-labelledby': 0, + 'aria-owns': 0, + 'aria-posinset': 0, + 'aria-rowcount': 0, + 'aria-rowindex': 0, + 'aria-rowspan': 0, + 'aria-setsize': 0 + }; + + var warnedProperties = {}; + var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$'); + var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$'); + var hasOwnProperty$1 = Object.prototype.hasOwnProperty; + + function validateProperty(tagName, name) { + { + if (hasOwnProperty$1.call(warnedProperties, name) && warnedProperties[name]) { + return true; + } + + if (rARIACamel.test(name)) { + var ariaName = 'aria-' + name.slice(4).toLowerCase(); + var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null; // If this is an aria-* attribute, but is not listed in the known DOM + // DOM properties, then it is an invalid aria-* attribute. + + if (correctName == null) { + error('Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.', name); + + warnedProperties[name] = true; + return true; + } // aria-* attributes should be lowercase; suggest the lowercase version. + + + if (name !== correctName) { + error('Invalid ARIA attribute `%s`. Did you mean `%s`?', name, correctName); + + warnedProperties[name] = true; + return true; + } + } + + if (rARIA.test(name)) { + var lowerCasedName = name.toLowerCase(); + var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null; // If this is an aria-* attribute, but is not listed in the known DOM + // DOM properties, then it is an invalid aria-* attribute. + + if (standardName == null) { + warnedProperties[name] = true; + return false; + } // aria-* attributes should be lowercase; suggest the lowercase version. + + + if (name !== standardName) { + error('Unknown ARIA attribute `%s`. Did you mean `%s`?', name, standardName); + + warnedProperties[name] = true; + return true; + } + } + } + + return true; + } + + function warnInvalidARIAProps(type, props) { + { + var invalidProps = []; + + for (var key in props) { + var isValid = validateProperty(type, key); + + if (!isValid) { + invalidProps.push(key); + } + } + + var unknownPropString = invalidProps.map(function (prop) { + return '`' + prop + '`'; + }).join(', '); + + if (invalidProps.length === 1) { + error('Invalid aria prop %s on <%s> tag. ' + 'For details, see https://reactjs.org/link/invalid-aria-props', unknownPropString, type); + } else if (invalidProps.length > 1) { + error('Invalid aria props %s on <%s> tag. ' + 'For details, see https://reactjs.org/link/invalid-aria-props', unknownPropString, type); + } + } + } + + function validateProperties(type, props) { + if (isCustomComponent(type, props)) { + return; + } + + warnInvalidARIAProps(type, props); + } + + var didWarnValueNull = false; + function validateProperties$1(type, props) { + { + if (type !== 'input' && type !== 'textarea' && type !== 'select') { + return; + } + + if (props != null && props.value === null && !didWarnValueNull) { + didWarnValueNull = true; + + if (type === 'select' && props.multiple) { + error('`value` prop on `%s` should not be null. ' + 'Consider using an empty array when `multiple` is set to `true` ' + 'to clear the component or `undefined` for uncontrolled components.', type); + } else { + error('`value` prop on `%s` should not be null. ' + 'Consider using an empty string to clear the component or `undefined` ' + 'for uncontrolled components.', type); + } + } + } + } + + var validateProperty$1 = function () {}; + + { + var warnedProperties$1 = {}; + var _hasOwnProperty = Object.prototype.hasOwnProperty; + var EVENT_NAME_REGEX = /^on./; + var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/; + var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$'); + var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$'); + + validateProperty$1 = function (tagName, name, value, eventRegistry) { + if (_hasOwnProperty.call(warnedProperties$1, name) && warnedProperties$1[name]) { + return true; + } + + var lowerCasedName = name.toLowerCase(); + + if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') { + error('React uses onFocus and onBlur instead of onFocusIn and onFocusOut. ' + 'All React events are normalized to bubble, so onFocusIn and onFocusOut ' + 'are not needed/supported by React.'); + + warnedProperties$1[name] = true; + return true; + } // We can't rely on the event system being injected on the server. + + + if (eventRegistry != null) { + var registrationNameDependencies = eventRegistry.registrationNameDependencies, + possibleRegistrationNames = eventRegistry.possibleRegistrationNames; + + if (registrationNameDependencies.hasOwnProperty(name)) { + return true; + } + + var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null; + + if (registrationName != null) { + error('Invalid event handler property `%s`. Did you mean `%s`?', name, registrationName); + + warnedProperties$1[name] = true; + return true; + } + + if (EVENT_NAME_REGEX.test(name)) { + error('Unknown event handler property `%s`. It will be ignored.', name); + + warnedProperties$1[name] = true; + return true; + } + } else if (EVENT_NAME_REGEX.test(name)) { + // If no event plugins have been injected, we are in a server environment. + // So we can't tell if the event name is correct for sure, but we can filter + // out known bad ones like `onclick`. We can't suggest a specific replacement though. + if (INVALID_EVENT_NAME_REGEX.test(name)) { + error('Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.', name); + } + + warnedProperties$1[name] = true; + return true; + } // Let the ARIA attribute hook validate ARIA attributes + + + if (rARIA$1.test(name) || rARIACamel$1.test(name)) { + return true; + } + + if (lowerCasedName === 'innerhtml') { + error('Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.'); + + warnedProperties$1[name] = true; + return true; + } + + if (lowerCasedName === 'aria') { + error('The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.'); + + warnedProperties$1[name] = true; + return true; + } + + if (lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string') { + error('Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.', typeof value); + + warnedProperties$1[name] = true; + return true; + } + + if (typeof value === 'number' && isNaN(value)) { + error('Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.', name); + + warnedProperties$1[name] = true; + return true; + } + + var propertyInfo = getPropertyInfo(name); + var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED; // Known attributes should match the casing specified in the property config. + + if (possibleStandardNames.hasOwnProperty(lowerCasedName)) { + var standardName = possibleStandardNames[lowerCasedName]; + + if (standardName !== name) { + error('Invalid DOM property `%s`. Did you mean `%s`?', name, standardName); + + warnedProperties$1[name] = true; + return true; + } + } else if (!isReserved && name !== lowerCasedName) { + // Unknown attributes should have lowercase casing since that's how they + // will be cased anyway with server rendering. + error('React does not recognize the `%s` prop on a DOM element. If you ' + 'intentionally want it to appear in the DOM as a custom ' + 'attribute, spell it as lowercase `%s` instead. ' + 'If you accidentally passed it from a parent component, remove ' + 'it from the DOM element.', name, lowerCasedName); + + warnedProperties$1[name] = true; + return true; + } + + if (typeof value === 'boolean' && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) { + if (value) { + error('Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.', value, name, name, value, name); + } else { + error('Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.\n\n' + 'If you used to conditionally omit it with %s={condition && value}, ' + 'pass %s={condition ? value : undefined} instead.', value, name, name, value, name, name, name); + } + + warnedProperties$1[name] = true; + return true; + } // Now that we've validated casing, do not validate + // data types for reserved props + + + if (isReserved) { + return true; + } // Warn when a known attribute is a bad type + + + if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) { + warnedProperties$1[name] = true; + return false; + } // Warn when passing the strings 'false' or 'true' into a boolean prop + + + if ((value === 'false' || value === 'true') && propertyInfo !== null && propertyInfo.type === BOOLEAN) { + error('Received the string `%s` for the boolean attribute `%s`. ' + '%s ' + 'Did you mean %s={%s}?', value, name, value === 'false' ? 'The browser will interpret it as a truthy value.' : 'Although this works, it will not work as expected if you pass the string "false".', name, value); + + warnedProperties$1[name] = true; + return true; + } + + return true; + }; + } + + var warnUnknownProperties = function (type, props, eventRegistry) { + { + var unknownProps = []; + + for (var key in props) { + var isValid = validateProperty$1(type, key, props[key], eventRegistry); + + if (!isValid) { + unknownProps.push(key); + } + } + + var unknownPropString = unknownProps.map(function (prop) { + return '`' + prop + '`'; + }).join(', '); + + if (unknownProps.length === 1) { + error('Invalid value for prop %s on <%s> tag. Either remove it from the element, ' + 'or pass a string or number value to keep it in the DOM. ' + 'For details, see https://reactjs.org/link/attribute-behavior ', unknownPropString, type); + } else if (unknownProps.length > 1) { + error('Invalid values for props %s on <%s> tag. Either remove them from the element, ' + 'or pass a string or number value to keep them in the DOM. ' + 'For details, see https://reactjs.org/link/attribute-behavior ', unknownPropString, type); + } + } + }; + + function validateProperties$2(type, props, eventRegistry) { + if (isCustomComponent(type, props)) { + return; + } + + warnUnknownProperties(type, props, eventRegistry); + } + + var IS_EVENT_HANDLE_NON_MANAGED_NODE = 1; + var IS_NON_DELEGATED = 1 << 1; + var IS_CAPTURE_PHASE = 1 << 2; + var IS_REPLAYED = 1 << 4; + // set to LEGACY_FB_SUPPORT. LEGACY_FB_SUPPORT only gets set when + // we call willDeferLaterForLegacyFBSupport, thus not bailing out + // will result in endless cycles like an infinite loop. + // We also don't want to defer during event replaying. + + var SHOULD_NOT_PROCESS_POLYFILL_EVENT_PLUGINS = IS_EVENT_HANDLE_NON_MANAGED_NODE | IS_NON_DELEGATED | IS_CAPTURE_PHASE; + + /** + * Gets the target node from a native browser event by accounting for + * inconsistencies in browser DOM APIs. + * + * @param {object} nativeEvent Native browser event. + * @return {DOMEventTarget} Target node. + */ + + function getEventTarget(nativeEvent) { + // Fallback to nativeEvent.srcElement for IE9 + // https://github.com/facebook/react/issues/12506 + var target = nativeEvent.target || nativeEvent.srcElement || window; // Normalize SVG <use> element events #4963 + + if (target.correspondingUseElement) { + target = target.correspondingUseElement; + } // Safari may fire events on text nodes (Node.TEXT_NODE is 3). + // @see http://www.quirksmode.org/js/events_properties.html + + + return target.nodeType === TEXT_NODE ? target.parentNode : target; + } + + var restoreImpl = null; + var restoreTarget = null; + var restoreQueue = null; + + function restoreStateOfTarget(target) { + // We perform this translation at the end of the event loop so that we + // always receive the correct fiber here + var internalInstance = getInstanceFromNode(target); + + if (!internalInstance) { + // Unmounted + return; + } + + if (!(typeof restoreImpl === 'function')) { + { + throw Error( "setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue." ); + } + } + + var stateNode = internalInstance.stateNode; // Guard against Fiber being unmounted. + + if (stateNode) { + var _props = getFiberCurrentPropsFromNode(stateNode); + + restoreImpl(internalInstance.stateNode, internalInstance.type, _props); + } + } + + function setRestoreImplementation(impl) { + restoreImpl = impl; + } + function enqueueStateRestore(target) { + if (restoreTarget) { + if (restoreQueue) { + restoreQueue.push(target); + } else { + restoreQueue = [target]; + } + } else { + restoreTarget = target; + } + } + function needsStateRestore() { + return restoreTarget !== null || restoreQueue !== null; + } + function restoreStateIfNeeded() { + if (!restoreTarget) { + return; + } + + var target = restoreTarget; + var queuedTargets = restoreQueue; + restoreTarget = null; + restoreQueue = null; + restoreStateOfTarget(target); + + if (queuedTargets) { + for (var i = 0; i < queuedTargets.length; i++) { + restoreStateOfTarget(queuedTargets[i]); + } + } + } + + // the renderer. Such as when we're dispatching events or if third party + // libraries need to call batchedUpdates. Eventually, this API will go away when + // everything is batched by default. We'll then have a similar API to opt-out of + // scheduled work and instead do synchronous work. + // Defaults + + var batchedUpdatesImpl = function (fn, bookkeeping) { + return fn(bookkeeping); + }; + + var discreteUpdatesImpl = function (fn, a, b, c, d) { + return fn(a, b, c, d); + }; + + var flushDiscreteUpdatesImpl = function () {}; + + var batchedEventUpdatesImpl = batchedUpdatesImpl; + var isInsideEventHandler = false; + var isBatchingEventUpdates = false; + + function finishEventHandler() { + // Here we wait until all updates have propagated, which is important + // when using controlled components within layers: + // https://github.com/facebook/react/issues/1698 + // Then we restore state of any controlled component. + var controlledComponentsHavePendingUpdates = needsStateRestore(); + + if (controlledComponentsHavePendingUpdates) { + // If a controlled event was fired, we may need to restore the state of + // the DOM node back to the controlled value. This is necessary when React + // bails out of the update without touching the DOM. + flushDiscreteUpdatesImpl(); + restoreStateIfNeeded(); + } + } + + function batchedUpdates(fn, bookkeeping) { + if (isInsideEventHandler) { + // If we are currently inside another batch, we need to wait until it + // fully completes before restoring state. + return fn(bookkeeping); + } + + isInsideEventHandler = true; + + try { + return batchedUpdatesImpl(fn, bookkeeping); + } finally { + isInsideEventHandler = false; + finishEventHandler(); + } + } + function batchedEventUpdates(fn, a, b) { + if (isBatchingEventUpdates) { + // If we are currently inside another batch, we need to wait until it + // fully completes before restoring state. + return fn(a, b); + } + + isBatchingEventUpdates = true; + + try { + return batchedEventUpdatesImpl(fn, a, b); + } finally { + isBatchingEventUpdates = false; + finishEventHandler(); + } + } + function discreteUpdates(fn, a, b, c, d) { + var prevIsInsideEventHandler = isInsideEventHandler; + isInsideEventHandler = true; + + try { + return discreteUpdatesImpl(fn, a, b, c, d); + } finally { + isInsideEventHandler = prevIsInsideEventHandler; + + if (!isInsideEventHandler) { + finishEventHandler(); + } + } + } + function flushDiscreteUpdatesIfNeeded(timeStamp) { + { + if (!isInsideEventHandler) { + flushDiscreteUpdatesImpl(); + } + } + } + function setBatchingImplementation(_batchedUpdatesImpl, _discreteUpdatesImpl, _flushDiscreteUpdatesImpl, _batchedEventUpdatesImpl) { + batchedUpdatesImpl = _batchedUpdatesImpl; + discreteUpdatesImpl = _discreteUpdatesImpl; + flushDiscreteUpdatesImpl = _flushDiscreteUpdatesImpl; + batchedEventUpdatesImpl = _batchedEventUpdatesImpl; + } + + function isInteractive(tag) { + return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea'; + } + + function shouldPreventMouseEvent(name, type, props) { + switch (name) { + case 'onClick': + case 'onClickCapture': + case 'onDoubleClick': + case 'onDoubleClickCapture': + case 'onMouseDown': + case 'onMouseDownCapture': + case 'onMouseMove': + case 'onMouseMoveCapture': + case 'onMouseUp': + case 'onMouseUpCapture': + case 'onMouseEnter': + return !!(props.disabled && isInteractive(type)); + + default: + return false; + } + } + /** + * @param {object} inst The instance, which is the source of events. + * @param {string} registrationName Name of listener (e.g. `onClick`). + * @return {?function} The stored callback. + */ + + + function getListener(inst, registrationName) { + var stateNode = inst.stateNode; + + if (stateNode === null) { + // Work in progress (ex: onload events in incremental mode). + return null; + } + + var props = getFiberCurrentPropsFromNode(stateNode); + + if (props === null) { + // Work in progress. + return null; + } + + var listener = props[registrationName]; + + if (shouldPreventMouseEvent(registrationName, inst.type, props)) { + return null; + } + + if (!(!listener || typeof listener === 'function')) { + { + throw Error( "Expected `" + registrationName + "` listener to be a function, instead got a value of `" + typeof listener + "` type." ); + } + } + + return listener; + } + + var passiveBrowserEventsSupported = false; // Check if browser support events with passive listeners + // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support + + if (canUseDOM) { + try { + var options = {}; // $FlowFixMe: Ignore Flow complaining about needing a value + + Object.defineProperty(options, 'passive', { + get: function () { + passiveBrowserEventsSupported = true; + } + }); + window.addEventListener('test', options, options); + window.removeEventListener('test', options, options); + } catch (e) { + passiveBrowserEventsSupported = false; + } + } + + function invokeGuardedCallbackProd(name, func, context, a, b, c, d, e, f) { + var funcArgs = Array.prototype.slice.call(arguments, 3); + + try { + func.apply(context, funcArgs); + } catch (error) { + this.onError(error); + } + } + + var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; + + { + // In DEV mode, we swap out invokeGuardedCallback for a special version + // that plays more nicely with the browser's DevTools. The idea is to preserve + // "Pause on exceptions" behavior. Because React wraps all user-provided + // functions in invokeGuardedCallback, and the production version of + // invokeGuardedCallback uses a try-catch, all user exceptions are treated + // like caught exceptions, and the DevTools won't pause unless the developer + // takes the extra step of enabling pause on caught exceptions. This is + // unintuitive, though, because even though React has caught the error, from + // the developer's perspective, the error is uncaught. + // + // To preserve the expected "Pause on exceptions" behavior, we don't use a + // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake + // DOM node, and call the user-provided callback from inside an event handler + // for that fake event. If the callback throws, the error is "captured" using + // a global event handler. But because the error happens in a different + // event loop context, it does not interrupt the normal program flow. + // Effectively, this gives us try-catch behavior without actually using + // try-catch. Neat! + // Check that the browser supports the APIs we need to implement our special + // DEV version of invokeGuardedCallback + if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') { + var fakeNode = document.createElement('react'); + + invokeGuardedCallbackImpl = function invokeGuardedCallbackDev(name, func, context, a, b, c, d, e, f) { + // If document doesn't exist we know for sure we will crash in this method + // when we call document.createEvent(). However this can cause confusing + // errors: https://github.com/facebookincubator/create-react-app/issues/3482 + // So we preemptively throw with a better message instead. + if (!(typeof document !== 'undefined')) { + { + throw Error( "The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous." ); + } + } + + var evt = document.createEvent('Event'); + var didCall = false; // Keeps track of whether the user-provided callback threw an error. We + // set this to true at the beginning, then set it to false right after + // calling the function. If the function errors, `didError` will never be + // set to false. This strategy works even if the browser is flaky and + // fails to call our global error handler, because it doesn't rely on + // the error event at all. + + var didError = true; // Keeps track of the value of window.event so that we can reset it + // during the callback to let user code access window.event in the + // browsers that support it. + + var windowEvent = window.event; // Keeps track of the descriptor of window.event to restore it after event + // dispatching: https://github.com/facebook/react/issues/13688 + + var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event'); + + function restoreAfterDispatch() { + // We immediately remove the callback from event listeners so that + // nested `invokeGuardedCallback` calls do not clash. Otherwise, a + // nested call would trigger the fake event handlers of any call higher + // in the stack. + fakeNode.removeEventListener(evtType, callCallback, false); // We check for window.hasOwnProperty('event') to prevent the + // window.event assignment in both IE <= 10 as they throw an error + // "Member not found" in strict mode, and in Firefox which does not + // support window.event. + + if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) { + window.event = windowEvent; + } + } // Create an event handler for our fake event. We will synchronously + // dispatch our fake event using `dispatchEvent`. Inside the handler, we + // call the user-provided callback. + + + var funcArgs = Array.prototype.slice.call(arguments, 3); + + function callCallback() { + didCall = true; + restoreAfterDispatch(); + func.apply(context, funcArgs); + didError = false; + } // Create a global error event handler. We use this to capture the value + // that was thrown. It's possible that this error handler will fire more + // than once; for example, if non-React code also calls `dispatchEvent` + // and a handler for that event throws. We should be resilient to most of + // those cases. Even if our error event handler fires more than once, the + // last error event is always used. If the callback actually does error, + // we know that the last error event is the correct one, because it's not + // possible for anything else to have happened in between our callback + // erroring and the code that follows the `dispatchEvent` call below. If + // the callback doesn't error, but the error event was fired, we know to + // ignore it because `didError` will be false, as described above. + + + var error; // Use this to track whether the error event is ever called. + + var didSetError = false; + var isCrossOriginError = false; + + function handleWindowError(event) { + error = event.error; + didSetError = true; + + if (error === null && event.colno === 0 && event.lineno === 0) { + isCrossOriginError = true; + } + + if (event.defaultPrevented) { + // Some other error handler has prevented default. + // Browsers silence the error report if this happens. + // We'll remember this to later decide whether to log it or not. + if (error != null && typeof error === 'object') { + try { + error._suppressLogging = true; + } catch (inner) {// Ignore. + } + } + } + } // Create a fake event type. + + + var evtType = "react-" + (name ? name : 'invokeguardedcallback'); // Attach our event handlers + + window.addEventListener('error', handleWindowError); + fakeNode.addEventListener(evtType, callCallback, false); // Synchronously dispatch our fake event. If the user-provided function + // errors, it will trigger our global error handler. + + evt.initEvent(evtType, false, false); + fakeNode.dispatchEvent(evt); + + if (windowEventDescriptor) { + Object.defineProperty(window, 'event', windowEventDescriptor); + } + + if (didCall && didError) { + if (!didSetError) { + // The callback errored, but the error event never fired. + error = new Error('An error was thrown inside one of your components, but React ' + "doesn't know what it was. This is likely due to browser " + 'flakiness. React does its best to preserve the "Pause on ' + 'exceptions" behavior of the DevTools, which requires some ' + "DEV-mode only tricks. It's possible that these don't work in " + 'your browser. Try triggering the error in production mode, ' + 'or switching to a modern browser. If you suspect that this is ' + 'actually an issue with React, please file an issue.'); + } else if (isCrossOriginError) { + error = new Error("A cross-origin error was thrown. React doesn't have access to " + 'the actual error object in development. ' + 'See https://reactjs.org/link/crossorigin-error for more information.'); + } + + this.onError(error); + } // Remove our event listeners + + + window.removeEventListener('error', handleWindowError); + + if (!didCall) { + // Something went really wrong, and our event was not dispatched. + // https://github.com/facebook/react/issues/16734 + // https://github.com/facebook/react/issues/16585 + // Fall back to the production implementation. + restoreAfterDispatch(); + return invokeGuardedCallbackProd.apply(this, arguments); + } + }; + } + } + + var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl; + + var hasError = false; + var caughtError = null; // Used by event system to capture/rethrow the first error. + + var hasRethrowError = false; + var rethrowError = null; + var reporter = { + onError: function (error) { + hasError = true; + caughtError = error; + } + }; + /** + * Call a function while guarding against errors that happens within it. + * Returns an error if it throws, otherwise null. + * + * In production, this is implemented using a try-catch. The reason we don't + * use a try-catch directly is so that we can swap out a different + * implementation in DEV mode. + * + * @param {String} name of the guard to use for logging or debugging + * @param {Function} func The function to invoke + * @param {*} context The context to use when calling the function + * @param {...*} args Arguments for function + */ + + function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { + hasError = false; + caughtError = null; + invokeGuardedCallbackImpl$1.apply(reporter, arguments); + } + /** + * Same as invokeGuardedCallback, but instead of returning an error, it stores + * it in a global so it can be rethrown by `rethrowCaughtError` later. + * TODO: See if caughtError and rethrowError can be unified. + * + * @param {String} name of the guard to use for logging or debugging + * @param {Function} func The function to invoke + * @param {*} context The context to use when calling the function + * @param {...*} args Arguments for function + */ + + function invokeGuardedCallbackAndCatchFirstError(name, func, context, a, b, c, d, e, f) { + invokeGuardedCallback.apply(this, arguments); + + if (hasError) { + var error = clearCaughtError(); + + if (!hasRethrowError) { + hasRethrowError = true; + rethrowError = error; + } + } + } + /** + * During execution of guarded functions we will capture the first error which + * we will rethrow to be handled by the top level error handler. + */ + + function rethrowCaughtError() { + if (hasRethrowError) { + var error = rethrowError; + hasRethrowError = false; + rethrowError = null; + throw error; + } + } + function hasCaughtError() { + return hasError; + } + function clearCaughtError() { + if (hasError) { + var error = caughtError; + hasError = false; + caughtError = null; + return error; + } else { + { + { + throw Error( "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." ); + } + } + } + } + + var ReactInternals$1 = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; + var _ReactInternals$Sched = ReactInternals$1.Scheduler, + unstable_cancelCallback = _ReactInternals$Sched.unstable_cancelCallback, + unstable_now = _ReactInternals$Sched.unstable_now, + unstable_scheduleCallback = _ReactInternals$Sched.unstable_scheduleCallback, + unstable_shouldYield = _ReactInternals$Sched.unstable_shouldYield, + unstable_requestPaint = _ReactInternals$Sched.unstable_requestPaint, + unstable_getFirstCallbackNode = _ReactInternals$Sched.unstable_getFirstCallbackNode, + unstable_runWithPriority = _ReactInternals$Sched.unstable_runWithPriority, + unstable_next = _ReactInternals$Sched.unstable_next, + unstable_continueExecution = _ReactInternals$Sched.unstable_continueExecution, + unstable_pauseExecution = _ReactInternals$Sched.unstable_pauseExecution, + unstable_getCurrentPriorityLevel = _ReactInternals$Sched.unstable_getCurrentPriorityLevel, + unstable_ImmediatePriority = _ReactInternals$Sched.unstable_ImmediatePriority, + unstable_UserBlockingPriority = _ReactInternals$Sched.unstable_UserBlockingPriority, + unstable_NormalPriority = _ReactInternals$Sched.unstable_NormalPriority, + unstable_LowPriority = _ReactInternals$Sched.unstable_LowPriority, + unstable_IdlePriority = _ReactInternals$Sched.unstable_IdlePriority, + unstable_forceFrameRate = _ReactInternals$Sched.unstable_forceFrameRate, + unstable_flushAllWithoutAsserting = _ReactInternals$Sched.unstable_flushAllWithoutAsserting; + + /** + * `ReactInstanceMap` maintains a mapping from a public facing stateful + * instance (key) and the internal representation (value). This allows public + * methods to accept the user facing instance as an argument and map them back + * to internal methods. + * + * Note that this module is currently shared and assumed to be stateless. + * If this becomes an actual Map, that will break. + */ + function get(key) { + return key._reactInternals; + } + function has(key) { + return key._reactInternals !== undefined; + } + function set(key, value) { + key._reactInternals = value; + } + + // Don't change these two values. They're used by React Dev Tools. + var NoFlags = + /* */ + 0; + var PerformedWork = + /* */ + 1; // You can change the rest (and add more). + + var Placement = + /* */ + 2; + var Update = + /* */ + 4; + var PlacementAndUpdate = + /* */ + 6; + var Deletion = + /* */ + 8; + var ContentReset = + /* */ + 16; + var Callback = + /* */ + 32; + var DidCapture = + /* */ + 64; + var Ref = + /* */ + 128; + var Snapshot = + /* */ + 256; + var Passive = + /* */ + 512; // TODO (effects) Remove this bit once the new reconciler is synced to the old. + + var PassiveUnmountPendingDev = + /* */ + 8192; + var Hydrating = + /* */ + 1024; + var HydratingAndUpdate = + /* */ + 1028; // Passive & Update & Callback & Ref & Snapshot + + var LifecycleEffectMask = + /* */ + 932; // Union of all host effects + + var HostEffectMask = + /* */ + 2047; // These are not really side effects, but we still reuse this field. + + var Incomplete = + /* */ + 2048; + var ShouldCapture = + /* */ + 4096; + var ForceUpdateForLegacySuspense = + /* */ + 16384; // Static tags describe aspects of a fiber that are not specific to a render, + + var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; + function getNearestMountedFiber(fiber) { + var node = fiber; + var nearestMounted = fiber; + + if (!fiber.alternate) { + // If there is no alternate, this might be a new tree that isn't inserted + // yet. If it is, then it will have a pending insertion effect on it. + var nextNode = node; + + do { + node = nextNode; + + if ((node.flags & (Placement | Hydrating)) !== NoFlags) { + // This is an insertion or in-progress hydration. The nearest possible + // mounted fiber is the parent but we need to continue to figure out + // if that one is still mounted. + nearestMounted = node.return; + } + + nextNode = node.return; + } while (nextNode); + } else { + while (node.return) { + node = node.return; + } + } + + if (node.tag === HostRoot) { + // TODO: Check if this was a nested HostRoot when used with + // renderContainerIntoSubtree. + return nearestMounted; + } // If we didn't hit the root, that means that we're in an disconnected tree + // that has been unmounted. + + + return null; + } + function getSuspenseInstanceFromFiber(fiber) { + if (fiber.tag === SuspenseComponent) { + var suspenseState = fiber.memoizedState; + + if (suspenseState === null) { + var current = fiber.alternate; + + if (current !== null) { + suspenseState = current.memoizedState; + } + } + + if (suspenseState !== null) { + return suspenseState.dehydrated; + } + } + + return null; + } + function getContainerFromFiber(fiber) { + return fiber.tag === HostRoot ? fiber.stateNode.containerInfo : null; + } + function isFiberMounted(fiber) { + return getNearestMountedFiber(fiber) === fiber; + } + function isMounted(component) { + { + var owner = ReactCurrentOwner.current; + + if (owner !== null && owner.tag === ClassComponent) { + var ownerFiber = owner; + var instance = ownerFiber.stateNode; + + if (!instance._warnedAboutRefsInRender) { + error('%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(ownerFiber.type) || 'A component'); + } + + instance._warnedAboutRefsInRender = true; + } + } + + var fiber = get(component); + + if (!fiber) { + return false; + } + + return getNearestMountedFiber(fiber) === fiber; + } + + function assertIsMounted(fiber) { + if (!(getNearestMountedFiber(fiber) === fiber)) { + { + throw Error( "Unable to find node on an unmounted component." ); + } + } + } + + function findCurrentFiberUsingSlowPath(fiber) { + var alternate = fiber.alternate; + + if (!alternate) { + // If there is no alternate, then we only need to check if it is mounted. + var nearestMounted = getNearestMountedFiber(fiber); + + if (!(nearestMounted !== null)) { + { + throw Error( "Unable to find node on an unmounted component." ); + } + } + + if (nearestMounted !== fiber) { + return null; + } + + return fiber; + } // If we have two possible branches, we'll walk backwards up to the root + // to see what path the root points to. On the way we may hit one of the + // special cases and we'll deal with them. + + + var a = fiber; + var b = alternate; + + while (true) { + var parentA = a.return; + + if (parentA === null) { + // We're at the root. + break; + } + + var parentB = parentA.alternate; + + if (parentB === null) { + // There is no alternate. This is an unusual case. Currently, it only + // happens when a Suspense component is hidden. An extra fragment fiber + // is inserted in between the Suspense fiber and its children. Skip + // over this extra fragment fiber and proceed to the next parent. + var nextParent = parentA.return; + + if (nextParent !== null) { + a = b = nextParent; + continue; + } // If there's no parent, we're at the root. + + + break; + } // If both copies of the parent fiber point to the same child, we can + // assume that the child is current. This happens when we bailout on low + // priority: the bailed out fiber's child reuses the current child. + + + if (parentA.child === parentB.child) { + var child = parentA.child; + + while (child) { + if (child === a) { + // We've determined that A is the current branch. + assertIsMounted(parentA); + return fiber; + } + + if (child === b) { + // We've determined that B is the current branch. + assertIsMounted(parentA); + return alternate; + } + + child = child.sibling; + } // We should never have an alternate for any mounting node. So the only + // way this could possibly happen is if this was unmounted, if at all. + + + { + { + throw Error( "Unable to find node on an unmounted component." ); + } + } + } + + if (a.return !== b.return) { + // The return pointer of A and the return pointer of B point to different + // fibers. We assume that return pointers never criss-cross, so A must + // belong to the child set of A.return, and B must belong to the child + // set of B.return. + a = parentA; + b = parentB; + } else { + // The return pointers point to the same fiber. We'll have to use the + // default, slow path: scan the child sets of each parent alternate to see + // which child belongs to which set. + // + // Search parent A's child set + var didFindChild = false; + var _child = parentA.child; + + while (_child) { + if (_child === a) { + didFindChild = true; + a = parentA; + b = parentB; + break; + } + + if (_child === b) { + didFindChild = true; + b = parentA; + a = parentB; + break; + } + + _child = _child.sibling; + } + + if (!didFindChild) { + // Search parent B's child set + _child = parentB.child; + + while (_child) { + if (_child === a) { + didFindChild = true; + a = parentB; + b = parentA; + break; + } + + if (_child === b) { + didFindChild = true; + b = parentB; + a = parentA; + break; + } + + _child = _child.sibling; + } + + if (!didFindChild) { + { + throw Error( "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." ); + } + } + } + } + + if (!(a.alternate === b)) { + { + throw Error( "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." ); + } + } + } // If the root is not a host container, we're in a disconnected tree. I.e. + // unmounted. + + + if (!(a.tag === HostRoot)) { + { + throw Error( "Unable to find node on an unmounted component." ); + } + } + + if (a.stateNode.current === a) { + // We've determined that A is the current branch. + return fiber; + } // Otherwise B has to be current branch. + + + return alternate; + } + function findCurrentHostFiber(parent) { + var currentParent = findCurrentFiberUsingSlowPath(parent); + + if (!currentParent) { + return null; + } // Next we'll drill down this component to find the first HostComponent/Text. + + + var node = currentParent; + + while (true) { + if (node.tag === HostComponent || node.tag === HostText) { + return node; + } else if (node.child) { + node.child.return = node; + node = node.child; + continue; + } + + if (node === currentParent) { + return null; + } + + while (!node.sibling) { + if (!node.return || node.return === currentParent) { + return null; + } + + node = node.return; + } + + node.sibling.return = node.return; + node = node.sibling; + } // Flow needs the return null here, but ESLint complains about it. + // eslint-disable-next-line no-unreachable + + + return null; + } + function findCurrentHostFiberWithNoPortals(parent) { + var currentParent = findCurrentFiberUsingSlowPath(parent); + + if (!currentParent) { + return null; + } // Next we'll drill down this component to find the first HostComponent/Text. + + + var node = currentParent; + + while (true) { + if (node.tag === HostComponent || node.tag === HostText || enableFundamentalAPI ) { + return node; + } else if (node.child && node.tag !== HostPortal) { + node.child.return = node; + node = node.child; + continue; + } + + if (node === currentParent) { + return null; + } + + while (!node.sibling) { + if (!node.return || node.return === currentParent) { + return null; + } + + node = node.return; + } + + node.sibling.return = node.return; + node = node.sibling; + } // Flow needs the return null here, but ESLint complains about it. + // eslint-disable-next-line no-unreachable + + + return null; + } + function doesFiberContain(parentFiber, childFiber) { + var node = childFiber; + var parentFiberAlternate = parentFiber.alternate; + + while (node !== null) { + if (node === parentFiber || node === parentFiberAlternate) { + return true; + } + + node = node.return; + } + + return false; + } + + var attemptUserBlockingHydration; + function setAttemptUserBlockingHydration(fn) { + attemptUserBlockingHydration = fn; + } + var attemptContinuousHydration; + function setAttemptContinuousHydration(fn) { + attemptContinuousHydration = fn; + } + var attemptHydrationAtCurrentPriority; + function setAttemptHydrationAtCurrentPriority(fn) { + attemptHydrationAtCurrentPriority = fn; + } + var attemptHydrationAtPriority; + function setAttemptHydrationAtPriority(fn) { + attemptHydrationAtPriority = fn; + } // TODO: Upgrade this definition once we're on a newer version of Flow that + var hasScheduledReplayAttempt = false; // The queue of discrete events to be replayed. + + var queuedDiscreteEvents = []; // Indicates if any continuous event targets are non-null for early bailout. + // if the last target was dehydrated. + + var queuedFocus = null; + var queuedDrag = null; + var queuedMouse = null; // For pointer events there can be one latest event per pointerId. + + var queuedPointers = new Map(); + var queuedPointerCaptures = new Map(); // We could consider replaying selectionchange and touchmoves too. + + var queuedExplicitHydrationTargets = []; + function hasQueuedDiscreteEvents() { + return queuedDiscreteEvents.length > 0; + } + var discreteReplayableEvents = ['mousedown', 'mouseup', 'touchcancel', 'touchend', 'touchstart', 'auxclick', 'dblclick', 'pointercancel', 'pointerdown', 'pointerup', 'dragend', 'dragstart', 'drop', 'compositionend', 'compositionstart', 'keydown', 'keypress', 'keyup', 'input', 'textInput', // Intentionally camelCase + 'copy', 'cut', 'paste', 'click', 'change', 'contextmenu', 'reset', 'submit']; + function isReplayableDiscreteEvent(eventType) { + return discreteReplayableEvents.indexOf(eventType) > -1; + } + + function createQueuedReplayableEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) { + return { + blockedOn: blockedOn, + domEventName: domEventName, + eventSystemFlags: eventSystemFlags | IS_REPLAYED, + nativeEvent: nativeEvent, + targetContainers: [targetContainer] + }; + } + + function queueDiscreteEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) { + var queuedEvent = createQueuedReplayableEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent); + queuedDiscreteEvents.push(queuedEvent); + } // Resets the replaying for this type of continuous event to no event. + + function clearIfContinuousEvent(domEventName, nativeEvent) { + switch (domEventName) { + case 'focusin': + case 'focusout': + queuedFocus = null; + break; + + case 'dragenter': + case 'dragleave': + queuedDrag = null; + break; + + case 'mouseover': + case 'mouseout': + queuedMouse = null; + break; + + case 'pointerover': + case 'pointerout': + { + var pointerId = nativeEvent.pointerId; + queuedPointers.delete(pointerId); + break; + } + + case 'gotpointercapture': + case 'lostpointercapture': + { + var _pointerId = nativeEvent.pointerId; + queuedPointerCaptures.delete(_pointerId); + break; + } + } + } + + function accumulateOrCreateContinuousQueuedReplayableEvent(existingQueuedEvent, blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) { + if (existingQueuedEvent === null || existingQueuedEvent.nativeEvent !== nativeEvent) { + var queuedEvent = createQueuedReplayableEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent); + + if (blockedOn !== null) { + var _fiber2 = getInstanceFromNode(blockedOn); + + if (_fiber2 !== null) { + // Attempt to increase the priority of this target. + attemptContinuousHydration(_fiber2); + } + } + + return queuedEvent; + } // If we have already queued this exact event, then it's because + // the different event systems have different DOM event listeners. + // We can accumulate the flags, and the targetContainers, and + // store a single event to be replayed. + + + existingQueuedEvent.eventSystemFlags |= eventSystemFlags; + var targetContainers = existingQueuedEvent.targetContainers; + + if (targetContainer !== null && targetContainers.indexOf(targetContainer) === -1) { + targetContainers.push(targetContainer); + } + + return existingQueuedEvent; + } + + function queueIfContinuousEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) { + // These set relatedTarget to null because the replayed event will be treated as if we + // moved from outside the window (no target) onto the target once it hydrates. + // Instead of mutating we could clone the event. + switch (domEventName) { + case 'focusin': + { + var focusEvent = nativeEvent; + queuedFocus = accumulateOrCreateContinuousQueuedReplayableEvent(queuedFocus, blockedOn, domEventName, eventSystemFlags, targetContainer, focusEvent); + return true; + } + + case 'dragenter': + { + var dragEvent = nativeEvent; + queuedDrag = accumulateOrCreateContinuousQueuedReplayableEvent(queuedDrag, blockedOn, domEventName, eventSystemFlags, targetContainer, dragEvent); + return true; + } + + case 'mouseover': + { + var mouseEvent = nativeEvent; + queuedMouse = accumulateOrCreateContinuousQueuedReplayableEvent(queuedMouse, blockedOn, domEventName, eventSystemFlags, targetContainer, mouseEvent); + return true; + } + + case 'pointerover': + { + var pointerEvent = nativeEvent; + var pointerId = pointerEvent.pointerId; + queuedPointers.set(pointerId, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointers.get(pointerId) || null, blockedOn, domEventName, eventSystemFlags, targetContainer, pointerEvent)); + return true; + } + + case 'gotpointercapture': + { + var _pointerEvent = nativeEvent; + var _pointerId2 = _pointerEvent.pointerId; + queuedPointerCaptures.set(_pointerId2, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointerCaptures.get(_pointerId2) || null, blockedOn, domEventName, eventSystemFlags, targetContainer, _pointerEvent)); + return true; + } + } + + return false; + } // Check if this target is unblocked. Returns true if it's unblocked. + + function attemptExplicitHydrationTarget(queuedTarget) { + // TODO: This function shares a lot of logic with attemptToDispatchEvent. + // Try to unify them. It's a bit tricky since it would require two return + // values. + var targetInst = getClosestInstanceFromNode(queuedTarget.target); + + if (targetInst !== null) { + var nearestMounted = getNearestMountedFiber(targetInst); + + if (nearestMounted !== null) { + var tag = nearestMounted.tag; + + if (tag === SuspenseComponent) { + var instance = getSuspenseInstanceFromFiber(nearestMounted); + + if (instance !== null) { + // We're blocked on hydrating this boundary. + // Increase its priority. + queuedTarget.blockedOn = instance; + attemptHydrationAtPriority(queuedTarget.lanePriority, function () { + unstable_runWithPriority(queuedTarget.priority, function () { + attemptHydrationAtCurrentPriority(nearestMounted); + }); + }); + return; + } + } else if (tag === HostRoot) { + var root = nearestMounted.stateNode; + + if (root.hydrate) { + queuedTarget.blockedOn = getContainerFromFiber(nearestMounted); // We don't currently have a way to increase the priority of + // a root other than sync. + + return; + } + } + } + } + + queuedTarget.blockedOn = null; + } + + function attemptReplayContinuousQueuedEvent(queuedEvent) { + if (queuedEvent.blockedOn !== null) { + return false; + } + + var targetContainers = queuedEvent.targetContainers; + + while (targetContainers.length > 0) { + var targetContainer = targetContainers[0]; + var nextBlockedOn = attemptToDispatchEvent(queuedEvent.domEventName, queuedEvent.eventSystemFlags, targetContainer, queuedEvent.nativeEvent); + + if (nextBlockedOn !== null) { + // We're still blocked. Try again later. + var _fiber3 = getInstanceFromNode(nextBlockedOn); + + if (_fiber3 !== null) { + attemptContinuousHydration(_fiber3); + } + + queuedEvent.blockedOn = nextBlockedOn; + return false; + } // This target container was successfully dispatched. Try the next. + + + targetContainers.shift(); + } + + return true; + } + + function attemptReplayContinuousQueuedEventInMap(queuedEvent, key, map) { + if (attemptReplayContinuousQueuedEvent(queuedEvent)) { + map.delete(key); + } + } + + function replayUnblockedEvents() { + hasScheduledReplayAttempt = false; // First replay discrete events. + + while (queuedDiscreteEvents.length > 0) { + var nextDiscreteEvent = queuedDiscreteEvents[0]; + + if (nextDiscreteEvent.blockedOn !== null) { + // We're still blocked. + // Increase the priority of this boundary to unblock + // the next discrete event. + var _fiber4 = getInstanceFromNode(nextDiscreteEvent.blockedOn); + + if (_fiber4 !== null) { + attemptUserBlockingHydration(_fiber4); + } + + break; + } + + var targetContainers = nextDiscreteEvent.targetContainers; + + while (targetContainers.length > 0) { + var targetContainer = targetContainers[0]; + var nextBlockedOn = attemptToDispatchEvent(nextDiscreteEvent.domEventName, nextDiscreteEvent.eventSystemFlags, targetContainer, nextDiscreteEvent.nativeEvent); + + if (nextBlockedOn !== null) { + // We're still blocked. Try again later. + nextDiscreteEvent.blockedOn = nextBlockedOn; + break; + } // This target container was successfully dispatched. Try the next. + + + targetContainers.shift(); + } + + if (nextDiscreteEvent.blockedOn === null) { + // We've successfully replayed the first event. Let's try the next one. + queuedDiscreteEvents.shift(); + } + } // Next replay any continuous events. + + + if (queuedFocus !== null && attemptReplayContinuousQueuedEvent(queuedFocus)) { + queuedFocus = null; + } + + if (queuedDrag !== null && attemptReplayContinuousQueuedEvent(queuedDrag)) { + queuedDrag = null; + } + + if (queuedMouse !== null && attemptReplayContinuousQueuedEvent(queuedMouse)) { + queuedMouse = null; + } + + queuedPointers.forEach(attemptReplayContinuousQueuedEventInMap); + queuedPointerCaptures.forEach(attemptReplayContinuousQueuedEventInMap); + } + + function scheduleCallbackIfUnblocked(queuedEvent, unblocked) { + if (queuedEvent.blockedOn === unblocked) { + queuedEvent.blockedOn = null; + + if (!hasScheduledReplayAttempt) { + hasScheduledReplayAttempt = true; // Schedule a callback to attempt replaying as many events as are + // now unblocked. This first might not actually be unblocked yet. + // We could check it early to avoid scheduling an unnecessary callback. + + unstable_scheduleCallback(unstable_NormalPriority, replayUnblockedEvents); + } + } + } + + function retryIfBlockedOn(unblocked) { + // Mark anything that was blocked on this as no longer blocked + // and eligible for a replay. + if (queuedDiscreteEvents.length > 0) { + scheduleCallbackIfUnblocked(queuedDiscreteEvents[0], unblocked); // This is a exponential search for each boundary that commits. I think it's + // worth it because we expect very few discrete events to queue up and once + // we are actually fully unblocked it will be fast to replay them. + + for (var i = 1; i < queuedDiscreteEvents.length; i++) { + var queuedEvent = queuedDiscreteEvents[i]; + + if (queuedEvent.blockedOn === unblocked) { + queuedEvent.blockedOn = null; + } + } + } + + if (queuedFocus !== null) { + scheduleCallbackIfUnblocked(queuedFocus, unblocked); + } + + if (queuedDrag !== null) { + scheduleCallbackIfUnblocked(queuedDrag, unblocked); + } + + if (queuedMouse !== null) { + scheduleCallbackIfUnblocked(queuedMouse, unblocked); + } + + var unblock = function (queuedEvent) { + return scheduleCallbackIfUnblocked(queuedEvent, unblocked); + }; + + queuedPointers.forEach(unblock); + queuedPointerCaptures.forEach(unblock); + + for (var _i = 0; _i < queuedExplicitHydrationTargets.length; _i++) { + var queuedTarget = queuedExplicitHydrationTargets[_i]; + + if (queuedTarget.blockedOn === unblocked) { + queuedTarget.blockedOn = null; + } + } + + while (queuedExplicitHydrationTargets.length > 0) { + var nextExplicitTarget = queuedExplicitHydrationTargets[0]; + + if (nextExplicitTarget.blockedOn !== null) { + // We're still blocked. + break; + } else { + attemptExplicitHydrationTarget(nextExplicitTarget); + + if (nextExplicitTarget.blockedOn === null) { + // We're unblocked. + queuedExplicitHydrationTargets.shift(); + } + } + } + } + + var DiscreteEvent = 0; + var UserBlockingEvent = 1; + var ContinuousEvent = 2; + + /** + * Generate a mapping of standard vendor prefixes using the defined style property and event name. + * + * @param {string} styleProp + * @param {string} eventName + * @returns {object} + */ + + function makePrefixMap(styleProp, eventName) { + var prefixes = {}; + prefixes[styleProp.toLowerCase()] = eventName.toLowerCase(); + prefixes['Webkit' + styleProp] = 'webkit' + eventName; + prefixes['Moz' + styleProp] = 'moz' + eventName; + return prefixes; + } + /** + * A list of event names to a configurable list of vendor prefixes. + */ + + + var vendorPrefixes = { + animationend: makePrefixMap('Animation', 'AnimationEnd'), + animationiteration: makePrefixMap('Animation', 'AnimationIteration'), + animationstart: makePrefixMap('Animation', 'AnimationStart'), + transitionend: makePrefixMap('Transition', 'TransitionEnd') + }; + /** + * Event names that have already been detected and prefixed (if applicable). + */ + + var prefixedEventNames = {}; + /** + * Element to check for prefixes on. + */ + + var style = {}; + /** + * Bootstrap if a DOM exists. + */ + + if (canUseDOM) { + style = document.createElement('div').style; // On some platforms, in particular some releases of Android 4.x, + // the un-prefixed "animation" and "transition" properties are defined on the + // style object but the events that fire will still be prefixed, so we need + // to check if the un-prefixed events are usable, and if not remove them from the map. + + if (!('AnimationEvent' in window)) { + delete vendorPrefixes.animationend.animation; + delete vendorPrefixes.animationiteration.animation; + delete vendorPrefixes.animationstart.animation; + } // Same as above + + + if (!('TransitionEvent' in window)) { + delete vendorPrefixes.transitionend.transition; + } + } + /** + * Attempts to determine the correct vendor prefixed event name. + * + * @param {string} eventName + * @returns {string} + */ + + + function getVendorPrefixedEventName(eventName) { + if (prefixedEventNames[eventName]) { + return prefixedEventNames[eventName]; + } else if (!vendorPrefixes[eventName]) { + return eventName; + } + + var prefixMap = vendorPrefixes[eventName]; + + for (var styleProp in prefixMap) { + if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) { + return prefixedEventNames[eventName] = prefixMap[styleProp]; + } + } + + return eventName; + } + + var ANIMATION_END = getVendorPrefixedEventName('animationend'); + var ANIMATION_ITERATION = getVendorPrefixedEventName('animationiteration'); + var ANIMATION_START = getVendorPrefixedEventName('animationstart'); + var TRANSITION_END = getVendorPrefixedEventName('transitionend'); + + var topLevelEventsToReactNames = new Map(); + var eventPriorities = new Map(); // We store most of the events in this module in pairs of two strings so we can re-use + // the code required to apply the same logic for event prioritization and that of the + // SimpleEventPlugin. This complicates things slightly, but the aim is to reduce code + // duplication (for which there would be quite a bit). For the events that are not needed + // for the SimpleEventPlugin (otherDiscreteEvents) we process them separately as an + // array of top level events. + // Lastly, we ignore prettier so we can keep the formatting sane. + // prettier-ignore + + var discreteEventPairsForSimpleEventPlugin = ['cancel', 'cancel', 'click', 'click', 'close', 'close', 'contextmenu', 'contextMenu', 'copy', 'copy', 'cut', 'cut', 'auxclick', 'auxClick', 'dblclick', 'doubleClick', // Careful! + 'dragend', 'dragEnd', 'dragstart', 'dragStart', 'drop', 'drop', 'focusin', 'focus', // Careful! + 'focusout', 'blur', // Careful! + 'input', 'input', 'invalid', 'invalid', 'keydown', 'keyDown', 'keypress', 'keyPress', 'keyup', 'keyUp', 'mousedown', 'mouseDown', 'mouseup', 'mouseUp', 'paste', 'paste', 'pause', 'pause', 'play', 'play', 'pointercancel', 'pointerCancel', 'pointerdown', 'pointerDown', 'pointerup', 'pointerUp', 'ratechange', 'rateChange', 'reset', 'reset', 'seeked', 'seeked', 'submit', 'submit', 'touchcancel', 'touchCancel', 'touchend', 'touchEnd', 'touchstart', 'touchStart', 'volumechange', 'volumeChange']; + var otherDiscreteEvents = ['change', 'selectionchange', 'textInput', 'compositionstart', 'compositionend', 'compositionupdate']; + + + var userBlockingPairsForSimpleEventPlugin = ['drag', 'drag', 'dragenter', 'dragEnter', 'dragexit', 'dragExit', 'dragleave', 'dragLeave', 'dragover', 'dragOver', 'mousemove', 'mouseMove', 'mouseout', 'mouseOut', 'mouseover', 'mouseOver', 'pointermove', 'pointerMove', 'pointerout', 'pointerOut', 'pointerover', 'pointerOver', 'scroll', 'scroll', 'toggle', 'toggle', 'touchmove', 'touchMove', 'wheel', 'wheel']; // prettier-ignore + + var continuousPairsForSimpleEventPlugin = ['abort', 'abort', ANIMATION_END, 'animationEnd', ANIMATION_ITERATION, 'animationIteration', ANIMATION_START, 'animationStart', 'canplay', 'canPlay', 'canplaythrough', 'canPlayThrough', 'durationchange', 'durationChange', 'emptied', 'emptied', 'encrypted', 'encrypted', 'ended', 'ended', 'error', 'error', 'gotpointercapture', 'gotPointerCapture', 'load', 'load', 'loadeddata', 'loadedData', 'loadedmetadata', 'loadedMetadata', 'loadstart', 'loadStart', 'lostpointercapture', 'lostPointerCapture', 'playing', 'playing', 'progress', 'progress', 'seeking', 'seeking', 'stalled', 'stalled', 'suspend', 'suspend', 'timeupdate', 'timeUpdate', TRANSITION_END, 'transitionEnd', 'waiting', 'waiting']; + /** + * Turns + * ['abort', ...] + * + * into + * + * topLevelEventsToReactNames = new Map([ + * ['abort', 'onAbort'], + * ]); + * + * and registers them. + */ + + function registerSimplePluginEventsAndSetTheirPriorities(eventTypes, priority) { + // As the event types are in pairs of two, we need to iterate + // through in twos. The events are in pairs of two to save code + // and improve init perf of processing this array, as it will + // result in far fewer object allocations and property accesses + // if we only use three arrays to process all the categories of + // instead of tuples. + for (var i = 0; i < eventTypes.length; i += 2) { + var topEvent = eventTypes[i]; + var event = eventTypes[i + 1]; + var capitalizedEvent = event[0].toUpperCase() + event.slice(1); + var reactName = 'on' + capitalizedEvent; + eventPriorities.set(topEvent, priority); + topLevelEventsToReactNames.set(topEvent, reactName); + registerTwoPhaseEvent(reactName, [topEvent]); + } + } + + function setEventPriorities(eventTypes, priority) { + for (var i = 0; i < eventTypes.length; i++) { + eventPriorities.set(eventTypes[i], priority); + } + } + + function getEventPriorityForPluginSystem(domEventName) { + var priority = eventPriorities.get(domEventName); // Default to a ContinuousEvent. Note: we might + // want to warn if we can't detect the priority + // for the event. + + return priority === undefined ? ContinuousEvent : priority; + } + function registerSimpleEvents() { + registerSimplePluginEventsAndSetTheirPriorities(discreteEventPairsForSimpleEventPlugin, DiscreteEvent); + registerSimplePluginEventsAndSetTheirPriorities(userBlockingPairsForSimpleEventPlugin, UserBlockingEvent); + registerSimplePluginEventsAndSetTheirPriorities(continuousPairsForSimpleEventPlugin, ContinuousEvent); + setEventPriorities(otherDiscreteEvents, DiscreteEvent); + } + + var ReactInternals$2 = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; + var _ReactInternals$Sched$1 = ReactInternals$2.SchedulerTracing, + __interactionsRef = _ReactInternals$Sched$1.__interactionsRef, + __subscriberRef = _ReactInternals$Sched$1.__subscriberRef, + unstable_clear = _ReactInternals$Sched$1.unstable_clear, + unstable_getCurrent = _ReactInternals$Sched$1.unstable_getCurrent, + unstable_getThreadID = _ReactInternals$Sched$1.unstable_getThreadID, + unstable_subscribe = _ReactInternals$Sched$1.unstable_subscribe, + unstable_trace = _ReactInternals$Sched$1.unstable_trace, + unstable_unsubscribe = _ReactInternals$Sched$1.unstable_unsubscribe, + unstable_wrap = _ReactInternals$Sched$1.unstable_wrap; + + var Scheduler_now = unstable_now; + + { + // Provide explicit error message when production+profiling bundle of e.g. + // react-dom is used with production (non-profiling) bundle of + // scheduler/tracing + if (!(__interactionsRef != null && __interactionsRef.current != null)) { + { + throw Error( "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at https://reactjs.org/link/profiling" ); + } + } + } + // ascending numbers so we can compare them like numbers. They start at 90 to + // avoid clashing with Scheduler's priorities. + + var ImmediatePriority = 99; + var UserBlockingPriority = 98; + var NormalPriority = 97; + var LowPriority = 96; + var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only. + + var NoPriority = 90; + var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. + + var SyncLanePriority = 15; + var SyncBatchedLanePriority = 14; + var InputDiscreteHydrationLanePriority = 13; + var InputDiscreteLanePriority = 12; + var InputContinuousHydrationLanePriority = 11; + var InputContinuousLanePriority = 10; + var DefaultHydrationLanePriority = 9; + var DefaultLanePriority = 8; + var TransitionHydrationPriority = 7; + var TransitionPriority = 6; + var RetryLanePriority = 5; + var SelectiveHydrationLanePriority = 4; + var IdleHydrationLanePriority = 3; + var IdleLanePriority = 2; + var OffscreenLanePriority = 1; + var NoLanePriority = 0; + var TotalLanes = 31; + var NoLanes = + /* */ + 0; + var NoLane = + /* */ + 0; + var SyncLane = + /* */ + 1; + var SyncBatchedLane = + /* */ + 2; + var InputDiscreteHydrationLane = + /* */ + 4; + var InputDiscreteLanes = + /* */ + 24; + var InputContinuousHydrationLane = + /* */ + 32; + var InputContinuousLanes = + /* */ + 192; + var DefaultHydrationLane = + /* */ + 256; + var DefaultLanes = + /* */ + 3584; + var TransitionHydrationLane = + /* */ + 4096; + var TransitionLanes = + /* */ + 4186112; + var RetryLanes = + /* */ + 62914560; + var SomeRetryLane = + /* */ + 33554432; + var SelectiveHydrationLane = + /* */ + 67108864; + var NonIdleLanes = + /* */ + 134217727; + var IdleHydrationLane = + /* */ + 134217728; + var IdleLanes = + /* */ + 805306368; + var OffscreenLane = + /* */ + 1073741824; + var NoTimestamp = -1; + function setCurrentUpdateLanePriority(newLanePriority) { + } // "Registers" used to "return" multiple values + // Used by getHighestPriorityLanes and getNextLanes: + + var return_highestLanePriority = DefaultLanePriority; + + function getHighestPriorityLanes(lanes) { + if ((SyncLane & lanes) !== NoLanes) { + return_highestLanePriority = SyncLanePriority; + return SyncLane; + } + + if ((SyncBatchedLane & lanes) !== NoLanes) { + return_highestLanePriority = SyncBatchedLanePriority; + return SyncBatchedLane; + } + + if ((InputDiscreteHydrationLane & lanes) !== NoLanes) { + return_highestLanePriority = InputDiscreteHydrationLanePriority; + return InputDiscreteHydrationLane; + } + + var inputDiscreteLanes = InputDiscreteLanes & lanes; + + if (inputDiscreteLanes !== NoLanes) { + return_highestLanePriority = InputDiscreteLanePriority; + return inputDiscreteLanes; + } + + if ((lanes & InputContinuousHydrationLane) !== NoLanes) { + return_highestLanePriority = InputContinuousHydrationLanePriority; + return InputContinuousHydrationLane; + } + + var inputContinuousLanes = InputContinuousLanes & lanes; + + if (inputContinuousLanes !== NoLanes) { + return_highestLanePriority = InputContinuousLanePriority; + return inputContinuousLanes; + } + + if ((lanes & DefaultHydrationLane) !== NoLanes) { + return_highestLanePriority = DefaultHydrationLanePriority; + return DefaultHydrationLane; + } + + var defaultLanes = DefaultLanes & lanes; + + if (defaultLanes !== NoLanes) { + return_highestLanePriority = DefaultLanePriority; + return defaultLanes; + } + + if ((lanes & TransitionHydrationLane) !== NoLanes) { + return_highestLanePriority = TransitionHydrationPriority; + return TransitionHydrationLane; + } + + var transitionLanes = TransitionLanes & lanes; + + if (transitionLanes !== NoLanes) { + return_highestLanePriority = TransitionPriority; + return transitionLanes; + } + + var retryLanes = RetryLanes & lanes; + + if (retryLanes !== NoLanes) { + return_highestLanePriority = RetryLanePriority; + return retryLanes; + } + + if (lanes & SelectiveHydrationLane) { + return_highestLanePriority = SelectiveHydrationLanePriority; + return SelectiveHydrationLane; + } + + if ((lanes & IdleHydrationLane) !== NoLanes) { + return_highestLanePriority = IdleHydrationLanePriority; + return IdleHydrationLane; + } + + var idleLanes = IdleLanes & lanes; + + if (idleLanes !== NoLanes) { + return_highestLanePriority = IdleLanePriority; + return idleLanes; + } + + if ((OffscreenLane & lanes) !== NoLanes) { + return_highestLanePriority = OffscreenLanePriority; + return OffscreenLane; + } + + { + error('Should have found matching lanes. This is a bug in React.'); + } // This shouldn't be reachable, but as a fallback, return the entire bitmask. + + + return_highestLanePriority = DefaultLanePriority; + return lanes; + } + + function schedulerPriorityToLanePriority(schedulerPriorityLevel) { + switch (schedulerPriorityLevel) { + case ImmediatePriority: + return SyncLanePriority; + + case UserBlockingPriority: + return InputContinuousLanePriority; + + case NormalPriority: + case LowPriority: + // TODO: Handle LowSchedulerPriority, somehow. Maybe the same lane as hydration. + return DefaultLanePriority; + + case IdlePriority: + return IdleLanePriority; + + default: + return NoLanePriority; + } + } + function lanePriorityToSchedulerPriority(lanePriority) { + switch (lanePriority) { + case SyncLanePriority: + case SyncBatchedLanePriority: + return ImmediatePriority; + + case InputDiscreteHydrationLanePriority: + case InputDiscreteLanePriority: + case InputContinuousHydrationLanePriority: + case InputContinuousLanePriority: + return UserBlockingPriority; + + case DefaultHydrationLanePriority: + case DefaultLanePriority: + case TransitionHydrationPriority: + case TransitionPriority: + case SelectiveHydrationLanePriority: + case RetryLanePriority: + return NormalPriority; + + case IdleHydrationLanePriority: + case IdleLanePriority: + case OffscreenLanePriority: + return IdlePriority; + + case NoLanePriority: + return NoPriority; + + default: + { + { + throw Error( "Invalid update priority: " + lanePriority + ". This is a bug in React." ); + } + } + + } + } + function getNextLanes(root, wipLanes) { + // Early bailout if there's no pending work left. + var pendingLanes = root.pendingLanes; + + if (pendingLanes === NoLanes) { + return_highestLanePriority = NoLanePriority; + return NoLanes; + } + + var nextLanes = NoLanes; + var nextLanePriority = NoLanePriority; + var expiredLanes = root.expiredLanes; + var suspendedLanes = root.suspendedLanes; + var pingedLanes = root.pingedLanes; // Check if any work has expired. + + if (expiredLanes !== NoLanes) { + nextLanes = expiredLanes; + nextLanePriority = return_highestLanePriority = SyncLanePriority; + } else { + // Do not work on any idle work until all the non-idle work has finished, + // even if the work is suspended. + var nonIdlePendingLanes = pendingLanes & NonIdleLanes; + + if (nonIdlePendingLanes !== NoLanes) { + var nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes; + + if (nonIdleUnblockedLanes !== NoLanes) { + nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes); + nextLanePriority = return_highestLanePriority; + } else { + var nonIdlePingedLanes = nonIdlePendingLanes & pingedLanes; + + if (nonIdlePingedLanes !== NoLanes) { + nextLanes = getHighestPriorityLanes(nonIdlePingedLanes); + nextLanePriority = return_highestLanePriority; + } + } + } else { + // The only remaining work is Idle. + var unblockedLanes = pendingLanes & ~suspendedLanes; + + if (unblockedLanes !== NoLanes) { + nextLanes = getHighestPriorityLanes(unblockedLanes); + nextLanePriority = return_highestLanePriority; + } else { + if (pingedLanes !== NoLanes) { + nextLanes = getHighestPriorityLanes(pingedLanes); + nextLanePriority = return_highestLanePriority; + } + } + } + } + + if (nextLanes === NoLanes) { + // This should only be reachable if we're suspended + // TODO: Consider warning in this path if a fallback timer is not scheduled. + return NoLanes; + } // If there are higher priority lanes, we'll include them even if they + // are suspended. + + + nextLanes = pendingLanes & getEqualOrHigherPriorityLanes(nextLanes); // If we're already in the middle of a render, switching lanes will interrupt + // it and we'll lose our progress. We should only do this if the new lanes are + // higher priority. + + if (wipLanes !== NoLanes && wipLanes !== nextLanes && // If we already suspended with a delay, then interrupting is fine. Don't + // bother waiting until the root is complete. + (wipLanes & suspendedLanes) === NoLanes) { + getHighestPriorityLanes(wipLanes); + var wipLanePriority = return_highestLanePriority; + + if (nextLanePriority <= wipLanePriority) { + return wipLanes; + } else { + return_highestLanePriority = nextLanePriority; + } + } // Check for entangled lanes and add them to the batch. + // + // A lane is said to be entangled with another when it's not allowed to render + // in a batch that does not also include the other lane. Typically we do this + // when multiple updates have the same source, and we only want to respond to + // the most recent event from that source. + // + // Note that we apply entanglements *after* checking for partial work above. + // This means that if a lane is entangled during an interleaved event while + // it's already rendering, we won't interrupt it. This is intentional, since + // entanglement is usually "best effort": we'll try our best to render the + // lanes in the same batch, but it's not worth throwing out partially + // completed work in order to do it. + // + // For those exceptions where entanglement is semantically important, like + // useMutableSource, we should ensure that there is no partial work at the + // time we apply the entanglement. + + + var entangledLanes = root.entangledLanes; + + if (entangledLanes !== NoLanes) { + var entanglements = root.entanglements; + var lanes = nextLanes & entangledLanes; + + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + nextLanes |= entanglements[index]; + lanes &= ~lane; + } + } + + return nextLanes; + } + function getMostRecentEventTime(root, lanes) { + var eventTimes = root.eventTimes; + var mostRecentEventTime = NoTimestamp; + + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + var eventTime = eventTimes[index]; + + if (eventTime > mostRecentEventTime) { + mostRecentEventTime = eventTime; + } + + lanes &= ~lane; + } + + return mostRecentEventTime; + } + + function computeExpirationTime(lane, currentTime) { + // TODO: Expiration heuristic is constant per lane, so could use a map. + getHighestPriorityLanes(lane); + var priority = return_highestLanePriority; + + if (priority >= InputContinuousLanePriority) { + // User interactions should expire slightly more quickly. + // + // NOTE: This is set to the corresponding constant as in Scheduler.js. When + // we made it larger, a product metric in www regressed, suggesting there's + // a user interaction that's being starved by a series of synchronous + // updates. If that theory is correct, the proper solution is to fix the + // starvation. However, this scenario supports the idea that expiration + // times are an important safeguard when starvation does happen. + // + // Also note that, in the case of user input specifically, this will soon no + // longer be an issue because we plan to make user input synchronous by + // default (until you enter `startTransition`, of course.) + // + // If weren't planning to make these updates synchronous soon anyway, I + // would probably make this number a configurable parameter. + return currentTime + 250; + } else if (priority >= TransitionPriority) { + return currentTime + 5000; + } else { + // Anything idle priority or lower should never expire. + return NoTimestamp; + } + } + + function markStarvedLanesAsExpired(root, currentTime) { + // TODO: This gets called every time we yield. We can optimize by storing + // the earliest expiration time on the root. Then use that to quickly bail out + // of this function. + var pendingLanes = root.pendingLanes; + var suspendedLanes = root.suspendedLanes; + var pingedLanes = root.pingedLanes; + var expirationTimes = root.expirationTimes; // Iterate through the pending lanes and check if we've reached their + // expiration time. If so, we'll assume the update is being starved and mark + // it as expired to force it to finish. + + var lanes = pendingLanes; + + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + var expirationTime = expirationTimes[index]; + + if (expirationTime === NoTimestamp) { + // Found a pending lane with no expiration time. If it's not suspended, or + // if it's pinged, assume it's CPU-bound. Compute a new expiration time + // using the current time. + if ((lane & suspendedLanes) === NoLanes || (lane & pingedLanes) !== NoLanes) { + // Assumes timestamps are monotonically increasing. + expirationTimes[index] = computeExpirationTime(lane, currentTime); + } + } else if (expirationTime <= currentTime) { + // This lane expired + root.expiredLanes |= lane; + } + + lanes &= ~lane; + } + } // This returns the highest priority pending lanes regardless of whether they + function getLanesToRetrySynchronouslyOnError(root) { + var everythingButOffscreen = root.pendingLanes & ~OffscreenLane; + + if (everythingButOffscreen !== NoLanes) { + return everythingButOffscreen; + } + + if (everythingButOffscreen & OffscreenLane) { + return OffscreenLane; + } + + return NoLanes; + } + function returnNextLanesPriority() { + return return_highestLanePriority; + } + function includesNonIdleWork(lanes) { + return (lanes & NonIdleLanes) !== NoLanes; + } + function includesOnlyRetries(lanes) { + return (lanes & RetryLanes) === lanes; + } + function includesOnlyTransitions(lanes) { + return (lanes & TransitionLanes) === lanes; + } // To ensure consistency across multiple updates in the same event, this should + // be a pure function, so that it always returns the same lane for given inputs. + + function findUpdateLane(lanePriority, wipLanes) { + switch (lanePriority) { + case NoLanePriority: + break; + + case SyncLanePriority: + return SyncLane; + + case SyncBatchedLanePriority: + return SyncBatchedLane; + + case InputDiscreteLanePriority: + { + var _lane = pickArbitraryLane(InputDiscreteLanes & ~wipLanes); + + if (_lane === NoLane) { + // Shift to the next priority level + return findUpdateLane(InputContinuousLanePriority, wipLanes); + } + + return _lane; + } + + case InputContinuousLanePriority: + { + var _lane2 = pickArbitraryLane(InputContinuousLanes & ~wipLanes); + + if (_lane2 === NoLane) { + // Shift to the next priority level + return findUpdateLane(DefaultLanePriority, wipLanes); + } + + return _lane2; + } + + case DefaultLanePriority: + { + var _lane3 = pickArbitraryLane(DefaultLanes & ~wipLanes); + + if (_lane3 === NoLane) { + // If all the default lanes are already being worked on, look for a + // lane in the transition range. + _lane3 = pickArbitraryLane(TransitionLanes & ~wipLanes); + + if (_lane3 === NoLane) { + // All the transition lanes are taken, too. This should be very + // rare, but as a last resort, pick a default lane. This will have + // the effect of interrupting the current work-in-progress render. + _lane3 = pickArbitraryLane(DefaultLanes); + } + } + + return _lane3; + } + + case TransitionPriority: // Should be handled by findTransitionLane instead + + case RetryLanePriority: + // Should be handled by findRetryLane instead + break; + + case IdleLanePriority: + var lane = pickArbitraryLane(IdleLanes & ~wipLanes); + + if (lane === NoLane) { + lane = pickArbitraryLane(IdleLanes); + } + + return lane; + } + + { + { + throw Error( "Invalid update priority: " + lanePriority + ". This is a bug in React." ); + } + } + } // To ensure consistency across multiple updates in the same event, this should + // be pure function, so that it always returns the same lane for given inputs. + + function findTransitionLane(wipLanes, pendingLanes) { + // First look for lanes that are completely unclaimed, i.e. have no + // pending work. + var lane = pickArbitraryLane(TransitionLanes & ~pendingLanes); + + if (lane === NoLane) { + // If all lanes have pending work, look for a lane that isn't currently + // being worked on. + lane = pickArbitraryLane(TransitionLanes & ~wipLanes); + + if (lane === NoLane) { + // If everything is being worked on, pick any lane. This has the + // effect of interrupting the current work-in-progress. + lane = pickArbitraryLane(TransitionLanes); + } + } + + return lane; + } // To ensure consistency across multiple updates in the same event, this should + // be pure function, so that it always returns the same lane for given inputs. + + function findRetryLane(wipLanes) { + // This is a fork of `findUpdateLane` designed specifically for Suspense + // "retries" — a special update that attempts to flip a Suspense boundary + // from its placeholder state to its primary/resolved state. + var lane = pickArbitraryLane(RetryLanes & ~wipLanes); + + if (lane === NoLane) { + lane = pickArbitraryLane(RetryLanes); + } + + return lane; + } + + function getHighestPriorityLane(lanes) { + return lanes & -lanes; + } + + function getLowestPriorityLane(lanes) { + // This finds the most significant non-zero bit. + var index = 31 - clz32(lanes); + return index < 0 ? NoLanes : 1 << index; + } + + function getEqualOrHigherPriorityLanes(lanes) { + return (getLowestPriorityLane(lanes) << 1) - 1; + } + + function pickArbitraryLane(lanes) { + // This wrapper function gets inlined. Only exists so to communicate that it + // doesn't matter which bit is selected; you can pick any bit without + // affecting the algorithms where its used. Here I'm using + // getHighestPriorityLane because it requires the fewest operations. + return getHighestPriorityLane(lanes); + } + + function pickArbitraryLaneIndex(lanes) { + return 31 - clz32(lanes); + } + + function laneToIndex(lane) { + return pickArbitraryLaneIndex(lane); + } + + function includesSomeLane(a, b) { + return (a & b) !== NoLanes; + } + function isSubsetOfLanes(set, subset) { + return (set & subset) === subset; + } + function mergeLanes(a, b) { + return a | b; + } + function removeLanes(set, subset) { + return set & ~subset; + } // Seems redundant, but it changes the type from a single lane (used for + // updates) to a group of lanes (used for flushing work). + + function laneToLanes(lane) { + return lane; + } + function higherPriorityLane(a, b) { + // This works because the bit ranges decrease in priority as you go left. + return a !== NoLane && a < b ? a : b; + } + function createLaneMap(initial) { + // Intentionally pushing one by one. + // https://v8.dev/blog/elements-kinds#avoid-creating-holes + var laneMap = []; + + for (var i = 0; i < TotalLanes; i++) { + laneMap.push(initial); + } + + return laneMap; + } + function markRootUpdated(root, updateLane, eventTime) { + root.pendingLanes |= updateLane; // TODO: Theoretically, any update to any lane can unblock any other lane. But + // it's not practical to try every single possible combination. We need a + // heuristic to decide which lanes to attempt to render, and in which batches. + // For now, we use the same heuristic as in the old ExpirationTimes model: + // retry any lane at equal or lower priority, but don't try updates at higher + // priority without also including the lower priority updates. This works well + // when considering updates across different priority levels, but isn't + // sufficient for updates within the same priority, since we want to treat + // those updates as parallel. + // Unsuspend any update at equal or lower priority. + + var higherPriorityLanes = updateLane - 1; // Turns 0b1000 into 0b0111 + + root.suspendedLanes &= higherPriorityLanes; + root.pingedLanes &= higherPriorityLanes; + var eventTimes = root.eventTimes; + var index = laneToIndex(updateLane); // We can always overwrite an existing timestamp because we prefer the most + // recent event, and we assume time is monotonically increasing. + + eventTimes[index] = eventTime; + } + function markRootSuspended(root, suspendedLanes) { + root.suspendedLanes |= suspendedLanes; + root.pingedLanes &= ~suspendedLanes; // The suspended lanes are no longer CPU-bound. Clear their expiration times. + + var expirationTimes = root.expirationTimes; + var lanes = suspendedLanes; + + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + expirationTimes[index] = NoTimestamp; + lanes &= ~lane; + } + } + function markRootPinged(root, pingedLanes, eventTime) { + root.pingedLanes |= root.suspendedLanes & pingedLanes; + } + function markDiscreteUpdatesExpired(root) { + root.expiredLanes |= InputDiscreteLanes & root.pendingLanes; + } + function hasDiscreteLanes(lanes) { + return (lanes & InputDiscreteLanes) !== NoLanes; + } + function markRootMutableRead(root, updateLane) { + root.mutableReadLanes |= updateLane & root.pendingLanes; + } + function markRootFinished(root, remainingLanes) { + var noLongerPendingLanes = root.pendingLanes & ~remainingLanes; + root.pendingLanes = remainingLanes; // Let's try everything again + + root.suspendedLanes = 0; + root.pingedLanes = 0; + root.expiredLanes &= remainingLanes; + root.mutableReadLanes &= remainingLanes; + root.entangledLanes &= remainingLanes; + var entanglements = root.entanglements; + var eventTimes = root.eventTimes; + var expirationTimes = root.expirationTimes; // Clear the lanes that no longer have pending work + + var lanes = noLongerPendingLanes; + + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + entanglements[index] = NoLanes; + eventTimes[index] = NoTimestamp; + expirationTimes[index] = NoTimestamp; + lanes &= ~lane; + } + } + function markRootEntangled(root, entangledLanes) { + root.entangledLanes |= entangledLanes; + var entanglements = root.entanglements; + var lanes = entangledLanes; + + while (lanes > 0) { + var index = pickArbitraryLaneIndex(lanes); + var lane = 1 << index; + entanglements[index] |= entangledLanes; + lanes &= ~lane; + } + } + var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback; // Count leading zeros. Only used on lanes, so assume input is an integer. + // Based on: + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32 + + var log = Math.log; + var LN2 = Math.LN2; + + function clz32Fallback(lanes) { + if (lanes === 0) { + return 32; + } + + return 31 - (log(lanes) / LN2 | 0) | 0; + } + + // Intentionally not named imports because Rollup would use dynamic dispatch for + var UserBlockingPriority$1 = unstable_UserBlockingPriority, + runWithPriority = unstable_runWithPriority; // TODO: can we stop exporting these? + + var _enabled = true; // This is exported in FB builds for use by legacy FB layer infra. + // We'd like to remove this but it's not clear if this is safe. + + function setEnabled(enabled) { + _enabled = !!enabled; + } + function isEnabled() { + return _enabled; + } + function createEventListenerWrapperWithPriority(targetContainer, domEventName, eventSystemFlags) { + var eventPriority = getEventPriorityForPluginSystem(domEventName); + var listenerWrapper; + + switch (eventPriority) { + case DiscreteEvent: + listenerWrapper = dispatchDiscreteEvent; + break; + + case UserBlockingEvent: + listenerWrapper = dispatchUserBlockingUpdate; + break; + + case ContinuousEvent: + default: + listenerWrapper = dispatchEvent; + break; + } + + return listenerWrapper.bind(null, domEventName, eventSystemFlags, targetContainer); + } + + function dispatchDiscreteEvent(domEventName, eventSystemFlags, container, nativeEvent) { + { + flushDiscreteUpdatesIfNeeded(nativeEvent.timeStamp); + } + + discreteUpdates(dispatchEvent, domEventName, eventSystemFlags, container, nativeEvent); + } + + function dispatchUserBlockingUpdate(domEventName, eventSystemFlags, container, nativeEvent) { + { + runWithPriority(UserBlockingPriority$1, dispatchEvent.bind(null, domEventName, eventSystemFlags, container, nativeEvent)); + } + } + + function dispatchEvent(domEventName, eventSystemFlags, targetContainer, nativeEvent) { + if (!_enabled) { + return; + } + + var allowReplay = true; + + { + // TODO: replaying capture phase events is currently broken + // because we used to do it during top-level native bubble handlers + // but now we use different bubble and capture handlers. + // In eager mode, we attach capture listeners early, so we need + // to filter them out until we fix the logic to handle them correctly. + // This could've been outside the flag but I put it inside to reduce risk. + allowReplay = (eventSystemFlags & IS_CAPTURE_PHASE) === 0; + } + + if (allowReplay && hasQueuedDiscreteEvents() && isReplayableDiscreteEvent(domEventName)) { + // If we already have a queue of discrete events, and this is another discrete + // event, then we can't dispatch it regardless of its target, since they + // need to dispatch in order. + queueDiscreteEvent(null, // Flags that we're not actually blocked on anything as far as we know. + domEventName, eventSystemFlags, targetContainer, nativeEvent); + return; + } + + var blockedOn = attemptToDispatchEvent(domEventName, eventSystemFlags, targetContainer, nativeEvent); + + if (blockedOn === null) { + // We successfully dispatched this event. + if (allowReplay) { + clearIfContinuousEvent(domEventName, nativeEvent); + } + + return; + } + + if (allowReplay) { + if (isReplayableDiscreteEvent(domEventName)) { + // This this to be replayed later once the target is available. + queueDiscreteEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent); + return; + } + + if (queueIfContinuousEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent)) { + return; + } // We need to clear only if we didn't queue because + // queueing is accummulative. + + + clearIfContinuousEvent(domEventName, nativeEvent); + } // This is not replayable so we'll invoke it but without a target, + // in case the event system needs to trace it. + + + dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativeEvent, null, targetContainer); + } // Attempt dispatching an event. Returns a SuspenseInstance or Container if it's blocked. + + function attemptToDispatchEvent(domEventName, eventSystemFlags, targetContainer, nativeEvent) { + // TODO: Warn if _enabled is false. + var nativeEventTarget = getEventTarget(nativeEvent); + var targetInst = getClosestInstanceFromNode(nativeEventTarget); + + if (targetInst !== null) { + var nearestMounted = getNearestMountedFiber(targetInst); + + if (nearestMounted === null) { + // This tree has been unmounted already. Dispatch without a target. + targetInst = null; + } else { + var tag = nearestMounted.tag; + + if (tag === SuspenseComponent) { + var instance = getSuspenseInstanceFromFiber(nearestMounted); + + if (instance !== null) { + // Queue the event to be replayed later. Abort dispatching since we + // don't want this event dispatched twice through the event system. + // TODO: If this is the first discrete event in the queue. Schedule an increased + // priority for this boundary. + return instance; + } // This shouldn't happen, something went wrong but to avoid blocking + // the whole system, dispatch the event without a target. + // TODO: Warn. + + + targetInst = null; + } else if (tag === HostRoot) { + var root = nearestMounted.stateNode; + + if (root.hydrate) { + // If this happens during a replay something went wrong and it might block + // the whole system. + return getContainerFromFiber(nearestMounted); + } + + targetInst = null; + } else if (nearestMounted !== targetInst) { + // If we get an event (ex: img onload) before committing that + // component's mount, ignore it for now (that is, treat it as if it was an + // event on a non-React tree). We might also consider queueing events and + // dispatching them after the mount. + targetInst = null; + } + } + } + + dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativeEvent, targetInst, targetContainer); // We're not blocked on anything. + + return null; + } + + function addEventBubbleListener(target, eventType, listener) { + target.addEventListener(eventType, listener, false); + return listener; + } + function addEventCaptureListener(target, eventType, listener) { + target.addEventListener(eventType, listener, true); + return listener; + } + function addEventCaptureListenerWithPassiveFlag(target, eventType, listener, passive) { + target.addEventListener(eventType, listener, { + capture: true, + passive: passive + }); + return listener; + } + function addEventBubbleListenerWithPassiveFlag(target, eventType, listener, passive) { + target.addEventListener(eventType, listener, { + passive: passive + }); + return listener; + } + + /** + * These variables store information about text content of a target node, + * allowing comparison of content before and after a given event. + * + * Identify the node where selection currently begins, then observe + * both its text content and its current position in the DOM. Since the + * browser may natively replace the target node during composition, we can + * use its position to find its replacement. + * + * + */ + var root = null; + var startText = null; + var fallbackText = null; + function initialize(nativeEventTarget) { + root = nativeEventTarget; + startText = getText(); + return true; + } + function reset() { + root = null; + startText = null; + fallbackText = null; + } + function getData() { + if (fallbackText) { + return fallbackText; + } + + var start; + var startValue = startText; + var startLength = startValue.length; + var end; + var endValue = getText(); + var endLength = endValue.length; + + for (start = 0; start < startLength; start++) { + if (startValue[start] !== endValue[start]) { + break; + } + } + + var minEnd = startLength - start; + + for (end = 1; end <= minEnd; end++) { + if (startValue[startLength - end] !== endValue[endLength - end]) { + break; + } + } + + var sliceTail = end > 1 ? 1 - end : undefined; + fallbackText = endValue.slice(start, sliceTail); + return fallbackText; + } + function getText() { + if ('value' in root) { + return root.value; + } + + return root.textContent; + } + + /** + * `charCode` represents the actual "character code" and is safe to use with + * `String.fromCharCode`. As such, only keys that correspond to printable + * characters produce a valid `charCode`, the only exception to this is Enter. + * The Tab-key is considered non-printable and does not have a `charCode`, + * presumably because it does not produce a tab-character in browsers. + * + * @param {object} nativeEvent Native browser event. + * @return {number} Normalized `charCode` property. + */ + function getEventCharCode(nativeEvent) { + var charCode; + var keyCode = nativeEvent.keyCode; + + if ('charCode' in nativeEvent) { + charCode = nativeEvent.charCode; // FF does not set `charCode` for the Enter-key, check against `keyCode`. + + if (charCode === 0 && keyCode === 13) { + charCode = 13; + } + } else { + // IE8 does not implement `charCode`, but `keyCode` has the correct value. + charCode = keyCode; + } // IE and Edge (on Windows) and Chrome / Safari (on Windows and Linux) + // report Enter as charCode 10 when ctrl is pressed. + + + if (charCode === 10) { + charCode = 13; + } // Some non-printable keys are reported in `charCode`/`keyCode`, discard them. + // Must not discard the (non-)printable Enter-key. + + + if (charCode >= 32 || charCode === 13) { + return charCode; + } + + return 0; + } + + function functionThatReturnsTrue() { + return true; + } + + function functionThatReturnsFalse() { + return false; + } // This is intentionally a factory so that we have different returned constructors. + // If we had a single constructor, it would be megamorphic and engines would deopt. + + + function createSyntheticEvent(Interface) { + /** + * Synthetic events are dispatched by event plugins, typically in response to a + * top-level event delegation handler. + * + * These systems should generally use pooling to reduce the frequency of garbage + * collection. The system should check `isPersistent` to determine whether the + * event should be released into the pool after being dispatched. Users that + * need a persisted event should invoke `persist`. + * + * Synthetic events (and subclasses) implement the DOM Level 3 Events API by + * normalizing browser quirks. Subclasses do not necessarily have to implement a + * DOM interface; custom application-specific events can also subclass this. + */ + function SyntheticBaseEvent(reactName, reactEventType, targetInst, nativeEvent, nativeEventTarget) { + this._reactName = reactName; + this._targetInst = targetInst; + this.type = reactEventType; + this.nativeEvent = nativeEvent; + this.target = nativeEventTarget; + this.currentTarget = null; + + for (var _propName in Interface) { + if (!Interface.hasOwnProperty(_propName)) { + continue; + } + + var normalize = Interface[_propName]; + + if (normalize) { + this[_propName] = normalize(nativeEvent); + } else { + this[_propName] = nativeEvent[_propName]; + } + } + + var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false; + + if (defaultPrevented) { + this.isDefaultPrevented = functionThatReturnsTrue; + } else { + this.isDefaultPrevented = functionThatReturnsFalse; + } + + this.isPropagationStopped = functionThatReturnsFalse; + return this; + } + + _assign(SyntheticBaseEvent.prototype, { + preventDefault: function () { + this.defaultPrevented = true; + var event = this.nativeEvent; + + if (!event) { + return; + } + + if (event.preventDefault) { + event.preventDefault(); // $FlowFixMe - flow is not aware of `unknown` in IE + } else if (typeof event.returnValue !== 'unknown') { + event.returnValue = false; + } + + this.isDefaultPrevented = functionThatReturnsTrue; + }, + stopPropagation: function () { + var event = this.nativeEvent; + + if (!event) { + return; + } + + if (event.stopPropagation) { + event.stopPropagation(); // $FlowFixMe - flow is not aware of `unknown` in IE + } else if (typeof event.cancelBubble !== 'unknown') { + // The ChangeEventPlugin registers a "propertychange" event for + // IE. This event does not support bubbling or cancelling, and + // any references to cancelBubble throw "Member not found". A + // typeof check of "unknown" circumvents this issue (and is also + // IE specific). + event.cancelBubble = true; + } + + this.isPropagationStopped = functionThatReturnsTrue; + }, + + /** + * We release all dispatched `SyntheticEvent`s after each event loop, adding + * them back into the pool. This allows a way to hold onto a reference that + * won't be added back into the pool. + */ + persist: function () {// Modern event system doesn't use pooling. + }, + + /** + * Checks if this event should be released back into the pool. + * + * @return {boolean} True if this should not be released, false otherwise. + */ + isPersistent: functionThatReturnsTrue + }); + + return SyntheticBaseEvent; + } + /** + * @interface Event + * @see http://www.w3.org/TR/DOM-Level-3-Events/ + */ + + + var EventInterface = { + eventPhase: 0, + bubbles: 0, + cancelable: 0, + timeStamp: function (event) { + return event.timeStamp || Date.now(); + }, + defaultPrevented: 0, + isTrusted: 0 + }; + var SyntheticEvent = createSyntheticEvent(EventInterface); + + var UIEventInterface = _assign({}, EventInterface, { + view: 0, + detail: 0 + }); + + var SyntheticUIEvent = createSyntheticEvent(UIEventInterface); + var lastMovementX; + var lastMovementY; + var lastMouseEvent; + + function updateMouseMovementPolyfillState(event) { + if (event !== lastMouseEvent) { + if (lastMouseEvent && event.type === 'mousemove') { + lastMovementX = event.screenX - lastMouseEvent.screenX; + lastMovementY = event.screenY - lastMouseEvent.screenY; + } else { + lastMovementX = 0; + lastMovementY = 0; + } + + lastMouseEvent = event; + } + } + /** + * @interface MouseEvent + * @see http://www.w3.org/TR/DOM-Level-3-Events/ + */ + + + var MouseEventInterface = _assign({}, UIEventInterface, { + screenX: 0, + screenY: 0, + clientX: 0, + clientY: 0, + pageX: 0, + pageY: 0, + ctrlKey: 0, + shiftKey: 0, + altKey: 0, + metaKey: 0, + getModifierState: getEventModifierState, + button: 0, + buttons: 0, + relatedTarget: function (event) { + if (event.relatedTarget === undefined) return event.fromElement === event.srcElement ? event.toElement : event.fromElement; + return event.relatedTarget; + }, + movementX: function (event) { + if ('movementX' in event) { + return event.movementX; + } + + updateMouseMovementPolyfillState(event); + return lastMovementX; + }, + movementY: function (event) { + if ('movementY' in event) { + return event.movementY; + } // Don't need to call updateMouseMovementPolyfillState() here + // because it's guaranteed to have already run when movementX + // was copied. + + + return lastMovementY; + } + }); + + var SyntheticMouseEvent = createSyntheticEvent(MouseEventInterface); + /** + * @interface DragEvent + * @see http://www.w3.org/TR/DOM-Level-3-Events/ + */ + + var DragEventInterface = _assign({}, MouseEventInterface, { + dataTransfer: 0 + }); + + var SyntheticDragEvent = createSyntheticEvent(DragEventInterface); + /** + * @interface FocusEvent + * @see http://www.w3.org/TR/DOM-Level-3-Events/ + */ + + var FocusEventInterface = _assign({}, UIEventInterface, { + relatedTarget: 0 + }); + + var SyntheticFocusEvent = createSyntheticEvent(FocusEventInterface); + /** + * @interface Event + * @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface + * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent + */ + + var AnimationEventInterface = _assign({}, EventInterface, { + animationName: 0, + elapsedTime: 0, + pseudoElement: 0 + }); + + var SyntheticAnimationEvent = createSyntheticEvent(AnimationEventInterface); + /** + * @interface Event + * @see http://www.w3.org/TR/clipboard-apis/ + */ + + var ClipboardEventInterface = _assign({}, EventInterface, { + clipboardData: function (event) { + return 'clipboardData' in event ? event.clipboardData : window.clipboardData; + } + }); + + var SyntheticClipboardEvent = createSyntheticEvent(ClipboardEventInterface); + /** + * @interface Event + * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents + */ + + var CompositionEventInterface = _assign({}, EventInterface, { + data: 0 + }); + + var SyntheticCompositionEvent = createSyntheticEvent(CompositionEventInterface); + /** + * @interface Event + * @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105 + * /#events-inputevents + */ + // Happens to share the same list for now. + + var SyntheticInputEvent = SyntheticCompositionEvent; + /** + * Normalization of deprecated HTML5 `key` values + * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names + */ + + var normalizeKey = { + Esc: 'Escape', + Spacebar: ' ', + Left: 'ArrowLeft', + Up: 'ArrowUp', + Right: 'ArrowRight', + Down: 'ArrowDown', + Del: 'Delete', + Win: 'OS', + Menu: 'ContextMenu', + Apps: 'ContextMenu', + Scroll: 'ScrollLock', + MozPrintableKey: 'Unidentified' + }; + /** + * Translation from legacy `keyCode` to HTML5 `key` + * Only special keys supported, all others depend on keyboard layout or browser + * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names + */ + + var translateToKey = { + '8': 'Backspace', + '9': 'Tab', + '12': 'Clear', + '13': 'Enter', + '16': 'Shift', + '17': 'Control', + '18': 'Alt', + '19': 'Pause', + '20': 'CapsLock', + '27': 'Escape', + '32': ' ', + '33': 'PageUp', + '34': 'PageDown', + '35': 'End', + '36': 'Home', + '37': 'ArrowLeft', + '38': 'ArrowUp', + '39': 'ArrowRight', + '40': 'ArrowDown', + '45': 'Insert', + '46': 'Delete', + '112': 'F1', + '113': 'F2', + '114': 'F3', + '115': 'F4', + '116': 'F5', + '117': 'F6', + '118': 'F7', + '119': 'F8', + '120': 'F9', + '121': 'F10', + '122': 'F11', + '123': 'F12', + '144': 'NumLock', + '145': 'ScrollLock', + '224': 'Meta' + }; + /** + * @param {object} nativeEvent Native browser event. + * @return {string} Normalized `key` property. + */ + + function getEventKey(nativeEvent) { + if (nativeEvent.key) { + // Normalize inconsistent values reported by browsers due to + // implementations of a working draft specification. + // FireFox implements `key` but returns `MozPrintableKey` for all + // printable characters (normalized to `Unidentified`), ignore it. + var key = normalizeKey[nativeEvent.key] || nativeEvent.key; + + if (key !== 'Unidentified') { + return key; + } + } // Browser does not implement `key`, polyfill as much of it as we can. + + + if (nativeEvent.type === 'keypress') { + var charCode = getEventCharCode(nativeEvent); // The enter-key is technically both printable and non-printable and can + // thus be captured by `keypress`, no other non-printable key should. + + return charCode === 13 ? 'Enter' : String.fromCharCode(charCode); + } + + if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') { + // While user keyboard layout determines the actual meaning of each + // `keyCode` value, almost all function keys have a universal value. + return translateToKey[nativeEvent.keyCode] || 'Unidentified'; + } + + return ''; + } + /** + * Translation from modifier key to the associated property in the event. + * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers + */ + + + var modifierKeyToProp = { + Alt: 'altKey', + Control: 'ctrlKey', + Meta: 'metaKey', + Shift: 'shiftKey' + }; // Older browsers (Safari <= 10, iOS Safari <= 10.2) do not support + // getModifierState. If getModifierState is not supported, we map it to a set of + // modifier keys exposed by the event. In this case, Lock-keys are not supported. + + function modifierStateGetter(keyArg) { + var syntheticEvent = this; + var nativeEvent = syntheticEvent.nativeEvent; + + if (nativeEvent.getModifierState) { + return nativeEvent.getModifierState(keyArg); + } + + var keyProp = modifierKeyToProp[keyArg]; + return keyProp ? !!nativeEvent[keyProp] : false; + } + + function getEventModifierState(nativeEvent) { + return modifierStateGetter; + } + /** + * @interface KeyboardEvent + * @see http://www.w3.org/TR/DOM-Level-3-Events/ + */ + + + var KeyboardEventInterface = _assign({}, UIEventInterface, { + key: getEventKey, + code: 0, + location: 0, + ctrlKey: 0, + shiftKey: 0, + altKey: 0, + metaKey: 0, + repeat: 0, + locale: 0, + getModifierState: getEventModifierState, + // Legacy Interface + charCode: function (event) { + // `charCode` is the result of a KeyPress event and represents the value of + // the actual printable character. + // KeyPress is deprecated, but its replacement is not yet final and not + // implemented in any major browser. Only KeyPress has charCode. + if (event.type === 'keypress') { + return getEventCharCode(event); + } + + return 0; + }, + keyCode: function (event) { + // `keyCode` is the result of a KeyDown/Up event and represents the value of + // physical keyboard key. + // The actual meaning of the value depends on the users' keyboard layout + // which cannot be detected. Assuming that it is a US keyboard layout + // provides a surprisingly accurate mapping for US and European users. + // Due to this, it is left to the user to implement at this time. + if (event.type === 'keydown' || event.type === 'keyup') { + return event.keyCode; + } + + return 0; + }, + which: function (event) { + // `which` is an alias for either `keyCode` or `charCode` depending on the + // type of the event. + if (event.type === 'keypress') { + return getEventCharCode(event); + } + + if (event.type === 'keydown' || event.type === 'keyup') { + return event.keyCode; + } + + return 0; + } + }); + + var SyntheticKeyboardEvent = createSyntheticEvent(KeyboardEventInterface); + /** + * @interface PointerEvent + * @see http://www.w3.org/TR/pointerevents/ + */ + + var PointerEventInterface = _assign({}, MouseEventInterface, { + pointerId: 0, + width: 0, + height: 0, + pressure: 0, + tangentialPressure: 0, + tiltX: 0, + tiltY: 0, + twist: 0, + pointerType: 0, + isPrimary: 0 + }); + + var SyntheticPointerEvent = createSyntheticEvent(PointerEventInterface); + /** + * @interface TouchEvent + * @see http://www.w3.org/TR/touch-events/ + */ + + var TouchEventInterface = _assign({}, UIEventInterface, { + touches: 0, + targetTouches: 0, + changedTouches: 0, + altKey: 0, + metaKey: 0, + ctrlKey: 0, + shiftKey: 0, + getModifierState: getEventModifierState + }); + + var SyntheticTouchEvent = createSyntheticEvent(TouchEventInterface); + /** + * @interface Event + * @see http://www.w3.org/TR/2009/WD-css3-transitions-20090320/#transition-events- + * @see https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent + */ + + var TransitionEventInterface = _assign({}, EventInterface, { + propertyName: 0, + elapsedTime: 0, + pseudoElement: 0 + }); + + var SyntheticTransitionEvent = createSyntheticEvent(TransitionEventInterface); + /** + * @interface WheelEvent + * @see http://www.w3.org/TR/DOM-Level-3-Events/ + */ + + var WheelEventInterface = _assign({}, MouseEventInterface, { + deltaX: function (event) { + return 'deltaX' in event ? event.deltaX : // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive). + 'wheelDeltaX' in event ? -event.wheelDeltaX : 0; + }, + deltaY: function (event) { + return 'deltaY' in event ? event.deltaY : // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive). + 'wheelDeltaY' in event ? -event.wheelDeltaY : // Fallback to `wheelDelta` for IE<9 and normalize (down is positive). + 'wheelDelta' in event ? -event.wheelDelta : 0; + }, + deltaZ: 0, + // Browsers without "deltaMode" is reporting in raw wheel delta where one + // notch on the scroll is always +/- 120, roughly equivalent to pixels. + // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or + // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size. + deltaMode: 0 + }); + + var SyntheticWheelEvent = createSyntheticEvent(WheelEventInterface); + + var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space + + var START_KEYCODE = 229; + var canUseCompositionEvent = canUseDOM && 'CompositionEvent' in window; + var documentMode = null; + + if (canUseDOM && 'documentMode' in document) { + documentMode = document.documentMode; + } // Webkit offers a very useful `textInput` event that can be used to + // directly represent `beforeInput`. The IE `textinput` event is not as + // useful, so we don't use it. + + + var canUseTextInputEvent = canUseDOM && 'TextEvent' in window && !documentMode; // In IE9+, we have access to composition events, but the data supplied + // by the native compositionend event may be incorrect. Japanese ideographic + // spaces, for instance (\u3000) are not recorded correctly. + + var useFallbackCompositionData = canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11); + var SPACEBAR_CODE = 32; + var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE); + + function registerEvents() { + registerTwoPhaseEvent('onBeforeInput', ['compositionend', 'keypress', 'textInput', 'paste']); + registerTwoPhaseEvent('onCompositionEnd', ['compositionend', 'focusout', 'keydown', 'keypress', 'keyup', 'mousedown']); + registerTwoPhaseEvent('onCompositionStart', ['compositionstart', 'focusout', 'keydown', 'keypress', 'keyup', 'mousedown']); + registerTwoPhaseEvent('onCompositionUpdate', ['compositionupdate', 'focusout', 'keydown', 'keypress', 'keyup', 'mousedown']); + } // Track whether we've ever handled a keypress on the space key. + + + var hasSpaceKeypress = false; + /** + * Return whether a native keypress event is assumed to be a command. + * This is required because Firefox fires `keypress` events for key commands + * (cut, copy, select-all, etc.) even though no character is inserted. + */ + + function isKeypressCommand(nativeEvent) { + return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) && // ctrlKey && altKey is equivalent to AltGr, and is not a command. + !(nativeEvent.ctrlKey && nativeEvent.altKey); + } + /** + * Translate native top level events into event types. + */ + + + function getCompositionEventType(domEventName) { + switch (domEventName) { + case 'compositionstart': + return 'onCompositionStart'; + + case 'compositionend': + return 'onCompositionEnd'; + + case 'compositionupdate': + return 'onCompositionUpdate'; + } + } + /** + * Does our fallback best-guess model think this event signifies that + * composition has begun? + */ + + + function isFallbackCompositionStart(domEventName, nativeEvent) { + return domEventName === 'keydown' && nativeEvent.keyCode === START_KEYCODE; + } + /** + * Does our fallback mode think that this event is the end of composition? + */ + + + function isFallbackCompositionEnd(domEventName, nativeEvent) { + switch (domEventName) { + case 'keyup': + // Command keys insert or clear IME input. + return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1; + + case 'keydown': + // Expect IME keyCode on each keydown. If we get any other + // code we must have exited earlier. + return nativeEvent.keyCode !== START_KEYCODE; + + case 'keypress': + case 'mousedown': + case 'focusout': + // Events are not possible without cancelling IME. + return true; + + default: + return false; + } + } + /** + * Google Input Tools provides composition data via a CustomEvent, + * with the `data` property populated in the `detail` object. If this + * is available on the event object, use it. If not, this is a plain + * composition event and we have nothing special to extract. + * + * @param {object} nativeEvent + * @return {?string} + */ + + + function getDataFromCustomEvent(nativeEvent) { + var detail = nativeEvent.detail; + + if (typeof detail === 'object' && 'data' in detail) { + return detail.data; + } + + return null; + } + /** + * Check if a composition event was triggered by Korean IME. + * Our fallback mode does not work well with IE's Korean IME, + * so just use native composition events when Korean IME is used. + * Although CompositionEvent.locale property is deprecated, + * it is available in IE, where our fallback mode is enabled. + * + * @param {object} nativeEvent + * @return {boolean} + */ + + + function isUsingKoreanIME(nativeEvent) { + return nativeEvent.locale === 'ko'; + } // Track the current IME composition status, if any. + + + var isComposing = false; + /** + * @return {?object} A SyntheticCompositionEvent. + */ + + function extractCompositionEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget) { + var eventType; + var fallbackData; + + if (canUseCompositionEvent) { + eventType = getCompositionEventType(domEventName); + } else if (!isComposing) { + if (isFallbackCompositionStart(domEventName, nativeEvent)) { + eventType = 'onCompositionStart'; + } + } else if (isFallbackCompositionEnd(domEventName, nativeEvent)) { + eventType = 'onCompositionEnd'; + } + + if (!eventType) { + return null; + } + + if (useFallbackCompositionData && !isUsingKoreanIME(nativeEvent)) { + // The current composition is stored statically and must not be + // overwritten while composition continues. + if (!isComposing && eventType === 'onCompositionStart') { + isComposing = initialize(nativeEventTarget); + } else if (eventType === 'onCompositionEnd') { + if (isComposing) { + fallbackData = getData(); + } + } + } + + var listeners = accumulateTwoPhaseListeners(targetInst, eventType); + + if (listeners.length > 0) { + var event = new SyntheticCompositionEvent(eventType, domEventName, null, nativeEvent, nativeEventTarget); + dispatchQueue.push({ + event: event, + listeners: listeners + }); + + if (fallbackData) { + // Inject data generated from fallback path into the synthetic event. + // This matches the property of native CompositionEventInterface. + event.data = fallbackData; + } else { + var customData = getDataFromCustomEvent(nativeEvent); + + if (customData !== null) { + event.data = customData; + } + } + } + } + + function getNativeBeforeInputChars(domEventName, nativeEvent) { + switch (domEventName) { + case 'compositionend': + return getDataFromCustomEvent(nativeEvent); + + case 'keypress': + /** + * If native `textInput` events are available, our goal is to make + * use of them. However, there is a special case: the spacebar key. + * In Webkit, preventing default on a spacebar `textInput` event + * cancels character insertion, but it *also* causes the browser + * to fall back to its default spacebar behavior of scrolling the + * page. + * + * Tracking at: + * https://code.google.com/p/chromium/issues/detail?id=355103 + * + * To avoid this issue, use the keypress event as if no `textInput` + * event is available. + */ + var which = nativeEvent.which; + + if (which !== SPACEBAR_CODE) { + return null; + } + + hasSpaceKeypress = true; + return SPACEBAR_CHAR; + + case 'textInput': + // Record the characters to be added to the DOM. + var chars = nativeEvent.data; // If it's a spacebar character, assume that we have already handled + // it at the keypress level and bail immediately. Android Chrome + // doesn't give us keycodes, so we need to ignore it. + + if (chars === SPACEBAR_CHAR && hasSpaceKeypress) { + return null; + } + + return chars; + + default: + // For other native event types, do nothing. + return null; + } + } + /** + * For browsers that do not provide the `textInput` event, extract the + * appropriate string to use for SyntheticInputEvent. + */ + + + function getFallbackBeforeInputChars(domEventName, nativeEvent) { + // If we are currently composing (IME) and using a fallback to do so, + // try to extract the composed characters from the fallback object. + // If composition event is available, we extract a string only at + // compositionevent, otherwise extract it at fallback events. + if (isComposing) { + if (domEventName === 'compositionend' || !canUseCompositionEvent && isFallbackCompositionEnd(domEventName, nativeEvent)) { + var chars = getData(); + reset(); + isComposing = false; + return chars; + } + + return null; + } + + switch (domEventName) { + case 'paste': + // If a paste event occurs after a keypress, throw out the input + // chars. Paste events should not lead to BeforeInput events. + return null; + + case 'keypress': + /** + * As of v27, Firefox may fire keypress events even when no character + * will be inserted. A few possibilities: + * + * - `which` is `0`. Arrow keys, Esc key, etc. + * + * - `which` is the pressed key code, but no char is available. + * Ex: 'AltGr + d` in Polish. There is no modified character for + * this key combination and no character is inserted into the + * document, but FF fires the keypress for char code `100` anyway. + * No `input` event will occur. + * + * - `which` is the pressed key code, but a command combination is + * being used. Ex: `Cmd+C`. No character is inserted, and no + * `input` event will occur. + */ + if (!isKeypressCommand(nativeEvent)) { + // IE fires the `keypress` event when a user types an emoji via + // Touch keyboard of Windows. In such a case, the `char` property + // holds an emoji character like `\uD83D\uDE0A`. Because its length + // is 2, the property `which` does not represent an emoji correctly. + // In such a case, we directly return the `char` property instead of + // using `which`. + if (nativeEvent.char && nativeEvent.char.length > 1) { + return nativeEvent.char; + } else if (nativeEvent.which) { + return String.fromCharCode(nativeEvent.which); + } + } + + return null; + + case 'compositionend': + return useFallbackCompositionData && !isUsingKoreanIME(nativeEvent) ? null : nativeEvent.data; + + default: + return null; + } + } + /** + * Extract a SyntheticInputEvent for `beforeInput`, based on either native + * `textInput` or fallback behavior. + * + * @return {?object} A SyntheticInputEvent. + */ + + + function extractBeforeInputEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget) { + var chars; + + if (canUseTextInputEvent) { + chars = getNativeBeforeInputChars(domEventName, nativeEvent); + } else { + chars = getFallbackBeforeInputChars(domEventName, nativeEvent); + } // If no characters are being inserted, no BeforeInput event should + // be fired. + + + if (!chars) { + return null; + } + + var listeners = accumulateTwoPhaseListeners(targetInst, 'onBeforeInput'); + + if (listeners.length > 0) { + var event = new SyntheticInputEvent('onBeforeInput', 'beforeinput', null, nativeEvent, nativeEventTarget); + dispatchQueue.push({ + event: event, + listeners: listeners + }); + event.data = chars; + } + } + /** + * Create an `onBeforeInput` event to match + * http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents. + * + * This event plugin is based on the native `textInput` event + * available in Chrome, Safari, Opera, and IE. This event fires after + * `onKeyPress` and `onCompositionEnd`, but before `onInput`. + * + * `beforeInput` is spec'd but not implemented in any browsers, and + * the `input` event does not provide any useful information about what has + * actually been added, contrary to the spec. Thus, `textInput` is the best + * available event to identify the characters that have actually been inserted + * into the target node. + * + * This plugin is also responsible for emitting `composition` events, thus + * allowing us to share composition fallback code for both `beforeInput` and + * `composition` event types. + */ + + + function extractEvents(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) { + extractCompositionEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget); + extractBeforeInputEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget); + } + + /** + * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary + */ + var supportedInputTypes = { + color: true, + date: true, + datetime: true, + 'datetime-local': true, + email: true, + month: true, + number: true, + password: true, + range: true, + search: true, + tel: true, + text: true, + time: true, + url: true, + week: true + }; + + function isTextInputElement(elem) { + var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); + + if (nodeName === 'input') { + return !!supportedInputTypes[elem.type]; + } + + if (nodeName === 'textarea') { + return true; + } + + return false; + } + + /** + * Checks if an event is supported in the current execution environment. + * + * NOTE: This will not work correctly for non-generic events such as `change`, + * `reset`, `load`, `error`, and `select`. + * + * Borrows from Modernizr. + * + * @param {string} eventNameSuffix Event name, e.g. "click". + * @return {boolean} True if the event is supported. + * @internal + * @license Modernizr 3.0.0pre (Custom Build) | MIT + */ + + function isEventSupported(eventNameSuffix) { + if (!canUseDOM) { + return false; + } + + var eventName = 'on' + eventNameSuffix; + var isSupported = (eventName in document); + + if (!isSupported) { + var element = document.createElement('div'); + element.setAttribute(eventName, 'return;'); + isSupported = typeof element[eventName] === 'function'; + } + + return isSupported; + } + + function registerEvents$1() { + registerTwoPhaseEvent('onChange', ['change', 'click', 'focusin', 'focusout', 'input', 'keydown', 'keyup', 'selectionchange']); + } + + function createAndAccumulateChangeEvent(dispatchQueue, inst, nativeEvent, target) { + // Flag this event loop as needing state restore. + enqueueStateRestore(target); + var listeners = accumulateTwoPhaseListeners(inst, 'onChange'); + + if (listeners.length > 0) { + var event = new SyntheticEvent('onChange', 'change', null, nativeEvent, target); + dispatchQueue.push({ + event: event, + listeners: listeners + }); + } + } + /** + * For IE shims + */ + + + var activeElement = null; + var activeElementInst = null; + /** + * SECTION: handle `change` event + */ + + function shouldUseChangeEvent(elem) { + var nodeName = elem.nodeName && elem.nodeName.toLowerCase(); + return nodeName === 'select' || nodeName === 'input' && elem.type === 'file'; + } + + function manualDispatchChangeEvent(nativeEvent) { + var dispatchQueue = []; + createAndAccumulateChangeEvent(dispatchQueue, activeElementInst, nativeEvent, getEventTarget(nativeEvent)); // If change and propertychange bubbled, we'd just bind to it like all the + // other events and have it go through ReactBrowserEventEmitter. Since it + // doesn't, we manually listen for the events and so we have to enqueue and + // process the abstract event manually. + // + // Batching is necessary here in order to ensure that all event handlers run + // before the next rerender (including event handlers attached to ancestor + // elements instead of directly on the input). Without this, controlled + // components don't work properly in conjunction with event bubbling because + // the component is rerendered and the value reverted before all the event + // handlers can run. See https://github.com/facebook/react/issues/708. + + batchedUpdates(runEventInBatch, dispatchQueue); + } + + function runEventInBatch(dispatchQueue) { + processDispatchQueue(dispatchQueue, 0); + } + + function getInstIfValueChanged(targetInst) { + var targetNode = getNodeFromInstance(targetInst); + + if (updateValueIfChanged(targetNode)) { + return targetInst; + } + } + + function getTargetInstForChangeEvent(domEventName, targetInst) { + if (domEventName === 'change') { + return targetInst; + } + } + /** + * SECTION: handle `input` event + */ + + + var isInputEventSupported = false; + + if (canUseDOM) { + // IE9 claims to support the input event but fails to trigger it when + // deleting text, so we ignore its input events. + isInputEventSupported = isEventSupported('input') && (!document.documentMode || document.documentMode > 9); + } + /** + * (For IE <=9) Starts tracking propertychange events on the passed-in element + * and override the value property so that we can distinguish user events from + * value changes in JS. + */ + + + function startWatchingForValueChange(target, targetInst) { + activeElement = target; + activeElementInst = targetInst; + activeElement.attachEvent('onpropertychange', handlePropertyChange); + } + /** + * (For IE <=9) Removes the event listeners from the currently-tracked element, + * if any exists. + */ + + + function stopWatchingForValueChange() { + if (!activeElement) { + return; + } + + activeElement.detachEvent('onpropertychange', handlePropertyChange); + activeElement = null; + activeElementInst = null; + } + /** + * (For IE <=9) Handles a propertychange event, sending a `change` event if + * the value of the active element has changed. + */ + + + function handlePropertyChange(nativeEvent) { + if (nativeEvent.propertyName !== 'value') { + return; + } + + if (getInstIfValueChanged(activeElementInst)) { + manualDispatchChangeEvent(nativeEvent); + } + } + + function handleEventsForInputEventPolyfill(domEventName, target, targetInst) { + if (domEventName === 'focusin') { + // In IE9, propertychange fires for most input events but is buggy and + // doesn't fire when text is deleted, but conveniently, selectionchange + // appears to fire in all of the remaining cases so we catch those and + // forward the event if the value has changed + // In either case, we don't want to call the event handler if the value + // is changed from JS so we redefine a setter for `.value` that updates + // our activeElementValue variable, allowing us to ignore those changes + // + // stopWatching() should be a noop here but we call it just in case we + // missed a blur event somehow. + stopWatchingForValueChange(); + startWatchingForValueChange(target, targetInst); + } else if (domEventName === 'focusout') { + stopWatchingForValueChange(); + } + } // For IE8 and IE9. + + + function getTargetInstForInputEventPolyfill(domEventName, targetInst) { + if (domEventName === 'selectionchange' || domEventName === 'keyup' || domEventName === 'keydown') { + // On the selectionchange event, the target is just document which isn't + // helpful for us so just check activeElement instead. + // + // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire + // propertychange on the first input event after setting `value` from a + // script and fires only keydown, keypress, keyup. Catching keyup usually + // gets it and catching keydown lets us fire an event for the first + // keystroke if user does a key repeat (it'll be a little delayed: right + // before the second keystroke). Other input methods (e.g., paste) seem to + // fire selectionchange normally. + return getInstIfValueChanged(activeElementInst); + } + } + /** + * SECTION: handle `click` event + */ + + + function shouldUseClickEvent(elem) { + // Use the `click` event to detect changes to checkbox and radio inputs. + // This approach works across all browsers, whereas `change` does not fire + // until `blur` in IE8. + var nodeName = elem.nodeName; + return nodeName && nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio'); + } + + function getTargetInstForClickEvent(domEventName, targetInst) { + if (domEventName === 'click') { + return getInstIfValueChanged(targetInst); + } + } + + function getTargetInstForInputOrChangeEvent(domEventName, targetInst) { + if (domEventName === 'input' || domEventName === 'change') { + return getInstIfValueChanged(targetInst); + } + } + + function handleControlledInputBlur(node) { + var state = node._wrapperState; + + if (!state || !state.controlled || node.type !== 'number') { + return; + } + + { + // If controlled, assign the value attribute to the current value on blur + setDefaultValue(node, 'number', node.value); + } + } + /** + * This plugin creates an `onChange` event that normalizes change events + * across form elements. This event fires at a time when it's possible to + * change the element's value without seeing a flicker. + * + * Supported elements are: + * - input (see `isTextInputElement`) + * - textarea + * - select + */ + + + function extractEvents$1(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) { + var targetNode = targetInst ? getNodeFromInstance(targetInst) : window; + var getTargetInstFunc, handleEventFunc; + + if (shouldUseChangeEvent(targetNode)) { + getTargetInstFunc = getTargetInstForChangeEvent; + } else if (isTextInputElement(targetNode)) { + if (isInputEventSupported) { + getTargetInstFunc = getTargetInstForInputOrChangeEvent; + } else { + getTargetInstFunc = getTargetInstForInputEventPolyfill; + handleEventFunc = handleEventsForInputEventPolyfill; + } + } else if (shouldUseClickEvent(targetNode)) { + getTargetInstFunc = getTargetInstForClickEvent; + } + + if (getTargetInstFunc) { + var inst = getTargetInstFunc(domEventName, targetInst); + + if (inst) { + createAndAccumulateChangeEvent(dispatchQueue, inst, nativeEvent, nativeEventTarget); + return; + } + } + + if (handleEventFunc) { + handleEventFunc(domEventName, targetNode, targetInst); + } // When blurring, set the value attribute for number inputs + + + if (domEventName === 'focusout') { + handleControlledInputBlur(targetNode); + } + } + + function registerEvents$2() { + registerDirectEvent('onMouseEnter', ['mouseout', 'mouseover']); + registerDirectEvent('onMouseLeave', ['mouseout', 'mouseover']); + registerDirectEvent('onPointerEnter', ['pointerout', 'pointerover']); + registerDirectEvent('onPointerLeave', ['pointerout', 'pointerover']); + } + /** + * For almost every interaction we care about, there will be both a top-level + * `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that + * we do not extract duplicate events. However, moving the mouse into the + * browser from outside will not fire a `mouseout` event. In this case, we use + * the `mouseover` top-level event. + */ + + + function extractEvents$2(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) { + var isOverEvent = domEventName === 'mouseover' || domEventName === 'pointerover'; + var isOutEvent = domEventName === 'mouseout' || domEventName === 'pointerout'; + + if (isOverEvent && (eventSystemFlags & IS_REPLAYED) === 0) { + // If this is an over event with a target, we might have already dispatched + // the event in the out event of the other target. If this is replayed, + // then it's because we couldn't dispatch against this target previously + // so we have to do it now instead. + var related = nativeEvent.relatedTarget || nativeEvent.fromElement; + + if (related) { + // If the related node is managed by React, we can assume that we have + // already dispatched the corresponding events during its mouseout. + if (getClosestInstanceFromNode(related) || isContainerMarkedAsRoot(related)) { + return; + } + } + } + + if (!isOutEvent && !isOverEvent) { + // Must not be a mouse or pointer in or out - ignoring. + return; + } + + var win; // TODO: why is this nullable in the types but we read from it? + + if (nativeEventTarget.window === nativeEventTarget) { + // `nativeEventTarget` is probably a window object. + win = nativeEventTarget; + } else { + // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8. + var doc = nativeEventTarget.ownerDocument; + + if (doc) { + win = doc.defaultView || doc.parentWindow; + } else { + win = window; + } + } + + var from; + var to; + + if (isOutEvent) { + var _related = nativeEvent.relatedTarget || nativeEvent.toElement; + + from = targetInst; + to = _related ? getClosestInstanceFromNode(_related) : null; + + if (to !== null) { + var nearestMounted = getNearestMountedFiber(to); + + if (to !== nearestMounted || to.tag !== HostComponent && to.tag !== HostText) { + to = null; + } + } + } else { + // Moving to a node from outside the window. + from = null; + to = targetInst; + } + + if (from === to) { + // Nothing pertains to our managed components. + return; + } + + var SyntheticEventCtor = SyntheticMouseEvent; + var leaveEventType = 'onMouseLeave'; + var enterEventType = 'onMouseEnter'; + var eventTypePrefix = 'mouse'; + + if (domEventName === 'pointerout' || domEventName === 'pointerover') { + SyntheticEventCtor = SyntheticPointerEvent; + leaveEventType = 'onPointerLeave'; + enterEventType = 'onPointerEnter'; + eventTypePrefix = 'pointer'; + } + + var fromNode = from == null ? win : getNodeFromInstance(from); + var toNode = to == null ? win : getNodeFromInstance(to); + var leave = new SyntheticEventCtor(leaveEventType, eventTypePrefix + 'leave', from, nativeEvent, nativeEventTarget); + leave.target = fromNode; + leave.relatedTarget = toNode; + var enter = null; // We should only process this nativeEvent if we are processing + // the first ancestor. Next time, we will ignore the event. + + var nativeTargetInst = getClosestInstanceFromNode(nativeEventTarget); + + if (nativeTargetInst === targetInst) { + var enterEvent = new SyntheticEventCtor(enterEventType, eventTypePrefix + 'enter', to, nativeEvent, nativeEventTarget); + enterEvent.target = toNode; + enterEvent.relatedTarget = fromNode; + enter = enterEvent; + } + + accumulateEnterLeaveTwoPhaseListeners(dispatchQueue, leave, enter, from, to); + } + + /** + * inlined Object.is polyfill to avoid requiring consumers ship their own + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + */ + function is(x, y) { + return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare + ; + } + + var objectIs = typeof Object.is === 'function' ? Object.is : is; + + var hasOwnProperty$2 = Object.prototype.hasOwnProperty; + /** + * Performs equality by iterating through keys on an object and returning false + * when any key has values which are not strictly equal between the arguments. + * Returns true when the values of all keys are strictly equal. + */ + + function shallowEqual(objA, objB) { + if (objectIs(objA, objB)) { + return true; + } + + if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { + return false; + } + + var keysA = Object.keys(objA); + var keysB = Object.keys(objB); + + if (keysA.length !== keysB.length) { + return false; + } // Test for A's keys different from B. + + + for (var i = 0; i < keysA.length; i++) { + if (!hasOwnProperty$2.call(objB, keysA[i]) || !objectIs(objA[keysA[i]], objB[keysA[i]])) { + return false; + } + } + + return true; + } + + /** + * Given any node return the first leaf node without children. + * + * @param {DOMElement|DOMTextNode} node + * @return {DOMElement|DOMTextNode} + */ + + function getLeafNode(node) { + while (node && node.firstChild) { + node = node.firstChild; + } + + return node; + } + /** + * Get the next sibling within a container. This will walk up the + * DOM if a node's siblings have been exhausted. + * + * @param {DOMElement|DOMTextNode} node + * @return {?DOMElement|DOMTextNode} + */ + + + function getSiblingNode(node) { + while (node) { + if (node.nextSibling) { + return node.nextSibling; + } + + node = node.parentNode; + } + } + /** + * Get object describing the nodes which contain characters at offset. + * + * @param {DOMElement|DOMTextNode} root + * @param {number} offset + * @return {?object} + */ + + + function getNodeForCharacterOffset(root, offset) { + var node = getLeafNode(root); + var nodeStart = 0; + var nodeEnd = 0; + + while (node) { + if (node.nodeType === TEXT_NODE) { + nodeEnd = nodeStart + node.textContent.length; + + if (nodeStart <= offset && nodeEnd >= offset) { + return { + node: node, + offset: offset - nodeStart + }; + } + + nodeStart = nodeEnd; + } + + node = getLeafNode(getSiblingNode(node)); + } + } + + /** + * @param {DOMElement} outerNode + * @return {?object} + */ + + function getOffsets(outerNode) { + var ownerDocument = outerNode.ownerDocument; + var win = ownerDocument && ownerDocument.defaultView || window; + var selection = win.getSelection && win.getSelection(); + + if (!selection || selection.rangeCount === 0) { + return null; + } + + var anchorNode = selection.anchorNode, + anchorOffset = selection.anchorOffset, + focusNode = selection.focusNode, + focusOffset = selection.focusOffset; // In Firefox, anchorNode and focusNode can be "anonymous divs", e.g. the + // up/down buttons on an <input type="number">. Anonymous divs do not seem to + // expose properties, triggering a "Permission denied error" if any of its + // properties are accessed. The only seemingly possible way to avoid erroring + // is to access a property that typically works for non-anonymous divs and + // catch any error that may otherwise arise. See + // https://bugzilla.mozilla.org/show_bug.cgi?id=208427 + + try { + /* eslint-disable no-unused-expressions */ + anchorNode.nodeType; + focusNode.nodeType; + /* eslint-enable no-unused-expressions */ + } catch (e) { + return null; + } + + return getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset); + } + /** + * Returns {start, end} where `start` is the character/codepoint index of + * (anchorNode, anchorOffset) within the textContent of `outerNode`, and + * `end` is the index of (focusNode, focusOffset). + * + * Returns null if you pass in garbage input but we should probably just crash. + * + * Exported only for testing. + */ + + function getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset) { + var length = 0; + var start = -1; + var end = -1; + var indexWithinAnchor = 0; + var indexWithinFocus = 0; + var node = outerNode; + var parentNode = null; + + outer: while (true) { + var next = null; + + while (true) { + if (node === anchorNode && (anchorOffset === 0 || node.nodeType === TEXT_NODE)) { + start = length + anchorOffset; + } + + if (node === focusNode && (focusOffset === 0 || node.nodeType === TEXT_NODE)) { + end = length + focusOffset; + } + + if (node.nodeType === TEXT_NODE) { + length += node.nodeValue.length; + } + + if ((next = node.firstChild) === null) { + break; + } // Moving from `node` to its first child `next`. + + + parentNode = node; + node = next; + } + + while (true) { + if (node === outerNode) { + // If `outerNode` has children, this is always the second time visiting + // it. If it has no children, this is still the first loop, and the only + // valid selection is anchorNode and focusNode both equal to this node + // and both offsets 0, in which case we will have handled above. + break outer; + } + + if (parentNode === anchorNode && ++indexWithinAnchor === anchorOffset) { + start = length; + } + + if (parentNode === focusNode && ++indexWithinFocus === focusOffset) { + end = length; + } + + if ((next = node.nextSibling) !== null) { + break; + } + + node = parentNode; + parentNode = node.parentNode; + } // Moving from `node` to its next sibling `next`. + + + node = next; + } + + if (start === -1 || end === -1) { + // This should never happen. (Would happen if the anchor/focus nodes aren't + // actually inside the passed-in node.) + return null; + } + + return { + start: start, + end: end + }; + } + /** + * In modern non-IE browsers, we can support both forward and backward + * selections. + * + * Note: IE10+ supports the Selection object, but it does not support + * the `extend` method, which means that even in modern IE, it's not possible + * to programmatically create a backward selection. Thus, for all IE + * versions, we use the old IE API to create our selections. + * + * @param {DOMElement|DOMTextNode} node + * @param {object} offsets + */ + + function setOffsets(node, offsets) { + var doc = node.ownerDocument || document; + var win = doc && doc.defaultView || window; // Edge fails with "Object expected" in some scenarios. + // (For instance: TinyMCE editor used in a list component that supports pasting to add more, + // fails when pasting 100+ items) + + if (!win.getSelection) { + return; + } + + var selection = win.getSelection(); + var length = node.textContent.length; + var start = Math.min(offsets.start, length); + var end = offsets.end === undefined ? start : Math.min(offsets.end, length); // IE 11 uses modern selection, but doesn't support the extend method. + // Flip backward selections, so we can set with a single range. + + if (!selection.extend && start > end) { + var temp = end; + end = start; + start = temp; + } + + var startMarker = getNodeForCharacterOffset(node, start); + var endMarker = getNodeForCharacterOffset(node, end); + + if (startMarker && endMarker) { + if (selection.rangeCount === 1 && selection.anchorNode === startMarker.node && selection.anchorOffset === startMarker.offset && selection.focusNode === endMarker.node && selection.focusOffset === endMarker.offset) { + return; + } + + var range = doc.createRange(); + range.setStart(startMarker.node, startMarker.offset); + selection.removeAllRanges(); + + if (start > end) { + selection.addRange(range); + selection.extend(endMarker.node, endMarker.offset); + } else { + range.setEnd(endMarker.node, endMarker.offset); + selection.addRange(range); + } + } + } + + function isTextNode(node) { + return node && node.nodeType === TEXT_NODE; + } + + function containsNode(outerNode, innerNode) { + if (!outerNode || !innerNode) { + return false; + } else if (outerNode === innerNode) { + return true; + } else if (isTextNode(outerNode)) { + return false; + } else if (isTextNode(innerNode)) { + return containsNode(outerNode, innerNode.parentNode); + } else if ('contains' in outerNode) { + return outerNode.contains(innerNode); + } else if (outerNode.compareDocumentPosition) { + return !!(outerNode.compareDocumentPosition(innerNode) & 16); + } else { + return false; + } + } + + function isInDocument(node) { + return node && node.ownerDocument && containsNode(node.ownerDocument.documentElement, node); + } + + function isSameOriginFrame(iframe) { + try { + // Accessing the contentDocument of a HTMLIframeElement can cause the browser + // to throw, e.g. if it has a cross-origin src attribute. + // Safari will show an error in the console when the access results in "Blocked a frame with origin". e.g: + // iframe.contentDocument.defaultView; + // A safety way is to access one of the cross origin properties: Window or Location + // Which might result in "SecurityError" DOM Exception and it is compatible to Safari. + // https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl + return typeof iframe.contentWindow.location.href === 'string'; + } catch (err) { + return false; + } + } + + function getActiveElementDeep() { + var win = window; + var element = getActiveElement(); + + while (element instanceof win.HTMLIFrameElement) { + if (isSameOriginFrame(element)) { + win = element.contentWindow; + } else { + return element; + } + + element = getActiveElement(win.document); + } + + return element; + } + /** + * @ReactInputSelection: React input selection module. Based on Selection.js, + * but modified to be suitable for react and has a couple of bug fixes (doesn't + * assume buttons have range selections allowed). + * Input selection module for React. + */ + + /** + * @hasSelectionCapabilities: we get the element types that support selection + * from https://html.spec.whatwg.org/#do-not-apply, looking at `selectionStart` + * and `selectionEnd` rows. + */ + + + function hasSelectionCapabilities(elem) { + var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); + return nodeName && (nodeName === 'input' && (elem.type === 'text' || elem.type === 'search' || elem.type === 'tel' || elem.type === 'url' || elem.type === 'password') || nodeName === 'textarea' || elem.contentEditable === 'true'); + } + function getSelectionInformation() { + var focusedElem = getActiveElementDeep(); + return { + focusedElem: focusedElem, + selectionRange: hasSelectionCapabilities(focusedElem) ? getSelection(focusedElem) : null + }; + } + /** + * @restoreSelection: If any selection information was potentially lost, + * restore it. This is useful when performing operations that could remove dom + * nodes and place them back in, resulting in focus being lost. + */ + + function restoreSelection(priorSelectionInformation) { + var curFocusedElem = getActiveElementDeep(); + var priorFocusedElem = priorSelectionInformation.focusedElem; + var priorSelectionRange = priorSelectionInformation.selectionRange; + + if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) { + if (priorSelectionRange !== null && hasSelectionCapabilities(priorFocusedElem)) { + setSelection(priorFocusedElem, priorSelectionRange); + } // Focusing a node can change the scroll position, which is undesirable + + + var ancestors = []; + var ancestor = priorFocusedElem; + + while (ancestor = ancestor.parentNode) { + if (ancestor.nodeType === ELEMENT_NODE) { + ancestors.push({ + element: ancestor, + left: ancestor.scrollLeft, + top: ancestor.scrollTop + }); + } + } + + if (typeof priorFocusedElem.focus === 'function') { + priorFocusedElem.focus(); + } + + for (var i = 0; i < ancestors.length; i++) { + var info = ancestors[i]; + info.element.scrollLeft = info.left; + info.element.scrollTop = info.top; + } + } + } + /** + * @getSelection: Gets the selection bounds of a focused textarea, input or + * contentEditable node. + * -@input: Look up selection bounds of this input + * -@return {start: selectionStart, end: selectionEnd} + */ + + function getSelection(input) { + var selection; + + if ('selectionStart' in input) { + // Modern browser with input or textarea. + selection = { + start: input.selectionStart, + end: input.selectionEnd + }; + } else { + // Content editable or old IE textarea. + selection = getOffsets(input); + } + + return selection || { + start: 0, + end: 0 + }; + } + /** + * @setSelection: Sets the selection bounds of a textarea or input and focuses + * the input. + * -@input Set selection bounds of this input or textarea + * -@offsets Object of same form that is returned from get* + */ + + function setSelection(input, offsets) { + var start = offsets.start; + var end = offsets.end; + + if (end === undefined) { + end = start; + } + + if ('selectionStart' in input) { + input.selectionStart = start; + input.selectionEnd = Math.min(end, input.value.length); + } else { + setOffsets(input, offsets); + } + } + + var skipSelectionChangeEvent = canUseDOM && 'documentMode' in document && document.documentMode <= 11; + + function registerEvents$3() { + registerTwoPhaseEvent('onSelect', ['focusout', 'contextmenu', 'dragend', 'focusin', 'keydown', 'keyup', 'mousedown', 'mouseup', 'selectionchange']); + } + + var activeElement$1 = null; + var activeElementInst$1 = null; + var lastSelection = null; + var mouseDown = false; + /** + * Get an object which is a unique representation of the current selection. + * + * The return value will not be consistent across nodes or browsers, but + * two identical selections on the same node will return identical objects. + */ + + function getSelection$1(node) { + if ('selectionStart' in node && hasSelectionCapabilities(node)) { + return { + start: node.selectionStart, + end: node.selectionEnd + }; + } else { + var win = node.ownerDocument && node.ownerDocument.defaultView || window; + var selection = win.getSelection(); + return { + anchorNode: selection.anchorNode, + anchorOffset: selection.anchorOffset, + focusNode: selection.focusNode, + focusOffset: selection.focusOffset + }; + } + } + /** + * Get document associated with the event target. + */ + + + function getEventTargetDocument(eventTarget) { + return eventTarget.window === eventTarget ? eventTarget.document : eventTarget.nodeType === DOCUMENT_NODE ? eventTarget : eventTarget.ownerDocument; + } + /** + * Poll selection to see whether it's changed. + * + * @param {object} nativeEvent + * @param {object} nativeEventTarget + * @return {?SyntheticEvent} + */ + + + function constructSelectEvent(dispatchQueue, nativeEvent, nativeEventTarget) { + // Ensure we have the right element, and that the user is not dragging a + // selection (this matches native `select` event behavior). In HTML5, select + // fires only on input and textarea thus if there's no focused element we + // won't dispatch. + var doc = getEventTargetDocument(nativeEventTarget); + + if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement(doc)) { + return; + } // Only fire when selection has actually changed. + + + var currentSelection = getSelection$1(activeElement$1); + + if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) { + lastSelection = currentSelection; + var listeners = accumulateTwoPhaseListeners(activeElementInst$1, 'onSelect'); + + if (listeners.length > 0) { + var event = new SyntheticEvent('onSelect', 'select', null, nativeEvent, nativeEventTarget); + dispatchQueue.push({ + event: event, + listeners: listeners + }); + event.target = activeElement$1; + } + } + } + /** + * This plugin creates an `onSelect` event that normalizes select events + * across form elements. + * + * Supported elements are: + * - input (see `isTextInputElement`) + * - textarea + * - contentEditable + * + * This differs from native browser implementations in the following ways: + * - Fires on contentEditable fields as well as inputs. + * - Fires for collapsed selection. + * - Fires after user input. + */ + + + function extractEvents$3(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) { + + var targetNode = targetInst ? getNodeFromInstance(targetInst) : window; + + switch (domEventName) { + // Track the input node that has focus. + case 'focusin': + if (isTextInputElement(targetNode) || targetNode.contentEditable === 'true') { + activeElement$1 = targetNode; + activeElementInst$1 = targetInst; + lastSelection = null; + } + + break; + + case 'focusout': + activeElement$1 = null; + activeElementInst$1 = null; + lastSelection = null; + break; + // Don't fire the event while the user is dragging. This matches the + // semantics of the native select event. + + case 'mousedown': + mouseDown = true; + break; + + case 'contextmenu': + case 'mouseup': + case 'dragend': + mouseDown = false; + constructSelectEvent(dispatchQueue, nativeEvent, nativeEventTarget); + break; + // Chrome and IE fire non-standard event when selection is changed (and + // sometimes when it hasn't). IE's event fires out of order with respect + // to key and input events on deletion, so we discard it. + // + // Firefox doesn't support selectionchange, so check selection status + // after each key entry. The selection changes after keydown and before + // keyup, but we check on keydown as well in the case of holding down a + // key, when multiple keydown events are fired but only one keyup is. + // This is also our approach for IE handling, for the reason above. + + case 'selectionchange': + if (skipSelectionChangeEvent) { + break; + } + + // falls through + + case 'keydown': + case 'keyup': + constructSelectEvent(dispatchQueue, nativeEvent, nativeEventTarget); + } + } + + function extractEvents$4(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) { + var reactName = topLevelEventsToReactNames.get(domEventName); + + if (reactName === undefined) { + return; + } + + var SyntheticEventCtor = SyntheticEvent; + var reactEventType = domEventName; + + switch (domEventName) { + case 'keypress': + // Firefox creates a keypress event for function keys too. This removes + // the unwanted keypress events. Enter is however both printable and + // non-printable. One would expect Tab to be as well (but it isn't). + if (getEventCharCode(nativeEvent) === 0) { + return; + } + + /* falls through */ + + case 'keydown': + case 'keyup': + SyntheticEventCtor = SyntheticKeyboardEvent; + break; + + case 'focusin': + reactEventType = 'focus'; + SyntheticEventCtor = SyntheticFocusEvent; + break; + + case 'focusout': + reactEventType = 'blur'; + SyntheticEventCtor = SyntheticFocusEvent; + break; + + case 'beforeblur': + case 'afterblur': + SyntheticEventCtor = SyntheticFocusEvent; + break; + + case 'click': + // Firefox creates a click event on right mouse clicks. This removes the + // unwanted click events. + if (nativeEvent.button === 2) { + return; + } + + /* falls through */ + + case 'auxclick': + case 'dblclick': + case 'mousedown': + case 'mousemove': + case 'mouseup': // TODO: Disabled elements should not respond to mouse events + + /* falls through */ + + case 'mouseout': + case 'mouseover': + case 'contextmenu': + SyntheticEventCtor = SyntheticMouseEvent; + break; + + case 'drag': + case 'dragend': + case 'dragenter': + case 'dragexit': + case 'dragleave': + case 'dragover': + case 'dragstart': + case 'drop': + SyntheticEventCtor = SyntheticDragEvent; + break; + + case 'touchcancel': + case 'touchend': + case 'touchmove': + case 'touchstart': + SyntheticEventCtor = SyntheticTouchEvent; + break; + + case ANIMATION_END: + case ANIMATION_ITERATION: + case ANIMATION_START: + SyntheticEventCtor = SyntheticAnimationEvent; + break; + + case TRANSITION_END: + SyntheticEventCtor = SyntheticTransitionEvent; + break; + + case 'scroll': + SyntheticEventCtor = SyntheticUIEvent; + break; + + case 'wheel': + SyntheticEventCtor = SyntheticWheelEvent; + break; + + case 'copy': + case 'cut': + case 'paste': + SyntheticEventCtor = SyntheticClipboardEvent; + break; + + case 'gotpointercapture': + case 'lostpointercapture': + case 'pointercancel': + case 'pointerdown': + case 'pointermove': + case 'pointerout': + case 'pointerover': + case 'pointerup': + SyntheticEventCtor = SyntheticPointerEvent; + break; + } + + var inCapturePhase = (eventSystemFlags & IS_CAPTURE_PHASE) !== 0; + + { + // Some events don't bubble in the browser. + // In the past, React has always bubbled them, but this can be surprising. + // We're going to try aligning closer to the browser behavior by not bubbling + // them in React either. We'll start by not bubbling onScroll, and then expand. + var accumulateTargetOnly = !inCapturePhase && // TODO: ideally, we'd eventually add all events from + // nonDelegatedEvents list in DOMPluginEventSystem. + // Then we can remove this special list. + // This is a breaking change that can wait until React 18. + domEventName === 'scroll'; + + var _listeners = accumulateSinglePhaseListeners(targetInst, reactName, nativeEvent.type, inCapturePhase, accumulateTargetOnly); + + if (_listeners.length > 0) { + // Intentionally create event lazily. + var _event = new SyntheticEventCtor(reactName, reactEventType, null, nativeEvent, nativeEventTarget); + + dispatchQueue.push({ + event: _event, + listeners: _listeners + }); + } + } + } + + // TODO: remove top-level side effect. + registerSimpleEvents(); + registerEvents$2(); + registerEvents$1(); + registerEvents$3(); + registerEvents(); + + function extractEvents$5(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) { + // TODO: we should remove the concept of a "SimpleEventPlugin". + // This is the basic functionality of the event system. All + // the other plugins are essentially polyfills. So the plugin + // should probably be inlined somewhere and have its logic + // be core the to event system. This would potentially allow + // us to ship builds of React without the polyfilled plugins below. + extractEvents$4(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags); + var shouldProcessPolyfillPlugins = (eventSystemFlags & SHOULD_NOT_PROCESS_POLYFILL_EVENT_PLUGINS) === 0; // We don't process these events unless we are in the + // event's native "bubble" phase, which means that we're + // not in the capture phase. That's because we emulate + // the capture phase here still. This is a trade-off, + // because in an ideal world we would not emulate and use + // the phases properly, like we do with the SimpleEvent + // plugin. However, the plugins below either expect + // emulation (EnterLeave) or use state localized to that + // plugin (BeforeInput, Change, Select). The state in + // these modules complicates things, as you'll essentially + // get the case where the capture phase event might change + // state, only for the following bubble event to come in + // later and not trigger anything as the state now + // invalidates the heuristics of the event plugin. We + // could alter all these plugins to work in such ways, but + // that might cause other unknown side-effects that we + // can't forsee right now. + + if (shouldProcessPolyfillPlugins) { + extractEvents$2(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags); + extractEvents$1(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget); + extractEvents$3(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget); + extractEvents(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget); + } + } // List of events that need to be individually attached to media elements. + + + var mediaEventTypes = ['abort', 'canplay', 'canplaythrough', 'durationchange', 'emptied', 'encrypted', 'ended', 'error', 'loadeddata', 'loadedmetadata', 'loadstart', 'pause', 'play', 'playing', 'progress', 'ratechange', 'seeked', 'seeking', 'stalled', 'suspend', 'timeupdate', 'volumechange', 'waiting']; // We should not delegate these events to the container, but rather + // set them on the actual target element itself. This is primarily + // because these events do not consistently bubble in the DOM. + + var nonDelegatedEvents = new Set(['cancel', 'close', 'invalid', 'load', 'scroll', 'toggle'].concat(mediaEventTypes)); + + function executeDispatch(event, listener, currentTarget) { + var type = event.type || 'unknown-event'; + event.currentTarget = currentTarget; + invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event); + event.currentTarget = null; + } + + function processDispatchQueueItemsInOrder(event, dispatchListeners, inCapturePhase) { + var previousInstance; + + if (inCapturePhase) { + for (var i = dispatchListeners.length - 1; i >= 0; i--) { + var _dispatchListeners$i = dispatchListeners[i], + instance = _dispatchListeners$i.instance, + currentTarget = _dispatchListeners$i.currentTarget, + listener = _dispatchListeners$i.listener; + + if (instance !== previousInstance && event.isPropagationStopped()) { + return; + } + + executeDispatch(event, listener, currentTarget); + previousInstance = instance; + } + } else { + for (var _i = 0; _i < dispatchListeners.length; _i++) { + var _dispatchListeners$_i = dispatchListeners[_i], + _instance = _dispatchListeners$_i.instance, + _currentTarget = _dispatchListeners$_i.currentTarget, + _listener = _dispatchListeners$_i.listener; + + if (_instance !== previousInstance && event.isPropagationStopped()) { + return; + } + + executeDispatch(event, _listener, _currentTarget); + previousInstance = _instance; + } + } + } + + function processDispatchQueue(dispatchQueue, eventSystemFlags) { + var inCapturePhase = (eventSystemFlags & IS_CAPTURE_PHASE) !== 0; + + for (var i = 0; i < dispatchQueue.length; i++) { + var _dispatchQueue$i = dispatchQueue[i], + event = _dispatchQueue$i.event, + listeners = _dispatchQueue$i.listeners; + processDispatchQueueItemsInOrder(event, listeners, inCapturePhase); // event system doesn't use pooling. + } // This would be a good time to rethrow if any of the event handlers threw. + + + rethrowCaughtError(); + } + + function dispatchEventsForPlugins(domEventName, eventSystemFlags, nativeEvent, targetInst, targetContainer) { + var nativeEventTarget = getEventTarget(nativeEvent); + var dispatchQueue = []; + extractEvents$5(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags); + processDispatchQueue(dispatchQueue, eventSystemFlags); + } + + function listenToNonDelegatedEvent(domEventName, targetElement) { + var isCapturePhaseListener = false; + var listenerSet = getEventListenerSet(targetElement); + var listenerSetKey = getListenerSetKey(domEventName, isCapturePhaseListener); + + if (!listenerSet.has(listenerSetKey)) { + addTrappedEventListener(targetElement, domEventName, IS_NON_DELEGATED, isCapturePhaseListener); + listenerSet.add(listenerSetKey); + } + } + var listeningMarker = '_reactListening' + Math.random().toString(36).slice(2); + function listenToAllSupportedEvents(rootContainerElement) { + { + if (rootContainerElement[listeningMarker]) { + // Performance optimization: don't iterate through events + // for the same portal container or root node more than once. + // TODO: once we remove the flag, we may be able to also + // remove some of the bookkeeping maps used for laziness. + return; + } + + rootContainerElement[listeningMarker] = true; + allNativeEvents.forEach(function (domEventName) { + if (!nonDelegatedEvents.has(domEventName)) { + listenToNativeEvent(domEventName, false, rootContainerElement, null); + } + + listenToNativeEvent(domEventName, true, rootContainerElement, null); + }); + } + } + function listenToNativeEvent(domEventName, isCapturePhaseListener, rootContainerElement, targetElement) { + var eventSystemFlags = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0; + var target = rootContainerElement; // selectionchange needs to be attached to the document + // otherwise it won't capture incoming events that are only + // triggered on the document directly. + + if (domEventName === 'selectionchange' && rootContainerElement.nodeType !== DOCUMENT_NODE) { + target = rootContainerElement.ownerDocument; + } // If the event can be delegated (or is capture phase), we can + // register it to the root container. Otherwise, we should + // register the event to the target element and mark it as + // a non-delegated event. + + + if (targetElement !== null && !isCapturePhaseListener && nonDelegatedEvents.has(domEventName)) { + // For all non-delegated events, apart from scroll, we attach + // their event listeners to the respective elements that their + // events fire on. That means we can skip this step, as event + // listener has already been added previously. However, we + // special case the scroll event because the reality is that any + // element can scroll. + // TODO: ideally, we'd eventually apply the same logic to all + // events from the nonDelegatedEvents list. Then we can remove + // this special case and use the same logic for all events. + if (domEventName !== 'scroll') { + return; + } + + eventSystemFlags |= IS_NON_DELEGATED; + target = targetElement; + } + + var listenerSet = getEventListenerSet(target); + var listenerSetKey = getListenerSetKey(domEventName, isCapturePhaseListener); // If the listener entry is empty or we should upgrade, then + // we need to trap an event listener onto the target. + + if (!listenerSet.has(listenerSetKey)) { + if (isCapturePhaseListener) { + eventSystemFlags |= IS_CAPTURE_PHASE; + } + + addTrappedEventListener(target, domEventName, eventSystemFlags, isCapturePhaseListener); + listenerSet.add(listenerSetKey); + } + } + + function addTrappedEventListener(targetContainer, domEventName, eventSystemFlags, isCapturePhaseListener, isDeferredListenerForLegacyFBSupport) { + var listener = createEventListenerWrapperWithPriority(targetContainer, domEventName, eventSystemFlags); // If passive option is not supported, then the event will be + // active and not passive. + + var isPassiveListener = undefined; + + if (passiveBrowserEventsSupported) { + // Browsers introduced an intervention, making these events + // passive by default on document. React doesn't bind them + // to document anymore, but changing this now would undo + // the performance wins from the change. So we emulate + // the existing behavior manually on the roots now. + // https://github.com/facebook/react/issues/19651 + if (domEventName === 'touchstart' || domEventName === 'touchmove' || domEventName === 'wheel') { + isPassiveListener = true; + } + } + + targetContainer = targetContainer; + var unsubscribeListener; // When legacyFBSupport is enabled, it's for when we + + + if (isCapturePhaseListener) { + if (isPassiveListener !== undefined) { + unsubscribeListener = addEventCaptureListenerWithPassiveFlag(targetContainer, domEventName, listener, isPassiveListener); + } else { + unsubscribeListener = addEventCaptureListener(targetContainer, domEventName, listener); + } + } else { + if (isPassiveListener !== undefined) { + unsubscribeListener = addEventBubbleListenerWithPassiveFlag(targetContainer, domEventName, listener, isPassiveListener); + } else { + unsubscribeListener = addEventBubbleListener(targetContainer, domEventName, listener); + } + } + } + + function isMatchingRootContainer(grandContainer, targetContainer) { + return grandContainer === targetContainer || grandContainer.nodeType === COMMENT_NODE && grandContainer.parentNode === targetContainer; + } + + function dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativeEvent, targetInst, targetContainer) { + var ancestorInst = targetInst; + + if ((eventSystemFlags & IS_EVENT_HANDLE_NON_MANAGED_NODE) === 0 && (eventSystemFlags & IS_NON_DELEGATED) === 0) { + var targetContainerNode = targetContainer; // If we are using the legacy FB support flag, we + + if (targetInst !== null) { + // The below logic attempts to work out if we need to change + // the target fiber to a different ancestor. We had similar logic + // in the legacy event system, except the big difference between + // systems is that the modern event system now has an event listener + // attached to each React Root and React Portal Root. Together, + // the DOM nodes representing these roots are the "rootContainer". + // To figure out which ancestor instance we should use, we traverse + // up the fiber tree from the target instance and attempt to find + // root boundaries that match that of our current "rootContainer". + // If we find that "rootContainer", we find the parent fiber + // sub-tree for that root and make that our ancestor instance. + var node = targetInst; + + mainLoop: while (true) { + if (node === null) { + return; + } + + var nodeTag = node.tag; + + if (nodeTag === HostRoot || nodeTag === HostPortal) { + var container = node.stateNode.containerInfo; + + if (isMatchingRootContainer(container, targetContainerNode)) { + break; + } + + if (nodeTag === HostPortal) { + // The target is a portal, but it's not the rootContainer we're looking for. + // Normally portals handle their own events all the way down to the root. + // So we should be able to stop now. However, we don't know if this portal + // was part of *our* root. + var grandNode = node.return; + + while (grandNode !== null) { + var grandTag = grandNode.tag; + + if (grandTag === HostRoot || grandTag === HostPortal) { + var grandContainer = grandNode.stateNode.containerInfo; + + if (isMatchingRootContainer(grandContainer, targetContainerNode)) { + // This is the rootContainer we're looking for and we found it as + // a parent of the Portal. That means we can ignore it because the + // Portal will bubble through to us. + return; + } + } + + grandNode = grandNode.return; + } + } // Now we need to find it's corresponding host fiber in the other + // tree. To do this we can use getClosestInstanceFromNode, but we + // need to validate that the fiber is a host instance, otherwise + // we need to traverse up through the DOM till we find the correct + // node that is from the other tree. + + + while (container !== null) { + var parentNode = getClosestInstanceFromNode(container); + + if (parentNode === null) { + return; + } + + var parentTag = parentNode.tag; + + if (parentTag === HostComponent || parentTag === HostText) { + node = ancestorInst = parentNode; + continue mainLoop; + } + + container = container.parentNode; + } + } + + node = node.return; + } + } + } + + batchedEventUpdates(function () { + return dispatchEventsForPlugins(domEventName, eventSystemFlags, nativeEvent, ancestorInst); + }); + } + + function createDispatchListener(instance, listener, currentTarget) { + return { + instance: instance, + listener: listener, + currentTarget: currentTarget + }; + } + + function accumulateSinglePhaseListeners(targetFiber, reactName, nativeEventType, inCapturePhase, accumulateTargetOnly) { + var captureName = reactName !== null ? reactName + 'Capture' : null; + var reactEventName = inCapturePhase ? captureName : reactName; + var listeners = []; + var instance = targetFiber; + var lastHostComponent = null; // Accumulate all instances and listeners via the target -> root path. + + while (instance !== null) { + var _instance2 = instance, + stateNode = _instance2.stateNode, + tag = _instance2.tag; // Handle listeners that are on HostComponents (i.e. <div>) + + if (tag === HostComponent && stateNode !== null) { + lastHostComponent = stateNode; // createEventHandle listeners + + + if (reactEventName !== null) { + var listener = getListener(instance, reactEventName); + + if (listener != null) { + listeners.push(createDispatchListener(instance, listener, lastHostComponent)); + } + } + } // If we are only accumulating events for the target, then we don't + // continue to propagate through the React fiber tree to find other + // listeners. + + + if (accumulateTargetOnly) { + break; + } + + instance = instance.return; + } + + return listeners; + } // We should only use this function for: + // - BeforeInputEventPlugin + // - ChangeEventPlugin + // - SelectEventPlugin + // This is because we only process these plugins + // in the bubble phase, so we need to accumulate two + // phase event listeners (via emulation). + + function accumulateTwoPhaseListeners(targetFiber, reactName) { + var captureName = reactName + 'Capture'; + var listeners = []; + var instance = targetFiber; // Accumulate all instances and listeners via the target -> root path. + + while (instance !== null) { + var _instance3 = instance, + stateNode = _instance3.stateNode, + tag = _instance3.tag; // Handle listeners that are on HostComponents (i.e. <div>) + + if (tag === HostComponent && stateNode !== null) { + var currentTarget = stateNode; + var captureListener = getListener(instance, captureName); + + if (captureListener != null) { + listeners.unshift(createDispatchListener(instance, captureListener, currentTarget)); + } + + var bubbleListener = getListener(instance, reactName); + + if (bubbleListener != null) { + listeners.push(createDispatchListener(instance, bubbleListener, currentTarget)); + } + } + + instance = instance.return; + } + + return listeners; + } + + function getParent(inst) { + if (inst === null) { + return null; + } + + do { + inst = inst.return; // TODO: If this is a HostRoot we might want to bail out. + // That is depending on if we want nested subtrees (layers) to bubble + // events to their parent. We could also go through parentNode on the + // host node but that wouldn't work for React Native and doesn't let us + // do the portal feature. + } while (inst && inst.tag !== HostComponent); + + if (inst) { + return inst; + } + + return null; + } + /** + * Return the lowest common ancestor of A and B, or null if they are in + * different trees. + */ + + + function getLowestCommonAncestor(instA, instB) { + var nodeA = instA; + var nodeB = instB; + var depthA = 0; + + for (var tempA = nodeA; tempA; tempA = getParent(tempA)) { + depthA++; + } + + var depthB = 0; + + for (var tempB = nodeB; tempB; tempB = getParent(tempB)) { + depthB++; + } // If A is deeper, crawl up. + + + while (depthA - depthB > 0) { + nodeA = getParent(nodeA); + depthA--; + } // If B is deeper, crawl up. + + + while (depthB - depthA > 0) { + nodeB = getParent(nodeB); + depthB--; + } // Walk in lockstep until we find a match. + + + var depth = depthA; + + while (depth--) { + if (nodeA === nodeB || nodeB !== null && nodeA === nodeB.alternate) { + return nodeA; + } + + nodeA = getParent(nodeA); + nodeB = getParent(nodeB); + } + + return null; + } + + function accumulateEnterLeaveListenersForEvent(dispatchQueue, event, target, common, inCapturePhase) { + var registrationName = event._reactName; + var listeners = []; + var instance = target; + + while (instance !== null) { + if (instance === common) { + break; + } + + var _instance4 = instance, + alternate = _instance4.alternate, + stateNode = _instance4.stateNode, + tag = _instance4.tag; + + if (alternate !== null && alternate === common) { + break; + } + + if (tag === HostComponent && stateNode !== null) { + var currentTarget = stateNode; + + if (inCapturePhase) { + var captureListener = getListener(instance, registrationName); + + if (captureListener != null) { + listeners.unshift(createDispatchListener(instance, captureListener, currentTarget)); + } + } else if (!inCapturePhase) { + var bubbleListener = getListener(instance, registrationName); + + if (bubbleListener != null) { + listeners.push(createDispatchListener(instance, bubbleListener, currentTarget)); + } + } + } + + instance = instance.return; + } + + if (listeners.length !== 0) { + dispatchQueue.push({ + event: event, + listeners: listeners + }); + } + } // We should only use this function for: + // - EnterLeaveEventPlugin + // This is because we only process this plugin + // in the bubble phase, so we need to accumulate two + // phase event listeners. + + + function accumulateEnterLeaveTwoPhaseListeners(dispatchQueue, leaveEvent, enterEvent, from, to) { + var common = from && to ? getLowestCommonAncestor(from, to) : null; + + if (from !== null) { + accumulateEnterLeaveListenersForEvent(dispatchQueue, leaveEvent, from, common, false); + } + + if (to !== null && enterEvent !== null) { + accumulateEnterLeaveListenersForEvent(dispatchQueue, enterEvent, to, common, true); + } + } + function getListenerSetKey(domEventName, capture) { + return domEventName + "__" + (capture ? 'capture' : 'bubble'); + } + + var didWarnInvalidHydration = false; + var DANGEROUSLY_SET_INNER_HTML = 'dangerouslySetInnerHTML'; + var SUPPRESS_CONTENT_EDITABLE_WARNING = 'suppressContentEditableWarning'; + var SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning'; + var AUTOFOCUS = 'autoFocus'; + var CHILDREN = 'children'; + var STYLE = 'style'; + var HTML$1 = '__html'; + var HTML_NAMESPACE$1 = Namespaces.html; + var warnedUnknownTags; + var suppressHydrationWarning; + var validatePropertiesInDevelopment; + var warnForTextDifference; + var warnForPropDifference; + var warnForExtraAttributes; + var warnForInvalidEventListener; + var canDiffStyleForHydrationWarning; + var normalizeMarkupForTextOrAttribute; + var normalizeHTML; + + { + warnedUnknownTags = { + // There are working polyfills for <dialog>. Let people use it. + dialog: true, + // Electron ships a custom <webview> tag to display external web content in + // an isolated frame and process. + // This tag is not present in non Electron environments such as JSDom which + // is often used for testing purposes. + // @see https://electronjs.org/docs/api/webview-tag + webview: true + }; + + validatePropertiesInDevelopment = function (type, props) { + validateProperties(type, props); + validateProperties$1(type, props); + validateProperties$2(type, props, { + registrationNameDependencies: registrationNameDependencies, + possibleRegistrationNames: possibleRegistrationNames + }); + }; // IE 11 parses & normalizes the style attribute as opposed to other + // browsers. It adds spaces and sorts the properties in some + // non-alphabetical order. Handling that would require sorting CSS + // properties in the client & server versions or applying + // `expectedStyle` to a temporary DOM node to read its `style` attribute + // normalized. Since it only affects IE, we're skipping style warnings + // in that browser completely in favor of doing all that work. + // See https://github.com/facebook/react/issues/11807 + + + canDiffStyleForHydrationWarning = canUseDOM && !document.documentMode; // HTML parsing normalizes CR and CRLF to LF. + // It also can turn \u0000 into \uFFFD inside attributes. + // https://www.w3.org/TR/html5/single-page.html#preprocessing-the-input-stream + // If we have a mismatch, it might be caused by that. + // We will still patch up in this case but not fire the warning. + + var NORMALIZE_NEWLINES_REGEX = /\r\n?/g; + var NORMALIZE_NULL_AND_REPLACEMENT_REGEX = /\u0000|\uFFFD/g; + + normalizeMarkupForTextOrAttribute = function (markup) { + var markupString = typeof markup === 'string' ? markup : '' + markup; + return markupString.replace(NORMALIZE_NEWLINES_REGEX, '\n').replace(NORMALIZE_NULL_AND_REPLACEMENT_REGEX, ''); + }; + + warnForTextDifference = function (serverText, clientText) { + if (didWarnInvalidHydration) { + return; + } + + var normalizedClientText = normalizeMarkupForTextOrAttribute(clientText); + var normalizedServerText = normalizeMarkupForTextOrAttribute(serverText); + + if (normalizedServerText === normalizedClientText) { + return; + } + + didWarnInvalidHydration = true; + + error('Text content did not match. Server: "%s" Client: "%s"', normalizedServerText, normalizedClientText); + }; + + warnForPropDifference = function (propName, serverValue, clientValue) { + if (didWarnInvalidHydration) { + return; + } + + var normalizedClientValue = normalizeMarkupForTextOrAttribute(clientValue); + var normalizedServerValue = normalizeMarkupForTextOrAttribute(serverValue); + + if (normalizedServerValue === normalizedClientValue) { + return; + } + + didWarnInvalidHydration = true; + + error('Prop `%s` did not match. Server: %s Client: %s', propName, JSON.stringify(normalizedServerValue), JSON.stringify(normalizedClientValue)); + }; + + warnForExtraAttributes = function (attributeNames) { + if (didWarnInvalidHydration) { + return; + } + + didWarnInvalidHydration = true; + var names = []; + attributeNames.forEach(function (name) { + names.push(name); + }); + + error('Extra attributes from the server: %s', names); + }; + + warnForInvalidEventListener = function (registrationName, listener) { + if (listener === false) { + error('Expected `%s` listener to be a function, instead got `false`.\n\n' + 'If you used to conditionally omit it with %s={condition && value}, ' + 'pass %s={condition ? value : undefined} instead.', registrationName, registrationName, registrationName); + } else { + error('Expected `%s` listener to be a function, instead got a value of `%s` type.', registrationName, typeof listener); + } + }; // Parse the HTML and read it back to normalize the HTML string so that it + // can be used for comparison. + + + normalizeHTML = function (parent, html) { + // We could have created a separate document here to avoid + // re-initializing custom elements if they exist. But this breaks + // how <noscript> is being handled. So we use the same document. + // See the discussion in https://github.com/facebook/react/pull/11157. + var testElement = parent.namespaceURI === HTML_NAMESPACE$1 ? parent.ownerDocument.createElement(parent.tagName) : parent.ownerDocument.createElementNS(parent.namespaceURI, parent.tagName); + testElement.innerHTML = html; + return testElement.innerHTML; + }; + } + + function getOwnerDocumentFromRootContainer(rootContainerElement) { + return rootContainerElement.nodeType === DOCUMENT_NODE ? rootContainerElement : rootContainerElement.ownerDocument; + } + + function noop() {} + + function trapClickOnNonInteractiveElement(node) { + // Mobile Safari does not fire properly bubble click events on + // non-interactive elements, which means delegated click listeners do not + // fire. The workaround for this bug involves attaching an empty click + // listener on the target node. + // https://www.quirksmode.org/blog/archives/2010/09/click_event_del.html + // Just set it using the onclick property so that we don't have to manage any + // bookkeeping for it. Not sure if we need to clear it when the listener is + // removed. + // TODO: Only do this for the relevant Safaris maybe? + node.onclick = noop; + } + + function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) { + for (var propKey in nextProps) { + if (!nextProps.hasOwnProperty(propKey)) { + continue; + } + + var nextProp = nextProps[propKey]; + + if (propKey === STYLE) { + { + if (nextProp) { + // Freeze the next style object so that we can assume it won't be + // mutated. We have already warned for this in the past. + Object.freeze(nextProp); + } + } // Relies on `updateStylesByID` not mutating `styleUpdates`. + + + setValueForStyles(domElement, nextProp); + } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { + var nextHtml = nextProp ? nextProp[HTML$1] : undefined; + + if (nextHtml != null) { + setInnerHTML(domElement, nextHtml); + } + } else if (propKey === CHILDREN) { + if (typeof nextProp === 'string') { + // Avoid setting initial textContent when the text is empty. In IE11 setting + // textContent on a <textarea> will cause the placeholder to not + // show within the <textarea> until it has been focused and blurred again. + // https://github.com/facebook/react/issues/6731#issuecomment-254874553 + var canSetTextContent = tag !== 'textarea' || nextProp !== ''; + + if (canSetTextContent) { + setTextContent(domElement, nextProp); + } + } else if (typeof nextProp === 'number') { + setTextContent(domElement, '' + nextProp); + } + } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (propKey === AUTOFOCUS) ; else if (registrationNameDependencies.hasOwnProperty(propKey)) { + if (nextProp != null) { + if ( typeof nextProp !== 'function') { + warnForInvalidEventListener(propKey, nextProp); + } + + if (propKey === 'onScroll') { + listenToNonDelegatedEvent('scroll', domElement); + } + } + } else if (nextProp != null) { + setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag); + } + } + } + + function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) { + // TODO: Handle wasCustomComponentTag + for (var i = 0; i < updatePayload.length; i += 2) { + var propKey = updatePayload[i]; + var propValue = updatePayload[i + 1]; + + if (propKey === STYLE) { + setValueForStyles(domElement, propValue); + } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { + setInnerHTML(domElement, propValue); + } else if (propKey === CHILDREN) { + setTextContent(domElement, propValue); + } else { + setValueForProperty(domElement, propKey, propValue, isCustomComponentTag); + } + } + } + + function createElement(type, props, rootContainerElement, parentNamespace) { + var isCustomComponentTag; // We create tags in the namespace of their parent container, except HTML + // tags get no namespace. + + var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement); + var domElement; + var namespaceURI = parentNamespace; + + if (namespaceURI === HTML_NAMESPACE$1) { + namespaceURI = getIntrinsicNamespace(type); + } + + if (namespaceURI === HTML_NAMESPACE$1) { + { + isCustomComponentTag = isCustomComponent(type, props); // Should this check be gated by parent namespace? Not sure we want to + // allow <SVG> or <mATH>. + + if (!isCustomComponentTag && type !== type.toLowerCase()) { + error('<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.', type); + } + } + + if (type === 'script') { + // Create the script via .innerHTML so its "parser-inserted" flag is + // set to true and it does not execute + var div = ownerDocument.createElement('div'); + + div.innerHTML = '<script><' + '/script>'; // eslint-disable-line + // This is guaranteed to yield a script element. + + var firstChild = div.firstChild; + domElement = div.removeChild(firstChild); + } else if (typeof props.is === 'string') { + // $FlowIssue `createElement` should be updated for Web Components + domElement = ownerDocument.createElement(type, { + is: props.is + }); + } else { + // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug. + // See discussion in https://github.com/facebook/react/pull/6896 + // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240 + domElement = ownerDocument.createElement(type); // Normally attributes are assigned in `setInitialDOMProperties`, however the `multiple` and `size` + // attributes on `select`s needs to be added before `option`s are inserted. + // This prevents: + // - a bug where the `select` does not scroll to the correct option because singular + // `select` elements automatically pick the first item #13222 + // - a bug where the `select` set the first item as selected despite the `size` attribute #14239 + // See https://github.com/facebook/react/issues/13222 + // and https://github.com/facebook/react/issues/14239 + + if (type === 'select') { + var node = domElement; + + if (props.multiple) { + node.multiple = true; + } else if (props.size) { + // Setting a size greater than 1 causes a select to behave like `multiple=true`, where + // it is possible that no option is selected. + // + // This is only necessary when a select in "single selection mode". + node.size = props.size; + } + } + } + } else { + domElement = ownerDocument.createElementNS(namespaceURI, type); + } + + { + if (namespaceURI === HTML_NAMESPACE$1) { + if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) { + warnedUnknownTags[type] = true; + + error('The tag <%s> is unrecognized in this browser. ' + 'If you meant to render a React component, start its name with ' + 'an uppercase letter.', type); + } + } + } + + return domElement; + } + function createTextNode(text, rootContainerElement) { + return getOwnerDocumentFromRootContainer(rootContainerElement).createTextNode(text); + } + function setInitialProperties(domElement, tag, rawProps, rootContainerElement) { + var isCustomComponentTag = isCustomComponent(tag, rawProps); + + { + validatePropertiesInDevelopment(tag, rawProps); + } // TODO: Make sure that we check isMounted before firing any of these events. + + + var props; + + switch (tag) { + case 'dialog': + listenToNonDelegatedEvent('cancel', domElement); + listenToNonDelegatedEvent('close', domElement); + props = rawProps; + break; + + case 'iframe': + case 'object': + case 'embed': + // We listen to this event in case to ensure emulated bubble + // listeners still fire for the load event. + listenToNonDelegatedEvent('load', domElement); + props = rawProps; + break; + + case 'video': + case 'audio': + // We listen to these events in case to ensure emulated bubble + // listeners still fire for all the media events. + for (var i = 0; i < mediaEventTypes.length; i++) { + listenToNonDelegatedEvent(mediaEventTypes[i], domElement); + } + + props = rawProps; + break; + + case 'source': + // We listen to this event in case to ensure emulated bubble + // listeners still fire for the error event. + listenToNonDelegatedEvent('error', domElement); + props = rawProps; + break; + + case 'img': + case 'image': + case 'link': + // We listen to these events in case to ensure emulated bubble + // listeners still fire for error and load events. + listenToNonDelegatedEvent('error', domElement); + listenToNonDelegatedEvent('load', domElement); + props = rawProps; + break; + + case 'details': + // We listen to this event in case to ensure emulated bubble + // listeners still fire for the toggle event. + listenToNonDelegatedEvent('toggle', domElement); + props = rawProps; + break; + + case 'input': + initWrapperState(domElement, rawProps); + props = getHostProps(domElement, rawProps); // We listen to this event in case to ensure emulated bubble + // listeners still fire for the invalid event. + + listenToNonDelegatedEvent('invalid', domElement); + + break; + + case 'option': + validateProps(domElement, rawProps); + props = getHostProps$1(domElement, rawProps); + break; + + case 'select': + initWrapperState$1(domElement, rawProps); + props = getHostProps$2(domElement, rawProps); // We listen to this event in case to ensure emulated bubble + // listeners still fire for the invalid event. + + listenToNonDelegatedEvent('invalid', domElement); + + break; + + case 'textarea': + initWrapperState$2(domElement, rawProps); + props = getHostProps$3(domElement, rawProps); // We listen to this event in case to ensure emulated bubble + // listeners still fire for the invalid event. + + listenToNonDelegatedEvent('invalid', domElement); + + break; + + default: + props = rawProps; + } + + assertValidProps(tag, props); + setInitialDOMProperties(tag, domElement, rootContainerElement, props, isCustomComponentTag); + + switch (tag) { + case 'input': + // TODO: Make sure we check if this is still unmounted or do any clean + // up necessary since we never stop tracking anymore. + track(domElement); + postMountWrapper(domElement, rawProps, false); + break; + + case 'textarea': + // TODO: Make sure we check if this is still unmounted or do any clean + // up necessary since we never stop tracking anymore. + track(domElement); + postMountWrapper$3(domElement); + break; + + case 'option': + postMountWrapper$1(domElement, rawProps); + break; + + case 'select': + postMountWrapper$2(domElement, rawProps); + break; + + default: + if (typeof props.onClick === 'function') { + // TODO: This cast may not be sound for SVG, MathML or custom elements. + trapClickOnNonInteractiveElement(domElement); + } + + break; + } + } // Calculate the diff between the two objects. + + function diffProperties(domElement, tag, lastRawProps, nextRawProps, rootContainerElement) { + { + validatePropertiesInDevelopment(tag, nextRawProps); + } + + var updatePayload = null; + var lastProps; + var nextProps; + + switch (tag) { + case 'input': + lastProps = getHostProps(domElement, lastRawProps); + nextProps = getHostProps(domElement, nextRawProps); + updatePayload = []; + break; + + case 'option': + lastProps = getHostProps$1(domElement, lastRawProps); + nextProps = getHostProps$1(domElement, nextRawProps); + updatePayload = []; + break; + + case 'select': + lastProps = getHostProps$2(domElement, lastRawProps); + nextProps = getHostProps$2(domElement, nextRawProps); + updatePayload = []; + break; + + case 'textarea': + lastProps = getHostProps$3(domElement, lastRawProps); + nextProps = getHostProps$3(domElement, nextRawProps); + updatePayload = []; + break; + + default: + lastProps = lastRawProps; + nextProps = nextRawProps; + + if (typeof lastProps.onClick !== 'function' && typeof nextProps.onClick === 'function') { + // TODO: This cast may not be sound for SVG, MathML or custom elements. + trapClickOnNonInteractiveElement(domElement); + } + + break; + } + + assertValidProps(tag, nextProps); + var propKey; + var styleName; + var styleUpdates = null; + + for (propKey in lastProps) { + if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) { + continue; + } + + if (propKey === STYLE) { + var lastStyle = lastProps[propKey]; + + for (styleName in lastStyle) { + if (lastStyle.hasOwnProperty(styleName)) { + if (!styleUpdates) { + styleUpdates = {}; + } + + styleUpdates[styleName] = ''; + } + } + } else if (propKey === DANGEROUSLY_SET_INNER_HTML || propKey === CHILDREN) ; else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (propKey === AUTOFOCUS) ; else if (registrationNameDependencies.hasOwnProperty(propKey)) { + // This is a special case. If any listener updates we need to ensure + // that the "current" fiber pointer gets updated so we need a commit + // to update this element. + if (!updatePayload) { + updatePayload = []; + } + } else { + // For all other deleted properties we add it to the queue. We use + // the allowed property list in the commit phase instead. + (updatePayload = updatePayload || []).push(propKey, null); + } + } + + for (propKey in nextProps) { + var nextProp = nextProps[propKey]; + var lastProp = lastProps != null ? lastProps[propKey] : undefined; + + if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) { + continue; + } + + if (propKey === STYLE) { + { + if (nextProp) { + // Freeze the next style object so that we can assume it won't be + // mutated. We have already warned for this in the past. + Object.freeze(nextProp); + } + } + + if (lastProp) { + // Unset styles on `lastProp` but not on `nextProp`. + for (styleName in lastProp) { + if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) { + if (!styleUpdates) { + styleUpdates = {}; + } + + styleUpdates[styleName] = ''; + } + } // Update styles that changed since `lastProp`. + + + for (styleName in nextProp) { + if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) { + if (!styleUpdates) { + styleUpdates = {}; + } + + styleUpdates[styleName] = nextProp[styleName]; + } + } + } else { + // Relies on `updateStylesByID` not mutating `styleUpdates`. + if (!styleUpdates) { + if (!updatePayload) { + updatePayload = []; + } + + updatePayload.push(propKey, styleUpdates); + } + + styleUpdates = nextProp; + } + } else if (propKey === DANGEROUSLY_SET_INNER_HTML) { + var nextHtml = nextProp ? nextProp[HTML$1] : undefined; + var lastHtml = lastProp ? lastProp[HTML$1] : undefined; + + if (nextHtml != null) { + if (lastHtml !== nextHtml) { + (updatePayload = updatePayload || []).push(propKey, nextHtml); + } + } + } else if (propKey === CHILDREN) { + if (typeof nextProp === 'string' || typeof nextProp === 'number') { + (updatePayload = updatePayload || []).push(propKey, '' + nextProp); + } + } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (registrationNameDependencies.hasOwnProperty(propKey)) { + if (nextProp != null) { + // We eagerly listen to this even though we haven't committed yet. + if ( typeof nextProp !== 'function') { + warnForInvalidEventListener(propKey, nextProp); + } + + if (propKey === 'onScroll') { + listenToNonDelegatedEvent('scroll', domElement); + } + } + + if (!updatePayload && lastProp !== nextProp) { + // This is a special case. If any listener updates we need to ensure + // that the "current" props pointer gets updated so we need a commit + // to update this element. + updatePayload = []; + } + } else if (typeof nextProp === 'object' && nextProp !== null && nextProp.$$typeof === REACT_OPAQUE_ID_TYPE) { + // If we encounter useOpaqueReference's opaque object, this means we are hydrating. + // In this case, call the opaque object's toString function which generates a new client + // ID so client and server IDs match and throws to rerender. + nextProp.toString(); + } else { + // For any other property we always add it to the queue and then we + // filter it out using the allowed property list during the commit. + (updatePayload = updatePayload || []).push(propKey, nextProp); + } + } + + if (styleUpdates) { + { + validateShorthandPropertyCollisionInDev(styleUpdates, nextProps[STYLE]); + } + + (updatePayload = updatePayload || []).push(STYLE, styleUpdates); + } + + return updatePayload; + } // Apply the diff. + + function updateProperties(domElement, updatePayload, tag, lastRawProps, nextRawProps) { + // Update checked *before* name. + // In the middle of an update, it is possible to have multiple checked. + // When a checked radio tries to change name, browser makes another radio's checked false. + if (tag === 'input' && nextRawProps.type === 'radio' && nextRawProps.name != null) { + updateChecked(domElement, nextRawProps); + } + + var wasCustomComponentTag = isCustomComponent(tag, lastRawProps); + var isCustomComponentTag = isCustomComponent(tag, nextRawProps); // Apply the diff. + + updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag); // TODO: Ensure that an update gets scheduled if any of the special props + // changed. + + switch (tag) { + case 'input': + // Update the wrapper around inputs *after* updating props. This has to + // happen after `updateDOMProperties`. Otherwise HTML5 input validations + // raise warnings and prevent the new value from being assigned. + updateWrapper(domElement, nextRawProps); + break; + + case 'textarea': + updateWrapper$1(domElement, nextRawProps); + break; + + case 'select': + // <select> value update needs to occur after <option> children + // reconciliation + postUpdateWrapper(domElement, nextRawProps); + break; + } + } + + function getPossibleStandardName(propName) { + { + var lowerCasedName = propName.toLowerCase(); + + if (!possibleStandardNames.hasOwnProperty(lowerCasedName)) { + return null; + } + + return possibleStandardNames[lowerCasedName] || null; + } + } + + function diffHydratedProperties(domElement, tag, rawProps, parentNamespace, rootContainerElement) { + var isCustomComponentTag; + var extraAttributeNames; + + { + suppressHydrationWarning = rawProps[SUPPRESS_HYDRATION_WARNING] === true; + isCustomComponentTag = isCustomComponent(tag, rawProps); + validatePropertiesInDevelopment(tag, rawProps); + } // TODO: Make sure that we check isMounted before firing any of these events. + + + switch (tag) { + case 'dialog': + listenToNonDelegatedEvent('cancel', domElement); + listenToNonDelegatedEvent('close', domElement); + break; + + case 'iframe': + case 'object': + case 'embed': + // We listen to this event in case to ensure emulated bubble + // listeners still fire for the load event. + listenToNonDelegatedEvent('load', domElement); + break; + + case 'video': + case 'audio': + // We listen to these events in case to ensure emulated bubble + // listeners still fire for all the media events. + for (var i = 0; i < mediaEventTypes.length; i++) { + listenToNonDelegatedEvent(mediaEventTypes[i], domElement); + } + + break; + + case 'source': + // We listen to this event in case to ensure emulated bubble + // listeners still fire for the error event. + listenToNonDelegatedEvent('error', domElement); + break; + + case 'img': + case 'image': + case 'link': + // We listen to these events in case to ensure emulated bubble + // listeners still fire for error and load events. + listenToNonDelegatedEvent('error', domElement); + listenToNonDelegatedEvent('load', domElement); + break; + + case 'details': + // We listen to this event in case to ensure emulated bubble + // listeners still fire for the toggle event. + listenToNonDelegatedEvent('toggle', domElement); + break; + + case 'input': + initWrapperState(domElement, rawProps); // We listen to this event in case to ensure emulated bubble + // listeners still fire for the invalid event. + + listenToNonDelegatedEvent('invalid', domElement); + + break; + + case 'option': + validateProps(domElement, rawProps); + break; + + case 'select': + initWrapperState$1(domElement, rawProps); // We listen to this event in case to ensure emulated bubble + // listeners still fire for the invalid event. + + listenToNonDelegatedEvent('invalid', domElement); + + break; + + case 'textarea': + initWrapperState$2(domElement, rawProps); // We listen to this event in case to ensure emulated bubble + // listeners still fire for the invalid event. + + listenToNonDelegatedEvent('invalid', domElement); + + break; + } + + assertValidProps(tag, rawProps); + + { + extraAttributeNames = new Set(); + var attributes = domElement.attributes; + + for (var _i = 0; _i < attributes.length; _i++) { + var name = attributes[_i].name.toLowerCase(); + + switch (name) { + // Built-in SSR attribute is allowed + case 'data-reactroot': + break; + // Controlled attributes are not validated + // TODO: Only ignore them on controlled tags. + + case 'value': + break; + + case 'checked': + break; + + case 'selected': + break; + + default: + // Intentionally use the original name. + // See discussion in https://github.com/facebook/react/pull/10676. + extraAttributeNames.add(attributes[_i].name); + } + } + } + + var updatePayload = null; + + for (var propKey in rawProps) { + if (!rawProps.hasOwnProperty(propKey)) { + continue; + } + + var nextProp = rawProps[propKey]; + + if (propKey === CHILDREN) { + // For text content children we compare against textContent. This + // might match additional HTML that is hidden when we read it using + // textContent. E.g. "foo" will match "f<span>oo</span>" but that still + // satisfies our requirement. Our requirement is not to produce perfect + // HTML and attributes. Ideally we should preserve structure but it's + // ok not to if the visible content is still enough to indicate what + // even listeners these nodes might be wired up to. + // TODO: Warn if there is more than a single textNode as a child. + // TODO: Should we use domElement.firstChild.nodeValue to compare? + if (typeof nextProp === 'string') { + if (domElement.textContent !== nextProp) { + if ( !suppressHydrationWarning) { + warnForTextDifference(domElement.textContent, nextProp); + } + + updatePayload = [CHILDREN, nextProp]; + } + } else if (typeof nextProp === 'number') { + if (domElement.textContent !== '' + nextProp) { + if ( !suppressHydrationWarning) { + warnForTextDifference(domElement.textContent, nextProp); + } + + updatePayload = [CHILDREN, '' + nextProp]; + } + } + } else if (registrationNameDependencies.hasOwnProperty(propKey)) { + if (nextProp != null) { + if ( typeof nextProp !== 'function') { + warnForInvalidEventListener(propKey, nextProp); + } + + if (propKey === 'onScroll') { + listenToNonDelegatedEvent('scroll', domElement); + } + } + } else if ( // Convince Flow we've calculated it (it's DEV-only in this method.) + typeof isCustomComponentTag === 'boolean') { + // Validate that the properties correspond to their expected values. + var serverValue = void 0; + var propertyInfo = getPropertyInfo(propKey); + + if (suppressHydrationWarning) ; else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING || // Controlled attributes are not validated + // TODO: Only ignore them on controlled tags. + propKey === 'value' || propKey === 'checked' || propKey === 'selected') ; else if (propKey === DANGEROUSLY_SET_INNER_HTML) { + var serverHTML = domElement.innerHTML; + var nextHtml = nextProp ? nextProp[HTML$1] : undefined; + + if (nextHtml != null) { + var expectedHTML = normalizeHTML(domElement, nextHtml); + + if (expectedHTML !== serverHTML) { + warnForPropDifference(propKey, serverHTML, expectedHTML); + } + } + } else if (propKey === STYLE) { + // $FlowFixMe - Should be inferred as not undefined. + extraAttributeNames.delete(propKey); + + if (canDiffStyleForHydrationWarning) { + var expectedStyle = createDangerousStringForStyles(nextProp); + serverValue = domElement.getAttribute('style'); + + if (expectedStyle !== serverValue) { + warnForPropDifference(propKey, serverValue, expectedStyle); + } + } + } else if (isCustomComponentTag) { + // $FlowFixMe - Should be inferred as not undefined. + extraAttributeNames.delete(propKey.toLowerCase()); + serverValue = getValueForAttribute(domElement, propKey, nextProp); + + if (nextProp !== serverValue) { + warnForPropDifference(propKey, serverValue, nextProp); + } + } else if (!shouldIgnoreAttribute(propKey, propertyInfo, isCustomComponentTag) && !shouldRemoveAttribute(propKey, nextProp, propertyInfo, isCustomComponentTag)) { + var isMismatchDueToBadCasing = false; + + if (propertyInfo !== null) { + // $FlowFixMe - Should be inferred as not undefined. + extraAttributeNames.delete(propertyInfo.attributeName); + serverValue = getValueForProperty(domElement, propKey, nextProp, propertyInfo); + } else { + var ownNamespace = parentNamespace; + + if (ownNamespace === HTML_NAMESPACE$1) { + ownNamespace = getIntrinsicNamespace(tag); + } + + if (ownNamespace === HTML_NAMESPACE$1) { + // $FlowFixMe - Should be inferred as not undefined. + extraAttributeNames.delete(propKey.toLowerCase()); + } else { + var standardName = getPossibleStandardName(propKey); + + if (standardName !== null && standardName !== propKey) { + // If an SVG prop is supplied with bad casing, it will + // be successfully parsed from HTML, but will produce a mismatch + // (and would be incorrectly rendered on the client). + // However, we already warn about bad casing elsewhere. + // So we'll skip the misleading extra mismatch warning in this case. + isMismatchDueToBadCasing = true; // $FlowFixMe - Should be inferred as not undefined. + + extraAttributeNames.delete(standardName); + } // $FlowFixMe - Should be inferred as not undefined. + + + extraAttributeNames.delete(propKey); + } + + serverValue = getValueForAttribute(domElement, propKey, nextProp); + } + + if (nextProp !== serverValue && !isMismatchDueToBadCasing) { + warnForPropDifference(propKey, serverValue, nextProp); + } + } + } + } + + { + // $FlowFixMe - Should be inferred as not undefined. + if (extraAttributeNames.size > 0 && !suppressHydrationWarning) { + // $FlowFixMe - Should be inferred as not undefined. + warnForExtraAttributes(extraAttributeNames); + } + } + + switch (tag) { + case 'input': + // TODO: Make sure we check if this is still unmounted or do any clean + // up necessary since we never stop tracking anymore. + track(domElement); + postMountWrapper(domElement, rawProps, true); + break; + + case 'textarea': + // TODO: Make sure we check if this is still unmounted or do any clean + // up necessary since we never stop tracking anymore. + track(domElement); + postMountWrapper$3(domElement); + break; + + case 'select': + case 'option': + // For input and textarea we current always set the value property at + // post mount to force it to diverge from attributes. However, for + // option and select we don't quite do the same thing and select + // is not resilient to the DOM state changing so we don't do that here. + // TODO: Consider not doing this for input and textarea. + break; + + default: + if (typeof rawProps.onClick === 'function') { + // TODO: This cast may not be sound for SVG, MathML or custom elements. + trapClickOnNonInteractiveElement(domElement); + } + + break; + } + + return updatePayload; + } + function diffHydratedText(textNode, text) { + var isDifferent = textNode.nodeValue !== text; + return isDifferent; + } + function warnForUnmatchedText(textNode, text) { + { + warnForTextDifference(textNode.nodeValue, text); + } + } + function warnForDeletedHydratableElement(parentNode, child) { + { + if (didWarnInvalidHydration) { + return; + } + + didWarnInvalidHydration = true; + + error('Did not expect server HTML to contain a <%s> in <%s>.', child.nodeName.toLowerCase(), parentNode.nodeName.toLowerCase()); + } + } + function warnForDeletedHydratableText(parentNode, child) { + { + if (didWarnInvalidHydration) { + return; + } + + didWarnInvalidHydration = true; + + error('Did not expect server HTML to contain the text node "%s" in <%s>.', child.nodeValue, parentNode.nodeName.toLowerCase()); + } + } + function warnForInsertedHydratedElement(parentNode, tag, props) { + { + if (didWarnInvalidHydration) { + return; + } + + didWarnInvalidHydration = true; + + error('Expected server HTML to contain a matching <%s> in <%s>.', tag, parentNode.nodeName.toLowerCase()); + } + } + function warnForInsertedHydratedText(parentNode, text) { + { + if (text === '') { + // We expect to insert empty text nodes since they're not represented in + // the HTML. + // TODO: Remove this special case if we can just avoid inserting empty + // text nodes. + return; + } + + if (didWarnInvalidHydration) { + return; + } + + didWarnInvalidHydration = true; + + error('Expected server HTML to contain a matching text node for "%s" in <%s>.', text, parentNode.nodeName.toLowerCase()); + } + } + function restoreControlledState$3(domElement, tag, props) { + switch (tag) { + case 'input': + restoreControlledState(domElement, props); + return; + + case 'textarea': + restoreControlledState$2(domElement, props); + return; + + case 'select': + restoreControlledState$1(domElement, props); + return; + } + } + + var validateDOMNesting = function () {}; + + var updatedAncestorInfo = function () {}; + + { + // This validation code was written based on the HTML5 parsing spec: + // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope + // + // Note: this does not catch all invalid nesting, nor does it try to (as it's + // not clear what practical benefit doing so provides); instead, we warn only + // for cases where the parser will give a parse tree differing from what React + // intended. For example, <b><div></div></b> is invalid but we don't warn + // because it still parses correctly; we do warn for other cases like nested + // <p> tags where the beginning of the second element implicitly closes the + // first, causing a confusing mess. + // https://html.spec.whatwg.org/multipage/syntax.html#special + var specialTags = ['address', 'applet', 'area', 'article', 'aside', 'base', 'basefont', 'bgsound', 'blockquote', 'body', 'br', 'button', 'caption', 'center', 'col', 'colgroup', 'dd', 'details', 'dir', 'div', 'dl', 'dt', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'iframe', 'img', 'input', 'isindex', 'li', 'link', 'listing', 'main', 'marquee', 'menu', 'menuitem', 'meta', 'nav', 'noembed', 'noframes', 'noscript', 'object', 'ol', 'p', 'param', 'plaintext', 'pre', 'script', 'section', 'select', 'source', 'style', 'summary', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'track', 'ul', 'wbr', 'xmp']; // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope + + var inScopeTags = ['applet', 'caption', 'html', 'table', 'td', 'th', 'marquee', 'object', 'template', // https://html.spec.whatwg.org/multipage/syntax.html#html-integration-point + // TODO: Distinguish by namespace here -- for <title>, including it here + // errs on the side of fewer warnings + 'foreignObject', 'desc', 'title']; // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-button-scope + + var buttonScopeTags = inScopeTags.concat(['button']); // https://html.spec.whatwg.org/multipage/syntax.html#generate-implied-end-tags + + var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt']; + var emptyAncestorInfo = { + current: null, + formTag: null, + aTagInScope: null, + buttonTagInScope: null, + nobrTagInScope: null, + pTagInButtonScope: null, + listItemTagAutoclosing: null, + dlItemTagAutoclosing: null + }; + + updatedAncestorInfo = function (oldInfo, tag) { + var ancestorInfo = _assign({}, oldInfo || emptyAncestorInfo); + + var info = { + tag: tag + }; + + if (inScopeTags.indexOf(tag) !== -1) { + ancestorInfo.aTagInScope = null; + ancestorInfo.buttonTagInScope = null; + ancestorInfo.nobrTagInScope = null; + } + + if (buttonScopeTags.indexOf(tag) !== -1) { + ancestorInfo.pTagInButtonScope = null; + } // See rules for 'li', 'dd', 'dt' start tags in + // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody + + + if (specialTags.indexOf(tag) !== -1 && tag !== 'address' && tag !== 'div' && tag !== 'p') { + ancestorInfo.listItemTagAutoclosing = null; + ancestorInfo.dlItemTagAutoclosing = null; + } + + ancestorInfo.current = info; + + if (tag === 'form') { + ancestorInfo.formTag = info; + } + + if (tag === 'a') { + ancestorInfo.aTagInScope = info; + } + + if (tag === 'button') { + ancestorInfo.buttonTagInScope = info; + } + + if (tag === 'nobr') { + ancestorInfo.nobrTagInScope = info; + } + + if (tag === 'p') { + ancestorInfo.pTagInButtonScope = info; + } + + if (tag === 'li') { + ancestorInfo.listItemTagAutoclosing = info; + } + + if (tag === 'dd' || tag === 'dt') { + ancestorInfo.dlItemTagAutoclosing = info; + } + + return ancestorInfo; + }; + /** + * Returns whether + */ + + + var isTagValidWithParent = function (tag, parentTag) { + // First, let's check if we're in an unusual parsing mode... + switch (parentTag) { + // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect + case 'select': + return tag === 'option' || tag === 'optgroup' || tag === '#text'; + + case 'optgroup': + return tag === 'option' || tag === '#text'; + // Strictly speaking, seeing an <option> doesn't mean we're in a <select> + // but + + case 'option': + return tag === '#text'; + // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd + // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption + // No special behavior since these rules fall back to "in body" mode for + // all except special table nodes which cause bad parsing behavior anyway. + // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr + + case 'tr': + return tag === 'th' || tag === 'td' || tag === 'style' || tag === 'script' || tag === 'template'; + // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody + + case 'tbody': + case 'thead': + case 'tfoot': + return tag === 'tr' || tag === 'style' || tag === 'script' || tag === 'template'; + // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup + + case 'colgroup': + return tag === 'col' || tag === 'template'; + // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable + + case 'table': + return tag === 'caption' || tag === 'colgroup' || tag === 'tbody' || tag === 'tfoot' || tag === 'thead' || tag === 'style' || tag === 'script' || tag === 'template'; + // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead + + case 'head': + return tag === 'base' || tag === 'basefont' || tag === 'bgsound' || tag === 'link' || tag === 'meta' || tag === 'title' || tag === 'noscript' || tag === 'noframes' || tag === 'style' || tag === 'script' || tag === 'template'; + // https://html.spec.whatwg.org/multipage/semantics.html#the-html-element + + case 'html': + return tag === 'head' || tag === 'body' || tag === 'frameset'; + + case 'frameset': + return tag === 'frame'; + + case '#document': + return tag === 'html'; + } // Probably in the "in body" parsing mode, so we outlaw only tag combos + // where the parsing rules cause implicit opens or closes to be added. + // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody + + + switch (tag) { + case 'h1': + case 'h2': + case 'h3': + case 'h4': + case 'h5': + case 'h6': + return parentTag !== 'h1' && parentTag !== 'h2' && parentTag !== 'h3' && parentTag !== 'h4' && parentTag !== 'h5' && parentTag !== 'h6'; + + case 'rp': + case 'rt': + return impliedEndTags.indexOf(parentTag) === -1; + + case 'body': + case 'caption': + case 'col': + case 'colgroup': + case 'frameset': + case 'frame': + case 'head': + case 'html': + case 'tbody': + case 'td': + case 'tfoot': + case 'th': + case 'thead': + case 'tr': + // These tags are only valid with a few parents that have special child + // parsing rules -- if we're down here, then none of those matched and + // so we allow it only if we don't know what the parent is, as all other + // cases are invalid. + return parentTag == null; + } + + return true; + }; + /** + * Returns whether + */ + + + var findInvalidAncestorForTag = function (tag, ancestorInfo) { + switch (tag) { + case 'address': + case 'article': + case 'aside': + case 'blockquote': + case 'center': + case 'details': + case 'dialog': + case 'dir': + case 'div': + case 'dl': + case 'fieldset': + case 'figcaption': + case 'figure': + case 'footer': + case 'header': + case 'hgroup': + case 'main': + case 'menu': + case 'nav': + case 'ol': + case 'p': + case 'section': + case 'summary': + case 'ul': + case 'pre': + case 'listing': + case 'table': + case 'hr': + case 'xmp': + case 'h1': + case 'h2': + case 'h3': + case 'h4': + case 'h5': + case 'h6': + return ancestorInfo.pTagInButtonScope; + + case 'form': + return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope; + + case 'li': + return ancestorInfo.listItemTagAutoclosing; + + case 'dd': + case 'dt': + return ancestorInfo.dlItemTagAutoclosing; + + case 'button': + return ancestorInfo.buttonTagInScope; + + case 'a': + // Spec says something about storing a list of markers, but it sounds + // equivalent to this check. + return ancestorInfo.aTagInScope; + + case 'nobr': + return ancestorInfo.nobrTagInScope; + } + + return null; + }; + + var didWarn$1 = {}; + + validateDOMNesting = function (childTag, childText, ancestorInfo) { + ancestorInfo = ancestorInfo || emptyAncestorInfo; + var parentInfo = ancestorInfo.current; + var parentTag = parentInfo && parentInfo.tag; + + if (childText != null) { + if (childTag != null) { + error('validateDOMNesting: when childText is passed, childTag should be null'); + } + + childTag = '#text'; + } + + var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo; + var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo); + var invalidParentOrAncestor = invalidParent || invalidAncestor; + + if (!invalidParentOrAncestor) { + return; + } + + var ancestorTag = invalidParentOrAncestor.tag; + var warnKey = !!invalidParent + '|' + childTag + '|' + ancestorTag; + + if (didWarn$1[warnKey]) { + return; + } + + didWarn$1[warnKey] = true; + var tagDisplayName = childTag; + var whitespaceInfo = ''; + + if (childTag === '#text') { + if (/\S/.test(childText)) { + tagDisplayName = 'Text nodes'; + } else { + tagDisplayName = 'Whitespace text nodes'; + whitespaceInfo = " Make sure you don't have any extra whitespace between tags on " + 'each line of your source code.'; + } + } else { + tagDisplayName = '<' + childTag + '>'; + } + + if (invalidParent) { + var info = ''; + + if (ancestorTag === 'table' && childTag === 'tr') { + info += ' Add a <tbody>, <thead> or <tfoot> to your code to match the DOM tree generated by ' + 'the browser.'; + } + + error('validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s', tagDisplayName, ancestorTag, whitespaceInfo, info); + } else { + error('validateDOMNesting(...): %s cannot appear as a descendant of ' + '<%s>.', tagDisplayName, ancestorTag); + } + }; + } + + var SUPPRESS_HYDRATION_WARNING$1; + + { + SUPPRESS_HYDRATION_WARNING$1 = 'suppressHydrationWarning'; + } + + var SUSPENSE_START_DATA = '$'; + var SUSPENSE_END_DATA = '/$'; + var SUSPENSE_PENDING_START_DATA = '$?'; + var SUSPENSE_FALLBACK_START_DATA = '$!'; + var STYLE$1 = 'style'; + var eventsEnabled = null; + var selectionInformation = null; + + function shouldAutoFocusHostComponent(type, props) { + switch (type) { + case 'button': + case 'input': + case 'select': + case 'textarea': + return !!props.autoFocus; + } + + return false; + } + function getRootHostContext(rootContainerInstance) { + var type; + var namespace; + var nodeType = rootContainerInstance.nodeType; + + switch (nodeType) { + case DOCUMENT_NODE: + case DOCUMENT_FRAGMENT_NODE: + { + type = nodeType === DOCUMENT_NODE ? '#document' : '#fragment'; + var root = rootContainerInstance.documentElement; + namespace = root ? root.namespaceURI : getChildNamespace(null, ''); + break; + } + + default: + { + var container = nodeType === COMMENT_NODE ? rootContainerInstance.parentNode : rootContainerInstance; + var ownNamespace = container.namespaceURI || null; + type = container.tagName; + namespace = getChildNamespace(ownNamespace, type); + break; + } + } + + { + var validatedTag = type.toLowerCase(); + var ancestorInfo = updatedAncestorInfo(null, validatedTag); + return { + namespace: namespace, + ancestorInfo: ancestorInfo + }; + } + } + function getChildHostContext(parentHostContext, type, rootContainerInstance) { + { + var parentHostContextDev = parentHostContext; + var namespace = getChildNamespace(parentHostContextDev.namespace, type); + var ancestorInfo = updatedAncestorInfo(parentHostContextDev.ancestorInfo, type); + return { + namespace: namespace, + ancestorInfo: ancestorInfo + }; + } + } + function getPublicInstance(instance) { + return instance; + } + function prepareForCommit(containerInfo) { + eventsEnabled = isEnabled(); + selectionInformation = getSelectionInformation(); + var activeInstance = null; + + setEnabled(false); + return activeInstance; + } + function resetAfterCommit(containerInfo) { + restoreSelection(selectionInformation); + setEnabled(eventsEnabled); + eventsEnabled = null; + selectionInformation = null; + } + function createInstance(type, props, rootContainerInstance, hostContext, internalInstanceHandle) { + var parentNamespace; + + { + // TODO: take namespace into account when validating. + var hostContextDev = hostContext; + validateDOMNesting(type, null, hostContextDev.ancestorInfo); + + if (typeof props.children === 'string' || typeof props.children === 'number') { + var string = '' + props.children; + var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type); + validateDOMNesting(null, string, ownAncestorInfo); + } + + parentNamespace = hostContextDev.namespace; + } + + var domElement = createElement(type, props, rootContainerInstance, parentNamespace); + precacheFiberNode(internalInstanceHandle, domElement); + updateFiberProps(domElement, props); + return domElement; + } + function appendInitialChild(parentInstance, child) { + parentInstance.appendChild(child); + } + function finalizeInitialChildren(domElement, type, props, rootContainerInstance, hostContext) { + setInitialProperties(domElement, type, props, rootContainerInstance); + return shouldAutoFocusHostComponent(type, props); + } + function prepareUpdate(domElement, type, oldProps, newProps, rootContainerInstance, hostContext) { + { + var hostContextDev = hostContext; + + if (typeof newProps.children !== typeof oldProps.children && (typeof newProps.children === 'string' || typeof newProps.children === 'number')) { + var string = '' + newProps.children; + var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type); + validateDOMNesting(null, string, ownAncestorInfo); + } + } + + return diffProperties(domElement, type, oldProps, newProps); + } + function shouldSetTextContent(type, props) { + return type === 'textarea' || type === 'option' || type === 'noscript' || typeof props.children === 'string' || typeof props.children === 'number' || typeof props.dangerouslySetInnerHTML === 'object' && props.dangerouslySetInnerHTML !== null && props.dangerouslySetInnerHTML.__html != null; + } + function createTextInstance(text, rootContainerInstance, hostContext, internalInstanceHandle) { + { + var hostContextDev = hostContext; + validateDOMNesting(null, text, hostContextDev.ancestorInfo); + } + + var textNode = createTextNode(text, rootContainerInstance); + precacheFiberNode(internalInstanceHandle, textNode); + return textNode; + } + // if a component just imports ReactDOM (e.g. for findDOMNode). + // Some environments might not have setTimeout or clearTimeout. + + var scheduleTimeout = typeof setTimeout === 'function' ? setTimeout : undefined; + var cancelTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined; + var noTimeout = -1; // ------------------- + function commitMount(domElement, type, newProps, internalInstanceHandle) { + // Despite the naming that might imply otherwise, this method only + // fires if there is an `Update` effect scheduled during mounting. + // This happens if `finalizeInitialChildren` returns `true` (which it + // does to implement the `autoFocus` attribute on the client). But + // there are also other cases when this might happen (such as patching + // up text content during hydration mismatch). So we'll check this again. + if (shouldAutoFocusHostComponent(type, newProps)) { + domElement.focus(); + } + } + function commitUpdate(domElement, updatePayload, type, oldProps, newProps, internalInstanceHandle) { + // Update the props handle so that we know which props are the ones with + // with current event handlers. + updateFiberProps(domElement, newProps); // Apply the diff to the DOM node. + + updateProperties(domElement, updatePayload, type, oldProps, newProps); + } + function resetTextContent(domElement) { + setTextContent(domElement, ''); + } + function commitTextUpdate(textInstance, oldText, newText) { + textInstance.nodeValue = newText; + } + function appendChild(parentInstance, child) { + parentInstance.appendChild(child); + } + function appendChildToContainer(container, child) { + var parentNode; + + if (container.nodeType === COMMENT_NODE) { + parentNode = container.parentNode; + parentNode.insertBefore(child, container); + } else { + parentNode = container; + parentNode.appendChild(child); + } // This container might be used for a portal. + // If something inside a portal is clicked, that click should bubble + // through the React tree. However, on Mobile Safari the click would + // never bubble through the *DOM* tree unless an ancestor with onclick + // event exists. So we wouldn't see it and dispatch it. + // This is why we ensure that non React root containers have inline onclick + // defined. + // https://github.com/facebook/react/issues/11918 + + + var reactRootContainer = container._reactRootContainer; + + if ((reactRootContainer === null || reactRootContainer === undefined) && parentNode.onclick === null) { + // TODO: This cast may not be sound for SVG, MathML or custom elements. + trapClickOnNonInteractiveElement(parentNode); + } + } + function insertBefore(parentInstance, child, beforeChild) { + parentInstance.insertBefore(child, beforeChild); + } + function insertInContainerBefore(container, child, beforeChild) { + if (container.nodeType === COMMENT_NODE) { + container.parentNode.insertBefore(child, beforeChild); + } else { + container.insertBefore(child, beforeChild); + } + } + + function removeChild(parentInstance, child) { + parentInstance.removeChild(child); + } + function removeChildFromContainer(container, child) { + if (container.nodeType === COMMENT_NODE) { + container.parentNode.removeChild(child); + } else { + container.removeChild(child); + } + } + function hideInstance(instance) { + // TODO: Does this work for all element types? What about MathML? Should we + // pass host context to this method? + instance = instance; + var style = instance.style; + + if (typeof style.setProperty === 'function') { + style.setProperty('display', 'none', 'important'); + } else { + style.display = 'none'; + } + } + function hideTextInstance(textInstance) { + textInstance.nodeValue = ''; + } + function unhideInstance(instance, props) { + instance = instance; + var styleProp = props[STYLE$1]; + var display = styleProp !== undefined && styleProp !== null && styleProp.hasOwnProperty('display') ? styleProp.display : null; + instance.style.display = dangerousStyleValue('display', display); + } + function unhideTextInstance(textInstance, text) { + textInstance.nodeValue = text; + } + function clearContainer(container) { + if (container.nodeType === ELEMENT_NODE) { + container.textContent = ''; + } else if (container.nodeType === DOCUMENT_NODE) { + var body = container.body; + + if (body != null) { + body.textContent = ''; + } + } + } // ------------------- + function canHydrateInstance(instance, type, props) { + if (instance.nodeType !== ELEMENT_NODE || type.toLowerCase() !== instance.nodeName.toLowerCase()) { + return null; + } // This has now been refined to an element node. + + + return instance; + } + function canHydrateTextInstance(instance, text) { + if (text === '' || instance.nodeType !== TEXT_NODE) { + // Empty strings are not parsed by HTML so there won't be a correct match here. + return null; + } // This has now been refined to a text node. + + + return instance; + } + function isSuspenseInstancePending(instance) { + return instance.data === SUSPENSE_PENDING_START_DATA; + } + function isSuspenseInstanceFallback(instance) { + return instance.data === SUSPENSE_FALLBACK_START_DATA; + } + + function getNextHydratable(node) { + // Skip non-hydratable nodes. + for (; node != null; node = node.nextSibling) { + var nodeType = node.nodeType; + + if (nodeType === ELEMENT_NODE || nodeType === TEXT_NODE) { + break; + } + } + + return node; + } + + function getNextHydratableSibling(instance) { + return getNextHydratable(instance.nextSibling); + } + function getFirstHydratableChild(parentInstance) { + return getNextHydratable(parentInstance.firstChild); + } + function hydrateInstance(instance, type, props, rootContainerInstance, hostContext, internalInstanceHandle) { + precacheFiberNode(internalInstanceHandle, instance); // TODO: Possibly defer this until the commit phase where all the events + // get attached. + + updateFiberProps(instance, props); + var parentNamespace; + + { + var hostContextDev = hostContext; + parentNamespace = hostContextDev.namespace; + } + + return diffHydratedProperties(instance, type, props, parentNamespace); + } + function hydrateTextInstance(textInstance, text, internalInstanceHandle) { + precacheFiberNode(internalInstanceHandle, textInstance); + return diffHydratedText(textInstance, text); + } + function getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance) { + var node = suspenseInstance.nextSibling; // Skip past all nodes within this suspense boundary. + // There might be nested nodes so we need to keep track of how + // deep we are and only break out when we're back on top. + + var depth = 0; + + while (node) { + if (node.nodeType === COMMENT_NODE) { + var data = node.data; + + if (data === SUSPENSE_END_DATA) { + if (depth === 0) { + return getNextHydratableSibling(node); + } else { + depth--; + } + } else if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) { + depth++; + } + } + + node = node.nextSibling; + } // TODO: Warn, we didn't find the end comment boundary. + + + return null; + } // Returns the SuspenseInstance if this node is a direct child of a + // SuspenseInstance. I.e. if its previous sibling is a Comment with + // SUSPENSE_x_START_DATA. Otherwise, null. + + function getParentSuspenseInstance(targetInstance) { + var node = targetInstance.previousSibling; // Skip past all nodes within this suspense boundary. + // There might be nested nodes so we need to keep track of how + // deep we are and only break out when we're back on top. + + var depth = 0; + + while (node) { + if (node.nodeType === COMMENT_NODE) { + var data = node.data; + + if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) { + if (depth === 0) { + return node; + } else { + depth--; + } + } else if (data === SUSPENSE_END_DATA) { + depth++; + } + } + + node = node.previousSibling; + } + + return null; + } + function commitHydratedContainer(container) { + // Retry if any event replaying was blocked on this. + retryIfBlockedOn(container); + } + function commitHydratedSuspenseInstance(suspenseInstance) { + // Retry if any event replaying was blocked on this. + retryIfBlockedOn(suspenseInstance); + } + function didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, text) { + { + warnForUnmatchedText(textInstance, text); + } + } + function didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, text) { + if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { + warnForUnmatchedText(textInstance, text); + } + } + function didNotHydrateContainerInstance(parentContainer, instance) { + { + if (instance.nodeType === ELEMENT_NODE) { + warnForDeletedHydratableElement(parentContainer, instance); + } else if (instance.nodeType === COMMENT_NODE) ; else { + warnForDeletedHydratableText(parentContainer, instance); + } + } + } + function didNotHydrateInstance(parentType, parentProps, parentInstance, instance) { + if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { + if (instance.nodeType === ELEMENT_NODE) { + warnForDeletedHydratableElement(parentInstance, instance); + } else if (instance.nodeType === COMMENT_NODE) ; else { + warnForDeletedHydratableText(parentInstance, instance); + } + } + } + function didNotFindHydratableContainerInstance(parentContainer, type, props) { + { + warnForInsertedHydratedElement(parentContainer, type); + } + } + function didNotFindHydratableContainerTextInstance(parentContainer, text) { + { + warnForInsertedHydratedText(parentContainer, text); + } + } + function didNotFindHydratableInstance(parentType, parentProps, parentInstance, type, props) { + if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { + warnForInsertedHydratedElement(parentInstance, type); + } + } + function didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, text) { + if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { + warnForInsertedHydratedText(parentInstance, text); + } + } + function didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance) { + if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) ; + } + var clientId = 0; + function makeClientIdInDEV(warnOnAccessInDEV) { + var id = 'r:' + (clientId++).toString(36); + return { + toString: function () { + warnOnAccessInDEV(); + return id; + }, + valueOf: function () { + warnOnAccessInDEV(); + return id; + } + }; + } + function isOpaqueHydratingObject(value) { + return value !== null && typeof value === 'object' && value.$$typeof === REACT_OPAQUE_ID_TYPE; + } + function makeOpaqueHydratingObject(attemptToReadValue) { + return { + $$typeof: REACT_OPAQUE_ID_TYPE, + toString: attemptToReadValue, + valueOf: attemptToReadValue + }; + } + function preparePortalMount(portalInstance) { + { + listenToAllSupportedEvents(portalInstance); + } + } + + var randomKey = Math.random().toString(36).slice(2); + var internalInstanceKey = '__reactFiber$' + randomKey; + var internalPropsKey = '__reactProps$' + randomKey; + var internalContainerInstanceKey = '__reactContainer$' + randomKey; + var internalEventHandlersKey = '__reactEvents$' + randomKey; + function precacheFiberNode(hostInst, node) { + node[internalInstanceKey] = hostInst; + } + function markContainerAsRoot(hostRoot, node) { + node[internalContainerInstanceKey] = hostRoot; + } + function unmarkContainerAsRoot(node) { + node[internalContainerInstanceKey] = null; + } + function isContainerMarkedAsRoot(node) { + return !!node[internalContainerInstanceKey]; + } // Given a DOM node, return the closest HostComponent or HostText fiber ancestor. + // If the target node is part of a hydrated or not yet rendered subtree, then + // this may also return a SuspenseComponent or HostRoot to indicate that. + // Conceptually the HostRoot fiber is a child of the Container node. So if you + // pass the Container node as the targetNode, you will not actually get the + // HostRoot back. To get to the HostRoot, you need to pass a child of it. + // The same thing applies to Suspense boundaries. + + function getClosestInstanceFromNode(targetNode) { + var targetInst = targetNode[internalInstanceKey]; + + if (targetInst) { + // Don't return HostRoot or SuspenseComponent here. + return targetInst; + } // If the direct event target isn't a React owned DOM node, we need to look + // to see if one of its parents is a React owned DOM node. + + + var parentNode = targetNode.parentNode; + + while (parentNode) { + // We'll check if this is a container root that could include + // React nodes in the future. We need to check this first because + // if we're a child of a dehydrated container, we need to first + // find that inner container before moving on to finding the parent + // instance. Note that we don't check this field on the targetNode + // itself because the fibers are conceptually between the container + // node and the first child. It isn't surrounding the container node. + // If it's not a container, we check if it's an instance. + targetInst = parentNode[internalContainerInstanceKey] || parentNode[internalInstanceKey]; + + if (targetInst) { + // Since this wasn't the direct target of the event, we might have + // stepped past dehydrated DOM nodes to get here. However they could + // also have been non-React nodes. We need to answer which one. + // If we the instance doesn't have any children, then there can't be + // a nested suspense boundary within it. So we can use this as a fast + // bailout. Most of the time, when people add non-React children to + // the tree, it is using a ref to a child-less DOM node. + // Normally we'd only need to check one of the fibers because if it + // has ever gone from having children to deleting them or vice versa + // it would have deleted the dehydrated boundary nested inside already. + // However, since the HostRoot starts out with an alternate it might + // have one on the alternate so we need to check in case this was a + // root. + var alternate = targetInst.alternate; + + if (targetInst.child !== null || alternate !== null && alternate.child !== null) { + // Next we need to figure out if the node that skipped past is + // nested within a dehydrated boundary and if so, which one. + var suspenseInstance = getParentSuspenseInstance(targetNode); + + while (suspenseInstance !== null) { + // We found a suspense instance. That means that we haven't + // hydrated it yet. Even though we leave the comments in the + // DOM after hydrating, and there are boundaries in the DOM + // that could already be hydrated, we wouldn't have found them + // through this pass since if the target is hydrated it would + // have had an internalInstanceKey on it. + // Let's get the fiber associated with the SuspenseComponent + // as the deepest instance. + var targetSuspenseInst = suspenseInstance[internalInstanceKey]; + + if (targetSuspenseInst) { + return targetSuspenseInst; + } // If we don't find a Fiber on the comment, it might be because + // we haven't gotten to hydrate it yet. There might still be a + // parent boundary that hasn't above this one so we need to find + // the outer most that is known. + + + suspenseInstance = getParentSuspenseInstance(suspenseInstance); // If we don't find one, then that should mean that the parent + // host component also hasn't hydrated yet. We can return it + // below since it will bail out on the isMounted check later. + } + } + + return targetInst; + } + + targetNode = parentNode; + parentNode = targetNode.parentNode; + } + + return null; + } + /** + * Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent + * instance, or null if the node was not rendered by this React. + */ + + function getInstanceFromNode(node) { + var inst = node[internalInstanceKey] || node[internalContainerInstanceKey]; + + if (inst) { + if (inst.tag === HostComponent || inst.tag === HostText || inst.tag === SuspenseComponent || inst.tag === HostRoot) { + return inst; + } else { + return null; + } + } + + return null; + } + /** + * Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding + * DOM node. + */ + + function getNodeFromInstance(inst) { + if (inst.tag === HostComponent || inst.tag === HostText) { + // In Fiber this, is just the state node right now. We assume it will be + // a host component or host text. + return inst.stateNode; + } // Without this first invariant, passing a non-DOM-component triggers the next + // invariant for a missing parent, which is super confusing. + + + { + { + throw Error( "getNodeFromInstance: Invalid argument." ); + } + } + } + function getFiberCurrentPropsFromNode(node) { + return node[internalPropsKey] || null; + } + function updateFiberProps(node, props) { + node[internalPropsKey] = props; + } + function getEventListenerSet(node) { + var elementListenerSet = node[internalEventHandlersKey]; + + if (elementListenerSet === undefined) { + elementListenerSet = node[internalEventHandlersKey] = new Set(); + } + + return elementListenerSet; + } + + var loggedTypeFailures = {}; + var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; + + function setCurrentlyValidatingElement(element) { + { + if (element) { + var owner = element._owner; + var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null); + ReactDebugCurrentFrame$1.setExtraStackFrame(stack); + } else { + ReactDebugCurrentFrame$1.setExtraStackFrame(null); + } + } + } + + function checkPropTypes(typeSpecs, values, location, componentName, element) { + { + // $FlowFixMe This is okay but Flow doesn't know it. + var has = Function.call.bind(Object.prototype.hasOwnProperty); + + for (var typeSpecName in typeSpecs) { + if (has(typeSpecs, typeSpecName)) { + var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to + // fail the render phase where it didn't fail before. So we log it. + // After these have been cleaned up, we'll let them throw. + + try { + // This is intentionally an invariant that gets caught. It's the same + // behavior as without this statement except with a better message. + if (typeof typeSpecs[typeSpecName] !== 'function') { + var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'); + err.name = 'Invariant Violation'; + throw err; + } + + error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'); + } catch (ex) { + error$1 = ex; + } + + if (error$1 && !(error$1 instanceof Error)) { + setCurrentlyValidatingElement(element); + + error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1); + + setCurrentlyValidatingElement(null); + } + + if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) { + // Only monitor this failure once because there tends to be a lot of the + // same error. + loggedTypeFailures[error$1.message] = true; + setCurrentlyValidatingElement(element); + + error('Failed %s type: %s', location, error$1.message); + + setCurrentlyValidatingElement(null); + } + } + } + } + } + + var valueStack = []; + var fiberStack; + + { + fiberStack = []; + } + + var index = -1; + + function createCursor(defaultValue) { + return { + current: defaultValue + }; + } + + function pop(cursor, fiber) { + if (index < 0) { + { + error('Unexpected pop.'); + } + + return; + } + + { + if (fiber !== fiberStack[index]) { + error('Unexpected Fiber popped.'); + } + } + + cursor.current = valueStack[index]; + valueStack[index] = null; + + { + fiberStack[index] = null; + } + + index--; + } + + function push(cursor, value, fiber) { + index++; + valueStack[index] = cursor.current; + + { + fiberStack[index] = fiber; + } + + cursor.current = value; + } + + var warnedAboutMissingGetChildContext; + + { + warnedAboutMissingGetChildContext = {}; + } + + var emptyContextObject = {}; + + { + Object.freeze(emptyContextObject); + } // A cursor to the current merged context object on the stack. + + + var contextStackCursor = createCursor(emptyContextObject); // A cursor to a boolean indicating whether the context has changed. + + var didPerformWorkStackCursor = createCursor(false); // Keep track of the previous context object that was on the stack. + // We use this to get access to the parent context after we have already + // pushed the next context provider, and now need to merge their contexts. + + var previousContext = emptyContextObject; + + function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) { + { + if (didPushOwnContextIfProvider && isContextProvider(Component)) { + // If the fiber is a context provider itself, when we read its context + // we may have already pushed its own child context on the stack. A context + // provider should not "see" its own child context. Therefore we read the + // previous (parent) context instead for a context provider. + return previousContext; + } + + return contextStackCursor.current; + } + } + + function cacheContext(workInProgress, unmaskedContext, maskedContext) { + { + var instance = workInProgress.stateNode; + instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext; + instance.__reactInternalMemoizedMaskedChildContext = maskedContext; + } + } + + function getMaskedContext(workInProgress, unmaskedContext) { + { + var type = workInProgress.type; + var contextTypes = type.contextTypes; + + if (!contextTypes) { + return emptyContextObject; + } // Avoid recreating masked context unless unmasked context has changed. + // Failing to do this will result in unnecessary calls to componentWillReceiveProps. + // This may trigger infinite loops if componentWillReceiveProps calls setState. + + + var instance = workInProgress.stateNode; + + if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { + return instance.__reactInternalMemoizedMaskedChildContext; + } + + var context = {}; + + for (var key in contextTypes) { + context[key] = unmaskedContext[key]; + } + + { + var name = getComponentName(type) || 'Unknown'; + checkPropTypes(contextTypes, context, 'context', name); + } // Cache unmasked context so we can avoid recreating masked context unless necessary. + // Context is created before the class component is instantiated so check for instance. + + + if (instance) { + cacheContext(workInProgress, unmaskedContext, context); + } + + return context; + } + } + + function hasContextChanged() { + { + return didPerformWorkStackCursor.current; + } + } + + function isContextProvider(type) { + { + var childContextTypes = type.childContextTypes; + return childContextTypes !== null && childContextTypes !== undefined; + } + } + + function popContext(fiber) { + { + pop(didPerformWorkStackCursor, fiber); + pop(contextStackCursor, fiber); + } + } + + function popTopLevelContextObject(fiber) { + { + pop(didPerformWorkStackCursor, fiber); + pop(contextStackCursor, fiber); + } + } + + function pushTopLevelContextObject(fiber, context, didChange) { + { + if (!(contextStackCursor.current === emptyContextObject)) { + { + throw Error( "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." ); + } + } + + push(contextStackCursor, context, fiber); + push(didPerformWorkStackCursor, didChange, fiber); + } + } + + function processChildContext(fiber, type, parentContext) { + { + var instance = fiber.stateNode; + var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future. + // It has only been added in Fiber to match the (unintentional) behavior in Stack. + + if (typeof instance.getChildContext !== 'function') { + { + var componentName = getComponentName(type) || 'Unknown'; + + if (!warnedAboutMissingGetChildContext[componentName]) { + warnedAboutMissingGetChildContext[componentName] = true; + + error('%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName); + } + } + + return parentContext; + } + + var childContext = instance.getChildContext(); + + for (var contextKey in childContext) { + if (!(contextKey in childContextTypes)) { + { + throw Error( (getComponentName(type) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes." ); + } + } + } + + { + var name = getComponentName(type) || 'Unknown'; + checkPropTypes(childContextTypes, childContext, 'child context', name); + } + + return _assign({}, parentContext, childContext); + } + } + + function pushContextProvider(workInProgress) { + { + var instance = workInProgress.stateNode; // We push the context as early as possible to ensure stack integrity. + // If the instance does not exist yet, we will push null at first, + // and replace it on the stack later when invalidating the context. + + var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject; // Remember the parent context so we can merge with it later. + // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates. + + previousContext = contextStackCursor.current; + push(contextStackCursor, memoizedMergedChildContext, workInProgress); + push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress); + return true; + } + } + + function invalidateContextProvider(workInProgress, type, didChange) { + { + var instance = workInProgress.stateNode; + + if (!instance) { + { + throw Error( "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." ); + } + } + + if (didChange) { + // Merge parent and own context. + // Skip this if we're not updating due to sCU. + // This avoids unnecessarily recomputing memoized values. + var mergedContext = processChildContext(workInProgress, type, previousContext); + instance.__reactInternalMemoizedMergedChildContext = mergedContext; // Replace the old (or empty) context with the new one. + // It is important to unwind the context in the reverse order. + + pop(didPerformWorkStackCursor, workInProgress); + pop(contextStackCursor, workInProgress); // Now push the new context and mark that it has changed. + + push(contextStackCursor, mergedContext, workInProgress); + push(didPerformWorkStackCursor, didChange, workInProgress); + } else { + pop(didPerformWorkStackCursor, workInProgress); + push(didPerformWorkStackCursor, didChange, workInProgress); + } + } + } + + function findCurrentUnmaskedContext(fiber) { + { + // Currently this is only used with renderSubtreeIntoContainer; not sure if it + // makes sense elsewhere + if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) { + { + throw Error( "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." ); + } + } + + var node = fiber; + + do { + switch (node.tag) { + case HostRoot: + return node.stateNode.context; + + case ClassComponent: + { + var Component = node.type; + + if (isContextProvider(Component)) { + return node.stateNode.__reactInternalMemoizedMergedChildContext; + } + + break; + } + } + + node = node.return; + } while (node !== null); + + { + { + throw Error( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); + } + } + } + } + + var LegacyRoot = 0; + var BlockingRoot = 1; + var ConcurrentRoot = 2; + + var rendererID = null; + var injectedHook = null; + var hasLoggedError = false; + var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined'; + function injectInternals(internals) { + if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') { + // No DevTools + return false; + } + + var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; + + if (hook.isDisabled) { + // This isn't a real property on the hook, but it can be set to opt out + // of DevTools integration and associated warnings and logs. + // https://github.com/facebook/react/issues/3877 + return true; + } + + if (!hook.supportsFiber) { + { + error('The installed version of React DevTools is too old and will not work ' + 'with the current version of React. Please update React DevTools. ' + 'https://reactjs.org/link/react-devtools'); + } // DevTools exists, even though it doesn't support Fiber. + + + return true; + } + + try { + rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks. + + injectedHook = hook; + } catch (err) { + // Catch all errors because it is unsafe to throw during initialization. + { + error('React instrumentation encountered an error: %s.', err); + } + } // DevTools exists + + + return true; + } + function onScheduleRoot(root, children) { + { + if (injectedHook && typeof injectedHook.onScheduleFiberRoot === 'function') { + try { + injectedHook.onScheduleFiberRoot(rendererID, root, children); + } catch (err) { + if ( !hasLoggedError) { + hasLoggedError = true; + + error('React instrumentation encountered an error: %s', err); + } + } + } + } + } + function onCommitRoot(root, priorityLevel) { + if (injectedHook && typeof injectedHook.onCommitFiberRoot === 'function') { + try { + var didError = (root.current.flags & DidCapture) === DidCapture; + + if (enableProfilerTimer) { + injectedHook.onCommitFiberRoot(rendererID, root, priorityLevel, didError); + } else { + injectedHook.onCommitFiberRoot(rendererID, root, undefined, didError); + } + } catch (err) { + { + if (!hasLoggedError) { + hasLoggedError = true; + + error('React instrumentation encountered an error: %s', err); + } + } + } + } + } + function onCommitUnmount(fiber) { + if (injectedHook && typeof injectedHook.onCommitFiberUnmount === 'function') { + try { + injectedHook.onCommitFiberUnmount(rendererID, fiber); + } catch (err) { + { + if (!hasLoggedError) { + hasLoggedError = true; + + error('React instrumentation encountered an error: %s', err); + } + } + } + } + } + + var Scheduler_runWithPriority = unstable_runWithPriority, + Scheduler_scheduleCallback = unstable_scheduleCallback, + Scheduler_cancelCallback = unstable_cancelCallback, + Scheduler_shouldYield = unstable_shouldYield, + Scheduler_requestPaint = unstable_requestPaint, + Scheduler_now$1 = unstable_now, + Scheduler_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel, + Scheduler_ImmediatePriority = unstable_ImmediatePriority, + Scheduler_UserBlockingPriority = unstable_UserBlockingPriority, + Scheduler_NormalPriority = unstable_NormalPriority, + Scheduler_LowPriority = unstable_LowPriority, + Scheduler_IdlePriority = unstable_IdlePriority; + + { + // Provide explicit error message when production+profiling bundle of e.g. + // react-dom is used with production (non-profiling) bundle of + // scheduler/tracing + if (!(__interactionsRef != null && __interactionsRef.current != null)) { + { + throw Error( "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at https://reactjs.org/link/profiling" ); + } + } + } + + var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Scheduler priorities. We use + // ascending numbers so we can compare them like numbers. They start at 90 to + // avoid clashing with Scheduler's priorities. + + var ImmediatePriority$1 = 99; + var UserBlockingPriority$2 = 98; + var NormalPriority$1 = 97; + var LowPriority$1 = 96; + var IdlePriority$1 = 95; // NoPriority is the absence of priority. Also React-only. + + var NoPriority$1 = 90; + var shouldYield = Scheduler_shouldYield; + var requestPaint = // Fall back gracefully if we're running an older version of Scheduler. + Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function () {}; + var syncQueue = null; + var immediateQueueCallbackNode = null; + var isFlushingSyncQueue = false; + var initialTimeMs$1 = Scheduler_now$1(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. + // This will be the case for modern browsers that support `performance.now`. In + // older browsers, Scheduler falls back to `Date.now`, which returns a Unix + // timestamp. In that case, subtract the module initialization time to simulate + // the behavior of performance.now and keep our times small enough to fit + // within 32 bits. + // TODO: Consider lifting this into Scheduler. + + var now = initialTimeMs$1 < 10000 ? Scheduler_now$1 : function () { + return Scheduler_now$1() - initialTimeMs$1; + }; + function getCurrentPriorityLevel() { + switch (Scheduler_getCurrentPriorityLevel()) { + case Scheduler_ImmediatePriority: + return ImmediatePriority$1; + + case Scheduler_UserBlockingPriority: + return UserBlockingPriority$2; + + case Scheduler_NormalPriority: + return NormalPriority$1; + + case Scheduler_LowPriority: + return LowPriority$1; + + case Scheduler_IdlePriority: + return IdlePriority$1; + + default: + { + { + throw Error( "Unknown priority level." ); + } + } + + } + } + + function reactPriorityToSchedulerPriority(reactPriorityLevel) { + switch (reactPriorityLevel) { + case ImmediatePriority$1: + return Scheduler_ImmediatePriority; + + case UserBlockingPriority$2: + return Scheduler_UserBlockingPriority; + + case NormalPriority$1: + return Scheduler_NormalPriority; + + case LowPriority$1: + return Scheduler_LowPriority; + + case IdlePriority$1: + return Scheduler_IdlePriority; + + default: + { + { + throw Error( "Unknown priority level." ); + } + } + + } + } + + function runWithPriority$1(reactPriorityLevel, fn) { + var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_runWithPriority(priorityLevel, fn); + } + function scheduleCallback(reactPriorityLevel, callback, options) { + var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_scheduleCallback(priorityLevel, callback, options); + } + function scheduleSyncCallback(callback) { + // Push this callback into an internal queue. We'll flush these either in + // the next tick, or earlier if something calls `flushSyncCallbackQueue`. + if (syncQueue === null) { + syncQueue = [callback]; // Flush the queue in the next tick, at the earliest. + + immediateQueueCallbackNode = Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueueImpl); + } else { + // Push onto existing queue. Don't need to schedule a callback because + // we already scheduled one when we created the queue. + syncQueue.push(callback); + } + + return fakeCallbackNode; + } + function cancelCallback(callbackNode) { + if (callbackNode !== fakeCallbackNode) { + Scheduler_cancelCallback(callbackNode); + } + } + function flushSyncCallbackQueue() { + if (immediateQueueCallbackNode !== null) { + var node = immediateQueueCallbackNode; + immediateQueueCallbackNode = null; + Scheduler_cancelCallback(node); + } + + flushSyncCallbackQueueImpl(); + } + + function flushSyncCallbackQueueImpl() { + if (!isFlushingSyncQueue && syncQueue !== null) { + // Prevent re-entrancy. + isFlushingSyncQueue = true; + var i = 0; + + { + try { + var _isSync2 = true; + var _queue = syncQueue; + runWithPriority$1(ImmediatePriority$1, function () { + for (; i < _queue.length; i++) { + var callback = _queue[i]; + + do { + callback = callback(_isSync2); + } while (callback !== null); + } + }); + syncQueue = null; + } catch (error) { + // If something throws, leave the remaining callbacks on the queue. + if (syncQueue !== null) { + syncQueue = syncQueue.slice(i + 1); + } // Resume flushing in the next tick + + + Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueue); + throw error; + } finally { + isFlushingSyncQueue = false; + } + } + } + } + + // TODO: this is special because it gets imported during build. + var ReactVersion = '17.0.2'; + + var NoMode = 0; + var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root + // tag instead + + var BlockingMode = 2; + var ConcurrentMode = 4; + var ProfileMode = 8; + var DebugTracingMode = 16; + + var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; + var NoTransition = 0; + function requestCurrentTransition() { + return ReactCurrentBatchConfig.transition; + } + + var ReactStrictModeWarnings = { + recordUnsafeLifecycleWarnings: function (fiber, instance) {}, + flushPendingUnsafeLifecycleWarnings: function () {}, + recordLegacyContextWarning: function (fiber, instance) {}, + flushLegacyContextWarning: function () {}, + discardPendingWarnings: function () {} + }; + + { + var findStrictRoot = function (fiber) { + var maybeStrictRoot = null; + var node = fiber; + + while (node !== null) { + if (node.mode & StrictMode) { + maybeStrictRoot = node; + } + + node = node.return; + } + + return maybeStrictRoot; + }; + + var setToSortedString = function (set) { + var array = []; + set.forEach(function (value) { + array.push(value); + }); + return array.sort().join(', '); + }; + + var pendingComponentWillMountWarnings = []; + var pendingUNSAFE_ComponentWillMountWarnings = []; + var pendingComponentWillReceivePropsWarnings = []; + var pendingUNSAFE_ComponentWillReceivePropsWarnings = []; + var pendingComponentWillUpdateWarnings = []; + var pendingUNSAFE_ComponentWillUpdateWarnings = []; // Tracks components we have already warned about. + + var didWarnAboutUnsafeLifecycles = new Set(); + + ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) { + // Dedup strategy: Warn once per component. + if (didWarnAboutUnsafeLifecycles.has(fiber.type)) { + return; + } + + if (typeof instance.componentWillMount === 'function' && // Don't warn about react-lifecycles-compat polyfilled components. + instance.componentWillMount.__suppressDeprecationWarning !== true) { + pendingComponentWillMountWarnings.push(fiber); + } + + if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillMount === 'function') { + pendingUNSAFE_ComponentWillMountWarnings.push(fiber); + } + + if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) { + pendingComponentWillReceivePropsWarnings.push(fiber); + } + + if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillReceiveProps === 'function') { + pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber); + } + + if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) { + pendingComponentWillUpdateWarnings.push(fiber); + } + + if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillUpdate === 'function') { + pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber); + } + }; + + ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () { + // We do an initial pass to gather component names + var componentWillMountUniqueNames = new Set(); + + if (pendingComponentWillMountWarnings.length > 0) { + pendingComponentWillMountWarnings.forEach(function (fiber) { + componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component'); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingComponentWillMountWarnings = []; + } + + var UNSAFE_componentWillMountUniqueNames = new Set(); + + if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) { + pendingUNSAFE_ComponentWillMountWarnings.forEach(function (fiber) { + UNSAFE_componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component'); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingUNSAFE_ComponentWillMountWarnings = []; + } + + var componentWillReceivePropsUniqueNames = new Set(); + + if (pendingComponentWillReceivePropsWarnings.length > 0) { + pendingComponentWillReceivePropsWarnings.forEach(function (fiber) { + componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component'); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingComponentWillReceivePropsWarnings = []; + } + + var UNSAFE_componentWillReceivePropsUniqueNames = new Set(); + + if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) { + pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function (fiber) { + UNSAFE_componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component'); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingUNSAFE_ComponentWillReceivePropsWarnings = []; + } + + var componentWillUpdateUniqueNames = new Set(); + + if (pendingComponentWillUpdateWarnings.length > 0) { + pendingComponentWillUpdateWarnings.forEach(function (fiber) { + componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component'); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingComponentWillUpdateWarnings = []; + } + + var UNSAFE_componentWillUpdateUniqueNames = new Set(); + + if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) { + pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function (fiber) { + UNSAFE_componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component'); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingUNSAFE_ComponentWillUpdateWarnings = []; + } // Finally, we flush all the warnings + // UNSAFE_ ones before the deprecated ones, since they'll be 'louder' + + + if (UNSAFE_componentWillMountUniqueNames.size > 0) { + var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames); + + error('Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '\nPlease update the following components: %s', sortedNames); + } + + if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) { + var _sortedNames = setToSortedString(UNSAFE_componentWillReceivePropsUniqueNames); + + error('Using UNSAFE_componentWillReceiveProps in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, " + 'refactor your code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state\n' + '\nPlease update the following components: %s', _sortedNames); + } + + if (UNSAFE_componentWillUpdateUniqueNames.size > 0) { + var _sortedNames2 = setToSortedString(UNSAFE_componentWillUpdateUniqueNames); + + error('Using UNSAFE_componentWillUpdate in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '\nPlease update the following components: %s', _sortedNames2); + } + + if (componentWillMountUniqueNames.size > 0) { + var _sortedNames3 = setToSortedString(componentWillMountUniqueNames); + + warn('componentWillMount has been renamed, and is not recommended for use. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '* Rename componentWillMount to UNSAFE_componentWillMount to suppress ' + 'this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames3); + } + + if (componentWillReceivePropsUniqueNames.size > 0) { + var _sortedNames4 = setToSortedString(componentWillReceivePropsUniqueNames); + + warn('componentWillReceiveProps has been renamed, and is not recommended for use. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, refactor your " + 'code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state\n' + '* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress ' + 'this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames4); + } + + if (componentWillUpdateUniqueNames.size > 0) { + var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames); + + warn('componentWillUpdate has been renamed, and is not recommended for use. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress ' + 'this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames5); + } + }; + + var pendingLegacyContextWarning = new Map(); // Tracks components we have already warned about. + + var didWarnAboutLegacyContext = new Set(); + + ReactStrictModeWarnings.recordLegacyContextWarning = function (fiber, instance) { + var strictRoot = findStrictRoot(fiber); + + if (strictRoot === null) { + error('Expected to find a StrictMode component in a strict mode tree. ' + 'This error is likely caused by a bug in React. Please file an issue.'); + + return; + } // Dedup strategy: Warn once per component. + + + if (didWarnAboutLegacyContext.has(fiber.type)) { + return; + } + + var warningsForRoot = pendingLegacyContextWarning.get(strictRoot); + + if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === 'function') { + if (warningsForRoot === undefined) { + warningsForRoot = []; + pendingLegacyContextWarning.set(strictRoot, warningsForRoot); + } + + warningsForRoot.push(fiber); + } + }; + + ReactStrictModeWarnings.flushLegacyContextWarning = function () { + pendingLegacyContextWarning.forEach(function (fiberArray, strictRoot) { + if (fiberArray.length === 0) { + return; + } + + var firstFiber = fiberArray[0]; + var uniqueNames = new Set(); + fiberArray.forEach(function (fiber) { + uniqueNames.add(getComponentName(fiber.type) || 'Component'); + didWarnAboutLegacyContext.add(fiber.type); + }); + var sortedNames = setToSortedString(uniqueNames); + + try { + setCurrentFiber(firstFiber); + + error('Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://reactjs.org/link/legacy-context', sortedNames); + } finally { + resetCurrentFiber(); + } + }); + }; + + ReactStrictModeWarnings.discardPendingWarnings = function () { + pendingComponentWillMountWarnings = []; + pendingUNSAFE_ComponentWillMountWarnings = []; + pendingComponentWillReceivePropsWarnings = []; + pendingUNSAFE_ComponentWillReceivePropsWarnings = []; + pendingComponentWillUpdateWarnings = []; + pendingUNSAFE_ComponentWillUpdateWarnings = []; + pendingLegacyContextWarning = new Map(); + }; + } + + function resolveDefaultProps(Component, baseProps) { + if (Component && Component.defaultProps) { + // Resolve default props. Taken from ReactElement + var props = _assign({}, baseProps); + + var defaultProps = Component.defaultProps; + + for (var propName in defaultProps) { + if (props[propName] === undefined) { + props[propName] = defaultProps[propName]; + } + } + + return props; + } + + return baseProps; + } + + // Max 31 bit integer. The max integer size in V8 for 32-bit systems. + // Math.pow(2, 30) - 1 + // 0b111111111111111111111111111111 + var MAX_SIGNED_31_BIT_INT = 1073741823; + + var valueCursor = createCursor(null); + var rendererSigil; + + { + // Use this to detect multiple renderers using the same context + rendererSigil = {}; + } + + var currentlyRenderingFiber = null; + var lastContextDependency = null; + var lastContextWithAllBitsObserved = null; + var isDisallowedContextReadInDEV = false; + function resetContextDependencies() { + // This is called right before React yields execution, to ensure `readContext` + // cannot be called outside the render phase. + currentlyRenderingFiber = null; + lastContextDependency = null; + lastContextWithAllBitsObserved = null; + + { + isDisallowedContextReadInDEV = false; + } + } + function enterDisallowedContextReadInDEV() { + { + isDisallowedContextReadInDEV = true; + } + } + function exitDisallowedContextReadInDEV() { + { + isDisallowedContextReadInDEV = false; + } + } + function pushProvider(providerFiber, nextValue) { + var context = providerFiber.type._context; + + { + push(valueCursor, context._currentValue, providerFiber); + context._currentValue = nextValue; + + { + if (context._currentRenderer !== undefined && context._currentRenderer !== null && context._currentRenderer !== rendererSigil) { + error('Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.'); + } + + context._currentRenderer = rendererSigil; + } + } + } + function popProvider(providerFiber) { + var currentValue = valueCursor.current; + pop(valueCursor, providerFiber); + var context = providerFiber.type._context; + + { + context._currentValue = currentValue; + } + } + function calculateChangedBits(context, newValue, oldValue) { + if (objectIs(oldValue, newValue)) { + // No change + return 0; + } else { + var changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT; + + { + if ((changedBits & MAX_SIGNED_31_BIT_INT) !== changedBits) { + error('calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits); + } + } + + return changedBits | 0; + } + } + function scheduleWorkOnParentPath(parent, renderLanes) { + // Update the child lanes of all the ancestors, including the alternates. + var node = parent; + + while (node !== null) { + var alternate = node.alternate; + + if (!isSubsetOfLanes(node.childLanes, renderLanes)) { + node.childLanes = mergeLanes(node.childLanes, renderLanes); + + if (alternate !== null) { + alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes); + } + } else if (alternate !== null && !isSubsetOfLanes(alternate.childLanes, renderLanes)) { + alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes); + } else { + // Neither alternate was updated, which means the rest of the + // ancestor path already has sufficient priority. + break; + } + + node = node.return; + } + } + function propagateContextChange(workInProgress, context, changedBits, renderLanes) { + var fiber = workInProgress.child; + + if (fiber !== null) { + // Set the return pointer of the child to the work-in-progress fiber. + fiber.return = workInProgress; + } + + while (fiber !== null) { + var nextFiber = void 0; // Visit this fiber. + + var list = fiber.dependencies; + + if (list !== null) { + nextFiber = fiber.child; + var dependency = list.firstContext; + + while (dependency !== null) { + // Check if the context matches. + if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) { + // Match! Schedule an update on this fiber. + if (fiber.tag === ClassComponent) { + // Schedule a force update on the work-in-progress. + var update = createUpdate(NoTimestamp, pickArbitraryLane(renderLanes)); + update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the + // update to the current fiber, too, which means it will persist even if + // this render is thrown away. Since it's a race condition, not sure it's + // worth fixing. + + enqueueUpdate(fiber, update); + } + + fiber.lanes = mergeLanes(fiber.lanes, renderLanes); + var alternate = fiber.alternate; + + if (alternate !== null) { + alternate.lanes = mergeLanes(alternate.lanes, renderLanes); + } + + scheduleWorkOnParentPath(fiber.return, renderLanes); // Mark the updated lanes on the list, too. + + list.lanes = mergeLanes(list.lanes, renderLanes); // Since we already found a match, we can stop traversing the + // dependency list. + + break; + } + + dependency = dependency.next; + } + } else if (fiber.tag === ContextProvider) { + // Don't scan deeper if this is a matching provider + nextFiber = fiber.type === workInProgress.type ? null : fiber.child; + } else { + // Traverse down. + nextFiber = fiber.child; + } + + if (nextFiber !== null) { + // Set the return pointer of the child to the work-in-progress fiber. + nextFiber.return = fiber; + } else { + // No child. Traverse to next sibling. + nextFiber = fiber; + + while (nextFiber !== null) { + if (nextFiber === workInProgress) { + // We're back to the root of this subtree. Exit. + nextFiber = null; + break; + } + + var sibling = nextFiber.sibling; + + if (sibling !== null) { + // Set the return pointer of the sibling to the work-in-progress fiber. + sibling.return = nextFiber.return; + nextFiber = sibling; + break; + } // No more siblings. Traverse up. + + + nextFiber = nextFiber.return; + } + } + + fiber = nextFiber; + } + } + function prepareToReadContext(workInProgress, renderLanes) { + currentlyRenderingFiber = workInProgress; + lastContextDependency = null; + lastContextWithAllBitsObserved = null; + var dependencies = workInProgress.dependencies; + + if (dependencies !== null) { + var firstContext = dependencies.firstContext; + + if (firstContext !== null) { + if (includesSomeLane(dependencies.lanes, renderLanes)) { + // Context list has a pending update. Mark that this fiber performed work. + markWorkInProgressReceivedUpdate(); + } // Reset the work-in-progress list + + + dependencies.firstContext = null; + } + } + } + function readContext(context, observedBits) { + { + // This warning would fire if you read context inside a Hook like useMemo. + // Unlike the class check below, it's not enforced in production for perf. + if (isDisallowedContextReadInDEV) { + error('Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().'); + } + } + + if (lastContextWithAllBitsObserved === context) ; else if (observedBits === false || observedBits === 0) ; else { + var resolvedObservedBits; // Avoid deopting on observable arguments or heterogeneous types. + + if (typeof observedBits !== 'number' || observedBits === MAX_SIGNED_31_BIT_INT) { + // Observe all updates. + lastContextWithAllBitsObserved = context; + resolvedObservedBits = MAX_SIGNED_31_BIT_INT; + } else { + resolvedObservedBits = observedBits; + } + + var contextItem = { + context: context, + observedBits: resolvedObservedBits, + next: null + }; + + if (lastContextDependency === null) { + if (!(currentlyRenderingFiber !== null)) { + { + throw Error( "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()." ); + } + } // This is the first dependency for this component. Create a new list. + + + lastContextDependency = contextItem; + currentlyRenderingFiber.dependencies = { + lanes: NoLanes, + firstContext: contextItem, + responders: null + }; + } else { + // Append a new context item. + lastContextDependency = lastContextDependency.next = contextItem; + } + } + + return context._currentValue ; + } + + var UpdateState = 0; + var ReplaceState = 1; + var ForceUpdate = 2; + var CaptureUpdate = 3; // Global state that is reset at the beginning of calling `processUpdateQueue`. + // It should only be read right after calling `processUpdateQueue`, via + // `checkHasForceUpdateAfterProcessing`. + + var hasForceUpdate = false; + var didWarnUpdateInsideUpdate; + var currentlyProcessingQueue; + + { + didWarnUpdateInsideUpdate = false; + currentlyProcessingQueue = null; + } + + function initializeUpdateQueue(fiber) { + var queue = { + baseState: fiber.memoizedState, + firstBaseUpdate: null, + lastBaseUpdate: null, + shared: { + pending: null + }, + effects: null + }; + fiber.updateQueue = queue; + } + function cloneUpdateQueue(current, workInProgress) { + // Clone the update queue from current. Unless it's already a clone. + var queue = workInProgress.updateQueue; + var currentQueue = current.updateQueue; + + if (queue === currentQueue) { + var clone = { + baseState: currentQueue.baseState, + firstBaseUpdate: currentQueue.firstBaseUpdate, + lastBaseUpdate: currentQueue.lastBaseUpdate, + shared: currentQueue.shared, + effects: currentQueue.effects + }; + workInProgress.updateQueue = clone; + } + } + function createUpdate(eventTime, lane) { + var update = { + eventTime: eventTime, + lane: lane, + tag: UpdateState, + payload: null, + callback: null, + next: null + }; + return update; + } + function enqueueUpdate(fiber, update) { + var updateQueue = fiber.updateQueue; + + if (updateQueue === null) { + // Only occurs if the fiber has been unmounted. + return; + } + + var sharedQueue = updateQueue.shared; + var pending = sharedQueue.pending; + + if (pending === null) { + // This is the first update. Create a circular list. + update.next = update; + } else { + update.next = pending.next; + pending.next = update; + } + + sharedQueue.pending = update; + + { + if (currentlyProcessingQueue === sharedQueue && !didWarnUpdateInsideUpdate) { + error('An update (setState, replaceState, or forceUpdate) was scheduled ' + 'from inside an update function. Update functions should be pure, ' + 'with zero side-effects. Consider using componentDidUpdate or a ' + 'callback.'); + + didWarnUpdateInsideUpdate = true; + } + } + } + function enqueueCapturedUpdate(workInProgress, capturedUpdate) { + // Captured updates are updates that are thrown by a child during the render + // phase. They should be discarded if the render is aborted. Therefore, + // we should only put them on the work-in-progress queue, not the current one. + var queue = workInProgress.updateQueue; // Check if the work-in-progress queue is a clone. + + var current = workInProgress.alternate; + + if (current !== null) { + var currentQueue = current.updateQueue; + + if (queue === currentQueue) { + // The work-in-progress queue is the same as current. This happens when + // we bail out on a parent fiber that then captures an error thrown by + // a child. Since we want to append the update only to the work-in + // -progress queue, we need to clone the updates. We usually clone during + // processUpdateQueue, but that didn't happen in this case because we + // skipped over the parent when we bailed out. + var newFirst = null; + var newLast = null; + var firstBaseUpdate = queue.firstBaseUpdate; + + if (firstBaseUpdate !== null) { + // Loop through the updates and clone them. + var update = firstBaseUpdate; + + do { + var clone = { + eventTime: update.eventTime, + lane: update.lane, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; + + if (newLast === null) { + newFirst = newLast = clone; + } else { + newLast.next = clone; + newLast = clone; + } + + update = update.next; + } while (update !== null); // Append the captured update the end of the cloned list. + + + if (newLast === null) { + newFirst = newLast = capturedUpdate; + } else { + newLast.next = capturedUpdate; + newLast = capturedUpdate; + } + } else { + // There are no base updates. + newFirst = newLast = capturedUpdate; + } + + queue = { + baseState: currentQueue.baseState, + firstBaseUpdate: newFirst, + lastBaseUpdate: newLast, + shared: currentQueue.shared, + effects: currentQueue.effects + }; + workInProgress.updateQueue = queue; + return; + } + } // Append the update to the end of the list. + + + var lastBaseUpdate = queue.lastBaseUpdate; + + if (lastBaseUpdate === null) { + queue.firstBaseUpdate = capturedUpdate; + } else { + lastBaseUpdate.next = capturedUpdate; + } + + queue.lastBaseUpdate = capturedUpdate; + } + + function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) { + switch (update.tag) { + case ReplaceState: + { + var payload = update.payload; + + if (typeof payload === 'function') { + // Updater function + { + enterDisallowedContextReadInDEV(); + } + + var nextState = payload.call(instance, prevState, nextProps); + + { + if ( workInProgress.mode & StrictMode) { + disableLogs(); + + try { + payload.call(instance, prevState, nextProps); + } finally { + reenableLogs(); + } + } + + exitDisallowedContextReadInDEV(); + } + + return nextState; + } // State object + + + return payload; + } + + case CaptureUpdate: + { + workInProgress.flags = workInProgress.flags & ~ShouldCapture | DidCapture; + } + // Intentional fallthrough + + case UpdateState: + { + var _payload = update.payload; + var partialState; + + if (typeof _payload === 'function') { + // Updater function + { + enterDisallowedContextReadInDEV(); + } + + partialState = _payload.call(instance, prevState, nextProps); + + { + if ( workInProgress.mode & StrictMode) { + disableLogs(); + + try { + _payload.call(instance, prevState, nextProps); + } finally { + reenableLogs(); + } + } + + exitDisallowedContextReadInDEV(); + } + } else { + // Partial state object + partialState = _payload; + } + + if (partialState === null || partialState === undefined) { + // Null and undefined are treated as no-ops. + return prevState; + } // Merge the partial state and the previous state. + + + return _assign({}, prevState, partialState); + } + + case ForceUpdate: + { + hasForceUpdate = true; + return prevState; + } + } + + return prevState; + } + + function processUpdateQueue(workInProgress, props, instance, renderLanes) { + // This is always non-null on a ClassComponent or HostRoot + var queue = workInProgress.updateQueue; + hasForceUpdate = false; + + { + currentlyProcessingQueue = queue.shared; + } + + var firstBaseUpdate = queue.firstBaseUpdate; + var lastBaseUpdate = queue.lastBaseUpdate; // Check if there are pending updates. If so, transfer them to the base queue. + + var pendingQueue = queue.shared.pending; + + if (pendingQueue !== null) { + queue.shared.pending = null; // The pending queue is circular. Disconnect the pointer between first + // and last so that it's non-circular. + + var lastPendingUpdate = pendingQueue; + var firstPendingUpdate = lastPendingUpdate.next; + lastPendingUpdate.next = null; // Append pending updates to base queue + + if (lastBaseUpdate === null) { + firstBaseUpdate = firstPendingUpdate; + } else { + lastBaseUpdate.next = firstPendingUpdate; + } + + lastBaseUpdate = lastPendingUpdate; // If there's a current queue, and it's different from the base queue, then + // we need to transfer the updates to that queue, too. Because the base + // queue is a singly-linked list with no cycles, we can append to both + // lists and take advantage of structural sharing. + // TODO: Pass `current` as argument + + var current = workInProgress.alternate; + + if (current !== null) { + // This is always non-null on a ClassComponent or HostRoot + var currentQueue = current.updateQueue; + var currentLastBaseUpdate = currentQueue.lastBaseUpdate; + + if (currentLastBaseUpdate !== lastBaseUpdate) { + if (currentLastBaseUpdate === null) { + currentQueue.firstBaseUpdate = firstPendingUpdate; + } else { + currentLastBaseUpdate.next = firstPendingUpdate; + } + + currentQueue.lastBaseUpdate = lastPendingUpdate; + } + } + } // These values may change as we process the queue. + + + if (firstBaseUpdate !== null) { + // Iterate through the list of updates to compute the result. + var newState = queue.baseState; // TODO: Don't need to accumulate this. Instead, we can remove renderLanes + // from the original lanes. + + var newLanes = NoLanes; + var newBaseState = null; + var newFirstBaseUpdate = null; + var newLastBaseUpdate = null; + var update = firstBaseUpdate; + + do { + var updateLane = update.lane; + var updateEventTime = update.eventTime; + + if (!isSubsetOfLanes(renderLanes, updateLane)) { + // Priority is insufficient. Skip this update. If this is the first + // skipped update, the previous update/state is the new base + // update/state. + var clone = { + eventTime: updateEventTime, + lane: updateLane, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; + + if (newLastBaseUpdate === null) { + newFirstBaseUpdate = newLastBaseUpdate = clone; + newBaseState = newState; + } else { + newLastBaseUpdate = newLastBaseUpdate.next = clone; + } // Update the remaining priority in the queue. + + + newLanes = mergeLanes(newLanes, updateLane); + } else { + // This update does have sufficient priority. + if (newLastBaseUpdate !== null) { + var _clone = { + eventTime: updateEventTime, + // This update is going to be committed so we never want uncommit + // it. Using NoLane works because 0 is a subset of all bitmasks, so + // this will never be skipped by the check above. + lane: NoLane, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; + newLastBaseUpdate = newLastBaseUpdate.next = _clone; + } // Process this update. + + + newState = getStateFromUpdate(workInProgress, queue, update, newState, props, instance); + var callback = update.callback; + + if (callback !== null) { + workInProgress.flags |= Callback; + var effects = queue.effects; + + if (effects === null) { + queue.effects = [update]; + } else { + effects.push(update); + } + } + } + + update = update.next; + + if (update === null) { + pendingQueue = queue.shared.pending; + + if (pendingQueue === null) { + break; + } else { + // An update was scheduled from inside a reducer. Add the new + // pending updates to the end of the list and keep processing. + var _lastPendingUpdate = pendingQueue; // Intentionally unsound. Pending updates form a circular list, but we + // unravel them when transferring them to the base queue. + + var _firstPendingUpdate = _lastPendingUpdate.next; + _lastPendingUpdate.next = null; + update = _firstPendingUpdate; + queue.lastBaseUpdate = _lastPendingUpdate; + queue.shared.pending = null; + } + } + } while (true); + + if (newLastBaseUpdate === null) { + newBaseState = newState; + } + + queue.baseState = newBaseState; + queue.firstBaseUpdate = newFirstBaseUpdate; + queue.lastBaseUpdate = newLastBaseUpdate; // Set the remaining expiration time to be whatever is remaining in the queue. + // This should be fine because the only two other things that contribute to + // expiration time are props and context. We're already in the middle of the + // begin phase by the time we start processing the queue, so we've already + // dealt with the props. Context in components that specify + // shouldComponentUpdate is tricky; but we'll have to account for + // that regardless. + + markSkippedUpdateLanes(newLanes); + workInProgress.lanes = newLanes; + workInProgress.memoizedState = newState; + } + + { + currentlyProcessingQueue = null; + } + } + + function callCallback(callback, context) { + if (!(typeof callback === 'function')) { + { + throw Error( "Invalid argument passed as callback. Expected a function. Instead received: " + callback ); + } + } + + callback.call(context); + } + + function resetHasForceUpdateBeforeProcessing() { + hasForceUpdate = false; + } + function checkHasForceUpdateAfterProcessing() { + return hasForceUpdate; + } + function commitUpdateQueue(finishedWork, finishedQueue, instance) { + // Commit the effects + var effects = finishedQueue.effects; + finishedQueue.effects = null; + + if (effects !== null) { + for (var i = 0; i < effects.length; i++) { + var effect = effects[i]; + var callback = effect.callback; + + if (callback !== null) { + effect.callback = null; + callCallback(callback, instance); + } + } + } + } + + var fakeInternalInstance = {}; + var isArray = Array.isArray; // React.Component uses a shared frozen object by default. + // We'll use it to determine whether we need to initialize legacy refs. + + var emptyRefsObject = new React.Component().refs; + var didWarnAboutStateAssignmentForComponent; + var didWarnAboutUninitializedState; + var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate; + var didWarnAboutLegacyLifecyclesAndDerivedState; + var didWarnAboutUndefinedDerivedState; + var warnOnUndefinedDerivedState; + var warnOnInvalidCallback; + var didWarnAboutDirectlyAssigningPropsToState; + var didWarnAboutContextTypeAndContextTypes; + var didWarnAboutInvalidateContextType; + + { + didWarnAboutStateAssignmentForComponent = new Set(); + didWarnAboutUninitializedState = new Set(); + didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set(); + didWarnAboutLegacyLifecyclesAndDerivedState = new Set(); + didWarnAboutDirectlyAssigningPropsToState = new Set(); + didWarnAboutUndefinedDerivedState = new Set(); + didWarnAboutContextTypeAndContextTypes = new Set(); + didWarnAboutInvalidateContextType = new Set(); + var didWarnOnInvalidCallback = new Set(); + + warnOnInvalidCallback = function (callback, callerName) { + if (callback === null || typeof callback === 'function') { + return; + } + + var key = callerName + '_' + callback; + + if (!didWarnOnInvalidCallback.has(key)) { + didWarnOnInvalidCallback.add(key); + + error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback); + } + }; + + warnOnUndefinedDerivedState = function (type, partialState) { + if (partialState === undefined) { + var componentName = getComponentName(type) || 'Component'; + + if (!didWarnAboutUndefinedDerivedState.has(componentName)) { + didWarnAboutUndefinedDerivedState.add(componentName); + + error('%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName); + } + } + }; // This is so gross but it's at least non-critical and can be removed if + // it causes problems. This is meant to give a nicer error message for + // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component, + // ...)) which otherwise throws a "_processChildContext is not a function" + // exception. + + + Object.defineProperty(fakeInternalInstance, '_processChildContext', { + enumerable: false, + value: function () { + { + { + throw Error( "_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn't supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal)." ); + } + } + } + }); + Object.freeze(fakeInternalInstance); + } + + function applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, nextProps) { + var prevState = workInProgress.memoizedState; + + { + if ( workInProgress.mode & StrictMode) { + disableLogs(); + + try { + // Invoke the function an extra time to help detect side-effects. + getDerivedStateFromProps(nextProps, prevState); + } finally { + reenableLogs(); + } + } + } + + var partialState = getDerivedStateFromProps(nextProps, prevState); + + { + warnOnUndefinedDerivedState(ctor, partialState); + } // Merge the partial state and the previous state. + + + var memoizedState = partialState === null || partialState === undefined ? prevState : _assign({}, prevState, partialState); + workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the + // base state. + + if (workInProgress.lanes === NoLanes) { + // Queue is always non-null for classes + var updateQueue = workInProgress.updateQueue; + updateQueue.baseState = memoizedState; + } + } + var classComponentUpdater = { + isMounted: isMounted, + enqueueSetState: function (inst, payload, callback) { + var fiber = get(inst); + var eventTime = requestEventTime(); + var lane = requestUpdateLane(fiber); + var update = createUpdate(eventTime, lane); + update.payload = payload; + + if (callback !== undefined && callback !== null) { + { + warnOnInvalidCallback(callback, 'setState'); + } + + update.callback = callback; + } + + enqueueUpdate(fiber, update); + scheduleUpdateOnFiber(fiber, lane, eventTime); + }, + enqueueReplaceState: function (inst, payload, callback) { + var fiber = get(inst); + var eventTime = requestEventTime(); + var lane = requestUpdateLane(fiber); + var update = createUpdate(eventTime, lane); + update.tag = ReplaceState; + update.payload = payload; + + if (callback !== undefined && callback !== null) { + { + warnOnInvalidCallback(callback, 'replaceState'); + } + + update.callback = callback; + } + + enqueueUpdate(fiber, update); + scheduleUpdateOnFiber(fiber, lane, eventTime); + }, + enqueueForceUpdate: function (inst, callback) { + var fiber = get(inst); + var eventTime = requestEventTime(); + var lane = requestUpdateLane(fiber); + var update = createUpdate(eventTime, lane); + update.tag = ForceUpdate; + + if (callback !== undefined && callback !== null) { + { + warnOnInvalidCallback(callback, 'forceUpdate'); + } + + update.callback = callback; + } + + enqueueUpdate(fiber, update); + scheduleUpdateOnFiber(fiber, lane, eventTime); + } + }; + + function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) { + var instance = workInProgress.stateNode; + + if (typeof instance.shouldComponentUpdate === 'function') { + { + if ( workInProgress.mode & StrictMode) { + disableLogs(); + + try { + // Invoke the function an extra time to help detect side-effects. + instance.shouldComponentUpdate(newProps, newState, nextContext); + } finally { + reenableLogs(); + } + } + } + + var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext); + + { + if (shouldUpdate === undefined) { + error('%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(ctor) || 'Component'); + } + } + + return shouldUpdate; + } + + if (ctor.prototype && ctor.prototype.isPureReactComponent) { + return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState); + } + + return true; + } + + function checkClassInstance(workInProgress, ctor, newProps) { + var instance = workInProgress.stateNode; + + { + var name = getComponentName(ctor) || 'Component'; + var renderPresent = instance.render; + + if (!renderPresent) { + if (ctor.prototype && typeof ctor.prototype.render === 'function') { + error('%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name); + } else { + error('%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name); + } + } + + if (instance.getInitialState && !instance.getInitialState.isReactClassApproved && !instance.state) { + error('getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name); + } + + if (instance.getDefaultProps && !instance.getDefaultProps.isReactClassApproved) { + error('getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name); + } + + if (instance.propTypes) { + error('propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name); + } + + if (instance.contextType) { + error('contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name); + } + + { + if (instance.contextTypes) { + error('contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name); + } + + if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) { + didWarnAboutContextTypeAndContextTypes.add(ctor); + + error('%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name); + } + } + + if (typeof instance.componentShouldUpdate === 'function') { + error('%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name); + } + + if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') { + error('%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentName(ctor) || 'A pure component'); + } + + if (typeof instance.componentDidUnmount === 'function') { + error('%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name); + } + + if (typeof instance.componentDidReceiveProps === 'function') { + error('%s has a method called ' + 'componentDidReceiveProps(). But there is no such lifecycle method. ' + 'If you meant to update the state in response to changing props, ' + 'use componentWillReceiveProps(). If you meant to fetch data or ' + 'run side-effects or mutations after React has updated the UI, use componentDidUpdate().', name); + } + + if (typeof instance.componentWillRecieveProps === 'function') { + error('%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name); + } + + if (typeof instance.UNSAFE_componentWillRecieveProps === 'function') { + error('%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name); + } + + var hasMutatedProps = instance.props !== newProps; + + if (instance.props !== undefined && hasMutatedProps) { + error('%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name); + } + + if (instance.defaultProps) { + error('Setting defaultProps as an instance property on %s is not supported and will be ignored.' + ' Instead, define defaultProps as a static property on %s.', name, name); + } + + if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) { + didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor); + + error('%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(ctor)); + } + + if (typeof instance.getDerivedStateFromProps === 'function') { + error('%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name); + } + + if (typeof instance.getDerivedStateFromError === 'function') { + error('%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name); + } + + if (typeof ctor.getSnapshotBeforeUpdate === 'function') { + error('%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name); + } + + var _state = instance.state; + + if (_state && (typeof _state !== 'object' || isArray(_state))) { + error('%s.state: must be set to an object or null', name); + } + + if (typeof instance.getChildContext === 'function' && typeof ctor.childContextTypes !== 'object') { + error('%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name); + } + } + } + + function adoptClassInstance(workInProgress, instance) { + instance.updater = classComponentUpdater; + workInProgress.stateNode = instance; // The instance needs access to the fiber so that it can schedule updates + + set(instance, workInProgress); + + { + instance._reactInternalInstance = fakeInternalInstance; + } + } + + function constructClassInstance(workInProgress, ctor, props) { + var isLegacyContextConsumer = false; + var unmaskedContext = emptyContextObject; + var context = emptyContextObject; + var contextType = ctor.contextType; + + { + if ('contextType' in ctor) { + var isValid = // Allow null for conditional declaration + contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer> + + if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) { + didWarnAboutInvalidateContextType.add(ctor); + var addendum = ''; + + if (contextType === undefined) { + addendum = ' However, it is set to undefined. ' + 'This can be caused by a typo or by mixing up named and default imports. ' + 'This can also happen due to a circular dependency, so ' + 'try moving the createContext() call to a separate file.'; + } else if (typeof contextType !== 'object') { + addendum = ' However, it is set to a ' + typeof contextType + '.'; + } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) { + addendum = ' Did you accidentally pass the Context.Provider instead?'; + } else if (contextType._context !== undefined) { + // <Context.Consumer> + addendum = ' Did you accidentally pass the Context.Consumer instead?'; + } else { + addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.'; + } + + error('%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum); + } + } + } + + if (typeof contextType === 'object' && contextType !== null) { + context = readContext(contextType); + } else { + unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); + var contextTypes = ctor.contextTypes; + isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined; + context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject; + } // Instantiate twice to help detect side-effects. + + + { + if ( workInProgress.mode & StrictMode) { + disableLogs(); + + try { + new ctor(props, context); // eslint-disable-line no-new + } finally { + reenableLogs(); + } + } + } + + var instance = new ctor(props, context); + var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null; + adoptClassInstance(workInProgress, instance); + + { + if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) { + var componentName = getComponentName(ctor) || 'Component'; + + if (!didWarnAboutUninitializedState.has(componentName)) { + didWarnAboutUninitializedState.add(componentName); + + error('`%s` uses `getDerivedStateFromProps` but its initial state is ' + '%s. This is not recommended. Instead, define the initial state by ' + 'assigning an object to `this.state` in the constructor of `%s`. ' + 'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.', componentName, instance.state === null ? 'null' : 'undefined', componentName); + } + } // If new component APIs are defined, "unsafe" lifecycles won't be called. + // Warn about these lifecycles if they are present. + // Don't warn about react-lifecycles-compat polyfilled methods though. + + + if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') { + var foundWillMountName = null; + var foundWillReceivePropsName = null; + var foundWillUpdateName = null; + + if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) { + foundWillMountName = 'componentWillMount'; + } else if (typeof instance.UNSAFE_componentWillMount === 'function') { + foundWillMountName = 'UNSAFE_componentWillMount'; + } + + if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) { + foundWillReceivePropsName = 'componentWillReceiveProps'; + } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') { + foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps'; + } + + if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) { + foundWillUpdateName = 'componentWillUpdate'; + } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') { + foundWillUpdateName = 'UNSAFE_componentWillUpdate'; + } + + if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) { + var _componentName = getComponentName(ctor) || 'Component'; + + var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()'; + + if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) { + didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName); + + error('Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' + '%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n' + 'The above lifecycles should be removed. Learn more about this warning here:\n' + 'https://reactjs.org/link/unsafe-component-lifecycles', _componentName, newApiName, foundWillMountName !== null ? "\n " + foundWillMountName : '', foundWillReceivePropsName !== null ? "\n " + foundWillReceivePropsName : '', foundWillUpdateName !== null ? "\n " + foundWillUpdateName : ''); + } + } + } + } // Cache unmasked context so we can avoid recreating masked context unless necessary. + // ReactFiberContext usually updates this cache but can't for newly-created instances. + + + if (isLegacyContextConsumer) { + cacheContext(workInProgress, unmaskedContext, context); + } + + return instance; + } + + function callComponentWillMount(workInProgress, instance) { + var oldState = instance.state; + + if (typeof instance.componentWillMount === 'function') { + instance.componentWillMount(); + } + + if (typeof instance.UNSAFE_componentWillMount === 'function') { + instance.UNSAFE_componentWillMount(); + } + + if (oldState !== instance.state) { + { + error('%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress.type) || 'Component'); + } + + classComponentUpdater.enqueueReplaceState(instance, instance.state, null); + } + } + + function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) { + var oldState = instance.state; + + if (typeof instance.componentWillReceiveProps === 'function') { + instance.componentWillReceiveProps(newProps, nextContext); + } + + if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') { + instance.UNSAFE_componentWillReceiveProps(newProps, nextContext); + } + + if (instance.state !== oldState) { + { + var componentName = getComponentName(workInProgress.type) || 'Component'; + + if (!didWarnAboutStateAssignmentForComponent.has(componentName)) { + didWarnAboutStateAssignmentForComponent.add(componentName); + + error('%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName); + } + } + + classComponentUpdater.enqueueReplaceState(instance, instance.state, null); + } + } // Invokes the mount life-cycles on a previously never rendered instance. + + + function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { + { + checkClassInstance(workInProgress, ctor, newProps); + } + + var instance = workInProgress.stateNode; + instance.props = newProps; + instance.state = workInProgress.memoizedState; + instance.refs = emptyRefsObject; + initializeUpdateQueue(workInProgress); + var contextType = ctor.contextType; + + if (typeof contextType === 'object' && contextType !== null) { + instance.context = readContext(contextType); + } else { + var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); + instance.context = getMaskedContext(workInProgress, unmaskedContext); + } + + { + if (instance.state === newProps) { + var componentName = getComponentName(ctor) || 'Component'; + + if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) { + didWarnAboutDirectlyAssigningPropsToState.add(componentName); + + error('%s: It is not recommended to assign props directly to state ' + "because updates to props won't be reflected in state. " + 'In most cases, it is better to use props directly.', componentName); + } + } + + if (workInProgress.mode & StrictMode) { + ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance); + } + + { + ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance); + } + } + + processUpdateQueue(workInProgress, newProps, instance, renderLanes); + instance.state = workInProgress.memoizedState; + var getDerivedStateFromProps = ctor.getDerivedStateFromProps; + + if (typeof getDerivedStateFromProps === 'function') { + applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); + instance.state = workInProgress.memoizedState; + } // In order to support react-lifecycles-compat polyfilled components, + // Unsafe lifecycles should not be invoked for components using the new APIs. + + + if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) { + callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's + // process them now. + + processUpdateQueue(workInProgress, newProps, instance, renderLanes); + instance.state = workInProgress.memoizedState; + } + + if (typeof instance.componentDidMount === 'function') { + workInProgress.flags |= Update; + } + } + + function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) { + var instance = workInProgress.stateNode; + var oldProps = workInProgress.memoizedProps; + instance.props = oldProps; + var oldContext = instance.context; + var contextType = ctor.contextType; + var nextContext = emptyContextObject; + + if (typeof contextType === 'object' && contextType !== null) { + nextContext = readContext(contextType); + } else { + var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); + nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext); + } + + var getDerivedStateFromProps = ctor.getDerivedStateFromProps; + var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what + // ever the previously attempted to render - not the "current". However, + // during componentDidUpdate we pass the "current" props. + // In order to support react-lifecycles-compat polyfilled components, + // Unsafe lifecycles should not be invoked for components using the new APIs. + + if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) { + if (oldProps !== newProps || oldContext !== nextContext) { + callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext); + } + } + + resetHasForceUpdateBeforeProcessing(); + var oldState = workInProgress.memoizedState; + var newState = instance.state = oldState; + processUpdateQueue(workInProgress, newProps, instance, renderLanes); + newState = workInProgress.memoizedState; + + if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) { + // If an update was already in progress, we should schedule an Update + // effect even though we're bailing out, so that cWU/cDU are called. + if (typeof instance.componentDidMount === 'function') { + workInProgress.flags |= Update; + } + + return false; + } + + if (typeof getDerivedStateFromProps === 'function') { + applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); + newState = workInProgress.memoizedState; + } + + var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext); + + if (shouldUpdate) { + // In order to support react-lifecycles-compat polyfilled components, + // Unsafe lifecycles should not be invoked for components using the new APIs. + if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) { + if (typeof instance.componentWillMount === 'function') { + instance.componentWillMount(); + } + + if (typeof instance.UNSAFE_componentWillMount === 'function') { + instance.UNSAFE_componentWillMount(); + } + } + + if (typeof instance.componentDidMount === 'function') { + workInProgress.flags |= Update; + } + } else { + // If an update was already in progress, we should schedule an Update + // effect even though we're bailing out, so that cWU/cDU are called. + if (typeof instance.componentDidMount === 'function') { + workInProgress.flags |= Update; + } // If shouldComponentUpdate returned false, we should still update the + // memoized state to indicate that this work can be reused. + + + workInProgress.memoizedProps = newProps; + workInProgress.memoizedState = newState; + } // Update the existing instance's state, props, and context pointers even + // if shouldComponentUpdate returns false. + + + instance.props = newProps; + instance.state = newState; + instance.context = nextContext; + return shouldUpdate; + } // Invokes the update life-cycles and returns false if it shouldn't rerender. + + + function updateClassInstance(current, workInProgress, ctor, newProps, renderLanes) { + var instance = workInProgress.stateNode; + cloneUpdateQueue(current, workInProgress); + var unresolvedOldProps = workInProgress.memoizedProps; + var oldProps = workInProgress.type === workInProgress.elementType ? unresolvedOldProps : resolveDefaultProps(workInProgress.type, unresolvedOldProps); + instance.props = oldProps; + var unresolvedNewProps = workInProgress.pendingProps; + var oldContext = instance.context; + var contextType = ctor.contextType; + var nextContext = emptyContextObject; + + if (typeof contextType === 'object' && contextType !== null) { + nextContext = readContext(contextType); + } else { + var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); + nextContext = getMaskedContext(workInProgress, nextUnmaskedContext); + } + + var getDerivedStateFromProps = ctor.getDerivedStateFromProps; + var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what + // ever the previously attempted to render - not the "current". However, + // during componentDidUpdate we pass the "current" props. + // In order to support react-lifecycles-compat polyfilled components, + // Unsafe lifecycles should not be invoked for components using the new APIs. + + if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) { + if (unresolvedOldProps !== unresolvedNewProps || oldContext !== nextContext) { + callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext); + } + } + + resetHasForceUpdateBeforeProcessing(); + var oldState = workInProgress.memoizedState; + var newState = instance.state = oldState; + processUpdateQueue(workInProgress, newProps, instance, renderLanes); + newState = workInProgress.memoizedState; + + if (unresolvedOldProps === unresolvedNewProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) { + // If an update was already in progress, we should schedule an Update + // effect even though we're bailing out, so that cWU/cDU are called. + if (typeof instance.componentDidUpdate === 'function') { + if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) { + workInProgress.flags |= Update; + } + } + + if (typeof instance.getSnapshotBeforeUpdate === 'function') { + if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) { + workInProgress.flags |= Snapshot; + } + } + + return false; + } + + if (typeof getDerivedStateFromProps === 'function') { + applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); + newState = workInProgress.memoizedState; + } + + var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext); + + if (shouldUpdate) { + // In order to support react-lifecycles-compat polyfilled components, + // Unsafe lifecycles should not be invoked for components using the new APIs. + if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) { + if (typeof instance.componentWillUpdate === 'function') { + instance.componentWillUpdate(newProps, newState, nextContext); + } + + if (typeof instance.UNSAFE_componentWillUpdate === 'function') { + instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext); + } + } + + if (typeof instance.componentDidUpdate === 'function') { + workInProgress.flags |= Update; + } + + if (typeof instance.getSnapshotBeforeUpdate === 'function') { + workInProgress.flags |= Snapshot; + } + } else { + // If an update was already in progress, we should schedule an Update + // effect even though we're bailing out, so that cWU/cDU are called. + if (typeof instance.componentDidUpdate === 'function') { + if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) { + workInProgress.flags |= Update; + } + } + + if (typeof instance.getSnapshotBeforeUpdate === 'function') { + if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) { + workInProgress.flags |= Snapshot; + } + } // If shouldComponentUpdate returned false, we should still update the + // memoized props/state to indicate that this work can be reused. + + + workInProgress.memoizedProps = newProps; + workInProgress.memoizedState = newState; + } // Update the existing instance's state, props, and context pointers even + // if shouldComponentUpdate returns false. + + + instance.props = newProps; + instance.state = newState; + instance.context = nextContext; + return shouldUpdate; + } + + var didWarnAboutMaps; + var didWarnAboutGenerators; + var didWarnAboutStringRefs; + var ownerHasKeyUseWarning; + var ownerHasFunctionTypeWarning; + + var warnForMissingKey = function (child, returnFiber) {}; + + { + didWarnAboutMaps = false; + didWarnAboutGenerators = false; + didWarnAboutStringRefs = {}; + /** + * Warn if there's no key explicitly set on dynamic arrays of children or + * object keys are not valid. This allows us to keep track of children between + * updates. + */ + + ownerHasKeyUseWarning = {}; + ownerHasFunctionTypeWarning = {}; + + warnForMissingKey = function (child, returnFiber) { + if (child === null || typeof child !== 'object') { + return; + } + + if (!child._store || child._store.validated || child.key != null) { + return; + } + + if (!(typeof child._store === 'object')) { + { + throw Error( "React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue." ); + } + } + + child._store.validated = true; + var componentName = getComponentName(returnFiber.type) || 'Component'; + + if (ownerHasKeyUseWarning[componentName]) { + return; + } + + ownerHasKeyUseWarning[componentName] = true; + + error('Each child in a list should have a unique ' + '"key" prop. See https://reactjs.org/link/warning-keys for ' + 'more information.'); + }; + } + + var isArray$1 = Array.isArray; + + function coerceRef(returnFiber, current, element) { + var mixedRef = element.ref; + + if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') { + { + // TODO: Clean this up once we turn on the string ref warning for + // everyone, because the strict mode case will no longer be relevant + if ((returnFiber.mode & StrictMode || warnAboutStringRefs) && // We warn in ReactElement.js if owner and self are equal for string refs + // because these cannot be automatically converted to an arrow function + // using a codemod. Therefore, we don't have to warn about string refs again. + !(element._owner && element._self && element._owner.stateNode !== element._self)) { + var componentName = getComponentName(returnFiber.type) || 'Component'; + + if (!didWarnAboutStringRefs[componentName]) { + { + error('A string ref, "%s", has been found within a strict mode tree. ' + 'String refs are a source of potential bugs and should be avoided. ' + 'We recommend using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', mixedRef); + } + + didWarnAboutStringRefs[componentName] = true; + } + } + } + + if (element._owner) { + var owner = element._owner; + var inst; + + if (owner) { + var ownerFiber = owner; + + if (!(ownerFiber.tag === ClassComponent)) { + { + throw Error( "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref" ); + } + } + + inst = ownerFiber.stateNode; + } + + if (!inst) { + { + throw Error( "Missing owner for string ref " + mixedRef + ". This error is likely caused by a bug in React. Please file an issue." ); + } + } + + var stringRef = '' + mixedRef; // Check if previous string ref matches new string ref + + if (current !== null && current.ref !== null && typeof current.ref === 'function' && current.ref._stringRef === stringRef) { + return current.ref; + } + + var ref = function (value) { + var refs = inst.refs; + + if (refs === emptyRefsObject) { + // This is a lazy pooled frozen object, so we need to initialize. + refs = inst.refs = {}; + } + + if (value === null) { + delete refs[stringRef]; + } else { + refs[stringRef] = value; + } + }; + + ref._stringRef = stringRef; + return ref; + } else { + if (!(typeof mixedRef === 'string')) { + { + throw Error( "Expected ref to be a function, a string, an object returned by React.createRef(), or null." ); + } + } + + if (!element._owner) { + { + throw Error( "Element ref was specified as a string (" + mixedRef + ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://reactjs.org/link/refs-must-have-owner for more information." ); + } + } + } + } + + return mixedRef; + } + + function throwOnInvalidObjectType(returnFiber, newChild) { + if (returnFiber.type !== 'textarea') { + { + { + throw Error( "Objects are not valid as a React child (found: " + (Object.prototype.toString.call(newChild) === '[object Object]' ? 'object with keys {' + Object.keys(newChild).join(', ') + '}' : newChild) + "). If you meant to render a collection of children, use an array instead." ); + } + } + } + } + + function warnOnFunctionType(returnFiber) { + { + var componentName = getComponentName(returnFiber.type) || 'Component'; + + if (ownerHasFunctionTypeWarning[componentName]) { + return; + } + + ownerHasFunctionTypeWarning[componentName] = true; + + error('Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.'); + } + } // We avoid inlining this to avoid potential deopts from using try/catch. + // to be able to optimize each path individually by branching early. This needs + // a compiler or we can do it manually. Helpers that don't need this branching + // live outside of this function. + + + function ChildReconciler(shouldTrackSideEffects) { + function deleteChild(returnFiber, childToDelete) { + if (!shouldTrackSideEffects) { + // Noop. + return; + } // Deletions are added in reversed order so we add it to the front. + // At this point, the return fiber's effect list is empty except for + // deletions, so we can just append the deletion to the list. The remaining + // effects aren't added until the complete phase. Once we implement + // resuming, this may not be true. + + + var last = returnFiber.lastEffect; + + if (last !== null) { + last.nextEffect = childToDelete; + returnFiber.lastEffect = childToDelete; + } else { + returnFiber.firstEffect = returnFiber.lastEffect = childToDelete; + } + + childToDelete.nextEffect = null; + childToDelete.flags = Deletion; + } + + function deleteRemainingChildren(returnFiber, currentFirstChild) { + if (!shouldTrackSideEffects) { + // Noop. + return null; + } // TODO: For the shouldClone case, this could be micro-optimized a bit by + // assuming that after the first child we've already added everything. + + + var childToDelete = currentFirstChild; + + while (childToDelete !== null) { + deleteChild(returnFiber, childToDelete); + childToDelete = childToDelete.sibling; + } + + return null; + } + + function mapRemainingChildren(returnFiber, currentFirstChild) { + // Add the remaining children to a temporary map so that we can find them by + // keys quickly. Implicit (null) keys get added to this set with their index + // instead. + var existingChildren = new Map(); + var existingChild = currentFirstChild; + + while (existingChild !== null) { + if (existingChild.key !== null) { + existingChildren.set(existingChild.key, existingChild); + } else { + existingChildren.set(existingChild.index, existingChild); + } + + existingChild = existingChild.sibling; + } + + return existingChildren; + } + + function useFiber(fiber, pendingProps) { + // We currently set sibling to null and index to 0 here because it is easy + // to forget to do before returning it. E.g. for the single child case. + var clone = createWorkInProgress(fiber, pendingProps); + clone.index = 0; + clone.sibling = null; + return clone; + } + + function placeChild(newFiber, lastPlacedIndex, newIndex) { + newFiber.index = newIndex; + + if (!shouldTrackSideEffects) { + // Noop. + return lastPlacedIndex; + } + + var current = newFiber.alternate; + + if (current !== null) { + var oldIndex = current.index; + + if (oldIndex < lastPlacedIndex) { + // This is a move. + newFiber.flags = Placement; + return lastPlacedIndex; + } else { + // This item can stay in place. + return oldIndex; + } + } else { + // This is an insertion. + newFiber.flags = Placement; + return lastPlacedIndex; + } + } + + function placeSingleChild(newFiber) { + // This is simpler for the single child case. We only need to do a + // placement for inserting new children. + if (shouldTrackSideEffects && newFiber.alternate === null) { + newFiber.flags = Placement; + } + + return newFiber; + } + + function updateTextNode(returnFiber, current, textContent, lanes) { + if (current === null || current.tag !== HostText) { + // Insert + var created = createFiberFromText(textContent, returnFiber.mode, lanes); + created.return = returnFiber; + return created; + } else { + // Update + var existing = useFiber(current, textContent); + existing.return = returnFiber; + return existing; + } + } + + function updateElement(returnFiber, current, element, lanes) { + if (current !== null) { + if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path: + isCompatibleFamilyForHotReloading(current, element) )) { + // Move based on index + var existing = useFiber(current, element.props); + existing.ref = coerceRef(returnFiber, current, element); + existing.return = returnFiber; + + { + existing._debugSource = element._source; + existing._debugOwner = element._owner; + } + + return existing; + } + } // Insert + + + var created = createFiberFromElement(element, returnFiber.mode, lanes); + created.ref = coerceRef(returnFiber, current, element); + created.return = returnFiber; + return created; + } + + function updatePortal(returnFiber, current, portal, lanes) { + if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) { + // Insert + var created = createFiberFromPortal(portal, returnFiber.mode, lanes); + created.return = returnFiber; + return created; + } else { + // Update + var existing = useFiber(current, portal.children || []); + existing.return = returnFiber; + return existing; + } + } + + function updateFragment(returnFiber, current, fragment, lanes, key) { + if (current === null || current.tag !== Fragment) { + // Insert + var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key); + created.return = returnFiber; + return created; + } else { + // Update + var existing = useFiber(current, fragment); + existing.return = returnFiber; + return existing; + } + } + + function createChild(returnFiber, newChild, lanes) { + if (typeof newChild === 'string' || typeof newChild === 'number') { + // Text nodes don't have keys. If the previous node is implicitly keyed + // we can continue to replace it without aborting even if it is not a text + // node. + var created = createFiberFromText('' + newChild, returnFiber.mode, lanes); + created.return = returnFiber; + return created; + } + + if (typeof newChild === 'object' && newChild !== null) { + switch (newChild.$$typeof) { + case REACT_ELEMENT_TYPE: + { + var _created = createFiberFromElement(newChild, returnFiber.mode, lanes); + + _created.ref = coerceRef(returnFiber, null, newChild); + _created.return = returnFiber; + return _created; + } + + case REACT_PORTAL_TYPE: + { + var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes); + + _created2.return = returnFiber; + return _created2; + } + } + + if (isArray$1(newChild) || getIteratorFn(newChild)) { + var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null); + + _created3.return = returnFiber; + return _created3; + } + + throwOnInvalidObjectType(returnFiber, newChild); + } + + { + if (typeof newChild === 'function') { + warnOnFunctionType(returnFiber); + } + } + + return null; + } + + function updateSlot(returnFiber, oldFiber, newChild, lanes) { + // Update the fiber if the keys match, otherwise return null. + var key = oldFiber !== null ? oldFiber.key : null; + + if (typeof newChild === 'string' || typeof newChild === 'number') { + // Text nodes don't have keys. If the previous node is implicitly keyed + // we can continue to replace it without aborting even if it is not a text + // node. + if (key !== null) { + return null; + } + + return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes); + } + + if (typeof newChild === 'object' && newChild !== null) { + switch (newChild.$$typeof) { + case REACT_ELEMENT_TYPE: + { + if (newChild.key === key) { + if (newChild.type === REACT_FRAGMENT_TYPE) { + return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key); + } + + return updateElement(returnFiber, oldFiber, newChild, lanes); + } else { + return null; + } + } + + case REACT_PORTAL_TYPE: + { + if (newChild.key === key) { + return updatePortal(returnFiber, oldFiber, newChild, lanes); + } else { + return null; + } + } + } + + if (isArray$1(newChild) || getIteratorFn(newChild)) { + if (key !== null) { + return null; + } + + return updateFragment(returnFiber, oldFiber, newChild, lanes, null); + } + + throwOnInvalidObjectType(returnFiber, newChild); + } + + { + if (typeof newChild === 'function') { + warnOnFunctionType(returnFiber); + } + } + + return null; + } + + function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) { + if (typeof newChild === 'string' || typeof newChild === 'number') { + // Text nodes don't have keys, so we neither have to check the old nor + // new node for the key. If both are text nodes, they match. + var matchedFiber = existingChildren.get(newIdx) || null; + return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes); + } + + if (typeof newChild === 'object' && newChild !== null) { + switch (newChild.$$typeof) { + case REACT_ELEMENT_TYPE: + { + var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null; + + if (newChild.type === REACT_FRAGMENT_TYPE) { + return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key); + } + + return updateElement(returnFiber, _matchedFiber, newChild, lanes); + } + + case REACT_PORTAL_TYPE: + { + var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null; + + return updatePortal(returnFiber, _matchedFiber2, newChild, lanes); + } + + } + + if (isArray$1(newChild) || getIteratorFn(newChild)) { + var _matchedFiber3 = existingChildren.get(newIdx) || null; + + return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null); + } + + throwOnInvalidObjectType(returnFiber, newChild); + } + + { + if (typeof newChild === 'function') { + warnOnFunctionType(returnFiber); + } + } + + return null; + } + /** + * Warns if there is a duplicate or missing key + */ + + + function warnOnInvalidKey(child, knownKeys, returnFiber) { + { + if (typeof child !== 'object' || child === null) { + return knownKeys; + } + + switch (child.$$typeof) { + case REACT_ELEMENT_TYPE: + case REACT_PORTAL_TYPE: + warnForMissingKey(child, returnFiber); + var key = child.key; + + if (typeof key !== 'string') { + break; + } + + if (knownKeys === null) { + knownKeys = new Set(); + knownKeys.add(key); + break; + } + + if (!knownKeys.has(key)) { + knownKeys.add(key); + break; + } + + error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key); + + break; + } + } + + return knownKeys; + } + + function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) { + // This algorithm can't optimize by searching from both ends since we + // don't have backpointers on fibers. I'm trying to see how far we can get + // with that model. If it ends up not being worth the tradeoffs, we can + // add it later. + // Even with a two ended optimization, we'd want to optimize for the case + // where there are few changes and brute force the comparison instead of + // going for the Map. It'd like to explore hitting that path first in + // forward-only mode and only go for the Map once we notice that we need + // lots of look ahead. This doesn't handle reversal as well as two ended + // search but that's unusual. Besides, for the two ended optimization to + // work on Iterables, we'd need to copy the whole set. + // In this first iteration, we'll just live with hitting the bad case + // (adding everything to a Map) in for every insert/move. + // If you change this code, also update reconcileChildrenIterator() which + // uses the same algorithm. + { + // First, validate keys. + var knownKeys = null; + + for (var i = 0; i < newChildren.length; i++) { + var child = newChildren[i]; + knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber); + } + } + + var resultingFirstChild = null; + var previousNewFiber = null; + var oldFiber = currentFirstChild; + var lastPlacedIndex = 0; + var newIdx = 0; + var nextOldFiber = null; + + for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) { + if (oldFiber.index > newIdx) { + nextOldFiber = oldFiber; + oldFiber = null; + } else { + nextOldFiber = oldFiber.sibling; + } + + var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes); + + if (newFiber === null) { + // TODO: This breaks on empty slots like null children. That's + // unfortunate because it triggers the slow path all the time. We need + // a better way to communicate whether this was a miss or null, + // boolean, undefined, etc. + if (oldFiber === null) { + oldFiber = nextOldFiber; + } + + break; + } + + if (shouldTrackSideEffects) { + if (oldFiber && newFiber.alternate === null) { + // We matched the slot, but we didn't reuse the existing fiber, so we + // need to delete the existing child. + deleteChild(returnFiber, oldFiber); + } + } + + lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx); + + if (previousNewFiber === null) { + // TODO: Move out of the loop. This only happens for the first run. + resultingFirstChild = newFiber; + } else { + // TODO: Defer siblings if we're not at the right index for this slot. + // I.e. if we had null values before, then we want to defer this + // for each null value. However, we also don't want to call updateSlot + // with the previous one. + previousNewFiber.sibling = newFiber; + } + + previousNewFiber = newFiber; + oldFiber = nextOldFiber; + } + + if (newIdx === newChildren.length) { + // We've reached the end of the new children. We can delete the rest. + deleteRemainingChildren(returnFiber, oldFiber); + return resultingFirstChild; + } + + if (oldFiber === null) { + // If we don't have any more existing children we can choose a fast path + // since the rest will all be insertions. + for (; newIdx < newChildren.length; newIdx++) { + var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes); + + if (_newFiber === null) { + continue; + } + + lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx); + + if (previousNewFiber === null) { + // TODO: Move out of the loop. This only happens for the first run. + resultingFirstChild = _newFiber; + } else { + previousNewFiber.sibling = _newFiber; + } + + previousNewFiber = _newFiber; + } + + return resultingFirstChild; + } // Add all children to a key map for quick lookups. + + + var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves. + + for (; newIdx < newChildren.length; newIdx++) { + var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes); + + if (_newFiber2 !== null) { + if (shouldTrackSideEffects) { + if (_newFiber2.alternate !== null) { + // The new fiber is a work in progress, but if there exists a + // current, that means that we reused the fiber. We need to delete + // it from the child list so that we don't add it to the deletion + // list. + existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key); + } + } + + lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx); + + if (previousNewFiber === null) { + resultingFirstChild = _newFiber2; + } else { + previousNewFiber.sibling = _newFiber2; + } + + previousNewFiber = _newFiber2; + } + } + + if (shouldTrackSideEffects) { + // Any existing children that weren't consumed above were deleted. We need + // to add them to the deletion list. + existingChildren.forEach(function (child) { + return deleteChild(returnFiber, child); + }); + } + + return resultingFirstChild; + } + + function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) { + // This is the same implementation as reconcileChildrenArray(), + // but using the iterator instead. + var iteratorFn = getIteratorFn(newChildrenIterable); + + if (!(typeof iteratorFn === 'function')) { + { + throw Error( "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." ); + } + } + + { + // We don't support rendering Generators because it's a mutation. + // See https://github.com/facebook/react/issues/12995 + if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag + newChildrenIterable[Symbol.toStringTag] === 'Generator') { + if (!didWarnAboutGenerators) { + error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.'); + } + + didWarnAboutGenerators = true; + } // Warn about using Maps as children + + + if (newChildrenIterable.entries === iteratorFn) { + if (!didWarnAboutMaps) { + error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.'); + } + + didWarnAboutMaps = true; + } // First, validate keys. + // We'll get a different iterator later for the main pass. + + + var _newChildren = iteratorFn.call(newChildrenIterable); + + if (_newChildren) { + var knownKeys = null; + + var _step = _newChildren.next(); + + for (; !_step.done; _step = _newChildren.next()) { + var child = _step.value; + knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber); + } + } + } + + var newChildren = iteratorFn.call(newChildrenIterable); + + if (!(newChildren != null)) { + { + throw Error( "An iterable object provided no iterator." ); + } + } + + var resultingFirstChild = null; + var previousNewFiber = null; + var oldFiber = currentFirstChild; + var lastPlacedIndex = 0; + var newIdx = 0; + var nextOldFiber = null; + var step = newChildren.next(); + + for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) { + if (oldFiber.index > newIdx) { + nextOldFiber = oldFiber; + oldFiber = null; + } else { + nextOldFiber = oldFiber.sibling; + } + + var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes); + + if (newFiber === null) { + // TODO: This breaks on empty slots like null children. That's + // unfortunate because it triggers the slow path all the time. We need + // a better way to communicate whether this was a miss or null, + // boolean, undefined, etc. + if (oldFiber === null) { + oldFiber = nextOldFiber; + } + + break; + } + + if (shouldTrackSideEffects) { + if (oldFiber && newFiber.alternate === null) { + // We matched the slot, but we didn't reuse the existing fiber, so we + // need to delete the existing child. + deleteChild(returnFiber, oldFiber); + } + } + + lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx); + + if (previousNewFiber === null) { + // TODO: Move out of the loop. This only happens for the first run. + resultingFirstChild = newFiber; + } else { + // TODO: Defer siblings if we're not at the right index for this slot. + // I.e. if we had null values before, then we want to defer this + // for each null value. However, we also don't want to call updateSlot + // with the previous one. + previousNewFiber.sibling = newFiber; + } + + previousNewFiber = newFiber; + oldFiber = nextOldFiber; + } + + if (step.done) { + // We've reached the end of the new children. We can delete the rest. + deleteRemainingChildren(returnFiber, oldFiber); + return resultingFirstChild; + } + + if (oldFiber === null) { + // If we don't have any more existing children we can choose a fast path + // since the rest will all be insertions. + for (; !step.done; newIdx++, step = newChildren.next()) { + var _newFiber3 = createChild(returnFiber, step.value, lanes); + + if (_newFiber3 === null) { + continue; + } + + lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx); + + if (previousNewFiber === null) { + // TODO: Move out of the loop. This only happens for the first run. + resultingFirstChild = _newFiber3; + } else { + previousNewFiber.sibling = _newFiber3; + } + + previousNewFiber = _newFiber3; + } + + return resultingFirstChild; + } // Add all children to a key map for quick lookups. + + + var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves. + + for (; !step.done; newIdx++, step = newChildren.next()) { + var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes); + + if (_newFiber4 !== null) { + if (shouldTrackSideEffects) { + if (_newFiber4.alternate !== null) { + // The new fiber is a work in progress, but if there exists a + // current, that means that we reused the fiber. We need to delete + // it from the child list so that we don't add it to the deletion + // list. + existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key); + } + } + + lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx); + + if (previousNewFiber === null) { + resultingFirstChild = _newFiber4; + } else { + previousNewFiber.sibling = _newFiber4; + } + + previousNewFiber = _newFiber4; + } + } + + if (shouldTrackSideEffects) { + // Any existing children that weren't consumed above were deleted. We need + // to add them to the deletion list. + existingChildren.forEach(function (child) { + return deleteChild(returnFiber, child); + }); + } + + return resultingFirstChild; + } + + function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) { + // There's no need to check for keys on text nodes since we don't have a + // way to define them. + if (currentFirstChild !== null && currentFirstChild.tag === HostText) { + // We already have an existing node so let's just update it and delete + // the rest. + deleteRemainingChildren(returnFiber, currentFirstChild.sibling); + var existing = useFiber(currentFirstChild, textContent); + existing.return = returnFiber; + return existing; + } // The existing first child is not a text node so we need to create one + // and delete the existing ones. + + + deleteRemainingChildren(returnFiber, currentFirstChild); + var created = createFiberFromText(textContent, returnFiber.mode, lanes); + created.return = returnFiber; + return created; + } + + function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) { + var key = element.key; + var child = currentFirstChild; + + while (child !== null) { + // TODO: If key === null and child.key === null, then this only applies to + // the first item in the list. + if (child.key === key) { + switch (child.tag) { + case Fragment: + { + if (element.type === REACT_FRAGMENT_TYPE) { + deleteRemainingChildren(returnFiber, child.sibling); + var existing = useFiber(child, element.props.children); + existing.return = returnFiber; + + { + existing._debugSource = element._source; + existing._debugOwner = element._owner; + } + + return existing; + } + + break; + } + + case Block: + + // We intentionally fallthrough here if enableBlocksAPI is not on. + // eslint-disable-next-lined no-fallthrough + + default: + { + if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path: + isCompatibleFamilyForHotReloading(child, element) )) { + deleteRemainingChildren(returnFiber, child.sibling); + + var _existing3 = useFiber(child, element.props); + + _existing3.ref = coerceRef(returnFiber, child, element); + _existing3.return = returnFiber; + + { + _existing3._debugSource = element._source; + _existing3._debugOwner = element._owner; + } + + return _existing3; + } + + break; + } + } // Didn't match. + + + deleteRemainingChildren(returnFiber, child); + break; + } else { + deleteChild(returnFiber, child); + } + + child = child.sibling; + } + + if (element.type === REACT_FRAGMENT_TYPE) { + var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key); + created.return = returnFiber; + return created; + } else { + var _created4 = createFiberFromElement(element, returnFiber.mode, lanes); + + _created4.ref = coerceRef(returnFiber, currentFirstChild, element); + _created4.return = returnFiber; + return _created4; + } + } + + function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) { + var key = portal.key; + var child = currentFirstChild; + + while (child !== null) { + // TODO: If key === null and child.key === null, then this only applies to + // the first item in the list. + if (child.key === key) { + if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) { + deleteRemainingChildren(returnFiber, child.sibling); + var existing = useFiber(child, portal.children || []); + existing.return = returnFiber; + return existing; + } else { + deleteRemainingChildren(returnFiber, child); + break; + } + } else { + deleteChild(returnFiber, child); + } + + child = child.sibling; + } + + var created = createFiberFromPortal(portal, returnFiber.mode, lanes); + created.return = returnFiber; + return created; + } // This API will tag the children with the side-effect of the reconciliation + // itself. They will be added to the side-effect list as we pass through the + // children and the parent. + + + function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) { + // This function is not recursive. + // If the top level item is an array, we treat it as a set of children, + // not as a fragment. Nested arrays on the other hand will be treated as + // fragment nodes. Recursion happens at the normal flow. + // Handle top level unkeyed fragments as if they were arrays. + // This leads to an ambiguity between <>{[...]}</> and <>...</>. + // We treat the ambiguous cases above the same. + var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null; + + if (isUnkeyedTopLevelFragment) { + newChild = newChild.props.children; + } // Handle object types + + + var isObject = typeof newChild === 'object' && newChild !== null; + + if (isObject) { + switch (newChild.$$typeof) { + case REACT_ELEMENT_TYPE: + return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes)); + + case REACT_PORTAL_TYPE: + return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes)); + + } + } + + if (typeof newChild === 'string' || typeof newChild === 'number') { + return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes)); + } + + if (isArray$1(newChild)) { + return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes); + } + + if (getIteratorFn(newChild)) { + return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes); + } + + if (isObject) { + throwOnInvalidObjectType(returnFiber, newChild); + } + + { + if (typeof newChild === 'function') { + warnOnFunctionType(returnFiber); + } + } + + if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) { + // If the new child is undefined, and the return fiber is a composite + // component, throw an error. If Fiber return types are disabled, + // we already threw above. + switch (returnFiber.tag) { + case ClassComponent: + { + { + var instance = returnFiber.stateNode; + + if (instance.render._isMockFunction) { + // We allow auto-mocks to proceed as if they're returning null. + break; + } + } + } + // Intentionally fall through to the next case, which handles both + // functions and classes + // eslint-disable-next-lined no-fallthrough + + case Block: + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: + { + { + { + throw Error( (getComponentName(returnFiber.type) || 'Component') + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." ); + } + } + } + } + } // Remaining cases are all treated as empty. + + + return deleteRemainingChildren(returnFiber, currentFirstChild); + } + + return reconcileChildFibers; + } + + var reconcileChildFibers = ChildReconciler(true); + var mountChildFibers = ChildReconciler(false); + function cloneChildFibers(current, workInProgress) { + if (!(current === null || workInProgress.child === current.child)) { + { + throw Error( "Resuming work not yet implemented." ); + } + } + + if (workInProgress.child === null) { + return; + } + + var currentChild = workInProgress.child; + var newChild = createWorkInProgress(currentChild, currentChild.pendingProps); + workInProgress.child = newChild; + newChild.return = workInProgress; + + while (currentChild.sibling !== null) { + currentChild = currentChild.sibling; + newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps); + newChild.return = workInProgress; + } + + newChild.sibling = null; + } // Reset a workInProgress child set to prepare it for a second pass. + + function resetChildFibers(workInProgress, lanes) { + var child = workInProgress.child; + + while (child !== null) { + resetWorkInProgress(child, lanes); + child = child.sibling; + } + } + + var NO_CONTEXT = {}; + var contextStackCursor$1 = createCursor(NO_CONTEXT); + var contextFiberStackCursor = createCursor(NO_CONTEXT); + var rootInstanceStackCursor = createCursor(NO_CONTEXT); + + function requiredContext(c) { + if (!(c !== NO_CONTEXT)) { + { + throw Error( "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." ); + } + } + + return c; + } + + function getRootHostContainer() { + var rootInstance = requiredContext(rootInstanceStackCursor.current); + return rootInstance; + } + + function pushHostContainer(fiber, nextRootInstance) { + // Push current root instance onto the stack; + // This allows us to reset root when portals are popped. + push(rootInstanceStackCursor, nextRootInstance, fiber); // Track the context and the Fiber that provided it. + // This enables us to pop only Fibers that provide unique contexts. + + push(contextFiberStackCursor, fiber, fiber); // Finally, we need to push the host context to the stack. + // However, we can't just call getRootHostContext() and push it because + // we'd have a different number of entries on the stack depending on + // whether getRootHostContext() throws somewhere in renderer code or not. + // So we push an empty value first. This lets us safely unwind on errors. + + push(contextStackCursor$1, NO_CONTEXT, fiber); + var nextRootContext = getRootHostContext(nextRootInstance); // Now that we know this function doesn't throw, replace it. + + pop(contextStackCursor$1, fiber); + push(contextStackCursor$1, nextRootContext, fiber); + } + + function popHostContainer(fiber) { + pop(contextStackCursor$1, fiber); + pop(contextFiberStackCursor, fiber); + pop(rootInstanceStackCursor, fiber); + } + + function getHostContext() { + var context = requiredContext(contextStackCursor$1.current); + return context; + } + + function pushHostContext(fiber) { + var rootInstance = requiredContext(rootInstanceStackCursor.current); + var context = requiredContext(contextStackCursor$1.current); + var nextContext = getChildHostContext(context, fiber.type); // Don't push this Fiber's context unless it's unique. + + if (context === nextContext) { + return; + } // Track the context and the Fiber that provided it. + // This enables us to pop only Fibers that provide unique contexts. + + + push(contextFiberStackCursor, fiber, fiber); + push(contextStackCursor$1, nextContext, fiber); + } + + function popHostContext(fiber) { + // Do not pop unless this Fiber provided the current context. + // pushHostContext() only pushes Fibers that provide unique contexts. + if (contextFiberStackCursor.current !== fiber) { + return; + } + + pop(contextStackCursor$1, fiber); + pop(contextFiberStackCursor, fiber); + } + + var DefaultSuspenseContext = 0; // The Suspense Context is split into two parts. The lower bits is + // inherited deeply down the subtree. The upper bits only affect + // this immediate suspense boundary and gets reset each new + // boundary or suspense list. + + var SubtreeSuspenseContextMask = 1; // Subtree Flags: + // InvisibleParentSuspenseContext indicates that one of our parent Suspense + // boundaries is not currently showing visible main content. + // Either because it is already showing a fallback or is not mounted at all. + // We can use this to determine if it is desirable to trigger a fallback at + // the parent. If not, then we might need to trigger undesirable boundaries + // and/or suspend the commit to avoid hiding the parent content. + + var InvisibleParentSuspenseContext = 1; // Shallow Flags: + // ForceSuspenseFallback can be used by SuspenseList to force newly added + // items into their fallback state during one of the render passes. + + var ForceSuspenseFallback = 2; + var suspenseStackCursor = createCursor(DefaultSuspenseContext); + function hasSuspenseContext(parentContext, flag) { + return (parentContext & flag) !== 0; + } + function setDefaultShallowSuspenseContext(parentContext) { + return parentContext & SubtreeSuspenseContextMask; + } + function setShallowSuspenseContext(parentContext, shallowContext) { + return parentContext & SubtreeSuspenseContextMask | shallowContext; + } + function addSubtreeSuspenseContext(parentContext, subtreeContext) { + return parentContext | subtreeContext; + } + function pushSuspenseContext(fiber, newContext) { + push(suspenseStackCursor, newContext, fiber); + } + function popSuspenseContext(fiber) { + pop(suspenseStackCursor, fiber); + } + + function shouldCaptureSuspense(workInProgress, hasInvisibleParent) { + // If it was the primary children that just suspended, capture and render the + // fallback. Otherwise, don't capture and bubble to the next boundary. + var nextState = workInProgress.memoizedState; + + if (nextState !== null) { + if (nextState.dehydrated !== null) { + // A dehydrated boundary always captures. + return true; + } + + return false; + } + + var props = workInProgress.memoizedProps; // In order to capture, the Suspense component must have a fallback prop. + + if (props.fallback === undefined) { + return false; + } // Regular boundaries always capture. + + + if (props.unstable_avoidThisFallback !== true) { + return true; + } // If it's a boundary we should avoid, then we prefer to bubble up to the + // parent boundary if it is currently invisible. + + + if (hasInvisibleParent) { + return false; + } // If the parent is not able to handle it, we must handle it. + + + return true; + } + function findFirstSuspended(row) { + var node = row; + + while (node !== null) { + if (node.tag === SuspenseComponent) { + var state = node.memoizedState; + + if (state !== null) { + var dehydrated = state.dehydrated; + + if (dehydrated === null || isSuspenseInstancePending(dehydrated) || isSuspenseInstanceFallback(dehydrated)) { + return node; + } + } + } else if (node.tag === SuspenseListComponent && // revealOrder undefined can't be trusted because it don't + // keep track of whether it suspended or not. + node.memoizedProps.revealOrder !== undefined) { + var didSuspend = (node.flags & DidCapture) !== NoFlags; + + if (didSuspend) { + return node; + } + } else if (node.child !== null) { + node.child.return = node; + node = node.child; + continue; + } + + if (node === row) { + return null; + } + + while (node.sibling === null) { + if (node.return === null || node.return === row) { + return null; + } + + node = node.return; + } + + node.sibling.return = node.return; + node = node.sibling; + } + + return null; + } + + var NoFlags$1 = + /* */ + 0; // Represents whether effect should fire. + + var HasEffect = + /* */ + 1; // Represents the phase in which the effect (not the clean-up) fires. + + var Layout = + /* */ + 2; + var Passive$1 = + /* */ + 4; + + // This may have been an insertion or a hydration. + + var hydrationParentFiber = null; + var nextHydratableInstance = null; + var isHydrating = false; + + function enterHydrationState(fiber) { + + var parentInstance = fiber.stateNode.containerInfo; + nextHydratableInstance = getFirstHydratableChild(parentInstance); + hydrationParentFiber = fiber; + isHydrating = true; + return true; + } + + function deleteHydratableInstance(returnFiber, instance) { + { + switch (returnFiber.tag) { + case HostRoot: + didNotHydrateContainerInstance(returnFiber.stateNode.containerInfo, instance); + break; + + case HostComponent: + didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance); + break; + } + } + + var childToDelete = createFiberFromHostInstanceForDeletion(); + childToDelete.stateNode = instance; + childToDelete.return = returnFiber; + childToDelete.flags = Deletion; // This might seem like it belongs on progressedFirstDeletion. However, + // these children are not part of the reconciliation list of children. + // Even if we abort and rereconcile the children, that will try to hydrate + // again and the nodes are still in the host tree so these will be + // recreated. + + if (returnFiber.lastEffect !== null) { + returnFiber.lastEffect.nextEffect = childToDelete; + returnFiber.lastEffect = childToDelete; + } else { + returnFiber.firstEffect = returnFiber.lastEffect = childToDelete; + } + } + + function insertNonHydratedInstance(returnFiber, fiber) { + fiber.flags = fiber.flags & ~Hydrating | Placement; + + { + switch (returnFiber.tag) { + case HostRoot: + { + var parentContainer = returnFiber.stateNode.containerInfo; + + switch (fiber.tag) { + case HostComponent: + var type = fiber.type; + var props = fiber.pendingProps; + didNotFindHydratableContainerInstance(parentContainer, type); + break; + + case HostText: + var text = fiber.pendingProps; + didNotFindHydratableContainerTextInstance(parentContainer, text); + break; + } + + break; + } + + case HostComponent: + { + var parentType = returnFiber.type; + var parentProps = returnFiber.memoizedProps; + var parentInstance = returnFiber.stateNode; + + switch (fiber.tag) { + case HostComponent: + var _type = fiber.type; + var _props = fiber.pendingProps; + didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type); + break; + + case HostText: + var _text = fiber.pendingProps; + didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text); + break; + + case SuspenseComponent: + didNotFindHydratableSuspenseInstance(parentType, parentProps); + break; + } + + break; + } + + default: + return; + } + } + } + + function tryHydrate(fiber, nextInstance) { + switch (fiber.tag) { + case HostComponent: + { + var type = fiber.type; + var props = fiber.pendingProps; + var instance = canHydrateInstance(nextInstance, type); + + if (instance !== null) { + fiber.stateNode = instance; + return true; + } + + return false; + } + + case HostText: + { + var text = fiber.pendingProps; + var textInstance = canHydrateTextInstance(nextInstance, text); + + if (textInstance !== null) { + fiber.stateNode = textInstance; + return true; + } + + return false; + } + + case SuspenseComponent: + { + + return false; + } + + default: + return false; + } + } + + function tryToClaimNextHydratableInstance(fiber) { + if (!isHydrating) { + return; + } + + var nextInstance = nextHydratableInstance; + + if (!nextInstance) { + // Nothing to hydrate. Make it an insertion. + insertNonHydratedInstance(hydrationParentFiber, fiber); + isHydrating = false; + hydrationParentFiber = fiber; + return; + } + + var firstAttemptedInstance = nextInstance; + + if (!tryHydrate(fiber, nextInstance)) { + // If we can't hydrate this instance let's try the next one. + // We use this as a heuristic. It's based on intuition and not data so it + // might be flawed or unnecessary. + nextInstance = getNextHydratableSibling(firstAttemptedInstance); + + if (!nextInstance || !tryHydrate(fiber, nextInstance)) { + // Nothing to hydrate. Make it an insertion. + insertNonHydratedInstance(hydrationParentFiber, fiber); + isHydrating = false; + hydrationParentFiber = fiber; + return; + } // We matched the next one, we'll now assume that the first one was + // superfluous and we'll delete it. Since we can't eagerly delete it + // we'll have to schedule a deletion. To do that, this node needs a dummy + // fiber associated with it. + + + deleteHydratableInstance(hydrationParentFiber, firstAttemptedInstance); + } + + hydrationParentFiber = fiber; + nextHydratableInstance = getFirstHydratableChild(nextInstance); + } + + function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) { + + var instance = fiber.stateNode; + var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber); // TODO: Type this specific to this type of component. + + fiber.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there + // is a new ref we mark this as an update. + + if (updatePayload !== null) { + return true; + } + + return false; + } + + function prepareToHydrateHostTextInstance(fiber) { + + var textInstance = fiber.stateNode; + var textContent = fiber.memoizedProps; + var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber); + + { + if (shouldUpdate) { + // We assume that prepareToHydrateHostTextInstance is called in a context where the + // hydration parent is the parent host component of this host text. + var returnFiber = hydrationParentFiber; + + if (returnFiber !== null) { + switch (returnFiber.tag) { + case HostRoot: + { + var parentContainer = returnFiber.stateNode.containerInfo; + didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent); + break; + } + + case HostComponent: + { + var parentType = returnFiber.type; + var parentProps = returnFiber.memoizedProps; + var parentInstance = returnFiber.stateNode; + didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent); + break; + } + } + } + } + } + + return shouldUpdate; + } + + function skipPastDehydratedSuspenseInstance(fiber) { + + var suspenseState = fiber.memoizedState; + var suspenseInstance = suspenseState !== null ? suspenseState.dehydrated : null; + + if (!suspenseInstance) { + { + throw Error( "Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue." ); + } + } + + return getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance); + } + + function popToNextHostParent(fiber) { + var parent = fiber.return; + + while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== SuspenseComponent) { + parent = parent.return; + } + + hydrationParentFiber = parent; + } + + function popHydrationState(fiber) { + + if (fiber !== hydrationParentFiber) { + // We're deeper than the current hydration context, inside an inserted + // tree. + return false; + } + + if (!isHydrating) { + // If we're not currently hydrating but we're in a hydration context, then + // we were an insertion and now need to pop up reenter hydration of our + // siblings. + popToNextHostParent(fiber); + isHydrating = true; + return false; + } + + var type = fiber.type; // If we have any remaining hydratable nodes, we need to delete them now. + // We only do this deeper than head and body since they tend to have random + // other nodes in them. We also ignore components with pure text content in + // side of them. + // TODO: Better heuristic. + + if (fiber.tag !== HostComponent || type !== 'head' && type !== 'body' && !shouldSetTextContent(type, fiber.memoizedProps)) { + var nextInstance = nextHydratableInstance; + + while (nextInstance) { + deleteHydratableInstance(fiber, nextInstance); + nextInstance = getNextHydratableSibling(nextInstance); + } + } + + popToNextHostParent(fiber); + + if (fiber.tag === SuspenseComponent) { + nextHydratableInstance = skipPastDehydratedSuspenseInstance(fiber); + } else { + nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null; + } + + return true; + } + + function resetHydrationState() { + + hydrationParentFiber = null; + nextHydratableInstance = null; + isHydrating = false; + } + + function getIsHydrating() { + return isHydrating; + } + + // and should be reset before starting a new render. + // This tracks which mutable sources need to be reset after a render. + + var workInProgressSources = []; + var rendererSigil$1; + + { + // Used to detect multiple renderers using the same mutable source. + rendererSigil$1 = {}; + } + + function markSourceAsDirty(mutableSource) { + workInProgressSources.push(mutableSource); + } + function resetWorkInProgressVersions() { + for (var i = 0; i < workInProgressSources.length; i++) { + var mutableSource = workInProgressSources[i]; + + { + mutableSource._workInProgressVersionPrimary = null; + } + } + + workInProgressSources.length = 0; + } + function getWorkInProgressVersion(mutableSource) { + { + return mutableSource._workInProgressVersionPrimary; + } + } + function setWorkInProgressVersion(mutableSource, version) { + { + mutableSource._workInProgressVersionPrimary = version; + } + + workInProgressSources.push(mutableSource); + } + function warnAboutMultipleRenderersDEV(mutableSource) { + { + { + if (mutableSource._currentPrimaryRenderer == null) { + mutableSource._currentPrimaryRenderer = rendererSigil$1; + } else if (mutableSource._currentPrimaryRenderer !== rendererSigil$1) { + error('Detected multiple renderers concurrently rendering the ' + 'same mutable source. This is currently unsupported.'); + } + } + } + } // Eager reads the version of a mutable source and stores it on the root. + + var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig; + var didWarnAboutMismatchedHooksForComponent; + var didWarnAboutUseOpaqueIdentifier; + + { + didWarnAboutUseOpaqueIdentifier = {}; + didWarnAboutMismatchedHooksForComponent = new Set(); + } + + // These are set right before calling the component. + var renderLanes = NoLanes; // The work-in-progress fiber. I've named it differently to distinguish it from + // the work-in-progress hook. + + var currentlyRenderingFiber$1 = null; // Hooks are stored as a linked list on the fiber's memoizedState field. The + // current hook list is the list that belongs to the current fiber. The + // work-in-progress hook list is a new list that will be added to the + // work-in-progress fiber. + + var currentHook = null; + var workInProgressHook = null; // Whether an update was scheduled at any point during the render phase. This + // does not get reset if we do another render pass; only when we're completely + // finished evaluating this component. This is an optimization so we know + // whether we need to clear render phase updates after a throw. + + var didScheduleRenderPhaseUpdate = false; // Where an update was scheduled only during the current render pass. This + // gets reset after each attempt. + // TODO: Maybe there's some way to consolidate this with + // `didScheduleRenderPhaseUpdate`. Or with `numberOfReRenders`. + + var didScheduleRenderPhaseUpdateDuringThisPass = false; + var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook + + var currentHookNameInDev = null; // In DEV, this list ensures that hooks are called in the same order between renders. + // The list stores the order of hooks used during the initial render (mount). + // Subsequent renders (updates) reference this list. + + var hookTypesDev = null; + var hookTypesUpdateIndexDev = -1; // In DEV, this tracks whether currently rendering component needs to ignore + // the dependencies for Hooks that need them (e.g. useEffect or useMemo). + // When true, such Hooks will always be "remounted". Only used during hot reload. + + var ignorePreviousDependencies = false; + + function mountHookTypesDev() { + { + var hookName = currentHookNameInDev; + + if (hookTypesDev === null) { + hookTypesDev = [hookName]; + } else { + hookTypesDev.push(hookName); + } + } + } + + function updateHookTypesDev() { + { + var hookName = currentHookNameInDev; + + if (hookTypesDev !== null) { + hookTypesUpdateIndexDev++; + + if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) { + warnOnHookMismatchInDev(hookName); + } + } + } + } + + function checkDepsAreArrayDev(deps) { + { + if (deps !== undefined && deps !== null && !Array.isArray(deps)) { + // Verify deps, but only on mount to avoid extra checks. + // It's unlikely their type would change as usually you define them inline. + error('%s received a final argument that is not an array (instead, received `%s`). When ' + 'specified, the final argument must be an array.', currentHookNameInDev, typeof deps); + } + } + } + + function warnOnHookMismatchInDev(currentHookName) { + { + var componentName = getComponentName(currentlyRenderingFiber$1.type); + + if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) { + didWarnAboutMismatchedHooksForComponent.add(componentName); + + if (hookTypesDev !== null) { + var table = ''; + var secondColumnStart = 30; + + for (var i = 0; i <= hookTypesUpdateIndexDev; i++) { + var oldHookName = hookTypesDev[i]; + var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName; + var row = i + 1 + ". " + oldHookName; // Extra space so second column lines up + // lol @ IE not supporting String#repeat + + while (row.length < secondColumnStart) { + row += ' '; + } + + row += newHookName + '\n'; + table += row; + } + + error('React has detected a change in the order of Hooks called by %s. ' + 'This will lead to bugs and errors if not fixed. ' + 'For more information, read the Rules of Hooks: https://reactjs.org/link/rules-of-hooks\n\n' + ' Previous render Next render\n' + ' ------------------------------------------------------\n' + '%s' + ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', componentName, table); + } + } + } + } + + function throwInvalidHookError() { + { + { + throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." ); + } + } + } + + function areHookInputsEqual(nextDeps, prevDeps) { + { + if (ignorePreviousDependencies) { + // Only true when this component is being hot reloaded. + return false; + } + } + + if (prevDeps === null) { + { + error('%s received a final argument during this render, but not during ' + 'the previous render. Even though the final argument is optional, ' + 'its type cannot change between renders.', currentHookNameInDev); + } + + return false; + } + + { + // Don't bother comparing lengths in prod because these arrays should be + // passed inline. + if (nextDeps.length !== prevDeps.length) { + error('The final argument passed to %s changed size between renders. The ' + 'order and size of this array must remain constant.\n\n' + 'Previous: %s\n' + 'Incoming: %s', currentHookNameInDev, "[" + prevDeps.join(', ') + "]", "[" + nextDeps.join(', ') + "]"); + } + } + + for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) { + if (objectIs(nextDeps[i], prevDeps[i])) { + continue; + } + + return false; + } + + return true; + } + + function renderWithHooks(current, workInProgress, Component, props, secondArg, nextRenderLanes) { + renderLanes = nextRenderLanes; + currentlyRenderingFiber$1 = workInProgress; + + { + hookTypesDev = current !== null ? current._debugHookTypes : null; + hookTypesUpdateIndexDev = -1; // Used for hot reloading: + + ignorePreviousDependencies = current !== null && current.type !== workInProgress.type; + } + + workInProgress.memoizedState = null; + workInProgress.updateQueue = null; + workInProgress.lanes = NoLanes; // The following should have already been reset + // currentHook = null; + // workInProgressHook = null; + // didScheduleRenderPhaseUpdate = false; + // TODO Warn if no hooks are used at all during mount, then some are used during update. + // Currently we will identify the update render as a mount because memoizedState === null. + // This is tricky because it's valid for certain types of components (e.g. React.lazy) + // Using memoizedState to differentiate between mount/update only works if at least one stateful hook is used. + // Non-stateful hooks (e.g. context) don't get added to memoizedState, + // so memoizedState would be null during updates and mounts. + + { + if (current !== null && current.memoizedState !== null) { + ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; + } else if (hookTypesDev !== null) { + // This dispatcher handles an edge case where a component is updating, + // but no stateful hooks have been used. + // We want to match the production code behavior (which will use HooksDispatcherOnMount), + // but with the extra DEV validation to ensure hooks ordering hasn't changed. + // This dispatcher does that. + ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV; + } else { + ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV; + } + } + + var children = Component(props, secondArg); // Check if there was a render phase update + + if (didScheduleRenderPhaseUpdateDuringThisPass) { + // Keep rendering in a loop for as long as render phase updates continue to + // be scheduled. Use a counter to prevent infinite loops. + var numberOfReRenders = 0; + + do { + didScheduleRenderPhaseUpdateDuringThisPass = false; + + if (!(numberOfReRenders < RE_RENDER_LIMIT)) { + { + throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." ); + } + } + + numberOfReRenders += 1; + + { + // Even when hot reloading, allow dependencies to stabilize + // after first render to prevent infinite render phase updates. + ignorePreviousDependencies = false; + } // Start over from the beginning of the list + + + currentHook = null; + workInProgressHook = null; + workInProgress.updateQueue = null; + + { + // Also validate hook order for cascading updates. + hookTypesUpdateIndexDev = -1; + } + + ReactCurrentDispatcher$1.current = HooksDispatcherOnRerenderInDEV ; + children = Component(props, secondArg); + } while (didScheduleRenderPhaseUpdateDuringThisPass); + } // We can assume the previous dispatcher is always this one, since we set it + // at the beginning of the render phase and there's no re-entrancy. + + + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + + { + workInProgress._debugHookTypes = hookTypesDev; + } // This check uses currentHook so that it works the same in DEV and prod bundles. + // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles. + + + var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null; + renderLanes = NoLanes; + currentlyRenderingFiber$1 = null; + currentHook = null; + workInProgressHook = null; + + { + currentHookNameInDev = null; + hookTypesDev = null; + hookTypesUpdateIndexDev = -1; + } + + didScheduleRenderPhaseUpdate = false; + + if (!!didRenderTooFewHooks) { + { + throw Error( "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." ); + } + } + + return children; + } + function bailoutHooks(current, workInProgress, lanes) { + workInProgress.updateQueue = current.updateQueue; + workInProgress.flags &= ~(Passive | Update); + current.lanes = removeLanes(current.lanes, lanes); + } + function resetHooksAfterThrow() { + // We can assume the previous dispatcher is always this one, since we set it + // at the beginning of the render phase and there's no re-entrancy. + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + + if (didScheduleRenderPhaseUpdate) { + // There were render phase updates. These are only valid for this render + // phase, which we are now aborting. Remove the updates from the queues so + // they do not persist to the next render. Do not remove updates from hooks + // that weren't processed. + // + // Only reset the updates from the queue if it has a clone. If it does + // not have a clone, that means it wasn't processed, and the updates were + // scheduled before we entered the render phase. + var hook = currentlyRenderingFiber$1.memoizedState; + + while (hook !== null) { + var queue = hook.queue; + + if (queue !== null) { + queue.pending = null; + } + + hook = hook.next; + } + + didScheduleRenderPhaseUpdate = false; + } + + renderLanes = NoLanes; + currentlyRenderingFiber$1 = null; + currentHook = null; + workInProgressHook = null; + + { + hookTypesDev = null; + hookTypesUpdateIndexDev = -1; + currentHookNameInDev = null; + isUpdatingOpaqueValueInRenderPhase = false; + } + + didScheduleRenderPhaseUpdateDuringThisPass = false; + } + + function mountWorkInProgressHook() { + var hook = { + memoizedState: null, + baseState: null, + baseQueue: null, + queue: null, + next: null + }; + + if (workInProgressHook === null) { + // This is the first hook in the list + currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook; + } else { + // Append to the end of the list + workInProgressHook = workInProgressHook.next = hook; + } + + return workInProgressHook; + } + + function updateWorkInProgressHook() { + // This function is used both for updates and for re-renders triggered by a + // render phase update. It assumes there is either a current hook we can + // clone, or a work-in-progress hook from a previous render pass that we can + // use as a base. When we reach the end of the base list, we must switch to + // the dispatcher used for mounts. + var nextCurrentHook; + + if (currentHook === null) { + var current = currentlyRenderingFiber$1.alternate; + + if (current !== null) { + nextCurrentHook = current.memoizedState; + } else { + nextCurrentHook = null; + } + } else { + nextCurrentHook = currentHook.next; + } + + var nextWorkInProgressHook; + + if (workInProgressHook === null) { + nextWorkInProgressHook = currentlyRenderingFiber$1.memoizedState; + } else { + nextWorkInProgressHook = workInProgressHook.next; + } + + if (nextWorkInProgressHook !== null) { + // There's already a work-in-progress. Reuse it. + workInProgressHook = nextWorkInProgressHook; + nextWorkInProgressHook = workInProgressHook.next; + currentHook = nextCurrentHook; + } else { + // Clone from the current hook. + if (!(nextCurrentHook !== null)) { + { + throw Error( "Rendered more hooks than during the previous render." ); + } + } + + currentHook = nextCurrentHook; + var newHook = { + memoizedState: currentHook.memoizedState, + baseState: currentHook.baseState, + baseQueue: currentHook.baseQueue, + queue: currentHook.queue, + next: null + }; + + if (workInProgressHook === null) { + // This is the first hook in the list. + currentlyRenderingFiber$1.memoizedState = workInProgressHook = newHook; + } else { + // Append to the end of the list. + workInProgressHook = workInProgressHook.next = newHook; + } + } + + return workInProgressHook; + } + + function createFunctionComponentUpdateQueue() { + return { + lastEffect: null + }; + } + + function basicStateReducer(state, action) { + // $FlowFixMe: Flow doesn't like mixed types + return typeof action === 'function' ? action(state) : action; + } + + function mountReducer(reducer, initialArg, init) { + var hook = mountWorkInProgressHook(); + var initialState; + + if (init !== undefined) { + initialState = init(initialArg); + } else { + initialState = initialArg; + } + + hook.memoizedState = hook.baseState = initialState; + var queue = hook.queue = { + pending: null, + dispatch: null, + lastRenderedReducer: reducer, + lastRenderedState: initialState + }; + var dispatch = queue.dispatch = dispatchAction.bind(null, currentlyRenderingFiber$1, queue); + return [hook.memoizedState, dispatch]; + } + + function updateReducer(reducer, initialArg, init) { + var hook = updateWorkInProgressHook(); + var queue = hook.queue; + + if (!(queue !== null)) { + { + throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." ); + } + } + + queue.lastRenderedReducer = reducer; + var current = currentHook; // The last rebase update that is NOT part of the base state. + + var baseQueue = current.baseQueue; // The last pending update that hasn't been processed yet. + + var pendingQueue = queue.pending; + + if (pendingQueue !== null) { + // We have new updates that haven't been processed yet. + // We'll add them to the base queue. + if (baseQueue !== null) { + // Merge the pending queue and the base queue. + var baseFirst = baseQueue.next; + var pendingFirst = pendingQueue.next; + baseQueue.next = pendingFirst; + pendingQueue.next = baseFirst; + } + + { + if (current.baseQueue !== baseQueue) { + // Internal invariant that should never happen, but feasibly could in + // the future if we implement resuming, or some form of that. + error('Internal error: Expected work-in-progress queue to be a clone. ' + 'This is a bug in React.'); + } + } + + current.baseQueue = baseQueue = pendingQueue; + queue.pending = null; + } + + if (baseQueue !== null) { + // We have a queue to process. + var first = baseQueue.next; + var newState = current.baseState; + var newBaseState = null; + var newBaseQueueFirst = null; + var newBaseQueueLast = null; + var update = first; + + do { + var updateLane = update.lane; + + if (!isSubsetOfLanes(renderLanes, updateLane)) { + // Priority is insufficient. Skip this update. If this is the first + // skipped update, the previous update/state is the new base + // update/state. + var clone = { + lane: updateLane, + action: update.action, + eagerReducer: update.eagerReducer, + eagerState: update.eagerState, + next: null + }; + + if (newBaseQueueLast === null) { + newBaseQueueFirst = newBaseQueueLast = clone; + newBaseState = newState; + } else { + newBaseQueueLast = newBaseQueueLast.next = clone; + } // Update the remaining priority in the queue. + // TODO: Don't need to accumulate this. Instead, we can remove + // renderLanes from the original lanes. + + + currentlyRenderingFiber$1.lanes = mergeLanes(currentlyRenderingFiber$1.lanes, updateLane); + markSkippedUpdateLanes(updateLane); + } else { + // This update does have sufficient priority. + if (newBaseQueueLast !== null) { + var _clone = { + // This update is going to be committed so we never want uncommit + // it. Using NoLane works because 0 is a subset of all bitmasks, so + // this will never be skipped by the check above. + lane: NoLane, + action: update.action, + eagerReducer: update.eagerReducer, + eagerState: update.eagerState, + next: null + }; + newBaseQueueLast = newBaseQueueLast.next = _clone; + } // Process this update. + + + if (update.eagerReducer === reducer) { + // If this update was processed eagerly, and its reducer matches the + // current reducer, we can use the eagerly computed state. + newState = update.eagerState; + } else { + var action = update.action; + newState = reducer(newState, action); + } + } + + update = update.next; + } while (update !== null && update !== first); + + if (newBaseQueueLast === null) { + newBaseState = newState; + } else { + newBaseQueueLast.next = newBaseQueueFirst; + } // Mark that the fiber performed work, but only if the new state is + // different from the current state. + + + if (!objectIs(newState, hook.memoizedState)) { + markWorkInProgressReceivedUpdate(); + } + + hook.memoizedState = newState; + hook.baseState = newBaseState; + hook.baseQueue = newBaseQueueLast; + queue.lastRenderedState = newState; + } + + var dispatch = queue.dispatch; + return [hook.memoizedState, dispatch]; + } + + function rerenderReducer(reducer, initialArg, init) { + var hook = updateWorkInProgressHook(); + var queue = hook.queue; + + if (!(queue !== null)) { + { + throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." ); + } + } + + queue.lastRenderedReducer = reducer; // This is a re-render. Apply the new render phase updates to the previous + // work-in-progress hook. + + var dispatch = queue.dispatch; + var lastRenderPhaseUpdate = queue.pending; + var newState = hook.memoizedState; + + if (lastRenderPhaseUpdate !== null) { + // The queue doesn't persist past this render pass. + queue.pending = null; + var firstRenderPhaseUpdate = lastRenderPhaseUpdate.next; + var update = firstRenderPhaseUpdate; + + do { + // Process this render phase update. We don't have to check the + // priority because it will always be the same as the current + // render's. + var action = update.action; + newState = reducer(newState, action); + update = update.next; + } while (update !== firstRenderPhaseUpdate); // Mark that the fiber performed work, but only if the new state is + // different from the current state. + + + if (!objectIs(newState, hook.memoizedState)) { + markWorkInProgressReceivedUpdate(); + } + + hook.memoizedState = newState; // Don't persist the state accumulated from the render phase updates to + // the base state unless the queue is empty. + // TODO: Not sure if this is the desired semantics, but it's what we + // do for gDSFP. I can't remember why. + + if (hook.baseQueue === null) { + hook.baseState = newState; + } + + queue.lastRenderedState = newState; + } + + return [newState, dispatch]; + } + + function readFromUnsubcribedMutableSource(root, source, getSnapshot) { + { + warnAboutMultipleRenderersDEV(source); + } + + var getVersion = source._getVersion; + var version = getVersion(source._source); // Is it safe for this component to read from this source during the current render? + + var isSafeToReadFromSource = false; // Check the version first. + // If this render has already been started with a specific version, + // we can use it alone to determine if we can safely read from the source. + + var currentRenderVersion = getWorkInProgressVersion(source); + + if (currentRenderVersion !== null) { + // It's safe to read if the store hasn't been mutated since the last time + // we read something. + isSafeToReadFromSource = currentRenderVersion === version; + } else { + // If there's no version, then this is the first time we've read from the + // source during the current render pass, so we need to do a bit more work. + // What we need to determine is if there are any hooks that already + // subscribed to the source, and if so, whether there are any pending + // mutations that haven't been synchronized yet. + // + // If there are no pending mutations, then `root.mutableReadLanes` will be + // empty, and we know we can safely read. + // + // If there *are* pending mutations, we may still be able to safely read + // if the currently rendering lanes are inclusive of the pending mutation + // lanes, since that guarantees that the value we're about to read from + // the source is consistent with the values that we read during the most + // recent mutation. + isSafeToReadFromSource = isSubsetOfLanes(renderLanes, root.mutableReadLanes); + + if (isSafeToReadFromSource) { + // If it's safe to read from this source during the current render, + // store the version in case other components read from it. + // A changed version number will let those components know to throw and restart the render. + setWorkInProgressVersion(source, version); + } + } + + if (isSafeToReadFromSource) { + var snapshot = getSnapshot(source._source); + + { + if (typeof snapshot === 'function') { + error('Mutable source should not return a function as the snapshot value. ' + 'Functions may close over mutable values and cause tearing.'); + } + } + + return snapshot; + } else { + // This handles the special case of a mutable source being shared between renderers. + // In that case, if the source is mutated between the first and second renderer, + // The second renderer don't know that it needs to reset the WIP version during unwind, + // (because the hook only marks sources as dirty if it's written to their WIP version). + // That would cause this tear check to throw again and eventually be visible to the user. + // We can avoid this infinite loop by explicitly marking the source as dirty. + // + // This can lead to tearing in the first renderer when it resumes, + // but there's nothing we can do about that (short of throwing here and refusing to continue the render). + markSourceAsDirty(source); + + { + { + throw Error( "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue." ); + } + } + } + } + + function useMutableSource(hook, source, getSnapshot, subscribe) { + var root = getWorkInProgressRoot(); + + if (!(root !== null)) { + { + throw Error( "Expected a work-in-progress root. This is a bug in React. Please file an issue." ); + } + } + + var getVersion = source._getVersion; + var version = getVersion(source._source); + var dispatcher = ReactCurrentDispatcher$1.current; // eslint-disable-next-line prefer-const + + var _dispatcher$useState = dispatcher.useState(function () { + return readFromUnsubcribedMutableSource(root, source, getSnapshot); + }), + currentSnapshot = _dispatcher$useState[0], + setSnapshot = _dispatcher$useState[1]; + + var snapshot = currentSnapshot; // Grab a handle to the state hook as well. + // We use it to clear the pending update queue if we have a new source. + + var stateHook = workInProgressHook; + var memoizedState = hook.memoizedState; + var refs = memoizedState.refs; + var prevGetSnapshot = refs.getSnapshot; + var prevSource = memoizedState.source; + var prevSubscribe = memoizedState.subscribe; + var fiber = currentlyRenderingFiber$1; + hook.memoizedState = { + refs: refs, + source: source, + subscribe: subscribe + }; // Sync the values needed by our subscription handler after each commit. + + dispatcher.useEffect(function () { + refs.getSnapshot = getSnapshot; // Normally the dispatch function for a state hook never changes, + // but this hook recreates the queue in certain cases to avoid updates from stale sources. + // handleChange() below needs to reference the dispatch function without re-subscribing, + // so we use a ref to ensure that it always has the latest version. + + refs.setSnapshot = setSnapshot; // Check for a possible change between when we last rendered now. + + var maybeNewVersion = getVersion(source._source); + + if (!objectIs(version, maybeNewVersion)) { + var maybeNewSnapshot = getSnapshot(source._source); + + { + if (typeof maybeNewSnapshot === 'function') { + error('Mutable source should not return a function as the snapshot value. ' + 'Functions may close over mutable values and cause tearing.'); + } + } + + if (!objectIs(snapshot, maybeNewSnapshot)) { + setSnapshot(maybeNewSnapshot); + var lane = requestUpdateLane(fiber); + markRootMutableRead(root, lane); + } // If the source mutated between render and now, + // there may be state updates already scheduled from the old source. + // Entangle the updates so that they render in the same batch. + + + markRootEntangled(root, root.mutableReadLanes); + } + }, [getSnapshot, source, subscribe]); // If we got a new source or subscribe function, re-subscribe in a passive effect. + + dispatcher.useEffect(function () { + var handleChange = function () { + var latestGetSnapshot = refs.getSnapshot; + var latestSetSnapshot = refs.setSnapshot; + + try { + latestSetSnapshot(latestGetSnapshot(source._source)); // Record a pending mutable source update with the same expiration time. + + var lane = requestUpdateLane(fiber); + markRootMutableRead(root, lane); + } catch (error) { + // A selector might throw after a source mutation. + // e.g. it might try to read from a part of the store that no longer exists. + // In this case we should still schedule an update with React. + // Worst case the selector will throw again and then an error boundary will handle it. + latestSetSnapshot(function () { + throw error; + }); + } + }; + + var unsubscribe = subscribe(source._source, handleChange); + + { + if (typeof unsubscribe !== 'function') { + error('Mutable source subscribe function must return an unsubscribe function.'); + } + } + + return unsubscribe; + }, [source, subscribe]); // If any of the inputs to useMutableSource change, reading is potentially unsafe. + // + // If either the source or the subscription have changed we can't can't trust the update queue. + // Maybe the source changed in a way that the old subscription ignored but the new one depends on. + // + // If the getSnapshot function changed, we also shouldn't rely on the update queue. + // It's possible that the underlying source was mutated between the when the last "change" event fired, + // and when the current render (with the new getSnapshot function) is processed. + // + // In both cases, we need to throw away pending updates (since they are no longer relevant) + // and treat reading from the source as we do in the mount case. + + if (!objectIs(prevGetSnapshot, getSnapshot) || !objectIs(prevSource, source) || !objectIs(prevSubscribe, subscribe)) { + // Create a new queue and setState method, + // So if there are interleaved updates, they get pushed to the older queue. + // When this becomes current, the previous queue and dispatch method will be discarded, + // including any interleaving updates that occur. + var newQueue = { + pending: null, + dispatch: null, + lastRenderedReducer: basicStateReducer, + lastRenderedState: snapshot + }; + newQueue.dispatch = setSnapshot = dispatchAction.bind(null, currentlyRenderingFiber$1, newQueue); + stateHook.queue = newQueue; + stateHook.baseQueue = null; + snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot); + stateHook.memoizedState = stateHook.baseState = snapshot; + } + + return snapshot; + } + + function mountMutableSource(source, getSnapshot, subscribe) { + var hook = mountWorkInProgressHook(); + hook.memoizedState = { + refs: { + getSnapshot: getSnapshot, + setSnapshot: null + }, + source: source, + subscribe: subscribe + }; + return useMutableSource(hook, source, getSnapshot, subscribe); + } + + function updateMutableSource(source, getSnapshot, subscribe) { + var hook = updateWorkInProgressHook(); + return useMutableSource(hook, source, getSnapshot, subscribe); + } + + function mountState(initialState) { + var hook = mountWorkInProgressHook(); + + if (typeof initialState === 'function') { + // $FlowFixMe: Flow doesn't like mixed types + initialState = initialState(); + } + + hook.memoizedState = hook.baseState = initialState; + var queue = hook.queue = { + pending: null, + dispatch: null, + lastRenderedReducer: basicStateReducer, + lastRenderedState: initialState + }; + var dispatch = queue.dispatch = dispatchAction.bind(null, currentlyRenderingFiber$1, queue); + return [hook.memoizedState, dispatch]; + } + + function updateState(initialState) { + return updateReducer(basicStateReducer); + } + + function rerenderState(initialState) { + return rerenderReducer(basicStateReducer); + } + + function pushEffect(tag, create, destroy, deps) { + var effect = { + tag: tag, + create: create, + destroy: destroy, + deps: deps, + // Circular + next: null + }; + var componentUpdateQueue = currentlyRenderingFiber$1.updateQueue; + + if (componentUpdateQueue === null) { + componentUpdateQueue = createFunctionComponentUpdateQueue(); + currentlyRenderingFiber$1.updateQueue = componentUpdateQueue; + componentUpdateQueue.lastEffect = effect.next = effect; + } else { + var lastEffect = componentUpdateQueue.lastEffect; + + if (lastEffect === null) { + componentUpdateQueue.lastEffect = effect.next = effect; + } else { + var firstEffect = lastEffect.next; + lastEffect.next = effect; + effect.next = firstEffect; + componentUpdateQueue.lastEffect = effect; + } + } + + return effect; + } + + function mountRef(initialValue) { + var hook = mountWorkInProgressHook(); + var ref = { + current: initialValue + }; + + { + Object.seal(ref); + } + + hook.memoizedState = ref; + return ref; + } + + function updateRef(initialValue) { + var hook = updateWorkInProgressHook(); + return hook.memoizedState; + } + + function mountEffectImpl(fiberFlags, hookFlags, create, deps) { + var hook = mountWorkInProgressHook(); + var nextDeps = deps === undefined ? null : deps; + currentlyRenderingFiber$1.flags |= fiberFlags; + hook.memoizedState = pushEffect(HasEffect | hookFlags, create, undefined, nextDeps); + } + + function updateEffectImpl(fiberFlags, hookFlags, create, deps) { + var hook = updateWorkInProgressHook(); + var nextDeps = deps === undefined ? null : deps; + var destroy = undefined; + + if (currentHook !== null) { + var prevEffect = currentHook.memoizedState; + destroy = prevEffect.destroy; + + if (nextDeps !== null) { + var prevDeps = prevEffect.deps; + + if (areHookInputsEqual(nextDeps, prevDeps)) { + pushEffect(hookFlags, create, destroy, nextDeps); + return; + } + } + } + + currentlyRenderingFiber$1.flags |= fiberFlags; + hook.memoizedState = pushEffect(HasEffect | hookFlags, create, destroy, nextDeps); + } + + function mountEffect(create, deps) { + { + // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests + if ('undefined' !== typeof jest) { + warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1); + } + } + + return mountEffectImpl(Update | Passive, Passive$1, create, deps); + } + + function updateEffect(create, deps) { + { + // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests + if ('undefined' !== typeof jest) { + warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1); + } + } + + return updateEffectImpl(Update | Passive, Passive$1, create, deps); + } + + function mountLayoutEffect(create, deps) { + return mountEffectImpl(Update, Layout, create, deps); + } + + function updateLayoutEffect(create, deps) { + return updateEffectImpl(Update, Layout, create, deps); + } + + function imperativeHandleEffect(create, ref) { + if (typeof ref === 'function') { + var refCallback = ref; + + var _inst = create(); + + refCallback(_inst); + return function () { + refCallback(null); + }; + } else if (ref !== null && ref !== undefined) { + var refObject = ref; + + { + if (!refObject.hasOwnProperty('current')) { + error('Expected useImperativeHandle() first argument to either be a ' + 'ref callback or React.createRef() object. Instead received: %s.', 'an object with keys {' + Object.keys(refObject).join(', ') + '}'); + } + } + + var _inst2 = create(); + + refObject.current = _inst2; + return function () { + refObject.current = null; + }; + } + } + + function mountImperativeHandle(ref, create, deps) { + { + if (typeof create !== 'function') { + error('Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null'); + } + } // TODO: If deps are provided, should we skip comparing the ref itself? + + + var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null; + return mountEffectImpl(Update, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps); + } + + function updateImperativeHandle(ref, create, deps) { + { + if (typeof create !== 'function') { + error('Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null'); + } + } // TODO: If deps are provided, should we skip comparing the ref itself? + + + var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null; + return updateEffectImpl(Update, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps); + } + + function mountDebugValue(value, formatterFn) {// This hook is normally a no-op. + // The react-debug-hooks package injects its own implementation + // so that e.g. DevTools can display custom hook values. + } + + var updateDebugValue = mountDebugValue; + + function mountCallback(callback, deps) { + var hook = mountWorkInProgressHook(); + var nextDeps = deps === undefined ? null : deps; + hook.memoizedState = [callback, nextDeps]; + return callback; + } + + function updateCallback(callback, deps) { + var hook = updateWorkInProgressHook(); + var nextDeps = deps === undefined ? null : deps; + var prevState = hook.memoizedState; + + if (prevState !== null) { + if (nextDeps !== null) { + var prevDeps = prevState[1]; + + if (areHookInputsEqual(nextDeps, prevDeps)) { + return prevState[0]; + } + } + } + + hook.memoizedState = [callback, nextDeps]; + return callback; + } + + function mountMemo(nextCreate, deps) { + var hook = mountWorkInProgressHook(); + var nextDeps = deps === undefined ? null : deps; + var nextValue = nextCreate(); + hook.memoizedState = [nextValue, nextDeps]; + return nextValue; + } + + function updateMemo(nextCreate, deps) { + var hook = updateWorkInProgressHook(); + var nextDeps = deps === undefined ? null : deps; + var prevState = hook.memoizedState; + + if (prevState !== null) { + // Assume these are defined. If they're not, areHookInputsEqual will warn. + if (nextDeps !== null) { + var prevDeps = prevState[1]; + + if (areHookInputsEqual(nextDeps, prevDeps)) { + return prevState[0]; + } + } + } + + var nextValue = nextCreate(); + hook.memoizedState = [nextValue, nextDeps]; + return nextValue; + } + + function mountDeferredValue(value) { + var _mountState = mountState(value), + prevValue = _mountState[0], + setValue = _mountState[1]; + + mountEffect(function () { + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; + + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.transition = prevTransition; + } + }, [value]); + return prevValue; + } + + function updateDeferredValue(value) { + var _updateState = updateState(), + prevValue = _updateState[0], + setValue = _updateState[1]; + + updateEffect(function () { + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; + + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.transition = prevTransition; + } + }, [value]); + return prevValue; + } + + function rerenderDeferredValue(value) { + var _rerenderState = rerenderState(), + prevValue = _rerenderState[0], + setValue = _rerenderState[1]; + + updateEffect(function () { + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; + + try { + setValue(value); + } finally { + ReactCurrentBatchConfig$1.transition = prevTransition; + } + }, [value]); + return prevValue; + } + + function startTransition(setPending, callback) { + var priorityLevel = getCurrentPriorityLevel(); + + { + runWithPriority$1(priorityLevel < UserBlockingPriority$2 ? UserBlockingPriority$2 : priorityLevel, function () { + setPending(true); + }); + runWithPriority$1(priorityLevel > NormalPriority$1 ? NormalPriority$1 : priorityLevel, function () { + var prevTransition = ReactCurrentBatchConfig$1.transition; + ReactCurrentBatchConfig$1.transition = 1; + + try { + setPending(false); + callback(); + } finally { + ReactCurrentBatchConfig$1.transition = prevTransition; + } + }); + } + } + + function mountTransition() { + var _mountState2 = mountState(false), + isPending = _mountState2[0], + setPending = _mountState2[1]; // The `start` method can be stored on a ref, since `setPending` + // never changes. + + + var start = startTransition.bind(null, setPending); + mountRef(start); + return [start, isPending]; + } + + function updateTransition() { + var _updateState2 = updateState(), + isPending = _updateState2[0]; + + var startRef = updateRef(); + var start = startRef.current; + return [start, isPending]; + } + + function rerenderTransition() { + var _rerenderState2 = rerenderState(), + isPending = _rerenderState2[0]; + + var startRef = updateRef(); + var start = startRef.current; + return [start, isPending]; + } + + var isUpdatingOpaqueValueInRenderPhase = false; + function getIsUpdatingOpaqueValueInRenderPhaseInDEV() { + { + return isUpdatingOpaqueValueInRenderPhase; + } + } + + function warnOnOpaqueIdentifierAccessInDEV(fiber) { + { + // TODO: Should warn in effects and callbacks, too + var name = getComponentName(fiber.type) || 'Unknown'; + + if (getIsRendering() && !didWarnAboutUseOpaqueIdentifier[name]) { + error('The object passed back from useOpaqueIdentifier is meant to be ' + 'passed through to attributes only. Do not read the ' + 'value directly.'); + + didWarnAboutUseOpaqueIdentifier[name] = true; + } + } + } + + function mountOpaqueIdentifier() { + var makeId = makeClientIdInDEV.bind(null, warnOnOpaqueIdentifierAccessInDEV.bind(null, currentlyRenderingFiber$1)) ; + + if (getIsHydrating()) { + var didUpgrade = false; + var fiber = currentlyRenderingFiber$1; + + var readValue = function () { + if (!didUpgrade) { + // Only upgrade once. This works even inside the render phase because + // the update is added to a shared queue, which outlasts the + // in-progress render. + didUpgrade = true; + + { + isUpdatingOpaqueValueInRenderPhase = true; + setId(makeId()); + isUpdatingOpaqueValueInRenderPhase = false; + warnOnOpaqueIdentifierAccessInDEV(fiber); + } + } + + { + { + throw Error( "The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. Do not read the value directly." ); + } + } + }; + + var id = makeOpaqueHydratingObject(readValue); + var setId = mountState(id)[1]; + + if ((currentlyRenderingFiber$1.mode & BlockingMode) === NoMode) { + currentlyRenderingFiber$1.flags |= Update | Passive; + pushEffect(HasEffect | Passive$1, function () { + setId(makeId()); + }, undefined, null); + } + + return id; + } else { + var _id = makeId(); + + mountState(_id); + return _id; + } + } + + function updateOpaqueIdentifier() { + var id = updateState()[0]; + return id; + } + + function rerenderOpaqueIdentifier() { + var id = rerenderState()[0]; + return id; + } + + function dispatchAction(fiber, queue, action) { + { + if (typeof arguments[3] === 'function') { + error("State updates from the useState() and useReducer() Hooks don't support the " + 'second callback argument. To execute a side effect after ' + 'rendering, declare it in the component body with useEffect().'); + } + } + + var eventTime = requestEventTime(); + var lane = requestUpdateLane(fiber); + var update = { + lane: lane, + action: action, + eagerReducer: null, + eagerState: null, + next: null + }; // Append the update to the end of the list. + + var pending = queue.pending; + + if (pending === null) { + // This is the first update. Create a circular list. + update.next = update; + } else { + update.next = pending.next; + pending.next = update; + } + + queue.pending = update; + var alternate = fiber.alternate; + + if (fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1) { + // This is a render phase update. Stash it in a lazily-created map of + // queue -> linked list of updates. After this render pass, we'll restart + // and apply the stashed updates on top of the work-in-progress hook. + didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true; + } else { + if (fiber.lanes === NoLanes && (alternate === null || alternate.lanes === NoLanes)) { + // The queue is currently empty, which means we can eagerly compute the + // next state before entering the render phase. If the new state is the + // same as the current state, we may be able to bail out entirely. + var lastRenderedReducer = queue.lastRenderedReducer; + + if (lastRenderedReducer !== null) { + var prevDispatcher; + + { + prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + } + + try { + var currentState = queue.lastRenderedState; + var eagerState = lastRenderedReducer(currentState, action); // Stash the eagerly computed state, and the reducer used to compute + // it, on the update object. If the reducer hasn't changed by the + // time we enter the render phase, then the eager state can be used + // without calling the reducer again. + + update.eagerReducer = lastRenderedReducer; + update.eagerState = eagerState; + + if (objectIs(eagerState, currentState)) { + // Fast path. We can bail out without scheduling React to re-render. + // It's still possible that we'll need to rebase this update later, + // if the component re-renders for a different reason and by that + // time the reducer has changed. + return; + } + } catch (error) {// Suppress the error. It will throw again in the render phase. + } finally { + { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + } + } + } + + { + // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests + if ('undefined' !== typeof jest) { + warnIfNotScopedWithMatchingAct(fiber); + warnIfNotCurrentlyActingUpdatesInDev(fiber); + } + } + + scheduleUpdateOnFiber(fiber, lane, eventTime); + } + } + + var ContextOnlyDispatcher = { + readContext: readContext, + useCallback: throwInvalidHookError, + useContext: throwInvalidHookError, + useEffect: throwInvalidHookError, + useImperativeHandle: throwInvalidHookError, + useLayoutEffect: throwInvalidHookError, + useMemo: throwInvalidHookError, + useReducer: throwInvalidHookError, + useRef: throwInvalidHookError, + useState: throwInvalidHookError, + useDebugValue: throwInvalidHookError, + useDeferredValue: throwInvalidHookError, + useTransition: throwInvalidHookError, + useMutableSource: throwInvalidHookError, + useOpaqueIdentifier: throwInvalidHookError, + unstable_isNewReconciler: enableNewReconciler + }; + var HooksDispatcherOnMountInDEV = null; + var HooksDispatcherOnMountWithHookTypesInDEV = null; + var HooksDispatcherOnUpdateInDEV = null; + var HooksDispatcherOnRerenderInDEV = null; + var InvalidNestedHooksDispatcherOnMountInDEV = null; + var InvalidNestedHooksDispatcherOnUpdateInDEV = null; + var InvalidNestedHooksDispatcherOnRerenderInDEV = null; + + { + var warnInvalidContextAccess = function () { + error('Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().'); + }; + + var warnInvalidHookAccess = function () { + error('Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. ' + 'You can only call Hooks at the top level of your React function. ' + 'For more information, see ' + 'https://reactjs.org/link/rules-of-hooks'); + }; + + HooksDispatcherOnMountInDEV = { + readContext: function (context, observedBits) { + return readContext(context, observedBits); + }, + useCallback: function (callback, deps) { + currentHookNameInDev = 'useCallback'; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); + return mountCallback(callback, deps); + }, + useContext: function (context, observedBits) { + currentHookNameInDev = 'useContext'; + mountHookTypesDev(); + return readContext(context, observedBits); + }, + useEffect: function (create, deps) { + currentHookNameInDev = 'useEffect'; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); + return mountEffect(create, deps); + }, + useImperativeHandle: function (ref, create, deps) { + currentHookNameInDev = 'useImperativeHandle'; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); + return mountImperativeHandle(ref, create, deps); + }, + useLayoutEffect: function (create, deps) { + currentHookNameInDev = 'useLayoutEffect'; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); + return mountLayoutEffect(create, deps); + }, + useMemo: function (create, deps) { + currentHookNameInDev = 'useMemo'; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + + try { + return mountMemo(create, deps); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useReducer: function (reducer, initialArg, init) { + currentHookNameInDev = 'useReducer'; + mountHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + + try { + return mountReducer(reducer, initialArg, init); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useRef: function (initialValue) { + currentHookNameInDev = 'useRef'; + mountHookTypesDev(); + return mountRef(initialValue); + }, + useState: function (initialState) { + currentHookNameInDev = 'useState'; + mountHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + + try { + return mountState(initialState); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useDebugValue: function (value, formatterFn) { + currentHookNameInDev = 'useDebugValue'; + mountHookTypesDev(); + return mountDebugValue(); + }, + useDeferredValue: function (value) { + currentHookNameInDev = 'useDeferredValue'; + mountHookTypesDev(); + return mountDeferredValue(value); + }, + useTransition: function () { + currentHookNameInDev = 'useTransition'; + mountHookTypesDev(); + return mountTransition(); + }, + useMutableSource: function (source, getSnapshot, subscribe) { + currentHookNameInDev = 'useMutableSource'; + mountHookTypesDev(); + return mountMutableSource(source, getSnapshot, subscribe); + }, + useOpaqueIdentifier: function () { + currentHookNameInDev = 'useOpaqueIdentifier'; + mountHookTypesDev(); + return mountOpaqueIdentifier(); + }, + unstable_isNewReconciler: enableNewReconciler + }; + HooksDispatcherOnMountWithHookTypesInDEV = { + readContext: function (context, observedBits) { + return readContext(context, observedBits); + }, + useCallback: function (callback, deps) { + currentHookNameInDev = 'useCallback'; + updateHookTypesDev(); + return mountCallback(callback, deps); + }, + useContext: function (context, observedBits) { + currentHookNameInDev = 'useContext'; + updateHookTypesDev(); + return readContext(context, observedBits); + }, + useEffect: function (create, deps) { + currentHookNameInDev = 'useEffect'; + updateHookTypesDev(); + return mountEffect(create, deps); + }, + useImperativeHandle: function (ref, create, deps) { + currentHookNameInDev = 'useImperativeHandle'; + updateHookTypesDev(); + return mountImperativeHandle(ref, create, deps); + }, + useLayoutEffect: function (create, deps) { + currentHookNameInDev = 'useLayoutEffect'; + updateHookTypesDev(); + return mountLayoutEffect(create, deps); + }, + useMemo: function (create, deps) { + currentHookNameInDev = 'useMemo'; + updateHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + + try { + return mountMemo(create, deps); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useReducer: function (reducer, initialArg, init) { + currentHookNameInDev = 'useReducer'; + updateHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + + try { + return mountReducer(reducer, initialArg, init); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useRef: function (initialValue) { + currentHookNameInDev = 'useRef'; + updateHookTypesDev(); + return mountRef(initialValue); + }, + useState: function (initialState) { + currentHookNameInDev = 'useState'; + updateHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + + try { + return mountState(initialState); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useDebugValue: function (value, formatterFn) { + currentHookNameInDev = 'useDebugValue'; + updateHookTypesDev(); + return mountDebugValue(); + }, + useDeferredValue: function (value) { + currentHookNameInDev = 'useDeferredValue'; + updateHookTypesDev(); + return mountDeferredValue(value); + }, + useTransition: function () { + currentHookNameInDev = 'useTransition'; + updateHookTypesDev(); + return mountTransition(); + }, + useMutableSource: function (source, getSnapshot, subscribe) { + currentHookNameInDev = 'useMutableSource'; + updateHookTypesDev(); + return mountMutableSource(source, getSnapshot, subscribe); + }, + useOpaqueIdentifier: function () { + currentHookNameInDev = 'useOpaqueIdentifier'; + updateHookTypesDev(); + return mountOpaqueIdentifier(); + }, + unstable_isNewReconciler: enableNewReconciler + }; + HooksDispatcherOnUpdateInDEV = { + readContext: function (context, observedBits) { + return readContext(context, observedBits); + }, + useCallback: function (callback, deps) { + currentHookNameInDev = 'useCallback'; + updateHookTypesDev(); + return updateCallback(callback, deps); + }, + useContext: function (context, observedBits) { + currentHookNameInDev = 'useContext'; + updateHookTypesDev(); + return readContext(context, observedBits); + }, + useEffect: function (create, deps) { + currentHookNameInDev = 'useEffect'; + updateHookTypesDev(); + return updateEffect(create, deps); + }, + useImperativeHandle: function (ref, create, deps) { + currentHookNameInDev = 'useImperativeHandle'; + updateHookTypesDev(); + return updateImperativeHandle(ref, create, deps); + }, + useLayoutEffect: function (create, deps) { + currentHookNameInDev = 'useLayoutEffect'; + updateHookTypesDev(); + return updateLayoutEffect(create, deps); + }, + useMemo: function (create, deps) { + currentHookNameInDev = 'useMemo'; + updateHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + + try { + return updateMemo(create, deps); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useReducer: function (reducer, initialArg, init) { + currentHookNameInDev = 'useReducer'; + updateHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + + try { + return updateReducer(reducer, initialArg, init); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useRef: function (initialValue) { + currentHookNameInDev = 'useRef'; + updateHookTypesDev(); + return updateRef(); + }, + useState: function (initialState) { + currentHookNameInDev = 'useState'; + updateHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + + try { + return updateState(initialState); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useDebugValue: function (value, formatterFn) { + currentHookNameInDev = 'useDebugValue'; + updateHookTypesDev(); + return updateDebugValue(); + }, + useDeferredValue: function (value) { + currentHookNameInDev = 'useDeferredValue'; + updateHookTypesDev(); + return updateDeferredValue(value); + }, + useTransition: function () { + currentHookNameInDev = 'useTransition'; + updateHookTypesDev(); + return updateTransition(); + }, + useMutableSource: function (source, getSnapshot, subscribe) { + currentHookNameInDev = 'useMutableSource'; + updateHookTypesDev(); + return updateMutableSource(source, getSnapshot, subscribe); + }, + useOpaqueIdentifier: function () { + currentHookNameInDev = 'useOpaqueIdentifier'; + updateHookTypesDev(); + return updateOpaqueIdentifier(); + }, + unstable_isNewReconciler: enableNewReconciler + }; + HooksDispatcherOnRerenderInDEV = { + readContext: function (context, observedBits) { + return readContext(context, observedBits); + }, + useCallback: function (callback, deps) { + currentHookNameInDev = 'useCallback'; + updateHookTypesDev(); + return updateCallback(callback, deps); + }, + useContext: function (context, observedBits) { + currentHookNameInDev = 'useContext'; + updateHookTypesDev(); + return readContext(context, observedBits); + }, + useEffect: function (create, deps) { + currentHookNameInDev = 'useEffect'; + updateHookTypesDev(); + return updateEffect(create, deps); + }, + useImperativeHandle: function (ref, create, deps) { + currentHookNameInDev = 'useImperativeHandle'; + updateHookTypesDev(); + return updateImperativeHandle(ref, create, deps); + }, + useLayoutEffect: function (create, deps) { + currentHookNameInDev = 'useLayoutEffect'; + updateHookTypesDev(); + return updateLayoutEffect(create, deps); + }, + useMemo: function (create, deps) { + currentHookNameInDev = 'useMemo'; + updateHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV; + + try { + return updateMemo(create, deps); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useReducer: function (reducer, initialArg, init) { + currentHookNameInDev = 'useReducer'; + updateHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV; + + try { + return rerenderReducer(reducer, initialArg, init); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useRef: function (initialValue) { + currentHookNameInDev = 'useRef'; + updateHookTypesDev(); + return updateRef(); + }, + useState: function (initialState) { + currentHookNameInDev = 'useState'; + updateHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV; + + try { + return rerenderState(initialState); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useDebugValue: function (value, formatterFn) { + currentHookNameInDev = 'useDebugValue'; + updateHookTypesDev(); + return updateDebugValue(); + }, + useDeferredValue: function (value) { + currentHookNameInDev = 'useDeferredValue'; + updateHookTypesDev(); + return rerenderDeferredValue(value); + }, + useTransition: function () { + currentHookNameInDev = 'useTransition'; + updateHookTypesDev(); + return rerenderTransition(); + }, + useMutableSource: function (source, getSnapshot, subscribe) { + currentHookNameInDev = 'useMutableSource'; + updateHookTypesDev(); + return updateMutableSource(source, getSnapshot, subscribe); + }, + useOpaqueIdentifier: function () { + currentHookNameInDev = 'useOpaqueIdentifier'; + updateHookTypesDev(); + return rerenderOpaqueIdentifier(); + }, + unstable_isNewReconciler: enableNewReconciler + }; + InvalidNestedHooksDispatcherOnMountInDEV = { + readContext: function (context, observedBits) { + warnInvalidContextAccess(); + return readContext(context, observedBits); + }, + useCallback: function (callback, deps) { + currentHookNameInDev = 'useCallback'; + warnInvalidHookAccess(); + mountHookTypesDev(); + return mountCallback(callback, deps); + }, + useContext: function (context, observedBits) { + currentHookNameInDev = 'useContext'; + warnInvalidHookAccess(); + mountHookTypesDev(); + return readContext(context, observedBits); + }, + useEffect: function (create, deps) { + currentHookNameInDev = 'useEffect'; + warnInvalidHookAccess(); + mountHookTypesDev(); + return mountEffect(create, deps); + }, + useImperativeHandle: function (ref, create, deps) { + currentHookNameInDev = 'useImperativeHandle'; + warnInvalidHookAccess(); + mountHookTypesDev(); + return mountImperativeHandle(ref, create, deps); + }, + useLayoutEffect: function (create, deps) { + currentHookNameInDev = 'useLayoutEffect'; + warnInvalidHookAccess(); + mountHookTypesDev(); + return mountLayoutEffect(create, deps); + }, + useMemo: function (create, deps) { + currentHookNameInDev = 'useMemo'; + warnInvalidHookAccess(); + mountHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + + try { + return mountMemo(create, deps); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useReducer: function (reducer, initialArg, init) { + currentHookNameInDev = 'useReducer'; + warnInvalidHookAccess(); + mountHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + + try { + return mountReducer(reducer, initialArg, init); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useRef: function (initialValue) { + currentHookNameInDev = 'useRef'; + warnInvalidHookAccess(); + mountHookTypesDev(); + return mountRef(initialValue); + }, + useState: function (initialState) { + currentHookNameInDev = 'useState'; + warnInvalidHookAccess(); + mountHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + + try { + return mountState(initialState); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useDebugValue: function (value, formatterFn) { + currentHookNameInDev = 'useDebugValue'; + warnInvalidHookAccess(); + mountHookTypesDev(); + return mountDebugValue(); + }, + useDeferredValue: function (value) { + currentHookNameInDev = 'useDeferredValue'; + warnInvalidHookAccess(); + mountHookTypesDev(); + return mountDeferredValue(value); + }, + useTransition: function () { + currentHookNameInDev = 'useTransition'; + warnInvalidHookAccess(); + mountHookTypesDev(); + return mountTransition(); + }, + useMutableSource: function (source, getSnapshot, subscribe) { + currentHookNameInDev = 'useMutableSource'; + warnInvalidHookAccess(); + mountHookTypesDev(); + return mountMutableSource(source, getSnapshot, subscribe); + }, + useOpaqueIdentifier: function () { + currentHookNameInDev = 'useOpaqueIdentifier'; + warnInvalidHookAccess(); + mountHookTypesDev(); + return mountOpaqueIdentifier(); + }, + unstable_isNewReconciler: enableNewReconciler + }; + InvalidNestedHooksDispatcherOnUpdateInDEV = { + readContext: function (context, observedBits) { + warnInvalidContextAccess(); + return readContext(context, observedBits); + }, + useCallback: function (callback, deps) { + currentHookNameInDev = 'useCallback'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return updateCallback(callback, deps); + }, + useContext: function (context, observedBits) { + currentHookNameInDev = 'useContext'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return readContext(context, observedBits); + }, + useEffect: function (create, deps) { + currentHookNameInDev = 'useEffect'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return updateEffect(create, deps); + }, + useImperativeHandle: function (ref, create, deps) { + currentHookNameInDev = 'useImperativeHandle'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return updateImperativeHandle(ref, create, deps); + }, + useLayoutEffect: function (create, deps) { + currentHookNameInDev = 'useLayoutEffect'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return updateLayoutEffect(create, deps); + }, + useMemo: function (create, deps) { + currentHookNameInDev = 'useMemo'; + warnInvalidHookAccess(); + updateHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + + try { + return updateMemo(create, deps); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useReducer: function (reducer, initialArg, init) { + currentHookNameInDev = 'useReducer'; + warnInvalidHookAccess(); + updateHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + + try { + return updateReducer(reducer, initialArg, init); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useRef: function (initialValue) { + currentHookNameInDev = 'useRef'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return updateRef(); + }, + useState: function (initialState) { + currentHookNameInDev = 'useState'; + warnInvalidHookAccess(); + updateHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + + try { + return updateState(initialState); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useDebugValue: function (value, formatterFn) { + currentHookNameInDev = 'useDebugValue'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return updateDebugValue(); + }, + useDeferredValue: function (value) { + currentHookNameInDev = 'useDeferredValue'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return updateDeferredValue(value); + }, + useTransition: function () { + currentHookNameInDev = 'useTransition'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return updateTransition(); + }, + useMutableSource: function (source, getSnapshot, subscribe) { + currentHookNameInDev = 'useMutableSource'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return updateMutableSource(source, getSnapshot, subscribe); + }, + useOpaqueIdentifier: function () { + currentHookNameInDev = 'useOpaqueIdentifier'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return updateOpaqueIdentifier(); + }, + unstable_isNewReconciler: enableNewReconciler + }; + InvalidNestedHooksDispatcherOnRerenderInDEV = { + readContext: function (context, observedBits) { + warnInvalidContextAccess(); + return readContext(context, observedBits); + }, + useCallback: function (callback, deps) { + currentHookNameInDev = 'useCallback'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return updateCallback(callback, deps); + }, + useContext: function (context, observedBits) { + currentHookNameInDev = 'useContext'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return readContext(context, observedBits); + }, + useEffect: function (create, deps) { + currentHookNameInDev = 'useEffect'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return updateEffect(create, deps); + }, + useImperativeHandle: function (ref, create, deps) { + currentHookNameInDev = 'useImperativeHandle'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return updateImperativeHandle(ref, create, deps); + }, + useLayoutEffect: function (create, deps) { + currentHookNameInDev = 'useLayoutEffect'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return updateLayoutEffect(create, deps); + }, + useMemo: function (create, deps) { + currentHookNameInDev = 'useMemo'; + warnInvalidHookAccess(); + updateHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + + try { + return updateMemo(create, deps); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useReducer: function (reducer, initialArg, init) { + currentHookNameInDev = 'useReducer'; + warnInvalidHookAccess(); + updateHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + + try { + return rerenderReducer(reducer, initialArg, init); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useRef: function (initialValue) { + currentHookNameInDev = 'useRef'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return updateRef(); + }, + useState: function (initialState) { + currentHookNameInDev = 'useState'; + warnInvalidHookAccess(); + updateHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + + try { + return rerenderState(initialState); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useDebugValue: function (value, formatterFn) { + currentHookNameInDev = 'useDebugValue'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return updateDebugValue(); + }, + useDeferredValue: function (value) { + currentHookNameInDev = 'useDeferredValue'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return rerenderDeferredValue(value); + }, + useTransition: function () { + currentHookNameInDev = 'useTransition'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return rerenderTransition(); + }, + useMutableSource: function (source, getSnapshot, subscribe) { + currentHookNameInDev = 'useMutableSource'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return updateMutableSource(source, getSnapshot, subscribe); + }, + useOpaqueIdentifier: function () { + currentHookNameInDev = 'useOpaqueIdentifier'; + warnInvalidHookAccess(); + updateHookTypesDev(); + return rerenderOpaqueIdentifier(); + }, + unstable_isNewReconciler: enableNewReconciler + }; + } + + var now$1 = unstable_now; + var commitTime = 0; + var profilerStartTime = -1; + + function getCommitTime() { + return commitTime; + } + + function recordCommitTime() { + + commitTime = now$1(); + } + + function startProfilerTimer(fiber) { + + profilerStartTime = now$1(); + + if (fiber.actualStartTime < 0) { + fiber.actualStartTime = now$1(); + } + } + + function stopProfilerTimerIfRunning(fiber) { + + profilerStartTime = -1; + } + + function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { + + if (profilerStartTime >= 0) { + var elapsedTime = now$1() - profilerStartTime; + fiber.actualDuration += elapsedTime; + + if (overrideBaseTime) { + fiber.selfBaseDuration = elapsedTime; + } + + profilerStartTime = -1; + } + } + + function transferActualDuration(fiber) { + // Transfer time spent rendering these children so we don't lose it + // after we rerender. This is used as a helper in special cases + // where we should count the work of multiple passes. + var child = fiber.child; + + while (child) { + fiber.actualDuration += child.actualDuration; + child = child.sibling; + } + } + + var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner; + var didReceiveUpdate = false; + var didWarnAboutBadClass; + var didWarnAboutModulePatternComponent; + var didWarnAboutContextTypeOnFunctionComponent; + var didWarnAboutGetDerivedStateOnFunctionComponent; + var didWarnAboutFunctionRefs; + var didWarnAboutReassigningProps; + var didWarnAboutRevealOrder; + var didWarnAboutTailOptions; + + { + didWarnAboutBadClass = {}; + didWarnAboutModulePatternComponent = {}; + didWarnAboutContextTypeOnFunctionComponent = {}; + didWarnAboutGetDerivedStateOnFunctionComponent = {}; + didWarnAboutFunctionRefs = {}; + didWarnAboutReassigningProps = false; + didWarnAboutRevealOrder = {}; + didWarnAboutTailOptions = {}; + } + + function reconcileChildren(current, workInProgress, nextChildren, renderLanes) { + if (current === null) { + // If this is a fresh new component that hasn't been rendered yet, we + // won't update its child set by applying minimal side-effects. Instead, + // we will add them all to the child before it gets rendered. That means + // we can optimize this reconciliation pass by not tracking side-effects. + workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderLanes); + } else { + // If the current child is the same as the work in progress, it means that + // we haven't yet started any work on these children. Therefore, we use + // the clone algorithm to create a copy of all the current children. + // If we had any progressed work already, that is invalid at this point so + // let's throw it out. + workInProgress.child = reconcileChildFibers(workInProgress, current.child, nextChildren, renderLanes); + } + } + + function forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderLanes) { + // This function is fork of reconcileChildren. It's used in cases where we + // want to reconcile without matching against the existing set. This has the + // effect of all current children being unmounted; even if the type and key + // are the same, the old child is unmounted and a new child is created. + // + // To do this, we're going to go through the reconcile algorithm twice. In + // the first pass, we schedule a deletion for all the current children by + // passing null. + workInProgress.child = reconcileChildFibers(workInProgress, current.child, null, renderLanes); // In the second pass, we mount the new children. The trick here is that we + // pass null in place of where we usually pass the current child set. This has + // the effect of remounting all children regardless of whether their + // identities match. + + workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderLanes); + } + + function updateForwardRef(current, workInProgress, Component, nextProps, renderLanes) { + // TODO: current can be non-null here even if the component + // hasn't yet mounted. This happens after the first render suspends. + // We'll need to figure out if this is fine or can cause issues. + { + if (workInProgress.type !== workInProgress.elementType) { + // Lazy component props can't be validated in createElement + // because they're only guaranteed to be resolved here. + var innerPropTypes = Component.propTypes; + + if (innerPropTypes) { + checkPropTypes(innerPropTypes, nextProps, // Resolved props + 'prop', getComponentName(Component)); + } + } + } + + var render = Component.render; + var ref = workInProgress.ref; // The rest is a fork of updateFunctionComponent + + var nextChildren; + prepareToReadContext(workInProgress, renderLanes); + + { + ReactCurrentOwner$1.current = workInProgress; + setIsRendering(true); + nextChildren = renderWithHooks(current, workInProgress, render, nextProps, ref, renderLanes); + + if ( workInProgress.mode & StrictMode) { + disableLogs(); + + try { + nextChildren = renderWithHooks(current, workInProgress, render, nextProps, ref, renderLanes); + } finally { + reenableLogs(); + } + } + + setIsRendering(false); + } + + if (current !== null && !didReceiveUpdate) { + bailoutHooks(current, workInProgress, renderLanes); + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + } // React DevTools reads this flag. + + + workInProgress.flags |= PerformedWork; + reconcileChildren(current, workInProgress, nextChildren, renderLanes); + return workInProgress.child; + } + + function updateMemoComponent(current, workInProgress, Component, nextProps, updateLanes, renderLanes) { + if (current === null) { + var type = Component.type; + + if (isSimpleFunctionComponent(type) && Component.compare === null && // SimpleMemoComponent codepath doesn't resolve outer props either. + Component.defaultProps === undefined) { + var resolvedType = type; + + { + resolvedType = resolveFunctionForHotReloading(type); + } // If this is a plain function component without default props, + // and with only the default shallow comparison, we upgrade it + // to a SimpleMemoComponent to allow fast path updates. + + + workInProgress.tag = SimpleMemoComponent; + workInProgress.type = resolvedType; + + { + validateFunctionComponentInDev(workInProgress, type); + } + + return updateSimpleMemoComponent(current, workInProgress, resolvedType, nextProps, updateLanes, renderLanes); + } + + { + var innerPropTypes = type.propTypes; + + if (innerPropTypes) { + // Inner memo component props aren't currently validated in createElement. + // We could move it there, but we'd still need this for lazy code path. + checkPropTypes(innerPropTypes, nextProps, // Resolved props + 'prop', getComponentName(type)); + } + } + + var child = createFiberFromTypeAndProps(Component.type, null, nextProps, workInProgress, workInProgress.mode, renderLanes); + child.ref = workInProgress.ref; + child.return = workInProgress; + workInProgress.child = child; + return child; + } + + { + var _type = Component.type; + var _innerPropTypes = _type.propTypes; + + if (_innerPropTypes) { + // Inner memo component props aren't currently validated in createElement. + // We could move it there, but we'd still need this for lazy code path. + checkPropTypes(_innerPropTypes, nextProps, // Resolved props + 'prop', getComponentName(_type)); + } + } + + var currentChild = current.child; // This is always exactly one child + + if (!includesSomeLane(updateLanes, renderLanes)) { + // This will be the props with resolved defaultProps, + // unlike current.memoizedProps which will be the unresolved ones. + var prevProps = currentChild.memoizedProps; // Default to shallow comparison + + var compare = Component.compare; + compare = compare !== null ? compare : shallowEqual; + + if (compare(prevProps, nextProps) && current.ref === workInProgress.ref) { + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + } + } // React DevTools reads this flag. + + + workInProgress.flags |= PerformedWork; + var newChild = createWorkInProgress(currentChild, nextProps); + newChild.ref = workInProgress.ref; + newChild.return = workInProgress; + workInProgress.child = newChild; + return newChild; + } + + function updateSimpleMemoComponent(current, workInProgress, Component, nextProps, updateLanes, renderLanes) { + // TODO: current can be non-null here even if the component + // hasn't yet mounted. This happens when the inner render suspends. + // We'll need to figure out if this is fine or can cause issues. + { + if (workInProgress.type !== workInProgress.elementType) { + // Lazy component props can't be validated in createElement + // because they're only guaranteed to be resolved here. + var outerMemoType = workInProgress.elementType; + + if (outerMemoType.$$typeof === REACT_LAZY_TYPE) { + // We warn when you define propTypes on lazy() + // so let's just skip over it to find memo() outer wrapper. + // Inner props for memo are validated later. + var lazyComponent = outerMemoType; + var payload = lazyComponent._payload; + var init = lazyComponent._init; + + try { + outerMemoType = init(payload); + } catch (x) { + outerMemoType = null; + } // Inner propTypes will be validated in the function component path. + + + var outerPropTypes = outerMemoType && outerMemoType.propTypes; + + if (outerPropTypes) { + checkPropTypes(outerPropTypes, nextProps, // Resolved (SimpleMemoComponent has no defaultProps) + 'prop', getComponentName(outerMemoType)); + } + } + } + } + + if (current !== null) { + var prevProps = current.memoizedProps; + + if (shallowEqual(prevProps, nextProps) && current.ref === workInProgress.ref && ( // Prevent bailout if the implementation changed due to hot reload. + workInProgress.type === current.type )) { + didReceiveUpdate = false; + + if (!includesSomeLane(renderLanes, updateLanes)) { + // The pending lanes were cleared at the beginning of beginWork. We're + // about to bail out, but there might be other lanes that weren't + // included in the current render. Usually, the priority level of the + // remaining updates is accumlated during the evaluation of the + // component (i.e. when processing the update queue). But since since + // we're bailing out early *without* evaluating the component, we need + // to account for it here, too. Reset to the value of the current fiber. + // NOTE: This only applies to SimpleMemoComponent, not MemoComponent, + // because a MemoComponent fiber does not have hooks or an update queue; + // rather, it wraps around an inner component, which may or may not + // contains hooks. + // TODO: Move the reset at in beginWork out of the common path so that + // this is no longer necessary. + workInProgress.lanes = current.lanes; + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + } else if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) { + // This is a special case that only exists for legacy mode. + // See https://github.com/facebook/react/pull/19216. + didReceiveUpdate = true; + } + } + } + + return updateFunctionComponent(current, workInProgress, Component, nextProps, renderLanes); + } + + function updateOffscreenComponent(current, workInProgress, renderLanes) { + var nextProps = workInProgress.pendingProps; + var nextChildren = nextProps.children; + var prevState = current !== null ? current.memoizedState : null; + + if (nextProps.mode === 'hidden' || nextProps.mode === 'unstable-defer-without-hiding') { + if ((workInProgress.mode & ConcurrentMode) === NoMode) { + // In legacy sync mode, don't defer the subtree. Render it now. + // TODO: Figure out what we should do in Blocking mode. + var nextState = { + baseLanes: NoLanes + }; + workInProgress.memoizedState = nextState; + pushRenderLanes(workInProgress, renderLanes); + } else if (!includesSomeLane(renderLanes, OffscreenLane)) { + var nextBaseLanes; + + if (prevState !== null) { + var prevBaseLanes = prevState.baseLanes; + nextBaseLanes = mergeLanes(prevBaseLanes, renderLanes); + } else { + nextBaseLanes = renderLanes; + } // Schedule this fiber to re-render at offscreen priority. Then bailout. + + + { + markSpawnedWork(OffscreenLane); + } + + workInProgress.lanes = workInProgress.childLanes = laneToLanes(OffscreenLane); + var _nextState = { + baseLanes: nextBaseLanes + }; + workInProgress.memoizedState = _nextState; // We're about to bail out, but we need to push this to the stack anyway + // to avoid a push/pop misalignment. + + pushRenderLanes(workInProgress, nextBaseLanes); + return null; + } else { + // Rendering at offscreen, so we can clear the base lanes. + var _nextState2 = { + baseLanes: NoLanes + }; + workInProgress.memoizedState = _nextState2; // Push the lanes that were skipped when we bailed out. + + var subtreeRenderLanes = prevState !== null ? prevState.baseLanes : renderLanes; + pushRenderLanes(workInProgress, subtreeRenderLanes); + } + } else { + var _subtreeRenderLanes; + + if (prevState !== null) { + _subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes); // Since we're not hidden anymore, reset the state + + workInProgress.memoizedState = null; + } else { + // We weren't previously hidden, and we still aren't, so there's nothing + // special to do. Need to push to the stack regardless, though, to avoid + // a push/pop misalignment. + _subtreeRenderLanes = renderLanes; + } + + pushRenderLanes(workInProgress, _subtreeRenderLanes); + } + + reconcileChildren(current, workInProgress, nextChildren, renderLanes); + return workInProgress.child; + } // Note: These happen to have identical begin phases, for now. We shouldn't hold + // ourselves to this constraint, though. If the behavior diverges, we should + // fork the function. + + + var updateLegacyHiddenComponent = updateOffscreenComponent; + + function updateFragment(current, workInProgress, renderLanes) { + var nextChildren = workInProgress.pendingProps; + reconcileChildren(current, workInProgress, nextChildren, renderLanes); + return workInProgress.child; + } + + function updateMode(current, workInProgress, renderLanes) { + var nextChildren = workInProgress.pendingProps.children; + reconcileChildren(current, workInProgress, nextChildren, renderLanes); + return workInProgress.child; + } + + function updateProfiler(current, workInProgress, renderLanes) { + { + workInProgress.flags |= Update; // Reset effect durations for the next eventual effect phase. + // These are reset during render to allow the DevTools commit hook a chance to read them, + + var stateNode = workInProgress.stateNode; + stateNode.effectDuration = 0; + stateNode.passiveEffectDuration = 0; + } + + var nextProps = workInProgress.pendingProps; + var nextChildren = nextProps.children; + reconcileChildren(current, workInProgress, nextChildren, renderLanes); + return workInProgress.child; + } + + function markRef(current, workInProgress) { + var ref = workInProgress.ref; + + if (current === null && ref !== null || current !== null && current.ref !== ref) { + // Schedule a Ref effect + workInProgress.flags |= Ref; + } + } + + function updateFunctionComponent(current, workInProgress, Component, nextProps, renderLanes) { + { + if (workInProgress.type !== workInProgress.elementType) { + // Lazy component props can't be validated in createElement + // because they're only guaranteed to be resolved here. + var innerPropTypes = Component.propTypes; + + if (innerPropTypes) { + checkPropTypes(innerPropTypes, nextProps, // Resolved props + 'prop', getComponentName(Component)); + } + } + } + + var context; + + { + var unmaskedContext = getUnmaskedContext(workInProgress, Component, true); + context = getMaskedContext(workInProgress, unmaskedContext); + } + + var nextChildren; + prepareToReadContext(workInProgress, renderLanes); + + { + ReactCurrentOwner$1.current = workInProgress; + setIsRendering(true); + nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderLanes); + + if ( workInProgress.mode & StrictMode) { + disableLogs(); + + try { + nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderLanes); + } finally { + reenableLogs(); + } + } + + setIsRendering(false); + } + + if (current !== null && !didReceiveUpdate) { + bailoutHooks(current, workInProgress, renderLanes); + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + } // React DevTools reads this flag. + + + workInProgress.flags |= PerformedWork; + reconcileChildren(current, workInProgress, nextChildren, renderLanes); + return workInProgress.child; + } + + function updateClassComponent(current, workInProgress, Component, nextProps, renderLanes) { + { + if (workInProgress.type !== workInProgress.elementType) { + // Lazy component props can't be validated in createElement + // because they're only guaranteed to be resolved here. + var innerPropTypes = Component.propTypes; + + if (innerPropTypes) { + checkPropTypes(innerPropTypes, nextProps, // Resolved props + 'prop', getComponentName(Component)); + } + } + } // Push context providers early to prevent context stack mismatches. + // During mounting we don't know the child context yet as the instance doesn't exist. + // We will invalidate the child context in finishClassComponent() right after rendering. + + + var hasContext; + + if (isContextProvider(Component)) { + hasContext = true; + pushContextProvider(workInProgress); + } else { + hasContext = false; + } + + prepareToReadContext(workInProgress, renderLanes); + var instance = workInProgress.stateNode; + var shouldUpdate; + + if (instance === null) { + if (current !== null) { + // A class component without an instance only mounts if it suspended + // inside a non-concurrent tree, in an inconsistent state. We want to + // treat it like a new mount, even though an empty version of it already + // committed. Disconnect the alternate pointers. + current.alternate = null; + workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect + + workInProgress.flags |= Placement; + } // In the initial pass we might need to construct the instance. + + + constructClassInstance(workInProgress, Component, nextProps); + mountClassInstance(workInProgress, Component, nextProps, renderLanes); + shouldUpdate = true; + } else if (current === null) { + // In a resume, we'll already have an instance we can reuse. + shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderLanes); + } else { + shouldUpdate = updateClassInstance(current, workInProgress, Component, nextProps, renderLanes); + } + + var nextUnitOfWork = finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderLanes); + + { + var inst = workInProgress.stateNode; + + if (shouldUpdate && inst.props !== nextProps) { + if (!didWarnAboutReassigningProps) { + error('It looks like %s is reassigning its own `this.props` while rendering. ' + 'This is not supported and can lead to confusing bugs.', getComponentName(workInProgress.type) || 'a component'); + } + + didWarnAboutReassigningProps = true; + } + } + + return nextUnitOfWork; + } + + function finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderLanes) { + // Refs should update even if shouldComponentUpdate returns false + markRef(current, workInProgress); + var didCaptureError = (workInProgress.flags & DidCapture) !== NoFlags; + + if (!shouldUpdate && !didCaptureError) { + // Context providers should defer to sCU for rendering + if (hasContext) { + invalidateContextProvider(workInProgress, Component, false); + } + + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + } + + var instance = workInProgress.stateNode; // Rerender + + ReactCurrentOwner$1.current = workInProgress; + var nextChildren; + + if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') { + // If we captured an error, but getDerivedStateFromError is not defined, + // unmount all the children. componentDidCatch will schedule an update to + // re-render a fallback. This is temporary until we migrate everyone to + // the new API. + // TODO: Warn in a future release. + nextChildren = null; + + { + stopProfilerTimerIfRunning(); + } + } else { + { + setIsRendering(true); + nextChildren = instance.render(); + + if ( workInProgress.mode & StrictMode) { + disableLogs(); + + try { + instance.render(); + } finally { + reenableLogs(); + } + } + + setIsRendering(false); + } + } // React DevTools reads this flag. + + + workInProgress.flags |= PerformedWork; + + if (current !== null && didCaptureError) { + // If we're recovering from an error, reconcile without reusing any of + // the existing children. Conceptually, the normal children and the children + // that are shown on error are two different sets, so we shouldn't reuse + // normal children even if their identities match. + forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderLanes); + } else { + reconcileChildren(current, workInProgress, nextChildren, renderLanes); + } // Memoize state using the values we just used to render. + // TODO: Restructure so we never read values from the instance. + + + workInProgress.memoizedState = instance.state; // The context might have changed so we need to recalculate it. + + if (hasContext) { + invalidateContextProvider(workInProgress, Component, true); + } + + return workInProgress.child; + } + + function pushHostRootContext(workInProgress) { + var root = workInProgress.stateNode; + + if (root.pendingContext) { + pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context); + } else if (root.context) { + // Should always be set + pushTopLevelContextObject(workInProgress, root.context, false); + } + + pushHostContainer(workInProgress, root.containerInfo); + } + + function updateHostRoot(current, workInProgress, renderLanes) { + pushHostRootContext(workInProgress); + var updateQueue = workInProgress.updateQueue; + + if (!(current !== null && updateQueue !== null)) { + { + throw Error( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ); + } + } + + var nextProps = workInProgress.pendingProps; + var prevState = workInProgress.memoizedState; + var prevChildren = prevState !== null ? prevState.element : null; + cloneUpdateQueue(current, workInProgress); + processUpdateQueue(workInProgress, nextProps, null, renderLanes); + var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property + // being called "element". + + var nextChildren = nextState.element; + + if (nextChildren === prevChildren) { + resetHydrationState(); + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + } + + var root = workInProgress.stateNode; + + if (root.hydrate && enterHydrationState(workInProgress)) { + // If we don't have any current children this might be the first pass. + // We always try to hydrate. If this isn't a hydration pass there won't + // be any children to hydrate which is effectively the same thing as + // not hydrating. + { + var mutableSourceEagerHydrationData = root.mutableSourceEagerHydrationData; + + if (mutableSourceEagerHydrationData != null) { + for (var i = 0; i < mutableSourceEagerHydrationData.length; i += 2) { + var mutableSource = mutableSourceEagerHydrationData[i]; + var version = mutableSourceEagerHydrationData[i + 1]; + setWorkInProgressVersion(mutableSource, version); + } + } + } + + var child = mountChildFibers(workInProgress, null, nextChildren, renderLanes); + workInProgress.child = child; + var node = child; + + while (node) { + // Mark each child as hydrating. This is a fast path to know whether this + // tree is part of a hydrating tree. This is used to determine if a child + // node has fully mounted yet, and for scheduling event replaying. + // Conceptually this is similar to Placement in that a new subtree is + // inserted into the React tree here. It just happens to not need DOM + // mutations because it already exists. + node.flags = node.flags & ~Placement | Hydrating; + node = node.sibling; + } + } else { + // Otherwise reset hydration state in case we aborted and resumed another + // root. + reconcileChildren(current, workInProgress, nextChildren, renderLanes); + resetHydrationState(); + } + + return workInProgress.child; + } + + function updateHostComponent(current, workInProgress, renderLanes) { + pushHostContext(workInProgress); + + if (current === null) { + tryToClaimNextHydratableInstance(workInProgress); + } + + var type = workInProgress.type; + var nextProps = workInProgress.pendingProps; + var prevProps = current !== null ? current.memoizedProps : null; + var nextChildren = nextProps.children; + var isDirectTextChild = shouldSetTextContent(type, nextProps); + + if (isDirectTextChild) { + // We special case a direct text child of a host node. This is a common + // case. We won't handle it as a reified child. We will instead handle + // this in the host environment that also has access to this prop. That + // avoids allocating another HostText fiber and traversing it. + nextChildren = null; + } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) { + // If we're switching from a direct text child to a normal child, or to + // empty, we need to schedule the text content to be reset. + workInProgress.flags |= ContentReset; + } + + markRef(current, workInProgress); + reconcileChildren(current, workInProgress, nextChildren, renderLanes); + return workInProgress.child; + } + + function updateHostText(current, workInProgress) { + if (current === null) { + tryToClaimNextHydratableInstance(workInProgress); + } // Nothing to do here. This is terminal. We'll do the completion step + // immediately after. + + + return null; + } + + function mountLazyComponent(_current, workInProgress, elementType, updateLanes, renderLanes) { + if (_current !== null) { + // A lazy component only mounts if it suspended inside a non- + // concurrent tree, in an inconsistent state. We want to treat it like + // a new mount, even though an empty version of it already committed. + // Disconnect the alternate pointers. + _current.alternate = null; + workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect + + workInProgress.flags |= Placement; + } + + var props = workInProgress.pendingProps; + var lazyComponent = elementType; + var payload = lazyComponent._payload; + var init = lazyComponent._init; + var Component = init(payload); // Store the unwrapped component in the type. + + workInProgress.type = Component; + var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component); + var resolvedProps = resolveDefaultProps(Component, props); + var child; + + switch (resolvedTag) { + case FunctionComponent: + { + { + validateFunctionComponentInDev(workInProgress, Component); + workInProgress.type = Component = resolveFunctionForHotReloading(Component); + } + + child = updateFunctionComponent(null, workInProgress, Component, resolvedProps, renderLanes); + return child; + } + + case ClassComponent: + { + { + workInProgress.type = Component = resolveClassForHotReloading(Component); + } + + child = updateClassComponent(null, workInProgress, Component, resolvedProps, renderLanes); + return child; + } + + case ForwardRef: + { + { + workInProgress.type = Component = resolveForwardRefForHotReloading(Component); + } + + child = updateForwardRef(null, workInProgress, Component, resolvedProps, renderLanes); + return child; + } + + case MemoComponent: + { + { + if (workInProgress.type !== workInProgress.elementType) { + var outerPropTypes = Component.propTypes; + + if (outerPropTypes) { + checkPropTypes(outerPropTypes, resolvedProps, // Resolved for outer only + 'prop', getComponentName(Component)); + } + } + } + + child = updateMemoComponent(null, workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too + updateLanes, renderLanes); + return child; + } + } + + var hint = ''; + + { + if (Component !== null && typeof Component === 'object' && Component.$$typeof === REACT_LAZY_TYPE) { + hint = ' Did you wrap a component in React.lazy() more than once?'; + } + } // This message intentionally doesn't mention ForwardRef or MemoComponent + // because the fact that it's a separate type of work is an + // implementation detail. + + + { + { + throw Error( "Element type is invalid. Received a promise that resolves to: " + Component + ". Lazy element type must resolve to a class or function." + hint ); + } + } + } + + function mountIncompleteClassComponent(_current, workInProgress, Component, nextProps, renderLanes) { + if (_current !== null) { + // An incomplete component only mounts if it suspended inside a non- + // concurrent tree, in an inconsistent state. We want to treat it like + // a new mount, even though an empty version of it already committed. + // Disconnect the alternate pointers. + _current.alternate = null; + workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect + + workInProgress.flags |= Placement; + } // Promote the fiber to a class and try rendering again. + + + workInProgress.tag = ClassComponent; // The rest of this function is a fork of `updateClassComponent` + // Push context providers early to prevent context stack mismatches. + // During mounting we don't know the child context yet as the instance doesn't exist. + // We will invalidate the child context in finishClassComponent() right after rendering. + + var hasContext; + + if (isContextProvider(Component)) { + hasContext = true; + pushContextProvider(workInProgress); + } else { + hasContext = false; + } + + prepareToReadContext(workInProgress, renderLanes); + constructClassInstance(workInProgress, Component, nextProps); + mountClassInstance(workInProgress, Component, nextProps, renderLanes); + return finishClassComponent(null, workInProgress, Component, true, hasContext, renderLanes); + } + + function mountIndeterminateComponent(_current, workInProgress, Component, renderLanes) { + if (_current !== null) { + // An indeterminate component only mounts if it suspended inside a non- + // concurrent tree, in an inconsistent state. We want to treat it like + // a new mount, even though an empty version of it already committed. + // Disconnect the alternate pointers. + _current.alternate = null; + workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect + + workInProgress.flags |= Placement; + } + + var props = workInProgress.pendingProps; + var context; + + { + var unmaskedContext = getUnmaskedContext(workInProgress, Component, false); + context = getMaskedContext(workInProgress, unmaskedContext); + } + + prepareToReadContext(workInProgress, renderLanes); + var value; + + { + if (Component.prototype && typeof Component.prototype.render === 'function') { + var componentName = getComponentName(Component) || 'Unknown'; + + if (!didWarnAboutBadClass[componentName]) { + error("The <%s /> component appears to have a render method, but doesn't extend React.Component. " + 'This is likely to cause errors. Change %s to extend React.Component instead.', componentName, componentName); + + didWarnAboutBadClass[componentName] = true; + } + } + + if (workInProgress.mode & StrictMode) { + ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null); + } + + setIsRendering(true); + ReactCurrentOwner$1.current = workInProgress; + value = renderWithHooks(null, workInProgress, Component, props, context, renderLanes); + setIsRendering(false); + } // React DevTools reads this flag. + + + workInProgress.flags |= PerformedWork; + + { + // Support for module components is deprecated and is removed behind a flag. + // Whether or not it would crash later, we want to show a good message in DEV first. + if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) { + var _componentName = getComponentName(Component) || 'Unknown'; + + if (!didWarnAboutModulePatternComponent[_componentName]) { + error('The <%s /> component appears to be a function component that returns a class instance. ' + 'Change %s to a class that extends React.Component instead. ' + "If you can't use a class try assigning the prototype on the function as a workaround. " + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + 'cannot be called with `new` by React.', _componentName, _componentName, _componentName); + + didWarnAboutModulePatternComponent[_componentName] = true; + } + } + } + + if ( // Run these checks in production only if the flag is off. + // Eventually we'll delete this branch altogether. + typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) { + { + var _componentName2 = getComponentName(Component) || 'Unknown'; + + if (!didWarnAboutModulePatternComponent[_componentName2]) { + error('The <%s /> component appears to be a function component that returns a class instance. ' + 'Change %s to a class that extends React.Component instead. ' + "If you can't use a class try assigning the prototype on the function as a workaround. " + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + 'cannot be called with `new` by React.', _componentName2, _componentName2, _componentName2); + + didWarnAboutModulePatternComponent[_componentName2] = true; + } + } // Proceed under the assumption that this is a class instance + + + workInProgress.tag = ClassComponent; // Throw out any hooks that were used. + + workInProgress.memoizedState = null; + workInProgress.updateQueue = null; // Push context providers early to prevent context stack mismatches. + // During mounting we don't know the child context yet as the instance doesn't exist. + // We will invalidate the child context in finishClassComponent() right after rendering. + + var hasContext = false; + + if (isContextProvider(Component)) { + hasContext = true; + pushContextProvider(workInProgress); + } else { + hasContext = false; + } + + workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null; + initializeUpdateQueue(workInProgress); + var getDerivedStateFromProps = Component.getDerivedStateFromProps; + + if (typeof getDerivedStateFromProps === 'function') { + applyDerivedStateFromProps(workInProgress, Component, getDerivedStateFromProps, props); + } + + adoptClassInstance(workInProgress, value); + mountClassInstance(workInProgress, Component, props, renderLanes); + return finishClassComponent(null, workInProgress, Component, true, hasContext, renderLanes); + } else { + // Proceed under the assumption that this is a function component + workInProgress.tag = FunctionComponent; + + { + + if ( workInProgress.mode & StrictMode) { + disableLogs(); + + try { + value = renderWithHooks(null, workInProgress, Component, props, context, renderLanes); + } finally { + reenableLogs(); + } + } + } + + reconcileChildren(null, workInProgress, value, renderLanes); + + { + validateFunctionComponentInDev(workInProgress, Component); + } + + return workInProgress.child; + } + } + + function validateFunctionComponentInDev(workInProgress, Component) { + { + if (Component) { + if (Component.childContextTypes) { + error('%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component'); + } + } + + if (workInProgress.ref !== null) { + var info = ''; + var ownerName = getCurrentFiberOwnerNameInDevOrNull(); + + if (ownerName) { + info += '\n\nCheck the render method of `' + ownerName + '`.'; + } + + var warningKey = ownerName || workInProgress._debugID || ''; + var debugSource = workInProgress._debugSource; + + if (debugSource) { + warningKey = debugSource.fileName + ':' + debugSource.lineNumber; + } + + if (!didWarnAboutFunctionRefs[warningKey]) { + didWarnAboutFunctionRefs[warningKey] = true; + + error('Function components cannot be given refs. ' + 'Attempts to access this ref will fail. ' + 'Did you mean to use React.forwardRef()?%s', info); + } + } + + if (typeof Component.getDerivedStateFromProps === 'function') { + var _componentName3 = getComponentName(Component) || 'Unknown'; + + if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]) { + error('%s: Function components do not support getDerivedStateFromProps.', _componentName3); + + didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] = true; + } + } + + if (typeof Component.contextType === 'object' && Component.contextType !== null) { + var _componentName4 = getComponentName(Component) || 'Unknown'; + + if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) { + error('%s: Function components do not support contextType.', _componentName4); + + didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true; + } + } + } + } + + var SUSPENDED_MARKER = { + dehydrated: null, + retryLane: NoLane + }; + + function mountSuspenseOffscreenState(renderLanes) { + return { + baseLanes: renderLanes + }; + } + + function updateSuspenseOffscreenState(prevOffscreenState, renderLanes) { + return { + baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes) + }; + } // TODO: Probably should inline this back + + + function shouldRemainOnFallback(suspenseContext, current, workInProgress, renderLanes) { + // If we're already showing a fallback, there are cases where we need to + // remain on that fallback regardless of whether the content has resolved. + // For example, SuspenseList coordinates when nested content appears. + if (current !== null) { + var suspenseState = current.memoizedState; + + if (suspenseState === null) { + // Currently showing content. Don't hide it, even if ForceSuspenseFallack + // is true. More precise name might be "ForceRemainSuspenseFallback". + // Note: This is a factoring smell. Can't remain on a fallback if there's + // no fallback to remain on. + return false; + } + } // Not currently showing content. Consult the Suspense context. + + + return hasSuspenseContext(suspenseContext, ForceSuspenseFallback); + } + + function getRemainingWorkInPrimaryTree(current, renderLanes) { + // TODO: Should not remove render lanes that were pinged during this render + return removeLanes(current.childLanes, renderLanes); + } + + function updateSuspenseComponent(current, workInProgress, renderLanes) { + var nextProps = workInProgress.pendingProps; // This is used by DevTools to force a boundary to suspend. + + { + if (shouldSuspend(workInProgress)) { + workInProgress.flags |= DidCapture; + } + } + + var suspenseContext = suspenseStackCursor.current; + var showFallback = false; + var didSuspend = (workInProgress.flags & DidCapture) !== NoFlags; + + if (didSuspend || shouldRemainOnFallback(suspenseContext, current)) { + // Something in this boundary's subtree already suspended. Switch to + // rendering the fallback children. + showFallback = true; + workInProgress.flags &= ~DidCapture; + } else { + // Attempting the main content + if (current === null || current.memoizedState !== null) { + // This is a new mount or this boundary is already showing a fallback state. + // Mark this subtree context as having at least one invisible parent that could + // handle the fallback state. + // Boundaries without fallbacks or should be avoided are not considered since + // they cannot handle preferred fallback states. + if (nextProps.fallback !== undefined && nextProps.unstable_avoidThisFallback !== true) { + suspenseContext = addSubtreeSuspenseContext(suspenseContext, InvisibleParentSuspenseContext); + } + } + } + + suspenseContext = setDefaultShallowSuspenseContext(suspenseContext); + pushSuspenseContext(workInProgress, suspenseContext); // OK, the next part is confusing. We're about to reconcile the Suspense + // boundary's children. This involves some custom reconcilation logic. Two + // main reasons this is so complicated. + // + // First, Legacy Mode has different semantics for backwards compatibility. The + // primary tree will commit in an inconsistent state, so when we do the + // second pass to render the fallback, we do some exceedingly, uh, clever + // hacks to make that not totally break. Like transferring effects and + // deletions from hidden tree. In Concurrent Mode, it's much simpler, + // because we bailout on the primary tree completely and leave it in its old + // state, no effects. Same as what we do for Offscreen (except that + // Offscreen doesn't have the first render pass). + // + // Second is hydration. During hydration, the Suspense fiber has a slightly + // different layout, where the child points to a dehydrated fragment, which + // contains the DOM rendered by the server. + // + // Third, even if you set all that aside, Suspense is like error boundaries in + // that we first we try to render one tree, and if that fails, we render again + // and switch to a different tree. Like a try/catch block. So we have to track + // which branch we're currently rendering. Ideally we would model this using + // a stack. + + if (current === null) { + // Initial mount + // If we're currently hydrating, try to hydrate this boundary. + // But only if this has a fallback. + if (nextProps.fallback !== undefined) { + tryToClaimNextHydratableInstance(workInProgress); // This could've been a dehydrated suspense component. + } + + var nextPrimaryChildren = nextProps.children; + var nextFallbackChildren = nextProps.fallback; + + if (showFallback) { + var fallbackFragment = mountSuspenseFallbackChildren(workInProgress, nextPrimaryChildren, nextFallbackChildren, renderLanes); + var primaryChildFragment = workInProgress.child; + primaryChildFragment.memoizedState = mountSuspenseOffscreenState(renderLanes); + workInProgress.memoizedState = SUSPENDED_MARKER; + return fallbackFragment; + } else if (typeof nextProps.unstable_expectedLoadTime === 'number') { + // This is a CPU-bound tree. Skip this tree and show a placeholder to + // unblock the surrounding content. Then immediately retry after the + // initial commit. + var _fallbackFragment = mountSuspenseFallbackChildren(workInProgress, nextPrimaryChildren, nextFallbackChildren, renderLanes); + + var _primaryChildFragment = workInProgress.child; + _primaryChildFragment.memoizedState = mountSuspenseOffscreenState(renderLanes); + workInProgress.memoizedState = SUSPENDED_MARKER; // Since nothing actually suspended, there will nothing to ping this to + // get it started back up to attempt the next item. While in terms of + // priority this work has the same priority as this current render, it's + // not part of the same transition once the transition has committed. If + // it's sync, we still want to yield so that it can be painted. + // Conceptually, this is really the same as pinging. We can use any + // RetryLane even if it's the one currently rendering since we're leaving + // it behind on this node. + + workInProgress.lanes = SomeRetryLane; + + { + markSpawnedWork(SomeRetryLane); + } + + return _fallbackFragment; + } else { + return mountSuspensePrimaryChildren(workInProgress, nextPrimaryChildren, renderLanes); + } + } else { + // This is an update. + // If the current fiber has a SuspenseState, that means it's already showing + // a fallback. + var prevState = current.memoizedState; + + if (prevState !== null) { + + if (showFallback) { + var _nextFallbackChildren2 = nextProps.fallback; + var _nextPrimaryChildren2 = nextProps.children; + + var _fallbackChildFragment = updateSuspenseFallbackChildren(current, workInProgress, _nextPrimaryChildren2, _nextFallbackChildren2, renderLanes); + + var _primaryChildFragment3 = workInProgress.child; + var prevOffscreenState = current.child.memoizedState; + _primaryChildFragment3.memoizedState = prevOffscreenState === null ? mountSuspenseOffscreenState(renderLanes) : updateSuspenseOffscreenState(prevOffscreenState, renderLanes); + _primaryChildFragment3.childLanes = getRemainingWorkInPrimaryTree(current, renderLanes); + workInProgress.memoizedState = SUSPENDED_MARKER; + return _fallbackChildFragment; + } else { + var _nextPrimaryChildren3 = nextProps.children; + + var _primaryChildFragment4 = updateSuspensePrimaryChildren(current, workInProgress, _nextPrimaryChildren3, renderLanes); + + workInProgress.memoizedState = null; + return _primaryChildFragment4; + } + } else { + // The current tree is not already showing a fallback. + if (showFallback) { + // Timed out. + var _nextFallbackChildren3 = nextProps.fallback; + var _nextPrimaryChildren4 = nextProps.children; + + var _fallbackChildFragment2 = updateSuspenseFallbackChildren(current, workInProgress, _nextPrimaryChildren4, _nextFallbackChildren3, renderLanes); + + var _primaryChildFragment5 = workInProgress.child; + var _prevOffscreenState = current.child.memoizedState; + _primaryChildFragment5.memoizedState = _prevOffscreenState === null ? mountSuspenseOffscreenState(renderLanes) : updateSuspenseOffscreenState(_prevOffscreenState, renderLanes); + _primaryChildFragment5.childLanes = getRemainingWorkInPrimaryTree(current, renderLanes); // Skip the primary children, and continue working on the + // fallback children. + + workInProgress.memoizedState = SUSPENDED_MARKER; + return _fallbackChildFragment2; + } else { + // Still haven't timed out. Continue rendering the children, like we + // normally do. + var _nextPrimaryChildren5 = nextProps.children; + + var _primaryChildFragment6 = updateSuspensePrimaryChildren(current, workInProgress, _nextPrimaryChildren5, renderLanes); + + workInProgress.memoizedState = null; + return _primaryChildFragment6; + } + } + } + } + + function mountSuspensePrimaryChildren(workInProgress, primaryChildren, renderLanes) { + var mode = workInProgress.mode; + var primaryChildProps = { + mode: 'visible', + children: primaryChildren + }; + var primaryChildFragment = createFiberFromOffscreen(primaryChildProps, mode, renderLanes, null); + primaryChildFragment.return = workInProgress; + workInProgress.child = primaryChildFragment; + return primaryChildFragment; + } + + function mountSuspenseFallbackChildren(workInProgress, primaryChildren, fallbackChildren, renderLanes) { + var mode = workInProgress.mode; + var progressedPrimaryFragment = workInProgress.child; + var primaryChildProps = { + mode: 'hidden', + children: primaryChildren + }; + var primaryChildFragment; + var fallbackChildFragment; + + if ((mode & BlockingMode) === NoMode && progressedPrimaryFragment !== null) { + // In legacy mode, we commit the primary tree as if it successfully + // completed, even though it's in an inconsistent state. + primaryChildFragment = progressedPrimaryFragment; + primaryChildFragment.childLanes = NoLanes; + primaryChildFragment.pendingProps = primaryChildProps; + + if ( workInProgress.mode & ProfileMode) { + // Reset the durations from the first pass so they aren't included in the + // final amounts. This seems counterintuitive, since we're intentionally + // not measuring part of the render phase, but this makes it match what we + // do in Concurrent Mode. + primaryChildFragment.actualDuration = 0; + primaryChildFragment.actualStartTime = -1; + primaryChildFragment.selfBaseDuration = 0; + primaryChildFragment.treeBaseDuration = 0; + } + + fallbackChildFragment = createFiberFromFragment(fallbackChildren, mode, renderLanes, null); + } else { + primaryChildFragment = createFiberFromOffscreen(primaryChildProps, mode, NoLanes, null); + fallbackChildFragment = createFiberFromFragment(fallbackChildren, mode, renderLanes, null); + } + + primaryChildFragment.return = workInProgress; + fallbackChildFragment.return = workInProgress; + primaryChildFragment.sibling = fallbackChildFragment; + workInProgress.child = primaryChildFragment; + return fallbackChildFragment; + } + + function createWorkInProgressOffscreenFiber(current, offscreenProps) { + // The props argument to `createWorkInProgress` is `any` typed, so we use this + // wrapper function to constrain it. + return createWorkInProgress(current, offscreenProps); + } + + function updateSuspensePrimaryChildren(current, workInProgress, primaryChildren, renderLanes) { + var currentPrimaryChildFragment = current.child; + var currentFallbackChildFragment = currentPrimaryChildFragment.sibling; + var primaryChildFragment = createWorkInProgressOffscreenFiber(currentPrimaryChildFragment, { + mode: 'visible', + children: primaryChildren + }); + + if ((workInProgress.mode & BlockingMode) === NoMode) { + primaryChildFragment.lanes = renderLanes; + } + + primaryChildFragment.return = workInProgress; + primaryChildFragment.sibling = null; + + if (currentFallbackChildFragment !== null) { + // Delete the fallback child fragment + currentFallbackChildFragment.nextEffect = null; + currentFallbackChildFragment.flags = Deletion; + workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChildFragment; + } + + workInProgress.child = primaryChildFragment; + return primaryChildFragment; + } + + function updateSuspenseFallbackChildren(current, workInProgress, primaryChildren, fallbackChildren, renderLanes) { + var mode = workInProgress.mode; + var currentPrimaryChildFragment = current.child; + var currentFallbackChildFragment = currentPrimaryChildFragment.sibling; + var primaryChildProps = { + mode: 'hidden', + children: primaryChildren + }; + var primaryChildFragment; + + if ( // In legacy mode, we commit the primary tree as if it successfully + // completed, even though it's in an inconsistent state. + (mode & BlockingMode) === NoMode && // Make sure we're on the second pass, i.e. the primary child fragment was + // already cloned. In legacy mode, the only case where this isn't true is + // when DevTools forces us to display a fallback; we skip the first render + // pass entirely and go straight to rendering the fallback. (In Concurrent + // Mode, SuspenseList can also trigger this scenario, but this is a legacy- + // only codepath.) + workInProgress.child !== currentPrimaryChildFragment) { + var progressedPrimaryFragment = workInProgress.child; + primaryChildFragment = progressedPrimaryFragment; + primaryChildFragment.childLanes = NoLanes; + primaryChildFragment.pendingProps = primaryChildProps; + + if ( workInProgress.mode & ProfileMode) { + // Reset the durations from the first pass so they aren't included in the + // final amounts. This seems counterintuitive, since we're intentionally + // not measuring part of the render phase, but this makes it match what we + // do in Concurrent Mode. + primaryChildFragment.actualDuration = 0; + primaryChildFragment.actualStartTime = -1; + primaryChildFragment.selfBaseDuration = currentPrimaryChildFragment.selfBaseDuration; + primaryChildFragment.treeBaseDuration = currentPrimaryChildFragment.treeBaseDuration; + } // The fallback fiber was added as a deletion effect during the first pass. + // However, since we're going to remain on the fallback, we no longer want + // to delete it. So we need to remove it from the list. Deletions are stored + // on the same list as effects. We want to keep the effects from the primary + // tree. So we copy the primary child fragment's effect list, which does not + // include the fallback deletion effect. + + + var progressedLastEffect = primaryChildFragment.lastEffect; + + if (progressedLastEffect !== null) { + workInProgress.firstEffect = primaryChildFragment.firstEffect; + workInProgress.lastEffect = progressedLastEffect; + progressedLastEffect.nextEffect = null; + } else { + // TODO: Reset this somewhere else? Lol legacy mode is so weird. + workInProgress.firstEffect = workInProgress.lastEffect = null; + } + } else { + primaryChildFragment = createWorkInProgressOffscreenFiber(currentPrimaryChildFragment, primaryChildProps); + } + + var fallbackChildFragment; + + if (currentFallbackChildFragment !== null) { + fallbackChildFragment = createWorkInProgress(currentFallbackChildFragment, fallbackChildren); + } else { + fallbackChildFragment = createFiberFromFragment(fallbackChildren, mode, renderLanes, null); // Needs a placement effect because the parent (the Suspense boundary) already + // mounted but this is a new fiber. + + fallbackChildFragment.flags |= Placement; + } + + fallbackChildFragment.return = workInProgress; + primaryChildFragment.return = workInProgress; + primaryChildFragment.sibling = fallbackChildFragment; + workInProgress.child = primaryChildFragment; + return fallbackChildFragment; + } + + function scheduleWorkOnFiber(fiber, renderLanes) { + fiber.lanes = mergeLanes(fiber.lanes, renderLanes); + var alternate = fiber.alternate; + + if (alternate !== null) { + alternate.lanes = mergeLanes(alternate.lanes, renderLanes); + } + + scheduleWorkOnParentPath(fiber.return, renderLanes); + } + + function propagateSuspenseContextChange(workInProgress, firstChild, renderLanes) { + // Mark any Suspense boundaries with fallbacks as having work to do. + // If they were previously forced into fallbacks, they may now be able + // to unblock. + var node = firstChild; + + while (node !== null) { + if (node.tag === SuspenseComponent) { + var state = node.memoizedState; + + if (state !== null) { + scheduleWorkOnFiber(node, renderLanes); + } + } else if (node.tag === SuspenseListComponent) { + // If the tail is hidden there might not be an Suspense boundaries + // to schedule work on. In this case we have to schedule it on the + // list itself. + // We don't have to traverse to the children of the list since + // the list will propagate the change when it rerenders. + scheduleWorkOnFiber(node, renderLanes); + } else if (node.child !== null) { + node.child.return = node; + node = node.child; + continue; + } + + if (node === workInProgress) { + return; + } + + while (node.sibling === null) { + if (node.return === null || node.return === workInProgress) { + return; + } + + node = node.return; + } + + node.sibling.return = node.return; + node = node.sibling; + } + } + + function findLastContentRow(firstChild) { + // This is going to find the last row among these children that is already + // showing content on the screen, as opposed to being in fallback state or + // new. If a row has multiple Suspense boundaries, any of them being in the + // fallback state, counts as the whole row being in a fallback state. + // Note that the "rows" will be workInProgress, but any nested children + // will still be current since we haven't rendered them yet. The mounted + // order may not be the same as the new order. We use the new order. + var row = firstChild; + var lastContentRow = null; + + while (row !== null) { + var currentRow = row.alternate; // New rows can't be content rows. + + if (currentRow !== null && findFirstSuspended(currentRow) === null) { + lastContentRow = row; + } + + row = row.sibling; + } + + return lastContentRow; + } + + function validateRevealOrder(revealOrder) { + { + if (revealOrder !== undefined && revealOrder !== 'forwards' && revealOrder !== 'backwards' && revealOrder !== 'together' && !didWarnAboutRevealOrder[revealOrder]) { + didWarnAboutRevealOrder[revealOrder] = true; + + if (typeof revealOrder === 'string') { + switch (revealOrder.toLowerCase()) { + case 'together': + case 'forwards': + case 'backwards': + { + error('"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase()); + + break; + } + + case 'forward': + case 'backward': + { + error('"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'React uses the -s suffix in the spelling. Use "%ss" instead.', revealOrder, revealOrder.toLowerCase()); + + break; + } + + default: + error('"%s" is not a supported revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder); + + break; + } + } else { + error('%s is not a supported value for revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder); + } + } + } + } + + function validateTailOptions(tailMode, revealOrder) { + { + if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) { + if (tailMode !== 'collapsed' && tailMode !== 'hidden') { + didWarnAboutTailOptions[tailMode] = true; + + error('"%s" is not a supported value for tail on <SuspenseList />. ' + 'Did you mean "collapsed" or "hidden"?', tailMode); + } else if (revealOrder !== 'forwards' && revealOrder !== 'backwards') { + didWarnAboutTailOptions[tailMode] = true; + + error('<SuspenseList tail="%s" /> is only valid if revealOrder is ' + '"forwards" or "backwards". ' + 'Did you mean to specify revealOrder="forwards"?', tailMode); + } + } + } + } + + function validateSuspenseListNestedChild(childSlot, index) { + { + var isArray = Array.isArray(childSlot); + var isIterable = !isArray && typeof getIteratorFn(childSlot) === 'function'; + + if (isArray || isIterable) { + var type = isArray ? 'array' : 'iterable'; + + error('A nested %s was passed to row #%s in <SuspenseList />. Wrap it in ' + 'an additional SuspenseList to configure its revealOrder: ' + '<SuspenseList revealOrder=...> ... ' + '<SuspenseList revealOrder=...>{%s}</SuspenseList> ... ' + '</SuspenseList>', type, index, type); + + return false; + } + } + + return true; + } + + function validateSuspenseListChildren(children, revealOrder) { + { + if ((revealOrder === 'forwards' || revealOrder === 'backwards') && children !== undefined && children !== null && children !== false) { + if (Array.isArray(children)) { + for (var i = 0; i < children.length; i++) { + if (!validateSuspenseListNestedChild(children[i], i)) { + return; + } + } + } else { + var iteratorFn = getIteratorFn(children); + + if (typeof iteratorFn === 'function') { + var childrenIterator = iteratorFn.call(children); + + if (childrenIterator) { + var step = childrenIterator.next(); + var _i = 0; + + for (; !step.done; step = childrenIterator.next()) { + if (!validateSuspenseListNestedChild(step.value, _i)) { + return; + } + + _i++; + } + } + } else { + error('A single row was passed to a <SuspenseList revealOrder="%s" />. ' + 'This is not useful since it needs multiple rows. ' + 'Did you mean to pass multiple children or an array?', revealOrder); + } + } + } + } + } + + function initSuspenseListRenderState(workInProgress, isBackwards, tail, lastContentRow, tailMode, lastEffectBeforeRendering) { + var renderState = workInProgress.memoizedState; + + if (renderState === null) { + workInProgress.memoizedState = { + isBackwards: isBackwards, + rendering: null, + renderingStartTime: 0, + last: lastContentRow, + tail: tail, + tailMode: tailMode, + lastEffect: lastEffectBeforeRendering + }; + } else { + // We can reuse the existing object from previous renders. + renderState.isBackwards = isBackwards; + renderState.rendering = null; + renderState.renderingStartTime = 0; + renderState.last = lastContentRow; + renderState.tail = tail; + renderState.tailMode = tailMode; + renderState.lastEffect = lastEffectBeforeRendering; + } + } // This can end up rendering this component multiple passes. + // The first pass splits the children fibers into two sets. A head and tail. + // We first render the head. If anything is in fallback state, we do another + // pass through beginWork to rerender all children (including the tail) with + // the force suspend context. If the first render didn't have anything in + // in fallback state. Then we render each row in the tail one-by-one. + // That happens in the completeWork phase without going back to beginWork. + + + function updateSuspenseListComponent(current, workInProgress, renderLanes) { + var nextProps = workInProgress.pendingProps; + var revealOrder = nextProps.revealOrder; + var tailMode = nextProps.tail; + var newChildren = nextProps.children; + validateRevealOrder(revealOrder); + validateTailOptions(tailMode, revealOrder); + validateSuspenseListChildren(newChildren, revealOrder); + reconcileChildren(current, workInProgress, newChildren, renderLanes); + var suspenseContext = suspenseStackCursor.current; + var shouldForceFallback = hasSuspenseContext(suspenseContext, ForceSuspenseFallback); + + if (shouldForceFallback) { + suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback); + workInProgress.flags |= DidCapture; + } else { + var didSuspendBefore = current !== null && (current.flags & DidCapture) !== NoFlags; + + if (didSuspendBefore) { + // If we previously forced a fallback, we need to schedule work + // on any nested boundaries to let them know to try to render + // again. This is the same as context updating. + propagateSuspenseContextChange(workInProgress, workInProgress.child, renderLanes); + } + + suspenseContext = setDefaultShallowSuspenseContext(suspenseContext); + } + + pushSuspenseContext(workInProgress, suspenseContext); + + if ((workInProgress.mode & BlockingMode) === NoMode) { + // In legacy mode, SuspenseList doesn't work so we just + // use make it a noop by treating it as the default revealOrder. + workInProgress.memoizedState = null; + } else { + switch (revealOrder) { + case 'forwards': + { + var lastContentRow = findLastContentRow(workInProgress.child); + var tail; + + if (lastContentRow === null) { + // The whole list is part of the tail. + // TODO: We could fast path by just rendering the tail now. + tail = workInProgress.child; + workInProgress.child = null; + } else { + // Disconnect the tail rows after the content row. + // We're going to render them separately later. + tail = lastContentRow.sibling; + lastContentRow.sibling = null; + } + + initSuspenseListRenderState(workInProgress, false, // isBackwards + tail, lastContentRow, tailMode, workInProgress.lastEffect); + break; + } + + case 'backwards': + { + // We're going to find the first row that has existing content. + // At the same time we're going to reverse the list of everything + // we pass in the meantime. That's going to be our tail in reverse + // order. + var _tail = null; + var row = workInProgress.child; + workInProgress.child = null; + + while (row !== null) { + var currentRow = row.alternate; // New rows can't be content rows. + + if (currentRow !== null && findFirstSuspended(currentRow) === null) { + // This is the beginning of the main content. + workInProgress.child = row; + break; + } + + var nextRow = row.sibling; + row.sibling = _tail; + _tail = row; + row = nextRow; + } // TODO: If workInProgress.child is null, we can continue on the tail immediately. + + + initSuspenseListRenderState(workInProgress, true, // isBackwards + _tail, null, // last + tailMode, workInProgress.lastEffect); + break; + } + + case 'together': + { + initSuspenseListRenderState(workInProgress, false, // isBackwards + null, // tail + null, // last + undefined, workInProgress.lastEffect); + break; + } + + default: + { + // The default reveal order is the same as not having + // a boundary. + workInProgress.memoizedState = null; + } + } + } + + return workInProgress.child; + } + + function updatePortalComponent(current, workInProgress, renderLanes) { + pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo); + var nextChildren = workInProgress.pendingProps; + + if (current === null) { + // Portals are special because we don't append the children during mount + // but at commit. Therefore we need to track insertions which the normal + // flow doesn't do during mount. This doesn't happen at the root because + // the root always starts with a "current" with a null child. + // TODO: Consider unifying this with how the root works. + workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderLanes); + } else { + reconcileChildren(current, workInProgress, nextChildren, renderLanes); + } + + return workInProgress.child; + } + + var hasWarnedAboutUsingNoValuePropOnContextProvider = false; + + function updateContextProvider(current, workInProgress, renderLanes) { + var providerType = workInProgress.type; + var context = providerType._context; + var newProps = workInProgress.pendingProps; + var oldProps = workInProgress.memoizedProps; + var newValue = newProps.value; + + { + if (!('value' in newProps)) { + if (!hasWarnedAboutUsingNoValuePropOnContextProvider) { + hasWarnedAboutUsingNoValuePropOnContextProvider = true; + + error('The `value` prop is required for the `<Context.Provider>`. Did you misspell it or forget to pass it?'); + } + } + + var providerPropTypes = workInProgress.type.propTypes; + + if (providerPropTypes) { + checkPropTypes(providerPropTypes, newProps, 'prop', 'Context.Provider'); + } + } + + pushProvider(workInProgress, newValue); + + if (oldProps !== null) { + var oldValue = oldProps.value; + var changedBits = calculateChangedBits(context, newValue, oldValue); + + if (changedBits === 0) { + // No change. Bailout early if children are the same. + if (oldProps.children === newProps.children && !hasContextChanged()) { + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + } + } else { + // The context value changed. Search for matching consumers and schedule + // them to update. + propagateContextChange(workInProgress, context, changedBits, renderLanes); + } + } + + var newChildren = newProps.children; + reconcileChildren(current, workInProgress, newChildren, renderLanes); + return workInProgress.child; + } + + var hasWarnedAboutUsingContextAsConsumer = false; + + function updateContextConsumer(current, workInProgress, renderLanes) { + var context = workInProgress.type; // The logic below for Context differs depending on PROD or DEV mode. In + // DEV mode, we create a separate object for Context.Consumer that acts + // like a proxy to Context. This proxy object adds unnecessary code in PROD + // so we use the old behaviour (Context.Consumer references Context) to + // reduce size and overhead. The separate object references context via + // a property called "_context", which also gives us the ability to check + // in DEV mode if this property exists or not and warn if it does not. + + { + if (context._context === undefined) { + // This may be because it's a Context (rather than a Consumer). + // Or it may be because it's older React where they're the same thing. + // We only want to warn if we're sure it's a new React. + if (context !== context.Consumer) { + if (!hasWarnedAboutUsingContextAsConsumer) { + hasWarnedAboutUsingContextAsConsumer = true; + + error('Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?'); + } + } + } else { + context = context._context; + } + } + + var newProps = workInProgress.pendingProps; + var render = newProps.children; + + { + if (typeof render !== 'function') { + error('A context consumer was rendered with multiple children, or a child ' + "that isn't a function. A context consumer expects a single child " + 'that is a function. If you did pass a function, make sure there ' + 'is no trailing or leading whitespace around it.'); + } + } + + prepareToReadContext(workInProgress, renderLanes); + var newValue = readContext(context, newProps.unstable_observedBits); + var newChildren; + + { + ReactCurrentOwner$1.current = workInProgress; + setIsRendering(true); + newChildren = render(newValue); + setIsRendering(false); + } // React DevTools reads this flag. + + + workInProgress.flags |= PerformedWork; + reconcileChildren(current, workInProgress, newChildren, renderLanes); + return workInProgress.child; + } + + function markWorkInProgressReceivedUpdate() { + didReceiveUpdate = true; + } + + function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) { + if (current !== null) { + // Reuse previous dependencies + workInProgress.dependencies = current.dependencies; + } + + { + // Don't update "base" render times for bailouts. + stopProfilerTimerIfRunning(); + } + + markSkippedUpdateLanes(workInProgress.lanes); // Check if the children have any pending work. + + if (!includesSomeLane(renderLanes, workInProgress.childLanes)) { + // The children don't have any work either. We can skip them. + // TODO: Once we add back resuming, we should check if the children are + // a work-in-progress set. If so, we need to transfer their effects. + return null; + } else { + // This fiber doesn't have work, but its subtree does. Clone the child + // fibers and continue. + cloneChildFibers(current, workInProgress); + return workInProgress.child; + } + } + + function remountFiber(current, oldWorkInProgress, newWorkInProgress) { + { + var returnFiber = oldWorkInProgress.return; + + if (returnFiber === null) { + throw new Error('Cannot swap the root fiber.'); + } // Disconnect from the old current. + // It will get deleted. + + + current.alternate = null; + oldWorkInProgress.alternate = null; // Connect to the new tree. + + newWorkInProgress.index = oldWorkInProgress.index; + newWorkInProgress.sibling = oldWorkInProgress.sibling; + newWorkInProgress.return = oldWorkInProgress.return; + newWorkInProgress.ref = oldWorkInProgress.ref; // Replace the child/sibling pointers above it. + + if (oldWorkInProgress === returnFiber.child) { + returnFiber.child = newWorkInProgress; + } else { + var prevSibling = returnFiber.child; + + if (prevSibling === null) { + throw new Error('Expected parent to have a child.'); + } + + while (prevSibling.sibling !== oldWorkInProgress) { + prevSibling = prevSibling.sibling; + + if (prevSibling === null) { + throw new Error('Expected to find the previous sibling.'); + } + } + + prevSibling.sibling = newWorkInProgress; + } // Delete the old fiber and place the new one. + // Since the old fiber is disconnected, we have to schedule it manually. + + + var last = returnFiber.lastEffect; + + if (last !== null) { + last.nextEffect = current; + returnFiber.lastEffect = current; + } else { + returnFiber.firstEffect = returnFiber.lastEffect = current; + } + + current.nextEffect = null; + current.flags = Deletion; + newWorkInProgress.flags |= Placement; // Restart work from the new fiber. + + return newWorkInProgress; + } + } + + function beginWork(current, workInProgress, renderLanes) { + var updateLanes = workInProgress.lanes; + + { + if (workInProgress._debugNeedsRemount && current !== null) { + // This will restart the begin phase with a new fiber. + return remountFiber(current, workInProgress, createFiberFromTypeAndProps(workInProgress.type, workInProgress.key, workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, workInProgress.lanes)); + } + } + + if (current !== null) { + var oldProps = current.memoizedProps; + var newProps = workInProgress.pendingProps; + + if (oldProps !== newProps || hasContextChanged() || ( // Force a re-render if the implementation changed due to hot reload: + workInProgress.type !== current.type )) { + // If props or context changed, mark the fiber as having performed work. + // This may be unset if the props are determined to be equal later (memo). + didReceiveUpdate = true; + } else if (!includesSomeLane(renderLanes, updateLanes)) { + didReceiveUpdate = false; // This fiber does not have any pending work. Bailout without entering + // the begin phase. There's still some bookkeeping we that needs to be done + // in this optimized path, mostly pushing stuff onto the stack. + + switch (workInProgress.tag) { + case HostRoot: + pushHostRootContext(workInProgress); + resetHydrationState(); + break; + + case HostComponent: + pushHostContext(workInProgress); + break; + + case ClassComponent: + { + var Component = workInProgress.type; + + if (isContextProvider(Component)) { + pushContextProvider(workInProgress); + } + + break; + } + + case HostPortal: + pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo); + break; + + case ContextProvider: + { + var newValue = workInProgress.memoizedProps.value; + pushProvider(workInProgress, newValue); + break; + } + + case Profiler: + { + // Profiler should only call onRender when one of its descendants actually rendered. + var hasChildWork = includesSomeLane(renderLanes, workInProgress.childLanes); + + if (hasChildWork) { + workInProgress.flags |= Update; + } // Reset effect durations for the next eventual effect phase. + // These are reset during render to allow the DevTools commit hook a chance to read them, + + + var stateNode = workInProgress.stateNode; + stateNode.effectDuration = 0; + stateNode.passiveEffectDuration = 0; + } + + break; + + case SuspenseComponent: + { + var state = workInProgress.memoizedState; + + if (state !== null) { + // whether to retry the primary children, or to skip over it and + // go straight to the fallback. Check the priority of the primary + // child fragment. + + + var primaryChildFragment = workInProgress.child; + var primaryChildLanes = primaryChildFragment.childLanes; + + if (includesSomeLane(renderLanes, primaryChildLanes)) { + // The primary children have pending work. Use the normal path + // to attempt to render the primary children again. + return updateSuspenseComponent(current, workInProgress, renderLanes); + } else { + // The primary child fragment does not have pending work marked + // on it + pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); // The primary children do not have pending work with sufficient + // priority. Bailout. + + var child = bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + + if (child !== null) { + // The fallback children have pending work. Skip over the + // primary children and work on the fallback. + return child.sibling; + } else { + return null; + } + } + } else { + pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); + } + + break; + } + + case SuspenseListComponent: + { + var didSuspendBefore = (current.flags & DidCapture) !== NoFlags; + + var _hasChildWork = includesSomeLane(renderLanes, workInProgress.childLanes); + + if (didSuspendBefore) { + if (_hasChildWork) { + // If something was in fallback state last time, and we have all the + // same children then we're still in progressive loading state. + // Something might get unblocked by state updates or retries in the + // tree which will affect the tail. So we need to use the normal + // path to compute the correct tail. + return updateSuspenseListComponent(current, workInProgress, renderLanes); + } // If none of the children had any work, that means that none of + // them got retried so they'll still be blocked in the same way + // as before. We can fast bail out. + + + workInProgress.flags |= DidCapture; + } // If nothing suspended before and we're rendering the same children, + // then the tail doesn't matter. Anything new that suspends will work + // in the "together" mode, so we can continue from the state we had. + + + var renderState = workInProgress.memoizedState; + + if (renderState !== null) { + // Reset to the "together" mode in case we've started a different + // update in the past but didn't complete it. + renderState.rendering = null; + renderState.tail = null; + renderState.lastEffect = null; + } + + pushSuspenseContext(workInProgress, suspenseStackCursor.current); + + if (_hasChildWork) { + break; + } else { + // If none of the children had any work, that means that none of + // them got retried so they'll still be blocked in the same way + // as before. We can fast bail out. + return null; + } + } + + case OffscreenComponent: + case LegacyHiddenComponent: + { + // Need to check if the tree still needs to be deferred. This is + // almost identical to the logic used in the normal update path, + // so we'll just enter that. The only difference is we'll bail out + // at the next level instead of this one, because the child props + // have not changed. Which is fine. + // TODO: Probably should refactor `beginWork` to split the bailout + // path from the normal path. I'm tempted to do a labeled break here + // but I won't :) + workInProgress.lanes = NoLanes; + return updateOffscreenComponent(current, workInProgress, renderLanes); + } + } + + return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + } else { + if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) { + // This is a special case that only exists for legacy mode. + // See https://github.com/facebook/react/pull/19216. + didReceiveUpdate = true; + } else { + // An update was scheduled on this fiber, but there are no new props + // nor legacy context. Set this to false. If an update queue or context + // consumer produces a changed value, it will set this to true. Otherwise, + // the component will assume the children have not changed and bail out. + didReceiveUpdate = false; + } + } + } else { + didReceiveUpdate = false; + } // Before entering the begin phase, clear pending update priority. + // TODO: This assumes that we're about to evaluate the component and process + // the update queue. However, there's an exception: SimpleMemoComponent + // sometimes bails out later in the begin phase. This indicates that we should + // move this assignment out of the common path and into each branch. + + + workInProgress.lanes = NoLanes; + + switch (workInProgress.tag) { + case IndeterminateComponent: + { + return mountIndeterminateComponent(current, workInProgress, workInProgress.type, renderLanes); + } + + case LazyComponent: + { + var elementType = workInProgress.elementType; + return mountLazyComponent(current, workInProgress, elementType, updateLanes, renderLanes); + } + + case FunctionComponent: + { + var _Component = workInProgress.type; + var unresolvedProps = workInProgress.pendingProps; + var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps); + return updateFunctionComponent(current, workInProgress, _Component, resolvedProps, renderLanes); + } + + case ClassComponent: + { + var _Component2 = workInProgress.type; + var _unresolvedProps = workInProgress.pendingProps; + + var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps); + + return updateClassComponent(current, workInProgress, _Component2, _resolvedProps, renderLanes); + } + + case HostRoot: + return updateHostRoot(current, workInProgress, renderLanes); + + case HostComponent: + return updateHostComponent(current, workInProgress, renderLanes); + + case HostText: + return updateHostText(current, workInProgress); + + case SuspenseComponent: + return updateSuspenseComponent(current, workInProgress, renderLanes); + + case HostPortal: + return updatePortalComponent(current, workInProgress, renderLanes); + + case ForwardRef: + { + var type = workInProgress.type; + var _unresolvedProps2 = workInProgress.pendingProps; + + var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2); + + return updateForwardRef(current, workInProgress, type, _resolvedProps2, renderLanes); + } + + case Fragment: + return updateFragment(current, workInProgress, renderLanes); + + case Mode: + return updateMode(current, workInProgress, renderLanes); + + case Profiler: + return updateProfiler(current, workInProgress, renderLanes); + + case ContextProvider: + return updateContextProvider(current, workInProgress, renderLanes); + + case ContextConsumer: + return updateContextConsumer(current, workInProgress, renderLanes); + + case MemoComponent: + { + var _type2 = workInProgress.type; + var _unresolvedProps3 = workInProgress.pendingProps; // Resolve outer props first, then resolve inner props. + + var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3); + + { + if (workInProgress.type !== workInProgress.elementType) { + var outerPropTypes = _type2.propTypes; + + if (outerPropTypes) { + checkPropTypes(outerPropTypes, _resolvedProps3, // Resolved for outer only + 'prop', getComponentName(_type2)); + } + } + } + + _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3); + return updateMemoComponent(current, workInProgress, _type2, _resolvedProps3, updateLanes, renderLanes); + } + + case SimpleMemoComponent: + { + return updateSimpleMemoComponent(current, workInProgress, workInProgress.type, workInProgress.pendingProps, updateLanes, renderLanes); + } + + case IncompleteClassComponent: + { + var _Component3 = workInProgress.type; + var _unresolvedProps4 = workInProgress.pendingProps; + + var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4); + + return mountIncompleteClassComponent(current, workInProgress, _Component3, _resolvedProps4, renderLanes); + } + + case SuspenseListComponent: + { + return updateSuspenseListComponent(current, workInProgress, renderLanes); + } + + case FundamentalComponent: + { + + break; + } + + case ScopeComponent: + { + + break; + } + + case Block: + { + + break; + } + + case OffscreenComponent: + { + return updateOffscreenComponent(current, workInProgress, renderLanes); + } + + case LegacyHiddenComponent: + { + return updateLegacyHiddenComponent(current, workInProgress, renderLanes); + } + } + + { + { + throw Error( "Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue." ); + } + } + } + + function markUpdate(workInProgress) { + // Tag the fiber with an update effect. This turns a Placement into + // a PlacementAndUpdate. + workInProgress.flags |= Update; + } + + function markRef$1(workInProgress) { + workInProgress.flags |= Ref; + } + + var appendAllChildren; + var updateHostContainer; + var updateHostComponent$1; + var updateHostText$1; + + { + // Mutation mode + appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) { + // We only have the top Fiber that was created but we need recurse down its + // children to find all the terminal nodes. + var node = workInProgress.child; + + while (node !== null) { + if (node.tag === HostComponent || node.tag === HostText) { + appendInitialChild(parent, node.stateNode); + } else if (node.tag === HostPortal) ; else if (node.child !== null) { + node.child.return = node; + node = node.child; + continue; + } + + if (node === workInProgress) { + return; + } + + while (node.sibling === null) { + if (node.return === null || node.return === workInProgress) { + return; + } + + node = node.return; + } + + node.sibling.return = node.return; + node = node.sibling; + } + }; + + updateHostContainer = function (workInProgress) {// Noop + }; + + updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) { + // If we have an alternate, that means this is an update and we need to + // schedule a side-effect to do the updates. + var oldProps = current.memoizedProps; + + if (oldProps === newProps) { + // In mutation mode, this is sufficient for a bailout because + // we won't touch this node even if children changed. + return; + } // If we get updated because one of our children updated, we don't + // have newProps so we'll have to reuse them. + // TODO: Split the update API as separate for the props vs. children. + // Even better would be if children weren't special cased at all tho. + + + var instance = workInProgress.stateNode; + var currentHostContext = getHostContext(); // TODO: Experiencing an error where oldProps is null. Suggests a host + // component is hitting the resume path. Figure out why. Possibly + // related to `hidden`. + + var updatePayload = prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, currentHostContext); // TODO: Type this specific to this type of component. + + workInProgress.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there + // is a new ref we mark this as an update. All the work is done in commitWork. + + if (updatePayload) { + markUpdate(workInProgress); + } + }; + + updateHostText$1 = function (current, workInProgress, oldText, newText) { + // If the text differs, mark it as an update. All the work in done in commitWork. + if (oldText !== newText) { + markUpdate(workInProgress); + } + }; + } + + function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { + if (getIsHydrating()) { + // If we're hydrating, we should consume as many items as we can + // so we don't leave any behind. + return; + } + + switch (renderState.tailMode) { + case 'hidden': + { + // Any insertions at the end of the tail list after this point + // should be invisible. If there are already mounted boundaries + // anything before them are not considered for collapsing. + // Therefore we need to go through the whole tail to find if + // there are any. + var tailNode = renderState.tail; + var lastTailNode = null; + + while (tailNode !== null) { + if (tailNode.alternate !== null) { + lastTailNode = tailNode; + } + + tailNode = tailNode.sibling; + } // Next we're simply going to delete all insertions after the + // last rendered item. + + + if (lastTailNode === null) { + // All remaining items in the tail are insertions. + renderState.tail = null; + } else { + // Detach the insertion after the last node that was already + // inserted. + lastTailNode.sibling = null; + } + + break; + } + + case 'collapsed': + { + // Any insertions at the end of the tail list after this point + // should be invisible. If there are already mounted boundaries + // anything before them are not considered for collapsing. + // Therefore we need to go through the whole tail to find if + // there are any. + var _tailNode = renderState.tail; + var _lastTailNode = null; + + while (_tailNode !== null) { + if (_tailNode.alternate !== null) { + _lastTailNode = _tailNode; + } + + _tailNode = _tailNode.sibling; + } // Next we're simply going to delete all insertions after the + // last rendered item. + + + if (_lastTailNode === null) { + // All remaining items in the tail are insertions. + if (!hasRenderedATailFallback && renderState.tail !== null) { + // We suspended during the head. We want to show at least one + // row at the tail. So we'll keep on and cut off the rest. + renderState.tail.sibling = null; + } else { + renderState.tail = null; + } + } else { + // Detach the insertion after the last node that was already + // inserted. + _lastTailNode.sibling = null; + } + + break; + } + } + } + + function completeWork(current, workInProgress, renderLanes) { + var newProps = workInProgress.pendingProps; + + switch (workInProgress.tag) { + case IndeterminateComponent: + case LazyComponent: + case SimpleMemoComponent: + case FunctionComponent: + case ForwardRef: + case Fragment: + case Mode: + case Profiler: + case ContextConsumer: + case MemoComponent: + return null; + + case ClassComponent: + { + var Component = workInProgress.type; + + if (isContextProvider(Component)) { + popContext(workInProgress); + } + + return null; + } + + case HostRoot: + { + popHostContainer(workInProgress); + popTopLevelContextObject(workInProgress); + resetWorkInProgressVersions(); + var fiberRoot = workInProgress.stateNode; + + if (fiberRoot.pendingContext) { + fiberRoot.context = fiberRoot.pendingContext; + fiberRoot.pendingContext = null; + } + + if (current === null || current.child === null) { + // If we hydrated, pop so that we can delete any remaining children + // that weren't hydrated. + var wasHydrated = popHydrationState(workInProgress); + + if (wasHydrated) { + // If we hydrated, then we'll need to schedule an update for + // the commit side-effects on the root. + markUpdate(workInProgress); + } else if (!fiberRoot.hydrate) { + // Schedule an effect to clear this container at the start of the next commit. + // This handles the case of React rendering into a container with previous children. + // It's also safe to do for updates too, because current.child would only be null + // if the previous render was null (so the the container would already be empty). + workInProgress.flags |= Snapshot; + } + } + + updateHostContainer(workInProgress); + return null; + } + + case HostComponent: + { + popHostContext(workInProgress); + var rootContainerInstance = getRootHostContainer(); + var type = workInProgress.type; + + if (current !== null && workInProgress.stateNode != null) { + updateHostComponent$1(current, workInProgress, type, newProps, rootContainerInstance); + + if (current.ref !== workInProgress.ref) { + markRef$1(workInProgress); + } + } else { + if (!newProps) { + if (!(workInProgress.stateNode !== null)) { + { + throw Error( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); + } + } // This can happen when we abort work. + + + return null; + } + + var currentHostContext = getHostContext(); // TODO: Move createInstance to beginWork and keep it on a context + // "stack" as the parent. Then append children as we go in beginWork + // or completeWork depending on whether we want to add them top->down or + // bottom->up. Top->down is faster in IE11. + + var _wasHydrated = popHydrationState(workInProgress); + + if (_wasHydrated) { + // TODO: Move this and createInstance step into the beginPhase + // to consolidate. + if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, currentHostContext)) { + // If changes to the hydrated node need to be applied at the + // commit-phase we mark this as such. + markUpdate(workInProgress); + } + } else { + var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress); + appendAllChildren(instance, workInProgress, false, false); + workInProgress.stateNode = instance; // Certain renderers require commit-time effects for initial mount. + // (eg DOM renderer supports auto-focus for certain elements). + // Make sure such renderers get scheduled for later work. + + if (finalizeInitialChildren(instance, type, newProps, rootContainerInstance)) { + markUpdate(workInProgress); + } + } + + if (workInProgress.ref !== null) { + // If there is a ref on a host node we need to schedule a callback + markRef$1(workInProgress); + } + } + + return null; + } + + case HostText: + { + var newText = newProps; + + if (current && workInProgress.stateNode != null) { + var oldText = current.memoizedProps; // If we have an alternate, that means this is an update and we need + // to schedule a side-effect to do the updates. + + updateHostText$1(current, workInProgress, oldText, newText); + } else { + if (typeof newText !== 'string') { + if (!(workInProgress.stateNode !== null)) { + { + throw Error( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); + } + } // This can happen when we abort work. + + } + + var _rootContainerInstance = getRootHostContainer(); + + var _currentHostContext = getHostContext(); + + var _wasHydrated2 = popHydrationState(workInProgress); + + if (_wasHydrated2) { + if (prepareToHydrateHostTextInstance(workInProgress)) { + markUpdate(workInProgress); + } + } else { + workInProgress.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext, workInProgress); + } + } + + return null; + } + + case SuspenseComponent: + { + popSuspenseContext(workInProgress); + var nextState = workInProgress.memoizedState; + + if ((workInProgress.flags & DidCapture) !== NoFlags) { + // Something suspended. Re-render with the fallback children. + workInProgress.lanes = renderLanes; // Do not reset the effect list. + + if ( (workInProgress.mode & ProfileMode) !== NoMode) { + transferActualDuration(workInProgress); + } + + return workInProgress; + } + + var nextDidTimeout = nextState !== null; + var prevDidTimeout = false; + + if (current === null) { + if (workInProgress.memoizedProps.fallback !== undefined) { + popHydrationState(workInProgress); + } + } else { + var prevState = current.memoizedState; + prevDidTimeout = prevState !== null; + } + + if (nextDidTimeout && !prevDidTimeout) { + // If this subtreee is running in blocking mode we can suspend, + // otherwise we won't suspend. + // TODO: This will still suspend a synchronous tree if anything + // in the concurrent tree already suspended during this render. + // This is a known bug. + if ((workInProgress.mode & BlockingMode) !== NoMode) { + // TODO: Move this back to throwException because this is too late + // if this is a large tree which is common for initial loads. We + // don't know if we should restart a render or not until we get + // this marker, and this is too late. + // If this render already had a ping or lower pri updates, + // and this is the first time we know we're going to suspend we + // should be able to immediately restart from within throwException. + var hasInvisibleChildContext = current === null && workInProgress.memoizedProps.unstable_avoidThisFallback !== true; + + if (hasInvisibleChildContext || hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext)) { + // If this was in an invisible tree or a new render, then showing + // this boundary is ok. + renderDidSuspend(); + } else { + // Otherwise, we're going to have to hide content so we should + // suspend for longer if possible. + renderDidSuspendDelayIfPossible(); + } + } + } + + { + // TODO: Only schedule updates if these values are non equal, i.e. it changed. + if (nextDidTimeout || prevDidTimeout) { + // If this boundary just timed out, schedule an effect to attach a + // retry listener to the promise. This flag is also used to hide the + // primary children. In mutation mode, we also need the flag to + // *unhide* children that were previously hidden, so check if this + // is currently timed out, too. + workInProgress.flags |= Update; + } + } + + return null; + } + + case HostPortal: + popHostContainer(workInProgress); + updateHostContainer(workInProgress); + + if (current === null) { + preparePortalMount(workInProgress.stateNode.containerInfo); + } + + return null; + + case ContextProvider: + // Pop provider fiber + popProvider(workInProgress); + return null; + + case IncompleteClassComponent: + { + // Same as class component case. I put it down here so that the tags are + // sequential to ensure this switch is compiled to a jump table. + var _Component = workInProgress.type; + + if (isContextProvider(_Component)) { + popContext(workInProgress); + } + + return null; + } + + case SuspenseListComponent: + { + popSuspenseContext(workInProgress); + var renderState = workInProgress.memoizedState; + + if (renderState === null) { + // We're running in the default, "independent" mode. + // We don't do anything in this mode. + return null; + } + + var didSuspendAlready = (workInProgress.flags & DidCapture) !== NoFlags; + var renderedTail = renderState.rendering; + + if (renderedTail === null) { + // We just rendered the head. + if (!didSuspendAlready) { + // This is the first pass. We need to figure out if anything is still + // suspended in the rendered set. + // If new content unsuspended, but there's still some content that + // didn't. Then we need to do a second pass that forces everything + // to keep showing their fallbacks. + // We might be suspended if something in this render pass suspended, or + // something in the previous committed pass suspended. Otherwise, + // there's no chance so we can skip the expensive call to + // findFirstSuspended. + var cannotBeSuspended = renderHasNotSuspendedYet() && (current === null || (current.flags & DidCapture) === NoFlags); + + if (!cannotBeSuspended) { + var row = workInProgress.child; + + while (row !== null) { + var suspended = findFirstSuspended(row); + + if (suspended !== null) { + didSuspendAlready = true; + workInProgress.flags |= DidCapture; + cutOffTailIfNeeded(renderState, false); // If this is a newly suspended tree, it might not get committed as + // part of the second pass. In that case nothing will subscribe to + // its thennables. Instead, we'll transfer its thennables to the + // SuspenseList so that it can retry if they resolve. + // There might be multiple of these in the list but since we're + // going to wait for all of them anyway, it doesn't really matter + // which ones gets to ping. In theory we could get clever and keep + // track of how many dependencies remain but it gets tricky because + // in the meantime, we can add/remove/change items and dependencies. + // We might bail out of the loop before finding any but that + // doesn't matter since that means that the other boundaries that + // we did find already has their listeners attached. + + var newThennables = suspended.updateQueue; + + if (newThennables !== null) { + workInProgress.updateQueue = newThennables; + workInProgress.flags |= Update; + } // Rerender the whole list, but this time, we'll force fallbacks + // to stay in place. + // Reset the effect list before doing the second pass since that's now invalid. + + + if (renderState.lastEffect === null) { + workInProgress.firstEffect = null; + } + + workInProgress.lastEffect = renderState.lastEffect; // Reset the child fibers to their original state. + + resetChildFibers(workInProgress, renderLanes); // Set up the Suspense Context to force suspense and immediately + // rerender the children. + + pushSuspenseContext(workInProgress, setShallowSuspenseContext(suspenseStackCursor.current, ForceSuspenseFallback)); + return workInProgress.child; + } + + row = row.sibling; + } + } + + if (renderState.tail !== null && now() > getRenderTargetTime()) { + // We have already passed our CPU deadline but we still have rows + // left in the tail. We'll just give up further attempts to render + // the main content and only render fallbacks. + workInProgress.flags |= DidCapture; + didSuspendAlready = true; + cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this + // to get it started back up to attempt the next item. While in terms + // of priority this work has the same priority as this current render, + // it's not part of the same transition once the transition has + // committed. If it's sync, we still want to yield so that it can be + // painted. Conceptually, this is really the same as pinging. + // We can use any RetryLane even if it's the one currently rendering + // since we're leaving it behind on this node. + + workInProgress.lanes = SomeRetryLane; + + { + markSpawnedWork(SomeRetryLane); + } + } + } else { + cutOffTailIfNeeded(renderState, false); + } // Next we're going to render the tail. + + } else { + // Append the rendered row to the child list. + if (!didSuspendAlready) { + var _suspended = findFirstSuspended(renderedTail); + + if (_suspended !== null) { + workInProgress.flags |= DidCapture; + didSuspendAlready = true; // Ensure we transfer the update queue to the parent so that it doesn't + // get lost if this row ends up dropped during a second pass. + + var _newThennables = _suspended.updateQueue; + + if (_newThennables !== null) { + workInProgress.updateQueue = _newThennables; + workInProgress.flags |= Update; + } + + cutOffTailIfNeeded(renderState, true); // This might have been modified. + + if (renderState.tail === null && renderState.tailMode === 'hidden' && !renderedTail.alternate && !getIsHydrating() // We don't cut it if we're hydrating. + ) { + // We need to delete the row we just rendered. + // Reset the effect list to what it was before we rendered this + // child. The nested children have already appended themselves. + var lastEffect = workInProgress.lastEffect = renderState.lastEffect; // Remove any effects that were appended after this point. + + if (lastEffect !== null) { + lastEffect.nextEffect = null; + } // We're done. + + + return null; + } + } else if ( // The time it took to render last row is greater than the remaining + // time we have to render. So rendering one more row would likely + // exceed it. + now() * 2 - renderState.renderingStartTime > getRenderTargetTime() && renderLanes !== OffscreenLane) { + // We have now passed our CPU deadline and we'll just give up further + // attempts to render the main content and only render fallbacks. + // The assumption is that this is usually faster. + workInProgress.flags |= DidCapture; + didSuspendAlready = true; + cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this + // to get it started back up to attempt the next item. While in terms + // of priority this work has the same priority as this current render, + // it's not part of the same transition once the transition has + // committed. If it's sync, we still want to yield so that it can be + // painted. Conceptually, this is really the same as pinging. + // We can use any RetryLane even if it's the one currently rendering + // since we're leaving it behind on this node. + + workInProgress.lanes = SomeRetryLane; + + { + markSpawnedWork(SomeRetryLane); + } + } + } + + if (renderState.isBackwards) { + // The effect list of the backwards tail will have been added + // to the end. This breaks the guarantee that life-cycles fire in + // sibling order but that isn't a strong guarantee promised by React. + // Especially since these might also just pop in during future commits. + // Append to the beginning of the list. + renderedTail.sibling = workInProgress.child; + workInProgress.child = renderedTail; + } else { + var previousSibling = renderState.last; + + if (previousSibling !== null) { + previousSibling.sibling = renderedTail; + } else { + workInProgress.child = renderedTail; + } + + renderState.last = renderedTail; + } + } + + if (renderState.tail !== null) { + // We still have tail rows to render. + // Pop a row. + var next = renderState.tail; + renderState.rendering = next; + renderState.tail = next.sibling; + renderState.lastEffect = workInProgress.lastEffect; + renderState.renderingStartTime = now(); + next.sibling = null; // Restore the context. + // TODO: We can probably just avoid popping it instead and only + // setting it the first time we go from not suspended to suspended. + + var suspenseContext = suspenseStackCursor.current; + + if (didSuspendAlready) { + suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback); + } else { + suspenseContext = setDefaultShallowSuspenseContext(suspenseContext); + } + + pushSuspenseContext(workInProgress, suspenseContext); // Do a pass over the next row. + + return next; + } + + return null; + } + + case FundamentalComponent: + { + + break; + } + + case ScopeComponent: + { + + break; + } + + case Block: + + break; + + case OffscreenComponent: + case LegacyHiddenComponent: + { + popRenderLanes(workInProgress); + + if (current !== null) { + var _nextState = workInProgress.memoizedState; + var _prevState = current.memoizedState; + var prevIsHidden = _prevState !== null; + var nextIsHidden = _nextState !== null; + + if (prevIsHidden !== nextIsHidden && newProps.mode !== 'unstable-defer-without-hiding') { + workInProgress.flags |= Update; + } + } + + return null; + } + } + + { + { + throw Error( "Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue." ); + } + } + } + + function unwindWork(workInProgress, renderLanes) { + switch (workInProgress.tag) { + case ClassComponent: + { + var Component = workInProgress.type; + + if (isContextProvider(Component)) { + popContext(workInProgress); + } + + var flags = workInProgress.flags; + + if (flags & ShouldCapture) { + workInProgress.flags = flags & ~ShouldCapture | DidCapture; + + if ( (workInProgress.mode & ProfileMode) !== NoMode) { + transferActualDuration(workInProgress); + } + + return workInProgress; + } + + return null; + } + + case HostRoot: + { + popHostContainer(workInProgress); + popTopLevelContextObject(workInProgress); + resetWorkInProgressVersions(); + var _flags = workInProgress.flags; + + if (!((_flags & DidCapture) === NoFlags)) { + { + throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ); + } + } + + workInProgress.flags = _flags & ~ShouldCapture | DidCapture; + return workInProgress; + } + + case HostComponent: + { + // TODO: popHydrationState + popHostContext(workInProgress); + return null; + } + + case SuspenseComponent: + { + popSuspenseContext(workInProgress); + + var _flags2 = workInProgress.flags; + + if (_flags2 & ShouldCapture) { + workInProgress.flags = _flags2 & ~ShouldCapture | DidCapture; // Captured a suspense effect. Re-render the boundary. + + if ( (workInProgress.mode & ProfileMode) !== NoMode) { + transferActualDuration(workInProgress); + } + + return workInProgress; + } + + return null; + } + + case SuspenseListComponent: + { + popSuspenseContext(workInProgress); // SuspenseList doesn't actually catch anything. It should've been + // caught by a nested boundary. If not, it should bubble through. + + return null; + } + + case HostPortal: + popHostContainer(workInProgress); + return null; + + case ContextProvider: + popProvider(workInProgress); + return null; + + case OffscreenComponent: + case LegacyHiddenComponent: + popRenderLanes(workInProgress); + return null; + + default: + return null; + } + } + + function unwindInterruptedWork(interruptedWork) { + switch (interruptedWork.tag) { + case ClassComponent: + { + var childContextTypes = interruptedWork.type.childContextTypes; + + if (childContextTypes !== null && childContextTypes !== undefined) { + popContext(interruptedWork); + } + + break; + } + + case HostRoot: + { + popHostContainer(interruptedWork); + popTopLevelContextObject(interruptedWork); + resetWorkInProgressVersions(); + break; + } + + case HostComponent: + { + popHostContext(interruptedWork); + break; + } + + case HostPortal: + popHostContainer(interruptedWork); + break; + + case SuspenseComponent: + popSuspenseContext(interruptedWork); + break; + + case SuspenseListComponent: + popSuspenseContext(interruptedWork); + break; + + case ContextProvider: + popProvider(interruptedWork); + break; + + case OffscreenComponent: + case LegacyHiddenComponent: + popRenderLanes(interruptedWork); + break; + } + } + + function createCapturedValue(value, source) { + // If the value is an error, call this function immediately after it is thrown + // so the stack is accurate. + return { + value: value, + source: source, + stack: getStackByFiberInDevAndProd(source) + }; + } + + // This module is forked in different environments. + // By default, return `true` to log errors to the console. + // Forks can return `false` if this isn't desirable. + function showErrorDialog(boundary, errorInfo) { + return true; + } + + function logCapturedError(boundary, errorInfo) { + try { + var logError = showErrorDialog(boundary, errorInfo); // Allow injected showErrorDialog() to prevent default console.error logging. + // This enables renderers like ReactNative to better manage redbox behavior. + + if (logError === false) { + return; + } + + var error = errorInfo.value; + + if (true) { + var source = errorInfo.source; + var stack = errorInfo.stack; + var componentStack = stack !== null ? stack : ''; // Browsers support silencing uncaught errors by calling + // `preventDefault()` in window `error` handler. + // We record this information as an expando on the error. + + if (error != null && error._suppressLogging) { + if (boundary.tag === ClassComponent) { + // The error is recoverable and was silenced. + // Ignore it and don't print the stack addendum. + // This is handy for testing error boundaries without noise. + return; + } // The error is fatal. Since the silencing might have + // been accidental, we'll surface it anyway. + // However, the browser would have silenced the original error + // so we'll print it first, and then print the stack addendum. + + + console['error'](error); // Don't transform to our wrapper + // For a more detailed description of this block, see: + // https://github.com/facebook/react/pull/13384 + } + + var componentName = source ? getComponentName(source.type) : null; + var componentNameMessage = componentName ? "The above error occurred in the <" + componentName + "> component:" : 'The above error occurred in one of your React components:'; + var errorBoundaryMessage; + var errorBoundaryName = getComponentName(boundary.type); + + if (errorBoundaryName) { + errorBoundaryMessage = "React will try to recreate this component tree from scratch " + ("using the error boundary you provided, " + errorBoundaryName + "."); + } else { + errorBoundaryMessage = 'Consider adding an error boundary to your tree to customize error handling behavior.\n' + 'Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.'; + } + + var combinedMessage = componentNameMessage + "\n" + componentStack + "\n\n" + ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack. + // We don't include the original error message and JS stack because the browser + // has already printed it. Even if the application swallows the error, it is still + // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils. + + console['error'](combinedMessage); // Don't transform to our wrapper + } else { + // In production, we print the error directly. + // This will include the message, the JS stack, and anything the browser wants to show. + // We pass the error object instead of custom message so that the browser displays the error natively. + console['error'](error); // Don't transform to our wrapper + } + } catch (e) { + // This method must not throw, or React internal state will get messed up. + // If console.error is overridden, or logCapturedError() shows a dialog that throws, + // we want to report this error outside of the normal stack as a last resort. + // https://github.com/facebook/react/issues/13188 + setTimeout(function () { + throw e; + }); + } + } + + var PossiblyWeakMap$1 = typeof WeakMap === 'function' ? WeakMap : Map; + + function createRootErrorUpdate(fiber, errorInfo, lane) { + var update = createUpdate(NoTimestamp, lane); // Unmount the root by rendering null. + + update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property + // being called "element". + + update.payload = { + element: null + }; + var error = errorInfo.value; + + update.callback = function () { + onUncaughtError(error); + logCapturedError(fiber, errorInfo); + }; + + return update; + } + + function createClassErrorUpdate(fiber, errorInfo, lane) { + var update = createUpdate(NoTimestamp, lane); + update.tag = CaptureUpdate; + var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + + if (typeof getDerivedStateFromError === 'function') { + var error$1 = errorInfo.value; + + update.payload = function () { + logCapturedError(fiber, errorInfo); + return getDerivedStateFromError(error$1); + }; + } + + var inst = fiber.stateNode; + + if (inst !== null && typeof inst.componentDidCatch === 'function') { + update.callback = function callback() { + { + markFailedErrorBoundaryForHotReloading(fiber); + } + + if (typeof getDerivedStateFromError !== 'function') { + // To preserve the preexisting retry behavior of error boundaries, + // we keep track of which ones already failed during this batch. + // This gets reset before we yield back to the browser. + // TODO: Warn in strict mode if getDerivedStateFromError is + // not defined. + markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined + + logCapturedError(fiber, errorInfo); + } + + var error$1 = errorInfo.value; + var stack = errorInfo.stack; + this.componentDidCatch(error$1, { + componentStack: stack !== null ? stack : '' + }); + + { + if (typeof getDerivedStateFromError !== 'function') { + // If componentDidCatch is the only error boundary method defined, + // then it needs to call setState to recover from errors. + // If no state update is scheduled then the boundary will swallow the error. + if (!includesSomeLane(fiber.lanes, SyncLane)) { + error('%s: Error boundaries should implement getDerivedStateFromError(). ' + 'In that method, return a state update to display an error message or fallback UI.', getComponentName(fiber.type) || 'Unknown'); + } + } + } + }; + } else { + update.callback = function () { + markFailedErrorBoundaryForHotReloading(fiber); + }; + } + + return update; + } + + function attachPingListener(root, wakeable, lanes) { + // Attach a listener to the promise to "ping" the root and retry. But only if + // one does not already exist for the lanes we're currently rendering (which + // acts like a "thread ID" here). + var pingCache = root.pingCache; + var threadIDs; + + if (pingCache === null) { + pingCache = root.pingCache = new PossiblyWeakMap$1(); + threadIDs = new Set(); + pingCache.set(wakeable, threadIDs); + } else { + threadIDs = pingCache.get(wakeable); + + if (threadIDs === undefined) { + threadIDs = new Set(); + pingCache.set(wakeable, threadIDs); + } + } + + if (!threadIDs.has(lanes)) { + // Memoize using the thread ID to prevent redundant listeners. + threadIDs.add(lanes); + var ping = pingSuspendedRoot.bind(null, root, wakeable, lanes); + wakeable.then(ping, ping); + } + } + + function throwException(root, returnFiber, sourceFiber, value, rootRenderLanes) { + // The source fiber did not complete. + sourceFiber.flags |= Incomplete; // Its effect list is no longer valid. + + sourceFiber.firstEffect = sourceFiber.lastEffect = null; + + if (value !== null && typeof value === 'object' && typeof value.then === 'function') { + // This is a wakeable. + var wakeable = value; + + if ((sourceFiber.mode & BlockingMode) === NoMode) { + // Reset the memoizedState to what it was before we attempted + // to render it. + var currentSource = sourceFiber.alternate; + + if (currentSource) { + sourceFiber.updateQueue = currentSource.updateQueue; + sourceFiber.memoizedState = currentSource.memoizedState; + sourceFiber.lanes = currentSource.lanes; + } else { + sourceFiber.updateQueue = null; + sourceFiber.memoizedState = null; + } + } + + var hasInvisibleParentBoundary = hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext); // Schedule the nearest Suspense to re-render the timed out view. + + var _workInProgress = returnFiber; + + do { + if (_workInProgress.tag === SuspenseComponent && shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary)) { + // Found the nearest boundary. + // Stash the promise on the boundary fiber. If the boundary times out, we'll + // attach another listener to flip the boundary back to its normal state. + var wakeables = _workInProgress.updateQueue; + + if (wakeables === null) { + var updateQueue = new Set(); + updateQueue.add(wakeable); + _workInProgress.updateQueue = updateQueue; + } else { + wakeables.add(wakeable); + } // If the boundary is outside of blocking mode, we should *not* + // suspend the commit. Pretend as if the suspended component rendered + // null and keep rendering. In the commit phase, we'll schedule a + // subsequent synchronous update to re-render the Suspense. + // + // Note: It doesn't matter whether the component that suspended was + // inside a blocking mode tree. If the Suspense is outside of it, we + // should *not* suspend the commit. + + + if ((_workInProgress.mode & BlockingMode) === NoMode) { + _workInProgress.flags |= DidCapture; + sourceFiber.flags |= ForceUpdateForLegacySuspense; // We're going to commit this fiber even though it didn't complete. + // But we shouldn't call any lifecycle methods or callbacks. Remove + // all lifecycle effect tags. + + sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete); + + if (sourceFiber.tag === ClassComponent) { + var currentSourceFiber = sourceFiber.alternate; + + if (currentSourceFiber === null) { + // This is a new mount. Change the tag so it's not mistaken for a + // completed class component. For example, we should not call + // componentWillUnmount if it is deleted. + sourceFiber.tag = IncompleteClassComponent; + } else { + // When we try rendering again, we should not reuse the current fiber, + // since it's known to be in an inconsistent state. Use a force update to + // prevent a bail out. + var update = createUpdate(NoTimestamp, SyncLane); + update.tag = ForceUpdate; + enqueueUpdate(sourceFiber, update); + } + } // The source fiber did not complete. Mark it with Sync priority to + // indicate that it still has pending work. + + + sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane); // Exit without suspending. + + return; + } // Confirmed that the boundary is in a concurrent mode tree. Continue + // with the normal suspend path. + // + // After this we'll use a set of heuristics to determine whether this + // render pass will run to completion or restart or "suspend" the commit. + // The actual logic for this is spread out in different places. + // + // This first principle is that if we're going to suspend when we complete + // a root, then we should also restart if we get an update or ping that + // might unsuspend it, and vice versa. The only reason to suspend is + // because you think you might want to restart before committing. However, + // it doesn't make sense to restart only while in the period we're suspended. + // + // Restarting too aggressively is also not good because it starves out any + // intermediate loading state. So we use heuristics to determine when. + // Suspense Heuristics + // + // If nothing threw a Promise or all the same fallbacks are already showing, + // then don't suspend/restart. + // + // If this is an initial render of a new tree of Suspense boundaries and + // those trigger a fallback, then don't suspend/restart. We want to ensure + // that we can show the initial loading state as quickly as possible. + // + // If we hit a "Delayed" case, such as when we'd switch from content back into + // a fallback, then we should always suspend/restart. Transitions apply + // to this case. If none is defined, JND is used instead. + // + // If we're already showing a fallback and it gets "retried", allowing us to show + // another level, but there's still an inner boundary that would show a fallback, + // then we suspend/restart for 500ms since the last time we showed a fallback + // anywhere in the tree. This effectively throttles progressive loading into a + // consistent train of commits. This also gives us an opportunity to restart to + // get to the completed state slightly earlier. + // + // If there's ambiguity due to batching it's resolved in preference of: + // 1) "delayed", 2) "initial render", 3) "retry". + // + // We want to ensure that a "busy" state doesn't get force committed. We want to + // ensure that new initial loading states can commit as soon as possible. + + + attachPingListener(root, wakeable, rootRenderLanes); + _workInProgress.flags |= ShouldCapture; + _workInProgress.lanes = rootRenderLanes; + return; + } // This boundary already captured during this render. Continue to the next + // boundary. + + + _workInProgress = _workInProgress.return; + } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode. + // TODO: Use invariant so the message is stripped in prod? + + + value = new Error((getComponentName(sourceFiber.type) || 'A React component') + ' suspended while rendering, but no fallback UI was specified.\n' + '\n' + 'Add a <Suspense fallback=...> component higher in the tree to ' + 'provide a loading indicator or placeholder to display.'); + } // We didn't find a boundary that could handle this type of exception. Start + // over and traverse parent path again, this time treating the exception + // as an error. + + + renderDidError(); + value = createCapturedValue(value, sourceFiber); + var workInProgress = returnFiber; + + do { + switch (workInProgress.tag) { + case HostRoot: + { + var _errorInfo = value; + workInProgress.flags |= ShouldCapture; + var lane = pickArbitraryLane(rootRenderLanes); + workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); + + var _update = createRootErrorUpdate(workInProgress, _errorInfo, lane); + + enqueueCapturedUpdate(workInProgress, _update); + return; + } + + case ClassComponent: + // Capture and retry + var errorInfo = value; + var ctor = workInProgress.type; + var instance = workInProgress.stateNode; + + if ((workInProgress.flags & DidCapture) === NoFlags && (typeof ctor.getDerivedStateFromError === 'function' || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) { + workInProgress.flags |= ShouldCapture; + + var _lane = pickArbitraryLane(rootRenderLanes); + + workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state + + var _update2 = createClassErrorUpdate(workInProgress, errorInfo, _lane); + + enqueueCapturedUpdate(workInProgress, _update2); + return; + } + + break; + } + + workInProgress = workInProgress.return; + } while (workInProgress !== null); + } + + var didWarnAboutUndefinedSnapshotBeforeUpdate = null; + + { + didWarnAboutUndefinedSnapshotBeforeUpdate = new Set(); + } + + var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set; + + var callComponentWillUnmountWithTimer = function (current, instance) { + instance.props = current.memoizedProps; + instance.state = current.memoizedState; + + { + instance.componentWillUnmount(); + } + }; // Capture errors so they don't interrupt unmounting. + + + function safelyCallComponentWillUnmount(current, instance) { + { + invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current, instance); + + if (hasCaughtError()) { + var unmountError = clearCaughtError(); + captureCommitPhaseError(current, unmountError); + } + } + } + + function safelyDetachRef(current) { + var ref = current.ref; + + if (ref !== null) { + if (typeof ref === 'function') { + { + invokeGuardedCallback(null, ref, null, null); + + if (hasCaughtError()) { + var refError = clearCaughtError(); + captureCommitPhaseError(current, refError); + } + } + } else { + ref.current = null; + } + } + } + + function safelyCallDestroy(current, destroy) { + { + invokeGuardedCallback(null, destroy, null); + + if (hasCaughtError()) { + var error = clearCaughtError(); + captureCommitPhaseError(current, error); + } + } + } + + function commitBeforeMutationLifeCycles(current, finishedWork) { + switch (finishedWork.tag) { + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: + case Block: + { + return; + } + + case ClassComponent: + { + if (finishedWork.flags & Snapshot) { + if (current !== null) { + var prevProps = current.memoizedProps; + var prevState = current.memoizedState; + var instance = finishedWork.stateNode; // We could update instance props and state here, + // but instead we rely on them being set during last render. + // TODO: revisit this when we implement resuming. + + { + if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) { + if (instance.props !== finishedWork.memoizedProps) { + error('Expected %s props to match memoized props before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); + } + + if (instance.state !== finishedWork.memoizedState) { + error('Expected %s state to match memoized state before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.state`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); + } + } + } + + var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState); + + { + var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate; + + if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) { + didWarnSet.add(finishedWork.type); + + error('%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork.type)); + } + } + + instance.__reactInternalSnapshotBeforeUpdate = snapshot; + } + } + + return; + } + + case HostRoot: + { + { + if (finishedWork.flags & Snapshot) { + var root = finishedWork.stateNode; + clearContainer(root.containerInfo); + } + } + + return; + } + + case HostComponent: + case HostText: + case HostPortal: + case IncompleteClassComponent: + // Nothing to do for these component types + return; + } + + { + { + throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); + } + } + } + + function commitHookEffectListUnmount(tag, finishedWork) { + var updateQueue = finishedWork.updateQueue; + var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; + + if (lastEffect !== null) { + var firstEffect = lastEffect.next; + var effect = firstEffect; + + do { + if ((effect.tag & tag) === tag) { + // Unmount + var destroy = effect.destroy; + effect.destroy = undefined; + + if (destroy !== undefined) { + destroy(); + } + } + + effect = effect.next; + } while (effect !== firstEffect); + } + } + + function commitHookEffectListMount(tag, finishedWork) { + var updateQueue = finishedWork.updateQueue; + var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; + + if (lastEffect !== null) { + var firstEffect = lastEffect.next; + var effect = firstEffect; + + do { + if ((effect.tag & tag) === tag) { + // Mount + var create = effect.create; + effect.destroy = create(); + + { + var destroy = effect.destroy; + + if (destroy !== undefined && typeof destroy !== 'function') { + var addendum = void 0; + + if (destroy === null) { + addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).'; + } else if (typeof destroy.then === 'function') { + addendum = '\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. ' + 'Instead, write the async function inside your effect ' + 'and call it immediately:\n\n' + 'useEffect(() => {\n' + ' async function fetchData() {\n' + ' // You can await here\n' + ' const response = await MyAPI.getData(someId);\n' + ' // ...\n' + ' }\n' + ' fetchData();\n' + "}, [someId]); // Or [] if effect doesn't need props or state\n\n" + 'Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching'; + } else { + addendum = ' You returned: ' + destroy; + } + + error('An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s', addendum); + } + } + } + + effect = effect.next; + } while (effect !== firstEffect); + } + } + + function schedulePassiveEffects(finishedWork) { + var updateQueue = finishedWork.updateQueue; + var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; + + if (lastEffect !== null) { + var firstEffect = lastEffect.next; + var effect = firstEffect; + + do { + var _effect = effect, + next = _effect.next, + tag = _effect.tag; + + if ((tag & Passive$1) !== NoFlags$1 && (tag & HasEffect) !== NoFlags$1) { + enqueuePendingPassiveHookEffectUnmount(finishedWork, effect); + enqueuePendingPassiveHookEffectMount(finishedWork, effect); + } + + effect = next; + } while (effect !== firstEffect); + } + } + + function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { + switch (finishedWork.tag) { + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: + case Block: + { + // At this point layout effects have already been destroyed (during mutation phase). + // This is done to prevent sibling component effects from interfering with each other, + // e.g. a destroy function in one component should never override a ref set + // by a create function in another component during the same commit. + { + commitHookEffectListMount(Layout | HasEffect, finishedWork); + } + + schedulePassiveEffects(finishedWork); + return; + } + + case ClassComponent: + { + var instance = finishedWork.stateNode; + + if (finishedWork.flags & Update) { + if (current === null) { + // We could update instance props and state here, + // but instead we rely on them being set during last render. + // TODO: revisit this when we implement resuming. + { + if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) { + if (instance.props !== finishedWork.memoizedProps) { + error('Expected %s props to match memoized props before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); + } + + if (instance.state !== finishedWork.memoizedState) { + error('Expected %s state to match memoized state before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.state`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); + } + } + } + + { + instance.componentDidMount(); + } + } else { + var prevProps = finishedWork.elementType === finishedWork.type ? current.memoizedProps : resolveDefaultProps(finishedWork.type, current.memoizedProps); + var prevState = current.memoizedState; // We could update instance props and state here, + // but instead we rely on them being set during last render. + // TODO: revisit this when we implement resuming. + + { + if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) { + if (instance.props !== finishedWork.memoizedProps) { + error('Expected %s props to match memoized props before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); + } + + if (instance.state !== finishedWork.memoizedState) { + error('Expected %s state to match memoized state before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.state`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); + } + } + } + + { + instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate); + } + } + } // TODO: I think this is now always non-null by the time it reaches the + // commit phase. Consider removing the type check. + + + var updateQueue = finishedWork.updateQueue; + + if (updateQueue !== null) { + { + if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) { + if (instance.props !== finishedWork.memoizedProps) { + error('Expected %s props to match memoized props before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); + } + + if (instance.state !== finishedWork.memoizedState) { + error('Expected %s state to match memoized state before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.state`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance'); + } + } + } // We could update instance props and state here, + // but instead we rely on them being set during last render. + // TODO: revisit this when we implement resuming. + + + commitUpdateQueue(finishedWork, updateQueue, instance); + } + + return; + } + + case HostRoot: + { + // TODO: I think this is now always non-null by the time it reaches the + // commit phase. Consider removing the type check. + var _updateQueue = finishedWork.updateQueue; + + if (_updateQueue !== null) { + var _instance = null; + + if (finishedWork.child !== null) { + switch (finishedWork.child.tag) { + case HostComponent: + _instance = getPublicInstance(finishedWork.child.stateNode); + break; + + case ClassComponent: + _instance = finishedWork.child.stateNode; + break; + } + } + + commitUpdateQueue(finishedWork, _updateQueue, _instance); + } + + return; + } + + case HostComponent: + { + var _instance2 = finishedWork.stateNode; // Renderers may schedule work to be done after host components are mounted + // (eg DOM renderer may schedule auto-focus for inputs and form controls). + // These effects should only be committed when components are first mounted, + // aka when there is no current/alternate. + + if (current === null && finishedWork.flags & Update) { + var type = finishedWork.type; + var props = finishedWork.memoizedProps; + commitMount(_instance2, type, props); + } + + return; + } + + case HostText: + { + // We have no life-cycles associated with text. + return; + } + + case HostPortal: + { + // We have no life-cycles associated with portals. + return; + } + + case Profiler: + { + { + var _finishedWork$memoize2 = finishedWork.memoizedProps, + onCommit = _finishedWork$memoize2.onCommit, + onRender = _finishedWork$memoize2.onRender; + var effectDuration = finishedWork.stateNode.effectDuration; + var commitTime = getCommitTime(); + + if (typeof onRender === 'function') { + { + onRender(finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, commitTime, finishedRoot.memoizedInteractions); + } + } + } + + return; + } + + case SuspenseComponent: + { + commitSuspenseHydrationCallbacks(finishedRoot, finishedWork); + return; + } + + case SuspenseListComponent: + case IncompleteClassComponent: + case FundamentalComponent: + case ScopeComponent: + case OffscreenComponent: + case LegacyHiddenComponent: + return; + } + + { + { + throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); + } + } + } + + function hideOrUnhideAllChildren(finishedWork, isHidden) { + { + // We only have the top Fiber that was inserted but we need to recurse down its + // children to find all the terminal nodes. + var node = finishedWork; + + while (true) { + if (node.tag === HostComponent) { + var instance = node.stateNode; + + if (isHidden) { + hideInstance(instance); + } else { + unhideInstance(node.stateNode, node.memoizedProps); + } + } else if (node.tag === HostText) { + var _instance3 = node.stateNode; + + if (isHidden) { + hideTextInstance(_instance3); + } else { + unhideTextInstance(_instance3, node.memoizedProps); + } + } else if ((node.tag === OffscreenComponent || node.tag === LegacyHiddenComponent) && node.memoizedState !== null && node !== finishedWork) ; else if (node.child !== null) { + node.child.return = node; + node = node.child; + continue; + } + + if (node === finishedWork) { + return; + } + + while (node.sibling === null) { + if (node.return === null || node.return === finishedWork) { + return; + } + + node = node.return; + } + + node.sibling.return = node.return; + node = node.sibling; + } + } + } + + function commitAttachRef(finishedWork) { + var ref = finishedWork.ref; + + if (ref !== null) { + var instance = finishedWork.stateNode; + var instanceToUse; + + switch (finishedWork.tag) { + case HostComponent: + instanceToUse = getPublicInstance(instance); + break; + + default: + instanceToUse = instance; + } // Moved outside to ensure DCE works with this flag + + if (typeof ref === 'function') { + ref(instanceToUse); + } else { + { + if (!ref.hasOwnProperty('current')) { + error('Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().', getComponentName(finishedWork.type)); + } + } + + ref.current = instanceToUse; + } + } + } + + function commitDetachRef(current) { + var currentRef = current.ref; + + if (currentRef !== null) { + if (typeof currentRef === 'function') { + currentRef(null); + } else { + currentRef.current = null; + } + } + } // User-originating errors (lifecycles and refs) should not interrupt + // deletion, so don't let them throw. Host-originating errors should + // interrupt deletion, so it's okay + + + function commitUnmount(finishedRoot, current, renderPriorityLevel) { + onCommitUnmount(current); + + switch (current.tag) { + case FunctionComponent: + case ForwardRef: + case MemoComponent: + case SimpleMemoComponent: + case Block: + { + var updateQueue = current.updateQueue; + + if (updateQueue !== null) { + var lastEffect = updateQueue.lastEffect; + + if (lastEffect !== null) { + var firstEffect = lastEffect.next; + var effect = firstEffect; + + do { + var _effect2 = effect, + destroy = _effect2.destroy, + tag = _effect2.tag; + + if (destroy !== undefined) { + if ((tag & Passive$1) !== NoFlags$1) { + enqueuePendingPassiveHookEffectUnmount(current, effect); + } else { + { + safelyCallDestroy(current, destroy); + } + } + } + + effect = effect.next; + } while (effect !== firstEffect); + } + } + + return; + } + + case ClassComponent: + { + safelyDetachRef(current); + var instance = current.stateNode; + + if (typeof instance.componentWillUnmount === 'function') { + safelyCallComponentWillUnmount(current, instance); + } + + return; + } + + case HostComponent: + { + safelyDetachRef(current); + return; + } + + case HostPortal: + { + // TODO: this is recursive. + // We are also not using this parent because + // the portal will get pushed immediately. + { + unmountHostComponents(finishedRoot, current); + } + + return; + } + + case FundamentalComponent: + { + + return; + } + + case DehydratedFragment: + { + + return; + } + + case ScopeComponent: + { + + return; + } + } + } + + function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) { + // While we're inside a removed host node we don't want to call + // removeChild on the inner nodes because they're removed by the top + // call anyway. We also want to call componentWillUnmount on all + // composites before this host node is removed from the tree. Therefore + // we do an inner loop while we're still inside the host node. + var node = root; + + while (true) { + commitUnmount(finishedRoot, node); // Visit children because they may contain more composite or host nodes. + // Skip portals because commitUnmount() currently visits them recursively. + + if (node.child !== null && ( // If we use mutation we drill down into portals using commitUnmount above. + // If we don't use mutation we drill down into portals here instead. + node.tag !== HostPortal)) { + node.child.return = node; + node = node.child; + continue; + } + + if (node === root) { + return; + } + + while (node.sibling === null) { + if (node.return === null || node.return === root) { + return; + } + + node = node.return; + } + + node.sibling.return = node.return; + node = node.sibling; + } + } + + function detachFiberMutation(fiber) { + // Cut off the return pointers to disconnect it from the tree. Ideally, we + // should clear the child pointer of the parent alternate to let this + // get GC:ed but we don't know which for sure which parent is the current + // one so we'll settle for GC:ing the subtree of this child. This child + // itself will be GC:ed when the parent updates the next time. + // Note: we cannot null out sibling here, otherwise it can cause issues + // with findDOMNode and how it requires the sibling field to carry out + // traversal in a later effect. See PR #16820. We now clear the sibling + // field after effects, see: detachFiberAfterEffects. + // + // Don't disconnect stateNode now; it will be detached in detachFiberAfterEffects. + // It may be required if the current component is an error boundary, + // and one of its descendants throws while unmounting a passive effect. + fiber.alternate = null; + fiber.child = null; + fiber.dependencies = null; + fiber.firstEffect = null; + fiber.lastEffect = null; + fiber.memoizedProps = null; + fiber.memoizedState = null; + fiber.pendingProps = null; + fiber.return = null; + fiber.updateQueue = null; + + { + fiber._debugOwner = null; + } + } + + function getHostParentFiber(fiber) { + var parent = fiber.return; + + while (parent !== null) { + if (isHostParent(parent)) { + return parent; + } + + parent = parent.return; + } + + { + { + throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); + } + } + } + + function isHostParent(fiber) { + return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal; + } + + function getHostSibling(fiber) { + // We're going to search forward into the tree until we find a sibling host + // node. Unfortunately, if multiple insertions are done in a row we have to + // search past them. This leads to exponential search for the next sibling. + // TODO: Find a more efficient way to do this. + var node = fiber; + + siblings: while (true) { + // If we didn't find anything, let's try the next sibling. + while (node.sibling === null) { + if (node.return === null || isHostParent(node.return)) { + // If we pop out of the root or hit the parent the fiber we are the + // last sibling. + return null; + } + + node = node.return; + } + + node.sibling.return = node.return; + node = node.sibling; + + while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedFragment) { + // If it is not host node and, we might have a host node inside it. + // Try to search down until we find one. + if (node.flags & Placement) { + // If we don't have a child, try the siblings instead. + continue siblings; + } // If we don't have a child, try the siblings instead. + // We also skip portals because they are not part of this host tree. + + + if (node.child === null || node.tag === HostPortal) { + continue siblings; + } else { + node.child.return = node; + node = node.child; + } + } // Check if this host node is stable or about to be placed. + + + if (!(node.flags & Placement)) { + // Found it! + return node.stateNode; + } + } + } + + function commitPlacement(finishedWork) { + + + var parentFiber = getHostParentFiber(finishedWork); // Note: these two variables *must* always be updated together. + + var parent; + var isContainer; + var parentStateNode = parentFiber.stateNode; + + switch (parentFiber.tag) { + case HostComponent: + parent = parentStateNode; + isContainer = false; + break; + + case HostRoot: + parent = parentStateNode.containerInfo; + isContainer = true; + break; + + case HostPortal: + parent = parentStateNode.containerInfo; + isContainer = true; + break; + + case FundamentalComponent: + + // eslint-disable-next-line-no-fallthrough + + default: + { + { + throw Error( "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." ); + } + } + + } + + if (parentFiber.flags & ContentReset) { + // Reset the text content of the parent before doing any insertions + resetTextContent(parent); // Clear ContentReset from the effect tag + + parentFiber.flags &= ~ContentReset; + } + + var before = getHostSibling(finishedWork); // We only have the top Fiber that was inserted but we need to recurse down its + // children to find all the terminal nodes. + + if (isContainer) { + insertOrAppendPlacementNodeIntoContainer(finishedWork, before, parent); + } else { + insertOrAppendPlacementNode(finishedWork, before, parent); + } + } + + function insertOrAppendPlacementNodeIntoContainer(node, before, parent) { + var tag = node.tag; + var isHost = tag === HostComponent || tag === HostText; + + if (isHost || enableFundamentalAPI ) { + var stateNode = isHost ? node.stateNode : node.stateNode.instance; + + if (before) { + insertInContainerBefore(parent, stateNode, before); + } else { + appendChildToContainer(parent, stateNode); + } + } else if (tag === HostPortal) ; else { + var child = node.child; + + if (child !== null) { + insertOrAppendPlacementNodeIntoContainer(child, before, parent); + var sibling = child.sibling; + + while (sibling !== null) { + insertOrAppendPlacementNodeIntoContainer(sibling, before, parent); + sibling = sibling.sibling; + } + } + } + } + + function insertOrAppendPlacementNode(node, before, parent) { + var tag = node.tag; + var isHost = tag === HostComponent || tag === HostText; + + if (isHost || enableFundamentalAPI ) { + var stateNode = isHost ? node.stateNode : node.stateNode.instance; + + if (before) { + insertBefore(parent, stateNode, before); + } else { + appendChild(parent, stateNode); + } + } else if (tag === HostPortal) ; else { + var child = node.child; + + if (child !== null) { + insertOrAppendPlacementNode(child, before, parent); + var sibling = child.sibling; + + while (sibling !== null) { + insertOrAppendPlacementNode(sibling, before, parent); + sibling = sibling.sibling; + } + } + } + } + + function unmountHostComponents(finishedRoot, current, renderPriorityLevel) { + // We only have the top Fiber that was deleted but we need to recurse down its + // children to find all the terminal nodes. + var node = current; // Each iteration, currentParent is populated with node's host parent if not + // currentParentIsValid. + + var currentParentIsValid = false; // Note: these two variables *must* always be updated together. + + var currentParent; + var currentParentIsContainer; + + while (true) { + if (!currentParentIsValid) { + var parent = node.return; + + findParent: while (true) { + if (!(parent !== null)) { + { + throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); + } + } + + var parentStateNode = parent.stateNode; + + switch (parent.tag) { + case HostComponent: + currentParent = parentStateNode; + currentParentIsContainer = false; + break findParent; + + case HostRoot: + currentParent = parentStateNode.containerInfo; + currentParentIsContainer = true; + break findParent; + + case HostPortal: + currentParent = parentStateNode.containerInfo; + currentParentIsContainer = true; + break findParent; + + } + + parent = parent.return; + } + + currentParentIsValid = true; + } + + if (node.tag === HostComponent || node.tag === HostText) { + commitNestedUnmounts(finishedRoot, node); // After all the children have unmounted, it is now safe to remove the + // node from the tree. + + if (currentParentIsContainer) { + removeChildFromContainer(currentParent, node.stateNode); + } else { + removeChild(currentParent, node.stateNode); + } // Don't visit children because we already visited them. + + } else if (node.tag === HostPortal) { + if (node.child !== null) { + // When we go into a portal, it becomes the parent to remove from. + // We will reassign it back when we pop the portal on the way up. + currentParent = node.stateNode.containerInfo; + currentParentIsContainer = true; // Visit children because portals might contain host components. + + node.child.return = node; + node = node.child; + continue; + } + } else { + commitUnmount(finishedRoot, node); // Visit children because we may find more host components below. + + if (node.child !== null) { + node.child.return = node; + node = node.child; + continue; + } + } + + if (node === current) { + return; + } + + while (node.sibling === null) { + if (node.return === null || node.return === current) { + return; + } + + node = node.return; + + if (node.tag === HostPortal) { + // When we go out of the portal, we need to restore the parent. + // Since we don't keep a stack of them, we will search for it. + currentParentIsValid = false; + } + } + + node.sibling.return = node.return; + node = node.sibling; + } + } + + function commitDeletion(finishedRoot, current, renderPriorityLevel) { + { + // Recursively delete all host nodes from the parent. + // Detach refs and call componentWillUnmount() on the whole subtree. + unmountHostComponents(finishedRoot, current); + } + + var alternate = current.alternate; + detachFiberMutation(current); + + if (alternate !== null) { + detachFiberMutation(alternate); + } + } + + function commitWork(current, finishedWork) { + + switch (finishedWork.tag) { + case FunctionComponent: + case ForwardRef: + case MemoComponent: + case SimpleMemoComponent: + case Block: + { + // Layout effects are destroyed during the mutation phase so that all + // destroy functions for all fibers are called before any create functions. + // This prevents sibling component effects from interfering with each other, + // e.g. a destroy function in one component should never override a ref set + // by a create function in another component during the same commit. + { + commitHookEffectListUnmount(Layout | HasEffect, finishedWork); + } + + return; + } + + case ClassComponent: + { + return; + } + + case HostComponent: + { + var instance = finishedWork.stateNode; + + if (instance != null) { + // Commit the work prepared earlier. + var newProps = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps + // as the newProps. The updatePayload will contain the real change in + // this case. + + var oldProps = current !== null ? current.memoizedProps : newProps; + var type = finishedWork.type; // TODO: Type the updateQueue to be specific to host components. + + var updatePayload = finishedWork.updateQueue; + finishedWork.updateQueue = null; + + if (updatePayload !== null) { + commitUpdate(instance, updatePayload, type, oldProps, newProps); + } + } + + return; + } + + case HostText: + { + if (!(finishedWork.stateNode !== null)) { + { + throw Error( "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." ); + } + } + + var textInstance = finishedWork.stateNode; + var newText = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps + // as the newProps. The updatePayload will contain the real change in + // this case. + + var oldText = current !== null ? current.memoizedProps : newText; + commitTextUpdate(textInstance, oldText, newText); + return; + } + + case HostRoot: + { + { + var _root = finishedWork.stateNode; + + if (_root.hydrate) { + // We've just hydrated. No need to hydrate again. + _root.hydrate = false; + commitHydratedContainer(_root.containerInfo); + } + } + + return; + } + + case Profiler: + { + return; + } + + case SuspenseComponent: + { + commitSuspenseComponent(finishedWork); + attachSuspenseRetryListeners(finishedWork); + return; + } + + case SuspenseListComponent: + { + attachSuspenseRetryListeners(finishedWork); + return; + } + + case IncompleteClassComponent: + { + return; + } + + case FundamentalComponent: + { + + break; + } + + case ScopeComponent: + { + + break; + } + + case OffscreenComponent: + case LegacyHiddenComponent: + { + var newState = finishedWork.memoizedState; + var isHidden = newState !== null; + hideOrUnhideAllChildren(finishedWork, isHidden); + return; + } + } + + { + { + throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); + } + } + } + + function commitSuspenseComponent(finishedWork) { + var newState = finishedWork.memoizedState; + + if (newState !== null) { + markCommitTimeOfFallback(); + + { + // Hide the Offscreen component that contains the primary children. TODO: + // Ideally, this effect would have been scheduled on the Offscreen fiber + // itself. That's how unhiding works: the Offscreen component schedules an + // effect on itself. However, in this case, the component didn't complete, + // so the fiber was never added to the effect list in the normal path. We + // could have appended it to the effect list in the Suspense component's + // second pass, but doing it this way is less complicated. This would be + // simpler if we got rid of the effect list and traversed the tree, like + // we're planning to do. + var primaryChildParent = finishedWork.child; + hideOrUnhideAllChildren(primaryChildParent, true); + } + } + } + + function commitSuspenseHydrationCallbacks(finishedRoot, finishedWork) { + + var newState = finishedWork.memoizedState; + + if (newState === null) { + var current = finishedWork.alternate; + + if (current !== null) { + var prevState = current.memoizedState; + + if (prevState !== null) { + var suspenseInstance = prevState.dehydrated; + + if (suspenseInstance !== null) { + commitHydratedSuspenseInstance(suspenseInstance); + } + } + } + } + } + + function attachSuspenseRetryListeners(finishedWork) { + // If this boundary just timed out, then it will have a set of wakeables. + // For each wakeable, attach a listener so that when it resolves, React + // attempts to re-render the boundary in the primary (pre-timeout) state. + var wakeables = finishedWork.updateQueue; + + if (wakeables !== null) { + finishedWork.updateQueue = null; + var retryCache = finishedWork.stateNode; + + if (retryCache === null) { + retryCache = finishedWork.stateNode = new PossiblyWeakSet(); + } + + wakeables.forEach(function (wakeable) { + // Memoize using the boundary fiber to prevent redundant listeners. + var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable); + + if (!retryCache.has(wakeable)) { + { + if (wakeable.__reactDoNotTraceInteractions !== true) { + retry = unstable_wrap(retry); + } + } + + retryCache.add(wakeable); + wakeable.then(retry, retry); + } + }); + } + } // This function detects when a Suspense boundary goes from visible to hidden. + // It returns false if the boundary is already hidden. + // TODO: Use an effect tag. + + + function isSuspenseBoundaryBeingHidden(current, finishedWork) { + if (current !== null) { + var oldState = current.memoizedState; + + if (oldState === null || oldState.dehydrated !== null) { + var newState = finishedWork.memoizedState; + return newState !== null && newState.dehydrated === null; + } + } + + return false; + } + + function commitResetTextContent(current) { + + resetTextContent(current.stateNode); + } + + var COMPONENT_TYPE = 0; + var HAS_PSEUDO_CLASS_TYPE = 1; + var ROLE_TYPE = 2; + var TEST_NAME_TYPE = 3; + var TEXT_TYPE = 4; + + if (typeof Symbol === 'function' && Symbol.for) { + var symbolFor$1 = Symbol.for; + COMPONENT_TYPE = symbolFor$1('selector.component'); + HAS_PSEUDO_CLASS_TYPE = symbolFor$1('selector.has_pseudo_class'); + ROLE_TYPE = symbolFor$1('selector.role'); + TEST_NAME_TYPE = symbolFor$1('selector.test_id'); + TEXT_TYPE = symbolFor$1('selector.text'); + } + var commitHooks = []; + function onCommitRoot$1() { + { + commitHooks.forEach(function (commitHook) { + return commitHook(); + }); + } + } + + var ceil = Math.ceil; + var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, + IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing; + var NoContext = + /* */ + 0; + var BatchedContext = + /* */ + 1; + var EventContext = + /* */ + 2; + var DiscreteEventContext = + /* */ + 4; + var LegacyUnbatchedContext = + /* */ + 8; + var RenderContext = + /* */ + 16; + var CommitContext = + /* */ + 32; + var RetryAfterError = + /* */ + 64; + var RootIncomplete = 0; + var RootFatalErrored = 1; + var RootErrored = 2; + var RootSuspended = 3; + var RootSuspendedWithDelay = 4; + var RootCompleted = 5; // Describes where we are in the React execution stack + + var executionContext = NoContext; // The root we're working on + + var workInProgressRoot = null; // The fiber we're working on + + var workInProgress = null; // The lanes we're rendering + + var workInProgressRootRenderLanes = NoLanes; // Stack that allows components to change the render lanes for its subtree + // This is a superset of the lanes we started working on at the root. The only + // case where it's different from `workInProgressRootRenderLanes` is when we + // enter a subtree that is hidden and needs to be unhidden: Suspense and + // Offscreen component. + // + // Most things in the work loop should deal with workInProgressRootRenderLanes. + // Most things in begin/complete phases should deal with subtreeRenderLanes. + + var subtreeRenderLanes = NoLanes; + var subtreeRenderLanesCursor = createCursor(NoLanes); // Whether to root completed, errored, suspended, etc. + + var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown + + var workInProgressRootFatalError = null; // "Included" lanes refer to lanes that were worked on during this render. It's + // slightly different than `renderLanes` because `renderLanes` can change as you + // enter and exit an Offscreen tree. This value is the combination of all render + // lanes for the entire render phase. + + var workInProgressRootIncludedLanes = NoLanes; // The work left over by components that were visited during this render. Only + // includes unprocessed updates, not work in bailed out children. + + var workInProgressRootSkippedLanes = NoLanes; // Lanes that were updated (in an interleaved event) during this render. + + var workInProgressRootUpdatedLanes = NoLanes; // Lanes that were pinged (in an interleaved event) during this render. + + var workInProgressRootPingedLanes = NoLanes; + var mostRecentlyUpdatedRoot = null; // The most recent time we committed a fallback. This lets us ensure a train + // model where we don't commit new loading states in too quick succession. + + var globalMostRecentFallbackTime = 0; + var FALLBACK_THROTTLE_MS = 500; // The absolute time for when we should start giving up on rendering + // more and prefer CPU suspense heuristics instead. + + var workInProgressRootRenderTargetTime = Infinity; // How long a render is supposed to take before we start following CPU + // suspense heuristics and opt out of rendering more content. + + var RENDER_TIMEOUT_MS = 500; + + function resetRenderTimer() { + workInProgressRootRenderTargetTime = now() + RENDER_TIMEOUT_MS; + } + + function getRenderTargetTime() { + return workInProgressRootRenderTargetTime; + } + var nextEffect = null; + var hasUncaughtError = false; + var firstUncaughtError = null; + var legacyErrorBoundariesThatAlreadyFailed = null; + var rootDoesHavePassiveEffects = false; + var rootWithPendingPassiveEffects = null; + var pendingPassiveEffectsRenderPriority = NoPriority$1; + var pendingPassiveEffectsLanes = NoLanes; + var pendingPassiveHookEffectsMount = []; + var pendingPassiveHookEffectsUnmount = []; + var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates + + var NESTED_UPDATE_LIMIT = 50; + var nestedUpdateCount = 0; + var rootWithNestedUpdates = null; + var NESTED_PASSIVE_UPDATE_LIMIT = 50; + var nestedPassiveUpdateCount = 0; // Marks the need to reschedule pending interactions at these lanes + // during the commit phase. This enables them to be traced across components + // that spawn new work during render. E.g. hidden boundaries, suspended SSR + // hydration or SuspenseList. + // TODO: Can use a bitmask instead of an array + + var spawnedWorkDuringRender = null; // If two updates are scheduled within the same event, we should treat their + // event times as simultaneous, even if the actual clock time has advanced + // between the first and second call. + + var currentEventTime = NoTimestamp; + var currentEventWipLanes = NoLanes; + var currentEventPendingLanes = NoLanes; // Dev only flag that tracks if passive effects are currently being flushed. + // We warn about state updates for unmounted components differently in this case. + + var isFlushingPassiveEffects = false; + var focusedInstanceHandle = null; + var shouldFireAfterActiveInstanceBlur = false; + function getWorkInProgressRoot() { + return workInProgressRoot; + } + function requestEventTime() { + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { + // We're inside React, so it's fine to read the actual time. + return now(); + } // We're not inside React, so we may be in the middle of a browser event. + + + if (currentEventTime !== NoTimestamp) { + // Use the same start time for all updates until we enter React again. + return currentEventTime; + } // This is the first update since React yielded. Compute a new start time. + + + currentEventTime = now(); + return currentEventTime; + } + function requestUpdateLane(fiber) { + // Special cases + var mode = fiber.mode; + + if ((mode & BlockingMode) === NoMode) { + return SyncLane; + } else if ((mode & ConcurrentMode) === NoMode) { + return getCurrentPriorityLevel() === ImmediatePriority$1 ? SyncLane : SyncBatchedLane; + } // The algorithm for assigning an update to a lane should be stable for all + // updates at the same priority within the same event. To do this, the inputs + // to the algorithm must be the same. For example, we use the `renderLanes` + // to avoid choosing a lane that is already in the middle of rendering. + // + // However, the "included" lanes could be mutated in between updates in the + // same event, like if you perform an update inside `flushSync`. Or any other + // code path that might call `prepareFreshStack`. + // + // The trick we use is to cache the first of each of these inputs within an + // event. Then reset the cached values once we can be sure the event is over. + // Our heuristic for that is whenever we enter a concurrent work loop. + // + // We'll do the same for `currentEventPendingLanes` below. + + + if (currentEventWipLanes === NoLanes) { + currentEventWipLanes = workInProgressRootIncludedLanes; + } + + var isTransition = requestCurrentTransition() !== NoTransition; + + if (isTransition) { + if (currentEventPendingLanes !== NoLanes) { + currentEventPendingLanes = mostRecentlyUpdatedRoot !== null ? mostRecentlyUpdatedRoot.pendingLanes : NoLanes; + } + + return findTransitionLane(currentEventWipLanes, currentEventPendingLanes); + } // TODO: Remove this dependency on the Scheduler priority. + // To do that, we're replacing it with an update lane priority. + + + var schedulerPriority = getCurrentPriorityLevel(); // The old behavior was using the priority level of the Scheduler. + // This couples React to the Scheduler internals, so we're replacing it + // with the currentUpdateLanePriority above. As an example of how this + // could be problematic, if we're not inside `Scheduler.runWithPriority`, + // then we'll get the priority of the current running Scheduler task, + // which is probably not what we want. + + var lane; + + if ( // TODO: Temporary. We're removing the concept of discrete updates. + (executionContext & DiscreteEventContext) !== NoContext && schedulerPriority === UserBlockingPriority$2) { + lane = findUpdateLane(InputDiscreteLanePriority, currentEventWipLanes); + } else { + var schedulerLanePriority = schedulerPriorityToLanePriority(schedulerPriority); + + lane = findUpdateLane(schedulerLanePriority, currentEventWipLanes); + } + + return lane; + } + + function requestRetryLane(fiber) { + // This is a fork of `requestUpdateLane` designed specifically for Suspense + // "retries" — a special update that attempts to flip a Suspense boundary + // from its placeholder state to its primary/resolved state. + // Special cases + var mode = fiber.mode; + + if ((mode & BlockingMode) === NoMode) { + return SyncLane; + } else if ((mode & ConcurrentMode) === NoMode) { + return getCurrentPriorityLevel() === ImmediatePriority$1 ? SyncLane : SyncBatchedLane; + } // See `requestUpdateLane` for explanation of `currentEventWipLanes` + + + if (currentEventWipLanes === NoLanes) { + currentEventWipLanes = workInProgressRootIncludedLanes; + } + + return findRetryLane(currentEventWipLanes); + } + + function scheduleUpdateOnFiber(fiber, lane, eventTime) { + checkForNestedUpdates(); + warnAboutRenderPhaseUpdatesInDEV(fiber); + var root = markUpdateLaneFromFiberToRoot(fiber, lane); + + if (root === null) { + warnAboutUpdateOnUnmountedFiberInDEV(fiber); + return null; + } // Mark that the root has a pending update. + + + markRootUpdated(root, lane, eventTime); + + if (root === workInProgressRoot) { + // Received an update to a tree that's in the middle of rendering. Mark + // that there was an interleaved update work on this root. Unless the + // `deferRenderPhaseUpdateToNextBatch` flag is off and this is a render + // phase update. In that case, we don't treat render phase updates as if + // they were interleaved, for backwards compat reasons. + { + workInProgressRootUpdatedLanes = mergeLanes(workInProgressRootUpdatedLanes, lane); + } + + if (workInProgressRootExitStatus === RootSuspendedWithDelay) { + // The root already suspended with a delay, which means this render + // definitely won't finish. Since we have a new update, let's mark it as + // suspended now, right before marking the incoming update. This has the + // effect of interrupting the current render and switching to the update. + // TODO: Make sure this doesn't override pings that happen while we've + // already started rendering. + markRootSuspended$1(root, workInProgressRootRenderLanes); + } + } // TODO: requestUpdateLanePriority also reads the priority. Pass the + // priority as an argument to that function and this one. + + + var priorityLevel = getCurrentPriorityLevel(); + + if (lane === SyncLane) { + if ( // Check if we're inside unbatchedUpdates + (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering + (executionContext & (RenderContext | CommitContext)) === NoContext) { + // Register pending interactions on the root to avoid losing traced interaction data. + schedulePendingInteractions(root, lane); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed + // root inside of batchedUpdates should be synchronous, but layout updates + // should be deferred until the end of the batch. + + performSyncWorkOnRoot(root); + } else { + ensureRootIsScheduled(root, eventTime); + schedulePendingInteractions(root, lane); + + if (executionContext === NoContext) { + // Flush the synchronous work now, unless we're already working or inside + // a batch. This is intentionally inside scheduleUpdateOnFiber instead of + // scheduleCallbackForFiber to preserve the ability to schedule a callback + // without immediately flushing it. We only do this for user-initiated + // updates, to preserve historical behavior of legacy mode. + resetRenderTimer(); + flushSyncCallbackQueue(); + } + } + } else { + // Schedule a discrete update but only if it's not Sync. + if ((executionContext & DiscreteEventContext) !== NoContext && ( // Only updates at user-blocking priority or greater are considered + // discrete, even inside a discrete event. + priorityLevel === UserBlockingPriority$2 || priorityLevel === ImmediatePriority$1)) { + // This is the result of a discrete event. Track the lowest priority + // discrete update per root so we can flush them early, if needed. + if (rootsWithPendingDiscreteUpdates === null) { + rootsWithPendingDiscreteUpdates = new Set([root]); + } else { + rootsWithPendingDiscreteUpdates.add(root); + } + } // Schedule other updates after in case the callback is sync. + + + ensureRootIsScheduled(root, eventTime); + schedulePendingInteractions(root, lane); + } // We use this when assigning a lane for a transition inside + // `requestUpdateLane`. We assume it's the same as the root being updated, + // since in the common case of a single root app it probably is. If it's not + // the same root, then it's not a huge deal, we just might batch more stuff + // together more than necessary. + + + mostRecentlyUpdatedRoot = root; + } // This is split into a separate function so we can mark a fiber with pending + // work without treating it as a typical update that originates from an event; + // e.g. retrying a Suspense boundary isn't an update, but it does schedule work + // on a fiber. + + function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { + // Update the source fiber's lanes + sourceFiber.lanes = mergeLanes(sourceFiber.lanes, lane); + var alternate = sourceFiber.alternate; + + if (alternate !== null) { + alternate.lanes = mergeLanes(alternate.lanes, lane); + } + + { + if (alternate === null && (sourceFiber.flags & (Placement | Hydrating)) !== NoFlags) { + warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); + } + } // Walk the parent path to the root and update the child expiration time. + + + var node = sourceFiber; + var parent = sourceFiber.return; + + while (parent !== null) { + parent.childLanes = mergeLanes(parent.childLanes, lane); + alternate = parent.alternate; + + if (alternate !== null) { + alternate.childLanes = mergeLanes(alternate.childLanes, lane); + } else { + { + if ((parent.flags & (Placement | Hydrating)) !== NoFlags) { + warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); + } + } + } + + node = parent; + parent = parent.return; + } + + if (node.tag === HostRoot) { + var root = node.stateNode; + return root; + } else { + return null; + } + } // Use this function to schedule a task for a root. There's only one task per + // root; if a task was already scheduled, we'll check to make sure the priority + // of the existing task is the same as the priority of the next level that the + // root has work on. This function is called on every update, and right before + // exiting a task. + + + function ensureRootIsScheduled(root, currentTime) { + var existingCallbackNode = root.callbackNode; // Check if any lanes are being starved by other work. If so, mark them as + // expired so we know to work on those next. + + markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. + + var nextLanes = getNextLanes(root, root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes); // This returns the priority level computed during the `getNextLanes` call. + + var newCallbackPriority = returnNextLanesPriority(); + + if (nextLanes === NoLanes) { + // Special case: There's nothing to work on. + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + root.callbackNode = null; + root.callbackPriority = NoLanePriority; + } + + return; + } // Check if there's an existing task. We may be able to reuse it. + + + if (existingCallbackNode !== null) { + var existingCallbackPriority = root.callbackPriority; + + if (existingCallbackPriority === newCallbackPriority) { + // The priority hasn't changed. We can reuse the existing task. Exit. + return; + } // The priority changed. Cancel the existing callback. We'll schedule a new + // one below. + + + cancelCallback(existingCallbackNode); + } // Schedule a new callback. + + + var newCallbackNode; + + if (newCallbackPriority === SyncLanePriority) { + // Special case: Sync React callbacks are scheduled on a special + // internal queue + newCallbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); + } else if (newCallbackPriority === SyncBatchedLanePriority) { + newCallbackNode = scheduleCallback(ImmediatePriority$1, performSyncWorkOnRoot.bind(null, root)); + } else { + var schedulerPriorityLevel = lanePriorityToSchedulerPriority(newCallbackPriority); + newCallbackNode = scheduleCallback(schedulerPriorityLevel, performConcurrentWorkOnRoot.bind(null, root)); + } + + root.callbackPriority = newCallbackPriority; + root.callbackNode = newCallbackNode; + } // This is the entry point for every concurrent task, i.e. anything that + // goes through Scheduler. + + + function performConcurrentWorkOnRoot(root) { + // Since we know we're in a React event, we can clear the current + // event time. The next update will compute a new event time. + currentEventTime = NoTimestamp; + currentEventWipLanes = NoLanes; + currentEventPendingLanes = NoLanes; + + if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { + { + throw Error( "Should not already be working." ); + } + } // Flush any pending passive effects before deciding which lanes to work on, + // in case they schedule additional work. + + + var originalCallbackNode = root.callbackNode; + var didFlushPassiveEffects = flushPassiveEffects(); + + if (didFlushPassiveEffects) { + // Something in the passive effect phase may have canceled the current task. + // Check if the task node for this root was changed. + if (root.callbackNode !== originalCallbackNode) { + // The current task was canceled. Exit. We don't need to call + // `ensureRootIsScheduled` because the check above implies either that + // there's a new task, or that there's no remaining work on this root. + return null; + } + } // Determine the next expiration time to work on, using the fields stored + // on the root. + + + var lanes = getNextLanes(root, root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes); + + if (lanes === NoLanes) { + // Defensive coding. This is never expected to happen. + return null; + } + + var exitStatus = renderRootConcurrent(root, lanes); + + if (includesSomeLane(workInProgressRootIncludedLanes, workInProgressRootUpdatedLanes)) { + // The render included lanes that were updated during the render phase. + // For example, when unhiding a hidden tree, we include all the lanes + // that were previously skipped when the tree was hidden. That set of + // lanes is a superset of the lanes we started rendering with. + // + // So we'll throw out the current work and restart. + prepareFreshStack(root, NoLanes); + } else if (exitStatus !== RootIncomplete) { + if (exitStatus === RootErrored) { + executionContext |= RetryAfterError; // If an error occurred during hydration, + // discard server response and fall back to client side render. + + if (root.hydrate) { + root.hydrate = false; + clearContainer(root.containerInfo); + } // If something threw an error, try rendering one more time. We'll render + // synchronously to block concurrent data mutations, and we'll includes + // all pending updates are included. If it still fails after the second + // attempt, we'll give up and commit the resulting tree. + + + lanes = getLanesToRetrySynchronouslyOnError(root); + + if (lanes !== NoLanes) { + exitStatus = renderRootSync(root, lanes); + } + } + + if (exitStatus === RootFatalErrored) { + var fatalError = workInProgressRootFatalError; + prepareFreshStack(root, NoLanes); + markRootSuspended$1(root, lanes); + ensureRootIsScheduled(root, now()); + throw fatalError; + } // We now have a consistent tree. The next step is either to commit it, + // or, if something suspended, wait to commit it after a timeout. + + + var finishedWork = root.current.alternate; + root.finishedWork = finishedWork; + root.finishedLanes = lanes; + finishConcurrentRender(root, exitStatus, lanes); + } + + ensureRootIsScheduled(root, now()); + + if (root.callbackNode === originalCallbackNode) { + // The task node scheduled for this root is the same one that's + // currently executed. Need to return a continuation. + return performConcurrentWorkOnRoot.bind(null, root); + } + + return null; + } + + function finishConcurrentRender(root, exitStatus, lanes) { + switch (exitStatus) { + case RootIncomplete: + case RootFatalErrored: + { + { + { + throw Error( "Root did not complete. This is a bug in React." ); + } + } + } + // Flow knows about invariant, so it complains if I add a break + // statement, but eslint doesn't know about invariant, so it complains + // if I do. eslint-disable-next-line no-fallthrough + + case RootErrored: + { + // We should have already attempted to retry this tree. If we reached + // this point, it errored again. Commit it. + commitRoot(root); + break; + } + + case RootSuspended: + { + markRootSuspended$1(root, lanes); // We have an acceptable loading state. We need to figure out if we + // should immediately commit it or wait a bit. + + if (includesOnlyRetries(lanes) && // do not delay if we're inside an act() scope + !shouldForceFlushFallbacksInDEV()) { + // This render only included retries, no updates. Throttle committing + // retries so that we don't show too many loading states too quickly. + var msUntilTimeout = globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now(); // Don't bother with a very short suspense time. + + if (msUntilTimeout > 10) { + var nextLanes = getNextLanes(root, NoLanes); + + if (nextLanes !== NoLanes) { + // There's additional work on this root. + break; + } + + var suspendedLanes = root.suspendedLanes; + + if (!isSubsetOfLanes(suspendedLanes, lanes)) { + // We should prefer to render the fallback of at the last + // suspended level. Ping the last suspended level to try + // rendering it again. + // FIXME: What if the suspended lanes are Idle? Should not restart. + var eventTime = requestEventTime(); + markRootPinged(root, suspendedLanes); + break; + } // The render is suspended, it hasn't timed out, and there's no + // lower priority work to do. Instead of committing the fallback + // immediately, wait for more data to arrive. + + + root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), msUntilTimeout); + break; + } + } // The work expired. Commit immediately. + + + commitRoot(root); + break; + } + + case RootSuspendedWithDelay: + { + markRootSuspended$1(root, lanes); + + if (includesOnlyTransitions(lanes)) { + // This is a transition, so we should exit without committing a + // placeholder and without scheduling a timeout. Delay indefinitely + // until we receive more data. + break; + } + + if (!shouldForceFlushFallbacksInDEV()) { + // This is not a transition, but we did trigger an avoided state. + // Schedule a placeholder to display after a short delay, using the Just + // Noticeable Difference. + // TODO: Is the JND optimization worth the added complexity? If this is + // the only reason we track the event time, then probably not. + // Consider removing. + var mostRecentEventTime = getMostRecentEventTime(root, lanes); + var eventTimeMs = mostRecentEventTime; + var timeElapsedMs = now() - eventTimeMs; + + var _msUntilTimeout = jnd(timeElapsedMs) - timeElapsedMs; // Don't bother with a very short suspense time. + + + if (_msUntilTimeout > 10) { + // Instead of committing the fallback immediately, wait for more data + // to arrive. + root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout); + break; + } + } // Commit the placeholder. + + + commitRoot(root); + break; + } + + case RootCompleted: + { + // The work completed. Ready to commit. + commitRoot(root); + break; + } + + default: + { + { + { + throw Error( "Unknown root exit status." ); + } + } + } + } + } + + function markRootSuspended$1(root, suspendedLanes) { + // When suspending, we should always exclude lanes that were pinged or (more + // rarely, since we try to avoid it) updated during the render phase. + // TODO: Lol maybe there's a better way to factor this besides this + // obnoxiously named function :) + suspendedLanes = removeLanes(suspendedLanes, workInProgressRootPingedLanes); + suspendedLanes = removeLanes(suspendedLanes, workInProgressRootUpdatedLanes); + markRootSuspended(root, suspendedLanes); + } // This is the entry point for synchronous tasks that don't go + // through Scheduler + + + function performSyncWorkOnRoot(root) { + if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { + { + throw Error( "Should not already be working." ); + } + } + + flushPassiveEffects(); + var lanes; + var exitStatus; + + if (root === workInProgressRoot && includesSomeLane(root.expiredLanes, workInProgressRootRenderLanes)) { + // There's a partial tree, and at least one of its lanes has expired. Finish + // rendering it before rendering the rest of the expired work. + lanes = workInProgressRootRenderLanes; + exitStatus = renderRootSync(root, lanes); + + if (includesSomeLane(workInProgressRootIncludedLanes, workInProgressRootUpdatedLanes)) { + // The render included lanes that were updated during the render phase. + // For example, when unhiding a hidden tree, we include all the lanes + // that were previously skipped when the tree was hidden. That set of + // lanes is a superset of the lanes we started rendering with. + // + // Note that this only happens when part of the tree is rendered + // concurrently. If the whole tree is rendered synchronously, then there + // are no interleaved events. + lanes = getNextLanes(root, lanes); + exitStatus = renderRootSync(root, lanes); + } + } else { + lanes = getNextLanes(root, NoLanes); + exitStatus = renderRootSync(root, lanes); + } + + if (root.tag !== LegacyRoot && exitStatus === RootErrored) { + executionContext |= RetryAfterError; // If an error occurred during hydration, + // discard server response and fall back to client side render. + + if (root.hydrate) { + root.hydrate = false; + clearContainer(root.containerInfo); + } // If something threw an error, try rendering one more time. We'll render + // synchronously to block concurrent data mutations, and we'll includes + // all pending updates are included. If it still fails after the second + // attempt, we'll give up and commit the resulting tree. + + + lanes = getLanesToRetrySynchronouslyOnError(root); + + if (lanes !== NoLanes) { + exitStatus = renderRootSync(root, lanes); + } + } + + if (exitStatus === RootFatalErrored) { + var fatalError = workInProgressRootFatalError; + prepareFreshStack(root, NoLanes); + markRootSuspended$1(root, lanes); + ensureRootIsScheduled(root, now()); + throw fatalError; + } // We now have a consistent tree. Because this is a sync render, we + // will commit it even if something suspended. + + + var finishedWork = root.current.alternate; + root.finishedWork = finishedWork; + root.finishedLanes = lanes; + commitRoot(root); // Before exiting, make sure there's a callback scheduled for the next + // pending level. + + ensureRootIsScheduled(root, now()); + return null; + } + function flushDiscreteUpdates() { + // TODO: Should be able to flush inside batchedUpdates, but not inside `act`. + // However, `act` uses `batchedUpdates`, so there's no way to distinguish + // those two cases. Need to fix this before exposing flushDiscreteUpdates + // as a public API. + if ((executionContext & (BatchedContext | RenderContext | CommitContext)) !== NoContext) { + { + if ((executionContext & RenderContext) !== NoContext) { + error('unstable_flushDiscreteUpdates: Cannot flush updates when React is ' + 'already rendering.'); + } + } // We're already rendering, so we can't synchronously flush pending work. + // This is probably a nested event dispatch triggered by a lifecycle/effect, + // like `el.focus()`. Exit. + + + return; + } + + flushPendingDiscreteUpdates(); // If the discrete updates scheduled passive effects, flush them now so that + // they fire before the next serial event. + + flushPassiveEffects(); + } + + function flushPendingDiscreteUpdates() { + if (rootsWithPendingDiscreteUpdates !== null) { + // For each root with pending discrete updates, schedule a callback to + // immediately flush them. + var roots = rootsWithPendingDiscreteUpdates; + rootsWithPendingDiscreteUpdates = null; + roots.forEach(function (root) { + markDiscreteUpdatesExpired(root); + ensureRootIsScheduled(root, now()); + }); + } // Now flush the immediate queue. + + + flushSyncCallbackQueue(); + } + + function batchedUpdates$1(fn, a) { + var prevExecutionContext = executionContext; + executionContext |= BatchedContext; + + try { + return fn(a); + } finally { + executionContext = prevExecutionContext; + + if (executionContext === NoContext) { + // Flush the immediate callbacks that were scheduled during this batch + resetRenderTimer(); + flushSyncCallbackQueue(); + } + } + } + function batchedEventUpdates$1(fn, a) { + var prevExecutionContext = executionContext; + executionContext |= EventContext; + + try { + return fn(a); + } finally { + executionContext = prevExecutionContext; + + if (executionContext === NoContext) { + // Flush the immediate callbacks that were scheduled during this batch + resetRenderTimer(); + flushSyncCallbackQueue(); + } + } + } + function discreteUpdates$1(fn, a, b, c, d) { + var prevExecutionContext = executionContext; + executionContext |= DiscreteEventContext; + + { + try { + return runWithPriority$1(UserBlockingPriority$2, fn.bind(null, a, b, c, d)); + } finally { + executionContext = prevExecutionContext; + + if (executionContext === NoContext) { + // Flush the immediate callbacks that were scheduled during this batch + resetRenderTimer(); + flushSyncCallbackQueue(); + } + } + } + } + function unbatchedUpdates(fn, a) { + var prevExecutionContext = executionContext; + executionContext &= ~BatchedContext; + executionContext |= LegacyUnbatchedContext; + + try { + return fn(a); + } finally { + executionContext = prevExecutionContext; + + if (executionContext === NoContext) { + // Flush the immediate callbacks that were scheduled during this batch + resetRenderTimer(); + flushSyncCallbackQueue(); + } + } + } + function flushSync(fn, a) { + var prevExecutionContext = executionContext; + + if ((prevExecutionContext & (RenderContext | CommitContext)) !== NoContext) { + { + error('flushSync was called from inside a lifecycle method. React cannot ' + 'flush when React is already rendering. Consider moving this call to ' + 'a scheduler task or micro task.'); + } + + return fn(a); + } + + executionContext |= BatchedContext; + + { + try { + if (fn) { + return runWithPriority$1(ImmediatePriority$1, fn.bind(null, a)); + } else { + return undefined; + } + } finally { + executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch. + // Note that this will happen even if batchedUpdates is higher up + // the stack. + + flushSyncCallbackQueue(); + } + } + } + function pushRenderLanes(fiber, lanes) { + push(subtreeRenderLanesCursor, subtreeRenderLanes, fiber); + subtreeRenderLanes = mergeLanes(subtreeRenderLanes, lanes); + workInProgressRootIncludedLanes = mergeLanes(workInProgressRootIncludedLanes, lanes); + } + function popRenderLanes(fiber) { + subtreeRenderLanes = subtreeRenderLanesCursor.current; + pop(subtreeRenderLanesCursor, fiber); + } + + function prepareFreshStack(root, lanes) { + root.finishedWork = null; + root.finishedLanes = NoLanes; + var timeoutHandle = root.timeoutHandle; + + if (timeoutHandle !== noTimeout) { + // The root previous suspended and scheduled a timeout to commit a fallback + // state. Now that we have additional work, cancel the timeout. + root.timeoutHandle = noTimeout; // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above + + cancelTimeout(timeoutHandle); + } + + if (workInProgress !== null) { + var interruptedWork = workInProgress.return; + + while (interruptedWork !== null) { + unwindInterruptedWork(interruptedWork); + interruptedWork = interruptedWork.return; + } + } + + workInProgressRoot = root; + workInProgress = createWorkInProgress(root.current, null); + workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; + workInProgressRootExitStatus = RootIncomplete; + workInProgressRootFatalError = null; + workInProgressRootSkippedLanes = NoLanes; + workInProgressRootUpdatedLanes = NoLanes; + workInProgressRootPingedLanes = NoLanes; + + { + spawnedWorkDuringRender = null; + } + + { + ReactStrictModeWarnings.discardPendingWarnings(); + } + } + + function handleError(root, thrownValue) { + do { + var erroredWork = workInProgress; + + try { + // Reset module-level state that was set during the render phase. + resetContextDependencies(); + resetHooksAfterThrow(); + resetCurrentFiber(); // TODO: I found and added this missing line while investigating a + // separate issue. Write a regression test using string refs. + + ReactCurrentOwner$2.current = null; + + if (erroredWork === null || erroredWork.return === null) { + // Expected to be working on a non-root fiber. This is a fatal error + // because there's no ancestor that can handle it; the root is + // supposed to capture all errors that weren't caught by an error + // boundary. + workInProgressRootExitStatus = RootFatalErrored; + workInProgressRootFatalError = thrownValue; // Set `workInProgress` to null. This represents advancing to the next + // sibling, or the parent if there are no siblings. But since the root + // has no siblings nor a parent, we set it to null. Usually this is + // handled by `completeUnitOfWork` or `unwindWork`, but since we're + // intentionally not calling those, we need set it here. + // TODO: Consider calling `unwindWork` to pop the contexts. + + workInProgress = null; + return; + } + + if (enableProfilerTimer && erroredWork.mode & ProfileMode) { + // Record the time spent rendering before an error was thrown. This + // avoids inaccurate Profiler durations in the case of a + // suspended render. + stopProfilerTimerIfRunningAndRecordDelta(erroredWork, true); + } + + throwException(root, erroredWork.return, erroredWork, thrownValue, workInProgressRootRenderLanes); + completeUnitOfWork(erroredWork); + } catch (yetAnotherThrownValue) { + // Something in the return path also threw. + thrownValue = yetAnotherThrownValue; + + if (workInProgress === erroredWork && erroredWork !== null) { + // If this boundary has already errored, then we had trouble processing + // the error. Bubble it to the next boundary. + erroredWork = erroredWork.return; + workInProgress = erroredWork; + } else { + erroredWork = workInProgress; + } + + continue; + } // Return to the normal work loop. + + + return; + } while (true); + } + + function pushDispatcher() { + var prevDispatcher = ReactCurrentDispatcher$2.current; + ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; + + if (prevDispatcher === null) { + // The React isomorphic package does not include a default dispatcher. + // Instead the first renderer will lazily attach one, in order to give + // nicer error messages. + return ContextOnlyDispatcher; + } else { + return prevDispatcher; + } + } + + function popDispatcher(prevDispatcher) { + ReactCurrentDispatcher$2.current = prevDispatcher; + } + + function pushInteractions(root) { + { + var prevInteractions = __interactionsRef.current; + __interactionsRef.current = root.memoizedInteractions; + return prevInteractions; + } + } + + function popInteractions(prevInteractions) { + { + __interactionsRef.current = prevInteractions; + } + } + + function markCommitTimeOfFallback() { + globalMostRecentFallbackTime = now(); + } + function markSkippedUpdateLanes(lane) { + workInProgressRootSkippedLanes = mergeLanes(lane, workInProgressRootSkippedLanes); + } + function renderDidSuspend() { + if (workInProgressRootExitStatus === RootIncomplete) { + workInProgressRootExitStatus = RootSuspended; + } + } + function renderDidSuspendDelayIfPossible() { + if (workInProgressRootExitStatus === RootIncomplete || workInProgressRootExitStatus === RootSuspended) { + workInProgressRootExitStatus = RootSuspendedWithDelay; + } // Check if there are updates that we skipped tree that might have unblocked + // this render. + + + if (workInProgressRoot !== null && (includesNonIdleWork(workInProgressRootSkippedLanes) || includesNonIdleWork(workInProgressRootUpdatedLanes))) { + // Mark the current render as suspended so that we switch to working on + // the updates that were skipped. Usually we only suspend at the end of + // the render phase. + // TODO: We should probably always mark the root as suspended immediately + // (inside this function), since by suspending at the end of the render + // phase introduces a potential mistake where we suspend lanes that were + // pinged or updated while we were rendering. + markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes); + } + } + function renderDidError() { + if (workInProgressRootExitStatus !== RootCompleted) { + workInProgressRootExitStatus = RootErrored; + } + } // Called during render to determine if anything has suspended. + // Returns false if we're not sure. + + function renderHasNotSuspendedYet() { + // If something errored or completed, we can't really be sure, + // so those are false. + return workInProgressRootExitStatus === RootIncomplete; + } + + function renderRootSync(root, lanes) { + var prevExecutionContext = executionContext; + executionContext |= RenderContext; + var prevDispatcher = pushDispatcher(); // If the root or lanes have changed, throw out the existing stack + // and prepare a fresh one. Otherwise we'll continue where we left off. + + if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) { + prepareFreshStack(root, lanes); + startWorkOnPendingInteractions(root, lanes); + } + + var prevInteractions = pushInteractions(root); + + do { + try { + workLoopSync(); + break; + } catch (thrownValue) { + handleError(root, thrownValue); + } + } while (true); + + resetContextDependencies(); + + { + popInteractions(prevInteractions); + } + + executionContext = prevExecutionContext; + popDispatcher(prevDispatcher); + + if (workInProgress !== null) { + // This is a sync render, so we should have finished the whole tree. + { + { + throw Error( "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." ); + } + } + } + + + workInProgressRoot = null; + workInProgressRootRenderLanes = NoLanes; + return workInProgressRootExitStatus; + } // The work loop is an extremely hot path. Tell Closure not to inline it. + + /** @noinline */ + + + function workLoopSync() { + // Already timed out, so perform work without checking if we need to yield. + while (workInProgress !== null) { + performUnitOfWork(workInProgress); + } + } + + function renderRootConcurrent(root, lanes) { + var prevExecutionContext = executionContext; + executionContext |= RenderContext; + var prevDispatcher = pushDispatcher(); // If the root or lanes have changed, throw out the existing stack + // and prepare a fresh one. Otherwise we'll continue where we left off. + + if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) { + resetRenderTimer(); + prepareFreshStack(root, lanes); + startWorkOnPendingInteractions(root, lanes); + } + + var prevInteractions = pushInteractions(root); + + do { + try { + workLoopConcurrent(); + break; + } catch (thrownValue) { + handleError(root, thrownValue); + } + } while (true); + + resetContextDependencies(); + + { + popInteractions(prevInteractions); + } + + popDispatcher(prevDispatcher); + executionContext = prevExecutionContext; + + + if (workInProgress !== null) { + + return RootIncomplete; + } else { + + + workInProgressRoot = null; + workInProgressRootRenderLanes = NoLanes; // Return the final exit status. + + return workInProgressRootExitStatus; + } + } + /** @noinline */ + + + function workLoopConcurrent() { + // Perform work until Scheduler asks us to yield + while (workInProgress !== null && !shouldYield()) { + performUnitOfWork(workInProgress); + } + } + + function performUnitOfWork(unitOfWork) { + // The current, flushed, state of this fiber is the alternate. Ideally + // nothing should rely on this, but relying on it here means that we don't + // need an additional field on the work in progress. + var current = unitOfWork.alternate; + setCurrentFiber(unitOfWork); + var next; + + if ( (unitOfWork.mode & ProfileMode) !== NoMode) { + startProfilerTimer(unitOfWork); + next = beginWork$1(current, unitOfWork, subtreeRenderLanes); + stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); + } else { + next = beginWork$1(current, unitOfWork, subtreeRenderLanes); + } + + resetCurrentFiber(); + unitOfWork.memoizedProps = unitOfWork.pendingProps; + + if (next === null) { + // If this doesn't spawn new work, complete the current work. + completeUnitOfWork(unitOfWork); + } else { + workInProgress = next; + } + + ReactCurrentOwner$2.current = null; + } + + function completeUnitOfWork(unitOfWork) { + // Attempt to complete the current unit of work, then move to the next + // sibling. If there are no more siblings, return to the parent fiber. + var completedWork = unitOfWork; + + do { + // The current, flushed, state of this fiber is the alternate. Ideally + // nothing should rely on this, but relying on it here means that we don't + // need an additional field on the work in progress. + var current = completedWork.alternate; + var returnFiber = completedWork.return; // Check if the work completed or if something threw. + + if ((completedWork.flags & Incomplete) === NoFlags) { + setCurrentFiber(completedWork); + var next = void 0; + + if ( (completedWork.mode & ProfileMode) === NoMode) { + next = completeWork(current, completedWork, subtreeRenderLanes); + } else { + startProfilerTimer(completedWork); + next = completeWork(current, completedWork, subtreeRenderLanes); // Update render duration assuming we didn't error. + + stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); + } + + resetCurrentFiber(); + + if (next !== null) { + // Completing this fiber spawned new work. Work on that next. + workInProgress = next; + return; + } + + resetChildLanes(completedWork); + + if (returnFiber !== null && // Do not append effects to parents if a sibling failed to complete + (returnFiber.flags & Incomplete) === NoFlags) { + // Append all the effects of the subtree and this fiber onto the effect + // list of the parent. The completion order of the children affects the + // side-effect order. + if (returnFiber.firstEffect === null) { + returnFiber.firstEffect = completedWork.firstEffect; + } + + if (completedWork.lastEffect !== null) { + if (returnFiber.lastEffect !== null) { + returnFiber.lastEffect.nextEffect = completedWork.firstEffect; + } + + returnFiber.lastEffect = completedWork.lastEffect; + } // If this fiber had side-effects, we append it AFTER the children's + // side-effects. We can perform certain side-effects earlier if needed, + // by doing multiple passes over the effect list. We don't want to + // schedule our own side-effect on our own list because if end up + // reusing children we'll schedule this effect onto itself since we're + // at the end. + + + var flags = completedWork.flags; // Skip both NoWork and PerformedWork tags when creating the effect + // list. PerformedWork effect is read by React DevTools but shouldn't be + // committed. + + if (flags > PerformedWork) { + if (returnFiber.lastEffect !== null) { + returnFiber.lastEffect.nextEffect = completedWork; + } else { + returnFiber.firstEffect = completedWork; + } + + returnFiber.lastEffect = completedWork; + } + } + } else { + // This fiber did not complete because something threw. Pop values off + // the stack without entering the complete phase. If this is a boundary, + // capture values if possible. + var _next = unwindWork(completedWork); // Because this fiber did not complete, don't reset its expiration time. + + + if (_next !== null) { + // If completing this work spawned new work, do that next. We'll come + // back here again. + // Since we're restarting, remove anything that is not a host effect + // from the effect tag. + _next.flags &= HostEffectMask; + workInProgress = _next; + return; + } + + if ( (completedWork.mode & ProfileMode) !== NoMode) { + // Record the render duration for the fiber that errored. + stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); // Include the time spent working on failed children before continuing. + + var actualDuration = completedWork.actualDuration; + var child = completedWork.child; + + while (child !== null) { + actualDuration += child.actualDuration; + child = child.sibling; + } + + completedWork.actualDuration = actualDuration; + } + + if (returnFiber !== null) { + // Mark the parent fiber as incomplete and clear its effect list. + returnFiber.firstEffect = returnFiber.lastEffect = null; + returnFiber.flags |= Incomplete; + } + } + + var siblingFiber = completedWork.sibling; + + if (siblingFiber !== null) { + // If there is more work to do in this returnFiber, do that next. + workInProgress = siblingFiber; + return; + } // Otherwise, return to the parent + + + completedWork = returnFiber; // Update the next thing we're working on in case something throws. + + workInProgress = completedWork; + } while (completedWork !== null); // We've reached the root. + + + if (workInProgressRootExitStatus === RootIncomplete) { + workInProgressRootExitStatus = RootCompleted; + } + } + + function resetChildLanes(completedWork) { + if ( // TODO: Move this check out of the hot path by moving `resetChildLanes` + // to switch statement in `completeWork`. + (completedWork.tag === LegacyHiddenComponent || completedWork.tag === OffscreenComponent) && completedWork.memoizedState !== null && !includesSomeLane(subtreeRenderLanes, OffscreenLane) && (completedWork.mode & ConcurrentMode) !== NoLanes) { + // The children of this component are hidden. Don't bubble their + // expiration times. + return; + } + + var newChildLanes = NoLanes; // Bubble up the earliest expiration time. + + if ( (completedWork.mode & ProfileMode) !== NoMode) { + // In profiling mode, resetChildExpirationTime is also used to reset + // profiler durations. + var actualDuration = completedWork.actualDuration; + var treeBaseDuration = completedWork.selfBaseDuration; // When a fiber is cloned, its actualDuration is reset to 0. This value will + // only be updated if work is done on the fiber (i.e. it doesn't bailout). + // When work is done, it should bubble to the parent's actualDuration. If + // the fiber has not been cloned though, (meaning no work was done), then + // this value will reflect the amount of time spent working on a previous + // render. In that case it should not bubble. We determine whether it was + // cloned by comparing the child pointer. + + var shouldBubbleActualDurations = completedWork.alternate === null || completedWork.child !== completedWork.alternate.child; + var child = completedWork.child; + + while (child !== null) { + newChildLanes = mergeLanes(newChildLanes, mergeLanes(child.lanes, child.childLanes)); + + if (shouldBubbleActualDurations) { + actualDuration += child.actualDuration; + } + + treeBaseDuration += child.treeBaseDuration; + child = child.sibling; + } + + var isTimedOutSuspense = completedWork.tag === SuspenseComponent && completedWork.memoizedState !== null; + + if (isTimedOutSuspense) { + // Don't count time spent in a timed out Suspense subtree as part of the base duration. + var primaryChildFragment = completedWork.child; + + if (primaryChildFragment !== null) { + treeBaseDuration -= primaryChildFragment.treeBaseDuration; + } + } + + completedWork.actualDuration = actualDuration; + completedWork.treeBaseDuration = treeBaseDuration; + } else { + var _child = completedWork.child; + + while (_child !== null) { + newChildLanes = mergeLanes(newChildLanes, mergeLanes(_child.lanes, _child.childLanes)); + _child = _child.sibling; + } + } + + completedWork.childLanes = newChildLanes; + } + + function commitRoot(root) { + var renderPriorityLevel = getCurrentPriorityLevel(); + runWithPriority$1(ImmediatePriority$1, commitRootImpl.bind(null, root, renderPriorityLevel)); + return null; + } + + function commitRootImpl(root, renderPriorityLevel) { + do { + // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which + // means `flushPassiveEffects` will sometimes result in additional + // passive effects. So we need to keep flushing in a loop until there are + // no more pending effects. + // TODO: Might be better if `flushPassiveEffects` did not automatically + // flush synchronous work at the end, to avoid factoring hazards like this. + flushPassiveEffects(); + } while (rootWithPendingPassiveEffects !== null); + + flushRenderPhaseStrictModeWarningsInDEV(); + + if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { + { + throw Error( "Should not already be working." ); + } + } + + var finishedWork = root.finishedWork; + var lanes = root.finishedLanes; + + if (finishedWork === null) { + + return null; + } + + root.finishedWork = null; + root.finishedLanes = NoLanes; + + if (!(finishedWork !== root.current)) { + { + throw Error( "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." ); + } + } // commitRoot never returns a continuation; it always finishes synchronously. + // So we can clear these now to allow a new callback to be scheduled. + + + root.callbackNode = null; // Update the first and last pending times on this root. The new first + // pending time is whatever is left on the root fiber. + + var remainingLanes = mergeLanes(finishedWork.lanes, finishedWork.childLanes); + markRootFinished(root, remainingLanes); // Clear already finished discrete updates in case that a later call of + // `flushDiscreteUpdates` starts a useless render pass which may cancels + // a scheduled timeout. + + if (rootsWithPendingDiscreteUpdates !== null) { + if (!hasDiscreteLanes(remainingLanes) && rootsWithPendingDiscreteUpdates.has(root)) { + rootsWithPendingDiscreteUpdates.delete(root); + } + } + + if (root === workInProgressRoot) { + // We can reset these now that they are finished. + workInProgressRoot = null; + workInProgress = null; + workInProgressRootRenderLanes = NoLanes; + } // Get the list of effects. + + + var firstEffect; + + if (finishedWork.flags > PerformedWork) { + // A fiber's effect list consists only of its children, not itself. So if + // the root has an effect, we need to add it to the end of the list. The + // resulting list is the set that would belong to the root's parent, if it + // had one; that is, all the effects in the tree including the root. + if (finishedWork.lastEffect !== null) { + finishedWork.lastEffect.nextEffect = finishedWork; + firstEffect = finishedWork.firstEffect; + } else { + firstEffect = finishedWork; + } + } else { + // There is no effect on the root. + firstEffect = finishedWork.firstEffect; + } + + if (firstEffect !== null) { + + var prevExecutionContext = executionContext; + executionContext |= CommitContext; + var prevInteractions = pushInteractions(root); // Reset this to null before calling lifecycles + + ReactCurrentOwner$2.current = null; // The commit phase is broken into several sub-phases. We do a separate pass + // of the effect list for each phase: all mutation effects come before all + // layout effects, and so on. + // The first phase a "before mutation" phase. We use this phase to read the + // state of the host tree right before we mutate it. This is where + // getSnapshotBeforeUpdate is called. + + focusedInstanceHandle = prepareForCommit(root.containerInfo); + shouldFireAfterActiveInstanceBlur = false; + nextEffect = firstEffect; + + do { + { + invokeGuardedCallback(null, commitBeforeMutationEffects, null); + + if (hasCaughtError()) { + if (!(nextEffect !== null)) { + { + throw Error( "Should be working on an effect." ); + } + } + + var error = clearCaughtError(); + captureCommitPhaseError(nextEffect, error); + nextEffect = nextEffect.nextEffect; + } + } + } while (nextEffect !== null); // We no longer need to track the active instance fiber + + + focusedInstanceHandle = null; + + { + // Mark the current commit time to be shared by all Profilers in this + // batch. This enables them to be grouped later. + recordCommitTime(); + } // The next phase is the mutation phase, where we mutate the host tree. + + + nextEffect = firstEffect; + + do { + { + invokeGuardedCallback(null, commitMutationEffects, null, root, renderPriorityLevel); + + if (hasCaughtError()) { + if (!(nextEffect !== null)) { + { + throw Error( "Should be working on an effect." ); + } + } + + var _error = clearCaughtError(); + + captureCommitPhaseError(nextEffect, _error); + nextEffect = nextEffect.nextEffect; + } + } + } while (nextEffect !== null); + + resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after + // the mutation phase, so that the previous tree is still current during + // componentWillUnmount, but before the layout phase, so that the finished + // work is current during componentDidMount/Update. + + root.current = finishedWork; // The next phase is the layout phase, where we call effects that read + // the host tree after it's been mutated. The idiomatic use case for this is + // layout, but class component lifecycles also fire here for legacy reasons. + + nextEffect = firstEffect; + + do { + { + invokeGuardedCallback(null, commitLayoutEffects, null, root, lanes); + + if (hasCaughtError()) { + if (!(nextEffect !== null)) { + { + throw Error( "Should be working on an effect." ); + } + } + + var _error2 = clearCaughtError(); + + captureCommitPhaseError(nextEffect, _error2); + nextEffect = nextEffect.nextEffect; + } + } + } while (nextEffect !== null); + + nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an + // opportunity to paint. + + requestPaint(); + + { + popInteractions(prevInteractions); + } + + executionContext = prevExecutionContext; + } else { + // No effects. + root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were + // no effects. + // TODO: Maybe there's a better way to report this. + + { + recordCommitTime(); + } + } + + var rootDidHavePassiveEffects = rootDoesHavePassiveEffects; + + if (rootDoesHavePassiveEffects) { + // This commit has passive effects. Stash a reference to them. But don't + // schedule a callback until after flushing layout work. + rootDoesHavePassiveEffects = false; + rootWithPendingPassiveEffects = root; + pendingPassiveEffectsLanes = lanes; + pendingPassiveEffectsRenderPriority = renderPriorityLevel; + } else { + // We are done with the effect chain at this point so let's clear the + // nextEffect pointers to assist with GC. If we have passive effects, we'll + // clear this in flushPassiveEffects. + nextEffect = firstEffect; + + while (nextEffect !== null) { + var nextNextEffect = nextEffect.nextEffect; + nextEffect.nextEffect = null; + + if (nextEffect.flags & Deletion) { + detachFiberAfterEffects(nextEffect); + } + + nextEffect = nextNextEffect; + } + } // Read this again, since an effect might have updated it + + + remainingLanes = root.pendingLanes; // Check if there's remaining work on this root + + if (remainingLanes !== NoLanes) { + { + if (spawnedWorkDuringRender !== null) { + var expirationTimes = spawnedWorkDuringRender; + spawnedWorkDuringRender = null; + + for (var i = 0; i < expirationTimes.length; i++) { + scheduleInteractions(root, expirationTimes[i], root.memoizedInteractions); + } + } + + schedulePendingInteractions(root, remainingLanes); + } + } else { + // If there's no remaining work, we can clear the set of already failed + // error boundaries. + legacyErrorBoundariesThatAlreadyFailed = null; + } + + { + if (!rootDidHavePassiveEffects) { + // If there are no passive effects, then we can complete the pending interactions. + // Otherwise, we'll wait until after the passive effects are flushed. + // Wait to do this until after remaining work has been scheduled, + // so that we don't prematurely signal complete for interactions when there's e.g. hidden work. + finishPendingInteractions(root, lanes); + } + } + + if (remainingLanes === SyncLane) { + // Count the number of times the root synchronously re-renders without + // finishing. If there are too many, it indicates an infinite update loop. + if (root === rootWithNestedUpdates) { + nestedUpdateCount++; + } else { + nestedUpdateCount = 0; + rootWithNestedUpdates = root; + } + } else { + nestedUpdateCount = 0; + } + + onCommitRoot(finishedWork.stateNode, renderPriorityLevel); + + { + onCommitRoot$1(); + } // Always call this before exiting `commitRoot`, to ensure that any + // additional work on this root is scheduled. + + + ensureRootIsScheduled(root, now()); + + if (hasUncaughtError) { + hasUncaughtError = false; + var _error3 = firstUncaughtError; + firstUncaughtError = null; + throw _error3; + } + + if ((executionContext & LegacyUnbatchedContext) !== NoContext) { + // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired + // synchronously, but layout updates should be deferred until the end + // of the batch. + + + return null; + } // If layout work was scheduled, flush it now. + + + flushSyncCallbackQueue(); + + return null; + } + + function commitBeforeMutationEffects() { + while (nextEffect !== null) { + var current = nextEffect.alternate; + + if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) { + if ((nextEffect.flags & Deletion) !== NoFlags) { + if (doesFiberContain(nextEffect, focusedInstanceHandle)) { + shouldFireAfterActiveInstanceBlur = true; + } + } else { + // TODO: Move this out of the hot path using a dedicated effect tag. + if (nextEffect.tag === SuspenseComponent && isSuspenseBoundaryBeingHidden(current, nextEffect) && doesFiberContain(nextEffect, focusedInstanceHandle)) { + shouldFireAfterActiveInstanceBlur = true; + } + } + } + + var flags = nextEffect.flags; + + if ((flags & Snapshot) !== NoFlags) { + setCurrentFiber(nextEffect); + commitBeforeMutationLifeCycles(current, nextEffect); + resetCurrentFiber(); + } + + if ((flags & Passive) !== NoFlags) { + // If there are passive effects, schedule a callback to flush at + // the earliest opportunity. + if (!rootDoesHavePassiveEffects) { + rootDoesHavePassiveEffects = true; + scheduleCallback(NormalPriority$1, function () { + flushPassiveEffects(); + return null; + }); + } + } + + nextEffect = nextEffect.nextEffect; + } + } + + function commitMutationEffects(root, renderPriorityLevel) { + // TODO: Should probably move the bulk of this function to commitWork. + while (nextEffect !== null) { + setCurrentFiber(nextEffect); + var flags = nextEffect.flags; + + if (flags & ContentReset) { + commitResetTextContent(nextEffect); + } + + if (flags & Ref) { + var current = nextEffect.alternate; + + if (current !== null) { + commitDetachRef(current); + } + } // The following switch statement is only concerned about placement, + // updates, and deletions. To avoid needing to add a case for every possible + // bitmap value, we remove the secondary effects from the effect tag and + // switch on that value. + + + var primaryFlags = flags & (Placement | Update | Deletion | Hydrating); + + switch (primaryFlags) { + case Placement: + { + commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is + // inserted, before any life-cycles like componentDidMount gets called. + // TODO: findDOMNode doesn't rely on this any more but isMounted does + // and isMounted is deprecated anyway so we should be able to kill this. + + nextEffect.flags &= ~Placement; + break; + } + + case PlacementAndUpdate: + { + // Placement + commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is + // inserted, before any life-cycles like componentDidMount gets called. + + nextEffect.flags &= ~Placement; // Update + + var _current = nextEffect.alternate; + commitWork(_current, nextEffect); + break; + } + + case Hydrating: + { + nextEffect.flags &= ~Hydrating; + break; + } + + case HydratingAndUpdate: + { + nextEffect.flags &= ~Hydrating; // Update + + var _current2 = nextEffect.alternate; + commitWork(_current2, nextEffect); + break; + } + + case Update: + { + var _current3 = nextEffect.alternate; + commitWork(_current3, nextEffect); + break; + } + + case Deletion: + { + commitDeletion(root, nextEffect); + break; + } + } + + resetCurrentFiber(); + nextEffect = nextEffect.nextEffect; + } + } + + function commitLayoutEffects(root, committedLanes) { + + + while (nextEffect !== null) { + setCurrentFiber(nextEffect); + var flags = nextEffect.flags; + + if (flags & (Update | Callback)) { + var current = nextEffect.alternate; + commitLifeCycles(root, current, nextEffect); + } + + { + if (flags & Ref) { + commitAttachRef(nextEffect); + } + } + + resetCurrentFiber(); + nextEffect = nextEffect.nextEffect; + } + } + + function flushPassiveEffects() { + // Returns whether passive effects were flushed. + if (pendingPassiveEffectsRenderPriority !== NoPriority$1) { + var priorityLevel = pendingPassiveEffectsRenderPriority > NormalPriority$1 ? NormalPriority$1 : pendingPassiveEffectsRenderPriority; + pendingPassiveEffectsRenderPriority = NoPriority$1; + + { + return runWithPriority$1(priorityLevel, flushPassiveEffectsImpl); + } + } + + return false; + } + function enqueuePendingPassiveHookEffectMount(fiber, effect) { + pendingPassiveHookEffectsMount.push(effect, fiber); + + if (!rootDoesHavePassiveEffects) { + rootDoesHavePassiveEffects = true; + scheduleCallback(NormalPriority$1, function () { + flushPassiveEffects(); + return null; + }); + } + } + function enqueuePendingPassiveHookEffectUnmount(fiber, effect) { + pendingPassiveHookEffectsUnmount.push(effect, fiber); + + { + fiber.flags |= PassiveUnmountPendingDev; + var alternate = fiber.alternate; + + if (alternate !== null) { + alternate.flags |= PassiveUnmountPendingDev; + } + } + + if (!rootDoesHavePassiveEffects) { + rootDoesHavePassiveEffects = true; + scheduleCallback(NormalPriority$1, function () { + flushPassiveEffects(); + return null; + }); + } + } + + function invokePassiveEffectCreate(effect) { + var create = effect.create; + effect.destroy = create(); + } + + function flushPassiveEffectsImpl() { + if (rootWithPendingPassiveEffects === null) { + return false; + } + + var root = rootWithPendingPassiveEffects; + var lanes = pendingPassiveEffectsLanes; + rootWithPendingPassiveEffects = null; + pendingPassiveEffectsLanes = NoLanes; + + if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { + { + throw Error( "Cannot flush passive effects while already rendering." ); + } + } + + { + isFlushingPassiveEffects = true; + } + + var prevExecutionContext = executionContext; + executionContext |= CommitContext; + var prevInteractions = pushInteractions(root); // It's important that ALL pending passive effect destroy functions are called + // before ANY passive effect create functions are called. + // Otherwise effects in sibling components might interfere with each other. + // e.g. a destroy function in one component may unintentionally override a ref + // value set by a create function in another component. + // Layout effects have the same constraint. + // First pass: Destroy stale passive effects. + + var unmountEffects = pendingPassiveHookEffectsUnmount; + pendingPassiveHookEffectsUnmount = []; + + for (var i = 0; i < unmountEffects.length; i += 2) { + var _effect = unmountEffects[i]; + var fiber = unmountEffects[i + 1]; + var destroy = _effect.destroy; + _effect.destroy = undefined; + + { + fiber.flags &= ~PassiveUnmountPendingDev; + var alternate = fiber.alternate; + + if (alternate !== null) { + alternate.flags &= ~PassiveUnmountPendingDev; + } + } + + if (typeof destroy === 'function') { + { + setCurrentFiber(fiber); + + { + invokeGuardedCallback(null, destroy, null); + } + + if (hasCaughtError()) { + if (!(fiber !== null)) { + { + throw Error( "Should be working on an effect." ); + } + } + + var error = clearCaughtError(); + captureCommitPhaseError(fiber, error); + } + + resetCurrentFiber(); + } + } + } // Second pass: Create new passive effects. + + + var mountEffects = pendingPassiveHookEffectsMount; + pendingPassiveHookEffectsMount = []; + + for (var _i = 0; _i < mountEffects.length; _i += 2) { + var _effect2 = mountEffects[_i]; + var _fiber = mountEffects[_i + 1]; + + { + setCurrentFiber(_fiber); + + { + invokeGuardedCallback(null, invokePassiveEffectCreate, null, _effect2); + } + + if (hasCaughtError()) { + if (!(_fiber !== null)) { + { + throw Error( "Should be working on an effect." ); + } + } + + var _error4 = clearCaughtError(); + + captureCommitPhaseError(_fiber, _error4); + } + + resetCurrentFiber(); + } + } // Note: This currently assumes there are no passive effects on the root fiber + // because the root is not part of its own effect list. + // This could change in the future. + + + var effect = root.current.firstEffect; + + while (effect !== null) { + var nextNextEffect = effect.nextEffect; // Remove nextEffect pointer to assist GC + + effect.nextEffect = null; + + if (effect.flags & Deletion) { + detachFiberAfterEffects(effect); + } + + effect = nextNextEffect; + } + + { + popInteractions(prevInteractions); + finishPendingInteractions(root, lanes); + } + + { + isFlushingPassiveEffects = false; + } + + executionContext = prevExecutionContext; + flushSyncCallbackQueue(); // If additional passive effects were scheduled, increment a counter. If this + // exceeds the limit, we'll fire a warning. + + nestedPassiveUpdateCount = rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1; + return true; + } + + function isAlreadyFailedLegacyErrorBoundary(instance) { + return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance); + } + function markLegacyErrorBoundaryAsFailed(instance) { + if (legacyErrorBoundariesThatAlreadyFailed === null) { + legacyErrorBoundariesThatAlreadyFailed = new Set([instance]); + } else { + legacyErrorBoundariesThatAlreadyFailed.add(instance); + } + } + + function prepareToThrowUncaughtError(error) { + if (!hasUncaughtError) { + hasUncaughtError = true; + firstUncaughtError = error; + } + } + + var onUncaughtError = prepareToThrowUncaughtError; + + function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { + var errorInfo = createCapturedValue(error, sourceFiber); + var update = createRootErrorUpdate(rootFiber, errorInfo, SyncLane); + enqueueUpdate(rootFiber, update); + var eventTime = requestEventTime(); + var root = markUpdateLaneFromFiberToRoot(rootFiber, SyncLane); + + if (root !== null) { + markRootUpdated(root, SyncLane, eventTime); + ensureRootIsScheduled(root, eventTime); + schedulePendingInteractions(root, SyncLane); + } + } + + function captureCommitPhaseError(sourceFiber, error) { + if (sourceFiber.tag === HostRoot) { + // Error was thrown at the root. There is no parent, so the root + // itself should capture it. + captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); + return; + } + + var fiber = sourceFiber.return; + + while (fiber !== null) { + if (fiber.tag === HostRoot) { + captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); + return; + } else if (fiber.tag === ClassComponent) { + var ctor = fiber.type; + var instance = fiber.stateNode; + + if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) { + var errorInfo = createCapturedValue(error, sourceFiber); + var update = createClassErrorUpdate(fiber, errorInfo, SyncLane); + enqueueUpdate(fiber, update); + var eventTime = requestEventTime(); + var root = markUpdateLaneFromFiberToRoot(fiber, SyncLane); + + if (root !== null) { + markRootUpdated(root, SyncLane, eventTime); + ensureRootIsScheduled(root, eventTime); + schedulePendingInteractions(root, SyncLane); + } else { + // This component has already been unmounted. + // We can't schedule any follow up work for the root because the fiber is already unmounted, + // but we can still call the log-only boundary so the error isn't swallowed. + // + // TODO This is only a temporary bandaid for the old reconciler fork. + // We can delete this special case once the new fork is merged. + if (typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) { + try { + instance.componentDidCatch(error, errorInfo); + } catch (errorToIgnore) {// TODO Ignore this error? Rethrow it? + // This is kind of an edge case. + } + } + } + + return; + } + } + + fiber = fiber.return; + } + } + function pingSuspendedRoot(root, wakeable, pingedLanes) { + var pingCache = root.pingCache; + + if (pingCache !== null) { + // The wakeable resolved, so we no longer need to memoize, because it will + // never be thrown again. + pingCache.delete(wakeable); + } + + var eventTime = requestEventTime(); + markRootPinged(root, pingedLanes); + + if (workInProgressRoot === root && isSubsetOfLanes(workInProgressRootRenderLanes, pingedLanes)) { + // Received a ping at the same priority level at which we're currently + // rendering. We might want to restart this render. This should mirror + // the logic of whether or not a root suspends once it completes. + // TODO: If we're rendering sync either due to Sync, Batched or expired, + // we should probably never restart. + // If we're suspended with delay, or if it's a retry, we'll always suspend + // so we can always restart. + if (workInProgressRootExitStatus === RootSuspendedWithDelay || workInProgressRootExitStatus === RootSuspended && includesOnlyRetries(workInProgressRootRenderLanes) && now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) { + // Restart from the root. + prepareFreshStack(root, NoLanes); + } else { + // Even though we can't restart right now, we might get an + // opportunity later. So we mark this render as having a ping. + workInProgressRootPingedLanes = mergeLanes(workInProgressRootPingedLanes, pingedLanes); + } + } + + ensureRootIsScheduled(root, eventTime); + schedulePendingInteractions(root, pingedLanes); + } + + function retryTimedOutBoundary(boundaryFiber, retryLane) { + // The boundary fiber (a Suspense component or SuspenseList component) + // previously was rendered in its fallback state. One of the promises that + // suspended it has resolved, which means at least part of the tree was + // likely unblocked. Try rendering again, at a new expiration time. + if (retryLane === NoLane) { + retryLane = requestRetryLane(boundaryFiber); + } // TODO: Special case idle priority? + + + var eventTime = requestEventTime(); + var root = markUpdateLaneFromFiberToRoot(boundaryFiber, retryLane); + + if (root !== null) { + markRootUpdated(root, retryLane, eventTime); + ensureRootIsScheduled(root, eventTime); + schedulePendingInteractions(root, retryLane); + } + } + function resolveRetryWakeable(boundaryFiber, wakeable) { + var retryLane = NoLane; // Default + + var retryCache; + + { + retryCache = boundaryFiber.stateNode; + } + + if (retryCache !== null) { + // The wakeable resolved, so we no longer need to memoize, because it will + // never be thrown again. + retryCache.delete(wakeable); + } + + retryTimedOutBoundary(boundaryFiber, retryLane); + } // Computes the next Just Noticeable Difference (JND) boundary. + // The theory is that a person can't tell the difference between small differences in time. + // Therefore, if we wait a bit longer than necessary that won't translate to a noticeable + // difference in the experience. However, waiting for longer might mean that we can avoid + // showing an intermediate loading state. The longer we have already waited, the harder it + // is to tell small differences in time. Therefore, the longer we've already waited, + // the longer we can wait additionally. At some point we have to give up though. + // We pick a train model where the next boundary commits at a consistent schedule. + // These particular numbers are vague estimates. We expect to adjust them based on research. + + function jnd(timeElapsed) { + return timeElapsed < 120 ? 120 : timeElapsed < 480 ? 480 : timeElapsed < 1080 ? 1080 : timeElapsed < 1920 ? 1920 : timeElapsed < 3000 ? 3000 : timeElapsed < 4320 ? 4320 : ceil(timeElapsed / 1960) * 1960; + } + + function checkForNestedUpdates() { + if (nestedUpdateCount > NESTED_UPDATE_LIMIT) { + nestedUpdateCount = 0; + rootWithNestedUpdates = null; + + { + { + throw Error( "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." ); + } + } + } + + { + if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) { + nestedPassiveUpdateCount = 0; + + error('Maximum update depth exceeded. This can happen when a component ' + "calls setState inside useEffect, but useEffect either doesn't " + 'have a dependency array, or one of the dependencies changes on ' + 'every render.'); + } + } + } + + function flushRenderPhaseStrictModeWarningsInDEV() { + { + ReactStrictModeWarnings.flushLegacyContextWarning(); + + { + ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings(); + } + } + } + + var didWarnStateUpdateForNotYetMountedComponent = null; + + function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { + { + if ((executionContext & RenderContext) !== NoContext) { + // We let the other warning about render phase updates deal with this one. + return; + } + + if (!(fiber.mode & (BlockingMode | ConcurrentMode))) { + return; + } + + var tag = fiber.tag; + + if (tag !== IndeterminateComponent && tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent && tag !== Block) { + // Only warn for user-defined components, not internal ones like Suspense. + return; + } // We show the whole stack but dedupe on the top component's name because + // the problematic code almost always lies inside that component. + + + var componentName = getComponentName(fiber.type) || 'ReactComponent'; + + if (didWarnStateUpdateForNotYetMountedComponent !== null) { + if (didWarnStateUpdateForNotYetMountedComponent.has(componentName)) { + return; + } + + didWarnStateUpdateForNotYetMountedComponent.add(componentName); + } else { + didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]); + } + + var previousFiber = current; + + try { + setCurrentFiber(fiber); + + error("Can't perform a React state update on a component that hasn't mounted yet. " + 'This indicates that you have a side-effect in your render function that ' + 'asynchronously later calls tries to update the component. Move this work to ' + 'useEffect instead.'); + } finally { + if (previousFiber) { + setCurrentFiber(fiber); + } else { + resetCurrentFiber(); + } + } + } + } + + var didWarnStateUpdateForUnmountedComponent = null; + + function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { + { + var tag = fiber.tag; + + if (tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent && tag !== Block) { + // Only warn for user-defined components, not internal ones like Suspense. + return; + } // If there are pending passive effects unmounts for this Fiber, + // we can assume that they would have prevented this update. + + + if ((fiber.flags & PassiveUnmountPendingDev) !== NoFlags) { + return; + } // We show the whole stack but dedupe on the top component's name because + // the problematic code almost always lies inside that component. + + + var componentName = getComponentName(fiber.type) || 'ReactComponent'; + + if (didWarnStateUpdateForUnmountedComponent !== null) { + if (didWarnStateUpdateForUnmountedComponent.has(componentName)) { + return; + } + + didWarnStateUpdateForUnmountedComponent.add(componentName); + } else { + didWarnStateUpdateForUnmountedComponent = new Set([componentName]); + } + + if (isFlushingPassiveEffects) ; else { + var previousFiber = current; + + try { + setCurrentFiber(fiber); + + error("Can't perform a React state update on an unmounted component. This " + 'is a no-op, but it indicates a memory leak in your application. To ' + 'fix, cancel all subscriptions and asynchronous tasks in %s.', tag === ClassComponent ? 'the componentWillUnmount method' : 'a useEffect cleanup function'); + } finally { + if (previousFiber) { + setCurrentFiber(fiber); + } else { + resetCurrentFiber(); + } + } + } + } + } + + var beginWork$1; + + { + var dummyFiber = null; + + beginWork$1 = function (current, unitOfWork, lanes) { + // If a component throws an error, we replay it again in a synchronously + // dispatched event, so that the debugger will treat it as an uncaught + // error See ReactErrorUtils for more information. + // Before entering the begin phase, copy the work-in-progress onto a dummy + // fiber. If beginWork throws, we'll use this to reset the state. + var originalWorkInProgressCopy = assignFiberPropertiesInDEV(dummyFiber, unitOfWork); + + try { + return beginWork(current, unitOfWork, lanes); + } catch (originalError) { + if (originalError !== null && typeof originalError === 'object' && typeof originalError.then === 'function') { + // Don't replay promises. Treat everything else like an error. + throw originalError; + } // Keep this code in sync with handleError; any changes here must have + // corresponding changes there. + + + resetContextDependencies(); + resetHooksAfterThrow(); // Don't reset current debug fiber, since we're about to work on the + // same fiber again. + // Unwind the failed stack frame + + unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber. + + assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy); + + if ( unitOfWork.mode & ProfileMode) { + // Reset the profiler timer. + startProfilerTimer(unitOfWork); + } // Run beginWork again. + + + invokeGuardedCallback(null, beginWork, null, current, unitOfWork, lanes); + + if (hasCaughtError()) { + var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`. + // Rethrow this error instead of the original one. + + throw replayError; + } else { + // This branch is reachable if the render phase is impure. + throw originalError; + } + } + }; + } + + var didWarnAboutUpdateInRender = false; + var didWarnAboutUpdateInRenderForAnotherComponent; + + { + didWarnAboutUpdateInRenderForAnotherComponent = new Set(); + } + + function warnAboutRenderPhaseUpdatesInDEV(fiber) { + { + if (isRendering && (executionContext & RenderContext) !== NoContext && !getIsUpdatingOpaqueValueInRenderPhaseInDEV()) { + switch (fiber.tag) { + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: + { + var renderingComponentName = workInProgress && getComponentName(workInProgress.type) || 'Unknown'; // Dedupe by the rendering component because it's the one that needs to be fixed. + + var dedupeKey = renderingComponentName; + + if (!didWarnAboutUpdateInRenderForAnotherComponent.has(dedupeKey)) { + didWarnAboutUpdateInRenderForAnotherComponent.add(dedupeKey); + var setStateComponentName = getComponentName(fiber.type) || 'Unknown'; + + error('Cannot update a component (`%s`) while rendering a ' + 'different component (`%s`). To locate the bad setState() call inside `%s`, ' + 'follow the stack trace as described in https://reactjs.org/link/setstate-in-render', setStateComponentName, renderingComponentName, renderingComponentName); + } + + break; + } + + case ClassComponent: + { + if (!didWarnAboutUpdateInRender) { + error('Cannot update during an existing state transition (such as ' + 'within `render`). Render methods should be a pure ' + 'function of props and state.'); + + didWarnAboutUpdateInRender = true; + } + + break; + } + } + } + } + } // a 'shared' variable that changes when act() opens/closes in tests. + + + var IsThisRendererActing = { + current: false + }; + function warnIfNotScopedWithMatchingAct(fiber) { + { + if ( IsSomeRendererActing.current === true && IsThisRendererActing.current !== true) { + var previousFiber = current; + + try { + setCurrentFiber(fiber); + + error("It looks like you're using the wrong act() around your test interactions.\n" + 'Be sure to use the matching version of act() corresponding to your renderer:\n\n' + '// for react-dom:\n' + // Break up imports to avoid accidentally parsing them as dependencies. + 'import {act} fr' + "om 'react-dom/test-utils';\n" + '// ...\n' + 'act(() => ...);\n\n' + '// for react-test-renderer:\n' + // Break up imports to avoid accidentally parsing them as dependencies. + 'import TestRenderer fr' + "om react-test-renderer';\n" + 'const {act} = TestRenderer;\n' + '// ...\n' + 'act(() => ...);'); + } finally { + if (previousFiber) { + setCurrentFiber(fiber); + } else { + resetCurrentFiber(); + } + } + } + } + } + function warnIfNotCurrentlyActingEffectsInDEV(fiber) { + { + if ( (fiber.mode & StrictMode) !== NoMode && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) { + error('An update to %s ran an effect, but was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://reactjs.org/link/wrap-tests-with-act', getComponentName(fiber.type)); + } + } + } + + function warnIfNotCurrentlyActingUpdatesInDEV(fiber) { + { + if ( executionContext === NoContext && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) { + var previousFiber = current; + + try { + setCurrentFiber(fiber); + + error('An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://reactjs.org/link/wrap-tests-with-act', getComponentName(fiber.type)); + } finally { + if (previousFiber) { + setCurrentFiber(fiber); + } else { + resetCurrentFiber(); + } + } + } + } + } + + var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV; // In tests, we want to enforce a mocked scheduler. + + var didWarnAboutUnmockedScheduler = false; // TODO Before we release concurrent mode, revisit this and decide whether a mocked + // scheduler is the actual recommendation. The alternative could be a testing build, + // a new lib, or whatever; we dunno just yet. This message is for early adopters + // to get their tests right. + + function warnIfUnmockedScheduler(fiber) { + { + if (didWarnAboutUnmockedScheduler === false && unstable_flushAllWithoutAsserting === undefined) { + if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) { + didWarnAboutUnmockedScheduler = true; + + error('In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' + 'to guarantee consistent behaviour across tests and browsers. ' + 'For example, with jest: \n' + // Break up requires to avoid accidentally parsing them as dependencies. + "jest.mock('scheduler', () => require" + "('scheduler/unstable_mock'));\n\n" + 'For more info, visit https://reactjs.org/link/mock-scheduler'); + } + } + } + } + + function computeThreadID(root, lane) { + // Interaction threads are unique per root and expiration time. + // NOTE: Intentionally unsound cast. All that matters is that it's a number + // and it represents a batch of work. Could make a helper function instead, + // but meh this is fine for now. + return lane * 1000 + root.interactionThreadID; + } + + function markSpawnedWork(lane) { + + if (spawnedWorkDuringRender === null) { + spawnedWorkDuringRender = [lane]; + } else { + spawnedWorkDuringRender.push(lane); + } + } + + function scheduleInteractions(root, lane, interactions) { + + if (interactions.size > 0) { + var pendingInteractionMap = root.pendingInteractionMap; + var pendingInteractions = pendingInteractionMap.get(lane); + + if (pendingInteractions != null) { + interactions.forEach(function (interaction) { + if (!pendingInteractions.has(interaction)) { + // Update the pending async work count for previously unscheduled interaction. + interaction.__count++; + } + + pendingInteractions.add(interaction); + }); + } else { + pendingInteractionMap.set(lane, new Set(interactions)); // Update the pending async work count for the current interactions. + + interactions.forEach(function (interaction) { + interaction.__count++; + }); + } + + var subscriber = __subscriberRef.current; + + if (subscriber !== null) { + var threadID = computeThreadID(root, lane); + subscriber.onWorkScheduled(interactions, threadID); + } + } + } + + function schedulePendingInteractions(root, lane) { + + scheduleInteractions(root, lane, __interactionsRef.current); + } + + function startWorkOnPendingInteractions(root, lanes) { + // we can accurately attribute time spent working on it, And so that cascading + // work triggered during the render phase will be associated with it. + + + var interactions = new Set(); + root.pendingInteractionMap.forEach(function (scheduledInteractions, scheduledLane) { + if (includesSomeLane(lanes, scheduledLane)) { + scheduledInteractions.forEach(function (interaction) { + return interactions.add(interaction); + }); + } + }); // Store the current set of interactions on the FiberRoot for a few reasons: + // We can re-use it in hot functions like performConcurrentWorkOnRoot() + // without having to recalculate it. We will also use it in commitWork() to + // pass to any Profiler onRender() hooks. This also provides DevTools with a + // way to access it when the onCommitRoot() hook is called. + + root.memoizedInteractions = interactions; + + if (interactions.size > 0) { + var subscriber = __subscriberRef.current; + + if (subscriber !== null) { + var threadID = computeThreadID(root, lanes); + + try { + subscriber.onWorkStarted(interactions, threadID); + } catch (error) { + // If the subscriber throws, rethrow it in a separate task + scheduleCallback(ImmediatePriority$1, function () { + throw error; + }); + } + } + } + } + + function finishPendingInteractions(root, committedLanes) { + + var remainingLanesAfterCommit = root.pendingLanes; + var subscriber; + + try { + subscriber = __subscriberRef.current; + + if (subscriber !== null && root.memoizedInteractions.size > 0) { + // FIXME: More than one lane can finish in a single commit. + var threadID = computeThreadID(root, committedLanes); + subscriber.onWorkStopped(root.memoizedInteractions, threadID); + } + } catch (error) { + // If the subscriber throws, rethrow it in a separate task + scheduleCallback(ImmediatePriority$1, function () { + throw error; + }); + } finally { + // Clear completed interactions from the pending Map. + // Unless the render was suspended or cascading work was scheduled, + // In which case– leave pending interactions until the subsequent render. + var pendingInteractionMap = root.pendingInteractionMap; + pendingInteractionMap.forEach(function (scheduledInteractions, lane) { + // Only decrement the pending interaction count if we're done. + // If there's still work at the current priority, + // That indicates that we are waiting for suspense data. + if (!includesSomeLane(remainingLanesAfterCommit, lane)) { + pendingInteractionMap.delete(lane); + scheduledInteractions.forEach(function (interaction) { + interaction.__count--; + + if (subscriber !== null && interaction.__count === 0) { + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + // If the subscriber throws, rethrow it in a separate task + scheduleCallback(ImmediatePriority$1, function () { + throw error; + }); + } + } + }); + } + }); + } + } // `act` testing API + + function shouldForceFlushFallbacksInDEV() { + // Never force flush in production. This function should get stripped out. + return actingUpdatesScopeDepth > 0; + } + // so we can tell if any async act() calls try to run in parallel. + + + var actingUpdatesScopeDepth = 0; + + function detachFiberAfterEffects(fiber) { + fiber.sibling = null; + fiber.stateNode = null; + } + + var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below. + + var failedBoundaries = null; + var setRefreshHandler = function (handler) { + { + resolveFamily = handler; + } + }; + function resolveFunctionForHotReloading(type) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return type; + } + + var family = resolveFamily(type); + + if (family === undefined) { + return type; + } // Use the latest known implementation. + + + return family.current; + } + } + function resolveClassForHotReloading(type) { + // No implementation differences. + return resolveFunctionForHotReloading(type); + } + function resolveForwardRefForHotReloading(type) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return type; + } + + var family = resolveFamily(type); + + if (family === undefined) { + // Check if we're dealing with a real forwardRef. Don't want to crash early. + if (type !== null && type !== undefined && typeof type.render === 'function') { + // ForwardRef is special because its resolved .type is an object, + // but it's possible that we only have its inner render function in the map. + // If that inner render function is different, we'll build a new forwardRef type. + var currentRender = resolveFunctionForHotReloading(type.render); + + if (type.render !== currentRender) { + var syntheticType = { + $$typeof: REACT_FORWARD_REF_TYPE, + render: currentRender + }; + + if (type.displayName !== undefined) { + syntheticType.displayName = type.displayName; + } + + return syntheticType; + } + } + + return type; + } // Use the latest known implementation. + + + return family.current; + } + } + function isCompatibleFamilyForHotReloading(fiber, element) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return false; + } + + var prevType = fiber.elementType; + var nextType = element.type; // If we got here, we know types aren't === equal. + + var needsCompareFamilies = false; + var $$typeofNextType = typeof nextType === 'object' && nextType !== null ? nextType.$$typeof : null; + + switch (fiber.tag) { + case ClassComponent: + { + if (typeof nextType === 'function') { + needsCompareFamilies = true; + } + + break; + } + + case FunctionComponent: + { + if (typeof nextType === 'function') { + needsCompareFamilies = true; + } else if ($$typeofNextType === REACT_LAZY_TYPE) { + // We don't know the inner type yet. + // We're going to assume that the lazy inner type is stable, + // and so it is sufficient to avoid reconciling it away. + // We're not going to unwrap or actually use the new lazy type. + needsCompareFamilies = true; + } + + break; + } + + case ForwardRef: + { + if ($$typeofNextType === REACT_FORWARD_REF_TYPE) { + needsCompareFamilies = true; + } else if ($$typeofNextType === REACT_LAZY_TYPE) { + needsCompareFamilies = true; + } + + break; + } + + case MemoComponent: + case SimpleMemoComponent: + { + if ($$typeofNextType === REACT_MEMO_TYPE) { + // TODO: if it was but can no longer be simple, + // we shouldn't set this. + needsCompareFamilies = true; + } else if ($$typeofNextType === REACT_LAZY_TYPE) { + needsCompareFamilies = true; + } + + break; + } + + default: + return false; + } // Check if both types have a family and it's the same one. + + + if (needsCompareFamilies) { + // Note: memo() and forwardRef() we'll compare outer rather than inner type. + // This means both of them need to be registered to preserve state. + // If we unwrapped and compared the inner types for wrappers instead, + // then we would risk falsely saying two separate memo(Foo) + // calls are equivalent because they wrap the same Foo function. + var prevFamily = resolveFamily(prevType); + + if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) { + return true; + } + } + + return false; + } + } + function markFailedErrorBoundaryForHotReloading(fiber) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return; + } + + if (typeof WeakSet !== 'function') { + return; + } + + if (failedBoundaries === null) { + failedBoundaries = new WeakSet(); + } + + failedBoundaries.add(fiber); + } + } + var scheduleRefresh = function (root, update) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return; + } + + var staleFamilies = update.staleFamilies, + updatedFamilies = update.updatedFamilies; + flushPassiveEffects(); + flushSync(function () { + scheduleFibersWithFamiliesRecursively(root.current, updatedFamilies, staleFamilies); + }); + } + }; + var scheduleRoot = function (root, element) { + { + if (root.context !== emptyContextObject) { + // Super edge case: root has a legacy _renderSubtree context + // but we don't know the parentComponent so we can't pass it. + // Just ignore. We'll delete this with _renderSubtree code path later. + return; + } + + flushPassiveEffects(); + flushSync(function () { + updateContainer(element, root, null, null); + }); + } + }; + + function scheduleFibersWithFamiliesRecursively(fiber, updatedFamilies, staleFamilies) { + { + var alternate = fiber.alternate, + child = fiber.child, + sibling = fiber.sibling, + tag = fiber.tag, + type = fiber.type; + var candidateType = null; + + switch (tag) { + case FunctionComponent: + case SimpleMemoComponent: + case ClassComponent: + candidateType = type; + break; + + case ForwardRef: + candidateType = type.render; + break; + } + + if (resolveFamily === null) { + throw new Error('Expected resolveFamily to be set during hot reload.'); + } + + var needsRender = false; + var needsRemount = false; + + if (candidateType !== null) { + var family = resolveFamily(candidateType); + + if (family !== undefined) { + if (staleFamilies.has(family)) { + needsRemount = true; + } else if (updatedFamilies.has(family)) { + if (tag === ClassComponent) { + needsRemount = true; + } else { + needsRender = true; + } + } + } + } + + if (failedBoundaries !== null) { + if (failedBoundaries.has(fiber) || alternate !== null && failedBoundaries.has(alternate)) { + needsRemount = true; + } + } + + if (needsRemount) { + fiber._debugNeedsRemount = true; + } + + if (needsRemount || needsRender) { + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + } + + if (child !== null && !needsRemount) { + scheduleFibersWithFamiliesRecursively(child, updatedFamilies, staleFamilies); + } + + if (sibling !== null) { + scheduleFibersWithFamiliesRecursively(sibling, updatedFamilies, staleFamilies); + } + } + } + + var findHostInstancesForRefresh = function (root, families) { + { + var hostInstances = new Set(); + var types = new Set(families.map(function (family) { + return family.current; + })); + findHostInstancesForMatchingFibersRecursively(root.current, types, hostInstances); + return hostInstances; + } + }; + + function findHostInstancesForMatchingFibersRecursively(fiber, types, hostInstances) { + { + var child = fiber.child, + sibling = fiber.sibling, + tag = fiber.tag, + type = fiber.type; + var candidateType = null; + + switch (tag) { + case FunctionComponent: + case SimpleMemoComponent: + case ClassComponent: + candidateType = type; + break; + + case ForwardRef: + candidateType = type.render; + break; + } + + var didMatch = false; + + if (candidateType !== null) { + if (types.has(candidateType)) { + didMatch = true; + } + } + + if (didMatch) { + // We have a match. This only drills down to the closest host components. + // There's no need to search deeper because for the purpose of giving + // visual feedback, "flashing" outermost parent rectangles is sufficient. + findHostInstancesForFiberShallowly(fiber, hostInstances); + } else { + // If there's no match, maybe there will be one further down in the child tree. + if (child !== null) { + findHostInstancesForMatchingFibersRecursively(child, types, hostInstances); + } + } + + if (sibling !== null) { + findHostInstancesForMatchingFibersRecursively(sibling, types, hostInstances); + } + } + } + + function findHostInstancesForFiberShallowly(fiber, hostInstances) { + { + var foundHostInstances = findChildHostInstancesForFiberShallowly(fiber, hostInstances); + + if (foundHostInstances) { + return; + } // If we didn't find any host children, fallback to closest host parent. + + + var node = fiber; + + while (true) { + switch (node.tag) { + case HostComponent: + hostInstances.add(node.stateNode); + return; + + case HostPortal: + hostInstances.add(node.stateNode.containerInfo); + return; + + case HostRoot: + hostInstances.add(node.stateNode.containerInfo); + return; + } + + if (node.return === null) { + throw new Error('Expected to reach root first.'); + } + + node = node.return; + } + } + } + + function findChildHostInstancesForFiberShallowly(fiber, hostInstances) { + { + var node = fiber; + var foundHostInstances = false; + + while (true) { + if (node.tag === HostComponent) { + // We got a match. + foundHostInstances = true; + hostInstances.add(node.stateNode); // There may still be more, so keep searching. + } else if (node.child !== null) { + node.child.return = node; + node = node.child; + continue; + } + + if (node === fiber) { + return foundHostInstances; + } + + while (node.sibling === null) { + if (node.return === null || node.return === fiber) { + return foundHostInstances; + } + + node = node.return; + } + + node.sibling.return = node.return; + node = node.sibling; + } + } + + return false; + } + + var hasBadMapPolyfill; + + { + hasBadMapPolyfill = false; + + try { + var nonExtensibleObject = Object.preventExtensions({}); + /* eslint-disable no-new */ + + new Map([[nonExtensibleObject, null]]); + new Set([nonExtensibleObject]); + /* eslint-enable no-new */ + } catch (e) { + // TODO: Consider warning about bad polyfills + hasBadMapPolyfill = true; + } + } + + var debugCounter = 1; + + function FiberNode(tag, pendingProps, key, mode) { + // Instance + this.tag = tag; + this.key = key; + this.elementType = null; + this.type = null; + this.stateNode = null; // Fiber + + this.return = null; + this.child = null; + this.sibling = null; + this.index = 0; + this.ref = null; + this.pendingProps = pendingProps; + this.memoizedProps = null; + this.updateQueue = null; + this.memoizedState = null; + this.dependencies = null; + this.mode = mode; // Effects + + this.flags = NoFlags; + this.nextEffect = null; + this.firstEffect = null; + this.lastEffect = null; + this.lanes = NoLanes; + this.childLanes = NoLanes; + this.alternate = null; + + { + // Note: The following is done to avoid a v8 performance cliff. + // + // Initializing the fields below to smis and later updating them with + // double values will cause Fibers to end up having separate shapes. + // This behavior/bug has something to do with Object.preventExtension(). + // Fortunately this only impacts DEV builds. + // Unfortunately it makes React unusably slow for some applications. + // To work around this, initialize the fields below with doubles. + // + // Learn more about this here: + // https://github.com/facebook/react/issues/14365 + // https://bugs.chromium.org/p/v8/issues/detail?id=8538 + this.actualDuration = Number.NaN; + this.actualStartTime = Number.NaN; + this.selfBaseDuration = Number.NaN; + this.treeBaseDuration = Number.NaN; // It's okay to replace the initial doubles with smis after initialization. + // This won't trigger the performance cliff mentioned above, + // and it simplifies other profiler code (including DevTools). + + this.actualDuration = 0; + this.actualStartTime = -1; + this.selfBaseDuration = 0; + this.treeBaseDuration = 0; + } + + { + // This isn't directly used but is handy for debugging internals: + this._debugID = debugCounter++; + this._debugSource = null; + this._debugOwner = null; + this._debugNeedsRemount = false; + this._debugHookTypes = null; + + if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') { + Object.preventExtensions(this); + } + } + } // This is a constructor function, rather than a POJO constructor, still + // please ensure we do the following: + // 1) Nobody should add any instance methods on this. Instance methods can be + // more difficult to predict when they get optimized and they are almost + // never inlined properly in static compilers. + // 2) Nobody should rely on `instanceof Fiber` for type testing. We should + // always know when it is a fiber. + // 3) We might want to experiment with using numeric keys since they are easier + // to optimize in a non-JIT environment. + // 4) We can easily go from a constructor to a createFiber object literal if that + // is faster. + // 5) It should be easy to port this to a C struct and keep a C implementation + // compatible. + + + var createFiber = function (tag, pendingProps, key, mode) { + // $FlowFixMe: the shapes are exact here but Flow doesn't like constructors + return new FiberNode(tag, pendingProps, key, mode); + }; + + function shouldConstruct$1(Component) { + var prototype = Component.prototype; + return !!(prototype && prototype.isReactComponent); + } + + function isSimpleFunctionComponent(type) { + return typeof type === 'function' && !shouldConstruct$1(type) && type.defaultProps === undefined; + } + function resolveLazyComponentTag(Component) { + if (typeof Component === 'function') { + return shouldConstruct$1(Component) ? ClassComponent : FunctionComponent; + } else if (Component !== undefined && Component !== null) { + var $$typeof = Component.$$typeof; + + if ($$typeof === REACT_FORWARD_REF_TYPE) { + return ForwardRef; + } + + if ($$typeof === REACT_MEMO_TYPE) { + return MemoComponent; + } + } + + return IndeterminateComponent; + } // This is used to create an alternate fiber to do work on. + + function createWorkInProgress(current, pendingProps) { + var workInProgress = current.alternate; + + if (workInProgress === null) { + // We use a double buffering pooling technique because we know that we'll + // only ever need at most two versions of a tree. We pool the "other" unused + // node that we're free to reuse. This is lazily created to avoid allocating + // extra objects for things that are never updated. It also allow us to + // reclaim the extra memory if needed. + workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode); + workInProgress.elementType = current.elementType; + workInProgress.type = current.type; + workInProgress.stateNode = current.stateNode; + + { + // DEV-only fields + workInProgress._debugID = current._debugID; + workInProgress._debugSource = current._debugSource; + workInProgress._debugOwner = current._debugOwner; + workInProgress._debugHookTypes = current._debugHookTypes; + } + + workInProgress.alternate = current; + current.alternate = workInProgress; + } else { + workInProgress.pendingProps = pendingProps; // Needed because Blocks store data on type. + + workInProgress.type = current.type; // We already have an alternate. + // Reset the effect tag. + + workInProgress.flags = NoFlags; // The effect list is no longer valid. + + workInProgress.nextEffect = null; + workInProgress.firstEffect = null; + workInProgress.lastEffect = null; + + { + // We intentionally reset, rather than copy, actualDuration & actualStartTime. + // This prevents time from endlessly accumulating in new commits. + // This has the downside of resetting values for different priority renders, + // But works for yielding (the common case) and should support resuming. + workInProgress.actualDuration = 0; + workInProgress.actualStartTime = -1; + } + } + + workInProgress.childLanes = current.childLanes; + workInProgress.lanes = current.lanes; + workInProgress.child = current.child; + workInProgress.memoizedProps = current.memoizedProps; + workInProgress.memoizedState = current.memoizedState; + workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so + // it cannot be shared with the current fiber. + + var currentDependencies = current.dependencies; + workInProgress.dependencies = currentDependencies === null ? null : { + lanes: currentDependencies.lanes, + firstContext: currentDependencies.firstContext + }; // These will be overridden during the parent's reconciliation + + workInProgress.sibling = current.sibling; + workInProgress.index = current.index; + workInProgress.ref = current.ref; + + { + workInProgress.selfBaseDuration = current.selfBaseDuration; + workInProgress.treeBaseDuration = current.treeBaseDuration; + } + + { + workInProgress._debugNeedsRemount = current._debugNeedsRemount; + + switch (workInProgress.tag) { + case IndeterminateComponent: + case FunctionComponent: + case SimpleMemoComponent: + workInProgress.type = resolveFunctionForHotReloading(current.type); + break; + + case ClassComponent: + workInProgress.type = resolveClassForHotReloading(current.type); + break; + + case ForwardRef: + workInProgress.type = resolveForwardRefForHotReloading(current.type); + break; + } + } + + return workInProgress; + } // Used to reuse a Fiber for a second pass. + + function resetWorkInProgress(workInProgress, renderLanes) { + // This resets the Fiber to what createFiber or createWorkInProgress would + // have set the values to before during the first pass. Ideally this wouldn't + // be necessary but unfortunately many code paths reads from the workInProgress + // when they should be reading from current and writing to workInProgress. + // We assume pendingProps, index, key, ref, return are still untouched to + // avoid doing another reconciliation. + // Reset the effect tag but keep any Placement tags, since that's something + // that child fiber is setting, not the reconciliation. + workInProgress.flags &= Placement; // The effect list is no longer valid. + + workInProgress.nextEffect = null; + workInProgress.firstEffect = null; + workInProgress.lastEffect = null; + var current = workInProgress.alternate; + + if (current === null) { + // Reset to createFiber's initial values. + workInProgress.childLanes = NoLanes; + workInProgress.lanes = renderLanes; + workInProgress.child = null; + workInProgress.memoizedProps = null; + workInProgress.memoizedState = null; + workInProgress.updateQueue = null; + workInProgress.dependencies = null; + workInProgress.stateNode = null; + + { + // Note: We don't reset the actualTime counts. It's useful to accumulate + // actual time across multiple render passes. + workInProgress.selfBaseDuration = 0; + workInProgress.treeBaseDuration = 0; + } + } else { + // Reset to the cloned values that createWorkInProgress would've. + workInProgress.childLanes = current.childLanes; + workInProgress.lanes = current.lanes; + workInProgress.child = current.child; + workInProgress.memoizedProps = current.memoizedProps; + workInProgress.memoizedState = current.memoizedState; + workInProgress.updateQueue = current.updateQueue; // Needed because Blocks store data on type. + + workInProgress.type = current.type; // Clone the dependencies object. This is mutated during the render phase, so + // it cannot be shared with the current fiber. + + var currentDependencies = current.dependencies; + workInProgress.dependencies = currentDependencies === null ? null : { + lanes: currentDependencies.lanes, + firstContext: currentDependencies.firstContext + }; + + { + // Note: We don't reset the actualTime counts. It's useful to accumulate + // actual time across multiple render passes. + workInProgress.selfBaseDuration = current.selfBaseDuration; + workInProgress.treeBaseDuration = current.treeBaseDuration; + } + } + + return workInProgress; + } + function createHostRootFiber(tag) { + var mode; + + if (tag === ConcurrentRoot) { + mode = ConcurrentMode | BlockingMode | StrictMode; + } else if (tag === BlockingRoot) { + mode = BlockingMode | StrictMode; + } else { + mode = NoMode; + } + + if ( isDevToolsPresent) { + // Always collect profile timings when DevTools are present. + // This enables DevTools to start capturing timing at any point– + // Without some nodes in the tree having empty base times. + mode |= ProfileMode; + } + + return createFiber(HostRoot, null, null, mode); + } + function createFiberFromTypeAndProps(type, // React$ElementType + key, pendingProps, owner, mode, lanes) { + var fiberTag = IndeterminateComponent; // The resolved type is set if we know what the final type will be. I.e. it's not lazy. + + var resolvedType = type; + + if (typeof type === 'function') { + if (shouldConstruct$1(type)) { + fiberTag = ClassComponent; + + { + resolvedType = resolveClassForHotReloading(resolvedType); + } + } else { + { + resolvedType = resolveFunctionForHotReloading(resolvedType); + } + } + } else if (typeof type === 'string') { + fiberTag = HostComponent; + } else { + getTag: switch (type) { + case REACT_FRAGMENT_TYPE: + return createFiberFromFragment(pendingProps.children, mode, lanes, key); + + case REACT_DEBUG_TRACING_MODE_TYPE: + fiberTag = Mode; + mode |= DebugTracingMode; + break; + + case REACT_STRICT_MODE_TYPE: + fiberTag = Mode; + mode |= StrictMode; + break; + + case REACT_PROFILER_TYPE: + return createFiberFromProfiler(pendingProps, mode, lanes, key); + + case REACT_SUSPENSE_TYPE: + return createFiberFromSuspense(pendingProps, mode, lanes, key); + + case REACT_SUSPENSE_LIST_TYPE: + return createFiberFromSuspenseList(pendingProps, mode, lanes, key); + + case REACT_OFFSCREEN_TYPE: + return createFiberFromOffscreen(pendingProps, mode, lanes, key); + + case REACT_LEGACY_HIDDEN_TYPE: + return createFiberFromLegacyHidden(pendingProps, mode, lanes, key); + + case REACT_SCOPE_TYPE: + + // eslint-disable-next-line no-fallthrough + + default: + { + if (typeof type === 'object' && type !== null) { + switch (type.$$typeof) { + case REACT_PROVIDER_TYPE: + fiberTag = ContextProvider; + break getTag; + + case REACT_CONTEXT_TYPE: + // This is a consumer + fiberTag = ContextConsumer; + break getTag; + + case REACT_FORWARD_REF_TYPE: + fiberTag = ForwardRef; + + { + resolvedType = resolveForwardRefForHotReloading(resolvedType); + } + + break getTag; + + case REACT_MEMO_TYPE: + fiberTag = MemoComponent; + break getTag; + + case REACT_LAZY_TYPE: + fiberTag = LazyComponent; + resolvedType = null; + break getTag; + + case REACT_BLOCK_TYPE: + fiberTag = Block; + break getTag; + } + } + + var info = ''; + + { + if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { + info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and " + 'named imports.'; + } + + var ownerName = owner ? getComponentName(owner.type) : null; + + if (ownerName) { + info += '\n\nCheck the render method of `' + ownerName + '`.'; + } + } + + { + { + throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + (type == null ? type : typeof type) + "." + info ); + } + } + } + } + } + + var fiber = createFiber(fiberTag, pendingProps, key, mode); + fiber.elementType = type; + fiber.type = resolvedType; + fiber.lanes = lanes; + + { + fiber._debugOwner = owner; + } + + return fiber; + } + function createFiberFromElement(element, mode, lanes) { + var owner = null; + + { + owner = element._owner; + } + + var type = element.type; + var key = element.key; + var pendingProps = element.props; + var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, lanes); + + { + fiber._debugSource = element._source; + fiber._debugOwner = element._owner; + } + + return fiber; + } + function createFiberFromFragment(elements, mode, lanes, key) { + var fiber = createFiber(Fragment, elements, key, mode); + fiber.lanes = lanes; + return fiber; + } + + function createFiberFromProfiler(pendingProps, mode, lanes, key) { + { + if (typeof pendingProps.id !== 'string') { + error('Profiler must specify an "id" as a prop'); + } + } + + var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode); // TODO: The Profiler fiber shouldn't have a type. It has a tag. + + fiber.elementType = REACT_PROFILER_TYPE; + fiber.type = REACT_PROFILER_TYPE; + fiber.lanes = lanes; + + { + fiber.stateNode = { + effectDuration: 0, + passiveEffectDuration: 0 + }; + } + + return fiber; + } + + function createFiberFromSuspense(pendingProps, mode, lanes, key) { + var fiber = createFiber(SuspenseComponent, pendingProps, key, mode); // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag. + // This needs to be fixed in getComponentName so that it relies on the tag + // instead. + + fiber.type = REACT_SUSPENSE_TYPE; + fiber.elementType = REACT_SUSPENSE_TYPE; + fiber.lanes = lanes; + return fiber; + } + function createFiberFromSuspenseList(pendingProps, mode, lanes, key) { + var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode); + + { + // TODO: The SuspenseListComponent fiber shouldn't have a type. It has a tag. + // This needs to be fixed in getComponentName so that it relies on the tag + // instead. + fiber.type = REACT_SUSPENSE_LIST_TYPE; + } + + fiber.elementType = REACT_SUSPENSE_LIST_TYPE; + fiber.lanes = lanes; + return fiber; + } + function createFiberFromOffscreen(pendingProps, mode, lanes, key) { + var fiber = createFiber(OffscreenComponent, pendingProps, key, mode); // TODO: The OffscreenComponent fiber shouldn't have a type. It has a tag. + // This needs to be fixed in getComponentName so that it relies on the tag + // instead. + + { + fiber.type = REACT_OFFSCREEN_TYPE; + } + + fiber.elementType = REACT_OFFSCREEN_TYPE; + fiber.lanes = lanes; + return fiber; + } + function createFiberFromLegacyHidden(pendingProps, mode, lanes, key) { + var fiber = createFiber(LegacyHiddenComponent, pendingProps, key, mode); // TODO: The LegacyHidden fiber shouldn't have a type. It has a tag. + // This needs to be fixed in getComponentName so that it relies on the tag + // instead. + + { + fiber.type = REACT_LEGACY_HIDDEN_TYPE; + } + + fiber.elementType = REACT_LEGACY_HIDDEN_TYPE; + fiber.lanes = lanes; + return fiber; + } + function createFiberFromText(content, mode, lanes) { + var fiber = createFiber(HostText, content, null, mode); + fiber.lanes = lanes; + return fiber; + } + function createFiberFromHostInstanceForDeletion() { + var fiber = createFiber(HostComponent, null, null, NoMode); // TODO: These should not need a type. + + fiber.elementType = 'DELETED'; + fiber.type = 'DELETED'; + return fiber; + } + function createFiberFromPortal(portal, mode, lanes) { + var pendingProps = portal.children !== null ? portal.children : []; + var fiber = createFiber(HostPortal, pendingProps, portal.key, mode); + fiber.lanes = lanes; + fiber.stateNode = { + containerInfo: portal.containerInfo, + pendingChildren: null, + // Used by persistent updates + implementation: portal.implementation + }; + return fiber; + } // Used for stashing WIP properties to replay failed work in DEV. + + function assignFiberPropertiesInDEV(target, source) { + if (target === null) { + // This Fiber's initial properties will always be overwritten. + // We only use a Fiber to ensure the same hidden class so DEV isn't slow. + target = createFiber(IndeterminateComponent, null, null, NoMode); + } // This is intentionally written as a list of all properties. + // We tried to use Object.assign() instead but this is called in + // the hottest path, and Object.assign() was too slow: + // https://github.com/facebook/react/issues/12502 + // This code is DEV-only so size is not a concern. + + + target.tag = source.tag; + target.key = source.key; + target.elementType = source.elementType; + target.type = source.type; + target.stateNode = source.stateNode; + target.return = source.return; + target.child = source.child; + target.sibling = source.sibling; + target.index = source.index; + target.ref = source.ref; + target.pendingProps = source.pendingProps; + target.memoizedProps = source.memoizedProps; + target.updateQueue = source.updateQueue; + target.memoizedState = source.memoizedState; + target.dependencies = source.dependencies; + target.mode = source.mode; + target.flags = source.flags; + target.nextEffect = source.nextEffect; + target.firstEffect = source.firstEffect; + target.lastEffect = source.lastEffect; + target.lanes = source.lanes; + target.childLanes = source.childLanes; + target.alternate = source.alternate; + + { + target.actualDuration = source.actualDuration; + target.actualStartTime = source.actualStartTime; + target.selfBaseDuration = source.selfBaseDuration; + target.treeBaseDuration = source.treeBaseDuration; + } + + target._debugID = source._debugID; + target._debugSource = source._debugSource; + target._debugOwner = source._debugOwner; + target._debugNeedsRemount = source._debugNeedsRemount; + target._debugHookTypes = source._debugHookTypes; + return target; + } + + function FiberRootNode(containerInfo, tag, hydrate) { + this.tag = tag; + this.containerInfo = containerInfo; + this.pendingChildren = null; + this.current = null; + this.pingCache = null; + this.finishedWork = null; + this.timeoutHandle = noTimeout; + this.context = null; + this.pendingContext = null; + this.hydrate = hydrate; + this.callbackNode = null; + this.callbackPriority = NoLanePriority; + this.eventTimes = createLaneMap(NoLanes); + this.expirationTimes = createLaneMap(NoTimestamp); + this.pendingLanes = NoLanes; + this.suspendedLanes = NoLanes; + this.pingedLanes = NoLanes; + this.expiredLanes = NoLanes; + this.mutableReadLanes = NoLanes; + this.finishedLanes = NoLanes; + this.entangledLanes = NoLanes; + this.entanglements = createLaneMap(NoLanes); + + { + this.mutableSourceEagerHydrationData = null; + } + + { + this.interactionThreadID = unstable_getThreadID(); + this.memoizedInteractions = new Set(); + this.pendingInteractionMap = new Map(); + } + + { + switch (tag) { + case BlockingRoot: + this._debugRootType = 'createBlockingRoot()'; + break; + + case ConcurrentRoot: + this._debugRootType = 'createRoot()'; + break; + + case LegacyRoot: + this._debugRootType = 'createLegacyRoot()'; + break; + } + } + } + + function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) { + var root = new FiberRootNode(containerInfo, tag, hydrate); + // stateNode is any. + + + var uninitializedFiber = createHostRootFiber(tag); + root.current = uninitializedFiber; + uninitializedFiber.stateNode = root; + initializeUpdateQueue(uninitializedFiber); + return root; + } + + // This ensures that the version used for server rendering matches the one + // that is eventually read during hydration. + // If they don't match there's a potential tear and a full deopt render is required. + + function registerMutableSourceForHydration(root, mutableSource) { + var getVersion = mutableSource._getVersion; + var version = getVersion(mutableSource._source); // TODO Clear this data once all pending hydration work is finished. + // Retaining it forever may interfere with GC. + + if (root.mutableSourceEagerHydrationData == null) { + root.mutableSourceEagerHydrationData = [mutableSource, version]; + } else { + root.mutableSourceEagerHydrationData.push(mutableSource, version); + } + } + + function createPortal(children, containerInfo, // TODO: figure out the API for cross-renderer implementation. + implementation) { + var key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; + return { + // This tag allow us to uniquely identify this as a React Portal + $$typeof: REACT_PORTAL_TYPE, + key: key == null ? null : '' + key, + children: children, + containerInfo: containerInfo, + implementation: implementation + }; + } + + var didWarnAboutNestedUpdates; + var didWarnAboutFindNodeInStrictMode; + + { + didWarnAboutNestedUpdates = false; + didWarnAboutFindNodeInStrictMode = {}; + } + + function getContextForSubtree(parentComponent) { + if (!parentComponent) { + return emptyContextObject; + } + + var fiber = get(parentComponent); + var parentContext = findCurrentUnmaskedContext(fiber); + + if (fiber.tag === ClassComponent) { + var Component = fiber.type; + + if (isContextProvider(Component)) { + return processChildContext(fiber, Component, parentContext); + } + } + + return parentContext; + } + + function findHostInstanceWithWarning(component, methodName) { + { + var fiber = get(component); + + if (fiber === undefined) { + if (typeof component.render === 'function') { + { + { + throw Error( "Unable to find node on an unmounted component." ); + } + } + } else { + { + { + throw Error( "Argument appears to not be a ReactComponent. Keys: " + Object.keys(component) ); + } + } + } + } + + var hostFiber = findCurrentHostFiber(fiber); + + if (hostFiber === null) { + return null; + } + + if (hostFiber.mode & StrictMode) { + var componentName = getComponentName(fiber.type) || 'Component'; + + if (!didWarnAboutFindNodeInStrictMode[componentName]) { + didWarnAboutFindNodeInStrictMode[componentName] = true; + var previousFiber = current; + + try { + setCurrentFiber(hostFiber); + + if (fiber.mode & StrictMode) { + error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which is inside StrictMode. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-find-node', methodName, methodName, componentName); + } else { + error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which renders StrictMode children. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-find-node', methodName, methodName, componentName); + } + } finally { + // Ideally this should reset to previous but this shouldn't be called in + // render and there's another warning for that anyway. + if (previousFiber) { + setCurrentFiber(previousFiber); + } else { + resetCurrentFiber(); + } + } + } + } + + return hostFiber.stateNode; + } + } + + function createContainer(containerInfo, tag, hydrate, hydrationCallbacks) { + return createFiberRoot(containerInfo, tag, hydrate); + } + function updateContainer(element, container, parentComponent, callback) { + { + onScheduleRoot(container, element); + } + + var current$1 = container.current; + var eventTime = requestEventTime(); + + { + // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests + if ('undefined' !== typeof jest) { + warnIfUnmockedScheduler(current$1); + warnIfNotScopedWithMatchingAct(current$1); + } + } + + var lane = requestUpdateLane(current$1); + + var context = getContextForSubtree(parentComponent); + + if (container.context === null) { + container.context = context; + } else { + container.pendingContext = context; + } + + { + if (isRendering && current !== null && !didWarnAboutNestedUpdates) { + didWarnAboutNestedUpdates = true; + + error('Render methods should be a pure function of props and state; ' + 'triggering nested component updates from render is not allowed. ' + 'If necessary, trigger nested updates in componentDidUpdate.\n\n' + 'Check the render method of %s.', getComponentName(current.type) || 'Unknown'); + } + } + + var update = createUpdate(eventTime, lane); // Caution: React DevTools currently depends on this property + // being called "element". + + update.payload = { + element: element + }; + callback = callback === undefined ? null : callback; + + if (callback !== null) { + { + if (typeof callback !== 'function') { + error('render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback); + } + } + + update.callback = callback; + } + + enqueueUpdate(current$1, update); + scheduleUpdateOnFiber(current$1, lane, eventTime); + return lane; + } + function getPublicRootInstance(container) { + var containerFiber = container.current; + + if (!containerFiber.child) { + return null; + } + + switch (containerFiber.child.tag) { + case HostComponent: + return getPublicInstance(containerFiber.child.stateNode); + + default: + return containerFiber.child.stateNode; + } + } + + function markRetryLaneImpl(fiber, retryLane) { + var suspenseState = fiber.memoizedState; + + if (suspenseState !== null && suspenseState.dehydrated !== null) { + suspenseState.retryLane = higherPriorityLane(suspenseState.retryLane, retryLane); + } + } // Increases the priority of thennables when they resolve within this boundary. + + + function markRetryLaneIfNotHydrated(fiber, retryLane) { + markRetryLaneImpl(fiber, retryLane); + var alternate = fiber.alternate; + + if (alternate) { + markRetryLaneImpl(alternate, retryLane); + } + } + + function attemptUserBlockingHydration$1(fiber) { + if (fiber.tag !== SuspenseComponent) { + // We ignore HostRoots here because we can't increase + // their priority and they should not suspend on I/O, + // since you have to wrap anything that might suspend in + // Suspense. + return; + } + + var eventTime = requestEventTime(); + var lane = InputDiscreteHydrationLane; + scheduleUpdateOnFiber(fiber, lane, eventTime); + markRetryLaneIfNotHydrated(fiber, lane); + } + function attemptContinuousHydration$1(fiber) { + if (fiber.tag !== SuspenseComponent) { + // We ignore HostRoots here because we can't increase + // their priority and they should not suspend on I/O, + // since you have to wrap anything that might suspend in + // Suspense. + return; + } + + var eventTime = requestEventTime(); + var lane = SelectiveHydrationLane; + scheduleUpdateOnFiber(fiber, lane, eventTime); + markRetryLaneIfNotHydrated(fiber, lane); + } + function attemptHydrationAtCurrentPriority$1(fiber) { + if (fiber.tag !== SuspenseComponent) { + // We ignore HostRoots here because we can't increase + // their priority other than synchronously flush it. + return; + } + + var eventTime = requestEventTime(); + var lane = requestUpdateLane(fiber); + scheduleUpdateOnFiber(fiber, lane, eventTime); + markRetryLaneIfNotHydrated(fiber, lane); + } + function runWithPriority$2(priority, fn) { + + try { + setCurrentUpdateLanePriority(priority); + return fn(); + } finally { + } + } + function findHostInstanceWithNoPortals(fiber) { + var hostFiber = findCurrentHostFiberWithNoPortals(fiber); + + if (hostFiber === null) { + return null; + } + + if (hostFiber.tag === FundamentalComponent) { + return hostFiber.stateNode.instance; + } + + return hostFiber.stateNode; + } + + var shouldSuspendImpl = function (fiber) { + return false; + }; + + function shouldSuspend(fiber) { + return shouldSuspendImpl(fiber); + } + var overrideHookState = null; + var overrideHookStateDeletePath = null; + var overrideHookStateRenamePath = null; + var overrideProps = null; + var overridePropsDeletePath = null; + var overridePropsRenamePath = null; + var scheduleUpdate = null; + var setSuspenseHandler = null; + + { + var copyWithDeleteImpl = function (obj, path, index) { + var key = path[index]; + var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj); + + if (index + 1 === path.length) { + if (Array.isArray(updated)) { + updated.splice(key, 1); + } else { + delete updated[key]; + } + + return updated; + } // $FlowFixMe number or string is fine here + + + updated[key] = copyWithDeleteImpl(obj[key], path, index + 1); + return updated; + }; + + var copyWithDelete = function (obj, path) { + return copyWithDeleteImpl(obj, path, 0); + }; + + var copyWithRenameImpl = function (obj, oldPath, newPath, index) { + var oldKey = oldPath[index]; + var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj); + + if (index + 1 === oldPath.length) { + var newKey = newPath[index]; // $FlowFixMe number or string is fine here + + updated[newKey] = updated[oldKey]; + + if (Array.isArray(updated)) { + updated.splice(oldKey, 1); + } else { + delete updated[oldKey]; + } + } else { + // $FlowFixMe number or string is fine here + updated[oldKey] = copyWithRenameImpl( // $FlowFixMe number or string is fine here + obj[oldKey], oldPath, newPath, index + 1); + } + + return updated; + }; + + var copyWithRename = function (obj, oldPath, newPath) { + if (oldPath.length !== newPath.length) { + warn('copyWithRename() expects paths of the same length'); + + return; + } else { + for (var i = 0; i < newPath.length - 1; i++) { + if (oldPath[i] !== newPath[i]) { + warn('copyWithRename() expects paths to be the same except for the deepest key'); + + return; + } + } + } + + return copyWithRenameImpl(obj, oldPath, newPath, 0); + }; + + var copyWithSetImpl = function (obj, path, index, value) { + if (index >= path.length) { + return value; + } + + var key = path[index]; + var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj); // $FlowFixMe number or string is fine here + + updated[key] = copyWithSetImpl(obj[key], path, index + 1, value); + return updated; + }; + + var copyWithSet = function (obj, path, value) { + return copyWithSetImpl(obj, path, 0, value); + }; + + var findHook = function (fiber, id) { + // For now, the "id" of stateful hooks is just the stateful hook index. + // This may change in the future with e.g. nested hooks. + var currentHook = fiber.memoizedState; + + while (currentHook !== null && id > 0) { + currentHook = currentHook.next; + id--; + } + + return currentHook; + }; // Support DevTools editable values for useState and useReducer. + + + overrideHookState = function (fiber, id, path, value) { + var hook = findHook(fiber, id); + + if (hook !== null) { + var newState = copyWithSet(hook.memoizedState, path, value); + hook.memoizedState = newState; + hook.baseState = newState; // We aren't actually adding an update to the queue, + // because there is no update we can add for useReducer hooks that won't trigger an error. + // (There's no appropriate action type for DevTools overrides.) + // As a result though, React will see the scheduled update as a noop and bailout. + // Shallow cloning props works as a workaround for now to bypass the bailout check. + + fiber.memoizedProps = _assign({}, fiber.memoizedProps); + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + } + }; + + overrideHookStateDeletePath = function (fiber, id, path) { + var hook = findHook(fiber, id); + + if (hook !== null) { + var newState = copyWithDelete(hook.memoizedState, path); + hook.memoizedState = newState; + hook.baseState = newState; // We aren't actually adding an update to the queue, + // because there is no update we can add for useReducer hooks that won't trigger an error. + // (There's no appropriate action type for DevTools overrides.) + // As a result though, React will see the scheduled update as a noop and bailout. + // Shallow cloning props works as a workaround for now to bypass the bailout check. + + fiber.memoizedProps = _assign({}, fiber.memoizedProps); + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + } + }; + + overrideHookStateRenamePath = function (fiber, id, oldPath, newPath) { + var hook = findHook(fiber, id); + + if (hook !== null) { + var newState = copyWithRename(hook.memoizedState, oldPath, newPath); + hook.memoizedState = newState; + hook.baseState = newState; // We aren't actually adding an update to the queue, + // because there is no update we can add for useReducer hooks that won't trigger an error. + // (There's no appropriate action type for DevTools overrides.) + // As a result though, React will see the scheduled update as a noop and bailout. + // Shallow cloning props works as a workaround for now to bypass the bailout check. + + fiber.memoizedProps = _assign({}, fiber.memoizedProps); + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + } + }; // Support DevTools props for function components, forwardRef, memo, host components, etc. + + + overrideProps = function (fiber, path, value) { + fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value); + + if (fiber.alternate) { + fiber.alternate.pendingProps = fiber.pendingProps; + } + + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + }; + + overridePropsDeletePath = function (fiber, path) { + fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path); + + if (fiber.alternate) { + fiber.alternate.pendingProps = fiber.pendingProps; + } + + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + }; + + overridePropsRenamePath = function (fiber, oldPath, newPath) { + fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath); + + if (fiber.alternate) { + fiber.alternate.pendingProps = fiber.pendingProps; + } + + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + }; + + scheduleUpdate = function (fiber) { + scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + }; + + setSuspenseHandler = function (newShouldSuspendImpl) { + shouldSuspendImpl = newShouldSuspendImpl; + }; + } + + function findHostInstanceByFiber(fiber) { + var hostFiber = findCurrentHostFiber(fiber); + + if (hostFiber === null) { + return null; + } + + return hostFiber.stateNode; + } + + function emptyFindFiberByHostInstance(instance) { + return null; + } + + function getCurrentFiberForDevTools() { + return current; + } + + function injectIntoDevTools(devToolsConfig) { + var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; + var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; + return injectInternals({ + bundleType: devToolsConfig.bundleType, + version: devToolsConfig.version, + rendererPackageName: devToolsConfig.rendererPackageName, + rendererConfig: devToolsConfig.rendererConfig, + overrideHookState: overrideHookState, + overrideHookStateDeletePath: overrideHookStateDeletePath, + overrideHookStateRenamePath: overrideHookStateRenamePath, + overrideProps: overrideProps, + overridePropsDeletePath: overridePropsDeletePath, + overridePropsRenamePath: overridePropsRenamePath, + setSuspenseHandler: setSuspenseHandler, + scheduleUpdate: scheduleUpdate, + currentDispatcherRef: ReactCurrentDispatcher, + findHostInstanceByFiber: findHostInstanceByFiber, + findFiberByHostInstance: findFiberByHostInstance || emptyFindFiberByHostInstance, + // React Refresh + findHostInstancesForRefresh: findHostInstancesForRefresh , + scheduleRefresh: scheduleRefresh , + scheduleRoot: scheduleRoot , + setRefreshHandler: setRefreshHandler , + // Enables DevTools to append owner stacks to error messages in DEV mode. + getCurrentFiber: getCurrentFiberForDevTools + }); + } + + function ReactDOMRoot(container, options) { + this._internalRoot = createRootImpl(container, ConcurrentRoot, options); + } + + function ReactDOMBlockingRoot(container, tag, options) { + this._internalRoot = createRootImpl(container, tag, options); + } + + ReactDOMRoot.prototype.render = ReactDOMBlockingRoot.prototype.render = function (children) { + var root = this._internalRoot; + + { + if (typeof arguments[1] === 'function') { + error('render(...): does not support the second callback argument. ' + 'To execute a side effect after rendering, declare it in a component body with useEffect().'); + } + + var container = root.containerInfo; + + if (container.nodeType !== COMMENT_NODE) { + var hostInstance = findHostInstanceWithNoPortals(root.current); + + if (hostInstance) { + if (hostInstance.parentNode !== container) { + error('render(...): It looks like the React-rendered content of the ' + 'root container was removed without using React. This is not ' + 'supported and will cause errors. Instead, call ' + "root.unmount() to empty a root's container."); + } + } + } + } + + updateContainer(children, root, null, null); + }; + + ReactDOMRoot.prototype.unmount = ReactDOMBlockingRoot.prototype.unmount = function () { + { + if (typeof arguments[0] === 'function') { + error('unmount(...): does not support a callback argument. ' + 'To execute a side effect after rendering, declare it in a component body with useEffect().'); + } + } + + var root = this._internalRoot; + var container = root.containerInfo; + updateContainer(null, root, null, function () { + unmarkContainerAsRoot(container); + }); + }; + + function createRootImpl(container, tag, options) { + // Tag is either LegacyRoot or Concurrent Root + var hydrate = options != null && options.hydrate === true; + var hydrationCallbacks = options != null && options.hydrationOptions || null; + var mutableSources = options != null && options.hydrationOptions != null && options.hydrationOptions.mutableSources || null; + var root = createContainer(container, tag, hydrate); + markContainerAsRoot(root.current, container); + var containerNodeType = container.nodeType; + + { + var rootContainerElement = container.nodeType === COMMENT_NODE ? container.parentNode : container; + listenToAllSupportedEvents(rootContainerElement); + } + + if (mutableSources) { + for (var i = 0; i < mutableSources.length; i++) { + var mutableSource = mutableSources[i]; + registerMutableSourceForHydration(root, mutableSource); + } + } + + return root; + } + function createLegacyRoot(container, options) { + return new ReactDOMBlockingRoot(container, LegacyRoot, options); + } + function isValidContainer(node) { + return !!(node && (node.nodeType === ELEMENT_NODE || node.nodeType === DOCUMENT_NODE || node.nodeType === DOCUMENT_FRAGMENT_NODE || node.nodeType === COMMENT_NODE && node.nodeValue === ' react-mount-point-unstable ')); + } + + var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; + var topLevelUpdateWarnings; + var warnedAboutHydrateAPI = false; + + { + topLevelUpdateWarnings = function (container) { + if (container._reactRootContainer && container.nodeType !== COMMENT_NODE) { + var hostInstance = findHostInstanceWithNoPortals(container._reactRootContainer._internalRoot.current); + + if (hostInstance) { + if (hostInstance.parentNode !== container) { + error('render(...): It looks like the React-rendered content of this ' + 'container was removed without using React. This is not ' + 'supported and will cause errors. Instead, call ' + 'ReactDOM.unmountComponentAtNode to empty a container.'); + } + } + } + + var isRootRenderedBySomeReact = !!container._reactRootContainer; + var rootEl = getReactRootElementInContainer(container); + var hasNonRootReactChild = !!(rootEl && getInstanceFromNode(rootEl)); + + if (hasNonRootReactChild && !isRootRenderedBySomeReact) { + error('render(...): Replacing React-rendered children with a new root ' + 'component. If you intended to update the children of this node, ' + 'you should instead have the existing children update their state ' + 'and render the new components instead of calling ReactDOM.render.'); + } + + if (container.nodeType === ELEMENT_NODE && container.tagName && container.tagName.toUpperCase() === 'BODY') { + error('render(): Rendering components directly into document.body is ' + 'discouraged, since its children are often manipulated by third-party ' + 'scripts and browser extensions. This may lead to subtle ' + 'reconciliation issues. Try rendering into a container element created ' + 'for your app.'); + } + }; + } + + function getReactRootElementInContainer(container) { + if (!container) { + return null; + } + + if (container.nodeType === DOCUMENT_NODE) { + return container.documentElement; + } else { + return container.firstChild; + } + } + + function shouldHydrateDueToLegacyHeuristic(container) { + var rootElement = getReactRootElementInContainer(container); + return !!(rootElement && rootElement.nodeType === ELEMENT_NODE && rootElement.hasAttribute(ROOT_ATTRIBUTE_NAME)); + } + + function legacyCreateRootFromDOMContainer(container, forceHydrate) { + var shouldHydrate = forceHydrate || shouldHydrateDueToLegacyHeuristic(container); // First clear any existing content. + + if (!shouldHydrate) { + var warned = false; + var rootSibling; + + while (rootSibling = container.lastChild) { + { + if (!warned && rootSibling.nodeType === ELEMENT_NODE && rootSibling.hasAttribute(ROOT_ATTRIBUTE_NAME)) { + warned = true; + + error('render(): Target node has markup rendered by React, but there ' + 'are unrelated nodes as well. This is most commonly caused by ' + 'white-space inserted around server-rendered markup.'); + } + } + + container.removeChild(rootSibling); + } + } + + { + if (shouldHydrate && !forceHydrate && !warnedAboutHydrateAPI) { + warnedAboutHydrateAPI = true; + + warn('render(): Calling ReactDOM.render() to hydrate server-rendered markup ' + 'will stop working in React v18. Replace the ReactDOM.render() call ' + 'with ReactDOM.hydrate() if you want React to attach to the server HTML.'); + } + } + + return createLegacyRoot(container, shouldHydrate ? { + hydrate: true + } : undefined); + } + + function warnOnInvalidCallback$1(callback, callerName) { + { + if (callback !== null && typeof callback !== 'function') { + error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback); + } + } + } + + function legacyRenderSubtreeIntoContainer(parentComponent, children, container, forceHydrate, callback) { + { + topLevelUpdateWarnings(container); + warnOnInvalidCallback$1(callback === undefined ? null : callback, 'render'); + } // TODO: Without `any` type, Flow says "Property cannot be accessed on any + // member of intersection type." Whyyyyyy. + + + var root = container._reactRootContainer; + var fiberRoot; + + if (!root) { + // Initial mount + root = container._reactRootContainer = legacyCreateRootFromDOMContainer(container, forceHydrate); + fiberRoot = root._internalRoot; + + if (typeof callback === 'function') { + var originalCallback = callback; + + callback = function () { + var instance = getPublicRootInstance(fiberRoot); + originalCallback.call(instance); + }; + } // Initial mount should not be batched. + + + unbatchedUpdates(function () { + updateContainer(children, fiberRoot, parentComponent, callback); + }); + } else { + fiberRoot = root._internalRoot; + + if (typeof callback === 'function') { + var _originalCallback = callback; + + callback = function () { + var instance = getPublicRootInstance(fiberRoot); + + _originalCallback.call(instance); + }; + } // Update + + + updateContainer(children, fiberRoot, parentComponent, callback); + } + + return getPublicRootInstance(fiberRoot); + } + + function findDOMNode(componentOrElement) { + { + var owner = ReactCurrentOwner$3.current; + + if (owner !== null && owner.stateNode !== null) { + var warnedAboutRefsInRender = owner.stateNode._warnedAboutRefsInRender; + + if (!warnedAboutRefsInRender) { + error('%s is accessing findDOMNode inside its render(). ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(owner.type) || 'A component'); + } + + owner.stateNode._warnedAboutRefsInRender = true; + } + } + + if (componentOrElement == null) { + return null; + } + + if (componentOrElement.nodeType === ELEMENT_NODE) { + return componentOrElement; + } + + { + return findHostInstanceWithWarning(componentOrElement, 'findDOMNode'); + } + } + function hydrate(element, container, callback) { + if (!isValidContainer(container)) { + { + throw Error( "Target container is not a DOM element." ); + } + } + + { + var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined; + + if (isModernRoot) { + error('You are calling ReactDOM.hydrate() on a container that was previously ' + 'passed to ReactDOM.createRoot(). This is not supported. ' + 'Did you mean to call createRoot(container, {hydrate: true}).render(element)?'); + } + } // TODO: throw or warn if we couldn't hydrate? + + + return legacyRenderSubtreeIntoContainer(null, element, container, true, callback); + } + function render(element, container, callback) { + if (!isValidContainer(container)) { + { + throw Error( "Target container is not a DOM element." ); + } + } + + { + var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined; + + if (isModernRoot) { + error('You are calling ReactDOM.render() on a container that was previously ' + 'passed to ReactDOM.createRoot(). This is not supported. ' + 'Did you mean to call root.render(element)?'); + } + } + + return legacyRenderSubtreeIntoContainer(null, element, container, false, callback); + } + function unstable_renderSubtreeIntoContainer(parentComponent, element, containerNode, callback) { + if (!isValidContainer(containerNode)) { + { + throw Error( "Target container is not a DOM element." ); + } + } + + if (!(parentComponent != null && has(parentComponent))) { + { + throw Error( "parentComponent must be a valid React Component" ); + } + } + + return legacyRenderSubtreeIntoContainer(parentComponent, element, containerNode, false, callback); + } + function unmountComponentAtNode(container) { + if (!isValidContainer(container)) { + { + throw Error( "unmountComponentAtNode(...): Target container is not a DOM element." ); + } + } + + { + var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined; + + if (isModernRoot) { + error('You are calling ReactDOM.unmountComponentAtNode() on a container that was previously ' + 'passed to ReactDOM.createRoot(). This is not supported. Did you mean to call root.unmount()?'); + } + } + + if (container._reactRootContainer) { + { + var rootEl = getReactRootElementInContainer(container); + var renderedByDifferentReact = rootEl && !getInstanceFromNode(rootEl); + + if (renderedByDifferentReact) { + error("unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by another copy of React.'); + } + } // Unmount should not be batched. + + + unbatchedUpdates(function () { + legacyRenderSubtreeIntoContainer(null, null, container, false, function () { + // $FlowFixMe This should probably use `delete container._reactRootContainer` + container._reactRootContainer = null; + unmarkContainerAsRoot(container); + }); + }); // If you call unmountComponentAtNode twice in quick succession, you'll + // get `true` twice. That's probably fine? + + return true; + } else { + { + var _rootEl = getReactRootElementInContainer(container); + + var hasNonRootReactChild = !!(_rootEl && getInstanceFromNode(_rootEl)); // Check if the container itself is a React root node. + + var isContainerReactRoot = container.nodeType === ELEMENT_NODE && isValidContainer(container.parentNode) && !!container.parentNode._reactRootContainer; + + if (hasNonRootReactChild) { + error("unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by React and is not a top-level container. %s', isContainerReactRoot ? 'You may have accidentally passed in a React root node instead ' + 'of its container.' : 'Instead, have the parent component update its state and ' + 'rerender in order to remove this component.'); + } + } + + return false; + } + } + + setAttemptUserBlockingHydration(attemptUserBlockingHydration$1); + setAttemptContinuousHydration(attemptContinuousHydration$1); + setAttemptHydrationAtCurrentPriority(attemptHydrationAtCurrentPriority$1); + setAttemptHydrationAtPriority(runWithPriority$2); + var didWarnAboutUnstableCreatePortal = false; + + { + if (typeof Map !== 'function' || // $FlowIssue Flow incorrectly thinks Map has no prototype + Map.prototype == null || typeof Map.prototype.forEach !== 'function' || typeof Set !== 'function' || // $FlowIssue Flow incorrectly thinks Set has no prototype + Set.prototype == null || typeof Set.prototype.clear !== 'function' || typeof Set.prototype.forEach !== 'function') { + error('React depends on Map and Set built-in types. Make sure that you load a ' + 'polyfill in older browsers. https://reactjs.org/link/react-polyfills'); + } + } + + setRestoreImplementation(restoreControlledState$3); + setBatchingImplementation(batchedUpdates$1, discreteUpdates$1, flushDiscreteUpdates, batchedEventUpdates$1); + + function createPortal$1(children, container) { + var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; + + if (!isValidContainer(container)) { + { + throw Error( "Target container is not a DOM element." ); + } + } // TODO: pass ReactDOM portal implementation as third argument + // $FlowFixMe The Flow type is opaque but there's no way to actually create it. + + + return createPortal(children, container, null, key); + } + + function renderSubtreeIntoContainer(parentComponent, element, containerNode, callback) { + + return unstable_renderSubtreeIntoContainer(parentComponent, element, containerNode, callback); + } + + function unstable_createPortal(children, container) { + var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; + + { + if (!didWarnAboutUnstableCreatePortal) { + didWarnAboutUnstableCreatePortal = true; + + warn('The ReactDOM.unstable_createPortal() alias has been deprecated, ' + 'and will be removed in React 18+. Update your code to use ' + 'ReactDOM.createPortal() instead. It has the exact same API, ' + 'but without the "unstable_" prefix.'); + } + } + + return createPortal$1(children, container, key); + } + + var Internals = { + // Keep in sync with ReactTestUtils.js, and ReactTestUtilsAct.js. + // This is an array for better minification. + Events: [getInstanceFromNode, getNodeFromInstance, getFiberCurrentPropsFromNode, enqueueStateRestore, restoreStateIfNeeded, flushPassiveEffects, // TODO: This is related to `act`, not events. Move to separate key? + IsThisRendererActing] + }; + var foundDevTools = injectIntoDevTools({ + findFiberByHostInstance: getClosestInstanceFromNode, + bundleType: 1 , + version: ReactVersion, + rendererPackageName: 'react-dom' + }); + + { + if (!foundDevTools && canUseDOM && window.top === window.self) { + // If we're in Chrome or Firefox, provide a download link if not installed. + if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) { + var protocol = window.location.protocol; // Don't warn in exotic cases like chrome-extension://. + + if (/^(https?|file):$/.test(protocol)) { + // eslint-disable-next-line react-internal/no-production-logging + console.info('%cDownload the React DevTools ' + 'for a better development experience: ' + 'https://reactjs.org/link/react-devtools' + (protocol === 'file:' ? '\nYou might need to use a local HTTP server (instead of file://): ' + 'https://reactjs.org/link/react-devtools-faq' : ''), 'font-weight:bold'); + } + } + } + } + + exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals; + exports.createPortal = createPortal$1; + exports.findDOMNode = findDOMNode; + exports.flushSync = flushSync; + exports.hydrate = hydrate; + exports.render = render; + exports.unmountComponentAtNode = unmountComponentAtNode; + exports.unstable_batchedUpdates = batchedUpdates$1; + exports.unstable_createPortal = unstable_createPortal; + exports.unstable_renderSubtreeIntoContainer = renderSubtreeIntoContainer; + exports.version = ReactVersion; + +}))); diff --git a/examples/lib/react.development.js b/examples/lib/react.development.js new file mode 100644 index 00000000..1124191b --- /dev/null +++ b/examples/lib/react.development.js @@ -0,0 +1,3357 @@ +/** @license React v17.0.2 + * react.development.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = global || self, factory(global.React = {})); +}(this, (function (exports) { 'use strict'; + + // TODO: this is special because it gets imported during build. + var ReactVersion = '17.0.2'; + + // ATTENTION + // When adding new symbols to this file, + // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' + // The Symbol used to tag the ReactElement-like types. If there is no native Symbol + // nor polyfill, then a plain number is used for performance. + var REACT_ELEMENT_TYPE = 0xeac7; + var REACT_PORTAL_TYPE = 0xeaca; + exports.Fragment = 0xeacb; + exports.StrictMode = 0xeacc; + exports.Profiler = 0xead2; + var REACT_PROVIDER_TYPE = 0xeacd; + var REACT_CONTEXT_TYPE = 0xeace; + var REACT_FORWARD_REF_TYPE = 0xead0; + exports.Suspense = 0xead1; + var REACT_SUSPENSE_LIST_TYPE = 0xead8; + var REACT_MEMO_TYPE = 0xead3; + var REACT_LAZY_TYPE = 0xead4; + var REACT_BLOCK_TYPE = 0xead9; + var REACT_SERVER_BLOCK_TYPE = 0xeada; + var REACT_FUNDAMENTAL_TYPE = 0xead5; + var REACT_SCOPE_TYPE = 0xead7; + var REACT_OPAQUE_ID_TYPE = 0xeae0; + var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1; + var REACT_OFFSCREEN_TYPE = 0xeae2; + var REACT_LEGACY_HIDDEN_TYPE = 0xeae3; + + if (typeof Symbol === 'function' && Symbol.for) { + var symbolFor = Symbol.for; + REACT_ELEMENT_TYPE = symbolFor('react.element'); + REACT_PORTAL_TYPE = symbolFor('react.portal'); + exports.Fragment = symbolFor('react.fragment'); + exports.StrictMode = symbolFor('react.strict_mode'); + exports.Profiler = symbolFor('react.profiler'); + REACT_PROVIDER_TYPE = symbolFor('react.provider'); + REACT_CONTEXT_TYPE = symbolFor('react.context'); + REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref'); + exports.Suspense = symbolFor('react.suspense'); + REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list'); + REACT_MEMO_TYPE = symbolFor('react.memo'); + REACT_LAZY_TYPE = symbolFor('react.lazy'); + REACT_BLOCK_TYPE = symbolFor('react.block'); + REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block'); + REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental'); + REACT_SCOPE_TYPE = symbolFor('react.scope'); + REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id'); + REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode'); + REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen'); + REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden'); + } + + var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; + var FAUX_ITERATOR_SYMBOL = '@@iterator'; + function getIteratorFn(maybeIterable) { + if (maybeIterable === null || typeof maybeIterable !== 'object') { + return null; + } + + var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; + + if (typeof maybeIterator === 'function') { + return maybeIterator; + } + + return null; + } + + var hasOwnProperty = Object.prototype.hasOwnProperty; + + var _assign = function (to, from) { + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + }; + + var assign = Object.assign || function (target, sources) { + if (target == null) { + throw new TypeError('Object.assign target cannot be null or undefined'); + } + + var to = Object(target); + + for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) { + var nextSource = arguments[nextIndex]; + + if (nextSource != null) { + _assign(to, Object(nextSource)); + } + } + + return to; + }; + + /** + * Keeps track of the current dispatcher. + */ + var ReactCurrentDispatcher = { + /** + * @internal + * @type {ReactComponent} + */ + current: null + }; + + /** + * Keeps track of the current batch's configuration such as how long an update + * should suspend for if it needs to. + */ + var ReactCurrentBatchConfig = { + transition: 0 + }; + + /** + * Keeps track of the current owner. + * + * The current owner is the component who should own any components that are + * currently being constructed. + */ + var ReactCurrentOwner = { + /** + * @internal + * @type {ReactComponent} + */ + current: null + }; + + var ReactDebugCurrentFrame = {}; + var currentExtraStackFrame = null; + function setExtraStackFrame(stack) { + { + currentExtraStackFrame = stack; + } + } + + { + ReactDebugCurrentFrame.setExtraStackFrame = function (stack) { + { + currentExtraStackFrame = stack; + } + }; // Stack implementation injected by the current renderer. + + + ReactDebugCurrentFrame.getCurrentStack = null; + + ReactDebugCurrentFrame.getStackAddendum = function () { + var stack = ''; // Add an extra top frame while an element is being validated + + if (currentExtraStackFrame) { + stack += currentExtraStackFrame; + } // Delegate to the injected renderer-specific implementation + + + var impl = ReactDebugCurrentFrame.getCurrentStack; + + if (impl) { + stack += impl() || ''; + } + + return stack; + }; + } + + /** + * Used by act() to track whether you're inside an act() scope. + */ + var IsSomeRendererActing = { + current: false + }; + + var ReactSharedInternals = { + ReactCurrentDispatcher: ReactCurrentDispatcher, + ReactCurrentBatchConfig: ReactCurrentBatchConfig, + ReactCurrentOwner: ReactCurrentOwner, + IsSomeRendererActing: IsSomeRendererActing, + // Used by renderers to avoid bundling object-assign twice in UMD bundles: + assign: assign + }; + + { + ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame; + } + + // by calls to these methods by a Babel plugin. + // + // In PROD (or in packages without access to React internals), + // they are left as they are instead. + + function warn(format) { + { + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + printWarning('warn', format, args); + } + } + function error(format) { + { + for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + args[_key2 - 1] = arguments[_key2]; + } + + printWarning('error', format, args); + } + } + + function printWarning(level, format, args) { + // When changing this logic, you might want to also + // update consoleWithStackDev.www.js as well. + { + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); + + if (stack !== '') { + format += '%s'; + args = args.concat([stack]); + } + + var argsWithFormat = args.map(function (item) { + return '' + item; + }); // Careful: RN currently depends on this prefix + + argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it + // breaks IE9: https://github.com/facebook/react/issues/13610 + // eslint-disable-next-line react-internal/no-production-logging + + Function.prototype.apply.call(console[level], console, argsWithFormat); + } + } + + var didWarnStateUpdateForUnmountedComponent = {}; + + function warnNoop(publicInstance, callerName) { + { + var _constructor = publicInstance.constructor; + var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass'; + var warningKey = componentName + "." + callerName; + + if (didWarnStateUpdateForUnmountedComponent[warningKey]) { + return; + } + + error("Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName); + + didWarnStateUpdateForUnmountedComponent[warningKey] = true; + } + } + /** + * This is the abstract API for an update queue. + */ + + + var ReactNoopUpdateQueue = { + /** + * Checks whether or not this composite component is mounted. + * @param {ReactClass} publicInstance The instance we want to test. + * @return {boolean} True if mounted, false otherwise. + * @protected + * @final + */ + isMounted: function (publicInstance) { + return false; + }, + + /** + * Forces an update. This should only be invoked when it is known with + * certainty that we are **not** in a DOM transaction. + * + * You may want to call this when you know that some deeper aspect of the + * component's state has changed but `setState` was not called. + * + * This will not invoke `shouldComponentUpdate`, but it will invoke + * `componentWillUpdate` and `componentDidUpdate`. + * + * @param {ReactClass} publicInstance The instance that should rerender. + * @param {?function} callback Called after component is updated. + * @param {?string} callerName name of the calling function in the public API. + * @internal + */ + enqueueForceUpdate: function (publicInstance, callback, callerName) { + warnNoop(publicInstance, 'forceUpdate'); + }, + + /** + * Replaces all of the state. Always use this or `setState` to mutate state. + * You should treat `this.state` as immutable. + * + * There is no guarantee that `this.state` will be immediately updated, so + * accessing `this.state` after calling this method may return the old value. + * + * @param {ReactClass} publicInstance The instance that should rerender. + * @param {object} completeState Next state. + * @param {?function} callback Called after component is updated. + * @param {?string} callerName name of the calling function in the public API. + * @internal + */ + enqueueReplaceState: function (publicInstance, completeState, callback, callerName) { + warnNoop(publicInstance, 'replaceState'); + }, + + /** + * Sets a subset of the state. This only exists because _pendingState is + * internal. This provides a merging strategy that is not available to deep + * properties which is confusing. TODO: Expose pendingState or don't use it + * during the merge. + * + * @param {ReactClass} publicInstance The instance that should rerender. + * @param {object} partialState Next partial state to be merged with state. + * @param {?function} callback Called after component is updated. + * @param {?string} Name of the calling function in the public API. + * @internal + */ + enqueueSetState: function (publicInstance, partialState, callback, callerName) { + warnNoop(publicInstance, 'setState'); + } + }; + + var emptyObject = {}; + + { + Object.freeze(emptyObject); + } + /** + * Base class helpers for the updating state of a component. + */ + + + function Component(props, context, updater) { + this.props = props; + this.context = context; // If a component has string refs, we will assign a different object later. + + this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the + // renderer. + + this.updater = updater || ReactNoopUpdateQueue; + } + + Component.prototype.isReactComponent = {}; + /** + * Sets a subset of the state. Always use this to mutate + * state. You should treat `this.state` as immutable. + * + * There is no guarantee that `this.state` will be immediately updated, so + * accessing `this.state` after calling this method may return the old value. + * + * There is no guarantee that calls to `setState` will run synchronously, + * as they may eventually be batched together. You can provide an optional + * callback that will be executed when the call to setState is actually + * completed. + * + * When a function is provided to setState, it will be called at some point in + * the future (not synchronously). It will be called with the up to date + * component arguments (state, props, context). These values can be different + * from this.* because your function may be called after receiveProps but before + * shouldComponentUpdate, and this new state, props, and context will not yet be + * assigned to this. + * + * @param {object|function} partialState Next partial state or function to + * produce next partial state to be merged with current state. + * @param {?function} callback Called after state is updated. + * @final + * @protected + */ + + Component.prototype.setState = function (partialState, callback) { + if (!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null)) { + { + throw Error( "setState(...): takes an object of state variables to update or a function which returns an object of state variables." ); + } + } + + this.updater.enqueueSetState(this, partialState, callback, 'setState'); + }; + /** + * Forces an update. This should only be invoked when it is known with + * certainty that we are **not** in a DOM transaction. + * + * You may want to call this when you know that some deeper aspect of the + * component's state has changed but `setState` was not called. + * + * This will not invoke `shouldComponentUpdate`, but it will invoke + * `componentWillUpdate` and `componentDidUpdate`. + * + * @param {?function} callback Called after update is complete. + * @final + * @protected + */ + + + Component.prototype.forceUpdate = function (callback) { + this.updater.enqueueForceUpdate(this, callback, 'forceUpdate'); + }; + /** + * Deprecated APIs. These APIs used to exist on classic React classes but since + * we would like to deprecate them, we're not going to move them over to this + * modern base class. Instead, we define a getter that warns if it's accessed. + */ + + + { + var deprecatedAPIs = { + isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'], + replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).'] + }; + + var defineDeprecationWarning = function (methodName, info) { + Object.defineProperty(Component.prototype, methodName, { + get: function () { + warn('%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]); + + return undefined; + } + }); + }; + + for (var fnName in deprecatedAPIs) { + if (deprecatedAPIs.hasOwnProperty(fnName)) { + defineDeprecationWarning(fnName, deprecatedAPIs[fnName]); + } + } + } + + function ComponentDummy() {} + + ComponentDummy.prototype = Component.prototype; + /** + * Convenience component with default shallow equality check for sCU. + */ + + function PureComponent(props, context, updater) { + this.props = props; + this.context = context; // If a component has string refs, we will assign a different object later. + + this.refs = emptyObject; + this.updater = updater || ReactNoopUpdateQueue; + } + + var pureComponentPrototype = PureComponent.prototype = new ComponentDummy(); + pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods. + + assign(pureComponentPrototype, Component.prototype); + + pureComponentPrototype.isPureReactComponent = true; + + // an immutable object with a single mutable value + function createRef() { + var refObject = { + current: null + }; + + { + Object.seal(refObject); + } + + return refObject; + } + + function getWrappedName(outerType, innerType, wrapperName) { + var functionName = innerType.displayName || innerType.name || ''; + return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName); + } + + function getContextName(type) { + return type.displayName || 'Context'; + } + + function getComponentName(type) { + if (type == null) { + // Host root, text node or just invalid type. + return null; + } + + { + if (typeof type.tag === 'number') { + error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.'); + } + } + + if (typeof type === 'function') { + return type.displayName || type.name || null; + } + + if (typeof type === 'string') { + return type; + } + + switch (type) { + case exports.Fragment: + return 'Fragment'; + + case REACT_PORTAL_TYPE: + return 'Portal'; + + case exports.Profiler: + return 'Profiler'; + + case exports.StrictMode: + return 'StrictMode'; + + case exports.Suspense: + return 'Suspense'; + + case REACT_SUSPENSE_LIST_TYPE: + return 'SuspenseList'; + } + + if (typeof type === 'object') { + switch (type.$$typeof) { + case REACT_CONTEXT_TYPE: + var context = type; + return getContextName(context) + '.Consumer'; + + case REACT_PROVIDER_TYPE: + var provider = type; + return getContextName(provider._context) + '.Provider'; + + case REACT_FORWARD_REF_TYPE: + return getWrappedName(type, type.render, 'ForwardRef'); + + case REACT_MEMO_TYPE: + return getComponentName(type.type); + + case REACT_BLOCK_TYPE: + return getComponentName(type._render); + + case REACT_LAZY_TYPE: + { + var lazyComponent = type; + var payload = lazyComponent._payload; + var init = lazyComponent._init; + + try { + return getComponentName(init(payload)); + } catch (x) { + return null; + } + } + } + } + + return null; + } + + var hasOwnProperty$1 = Object.prototype.hasOwnProperty; + var RESERVED_PROPS = { + key: true, + ref: true, + __self: true, + __source: true + }; + var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs; + + { + didWarnAboutStringRefs = {}; + } + + function hasValidRef(config) { + { + if (hasOwnProperty$1.call(config, 'ref')) { + var getter = Object.getOwnPropertyDescriptor(config, 'ref').get; + + if (getter && getter.isReactWarning) { + return false; + } + } + } + + return config.ref !== undefined; + } + + function hasValidKey(config) { + { + if (hasOwnProperty$1.call(config, 'key')) { + var getter = Object.getOwnPropertyDescriptor(config, 'key').get; + + if (getter && getter.isReactWarning) { + return false; + } + } + } + + return config.key !== undefined; + } + + function defineKeyPropWarningGetter(props, displayName) { + var warnAboutAccessingKey = function () { + { + if (!specialPropKeyWarningShown) { + specialPropKeyWarningShown = true; + + error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName); + } + } + }; + + warnAboutAccessingKey.isReactWarning = true; + Object.defineProperty(props, 'key', { + get: warnAboutAccessingKey, + configurable: true + }); + } + + function defineRefPropWarningGetter(props, displayName) { + var warnAboutAccessingRef = function () { + { + if (!specialPropRefWarningShown) { + specialPropRefWarningShown = true; + + error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName); + } + } + }; + + warnAboutAccessingRef.isReactWarning = true; + Object.defineProperty(props, 'ref', { + get: warnAboutAccessingRef, + configurable: true + }); + } + + function warnIfStringRefCannotBeAutoConverted(config) { + { + if (typeof config.ref === 'string' && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) { + var componentName = getComponentName(ReactCurrentOwner.current.type); + + if (!didWarnAboutStringRefs[componentName]) { + error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', componentName, config.ref); + + didWarnAboutStringRefs[componentName] = true; + } + } + } + } + /** + * Factory method to create a new React element. This no longer adheres to + * the class pattern, so do not use new to call it. Also, instanceof check + * will not work. Instead test $$typeof field against Symbol.for('react.element') to check + * if something is a React Element. + * + * @param {*} type + * @param {*} props + * @param {*} key + * @param {string|object} ref + * @param {*} owner + * @param {*} self A *temporary* helper to detect places where `this` is + * different from the `owner` when React.createElement is called, so that we + * can warn. We want to get rid of owner and replace string `ref`s with arrow + * functions, and as long as `this` and owner are the same, there will be no + * change in behavior. + * @param {*} source An annotation object (added by a transpiler or otherwise) + * indicating filename, line number, and/or other information. + * @internal + */ + + + var ReactElement = function (type, key, ref, self, source, owner, props) { + var element = { + // This tag allows us to uniquely identify this as a React Element + $$typeof: REACT_ELEMENT_TYPE, + // Built-in properties that belong on the element + type: type, + key: key, + ref: ref, + props: props, + // Record the component responsible for creating this element. + _owner: owner + }; + + { + // The validation flag is currently mutative. We put it on + // an external backing store so that we can freeze the whole object. + // This can be replaced with a WeakMap once they are implemented in + // commonly used development environments. + element._store = {}; // To make comparing ReactElements easier for testing purposes, we make + // the validation flag non-enumerable (where possible, which should + // include every environment we run tests in), so the test framework + // ignores it. + + Object.defineProperty(element._store, 'validated', { + configurable: false, + enumerable: false, + writable: true, + value: false + }); // self and source are DEV only properties. + + Object.defineProperty(element, '_self', { + configurable: false, + enumerable: false, + writable: false, + value: self + }); // Two elements created in two different places should be considered + // equal for testing purposes and therefore we hide it from enumeration. + + Object.defineProperty(element, '_source', { + configurable: false, + enumerable: false, + writable: false, + value: source + }); + + if (Object.freeze) { + Object.freeze(element.props); + Object.freeze(element); + } + } + + return element; + }; + /** + * Create and return a new ReactElement of the given type. + * See https://reactjs.org/docs/react-api.html#createelement + */ + + function createElement(type, config, children) { + var propName; // Reserved names are extracted + + var props = {}; + var key = null; + var ref = null; + var self = null; + var source = null; + + if (config != null) { + if (hasValidRef(config)) { + ref = config.ref; + + { + warnIfStringRefCannotBeAutoConverted(config); + } + } + + if (hasValidKey(config)) { + key = '' + config.key; + } + + self = config.__self === undefined ? null : config.__self; + source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object + + for (propName in config) { + if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { + props[propName] = config[propName]; + } + } + } // Children can be more than one argument, and those are transferred onto + // the newly allocated props object. + + + var childrenLength = arguments.length - 2; + + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = Array(childrenLength); + + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 2]; + } + + { + if (Object.freeze) { + Object.freeze(childArray); + } + } + + props.children = childArray; + } // Resolve default props + + + if (type && type.defaultProps) { + var defaultProps = type.defaultProps; + + for (propName in defaultProps) { + if (props[propName] === undefined) { + props[propName] = defaultProps[propName]; + } + } + } + + { + if (key || ref) { + var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type; + + if (key) { + defineKeyPropWarningGetter(props, displayName); + } + + if (ref) { + defineRefPropWarningGetter(props, displayName); + } + } + } + + return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); + } + function cloneAndReplaceKey(oldElement, newKey) { + var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props); + return newElement; + } + /** + * Clone and return a new ReactElement using element as the starting point. + * See https://reactjs.org/docs/react-api.html#cloneelement + */ + + function cloneElement(element, config, children) { + if (!!(element === null || element === undefined)) { + { + throw Error( "React.cloneElement(...): The argument must be a React element, but you passed " + element + "." ); + } + } + + var propName; // Original props are copied + + var props = assign({}, element.props); // Reserved names are extracted + + + var key = element.key; + var ref = element.ref; // Self is preserved since the owner is preserved. + + var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a + // transpiler, and the original source is probably a better indicator of the + // true owner. + + var source = element._source; // Owner will be preserved, unless ref is overridden + + var owner = element._owner; + + if (config != null) { + if (hasValidRef(config)) { + // Silently steal the ref from the parent. + ref = config.ref; + owner = ReactCurrentOwner.current; + } + + if (hasValidKey(config)) { + key = '' + config.key; + } // Remaining properties override existing props + + + var defaultProps; + + if (element.type && element.type.defaultProps) { + defaultProps = element.type.defaultProps; + } + + for (propName in config) { + if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { + if (config[propName] === undefined && defaultProps !== undefined) { + // Resolve default props + props[propName] = defaultProps[propName]; + } else { + props[propName] = config[propName]; + } + } + } + } // Children can be more than one argument, and those are transferred onto + // the newly allocated props object. + + + var childrenLength = arguments.length - 2; + + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = Array(childrenLength); + + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 2]; + } + + props.children = childArray; + } + + return ReactElement(element.type, key, ref, self, source, owner, props); + } + /** + * Verifies the object is a ReactElement. + * See https://reactjs.org/docs/react-api.html#isvalidelement + * @param {?object} object + * @return {boolean} True if `object` is a ReactElement. + * @final + */ + + function isValidElement(object) { + return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; + } + + var SEPARATOR = '.'; + var SUBSEPARATOR = ':'; + /** + * Escape and wrap key so it is safe to use as a reactid + * + * @param {string} key to be escaped. + * @return {string} the escaped key. + */ + + function escape(key) { + var escapeRegex = /[=:]/g; + var escaperLookup = { + '=': '=0', + ':': '=2' + }; + var escapedString = key.replace(escapeRegex, function (match) { + return escaperLookup[match]; + }); + return '$' + escapedString; + } + /** + * TODO: Test that a single child and an array with one item have the same key + * pattern. + */ + + + var didWarnAboutMaps = false; + var userProvidedKeyEscapeRegex = /\/+/g; + + function escapeUserProvidedKey(text) { + return text.replace(userProvidedKeyEscapeRegex, '$&/'); + } + /** + * Generate a key string that identifies a element within a set. + * + * @param {*} element A element that could contain a manual key. + * @param {number} index Index that is used if a manual key is not provided. + * @return {string} + */ + + + function getElementKey(element, index) { + // Do some typechecking here since we call this blindly. We want to ensure + // that we don't block potential future ES APIs. + if (typeof element === 'object' && element !== null && element.key != null) { + // Explicit key + return escape('' + element.key); + } // Implicit key determined by the index in the set + + + return index.toString(36); + } + + function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) { + var type = typeof children; + + if (type === 'undefined' || type === 'boolean') { + // All of the above are perceived as null. + children = null; + } + + var invokeCallback = false; + + if (children === null) { + invokeCallback = true; + } else { + switch (type) { + case 'string': + case 'number': + invokeCallback = true; + break; + + case 'object': + switch (children.$$typeof) { + case REACT_ELEMENT_TYPE: + case REACT_PORTAL_TYPE: + invokeCallback = true; + } + + } + } + + if (invokeCallback) { + var _child = children; + var mappedChild = callback(_child); // If it's the only child, treat the name as if it was wrapped in an array + // so that it's consistent if the number of children grows: + + var childKey = nameSoFar === '' ? SEPARATOR + getElementKey(_child, 0) : nameSoFar; + + if (Array.isArray(mappedChild)) { + var escapedChildKey = ''; + + if (childKey != null) { + escapedChildKey = escapeUserProvidedKey(childKey) + '/'; + } + + mapIntoArray(mappedChild, array, escapedChildKey, '', function (c) { + return c; + }); + } else if (mappedChild != null) { + if (isValidElement(mappedChild)) { + mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as + // traverseAllChildren used to do for objects as children + escapedPrefix + ( // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key + mappedChild.key && (!_child || _child.key !== mappedChild.key) ? // $FlowFixMe Flow incorrectly thinks existing element's key can be a number + escapeUserProvidedKey('' + mappedChild.key) + '/' : '') + childKey); + } + + array.push(mappedChild); + } + + return 1; + } + + var child; + var nextName; + var subtreeCount = 0; // Count of children found in the current subtree. + + var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR; + + if (Array.isArray(children)) { + for (var i = 0; i < children.length; i++) { + child = children[i]; + nextName = nextNamePrefix + getElementKey(child, i); + subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback); + } + } else { + var iteratorFn = getIteratorFn(children); + + if (typeof iteratorFn === 'function') { + var iterableChildren = children; + + { + // Warn about using Maps as children + if (iteratorFn === iterableChildren.entries) { + if (!didWarnAboutMaps) { + warn('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.'); + } + + didWarnAboutMaps = true; + } + } + + var iterator = iteratorFn.call(iterableChildren); + var step; + var ii = 0; + + while (!(step = iterator.next()).done) { + child = step.value; + nextName = nextNamePrefix + getElementKey(child, ii++); + subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback); + } + } else if (type === 'object') { + var childrenString = '' + children; + + { + { + throw Error( "Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + "). If you meant to render a collection of children, use an array instead." ); + } + } + } + } + + return subtreeCount; + } + + /** + * Maps children that are typically specified as `props.children`. + * + * See https://reactjs.org/docs/react-api.html#reactchildrenmap + * + * The provided mapFunction(child, index) will be called for each + * leaf child. + * + * @param {?*} children Children tree container. + * @param {function(*, int)} func The map function. + * @param {*} context Context for mapFunction. + * @return {object} Object containing the ordered map of results. + */ + function mapChildren(children, func, context) { + if (children == null) { + return children; + } + + var result = []; + var count = 0; + mapIntoArray(children, result, '', '', function (child) { + return func.call(context, child, count++); + }); + return result; + } + /** + * Count the number of children that are typically specified as + * `props.children`. + * + * See https://reactjs.org/docs/react-api.html#reactchildrencount + * + * @param {?*} children Children tree container. + * @return {number} The number of children. + */ + + + function countChildren(children) { + var n = 0; + mapChildren(children, function () { + n++; // Don't return anything + }); + return n; + } + + /** + * Iterates through children that are typically specified as `props.children`. + * + * See https://reactjs.org/docs/react-api.html#reactchildrenforeach + * + * The provided forEachFunc(child, index) will be called for each + * leaf child. + * + * @param {?*} children Children tree container. + * @param {function(*, int)} forEachFunc + * @param {*} forEachContext Context for forEachContext. + */ + function forEachChildren(children, forEachFunc, forEachContext) { + mapChildren(children, function () { + forEachFunc.apply(this, arguments); // Don't return anything. + }, forEachContext); + } + /** + * Flatten a children object (typically specified as `props.children`) and + * return an array with appropriately re-keyed children. + * + * See https://reactjs.org/docs/react-api.html#reactchildrentoarray + */ + + + function toArray(children) { + return mapChildren(children, function (child) { + return child; + }) || []; + } + /** + * Returns the first child in a collection of children and verifies that there + * is only one child in the collection. + * + * See https://reactjs.org/docs/react-api.html#reactchildrenonly + * + * The current implementation of this function assumes that a single child gets + * passed without a wrapper, but the purpose of this helper function is to + * abstract away the particular structure of children. + * + * @param {?object} children Child collection structure. + * @return {ReactElement} The first and only `ReactElement` contained in the + * structure. + */ + + + function onlyChild(children) { + if (!isValidElement(children)) { + { + throw Error( "React.Children.only expected to receive a single React element child." ); + } + } + + return children; + } + + function createContext(defaultValue, calculateChangedBits) { + if (calculateChangedBits === undefined) { + calculateChangedBits = null; + } else { + { + if (calculateChangedBits !== null && typeof calculateChangedBits !== 'function') { + error('createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits); + } + } + } + + var context = { + $$typeof: REACT_CONTEXT_TYPE, + _calculateChangedBits: calculateChangedBits, + // As a workaround to support multiple concurrent renderers, we categorize + // some renderers as primary and others as secondary. We only expect + // there to be two concurrent renderers at most: React Native (primary) and + // Fabric (secondary); React DOM (primary) and React ART (secondary). + // Secondary renderers store their context values on separate fields. + _currentValue: defaultValue, + _currentValue2: defaultValue, + // Used to track how many concurrent renderers this context currently + // supports within in a single renderer. Such as parallel server rendering. + _threadCount: 0, + // These are circular + Provider: null, + Consumer: null + }; + context.Provider = { + $$typeof: REACT_PROVIDER_TYPE, + _context: context + }; + var hasWarnedAboutUsingNestedContextConsumers = false; + var hasWarnedAboutUsingConsumerProvider = false; + var hasWarnedAboutDisplayNameOnConsumer = false; + + { + // A separate object, but proxies back to the original context object for + // backwards compatibility. It has a different $$typeof, so we can properly + // warn for the incorrect usage of Context as a Consumer. + var Consumer = { + $$typeof: REACT_CONTEXT_TYPE, + _context: context, + _calculateChangedBits: context._calculateChangedBits + }; // $FlowFixMe: Flow complains about not setting a value, which is intentional here + + Object.defineProperties(Consumer, { + Provider: { + get: function () { + if (!hasWarnedAboutUsingConsumerProvider) { + hasWarnedAboutUsingConsumerProvider = true; + + error('Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?'); + } + + return context.Provider; + }, + set: function (_Provider) { + context.Provider = _Provider; + } + }, + _currentValue: { + get: function () { + return context._currentValue; + }, + set: function (_currentValue) { + context._currentValue = _currentValue; + } + }, + _currentValue2: { + get: function () { + return context._currentValue2; + }, + set: function (_currentValue2) { + context._currentValue2 = _currentValue2; + } + }, + _threadCount: { + get: function () { + return context._threadCount; + }, + set: function (_threadCount) { + context._threadCount = _threadCount; + } + }, + Consumer: { + get: function () { + if (!hasWarnedAboutUsingNestedContextConsumers) { + hasWarnedAboutUsingNestedContextConsumers = true; + + error('Rendering <Context.Consumer.Consumer> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?'); + } + + return context.Consumer; + } + }, + displayName: { + get: function () { + return context.displayName; + }, + set: function (displayName) { + if (!hasWarnedAboutDisplayNameOnConsumer) { + warn('Setting `displayName` on Context.Consumer has no effect. ' + "You should set it directly on the context with Context.displayName = '%s'.", displayName); + + hasWarnedAboutDisplayNameOnConsumer = true; + } + } + } + }); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty + + context.Consumer = Consumer; + } + + { + context._currentRenderer = null; + context._currentRenderer2 = null; + } + + return context; + } + + var Uninitialized = -1; + var Pending = 0; + var Resolved = 1; + var Rejected = 2; + + function lazyInitializer(payload) { + if (payload._status === Uninitialized) { + var ctor = payload._result; + var thenable = ctor(); // Transition to the next state. + + var pending = payload; + pending._status = Pending; + pending._result = thenable; + thenable.then(function (moduleObject) { + if (payload._status === Pending) { + var defaultExport = moduleObject.default; + + { + if (defaultExport === undefined) { + error('lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + // Break up imports to avoid accidentally parsing them as dependencies. + 'const MyComponent = lazy(() => imp' + "ort('./MyComponent'))", moduleObject); + } + } // Transition to the next state. + + + var resolved = payload; + resolved._status = Resolved; + resolved._result = defaultExport; + } + }, function (error) { + if (payload._status === Pending) { + // Transition to the next state. + var rejected = payload; + rejected._status = Rejected; + rejected._result = error; + } + }); + } + + if (payload._status === Resolved) { + return payload._result; + } else { + throw payload._result; + } + } + + function lazy(ctor) { + var payload = { + // We use these fields to store the result. + _status: -1, + _result: ctor + }; + var lazyType = { + $$typeof: REACT_LAZY_TYPE, + _payload: payload, + _init: lazyInitializer + }; + + { + // In production, this would just set it on the object. + var defaultProps; + var propTypes; // $FlowFixMe + + Object.defineProperties(lazyType, { + defaultProps: { + configurable: true, + get: function () { + return defaultProps; + }, + set: function (newDefaultProps) { + error('React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.'); + + defaultProps = newDefaultProps; // Match production behavior more closely: + // $FlowFixMe + + Object.defineProperty(lazyType, 'defaultProps', { + enumerable: true + }); + } + }, + propTypes: { + configurable: true, + get: function () { + return propTypes; + }, + set: function (newPropTypes) { + error('React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.'); + + propTypes = newPropTypes; // Match production behavior more closely: + // $FlowFixMe + + Object.defineProperty(lazyType, 'propTypes', { + enumerable: true + }); + } + } + }); + } + + return lazyType; + } + + function forwardRef(render) { + { + if (render != null && render.$$typeof === REACT_MEMO_TYPE) { + error('forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).'); + } else if (typeof render !== 'function') { + error('forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render); + } else { + if (render.length !== 0 && render.length !== 2) { + error('forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.'); + } + } + + if (render != null) { + if (render.defaultProps != null || render.propTypes != null) { + error('forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?'); + } + } + } + + var elementType = { + $$typeof: REACT_FORWARD_REF_TYPE, + render: render + }; + + { + var ownName; + Object.defineProperty(elementType, 'displayName', { + enumerable: false, + configurable: true, + get: function () { + return ownName; + }, + set: function (name) { + ownName = name; + + if (render.displayName == null) { + render.displayName = name; + } + } + }); + } + + return elementType; + } + + // Filter certain DOM attributes (e.g. src, href) if their values are empty strings. + + var enableScopeAPI = false; // Experimental Create Event Handle API. + + function isValidElementType(type) { + if (typeof type === 'string' || typeof type === 'function') { + return true; + } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill). + + + if (type === exports.Fragment || type === exports.Profiler || type === REACT_DEBUG_TRACING_MODE_TYPE || type === exports.StrictMode || type === exports.Suspense || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) { + return true; + } + + if (typeof type === 'object' && type !== null) { + if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) { + return true; + } + } + + return false; + } + + function memo(type, compare) { + { + if (!isValidElementType(type)) { + error('memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type); + } + } + + var elementType = { + $$typeof: REACT_MEMO_TYPE, + type: type, + compare: compare === undefined ? null : compare + }; + + { + var ownName; + Object.defineProperty(elementType, 'displayName', { + enumerable: false, + configurable: true, + get: function () { + return ownName; + }, + set: function (name) { + ownName = name; + + if (type.displayName == null) { + type.displayName = name; + } + } + }); + } + + return elementType; + } + + function resolveDispatcher() { + var dispatcher = ReactCurrentDispatcher.current; + + if (!(dispatcher !== null)) { + { + throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." ); + } + } + + return dispatcher; + } + + function useContext(Context, unstable_observedBits) { + var dispatcher = resolveDispatcher(); + + { + if (unstable_observedBits !== undefined) { + error('useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://reactjs.org/link/rules-of-hooks' : ''); + } // TODO: add a more generic warning for invalid values. + + + if (Context._context !== undefined) { + var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs + // and nobody should be using this in existing code. + + if (realContext.Consumer === Context) { + error('Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?'); + } else if (realContext.Provider === Context) { + error('Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?'); + } + } + } + + return dispatcher.useContext(Context, unstable_observedBits); + } + function useState(initialState) { + var dispatcher = resolveDispatcher(); + return dispatcher.useState(initialState); + } + function useReducer(reducer, initialArg, init) { + var dispatcher = resolveDispatcher(); + return dispatcher.useReducer(reducer, initialArg, init); + } + function useRef(initialValue) { + var dispatcher = resolveDispatcher(); + return dispatcher.useRef(initialValue); + } + function useEffect(create, deps) { + var dispatcher = resolveDispatcher(); + return dispatcher.useEffect(create, deps); + } + function useLayoutEffect(create, deps) { + var dispatcher = resolveDispatcher(); + return dispatcher.useLayoutEffect(create, deps); + } + function useCallback(callback, deps) { + var dispatcher = resolveDispatcher(); + return dispatcher.useCallback(callback, deps); + } + function useMemo(create, deps) { + var dispatcher = resolveDispatcher(); + return dispatcher.useMemo(create, deps); + } + function useImperativeHandle(ref, create, deps) { + var dispatcher = resolveDispatcher(); + return dispatcher.useImperativeHandle(ref, create, deps); + } + function useDebugValue(value, formatterFn) { + { + var dispatcher = resolveDispatcher(); + return dispatcher.useDebugValue(value, formatterFn); + } + } + + // Helpers to patch console.logs to avoid logging during side-effect free + // replaying on render function. This currently only patches the object + // lazily which won't cover if the log function was extracted eagerly. + // We could also eagerly patch the method. + var disabledDepth = 0; + var prevLog; + var prevInfo; + var prevWarn; + var prevError; + var prevGroup; + var prevGroupCollapsed; + var prevGroupEnd; + + function disabledLog() {} + + disabledLog.__reactDisabledLog = true; + function disableLogs() { + { + if (disabledDepth === 0) { + /* eslint-disable react-internal/no-production-logging */ + prevLog = console.log; + prevInfo = console.info; + prevWarn = console.warn; + prevError = console.error; + prevGroup = console.group; + prevGroupCollapsed = console.groupCollapsed; + prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 + + var props = { + configurable: true, + enumerable: true, + value: disabledLog, + writable: true + }; // $FlowFixMe Flow thinks console is immutable. + + Object.defineProperties(console, { + info: props, + log: props, + warn: props, + error: props, + group: props, + groupCollapsed: props, + groupEnd: props + }); + /* eslint-enable react-internal/no-production-logging */ + } + + disabledDepth++; + } + } + function reenableLogs() { + { + disabledDepth--; + + if (disabledDepth === 0) { + /* eslint-disable react-internal/no-production-logging */ + var props = { + configurable: true, + enumerable: true, + writable: true + }; // $FlowFixMe Flow thinks console is immutable. + + Object.defineProperties(console, { + log: assign({}, props, { + value: prevLog + }), + info: assign({}, props, { + value: prevInfo + }), + warn: assign({}, props, { + value: prevWarn + }), + error: assign({}, props, { + value: prevError + }), + group: assign({}, props, { + value: prevGroup + }), + groupCollapsed: assign({}, props, { + value: prevGroupCollapsed + }), + groupEnd: assign({}, props, { + value: prevGroupEnd + }) + }); + /* eslint-enable react-internal/no-production-logging */ + } + + if (disabledDepth < 0) { + error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.'); + } + } + } + + var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher; + var prefix; + function describeBuiltInComponentFrame(name, source, ownerFn) { + { + if (prefix === undefined) { + // Extract the VM specific prefix used by each line. + try { + throw Error(); + } catch (x) { + var match = x.stack.trim().match(/\n( *(at )?)/); + prefix = match && match[1] || ''; + } + } // We use the prefix to ensure our stacks line up with native stack frames. + + + return '\n' + prefix + name; + } + } + var reentry = false; + var componentFrameCache; + + { + var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map; + componentFrameCache = new PossiblyWeakMap(); + } + + function describeNativeComponentFrame(fn, construct) { + // If something asked for a stack inside a fake render, it should get ignored. + if (!fn || reentry) { + return ''; + } + + { + var frame = componentFrameCache.get(fn); + + if (frame !== undefined) { + return frame; + } + } + + var control; + reentry = true; + var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined. + + Error.prepareStackTrace = undefined; + var previousDispatcher; + + { + previousDispatcher = ReactCurrentDispatcher$1.current; // Set the dispatcher in DEV because this might be call in the render function + // for warnings. + + ReactCurrentDispatcher$1.current = null; + disableLogs(); + } + + try { + // This should throw. + if (construct) { + // Something should be setting the props in the constructor. + var Fake = function () { + throw Error(); + }; // $FlowFixMe + + + Object.defineProperty(Fake.prototype, 'props', { + set: function () { + // We use a throwing setter instead of frozen or non-writable props + // because that won't throw in a non-strict mode function. + throw Error(); + } + }); + + if (typeof Reflect === 'object' && Reflect.construct) { + // We construct a different control for this case to include any extra + // frames added by the construct call. + try { + Reflect.construct(Fake, []); + } catch (x) { + control = x; + } + + Reflect.construct(fn, [], Fake); + } else { + try { + Fake.call(); + } catch (x) { + control = x; + } + + fn.call(Fake.prototype); + } + } else { + try { + throw Error(); + } catch (x) { + control = x; + } + + fn(); + } + } catch (sample) { + // This is inlined manually because closure doesn't do it for us. + if (sample && control && typeof sample.stack === 'string') { + // This extracts the first frame from the sample that isn't also in the control. + // Skipping one frame that we assume is the frame that calls the two. + var sampleLines = sample.stack.split('\n'); + var controlLines = control.stack.split('\n'); + var s = sampleLines.length - 1; + var c = controlLines.length - 1; + + while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) { + // We expect at least one stack frame to be shared. + // Typically this will be the root most one. However, stack frames may be + // cut off due to maximum stack limits. In this case, one maybe cut off + // earlier than the other. We assume that the sample is longer or the same + // and there for cut off earlier. So we should find the root most frame in + // the sample somewhere in the control. + c--; + } + + for (; s >= 1 && c >= 0; s--, c--) { + // Next we find the first one that isn't the same which should be the + // frame that called our sample function and the control. + if (sampleLines[s] !== controlLines[c]) { + // In V8, the first line is describing the message but other VMs don't. + // If we're about to return the first line, and the control is also on the same + // line, that's a pretty good indicator that our sample threw at same line as + // the control. I.e. before we entered the sample frame. So we ignore this result. + // This can happen if you passed a class to function component, or non-function. + if (s !== 1 || c !== 1) { + do { + s--; + c--; // We may still have similar intermediate frames from the construct call. + // The next one that isn't the same should be our match though. + + if (c < 0 || sampleLines[s] !== controlLines[c]) { + // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier. + var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); + + { + if (typeof fn === 'function') { + componentFrameCache.set(fn, _frame); + } + } // Return the line we found. + + + return _frame; + } + } while (s >= 1 && c >= 0); + } + + break; + } + } + } + } finally { + reentry = false; + + { + ReactCurrentDispatcher$1.current = previousDispatcher; + reenableLogs(); + } + + Error.prepareStackTrace = previousPrepareStackTrace; + } // Fallback to just using the name if we couldn't make it throw. + + + var name = fn ? fn.displayName || fn.name : ''; + var syntheticFrame = name ? describeBuiltInComponentFrame(name) : ''; + + { + if (typeof fn === 'function') { + componentFrameCache.set(fn, syntheticFrame); + } + } + + return syntheticFrame; + } + function describeFunctionComponentFrame(fn, source, ownerFn) { + { + return describeNativeComponentFrame(fn, false); + } + } + + function shouldConstruct(Component) { + var prototype = Component.prototype; + return !!(prototype && prototype.isReactComponent); + } + + function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) { + + if (type == null) { + return ''; + } + + if (typeof type === 'function') { + { + return describeNativeComponentFrame(type, shouldConstruct(type)); + } + } + + if (typeof type === 'string') { + return describeBuiltInComponentFrame(type); + } + + switch (type) { + case exports.Suspense: + return describeBuiltInComponentFrame('Suspense'); + + case REACT_SUSPENSE_LIST_TYPE: + return describeBuiltInComponentFrame('SuspenseList'); + } + + if (typeof type === 'object') { + switch (type.$$typeof) { + case REACT_FORWARD_REF_TYPE: + return describeFunctionComponentFrame(type.render); + + case REACT_MEMO_TYPE: + // Memo may contain any component type so we recursively resolve it. + return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn); + + case REACT_BLOCK_TYPE: + return describeFunctionComponentFrame(type._render); + + case REACT_LAZY_TYPE: + { + var lazyComponent = type; + var payload = lazyComponent._payload; + var init = lazyComponent._init; + + try { + // Lazy may contain any component type so we recursively resolve it. + return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn); + } catch (x) {} + } + } + } + + return ''; + } + + var loggedTypeFailures = {}; + var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; + + function setCurrentlyValidatingElement(element) { + { + if (element) { + var owner = element._owner; + var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null); + ReactDebugCurrentFrame$1.setExtraStackFrame(stack); + } else { + ReactDebugCurrentFrame$1.setExtraStackFrame(null); + } + } + } + + function checkPropTypes(typeSpecs, values, location, componentName, element) { + { + // $FlowFixMe This is okay but Flow doesn't know it. + var has = Function.call.bind(Object.prototype.hasOwnProperty); + + for (var typeSpecName in typeSpecs) { + if (has(typeSpecs, typeSpecName)) { + var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to + // fail the render phase where it didn't fail before. So we log it. + // After these have been cleaned up, we'll let them throw. + + try { + // This is intentionally an invariant that gets caught. It's the same + // behavior as without this statement except with a better message. + if (typeof typeSpecs[typeSpecName] !== 'function') { + var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'); + err.name = 'Invariant Violation'; + throw err; + } + + error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'); + } catch (ex) { + error$1 = ex; + } + + if (error$1 && !(error$1 instanceof Error)) { + setCurrentlyValidatingElement(element); + + error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1); + + setCurrentlyValidatingElement(null); + } + + if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) { + // Only monitor this failure once because there tends to be a lot of the + // same error. + loggedTypeFailures[error$1.message] = true; + setCurrentlyValidatingElement(element); + + error('Failed %s type: %s', location, error$1.message); + + setCurrentlyValidatingElement(null); + } + } + } + } + } + + function setCurrentlyValidatingElement$1(element) { + { + if (element) { + var owner = element._owner; + var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null); + setExtraStackFrame(stack); + } else { + setExtraStackFrame(null); + } + } + } + + var propTypesMisspellWarningShown; + + { + propTypesMisspellWarningShown = false; + } + + function getDeclarationErrorAddendum() { + if (ReactCurrentOwner.current) { + var name = getComponentName(ReactCurrentOwner.current.type); + + if (name) { + return '\n\nCheck the render method of `' + name + '`.'; + } + } + + return ''; + } + + function getSourceInfoErrorAddendum(source) { + if (source !== undefined) { + var fileName = source.fileName.replace(/^.*[\\\/]/, ''); + var lineNumber = source.lineNumber; + return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.'; + } + + return ''; + } + + function getSourceInfoErrorAddendumForProps(elementProps) { + if (elementProps !== null && elementProps !== undefined) { + return getSourceInfoErrorAddendum(elementProps.__source); + } + + return ''; + } + /** + * Warn if there's no key explicitly set on dynamic arrays of children or + * object keys are not valid. This allows us to keep track of children between + * updates. + */ + + + var ownerHasKeyUseWarning = {}; + + function getCurrentComponentErrorInfo(parentType) { + var info = getDeclarationErrorAddendum(); + + if (!info) { + var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; + + if (parentName) { + info = "\n\nCheck the top-level render call using <" + parentName + ">."; + } + } + + return info; + } + /** + * Warn if the element doesn't have an explicit key assigned to it. + * This element is in an array. The array could grow and shrink or be + * reordered. All children that haven't already been validated are required to + * have a "key" property assigned to it. Error statuses are cached so a warning + * will only be shown once. + * + * @internal + * @param {ReactElement} element Element that requires a key. + * @param {*} parentType element's parent's type. + */ + + + function validateExplicitKey(element, parentType) { + if (!element._store || element._store.validated || element.key != null) { + return; + } + + element._store.validated = true; + var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); + + if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { + return; + } + + ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a + // property, it may be the creator of the child that's responsible for + // assigning it a key. + + var childOwner = ''; + + if (element && element._owner && element._owner !== ReactCurrentOwner.current) { + // Give the component that originally created this child. + childOwner = " It was passed a child from " + getComponentName(element._owner.type) + "."; + } + + { + setCurrentlyValidatingElement$1(element); + + error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner); + + setCurrentlyValidatingElement$1(null); + } + } + /** + * Ensure that every element either is passed in a static location, in an + * array with an explicit keys property defined, or in an object literal + * with valid key property. + * + * @internal + * @param {ReactNode} node Statically passed child of any type. + * @param {*} parentType node's parent's type. + */ + + + function validateChildKeys(node, parentType) { + if (typeof node !== 'object') { + return; + } + + if (Array.isArray(node)) { + for (var i = 0; i < node.length; i++) { + var child = node[i]; + + if (isValidElement(child)) { + validateExplicitKey(child, parentType); + } + } + } else if (isValidElement(node)) { + // This element was passed in a valid location. + if (node._store) { + node._store.validated = true; + } + } else if (node) { + var iteratorFn = getIteratorFn(node); + + if (typeof iteratorFn === 'function') { + // Entry iterators used to provide implicit keys, + // but now we print a separate warning for them later. + if (iteratorFn !== node.entries) { + var iterator = iteratorFn.call(node); + var step; + + while (!(step = iterator.next()).done) { + if (isValidElement(step.value)) { + validateExplicitKey(step.value, parentType); + } + } + } + } + } + } + /** + * Given an element, validate that its props follow the propTypes definition, + * provided by the type. + * + * @param {ReactElement} element + */ + + + function validatePropTypes(element) { + { + var type = element.type; + + if (type === null || type === undefined || typeof type === 'string') { + return; + } + + var propTypes; + + if (typeof type === 'function') { + propTypes = type.propTypes; + } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. + // Inner props are checked in the reconciler. + type.$$typeof === REACT_MEMO_TYPE)) { + propTypes = type.propTypes; + } else { + return; + } + + if (propTypes) { + // Intentionally inside to avoid triggering lazy initializers: + var name = getComponentName(type); + checkPropTypes(propTypes, element.props, 'prop', name, element); + } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) { + propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers: + + var _name = getComponentName(type); + + error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown'); + } + + if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) { + error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.'); + } + } + } + /** + * Given a fragment, validate that it can only be provided with fragment props + * @param {ReactElement} fragment + */ + + + function validateFragmentProps(fragment) { + { + var keys = Object.keys(fragment.props); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + + if (key !== 'children' && key !== 'key') { + setCurrentlyValidatingElement$1(fragment); + + error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); + + setCurrentlyValidatingElement$1(null); + break; + } + } + + if (fragment.ref !== null) { + setCurrentlyValidatingElement$1(fragment); + + error('Invalid attribute `ref` supplied to `React.Fragment`.'); + + setCurrentlyValidatingElement$1(null); + } + } + } + function createElementWithValidation(type, props, children) { + var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to + // succeed and there will likely be errors in render. + + if (!validType) { + var info = ''; + + if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { + info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports."; + } + + var sourceInfo = getSourceInfoErrorAddendumForProps(props); + + if (sourceInfo) { + info += sourceInfo; + } else { + info += getDeclarationErrorAddendum(); + } + + var typeString; + + if (type === null) { + typeString = 'null'; + } else if (Array.isArray(type)) { + typeString = 'array'; + } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) { + typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />"; + info = ' Did you accidentally export a JSX literal instead of a component?'; + } else { + typeString = typeof type; + } + + { + error('React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info); + } + } + + var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used. + // TODO: Drop this when these are no longer allowed as the type argument. + + if (element == null) { + return element; + } // Skip key warning if the type isn't valid since our key validation logic + // doesn't expect a non-string/function type and can throw confusing errors. + // We don't want exception behavior to differ between dev and prod. + // (Rendering will throw with a helpful message and as soon as the type is + // fixed, the key warnings will appear.) + + + if (validType) { + for (var i = 2; i < arguments.length; i++) { + validateChildKeys(arguments[i], type); + } + } + + if (type === exports.Fragment) { + validateFragmentProps(element); + } else { + validatePropTypes(element); + } + + return element; + } + var didWarnAboutDeprecatedCreateFactory = false; + function createFactoryWithValidation(type) { + var validatedFactory = createElementWithValidation.bind(null, type); + validatedFactory.type = type; + + { + if (!didWarnAboutDeprecatedCreateFactory) { + didWarnAboutDeprecatedCreateFactory = true; + + warn('React.createFactory() is deprecated and will be removed in ' + 'a future major release. Consider using JSX ' + 'or use React.createElement() directly instead.'); + } // Legacy hook: remove it + + + Object.defineProperty(validatedFactory, 'type', { + enumerable: false, + get: function () { + warn('Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.'); + + Object.defineProperty(this, 'type', { + value: type + }); + return type; + } + }); + } + + return validatedFactory; + } + function cloneElementWithValidation(element, props, children) { + var newElement = cloneElement.apply(this, arguments); + + for (var i = 2; i < arguments.length; i++) { + validateChildKeys(arguments[i], newElement.type); + } + + validatePropTypes(newElement); + return newElement; + } + + var enableSchedulerDebugging = false; + var enableProfiling = false; + + var requestHostCallback; + var requestHostTimeout; + var cancelHostTimeout; + var shouldYieldToHost; + var requestPaint; + var getCurrentTime; + var forceFrameRate; + var hasPerformanceNow = typeof performance === 'object' && typeof performance.now === 'function'; + + if (hasPerformanceNow) { + var localPerformance = performance; + + getCurrentTime = function () { + return localPerformance.now(); + }; + } else { + var localDate = Date; + var initialTime = localDate.now(); + + getCurrentTime = function () { + return localDate.now() - initialTime; + }; + } + + if ( // If Scheduler runs in a non-DOM environment, it falls back to a naive + // implementation using setTimeout. + typeof window === 'undefined' || // Check if MessageChannel is supported, too. + typeof MessageChannel !== 'function') { + // If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore, + // fallback to a naive implementation. + var _callback = null; + var _timeoutID = null; + + var _flushCallback = function () { + if (_callback !== null) { + try { + var currentTime = getCurrentTime(); + var hasRemainingTime = true; + + _callback(hasRemainingTime, currentTime); + + _callback = null; + } catch (e) { + setTimeout(_flushCallback, 0); + throw e; + } + } + }; + + requestHostCallback = function (cb) { + if (_callback !== null) { + // Protect against re-entrancy. + setTimeout(requestHostCallback, 0, cb); + } else { + _callback = cb; + setTimeout(_flushCallback, 0); + } + }; + + requestHostTimeout = function (cb, ms) { + _timeoutID = setTimeout(cb, ms); + }; + + cancelHostTimeout = function () { + clearTimeout(_timeoutID); + }; + + shouldYieldToHost = function () { + return false; + }; + + requestPaint = forceFrameRate = function () {}; + } else { + // Capture local references to native APIs, in case a polyfill overrides them. + var _setTimeout = window.setTimeout; + var _clearTimeout = window.clearTimeout; + + if (typeof console !== 'undefined') { + // TODO: Scheduler no longer requires these methods to be polyfilled. But + // maybe we want to continue warning if they don't exist, to preserve the + // option to rely on it in the future? + var requestAnimationFrame = window.requestAnimationFrame; + var cancelAnimationFrame = window.cancelAnimationFrame; + + if (typeof requestAnimationFrame !== 'function') { + // Using console['error'] to evade Babel and ESLint + console['error']("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://reactjs.org/link/react-polyfills'); + } + + if (typeof cancelAnimationFrame !== 'function') { + // Using console['error'] to evade Babel and ESLint + console['error']("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://reactjs.org/link/react-polyfills'); + } + } + + var isMessageLoopRunning = false; + var scheduledHostCallback = null; + var taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main + // thread, like user events. By default, it yields multiple times per frame. + // It does not attempt to align with frame boundaries, since most tasks don't + // need to be frame aligned; for those that do, use requestAnimationFrame. + + var yieldInterval = 5; + var deadline = 0; // TODO: Make this configurable + + { + // `isInputPending` is not available. Since we have no way of knowing if + // there's pending input, always yield at the end of the frame. + shouldYieldToHost = function () { + return getCurrentTime() >= deadline; + }; // Since we yield every frame regardless, `requestPaint` has no effect. + + + requestPaint = function () {}; + } + + forceFrameRate = function (fps) { + if (fps < 0 || fps > 125) { + // Using console['error'] to evade Babel and ESLint + console['error']('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing frame rates higher than 125 fps is not supported'); + return; + } + + if (fps > 0) { + yieldInterval = Math.floor(1000 / fps); + } else { + // reset the framerate + yieldInterval = 5; + } + }; + + var performWorkUntilDeadline = function () { + if (scheduledHostCallback !== null) { + var currentTime = getCurrentTime(); // Yield after `yieldInterval` ms, regardless of where we are in the vsync + // cycle. This means there's always time remaining at the beginning of + // the message event. + + deadline = currentTime + yieldInterval; + var hasTimeRemaining = true; + + try { + var hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime); + + if (!hasMoreWork) { + isMessageLoopRunning = false; + scheduledHostCallback = null; + } else { + // If there's more work, schedule the next message event at the end + // of the preceding one. + port.postMessage(null); + } + } catch (error) { + // If a scheduler task throws, exit the current browser task so the + // error can be observed. + port.postMessage(null); + throw error; + } + } else { + isMessageLoopRunning = false; + } // Yielding to the browser will give it a chance to paint, so we can + }; + + var channel = new MessageChannel(); + var port = channel.port2; + channel.port1.onmessage = performWorkUntilDeadline; + + requestHostCallback = function (callback) { + scheduledHostCallback = callback; + + if (!isMessageLoopRunning) { + isMessageLoopRunning = true; + port.postMessage(null); + } + }; + + requestHostTimeout = function (callback, ms) { + taskTimeoutID = _setTimeout(function () { + callback(getCurrentTime()); + }, ms); + }; + + cancelHostTimeout = function () { + _clearTimeout(taskTimeoutID); + + taskTimeoutID = -1; + }; + } + + function push(heap, node) { + var index = heap.length; + heap.push(node); + siftUp(heap, node, index); + } + function peek(heap) { + var first = heap[0]; + return first === undefined ? null : first; + } + function pop(heap) { + var first = heap[0]; + + if (first !== undefined) { + var last = heap.pop(); + + if (last !== first) { + heap[0] = last; + siftDown(heap, last, 0); + } + + return first; + } else { + return null; + } + } + + function siftUp(heap, node, i) { + var index = i; + + while (true) { + var parentIndex = index - 1 >>> 1; + var parent = heap[parentIndex]; + + if (parent !== undefined && compare(parent, node) > 0) { + // The parent is larger. Swap positions. + heap[parentIndex] = node; + heap[index] = parent; + index = parentIndex; + } else { + // The parent is smaller. Exit. + return; + } + } + } + + function siftDown(heap, node, i) { + var index = i; + var length = heap.length; + + while (index < length) { + var leftIndex = (index + 1) * 2 - 1; + var left = heap[leftIndex]; + var rightIndex = leftIndex + 1; + var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those. + + if (left !== undefined && compare(left, node) < 0) { + if (right !== undefined && compare(right, left) < 0) { + heap[index] = right; + heap[rightIndex] = node; + index = rightIndex; + } else { + heap[index] = left; + heap[leftIndex] = node; + index = leftIndex; + } + } else if (right !== undefined && compare(right, node) < 0) { + heap[index] = right; + heap[rightIndex] = node; + index = rightIndex; + } else { + // Neither child is smaller. Exit. + return; + } + } + } + + function compare(a, b) { + // Compare sort index first, then task id. + var diff = a.sortIndex - b.sortIndex; + return diff !== 0 ? diff : a.id - b.id; + } + + // TODO: Use symbols? + var ImmediatePriority = 1; + var UserBlockingPriority = 2; + var NormalPriority = 3; + var LowPriority = 4; + var IdlePriority = 5; + + function markTaskErrored(task, ms) { + } + + /* eslint-disable no-var */ + // Math.pow(2, 30) - 1 + // 0b111111111111111111111111111111 + + var maxSigned31BitInt = 1073741823; // Times out immediately + + var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out + + var USER_BLOCKING_PRIORITY_TIMEOUT = 250; + var NORMAL_PRIORITY_TIMEOUT = 5000; + var LOW_PRIORITY_TIMEOUT = 10000; // Never times out + + var IDLE_PRIORITY_TIMEOUT = maxSigned31BitInt; // Tasks are stored on a min heap + + var taskQueue = []; + var timerQueue = []; // Incrementing id counter. Used to maintain insertion order. + + var taskIdCounter = 1; // Pausing the scheduler is useful for debugging. + var currentTask = null; + var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrancy. + + var isPerformingWork = false; + var isHostCallbackScheduled = false; + var isHostTimeoutScheduled = false; + + function advanceTimers(currentTime) { + // Check for tasks that are no longer delayed and add them to the queue. + var timer = peek(timerQueue); + + while (timer !== null) { + if (timer.callback === null) { + // Timer was cancelled. + pop(timerQueue); + } else if (timer.startTime <= currentTime) { + // Timer fired. Transfer to the task queue. + pop(timerQueue); + timer.sortIndex = timer.expirationTime; + push(taskQueue, timer); + } else { + // Remaining timers are pending. + return; + } + + timer = peek(timerQueue); + } + } + + function handleTimeout(currentTime) { + isHostTimeoutScheduled = false; + advanceTimers(currentTime); + + if (!isHostCallbackScheduled) { + if (peek(taskQueue) !== null) { + isHostCallbackScheduled = true; + requestHostCallback(flushWork); + } else { + var firstTimer = peek(timerQueue); + + if (firstTimer !== null) { + requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); + } + } + } + } + + function flushWork(hasTimeRemaining, initialTime) { + + + isHostCallbackScheduled = false; + + if (isHostTimeoutScheduled) { + // We scheduled a timeout but it's no longer needed. Cancel it. + isHostTimeoutScheduled = false; + cancelHostTimeout(); + } + + isPerformingWork = true; + var previousPriorityLevel = currentPriorityLevel; + + try { + if (enableProfiling) { + try { + return workLoop(hasTimeRemaining, initialTime); + } catch (error) { + if (currentTask !== null) { + var currentTime = getCurrentTime(); + markTaskErrored(currentTask, currentTime); + currentTask.isQueued = false; + } + + throw error; + } + } else { + // No catch in prod code path. + return workLoop(hasTimeRemaining, initialTime); + } + } finally { + currentTask = null; + currentPriorityLevel = previousPriorityLevel; + isPerformingWork = false; + } + } + + function workLoop(hasTimeRemaining, initialTime) { + var currentTime = initialTime; + advanceTimers(currentTime); + currentTask = peek(taskQueue); + + while (currentTask !== null && !(enableSchedulerDebugging )) { + if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) { + // This currentTask hasn't expired, and we've reached the deadline. + break; + } + + var callback = currentTask.callback; + + if (typeof callback === 'function') { + currentTask.callback = null; + currentPriorityLevel = currentTask.priorityLevel; + var didUserCallbackTimeout = currentTask.expirationTime <= currentTime; + + var continuationCallback = callback(didUserCallbackTimeout); + currentTime = getCurrentTime(); + + if (typeof continuationCallback === 'function') { + currentTask.callback = continuationCallback; + } else { + + if (currentTask === peek(taskQueue)) { + pop(taskQueue); + } + } + + advanceTimers(currentTime); + } else { + pop(taskQueue); + } + + currentTask = peek(taskQueue); + } // Return whether there's additional work + + + if (currentTask !== null) { + return true; + } else { + var firstTimer = peek(timerQueue); + + if (firstTimer !== null) { + requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); + } + + return false; + } + } + + function unstable_runWithPriority(priorityLevel, eventHandler) { + switch (priorityLevel) { + case ImmediatePriority: + case UserBlockingPriority: + case NormalPriority: + case LowPriority: + case IdlePriority: + break; + + default: + priorityLevel = NormalPriority; + } + + var previousPriorityLevel = currentPriorityLevel; + currentPriorityLevel = priorityLevel; + + try { + return eventHandler(); + } finally { + currentPriorityLevel = previousPriorityLevel; + } + } + + function unstable_next(eventHandler) { + var priorityLevel; + + switch (currentPriorityLevel) { + case ImmediatePriority: + case UserBlockingPriority: + case NormalPriority: + // Shift down to normal priority + priorityLevel = NormalPriority; + break; + + default: + // Anything lower than normal priority should remain at the current level. + priorityLevel = currentPriorityLevel; + break; + } + + var previousPriorityLevel = currentPriorityLevel; + currentPriorityLevel = priorityLevel; + + try { + return eventHandler(); + } finally { + currentPriorityLevel = previousPriorityLevel; + } + } + + function unstable_wrapCallback(callback) { + var parentPriorityLevel = currentPriorityLevel; + return function () { + // This is a fork of runWithPriority, inlined for performance. + var previousPriorityLevel = currentPriorityLevel; + currentPriorityLevel = parentPriorityLevel; + + try { + return callback.apply(this, arguments); + } finally { + currentPriorityLevel = previousPriorityLevel; + } + }; + } + + function unstable_scheduleCallback(priorityLevel, callback, options) { + var currentTime = getCurrentTime(); + var startTime; + + if (typeof options === 'object' && options !== null) { + var delay = options.delay; + + if (typeof delay === 'number' && delay > 0) { + startTime = currentTime + delay; + } else { + startTime = currentTime; + } + } else { + startTime = currentTime; + } + + var timeout; + + switch (priorityLevel) { + case ImmediatePriority: + timeout = IMMEDIATE_PRIORITY_TIMEOUT; + break; + + case UserBlockingPriority: + timeout = USER_BLOCKING_PRIORITY_TIMEOUT; + break; + + case IdlePriority: + timeout = IDLE_PRIORITY_TIMEOUT; + break; + + case LowPriority: + timeout = LOW_PRIORITY_TIMEOUT; + break; + + case NormalPriority: + default: + timeout = NORMAL_PRIORITY_TIMEOUT; + break; + } + + var expirationTime = startTime + timeout; + var newTask = { + id: taskIdCounter++, + callback: callback, + priorityLevel: priorityLevel, + startTime: startTime, + expirationTime: expirationTime, + sortIndex: -1 + }; + + if (startTime > currentTime) { + // This is a delayed task. + newTask.sortIndex = startTime; + push(timerQueue, newTask); + + if (peek(taskQueue) === null && newTask === peek(timerQueue)) { + // All tasks are delayed, and this is the task with the earliest delay. + if (isHostTimeoutScheduled) { + // Cancel an existing timeout. + cancelHostTimeout(); + } else { + isHostTimeoutScheduled = true; + } // Schedule a timeout. + + + requestHostTimeout(handleTimeout, startTime - currentTime); + } + } else { + newTask.sortIndex = expirationTime; + push(taskQueue, newTask); + // wait until the next time we yield. + + + if (!isHostCallbackScheduled && !isPerformingWork) { + isHostCallbackScheduled = true; + requestHostCallback(flushWork); + } + } + + return newTask; + } + + function unstable_pauseExecution() { + } + + function unstable_continueExecution() { + + if (!isHostCallbackScheduled && !isPerformingWork) { + isHostCallbackScheduled = true; + requestHostCallback(flushWork); + } + } + + function unstable_getFirstCallbackNode() { + return peek(taskQueue); + } + + function unstable_cancelCallback(task) { + // remove from the queue because you can't remove arbitrary nodes from an + // array based heap, only the first one.) + + + task.callback = null; + } + + function unstable_getCurrentPriorityLevel() { + return currentPriorityLevel; + } + + var unstable_requestPaint = requestPaint; + var unstable_Profiling = null; + + + + var Scheduler = /*#__PURE__*/Object.freeze({ + __proto__: null, + unstable_ImmediatePriority: ImmediatePriority, + unstable_UserBlockingPriority: UserBlockingPriority, + unstable_NormalPriority: NormalPriority, + unstable_IdlePriority: IdlePriority, + unstable_LowPriority: LowPriority, + unstable_runWithPriority: unstable_runWithPriority, + unstable_next: unstable_next, + unstable_scheduleCallback: unstable_scheduleCallback, + unstable_cancelCallback: unstable_cancelCallback, + unstable_wrapCallback: unstable_wrapCallback, + unstable_getCurrentPriorityLevel: unstable_getCurrentPriorityLevel, + get unstable_shouldYield () { return shouldYieldToHost; }, + unstable_requestPaint: unstable_requestPaint, + unstable_continueExecution: unstable_continueExecution, + unstable_pauseExecution: unstable_pauseExecution, + unstable_getFirstCallbackNode: unstable_getFirstCallbackNode, + get unstable_now () { return getCurrentTime; }, + get unstable_forceFrameRate () { return forceFrameRate; }, + unstable_Profiling: unstable_Profiling + }); + + var DEFAULT_THREAD_ID = 0; // Counters used to generate unique IDs. + + var interactionIDCounter = 0; + var threadIDCounter = 0; // Set of currently traced interactions. + // Interactions "stack"– + // Meaning that newly traced interactions are appended to the previously active set. + // When an interaction goes out of scope, the previous set (if any) is restored. + + var interactionsRef = null; // Listener(s) to notify when interactions begin and end. + + var subscriberRef = null; + + { + interactionsRef = { + current: new Set() + }; + subscriberRef = { + current: null + }; + } + function unstable_clear(callback) { + + var prevInteractions = interactionsRef.current; + interactionsRef.current = new Set(); + + try { + return callback(); + } finally { + interactionsRef.current = prevInteractions; + } + } + function unstable_getCurrent() { + { + return interactionsRef.current; + } + } + function unstable_getThreadID() { + return ++threadIDCounter; + } + function unstable_trace(name, timestamp, callback) { + var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID; + + var interaction = { + __count: 1, + id: interactionIDCounter++, + name: name, + timestamp: timestamp + }; + var prevInteractions = interactionsRef.current; // Traced interactions should stack/accumulate. + // To do that, clone the current interactions. + // The previous set will be restored upon completion. + + var interactions = new Set(prevInteractions); + interactions.add(interaction); + interactionsRef.current = interactions; + var subscriber = subscriberRef.current; + var returnValue; + + try { + if (subscriber !== null) { + subscriber.onInteractionTraced(interaction); + } + } finally { + try { + if (subscriber !== null) { + subscriber.onWorkStarted(interactions, threadID); + } + } finally { + try { + returnValue = callback(); + } finally { + interactionsRef.current = prevInteractions; + + try { + if (subscriber !== null) { + subscriber.onWorkStopped(interactions, threadID); + } + } finally { + interaction.__count--; // If no async work was scheduled for this interaction, + // Notify subscribers that it's completed. + + if (subscriber !== null && interaction.__count === 0) { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } + } + } + } + } + + return returnValue; + } + function unstable_wrap(callback) { + var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID; + + var wrappedInteractions = interactionsRef.current; + var subscriber = subscriberRef.current; + + if (subscriber !== null) { + subscriber.onWorkScheduled(wrappedInteractions, threadID); + } // Update the pending async work count for the current interactions. + // Update after calling subscribers in case of error. + + + wrappedInteractions.forEach(function (interaction) { + interaction.__count++; + }); + var hasRun = false; + + function wrapped() { + var prevInteractions = interactionsRef.current; + interactionsRef.current = wrappedInteractions; + subscriber = subscriberRef.current; + + try { + var returnValue; + + try { + if (subscriber !== null) { + subscriber.onWorkStarted(wrappedInteractions, threadID); + } + } finally { + try { + returnValue = callback.apply(undefined, arguments); + } finally { + interactionsRef.current = prevInteractions; + + if (subscriber !== null) { + subscriber.onWorkStopped(wrappedInteractions, threadID); + } + } + } + + return returnValue; + } finally { + if (!hasRun) { + // We only expect a wrapped function to be executed once, + // But in the event that it's executed more than once– + // Only decrement the outstanding interaction counts once. + hasRun = true; // Update pending async counts for all wrapped interactions. + // If this was the last scheduled async work for any of them, + // Mark them as completed. + + wrappedInteractions.forEach(function (interaction) { + interaction.__count--; + + if (subscriber !== null && interaction.__count === 0) { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } + }); + } + } + } + + wrapped.cancel = function cancel() { + subscriber = subscriberRef.current; + + try { + if (subscriber !== null) { + subscriber.onWorkCanceled(wrappedInteractions, threadID); + } + } finally { + // Update pending async counts for all wrapped interactions. + // If this was the last scheduled async work for any of them, + // Mark them as completed. + wrappedInteractions.forEach(function (interaction) { + interaction.__count--; + + if (subscriber && interaction.__count === 0) { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } + }); + } + }; + + return wrapped; + } + + var subscribers = null; + + { + subscribers = new Set(); + } + + function unstable_subscribe(subscriber) { + { + subscribers.add(subscriber); + + if (subscribers.size === 1) { + subscriberRef.current = { + onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted, + onInteractionTraced: onInteractionTraced, + onWorkCanceled: onWorkCanceled, + onWorkScheduled: onWorkScheduled, + onWorkStarted: onWorkStarted, + onWorkStopped: onWorkStopped + }; + } + } + } + function unstable_unsubscribe(subscriber) { + { + subscribers.delete(subscriber); + + if (subscribers.size === 0) { + subscriberRef.current = null; + } + } + } + + function onInteractionTraced(interaction) { + var didCatchError = false; + var caughtError = null; + subscribers.forEach(function (subscriber) { + try { + subscriber.onInteractionTraced(interaction); + } catch (error) { + if (!didCatchError) { + didCatchError = true; + caughtError = error; + } + } + }); + + if (didCatchError) { + throw caughtError; + } + } + + function onInteractionScheduledWorkCompleted(interaction) { + var didCatchError = false; + var caughtError = null; + subscribers.forEach(function (subscriber) { + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + if (!didCatchError) { + didCatchError = true; + caughtError = error; + } + } + }); + + if (didCatchError) { + throw caughtError; + } + } + + function onWorkScheduled(interactions, threadID) { + var didCatchError = false; + var caughtError = null; + subscribers.forEach(function (subscriber) { + try { + subscriber.onWorkScheduled(interactions, threadID); + } catch (error) { + if (!didCatchError) { + didCatchError = true; + caughtError = error; + } + } + }); + + if (didCatchError) { + throw caughtError; + } + } + + function onWorkStarted(interactions, threadID) { + var didCatchError = false; + var caughtError = null; + subscribers.forEach(function (subscriber) { + try { + subscriber.onWorkStarted(interactions, threadID); + } catch (error) { + if (!didCatchError) { + didCatchError = true; + caughtError = error; + } + } + }); + + if (didCatchError) { + throw caughtError; + } + } + + function onWorkStopped(interactions, threadID) { + var didCatchError = false; + var caughtError = null; + subscribers.forEach(function (subscriber) { + try { + subscriber.onWorkStopped(interactions, threadID); + } catch (error) { + if (!didCatchError) { + didCatchError = true; + caughtError = error; + } + } + }); + + if (didCatchError) { + throw caughtError; + } + } + + function onWorkCanceled(interactions, threadID) { + var didCatchError = false; + var caughtError = null; + subscribers.forEach(function (subscriber) { + try { + subscriber.onWorkCanceled(interactions, threadID); + } catch (error) { + if (!didCatchError) { + didCatchError = true; + caughtError = error; + } + } + }); + + if (didCatchError) { + throw caughtError; + } + } + + + + var SchedulerTracing = /*#__PURE__*/Object.freeze({ + __proto__: null, + get __interactionsRef () { return interactionsRef; }, + get __subscriberRef () { return subscriberRef; }, + unstable_clear: unstable_clear, + unstable_getCurrent: unstable_getCurrent, + unstable_getThreadID: unstable_getThreadID, + unstable_trace: unstable_trace, + unstable_wrap: unstable_wrap, + unstable_subscribe: unstable_subscribe, + unstable_unsubscribe: unstable_unsubscribe + }); + + var ReactSharedInternals$1 = { + ReactCurrentDispatcher: ReactCurrentDispatcher, + ReactCurrentOwner: ReactCurrentOwner, + IsSomeRendererActing: IsSomeRendererActing, + ReactCurrentBatchConfig: ReactCurrentBatchConfig, + // Used by renderers to avoid bundling object-assign twice in UMD bundles: + assign: assign, + // Re-export the schedule API(s) for UMD bundles. + // This avoids introducing a dependency on a new UMD global in a minor update, + // Since that would be a breaking change (e.g. for all existing CodeSandboxes). + // This re-export is only required for UMD bundles; + // CJS bundles use the shared NPM package. + Scheduler: Scheduler, + SchedulerTracing: SchedulerTracing + }; + + { + ReactSharedInternals$1.ReactDebugCurrentFrame = ReactDebugCurrentFrame; + } + + { + + try { + var frozenObject = Object.freeze({}); + /* eslint-disable no-new */ + + new Map([[frozenObject, null]]); + new Set([frozenObject]); + /* eslint-enable no-new */ + } catch (e) { + } + } + + var createElement$1 = createElementWithValidation ; + var cloneElement$1 = cloneElementWithValidation ; + var createFactory = createFactoryWithValidation ; + var Children = { + map: mapChildren, + forEach: forEachChildren, + count: countChildren, + toArray: toArray, + only: onlyChild + }; + + exports.Children = Children; + exports.Component = Component; + exports.PureComponent = PureComponent; + exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals$1; + exports.cloneElement = cloneElement$1; + exports.createContext = createContext; + exports.createElement = createElement$1; + exports.createFactory = createFactory; + exports.createRef = createRef; + exports.forwardRef = forwardRef; + exports.isValidElement = isValidElement; + exports.lazy = lazy; + exports.memo = memo; + exports.useCallback = useCallback; + exports.useContext = useContext; + exports.useDebugValue = useDebugValue; + exports.useEffect = useEffect; + exports.useImperativeHandle = useImperativeHandle; + exports.useLayoutEffect = useLayoutEffect; + exports.useMemo = useMemo; + exports.useReducer = useReducer; + exports.useRef = useRef; + exports.useState = useState; + exports.version = ReactVersion; + +}))); diff --git a/package-lock.json b/package-lock.json index ec188568..538f4a20 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,18 @@ { "name": "mmgis", - "version": "2.7.0", + "version": "2.8.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mmgis", - "version": "2.7.0", + "version": "2.8.0", "dependencies": { "@babel/core": "7.9.0", "@eonasdan/tempus-dominus": "^6.2.6", "@popperjs/core": "^2.11.6", "@svgr/webpack": "4.3.3", + "@terraformer/wkt": "^2.2.0", "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.5.0", "@testing-library/user-event": "^7.2.1", @@ -30,6 +31,7 @@ "chart.js": "^3.6.0", "chartjs-plugin-zoom": "^1.2.1", "compression": "^1.7.4", + "connect-pg-simple": "^8.0.0", "cookie-parser": "^1.4.5", "cors": "^2.8.5", "cross-env": "^7.0.2", @@ -49,11 +51,12 @@ "eslint-plugin-react-hooks": "^1.6.1", "express": "^4.16.3", "express-rate-limit": "^5.1.3", - "express-session": "^1.17.1", + "express-session": "^1.17.3", "file-loader": "4.3.0", "file-saver": "^2.0.2", "flat": "^5.0.2", "fs-extra": "^8.1.0", + "geojson-validation": "^1.0.2", "hammerjs": "^2.0.8", "helmet": "^4.1.1", "html-webpack-plugin": "4.0.0-beta.11", @@ -68,6 +71,7 @@ "jquery": "^3.5.1", "lithosphere": "^1.5.4", "mark.js": "^8.11.1", + "materialize-css": "^1.0.0", "memorystore": "^1.6.2", "mini-css-extract-plugin": "0.9.0", "nipplejs": "^0.8.5", @@ -82,6 +86,7 @@ "postcss-normalize": "8.0.1", "postcss-preset-env": "6.7.0", "postcss-safe-parser": "4.0.1", + "proj4": "^2.8.1", "pug": "^3.0.1", "react": "^16.13.1", "react-app-polyfill": "^1.0.6", @@ -93,6 +98,7 @@ "sass-loader": "8.0.2", "semver": "6.3.0", "sequelize": "^5.21.2", + "sharp": "^0.31.2", "showdown": "^2.1.0", "sortablejs": "^1.15.0", "string-replace-loader": "^2.3.0", @@ -104,12 +110,14 @@ "turf": "^3.0.14", "url-loader": "2.3.0", "util": "^0.12.3", + "uuid": "^9.0.0", "webpack": "4.42.0", "webpack-dev-server": "^3.11.0", "webpack-manifest-plugin": "2.2.0", "winston": "^3.3.4", "workbox-webpack-plugin": "4.3.1", - "ws": "^8.8.1" + "ws": "^8.8.1", + "xml2js": "^0.4.23" }, "devDependencies": { "@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6", @@ -2085,6 +2093,11 @@ "node": ">=8" } }, + "node_modules/@terraformer/wkt": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@terraformer/wkt/-/wkt-2.2.0.tgz", + "integrity": "sha512-i33rTSqPtmO4sRdeznI0IEc9gpIZZIXN5kGhZ4rTwVtDccDKL3h4uia9cmWdRJlJMlG4Febxatw5b9ylI5YYuA==" + }, "node_modules/@testing-library/dom": { "version": "6.16.0", "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-6.16.0.tgz", @@ -3940,6 +3953,16 @@ "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==" }, + "node_modules/@types/pg": { + "version": "8.6.5", + "resolved": "https://registry.npmjs.org/@types/pg/-/pg-8.6.5.tgz", + "integrity": "sha512-tOkGtAqRVkHa/PVZicq67zuujI4Oorfglsr2IbKofDwBSysnaqSx7W1mDqFqdkGE6Fbgh+PZAl0r/BWON/mozw==", + "dependencies": { + "@types/node": "*", + "pg-protocol": "*", + "pg-types": "^2.2.0" + } + }, "node_modules/@types/prop-types": { "version": "15.7.3", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz", @@ -4404,12 +4427,12 @@ "integrity": "sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q==" }, "node_modules/accepts": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", - "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", "dependencies": { - "mime-types": "~2.1.24", - "negotiator": "0.6.2" + "mime-types": "~2.1.34", + "negotiator": "0.6.3" }, "engines": { "node": ">= 0.6" @@ -4483,9 +4506,9 @@ } }, "node_modules/adjust-sourcemap-loader/node_modules/loader-utils": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", - "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.4.tgz", + "integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==", "dependencies": { "big.js": "^5.2.2", "emojis-list": "^3.0.0", @@ -5539,6 +5562,39 @@ "resolved": "https://registry.npmjs.org/bit-twiddle/-/bit-twiddle-1.0.2.tgz", "integrity": "sha1-DGwfq+KyPRcXPZpht7cJPrnhdp4=" }, + "node_modules/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "dependencies": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "node_modules/bl/node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, "node_modules/bluebird": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", @@ -5550,29 +5606,32 @@ "integrity": "sha512-GkTiFpjFtUzU9CbMeJ5iazkCzGL3jrhzerzZIuqLABjbwRaFt33I9tUdSNryIptM+RxDet6OKm2WnLXzW51KsQ==" }, "node_modules/body-parser": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", - "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", + "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", "dependencies": { - "bytes": "3.1.0", + "bytes": "3.1.2", "content-type": "~1.0.4", "debug": "2.6.9", - "depd": "~1.1.2", - "http-errors": "1.7.2", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", "iconv-lite": "0.4.24", - "on-finished": "~2.3.0", - "qs": "6.7.0", - "raw-body": "2.4.0", - "type-is": "~1.6.17" + "on-finished": "2.4.1", + "qs": "6.11.0", + "raw-body": "2.5.1", + "type-is": "~1.6.18", + "unpipe": "1.0.0" }, "engines": { - "node": ">= 0.8" + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" } }, "node_modules/body-parser/node_modules/bytes": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", - "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", "engines": { "node": ">= 0.8" } @@ -5585,10 +5644,18 @@ "ms": "2.0.0" } }, + "node_modules/body-parser/node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/body-parser/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, "node_modules/bonjour": { "version": "3.5.0", @@ -6579,6 +6646,43 @@ "node": ">=0.8" } }, + "node_modules/connect-pg-simple": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/connect-pg-simple/-/connect-pg-simple-8.0.0.tgz", + "integrity": "sha512-pBDa23RA1LCkwvRrPOh5xevB+Nknh1UDuhFOKsUrkUDodYqfiQT18P2qXc4lk/TqCMB6hI06B8KNncHh91bZMQ==", + "dependencies": { + "@types/pg": "^8.6.5", + "pg": "^8.8.0" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + } + }, + "node_modules/connect-pg-simple/node_modules/pg": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/pg/-/pg-8.8.0.tgz", + "integrity": "sha512-UXYN0ziKj+AeNNP7VDMwrehpACThH7LUl/p8TDFpEUuSejCUIwGSfxpHsPvtM6/WXFy6SU4E5RG4IJV/TZAGjw==", + "dependencies": { + "buffer-writer": "2.0.0", + "packet-reader": "1.0.0", + "pg-connection-string": "^2.5.0", + "pg-pool": "^3.5.2", + "pg-protocol": "^1.5.0", + "pg-types": "^2.1.0", + "pgpass": "1.x" + }, + "engines": { + "node": ">= 8.0.0" + }, + "peerDependencies": { + "pg-native": ">=3.0.1" + }, + "peerDependenciesMeta": { + "pg-native": { + "optional": true + } + } + }, "node_modules/console-browserify": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.2.0.tgz", @@ -6607,20 +6711,39 @@ } }, "node_modules/content-disposition": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", - "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", "dependencies": { - "safe-buffer": "5.1.2" + "safe-buffer": "5.2.1" }, "engines": { "node": ">= 0.6" } }, + "node_modules/content-disposition/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/content-type": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", - "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", "engines": { "node": ">= 0.6" } @@ -7668,13 +7791,27 @@ } }, "node_modules/decode-uri-component": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", - "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz", + "integrity": "sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==", "engines": { "node": ">=0.10" } }, + "node_modules/decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "dependencies": { + "mimic-response": "^3.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/deep-equal": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.1.1.tgz", @@ -7691,6 +7828,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", + "engines": { + "node": ">=4.0.0" + } + }, "node_modules/deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", @@ -7869,9 +8014,21 @@ } }, "node_modules/destroy": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", - "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/detect-libc": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.1.tgz", + "integrity": "sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w==", + "engines": { + "node": ">=8" + } }, "node_modules/detect-newline": { "version": "2.1.0", @@ -8193,7 +8350,7 @@ "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { "version": "1.3.743", @@ -8240,7 +8397,7 @@ "node_modules/encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", "engines": { "node": ">= 0.8" } @@ -8369,13 +8526,17 @@ } }, "node_modules/es5-ext": { - "version": "0.10.53", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.53.tgz", - "integrity": "sha512-Xs2Stw6NiNHWypzRTY1MtaG/uJlwCk8kH81920ma8mvN8Xq1gsfhZvpkImLQArw8AHnv8MT2I45J3c0R8slE+Q==", + "version": "0.10.62", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", + "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", + "hasInstallScript": true, "dependencies": { - "es6-iterator": "~2.0.3", - "es6-symbol": "~3.1.3", - "next-tick": "~1.0.0" + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.3", + "next-tick": "^1.1.0" + }, + "engines": { + "node": ">=0.10" } }, "node_modules/es6-iterator": { @@ -9104,7 +9265,7 @@ "node_modules/etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", "engines": { "node": ">= 0.6" } @@ -9221,6 +9382,14 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, + "node_modules/expand-template": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", + "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==", + "engines": { + "node": ">=6" + } + }, "node_modules/expect": { "version": "24.9.0", "resolved": "https://registry.npmjs.org/expect/-/expect-24.9.0.tgz", @@ -9238,37 +9407,38 @@ } }, "node_modules/express": { - "version": "4.17.1", - "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", - "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", + "version": "4.18.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", + "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", "dependencies": { - "accepts": "~1.3.7", + "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.19.0", - "content-disposition": "0.5.3", + "body-parser": "1.20.1", + "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.4.0", + "cookie": "0.5.0", "cookie-signature": "1.0.6", "debug": "2.6.9", - "depd": "~1.1.2", + "depd": "2.0.0", "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "etag": "~1.8.1", - "finalhandler": "~1.1.2", + "finalhandler": "1.2.0", "fresh": "0.5.2", + "http-errors": "2.0.0", "merge-descriptors": "1.0.1", "methods": "~1.1.2", - "on-finished": "~2.3.0", + "on-finished": "2.4.1", "parseurl": "~1.3.3", "path-to-regexp": "0.1.7", - "proxy-addr": "~2.0.5", - "qs": "6.7.0", + "proxy-addr": "~2.0.7", + "qs": "6.11.0", "range-parser": "~1.2.1", - "safe-buffer": "5.1.2", - "send": "0.17.1", - "serve-static": "1.14.1", - "setprototypeof": "1.1.1", - "statuses": "~1.5.0", + "safe-buffer": "5.2.1", + "send": "0.18.0", + "serve-static": "1.15.0", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", "type-is": "~1.6.18", "utils-merge": "1.0.1", "vary": "~1.1.2" @@ -9283,23 +9453,31 @@ "integrity": "sha512-cjQH+oDrEPXxc569XvxhHC6QXqJiuBT6BhZ70X3bdAImcnHnTNMVuMAJaT0TXPoRiEErUrVPRcOTpZpM36VbOQ==" }, "node_modules/express-session": { - "version": "1.17.1", - "resolved": "https://registry.npmjs.org/express-session/-/express-session-1.17.1.tgz", - "integrity": "sha512-UbHwgqjxQZJiWRTMyhvWGvjBQduGCSBDhhZXYenziMFjxst5rMV+aJZ6hKPHZnPyHGsrqRICxtX8jtEbm/z36Q==", + "version": "1.17.3", + "resolved": "https://registry.npmjs.org/express-session/-/express-session-1.17.3.tgz", + "integrity": "sha512-4+otWXlShYlG1Ma+2Jnn+xgKUZTMJ5QD3YvfilX3AcocOAbIkVylSWEklzALe/+Pu4qV6TYBj5GwOBFfdKqLBw==", "dependencies": { - "cookie": "0.4.0", + "cookie": "0.4.2", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "~2.0.0", "on-headers": "~1.0.2", "parseurl": "~1.3.3", - "safe-buffer": "5.2.0", + "safe-buffer": "5.2.1", "uid-safe": "~2.1.5" }, "engines": { "node": ">= 0.8.0" } }, + "node_modules/express-session/node_modules/cookie": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/express-session/node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -9319,12 +9497,34 @@ "node_modules/express-session/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, "node_modules/express-session/node_modules/safe-buffer": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", - "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==" + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/express/node_modules/cookie": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", + "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "engines": { + "node": ">= 0.6" + } }, "node_modules/express/node_modules/debug": { "version": "2.6.9", @@ -9334,11 +9534,46 @@ "ms": "2.0.0" } }, + "node_modules/express/node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/express/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, + "node_modules/express/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/express/node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/ext": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/ext/-/ext-1.4.0.tgz", @@ -9690,16 +9925,16 @@ } }, "node_modules/finalhandler": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", - "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", + "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", "dependencies": { "debug": "2.6.9", "encodeurl": "~1.0.2", "escape-html": "~1.0.3", - "on-finished": "~2.3.0", + "on-finished": "2.4.1", "parseurl": "~1.3.3", - "statuses": "~1.5.0", + "statuses": "2.0.1", "unpipe": "~1.0.0" }, "engines": { @@ -9717,7 +9952,15 @@ "node_modules/finalhandler/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, + "node_modules/finalhandler/node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "engines": { + "node": ">= 0.8" + } }, "node_modules/find-cache-dir": { "version": "2.1.0", @@ -9902,9 +10145,9 @@ } }, "node_modules/forwarded": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", - "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", "engines": { "node": ">= 0.6" } @@ -9923,7 +10166,7 @@ "node_modules/fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", "engines": { "node": ">= 0.6" } @@ -9959,6 +10202,11 @@ "safe-buffer": "~5.1.0" } }, + "node_modules/fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, "node_modules/fs-extra": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", @@ -10100,6 +10348,14 @@ "rbush": "^3.0.1" } }, + "node_modules/geojson-validation": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/geojson-validation/-/geojson-validation-1.0.2.tgz", + "integrity": "sha512-K5jrJ4wFvORn2pRKeg181LL0QPYuEKn2KHPvfH1m2QtFlAXFLKdseqt0XwBM3ELOY7kNM1fglRQ6ZwUQZ5S00A==", + "bin": { + "gjv": "bin/gjv" + } + }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -10161,6 +10417,11 @@ "assert-plus": "^1.0.0" } }, + "node_modules/github-from-package": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", + "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==" + }, "node_modules/glob": { "version": "7.1.6", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", @@ -10749,24 +11010,35 @@ "integrity": "sha1-+nFolEq5pRnTN8sL7HKE3D5yPYc=" }, "node_modules/http-errors": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", - "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", "dependencies": { - "depd": "~1.1.2", - "inherits": "2.0.3", - "setprototypeof": "1.1.1", - "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.0" + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" }, "engines": { - "node": ">= 0.6" + "node": ">= 0.8" } }, - "node_modules/http-errors/node_modules/inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + "node_modules/http-errors/node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/http-errors/node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "engines": { + "node": ">= 0.8" + } }, "node_modules/http-parser-js": { "version": "0.5.3", @@ -11287,9 +11559,9 @@ } }, "node_modules/is-core-module": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.2.0.tgz", - "integrity": "sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ==", + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz", + "integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==", "dependencies": { "has": "^1.0.3" }, @@ -12526,12 +12798,9 @@ "integrity": "sha512-c7/8mbUsKigAbLkD5B010BK4D9LZm7A1pNItkEwiUZRpIN66exu/e7YQWysGun+TRKaJp8MhemM+VkfWv42aCA==" }, "node_modules/json5": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.3.tgz", - "integrity": "sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA==", - "dependencies": { - "minimist": "^1.2.5" - }, + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "bin": { "json5": "lib/cli.js" }, @@ -12780,9 +13049,9 @@ } }, "node_modules/loader-utils": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.0.tgz", - "integrity": "sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.2.tgz", + "integrity": "sha512-I5d00Pd/jwMD2QCduo657+YM/6L3KZu++pmX9VFncxaxvHcru9jx1lBaFft+r4Mt2jK0Yhp41XlRAihzPxHNCg==", "dependencies": { "big.js": "^5.2.2", "emojis-list": "^3.0.0", @@ -12793,9 +13062,9 @@ } }, "node_modules/loader-utils/node_modules/json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", "dependencies": { "minimist": "^1.2.0" }, @@ -12986,6 +13255,11 @@ "resolved": "https://registry.npmjs.org/mark.js/-/mark.js-8.11.1.tgz", "integrity": "sha1-GA8fnr74sOY45BZq1S24eb6y/8U=" }, + "node_modules/materialize-css": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/materialize-css/-/materialize-css-1.0.0.tgz", + "integrity": "sha512-4/oecXl8y/1i8RDZvyvwAICyqwNoKU4or5uf8uoAd74k76KzZ0Llym4zhJ5lLNUskcqjO0AuMcvNyDkpz8Z6zw==" + }, "node_modules/md5.js": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", @@ -13004,7 +13278,7 @@ "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", "engines": { "node": ">= 0.6" } @@ -13041,9 +13315,9 @@ } }, "node_modules/memorystore": { - "version": "1.6.4", - "resolved": "https://registry.npmjs.org/memorystore/-/memorystore-1.6.4.tgz", - "integrity": "sha512-51j4kUedbqkWGby44hAhf5f/hj8GOvHoLX00/YHURBNxOMf5k8JbPuGfmeNpZEXhc3vrmfnFben4+rOOx3HjEQ==", + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/memorystore/-/memorystore-1.6.7.tgz", + "integrity": "sha512-OZnmNY/NDrKohPQ+hxp0muBcBKrzKNtHr55DbqSx9hLsYVNnomSAMRAtI7R64t3gf3ID7tHQA7mG4oL3Hu9hdw==", "dependencies": { "debug": "^4.3.0", "lru-cache": "^4.0.3" @@ -13064,7 +13338,7 @@ "node_modules/memorystore/node_modules/yallist": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" + "integrity": "sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==" }, "node_modules/merge-deep": { "version": "3.0.3", @@ -13175,19 +13449,19 @@ } }, "node_modules/mime-db": { - "version": "1.45.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.45.0.tgz", - "integrity": "sha512-CkqLUxUk15hofLoLyljJSrukZi8mAtgd+yE5uO4tqRZsdsAJKv0O+rFMhVDRJgozy+yG6md5KwuXhD4ocIoP+w==", + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", "engines": { "node": ">= 0.6" } }, "node_modules/mime-types": { - "version": "2.1.28", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.28.tgz", - "integrity": "sha512-0TO2yJ5YHYr7M2zzT7gDU1tbwHxEUWBCLt0lscSNpcdAfFyJOVEpRYNS7EXVcTLNj/25QO8gulHC5JtTzSE2UQ==", + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", "dependencies": { - "mime-db": "1.45.0" + "mime-db": "1.52.0" }, "engines": { "node": ">= 0.6" @@ -13201,6 +13475,17 @@ "node": ">=6" } }, + "node_modules/mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/min-indent": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", @@ -13395,6 +13680,11 @@ "mkdirp": "bin/cmd.js" } }, + "node_modules/mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" + }, "node_modules/moment": { "version": "2.29.4", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", @@ -13404,11 +13694,11 @@ } }, "node_modules/moment-timezone": { - "version": "0.5.32", - "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.32.tgz", - "integrity": "sha512-Z8QNyuQHQAmWucp8Knmgei8YNo28aLjJq6Ma+jy1ZSpSk5nyfRT8xgUbSQvD2+2UajISfenndwvFuH3NGS+nvA==", + "version": "0.5.43", + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.43.tgz", + "integrity": "sha512-72j3aNyuIsDxdF1i7CEgV2FfxM1r6aaqJyLB2vwb33mXYyoyLly+F1zbWqhA3/bVIoJ4szlUoMbUnVdid32NUQ==", "dependencies": { - "moment": ">= 2.9.0" + "moment": "^2.29.4" }, "engines": { "node": "*" @@ -13506,15 +13796,20 @@ "node": ">=0.10.0" } }, + "node_modules/napi-build-utils": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", + "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==" + }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=" }, "node_modules/negotiator": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", - "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==", + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", "engines": { "node": ">= 0.6" } @@ -13525,9 +13820,9 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" }, "node_modules/next-tick": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", - "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", + "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" }, "node_modules/nice-try": { "version": "1.0.5", @@ -13553,6 +13848,36 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz", "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==" }, + "node_modules/node-abi": { + "version": "3.30.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.30.0.tgz", + "integrity": "sha512-qWO5l3SCqbwQavymOmtTVuCWZE23++S+rxyoHjXqUmPyzRcaoI4lA2gO55/drddGnedAyjA7sk76SfQ5lfUMnw==", + "dependencies": { + "semver": "^7.3.5" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/node-abi/node_modules/semver": { + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/node-addon-api": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-5.0.0.tgz", + "integrity": "sha512-CvkDw2OEnme7ybCykJpVcKH+uAOLV2qLqiyla128dN9TkEWfrYmxG6C2boDe5KcNQqZF3orkqzGgOMvZ/JNekA==" + }, "node_modules/node-fetch": { "version": "2.6.7", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", @@ -13986,9 +14311,9 @@ "integrity": "sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==" }, "node_modules/on-finished": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", "dependencies": { "ee-first": "1.1.1" }, @@ -14446,9 +14771,9 @@ } }, "node_modules/pg-connection-string": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.4.0.tgz", - "integrity": "sha512-3iBXuv7XKvxeMrIgym7njT+HlZkwZqqGX4Bu9cci8xHZNT+Um1gWKqCsAzcC0d95rcKMU5WBg6YRUcHyV0HZKQ==" + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.5.0.tgz", + "integrity": "sha512-r5o/V/ORTA6TmUnyWZR9nCj1klXCO2CEKNRlVuJptZe85QuhFayC7WeMic7ndayT5IRIR0S0xFxFi2ousartlQ==" }, "node_modules/pg-int8": { "version": "1.0.1", @@ -14467,9 +14792,9 @@ } }, "node_modules/pg-pool": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.2.2.tgz", - "integrity": "sha512-ORJoFxAlmmros8igi608iVEbQNNZlp89diFVx6yV5v+ehmpMY9sK6QgpmgoXbmkNaBAx8cOOZh9g80kJv1ooyA==", + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.5.2.tgz", + "integrity": "sha512-His3Fh17Z4eg7oANLob6ZvH8xIVen3phEZh2QuyrIl4dQSDVEabNducv6ysROKpDNPSD+12tONZVWfSgMvDD9w==", "peerDependencies": { "pg": ">=8.0" } @@ -14489,9 +14814,9 @@ } }, "node_modules/pg-protocol": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.4.0.tgz", - "integrity": "sha512-El+aXWcwG/8wuFICMQjM5ZSAm6OWiJicFdNYo+VY3QP+8vI4SvLIWVe51PppTzMhikUJR+PsyIFKqfdXPz/yxA==" + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.5.0.tgz", + "integrity": "sha512-muRttij7H8TqRNu/DxrAJQITO4Ac7RmX3Klyr/9mJEOBeIpgnF8f9jAfRz5d3XwQZl5qBjF9gLsUtMPJE0vezQ==" }, "node_modules/pg-types": { "version": "2.2.0", @@ -15797,6 +16122,31 @@ "node": ">=0.10.0" } }, + "node_modules/prebuild-install": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.1.tgz", + "integrity": "sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==", + "dependencies": { + "detect-libc": "^2.0.0", + "expand-template": "^2.0.3", + "github-from-package": "0.0.0", + "minimist": "^1.2.3", + "mkdirp-classic": "^0.5.3", + "napi-build-utils": "^1.0.1", + "node-abi": "^3.3.0", + "pump": "^3.0.0", + "rc": "^1.2.7", + "simple-get": "^4.0.0", + "tar-fs": "^2.0.0", + "tunnel-agent": "^0.6.0" + }, + "bin": { + "prebuild-install": "bin.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", @@ -15869,9 +16219,9 @@ } }, "node_modules/proj4": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/proj4/-/proj4-2.8.0.tgz", - "integrity": "sha512-baC+YcD4xsSqJ+CpCZljj2gcQDhlKb+J+Zjv/2KSBwWNjk4M0pafgQsE+mWurd84tflMIsP+7j7mtIpFDHzQfQ==", + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/proj4/-/proj4-2.8.1.tgz", + "integrity": "sha512-KK/bgM6oIwxdpeCaJ/JK3V1D8LMQCKKKzndab4/pYQNd+NVKTcddUNtds053Q110GxTALXVjx98L9f5q8xPVXQ==", "dependencies": { "mgrs": "1.0.0", "wkt-parser": "^1.3.1" @@ -15913,11 +16263,11 @@ } }, "node_modules/proxy-addr": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz", - "integrity": "sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==", + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", "dependencies": { - "forwarded": "~0.1.2", + "forwarded": "0.2.0", "ipaddr.js": "1.9.1" }, "engines": { @@ -15932,7 +16282,7 @@ "node_modules/pseudomap": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", - "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" + "integrity": "sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==" }, "node_modules/psl": { "version": "1.8.0", @@ -16127,11 +16477,17 @@ } }, "node_modules/qs": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "dependencies": { + "side-channel": "^1.0.4" + }, "engines": { "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/query-string": { @@ -16203,7 +16559,7 @@ "node_modules/random-bytes": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz", - "integrity": "sha1-T2ih3Arli9P7lYSMMDJNt11kNgs=", + "integrity": "sha512-iv7LhNVO047HzYR3InF6pUcUsPQiHTM1Qal51DcGSuZFBil1aBBWG5eHPNek7bvILMaYJ/8RU1e8w1AMdHmLQQ==", "engines": { "node": ">= 0.8" } @@ -16234,12 +16590,12 @@ } }, "node_modules/raw-body": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", - "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", + "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", "dependencies": { - "bytes": "3.1.0", - "http-errors": "1.7.2", + "bytes": "3.1.2", + "http-errors": "2.0.0", "iconv-lite": "0.4.24", "unpipe": "1.0.0" }, @@ -16248,9 +16604,9 @@ } }, "node_modules/raw-body/node_modules/bytes": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", - "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", "engines": { "node": ">= 0.8" } @@ -16263,6 +16619,28 @@ "quickselect": "^2.0.0" } }, + "node_modules/rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "dependencies": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "bin": { + "rc": "cli.js" + } + }, + "node_modules/rc/node_modules/strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/react": { "version": "16.14.0", "resolved": "https://registry.npmjs.org/react/-/react-16.14.0.tgz", @@ -16949,13 +17327,22 @@ } }, "node_modules/request/node_modules/qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz", + "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==", "engines": { "node": ">=0.6" } }, + "node_modules/request/node_modules/uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", + "bin": { + "uuid": "bin/uuid" + } + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -17011,16 +17398,16 @@ "deprecated": "https://github.com/lydell/resolve-url#deprecated" }, "node_modules/resolve-url-loader": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/resolve-url-loader/-/resolve-url-loader-3.1.4.tgz", - "integrity": "sha512-D3sQ04o0eeQEySLrcz4DsX3saHfsr8/N6tfhblxgZKXxMT2Louargg12oGNfoTRLV09GXhVUe5/qgA5vdgNigg==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/resolve-url-loader/-/resolve-url-loader-3.1.5.tgz", + "integrity": "sha512-mgFMCmrV/tA4738EsFmPFE5/MaqSgUMe8LK971kVEKA/RrNVb7+VqFsg/qmKyythf34eyq476qIobP/gfFBGSQ==", "dependencies": { "adjust-sourcemap-loader": "3.0.0", "camelcase": "5.3.1", "compose-function": "3.0.3", "convert-source-map": "1.7.0", "es6-iterator": "2.0.3", - "loader-utils": "1.2.3", + "loader-utils": "^1.2.3", "postcss": "7.0.36", "rework": "1.0.1", "rework-visit": "1.0.0", @@ -17030,38 +17417,6 @@ "node": ">=6.0.0" } }, - "node_modules/resolve-url-loader/node_modules/emojis-list": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", - "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=", - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/resolve-url-loader/node_modules/json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", - "dependencies": { - "minimist": "^1.2.0" - }, - "bin": { - "json5": "lib/cli.js" - } - }, - "node_modules/resolve-url-loader/node_modules/loader-utils": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.2.3.tgz", - "integrity": "sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA==", - "dependencies": { - "big.js": "^5.2.2", - "emojis-list": "^2.0.0", - "json5": "^1.0.1" - }, - "engines": { - "node": ">=4.0.0" - } - }, "node_modules/resolve-url-loader/node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -17444,23 +17799,23 @@ } }, "node_modules/send": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", - "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", + "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", "dependencies": { "debug": "2.6.9", - "depd": "~1.1.2", - "destroy": "~1.0.4", + "depd": "2.0.0", + "destroy": "1.2.0", "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "etag": "~1.8.1", "fresh": "0.5.2", - "http-errors": "~1.7.2", + "http-errors": "2.0.0", "mime": "1.6.0", - "ms": "2.1.1", - "on-finished": "~2.3.0", + "ms": "2.1.3", + "on-finished": "2.4.1", "range-parser": "~1.2.1", - "statuses": "~1.5.0" + "statuses": "2.0.1" }, "engines": { "node": ">= 0.8.0" @@ -17477,12 +17832,28 @@ "node_modules/send/node_modules/debug/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, + "node_modules/send/node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "engines": { + "node": ">= 0.8" + } }, "node_modules/send/node_modules/ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/send/node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "engines": { + "node": ">= 0.8" + } }, "node_modules/sequelize": { "version": "5.22.5", @@ -17589,14 +17960,14 @@ "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" }, "node_modules/serve-static": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", - "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", + "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", "dependencies": { "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "parseurl": "~1.3.3", - "send": "0.17.1" + "send": "0.18.0" }, "engines": { "node": ">= 0.8.0" @@ -17638,9 +18009,9 @@ "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=" }, "node_modules/setprototypeof": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", - "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, "node_modules/sha.js": { "version": "2.4.11", @@ -17687,6 +18058,70 @@ "node": ">=0.10.0" } }, + "node_modules/sharp": { + "version": "0.31.2", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.31.2.tgz", + "integrity": "sha512-DUdNVEXgS5A97cTagSLIIp8dUZ/lZtk78iNVZgHdHbx1qnQR7JAHY0BnXnwwH39Iw+VKhO08CTYhIg0p98vQ5Q==", + "hasInstallScript": true, + "dependencies": { + "color": "^4.2.3", + "detect-libc": "^2.0.1", + "node-addon-api": "^5.0.0", + "prebuild-install": "^7.1.1", + "semver": "^7.3.8", + "simple-get": "^4.0.1", + "tar-fs": "^2.1.1", + "tunnel-agent": "^0.6.0" + }, + "engines": { + "node": ">=14.15.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/sharp/node_modules/color": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz", + "integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==", + "dependencies": { + "color-convert": "^2.0.1", + "color-string": "^1.9.0" + }, + "engines": { + "node": ">=12.5.0" + } + }, + "node_modules/sharp/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/sharp/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/sharp/node_modules/semver": { + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/shebang-command": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", @@ -17762,6 +18197,49 @@ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==" }, + "node_modules/simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/simple-get": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", + "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "decompress-response": "^6.0.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, "node_modules/simple-swizzle": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", @@ -18004,6 +18482,15 @@ "ms": "^2.1.1" } }, + "node_modules/sockjs/node_modules/uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", + "bin": { + "uuid": "bin/uuid" + } + }, "node_modules/sort-keys": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz", @@ -18776,6 +19263,37 @@ "node": ">= 10" } }, + "node_modules/tar-fs": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", + "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", + "dependencies": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.1.4" + } + }, + "node_modules/tar-fs/node_modules/chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + }, + "node_modules/tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "dependencies": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/tar/node_modules/mkdirp": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", @@ -19212,9 +19730,9 @@ } }, "node_modules/toidentifier": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", - "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", "engines": { "node": ">=0.6" } @@ -19927,6 +20445,19 @@ "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, + "node_modules/typescript": { + "version": "4.9.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz", + "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==", + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/uglify-js": { "version": "3.12.4", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.12.4.tgz", @@ -20041,7 +20572,7 @@ "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", "engines": { "node": ">= 0.8" } @@ -20265,12 +20796,11 @@ } }, "node_modules/uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", "bin": { - "uuid": "bin/uuid" + "uuid": "dist/bin/uuid" } }, "node_modules/v8-compile-cache": { @@ -20426,7 +20956,7 @@ "node_modules/watchpack-chokidar2/node_modules/glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "integrity": "sha512-E8Ak/2+dZY6fnzlR7+ueWvhsH1SjHr4jjss4YS/h4py44jY9MhK/VFdaZJAWDz6BbL21KeteKxFSFpq8OS5gVA==", "optional": true, "dependencies": { "is-glob": "^3.1.0", @@ -20840,7 +21370,7 @@ "node_modules/webpack-dev-server/node_modules/glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "integrity": "sha512-E8Ak/2+dZY6fnzlR7+ueWvhsH1SjHr4jjss4YS/h4py44jY9MhK/VFdaZJAWDz6BbL21KeteKxFSFpq8OS5gVA==", "dependencies": { "is-glob": "^3.1.0", "path-dirname": "^1.0.0" @@ -20974,6 +21504,15 @@ "node": ">= 6" } }, + "node_modules/webpack-log/node_modules/uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", + "bin": { + "uuid": "bin/uuid" + } + }, "node_modules/webpack-manifest-plugin": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/webpack-manifest-plugin/-/webpack-manifest-plugin-2.2.0.tgz", @@ -21587,6 +22126,26 @@ "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz", "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==" }, + "node_modules/xml2js": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", + "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", + "dependencies": { + "sax": ">=0.6.0", + "xmlbuilder": "~11.0.0" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/xmlbuilder": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==", + "engines": { + "node": ">=4.0" + } + }, "node_modules/xmlchars": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", @@ -23256,6 +23815,11 @@ "loader-utils": "^1.2.3" } }, + "@terraformer/wkt": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@terraformer/wkt/-/wkt-2.2.0.tgz", + "integrity": "sha512-i33rTSqPtmO4sRdeznI0IEc9gpIZZIXN5kGhZ4rTwVtDccDKL3h4uia9cmWdRJlJMlG4Febxatw5b9ylI5YYuA==" + }, "@testing-library/dom": { "version": "6.16.0", "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-6.16.0.tgz", @@ -24753,6 +25317,16 @@ "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==" }, + "@types/pg": { + "version": "8.6.5", + "resolved": "https://registry.npmjs.org/@types/pg/-/pg-8.6.5.tgz", + "integrity": "sha512-tOkGtAqRVkHa/PVZicq67zuujI4Oorfglsr2IbKofDwBSysnaqSx7W1mDqFqdkGE6Fbgh+PZAl0r/BWON/mozw==", + "requires": { + "@types/node": "*", + "pg-protocol": "*", + "pg-types": "^2.2.0" + } + }, "@types/prop-types": { "version": "15.7.3", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz", @@ -25133,12 +25707,12 @@ "integrity": "sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q==" }, "accepts": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", - "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", "requires": { - "mime-types": "~2.1.24", - "negotiator": "0.6.2" + "mime-types": "~2.1.34", + "negotiator": "0.6.3" } }, "acorn": { @@ -25188,9 +25762,9 @@ }, "dependencies": { "loader-utils": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", - "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.4.tgz", + "integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==", "requires": { "big.js": "^5.2.2", "emojis-list": "^3.0.0", @@ -26020,6 +26594,27 @@ "resolved": "https://registry.npmjs.org/bit-twiddle/-/bit-twiddle-1.0.2.tgz", "integrity": "sha1-DGwfq+KyPRcXPZpht7cJPrnhdp4=" }, + "bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "requires": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + }, + "dependencies": { + "buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + } + } + }, "bluebird": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", @@ -26031,26 +26626,28 @@ "integrity": "sha512-GkTiFpjFtUzU9CbMeJ5iazkCzGL3jrhzerzZIuqLABjbwRaFt33I9tUdSNryIptM+RxDet6OKm2WnLXzW51KsQ==" }, "body-parser": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", - "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", + "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", "requires": { - "bytes": "3.1.0", + "bytes": "3.1.2", "content-type": "~1.0.4", "debug": "2.6.9", - "depd": "~1.1.2", - "http-errors": "1.7.2", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", "iconv-lite": "0.4.24", - "on-finished": "~2.3.0", - "qs": "6.7.0", - "raw-body": "2.4.0", - "type-is": "~1.6.17" + "on-finished": "2.4.1", + "qs": "6.11.0", + "raw-body": "2.5.1", + "type-is": "~1.6.18", + "unpipe": "1.0.0" }, "dependencies": { "bytes": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", - "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==" }, "debug": { "version": "2.6.9", @@ -26060,10 +26657,15 @@ "ms": "2.0.0" } }, + "depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==" + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" } } }, @@ -26897,6 +27499,31 @@ "resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-1.6.0.tgz", "integrity": "sha512-e54B99q/OUoH64zYYRf3HBP5z24G38h5D3qXu23JGRoigpX5Ss4r9ZnDk3g0Z8uQC2x2lPaJ+UlWBc1ZWBWdLg==" }, + "connect-pg-simple": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/connect-pg-simple/-/connect-pg-simple-8.0.0.tgz", + "integrity": "sha512-pBDa23RA1LCkwvRrPOh5xevB+Nknh1UDuhFOKsUrkUDodYqfiQT18P2qXc4lk/TqCMB6hI06B8KNncHh91bZMQ==", + "requires": { + "@types/pg": "^8.6.5", + "pg": "^8.8.0" + }, + "dependencies": { + "pg": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/pg/-/pg-8.8.0.tgz", + "integrity": "sha512-UXYN0ziKj+AeNNP7VDMwrehpACThH7LUl/p8TDFpEUuSejCUIwGSfxpHsPvtM6/WXFy6SU4E5RG4IJV/TZAGjw==", + "requires": { + "buffer-writer": "2.0.0", + "packet-reader": "1.0.0", + "pg-connection-string": "^2.5.0", + "pg-pool": "^3.5.2", + "pg-protocol": "^1.5.0", + "pg-types": "^2.1.0", + "pgpass": "1.x" + } + } + } + }, "console-browserify": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.2.0.tgz", @@ -26922,17 +27549,24 @@ "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=" }, "content-disposition": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", - "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", "requires": { - "safe-buffer": "5.1.2" + "safe-buffer": "5.2.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + } } }, "content-type": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", - "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==" }, "convert-source-map": { "version": "1.7.0", @@ -27798,9 +28432,17 @@ "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" }, "decode-uri-component": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", - "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=" + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz", + "integrity": "sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==" + }, + "decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "requires": { + "mimic-response": "^3.1.0" + } }, "deep-equal": { "version": "1.1.1", @@ -27815,6 +28457,11 @@ "regexp.prototype.flags": "^1.2.0" } }, + "deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==" + }, "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", @@ -27954,9 +28601,14 @@ } }, "destroy": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", - "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==" + }, + "detect-libc": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.1.tgz", + "integrity": "sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w==" }, "detect-newline": { "version": "2.1.0", @@ -28239,7 +28891,7 @@ "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "electron-to-chromium": { "version": "1.3.743", @@ -28285,7 +28937,7 @@ "encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==" }, "end-of-stream": { "version": "1.4.4", @@ -28389,13 +29041,13 @@ } }, "es5-ext": { - "version": "0.10.53", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.53.tgz", - "integrity": "sha512-Xs2Stw6NiNHWypzRTY1MtaG/uJlwCk8kH81920ma8mvN8Xq1gsfhZvpkImLQArw8AHnv8MT2I45J3c0R8slE+Q==", + "version": "0.10.62", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", + "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", "requires": { - "es6-iterator": "~2.0.3", - "es6-symbol": "~3.1.3", - "next-tick": "~1.0.0" + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.3", + "next-tick": "^1.1.0" } }, "es6-iterator": { @@ -28943,7 +29595,7 @@ "etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==" }, "eventemitter3": { "version": "4.0.7", @@ -29038,6 +29690,11 @@ } } }, + "expand-template": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", + "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==" + }, "expect": { "version": "24.9.0", "resolved": "https://registry.npmjs.org/expect/-/expect-24.9.0.tgz", @@ -29052,42 +29709,48 @@ } }, "express": { - "version": "4.17.1", - "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", - "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", + "version": "4.18.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", + "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", "requires": { - "accepts": "~1.3.7", + "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.19.0", - "content-disposition": "0.5.3", + "body-parser": "1.20.1", + "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.4.0", + "cookie": "0.5.0", "cookie-signature": "1.0.6", "debug": "2.6.9", - "depd": "~1.1.2", + "depd": "2.0.0", "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "etag": "~1.8.1", - "finalhandler": "~1.1.2", + "finalhandler": "1.2.0", "fresh": "0.5.2", + "http-errors": "2.0.0", "merge-descriptors": "1.0.1", "methods": "~1.1.2", - "on-finished": "~2.3.0", + "on-finished": "2.4.1", "parseurl": "~1.3.3", "path-to-regexp": "0.1.7", - "proxy-addr": "~2.0.5", - "qs": "6.7.0", + "proxy-addr": "~2.0.7", + "qs": "6.11.0", "range-parser": "~1.2.1", - "safe-buffer": "5.1.2", - "send": "0.17.1", - "serve-static": "1.14.1", - "setprototypeof": "1.1.1", - "statuses": "~1.5.0", + "safe-buffer": "5.2.1", + "send": "0.18.0", + "serve-static": "1.15.0", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", "type-is": "~1.6.18", "utils-merge": "1.0.1", "vary": "~1.1.2" }, "dependencies": { + "cookie": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", + "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==" + }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -29096,10 +29759,25 @@ "ms": "2.0.0" } }, + "depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==" + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + }, + "statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==" } } }, @@ -29109,20 +29787,25 @@ "integrity": "sha512-cjQH+oDrEPXxc569XvxhHC6QXqJiuBT6BhZ70X3bdAImcnHnTNMVuMAJaT0TXPoRiEErUrVPRcOTpZpM36VbOQ==" }, "express-session": { - "version": "1.17.1", - "resolved": "https://registry.npmjs.org/express-session/-/express-session-1.17.1.tgz", - "integrity": "sha512-UbHwgqjxQZJiWRTMyhvWGvjBQduGCSBDhhZXYenziMFjxst5rMV+aJZ6hKPHZnPyHGsrqRICxtX8jtEbm/z36Q==", + "version": "1.17.3", + "resolved": "https://registry.npmjs.org/express-session/-/express-session-1.17.3.tgz", + "integrity": "sha512-4+otWXlShYlG1Ma+2Jnn+xgKUZTMJ5QD3YvfilX3AcocOAbIkVylSWEklzALe/+Pu4qV6TYBj5GwOBFfdKqLBw==", "requires": { - "cookie": "0.4.0", + "cookie": "0.4.2", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "~2.0.0", "on-headers": "~1.0.2", "parseurl": "~1.3.3", - "safe-buffer": "5.2.0", + "safe-buffer": "5.2.1", "uid-safe": "~2.1.5" }, "dependencies": { + "cookie": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==" + }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -29139,12 +29822,12 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, "safe-buffer": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", - "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==" + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" } } }, @@ -29431,16 +30114,16 @@ } }, "finalhandler": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", - "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", + "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", "requires": { "debug": "2.6.9", "encodeurl": "~1.0.2", "escape-html": "~1.0.3", - "on-finished": "~2.3.0", + "on-finished": "2.4.1", "parseurl": "~1.3.3", - "statuses": "~1.5.0", + "statuses": "2.0.1", "unpipe": "~1.0.0" }, "dependencies": { @@ -29455,7 +30138,12 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, + "statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==" } } }, @@ -29600,9 +30288,9 @@ } }, "forwarded": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", - "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==" }, "fragment-cache": { "version": "0.2.1", @@ -29615,7 +30303,7 @@ "fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==" }, "from2": { "version": "2.3.0", @@ -29650,6 +30338,11 @@ } } }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, "fs-extra": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", @@ -29771,6 +30464,11 @@ "rbush": "^3.0.1" } }, + "geojson-validation": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/geojson-validation/-/geojson-validation-1.0.2.tgz", + "integrity": "sha512-K5jrJ4wFvORn2pRKeg181LL0QPYuEKn2KHPvfH1m2QtFlAXFLKdseqt0XwBM3ELOY7kNM1fglRQ6ZwUQZ5S00A==" + }, "get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -29817,6 +30515,11 @@ "assert-plus": "^1.0.0" } }, + "github-from-package": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", + "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==" + }, "glob": { "version": "7.1.6", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", @@ -30281,21 +30984,26 @@ "integrity": "sha1-+nFolEq5pRnTN8sL7HKE3D5yPYc=" }, "http-errors": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", - "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", "requires": { - "depd": "~1.1.2", - "inherits": "2.0.3", - "setprototypeof": "1.1.1", - "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.0" + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" }, "dependencies": { - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + "depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==" + }, + "statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==" } } }, @@ -30683,9 +31391,9 @@ } }, "is-core-module": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.2.0.tgz", - "integrity": "sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ==", + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz", + "integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==", "requires": { "has": "^1.0.3" } @@ -31647,12 +32355,9 @@ "integrity": "sha512-c7/8mbUsKigAbLkD5B010BK4D9LZm7A1pNItkEwiUZRpIN66exu/e7YQWysGun+TRKaJp8MhemM+VkfWv42aCA==" }, "json5": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.3.tgz", - "integrity": "sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA==", - "requires": { - "minimist": "^1.2.5" - } + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==" }, "jsonfile": { "version": "4.0.0", @@ -31845,9 +32550,9 @@ "integrity": "sha512-Jsmr89RcXGIwivFY21FcRrisYZfvLMTWx5kOLc+JTxtpBOG6xML0vzbc6SEQG2FO9/4Fc3wW4LVcB5DmGflaRw==" }, "loader-utils": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.0.tgz", - "integrity": "sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.2.tgz", + "integrity": "sha512-I5d00Pd/jwMD2QCduo657+YM/6L3KZu++pmX9VFncxaxvHcru9jx1lBaFft+r4Mt2jK0Yhp41XlRAihzPxHNCg==", "requires": { "big.js": "^5.2.2", "emojis-list": "^3.0.0", @@ -31855,9 +32560,9 @@ }, "dependencies": { "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", "requires": { "minimist": "^1.2.0" } @@ -32020,6 +32725,11 @@ "resolved": "https://registry.npmjs.org/mark.js/-/mark.js-8.11.1.tgz", "integrity": "sha1-GA8fnr74sOY45BZq1S24eb6y/8U=" }, + "materialize-css": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/materialize-css/-/materialize-css-1.0.0.tgz", + "integrity": "sha512-4/oecXl8y/1i8RDZvyvwAICyqwNoKU4or5uf8uoAd74k76KzZ0Llym4zhJ5lLNUskcqjO0AuMcvNyDkpz8Z6zw==" + }, "md5.js": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", @@ -32038,7 +32748,7 @@ "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==" }, "memory-fs": { "version": "0.4.1", @@ -32074,9 +32784,9 @@ } }, "memorystore": { - "version": "1.6.4", - "resolved": "https://registry.npmjs.org/memorystore/-/memorystore-1.6.4.tgz", - "integrity": "sha512-51j4kUedbqkWGby44hAhf5f/hj8GOvHoLX00/YHURBNxOMf5k8JbPuGfmeNpZEXhc3vrmfnFben4+rOOx3HjEQ==", + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/memorystore/-/memorystore-1.6.7.tgz", + "integrity": "sha512-OZnmNY/NDrKohPQ+hxp0muBcBKrzKNtHr55DbqSx9hLsYVNnomSAMRAtI7R64t3gf3ID7tHQA7mG4oL3Hu9hdw==", "requires": { "debug": "^4.3.0", "lru-cache": "^4.0.3" @@ -32094,7 +32804,7 @@ "yallist": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" + "integrity": "sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==" } } }, @@ -32187,16 +32897,16 @@ "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" }, "mime-db": { - "version": "1.45.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.45.0.tgz", - "integrity": "sha512-CkqLUxUk15hofLoLyljJSrukZi8mAtgd+yE5uO4tqRZsdsAJKv0O+rFMhVDRJgozy+yG6md5KwuXhD4ocIoP+w==" + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==" }, "mime-types": { - "version": "2.1.28", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.28.tgz", - "integrity": "sha512-0TO2yJ5YHYr7M2zzT7gDU1tbwHxEUWBCLt0lscSNpcdAfFyJOVEpRYNS7EXVcTLNj/25QO8gulHC5JtTzSE2UQ==", + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", "requires": { - "mime-db": "1.45.0" + "mime-db": "1.52.0" } }, "mimic-fn": { @@ -32204,6 +32914,11 @@ "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" }, + "mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==" + }, "min-indent": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", @@ -32356,17 +33071,22 @@ "minimist": "^1.2.5" } }, + "mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" + }, "moment": { "version": "2.29.4", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==" }, "moment-timezone": { - "version": "0.5.32", - "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.32.tgz", - "integrity": "sha512-Z8QNyuQHQAmWucp8Knmgei8YNo28aLjJq6Ma+jy1ZSpSk5nyfRT8xgUbSQvD2+2UajISfenndwvFuH3NGS+nvA==", + "version": "0.5.43", + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.43.tgz", + "integrity": "sha512-72j3aNyuIsDxdF1i7CEgV2FfxM1r6aaqJyLB2vwb33mXYyoyLly+F1zbWqhA3/bVIoJ4szlUoMbUnVdid32NUQ==", "requires": { - "moment": ">= 2.9.0" + "moment": "^2.29.4" } }, "monotone-convex-hull-2d": { @@ -32451,15 +33171,20 @@ } } }, + "napi-build-utils": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", + "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==" + }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=" }, "negotiator": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", - "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==" }, "neo-async": { "version": "2.6.2", @@ -32467,9 +33192,9 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" }, "next-tick": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", - "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", + "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" }, "nice-try": { "version": "1.0.5", @@ -32497,6 +33222,29 @@ } } }, + "node-abi": { + "version": "3.30.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.30.0.tgz", + "integrity": "sha512-qWO5l3SCqbwQavymOmtTVuCWZE23++S+rxyoHjXqUmPyzRcaoI4lA2gO55/drddGnedAyjA7sk76SfQ5lfUMnw==", + "requires": { + "semver": "^7.3.5" + }, + "dependencies": { + "semver": { + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, + "node-addon-api": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-5.0.0.tgz", + "integrity": "sha512-CvkDw2OEnme7ybCykJpVcKH+uAOLV2qLqiyla128dN9TkEWfrYmxG6C2boDe5KcNQqZF3orkqzGgOMvZ/JNekA==" + }, "node-fetch": { "version": "2.6.7", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", @@ -32849,9 +33597,9 @@ "integrity": "sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==" }, "on-finished": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", "requires": { "ee-first": "1.1.1" } @@ -33212,9 +33960,9 @@ } }, "pg-connection-string": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.4.0.tgz", - "integrity": "sha512-3iBXuv7XKvxeMrIgym7njT+HlZkwZqqGX4Bu9cci8xHZNT+Um1gWKqCsAzcC0d95rcKMU5WBg6YRUcHyV0HZKQ==" + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.5.0.tgz", + "integrity": "sha512-r5o/V/ORTA6TmUnyWZR9nCj1klXCO2CEKNRlVuJptZe85QuhFayC7WeMic7ndayT5IRIR0S0xFxFi2ousartlQ==" }, "pg-int8": { "version": "1.0.1", @@ -33227,9 +33975,9 @@ "integrity": "sha512-1KdmFGGTP6jplJoI8MfvRlfvMiyBivMRP7/ffh4a11RUFJ7kC2J0ZHlipoKiH/1hz+DVgceon9U2qbaHpPeyPg==" }, "pg-pool": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.2.2.tgz", - "integrity": "sha512-ORJoFxAlmmros8igi608iVEbQNNZlp89diFVx6yV5v+ehmpMY9sK6QgpmgoXbmkNaBAx8cOOZh9g80kJv1ooyA==", + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.5.2.tgz", + "integrity": "sha512-His3Fh17Z4eg7oANLob6ZvH8xIVen3phEZh2QuyrIl4dQSDVEabNducv6ysROKpDNPSD+12tONZVWfSgMvDD9w==", "requires": {} }, "pg-promise": { @@ -33244,9 +33992,9 @@ } }, "pg-protocol": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.4.0.tgz", - "integrity": "sha512-El+aXWcwG/8wuFICMQjM5ZSAm6OWiJicFdNYo+VY3QP+8vI4SvLIWVe51PppTzMhikUJR+PsyIFKqfdXPz/yxA==" + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.5.0.tgz", + "integrity": "sha512-muRttij7H8TqRNu/DxrAJQITO4Ac7RmX3Klyr/9mJEOBeIpgnF8f9jAfRz5d3XwQZl5qBjF9gLsUtMPJE0vezQ==" }, "pg-types": { "version": "2.2.0", @@ -34318,6 +35066,25 @@ "xtend": "^4.0.0" } }, + "prebuild-install": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.1.tgz", + "integrity": "sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==", + "requires": { + "detect-libc": "^2.0.0", + "expand-template": "^2.0.3", + "github-from-package": "0.0.0", + "minimist": "^1.2.3", + "mkdirp-classic": "^0.5.3", + "napi-build-utils": "^1.0.1", + "node-abi": "^3.3.0", + "pump": "^3.0.0", + "rc": "^1.2.7", + "simple-get": "^4.0.0", + "tar-fs": "^2.0.0", + "tunnel-agent": "^0.6.0" + } + }, "prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", @@ -34369,9 +35136,9 @@ "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==" }, "proj4": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/proj4/-/proj4-2.8.0.tgz", - "integrity": "sha512-baC+YcD4xsSqJ+CpCZljj2gcQDhlKb+J+Zjv/2KSBwWNjk4M0pafgQsE+mWurd84tflMIsP+7j7mtIpFDHzQfQ==", + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/proj4/-/proj4-2.8.1.tgz", + "integrity": "sha512-KK/bgM6oIwxdpeCaJ/JK3V1D8LMQCKKKzndab4/pYQNd+NVKTcddUNtds053Q110GxTALXVjx98L9f5q8xPVXQ==", "requires": { "mgrs": "1.0.0", "wkt-parser": "^1.3.1" @@ -34410,11 +35177,11 @@ } }, "proxy-addr": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz", - "integrity": "sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==", + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", "requires": { - "forwarded": "~0.1.2", + "forwarded": "0.2.0", "ipaddr.js": "1.9.1" } }, @@ -34426,7 +35193,7 @@ "pseudomap": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", - "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" + "integrity": "sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==" }, "psl": { "version": "1.8.0", @@ -34617,9 +35384,12 @@ "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=" }, "qs": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "requires": { + "side-channel": "^1.0.4" + } }, "query-string": { "version": "4.3.4", @@ -34666,7 +35436,7 @@ "random-bytes": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz", - "integrity": "sha1-T2ih3Arli9P7lYSMMDJNt11kNgs=" + "integrity": "sha512-iv7LhNVO047HzYR3InF6pUcUsPQiHTM1Qal51DcGSuZFBil1aBBWG5eHPNek7bvILMaYJ/8RU1e8w1AMdHmLQQ==" }, "randombytes": { "version": "2.1.0", @@ -34691,20 +35461,20 @@ "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" }, "raw-body": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", - "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", + "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", "requires": { - "bytes": "3.1.0", - "http-errors": "1.7.2", + "bytes": "3.1.2", + "http-errors": "2.0.0", "iconv-lite": "0.4.24", "unpipe": "1.0.0" }, "dependencies": { "bytes": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", - "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==" } } }, @@ -34716,6 +35486,24 @@ "quickselect": "^2.0.0" } }, + "rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "dependencies": { + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==" + } + } + }, "react": { "version": "16.14.0", "resolved": "https://registry.npmjs.org/react/-/react-16.14.0.tgz", @@ -35217,9 +36005,14 @@ }, "dependencies": { "qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz", + "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==" + }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" } } }, @@ -35283,45 +36076,22 @@ "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=" }, "resolve-url-loader": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/resolve-url-loader/-/resolve-url-loader-3.1.4.tgz", - "integrity": "sha512-D3sQ04o0eeQEySLrcz4DsX3saHfsr8/N6tfhblxgZKXxMT2Louargg12oGNfoTRLV09GXhVUe5/qgA5vdgNigg==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/resolve-url-loader/-/resolve-url-loader-3.1.5.tgz", + "integrity": "sha512-mgFMCmrV/tA4738EsFmPFE5/MaqSgUMe8LK971kVEKA/RrNVb7+VqFsg/qmKyythf34eyq476qIobP/gfFBGSQ==", "requires": { "adjust-sourcemap-loader": "3.0.0", "camelcase": "5.3.1", "compose-function": "3.0.3", "convert-source-map": "1.7.0", "es6-iterator": "2.0.3", - "loader-utils": "1.2.3", + "loader-utils": "^1.2.3", "postcss": "7.0.36", "rework": "1.0.1", "rework-visit": "1.0.0", "source-map": "0.6.1" }, "dependencies": { - "emojis-list": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", - "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=" - }, - "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", - "requires": { - "minimist": "^1.2.0" - } - }, - "loader-utils": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.2.3.tgz", - "integrity": "sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA==", - "requires": { - "big.js": "^5.2.2", - "emojis-list": "^2.0.0", - "json5": "^1.0.1" - } - }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -35615,23 +36385,23 @@ "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" }, "send": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", - "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", + "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", "requires": { "debug": "2.6.9", - "depd": "~1.1.2", - "destroy": "~1.0.4", + "depd": "2.0.0", + "destroy": "1.2.0", "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "etag": "~1.8.1", "fresh": "0.5.2", - "http-errors": "~1.7.2", + "http-errors": "2.0.0", "mime": "1.6.0", - "ms": "2.1.1", - "on-finished": "~2.3.0", + "ms": "2.1.3", + "on-finished": "2.4.1", "range-parser": "~1.2.1", - "statuses": "~1.5.0" + "statuses": "2.0.1" }, "dependencies": { "debug": { @@ -35645,14 +36415,24 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" } } }, + "depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==" + }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==" } } }, @@ -35749,14 +36529,14 @@ } }, "serve-static": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", - "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", + "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", "requires": { "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "parseurl": "~1.3.3", - "send": "0.17.1" + "send": "0.18.0" } }, "set-blocking": { @@ -35791,9 +36571,9 @@ "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=" }, "setprototypeof": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", - "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, "sha.js": { "version": "2.4.11", @@ -35830,6 +36610,53 @@ } } }, + "sharp": { + "version": "0.31.2", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.31.2.tgz", + "integrity": "sha512-DUdNVEXgS5A97cTagSLIIp8dUZ/lZtk78iNVZgHdHbx1qnQR7JAHY0BnXnwwH39Iw+VKhO08CTYhIg0p98vQ5Q==", + "requires": { + "color": "^4.2.3", + "detect-libc": "^2.0.1", + "node-addon-api": "^5.0.0", + "prebuild-install": "^7.1.1", + "semver": "^7.3.8", + "simple-get": "^4.0.1", + "tar-fs": "^2.1.1", + "tunnel-agent": "^0.6.0" + }, + "dependencies": { + "color": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz", + "integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==", + "requires": { + "color-convert": "^2.0.1", + "color-string": "^1.9.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "semver": { + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, "shebang-command": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", @@ -35888,6 +36715,21 @@ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==" }, + "simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==" + }, + "simple-get": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", + "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", + "requires": { + "decompress-response": "^6.0.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, "simple-swizzle": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", @@ -36073,6 +36915,13 @@ "faye-websocket": "^0.11.3", "uuid": "^3.4.0", "websocket-driver": "^0.7.4" + }, + "dependencies": { + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" + } } }, "sockjs-client": { @@ -36728,6 +37577,36 @@ } } }, + "tar-fs": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", + "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", + "requires": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.1.4" + }, + "dependencies": { + "chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + } + } + }, + "tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "requires": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + } + }, "terser": { "version": "4.8.1", "resolved": "https://registry.npmjs.org/terser/-/terser-4.8.1.tgz", @@ -37051,9 +37930,9 @@ } }, "toidentifier": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", - "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==" }, "token-stream": { "version": "1.0.0", @@ -37672,6 +38551,12 @@ "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, + "typescript": { + "version": "4.9.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz", + "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==", + "peer": true + }, "uglify-js": { "version": "3.12.4", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.12.4.tgz", @@ -37759,7 +38644,7 @@ "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==" }, "unquote": { "version": "1.1.1", @@ -37940,9 +38825,9 @@ } }, "uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==" }, "v8-compile-cache": { "version": "2.2.0", @@ -38073,7 +38958,7 @@ "glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "integrity": "sha512-E8Ak/2+dZY6fnzlR7+ueWvhsH1SjHr4jjss4YS/h4py44jY9MhK/VFdaZJAWDz6BbL21KeteKxFSFpq8OS5gVA==", "optional": true, "requires": { "is-glob": "^3.1.0", @@ -38482,7 +39367,7 @@ "glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "integrity": "sha512-E8Ak/2+dZY6fnzlR7+ueWvhsH1SjHr4jjss4YS/h4py44jY9MhK/VFdaZJAWDz6BbL21KeteKxFSFpq8OS5gVA==", "requires": { "is-glob": "^3.1.0", "path-dirname": "^1.0.0" @@ -38591,6 +39476,13 @@ "requires": { "ansi-colors": "^3.0.0", "uuid": "^3.3.2" + }, + "dependencies": { + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" + } } }, "webpack-manifest-plugin": { @@ -39017,6 +39909,20 @@ "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz", "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==" }, + "xml2js": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", + "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", + "requires": { + "sax": ">=0.6.0", + "xmlbuilder": "~11.0.0" + } + }, + "xmlbuilder": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==" + }, "xmlchars": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", diff --git a/package.json b/package.json index 4cc757a2..4d2ed31b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mmgis", - "version": "2.8.0", + "version": "2.9.0", "description": "A web-based mapping and localization solution for science operation on planetary missions.", "homepage": "build", "repository": { @@ -36,18 +36,20 @@ "cesium" ], "scripts": { - "start": "node run/server.js", - "start:prod": "cross-env NODE_ENV=production node run/server.js", + "start": "node scripts/init-db.js && node scripts/server.js", + "start:prod": "node scripts/init-db.js && cross-env NODE_ENV=production node scripts/server.js", + "start:prod:with_examples": "cross-env NODE_ENV=production node scripts/server.js --with_examples", "start:docs": "cd ./docs && bundle exec jekyll serve", - "start:analyzer": "node run/server.js --analyze", - "build": "node run/build.js", - "test": "node run/test.js" + "start:analyzer": "node scripts/server.js --analyze", + "build": "node scripts/build.js", + "test": "node scripts/test.js" }, "dependencies": { "@babel/core": "7.9.0", "@eonasdan/tempus-dominus": "^6.2.6", "@popperjs/core": "^2.11.6", "@svgr/webpack": "4.3.3", + "@terraformer/wkt": "^2.2.0", "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.5.0", "@testing-library/user-event": "^7.2.1", @@ -66,6 +68,7 @@ "chart.js": "^3.6.0", "chartjs-plugin-zoom": "^1.2.1", "compression": "^1.7.4", + "connect-pg-simple": "^8.0.0", "cookie-parser": "^1.4.5", "cors": "^2.8.5", "cross-env": "^7.0.2", @@ -85,11 +88,12 @@ "eslint-plugin-react-hooks": "^1.6.1", "express": "^4.16.3", "express-rate-limit": "^5.1.3", - "express-session": "^1.17.1", + "express-session": "^1.17.3", "file-loader": "4.3.0", "file-saver": "^2.0.2", "flat": "^5.0.2", "fs-extra": "^8.1.0", + "geojson-validation": "^1.0.2", "hammerjs": "^2.0.8", "helmet": "^4.1.1", "html-webpack-plugin": "4.0.0-beta.11", @@ -104,6 +108,7 @@ "jquery": "^3.5.1", "lithosphere": "^1.5.4", "mark.js": "^8.11.1", + "materialize-css": "^1.0.0", "memorystore": "^1.6.2", "mini-css-extract-plugin": "0.9.0", "nipplejs": "^0.8.5", @@ -118,6 +123,7 @@ "postcss-normalize": "8.0.1", "postcss-preset-env": "6.7.0", "postcss-safe-parser": "4.0.1", + "proj4": "^2.8.1", "pug": "^3.0.1", "react": "^16.13.1", "react-app-polyfill": "^1.0.6", @@ -129,6 +135,7 @@ "sass-loader": "8.0.2", "semver": "6.3.0", "sequelize": "^5.21.2", + "sharp": "^0.31.2", "showdown": "^2.1.0", "sortablejs": "^1.15.0", "string-replace-loader": "^2.3.0", @@ -140,12 +147,14 @@ "turf": "^3.0.14", "url-loader": "2.3.0", "util": "^0.12.3", + "uuid": "^9.0.0", "webpack": "4.42.0", "webpack-dev-server": "^3.11.0", "webpack-manifest-plugin": "2.2.0", "winston": "^3.3.4", "workbox-webpack-plugin": "4.3.1", - "ws": "^8.8.1" + "ws": "^8.8.1", + "xml2js": "^0.4.23" }, "eslintConfig": { "extends": "react-app" diff --git a/private/api/great_circle_calculator/__conversion.pyc b/private/api/great_circle_calculator/__conversion.pyc index 9867d83b..2ac8fa31 100644 Binary files a/private/api/great_circle_calculator/__conversion.pyc and b/private/api/great_circle_calculator/__conversion.pyc differ diff --git a/private/api/great_circle_calculator/__error_checking.pyc b/private/api/great_circle_calculator/__error_checking.pyc index 7c5fecc0..f09a55b8 100644 Binary files a/private/api/great_circle_calculator/__error_checking.pyc and b/private/api/great_circle_calculator/__error_checking.pyc differ diff --git a/private/api/great_circle_calculator/__init__.pyc b/private/api/great_circle_calculator/__init__.pyc index 22d41565..b52d67a0 100644 Binary files a/private/api/great_circle_calculator/__init__.pyc and b/private/api/great_circle_calculator/__init__.pyc differ diff --git a/private/api/great_circle_calculator/_constants.pyc b/private/api/great_circle_calculator/_constants.pyc index 9e329af6..b1f2ee0a 100644 Binary files a/private/api/great_circle_calculator/_constants.pyc and b/private/api/great_circle_calculator/_constants.pyc differ diff --git a/private/api/great_circle_calculator/great_circle_calculator.pyc b/private/api/great_circle_calculator/great_circle_calculator.pyc index f269800a..9278ab33 100644 Binary files a/private/api/great_circle_calculator/great_circle_calculator.pyc and b/private/api/great_circle_calculator/great_circle_calculator.pyc differ diff --git a/public/index.html b/public/index.html index 129904c8..04d81a1b 100644 --- a/public/index.html +++ b/public/index.html @@ -335,7 +335,12 @@ mmgisglobal.CLEARANCE_NUMBER = "#{CLEARANCE_NUMBER}"; mmgisglobal.HOSTS = "#{HOSTS}"; mmgisglobal.PORT = "#{PORT}"; + mmgisglobal.ROOT_PATH = "#{ROOT_PATH}"; + mmgisglobal.WEBSOCKET_ROOT_PATH = "#{WEBSOCKET_ROOT_PATH}"; mmgisglobal.ENABLE_MMGIS_WEBSOCKETS = "#{ENABLE_MMGIS_WEBSOCKETS}"; + mmgisglobal.MAIN_MISSION = "#{MAIN_MISSION}"; + mmgisglobal.SKIP_CLIENT_INITIAL_LOGIN = "#{SKIP_CLIENT_INITIAL_LOGIN}"; + mmgisglobal.THIRD_PARTY_COOKIES = "#{THIRD_PARTY_COOKIES}"; break; default: mmgisglobal.AUTH = "%AUTH%"; @@ -347,7 +352,12 @@ mmgisglobal.FORCE_CONFIG_PATH = null; mmgisglobal.CLEARANCE_NUMBER = "%CLEARANCE_NUMBER%"; mmgisglobal.PORT = "%PORT%"; + mmgisglobal.ROOT_PATH = "%ROOT_PATH%"; + mmgisglobal.WEBSOCKET_ROOT_PATH = "%WEBSOCKET_ROOT_PATH%"; mmgisglobal.ENABLE_MMGIS_WEBSOCKETS = "%ENABLE_MMGIS_WEBSOCKETS%"; + mmgisglobal.MAIN_MISSION = "%MAIN_MISSION%"; + mmgisglobal.SKIP_CLIENT_INITIAL_LOGIN = "%SKIP_CLIENT_INITIAL_LOGIN%"; + mmgisglobal.THIRD_PARTY_COOKIES = "%THIRD_PARTY_COOKIES%"; // eslint-disable-next-line mmgisglobal.HOSTS = %HOSTS%; break; diff --git a/public/login.js b/public/login.js index 9bd59009..cbb40384 100644 --- a/public/login.js +++ b/public/login.js @@ -21,12 +21,11 @@ function login() { (data.hasOwnProperty("status") && data.status === "success") ) { //success - document.cookie = - "MMGISUser=" + - JSON.stringify({ - username: data.username, - token: data.token, - }); + document.cookie = "MMGISUser=;expires=Thu, 01 Jan 1970 00:00:01 GMT;"; + document.cookie = `MMGISUser=${JSON.stringify({ + username: data.username, + token: data.token, + })}${data.additional}`; window.location.reload(); } else { //error diff --git a/run/middleware.js b/run/middleware.js deleted file mode 100644 index 6cf3d19d..00000000 --- a/run/middleware.js +++ /dev/null @@ -1,93 +0,0 @@ -const fs = require("fs"); -const path = require("path"); -const rootDir = `${__dirname}/..`; - -const dirStore = {}; -const DIR_STORE_MAX_AGE = 3600000 / 2; // 1hours / 2 -function getTimePath(prepath, suffixPath, time) { - let dirs = dirStore[prepath]; - if (dirs) { - dirs = dirs.dirs; - time = time.replace(/:/g, "_").replace("Z", ""); - - let closestTimeWithoutGoingOver = dirs.filter(function (v) { - return v.split("Z-")[0] <= time; - }); - if (closestTimeWithoutGoingOver.length > 0) - closestTimeWithoutGoingOver = - closestTimeWithoutGoingOver[closestTimeWithoutGoingOver.length - 1]; - else return false; - - if (closestTimeWithoutGoingOver) - return `${prepath}${closestTimeWithoutGoingOver}${suffixPath}`; - - return false; - } - return false; -} - -const middleware = { - missions: function () { - return (req, res, next) => { - const originalUrl = req.originalUrl.split("?")[0]; - const relUrl = req.url.split("?")[0]; - - if (req.query.time != null && originalUrl.indexOf("_time_") > -1) { - const urlSplit = originalUrl.split("_time_"); - const relUrlSplit = relUrl.split("_time_"); - - if (dirStore[relUrlSplit[0]] == null) { - dirStore[relUrlSplit[0]] = { - lastUpdated: 0, - dirs: [], - }; - } - if ( - Date.now() - dirStore[relUrlSplit[0]].lastUpdated > - DIR_STORE_MAX_AGE - ) { - fs.readdir( - path.join(rootDir, urlSplit[0]), - { withFileTypes: true }, - (error, files) => { - if (!error) { - const dirs = files - .filter((item) => item.isDirectory()) - .map((item) => item.name); - - dirStore[relUrlSplit[0]].lastUpdated = Date.now(); - dirStore[relUrlSplit[0]].dirs = dirs.sort(); - - const newUrl = getTimePath( - relUrlSplit[0], - relUrlSplit[1], - req.query.time - ); - if (!newUrl) res.sendStatus(404); - else { - req.url = newUrl; - next(); - } - } else { - res.sendStatus(404); - } - } - ); - } else { - const newUrl = getTimePath( - relUrlSplit[0], - relUrlSplit[1], - req.query.time - ); - if (!newUrl) res.sendStatus(404); - else { - req.url = newUrl; - next(); - } - } - } else next(); - }; - }, -}; - -module.exports = { middleware }; diff --git a/sample.env b/sample.env index 4c28e2cb..4fbaed43 100644 --- a/sample.env +++ b/sample.env @@ -20,11 +20,19 @@ SECRET=aSecretKey #LOGGING VERBOSE_LOGGING=false -# Sets the Content-Security-Policy: frame-ancestors header to allow the embedding in external sites. default null +# Sets the Content-Security-Policy: frame-ancestors header to allow the embedding in external sites. default null, ex: FRAME_ANCESTORS='["https://*.jpl.nasa.gov"]' FRAME_ANCESTORS= +# Sets "SameSite=None; Secure" on the login cookie. Useful when using AUTH=local as an iframe within a cross-origin page. +THIRD_PARTY_COOKIES=false +# Sets the Content-Security-Policy: frame-src header to allow the embedding external sites with mmgis. default null, ex: FRAME_ANCESTORS='["https://*.jpl.nasa.gov"]'. +# Setting this will almost always have no effect +FRAME_SRC= -# Allows MMGIS to be deployed at a subpath. Use an absolute path. For example if serving at the subpath 'mmgis' is desired, set PUBLIC_URL to 'https://{domain}/mmgis/build' -PUBLIC_URL= +# Set MMGIS to be deployed under a subpath. For example if serving at the subpath 'https://{domain}/path/where/I/serve/mmgis' is desired, set `ROOT_PATH=/path/where/I/serve/mmgis`. If no subpath, leave blank. +ROOT_PATH= + +# Overrides ROOT_PATH's use when the client connects via websocket. Websocket url: `${ws_protocol}://${window.location.host}${WEBSOCKET_ROOT_PATH || ROOT_PATH || ''}/` +WEBSOCKET_ROOT_PATH= # Sets a clearance number for the website CLEARANCE_NUMBER= @@ -56,4 +64,16 @@ CSSO_LEAD_GROUP=A LEADS=["user1"] # If true, enables the backend MMGIS websockets to tell clients to update layers -ENABLE_MMGIS_SOCKETS=false +ENABLE_MMGIS_WEBSOCKETS=false +# If true, notifications are sent to /configure users whenever the configuration objects changes out from under them and puts (overridable) limits on saving. +ENABLE_CONFIG_WEBSOCKETS=false +# For use when ENABLE_CONFIG_WEBSOCKETS=true (if ENABLE_CONFIG_WEBSOCKETS=false, all saves will freely overwrite already). If true, gives /configure users the ability to override changes made to the configuration while they were working on it with their own. +ENABLE_CONFIG_OVERRIDE=false + +# If the new MAIN_MISSION ENV is set to a valid mission, skip the landing page and go straight to that mission. +# Other missions will still be accessible by either forcing the landing page (clicking the top-left M logo) or by going to a link directly. +MAIN_MISSION= + +# If true, MMGIS will not auto-login returning users. This can be useful when login is managed someplace else. +# The initial login process can be manually triggered with mmgisAPI.initialLogin() +SKIP_CLIENT_INITIAL_LOGIN= \ No newline at end of file diff --git a/run/build.js b/scripts/build.js similarity index 100% rename from run/build.js rename to scripts/build.js diff --git a/scripts/init-db.js b/scripts/init-db.js new file mode 100644 index 00000000..ee0bb428 --- /dev/null +++ b/scripts/init-db.js @@ -0,0 +1,135 @@ +const Sequelize = require("sequelize"); +const logger = require("../API/logger"); +require("dotenv").config({ path: __dirname + "/../.env" }); + +initializeDatabase() + .then(() => { + logger("info", "Finished successfully.", "connection"); + process.exit(); + }) + .catch((err) => { + logger("info", "Failed.", "connection", err); + process.exit(1); + }); + +async function initializeDatabase() { + return new Promise(async (resolve, reject) => { + const baseSequelize = new Sequelize( + null, + process.env.DB_USER, + process.env.DB_PASS, + { + host: process.env.DB_HOST, + dialect: "postgres", + logging: process.env.VERBOSE_LOGGING == "true" || false, + pool: { + max: 10, + min: 0, + acquire: 30000, + idle: 10000, + }, + } + ); + await baseSequelize + .query(`CREATE DATABASE "${process.env.DB_NAME}";`) + .then(() => { + logger( + "info", + `Created ${process.env.DB_NAME} database.`, + "connection" + ); + keepGoing(); + return null; + }) + .catch((err) => { + logger( + "info", + `Database ${process.env.DB_NAME} already exists. Nothing to do...`, + "connection" + ); + keepGoing(); + return null; + }); + + async function keepGoing() { + const sequelize = new Sequelize( + process.env.DB_NAME, + process.env.DB_USER, + process.env.DB_PASS, + { + host: process.env.DB_HOST, + dialect: "postgres", + logging: process.env.VERBOSE_LOGGING == "true" || false, + pool: { + max: 10, + min: 0, + acquire: 30000, + idle: 10000, + }, + } + ); + // Source: http://docs.sequelizejs.com/manual/installation/getting-started.html + sequelize + .authenticate() + .then(async () => { + logger("info", "Database connection is successful.", "connection"); + await sequelize + .query(`CREATE EXTENSION postgis;`) + .then(() => { + logger("info", `Created POSTGIS extension.`, "connection"); + resolve(); + return null; + }) + .catch((err) => { + logger( + "info", + `POSTGIS extension already exists. Nothing to do...`, + "connection" + ); + + return null; + }); + await sequelize + .query( + ` + CREATE TABLE "session" ( + "sid" varchar NOT NULL COLLATE "default", + "sess" json NOT NULL, + "expire" timestamp(6) NOT NULL + ) + WITH (OIDS=FALSE); + + ALTER TABLE "session" ADD CONSTRAINT "session_pkey" PRIMARY KEY ("sid") NOT DEFERRABLE INITIALLY IMMEDIATE; + + CREATE INDEX "IDX_session_expire" ON "session" ("expire");` + ) + .then(() => { + logger("info", `Created "session" table.`, "connection"); + return null; + }) + .catch((err) => { + logger( + "info", + `"session" table already exists. Nothing to do...`, + "connection" + ); + resolve(); + return null; + }); + resolve(); + }) + .catch((err) => { + logger( + "infrastructure_error", + "Unable to connect to the database.", + "connection", + null, + err + ); + reject(); + return null; + }); + } + return null; + }); +} diff --git a/scripts/middleware.js b/scripts/middleware.js new file mode 100644 index 00000000..add1d301 --- /dev/null +++ b/scripts/middleware.js @@ -0,0 +1,184 @@ +const fs = require("fs"); +const path = require("path"); +const sharp = require("sharp"); + +const rootDir = `${__dirname}/..`; +const rootDirMissions = `${rootDir}/Missions`; + +const dirStore = {}; +const DIR_STORE_MAX_AGE = 3600000 / 2; // 1hours / 2 + +async function compositeImageUrls(urls) { + try { + const output = await sharp({ + create: { + width: 256, + height: 256, + channels: 4, + background: { r: 0, g: 0, b: 0, alpha: 0 }, + }, + }) + .composite( + urls.map((url) => { + return { input: `${rootDirMissions}${url}` }; + }) + ) + .png() + .toBuffer(); + return output; + } catch (err) { + return false; + } +} + +async function onlyExistingFilepaths(paths) { + const filePromises = []; + paths.forEach((path) => { + filePromises.push( + new Promise(async (resolve, reject) => { + try { + await fs.promises.access(`${rootDirMissions}${path}`); + resolve(path); + } catch (err) { + resolve(false); + } + }) + ); + }); + const filesExist = await Promise.all(filePromises).catch((err) => {}); + + return paths.filter((p) => filesExist.includes(p)); +} + +function getTimePath(prepath, suffixPath, time, starttime, returnUrls) { + let dirs = dirStore[prepath]; + if (dirs) { + dirs = dirs.dirs; + time = time.replace(/:/g, "_").replace("Z", ""); + + if (starttime != null) { + starttime = starttime.replace(/:/g, "_").replace("Z", ""); + } + + let closestTimeWithoutGoingOver = dirs.filter(function (v) { + const s = v.split("--")[0].replace(/Z/g, ""); + if (s.indexOf("-to-") > -1) { + const t = s.split("-to-"); + + if (starttime != null) return !(time < t[0] || starttime > t[1]); + else return t[1] <= time; + } else { + if (starttime != null) return s >= starttime && s <= time; + else return s <= time; + } + }); + if (returnUrls) { + closestTimeWithoutGoingOver = closestTimeWithoutGoingOver.map((v) => { + return `${prepath}${v}${suffixPath}`; + }); + return closestTimeWithoutGoingOver; + } + + if (closestTimeWithoutGoingOver.length > 0) + closestTimeWithoutGoingOver = + closestTimeWithoutGoingOver[closestTimeWithoutGoingOver.length - 1]; + else return false; + + if (closestTimeWithoutGoingOver) + return `${prepath}${closestTimeWithoutGoingOver}${suffixPath}`; + + return false; + } + return false; +} + +async function sendImage(req, res, next, relUrlSplit) { + if (req.query.composite === "true") { + let compositeUrls = getTimePath( + relUrlSplit[0], + relUrlSplit[1], + req.query.time, + req.query.starttime, + true + ); + + compositeUrls = await onlyExistingFilepaths(compositeUrls); + // Never composite more than 100 images + compositeUrls = compositeUrls.slice(-100); + + if (compositeUrls.length > 1) { + const outputImage = await compositeImageUrls(compositeUrls); + if (outputImage === false) res.sendStatus(404); + else { + res.contentType("image/webp"); + res.send(Buffer.from(outputImage, "binary")); + } + } else if (compositeUrls.length === 1 && compositeUrls[0] != null) { + req.url = compositeUrls[0]; + next(); + } else { + res.sendStatus(404); + } + } else { + const newUrl = getTimePath( + relUrlSplit[0], + relUrlSplit[1], + req.query.time, + req.query.starttime + ); + if (!newUrl) res.sendStatus(404); + else { + req.url = newUrl; + next(); + } + } +} + +const middleware = { + missions: function () { + return (req, res, next) => { + const originalUrl = req.originalUrl.split("?")[0]; + const relUrl = req.url.split("?")[0]; + + if (req.query.time != null && originalUrl.indexOf("_time_") > -1) { + const urlSplit = originalUrl.split("_time_"); + const relUrlSplit = relUrl.split("_time_"); + + if (dirStore[relUrlSplit[0]] == null) { + dirStore[relUrlSplit[0]] = { + lastUpdated: 0, + dirs: [], + }; + } + + if ( + Date.now() - dirStore[relUrlSplit[0]].lastUpdated > + DIR_STORE_MAX_AGE + ) { + fs.readdir( + path.join(rootDir, urlSplit[0]), + { withFileTypes: true }, + (error, files) => { + if (!error) { + const dirs = files + .filter((item) => item.isDirectory()) + .map((item) => item.name); + + dirStore[relUrlSplit[0]].lastUpdated = Date.now(); + dirStore[relUrlSplit[0]].dirs = dirs.sort(); + + sendImage(req, res, next, relUrlSplit); + } else { + res.sendStatus(404); + } + } + ); + } else { + sendImage(req, res, next, relUrlSplit); + } + } else next(); + }; + }, +}; + +module.exports = { middleware }; diff --git a/run/server.js b/scripts/server.js similarity index 78% rename from run/server.js rename to scripts/server.js index bcd305d8..05969d24 100644 --- a/run/server.js +++ b/scripts/server.js @@ -2,6 +2,7 @@ require("dotenv").config(); const fs = require("fs"); const http = require("http"); +const { Pool } = require("pg"); var path = require("path"); const packagejson = require("../package.json"); var bodyParser = require("body-parser"); @@ -18,7 +19,6 @@ const rateLimit = require("express-rate-limit"); const compression = require("compression"); const session = require("express-session"); -var MemoryStore = require("memorystore")(session); const apiRouter = require("../API/Backend/APIs/routes/apis"); @@ -57,6 +57,14 @@ const isDevEnv = process.env.NODE_ENV === "development"; //Username to use when not logged in const guestUsername = "guest"; +const ROOT_PATH = isDevEnv ? "" : process.env.ROOT_PATH || ""; + +if (!(process.env.PUBLIC_URL == null || process.env.PUBLIC_URL == "")) + logger( + "warn", + `The 'PUBLIC_URL' env is deprecated. Please using 'ROOT_PATH' instead.` + ); + const rootDir = `${__dirname}/..`; /////////////////////////// @@ -83,16 +91,29 @@ permissions.users = process.env.CSSO_GROUPS const port = parseInt(process.env.PORT || "8888", 10); /** set the session for application */ +const cookieOptions = { maxAge: 86400000 }; +if (process.env.THIRD_PARTY_COOKIES === "true") { + cookieOptions.sameSite = "None"; + if (process.env.NODE_ENV === "production") cookieOptions.secure = true; +} + +const pool = new Pool({ + user: process.env.DB_USER, + host: process.env.DB_HOST, + database: process.env.DB_NAME, + password: process.env.DB_PASS, + port: process.env.DB_PORT || "5432", +}); app.use( session({ secret: process.env.SECRET || "Shhhh, it is a secret!", name: "MMGISSession", proxy: true, resave: false, - cookie: { maxAge: 86400000 }, + cookie: cookieOptions, saveUninitialized: false, - store: new MemoryStore({ - checkPeriod: 86400000, // prune expired entries every 24h + store: new (require("connect-pg-simple")(session))({ + pool, }), }) ); @@ -205,7 +226,7 @@ function stopGuests(req, res, next) { return; } - if (req.user == guestUsername) { + if (req.user == guestUsername || process.env.AUTH === "off") { res.send({ status: "failure", message: "User is not logged in." }); res.end(); return; @@ -342,10 +363,31 @@ function ensureUser() { ) { next(); } else { - res.render("login", { - user: req.user, - CLEARANCE_NUMBER: process.env.CLEARANCE_NUMBER || "CL##-####", - }); + if (req.headers.authorization) { + const remoteAddress = + req.headers["x-forwarded-for"] || req.connection.remoteAddress; + validateLongTermToken( + req.headers.authorization, + () => { + req.isLongTermToken = true; + next(); + }, + () => { + res.send({ status: "failure", message: "Unauthorized Token!" }); + logger( + "warn", + `Unauthorized token call made and rejected (from ${remoteAddress}, with token ${req.headers.authorization})`, + req.originalUrl, + req + ); + } + ); + } else { + res.render("login", { + user: req.user, + CLEARANCE_NUMBER: process.env.CLEARANCE_NUMBER || "CL##-####", + }); + } } return; }; @@ -373,6 +415,7 @@ let s = { swaggerUi, useSwaggerSchema, permissions, + ROOT_PATH, }; // Trust first proxy @@ -404,7 +447,7 @@ const helmet = require("helmet"); let helmetConfig = { contentSecurityPolicy: { directives: { - defaultSrc: ["'self'", "'unsafe-inline'", "'unsafe-eval'"], + defaultSrc: ["'self'", "blob:", "'unsafe-inline'", "'unsafe-eval'"], imgSrc: ["*", "data:", "blob:", "'unsafe-inline'"], styleSrc: ["*", "data:", "blob:", "'unsafe-inline'"], fontSrc: ["*", "data:", "blob:", "'unsafe-inline'"], @@ -412,6 +455,9 @@ let helmetConfig = { frameAncestors: process.env.FRAME_ANCESTORS ? JSON.parse(process.env.FRAME_ANCESTORS) : "none", + frameSrc: process.env.FRAME_SRC + ? JSON.parse(process.env.FRAME_SRC) + : "none", }, }, }; @@ -423,7 +469,7 @@ app.disable("x-powered-by"); app.disable("Origin"); app.use( - "/api/docs/main", + `${ROOT_PATH}/api/docs/main`, swaggerUi.serve, useSwaggerSchema(swaggerDocumentMain) ); @@ -488,46 +534,74 @@ setups.getBackendSetups(function (setups) { ) ); - app.use("/build", ensureUser(), express.static(path.join(rootDir, "/build"))); + // STATICS + app.use( - "/documentation", + `${ROOT_PATH}/build`, + ensureUser(), + express.static(path.join(rootDir, "/build")) + ); + app.use( + `${ROOT_PATH}/documentation`, express.static(path.join(rootDir, "/documentation")) ); - app.use("/docs/helps", express.static(path.join(rootDir, "/docs/helps"))); - app.use("/README.md", express.static(path.join(rootDir, "/README.md"))); - app.use("/config/login", express.static(path.join(rootDir, "/config/login"))); app.use( - "/config/css", + `${ROOT_PATH}/docs/helps`, + express.static(path.join(rootDir, "/docs/helps")) + ); + app.use( + `${ROOT_PATH}/README.md`, + express.static(path.join(rootDir, "/README.md")) + ); + app.use( + `${ROOT_PATH}/config/login`, + express.static(path.join(rootDir, "/config/login")) + ); + app.use( + `${ROOT_PATH}/config/css`, ensureUser(), express.static(path.join(rootDir, "/config/css")) ); app.use( - "/config/js", + `${ROOT_PATH}/config/js`, ensureUser(), express.static(path.join(rootDir, "/config/js")) ); app.use( - "/config/pre", + `${ROOT_PATH}/config/pre`, ensureUser(), express.static(path.join(rootDir, "/config/pre")) ); app.use( - "/config/fonts", + `${ROOT_PATH}/config/fonts`, ensureUser(), express.static(path.join(rootDir, "/config/fonts")) ); - app.use("/public", express.static(path.join(rootDir, "/public"))); + if (process.argv.includes("--with_examples")) + app.use( + `${ROOT_PATH}/examples`, + express.static(path.join(rootDir, "/examples")) + ); + app.use(`${ROOT_PATH}/public`, express.static(path.join(rootDir, "/public"))); app.use( - "/Missions", + `${ROOT_PATH}/Missions`, ensureUser(), middleware.missions(), express.static(path.join(rootDir, "/Missions")) ); if (isDevEnv) { - app.use("/css", ensureUser(), express.static(path.join(rootDir, "/css"))); - app.use("/src", ensureUser(), express.static(path.join(rootDir, "/src"))); + app.use( + `${ROOT_PATH}/css`, + ensureUser(), + express.static(path.join(rootDir, "/css")) + ); + app.use( + `${ROOT_PATH}/src`, + ensureUser(), + express.static(path.join(rootDir, "/src")) + ); } // Disable for now @@ -536,18 +610,18 @@ setups.getBackendSetups(function (setups) { // PAGES //docs - app.get("/docs", ensureUser(), ensureGroup(permissions.users), (req, res) => { - res.render("docs", {}); - }); - - //help - app.get("/help", ensureUser(), ensureGroup(permissions.users), (req, res) => { - res.render("help", {}); - }); + app.get( + `${ROOT_PATH}/docs`, + ensureUser(), + ensureGroup(permissions.users), + (req, res) => { + res.render("docs", {}); + } + ); // API //TEST - app.post("/api/test", function (req, res) { + app.post(`${ROOT_PATH}/api/test`, function (req, res) { res.send("Hello World!"); }); @@ -555,7 +629,7 @@ setups.getBackendSetups(function (setups) { //utils getprofile app.post( - "/api/utils/getprofile", + `${ROOT_PATH}/api/utils/getprofile`, ensureUser(), ensureGroup(permissions.users), function (req, res) { @@ -589,7 +663,7 @@ setups.getBackendSetups(function (setups) { //utils getbands app.post( - "/api/utils/getbands", + `${ROOT_PATH}/api/utils/getbands`, ensureUser(), ensureGroup(permissions.users), function (req, res) { @@ -666,31 +740,41 @@ setups.getBackendSetups(function (setups) { // passing to it an array of LDAP group names (which were loaded // from the permissions.json file at the top of the file). - app.get("/", ensureUser(), ensureGroup(permissions.users), (req, res) => { - let user = guestUsername; - if (process.env.AUTH === "csso" || req.user != null) user = req.user; - - let permission = "000"; - if (process.env.AUTH === "csso") permission = "001"; - if (req.session.permission) permission = req.session.permission; - - const groups = req.groups ? Object.keys(req.groups) : []; - res.render("../build/index.pug", { - user: user, - permission: permission, - groups: JSON.stringify(groups), - AUTH: process.env.AUTH, - NODE_ENV: process.env.NODE_ENV, - VERSION: packagejson.version, - FORCE_CONFIG_PATH: process.env.FORCE_CONFIG_PATH, - CLEARANCE_NUMBER: process.env.CLEARANCE_NUMBER, - ENABLE_MMGIS_WEBSOCKETS: process.env.ENABLE_MMGIS_WEBSOCKETS, - PORT: process.env.PORT, - HOSTS: JSON.stringify({ - scienceIntent: process.env.SCIENCE_INTENT_HOST, - }), - }); - }); + app.get( + `${ROOT_PATH}/`, + ensureUser(), + ensureGroup(permissions.users), + (req, res) => { + let user = guestUsername; + if (process.env.AUTH === "csso" || req.user != null) user = req.user; + + let permission = "000"; + if (process.env.AUTH === "csso") permission = "001"; + if (req.session.permission) permission = req.session.permission; + + const groups = req.groups ? Object.keys(req.groups) : []; + res.render("../build/index.pug", { + user: user, + permission: permission, + groups: JSON.stringify(groups), + AUTH: process.env.AUTH, + NODE_ENV: process.env.NODE_ENV, + VERSION: packagejson.version, + FORCE_CONFIG_PATH: process.env.FORCE_CONFIG_PATH, + CLEARANCE_NUMBER: process.env.CLEARANCE_NUMBER, + ENABLE_MMGIS_WEBSOCKETS: process.env.ENABLE_MMGIS_WEBSOCKETS, + MAIN_MISSION: process.env.MAIN_MISSION, + SKIP_CLIENT_INITIAL_LOGIN: process.env.SKIP_CLIENT_INITIAL_LOGIN, + THIRD_PARTY_COOKIES: process.env.THIRD_PARTY_COOKIES, + PORT: process.env.PORT, + ROOT_PATH: ROOT_PATH, + WEBSOCKET_ROOT_PATH: process.env.WEBSOCKET_ROOT_PATH, + HOSTS: JSON.stringify({ + scienceIntent: process.env.SCIENCE_INTENT_HOST, + }), + }); + } + ); } if (err) { logger("infrastructure_error", "MMGIS did not start!", "server"); diff --git a/run/start.js b/scripts/start.js similarity index 100% rename from run/start.js rename to scripts/start.js diff --git a/run/test.js b/scripts/test.js similarity index 100% rename from run/test.js rename to scripts/test.js diff --git a/src/css/mmgis.css b/src/css/mmgis.css index 90110632..8f53a7e7 100644 --- a/src/css/mmgis.css +++ b/src/css/mmgis.css @@ -146,6 +146,11 @@ body { #topBar { } +#topBarInfo { + width: 24px; + height: 24px; +} + #topBarHelp { width: 24px; height: 24px; @@ -301,6 +306,9 @@ body { .toolButton:hover { background: var(--color-a1-5) !important; } +.toolButtonSep:hover { + color: var(--color-c) !important; +} #tScreen { width: 100%; position: absolute; @@ -902,6 +910,7 @@ body { white-space: nowrap; user-select: none; cursor: pointer; + user-select: none; transition: all 0.2s cubic-bezier(0.445, 0.05, 0.55, 0.95), transform 0s ease-in-out; } diff --git a/src/css/mmgisUI.css b/src/css/mmgisUI.css index 4b3b7f64..768fc0a8 100644 --- a/src/css/mmgisUI.css +++ b/src/css/mmgisUI.css @@ -800,6 +800,54 @@ color: var(--color-c2); } +/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv toggle switch vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ +/* Use as: <div class="mmgisToggleSwitch" ><input type="checkbox" id="switch" /><label for="switch">Toggle</label></div> */ +.mmgisToggleSwitch { + position: relative; +} +.mmgisToggleSwitch input[type='checkbox'] { + height: 0; + width: 0; + visibility: hidden; +} + +.mmgisToggleSwitch label { + cursor: pointer; + text-indent: -9999px; + width: 36px; + height: 18px; + background: grey; + display: block; + border-radius: 2px; + position: relative; + top: -18px; +} + +.mmgisToggleSwitch label:after { + content: ''; + position: absolute; + top: 2px; + left: 2px; + width: 14px; + height: 14px; + background: #fff; + border-radius: 2px; + transition: 0.3s; +} + +.mmgisToggleSwitch input:checked + label { + background: var(--color-c); +} + +.mmgisToggleSwitch input:checked + label:after { + left: calc(100% - 2px); + transform: translateX(-100%); +} + +.mmgisToggleSwitch label:active:after { + width: 20px; +} + /*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv switch slider vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ .mmgisMultirange { @@ -1551,3 +1599,76 @@ input::-webkit-inner-spin-button { border-top-color: #fff; animation: layerLoadingSpin 1s ease-in-out infinite; } +#toast-container { + position: fixed !important; + bottom: 40px !important; + right: 5px !important; + z-index: 1001 !important; +} +.mmgisToast { + z-index: 1000; + border-radius: 2px; + top: 35px; + width: auto; + margin-top: 10px; + position: relative; + max-width: 100%; + height: auto; + line-height: 1.5em; + background-color: var(--color-mmgis); + padding: 10px 25px; + /* + font-size: 1.1rem; + font-weight: 300; +*/ + color: var(--color-f); + display: flex; + align-items: center; + justify-content: space-between; + cursor: default; +} +.mmgisToast.failure { + background-color: var(--color-r1); +} + +/*spinner1*/ +.mmgis-spinner1 { + -webkit-animation: spinner1_rotate 2s linear infinite; + animation: spinner1_rotate 2s linear infinite; + z-index: 2; + position: absolute; + top: 50%; + left: 50%; + margin: 0; + width: 20px; + height: 20px; + top: calc(50% - 10px); + left: calc(50% - 10px); +} +.mmgis-spinner1 .path { + stroke: var(--color-c); + stroke-linecap: round; + -webkit-animation: spinner1_dash 1.5s ease-in-out infinite; + animation: spinner1_dash 1.5s ease-in-out infinite; +} + +@keyframes spinner1_rotate { + 100% { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); + } +} +@keyframes spinner1_dash { + 0% { + stroke-dasharray: 1, 150; + stroke-dashoffset: 0; + } + 50% { + stroke-dasharray: 90, 150; + stroke-dashoffset: -35; + } + 100% { + stroke-dasharray: 90, 150; + stroke-dashoffset: -124; + } +} diff --git a/src/essence/Ancillary/ContextMenu.css b/src/essence/Ancillary/ContextMenu.css index 7dd2536e..fa933d64 100644 --- a/src/essence/Ancillary/ContextMenu.css +++ b/src/essence/Ancillary/ContextMenu.css @@ -2,10 +2,11 @@ position: absolute; background: var(--color-a); box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.3); - border: 1px solid var(--color-i); - border-radius: 3px; + border-radius: 1px; + font-size: 15px; z-index: 1; transition: opacity 0.2s cubic-bezier(0.39, 0.575, 0.565, 1); + overflow-y: auto; } .ContextMenuMap #contextMenuCursor { @@ -36,11 +37,52 @@ padding: 0; } .ContextMenuMap li { - padding: 4px 16px; + padding: 5px 16px 5px 16px; cursor: pointer; color: #aaa; + border-top: 1px solid var(--color-a1); + display: flex; transition: color 0.2s cubic-bezier(0.39, 0.575, 0.565, 1); + line-height: 18px; +} +.ContextMenuMap li:first-child { + border-top: none; +} +.ContextMenuMap li i { + padding: 0px 6px; } .ContextMenuMap li:hover { color: white; + background: var(--color-a1); +} + +.ContextMenuMap .contextMenuHeader { +} +.ContextMenuMap .contextMenuHeader span:nth-child(1) { + color: var(--color-h); + padding-right: 4px; + font-size: 12px; + line-height: 18px; } +.ContextMenuMap .contextMenuHeader span:nth-child(2) { + color: var(--color-a5); + padding-right: 4px; +} +.ContextMenuMap .contextMenuHeader span:nth-child(3) { + color: var(--color-a4); + font-size: 12px; + line-height: 18px; + padding-left: 4px; +} +.ContextMenuMap .contextMenuHeader span:nth-child(4) { + padding-left: 4px; + color: var(--color-a7); +} + +.ContextMenuMap .contextMenuFeatureItem { + margin-left: 15px; + padding-left: 15px; + font-size: 13px; + line-height: 15px; + border-left: 1px solid var(--color-a1); +} \ No newline at end of file diff --git a/src/essence/Ancillary/ContextMenu.js b/src/essence/Ancillary/ContextMenu.js index 202df8cb..0b600034 100644 --- a/src/essence/Ancillary/ContextMenu.js +++ b/src/essence/Ancillary/ContextMenu.js @@ -1,38 +1,86 @@ import $ from 'jquery' import * as d3 from 'd3' +import L_ from '../Basics/Layers_/Layers_' import F_ from '../Basics/Formulae_/Formulae_' import Map_ from '../Basics/Map_/Map_' import Coordinates from './Coordinates' +import { geojsonToWKT } from '@terraformer/wkt' + import './ContextMenu.css' var ContextMenu = { init: function () { this.remove() Map_.map.on('contextmenu', showContextMenuMap) + $('#_lithosphere_scene').on('contextmenu', showContextMenuMap) }, remove: function () { hideContextMenuMap() Map_.map.off('contextmenu', showContextMenuMap) + $('#_lithosphere_scene').off('contextmenu', showContextMenuMap) }, } function showContextMenuMap(e) { + const contextMenuActions = F_.getIn( + L_, + 'configData.coordinates.variables.rightClickMenuActions', + [] + ) + const contextMenuActionsFull = [] + e.latlng = e.latlng || Coordinates.getLatLng(true) + + const featuresAtClick = L_.getFeaturesAtPoint(e, true) + featuresAtClick.splice(100) + hideContextMenuMap(true) var x = e.originalEvent.clientX var y = e.originalEvent.clientY + // prettier-ignore var markup = [ - "<div class='ContextMenuMap' style='left: " + x + "px; top: " + y + "px;'>", - "<div id='contextMenuCursor'>", - "<div></div>", - "<div></div>", - "</div>", - "<ul>", - "<li id='contextMenuMapCopyCoords'>Copy Coordinates</div>", - "</ul>", - "</div>" - ].join('\n'); + `<div class='ContextMenuMap' style='left: ${x}px; top: ${y}px; max-height: ${window.innerHeight - y}px;'>`, + "<div id='contextMenuCursor'>", + "<div></div>", + "<div></div>", + "</div>", + "<ul>", + "<li id='contextMenuMapCopyCoords'>Copy Coordinates</li>", + contextMenuActions.map((a, idx) => { + const items = [] + if(a.for == null) { + items.push(`<li id='contextMenuAction_${idx}_0'>${a.name}${a.link != null ? `<div><i class='mdi mdi-open-in-new mdi-18px'></i>` : ''}</li>`) + contextMenuActionsFull.push({contextMenuAction: a, idx: idx, idx2: 0}) + } + return items.join('\n') + } ).join('\n'), + featuresAtClick.map((f, idx2) => { + const items = [] + const layerName = f.options.layerName + const displayName = L_.layers.data[layerName]?.display_name || layerName + const pv = L_.getLayersChosenNamePropVal(f.feature, layerName) + const key = Object.keys(pv)[0] + const val = pv[key] + items.push(`<li class='contextMenuHeader' id='contextMenuAction_${'head'}_${idx2}'><span>${f.feature.geometry.type}</span><span>${displayName}</span>-<span>${key}</span>:<span>${val}</span></li>`) + contextMenuActionsFull.push({contextMenuAction: { goto: true }, idx: 'head', idx2: idx2, feature: f}) + contextMenuActions.map((a, idx) => { + const forLower = a.for ? a.for.toLowerCase() : null + switch(forLower) { + case "polygon": + if( f.feature.geometry.type.toLowerCase() === forLower) { + items.push(`<li class='contextMenuFeatureItem' id='contextMenuAction_${idx}_${idx2}'>${a.name}${a.link != null ? `<div><i class='mdi mdi-open-in-new mdi-18px'></i>` : ''}</li>`) + contextMenuActionsFull.push({contextMenuAction: a, idx: idx, idx2: idx2, feature: f}) + } + break; + default: + } + } ) + return items.join('\n') + }).join('\n'), + "</ul>", + "</div>" + ].join('\n'); $('body').append(markup) @@ -47,6 +95,64 @@ function showContextMenuMap(e) { $('#contextMenuMapCopyCoords').text('Copy Coordinates') }, 2000) }) + + contextMenuActionsFull.forEach((c) => { + $(`#contextMenuAction_${c.idx}_${c.idx2}`).on('click', function () { + const a = c.contextMenuAction + const l = featuresAtClick[c.idx2] + if (a.link) { + let link = a.link + + const lnglat = Coordinates.getLngLat() + Object.keys(Coordinates.states).forEach((s) => { + if (link.indexOf(`{${s}[`) !== -1) { + const converted = Coordinates.convertLngLat( + lnglat[0], + lnglat[1], + s, + false, + true + ) + link = link.replace( + new RegExp(`{${s}\\[0\\]}`, 'gi'), + converted[0] + ) + link = link.replace( + new RegExp(`{${s}\\[1\\]}`, 'gi'), + converted[1] + ) + link = link.replace( + new RegExp(`{${s}\\[2\\]}`, 'gi'), + converted[2] + ) + } + }) + + const geom = F_.simplifyGeometry(l.feature.geometry, 0.0003) + + let wkt + if (link.indexOf(`{wkt}`) !== -1) { + wkt = geojsonToWKT(geom) + link = link.replace(new RegExp(`{wkt}`, 'gi'), wkt) + } + if (link.indexOf(`{wkt_}`) !== -1) { + wkt = geojsonToWKT(geom) + link = link.replace( + new RegExp(`{wkt_}`, 'gi'), + wkt.replace(/,/g, '_') + ) + } + window.open(link, '_blank').focus() + } + if (a.goto === true) { + if (l) { + if (typeof l.getBounds === 'function') + Map_.map.fitBounds(l.getBounds()) + else if (l._latlng) Map_.map.panTo(l._latlng) + } + } + }) + }) } function hideContextMenuMap(immediately) { diff --git a/src/essence/Ancillary/Coordinates.js b/src/essence/Ancillary/Coordinates.js index 487f772f..fd14484a 100644 --- a/src/essence/Ancillary/Coordinates.js +++ b/src/essence/Ancillary/Coordinates.js @@ -120,6 +120,16 @@ const Coordinates = { offset: [0, 20], }) + if ( + !( + L_.configData.time && + L_.configData.time.enabled === true && + L_.configData.time.visible === true + ) + ) { + $('#toggleTimeUI').css({ display: 'none' }) + $('#CoordinatesDiv').css({ marginRight: '0px' }) + } if (L_.configData.coordinates) { // ll if (L_.configData.coordinates.coordll == false) @@ -261,6 +271,15 @@ const Coordinates = { $('#toggleTimeUI').on('click', toggleTimeUI) Map_.map.on('mousemove', mouseLngLatMove) Map_.map.on('click', urlClick) + + if ( + L_.configData.time && + L_.configData.time.enabled === true && + L_.configData.time.visible === true && + L_.configData.time.initiallyOpen === true + ) { + toggleTimeUI() + } }, refreshDropdown: function () { const names = [] @@ -309,12 +328,19 @@ const Coordinates = { getLngLat: function () { return Coordinates.mouseLngLat }, - getLatLng: function () { + getLatLng: function (asObject) { + if (asObject) + return { + lat: Coordinates.mouseLngLat[1], + lng: Coordinates.mouseLngLat[0], + } return [Coordinates.mouseLngLat[1], Coordinates.mouseLngLat[0]] }, getAllCoordinates: function () { return { - description: d3.select('#mouseDesc').html(), + description: d3 + .select('#changeCoordTypeDropdown .dropy__title > span') + .html(), coordinates: [ ...d3.select('#mouseLngLat').html().split(','), d3.select('#mouseElev').html(), @@ -422,7 +448,8 @@ const Coordinates = { if (withDropdownChanges) { currentState.title = 'Relative to ' + - Map_.activeLayer.options.layerName + + L_.layers.data[Map_.activeLayer.options.layerName] + .display_name + ': ' + keyAsName Coordinates.refreshDropdown() @@ -468,7 +495,8 @@ const Coordinates = { if (withDropdownChanges) { currentState.title = 'Local Level - ' + - Map_.activeLayer.options.layerName + + L_.layers.data[Map_.activeLayer.options.layerName] + .display_name + ': ' + keyAsName Coordinates.refreshDropdown() @@ -754,12 +782,15 @@ function urlClick(e) { } function toggleTimeUI() { - const active = $(this).hasClass('active') - $(this).toggleClass('active') + const active = $('#toggleTimeUI').hasClass('active') + $('#toggleTimeUI').toggleClass('active') $('#timeUI').toggleClass('active') + const newBottom = active ? 0 : 40 const timeBottom = active ? -40 : 0 + Map_.map._fadeAnimated = active + $('#CoordinatesDiv').css({ bottom: newBottom + (UserInterface.pxIsTools || 0) + 'px', }) @@ -780,6 +811,10 @@ function toggleTimeUI() { $('#timeUI').css({ bottom: timeBottom + (UserInterface.pxIsTools || 0) + 'px', }) + + Object.keys(L_._onTimeUIToggleSubscriptions).forEach((k) => { + L_._onTimeUIToggleSubscriptions[k](!active) + }) } export default Coordinates diff --git a/src/essence/Ancillary/CursorInfo.js b/src/essence/Ancillary/CursorInfo.js index 6d1f28f5..408cde43 100644 --- a/src/essence/Ancillary/CursorInfo.js +++ b/src/essence/Ancillary/CursorInfo.js @@ -21,13 +21,15 @@ var CursorInfo = { .style('position', 'absolute') .style('left', 0) .style('top', 0) - .style('padding', '6px 9px 6px 9px') + .style('padding', '5px 9px 4px 9px') + .style('line-height', '22px') .style('border', '1px solid #17586E') .style('border-radius', '3px') .style('background-color', 'var(--color-a)') .style('color', '#DCDCDC') .style('font-weight', 'bold') .style('font-size', '16px') + .style('white-space', 'pre-wrap') //.style( 'box-shadow', '0px 5px 15px #000' ) .style('z-index', '60000000') .style('pointer-events', 'none') @@ -80,8 +82,24 @@ var CursorInfo = { : 'none' }) .style('display', 'block') - if (asHTML) CursorInfo.cursorInfoDiv.html(message) - else CursorInfo.cursorInfoDiv.text(message) + if ( + typeof message === 'object' && + !Array.isArray(message) && + message !== null + ) { + let messageFormatted = '' + const keys = Object.keys(message) + keys.forEach((k, idx) => { + if (typeof k === 'string') + messageFormatted += `<span style="color: var(--color-a5);">${k.capitalizeFirstLetter()}:</span> ${ + message[k] + }${idx === keys.length - 1 ? '' : '\n'}` + }) + CursorInfo.cursorInfoDiv.html(messageFormatted) + } else { + if (asHTML) CursorInfo.cursorInfoDiv.html(message) + else CursorInfo.cursorInfoDiv.text(message) + } if (time != null) { setTimeout(function () { diff --git a/src/essence/Ancillary/DataShaders.js b/src/essence/Ancillary/DataShaders.js index e26476d1..ebf60a2b 100644 --- a/src/essence/Ancillary/DataShaders.js +++ b/src/essence/Ancillary/DataShaders.js @@ -165,11 +165,11 @@ let DataShaders = { // Get minmax const getMinMax = (e) => { - if (!L_.layersGroup[name]) return + if (!L_.layers.layer[name]) return if ( - L_.layersGroup[name].minValue != null && - L_.layersGroup[name].maxValue != null && - L_.layersGroup[name].isDynamic === false + L_.layers.layer[name].minValue != null && + L_.layers.layer[name].maxValue != null && + L_.layers.layer[name].isDynamic === false ) { return } @@ -232,21 +232,21 @@ let DataShaders = { } } }) - L_.layersGroup[name].histogram = histo + L_.layers.layer[name].histogram = histo if (noDataValues) { if (noDataValues[0] != null) - L_.layersGroup[name].setUniform( + L_.layers.layer[name].setUniform( 'nodatavalue0', noDataValues[0] ) if (noDataValues[1] != null) - L_.layersGroup[name].setUniform( + L_.layers.layer[name].setUniform( 'nodatavalue1', noDataValues[1] ) if (noDataValues[2] != null) - L_.layersGroup[name].setUniform( + L_.layers.layer[name].setUniform( 'nodatavalue2', noDataValues[2] ) @@ -262,7 +262,7 @@ let DataShaders = { Map_.map.on('moveend', getMinMax) Map_.map.on('zoomend', getMinMax) - L_.layersGroup[name].on('tileload', getMinMax) + L_.layers.layer[name].on('tileload', getMinMax) }, lastMinMax: { min: null, max: null }, intervalMinMax: null, @@ -272,13 +272,13 @@ let DataShaders = { if ( DataShaders.colorize.lastMinMax.min == null || DataShaders.colorize.lastMinMax.max == null || - L_.layersGroup[name].isAnimated === false + L_.layers.layer[name].isAnimated === false ) { DataShaders.colorize.lastMinMax.min = min DataShaders.colorize.lastMinMax.max = max - L_.layersGroup[name].setUniform('minvalue', min) - L_.layersGroup[name].setUniform('maxvalue', max) - L_.layersGroup[name].reRender() + L_.layers.layer[name].setUniform('minvalue', min) + L_.layers.layer[name].setUniform('maxvalue', max) + L_.layers.layer[name].reRender() return } if (DataShaders.colorize.intervalMinMax) @@ -289,9 +289,9 @@ let DataShaders = { Math.abs(max - DataShaders.colorize.lastMinMax.max) < 1 ) { clearInterval(DataShaders.colorize.intervalMinMax) - L_.layersGroup[name].setUniform('minvalue', min) - L_.layersGroup[name].setUniform('maxvalue', max) - L_.layersGroup[name].reRender() + L_.layers.layer[name].setUniform('minvalue', min) + L_.layers.layer[name].setUniform('maxvalue', max) + L_.layers.layer[name].reRender() DataShaders.colorize.updateLegendMinMax( name, @@ -313,15 +313,15 @@ let DataShaders = { else if (DataShaders.colorize.lastMinMax.min < max) DataShaders.colorize.lastMinMax.max += maxRate - L_.layersGroup[name].setUniform( + L_.layers.layer[name].setUniform( 'minvalue', DataShaders.colorize.lastMinMax.min ) - L_.layersGroup[name].setUniform( + L_.layers.layer[name].setUniform( 'maxvalue', DataShaders.colorize.lastMinMax.max ) - L_.layersGroup[name].reRender() + L_.layers.layer[name].reRender() }, 50) }, // Like attach immediate events but on layer tool open @@ -332,7 +332,7 @@ let DataShaders = { function () { const layerName = $(this).attr('layername') const val = $(this).val() - L_.layersGroup[layerName].isDynamic = val === 'true' + L_.layers.layer[layerName].isDynamic = val === 'true' } ) //MODE @@ -342,7 +342,7 @@ let DataShaders = { const layerName = $(this).attr('layername') const parameter = $(this).attr('parameter') const val = $(this).val() - L_.layersGroup[layerName].isDiscrete = val === 'discrete' + L_.layers.layer[layerName].isDiscrete = val === 'discrete' DataShaders.colorize.setLegend( name, shaderObj, @@ -350,11 +350,11 @@ let DataShaders = { 'rampIdx' ) ) - L_.layersGroup[layerName].setUniform( + L_.layers.layer[layerName].setUniform( parameter, - L_.layersGroup[layerName].isDiscrete ? 1 : 0 + L_.layers.layer[layerName].isDiscrete ? 1 : 0 ) - L_.layersGroup[layerName].reRender() + L_.layers.layer[layerName].reRender() } ) //Animated @@ -363,7 +363,7 @@ let DataShaders = { function () { const layerName = $(this).attr('layername') const val = $(this).val() - L_.layersGroup[layerName].isAnimated = val === 'true' + L_.layers.layer[layerName].isAnimated = val === 'true' } ) @@ -376,7 +376,7 @@ let DataShaders = { name, shaderObj, min, - L_.layersGroup[name].maxValue + L_.layers.layer[name].maxValue ) } ) @@ -387,7 +387,7 @@ let DataShaders = { DataShaders.colorize.setMinMaxAnimated( name, shaderObj, - L_.layersGroup[name].minValue, + L_.layers.layer[name].minValue, max ) } @@ -456,7 +456,7 @@ let DataShaders = { DataShaders.colorize.setLegend(name, shaderObj, rampIdx) if (shaderObj.ramps) { const ramp = shaderObj.ramps[rampIdx != null ? rampIdx : 0] - L_.layersGroup[name].ramp = ramp + L_.layers.layer[name].ramp = ramp ramp.forEach((color, idx) => { let rgb // Hacky easy transparency support @@ -467,7 +467,7 @@ let DataShaders = { rgb = { r: 0, g: 0, b: 0 } } - L_.layersGroup[name].setUniform( + L_.layers.layer[name].setUniform( `ramp${idx}`, new Float32Array([ rgb.r / 255, @@ -477,7 +477,7 @@ let DataShaders = { ]) ) }) - L_.layersGroup[name].reRender() + L_.layers.layer[name].reRender() } }, setLegend: function (name, shaderObj, rampIdx) { @@ -485,7 +485,7 @@ let DataShaders = { let legend = [] - const isDiscrete = L_.layersGroup[name].isDiscrete + const isDiscrete = L_.layers.layer[name].isDiscrete if (shaderObj.ramps) { const ramp = shaderObj.ramps[rampIdx != null ? rampIdx : 0] ramp.forEach((color, idx) => { @@ -535,8 +535,8 @@ let DataShaders = { dontUpdateMinMix ) { const cname = name.replace(/ /g, '_') - if (min == null) min = L_.layersGroup[name].minValue - if (max == null) max = L_.layersGroup[name].maxValue + if (min == null) min = L_.layers.layer[name].minValue + if (max == null) max = L_.layers.layer[name].maxValue const isDiscrete = $(`#dataShader_${cname}_colorize_legend`).attr('isdiscrete') == 'true' @@ -585,12 +585,12 @@ let DataShaders = { }) // Histogram - if (L_.layersGroup[name].histogram) { + if (L_.layers.layer[name].histogram) { const histogram = [] const binSize = (Math.max(min, max) - Math.min(min, max)) / ramp.length const histoKeys = Object.keys( - L_.layersGroup[name].histogram + L_.layers.layer[name].histogram ) for ( let v = Math.min(min, max); @@ -606,7 +606,7 @@ let DataShaders = { ) .forEach((value) => { binValue += - L_.layersGroup[name].histogram[value] + L_.layers.layer[name].histogram[value] }) histogram.push(binValue) } @@ -641,8 +641,8 @@ let DataShaders = { } if (!dontUpdateMinMix) { - L_.layersGroup[name].minValue = min - L_.layersGroup[name].maxValue = max + L_.layers.layer[name].minValue = min + L_.layers.layer[name].maxValue = max $( `.dataShader_${cname}_colorize_minValue input[parameter=min]` diff --git a/src/essence/Ancillary/Description.js b/src/essence/Ancillary/Description.js index 566966c8..4fa1a534 100644 --- a/src/essence/Ancillary/Description.js +++ b/src/essence/Ancillary/Description.js @@ -5,7 +5,7 @@ import F_ from '../Basics/Formulae_/Formulae_' import tippy from 'tippy.js' -var Description = { +const Description = { inited: false, waitingOnUpdate: false, descCont: null, @@ -78,15 +78,15 @@ var Description = { let infos = [] - for (let layer in this.L_.layersNamed) { - let l = this.L_.layersNamed[layer] + for (let layer in this.L_.layers.data) { + let l = this.L_.layers.data[layer] if ( - this.L_.layersGroup[layer] && + this.L_.layers.layer[layer] && l.hasOwnProperty('variables') && l.variables.hasOwnProperty('info') && l.variables.info.hasOwnProperty('length') ) { - let layers = this.L_.layersGroup[layer]._layers + let layers = this.L_.layers.layer[layer]._layers let newInfo = '' for (let i = 0; i < l.variables.info.length; i++) { let which = @@ -100,7 +100,9 @@ var Description = { 0 ) : Object.keys(layers).length - 1 - let feature = layers[Object.keys(layers)[which]].feature + let feature = layers[Object.keys(layers)[which]]?.feature + if (feature == null) continue + let infoText = F_.bracketReplace( l.variables.info[i].value, feature.properties @@ -154,6 +156,12 @@ var Description = { }) }, updatePoint: function (activeLayer) { + if ( + activeLayer == null || + Description.L_.layers.data[activeLayer.options.layerName] == null + ) + return + this.descCont.style('display', 'flex') $('.mainDescription').animate( { @@ -170,11 +178,11 @@ var Description = { var links = "<span style='padding-left: 4px;'></span>" if ( - this.L_.layersNamed[activeLayer.options.layerName] && - this.L_.layersNamed[activeLayer.options.layerName].variables + this.L_.layers.data[activeLayer.options.layerName] && + this.L_.layers.data[activeLayer.options.layerName].variables ) { let v = - this.L_.layersNamed[activeLayer.options.layerName].variables + this.L_.layers.data[activeLayer.options.layerName].variables if (v.links) { links = '' for (let i = 0; i < v.links.length; i++) { @@ -228,7 +236,10 @@ var Description = { ')</div>' Description.descPointInner.html( - activeLayer.options.layerName + ': ' + keyAsName + Description.L_.layers.data[activeLayer.options.layerName] + .display_name + + ': ' + + keyAsName ) Description.descPointLinks.html(links) diff --git a/src/essence/Ancillary/Login/Login.css b/src/essence/Ancillary/Login/Login.css index e8b0e176..7cf1cdf2 100644 --- a/src/essence/Ancillary/Login/Login.css +++ b/src/essence/Ancillary/Login/Login.css @@ -5,7 +5,11 @@ left: 0; width: 100%; height: 100%; - background: linear-gradient(to top, rgba(29, 31, 32, 0.95), rgba(29, 31, 32, 0.9)); + background: linear-gradient( + to top, + rgba(29, 31, 32, 0.95), + rgba(29, 31, 32, 0.9) + ); z-index: 999999; opacity: 0; pointer-events: none !important; @@ -156,3 +160,15 @@ #forceSignupButton:hover { color: var(--color-mmgis); } +#loginDiv #loginUser.attention { + animation: 0.8s attention ease infinite alternate; +} + +@keyframes attention { + 0% { + background: var(--color-r1); + } + 100% { + background: var(--color-red); + } +} diff --git a/src/essence/Ancillary/Login/Login.js b/src/essence/Ancillary/Login/Login.js index 51dbd590..ee9b5d8d 100644 --- a/src/essence/Ancillary/Login/Login.js +++ b/src/essence/Ancillary/Login/Login.js @@ -4,6 +4,7 @@ import * as d3 from 'd3' import F_ from '../../Basics/Formulae_/Formulae_' import L_ from '../../Basics/Layers_/Layers_' import ToolController_ from '../../Basics/ToolController_/ToolController_' +import tippy from 'tippy.js' import calls from '../../../pre/calls' @@ -90,7 +91,6 @@ var Login = { Login.loginBar .append('div') .attr('id', 'loginUser') - .attr('title', Login.loggedIn ? Login.username : '') .style('text-align', 'center') .style('font-size', '12px') .style('font-weight', 'bold') @@ -110,6 +110,18 @@ var Login = { .style('transition', 'opacity 0.2s ease-out') .html(Login.loggedIn ? Login.username[0] : '') + if (Login.loggedIn) { + if (window._tippyLoginUser && window._tippyLoginUser[0]) + window._tippyLoginUser[0].setContent(Login.username) + else + window._tippyLoginUser = tippy('#loginUser', { + content: Login.username, + placement: 'bottom-end', + theme: 'blue', + allowHTML: true, + }) + } + //Show signup for admins if ( window.mmgisglobal.AUTH === 'local' && @@ -221,29 +233,33 @@ var Login = { : 'mdi mdi-login mdi-18px' ) - //Sign in at page load from cookie if possible + // Sign in at page load from cookie if possible if ( window.mmgisglobal.AUTH !== 'off' && - window.mmgisglobal.AUTH !== 'csso' + window.mmgisglobal.AUTH !== 'csso' && + window.mmgisglobal.SKIP_CLIENT_INITIAL_LOGIN != 'true' ) { - calls.api( - 'login', - { - useToken: true, - }, - function (d) { - Login.username = d.username - window.mmgisglobal.user = Login.username - window.mmgisglobal.groups = d.groups - - loginSuccess(d) - }, - function (d) { - loginSuccess(d, true) - } - ) + Login.initialLogin() } }, + initialLogin() { + calls.api( + 'login', + { + useToken: true, + }, + function (d) { + Login.username = d.username + window.mmgisglobal.user = Login.username + window.mmgisglobal.groups = d.groups + + loginSuccess(d) + }, + function (d) { + loginSuccess(d, true) + } + ) + }, createModal: function () { this.removeModal() @@ -364,7 +380,6 @@ var Login = { }) values['mission'] = L_.mission - values['master'] = L_.masterdb if (!Login.signUp) { if (validate.username && validate.password) { @@ -479,12 +494,17 @@ var Login = { function loginSuccess(data, ignoreError) { if (data.status == 'success') { - document.cookie = - 'MMGISUser=' + - JSON.stringify({ - username: data.username, - token: data.token, - }) + document.cookie = 'MMGISUser=;expires=Thu, 01 Jan 1970 00:00:01 GMT;' + document.cookie = `MMGISUser=${JSON.stringify({ + username: data.username, + token: data.token, + })}${ + mmgisglobal.THIRD_PARTY_COOKIES === 'true' + ? `; SameSite=None;${ + mmgisglobal.NODE_ENV === 'production' ? ' Secure' : '' + }` + : '' + }` Login.loggedIn = true $('#loginErrorMessage').animate({ opacity: '0' }, 500) @@ -533,6 +553,18 @@ function loginSuccess(data, ignoreError) { background: Login.loggedIn ? 'var(--color-a)' : 'transparent', }) .html(Login.username[0]) + + if (Login.loggedIn) { + if (window._tippyLoginUser && window._tippyLoginUser[0]) + window._tippyLoginUser[0].setContent(Login.username) + else + window._tippyLoginUser = tippy('#loginUser', { + content: Login.username, + placement: 'bottom-end', + theme: 'blue', + allowHTML: true, + }) + } } else { document.cookie = 'MMGISUser=;expires=Thu, 01 Jan 1970 00:00:01 GMT;' diff --git a/src/essence/Ancillary/Modal.css b/src/essence/Ancillary/Modal.css index d16e183f..58649602 100644 --- a/src/essence/Ancillary/Modal.css +++ b/src/essence/Ancillary/Modal.css @@ -1,4 +1,4 @@ -#mmgisModal { +.mmgisModal { overflow: auto; position: fixed; top: 0; @@ -6,7 +6,7 @@ width: 100%; height: 100%; background: linear-gradient(to top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.5)); - z-index: 999999; + z-index: 9998; opacity: 0; } diff --git a/src/essence/Ancillary/Modal.js b/src/essence/Ancillary/Modal.js index d5b0c71f..d5573fb0 100644 --- a/src/essence/Ancillary/Modal.js +++ b/src/essence/Ancillary/Modal.js @@ -9,12 +9,17 @@ import $ from 'jquery' import './Modal.css' const Modal = { - _onRemoveCallback: null, - set: function (html, onAddCallback, onRemoveCallback) { - if ($('#mmgisModal')) $('#mmgisModal').remove() + _onRemoveCallback: {}, + _activeModalIds: {}, + set: function (html, onAddCallback, onRemoveCallback, modalId) { + modalId = modalId || 0 + Modal._activeModalIds[modalId] = true + const id = `mmgisModal_${modalId}` + const elmId = `#${id}` + if ($(elmId)) $(elmId).remove() // prettier-ignore $('body').append([ - "<div id='mmgisModal'>", + `<div id='${id}' class='mmgisModal dontCloseWhenClicked'>`, "<div id='mmgisModalClose'><i class='mdi mdi-close mdi-24px'></i></div>", "<div id='mmgisModalInner'>", html, @@ -22,17 +27,17 @@ const Modal = { "</div>" ].join('\n')) - if (typeof onAddCallback === 'function') onAddCallback('mmgisModal') + if (typeof onAddCallback === 'function') onAddCallback(id) - $('#mmgisModal').on('click', function () { - Modal.remove() - }) - $('#mmgisModalInner').on('click', function (e) { - e.stopPropagation() + $(elmId).on('click', (e) => { + if (!$(e.target).parents().hasClass('dontCloseWhenClicked')) + Modal.remove(false, modalId) }) - $('#main-container').css({ filter: 'blur(3px)' }) - $('#mmgisModal').animate( + $('#main-container').css({ + filter: `blur(${3 * Object.keys(Modal._activeModalIds).length}px)`, + }) + $(elmId).animate( { opacity: 1, }, @@ -40,25 +45,33 @@ const Modal = { ) if (typeof onRemoveCallback === 'function') - Modal._onRemoveCallback = onRemoveCallback - else Modal._onRemoveCallback = null + Modal._onRemoveCallback[modalId] = onRemoveCallback + else Modal._onRemoveCallback[modalId] = null }, //Remove everything CursorInfo created - remove: function (isImmediate) { + remove: function (isImmediate, modalId) { + modalId = modalId || 0 + const elmId = `#mmgisModal_${modalId}` const time = isImmediate ? 0 : 500 - if (typeof Modal._onRemoveCallback === 'function') - Modal._onRemoveCallback() - Modal._onRemoveCallback = null + if (typeof Modal._onRemoveCallback[modalId] === 'function') + Modal._onRemoveCallback[modalId]() + Modal._onRemoveCallback[modalId] = null - $('#main-container').css({ filter: 'blur(0px)' }) - $('#mmgisModal').animate( + $('#main-container').css({ + filter: `blur(${ + 3 * (Object.keys(Modal._activeModalIds).length - 1) + }px)`, + }) + $(elmId).animate( { opacity: 0, }, time, function () { - $('#mmgisModal').remove() + $(elmId).remove() + + delete Modal._activeModalIds[modalId] } ) }, diff --git a/src/essence/Ancillary/QueryURL.js b/src/essence/Ancillary/QueryURL.js index e8ec9bf4..89ee3dd3 100644 --- a/src/essence/Ancillary/QueryURL.js +++ b/src/essence/Ancillary/QueryURL.js @@ -1,5 +1,6 @@ import * as moment from 'moment' +import F_ from '../Basics/Formulae_/Formulae_' import L_ from '../Basics/Layers_/Layers_' import T_ from '../Basics/ToolController_/ToolController_' import calls from '../../pre/calls' @@ -153,6 +154,9 @@ var QueryURL = { } if (startTime !== false) { + // Parse to an int if a unix timestamp + if (F_.isStringNumeric(startTime)) startTime = parseInt(startTime) + const date = new moment(startTime) if (!isNaN(date) && date.isValid()) { L_.FUTURES.startTime = date @@ -162,6 +166,8 @@ var QueryURL = { } if (endTime !== false) { + if (F_.isStringNumeric(endTime)) endTime = parseInt(endTime) + const date = new moment(endTime) if (!isNaN(date) && date.isValid()) { L_.FUTURES.endTime = date @@ -342,17 +348,17 @@ var QueryURL = { //on var layersOnString = '' - for (var l in L_.toggledArray) { - if (L_.toggledArray[l] && L_.layersDataByName[l].type !== 'header') + for (var l in L_.layers.on) { + if (L_.layers.on[l] && L_.layers.data[l].type !== 'header') layersOnString += - l + '$' + parseFloat(L_.opacityArray[l]).toFixed(2) + ',' + l + '$' + parseFloat(L_.layers.opacity[l]).toFixed(2) + ',' } layersOnString = layersOnString.substring(0, layersOnString.length - 1) if (layersOnString.length > 0) urlAppendage += '&on=' + layersOnString //selected if (L_.lastActivePoint.layerName != null) { - if (L_.toggledArray[L_.lastActivePoint.layerName]) + if (L_.layers.on[L_.lastActivePoint.layerName]) urlAppendage += '&selected=' + L_.lastActivePoint.layerName + @@ -375,7 +381,7 @@ var QueryURL = { if (L_.FUTURES.startTime) urlAppendage += '&startTime=' + startTime if (L_.FUTURES.endTime) urlAppendage += '&endTime=' + endTime - var url = urlAppendage + var url = encodeURI(urlAppendage) if (shortenURL) { calls.api( diff --git a/src/essence/Ancillary/Search.js b/src/essence/Ancillary/Search.js index 894fab18..bf1d284d 100644 --- a/src/essence/Ancillary/Search.js +++ b/src/essence/Ancillary/Search.js @@ -1,7 +1,7 @@ import $ from 'jquery' import F_ from '../Basics/Formulae_/Formulae_' //jqueryUI -import turf from 'turf' +import { center } from '@turf/turf' import * as d3 from 'd3' import Dropy from '../../external/Dropy/dropy' @@ -40,6 +40,7 @@ var Search = { MMWebGISInterface: null, searchvars: {}, searchFields: {}, + adjustedFieldUUIDs: [], adjustedFieldNames: [], type: 'geojson', lastGeodatasetLayerName: null, @@ -51,12 +52,12 @@ var Search = { //Get search variables this.searchvars = {} - for (let l in L_.layersNamed) { + for (let l in L_.layers.data) { if ( - L_.layersNamed[l].variables && - L_.layersNamed[l].variables.search + L_.layers.data[l].variables && + L_.layers.data[l].variables.search ) - this.searchvars[l] = L_.layersNamed[l].variables.search + this.searchvars[l] = L_.layers.data[l].variables.search } // Nothing configured so don't even render it @@ -87,14 +88,16 @@ function interfaceWithMMWebGIS(classSel) { cont.selectAll('*').remove() cont.html(markup) + Search.adjustedFieldUUIDs = [] Search.adjustedFieldNames = [] for (let l in Search.searchFields) { if ( - L_.layersNamed[l] && - (L_.layersNamed[l].type == 'vector' || - L_.layersNamed[l].type == 'vectortile') + L_.layers.data[l] && + (L_.layers.data[l].type == 'vector' || + L_.layers.data[l].type == 'vectortile') ) { - Search.adjustedFieldNames.push(l) + Search.adjustedFieldUUIDs.push(l) + Search.adjustedFieldNames.push(L_.layers.data[l].display_name) } } @@ -102,9 +105,9 @@ function interfaceWithMMWebGIS(classSel) { Dropy.construct(Search.adjustedFieldNames, 'Search Layer...', 0) ) Dropy.init($('#SearchType'), function (idx) { - changeSearchField(Search.adjustedFieldNames[idx]) + changeSearchField(Search.adjustedFieldUUIDs[idx]) }) - changeSearchField(Search.adjustedFieldNames[0]) + changeSearchField(Search.adjustedFieldUUIDs[0]) d3.select('#SearchGo').on('click', searchGo) d3.select('#SearchSelect').on('click', searchSelect) @@ -186,9 +189,9 @@ async function changeSearchField(val, selectedPlaceholder) { if (Map_ != null) { Search.lname = val - Search.layerType = L_.layersNamed[Search.lname].type - if (L_.toggledArray[Search.lname] !== true) { - await L_.toggleLayer(L_.layersNamed[Search.lname]) + Search.layerType = L_.layers.data[Search.lname].type + if (L_.layers.on[Search.lname] !== true) { + await L_.toggleLayer(L_.layers.data[Search.lname]) const layerCheck = $( `#LayersTool${Search.lname.replace( @@ -211,17 +214,19 @@ async function changeSearchField(val, selectedPlaceholder) { Search.arrayToSearch = [] let data try { - data = L_.layersGroup[Search.lname].toGeoJSON(L_.GEOJSON_PRECISION) + data = L_.layers.layer[Search.lname].toGeoJSON(L_.GEOJSON_PRECISION) } catch (err) { data = { features: [] } } - var props - for (var i = 0; i < data.features.length; i++) { + + let props + for (let i = 0; i < data.features.length; i++) { props = data.features[i].properties Search.arrayToSearch.push( getSearchFieldStringForFeature(Search.lname, props) ) } + if (Search.arrayToSearch[0]) { if (!isNaN(Search.arrayToSearch[0])) Search.arrayToSearch.sort(function (a, b) { @@ -285,12 +290,12 @@ function searchGeodatasets() { var r = d.body[0] let selectTimeout = setTimeout(() => { - L_.layersGroup[Search.lname].off('load') + L_.layers.layer[Search.lname].off('load') selectFeature() }, 1500) - L_.layersGroup[Search.lname].on('load', function (event) { - L_.layersGroup[Search.lname].off('load') + L_.layers.layer[Search.lname].on('load', function (event) { + L_.layers.layer[Search.lname].off('load') clearTimeout(selectTimeout) selectFeature() }) @@ -298,9 +303,9 @@ function searchGeodatasets() { [r.coordinates[1], r.coordinates[0]], Map_.mapScaleZoom || Map_.map.getZoom() ) - if (!L_.toggledArray[Search.lname]) { + if (!L_.layers.on[Search.lname]) { wasOff = true - L_.toggleLayer(L_.layersNamed[Search.lname]) + L_.toggleLayer(L_.layers.data[Search.lname]) const layerCheck = $( `#LayersTool${Search.lname.replace( /\s/g, @@ -314,14 +319,14 @@ function searchGeodatasets() { } function selectFeature() { - var vts = L_.layersGroup[Search.lname]._vectorTiles + var vts = L_.layers.layer[Search.lname]._vectorTiles for (var i in vts) { for (var j in vts[i]._features) { var feature = vts[i]._features[j].feature if (feature.properties[key] == value) { feature._layerName = vts[i].options.layerName feature._layer = feature - L_.layersGroup[Search.lname]._events.click[0].fn({ + L_.layers.layer[Search.lname]._events.click[0].fn({ layer: feature, sourceTarget: feature, }) @@ -355,13 +360,13 @@ function doWithSearch(doX, forceX, forceSTS, isURLSearch, value) { if (forceSTS == 'false') sTS = Search.lname else sTS = forceSTS - var markers = L_.layersGroup[Search.lname] + var markers = L_.layers.layer[Search.lname] var selectLayers = [] var gotoLayers = [] // Turn the layer on if it's off - if (!L_.toggledArray[Search.lname]) { - L_.toggleLayer(L_.layersNamed[Search.lname]) + if (!L_.layers.on[Search.lname]) { + L_.toggleLayer(L_.layers.data[Search.lname]) const layerCheck = $( `#LayersTool${Search.lname.replace( /\s/g, @@ -453,10 +458,10 @@ function makeSearchFields(vars) { } function getSearchFieldStringForFeature(name, props) { - var str = '' + let str = '' if (Search.searchFields.hasOwnProperty(name)) { - var sf = Search.searchFields[name] //sf for search field - for (var i = 0; i < sf.length; i++) { + const sf = Search.searchFields[name] //sf for search field + for (let i = 0; i < sf.length; i++) { switch (sf[i][0].toLowerCase()) { case '': //no function str += F_.getIn(props, sf[i][1]) @@ -505,8 +510,9 @@ function getMapZoomCoordinate(layers) { var longitudeValidRange = [-180, 180] for (var i = 0; i < layers.length; i++) { - const center = turf.center(layers[i].feature)?.geometry - ?.coordinates || [-1001, -1001] + const center = center(layers[i].feature)?.geometry?.coordinates || [ + -1001, -1001, + ] var latitude = center[1] var longitude = center[0] diff --git a/src/essence/Ancillary/Stylize.js b/src/essence/Ancillary/Stylize.js index b4a65ddf..6aa52e47 100644 --- a/src/essence/Ancillary/Stylize.js +++ b/src/essence/Ancillary/Stylize.js @@ -73,6 +73,12 @@ export function stylize() { ) $('#favicon').attr('href', L_.configData.look.logourl) } + if (L_.configData.look.infourl && L_.configData.look.infourl != '') { + $('#topBarInfo').on('click', function () { + let win = window.open(L_.configData.look.infourl, '_mmgisinfo') + win.focus() + }) + } if (L_.configData.look.helpurl && L_.configData.look.helpurl != '') { $('#topBarHelp').on('click', function () { let win = window.open(L_.configData.look.helpurl, '_mmgishelp') diff --git a/src/essence/Ancillary/TimeControl.js b/src/essence/Ancillary/TimeControl.js index 0b3ccc58..3b11fa76 100644 --- a/src/essence/Ancillary/TimeControl.js +++ b/src/essence/Ancillary/TimeControl.js @@ -2,6 +2,7 @@ import * as d3 from 'd3' import * as moment from 'moment' import $ from 'jquery' +import F_ from '../Basics/Formulae_/Formulae_' import L_ from '../Basics/Layers_/Layers_' import Map_ from '../Basics/Map_/Map_' import TimeUI from './TimeUI' @@ -16,10 +17,10 @@ const relativeTimeFormat = new RegExp( var TimeControl = { enabled: false, isRelative: true, - currentTime: new Date().toISOString().split('.')[0] + 'Z', + currentTime: null, timeOffset: '01:00:00', - startTime: new Date().toISOString().split('.')[0] + 'Z', - endTime: new Date().toISOString().split('.')[0] + 'Z', + startTime: null, + endTime: null, relativeStartTime: '01:00:00', relativeEndTime: '00:00:00', globalTimeFormat: null, @@ -37,48 +38,16 @@ var TimeControl = { return } - // prettier-ignore - const markup = [ - "<label id='currentTimeLabel'></label>", - - "<label id='startTimeLabel'>Start:</label>", - `<input id='startTimeInput' value='${this.startTime}'></input>`, - - "<label id='endTimeLabel'>End:</label>", - `<input id='endTimeInput' value='${this.endTime}'></input>`, - - "<label id='offsetTime'>Offset:</label>", - `<input id='offsetTimeInput' value='${this.timeOffset}'></input>`, - - `<input id='isRelativeTime' type='checkbox' ${this.isRelative ? 'checked' : ''}></input>`, - "<label id='isRelativeTimeLabel'>Relative Time</label>", - - "<label id='startRelativeTime'>Start: -</label>", - `<input id='startRelativeTimeInput' value='${this.relativeStartTime}'></input>`, - - "<label id='endRelativeTime'>End: +</label>", - `<input id='endRelativeTimeInput' value='${this.relativeEndTime}'></input>`, - ].join('\n'); - - TimeControl.timeUI = TimeUI.init(timeInputChange) + TimeControl.timeUI = TimeUI.init(timeInputChange, TimeControl.enabled) //updateTime() - if (L_.configData.time.visible == false) { - TimeControl.toggleTimeUI(false) - } - //initLayerDataTimes() - }, - fina: function () { initLayerTimes() + initLayerDataTimes() }, - toggleTimeUI: function (isOn) { - d3.select('#timeUI').style('visibility', function () { - if (!isOn) $('#toggleTimeUI').click() - - return isOn === true ? 'visible' : 'hidden' - }) - return isOn + fina: function () { + if ((TimeControl.enabled = true && TimeControl.timeUI != null)) + TimeControl.timeUI.fina() }, setTime: function ( startTime, @@ -136,15 +105,16 @@ var TimeControl = { }, setLayerTime: function (layer, startTime, endTime) { if (typeof layer == 'string') { - layer = L_.layersNamed[layer] + layer = L_.asLayerUUID(layer) + layer = L_.layers.data[layer] } if (layer.time && layer.time.enabled == true) { layer.time.start = startTime layer.time.end = endTime - d3.select('.starttime.' + layer.name.replace(/\s/g, '')).text( + d3.select('.starttime.' + F_.getSafeName(layer.name)).text( layer.time.start ) - d3.select('.endtime.' + layer.name.replace(/\s/g, '')).text( + d3.select('.endtime.' + F_.getSafeName(layer.name)).text( layer.time.end ) @@ -165,56 +135,82 @@ var TimeControl = { }, getLayerStartTime: function (layer) { if (typeof layer == 'string') { - layer = L_.layersNamed[layer] + layer = L_.asLayerUUID(layer) + layer = L_.layers.data[layer] } if (layer.time) return layer.time.start return false }, getLayerEndTime: function (layer) { if (typeof layer == 'string') { - layer = L_.layersNamed[layer] + layer = L_.asLayerUUID(layer) + layer = L_.layers.data[layer] } if (layer.time) return layer.time.end return false }, - reloadLayer: async function (layer, evenIfOff) { + reloadLayer: async function (layer, evenIfOff, evenIfControlled) { // reload layer if (typeof layer == 'string') { - layer = L_.layersNamed[layer] + layer = L_.asLayerUUID(layer) + layer = L_.layers.data[layer] } + + if (L_.layers.layer[layer.name] === null) return + var layerTimeFormat = d3.utcFormat(layer.time.format) layer.time.current = TimeControl.currentTime // keeps track of when layer was refreshed - if (layer.type == 'tile') { - if (layer.time && layer.time.enabled == true) { + if (layer.type === 'tile') { + if (layer.time && layer.time.enabled === true) { TimeControl.setLayerWmsParams(layer) } - - if (L_.toggledArray[layer.name] || evenIfOff) { - L_.toggleLayer(layer) - L_.toggleLayer(layer) + if (evenIfControlled === true || layer.controlled !== true) { + if (L_.layers.on[layer.name] || evenIfOff) { + L_.layers.layer[layer.name].refresh() + } } } else { + var originalUrl = layer.url + // replace start/endtime keywords - if (layer.time && layer.time.enabled == true) { - var originalUrl = layer.url - layer.url = layer.url - .replace( - /{starttime}/g, - layerTimeFormat(Date.parse(layer.time.start)) - ) - .replace( - /{endtime}/g, - layerTimeFormat(Date.parse(layer.time.end)) - ) + if (layer.time && layer.time.enabled === true) { + if ( + layer.time.type === 'global' || + layer.time.type === 'requery' + ) { + layer.url = layer.url + .replace( + /{starttime}/g, + layerTimeFormat(Date.parse(layer.time.start)) + ) + .replace( + /{endtime}/g, + layerTimeFormat(Date.parse(layer.time.end)) + ) + } } - // refresh map - if (L_.toggledArray[layer.name] || evenIfOff) { - await Map_.refreshLayer(layer) + if ( + layer.type === 'vector' && + layer.time.type === 'local' && + layer.time.endProp != null + ) { + if (evenIfControlled === true || layer.controlled !== true) + L_.timeFilterVectorLayer( + layer.name, + new Date(layer.time.start).getTime(), + new Date(layer.time.end).getTime() + ) + } else { + // refresh map + if (evenIfControlled === true || layer.controlled !== true) + if (L_.layers.on[layer.name] || evenIfOff) { + await Map_.refreshLayer(layer) + } + // put start/endtime keywords back + if (layer.time && layer.time.enabled === true) + layer.url = originalUrl } - // put start/endtime keywords back - if (layer.time && layer.time.enabled == true) - layer.url = originalUrl } return true @@ -222,9 +218,9 @@ var TimeControl = { reloadTimeLayers: function () { // refresh time enabled layers var reloadedLayers = [] - for (let layerName in L_.layersNamed) { - const layer = L_.layersNamed[layerName] - if (layer.time && layer.time.enabled == true) { + for (let layerName in L_.layers.data) { + const layer = L_.layers.data[layerName] + if (layer.time && layer.time.enabled === true) { TimeControl.reloadLayer(layer) reloadedLayers.push(layer.name) } @@ -233,23 +229,19 @@ var TimeControl = { }, updateLayersTime: function () { var updatedLayers = [] - for (let layerName in L_.layersNamed) { - const layer = L_.layersNamed[layerName] - if ( - layer.time && - layer.time.enabled == true && - layer.time.type == 'global' - ) { + for (let layerName in L_.layers.data) { + const layer = L_.layers.data[layerName] + if (layer.time && layer.time.enabled === true) { layer.time.start = TimeControl.startTime layer.time.end = TimeControl.currentTime - d3.select('.starttime.' + layer.name.replace(/\s/g, '')).text( + d3.select('.starttime.' + F_.getSafeName(layer.name)).text( layer.time.start ) - d3.select('.endtime.' + layer.name.replace(/\s/g, '')).text( + d3.select('.endtime.' + F_.getSafeName(layer.name)).text( layer.time.end ) updatedLayers.push(layer.name) - if (layer.type == 'tile') { + if (layer.type === 'tile') { TimeControl.setLayerWmsParams(layer) } } @@ -258,11 +250,12 @@ var TimeControl = { }, setLayerTimeStatus: function (layer, color) { if (typeof layer == 'string') { - layer = L_.layersNamed[layer] + layer = L_.asLayerUUID(layer) + layer = L_.layers.data[layer] } if (layer.time) { layer.time.status = color - d3.select('#timesettings' + layer.name.replace(/\s/g, '')).style( + d3.select('#timesettings' + F_.getSafeName(layer.name)).style( 'color', layer.time.status ) @@ -271,12 +264,12 @@ var TimeControl = { }, setLayersTimeStatus: function (color) { var updatedLayers = [] - for (let layerName in L_.layersNamed) { - const layer = L_.layersNamed[layerName] + for (let layerName in L_.layers.data) { + const layer = L_.layers.data[layerName] if ( layer.time && - layer.time.enabled == true && - layer.time.type == 'global' + layer.time.enabled === true && + (layer.time.type === 'global' || layer.time.type === 'requery') ) { TimeControl.setLayerTimeStatus(layer, color) updatedLayers.push(layer.name) @@ -286,55 +279,44 @@ var TimeControl = { }, setLayerWmsParams: function (layer) { var layerTimeFormat = d3.utcFormat(layer.time.format) + const l = L_.layers.layer[layer.name] - if (layer.type == 'tile') { - L_.layersGroup[layer.name].options.time = layerTimeFormat( - Date.parse(layer.time.end) - ) - L_.layersGroup[layer.name].options.starttime = layerTimeFormat( - Date.parse(layer.time.start) - ) - L_.layersGroup[layer.name].options.endtime = layerTimeFormat( - Date.parse(layer.time.end) - ) + if (l != null && layer.type === 'tile') { + l.options.time = layerTimeFormat(Date.parse(layer.time.end)) + l.options.starttime = layerTimeFormat(Date.parse(layer.time.start)) + l.options.endtime = layerTimeFormat(Date.parse(layer.time.end)) } }, } function initLayerDataTimes() { - for (let i in L_.layersData) { - const layer = L_.layersData[i] - if (layer.time && layer.time.enabled == true) { + for (let i in L_.layers.dataFlat) { + const layer = L_.layers.dataFlat[i] + if (layer.time && layer.time.enabled === true) { layer.time.start = L_.FUTURES.startTime ? L_.FUTURES.startTime.toISOString().split('.')[0] + 'Z' : TimeControl.startTime layer.time.end = L_.FUTURES.endTime ? L_.FUTURES.endTime.toISOString().split('.')[0] + 'Z' : TimeControl.endTime - d3.select('.starttime.' + layer.name.replace(/\s/g, '')).text( - layer.time.start - ) - d3.select('.endtime.' + layer.name.replace(/\s/g, '')).text( - layer.time.end - ) } } } function initLayerTimes() { - for (let layerName in L_.layersNamed) { - const layer = L_.layersNamed[layerName] - if (layer.time && layer.time.enabled == true) { + for (let layerName in L_.layers.data) { + const layer = L_.layers.data[layerName] + if (layer.time && layer.time.enabled === true) { layer.time.start = L_.FUTURES.startTime ? L_.FUTURES.startTime.toISOString().split('.')[0] + 'Z' : TimeControl.startTime layer.time.end = L_.FUTURES.endTime ? L_.FUTURES.endTime.toISOString().split('.')[0] + 'Z' : TimeControl.endTime - d3.select('.starttime.' + layer.name.replace(/\s/g, '')).text( + d3.select('.starttime.' + F_.getSafeName(layer.name)).text( layer.time.start ) - d3.select('.endtime.' + layer.name.replace(/\s/g, '')).text( + d3.select('.endtime.' + F_.getSafeName(layer.name)).text( layer.time.end ) @@ -345,58 +327,21 @@ function initLayerTimes() { } } -function updateTime() { - if (!TimeControl._updateLockedForAcceptingInput && TimeControl.enabled) { - // Continuously update global time clock and UI elements - var now = new Date() - var offset = 0 - var offsetTime = d3.select('#offsetTimeInput').property('value') - if (relativeTimeFormat.test(offsetTime)) { - offset = parseTime(offsetTime) - } - var currentTime = new moment(now).add(offset, 'seconds') - d3.select('#currentTimeLabel').text( - TimeControl.globalTimeFormat(currentTime) - ) - TimeControl.currentTime = - currentTime.toDate().toISOString().split('.')[0] + 'Z' - - if (d3.select('#isRelativeTime').property('checked') == true) { - var start = parseTime( - d3.select('#startRelativeTimeInput').property('value') - ) - var end = parseTime( - d3.select('#endRelativeTimeInput').property('value') - ) - var startTime = new moment(currentTime).subtract(start, 'seconds') - var endTime = new moment(currentTime).add(end, 'seconds') - - TimeControl.startTime = - startTime.toDate().toISOString().split('.')[0] + 'Z' - TimeControl.endTime = - endTime.toDate().toISOString().split('.')[0] + 'Z' - - d3.select('#startTimeInput').property( - 'value', - startTime.toISOString().split('.')[0] + 'Z' - ) - d3.select('#endTimeInput').property( - 'value', - endTime.toISOString().split('.')[0] + 'Z' - ) - } - } - setTimeout(updateTime, 100) -} - -function timeInputChange(startTime, endTime, currentTime) { +function timeInputChange(startTime, endTime, currentTime, skipUpdate) { TimeControl.startTime = startTime TimeControl.currentTime = currentTime == null ? endTime : currentTime TimeControl.endTime = endTime - // Update layer times and reload - TimeControl.updateLayersTime() - TimeControl.reloadTimeLayers() + if (L_?._timeChangeSubscriptions) + Object.keys(L_._timeChangeSubscriptions).forEach((k) => { + L_._timeChangeSubscriptions[k]({ startTime, currentTime, endTime }) + }) + + if (skipUpdate !== true) { + // Update layer times and reload + TimeControl.updateLayersTime() + TimeControl.reloadTimeLayers() + } } function parseTime(t) { @@ -411,18 +356,4 @@ function parseTime(t) { return seconds } -function formatTimeString(seconds) { - // converts seconds to hh:mm:ss - if (typeof seconds === 'undefined') { - return '00:00:00' - } - var t = Math.abs(seconds) - var days = Math.floor(t / 86400) - var dt = new Date(t * 1000) - var dtString = dt.toISOString().substr(11, 8) - var s = dtString.split(':') - var hours = +s[0] + days * 24 - return (seconds < 0 ? '-' : '') + hours + ':' + s[1] + ':' + s[2] -} - export default TimeControl diff --git a/src/essence/Ancillary/TimeUI.css b/src/essence/Ancillary/TimeUI.css index d3009b75..90b2477c 100644 --- a/src/essence/Ancillary/TimeUI.css +++ b/src/essence/Ancillary/TimeUI.css @@ -1,12 +1,12 @@ #timeUI { - background: rgba(29, 31, 32, 0.65); + background: rgba(15, 16, 16, 0.6); height: 40px; width: 100%; position: absolute; bottom: -40px; left: 0px; margin: 0; - z-index: 777; + z-index: 77777; font-size: 14px; opacity: 0; pointer-events: none; @@ -51,6 +51,7 @@ flex: 1; display: flex; justify-content: space-between; + position: relative; } #mmgisTimeUI input { @@ -85,14 +86,13 @@ font-size: 11px; text-transform: uppercase; pointer-events: none; - color: var(--color-a5); + color: var(--color-h); } #mmgisTimeUITimeline { display: flex; flex: 1; position: relative; - /*cursor: ew-resize;*/ user-select: none; } #mmgisTimeUITimelineSlider { @@ -102,14 +102,19 @@ background: var(--color-h); height: 2px; opacity: 0.75; + pointer-events: none; } #mmgisTimeUITimelineSlider .rangeSlider { - height: 2px; - margin: 20px 6px 20px 8px; + height: 0px; + margin: 21px 0px 21px 4px; background: var(--color-a2); } -#mmgisTimeUITimelineSlider .rangeHandle:first-child { - display: none; +#mmgisTimeUITimelineSlider .rangeSlider:after { + content: ""; + position: absolute; + width: 100%; + height: 2px; + background: var(--color-a3); pointer-events: none; } #mmgisTimeUITimelineSlider .rangeHandle { @@ -134,35 +139,43 @@ margin: 0px 7px; } +#mmgisTimeUITimelineInner { + height: 100%; + width: 100%; + position: absolute; +} .mmgisTimeUITick { position: absolute; top: 0; display: flex; + pointer-events: none; } .mmgisTimeUITick .mmgisTimeUITickSmall { height: 30px; background: var(--color-a4); width: 1px; + pointer-events: none; } .mmgisTimeUITick .mmgisTimeUITickBig { height: 40px; - background: var(--color-a4); + background: var(--color-a3); width: 1px; + pointer-events: none; } .mmgisTimeUITick .mmgisTimeUITickLabel { height: 40px; line-height: 20px; padding-left: 4px; - text-transform: uppercase; font-size: 13px; color: var(--color-a7); + pointer-events: none; } .mmgisTimeUITick .mmgisTimeUITickLabel span { font-size: 12px; line-height: 22px; text-transform: capitalize; - color: var(--color-a7); + color: var(--color-a5); } #mmgisTimeUIStartWrapper { } @@ -173,6 +186,7 @@ background: var(--color-a); display: flex; justify-content: space-between; + height: 40px; } .mmgisTimeUIButton { margin: 5px; @@ -205,8 +219,51 @@ pointer-events: none; } #mmgisTimeUITimelineHisto > div { - background: var(--color-c2); - opacity: 0.38; + background: #056e94; height: 100%; transition: margin-top 0.2s ease-in-out; } + +#mmgisTimeUIModeDropdown { + background: var(--color-a-5); + width: 80px; +} +#mmgisTimeUIStepDropdown { + width: 80px; +} +#mmgisTimeUIRateDropdown { + width: 60px; +} +#mmgisTimeUIModeDropdown .dropy__title i, +#mmgisTimeUIStepDropdown .dropy__title i, +#mmgisTimeUIRateDropdown .dropy__title i { + color: var(--color-a5); +} +#mmgisTimeUIModeDropdown .dropy__title span, +#mmgisTimeUIStepDropdown .dropy__title span, +#mmgisTimeUIRateDropdown .dropy__title span { + font-size: 12px; + padding: 14px 0px 14px 12px; + color: var(--color-a5); +} +#mmgisTimeUIModeDropdown .dropy__title span { + color: var(--color-a5); + text-transform: uppercase; +} + +#mmgisTimeUIModeDropdown li a, +#mmgisTimeUIStepDropdown li a, +#mmgisTimeUIRateDropdown li a { + font-size: 13px; + padding: 5px 8px; +} + +#mmgisTimeUIStartWrapperFake, +#mmgisTimeUIEndWrapperFake { + position: absolute; + pointer-events: none; + display: none; +} +#mmgisTimeUIEndWrapperFake { + right: 0; +} \ No newline at end of file diff --git a/src/essence/Ancillary/TimeUI.js b/src/essence/Ancillary/TimeUI.js index b9a34468..4ffacf0e 100644 --- a/src/essence/Ancillary/TimeUI.js +++ b/src/essence/Ancillary/TimeUI.js @@ -8,9 +8,11 @@ import $ from 'jquery' import * as d3 from 'd3' import * as moment from 'moment' import F_ from '../Basics/Formulae_/Formulae_' +import Map_ from '../Basics/Map_/Map_' import L_ from '../Basics/Layers_/Layers_' import calls from '../../pre/calls' import tippy from 'tippy.js' +import Dropy from '../../external/Dropy/dropy' import { TempusDominus, Namespace } from '@eonasdan/tempus-dominus' import '@eonasdan/tempus-dominus/dist/css/tempus-dominus.css' @@ -20,8 +22,10 @@ import './TimeUI.css' const FORMAT = 'MM/DD/yyyy, hh:mm:ss A' const MS = { + decade: 315576000000, year: 31557600000, month: 2629800000, + week: 604800000, day: 86400000, hour: 3600000, minute: 60000, @@ -35,65 +39,86 @@ const TimeUI = { _startTimestamp: null, _endTimestamp: null, _timeSliderTimestamp: null, + _timelineStartTimestamp: null, + _timelineEndTimestamp: null, now: false, - intervalIndex: 3, - intervalKeys: [ + numFrames: 24, + intervalIndex: 6, + intervalValues: [100, 250, 500, 1000, 2000, 3000, 4000, 5000, 10000, 20000], + intervalNames: [ + '.1s', + '.25s', + '0.5s', '1s', '2s', + '3s', + '4s', '5s', '10s', '20s', - '30s', - '1m', - '2m', - '5m', - '10m', ], - intervalValues: [ - 1000, - 2000, - 5000, - 10000, - 20000, - 30000, - 60000, - 60000 * 2, - 60000 * 5, - 60000 * 10, - ], - init: function (timeChange) { + stepIndex: 3, + modes: ['Range', 'Point'], + modeIndex: 0, + _initialStart: null, + _initialEnd: null, + init: function (timeChange, enabled) { TimeUI.timeChange = timeChange + TimeUI.enabled = enabled // prettier-ignore const markup = [ `<div id="mmgisTimeUI">`, + `<div id="mmgisTimeUIActionsLeft">`, + `<div id='mmgisTimeUIMode'>`, + `<div id='mmgisTimeUIModeDropdown' class='ui dropdown short'></div>`, + `</div>`, + `<div class="vertDiv"></div>`, + `<div id="mmgisTimeUIPlay" class="mmgisTimeUIButton">`, + `<i class='mdi mdi-play mdi-24px'></i>`, + `</div>`, + `<div class="vertDiv"></div>`, + `<div id='mmgisTimeUIStep'>`, + `<div id='mmgisTimeUIStepDropdown' class='ui dropdown short'></div>`, + `</div>`, + `<div class="vertDiv"></div>`, + `<div id='mmgisTimeUIRate'>`, + `<div id='mmgisTimeUIRateDropdown' class='ui dropdown short'></div>`, + `</div>`, + `</div>`, `<div id="mmgisTimeUIMain">`, `<div class="mmgisTimeUIInput" id="mmgisTimeUIStartWrapper">`, `<span>Start Time</span>`, `<input id="mmgisTimeUIStart"/>`, `</div>`, + `<div class="mmgisTimeUIInput" id="mmgisTimeUIStartWrapperFake">`, + `<span>Start Time</span>`, + `<input id="mmgisTimeUIStartFake" type="text"/>`, + `</div>`, `<div id="mmgisTimeUITimeline">`, `<div id="mmgisTimeUITimelineHisto"></div>`, `<div id="mmgisTimeUITimelineInner"></div>`, `<div id='mmgisTimeUITimelineSlider' class='svelteSlider'></div>`, `</div>`, `<div class="mmgisTimeUIInput" id="mmgisTimeUIEndWrapper">`, - `<span>End Time</span>`, + `<span>Active Time</span>`, `<input id="mmgisTimeUIEnd"/>`, `</div>`, + `<div class="mmgisTimeUIInput" id="mmgisTimeUIEndWrapperFake">`, + `<span>Active Time</span>`, + `<input id="mmgisTimeUIEndFake" type="text"/>`, + `</div>`, `</div>`, `<div id="mmgisTimeUIActionsRight">`, - `<div id="mmgisTimeUIPlay" class="mmgisTimeUIButton">`, - `<i class='mdi mdi-play mdi-24px'></i>`, - `</div>`, - `<div class="vertDiv"></div>`, - `<div id="mmgisTimeUIInterval" class="mmgisTimeUIButton">`, - `<div id='mmgisTimeUIIntervalCycler'>${TimeUI.intervalKeys[TimeUI.intervalIndex]}</div>`, + `<div id="mmgisTimeUIPresent" class="mmgisTimeUIButton">`, + `<i class='mdi mdi-clock-end mdi-24px'></i>`, `</div>`, `</div>`, + /* `<div id="mmgisTimeUICurrentWrapper">`, `<div>Active Time</div>`, `<div id="mmgisTimeUICurrentTime"></div>`, `</div>`, + */ `</div>` ].join('\n') @@ -108,6 +133,64 @@ const TimeUI = { }, getElement: function () {}, attachEvents: function (timeChange) { + // Timeline pan and zoom + // zoom + $('#mmgisTimeUITimelineInner').on('mousewheel', function (e) { + if (TimeUI.play) return + const x = e.originalEvent.offsetX + const width = document + .getElementById('mmgisTimeUITimelineInner') + .getBoundingClientRect().width + // As opposed to per-cent + const perun = x / width + const direction = e.originalEvent.deltaY > 0 ? 1 : -1 + const AMOUNT = 0.07 + const dif = + TimeUI._timelineEndTimestamp - TimeUI._timelineStartTimestamp + const maxChangeAmount = dif * AMOUNT + + const nextStart = + TimeUI._timelineStartTimestamp - + 0 - + perun * maxChangeAmount * direction + const nextEnd = + TimeUI._timelineEndTimestamp - + 0 + + (1 - perun) * maxChangeAmount * direction + + TimeUI._drawTimeLine(nextStart, nextEnd) + + clearTimeout(TimeUI._zoomHistoTimeout) + $('#mmgisTimeUITimelineHisto').empty() + TimeUI._zoomHistoTimeout = setTimeout(() => { + TimeUI._makeHistogram() + }, 3000) + }) + + // pan + $('#mmgisTimeUITimelineInner').on('mousedown', function () { + if (TimeUI.play) { + TimeUI._timelineDragging = false + return + } + TimeUI._timelineDragging = true + $('#mmgisTimeUITimelineSlider').css({ pointerEvents: 'none' }) + $('#mmgisTimeUITimelineInner').on('mousemove', TimeUI._timelineDrag) + }) + $('body').on('mouseup', function () { + if (TimeUI._timelineDragging === true) { + $('#mmgisTimeUITimelineSlider').css({ + pointerEvents: 'inherit', + }) + $('#mmgisTimeUITimelineInner').off( + 'mousemove', + TimeUI._timelineDrag + ) + TimeUI._timelineDragging = false + } + }) + + // Time const options = { display: { viewMode: 'months', @@ -158,25 +241,39 @@ const TimeUI = { // Don't let end date be before start date TimeUI.startTempus.subscribe(Namespace.events.change, (e) => { - TimeUI.setStartTime( - moment.utc(e.date).toISOString(), - TimeUI.startTempus.dontChangeNext - ) - TimeUI.endTempus.updateOptions({ - restrictions: { - minDate: e.date, - }, - }) - TimeUI._remakeTimeSlider() - TimeUI.startTempus.dontChangeNext = false + if (TimeUI.startTempus.dontChangeAnythingElse !== true) { + TimeUI.setStartTime( + moment.utc(e.date).toISOString(), + TimeUI.startTempus.dontChangeNext, + null, + e.oldDate != null + ) + TimeUI.startTempusSavedLastDate = e.date + + TimeUI.endTempus.updateOptions({ + restrictions: { + minDate: e.date, + }, + }) + + TimeUI._remakeTimeSlider() + TimeUI.startTempus.dontChangeNext = false + } + TimeUI.startTempus.dontChangeAnythingElse = false }) // Don't let start date be after end date TimeUI.endTempus.subscribe(Namespace.events.change, (e) => { - if (TimeUI._startTimestamp != null) { + if ( + TimeUI._startTimestamp != null && + TimeUI.endTempus.dontChangeAnythingElse !== true + ) { TimeUI.setEndTime( moment.utc(e.date).toISOString(), - TimeUI.endTempus.dontChangeNext + TimeUI.endTempus.dontChangeNext, + e.oldDate != null ) + TimeUI.endTempusSavedLastDate = e.date + TimeUI.startTempus.updateOptions({ restrictions: { maxDate: e.date, @@ -185,6 +282,7 @@ const TimeUI = { TimeUI._remakeTimeSlider() TimeUI.endTempus.dontChangeNext = false } + TimeUI.endTempus.dontChangeAnythingElse = false }) // Disable Now when picking so that date restrictions don't keep applying and hiding calendar @@ -201,129 +299,446 @@ const TimeUI = { } }) - // Interval Cycler - $('#mmgisTimeUIIntervalCycler').on('click', function () { - TimeUI.intervalIndex++ - if (TimeUI.intervalIndex >= TimeUI.intervalKeys.length) - TimeUI.intervalIndex = 0 - $('#mmgisTimeUIIntervalCycler').text( - TimeUI.intervalKeys[TimeUI.intervalIndex] - ) - - clearInterval(TimeUI.loopTime) - TimeUI.loopTime = setInterval( - TimeUI._setCurrentTime, - TimeUI.intervalValues[TimeUI.intervalIndex] - ) - }) - // tippy + tippy('#mmgisTimeUIMode', { + content: 'Mode', + placement: 'top', + theme: 'blue', + }) tippy('#mmgisTimeUIPlay', { - content: 'Play (Drag slider to End Time for Current Time too)', + content: 'Play / Pause', placement: 'top', theme: 'blue', }) - tippy('#mmgisTimeUIIntervalCycler', { - content: 'Play Interval', + tippy('#mmgisTimeUIStep', { + content: 'Step Size', + placement: 'top', + theme: 'blue', + }) + tippy('#mmgisTimeUIRate', { + content: 'Step Duration', + placement: 'top', + theme: 'blue', + }) + tippy('#mmgisTimeUIPresent', { + content: 'Present', placement: 'top', theme: 'blue', }) - setTimeout(() => { - let date = new Date() - const offsetEndDate = new Date( - date.getTime() + date.getTimezoneOffset() * 60000 - ) - const parsedEnd = TimeUI.endTempus.dates.parseInput( - new Date(offsetEndDate) + // Mode dropdown + $('#mmgisTimeUIModeDropdown').html( + Dropy.construct(TimeUI.modes, 'Mode', TimeUI.modeIndex, { + openUp: true, + dark: true, + }) + ) + Dropy.init($('#mmgisTimeUIModeDropdown'), function (idx) { + TimeUI.modeIndex = idx + if (TimeUI.modes[TimeUI.modeIndex] === 'Point') { + $('#mmgisTimeUIStartWrapper').css({ display: 'none' }) + // Remove end date enforcement + TimeUI.endTempus.updateOptions({ + restrictions: { + minDate: new Date(0).toISOString(), + }, + }) + } else { + $('#mmgisTimeUIStartWrapper').css({ display: 'inherit' }) + // Reinforce min date + TimeUI.endTempus.updateOptions({ + restrictions: { + minDate: TimeUI.startTempusSavedLastDate, + }, + }) + if (TimeUI._startTimestamp >= TimeUI._endTimestamp) { + const offsetStartDate = new Date(TimeUI._endTimestamp) + const parsedStart = TimeUI.startTempus.dates.parseInput( + new Date(offsetStartDate) + ) + TimeUI.startTempus.dates.setValue(parsedStart) + } + } + TimeUI._remakeTimeSlider(true) + }) + // Step dropdown + $('#mmgisTimeUIStepDropdown').html( + Dropy.construct( + Object.keys(MS).map((k) => k.capitalizeFirstLetter()), + 'Step', + TimeUI.stepIndex, + { + openUp: true, + dark: true, + } ) - TimeUI.endTempus.dates.setValue(parsedEnd) - // Start 1 month ago - date.setUTCMonth(date.getUTCMonth() - 1) - const offsetStartDate = new Date( - date.getTime() + date.getTimezoneOffset() * 60000 + ) + Dropy.init($('#mmgisTimeUIStepDropdown'), function (idx) { + TimeUI.stepIndex = idx + TimeUI._refreshIntervals() + }) + // Rate dropdown + $('#mmgisTimeUIRateDropdown').html( + Dropy.construct( + TimeUI.intervalNames, + 'Rate', + TimeUI.intervalIndex, + { + openUp: true, + dark: true, + } ) - const parsedStart = TimeUI.startTempus.dates.parseInput( - new Date(offsetStartDate) + ) + Dropy.init($('#mmgisTimeUIRateDropdown'), function (idx) { + TimeUI.intervalIndex = idx + TimeUI._refreshIntervals() + }) + + // Initial end + if (L_.FUTURES.endTime != null) { + L_.configData.time.initialend = L_.FUTURES.endTime + } + if ( + L_.configData.time.initialend != null && + L_.configData.time.initialend != 'now' + ) { + const dateStaged = new Date(L_.configData.time.initialend) + if (dateStaged == 'Invalid Date') { + TimeUI._initialEnd = new Date() + console.warn( + "Invalid 'Initial End Time' provided. Defaulting to 'now'." + ) + } else TimeUI._initialEnd = dateStaged + } else TimeUI._initialEnd = new Date() + + // Initial Timeline window end + if ( + L_.configData.time.initialwindowend != null && + L_.configData.time.initialwindowend != 'now' + ) { + const dateStaged = new Date(L_.configData.time.initialwindowend) + if (dateStaged == 'Invalid Date') { + console.warn( + "Invalid 'Initial Window End Time' provided. Defaulting to 'now'." + ) + } else TimeUI._timelineEndTimestamp = dateStaged.getTime() + } + + // Initial start + // Start 1 month ago + TimeUI._initialStart = new Date(TimeUI._initialEnd) + if (L_.FUTURES.startTime != null) { + L_.configData.time.initialstart = L_.FUTURES.startTime + } + if (L_.configData.time.initialstart == null) + TimeUI._initialStart.setUTCMonth( + TimeUI._initialStart.getUTCMonth() - 1 ) - TimeUI.startTempus.dates.setValue(parsedStart) + else { + const dateStaged = new Date(L_.configData.time.initialstart) + if (dateStaged == 'Invalid Date') { + TimeUI._initialStart.setUTCMonth( + TimeUI._initialStart.getUTCMonth() - 1 + ) + console.warn( + "Invalid 'Initial Start Time' provided. Defaulting to 1 month before the end time." + ) + } else if (dateStaged.getTime() > TimeUI._initialEnd.getTime()) { + TimeUI._initialStart.setUTCMonth( + TimeUI._initialStart.getUTCMonth() - 1 + ) + console.warn( + "'Initial Start Time' cannot be later than the end time. Defaulting to 1 month before the end time." + ) + } else TimeUI._initialStart = dateStaged + } - $('#mmgisTimeUIPlay').on('click', TimeUI.toggleTimeNow) + // Initial Timeline window start + if (L_.configData.time.initialwindowstart != null) { + const dateStaged = new Date(L_.configData.time.initialwindowstart) + if (dateStaged == 'Invalid Date') { + console.warn("Invalid 'Initial Window Start Time' provided.") + } else if ( + TimeUI._timelineEndTimestamp == null || + dateStaged.getTime() > TimeUI._timelineEndTimestamp + ) { + console.warn( + "'Initial Window Start Time' cannot be later than the Initial Window End Time." + ) + } else TimeUI._timelineStartTimestamp = dateStaged.getTime() + } + + // Initialize the time control times, but don't trigger events + TimeUI.timeChange( + TimeUI._initialStart.toISOString(), + TimeUI._initialEnd.toISOString(), + null, + true + ) + }, + fina() { + let date + // Initial end + date = new Date(TimeUI._initialEnd) + const savedEndDate = new Date(date) - TimeUI.loopTime = setInterval( + const offsetEndDate = new Date( + date.getTime() + date.getTimezoneOffset() * 60000 + ) + const parsedEnd = TimeUI.endTempus.dates.parseInput( + new Date(offsetEndDate) + ) + TimeUI.endTempus.dates.setValue(parsedEnd) + + // Initial start + // Start 1 month ago + if (L_.configData.time.initialstart == null) + date.setUTCMonth(date.getUTCMonth() - 1) + else { + const dateStaged = new Date(L_.configData.time.initialstart) + if (dateStaged === 'Invalid Date') { + date.setUTCMonth(date.getUTCMonth() - 1) + console.warn( + "Invalid 'Initial Start Time' provided. Defaulting to 1 month before the end time." + ) + } else if (dateStaged.getTime() > savedEndDate.getTime()) { + date.setUTCMonth(date.getUTCMonth() - 1) + console.warn( + "'Initial Start Time' cannot be later than the end time. Defaulting to 1 month before the end time." + ) + } else date = dateStaged + } + date = new Date(TimeUI._initialStart) + + const offsetStartDate = new Date( + date.getTime() + date.getTimezoneOffset() * 60000 + ) + const parsedStart = TimeUI.startTempus.dates.parseInput( + new Date(offsetStartDate) + ) + TimeUI.startTempus.dates.setValue(parsedStart) + + $('#mmgisTimeUIPlay').on('click', TimeUI.togglePlay) + $('#mmgisTimeUIPresent').on('click', TimeUI.toggleTimeNow) + + TimeUI._remakeTimeSlider() + TimeUI._setCurrentTime(true, savedEndDate) + + if (TimeUI.enabled) { + TimeUI._makeHistogram() + } + }, + togglePlay(force) { + const mode = TimeUI.modes[TimeUI.modeIndex] + if (TimeUI.play || force === false) { + $('#mmgisTimeUIPlay') + .css('background', '') + .css('color', 'var(--color-a4)') + $('#mmgisTimeUIPlay > i') + .removeClass('mdi-pause') + .addClass('mdi-play') + TimeUI.play = false + + // Don't reposition active time on Stop for Point Mode + if (mode === 'Point') TimeUI._savedPlayEnd = null + + // But do for Range Mode + if (TimeUI._savedPlayEnd != null) { + TimeUI.setCurrentTime(TimeUI._savedPlayEnd) + TimeUI._remakeTimeSlider(true) + TimeUI._savedPlayEnd = null + } + } else { + $('#mmgisTimeUIPlay') + .css('background', 'var(--color-p4)') + .css('color', 'white') + + $('#mmgisTimeUIPlay > i') + .removeClass('mdi-play') + .addClass('mdi-pause') + TimeUI.play = true + TimeUI._savedPlayEnd = TimeUI.getCurrentTimestamp() + TimeUI.now = false + $('#mmgisTimeUIPresent') + .css('background', '') + .css('color', 'var(--color-a4)') + $('#mmgisTimeUIEnd').css('pointer-events', 'inherit') + $('#mmgisTimeUIEndWrapper').css('cursor', 'inherit') + } + TimeUI._refreshIntervals() + }, + _refreshIntervals() { + clearInterval(TimeUI.playInterval) + if (TimeUI.play) { + TimeUI._loopTime() + TimeUI.playInterval = setInterval( + TimeUI._loopTime, + TimeUI.intervalValues[TimeUI.intervalIndex] + ) + } + + clearInterval(TimeUI.presentTimeInterval) + if (TimeUI.now) { + TimeUI.presentTimeInterval = setInterval( TimeUI._setCurrentTime, TimeUI.intervalValues[TimeUI.intervalIndex] ) + } + }, + _loopTime() { + const mode = TimeUI.modes[TimeUI.modeIndex] + const start = + mode === 'Range' + ? TimeUI._startTimestamp + : TimeUI._timelineStartTimestamp + + const end = + mode === 'Range' + ? TimeUI._endTimestamp + : TimeUI._timelineEndTimestamp + const current = TimeUI.getCurrentTimestamp() + + let next = current + MS[Object.keys(MS)[TimeUI.stepIndex]] + if (next > end) next = end + if (current === end) next = start + + if (mode === 'Range') TimeUI.setCurrentTime(next) + if (mode === 'Point') TimeUI.setCurrentTime(next, null, null, true) - TimeUI._remakeTimeSlider() - TimeUI._setCurrentTime(true) - }, 2000) + TimeUI._remakeTimeSlider(true) }, toggleTimeNow(force) { if ((!TimeUI.now && typeof force != 'boolean') || force === true) { - $('#mmgisTimeUIEnd').css('pointer-events', 'none') - $('#mmgisTimeUIEndWrapper').css('cursor', 'not-allowed') - $('#mmgisTimeUIPlay') + $('#mmgisTimeUIPresent') .css('background', 'var(--color-p4)') .css('color', 'white') + $('#mmgisTimeUIEnd').css('pointer-events', 'none') + $('#mmgisTimeUIEndWrapper').css('cursor', 'not-allowed') TimeUI.now = true + TimeUI.togglePlay(false) } else { - $('#mmgisTimeUIEnd').css('pointer-events', 'inherit') - $('#mmgisTimeUIEndWrapper').css('cursor', 'inherit') - $('#mmgisTimeUIPlay') + clearInterval(TimeUI.presentTimeInterval) + $('#mmgisTimeUIPresent') .css('background', '') .css('color', 'var(--color-a4)') + $('#mmgisTimeUIEnd').css('pointer-events', 'inherit') + $('#mmgisTimeUIEndWrapper').css('cursor', 'inherit') TimeUI.now = false } + TimeUI._refreshIntervals() }, _remakeTimeSlider(ignoreHistogram) { + const rangeMode = + TimeUI.modes[TimeUI.modeIndex] === 'Range' ? true : false if (TimeUI.timeSlider) { - $('#mmgisTimeUITimelineSlider').empty() + TimeUI.timeSlider.$destroy() TimeUI.timeSlider = null + $('#mmgisTimeUITimelineSlider').empty() + if (rangeMode) $('#mmgisTimeUITimelineSlider').addClass('rangeMode') + else $('#mmgisTimeUITimelineSlider').removeClass('rangeMode') } + if ( + TimeUI._timelineStartTimestamp == null || + TimeUI._timelineEndTimestamp == null + ) + return + TimeUI.timeSlider = new RangeSliderPips({ target: document.querySelector('#mmgisTimeUITimelineSlider'), props: { - values: [TimeUI._startTimestamp, TimeUI.getCurrentTimestamp()], + values: rangeMode + ? [ + TimeUI.removeOffset(TimeUI._startTimestamp), + TimeUI.removeOffset(TimeUI.getCurrentTimestamp()), + ] + : [TimeUI.removeOffset(TimeUI.getCurrentTimestamp())], pips: false, - min: TimeUI._startTimestamp, - max: TimeUI._endTimestamp, - range: true, + min: + TimeUI._timelineEndTimestamp != null + ? TimeUI._timelineStartTimestamp + : 0, + max: + TimeUI._timelineStartTimestamp != null + ? TimeUI._timelineEndTimestamp + : 100, + range: rangeMode, pushy: false, float: false, springValues: { stiffness: 0.15, - damping: 0.5, + damping: 0.4, }, handleFormatter: (v) => { - return moment.utc(v).format(FORMAT) + return moment.utc(TimeUI.removeOffset(v)).format(FORMAT) }, }, }) - - $('#mmgisTimeUICurrentTime').text( - moment.utc(TimeUI.getCurrentTimestamp(true)).format(FORMAT) - ) - TimeUI.timeSlider.$on('start', (e) => { TimeUI.toggleTimeNow(false) + if (TimeUI.play) { + TimeUI._savedPlayEnd = null + TimeUI.togglePlay(false) + } }) TimeUI.timeSlider.$on('change', (e) => { - $('#mmgisTimeUICurrentTime').text( - moment.utc(TimeUI.removeOffset(e.detail.value)).format(FORMAT) + let idx = 0 + if (TimeUI.modes[TimeUI.modeIndex] === 'Point') idx -= 1 + + const date = new Date(e.detail.value) + const offsetNowDate = new Date( + date.getTime() + date.getTimezoneOffset() * 60000 ) + if (e.detail.activeHandle === idx) { + $('#mmgisTimeUIStartWrapperFake').css('display', 'block') + $('#mmgisTimeUIStartFake').val( + moment + .utc(TimeUI.removeOffset(offsetNowDate)) + .format(FORMAT) + ) + } + if (e.detail.activeHandle === idx + 1) { + $('#mmgisTimeUIEndWrapperFake').css('display', 'block') + $('#mmgisTimeUIEndFake').val( + moment + .utc(TimeUI.removeOffset(offsetNowDate)) + .format(FORMAT) + ) + } }) TimeUI.timeSlider.$on('stop', (e) => { - TimeUI.setCurrentTime(new Date(e.detail.value).toISOString()) + $('#mmgisTimeUIStartWrapperFake').css('display', 'none') + $('#mmgisTimeUIEndWrapperFake').css('display', 'none') + + let idx = 0 + if (TimeUI.modes[TimeUI.modeIndex] === 'Point') idx -= 1 + + const date = new Date(e.detail.value) + const offsetNowDate = new Date( + date.getTime() + date.getTimezoneOffset() * 60000 + ) + if (e.detail.activeHandle === idx) { + const parsedNow = TimeUI.startTempus.dates.parseInput( + new Date(offsetNowDate) + ) + TimeUI.startTempus.dates.setValue(parsedNow) + } + if (e.detail.activeHandle === idx + 1) { + const parsedNow = TimeUI.endTempus.dates.parseInput( + new Date(offsetNowDate) + ) + TimeUI.endTempus.dates.setValue(parsedNow) + } }) if ($('#toggleTimeUI').hasClass('active') && ignoreHistogram !== true) TimeUI._makeHistogram() }, _makeHistogram() { - const startTimestamp = TimeUI._startTimestamp - const endTimestamp = TimeUI.getCurrentTimestamp() + const startTimestamp = TimeUI.removeOffset( + TimeUI._timelineStartTimestamp + ) + const endTimestamp = TimeUI.removeOffset(TimeUI._timelineEndTimestamp) // Don't remake if nothing changes if ( @@ -338,14 +753,14 @@ const TimeUI = { // Find all on, time-enabled, tile layers const sparklineLayers = [] - Object.keys(L_.layersNamed).forEach((name) => { - const l = L_.layersNamed[name] + Object.keys(L_.layers.data).forEach((name) => { + const l = L_.layers.data[name] if ( l && l.type === 'tile' && l.time && l.time.enabled === true && - L_.toggledArray[name] === true + L_.layers.on[name] === true ) { let layerUrl = l.url if (!F_.isUrlAbsolute(layerUrl)) { @@ -359,10 +774,15 @@ const TimeUI = { } }) - const starttimeISO = new Date(TimeUI._startTimestamp).toISOString() - const endtimeISO = new Date(endTimestamp).toISOString() + const starttimeISO = new Date( + TimeUI._timelineStartTimestamp + ).toISOString() + const endtimeISO = new Date(TimeUI._timelineEndTimestamp).toISOString() - const NUM_BINS = Math.min(endTimestamp - startTimestamp, 360) + const NUM_BINS = Math.max( + Math.min(endTimestamp - startTimestamp, 360), + 1 + ) const bins = new Array(NUM_BINS).fill(0) sparklineLayers.forEach((l) => { @@ -381,7 +801,9 @@ const TimeUI = { F_.linearScale( [startTimestamp, endTimestamp], [0, NUM_BINS], - new Date(time.t).getTime() + TimeUI.removeOffset( + new Date(time.t).getTime() + ) ) ) ]++ @@ -407,15 +829,18 @@ const TimeUI = { ) }) }, - _setCurrentTime(force) { + _setCurrentTime(force, forceDate, disableChange) { if (TimeUI.now === true || force === true) { - let date = new Date() + let date = forceDate || new Date() const offsetNowDate = new Date( date.getTime() + date.getTimezoneOffset() * 60000 ) const parsedNow = TimeUI.endTempus.dates.parseInput( new Date(offsetNowDate) ) + + TimeUI.setCurrentTime(parsedNow, disableChange) + //TimeUI._remakeTimeSlider(true) TimeUI.endTempus.dates.setValue(parsedNow) } }, @@ -425,9 +850,7 @@ const TimeUI = { // Start if (start != null) { date = new Date(start) - const offsetStartDate = new Date( - date.getTime() + date.getTimezoneOffset() * 60000 - ) + const offsetStartDate = TimeUI.addOffset(date) const parsedStart = TimeUI.startTempus.dates.parseInput( new Date(offsetStartDate) ) @@ -456,13 +879,34 @@ const TimeUI = { TimeUI.change() }, - setStartTime(ISOString, disableChange) { + setStartTime( + ISOString, + disableChange, + dontRedrawTimeline, + andMatchTimeline + ) { const timestamp = Date.parse(ISOString) TimeUI._startTimestamp = timestamp + if (TimeUI._timelineStartTimestamp == null) + TimeUI._timelineStartTimestamp = TimeUI.removeOffset( + TimeUI._startTimestamp + ) - TimeUI._drawTimeLine() + if (dontRedrawTimeline != true) + TimeUI._drawTimeLine( + andMatchTimeline + ? TimeUI.removeOffset(TimeUI._startTimestamp) + : null + ) if (disableChange != true) TimeUI.change() }, + addOffset(timestamp) { + const date = new Date(timestamp) + const addedOffset = new Date( + date.getTime() + date.getTimezoneOffset() * 60000 + ) + return addedOffset + }, removeOffset(timestamp) { const date = new Date(timestamp) const removedOffset = new Date( @@ -483,35 +927,64 @@ const TimeUI = { return TimeUI.removeOffset(currentTimestamp) } else return currentTimestamp }, - setEndTime(ISOString, disableChange) { + setEndTime(ISOString, disableChange, andMatchTimeline) { const sliderFixedToEnd = TimeUI._endTimestamp === TimeUI.getCurrentTimestamp() const timestamp = Date.parse(ISOString) TimeUI._endTimestamp = timestamp - TimeUI._drawTimeLine() + + if (TimeUI._timelineEndTimestamp == null) + TimeUI._timelineEndTimestamp = TimeUI.removeOffset( + TimeUI._endTimestamp + ) + + TimeUI._drawTimeLine( + null, + andMatchTimeline ? TimeUI.removeOffset(TimeUI._endTimestamp) : null + ) if (sliderFixedToEnd) { TimeUI._timeSliderTimestamp = TimeUI._endTimestamp if (disableChange != true) TimeUI.change() } }, - setCurrentTime(ISOString, disableChange) { - const timestamp = Date.parse(ISOString) + setCurrentTime( + ISOString, + disableChange, + dontRemoveOffset, + ignoreDontChange + ) { + const timestamp = + typeof ISOString === 'string' ? Date.parse(ISOString) : ISOString TimeUI._timeSliderTimestamp = timestamp - $('#mmgisTimeUICurrentTime').text( - moment.utc(TimeUI.getCurrentTimestamp(true)).format(FORMAT) - ) + if (TimeUI.play) { + const date = new Date(TimeUI._timeSliderTimestamp) + const offsetNowDate = new Date( + date.getTime() + date.getTimezoneOffset() * 60000 + ) + const parsedNow = TimeUI.endTempus.dates.parseInput( + new Date(offsetNowDate) + ) + if (ignoreDontChange !== true) + TimeUI.endTempus.dontChangeAnythingElse = true + TimeUI.endTempus.dates.setValue(parsedNow) + } + if (disableChange != true) TimeUI.change() }, change() { if ( typeof TimeUI.timeChange === 'function' && - TimeUI._startTimestamp && - TimeUI._endTimestamp + TimeUI._startTimestamp != null && + TimeUI._endTimestamp != null ) { + const mode = TimeUI.modes[TimeUI.modeIndex] + TimeUI.timeChange( new Date( - TimeUI.removeOffset(TimeUI._startTimestamp) + mode === 'Range' + ? TimeUI.removeOffset(TimeUI._startTimestamp) + : 0 ).toISOString(), new Date( TimeUI.removeOffset(TimeUI._endTimestamp) @@ -520,32 +993,65 @@ const TimeUI = { ) } }, - _drawTimeLine() { + _timelineDrag: function (e) { + if (TimeUI._timelineDragging === true) { + const dx = e.originalEvent.movementX / 1.5 + const width = document + .getElementById('mmgisTimeUITimelineInner') + .getBoundingClientRect().width + const dif = + TimeUI._timelineEndTimestamp - TimeUI._timelineStartTimestamp + + const nextStart = + TimeUI._timelineStartTimestamp - 0 - (dif / width) * dx + const nextEnd = + TimeUI._timelineEndTimestamp - 0 - (dif / width) * dx + + TimeUI._drawTimeLine(nextStart, nextEnd) + + clearTimeout(TimeUI._panHistoTimeout) + $('#mmgisTimeUITimelineHisto').empty() + TimeUI._panHistoTimeout = setTimeout(() => { + TimeUI._makeHistogram() + }, 3000) + } + }, + _drawTimeLine(forceStart, forceEnd) { const timelineElm = $('#mmgisTimeUITimelineInner') timelineElm.empty() - const s = TimeUI._startTimestamp - const e = TimeUI._endTimestamp + let s = forceStart || TimeUI._timelineStartTimestamp + let e = forceEnd || TimeUI._timelineEndTimestamp + if (e == null || s == null) return + s = Math.max(s - 0, 0) // Year 1970 + e = Math.min(e - 0, 3155788800000) // Year 2070 + + TimeUI._timelineStartTimestamp = parseInt(s) + TimeUI._timelineEndTimestamp = parseInt(e) + const dif = e - s let unit = null - if (dif / MS.year > 3) { + if (dif / MS.decade > 2) { + unit = 'decade' + } else if (dif / MS.year > 2) { unit = 'year' } else if (dif / MS.month > 1) { unit = 'month' - } else if (dif / MS.day > 2) { + } else if (dif / MS.day > 1.5) { unit = 'day' - } else if (dif / MS.hour > 1) { + } else if (dif / MS.hour > 0.75) { unit = 'hour' - } else if (dif / MS.minute > 1) { + } else if (dif / MS.minute > 0.75) { unit = 'minute' } else unit = 'second' let first = true const bigTicks = F_.getTimeStartsBetweenTimestamps(s, e, unit) + for (let i = 0; i < bigTicks.length; i++) { const left = F_.linearScale([s, e], [0, 100], bigTicks[i].ts) if (left >= 0 && left <= 100) { @@ -553,15 +1059,17 @@ const TimeUI = { [ `<div class="mmgisTimeUITick" style="left: ${left}%">`, `<div class="mmgisTimeUITickBig"></div>`, - `<div class="mmgisTimeUITickLabel">${ + `<div class="mmgisTimeUITickLabel" id="mmgisTimeUITickLabel_${i}">${ bigTicks[i].label - }${first ? `<br/><span>${unit}</span>` : ''}</div`, + }${first ? `<br/><span>${unit}</span>` : ''}</div>`, `</div>`, ].join('\n') ) first = false } } + + TimeUI._remakeTimeSlider(true) }, } diff --git a/src/essence/Basics/Formulae_/Formulae_.js b/src/essence/Basics/Formulae_/Formulae_.js index 33965b58..0c569fa0 100644 --- a/src/essence/Basics/Formulae_/Formulae_.js +++ b/src/essence/Basics/Formulae_/Formulae_.js @@ -1,10 +1,11 @@ //Holds a bunch of reusable mathy formulas and variables -import turf from '@turf/turf' +import { bbox, simplify } from '@turf/turf' import { saveAs } from 'file-saver' import $ from 'jquery' import calls from '../../../pre/calls' -// often referred to as F_ +import azElDistBetween from './subformulae/azElDistBetween' + var temp = new Float32Array(1) // eslint-disable-next-line no-extend-native @@ -17,6 +18,7 @@ Object.defineProperty(Object.prototype, 'getFirst', { enumerable: false, }) +// often referred to as F_ var Formulae_ = { radiusOfPlanetMajor: 3396190, //(m) Defaults to Mars radiusOfPlanetMinor: 3396190, @@ -59,6 +61,13 @@ var Formulae_ = { range[0] ) }, + isStringNumeric: function (str) { + if (typeof str != 'string') return false + return !isNaN(str) && !isNaN(parseFloat(str)) + }, + getBase64Transparent256Tile: function () { + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAABFUlEQVR42u3BMQEAAADCoPVP7WsIoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAeAMBPAAB2ClDBAAAAABJRU5ErkJggg==' + }, monthNumberToName: function (monthNumber) { switch (monthNumber) { case 0: @@ -89,6 +98,20 @@ var Formulae_ = { return '' } }, + addTimeZoneOffset(timestamp) { + const date = new Date(timestamp) + const addedOffset = new Date( + date.getTime() + date.getTimezoneOffset() * 60000 + ) + return addedOffset + }, + removeTimeZoneOffset(timestamp) { + const date = new Date(timestamp) + const removedOffset = new Date( + date.getTime() - date.getTimezoneOffset() * 60000 + ) + return removedOffset + }, // Returns an array of timestamps between startTime and endTime timestamps that fall along the unit getTimeStartsBetweenTimestamps: function (startTime, endTime, unit) { const timeStarts = [] @@ -100,6 +123,23 @@ var Formulae_ = { let currentDate switch (unit) { + case 'decade': + currentDate = new Date( + Date.UTC(Math.floor(startDate.getFullYear() / 10) * 10) + ) + while (currentDate < endDate) { + currentDate.setUTCFullYear( + Math.floor(currentDate.getUTCFullYear() / 10) * 10 + 10 + ) + timeStarts.push({ + ts: Date.parse(currentDate), + label: + Math.floor(currentDate.getUTCFullYear() / 10) * 10 + + 's', + }) + } + + break case 'year': currentDate = new Date(Date.UTC(startDate.getFullYear())) while (currentDate < endDate) { @@ -121,7 +161,7 @@ var Formulae_ = { ts: Date.parse(currentDate), label: Formulae_.monthNumberToName( currentDate.getUTCMonth() - ), + ).toUpperCase(), }) } break @@ -216,17 +256,15 @@ var Formulae_ = { return R * c }, - bearingFromGreatArcDistance: function (distance) { - return ( - -1 * ((distance / this.radiusOfPlanetMajor) * (180 / Math.PI) + 90) - ) - }, metersToDegrees: function (meters) { return (meters / this.radiusOfPlanetMajor) * (180 / Math.PI) }, degreesToMeters: function (degrees) { return degrees * (Math.PI / 180) * this.radiusOfPlanetMajor }, + simplifyGeometry: function (geometry, tolerance) { + return simplify(geometry, { tolerance: tolerance }) + }, //2D distanceFormula: function (x1, y1, x2, y2) { return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)) @@ -260,8 +298,9 @@ var Formulae_ = { return [closestI, closestJ] }, //a mod that works with negatives. a true modulo and not remainder - mod: function (n, m) { - var remain = n % m + mod: function (n, m, dontFloor) { + const remain = n % m + if (dontFloor) return remain >= 0 ? remain : remain + m return Math.floor(remain >= 0 ? remain : remain + m) }, //2D rotate a point about another point a certain angle @@ -309,11 +348,6 @@ var Formulae_ = { return { x: x, y: y, z: z } }, - round: function (number, decimals = 0) { - if (decimals == 0) return Math.round(number) - var multiplier = Math.pow(10, decimals) - return Math.round(number * multiplier) / multiplier - }, // From: https://github.com/nuclearsecrecy/Leaflet.greatCircle/blob/master/Leaflet.greatCircle.js#L160 // returns destination lat/lon from a start point lat/lon of a giving bearing (degrees) and distance (km). destinationFromBearing: function ( @@ -492,7 +526,6 @@ var Formulae_ = { * @returns {String} - color in hex color code - '#ae6204' */ stringToColor2: function (stringInput) { - console.log(stringInput) const h = [...stringInput].reduce((acc, char) => { return char.charCodeAt(0) + ((acc << 5) - acc) }, 0) @@ -511,7 +544,7 @@ var Formulae_ = { intToRGB: function (i) { var c = (i & 0x00ffffff).toString(16).toUpperCase() - return '#00000'.substring(0, 6 - c.length) + c + return '#000000'.substring(0, 7 - c.length) + c }, rgbObjToStr: function (rgb, hasAlpha) { if (hasAlpha && rgb.a != null) @@ -581,30 +614,8 @@ var Formulae_ = { return { x: x, y: y, z: z } }, - //From: https://github.com/mrdoob/three.js/issues/758 mrdoob - getImageData: function (image) { - if (image.width == 0) return - var canvas = document.createElement('canvas') - canvas.width = image.width - canvas.height = image.height - - var context = canvas.getContext('2d') - context.drawImage(image, 0, 0) - - return context.getImageData(0, 0, image.width, image.height) - }, - getPixel: function (imagedata, x, y) { - var position = (x + imagedata.width * y) * 4, - data = imagedata.data - return { - r: data[position], - g: data[position + 1], - b: data[position + 2], - a: data[position + 3], - } - }, getSafeName: function (name) { - return (name || '').replace(/\s/g, '') + return ('UUID' + (name || '').replace(/\s/g, '')).toLowerCase() }, /** * Traverses an object with an array of keys @@ -656,8 +667,8 @@ var Formulae_ = { return uniqueArr }, removeDuplicatesInArray(arr) { - arr.filter((c, index) => { - return arr.indexOf(c) !== index + arr = arr.filter((c, index) => { + return arr.indexOf(c) === index }) return arr @@ -713,15 +724,6 @@ var Formulae_ = { } return subdividedLine }, - //Helper to make an array or object an enumerated array - enumerate: function (obj) { - var arr = [] - var keys = Object.keys(obj) - for (var k = 0; k < keys.length; k++) { - arr[k] = obj[keys[k]] - } - return arr - }, //Return a clone of the object to avoid pass by reference issues clone: function (obj) { var copy @@ -805,15 +807,6 @@ var Formulae_ = { const r = new RegExp('^(?:[a-z]+:)?//', 'i') return r.test(url) }, - populateUrl: function (url, xyz, invertY) { - url = url.replace('{x}', xyz.x) - url = url.replace( - '{y}', - invertY === true ? Math.pow(2, xyz.z) - 1 - xyz.y : xyz.y - ) - url = url.replace('{z}', xyz.z) - return url - }, csvToJSON: function (csv) { var lines = csv.split('\n') var result = [] @@ -900,6 +893,113 @@ var Formulae_ = { return '#ffffff' } }, + getIn4Layers: function (obj, keyArray, notSetValue, assumeLayerHierarchy) { + if (obj == null) return notSetValue != null ? notSetValue : null + if (keyArray == null) return notSetValue != null ? notSetValue : null + if (typeof keyArray === 'string') keyArray = keyArray.split('.') + let object = Object.assign({}, obj) + console.log(object, keyArray) + for (let i = 0; i < keyArray.length; i++) { + if (object && object.hasOwnProperty(keyArray[i])) + object = object[keyArray[i]] + else if ( + assumeLayerHierarchy && + object && + Formulae_.objectArrayIndexOfKeyWithValue( + object, + 'name', + keyArray[i] + ) >= 0 + ) + object = + object[ + Formulae_.objectArrayIndexOfKeyWithValue( + object, + 'name', + keyArray[i] + ) + ] + else return notSetValue != null ? notSetValue : null + } + return object + }, + objectArrayIndexOfKeyWithValue: function (objectArray, key, value) { + var index = -1 + for (let i in objectArray) { + if (objectArray[i]) { + if ( + objectArray[i].hasOwnProperty(key) && + objectArray[i][key] === value + ) { + index = i + break + } + } + } + return index + }, + setIn4Layers: function ( + obj, + keyArray, + value, + splice, + assumeLayerHierarchy + ) { + if (keyArray == null || keyArray === []) return false + if (typeof keyArray === 'string') keyArray = keyArray.split('.') + let object = obj + for (let i = 0; i < keyArray.length - 1; i++) { + if (object.hasOwnProperty(keyArray[i])) object = object[keyArray[i]] + else if ( + assumeLayerHierarchy && + Formulae_.objectArrayIndexOfKeyWithValue( + object, + 'name', + keyArray[i] + ) >= 0 + ) + object = + object[ + Formulae_.objectArrayIndexOfKeyWithValue( + object, + 'name', + keyArray[i] + ) + ] + else return false + } + const finalKey = keyArray[keyArray.length - 1] + + if (splice && !isNaN(finalKey) && typeof object.splice === 'function') + object.splice(parseInt(finalKey), 0, value) + else object[keyArray[keyArray.length - 1]] = value + return true + }, + traverseLayers: function (layers, onLayer) { + depthTraversal(layers, 0, []) + function depthTraversal(node, depth, path) { + for (var i = 0; i < node.length; i++) { + const ret = onLayer(node[i], path, i) + + if (ret === 'remove') { + node.splice(i, 1) + i-- + } + //Add other feature information while we're at it + else if ( + node[i] && + node[i].sublayers != null && + node[i].sublayers.length > 0 + ) { + depthTraversal( + node[i].sublayers, + depth + 1, + `${path.length > 0 ? path + '.' : ''}${node[i].name}` + ) + } + } + } + }, invertGeoJSONLatLngs(feature) { let geojson = this.clone(feature) var coords = geojson.geometry.coordinates @@ -1313,21 +1413,6 @@ var Formulae_ = { return (_ * Math.PI) / 180 } }, - calcPolygonArea(vertices) { - var total = 0 - - for (var i = 0, l = vertices.length; i < l; i++) { - var addX = vertices[i][0] - var addY = vertices[i == vertices.length - 1 ? 0 : i + 1][1] - var subX = vertices[i == vertices.length - 1 ? 0 : i + 1][0] - var subY = vertices[i][1] - - total += addX * addY * 0.5 - total -= subX * subY * 0.5 - } - - return Math.abs(total) - }, //if array is an array of objects, // the optional key can be set to say which key to average arrayAverage(array, key) { @@ -1338,19 +1423,6 @@ var Formulae_ = { } return total / array.length }, - doubleToTwoFloats(double) { - if (double >= 0) { - var high = Math.floor(double / 65536) * 65536 - return [this.f32round(high), this.f32round(double - high)] - } else { - var high = Math.floor(-double / 65536) * 65536 - return [this.f32round(-high), this.f32round(double + high)] - } - }, - f32round(x) { - temp[0] = +x - return temp[0] - }, toEllipsisString(str, length) { return str.length > length ? str.substr(0, length - 3) + '...' : str }, @@ -1367,7 +1439,7 @@ var Formulae_ = { for (var i = 0; i < savedFeatures.length; i++) { if (i != 0) { featuresString += '\n,' - savedFeatures[i].properties['boundingbox'] = turf.bbox( + savedFeatures[i].properties['boundingbox'] = bbox( savedFeatures[i] ) } @@ -1555,10 +1627,6 @@ var Formulae_ = { var cvd = document.body.appendChild(cv) return cv.toDataURL() }, - //A out of little place - download: function (filepath) { - window.open(filepath + '?nocache=' + new Date().getTime()) - }, downloadObject(exportObj, exportName, exportExt) { var strung if (typeof exportObj === 'string') { @@ -1667,19 +1735,56 @@ var Formulae_ = { }, } }, - pointsInPoint(point, layers) { - var points = [] + // searchRadiusInDegrees = [lng, lng, lat, lat] bbox + pointsInPoint(point, layers, searchRadiusInDegrees) { + let points = [] - var l = layers._layers - - if (l == null) return points - - for (var i in l) { - if ( - l[i].feature.geometry.coordinates[0] == point[0] && - l[i].feature.geometry.coordinates[1] == point[1] - ) - points.push(l[i]) + if (Array.isArray(layers)) { + layers.forEach((l) => { + points = points.concat( + Formulae_.pointsInPoint(point, l, searchRadiusInDegrees) + ) + }) + } else { + let l + if (layers.feature && layers.feature.geometry?.type === 'Point') { + l = [layers] + } else l = layers._layers + + if (l == null) return points + for (let i in l) { + if (l[i].feature == null) continue + if (searchRadiusInDegrees != null) { + if ( + l[i].feature.geometry.coordinates[0] > + Math.min( + searchRadiusInDegrees[0], + searchRadiusInDegrees[1] + ) && + l[i].feature.geometry.coordinates[0] < + Math.max( + searchRadiusInDegrees[0], + searchRadiusInDegrees[1] + ) && + l[i].feature.geometry.coordinates[1] > + Math.min( + searchRadiusInDegrees[2], + searchRadiusInDegrees[3] + ) && + l[i].feature.geometry.coordinates[1] < + Math.max( + searchRadiusInDegrees[2], + searchRadiusInDegrees[3] + ) + ) { + points.push(l[i]) + } + } else if ( + l[i].feature.geometry.coordinates[0] == point[0] && + l[i].feature.geometry.coordinates[1] == point[1] + ) + points.push(l[i]) + } } return points @@ -1706,7 +1811,7 @@ var Formulae_ = { image.style.color = stringToTest return image.style.color !== 'rgb(255, 255, 255)' }, - timestampToDate(timestamp) { + timestampToDate(timestamp, small) { var a = new Date(timestamp * 1000) var months = [ 'Jan', @@ -1733,6 +1838,19 @@ var Formulae_ = { var sec = a.getUTCSeconds() < 10 ? '0' + a.getUTCSeconds() : a.getUTCSeconds() + if (small) { + return ( + month + + '/' + + date + + '/' + + (year + '').slice(-2) + + ' ' + + hour + + ':' + + min + ) + } return ( monthName + ' ' + @@ -1747,6 +1865,11 @@ var Formulae_ = { sec ) }, + isValidUrl(str) { + const a = document.createElement('a') + a.href = str + return a.host && a.host !== window.location.host + }, /** * Returns an array of only the matching elements between two arrays * @param {[]} arr1 @@ -1981,17 +2104,6 @@ var Formulae_ = { //prettier-ignore return 'hsl(' + colorScaleA[i % colorScaleA.length] + ', ' + s + ', ' + l + ')' }, - ASCIIProduct(str) { - if (str == null) return 0 - let product = 1 - for (let i = 0; i < str.length; i++) product += str.charCodeAt(i) - return product - }, - everyOtherChar(str) { - let newStr = '' - for (let i = 0; i < str.length; i += 2) newStr += str[i] - return newStr - }, cloneCanvas(oldCanvas) { //create a new canvas var newCanvas = document.createElement('canvas') @@ -2083,6 +2195,8 @@ var Formulae_ = { let xAxis = axes.x || 0 let yAxis = axes.y || 0 + + if (xAxis === 0 || yAxis === 0) return null // Optional params options = options || {} let steps = options.steps || 32 @@ -2203,6 +2317,39 @@ var Formulae_ = { if (data == 1010101 || data > 35000 || data < -35000) return true return false }, + azElDistBetween(latLngEl_A, latLngEl_B) { + //Formulae_.azElBetween2(latLngEl_A, latLngEl_B) + + const b = azElDistBetween( + latLngEl_A, + latLngEl_B, + Formulae_.radiusOfPlanetMajor, + Formulae_.radiusOfPlanetMinor + ) + return b + }, + azElBetween2(latLngEl_A, latLngEl_B) { + const crs = window.mmgisglobal.customCRS + const a = crs.project(latLngEl_A) + const b = crs.project(latLngEl_B) + + const dist = Math.sqrt( + Math.pow(b.x - a.x, 2) + + Math.pow(b.y - a.y, 2) + + Math.pow(latLngEl_B.el - latLngEl_A.el, 2) + ) + + const el = + Math.asin((latLngEl_B.el - latLngEl_A.el) / dist) * (180 / Math.PI) + + let az = Math.atan2(b.x - a.x, b.y - a.y) * (180 / Math.PI) + if (az < 0) az += 360 + console.log({ + az: az, + el: el, + dist: dist, + }) + }, // Breaks an array in multiple arrays of some size chunkArray(arr, size) { return arr.length > size @@ -2212,9 +2359,24 @@ var Formulae_ = { ] : [arr] }, - getCookieValue(a) { - let b = document.cookie.match('(^|[^;]+)\\s*' + a + '\\s*=\\s*([^;]+)') - return b ? b.pop() : '' + /** + * From https://stackoverflow.com/questions/10420352/converting-file-size-in-bytes-to-human-readable-string + */ + humanFileSize(bytes, si) { + if (bytes == null) return null + var thresh = si ? 1000 : 1024 + if (Math.abs(bytes) < thresh) { + return bytes + ' B' + } + var units = si + ? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] + : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'] + var u = -1 + do { + bytes /= thresh + ++u + } while (Math.abs(bytes) >= thresh && u < units.length - 1) + return bytes.toFixed(1) + ' ' + units[u] }, getBrowser() { //Check if browser is IE diff --git a/src/essence/Basics/Formulae_/subformulae/azElDistBetween.js b/src/essence/Basics/Formulae_/subformulae/azElDistBetween.js new file mode 100644 index 00000000..99ffb4f9 --- /dev/null +++ b/src/essence/Basics/Formulae_/subformulae/azElDistBetween.js @@ -0,0 +1,197 @@ +// Adapted from https://github.com/cosinekitty/geocalc/blob/master/compass.html + +function parseAngle(angle, limit) { + angle = parseFloat(angle) + if (isNaN(angle) || angle < -limit || angle > limit) return null + return angle +} + +function parseElevation(el) { + el = parseFloat(el) + if (isNaN(el)) return null + return el +} + +function parseLocation(latLngEl) { + const lat = parseAngle(latLngEl.lat, 90.0) + let location = null + if (lat != null) { + const lng = parseAngle(latLngEl.lng, 180.0) + if (lng != null) { + const el = parseElevation(latLngEl.el) + if (el != null) { + location = { lat: lat, lng: lng, el: el } + } + } + } + return location +} + +function earthRadiusInMeters(latitudeRadians, majorRadius, minorRadius) { + // latitudeRadians is geodetic, i.e. that reported by GPS. + // http://en.wikipedia.org/wiki/Earth_radius + const a = majorRadius // equatorial radius in meters + const b = minorRadius // polar radius in meters + const cos = Math.cos(latitudeRadians) + const sin = Math.sin(latitudeRadians) + const t1 = a * a * cos + const t2 = b * b * sin + const t3 = a * cos + const t4 = b * sin + return Math.sqrt((t1 * t1 + t2 * t2) / (t3 * t3 + t4 * t4)) +} + +function geocentricLatitude(lat, majorRadius, minorRadius) { + const a = majorRadius // equatorial radius in meters + const b = minorRadius // polar radius in meters + const f = (a - b) / a // flattening + const e2 = 2 * f - Math.pow(f, 2) // eccentricity squared + + // Convert geodetic latitude 'lat' to a geocentric latitude 'clat'. + // Geodetic latitude is the latitude as given by GPS. + // Geocentric latitude is the angle measured from center of Earth between a point and the equator. + // https://en.wikipedia.org/wiki/Latitude#Geocentric_latitude + const clat = Math.atan((1.0 - e2) * Math.tan(lat)) + + return clat +} + +function locationToPoint(c, majorRadius, minorRadius) { + // Convert (lat, lng, el) to (x, y, z). + const lat = (c.lat * Math.PI) / 180.0 + const lng = (c.lng * Math.PI) / 180.0 + const radius = earthRadiusInMeters(lat, majorRadius, minorRadius) + const clat = geocentricLatitude(lat, majorRadius, minorRadius) + + const cosLng = Math.cos(lng) + const sinLng = Math.sin(lng) + const cosLat = Math.cos(clat) + const sinLat = Math.sin(clat) + let x = radius * cosLng * cosLat + let y = radius * sinLng * cosLat + let z = radius * sinLat + + // We used geocentric latitude to calculate (x,y,z) on the Earth's ellipsoid. + // Now we use geodetic latitude to calculate normal vector from the surface, to correct for elevation. + const cosGlat = Math.cos(lat) + const sinGlat = Math.sin(lat) + + const nx = cosGlat * cosLng + const ny = cosGlat * sinLng + const nz = sinGlat + + x += c.el * nx + y += c.el * ny + z += c.el * nz + + return { x: x, y: y, z: z, radius: radius, nx: nx, ny: ny, nz: nz } +} + +function distance(ap, bp) { + const dx = ap.x - bp.x + const dy = ap.y - bp.y + const dz = ap.z - bp.z + return Math.sqrt(dx * dx + dy * dy + dz * dz) +} + +function rotateGlobe(b, a, bradius, aradius, majorRadius, minorRadius) { + // Get modified coordinates of 'b' by rotating the globe so that 'a' is at lat=0, lng=0. + const br = { lat: b.lat, lng: b.lng - a.lng, el: b.el } + const brp = locationToPoint(br, majorRadius, minorRadius) + + // Rotate brp cartesian coordinates around the z-axis by a.lng degrees, + // then around the y-axis by a.lat degrees. + // Though we are decreasing by a.lat degrees, as seen above the y-axis, + // this is a positive (counterclockwise) rotation (if B's longitude is east of A's). + // However, from this point of view the x-axis is pointing left. + // So we will look the other way making the x-axis pointing right, the z-axis + // pointing up, and the rotation treated as negative. + + const alat = geocentricLatitude( + (-a.lat * Math.PI) / 180.0, + majorRadius, + minorRadius + ) + const acos = Math.cos(alat) + const asin = Math.sin(alat) + + const bx = brp.x * acos - brp.z * asin + const by = brp.y + const bz = brp.x * asin + brp.z * acos + + return { x: bx, y: by, z: bz, radius: bradius } +} + +function normalizeVectorDiff(b, a) { + // Calculate norm(b-a), where norm divides a vector by its length to produce a unit vector. + var dx = b.x - a.x + var dy = b.y - a.y + var dz = b.z - a.z + var dist2 = dx * dx + dy * dy + dz * dz + if (dist2 == 0) { + return null + } + var dist = Math.sqrt(dist2) + return { x: dx / dist, y: dy / dist, z: dz / dist, radius: 1.0 } +} + +export default function azElDistBetween( + latLngEl_A, + latLngEl_B, + majorRadius, + minorRadius +) { + majorRadius = 3396190 + minorRadius = majorRadius + const result = { az: 0, el: 0, dist: 0 } + const a = parseLocation(latLngEl_A) + if (a != null) { + const b = parseLocation(latLngEl_B) + if (b != null) { + const ap = locationToPoint(a, majorRadius, minorRadius) + const bp = locationToPoint(b, majorRadius, minorRadius) + result.dist = distance(ap, bp) + + // Let's use a trick to calculate azimuth: + // Rotate the globe so that point A looks like latitude 0, longitude 0. + // We keep the actual radii calculated based on the oblate geoid, + // but use angles based on subtraction. + // Point A will be at x=radius, y=0, z=0. + // Vector difference B-A will have dz = N/S component, dy = E/W component. + const br = rotateGlobe( + b, + a, + bp.radius, + ap.radius, + majorRadius, + minorRadius + ) + if (br.z * br.z + br.y * br.y > 1.0e-6) { + const theta = (Math.atan2(br.z, br.y) * 180.0) / Math.PI + let azimuth = 90.0 - theta + if (azimuth < 0.0) { + azimuth += 360.0 + } + if (azimuth > 360.0) { + azimuth -= 360.0 + } + result.az = azimuth + } + + const bma = normalizeVectorDiff(bp, ap) + if (bma != null) { + // Calculate altitude, which is the angle above the horizon of B as seen from A. + // Almost always, B will actually be below the horizon, so the altitude will be negative. + // The dot product of bma and norm = cos(zenith_angle), and zenith_angle = (90 deg) - altitude. + // So altitude = 90 - acos(dotprod). + const altitude = + 90.0 - + (180.0 / Math.PI) * + Math.acos(bma.x * ap.nx + bma.y * ap.ny + bma.z * ap.nz) + result.el = altitude + } + } + } + + return result +} diff --git a/src/essence/Basics/Globe_/Globe_.js b/src/essence/Basics/Globe_/Globe_.js index 94571d10..5d17f7e9 100644 --- a/src/essence/Basics/Globe_/Globe_.js +++ b/src/essence/Basics/Globe_/Globe_.js @@ -128,7 +128,10 @@ let Globe_ = { hideElement: true, onChange: (lng, lat, elev) => { if (lng == null || lat == null) { - $('#mouseLngLat').text(`Outer Space`) + L_.Coordinates.setCoords( + [null, null, null], + 'Outer Space' + ) } else { const converted = L_.Coordinates.convertLngLat( lng, @@ -136,7 +139,8 @@ let Globe_ = { L_.Coordinates.currentType, true ) - $('#mouseLngLat').text( + L_.Coordinates.setCoords( + [lng, lat, elev], `${converted[0]}, ${converted[1]}` ) } diff --git a/src/essence/Basics/Layers_/LayerCapturer.js b/src/essence/Basics/Layers_/LayerCapturer.js index 5511b864..a71d43a4 100644 --- a/src/essence/Basics/Layers_/LayerCapturer.js +++ b/src/essence/Basics/Layers_/LayerCapturer.js @@ -8,16 +8,19 @@ import TimeControl from '../../Ancillary/TimeControl' export const captureVector = (layerObj, options, cb) => { options = options || {} let layerUrl = layerObj.url - const layerData = L_.layersDataByName[layerObj.name] + const layerData = L_.layers.data[layerObj.name] // If there is no url to a JSON file but the "controlled" option is checked in the layer config, // create the geoJSON layer with empty GeoJSON data - if (options.useEmptyGeoJSON || layerData.controlled) { + if ( + options.useEmptyGeoJSON || + (layerData.controlled && layerUrl.length === 0) + ) { cb(F_.getBaseGeoJSON()) return } - if (options.evenIfOff !== true && !L_.toggledArray[layerObj.name]) { + if (options.evenIfOff !== true && !L_.layers.on[layerObj.name]) { cb('off') return } @@ -67,7 +70,7 @@ export const captureVector = (layerObj, options, cb) => { }, function (data) { console.warn( - 'ERROR! ' + + 'ERROR: ' + data.status + ' in ' + layerUrl + diff --git a/src/essence/Basics/Layers_/LayerConstructors.js b/src/essence/Basics/Layers_/LayerConstructors.js index 3d98df69..7fd14b98 100644 --- a/src/essence/Basics/Layers_/LayerConstructors.js +++ b/src/essence/Basics/Layers_/LayerConstructors.js @@ -9,6 +9,8 @@ import L_ from '../Layers_/Layers_' import LayerGeologic from './LayerGeologic/LayerGeologic' import { parseExtendedGeoJSON, getCoordProperties } from './ExtendedGeoJSON' +import { centroid } from '@turf/turf' + let L = window.L const tooltipProto = L.Tooltip.prototype @@ -65,10 +67,12 @@ export const constructVectorLayer = ( if (feature.properties.hasOwnProperty('style')) { let className = layerObj.style.className let layerName = layerObj.style.layerName + layerObj.style = Object.assign({}, layerObj.style) layerObj.style = { - ...JSON.parse(JSON.stringify(layerObj.style)), + ...layerObj.style, ...JSON.parse(JSON.stringify(feature.properties.style)), } + if (className) layerObj.style.className = className if (layerName) layerObj.style.layerName = layerName } else { @@ -219,6 +223,22 @@ export const constructVectorLayer = ( } layerObj.shape = 'directional_circle' } + + const markerXY = Map_.map.latLngToLayerPoint(latlong) + const markerLatLong = Map_.map.containerPointToLatLng([ + markerXY.x, + markerXY.y, + ]) + const pixelBelowMarkerLatLong = Map_.map.containerPointToLatLng( + [markerXY.x, markerXY.y + 1] + ) + yaw -= F_.bearingBetweenTwoLatLngs( + pixelBelowMarkerLatLong.lat, + pixelBelowMarkerLatLong.lng, + markerLatLong.lat, + markerLatLong.lng + ) + yaw = -((360 - yaw) % 360) } switch (layerObj.shape) { @@ -331,11 +351,9 @@ export const constructVectorLayer = ( } else if (layer == null && svg != null) { layer = L.marker(latlong, { icon: L.divIcon({ - className: `leafletMarkerShape leafletMarkerShape_${layerObj.name - .replace(/\s/g, '') - .toLowerCase()} ${layerObj.name - .replace(/\s/g, '') - .toLowerCase()} leafletDivIcon`, + className: `leafletMarkerShape leafletMarkerShape_${F_.getSafeName( + layerObj.name + )} ${F_.getSafeName(layerObj.name)} leafletDivIcon`, iconSize: [ (featureStyle.radius + pixelBuffer) * 2, (featureStyle.radius + pixelBuffer) * 2, @@ -491,6 +509,7 @@ export const constructSublayers = ( // note: sublayer ordering here does denote render order (bottom on top). const sublayers = { labels: false, + pairings: pairings(geojson, layerObj, leafletLayerObject), uncertainty_ellipses: uncertaintyEllipses( geojson, layerObj, @@ -612,7 +631,7 @@ const labels = (geojson, layerObj, leafletLayerObject, layer, sublayers) => { layer.dropdown = mainDropdownProps.dropdown layer.dropdownValue = mainDropdownProps.dropdownValue layer.dropdownFunc = (layerName, subName, Map_, prop) => { - const sublayer = L_.layersGroupSublayers[layerName][subName] + const sublayer = L_.layers.attachments[layerName][subName] layer.dropdownValue = prop if (sublayer.on) layer.on() } @@ -736,12 +755,12 @@ const labels = (geojson, layerObj, leafletLayerObject, layer, sublayers) => { layer.addDataEnhanced = function (geojson, layerName, subName) { this.addData(geojson) - if (L_.layersGroupSublayers[layerName][subName].on) this.on() + if (L_.layers.attachments[layerName][subName].on) this.on() } return { - on: L_.layersGroupSublayers[layerObj.name]?.labels - ? L_.layersGroupSublayers[layerObj.name]?.labels.on + on: L_.layers.attachments[layerObj.name]?.labels + ? L_.layers.attachments[layerObj.name]?.labels.on : labelsVar.initialVisibility != null ? labelsVar.initialVisibility : true, @@ -755,6 +774,184 @@ const labels = (geojson, layerObj, leafletLayerObject, layer, sublayers) => { } else return false } +// Draws a thin faint line to the center of features from other layers that are connected to this layer +const pairings = (geojson, layerObj, leafletLayerObject) => { + //PAIRINGS + const pairingsVar = F_.getIn( + layerObj, + 'variables.layerAttachments.pairings' + ) + + if (pairingsVar) { + const layers = (pairingsVar.layers || []).map((l) => L_.asLayerUUID(l)) + + const pairProp = pairingsVar.pairProp + const layersAzProp = pairingsVar.layersAzProp + const layersElProp = pairingsVar.layersElProp + const style = pairingsVar.style || {} + const styleObject = { + style: { + ...{ + weight: 2, + color: 'yellow', + opacity: 0.35, + }, + ...style, + }, + } + + if (layers.length === 0 || pairProp == null) { + console.warn( + `Layer '${layerObj.name}' has badly formed 'pairings' attachments object. Missing 'layers' or 'pairProp'.` + ) + return + } + + const getPairingLayer = (dontCalculate, forceGeojson) => { + const pairingLineFeatures = [] + if (forceGeojson) geojson = forceGeojson + if (!dontCalculate) + geojson.features.forEach((f) => { + const featureCenter = centroid(f).geometry.coordinates + const pairValue = F_.getIn( + f.properties, + pairProp, + '___null' + ) + + layers.forEach((layerName) => { + if ( + L_.layers.layer[layerName] && + L_.layers.layer[layerName]._sourceGeoJSON && + L_.layers.on[layerName] === true + ) { + L_.layers.layer[ + layerName + ]._sourceGeoJSON.features.forEach((pairFeature) => { + if ( + F_.getIn( + pairFeature.properties, + pairProp, + null + ) === pairValue + ) { + const pairFeatureCenter = + centroid(pairFeature).geometry + .coordinates + + pairingLineFeatures.push({ + type: 'Feature', + properties: {}, + geometry: { + type: 'LineString', + coordinates: [ + featureCenter, + pairFeatureCenter, + ], + }, + }) + } + }) + } + }) + }) + + let layer = L.geoJson(pairingLineFeatures, styleObject) + + layer.on = (firstTime, sublayerLayer) => { + const layerMain = + L_.layers.attachments?.[layerObj.name]?.pairings?.layer + if (layerMain == null) return + + layerMain.off() + // For checking whether we can use the previous layer instead of recreating + const constructedFromLayers = [] + layers.forEach((layerName) => { + if ( + L_.layers.layer[layerName] && + L_.layers.layer[layerName]._sourceGeoJSON && + L_.layers.on[layerName] === true + ) { + constructedFromLayers.push(layerName) + } + }) + const constructedTag = constructedFromLayers.join('__') + + // Check if "", since if it is, no need to add anything + if (constructedTag.length > 0) { + if ( + sublayerLayer == null || + constructedTag !== layerMain.constructedTag + ) { + L_.layers.attachments[layerObj.name].pairings.layer = + getPairingLayer() + L_.layers.attachments[ + layerObj.name + ].pairings.layer.constructedTag = constructedTag + if (sublayerLayer) + sublayerLayer = + L_.layers.attachments[layerObj.name].pairings + .layer + } + L_.Map_.map.addLayer(layerMain) + layerMain.setZIndex( + L_._layersOrdered.length + + 1 - + L_._layersOrdered.indexOf(layerObj.name) + ) + } + } + layer.off = () => { + const layerMain = + L_.layers.attachments?.[layerObj.name]?.pairings?.layer + if (layerMain == null) return + + L_.Map_.rmNotNull(layerMain) + } + return layer + } + + // Doesn't matter if Map isn't attached to Layers for the first time + if (L_.Map_) { + L_.Map_.rmNotNull( + L_.layers.attachments?.[layerObj.name]?.pairings?.layer + ) + } + const layer = getPairingLayer(true) + + layer.addDataEnhanced = function (geojson, layerName, subName, Map_) { + Map_.rmNotNull(L_.layers.attachments[layerName][subName].layer) + L_.layers.attachments[layerName][subName].geojson = geojson + L_.layers.attachments[layerName][subName].layer = getPairingLayer( + false, + geojson + ) + Map_.map.addLayer(L_.layers.attachments[layerName][subName].layer) // + } + + return { + on: L_.layers.attachments[layerObj.name]?.pairings + ? L_.layers.attachments[layerObj.name]?.pairings.on + : pairingsVar.initialVisibility != null + ? pairingsVar.initialVisibility + : true, + pairedLayers: layers, + pairProp: pairProp, + layersAzProp: layersAzProp, + layersElProp: layersElProp, + originOffsetOrder: pairingsVar.originOffsetOrder, + type: 'pairings', + geojson: geojson, + layer: layer, + title: 'Feature Pairings', + minZoom: 0, + maxZoom: 100, + } + } else { + return false + } +} + const uncertaintyEllipses = (geojson, layerObj, leafletLayerObject) => { //UNCERTAINTY const uncertaintyVar = F_.getIn( @@ -802,15 +999,17 @@ const uncertaintyEllipses = (geojson, layerObj, leafletLayerObject) => { angle: uncertaintyAngle, } ) - for ( - let i = 0; - i < feature.geometry.coordinates[0].length; - i++ - ) { - feature.geometry.coordinates[0][i][2] = - f.geometry.coordinates[2] + depth3d + if (feature) { + for ( + let i = 0; + i < feature.geometry.coordinates[0].length; + i++ + ) { + feature.geometry.coordinates[0][i][2] = + f.geometry.coordinates[2] + depth3d + } + uncertaintyEllipseFeatures.push(feature) } - uncertaintyEllipseFeatures.push(feature) } }) @@ -853,20 +1052,23 @@ const uncertaintyEllipses = (geojson, layerObj, leafletLayerObject) => { if (uncertaintyVar.angleUnit === 'rad') uncertaintyAngle = uncertaintyAngle * (180 / Math.PI) + const xy = { + x: F_.getIn( + feature.properties, + uncertaintyVar.xAxisProp, + false + ), + y: F_.getIn( + feature.properties, + uncertaintyVar.yAxisProp, + false + ), + } + if (xy.x === false && xy.y === false) return null + uncertaintyEllipse = F_.toEllipse( latlong, - { - x: F_.getIn( - feature.properties, - uncertaintyVar.xAxisProp, - 1 - ), - y: F_.getIn( - feature.properties, - uncertaintyVar.yAxisProp, - 1 - ), - }, + xy, window.mmgisglobal.customCRS, { units: uncertaintyVar.axisUnits || 'meters', @@ -881,6 +1083,7 @@ const uncertaintyEllipses = (geojson, layerObj, leafletLayerObject) => { return uncertaintyEllipse }, } + return curtainUncertaintyOptions ? { on: @@ -972,7 +1175,7 @@ const imageOverlays = (geojson, layerObj, leafletLayerObject) => { imageSettings.angleProp, 0 ) - if (imageSettings.angleProp === 'deg') + if (imageSettings.angleUnit === 'deg') angle = angle * (Math.PI / 180) const crs = window.mmgisglobal.customCRS @@ -1397,22 +1600,20 @@ const pathGradient = (geojson, layerObj, leafletLayerObject) => { Map_, overrideColorWithProp ) { - Map_.rmNotNull( - L_.layersGroupSublayers[layerName][subName].layer - ) - L_.layersGroupSublayers[layerName][subName].layer = getLayer( + Map_.rmNotNull(L_.layers.attachments[layerName][subName].layer) + L_.layers.attachments[layerName][subName].layer = getLayer( geojson, - L_.layersGroupSublayers[layerName][subName].layer.layerObj, + L_.layers.attachments[layerName][subName].layer.layerObj, overrideColorWithProp ) Map_.map.addLayer( - L_.layersGroupSublayers[layerName][subName].layer + L_.layers.attachments[layerName][subName].layer ) } layer.dropdown = pathGradientSettings.dropdownColorWithProp layer.dropdownValue = pathGradientSettings.colorWithProp layer.dropdownFunc = function (layerName, subName, Map_, prop) { - const l = L_.layersGroupSublayers[layerName][subName] + const l = L_.layers.attachments[layerName][subName] l.layer.addDataEnhanced( l.geojson, layerName, diff --git a/src/essence/Basics/Layers_/Layers_.js b/src/essence/Basics/Layers_/Layers_.js index cab2f6f8..3228f8f2 100644 --- a/src/essence/Basics/Layers_/Layers_.js +++ b/src/essence/Basics/Layers_/Layers_.js @@ -7,7 +7,7 @@ import LayerGeologic from './LayerGeologic/LayerGeologic' import $ from 'jquery' import * as d3 from 'd3' -var L_ = { +const L_ = { url: window.location.href, mission: null, missionPath: null, @@ -25,46 +25,25 @@ var L_ = { tools: null, //The full, unchanged data configData: null, - //The full layer object - layers: null, //was fullData - //Name -> layer objects - layersNamed: {}, //was namedLayersData - //Name -> leaflet layer - layersGroup: {}, //was mainLayerGroup - //Name -> sublayer group - layersGroupSublayers: {}, + layers: { + data: {}, // layersNamed but by uuid + dataFlat: [], //layersData + layer: {}, // layersGroup + attachments: {}, // layersGroupSubLayers + on: {}, // toggledArray + opacity: {}, // opacityArray + filters: {}, // layerFilters + nameToUUID: {}, + }, + // ===== Private ====== //Index -> layer name - layersOrdered: [], //was mainLayerOrder - //Index -> layerName (an unchanging layersOrdered) - layersOrderedFixed: [], //was fixedLayerOrder - //Name -> original index - layersIndex: {}, + _layersOrdered: [], // 78 uses //Index -> had loaded (T/F) (same index as orderedLayers) - layersLoaded: [], //was layersloaded - //Name -> style - layersStyles: {}, //was layerStyles - //Name -> legendurl - layersLegends: {}, //was layerLegends - //Name -> legendData - layersLegendsData: {}, - //Name -> layer expanded in layers tab (T/F) - expandArray: {}, - //Index -> layer object - layersData: [], - //Name => layer object - layersDataByName: {}, - //Index -> level (0, 1, 2 ... ) - indentArray: [], - //Name -> is toggled (T/F) - toggledArray: {}, - //Name -> layer visible because header expanded (T/F) - expanded: {}, - //Name -> layer opacity ( 0 to 1 ) - opacityArray: {}, - //Name -> filter value array - layerFilters: {}, + _layersLoaded: [], // 27 uses //Name -> parent - layersParent: {}, + _layersParent: {}, // 5 uses + // + _localTimeFilterCache: {}, //FUTURES FUTURES: { site: null, @@ -91,10 +70,23 @@ var L_ = { toggledOffFeatures: [], mapAndGlobeLinked: false, addLayerQueue: [], + _onLoadCallbacks: [], + _loaded: false, init: function (configData, missionsList, urlOnLayers) { parseConfig(configData, urlOnLayers) L_.missionsList = missionsList }, + onceLoaded(cb) { + if (L_._loaded === true) cb() + else L_._onLoadCallbacks.push(cb) + }, + loaded: function () { + L_._loaded = true + L_._onLoadCallbacks.forEach((cb) => { + cb() + }) + L_._onLoadCallbacks = [] + }, clear: function () { L_.mission = null L_.missionPath = null @@ -109,25 +101,19 @@ var L_ = { L_.UserInterface_ = null L_.tools = null L_.configData = null - L_.layers = null - L_.layersNamed = {} - L_.layersGroup = {} - L_.layersOrdered = [] - L_.layersOrderedFixed = [] - L_.layersIndex = {} - L_.layersLoaded = [] - L_.layersStyles = {} - L_.layersLegends = {} - L_.layersLegendsData = {} - L_.expandArray = {} - L_.layersData = [] - L_.layersDataByName = {} - L_.indentArray = [] - L_.toggledArray = {} - L_.expanded = {} - L_.opacityArray = {} - L_.layerFilters = {} - L_.layersParent = {} + L_.layers = { + data: {}, + dataFlat: [], + leafletLayer: {}, + attachments: {}, + toggled: {}, + opacity: {}, + filters: {}, + } + L_._layersOrdered = [] + L_._layersLoaded = [] + L_._layersParent = {} + L_._localTimeFilterCache = {} L_.FUTURES = { site: null, mapView: null, @@ -202,57 +188,94 @@ var L_ = { } } else console.log('Failure updating to new site') }, + _timeChangeSubscriptions: {}, + subscribeTimeChange: function (fid, func) { + if (typeof func === 'function') L_._timeChangeSubscriptions[fid] = func + }, + unsubscribeTimeChange: function (fid) { + if (L_._timeChangeSubscriptions[fid] != null) + delete L_._timeChangeSubscriptions[fid] + }, + _onTimeUIToggleSubscriptions: {}, + subscribeOnTimeUIToggle: function (fid, func) { + if (typeof func === 'function') + L_._onTimeUIToggleSubscriptions[fid] = func + }, + unsubscribeOnTimeUIToggle: function (fid) { + if (L_._onTimeUIToggleSubscriptions[fid] != null) + delete L_._onTimeUIToggleSubscriptions[fid] + }, + _onLayerToggleSubscriptions: {}, + subscribeOnLayerToggle: function (fid, func) { + if (typeof func === 'function') + L_._onLayerToggleSubscriptions[fid] = func + }, + unsubscribeOnLayerToggle: function (fid) { + if (L_._onLayerToggleSubscriptions[fid] != null) + delete L_._onLayerToggleSubscriptions[fid] + }, //Takes in config layer obj //Toggles a layer on and off and accounts for sublayers //Takes in a config layer object toggleLayer: async function (s) { if (s == null) return let on //if on -> turn off //if off -> turn on - if (L_.toggledArray[s.name] === true) on = true + if (L_.layers.on[s.name] === true) on = true else on = false await L_.toggleLayerHelper(s, on) + + Object.keys(L_._onLayerToggleSubscriptions).forEach((k) => { + L_._onLayerToggleSubscriptions[k](s.name, !on) + }) }, - toggleLayerHelper: async function (s, on, ignoreToggleStateChange) { + toggleLayerHelper: async function ( + s, + on, + ignoreToggleStateChange, + globeOnly + ) { if (s.type !== 'header') { if (on) { - if (L_.Map_.map.hasLayer(L_.layersGroup[s.name])) { + if ( + L_.Map_.map.hasLayer(L_.layers.layer[s.name]) && + globeOnly != true + ) { try { $('.drawToolContextMenuHeaderClose').click() } catch (err) {} - L_.Map_.map.removeLayer(L_.layersGroup[s.name]) - if (L_.layersGroupSublayers[s.name]) { - for (let sub in L_.layersGroupSublayers[s.name]) { - switch (L_.layersGroupSublayers[s.name][sub].type) { + L_.Map_.map.removeLayer(L_.layers.layer[s.name]) + if (L_.layers.attachments[s.name]) { + for (let sub in L_.layers.attachments[s.name]) { + switch (L_.layers.attachments[s.name][sub].type) { case 'model': L_.Globe_.litho.removeLayer( - L_.layersGroupSublayers[s.name][sub] + L_.layers.attachments[s.name][sub] .layerId ) break case 'uncertainty_ellipses': L_.Globe_.litho.removeLayer( - L_.layersGroupSublayers[s.name][sub] + L_.layers.attachments[s.name][sub] .curtainLayerId ) L_.Globe_.litho.removeLayer( - L_.layersGroupSublayers[s.name][sub] + L_.layers.attachments[s.name][sub] .clampedLayerId ) L_.Map_.rmNotNull( - L_.layersGroupSublayers[s.name][sub] - .layer + L_.layers.attachments[s.name][sub].layer ) break case 'labels': - L_.layersGroupSublayers[s.name][ + case 'pairings': + L_.layers.attachments[s.name][ sub ].layer.off() break default: L_.Map_.rmNotNull( - L_.layersGroupSublayers[s.name][sub] - .layer + L_.layers.attachments[s.name][sub].layer ) break } @@ -263,70 +286,85 @@ var L_ = { L_.Globe_.litho.toggleLayer(s.name, false) } else L_.Globe_.litho.removeLayer(s.name) } else { - if (L_.layersGroup[s.name]) { - if (L_.layersGroupSublayers[s.name]) { - for (let sub in L_.layersGroupSublayers[s.name]) { - if (L_.layersGroupSublayers[s.name][sub].on) { + if (L_.layers.layer[s.name] && globeOnly != true) { + if (L_.layers.attachments[s.name]) { + for (let sub in L_.layers.attachments[s.name]) { + if (L_.layers.attachments[s.name][sub].on) { switch ( - L_.layersGroupSublayers[s.name][sub].type + L_.layers.attachments[s.name][sub].type ) { case 'model': L_.Globe_.litho.addLayer( 'model', - L_.layersGroupSublayers[s.name][sub] + L_.layers.attachments[s.name][sub] .modelOptions ) break case 'uncertainty_ellipses': L_.Globe_.litho.addLayer( 'curtain', - L_.layersGroupSublayers[s.name][sub] + L_.layers.attachments[s.name][sub] .curtainOptions ) L_.Globe_.litho.addLayer( 'clamped', - L_.layersGroupSublayers[s.name][sub] + L_.layers.attachments[s.name][sub] .clampedOptions ) L_.Map_.map.addLayer( - L_.layersGroupSublayers[s.name][sub] + L_.layers.attachments[s.name][sub] .layer ) - L_.layersGroupSublayers[s.name][ + L_.layers.attachments[s.name][ sub ].layer.setZIndex( - L_.layersOrdered.length + + L_._layersOrdered.length + 1 - - L_.layersOrdered.indexOf(s.name) + L_._layersOrdered.indexOf( + s.name + ) ) break case 'labels': - L_.layersGroupSublayers[s.name][ - sub - ].layer.on() + case 'pairings': + if ( + L_.layers.attachments[s.name][sub] + .layer + ) + L_.layers.attachments[s.name][ + sub + ].layer.on( + false, + L_.layers.attachments[s.name][ + sub + ].layer + ) break default: L_.Map_.map.addLayer( - L_.layersGroupSublayers[s.name][sub] + L_.layers.attachments[s.name][sub] .layer ) - L_.layersGroupSublayers[s.name][ + L_.layers.attachments[s.name][ sub ].layer.setZIndex( - L_.layersOrdered.length + + L_._layersOrdered.length + 1 - - L_.layersOrdered.indexOf(s.name) + L_._layersOrdered.indexOf( + s.name + ) ) break } } } } - L_.Map_.map.addLayer(L_.layersGroup[s.name]) - L_.layersGroup[s.name].setZIndex( - L_.layersOrdered.length + + + L_.Map_.map.addLayer(L_.layers.layer[s.name]) + L_.layers.layer[s.name].setZIndex( + L_._layersOrdered.length + 1 - - L_.layersOrdered.indexOf(s.name) + L_._layersOrdered.indexOf(s.name) ) } if (s.type === 'tile') { @@ -340,8 +378,8 @@ var L_ = { demUrl = undefined L_.Globe_.litho.addLayer('tile', { name: s.name, - order: L_.layersOrdered, - on: L_.opacityArray[s.name], + order: L_._layersOrdered, + on: L_.layers.opacity[s.name], format: s.tileformat || 'tms', formatOptions: {}, demFormat: s.tileformat || 'tms', @@ -352,7 +390,7 @@ var L_ = { parser: s.demparser || null, path: layerUrl, demPath: demUrl, - opacity: L_.opacityArray[s.name], + opacity: L_.layers.opacity[s.name], minZoom: s.minZoom, maxZoom: s.maxNativeZoom, //boundingBox: s.boundingBox, @@ -388,45 +426,53 @@ var L_ = { } } else { let hadToMake = false - if (L_.layersGroup[s.name] === false) { + if ( + L_.layers.layer[s.name] === false && + globeOnly != true + ) { await L_.Map_.makeLayer(s, true) Description.updateInfo() hadToMake = true } - if (L_.layersGroup[s.name]) { - if (!hadToMake) { - // Refresh annotation popups - if (L_.layersGroup[s.name]._layers) - Object.keys( - L_.layersGroup[s.name]._layers - ).forEach((key) => { - const l = - L_.layersGroup[s.name]._layers[key] - if (l._isAnnotation) { - L_.layersGroup[s.name]._layers[key] = - L_.createAnnotation( + if (L_.layers.layer[s.name]) { + if (globeOnly != true) { + if (!hadToMake) { + // Refresh annotation popups + if (L_.layers.layer[s.name]._layers) + Object.keys( + L_.layers.layer[s.name]._layers + ).forEach((key) => { + const l = + L_.layers.layer[s.name]._layers[key] + if (l._isAnnotation) { + L_.layers.layer[s.name]._layers[ + key + ] = L_.createAnnotation( l._annotationParams.feature, l._annotationParams.className, l._annotationParams.layerId, l._annotationParams.id1 ) - } - }) + } + }) + } + L_.Map_.map.addLayer(L_.layers.layer[s.name]) + L_.layers.layer[s.name].setZIndex( + L_._layersOrdered.length + + 1 - + L_._layersOrdered.indexOf(s.name) + ) } - L_.Map_.map.addLayer(L_.layersGroup[s.name]) - L_.layersGroup[s.name].setZIndex( - L_.layersOrdered.length + - 1 - - L_.layersOrdered.indexOf(s.name) - ) if (s.type === 'vector') { L_.Globe_.litho.addLayer( s.layer3dType || 'clamped', { name: s.name, - order: L_.layersOrdered, // Since higher order in litho is on top - on: L_.opacityArray[s.name] ? true : false, - geojson: L_.layersGroup[s.name].toGeoJSON( + order: L_._layersOrdered, // Since higher order in litho is on top + on: L_.layers.opacity[s.name] + ? true + : false, + geojson: L_.layers.layer[s.name].toGeoJSON( L_.GEOJSON_PRECISION ), onClick: (feature, lnglat, layer) => { @@ -451,7 +497,7 @@ var L_ = { .bearing : null, }, - opacity: L_.opacityArray[s.name], + opacity: L_.layers.opacity[s.name], minZoom: s.visibilitycutoff > 0 ? s.visibilitycutoff @@ -468,35 +514,43 @@ var L_ = { } } - if (!ignoreToggleStateChange) { - if (on) L_.toggledArray[s.name] = false - if (!on) L_.toggledArray[s.name] = true - } + if (globeOnly != true) { + if (!ignoreToggleStateChange) { + if (on) L_.layers.on[s.name] = false + if (!on) L_.layers.on[s.name] = true + } - if (!on && s.type === 'vector') { - L_.Map_.orderedBringToFront() - } + if (s.type === 'vector') L_._updatePairings(s.name, !on) + if (!on && s.type === 'vector') { + L_.Map_.orderedBringToFront() + } + L_._refreshAnnotationEvents() + + // Toggling rereveals hidden features, so make sure they stay hidden + if (L_.toggledOffFeatures && L_.toggledOffFeatures.length > 0) { + L_.toggledOffFeatures.forEach((f) => { + L_.toggleFeature(f, false) + }) + } + } + }, + _refreshAnnotationEvents() { // Add annotation click events since onEachFeatureDefault doesn't apply to popups $('.mmgisAnnotation').off('click') $('.mmgisAnnotation').on('click', function () { const layerName = $(this).attr('layerId') const layerCode = $(this).attr('layer') - const layer = L_.layersGroup[layerName]._layers[layerCode] + const layer = L_.layers.layer[layerName]._layers[layerCode] L_.Map_.featureDefaultClick(layer.feature, layer, { latlng: layer._latlng, }) }) - - // Toggling rereveals hidden features, so make sure they stay hidden - if (L_.toggledOffFeatures && L_.toggledOffFeatures.length > 0) { - L_.toggledOffFeatures.forEach((f) => { - L_.toggleFeature(f, false) - }) - } }, toggleSublayer: function (layerName, sublayerName) { - const sublayers = L_.layersGroupSublayers[layerName] || {} + layerName = L_.asLayerUUID(layerName) + + const sublayers = L_.layers.attachments[layerName] || {} const sublayer = sublayers[sublayerName] if (sublayer) { if (sublayer.on === true) { @@ -510,6 +564,7 @@ var L_ = { L_.Map_.rmNotNull(sublayer.layer) break case 'labels': + case 'pairings': sublayer.layer.off() break default: @@ -533,20 +588,21 @@ var L_ = { ) L_.Map_.map.addLayer(sublayer.layer) sublayer.layer.setZIndex( - L_.layersOrdered.length + + L_._layersOrdered.length + 1 - - L_.layersOrdered.indexOf(layerName) + L_._layersOrdered.indexOf(layerName) ) break case 'labels': - sublayer.layer.on() + case 'pairings': + sublayer.layer.on(false, sublayer.layer) break default: L_.Map_.map.addLayer(sublayer.layer) sublayer.layer.setZIndex( - L_.layersOrdered.length + + L_._layersOrdered.length + 1 - - L_.layersOrdered.indexOf(layerName) + L_._layersOrdered.indexOf(layerName) ) break } @@ -555,26 +611,26 @@ var L_ = { } }, disableAllBut: function (siteName, skipDisabling) { - if (L_.layersNamed.hasOwnProperty(siteName)) { + if (L_.layers.data.hasOwnProperty(siteName)) { let l if (skipDisabling !== true) { - for (let i = 0; i < L_.layersData.length; i++) { - l = L_.layersData[i] - if (L_.toggledArray[l.name] == true) { + for (let i = 0; i < L_.layers.dataFlat.length; i++) { + l = L_.layers.dataFlat[i] + if (L_.layers.on[l.name] == true) { if (l.name != 'Mars Overview') L_.toggleLayer(l) } - if (L_.toggledArray['Mars Overview'] === false) { + if (L_.layers.on['Mars Overview'] === false) { if (l.name === 'Mars Overview') L_.toggleLayer(l) } } } - for (let n in L_.layersParent) { - if (L_.layersParent[n] === siteName && L_.layersDataByName[n]) { - l = L_.layersDataByName[n] + for (let n in L_._layersParent) { + if (L_._layersParent[n] === siteName && L_.layers.data[n]) { + l = L_.layers.data[n] if ( l.visibility === true && // initial visibility - L_.toggledArray[l.name] === false + L_.layers.on[l.name] === false ) { L_.toggleLayer(l) } @@ -598,24 +654,24 @@ var L_ = { } else { map = map.map } - for (var i = L_.layersData.length - 1; i >= 0; i--) { + for (var i = L_.layers.dataFlat.length - 1; i >= 0; i--) { if ( (onlyTheseLayers == null || - onlyTheseLayers.includes(L_.layersData[i].name)) && - L_.toggledArray[L_.layersData[i].name] === true && - (L_.layersData[i].type === 'model' || - L_.layersGroup[L_.layersData[i].name] != null) + onlyTheseLayers.includes(L_.layers.dataFlat[i].name)) && + L_.layers.on[L_.layers.dataFlat[i].name] === true && + (L_.layers.dataFlat[i].type === 'model' || + L_.layers.layer[L_.layers.dataFlat[i].name] != null) ) { // Add Map layers - if (L_.layersGroup[L_.layersData[i].name]) { + if (L_.layers.layer[L_.layers.dataFlat[i].name]) { try { - if (L_.layersGroupSublayers[L_.layersData[i].name]) { - for (let s in L_.layersGroupSublayers[ - L_.layersData[i].name + if (L_.layers.attachments[L_.layers.dataFlat[i].name]) { + for (let s in L_.layers.attachments[ + L_.layers.dataFlat[i].name ]) { const sublayer = - L_.layersGroupSublayers[ - L_.layersData[i].name + L_.layers.attachments[ + L_.layers.dataFlat[i].name ][s] if (sublayer.on) { switch (sublayer.type) { @@ -637,7 +693,12 @@ var L_ = { map.addLayer(sublayer.layer) break case 'labels': - sublayer.layer.on() + case 'pairings': + if (sublayer.layer) + sublayer.layer.on( + false, + sublayer.layer + ) break default: map.addLayer(sublayer.layer) @@ -646,50 +707,50 @@ var L_ = { } } } - map.addLayer(L_.layersGroup[L_.layersData[i].name]) + map.addLayer( + L_.layers.layer[L_.layers.dataFlat[i].name] + ) // Set markerDiv based opacities if any $( - `.leafletMarkerShape_${L_.layersData[i].name - .replace(/\s/g, '') - .toLowerCase()}` + `.leafletMarkerShape_${F_.getSafeName( + L_.layers.dataFlat[i].name + )}` ).css({ opacity: - L_.opacityArray[L_.layersData[i].name] || 0, + L_.layers.opacity[L_.layers.dataFlat[i].name] || + 0, }) } catch (e) { console.log(e) console.warn( 'Warning: Failed to add layer to map: ' + - L_.layersData[i].name + L_.layers.dataFlat[i].name ) } } // Add Globe layers - const s = L_.layersData[i] + const s = L_.layers.dataFlat[i] let layerUrl = s.url if (!F_.isUrlAbsolute(layerUrl)) layerUrl = L_.missionPath + layerUrl - if ( - L_.layersData[i].type === 'tile' || - L_.layersData[i].type === 'data' - ) { + if (s.type === 'tile' || s.type === 'data') { // Make sure all tile layers follow z-index order at start instead of element order - L_.layersGroup[L_.layersData[i].name].setZIndex( - L_.layersOrdered.length + + L_.layers.layer[s.name].setZIndex( + L_._layersOrdered.length + 1 - - L_.layersOrdered.indexOf(L_.layersData[i].name) + L_._layersOrdered.indexOf(s.name) ) let demUrl = s.demtileurl if (!F_.isUrlAbsolute(demUrl)) demUrl = L_.missionPath + demUrl if (s.demtileurl == undefined) demUrl = undefined - if (L_.layersData[i].type === 'tile') + if (s.type === 'tile') L_.Globe_.litho.addLayer('tile', { name: s.name, - order: L_.layersOrdered, - on: L_.opacityArray[s.name], + order: L_._layersOrdered, + on: L_.layers.opacity[s.name], format: s.tileformat || 'tms', formatOptions: {}, demFormat: s.tileformat || 'tms', @@ -700,19 +761,19 @@ var L_ = { parser: s.demparser || null, path: layerUrl, demPath: demUrl, - opacity: L_.opacityArray[s.name], + opacity: L_.layers.opacity[s.name], minZoom: s.minZoom, maxZoom: s.maxNativeZoom, //boundingBox: s.boundingBox, //time: s.time == null ? '' : s.time.end, }) - } else if (L_.layersData[i].type === 'model') { + } else if (s.type === 'model') { L_.Globe_.litho.addLayer('model', { name: s.name, - order: L_.layersOrdered, + order: L_._layersOrdered, on: true, path: layerUrl, - opacity: L_.opacityArray[s.name], + opacity: L_.layers.opacity[s.name], position: { longitude: s.position?.longitude || 0, latitude: s.position?.latitude || 0, @@ -726,17 +787,17 @@ var L_ = { z: s.rotation?.z || 0, }, }) - } else if (L_.layersData[i].type != 'header') { - if (typeof L_.layersGroup[s.name].toGeoJSON === 'function') + } else if (s.type != 'header') { + if (typeof L_.layers.layer[s.name].toGeoJSON === 'function') L_.Globe_.litho.addLayer( - L_.layersData[i].type == 'vector' - ? L_.layersData[i].layer3dType || 'clamped' - : L_.layersData[i].type, + s.type == 'vector' + ? s.layer3dType || 'clamped' + : s.type, { name: s.name, - order: L_.layersOrdered, // Since higher order in litho is on top - on: L_.opacityArray[s.name] ? true : false, - geojson: L_.layersGroup[s.name].toGeoJSON( + order: L_._layersOrdered, // Since higher order in litho is on top + on: L_.layers.opacity[s.name] ? true : false, + geojson: L_.layers.layer[s.name].toGeoJSON( L_.GEOJSON_PRECISION ), onClick: (feature, lnglat, layer) => { @@ -760,7 +821,7 @@ var L_ = { ? s.variables.markerAttachments.bearing : null, }, - opacity: L_.opacityArray[s.name], + opacity: L_.layers.opacity[s.name], minZoom: s.visibilitycutoff > 0 ? s.visibilitycutoff @@ -774,8 +835,10 @@ var L_ = { } } } + + L_._refreshAnnotationEvents() }, - addGeoJSONData: async function (layer, geojson) { + addGeoJSONData: function (layer, geojson) { if (layer._sourceGeoJSON) { if (layer._sourceGeoJSON.features) if (geojson.features) @@ -794,31 +857,40 @@ var L_ = { // Don't add data if hidden if ( - L_.layersNamed[layer._layerName] && + L_.layers.data[layer._layerName] && F_.getIn( - L_.layersNamed[layer._layerName], + L_.layers.data[layer._layerName], 'variables.hideMainFeature' ) === true ) return - const initialOn = L_.toggledArray[layer._layerName] + const initialOn = L_.layers.on[layer._layerName] // Remove layer - L_.Map_.rmNotNull(L_.layersGroup[layer._layerName]) + L_.Map_.rmNotNull(L_.layers.layer[layer._layerName]) // Remove sublayers L_.syncSublayerData(layer._layerName, true) - // Remake Layer - await L_.Map_.makeLayer( - L_.layersNamed[layer._layerName], + L_.Map_.makeLayer( + L_.layers.data[layer._layerName], true, layer._sourceGeoJSON ) if (initialOn) { - L_.toggleLayerHelper(L_.layersNamed[layer._layerName], false) - L_.toggledArray[layer._layerName] = true + L_.toggleLayerHelper(L_.layers.data[layer._layerName], false) + L_.layers.on[layer._layerName] = true + } + //L_.syncSublayerData(layer._layerName) + + if (initialOn) { + // Reselect activeFeature + if (L_.activeFeature) { + L_.selectFeature( + L_.activeFeature.layerName, + L_.activeFeature.feature + ) + } } - L_.syncSublayerData(layer._layerName) }, clearGeoJSONData: function (layer) { if (layer._sourceGeoJSON) layer._sourceGeoJSON = F_.getBaseGeoJSON() @@ -877,10 +949,12 @@ var L_ = { L_.clearVectorLayerInfo() } }, - highlight(layer) { + highlight(layer, forceColor) { if (layer == null) return const color = - (L_.configData.look && L_.configData.look.highlightcolor) || 'red' + forceColor || + (L_.configData.look && L_.configData.look.highlightcolor) || + 'red' try { if ( layer.feature?.properties?.annotation === true && @@ -897,9 +971,12 @@ var L_ = { color ) } else { + const savedOptions = JSON.parse(JSON.stringify(layer.options)) layer.setStyle({ color: color, + stroke: color, }) + layer.options = savedOptions } } catch (err) { if (layer._icon) @@ -952,19 +1029,22 @@ var L_ = { } L_.Map_.orderedBringToFront() L_.setActiveFeature(L_.activeFeature?.layer) + L_._refreshAnnotationEvents() }, /** * * @param {string[]} forceLayerNames - Enforce visibilities per layer */ enforceVisibilityCutoffs: function (forceLayerNames) { - const layerNames = forceLayerNames || Object.keys(L_.layersGroup) + const layerNames = forceLayerNames || Object.keys(L_.layers.layer) layerNames.forEach((layerName) => { - let layerObj = L_.layersNamed[layerName] - let layer = L_.layersGroup[layerName] + const layerDisplayName = layerName + layerName = L_.asLayerUUID(layerName) + let layerObj = L_.layers.data[layerName] + let layer = L_.layers.layer[layerName] - if (layerObj == null && layerName.includes('DrawTool')) + if (layerObj == null && layerDisplayName.includes('DrawTool')) layerObj = { type: 'vector', } @@ -976,8 +1056,8 @@ var L_ = { layerObj != null && layerObj.type === 'vector' && layer && - (L_.layersNamed[layerName] - ? L_.Map_.map.hasLayer(L_.layersGroup[layerName]) + (L_.layers.data[layerName] + ? L_.Map_.map.hasLayer(L_.layers.layer[layerName]) : true) ) { let minZoom = null @@ -1211,19 +1291,19 @@ var L_ = { } return arrowLayer } else { - if (index == null) index = L_.layersGroup[layerId].length - L_.Map_.rmNotNull(L_.layersGroup[layerId][index]) - L_.layersGroup[layerId][index] = L.layerGroup([ + if (index == null) index = L_.layers.layer[layerId].length + L_.Map_.rmNotNull(L_.layers.layer[layerId][index]) + L_.layers.layer[layerId][index] = L.layerGroup([ arrowBodyOutline, arrowHeadOutline, arrowBody, arrowHead, ]).addTo(L_.Map_.map) - L_.layersGroup[layerId][index]._isArrow = true - L_.layersGroup[layerId][index]._idx = index - L_.layersGroup[layerId][index].start = start - L_.layersGroup[layerId][index].end = end - L_.layersGroup[layerId][index].feature = feature + L_.layers.layer[layerId][index]._isArrow = true + L_.layers.layer[layerId][index]._idx = index + L_.layers.layer[layerId][index].start = start + L_.layers.layer[layerId][index].end = end + L_.layers.layer[layerId][index].feature = feature if (typeof indexedCallback === 'function') indexedCallback() } }, @@ -1271,6 +1351,8 @@ var L_ = { closeOnClick: false, autoPan: false, offset: new L.point(0, 3), + interactive: true, + bubblingMouseEvents: true }) .setLatLng( new L.LatLng( @@ -1284,13 +1366,18 @@ var L_ = { ` class='${className === 'DrawToolAnnotation' ? 'drawToolAnnotation' : 'mmgisAnnotation'} ${className}_${id1} blackTextBorder'` + " layer='" + id1 + "' layerId='" + layerId + - (L_.layersGroup[layerId] != null ? "' index='" + L_.layersGroup[layerId].length : '') + + (L_.layers.layer[layerId] != null ? "' index='" + L_.layers.layer[layerId].length : '') + "' style='" + styleString + "'>" + `${feature.properties.name.replace(/[<>;{}]/g, '')}`, '</div>' + '</div>' ) + if (popup?._contentNode?._leaflet_events) + Object.keys(popup._contentNode._leaflet_events).forEach((ev) => { + delete popup._contentNode._leaflet_events[ev] + }) + popup._isAnnotation = true popup._annotationParams = { feature, @@ -1306,21 +1393,56 @@ var L_ = { popup.toGeoJSON = function () { return feature } + if (andAddToMap) { popup.addTo(L_.Map_.map) - L_.layersGroup[layerId].push(popup) + L_.removePopupStopPropogationFunctions(popup) + L_.layers.layer[layerId].push(popup) + } else { + setTimeout(() => { + L_.removePopupStopPropogationFunctions(popup) + }, 2000) } return popup }, + removePopupStopPropogationFunctions(popup) { + if (popup?._contentNode?._leaflet_events) + Object.keys(popup._contentNode._leaflet_events).forEach((ev) => { + document + .querySelectorAll('.leaflet-popup-content') + .forEach(function (elm) { + // Now do something with my button + elm.removeEventListener( + 'wheel', + popup._contentNode._leaflet_events[ev] + ) + }) + }) + + if (popup?._container?.children?.[0]?._leaflet_events) + Object.keys(popup._container.children[0]._leaflet_events).forEach( + (ev) => { + document + .querySelectorAll('.leaflet-popup-content-wrapper') + .forEach(function (elm) { + // Now do something with my button + elm.removeEventListener( + ev.replace(/\d+$/, ''), + popup._container.children[0]._leaflet_events[ev] + ) + }) + } + ) + }, setLayerOpacity: function (name, newOpacity) { newOpacity = parseFloat(newOpacity) if (L_.Globe_) L_.Globe_.litho.setLayerOpacity(name, newOpacity) - let l = L_.layersGroup[name] + let l = L_.layers.layer[name] if (l.options.initialFillOpacity == null) l.options.initialFillOpacity = - L_.layersStyles[name]?.fillOpacity != null - ? parseFloat(L_.layersStyles[name]?.fillOpacity) + L_.layers.data[name]?.style?.fillOpacity != null + ? parseFloat(L_.layers.data[name].style.fillOpacity) : 1 if (l) { @@ -1331,14 +1453,12 @@ var L_ = { opacity: newOpacity, fillOpacity: newOpacity * l.options.initialFillOpacity, }) - $( - `.leafletMarkerShape_${name - .replace(/\s/g, '') - .toLowerCase()}` - ).css({ opacity: newOpacity }) + $(`.leafletMarkerShape_${F_.getSafeName(name)}`).css({ + opacity: newOpacity, + }) } - const sublayers = L_.layersGroupSublayers[name] + const sublayers = L_.layers.attachments[name] if (sublayers) { for (let sub in sublayers) { if ( @@ -1382,10 +1502,10 @@ var L_ = { l.options.opacity = newOpacity } } - L_.opacityArray[name] = newOpacity + L_.layers.opacity[name] = newOpacity }, getLayerOpacity: function (name) { - var l = L_.layersGroup[name] + var l = L_.layers.layer[name] if (l == null) return 0 @@ -1400,7 +1520,7 @@ var L_ = { setLayerFilter: function (name, filter, value) { // Clear if (filter === 'clear') { - L_.layerFilters[name] = {} + L_.layers.filters[name] = {} if (L_.Globe_) { L_.Globe_.litho.setLayerFilterEffect(name, 'brightness', 1) L_.Globe_.litho.setLayerFilterEffect(name, 'contrast', 1) @@ -1409,10 +1529,10 @@ var L_ = { } } // Create a filters object for the layer if one doesn't exist - L_.layerFilters[name] = L_.layerFilters[name] || {} + L_.layers.filters[name] = L_.layers.filters[name] || {} // Set the new filter (if it's not 'clear') - if (filter !== 'clear') L_.layerFilters[name][filter] = value + if (filter !== 'clear') L_.layers.filters[name][filter] = value // Mappings because litho names things differently const lithoBlendMappings = ['none', 'overlay', 'color'] @@ -1422,59 +1542,63 @@ var L_ = { saturate: 'saturation', } - if (typeof L_.layersGroup[name].updateFilter === 'function') { + if (typeof L_.layers.layer[name].updateFilter === 'function') { let filterArray = [] // Apply filter effects - for (let f in L_.layerFilters[name]) { - filterArray.push(f + ':' + L_.layerFilters[name][f]) + for (let f in L_.layers.filters[name]) { + filterArray.push(f + ':' + L_.layers.filters[name][f]) // For Globe/litho if (L_.Globe_) { if (f === 'mix-blend-mode') { L_.Globe_.litho.setLayerFilterEffect( name, 'blendCode', - lithoBlendMappings.indexOf(L_.layerFilters[name][f]) + lithoBlendMappings.indexOf( + L_.layers.filters[name][f] + ) ) } else { L_.Globe_.litho.setLayerFilterEffect( name, lithoFilterMappings[f], - parseFloat(L_.layerFilters[name][f]) + parseFloat(L_.layers.filters[name][f]) ) } } } // For Map - L_.layersGroup[name].updateFilter(filterArray) + L_.layers.layer[name].updateFilter(filterArray) } }, - resetLayerFills: function () { + resetLayerFills: function (onlyThisLayerName) { // Regular Layers - for (let key in this.layersGroup) { - var s = key.split('_') - var onId = s[1] != 'master' ? parseInt(s[1]) : s[1] + for (let key in L_.layers.layer) { + const s = key.split('_') + const onId = s[1] != 'master' ? parseInt(s[1]) : s[1] + + if (onlyThisLayerName != null && onlyThisLayerName !== key) continue if ( - (this.layersGroup[key] && - this.layersNamed[key] && - (this.layersNamed[key].type == 'point' || - (key.toLowerCase().indexOf('draw') == -1 && - (this.layersNamed[key].type === 'vector' || - this.layersNamed[key].type === 'query')))) || - (s[0] == 'DrawTool' && !Number.isNaN(onId)) + (L_.layers.layer[key] && + L_.layers.data[key] && + (L_.layers.data[key].type === 'point' || + (key.toLowerCase().indexOf('draw') === -1 && + (L_.layers.data[key].type === 'vector' || + L_.layers.data[key].type === 'query')))) || + (s[0] === 'DrawTool' && !Number.isNaN(onId)) ) { if ( - this.layersGroup.hasOwnProperty(key) && - this.layersGroup[key] != undefined && - this.layersStyles.hasOwnProperty(key) && - this.layersStyles[key] != undefined + L_.layers.layer.hasOwnProperty(key) && + L_.layers.layer[key] != undefined && + L_.layers.data.hasOwnProperty(key) && + L_.layers.data[key].style != undefined ) { - this.layersGroup[key].eachLayer((layer) => { + L_.layers.layer[key].eachLayer((layer) => { const savedOptions = layer.options const savedUseKeyAsName = layer.useKeyAsName - let fillColor = this.layersStyles[key].fillColor - let color = this.layersStyles[key].color + let fillColor = L_.layers.data[key].style.fillColor + let color = L_.layers.data[key].style.color let opacity = layer.options.opacity let fillOpacity = layer.options.fillOpacity let weight = layer.options.weight @@ -1498,8 +1622,9 @@ var L_ = { `.LayerArrow_${layer._idx}.mmgisArrowOutline` ).css('stroke', '') } else { - L_.layersGroup[key].resetStyle(layer) + L_.layers.layer[key].resetStyle(layer) } + try { layer.setStyle({ opacity: opacity, @@ -1507,6 +1632,7 @@ var L_ = { fillColor: layer.options.fillColor || fillColor, weight: parseInt(weight), color: layer.options.color || color, + stroke: layer.options.color || color, }) } catch (err) { if (layer._icon) layer._icon.style.filter = '' @@ -1514,11 +1640,11 @@ var L_ = { layer.options = savedOptions layer.useKeyAsName = savedUseKeyAsName }) - } else if (s[0] == 'DrawTool') { - for (let k in this.layersGroup[key]) { - if (!this.layersGroup[key][k]) continue - if ('getLayers' in this.layersGroup[key][k]) { - let layer = this.layersGroup[key][k] + } else if (s[0] === 'DrawTool') { + for (let k in L_.layers.layer[key]) { + if (!L_.layers.layer[key][k]) continue + if ('getLayers' in L_.layers.layer[key][k]) { + let layer = L_.layers.layer[key][k] if (!layer?.feature?.properties?.arrow) { // Polygons and lines layer.eachLayer(function (l) { @@ -1526,9 +1652,9 @@ var L_ = { }) } else { // Arrow - let layers = this.layersGroup[key][k]._layers + let layers = L_.layers.layer[key][k]._layers const style = - this.layersGroup[key][k].feature.properties + L_.layers.layer[key][k].feature.properties .style const color = style.color layers[Object.keys(layers)[0]].setStyle({ @@ -1539,11 +1665,11 @@ var L_ = { }) } } else if ( - this.layersGroup[key][k].feature?.properties + L_.layers.layer[key][k].feature?.properties ?.annotation ) { // Annotation - let layer = this.layersGroup[key][k] + let layer = L_.layers.layer[key][k] let id = '#DrawToolAnnotation_' + layer.feature.properties._.file_id + @@ -1553,9 +1679,9 @@ var L_ = { 'color', layer.feature.properties.style.fillColor ) - } else if ('feature' in this.layersGroup[key][k]) { + } else if ('feature' in L_.layers.layer[key][k]) { // Points (that are not annotations) - let layer = this.layersGroup[key][k] + let layer = L_.layers.layer[key][k] setLayerStyle(layer) } } @@ -1572,6 +1698,7 @@ var L_ = { if (typeof layer.setStyle === 'function') layer.setStyle({ color: color, + stroke: color, }) else if (layer._icon?.style) { layer._icon.style.filter = 'unset' @@ -1585,21 +1712,21 @@ var L_ = { // Currently only coordinate_markers // Expects feature._style to be set const highlightableSublayers = ['coordinate_markers'] - for (let layerName in this.layersGroupSublayers) { - if (this.layersGroupSublayers[layerName]) { - for (let sublayerName in this.layersGroupSublayers[layerName]) { + for (let layerName in L_.layers.attachments) { + if (L_.layers.attachments[layerName]) { + for (let sublayerName in L_.layers.attachments[layerName]) { if ( - this.layersGroupSublayers[layerName][sublayerName] && + L_.layers.attachments[layerName][sublayerName] && highlightableSublayers.includes(sublayerName) ) { - for (let sll in this.layersGroupSublayers[layerName][ + for (let sll in L_.layers.attachments[layerName][ sublayerName ].layer._layers) { try { - this.layersGroupSublayers[layerName][ + L_.layers.attachments[layerName][ sublayerName ].layer._layers[sll].setStyle( - this.layersGroupSublayers[layerName][ + L_.layers.attachments[layerName][ sublayerName ].layer._layers[sll].feature._style ) @@ -1668,7 +1795,9 @@ var L_ = { } }, selectFeature(layerName, feature) { - const layer = L_.layersGroup[layerName] + layerName = L_.asLayerUUID(layerName) + + const layer = L_.layers.layer[layerName] if (layer) { const layers = layer._layers for (let l in layers) { @@ -1694,7 +1823,7 @@ var L_ = { * Converts lnglat geojsons into the primary coordinate type. * @param {object} geojson - geojson object or geojson feature */ - convertGeoJSONLngLatsToPrimaryCoordinates(geojson) { + convertGeoJSONLngLatsToPrimaryCoordinates(geojson, forceType) { if (geojson.features) { const nextGeoJSON = JSON.parse(JSON.stringify(geojson)) const convertedFeatures = [] @@ -1707,7 +1836,8 @@ var L_ = { const elev = coords[2] converted = L_.Coordinates.convertLngLat( coords[0], - coords[1] + coords[1], + forceType ) if (elev != null) converted[2] = elev return converted @@ -1731,7 +1861,8 @@ var L_ = { const elev = coords[2] converted = L_.Coordinates.convertLngLat( coords[0], - coords[1] + coords[1], + forceType ) if (elev != null) converted[2] = elev return converted @@ -1740,19 +1871,30 @@ var L_ = { return feature } }, + asLayerUUID(uuid) { + if (L_.layers.data[uuid] != null) return uuid + if (L_.layers.nameToUUID[uuid]?.[0] != null) + return L_.layers.nameToUUID[uuid][0] + return null + }, /** - * @param {object} - activePoint { layerName: , lat: lon: } + * @param {object} - activePoint { layerUUID: , lat: lon: } * @returns {bool} - true only if successful */ selectPoint(activePoint) { + if (activePoint == null) return false + // Backward pre-uuid compatibility + activePoint.layerUUID = L_.asLayerUUID( + activePoint.layerUUID || activePoint.layerName + ) + if ( - activePoint && - activePoint.layerName != null && + activePoint.layerUUID != null && activePoint.lat != null && activePoint.lon != null ) { - if (L_.layersGroup.hasOwnProperty(activePoint.layerName)) { - let g = L_.layersGroup[activePoint.layerName]._layers + if (L_.layers.layer.hasOwnProperty(activePoint.layerUUID)) { + let g = L_.layers.layer[activePoint.layerUUID]._layers for (let l in g) { if ( g[l]._latlng.lat == activePoint.lat && @@ -1765,13 +1907,12 @@ var L_ = { } } } else if ( - activePoint && - activePoint.layerName != null && + activePoint.layerUUID != null && activePoint.key != null && activePoint.value != null ) { - if (L_.layersGroup.hasOwnProperty(activePoint.layerName)) { - let g = L_.layersGroup[activePoint.layerName]._layers + if (L_.layers.layer.hasOwnProperty(activePoint.layerUUID)) { + let g = L_.layers.layer[activePoint.layerUUID]._layers for (let l in g) { if (g[l] && g[l].feature && g[l].feature.properties) { if ( @@ -1788,12 +1929,11 @@ var L_ = { } } } else if ( - activePoint && - activePoint.layerName != null && + activePoint.layerUUID != null && activePoint.layerId != null ) { - if (L_.layersGroup.hasOwnProperty(activePoint.layerName)) { - let g = L_.layersGroup[activePoint.layerName]._layers + if (L_.layers.layer.hasOwnProperty(activePoint.layerUUID)) { + let g = L_.layers.layer[activePoint.layerUUID]._layers const l = activePoint.layerId if (g[l] != null) { g[l].fireEvent('click') @@ -1840,12 +1980,15 @@ var L_ = { L_.Globe_.litho.setCenter(newView) } } + setTimeout(() => { + L_.setActiveFeature(layer) + }, 300) }, reorderLayers: function (newLayersOrdered) { // Check that newLayersOrdered is valid let isValid = true - if (newLayersOrdered.length === L_.layersOrdered.length) { - L_.layersOrdered.forEach((l) => { + if (newLayersOrdered.length === L_._layersOrdered.length) { + L_._layersOrdered.forEach((l) => { if (!newLayersOrdered.includes(l)) isValid = false }) } else isValid = false @@ -1857,15 +2000,16 @@ var L_ = { return } - L_.layersOrdered = newLayersOrdered + L_._layersOrdered = newLayersOrdered if (L_.Map_) L_.Map_.orderedBringToFront(true) - if (L_.Globe_) L_.Globe_.litho.orderLayers(L_.layersOrdered) + if (L_.Globe_) L_.Globe_.litho.orderLayers(L_._layersOrdered) }, clearVectorLayer: function (layerName) { + layerName = L_.asLayerUUID(layerName) try { - L_.clearGeoJSONData(L_.layersGroup[layerName]) + L_.clearGeoJSONData(L_.layers.layer[layerName]) L_.clearVectorLayerInfo() L_.syncSublayerData(layerName) } catch (e) { @@ -1920,6 +2064,7 @@ var L_ = { timePropPath, trimType ) { + layerName = L_.asLayerUUID(layerName) // Validate input parameters if (!keepTime) { console.warn( @@ -1952,8 +2097,8 @@ var L_ = { } } - if (layerName in L_.layersGroup) { - const updateLayer = L_.layersGroup[layerName] + if (layerName in L_.layers.layer) { + const updateLayer = L_.layers.layer[layerName] if (keepTime) { const layersGeoJSON = updateLayer.toGeoJSON( @@ -2008,6 +2153,7 @@ var L_ = { L_.keepNHelper(layerName, keepLastN, 'last') }, keepNHelper: function (layerName, keepN, keepType) { + layerName = L_.asLayerUUID(layerName) // Validate input parameter const keepNum = parseInt(keepN) if (Number.isNaN(Number(keepNum))) { @@ -2023,10 +2169,10 @@ var L_ = { return } - if (layerName in L_.layersGroup) { + if (layerName in L_.layers.layer) { // Keep N elements if greater than 0 else keep all elements if (keepN && keepN > 0) { - const updateLayer = L_.layersGroup[layerName] + const updateLayer = L_.layers.layer[layerName] var layers = updateLayer.getLayers() const layersGeoJSON = updateLayer.toGeoJSON( @@ -2082,6 +2228,8 @@ var L_ = { } }, trimLineString: function (layerName, time, timeProp, trimN, startOrEnd) { + layerName = L_.asLayerUUID(layerName) + // Validate input parameters if (!time) { console.warn( @@ -2146,10 +2294,9 @@ var L_ = { return } - if (layerName in L_.layersGroup) { - const updateLayer = L_.layersGroup[layerName] + if (layerName in L_.layers.layer) { + const updateLayer = L_.layers.layer[layerName] - var layers = updateLayer.getLayers() var layersGeoJSON = updateLayer.toGeoJSON(L_.GEOJSON_PRECISION) var features = layersGeoJSON.features @@ -2297,6 +2444,8 @@ var L_ = { } }, appendLineString: function (layerName, inputData, timeProp) { + layerName = L_.asLayerUUID(layerName) + // Validate input parameter if (!inputData) { console.warn( @@ -2321,8 +2470,8 @@ var L_ = { return } - if (layerName in L_.layersGroup) { - const updateLayer = L_.layersGroup[layerName] + if (layerName in L_.layers.layer) { + const updateLayer = L_.layers.layer[layerName] var layers = updateLayer.getLayers() var layersGeoJSON = updateLayer.toGeoJSON(L_.GEOJSON_PRECISION) @@ -2384,9 +2533,24 @@ var L_ = { return } - L_.clearVectorLayerInfo() + const initialOn = L_.layers.on[layerName] + if (initialOn) { + L_.toggleLayerHelper(L_.layers.data[layerName], false) + L_.layers.on[layerName] = true + } + L_.clearGeoJSONData(updateLayer) L_.addGeoJSONData(updateLayer, layersGeoJSON) + + if (initialOn) { + // Reselect activeFeature + if (L_.activeFeature) { + L_.selectFeature( + L_.activeFeature.layerName, + L_.activeFeature.feature + ) + } + } } else { console.warn( 'Warning: Unable to append to the vector layer `' + @@ -2403,8 +2567,10 @@ var L_ = { } }, updateVectorLayer: function (layerName, inputData) { - if (layerName in L_.layersGroup) { - const updateLayer = L_.layersGroup[layerName] + layerName = L_.asLayerUUID(layerName) + + if (layerName in L_.layers.layer) { + const updateLayer = L_.layers.layer[layerName] try { L_.addGeoJSONData(updateLayer, inputData) @@ -2426,16 +2592,18 @@ var L_ = { } }, // Make a layer's sublayer match the layers data again - syncSublayerData: function (layerName, onlyClear) { + syncSublayerData: async function (layerName, onlyClear) { + layerName = L_.asLayerUUID(layerName) + try { - let geojson = L_.layersGroup[layerName].toGeoJSON( + let geojson = L_.layers.layer[layerName].toGeoJSON( L_.GEOJSON_PRECISION ) - if (L_.layersGroup[layerName]._sourceGeoJSON) - geojson = L_.layersGroup[layerName]._sourceGeoJSON + if (L_.layers.layer[layerName]._sourceGeoJSON) + geojson = L_.layers.layer[layerName]._sourceGeoJSON // Now try the sublayers (if any) - const subUpdateLayers = L_.layersGroupSublayers[layerName] + const subUpdateLayers = L_.layers.attachments[layerName] if (subUpdateLayers) { for (let sub in subUpdateLayers) { @@ -2449,18 +2617,19 @@ var L_ = { if ( typeof subUpdateLayers[sub].layer .addDataEnhanced === 'function' - ) + ) { subUpdateLayers[sub].layer.addDataEnhanced( geojson, layerName, sub, L_.Map_ ) - else if ( + } else if ( typeof subUpdateLayers[sub].layer.addData === 'function' - ) + ) { subUpdateLayers[sub].layer.addData(geojson) + } } } } @@ -2472,12 +2641,12 @@ var L_ = { ) } - L_.globeLithoLayerHelper(L_.layersNamed[layerName], onlyClear) + await L_.globeLithoLayerHelper(L_.layers.data[layerName], onlyClear) }, clearVectorLayerInfo: function () { // Clear the InfoTools data const infoTool = ToolController_.getTool('InfoTool') - if (infoTool.hasOwnProperty('clearInfo')) { + if (infoTool && infoTool.hasOwnProperty('clearInfo')) { infoTool.clearInfo() } @@ -2490,67 +2659,167 @@ var L_ = { if (L_.Globe_) { // Only toggle the layer to reset if the layer is toggled on, // because if the layer is toggled off, it is not on the globe - if (L_.toggledArray[s.name]) { + if (L_.layers.on[s.name]) { // turn off - await L_.toggleLayerHelper(s, true, true) + await L_.toggleLayerHelper(s, true, true, true) // Toggle the layer so its drawn in the globe // turn on - if (!onlyClear) L_.toggleLayerHelper(s, false, true) + if (!onlyClear) await L_.toggleLayerHelper(s, false, true, true) } } }, parseConfig: parseConfig, - // Dynamically add a new layer or update a layer (used by WebSocket) - addNewLayer: async function (data, layerName, type) { - // Save so we can make sure we reproduce the same layer settings after parsing the config - const toggledArray = { ...L_.toggledArray } - // Save the original layer ordering - const origLayersOrdered = [...L_.layersOrdered] + resetConfig: function (data) { + // Save so we can make sure we reproduce the same layer settings after parsing the config + const toggledArray = { ...L_.layers.on } // Reset for now - L_.toggledArray = {} + L_.layers.on = {} // Reset as these are appended to by parseConfig - L_.indentArray = [] - L_.layersOrdered = [] - L_.layersOrderedFixed = [] - L_.layersData = [] - L_.layersLoaded = [] + L_._layersOrdered = [] + L_.layers.dataFlat = [] + L_._layersLoaded = [] L_.parseConfig(data) // Set back - L_.toggledArray = { ...L_.toggledArray, ...toggledArray } + L_.layers.on = { ...L_.layers.on, ...toggledArray } + }, + // Dynamically add a new layer or update a layer (used by WebSocket) + modifyLayer: async function (data, layerName, type) { + layerName = L_.asLayerUUID(layerName) - const newLayersOrdered = [...L_.layersOrdered] - const index = L_.layersOrdered.findIndex((name) => name === layerName) + const newLayersOrdered = [...L_._layersOrdered] + const index = L_._layersOrdered.findIndex((name) => name === layerName) newLayersOrdered.splice(index, 1) - if (type === 'updateLayer' && layerName in L_.layersNamed) { + if (type === 'updateLayer' && layerName in L_.layers.data) { // Update layer - await L_.TimeControl_.reloadLayer(layerName, true) + await L_.TimeControl_.reloadLayer(layerName, true, true) } else if (type === 'addLayer') { - // Add layer - await L_.Map_.makeLayer(L_.layersDataByName[layerName]) - L_.addVisible(L_.Map_, [layerName]) + await L_.addLayerToLayersData(layerName) } else if (type === 'removeLayer') { - // If the layer is visible, we need to remove it, - // otherwise do nothing since its already removed from the map - if (layerName in L_.toggledArray && L_.toggledArray[layerName]) { - // Toggle it to remove it - await L_.toggleLayer(L_.layersNamed[layerName]) + await L_.removeLayerFromLayersData(layerName) + } + + if (ToolController_.activeToolName === 'LayersTool') { + const layersTool = ToolController_.getTool('LayersTool') + if (layersTool.destroy && layersTool.make) { + layersTool.destroy() + layersTool.make() + } + } + }, + addLayerToLayersData: async function (layerName) { + if (L_.layers.data[layerName]) { + // Recursively going through the new layer to get all of its sub layers + const layersOrdered = L_.expandLayersToArray([ + L_.layers.data[layerName], + ]) + + if (!layersOrdered.includes(layerName)) { + // If the new layer is a header, we need to add it to the list of layers + layersOrdered.push(layerName) + } + layersOrdered.reverse() + + for (let i = 0; i < layersOrdered.length; i++) { + // Add layer + await L_.Map_.makeLayer(L_.layers.data[layersOrdered[i]]) + L_.addVisible(L_.Map_, [layersOrdered[i]]) + } + } + }, + removeLayerFromLayersData: async function (layerName) { + if (L_.layers.data[layerName]) { + // Recursively going through the removed layer to get all of its sub layers + const layersOrdered = L_.expandLayersToArray([ + L_.layers.data[layerName], + ]) + + if (!layersOrdered.includes(layerName)) { + // If the new layer is a header, we need to add it to the list of layers + layersOrdered.push(layerName) + } + + for (let i = 0; i < layersOrdered.length; i++) { + const layerUUID = layersOrdered[i] + + // If the layer is visible, we need to remove it, + // otherwise do nothing since its already removed from the map + if (layerUUID in L_.layers.on && L_.layers.on[layerUUID]) { + // Toggle it to remove it + await L_.toggleLayer(L_.layers.data[layerUUID]) + } + + const display_name = L_.layers.data[layerUUID].display_name + if (L_.layers.nameToUUID[display_name]) { + const index = + L_.layers.nameToUUID[display_name].indexOf(layerUUID) + if (index > -1) { + L_.layers.nameToUUID[display_name].splice(index, 1) + } + if (L_.layers.nameToUUID[display_name].length < 1) { + delete L_.layers.nameToUUID[display_name] + } + } + + delete L_.layers.layer[layerUUID] + delete L_.layers.data[layerUUID] + delete L_.layers.on[layerUUID] + delete L_.layers.attachments[layerUUID] + delete L_.layers.opacity[layerUUID] } - delete L_.toggledArray[layerName] } }, + expandLayersToArray: function (layer) { + // Recursively going through the removed layer to get all of its sub layers + const layersOrdered = [] + expandLayers(layer, 0, null) + + function expandLayers(d, level, prevName) { + //Iterate over each layer + for (let i = 0; i < d.length; i++) { + //Check if it's not a header and thus an actual layer with data + if (d[i].type != 'header') { + //Create parsed layers ordered + layersOrdered.push(d[i].name) + } + + //Get the current layers sublayers (returns 0 if none) + var dNext = getSublayers(d[i]) + //If they are sublayers, call this function again and move up a level + if (dNext != 0) { + expandLayers(dNext, level + 1, d[i].name) + } + } + } + //Get the current layers sublayers (returns 0 if none) + function getSublayers(d) { + //If object d has a sublayers property, return it + if (d.hasOwnProperty('sublayers')) { + return d.sublayers + } + //Otherwise return 0 + return 0 + } + + return layersOrdered + }, updateLayersHelper: async function (layerQueueList) { if (layerQueueList.length > 0) { + // If we have a few changes waiting in the queue, we only need to parse the config once + // as the last item in the queue should have the latest data + const lastLayer = layerQueueList[layerQueueList.length - 1] + L_.resetConfig(lastLayer.data) + while (layerQueueList.length > 0) { const firstLayer = layerQueueList.shift() const { data, newLayerName, type } = firstLayer - await L_.addNewLayer(data, newLayerName, type) + await L_.modifyLayer(data, newLayerName, type) } if (L_.Map_) L_.Map_.orderedBringToFront(true) @@ -2579,6 +2848,259 @@ var L_ = { updateQueueLayers: async function () { await L_.updateLayersHelper(L_.addLayerQueue) }, + // Limits a Local, Time-Enabled, Prop-set, vector layer to a range of time + // start and end are unix timestamps + timeFilterVectorLayer: function (layerName, start, end) { + layerName = L_.asLayerUUID(layerName) + + let reset = false + if (start === false) reset = true + + start = start || 0 + + const layerConfig = L_.layers.data[layerName] + const layer = L_.layers.layer[layerName] + + if ( + layerConfig.type === 'vector' && + layerConfig.time.type === 'local' && + layerConfig.time.endProp != null && + layer != false && + layer._sourceGeoJSON != null + ) { + const filteredGeoJSON = JSON.parse( + JSON.stringify( + L_._localTimeFilterCache[layerName] || layer._sourceGeoJSON + ) + ) + if (L_._localTimeFilterCache[layerName] == null) + L_._localTimeFilterCache[layerName] = JSON.parse( + JSON.stringify(filteredGeoJSON) + ) + + if (reset === false) { + filteredGeoJSON.features = filteredGeoJSON.features.filter( + (f) => { + let startTimeValue = false + if (layerConfig.time.startProp) + startTimeValue = F_.getIn( + f.properties, + layerConfig.time.startProp, + 0 + ) + let endTimeValue = false + if (layerConfig.time.endProp) + endTimeValue = F_.getIn( + f.properties, + layerConfig.time.endProp, + false + ) + + // No prop, won't show + if (endTimeValue === false) return false + + if (startTimeValue === false) { + //Single Point in time, just compare end times + let endDate = new Date(endTimeValue) + if (endDate == 'Invalid Date') return false + + endDate = endDate.getTime() + if (endDate <= end && endDate >= start) return true + return false + } else { + // Then we have a range + let startDate = new Date(startTimeValue) + let endDate = new Date(endTimeValue) + + // Bad prop value, won't show + if ( + startDate == 'Invalid Date' || + endDate == 'Invalid Date' + ) + return false + + startDate = startDate.getTime() + endDate = endDate.getTime() + + if (end < startDate) return false + if (start > endDate) return false + + return true + } + } + ) + } + // Update layer + L_.clearVectorLayer(layerName) + L_.updateVectorLayer(layerName, filteredGeoJSON) + } + }, + _updatePairings: function (layerName, on) { + Object.keys(L_.layers.layer).forEach((name) => { + if ( + L_.layers.on[name] && + L_.layers.attachments[name] && + L_.layers.attachments[name].pairings && + L_.layers.attachments[name].pairings.on && + L_.layers.attachments[name].pairings.pairedLayers.includes( + layerName + ) + ) { + L_.layers.attachments[name].pairings.layer.on( + false, + L_.layers.attachments[name].pairings.layer + ) + } + }) + }, + //Specific internal functions likely only to be used once + getLayersChosenNamePropVal(feature, layer) { + //These are what you'd think they'd be (Name could be thought of as key) + let propertyNames, propertyValues + let foundThroughVariables = false + + let layerName = + typeof layer === 'string' ? layer : layer?.options?.layerName + if (layerName != null) { + const l = L_.layers.data[layerName] + if ( + l && + l.hasOwnProperty('variables') && + l.variables.hasOwnProperty('useKeyAsName') + ) { + propertyNames = l.variables['useKeyAsName'] + if (typeof propertyNames === 'string') + propertyNames = [propertyNames] + propertyValues = Array(propertyNames.length).fill(null) + propertyNames.forEach((propertyName, idx) => { + if (feature.properties.hasOwnProperty(propertyName)) { + propertyValues[idx] = F_.getIn( + feature.properties, + propertyName + ) + if (propertyValues[idx] != null) + foundThroughVariables = true + } + }) + } + } + + // Use first key that is not an object + if (!foundThroughVariables) { + for (let key in feature.properties) { + //Default to show geometry type + propertyNames = ['Type'] + propertyValues = [feature.geometry.type] + + //Be certain we have that key in the feature + if ( + feature.properties.hasOwnProperty(key) && + (typeof feature.properties[key] === 'string' || + typeof feature.properties[key] === 'number') + ) { + //Store the current feature's key + propertyNames = [key] + //Store the current feature's value + propertyValues = [feature.properties[key]] + //Break out of for loop since we're done + break + } + } + } + return F_.stitchArrays(propertyNames, propertyValues) + }, + // Returns all feature at a leaflet map click + // e = {latlng: {lat, lng}, containerPoint?: {x, y}} + getFeaturesAtPoint(e, fullLayers) { + let features = [] + let correspondingLayerNames = [] + if (e.latlng && e.latlng.lng != null && e.latlng.lat != null) { + // To better intersect points on click we're going to buffer out a small bounding box + const mapRect = document + .getElementById('map') + .getBoundingClientRect() + + const wOffset = e.containerPoint?.x || mapRect.width / 2 + const hOffset = e.containerPoint?.y || mapRect.height / 2 + + let nwLatLong = L_.Map_.map.containerPointToLatLng([ + wOffset - 15, + hOffset - 15, + ]) + let seLatLong = L_.Map_.map.containerPointToLatLng([ + wOffset + 15, + hOffset + 15, + ]) + // If we didn't have a container click point, buffer out e.latlng + if (e.containerPoint == null) { + const lngDif = Math.abs(nwLatLong.lng - seLatLong.lng) / 2 + const latDif = Math.abs(nwLatLong.lat - seLatLong.lat) / 2 + nwLatLong = { + lng: e.latlng.lng - lngDif, + lat: e.latlng.lat - latDif, + } + seLatLong = { + lng: e.latlng.lng + lngDif, + lat: e.latlng.lat + latDif, + } + } + + // Find all the intersected points and polygons of the click + Object.keys(L_.layers.layer).forEach((lName) => { + if ( + (L_.layers.on[lName] && + (L_.layers.data[lName].type === 'vector' || + L_.layers.data[lName].type === 'query') && + L_.layers.layer[lName]) || + (lName.indexOf('DrawTool_') === 0 && + L_.layers.layer[lName]?.[0]?._map != null) + ) { + const nextFeatures = L.leafletPip + .pointInLayer( + [e.latlng.lng, e.latlng.lat], + L_.layers.layer[lName] + ) + .concat( + F_.pointsInPoint( + [e.latlng.lng, e.latlng.lat], + L_.layers.layer[lName], + [ + nwLatLong.lng, + seLatLong.lng, + nwLatLong.lat, + seLatLong.lat, + ] + ) + ) + .reverse() + features = features.concat(nextFeatures) + correspondingLayerNames = correspondingLayerNames.concat( + new Array(nextFeatures.length).fill().map(() => lName) + ) + } + }) + + if (features[0] == null) features = [] + else { + const swapFeatures = [] + features.forEach((f) => { + if ( + typeof f.type === 'string' && + f.type.toLowerCase() === 'feature' + ) + swapFeatures.push(f) + else if ( + f.feature && + typeof f.feature.type === 'string' && + f.feature.type.toLowerCase() === 'feature' + ) + swapFeatures.push(fullLayers ? f : f.feature) + }) + features = swapFeatures + } + } + return features + }, } //Takes in a configData object and does a depth-first search through its @@ -2640,45 +3162,45 @@ function parseConfig(configData, urlOnLayers) { L_.hasViewer = L_.configData.panels.indexOf('viewer') > -1 L_.hasGlobe = L_.configData.panels.indexOf('globe') > -1 //We only care about the layers now - var layers = L_.configData.layers - //Create parsed layers - L_.layers = layers - - //Because we want overall indecies and not local - let layerIndex = 0 + const layers = L_.configData.layers //Begin recursively going through those layers expandLayers(layers, 0, null) function expandLayers(d, level, prevName) { //Iterate over each layer - for (var i = 0; i < d.length; i++) { + for (let i = 0; i < d.length; i++) { + // Quick hack to use uuid instead of name as main id + d[i].uuid = d[i].uuid || d[i].name + if (L_.layers.nameToUUID[d[i].name] == null) + L_.layers.nameToUUID[d[i].name] = [] + + if (!L_.layers.nameToUUID[d[i].name].includes(d[i].uuid)) { + L_.layers.nameToUUID[d[i].name].push(d[i].uuid) + } + d[i] = { display_name: d[i].name, ...d[i] } + d[i].name = d[i].uuid || d[i].name + //Create parsed layers named - L_.layersNamed[d[i].name] = d[i] + L_.layers.data[d[i].name] = d[i] //Save the prevName for easy tracing back - L_.layersParent[d[i].name] = prevName - //Save the i - L_.layersIndex[d[i].name] = layerIndex - - layerIndex++ + L_._layersParent[d[i].name] = prevName //Check if it's not a header and thus an actual layer with data if (d[i].type != 'header') { //Create parsed layers ordered - L_.layersOrdered.push(d[i].name) + L_._layersOrdered.push(d[i].name) //Create parsed layers loaded if (d[i].type != 'data' && d[i].type != 'model') //No load checking for model since it's globe only - L_.layersLoaded.push(false) - else L_.layersLoaded.push(true) - //Create parsed layers styles - L_.layersStyles[d[i].name] = d[i].style - //Create parsed layers legends - L_.layersLegends[d[i].name] = d[i].legend + L_._layersLoaded.push(false) + else L_._layersLoaded.push(true) //relative or full path? - var legendPath = L_.layersLegends[d[i].name] - if (legendPath != undefined) { + let legendPath = d[i].legend + if (d[i]?.variables?.legend) { + L_.layers.data[d[i].name]._legend = d[i].variables.legend + } else if (legendPath != undefined) { if (!F_.isUrlAbsolute(legendPath)) legendPath = L_.missionPath + legendPath $.get( @@ -2686,50 +3208,43 @@ function parseConfig(configData, urlOnLayers) { (function (name) { return function (data) { data = F_.csvToJSON(data) - L_.layersLegendsData[name] = data + L_.layers.data[name]._legend = data } })(d[i].name) ) } - //Create parsed expand array - L_.expandArray[d[i].name] = true - //Create parsed expanded - L_.expanded[d[i].name] = false - } else { - //If it is a header, keep it closed - //Create parsed expand array - L_.expandArray[d[i].name] = false - //Create parsed expanded - L_.expanded[d[i].name] = true } //Create parsed layers data - L_.layersData.push(d[i]) - //And by name - L_.layersDataByName[d[i].name] = d[i] - //Create parsed indent array - L_.indentArray.push(level) + L_.layers.dataFlat.push(d[i]) + //Create parsed toggled array based on config layer visibility - L_.toggledArray[d[i].name] = + L_.layers.on[d[i].name] = d[i].visibility == undefined ? true : d[i].visibility // Headers always start as true // Toggling header visibility toggles between all-off and previous-on states - if (d[i].type === 'header') L_.toggledArray[d[i].name] = true + if (d[i].type === 'header') L_.layers.on[d[i].name] = true //Create parsed opacity array let io = d[i].initialOpacity - L_.opacityArray[d[i].name] = io == null || io < 0 || io > 1 ? 1 : io + L_.layers.opacity[d[i].name] = + io == null || io < 0 || io > 1 ? 1 : io //Set visibility if we have all the on layers listed in the url if (urlOnLayers) { //this is null if we've no url layers - if (urlOnLayers.onLayers.hasOwnProperty(d[i].name)) { - L_.toggledArray[d[i].name] = true - L_.opacityArray[d[i].name] = - urlOnLayers.onLayers[d[i].name].opacity || 1 + let standardId = null + if (urlOnLayers.onLayers.hasOwnProperty(d[i].name)) + standardId = d[i].name + else if (urlOnLayers.onLayers.hasOwnProperty(d[i].display_name)) + standardId = d[i].display_name + if (standardId != null) { + L_.layers.on[d[i].name] = true + L_.layers.opacity[d[i].name] = + urlOnLayers.onLayers[standardId].opacity || 1 } else if (urlOnLayers.method == 'replace') { - L_.toggledArray[d[i].name] = false + L_.layers.on[d[i].name] = false } } //Get the current layers sublayers (returns 0 if none) @@ -2739,9 +3254,6 @@ function parseConfig(configData, urlOnLayers) { expandLayers(dNext, level + 1, d[i].name) } } - - //Save the order of the layers - L_.layersOrderedFixed = L_.layersOrdered } //Get the current layers sublayers (returns 0 if none) function getSublayers(d) { @@ -2754,4 +3266,5 @@ function parseConfig(configData, urlOnLayers) { } } +window.L_ = L_ export default L_ diff --git a/src/essence/Basics/Layers_/leaflet-tilelayer-middleware.js b/src/essence/Basics/Layers_/leaflet-tilelayer-middleware.js index bc6e01c6..4372c723 100644 --- a/src/essence/Basics/Layers_/leaflet-tilelayer-middleware.js +++ b/src/essence/Basics/Layers_/leaflet-tilelayer-middleware.js @@ -11,6 +11,8 @@ https://github.com/xtk93x/Leaflet.TileLayer.ColorFilter */ +import F_ from '../../Basics/Formulae_/Formulae_' + var colorFilterExtension = { intialize: function (url, options) { L.TileLayer.prototype.initialize.call(this, url, options) @@ -22,8 +24,10 @@ var colorFilterExtension = { .replace(/{time}/g, this.options.time) .replace(/{starttime}/g, this.options.starttime) .replace(/{endtime}/g, this.options.endtime) - - if (this.options.time) url += `?time=${this.options.endtime}` + if (this.options.time && this.options.tileFormat === 'tms') { + url += `?starttime=${this.options.starttime}&time=${this.options.endtime}` + if (this.options.compositeTile === true) url += `&composite=true` + } return url }, colorFilter: function () { @@ -91,6 +95,37 @@ var colorFilterExtension = { this._container.style['mix-blend-mode'] = this.colorBlend() } }, + // Reduces tile flicker. This and refresh() from https://github.com/Leaflet/Leaflet/issues/6659#issuecomment-813328622 + _refreshTileUrl: function (tile, url) { + //use a image in background, so that only replace the actual tile, once image is loaded in cache! + let img = new Image() + img.onload = function (e) { + L.Util.requestAnimFrame(function () { + tile.el.src = url + tile.el.style.opacity = 1 + }) + } + img.onerror = function (e) { + tile.el.src = F_.getBase64Transparent256Tile() + tile.el.style.opacity = 0 + } + img.src = url + }, + refresh: function () { + if (this._map == null) return + + for (let key in this._tiles) { + const tile = this._tiles[key] + if (tile.current && tile.active) { + const oldsrc = tile.el.src + const newsrc = this.getTileUrl(tile.coords) + if (oldsrc != newsrc) { + //L.DomEvent.off(tile, 'load', this._tileOnLoad); ... this doesnt work! + this._refreshTileUrl(tile, newsrc) + } + } + } + }, } var wmsExtension = { @@ -232,7 +267,7 @@ L.TileLayer.ColorFilter = L.TileLayer.extend(colorFilterExtension) // We can't extend an already extended so we'll merge by hand L.TileLayer.WMSColorFilter = L.TileLayer.extend( - Object.assign(wmsExtension, colorFilterExtension) + Object.assign(colorFilterExtension, wmsExtension) ) L.tileLayer.colorFilter = function (url, options) { @@ -243,9 +278,15 @@ L.tileLayer.colorFilter = function (url, options) { const wmsOptions = {} const urlParams = new URLSearchParams(urlParamString) const entries = urlParams.entries() + for (const entry of entries) { wmsOptions[entry[0].toUpperCase()] = entry[1] } + if (wmsOptions.TILESIZE != null) { + wmsOptions.tileSize = parseInt(wmsOptions.TILESIZE) + delete wmsOptions.TILESIZE + } + if (wmsOptions.LAYERS == null) console.warn( `WARNING: WMS layer has no "layers" parameter in the url - ${url}` @@ -255,5 +296,7 @@ L.tileLayer.colorFilter = function (url, options) { } url = url.replace(/{t}/g, '_time_') - return new L.TileLayer.ColorFilter(url, options) + const tileLayer = new L.TileLayer.ColorFilter(url, options) + + return tileLayer } diff --git a/src/essence/Basics/Map_/Map_.js b/src/essence/Basics/Map_/Map_.js index cc051ed1..dc4f713a 100644 --- a/src/essence/Basics/Map_/Map_.js +++ b/src/essence/Basics/Map_/Map_.js @@ -17,6 +17,9 @@ import { Kinds } from '../../../pre/tools' import DataShaders from '../../Ancillary/DataShaders' import calls from '../../../pre/calls' import TimeControl from '../../Ancillary/TimeControl' + +import gjv from 'geojson-validation' + let L = window.L let essenceFina = function () {} @@ -185,7 +188,7 @@ let Map_ = { d3.select('.leaflet-control-attribution').remove() //Make our layers - makeLayers(L_.layersData) + makeLayers(L_.layers.dataFlat) //Just in case we have no layers allLayersLoaded() @@ -280,8 +283,8 @@ let Map_ = { }, //returns true if the map has the layer hasLayer: function (layername) { - if (L_.layersGroup[layername]) { - return Map_.map.hasLayer(L_.layersGroup[layername]) + if (L_.layers.layer[layername]) { + return Map_.map.hasLayer(L_.layers.layer[layername]) } return false }, @@ -315,28 +318,30 @@ let Map_ = { let hasIndex = [] let hasIndexRaster = [] - for (let i = L_.layersOrdered.length - 1; i >= 0; i--) { - if (Map_.hasLayer(L_.layersOrdered[i])) { - if (L_.layersNamed[L_.layersOrdered[i]]) { - if (L_.layersNamed[L_.layersOrdered[i]].type === 'vector') { - if (L_.layersGroupSublayers[L_.layersOrdered[i]]) { - for (let s in L_.layersGroupSublayers[ - L_.layersOrdered[i] + for (let i = L_._layersOrdered.length - 1; i >= 0; i--) { + if (Map_.hasLayer(L_._layersOrdered[i])) { + if (L_.layers.data[L_._layersOrdered[i]]) { + if ( + L_.layers.data[L_._layersOrdered[i]].type === 'vector' + ) { + if (L_.layers.attachments[L_._layersOrdered[i]]) { + for (let s in L_.layers.attachments[ + L_._layersOrdered[i] ]) { Map_.rmNotNull( - L_.layersGroupSublayers[ - L_.layersOrdered[i] - ][s].layer + L_.layers.attachments[L_._layersOrdered[i]][ + s + ].layer ) } } Map_.map.removeLayer( - L_.layersGroup[L_.layersOrdered[i]] + L_.layers.layer[L_._layersOrdered[i]] ) hasIndex.push(i) } else if ( - L_.layersNamed[L_.layersOrdered[i]].type === 'tile' || - L_.layersNamed[L_.layersOrdered[i]].type === 'data' + L_.layers.data[L_._layersOrdered[i]].type === 'tile' || + L_.layers.data[L_._layersOrdered[i]].type === 'data' ) { hasIndexRaster.push(i) } @@ -346,29 +351,29 @@ let Map_ = { // First only vectors for (let i = 0; i < hasIndex.length; i++) { - if (L_.layersGroupSublayers[L_.layersOrdered[hasIndex[i]]]) { - for (let s in L_.layersGroupSublayers[ - L_.layersOrdered[hasIndex[i]] + if (L_.layers.attachments[L_._layersOrdered[hasIndex[i]]]) { + for (let s in L_.layers.attachments[ + L_._layersOrdered[hasIndex[i]] ]) { if ( - L_.layersGroupSublayers[L_.layersOrdered[hasIndex[i]]][ - s - ].on + L_.layers.attachments[L_._layersOrdered[hasIndex[i]]][s] + .on ) { if ( - L_.layersGroupSublayers[ - L_.layersOrdered[hasIndex[i]] + L_.layers.attachments[ + L_._layersOrdered[hasIndex[i]] ][s].type !== 'model' - ) + ) { Map_.map.addLayer( - L_.layersGroupSublayers[ - L_.layersOrdered[hasIndex[i]] + L_.layers.attachments[ + L_._layersOrdered[hasIndex[i]] ][s].layer ) + } } } } - Map_.map.addLayer(L_.layersGroup[L_.layersOrdered[hasIndex[i]]]) + Map_.map.addLayer(L_.layers.layer[L_._layersOrdered[hasIndex[i]]]) } L_.enforceVisibilityCutoffs() @@ -376,11 +381,11 @@ let Map_ = { // Now only rasters // They're separate because its better to only change the raster z-index for (let i = 0; i < hasIndexRaster.length; i++) { - L_.layersGroup[L_.layersOrdered[hasIndexRaster[i]]].setZIndex( - L_.layersOrdered.length + + L_.layers.layer[L_._layersOrdered[hasIndexRaster[i]]].setZIndex( + L_._layersOrdered.length + 1 - - L_.layersOrdered.indexOf( - L_.layersOrdered[hasIndexRaster[i]] + L_._layersOrdered.indexOf( + L_._layersOrdered[hasIndexRaster[i]] ) ) } @@ -388,22 +393,22 @@ let Map_ = { refreshLayer: async function (layerObj) { // We need to find and remove all points on the map that belong to the layer // Not sure if there is a cleaner way of doing this - for (var i = L_.layersOrdered.length - 1; i >= 0; i--) { + for (var i = L_._layersOrdered.length - 1; i >= 0; i--) { if ( - L_.layersNamed[L_.layersOrdered[i]] && - L_.layersNamed[L_.layersOrdered[i]].type == 'vector' && - L_.layersNamed[L_.layersOrdered[i]].name == layerObj.name + L_.layers.data[L_._layersOrdered[i]] && + L_.layers.data[L_._layersOrdered[i]].type == 'vector' && + L_.layers.data[L_._layersOrdered[i]].name == layerObj.name ) { - const wasOn = L_.toggledArray[layerObj.name] - if (wasOn) L_.toggleLayer(L_.layersNamed[layerObj.name]) // turn off if on + const wasOn = L_.layers.on[layerObj.name] + if (wasOn) L_.toggleLayer(L_.layers.data[layerObj.name]) // turn off if on // fake on - L_.toggledArray[layerObj.name] = true + L_.layers.on[layerObj.name] = true await makeLayer(layerObj, true) L_.addVisible(Map_, [layerObj.name]) // turn off if was off - if (wasOn) L_.toggledArray[layerObj.name] = false - L_.toggleLayer(L_.layersNamed[layerObj.name]) // turn back on/off + if (wasOn) L_.layers.on[layerObj.name] = false + L_.toggleLayer(L_.layers.data[layerObj.name]) // turn back on/off L_.enforceVisibilityCutoffs() return @@ -508,44 +513,6 @@ let Map_ = { allLayersLoaded: allLayersLoaded, } -//Specific internal functions likely only to be used once -function getLayersChosenNamePropVal(feature, layer) { - //These are what you'd think they'd be (Name could be thought of as key) - var propertyName, propertyValue - var foundThroughVariables = false - if ( - layer.hasOwnProperty('options') && - layer.options.hasOwnProperty('layerName') - ) { - var l = L_.layersNamed[layer.options.layerName] - if ( - l.hasOwnProperty('variables') && - l.variables.hasOwnProperty('useKeyAsName') - ) { - propertyName = l.variables['useKeyAsName'] - if (feature.properties.hasOwnProperty(propertyName)) { - propertyValue = F_.getIn(feature.properties, propertyName) - if (propertyValue != null) foundThroughVariables = true - } - } - } - // Use first key - if (!foundThroughVariables) { - for (var key in feature.properties) { - //Store the current feature's key - propertyName = key - //Be certain we have that key in the feature - if (feature.properties.hasOwnProperty(key)) { - //Store the current feature's value - propertyValue = feature.properties[key] - //Break out of for loop since we're done - break - } - } - } - return { name: propertyName, value: propertyValue } -} - //Takes an array of layer objects and makes them map layers function makeLayers(layersObj) { //Make each layer (backwards to maintain draw order) @@ -587,32 +554,22 @@ async function makeLayer(layerObj, evenIfOff, forceGeoJSON) { //Default is onclick show full properties and onhover show 1st property Map_.onEachFeatureDefault = onEachFeatureDefault function onEachFeatureDefault(feature, layer) { - var pv = getLayersChosenNamePropVal(feature, layer) + const pv = L_.getLayersChosenNamePropVal(feature, layer) - layer['useKeyAsName'] = pv.name + layer['useKeyAsName'] = Object.keys(pv)[0] if ( layer.hasOwnProperty('options') && layer.options.hasOwnProperty('layerName') ) { - L_.layersNamed[layer.options.layerName].useKeyAsName = pv.name + L_.layers.data[layer.options.layerName].useKeyAsName = + layer['useKeyAsName'] } - if ( - pv.hasOwnProperty('name') && - pv.name != null && - typeof pv.name === 'string' - ) { - var propertyName = pv.name.capitalizeFirstLetter() - var propertyValue = pv.value - + if (typeof layer['useKeyAsName'] === 'string') { //Add a mouseover event to the layer layer.on('mouseover', function () { //Make it turn on CursorInfo and show name and value - CursorInfo.update( - propertyName + ': ' + propertyValue, - null, - false - ) + CursorInfo.update(pv, null, false) }) //Add a mouseout event layer.on('mouseout', function () { @@ -646,12 +603,12 @@ async function makeLayer(layerObj, evenIfOff, forceGeoJSON) { //Query dataset links if possible and add that data to the feature's properties if ( layer.options.layerName && - L_.layersNamed[layer.options.layerName] && - L_.layersNamed[layer.options.layerName].variables && - L_.layersNamed[layer.options.layerName].variables.datasetLinks + L_.layers.data[layer.options.layerName] && + L_.layers.data[layer.options.layerName].variables && + L_.layers.data[layer.options.layerName].variables.datasetLinks ) { const dl = - L_.layersNamed[layer.options.layerName].variables.datasetLinks + L_.layers.data[layer.options.layerName].variables.datasetLinks let dlFilled = dl for (let i = 0; i < dlFilled.length; i++) { dlFilled[i].search = F_.getIn( @@ -705,7 +662,7 @@ async function makeLayer(layerObj, evenIfOff, forceGeoJSON) { ) Kinds.use( - L_.layersNamed[layerObj.name].kind, + L_.layers.data[layerObj.name].kind, Map_, feature, layer, @@ -724,7 +681,7 @@ async function makeLayer(layerObj, evenIfOff, forceGeoJSON) { } } - Viewer_.changeImages(propImages, feature) + Viewer_.changeImages(propImages, feature, layer) for (var i in propImages) { if (propImages[i].type == 'radargram') { //Globe_.radargram( layer.options.layerName, feature.geometry, propImages[i].url, propImages[i].length, propImages[i].depth ); @@ -795,11 +752,51 @@ async function makeLayer(layerObj, evenIfOff, forceGeoJSON) { ) function add(data) { - if (data == null || data === 'off') { - L_.layersLoaded[ - L_.layersOrdered.indexOf(layerObj.name) + // [] + if (Array.isArray(data) && data.length === 0) { + data = { type: 'FeatureCollection', features: [] } + } + // [<FeatureCollection>] + else if ( + Array.isArray(data) && + data[0] && + data[0].type === 'FeatureCollection' + ) { + const nextData = { type: 'FeatureCollection', features: [] } + data.forEach((fc) => { + if (fc.type === 'FeatureCollection') + nextData.features = nextData.features.concat( + fc.features + ) + }) + data = nextData + } + + let invalidGeoJSONTrace = gjv.valid(data, true) + const allowableErrors = [`position must only contain numbers`] + invalidGeoJSONTrace = invalidGeoJSONTrace.filter((t) => { + if (typeof t !== 'string') return false + for (let i = 0; i < allowableErrors.length; i++) { + if (t.toLowerCase().indexOf(allowableErrors[i]) != -1) + return false + } + return true + }) + if ( + data == null || + data === 'off' || + invalidGeoJSONTrace.length > 0 + ) { + if (data != null && data != 'off') { + data = null + console.warn( + `ERROR: ${layerObj.display_name} has invalid GeoJSON!` + ) + } + L_._layersLoaded[ + L_._layersOrdered.indexOf(layerObj.name) ] = true - L_.layersGroup[layerObj.name] = data == null ? null : false + L_.layers.layer[layerObj.name] = data == null ? null : false allLayersLoaded() resolve() return @@ -808,8 +805,8 @@ async function makeLayer(layerObj, evenIfOff, forceGeoJSON) { layerObj.style = layerObj.style || {} layerObj.style.layerName = layerObj.name - layerObj.style.opacity = L_.opacityArray[layerObj.name] - //layerObj.style.fillOpacity = L_.opacityArray[layerObj.name] + layerObj.style.opacity = L_.layers.opacity[layerObj.name] + //layerObj.style.fillOpacity = L_.layers.opacity[layerObj.name] const vl = constructVectorLayer( data, @@ -817,13 +814,15 @@ async function makeLayer(layerObj, evenIfOff, forceGeoJSON) { onEachFeatureDefault, Map_ ) - L_.layersGroupSublayers[layerObj.name] = vl.sublayers - L_.layersGroup[layerObj.name] = vl.layer + L_.layers.attachments[layerObj.name] = vl.sublayers + L_.layers.layer[layerObj.name] = vl.layer - d3.selectAll( - '.' + layerObj.name.replace(/\s/g, '').toLowerCase() - ).data(data.features) - L_.layersLoaded[L_.layersOrdered.indexOf(layerObj.name)] = true + d3.selectAll('.' + F_.getSafeName(layerObj.name)).data( + data.features + ) + L_._layersLoaded[ + L_._layersOrdered.indexOf(layerObj.name) + ] = true allLayersLoaded() resolve() @@ -850,7 +849,7 @@ async function makeLayer(layerObj, evenIfOff, forceGeoJSON) { tileFormat = tileFormat ? 'tms' : 'wmts' } else tileFormat = layerObj.tileformat - L_.layersGroup[layerObj.name] = L.tileLayer.colorFilter(layerUrl, { + L_.layers.layer[layerObj.name] = L.tileLayer.colorFilter(layerUrl, { minZoom: layerObj.minZoom, maxZoom: layerObj.maxZoom, maxNativeZoom: layerObj.maxNativeZoom, @@ -860,16 +859,22 @@ async function makeLayer(layerObj, evenIfOff, forceGeoJSON) { continuousWorld: true, reuseTiles: true, bounds: bb, + timeEnabled: + layerObj.time != null && layerObj.time.enabled === true, time: typeof layerObj.time === 'undefined' ? '' : layerObj.time.end, + compositeTile: + typeof layerObj.time === 'undefined' + ? false + : layerObj.time.compositeTile || false, starttime: typeof layerObj.time === 'undefined' ? '' : layerObj.time.start, endtime: typeof layerObj.time === 'undefined' ? '' : layerObj.time.end, }) - L_.setLayerOpacity(layerObj.name, L_.opacityArray[layerObj.name]) + L_.setLayerOpacity(layerObj.name, L_.layers.opacity[layerObj.name]) - L_.layersLoaded[L_.layersOrdered.indexOf(layerObj.name)] = true + L_._layersLoaded[L_._layersOrdered.indexOf(layerObj.name)] = true allLayersLoaded() } @@ -884,8 +889,9 @@ async function makeLayer(layerObj, evenIfOff, forceGeoJSON) { urlSplit[1] != null ) { layerUrl = - '/API/geodatasets/get?layer=' + - urlSplit[1] + + `${ + window.mmgisglobal.ROOT_PATH || '' + }/api/geodatasets/get?layer=${urlSplit[1]}` + '&type=mvt&x={x}&y={y}&z={z}' } @@ -898,13 +904,13 @@ async function makeLayer(layerObj, evenIfOff, forceGeoJSON) { } var clearHighlight = function () { - for (let l of Object.keys(L_.layersNamed)) { - if (L_.layersGroup[l]) { - var highlight = L_.layersGroup[l].highlight + for (let l of Object.keys(L_.layers.data)) { + if (L_.layers.layer[l]) { + var highlight = L_.layers.layer[l].highlight if (highlight) { - L_.layersGroup[l].resetFeatureStyle(highlight) + L_.layers.layer[l].resetFeatureStyle(highlight) } - L_.layersGroup[l].highlight = null + L_.layers.layer[l].highlight = null } } } @@ -919,9 +925,9 @@ async function makeLayer(layerObj, evenIfOff, forceGeoJSON) { ell.latlng = JSON.parse(JSON.stringify(e.latlng)) Kinds.use( - L_.layersNamed[layerName].kind, + L_.layers.data[layerName].kind, Map_, - L_.layersGroup[layerName].activeFeatures[0], + L_.layers.layer[layerName].activeFeatures[0], layer, layerName, null, @@ -931,13 +937,13 @@ async function makeLayer(layerObj, evenIfOff, forceGeoJSON) { ToolController_.getTool('InfoTool').use( layer, layerName, - L_.layersGroup[layerName].activeFeatures, + L_.layers.layer[layerName].activeFeatures, null, null, null, ell ) - L_.layersGroup[layerName].activeFeatures = [] + L_.layers.layer[layerName].activeFeatures = [] } })(layer, layerName, e), 100 @@ -965,16 +971,16 @@ async function makeLayer(layerObj, evenIfOff, forceGeoJSON) { })(layerObj.style.vtId), } - L_.layersGroup[layerObj.name] = L.vectorGrid + L_.layers.layer[layerObj.name] = L.vectorGrid .protobuf(layerUrl, vectorTileOptions) .on('click', function (e) { let layerName = e.sourceTarget._layerName - let vtId = L_.layersGroup[layerName].vtId + let vtId = L_.layers.layer[layerName].vtId clearHighlight() - L_.layersGroup[layerName].highlight = e.layer.properties[vtId] + L_.layers.layer[layerName].highlight = e.layer.properties[vtId] - L_.layersGroup[layerName].setFeatureStyle( - L_.layersGroup[layerName].highlight, + L_.layers.layer[layerName].setFeatureStyle( + L_.layers.layer[layerName].highlight, { weight: 2, color: 'red', @@ -985,9 +991,9 @@ async function makeLayer(layerObj, evenIfOff, forceGeoJSON) { fillOpacity: 1, } ) - L_.layersGroup[layerName].activeFeatures = - L_.layersGroup[layerName].activeFeatures || [] - L_.layersGroup[layerName].activeFeatures.push({ + L_.layers.layer[layerName].activeFeatures = + L_.layers.layer[layerName].activeFeatures || [] + L_.layers.layer[layerName].activeFeatures.push({ type: 'Feature', properties: e.layer.properties, geometry: {}, @@ -1012,7 +1018,7 @@ async function makeLayer(layerObj, evenIfOff, forceGeoJSON) { vtId ] != e.layer.properties[vtId] ) { - L_.layersGroup[layerName].activeFeatures.push({ + L_.layers.layer[layerName].activeFeatures.push({ type: 'Feature', properties: e.layer._renderer._features[i].feature @@ -1043,17 +1049,17 @@ async function makeLayer(layerObj, evenIfOff, forceGeoJSON) { CursorInfo.hide() }) - L_.layersGroup[layerObj.name].vtId = layerObj.style.vtId - L_.layersGroup[layerObj.name].vtKey = layerObj.style.vtKey + L_.layers.layer[layerObj.name].vtId = layerObj.style.vtId + L_.layers.layer[layerObj.name].vtKey = layerObj.style.vtKey - L_.setLayerOpacity(layerObj.name, L_.opacityArray[layerObj.name]) + L_.setLayerOpacity(layerObj.name, L_.layers.opacity[layerObj.name]) - L_.layersLoaded[L_.layersOrdered.indexOf(layerObj.name)] = true + L_._layersLoaded[L_._layersOrdered.indexOf(layerObj.name)] = true allLayersLoaded() } function makeModelLayer() { - L_.layersLoaded[L_.layersOrdered.indexOf(layerObj.name)] = true + L_._layersLoaded[L_._layersOrdered.indexOf(layerObj.name)] = true allLayersLoaded() } @@ -1078,7 +1084,7 @@ async function makeLayer(layerObj, evenIfOff, forceGeoJSON) { DataShaders[shaderType].settings[i].value } - L_.layersGroup[layerObj.name] = L.tileLayer.gl({ + L_.layers.layer[layerObj.name] = L.tileLayer.gl({ options: { tms: true, bounds: bb, @@ -1093,9 +1099,9 @@ async function makeLayer(layerObj, evenIfOff, forceGeoJSON) { DataShaders[shaderType].attachImmediateEvents(layerObj.name, shader) } - L_.setLayerOpacity(layerObj.name, L_.opacityArray[layerObj.name]) + L_.setLayerOpacity(layerObj.name, L_.layers.opacity[layerObj.name]) - L_.layersLoaded[L_.layersOrdered.indexOf(layerObj.name)] = true + L_._layersLoaded[L_._layersOrdered.indexOf(layerObj.name)] = true allLayersLoaded() } } @@ -1105,8 +1111,8 @@ async function makeLayer(layerObj, evenIfOff, forceGeoJSON) { function allLayersLoaded() { if (!Map_.allLayersLoadedPassed) { //Only continues if all layers have been loaded - for (var i = 0; i < L_.layersLoaded.length; i++) { - if (L_.layersLoaded[i] == false) { + for (var i = 0; i < L_._layersLoaded.length; i++) { + if (L_._layersLoaded[i] == false) { return } } @@ -1118,7 +1124,27 @@ function allLayersLoaded() { L_.enforceVisibilityCutoffs() ToolController_.finalizeTools() + + L_.loaded() //OTHER TEMPORARY TEST STUFF THINGS + + // Turn on legend if displayOnStart is true + if ('LegendTool' in ToolController_.toolModules) { + if ( + ToolController_.toolModules['LegendTool'].displayOnStart == true + ) { + ToolController_.toolModules['LegendTool'].make( + 'toolContentSeparated_Legend' + ) + let _event = new CustomEvent('toggleSeparatedTool', { + detail: { + toggledToolName: 'LegendTool', + visible: true, + }, + }) + document.dispatchEvent(_event) + } + } } } @@ -1249,18 +1275,18 @@ function clearOnMapClick(event) { let found = false // For all MMGIS layers - for (let key in L_.layersGroup) { - if (L_.layersGroup[key] === false || L_.layersGroup[key] == null) + for (let key in L_.layers.layer) { + if (L_.layers.layer[key] === false || L_.layers.layer[key] == null) continue let layers // Layers can be a LayerGroup or an array of LayerGroup - if ('getLayers' in L_.layersGroup[key]) { - layers = L_.layersGroup[key].getLayers() + if ('getLayers' in L_.layers.layer[key]) { + layers = L_.layers.layer[key].getLayers() } - if (Array.isArray(L_.layersGroup[key])) { - layers = L_.layersGroup[key] + if (Array.isArray(L_.layers.layer[key])) { + layers = L_.layers.layer[key] } for (let k in layers) { @@ -1270,10 +1296,27 @@ function clearOnMapClick(event) { const _layer = layer.getLayers() for (let x in _layer) { found = checkBounds(_layer[x]) - if (found) break + // We should bubble down further for layers that have no fill, as it is possible + // for there to be layers with features under the transparent fill + if (found) { + if (layer.options.fill) { + break + } else { + found = false + } + } } } else { found = checkBounds(layer) + if (found) { + // We should bubble down further for layers that have no fill, as it is possible + // for there to be layers with features under the transparent fill + if (layer.options.fill) { + break + } else { + found = false + } + } } if (found) break @@ -1286,7 +1329,10 @@ function clearOnMapClick(event) { } function checkBounds(layer) { - if (layer.feature.geometry.type.toLowerCase() === 'polygon') { + if ( + layer.feature && + layer.feature.geometry.type.toLowerCase() === 'polygon' + ) { if ( L.leafletPip.pointInLayer( [latlng.lng, latlng.lat], diff --git a/src/essence/Basics/ToolController_/ToolController_.js b/src/essence/Basics/ToolController_/ToolController_.js index eea31fa2..b0df9ba7 100644 --- a/src/essence/Basics/ToolController_/ToolController_.js +++ b/src/essence/Basics/ToolController_/ToolController_.js @@ -9,6 +9,7 @@ let ToolController_ = { tools: null, incToolsDiv: null, excToolsDiv: null, + separatedDiv: null, toolModuleNames: [], toolModules: toolModules, activeTool: null, @@ -36,98 +37,171 @@ let ToolController_ = { .style('opacity', '0') .style('padding-bottom', '8px') - for (var i = 0; i < tools.length; i++) { + this.separatedDiv = d3 + .select('#splitscreens') + .append('div') + .attr('id', 'toolcontroller_sepdiv') + .style('position', 'absolute') + .style('top', '40px') + .style('left', '0px') + .style('margin-left', '6px') + .style('z-index', '1004') + + for (let i = 0; i < tools.length; i++) { this.toolModuleNames.push(tools[i].js) - this.incToolsDiv - .append('div') - .attr('id', `toolButton${tools[i].name}`) - .attr('class', 'toolButton') - .style( - 'transition', - 'color 0.25s ease-in, background 0.25s ease-in' - ) - .style('width', '100%') - .style('height', '36px') - .style('display', 'inline-block') - .style('text-align', 'center') - .style('line-height', '36px') - .style( - 'border-top', - i === 0 ? '1px solid var(--color-a-5)' : 'none' - ) - .style('border-bottom', '1px solid var(--color-a-5)') - //.style( 'text-shadow', '0px 1px #111' ) - .style('vertical-align', 'middle') - .style('cursor', 'pointer') - .attr('tabindex', i + 1) - .style('transition', 'all 0.2s ease-in') - .style('color', ToolController_.defaultColor) - .on( - 'click', - (function (i) { - return function () { - var hasActive = false - if ($(this).hasClass('active')) { - hasActive = true + if (tools[i].separatedTool) { + d3.select('#viewerToolBar').style('padding-left', '36px') + let sep = this.separatedDiv + .append('div') + .attr('id', `toolSeparated_${tools[i].name}`) + .style('position', 'relative') + .style('border-radius', '3px') + .style('background', 'var(--color-a)') + + sep.append('div') + .attr('id', `toolContentSeparated_${tools[i].name}`) + .style('position', 'absolute') + .style('top', '0px') + .style('left', '0px') + .style('border-radius', '3px') + .style('background', 'var(--color-a)') + + sep.append('div') + .attr('id', `toolButtonSeparated_${tools[i].name}`) + .attr('class', 'toolButtonSep') + .style('position', 'relative') + .style('width', '30px') + .style('height', '30px') + .style('display', 'inline-block') + .style('text-align', 'center') + .style('line-height', '30px') + //.style( 'text-shadow', '0px 1px #111' ) + .style('vertical-align', 'middle') + .style('cursor', 'pointer') + .attr('tabindex', i + 1) + .style('transition', 'all 0.2s ease-in') + .style('color', ToolController_.defaultColor) + .on( + 'click', + (function (i) { + return function () { + const tM = + ToolController_.toolModules[ + `${ToolController_.tools[i].name}Tool` + ] + if (tM) { + if (tM.made === false) + tM.make( + `toolContentSeparated_${ToolController_.tools[i].name}` + ) + else tM.destroy() + + // Dispatch `toggleSeparatedTool` event + let _event = new CustomEvent('toggleSeparatedTool', { + detail: { + toggledToolName: ToolController_.tools[i].js, + visible: tM.made, + }, + }) + document.dispatchEvent(_event) + } } - var prevActive = $('#toolcontroller_incdiv .active') - prevActive.removeClass('active').css({ - color: ToolController_.defaultColor, - background: 'none', - }) - prevActive.parent().css({ - background: 'none', - }) - if (!hasActive) { - var newActive = $( - '#toolcontroller_incdiv #' + - ToolController_.tools[i].name + - 'Tool' + })(i) + ) + .append('i') + .attr('id', tools[i].name + 'Tool') + .attr('class', 'mdi mdi-' + tools[i].icon + ' mdi-18px') + .style('cursor', 'pointer') + } else { + this.incToolsDiv + .append('div') + .attr('id', `toolButton${tools[i].name}`) + .attr('class', 'toolButton') + .style('width', '100%') + .style('height', '36px') + .style('display', 'inline-block') + .style('text-align', 'center') + .style('line-height', '36px') + .style( + 'border-top', + i === 0 ? '1px solid var(--color-a-5)' : 'none' + ) + .style('border-bottom', '1px solid var(--color-a-5)') + //.style( 'text-shadow', '0px 1px #111' ) + .style('vertical-align', 'middle') + .style('cursor', 'pointer') + .attr('tabindex', i + 1) + .style('transition', 'all 0.2s ease-in') + .style('color', ToolController_.defaultColor) + .on( + 'click', + (function (i) { + return function () { + var hasActive = false + if ($(this).hasClass('active')) { + hasActive = true + } + var prevActive = $( + '#toolcontroller_incdiv .active' ) - newActive.addClass('active').css({ - color: ToolController_.activeColor, + prevActive.removeClass('active').css({ + color: ToolController_.defaultColor, + background: 'none', }) - newActive.parent().css({ - background: ToolController_.activeBG, + prevActive.parent().css({ + background: 'none', }) - } - ToolController_.makeTool( - ToolController_.toolModuleNames[i] - ) + if (!hasActive) { + var newActive = $( + '#toolcontroller_incdiv #' + + ToolController_.tools[i].name + + 'Tool' + ) + newActive.addClass('active').css({ + color: ToolController_.activeColor, + }) + newActive.parent().css({ + background: ToolController_.activeBG, + }) + } + ToolController_.makeTool( + ToolController_.toolModuleNames[i] + ) - // Dispatch `toolChange` event - let _event = new CustomEvent('toolChange', { - detail: { - activeTool: ToolController_.activeTool, - activeToolName: - ToolController_.activeToolName, - }, - }) - document.dispatchEvent(_event) + // Dispatch `toolChange` event + let _event = new CustomEvent('toolChange', { + detail: { + activeTool: ToolController_.activeTool, + activeToolName: + ToolController_.activeToolName, + }, + }) + document.dispatchEvent(_event) + } + })(i) + ) + .on('mouseover', function () { + if (!$(this).hasClass('active')) { + $(this).css({ color: ToolController_.hoverColor }) } - })(i) - ) - .on('mouseover', function () { - if (!$(this).hasClass('active')) { - $(this).css({ color: ToolController_.hoverColor }) - } - }) - .on('mouseleave', function () { - if (!$(this).hasClass('active')) { - $(this).css({ color: ToolController_.defaultColor }) - } - }) - .append('i') - .attr('id', tools[i].name + 'Tool') - .attr('class', 'mdi mdi-' + tools[i].icon + ' mdi-18px') - .style('cursor', 'pointer') + }) + .on('mouseleave', function () { + if (!$(this).hasClass('active')) { + $(this).css({ color: ToolController_.defaultColor }) + } + }) + .append('i') + .attr('id', tools[i].name + 'Tool') + .attr('class', 'mdi mdi-' + tools[i].icon + ' mdi-18px') + .style('cursor', 'pointer') - tippy(`#toolButton${tools[i].name}`, { - content: tools[i].name, - placement: 'right', - theme: 'blue', - }) + tippy(`#toolButton${tools[i].name}`, { + content: tools[i].name, + placement: 'right', + theme: 'blue', + }) + } } ToolController_.incToolsDiv @@ -270,4 +344,5 @@ let ToolController_ = { }, } +window.ToolController_ = ToolController_ export default ToolController_ diff --git a/src/essence/Basics/UserInterface_/BottomBar.js b/src/essence/Basics/UserInterface_/BottomBar.js index 975779ac..cc5d879c 100644 --- a/src/essence/Basics/UserInterface_/BottomBar.js +++ b/src/essence/Basics/UserInterface_/BottomBar.js @@ -245,12 +245,39 @@ let BottomBar = { theme: 'blue', }) + // Info + bottomBar + .append('i') + .attr('id', 'topBarInfo') + .attr('title', 'Info') + .attr('tabindex', 105) + .attr('class', 'mmgisHoverBlue mdi mdi-information-outline mdi-18px') + .style('padding', '5px 10px') + .style('width', '40px') + .style('height', '36px') + .style('line-height', '26px') + .style('cursor', 'pointer') + .on('click', function () { + this.infoOn = !this.infoOn + if (this.infoOn) { + d3.select('#viewer_Info').style('display', 'inherit') + } else { + d3.select('#viewer_Info').style('display', 'none') + } + }) + + tippy(`#topBarInfo`, { + content: `Info`, + placement: 'right', + theme: 'blue', + }) + // Help bottomBar .append('i') .attr('id', 'topBarHelp') .attr('title', 'Help') - .attr('tabindex', 105) + .attr('tabindex', 106) .attr('class', 'mmgisHoverBlue mdi mdi-help mdi-18px') .style('padding', '5px 10px') .style('width', '40px') @@ -275,12 +302,12 @@ let BottomBar = { toggleSettings: function (on) { if (on) { BottomBar.settings.visibility = BottomBar.settings.visibility || { - topbar: true, - toolbars: true, - scalebar: true, - coordinates: true, + topbar: L_.configData.look.topbar != false, + toolbars: L_.configData.look.toolbar != false, + scalebar: L_.configData.look.scalebar != false, + coordinates: L_.configData.look.coorindates != false, graticule: this.UI_.Map_.graticule != null, - miscellaneous: true, + miscellaneous: L_.configData.look.miscellaneous != false, } // prettier-ignore const modalContent = [ @@ -297,12 +324,11 @@ let BottomBar = { `<div class="mmgis-checkbox"><input type="checkbox" ${BottomBar.settings.visibility.topbar ? 'checked ' : ''}id="checkbox_msmsUIV1" value='topbar'/><label for="checkbox_msmsUIV1"></label></div>`, `<div>Top Bar</div>`, `</li>`, - /* For now because then we need a way to open the settings modal again + /* For now because then we need a way to open the settings modal again */ `<li>`, `<div class="mmgis-checkbox"><input type="checkbox" ${BottomBar.settings.visibility.toolbars ? 'checked ' : ''}id="checkbox_msmsUIV2" value='toolbars'/><label for="checkbox_msmsUIV2"></label></div>`, `<div>Toolbars</div>`, `</li>`, - */ `<li>`, `<div class="mmgis-checkbox"><input type="checkbox" ${BottomBar.settings.visibility.scalebar ? 'checked ' : ''}id="checkbox_msmsUIV3" value='scalebar'/><label for="checkbox_msmsUIV3"></label></div>`, `<div>Scale Bar</div>`, @@ -353,112 +379,7 @@ let BottomBar = { BottomBar.settings.visibility[value] = checked - if (!checked) { - // now on - switch (value) { - case 'topbar': - $('#topBar').css('display', 'none') - break - case 'toolbars': - $('#mmgislogo').css('display', 'none') - $('#barBottom').css('display', 'none') - $('#toolbar').css({ - display: 'none', - width: '0px', - }) - $('#viewerToolBar').css('display', 'none') - $('#_lithosphere_controls').css( - 'display', - 'none' - ) - $('#splitscreens').css({ - left: '0px', - width: '100%', - }) - $('#mapScreen').css( - 'width', - $('#mapScreen').width() + 40 + 'px' - ) - BottomBar.UI_.topSize = 0 - window.dispatchEvent(new Event('resize')) - break - case 'scalebar': - $('#scaleBarBounds').css('display', 'none') - break - case 'coordinates': - $('#CoordinatesDiv').css('display', 'none') - break - case 'graticule': - BottomBar.UI_.Map_.toggleGraticule(false) - break - case 'miscellaneous': - $('.leaflet-control-container').css( - 'display', - 'none' - ) - $('.splitterVInner').css('display', 'none') - break - default: - break - } - } else { - // now off - switch (value) { - case 'topbar': - $('#topBar').css('display', 'flex') - break - case 'toolbars': - $('#mmgislogo').css('display', 'inherit') - $('#barBottom').css('display', 'flex') - $('#toolbar').css({ - display: 'inherit', - width: '40px', - }) - $('#viewerToolBar').css( - 'display', - 'inherit' - ) - $('#_lithosphere_controls').css( - 'display', - 'inherit' - ) - $('#splitscreens').css({ - left: '40px', - width: 'calc(100% - 40px)', - }) - $('#mapScreen').css( - 'width', - $('#mapScreen').width() - 40 + 'px' - ) - BottomBar.UI_.topSize = 40 - window.dispatchEvent(new Event('resize')) - break - case 'scalebar': - $('#scaleBarBounds').css( - 'display', - 'inherit' - ) - break - case 'coordinates': - $('#CoordinatesDiv').css('display', 'flex') - break - case 'graticule': - BottomBar.UI_.Map_.toggleGraticule(true) - break - case 'miscellaneous': - $('.leaflet-control-container').css( - 'display', - 'block' - ) - $('.splitterVInner').css( - 'display', - 'inline-flex' - ) - break - default: - break - } - } + BottomBar.changeUIVisibility(value, checked) }) // 3d Globe @@ -481,6 +402,94 @@ let BottomBar = { } else { } }, + changeUIVisibility: function (value, checked) { + if (!checked) { + // now off + switch (value) { + case 'topbar': + $('#topBar').css('display', 'none') + break + case 'toolbars': + $('#mmgislogo').css('display', 'none') + $('#barBottom').css('display', 'none') + $('#toolbar').css({ + display: 'none', + width: '0px', + }) + $('#viewerToolBar').css('display', 'none') + $('#_lithosphere_controls').css('display', 'none') + $('#splitscreens').css({ + left: '0px', + width: '100%', + }) + $('#mapScreen').css( + 'width', + $('#mapScreen').width() + 40 + 'px' + ) + BottomBar.UI_.topSize = 0 + window.dispatchEvent(new Event('resize')) + break + case 'scalebar': + $('#scaleBarBounds').css('display', 'none') + break + case 'coordinates': + $('#CoordinatesDiv').css('display', 'none') + break + case 'graticule': + BottomBar.UI_.Map_.toggleGraticule(false) + break + case 'miscellaneous': + $('.leaflet-control-container').css('display', 'none') + $('.splitterVInner').css('display', 'none') + break + default: + break + } + } else { + // now on + switch (value) { + case 'topbar': + $('#topBar').css('display', 'flex') + break + case 'toolbars': + $('#mmgislogo').css('display', 'inherit') + $('#barBottom').css('display', 'flex') + $('#toolbar').css({ + display: 'inherit', + width: '40px', + }) + $('#viewerToolBar').css('display', 'inherit') + $('#_lithosphere_controls').css('display', 'inherit') + $('#splitscreens').css({ + left: '40px', + width: 'calc(100% - 40px)', + }) + $('#mapScreen').css( + 'width', + $('#mapScreen').width() - 40 + 'px' + ) + BottomBar.UI_.topSize = 40 + window.dispatchEvent(new Event('resize')) + break + case 'scalebar': + $('#scaleBarBounds').css('display', 'inherit') + break + case 'coordinates': + $('#CoordinatesDiv').css('display', 'flex') + break + case 'graticule': + BottomBar.UI_.Map_.toggleGraticule(true) + break + case 'miscellaneous': + $('.leaflet-control-container').css('display', 'block') + $('.splitterVInner').css('display', 'inline-flex') + break + default: + break + } + } + }, + toggleInfo: function () {}, toggleHelp: function () {}, fullscreen: function () { var isInFullScreen = diff --git a/src/essence/Basics/UserInterface_/LayerUpdatedControl.css b/src/essence/Basics/UserInterface_/LayerUpdatedControl.css index 9ca71f08..78f37f8f 100644 --- a/src/essence/Basics/UserInterface_/LayerUpdatedControl.css +++ b/src/essence/Basics/UserInterface_/LayerUpdatedControl.css @@ -33,7 +33,7 @@ color: var(--color-a) !important; } .DISCONNECTED { - background: var(--color-red) !important; + background: var(--color-r1) !important; color: var(--color-f) !important; } .leaflet-control-update-layer-icon > .mdi-reload-alert, diff --git a/src/essence/Basics/UserInterface_/UserInterface_.css b/src/essence/Basics/UserInterface_/UserInterface_.css index da8db2d2..a3a9f28d 100644 --- a/src/essence/Basics/UserInterface_/UserInterface_.css +++ b/src/essence/Basics/UserInterface_/UserInterface_.css @@ -54,7 +54,7 @@ transition: color 0.2s cubic-bezier(0.445, 0.05, 0.55, 0.95); } #main-container > #topBar #topBarTitleName { - font-size: 16px; + font-size: 14px; padding: 6px 14px 8px 14px; display: flex; align-items: center; @@ -62,8 +62,9 @@ font-weight: 600; line-height: 15px; letter-spacing: 1px; - font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', - Roboto, Helvetica, Arial, sans-serif; + font-family: 'lato-light', system-ui, -apple-system, BlinkMacSystemFont, + 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; + text-transform: uppercase; } #main-container > #topBar #topBarTitle:hover { @@ -102,7 +103,6 @@ opacity: 0; border-radius: 3px; pointer-events: auto; - transition: opacity 0.2s ease-out; } .mainInfo > div { diff --git a/src/essence/Basics/UserInterface_/UserInterface_.js b/src/essence/Basics/UserInterface_/UserInterface_.js index d3174132..0d623020 100644 --- a/src/essence/Basics/UserInterface_/UserInterface_.js +++ b/src/essence/Basics/UserInterface_/UserInterface_.js @@ -290,7 +290,7 @@ var UserInterface = { .style('width', '30px') .style('height', '30px') .style('position', 'absolute') - .style('left', '22px') + .style('left', '23px') .style('z-index', '-1') this.mapSplitInner .append('i') @@ -925,10 +925,49 @@ var UserInterface = { display: l_.configData.look.fullscreen ? 'inherit' : 'none', }) - if (l_.configData.look && l_.configData.look.help != null) + if (l_.configData.look && l_.configData.look.settings != null) + $('#bottomBarSettings').css({ + display: l_.configData.look.settings ? 'inherit' : 'none', + }) + + if ( + l_.configData.look && + l_.configData.look.info != null && + l_.configData.look.infourl != '' + ) { + $('#topBarInfo').css({ + display: l_.configData.look.info ? 'inherit' : 'none', + }) + } else { + $('#topBarInfo').css({ + display: 'none', + }) + } + + if ( + l_.configData.look && + l_.configData.look.help != null && + l_.configData.look.helpurl != '' + ) { $('#topBarHelp').css({ display: l_.configData.look.help ? 'inherit' : 'none', }) + } else { + $('#topBarHelp').css({ + display: 'none', + }) + } + + if (l_.configData.look && l_.configData.look.topbar === false) + BottomBar.changeUIVisibility('topbar', false) + if (l_.configData.look && l_.configData.look.toolbar === false) + BottomBar.changeUIVisibility('toolbars', false) + if (l_.configData.look && l_.configData.look.scalebar === false) + BottomBar.changeUIVisibility('scalebar', false) + if (l_.configData.look && l_.configData.look.coordinates === false) + BottomBar.changeUIVisibility('coordinates', false) + if (l_.configData.look && l_.configData.look.miscellaneous === false) + BottomBar.changeUIVisibility('miscellaneous', false) UserInterface.show() }, @@ -1339,21 +1378,21 @@ function windowresize() { UserInterface.mainHeight = $('#splitscreens').height() //Resize widest panel so that their sum is the screen width - var widest = Math.max( + const widest = Math.max( UserInterface.pxIsViewer, UserInterface.pxIsMap, UserInterface.pxIsGlobe ) - if (UserInterface.pxIsViewer == widest) - UserInterface.pxIsViewer = - UserInterface.mainWidth - - UserInterface.pxIsMap - - UserInterface.pxIsGlobe - else if (UserInterface.pxIsMap == widest) + if (UserInterface.pxIsMap == widest) UserInterface.pxIsMap = UserInterface.mainWidth - UserInterface.pxIsViewer - UserInterface.pxIsGlobe + else if (UserInterface.pxIsViewer == widest) + UserInterface.pxIsViewer = + UserInterface.mainWidth - + UserInterface.pxIsMap - + UserInterface.pxIsGlobe else if (UserInterface.pxIsGlobe == widest) UserInterface.pxIsGlobe = UserInterface.mainWidth - diff --git a/src/essence/Basics/Viewer_/Photosphere.js b/src/essence/Basics/Viewer_/Photosphere.js index c3f46895..1201f1c1 100644 --- a/src/essence/Basics/Viewer_/Photosphere.js +++ b/src/essence/Basics/Viewer_/Photosphere.js @@ -39,6 +39,8 @@ export default function (domEl, lookupPath, options, Map_) { var lastFov = null var geometry = null + var currentImageObj = null + var lastIntLayerName = null var webglSupport = (function () { try { @@ -170,37 +172,171 @@ export default function (domEl, lookupPath, options, Map_) { } } - function changeImage(imageObj, feature, callback) { + function changeImage(imageObj, feature, layer, callback) { if (!wasInitialized) { - if (typeof callback === 'function' && !calledBack) + if (typeof callback === 'function') callback( "<div style='letter-spacing: 0px; font-size: 18px; text-align: center; font-family: roboto; color: #CCC;'><div style='margin-bottom: 5px;'>Seems like <a target='_blank' href='https://www.khronos.org/webgl/wiki/Getting_a_WebGL_Implementation'>WebGL</a> isn't supported for you.</div><div>Find out how to get it <a target='_blank' href='https://get.webgl.org/'>here</a>.</div></div>" ) } geometry = feature.geometry + currentImageObj = imageObj - var url = imageObj.url + const url = imageObj.url //crop out directory path and extension from image name - var croppedName = url.substring(0, url.length - 4).split('/') + let croppedName = url.substring(0, url.length - 4).split('/') croppedName = croppedName[croppedName.length - 1] - var croppedNameSol = croppedName.split('_')[2] + const croppedNameSol = croppedName.split('_')[2] //assemble ranges - var azR = [parseFloat(imageObj.azmin), parseFloat(imageObj.azmax)] - var elR = [parseFloat(imageObj.elmin), parseFloat(imageObj.elmax)] - var xyR = [parseInt(imageObj.columns), parseInt(imageObj.rows)] + const azR = [parseFloat(imageObj.azmin), parseFloat(imageObj.azmax)] + const elR = [parseFloat(imageObj.elmin), parseFloat(imageObj.elmax)] + const xyR = [parseInt(imageObj.columns), parseInt(imageObj.rows)] clearLayers() - makeModifiedTexture(url, azR, elR, xyR, function () { - addPointLayer( - 'ChemCam', - 'Missions/' + - L_.mission + - '/Data/Mosaics/azel_mosaic_targets/azel_targets_' + - croppedName + - '_sol' + - croppedNameSol + - '.csv' - ) + makeModifiedTexture(url, azR, elR, xyR, () => { + const layerName = layer.options.layerName + + if ( + feature.geometry.type === 'Point' && + L_.layers.on[layerName] && + L_.layers.attachments[layerName] && + L_.layers.attachments[layerName].pairings && + L_.layers.attachments[layerName].pairings.on + ) { + let sourceCoords = feature.geometry.coordinates + let originOffsetOrder = + L_.layers.attachments[layerName].pairings.originOffsetOrder + if (originOffsetOrder) + originOffsetOrder = originOffsetOrder.map((o) => + o.toLowerCase() + ) + + // Allow sourceCoords offset with originOffset and support configurable axis order + // prettier-ignore + if( imageObj.originOffset != null ) { + const crs = window.mmgisglobal.customCRS + const scp = crs.project({lng: sourceCoords[0], lat: sourceCoords[1]}) + sourceCoords = [scp.x, scp.y, sourceCoords[2]] + if(imageObj.originOffset[0] != null) { + if( originOffsetOrder != null && originOffsetOrder[0] != null) { + const pos = originOffsetOrder[0].includes('z') ? 2 : originOffsetOrder[0].includes('y') ? 1 : 0 + const sign = originOffsetOrder[0].includes('-') ? -1 : 1 + sourceCoords[pos] += sign * imageObj.originOffset[0] + } + else + sourceCoords[0] += imageObj.originOffset[0] + } + if(imageObj.originOffset[1] != null) { + if( originOffsetOrder != null && originOffsetOrder[1] != null) { + const pos = originOffsetOrder[1].includes('z') ? 2 : originOffsetOrder[1].includes('y') ? 1 : 0 + const sign = originOffsetOrder[1].includes('-') ? -1 : 1 + sourceCoords[pos] += sign * imageObj.originOffset[1] + } + else + sourceCoords[1] += imageObj.originOffset[1] + } + if(imageObj.originOffset[2] != null) { + if( originOffsetOrder != null && originOffsetOrder[2] != null) { + const pos = originOffsetOrder[2].includes('z') ? 2 : originOffsetOrder[2].includes('y') ? 1 : 0 + const sign = originOffsetOrder[2].includes('-') ? -1 : 1 + sourceCoords[pos] += sign * imageObj.originOffset[2] + } + else + sourceCoords[2] += imageObj.originOffset[2] + } + const scup = crs.unproject({x: sourceCoords[0], y: sourceCoords[1]}) + sourceCoords = [scup.lng, scup.lat, sourceCoords[2]] + } + + currentImageObj._center = sourceCoords + + const pairValue = F_.getIn( + feature.properties, + L_.layers.attachments[layerName].pairings.pairProp, + '___null' + ) + L_.layers.attachments[layerName].pairings.pairedLayers.forEach( + (pairedLayerName) => { + if ( + L_.layers.layer[pairedLayerName] && + L_.layers.layer[pairedLayerName]._sourceGeoJSON && + L_.layers.on[pairedLayerName] === true + ) { + layers[pairedLayerName] = {} + L_.layers.layer[ + pairedLayerName + ]._sourceGeoJSON.features.forEach((pairFeature) => { + if ( + pairFeature.geometry.type === 'Point' && + F_.getIn( + pairFeature.properties, + L_.layers.attachments[layerName] + .pairings.pairProp, + null + ) === pairValue + ) { + const pairCoords = + pairFeature.geometry.coordinates + const azElDist = F_.azElDistBetween( + { + lat: sourceCoords[1], + lng: sourceCoords[0], + el: sourceCoords[2], + }, + { + lat: pairCoords[1], + lng: pairCoords[0], + el: pairCoords[2], + } + ) + + // Prefer az/els already provided with the feature (if any and set up) + if ( + L_.layers.attachments[layerName] + .pairings.layersAzProp != null + ) { + const az = F_.getIn( + pairFeature.properties, + L_.layers.attachments[layerName] + .pairings.layersAzProp, + null + ) + if (az != null) azElDist.az = az + } + if ( + L_.layers.attachments[layerName] + .pairings.layersElProp != null + ) { + const el = F_.getIn( + pairFeature.properties, + L_.layers.attachments[layerName] + .pairings.layersElProp, + null + ) + if (el != null) azElDist.el = el + } + + addPoint( + pairedLayerName, + azElDist.az, + azElDist.el, + L_.layers.data[pairedLayerName] + .useKeyAsName, + F_.getIn( + pairFeature.properties, + L_.layers.data[pairedLayerName] + .useKeyAsName + ), + L_.layers.data[pairedLayerName].style + ) + } + }) + } + } + ) + + render() + } if (typeof callback === 'function') { callback() } @@ -213,34 +349,18 @@ export default function (domEl, lookupPath, options, Map_) { else controls = orientationControls } - //url is is to csv with header: az,el,target - function addPointLayer(layerName, url) { - d3.csv(url, function (d) { - if (d == null) { - console.log('Point Layer Not Found.') - return - } - layers[layerName] = {} - for (var i = 0; i < d.length; i++) { - addPoint(layerName, d[i].az, -d[i].el, 'TARGET', d[i].target) - } - render() - }) - } + let pointId = 0 + function addPoint(layerName, az, el, nameKey, name, style) { + pointId++ - function addPoint(layerName, az, el, nameKey, name) { - var mapped = F_.lonLatToVector3nr( - F_.mod(az - 90 - sphereRot - 180, 360), - el, - sphereRadius / 2 - ) - var mappedCloser = F_.lonLatToVector3nr( - F_.mod(az - 90 - sphereRot - 180, 360), - el, - sphereRadius / 1.5 - ) + style = style || {} + + const rot = F_.mod(az - 90, 360, true) + + const mapped = F_.lonLatToVector3nr(rot, -el, sphereRadius / 2) + const mappedCloser = F_.lonLatToVector3nr(rot, -el, sphereRadius / 1.5) - var boundingSphere = new THREE.Mesh( + const boundingSphere = new THREE.Mesh( new THREE.SphereGeometry(1, 12, 12), new THREE.MeshBasicMaterial({ color: 0x000000, @@ -253,33 +373,46 @@ export default function (domEl, lookupPath, options, Map_) { boundingSphere.layerName = layerName boundingSphere.nameKey = nameKey boundingSphere.name = name + boundingSphere.pid = pointId scene.add(boundingSphere) - var point = Sprites.makeMarkerSprite({ - radius: 64, - fillColor: { r: 102, g: 204, b: 102, a: 0.7 }, - strokeWeight: 12, - strokeColor: { r: 0, g: 0, b: 0, a: 1 }, + const fillColor = F_.hexToRGB(F_.rgb2hex(style.fillColor)) || false + if (fillColor) + fillColor.a = + style.fillOpacity != null ? parseFloat(style.fillOpacity) : 1 + const strokeColor = F_.hexToRGB(F_.rgb2hex(style.color)) || false + if (strokeColor) + strokeColor.a = + style.opacity != null ? parseFloat(style.opacity) : 1 + + const point = Sprites.makeMarkerSprite({ + radius: style.radius ? style.radius * 8 : 64, + fillColor, + strokeWeight: style.weight ? style.weight * 6 : 12, + strokeColor, }) point.position.set(mappedCloser.x, mappedCloser.y, mappedCloser.z) point.layerName = layerName point.savedMaterial = point.material point.nameKey = nameKey point.name = name + point.pid = pointId scene.add(point) - var text = Sprites.makeTextSprite(name, { + const text = Sprites.makeTextSprite(name, { fontsize: 36, fontColor: { r: 255, g: 255, b: 255, a: 1.0 }, - strokeColor: { r: 0, g: 0, b: 0, a: 0.8 }, + strokeColor: { r: 0, g: 0, b: 0, a: 1.0 }, }) text.position.set(mappedCloser.x, mappedCloser.y, mappedCloser.z) text.layerName = layerName text.nameKey = nameKey text.name = name + text.pid = pointId scene.add(text) - layers[layerName][name] = { + layers[layerName][name] = layers[layerName][name] || {} + layers[layerName][name][pointId] = { boundingSphere: boundingSphere, point: point, text: text, @@ -287,14 +420,16 @@ export default function (domEl, lookupPath, options, Map_) { } function clearLayers() { - for (var l in layers) { - for (var p in layers[l]) { - layers[l][p].boundingSphere.geometry.dispose() - layers[l][p].boundingSphere.material.dispose() - layers[l][p].point.material.dispose() - layers[l][p].text.material.dispose() - scene.remove(layers[l][p].point) - scene.remove(layers[l][p].text) + for (let l in layers) { + for (let p in layers[l]) { + for (let i in layers[l][p]) { + layers[l][p][i].boundingSphere.geometry.dispose() + layers[l][p][i].boundingSphere.material.dispose() + layers[l][p][i].point.material.dispose() + layers[l][p][i].text.material.dispose() + scene.remove(layers[l][p][i].point) + scene.remove(layers[l][p][i].text) + } } } layers = {} @@ -342,11 +477,15 @@ export default function (domEl, lookupPath, options, Map_) { lastEl = currentEl lastFov = currentFov - if (geometry) { + if (geometry && currentImageObj) { Map_.rmNotNull(Map_.tempPhotosphereWedge) - //console.log( geometry ) let start = [geometry.coordinates[1], geometry.coordinates[0]] + if (currentImageObj._center != null) + start = [ + currentImageObj._center[1], + currentImageObj._center[0], + ] let end let rp let line @@ -473,20 +612,22 @@ export default function (domEl, lookupPath, options, Map_) { 1 raycaster.setFromCamera(mouse, camera) - var intersectArr = [] - for (var l in layers) { - for (var p in layers[l]) - intersectArr.push(layers[l][p].boundingSphere) + const intersectArr = [] + for (let l in layers) { + for (let p in layers[l]) + for (let i in layers[l][p]) + intersectArr.push(layers[l][p][i].boundingSphere) } - var intersects = raycaster.intersectObjects(intersectArr) + const intersects = raycaster.intersectObjects(intersectArr) if (intersects.length > 0) { //reset all photosphere point materials resetLayerMaterials() + const intLayerName = intersects[0].object.layerName //change clicked point material - var point = - layers[intersects[0].object.layerName][ - intersects[0].object.name + const point = + layers[intLayerName][intersects[0].object.name][ + intersects[0].object.pid ].point point.material = Sprites.makeMarkerMaterial({ radius: 64, @@ -498,14 +639,18 @@ export default function (domEl, lookupPath, options, Map_) { render() //Select the point in the map - var markers = L_.layersGroup[intersects[0].object.layerName] + const markers = L_.layers.layer[intLayerName] if (markers != undefined) { markers.eachLayer(function (layer) { if ( intersects[0].object.name == layer.feature.properties[intersects[0].object.nameKey] ) { - layer.fireEvent('click') + if (lastIntLayerName) + L_.resetLayerFills(lastIntLayerName) + L_.highlight(layer) + lastIntLayerName = intLayerName + //layer.fireEvent('click') return } }) @@ -515,32 +660,37 @@ export default function (domEl, lookupPath, options, Map_) { function highlight(layer) { if (layers.hasOwnProperty(layer.options.layerName)) { - var l = layers[layer.options.layerName] - - for (var p in l) { - if ( - l[p].point.name == - layer.feature.properties[l[p].point.nameKey] - ) { - resetLayerMaterials() - l[p].point.material = Sprites.makeMarkerMaterial({ - radius: 64, - fillColor: { r: 102, g: 204, b: 102, a: 0 }, - strokeWeight: 20, - strokeColor: { r: 255, g: 0, b: 0, a: 0.9 }, - }) - render() + let l = layers[layer.options.layerName] + + for (let p in l) { + for (let i in l[p]) { + if ( + l[p][i].point.name == + layer.feature.properties[l[p][i].point.nameKey] + ) { + resetLayerMaterials() + l[p][i].point.material = Sprites.makeMarkerMaterial({ + radius: 64, + fillColor: { r: 102, g: 204, b: 102, a: 0 }, + strokeWeight: 20, + strokeColor: { r: 255, g: 0, b: 0, a: 0.9 }, + }) + render() + } } } } } function resetLayerMaterials() { - for (var l in layers) { - for (var p in layers[l]) { - layers[l][p].point.material.dispose() - layers[l][p].point.material = layers[l][p].point.savedMaterial - layers[l][p].point.material.needsUpdate = true + for (let l in layers) { + for (let p in layers[l]) { + for (let i in layers[l][p]) { + layers[l][p][i].point.material.dispose() + layers[l][p][i].point.material = + layers[l][p][i].point.savedMaterial + layers[l][p][i].point.material.needsUpdate = true + } } } } @@ -636,10 +786,10 @@ export default function (domEl, lookupPath, options, Map_) { var zero = [0, 0] if (az[0] < az[1]) { zero[0] = linearScale(az, [0, dim[0]], 0) - sphereRot = F_.mod((az[0] + az[1]) / 2, 360) + sphereRot = F_.mod((az[0] + az[1]) / 2, 360, true) } else { zero[0] = linearScale([az[0] - 360, az[1]], [0, dim[0]], 0) - sphereRot = F_.mod((az[0] - 360 + az[1]) / 2, 360) + sphereRot = F_.mod((az[0] - 360 + az[1]) / 2, 360, true) } zero[1] = linearScale(el, [dim[1], 0], 0) @@ -762,7 +912,6 @@ export default function (domEl, lookupPath, options, Map_) { return { changeImage: changeImage, - addPointLayer: addPointLayer, toggleControls: toggleControls, highlight: highlight, resize: resize, diff --git a/src/essence/Basics/Viewer_/Viewer_.js b/src/essence/Basics/Viewer_/Viewer_.js index 168e52a7..7b952081 100644 --- a/src/essence/Basics/Viewer_/Viewer_.js +++ b/src/essence/Basics/Viewer_/Viewer_.js @@ -19,6 +19,7 @@ var Viewer_ = { viewer: $('#viewer'), images: [], feature: null, + layer: null, imageDiv: null, url: null, ext: null, @@ -136,10 +137,11 @@ var Viewer_ = { }, //images is [ { 'url': '', 'name': '', 'isPanoramic': false },{...}, ... ] //Shows the first image too - changeImages: function (images, feature) { + changeImages: function (images, feature, layer) { images = images || [] Viewer_.images = images Viewer_.feature = feature + Viewer_.layer = layer var imageI = 0 var setLocAfter = false @@ -261,20 +263,30 @@ var Viewer_ = { window.onresize = this.photosphere.resize Viewer_.toolBarLoading.style('opacity', '1') - this.photosphere.changeImage(o, Viewer_.feature, function (err) { - if (err) { - console.log(err) - Viewer_.toolBarLoading.html(err) - } else { - Viewer_.toolBarLoading.style('opacity', '0') - if (setLocAfter) { - var l = L_.FUTURES.viewerLoc - Viewer_.photosphere.setTarget(l[0], l[1], l[2], l[3]) - L_.FUTURES.viewerLoc = null + this.photosphere.changeImage( + o, + Viewer_.feature, + Viewer_.layer, + function (err) { + if (err) { + console.log(err) + Viewer_.toolBarLoading.html(err) + } else { + Viewer_.toolBarLoading.style('opacity', '0') + if (setLocAfter) { + var l = L_.FUTURES.viewerLoc + Viewer_.photosphere.setTarget( + l[0], + l[1], + l[2], + l[3] + ) + L_.FUTURES.viewerLoc = null + } + Viewer_.photosphere.resize() } - Viewer_.photosphere.resize() } - }) + ) } else { this.imageViewer.style('display', 'inherit') this.imagePanorama.style('display', 'none') @@ -395,6 +407,7 @@ var Viewer_ = { function buildToolBar() { d3.select('#viewerToolBar').html('') + Viewer_.toolBar = d3 .select('#viewerToolBar') .append('div') @@ -403,6 +416,7 @@ function buildToolBar() { .style('display', 'flex') .style('justify-content', 'space-between') .style('padding', '0px 5px') + //.style() let left = Viewer_.toolBar.append('div') diff --git a/src/essence/LandingPage/LandingPage.js b/src/essence/LandingPage/LandingPage.js index 97741faf..dc821acf 100644 --- a/src/essence/LandingPage/LandingPage.js +++ b/src/essence/LandingPage/LandingPage.js @@ -24,6 +24,18 @@ export default { if (missions.length == 1 && !forceLanding) missionUrl = missions[0] } + if ( + missionUrl == false && + !forceLanding && + mmgisglobal.MAIN_MISSION != null && + mmgisglobal.MAIN_MISSION != '' && + mmgisglobal.MAIN_MISSION != 'undefined' && + typeof mmgisglobal.MAIN_MISSION === 'string' && + mmgisglobal.MAIN_MISSION.length > 0 + ) { + missionUrl = mmgisglobal.MAIN_MISSION + } + if (missionUrl == false && !forceConfig) { var background = d3 .select('body') diff --git a/src/essence/Tools/Chemistry/ChemistryTool.js b/src/essence/Tools/Chemistry/ChemistryTool.js index a64fbc29..cb259e7b 100644 --- a/src/essence/Tools/Chemistry/ChemistryTool.js +++ b/src/essence/Tools/Chemistry/ChemistryTool.js @@ -117,11 +117,11 @@ function interfaceWithMMWebGIS() { //Add chemOnClick to all layers with a chemistry variable /* //Moved to .use in onEachFeatureDefault - for( var l in L_.layersNamed) { - if( L_.layersNamed[l].hasOwnProperty( 'variables' ) && - L_.layersNamed[l].variables.hasOwnProperty( 'chemistry' ) ) { - if( L_.layersGroup[l] ) { - L_.layersGroup[l].eachLayer( function( layer ) { + for( var l in L_.layers.data) { + if( L_.layers.data[l].hasOwnProperty( 'variables' ) && + L_.layers.data[l].variables.hasOwnProperty( 'chemistry' ) ) { + if( L_.layers.layer[l] ) { + L_.layers.layer[l].eachLayer( function( layer ) { layer.on( 'click', chemOnClick ); } ); } @@ -133,13 +133,13 @@ function interfaceWithMMWebGIS() { $('#chemistryToolOptions #chemistryToolSingleMode').off('click', _ct0) $('#chemistryToolOptions #chemistryToolMultiMode').off('click', _ct1) - for (var l in L_.layersNamed) { + for (var l in L_.layers.data) { if ( - L_.layersNamed[l].hasOwnProperty('variables') && - L_.layersNamed[l].variables.hasOwnProperty('chemistry') + L_.layers.data[l].hasOwnProperty('variables') && + L_.layers.data[l].variables.hasOwnProperty('chemistry') ) { - if (L_.layersGroup[l]) { - L_.layersGroup[l].eachLayer(function (layer) { + if (L_.layers.layer[l]) { + L_.layers.layer[l].eachLayer(function (layer) { layer.off('click', chemOnClick) }) } @@ -160,8 +160,8 @@ function chemOnClick(d) { //If point has no chemistry at all if ( - !L_.layersNamed[layerName].variables || - !L_.layersNamed[layerName].variables.chemistry + !L_.layers.data[layerName].variables || + !L_.layers.data[layerName].variables.chemistry ) { d3.select('#chemistry_panel').selectAll('*').remove() return @@ -207,7 +207,7 @@ function chemOnClick(d) { */ else chemistrychart.make( chems, - L_.layersNamed[layerName].variables.chemistry, + L_.layers.data[layerName].variables.chemistry, 'chemistry_panel' ) } diff --git a/src/essence/Tools/Draw/DrawTool.css b/src/essence/Tools/Draw/DrawTool.css index 085d3800..fc3772a9 100644 --- a/src/essence/Tools/Draw/DrawTool.css +++ b/src/essence/Tools/Draw/DrawTool.css @@ -41,7 +41,7 @@ } .drawToolButton1 { - background: var(--color-o); + background: #067ca7; padding: 3px 8px; margin: 5px 0px; text-align: center; @@ -237,46 +237,61 @@ border-bottom: 1px solid var(--color-mmgis); border-left: 1px solid var(--color-mmgis); } -#drawToolDrawFilesNew { +#drawToolDrawFilesNewUpload { cursor: pointer; - width: 30px; + flex: 1; + line-height: 26px; height: 30px; background: var(--color-a1); + color: var(--color-a6); + text-align: center; + border-bottom: 1px solid rgba(0, 0, 0, 0.3); + transition: background 0.2s ease-out; + display: flex; + justify-content: center; + border-right: 1px solid var(--color-a1-5); +} +#drawToolDrawFilesNewUpload:hover { + background: var(--color-a2); color: var(--color-a7); +} +#drawToolDrawFilesNewUpload > div:first-child { + line-height: 31px; + font-size: 10px; +} +#drawToolDrawFilesNewUpload > div:last-child { line-height: 30px; + margin-left: 2px; +} +#drawToolDrawFilesNew { + cursor: pointer; + flex: 1; + line-height: 26px; + height: 30px; + background: var(--color-a1); + color: var(--color-a6); text-align: center; border-bottom: 1px solid rgba(0, 0, 0, 0.3); - transition: color 0.2s ease-out; + transition: background 0.2s ease-out; + display: flex; + justify-content: center; + border-left: 1px solid var(--color-a1-5); } - -#drawToolDrawFilesNewName:focus ~ #drawToolDrawFilesNew { - background: var(--color-mmgis); +#drawToolDrawFilesNew:hover { + background: var(--color-a2); + color: var(--color-a7); } -#drawToolDrawFilesNewLoading { - width: calc(100% - 14px); - height: 2px; - position: absolute; - top: 36px; - left: 7px; - overflow: hidden; - opacity: 0; - transition: opacity 0.1s cubic-bezier(0.445, 0.05, 0.55, 0.95); +#drawToolDrawFilesNew > div:first-child { + line-height: 31px; + font-size: 10px; } -#drawToolDrawFilesNewLoading > div { - width: 30%; - height: 100%; - background: #1169d3; - animation: drawToolLoading1 1s ease-in-out infinite; +#drawToolDrawFilesNew > div:last-child { + line-height: 30px; + margin-left: 2px; } -@keyframes drawToolLoading1 { - 0% { - transform: translateX(-100%); - width: 30%; - } - 100% { - transform: translateX(230%); - width: 60%; - } + +#drawToolDrawFilesNewName:focus ~ #drawToolDrawFilesNew { + background: var(--color-mmgis); } .drawToolFileDelete { @@ -564,6 +579,7 @@ height: 100%; display: flex; flex-flow: column; + position: relative; } #drawToolMaster { @@ -969,6 +985,9 @@ color: black; font-weight: bold; } +.drawToolShapeLi.temporallyHidden { + display: none !important; +} .drawToolShapeLiItem { cursor: pointer; @@ -1228,16 +1247,11 @@ margin-bottom: 8px; flex-flow: column; } -.drawToolContextMenuPropertiesName > div { - height: 30px; - line-height: 30px; -} .drawToolContextMenuPropertiesDescription { flex-flow: column; -} -.drawToolContextMenuPropertiesDescription > div { - height: 30px; - line-height: 30px; + border-bottom: 1px solid var(--color-a1); + padding-bottom: 8px; + margin-bottom: 8px; } #drawToolContextMenuPropertiesDescription { width: 100%; @@ -1353,17 +1367,42 @@ font-size: 12px; padding: 0px 5px 0px 9px; } +.drawToolFileEditListEditors { + height: 31px; + display: flex; + justify-content: space-between; + border-top: 1px solid black; + border-bottom: 1px solid black; + box-sizing: initial; +} +.drawToolFileEditListEditors > div { + line-height: 31px; + padding: 0px 8px; + font-size: 12px; + color: var(--color-a4); +} +.drawToolFileEditListEditors > input { + width: 180px; + height: 31px; + background: var(--color-a1-5); + border: none; + padding: 0px 8px; + font-size: 14px; + color: var(--color-mw2); + flex: 1 1; + border-left: 1px solid black; + transition: background 0.2s ease-out, border 0.2s ease-out; +} .drawToolFileEditOnDescription { display: flex; justify-content: space-between; - margin-bottom: 5px; } .drawToolFileDesc { background: var(--color-a); border: none; border-top: 1px solid black; color: var(--color-f); - min-width: 411px; + min-width: 452px; max-width: 750px; min-height: 100px; max-height: 400px; @@ -1991,7 +2030,6 @@ transition: height 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94); } #drawToolHistorySequenceList { - margin: 0px 2px 0px 5px; flex: 1; overflow-y: auto; } @@ -2005,8 +2043,8 @@ #drawToolHistorySequenceList > ul > li { color: var(--color-f); background: rgba(0, 0, 0, 0); - border-bottom: 1px solid rgba(0, 0, 17, 0.25); - padding: 2px 5px; + border-top: 1px solid var(--color-a1-5); + padding: 3px 8px; font-size: 13px; cursor: pointer; transition: background 0.2s cubic-bezier(0.39, 0.575, 0.565, 1); @@ -2197,35 +2235,6 @@ background: var(--color-c); } -#drawToolFileUpload { - cursor: pointer; - width: 30px; - height: 30px; - background: var(--color-a1); - color: var(--color-a5); - border-right: 1px solid var(--color-a); - box-sizing: border-box; - line-height: 30px; - text-align: center; - transition: background 0.2s ease-out; -} -#drawToolFileUpload:hover { - color: var(--color-a7); - background: var(--color-a2); -} -#drawToolFileUpload i { - cursor: pointer; - pointer-events: none; -} -#drawToolFileUpload input { - position: absolute; - left: 7px; - top: 7px; - opacity: 0; - height: 30px; - width: 26px; -} - .leaflet-marker-icon.leaflet-div-icon.leaflet-editing-icon.leaflet-touch-icon.leaflet-zoom-animated.leaflet-interactive.leaflet-marker-draggable { width: 12px !important; height: 12px !important; @@ -2537,10 +2546,176 @@ display: none; background: var(--color-k); color: var(--color-f); - padding: 15px; + padding: 10px; overflow-y: auto; height: calc(100vh - 186px); } .drawToolContextMenuTab.active { display: inherit; } + +.drawToolContextMenuPropertiesTitle { + height: 30px; + line-height: 30px; + color: var(--color-query); +} +.drawToolContextMenuPropertiesExtended { + margin-bottom: 12px; + padding-bottom: 12px; + border-bottom: 1px solid var(--color-a1); +} +.drawToolContextMenuPropertiesExtended > li { + display: flex; + justify-content: space-between; + padding: 2px 0px; +} + +#drawToolContextMenuPropertiesTemplate { + border-bottom: 1px solid var(--color-a1); + margin-bottom: 12px; +} + +.drawToolFileTemplate { +} +.drawToolFileTemplate > div:first-child { +} +.drawToolFileTemplate > div:last-child { + display: flex; + cursor: pointer; +} +.drawToolFileTemplate > div:last-child > div { + overflow: hidden; + text-overflow: ellipsis; + max-width: 120px; +} + +.drawToolFileTemplate > div:last-child > i { + background: var(--color-a6); + color: var(--color-a-5); + border-radius: 50%; + width: 16px; + height: 16px; + text-align: center; + line-height: 16px; + margin-left: 4px; + margin-top: -2px; + transition: background 0.2s ease-in-out; +} +.drawToolFileTemplate > div:last-child:hover > i { + background: var(--color-c); +} + +#cmExportGeoJSON, +#cmExportSourceGeoJSON { + display: block; +} +#cmExportGeoJSON > div:last-child, +#cmExportSourceGeoJSON > div:last-child { + font-size: 12px; + text-align: right; +} + +/*FILE INFO TEMPLATE MODAL*/ +#drawToolFileTemplateEditModal { + background: var(--color-a-5); + min-width: 624px; +} +#drawToolFileTemplateEditModalTitle { + padding: 0px 0px 0px 10px; + height: 40px; + line-height: 39px; + font-size: 18px; + background: var(--color-i); + border-top-left-radius: 3px; + border-top-right-radius: 3px; + display: flex; + justify-content: space-between; +} +#drawToolFileTemplateEditModalTitle > div:first-child { + display: flex; +} +#drawToolFileTemplateEditModalTitle > div:first-child > div { + margin-left: 6px; + line-height: 40px; +} +#drawToolFileTemplateEditModalClose { + width: 40px; + height: 40px; + text-align: center; +} +#drawToolFileTemplateEditModalActions { + display: flex; + padding: 6px 10px; + justify-content: space-between; + background: var(--color-a1); + border-top: 1px solid var(--color-a); +} +#drawToolFileTemplateEditModalActions > div { + width: 70px; + height: 35px; + line-height: 30px; + margin: 0; +} +#drawToolFileTemplateEditModalActionsCancel { + background: var(--color-a1); +} + +.drawToolContextMenuPropertiesCollapsible + > .drawToolContextMenuPropertiesTitle { + display: flex; + justify-content: space-between; + cursor: pointer; +} +.drawToolContextMenuPropertiesCollapsible + > .drawToolContextMenuPropertiesTitle + > i { + transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94); +} +.drawToolContextMenuPropertiesCollapsible + > .drawToolContextMenuPropertiesTitle:hover + > i { + color: var(--color-c); +} +.drawToolContextMenuPropertiesCollapsible.state-collapsed + > .drawToolContextMenuPropertiesTitle + > i { + transform: rotateZ(-90deg); +} +.drawToolContextMenuPropertiesCollapsible.state-collapsed > div:last-child { + display: none; +} + +/*files loading spinner*/ +#drawToolFilesLoadingSpinner { + position: absolute; + pointer-events: none; + width: 100%; + height: 100%; + opacity: 0; + transition: opacity 0.2s ease-in-out; +} +#drawToolFilesLoadingSpinner.on { + opacity: 1; +} + +#DrawTool_TimeToggle { + position: absolute; + bottom: 45px; + left: 50%; + transform: translateX(-50%); + display: flex; + background: var(--color-a); + border-radius: 2px; + height: 24px; + line-height: 18px; + padding: 3px 3px; + font-size: 13px; + box-shadow: 0px 4px 3px 0px rgba(0,0,0,0.2); +} +#DrawTool_TimeToggle > div:first-child { + padding: 0px 6px 0px 5px; + letter-spacing: 1px; +} +#DrawTool_TimeToggle_switch { + top: -14px; +} diff --git a/src/essence/Tools/Draw/DrawTool.js b/src/essence/Tools/Draw/DrawTool.js index ec5c269a..3d7ff010 100644 --- a/src/essence/Tools/Draw/DrawTool.js +++ b/src/essence/Tools/Draw/DrawTool.js @@ -4,6 +4,8 @@ import DrawTool_Files from './DrawTool_Files' import DrawTool_History from './DrawTool_History' import DrawTool_Publish from './DrawTool_Publish' import DrawTool_Shapes from './DrawTool_Shapes' +import DrawTool_FileModal from './DrawTool_FileModal' +import DrawTool_Templater from './DrawTool_Templater' import $ from 'jquery' import * as d3 from 'd3' @@ -15,15 +17,16 @@ import Viewer_ from '../../Basics/Viewer_/Viewer_' import ToolController_ from '../../Basics/ToolController_/ToolController_' import CursorInfo from '../../Ancillary/CursorInfo' import Description from '../../Ancillary/Description' +import TimeControl from '../../Ancillary/TimeControl' import { Kinds } from '../../../pre/tools' import turf from 'turf' -import shp from '../../../external/shpjs/shapefile' -import shpwrite from '../../../external/SHPWrite/shpwrite' import calls from '../../../pre/calls' import './DrawTool.css' +import tippy from 'tippy.js' + // Plugins import DrawTool_Geologic from './Plugins/Geologic/DrawTool_Geologic' import DrawTool_SetOperations from './Plugins/SetOperations/DrawTool_SetOperations' @@ -58,24 +61,6 @@ var markup = [ "<div id='drawToolDraw'>", "<div id='drawToolDrawShapes'>", - "<div id='drawToolDrawFilesNewDiv'>", - "<div id='drawToolFileUpload'>", - "<i class='mdi mdi-upload mdi-18px'></i>", - "<input title='Upload' type=file accept='.json, .geojson, .shp, .dbf' multiple>", - "</div>", - "<input id='drawToolDrawFilesNewName' type='text' placeholder='New File' />", - "<select>", - "<option id='drawToolNewFileAll' value='all'>Map</option>", - "<option id='drawToolNewFileROI' value='roi'>ROI</option>", - "<option id='drawToolNewFileCampaign' value='campaign'>Campaign</option>", - "<option id='drawToolNewFileCampsite' value='campsite'>Campsite</option>", - "<option id='drawToolNewFileTrail' value='trail'>Trail</option>", - "<option id='drawToolNewFileSignpost' value='signpost'>Signpost</option>", - //"<option value='note'>Note</option>", - "</select>", - "<i id='drawToolDrawFilesNew' title='Make new file' class='mdi mdi-plus mdi-18px'></i>", - "<div id='drawToolDrawFilesNewLoading'><div></div></div>", - "</div>", //"<div id='drawToolDrawingInIndicator'>Choose a file to draw in</div>", "<div id='drawToolDrawingCont'>", "<div id='drawToolDrawingTypeDiv'>", @@ -96,7 +81,7 @@ var markup = [ "<div title='Clip drawing of existing shapes'>Draw Clipping</div>", "<div id='drawToolDrawSettingsTier' class='drawToolRadio'>", "<div value='over'>Over</div>", - "<div class='active' value='under'>Under</div>", + "<div value='under'>Under</div>", "<div value='off'>Off</div>", "</div>", "</li>", @@ -203,14 +188,36 @@ var markup = [ "</div>", "<ul id='drawToolDrawFilesList' class='mmgisScrollbar2'>", "</ul>", + "<div id='drawToolFilesLoadingSpinner'>", + "<svg class='mmgis-spinner1' viewbox='0 0 50 50'>", + "<circle class='path' cx='25' cy='25' r='20' fill='none' stroke-width='5' />", + "</svg>", + "</div>", "</div>", "</div>", + + "<div id='drawToolDrawFilesNewDiv'>", + //"<input id='drawToolDrawFilesNewName' type='text' placeholder='New File' />", + /* + "<select>", + "<option id='drawToolNewFileAll' value='all'>Map</option>", + "<option id='drawToolNewFileROI' value='roi'>ROI</option>", + "<option id='drawToolNewFileCampaign' value='campaign'>Campaign</option>", + "<option id='drawToolNewFileCampsite' value='campsite'>Campsite</option>", + "<option id='drawToolNewFileTrail' value='trail'>Trail</option>", + "<option id='drawToolNewFileSignpost' value='signpost'>Signpost</option>", + //"<option value='note'>Note</option>", + "</select>", + */ + "<div id='drawToolDrawFilesNewUpload'><div>UPLOAD</div><div><i class='mdi mdi-upload mdi-18px'></i></div></div>", + "<div id='drawToolDrawFilesNew'><div>CREATE</div><div><i class='mdi mdi-plus mdi-18px'></i></div></div>", + "</div>", "</div>", "<div id='drawToolShapes'>", "<div id='drawToolShapesFilterDiv'>", "<input id='drawToolShapesFilter' type='text' placeholder='Filter Shapes' />", - "<div id='drawToolShapesFilterClear'><i id='drawToolDrawFilesNew' class='mdi mdi-close mdi-18px'></i></div>", + "<div id='drawToolShapesFilterClear'><i class='mdi mdi-close mdi-18px'></i></div>", "<div id='drawToolShapesFilterCount'></div>", "</div>", "<div id='drawToolDrawShapesList' class='mmgisScrollbar2'>", @@ -269,10 +276,12 @@ var DrawTool = { activeContent: 'draw', intentType: null, currentFileId: null, + _firstGetFiles: null, filesOn: [], allTags: {}, //<tag>: count, ... tags: [], labelsOn: [], + fileGeoJSONFeatures: {}, palettes: [ [ '#26a8ff', @@ -501,6 +510,7 @@ var DrawTool = { DrawTool.activeContent = 'draw' DrawTool.intentType = null DrawTool.currentFileId = null + DrawTool._firstGetFiles = null //DrawTool.filesOn = []; DrawTool.isEditing = false @@ -569,158 +579,17 @@ var DrawTool = { $(this).parent().find('div').removeClass('active') $(this).addClass('active') }) - //Upload - $('#drawToolFileUpload > input').on('change', function (evt) { - $('#drawToolDrawFilesNewLoading').css('opacity', '1') - $('#drawToolFileUpload > i').css('color', '#1169d3') - - var files = evt.target.files // FileList object - - // use the 1st file from the list - var f = files[0] - var ext = F_.getExtension(f.name).toLowerCase() - switch (ext) { - case 'shp': - case 'dbf': - var shpFile - var dbfFile - for (var i = 0; i < files.length; i++) { - if ( - F_.getExtension(files[i].name).toLowerCase() == - 'shp' - ) - shpFile = files[i] - if ( - F_.getExtension(files[i].name).toLowerCase() == - 'dbf' - ) - dbfFile = files[i] - } - if (shpFile && dbfFile) { - var shpBuffer - var dbfBuffer - - var readerSHP = new FileReader() - readerSHP.onload = function (e) { - shpBuffer = e.target.result - var readerDBF = new FileReader() - readerDBF.onload = function (e) { - dbfBuffer = e.target.result - bothLoaded() - } - readerDBF.readAsArrayBuffer(dbfFile) - } - readerSHP.readAsArrayBuffer(shpFile) - - function bothLoaded() { - var featureArray = [] - shp.open(shpBuffer, dbfBuffer) - .then((source) => - source.read().then(function log(result) { - if (result.done) { - var geojsonResult = - F_.getBaseGeoJSON() - geojsonResult.features = - featureArray - var body = { - file_name: f.name, - intent: 'all', - geojson: - JSON.stringify( - geojsonResult - ), - } - DrawTool.makeFile( - body, - function () { - DrawTool.populateFiles() - endLoad() - } - ) - return - } - - featureArray.push( - F_.geoJSONFeatureMetersToDegrees( - result.value - ) - ) - return source.read().then(log) - }) - ) - .catch((error) => { - endLoad() - }) - } - } else { - CIU('Warning! FileManager - missing .shp or .dbf') - } - break - case 'json': - case 'geojson': - var reader = new FileReader() - // Closure to capture the file information. - - reader.onload = (function (file) { - return function (e) { - var body = { - file_name: file.name, - intent: 'all', - geojson: e.target.result, - } - if ( - body.geojson && - JSON.parse(body.geojson).type !== - 'FeatureCollection' - ) { - CIU( - 'Uploaded object has no type: "FeatureCollection". Are you sure this is geojson?' - ) - return - } - DrawTool.makeFile(body, function () { - DrawTool.populateFiles() - endLoad() - }) - } - })(f) - - // Read in the image file as a data URL. - reader.readAsText(f) - break - default: - CIU( - 'Only .json, .geojson and .shp (with .dbf) files may be uploaded' - ) - } - - function endLoad() { - $('#drawToolDrawFilesNewLoading').css('opacity', '0') - $('#drawToolFileUpload > i').css('color', 'unset') - } - function CIU(message) { - CursorInfo.update( - message, - 6000, - true, - { x: 305, y: 6 }, - '#e9ff26', - 'black' - ) - endLoad() - } - }) }, destroy: function () { this.MMGISInterface.separateFromMMGIS() - for (var l in L_.layersGroup) { + for (var l in L_.layers.layer) { var s = l.split('_') var onId = s[1] != 'master' ? parseInt(s[1]) : s[1] if (s[0] == 'DrawTool' && DrawTool.filesOn.indexOf(onId) != -1) { - for (var i = 0; i < L_.layersGroup[l].length; i++) { - var f = L_.layersGroup[l][i] + for (var i = 0; i < L_.layers.layer[l].length; i++) { + var f = L_.layers.layer[l][i] if (!f) continue @@ -755,13 +624,13 @@ var DrawTool = { let layer = d.target let found = false if (!d.target.hasOwnProperty('feature')) { - for (var _l in L_.layersGroup) { + for (var _l in L_.layers.layer) { if (!_l.startsWith('DrawTool_')) continue - for (var x in L_.layersGroup[l]) { + for (var x in L_.layers.layer[l]) { var childLayer = - L_.layersGroup[l][x] + L_.layers.layer[l][x] if ('hasLayer' in childLayer) { if ( childLayer.hasOwnProperty( @@ -823,13 +692,14 @@ var DrawTool = { let name // If the DrawTool layer that is hovered is an arrow, the parent arrow layer knows the name if (!d.target.hasOwnProperty('feature')) { - for (var _l in L_.layersGroup) { + for (var _l in L_.layers.layer) { if (!_l.startsWith('DrawTool_')) { continue } - for (var x in L_.layersGroup[l]) { - var layer = L_.layersGroup[l][x] + for (var x in L_.layers.layer[l]) { + var layer = + L_.layers.layer[l][x] if ('hasLayer' in layer) { if ( layer.hasOwnProperty( @@ -997,20 +867,20 @@ var DrawTool = { } if (typeof file_description !== 'string') return [] - const tags = file_description.match(/#\w*/g) || [] + const tags = file_description.match(/~#\w+/g) || [] const uniqueTags = [...tags] // remove '#'s - tagFolders.tags = uniqueTags.map((t) => t.substring(1)) || [] + tagFolders.tags = uniqueTags.map((t) => t.substring(2)) || [] - const folders = file_description.match(/@\w*/g) || [] + const folders = file_description.match(/~@\w+/g) || [] const uniqueFolders = [...folders] // remove '@'s - tagFolders.folders = uniqueFolders.map((t) => t.substring(1)) || [] + tagFolders.folders = uniqueFolders.map((t) => t.substring(2)) || [] - const efolders = file_description.match(/\^\w*/g) || [] + const efolders = file_description.match(/~\^\w+/g) || [] const uniqueEFolders = [...efolders] // remove '^'s - tagFolders.efolders = uniqueEFolders.map((t) => t.substring(1)) || [] + tagFolders.efolders = uniqueEFolders.map((t) => t.substring(2)) || [] // At least one folder if (noDefaults !== true) { @@ -1053,13 +923,18 @@ var DrawTool = { stripTagsFromDescription(file_description) { if (typeof file_description !== 'string') return '' return file_description - .replaceAll(/#\w*/g, '') - .replaceAll(/@\w*/g, '') - .replaceAll(/\^\w*/g, '') + .replaceAll(/~#\w+/g, '') + .replaceAll(/~@\w+/g, '') + .replaceAll(/~\^\w+/g, '') .trimStart() .trimEnd() }, getFiles: function (callback) { + // setLoading + if (DrawTool._firstGetFiles !== true) { + $(`#drawToolFilesLoadingSpinner`).addClass('on') + DrawTool._firstGetFiles = true + } calls.api( 'files_getfiles', {}, @@ -1087,29 +962,44 @@ var DrawTool = { DrawTool.files[i] ) } - DrawTool.allTags = DrawTool.getAllTags(true) DrawTool.tags = Object.keys(DrawTool.allTags) } if (typeof callback === 'function') callback() + + // endLoading + $(`#drawToolFilesLoadingSpinner`).removeClass('on') }, function (data) { if (data && data.message == 'User is not logged in.') { $('#drawToolNotLoggedIn').css('display', 'inherit') } + // endLoading + $(`#drawToolFilesLoadingSpinner`).removeClass('on') } ) }, makeFile: function (body, callback) { + const filename = body.file_name calls.api( 'files_make', body, function (data) { - if (data.status === 'success') + if (data.status === 'success') { DrawTool.getFiles(() => { callback(data.body.file_id) + CursorInfo.update( + `Successfully made new file: ${filename}`, + 4000, + false, + { x: 305, y: 6 }, + '#009eff', + 'white', + null, + true + ) }) - else + } else CursorInfo.update( 'Failed to add file.', 6000, @@ -1190,6 +1080,19 @@ var DrawTool = { ) }, addDrawing: function (body, callback, failure) { + // Add template property defaults + const file = DrawTool.getFileObjectWithId(body.file_id) + if (file?.template?.template && body?.properties) { + let newProps = JSON.parse(body.properties) + const templateDefaults = DrawTool_Templater.getTemplateDefaults( + file?.template?.template, + L_.layers.layer[`DrawTool_${body.file_id}`] + ) + + newProps = { ...newProps, ...templateDefaults } + body.properties = JSON.stringify(newProps) + } + if (body.file_id == null) { CursorInfo.update( 'No file chosen. Please select or make a file for drawings.', @@ -1300,8 +1203,186 @@ var DrawTool = { } } }, -} + enforceTemplate(geojson, templateObj, force) { + if (templateObj == null || templateObj.template == null) return geojson + const templateEnforcedFeatures = [] + geojson.features.forEach((f) => { + const newF = JSON.parse(JSON.stringify(f)) + if (force) { + newF.properties = newF.properties || {} + const forcedTemplateProperties = {} + templateObj.template.forEach((t) => { + if (!newF.properties.hasOwnProperty([t.field])) + forcedTemplateProperties[t.field] = t.default + else + forcedTemplateProperties[t.field] = + newF.properties[t.field] + }) + newF.properties = forcedTemplateProperties + } else { + newF.properties = newF.properties || {} + templateObj.template.forEach((t) => { + if (!newF.properties.hasOwnProperty([t.field])) + newF.properties[t.field] = t.default + }) + } + templateEnforcedFeatures.push(newF) + }) + geojson.features = templateEnforcedFeatures + return geojson + }, + _isFeatureTemporallyVisible(feature, startField, endField) { + if (DrawTool.timeToggledOn !== true) return true + const startTime = F_.removeTimeZoneOffset( + new Date(L_.TimeControl_.getStartTime()).getTime() + ) + const endTime = F_.removeTimeZoneOffset( + new Date(L_.TimeControl_.getEndTime()).getTime() + ) + + let startTimeValue = false + if (startField) + startTimeValue = F_.getIn(feature.properties, startField, 0) + let endTimeValue = false + if (endField) + endTimeValue = F_.getIn(feature.properties, endField, false) + + // No prop, won't show + if (endTimeValue === false) return false + else if ( + typeof endTimeValue === 'string' && + endTimeValue.indexOf('T') != -1 + ) + endTimeValue += 'Z' + + if (startTimeValue === false) { + //Single Point in time, just compare end times + let endDate = new Date(endTimeValue) + if (endDate === 'Invalid Date') return false + endDate = endDate.getTime() + if (endDate <= endTime && endDate >= startTime) return true + return false + } else { + if ( + typeof startTimeValue === 'string' && + startTimeValue.indexOf('T') != -1 + ) + startTimeValue += 'Z' + // Then we have a range + let startDate = new Date(startTimeValue) + let endDate = new Date(endTimeValue) + + // Bad prop value, won't show + if (startDate === 'Invalid Date' || endDate === 'Invalid Date') + return false + + startDate = startDate.getTime() + endDate = endDate.getTime() + if (endTime < startDate) return false + if (startTime > endDate) return false + + return true + } + }, + timeFilterDrawingLayer(fileId) { + if (L_.layers.layer[`DrawTool_${fileId}`]) { + const file = DrawTool.getFileObjectWithId(fileId) + + let startField + let endField + if (file?.template?.template) { + file.template.template.forEach((t) => { + if (startField == null && t.isStart === true) + startField = t.field + if (endField == null && t.isEnd === true) endField = t.field + }) + } + L_.layers.layer[`DrawTool_${fileId}`].forEach((l, index) => { + if (l == null) return + if (l.feature == null) { + if (l._layers) { + Object.keys(l._layers).forEach((l2) => { + l2 = l._layers[l2] + if (l2.feature) { + const isVisible = + DrawTool._isFeatureTemporallyVisible( + l2.feature, + startField, + endField + ) + if (l2.savedOptions == null) + l2.savedOptions = JSON.parse( + JSON.stringify(l2.options) + ) + l2.temporallyHidden = !isVisible + if (l2.temporallyHidden) + $( + `#drawToolShapeLiItem_DrawTool_${fileId}_${index}` + ).addClass('temporallyHidden') + else + $( + `#drawToolShapeLiItem_DrawTool_${fileId}_${index}` + ).removeClass('temporallyHidden') + if (l2.temporallyHidden) { + l2.setStyle({ + opacity: 0, + fillOpacity: 0, + }) + if (l2._path?.style) + l2._path.style.pointerEvents = 'none' + } else if (l2.savedOptions) { + l2.setStyle({ + opacity: l2.savedOptions.opacity, + fillOpacity: + l2.savedOptions.fillOpacity, + }) + if (l2._path?.style) + l2._path.style.pointerEvents = 'all' + } + } + }) + } + } else { + const isVisible = DrawTool._isFeatureTemporallyVisible( + l.feature, + startField, + endField + ) + if (l.savedOptions == null) + l.savedOptions = JSON.parse(JSON.stringify(l.options)) + + l.temporallyHidden = !isVisible + if (l.temporallyHidden) + $( + `#drawToolShapeLiItem_DrawTool_${fileId}_${index}` + ).addClass('temporallyHidden') + else + $( + `#drawToolShapeLiItem_DrawTool_${fileId}_${index}` + ).removeClass('temporallyHidden') + if (l.setStyle) { + if (l.temporallyHidden) { + l.setStyle({ + opacity: 0, + fillOpacity: 0, + }) + if (l._path?.style) + l._path.style.pointerEvents = 'none' + } else if (l.savedOptions) { + l.setStyle({ + opacity: l.savedOptions.opacity, + fillOpacity: l.savedOptions.fillOpacity, + }) + if (l._path?.style) + l._path.style.pointerEvents = 'all' + } + } + } + }) + } + }, +} // function interfaceWithMMGIS() { this.separateFromMMGIS = function () { @@ -1315,8 +1396,66 @@ function interfaceWithMMGIS() { tools.selectAll('*').remove() //Add a semantic container tools = tools.append('div').style('height', '100%') + //Add the markup to tools or do it manually tools.html(markup) + + // Set defaultDrawClipping if any + $( + `#drawToolDrawSettingsTier > [value="${ + ['over', 'under', 'off'].includes(DrawTool.vars.defaultDrawClipping) + ? DrawTool.vars.defaultDrawClipping + : 'under' + }"]` + ).addClass('active') + + // Add time indicator + if (L_.configData?.time?.enabled === true) { + // prettier-ignore + $('body').append([ + `<div id="DrawTool_TimeToggle">`, + `<div>Temporal Drawings</div>`, + `<div class="mmgisToggleSwitch">`, + `<input type="checkbox" id="DrawTool_TimeToggle_switch"/>`, + `<label for="DrawTool_TimeToggle_switch">Toggle</label>`, + `</div>`, + `</div>` + ].join('\n')) + $('#DrawTool_TimeToggle').css( + 'display', + $('#toggleTimeUI.active').length > 0 ? 'flex' : 'none' + ) + + $('#DrawTool_TimeToggle_switch').on('input', function (e) { + // Toggle edit panel off + $('.drawToolContextMenuHeaderClose').click() + DrawTool.timeToggledOn = $(this).is(':checked') + DrawTool.filesOn.forEach((fileId) => { + DrawTool.timeFilterDrawingLayer(fileId) + }) + }) + L_.subscribeTimeChange('DrawTool', (times) => { + DrawTool.filesOn.forEach((fileId) => { + DrawTool.timeFilterDrawingLayer(fileId) + }) + }) + L_.subscribeOnTimeUIToggle('DrawTool', (active) => { + $('#DrawTool_TimeToggle').css('display', active ? 'flex' : 'none') + }) + tippy('#DrawTool_TimeToggle', { + content: + 'Only display drawings whose templated dates fall within the current time window.', + placement: 'bottom', + theme: 'blue', + maxWidth: 700, + }) + } + + tippy('#drawToolDrawFilesNew', { + content: 'New File', + placement: 'right', + theme: 'blue', + }) //Force intent mappings $('#drawToolNewFileAll').html(DrawTool.intentNameMapping.all) $('#drawToolNewFileROI').html(DrawTool.intentNameMapping.roi) @@ -1339,9 +1478,6 @@ function interfaceWithMMGIS() { DrawTool.intentNameMapping.signpost + 's' ) - if (F_.getBrowser() == 'firefox') - $('#drawToolDrawFiles').css('max-height', 'calc(100vh - 313px)') - $('#drawToolDrawingSettingsToggle').on('click', function () { $('#drawToolDrawingSettingsToggle').toggleClass('active') $('#drawToolDrawSettings').toggleClass('active') @@ -1420,41 +1556,14 @@ function interfaceWithMMGIS() { } else return true }) + $('#drawToolDrawFilesNewUpload').on('click', function () { + DrawTool_FileModal.newFileModal(DrawTool, function () { + $('#drawToolFileUpload > input').click() + }) + }) //Adding a new file $('#drawToolDrawFilesNew').on('click', function () { - var val = $('#drawToolDrawFilesNewName').val() - var intent = $('#drawToolDrawFilesNewDiv > select').val() - if (val == null || val == '') { - CursorInfo.update( - 'Please enter a file name.', - 6000, - true, - { x: 305, y: 6 }, - '#e9ff26', - 'black' - ) - return - } - if (/[&\'\"<>]/g.test(val)) { - CursorInfo.update( - 'Invalid file name.', - 6000, - true, - { x: 305, y: 6 }, - '#e9ff26', - 'black' - ) - return - } - var body = { - file_name: val || 'New File', - intent: intent, - } - DrawTool.makeFile(body, function (file_id) { - DrawTool.populateFiles(file_id) - - $('#drawToolDrawFilesNewName').val('') - }) + DrawTool_FileModal.newFileModal(DrawTool) }) //Copy shapes @@ -1506,7 +1615,7 @@ function interfaceWithMMGIS() { if ($(elm).hasClass('active')) { var layer = $(elm).attr('layer') var index = $(elm).attr('index') - var shape = L_.layersGroup[layer][index] + var shape = L_.layers.layer[layer][index] let fromFileId = $(elm).attr('file_id') let fromFile = DrawTool.getFileObjectWithId(fromFileId) @@ -1706,6 +1815,8 @@ function interfaceWithMMGIS() { function separateFromMMGIS() { DrawTool.endDrawing() $('.drawToolContextMenuHeaderClose').click() + L_.unsubscribeTimeChange('DrawTool') + L_.unsubscribeOnTimeUIToggle('DrawTool') DrawTool.open = false } } diff --git a/src/essence/Tools/Draw/DrawTool.test.js b/src/essence/Tools/Draw/DrawTool.test.js index 08c30b20..e8419797 100644 --- a/src/essence/Tools/Draw/DrawTool.test.js +++ b/src/essence/Tools/Draw/DrawTool.test.js @@ -269,7 +269,7 @@ var Test = { 'Switches to polygon drawing', $('.drawToolDrawingTypePolygon').hasClass('active') ) - var oldLength = L_.layersGroup['DrawTool_7'].length + var oldLength = L_.layers.layer['DrawTool_7'].length Test_.mapEvent('click') Test_.fireEvent('mousemove', 300, 300) Test.tool.drawing.polygon.move() @@ -282,7 +282,7 @@ var Test = { setTimeout(function () { c( 'Draws and saves a polygon', - L_.layersGroup['DrawTool_7'].length == oldLength + 1 + L_.layers.layer['DrawTool_7'].length == oldLength + 1 ) }, Test.timeout) }, @@ -297,7 +297,7 @@ var Test = { $('.drawToolDrawingTypeLine').hasClass('active') ) - var oldLength = F_.noNullLength(L_.layersGroup['DrawTool_7']) + var oldLength = F_.noNullLength(L_.layers.layer['DrawTool_7']) Test_.mapEvent('click') Test_.fireEvent('mousemove', 300, 300) Test.tool.drawing.line.move() @@ -310,7 +310,7 @@ var Test = { setTimeout(function () { c( 'Draws and saves a line', - F_.noNullLength(L_.layersGroup['DrawTool_7']) == + F_.noNullLength(L_.layers.layer['DrawTool_7']) == oldLength + 1 ) }, Test.timeout) @@ -326,13 +326,13 @@ var Test = { $('.drawToolDrawingTypePoint').hasClass('active') ) - var oldLength = F_.noNullLength(L_.layersGroup['DrawTool_7']) + var oldLength = F_.noNullLength(L_.layers.layer['DrawTool_7']) Test.tool.drawing.point.shape = { lat: -5, lng: 138 } Test_.mapEvent('draw:drawstop') setTimeout(function () { c( 'Draws and saves a point', - F_.noNullLength(L_.layersGroup['DrawTool_7']) == + F_.noNullLength(L_.layers.layer['DrawTool_7']) == oldLength + 1 ) }, Test.timeout) @@ -348,7 +348,7 @@ var Test = { $('.drawToolDrawingTypeText').hasClass('active') ) - var oldLength = F_.noNullLength(L_.layersGroup['DrawTool_7']) + var oldLength = F_.noNullLength(L_.layers.layer['DrawTool_7']) Test.tool.drawing.annotation.shape = { lat: -4.5, lng: 137.5, @@ -359,7 +359,7 @@ var Test = { setTimeout(function () { c( 'Draws and saves text', - F_.noNullLength(L_.layersGroup['DrawTool_7']) == + F_.noNullLength(L_.layers.layer['DrawTool_7']) == oldLength + 1 ) }, Test.timeout) @@ -375,7 +375,7 @@ var Test = { $('.drawToolDrawingTypeArrow').hasClass('active') ) - var oldLength = F_.noNullLength(L_.layersGroup['DrawTool_7']) + var oldLength = F_.noNullLength(L_.layers.layer['DrawTool_7']) Test.tool.drawing.arrow.start({ latlng: { lat: -4.5, lng: 137.5 }, }) @@ -385,7 +385,7 @@ var Test = { setTimeout(function () { c( 'Draws and saves arrows', - F_.noNullLength(L_.layersGroup['DrawTool_7']) == + F_.noNullLength(L_.layers.layer['DrawTool_7']) == oldLength + 1 ) }, Test.timeout) @@ -465,7 +465,7 @@ var Test = { setTimeout(function () { c( 'Deletes polygon', - L_.layersGroup['DrawTool_7'][0] == null + L_.layers.layer['DrawTool_7'][0] == null ) }, Test.timeout) }, Test.timeout) @@ -539,7 +539,7 @@ var Test = { setTimeout(function () { c( 'Deletes line', - L_.layersGroup['DrawTool_7'][1] == null + L_.layers.layer['DrawTool_7'][1] == null ) }, Test.timeout) }, Test.timeout) @@ -620,7 +620,7 @@ var Test = { setTimeout(function () { c( 'Deletes point', - L_.layersGroup['DrawTool_7'][2] == null + L_.layers.layer['DrawTool_7'][2] == null ) }, Test.timeout) }, Test.timeout) @@ -705,7 +705,7 @@ var Test = { setTimeout(function () { c( 'Deletes text', - L_.layersGroup['DrawTool_7'][3] == null + L_.layers.layer['DrawTool_7'][3] == null ) }, Test.timeout) }, Test.timeout) @@ -780,7 +780,7 @@ var Test = { setTimeout(function () { c( 'Deletes arrow', - L_.layersGroup['DrawTool_7'][4] == null + L_.layers.layer['DrawTool_7'][4] == null ) }, Test.timeout) }, Test.timeout) @@ -852,20 +852,20 @@ var Test = { ).click() c( 'Can open file popup', - $('#mmgisModal .drawToolFileEditOn').css('display') != + $('.mmgisModal .drawToolFileEditOn').css('display') != 'none' ) - $('#mmgisModal .drawToolFileNameInput').val( + $('.mmgisModal .drawToolFileNameInput').val( 'Test Trail Altered' ) - $('#mmgisModal .drawToolFileDesc').text( + $('.mmgisModal .drawToolFileDesc').text( 'Description Altered' ) - $('#mmgisModal #drawToolFileEditOnPublicityDropdown').val( + $('.mmgisModal #drawToolFileEditOnPublicityDropdown').val( 'private' ) - $('#mmgisModal .drawToolFileSave').click() + $('.mmgisModal .drawToolFileSave').click() setTimeout(function () { $( @@ -880,22 +880,22 @@ var Test = { ) c( 'File name input updates', - $('#mmgisModal .drawToolFileNameInput').val() === + $('.mmgisModal .drawToolFileNameInput').val() === 'Test Trail Altered' ) c( 'File description updates', - $('#mmgisModal .drawToolFileDesc').text() === + $('.mmgisModal .drawToolFileDesc').text() === 'Description Altered' ) c( 'File publicity updates', $( - '#mmgisModal #drawToolFileEditOnPublicityDropdown' + '.mmgisModal #drawToolFileEditOnPublicityDropdown' ).val() == 'private' ) - $('#mmgisModal .drawToolFileCancel').click() + $('.mmgisModal .drawToolFileCancel').click() }, Test.timeout * 3) }, Test.timeout) }, @@ -1374,7 +1374,7 @@ var Test = { ) ) - var oldLength = L_.layersGroup[layerId].length + var oldLength = L_.layers.layer[layerId].length Test_.mapEvent('click') Test_.fireEvent('mousemove', 300, 300) Test.tool.drawing.polygon.move() @@ -1388,7 +1388,7 @@ var Test = { setTimeout(function () { c( 'Draws polygon off', - L_.layersGroup[layerId].length == oldLength + 1 + L_.layers.layer[layerId].length == oldLength + 1 ) $("#drawToolDrawSettingsTier > div[value='over']").click() @@ -1399,7 +1399,7 @@ var Test = { ).hasClass('active') ) - oldLength = L_.layersGroup[layerId].filter(Boolean).length + oldLength = L_.layers.layer[layerId].filter(Boolean).length Test_.mapEvent('click') Test_.fireEvent('mousemove', 300, 300) Test.tool.drawing.polygon.move() @@ -1413,7 +1413,7 @@ var Test = { setTimeout(function () { c( 'Draws polygon over', - L_.layersGroup[layerId].filter(Boolean).length == + L_.layers.layer[layerId].filter(Boolean).length == oldLength + 1 ) @@ -1428,7 +1428,7 @@ var Test = { ) oldLength = - L_.layersGroup[layerId].filter(Boolean).length + L_.layers.layer[layerId].filter(Boolean).length Test_.mapEvent('click') Test_.fireEvent('mousemove', 300, 300) Test.tool.drawing.polygon.move() @@ -1442,7 +1442,7 @@ var Test = { setTimeout(function () { c( 'Draws polygon under', - L_.layersGroup[layerId].filter(Boolean) + L_.layers.layer[layerId].filter(Boolean) .length == oldLength + 1 ) @@ -1466,7 +1466,7 @@ var Test = { $('.drawToolDrawingTypeLine').hasClass('active') ) - var oldLength = L_.layersGroup[layerId].filter(Boolean).length + var oldLength = L_.layers.layer[layerId].filter(Boolean).length Test_.mapEvent('click') Test_.fireEvent('mousemove', 300, 300) Test.tool.drawing.line.move() @@ -1478,7 +1478,7 @@ var Test = { setTimeout(function () { c( 'Draw and save a line', - L_.layersGroup[layerId].filter(Boolean).length == + L_.layers.layer[layerId].filter(Boolean).length == oldLength + 1 ) @@ -1643,7 +1643,7 @@ var Test = { ).click() let layerId = 'DrawTool_7' let oldLength = - L_.layersGroup[layerId].filter(Boolean).length + L_.layers.layer[layerId].filter(Boolean).length Test_.mapEvent('click') Test_.fireEvent('mousemove', 300, 300) Test.tool.drawing.polygon.move() @@ -1657,7 +1657,7 @@ var Test = { setTimeout(function () { c( 'Draws a new polygon for merging', - L_.layersGroup[layerId].filter(Boolean).length == + L_.layers.layer[layerId].filter(Boolean).length == oldLength + 1 ) Test.tool.showContent('draw') @@ -1724,7 +1724,7 @@ var Test = { ) var oldLength = - L_.layersGroup['DrawTool_1'].filter(Boolean).length + L_.layers.layer['DrawTool_1'].filter(Boolean).length Test_.mapEvent('click') Test_.fireEvent('mousemove', 300, 300) Test.tool.drawing.polygon.move() @@ -1738,7 +1738,7 @@ var Test = { setTimeout(function () { c( 'Draws and saves a Lead ROI', - L_.layersGroup['DrawTool_1'].filter(Boolean).length == + L_.layers.layer['DrawTool_1'].filter(Boolean).length == oldLength + 1 ) }, Test.timeout) @@ -1756,7 +1756,7 @@ var Test = { $('.drawToolDrawingTypePolygon').hasClass('active') ) var oldLength = - L_.layersGroup['DrawTool_2'].filter(Boolean).length + L_.layers.layer['DrawTool_2'].filter(Boolean).length Test_.mapEvent('click') Test_.fireEvent('mousemove', 300, 300) Test.tool.drawing.polygon.move() @@ -1770,7 +1770,7 @@ var Test = { setTimeout(function () { c( 'Draws and saves a Lead Campaign', - L_.layersGroup['DrawTool_2'].filter(Boolean).length == + L_.layers.layer['DrawTool_2'].filter(Boolean).length == oldLength + 1 ) @@ -1787,7 +1787,7 @@ var Test = { setTimeout(function () { c( 'Draws and saves another Lead Campaign', - L_.layersGroup['DrawTool_2'].filter(Boolean) + L_.layers.layer['DrawTool_2'].filter(Boolean) .length == oldLength + 2 ) @@ -1807,7 +1807,7 @@ var Test = { $('.drawToolDrawingTypePolygon').hasClass('active') ) var oldLength = - L_.layersGroup['DrawTool_3'].filter(Boolean).length + L_.layers.layer['DrawTool_3'].filter(Boolean).length Test_.mapEvent('click') Test_.fireEvent('mousemove', 300, 300) Test.tool.drawing.polygon.move() @@ -1821,7 +1821,7 @@ var Test = { setTimeout(function () { c( 'Draws and saves a Lead Campsite', - L_.layersGroup['DrawTool_3'].filter(Boolean).length == + L_.layers.layer['DrawTool_3'].filter(Boolean).length == oldLength + 1 ) }, Test.timeout) @@ -1839,7 +1839,7 @@ var Test = { $('.drawToolDrawingTypeLine').hasClass('active') ) var oldLength = - L_.layersGroup['DrawTool_4'].filter(Boolean).length + L_.layers.layer['DrawTool_4'].filter(Boolean).length Test_.mapEvent('click') Test_.fireEvent('mousemove', 300, 300) Test.tool.drawing.line.move() @@ -1851,7 +1851,7 @@ var Test = { setTimeout(function () { c( 'Draws and saves a Lead Trail', - L_.layersGroup['DrawTool_4'].filter(Boolean).length == + L_.layers.layer['DrawTool_4'].filter(Boolean).length == oldLength + 1 ) }, Test.timeout) @@ -1869,13 +1869,13 @@ var Test = { $('.drawToolDrawingTypePoint').hasClass('active') ) var oldLength = - L_.layersGroup['DrawTool_5'].filter(Boolean).length + L_.layers.layer['DrawTool_5'].filter(Boolean).length Test.tool.drawing.point.shape = { lat: -4.45, lng: 137.45 } Test_.mapEvent('draw:drawstop') setTimeout(function () { c( 'Draws and saves a Lead Signpost', - L_.layersGroup['DrawTool_5'].filter(Boolean).length == + L_.layers.layer['DrawTool_5'].filter(Boolean).length == oldLength + 1 ) @@ -1887,7 +1887,7 @@ var Test = { setTimeout(function () { c( 'Draws and saves another Lead Signpost', - L_.layersGroup['DrawTool_5'].filter(Boolean) + L_.layers.layer['DrawTool_5'].filter(Boolean) .length == oldLength + 2 ) diff --git a/src/essence/Tools/Draw/DrawTool_Drawing.js b/src/essence/Tools/Draw/DrawTool_Drawing.js index 35369b61..96e30c45 100644 --- a/src/essence/Tools/Draw/DrawTool_Drawing.js +++ b/src/essence/Tools/Draw/DrawTool_Drawing.js @@ -68,7 +68,7 @@ var Drawing = { //Then modify the ones it overlapped var bb = turf.bbox(d.shape) - var lg = L_.layersGroup['DrawTool_' + DrawTool.currentFileId] + var lg = L_.layers.layer['DrawTool_' + DrawTool.currentFileId] throughLoop(0) function throughLoop(i) { @@ -202,7 +202,7 @@ var Drawing = { drawUnder: function (d) { //Modify shape based on intersecting features var bb = turf.bbox(d.shape) - var lg = L_.layersGroup['DrawTool_' + DrawTool.currentFileId] + var lg = L_.layers.layer['DrawTool_' + DrawTool.currentFileId] for (var i = 0; i < lg.length; i++) { if (lg[i] == null) continue @@ -1562,7 +1562,7 @@ var drawing = { " blackTextBorder' layer='" + DrawTool.currentFileId + "' index='" + - L_.layersGroup[ + L_.layers.layer[ 'DrawTool_' + DrawTool.currentFileId ].length + "'></div>" + @@ -1577,7 +1577,7 @@ var drawing = { data.id ).text(shape.properties.name) - L_.layersGroup[ + L_.layers.layer[ 'DrawTool_' + DrawTool.currentFileId ].push(popup) @@ -1611,7 +1611,7 @@ var drawing = { $('.drawToolAnnotation').on('click', function () { var layer = 'DrawTool_' + $(this).attr('layer') var index = $(this).attr('index') - var shape = L_.layersGroup[layer][index] + var shape = L_.layers.layer[layer][index] if (!mmgisglobal.shiftDown) { if (typeof shape.getBounds === 'function') Map_.map.fitBounds(shape.getBounds()) @@ -1622,10 +1622,10 @@ var drawing = { }) var l = - L_.layersGroup[ + L_.layers.layer[ 'DrawTool_' + DrawTool.currentFileId ][ - L_.layersGroup[ + L_.layers.layer[ 'DrawTool_' + DrawTool.currentFileId ].length - 1 ] diff --git a/src/essence/Tools/Draw/DrawTool_Editing.js b/src/essence/Tools/Draw/DrawTool_Editing.js index 9ff19d47..dd3e65a8 100644 --- a/src/essence/Tools/Draw/DrawTool_Editing.js +++ b/src/essence/Tools/Draw/DrawTool_Editing.js @@ -5,8 +5,11 @@ import LayerGeologic from '../../Basics/Layers_/LayerGeologic/LayerGeologic' import Globe_ from '../../Basics/Globe_/Globe_' import Map_ from '../../Basics/Map_/Map_' import UserInterface_ from '../../Basics/UserInterface_/UserInterface_' +import CursorInfo from '../../Ancillary/CursorInfo' import turf from 'turf' +import DrawTool_Templater from './DrawTool_Templater' + import calls from '../../../pre/calls' var DrawTool = null @@ -56,6 +59,8 @@ var Editing = { return } + let templater + //ctrl does lots. Here, if ctrl is pressed, check whether the layer is already selected. // If it is, remove it var deselecting = false @@ -135,7 +140,7 @@ var Editing = { } var shape = layer - if (index != null) shape = L_.layersGroup[shape][index] + if (index != null) shape = L_.layers.layer[shape][index] //Disable editing the previous drawing layer if it was being if (!displayOnly) { if (DrawTool.contextMenuLayer) { @@ -296,8 +301,8 @@ var Editing = { properties.style = properties.style || {} style = properties.style || {} let fallbackStyle = {} - if (kindLayerName && L_.layersStyles[kindLayerName]) - fallbackStyle = L_.layersStyles[kindLayerName] + if (kindLayerName && L_.layers.data[kindLayerName]?.style) + fallbackStyle = L_.layers.data[kindLayerName].style //Set blank styles to style.color = style.color || fallbackStyle.color || 'black' @@ -410,8 +415,8 @@ var Editing = { properties.style = properties.style || {} style = properties.style || {} let fallbackStyle = {} - if (kindLayerName && L_.layersStyles[kindLayerName]) - fallbackStyle = L_.layersStyles[kindLayerName] + if (kindLayerName && L_.layers.data[kindLayerName].style) + fallbackStyle = L_.layers.data[kindLayerName].style //Set blank styles to style.color = style.color || fallbackStyle.color || 'black' style.opacity = @@ -484,7 +489,6 @@ var Editing = { ) ) } - //console.log( JSON.parse(JSON.stringify(DrawTool.contextMenuLayer.feature)) ); if ( reenableEdit && @@ -517,19 +521,26 @@ var Editing = { if (displayOnly) ownedByUser = false else { for (var i = 0; i < DrawTool.contextMenuLayers.length; i++) { + const cfile = DrawTool.contextMenuLayers[i].file + const isListEdit = + file.public == '1' && + file.publicity_type == 'list_edit' && + typeof file.public_editors?.includes === 'function' && + (file.public_editors.includes(mmgisglobal.user) || + ownedByUser) + const isAllEdit = + file.public == '1' && file.publicity_type == 'all_edit' + if ( - DrawTool.contextMenuLayers[i].file.file_owner == 'master' || - (mmgisglobal.user !== - DrawTool.contextMenuLayers[i].file.file_owner && - (DrawTool.contextMenuLayers[i].file.file_owner_group == - null || - (DrawTool.contextMenuLayers[i].file - .file_owner_group && - F_.diff( - DrawTool.contextMenuLayers[i].file - .file_owner_group, - DrawTool.userGroups - ).length == 0))) + (cfile.file_owner == 'master' || + (mmgisglobal.user !== cfile.file_owner && + (cfile.file_owner_group == null || + (cfile.file_owner_group && + F_.diff( + cfile.file_owner_group, + DrawTool.userGroups + ).length == 0)))) && + !(isListEdit || isAllEdit) ) ownedByUser = false } @@ -591,37 +602,59 @@ var Editing = { "<div class='drawToolContextMenuTab drawToolContextMenuTabProperties'>", "<div class='drawToolContextMenuProperties'>", "<div class='drawToolContextMenuPropertiesName flexbetween'>", - "<div>Name</div>", + "<div class='drawToolContextMenuPropertiesTitle'>Name</div>", "<input id='drawToolContextMenuPropertiesName' type='text' value='" + F_.sanitize(defaultName) + "'/>", "</div>", "<div class='drawToolContextMenuPropertiesDescription flexbetween'>", - "<div>Description</div>", - "<textarea id='drawToolContextMenuPropertiesDescription' rows='10'></textarea>", + "<div class='drawToolContextMenuPropertiesTitle'>Description</div>", + "<textarea id='drawToolContextMenuPropertiesDescription' rows='2'></textarea>", "</div>", - (hasLengthMetric) ? [ - "<div class='flexbetween' style='margin: 4px 0px;'>", - "<div>Length</div>", - `<div>${F_.getFeatureLength(DrawTool.contextMenuLayer.feature, true)}</div>`, - "</div>", - ].join('\n') : "", - (hasPerimeterMetric) ? [ - "<div class='flexbetween' style='margin: 4px 0px;'>", - "<div>Perimeter</div>", - `<div>${F_.getFeatureLength(DrawTool.contextMenuLayer.feature, true)}</div>`, - "</div>", - ].join('\n') : "", - (hasAreaMetric) ? [ - "<div class='flexbetween' style='margin-bottom: 4px;'>", - "<div>Area</div>", - `<div>${F_.getFeatureArea(DrawTool.contextMenuLayer.feature, true)}</div>`, + (file.template != null ) ? [ + "<div class='drawToolContextMenuPropertiesCollapsible'>", + `<div class='drawToolContextMenuPropertiesTitle'><div>Template (${file.template?.name})</div><i class='mdi mdi-chevron-down mdi-24px'></i></div>`, + "<div id='drawToolContextMenuPropertiesTemplate'></div>", + "</div>"].join('\n') : "", + "<div class='drawToolContextMenuPropertiesCollapsible state-collapsed'>", + "<div class='drawToolContextMenuPropertiesTitle'><div>Metrics</div><i class='mdi mdi-chevron-down mdi-24px'></i></div>", + "<div>", + (hasLengthMetric) ? [ + "<div class='flexbetween' style='margin: 4px 0px;'>", + "<div>Length</div>", + `<div>${F_.getFeatureLength(DrawTool.contextMenuLayer.feature, true)}</div>`, + "</div>", + ].join('\n') : "", + (hasPerimeterMetric) ? [ + "<div class='flexbetween' style='margin: 4px 0px;'>", + "<div>Perimeter</div>", + `<div>${F_.getFeatureLength(DrawTool.contextMenuLayer.feature, true)}</div>`, + "</div>", + ].join('\n') : "", + (hasAreaMetric) ? [ + "<div class='flexbetween' style='margin-bottom: 4px;'>", + "<div>Area</div>", + `<div>${F_.getFeatureArea(DrawTool.contextMenuLayer.feature, true)}</div>`, + "</div>", + ].join('\n') : "", + (DrawTool.contextMenuLayer?.feature?.properties?._radius != null) ? [ + "<div class='flexbetween' style='margin-bottom: 4px;'>", + "<div>Radius</div>", + `<div>${DrawTool.contextMenuLayer.feature.properties._radius.toFixed(3)}m</div>`, + "</div>", + ].join('\n') : "", "</div>", - ].join('\n') : "", - (DrawTool.contextMenuLayer?.feature?.properties?._radius != null) ? [ - "<div class='flexbetween' style='margin-bottom: 4px;'>", - "<div>Radius</div>", - `<div>${DrawTool.contextMenuLayer.feature.properties._radius.toFixed(3)}m</div>`, + "</div>", + "<div class='drawToolContextMenuPropertiesCollapsible'>", + "<div class='drawToolContextMenuPropertiesTitle'><div>Properties</div><i class='mdi mdi-chevron-down mdi-24px'></i></div>", + "<div class='drawToolContextMenuPropertiesExtended'>", + Object.keys(DrawTool.contextMenuLayer.feature.properties).map((p) => { + const pv = DrawTool.contextMenuLayer.feature.properties[p] + if(p === 'uuid') return '' + if( typeof pv === 'number' || typeof pv === 'string' || typeof pv === 'boolean') + return `<li><div>${p}</div><div>${pv}</div></li>` + else return '' + }).join('\n'), "</div>", - ].join('\n') : "", + "</div>", (!displayOnly) ? ["<div class='drawToolContextMenuPropertiesReassignUUID flexbetween'>", "<div id='drawToolContextMenuPropertiesReassignUUIDValue'>" + uuid + "</div>", "<div id='drawToolContextMenuPropertiesReassignUUID' class='drawToolButton1'>Reassign</div>", @@ -843,6 +876,17 @@ var Editing = { ].join('\n'); $('#uiRightPanel').empty() $('#uiRightPanel').append(markup) + + templater = DrawTool_Templater.renderTemplate( + 'drawToolContextMenuPropertiesTemplate', + file.template, + DrawTool.contextMenuLayer?.feature?.properties + ) + $( + `.drawToolContextMenuPropertiesCollapsible > .drawToolContextMenuPropertiesTitle` + ).on('click', function () { + $(this).parent().toggleClass('state-collapsed') + }) UserInterface_.openRightPanel(360) $('#drawToolContextMenuPropertiesDescription').text(description) @@ -920,7 +964,7 @@ var Editing = { !displayOnly && l != null && l.hasOwnProperty('l_i_f') && - L_.layersGroup[l.l_i_f.layer][l.l_i_f.index] != null + L_.layers.layer[l.l_i_f.layer][l.l_i_f.index] != null ) { //Properties //Style @@ -965,7 +1009,7 @@ var Editing = { !displayOnly && l != null && l.hasOwnProperty('l_i_f') && - L_.layersGroup[l.l_i_f.layer][l.l_i_f.index] != null && + L_.layers.layer[l.l_i_f.layer][l.l_i_f.index] != null && l.properties.arrow == true ) { L_.addArrowToMap( @@ -1063,7 +1107,7 @@ var Editing = { } DrawTool.removeDrawing(body, function () { Map_.rmNotNull(DrawTool.contextMenuLayer) - L_.layersGroup[DrawTool.lastContextLayerIndexFileId.layer][ + L_.layers.layer[DrawTool.lastContextLayerIndexFileId.layer][ DrawTool.lastContextLayerIndexFileId.index ] = null @@ -2222,7 +2266,6 @@ var Editing = { {} DrawTool.contextMenuLayer.snapediting.enable() } catch (e) { - console.log(e) DrawTool.contextMenuLayer.enableEdit() } } else { @@ -2291,7 +2334,17 @@ var Editing = { if (DrawTool.isReviewOpen) DrawTool.showReview() }, - function () { + function (err) { + CursorInfo.update( + `${err.message}${ + err.body?.error + ? ` - ${err.body.error}` + : '' + }`, + 6000, + true, + { x: 305, y: 6 } + ) $('.drawToolContextMenuSave').css( 'background', '#ff2626' @@ -2313,6 +2366,16 @@ var Editing = { if (DrawTool.plugins?.Geologic?.custom?.resetGeologic) DrawTool.plugins.Geologic.custom.resetGeologic() + let templaterProperties = {} + if (templater) { + templaterProperties = templater.getValues( + L_.layers.layer[DrawTool.lastContextLayerIndexFileId.layer], + properties, + grouping ? true : false + ) + if (templaterProperties === false) return + } + if (!grouping) { //Then just a regular single save if (typeof DrawTool.contextMenuLayer.toGeoJSON === 'function') @@ -2333,12 +2396,14 @@ var Editing = { DrawTool.contextMenuLayer._latlng ) - var newProperties = properties + let newProperties = properties newProperties.style = properties.style || {} setProperties(newProperties) - var newGeometry + newProperties = { ...newProperties, ...templaterProperties } + + let newGeometry if (featureType != 'note' && featureType != 'arrow') { newGeometry = DrawTool.contextMenuLayer.toGeoJSON( L_.GEOJSON_PRECISION @@ -2414,7 +2479,17 @@ var Editing = { if (DrawTool.isReviewOpen) DrawTool.showReview() } })(newProperties, newGeometry, featureType, fileid), - function () { + function (err) { + CursorInfo.update( + `${err.message}${ + err.body?.error + ? ` - ${err.body.error}` + : '' + }`, + 6000, + true, + { x: 305, y: 6 } + ) $('.drawToolContextMenuSave').css( 'background', '#ff2626' @@ -2451,6 +2526,11 @@ var Editing = { setProperties(newProperties) + newProperties = { + ...newProperties, + ...templaterProperties, + } + calls.api( 'draw_edit', { @@ -2477,7 +2557,17 @@ var Editing = { }, 2) } })(l, l.file.id, l.properties._.id, newProperties), - function () { + function (err) { + CursorInfo.update( + `${err.message}${ + err.body?.error + ? ` - ${err.body.error}` + : '' + }`, + 6000, + true, + { x: 305, y: 6 } + ) $('.drawToolContextMenuSave').css( 'background', '#ff2626' @@ -2640,7 +2730,7 @@ var Editing = { getSnapGuides: function (layer) { var guides = [] for (var j = 0; j < DrawTool.filesOn.length; j++) { - for (var e of L_.layersGroup['DrawTool_' + DrawTool.filesOn[j]]) + for (var e of L_.layers.layer['DrawTool_' + DrawTool.filesOn[j]]) if (e != null) { var l = e if (l.hasOwnProperty('_layers')) diff --git a/src/essence/Tools/Draw/DrawTool_FileModal.css b/src/essence/Tools/Draw/DrawTool_FileModal.css new file mode 100644 index 00000000..69ff0e33 --- /dev/null +++ b/src/essence/Tools/Draw/DrawTool_FileModal.css @@ -0,0 +1,182 @@ +.drawToolFileModal { + min-width: 615px; + color: var(--color-f); + background: var(--color-a); + box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.5); + border-radius: 2px; + margin: 30px 120px 100px 120px; + max-height: 80vh; + font-size: 14px; +} +.drawToolFileModal .drawToolButton1 { + padding: 5px 12px; +} + +.drawToolFileModal input[type='text'], +.drawToolFileModal input[type='number'] { + flex: 1 1; + border: none; + padding: 0px 8px; + font-size: 14px; + height: 30px; + width: 100%; + background: var(--color-a1-5); + color: var(--color-a7); +} +#drawToolFileModalHeading { + display: flex; + justify-content: space-between; + height: 42px; + padding: 8px 10px 0px 10px; + margin-bottom: 8px; + position: relative; + background: var(--color-a1); + border-bottom: 1px solid var(--color-a); +} +#drawToolFileModalHeadingName { + font-size: 18px; + line-height: 26px; + padding-left: 4px; +} +#drawToolFileModalHeading > div { + display: flex; + padding: 0px; +} +#drawToolFileModalBody { +} +#drawToolFileModalBody > div { + margin-bottom: 16px; +} + +#drawToolFileModalBodyName { + padding: 0px 12px; + flex: 1; +} +#drawToolFileModalBodyName > div { + line-height: 30px; + color: var(--color-blue); +} +#drawToolFileModelUploadedFrom { + color: var(--color-p0); + font-size: 14px; + text-align: center; +} +#drawToolFileModalBodyTemplate { + padding: 0px 12px; + flex: 1; +} +#drawToolFileModalBodyTemplate > div { + display: flex; +} +#drawToolFileModalBodyTemplate > div > i { + margin: 0px 4px; +} +#drawToolFileModalBodyTemplate > div:first-child { + padding-right: 8px; + line-height: 30px; + color: var(--color-blue); +} +#drawToolFileModalBodyTemplate > div > span { + margin: 0px 10px; + line-height: 30px; +} + +#drawToolFileModalTemplateDropdown { + flex: 1; + height: 30px; + background: var(--color-a1-5); +} +#drawToolFileModalTemplateDropdown .dropy { + margin-bottom: 0; +} +#drawToolFileModalTemplateDropdown .dropy__title { + line-height: 11px; + font-size: 14px; +} +#drawToolFileModalTemplateDropdown .dropy__title > i { + transform: translateY(30%); +} +#drawToolFileModalTemplateNew { + width: 72px; + margin: 0px; + height: 30px; + line-height: 22px; + font-size: 13px; + background: var(--color-a1); + transition: background 0.2s ease-in-out; +} +#drawToolFileModalTemplateNew:hover { + background: var(--color-a2); +} +#drawToolFileModalActions { + display: flex; + padding: 2px 10px; + justify-content: space-between; + background: var(--color-a1); + border-top: 1px solid var(--color-a); +} +#drawToolFileModalActionsCancel { + background: var(--color-a1); +} + +#drawToolFileUpload { + visibility: hidden; + pointer-events: none; + position: relative; + top: -4px; + font-size: 12px; + width: 74px; + padding: 0px 8px; + cursor: pointer; + height: 30px; + background: var(--color-a1-5); + color: var(--color-a5); + box-sizing: border-box; + line-height: 30px; + text-align: center; + transition: background 0.2s ease-out; +} +#drawToolFileUpload:hover { + color: var(--color-a7); + background: var(--color-a2); +} +#drawToolFileUpload i { + cursor: pointer; + pointer-events: none; +} +#drawToolFileUpload input { + cursor: pointer; + position: absolute; + left: 0px; + top: 0px; + opacity: 0; + height: 30px; + width: 68px; +} + +#drawToolDrawFilesNewLoading { + width: 100%; + height: 3px; + position: absolute; + bottom: -3px; + left: 0px; + overflow: hidden; + opacity: 0; + transition: opacity 0.1s cubic-bezier(0.445, 0.05, 0.55, 0.95); +} +#drawToolDrawFilesNewLoading > div { + width: 30%; + height: 100%; + background: var(--color-c); + animation: drawToolLoading1 1s ease-in-out infinite; +} +@keyframes drawToolLoading1 { + 0% { + transform: translateX(-100%); + width: 30%; + } + 100% { + transform: translateX(230%); + width: 60%; + } +} diff --git a/src/essence/Tools/Draw/DrawTool_FileModal.js b/src/essence/Tools/Draw/DrawTool_FileModal.js new file mode 100644 index 00000000..8f579164 --- /dev/null +++ b/src/essence/Tools/Draw/DrawTool_FileModal.js @@ -0,0 +1,417 @@ +import $ from 'jquery' +import * as d3 from 'd3' +import F_ from '../../Basics/Formulae_/Formulae_' +import L_ from '../../Basics/Layers_/Layers_' + +import CursorInfo from '../../Ancillary/CursorInfo' +import Modal from '../../Ancillary/Modal' +import Dropy from '../../../external/Dropy/dropy' +import tippy from 'tippy.js' +import shp from '../../../external/shpjs/shapefile' +import shpwrite from '../../../external/SHPWrite/shpwrite' + +import DrawTool_Templater from './DrawTool_Templater' + +import './DrawTool_FileModal.css' + +const DrawTool_FileModal = { + newFileModalTemplateIndex: 0, + newFileModal: function (DrawTool, cb) { + // prettier-ignore + const modalContent = [ + "<div class='drawToolFileModal'>", + "<div id='drawToolFileModalHeading'>", + "<div>", + "<i class='mdi mdi-file-plus mdi-24px'></i>", + "<div id='drawToolFileModalHeadingName'>", + "New File", + "</div>", + "</div>", + "<div id='drawToolFileUpload'>", + "Upload", + "<i class='mdi mdi-upload mdi-18px'></i>", + "<input title='Upload' type=file accept='.json, .geojson, .rksml, .shp, .dbf' multiple>", + "</div>", + "<div id='drawToolDrawFilesNewLoading'><div></div></div>", + "</div>", + "<div id='drawToolFileModalBody'>", + "<div class='flexbetween'>", + "<div id='drawToolFileModalBodyName'>", + "<div><div>File Name</div></div>", + "<input class='drawToolFileModalName' placeholder='Enter a new filename' type='text' value=''></input>", + "</div>", + "<div id='drawToolFileModalBodyTemplate'>", + "<div>Property Template<i id='drawToolFileModalBodyTemplateInfo' class='mdi mdi-information mdi-14px'></i></div>", + "<div>", + "<div id='drawToolFileModalTemplateDropdown' class='ui dropdown short'></div>", + "<span>or</span>", + "<div id='drawToolFileModalTemplateNew' class='drawToolButton1'>NEW</div>", + "</div>", + "</div>", + "</div>", + "<div id='drawToolFileModelUploadedFrom'></div>", + "<div id='drawToolFileModalTemplateContainer'></div>", + "</div>", + "<div id='drawToolFileModalActions'>", + "<div id='drawToolFileModalActionsCancel' class='drawToolButton1'>Cancel</div>", + "<div id='drawToolFileModalActionsCreate' class='drawToolButton1'>CREATE</div>", + "</div>", + "</div>" + ].join('\n') + const templates = DrawTool.vars.templates || {} + + let allTemplates = {} + if (DrawTool.files) { + DrawTool.files.forEach((f) => { + if ( + f.template != null && + f.template.name != null && + f.template.template != null + ) { + allTemplates[f.template.name] = f.template.template + } + }) + } + + const templateItems = ['NONE'] + .concat(Object.keys(templates)) + .concat(Object.keys(allTemplates).sort()) + + allTemplates = { + ...allTemplates, + ...JSON.parse(JSON.stringify(templates || {})), + } + + let body = false + Modal.remove() + Modal.set(modalContent, function () { + tippy('#drawToolFileModalBodyTemplateInfo', { + content: `Assign a form to this file that each feature's properties must conform to.`, + placement: 'right', + theme: 'blue', + }) + + //Upload + $('#drawToolFileUpload > input').on('change', function (evt) { + $('#drawToolDrawFilesNewLoading').css('opacity', '1') + $('#drawToolFileUpload > i').css('color', '#1169d3') + + var files = evt.target.files // FileList object + + // use the 1st file from the list + var f = files[0] + var ext = F_.getExtension(f.name).toLowerCase() + switch (ext) { + case 'shp': + case 'dbf': + var shpFile + var dbfFile + for (var i = 0; i < files.length; i++) { + if ( + F_.getExtension(files[i].name).toLowerCase() == + 'shp' + ) + shpFile = files[i] + if ( + F_.getExtension(files[i].name).toLowerCase() == + 'dbf' + ) + dbfFile = files[i] + } + if (shpFile && dbfFile) { + var shpBuffer + var dbfBuffer + + var readerSHP = new FileReader() + readerSHP.onload = function (e) { + shpBuffer = e.target.result + var readerDBF = new FileReader() + readerDBF.onload = function (e) { + dbfBuffer = e.target.result + bothLoaded() + } + readerDBF.readAsArrayBuffer(dbfFile) + } + readerSHP.readAsArrayBuffer(shpFile) + + function bothLoaded() { + var featureArray = [] + shp.open(shpBuffer, dbfBuffer) + .then((source) => + source + .read() + .then(function log(result) { + if (result.done) { + var geojsonResult = + F_.getBaseGeoJSON() + geojsonResult.features = + featureArray + body = { + file_name: f.name, + intent: 'all', + geojson: + JSON.stringify( + geojsonResult + ), + } + uploaded(body, f) + return + } + + featureArray.push( + F_.geoJSONFeatureMetersToDegrees( + result.value + ) + ) + return source.read().then(log) + }) + ) + .catch((error) => { + endLoad() + }) + } + } else { + CIU('Warning! FileManager - missing .shp or .dbf') + } + break + case 'json': + case 'geojson': + var reader = new FileReader() + // Closure to capture the file information. + + reader.onload = (function (file) { + return function (e) { + body = { + file_name: file.name, + intent: 'all', + geojson: e.target.result, + } + if ( + body.geojson && + JSON.parse(body.geojson).type !== + 'FeatureCollection' + ) { + CIU( + 'Uploaded object has no type: "FeatureCollection". Are you sure this is geojson?' + ) + return + } + uploaded(body, file) + } + })(f) + + // Read in the image file as a data URL. + reader.readAsText(f) + break + case 'rksml': + const readerRKSML = new FileReader() + // Closure to capture the file information. + + readerRKSML.onload = (function (file) { + return function (e) { + let rksmlBody = { + to: 'geojson', + abbreviated: true, + rksml: e.target.result, + } + + $.ajax({ + type: 'POST', + url: `${ + window.mmgisglobal.ROOT_PATH + ? window.mmgisglobal.ROOT_PATH + '/' + : '' + }API/rksml/convert`, + data: rksmlBody, + xhrFields: { + withCredentials: true, + }, + success: function (data) { + if ( + data && + data.type !== 'FeatureCollection' + ) { + CIU( + 'RKSML failed to convert into GeoJSON.' + ) + return + } + + body = { + file_name: file.name, + intent: 'all', + geojson: JSON.stringify(data), + } + + uploaded(body, file) + }, + error: function () { + endLoad() + }, + }) + } + })(f) + + // Read in the image file as a data URL. + readerRKSML.readAsText(f) + break + default: + CIU( + 'Only .json, .geojson, .rksml and .shp (with .dbf) files may be uploaded' + ) + } + + function uploaded(body, file) { + $('#drawToolFileModelUploadedFrom').text( + `Uploaded from: ${body.file_name} (${F_.humanFileSize( + file.size + )})` + ) + $('.drawToolFileModalName').val( + (body.file_name || '').replace(/\.[^/.]+$/, '') + ) + if (body?.geojson) { + try { + const geojson = JSON.parse(body.geojson) + const templateFromThisFeature = + geojson.features[0] || null + DrawTool_Templater.renderDesignTemplate( + 'drawToolFileModalTemplateContainer', + null, + true, + templateFromThisFeature + ) + } catch (err) {} + } + endLoad() + } + + function endLoad() { + $('#drawToolDrawFilesNewLoading').css('opacity', '0') + $('#drawToolFileUpload > i').css('color', 'unset') + } + function CIU(message) { + CursorInfo.update( + message, + 6000, + true, + { x: 305, y: 6 }, + '#e9ff26', + 'black' + ) + endLoad() + } + }) + + DrawTool_FileModal.newFileModalTemplateIndex = 0 + $('#drawToolFileModalTemplateDropdown').html( + Dropy.construct( + templateItems, + 'Templates', + DrawTool_FileModal.newFileModalTemplateIndex, + { + openUp: false, + dark: true, + } + ) + ) + Dropy.init($('#drawToolFileModalTemplateDropdown'), function (idx) { + DrawTool_FileModal.newFileModalTemplateIndex = idx + + DrawTool_Templater.renderDesignTemplate( + 'drawToolFileModalTemplateContainer', + { + name: templateItems[idx], + template: allTemplates[templateItems[idx]], + } + ) + }) + + $('#drawToolFileModalTemplateNew').on('click', function () { + DrawTool_Templater.renderDesignTemplate( + 'drawToolFileModalTemplateContainer' + ) + }) + + $('#drawToolFileModalActionsCreate').on('click', function () { + const val = $('.drawToolFileModalName').val() + const intent = 'all' + //templateItems[DrawTool_FileModal.newFileModalTemplateIndex] + if (val == null || val === '') { + CursorInfo.update( + 'Please enter a file name.', + 6000, + true, + { x: 305, y: 6 }, + '#e9ff26', + 'black' + ) + return + } + if (/[&\'\"<>]/g.test(val)) { + CursorInfo.update( + 'Invalid file name.', + 6000, + true, + { x: 305, y: 6 }, + '#e9ff26', + 'black' + ) + return + } + let chosenTemplate = + templateItems[DrawTool_FileModal.newFileModalTemplateIndex] + if (chosenTemplate === 'NONE') chosenTemplate = null + else { + if (templates[chosenTemplate] != null) + chosenTemplate = JSON.stringify({ + name: chosenTemplate, + template: templates[chosenTemplate], + }) + else chosenTemplate = null + } + + let finalBody + if (body !== false) { + finalBody = body + finalBody.file_name = val || 'New File' + finalBody.template = chosenTemplate + } else + finalBody = { + file_name: val || 'New File', + intent: intent, + template: chosenTemplate, + } + + const designedTemplate = DrawTool_Templater.getDesignedTemplate( + 'drawToolFileModalTemplateContainer', + allTemplates + ) + if (designedTemplate === true) { + // Do nothing and continue; user was not designing a new template + } else if (designedTemplate === false) { + // User was designing, but it had errors + return + } else { + finalBody.template = JSON.stringify(designedTemplate) + } + + DrawTool.makeFile(finalBody, function (file_id) { + DrawTool.populateFiles(file_id) + + Modal.remove() + $('.drawToolFileModalName').val('') + }) + }) + + $('#drawToolFileModalActionsCancel').on('click', function () { + Modal.remove() + $('.drawToolFileModalName').val('') + }) + + if (typeof cb === 'function') cb() + }) + }, +} + +export default DrawTool_FileModal diff --git a/src/essence/Tools/Draw/DrawTool_Files.js b/src/essence/Tools/Draw/DrawTool_Files.js index 5381a2d7..50f51dc5 100644 --- a/src/essence/Tools/Draw/DrawTool_Files.js +++ b/src/essence/Tools/Draw/DrawTool_Files.js @@ -8,6 +8,8 @@ import Map_ from '../../Basics/Map_/Map_' import CursorInfo from '../../Ancillary/CursorInfo' import Modal from '../../Ancillary/Modal' +import DrawTool_Templater from './DrawTool_Templater' + import '../../../external/JQuery/jquery.autocomplete' import calls from '../../../pre/calls' @@ -152,7 +154,7 @@ var Files = { DrawTool.setDrawingType(drawType) } else { CursorInfo.update( - `Please select a file from the list below (by clicking on its name). If none exist, create one with the + above.`, + `Please select a file from the list below (by clicking on its name). If none exist, make one with the create button below.`, 6000, false, { @@ -350,13 +352,21 @@ var Files = { ) ownedByUser = true + const isListEdit = + file.public == '1' && + file.publicity_type == 'list_edit' && + typeof file.public_editors?.includes === 'function' && + (file.public_editors.includes(mmgisglobal.user) || ownedByUser) + const isAllEdit = + file.public == '1' && file.publicity_type == 'all_edit' + // prettier-ignore var markup = [ "<div class='flexbetween' style='height: 30px; line-height: 30px;'>", "<div class='drawToolFileSelector flexbetween' file_id='" + file.id + "' file_owner='" + file.file_owner + "' file_intent='" + file.intent + "'>", "<div class='drawToolIntentColor' style='height: 100%; width: 7px; background: " + DrawTool.categoryStyles[file.intent].color + "'></div>", "<div class='drawToolFileInfo'>", - "<i title='Owned by you!' class='drawToolFileOwner mdi" + ( (ownedByUser) ? ((file.is_master) ? ' mdi-account-tie' : ' mdi-account') : '' ) + " mdi-18px " + ( (ownedByUser) ? 'alwaysShow' : '' ) + "' style='pointer-event: " + ( (ownedByUser) ? 'all' : 'none' ) + "' file_id='" + file.id + "'></i>", + "<i title='Owned by you!' class='drawToolFileOwner mdi" + (file.is_master ? ' mdi-account-tie' : isAllEdit ? ' mdi-account-group' : isListEdit ? ' mdi-account-multiple' : (ownedByUser) ? ' mdi-account' : '' ) + " mdi-18px " + ( (file.is_master || ownedByUser || isAllEdit || isListEdit) ? 'alwaysShow' : '' ) + "' style='pointer-events: " + ( (ownedByUser) ? 'all' : 'none' ) + "' file_id='" + file.id + "'></i>", `<div class='drawToolFileName' title='${file.file_name}\nIntent: ${file.intent}\nAuthor: ${file.file_owner}\nId: ${file.id}\nSelect to draw in,\nInfo button for information,\nCheck-box to toggle on,\nRight-Click for actions'>${file.file_name}</div>`, "</div>", "</div>", @@ -421,11 +431,11 @@ var Files = { } if ( $( - `.drawToolDrawFilesGroupElem[group_name=${g}] .drawToolDrawFilesGroupListElem > .drawToolDrawFilesListElem[file_id=${file.id}]` + `.drawToolDrawFilesGroupElem[group_name="${g}"] .drawToolDrawFilesGroupListElem > .drawToolDrawFilesListElem[file_id="${file.id}"]` ).length === 0 ) { d3.select( - `.drawToolDrawFilesGroupElem[group_name=${g}] .drawToolDrawFilesGroupListElem` + `.drawToolDrawFilesGroupElem[group_name="${g}"] .drawToolDrawFilesGroupListElem` ) .append('li') .attr( @@ -529,27 +539,36 @@ var Files = { hideContextMenu(true) + const fileId = elm.attr('file_id') + const file = DrawTool.getFileObjectWithId(fileId) + + const hasTemplate = file?.template?.template != null + let rect = $(this).get(0).getBoundingClientRect() + // Export GeoJSON + // Export GeoJSON [Forced Template] // prettier-ignore let markup = [ - "<div id='drawToolDrawFilesListElemContextMenu' style='top: " + - (rect.y + rect.height - 1) + - 'px; left: ' + - 40 + - 'px; width: ' + - rect.width + - "px; z-index: 2000; font-size: 14px;'>", - '<ul>', - (!isHead && L_.Coordinates.mainType != 'll') ? `<li id='cmExportGeoJSON' convert='true'><i class='mdi mdi-download mdi-14px'></i>Export GeoJSON (${L_.Coordinates.getMainTypeName()})</li>` : "", - !isHead ? `<li id='cmExportSourceGeoJSON' convert='true'><i class='mdi mdi-download mdi-14px'></i>Export GeoJSON ${L_.Coordinates.mainType != 'll' ? '(lonlat)' : '' }</li>` : "", - //"<li id='cmExportShp'>Export as .shp</li>", - (!isHead && !isPub) ? `<li id='cmToggleLabels'><i class='mdi mdi-label-outline mdi-14px'></i>Toggle Labels</li>` : "", - isHead ? `<li id='drawToolcmRenameTagFol'><i class='mdi mdi-rename-box mdi-14px'></i>Rename ${activeTagFolType === 'tags' ? "Tag" : "Folder"}</li>` : "", - isHead ? `<li id='drawToolcmRemoveTagFol'><i class='mdi mdi-delete-forever mdi-14px'></i>Remove ${activeTagFolType === 'tags' ? "Tag" : "Folder"}</li>` : "", - '</ul>', - '</div>', - ].join('\n') + "<div id='drawToolDrawFilesListElemContextMenu' style='top: " + + (rect.y + rect.height - 1) + + 'px; left: ' + + 40 + + 'px; width: ' + + rect.width + + "px; z-index: 2000; font-size: 14px;'>", + '<ul>', + (!isHead && L_.Coordinates.mainType != 'll') ? `<li id='cmExportGeoJSON' convert='true'><div><i class='mdi mdi-download mdi-14px'></i>Export GeoJSON</div><div>Coords: (${L_.Coordinates.getMainTypeName()})</div></li>` : "", + !isHead ? `<li id='cmExportSourceGeoJSON' convert='true'><div><i class='mdi mdi-download mdi-14px'></i>Export GeoJSON</div><div>${L_.Coordinates.mainType != 'll' ? 'Coords: lonlat' : '' }</div></li>` : "", + (!isHead && hasTemplate && L_.Coordinates.mainType != 'll') ? `<li id='cmExportGeoJSON' convert='true' templateforced='true' title='All feature properties foreign to the template will be removed.'><div><i class='mdi mdi-download mdi-14px'></i>Export GeoJSON</div><div>Restrict to Template</div></li>` : "", + (!isHead && hasTemplate) ? `<li id='cmExportSourceGeoJSON' convert='true' templateforced='true' title='All feature properties foreign to the template will be removed.'><div><i class='mdi mdi-download mdi-14px'></i>Export GeoJSON</div><div>Restrict to Template</div></li>` : "", + //"<li id='cmExportShp'>Export as .shp</li>", + (!isHead && !isPub) ? `<li id='cmToggleLabels'><i class='mdi mdi-label-outline mdi-14px'></i>Toggle Labels</li>` : "", + isHead ? `<li id='drawToolcmRenameTagFol'><i class='mdi mdi-rename-box mdi-14px'></i>Rename ${activeTagFolType === 'tags' ? "Tag" : "Folder"}</li>` : "", + isHead ? `<li id='drawToolcmRemoveTagFol'><i class='mdi mdi-delete-forever mdi-14px'></i>Remove ${activeTagFolType === 'tags' ? "Tag" : "Folder"}</li>` : "", + '</ul>', + '</div>', + ].join('\n') $('body').append(markup) @@ -567,6 +586,7 @@ var Files = { (function (body, isPub) { return function () { const convert = $(this).attr('convert') + const templateForced = $(this).attr('templateforced') DrawTool.getFile(body, function (d) { let geojson = d.geojson let filename = '' @@ -615,6 +635,11 @@ var Files = { L_.convertGeoJSONLngLatsToPrimaryCoordinates( geojson ) + geojson = DrawTool.enforceTemplate( + geojson, + d?.file?.[0]?.template, + templateForced + ) F_.downloadObject(geojson, filename, '.geojson') }) } @@ -922,20 +947,30 @@ var Files = { "<div>", `<div id="drawToolFileEditOnHeadingOwner">by ${file.file_owner}${ownedByUser ? ' (you)' : ''}</div>`, "<select id='drawToolFileEditOnPublicityDropdown' class='ui dropdown dropdown_2 unsetMaxWidth'>", - `<option value='public' ${file.public == '1' ? 'selected' : ''}>Public</option>`, - `<option value='private' ${file.public != '1' ? 'selected' : ''}>Private</option>`, + `<option value='private' ${file.public == '0' ? 'selected' : ''}>Private</option>`, + `<option value='public read_only' ${file.public == '1' && file.publicity_type != 'list_edit' && file.publicity_type != 'all_edit' ? 'selected' : ''}>Public - Read-Only</option>`, + `<option value='public list_edit' ${file.public == '1' && file.publicity_type == 'list_edit' ? 'selected' : ''}>Public - List-Editors</option>`, + `<option value='public all_edit' ${file.public == '1' && file.publicity_type == 'all_edit' ? 'selected' : ''}>Public - All-Edit</option>`, "</select>", "</div>", "</div>", + `<div class='drawToolFileEditListEditors' style='display: ${file.public == '1' && file.publicity_type == 'list_edit' ? 'flex' : 'none'}'>`, + "<div>File Editors:</div>", + `<input id='drawToolFileEditListEditors' type='text' placeholder='Comma-separated names of users who can edit this file...' value='${file.public_editors && typeof file.public_editors.join === 'function' ? file.public_editors.join(',') : ''}'></input>`, + "</div>", "<div class='drawToolFileEditOnDates'>", "<div>", "<div>Created:</div>", `<div>${file.created_on.split('T')[0]}</div>`, "</div>", "<div>", - "<div>Last Modified:</div>", + "<div>Modified:</div>", `<div>${file.updated_on.split('T')[0]}</div>`, "</div>", + "<div class='drawToolFileTemplate' id='drawToolFileTemplateEdit'>", + "<div>Template:</div>", + `<div><div>${file.template?.name || 'NONE'}</div><i class='mdi mdi-pencil mdi-14px'></i></div>`, + "</div>", "</div>", "<div class='drawToolFileEditOnDescription'>", "<textarea class='drawToolFileDesc' rows='9' placeholder='Description...'>" + DrawTool.stripTagsFromDescription(file.file_description) + "</textarea>", @@ -973,6 +1008,8 @@ var Files = { "</div>" ].join('\n') + let template = file.template || null + // prettier-ignore const modalContent = [ "<div class='drawToolFileEditOn' file_id='" + fileId + "' file_owner='" + file.file_owner + "' file_name='" + file.file_name + "'>", @@ -993,9 +1030,13 @@ var Files = { `<div>${file.created_on.split('T')[0]}</div>`, "</div>", "<div>", - "<div>Last Modified:</div>", + "<div>Modified:</div>", `<div>${file.updated_on.split('T')[0]}</div>`, "</div>", + "<div class='drawToolFileTemplate'>", + "<div>Template:</div>", + `<div><div>${template?.name || 'NONE'}</div></div>`, + "</div>", "</div>", "<div class='drawToolFileEditOnDescription'>", "<textarea class='drawToolFileDesc' rows='9' placeholder='No description...' disabled>" + DrawTool.stripTagsFromDescription(file.file_description) + "</textarea>", @@ -1028,6 +1069,106 @@ var Files = { ? modalContentEditable : modalContent, function () { + // + $('#drawToolFileTemplateEdit').on('click', () => { + // prettier-ignore + const templateEditMarkup = [ + `<div id='drawToolFileTemplateEditModal'>`, + `<div id='drawToolFileTemplateEditModalTitle'>`, + `<div><i class='mdi mdi-form-select mdi-18px'></i><div>Template</div></div>`, + `<div id='drawToolFileTemplateEditModalClose'><i class='mmgisHoverBlue mdi mdi-close mdi-18px'></i></div>`, + `</div>`, + `<div id='drawToolFileTemplateContainer'>`, + `</div>`, + `<div id='drawToolFileTemplateEditModalActions'>`, + `<div id='drawToolFileTemplateEditModalActionsCancel' class='drawToolButton1'>Cancel</div>`, + `<div id='drawToolFileTemplateEditModalActionsDone' class='drawToolButton1'>Done</div>`, + `</div>`, + `</div>` + ].join('\n') + Modal.set( + templateEditMarkup, + function () { + $(`#drawToolFileTemplateEditModalClose`).on( + 'click', + function () { + Modal.remove(false, 1) + } + ) + $( + `#drawToolFileTemplateEditModalActionsCancel` + ).on('click', function () { + Modal.remove(false, 1) + }) + DrawTool_Templater.renderDesignTemplate( + 'drawToolFileTemplateContainer', + { + name: template?.name, + template: template?.template, + }, + template?.name == null + ) + $( + `#drawToolFileTemplateEditModalActionsDone` + ).on('click', function () { + let allTemplates = {} + if (DrawTool.files) { + DrawTool.files.forEach((f) => { + if ( + f.template != null && + f.template.name != null && + f.template.template != null + ) { + allTemplates[f.template.name] = + f.template.template + } + }) + } + allTemplates = { + ...allTemplates, + ...JSON.parse( + JSON.stringify( + DrawTool.vars.templates || {} + ) + ), + } + const designedTemplate = + DrawTool_Templater.getDesignedTemplate( + 'drawToolFileTemplateContainer', + allTemplates + ) + if (designedTemplate === true) { + template = null + $( + `#drawToolFileTemplateEdit > div > div` + ) + .text('NONE') + .css({ + color: 'var(--color-green)', + }) + // Do nothing and continue; user was not designing a new template + } else if (designedTemplate === false) { + // User was designing, but it had errors + return + } else { + template = JSON.parse( + JSON.stringify(designedTemplate) + ) + $( + `#drawToolFileTemplateEdit > div > div` + ) + .text(template.name) + .css({ + color: 'var(--color-green)', + }) + } + Modal.remove(false, 1) + }) + }, + function () {}, + 1 + ) + }) // Set up events $('#drawToolFileEditOnTagsNew').autocomplete({ lookup: DrawTool.tags, @@ -1142,7 +1283,17 @@ var Files = { $('#drawToolFileEditOnTagsNew').val('') existingTagFol[type].push(newTag) } - + $('#drawToolFileEditOnPublicityDropdown').on( + 'change', + function () { + $('.drawToolFileEditListEditors').css({ + display: + $(this).val() === 'public list_edit' + ? 'flex' + : 'none', + }) + } + ) $('#drawToolFileEditOnTagsNewAdd').on('click', function () { tagFolderAdd('tags') }) @@ -1204,22 +1355,38 @@ var Files = { file_description: description + existingTagFol['efolders'] - .map((t) => ' ^' + t) + .map((t) => ' ~^' + t) .join('') + existingTagFol['folders'] - .map((t) => ' @' + t) + .map((t) => ' ~@' + t) .join('') + existingTagFol['tags'] - .map((t) => ' #' + t) + .map((t) => ' ~#' + t) .join(''), public: elm .find( '#drawToolFileEditOnPublicityDropdown' ) - .val() == 'public' + .val() + .indexOf('public') != -1 ? 1 : 0, + template: JSON.stringify(template), + publicity_type: elm + .find('#drawToolFileEditOnPublicityDropdown') + .val() + .includes('public') + ? elm + .find( + '#drawToolFileEditOnPublicityDropdown' + ) + .val() + .replace('public ', '') + : null, + public_editors: elm + .find('#drawToolFileEditListEditors') + .val(), } DrawTool.changeFile( @@ -1311,15 +1478,15 @@ var Files = { return function (d) { //Remove each feature in its group if ( - L_.layersGroup.hasOwnProperty(layerId) + L_.layers.layer.hasOwnProperty(layerId) ) { for ( var i = 0; - i < L_.layersGroup[layerId].length; + i < L_.layers.layer[layerId].length; i++ ) { Map_.rmNotNull( - L_.layersGroup[layerId][i] + L_.layers.layer[layerId][i] ) } //And from the Globe @@ -1353,12 +1520,13 @@ var Files = { //Highlight layer if on $('.drawToolDrawFilesListElem').off('mouseenter') $('.drawToolDrawFilesListElem').on('mouseenter', function () { + if (DrawTool.timeToggledOn) return $(this).find('.drawToolFileEdit').addClass('shown') var fileId = parseInt($(this).attr('file_id')) - var l = L_.layersGroup['DrawTool_' + fileId] + var l = L_.layers.layer['DrawTool_' + fileId] if (!l) return for (var i = 0; i < l.length; i++) { - if (l[i] != null) { + if (l[i] != null && l[i].temporallyHidden != true) { if (typeof l[i].setStyle === 'function') l[i].setStyle({ color: '#7fff00' }) else if (l[i].hasOwnProperty('_layers')) { @@ -1377,9 +1545,11 @@ var Files = { }) $('.drawToolDrawFilesListElem').off('mouseleave') $('.drawToolDrawFilesListElem').on('mouseleave', function () { + if (DrawTool.timeToggledOn) return + $(this).find('.drawToolFileEdit').removeClass('shown') var fileId = parseInt($(this).attr('file_id')) - var l = L_.layersGroup['DrawTool_' + fileId] + var l = L_.layers.layer['DrawTool_' + fileId] if (!l) return for (var i = 0; i < l.length; i++) { var style @@ -1452,13 +1622,30 @@ var Files = { // Only select files you own const fileId = $(this).attr('file_id') var fileFromId = DrawTool.getFileObjectWithId(fileId) + if ( - mmgisglobal.user !== $(this).attr('file_owner') && + mmgisglobal.user !== fileFromId.file_owner && fileFromId && F_.diff(fileFromId.file_owner_group, DrawTool.userGroups) .length == 0 - ) - return + ) { + // Now check public list_edit + if ( + !( + (fileFromId.public == '1' && + fileFromId.publicity_type == 'all_edit') || + (fileFromId.public == '1' && + fileFromId.publicity_type == 'list_edit' && + fileFromId.public_editors != null && + typeof fileFromId.public_editors.includes === + 'function' && + fileFromId.public_editors.includes( + mmgisglobal.user + )) + ) + ) + return + } const wasOn = $(this).parent().parent().hasClass('checked') @@ -1525,7 +1712,7 @@ var Files = { //Can't refresh what isn't there if ( parsedId != 'master' && - L_.layersGroup.hasOwnProperty('DrawTool_' + parsedId) == false + L_.layers.layer.hasOwnProperty('DrawTool_' + parsedId) == false ) return @@ -1541,24 +1728,26 @@ var Files = { return function (data) { var layerId = 'DrawTool_' + index //Remove it first - if (L_.layersGroup.hasOwnProperty(layerId)) { + if (L_.layers.layer.hasOwnProperty(layerId)) { for ( var i = 0; - i < L_.layersGroup[layerId].length; + i < L_.layers.layer[layerId].length; i++ ) { //Close any popups/labels - var popupLayer = L_.layersGroup[layerId][i] + var popupLayer = L_.layers.layer[layerId][i] DrawTool.removePopupsFromLayer(popupLayer) - Map_.rmNotNull(L_.layersGroup[layerId][i]) - L_.layersGroup[layerId][i] = null + Map_.rmNotNull(L_.layers.layer[layerId][i]) + L_.layers.layer[layerId][i] = null } //And from the Globe Globe_.litho.removeLayer('camptool_' + layerId) } let features = data.geojson.features + DrawTool.fileGeoJSONFeatures[index] = features + let coreFeatures = JSON.parse(JSON.stringify(data.geojson)) coreFeatures.features = [] @@ -1599,25 +1788,25 @@ var Files = { DrawTool.refreshNoteEvents() } else if (features[i].geometry.type === 'Point') { - L_.layersGroup[layerId].push( + L_.layers.layer[layerId].push( LayerGeologic.createSymbolMarker( features[i].geometry.coordinates[1], features[i].geometry.coordinates[0], features[i].properties.style ).addTo(Map_.map) ) - L_.layersGroup[layerId][ - L_.layersGroup[layerId].length - 1 + L_.layers.layer[layerId][ + L_.layers.layer[layerId].length - 1 ].feature = features[i] } else if (features[i].geometry.type === 'LineString') { - L_.layersGroup[layerId].push( + L_.layers.layer[layerId].push( LayerGeologic.createLinework( features[i], style ).addTo(Map_.map) ) } else { - L_.layersGroup[layerId].push( + L_.layers.layer[layerId].push( L.geoJson( { type: 'FeatureCollection', @@ -1675,8 +1864,8 @@ var Files = { } if (features[i].properties.arrow !== true) { - var last = L_.layersGroup[layerId].length - 1 - var llast = L_.layersGroup[layerId][last] + var last = L_.layers.layer[layerId].length - 1 + var llast = L_.layers.layer[layerId][last] var layer if (llast.hasOwnProperty('_layers')) @@ -1720,6 +1909,7 @@ var Files = { L_.enforceVisibilityCutoffs([layerId]) DrawTool.maintainLayerOrder() + DrawTool.timeFilterDrawingLayer(index) DrawTool.refreshMasterCheckbox() @@ -1779,9 +1969,9 @@ var Files = { .removeClass('on') } //Remove each feature in its group - if (L_.layersGroup.hasOwnProperty(layerId)) { - for (var i = 0; i < L_.layersGroup[layerId].length; i++) { - Map_.rmNotNull(L_.layersGroup[layerId][i]) + if (L_.layers.layer.hasOwnProperty(layerId)) { + for (var i = 0; i < L_.layers.layer[layerId].length; i++) { + Map_.rmNotNull(L_.layers.layer[layerId][i]) } //And from the Globe Globe_.litho.removeLayer('camptool_' + layerId) @@ -1802,7 +1992,7 @@ var Files = { .addClass('on') } //Get the file if we don't already have it - L_.layersGroup[layerId] = [] + L_.layers.layer[layerId] = [] DrawTool.refreshFile( id == 'master' ? DrawTool.masterFileIds : id, null, @@ -1813,7 +2003,7 @@ var Files = { } }, toggleLabels: function (file_id) { - var l = L_.layersGroup['DrawTool_' + file_id] + var l = L_.layers.layer['DrawTool_' + file_id] let indexOf = DrawTool.labelsOn.indexOf(file_id) var isOn = indexOf != -1 if (isOn) DrawTool.labelsOn.splice(indexOf, 1) @@ -1840,7 +2030,7 @@ var Files = { for (var j = 0; j < DrawTool.filesOn.length; j++) { var file = DrawTool.getFileObjectWithId(DrawTool.filesOn[j]) if (file && file.intent === DrawTool.intentOrder[i]) { - for (var e of L_.layersGroup[ + for (var e of L_.layers.layer[ 'DrawTool_' + DrawTool.filesOn[j] ]) if (e != null && typeof e.bringToFront === 'function') @@ -1897,7 +2087,7 @@ var Files = { $('.drawToolAnnotation').on('click', function () { var layer = 'DrawTool_' + $(this).attr('layer') var index = $(this).attr('index') - var shape = L_.layersGroup[layer][index] + var shape = L_.layers.layer[layer][index] if (!mmgisglobal.shiftDown) { if (typeof shape.getBounds === 'function') Map_.map.fitBounds(shape.getBounds()) diff --git a/src/essence/Tools/Draw/DrawTool_History.js b/src/essence/Tools/Draw/DrawTool_History.js index 0e0f7b01..987a4b06 100644 --- a/src/essence/Tools/Draw/DrawTool_History.js +++ b/src/essence/Tools/Draw/DrawTool_History.js @@ -90,7 +90,10 @@ var History = { var markup = [ "<div class='flexbetween' time=" + h.time + ">", "<span>" + h.message + "</span>", - "<span>" + F_.timestampToDate(h.time / 1000) + "</span>", + "<span style='white-space: nowrap;'>", + `<span style='color: var(--color-a5); font-size: 12px;'>${h.author ? `${h.author} - ` : ''}</span>`, + `<span>${F_.timestampToDate(h.time / 1000, true)}</span>`, + "</span>", "</div>" ].join('\n'); diff --git a/src/essence/Tools/Draw/DrawTool_Shapes.js b/src/essence/Tools/Draw/DrawTool_Shapes.js index fb76377d..6566d1c0 100644 --- a/src/essence/Tools/Draw/DrawTool_Shapes.js +++ b/src/essence/Tools/Draw/DrawTool_Shapes.js @@ -34,12 +34,12 @@ var Shapes = { //Populate shapes $('#drawToolShapesFeaturesList *').remove() - for (var l in L_.layersGroup) { + for (var l in L_.layers.layer) { var s = l.split('_') var onId = s[1] != 'master' ? parseInt(s[1]) : s[1] if (s[0] == 'DrawTool' && DrawTool.filesOn.indexOf(onId) != -1) { var file = DrawTool.getFileObjectWithId(s[1]) - if (L_.layersGroup[l].length > 0) + if (L_.layers.layer[l].length > 0) d3.select('#drawToolShapesFeaturesList') .append('li') .attr('class', 'drawToolShapesFeaturesListFileHeader') @@ -57,8 +57,8 @@ var Shapes = { : 'white' ) .html(file.file_name) - for (var i = 0; i < L_.layersGroup[l].length; i++) { - addShapeToList(L_.layersGroup[l][i], file, l, i, s[1]) + for (var i = 0; i < L_.layers.layer[l].length; i++) { + addShapeToList(L_.layers.layer[l][i], file, l, i, s[1]) } } } @@ -88,7 +88,9 @@ var Shapes = { $('.drawToolShapeLi').each(function () { var l = - L_.layersGroup[$(this).attr('layer')][$(this).attr('index')] + L_.layers.layer[$(this).attr('layer')][ + $(this).attr('index') + ] if (l.feature == null && l.hasOwnProperty('_layers')) l = l._layers[Object.keys(l._layers)[0]] @@ -277,7 +279,7 @@ var Shapes = { DrawTool.contextMenuLayer.dragging ) return - var l = L_.layersGroup[layer][index] + var l = L_.layers.layer[layer][index] if ( !l.hasOwnProperty('feature') && l.hasOwnProperty('_layers') @@ -487,11 +489,11 @@ var Shapes = { var layer = $(this).find('.drawToolShapeLiItem').attr('layer') var index = $(this).find('.drawToolShapeLiItem').attr('index') - if (typeof L_.layersGroup[layer][index].setStyle === 'function') - L_.layersGroup[layer][index].setStyle({ color: '#7fff00' }) - else if (L_.layersGroup[layer][index].hasOwnProperty('_layers')) { + if (typeof L_.layers.layer[layer][index].setStyle === 'function') + L_.layers.layer[layer][index].setStyle({ color: '#7fff00' }) + else if (L_.layers.layer[layer][index].hasOwnProperty('_layers')) { //Arrow - var layers = L_.layersGroup[layer][index]._layers + var layers = L_.layers.layer[layer][index]._layers layers[Object.keys(layers)[0]].setStyle({ color: '#7fff00', }) @@ -512,7 +514,7 @@ var Shapes = { var layer = $(this).find('.drawToolShapeLiItem').attr('layer') var index = $(this).find('.drawToolShapeLiItem').attr('index') var shapeId = $(this).attr('shape_id') - var shape = L_.layersGroup[layer][index] + var shape = L_.layers.layer[layer][index] var style if ( @@ -581,7 +583,7 @@ var Shapes = { $('.drawToolShapeLiItem').on('click', function (e) { var layer = $(this).attr('layer') var index = $(this).attr('index') - var shape = L_.layersGroup[layer][index] + var shape = L_.layers.layer[layer][index] if (!mmgisglobal.shiftDown) { if (typeof shape.getBounds === 'function') Map_.map.panTo(shape.getBounds().getCenter()) @@ -622,7 +624,7 @@ var Shapes = { ) if (item.length > 0) { var shape = - L_.layersGroup[item.attr('layer')][item.attr('index')] + L_.layers.layer[item.attr('layer')][item.attr('index')] if (shape.hasOwnProperty('_layers')) shape._layers[Object.keys(shape._layers)[0]].fireEvent( 'click' @@ -658,6 +660,23 @@ var Shapes = { }) for (var i = 0; i < DrawTool.files.length; i++) { + const file = DrawTool.files[i] + let ownedByUser = false + if ( + mmgisglobal.user == file.file_owner || + (file.file_owner_group && + F_.diff(file.file_owner_group, DrawTool.userGroups) + .length > 0) + ) + ownedByUser = true + const isListEdit = + file.public == '1' && + file.publicity_type == 'list_edit' && + typeof file.public_editors?.includes === 'function' && + (file.public_editors.includes(mmgisglobal.user) || + ownedByUser) + const isAllEdit = + file.public == '1' && file.publicity_type == 'all_edit' //Lead Files if ( DrawTool.userGroups.indexOf('mmgis-group') != -1 && @@ -682,7 +701,9 @@ var Shapes = { .attr('value', DrawTool.files[i].id) .text(DrawTool.files[i].file_name + ' [Lead]') } else if ( - mmgisglobal.user == DrawTool.files[i].file_owner && + (mmgisglobal.user == DrawTool.files[i].file_owner || + isListEdit || + isAllEdit) && filenames.indexOf(DrawTool.files[i].file_name) == -1 && intent == DrawTool.files[i].intent && DrawTool.files[i].hidden == '0' diff --git a/src/essence/Tools/Draw/DrawTool_Templater.css b/src/essence/Tools/Draw/DrawTool_Templater.css new file mode 100644 index 00000000..60ccfd27 --- /dev/null +++ b/src/essence/Tools/Draw/DrawTool_Templater.css @@ -0,0 +1,338 @@ +#drawToolTemplater { +} + +#drawToolTemplater > li { + list-style-type: none; + display: flex; + justify-content: space-between; + height: 30px; + margin-bottom: 8px; +} + +#drawToolTemplater > li > div:first-child { + line-height: 30px; + padding-right: 10px; + width: 150px; + text-overflow: ellipsis; + overflow: hidden; +} +#drawToolTemplater > li input { + text-align: right; + font-size: 14px; +} +#drawToolTemplater > li textarea { + font-size: 14px; +} + +#drawToolTemplater_setTime { + border-top: 1px solid var(--color-a1); + padding-top: 8px; + display: flex; +} +#drawToolTemplater_setTime > div:first-child { + display: flex; + margin-right: 4px; +} +#drawToolTemplater_setTime > div:last-child { + display: flex; + margin-left: 4px; +} +#drawToolTemplater_setTime > div { + display: flex !important; + justify-content: center; + text-align: center; + flex: 1; + background: var(--color-a1); + line-height: 26px !important; + cursor: pointer; + opacity: 0.4; + pointer-events: none; + transition: all 0.2s ease-in-out; +} +#drawToolTemplater_setTime > div > div { + line-height: 32px; + font-size: 13px; +} +#drawToolTemplater_setTime > div:hover { + color: white; + background: var(--color-a2); +} +#drawToolTemplater_setTime > div.active { + opacity: 1; + pointer-events: all; +} +#drawToolTemplater_setTime > div:first-child > i { + margin-right: 4px; + line-height: 30px; +} +#drawToolTemplater_setTime > div:last-child > i { + margin-left: 4px; + line-height: 30px; +} + +.drawToolTemplatercheckbox .mmgis-checkbox { + margin-right: 5px; + margin-top: 5px; +} + +.drawToolTemplaternumber { +} +.drawToolTemplatertextarea { + height: auto !important; +} +.drawToolTemplatertextarea textarea { + width: 100%; + min-height: 60px; + resize: vertical; + box-sizing: border-box; + margin-bottom: 4px; + color: var(--color-f) !important; + background: var(--color-i) !important; + font-size: 16px; + padding: 8px; + border: none; +} + +.drawToolTemplaterrange { + position: relative; +} +.drawToolTemplaterrange > input { + margin-top: 7px; + padding: 6px 0px !important; +} +.drawToolTemplaterrange > span { + position: absolute; + top: 8px; + right: 7px; + font-size: 14px; + color: white; + z-index: 10; + pointer-events: none; + mix-blend-mode: difference; +} + +.drawToolTemplaterdropdown .dropdown { + width: 340px; + height: 30px; + background: var(--color-a1); +} +.drawToolTemplaterdropdown .dropdown .dropy { + margin-bottom: 0; +} +.drawToolTemplaterdropdown .dropdown .dropy__title { + line-height: 9px; +} +.drawToolTemplaterdropdown .dropdown .dropy__title > i { + transform: translateY(30%); +} + +#drawToolFileModalTemplateContainer { + background: var(--color-a-5); + margin-bottom: 0px !important; +} +#drawToolTemplaterDesignContentWrapper { + overflow-y: auto; + max-height: calc(80vh - 255px); + min-height: 320px; +} +#drawToolTemplaterDesignHeading { + display: flex; + justify-content: space-between; + padding: 12px; + border-top: 1px solid var(--color-a1); +} +#drawToolTemplaterDesignHeadingName { + display: flex; + flex: 1; +} +#drawToolTemplaterDesignHeadingName > div { + line-height: 30px; + color: var(--color-blue); + padding-right: 8px; +} +#drawToolTemplaterDesignHeadingCancel { + margin: 0; + padding: 5px 6px; + background: var(--color-a2); +} +#drawToolTemplaterDesignHeadingCancel:hover { + background: var(--color-p4); +} + +.drawToolTemplaterIsReadOnly #drawToolTemplaterDesignHeadingName > div { + font-size: 16px; + color: var(--color-mh); +} + +#drawToolTemplaterDesignHeadingAdd { + width: 90px; + margin: 8px auto 0px auto; + border-radius: 15px; + padding: 6px 6px 4px 10px; + background: var(--color-a); + text-transform: uppercase; + font-size: 11px; + color: var(--color-a5); + transition: all 0.2s ease-in-out; + display: flex; + justify-content: center; +} +#drawToolTemplaterDesignHeadingAdd:hover { + background: var(--color-a1); + color: var(--color-a7); +} +#drawToolTemplaterDesignHeadingAdd > div:first-child { + line-height: 20px; +} +#drawToolTemplaterDesignHeadingAdd > div:last-child { + margin-left: 2px; +} +#drawToolTemplaterDesign { + padding-bottom: 8px; +} +#drawToolTemplaterDesign input[type='text'], +#drawToolTemplaterDesign input[type='number'] { + flex: 1 1; + border: none; + padding: 0px 8px; + font-size: 14px; + height: 30px; + width: 100%; + background: var(--color-a1-5); + color: var(--color-a7); +} +.drawToolTemplaterLiBody_slider_default, +.drawToolTemplaterLiBody_number_default, +.drawToolTemplaterLiBody_text_regex { + flex: 1; +} + +.drawToolTemplaterLi { + list-style-type: none; + padding-bottom: 5px; + margin: 0px 12px 4px 12px; + background: var(--color-a); + box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.8); +} +.drawToolTemplaterLiHead { + display: flex; + justify-content: space-between; + height: 30px; + margin-bottom: 5px; +} +.drawToolTemplaterLiIdx { + height: 30px; + line-height: 30px; + min-width: 30px; + text-align: center; + font-size: 14px; + background: var(--color-a2); +} +.drawToolTemplaterLiField { + display: flex; + flex: 1; +} +.drawToolTemplaterLiField input { + width: 300px !important; +} + +.drawToolTemplaterLiBodyDropdown_format, +.drawToolTemplaterLiType > div { + width: 150px; + height: 30px; + background: var(--color-a2); +} +.drawToolTemplaterLiBodyDropdown_format { + width: 160px; +} +.drawToolTemplaterLiBodyDropdown_format .dropy, +.drawToolTemplaterLiType > div .dropy { + margin-bottom: 0; +} +.drawToolTemplaterLiBodyDropdown_format .dropy__title { + line-height: 21px; + font-size: 11px; +} +.drawToolTemplaterLiType > div .dropy__title { + line-height: 13px; + font-size: 14px; +} +.drawToolTemplaterLiBodyDropdown_format .dropy__title > i, +.drawToolTemplaterLiType > div .dropy__title > i { + transform: translateY(30%); +} +.drawToolTemplaterLiBody_date_default > input { + width: 125px; +} +.drawToolTemplaterDesignHeadingRemove { + width: 30px; + height: 30px; + line-height: 30px; + text-align: center; + cursor: pointer; + background: var(--color-a1); + transition: background 0.2s ease-in-out; +} +.drawToolTemplaterDesignHeadingRemove:hover { + background: var(--color-p4); +} + +.drawToolTemplaterLiBody { + height: 30px; + padding: 0px 5px 0px 1px; +} +.drawToolTemplaterLiBody > div { + display: flex; +} +.drawToolTemplaterLiBody > div > div { + display: flex; +} +.drawToolTemplaterLiBody > div > div > div:first-child { + margin: 0px 8px 0px 8px; + line-height: 31px; + color: var(--color-mh); + font-size: 13px; +} +.drawToolTemplaterLiBody_dropdown > div { + width: 100%; +} +.drawToolTemplaterLiBody_dropdown_default { + width: auto !important; +} + +.drawToolTemplaterLiBody_textarea_default { + flex: 1; +} +.drawToolTemplaterLiBody_text_default input { + width: 130px !important; +} +.drawToolTemplaterLiBody_number_default { +} +.drawToolTemplaterLiBody_number_min { +} +.drawToolTemplaterLiBody_number_max { +} +.drawToolTemplaterLiBody_number_step { +} +.drawToolTemplaterLiBody .mmgis-checkbox { + margin: 5px 3px !important; +} +.drawToolTemplaterLiBody_text_regex input { + width: 70px !important; +} + +.drawToolTemplaterLiBody input[type='number'] { + width: 50px !important; +} +.drawToolTemplaterLiBody_number_default input[type='number'] { + width: 160px !important; +} +.drawToolTemplaterLiBody_slider_default input[type='number'] { + width: 227px !important; +} +.drawToolTemplaterLiBody_dropdown_default input[type='number'] { + width: 90px !important; +} +.drawToolTemplaterLiBody_incrementer_default { + width: 100%; +} diff --git a/src/essence/Tools/Draw/DrawTool_Templater.js b/src/essence/Tools/Draw/DrawTool_Templater.js new file mode 100644 index 00000000..d8480f30 --- /dev/null +++ b/src/essence/Tools/Draw/DrawTool_Templater.js @@ -0,0 +1,1355 @@ +import $ from 'jquery' + +import CursorInfo from '../../Ancillary/CursorInfo' +import Dropy from '../../../external/Dropy/dropy' +import TimeControl from '../../Ancillary/TimeControl' + +import * as moment from 'moment' +import { TempusDominus, Namespace } from '@eonasdan/tempus-dominus' +import '@eonasdan/tempus-dominus/dist/css/tempus-dominus.css' +import tippy from 'tippy.js' + +import './DrawTool_Templater.css' + +const DrawTool_Templater = { + renderTemplate: function (containerId, templateObj, properties) { + if (templateObj == null) return null + properties = properties || {} + const template = JSON.parse(JSON.stringify(templateObj.template)) + + let hasStartTime, hasEndTime + // prettier-ignore + const markup = [ + "<ul id='drawToolTemplater'>", + template.map((t, idx) => { + + if( properties[t.field] != null) { + t._default = t.default + t.default = properties[t.field] + } + if( hasStartTime == null && t.isStart) + hasStartTime = t + if( hasEndTime == null && t.isEnd ) + hasEndTime = t + // prettier-ignore + switch(t.type) { + case 'checkbox': + return [ + `<li id='drawToolTemplater_${idx}' class='drawToolTemplater${t.type}'>`, + `<div title='${t.field}'>${t.field}:</div>`, + `<div class="mmgis-checkbox small"><input type="checkbox" ${t.default === true ? 'checked ' : ''}id="templater-checkbox-${idx}"/><label for="templater-checkbox-${idx}"></label></div>`, + `</li>` + ].join('\n') + case 'number': + return [ + `<li id='drawToolTemplater_${idx}' class='drawToolTemplater${t.type}'>`, + `<div title='${t.field}'>${t.field}:</div>`, + `<input type='number' placeholder="Enter Number" autocomplete="off" + ${t.default != null && typeof t.default === 'number' ? ` value='${t.default}'` : ''} + ${t.min != null && typeof t.min === 'number' ? ` min='${t.min}'` : ''} + ${t.max != null && typeof t.max === 'number' ? ` max='${t.max}'` : ''} + ${t.step != null && typeof t.step === 'number' ? ` step='${t.step}'` : ''} + />`, + `</li>` + ].join('\n') + case 'text': + return [ + `<li id='drawToolTemplater_${idx}' class='drawToolTemplater${t.type}'>`, + `<div title='${t.field}'>${t.field}:</div>`, + `<input type='text' placeholder="Enter Text" autocomplete="off" + ${t.default != null ? ` value='${t.default}'` : ''} + ${t.minLength != null && typeof t.min === 'number' ? ` minLength='${t.minLength}'` : ''} + ${t.maxLength != null && typeof t.max === 'number' ? ` maxLength='${t.maxLength}'` : ''} + />`, + `</li>` + ].join('\n') + case 'textarea': + return [ + `<li id='drawToolTemplater_${idx}' class='drawToolTemplater${t.type}'>`, + `<div title='${t.field}'>${t.field}:</div>`, + `<textarea>${t.default != null ? t.default : ''}</textarea>`, + `</li>` + ].join('\n') + case 'range': + case 'slider': + return [ + `<li id='drawToolTemplater_${idx}' class='drawToolTemplaterrange'>`, + `<div title='${t.field}'>${t.field}:</div>`, + `<span>${t.default != null && typeof t.default === 'number' ? t.default : 'N/A'}</span>`, + `<input type='range' class='slider2' + ${t.default != null && typeof t.default === 'number' ? ` value='${t.default}'` : ''} + ${t.min != null && typeof t.min === 'number' ? ` min='${t.min}'` : ''} + ${t.max != null && typeof t.max === 'number' ? ` max='${t.max}'` : ''} + ${t.step != null && typeof t.step === 'number' ? ` step='${t.step}'` : ''} + />`, + `</li>` + ].join('\n') + case 'dropdown': + return [ + `<li id='drawToolTemplater_${idx}' class='drawToolTemplater${t.type}'>`, + `<div title='${t.field}'>${t.field}:</div>`, + `<div id='drawToolFileModalTemplateDropdown_${idx}' class='ui dropdown short'></div>`, + `</li>` + ].join('\n') + case 'date': + return [ + `<li id='drawToolTemplater_${idx}' class='drawToolTemplater${t.type}'>`, + `<div title='${t.field}'>${t.field}:</div>`, + `<input id='drawToolFileModalTemplateDate_${idx}' placeholder='${t.format || 'YYYY-MM-DDTHH:mm:ss'}' autocomplete='off'></input>`, + `</li>` + ].join('\n') + case 'incrementer': + return [ + `<li id='drawToolTemplater_${idx}' class='drawToolTemplater${t.type}'>`, + `<div title='${t.field}'>${t.field}:</div>`, + `<input type='text' placeholder="${t.default != null ? ` value='${t.default}'` : ''}" autocomplete="off" + ${t.default != null ? ` value='${t.default}'` : ''} + />`, + `</li>` + ].join('\n') + default: + return null + } + }).join('\n'), + hasStartTime || hasEndTime ? [ + `<li id='drawToolTemplater_setTime'>`, + `<div id='drawToolTemplater_setTimeStart' class="${hasStartTime && hasStartTime.default.length > 0 ? 'active' : ''}"><i class='mdi mdi-clock mdi-18px'></i><div>Use Start Time</div></div>`, + `<div id='drawToolTemplater_setTimeEnd' class="${hasEndTime && hasEndTime.default.length > 0 ? 'active' : ''}"><div>Use End Time</div><i class='mdi mdi-clock-outline mdi-18px'></i></div>`, + `</li>`].join('\n') : null, + "</ul>" + ].join('\n') + + $(`#${containerId}`).append(markup) + + const helperStates = {} + let startTime, endTime + // Attach events + template.forEach((t, idx) => { + if (startTime == null && t.isStart) startTime = t.field + if (endTime == null && t.isEnd) endTime = t.field + + switch (t.type) { + case 'range': + case 'slider': + $(`#drawToolTemplater_${idx} input`).on('input', () => { + $(`#drawToolTemplater_${idx} span`).text( + `${$(`#drawToolTemplater_${idx} input`).val()}` + ) + }) + break + case 'dropdown': + helperStates[idx] = Math.max( + (t.items || []).indexOf(t.default), + 0 + ) + $(`#drawToolFileModalTemplateDropdown_${idx}`).html( + Dropy.construct( + t.items || [], + t.field, + helperStates[idx], + { + openUp: false, + dark: true, + } + ) + ) + Dropy.init( + $(`#drawToolFileModalTemplateDropdown_${idx}`), + function (idx2) { + helperStates[idx] = idx2 + } + ) + break + case 'date': + const startElm = document.getElementById( + `drawToolFileModalTemplateDate_${idx}` + ) + const options = { + display: { + viewMode: 'months', + components: { + decades: true, + year: true, + month: true, + date: true, + hours: true, + minutes: true, + seconds: true, + }, + buttons: { + today: true, + clear: true, + close: true, + }, + theme: 'dark', + icons: { + type: 'icons', + time: 'mdi mdi-clock-outline mdi-18px', + date: 'mdi mdi-calendar-outline mdi-18px', + up: 'mdi mdi-chevron-up mdi-18px', + down: 'mdi mdi-chevron-down mdi-18px', + previous: 'mdi mdi-chevron-left mdi-18px', + next: 'mdi mdi-chevron-right mdi-18px', + today: 'mdi mdi-calendar-today mdi-18px', + clear: 'mdi mdi-delete mdi-18px', + close: 'mdi mdi-check-bold mdi-18px', + }, + }, + useCurrent: false, + //promptTimeOnDateChange: true, + promptTimeOnDateChangeTransitionDelay: 200, + } + const dateTempus = new TempusDominus(startElm, options) + dateTempus.dates.formatInput = (date) => { + return moment + .utc(DrawTool_Templater.removeOffset(date)) + .format(t.format || 'YYYY-MM-DDTHH:mm:ss') + } + if (t.default != null && t.default != '') { + let def = t.default + let d + if (def === 'NOW') d = new Date().getTime() + else if (def === 'STARTTIME') + d = DrawTool_Templater.addOffset( + new Date(TimeControl.getStartTime()).getTime() + ) + else if (def === 'ENDTIME') + d = DrawTool_Templater.addOffset( + new Date(TimeControl.getEndTime()).getTime() + ) + else { + d = new moment( + def, + t.format || 'YYYY-MM-DDTHH:mm:ss' + ) + .utc() + .valueOf() + } + const parsed = dateTempus.dates.parseInput(new Date(d)) + dateTempus.dates.setValue(parsed) + } + break + default: + break + } + }) + + $(`#drawToolTemplater_setTimeStart`).on('click', () => { + L_.TimeControl_.setTime( + properties[startTime], + L_.TimeControl_.getEndTime() + ) + }) + $(`#drawToolTemplater_setTimeEnd`).on('click', () => { + L_.TimeControl_.setTime( + L_.TimeControl_.getStartTime(), + properties[endTime] + ) + }) + + return { + getValues: (layer, existingProperties, onlyIfChanged) => { + const values = {} + const invalids = {} + + template.forEach((t, idx) => { + switch (t.type) { + case 'checkbox': + values[t.field] = $( + `#${containerId} #drawToolTemplater_${idx} input` + ).prop('checked') + + break + case 'number': + values[t.field] = parseFloat( + $( + `#${containerId} #drawToolTemplater_${idx} input` + ).val() + ) + if (isNaN(values[t.field])) values[t.field] = null + + if ( + t.min != null && + t.min != '' && + values[t.field] < t.min + ) + invalids[ + t.field + ] = `'${t.field}' must be >= ${t.min}` + if ( + t.max != null && + t.max != '' && + values[t.field] > t.max + ) + invalids[ + t.field + ] = `'${t.field}' must be <= ${t.max}` + if ( + t.step != null && + t.step != '' && + values[t.field] / t.step != + parseInt(values[t.field] / t.step) + ) + invalids[ + t.field + ] = `'${t.field}' must be a multiple of ${t.step}` + + break + case 'text': + values[t.field] = $( + `#${containerId} #drawToolTemplater_${idx} input` + ).val() + if ( + t.minLength != null && + t.minLength != '' && + values[t.field].length < t.minLength + ) + invalids[ + t.field + ] = `'${t.field}' must be >= ${t.minLength} characters` + + if ( + t.maxLength != null && + t.maxLength != '' && + values[t.field] != null && + values[t.field].length > t.maxLength + ) + invalids[ + t.field + ] = `'${t.field}' must be <= ${t.maxLength} characters` + + if ( + t.regex != null && + t.regex != '' && + values[t.field] != null + ) { + try { + if ( + values[t.field].match( + new RegExp(t.regex) + ) == null + ) + invalids[ + t.field + ] = `'${t.field}' does not match regex: ${t.regex}` + } catch (error) { + // regex no good + } + } + + break + case 'textarea': + values[t.field] = $( + `#${containerId} #drawToolTemplater_${idx} textarea` + ).val() + if ( + t.required === true && + (values[t.field] == null || + values[t.field] == '') + ) + invalids[ + t.field + ] = `'${t.field}' cannot be empty` + if ( + t.maxLength != null && + t.maxLength != '' && + values[t.field] != null && + values[t.field].length > t.maxLength + ) + invalids[ + t.field + ] = `'${t.field}' must be <= ${t.maxLength} characters` + break + case 'range': + case 'slider': + values[t.field] = parseFloat( + $( + `#${containerId} #drawToolTemplater_${idx} input` + ).val() + ) + if (isNaN(values[t.field])) values[t.field] = null + break + case 'dropdown': + values[t.field] = t.items[helperStates[idx]] + break + case 'date': + values[t.field] = $( + `#${containerId} #drawToolFileModalTemplateDate_${idx}` + ).val() + if (values[t.field] === 'Invalid Date') + values[t.field] = null + break + case 'incrementer': + values[t.field] = $( + `#${containerId} #drawToolTemplater_${idx} input` + ).val() + + const nextIncrement = + DrawTool_Templater._validateIncrement( + values[t.field], + t, + layer, + existingProperties + ) + + if (nextIncrement.error != null) + invalids[t.field] = nextIncrement.error + else values[t.field] = nextIncrement.newValue + + break + default: + break + } + + if ( + t.required === true && + (values[t.field] == null || + values[t.field] == '' || + (t.type === 'number' && isNaN(values[t.field]))) + ) { + invalids[t.field] = `'${t.field}' is a required field` + } + }) + let hadInvalid = false + let bestMessage + template.forEach((t, idx) => { + if (invalids[t.field] != null) { + hadInvalid = true + bestMessage = invalids[t.field] + switch (t.type) { + case 'textarea': + $( + `#${containerId} #drawToolTemplater_${idx} textarea` + ).css('border-bottom', '2px solid red') + break + default: + $( + `#${containerId} #drawToolTemplater_${idx} input` + ).css('border-bottom', '2px solid red') + } + } else { + switch (t.type) { + case 'textarea': + $( + `#${containerId} #drawToolTemplater_${idx} textarea` + ).css('border-bottom', 'none') + break + default: + $( + `#${containerId} #drawToolTemplater_${idx} input` + ).css('border-bottom', 'none') + } + } + }) + if (hadInvalid) { + CursorInfo.update( + `This feature has invalid form values: ${bestMessage}`, + 6000, + true, + { x: 305, y: 6 }, + '#e9ff26', + 'black' + ) + return false + } else { + if (onlyIfChanged === true) { + const changedValues = {} + Object.keys(values).forEach((k) => { + if ( + !existingProperties.hasOwnProperty(k) || + values[k] !== existingProperties[k] + ) + changedValues[k] = values[k] + }) + return changedValues + } else return values + } + }, + } + }, + addOffset(timestamp) { + const date = new Date(timestamp) + const addedOffset = new Date( + date.getTime() + date.getTimezoneOffset() * 60000 + ) + return addedOffset + }, + removeOffset(timestamp) { + const date = new Date(timestamp) + const removedOffset = new Date( + date.getTime() - date.getTimezoneOffset() * 60000 + ) + return removedOffset + }, + + /** + * + * @param {*} value + * @param {*} t + * @param {*} layer + * @returns {newValue: Number, error: String} + */ + _validateIncrement(value, t, layer, existingProperties) { + const response = { + newValue: value, + error: null, + } + + let usedValues = [] + const split = (t._default || t.default).split('#') + const start = split[0] + const end = split[1] + + for (var i = 0; i < layer.length; i++) { + if (layer[i] == null) continue + let geojson = + layer[i].feature || + layer[i]._layers[Object.keys(layer[i]._layers)[0]].feature + if (geojson?.properties?.[t.field] != null) { + let featuresVal = geojson?.properties?.[t.field] + + featuresVal = featuresVal.replace(start, '').replace(end, '') + + if (featuresVal !== '#') { + featuresVal = parseInt(featuresVal) + usedValues.push(featuresVal) + } + } + } + + if ((response.newValue || '').indexOf('#') !== -1) { + // Actually increment the incrementer for the first time + let bestVal = 0 + usedValues.sort(function (a, b) { + return a - b + }) + usedValues = [...new Set(usedValues)] // makes it unique + usedValues.forEach((v) => { + if (bestVal === v) bestVal++ + }) + } else if (existingProperties) { + let numVal = response.newValue.replace(start, '').replace(end, '') + if (numVal != '#') { + numVal = parseInt(numVal) + if (existingProperties[t.field] === response.newValue) { + // In case of a resave, make sure the id exists only once + let count = 0 + usedValues.forEach((v) => { + if (numVal === v) count++ + }) + if (count > 1) + response.error = `Incrementing field: '${t.field}' is not unique` + } else { + // In case a manual change, make sure the id is unique + if (usedValues.indexOf(numVal) !== -1) + response.error = `Incrementing field: '${t.field}' is not unique` + } + } + } + + // Check that the field still matches the surrounding string + const incRegex = new RegExp(`^${start}\\d+${end}$`) + if (incRegex.test(response.newValue) == false) { + response.error = `Incrementing field: '${t.field}' must follow syntax: '${start}{#}${end}'` + } + + return response + }, + _templateInDesignIdx: 0, + _templateInDesign: {}, + _TEMPLATE_TYPES: [ + 'checkbox', + 'date', + 'dropdown', + 'incrementer', + 'number', + 'slider', + 'text', + 'textarea', + ], + _DATE_FORMATS: [ + 'YYYY-MM-DDTHH:mm:ss', + 'MMMM Do YYYY', + 'YYYY-MM-DD', + 'MMMM Do YYYY, h:mm:ss a', + 'HH:mm:ss', + 'h:mm:ss a', + ], + renderDesignTemplate: function ( + containerId, + templateObj, + isNew, + featureToMakeTemplateFrom + ) { + $(`#${containerId} #drawToolTemplaterDesign`).remove() + + if (featureToMakeTemplateFrom && featureToMakeTemplateFrom.properties) { + isNew = true + const featureTemplate = { + name: '', + template: [], + } + Object.keys(featureToMakeTemplateFrom.properties).forEach( + (propKey) => { + const newTemplateItem = { + field: propKey, + } + const v = featureToMakeTemplateFrom.properties[propKey] + switch (typeof v) { + case 'boolean': + newTemplateItem.type = 'checkbox' + break + case 'number': + newTemplateItem.type = 'number' + newTemplateItem.min = '' + newTemplateItem.max = '' + newTemplateItem.step = '' + break + case 'string': + newTemplateItem.type = 'text' + newTemplateItem.minLength = '' + newTemplateItem.maxLength = '' + newTemplateItem.regex = '' + break + default: + break + } + if (newTemplateItem.type != null) + featureTemplate.template.push(newTemplateItem) + } + ) + templateObj = featureTemplate + } + + const isReadOnly = templateObj?.name != null && isNew !== true + + DrawTool_Templater._templateInDesignIdx = 0 + DrawTool_Templater._templateInDesign = [] + // prettier-ignore + const markup = [ + `<div id='drawToolTemplaterDesign' class='${isReadOnly ? 'drawToolTemplaterIsReadOnly' : ''}'>`, + "<div id='drawToolTemplaterDesignHeading'>", + `<div id='drawToolTemplaterDesignHeadingName'>`, + `<div>${isReadOnly ? `Template: ${templateObj?.name}` : 'New Template'}</div>`, + `<input id='drawToolTemplaterDesignHeadingNameInput' placeholder='Enter a Template Name' type='text' value='${templateObj?.name || ''}'></input>`, + "</div>", + "<div id='drawToolTemplaterDesignHeadingCancel' class='drawToolButton1'><i class='mdi mdi-close mdi-18px'></i></div>", + "</div>", + "<div id='drawToolTemplaterDesignContentWrapper'>", + "<ul id='drawToolTemplaterDesignContent'></ul>", + "<div id='drawToolTemplaterDesignHeadingAdd' class='drawToolButton1'><div>Add Field</div><div><i class='mdi mdi-plus mdi-18px'></div></i></div>", + "</div>", + "</div>" + ].join('\n') + + $(`#${containerId}`).append(markup) + + tippy('#drawToolTemplaterDesignHeadingCancel', { + content: `Remove New Template`, + placement: 'right', + theme: 'red', + }) + + $(`#drawToolTemplaterDesignHeadingCancel`).on('click', (e) => { + $(`#${containerId} #drawToolTemplaterDesign`).remove() + e.stopPropagation() + }) + + // Options is the inner template configuration object for the component + const add = (options) => { + options = options || {} + const idx = DrawTool_Templater._templateInDesignIdx + DrawTool_Templater._templateInDesign[idx] = {} + // prettier-ignore + const liMarkup = [ + `<li class='drawToolTemplaterLi' id='drawToolTemplaterLi_${idx}'>`, + "<div class='drawToolTemplaterLiHead'>", + "<div class='drawToolTemplaterLiField'>", + `<div class='drawToolTemplaterLiIdx'>${idx + 1}</div>`, + `<input id='drawToolTemplaterLiFieldInput_${idx}' placeholder='Field Name' type='text' value='${options.field || ''}'></input>`, + "</div>", + "<div class='drawToolTemplaterLiType'>", + `<div id='drawToolTemplaterLiTypeDropdown_${idx}' class='ui dropdown short'></div>`, + "</div>", + `<div class='drawToolTemplaterDesignHeadingRemove' id='drawToolTemplaterDesignHeadingRemove_${idx}' class='drawToolButton1'><i class='mdi mdi-close mdi-18px'></i></div>`, + "</div>", + `<div id='drawToolTemplaterLiBody_${idx}' class='drawToolTemplaterLiBody'>`, + "</div>", + "</li>" + ].join('\n') + + $(`#drawToolTemplaterDesignContent`).append(liMarkup) + + $(`#drawToolTemplaterLiFieldInput_${idx}`).focus() + + $(`#drawToolTemplaterDesignHeadingRemove_${idx}`).on( + 'click', + (e) => { + $(`#drawToolTemplaterLi_${idx}`).remove() + e.stopPropagation() + } + ) + + const setType = (idx2, opts) => { + opts = opts || {} + DrawTool_Templater._templateInDesign[idx].type = + DrawTool_Templater._TEMPLATE_TYPES[idx2] + + const type = DrawTool_Templater._templateInDesign[idx].type + let typeMarkup = [] + switch (type) { + case 'checkbox': + // prettier-ignore + typeMarkup = [ + `<div class='drawToolTemplaterLiBody_${type}'>`, + "<div>", + `<div>Default: </div>`, + `<div class="mmgis-checkbox"><input type="checkbox" ${opts.default === true ? 'checked ' : ''}id="design-checkbox-checkbox-${idx}"/><label for="design-checkbox-checkbox-${idx}"></label></div>`, + "</div>", + "</div>" + ] + break + case 'dropdown': + // prettier-ignore + typeMarkup = [ + `<div class='drawToolTemplaterLiBody_${type}'>`, + `<div class='drawToolTemplaterLiBody_${type}_default'>`, + `<div>Default: </div>`, + `<input id='drawToolTemplaterLiFieldInput_${idx}_default' placeholder='Default' type='text' value='${opts.default != null ? opts.default : ''}'></input>`, + "</div>", + `<div class='drawToolTemplaterLiBody_${type}_values'>`, + `<div>Values: </div>`, + `<input id='drawToolTemplaterLiFieldInput_${idx}' placeholder='Comma,separated,values,first,is,default' type='text' value='${(opts.items != null && Array.isArray(opts.items)) ? opts.items.join(',') : ''}'></input>`, + "</div>", + "</div>" + ] + break + case 'number': + // prettier-ignore + typeMarkup = [ + `<div class='drawToolTemplaterLiBody_${type}'>`, + `<div class='drawToolTemplaterLiBody_${type}_default'>`, + `<div>Default: </div>`, + `<input id='drawToolTemplaterLiFieldInput_${idx}_default' placeholder='Default' type='number' value='${opts.default != null ? opts.default : ''}'></input>`, + "</div>", + `<div class='drawToolTemplaterLiBody_${type}_min'>`, + `<div>Min: </div>`, + `<input id='drawToolTemplaterLiFieldInput_${idx}_min' type='number' value='${opts.min != null ? opts.min : '0'}'></input>`, + "</div>", + `<div class='drawToolTemplaterLiBody_${type}_max'>`, + `<div>Max: </div>`, + `<input id='drawToolTemplaterLiFieldInput_${idx}_max' type='number' value='${opts.max != null ? opts.max : '100'}'></input>`, + "</div>", + `<div class='drawToolTemplaterLiBody_${type}_step'>`, + `<div>Step: </div>`, + `<input id='drawToolTemplaterLiFieldInput_${idx}_step' type='number' value='${opts.step != null ? opts.step : '1'}'></input>`, + "</div>", + `<div class='drawToolTemplaterLiBody_${type}_required'>`, + `<div title='Required'>Req: </div>`, + `<div class="mmgis-checkbox"><input type="checkbox" ${opts.required === true ? 'checked ' : ''}id="design-number-checkbox-${idx}"/><label for="design-number-checkbox-${idx}"></label></div>`, + "</div>", + "</div>" + ] + break + case 'range': + case 'slider': + // prettier-ignore + typeMarkup = [ + `<div class='drawToolTemplaterLiBody_${type}'>`, + `<div class='drawToolTemplaterLiBody_${type}_default'>`, + `<div>Default: </div>`, + `<input id='drawToolTemplaterLiFieldInput_${idx}_default' type='number' value='${opts.default != null ? opts.default : '0'}'></input>`, + "</div>", + `<div class='drawToolTemplaterLiBody_${type}_min'>`, + `<div>Min: </div>`, + `<input id='drawToolTemplaterLiFieldInput_${idx}_min' type='number' value='${opts.min != null ? opts.min : '0'}'></input>`, + "</div>", + `<div class='drawToolTemplaterLiBody_${type}_max'>`, + `<div>Max: </div>`, + `<input id='drawToolTemplaterLiFieldInput_${idx}_max' type='number' value='${opts.max != null ? opts.max : '100'}'></input>`, + "</div>", + `<div class='drawToolTemplaterLiBody_${type}_step'>`, + `<div>Step: </div>`, + `<input id='drawToolTemplaterLiFieldInput_${idx}_step' type='number' value='${opts.step != null ? opts.step : '1'}'></input>`, + "</div>", + "</div>" + ] + break + case 'text': + // prettier-ignore + typeMarkup = [ + `<div class='drawToolTemplaterLiBody_${type}'>`, + `<div class='drawToolTemplaterLiBody_${type}_default'>`, + `<div>Default: </div>`, + `<input id='drawToolTemplaterLiFieldInput_${idx}_default' placeholder='Default' type='text' value='${opts.default != null ? opts.default : ''}'></input>`, + "</div>", + `<div class='drawToolTemplaterLiBody_${type}_min'>`, + `<div title='Min # of Characters'>Min: </div>`, + `<input id='drawToolTemplaterLiFieldInput_${idx}_min' type='number' value='${opts.minLength != null ? opts.minLength : '0'}'></input>`, + "</div>", + `<div class='drawToolTemplaterLiBody_${type}_max'>`, + `<div title='Max # of Characters'>Max: </div>`, + `<input id='drawToolTemplaterLiFieldInput_${idx}_max' type='number' value='${opts.maxLength != null ? opts.maxLength : '100'}'></input>`, + "</div>", + `<div class='drawToolTemplaterLiBody_${type}_regex'>`, + `<div>Regex: </div>`, + `<input id='drawToolTemplaterLiFieldInput_${idx}_regex' type='text' value='${opts.regex != null ? opts.regex : ''}'></input>`, + "</div>", + `<div class='drawToolTemplaterLiBody_${type}_required'>`, + `<div title='Required'>Req: </div>`, + `<div class="mmgis-checkbox"><input type="checkbox" ${opts.required === true ? 'checked ' : ''}id="design-number-checkbox-${idx}"/><label for="design-number-checkbox-${idx}"></label></div>`, + "</div>", + "</div>" + ] + break + case 'textarea': + // prettier-ignore + typeMarkup = [ + `<div class='drawToolTemplaterLiBody_${type}'>`, + `<div class='drawToolTemplaterLiBody_${type}_default'>`, + `<div>Default: </div>`, + `<input id='drawToolTemplaterLiFieldInput_${idx}_default' placeholder='Default' type='text' value='${opts.default != null ? opts.default : ''}'></input>`, + "</div>", + `<div class='drawToolTemplaterLiBody_${type}_max'>`, + `<div>Max length: </div>`, + `<input id='drawToolTemplaterLiFieldInput_${idx}_max' type='number' value='${opts.maxLength != null ? opts.maxLength : ''}''></input>`, + "</div>", + `<div class='drawToolTemplaterLiBody_${type}_required'>`, + `<div title='Required'>Req: </div>`, + `<div class="mmgis-checkbox"><input type="checkbox" ${opts.required === true ? 'checked ' : ''}id="design-textarea-checkbox-${idx}"/><label for="design-textarea-checkbox-${idx}"></label></div>`, + "</div>", + "</div>" + ] + break + case 'date': + // prettier-ignore + typeMarkup = [ + `<div class='drawToolTemplaterLiBody_${type}'>`, + `<div class='drawToolTemplaterLiBody_${type}_default'>`, + `<div title='Use "NOW", "STARTTIME" and "ENDTIME" for dynamic defaults.'>Default: </div>`, + `<input id='drawToolTemplaterLiFieldInput_${idx}_default' placeholder='Default' type='text' value='${opts.default != null ? opts.default : ''}'></input>`, + "</div>", + `<div class='drawToolTemplaterLiBody_${type}_format'>`, + `<div>Format: </div>`, + `<div id='drawToolTemplaterLiBody_${idx}_format' class='drawToolTemplaterLiBodyDropdown_format ui dropdown short' value='${opts.format != null ? opts.format : DrawTool_Templater._DATE_FORMATS[0]}'></div>`, + "</div>", + `<div class='drawToolTemplaterLiBody_${type}_isStart'>`, + `<div title="Use this field as the feature's Start Time">S<i class='mdi mdi-clock-out mdi-18px'></i>: </div>`, + `<div class="mmgis-checkbox"><input type="checkbox" ${opts.isStart === true ? 'checked ' : ''}id="design-date-checkbox-${idx}-start"/><label for="design-date-checkbox-${idx}-start"></label></div>`, + "</div>", + `<div class='drawToolTemplaterLiBody_${type}_isEnd'>`, + `<div title="Use this field as the feature's End Time">E<i class='mdi mdi-clock-in mdi-18px'></i>: </div>`, + `<div class="mmgis-checkbox"><input type="checkbox" ${opts.isEnd === true ? 'checked ' : ''}id="design-date-checkbox-${idx}-end"/><label for="design-date-checkbox-${idx}-end"></label></div>`, + "</div>", + `<div class='drawToolTemplaterLiBody_${type}_required'>`, + `<div title='Required'>Req: </div>`, + `<div class="mmgis-checkbox"><input type="checkbox" ${opts.required === true ? 'checked ' : ''}id="design-date-checkbox-${idx}"/><label for="design-date-checkbox-${idx}"></label></div>`, + "</div>", + "</div>" + ] + break + case 'incrementer': + // prettier-ignore + typeMarkup = [ + `<div class='drawToolTemplaterLiBody_${type}'>`, + `<div class='drawToolTemplaterLiBody_${type}_default'>`, + `<div>Value with a single '#' to place an incrementing number: </div>`, + `<input id='drawToolTemplaterLiFieldInput_${idx}_default' placeholder='ID-#' type='text' value='${opts.default != null ? opts.default : ''}'></input>`, + "</div>", + "</div>" + ] + break + default: + break + } + + // Add html + $(`#drawToolTemplaterLiBody_${idx}`).html(typeMarkup.join('\n')) + + // Init dropdowns + const f = + opts.format != null + ? opts.format + : DrawTool_Templater._DATE_FORMATS[0] + const initialFormatIndex = Math.max( + DrawTool_Templater._DATE_FORMATS.indexOf(f), + 0 + ) + $(`#drawToolTemplaterLiBody_${idx}_format`).html( + Dropy.construct( + DrawTool_Templater._DATE_FORMATS, + 'Formats', + initialFormatIndex, + { + openUp: false, + dark: true, + } + ) + ) + Dropy.init( + $(`#drawToolTemplaterLiBody_${idx}_format`), + (idx2) => { + $(`#drawToolTemplaterLiBody_${idx}_format`).attr( + 'value', + DrawTool_Templater._DATE_FORMATS[idx2] + ) + } + ) + } + + let initialType = options.type || 'checkbox' + if (initialType === 'range') initialType = 'slider' + + let initialTypeIdx = + DrawTool_Templater._TEMPLATE_TYPES.indexOf(initialType) + $(`#drawToolTemplaterLiTypeDropdown_${idx}`).html( + Dropy.construct( + DrawTool_Templater._TEMPLATE_TYPES, + 'Types', + initialTypeIdx, + { + openUp: false, + dark: true, + } + ) + ) + Dropy.init($(`#drawToolTemplaterLiTypeDropdown_${idx}`), (idx2) => { + setType(idx2) + }) + setType(initialTypeIdx, options) + + DrawTool_Templater._templateInDesignIdx++ + } + + $(`#drawToolTemplaterDesignHeadingAdd`).on('click', () => { + add() + }) + + if ( + (isReadOnly || featureToMakeTemplateFrom != null) && + Array.isArray(templateObj.template) + ) { + templateObj.template.forEach((t) => { + add(t) + }) + } + }, + getDesignedTemplate: function (containerId, reservedTemplates) { + // For if no template is being designed + if (!$(`#${containerId}`).length) { + return true + } + + reservedTemplates = reservedTemplates || {} + const reservedTemplatesNames = ['NONE'].concat( + Object.keys(reservedTemplates) + ) + + const name = $( + `#${containerId} #drawToolTemplaterDesignHeadingNameInput` + ).val() + + const items = [] + const invalids = {} + $(`#${containerId} #drawToolTemplaterDesignContent > li`).each( + function () { + const item = {} + item.field = $(this) + .find('.drawToolTemplaterLiField > input') + .val() + item.type = $(this) + .find( + '.drawToolTemplaterLiType .dropy__content li > a.selected' + ) + .text() + switch (item.type) { + case 'checkbox': + item.default = $(this) + .find('.drawToolTemplaterLiBody_checkbox input') + .prop('checked') + break + case 'dropdown': + item.default = $(this) + .find( + '.drawToolTemplaterLiBody_dropdown_default input' + ) + .val() + item.items = ( + $(this) + .find( + '.drawToolTemplaterLiBody_dropdown_values input' + ) + .val() || '' + ).split(',') + break + case 'number': + item.default = $(this) + .find( + '.drawToolTemplaterLiBody_number_default input' + ) + .val() + if (item.default != '') + item.default = parseFloat(item.default) + item.min = $(this) + .find('.drawToolTemplaterLiBody_number_min input') + .val() + if (item.min != '') item.min = parseFloat(item.min) + item.max = $(this) + .find('.drawToolTemplaterLiBody_number_max input') + .val() + if (item.max != '') item.max = parseFloat(item.max) + item.step = $(this) + .find('.drawToolTemplaterLiBody_number_step input') + .val() + if (item.step != '') item.step = parseFloat(item.step) + item.required = $(this) + .find( + '.drawToolTemplaterLiBody_number_required input' + ) + .prop('checked') + break + case 'slider': + item.default = $(this) + .find( + '.drawToolTemplaterLiBody_slider_default input' + ) + .val() + if (item.default != '') + item.default = parseFloat(item.default) + item.min = $(this) + .find('.drawToolTemplaterLiBody_slider_min input') + .val() + if (item.min != '') item.min = parseFloat(item.min) + item.max = $(this) + .find('.drawToolTemplaterLiBody_slider_max input') + .val() + if (item.max != '') item.max = parseFloat(item.max) + item.step = $(this) + .find('.drawToolTemplaterLiBody_slider_step input') + .val() + if (item.step != '') item.step = parseFloat(item.step) + break + case 'text': + item.default = $(this) + .find('.drawToolTemplaterLiBody_text_default input') + .val() + item.minLength = $(this) + .find('.drawToolTemplaterLiBody_text_min input') + .val() + if (item.minLength != '') + item.minLength = parseFloat(item.minLength) + item.maxLength = $(this) + .find('.drawToolTemplaterLiBody_text_max input') + .val() + if (item.maxLength != '') + item.maxLength = parseFloat(item.maxLength) + item.regex = $(this) + .find('.drawToolTemplaterLiBody_text_regex input') + .val() + item.required = $(this) + .find( + '.drawToolTemplaterLiBody_text_required input' + ) + .prop('checked') + break + case 'textarea': + item.default = $(this) + .find( + '.drawToolTemplaterLiBody_textarea_default input' + ) + .val() + item.maxLength = $(this) + .find('.drawToolTemplaterLiBody_textarea_max input') + .val() + if (item.maxLength != '') + item.maxLength = parseFloat(item.maxLength) + item.required = $(this) + .find( + '.drawToolTemplaterLiBody_textarea_required input' + ) + .prop('checked') + break + case 'date': + item.default = $(this) + .find('.drawToolTemplaterLiBody_date_default input') + .val() + item.format = $(this) + .find('.drawToolTemplaterLiBodyDropdown_format') + .attr('value') + item.isStart = $(this) + .find('.drawToolTemplaterLiBody_date_isStart input') + .prop('checked') + item.isEnd = $(this) + .find('.drawToolTemplaterLiBody_date_isEnd input') + .prop('checked') + item.required = $(this) + .find( + '.drawToolTemplaterLiBody_date_required input' + ) + .prop('checked') + break + case 'incrementer': + item.default = $(this) + .find( + '.drawToolTemplaterLiBody_incrementer_default input' + ) + .val() + + if ( + ((item.default || '').match(/#/g) || []).length != 1 + ) { + invalids[ + item.field + ] = `'${item.field}' must contain exactly one '#' symbol` + } + break + default: + break + } + items.push(item) + } + ) + + const template = { + name: name, + template: items || [], + } + if (template.template.length === 0) { + return true + } + // Validate + if (template.name == null || template.name == '') { + CursorInfo.update( + `Please enter a template name`, + 6000, + true, + { x: 305, y: 6 }, + '#e9ff26', + 'black' + ) + return false + } + if (reservedTemplatesNames.includes(template.name)) { + if ( + !DrawTool_Templater.areTemplatesEqual( + reservedTemplates[template.name], + template.template + ) + ) { + CursorInfo.update( + `Use a different template name. A template by the name '${template.name}' already exists.`, + 6000, + true, + { x: 305, y: 6 }, + '#e9ff26', + 'black' + ) + return false + } + } + + // Only allow one of each: + let hasADateStartTime = false + let hasADateEndTime = false + + for (let i = 0; i < template.template.length; i++) { + const t = template.template[i] + if (t.field == null || t.field == '') { + CursorInfo.update( + `Template cannot contain empty 'Field Names'`, + 6000, + true, + { x: 305, y: 6 }, + '#e9ff26', + 'black' + ) + return false + } + if (t.field == 'uuid') { + CursorInfo.update( + `Template cannot contain the field name 'uuid'`, + 6000, + true, + { x: 305, y: 6 }, + '#e9ff26', + 'black' + ) + return false + } + if (t.type === 'date') { + if (t.isStart && t.isEnd) { + CursorInfo.update( + `Template cannot use same date field as Start Time and End Time.`, + 6000, + true, + { x: 305, y: 6 }, + '#e9ff26', + 'black' + ) + return false + } else if (t.isStart) { + if (hasADateStartTime === false) hasADateStartTime = true + else { + CursorInfo.update( + `Template cannot use multiple date fields as Start Times.`, + 6000, + true, + { x: 305, y: 6 }, + '#e9ff26', + 'black' + ) + return false + } + } else if (t.isEnd) { + if (hasADateEndTime === false) hasADateEndTime = true + else { + CursorInfo.update( + `Template cannot use multiple date fields as End Times.`, + 6000, + true, + { x: 305, y: 6 }, + '#e9ff26', + 'black' + ) + return false + } + } + } + if (t.regex != null) { + try { + new RegExp(t.regex) + } catch (error) { + // no good + CursorInfo.update( + `Template cannot contain invalid regex: ${t.regex}`, + 6000, + true, + { x: 305, y: 6 }, + '#e9ff26', + 'black' + ) + return false + } + } + if (invalids[t.field] != null) { + CursorInfo.update( + `Template field: ${invalids[t.field]}`, + 6000, + true, + { x: 305, y: 6 }, + '#e9ff26', + 'black' + ) + return false + } + } + return template + }, + areTemplatesEqual: function (t1, t2) { + if (t1.length !== t2.length) return false + + for (let i = 0; i < t1.length; i++) { + const tA = t1[i] + const tB = t2[i] + + let keys = Object.keys(tA) + + for (let k = 0; k < keys.length; k++) { + const key = keys[k] + if (tA[key] !== tB[key]) { + if (key === 'required') { + if (tA[key] === true || tB[key] === true) { + return false + } + } else { + if ( + (tA[key] == null && tB[key] == '') || + (tA[key] == '' && tB[key] == null) + ) { + // Okay if null vs '' + } else { + if ( + Array.isArray(tA[key]) && + Array.isArray(tB[key]) && + JSON.stringify(tA[key]) === + JSON.stringify(tB[key]) + ) { + } else return false + } + } + } + } + + // And do the reverse (in case tB has more keys than tA) + keys = Object.keys(tB) + + for (let k = 0; k < keys.length; k++) { + const key = keys[k] + if (tA[key] !== tB[key]) { + if (key === 'required') { + if (tA[key] === true || tB[key] === true) { + return false + } + } else { + if ( + (tA[key] == null && tB[key] == '') || + (tA[key] == '' && tB[key] == null) + ) { + // Okay if null vs '' + } else { + if ( + Array.isArray(tA[key]) && + Array.isArray(tB[key]) && + JSON.stringify(tA[key]) === + JSON.stringify(tB[key]) + ) { + } else return false + } + } + } + } + } + return true + }, + getTemplateDefaults: function (template, layer) { + const defaultProps = {} + + template.forEach((t, idx) => { + if (t.field != null && t.default != null && t.default != '') { + let f = t.field + let v = t.default + switch (t.type) { + case 'incrementer': + const nextIncrement = + DrawTool_Templater._validateIncrement( + t.default, + t, + layer + ) + v = nextIncrement.newValue + break + case 'date': + if (v === 'NOW') + v = moment + .utc(new Date().getTime()) + .format(t.format || 'YYYY-MM-DDTHH:mm:ss') + else if (v === 'STARTTIME') + v = moment + .utc(TimeControl.getStartTime()) + .format(t.format || 'YYYY-MM-DDTHH:mm:ss') + else if (v === 'ENDTIME') + v = moment + .utc(TimeControl.getEndTime()) + .format(t.format || 'YYYY-MM-DDTHH:mm:ss') + break + default: + } + defaultProps[f] = v + } + }) + + return defaultProps + }, +} + +export default DrawTool_Templater diff --git a/src/essence/Tools/Draw/config.json b/src/essence/Tools/Draw/config.json index 16d2c37d..fc5f96c7 100644 --- a/src/essence/Tools/Draw/config.json +++ b/src/essence/Tools/Draw/config.json @@ -12,8 +12,68 @@ "Point_Alias", "All_Alias" ], + "defaultDrawClipping": "over || under || off", "leadsCanEditFileInfo": false, - "hoverLengthOnLines": false + "hoverLengthOnLines": false, + "templates": { + "myTemplate": [ + { + "type": "slider", + "field": "a", + "min": 0, + "max": 100, + "step": 1, + "default": 0 + }, + { + "type": "number", + "field": "b", + "min": 0, + "max": 100, + "step": 1, + "required": true, + "default": 3 + }, + { + "type": "text", + "field": "c", + "minLength": 2, + "maxLength": 4, + "required": true, + "regex": null, + "default": null + }, + { + "type": "textarea", + "field": "d", + "maxLength": 10, + "required": true, + "default": "hi" + }, + { + "type": "checkbox", + "field": "e", + "default": true + }, + { + "type": "dropdown", + "field": "f", + "items": ["Yes", "No", "Maybe"], + "default": "No" + }, + { + "type": "incrementer", + "field": "g", + "default": "ID-#" + }, + { + "type": "date", + "field": "h", + "format": "HH:mm:ss", + "default": "now" + } + ] + } } }, "hasVars": true, diff --git a/src/essence/Tools/Identifier/IdentifierTool.js b/src/essence/Tools/Identifier/IdentifierTool.js index a6d3b9e1..3fee524e 100644 --- a/src/essence/Tools/Identifier/IdentifierTool.js +++ b/src/essence/Tools/Identifier/IdentifierTool.js @@ -30,7 +30,12 @@ var IdentifierTool = { this.MMWebGISInterface = new interfaceWithMMWebGIS() //Get tool variables - this.vars = L_.getToolVars('identifier') + this.varsRaw = L_.getToolVars('identifier') + this.vars = {} + Object.keys(this.varsRaw).forEach((layerName) => { + this.vars[L_.asLayerUUID(layerName)] = this.varsRaw[layerName] + }) + //Probably always 256 this.tileImageWidth = 256 //x y and zoom of mousedover tile @@ -50,6 +55,28 @@ var IdentifierTool = { destroy: function () { this.MMWebGISInterface.separateFromMMWebGIS() }, + //From: https://github.com/mrdoob/three.js/issues/758 mrdoob + getImageData: function (image) { + if (image.width == 0) return + var canvas = document.createElement('canvas') + canvas.width = image.width + canvas.height = image.height + + var context = canvas.getContext('2d') + context.drawImage(image, 0, 0) + + return context.getImageData(0, 0, image.width, image.height) + }, + getPixel: function (imagedata, x, y) { + var position = (x + imagedata.width * y) * 4, + data = imagedata.data + return { + r: data[position], + g: data[position + 1], + b: data[position + 2], + a: data[position + 3], + } + }, idPixelMap: function (e) { IdentifierTool.idPixel(e, [ e.latlng.lng, @@ -88,19 +115,19 @@ var IdentifierTool = { IdentifierTool.activeLayerNames = [] IdentifierTool.activeLayerURLs = [] IdentifierTool.zoomLevels = [] - for (let n in L_.toggledArray) { - if (L_.toggledArray[n] == true) { + for (let n in L_.layers.on) { + if (L_.layers.on[n] == true) { //We only want the tile layers - if (L_.layersNamed[n].type == 'tile') { + if (L_.layers.data[n].type == 'tile') { //Cut the {z}/{x}/{y}.png - var croppedUrl = L_.layersNamed[n].url + var croppedUrl = L_.layers.data[n].url croppedUrl = croppedUrl.substr(0, croppedUrl.length - 15) if (!F_.isUrlAbsolute(croppedUrl)) croppedUrl = L_.missionPath + croppedUrl IdentifierTool.activeLayerURLs.push(croppedUrl) IdentifierTool.activeLayerNames.push(n) IdentifierTool.zoomLevels.push( - L_.layersNamed[n].maxNativeZoom + L_.layers.data[n].maxNativeZoom ) } } @@ -153,9 +180,10 @@ var IdentifierTool = { IdentifierTool.images[i] = new Image() IdentifierTool.images[i].onload = (function (i) { return function () { - IdentifierTool.imageData[i] = F_.getImageData( - IdentifierTool.images[i] - ) + IdentifierTool.imageData[i] = + IdentifierTool.getImageData( + IdentifierTool.images[i] + ) } })(i) IdentifierTool.images[i].onerror = (function (i) { @@ -189,7 +217,7 @@ var IdentifierTool = { var pxRGBA = { r: 0, g: 0, b: 0, a: 0 } if (IdentifierTool.imageData[i]) { - pxRGBA = F_.getPixel( + pxRGBA = IdentifierTool.getPixel( IdentifierTool.imageData[i], IdentifierTool.pxXYs[i].x, IdentifierTool.pxXYs[i].y @@ -262,13 +290,13 @@ var IdentifierTool = { ) } else { if ( - L_.layersLegendsData[IdentifierTool.activeLayerNames[i]] + L_.layers.data[IdentifierTool.activeLayerNames[i]] + ?._legend ) { value = bestMatchInLegend( pxRGBA, - L_.layersLegendsData[ - IdentifierTool.activeLayerNames[i] - ] + L_.layers.data[IdentifierTool.activeLayerNames[i]] + ._legend ) } } @@ -287,7 +315,8 @@ var IdentifierTool = { "<li><div style='width: 14px; height: 14px; float: left; margin-right: 5px; margin-top: 1px; background: " + colorString + ";'></div>" + - IdentifierTool.activeLayerNames[i] + + L_.layers.data[IdentifierTool.activeLayerNames[i]] + .display_name + "<div id='identifierToolIdPixelCursorInfo_" + i + "' style='padding-left: 20px;'>" + @@ -429,7 +458,7 @@ function queryDataValue(url, lng, lat, numBands, callback) { } }, function () { - console.warn('IdentiferTool: Failed to query bands.') + console.warn('IdentifierTool: Failed to query bands.') } ) } diff --git a/src/essence/Tools/Info/InfoTool.js b/src/essence/Tools/Info/InfoTool.js index 2eea6f0d..63a659ff 100644 --- a/src/essence/Tools/Info/InfoTool.js +++ b/src/essence/Tools/Info/InfoTool.js @@ -3,9 +3,6 @@ import * as d3 from 'd3' import F_ from '../../Basics/Formulae_/Formulae_' import L_ from '../../Basics/Layers_/Layers_' import Map_ from '../../Basics/Map_/Map_' -import Globe_ from '../../Basics/Globe_/Globe_' -import Login from '../../Ancillary/Login/Login' -import CursorInfo from '../../Ancillary/CursorInfo' import { Kinds } from '../../../pre/tools' import Dropy from '../../../external/Dropy/dropy' @@ -223,7 +220,7 @@ var InfoTool = { Dropy.init($('#infoToolSelectedDropdown'), function (idx) { let e = JSON.parse(JSON.stringify(InfoTool.initialEvent)) Kinds.use( - L_.layersNamed[InfoTool.currentLayerName].kind, + L_.layers.data[InfoTool.currentLayerName]?.kind || null, Map_, InfoTool.info[idx], InfoTool.featureLayers[idx] || InfoTool.currentLayer, @@ -444,7 +441,9 @@ var InfoTool = { `${keys[i]}:`, '</div>', '<div>', - node[keys[i]], + F_.isValidUrl(node[keys[i]]) ? + `<a href="${node[keys[i]]}" target="_blank">${node[keys[i]]}</a><i class='mdi mdi-open-in-new mdi-14px' style='margin-left: 2px;'></i>` + : node[keys[i]], '</div>', '</li>' ].join('\n')) diff --git a/src/essence/Tools/Isochrone/IsochroneTool.js b/src/essence/Tools/Isochrone/IsochroneTool.js index 5b94f73c..6b7c0941 100644 --- a/src/essence/Tools/Isochrone/IsochroneTool.js +++ b/src/essence/Tools/Isochrone/IsochroneTool.js @@ -1,13 +1,13 @@ -import $ from 'jquery'; -import L_ from '../../Basics/Layers_/Layers_'; -import Map_ from '../../Basics/Map_/Map_'; -import CursorInfo from '../../Ancillary/CursorInfo'; +import $ from 'jquery' +import L_ from '../../Basics/Layers_/Layers_' +import Map_ from '../../Basics/Map_/Map_' +import CursorInfo from '../../Ancillary/CursorInfo' -import IsochroneManager from './IsochroneTool_Manager'; -import models from './models'; +import IsochroneManager from './IsochroneTool_Manager' +import models from './models' -import './IsochroneTool.css'; -const L = window.L; +import './IsochroneTool.css' +const L = window.L /* Handles map events, sidebar management, drawing layers and markers. @@ -15,8 +15,7 @@ Individual isochrones, from data gathering to modeling to analysis, are handled in IsochroneTool_Manager and its imports. */ -const markup = -`<div id="isochroneTool"> +const markup = `<div id="isochroneTool"> <div id="isochroneToolHeader"> <span id="isochroneToolTitle">Isochrone</span> <span id="iscNew"> @@ -25,22 +24,22 @@ const markup = </span> </div> <ul id="isochroneOptionsContainer"></ul> -</div>`; +</div>` //Legacy color mapping function function hueMap(val) { - const hueToChannel = h => { - h = (h + 1530) % 1530; - if (h < 255) return h; - if (h < 765) return 255; - if (h < 1020) return 255 - (h % 255); - return 0; + const hueToChannel = (h) => { + h = (h + 1530) % 1530 + if (h < 255) return h + if (h < 765) return 255 + if (h < 1020) return 255 - (h % 255) + return 0 } - const hue = Math.floor(val * 1050); - const r = hueToChannel(hue + 510); - const g = hueToChannel(hue); - const b = hueToChannel(hue - 510); - return [r, g, b]; + const hue = Math.floor(val * 1050) + const r = hueToChannel(hue + 510) + const g = hueToChannel(hue) + const b = hueToChannel(hue - 510) + return [r, g, b] } //https://leafletjs.com/reference-1.7.1.html#gridlayer @@ -48,58 +47,63 @@ L.IsochroneLayer = L.GridLayer.extend({ //Override to make layer accept Bounds in place of LatLngBounds // (cleaner, supports polar projections better) _isValidTile(coords) { - const bounds = this.options.bounds; - return coords.x >= bounds.min.x - && coords.y >= bounds.min.y - && coords.x < bounds.max.x - && coords.y < bounds.max.y; + const bounds = this.options.bounds + return ( + coords.x >= bounds.min.x && + coords.y >= bounds.min.y && + coords.x < bounds.max.x && + coords.y < bounds.max.y + ) }, - createTile: function(coords) { - const tile = L.DomUtil.create('canvas', 'leaflet-tile'); + createTile: function (coords) { + const tile = L.DomUtil.create('canvas', 'leaflet-tile') - const size = this.getTileSize(); - tile.width = size.x; - tile.height = size.y; + const size = this.getTileSize() + tile.width = size.x + tile.height = size.y - const ctx = tile.getContext('2d'); - const img = ctx.getImageData(0, 0, size.x, size.y); + const ctx = tile.getContext('2d') + const img = ctx.getImageData(0, 0, size.x, size.y) - const bounds = this.options.bounds; - const tXOffset = coords.x - bounds.min.x; - const tYOffset = coords.y - bounds.min.y; + const bounds = this.options.bounds + const tXOffset = coords.x - bounds.min.x + const tYOffset = coords.y - bounds.min.y - const alpha = Math.floor(this.options.opacity * 255); + const alpha = Math.floor(this.options.opacity * 255) - let di = 0; //img data index + let di = 0 //img data index for (let y = 0; y < size.y; y++) { - const yIndex = tYOffset * size.y + y; + const yIndex = tYOffset * size.y + y for (let x = 0; x < size.x; x++) { - const xIndex = tXOffset * size.x + x; - const currentData = this.options.data[yIndex][xIndex]; - if (isFinite(currentData) && currentData <= this.options.maxCost) { + const xIndex = tXOffset * size.x + x + const currentData = this.options.data[yIndex][xIndex] + if ( + isFinite(currentData) && + currentData <= this.options.maxCost + ) { const color = IsochroneTool.valueToColor( currentData / this.options.maxCost, this.options.color, this.options.steps - ); - img.data[di] = color[0]; - img.data[di + 1] = color[1]; - img.data[di + 2] = color[2]; - img.data[di + 3] = alpha; + ) + img.data[di] = color[0] + img.data[di + 1] = color[1] + img.data[di + 2] = color[2] + img.data[di + 3] = alpha } else { - img.data[di] = 0; - img.data[di + 1] = 0; - img.data[di + 2] = 0; - img.data[di + 3] = 0; + img.data[di] = 0 + img.data[di + 1] = 0 + img.data[di + 2] = 0 + img.data[di + 3] = 0 } - di += 4; + di += 4 } } - ctx.putImageData(img, 0, 0); - return tile; - } -}); + ctx.putImageData(img, 0, 0) + return tile + }, +}) //See IsochroneTool_Algorithm.js const backlinkToMove = [ @@ -118,11 +122,8 @@ const backlinkToMove = [ [-1, 0], [-2, 1], [-1, 1], - [-1, 2] -]; - - - + [-1, 2], +] const IsochroneTool = { height: 0, @@ -144,80 +145,91 @@ const IsochroneTool = { //https://developers.arcgis.com/javascript/latest/visualization/symbols-color-ramps/esri-color-ramps/ colorRamps: [ - [ //Red 5 + [ + //Red 5 [254, 229, 217], [252, 187, 161], [252, 106, 74], [222, 45, 38], - [165, 15, 21] + [165, 15, 21], ], - [ //Orange 4 + [ + //Orange 4 [255, 255, 178], [254, 204, 92], [253, 141, 60], [240, 59, 32], - [189, 0, 38] + [189, 0, 38], ], - [ //Green 1 + [ + //Green 1 [237, 248, 233], [186, 228, 179], [116, 196, 118], [49, 163, 84], - [0, 109, 44] + [0, 109, 44], ], - [ //Blue 4 + [ + //Blue 4 [240, 249, 232], [186, 228, 188], [123, 204, 196], [67, 162, 202], - [8, 104, 172] + [8, 104, 172], ], - [ //Purple 4 + [ + //Purple 4 [237, 248, 251], [179, 205, 227], [140, 150, 198], [136, 86, 167], - [129, 15, 124] - ] + [129, 15, 124], + ], ], - initialize: function() { - this.vars = L_.getToolVars('isochrone'); - const globalIS = this.vars.interpolateSeams !== false; + initialize: function () { + this.vars = L_.getToolVars('isochrone') + const globalIS = this.vars.interpolateSeams !== false //add info for scaling low-res tiles for (const dataType in this.vars.data) { - const lcDataType = dataType.toLowerCase(); - this.dataSources[lcDataType] = []; + const lcDataType = dataType.toLowerCase() + this.dataSources[lcDataType] = [] for (const src of this.vars.data[dataType]) { - const {name, tileurl, minZoom, maxNativeZoom, resolution} = src; - - const sourceIS = src.interpolateSeams; - const interpolateSeams = sourceIS === undefined ? globalIS : sourceIS; + const { name, tileurl, minZoom, maxNativeZoom, resolution } = + src - let zoomOffset = null; + const sourceIS = src.interpolateSeams + const interpolateSeams = + sourceIS === undefined ? globalIS : sourceIS + + let zoomOffset = null switch (resolution) { case 256: - zoomOffset = 0; - break; + zoomOffset = 0 + break case 128: - zoomOffset = 1; - break; + zoomOffset = 1 + break case 64: - zoomOffset = 2; - break; + zoomOffset = 2 + break case 32: - zoomOffset = 3; - break; + zoomOffset = 3 + break case undefined: - console.warn(`IsochroneTool: ${dataType} source "${name}" has no defined resolution!`); - break; + console.warn( + `IsochroneTool: ${dataType} source "${name}" has no defined resolution!` + ) + break default: - console.warn(`IsochroneTool: ${dataType} source "${name}" has nonstandard resolution: ${resolution}!`); + console.warn( + `IsochroneTool: ${dataType} source "${name}" has nonstandard resolution: ${resolution}!` + ) } - const minResolution = Math.max(minZoom - zoomOffset, 0); - const maxResolution = maxNativeZoom - zoomOffset; + const minResolution = Math.max(minZoom - zoomOffset, 0) + const maxResolution = maxNativeZoom - zoomOffset if (zoomOffset !== null) { //Data source interface @@ -230,44 +242,45 @@ const IsochroneTool = { minResolution, //number maxResolution, //number zoomOffset, //number - interpolateSeams //boolean - }); + interpolateSeams, //boolean + }) } } } if (this.vars.models) { - const lcModelNames = this.vars.models.map(m => m.toLowerCase()); - const modelIndex = m => lcModelNames.indexOf(m.nameString.toLowerCase()); - this.enabledModels = models.filter(m => modelIndex(m) > -1); - this.enabledModels.sort((a, b) => modelIndex(a) - modelIndex(b)); + const lcModelNames = this.vars.models.map((m) => m.toLowerCase()) + const modelIndex = (m) => + lcModelNames.indexOf(m.nameString.toLowerCase()) + this.enabledModels = models.filter((m) => modelIndex(m) > -1) + this.enabledModels.sort((a, b) => modelIndex(a) - modelIndex(b)) } else { - this.enabledModels = models.filter(m => m.enabledByDefault); + this.enabledModels = models.filter((m) => m.enabledByDefault) } }, - make: function() { - this.MMGISInterface = new interfaceWithMMGIS(); + make: function () { + this.MMGISInterface = new interfaceWithMMGIS() - $('#iscNew').on('click', () => this.addIsochrone()); - this.containerEl = $('#isochroneOptionsContainer'); - this.addIsochrone(); + $('#iscNew').on('click', () => this.addIsochrone()) + this.containerEl = $('#isochroneOptionsContainer') + this.addIsochrone() }, - destroy: function() { - for (const {marker, layerName} of this.managers) { - Map_.rmNotNull(marker); - Map_.rmNotNull(L_.layersGroup[layerName]); + destroy: function () { + for (const { marker, layerName } of this.managers) { + Map_.rmNotNull(marker) + Map_.rmNotNull(L_.layers.layer[layerName]) } if (this.hoverPolyline !== null) { - this.hoverPolyline.remove(Map_.map); + this.hoverPolyline.remove(Map_.map) } - this.managers = []; - this.activeManager = null; - this.managerCounter = 0; - this.MMGISInterface.separateFromMMGIS(); + this.managers = [] + this.activeManager = null + this.managerCounter = 0 + this.MMGISInterface.separateFromMMGIS() }, /** @@ -277,110 +290,115 @@ const IsochroneTool = { * @param {number} steps Optional number of discrete color steps to apply to the ramp * @returns {number[]} Array `[r, g, b]` of color channels */ - valueToColor: function(val, rampIndex, steps = 0) { - val = Math.min(val, 1); + valueToColor: function (val, rampIndex, steps = 0) { + val = Math.min(val, 1) if (steps) { - val = Math.floor(val * steps) / steps; + val = Math.floor(val * steps) / steps } - const ramp = this.colorRamps[rampIndex]; - const color = val * (ramp.length - 1); - const i = Math.min(Math.floor(color), ramp.length - 2); - const off = color % 1; - const getChan = chan => Math.floor(ramp[i][chan] * (1 - off) + ramp[i + 1][chan] * off); - return [getChan(0), getChan(1), getChan(2)]; + const ramp = this.colorRamps[rampIndex] + const color = val * (ramp.length - 1) + const i = Math.min(Math.floor(color), ramp.length - 2) + const off = color % 1 + const getChan = (chan) => + Math.floor(ramp[i][chan] * (1 - off) + ramp[i + 1][chan] * off) + return [getChan(0), getChan(1), getChan(2)] }, /** Create canvases for use in color ramp dropdown */ - makeGradientEls: function() { - const C_WIDTH = 120, C_HEIGHT = 25; - const numRamps = this.colorRamps.length; - let colorEls = []; + makeGradientEls: function () { + const C_WIDTH = 120, + C_HEIGHT = 25 + const numRamps = this.colorRamps.length + let colorEls = [] for (let i = 0; i < numRamps; i++) { - let canvas = document.createElement('canvas'); - canvas.width = C_WIDTH; - canvas.height = C_HEIGHT; - let ctx = canvas.getContext('2d'); - let image = ctx.getImageData(0, 0, C_WIDTH, C_HEIGHT); - let data = image.data; + let canvas = document.createElement('canvas') + canvas.width = C_WIDTH + canvas.height = C_HEIGHT + let ctx = canvas.getContext('2d') + let image = ctx.getImageData(0, 0, C_WIDTH, C_HEIGHT) + let data = image.data for (let x = 0; x < C_WIDTH; x++) { - const color = this.valueToColor(x / C_WIDTH, i); + const color = this.valueToColor(x / C_WIDTH, i) for (let y = 0; y < C_HEIGHT; y++) { - const di = (y * C_WIDTH * 4) + (x * 4); - data[di] = color[0]; - data[di + 1] = color[1]; - data[di + 2] = color[2]; - data[di + 3] = 255; + const di = y * C_WIDTH * 4 + x * 4 + data[di] = color[0] + data[di + 1] = color[1] + data[di + 2] = color[2] + data[di + 3] = 255 } } - ctx.putImageData(image, 0, 0); - colorEls.push(canvas); + ctx.putImageData(image, 0, 0) + colorEls.push(canvas) } - return colorEls; + return colorEls }, - managerOnChange: function(manager) { - this.makeMarker(manager); - manager.marker.dragging.enable(); - this.makeDataLayer(manager); + managerOnChange: function (manager) { + this.makeMarker(manager) + manager.marker.dragging.enable() + this.makeDataLayer(manager) }, - managerOnFocus: function(manager) { - if (this.activeManager === manager) return; + managerOnFocus: function (manager) { + if (this.activeManager === manager) return if (this.activeManager !== null) { - this.activeManager.unfocus(); + this.activeManager.unfocus() } - this.activeManager = manager; - this.activeManager.focus(); + this.activeManager = manager + this.activeManager.focus() }, - managerOnDelete: function(manager) { - manager.optionEls.root.remove(); - Map_.rmNotNull(L_.layersGroup[manager.layerName]); - Map_.rmNotNull(manager.marker); + managerOnDelete: function (manager) { + manager.optionEls.root.remove() + Map_.rmNotNull(L_.layers.layer[manager.layerName]) + Map_.rmNotNull(manager.marker) - const managerIndex = this.managers.indexOf(manager); - this.managers.splice(managerIndex, 1); + const managerIndex = this.managers.indexOf(manager) + this.managers.splice(managerIndex, 1) if (this.activeManager === manager) { if (this.managers.length === 0) { - this.activeManager = null; + this.activeManager = null } else { - const newIndex = Math.min(managerIndex, this.managers.length - 1); - this.activeManager = this.managers[newIndex]; - this.activeManager.focus(); + const newIndex = Math.min( + managerIndex, + this.managers.length - 1 + ) + this.activeManager = this.managers[newIndex] + this.activeManager.focus() } } }, - addIsochrone: function() { + addIsochrone: function () { const newManager = new IsochroneManager( this.managerCounter + 1, this.dataSources, this.enabledModels, - {color: this.managerCounter % this.colorRamps.length} - ); - this.managerCounter++; + { color: this.managerCounter % this.colorRamps.length } + ) + this.managerCounter++ - newManager.onChange = () => this.managerOnChange(newManager); - newManager.onFocus = () => this.managerOnFocus(newManager); - newManager.onDelete = () => this.managerOnDelete(newManager); + newManager.onChange = () => this.managerOnChange(newManager) + newManager.onFocus = () => this.managerOnFocus(newManager) + newManager.onDelete = () => this.managerOnDelete(newManager) - this.managers.push(newManager); + this.managers.push(newManager) - const optionsEl = newManager.makeElement(this.makeGradientEls()); - this.containerEl.append(optionsEl); - this.managerOnFocus(newManager); + const optionsEl = newManager.makeElement(this.makeGradientEls()) + this.containerEl.append(optionsEl) + this.managerOnFocus(newManager) - return newManager; + return newManager }, /** Create an isochrone data layer for a given isochrone manager */ - makeDataLayer: function(manager) { - const {layerName, cost, tileBounds, options} = manager; + makeDataLayer: function (manager) { + const { layerName, cost, tileBounds, options } = manager - Map_.rmNotNull(L_.layersGroup[layerName]); + Map_.rmNotNull(L_.layers.layer[layerName]) - if (!manager.options.visible) return; + if (!manager.options.visible) return - L_.layersGroup[layerName] = new L.IsochroneLayer({ + L_.layers.layer[layerName] = new L.IsochroneLayer({ className: 'nofade', //Borrowed from viewshed... but is it actually doing anything? minZoom: Math.min(options.resolution, Map_.map.getMinZoom()), maxZoom: Map_.map.getMaxZoom(), @@ -392,54 +410,49 @@ const IsochroneTool = { color: options.color, maxCost: options.maxCost, steps: options.steps, - data: cost - }); + data: cost, + }) - L_.layersGroup[layerName].setZIndex(1000); - Map_.map.addLayer(L_.layersGroup[layerName]); + L_.layers.layer[layerName].setZIndex(1000) + Map_.map.addLayer(L_.layers.layer[layerName]) }, /** Create a start point marker for a given isochrone manager */ - makeMarker: function(manager) { //ViewshedTool.js, function viewshed - const {start, options} = manager; - let canvas = document.createElement('canvas'); - canvas.width = 16; - canvas.height = 16; - let ctx = canvas.getContext('2d'); + makeMarker: function (manager) { + //ViewshedTool.js, function viewshed + const { start, options } = manager + let canvas = document.createElement('canvas') + canvas.width = 16 + canvas.height = 16 + let ctx = canvas.getContext('2d') const radius = 7 const strokeWeight = 2 - const ramp = IsochroneTool.colorRamps[options.color]; - const c = ramp[ramp.length - 1]; + const ramp = IsochroneTool.colorRamps[options.color] + const c = ramp[ramp.length - 1] - ctx.fillStyle = `rgba(${c[0]}, ${c[1]}, ${c[2]}, 255)`; + ctx.fillStyle = `rgba(${c[0]}, ${c[1]}, ${c[2]}, 255)` - ctx.strokeStyle = 'rgba(255, 255, 255, 255)'; - ctx.beginPath(); - ctx.arc( - canvas.width / 2, - canvas.height / 2, - radius, - 0, - 2 * Math.PI - ); + ctx.strokeStyle = 'rgba(255, 255, 255, 255)' + ctx.beginPath() + ctx.arc(canvas.width / 2, canvas.height / 2, radius, 0, 2 * Math.PI) - ctx.fill(); - ctx.lineWidth = strokeWeight; - ctx.stroke(); - ctx.strokeStyle = 'rgba(0, 0, 0, 255)'; - ctx.beginPath(); + ctx.fill() + ctx.lineWidth = strokeWeight + ctx.stroke() + ctx.strokeStyle = 'rgba(0, 0, 0, 255)' + ctx.beginPath() ctx.arc( canvas.width / 2, canvas.height / 2, radius - strokeWeight, 0, 2 * Math.PI - ); + ) - ctx.fill(); - ctx.lineWidth = strokeWeight; - ctx.stroke(); + ctx.fill() + ctx.lineWidth = strokeWeight + ctx.stroke() let isochroneIcon = L.icon({ iconUrl: canvas.toDataURL(), @@ -448,141 +461,157 @@ const IsochroneTool = { popupAnchor: [-3, -76], shadowSize: [68, 95], shadowAnchor: [22, 94], - }); - - Map_.rmNotNull(manager.marker); - manager.marker = new L.marker([start.lat, start.lng], {icon: isochroneIcon}); - - manager.marker.on('click', e => this.managerOnFocus(manager)); - manager.marker.on('dragend', e => { - manager.marker.dragging.disable(); - manager.start = e.target._latlng; - manager.setBounds(); - this.managerOnFocus(manager); - }); - - manager.marker.addTo(Map_.map); + }) + + Map_.rmNotNull(manager.marker) + manager.marker = new L.marker([start.lat, start.lng], { + icon: isochroneIcon, + }) + + manager.marker.on('click', (e) => this.managerOnFocus(manager)) + manager.marker.on('dragend', (e) => { + manager.marker.dragging.disable() + manager.start = e.target._latlng + manager.setBounds() + this.managerOnFocus(manager) + }) + + manager.marker.addTo(Map_.map) }, //Click event handler - handleClick: function(e) { + handleClick: function (e) { if (e && e.latlng && this.activeManager.currentStage < 4) { - this.activeManager.start = e.latlng; - this.makeMarker(this.activeManager); - this.activeManager.setBounds(); + this.activeManager.start = e.latlng + this.makeMarker(this.activeManager) + this.activeManager.setBounds() } }, //Mouse move event handler - handleMouseMove: function(e) { - const MAX_STEPS = 5000; - const manager = this.activeManager; - - if (!e || !manager || !manager.backlink || manager.currentStage > 0 || !manager.options.visible) { - return; + handleMouseMove: function (e) { + const MAX_STEPS = 5000 + const manager = this.activeManager + + if ( + !e || + !manager || + !manager.backlink || + manager.currentStage > 0 || + !manager.options.visible + ) { + return } - const now = Date.now(); - if (this.lastHoverCall + 65 > now) return; - this.lastHoverCall = now; + const now = Date.now() + if (this.lastHoverCall + 65 > now) return + this.lastHoverCall = now - Map_.rmNotNull(this.hoverPolyline); + Map_.rmNotNull(this.hoverPolyline) const toLinePoint = (x, y) => { const point = manager.tileBounds.min .multiplyBy(256) - .add([x + 0.5, y + 0.5]); - const latlng = Map_.map.unproject(point, manager.options.resolution); - return [latlng.lat, latlng.lng]; + .add([x + 0.5, y + 0.5]) + const latlng = Map_.map.unproject(point, manager.options.resolution) + return [latlng.lat, latlng.lng] } - let hoveredPx, width, height, startVal = 0; + let hoveredPx, + width, + height, + startVal = 0 if (e.latlng) { hoveredPx = Map_.map .project(e.latlng, manager.options.resolution) .subtract(manager.tileBounds.min.multiplyBy(256)) - .floor(); - width = manager.backlink[0].length; - height = manager.backlink.length; - if (hoveredPx.x >= 0 && hoveredPx.y >= 0 && hoveredPx.x < width && hoveredPx.y < height) { - startVal = manager.backlink[hoveredPx.y][hoveredPx.x]; + .floor() + width = manager.backlink[0].length + height = manager.backlink.length + if ( + hoveredPx.x >= 0 && + hoveredPx.y >= 0 && + hoveredPx.x < width && + hoveredPx.y < height + ) { + startVal = manager.backlink[hoveredPx.y][hoveredPx.x] } } if (startVal !== 0) { - this.hovered = true; - const hoveredCost = manager.cost[hoveredPx.y][hoveredPx.x]; - const tooltipMsg = manager.modelProto.costToString(hoveredCost); - CursorInfo.update(tooltipMsg, null, false); - - let cx = hoveredPx.x; - let cy = hoveredPx.y; - let step = startVal; - let line = [toLinePoint(cx, cy)]; - let lastStep = 0; - let count = 0; + this.hovered = true + const hoveredCost = manager.cost[hoveredPx.y][hoveredPx.x] + const tooltipMsg = manager.modelProto.costToString(hoveredCost) + CursorInfo.update(tooltipMsg, null, false) + + let cx = hoveredPx.x + let cy = hoveredPx.y + let step = startVal + let line = [toLinePoint(cx, cy)] + let lastStep = 0 + let count = 0 while (step !== 0 && count < MAX_STEPS) { - let move = backlinkToMove[step - 1]; - cx += move[1]; - cy += move[0]; - if(step === lastStep) { //Extend line - line[line.length - 1] = toLinePoint(cx, cy); - } else { //Begin new line - line.push(toLinePoint(cx, cy)); + let move = backlinkToMove[step - 1] + cx += move[1] + cy += move[0] + if (step === lastStep) { + //Extend line + line[line.length - 1] = toLinePoint(cx, cy) + } else { + //Begin new line + line.push(toLinePoint(cx, cy)) } - lastStep = step; - step = manager.backlink[cy][cx]; - count++; + lastStep = step + step = manager.backlink[cy][cx] + count++ } - this.hoverPolyline = L.polyline(line, {interactive: false}); - this.hoverPolyline.addTo(Map_.map); + this.hoverPolyline = L.polyline(line, { interactive: false }) + this.hoverPolyline.addTo(Map_.map) } else if (this.hovered) { - this.hovered = false; - CursorInfo.hide(); + this.hovered = false + CursorInfo.hide() } }, //Mouse out event container - handleMouseOut: function(e) { + handleMouseOut: function (e) { if (this.hovered) { - this.hovered = false; - Map_.rmNotNull(this.hoverPolyline); - CursorInfo.hide(); + this.hovered = false + Map_.rmNotNull(this.hoverPolyline) + CursorInfo.hide() } - } + }, } - - function interfaceWithMMGIS() { - this.separateFromMMGIS = function() { + this.separateFromMMGIS = function () { separateFromMMGIS() } - const tools = $('#toolPanel'); - tools.empty(); + const tools = $('#toolPanel') + tools.empty() const toolContainer = $('<div></div>') .attr('class', 'center aligned ui padded grid') - .css({'height': '100%'}); + .css({ height: '100%' }) tools.append(toolContainer) - toolContainer.html(markup); + toolContainer.html(markup) - const clickEventContainer = e => IsochroneTool.handleClick(e); - Map_.map.on('click', clickEventContainer); + const clickEventContainer = (e) => IsochroneTool.handleClick(e) + Map_.map.on('click', clickEventContainer) - const moveEventContainer = e => IsochroneTool.handleMouseMove(e); - Map_.map.on('mousemove', moveEventContainer); + const moveEventContainer = (e) => IsochroneTool.handleMouseMove(e) + Map_.map.on('mousemove', moveEventContainer) - const outEventContainer = e => IsochroneTool.handleMouseOut(e); - Map_.map.on('mouseout', outEventContainer); + const outEventContainer = (e) => IsochroneTool.handleMouseOut(e) + Map_.map.on('mouseout', outEventContainer) //Share everything. Don't take things that aren't yours. // Put things back where you found them. function separateFromMMGIS() { - Map_.map.off('click', clickEventContainer); - Map_.map.off('mousemove', moveEventContainer); - Map_.map.off('mouseout', outEventContainer); + Map_.map.off('click', clickEventContainer) + Map_.map.off('mousemove', moveEventContainer) + Map_.map.off('mouseout', outEventContainer) } } -export default IsochroneTool; +export default IsochroneTool diff --git a/src/essence/Tools/Kinds/Kinds.js b/src/essence/Tools/Kinds/Kinds.js index 1eb41bb5..b15afc22 100644 --- a/src/essence/Tools/Kinds/Kinds.js +++ b/src/essence/Tools/Kinds/Kinds.js @@ -20,8 +20,8 @@ var Kinds = { if (typeof kind !== 'string') return let layerVar = {} - if (L_.layersNamed[layer.options.layerName]) - layerVar = L_.layersNamed[layer.options.layerName].variables || {} + if (L_.layers.data[layer.options.layerName]) + layerVar = L_.layers.data[layer.options.layerName].variables || {} // Remove temp layers Map_.rmNotNull(Map_.tempOverlayImage) @@ -369,10 +369,11 @@ var Kinds = { if (e.latlng && e.latlng.lng != null && e.latlng.lat != null) { if ( - typeof L_.layersGroup[layerName].eachLayer !== - 'function' + typeof L_.layers.layer[layerName].eachLayer !== + 'function' && + layerName.indexOf('DrawTool_') != 0 ) { - L_.layersGroup[layerName].eachLayer = function (cb) { + L_.layers.layer[layerName].eachLayer = function (cb) { for (var v in this._vectorTiles) { for (var l in this._vectorTiles[v]._layers) { cb(this._vectorTiles[v]._layers[l]) @@ -380,18 +381,72 @@ var Kinds = { } } } - features = L.leafletPip - .pointInLayer( - [e.latlng.lng, e.latlng.lat], - L_.layersGroup[layerName] - ) - .concat( - F_.pointsInPoint( - [e.latlng.lng, e.latlng.lat], - L_.layersGroup[layerName] + + // To better intersect points on click we're going to buffer out a small bounding box + const mapRect = document + .getElementById('map') + .getBoundingClientRect() + + const wOffset = e.containerPoint?.x || mapRect.width / 2 + const hOffset = e.containerPoint?.y || mapRect.height / 2 + + let nwLatLong = Map_.map.containerPointToLatLng([ + wOffset - 15, + hOffset - 15, + ]) + let seLatLong = Map_.map.containerPointToLatLng([ + wOffset + 15, + hOffset + 15, + ]) + // If we didn't have a container click point, buffer out e.latlng + if (e.containerPoint == null) { + const lngDif = + Math.abs(nwLatLong.lng - seLatLong.lng) / 2 + const latDif = + Math.abs(nwLatLong.lat - seLatLong.lat) / 2 + nwLatLong = { + lng: e.latlng.lng - lngDif, + lat: e.latlng.lat - latDif, + } + seLatLong = { + lng: e.latlng.lng + lngDif, + lat: e.latlng.lat + latDif, + } + } + + // Find all the intersected points and polygons of the click + Object.keys(L_.layers.layer).forEach((lName) => { + if ( + (L_.layers.on[lName] && + (L_.layers.data[lName].type === 'vector' || + L_.layers.data[lName].type === 'query') && + L_.layers.layer[lName]) || + (lName.indexOf('DrawTool_') === 0 && + L_.layers.layer[lName]?.[0]?._map != null) + ) { + features = features.concat( + L.leafletPip + .pointInLayer( + [e.latlng.lng, e.latlng.lat], + L_.layers.layer[lName] + ) + .concat( + F_.pointsInPoint( + [e.latlng.lng, e.latlng.lat], + L_.layers.layer[lName], + [ + nwLatLong.lng, + seLatLong.lng, + nwLatLong.lat, + seLatLong.lat, + ] + ) + ) + .reverse() ) - ) - .reverse() + } + }) + if (features[0] == null) features = [feature] else { const swapFeatures = [] diff --git a/src/essence/Tools/Layers/Filtering/Filtering.js b/src/essence/Tools/Layers/Filtering/Filtering.js index ce06b82f..d9e2b705 100644 --- a/src/essence/Tools/Layers/Filtering/Filtering.js +++ b/src/essence/Tools/Layers/Filtering/Filtering.js @@ -21,7 +21,7 @@ const Filtering = { current: {}, mapSpatialLayer: null, make: async function (container, layerName) { - const layerObj = L_.layersNamed[layerName] + const layerObj = L_.layers.data[layerName] if (layerObj == null) return @@ -43,7 +43,7 @@ const Filtering = { try { Filtering.filters[layerName].geojson = Filtering.filters[layerName].geojson || - L_.layersGroup[layerName].toGeoJSON(L_.GEOJSON_PRECISION) + L_.layers.layer[layerName].toGeoJSON(L_.GEOJSON_PRECISION) } catch (err) { console.warn( `Filtering - Cannot find GeoJSON to filter on for layer: ${layerName}` diff --git a/src/essence/Tools/Layers/Filtering/LocalFilterer.js b/src/essence/Tools/Layers/Filtering/LocalFilterer.js index 5e0f5b20..f6692065 100644 --- a/src/essence/Tools/Layers/Filtering/LocalFilterer.js +++ b/src/essence/Tools/Layers/Filtering/LocalFilterer.js @@ -9,7 +9,7 @@ import { booleanIntersects, booleanContains } from '@turf/turf' const LocalFilterer = { make: function (container, layerName) { - const layerObj = L_.layersNamed[layerName] + const layerObj = L_.layers.data[layerName] if (layerObj == null) return diff --git a/src/essence/Tools/Layers/LayerInfoModal/LayerInfoModal.css b/src/essence/Tools/Layers/LayerInfoModal/LayerInfoModal.css index a3f57d2a..1fcf9207 100644 --- a/src/essence/Tools/Layers/LayerInfoModal/LayerInfoModal.css +++ b/src/essence/Tools/Layers/LayerInfoModal/LayerInfoModal.css @@ -114,6 +114,12 @@ padding-bottom: 8px; background: var(--color-a1-5); } +#LayerInfoModalInnerUUID { + padding: 4px 30px; + text-align: right; + font-size: 11px; + color: var(--color-a2); +} .LayerInfoModalTag { color: black; diff --git a/src/essence/Tools/Layers/LayerInfoModal/LayerInfoModal.js b/src/essence/Tools/Layers/LayerInfoModal/LayerInfoModal.js index ffbce2bc..0004d066 100644 --- a/src/essence/Tools/Layers/LayerInfoModal/LayerInfoModal.js +++ b/src/essence/Tools/Layers/LayerInfoModal/LayerInfoModal.js @@ -10,7 +10,7 @@ showdown.setFlavor('github') const LayerInfo = { converter: new showdown.Converter(), open: function (layerName) { - const layer = L_.layersNamed[layerName] + const layer = L_.layers.data[layerName] if (layer == null) return @@ -18,7 +18,7 @@ const LayerInfo = { if (layer.type === 'vector') try { numberOfFeatures = ` (${ - L_.layersGroup[layerName].getLayers().length + L_.layers.layer[layerName].getLayers().length } Features)` } catch (e) {} @@ -37,7 +37,7 @@ const LayerInfo = { `<div id='LayerInfoModalClose'><i class='mmgisHoverBlue mdi mdi-close mdi-18px'></i></div>`, `</div>`, `<div id='LayerInfoModalContent'>`, - `<div id='LayerInfoModalInnerTitle'>${title}: ${layer.name}</div>`, + `<div id='LayerInfoModalInnerTitle'>${title}: ${layer.display_name}</div>`, `<div id='LayerInfoModalInnerSubtitle'>${type}<span>${numberOfFeatures}</span></div>`, layer.tags && layer.tags.length > 0 ? @@ -66,6 +66,7 @@ const LayerInfo = { layer.description ? LayerInfo.converter.makeHtml(layer.description) : `<div class='LayerInfoModalNone'>No Description</div>`, `</div>`, `</div>`, + `<div id='LayerInfoModalInnerUUID'>${layer.uuid}</div>`, `</div>`, `</div>` ].join('\n'), diff --git a/src/essence/Tools/Layers/LayersTool.css b/src/essence/Tools/Layers/LayersTool.css index 89a1342f..c4e02d19 100644 --- a/src/essence/Tools/Layers/LayersTool.css +++ b/src/essence/Tools/Layers/LayersTool.css @@ -197,6 +197,19 @@ list-style-type: none; padding: 0; margin: 0; +} +#layersTool .settings .layerSettingsTitle { + display: flex; + height: 30px; + line-height: 30px; +} +#layersTool .settings .layerSettingsTitle > div:first-child { + color: var(--color-h); + text-transform: uppercase; + font-size: 12px; +} +#layersTool .settings .layerSettingsTitle > div:last-child { + } #layersTool .settings ul > li { line-height: 30px; @@ -276,10 +289,12 @@ padding: 2px 6px 2px 12px; } +#layersTool .reload, #layersTool .reset, #layersTool .layerDownload, #layersTool .gears, -#layersTool .LayersToolInfo { +#layersTool .LayersToolInfo, +#layersTool .time { width: 30px; height: 100%; text-align: center; @@ -289,18 +304,21 @@ transition: color 0.2s cubic-bezier(0.445, 0.05, 0.55, 0.95), background 0.2s cubic-bezier(0.445, 0.05, 0.55, 0.95); } - +#layersTool .reload, #layersTool .layerDownload, #layersTool .gears, #layersTool .LayersToolInfo { color: transparent; } -#layersTool .reset:hover, +#layersTool .reload:hover, #layersTool .layerDownload:hover, #layersTool .gears:hover, #layersTool .LayersToolInfo:hover { background: var(--color-k); } +#layersTool .reset:hover { + color: white; +} #layersTool .reset { display: none; } @@ -312,6 +330,7 @@ #layersTool li.download_on .layerDownload, #layersTool li:hover .layerDownload, #layersTool li.gears_on .gears, +#layersTool li:hover .reload, #layersTool li:hover .gears, #layersTool li:hover .LayersToolInfo { color: #fff; diff --git a/src/essence/Tools/Layers/LayersTool.js b/src/essence/Tools/Layers/LayersTool.js index ccbd96da..d3fb2015 100644 --- a/src/essence/Tools/Layers/LayersTool.js +++ b/src/essence/Tools/Layers/LayersTool.js @@ -175,7 +175,7 @@ function interfaceWithMMGIS(fromInit) { let headerI = 0 //This is where the layers list is created in the tool panel. - depthTraversal(L_.layers, {}, 0) + depthTraversal(L_.configData.layers, {}, 0) function depthTraversal(node, parent, depth) { for (var i = 0; i < node.length; i++) { @@ -251,14 +251,14 @@ function interfaceWithMMGIS(fromInit) { case 'tile': currentOpacity = L_.getLayerOpacity(node[i].name) if (currentOpacity == null) - currentOpacity = L_.opacityArray[node[i].name] + currentOpacity = L_.layers.opacity[node[i].name] currentBrightness = 1 currentContrast = 1 currentSaturation = 1 currentBlend = 'none' - if (L_.layerFilters[node[i].name]) { - let f = L_.layerFilters[node[i].name] + if (L_.layers.filters[node[i].name]) { + let f = L_.layers.filters[node[i].name] currentBrightness = f['brightness'] == null @@ -284,7 +284,7 @@ function interfaceWithMMGIS(fromInit) { '<li>', '<div>', '<div>Opacity</div>', - '<input class="transparencyslider slider2" layername="' + node[i].name + '" type="range" min="0" max="1" step="0.01" value="' + currentOpacity + '" default="' + L_.opacityArray[node[i].name] + '">', + '<input class="transparencyslider slider2" layername="' + node[i].name + '" type="range" min="0" max="1" step="0.01" value="' + currentOpacity + '" default="' + L_.layers.opacity[node[i].name] + '">', '</div>', '</li>', '<li>', @@ -348,11 +348,11 @@ function interfaceWithMMGIS(fromInit) { case 'data': currentOpacity = L_.getLayerOpacity(node[i].name) if (currentOpacity == null) - currentOpacity = L_.opacityArray[node[i].name] + currentOpacity = L_.layers.opacity[node[i].name] currentBlend = 'none' - if (L_.layerFilters[node[i].name]) { - let f = L_.layerFilters[node[i].name] + if (L_.layers.filters[node[i].name]) { + let f = L_.layers.filters[node[i].name] currentBlend = f['mix-blend-mode'] == null @@ -376,7 +376,7 @@ function interfaceWithMMGIS(fromInit) { '<li>', '<div>', '<div>Opacity</div>', - '<input class="transparencyslider slider2" layername="' + node[i].name + '" type="range" min="0" max="1" step="0.01" value="' + currentOpacity + '" default="' + L_.opacityArray[node[i].name] + '">', + '<input class="transparencyslider slider2" layername="' + node[i].name + '" type="range" min="0" max="1" step="0.01" value="' + currentOpacity + '" default="' + L_.layers.opacity[node[i].name] + '">', '</div>', '</li>', '<li>', @@ -401,7 +401,7 @@ function interfaceWithMMGIS(fromInit) { '<li>', '<div>', '<div>Opacity</div>', - '<input class="transparencyslider slider2" layername="' + node[i].name + '" type="range" min="0" max="1" step="0.01" value="' + currentOpacity + '" default="' + L_.opacityArray[node[i].name] + '">', + '<input class="transparencyslider slider2" layername="' + node[i].name + '" type="range" min="0" max="1" step="0.01" value="' + currentOpacity + '" default="' + L_.layers.opacity[node[i].name] + '">', '</div>', '</li>', '</ul>', @@ -425,8 +425,8 @@ function interfaceWithMMGIS(fromInit) { '<div>', '<i class="headerChevron mdi mdi-chevron-down mdi-24px"></i>', '</div>', - `<div class="layerName" title="${node[i].name}">`, - node[i].name, + `<div class="layerName" title="${node[i].display_name}">`, + node[i].display_name, '</div>', '<div class="layerCount">', (node[i].sublayers ? node[i].sublayers.length : '0'), @@ -446,32 +446,34 @@ function interfaceWithMMGIS(fromInit) { // prettier-ignore $('#layersToolList').append( [ - '<li id="LayersTool' + F_.getSafeName(node[i].name) + '" class="' + ((!quasiLayers.includes(node[i].type) && L_.layersGroup[node[i].name] == null) ? 'layernotfound' : '') + '" type="' + node[i].type + '" on="true" depth="' + depth + '" name="' + node[i].name + '" parent="' + parent.name + '" style="margin-bottom: 1px;">', + '<li id="LayersTool' + F_.getSafeName(node[i].name) + '" class="' + ((!quasiLayers.includes(node[i].type) && L_.layers.layer[node[i].name] == null) ? 'layernotfound' : '') + '" type="' + node[i].type + '" on="true" depth="' + depth + '" name="' + node[i].name + '" parent="' + parent.name + '" style="margin-bottom: 1px;">', `<div class="title" id="layerstart${F_.getSafeName(node[i].name)}" style="border-left: ${depth * DEPTH_SIZE}px solid ${INDENT_COLOR};">`, '<div class="layersToolColor ' + node[i].type + '">', '<i class="mdi mdi-drag-vertical mdi-12px"></i>', '</div>', '<div class="checkboxcont">', - '<div class="checkbox ' + (L_.toggledArray[node[i].name] ? 'on' : 'off') + '"></div>', + '<div class="checkbox ' + (L_.layers.on[node[i].name] ? 'on' : 'off') + '"></div>', '</div>', - `<div class="layerName" title="${node[i].name}">`, - node[i].name, + `<div class="layerName" title="${node[i].display_name}">`, + node[i].display_name, '</div>', - '<div class="reset">', + node[i].type === 'vector' ? + ['<div class="reload" title="Reload Layer">', '<i class="mdi mdi-refresh mdi-18px"></i>', - '</div>', + '</div>'].join('\n') + : null, (layerExport != '') ? ['<div title="Download" class="layerDownload" id="layerexport' + F_.getSafeName(node[i].name) + '" stype="' + node[i].type + '" layername="' + node[i].name + '">', '<i class="mdi mdi-download mdi-18px" name="layerexport"></i>', '</div>'].join('\n') : '', - (timeDisplay != '') ? ['<div class="time" id="timesettings' + F_.getSafeName(node[i].name) + '" stype="' + node[i].type + '" layername="' + node[i].name + '">', - '<i class="mdi mdi-clock mdi-18px" name="timesettings" style="color:' + node[i].time.status + '"></i>', - '</div>'].join('\n') : '', '<div title="Settings" class="gears" id="layersettings' + F_.getSafeName(node[i].name) + '" stype="' + node[i].type + '" layername="' + node[i].name + '">', '<i class="mdi mdi-tune mdi-18px" name="layersettings"></i>', '</div>', '<div title="Information" class="LayersToolInfo" id="layerinfo' + F_.getSafeName(node[i].name) + '" stype="' + node[i].type + '" layername="' + node[i].name + '">', '<i class="mdi mdi-information-outline mdi-18px" name="layerinfo"></i>', '</div>', + (timeDisplay != '') ? ['<div class="time" id="timesettings' + F_.getSafeName(node[i].name) + '" stype="' + node[i].type + '" layername="' + node[i].name + '">', + '<i class="mdi mdi-clock mdi-18px" name="timesettings" style="color:' + node[i].time.status + '"></i>', + '</div>'].join('\n') : '', '</div>', '<div class="layerExport ' + node[i].type + '">', layerExport, @@ -480,6 +482,12 @@ function interfaceWithMMGIS(fromInit) { timeDisplay, '</div>', '<div class="settings settingsmain' + node[i].type + '">', + '<div class="layerSettingsTitle">', + '<div>Layer Settings</div>', + '<div class="reset" title="Reset Settings">', + '<i class="mdi mdi-restore mdi-18px"></i>', + '</div>', + '</div>', settings, '</div>', '</li>', @@ -514,25 +522,24 @@ function interfaceWithMMGIS(fromInit) { const layerName = li.attr('name') checkbox.addClass('loading') - await L_.toggleLayer(L_.layersNamed[layerName]) + await L_.toggleLayer(L_.layers.data[layerName]) checkbox.removeClass('loading') if ( quasiLayers.includes(li.attr('type')) || - L_.layersGroup[layerName] + L_.layers.layer[layerName] ) checkbox.toggleClass('on') else if ( !quasiLayers.includes(li.attr('type')) && - L_.layersGroup[layerName] == null + L_.layers.layer[layerName] == null ) li.addClass('layernotfound') if (checkbox.hasClass('on')) { if ( - L_.layersGroupSublayers[layerName] && - Object.keys(L_.layersGroupSublayers[layerName]).length > - 0 && + L_.layers.attachments[layerName] && + Object.keys(L_.layers.attachments[layerName]).length > 0 && !$( `#LayersTool${F_.getSafeName( layerName @@ -555,9 +562,9 @@ function interfaceWithMMGIS(fromInit) { // Dispatch `layerVisibilityChange` event let _event = new CustomEvent('layerVisibilityChange', { detail: { - layer: L_.layersNamed[layerName], + layer: L_.layers.data[layerName], layerName, - visible: L_.toggledArray[layerName], + visible: L_.layers.on[layerName], }, }) document.dispatchEvent(_event) @@ -623,7 +630,7 @@ function interfaceWithMMGIS(fromInit) { if (stillUnder && $(item).attr('depth') > elmDepth) { // Save state and then turn off if ( - L_.toggledArray[$(item).attr('name')] && + L_.layers.on[$(item).attr('name')] && $(item).attr('type') !== 'header' ) { LayersTool._header_states[name].push( @@ -715,32 +722,52 @@ function interfaceWithMMGIS(fromInit) { //Export GeoJSON $('.layersToolExportGeoJSON').on('click', function () { - var li = $(this).parent().parent().parent().parent() + const li = $(this).parent().parent().parent().parent() - let layerName = li.attr('name') + const layerUUID = li.attr('name') + const layerDisplayName = + L_.layers.data[layerUUID]?.display_name || layerUUID F_.downloadObject( L_.convertGeoJSONLngLatsToPrimaryCoordinates( - L_.layersGroup[layerName].toGeoJSON(L_.GEOJSON_PRECISION) + L_.layers.layer[layerUUID].toGeoJSON(L_.GEOJSON_PRECISION) ), - layerName, + layerDisplayName, '.json' ) }) //Export Source GeoJSON $('.layersToolExportSourceGeoJSON').on('click', function () { - var li = $(this).parent().parent().parent().parent() + const li = $(this).parent().parent().parent().parent() - let layerName = li.attr('name') + const layerUUID = li.attr('name') + const layerDisplayName = + L_.layers.data[layerUUID]?.display_name || layerUUID F_.downloadObject( - L_.layersGroup[layerName].toGeoJSON(L_.GEOJSON_PRECISION), - layerName, + L_.layers.layer[layerUUID].toGeoJSON(L_.GEOJSON_PRECISION), + layerDisplayName, '.json' ) }) + //Refresh settings + $('.reload').on('click', function () { + const li = $(this).parent().parent() + let layer = li.attr('name') + layer = L_.asLayerUUID(layer) + layer = L_.layers.data[layer] + if (L_.layers.layer[layer.name] === null) return + + if (layer.type === 'tile') { + } else { + if (layer.controlled !== true) + try { + Map_.refreshLayer(layer) + } catch (err) {} + } + }) //Refresh settings $('.reset').on('click', function () { - var li = $(this).parent().parent() + const li = $(this).parent().parent().parent() L_.setLayerOpacity(li.attr('name'), 1) li.find('.transparencyslider').val(1) @@ -777,8 +804,8 @@ function interfaceWithMMGIS(fromInit) { }) let tags = [] - Object.keys(L_.layersNamed).forEach((l) => { - if (L_.layersNamed[l].tags) tags = tags.concat(L_.layersNamed[l].tags) + Object.keys(L_.layers.data).forEach((l) => { + if (L_.layers.data[l].tags) tags = tags.concat(L_.layers.data[l].tags) }) // Remove duplicates tags = tags.filter((c, idx) => { @@ -870,7 +897,7 @@ function interfaceWithMMGIS(fromInit) { }) const layerName = $(that).attr('name') - const layerObj = L_.layersNamed[layerName] + const layerObj = L_.layers.data[layerName] if (layerObj) { //Look at description @@ -1179,7 +1206,8 @@ function interfaceWithMMGIS(fromInit) { function getVectorLayerSettings(layerName) { let currentOpacity = L_.getLayerOpacity(layerName) - if (currentOpacity == null) currentOpacity = L_.opacityArray[layerName] + if (currentOpacity == null) + currentOpacity = L_.layers.opacity[layerName] // prettier-ignore return [ @@ -1187,23 +1215,23 @@ function interfaceWithMMGIS(fromInit) { '<li>', '<div>', '<div>Opacity</div>', - '<input class="transparencyslider slider2" layername="' + layerName + '" type="range" min="0" max="1" step="0.01" value="' + currentOpacity + '" default="' + L_.opacityArray[layerName] + '">', + '<input class="transparencyslider slider2" layername="' + layerName + '" type="range" min="0" max="1" step="0.01" value="' + currentOpacity + '" default="' + L_.layers.opacity[layerName] + '">', '</div>', - L_.layersGroupSublayers[layerName] ? `<div class="sublayerHeading">Composite Layers</div>` : null, - L_.layersGroupSublayers[layerName] ? Object.keys(L_.layersGroupSublayers[layerName]).map(function(s) { - return L_.layersGroupSublayers[layerName][s] === false ? '' : [ + L_.layers.attachments[layerName] ? `<div class="sublayerHeading">Composite Layers</div>` : null, + L_.layers.attachments[layerName] ? Object.keys(L_.layers.attachments[layerName]).map(function(s) { + return L_.layers.attachments[layerName][s] === false ? '' : [ '<div class="sublayer">', - `<div title="${L_.layersGroupSublayers[layerName][s].title || ''}">${F_.prettifyName(s)}</div>`, + `<div title="${L_.layers.attachments[layerName][s].title || ''}">${F_.prettifyName(s)}</div>`, '<div style="display: flex;">', - L_.layersGroupSublayers[layerName][s].layer?.dropdown ? [ + L_.layers.attachments[layerName][s].layer?.dropdown ? [ `<select class="dropdown sublayerDropdown" layername="${layerName}" sublayername="${s}">`, - L_.layersGroupSublayers[layerName][s].layer?.dropdown.map((d) => - `<option value="${d}"${(d === L_.layersGroupSublayers[layerName][s].layer?.dropdownValue ? ' selected' : '')}>${d}</option>` + L_.layers.attachments[layerName][s].layer?.dropdown.map((d) => + `<option value="${d}"${(d === L_.layers.attachments[layerName][s].layer?.dropdownValue ? ' selected' : '')}>${d}</option>` ).join('\n'), '</select>' ].join('\n') : null, '<div class="checkboxcont">', - `<div class="checkbox small ${(L_.layersGroupSublayers[layerName][s].on ? 'on' : 'off')}" layername="${layerName}" sublayername="${s}" style="margin: 7px 0px 7px 10px;"></div>`, + `<div class="checkbox small ${(L_.layers.attachments[layerName][s].on ? 'on' : 'off')}" layername="${layerName}" sublayername="${s}" style="margin: 7px 0px 7px 10px;"></div>`, '</div>', '</div>', '</div>' @@ -1236,10 +1264,10 @@ function interfaceWithMMGIS(fromInit) { $(this).val() if ( - L_.layersGroupSublayers[layerName] && - L_.layersGroupSublayers[layerName][sublayerName] + L_.layers.attachments[layerName] && + L_.layers.attachments[layerName][sublayerName] ) { - const l = L_.layersGroupSublayers[layerName][sublayerName] + const l = L_.layers.attachments[layerName][sublayerName] l.layer.dropdownFunc( layerName, sublayerName, @@ -1260,10 +1288,10 @@ function interfaceWithMMGIS(fromInit) { await L_.toggleSublayer(layerName, sublayerName) if ( - L_.layersGroupSublayers[layerName] && - L_.layersGroupSublayers[layerName][sublayerName] + L_.layers.attachments[layerName] && + L_.layers.attachments[layerName][sublayerName] ) { - if (L_.layersGroupSublayers[layerName][sublayerName].on) + if (L_.layers.attachments[layerName][sublayerName].on) $(this).addClass('on') else $(this).removeClass('on') } diff --git a/src/essence/Tools/Legend/LegendTool.js b/src/essence/Tools/Legend/LegendTool.js index dc7260f3..16fd0afa 100644 --- a/src/essence/Tools/Legend/LegendTool.js +++ b/src/essence/Tools/Legend/LegendTool.js @@ -11,14 +11,42 @@ var LegendTool = { width: 200, activeLayerNames: null, MMWebGISInterface: null, - make: function () { + targetId: null, + made: false, + displayOnStart: false, + justification: 'left', + initialize: function () { + //Get tool variables + this.displayOnStart = L_.getToolVars('legend')['displayOnStart'] + this.justification = L_.getToolVars('legend')['justification'] + if (this.justification == 'right') { + var toolController = d3.select('#toolcontroller_sepdiv') + var toolContent = d3.select('#toolContentSeparated_Legend') + toolController.style('top', '110px') + toolController.style('left', null) + toolController.style('right', '5px') + toolContent.style('left', null) + toolContent.style('right', '0px') + } + }, + make: function (targetId) { + this.targetId = targetId this.MMWebGISInterface = new interfaceWithMMWebGIS() - this.activeLayerNames = [] + + L_.subscribeOnLayerToggle('LegendTool', () => { + this.MMWebGISInterface = new interfaceWithMMWebGIS() + }) + + this.made = true }, destroy: function () { this.MMWebGISInterface.separateFromMMWebGIS() + this.targetId = null + L_.unsubscribeOnLayerToggle('LegendTool') + this.made = false }, + overwriteLegends: overwriteLegends, } // @@ -26,22 +54,94 @@ function interfaceWithMMWebGIS() { this.separateFromMMWebGIS = function () { separateFromMMWebGIS() } + separateFromMMWebGIS() + + let tools = drawLegendHeader() + + //Add the markup to tools or do it manually + //tools.html( markup ); + + //Add event functions and whatnot + //Draw legends + var first = true + for (let l in L_.layers.on) { + if (L_.layers.on[l] == true) { + if (L_.layers.data[l].type != 'header') { + if (L_.layers.data[l]?._legend != undefined) { + drawLegends( + tools, + L_.layers.data[l]?._legend, + l, + L_.layers.data[l].display_name, + L_.layers.opacity[l] + ) + } + } + } + } + + //Share everything. Don't take things that aren't yours. + // Put things back where you found them. + function separateFromMMWebGIS() { + let tools = d3.select( + LegendTool.targetId ? `#${LegendTool.targetId}` : '#toolPanel' + ) + tools.style('background', 'var(--color-k)') + //Clear it + tools.selectAll('*').remove() + } +} + +// The legends parameter should be an array of objects, where each object must contain +// the following keys: legend, layerUUID, display_name, opacity. +// The value for the legend key should be in the same format as what is stored in the +// layers data under the `_legend` key (i.e. `L_.layers.data[layerName]._legend`). +// layerUUID and display_name should be strings and opacity should be a number between 0 and 1. +function overwriteLegends(legends) { + if (!Array.isArray(legends)) { + console.warn('legends parameter must be an array.', legends) + return + } + + if (legends.length < 1) { + console.warn('legends array is empty.', legends) + return + } + + var tools = drawLegendHeader() + for (let l in legends) { + const { legend, layerUUID, display_name, opacity } = legends[l] + if (!legend || !layerUUID || !display_name || !opacity) { + console.warn('Unable to overwrite legends in LegendTool.', legends) + return + } + drawLegends(tools, legend, layerUUID, display_name, opacity) + } +} + +function drawLegendHeader() { //MMWebGIS should always have a div with id 'tools' - var tools = d3.select('#toolPanel') + let tools = d3.select( + LegendTool.targetId ? `#${LegendTool.targetId}` : '#toolPanel' + ) tools.style('background', 'var(--color-k)') //Clear it tools.selectAll('*').remove() tools .append('div') - .style('height', '40px') - .style('line-height', '40px') - .style('font-size', '16px') - .style('padding-left', '6px') + .style('height', '30px') + .style('line-height', '30px') + .style('font-size', '13px') + .style('padding-right', '8px') + .style('padding-left', '30px') .style('color', 'var(--color-l)') - .style('background', 'var(--color-a)') + .style('background', 'var(--color-i)') .style('font-family', 'lato-light') .style('text-transform', 'uppercase') + .style('border-top-left-radius', '3px') + .style('border-top-right-radius', '3px') + .style('border-bottom', '1px solid var(--color-i)') .html('Legend') //Add a semantic container tools = tools @@ -49,175 +149,125 @@ function interfaceWithMMWebGIS() { .attr('id', 'LegendTool') .style('color', '#dcdcdc') .style('height', 'calc(100% - 40px)') + .style('max-height', 'calc(100vh - 185px)') + .style('border-bottom-left-radius', '3px') + .style('border-bottom-right-radius', '3px') .style('overflow-y', 'auto') - //Add the markup to tools or do it manually - //tools.html( markup ); + return tools +} - //Add event functions and whatnot - //Draw legends - var first = true - for (let l in L_.toggledArray) { - if (L_.toggledArray[l] == true) { - if (L_.layersNamed[l].type != 'header') { - if (L_.layersLegends[l] != undefined) { - var c = tools - .append('div') - .attr('class', 'mmgisScrollbar') - .style('width', '100%') - .style('display', 'inline-block') - .style('padding-top', '5px') - .style('border-top', '1px solid var(--color-i)') - first = false - c.append('div') - .attr('class', 'row') - .append('p') - .style('font-size', '16px') - .style('color', 'var(--color-f)') - .style('margin-bottom', '5px') - .style('padding-left', '10px') - .html(l) +function drawLegends(tools, _legend, layerUUID, display_name, opacity) { + var c = tools + .append('div') + .attr('class', 'mmgisScrollbar') + .style('width', '100%') + .style('display', 'inline-block') + .style('padding-top', '5px') + .style('padding-right', '12px') + .style('border-bottom', '1px solid var(--color-i)') - let lastContinues = [] - let lastShape = '' - for (let d in L_.layersLegendsData[l]) { - var shape = L_.layersLegendsData[l][d].shape - if ( - shape == 'circle' || - shape == 'square' || - shape == 'rect' || - shape == 'triangle' - ) { - // finalize discreet and continuous - if (lastContinues.length > 0) { - pushScale(lastContinues) - lastContinues = [] - } + c.append('div') + .attr('class', 'row') + .append('p') + .style('font-size', '13px') + .style('color', 'var(--color-f)') + .style('margin-bottom', '5px') + .style('padding-left', '8px') + .text(display_name) - var r = c - .append('div') - .attr('class', 'row') - .style('display', 'flex') - .style('margin', '0px 0px 10px 10px') - var svg = r - .append('svg') - .attr('width', '20px') - .attr('height', '20px') + let lastContinues = [] + let lastShape = '' + for (let d in _legend) { + var shape = _legend[d].shape + if ( + shape == 'circle' || + shape == 'square' || + shape == 'rect' || + shape == 'triangle' + ) { + // finalize discreet and continuous + if (lastContinues.length > 0) { + pushScale(lastContinues) + lastContinues = [] + } + + var r = c + .append('div') + .attr('class', 'row') + .style('display', 'flex') + .style('margin', '0px 0px 8px 9px') - switch (shape) { - case 'circle': - svg.append('circle') - .attr('class', l + '_legendshape') - .attr('r', 7) - .attr('cx', 10) - .attr('cy', 10) - .attr( - 'fill', - L_.layersLegendsData[l][d].color - ) - .attr('opacity', L_.opacityArray[l]) - .attr( - 'stroke', - L_.layersLegendsData[l][d] - .strokecolor - ) - break - case 'square': - svg.append('rect') - .attr('class', l + '_legendshape') - .attr('width', 20) - .attr('height', 20) - .attr( - 'fill', - L_.layersLegendsData[l][d].color - ) - .attr('opacity', L_.opacityArray[l]) - .attr( - 'stroke', - L_.layersLegendsData[l][d] - .strokecolor - ) - break - case 'rect': - svg.append('rect') - .attr('class', l + '_legendshape') - .attr('width', 20) - .attr('height', 10) - .attr('y', 5) - .attr( - 'fill', - L_.layersLegendsData[l][d].color - ) - .attr('opacity', L_.opacityArray[l]) - .attr( - 'stroke', - L_.layersLegendsData[l][d] - .strokecolor - ) - break - case 'triangle': - var trianglePoints = '0 0, 10 20, 20 0' - svg.append('polyline') - .attr('class', l + '_legendshape') - .attr('width', 20) - .attr('height', 20) - .attr('points', trianglePoints) - .attr( - 'fill', - L_.layersLegendsData[l][d].color - ) - .attr('opacity', L_.opacityArray[l]) - .attr( - 'stroke', - L_.layersLegendsData[l][d] - .strokecolor - ) - break - } - svg.append(shape).attr( - 'fill', - L_.layersLegendsData[l][d].color - ) - r.append('div') - .style('margin-left', '5px') - .style('height', '100%') - .style('line-height', '21px') - .style('font-size', '14px') - .style('overflow', 'auto') - .html(L_.layersLegendsData[l][d].value) - } else if ( - shape == 'continuous' || - shape == 'discreet' - ) { - if (lastShape != shape) { - if (lastContinues.length > 0) { - pushScale(lastContinues) - lastContinues = [] - } - } - lastContinues.push({ - color: L_.layersLegendsData[l][d].color, - shape: shape, - value: L_.layersLegendsData[l][d].value, - }) - lastShape = shape - } - } - if (lastContinues.length > 0) { - pushScale(lastContinues) - lastContinues = [] - } + switch (shape) { + case 'circle': + r.append('div') + .attr('class', layerUUID + '_legendshape') + .style('width', '18px') + .style('height', '18px') + .style('background', _legend[d].color) + .style('opacity', opacity) + .style('border', `1px solid ${_legend[d].strokecolor}`) + .style('border-radius', '50%') + break + case 'square': + r.append('div') + .attr('class', layerUUID + '_legendshape') + .style('width', '18px') + .style('height', '18px') + .style('background', _legend[d].color) + .style('opacity', opacity) + .style('border', `1px solid ${_legend[d].strokecolor}`) + break + case 'rect': + r.append('div') + .attr('class', layerUUID + '_legendshape') + .style('width', '18px') + .style('height', '8px') + .style('margin', '5px 0px 5px 0px') + .style('background', _legend[d].color) + .style('opacity', opacity) + .style('border', `1px solid ${_legend[d].strokecolor}`) + break + default: + } + + r.append('div') + .style('margin-left', '5px') + .style('height', '100%') + .style('line-height', '19px') + .style('font-size', '14px') + .style('overflow', 'hidden') + .style('white-space', 'nowrap') + .style('max-width', '270px') + .style('text-overflow', 'ellipsis') + .attr('title', _legend[d].value) + .text(_legend[d].value) + } else if (shape == 'continuous' || shape == 'discreet') { + if (lastShape != shape) { + if (lastContinues.length > 0) { + pushScale(lastContinues) + lastContinues = [] } } + lastContinues.push({ + color: _legend[d].color, + shape: shape, + value: _legend[d].value, + }) + lastShape = shape } } + if (lastContinues.length > 0) { + pushScale(lastContinues) + lastContinues = [] + } function pushScale(lastContinues) { var r = c .append('div') .attr('class', 'row') .style('display', 'flex') - .style('margin', '0px 0px 10px 10px') + .style('margin', '0px 0px 8px 8px') var gradient = r .append('div') .style('width', '19px') @@ -233,7 +283,8 @@ function interfaceWithMMWebGIS() { .style('line-height', '19px') .style('font-size', '14px') .style('position', 'relative') - .html(lastContinues[i].value) + .style('white-space', 'nowrap') + .text(lastContinues[i].value) if (lastContinues[i].shape == 'continuous') { v.append('div') @@ -280,10 +331,6 @@ function interfaceWithMMWebGIS() { 'linear-gradient(to bottom, ' + gradientArray.join(',') + ')' ) } - - //Share everything. Don't take things that aren't yours. - // Put things back where you found them. - function separateFromMMWebGIS() {} } //Other functions diff --git a/src/essence/Tools/Legend/config.json b/src/essence/Tools/Legend/config.json index 38a6beb7..2a14f923 100644 --- a/src/essence/Tools/Legend/config.json +++ b/src/essence/Tools/Legend/config.json @@ -1,10 +1,17 @@ { - "defaultIcon": "format-list-bulleted-type", + "defaultIcon": "map-legend", "description": "Show a chart mapping colors and symbols to meaning.", - "descriptionFull": "", - "hasVars": false, + "descriptionFull": { + "title": "Show a chart legend that maps colors and symbols to meaning.", + "example": { + "displayOnStart": true, + "justification": "right" + } + }, + "hasVars": true, "name": "Legend", "toolbarPriority": 2, + "separatedTool": true, "paths": { "LegendTool": "essence/Tools/Legend/LegendTool" } diff --git a/src/essence/Tools/Measure/MeasureTool.js b/src/essence/Tools/Measure/MeasureTool.js index 848c9abc..3cf08557 100644 --- a/src/essence/Tools/Measure/MeasureTool.js +++ b/src/essence/Tools/Measure/MeasureTool.js @@ -10,7 +10,7 @@ import calls from '../../../pre/calls' import metricsGraphics from '../../../external/MetricsGraphics/metricsgraphics.min' -import ReactDOM from 'react-dom' +import {render, unmountComponentAtNode } from 'react-dom' import React, { useState, useEffect, useRef } from 'react' import { Chart } from 'chart.js' @@ -622,10 +622,10 @@ let MeasureTool = { this.dems = MeasureTool.getDems() this.activeDemIdx = 0 - ReactDOM.render(<Measure />, document.getElementById('tools')) + render(<Measure />, document.getElementById('tools')) }, destroy: function () { - ReactDOM.unmountComponentAtNode(document.getElementById('tools')) + unmountComponentAtNode(document.getElementById('tools')) Map_.map .off('click', MeasureTool.clickMap) @@ -678,7 +678,7 @@ let MeasureTool = { dems.push({ name: 'Main', path: MeasureTool.vars.dem }) if (MeasureTool.vars.layerDems) for (let name in MeasureTool.vars.layerDems) { - if (!onlyShowDemIfLayerOn || L_.toggledArray[name]) + if (!onlyShowDemIfLayerOn || L_.layers.on[name]) dems.push({ name: name, path: MeasureTool.vars.layerDems[name], diff --git a/src/essence/Tools/Viewshed/ViewshedTool.js b/src/essence/Tools/Viewshed/ViewshedTool.js index 77bdec63..7a1779d8 100644 --- a/src/essence/Tools/Viewshed/ViewshedTool.js +++ b/src/essence/Tools/Viewshed/ViewshedTool.js @@ -498,14 +498,14 @@ let ViewshedTool = { ).hasClass('on') const layerName = 'viewshed' + id if (isOn) { - if (L_.layersGroup[layerName]) - Map_.map.addLayer(L_.layersGroup[layerName]) + if (L_.layers.layer[layerName]) + Map_.map.addLayer(L_.layers.layer[layerName]) if (ViewshedTool.shedMarkers[id]) Map_.map.addLayer(ViewshedTool.shedMarkers[id]) if (ViewshedTool.shedWedges[id]) Map_.map.addLayer(ViewshedTool.shedWedges[id]) } else { - Map_.rmNotNull(L_.layersGroup[layerName]) + Map_.rmNotNull(L_.layers.layer[layerName]) Map_.rmNotNull(ViewshedTool.shedMarkers[id]) Map_.rmNotNull(ViewshedTool.shedWedges[id]) } @@ -1270,11 +1270,11 @@ let ViewshedTool = { function makeDataLayer(layerUrl, activeElmId, dlc) { let layerName = 'viewshed' + activeElmId - Map_.rmNotNull(L_.layersGroup[layerName]) + Map_.rmNotNull(L_.layers.layer[layerName]) let uniforms = {} - L_.layersGroup[layerName] = L.tileLayer.gl({ + L_.layers.layer[layerName] = L.tileLayer.gl({ options: { tms: false, className: 'nofade', @@ -1286,13 +1286,13 @@ let ViewshedTool = { uniforms: uniforms, tileUrlsAsDataUrls: true, }) - L_.layersGroup[layerName].setZIndex(1000) + L_.layers.layer[layerName].setZIndex(1000) $( '#vstViewsheds #vstId_' + activeElmId + ' .vstShedHeader .checkbox' ).addClass('on') - Map_.map.addLayer(L_.layersGroup[layerName]) + Map_.map.addLayer(L_.layers.layer[layerName]) Globe_.litho.removeLayer(layerName) } @@ -1384,10 +1384,10 @@ let ViewshedTool = { }, delete: function (activeElmId) { $('#vstId_' + activeElmId).remove() - Map_.rmNotNull(L_.layersGroup['viewshed' + activeElmId]) + Map_.rmNotNull(L_.layers.layer['viewshed' + activeElmId]) Map_.rmNotNull(ViewshedTool.shedMarkers[activeElmId]) Map_.rmNotNull(ViewshedTool.shedWedges[activeElmId]) - L_.layersGroup['viewshed' + activeElmId] = null + L_.layers.layer['viewshed' + activeElmId] = null ViewshedTool.shedMarkers[activeElmId] = null ViewshedTool.shedWedges[activeElmId] = null ViewshedTool.canvases[activeElmId] = null diff --git a/src/essence/Tools/_OLD/Query/QueryTool.js b/src/essence/Tools/_OLD/Query/QueryTool.js index 89ba660d..0807a310 100644 --- a/src/essence/Tools/_OLD/Query/QueryTool.js +++ b/src/essence/Tools/_OLD/Query/QueryTool.js @@ -154,7 +154,7 @@ let QueryTool = { thisDrawing.firstDrawing = false if (thisDrawing.drawingType === 'point') { - Map_.rmNotNull(L_.layersGroup['QueryToolPointBuffer']) + Map_.rmNotNull(L_.layers.layer['QueryToolPointBuffer']) if (radius == null) { radius = F_.lngLatDistBetween( @@ -168,7 +168,7 @@ let QueryTool = { radius *= F_.getEarthToPlanetRatio() - thisDrawing.drawingPoly = L_.layersGroup[ + thisDrawing.drawingPoly = L_.layers.layer[ 'QueryToolPointBuffer' ] = L.geoJson( { @@ -1512,18 +1512,19 @@ function interfaceWithMMGIS() { 1.55 // Max line data - let maxData = [ - { - x: 0, - y: - max - - 0.05, - }, - { - x: max_X, - y: -1, - }, - ] + let maxData = + [ + { + x: 0, + y: + max - + 0.05, + }, + { + x: max_X, + y: -1, + }, + ] d3.select( '#mat-graph-' + @@ -1648,18 +1649,19 @@ function interfaceWithMMGIS() { 1.55 // Min line data - let minData = [ - { - x: 0, - y: - max - - 0.05, - }, - { - x: min_X, - y: -1, - }, - ] + let minData = + [ + { + x: 0, + y: + max - + 0.05, + }, + { + x: min_X, + y: -1, + }, + ] d3.select( '#mat-graph-' + @@ -2103,7 +2105,8 @@ function interfaceWithMMGIS() { // The following code block removes duplicate items from an array $(function () { - let availableInputs = [] + let availableInputs = + [] // Remove duplicate elements in the array $.each( @@ -2310,7 +2313,7 @@ function interfaceWithMMGIS() { // remove the drawn layer if exists if (sec[sec.length - 1] === 'adjust') { QueryTool.Draw._radiusPoints = [] - Map_.rmNotNull(L_.layersGroup['QueryToolPointBuffer']) + Map_.rmNotNull(L_.layers.layer['QueryToolPointBuffer']) } if ( @@ -3614,7 +3617,7 @@ function interfaceWithMMGIS() { let pointCoords = function () { // console.log(QueryTool.Draw._radiusPoints); - // console.log(QueryTool.drawingPoly = L_.layersGroup['QueryToolPointBuffer']); + // console.log(QueryTool.drawingPoly = L_.layers.layer['QueryToolPointBuffer']); if ( QueryTool.Draw._radiusPoints[0] !== undefined @@ -3622,12 +3625,10 @@ function interfaceWithMMGIS() { // Set the query run flag to true runQuery = true return { - lng: - QueryTool.Draw - ._radiusPoints[0].lng, - lat: - QueryTool.Draw - ._radiusPoints[0].lat, + lng: QueryTool.Draw + ._radiusPoints[0].lng, + lat: QueryTool.Draw + ._radiusPoints[0].lat, } } else { // Set the query run flag to false diff --git a/src/essence/Tools/_OLD/Search/SearchTool.js b/src/essence/Tools/_OLD/Search/SearchTool.js index b2d9a8d2..82e30a2e 100644 --- a/src/essence/Tools/_OLD/Search/SearchTool.js +++ b/src/essence/Tools/_OLD/Search/SearchTool.js @@ -72,10 +72,10 @@ function interfaceWithMMWebGIS() { var first = true for (l in SearchTool.searchFields) { if ( - L_.layersNamed[l] && - (L_.layersNamed[l].type == 'vector' || - L_.layersNamed[l].type == 'vectortile') && - L_.toggledArray[l] + L_.layers.data[l] && + (L_.layers.data[l].type == 'vector' || + L_.layers.data[l].type == 'vectortile') && + L_.layers.on[l] ) { d3.select('#searchToolType') .append('option') @@ -114,12 +114,12 @@ function initializeSearch() { source: function (request, response) { var re = $.ui.autocomplete.escapeRegex(request.term) var matcher = new RegExp('\\b' + re, 'i') - var a = $.grep(SearchTool.arrayToSearch, function ( - item, - index - ) { - return matcher.test(item) - }) + var a = $.grep( + SearchTool.arrayToSearch, + function (item, index) { + return matcher.test(item) + } + ) response(a) }, //drop up @@ -145,7 +145,7 @@ function changeSearchField(val) { if (Map_ != null) { SearchTool.lname = val - let urlSplit = L_.layersNamed[SearchTool.lname].url.split(':') + let urlSplit = L_.layers.data[SearchTool.lname].url.split(':') if (urlSplit[0] == 'geodatasets' && urlSplit[1] != null) { SearchTool.type = 'geodatasets' @@ -157,7 +157,7 @@ function changeSearchField(val) { $('#searchToolSelect').css({ display: 'inherit' }) $('#searchToolBoth').css({ display: 'inherit' }) - var searchFile = L_.layersNamed[SearchTool.lname].url + var searchFile = L_.layers.data[SearchTool.lname].url $.getJSON(L_.missionPath + searchFile, function (data) { SearchTool.arrayToSearch = [] @@ -176,9 +176,8 @@ function changeSearchField(val) { else SearchTool.arrayToSearch.sort() } if (document.getElementById('auto_search') != null) { - document.getElementById( - 'auto_search' - ).placeholder = getSearchFieldKeys(SearchTool.lname) + document.getElementById('auto_search').placeholder = + getSearchFieldKeys(SearchTool.lname) } }) } @@ -225,12 +224,12 @@ function searchGeodatasets() { Map_.map.getZoom() ) setTimeout(function () { - var vts = L_.layersGroup[SearchTool.lname]._vectorTiles + var vts = L_.layers.layer[SearchTool.lname]._vectorTiles for (var i in vts) { for (var j in vts[i]._features) { var feature = vts[i]._features[j].feature if (feature.properties[key] == value) { - L_.layersGroup[ + L_.layers.layer[ SearchTool.lname ]._events.click[0].fn({ layer: feature }) break @@ -260,7 +259,7 @@ function doWithSearch(doX, forceX, forceSTS, isURLSearch) { if (forceSTS == 'false') sTS = SearchTool.lname else sTS = forceSTS - var markers = L_.layersGroup[SearchTool.lname] + var markers = L_.layers.layer[SearchTool.lname] var selectLayers = [] var gotoLayers = [] var targetsID @@ -406,28 +405,8 @@ function searchWithURLParams() { function getMapZoomCoordinate(layers) { //The zoom levels are defined at http://wiki.openstreetmap.org/wiki/Zoom_levels var zoomLevels = [ - 360, - 180, - 90, - 45, - 22.5, - 11.25, - 5.625, - 2.813, - 1.406, - 0.703, - 0.352, - 0.176, - 0.088, - 0.044, - 0.022, - 0.011, - 0.005, - 0.003, - 0.001, - 0.0005, - 0.0003, - 0.0001, + 360, 180, 90, 45, 22.5, 11.25, 5.625, 2.813, 1.406, 0.703, 0.352, 0.176, + 0.088, 0.044, 0.022, 0.011, 0.005, 0.003, 0.001, 0.0005, 0.0003, 0.0001, ] var boundingBoxNorth = 90 var boundingBoxSouth = -90 diff --git a/src/essence/Tools/_OLD/Sketch/SketchTool.js b/src/essence/Tools/_OLD/Sketch/SketchTool.js index 4acb1276..5e96a398 100644 --- a/src/essence/Tools/_OLD/Sketch/SketchTool.js +++ b/src/essence/Tools/_OLD/Sketch/SketchTool.js @@ -205,8 +205,8 @@ var SketchTool = { if (L_.site == '') this.siteDrawings = 'Drawings' - if (Map_.map.hasLayer(L_.layersGroup[SketchTool.siteDrawings])) { - Map_.map.removeLayer(L_.layersGroup[SketchTool.siteDrawings]) + if (Map_.map.hasLayer(L_.layers.layer[SketchTool.siteDrawings])) { + Map_.map.removeLayer(L_.layers.layer[SketchTool.siteDrawings]) } this.MMWebGISInterface = new interfaceWithMMWebGIS(domId) @@ -326,8 +326,8 @@ function interfaceWithMMWebGIS(domId) { }) //Turn site drawing layer on if it's off - if (L_.toggledArray[SketchTool.siteDrawings] == false) { - L_.toggleLayer(L_.layersNamed[SketchTool.siteDrawings]) + if (L_.layers.on[SketchTool.siteDrawings] == false) { + L_.toggleLayer(L_.layers.data[SketchTool.siteDrawings]) } //Intializations var optionValue @@ -481,9 +481,8 @@ function interfaceWithMMWebGIS(domId) { ) } $('#sketchToolEditColor').css({ - 'background-color': $(this).css( - 'background-color' - ), + 'background-color': + $(this).css('background-color'), }) $('#sketchToolEditName').val( SketchTool.drawVarColorLegend[i] @@ -960,7 +959,8 @@ function reloadSPEPolys(geojsonFile, noPointerEvents, useOpacity) { color: '#26d962', }) } - SketchTool.lastEditedGeometry = layer.toGeoJSON().geometry + SketchTool.lastEditedGeometry = + layer.toGeoJSON().geometry SketchTool.lastClickedFeature = feature if (SketchTool.lastClickedLayer) SketchTool.lastClickedLayer.disableEdit() @@ -968,10 +968,10 @@ function reloadSPEPolys(geojsonFile, noPointerEvents, useOpacity) { SketchTool.lastClickedLayer.enableEdit() SketchTool.updateEditPanel() - L_.layersGroup[ + L_.layers.layer[ SketchTool.siteDrawings ].eachLayer(function (l) { - L_.layersGroup[ + L_.layers.layer[ SketchTool.siteDrawings ].resetStyle(l) if (l.hasBeenEdited) { @@ -993,7 +993,8 @@ function reloadSPEPolys(geojsonFile, noPointerEvents, useOpacity) { 'border-color': '#33cc66', color: '#26d962', }) - SketchTool.lastEditedGeometry = layer.toGeoJSON().geometry + SketchTool.lastEditedGeometry = + layer.toGeoJSON().geometry layer.setStyle({ color: 'blue', weight: 4 }) }) layer.on('mouseover', function (e) { @@ -1050,15 +1051,15 @@ function reloadSPEPolys(geojsonFile, noPointerEvents, useOpacity) { }) } else { $.getJSON(geojsonFile, { _: new Date().getTime() }, function (data) { - if (Map_.map.hasLayer(L_.layersGroup[SketchTool.siteDrawings])) { - Map_.map.removeLayer(L_.layersGroup[SketchTool.siteDrawings]) + if (Map_.map.hasLayer(L_.layers.layer[SketchTool.siteDrawings])) { + Map_.map.removeLayer(L_.layers.layer[SketchTool.siteDrawings]) } //sort data so point features are always on top of lines and lines always on top of polygons F_.sortGeoJSONFeatures(data) SketchTool.speGeoJSONPolys = data.features //var pointerEvents = null; if(noPointerEvents) pointerEvents = "none"; - L_.layersGroup[SketchTool.siteDrawings] = L.geoJson(data, { + L_.layers.layer[SketchTool.siteDrawings] = L.geoJson(data, { style: function (feature) { return { color: 'black', @@ -1107,7 +1108,8 @@ function reloadSPEPolys(geojsonFile, noPointerEvents, useOpacity) { color: '#26d962', }) } - SketchTool.lastEditedGeometry = layer.toGeoJSON().geometry + SketchTool.lastEditedGeometry = + layer.toGeoJSON().geometry SketchTool.lastClickedFeature = feature if (SketchTool.lastClickedLayer) SketchTool.lastClickedLayer.disableEdit() @@ -1115,9 +1117,9 @@ function reloadSPEPolys(geojsonFile, noPointerEvents, useOpacity) { SketchTool.lastClickedLayer.enableEdit() SketchTool.updateEditPanel() - L_.layersGroup[SketchTool.siteDrawings].eachLayer( + L_.layers.layer[SketchTool.siteDrawings].eachLayer( function (l) { - L_.layersGroup[ + L_.layers.layer[ SketchTool.siteDrawings ].resetStyle(l) if (l.hasBeenEdited) { @@ -1137,16 +1139,17 @@ function reloadSPEPolys(geojsonFile, noPointerEvents, useOpacity) { 'border-color': '#33cc66', color: '#26d962', }) - SketchTool.lastEditedGeometry = layer.toGeoJSON().geometry + SketchTool.lastEditedGeometry = + layer.toGeoJSON().geometry layer.setStyle({ color: 'blue', weight: 4 }) }) layer.on('mouseover', function (e) { this.setStyle({ color: 'white', weight: 6 }) }) layer.on('mouseout', function (e) { - L_.layersGroup[SketchTool.siteDrawings].eachLayer( + L_.layers.layer[SketchTool.siteDrawings].eachLayer( function (l) { - L_.layersGroup[ + L_.layers.layer[ SketchTool.siteDrawings ].resetStyle(l) if (l.hasBeenEdited) { @@ -1175,13 +1178,14 @@ function reloadSPEPolys(geojsonFile, noPointerEvents, useOpacity) { }, }) - if (L_.toggledArray[SketchTool.siteDrawings] == true) { - L_.layersGroup[SketchTool.siteDrawings].addTo(Map_.map) + if (L_.layers.on[SketchTool.siteDrawings] == true) { + L_.layers.layer[SketchTool.siteDrawings].addTo(Map_.map) if (!SketchTool.removed) { Globe_.removeVectorTileLayer('drawtool_sitedrawings') Globe_.addVectorTileLayer({ id: 'drawtool_sitedrawings', - layers: L_.layersGroup[SketchTool.siteDrawings]._layers, + layers: L_.layers.layer[SketchTool.siteDrawings] + ._layers, }) } } diff --git a/src/essence/essence.js b/src/essence/essence.js index 69a8b8d6..8e368618 100644 --- a/src/essence/essence.js +++ b/src/essence/essence.js @@ -19,6 +19,7 @@ import $ from 'jquery' import WebSocket from 'isomorphic-ws' +import M from 'materialize-css' import F_ from './Basics/Formulae_/Formulae_' import T_ from './Basics/Test_/Test_' import L_ from './Basics/Layers_/Layers_' @@ -103,7 +104,7 @@ $(document).keyup(function (e) { // On tab, add tab styles if (e.which == '9' && !tabFocusAdded) { document.styleSheets[0].insertRule( - '.toolButton:focus,#barBottom > i:focus,#topBarTitleName:focus,.mainInfo > div:focus,#mainDescription:focus,#SearchType:focus,#auto_search:focus,#loginoutButton:focus,#mapSplitInnerLeft:focus,#mapSplitInnerRight:focus,#globeSplitInnerLeft:focus,#globeSplitInnerRight:focus {border: 2px solid var(--color-mmgis) !important;}', + '.toolButton:focus,#barBottom > i:focus,#topBarTitleName:focus,.mainInfo > div:focus,#mainDescription:focus,#SearchType:focus,#auto_search:focus,#loginoutButton:focus,#mapSplitInnerLeft:focus,#mapSplitInnerRight:focus,#globeSplitInnerLeft:focus,#globeSplitInnerRight:focus {box-shadow: inset 0px 0px 0px 2px var(--color-mmgis) !important;}', 1 ) tabFocusAdded = true @@ -125,6 +126,181 @@ $(document.body).keydown(function (e) { var essence = { configData: null, hasSwapped: false, + ws: null, + initialWebSocketRetryInterval: 60000, // 1 minute + webSocketRetryInterval: 60000, // Start with this time and double if disconnected + webSocketPingInterval: null, + connectWebSocket: function (path, initial) { + // https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/readyState + if ( + essence.ws === undefined || + essence.ws === null || + (essence.ws && essence.ws.readyState === 3) + ) { + essence.initWebSocket(path) + + // If we're trying to start the WebSocket for the first time, we know we're not connected already + // so we don't need to retry to connect yet + if (!initial) { + clearInterval(essence.webSocketPingInterval) + essence.webSocketRetryInterval = + essence.webSocketRetryInterval * 2 + essence.webSocketPingInterval = setInterval( + essence.connectWebSocket, + essence.webSocketRetryInterval, + path, + false + ) // 10 seconds + } + } + }, + initWebSocket: function (path) { + essence.ws = new WebSocket(path) + + essence.ws.onerror = function (e) { + console.log(`Unable to connect to WebSocket at ${path}`) + + M.Toast.dismissAll() + + const asMinutes = essence.webSocketRetryInterval / 60000 || '' + M.toast({ + html: `Not connected to WebSocket. Retrying in ${ + asMinutes >= 1 ? parseInt(asMinutes) : asMinutes.toFixed(2) + } minute${asMinutes > 1 ? 's' : ''}...`, + displayLength: 10000, + classes: 'mmgisToast failure', + }) + } + + essence.ws.onopen = function () { + console.log('Websocket connection opened...') + + UserInterface_.removeLayerUpdateButton() + + M.Toast.dismissAll() + + if ( + essence.webSocketRetryInterval > + essence.initialWebSocketRetryInterval + ) { + /* + M.toast({ + html: 'Successfully connected to WebSocket', + displayLength: 1600, + classes: 'mmgisToast', + }) + */ + + essence.webSocketRetryInterval = + essence.initialWebSocketRetryInterval + clearInterval(essence.webSocketPingInterval) + essence.webSocketPingInterval = setInterval( + essence.connectWebSocket, + essence.webSocketRetryInterval, + path, + false + ) // 1 minute + } + } + + essence.ws.onmessage = function (data) { + if (data.data) { + try { + const parsed = JSON.parse(data.data) + const mission = essence.configData.msv.mission + + if ( + !parsed.body.mission || + parsed.body.mission !== mission + ) { + return + } + + if ('info' in parsed) { + const { type, layerName } = parsed.info + + if ( + type === 'addLayer' || + type === 'updateLayer' || + type === 'removeLayer' + ) { + calls.api( + 'get', + { + mission, + }, + async function (data) { + if (Array.isArray(layerName)) { + // If we're adding an array of new layers, add each layer to the queue individually + for (let layer in layerName) { + L_.addLayerQueue.push({ + newLayerName: layerName[layer], + data, + type, + }) + } + } else { + // Otherwise only a single new layer was added + L_.addLayerQueue.push({ + newLayerName: layerName, + data, + type, + }) + } + + if (parsed.forceClientUpdate) { + // Force update the client side + await L_.updateQueueLayers() + } else { + UserInterface_.updateLayerUpdateButton( + 'ADD_LAYER' + ) + } + }, + function (e) { + console.warn( + "Warning: Couldn't load: " + + mission + + ' configuration.' + ) + } + ) + } else { + if (parsed.body && parsed.body.config) { + UserInterface_.updateLayerUpdateButton('RELOAD') + } + } + } else { + if (parsed.body && parsed.body.config) { + UserInterface_.updateLayerUpdateButton('RELOAD') + } + } + + // Dispatch `websocketChange` event + let _event = new CustomEvent('websocketChange', { + detail: { + layer: + typeof layerName !== 'undefined' + ? layerName + : null, + type: typeof type !== 'undefined' ? type : null, + data: parsed, + }, + }) + document.dispatchEvent(_event) + } catch (e) { + console.warn( + `Error parsing data from MMGIS websocket: ${e}` + ) + } + } + } + + essence.ws.onclose = function () { + console.log('Closed websocket connection...', new Date()) + UserInterface_.updateLayerUpdateButton('DISCONNECTED') + } + }, init: function (config, missionsList, swapping) { //Save the config data this.configData = config @@ -209,101 +385,29 @@ var essence = { window.mmgisglobal.PORT && window.mmgisglobal.ENABLE_MMGIS_WEBSOCKETS === 'true' ) { - const port = parseInt(process.env.PORT || '8888', 10) + const port = parseInt(window.mmgisglobal.PORT || '8888', 10) const protocol = window.location.protocol.indexOf('https') !== -1 ? 'wss' : 'ws' const path = window.mmgisglobal.NODE_ENV === 'development' - ? `${protocol}://localhost:${port}/` - : `${protocol}://${window.location.host}/` - - const ws = new WebSocket(path) - - ws.onmessage = function (data) { - if (data.data) { - try { - const parsed = JSON.parse(data.data) - const mission = essence.configData.msv.mission - - if ( - !parsed.body.mission || - parsed.body.mission !== mission - ) { - return - } - - if ('info' in parsed) { - const { type, layerName } = parsed.info - - if ( - type === 'addLayer' || - type === 'updateLayer' || - type === 'removeLayer' - ) { - calls.api( - 'get', - { - mission, - }, - async function (data) { - if (parsed.forceClientUpdate) { - // Force update the client side - await L_.autoUpdateLayer( - data, - layerName, - type - ) - } else { - L_.addLayerQueue.push({ - newLayerName: layerName, - data, - type, - }) - - UserInterface_.updateLayerUpdateButton( - 'ADD_LAYER' - ) - } - }, - function (e) { - console.warn( - "Warning: Couldn't load: " + - mission + - ' configuration.' - ) - } - ) - } - } else { - if (parsed.body && parsed.body.config) { - UserInterface_.updateLayerUpdateButton('RELOAD') - } - } - - // Dispatch `websocketChange` event - let _event = new CustomEvent('websocketChange', { - detail: { - layer: - typeof layerName !== 'undefined' - ? layerName - : null, - type: typeof type !== 'undefined' ? type : null, - data: parsed, - }, - }) - document.dispatchEvent(_event) - } catch (e) { - console.warn( - `Error parsing data from MMGIS websocket: ${e}` - ) - } - } - } - - ws.onclose = function () { - console.log('Closed websocket connection...') - UserInterface_.updateLayerUpdateButton('DISCONNECTED') - } + ? `${protocol}://localhost:${port}${ + window.mmgisglobal.WEBSOCKET_ROOT_PATH || + window.mmgisglobal.ROOT_PATH || + '' + }/` + : `${protocol}://${window.location.host}${ + window.mmgisglobal.WEBSOCKET_ROOT_PATH || + window.mmgisglobal.ROOT_PATH || + '' + }/` + + essence.connectWebSocket(path, true) + essence.webSocketPingInterval = setInterval( + essence.connectWebSocket, + essence.webSocketRetryInterval, + path, + false + ) // 10 seconds } }, swapMission(to) { diff --git a/src/essence/mmgisAPI/mmgisAPI.js b/src/essence/mmgisAPI/mmgisAPI.js index 3d36e0d4..1bfb031c 100644 --- a/src/essence/mmgisAPI/mmgisAPI.js +++ b/src/essence/mmgisAPI/mmgisAPI.js @@ -3,6 +3,8 @@ import F_ from '../Basics/Formulae_/Formulae_' import ToolController_ from '../Basics/ToolController_/ToolController_' import QueryURL from '../Ancillary/QueryURL' import TimeControl from '../Ancillary/TimeControl' +import Login from '../Ancillary/Login/Login' +import LegendTool from '../Tools/Legend/LegendTool.js' import $ from 'jquery' @@ -20,6 +22,116 @@ var mmgisAPI_ = { mmgisAPI_.onLoadCallback = null } }, + // Adds a layer to the map. For a more "temporary" layer, use Leaflet directly through `mmgisAPI.map` + addLayer: function (layerObj, placement) { + return new Promise(async (resolve, reject) => { + if (layerObj == null) { + reject('Missing parameter: layerObj') + return + } + if (layerObj.name == null) { + reject('Missing parameter: layerObj.name') + return + } + if (layerObj.type == null) { + reject('Missing parameter: layerObj.type') + return + } + + if ( + (layerObj.uuid || layerObj.name) && + L_.layers.data[layerObj.uuid || layerObj.name] != null + ) { + reject( + `Layer uuid/name already in use: '${ + layerObj.uuid || layerObj.name + }'` + ) + } + + // Inject new layer into configData + let placementPath = placement?.path + let placementIndex = placement?.index + + const configData = JSON.parse(JSON.stringify(L_.configData)) + + if (placementPath && typeof placementPath === 'string') { + placementPath = placementPath + .split('.') + .map((p) => { + return L_.asLayerUUID(p) + }) + .join('.') + placementPath = placementPath + .replace(/\./g, '.sublayers.') + .split('.') + .concat('sublayers') + .join('.') + + const level = F_.getIn4Layers( + configData.layers, + placementPath, + null, + true + ) + if (level == null) { + reject( + `Path specified in 'placement.path' not found in 'layers': ${placementPath}.` + ) + return + } + if (placementIndex == null) placementIndex = level.length + placementIndex = Math.max( + 0, + Math.min(placementIndex, level.length) + ) + + placementPath += '.' + } else { + placementPath = '' + if (placementIndex == null) + placementIndex = configData.layers.length + placementIndex = Math.max( + 0, + Math.min(placementIndex, configData.layers.length) + ) + } + + const didSet = F_.setIn4Layers( + configData.layers, + `${placementPath}${placementIndex}`, + layerObj, + true, + true + ) + + // Then add + if (didSet) + await L_.modifyLayer(configData, layerObj.name, 'addLayer') + else { + reject('Failed to add layer.') + return + } + resolve() + }) + }, + removeLayer: function (layerUUID) { + const configData = JSON.parse(JSON.stringify(L_.configData)) + + layerUUID = L_.asLayerUUID(layerUUID) + let didRemove = false + F_.traverseLayers(configData.layers, (layer, path, index) => { + if (layer.uuid === layerUUID) { + didRemove = true + return 'remove' + } + }) + if (didRemove) { + L_.modifyLayer(configData, layerUUID, 'removeLayer') + return true + } + return false + }, // Returns an array of all features in a given extent featuresContained: function () { if (!mmgisAPI_.map) { @@ -32,49 +144,54 @@ var mmgisAPI_ = { let features = {} // For all MMGIS layers - for (let key in L_.layersGroup) { - if (L_.layersGroup[key].hasOwnProperty('_layers')) { + for (let key in L_.layers.layer) { + if (L_.layers.layer[key] === false || L_.layers.layer[key] == null) + continue + + if (L_.layers.layer[key].hasOwnProperty('_layers')) { // For normal layers const foundFeatures = findFeaturesInLayer( extent, - L_.layersGroup[key] + L_.layers.layer[key] ) features[key] = foundFeatures } else if ( key.startsWith('DrawTool_') && - Array.isArray(L_.layersGroup[key]) + Array.isArray(L_.layers.layer[key]) ) { // If layer is a DrawTool array of layers - for (let layer in L_.layersGroup[key]) { + for (let layer in L_.layers.layer[key]) { let foundFeatures - if ('getLayers' in L_.layersGroup[key][layer]) { + if ('getLayers' in L_.layers.layer[key][layer]) { if ( - L_.layersGroup[key][layer]?.feature?.properties + L_.layers.layer[key][layer]?.feature?.properties ?.arrow ) { // If the DrawTool sublayer is an arrow foundFeatures = findFeaturesInLayer( extent, - L_.layersGroup[key][layer] + L_.layers.layer[key][layer] ) // As long as one of the layers of the arrow layer is in the current Map bounds, // return the parent arrow layer's feature if (foundFeatures && foundFeatures.length > 0) { foundFeatures = - L_.layersGroup[key][layer].feature + L_.layers.layer[key][layer].feature } } else { // If the DrawTool sublayer is Polygon or Line foundFeatures = findFeaturesInLayer( extent, - L_.layersGroup[key][layer] + L_.layers.layer[key][layer] ) } - } else if ('getLatLng' in L_.layersGroup[key][layer]) { + } else if ('getLatLng' in L_.layers.layer[key][layer]) { // If the DrawTool sublayer is a Point - if (isLayerInBounds(L_.layersGroup[key][layer])) { - foundFeatures = [L_.layersGroup[key][layer].feature] + if (isLayerInBounds(L_.layers.layer[key][layer])) { + foundFeatures = [ + L_.layers.layer[key][layer].feature, + ] } } @@ -164,10 +281,10 @@ var mmgisAPI_ = { return null }, - selectFeature: function (layerName, options) { + selectFeature: function (layerUUID, options) { return L_.selectPoint({ ...{ - layerName: layerName, + layerUUID: layerUUID, }, ...options, }) @@ -184,8 +301,8 @@ var mmgisAPI_ = { getLayerConfigs: function (match) { if (match) { const matchedLayers = {} - Object.keys(L_.layersNamed).forEach((name) => { - const layer = L_.layersNamed[name] + Object.keys(L_.layers.data).forEach((name) => { + const layer = L_.layers.data[name] let matched = false Object.keys(match).forEach((key) => { const value = F_.getIn(layer, key) @@ -199,17 +316,17 @@ var mmgisAPI_ = { matchedLayers[name] = JSON.parse(JSON.stringify(layer)) }) return matchedLayers - } else return L_.layersNamed + } else return L_.layers.data }, getLayers: function () { - return L_.layersGroup + return L_.layers.layer }, // Returns an object with the visibility state of all layers getVisibleLayers: function () { // Also return the visibility of the DrawTool layers var drawToolVisibility = {} - for (let l in L_.layersGroup) { - if (!(l in L_.toggledArray)) { + for (let l in L_.layers.layer) { + if (!(l in L_.layers.on)) { var s = l.split('_') var onId = s[1] != 'master' ? parseInt(s[1]) : s[1] if (s[0] == 'DrawTool') { @@ -221,7 +338,7 @@ var mmgisAPI_ = { } } - return { ...L_.toggledArray, ...drawToolVisibility } + return { ...L_.layers.on, ...drawToolVisibility } }, //customListeners: {}, // Adds map event listener @@ -276,6 +393,7 @@ var mmgisAPI_ = { 'toolChange', 'layerVisibilityChange', 'websocketChange', + 'toggleSeparatedTool', ] return validEvents.includes(eventName) }, @@ -295,35 +413,45 @@ var mmgisAPI_ = { return window.mmgisglobal.customCRS.unproject(xy) }, toggleLayer: async function (layerName, on) { - if (layerName in L_.layersDataByName) { + if (layerName in L_.layers.data) { if (on === undefined || on === null) { // If on is not defined, switch the visibility state of the layer - await L_.toggleLayer(L_.layersDataByName[layerName]) + await L_.toggleLayer(L_.layers.data[layerName]) } else { - let state = L_.toggledArray[layerName] && !on ? true : false - await L_.toggleLayerHelper( - L_.layersDataByName[layerName], - state - ) + let state = !on + await L_.toggleLayerHelper(L_.layers.data[layerName], state) } if (ToolController_.activeToolName === 'LayersTool') { const id = `#layerstart${F_.getSafeName(layerName)} .checkbox` - if (L_.toggledArray[layerName]) { + if (L_.layers.on[layerName]) { $(id).addClass('on') } else { $(id).removeClass('on') } } } else { - console.warn(`'Warning: Unable to find layer named ${layereName}`) + console.warn(`'Warning: Unable to find layer named ${layerName}`) return } }, } var mmgisAPI = { + /** + * Adds a layer to the map. For a more "temporary" layer, use Leaflet directly through `mmgisAPI.map` + * @param {object} layerObj - See schema in configData + * @param {object} placement - Position to place layer relative to other layers - {path: , index: } + * @returns {Promise} + */ + addLayer: mmgisAPI_.addLayer, + /** + * Removes a layer from the map. + * @params {string} layerUUID - layer name/uuid to remove + * @returns {boolean} - true if found and removed, otherwise false + */ + removeLayer: mmgisAPI_.removeLayer, /** * Clears a layer with a specified name * @param {string} - layerName - name of layer to clear @@ -445,6 +573,12 @@ var mmgisAPI = { */ reloadLayer: TimeControl.reloadLayer, + /** Sets layer UUIDs and layer Names to UUIDs + * @param {string} [uuid] + * @returns {string} - Best UUID, else null + */ + asLayerUUID: L_.asLayerUUID, + /** setLayersTimeStatus - will set the status color for all global time enabled layers * @param {string} [color] * @returns {array} - A list of layers that were set @@ -520,7 +654,7 @@ var mmgisAPI = { getVisibleLayers: mmgisAPI_.getVisibleLayers, /** addEventListener - adds map event or MMGIS action listener. - * @param {string} - eventName - name of event to add listener to. Available events: onPan, onZoom, onClick, toolChange, layerVisibilityChange + * @param {string} - eventName - name of event to add listener to. Available events: onPan, onZoom, onClick, toolChange, layerVisibilityChange, toggleSeparatedTool * @param {function} - functionReference - function reference to listener event callback function. null value removes all functions for a given eventName @@ -528,7 +662,7 @@ var mmgisAPI = { addEventListener: mmgisAPI_.addEventListener, /** removeEventListener - removes map event or MMGIS action listener added using the MMGIS API. - * @param {string} - eventName - name of event to add listener to. Available events: onPan, onZoom, onClick, toolChange, layerVisibilityChange + * @param {string} - eventName - name of event to add listener to. Available events: onPan, onZoom, onClick, toolChange, layerVisibilityChange, toggleSeparatedTool * @param {function} - functionReference - function reference to listener event callback function. null value removes all functions for a given eventName */ removeEventListener: mmgisAPI_.removeEventListener, @@ -544,6 +678,10 @@ var mmgisAPI = { */ onLoaded: mmgisAPI_.onLoaded, + /** initialLogin: performs the initial login call to relogin returning users. Pairable with the ENV `SKIP_CLIENT_INITIAL_LOGIN=`. + */ + initialLogin: Login.initialLogin, + /** project - converts a lnglat into xy coordinates with the current (custom or default web mercator) proj4 definition * @param {object} {lng: 0, lat: 0} - lnglat to convert * @returns {object} {x: 0, y: 0} - converted easting northing xy @@ -557,10 +695,18 @@ var mmgisAPI = { unproject: mmgisAPI_.unproject, /** toggleLayer - set the visibility state for a named layer - * @param {string} - layerName - name of layer to set visiblity - * @param {boolean} - on - (optional) Set true if the visibility should be on or false if visibility should be off. If not set, the current visiblity state will switch to the opposite state. + * @param {string} - layerName - name of layer to set visibility + * @param {boolean} - on - (optional) Set true if the visibility should be on or false if visibility should be off. If not set, the current visibility state will switch to the opposite state. */ toggleLayer: mmgisAPI_.toggleLayer, + + /** overwriteLegends - overwrite the contents displayed in the LegendTool; useful when used with `toggleSeparatedTool` event listener in mmgisAPI + * @param {array} - legends - an array of objects, where each object must contain the following keys: legend, layerUUID, display_name, opacity. The value for the legend key should be in the same format as what is stored in the layers data under the `_legend` key (i.e. `L_.layers.data[layerName]._legend`). layerUUID and display_name should be strings and opacity should be a number between 0 and 1. + */ + overwriteLegends: LegendTool.overwriteLegends, + + // Formulae_ + utils: { ...F_ }, } window.mmgisAPI = mmgisAPI diff --git a/src/external/Dropy/dropy.css b/src/external/Dropy/dropy.css index 4e9bbe24..a7fb2435 100644 --- a/src/external/Dropy/dropy.css +++ b/src/external/Dropy/dropy.css @@ -127,7 +127,7 @@ dd { } .dropy.open .dropy__content ul { - max-height: 18.75em; + max-height: 20em; overflow-y: auto; opacity: 1; } diff --git a/src/external/Leaflet/leaflet-pip.js b/src/external/Leaflet/leaflet-pip.js index 5bfbc2d8..fc2d1698 100644 --- a/src/external/Leaflet/leaflet-pip.js +++ b/src/external/Leaflet/leaflet-pip.js @@ -68,10 +68,10 @@ p = p.concat().reverse() var results = [] - if (typeof layer.eachLayer === 'feature') { + + if (typeof layer.eachLayer === 'function') { layer.eachLayer(function (l) { if (first && results.length) return - if ( isPoly(l) && gju.pointInPolygon( @@ -85,6 +85,42 @@ results.push(l) } }) + } else if (Array.isArray(layer)) { + layer.forEach((innerLayer) => { + if ( + typeof innerLayer.eachLayer === + 'function' + ) { + innerLayer.eachLayer(function (l) { + if (first && results.length) return + if ( + isPoly(l) && + gju.pointInPolygon( + { + type: 'Point', + coordinates: p, + }, + l.toGeoJSON(10).geometry + ) + ) { + results.push(l) + } + }) + } else { + if ( + isPoly(innerLayer) && + gju.pointInPolygon( + { + type: 'Point', + coordinates: p, + }, + innerLayer.feature.geometry + ) + ) { + results.push(innerLayer) + } + } + }) } else { if ( isPoly(layer) && diff --git a/src/index.js b/src/index.js index 5d06515d..56168bb7 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,5 @@ -import React from 'react' -import ReactDOM from 'react-dom' +import React, { StrictMode } from 'react' +import { render } from 'react-dom' import './index.css' import RefreshAuth from './pre/RefreshAuth' @@ -63,10 +63,10 @@ import 'tippy.js/dist/tippy.css' import App from './App' import * as serviceWorker from './serviceWorker' -ReactDOM.render( - <React.StrictMode> +render( + <StrictMode> <App /> - </React.StrictMode>, + </StrictMode>, document.getElementById('root') ) diff --git a/src/pre/RefreshAuth.js b/src/pre/RefreshAuth.js index b58c8443..40c1bffb 100644 --- a/src/pre/RefreshAuth.js +++ b/src/pre/RefreshAuth.js @@ -36,7 +36,7 @@ if (mmgisglobal.SERVER == 'node' && mmgisglobal.AUTH == 'csso') { mmgisglobal.lastInteraction = Math.floor(Date.now() / 1000) var _refreshAuth_checkEvery = 60000 * 10 //milliseconds - var _refreshAuth_expiringLessThan = 60 * 11 //seconds + var _refreshAuth_expiringLessThan = 60 * 20 //seconds var _refreshAuth_interactedPast = 60000 * 30 //milliseconds function ssorefresh() { @@ -49,26 +49,23 @@ if (mmgisglobal.SERVER == 'node' && mmgisglobal.AUTH == 'csso') { var now = Math.floor(Date.now() / 1000) - if (mmgisglobal.SHOW_AUTH_TIMEOUT) { - var append = false - - var elm = document.getElementById('AUTH_TIMEOUT') - if (elm == null) { - elm = document.createElement('div') - append = true + if (result.authenticated) { + const content = `${ + result.sub + }<br />Authentication expiring in ${(result.exp - now) + .toString() + .toHHMMSS()}` + if (window._tippyLoginUser && window._tippyLoginUser[0]) + window._tippyLoginUser[0].setContent(content) + if ( + result.exp - now <= _refreshAuth_expiringLessThan && + document.getElementById('loginUser') != null + ) { + document + .getElementById('loginUser') + .classList.add('attention') } - elm.id = 'AUTH_TIMEOUT' - elm.style.cssText = - 'position:fixed;left:225px;bottom:0px;z-index:11000;font-family:monospace;font-size:11px;color:#121626;' - elm.innerHTML = - 'Authentication expiring in ' + - (result.exp - now).toString().toHHMMSS() + - '<div onclick="ssologin()" style="cursor:pointer;">Login again to renew</div>' - if (append) document.body.appendChild(elm) - } - - if (result.authenticated) { if ( mmgisglobal.lastInteraction + _refreshAuth_interactedPast <= diff --git a/src/pre/calls.js b/src/pre/calls.js index 32341274..3210c8d6 100644 --- a/src/pre/calls.js +++ b/src/pre/calls.js @@ -148,7 +148,11 @@ function api(call, data, success, error) { $.ajax({ type: c[call].type, - url: c[call].url, + url: `${ + window.mmgisglobal.ROOT_PATH + ? window.mmgisglobal.ROOT_PATH + '/' + : '' + }${c[call].url}`, data: data, xhrFields: { withCredentials: true, diff --git a/views/configure.pug b/views/configure.pug index ffcbf4d1..917412d9 100644 --- a/views/configure.pug +++ b/views/configure.pug @@ -32,13 +32,19 @@ script. mmgisglobal.SHOW_AUTH_TIMEOUT = true; mmgisglobal.user = '#{user}'; mmgisglobal.NODE_ENV = '#{NODE_ENV}'; + mmgisglobal.ROOT_PATH = '#{ROOT_PATH}'; + mmgisglobal.WEBSOCKET_ROOT_PATH = '#{WEBSOCKET_ROOT_PATH}'; + mmgisglobal.PORT = '#{PORT}' + mmgisglobal.ENABLE_CONFIG_WEBSOCKETS = '#{ENABLE_CONFIG_WEBSOCKETS}' + mmgisglobal.ENABLE_CONFIG_OVERRIDE = '#{ENABLE_CONFIG_OVERRIDE}' script(type='text/javascript' src='config/js/calls.js') script(type='text/javascript' src='config/js/keys.js') script(type='text/javascript' src='config/js/datasets.js') script(type='text/javascript' src='config/js/geodatasets.js') script(type='text/javascript' src='config/js/webhooks.js') script(type='text/javascript' src='config/js/config.js') -script(type='text/javascript' src='src/pre/RefreshAuth.js') +script(type='text/javascript' src='config/js/websocket.js') +script(type='text/javascript' src='config/pre/RefreshAuth.js') #leftPanel #tbtitle @@ -119,7 +125,7 @@ script(type='text/javascript' src='src/pre/RefreshAuth.js') li.tab.col.s1 a(href='#tab_time') Time #tab_overall.col.s12 - a.helpFromDocs(href='docs/?page=Overall_Tab' target='__blank' rel='noopener') + a.helpFromDocs(href='https://nasa-ammos.github.io/MMGIS/configure/tabs/overall' target='__blank' rel='noopener') i.mdi.mdi-help.mdi-14px ul#tab_overall_rows li.row @@ -136,8 +142,12 @@ script(type='text/javascript' src='src/pre/RefreshAuth.js') a#delete_mission.modal-trigger.btn.waves-effect.waves-light.red.darken-3.col.s2.push-s2(href='#delete_modal' style='border-radius: 0px; padding: 1px 0.5rem 0 0.5rem; font-size: 12px; line-height: 35px;') | Delete Mission i.mdi.mdi-delete.mdi-18px(style='float: right; margin-top: -1px;') + li.row(style='margin-top: 64px;') + a#download_working_config.btn.waves-effect.waves-light.brown.darken-3.col.s2.push-s5(style='border-radius: 0px; padding: 1px 0.5rem 0 0.5rem; font-size: 12px; line-height: 35px;') + | Export unsaved config.json + i.mdi.mdi-download.mdi-18px(style='float: right; margin-top: -1px;') #tab_initial.col.s12 - a.helpFromDocs(href='docs/?page=Initial_Tab' target='__blank' rel='noopener') + a.helpFromDocs(href='https://nasa-ammos.github.io/MMGIS/configure/tabs/initial' target='__blank' rel='noopener') i.mdi.mdi-help.mdi-14px ul#tab_initial_rows li.row @@ -173,7 +183,7 @@ script(type='text/javascript' src='src/pre/RefreshAuth.js') input#imapScale.validate(type='text' value='') label(for='imapScale') Zoom Level of Map Scale #tab_projection.col.s12(style='padding-bottom: 15px;') - a.helpFromDocs(href='docs/?page=Projection_Tab' target='__blank' rel='noopener') + a.helpFromDocs(href='https://nasa-ammos.github.io/MMGIS/configure/tabs/projection' target='__blank' rel='noopener') i.mdi.mdi-help.mdi-14px ul#tab_projection_rows li.row @@ -222,7 +232,7 @@ script(type='text/javascript' src='src/pre/RefreshAuth.js') label(for='projection_res') the units per pixel are #tab_coordinates.col.s12 - a.helpFromDocs(href='docs/?page=Coordinates_Tab' target='__blank' rel='noopener') + a.helpFromDocs(href='https://nasa-ammos.github.io/MMGIS/configure/tabs/coordinates' target='__blank' rel='noopener') i.mdi.mdi-help.mdi-14px ul#tab_coordinates_rows li.row.title @@ -325,9 +335,18 @@ script(type='text/javascript' src='src/pre/RefreshAuth.js') #coordinates_coordelevurlEl.input-field.col.s7.push-s1 input#coordinates_coordelevurl.validate(type='text' value='') label(for='coordinates_coordelevurl') DEM URL + li.row.title(style='margin-top: 45px;') + .col.s2.push-s1 Raw Variables + .col.s6.push-s3(style='text-align: center; background-color: rgba(0,0,0,0.06); position: relative; padding: 0;') + a.waves-effect.waves-light.modal-trigger(href='#coordinatesVariables_modal' style='color: #111; width: 100%;') Click for configuration documentation + i.mdi.mdi-information.mdi-18px(style='position: absolute; right: 2px; top: -2px; color: #444;') + + li.row(style='padding-bottom: 0px;') + #coordinates_variablseEl.input-field.col.s10.push-s1 + textarea#coordinatesVariables #tab_look.col.s12 - a.helpFromDocs(href='docs/?page=Look_Tab' target='__blank' rel='noopener') + a.helpFromDocs(href='https://nasa-ammos.github.io/MMGIS/configure/tabs/look' target='__blank' rel='noopener') i.mdi.mdi-help.mdi-14px ul#tab_look_rows li.row.title @@ -342,15 +361,34 @@ script(type='text/javascript' src='src/pre/RefreshAuth.js') li.row.title .col.s2.push-s2 User Interface li.row.checkboxRow - #look_minimalistEl.input-field.col.s2.push-s2 + #look_minimalistEl.input-field.col.s2.push-s2(style='display:none') input#look_minimalist.filled-in.checkbox-color(type='checkbox') label(for='look_minimalist' style='color: black;') Minimalist UI + #look_topbarEl.input-field.col.s2.push-s2 + input#look_topbar.filled-in.checkbox-color(type='checkbox') + label(for='look_topbar' style='color: black;') Top Bar + #look_toolbarEl.input-field.col.s2.push-s2 + input#look_toolbar.filled-in.checkbox-color(type='checkbox') + label(for='look_toolbar' style='color: black;') Tool Bar + #look_scalebarEl.input-field.col.s2.push-s2 + input#look_scalebar.filled-in.checkbox-color(type='checkbox') + label(for='look_scalebar' style='color: black;') Scale Bar + #look_coordinatesEl.input-field.col.s2.push-s2 + input#look_coordinates.filled-in.checkbox-color(type='checkbox') + label(for='look_coordinates' style='color: black;') Coordinates + li.row.checkboxRow #look_zoomcontrolEl.input-field.col.s2.push-s2 input#look_zoomcontrol.filled-in.checkbox-color(type='checkbox') label(for='look_zoomcontrol' style='color: black;') Map Zoom Control #look_graticuleEl.input-field.col.s2.push-s2 input#look_graticule.filled-in.checkbox-color(type='checkbox') label(for='look_graticule' style='color: black;') Map Graticule + #look_miscellaneousEl.input-field.col.s2.push-s2 + input#look_miscellaneous.filled-in.checkbox-color(type='checkbox') + label(for='look_miscellaneous' style='color: black;') Miscellaneous + #look_settingsEl.input-field.col.s2.push-s2 + input#look_settings.filled-in.checkbox-color(type='checkbox') + label(for='look_settings' style='color: black;') Settings li.row.title .col.s2.push-s2 Colors @@ -397,6 +435,15 @@ script(type='text/javascript' src='src/pre/RefreshAuth.js') #look_fullscreenEl.input-field.col.s2.push-s2 input#look_fullscreen.filled-in.checkbox-color(type='checkbox') label(for='look_fullscreen' style='color: black;') Fullscreen + li.row.title + .col.s2.push-s2 User Info + li.row.checkboxRow + #look_helpEl.input-field.col.s2.push-s2 + input#look_info.filled-in.checkbox-color(type='checkbox') + label(for='look_info' style='color: black;') Info + #look_helpurlEl.input-field.col.s6.push-s2 + input#look_infourl.validate(type='text' value='') + label(for='look_infourl') Info URL li.row.title .col.s2.push-s2 User Help li.row.checkboxRow @@ -408,7 +455,7 @@ script(type='text/javascript' src='src/pre/RefreshAuth.js') label(for='look_helpurl') Help URL #tab_panels.col.s8.push-s2 - a.helpFromDocs(href='docs/?page=Panels_Tab' target='__blank' rel='noopener') + a.helpFromDocs(href='https://nasa-ammos.github.io/MMGIS/configure/tabs/panels' target='__blank' rel='noopener') i.mdi.mdi-help.mdi-14px p input#panels_viewer.filled-in.checkbox-color(type='checkbox') @@ -437,29 +484,48 @@ script(type='text/javascript' src='src/pre/RefreshAuth.js') label(for='panels_globeDemFallbackType') Fallback Type #tab_time.col.s12 - a.helpFromDocs(href='docs/?page=Time_Tab' target='__blank' rel='noopener') + a.helpFromDocs(href='https://nasa-ammos.github.io/MMGIS/configure/tabs/time' target='__blank' rel='noopener') i.mdi.mdi-help.mdi-14px ul#tab_time_rows li.row.title .col.s2.push-s2 User Interface - li.row.checkboxRow.col.s2.push-s2 - p + li.row + #time_enabledEl.input-field.col.s2.push-s2 input#time_enabled.filled-in.checkbox-color(type='checkbox') label(for='time_enabled' style='color: black;') Enabled - p + #time_visibledEl.input-field.col.s2.push-s2 input#time_visible.filled-in.checkbox-color(type='checkbox') label(for='time_visible' style='color: black;') Visible + #time_initiallyOpendEl.input-field.col.s2.push-s2 + input#time_initiallyOpen.filled-in.checkbox-color(type='checkbox') + label(for='time_initiallyOpen' style='color: black;') Initially Open + li.row.title + .col.s2.push-s2 Settings li.row - #time_format_row.input-field.col.s4.push-s2 + #time_format_row.input-field.col.s3.push-s2 input#time_format.validate(type='text' value='%Y-%m-%dT%H:%M:%SZ') label(for='time_format') Time Format + li.row + #time_initialstartEl.input-field.col.s3.push-s2 + input#time_initialstart.validate(type='text' value='' title="Parsable time (defaults to a month before the end time)") + label(for='time_initialstart') Initial Start Time + #time_initialendEl.input-field.col.s3.push-s2 + input#time_initialend.validate(type='text' value='now' title="Parsable time (default to 'now')") + label(for='time_initialend') Initial End Time + li.row + #time_initialwindowstartEl.input-field.col.s3.push-s2 + input#time_initialwindowstart.validate(type='text' value='' title="Parsable time (defaults to the Initial Start Time)") + label(for='time_initialwindowstart') Initial Timeline Window Start Time + #time_initialwindowendEl.input-field.col.s3.push-s2 + input#time_initialwindowend.validate(type='text' value='now' title="Parsable time (default to the Initial End TIme)") + label(for='time_initialwindowend') Initial Timeline Window End Time #tab_tools.col.s12 - a.helpFromDocs(href='docs/?page=Tools_Tab' target='__blank' rel='noopener') + a.helpFromDocs(href='https://nasa-ammos.github.io/MMGIS/configure/tabs/tools' target='__blank' rel='noopener') i.mdi.mdi-help.mdi-14px ul#tab_tools_rows #tab_layers.col.s12 - a.helpFromDocs(href='docs/?page=Layers_Tab' target='__blank' rel='noopener') + a.helpFromDocs(href='https://nasa-ammos.github.io/MMGIS/configure/tabs/layers' target='__blank' rel='noopener') i.mdi.mdi-help.mdi-14px ul#tab_layers_rows(style='margin-top: 20px;') #add_new_layer.row @@ -497,6 +563,17 @@ script(type='text/javascript' src='src/pre/RefreshAuth.js') a#delete_mission_delete.modal-action.modal-close.btn-flat.waves-effect.waves-light.col.s12(style='border-radius: 0px; color: white;') | Delete Mission i.mdi.mdi-delete.mdi-24px(style='float: right; margin-top: 1px; padding-left: 5px;') + #coordinatesVariables_modal.modal + .modal-content(style='padding-bottom: 0;') + h4 Coordinates Raw Variables + #coordinatesVariables_info(style='margin-bottom: 0;') + #coordinatesVariables_title + hr + #coordinatesVariables_content + pre#coordinatesVariables_example + .modal-footer + a.modal-action.modal-close.waves-effect.waves-green.btn-flat(href='#!') Done + .row #info_modal.modal .modal-content(style='padding-bottom: 0;') h4 Modal Header