From 642e5c995d3d8cfc19c9a4ca35758a52f5717fcb Mon Sep 17 00:00:00 2001 From: Kassem Tohme Date: Tue, 30 May 2017 17:46:30 +0200 Subject: [PATCH 01/24] using native jdbc to avoid hibernate/jpa locking and obscure exceptions --- .../metascope/model/MetascopeExport.java | 18 ++ .../metascope/model/MetascopeField.java | 20 ++ .../metascope/model/MetascopeTable.java | 12 +- .../repository/jdbc/JDBCContext.java | 58 +++++ .../repository/jdbc/RawJDBCSqlRepository.java | 216 +++++------------- .../entity/JDBCMetascopeExportRepository.java | 130 +++++++++++ .../entity/JDBCMetascopeFieldRepository.java | 146 ++++++++++++ .../JDBCMetascopeMetadataRepository.java | 38 +++ .../entity/JDBCMetascopeTableRepository.java | 181 +++++++++++++++ .../entity/JDBCMetascopeViewRepository.java | 122 ++++++++++ .../metascope/task/SchedoscopeTask.java | 55 +++-- 11 files changed, 803 insertions(+), 193 deletions(-) create mode 100644 schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/JDBCContext.java create mode 100644 schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeExportRepository.java create mode 100644 schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeFieldRepository.java create mode 100644 schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeMetadataRepository.java create mode 100644 schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeTableRepository.java create mode 100644 schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeViewRepository.java diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeExport.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeExport.java index 7f5506468..5e4896c28 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeExport.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeExport.java @@ -16,6 +16,7 @@ package org.schedoscope.metascope.model; import javax.persistence.*; +import java.util.HashMap; import java.util.Map; @Entity @@ -29,6 +30,8 @@ public class MetascopeExport { private Map exportProperties; @ManyToOne(fetch = FetchType.LAZY) private MetascopeTable table; + @Transient + private String tableFqdn; /* getter and setter */ public String getExportId() { @@ -79,4 +82,19 @@ public int hashCode() { return exportId.hashCode(); } + public String getTableFqdn() { + return tableFqdn; + } + + public void setTableFqdn(String tableFqdn) { + this.tableFqdn = tableFqdn; + } + + public void addProperty(String key, String value) { + if (exportProperties == null) { + this.exportProperties = new HashMap<>(); + } + this.exportProperties.put(key, value); + } + } diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeField.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeField.java index 297e18063..2439fbfde 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeField.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeField.java @@ -34,6 +34,10 @@ public class MetascopeField extends Documentable { private boolean isParameter; @ManyToOne(fetch = FetchType.LAZY) private MetascopeTable table; + @Transient + private Long commentId; + @Transient + private String tableFqdn; @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL) @JoinTable(name = "metascope_field_relationship", @@ -116,6 +120,22 @@ public List getSuccessors() { return successors; } + public Long getCommentId() { + return commentId; + } + + public String getTableFqdn() { + return tableFqdn; + } + + public void setCommentId(Long commentId) { + this.commentId = commentId; + } + + public void setTableFqdn(String tableFqdn) { + this.tableFqdn = tableFqdn; + } + public void addToDependencies(MetascopeField field) { if (dependencies == null) { this.dependencies = new ArrayList<>(); diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTable.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTable.java index 6b35c0a75..a7078239d 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTable.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTable.java @@ -67,6 +67,8 @@ public class MetascopeTable extends Documentable { @Column(columnDefinition = "int default 1") private int viewsSize; private String personResponsible; + @Transient + private Long commentId; @OneToOne(mappedBy = "table", cascade = CascadeType.ALL) @LazyCollection(LazyCollectionOption.FALSE) @@ -417,7 +419,15 @@ public void setViewsSize(int viewsSize) { this.viewsSize = viewsSize; } - /* ### GETTER/SETTER END ### */ + public Long getCommentId() { + return commentId; + } + + public void setCommentId(Long commentId) { + this.commentId = commentId; + } + + /* ### GETTER/SETTER END ### */ /* ### ADD/REMOVE START ### */ public void addToFields(MetascopeField field) { diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/JDBCContext.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/JDBCContext.java new file mode 100644 index 000000000..5c45cdb64 --- /dev/null +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/JDBCContext.java @@ -0,0 +1,58 @@ +package org.schedoscope.metascope.repository.jdbc; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; + +public class JDBCContext { + + private static final Logger LOG = LoggerFactory.getLogger(JDBCContext.class); + + private final boolean isMySQLDatabase; + private final boolean isH2Database; + + public JDBCContext(boolean isMySQLDatabase, boolean isH2Database) { + this.isMySQLDatabase = isMySQLDatabase; + this.isH2Database = isH2Database; + } + + protected void disableChecks(Connection connection) { + try { + Statement stmt = connection.createStatement(); + connection.setAutoCommit(false); + if (isMySQLDatabase) { + stmt.addBatch("set foreign_key_checks=0"); + stmt.addBatch("set unique_checks=0"); + } + if (isH2Database) { + stmt.addBatch("SET REFERENTIAL_INTEGRITY FALSE"); + } + stmt.executeBatch(); + stmt.close(); + } catch (SQLException e) { + LOG.error("Could not disable checks", e); + } + } + + protected void enableChecks(Connection connection) { + try { + Statement stmt = connection.createStatement(); + connection.setAutoCommit(true); + if (isMySQLDatabase) { + stmt.addBatch("set foreign_key_checks=1"); + stmt.addBatch("set unique_checks=1"); + } + if (isH2Database) { + stmt.addBatch("SET REFERENTIAL_INTEGRITY TRUE"); + } + stmt.executeBatch(); + stmt.close(); + } catch (SQLException e) { + LOG.error("Could not enable checks", e); + } + } + +} diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/RawJDBCSqlRepository.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/RawJDBCSqlRepository.java index e262aa7d5..61bfac667 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/RawJDBCSqlRepository.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/RawJDBCSqlRepository.java @@ -15,194 +15,82 @@ */ package org.schedoscope.metascope.repository.jdbc; -import org.apache.commons.dbutils.DbUtils; -import org.schedoscope.metascope.model.MetascopeView; +import org.schedoscope.metascope.model.*; +import org.schedoscope.metascope.repository.jdbc.entity.*; import org.schedoscope.metascope.task.model.FieldDependency; import org.schedoscope.metascope.task.model.ViewDependency; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.sql.Statement; import java.util.List; +import java.util.Set; public class RawJDBCSqlRepository { - private static final Logger LOG = LoggerFactory.getLogger(RawJDBCSqlRepository.class); - private final boolean isMySQLDatabase; - private final boolean isH2Database; + private final JDBCMetascopeTableRepository jdbcMetascopeTableRepository; + private final JDBCMetascopeViewRepository jdbcMetascopeViewRepository; + private final JDBCMetascopeFieldRepository jdbcMetascopeFieldRepository; + private final JDBCMetascopeExportRepository jdbcMetascopeExportRepository; + private final JDBCMetascopeMetadataRepository jdbcMetascopeMetadataRepository; public RawJDBCSqlRepository(boolean isMySQLDatabase, boolean isH2Database) { - this.isMySQLDatabase = isMySQLDatabase; - this.isH2Database = isH2Database; + this.jdbcMetascopeTableRepository = new JDBCMetascopeTableRepository(isMySQLDatabase, isH2Database); + this.jdbcMetascopeViewRepository = new JDBCMetascopeViewRepository(isMySQLDatabase, isH2Database); + this.jdbcMetascopeFieldRepository = new JDBCMetascopeFieldRepository(isMySQLDatabase, isH2Database); + this.jdbcMetascopeExportRepository = new JDBCMetascopeExportRepository(isMySQLDatabase, isH2Database); + this.jdbcMetascopeMetadataRepository = new JDBCMetascopeMetadataRepository(isMySQLDatabase, isH2Database); } - public void insertOrUpdateViews(Connection connection, Iterable views) { - String deleteQuery = "delete from metascope_view"; - String insertViewSql = "insert into metascope_view (view_id, view_url, parameter_string, table_fqdn) values " - + "(?, ?, ?, ?) on duplicate key update view_id=values(view_id), view_url=values(view_url), " - + "parameter_string=values(parameter_string), table_fqdn=values(table_fqdn)"; - PreparedStatement stmt = null; - try { - int batch = 0; - disableChecks(connection); - - Statement deleteStmt = connection.createStatement(); - deleteStmt.execute(deleteQuery); - deleteStmt.close(); - - stmt = connection.prepareStatement(insertViewSql); - for (MetascopeView viewEntity : views) { - stmt.setString(1, viewEntity.getViewId()); - stmt.setString(2, viewEntity.getViewUrl()); - stmt.setString(3, viewEntity.getParameterString()); - stmt.setString(4, viewEntity.getTable().getFqdn()); - stmt.addBatch(); - batch++; - if (batch % 1024 == 0) { - stmt.executeBatch(); - } - } - stmt.executeBatch(); - connection.commit(); - enableChecks(connection); - } catch (SQLException e) { - LOG.error("Could not save view", e); - } finally { - DbUtils.closeQuietly(stmt); - } + /*### MetascopeTable ###*/ + public MetascopeTable findTable(Connection connection, String fqdn) { + return this.jdbcMetascopeTableRepository.findTable(connection, fqdn); } - public void insertFieldDependencies(Connection connection, List fieldDependencies) { - String deleteQuery = "delete from metascope_field_relationship"; - String sql = "insert into metascope_field_relationship (successor, dependency) values (?, ?) " - + "on duplicate key update successor=values(successor), dependency=values(dependency)"; - PreparedStatement stmt = null; - try { - int batch = 0; - disableChecks(connection); - - Statement deleteStmt = connection.createStatement(); - deleteStmt.execute(deleteQuery); - deleteStmt.close(); - - stmt = connection.prepareStatement(sql); - for (FieldDependency fieldDependency : fieldDependencies) { - stmt.setString(1, fieldDependency.getDependency()); - stmt.setString(2, fieldDependency.getSuccessor()); - stmt.addBatch(); - batch++; - if (batch % 1024 == 0) { - stmt.executeBatch(); - } - } - stmt.executeBatch(); - connection.commit(); - enableChecks(connection); - } catch (SQLException e) { - LOG.error("Could not save view", e); - } finally { - DbUtils.closeQuietly(stmt); - } + public void saveTable(Connection connection, MetascopeTable table) { + this.jdbcMetascopeTableRepository.save(connection, table); + } + + public void saveTransformation(Connection connection, MetascopeTransformation transformation, String fqdn) { + this.jdbcMetascopeTableRepository.saveTransformation(connection, transformation, fqdn); + } + + /*### MetascopeView ###*/ + public void insertOrUpdateViews(Connection connection, Iterable views) { + this.jdbcMetascopeViewRepository.insertOrUpdateViews(connection, views); } public void insertViewDependencies(Connection connection, List viewDependencies) { - String deleteQuery = "delete from metascope_view_relationship"; - String sql = "insert into metascope_view_relationship (successor, dependency) values (?, ?) " - + "on duplicate key update successor=values(successor), dependency=values(dependency)"; - PreparedStatement stmt = null; - try { - int batch = 0; - disableChecks(connection); - - Statement deleteStmt = connection.createStatement(); - deleteStmt.execute(deleteQuery); - deleteStmt.close(); - - stmt = connection.prepareStatement(sql); - for (ViewDependency viewDependency : viewDependencies) { - stmt.setString(1, viewDependency.getDependency()); - stmt.setString(2, viewDependency.getSuccessor()); - stmt.addBatch(); - batch++; - if (batch % 1024 == 0) { - stmt.executeBatch(); - } - } - stmt.executeBatch(); - connection.commit(); - enableChecks(connection); - } catch (SQLException e) { - LOG.error("Could not save view", e); - } finally { - DbUtils.closeQuietly(stmt); - } + this.jdbcMetascopeViewRepository.insertViewDependencies(connection, viewDependencies); } public void updateStatus(Connection connection, Iterable views) { - String updateStatus = "update metascope_view set last_transformation=?, total_size=?, num_rows=? where view_id = ?"; - PreparedStatement updateStatusStmt = null; - try { - int batch = 0; - disableChecks(connection); - updateStatusStmt = connection.prepareStatement(updateStatus); - for (MetascopeView viewEntity : views) { - updateStatusStmt.setLong(1, viewEntity.getLastTransformation()); - updateStatusStmt.setLong(2, viewEntity.getTotalSize()); - updateStatusStmt.setLong(3, viewEntity.getNumRows()); - updateStatusStmt.setString(4, viewEntity.getViewId()); - updateStatusStmt.addBatch(); - batch++; - if (batch % 1024 == 0) { - updateStatusStmt.executeBatch(); - } - } - updateStatusStmt.executeBatch(); - connection.commit(); - enableChecks(connection); - } catch (SQLException e) { - LOG.error("Could not update view", e); - } finally { - DbUtils.closeQuietly(updateStatusStmt); - } + this.jdbcMetascopeViewRepository.updateStatus(connection, views); + } + + /*### MetascopeField ###*/ + public MetascopeField findField(Connection connection, String fieldFqdn) { + return this.jdbcMetascopeFieldRepository.findField(connection, fieldFqdn); + } + + public void saveFields(Connection connection, Set fields, String fqdn, String mappingTable) { + this.jdbcMetascopeFieldRepository.saveFields(connection, fields, fqdn, mappingTable); + } + + public void insertFieldDependencies(Connection connection, List fieldDependencies) { + this.jdbcMetascopeFieldRepository.insertFieldDependencies(connection, fieldDependencies); + } + + /*### MetascopeExport ###*/ + public MetascopeExport findExport(Connection connection, String exportFqdn) { + return this.jdbcMetascopeExportRepository.findExport(connection, exportFqdn); } - private void disableChecks(Connection connection) { - try { - Statement stmt = connection.createStatement(); - connection.setAutoCommit(false); - if (isMySQLDatabase) { - stmt.addBatch("set foreign_key_checks=0"); - stmt.addBatch("set unique_checks=0"); - } - if (isH2Database) { - stmt.addBatch("SET REFERENTIAL_INTEGRITY FALSE"); - } - stmt.executeBatch(); - stmt.close(); - } catch (SQLException e) { - LOG.error("Could not disable checks", e); - } + public void saveExports(Connection connection, List exports, String fqdn) { + this.jdbcMetascopeExportRepository.save(connection, exports, fqdn); } - private void enableChecks(Connection connection) { - try { - Statement stmt = connection.createStatement(); - connection.setAutoCommit(true); - if (isMySQLDatabase) { - stmt.addBatch("set foreign_key_checks=1"); - stmt.addBatch("set unique_checks=1"); - } - if (isH2Database) { - stmt.addBatch("SET REFERENTIAL_INTEGRITY TRUE"); - } - stmt.executeBatch(); - stmt.close(); - } catch (SQLException e) { - LOG.error("Could not enable checks", e); - } + /*### MetascopeMetadata ###*/ + public void saveMetadata(Connection connection, String key, String value) { + this.jdbcMetascopeMetadataRepository.saveMetadata(connection, key, value); } } \ No newline at end of file diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeExportRepository.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeExportRepository.java new file mode 100644 index 000000000..3c0cb167a --- /dev/null +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeExportRepository.java @@ -0,0 +1,130 @@ +package org.schedoscope.metascope.repository.jdbc.entity; + +import org.apache.commons.dbutils.DbUtils; +import org.schedoscope.metascope.model.MetascopeExport; +import org.schedoscope.metascope.repository.jdbc.JDBCContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.List; +import java.util.Map; + +public class JDBCMetascopeExportRepository extends JDBCContext { + + private static final Logger LOG = LoggerFactory.getLogger(JDBCMetascopeExportRepository.class); + + public JDBCMetascopeExportRepository(boolean isMySQLDatabase, boolean isH2Database) { + super(isMySQLDatabase, isH2Database); + } + + public MetascopeExport findExport(Connection connection, String exportFqdn) { + MetascopeExport export = null; + String findQuery = "select export_id, export_type, table_fqdn from metascope_export where export_id = ?"; + PreparedStatement stmt = null; + PreparedStatement propertiesStmt = null; + ResultSet rs = null; + try { + stmt = connection.prepareStatement(findQuery); + stmt.setString(1, exportFqdn); + rs = stmt.executeQuery(); + if (rs.next()) { + export = new MetascopeExport(); + export.setExportId(rs.getString("export_id")); + export.setExportType(rs.getString("export_type")); + export.setTableFqdn(rs.getString("table_fqdn")); + + propertiesStmt = connection.prepareStatement("select metascope_export_export_id, export_properties_key, " + + "export_properties from metascope_export_export_properties where metascope_export_export_id = ?"); + propertiesStmt.setString(1, export.getExportId()); + ResultSet propsRs = propertiesStmt.executeQuery(); + while (propsRs.next()) { + String key = propsRs.getString("export_properties_key"); + String value = propsRs.getString("export_properties"); + export.addProperty(key, value); + } + } + } catch (SQLException e) { + LOG.error("Could not retrieve table", e); + } finally { + DbUtils.closeQuietly(rs); + DbUtils.closeQuietly(stmt); + DbUtils.closeQuietly(propertiesStmt); + } + return export; + } + + public void save(Connection connection, List exports, String fqdn) { + String deleteQuery = "delete from metascope_export where table_fqdn = ?"; + String deletePropertyQuery = "delete from metascope_export_export_properties where metascope_export_export_id = ?"; + String insertTableSql = "insert into metascope_export (export_id, export_type, table_fqdn) values " + + "(?, ?, ?) on duplicate key update export_id=values(export_id), export_type=values(export_type), " + + "table_fqdn=values(table_fqdn)"; + String insertPropsSql = "insert into metascope_export_export_properties (metascope_export_export_id, export_properties_key, " + + "export_properties) values (?, ?, ?) on duplicate key update metascope_export_export_id=values(metascope_export_export_id), " + + "export_properties_key=values(export_properties_key), export_properties=values(export_properties)"; + PreparedStatement stmt = null; + PreparedStatement propsStmt = null; + PreparedStatement deleteStmt = null; + PreparedStatement deletePropsStmt = null; + try { + int batch = 0; + disableChecks(connection); + + deleteStmt = connection.prepareStatement(deleteQuery); + deleteStmt.setString(1, fqdn); + deleteStmt.execute(); + + for (MetascopeExport export : exports) { + deletePropsStmt = connection.prepareStatement(deletePropertyQuery); + deletePropsStmt.setString(1, export.getExportId()); + deletePropsStmt.execute(); + deletePropsStmt.close(); + } + + stmt = connection.prepareStatement(insertTableSql); + for (MetascopeExport export : exports) { + stmt.setString(1, export.getExportId()); + stmt.setString(2, export.getExportType()); + stmt.setString(3, export.getTableFqdn()); + stmt.addBatch(); + + batch++; + if (batch % 1024 == 0) { + stmt.executeBatch(); + } + } + stmt.executeBatch(); + + batch = 0; + propsStmt = connection.prepareStatement(insertPropsSql); + for (MetascopeExport export : exports) { + for (Map.Entry entry : export.getProperties().entrySet()) { + propsStmt.setString(1, export.getExportId()); + propsStmt.setString(2, entry.getKey()); + propsStmt.setString(3, entry.getValue()); + propsStmt.addBatch(); + } + + batch++; + if (batch % 1024 == 0) { + propsStmt.executeBatch(); + } + } + propsStmt.executeBatch(); + + connection.commit(); + enableChecks(connection); + } catch (SQLException e) { + LOG.error("Could not save/update exports", e); + } finally { + DbUtils.closeQuietly(stmt); + DbUtils.closeQuietly(deleteStmt); + DbUtils.closeQuietly(deletePropsStmt); + } + } + +} diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeFieldRepository.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeFieldRepository.java new file mode 100644 index 000000000..e01def779 --- /dev/null +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeFieldRepository.java @@ -0,0 +1,146 @@ +package org.schedoscope.metascope.repository.jdbc.entity; + +import org.apache.commons.dbutils.DbUtils; +import org.schedoscope.metascope.model.MetascopeField; +import org.schedoscope.metascope.repository.jdbc.JDBCContext; +import org.schedoscope.metascope.task.model.FieldDependency; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.*; +import java.util.List; +import java.util.Set; + +public class JDBCMetascopeFieldRepository extends JDBCContext { + + private static final Logger LOG = LoggerFactory.getLogger(JDBCMetascopeFieldRepository.class); + + public JDBCMetascopeFieldRepository(boolean isMySQLDatabase, boolean isH2Database) { + super(isMySQLDatabase, isH2Database); + } + + public MetascopeField findField(Connection connection, String fieldFqdn) { + MetascopeField field = null; + String findQuery = "select field_id, field_name, field_type, field_order, is_parameter, description, comment_id, table_fqdn " + + "from metascope_field where field_id = ?"; + PreparedStatement stmt = null; + ResultSet rs = null; + try { + stmt = connection.prepareStatement(findQuery); + stmt.setString(1, fieldFqdn); + rs = stmt.executeQuery(); + if (rs.next()) { + field = new MetascopeField(); + field.setFieldId(rs.getString("field_id")); + field.setFieldName(rs.getString("field_name")); + field.setFieldType(rs.getString("field_type")); + field.setFieldOrder(rs.getInt("field_order")); + field.setParameter(rs.getBoolean("is_parameter")); + field.setDescription(rs.getString("description")); + field.setTableFqdn(rs.getString("table_fqdn")); + long commentId = rs.getLong("comment_id"); + field.setCommentId(rs.wasNull() ? null : commentId); + } + } catch (SQLException e) { + LOG.error("Could not retrieve table", e); + } finally { + DbUtils.closeQuietly(rs); + DbUtils.closeQuietly(stmt); + } + return field; + } + + public void saveFields(Connection connection, Set fields, String fqdn, String mappingTable) { + String deleteQuery = "delete from metascope_field where table_fqdn = ?"; + String deleteFromMappingTable = "delete from " + mappingTable + " where metascope_table_fqdn = ?"; + String insertIntoMetascopeField = "insert into metascope_field (field_id, field_name, field_type, field_order, " + + "is_parameter, description, comment_id, table_fqdn) values " + + "(?, ?, ?, ?, ?, ?, ?) on duplicate key update field_id=values(field_id), field_name=values(field_name), " + + "field_type=values(field_type), field_order=values(field_order), is_parameter=values(is_parameter), " + + "description=values(description), comment_id=values(comment_id), table_fqdn=values(table_fqdn)"; + String insertIntoMappingTable = "insert into " + mappingTable + " (metascope_table_fqdn, fields_field_id) values " + + "(?,?) on duplicate key update metascope_table_fqdn=values(metascope_table_fqdn), fields_field_id=values(fields_field_id)"; + PreparedStatement insertMain = null; + PreparedStatement insertMapping = null; + try { + int batch = 0; + disableChecks(connection); + + PreparedStatement deleteStmt = connection.prepareStatement(deleteQuery); + deleteStmt.setString(1, fqdn); + deleteStmt.executeUpdate(); + deleteStmt.close(); + + deleteStmt = connection.prepareStatement(deleteFromMappingTable); + deleteStmt.setString(1, fqdn); + deleteStmt.execute(); + deleteStmt.close(); + + insertMain = connection.prepareStatement(insertIntoMetascopeField); + insertMapping = connection.prepareStatement(insertIntoMappingTable); + for (MetascopeField field : fields) { + insertMain.setString(1, field.getFieldId()); + insertMain.setString(2, field.getFieldName()); + insertMain.setString(3, field.getFieldType()); + insertMain.setInt(4, field.getFieldOrder()); + insertMain.setBoolean(5, field.isParameter()); + insertMain.setString(6, field.getDescription()); + insertMain.setLong(7, field.getCommentId()); + insertMain.setString(8, field.getTableFqdn()); + insertMain.addBatch(); + + insertMapping.setString(1, field.getTableFqdn()); + insertMapping.setString(2, field.getFieldId()); + insertMapping.addBatch(); + batch++; + if (batch % 1024 == 0) { + insertMain.executeBatch(); + insertMapping.executeBatch(); + } + } + insertMain.executeBatch(); + insertMapping.executeBatch(); + connection.commit(); + enableChecks(connection); + } catch (SQLException e) { + LOG.error("Could not save/update fields", e); + } finally { + DbUtils.closeQuietly(insertMain); + DbUtils.closeQuietly(insertMapping); + } + } + + public void insertFieldDependencies(Connection connection, List fieldDependencies) { + String deleteQuery = "delete from metascope_field_relationship"; + String sql = "insert into metascope_field_relationship (successor, dependency) values (?, ?) " + + "on duplicate key update successor=values(successor), dependency=values(dependency)"; + PreparedStatement stmt = null; + try { + int batch = 0; + disableChecks(connection); + + Statement deleteStmt = connection.createStatement(); + deleteStmt.execute(deleteQuery); + deleteStmt.close(); + + stmt = connection.prepareStatement(sql); + for (FieldDependency fieldDependency : fieldDependencies) { + stmt.setString(1, fieldDependency.getDependency()); + stmt.setString(2, fieldDependency.getSuccessor()); + stmt.addBatch(); + batch++; + if (batch % 1024 == 0) { + stmt.executeBatch(); + } + } + stmt.executeBatch(); + connection.commit(); + enableChecks(connection); + } catch (SQLException e) { + LOG.error("Could not save view", e); + } finally { + DbUtils.closeQuietly(stmt); + } + } + +} diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeMetadataRepository.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeMetadataRepository.java new file mode 100644 index 000000000..f2491c849 --- /dev/null +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeMetadataRepository.java @@ -0,0 +1,38 @@ +package org.schedoscope.metascope.repository.jdbc.entity; + +import org.apache.commons.dbutils.DbUtils; +import org.schedoscope.metascope.repository.jdbc.JDBCContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +public class JDBCMetascopeMetadataRepository extends JDBCContext { + + private static final Logger LOG = LoggerFactory.getLogger(JDBCMetascopeMetadataRepository.class); + + public JDBCMetascopeMetadataRepository(boolean isMySQLDatabase, boolean isH2Database) { + super(isMySQLDatabase, isH2Database); + } + + public void saveMetadata(Connection connection, String key, String value) { + String insertTableSql = "insert into metascope_metadata (metadata_key, metadata_value) values " + + "(?, ?) on duplicate key update metadata_key=values(metadata_key), metadata_value=values(metadata_value)"; + PreparedStatement stmt = null; + try { + disableChecks(connection); + stmt = connection.prepareStatement(insertTableSql); + stmt.setString(1, key); + stmt.setString(2, value); + stmt.execute(); + enableChecks(connection); + } catch (SQLException e) { + LOG.error("Could not save/update metadata", e); + } finally { + DbUtils.closeQuietly(stmt); + } + } + +} diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeTableRepository.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeTableRepository.java new file mode 100644 index 000000000..4069a06c6 --- /dev/null +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeTableRepository.java @@ -0,0 +1,181 @@ +package org.schedoscope.metascope.repository.jdbc.entity; + +import org.apache.commons.dbutils.DbUtils; +import org.schedoscope.metascope.model.MetascopeTable; +import org.schedoscope.metascope.model.MetascopeTransformation; +import org.schedoscope.metascope.repository.jdbc.JDBCContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class JDBCMetascopeTableRepository extends JDBCContext { + + private static final Logger LOG = LoggerFactory.getLogger(JDBCMetascopeTableRepository.class); + + public JDBCMetascopeTableRepository(boolean isMySQLDatabase, boolean isH2Database) { + super(isMySQLDatabase, isH2Database); + } + + public MetascopeTable findTable(Connection connection, String fqdn) { + MetascopeTable table = null; + String findQuery = "select fqdn, schedoscope_id, database_name, table_name, view_path, " + + "external_table, table_description, storage_format, input_format, output_format, materialize_once, created_at, " + + "table_owner, data_path, data_size, permissions, rowcount, last_data, timestamp_field, timestamp_field_format, " + + "last_change, last_partition_created, last_schema_change, last_transformation_timestamp, view_count, views_size, " + + "person_responsible, comment_id" + + "from metascope_table where fqdn = ?"; + PreparedStatement stmt = null; + try { + stmt = connection.prepareStatement(findQuery); + stmt.setString(1, fqdn); + ResultSet rs = stmt.executeQuery(); + if (rs.next()) { + table = new MetascopeTable(); + table.setFqdn(rs.getString("fqdn")); + table.setSchedoscopeId(rs.getString("schedoscope_id")); + table.setDatabaseName(rs.getString("database_name")); + table.setTableName(rs.getString("table_name")); + table.setViewPath(rs.getString("view_path")); + table.setExternalTable(rs.getBoolean("external_table")); + table.setTableDescription(rs.getString("table_description")); + table.setStorageFormat(rs.getString("storage_format")); + table.setInputFormat(rs.getString("input_format")); + table.setOutputFormat(rs.getString("output_format")); + table.setMaterializeOnce(rs.getBoolean("materialize_once")); + table.setCreatedAt(rs.getLong("created_at")); + table.setTableOwner(rs.getString("table_owner")); + table.setDataPath(rs.getString("data_path")); + table.setDataSize(rs.getLong("data_size")); + table.setPermissions(rs.getString("permissions")); + table.setRowcount(rs.getLong("rowcount")); + table.setLastData(rs.getString("last_data")); + table.setTimestampField(rs.getString("timestamp_field")); + table.setTimestampFieldFormat(rs.getString("timestamp_field_format")); + table.setLastChange(rs.getLong("last_change")); + table.setLastPartitionCreated(rs.getLong("last_partition_created")); + table.setLastSchemaChange(rs.getLong("last_schema_change")); + table.setLastTransformation(rs.getLong("last_transformation_timestamp")); + table.setViewCount(rs.getInt("view_count")); + table.setViewsSize(rs.getInt("views_size")); + table.setPersonResponsible(rs.getString("person_responsible")); + long comment_id = rs.getLong("comment_id"); + table.setCommentId(rs.wasNull() ? null : comment_id); + } + } catch (SQLException e) { + LOG.error("Could not retrieve table", e); + } finally { + DbUtils.closeQuietly(stmt); + } + return table; + } + + public void save(Connection connection, MetascopeTable table) { + String insertTableSql = "insert into metascope_table (fqdn, schedoscope_id, database_name, table_name, view_path, " + + "external_table, table_description, storage_format, input_format, output_format, materialize_once, created_at, " + + "table_owner, data_path, data_size, permissions, rowcount, last_data, timestamp_field, timestamp_field_format, " + + "last_change, last_partition_created, last_schema_change, last_transformation_timestamp, view_count, views_size, " + + "person_responsible, comment_id) values " + + "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) on duplicate key update " + + "fqdn=values(fqdn), " + + "schedoscope_id=values(schedoscope_id), " + + "database_name=values(database_name), " + + "table_name=values(table_name), " + + "view_path=values(view_path), " + + "external_table=values(external_table), " + + "table_description=values(table_description), " + + "storage_format=values(storage_format), " + + "input_format=values(input_format), " + + "output_format=values(output_format), " + + "materialize_once=values(materialize_once), " + + "created_at=values(created_at), " + + "table_owner=values(table_owner), " + + "data_path=values(data_path), " + + "data_size=values(data_size), " + + "permissions=values(permissions), " + + "rowcount=values(rowcount), " + + "last_data=values(last_data), " + + "timestamp_field=values(timestamp_field), " + + "timestamp_field_format=values(timestamp_field_format), " + + "last_change=values(last_change)" + + "last_partition_created=values(last_partition_created)" + + "last_schema_change=values(last_schema_change)" + + "last_transformation_timestamp=values(last_transformation_timestamp)" + + "view_count=values(view_count)" + + "views_size=values(views_size)" + + "person_responsible=values(person_responsible)" + + "comment_id=values(comment_id)"; + PreparedStatement stmt = null; + try { + disableChecks(connection); + stmt = connection.prepareStatement(insertTableSql); + stmt.setString(1, table.getFqdn()); + stmt.setString(2, table.getSchedoscopeId()); + stmt.setString(3, table.getDatabaseName()); + stmt.setString(4, table.getTableName()); + stmt.setString(5, table.getViewPath()); + stmt.setBoolean(6, table.isExternalTable()); + stmt.setString(7, table.getTableDescription()); + stmt.setString(8, table.getStorageFormat()); + stmt.setString(9, table.getInputFormat()); + stmt.setString(10, table.getOutputFormat()); + stmt.setBoolean(11, table.isMaterializeOnce()); + stmt.setLong(12, table.getCreatedAt()); + stmt.setString(13, table.getTableOwner()); + stmt.setString(14, table.getDataPath()); + stmt.setLong(15, table.getDataSize()); + stmt.setString(16, table.getPermissions()); + stmt.setLong(17, table.getRowcount()); + stmt.setString(18, table.getLastData()); + stmt.setString(19, table.getTimestampField()); + stmt.setString(20, table.getTimestampFieldFormat()); + stmt.setLong(21, table.getLastChange()); + stmt.setLong(22, table.getLastPartitionCreated()); + stmt.setLong(23, table.getLastSchemaChange()); + stmt.setLong(24, table.getLastTransformation()); + stmt.setInt(25, table.getViewCount()); + stmt.setInt(26, table.getViewsSize()); + stmt.setString(27, table.getPersonResponsible()); + stmt.setLong(28, table.getCommentId()); + stmt.execute(); + } catch (SQLException e) { + LOG.error("Could not save/update table", e); + } finally { + DbUtils.closeQuietly(stmt); + } + } + + public void saveTransformation(Connection connection, MetascopeTransformation transformation, String fqdn) { + String deleteQuery = "delete from metascope_transformation where table_fqdn = ?"; + String insertInto = "insert into metascope_transformation (transformation_id, transformation_type, table_fqdn) values " + + "(?, ?, ?) on duplicate key update transformation_id=values(transformation_id), transformation_type=values(transformation_type)," + + "table_fqdn=values(table_fqdn)"; + + PreparedStatement stmt = null; + PreparedStatement delStmt = null; + try { + disableChecks(connection); + + delStmt = connection.prepareStatement(deleteQuery); + delStmt.setString(1, fqdn); + delStmt.execute(); + + stmt = connection.prepareStatement(insertInto); + stmt.setString(1, transformation.getTransformationId()); + stmt.setString(2, transformation.getTransformationType()); + stmt.setString(3, fqdn); + stmt.execute(); + enableChecks(connection); + } catch (SQLException e) { + LOG.error("Could not save/update fields", e); + } finally { + DbUtils.closeQuietly(stmt); + DbUtils.closeQuietly(delStmt); + } + + } + +} diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeViewRepository.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeViewRepository.java new file mode 100644 index 000000000..7cc876f0b --- /dev/null +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeViewRepository.java @@ -0,0 +1,122 @@ +package org.schedoscope.metascope.repository.jdbc.entity; + +import org.apache.commons.dbutils.DbUtils; +import org.schedoscope.metascope.model.MetascopeView; +import org.schedoscope.metascope.repository.jdbc.JDBCContext; +import org.schedoscope.metascope.repository.jdbc.RawJDBCSqlRepository; +import org.schedoscope.metascope.task.model.ViewDependency; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.List; + +public class JDBCMetascopeViewRepository extends JDBCContext { + + private static final Logger LOG = LoggerFactory.getLogger(JDBCMetascopeViewRepository.class); + + public JDBCMetascopeViewRepository(boolean isMySQLDatabase, boolean isH2Database) { + super(isMySQLDatabase, isH2Database); + } + + public void insertOrUpdateViews(Connection connection, Iterable views) { + String deleteQuery = "delete from metascope_view"; + String insertViewSql = "insert into metascope_view (view_id, view_url, parameter_string, table_fqdn) values " + + "(?, ?, ?, ?) on duplicate key update view_id=values(view_id), view_url=values(view_url), " + + "parameter_string=values(parameter_string), table_fqdn=values(table_fqdn)"; + PreparedStatement stmt = null; + try { + int batch = 0; + disableChecks(connection); + + Statement deleteStmt = connection.createStatement(); + deleteStmt.execute(deleteQuery); + deleteStmt.close(); + + stmt = connection.prepareStatement(insertViewSql); + for (MetascopeView viewEntity : views) { + stmt.setString(1, viewEntity.getViewId()); + stmt.setString(2, viewEntity.getViewUrl()); + stmt.setString(3, viewEntity.getParameterString()); + stmt.setString(4, viewEntity.getTable().getFqdn()); + stmt.addBatch(); + batch++; + if (batch % 1024 == 0) { + stmt.executeBatch(); + } + } + stmt.executeBatch(); + connection.commit(); + enableChecks(connection); + } catch (SQLException e) { + LOG.error("Could not save view", e); + } finally { + DbUtils.closeQuietly(stmt); + } + } + + public void insertViewDependencies(Connection connection, List viewDependencies) { + String deleteQuery = "delete from metascope_view_relationship"; + String sql = "insert into metascope_view_relationship (successor, dependency) values (?, ?) " + + "on duplicate key update successor=values(successor), dependency=values(dependency)"; + PreparedStatement stmt = null; + try { + int batch = 0; + disableChecks(connection); + + Statement deleteStmt = connection.createStatement(); + deleteStmt.execute(deleteQuery); + deleteStmt.close(); + + stmt = connection.prepareStatement(sql); + for (ViewDependency viewDependency : viewDependencies) { + stmt.setString(1, viewDependency.getDependency()); + stmt.setString(2, viewDependency.getSuccessor()); + stmt.addBatch(); + batch++; + if (batch % 1024 == 0) { + stmt.executeBatch(); + } + } + stmt.executeBatch(); + connection.commit(); + enableChecks(connection); + } catch (SQLException e) { + LOG.error("Could not save view", e); + } finally { + DbUtils.closeQuietly(stmt); + } + } + + public void updateStatus(Connection connection, Iterable views) { + String updateStatus = "update metascope_view set last_transformation=?, total_size=?, num_rows=? where view_id = ?"; + PreparedStatement updateStatusStmt = null; + try { + int batch = 0; + disableChecks(connection); + updateStatusStmt = connection.prepareStatement(updateStatus); + for (MetascopeView viewEntity : views) { + updateStatusStmt.setLong(1, viewEntity.getLastTransformation()); + updateStatusStmt.setLong(2, viewEntity.getTotalSize()); + updateStatusStmt.setLong(3, viewEntity.getNumRows()); + updateStatusStmt.setString(4, viewEntity.getViewId()); + updateStatusStmt.addBatch(); + batch++; + if (batch % 1024 == 0) { + updateStatusStmt.executeBatch(); + } + } + updateStatusStmt.executeBatch(); + connection.commit(); + enableChecks(connection); + } catch (SQLException e) { + LOG.error("Could not update view", e); + } finally { + DbUtils.closeQuietly(updateStatusStmt); + } + } + +} diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java index abc4c0aa5..274fd1a97 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java @@ -20,11 +20,7 @@ import org.schedoscope.metascope.exception.SchedoscopeConnectException; import org.schedoscope.metascope.index.SolrFacade; import org.schedoscope.metascope.model.*; -import org.schedoscope.metascope.repository.MetascopeExportRepository; -import org.schedoscope.metascope.repository.MetascopeFieldRepository; -import org.schedoscope.metascope.repository.MetascopeTableRepository; import org.schedoscope.metascope.repository.jdbc.RawJDBCSqlRepository; -import org.schedoscope.metascope.service.MetascopeMetadataService; import org.schedoscope.metascope.task.model.*; import org.schedoscope.metascope.util.SchedoscopeUtil; import org.schedoscope.metascope.util.model.SchedoscopeInstance; @@ -47,20 +43,14 @@ public class SchedoscopeTask extends Task { private static final String OCCURRED_AT = "occurred_at"; private static final String OCCURRED_UNTIL = "occurred_until"; private static final String SCHEDOSCOPE_TIMESTAMP_FORMAT = "yyyy-MM-dd''T''HH:mm:ss.SSS''Z''"; + private static final String FIELD_MAPPING_TABLE = "metascope_fields_mapping"; + private static final String PARAMETER_MAPPING_TABLE = "metascope_parameter_mapping"; @Autowired private MetascopeConfig config; @Autowired private SolrFacade solrFacade; @Autowired - private MetascopeTableRepository metascopeTableRepository; - @Autowired - private MetascopeFieldRepository metascopeFieldRepository; - @Autowired - private MetascopeExportRepository metascopeExportRepository; - @Autowired - private MetascopeMetadataService metascopeMetadataService; - @Autowired private DataSource dataSource; private SchedoscopeInstance schedoscopeInstance; @@ -79,6 +69,15 @@ public boolean run(long start) { boolean isH2Database = config.getRepositoryUrl().startsWith("jdbc:h2"); boolean isMySQLDatabase = config.getRepositoryUrl().startsWith("jdbc:mysql"); + Connection connection; + try { + connection = dataSource.getConnection(); + } catch (SQLException e) { + LOG.error("Could not retrieve database connection.", e); + return false; + } + + RawJDBCSqlRepository sqlRepository = new RawJDBCSqlRepository(isMySQLDatabase, isH2Database); /** get data from schedoscope */ ViewStatus viewStatus; @@ -96,7 +95,7 @@ public boolean run(long start) { if (viewStatus.getViews().size() == 0) { LOG.info("[SchedoscopeSyncTask] No schedoscope metadata available. Maybe materialize some views?"); - metascopeMetadataService.save("schedoscopeTimestamp", String.valueOf(System.currentTimeMillis())); + sqlRepository.saveMetadata(connection, "schedoscopeTimestamp", String.valueOf(System.currentTimeMillis())); return false; } @@ -108,20 +107,17 @@ public boolean run(long start) { for (View view : viewStatus.getViews()) { if (view.isTable()) { String fqdn = view.getDatabase() + "." + view.getTableName(); - MetascopeTable table = metascopeTableRepository.findOne(fqdn); + MetascopeTable table = sqlRepository.findTable(connection, fqdn); if (table == null) { table = new MetascopeTable(); table.setFqdn(fqdn); } cachedTables.put(fqdn, table); - LOG.info("Saved table " + fqdn); tableCount++; } } LOG.info("Received " + tableCount + " tables"); - metascopeTableRepository.save(cachedTables.values()); - for (View view : viewStatus.getViews()) { if (view.isTable()) { String fqdn = view.getDatabase() + "." + view.getTableName(); @@ -154,10 +150,11 @@ public boolean run(long start) { int i = 0; for (ViewField viewField : view.getFields()) { String fieldFqdn = fqdn + "." + viewField.getName(); - MetascopeField field = metascopeFieldRepository.findOne(fieldFqdn); + MetascopeField field = sqlRepository.findField(connection, fieldFqdn); if (field == null) { field = new MetascopeField(); field.setFieldId(fieldFqdn); + field.setTableFqdn(fqdn); } field.setFieldName(viewField.getName()); field.setFieldType(viewField.getFieldtype()); @@ -184,16 +181,18 @@ public boolean run(long start) { cachedFields.put(field.getFieldId(), field); } table.setFields(tableFields); + sqlRepository.saveFields(connection, table.getFields(), table.getFqdn(), FIELD_MAPPING_TABLE); /** parameter */ Set tableParameter = new HashSet<>(); i = 0; for (ViewField viewField : view.getParameters()) { String parameterFqdn = fqdn + "." + viewField.getName(); - MetascopeField parameter = metascopeFieldRepository.findOne(parameterFqdn); + MetascopeField parameter = sqlRepository.findField(connection, parameterFqdn); if (parameter == null) { parameter = new MetascopeField(); parameter.setFieldId(parameterFqdn); + parameter.setTableFqdn(fqdn); } parameter.setFieldName(viewField.getName()); parameter.setFieldType(viewField.getFieldtype()); @@ -205,17 +204,19 @@ public boolean run(long start) { tableParameter.add(parameter); } table.setParameters(tableParameter); + sqlRepository.saveFields(connection, table.getParameters(), table.getFqdn(), PARAMETER_MAPPING_TABLE); /** exports */ List tableExports = new ArrayList<>(); i = 0; if (view.getExport() != null) { for (ViewTransformation viewExport : view.getExport()) { - String parameterFqdn = fqdn + "." + viewExport.getName(); - MetascopeExport export = metascopeExportRepository.findOne(parameterFqdn); + String exportFqdn = fqdn + "." + viewExport.getName() + "_" + i; + MetascopeExport export = sqlRepository.findExport(connection, exportFqdn); if (export == null) { export = new MetascopeExport(); - export.setExportId(table.getFqdn() + "_" + (i)); + export.setExportId(exportFqdn); + export.setTableFqdn(fqdn); } export.setExportType(viewExport.getName()); export.setProperties(viewExport.getProperties()); @@ -226,6 +227,7 @@ public boolean run(long start) { } } table.setExports(tableExports); + sqlRepository.saveExports(connection, table.getExports(), table.getFqdn()); /** transformation */ MetascopeTransformation metascopeTransformation = new MetascopeTransformation(); @@ -233,6 +235,7 @@ public boolean run(long start) { metascopeTransformation.setTransformationType(view.getTransformation().getName()); metascopeTransformation.setProperties(view.getTransformation().getProperties()); table.setTransformation(metascopeTransformation); + sqlRepository.saveTransformation(connection, table.getTransformation(), table.getFqdn()); /** views and dependencies */ LOG.info("Getting views for table " + fqdn); @@ -278,17 +281,13 @@ public boolean run(long start) { LOG.info("Processed all views for table " + fqdn); table.setViewsSize(views.size()); - metascopeTableRepository.save(table); + sqlRepository.saveTable(connection, table); LOG.info("Finished processing table " + fqdn); } } - /* save view information via JDBC and raw sql to boost performance and avoid excessive database locking */ - Connection connection = null; try { - connection = dataSource.getConnection(); - RawJDBCSqlRepository sqlRepository = new RawJDBCSqlRepository(isMySQLDatabase, isH2Database); LOG.info("Saving views (" + cachedViews.values().size() + ")..."); sqlRepository.insertOrUpdateViews(connection, cachedViews.values()); LOG.info("Saving field dependency information (" + fieldDependencies.size() + ") ..."); @@ -312,7 +311,7 @@ public boolean run(long start) { solrFacade.commit(); LOG.info("Finished index update"); - metascopeMetadataService.save("schedoscopeTimestamp", String.valueOf(System.currentTimeMillis())); + sqlRepository.saveMetadata(connection, "schedoscopeTimestamp", String.valueOf(System.currentTimeMillis())); LOG.info("Finished sync with schedoscope instance \"" + schedoscopeInstance.getId() + "\""); return true; From d5b303c39afc42a7233919e6e568930cfad478b3 Mon Sep 17 00:00:00 2001 From: Kassem Tohme Date: Wed, 31 May 2017 06:33:01 -0700 Subject: [PATCH 02/24] added more jdbc methods to update metascope metastore --- .../metascope/model/MetascopeAutoSave.java | 2 +- .../metascope/model/MetascopeCategory.java | 2 +- .../model/MetascopeCategoryObject.java | 4 +- .../metascope/model/MetascopeComment.java | 4 +- .../metascope/model/MetascopeField.java | 4 +- .../metascope/model/MetascopeTable.java | 4 +- .../metascope/model/MetascopeTaxonomy.java | 2 +- .../model/MetascopeTransformation.java | 2 +- .../metascope/model/MetascopeView.java | 4 +- .../repository/jdbc/RawJDBCSqlRepository.java | 15 +++--- .../entity/JDBCMetascopeExportRepository.java | 32 ++++++++++- .../entity/JDBCMetascopeFieldRepository.java | 31 +++++++---- .../entity/JDBCMetascopeTableRepository.java | 53 ++++++++++++++----- .../entity/JDBCMetascopeViewRepository.java | 7 ++- .../metascope/task/MetastoreTask.java | 9 +++- .../metascope/task/SchedoscopeTask.java | 29 +++++----- .../{ViewDependency.java => Dependency.java} | 4 +- .../metascope/task/model/FieldDependency.java | 29 ---------- .../application-production.properties | 2 + 19 files changed, 144 insertions(+), 95 deletions(-) rename schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/model/{ViewDependency.java => Dependency.java} (92%) delete mode 100644 schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/model/FieldDependency.java diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeAutoSave.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeAutoSave.java index 90deff18d..05486207a 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeAutoSave.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeAutoSave.java @@ -25,7 +25,7 @@ public class MetascopeAutoSave { @Id private String id; private String tableFqdn; - @Column(columnDefinition = "varchar(32629)") + @Column(columnDefinition = "text") private String text; private long timestamp; diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeCategory.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeCategory.java index e13d98e2a..6e11e0216 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeCategory.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeCategory.java @@ -29,7 +29,7 @@ public class MetascopeCategory { @ManyToOne private MetascopeTaxonomy taxonomy; - @Column(columnDefinition = "varchar(32672)") + @Column(columnDefinition = "text") private String name; @OneToMany(mappedBy = "category", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeCategoryObject.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeCategoryObject.java index 764f1c058..131cf8fb5 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeCategoryObject.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeCategoryObject.java @@ -27,10 +27,10 @@ public class MetascopeCategoryObject { @ManyToOne private MetascopeCategory category; - @Column(columnDefinition = "varchar(32672)") + @Column(columnDefinition = "text") private String name; - @Column(columnDefinition = "varchar(32672)") + @Column(columnDefinition = "text") private String description; public long getCategoryObjectId() { diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeComment.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeComment.java index 5117821c2..32c2f3410 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeComment.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeComment.java @@ -26,9 +26,9 @@ public class MetascopeComment { @Id @GeneratedValue private Long id; - @Column(columnDefinition = "varchar(32629)") + @Column(columnDefinition = "text") private String text; - @Column(columnDefinition = "varchar(32629)") + @Column(columnDefinition = "text") private String plainText; private String username; private long lastEdit; diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeField.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeField.java index 2439fbfde..76e1ce37f 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeField.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeField.java @@ -26,10 +26,10 @@ public class MetascopeField extends Documentable { @Id private String fieldId; private String fieldName; - @Column(columnDefinition = "varchar(31000)") + @Column(columnDefinition = "text") private String fieldType; private int fieldOrder; - @Column(columnDefinition = "varchar(31000)") + @Column(columnDefinition = "text") private String description; private boolean isParameter; @ManyToOne(fetch = FetchType.LAZY) diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTable.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTable.java index a7078239d..27a62666e 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTable.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTable.java @@ -35,7 +35,7 @@ public class MetascopeTable extends Documentable { private String tableName; private String viewPath; private boolean externalTable; - @Column(columnDefinition = "varchar(20000)") + @Column(columnDefinition = "text") private String tableDescription; private String storageFormat; private String inputFormat; @@ -44,7 +44,7 @@ public class MetascopeTable extends Documentable { @Column(columnDefinition = "bigint default 0") private long createdAt; private String tableOwner; - @Column(columnDefinition = "varchar(5000)") + @Column(columnDefinition = "text") private String dataPath; @Column(columnDefinition = "bigint default 0") private long dataSize; diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTaxonomy.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTaxonomy.java index 1c3557563..8de1b5fb6 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTaxonomy.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTaxonomy.java @@ -26,7 +26,7 @@ public class MetascopeTaxonomy { @GeneratedValue(strategy = GenerationType.AUTO) private long taxonomyId; - @Column(columnDefinition = "varchar(32672)") + @Column(columnDefinition = "text") private String name; @OneToMany(mappedBy = "taxonomy", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTransformation.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTransformation.java index f2393f353..7c3ea0f48 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTransformation.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTransformation.java @@ -25,7 +25,7 @@ public class MetascopeTransformation { private String transformationId; private String transformationType; @ElementCollection - @Column(length = 32000) + @Column(length = 21000) private Map properties; @OneToOne(fetch = FetchType.LAZY) private MetascopeTable table; diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeView.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeView.java index 40ded6f7c..6b44d3df4 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeView.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeView.java @@ -25,9 +25,9 @@ public class MetascopeView { @Id @Column(columnDefinition = "varchar(766)") private String viewId; - @Column(columnDefinition = "varchar(5000)") + @Column(columnDefinition = "text") private String viewUrl; - @Column(columnDefinition = "varchar(5000)") + @Column(columnDefinition = "text") private String parameterString; @Column(columnDefinition = "bigint default 0") private long numRows; diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/RawJDBCSqlRepository.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/RawJDBCSqlRepository.java index 61bfac667..a471bfcb7 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/RawJDBCSqlRepository.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/RawJDBCSqlRepository.java @@ -17,8 +17,7 @@ import org.schedoscope.metascope.model.*; import org.schedoscope.metascope.repository.jdbc.entity.*; -import org.schedoscope.metascope.task.model.FieldDependency; -import org.schedoscope.metascope.task.model.ViewDependency; +import org.schedoscope.metascope.task.model.Dependency; import java.sql.Connection; import java.util.List; @@ -53,12 +52,16 @@ public void saveTransformation(Connection connection, MetascopeTransformation tr this.jdbcMetascopeTableRepository.saveTransformation(connection, transformation, fqdn); } + public void insertTableDependencies(Connection connection, String fqdn, String depdencyFqdn) { + this.jdbcMetascopeTableRepository.saveDependency(connection, fqdn, depdencyFqdn); + } + /*### MetascopeView ###*/ public void insertOrUpdateViews(Connection connection, Iterable views) { this.jdbcMetascopeViewRepository.insertOrUpdateViews(connection, views); } - public void insertViewDependencies(Connection connection, List viewDependencies) { + public void insertViewDependencies(Connection connection, List viewDependencies) { this.jdbcMetascopeViewRepository.insertViewDependencies(connection, viewDependencies); } @@ -71,11 +74,11 @@ public MetascopeField findField(Connection connection, String fieldFqdn) { return this.jdbcMetascopeFieldRepository.findField(connection, fieldFqdn); } - public void saveFields(Connection connection, Set fields, String fqdn, String mappingTable) { - this.jdbcMetascopeFieldRepository.saveFields(connection, fields, fqdn, mappingTable); + public void saveFields(Connection connection, Set fields, String fqdn, boolean isParameter) { + this.jdbcMetascopeFieldRepository.saveFields(connection, fields, fqdn, isParameter); } - public void insertFieldDependencies(Connection connection, List fieldDependencies) { + public void insertFieldDependencies(Connection connection, List fieldDependencies) { this.jdbcMetascopeFieldRepository.insertFieldDependencies(connection, fieldDependencies); } diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeExportRepository.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeExportRepository.java index 3c0cb167a..6f7eba121 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeExportRepository.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeExportRepository.java @@ -60,16 +60,22 @@ public MetascopeExport findExport(Connection connection, String exportFqdn) { public void save(Connection connection, List exports, String fqdn) { String deleteQuery = "delete from metascope_export where table_fqdn = ?"; String deletePropertyQuery = "delete from metascope_export_export_properties where metascope_export_export_id = ?"; + String deleteMappingQuery = "delete from metascope_table_exports where metascope_table_fqdn = ?"; String insertTableSql = "insert into metascope_export (export_id, export_type, table_fqdn) values " + "(?, ?, ?) on duplicate key update export_id=values(export_id), export_type=values(export_type), " + "table_fqdn=values(table_fqdn)"; String insertPropsSql = "insert into metascope_export_export_properties (metascope_export_export_id, export_properties_key, " + "export_properties) values (?, ?, ?) on duplicate key update metascope_export_export_id=values(metascope_export_export_id), " + "export_properties_key=values(export_properties_key), export_properties=values(export_properties)"; + String insertMappingSql = "insert into metascope_table_exports (metascope_table_fqdn, exports_export_id) " + + "values (?, ?) on duplicate key update metascope_table_fqdn=values(metascope_table_fqdn), " + + "exports_export_id=values(exports_export_id)"; PreparedStatement stmt = null; PreparedStatement propsStmt = null; + PreparedStatement mappingStmt = null; PreparedStatement deleteStmt = null; PreparedStatement deletePropsStmt = null; + PreparedStatement deleteMappingStmt = null; try { int batch = 0; disableChecks(connection); @@ -85,6 +91,10 @@ public void save(Connection connection, List exports, String fq deletePropsStmt.close(); } + deleteMappingStmt = connection.prepareStatement(deleteMappingQuery); + deleteMappingStmt.setString(1, fqdn); + deleteMappingStmt.execute(); + stmt = connection.prepareStatement(insertTableSql); for (MetascopeExport export : exports) { stmt.setString(1, export.getExportId()); @@ -107,14 +117,29 @@ public void save(Connection connection, List exports, String fq propsStmt.setString(2, entry.getKey()); propsStmt.setString(3, entry.getValue()); propsStmt.addBatch(); + + batch++; + if (batch % 1024 == 0) { + propsStmt.executeBatch(); + } } + } + propsStmt.executeBatch(); + + batch = 0; + mappingStmt = connection.prepareStatement(insertMappingSql); + for (MetascopeExport export : exports) { + mappingStmt.setString(1, fqdn); + mappingStmt.setString(2, export.getExportId()); + mappingStmt.addBatch(); + batch++; if (batch % 1024 == 0) { - propsStmt.executeBatch(); + mappingStmt.executeBatch(); } } - propsStmt.executeBatch(); + mappingStmt.executeBatch(); connection.commit(); enableChecks(connection); @@ -122,8 +147,11 @@ public void save(Connection connection, List exports, String fq LOG.error("Could not save/update exports", e); } finally { DbUtils.closeQuietly(stmt); + DbUtils.closeQuietly(propsStmt); + DbUtils.closeQuietly(mappingStmt); DbUtils.closeQuietly(deleteStmt); DbUtils.closeQuietly(deletePropsStmt); + DbUtils.closeQuietly(deleteMappingStmt); } } diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeFieldRepository.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeFieldRepository.java index e01def779..1e2f5bc69 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeFieldRepository.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeFieldRepository.java @@ -3,7 +3,7 @@ import org.apache.commons.dbutils.DbUtils; import org.schedoscope.metascope.model.MetascopeField; import org.schedoscope.metascope.repository.jdbc.JDBCContext; -import org.schedoscope.metascope.task.model.FieldDependency; +import org.schedoscope.metascope.task.model.Dependency; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -15,6 +15,11 @@ public class JDBCMetascopeFieldRepository extends JDBCContext { private static final Logger LOG = LoggerFactory.getLogger(JDBCMetascopeFieldRepository.class); + private static final String FIELD_MAPPING_TABLE = "metascope_fields_mapping"; + private static final String PARAMETER_MAPPING_TABLE = "metascope_parameter_mapping"; + private static final String FIELD_MAPPING_FIELD = "fields_field_id"; + private static final String PARAMETER_MAPPING_FIELD = "parameters_field_id"; + public JDBCMetascopeFieldRepository(boolean isMySQLDatabase, boolean isH2Database) { super(isMySQLDatabase, isH2Database); } @@ -50,16 +55,19 @@ public MetascopeField findField(Connection connection, String fieldFqdn) { return field; } - public void saveFields(Connection connection, Set fields, String fqdn, String mappingTable) { - String deleteQuery = "delete from metascope_field where table_fqdn = ?"; + public void saveFields(Connection connection, Set fields, String fqdn, boolean isParameter) { + String mappingTable = isParameter ? PARAMETER_MAPPING_TABLE : FIELD_MAPPING_TABLE; + String mappingField = isParameter ? PARAMETER_MAPPING_FIELD : FIELD_MAPPING_FIELD; + + String deleteQuery = "delete from metascope_field where table_fqdn = ? and is_parameter = ?"; String deleteFromMappingTable = "delete from " + mappingTable + " where metascope_table_fqdn = ?"; String insertIntoMetascopeField = "insert into metascope_field (field_id, field_name, field_type, field_order, " + "is_parameter, description, comment_id, table_fqdn) values " - + "(?, ?, ?, ?, ?, ?, ?) on duplicate key update field_id=values(field_id), field_name=values(field_name), " + + "(?, ?, ?, ?, ?, ?, ?, ?) on duplicate key update field_id=values(field_id), field_name=values(field_name), " + "field_type=values(field_type), field_order=values(field_order), is_parameter=values(is_parameter), " + "description=values(description), comment_id=values(comment_id), table_fqdn=values(table_fqdn)"; - String insertIntoMappingTable = "insert into " + mappingTable + " (metascope_table_fqdn, fields_field_id) values " - + "(?,?) on duplicate key update metascope_table_fqdn=values(metascope_table_fqdn), fields_field_id=values(fields_field_id)"; + String insertIntoMappingTable = "insert into " + mappingTable + " (metascope_table_fqdn, " + mappingField + ") values " + + "(?,?) on duplicate key update metascope_table_fqdn=values(metascope_table_fqdn), " + mappingField + "=values(" + mappingField + ")"; PreparedStatement insertMain = null; PreparedStatement insertMapping = null; try { @@ -68,6 +76,7 @@ public void saveFields(Connection connection, Set fields, String PreparedStatement deleteStmt = connection.prepareStatement(deleteQuery); deleteStmt.setString(1, fqdn); + deleteStmt.setBoolean(2, isParameter); deleteStmt.executeUpdate(); deleteStmt.close(); @@ -85,7 +94,11 @@ public void saveFields(Connection connection, Set fields, String insertMain.setInt(4, field.getFieldOrder()); insertMain.setBoolean(5, field.isParameter()); insertMain.setString(6, field.getDescription()); - insertMain.setLong(7, field.getCommentId()); + if (field.getCommentId() == null) { + insertMain.setNull(7, Types.BIGINT); + } else { + insertMain.setLong(7, field.getCommentId()); + } insertMain.setString(8, field.getTableFqdn()); insertMain.addBatch(); @@ -110,7 +123,7 @@ public void saveFields(Connection connection, Set fields, String } } - public void insertFieldDependencies(Connection connection, List fieldDependencies) { + public void insertFieldDependencies(Connection connection, List fieldDependencies) { String deleteQuery = "delete from metascope_field_relationship"; String sql = "insert into metascope_field_relationship (successor, dependency) values (?, ?) " + "on duplicate key update successor=values(successor), dependency=values(dependency)"; @@ -124,7 +137,7 @@ public void insertFieldDependencies(Connection connection, List deleteStmt.close(); stmt = connection.prepareStatement(sql); - for (FieldDependency fieldDependency : fieldDependencies) { + for (Dependency fieldDependency : fieldDependencies) { stmt.setString(1, fieldDependency.getDependency()); stmt.setString(2, fieldDependency.getSuccessor()); stmt.addBatch(); diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeTableRepository.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeTableRepository.java index 4069a06c6..221fb26a5 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeTableRepository.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeTableRepository.java @@ -7,10 +7,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; +import java.sql.*; +import java.util.Map; public class JDBCMetascopeTableRepository extends JDBCContext { @@ -26,7 +24,7 @@ public MetascopeTable findTable(Connection connection, String fqdn) { + "external_table, table_description, storage_format, input_format, output_format, materialize_once, created_at, " + "table_owner, data_path, data_size, permissions, rowcount, last_data, timestamp_field, timestamp_field_format, " + "last_change, last_partition_created, last_schema_change, last_transformation_timestamp, view_count, views_size, " - + "person_responsible, comment_id" + + "person_responsible, comment_id " + "from metascope_table where fqdn = ?"; PreparedStatement stmt = null; try { @@ -100,13 +98,13 @@ public void save(Connection connection, MetascopeTable table) { + "last_data=values(last_data), " + "timestamp_field=values(timestamp_field), " + "timestamp_field_format=values(timestamp_field_format), " - + "last_change=values(last_change)" - + "last_partition_created=values(last_partition_created)" - + "last_schema_change=values(last_schema_change)" - + "last_transformation_timestamp=values(last_transformation_timestamp)" - + "view_count=values(view_count)" - + "views_size=values(views_size)" - + "person_responsible=values(person_responsible)" + + "last_change=values(last_change), " + + "last_partition_created=values(last_partition_created), " + + "last_schema_change=values(last_schema_change), " + + "last_transformation_timestamp=values(last_transformation_timestamp), " + + "view_count=values(view_count), " + + "views_size=values(views_size), " + + "person_responsible=values(person_responsible), " + "comment_id=values(comment_id)"; PreparedStatement stmt = null; try { @@ -139,7 +137,11 @@ public void save(Connection connection, MetascopeTable table) { stmt.setInt(25, table.getViewCount()); stmt.setInt(26, table.getViewsSize()); stmt.setString(27, table.getPersonResponsible()); - stmt.setLong(28, table.getCommentId()); + if (table.getCommentId() == null) { + stmt.setNull(28, Types.BIGINT); + } else { + stmt.setLong(28, table.getCommentId()); + } stmt.execute(); } catch (SQLException e) { LOG.error("Could not save/update table", e); @@ -150,12 +152,18 @@ public void save(Connection connection, MetascopeTable table) { public void saveTransformation(Connection connection, MetascopeTransformation transformation, String fqdn) { String deleteQuery = "delete from metascope_transformation where table_fqdn = ?"; + String deletePropsQuery = "delete from metascope_transformation_properties where metascope_transformation_transformation_id = ?"; String insertInto = "insert into metascope_transformation (transformation_id, transformation_type, table_fqdn) values " + "(?, ?, ?) on duplicate key update transformation_id=values(transformation_id), transformation_type=values(transformation_type)," + "table_fqdn=values(table_fqdn)"; + String insertIntoProps = "insert into metascope_transformation_properties (metascope_transformation_transformation_id, properties_key, properties) values " + + "(?, ?, ?) on duplicate key update metascope_transformation_transformation_id=values(metascope_transformation_transformation_id), " + + "properties_key=values(properties_key), properties=values(properties)"; PreparedStatement stmt = null; + PreparedStatement propsStmt = null; PreparedStatement delStmt = null; + PreparedStatement delPropsStmt = null; try { disableChecks(connection); @@ -163,19 +171,38 @@ public void saveTransformation(Connection connection, MetascopeTransformation tr delStmt.setString(1, fqdn); delStmt.execute(); + delPropsStmt = connection.prepareStatement(deletePropsQuery); + delPropsStmt.setString(1, transformation.getTransformationId()); + delPropsStmt.execute(); + stmt = connection.prepareStatement(insertInto); stmt.setString(1, transformation.getTransformationId()); stmt.setString(2, transformation.getTransformationType()); stmt.setString(3, fqdn); stmt.execute(); + + for (Map.Entry entry : transformation.getProperties().entrySet()) { + propsStmt = connection.prepareStatement(insertIntoProps); + propsStmt.setString(1, transformation.getTransformationId()); + propsStmt.setString(2, entry.getKey()); + propsStmt.setString(3, entry.getValue()); + propsStmt.execute(); + } + enableChecks(connection); } catch (SQLException e) { LOG.error("Could not save/update fields", e); } finally { DbUtils.closeQuietly(stmt); + DbUtils.closeQuietly(propsStmt); DbUtils.closeQuietly(delStmt); + DbUtils.closeQuietly(delPropsStmt); } } + public void saveDependency(Connection connection, String fqdn, String depdencyFqdn) { + + } + } diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeViewRepository.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeViewRepository.java index 7cc876f0b..16c16a03c 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeViewRepository.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeViewRepository.java @@ -3,8 +3,7 @@ import org.apache.commons.dbutils.DbUtils; import org.schedoscope.metascope.model.MetascopeView; import org.schedoscope.metascope.repository.jdbc.JDBCContext; -import org.schedoscope.metascope.repository.jdbc.RawJDBCSqlRepository; -import org.schedoscope.metascope.task.model.ViewDependency; +import org.schedoscope.metascope.task.model.Dependency; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,7 +57,7 @@ public void insertOrUpdateViews(Connection connection, Iterable v } } - public void insertViewDependencies(Connection connection, List viewDependencies) { + public void linsertViewDependencies(Connection connection, List viewDependencies) { String deleteQuery = "delete from metascope_view_relationship"; String sql = "insert into metascope_view_relationship (successor, dependency) values (?, ?) " + "on duplicate key update successor=values(successor), dependency=values(dependency)"; @@ -72,7 +71,7 @@ public void insertViewDependencies(Connection connection, List v deleteStmt.close(); stmt = connection.prepareStatement(sql); - for (ViewDependency viewDependency : viewDependencies) { + for (Dependency viewDependency : viewDependencies) { stmt.setString(1, viewDependency.getDependency()); stmt.setString(2, viewDependency.getSuccessor()); stmt.addBatch(); diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/MetastoreTask.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/MetastoreTask.java index cdfdeadd9..b81e7508a 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/MetastoreTask.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/MetastoreTask.java @@ -109,8 +109,13 @@ public boolean run(long start) { table.setInputFormat(mTable.getSd().getInputFormat()); table.setOutputFormat(mTable.getSd().getOutputFormat()); table.setDataPath(mTable.getSd().getLocation()); - table.setDataSize(getDirectorySize(fs, table.getDataPath())); - table.setPermissions(getPermission(fs, table.getDataPath())); + try { + table.setDataSize(getDirectorySize(fs, table.getDataPath())); + table.setPermissions(getPermission(fs, table.getDataPath())); + } catch (IllegalArgumentException e) { + LOG.warn("Could not retrieve dir size: " + e.getMessage()); + LOG.debug("ERROR: Could not read HDFS metadata", e); + } long maxLastTransformation = -1; diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java index 274fd1a97..b1e411ea3 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java @@ -43,8 +43,6 @@ public class SchedoscopeTask extends Task { private static final String OCCURRED_AT = "occurred_at"; private static final String OCCURRED_UNTIL = "occurred_until"; private static final String SCHEDOSCOPE_TIMESTAMP_FORMAT = "yyyy-MM-dd''T''HH:mm:ss.SSS''Z''"; - private static final String FIELD_MAPPING_TABLE = "metascope_fields_mapping"; - private static final String PARAMETER_MAPPING_TABLE = "metascope_parameter_mapping"; @Autowired private MetascopeConfig config; @@ -61,8 +59,9 @@ public boolean run(long start) { Map cachedTables = new HashMap<>(); Map cachedFields = new HashMap<>(); Map cachedViews = new HashMap<>(); - List viewDependencies = new ArrayList<>(); - List fieldDependencies = new ArrayList<>(); + List tableDependencies = new ArrayList<>(); + List viewDependencies = new ArrayList<>(); + List fieldDependencies = new ArrayList<>(); LOG.info("Retrieve and parse data from schedoscope instance \"" + schedoscopeInstance.getId() + "\""); @@ -172,7 +171,7 @@ public boolean run(long start) { dField.setFieldId(dependencyField); cachedFields.put(dependencyField, dField); } - fieldDependencies.add(new FieldDependency(field.getFieldId(), dField.getFieldId())); + fieldDependencies.add(new Dependency(field.getFieldId(), dField.getFieldId())); } } } @@ -181,7 +180,7 @@ public boolean run(long start) { cachedFields.put(field.getFieldId(), field); } table.setFields(tableFields); - sqlRepository.saveFields(connection, table.getFields(), table.getFqdn(), FIELD_MAPPING_TABLE); + sqlRepository.saveFields(connection, table.getFields(), table.getFqdn(), false); /** parameter */ Set tableParameter = new HashSet<>(); @@ -204,7 +203,7 @@ public boolean run(long start) { tableParameter.add(parameter); } table.setParameters(tableParameter); - sqlRepository.saveFields(connection, table.getParameters(), table.getFqdn(), PARAMETER_MAPPING_TABLE); + sqlRepository.saveFields(connection, table.getParameters(), table.getFqdn(), true); /** exports */ List tableExports = new ArrayList<>(); @@ -265,7 +264,7 @@ public boolean run(long start) { } metascopeView.addToDependencies(dependencyView); dependencyView.addToSuccessors(metascopeView); - viewDependencies.add(new ViewDependency(metascopeView.getViewId(), dependencyView.getViewId())); + viewDependencies.add(new Dependency(metascopeView.getViewId(), dependencyView.getViewId())); } } for (String dependency : partition.getDependencies().keySet()) { @@ -273,6 +272,8 @@ public boolean run(long start) { MetascopeTable dep = cachedTables.get(dqpFqdn); table.addToDependencies(dep); dep.addToSuccessor(table); + tableDependencies.add(new Dependency(fqdn, dep.getFqdn())); + sqlRepository.saveDependency(connection, fqdn, dep.getFqdn()); } cachedViews.put(partition.getName(), metascopeView); metascopeView.setTable(table); @@ -298,12 +299,6 @@ public boolean run(long start) { LOG.error("Error writing to database", e); } - try { - connection.close(); - } catch (SQLException e) { - LOG.error("Could not close connection", e); - } - LOG.info("Saving to index"); for (MetascopeTable table : cachedTables.values()) { solrFacade.updateTablePartial(table, false); @@ -313,6 +308,12 @@ public boolean run(long start) { sqlRepository.saveMetadata(connection, "schedoscopeTimestamp", String.valueOf(System.currentTimeMillis())); + try { + connection.close(); + } catch (SQLException e) { + LOG.error("Could not close connection", e); + } + LOG.info("Finished sync with schedoscope instance \"" + schedoscopeInstance.getId() + "\""); return true; } diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/model/ViewDependency.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/model/Dependency.java similarity index 92% rename from schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/model/ViewDependency.java rename to schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/model/Dependency.java index 50e346cb1..70112173a 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/model/ViewDependency.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/model/Dependency.java @@ -15,12 +15,12 @@ */ package org.schedoscope.metascope.task.model; -public class ViewDependency { +public class Dependency { private String successor; private String dependency; - public ViewDependency(String successor, String dependency) { + public Dependency(String successor, String dependency) { this.successor = successor; this.dependency = dependency; } diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/model/FieldDependency.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/model/FieldDependency.java deleted file mode 100644 index fd646416e..000000000 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/model/FieldDependency.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.schedoscope.metascope.task.model; - -public class FieldDependency { - - private String successor; - private String dependency; - - public FieldDependency(String successor, String dependency) { - this.successor = successor; - this.dependency = dependency; - } - - public String getSuccessor() { - return successor; - } - - public void setSuccessor(String successor) { - this.successor = successor; - } - - public String getDependency() { - return dependency; - } - - public void setDependency(String dependency) { - this.dependency = dependency; - } - -} diff --git a/schedoscope-metascope/src/main/resources/application-production.properties b/schedoscope-metascope/src/main/resources/application-production.properties index 2f1e09078..e777130e9 100644 --- a/schedoscope-metascope/src/main/resources/application-production.properties +++ b/schedoscope-metascope/src/main/resources/application-production.properties @@ -13,5 +13,7 @@ spring.jpa.properties.hibernate.order_inserts=true spring.jpa.properties.hibernate.order_updates=true spring.jpa.properties.hibernate.event.merge.entity_copy_observer=allow spring.main.banner-mode=off +spring.jpa.properties.hibernate.connection.characterEncoding=latin1 +spring.jpa.properties.hibernate.connection.CharSet=latin1 #logging.level.org.hibernate.SQL=DEBUG #logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE \ No newline at end of file From 0d53611a0a1f8910ff03fbc84f41186005d338f2 Mon Sep 17 00:00:00 2001 From: Kassem Tohme Date: Thu, 1 Jun 2017 14:33:25 +0200 Subject: [PATCH 03/24] fixed schedoscope sync task --- .../rest/SchedoscopeJsonDataFormat.scala | 2 +- .../service/SchedoscopeService.scala | 3 ++- .../service/SchedoscopeServiceImpl.scala | 3 ++- .../model/MetascopeTransformation.java | 2 +- .../entity/JDBCMetascopeFieldRepository.java | 21 ++++++++++++------- .../entity/JDBCMetascopeViewRepository.java | 7 ++++--- .../metascope/task/SchedoscopeTask.java | 3 +-- .../metascope/util/SchedoscopeUtil.java | 11 ++++++++++ 8 files changed, 35 insertions(+), 17 deletions(-) diff --git a/schedoscope-core/src/main/scala/org/schedoscope/scheduler/rest/SchedoscopeJsonDataFormat.scala b/schedoscope-core/src/main/scala/org/schedoscope/scheduler/rest/SchedoscopeJsonDataFormat.scala index 53bb48f25..872bc785d 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/scheduler/rest/SchedoscopeJsonDataFormat.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/scheduler/rest/SchedoscopeJsonDataFormat.scala @@ -27,7 +27,7 @@ object SchedoscopeJsonDataFormat extends DefaultJsonProtocol { implicit val actionStatusFormat = jsonFormat5(TransformationStatus) implicit val actionStatusListFormat = jsonFormat2(TransformationStatusList) implicit val viewTransformationStatusFormat: JsonFormat[ViewTransformationStatus] = lazyFormat(jsonFormat2(ViewTransformationStatus)) - implicit val viewStatusFormat: JsonFormat[ViewStatus] = lazyFormat(jsonFormat14(ViewStatus)) + implicit val viewStatusFormat: JsonFormat[ViewStatus] = lazyFormat(jsonFormat15(ViewStatus)) implicit val fieldStatusFormat: JsonFormat[FieldStatus] = lazyFormat(jsonFormat3(FieldStatus)) implicit val viewStatusListFormat = jsonFormat2(ViewStatusList) implicit val queueStatusListFormat = jsonFormat2(QueueStatusList) diff --git a/schedoscope-core/src/main/scala/org/schedoscope/scheduler/service/SchedoscopeService.scala b/schedoscope-core/src/main/scala/org/schedoscope/scheduler/service/SchedoscopeService.scala index 0dcf17483..72de5d3ab 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/scheduler/service/SchedoscopeService.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/scheduler/service/SchedoscopeService.scala @@ -37,7 +37,8 @@ case class ViewStatus( storageFormat: Option[String], materializeOnce: Option[Boolean], comment: Option[Option[String]], - isTable: Option[Boolean]) + isTable: Option[Boolean], + isExternal: Boolean) case class FieldStatus(name: String, fieldtype: String, comment: Option[String]) diff --git a/schedoscope-core/src/main/scala/org/schedoscope/scheduler/service/SchedoscopeServiceImpl.scala b/schedoscope-core/src/main/scala/org/schedoscope/scheduler/service/SchedoscopeServiceImpl.scala index 7d691c298..2415e20d0 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/scheduler/service/SchedoscopeServiceImpl.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/scheduler/service/SchedoscopeServiceImpl.scala @@ -148,7 +148,8 @@ class SchedoscopeServiceImpl(actorSystem: ActorSystem, settings: SchedoscopeSett storageFormat = if (overview) None else Option(vsr.view.storageFormat.getClass.getSimpleName), materializeOnce = if (overview) None else Option(vsr.view.isMaterializeOnce), comment = if (overview) None else Option(vsr.view.comment), - isTable = isTable + isTable = isTable, + isExternal = vsr.view.isExternal ) private def viewStatusListFromStatusResponses(viewStatusResponses: List[ViewStatusResponse], diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTransformation.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTransformation.java index 7c3ea0f48..a67aead1f 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTransformation.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTransformation.java @@ -25,7 +25,7 @@ public class MetascopeTransformation { private String transformationId; private String transformationType; @ElementCollection - @Column(length = 21000) + @Column(columnDefinition = "text") private Map properties; @OneToOne(fetch = FetchType.LAZY) private MetascopeTable table; diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeFieldRepository.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeFieldRepository.java index 1e2f5bc69..a817cace3 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeFieldRepository.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeFieldRepository.java @@ -70,20 +70,22 @@ public void saveFields(Connection connection, Set fields, String + "(?,?) on duplicate key update metascope_table_fqdn=values(metascope_table_fqdn), " + mappingField + "=values(" + mappingField + ")"; PreparedStatement insertMain = null; PreparedStatement insertMapping = null; + PreparedStatement deleteStmt = null; + PreparedStatement deleteMappingStmt = null; try { int batch = 0; disableChecks(connection); - PreparedStatement deleteStmt = connection.prepareStatement(deleteQuery); + deleteStmt = connection.prepareStatement(deleteQuery); deleteStmt.setString(1, fqdn); deleteStmt.setBoolean(2, isParameter); deleteStmt.executeUpdate(); deleteStmt.close(); - deleteStmt = connection.prepareStatement(deleteFromMappingTable); - deleteStmt.setString(1, fqdn); - deleteStmt.execute(); - deleteStmt.close(); + deleteMappingStmt = connection.prepareStatement(deleteFromMappingTable); + deleteMappingStmt.setString(1, fqdn); + deleteMappingStmt.execute(); + deleteMappingStmt.close(); insertMain = connection.prepareStatement(insertIntoMetascopeField); insertMapping = connection.prepareStatement(insertIntoMappingTable); @@ -120,6 +122,8 @@ public void saveFields(Connection connection, Set fields, String } finally { DbUtils.closeQuietly(insertMain); DbUtils.closeQuietly(insertMapping); + DbUtils.closeQuietly(deleteStmt); + DbUtils.closeQuietly(deleteMappingStmt); } } @@ -128,13 +132,13 @@ public void insertFieldDependencies(Connection connection, List fiel String sql = "insert into metascope_field_relationship (successor, dependency) values (?, ?) " + "on duplicate key update successor=values(successor), dependency=values(dependency)"; PreparedStatement stmt = null; + Statement delStmt = null; try { int batch = 0; disableChecks(connection); - Statement deleteStmt = connection.createStatement(); - deleteStmt.execute(deleteQuery); - deleteStmt.close(); + delStmt = connection.createStatement(); + delStmt.execute(deleteQuery); stmt = connection.prepareStatement(sql); for (Dependency fieldDependency : fieldDependencies) { @@ -153,6 +157,7 @@ public void insertFieldDependencies(Connection connection, List fiel LOG.error("Could not save view", e); } finally { DbUtils.closeQuietly(stmt); + DbUtils.closeQuietly(delStmt); } } diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeViewRepository.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeViewRepository.java index 16c16a03c..4851d7cc1 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeViewRepository.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeViewRepository.java @@ -57,18 +57,18 @@ public void insertOrUpdateViews(Connection connection, Iterable v } } - public void linsertViewDependencies(Connection connection, List viewDependencies) { + public void insertViewDependencies(Connection connection, List viewDependencies) { String deleteQuery = "delete from metascope_view_relationship"; String sql = "insert into metascope_view_relationship (successor, dependency) values (?, ?) " + "on duplicate key update successor=values(successor), dependency=values(dependency)"; PreparedStatement stmt = null; + Statement deleteStmt = null; try { int batch = 0; disableChecks(connection); - Statement deleteStmt = connection.createStatement(); + deleteStmt = connection.createStatement(); deleteStmt.execute(deleteQuery); - deleteStmt.close(); stmt = connection.prepareStatement(sql); for (Dependency viewDependency : viewDependencies) { @@ -87,6 +87,7 @@ public void linsertViewDependencies(Connection connection, List view LOG.error("Could not save view", e); } finally { DbUtils.closeQuietly(stmt); + DbUtils.closeQuietly(deleteStmt); } } diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java index b1e411ea3..05bcd1a89 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java @@ -118,7 +118,7 @@ public boolean run(long start) { LOG.info("Received " + tableCount + " tables"); for (View view : viewStatus.getViews()) { - if (view.isTable()) { + if (view.isTable() && !view.isExternal()) { String fqdn = view.getDatabase() + "." + view.getTableName(); LOG.info("Consuming table " + fqdn); @@ -273,7 +273,6 @@ public boolean run(long start) { table.addToDependencies(dep); dep.addToSuccessor(table); tableDependencies.add(new Dependency(fqdn, dep.getFqdn())); - sqlRepository.saveDependency(connection, fqdn, dep.getFqdn()); } cachedViews.put(partition.getName(), metascopeView); metascopeView.setTable(table); diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/SchedoscopeUtil.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/SchedoscopeUtil.java index fee3d2084..338ff16d3 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/SchedoscopeUtil.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/SchedoscopeUtil.java @@ -79,6 +79,17 @@ private static String getViewsAsJsonFromSchedoscope(boolean all, boolean depende url += "&filter=" + filter; } + //TODO + if (all && port == 20698) { + url = "http://localhost:9090/eci"; + } else if (!all && port == 20698) { + url = "http://localhost:9090/eci-status"; + } else if (all && port == 30698) { + url = "http://localhost:9090/ogm"; + } else if (!all && port == 30698) { + url = "http://localhost:9090/ogm-status"; + } + return makeRequest(url); } From c199dd70458389993e5e1d8f05ebf3a861b00215 Mon Sep 17 00:00:00 2001 From: Kassem Tohme Date: Thu, 1 Jun 2017 19:18:49 +0200 Subject: [PATCH 04/24] correct merging of metadata from multiple schedoscope instances --- .../service/SchedoscopeServiceImplSpec.scala | 22 ++++----- .../metascope/index/SolrUpdateHandler.java | 3 ++ .../metascope/model/MetascopeTable.java | 10 +++++ .../repository/jdbc/RawJDBCSqlRepository.java | 9 ++-- .../entity/JDBCMetascopeFieldRepository.java | 24 +++++++--- .../entity/JDBCMetascopeTableRepository.java | 45 ++++++++++++++++++- .../entity/JDBCMetascopeViewRepository.java | 15 +------ .../metascope/task/SchedoscopeTask.java | 18 ++++---- .../metascope/task/model/View.java | 8 ++-- 9 files changed, 106 insertions(+), 48 deletions(-) diff --git a/schedoscope-core/src/test/scala/org/schedoscope/scheduler/service/SchedoscopeServiceImplSpec.scala b/schedoscope-core/src/test/scala/org/schedoscope/scheduler/service/SchedoscopeServiceImplSpec.scala index 3067510f7..80bb124bb 100644 --- a/schedoscope-core/src/test/scala/org/schedoscope/scheduler/service/SchedoscopeServiceImplSpec.scala +++ b/schedoscope-core/src/test/scala/org/schedoscope/scheduler/service/SchedoscopeServiceImplSpec.scala @@ -496,7 +496,7 @@ class SchedoscopeServiceImplSpec extends TestKit(ActorSystem("schedoscope")) val expected = ViewStatusList(Map("loading" -> 1), List(ViewStatus("test.views/Brand/test", - None, "loading", None, None, None, None, None, None, None, None, None, None, None))) + None, "loading", None, None, None, None, None, None, None, None, None, None, None, false))) whenReady(response) { result => result shouldBe expected @@ -517,14 +517,14 @@ class SchedoscopeServiceImplSpec extends TestKit(ActorSystem("schedoscope")) properties = Some(Map("errors" -> "false", "incomplete" -> "false")), fields = None, parameters = None, dependencies = None, lineage = None, transformation = None, export = None, storageFormat = None, materializeOnce = None, - comment = None, isTable = None) + comment = None, isTable = None, isExternal = false) val prodExpected = ViewStatus(viewPath = productDependency01.urlPath, viewTableName = None, status = "materialized", properties = Some(Map("errors" -> "false", "incomplete" -> "false")), fields = None, parameters = None, dependencies = None, lineage = None, transformation = None, export = None, storageFormat = None, materializeOnce = None, - comment = None, isTable = None) + comment = None, isTable = None, isExternal = false) viewManagerActor ? brandVSRmsg viewManagerActor ? prodVSRmsg @@ -553,14 +553,14 @@ class SchedoscopeServiceImplSpec extends TestKit(ActorSystem("schedoscope")) properties = Some(Map("errors" -> "true", "incomplete" -> "true")), fields = None, parameters = None, dependencies = None, lineage = None, transformation = None, export = None, storageFormat = None, materializeOnce = None, comment = None, - isTable = None) + isTable = None, isExternal = false) val prodExpected = ViewStatus(viewPath = productDependency01.urlPath, viewTableName = None, status = "materialized", properties = Some(Map("errors" -> "true", "incomplete" -> "true")), fields = None, parameters = None, dependencies = None, lineage = None, transformation = None, export = None, storageFormat = None, materializeOnce = None, comment = None, - isTable = None) + isTable = None, isExternal = false) viewManagerActor ? brandVSRmsg viewManagerActor ? prodVSRmsg @@ -589,14 +589,14 @@ class SchedoscopeServiceImplSpec extends TestKit(ActorSystem("schedoscope")) properties = Some(Map("errors" -> "true", "incomplete" -> "true")), fields = None, parameters = None, dependencies = None, lineage = None, transformation = None, export = None, storageFormat = None, materializeOnce = None, comment = None, - isTable = None) + isTable = None, isExternal = false) val prodExpected = ViewStatus(viewPath = productDependency01.urlPath, viewTableName = None, status = "materialized", properties = Some(Map("errors" -> "true", "incomplete" -> "true")), fields = None, parameters = None, dependencies = None, lineage = None, transformation = None, export = None, storageFormat = None, materializeOnce = None, comment = None, - isTable = None) + isTable = None, isExternal = false) viewManagerActor ? brandVSRmsg viewManagerActor ? prodVSRmsg @@ -626,14 +626,14 @@ class SchedoscopeServiceImplSpec extends TestKit(ActorSystem("schedoscope")) properties = Some(Map("errors" -> "true", "incomplete" -> "true")), fields = None, parameters = None, dependencies = None, lineage = None, transformation = None, export = None, storageFormat = None, materializeOnce = None, comment = None, - isTable = None) + isTable = None, isExternal = false) val prodExpected = ViewStatus(viewPath = productDependency01.urlPath, viewTableName = None, status = "materialized", properties = Some(Map("errors" -> "true", "incomplete" -> "true")), fields = None, parameters = None, dependencies = None, lineage = None, transformation = None, export = None, storageFormat = None, materializeOnce = None, comment = None, - isTable = None) + isTable = None, isExternal = false) viewManagerActor ? brandVSRmsg viewManagerActor ? prodVSRmsg @@ -661,14 +661,14 @@ class SchedoscopeServiceImplSpec extends TestKit(ActorSystem("schedoscope")) properties = Some(Map("errors" -> "false", "incomplete" -> "true")), fields = None, parameters = None, dependencies = None, lineage = None, transformation = None, export = None, storageFormat = None, materializeOnce = None, comment = None, - isTable = None) + isTable = None, isExternal = false) val prodExpected = ViewStatus(viewPath = productDependency01.urlPath, viewTableName = None, status = "materialized", properties = Some(Map("errors" -> "false", "incomplete" -> "true")), fields = None, parameters = None, dependencies = None, lineage = None, transformation = None, export = None, storageFormat = None, materializeOnce = None, comment = None, - isTable = None) + isTable = None, isExternal = false) viewManagerActor ? brandVSRmsg viewManagerActor ? prodVSRmsg diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/index/SolrUpdateHandler.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/index/SolrUpdateHandler.java index 0808cb97f..c04d9c50e 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/index/SolrUpdateHandler.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/index/SolrUpdateHandler.java @@ -142,6 +142,9 @@ public void updateTablePartial(MetascopeTable table, boolean commit) { if (table.getFields().size() > 0) { doc.setField(FIELDS, table.getFieldNames()); } + if (table.getParameters().size() > 0) { + doc.setField(PARAMETERS, table.getParameterNames()); + } doc.setField(TRANSFORMATION, table.getTransformation().getTransformationType().split(" -> ")[0]); if (table.getExports() != null) { doc.setField(EXPORTS, table.getExportNames()); diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTable.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTable.java index 27a62666e..0eb21d6cd 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTable.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/model/MetascopeTable.java @@ -105,9 +105,19 @@ public class MetascopeTable extends Documentable { private List views; @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @JoinTable(name = "metascope_table_relationship", + joinColumns = @JoinColumn(name = "successor"), + inverseJoinColumns = @JoinColumn(name = "dependency"), + uniqueConstraints = @UniqueConstraint(columnNames = {"dependency", "successor"}) + ) private List successors; @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @JoinTable(name = "metascope_table_relationship", + joinColumns = @JoinColumn(name = "dependency"), + inverseJoinColumns = @JoinColumn(name = "successor"), + uniqueConstraints = @UniqueConstraint(columnNames = {"dependency", "successor"}) + ) private List dependencies; /* ### GETTER/SETTER START ### */ diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/RawJDBCSqlRepository.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/RawJDBCSqlRepository.java index a471bfcb7..f5cd45882 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/RawJDBCSqlRepository.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/RawJDBCSqlRepository.java @@ -20,6 +20,7 @@ import org.schedoscope.metascope.task.model.Dependency; import java.sql.Connection; +import java.util.Collection; import java.util.List; import java.util.Set; @@ -52,8 +53,8 @@ public void saveTransformation(Connection connection, MetascopeTransformation tr this.jdbcMetascopeTableRepository.saveTransformation(connection, transformation, fqdn); } - public void insertTableDependencies(Connection connection, String fqdn, String depdencyFqdn) { - this.jdbcMetascopeTableRepository.saveDependency(connection, fqdn, depdencyFqdn); + public void insertTableDependencies(Connection connection, Collection currentTables, List tables) { + this.jdbcMetascopeTableRepository.saveTableDependency(connection, currentTables, tables); } /*### MetascopeView ###*/ @@ -78,8 +79,8 @@ public void saveFields(Connection connection, Set fields, String this.jdbcMetascopeFieldRepository.saveFields(connection, fields, fqdn, isParameter); } - public void insertFieldDependencies(Connection connection, List fieldDependencies) { - this.jdbcMetascopeFieldRepository.insertFieldDependencies(connection, fieldDependencies); + public void insertFieldDependencies(Connection connection, Collection currentTables, List fieldDependencies) { + this.jdbcMetascopeFieldRepository.insertFieldDependencies(connection, currentTables, fieldDependencies); } /*### MetascopeExport ###*/ diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeFieldRepository.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeFieldRepository.java index a817cace3..10a910080 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeFieldRepository.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeFieldRepository.java @@ -2,12 +2,14 @@ import org.apache.commons.dbutils.DbUtils; import org.schedoscope.metascope.model.MetascopeField; +import org.schedoscope.metascope.model.MetascopeTable; import org.schedoscope.metascope.repository.jdbc.JDBCContext; import org.schedoscope.metascope.task.model.Dependency; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.sql.*; +import java.util.Collection; import java.util.List; import java.util.Set; @@ -127,19 +129,29 @@ public void saveFields(Connection connection, Set fields, String } } - public void insertFieldDependencies(Connection connection, List fieldDependencies) { - String deleteQuery = "delete from metascope_field_relationship"; + public void insertFieldDependencies(Connection connection, Collection currentTables, List fieldDependencies) { + String delSql = "delete from metascope_field_relationship where successor like ? or dependency like ?"; String sql = "insert into metascope_field_relationship (successor, dependency) values (?, ?) " + "on duplicate key update successor=values(successor), dependency=values(dependency)"; PreparedStatement stmt = null; - Statement delStmt = null; + PreparedStatement delStmt = null; try { int batch = 0; disableChecks(connection); - delStmt = connection.createStatement(); - delStmt.execute(deleteQuery); + delStmt = connection.prepareStatement(delSql); + for (MetascopeTable t : currentTables) { + delStmt.setString(1, t.getFqdn() + "%"); + delStmt.setString(2, t.getFqdn() + "%"); + delStmt.addBatch(); + batch++; + if (batch % 1024 == 0) { + delStmt.executeBatch(); + } + } + delStmt.executeBatch(); + batch = 0; stmt = connection.prepareStatement(sql); for (Dependency fieldDependency : fieldDependencies) { stmt.setString(1, fieldDependency.getDependency()); @@ -154,7 +166,7 @@ public void insertFieldDependencies(Connection connection, List fiel connection.commit(); enableChecks(connection); } catch (SQLException e) { - LOG.error("Could not save view", e); + LOG.error("Could not save field deoendencies", e); } finally { DbUtils.closeQuietly(stmt); DbUtils.closeQuietly(delStmt); diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeTableRepository.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeTableRepository.java index 221fb26a5..784fd3586 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeTableRepository.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeTableRepository.java @@ -4,10 +4,13 @@ import org.schedoscope.metascope.model.MetascopeTable; import org.schedoscope.metascope.model.MetascopeTransformation; import org.schedoscope.metascope.repository.jdbc.JDBCContext; +import org.schedoscope.metascope.task.model.Dependency; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.sql.*; +import java.util.Collection; +import java.util.List; import java.util.Map; public class JDBCMetascopeTableRepository extends JDBCContext { @@ -201,8 +204,48 @@ public void saveTransformation(Connection connection, MetascopeTransformation tr } - public void saveDependency(Connection connection, String fqdn, String depdencyFqdn) { + public void saveTableDependency(Connection connection, Collection currentTables, List tableDependencies) { + String delSql = "delete from metascope_table_relationship where successor = ? or dependency = ?"; + String sql = "insert into metascope_table_relationship (successor, dependency) values (?, ?) " + + "on duplicate key update successor=values(successor), dependency=values(dependency)"; + PreparedStatement stmt = null; + PreparedStatement delStmt = null; + try { + int batch = 0; + disableChecks(connection); + delStmt = connection.prepareStatement(delSql); + for (MetascopeTable t : currentTables) { + delStmt.setString(1, t.getFqdn()); + delStmt.setString(2, t.getFqdn()); + delStmt.addBatch(); + batch++; + if (batch % 1024 == 0) { + delStmt.executeBatch(); + } + } + delStmt.executeBatch(); + + batch = 0; + stmt = connection.prepareStatement(sql); + for (Dependency tableDependency : tableDependencies) { + stmt.setString(1, tableDependency.getDependency()); + stmt.setString(2, tableDependency.getSuccessor()); + stmt.addBatch(); + batch++; + if (batch % 1024 == 0) { + stmt.executeBatch(); + } + } + stmt.executeBatch(); + connection.commit(); + enableChecks(connection); + } catch (SQLException e) { + LOG.error("Could not save table deoendencies", e); + } finally { + DbUtils.closeQuietly(stmt); + DbUtils.closeQuietly(delStmt); + } } } diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeViewRepository.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeViewRepository.java index 4851d7cc1..34f6793c1 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeViewRepository.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/repository/jdbc/entity/JDBCMetascopeViewRepository.java @@ -22,7 +22,6 @@ public JDBCMetascopeViewRepository(boolean isMySQLDatabase, boolean isH2Database } public void insertOrUpdateViews(Connection connection, Iterable views) { - String deleteQuery = "delete from metascope_view"; String insertViewSql = "insert into metascope_view (view_id, view_url, parameter_string, table_fqdn) values " + "(?, ?, ?, ?) on duplicate key update view_id=values(view_id), view_url=values(view_url), " + "parameter_string=values(parameter_string), table_fqdn=values(table_fqdn)"; @@ -31,10 +30,6 @@ public void insertOrUpdateViews(Connection connection, Iterable v int batch = 0; disableChecks(connection); - Statement deleteStmt = connection.createStatement(); - deleteStmt.execute(deleteQuery); - deleteStmt.close(); - stmt = connection.prepareStatement(insertViewSql); for (MetascopeView viewEntity : views) { stmt.setString(1, viewEntity.getViewId()); @@ -43,7 +38,7 @@ public void insertOrUpdateViews(Connection connection, Iterable v stmt.setString(4, viewEntity.getTable().getFqdn()); stmt.addBatch(); batch++; - if (batch % 1024 == 0) { + if (batch % 10000 == 0) { stmt.executeBatch(); } } @@ -58,25 +53,20 @@ public void insertOrUpdateViews(Connection connection, Iterable v } public void insertViewDependencies(Connection connection, List viewDependencies) { - String deleteQuery = "delete from metascope_view_relationship"; String sql = "insert into metascope_view_relationship (successor, dependency) values (?, ?) " + "on duplicate key update successor=values(successor), dependency=values(dependency)"; PreparedStatement stmt = null; - Statement deleteStmt = null; try { int batch = 0; disableChecks(connection); - deleteStmt = connection.createStatement(); - deleteStmt.execute(deleteQuery); - stmt = connection.prepareStatement(sql); for (Dependency viewDependency : viewDependencies) { stmt.setString(1, viewDependency.getDependency()); stmt.setString(2, viewDependency.getSuccessor()); stmt.addBatch(); batch++; - if (batch % 1024 == 0) { + if (batch % 10000 == 0) { stmt.executeBatch(); } } @@ -87,7 +77,6 @@ public void insertViewDependencies(Connection connection, List viewD LOG.error("Could not save view", e); } finally { DbUtils.closeQuietly(stmt); - DbUtils.closeQuietly(deleteStmt); } } diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java index 05bcd1a89..64d7cd118 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java @@ -59,6 +59,7 @@ public boolean run(long start) { Map cachedTables = new HashMap<>(); Map cachedFields = new HashMap<>(); Map cachedViews = new HashMap<>(); + List viewsToPersist = new ArrayList<>(); List tableDependencies = new ArrayList<>(); List viewDependencies = new ArrayList<>(); List fieldDependencies = new ArrayList<>(); @@ -104,7 +105,7 @@ public boolean run(long start) { /** save tables to avoid foreign key constraint violation */ int tableCount = 0; for (View view : viewStatus.getViews()) { - if (view.isTable()) { + if (view.isTable() && !view.isExternal()) { String fqdn = view.getDatabase() + "." + view.getTableName(); MetascopeTable table = sqlRepository.findTable(connection, fqdn); if (table == null) { @@ -249,6 +250,7 @@ public boolean run(long start) { metascopeView.setViewId(partition.getName()); cachedViews.put(partition.getName(), metascopeView); } + viewsToPersist.add(metascopeView); if (table.getParameters() != null && table.getParameters().size() > 0) { String parameterString = getParameterString(partition.getName(), table); metascopeView.setParameterString(parameterString); @@ -268,11 +270,7 @@ public boolean run(long start) { } } for (String dependency : partition.getDependencies().keySet()) { - String dqpFqdn = dependency; - MetascopeTable dep = cachedTables.get(dqpFqdn); - table.addToDependencies(dep); - dep.addToSuccessor(table); - tableDependencies.add(new Dependency(fqdn, dep.getFqdn())); + tableDependencies.add(new Dependency(fqdn, dependency)); } cachedViews.put(partition.getName(), metascopeView); metascopeView.setTable(table); @@ -288,10 +286,12 @@ public boolean run(long start) { } try { - LOG.info("Saving views (" + cachedViews.values().size() + ")..."); - sqlRepository.insertOrUpdateViews(connection, cachedViews.values()); LOG.info("Saving field dependency information (" + fieldDependencies.size() + ") ..."); - sqlRepository.insertFieldDependencies(connection, fieldDependencies); + sqlRepository.insertFieldDependencies(connection, cachedTables.values(), fieldDependencies); + LOG.info("Saving table dependency information (" + tableDependencies.size() + ") ..."); + sqlRepository.insertTableDependencies(connection, cachedTables.values(), tableDependencies); + LOG.info("Saving views (" + viewsToPersist.size() + ")..."); + sqlRepository.insertOrUpdateViews(connection, viewsToPersist); LOG.info("Saving view dependency information (" + viewDependencies.size() + ") ..."); sqlRepository.insertViewDependencies(connection, viewDependencies); } catch (Exception e) { diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/model/View.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/model/View.java index 24b6ae2fa..495e0f6f4 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/model/View.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/model/View.java @@ -41,7 +41,7 @@ public class View { private ViewTransformation transformation; private List export; private String storageFormat; - private boolean external; + private boolean isExternal; private boolean materializeOnce; private String comment; private long createdAt; @@ -173,11 +173,11 @@ public void setStorageFormat(String storageFormat) { } public boolean isExternal() { - return external; + return isExternal; } - public void setExternal(boolean external) { - this.external = external; + public void setIsExternal(boolean isExternal) { + this.isExternal = isExternal; } public boolean isMaterializeOnce() { From 4a9871c2f7fa40ace19a30517a3c00ab24a5e0ae Mon Sep 17 00:00:00 2001 From: Jan Hicken Date: Mon, 12 Jun 2017 15:29:28 +0200 Subject: [PATCH 05/24] New lineage graphs * Rectify View.affects() to use the correct view instance with View.register() * Let Metascope retrieve schema-level lineage from Schedoscope * Implement a schema-level lineage graph using dagre-d3 * Switch from vis.js to dagre-d3 for view-level lineage --- .../controller/MetascopeTableController.java | 46 +-- .../service/MetascopeTableService.java | 11 +- .../metascope/util/LineageUtil.java | 161 ++++------ .../util/model/MetascopeLineageEdge.java | 45 +++ .../util/model/MetascopeLineageNode.java | 53 +++ .../util/model/MetascopeSchemaLineage.java | 26 ++ .../metascope/util/model/Node.java | 118 ------- .../src/main/resources/static/css/lineage.css | 46 +++ .../src/main/resources/static/js/functions.js | 116 ------- .../main/resources/static/js/graphconfig.js | 109 ------- .../resources/static/js/graphdataprocessor.js | 227 ------------- .../main/resources/static/js/lineage-graph.js | 154 +++++++++ .../resources/static/js/metascopegraph.js | 304 ------------------ .../src/main/resources/static/js/table.js | 10 - .../src/main/resources/static/js/vis.min.js | 44 --- .../templates/body/schemaLineage.html | 53 +++ .../body/table/sections/dependency.html | 37 +-- .../resources/templates/body/viewLineage.html | 51 +++ .../resources/templates/includes/scripts.html | 5 - 19 files changed, 522 insertions(+), 1094 deletions(-) create mode 100644 schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/model/MetascopeLineageEdge.java create mode 100644 schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/model/MetascopeLineageNode.java create mode 100644 schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/model/MetascopeSchemaLineage.java delete mode 100644 schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/model/Node.java create mode 100644 schedoscope-metascope/src/main/resources/static/css/lineage.css delete mode 100644 schedoscope-metascope/src/main/resources/static/js/graphconfig.js delete mode 100644 schedoscope-metascope/src/main/resources/static/js/graphdataprocessor.js create mode 100644 schedoscope-metascope/src/main/resources/static/js/lineage-graph.js delete mode 100644 schedoscope-metascope/src/main/resources/static/js/metascopegraph.js delete mode 100644 schedoscope-metascope/src/main/resources/static/js/vis.min.js create mode 100644 schedoscope-metascope/src/main/resources/templates/body/schemaLineage.html create mode 100644 schedoscope-metascope/src/main/resources/templates/body/viewLineage.html diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/controller/MetascopeTableController.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/controller/MetascopeTableController.java index 4fef957fc..ada76a1fd 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/controller/MetascopeTableController.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/controller/MetascopeTableController.java @@ -293,42 +293,42 @@ public void increaseViewCount(String fqdn) { } /** - * Returns a JSON for VisJS to render the lineage graph + * Returns a {@link ModelAndView} for the view lineage detail page. * * @param fqdn the table for which the lineage graph is requesed - * @return JSON for VisJS + * @return the corresponding {@link ModelAndView} object */ @RequestMapping(value = "/table/view/lineage", method = RequestMethod.GET) - @ResponseBody - public String getLineage(String fqdn) { + public ModelAndView getLineage(String fqdn) { + ModelAndView mav = new ModelAndView("body/viewLineage"); MetascopeTable table = metascopeTableService.findByFqdn(fqdn); + if (table == null) return new ModelAndView(new RedirectView("/notfound")); - if (table == null) { - return "table not found"; - } + mav.addObject("admin", metascopeUserService.isAdmin()); + mav.addObject("userMgmnt", config.withUserManagement()); + mav.addObject("userEntityService", metascopeUserService); + mav.addObject("lineage", metascopeTableService.getViewLineage(table)); - return metascopeTableService.getLineage(table); + return mav; } /** - * Returns the lineage detail when a node is selected in the lineage graph + * Returns a {@link ModelAndView} for the schema lineage detail page. * - * @param fqdn the table for which the lineage graph is requesed - * @param type the type of the node (either transformation or table) - * @return + * @param fqdn the table for which the schema lineage graph is requested + * @return the corresponding {@link ModelAndView} object */ - @RequestMapping(value = "/table/view/lineage/detail", method = RequestMethod.GET) - @ResponseBody - public ModelAndView getTableDetail(String fqdn, String type) { - ModelAndView mav = null; + @RequestMapping(value = "/table/schema/lineage", method = RequestMethod.GET) + public ModelAndView showSchemaLineage(String fqdn) { + ModelAndView mav = new ModelAndView("body/schemaLineage"); MetascopeTable table = metascopeTableService.findByFqdn(fqdn); - if (table != null) { - mav = new ModelAndView("body/table/sections/lineagedetail"); - mav.addObject("table", table); - mav.addObject("type", type); - mav.addObject("util", htmlUtil); - mav.addObject("metascopeUserService", metascopeUserService); - } + if (table == null) return new ModelAndView(new RedirectView("/notfound")); + + mav.addObject("admin", metascopeUserService.isAdmin()); + mav.addObject("userMgmnt", config.withUserManagement()); + mav.addObject("userEntityService", metascopeUserService); + mav.addObject("lineage", metascopeTableService.getSchemaLineage(table)); + return mav; } diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/service/MetascopeTableService.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/service/MetascopeTableService.java index 9ec29b54e..5eff0d547 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/service/MetascopeTableService.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/service/MetascopeTableService.java @@ -27,6 +27,8 @@ import org.schedoscope.metascope.util.SampleCacheLoader; import org.schedoscope.metascope.util.model.CategoryMap; import org.schedoscope.metascope.util.model.HiveQueryResult; +import org.schedoscope.metascope.util.model.MetascopeLineageEdge; +import org.schedoscope.metascope.util.model.MetascopeSchemaLineage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -255,8 +257,13 @@ public void increaseViewCount(String fqdn) { } @Transactional - public String getLineage(MetascopeTable table) { - return LineageUtil.getDependencyGraph(table); + public Set getViewLineage(MetascopeTable table) { + return LineageUtil.getViewLineage(table); + } + + @Transactional + public MetascopeSchemaLineage getSchemaLineage(MetascopeTable table) { + return LineageUtil.getSchemaLineage(table); } @Async diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/LineageUtil.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/LineageUtil.java index a9b72233f..28ba4e904 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/LineageUtil.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/LineageUtil.java @@ -1,4 +1,4 @@ -/** +/* * Copyright 2017 Otto (GmbH & Co KG) *

* Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,124 +15,83 @@ */ package org.schedoscope.metascope.util; +import org.schedoscope.metascope.model.MetascopeField; import org.schedoscope.metascope.model.MetascopeTable; -import org.schedoscope.metascope.util.model.Node; +import org.schedoscope.metascope.util.model.MetascopeSchemaLineage; +import org.schedoscope.metascope.util.model.MetascopeLineageEdge; +import org.schedoscope.metascope.util.model.MetascopeLineageNode; import java.util.*; public class LineageUtil { + public static Set getViewLineage(MetascopeTable table) { + Set result = new HashSet<>(); - public static String getDependencyGraph(MetascopeTable table) { - List topLevelNodes = getTopLevelNodes(table, 0); - Collections.sort(topLevelNodes); - Map visited = new HashMap<>(); - for (Node topLevelNode : topLevelNodes) { - createDependencyGraph(topLevelNode, visited); - } + getRecursiveViewLineage(result, table, true); + getRecursiveViewLineage(result, table, false); + + return result; + } - int i = 0; - int minLevel = Integer.MAX_VALUE; - int maxLevel = Integer.MIN_VALUE; - for (Node node : visited.values()) { - node.setId(i++); - if (node.getDistanceToCentralNode() < minLevel) { - minLevel = node.getDistanceToCentralNode(); + private static Set getRecursiveViewLineage(Set soFar, MetascopeTable table, boolean isBackward) { + List otherTables = isBackward ? table.getDependencies() : table.getSuccessors(); + + MetascopeLineageNode thisNode = new MetascopeLineageNode(table.getFqdn(), table.getTableName(), table.getDatabaseName()); + for (MetascopeTable otherTable : otherTables) { + MetascopeLineageNode otherNode = new MetascopeLineageNode(otherTable.getFqdn(), otherTable.getTableName(), otherTable.getDatabaseName()); + MetascopeLineageEdge edge; + if (isBackward) { + edge = new MetascopeLineageEdge(otherNode, thisNode); + } else { + edge = new MetascopeLineageEdge(thisNode, otherNode); } - if (node.getDistanceToCentralNode() > maxLevel) { - maxLevel = node.getDistanceToCentralNode(); + if (soFar.add(edge)) { + soFar.addAll(getRecursiveViewLineage(soFar, otherTable, isBackward)); } } - return convertLineageGraphToVisJsNetwork(visited.values(), maxLevel, minLevel); + return soFar; } - private static void createDependencyGraph(Node parent, Map visited) { - if (visited.get(parent.getTable().getFqdn()) == null) { - visited.put(parent.getTable().getFqdn(), parent); - for (MetascopeTable metascopeTable : parent.getTable().getDependencies()) { - Node n = visited.get(metascopeTable.getFqdn()); - boolean alreadyVisited = true; - if (n == null) { - n = new Node(); - n.setTable(metascopeTable); - n.setDistanceToCentralNode(parent.getDistanceToCentralNode() - 1); - alreadyVisited = false; - } - n.addToNexts(parent); - parent.addToPrevious(n); - if (!alreadyVisited) { - createDependencyGraph(n, visited); - } - } + public static MetascopeSchemaLineage getSchemaLineage(MetascopeTable table) { + MetascopeSchemaLineage schemaLineage = new MetascopeSchemaLineage(); + + List forwardEdges = new ArrayList<>(); + List backwardEdges = new ArrayList<>(); + + for (MetascopeField metascopeField : table.getFields()) { + forwardEdges.addAll(computeRecursiveSchemaLineage(metascopeField, false)); } - } - private static List getTopLevelNodes(MetascopeTable table, int distance) { - List toplevelNodes = new ArrayList<>(); - if (table.getSuccessors().isEmpty()) { - Node node = new Node(); - node.setTable(table); - node.setDistanceToCentralNode(distance); - toplevelNodes.add(node); - } else { - for (MetascopeTable metascopeTable : table.getSuccessors()) { - if (metascopeTable.getFqdn().equals(table.getFqdn())) { - continue; - } - - List nodes = getTopLevelNodes(metascopeTable, distance++); - if (toplevelNodes.isEmpty()) { - toplevelNodes.addAll(nodes); - } else { - List newNodes = new ArrayList<>(); - for (Node newNode : nodes) { - boolean isNew = true; - for (Node existing : toplevelNodes) { - if (existing.getTable().equals(newNode.getTable())) { - isNew = false; - if (existing.getDistanceToCentralNode() < newNode.getDistanceToCentralNode()) { - existing.setDistanceToCentralNode(newNode.getDistanceToCentralNode()); - } - } - } - if (isNew) { - newNodes.add(newNode); - } - } - toplevelNodes.addAll(newNodes); - } - } + for (MetascopeField metascopeField : table.getFields()) { + backwardEdges.addAll(computeRecursiveSchemaLineage(metascopeField, true)); } - return toplevelNodes; + + schemaLineage.setForwardEdges(forwardEdges); + schemaLineage.setBackwardEdges(backwardEdges); + + return schemaLineage; } - public static String convertLineageGraphToVisJsNetwork(Collection graph, int maxLevel, int minLevel) { - for (Node node : graph) { - node.setLevel(node.getDistanceToCentralNode() - minLevel); - } - String nodes = "{\n \"nodes\": [\n"; - String edges = "\n \"edges\": [\n"; - int nodeCounter = 0; - int edgeCounter = 0; - for (Node n : graph) { - if (nodeCounter > 0) { - nodes += ", "; - } - String tableName = n.getTable().getFqdn().replace(".", "\\n"); - nodes += "{\n \"id\": " + n.getId() + ",\n \"label\": \"" + tableName + "\",\n \"group\": \"tables\"" - + ",\n \"level\": " + n.getLevel() * 2 + ",\n \"fqdn\": \"" + n.getTable().getFqdn() + "\"\n}"; - nodeCounter++; - for (Node d : n.getNexts()) { - if (edgeCounter > 0) { - edges += ", "; - } - edges += "{\n \"from\": " + d.getId() + ",\n \"to\": " + n.getId() + ",\n \"arrows\": \"from\"\n}"; - edgeCounter++; - } + /** + * Computes the recursive schema lineage edges for a field + * + * @param field the field to compute the edges for + * @param isBackward {@code true}: backward, {@code false}: forward + * @return the edges to display in the graph + */ + private static Set computeRecursiveSchemaLineage(MetascopeField field, boolean isBackward) { + Collection lineage = isBackward ? field.getDependencies() : field.getSuccessors(); + HashSet result = new HashSet<>(); + if (lineage.isEmpty()) return result; + + for (MetascopeField otherField : lineage) { + MetascopeLineageNode from = new MetascopeLineageNode(field.getFieldId(), field.getFieldName(), field.getTable().getFqdn()); + MetascopeLineageNode to = new MetascopeLineageNode(otherField.getFieldId(), otherField.getFieldName(), otherField.getTable().getFqdn()); + result.add(new MetascopeLineageEdge(from, to)); + result.addAll(computeRecursiveSchemaLineage(otherField, isBackward)); } - nodes += "],"; - edges += "]}"; - return nodes + edges; - } + return result; + } } diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/model/MetascopeLineageEdge.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/model/MetascopeLineageEdge.java new file mode 100644 index 000000000..2c6af156c --- /dev/null +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/model/MetascopeLineageEdge.java @@ -0,0 +1,45 @@ +package org.schedoscope.metascope.util.model; + +public class MetascopeLineageEdge { + + private MetascopeLineageNode from; + private MetascopeLineageNode to; + + public MetascopeLineageEdge(MetascopeLineageNode from, MetascopeLineageNode to) { + this.from = from; + this.to = to; + } + + public void setFrom(MetascopeLineageNode from) { + this.from = from; + } + + public void setTo(MetascopeLineageNode to) { + this.to = to; + } + + public MetascopeLineageNode getFrom() { + return from; + } + + public MetascopeLineageNode getTo() { + return to; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + MetascopeLineageEdge that = (MetascopeLineageEdge) o; + + return (from != null ? from.equals(that.from) : that.from == null) && (to != null ? to.equals(that.to) : that.to == null); + } + + @Override + public int hashCode() { + int result = from != null ? from.hashCode() : 0; + result = 31 * result + (to != null ? to.hashCode() : 0); + return result; + } +} diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/model/MetascopeLineageNode.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/model/MetascopeLineageNode.java new file mode 100644 index 000000000..688304e7d --- /dev/null +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/model/MetascopeLineageNode.java @@ -0,0 +1,53 @@ +package org.schedoscope.metascope.util.model; + +public class MetascopeLineageNode { + + private String id; + private String label; + private String parent; + + public MetascopeLineageNode(String id, String label, String parent) { + this.id = id; + this.label = label; + this.parent = parent; + } + + public void setId(String id) { + this.id = id; + } + + public void setLabel(String label) { + this.label = label; + } + + public void setParent(String parent) { + this.parent = parent; + } + + public String getId() { + return id; + } + + public String getLabel() { + return label; + } + + public String getParent() { + return parent; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + MetascopeLineageNode that = (MetascopeLineageNode) o; + + return id != null ? id.equals(that.id) : that.id == null; + } + + @Override + public int hashCode() { + return id != null ? id.hashCode() : 0; + } +} diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/model/MetascopeSchemaLineage.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/model/MetascopeSchemaLineage.java new file mode 100644 index 000000000..7657ef095 --- /dev/null +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/model/MetascopeSchemaLineage.java @@ -0,0 +1,26 @@ +package org.schedoscope.metascope.util.model; + +import java.util.List; + +public class MetascopeSchemaLineage { + + private List forwardEdges; + private List backwardEdges; + + public void setForwardEdges(List forwardEdges) { + this.forwardEdges = forwardEdges; + } + + public void setBackwardEdges(List backwardEdges) { + this.backwardEdges = backwardEdges; + } + + public List getForwardEdges() { + return forwardEdges; + } + + public List getBackwardEdges() { + return backwardEdges; + } + +} diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/model/Node.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/model/Node.java deleted file mode 100644 index b38c5d9a4..000000000 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/util/model/Node.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Copyright 2017 Otto (GmbH & Co KG) - *

- * 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. - */ -package org.schedoscope.metascope.util.model; - -import org.schedoscope.metascope.model.MetascopeTable; - -import java.util.ArrayList; -import java.util.List; - -public class Node implements Comparable { - - private MetascopeTable table; - private int id; - private int level; - private int distanceToCentralNode; - private List nexts; - private List previous; - - public Node() { - this.nexts = new ArrayList<>(); - this.previous = new ArrayList<>(); - } - - public MetascopeTable getTable() { - return table; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public void setTable(MetascopeTable table) { - this.table = table; - } - - public int getLevel() { - return level; - } - - public void setLevel(int level) { - this.level = level; - } - - public int getDistanceToCentralNode() { - return distanceToCentralNode; - } - - public void setDistanceToCentralNode(int distanceToCentralNode) { - this.distanceToCentralNode = distanceToCentralNode; - } - - public List getNexts() { - return nexts; - } - - public void setNexts(List nexts) { - this.nexts = nexts; - } - - public List getPrevious() { - return previous; - } - - public void setPrevious(List previous) { - this.previous = previous; - } - - public void addToNexts(Node node) { - if (this.nexts == null) { - this.nexts = new ArrayList<>(); - } - this.nexts.add(node); - } - - public void addToPrevious(Node node) { - if (this.previous == null) { - this.previous = new ArrayList<>(); - } - this.previous.add(node); - } - - @Override - public int compareTo(Node o) { - return o.getDistanceToCentralNode() - getDistanceToCentralNode(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Node node = (Node) o; - - return table.getFqdn().equals(node.table.getFqdn()); - } - - @Override - public int hashCode() { - return table.hashCode(); - } -} diff --git a/schedoscope-metascope/src/main/resources/static/css/lineage.css b/schedoscope-metascope/src/main/resources/static/css/lineage.css new file mode 100644 index 000000000..c0f2d8c97 --- /dev/null +++ b/schedoscope-metascope/src/main/resources/static/css/lineage.css @@ -0,0 +1,46 @@ +#forward-lineage-container + #backward-lineage-container { + box-sizing: border-box; + border-left: 1px solid black; +} + +svg g.output { + font-family: monospace; + font-size: large; +} + +svg g.output .node.btn-default rect { + fill: white; + stroke: #ccc; +} + +svg g.output .node.btn-default:hover rect { + fill: #e6e6e6; + stroke: #adadad; +} + +svg g.output .node.btn-default.disabled rect { + fill: #e0e0e0; +} + +#lineage-container svg g.output .node.btn-default.start rect { + stroke: #E23322; + stroke-width: 2px; +} + +#lineage-container svg g.output .node.btn-default.start:hover rect { + stroke: #E23322; +} + +svg g.output .node.leaf { + cursor: not-allowed; +} + +svg g.output .edgePath { + fill: black; + stroke: black; + stroke-width: 2px; +} + +svg g.output .clusters rect { + fill: lightblue; +} \ No newline at end of file diff --git a/schedoscope-metascope/src/main/resources/static/js/functions.js b/schedoscope-metascope/src/main/resources/static/js/functions.js index c40213b7f..8d9b4f5aa 100644 --- a/schedoscope-metascope/src/main/resources/static/js/functions.js +++ b/schedoscope-metascope/src/main/resources/static/js/functions.js @@ -467,122 +467,6 @@ var errorToast = function(title, message) { }); } -/** - * Draws a VisJS network graph respresenting the data lineage of an entity - */ -var drawLineage = function(data) { - var containerFA = document.getElementById('mynetworkFA'); - if (!containerFA.hasChildNodes()) { - var optionsFA = { - edges : { - smooth : { - type : 'cubicBezier', - forceDirection : 'vertical', - roundness : 0.2 - } - }, - layout : { - hierarchical : { - direction : "LR" - } - }, - groups : { - tables : { - shape : 'icon', - icon : { - face : 'FontAwesome', - code : '\uf0ce', - size : 50, - color : '#57169a' - } - }, - transformations : { - shape : 'icon', - icon : { - face : 'FontAwesome', - code : '\uf085', - size : 50, - color : '#aa00ff' - } - } - } - }; - - var dataFA = JSON.parse(data); - var networkFA = new vis.Network(containerFA, dataFA, optionsFA); - - var nodeID = 0; - var fqdn; - var type; - var nodes = dataFA.nodes; - for (var i = 0; i < nodes.length; i++) { - var obj = nodes[i]; - var thisFqdn = $("#lineageFqdn").val().replace(".", "\n") - if (obj.label == thisFqdn) { - nodeID = obj.id; - fqdn = obj.fqdn; - type = obj.group; - } - } - - networkFA.on("select", function(params) { - onSelect(params); - }); - - var init = true; - networkFA.on("afterDrawing", function(params) { - if (init) { - init = false; - var options = { - scale : 1.0, - offset : { - x : 0, - y : 0 - }, - animation : { - duration : 1000, - easingFunction : 'easeOutQuad' - } - }; - networkFA.focus(nodeID, options); - networkFA.selectNodes([ nodeID ]); - var params = {}; - params["nodeId"] = nodeID; - onSelect(params); - selectNode(fqdn, type); - } - }); - - var onSelect = function(params) { - if (typeof params.nodes !== "undefined") { - params.event = "[original event]"; - for (var i = 0; i < nodes.length; i++) { - if (nodes[i].id === parseInt(params.nodes[0], 10)) { - selectNode(nodes[i].fqdn, nodes[i].group); - } - } - } - } - } - -} - -var selectNode = function(fqdn, type) { - $.ajax({ - url : '/table/view/lineage/detail', - type : 'GET', - data : { - fqdn : fqdn, - type : type - }, - success : setLineageDetail - }); -} - -var setLineageDetail = function(data) { - $("#lineageDetail").html(data); -} - var getPanelColor = function(status) { switch (status) { case "failed": diff --git a/schedoscope-metascope/src/main/resources/static/js/graphconfig.js b/schedoscope-metascope/src/main/resources/static/js/graphconfig.js deleted file mode 100644 index 79293c101..000000000 --- a/schedoscope-metascope/src/main/resources/static/js/graphconfig.js +++ /dev/null @@ -1,109 +0,0 @@ -/** - * http://usejsdoc.org/ - */ -var metaScopeLineageGraph = {}; - -metaScopeLineageGraph.bigOptions = { - nodes : { - font: { - color: '#343434', - size: 14, // px - face: 'FontAwesome', - }, - scaling : { - min : 2, - max : 2, - label: { - enabled: false - } - - }, - icon: { - face: 'FontAwesome', - code: '\uf0ce', - size: 50, //50, - color:'#000000' - }, - shape: 'icon' - - }, - interaction : { - tooltipDelay : 200 - }, - edges : { - //arrowStrikethrough: false, - arrows : 'to', - color : { - inherit : 'to' - } - }, - layout : { - hierarchical : { - enabled : true, - direction : 'LR', - sortMethod : 'hubsize', - levelSeparation : 600 - } - }, - // font: { - // align: 'left' -// }, - physics : false, - autoResize : true, - height : '400px', - width : '100%' -}; - -metaScopeLineageGraph.smallOptions = { - layout : { - hierarchical : { - enabled : true, - direction : 'LR', - sortMethod : 'directed' - } - }, - nodes : { - font: { - color: '#343434', - size: 14, // px - face: 'FontAwesome', - }, - scaling : { - min : 2, - max : 2, - label: { - enabled: false - } - }, - fixed : true, - icon: { - face: 'FontAwesome', - code: '\uf0ce', - size: 50, //50, - color:'green' - }, - shape: 'icon' - - }, - edges : { - //arrowStrikethrough: false, - arrows : { - - to : { - enabled : true, - scaleFactor : 1 - } - }, - color : { - inherit : 'to' - }, - }, - physics : { - enabled : true, - }, - // font: { - // align: 'left' - // }, - height : '400px', - width : '100%' -}; diff --git a/schedoscope-metascope/src/main/resources/static/js/graphdataprocessor.js b/schedoscope-metascope/src/main/resources/static/js/graphdataprocessor.js deleted file mode 100644 index 310d0adc8..000000000 --- a/schedoscope-metascope/src/main/resources/static/js/graphdataprocessor.js +++ /dev/null @@ -1,227 +0,0 @@ -/* - * This function takes the raw data to processes it for the Graph. - * It sets the layout level and deletes edges that are not necessary - * The first step is to identify the start nodes and give them level 0. - * Now we traverse trough the graph to set the levels of the other nodes. - * When all the nodes are leveled, we detect transitive edges and delete them. - * At last we return the cleared and leveled data for the Graph. - * - * - * @param raw jsonData in given format data { tables: [], dependency: [] } - * @return a vis.dataset - * - */ -metaScopeLineageGraph.processData = function(jsonData) { - var dataGroups = []; - // Set start Level of all Nodes to 0 and mark all as not critical - jsonData.tables.forEach(function(node) { - node.level = 0; - node.critical = false; - node.icon ={}; - node.group = 'table'; - node.fqdn = node.label; - node.color = 'black'; - node.icon.color = '#000000'; - var text = node.label; - var split = text.split("."); - var dataname = split[0]; - dataGroups.push(dataname); - var tablename = split[1]; - dataname = dataname.concat('\n'); - dataname = dataname.concat(tablename); - node.label = dataname; - var timestamp = Math.random()*10 - }); - var gNodes = new vis.DataSet(jsonData.tables); - var gEdges = new vis.DataSet(jsonData.dependency); - dataGroups = _.uniq(dataGroups); - - /* - * @param data(level is set to 0 and critical is set to false for all nodes ) - * @return Leveled data. - */ - function levelingData(data) { - - // @param: json data @return: array of startnode ids - function findStartNodes(jsonData) { - var nodes = jsonData.tables; - var edges = jsonData.dependency; - var allNodeIds = []; - var notStartNodes = []; - for (var i = 0, l = edges.length; i < l; i++) { - notStartNodes.push(edges[i].to); - } - for (var x = 0, le = nodes.length; x < le; x++) { - allNodeIds.push(nodes[x].id); - } - var startNodes = _.difference(allNodeIds, notStartNodes); - return startNodes; - } - - var queue = findStartNodes(data); - - // @param: a nodeid as Int, @return an array of the next forward Nodes - // with level - function nextFwdNodes(aNodeId) { - var connectedEdges = getFwdConnetedEdges(aNodeId); - var nextNodes = []; - for ( var edge in connectedEdges) { - var edgeObj = connectedEdges[edge]; - var isFwdEdge = edgeObj.from === aNodeId; - if (isFwdEdge) { - var previousNode = gNodes.get(edgeObj.from); - var currentNode = gNodes.get(edgeObj.to); - if (currentNode.level > previousNode.level + 1) { - nextNodes.push(edgeObj.to); - } else { - currentNode.level = previousNode.level + 1; - gNodes.update(currentNode); - nextNodes.push(edgeObj.to); - } - } - } - return nextNodes; - } - - // Main loop to process the queue - function processQueue(data) { - if (data.length === 0) { - - } else { - var currentNode = data.pop(); - var nextNodes = nextFwdNodes(currentNode); - nextNodes.forEach(function(e) { - data.push(e); - }); - processQueue(queue); - } - } - - processQueue(queue); - - var processedData = { - nodes : gNodes, - edges : gEdges - }; - // return processedData; - - } - - - levelingData(jsonData);// level the data. - - // @param : a nodeid as int, @return: all connectedEdges to the given node - // //getFwdConnetedEdges - function getFwdConnetedEdges(aNodeId) { - var connectedEdges = gEdges.get({ - filter : function(item) { - return (item.from === aNodeId); - } - }); - return connectedEdges; - } - - /* - * Detect if a edge connects two nodes where the level difference is more - * then one and mark them as critical, those are candidates for getting - * deleted. changes are directly done in the gNodes and gEdges. - */ - function detectLevelGaps() { - var edgeIds = gEdges.getIds(); - for (var i = 0, l = gNodes.length; i < l; i++) { - var connectedEdges = getFwdConnetedEdges(gNodes.get(i).id); - for (var edge = 0, totalEdges = gEdges.length; edge < totalEdges; edge++) { - var fromNode = gEdges.get(edgeIds[edge]).from; - var toNode = gEdges.get(edgeIds[edge]).to; - var criticalEdge = gEdges.get(edgeIds[edge]); - if (gNodes.get(fromNode).level + 1 < gNodes.get(toNode).level - && criticalEdge.critical !== true) { - var criticalNode = gNodes.get(fromNode); - criticalEdge.critical = true; - gNodes.update(criticalNode); - gEdges.update(criticalEdge); - } - } - } - } - detectLevelGaps(); - - // Get edges that are marked as Critical - function getCriticalEdges() { - var criticalEdges = gEdges.get({ - filter : function(item) { - return item.critical; - } - }); - return criticalEdges; - } - - // @param : a nodeid as int @return visted nodes as a Array - // reachableNodes rename - function fwdPath(nodeId) { - var nextNodes = [ nodeId ]; - var vistedNodes = [ nodeId ]; - while (nextNodes.length !== 0) { - var currentNode = nextNodes.pop(); - var connectedEdges = getFwdConnetedEdges(currentNode); - for ( var edge in connectedEdges) { - var currentEdge = connectedEdges[edge]; - var isFwdNode = currentEdge.from === currentNode; - if (isFwdNode) { - nextNodes.push(currentEdge.to); - vistedNodes.push(currentEdge.to); - } - } - } - return vistedNodes; - } - - // checks if there is a path between two nodes - // isReachable rename - function alternativePath(startNodeId, goalNodeId) { - var vistedNodes = fwdPath(startNodeId); - return _.contains(vistedNodes, goalNodeId); - } - - // checks if a given critical edge is obsolete or not, returns true or - // false - function isEdgeObsolete(edgeObj) { - var startNode = edgeObj.from; - var goalNode = edgeObj.to; - var connectedEdges = getFwdConnetedEdges(startNode); - for ( var edges in connectedEdges) { - var currentEdge = connectedEdges[edges]; - if (currentEdge.id !== edgeObj.id) { - if (currentEdge.from === startNode) { - if (alternativePath(currentEdge.to, goalNode)) { - return true; - } - } - } - } - } - - /* - * @param Array of edge objects. checks each edge in the given array if the - * edge is obsolete, if so they will be deleted in gEdges. - */ - function deleteEdges(edgeArray) { - edgeArray.forEach(function(edge) { - if (isEdgeObsolete(edge)) { - var currentEdge = gEdges.get(edge.id); - gEdges.remove(currentEdge.id); - } - }); - } - - var criticalEdges = getCriticalEdges(); - - deleteEdges(criticalEdges); - - var finalData = { - nodes : gNodes, - edges : gEdges - }; - - return finalData; -} diff --git a/schedoscope-metascope/src/main/resources/static/js/lineage-graph.js b/schedoscope-metascope/src/main/resources/static/js/lineage-graph.js new file mode 100644 index 000000000..d929903b8 --- /dev/null +++ b/schedoscope-metascope/src/main/resources/static/js/lineage-graph.js @@ -0,0 +1,154 @@ +"use strict"; + +/** + * Represents a graph to show the lineage of a view's fields. + * @param {string} containerSelector A W3C selector string for the container to draw into + * @param {string} direction Direction for rank nodes. Can be TB, BT, LR or RL, where T = top, B = bottom, L = left and R = right. + * @constructor + */ +function LineageGraph(containerSelector, direction) { + const CLUSTER_LABEL_POS = "top"; + const SVG_NAMESPACE_URI = "http://www.w3.org/2000/svg"; + + var container = document.querySelector(containerSelector); + if (container === null) + throw "The selector '" + containerSelector + "' does not match any element."; + + var svg = document.createElementNS(SVG_NAMESPACE_URI, "svg"); + if (direction === "RL") svg.style.float = "right"; + container.appendChild(svg); + var d3svg = d3.select(svg); + var render = new dagreD3.render(); + var parents = {}; + var fullGraph = new dagreD3.graphlib.Graph() + .setGraph({}) + .setDefaultEdgeLabel(function () { + return {}; + }) + .setDefaultNodeLabel(function () { + return {}; + }); + var drawnGraph = new dagreD3.graphlib.Graph({compound: true}) + .setGraph({ + rankdir: direction, + transition: function (selection) { + return selection.transition().duration(256); + } + }) + .setDefaultEdgeLabel(function () { + return {}; + }) + .setDefaultNodeLabel(function (nodeId) { + return fullGraph.node(nodeId); + }); + + var redraw = function () { + render(d3svg, drawnGraph); + + svg.setAttribute("width", drawnGraph.graph().width); + svg.setAttribute("height", drawnGraph.graph().height); + + d3svg.selectAll(".node").on("click", this.addNeighbours); + d3svg.selectAll(".cluster").insert("title") + .text(function (d) { + return d.split(".")[0] + }); + }.bind(this); + + var addStartNode = function (id) { + // add the node + drawnGraph.setNode(id); + drawnGraph.node(id).class += " start"; + + // add the parent node + addParentOf(id); + }; + + /** + * Adds an edge and its parent to the drawn graph. + * @param {Object} edge The edge to add + */ + var addEdge = function (edge) { + drawnGraph.setEdge(edge.v, edge.w); + addParentOf(edge.v); + addParentOf(edge.w); + }; + + var addParentOf = function (node) { + var parent = parents[node]; + var delimiter = parent.includes(".") ? "." : "_"; + var splitParent = parent.split(delimiter); + drawnGraph.setNode(parent, {label: splitParent[splitParent.length - 1], clusterLabelPos: CLUSTER_LABEL_POS}); + drawnGraph.setParent(node, parent); + }; + + /** + * Adds all neighbor nodes of the given node id to the graph. + * + * @param {String} nodeId a node id + */ + this.addNeighbours = function (nodeId) { + if (!fullGraph.hasNode(nodeId)) + throw "Unknown node id " + nodeId; + + var neighbourEdges = fullGraph.outEdges(nodeId).concat(fullGraph.inEdges(nodeId)); + var newEdges = neighbourEdges.filter(function (edge) { + return !drawnGraph.hasEdge(edge); + }); + if (newEdges.length === 0) return; + + newEdges.forEach(addEdge); + redraw(); + d3svg.selectAll(".cluster .label").each(function () { + var label = d3.select(this); + var g = label.select(g); + + label.append("a") + .attr("href", function (d) { + return "?fqdn=" + d; + }) + .node().appendChild(this.querySelector("g")); + }); + + d3svg.selectAll(".node").classed("disabled", function (d) { + var toAdd = fullGraph.outEdges(d).concat(fullGraph.inEdges(d)); + return toAdd.every(function (edge) { + return drawnGraph.hasEdge(edge); + }); + }); + }; + + /** + * Sets the data to display in the graph. All sources will be display initially. + * + * @param {Object[]} edgesData All edges to display. + * @param {String[]} startNodes (Optional) The nodes to display at the beginning. If not given, all graph sources will be shown. + */ + this.setData = function (edgesData, startNodes) { + if (edgesData.length === 0) return; + + edgesData.forEach(function (edgeData) { + fullGraph.setEdge(edgeData.from.id, edgeData.to.id); + [edgeData.from, edgeData.to].forEach(function (node) { + fullGraph.setNode(node.id, {label: node.label, class: "btn btn-default"}); + parents[node.id] = node.parent; + }); + }); + + // check if graph is acyclic + if (!dagreD3.graphlib.alg.isAcyclic(fullGraph)) { + var cycles = dagreD3.graphlib.alg.findCycles(fullGraph); + var message = "Lineage graph is not acyclic. Brace yourself, display bugs are coming!"; + cycles.forEach(function (cycle) { + message += "\nFound cycle: " + cycle.join(" → ") + " → " + cycle[0]; + }); + alert(message); + } + + if (!startNodes) { + startNodes = fullGraph.sources(); + } + startNodes.forEach(addStartNode); + redraw(); + }; +} \ No newline at end of file diff --git a/schedoscope-metascope/src/main/resources/static/js/metascopegraph.js b/schedoscope-metascope/src/main/resources/static/js/metascopegraph.js deleted file mode 100644 index 0e5bbaaa9..000000000 --- a/schedoscope-metascope/src/main/resources/static/js/metascopegraph.js +++ /dev/null @@ -1,304 +0,0 @@ -/** - * http://usejsdoc.org/ - */ - -/* - * Function that draws two Graphs and adds some functionality like, forward and - * backward trace by clicking on a node. The two graphs are not the same but - * Linked trough some globals (gNodes, gEdges, selectedNode) - * - * - * @param graphData, is the json data holding nodes and edges graphOptions, an - * object of option parameters lying in graphconfig.js smallGraphOptions, - * options for the small graph bigGraphContainer, the container in which the big - * graph is being drawn smallGraphContainer, the container in which the small - * graph is being drawn - */ -metaScopeLineageGraph.doGraph = function(graphData, graphOptions, - smallGraphOptions, bigGraphContainer, smallGraphContainer, selectedNode) { - var fqdnValue = selectedNode; - // global SelectedNode to pass this between the two graphs - var initState = true; - var datajson = graphData; - var container = bigGraphContainer; - var options = graphOptions; - var gNodes = datajson["nodes"]; - var gEdges = datajson["edges"]; - var theNode = gNodes.get({ - filter: function(item){ - return item.fqdn == fqdnValue; - } - }) - var theSelectedNode = theNode[0].id; - var smallContainer = smallGraphContainer; - var smallOptions = smallGraphOptions; - var allNodesArray = []; - var allEdgesArray = []; - var gSteps = 3; - - var allNodes = gNodes.get({ - returnType : "Object" - }); - var allEdges = gEdges.get({ - returnType : "Object" - }); - var data = { - nodes : gNodes, - edges : gEdges - }; - - var smallNodes = []; - var smallEdges = []; - var smallInitData = { - nodes : smallNodes, - edges : smallEdges - }; - - var network = new vis.Network(container, data, options); - var bottomGraph = new vis.Network(smallContainer, smallInitData, - smallOptions); - network.storePositions(); - - /* - * a function that reinitalizes the net. - * - */ - function mrClean() { - for ( var nodeId in allNodes) { - allNodes[nodeId].color = 'black'; - allNodes[nodeId].icon.color = 'black'; - allNodesArray.push(allNodes[nodeId]); - } - for ( var edgeId in allEdges) { - allEdges[edgeId].color = 'black'; - allEdgesArray.push(allEdges[edgeId]); - } - gNodes.update(allNodesArray); - gEdges.update(allEdgesArray); - network.fit(); - } - - network.on("deselectNode", function(params) { - bottomGraph.setData(smallInitData); - //$("#lineageTable").empty(); - //$("#lineageName").empty(); - mrClean(); - }); - - network.on("afterDrawing", function(params){ - if(initState){ - initState = false; - network.selectNodes([theSelectedNode]); - displayRoutine(theSelectedNode, gSteps); - bottomGraph.redraw(); - detailTable(allNodes[theSelectedNode].fqdn, allNodes[theSelectedNode].group); - } - - }) - // colors all nodes gray - function grayNodes() { - for ( var node in allNodes) { - allNodes[node].icon.color = '#d9d9d9'; - // allNodes[node].image = '/images/database-gray.png'; - allNodesArray.push(allNodes[node]); - } - for ( var edge in allEdges) { - allEdges[edge].color = '#d9d9d9'; - allEdgesArray.push(allEdges[edge]); - } - } - - /* - * @param startNode:int, fwdJumps:int @return {'nodes': [], 'edges':[]} - * returns all forward Nodes from given StartNode in given range fwdJumps - */ - function pushFwdNodes(startNode, fwdJumps) { - var fwdNodes = [ startNode ]; - var markedTuple = { - 'nodes' : [ startNode ], - 'edges' : [] - }; - - for (var i = 0; i < fwdJumps; i++) { - var currentFwdNodes = fwdNodes; - fwdNodes = []; - for ( var node in currentFwdNodes) { - var nodeEdges = network - .getConnectedEdges(currentFwdNodes[node]); - for ( var edge in nodeEdges) { - var edgeObj = allEdges[nodeEdges[edge]]; - var isForwardNode = edgeObj.from === currentFwdNodes[node]; - if (isForwardNode) { - edgeObj.color = { - inherit : 'to' - }; - fwdNodes.push(edgeObj.to); - if (!_.contains(markedTuple.nodes, edgeObj.to)) { - markedTuple.nodes.push(edgeObj.to); - } - if (!_.contains(markedTuple.edges, edgeObj.id)) { - markedTuple.edges.push(edgeObj.id); - } - } - } - } - } - return markedTuple; - } - - /* - * @param startNode:int, bwdJumps:int @return {'nodes': [], 'edges':[]} - * returns all backward Nodes from given StartNode in given range bwdJumps - */ - function pushBwdNodes(startNode, bwdJumps) { - var bwdNodes = [ startNode ]; - var markedTuple = { - 'nodes' : [ startNode ], - 'edges' : [] - }; - for (var i = 0; i < bwdJumps; i++) { - var currentBwdNodes = bwdNodes; - bwdNodes = []; - for ( var node in currentBwdNodes) { - var nodeEdges = network - .getConnectedEdges(currentBwdNodes[node]); - for ( var edge in nodeEdges) { - var edgeObj = allEdges[nodeEdges[edge]]; - var isBackwardNode = edgeObj.to === currentBwdNodes[node]; - if (isBackwardNode) { - edgeObj.color = { - inherit : 'from' - }; - bwdNodes.push(edgeObj.from); - if (!_.contains(markedTuple.nodes, edgeObj.from)) { - markedTuple.nodes.push(edgeObj.from); - } - if (!_.contains(markedTuple.edges, edgeObj.id)) { - markedTuple.edges.push(edgeObj.id); - } - } - } - } - } - return markedTuple; - } - - /* - * pure facade function, that marks all paths from and to a given startNode - * of a given length @param startNode: a node ID as int, steps: a Int - * @return all marked nodes and edges as an Object - */ - function getNeighborhoodGraph(startNode, steps) { - var fwdTuple = pushFwdNodes(startNode, steps); - var bwdTuple = pushBwdNodes(startNode, steps); - var nodesToMark = fwdTuple.nodes.concat(bwdTuple.nodes); - var edgesToMark = fwdTuple.edges.concat(bwdTuple.edges); - var combinedMarkedTuple = { - 'nodes' : [], - 'edges' : [] - }; - combinedMarkedTuple.nodes.push(nodesToMark); - combinedMarkedTuple.edges.push(edgesToMark); - return combinedMarkedTuple; - } - - /* - * @param nodes, edges: as an Array @return Options Object for a subgraph - * rename [rawData, rawEdges, rawNodes] = getRawData(nodes, edges) smallData = - * rawData smallEdges = rawEdges smallNodes = rawNodes - */ - function smallGraphData(nodes, edges) { - var rawSmallNodes = new vis.DataSet(gNodes.get(_.uniq(nodes))); - smallEdges = new vis.DataSet(gEdges.get(edges)); - smallNodes = rawSmallNodes.get({ - order : "level" - }); - - var smallData = { - nodes : smallNodes, - edges : smallEdges - }; - return smallData; - } - - function markNodes(nodeArray) { - for ( var node in nodeArray) { - // allNodes[nodeArray[node]].image = '/images/database-red.png'; - allNodes[nodeArray[node]].icon.color = 'black'; - } - } - /* - * ties all the functions together that will visualize the path in the - * graph. - */ - function displayRoutine(theSelectedNode, steps) { - grayNodes(); - var markedTuple = getNeighborhoodGraph(theSelectedNode, steps); - markNodes(markedTuple.nodes[0]); - //allNodes[theSelectedNode].image = '/images/database-orange.png'; - allNodes[theSelectedNode].icon.color = 'orange'; - gNodes.update(allNodesArray); - gEdges.update(allEdgesArray); - var smallData = smallGraphData(markedTuple.nodes[0], - markedTuple.edges[0]); - bottomGraph.setData(smallData); - } - - // on node select handler - network.on("selectNode", function(params) { - gSteps = 2; - theSelectedNode = parseInt(params.nodes[0]); - displayRoutine(theSelectedNode, gSteps); - bottomGraph.redraw(); - detailTable(allNodes[theSelectedNode].fqdn, allNodes[theSelectedNode].group); - }); - - /* - * Changes the Global steps @param negative values will show you less nodes, - * positive values will show you more nodes - * - */ - function zoom(steps) { - gSteps = steps + gSteps; - if (gSteps <= 0) { - gSteps = 1; - } - displayRoutine(theSelectedNode, gSteps); - bottomGraph.redraw(); - } - - // side effects not good make good commentar or stuff - bottomGraph.on("selectNode", function(params) { - theSelectedNode = parseInt(params.nodes[0]); - displayRoutine(theSelectedNode, gSteps); - detailTable(allNodes[theSelectedNode].fqdn, allNodes[theSelectedNode].group); - }); - - // Zoom out so you get MORE nodes - $("#zoomOut").click(function() { - zoom(1); - }); - - // Zoom in so you get LESS nodes - $("#zoomIn").click(function() { - zoom(-1); - }); - - - var detailTable = function(fqdn, type) { - $.ajax({ - url : '/table/view/lineage/detail', - type : 'GET', - data : { - fqdn : fqdn, - type : type - }, - success : setLineageDetail - }); - } - - var setLineageDetail = function(data) { - $("#lineageDetail").html(data); - } - -} \ No newline at end of file diff --git a/schedoscope-metascope/src/main/resources/static/js/table.js b/schedoscope-metascope/src/main/resources/static/js/table.js index 2289f955d..ee9593725 100644 --- a/schedoscope-metascope/src/main/resources/static/js/table.js +++ b/schedoscope-metascope/src/main/resources/static/js/table.js @@ -32,16 +32,6 @@ $(function() { $('#partitionSelectBox').sort_select_box(); - /* GET lineage information on lineage modal open event */ - $('#lineage').on('shown.bs.modal', function(e) { - $.ajax({ - url : '/table/view/lineage', - type : 'GET', - data : $('#lineageForm').serialize(), - success : drawLineage - }); - }); - /* initialize tablesorter plugin */ initTablesorter(); diff --git a/schedoscope-metascope/src/main/resources/static/js/vis.min.js b/schedoscope-metascope/src/main/resources/static/js/vis.min.js deleted file mode 100644 index 6fc4277bd..000000000 --- a/schedoscope-metascope/src/main/resources/static/js/vis.min.js +++ /dev/null @@ -1,44 +0,0 @@ -/** - * vis.js - * https://github.com/almende/vis - * - * A dynamic, browser-based visualization library. - * - * @version 4.9.0 - * @date 2015-10-01 - * - * @license - * Copyright (C) 2011-2015 Almende B.V, http://almende.com - * - * Vis.js is dual licensed under both - * - * * The Apache 2.0 License - * http://www.apache.org/licenses/LICENSE-2.0 - * - * and - * - * * The MIT License - * http://opensource.org/licenses/MIT - * - * Vis.js may be distributed under either license. - */ -"use strict";!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.vis=e():t.vis=e()}(this,function(){return function(t){function e(o){if(i[o])return i[o].exports;var n=i[o]={exports:{},id:o,loaded:!1};return t[o].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){e.util=i(1),e.DOMutil=i(7),e.DataSet=i(8),e.DataView=i(10),e.Queue=i(9),e.Graph3d=i(11),e.graph3d={Camera:i(15),Filter:i(16),Point2d:i(14),Point3d:i(13),Slider:i(17),StepNumber:i(18)},e.Timeline=i(19),e.Graph2d=i(49),e.timeline={DateUtil:i(27),DataStep:i(52),Range:i(24),stack:i(32),TimeStep:i(30),components:{items:{Item:i(34),BackgroundItem:i(38),BoxItem:i(36),PointItem:i(37),RangeItem:i(33)},Component:i(26),CurrentTime:i(44),CustomTime:i(42),DataAxis:i(51),GraphGroup:i(53),Group:i(31),BackgroundGroup:i(35),ItemSet:i(29),Legend:i(57),LineGraph:i(50),TimeAxis:i(39)}},e.Network=i(59),e.network={Images:i(117),dotparser:i(115),gephiParser:i(116),allOptions:i(111)},e.network.convertDot=function(t){return e.network.dotparser.DOTToGraph(t)},e.network.convertGephi=function(t,i){return e.network.gephiParser.parseGephi(t,i)},e.moment=i(2),e.Hammer=i(20),e.keycharm=i(41)},function(t,e,i){var o=i(2),n=i(6);e.isNumber=function(t){return t instanceof Number||"number"==typeof t},e.recursiveDOMDelete=function(t){if(t)for(;t.hasChildNodes()===!0;)e.recursiveDOMDelete(t.firstChild),t.removeChild(t.firstChild)},e.giveRange=function(t,e,i,o){if(e==t)return.5;var n=1/(e-t);return Math.max(0,(o-t)*n)},e.isString=function(t){return t instanceof String||"string"==typeof t},e.isDate=function(t){if(t instanceof Date)return!0;if(e.isString(t)){var i=s.exec(t);if(i)return!0;if(!isNaN(Date.parse(t)))return!0}return!1},e.randomUUID=function(){return n.v4()},e.assignAllKeys=function(t,e){for(var i in t)t.hasOwnProperty(i)&&"object"!=typeof t[i]&&(t[i]=e)},e.fillIfDefined=function(t,i){var o=arguments.length<=2||void 0===arguments[2]?!1:arguments[2];for(var n in t)void 0!==i[n]&&("object"!=typeof i[n]?void 0!==i[n]&&null!==i[n]||void 0===t[n]||o!==!0?t[n]=i[n]:delete t[n]:"object"==typeof t[n]&&e.fillIfDefined(t[n],i[n],o))},e.protoExtend=function(t,e){for(var i=1;ii;i++)if(t[i]!=e[i])return!1;return!0},e.convert=function(t,i){var n;if(void 0===t)return void 0;if(null===t)return null;if(!i)return t;if("string"!=typeof i&&!(i instanceof String))throw new Error("Type must be a string");switch(i){case"boolean":case"Boolean":return Boolean(t);case"number":case"Number":return Number(t.valueOf());case"string":case"String":return String(t);case"Date":if(e.isNumber(t))return new Date(t);if(t instanceof Date)return new Date(t.valueOf());if(o.isMoment(t))return new Date(t.valueOf());if(e.isString(t))return n=s.exec(t),n?new Date(Number(n[1])):o(t).toDate();throw new Error("Cannot convert object of type "+e.getType(t)+" to type Date");case"Moment":if(e.isNumber(t))return o(t);if(t instanceof Date)return o(t.valueOf());if(o.isMoment(t))return o(t);if(e.isString(t))return n=s.exec(t),o(n?Number(n[1]):t);throw new Error("Cannot convert object of type "+e.getType(t)+" to type Date");case"ISODate":if(e.isNumber(t))return new Date(t);if(t instanceof Date)return t.toISOString();if(o.isMoment(t))return t.toDate().toISOString();if(e.isString(t))return n=s.exec(t),n?new Date(Number(n[1])).toISOString():new Date(t).toISOString();throw new Error("Cannot convert object of type "+e.getType(t)+" to type ISODate");case"ASPDate":if(e.isNumber(t))return"/Date("+t+")/";if(t instanceof Date)return"/Date("+t.valueOf()+")/";if(e.isString(t)){n=s.exec(t);var r;return r=n?new Date(Number(n[1])).valueOf():new Date(t).valueOf(),"/Date("+r+")/"}throw new Error("Cannot convert object of type "+e.getType(t)+" to type ASPDate");default:throw new Error('Unknown type "'+i+'"')}};var s=/^\/?Date\((\-?\d+)/i;e.getType=function(t){var e=typeof t;return"object"==e?null===t?"null":t instanceof Boolean?"Boolean":t instanceof Number?"Number":t instanceof String?"String":Array.isArray(t)?"Array":t instanceof Date?"Date":"Object":"number"==e?"Number":"boolean"==e?"Boolean":"string"==e?"String":void 0===e?"undefined":e},e.copyAndExtendArray=function(t,e){for(var i=[],o=0;oi;i++)e(t[i],i,t);else for(i in t)t.hasOwnProperty(i)&&e(t[i],i,t)},e.toArray=function(t){var e=[];for(var i in t)t.hasOwnProperty(i)&&e.push(t[i]);return e},e.updateProperty=function(t,e,i){return t[e]!==i?(t[e]=i,!0):!1},e.throttle=function(t,e){var i=null,o=!1;return function n(){i?o=!0:(o=!1,t(),i=setTimeout(function(){i=null,o&&n()},e))}},e.addEventListener=function(t,e,i,o){t.addEventListener?(void 0===o&&(o=!1),"mousewheel"===e&&navigator.userAgent.indexOf("Firefox")>=0&&(e="DOMMouseScroll"),t.addEventListener(e,i,o)):t.attachEvent("on"+e,i)},e.removeEventListener=function(t,e,i,o){t.removeEventListener?(void 0===o&&(o=!1),"mousewheel"===e&&navigator.userAgent.indexOf("Firefox")>=0&&(e="DOMMouseScroll"),t.removeEventListener(e,i,o)):t.detachEvent("on"+e,i)},e.preventDefault=function(t){t||(t=window.event),t.preventDefault?t.preventDefault():t.returnValue=!1},e.getTarget=function(t){t||(t=window.event);var e;return t.target?e=t.target:t.srcElement&&(e=t.srcElement),void 0!=e.nodeType&&3==e.nodeType&&(e=e.parentNode),e},e.hasParent=function(t,e){for(var i=t;i;){if(i===e)return!0;i=i.parentNode}return!1},e.option={},e.option.asBoolean=function(t,e){return"function"==typeof t&&(t=t()),null!=t?0!=t:e||null},e.option.asNumber=function(t,e){return"function"==typeof t&&(t=t()),null!=t?Number(t)||e||null:e||null},e.option.asString=function(t,e){return"function"==typeof t&&(t=t()),null!=t?String(t):e||null},e.option.asSize=function(t,i){return"function"==typeof t&&(t=t()),e.isString(t)?t:e.isNumber(t)?t+"px":i||null},e.option.asElement=function(t,e){return"function"==typeof t&&(t=t()),t||e||null},e.hexToRGB=function(t){var e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;t=t.replace(e,function(t,e,i,o){return e+e+i+i+o+o});var i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return i?{r:parseInt(i[1],16),g:parseInt(i[2],16),b:parseInt(i[3],16)}:null},e.overrideOpacity=function(t,i){if(-1!=t.indexOf("rgba"))return t;if(-1!=t.indexOf("rgb")){var o=t.substr(t.indexOf("(")+1).replace(")","").split(",");return"rgba("+o[0]+","+o[1]+","+o[2]+","+i+")"}var o=e.hexToRGB(t);return null==o?t:"rgba("+o.r+","+o.g+","+o.b+","+i+")"},e.RGBToHex=function(t,e,i){return"#"+((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1)},e.parseColor=function(t){var i;if(e.isString(t)===!0){if(e.isValidRGB(t)===!0){var o=t.substr(4).substr(0,t.length-5).split(",").map(function(t){return parseInt(t)});t=e.RGBToHex(o[0],o[1],o[2])}if(e.isValidHex(t)===!0){var n=e.hexToHSV(t),s={h:n.h,s:.8*n.s,v:Math.min(1,1.02*n.v)},r={h:n.h,s:Math.min(1,1.25*n.s),v:.8*n.v},a=e.HSVToHex(r.h,r.s,r.v),h=e.HSVToHex(s.h,s.s,s.v);i={background:t,border:a,highlight:{background:h,border:a},hover:{background:h,border:a}}}else i={background:t,border:t,highlight:{background:t,border:t},hover:{background:t,border:t}}}else i={},i.background=t.background||void 0,i.border=t.border||void 0,e.isString(t.highlight)?i.highlight={border:t.highlight,background:t.highlight}:(i.highlight={},i.highlight.background=t.highlight&&t.highlight.background||void 0,i.highlight.border=t.highlight&&t.highlight.border||void 0),e.isString(t.hover)?i.hover={border:t.hover,background:t.hover}:(i.hover={},i.hover.background=t.hover&&t.hover.background||void 0,i.hover.border=t.hover&&t.hover.border||void 0);return i},e.RGBToHSV=function(t,e,i){t/=255,e/=255,i/=255;var o=Math.min(t,Math.min(e,i)),n=Math.max(t,Math.max(e,i));if(o==n)return{h:0,s:0,v:o};var s=t==o?e-i:i==o?t-e:i-t,r=t==o?3:i==o?1:5,a=60*(r-s/(n-o))/360,h=(n-o)/n,d=n;return{h:a,s:h,v:d}};var r={split:function(t){var e={};return t.split(";").forEach(function(t){if(""!=t.trim()){var i=t.split(":"),o=i[0].trim(),n=i[1].trim();e[o]=n}}),e},join:function(t){return Object.keys(t).map(function(e){return e+": "+t[e]}).join("; ")}};e.addCssText=function(t,i){var o=r.split(t.style.cssText),n=r.split(i),s=e.extend(o,n);t.style.cssText=r.join(s)},e.removeCssText=function(t,e){var i=r.split(t.style.cssText),o=r.split(e);for(var n in o)o.hasOwnProperty(n)&&delete i[n];t.style.cssText=r.join(i)},e.HSVToRGB=function(t,e,i){var o,n,s,r=Math.floor(6*t),a=6*t-r,h=i*(1-e),d=i*(1-a*e),l=i*(1-(1-a)*e);switch(r%6){case 0:o=i,n=l,s=h;break;case 1:o=d,n=i,s=h;break;case 2:o=h,n=i,s=l;break;case 3:o=h,n=d,s=i;break;case 4:o=l,n=h,s=i;break;case 5:o=i,n=h,s=d}return{r:Math.floor(255*o),g:Math.floor(255*n),b:Math.floor(255*s)}},e.HSVToHex=function(t,i,o){var n=e.HSVToRGB(t,i,o);return e.RGBToHex(n.r,n.g,n.b)},e.hexToHSV=function(t){var i=e.hexToRGB(t);return e.RGBToHSV(i.r,i.g,i.b)},e.isValidHex=function(t){var e=/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t);return e},e.isValidRGB=function(t){t=t.replace(" ","");var e=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/i.test(t);return e},e.isValidRGBA=function(t){t=t.replace(" ","");var e=/rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(.{1,3})\)/i.test(t);return e},e.selectiveBridgeObject=function(t,i){if("object"==typeof i){for(var o=Object.create(i),n=0;n=r&&n>s;){var h=Math.floor((r+a)/2),d=t[h],l=void 0===o?d[i]:d[i][o],u=e(l);if(0==u)return h;-1==u?r=h+1:a=h-1,s++}return-1},e.binarySearchValue=function(t,e,i,o){for(var n,s,r,a,h=1e4,d=0,l=0,u=t.length-1;u>=l&&h>d;){if(a=Math.floor(.5*(u+l)),n=t[Math.max(0,a-1)][i],s=t[a][i],r=t[Math.min(t.length-1,a+1)][i],s==e)return a;if(e>n&&s>e)return"before"==o?Math.max(0,a-1):a;if(e>s&&r>e)return"before"==o?a:Math.min(t.length-1,a+1);e>s?l=a+1:u=a-1,d++}return-1},e.easingFunctions={linear:function(t){return t},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return t*(2-t)},easeInOutQuad:function(t){return.5>t?2*t*t:-1+(4-2*t)*t},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return--t*t*t+1},easeInOutCubic:function(t){return.5>t?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return 1- --t*t*t*t},easeInOutQuart:function(t){return.5>t?8*t*t*t*t:1-8*--t*t*t*t},easeInQuint:function(t){return t*t*t*t*t},easeOutQuint:function(t){return 1+--t*t*t*t*t},easeInOutQuint:function(t){return.5>t?16*t*t*t*t*t:1+16*--t*t*t*t*t}}},function(t,e,i){t.exports="undefined"!=typeof window&&window.moment||i(3)},function(t,e,i){(function(t){!function(e,i){t.exports=i()}(this,function(){function e(){return Ni.apply(null,arguments)}function i(t){Ni=t}function o(t){return"[object Array]"===Object.prototype.toString.call(t)}function n(t){return t instanceof Date||"[object Date]"===Object.prototype.toString.call(t)}function s(t,e){var i,o=[];for(i=0;i0)for(i in Ai)o=Ai[i],n=e[o],"undefined"!=typeof n&&(t[o]=n);return t}function f(t){p(this,t),this._d=new Date(null!=t._d?t._d.getTime():NaN),Bi===!1&&(Bi=!0,e.updateOffset(this),Bi=!1)}function m(t){return t instanceof f||null!=t&&null!=t._isAMomentObject}function v(t){return 0>t?Math.ceil(t):Math.floor(t)}function g(t){var e=+t,i=0;return 0!==e&&isFinite(e)&&(i=v(e)),i}function y(t,e,i){var o,n=Math.min(t.length,e.length),s=Math.abs(t.length-e.length),r=0;for(o=0;n>o;o++)(i&&t[o]!==e[o]||!i&&g(t[o])!==g(e[o]))&&r++;return r+s}function b(){}function w(t){return t?t.toLowerCase().replace("_","-"):t}function _(t){for(var e,i,o,n,s=0;s0;){if(o=x(n.slice(0,e).join("-")))return o;if(i&&i.length>=e&&y(n,i,!0)>=e-1)break;e--}s++}return null}function x(e){var i=null;if(!Ri[e]&&"undefined"!=typeof t&&t&&t.exports)try{i=Li._abbr,!function(){var t=new Error('Cannot find module "./locale"');throw t.code="MODULE_NOT_FOUND",t}(),k(i)}catch(o){}return Ri[e]}function k(t,e){var i;return t&&(i="undefined"==typeof e?D(t):O(t,e),i&&(Li=i)),Li._abbr}function O(t,e){return null!==e?(e.abbr=t,Ri[t]=Ri[t]||new b,Ri[t].set(e),k(t),Ri[t]):(delete Ri[t],null)}function D(t){var e;if(t&&t._locale&&t._locale._abbr&&(t=t._locale._abbr),!t)return Li;if(!o(t)){if(e=x(t))return e;t=[t]}return _(t)}function M(t,e){var i=t.toLowerCase();Fi[i]=Fi[i+"s"]=Fi[e]=t}function C(t){return"string"==typeof t?Fi[t]||Fi[t.toLowerCase()]:void 0}function T(t){var e,i,o={};for(i in t)r(t,i)&&(e=C(i),e&&(o[e]=t[i]));return o}function E(t,i){return function(o){return null!=o?(P(this,t,o),e.updateOffset(this,i),this):S(this,t)}}function S(t,e){return t._d["get"+(t._isUTC?"UTC":"")+e]()}function P(t,e,i){return t._d["set"+(t._isUTC?"UTC":"")+e](i)}function I(t,e){var i;if("object"==typeof t)for(i in t)this.set(i,t[i]);else if(t=C(t),"function"==typeof this[t])return this[t](e);return this}function z(t,e,i){var o=""+Math.abs(t),n=e-o.length,s=t>=0;return(s?i?"+":"":"-")+Math.pow(10,Math.max(0,n)).toString().substr(1)+o}function N(t,e,i,o){var n=o;"string"==typeof o&&(n=function(){return this[o]()}),t&&(Yi[t]=n),e&&(Yi[e[0]]=function(){return z(n.apply(this,arguments),e[1],e[2])}),i&&(Yi[i]=function(){return this.localeData().ordinal(n.apply(this,arguments),t)})}function L(t){return t.match(/\[[\s\S]/)?t.replace(/^\[|\]$/g,""):t.replace(/\\/g,"")}function A(t){var e,i,o=t.match(ji);for(e=0,i=o.length;i>e;e++)Yi[o[e]]?o[e]=Yi[o[e]]:o[e]=L(o[e]);return function(n){var s="";for(e=0;i>e;e++)s+=o[e]instanceof Function?o[e].call(n,t):o[e];return s}}function B(t,e){return t.isValid()?(e=R(e,t.localeData()),Wi[e]=Wi[e]||A(e),Wi[e](t)):t.localeData().invalidDate()}function R(t,e){function i(t){return e.longDateFormat(t)||t}var o=5;for(Hi.lastIndex=0;o>=0&&Hi.test(t);)t=t.replace(Hi,i),Hi.lastIndex=0,o-=1;return t}function F(t){return"function"==typeof t&&"[object Function]"===Object.prototype.toString.call(t)}function j(t,e,i){no[t]=F(e)?e:function(t){return t&&i?i:e}}function H(t,e){return r(no,t)?no[t](e._strict,e._locale):new RegExp(W(t))}function W(t){return t.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(t,e,i,o,n){return e||i||o||n}).replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function Y(t,e){var i,o=e;for("string"==typeof t&&(t=[t]),"number"==typeof e&&(o=function(t,i){i[e]=g(t)}),i=0;io;o++){if(n=h([2e3,o]),i&&!this._longMonthsParse[o]&&(this._longMonthsParse[o]=new RegExp("^"+this.months(n,"").replace(".","")+"$","i"),this._shortMonthsParse[o]=new RegExp("^"+this.monthsShort(n,"").replace(".","")+"$","i")),i||this._monthsParse[o]||(s="^"+this.months(n,"")+"|^"+this.monthsShort(n,""),this._monthsParse[o]=new RegExp(s.replace(".",""),"i")),i&&"MMMM"===e&&this._longMonthsParse[o].test(t))return o;if(i&&"MMM"===e&&this._shortMonthsParse[o].test(t))return o;if(!i&&this._monthsParse[o].test(t))return o}}function K(t,e){var i;return"string"==typeof e&&(e=t.localeData().monthsParse(e),"number"!=typeof e)?t:(i=Math.min(t.date(),V(t.year(),e)),t._d["set"+(t._isUTC?"UTC":"")+"Month"](e,i),t)}function J(t){return null!=t?(K(this,t),e.updateOffset(this,!0),this):S(this,"Month")}function Q(){return V(this.year(),this.month())}function $(t){var e,i=t._a;return i&&-2===l(t).overflow&&(e=i[ao]<0||i[ao]>11?ao:i[ho]<1||i[ho]>V(i[ro],i[ao])?ho:i[lo]<0||i[lo]>24||24===i[lo]&&(0!==i[uo]||0!==i[co]||0!==i[po])?lo:i[uo]<0||i[uo]>59?uo:i[co]<0||i[co]>59?co:i[po]<0||i[po]>999?po:-1,l(t)._overflowDayOfYear&&(ro>e||e>ho)&&(e=ho),l(t).overflow=e),t}function tt(t){e.suppressDeprecationWarnings===!1&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+t)}function et(t,e){var i=!0;return a(function(){return i&&(tt(t+"\n"+(new Error).stack),i=!1),e.apply(this,arguments)},e)}function it(t,e){vo[t]||(tt(e),vo[t]=!0)}function ot(t){var e,i,o=t._i,n=go.exec(o);if(n){for(l(t).iso=!0,e=0,i=yo.length;i>e;e++)if(yo[e][1].exec(o)){t._f=yo[e][0];break}for(e=0,i=bo.length;i>e;e++)if(bo[e][1].exec(o)){t._f+=(n[6]||" ")+bo[e][0];break}o.match(eo)&&(t._f+="Z"),xt(t)}else t._isValid=!1}function nt(t){var i=wo.exec(t._i);return null!==i?void(t._d=new Date(+i[1])):(ot(t),void(t._isValid===!1&&(delete t._isValid,e.createFromInputFallback(t))))}function st(t,e,i,o,n,s,r){var a=new Date(t,e,i,o,n,s,r);return 1970>t&&a.setFullYear(t),a}function rt(t){var e=new Date(Date.UTC.apply(null,arguments));return 1970>t&&e.setUTCFullYear(t),e}function at(t){return ht(t)?366:365}function ht(t){return t%4===0&&t%100!==0||t%400===0}function dt(){return ht(this.year())}function lt(t,e,i){var o,n=i-e,s=i-t.day();return s>n&&(s-=7),n-7>s&&(s+=7),o=St(t).add(s,"d"),{week:Math.ceil(o.dayOfYear()/7),year:o.year()}}function ut(t){return lt(t,this._week.dow,this._week.doy).week}function ct(){return this._week.dow}function pt(){return this._week.doy}function ft(t){var e=this.localeData().week(this);return null==t?e:this.add(7*(t-e),"d")}function mt(t){var e=lt(this,1,4).week;return null==t?e:this.add(7*(t-e),"d")}function vt(t,e,i,o,n){var s,r=6+n-o,a=rt(t,0,1+r),h=a.getUTCDay();return n>h&&(h+=7),i=null!=i?1*i:n,s=1+r+7*(e-1)-h+i,{year:s>0?t:t-1,dayOfYear:s>0?s:at(t-1)+s}}function gt(t){var e=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return null==t?e:this.add(t-e,"d")}function yt(t,e,i){return null!=t?t:null!=e?e:i}function bt(t){var e=new Date;return t._useUTC?[e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()]:[e.getFullYear(),e.getMonth(),e.getDate()]}function wt(t){var e,i,o,n,s=[];if(!t._d){for(o=bt(t),t._w&&null==t._a[ho]&&null==t._a[ao]&&_t(t),t._dayOfYear&&(n=yt(t._a[ro],o[ro]),t._dayOfYear>at(n)&&(l(t)._overflowDayOfYear=!0),i=rt(n,0,t._dayOfYear),t._a[ao]=i.getUTCMonth(),t._a[ho]=i.getUTCDate()),e=0;3>e&&null==t._a[e];++e)t._a[e]=s[e]=o[e];for(;7>e;e++)t._a[e]=s[e]=null==t._a[e]?2===e?1:0:t._a[e];24===t._a[lo]&&0===t._a[uo]&&0===t._a[co]&&0===t._a[po]&&(t._nextDay=!0,t._a[lo]=0),t._d=(t._useUTC?rt:st).apply(null,s),null!=t._tzm&&t._d.setUTCMinutes(t._d.getUTCMinutes()-t._tzm),t._nextDay&&(t._a[lo]=24)}}function _t(t){var e,i,o,n,s,r,a;e=t._w,null!=e.GG||null!=e.W||null!=e.E?(s=1,r=4,i=yt(e.GG,t._a[ro],lt(St(),1,4).year),o=yt(e.W,1),n=yt(e.E,1)):(s=t._locale._week.dow,r=t._locale._week.doy,i=yt(e.gg,t._a[ro],lt(St(),s,r).year),o=yt(e.w,1),null!=e.d?(n=e.d,s>n&&++o):n=null!=e.e?e.e+s:s),a=vt(i,o,n,r,s),t._a[ro]=a.year,t._dayOfYear=a.dayOfYear}function xt(t){if(t._f===e.ISO_8601)return void ot(t);t._a=[],l(t).empty=!0;var i,o,n,s,r,a=""+t._i,h=a.length,d=0;for(n=R(t._f,t._locale).match(ji)||[],i=0;i0&&l(t).unusedInput.push(r),a=a.slice(a.indexOf(o)+o.length),d+=o.length),Yi[s]?(o?l(t).empty=!1:l(t).unusedTokens.push(s),U(s,o,t)):t._strict&&!o&&l(t).unusedTokens.push(s);l(t).charsLeftOver=h-d,a.length>0&&l(t).unusedInput.push(a),l(t).bigHour===!0&&t._a[lo]<=12&&t._a[lo]>0&&(l(t).bigHour=void 0),t._a[lo]=kt(t._locale,t._a[lo],t._meridiem),wt(t),$(t)}function kt(t,e,i){var o;return null==i?e:null!=t.meridiemHour?t.meridiemHour(e,i):null!=t.isPM?(o=t.isPM(i),o&&12>e&&(e+=12),o||12!==e||(e=0),e):e}function Ot(t){var e,i,o,n,s;if(0===t._f.length)return l(t).invalidFormat=!0,void(t._d=new Date(NaN));for(n=0;ns)&&(o=s,i=e));a(t,i||e)}function Dt(t){if(!t._d){var e=T(t._i);t._a=[e.year,e.month,e.day||e.date,e.hour,e.minute,e.second,e.millisecond],wt(t)}}function Mt(t){var e=new f($(Ct(t)));return e._nextDay&&(e.add(1,"d"),e._nextDay=void 0),e}function Ct(t){var e=t._i,i=t._f;return t._locale=t._locale||D(t._l),null===e||void 0===i&&""===e?c({nullInput:!0}):("string"==typeof e&&(t._i=e=t._locale.preparse(e)),m(e)?new f($(e)):(o(i)?Ot(t):i?xt(t):n(e)?t._d=e:Tt(t),t))}function Tt(t){var i=t._i;void 0===i?t._d=new Date:n(i)?t._d=new Date(+i):"string"==typeof i?nt(t):o(i)?(t._a=s(i.slice(0),function(t){return parseInt(t,10)}),wt(t)):"object"==typeof i?Dt(t):"number"==typeof i?t._d=new Date(i):e.createFromInputFallback(t)}function Et(t,e,i,o,n){var s={};return"boolean"==typeof i&&(o=i,i=void 0),s._isAMomentObject=!0,s._useUTC=s._isUTC=n,s._l=i,s._i=t,s._f=e,s._strict=o,Mt(s)}function St(t,e,i,o){return Et(t,e,i,o,!1)}function Pt(t,e){var i,n;if(1===e.length&&o(e[0])&&(e=e[0]),!e.length)return St();for(i=e[0],n=1;nt&&(t=-t,i="-"),i+z(~~(t/60),2)+e+z(~~t%60,2)})}function Bt(t){var e=(t||"").match(eo)||[],i=e[e.length-1]||[],o=(i+"").match(Do)||["-",0,0],n=+(60*o[1])+g(o[2]);return"+"===o[0]?n:-n}function Rt(t,i){var o,s;return i._isUTC?(o=i.clone(),s=(m(t)||n(t)?+t:+St(t))-+o,o._d.setTime(+o._d+s),e.updateOffset(o,!1),o):St(t).local()}function Ft(t){return 15*-Math.round(t._d.getTimezoneOffset()/15)}function jt(t,i){var o,n=this._offset||0;return null!=t?("string"==typeof t&&(t=Bt(t)),Math.abs(t)<16&&(t=60*t),!this._isUTC&&i&&(o=Ft(this)),this._offset=t,this._isUTC=!0,null!=o&&this.add(o,"m"),n!==t&&(!i||this._changeInProgress?ie(this,Jt(t-n,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,e.updateOffset(this,!0),this._changeInProgress=null)),this):this._isUTC?n:Ft(this)}function Ht(t,e){return null!=t?("string"!=typeof t&&(t=-t),this.utcOffset(t,e),this):-this.utcOffset()}function Wt(t){return this.utcOffset(0,t)}function Yt(t){return this._isUTC&&(this.utcOffset(0,t),this._isUTC=!1,t&&this.subtract(Ft(this),"m")),this}function Gt(){return this._tzm?this.utcOffset(this._tzm):"string"==typeof this._i&&this.utcOffset(Bt(this._i)),this}function Ut(t){return t=t?St(t).utcOffset():0,(this.utcOffset()-t)%60===0}function Vt(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function qt(){if("undefined"!=typeof this._isDSTShifted)return this._isDSTShifted;var t={};if(p(t,this),t=Ct(t),t._a){var e=t._isUTC?h(t._a):St(t._a);this._isDSTShifted=this.isValid()&&y(t._a,e.toArray())>0}else this._isDSTShifted=!1;return this._isDSTShifted}function Xt(){return!this._isUTC}function Zt(){return this._isUTC}function Kt(){return this._isUTC&&0===this._offset}function Jt(t,e){var i,o,n,s=t,a=null;return Lt(t)?s={ms:t._milliseconds,d:t._days,M:t._months}:"number"==typeof t?(s={},e?s[e]=t:s.milliseconds=t):(a=Mo.exec(t))?(i="-"===a[1]?-1:1,s={y:0,d:g(a[ho])*i,h:g(a[lo])*i,m:g(a[uo])*i,s:g(a[co])*i,ms:g(a[po])*i}):(a=Co.exec(t))?(i="-"===a[1]?-1:1,s={y:Qt(a[2],i),M:Qt(a[3],i),d:Qt(a[4],i),h:Qt(a[5],i),m:Qt(a[6],i),s:Qt(a[7],i),w:Qt(a[8],i)}):null==s?s={}:"object"==typeof s&&("from"in s||"to"in s)&&(n=te(St(s.from),St(s.to)),s={},s.ms=n.milliseconds,s.M=n.months),o=new Nt(s),Lt(t)&&r(t,"_locale")&&(o._locale=t._locale),o}function Qt(t,e){var i=t&&parseFloat(t.replace(",","."));return(isNaN(i)?0:i)*e}function $t(t,e){var i={milliseconds:0,months:0};return i.months=e.month()-t.month()+12*(e.year()-t.year()),t.clone().add(i.months,"M").isAfter(e)&&--i.months,i.milliseconds=+e-+t.clone().add(i.months,"M"),i}function te(t,e){var i;return e=Rt(e,t),t.isBefore(e)?i=$t(t,e):(i=$t(e,t),i.milliseconds=-i.milliseconds,i.months=-i.months),i}function ee(t,e){return function(i,o){var n,s;return null===o||isNaN(+o)||(it(e,"moment()."+e+"(period, number) is deprecated. Please use moment()."+e+"(number, period)."),s=i,i=o,o=s),i="string"==typeof i?+i:i,n=Jt(i,o),ie(this,n,t),this}}function ie(t,i,o,n){var s=i._milliseconds,r=i._days,a=i._months;n=null==n?!0:n,s&&t._d.setTime(+t._d+s*o),r&&P(t,"Date",S(t,"Date")+r*o),a&&K(t,S(t,"Month")+a*o),n&&e.updateOffset(t,r||a)}function oe(t,e){var i=t||St(),o=Rt(i,this).startOf("day"),n=this.diff(o,"days",!0),s=-6>n?"sameElse":-1>n?"lastWeek":0>n?"lastDay":1>n?"sameDay":2>n?"nextDay":7>n?"nextWeek":"sameElse";return this.format(e&&e[s]||this.localeData().calendar(s,this,St(i)))}function ne(){return new f(this)}function se(t,e){var i;return e=C("undefined"!=typeof e?e:"millisecond"),"millisecond"===e?(t=m(t)?t:St(t),+this>+t):(i=m(t)?+t:+St(t),i<+this.clone().startOf(e))}function re(t,e){var i;return e=C("undefined"!=typeof e?e:"millisecond"),"millisecond"===e?(t=m(t)?t:St(t),+t>+this):(i=m(t)?+t:+St(t),+this.clone().endOf(e)e-s?(i=t.clone().add(n-1,"months"),o=(e-s)/(s-i)):(i=t.clone().add(n+1,"months"),o=(e-s)/(i-s)),-(n+o)}function ue(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")}function ce(){var t=this.clone().utc();return 0e;e++)if(this._weekdaysParse[e]||(i=St([2e3,1]).day(e),o="^"+this.weekdays(i,"")+"|^"+this.weekdaysShort(i,"")+"|^"+this.weekdaysMin(i,""),this._weekdaysParse[e]=new RegExp(o.replace(".",""),"i")),this._weekdaysParse[e].test(t))return e}function We(t){var e=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=t?(t=Be(t,this.localeData()),this.add(t-e,"d")):e}function Ye(t){var e=(this.day()+7-this.localeData()._week.dow)%7;return null==t?e:this.add(t-e,"d")}function Ge(t){return null==t?this.day()||7:this.day(this.day()%7?t:t-7)}function Ue(t,e){N(t,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),e)})}function Ve(t,e){return e._meridiemParse}function qe(t){return"p"===(t+"").toLowerCase().charAt(0)}function Xe(t,e,i){return t>11?i?"pm":"PM":i?"am":"AM"}function Ze(t,e){e[po]=g(1e3*("0."+t))}function Ke(){return this._isUTC?"UTC":""}function Je(){return this._isUTC?"Coordinated Universal Time":""}function Qe(t){return St(1e3*t)}function $e(){return St.apply(null,arguments).parseZone()}function ti(t,e,i){var o=this._calendar[t];return"function"==typeof o?o.call(e,i):o}function ei(t){var e=this._longDateFormat[t],i=this._longDateFormat[t.toUpperCase()];return e||!i?e:(this._longDateFormat[t]=i.replace(/MMMM|MM|DD|dddd/g,function(t){return t.slice(1)}),this._longDateFormat[t])}function ii(){return this._invalidDate}function oi(t){return this._ordinal.replace("%d",t)}function ni(t){return t}function si(t,e,i,o){var n=this._relativeTime[i];return"function"==typeof n?n(t,e,i,o):n.replace(/%d/i,t)}function ri(t,e){var i=this._relativeTime[t>0?"future":"past"];return"function"==typeof i?i(e):i.replace(/%s/i,e)}function ai(t){var e,i;for(i in t)e=t[i],"function"==typeof e?this[i]=e:this["_"+i]=e;this._ordinalParseLenient=new RegExp(this._ordinalParse.source+"|"+/\d{1,2}/.source)}function hi(t,e,i,o){var n=D(),s=h().set(o,e);return n[i](s,t)}function di(t,e,i,o,n){if("number"==typeof t&&(e=t,t=void 0),t=t||"",null!=e)return hi(t,e,i,n);var s,r=[];for(s=0;o>s;s++)r[s]=hi(t,s,i,n);return r}function li(t,e){return di(t,e,"months",12,"month")}function ui(t,e){return di(t,e,"monthsShort",12,"month")}function ci(t,e){return di(t,e,"weekdays",7,"day")}function pi(t,e){return di(t,e,"weekdaysShort",7,"day")}function fi(t,e){return di(t,e,"weekdaysMin",7,"day")}function mi(){var t=this._data;return this._milliseconds=Ko(this._milliseconds),this._days=Ko(this._days),this._months=Ko(this._months),t.milliseconds=Ko(t.milliseconds),t.seconds=Ko(t.seconds),t.minutes=Ko(t.minutes),t.hours=Ko(t.hours),t.months=Ko(t.months),t.years=Ko(t.years),this}function vi(t,e,i,o){var n=Jt(e,i);return t._milliseconds+=o*n._milliseconds,t._days+=o*n._days,t._months+=o*n._months,t._bubble()}function gi(t,e){return vi(this,t,e,1)}function yi(t,e){return vi(this,t,e,-1)}function bi(t){return 0>t?Math.floor(t):Math.ceil(t)}function wi(){var t,e,i,o,n,s=this._milliseconds,r=this._days,a=this._months,h=this._data;return s>=0&&r>=0&&a>=0||0>=s&&0>=r&&0>=a||(s+=864e5*bi(xi(a)+r),r=0,a=0),h.milliseconds=s%1e3,t=v(s/1e3),h.seconds=t%60,e=v(t/60),h.minutes=e%60,i=v(e/60),h.hours=i%24,r+=v(i/24),n=v(_i(r)),a+=n,r-=bi(xi(n)),o=v(a/12),a%=12,h.days=r,h.months=a,h.years=o,this}function _i(t){return 4800*t/146097}function xi(t){return 146097*t/4800}function ki(t){var e,i,o=this._milliseconds;if(t=C(t),"month"===t||"year"===t)return e=this._days+o/864e5,i=this._months+_i(e),"month"===t?i:i/12;switch(e=this._days+Math.round(xi(this._months)),t){case"week":return e/7+o/6048e5;case"day":return e+o/864e5;case"hour":return 24*e+o/36e5;case"minute":return 1440*e+o/6e4;case"second":return 86400*e+o/1e3;case"millisecond":return Math.floor(864e5*e)+o;default:throw new Error("Unknown unit "+t)}}function Oi(){return this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*g(this._months/12)}function Di(t){return function(){return this.as(t)}}function Mi(t){return t=C(t),this[t+"s"]()}function Ci(t){return function(){return this._data[t]}}function Ti(){return v(this.days()/7)}function Ei(t,e,i,o,n){return n.relativeTime(e||1,!!i,t,o)}function Si(t,e,i){var o=Jt(t).abs(),n=pn(o.as("s")),s=pn(o.as("m")),r=pn(o.as("h")),a=pn(o.as("d")),h=pn(o.as("M")),d=pn(o.as("y")),l=n0,l[4]=i,Ei.apply(null,l)}function Pi(t,e){return void 0===fn[t]?!1:void 0===e?fn[t]:(fn[t]=e,!0)}function Ii(t){var e=this.localeData(),i=Si(this,!t,e);return t&&(i=e.pastFuture(+this,i)),e.postformat(i)}function zi(){var t,e,i,o=mn(this._milliseconds)/1e3,n=mn(this._days),s=mn(this._months);t=v(o/60),e=v(t/60),o%=60,t%=60,i=v(s/12),s%=12;var r=i,a=s,h=n,d=e,l=t,u=o,c=this.asSeconds();return c?(0>c?"-":"")+"P"+(r?r+"Y":"")+(a?a+"M":"")+(h?h+"D":"")+(d||l||u?"T":"")+(d?d+"H":"")+(l?l+"M":"")+(u?u+"S":""):"P0D"}var Ni,Li,Ai=e.momentProperties=[],Bi=!1,Ri={},Fi={},ji=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,Hi=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,Wi={},Yi={},Gi=/\d/,Ui=/\d\d/,Vi=/\d{3}/,qi=/\d{4}/,Xi=/[+-]?\d{6}/,Zi=/\d\d?/,Ki=/\d{1,3}/,Ji=/\d{1,4}/,Qi=/[+-]?\d{1,6}/,$i=/\d+/,to=/[+-]?\d+/,eo=/Z|[+-]\d\d:?\d\d/gi,io=/[+-]?\d+(\.\d{1,3})?/,oo=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,no={},so={},ro=0,ao=1,ho=2,lo=3,uo=4,co=5,po=6;N("M",["MM",2],"Mo",function(){return this.month()+1}),N("MMM",0,0,function(t){return this.localeData().monthsShort(this,t)}),N("MMMM",0,0,function(t){return this.localeData().months(this,t)}),M("month","M"),j("M",Zi),j("MM",Zi,Ui),j("MMM",oo),j("MMMM",oo),Y(["M","MM"],function(t,e){e[ao]=g(t)-1}),Y(["MMM","MMMM"],function(t,e,i,o){var n=i._locale.monthsParse(t,o,i._strict);null!=n?e[ao]=n:l(i).invalidMonth=t});var fo="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),mo="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),vo={};e.suppressDeprecationWarnings=!1;var go=/^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,yo=[["YYYYYY-MM-DD",/[+-]\d{6}-\d{2}-\d{2}/],["YYYY-MM-DD",/\d{4}-\d{2}-\d{2}/],["GGGG-[W]WW-E",/\d{4}-W\d{2}-\d/],["GGGG-[W]WW",/\d{4}-W\d{2}/],["YYYY-DDD",/\d{4}-\d{3}/]],bo=[["HH:mm:ss.SSSS",/(T| )\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],wo=/^\/?Date\((\-?\d+)/i;e.createFromInputFallback=et("moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.",function(t){t._d=new Date(t._i+(t._useUTC?" UTC":""))}),N(0,["YY",2],0,function(){return this.year()%100}),N(0,["YYYY",4],0,"year"),N(0,["YYYYY",5],0,"year"),N(0,["YYYYYY",6,!0],0,"year"),M("year","y"),j("Y",to),j("YY",Zi,Ui),j("YYYY",Ji,qi),j("YYYYY",Qi,Xi),j("YYYYYY",Qi,Xi),Y(["YYYYY","YYYYYY"],ro),Y("YYYY",function(t,i){i[ro]=2===t.length?e.parseTwoDigitYear(t):g(t)}),Y("YY",function(t,i){i[ro]=e.parseTwoDigitYear(t)}),e.parseTwoDigitYear=function(t){return g(t)+(g(t)>68?1900:2e3)};var _o=E("FullYear",!1);N("w",["ww",2],"wo","week"),N("W",["WW",2],"Wo","isoWeek"),M("week","w"),M("isoWeek","W"),j("w",Zi),j("ww",Zi,Ui),j("W",Zi),j("WW",Zi,Ui),G(["w","ww","W","WW"],function(t,e,i,o){e[o.substr(0,1)]=g(t)});var xo={dow:0,doy:6};N("DDD",["DDDD",3],"DDDo","dayOfYear"),M("dayOfYear","DDD"),j("DDD",Ki),j("DDDD",Vi),Y(["DDD","DDDD"],function(t,e,i){i._dayOfYear=g(t)}),e.ISO_8601=function(){};var ko=et("moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548",function(){var t=St.apply(null,arguments);return this>t?this:t}),Oo=et("moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548",function(){var t=St.apply(null,arguments);return t>this?this:t});At("Z",":"),At("ZZ",""),j("Z",eo),j("ZZ",eo),Y(["Z","ZZ"],function(t,e,i){i._useUTC=!0,i._tzm=Bt(t)});var Do=/([\+\-]|\d\d)/gi;e.updateOffset=function(){};var Mo=/(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,Co=/^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/;Jt.fn=Nt.prototype;var To=ee(1,"add"),Eo=ee(-1,"subtract");e.defaultFormat="YYYY-MM-DDTHH:mm:ssZ";var So=et("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(t){return void 0===t?this.localeData():this.locale(t)});N(0,["gg",2],0,function(){return this.weekYear()%100}),N(0,["GG",2],0,function(){return this.isoWeekYear()%100}),Se("gggg","weekYear"),Se("ggggg","weekYear"),Se("GGGG","isoWeekYear"),Se("GGGGG","isoWeekYear"),M("weekYear","gg"),M("isoWeekYear","GG"),j("G",to),j("g",to),j("GG",Zi,Ui),j("gg",Zi,Ui),j("GGGG",Ji,qi),j("gggg",Ji,qi),j("GGGGG",Qi,Xi),j("ggggg",Qi,Xi),G(["gggg","ggggg","GGGG","GGGGG"],function(t,e,i,o){e[o.substr(0,2)]=g(t)}),G(["gg","GG"],function(t,i,o,n){i[n]=e.parseTwoDigitYear(t)}),N("Q",0,0,"quarter"),M("quarter","Q"),j("Q",Gi),Y("Q",function(t,e){e[ao]=3*(g(t)-1)}),N("D",["DD",2],"Do","date"),M("date","D"),j("D",Zi),j("DD",Zi,Ui),j("Do",function(t,e){return t?e._ordinalParse:e._ordinalParseLenient}),Y(["D","DD"],ho),Y("Do",function(t,e){e[ho]=g(t.match(Zi)[0],10)});var Po=E("Date",!0);N("d",0,"do","day"),N("dd",0,0,function(t){return this.localeData().weekdaysMin(this,t)}),N("ddd",0,0,function(t){return this.localeData().weekdaysShort(this,t)}),N("dddd",0,0,function(t){return this.localeData().weekdays(this,t)}),N("e",0,0,"weekday"),N("E",0,0,"isoWeekday"),M("day","d"),M("weekday","e"),M("isoWeekday","E"),j("d",Zi),j("e",Zi),j("E",Zi),j("dd",oo),j("ddd",oo),j("dddd",oo),G(["dd","ddd","dddd"],function(t,e,i){var o=i._locale.weekdaysParse(t);null!=o?e.d=o:l(i).invalidWeekday=t}),G(["d","e","E"],function(t,e,i,o){e[o]=g(t)});var Io="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),zo="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),No="Su_Mo_Tu_We_Th_Fr_Sa".split("_");N("H",["HH",2],0,"hour"),N("h",["hh",2],0,function(){return this.hours()%12||12}),Ue("a",!0),Ue("A",!1),M("hour","h"),j("a",Ve),j("A",Ve),j("H",Zi),j("h",Zi),j("HH",Zi,Ui),j("hh",Zi,Ui),Y(["H","HH"],lo),Y(["a","A"],function(t,e,i){i._isPm=i._locale.isPM(t),i._meridiem=t}),Y(["h","hh"],function(t,e,i){e[lo]=g(t),l(i).bigHour=!0});var Lo=/[ap]\.?m?\.?/i,Ao=E("Hours",!0);N("m",["mm",2],0,"minute"),M("minute","m"),j("m",Zi),j("mm",Zi,Ui),Y(["m","mm"],uo);var Bo=E("Minutes",!1);N("s",["ss",2],0,"second"),M("second","s"),j("s",Zi),j("ss",Zi,Ui),Y(["s","ss"],co);var Ro=E("Seconds",!1);N("S",0,0,function(){return~~(this.millisecond()/100)}),N(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),N(0,["SSS",3],0,"millisecond"),N(0,["SSSS",4],0,function(){return 10*this.millisecond()}),N(0,["SSSSS",5],0,function(){return 100*this.millisecond()}),N(0,["SSSSSS",6],0,function(){return 1e3*this.millisecond()}),N(0,["SSSSSSS",7],0,function(){return 1e4*this.millisecond()}),N(0,["SSSSSSSS",8],0,function(){return 1e5*this.millisecond()}),N(0,["SSSSSSSSS",9],0,function(){return 1e6*this.millisecond()}),M("millisecond","ms"),j("S",Ki,Gi),j("SS",Ki,Ui),j("SSS",Ki,Vi);var Fo;for(Fo="SSSS";Fo.length<=9;Fo+="S")j(Fo,$i);for(Fo="S";Fo.length<=9;Fo+="S")Y(Fo,Ze);var jo=E("Milliseconds",!1);N("z",0,0,"zoneAbbr"),N("zz",0,0,"zoneName");var Ho=f.prototype;Ho.add=To,Ho.calendar=oe,Ho.clone=ne,Ho.diff=de,Ho.endOf=_e,Ho.format=pe,Ho.from=fe,Ho.fromNow=me,Ho.to=ve,Ho.toNow=ge,Ho.get=I,Ho.invalidAt=Ee,Ho.isAfter=se,Ho.isBefore=re,Ho.isBetween=ae,Ho.isSame=he,Ho.isValid=Ce,Ho.lang=So,Ho.locale=ye,Ho.localeData=be,Ho.max=Oo,Ho.min=ko,Ho.parsingFlags=Te,Ho.set=I,Ho.startOf=we,Ho.subtract=Eo,Ho.toArray=De,Ho.toObject=Me,Ho.toDate=Oe,Ho.toISOString=ce,Ho.toJSON=ce,Ho.toString=ue,Ho.unix=ke,Ho.valueOf=xe,Ho.year=_o,Ho.isLeapYear=dt,Ho.weekYear=Ie,Ho.isoWeekYear=ze,Ho.quarter=Ho.quarters=Ae,Ho.month=J,Ho.daysInMonth=Q,Ho.week=Ho.weeks=ft,Ho.isoWeek=Ho.isoWeeks=mt,Ho.weeksInYear=Le,Ho.isoWeeksInYear=Ne,Ho.date=Po,Ho.day=Ho.days=We,Ho.weekday=Ye,Ho.isoWeekday=Ge,Ho.dayOfYear=gt,Ho.hour=Ho.hours=Ao,Ho.minute=Ho.minutes=Bo,Ho.second=Ho.seconds=Ro,Ho.millisecond=Ho.milliseconds=jo,Ho.utcOffset=jt,Ho.utc=Wt,Ho.local=Yt,Ho.parseZone=Gt,Ho.hasAlignedHourOffset=Ut,Ho.isDST=Vt,Ho.isDSTShifted=qt,Ho.isLocal=Xt,Ho.isUtcOffset=Zt,Ho.isUtc=Kt,Ho.isUTC=Kt,Ho.zoneAbbr=Ke,Ho.zoneName=Je,Ho.dates=et("dates accessor is deprecated. Use date instead.",Po),Ho.months=et("months accessor is deprecated. Use month instead",J),Ho.years=et("years accessor is deprecated. Use year instead",_o),Ho.zone=et("moment().zone is deprecated, use moment().utcOffset instead. https://github.com/moment/moment/issues/1779",Ht);var Wo=Ho,Yo={sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},Go={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},Uo="Invalid date",Vo="%d",qo=/\d{1,2}/,Xo={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},Zo=b.prototype;Zo._calendar=Yo,Zo.calendar=ti,Zo._longDateFormat=Go,Zo.longDateFormat=ei,Zo._invalidDate=Uo,Zo.invalidDate=ii,Zo._ordinal=Vo,Zo.ordinal=oi,Zo._ordinalParse=qo,Zo.preparse=ni,Zo.postformat=ni,Zo._relativeTime=Xo,Zo.relativeTime=si,Zo.pastFuture=ri,Zo.set=ai,Zo.months=q,Zo._months=fo,Zo.monthsShort=X,Zo._monthsShort=mo,Zo.monthsParse=Z,Zo.week=ut,Zo._week=xo,Zo.firstDayOfYear=pt,Zo.firstDayOfWeek=ct,Zo.weekdays=Re,Zo._weekdays=Io,Zo.weekdaysMin=je,Zo._weekdaysMin=No,Zo.weekdaysShort=Fe,Zo._weekdaysShort=zo,Zo.weekdaysParse=He,Zo.isPM=qe,Zo._meridiemParse=Lo,Zo.meridiem=Xe,k("en",{ordinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(t){var e=t%10,i=1===g(t%100/10)?"th":1===e?"st":2===e?"nd":3===e?"rd":"th";return t+i}}),e.lang=et("moment.lang is deprecated. Use moment.locale instead.",k),e.langData=et("moment.langData is deprecated. Use moment.localeData instead.",D);var Ko=Math.abs,Jo=Di("ms"),Qo=Di("s"),$o=Di("m"),tn=Di("h"),en=Di("d"),on=Di("w"),nn=Di("M"),sn=Di("y"),rn=Ci("milliseconds"),an=Ci("seconds"),hn=Ci("minutes"),dn=Ci("hours"),ln=Ci("days"),un=Ci("months"),cn=Ci("years"),pn=Math.round,fn={s:45,m:45,h:22,d:26,M:11},mn=Math.abs,vn=Nt.prototype;vn.abs=mi,vn.add=gi,vn.subtract=yi,vn.as=ki,vn.asMilliseconds=Jo,vn.asSeconds=Qo,vn.asMinutes=$o,vn.asHours=tn,vn.asDays=en,vn.asWeeks=on,vn.asMonths=nn,vn.asYears=sn,vn.valueOf=Oi,vn._bubble=wi,vn.get=Mi,vn.milliseconds=rn,vn.seconds=an,vn.minutes=hn,vn.hours=dn,vn.days=ln,vn.weeks=Ti,vn.months=un,vn.years=cn,vn.humanize=Ii,vn.toISOString=zi,vn.toString=zi,vn.toJSON=zi,vn.locale=ye,vn.localeData=be,vn.toIsoString=et("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",zi),vn.lang=So,N("X",0,0,"unix"),N("x",0,0,"valueOf"),j("x",to),j("X",io),Y("X",function(t,e,i){i._d=new Date(1e3*parseFloat(t,10))}),Y("x",function(t,e,i){i._d=new Date(g(t))}),e.version="2.10.6",i(St),e.fn=Wo,e.min=It,e.max=zt,e.utc=h,e.unix=Qe,e.months=li,e.isDate=n,e.locale=k,e.invalid=c,e.duration=Jt,e.isMoment=m,e.weekdays=ci,e.parseZone=$e,e.localeData=D,e.isDuration=Lt,e.monthsShort=ui,e.weekdaysMin=fi,e.defineLocale=O,e.weekdaysShort=pi,e.normalizeUnits=C,e.relativeTimeThreshold=Pi;var gn=e;return gn})}).call(e,i(4)(t))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}},function(t,e){function i(t){throw new Error("Cannot find module '"+t+"'.")}i.keys=function(){return[]},i.resolve=i,t.exports=i,i.id=5},function(t,e){(function(e){function i(t,e,i){var o=e&&i||0,n=0;for(e=e||[],t.toLowerCase().replace(/[0-9a-f]{2}/g,function(t){16>n&&(e[o+n++]=u[t])});16>n;)e[o+n++]=0;return e}function o(t,e){var i=e||0,o=l;return o[t[i++]]+o[t[i++]]+o[t[i++]]+o[t[i++]]+"-"+o[t[i++]]+o[t[i++]]+"-"+o[t[i++]]+o[t[i++]]+"-"+o[t[i++]]+o[t[i++]]+"-"+o[t[i++]]+o[t[i++]]+o[t[i++]]+o[t[i++]]+o[t[i++]]+o[t[i++]]}function n(t,e,i){var n=e&&i||0,s=e||[];t=t||{};var r=void 0!==t.clockseq?t.clockseq:m,a=void 0!==t.msecs?t.msecs:(new Date).getTime(),h=void 0!==t.nsecs?t.nsecs:g+1,d=a-v+(h-g)/1e4;if(0>d&&void 0===t.clockseq&&(r=r+1&16383),(0>d||a>v)&&void 0===t.nsecs&&(h=0),h>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");v=a,g=h,m=r,a+=122192928e5;var l=(1e4*(268435455&a)+h)%4294967296;s[n++]=l>>>24&255,s[n++]=l>>>16&255,s[n++]=l>>>8&255,s[n++]=255&l;var u=a/4294967296*1e4&268435455;s[n++]=u>>>8&255,s[n++]=255&u,s[n++]=u>>>24&15|16,s[n++]=u>>>16&255,s[n++]=r>>>8|128,s[n++]=255&r;for(var c=t.node||f,p=0;6>p;p++)s[n+p]=c[p];return e?e:o(s)}function s(t,e,i){var n=e&&i||0;"string"==typeof t&&(e="binary"==t?new Array(16):null,t=null),t=t||{};var s=t.random||(t.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,e)for(var a=0;16>a;a++)e[n+a]=s[a];return e||o(s)}var r,a="undefined"!=typeof window?window:"undefined"!=typeof e?e:null;if(a&&a.crypto&&crypto.getRandomValues){var h=new Uint8Array(16);r=function(){return crypto.getRandomValues(h),h}}if(!r){var d=new Array(16);r=function(){for(var t,e=0;16>e;e++)0===(3&e)&&(t=4294967296*Math.random()),d[e]=t>>>((3&e)<<3)&255;return d}}for(var l=[],u={},c=0;256>c;c++)l[c]=(c+256).toString(16).substr(1),u[l[c]]=c;var p=r(),f=[1|p[0],p[1],p[2],p[3],p[4],p[5]],m=16383&(p[6]<<8|p[7]),v=0,g=0,y=s;y.v1=n,y.v4=s,y.parse=i,y.unparse=o,t.exports=y}).call(e,function(){return this}())},function(t,e){e.prepareElements=function(t){for(var e in t)t.hasOwnProperty(e)&&(t[e].redundant=t[e].used,t[e].used=[])},e.cleanupElements=function(t){for(var e in t)if(t.hasOwnProperty(e)&&t[e].redundant){for(var i=0;i0?(o=e[t].redundant[0],e[t].redundant.shift()):(o=document.createElementNS("http://www.w3.org/2000/svg",t),i.appendChild(o)):(o=document.createElementNS("http://www.w3.org/2000/svg",t),e[t]={used:[],redundant:[]},i.appendChild(o)),e[t].used.push(o),o},e.getDOMElement=function(t,e,i,o){var n;return e.hasOwnProperty(t)?e[t].redundant.length>0?(n=e[t].redundant[0],e[t].redundant.shift()):(n=document.createElement(t),void 0!==o?i.insertBefore(n,o):i.appendChild(n)):(n=document.createElement(t),e[t]={used:[],redundant:[]},void 0!==o?i.insertBefore(n,o):i.appendChild(n)),e[t].used.push(n),n},e.drawPoint=function(t,i,o,n,s,r){var a;if("circle"==o.style?(a=e.getSVGElement("circle",n,s),a.setAttributeNS(null,"cx",t),a.setAttributeNS(null,"cy",i),a.setAttributeNS(null,"r",.5*o.size)):(a=e.getSVGElement("rect",n,s),a.setAttributeNS(null,"x",t-.5*o.size),a.setAttributeNS(null,"y",i-.5*o.size),a.setAttributeNS(null,"width",o.size),a.setAttributeNS(null,"height",o.size)),void 0!==o.styles&&a.setAttributeNS(null,"style",o.styles),a.setAttributeNS(null,"class",o.className+" vis-point"),r){var h=e.getSVGElement("text",n,s);r.xOffset&&(t+=r.xOffset),r.yOffset&&(i+=r.yOffset),r.content&&(h.textContent=r.content),r.className&&h.setAttributeNS(null,"class",r.className+" vis-label"),h.setAttributeNS(null,"x",t),h.setAttributeNS(null,"y",i)}return a},e.drawBar=function(t,i,o,n,s,r,a,h){if(0!=n){0>n&&(n*=-1,i-=n);var d=e.getSVGElement("rect",r,a);d.setAttributeNS(null,"x",t-.5*o),d.setAttributeNS(null,"y",i),d.setAttributeNS(null,"width",o),d.setAttributeNS(null,"height",n),d.setAttributeNS(null,"class",s),h&&d.setAttributeNS(null,"style",h)}}},function(t,e,i){function o(t,e){if(t&&!Array.isArray(t)&&(e=t,t=null),this._options=e||{},this._data={},this.length=0,this._fieldId=this._options.fieldId||"id",this._type={},this._options.type)for(var i in this._options.type)if(this._options.type.hasOwnProperty(i)){var o=this._options.type[i];"Date"==o||"ISODate"==o||"ASPDate"==o?this._type[i]="Date":this._type[i]=o}if(this._options.convert)throw new Error('Option "convert" is deprecated. Use "type" instead.');this._subscribers={},t&&this.add(t),this.setOptions(e)}var n=i(1),s=i(9);o.prototype.setOptions=function(t){t&&void 0!==t.queue&&(t.queue===!1?this._queue&&(this._queue.destroy(),delete this._queue):(this._queue||(this._queue=s.extend(this,{replace:["add","update","remove"]})),"object"==typeof t.queue&&this._queue.setOptions(t.queue)))},o.prototype.on=function(t,e){var i=this._subscribers[t];i||(i=[],this._subscribers[t]=i),i.push({callback:e})},o.prototype.subscribe=function(){throw new Error("DataSet.subscribe is deprecated. Use DataSet.on instead.")},o.prototype.off=function(t,e){var i=this._subscribers[t];i&&(this._subscribers[t]=i.filter(function(t){return t.callback!=e}))},o.prototype.unsubscribe=function(){throw new Error("DataSet.unsubscribe is deprecated. Use DataSet.off instead.")},o.prototype._trigger=function(t,e,i){if("*"==t)throw new Error("Cannot trigger event *");var o=[];t in this._subscribers&&(o=o.concat(this._subscribers[t])),"*"in this._subscribers&&(o=o.concat(this._subscribers["*"]));for(var n=0;ns;s++)i=n._addItem(t[s]),o.push(i);else{if(!(t instanceof Object))throw new Error("Unknown dataType");i=n._addItem(t),o.push(i)}return o.length&&this._trigger("add",{items:o},e),o},o.prototype.update=function(t,e){var i=[],o=[],n=[],s=this,r=s._fieldId,a=function(t){var e=t[r];s._data[e]?(e=s._updateItem(t),o.push(e),n.push(t)):(e=s._addItem(t),i.push(e))};if(Array.isArray(t))for(var h=0,d=t.length;d>h;h++)a(t[h]);else{if(!(t instanceof Object))throw new Error("Unknown dataType");a(t)}return i.length&&this._trigger("add",{items:i},e),o.length&&this._trigger("update",{items:o,data:n},e),i.concat(o)},o.prototype.get=function(t){var e,i,o,s=this,r=n.getType(arguments[0]);"String"==r||"Number"==r?(e=arguments[0],o=arguments[1]):"Array"==r?(i=arguments[0],o=arguments[1]):o=arguments[0];var a;if(o&&o.returnType){var h=["Array","Object"];a=-1==h.indexOf(o.returnType)?"Array":o.returnType}else a="Array";var d,l,u,c,p=o&&o.type||this._options.type,f=o&&o.filter,m=[];if(void 0!=e)d=s._getItem(e,p),f&&!f(d)&&(d=null);else if(void 0!=i)for(u=0,c=i.length;c>u;u++)d=s._getItem(i[u],p),(!f||f(d))&&m.push(d);else for(l in this._data)this._data.hasOwnProperty(l)&&(d=s._getItem(l,p),(!f||f(d))&&m.push(d));if(o&&o.order&&void 0==e&&this._sort(m,o.order),o&&o.fields){var v=o.fields;if(void 0!=e)d=this._filterFields(d,v);else for(u=0,c=m.length;c>u;u++)m[u]=this._filterFields(m[u],v)}if("Object"==a){var g={};for(u=0;ue;e++)l[e]=s[e][this._fieldId]}else for(o in r)r.hasOwnProperty(o)&&(n=this._getItem(o,d),a(n)&&l.push(n[this._fieldId]));else if(h){s=[];for(o in r)r.hasOwnProperty(o)&&s.push(r[o]);for(this._sort(s,h),e=0,i=s.length;i>e;e++)l[e]=s[e][this._fieldId]}else for(o in r)r.hasOwnProperty(o)&&(n=r[o],l.push(n[this._fieldId]));return l},o.prototype.getDataSet=function(){return this},o.prototype.forEach=function(t,e){var i,o,n=e&&e.filter,s=e&&e.type||this._options.type,r=this._data;if(e&&e.order)for(var a=this.get(e),h=0,d=a.length;d>h;h++)i=a[h],o=i[this._fieldId],t(i,o);else for(o in r)r.hasOwnProperty(o)&&(i=this._getItem(o,s),(!n||n(i))&&t(i,o))},o.prototype.map=function(t,e){var i,o=e&&e.filter,n=e&&e.type||this._options.type,s=[],r=this._data;for(var a in r)r.hasOwnProperty(a)&&(i=this._getItem(a,n),(!o||o(i))&&s.push(t(i,a)));return e&&e.order&&this._sort(s,e.order),s},o.prototype._filterFields=function(t,e){if(!t)return t;var i={};if(Array.isArray(e))for(var o in t)t.hasOwnProperty(o)&&-1!=e.indexOf(o)&&(i[o]=t[o]);else for(var o in t)t.hasOwnProperty(o)&&e.hasOwnProperty(o)&&(i[e[o]]=t[o]);return i},o.prototype._sort=function(t,e){if(n.isString(e)){var i=e;t.sort(function(t,e){var o=t[i],n=e[i];return o>n?1:n>o?-1:0})}else{if("function"!=typeof e)throw new TypeError("Order must be a function or a string");t.sort(e)}},o.prototype.remove=function(t,e){var i,o,n,s=[];if(Array.isArray(t))for(i=0,o=t.length;o>i;i++)n=this._remove(t[i]),null!=n&&s.push(n);else n=this._remove(t),null!=n&&s.push(n);return s.length&&this._trigger("remove",{items:s},e),s},o.prototype._remove=function(t){if(n.isNumber(t)||n.isString(t)){if(this._data[t])return delete this._data[t],this.length--,t}else if(t instanceof Object){var e=t[this._fieldId];if(e&&this._data[e])return delete this._data[e],this.length--,e}return null},o.prototype.clear=function(t){var e=Object.keys(this._data);return this._data={},this.length=0,this._trigger("remove",{items:e},t),e},o.prototype.max=function(t){var e=this._data,i=null,o=null;for(var n in e)if(e.hasOwnProperty(n)){var s=e[n],r=s[t];null!=r&&(!i||r>o)&&(i=s,o=r)}return i},o.prototype.min=function(t){var e=this._data,i=null,o=null;for(var n in e)if(e.hasOwnProperty(n)){var s=e[n],r=s[t];null!=r&&(!i||o>r)&&(i=s,o=r)}return i},o.prototype.distinct=function(t){var e,i=this._data,o=[],s=this._options.type&&this._options.type[t]||null,r=0;for(var a in i)if(i.hasOwnProperty(a)){var h=i[a],d=h[t],l=!1;for(e=0;r>e;e++)if(o[e]==d){l=!0;break}l||void 0===d||(o[r]=d,r++)}if(s)for(e=0;ethis.max&&this.flush(),clearTimeout(this._timeout),this.queue.length>0&&"number"==typeof this.delay){var t=this;this._timeout=setTimeout(function(){t.flush()},this.delay)}},i.prototype.flush=function(){for(;this._queue.length>0;){var t=this._queue.shift();t.fn.apply(t.context||t.fn,t.args||[])}},t.exports=i},function(t,e,i){function o(t,e){this._data=null,this._ids={},this.length=0,this._options=e||{},this._fieldId="id",this._subscribers={};var i=this;this.listener=function(){i._onEvent.apply(i,arguments)},this.setData(t)}var n=i(1),s=i(8);o.prototype.setData=function(t){var e,i,o;if(this._data){this._data.off&&this._data.off("*",this.listener),e=[];for(var n in this._ids)this._ids.hasOwnProperty(n)&&e.push(n);this._ids={},this.length=0,this._trigger("remove",{items:e})}if(this._data=t,this._data){for(this._fieldId=this._options.fieldId||this._data&&this._data.options&&this._data.options.fieldId||"id",e=this._data.getIds({filter:this._options&&this._options.filter}),i=0,o=e.length;o>i;i++)n=e[i],this._ids[n]=!0;this.length=e.length,this._trigger("add",{items:e}),this._data.on&&this._data.on("*",this.listener)}},o.prototype.refresh=function(){for(var t,e=this._data.getIds({filter:this._options&&this._options.filter}),i={},o=[],n=[],s=0;so;o++)s=a[o],r=this.get(s),r&&(this._ids[s]=!0,l.push(s));break;case"update":for(o=0,n=a.length;n>o;o++)s=a[o],r=this.get(s),r?this._ids[s]?(u.push(s),d.push(e.data[o])):(this._ids[s]=!0,l.push(s)):this._ids[s]&&(delete this._ids[s], -c.push(s));break;case"remove":for(o=0,n=a.length;n>o;o++)s=a[o],this._ids[s]&&(delete this._ids[s],c.push(s))}this.length+=l.length-c.length,l.length&&this._trigger("add",{items:l},i),u.length&&this._trigger("update",{items:u,data:d},i),c.length&&this._trigger("remove",{items:c},i)}},o.prototype.on=s.prototype.on,o.prototype.off=s.prototype.off,o.prototype._trigger=s.prototype._trigger,o.prototype.subscribe=o.prototype.on,o.prototype.unsubscribe=o.prototype.off,t.exports=o},function(t,e,i){function o(t,e,i){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");this.containerElement=t,this.width="400px",this.height="400px",this.margin=10,this.defaultXCenter="55%",this.defaultYCenter="50%",this.xLabel="x",this.yLabel="y",this.zLabel="z";var n=function(t){return t};this.xValueLabel=n,this.yValueLabel=n,this.zValueLabel=n,this.filterLabel="time",this.legendLabel="value",this.style=o.STYLE.DOT,this.showPerspective=!0,this.showGrid=!0,this.keepAspectRatio=!0,this.showShadow=!1,this.showGrayBottom=!1,this.showTooltip=!1,this.verticalRatio=.5,this.animationInterval=1e3,this.animationPreload=!1,this.camera=new c,this.camera.setArmRotation(1,.5),this.camera.setArmLength(1.7),this.eye=new l(0,0,-1),this.dataTable=null,this.dataPoints=null,this.colX=void 0,this.colY=void 0,this.colZ=void 0,this.colValue=void 0,this.colFilter=void 0,this.xMin=0,this.xStep=void 0,this.xMax=1,this.yMin=0,this.yStep=void 0,this.yMax=1,this.zMin=0,this.zStep=void 0,this.zMax=1,this.valueMin=0,this.valueMax=1,this.xBarWidth=1,this.yBarWidth=1,this.axisColor="#4D4D4D",this.gridColor="#D3D3D3",this.dataColor={fill:"#7DC1FF",stroke:"#3267D2",strokeWidth:1},this.create(),this.setOptions(i),e&&this.setData(e)}function n(t){return"clientX"in t?t.clientX:t.targetTouches[0]&&t.targetTouches[0].clientX||0}function s(t){return"clientY"in t?t.clientY:t.targetTouches[0]&&t.targetTouches[0].clientY||0}var r=i(12),a=i(8),h=i(10),d=i(1),l=i(13),u=i(14),c=i(15),p=i(16),f=i(17),m=i(18);r(o.prototype),o.prototype._setScale=function(){this.scale=new l(1/(this.xMax-this.xMin),1/(this.yMax-this.yMin),1/(this.zMax-this.zMin)),this.keepAspectRatio&&(this.scale.x3&&(this.colFilter=3);else{if(this.style!==o.STYLE.DOTCOLOR&&this.style!==o.STYLE.DOTSIZE&&this.style!==o.STYLE.BARCOLOR&&this.style!==o.STYLE.BARSIZE)throw'Unknown style "'+this.style+'"';this.colX=0,this.colY=1,this.colZ=2,this.colValue=3,t.getNumberOfColumns()>4&&(this.colFilter=4)}},o.prototype.getNumberOfRows=function(t){return t.length},o.prototype.getNumberOfColumns=function(t){var e=0;for(var i in t[0])t[0].hasOwnProperty(i)&&e++;return e},o.prototype.getDistinctValues=function(t,e){for(var i=[],o=0;ot[o][e]&&(i.min=t[o][e]),i.maxt;t++){var f=(t-c)/(p-c),v=240*f,g=this._hsv2rgb(v,1,1);u.strokeStyle=g,u.beginPath(),u.moveTo(h,r+t),u.lineTo(a,r+t),u.stroke()}u.strokeStyle=this.axisColor,u.strokeRect(h,r,i,s)}if(this.style===o.STYLE.DOTSIZE&&(u.strokeStyle=this.axisColor,u.fillStyle=this.dataColor.fill,u.beginPath(),u.moveTo(h,r),u.lineTo(a,r),u.lineTo(a-i+e,d),u.lineTo(h,d),u.closePath(),u.fill(),u.stroke()),this.style===o.STYLE.DOTCOLOR||this.style===o.STYLE.DOTSIZE){var y=5,b=new m(this.valueMin,this.valueMax,(this.valueMax-this.valueMin)/5,!0);for(b.start(),b.getCurrent()0?this.yMin:this.yMax,n=this._convert3Dto2D(new l(_,r,this.zMin)),Math.cos(2*w)>0?(v.textAlign="center",v.textBaseline="top",n.y+=b):Math.sin(2*w)<0?(v.textAlign="right",v.textBaseline="middle"):(v.textAlign="left",v.textBaseline="middle"),v.fillStyle=this.axisColor,v.fillText(" "+this.xValueLabel(i.getCurrent())+" ",n.x,n.y),i.next()}for(v.lineWidth=1,o=void 0===this.defaultYStep,i=new m(this.yMin,this.yMax,this.yStep,o),i.start(),i.getCurrent()0?this.xMin:this.xMax,n=this._convert3Dto2D(new l(s,i.getCurrent(),this.zMin)),Math.cos(2*w)<0?(v.textAlign="center",v.textBaseline="top",n.y+=b):Math.sin(2*w)>0?(v.textAlign="right",v.textBaseline="middle"):(v.textAlign="left",v.textBaseline="middle"),v.fillStyle=this.axisColor,v.fillText(" "+this.yValueLabel(i.getCurrent())+" ",n.x,n.y),i.next();for(v.lineWidth=1,o=void 0===this.defaultZStep,i=new m(this.zMin,this.zMax,this.zStep,o),i.start(),i.getCurrent()0?this.xMin:this.xMax,r=Math.sin(w)<0?this.yMin:this.yMax;!i.end();)t=this._convert3Dto2D(new l(s,r,i.getCurrent())),v.strokeStyle=this.axisColor,v.beginPath(),v.moveTo(t.x,t.y),v.lineTo(t.x-b,t.y),v.stroke(),v.textAlign="right",v.textBaseline="middle",v.fillStyle=this.axisColor,v.fillText(this.zValueLabel(i.getCurrent())+" ",t.x-5,t.y),i.next();v.lineWidth=1,t=this._convert3Dto2D(new l(s,r,this.zMin)),e=this._convert3Dto2D(new l(s,r,this.zMax)),v.strokeStyle=this.axisColor,v.beginPath(),v.moveTo(t.x,t.y),v.lineTo(e.x,e.y),v.stroke(),v.lineWidth=1,c=this._convert3Dto2D(new l(this.xMin,this.yMin,this.zMin)),p=this._convert3Dto2D(new l(this.xMax,this.yMin,this.zMin)),v.strokeStyle=this.axisColor,v.beginPath(),v.moveTo(c.x,c.y),v.lineTo(p.x,p.y),v.stroke(),c=this._convert3Dto2D(new l(this.xMin,this.yMax,this.zMin)),p=this._convert3Dto2D(new l(this.xMax,this.yMax,this.zMin)),v.strokeStyle=this.axisColor,v.beginPath(),v.moveTo(c.x,c.y),v.lineTo(p.x,p.y),v.stroke(),v.lineWidth=1,t=this._convert3Dto2D(new l(this.xMin,this.yMin,this.zMin)),e=this._convert3Dto2D(new l(this.xMin,this.yMax,this.zMin)),v.strokeStyle=this.axisColor,v.beginPath(),v.moveTo(t.x,t.y),v.lineTo(e.x,e.y),v.stroke(),t=this._convert3Dto2D(new l(this.xMax,this.yMin,this.zMin)),e=this._convert3Dto2D(new l(this.xMax,this.yMax,this.zMin)),v.strokeStyle=this.axisColor,v.beginPath(),v.moveTo(t.x,t.y),v.lineTo(e.x,e.y),v.stroke();var x=this.xLabel;x.length>0&&(u=.1/this.scale.y,s=(this.xMin+this.xMax)/2,r=Math.cos(w)>0?this.yMin-u:this.yMax+u,n=this._convert3Dto2D(new l(s,r,this.zMin)),Math.cos(2*w)>0?(v.textAlign="center",v.textBaseline="top"):Math.sin(2*w)<0?(v.textAlign="right",v.textBaseline="middle"):(v.textAlign="left",v.textBaseline="middle"),v.fillStyle=this.axisColor,v.fillText(x,n.x,n.y));var k=this.yLabel;k.length>0&&(d=.1/this.scale.x,s=Math.sin(w)>0?this.xMin-d:this.xMax+d,r=(this.yMin+this.yMax)/2,n=this._convert3Dto2D(new l(s,r,this.zMin)),Math.cos(2*w)<0?(v.textAlign="center",v.textBaseline="top"):Math.sin(2*w)>0?(v.textAlign="right",v.textBaseline="middle"):(v.textAlign="left",v.textBaseline="middle"),v.fillStyle=this.axisColor,v.fillText(k,n.x,n.y));var O=this.zLabel;O.length>0&&(h=30,s=Math.cos(w)>0?this.xMin:this.xMax,r=Math.sin(w)<0?this.yMin:this.yMax,a=(this.zMin+this.zMax)/2,n=this._convert3Dto2D(new l(s,r,a)),v.textAlign="right",v.textBaseline="middle",v.fillStyle=this.axisColor,v.fillText(O,n.x-h,n.y))},o.prototype._hsv2rgb=function(t,e,i){var o,n,s,r,a,h;switch(r=i*e,a=Math.floor(t/60),h=r*(1-Math.abs(t/60%2-1)),a){case 0:o=r,n=h,s=0;break;case 1:o=h,n=r,s=0;break;case 2:o=0,n=r,s=h;break;case 3:o=0,n=h,s=r;break;case 4:o=h,n=0,s=r;break;case 5:o=r,n=0,s=h;break;default:o=0,n=0,s=0}return"RGB("+parseInt(255*o)+","+parseInt(255*n)+","+parseInt(255*s)+")"},o.prototype._redrawDataGrid=function(){var t,e,i,n,s,r,a,h,d,u,c,p,f=this.frame.canvas,m=f.getContext("2d");if(m.lineJoin="round",m.lineCap="round",!(void 0===this.dataPoints||this.dataPoints.length<=0)){for(s=0;s0}else r=!0;r?(p=(t.point.z+e.point.z+i.point.z+n.point.z)/4,d=240*(1-(p-this.zMin)*this.scale.z/this.verticalRatio),u=1,this.showShadow?(c=Math.min(1+x.x/k/2,1),a=this._hsv2rgb(d,u,c),h=a):(c=1,a=this._hsv2rgb(d,u,c),h=this.axisColor)):(a="gray",h=this.axisColor),m.lineWidth=this._getStrokeWidth(t),m.fillStyle=a,m.strokeStyle=h,m.beginPath(),m.moveTo(t.screen.x,t.screen.y),m.lineTo(e.screen.x,e.screen.y),m.lineTo(n.screen.x,n.screen.y),m.lineTo(i.screen.x,i.screen.y),m.closePath(),m.fill(),m.stroke()}}else for(s=0;sc&&(c=0);var p,f,m;this.style===o.STYLE.DOTCOLOR?(p=240*(1-(d.point.value-this.valueMin)*this.scale.value),f=this._hsv2rgb(p,1,1),m=this._hsv2rgb(p,1,.8)):this.style===o.STYLE.DOTSIZE?(f=this.dataColor.fill,m=this.dataColor.stroke):(p=240*(1-(d.point.z-this.zMin)*this.scale.z/this.verticalRatio),f=this._hsv2rgb(p,1,1),m=this._hsv2rgb(p,1,.8)),i.lineWidth=this._getStrokeWidth(d),i.strokeStyle=m,i.fillStyle=f,i.beginPath(),i.arc(d.screen.x,d.screen.y,c,0,2*Math.PI,!0),i.fill(),i.stroke()}}},o.prototype._redrawDataBar=function(){var t,e,i,n,s=this.frame.canvas,r=s.getContext("2d");if(!(void 0===this.dataPoints||this.dataPoints.length<=0)){for(t=0;t0){for(t=this.dataPoints[0],o.lineWidth=this._getStrokeWidth(t),o.lineJoin="round",o.lineCap="round",o.strokeStyle=this.dataColor.stroke,o.beginPath(),o.moveTo(t.screen.x,t.screen.y),e=1;e0?1:0>t?-1:0}var o=e[0],n=e[1],s=e[2],r=i((n.x-o.x)*(t.y-o.y)-(n.y-o.y)*(t.x-o.x)),a=i((s.x-n.x)*(t.y-n.y)-(s.y-n.y)*(t.x-n.x)),h=i((o.x-s.x)*(t.y-s.y)-(o.y-s.y)*(t.x-s.x));return!(0!=r&&0!=a&&r!=a||0!=a&&0!=h&&a!=h||0!=r&&0!=h&&r!=h)},o.prototype._dataPointFromXY=function(t,e){var i,n=100,s=null,r=null,a=null,h=new u(t,e);if(this.style===o.STYLE.BAR||this.style===o.STYLE.BARCOLOR||this.style===o.STYLE.BARSIZE)for(i=this.dataPoints.length-1;i>=0;i--){s=this.dataPoints[i];var d=s.surfaces;if(d)for(var l=d.length-1;l>=0;l--){var c=d[l],p=c.corners,f=[p[0].screen,p[1].screen,p[2].screen],m=[p[2].screen,p[3].screen,p[0].screen];if(this._insideTriangle(h,f)||this._insideTriangle(h,m))return s}}else for(i=0;ib)&&n>b&&(a=b,r=s)}}return r},o.prototype._showTooltip=function(t){var e,i,o;this.tooltip?(e=this.tooltip.dom.content,i=this.tooltip.dom.line,o=this.tooltip.dom.dot):(e=document.createElement("div"),e.style.position="absolute",e.style.padding="10px",e.style.border="1px solid #4d4d4d",e.style.color="#1a1a1a",e.style.background="rgba(255,255,255,0.7)",e.style.borderRadius="2px",e.style.boxShadow="5px 5px 10px rgba(128,128,128,0.5)",i=document.createElement("div"),i.style.position="absolute",i.style.height="40px",i.style.width="0",i.style.borderLeft="1px solid #4d4d4d",o=document.createElement("div"),o.style.position="absolute",o.style.height="0",o.style.width="0",o.style.border="5px solid #4d4d4d",o.style.borderRadius="5px",this.tooltip={dataPoint:null,dom:{content:e,line:i,dot:o}}),this._hideTooltip(),this.tooltip.dataPoint=t,"function"==typeof this.showTooltip?e.innerHTML=this.showTooltip(t.point):e.innerHTML="
x:"+t.point.x+"
y:"+t.point.y+"
z:"+t.point.z+"
",e.style.left="0",e.style.top="0",this.frame.appendChild(e),this.frame.appendChild(i),this.frame.appendChild(o);var n=e.offsetWidth,s=e.offsetHeight,r=i.offsetHeight,a=o.offsetWidth,h=o.offsetHeight,d=t.screen.x-n/2;d=Math.min(Math.max(d,10),this.frame.clientWidth-10-n),i.style.left=t.screen.x+"px",i.style.top=t.screen.y-r+"px",e.style.left=d+"px",e.style.top=t.screen.y-r-s+"px",o.style.left=t.screen.x-a/2+"px",o.style.top=t.screen.y-h/2+"px"},o.prototype._hideTooltip=function(){if(this.tooltip){this.tooltip.dataPoint=null;for(var t in this.tooltip.dom)if(this.tooltip.dom.hasOwnProperty(t)){var e=this.tooltip.dom[t];e&&e.parentNode&&e.parentNode.removeChild(e)}}},t.exports=o},function(t,e){function i(t){return t?o(t):void 0}function o(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}t.exports=i,i.prototype.on=i.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[t]=this._callbacks[t]||[]).push(e),this},i.prototype.once=function(t,e){function i(){o.off(t,i),e.apply(this,arguments)}var o=this;return this._callbacks=this._callbacks||{},i.fn=e,this.on(t,i),this},i.prototype.off=i.prototype.removeListener=i.prototype.removeAllListeners=i.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var i=this._callbacks[t];if(!i)return this;if(1==arguments.length)return delete this._callbacks[t],this;for(var o,n=0;no;++o)i[o].apply(this,e)}return this},i.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[t]||[]},i.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e){function i(t,e,i){this.x=void 0!==t?t:0,this.y=void 0!==e?e:0,this.z=void 0!==i?i:0}i.subtract=function(t,e){var o=new i;return o.x=t.x-e.x,o.y=t.y-e.y,o.z=t.z-e.z,o},i.add=function(t,e){var o=new i;return o.x=t.x+e.x,o.y=t.y+e.y,o.z=t.z+e.z,o},i.avg=function(t,e){return new i((t.x+e.x)/2,(t.y+e.y)/2,(t.z+e.z)/2)},i.crossProduct=function(t,e){var o=new i;return o.x=t.y*e.z-t.z*e.y,o.y=t.z*e.x-t.x*e.z,o.z=t.x*e.y-t.y*e.x,o},i.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},t.exports=i},function(t,e){function i(t,e){this.x=void 0!==t?t:0,this.y=void 0!==e?e:0}t.exports=i},function(t,e,i){function o(){this.armLocation=new n,this.armRotation={},this.armRotation.horizontal=0,this.armRotation.vertical=0,this.armLength=1.7,this.cameraLocation=new n,this.cameraRotation=new n(.5*Math.PI,0,0),this.calculateCameraOrientation()}var n=i(13);o.prototype.setArmLocation=function(t,e,i){this.armLocation.x=t,this.armLocation.y=e,this.armLocation.z=i,this.calculateCameraOrientation()},o.prototype.setArmRotation=function(t,e){void 0!==t&&(this.armRotation.horizontal=t),void 0!==e&&(this.armRotation.vertical=e,this.armRotation.vertical<0&&(this.armRotation.vertical=0),this.armRotation.vertical>.5*Math.PI&&(this.armRotation.vertical=.5*Math.PI)),(void 0!==t||void 0!==e)&&this.calculateCameraOrientation()},o.prototype.getArmRotation=function(){var t={};return t.horizontal=this.armRotation.horizontal,t.vertical=this.armRotation.vertical,t},o.prototype.setArmLength=function(t){void 0!==t&&(this.armLength=t,this.armLength<.71&&(this.armLength=.71),this.armLength>5&&(this.armLength=5),this.calculateCameraOrientation())},o.prototype.getArmLength=function(){return this.armLength},o.prototype.getCameraLocation=function(){return this.cameraLocation},o.prototype.getCameraRotation=function(){return this.cameraRotation},o.prototype.calculateCameraOrientation=function(){this.cameraLocation.x=this.armLocation.x-this.armLength*Math.sin(this.armRotation.horizontal)*Math.cos(this.armRotation.vertical),this.cameraLocation.y=this.armLocation.y-this.armLength*Math.cos(this.armRotation.horizontal)*Math.cos(this.armRotation.vertical),this.cameraLocation.z=this.armLocation.z+this.armLength*Math.sin(this.armRotation.vertical),this.cameraRotation.x=Math.PI/2-this.armRotation.vertical,this.cameraRotation.y=0,this.cameraRotation.z=-this.armRotation.horizontal},t.exports=o},function(t,e,i){function o(t,e,i){this.data=t,this.column=e,this.graph=i,this.index=void 0,this.value=void 0,this.values=i.getDistinctValues(t.get(),this.column),this.values.sort(function(t,e){return t>e?1:e>t?-1:0}),this.values.length>0&&this.selectValue(0),this.dataPoints=[],this.loaded=!1,this.onLoadCallback=void 0,i.animationPreload?(this.loaded=!1,this.loadInBackground()):this.loaded=!0}var n=i(10);o.prototype.isLoaded=function(){return this.loaded},o.prototype.getLoadedProgress=function(){for(var t=this.values.length,e=0;this.dataPoints[e];)e++;return Math.round(e/t*100)},o.prototype.getLabel=function(){return this.graph.filterLabel},o.prototype.getColumn=function(){return this.column},o.prototype.getSelectedValue=function(){return void 0===this.index?void 0:this.values[this.index]},o.prototype.getValues=function(){return this.values},o.prototype.getValue=function(t){if(t>=this.values.length)throw"Error: index out of range";return this.values[t]},o.prototype._getDataPoints=function(t){if(void 0===t&&(t=this.index),void 0===t)return[];var e;if(this.dataPoints[t])e=this.dataPoints[t];else{var i={};i.column=this.column,i.value=this.values[t];var o=new n(this.data,{filter:function(t){return t[i.column]==i.value}}).get();e=this.graph._getDataPoints(o),this.dataPoints[t]=e}return e},o.prototype.setOnLoadCallback=function(t){this.onLoadCallback=t},o.prototype.selectValue=function(t){if(t>=this.values.length)throw"Error: index out of range";this.index=t,this.value=this.values[t]},o.prototype.loadInBackground=function(t){void 0===t&&(t=0);var e=this.graph.frame;if(t0&&(t--,this.setIndex(t))},o.prototype.next=function(){var t=this.getIndex();t0?this.setIndex(0):this.index=void 0},o.prototype.setIndex=function(t){if(!(to&&(o=0),o>this.values.length-1&&(o=this.values.length-1),o},o.prototype.indexToLeft=function(t){var e=parseFloat(this.frame.bar.style.width)-this.frame.slide.clientWidth-10,i=t/(this.values.length-1)*e,o=i+3;return o},o.prototype._onMouseMove=function(t){var e=t.clientX-this.startClientX,i=this.startSlideX+e,o=this.leftToIndex(i);this.setIndex(o),n.preventDefault()},o.prototype._onMouseUp=function(t){this.frame.style.cursor="auto",n.removeEventListener(document,"mousemove",this.onmousemove),n.removeEventListener(document,"mouseup",this.onmouseup),n.preventDefault()},t.exports=o},function(t,e){function i(t,e,i,o){this._start=0,this._end=0,this._step=1,this.prettyStep=!0,this.precision=5,this._current=0,this.setRange(t,e,i,o)}i.prototype.setRange=function(t,e,i,o){this._start=t?t:0,this._end=e?e:0,this.setStep(i,o)},i.prototype.setStep=function(t,e){void 0===t||0>=t||(void 0!==e&&(this.prettyStep=e),this.prettyStep===!0?this._step=i.calculatePrettyStep(t):this._step=t)},i.calculatePrettyStep=function(t){var e=function(t){return Math.log(t)/Math.LN10},i=Math.pow(10,Math.round(e(t))),o=2*Math.pow(10,Math.round(e(t/2))),n=5*Math.pow(10,Math.round(e(t/5))),s=i;return Math.abs(o-t)<=Math.abs(s-t)&&(s=o),Math.abs(n-t)<=Math.abs(s-t)&&(s=n),0>=s&&(s=1),s},i.prototype.getCurrent=function(){return parseFloat(this._current.toPrecision(this.precision))},i.prototype.getStep=function(){return this._step},i.prototype.start=function(){this._current=this._start-this._start%this._step},i.prototype.next=function(){this._current+=this._step},i.prototype.end=function(){return this._current>this._end},t.exports=i},function(t,e,i){function o(t,e,i,d){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");if(!(Array.isArray(i)||i instanceof r||i instanceof a)&&i instanceof Object){var c=d;d=i,i=c}var f=this;this.defaultOptions={start:null,end:null,autoResize:!0,throttleRedraw:0,orientation:{axis:"bottom",item:"bottom"},moment:n,width:null,height:null,maxHeight:null,minHeight:null},this.options=s.deepExtend({},this.defaultOptions),this._create(t),this.components=[],this.body={dom:this.dom,domProps:this.props,emitter:{on:this.on.bind(this),off:this.off.bind(this),emit:this.emit.bind(this)},hiddenDates:[],util:{getScale:function(){return f.timeAxis.step.scale},getStep:function(){return f.timeAxis.step.step},toScreen:f._toScreen.bind(f),toGlobalScreen:f._toGlobalScreen.bind(f),toTime:f._toTime.bind(f),toGlobalTime:f._toGlobalTime.bind(f)}},this.range=new h(this.body),this.components.push(this.range),this.body.range=this.range,this.timeAxis=new l(this.body),this.timeAxis2=null,this.components.push(this.timeAxis),this.currentTime=new u(this.body),this.components.push(this.currentTime),this.itemSet=new p(this.body),this.components.push(this.itemSet),this.itemsData=null,this.groupsData=null,this.on("tap",function(t){f.emit("click",f.getEventProperties(t))}),this.on("doubletap",function(t){f.emit("doubleClick",f.getEventProperties(t))}),this.dom.root.oncontextmenu=function(t){f.emit("contextmenu",f.getEventProperties(t))},d&&this.setOptions(d),i&&this.setGroups(i),e?this.setItems(e):this._redraw()}var n=(i(12),i(20),i(2)),s=i(1),r=i(8),a=i(10),h=i(24),d=i(28),l=i(39),u=i(44),c=i(42),p=i(29),f=i(45),m=i(47)["default"],v=i(47).printStyle,g=i(48).allOptions,y=i(48).configureOptions;o.prototype=new d,o.prototype._createConfigurator=function(){return new f(this,this.dom.container,y)},o.prototype.redraw=function(){this.itemSet&&this.itemSet.markDirty({refreshItems:!0}),this._redraw()},o.prototype.setOptions=function(t){var e=m.validate(t,g);if(e===!0&&console.log("%cErrors have been found in the supplied options object.",v),d.prototype.setOptions.call(this,t),"type"in t&&t.type!==this.options.type){this.options.type=t.type;var i=this.itemsData;if(i){var o=this.getSelection();this.setItems(null),this.setItems(i),this.setSelection(o)}}},o.prototype.setItems=function(t){var e,i=null==this.itemsData;if(e=t?t instanceof r||t instanceof a?t:new r(t,{type:{start:"Date",end:"Date"}}):null,this.itemsData=e,this.itemSet&&this.itemSet.setItems(e),i)if(void 0!=this.options.start||void 0!=this.options.end){if(void 0==this.options.start||void 0==this.options.end)var o=this.getItemRange();var n=void 0!=this.options.start?this.options.start:o.min,s=void 0!=this.options.end?this.options.end:o.max;this.setWindow(n,s,{animation:!1})}else this.fit({animation:!1})},o.prototype.setGroups=function(t){var e;e=t?t instanceof r||t instanceof a?t:new r(t):null,this.groupsData=e,this.itemSet.setGroups(e)},o.prototype.setData=function(t){t&&t.groups&&this.setGroups(t.groups),t&&t.items&&this.setItems(t.items)},o.prototype.setSelection=function(t,e){this.itemSet&&this.itemSet.setSelection(t),e&&e.focus&&this.focus(t,e)},o.prototype.getSelection=function(){return this.itemSet&&this.itemSet.getSelection()||[]},o.prototype.focus=function(t,e){if(this.itemsData&&void 0!=t){var i=Array.isArray(t)?t:[t],o=this.itemsData.getDataSet().get(i,{type:{start:"Date",end:"Date"}}),n=null,s=null;if(o.forEach(function(t){var e=t.start.valueOf(),i="end"in t?t.end.valueOf():t.start.valueOf();(null===n||n>e)&&(n=e),(null===s||i>s)&&(s=i)}),null!==n&&null!==s){var r=(n+s)/2,a=Math.max(this.range.end-this.range.start,1.1*(s-n)),h=e&&void 0!==e.animation?e.animation:!0;this.range.setRange(r-a/2,r+a/2,h)}}},o.prototype.fit=function(t){var e=t&&void 0!==t.animation?t.animation:!0,i=this.getItemRange();this.range.setRange(i.min,i.max,e)},o.prototype.getItemRange=function(){var t=this,e=this.getDataRange(),i=e.min,o=e.max,n=null,r=null;if(null!=i&&null!=o){var a,h,d,l,u;!function(){var e=function(t){return s.convert(t.data.start,"Date").valueOf()},c=function(t){var e=void 0!=t.data.end?t.data.end:t.data.start;return s.convert(e,"Date").valueOf()};a=o-i,0>=a&&(a=10),h=a/t.props.center.width,s.forEach(t.itemSet.items,function(t){t.show();var s=e(t),a=c(t),d=new Date(s-(t.getWidthLeft()+10)*h),l=new Date(a+(t.getWidthRight()+10)*h);i>d&&(i=d,n=t),l>o&&(o=l,r=t)}.bind(t)),n&&r&&(d=n.getWidthLeft()+10,l=r.getWidthRight()+10,u=t.props.center.width-d-l,u>0&&(i=e(n)-d*a/u,o=c(r)+l*a/u))}()}return{min:null!=i?new Date(i):null,max:null!=o?new Date(o):null}},o.prototype.getDataRange=function(){var t=null,e=null,i=this.itemsData&&this.itemsData.getDataSet();return i&&i.forEach(function(i){var o=s.convert(i.start,"Date").valueOf(),n=s.convert(void 0!=i.end?i.end:i.start,"Date").valueOf();(null===t||t>o)&&(t=o),(null===e||n>e)&&(e=o)}),{min:null!=t?new Date(t):null,max:null!=e?new Date(e):null}},o.prototype.getEventProperties=function(t){var e=t.center?t.center.x:t.clientX,i=t.center?t.center.y:t.clientY,o=e-s.getAbsoluteLeft(this.dom.centerContainer),n=i-s.getAbsoluteTop(this.dom.centerContainer),r=this.itemSet.itemFromTarget(t),a=this.itemSet.groupFromTarget(t),h=c.customTimeFromTarget(t),d=this.itemSet.options.snap||null,l=this.body.util.getScale(),u=this.body.util.getStep(),p=this._toTime(o),f=d?d(p,l,u):p,m=s.getTarget(t),v=null;return null!=r?v="item":null!=h?v="custom-time":s.hasParent(m,this.timeAxis.dom.foreground)?v="axis":this.timeAxis2&&s.hasParent(m,this.timeAxis2.dom.foreground)?v="axis":s.hasParent(m,this.itemSet.dom.labelSet)?v="group-label":s.hasParent(m,this.currentTime.bar)?v="current-time":s.hasParent(m,this.dom.center)&&(v="background"),{event:t,item:r?r.id:null,group:a?a.groupId:null,what:v,pageX:t.srcEvent?t.srcEvent.pageX:t.pageX,pageY:t.srcEvent?t.srcEvent.pageY:t.pageY,x:o,y:n,time:p,snappedTime:f}},t.exports=o},function(t,e,i){if("undefined"!=typeof window){var o=i(21),n=window.Hammer||i(22);t.exports=o(n,{preventDefault:"mouse"})}else t.exports=function(){throw Error("hammer.js is only available in a browser, not in node.js.")}},function(t,e,i){var o,n,s;!function(i){n=[],o=i,s="function"==typeof o?o.apply(e,n):o,!(void 0!==s&&(t.exports=s))}(function(){var t=null;return function e(i,o){function n(t){return t.match(/[^ ]+/g)}function s(e){if("hammer.input"!==e.type){if(e.srcEvent._handled||(e.srcEvent._handled={}),e.srcEvent._handled[e.type])return;e.srcEvent._handled[e.type]=!0}var i=!1;e.stopPropagation=function(){i=!0},e.firstTarget=t;for(var o=t;o&&!i;){var n=o.hammer&&o.hammer._handlers[e.type];if(n)for(var s=0;s0?d._handlers[t]=o:(i.off(t,s),delete d._handlers[t]))}),d},d.emit=function(e,o){t=o.target,i.emit(e,o)},d.destroy=function(){delete i.element.hammer,d._handlers={},i.destroy()},d}})},function(t,e,i){var o;!function(n,s,r,a){function h(t,e,i){return setTimeout(f(t,i),e)}function d(t,e,i){return Array.isArray(t)?(l(t,i[e],i),!0):!1}function l(t,e,i){var o;if(t)if(t.forEach)t.forEach(e,i);else if(t.length!==a)for(o=0;o-1}function _(t){return t.trim().split(/\s+/g)}function x(t,e,i){if(t.indexOf&&!i)return t.indexOf(e);for(var o=0;oi[e]}):o.sort()),o}function D(t,e){for(var i,o,n=e[0].toUpperCase()+e.slice(1),s=0;s1&&!i.firstMultiple?i.firstMultiple=N(e):1===n&&(i.firstMultiple=!1);var s=i.firstInput,r=i.firstMultiple,a=r?r.center:s.center,h=e.center=L(o);e.timeStamp=gt(),e.deltaTime=e.timeStamp-s.timeStamp,e.angle=F(a,h),e.distance=R(a,h),I(i,e),e.offsetDirection=B(e.deltaX,e.deltaY),e.scale=r?H(r.pointers,o):1,e.rotation=r?j(r.pointers,o):0,z(i,e);var d=t.element;b(e.srcEvent.target,d)&&(d=e.srcEvent.target),e.target=d}function I(t,e){var i=e.center,o=t.offsetDelta||{},n=t.prevDelta||{},s=t.prevInput||{};(e.eventType===Tt||s.eventType===St)&&(n=t.prevDelta={x:s.deltaX||0,y:s.deltaY||0},o=t.offsetDelta={x:i.x,y:i.y}),e.deltaX=n.x+(i.x-o.x),e.deltaY=n.y+(i.y-o.y)}function z(t,e){var i,o,n,s,r=t.lastInterval||e,h=e.timeStamp-r.timeStamp;if(e.eventType!=Pt&&(h>Ct||r.velocity===a)){var d=r.deltaX-e.deltaX,l=r.deltaY-e.deltaY,u=A(h,d,l);o=u.x,n=u.y,i=vt(u.x)>vt(u.y)?u.x:u.y,s=B(d,l),t.lastInterval=e}else i=r.velocity,o=r.velocityX,n=r.velocityY,s=r.direction;e.velocity=i,e.velocityX=o,e.velocityY=n,e.direction=s}function N(t){for(var e=[],i=0;in;)i+=t[n].clientX,o+=t[n].clientY,n++;return{x:mt(i/e),y:mt(o/e)}}function A(t,e,i){return{x:e/t||0,y:i/t||0}}function B(t,e){return t===e?It:vt(t)>=vt(e)?t>0?zt:Nt:e>0?Lt:At}function R(t,e,i){i||(i=jt);var o=e[i[0]]-t[i[0]],n=e[i[1]]-t[i[1]];return Math.sqrt(o*o+n*n)}function F(t,e,i){i||(i=jt);var o=e[i[0]]-t[i[0]],n=e[i[1]]-t[i[1]];return 180*Math.atan2(n,o)/Math.PI}function j(t,e){return F(e[1],e[0],Ht)-F(t[1],t[0],Ht)}function H(t,e){return R(e[0],e[1],Ht)/R(t[0],t[1],Ht)}function W(){this.evEl=Yt,this.evWin=Gt,this.allow=!0,this.pressed=!1,T.apply(this,arguments)}function Y(){this.evEl=qt,this.evWin=Xt,T.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}function G(){this.evTarget=Kt,this.evWin=Jt,this.started=!1,T.apply(this,arguments)}function U(t,e){var i=k(t.touches),o=k(t.changedTouches);return e&(St|Pt)&&(i=O(i.concat(o),"identifier",!0)),[i,o]}function V(){this.evTarget=$t,this.targetIds={},T.apply(this,arguments)}function q(t,e){var i=k(t.touches),o=this.targetIds;if(e&(Tt|Et)&&1===i.length)return o[i[0].identifier]=!0,[i,i];var n,s,r=k(t.changedTouches),a=[],h=this.target;if(s=i.filter(function(t){return b(t.target,h)}),e===Tt)for(n=0;na&&(e.push(t),a=e.length-1):n&(St|Pt)&&(i=!0),0>a||(e[a]=t,this.callback(this.manager,n,{pointers:e,changedPointers:[t],pointerType:s,srcEvent:t}),i&&e.splice(a,1))}});var Zt={touchstart:Tt,touchmove:Et,touchend:St,touchcancel:Pt},Kt="touchstart",Jt="touchstart touchmove touchend touchcancel";p(G,T,{handler:function(t){var e=Zt[t.type];if(e===Tt&&(this.started=!0),this.started){var i=U.call(this,t,e);e&(St|Pt)&&i[0].length-i[1].length===0&&(this.started=!1),this.callback(this.manager,e,{pointers:i[0],changedPointers:i[1],pointerType:kt,srcEvent:t})}}});var Qt={touchstart:Tt,touchmove:Et,touchend:St,touchcancel:Pt},$t="touchstart touchmove touchend touchcancel"; -p(V,T,{handler:function(t){var e=Qt[t.type],i=q.call(this,t,e);i&&this.callback(this.manager,e,{pointers:i[0],changedPointers:i[1],pointerType:kt,srcEvent:t})}}),p(X,T,{handler:function(t,e,i){var o=i.pointerType==kt,n=i.pointerType==Dt;if(o)this.mouse.allow=!1;else if(n&&!this.mouse.allow)return;e&(St|Pt)&&(this.mouse.allow=!0),this.callback(t,e,i)},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var te=D(pt.style,"touchAction"),ee=te!==a,ie="compute",oe="auto",ne="manipulation",se="none",re="pan-x",ae="pan-y";Z.prototype={set:function(t){t==ie&&(t=this.compute()),ee&&(this.manager.element.style[te]=t),this.actions=t.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var t=[];return l(this.manager.recognizers,function(e){m(e.options.enable,[e])&&(t=t.concat(e.getTouchAction()))}),K(t.join(" "))},preventDefaults:function(t){if(!ee){var e=t.srcEvent,i=t.offsetDirection;if(this.manager.session.prevented)return void e.preventDefault();var o=this.actions,n=w(o,se),s=w(o,ae),r=w(o,re);return n||s&&i&Bt||r&&i&Rt?this.preventSrc(e):void 0}},preventSrc:function(t){this.manager.session.prevented=!0,t.preventDefault()}};var he=1,de=2,le=4,ue=8,ce=ue,pe=16,fe=32;J.prototype={defaults:{},set:function(t){return u(this.options,t),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(t){if(d(t,"recognizeWith",this))return this;var e=this.simultaneous;return t=tt(t,this),e[t.id]||(e[t.id]=t,t.recognizeWith(this)),this},dropRecognizeWith:function(t){return d(t,"dropRecognizeWith",this)?this:(t=tt(t,this),delete this.simultaneous[t.id],this)},requireFailure:function(t){if(d(t,"requireFailure",this))return this;var e=this.requireFail;return t=tt(t,this),-1===x(e,t)&&(e.push(t),t.requireFailure(this)),this},dropRequireFailure:function(t){if(d(t,"dropRequireFailure",this))return this;t=tt(t,this);var e=x(this.requireFail,t);return e>-1&&this.requireFail.splice(e,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(t){return!!this.simultaneous[t.id]},emit:function(t){function e(e){i.manager.emit(i.options.event+(e?Q(o):""),t)}var i=this,o=this.state;ue>o&&e(!0),e(),o>=ue&&e(!0)},tryEmit:function(t){return this.canEmit()?this.emit(t):void(this.state=fe)},canEmit:function(){for(var t=0;ts?zt:Nt,i=s!=this.pX,o=Math.abs(t.deltaX)):(n=0===r?It:0>r?Lt:At,i=r!=this.pY,o=Math.abs(t.deltaY))),t.direction=n,i&&o>e.threshold&&n&e.direction},attrTest:function(t){return et.prototype.attrTest.call(this,t)&&(this.state&de||!(this.state&de)&&this.directionTest(t))},emit:function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=$(t.direction);e&&this.manager.emit(this.options.event+e,t),this._super.emit.call(this,t)}}),p(ot,et,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[se]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||this.state&de)},emit:function(t){if(this._super.emit.call(this,t),1!==t.scale){var e=t.scale<1?"in":"out";this.manager.emit(this.options.event+e,t)}}}),p(nt,J,{defaults:{event:"press",pointers:1,time:500,threshold:5},getTouchAction:function(){return[oe]},process:function(t){var e=this.options,i=t.pointers.length===e.pointers,o=t.distancee.time;if(this._input=t,!o||!i||t.eventType&(St|Pt)&&!n)this.reset();else if(t.eventType&Tt)this.reset(),this._timer=h(function(){this.state=ce,this.tryEmit()},e.time,this);else if(t.eventType&St)return ce;return fe},reset:function(){clearTimeout(this._timer)},emit:function(t){this.state===ce&&(t&&t.eventType&St?this.manager.emit(this.options.event+"up",t):(this._input.timeStamp=gt(),this.manager.emit(this.options.event,this._input)))}}),p(st,et,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[se]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.rotation)>this.options.threshold||this.state&de)}}),p(rt,et,{defaults:{event:"swipe",threshold:10,velocity:.65,direction:Bt|Rt,pointers:1},getTouchAction:function(){return it.prototype.getTouchAction.call(this)},attrTest:function(t){var e,i=this.options.direction;return i&(Bt|Rt)?e=t.velocity:i&Bt?e=t.velocityX:i&Rt&&(e=t.velocityY),this._super.attrTest.call(this,t)&&i&t.direction&&t.distance>this.options.threshold&&vt(e)>this.options.velocity&&t.eventType&St},emit:function(t){var e=$(t.direction);e&&this.manager.emit(this.options.event+e,t),this.manager.emit(this.options.event,t)}}),p(at,J,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:2,posThreshold:10},getTouchAction:function(){return[ne]},process:function(t){var e=this.options,i=t.pointers.length===e.pointers,o=t.distanceu,c=r||null===n?n:h+(n-h)*i,v=r||null===s?s:l+(s-l)*i;g=a._applyRange(c,v),d.updateHiddenDates(a.options.moment,a.body,a.options.hiddenDates),m=m||g,g&&a.body.emitter.emit("rangechange",{start:new Date(a.start),end:new Date(a.end),byUser:o}),r?m&&a.body.emitter.emit("rangechanged",{start:new Date(a.start),end:new Date(a.end),byUser:o}):a.animationTimer=setTimeout(b,20)}};return v()}var g=this._applyRange(n,s);if(d.updateHiddenDates(this.options.moment,this.body,this.options.hiddenDates),g){var y={start:new Date(this.start),end:new Date(this.end),byUser:o};this.body.emitter.emit("rangechange",y),this.body.emitter.emit("rangechanged",y)}},o.prototype._cancelAnimation=function(){this.animationTimer&&(clearTimeout(this.animationTimer),this.animationTimer=null)},o.prototype._applyRange=function(t,e){var i,o=null!=t?r.convert(t,"Date").valueOf():this.start,n=null!=e?r.convert(e,"Date").valueOf():this.end,s=null!=this.options.max?r.convert(this.options.max,"Date").valueOf():null,a=null!=this.options.min?r.convert(this.options.min,"Date").valueOf():null;if(isNaN(o)||null===o)throw new Error('Invalid start "'+t+'"');if(isNaN(n)||null===n)throw new Error('Invalid end "'+e+'"');if(o>n&&(n=o),null!==a&&a>o&&(i=a-o,o+=i,n+=i,null!=s&&n>s&&(n=s)),null!==s&&n>s&&(i=n-s,o-=i,n-=i,null!=a&&a>o&&(o=a)),null!==this.options.zoomMin){var h=parseFloat(this.options.zoomMin);0>h&&(h=0),h>n-o&&(this.end-this.start===h&&o>this.start&&nd&&(d=0),n-o>d&&(this.end-this.start===d&&othis.end?(o=this.start,n=this.end):(i=n-o-d,o+=i/2,n-=i/2))}var l=this.start!=o||this.end!=n;return o>=this.start&&o<=this.end||n>=this.start&&n<=this.end||this.start>=o&&this.start<=n||this.end>=o&&this.end<=n||this.body.emitter.emit("checkRangedItems"),this.start=o,this.end=n,l},o.prototype.getRange=function(){return{start:this.start,end:this.end}},o.prototype.conversion=function(t,e){return o.conversion(this.start,this.end,t,e)},o.conversion=function(t,e,i,o){return void 0===o&&(o=0),0!=i&&e-t!=0?{offset:t,scale:i/(e-t-o)}:{offset:0,scale:1}},o.prototype._onDragStart=function(t){this.deltaDifference=0,this.previousDelta=0,this.options.moveable&&this._isInsideRange(t)&&this.props.touch.allowDragging&&(this.props.touch.start=this.start,this.props.touch.end=this.end,this.props.touch.dragging=!0,this.body.dom.root&&(this.body.dom.root.style.cursor="move"))},o.prototype._onDrag=function(t){if(this.props.touch.dragging&&this.options.moveable&&this.props.touch.allowDragging){var e=this.options.direction;n(e);var i="horizontal"==e?t.deltaX:t.deltaY;i-=this.deltaDifference;var o=this.props.touch.end-this.props.touch.start,s=d.getHiddenDurationBetween(this.body.hiddenDates,this.start,this.end);o-=s;var r="horizontal"==e?this.body.domProps.center.width:this.body.domProps.center.height,a=-i/r*o,h=this.props.touch.start+a,l=this.props.touch.end+a,u=d.snapAwayFromHidden(this.body.hiddenDates,h,this.previousDelta-i,!0),c=d.snapAwayFromHidden(this.body.hiddenDates,l,this.previousDelta-i,!0);if(u!=h||c!=l)return this.deltaDifference+=i,this.props.touch.start=u,this.props.touch.end=c,void this._onDrag(t);this.previousDelta=i,this._applyRange(h,l),this.body.emitter.emit("rangechange",{start:new Date(this.start),end:new Date(this.end),byUser:!0})}},o.prototype._onDragEnd=function(t){this.props.touch.dragging&&this.options.moveable&&this.props.touch.allowDragging&&(this.props.touch.dragging=!1,this.body.dom.root&&(this.body.dom.root.style.cursor="auto"),this.body.emitter.emit("rangechanged",{start:new Date(this.start),end:new Date(this.end),byUser:!0}))},o.prototype._onMouseWheel=function(t){if(this.options.zoomable&&this.options.moveable&&this._isInsideRange(t)&&(!this.options.zoomKey||t[this.options.zoomKey])){var e=0;if(t.wheelDelta?e=t.wheelDelta/120:t.detail&&(e=-t.detail/3),e){var i;i=0>e?1-e/5:1/(1+e/5);var o=s({x:t.clientX,y:t.clientY},this.body.dom.center),n=this._pointerToDate(o);this.zoom(i,n,e)}t.preventDefault()}},o.prototype._onTouch=function(t){this.props.touch.start=this.start,this.props.touch.end=this.end,this.props.touch.allowDragging=!0,this.props.touch.center=null,this.scaleOffset=0,this.deltaDifference=0},o.prototype._onPinch=function(t){if(this.options.zoomable&&this.options.moveable){this.props.touch.allowDragging=!1,this.props.touch.center||(this.props.touch.center=s(t.center,this.body.dom.center));var e=1/(t.scale+this.scaleOffset),i=this._pointerToDate(this.props.touch.center),o=d.getHiddenDurationBetween(this.body.hiddenDates,this.start,this.end),n=d.getHiddenDurationBefore(this.options.moment,this.body.hiddenDates,this,i),r=o-n,a=i-n+(this.props.touch.start-(i-n))*e,h=i+r+(this.props.touch.end-(i+r))*e;this.startToFront=0>=1-e,this.endToFront=0>=e-1;var l=d.snapAwayFromHidden(this.body.hiddenDates,a,1-e,!0),u=d.snapAwayFromHidden(this.body.hiddenDates,h,e-1,!0);(l!=a||u!=h)&&(this.props.touch.start=l,this.props.touch.end=u,this.scaleOffset=1-t.scale,a=l,h=u),this.setRange(a,h,!1,!0),this.startToFront=!1,this.endToFront=!0}},o.prototype._isInsideRange=function(t){var e=t.center?t.center.x:t.clientX,i=e-r.getAbsoluteLeft(this.body.dom.centerContainer),o=this.body.util.toTime(i);return o>=this.start&&o<=this.end},o.prototype._pointerToDate=function(t){var e,i=this.options.direction;if(n(i),"horizontal"==i)return this.body.util.toTime(t.x).valueOf();var o=this.body.domProps.center.height;return e=this.conversion(o),t.y/e.scale+e.offset},o.prototype.zoom=function(t,e,i){null==e&&(e=(this.start+this.end)/2);var o=d.getHiddenDurationBetween(this.body.hiddenDates,this.start,this.end),n=d.getHiddenDurationBefore(this.options.moment,this.body.hiddenDates,this,e),s=o-n,r=e-n+(this.start-(e-n))*t,a=e+s+(this.end-(e+s))*t;this.startToFront=i>0?!1:!0,this.endToFront=-i>0?!1:!0;var h=d.snapAwayFromHidden(this.body.hiddenDates,r,i,!0),l=d.snapAwayFromHidden(this.body.hiddenDates,a,-i,!0);(h!=r||l!=a)&&(r=h,a=l),this.setRange(r,a,!1,!0),this.startToFront=!1,this.endToFront=!0},o.prototype.move=function(t){var e=this.end-this.start,i=this.start+e*t,o=this.end+e*t;this.start=i,this.end=o},o.prototype.moveTo=function(t){var e=(this.start+this.end)/2,i=e-t,o=this.start-i,n=this.end-i;this.setRange(o,n)},t.exports=o},function(t,e,i){i(20);e.onTouch=function(t,e){e.inputHandler=function(t){t.isFirst&&!o&&(e(t),o=!0,setTimeout(function(){o=!1},0))},t.on("hammer.input",e.inputHandler)};var o=!1;e.onRelease=function(t,e){return e.inputHandler=function(t){t.isFinal&&!n&&(e(t),n=!0,setTimeout(function(){n=!1},0))},t.on("hammer.input",e.inputHandler)};var n=!1;e.offTouch=function(t,e){t.off("hammer.input",e.inputHandler)},e.offRelease=e.offTouch},function(t,e){function i(t,e){this.options=null,this.props=null}i.prototype.setOptions=function(t){t&&util.extend(this.options,t)},i.prototype.redraw=function(){return!1},i.prototype.destroy=function(){},i.prototype._isResized=function(){var t=this.props._previousWidth!==this.props.width||this.props._previousHeight!==this.props.height;return this.props._previousWidth=this.props.width,this.props._previousHeight=this.props.height,t},t.exports=i},function(t,e){e.convertHiddenOptions=function(t,i,o){if(o&&!Array.isArray(o))return e.convertHiddenOptions(t,i,[o]);if(i.hiddenDates=[],o&&1==Array.isArray(o)){for(var n=0;n=4*a){var c=0,p=s.clone();switch(o[h].repeat){case"daily":d.day()!=l.day()&&(c=1),d.dayOfYear(n.dayOfYear()),d.year(n.year()),d.subtract(7,"days"),l.dayOfYear(n.dayOfYear()),l.year(n.year()),l.subtract(7-c,"days"),p.add(1,"weeks");break;case"weekly":var f=l.diff(d,"days"),m=d.day();d.date(n.date()),d.month(n.month()),d.year(n.year()),l=d.clone(),d.day(m),l.day(m),l.add(f,"days"),d.subtract(1,"weeks"),l.subtract(1,"weeks"),p.add(1,"weeks");break;case"monthly":d.month()!=l.month()&&(c=1),d.month(n.month()),d.year(n.year()),d.subtract(1,"months"),l.month(n.month()),l.year(n.year()),l.subtract(1,"months"),l.add(c,"months"),p.add(1,"months");break;case"yearly":d.year()!=l.year()&&(c=1),d.year(n.year()),d.subtract(1,"years"),l.year(n.year()),l.subtract(1,"years"),l.add(c,"years"),p.add(1,"years");break;default:return void console.log("Wrong repeat format, allowed are: daily, weekly, monthly, yearly. Given:",o[h].repeat)}for(;p>d;)switch(i.hiddenDates.push({start:d.valueOf(),end:l.valueOf()}),o[h].repeat){case"daily":d.add(1,"days"),l.add(1,"days");break;case"weekly":d.add(1,"weeks"),l.add(1,"weeks");break;case"monthly":d.add(1,"months"),l.add(1,"months");break;case"yearly":d.add(1,"y"),l.add(1,"y");break;default:return void console.log("Wrong repeat format, allowed are: daily, weekly, monthly, yearly. Given:",o[h].repeat)}i.hiddenDates.push({start:d.valueOf(),end:l.valueOf()})}}e.removeDuplicates(i);var v=e.isHidden(i.range.start,i.hiddenDates),g=e.isHidden(i.range.end,i.hiddenDates),y=i.range.start,b=i.range.end;1==v.hidden&&(y=1==i.range.startToFront?v.startDate-1:v.endDate+1),1==g.hidden&&(b=1==i.range.endToFront?g.startDate-1:g.endDate+1),(1==v.hidden||1==g.hidden)&&i.range._applyRange(y,b)}},e.removeDuplicates=function(t){for(var e=t.hiddenDates,i=[],o=0;o=e[o].start&&e[n].end<=e[o].end?e[n].remove=!0:e[n].start>=e[o].start&&e[n].start<=e[o].end?(e[o].end=e[n].end,e[n].remove=!0):e[n].end>=e[o].start&&e[n].end<=e[o].end&&(e[o].start=e[n].start,e[n].remove=!0));for(var o=0;o=r&&a>n){o=!0;break}}if(1==o&&n=e&&i>r&&(o+=r-s)}return o},e.correctTimeForHidden=function(t,i,o,n){return n=t(n).toDate().valueOf(),n-=e.getHiddenDurationBefore(t,i,o,n)},e.getHiddenDurationBefore=function(t,e,i,o){var n=0;o=t(o).toDate().valueOf();for(var s=0;s=i.start&&a=a&&(n+=a-r)}return n},e.getAccumulatedHiddenDuration=function(t,e,i){for(var o=0,n=0,s=e.start,r=0;r=e.start&&h=i)break;o+=h-a}}return o},e.snapAwayFromHidden=function(t,i,o,n){var s=e.isHidden(i,t);return 1==s.hidden?0>o?1==n?s.startDate-(s.endDate-i)-1:s.startDate-1:1==n?s.endDate+(i-s.startDate)+1:s.endDate+1:i},e.isHidden=function(t,e){for(var i=0;i=o&&n>t)return{hidden:!0,startDate:o,endDate:n}}return{hidden:!1,startDate:o,endDate:n}}},function(t,e,i){function o(){}var n=i(12),s=i(20),r=i(25),a=i(1),h=(i(8),i(10),i(24),i(29),i(39)),d=i(40),l=i(27),u=i(42);n(o.prototype),o.prototype._create=function(t){function e(t){i.isActive()&&i.emit("mousewheel",t)}this.dom={},this.dom.container=t,this.dom.root=document.createElement("div"),this.dom.background=document.createElement("div"),this.dom.backgroundVertical=document.createElement("div"),this.dom.backgroundHorizontal=document.createElement("div"),this.dom.centerContainer=document.createElement("div"),this.dom.leftContainer=document.createElement("div"),this.dom.rightContainer=document.createElement("div"),this.dom.center=document.createElement("div"),this.dom.left=document.createElement("div"),this.dom.right=document.createElement("div"),this.dom.top=document.createElement("div"),this.dom.bottom=document.createElement("div"),this.dom.shadowTop=document.createElement("div"),this.dom.shadowBottom=document.createElement("div"),this.dom.shadowTopLeft=document.createElement("div"),this.dom.shadowBottomLeft=document.createElement("div"),this.dom.shadowTopRight=document.createElement("div"),this.dom.shadowBottomRight=document.createElement("div"),this.dom.root.className="vis-timeline",this.dom.background.className="vis-panel vis-background",this.dom.backgroundVertical.className="vis-panel vis-background vis-vertical",this.dom.backgroundHorizontal.className="vis-panel vis-background vis-horizontal",this.dom.centerContainer.className="vis-panel vis-center",this.dom.leftContainer.className="vis-panel vis-left",this.dom.rightContainer.className="vis-panel vis-right",this.dom.top.className="vis-panel vis-top",this.dom.bottom.className="vis-panel vis-bottom",this.dom.left.className="vis-content",this.dom.center.className="vis-content",this.dom.right.className="vis-content",this.dom.shadowTop.className="vis-shadow vis-top",this.dom.shadowBottom.className="vis-shadow vis-bottom",this.dom.shadowTopLeft.className="vis-shadow vis-top",this.dom.shadowBottomLeft.className="vis-shadow vis-bottom",this.dom.shadowTopRight.className="vis-shadow vis-top",this.dom.shadowBottomRight.className="vis-shadow vis-bottom",this.dom.root.appendChild(this.dom.background),this.dom.root.appendChild(this.dom.backgroundVertical),this.dom.root.appendChild(this.dom.backgroundHorizontal),this.dom.root.appendChild(this.dom.centerContainer),this.dom.root.appendChild(this.dom.leftContainer),this.dom.root.appendChild(this.dom.rightContainer),this.dom.root.appendChild(this.dom.top),this.dom.root.appendChild(this.dom.bottom),this.dom.centerContainer.appendChild(this.dom.center),this.dom.leftContainer.appendChild(this.dom.left),this.dom.rightContainer.appendChild(this.dom.right),this.dom.centerContainer.appendChild(this.dom.shadowTop),this.dom.centerContainer.appendChild(this.dom.shadowBottom),this.dom.leftContainer.appendChild(this.dom.shadowTopLeft),this.dom.leftContainer.appendChild(this.dom.shadowBottomLeft),this.dom.rightContainer.appendChild(this.dom.shadowTopRight),this.dom.rightContainer.appendChild(this.dom.shadowBottomRight),this.on("rangechange",function(){this._redraw()}.bind(this)),this.on("touch",this._onTouch.bind(this)),this.on("pan",this._onDrag.bind(this));var i=this;this.on("change",function(t){t&&1==t.queue?i._redrawTimer||(i._redrawTimer=setTimeout(function(){i._redrawTimer=null,i._redraw()},0)):i._redraw()}),this.hammer=new s(this.dom.root),this.hammer.get("pinch").set({enable:!0}),this.hammer.get("pan").set({threshold:5,direction:30}),this.listeners={};var o=["tap","doubletap","press","pinch","pan","panstart","panmove","panend"];if(o.forEach(function(t){var e=function(e){i.isActive()&&i.emit(t,e)};i.hammer.on(t,e),i.listeners[t]=e}),r.onTouch(this.hammer,function(t){i.emit("touch",t)}.bind(this)),r.onRelease(this.hammer,function(t){i.emit("release",t)}.bind(this)),this.dom.root.addEventListener("mousewheel",e),this.dom.root.addEventListener("DOMMouseScroll",e),this.props={root:{},background:{},centerContainer:{},leftContainer:{},rightContainer:{},center:{},left:{},right:{},top:{},bottom:{},border:{},scrollTop:0,scrollTopMin:0},this.customTimes=[],this.touch={},this.redrawCount=0,!t)throw new Error("No container provided");t.appendChild(this.dom.root)},o.prototype.setOptions=function(t){if(t){var e=["width","height","minHeight","maxHeight","autoResize","start","end","clickToUse","dataAttributes","hiddenDates","locale","locales","moment","throttleRedraw"];if(a.selectiveExtend(e,this.options,t),"orientation"in t&&("string"==typeof t.orientation?this.options.orientation={item:t.orientation,axis:t.orientation}:"object"==typeof t.orientation&&("item"in t.orientation&&(this.options.orientation.item=t.orientation.item),"axis"in t.orientation&&(this.options.orientation.axis=t.orientation.axis))),"both"===this.options.orientation.axis){if(!this.timeAxis2){var i=this.timeAxis2=new h(this.body);i.setOptions=function(t){var e=t?a.extend({},t):{};e.orientation="top",h.prototype.setOptions.call(i,e)},this.components.push(i)}}else if(this.timeAxis2){var o=this.components.indexOf(this.timeAxis2);-1!==o&&this.components.splice(o,1),this.timeAxis2.destroy(),this.timeAxis2=null}if("function"==typeof t.drawPoints&&(t.drawPoints={onRender:t.drawPoints}),"hiddenDates"in this.options&&l.convertHiddenOptions(this.options.moment,this.body,this.options.hiddenDates),"clickToUse"in t&&(t.clickToUse?this.activator||(this.activator=new d(this.dom.root)):this.activator&&(this.activator.destroy(),delete this.activator)),"showCustomTime"in t)throw new Error("Option `showCustomTime` is deprecated. Create a custom time bar via timeline.addCustomTime(time [, id])");this._initAutoResize()}if(this.components.forEach(function(e){return e.setOptions(t)}),"configure"in t){this.configurator||(this.configurator=this._createConfigurator()),this.configurator.setOptions(t.configure);var n=a.deepExtend({},this.options);this.components.forEach(function(t){a.deepExtend(n,t.options)}),this.configurator.setModuleOptions({global:n})}this._origRedraw||(this._origRedraw=this._redraw.bind(this)),this._redraw=a.throttle(this._origRedraw,this.options.throttleRedraw),this._redraw()},o.prototype.isActive=function(){return!this.activator||this.activator.active},o.prototype.destroy=function(){this.setItems(null),this.setGroups(null),this.off(),this._stopAutoResize(),this.dom.root.parentNode&&this.dom.root.parentNode.removeChild(this.dom.root),this.dom=null,this.activator&&(this.activator.destroy(),delete this.activator);for(var t in this.listeners)this.listeners.hasOwnProperty(t)&&delete this.listeners[t];this.listeners=null,this.hammer=null,this.components.forEach(function(t){return t.destroy()}),this.body=null},o.prototype.setCustomTime=function(t,e){var i=this.customTimes.filter(function(t){return e===t.options.id});if(0===i.length)throw new Error("No custom time bar found with id "+JSON.stringify(e));i.length>0&&i[0].setCustomTime(t)},o.prototype.getCustomTime=function(t){var e=this.customTimes.filter(function(e){return e.options.id===t});if(0===e.length)throw new Error("No custom time bar found with id "+JSON.stringify(t));return e[0].getCustomTime()},o.prototype.setCustomTimeTitle=function(t,e){var i=this.customTimes.filter(function(t){return t.options.id===e});if(0===i.length)throw new Error("No custom time bar found with id "+JSON.stringify(e));return i.length>0?i[0].setCustomTitle(t):void 0},o.prototype.getEventProperties=function(t){return{event:t}},o.prototype.addCustomTime=function(t,e){var i=void 0!==t?a.convert(t,"Date").valueOf():new Date,o=this.customTimes.some(function(t){return t.options.id===e});if(o)throw new Error("A custom time with id "+JSON.stringify(e)+" already exists");var n=new u(this.body,a.extend({},this.options,{time:i,id:e}));return this.customTimes.push(n),this.components.push(n),this._redraw(),e},o.prototype.removeCustomTime=function(t){var e=this.customTimes.filter(function(e){return e.options.id===t});if(0===e.length)throw new Error("No custom time bar found with id "+JSON.stringify(t));e.forEach(function(t){this.customTimes.splice(this.customTimes.indexOf(t),1), -this.components.splice(this.components.indexOf(t),1),t.destroy()}.bind(this))},o.prototype.getVisibleItems=function(){return this.itemSet&&this.itemSet.getVisibleItems()||[]},o.prototype.fit=function(t){var e=this.getDataRange();if(null!==e.min||null!==e.max){var i=e.max-e.min,o=new Date(e.min.valueOf()-.01*i),n=new Date(e.max.valueOf()+.01*i),s=t&&void 0!==t.animation?t.animation:!0;this.range.setRange(o,n,s)}},o.prototype.getDataRange=function(){throw new Error("Cannot invoke abstract method getDataRange")},o.prototype.setWindow=function(t,e,i){var o;if(1==arguments.length){var n=arguments[0];o=void 0!==n.animation?n.animation:!0,this.range.setRange(n.start,n.end,o)}else o=i&&void 0!==i.animation?i.animation:!0,this.range.setRange(t,e,o)},o.prototype.moveTo=function(t,e){var i=this.range.end-this.range.start,o=a.convert(t,"Date").valueOf(),n=o-i/2,s=o+i/2,r=e&&void 0!==e.animation?e.animation:!0;this.range.setRange(n,s,r)},o.prototype.getWindow=function(){var t=this.range.getRange();return{start:new Date(t.start),end:new Date(t.end)}},o.prototype.redraw=function(){this._redraw()},o.prototype._redraw=function(){var t=!1,e=this.options,i=this.props,o=this.dom;if(o){l.updateHiddenDates(this.options.moment,this.body,this.options.hiddenDates),"top"==e.orientation?(a.addClassName(o.root,"vis-top"),a.removeClassName(o.root,"vis-bottom")):(a.removeClassName(o.root,"vis-top"),a.addClassName(o.root,"vis-bottom")),o.root.style.maxHeight=a.option.asSize(e.maxHeight,""),o.root.style.minHeight=a.option.asSize(e.minHeight,""),o.root.style.width=a.option.asSize(e.width,""),i.border.left=(o.centerContainer.offsetWidth-o.centerContainer.clientWidth)/2,i.border.right=i.border.left,i.border.top=(o.centerContainer.offsetHeight-o.centerContainer.clientHeight)/2,i.border.bottom=i.border.top;var n=o.root.offsetHeight-o.root.clientHeight,s=o.root.offsetWidth-o.root.clientWidth;0===o.centerContainer.clientHeight&&(i.border.left=i.border.top,i.border.right=i.border.left),0===o.root.clientHeight&&(s=n),i.center.height=o.center.offsetHeight,i.left.height=o.left.offsetHeight,i.right.height=o.right.offsetHeight,i.top.height=o.top.clientHeight||-i.border.top,i.bottom.height=o.bottom.clientHeight||-i.border.bottom;var r=Math.max(i.left.height,i.center.height,i.right.height),h=i.top.height+r+i.bottom.height+n+i.border.top+i.border.bottom;o.root.style.height=a.option.asSize(e.height,h+"px"),i.root.height=o.root.offsetHeight,i.background.height=i.root.height-n;var d=i.root.height-i.top.height-i.bottom.height-n;i.centerContainer.height=d,i.leftContainer.height=d,i.rightContainer.height=i.leftContainer.height,i.root.width=o.root.offsetWidth,i.background.width=i.root.width-s,i.left.width=o.leftContainer.clientWidth||-i.border.left,i.leftContainer.width=i.left.width,i.right.width=o.rightContainer.clientWidth||-i.border.right,i.rightContainer.width=i.right.width;var u=i.root.width-i.left.width-i.right.width-s;i.center.width=u,i.centerContainer.width=u,i.top.width=u,i.bottom.width=u,o.background.style.height=i.background.height+"px",o.backgroundVertical.style.height=i.background.height+"px",o.backgroundHorizontal.style.height=i.centerContainer.height+"px",o.centerContainer.style.height=i.centerContainer.height+"px",o.leftContainer.style.height=i.leftContainer.height+"px",o.rightContainer.style.height=i.rightContainer.height+"px",o.background.style.width=i.background.width+"px",o.backgroundVertical.style.width=i.centerContainer.width+"px",o.backgroundHorizontal.style.width=i.background.width+"px",o.centerContainer.style.width=i.center.width+"px",o.top.style.width=i.top.width+"px",o.bottom.style.width=i.bottom.width+"px",o.background.style.left="0",o.background.style.top="0",o.backgroundVertical.style.left=i.left.width+i.border.left+"px",o.backgroundVertical.style.top="0",o.backgroundHorizontal.style.left="0",o.backgroundHorizontal.style.top=i.top.height+"px",o.centerContainer.style.left=i.left.width+"px",o.centerContainer.style.top=i.top.height+"px",o.leftContainer.style.left="0",o.leftContainer.style.top=i.top.height+"px",o.rightContainer.style.left=i.left.width+i.center.width+"px",o.rightContainer.style.top=i.top.height+"px",o.top.style.left=i.left.width+"px",o.top.style.top="0",o.bottom.style.left=i.left.width+"px",o.bottom.style.top=i.top.height+i.centerContainer.height+"px",this._updateScrollTop();var c=this.props.scrollTop;"top"!=e.orientation.item&&(c+=Math.max(this.props.centerContainer.height-this.props.center.height-this.props.border.top-this.props.border.bottom,0)),o.center.style.left="0",o.center.style.top=c+"px",o.left.style.left="0",o.left.style.top=c+"px",o.right.style.left="0",o.right.style.top=c+"px";var p=0==this.props.scrollTop?"hidden":"",f=this.props.scrollTop==this.props.scrollTopMin?"hidden":"";if(o.shadowTop.style.visibility=p,o.shadowBottom.style.visibility=f,o.shadowTopLeft.style.visibility=p,o.shadowBottomLeft.style.visibility=f,o.shadowTopRight.style.visibility=p,o.shadowBottomRight.style.visibility=f,this.components.forEach(function(e){t=e.redraw()||t}),t){var m=3;this.redrawCount0&&(this.props.scrollTop=0),this.props.scrollTope;e++)o=this.selection[e],n=this.items[o],n&&n.unselect();for(this.selection=[],e=0,i=t.length;i>e;e++)o=t[e],n=this.items[o],n&&(this.selection.push(o),n.select())},o.prototype.getSelection=function(){return this.selection.concat([])},o.prototype.getVisibleItems=function(){var t=this.body.range.getRange(),e=this.body.util.toScreen(t.start),i=this.body.util.toScreen(t.end),o=[];for(var n in this.groups)if(this.groups.hasOwnProperty(n))for(var s=this.groups[n],r=s.visibleItems,a=0;ae&&o.push(h.id)}return o},o.prototype._deselect=function(t){for(var e=this.selection,i=0,o=e.length;o>i;i++)if(e[i]==t){e.splice(i,1);break}},o.prototype.redraw=function(){var t=this.options.margin,e=this.body.range,i=s.option.asSize,o=this.options,n=o.orientation.item,r=!1,a=this.dom.frame;this.props.top=this.body.domProps.top.height+this.body.domProps.border.top,this.props.left=this.body.domProps.left.width+this.body.domProps.border.left,a.className="vis-itemset",r=this._orderGroups()||r;var h=e.end-e.start,d=h!=this.lastVisibleInterval||this.props.width!=this.props.lastWidth;d&&(this.stackDirty=!0),this.lastVisibleInterval=h,this.props.lastWidth=this.props.width;var l=this.stackDirty,u=this._firstGroup(),c={item:t.item,axis:t.axis},p={item:t.item,axis:t.item.vertical/2},f=0,m=t.axis+t.item.vertical;return this.groups[g].redraw(e,p,l),s.forEach(this.groups,function(t){var i=t==u?c:p,o=t.redraw(e,i,l);r=o||r,f+=t.height}),f=Math.max(f,m),this.stackDirty=!1,a.style.height=i(f),this.props.width=a.offsetWidth,this.props.height=f,this.dom.axis.style.top=i("top"==n?this.body.domProps.top.height+this.body.domProps.border.top:this.body.domProps.top.height+this.body.domProps.centerContainer.height),this.dom.axis.style.left="0",r=this._isResized()||r},o.prototype._firstGroup=function(){var t="top"==this.options.orientation.item?0:this.groupIds.length-1,e=this.groupIds[t],i=this.groups[e]||this.groups[v];return i||null},o.prototype._updateUngrouped=function(){var t,e,i=this.groups[v];this.groups[g];if(this.groupsData){if(i){i.hide(),delete this.groups[v];for(e in this.items)if(this.items.hasOwnProperty(e)){t=this.items[e],t.parent&&t.parent.remove(t);var o=this._getGroupId(t.data),n=this.groups[o];n&&n.add(t)||t.hide()}}}else if(!i){var s=null,r=null;i=new l(s,r,this),this.groups[v]=i;for(e in this.items)this.items.hasOwnProperty(e)&&(t=this.items[e],i.add(t));i.show()}},o.prototype.getLabelSet=function(){return this.dom.labelSet},o.prototype.setItems=function(t){var e,i=this,o=this.itemsData;if(t){if(!(t instanceof r||t instanceof a))throw new TypeError("Data must be an instance of DataSet or DataView");this.itemsData=t}else this.itemsData=null;if(o&&(s.forEach(this.itemListeners,function(t,e){o.off(e,t)}),e=o.getIds(),this._onRemove(e)),this.itemsData){var n=this.id;s.forEach(this.itemListeners,function(t,e){i.itemsData.on(e,t,n)}),e=this.itemsData.getIds(),this._onAdd(e),this._updateUngrouped()}},o.prototype.getItems=function(){return this.itemsData},o.prototype.setGroups=function(t){var e,i=this;if(this.groupsData&&(s.forEach(this.groupListeners,function(t,e){i.groupsData.off(e,t)}),e=this.groupsData.getIds(),this.groupsData=null,this._onRemoveGroups(e)),t){if(!(t instanceof r||t instanceof a))throw new TypeError("Data must be an instance of DataSet or DataView");this.groupsData=t}else this.groupsData=null;if(this.groupsData){var o=this.id;s.forEach(this.groupListeners,function(t,e){i.groupsData.on(e,t,o)}),e=this.groupsData.getIds(),this._onAddGroups(e)}this._updateUngrouped(),this._order(),this.body.emitter.emit("change",{queue:!0})},o.prototype.getGroups=function(){return this.groupsData},o.prototype.removeItem=function(t){var e=this.itemsData.get(t),i=this.itemsData.getDataSet();e&&this.options.onRemove(e,function(e){e&&i.remove(t)})},o.prototype._getType=function(t){return t.type||this.options.type||(t.end?"range":"box")},o.prototype._getGroupId=function(t){var e=this._getType(t);return"background"==e&&void 0==t.group?g:this.groupsData?t.group:v},o.prototype._onUpdate=function(t){var e=this;t.forEach(function(t){var i,n=e.itemsData.get(t,e.itemOptions),s=e.items[t],r=e._getType(n),a=o.types[r];if(s&&(a&&s instanceof a?e._updateItem(s,n):(i=s.selected,e._removeItem(s),s=null)),!s){if(!a)throw"rangeoverflow"==r?new TypeError('Item type "rangeoverflow" is deprecated. Use css styling instead: .vis-item.vis-range .vis-item-content {overflow: visible;}'):new TypeError('Unknown item type "'+r+'"');s=new a(n,e.conversion,e.options),s.id=t,e._addItem(s),i&&(this.selection.push(t),s.select())}}.bind(this)),this._order(),this.stackDirty=!0,this.body.emitter.emit("change",{queue:!0})},o.prototype._onAdd=o.prototype._onUpdate,o.prototype._onRemove=function(t){var e=0,i=this;t.forEach(function(t){var o=i.items[t];o&&(e++,i._removeItem(o))}),e&&(this._order(),this.stackDirty=!0,this.body.emitter.emit("change",{queue:!0}))},o.prototype._order=function(){s.forEach(this.groups,function(t){t.order()})},o.prototype._onUpdateGroups=function(t){this._onAddGroups(t)},o.prototype._onAddGroups=function(t){var e=this;t.forEach(function(t){var i=e.groupsData.get(t),o=e.groups[t];if(o)o.setData(i);else{if(t==v||t==g)throw new Error("Illegal group id. "+t+" is a reserved id.");var n=Object.create(e.options);s.extend(n,{height:null}),o=new l(t,i,e),e.groups[t]=o;for(var r in e.items)if(e.items.hasOwnProperty(r)){var a=e.items[r];a.data.group==t&&o.add(a)}o.order(),o.show()}}),this.body.emitter.emit("change",{queue:!0})},o.prototype._onRemoveGroups=function(t){var e=this.groups;t.forEach(function(t){var i=e[t];i&&(i.hide(),delete e[t])}),this.markDirty(),this.body.emitter.emit("change",{queue:!0})},o.prototype._orderGroups=function(){if(this.groupsData){var t=this.groupsData.getIds({order:this.options.groupOrder}),e=!s.equalArray(t,this.groupIds);if(e){var i=this.groups;t.forEach(function(t){i[t].hide()}),t.forEach(function(t){i[t].show()}),this.groupIds=t}return e}return!1},o.prototype._addItem=function(t){this.items[t.id]=t;var e=this._getGroupId(t.data),i=this.groups[e];i&&i.add(t)},o.prototype._updateItem=function(t,e){var i=t.data.group,o=t.data.subgroup;if(t.setData(e),i!=t.data.group||o!=t.data.subgroup){var n=this.groups[i];n&&n.remove(t);var s=this._getGroupId(t.data),r=this.groups[s];r&&r.add(t)}},o.prototype._removeItem=function(t){t.hide(),delete this.items[t.id];var e=this.selection.indexOf(t.id);-1!=e&&this.selection.splice(e,1),t.parent&&t.parent.remove(t)},o.prototype._constructByEndArray=function(t){for(var e=[],i=0;in+r)return}else{var a=e.height;if(n+a-r>o)return}}if(e&&e!=this.groupTouchParams.group){var h=this.groupsData,d=h.get(e.groupId),l=h.get(this.groupTouchParams.group.groupId);l&&d&&(this.options.groupOrderSwap(l,d,this.groupsData),this.groupsData.update(l),this.groupsData.update(d));var u=this.groupsData.getIds({order:this.options.groupOrder});if(!s.equalArray(u,this.groupTouchParams.originalOrder))for(var h=this.groupsData,c=this.groupTouchParams.originalOrder,p=this.groupTouchParams.group.groupId,f=Math.min(c.length,u.length),m=0,v=0,g=0;f>m;){for(;f>m+v&&f>m+g&&u[m+v]==c[m+g];)m++;if(m+v>=f)break;if(u[m+v]!=p)if(c[m+g]!=p){var y=u.indexOf(c[m+g]),b=h.get(u[m+v]),w=h.get(c[m+g]);this.options.groupOrderSwap(b,w,h),h.update(b),h.update(w);var _=u[m+v];u[m+v]=c[m+g],u[y]=_,m++}else g=1;else v=1}}}},o.prototype._onGroupDragEnd=function(t){if(this.options.groupEditable.order&&this.groupTouchParams.group){t.stopPropagation();var e=this,i=e.groupTouchParams.group.groupId,o=e.groupsData.getDataSet(),n=s.extend({},o.get(i));e.options.onMoveGroup(n,function(t){if(t)t[o._fieldId]=i,o.update(t);else{var n=o.getIds({order:e.options.groupOrder});if(!s.equalArray(n,e.groupTouchParams.originalOrder))for(var r=e.groupTouchParams.originalOrder,a=Math.min(r.length,n.length),h=0;a>h;){for(;a>h&&n[h]==r[h];)h++;if(h>=a)break;var d=n.indexOf(r[h]),l=o.get(n[h]),u=o.get(r[h]);e.options.groupOrderSwap(l,u,o),groupsData.update(l),groupsData.update(u);var c=n[h];n[h]=r[h],n[d]=c,h++}}}),e.body.emitter.emit("groupDragged",{groupId:i})}},o.prototype._onSelectItem=function(t){if(this.options.selectable){var e=t.srcEvent&&(t.srcEvent.ctrlKey||t.srcEvent.metaKey),i=t.srcEvent&&t.srcEvent.shiftKey;if(e||i)return void this._onMultiSelectItem(t);var o=this.getSelection(),n=this.itemFromTarget(t),s=n?[n.id]:[];this.setSelection(s);var r=this.getSelection();(r.length>0||o.length>0)&&this.body.emitter.emit("select",{items:r,event:t})}},o.prototype._onAddItem=function(t){if(this.options.selectable&&this.options.editable.add){var e=this,i=this.options.snap||null,o=this.itemFromTarget(t);if(t.stopPropagation(),o){var n=e.itemsData.get(o.id);this.options.onUpdate(n,function(t){t&&e.itemsData.getDataSet().update(t)})}else{var r=s.getAbsoluteLeft(this.dom.frame),a=t.center.x-r,h=this.body.util.toTime(a),d=this.body.util.getScale(),l=this.body.util.getStep(),u={start:i?i(h,d,l):h,content:"new item"};if("range"===this.options.type){var c=this.body.util.toTime(a+this.props.width/5);u.end=i?i(c,d,l):c}u[this.itemsData._fieldId]=s.randomUUID();var p=this.groupFromTarget(t);p&&(u.group=p.groupId),u=this._cloneItemData(u),this.options.onAdd(u,function(t){t&&e.itemsData.getDataSet().add(t)})}}},o.prototype._onMultiSelectItem=function(t){if(this.options.selectable){var e=this.itemFromTarget(t);if(e){var i=this.options.multiselect?this.getSelection():[],n=t.srcEvent&&t.srcEvent.shiftKey||!1;if(n&&this.options.multiselect){i.push(e.id);var s=o._getItemRange(this.itemsData.get(i,this.itemOptions));i=[];for(var r in this.items)if(this.items.hasOwnProperty(r)){var a=this.items[r],h=a.data.start,d=void 0!==a.data.end?a.data.end:h;h>=s.min&&d<=s.max&&!(a instanceof m)&&i.push(a.id)}}else{var l=i.indexOf(e.id);-1==l?i.push(e.id):i.splice(l,1)}this.setSelection(i),this.body.emitter.emit("select",{items:this.getSelection(),event:t})}}},o._getItemRange=function(t){var e=null,i=null;return t.forEach(function(t){(null==i||t.starte)&&(e=t.end):(null==e||t.start>e)&&(e=t.start)}),{min:i,max:e}},o.prototype.itemFromTarget=function(t){for(var e=t.target;e;){if(e.hasOwnProperty("timeline-item"))return e["timeline-item"];e=e.parentNode}return null},o.prototype.groupFromTarget=function(t){for(var e=t.center?t.center.y:t.clientY,i=0;ia&&ea)return n}else if(0===i&&e0?t.step:1,this.autoScale=!1)},o.prototype.setAutoScale=function(t){this.autoScale=t},o.prototype.setMinimumStep=function(t){if(void 0!=t){var e=31104e6,i=2592e6,o=864e5,n=36e5,s=6e4,r=1e3,a=1;1e3*e>t&&(this.scale="year",this.step=1e3),500*e>t&&(this.scale="year",this.step=500),100*e>t&&(this.scale="year",this.step=100),50*e>t&&(this.scale="year",this.step=50),10*e>t&&(this.scale="year",this.step=10),5*e>t&&(this.scale="year",this.step=5),e>t&&(this.scale="year",this.step=1),3*i>t&&(this.scale="month",this.step=3),i>t&&(this.scale="month",this.step=1),5*o>t&&(this.scale="day",this.step=5),2*o>t&&(this.scale="day",this.step=2),o>t&&(this.scale="day",this.step=1),o/2>t&&(this.scale="weekday",this.step=1),4*n>t&&(this.scale="hour",this.step=4),n>t&&(this.scale="hour",this.step=1),15*s>t&&(this.scale="minute",this.step=15),10*s>t&&(this.scale="minute",this.step=10),5*s>t&&(this.scale="minute",this.step=5),s>t&&(this.scale="minute",this.step=1),15*r>t&&(this.scale="second",this.step=15),10*r>t&&(this.scale="second",this.step=10),5*r>t&&(this.scale="second",this.step=5),r>t&&(this.scale="second",this.step=1),200*a>t&&(this.scale="millisecond",this.step=200),100*a>t&&(this.scale="millisecond",this.step=100),50*a>t&&(this.scale="millisecond",this.step=50),10*a>t&&(this.scale="millisecond",this.step=10),5*a>t&&(this.scale="millisecond",this.step=5),a>t&&(this.scale="millisecond",this.step=1)}},o.snap=function(t,e,i){var o=n(t);if("year"==e){var s=o.year()+Math.round(o.month()/12);o.year(Math.round(s/i)*i),o.month(0),o.date(0),o.hours(0),o.minutes(0),o.seconds(0),o.milliseconds(0)}else if("month"==e)o.date()>15?(o.date(1),o.add(1,"month")):o.date(1),o.hours(0),o.minutes(0),o.seconds(0),o.milliseconds(0);else if("day"==e){switch(i){case 5:case 2:o.hours(24*Math.round(o.hours()/24));break;default:o.hours(12*Math.round(o.hours()/12))}o.minutes(0),o.seconds(0),o.milliseconds(0)}else if("weekday"==e){switch(i){case 5:case 2:o.hours(12*Math.round(o.hours()/12));break;default:o.hours(6*Math.round(o.hours()/6))}o.minutes(0),o.seconds(0),o.milliseconds(0)}else if("hour"==e){switch(i){case 4:o.minutes(60*Math.round(o.minutes()/60));break;default:o.minutes(30*Math.round(o.minutes()/30))}o.seconds(0),o.milliseconds(0)}else if("minute"==e){switch(i){case 15:case 10:o.minutes(5*Math.round(o.minutes()/5)),o.seconds(0);break;case 5:o.seconds(60*Math.round(o.seconds()/60));break;default:o.seconds(30*Math.round(o.seconds()/30))}o.milliseconds(0)}else if("second"==e)switch(i){case 15:case 10:o.seconds(5*Math.round(o.seconds()/5)),o.milliseconds(0);break;case 5:o.milliseconds(1e3*Math.round(o.milliseconds()/1e3));break;default:o.milliseconds(500*Math.round(o.milliseconds()/500))}else if("millisecond"==e){var r=i>5?i/2:1;o.milliseconds(Math.round(o.milliseconds()/r)*r)}return o},o.prototype.isMajor=function(){if(1==this.switchedYear)switch(this.switchedYear=!1,this.scale){case"year":case"month":case"weekday":case"day":case"hour":case"minute":case"second":case"millisecond":return!0;default:return!1}else if(1==this.switchedMonth)switch(this.switchedMonth=!1,this.scale){case"weekday":case"day":case"hour":case"minute":case"second":case"millisecond":return!0;default:return!1}else if(1==this.switchedDay)switch(this.switchedDay=!1,this.scale){case"millisecond":case"second":case"minute":case"hour":return!0;default:return!1}var t=this.moment(this.current);switch(this.scale){case"millisecond":return 0==t.milliseconds();case"second":return 0==t.seconds();case"minute":return 0==t.hours()&&0==t.minutes();case"hour":return 0==t.hours();case"weekday":case"day":return 1==t.date();case"month":return 0==t.month();case"year":return!1;default:return!1}},o.prototype.getLabelMinor=function(t){void 0==t&&(t=this.current);var e=this.format.minorLabels[this.scale];return e&&e.length>0?this.moment(t).format(e):""},o.prototype.getLabelMajor=function(t){void 0==t&&(t=this.current);var e=this.format.majorLabels[this.scale];return e&&e.length>0?this.moment(t).format(e):""},o.prototype.getClassName=function(){function t(t){return t/h%2==0?" vis-even":" vis-odd"}function e(t){return t.isSame(new Date,"day")?" vis-today":t.isSame(s().add(1,"day"),"day")?" vis-tomorrow":t.isSame(s().add(-1,"day"),"day")?" vis-yesterday":""}function i(t){return t.isSame(new Date,"week")?" vis-current-week":""}function o(t){return t.isSame(new Date,"month")?" vis-current-month":""}function n(t){return t.isSame(new Date,"year")?" vis-current-year":""}var s=this.moment,r=this.moment(this.current),a=r.locale?r.locale("en"):r.lang("en"),h=this.step;switch(this.scale){case"millisecond":return t(a.milliseconds()).trim();case"second":return t(a.seconds()).trim();case"minute":return t(a.minutes()).trim();case"hour":var d=a.hours();return 4==this.step&&(d=d+"-h"+(d+4)),"vis-h"+d+e(a)+t(a.hours());case"weekday":return"vis-"+a.format("dddd").toLowerCase()+e(a)+i(a)+t(a.date());case"day":var l=a.date(),u=a.format("MMMM").toLowerCase();return"vis-day"+l+" vis-"+u+o(a)+t(l-1);case"month":return"vis-"+a.format("MMMM").toLowerCase()+o(a)+t(a.month());case"year":var c=a.year();return"vis-year"+c+n(a)+t(c);default:return""}},t.exports=o},function(t,e,i){function o(t,e,i){this.groupId=t,this.subgroups={},this.subgroupIndex=0,this.subgroupOrderer=e&&e.subgroupOrder,this.itemSet=i,this.dom={},this.props={label:{width:0,height:0}},this.className=null,this.items={},this.visibleItems=[],this.orderedItems={byStart:[],byEnd:[]},this.checkRangedItems=!1;var o=this;this.itemSet.body.emitter.on("checkRangedItems",function(){o.checkRangedItems=!0}),this._create(),this.setData(e)}var n=i(1),s=i(32);i(33);o.prototype._create=function(){var t=document.createElement("div");this.itemSet.options.groupEditable.order?t.className="vis-label draggable":t.className="vis-label",this.dom.label=t;var e=document.createElement("div");e.className="vis-inner",t.appendChild(e),this.dom.inner=e;var i=document.createElement("div");i.className="vis-group",i["timeline-group"]=this,this.dom.foreground=i,this.dom.background=document.createElement("div"),this.dom.background.className="vis-group",this.dom.axis=document.createElement("div"),this.dom.axis.className="vis-group",this.dom.marker=document.createElement("div"),this.dom.marker.style.visibility="hidden",this.dom.marker.innerHTML="?",this.dom.background.appendChild(this.dom.marker)},o.prototype.setData=function(t){var e;if(e=this.itemSet.options&&this.itemSet.options.groupTemplate?this.itemSet.options.groupTemplate(t):t&&t.content,e instanceof Element){for(this.dom.inner.appendChild(e);this.dom.inner.firstChild;)this.dom.inner.removeChild(this.dom.inner.firstChild);this.dom.inner.appendChild(e)}else void 0!==e&&null!==e?this.dom.inner.innerHTML=e:this.dom.inner.innerHTML=this.groupId||"";this.dom.label.title=t&&t.title||"",this.dom.inner.firstChild?n.removeClassName(this.dom.inner,"vis-hidden"):n.addClassName(this.dom.inner,"vis-hidden");var i=t&&t.className||null;i!=this.className&&(this.className&&(n.removeClassName(this.dom.label,this.className),n.removeClassName(this.dom.foreground,this.className),n.removeClassName(this.dom.background,this.className),n.removeClassName(this.dom.axis,this.className)),n.addClassName(this.dom.label,i),n.addClassName(this.dom.foreground,i),n.addClassName(this.dom.background,i),n.addClassName(this.dom.axis,i),this.className=i),this.style&&(n.removeCssText(this.dom.label,this.style),this.style=null),t&&t.style&&(n.addCssText(this.dom.label,t.style),this.style=t.style)},o.prototype.getLabelWidth=function(){return this.props.label.width},o.prototype.redraw=function(t,e,i){var o=!1,r=this.dom.marker.clientHeight;if(r!=this.lastMarkerHeight&&(this.lastMarkerHeight=r,n.forEach(this.items,function(t){t.dirty=!0,t.displayed&&t.redraw()}),i=!0),"function"==typeof this.itemSet.options.order){if(i){var a=this,h=!1;n.forEach(this.items,function(t){t.displayed||(t.redraw(),a.visibleItems.push(t)),t.repositionX(h)});var d=this.orderedItems.byStart.slice().sort(function(t,e){return a.itemSet.options.order(t.data,e.data)});s.stack(d,e,!0)}this.visibleItems=this._updateVisibleItems(this.orderedItems,this.visibleItems,t)}else this.visibleItems=this._updateVisibleItems(this.orderedItems,this.visibleItems,t),this.itemSet.options.stack?s.stack(this.visibleItems,e,i):s.nostack(this.visibleItems,e,this.subgroups);var l=this._calculateHeight(e),u=this.dom.foreground;this.top=u.offsetTop,this.left=u.offsetLeft,this.width=u.offsetWidth,o=n.updateProperty(this,"height",l)||o,o=n.updateProperty(this.props.label,"width",this.dom.inner.clientWidth)||o,o=n.updateProperty(this.props.label,"height",this.dom.inner.clientHeight)||o,this.dom.background.style.height=l+"px",this.dom.foreground.style.height=l+"px",this.dom.label.style.height=l+"px";for(var c=0,p=this.visibleItems.length;p>c;c++){var f=this.visibleItems[c];f.repositionY(e)}return o},o.prototype._calculateHeight=function(t){var e,i=this.visibleItems;this.resetSubgroups();var o=this;if(i.length>0){var s=i[0].top,r=i[0].top+i[0].height;if(n.forEach(i,function(t){s=Math.min(s,t.top),r=Math.max(r,t.top+t.height),void 0!==t.data.subgroup&&(o.subgroups[t.data.subgroup].height=Math.max(o.subgroups[t.data.subgroup].height,t.height),o.subgroups[t.data.subgroup].visible=!0)}),s>t.axis){var a=s-t.axis;r-=a,n.forEach(i,function(t){t.top-=a})}e=r+t.item.vertical/2}else e=0;return e=Math.max(e,this.props.label.height)},o.prototype.show=function(){this.dom.label.parentNode||this.itemSet.dom.labelSet.appendChild(this.dom.label),this.dom.foreground.parentNode||this.itemSet.dom.foreground.appendChild(this.dom.foreground),this.dom.background.parentNode||this.itemSet.dom.background.appendChild(this.dom.background),this.dom.axis.parentNode||this.itemSet.dom.axis.appendChild(this.dom.axis)},o.prototype.hide=function(){var t=this.dom.label;t.parentNode&&t.parentNode.removeChild(t);var e=this.dom.foreground;e.parentNode&&e.parentNode.removeChild(e);var i=this.dom.background;i.parentNode&&i.parentNode.removeChild(i);var o=this.dom.axis;o.parentNode&&o.parentNode.removeChild(o)},o.prototype.add=function(t){if(this.items[t.id]=t,t.setParent(this),void 0!==t.data.subgroup&&(void 0===this.subgroups[t.data.subgroup]&&(this.subgroups[t.data.subgroup]={height:0,visible:!1,index:this.subgroupIndex,items:[]},this.subgroupIndex++),this.subgroups[t.data.subgroup].items.push(t)),this.orderSubgroups(),-1==this.visibleItems.indexOf(t)){var e=this.itemSet.body.range;this._checkIfVisible(t,this.visibleItems,e)}},o.prototype.orderSubgroups=function(){if(void 0!==this.subgroupOrderer){var t=[];if("string"==typeof this.subgroupOrderer){for(var e in this.subgroups)t.push({subgroup:e,sortField:this.subgroups[e].items[0].data[this.subgroupOrderer]});t.sort(function(t,e){return t.sortField-e.sortField})}else if("function"==typeof this.subgroupOrderer){for(var e in this.subgroups)t.push(this.subgroups[e].items[0].data);t.sort(this.subgroupOrderer)}if(t.length>0)for(var i=0;it?-1:l>=t?0:1};if(e.length>0)for(s=0;sl}),1==this.checkRangedItems)for(this.checkRangedItems=!1,s=0;sl})}for(s=0;s=0&&(s=e[r],!n(s));r--)void 0===o[s.id]&&(o[s.id]=!0,i.push(s));for(r=t+1;rn;n++)t[n].top=null;for(n=0,s=t.length;s>n;n++){var r=t[n];if(r.stack&&null===r.top){r.top=i.axis;do{for(var a=null,h=0,d=t.length;d>h;h++){var l=t[h];if(null!==l.top&&l!==r&&l.stack&&e.collision(r,l,i.item)){a=l;break}}null!=a&&(r.top=a.top+a.height+i.item.vertical)}while(a)}}},e.nostack=function(t,e,i){var o,n,s;for(o=0,n=t.length;n>o;o++)if(void 0!==t[o].data.subgroup){s=e.axis;for(var r in i)i.hasOwnProperty(r)&&1==i[r].visible&&i[r].indexe.left&&t.top-o.vertical+ie.top}},function(t,e,i){function o(t,e,i){if(this.props={content:{width:0}},this.overflow=!1,t){if(void 0==t.start)throw new Error('Property "start" missing in item '+t.id);if(void 0==t.end)throw new Error('Property "end" missing in item '+t.id)}n.call(this,t,e,i)}var n=(i(20),i(34));o.prototype=new n(null,null,null),o.prototype.baseClassName="vis-item vis-range",o.prototype.isVisible=function(t){return this.data.startt.start},o.prototype.redraw=function(){var t=this.dom;if(t||(this.dom={},t=this.dom,t.box=document.createElement("div"),t.frame=document.createElement("div"),t.frame.className="vis-item-overflow",t.box.appendChild(t.frame),t.content=document.createElement("div"),t.content.className="vis-item-content",t.frame.appendChild(t.content),t.box["timeline-item"]=this,this.dirty=!0),!this.parent)throw new Error("Cannot redraw item: no parent attached");if(!t.box.parentNode){var e=this.parent.dom.foreground;if(!e)throw new Error("Cannot redraw item: parent has no foreground container element");e.appendChild(t.box)}if(this.displayed=!0,this.dirty){this._updateContents(this.dom.content),this._updateTitle(this.dom.box),this._updateDataAttributes(this.dom.box),this._updateStyle(this.dom.box);var i=(this.options.editable.updateTime||this.options.editable.updateGroup||this.editable===!0)&&this.editable!==!1,o=(this.data.className?" "+this.data.className:"")+(this.selected?" vis-selected":"")+(i?" vis-editable":" vis-readonly");t.box.className=this.baseClassName+o,this.overflow="hidden"!==window.getComputedStyle(t.frame).overflow,this.dom.content.style.maxWidth="none",this.props.content.width=this.dom.content.offsetWidth,this.height=this.dom.box.offsetHeight,this.dom.content.style.maxWidth="",this.dirty=!1}this._repaintDeleteButton(t.box),this._repaintDragLeft(),this._repaintDragRight()},o.prototype.show=function(){this.displayed||this.redraw()},o.prototype.hide=function(){if(this.displayed){var t=this.dom.box;t.parentNode&&t.parentNode.removeChild(t),this.displayed=!1}},o.prototype.repositionX=function(t){var e,i,o=this.parent.width,n=this.conversion.toScreen(this.data.start),s=this.conversion.toScreen(this.data.end);(void 0===t||t===!0)&&(-o>n&&(n=-o),s>2*o&&(s=2*o));var r=Math.max(s-n,1);switch(this.overflow?(this.left=n,this.width=r+this.props.content.width,i=this.props.content.width):(this.left=n,this.width=r,i=Math.min(s-n,this.props.content.width)),this.dom.box.style.left=this.left+"px",this.dom.box.style.width=r+"px",this.options.align){case"left":this.dom.content.style.left="0";break;case"right":this.dom.content.style.left=Math.max(r-i,0)+"px";break;case"center":this.dom.content.style.left=Math.max((r-i)/2,0)+"px";break;default:e=this.overflow?s>0?Math.max(-n,0):-i:0>n?-n:0,this.dom.content.style.left=e+"px"}},o.prototype.repositionY=function(){var t=this.options.orientation.item,e=this.dom.box;"top"==t?e.style.top=this.top+"px":e.style.top=this.parent.height-this.top-this.height+"px"},o.prototype._repaintDragLeft=function(){if(this.selected&&this.options.editable.updateTime&&!this.dom.dragLeft){var t=document.createElement("div");t.className="vis-drag-left",t.dragLeftItem=this,this.dom.box.appendChild(t),this.dom.dragLeft=t}else!this.selected&&this.dom.dragLeft&&(this.dom.dragLeft.parentNode&&this.dom.dragLeft.parentNode.removeChild(this.dom.dragLeft),this.dom.dragLeft=null)},o.prototype._repaintDragRight=function(){if(this.selected&&this.options.editable.updateTime&&!this.dom.dragRight){var t=document.createElement("div");t.className="vis-drag-right",t.dragRightItem=this,this.dom.box.appendChild(t),this.dom.dragRight=t}else!this.selected&&this.dom.dragRight&&(this.dom.dragRight.parentNode&&this.dom.dragRight.parentNode.removeChild(this.dom.dragRight),this.dom.dragRight=null)},t.exports=o},function(t,e,i){function o(t,e,i){this.id=null,this.parent=null,this.data=t,this.dom=null,this.conversion=e||{},this.options=i||{},this.selected=!1,this.displayed=!1,this.dirty=!0,this.top=null,this.left=null,this.width=null,this.height=null,this.editable=null,this.data&&this.data.hasOwnProperty("editable")&&"boolean"==typeof this.data.editable&&(this.editable=t.editable)}var n=i(20),s=i(1);o.prototype.stack=!0,o.prototype.select=function(){this.selected=!0,this.dirty=!0,this.displayed&&this.redraw()},o.prototype.unselect=function(){this.selected=!1,this.dirty=!0,this.displayed&&this.redraw()},o.prototype.setData=function(t){var e=void 0!=t.group&&this.data.group!=t.group;e&&this.parent.itemSet._moveToGroup(this,t.group),t.hasOwnProperty("editable")&&"boolean"==typeof t.editable&&(this.editable=t.editable),this.data=t,this.dirty=!0,this.displayed&&this.redraw()},o.prototype.setParent=function(t){this.displayed?(this.hide(),this.parent=t,this.parent&&this.show()):this.parent=t},o.prototype.isVisible=function(t){return!1},o.prototype.show=function(){return!1},o.prototype.hide=function(){return!1},o.prototype.redraw=function(){},o.prototype.repositionX=function(){},o.prototype.repositionY=function(){},o.prototype._repaintDeleteButton=function(t){var e=(this.options.editable.remove||this.data.editable===!0)&&this.data.editable!==!1;if(this.selected&&e&&!this.dom.deleteButton){var i=this,o=document.createElement("div");o.className="vis-delete",o.title="Delete this item",new n(o).on("tap",function(t){t.stopPropagation(),i.parent.removeFromDataSet(i)}),t.appendChild(o),this.dom.deleteButton=o}else!this.selected&&this.dom.deleteButton&&(this.dom.deleteButton.parentNode&&this.dom.deleteButton.parentNode.removeChild(this.dom.deleteButton),this.dom.deleteButton=null)},o.prototype._updateContents=function(t){var e;if(this.options.template){var i=this.parent.itemSet.itemsData.get(this.id);e=this.options.template(i)}else e=this.data.content;var o=this._contentToString(this.content)!==this._contentToString(e);if(o){if(e instanceof Element)t.innerHTML="",t.appendChild(e);else if(void 0!=e)t.innerHTML=e;else if("background"!=this.data.type||void 0!==this.data.content)throw new Error('Property "content" missing in item '+this.id);this.content=e}},o.prototype._updateTitle=function(t){null!=this.data.title?t.title=this.data.title||"":t.removeAttribute("vis-title")},o.prototype._updateDataAttributes=function(t){if(this.options.dataAttributes&&this.options.dataAttributes.length>0){var e=[];if(Array.isArray(this.options.dataAttributes))e=this.options.dataAttributes;else{if("all"!=this.options.dataAttributes)return;e=Object.keys(this.data)}for(var i=0;in;n++){var r=this.visibleItems[n];r.repositionY(e)}return o},o.prototype.show=function(){this.dom.background.parentNode||this.itemSet.dom.background.appendChild(this.dom.background)},t.exports=o},function(t,e,i){function o(t,e,i){if(this.props={dot:{width:0,height:0},line:{width:0,height:0}},t&&void 0==t.start)throw new Error('Property "start" missing in item '+t);n.call(this,t,e,i)}var n=i(34);i(1);o.prototype=new n(null,null,null),o.prototype.isVisible=function(t){var e=(t.end-t.start)/4;return this.data.start>t.start-e&&this.data.startt.start-e&&this.data.startt.start},o.prototype.redraw=function(){var t=this.dom;if(t||(this.dom={},t=this.dom,t.box=document.createElement("div"),t.frame=document.createElement("div"),t.frame.className="vis-item-overflow",t.box.appendChild(t.frame),t.content=document.createElement("div"),t.content.className="vis-item-content",t.frame.appendChild(t.content),this.dirty=!0),!this.parent)throw new Error("Cannot redraw item: no parent attached");if(!t.box.parentNode){var e=this.parent.dom.background;if(!e)throw new Error("Cannot redraw item: parent has no background container element");e.appendChild(t.box)}if(this.displayed=!0,this.dirty){this._updateContents(this.dom.content),this._updateTitle(this.dom.content),this._updateDataAttributes(this.dom.content),this._updateStyle(this.dom.box);var i=(this.data.className?" "+this.data.className:"")+(this.selected?" vis-selected":"");t.box.className=this.baseClassName+i,this.overflow="hidden"!==window.getComputedStyle(t.content).overflow,this.props.content.width=this.dom.content.offsetWidth,this.height=0,this.dirty=!1}},o.prototype.show=r.prototype.show,o.prototype.hide=r.prototype.hide,o.prototype.repositionX=r.prototype.repositionX,o.prototype.repositionY=function(t){var e="top"===this.options.orientation.item;this.dom.content.style.top=e?"":"0",this.dom.content.style.bottom=e?"0":"";var i;if(void 0!==this.data.subgroup){var o=this.data.subgroup,n=this.parent.subgroups,r=n[o].index;if(1==e){i=this.parent.subgroups[o].height+t.item.vertical,i+=0==r?t.axis-.5*t.item.vertical:0;var a=this.parent.top;for(var h in n)n.hasOwnProperty(h)&&1==n[h].visible&&n[h].indexr&&(a+=l)}i=this.parent.subgroups[o].height+t.item.vertical,this.dom.box.style.top=this.parent.height-d+a+"px",this.dom.box.style.bottom=""}}else this.parent instanceof s?(i=Math.max(this.parent.height,this.parent.itemSet.body.domProps.center.height,this.parent.itemSet.body.domProps.centerContainer.height),this.dom.box.style.top=e?"0":"",this.dom.box.style.bottom=e?"":"0"):(i=this.parent.height,this.dom.box.style.top=this.parent.top+"px",this.dom.box.style.bottom="");this.dom.box.style.height=i+"px"},t.exports=o},function(t,e,i){function o(t,e){this.dom={ -foreground:null,lines:[],majorTexts:[],minorTexts:[],redundant:{lines:[],majorTexts:[],minorTexts:[]}},this.props={range:{start:0,end:0,minimumStep:0},lineTop:0},this.defaultOptions={orientation:{axis:"bottom"},showMinorLabels:!0,showMajorLabels:!0,format:r.FORMAT,moment:h,timeAxis:null},this.options=n.extend({},this.defaultOptions),this.body=t,this._create(),this.setOptions(e)}var n=i(1),s=i(26),r=i(30),a=i(27),h=i(2);o.prototype=new s,o.prototype.setOptions=function(t){t&&(n.selectiveExtend(["showMinorLabels","showMajorLabels","hiddenDates","timeAxis","moment"],this.options,t),n.selectiveDeepExtend(["format"],this.options,t),"orientation"in t&&("string"==typeof t.orientation?this.options.orientation.axis=t.orientation:"object"==typeof t.orientation&&"axis"in t.orientation&&(this.options.orientation.axis=t.orientation.axis)),"locale"in t&&("function"==typeof h.locale?h.locale(t.locale):h.lang(t.locale)))},o.prototype._create=function(){this.dom.foreground=document.createElement("div"),this.dom.background=document.createElement("div"),this.dom.foreground.className="vis-time-axis vis-foreground",this.dom.background.className="vis-time-axis vis-background"},o.prototype.destroy=function(){this.dom.foreground.parentNode&&this.dom.foreground.parentNode.removeChild(this.dom.foreground),this.dom.background.parentNode&&this.dom.background.parentNode.removeChild(this.dom.background),this.body=null},o.prototype.redraw=function(){var t=this.props,e=this.dom.foreground,i=this.dom.background,o="top"==this.options.orientation.axis?this.body.dom.top:this.body.dom.bottom,n=e.parentNode!==o;this._calculateCharSize();var s=this.options.showMinorLabels&&"none"!==this.options.orientation.axis,r=this.options.showMajorLabels&&"none"!==this.options.orientation.axis;t.minorLabelHeight=s?t.minorCharHeight:0,t.majorLabelHeight=r?t.majorCharHeight:0,t.height=t.minorLabelHeight+t.majorLabelHeight,t.width=e.offsetWidth,t.minorLineHeight=this.body.domProps.root.height-t.majorLabelHeight-("top"==this.options.orientation.axis?this.body.domProps.bottom.height:this.body.domProps.top.height),t.minorLineWidth=1,t.majorLineHeight=t.minorLineHeight+t.majorLabelHeight,t.majorLineWidth=1;var a=e.nextSibling,h=i.nextSibling;return e.parentNode&&e.parentNode.removeChild(e),i.parentNode&&i.parentNode.removeChild(i),e.style.height=this.props.height+"px",this._repaintLabels(),a?o.insertBefore(e,a):o.appendChild(e),h?this.body.dom.backgroundVertical.insertBefore(i,h):this.body.dom.backgroundVertical.appendChild(i),this._isResized()||n},o.prototype._repaintLabels=function(){var t=this.options.orientation.axis,e=n.convert(this.body.range.start,"Number"),i=n.convert(this.body.range.end,"Number"),o=this.body.util.toTime(7*(this.props.minorCharWidth||10)).valueOf(),s=o-a.getHiddenDurationBefore(this.options.moment,this.body.hiddenDates,this.body.range,o);s-=this.body.util.toTime(0).valueOf();var h=new r(new Date(e),new Date(i),s,this.body.hiddenDates);h.setMoment(this.options.moment),this.options.format&&h.setFormat(this.options.format),this.options.timeAxis&&h.setScale(this.options.timeAxis),this.step=h;var d=this.dom;d.redundant.lines=d.lines,d.redundant.majorTexts=d.majorTexts,d.redundant.minorTexts=d.minorTexts,d.lines=[],d.majorTexts=[],d.minorTexts=[];var l,u,c,p,f,m,v,g,y,b=void 0,w=0;for(h.start(),u=h.getCurrent(),p=this.body.util.toScreen(u);h.hasNext()&&1e3>w;){w++,f=h.isMajor(),y=h.getClassName(),g=h.getLabelMinor(),l=u,c=p,h.next(),u=h.getCurrent(),p=this.body.util.toScreen(u),m=p-c;var _=(g.length+1)*this.props.minorCharWidth0&&(void 0==b&&(b=c),this._repaintMajorText(c,h.getLabelMajor(),t,y)),v=this._repaintMajorLine(c,m,t,y)):_?v=this._repaintMinorLine(c,m,t,y):v&&(v.style.width=parseInt(v.style.width)+m+"px")}if(this.options.showMajorLabels){var x=this.body.util.toTime(0),k=h.getLabelMajor(x),O=k.length*(this.props.majorCharWidth||10)+10;(void 0==b||b>O)&&this._repaintMajorText(0,k,t,y)}n.forEach(this.dom.redundant,function(t){for(;t.length;){var e=t.pop();e&&e.parentNode&&e.parentNode.removeChild(e)}})},o.prototype._repaintMinorText=function(t,e,i,o){var n=this.dom.redundant.minorTexts.shift();if(!n){var s=document.createTextNode("");n=document.createElement("div"),n.appendChild(s),this.dom.foreground.appendChild(n)}return this.dom.minorTexts.push(n),n.childNodes[0].nodeValue=e,n.style.top="top"==i?this.props.majorLabelHeight+"px":"0",n.style.left=t+"px",n.className="vis-text vis-minor "+o,n},o.prototype._repaintMajorText=function(t,e,i,o){var n=this.dom.redundant.majorTexts.shift();if(!n){var s=document.createTextNode(e);n=document.createElement("div"),n.appendChild(s),this.dom.foreground.appendChild(n)}return this.dom.majorTexts.push(n),n.childNodes[0].nodeValue=e,n.className="vis-text vis-major "+o,n.style.top="top"==i?"0":this.props.minorLabelHeight+"px",n.style.left=t+"px",n},o.prototype._repaintMinorLine=function(t,e,i,o){var n=this.dom.redundant.lines.shift();n||(n=document.createElement("div"),this.dom.background.appendChild(n)),this.dom.lines.push(n);var s=this.props;return"top"==i?n.style.top=s.majorLabelHeight+"px":n.style.top=this.body.domProps.top.height+"px",n.style.height=s.minorLineHeight+"px",n.style.left=t-s.minorLineWidth/2+"px",n.style.width=e+"px",n.className="vis-grid vis-vertical vis-minor "+o,n},o.prototype._repaintMajorLine=function(t,e,i,o){var n=this.dom.redundant.lines.shift();n||(n=document.createElement("div"),this.dom.background.appendChild(n)),this.dom.lines.push(n);var s=this.props;return"top"==i?n.style.top="0":n.style.top=this.body.domProps.top.height+"px",n.style.left=t-s.majorLineWidth/2+"px",n.style.height=s.majorLineHeight+"px",n.style.width=e+"px",n.className="vis-grid vis-vertical vis-major "+o,n},o.prototype._calculateCharSize=function(){this.dom.measureCharMinor||(this.dom.measureCharMinor=document.createElement("DIV"),this.dom.measureCharMinor.className="vis-text vis-minor vis-measure",this.dom.measureCharMinor.style.position="absolute",this.dom.measureCharMinor.appendChild(document.createTextNode("0")),this.dom.foreground.appendChild(this.dom.measureCharMinor)),this.props.minorCharHeight=this.dom.measureCharMinor.clientHeight,this.props.minorCharWidth=this.dom.measureCharMinor.clientWidth,this.dom.measureCharMajor||(this.dom.measureCharMajor=document.createElement("DIV"),this.dom.measureCharMajor.className="vis-text vis-major vis-measure",this.dom.measureCharMajor.style.position="absolute",this.dom.measureCharMajor.appendChild(document.createTextNode("0")),this.dom.foreground.appendChild(this.dom.measureCharMajor)),this.props.majorCharHeight=this.dom.measureCharMajor.clientHeight,this.props.majorCharWidth=this.dom.measureCharMajor.clientWidth},t.exports=o},function(t,e,i){function o(t){this.active=!1,this.dom={container:t},this.dom.overlay=document.createElement("div"),this.dom.overlay.className="vis-overlay",this.dom.container.appendChild(this.dom.overlay),this.hammer=a(this.dom.overlay),this.hammer.on("tap",this._onTapOverlay.bind(this));var e=this,i=["tap","doubletap","press","pinch","pan","panstart","panmove","panend"];i.forEach(function(t){e.hammer.on(t,function(t){t.stopPropagation()})}),document&&document.body&&(this.onClick=function(i){n(i.target,t)||e.deactivate()},document.body.addEventListener("click",this.onClick)),void 0!==this.keycharm&&this.keycharm.destroy(),this.keycharm=s(),this.escListener=this.deactivate.bind(this)}function n(t,e){for(;t;){if(t===e)return!0;t=t.parentNode}return!1}var s=i(41),r=i(12),a=i(20),h=i(1);r(o.prototype),o.current=null,o.prototype.destroy=function(){this.deactivate(),this.dom.overlay.parentNode.removeChild(this.dom.overlay),this.onClick&&document.body.removeEventListener("click",this.onClick),this.hammer.destroy(),this.hammer=null},o.prototype.activate=function(){o.current&&o.current.deactivate(),o.current=this,this.active=!0,this.dom.overlay.style.display="none",h.addClassName(this.dom.container,"vis-active"),this.emit("change"),this.emit("activate"),this.keycharm.bind("esc",this.escListener)},o.prototype.deactivate=function(){this.active=!1,this.dom.overlay.style.display="",h.removeClassName(this.dom.container,"vis-active"),this.keycharm.unbind("esc",this.escListener),this.emit("change"),this.emit("deactivate")},o.prototype._onTapOverlay=function(t){this.activate(),t.stopPropagation()},t.exports=o},function(t,e,i){var o,n,s;!function(i,r){n=[],o=r,s="function"==typeof o?o.apply(e,n):o,!(void 0!==s&&(t.exports=s))}(this,function(){function t(t){var e,i=t&&t.preventDefault||!1,o=t&&t.container||window,n={},s={keydown:{},keyup:{}},r={};for(e=97;122>=e;e++)r[String.fromCharCode(e)]={code:65+(e-97),shift:!1};for(e=65;90>=e;e++)r[String.fromCharCode(e)]={code:e,shift:!0};for(e=0;9>=e;e++)r[""+e]={code:48+e,shift:!1};for(e=1;12>=e;e++)r["F"+e]={code:111+e,shift:!1};for(e=0;9>=e;e++)r["num"+e]={code:96+e,shift:!1};r["num*"]={code:106,shift:!1},r["num+"]={code:107,shift:!1},r["num-"]={code:109,shift:!1},r["num/"]={code:111,shift:!1},r["num."]={code:110,shift:!1},r.left={code:37,shift:!1},r.up={code:38,shift:!1},r.right={code:39,shift:!1},r.down={code:40,shift:!1},r.space={code:32,shift:!1},r.enter={code:13,shift:!1},r.shift={code:16,shift:void 0},r.esc={code:27,shift:!1},r.backspace={code:8,shift:!1},r.tab={code:9,shift:!1},r.ctrl={code:17,shift:!1},r.alt={code:18,shift:!1},r["delete"]={code:46,shift:!1},r.pageup={code:33,shift:!1},r.pagedown={code:34,shift:!1},r["="]={code:187,shift:!1},r["-"]={code:189,shift:!1},r["]"]={code:221,shift:!1},r["["]={code:219,shift:!1};var a=function(t){d(t,"keydown")},h=function(t){d(t,"keyup")},d=function(t,e){if(void 0!==s[e][t.keyCode]){for(var o=s[e][t.keyCode],n=0;no&&(o=30),o>1e3&&(o=1e3),e.redraw(),e.currentTimeTimer=setTimeout(t,o)}var e=this;t()},o.prototype.stop=function(){void 0!==this.currentTimeTimer&&(clearTimeout(this.currentTimeTimer),delete this.currentTimeTimer)},o.prototype.setCurrentTime=function(t){var e=n.convert(t,"Date").valueOf(),i=(new Date).valueOf();this.offset=e-i,this.redraw()},o.prototype.getCurrentTime=function(){return new Date((new Date).valueOf()+this.offset)},t.exports=o},function(t,e,i){function o(t){return t&&t.__esModule?t:{"default":t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var i=0;i0&&this._makeItem([]),this._makeHeader(n),this._handleObject(this.configureOptions[n],[n])),i++);this.options.showButton===!0&&!function(){var e=document.createElement("div");e.className="vis-configuration vis-config-button",e.innerHTML="generate options",e.onclick=function(){t._printOptions()},e.onmouseover=function(){e.className="vis-configuration vis-config-button hover"},e.onmouseout=function(){e.className="vis-configuration vis-config-button"},t.optionsContainer=document.createElement("div"),t.optionsContainer.className="vis-configuration vis-config-option-container",t.domElements.push(t.optionsContainer),t.domElements.push(e)}(),this._push(),this.colorPicker.insertTo(this.container)}},{key:"_push",value:function(){this.wrapper=document.createElement("div"),this.wrapper.className="vis-configuration-wrapper",this.container.appendChild(this.wrapper);for(var t=0;t1?o-1:0),s=1;o>s;s++)n[s-1]=e[s];return n.forEach(function(t){r.appendChild(t)}),i.domElements.push(r),{v:i.domElements.length}}();if("object"==typeof r)return r.v}return 0}},{key:"_makeHeader",value:function(t){var e=document.createElement("div");e.className="vis-configuration vis-config-header",e.innerHTML=t,this._makeItem([],e)}},{key:"_makeLabel",value:function(t,e){var i=arguments.length<=2||void 0===arguments[2]?!1:arguments[2],o=document.createElement("div");return o.className="vis-configuration vis-config-label vis-config-s"+e.length,i===!0?o.innerHTML=""+t+":":o.innerHTML=t+":",o}},{key:"_makeDropdown",value:function(t,e,i){var o=document.createElement("select");o.className="vis-configuration vis-config-select";var n=0;void 0!==e&&-1!==t.indexOf(e)&&(n=t.indexOf(e));for(var s=0;se&&n>e*u?(a.min=Math.ceil(e*u),l=a.min,d="range increased"):n>e/u&&(a.min=Math.ceil(e/u),l=a.min,d="range increased"),e*u>s&&1!==s&&(a.max=Math.ceil(e*u),l=a.max,d="range increased"),a.value=e}else a.value=o;var c=document.createElement("input");c.className="vis-configuration vis-config-rangeinput",c.value=a.value;var p=this;a.onchange=function(){c.value=this.value,p._update(Number(this.value),i)},a.oninput=function(){c.value=this.value};var f=this._makeLabel(i[i.length-1],i),m=this._makeItem(i,f,a,c);""!==d&&this.popupHistory[m]!==l&&(this.popupHistory[m]=l,this._setupPopup(d,m))}},{key:"_setupPopup",value:function(t,e){var i=this;if(this.initialized===!0&&this.allowCreation===!0&&this.popupCountervar options = "+JSON.stringify(t,null,2)+""}},{key:"getOptions",value:function(){for(var t={},e=0;es;s++)for(r=0;rp?p+1:p;var f=l/this.r,m=a.RGBToHSV(this.color.r,this.color.g,this.color.b);m.h=p,m.s=f;var v=a.HSVToRGB(m.h,m.s,m.v);v.a=this.color.a,this.color=v,this.initialColorDiv.style.backgroundColor="rgba("+this.initialColor.r+","+this.initialColor.g+","+this.initialColor.b+","+this.initialColor.a+")",this.newColorDiv.style.backgroundColor="rgba("+this.color.r+","+this.color.g+","+this.color.b+","+this.color.a+")"}}]),t}();e["default"]=h,t.exports=e["default"]},function(t,e,i){function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){for(var i=0;is.distance?console.log('%cUnknown option detected: "'+e+'" in '+t.printLocation(n.path,e,"")+"Perhaps it was misplaced? Matching option found at: "+t.printLocation(s.path,s.closestMatch,""),h):n.distance<=d?console.log('%cUnknown option detected: "'+e+'". Did you mean "'+n.closestMatch+'"?'+t.printLocation(n.path,e),h):console.log('%cUnknown option detected: "'+e+'". Did you mean one of these: '+t.print(Object.keys(i))+t.printLocation(o,e),h),r=!0}},{key:"findInOptions",value:function(e,i,o){var n=arguments.length<=3||void 0===arguments[3]?!1:arguments[3],r=1e9,a="",h=[],d=e.toLowerCase(),l=void 0;for(var u in i){var c=void 0;if(void 0!==i[u].__type__&&n===!0){var p=t.findInOptions(e,i[u],s.copyAndExtendArray(o,u));r>p.distance&&(a=p.closestMatch,h=p.path,r=p.distance,l=p.indexMatch)}else-1!==u.toLowerCase().indexOf(d)&&(l=u),c=t.levenshteinDistance(e,u),r>c&&(a=u,h=s.copyArray(o),r=c)}return{closestMatch:a,path:h,distance:r,indexMatch:l}}},{key:"printLocation",value:function(t,e){for(var i=arguments.length<=2||void 0===arguments[2]?"Problem value found at: \n":arguments[2],o="\n\n"+i+"options = {\n",n=0;ns;s++)o+=" ";o+=t[n]+": {\n"}for(var s=0;sr?r:t,e=null==e?r:r>e?r:e}return{min:null!=t?new Date(t):null,max:null!=e?new Date(e):null}},o.prototype.getEventProperties=function(t){var e=t.center?t.center.x:t.clientX,i=t.center?t.center.y:t.clientY,o=e-s.getAbsoluteLeft(this.dom.centerContainer),n=i-s.getAbsoluteTop(this.dom.centerContainer),r=this._toTime(o),a=c.customTimeFromTarget(t),h=s.getTarget(t),d=null;s.hasParent(h,this.timeAxis.dom.foreground)?d="axis":this.timeAxis2&&s.hasParent(h,this.timeAxis2.dom.foreground)?d="axis":s.hasParent(h,this.linegraph.yAxisLeft.dom.frame)?d="data-axis":s.hasParent(h,this.linegraph.yAxisRight.dom.frame)?d="data-axis":s.hasParent(h,this.linegraph.legendLeft.dom.frame)?d="legend":s.hasParent(h,this.linegraph.legendRight.dom.frame)?d="legend":null!=a?d="custom-time":s.hasParent(h,this.currentTime.bar)?d="current-time":s.hasParent(h,this.dom.center)&&(d="background");var l=[],u=this.linegraph.yAxisLeft,p=this.linegraph.yAxisRight;return u.hidden||l.push(u.screenToValue(n)),p.hidden||l.push(p.screenToValue(n)),{event:t,what:d,pageX:t.srcEvent?t.srcEvent.pageX:t.pageX,pageY:t.srcEvent?t.srcEvent.pageY:t.pageY,x:o,y:n,time:r,value:l}},o.prototype._createConfigurator=function(){return new f(this,this.dom.container,y)},t.exports=o},function(t,e,i){function o(t,e){this.id=n.randomUUID(),this.body=t,this.defaultOptions={yAxisOrientation:"left",defaultGroup:"default",sort:!0,sampling:!0,stack:!1,graphHeight:"400px",shaded:{enabled:!1,orientation:"bottom"},style:"line",barChart:{width:50,sideBySide:!1,align:"center"},interpolation:{enabled:!0,parametrization:"centripetal",alpha:.5},drawPoints:{enabled:!0,size:6,style:"square"},dataAxis:{showMinorLabels:!0,showMajorLabels:!0,icons:!1,width:"40px",visible:!0,alignZeros:!0,left:{range:{min:void 0,max:void 0},format:function(t){return t},title:{text:void 0,style:void 0}},right:{range:{min:void 0,max:void 0},format:function(t){return t},title:{text:void 0,style:void 0}}},legend:{enabled:!1,icons:!0,left:{visible:!0,position:"top-left"},right:{visible:!0,position:"top-right"}},groups:{visibility:{}}},this.options=n.extend({},this.defaultOptions),this.dom={},this.props={},this.hammer=null,this.groups={},this.abortedGraphUpdate=!1,this.updateSVGheight=!1,this.updateSVGheightOnResize=!1;var i=this;this.itemsData=null,this.groupsData=null,this.itemListeners={add:function(t,e,o){i._onAdd(e.items)},update:function(t,e,o){i._onUpdate(e.items)},remove:function(t,e,o){i._onRemove(e.items)}},this.groupListeners={add:function(t,e,o){i._onAddGroups(e.items)},update:function(t,e,o){i._onUpdateGroups(e.items)},remove:function(t,e,o){i._onRemoveGroups(e.items)}},this.items={},this.selection=[],this.lastStart=this.body.range.start,this.touchParams={},this.svgElements={},this.setOptions(e),this.groupsUsingDefaultStyles=[0],this.COUNTER=0,this.body.emitter.on("rangechanged",function(){i.lastStart=i.body.range.start,i.svg.style.left=n.option.asSize(-i.props.width),i.redraw.call(i,!0)}),this._create(),this.framework={svg:this.svg,svgElements:this.svgElements,options:this.options,groups:this.groups},this.body.emitter.emit("change")}var n=i(1),s=i(7),r=i(8),a=i(10),h=i(26),d=i(51),l=i(53),u=i(57),c=i(56),p=(i(54),"__ungrouped__");o.prototype=new h,o.prototype._create=function(){var t=document.createElement("div");t.className="vis-line-graph",this.dom.frame=t,this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.svg.style.position="relative",this.svg.style.height=(""+this.options.graphHeight).replace("px","")+"px",this.svg.style.display="block",t.appendChild(this.svg),this.options.dataAxis.orientation="left",this.yAxisLeft=new d(this.body,this.options.dataAxis,this.svg,this.options.groups),this.options.dataAxis.orientation="right",this.yAxisRight=new d(this.body,this.options.dataAxis,this.svg,this.options.groups),delete this.options.dataAxis.orientation,this.legendLeft=new u(this.body,this.options.legend,"left",this.options.groups),this.legendRight=new u(this.body,this.options.legend,"right",this.options.groups),this.show()},o.prototype.setOptions=function(t){if(t){var e=["sampling","defaultGroup","stack","height","graphHeight","yAxisOrientation","style","barChart","dataAxis","sort","groups"];void 0===t.graphHeight&&void 0!==t.height&&void 0!==this.body.domProps.centerContainer.height?(this.updateSVGheight=!0,this.updateSVGheightOnResize=!0):void 0!==this.body.domProps.centerContainer.height&&void 0!==t.graphHeight&&parseInt((t.graphHeight+"").replace("px",""))0){var d=this.body.util.toGlobalTime(-this.body.domProps.root.width),l=this.body.util.toGlobalTime(2*this.body.domProps.root.width),u={};for(this._getRelevantData(a,u,d,l),this._applySampling(a,u),e=0;ep&&console.log("WARNING: there may be an infinite loop in the _updateGraph emitter cycle."),this.COUNTER=0,this.abortedGraphUpdate=!1,e=0;e0)for(r=0;ro){d.push(h);break}d.push(h)}}else for(a=0;ai&&h.x0)for(var o=0;o0){var s=1,r=n.length,a=this.body.util.toGlobalScreen(n[n.length-1].x)-this.body.util.toGlobalScreen(n[0].x),h=r/a;s=Math.min(Math.ceil(.2*r),Math.max(1,Math.round(h)));for(var d=[],l=0;r>l;l+=s)d.push(n[l]);e[t[o]]=d}}},o.prototype._getYRanges=function(t,e,i){var o,n,s,r,a=[],h=[];if(t.length>0){for(s=0;s0&&(n=this.groups[t[s]],r.stack===!0&&"bar"===r.style?"left"===r.yAxisOrientation?a=a.concat(n.getData(o)):h=h.concat(n.getData(o)):i[t[s]]=n.getYRange(o,t[s]));c.getStackedYRange(a,i,t,"__barStackLeft","left"),c.getStackedYRange(h,i,t,"__barStackRight","right")}},o.prototype._updateYAxis=function(t,e){var i,o,n=!1,s=!1,r=!1,a=1e9,h=1e9,d=-1e9,l=-1e9;if(t.length>0){for(var u=0;ui?i:a,d=o>d?o:d):(r=!0,h=h>i?i:h,l=o>l?o:l));1==s&&this.yAxisLeft.setRange(a,d),1==r&&this.yAxisRight.setRange(h,l)}n=this._toggleAxisVisiblity(s,this.yAxisLeft)||n,n=this._toggleAxisVisiblity(r,this.yAxisRight)||n,1==r&&1==s?(this.yAxisLeft.drawIcons=!0,this.yAxisRight.drawIcons=!0):(this.yAxisLeft.drawIcons=!1,this.yAxisRight.drawIcons=!1),this.yAxisRight.master=!s,0==this.yAxisRight.master?(1==r?this.yAxisLeft.lineOffset=this.yAxisRight.width:this.yAxisLeft.lineOffset=0,n=this.yAxisLeft.redraw()||n,this.yAxisRight.stepPixels=this.yAxisLeft.stepPixels,this.yAxisRight.zeroCrossing=this.yAxisLeft.zeroCrossing,this.yAxisRight.amountOfSteps=this.yAxisLeft.amountOfSteps,n=this.yAxisRight.redraw()||n):n=this.yAxisRight.redraw()||n;for(var p=["__barStackLeft","__barStackRight","__lineStackLeft","__lineStackRight"],u=0;ut?-1:1});for(var a=0;a0&&(t=0),this.range.start=t,this.range.end=e},o.prototype.redraw=function(){var t=!1,e=0;this.dom.lineContainer.style.top=this.body.domProps.scrollTop+"px";for(var i in this.groups)this.groups.hasOwnProperty(i)&&(this.groups[i].visible!==!0||void 0!==this.linegraphOptions.visibility[i]&&this.linegraphOptions.visibility[i]!==!0||e++);if(0===this.amountOfGroups||0===e)this.hide();else{this.show(),this.height=Number(this.linegraphSVG.style.height.replace("px","")),this.dom.lineContainer.style.height=this.height+"px",this.width=this.options.visible===!0?Number((""+this.options.width).replace("px","")):0;var o=this.props,n=this.dom.frame;n.className="vis-data-axis",this._calculateCharSize();var s=this.options.orientation,r=this.options.showMinorLabels,a=this.options.showMajorLabels;o.minorLabelHeight=r?o.minorCharHeight:0,o.majorLabelHeight=a?o.majorCharHeight:0,o.minorLineWidth=this.body.dom.backgroundHorizontal.offsetWidth-this.lineOffset-this.width+2*this.options.minorLinesOffset,o.minorLineHeight=1,o.majorLineWidth=this.body.dom.backgroundHorizontal.offsetWidth-this.lineOffset-this.width+2*this.options.majorLinesOffset,o.majorLineHeight=1,"left"===s?(n.style.top="0",n.style.left="0",n.style.bottom="",n.style.width=this.width+"px",n.style.height=this.height+"px",this.props.width=this.body.domProps.left.width,this.props.height=this.body.domProps.left.height):(n.style.top="",n.style.bottom="0",n.style.left="0",n.style.width=this.width+"px",n.style.height=this.height+"px",this.props.width=this.body.domProps.right.width,this.props.height=this.body.domProps.right.height),t=this._redrawLabels(),t=this._isResized()||t,this.options.icons===!0?this._redrawGroupIcons():this._cleanupIcons(),this._redrawTitle(s)}return t},o.prototype._redrawLabels=function(){var t=!1;s.prepareElements(this.DOMelements.lines),s.prepareElements(this.DOMelements.labels);var e,i=this.options.orientation;if(this.master===!1){var o,n,r,h;-1!==this.zeroCrossing&&this.options.alignZeros===!0?this.range.end>0?(o=this.range.end/this.zeroCrossing,n=this.range.end-this.amountOfSteps*o,r=this.range.end):(o=-1*this.range.start/(this.amountOfSteps-this.zeroCrossing),n=this.range.start,r=this.range.start+o*this.amountOfSteps):(n=this.range.start,r=this.range.end),h=this.stepPixels}else h=this.props.majorCharHeight,n=this.range.start,r=this.range.end;if(this.step=e=new a(n,r,h,this.dom.frame.offsetHeight,this.options[this.options.orientation].range,this.options[this.options.orientation].format,this.master===!1&&this.options.alignZeros),this.master===!0)this.stepPixels=this.dom.frame.offsetHeight/e.marginRange*e.step,this.amountOfSteps=Math.ceil(this.dom.frame.offsetHeight/this.stepPixels);else if(this.options.alignZeros===!0&&-1!==this.zeroCrossing){var d=(e.current-this.zeroCrossing*e.step)/e.step;this.step.shift(d)}this.valueAtBottom=e.marginEnd,this.maxLabelSize=0;for(var l=0,u=0,c=!1;u0&&u!==this.amountOfSteps&&((this.options.showMinorLabels&&c===!1||this.master===!1&&this.options.showMinorLabels===!0)&&this._redrawLabel(l-2,e.getCurrent(),i,"vis-y-axis vis-minor",this.props.minorCharHeight),c&&this.options.showMajorLabels&&this.master===!0||this.options.showMinorLabels===!1&&this.master===!1&&c===!0?(l>=0&&this._redrawLabel(l-2,e.getCurrent(),i,"vis-y-axis vis-major",this.props.majorCharHeight),this._redrawLine(l,i,"vis-grid vis-horizontal vis-major",this.options.majorLinesOffset,this.props.majorLineWidth)):this._redrawLine(l,i,"vis-grid vis-horizontal vis-minor",this.options.minorLinesOffset,this.props.minorLineWidth)),this.master===!0&&0===e.current&&(this.zeroCrossing=u),e.next(),u+=1;this.master===!0&&0===e.current&&(this.zeroCrossing=u),this.conversionFactor=this.stepPixels/e.step;var p=0;void 0!==this.options[i].title&&void 0!==this.options[i].title.text&&(p=this.props.titleCharHeight);var f=this.options.icons===!0?Math.max(this.options.iconWidth,p)+this.options.labelOffsetX+15:p+this.options.labelOffsetX+15;return this.maxLabelSize>this.width-f&&this.options.visible===!0?(this.width=this.maxLabelSize+f,this.options.width=this.width+"px",s.cleanupElements(this.DOMelements.lines),s.cleanupElements(this.DOMelements.labels),this.redraw(),t=!0):this.maxLabelSizethis.minWidth?(this.width=Math.max(this.minWidth,this.maxLabelSize+f),this.options.width=this.width+"px",s.cleanupElements(this.DOMelements.lines),s.cleanupElements(this.DOMelements.labels),this.redraw(),t=!0):(s.cleanupElements(this.DOMelements.lines),s.cleanupElements(this.DOMelements.labels),t=!1),t},o.prototype.convertValue=function(t){var e=this.valueAtBottom-t,i=e*this.conversionFactor;return i},o.prototype.screenToValue=function(t){return this.valueAtBottom-t/this.conversionFactor},o.prototype._redrawLabel=function(t,e,i,o,n){var r=s.getDOMElement("div",this.DOMelements.labels,this.dom.frame);r.className=o,r.innerHTML=e,"left"===i?(r.style.left="-"+this.options.labelOffsetX+"px",r.style.textAlign="right"):(r.style.right="-"+this.options.labelOffsetX+"px",r.style.textAlign="left"),r.style.top=t-.5*n+this.options.labelOffsetY+"px",e+="";var a=Math.max(this.props.majorCharWidth,this.props.minorCharWidth);this.maxLabelSizes&&(h=s);for(var d=!1,l=h;Math.abs(l)<=Math.abs(s);l++){a=Math.pow(10,l);for(var u=0;u=n){d=!0,r=u;break}}if(d===!0)break}this.stepIndex=r,this.scale=a,this.step=a*this.minorSteps[r]},i.prototype.setFirst=function(t){void 0===t&&(t={});var e=void 0===t.min?this._start-2*this.scale*this.minorSteps[this.stepIndex]:t.min,i=void 0===t.max?this._end+this.scale*this.minorSteps[this.stepIndex]:t.max;this.marginEnd=void 0===t.max?this.roundToMinor(i):t.max,this.marginStart=void 0===t.min?this.roundToMinor(e):t.min,this.alignZeros===!0&&(this.marginEnd-this.marginStart)%this.step!=0&&(this.marginEnd+=this.marginEnd%this.step),this.deadSpace=this.roundToMinor(i)-i+this.roundToMinor(e)-e,this.marginRange=this.marginEnd-this.marginStart,this.current=this.marginEnd},i.prototype.roundToMinor=function(t){var e=t-t%(this.scale*this.minorSteps[this.stepIndex]);return t%(this.scale*this.minorSteps[this.stepIndex])>.5*(this.scale*this.minorSteps[this.stepIndex])?e+this.scale*this.minorSteps[this.stepIndex]:e},i.prototype.hasNext=function(){return this.current>=this.marginStart},i.prototype.next=function(){var t=this.current;this.current-=this.step,this.current===t&&(this.current=this._end)},i.prototype.previous=function(){this.current+=this.step,this.marginEnd+=this.step,this.marginRange=this.marginEnd-this.marginStart},i.prototype.getCurrent=function(){var t=Math.abs(this.current)t)for(var e=0;-t>e;e++)this.previous();else if(t>0)for(var e=0;t>e;e++)this.next()},t.exports=i},function(t,e,i){function o(t,e,i,o){this.id=e;var s=["sampling","style","sort","yAxisOrientation","barChart","drawPoints","shaded","interpolation"];this.options=n.selectiveBridgeObject(s,i),this.usingDefaultStyle=void 0===t.className,this.groupsUsingDefaultStyles=o,this.zeroPosition=0,this.update(t),1==this.usingDefaultStyle&&(this.groupsUsingDefaultStyles[0]+=1),this.itemsData=[],this.visible=void 0===t.visible?!0:t.visible}var n=i(1),s=i(7),r=i(54),a=i(56),h=i(55);o.prototype.setItems=function(t){if(null!=t){this.itemsData=t,1==this.options.sort&&this.itemsData.sort(function(t,e){return t.x-e.x});for(var e=0;et[o].y?t[o].y:e,i=i0){t.sort(function(t,e){return t.x===e.x?t.groupIde[s].y?e[s].y:o,n=nt[r].accumulatedNegative?t[r].accumulatedNegative:o,o=o>t[r].accumulatedPositive?t[r].accumulatedPositive:o,n=n0&&(i=Math.min(i,Math.abs(e[o-1].x-e[o].x))),0===i&&(void 0===t[e[o].x]&&(t[e[o].x]={amount:0,resolved:0,accumulatedPositive:0,accumulatedNegative:0}),t[e[o].x].amount+=1)},o.prototype.draw=function(t,e,i){if(null!=t&&t.length>0){var r,a,h=Number(i.svg.style.height.replace("px",""));if(r=n.getSVGElement("path",i.svgElements,i.svg),r.setAttributeNS(null,"class",e.className),void 0!==e.style&&r.setAttributeNS(null,"style",e.style),a=1==e.options.interpolation.enabled?o._catmullRom(t,e):o._linear(t),1==e.options.shaded.enabled){var d,l=n.getSVGElement("path",i.svgElements,i.svg);d="top"==e.options.shaded.orientation?"M"+t[0].x+",0 "+a+"L"+t[t.length-1].x+",0":"M"+t[0].x+","+h+" "+a+"L"+t[t.length-1].x+","+h,l.setAttributeNS(null,"class",e.className+" vis-fill"),void 0!==e.options.shaded.style&&l.setAttributeNS(null,"style",e.options.shaded.style),l.setAttributeNS(null,"d",d)}r.setAttributeNS(null,"d","M"+a),1==e.options.drawPoints.enabled&&s.draw(t,e,i)}},o._catmullRomUniform=function(t){for(var e,i,o,n,s,r,a=Math.round(t[0].x)+","+Math.round(t[0].y)+" ",h=1/6,d=t.length,l=0;d-1>l;l++)e=0==l?t[0]:t[l-1],i=t[l],o=t[l+1],n=d>l+2?t[l+2]:o,s={x:(-e.x+6*i.x+o.x)*h,y:(-e.y+6*i.y+o.y)*h},r={x:(i.x+6*o.x-n.x)*h,y:(i.y+6*o.y-n.y)*h},a+="C"+s.x+","+s.y+" "+r.x+","+r.y+" "+o.x+","+o.y+" ";return a},o._catmullRom=function(t,e){var i=e.options.interpolation.alpha;if(0==i||void 0===i)return this._catmullRomUniform(t);for(var o,n,s,r,a,h,d,l,u,c,p,f,m,v,g,y,b,w,_,x=Math.round(t[0].x)+","+Math.round(t[0].y)+" ",k=t.length,O=0;k-1>O;O++)o=0==O?t[0]:t[O-1],n=t[O],s=t[O+1],r=k>O+2?t[O+2]:s,d=Math.sqrt(Math.pow(o.x-n.x,2)+Math.pow(o.y-n.y,2)),l=Math.sqrt(Math.pow(n.x-s.x,2)+Math.pow(n.y-s.y,2)),u=Math.sqrt(Math.pow(s.x-r.x,2)+Math.pow(s.y-r.y,2)),v=Math.pow(u,i),y=Math.pow(u,2*i),g=Math.pow(l,i),b=Math.pow(l,2*i),_=Math.pow(d,i),w=Math.pow(d,2*i),c=2*w+3*_*g+b,p=2*y+3*v*g+b,f=3*_*(_+g),f>0&&(f=1/f),m=3*v*(v+g),m>0&&(m=1/m),a={x:(-b*o.x+c*n.x+w*s.x)*f,y:(-b*o.y+c*n.y+w*s.y)*f},h={x:(y*n.x+p*s.x-b*r.x)*m,y:(y*n.y+p*s.y-b*r.y)*m},0==a.x&&0==a.y&&(a=n),0==h.x&&0==h.y&&(h=s),x+="C"+a.x+","+a.y+" "+h.x+","+h.y+" "+s.x+","+s.y+" ";return x},o._linear=function(t){for(var e="",i=0;it[o].y?t[o].y:e,i=it[o].y?t[o].y:e,i=i0&&(r=Math.min(r,Math.abs(c[l-1].x-a))),h=o._getSafeDrawData(r,d,m);else{var g=l+(p[a].amount-p[a].resolved),y=l-(p[a].resolved+1);g0&&(r=Math.min(r,Math.abs(c[y].x-a))),h=o._getSafeDrawData(r,d,m),p[a].resolved+=1,d.options.stack===!0?c[l].y0&&(i=Math.min(i,Math.abs(e[o-1].x-e[o].x))),0===i&&(void 0===t[e[o].x]&&(t[e[o].x]={amount:0,resolved:0,accumulatedPositive:0,accumulatedNegative:0}),t[e[o].x].amount+=1)},o._getSafeDrawData=function(t,e,i){var o,n;return t0?(o=i>t?i:t,n=0,"left"===e.options.barChart.align?n-=.5*t:"right"===e.options.barChart.align&&(n+=.5*t)):(o=e.options.barChart.width,n=0,"left"===e.options.barChart.align?n-=.5*e.options.barChart.width:"right"===e.options.barChart.align&&(n+=.5*e.options.barChart.width)),{width:o,offset:n}},o.getStackedYRange=function(t,e,i,n,s){if(t.length>0){t.sort(function(t,e){return t.x===e.x?t.groupIde[s].y?e[s].y:o,n=nt[r].accumulatedNegative?t[r].accumulatedNegative:o,o=o>t[r].accumulatedPositive?t[r].accumulatedPositive:o,n=nt?-1:1});for(var i=0;i")}this.dom.textArea.innerHTML=s,this.dom.textArea.style.lineHeight=.75*this.options.iconSize+this.options.iconSpacing+"px"}},o.prototype.drawLegendIcons=function(){if(this.dom.frame.parentNode){var t=Object.keys(this.groups);t.sort(function(t,e){return e>t?-1:1}),s.prepareElements(this.svgElements);var e=window.getComputedStyle(this.dom.frame).paddingTop,i=Number(e.replace("px","")),o=i,n=this.options.iconSize,r=.75*this.options.iconSize,a=i+.5*r+3;this.svg.style.width=n+5+i+"px";for(var h=0;h0){var i=this.groupIndex%this.groupsArray.length;this.groupIndex++,e={},e.color=this.groups[this.groupsArray[i]],this.groups[t]=e}else{var i=this.defaultIndex%this.defaultGroups.length;this.defaultIndex++,e={},e.color=this.defaultGroups[i],this.groups[t]=e}return e}},{key:"add",value:function(t,e){return this.groups[t]=e,this.groupsArray.push(t),e}}]),t}();e["default"]=r,t.exports=e["default"]},function(t,e,i){function o(t){return t&&t.__esModule?t:{"default":t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var i=0;it.left&&this.shape.topt.top}},{key:"isBoundingBoxOverlappingWith",value:function(t){return this.shape.boundingBox.leftt.left&&this.shape.boundingBox.topt.top}}],[{key:"parseOptions",value:function(t,e){var i=arguments.length<=2||void 0===arguments[2]?!1:arguments[2],o=arguments.length<=3||void 0===arguments[3]?{}:arguments[3],n=["color","font","fixed","shadow"];if(B.selectiveNotDeepExtend(n,t,e,i),B.mergeOptions(t,e,"shadow",i,o),void 0!==e.color&&null!==e.color){var s=B.parseColor(e.color);B.fillIfDefined(t.color,s)}else i===!0&&null===e.color&&(t.color=Object.create(o.color));void 0!==e.fixed&&null!==e.fixed&&("boolean"==typeof e.fixed?(t.fixed.x=e.fixed,t.fixed.y=e.fixed):(void 0!==e.fixed.x&&"boolean"==typeof e.fixed.x&&(t.fixed.x=e.fixed.x),void 0!==e.fixed.y&&"boolean"==typeof e.fixed.y&&(t.fixed.y=e.fixed.y))),void 0!==e.font&&null!==e.font?a["default"].parseOptions(t.font,e):i===!0&&null===e.font&&(t.font=Object.create(o.font)),void 0!==e.scaling&&B.mergeOptions(t.scaling,e.scaling,"label",i,o.scaling)}}]),t}();e["default"]=R,t.exports=e["default"]},function(t,e,i){function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){var i=[],o=!0,n=!1,s=void 0;try{for(var r,a=t[Symbol.iterator]();!(o=(r=a.next()).done)&&(i.push(r.value),!e||i.length!==e);o=!0);}catch(h){n=!0,s=h}finally{try{!o&&a["return"]&&a["return"]()}finally{if(n)throw s}}return i}return function(e,i){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),s=function(){function t(t,e){for(var i=0;i=this.nodeOptions.scaling.label.maxVisible&&(r=Number(this.nodeOptions.scaling.label.maxVisible)/this.body.view.scale);var h=this.size.yLine,d=this._getColor(a),l=n(d,2),u=l[0],c=l[1],p=this._setAlignment(t,i,h,s),f=n(p,2);i=f[0],h=f[1],t.font=(e&&this.nodeOptions.labelHighlightBold?"bold ":"")+r+"px "+this.fontOptions.face,t.fillStyle=u,t.textAlign="center",this.fontOptions.strokeWidth>0&&(t.lineWidth=this.fontOptions.strokeWidth,t.strokeStyle=c,t.lineJoin="round");for(var m=0;m0&&t.strokeText(this.lines[m],i,h),t.fillText(this.lines[m],i,h),h+=r}},{key:"_setAlignment",value:function(t,e,i,o){if("horizontal"!==this.fontOptions.align&&this.pointToSelf===!1){e=0,i=0;var n=2;"top"===this.fontOptions.align?(t.textBaseline="alphabetic",i-=2*n):"bottom"===this.fontOptions.align?(t.textBaseline="hanging",i+=2*n):t.textBaseline="middle"}else t.textBaseline=o;return[e,i]}},{key:"_getColor",value:function(t){var e=this.fontOptions.color||"#000000",i=this.fontOptions.strokeColor||"#ffffff";if(t<=this.nodeOptions.scaling.label.drawThreshold){var o=Math.max(0,Math.min(1,1-(this.nodeOptions.scaling.label.drawThreshold-t)));e=r.overrideOpacity(e,o),i=r.overrideOpacity(i,o)}return[e,i]}},{key:"getTextSize",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?!1:arguments[1],i={width:this._processLabel(t,e),height:this.fontOptions.size*this.lineCount,lineCount:this.lineCount};return i}},{key:"calculateLabelSize",value:function(t,e){var i=arguments.length<=2||void 0===arguments[2]?0:arguments[2],o=arguments.length<=3||void 0===arguments[3]?0:arguments[3],n=arguments.length<=4||void 0===arguments[4]?"middle":arguments[4];this.labelDirty===!0&&(this.size.width=this._processLabel(t,e)),this.size.height=this.fontOptions.size*this.lineCount,this.size.left=i-.5*this.size.width,this.size.top=o-.5*this.size.height,this.size.yLine=o+.5*(1-this.lineCount)*this.fontOptions.size,"hanging"===n&&(this.size.top+=.5*this.fontOptions.size,this.size.top+=4,this.size.yLine+=4),this.labelDirty=!1}},{key:"_processLabel",value:function(t,e){var i=0,o=[""],n=0;if(void 0!==this.nodeOptions.label){o=String(this.nodeOptions.label).split("\n"),n=o.length,t.font=(e&&this.nodeOptions.labelHighlightBold?"bold ":"")+this.fontOptions.size+"px "+this.fontOptions.face,i=t.measureText(o[0]).width;for(var s=1;n>s;s++){var r=t.measureText(o[s]).width;i=r>i?r:i}}return this.lines=o,this.lineCount=n,i}}],[{key:"parseOptions",value:function(t,e){var i=arguments.length<=2||void 0===arguments[2]?!1:arguments[2];if("string"==typeof e.font){var o=e.font.split(" ");t.size=o[0].replace("px",""),t.face=o[1],t.color=o[2]}else"object"==typeof e.font&&r.fillIfDefined(t,e.font,i);t.size=Number(t.size)}}]),t}();e["default"]=a,t.exports=e["default"]},function(t,e,i){function o(t){return t&&t.__esModule?t:{"default":t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var i=0;ithis.imageObj.height?(o=this.imageObj.width/this.imageObj.height,e=2*this.options.size*o||this.imageObj.width,i=2*this.options.size||this.imageObj.height):(o=this.imageObj.width&&this.imageObj.height?this.imageObj.height/this.imageObj.width:1,e=2*this.options.size,i=2*this.options.size*o):(e=this.imageObj.width,i=this.imageObj.height),this.width=e,this.height=i,this.radius=.5*this.width}}},{key:"_drawRawCircle",value:function(t,e,i,o,n,s){var r=this.options.borderWidth,a=this.options.borderWidthSelected||2*this.options.borderWidth;t.strokeStyle=o?this.options.color.highlight.border:n?this.options.color.hover.border:this.options.color.border,t.lineWidth=o?a:r,t.lineWidth*=this.networkScaleInv,t.lineWidth=Math.min(this.width,t.lineWidth),t.fillStyle=o?this.options.color.highlight.background:n?this.options.color.hover.background:this.options.color.background,t.circle(e,i,s),this.enableShadow(t),t.fill(),this.disableShadow(t),t.save(),this.enableBorderDashes(t),t.stroke(),this.disableBorderDashes(t),t.restore()}},{key:"_drawImageAtPosition",value:function(t){0!=this.imageObj.width&&(t.globalAlpha=1,this.enableShadow(t),t.drawImage(this.imageObj,this.left,this.top,this.width,this.height),this.disableShadow(t))}},{key:"_drawImageLabel",value:function(t,e,i,o){var n,s=0;if(void 0!==this.height){s=.5*this.height;var r=this.labelModule.getTextSize(t);r.lineCount>=1&&(s+=r.height/2)}n=i+s,this.options.label&&(this.labelOffset=s),this.labelModule.draw(t,e,n,o,"hanging")}}]),e}(d["default"]);e["default"]=l,t.exports=e["default"]},function(t,e,i){function o(t){return t&&t.__esModule?t:{"default":t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var i=0;i0&&(this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelModule.size.height+3))}}]),e}(d["default"]);e["default"]=l,t.exports=e["default"]},function(t,e,i){function o(t){return t&&t.__esModule?t:{"default":t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var i=0;i0){var i=5;this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelModule.size.height+i)}}},{key:"_icon",value:function(t,e,i,o){var n=Number(this.options.icon.size);void 0!==this.options.icon.code?(t.font=(o?"bold ":"")+n+"px "+this.options.icon.face,t.fillStyle=this.options.icon.color||"black",t.textAlign="center",t.textBaseline="middle",this.enableShadow(t),t.fillText(this.options.icon.code,e,i),this.disableShadow(t)):console.error("When using the icon shape, you need to define the code in the icon options object. This can be done per node or globally.")}},{key:"distanceToBorder",value:function(t,e){return this._distanceToBorder(t,e)}}]),e}(d["default"]);e["default"]=l,t.exports=e["default"]},function(t,e,i){function o(t){return t&&t.__esModule?t:{"default":t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var i=0;i0&&(this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelOffset))}},{key:"distanceToBorder",value:function(t,e){this.resize(t);var i=this.width/2,o=this.height/2,n=Math.sin(e)*i,s=Math.cos(e)*o;return i*o/Math.sqrt(n*n+s*s)}}]),e}(d["default"]);e["default"]=l,t.exports=e["default"]},function(t,e,i){function o(t){return t&&t.__esModule?t:{"default":t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var i=0;ii.shape.height?(r=i.x+.5*i.shape.width,a=i.y-h):(r=i.x+h,a=i.y-.5*i.shape.height),s=this._pointOnCircle(r,a,h,.125),this.labelModule.draw(t,s.x,s.y,n)}}}},{key:"isOverlappingWith",value:function(t){if(this.connected){var e=10,i=this.from.x,o=this.from.y,n=this.to.x,s=this.to.y,r=t.left,a=t.top,h=this.edgeType.getDistanceToEdge(i,o,n,s,r,a);return e>h}return!1}},{key:"_rotateForLabelAlignment",value:function(t){var e=this.from.y-this.to.y,i=this.from.x-this.to.x,o=Math.atan2(e,i);(-1>o&&0>i||o>0&&0>i)&&(o+=Math.PI),t.rotate(o)}},{key:"_pointOnCircle",value:function(t,e,i,o){var n=2*o*Math.PI;return{x:t+i*Math.cos(n),y:e-i*Math.sin(n)}}},{key:"select",value:function(){this.selected=!0}},{key:"unselect",value:function(){this.selected=!1}},{key:"cleanup",value:function(){return this.edgeType.cleanup()}}],[{key:"parseOptions",value:function(t,e){var i=arguments.length<=2||void 0===arguments[2]?!1:arguments[2],o=arguments.length<=3||void 0===arguments[3]?{}:arguments[3],n=["id","from","hidden","hoverWidth","label","labelHighlightBold","length","line","opacity","physics","scaling","selectionWidth","selfReferenceSize","to","title","value","width"];if(v.selectiveDeepExtend(n,t,e,i),v.mergeOptions(t,e,"smooth",i,o),v.mergeOptions(t,e,"shadow",i,o),void 0!==e.dashes&&null!==e.dashes?t.dashes=e.dashes:i===!0&&null===e.dashes&&(t.dashes=Object.create(o.dashes)),void 0!==e.scaling&&null!==e.scaling?(void 0!==e.scaling.min&&(t.scaling.min=e.scaling.min),void 0!==e.scaling.max&&(t.scaling.max=e.scaling.max),v.mergeOptions(t.scaling,e.scaling,"label",i,o.scaling)):i===!0&&null===e.scaling&&(t.scaling=Object.create(o.scaling)),void 0!==e.arrows&&null!==e.arrows)if("string"==typeof e.arrows){var s=e.arrows.toLowerCase();-1!=s.indexOf("to")&&(t.arrows.to.enabled=!0),-1!=s.indexOf("middle")&&(t.arrows.middle.enabled=!0),-1!=s.indexOf("from")&&(t.arrows.from.enabled=!0)}else{if("object"!=typeof e.arrows)throw new Error("The arrow newOptions can only be an object or a string. Refer to the documentation. You used:"+JSON.stringify(e.arrows));v.mergeOptions(t.arrows,e.arrows,"to",i,o.arrows),v.mergeOptions(t.arrows,e.arrows,"middle",i,o.arrows),v.mergeOptions(t.arrows,e.arrows,"from",i,o.arrows)}else i===!0&&null===e.arrows&&(t.arrows=Object.create(o.arrows));if(void 0!==e.color&&null!==e.color)if(v.isString(e.color))t.color.color=e.color,t.color.highlight=e.color,t.color.hover=e.color,t.color.inherit=!1;else{var r=!1;void 0!==e.color.color&&(t.color.color=e.color.color,r=!0),void 0!==e.color.highlight&&(t.color.highlight=e.color.highlight,r=!0),void 0!==e.color.hover&&(t.color.hover=e.color.hover,r=!0),void 0!==e.color.inherit&&(t.color.inherit=e.color.inherit),void 0!==e.color.opacity&&(t.color.opacity=Math.min(1,Math.max(0,e.color.opacity))),void 0===e.color.inherit&&r===!0&&(t.color.inherit=!1)}else i===!0&&null===e.color&&(t.color=Object.create(o.color));void 0!==e.font&&null!==e.font?a["default"].parseOptions(t.font,e):i===!0&&null===e.font&&(t.font=Object.create(o.font))}}]),t}();e["default"]=g,t.exports=e["default"]},function(t,e,i){function o(t){return t&&t.__esModule?t:{"default":t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){var i=[],o=!0,n=!1,s=void 0;try{for(var r,a=t[Symbol.iterator]();!(o=(r=a.next()).done)&&(i.push(r.value),!e||i.length!==e);o=!0);}catch(h){n=!0,s=h}finally{try{!o&&a["return"]&&a["return"]()}finally{if(n)throw s}}return i}return function(e,i){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),a=function(){function t(t,e){for(var i=0;iMath.abs(e)||this.options.smooth.forceDirection===!0||"horizontal"===this.options.smooth.forceDirection)&&"vertical"!==this.options.smooth.forceDirection?(o=this.from.y,s=this.to.y,i=this.from.x-r*t,n=this.to.x+r*t):(o=this.from.y-r*e,s=this.to.y+r*e,i=this.from.x,n=this.to.x),[{x:i,y:o},{x:n,y:s}]}},{key:"_findBorderPosition",value:function(t,e){return this._findBorderPositionBezier(t,e)}},{key:"_getDistanceToEdge",value:function(t,e,i,o,n,s){var a=arguments.length<=6||void 0===arguments[6]?this._getViaCoordinates():arguments[6],h=r(a,2),d=h[0],l=h[1];return this._getDistanceToBezierEdge(t,e,i,o,n,s,d,l)}},{key:"getPoint",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?this._getViaCoordinates():arguments[1],i=r(e,2),o=i[0],n=i[1],s=t,a=[];a[0]=Math.pow(1-s,3),a[1]=3*s*Math.pow(1-s,2),a[2]=3*Math.pow(s,2)*(1-s),a[3]=Math.pow(s,3);var h=a[0]*this.from.x+a[1]*o.x+a[2]*n.x+a[3]*this.to.x,d=a[0]*this.from.y+a[1]*o.y+a[2]*n.y+a[3]*this.to.y;return{x:h,y:d}}}]),e}(l["default"]);e["default"]=u,t.exports=e["default"]},function(t,e,i){function o(t){return t&&t.__esModule?t:{"default":t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var i=0;il;l++)u=.1*l,v[0]=Math.pow(1-u,3),v[1]=3*u*Math.pow(1-u,2),v[2]=3*Math.pow(u,2)*(1-u),v[3]=Math.pow(u,3),c=v[0]*t+v[1]*r.x+v[2]*a.x+v[3]*i,p=v[0]*e+v[1]*r.y+v[2]*a.y+v[3]*o,l>0&&(d=this._getDistanceToLine(f,m,c,p,n,s),h=h>d?d:h),f=c,m=p;return h}}]),e}(d["default"]);e["default"]=l,t.exports=e["default"]},function(t,e,i){function o(t){return t&&t.__esModule?t:{"default":t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var i=0;i=l&&h>d;){var m=.5*(l+u);if(i=this.getPoint(m,a),o=Math.atan2(p.y-i.y,p.x-i.x),n=p.distanceToBorder(e,o),s=Math.sqrt(Math.pow(i.x-p.x,2)+Math.pow(i.y-p.y,2)),r=n-s,Math.abs(r)r?f===!1?l=m:u=m:f===!1?u=m:l=m,d++}return i.t=m,i}},{key:"_getDistanceToBezierEdge",value:function(t,e,i,o,n,s,r){var a=1e9,h=void 0,d=void 0,l=void 0,u=void 0,c=void 0,p=t,f=e;for(d=1;10>d;d++)l=.1*d,u=Math.pow(1-l,2)*t+2*l*(1-l)*r.x+Math.pow(l,2)*i,c=Math.pow(1-l,2)*e+2*l*(1-l)*r.y+Math.pow(l,2)*o,d>0&&(h=this._getDistanceToLine(p,f,u,c,n,s),a=a>h?h:a),p=u,f=c;return a}}]),e}(d["default"]);e["default"]=l,t.exports=e["default"]},function(t,e,i){function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){var i=[],o=!0,n=!1,s=void 0;try{for(var r,a=t[Symbol.iterator]();!(o=(r=a.next()).done)&&(i.push(r.value),!e||i.length!==e);o=!0);}catch(h){n=!0,s=h}finally{try{!o&&a["return"]&&a["return"]()}finally{if(n)throw s}}return i}return function(e,i){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),s=function(){function t(t,e){for(var i=0;io.shape.height?(e=o.x+.5*o.shape.width,i=o.y-n):(e=o.x+n,i=o.y-.5*o.shape.height),[e,i,n]}},{key:"_pointOnCircle",value:function(t,e,i,o){var n=2*o*Math.PI;return{x:t+i*Math.cos(n),y:e-i*Math.sin(n)}}},{key:"_findBorderPositionCircle",value:function(t,e,i){for(var o=i.x,n=i.y,s=i.low,r=i.high,a=i.direction,h=10,d=0,l=this.options.selfReferenceSize,u=void 0,c=void 0,p=void 0,f=void 0,m=void 0,v=.05,g=.5*(s+r);r>=s&&h>d&&(g=.5*(s+r),u=this._pointOnCircle(o,n,l,g),c=Math.atan2(t.y-u.y,t.x-u.x),p=t.distanceToBorder(e,c),f=Math.sqrt(Math.pow(u.x-t.x,2)+Math.pow(u.y-t.y,2)),m=p-f,!(Math.abs(m)0?a>0?s=g:r=g:a>0?r=g:s=g,d++;return u.t=g,u}},{key:"getLineWidth",value:function(t,e){return t===!0?Math.max(this.selectionWidth,.3/this.body.view.scale):e===!0?Math.max(this.hoverWidth,.3/this.body.view.scale):Math.max(this.options.width,.3/this.body.view.scale)}},{key:"getColor",value:function(t,e,i){var o=this.options.color;if(o.inherit!==!1){if("both"===o.inherit&&this.from.id!==this.to.id){var n=t.createLinearGradient(this.from.x,this.from.y,this.to.x,this.to.y),s=void 0,a=void 0;return s=this.from.options.color.highlight.border,a=this.to.options.color.highlight.border,this.from.selected===!1&&this.to.selected===!1?(s=r.overrideOpacity(this.from.options.color.border,this.options.color.opacity),a=r.overrideOpacity(this.to.options.color.border,this.options.color.opacity)):this.from.selected===!0&&this.to.selected===!1?a=this.to.options.color.border:this.from.selected===!1&&this.to.selected===!0&&(s=this.from.options.color.border),n.addColorStop(0,s),n.addColorStop(1,a),n}this.colorDirty===!0&&("to"===o.inherit?(this.color.highlight=this.to.options.color.highlight.border,this.color.hover=this.to.options.color.hover.border,this.color.color=r.overrideOpacity(this.to.options.color.border,o.opacity)):(this.color.highlight=this.from.options.color.highlight.border,this.color.hover=this.from.options.color.hover.border,this.color.color=r.overrideOpacity(this.from.options.color.border,o.opacity)))}else this.colorDirty===!0&&(this.color.highlight=o.highlight,this.color.hover=o.hover,this.color.color=r.overrideOpacity(o.color,o.opacity));return this.colorDirty=!1,e===!0?this.color.highlight:i===!0?this.color.hover:this.color.color}},{key:"_circle",value:function(t,e,i,o){this.enableShadow(t),t.beginPath(),t.arc(e,i,o,0,2*Math.PI,!1),t.stroke(),this.disableShadow(t)}},{key:"getDistanceToEdge",value:function(t,e,i,o,s,r,a){var h=0;if(this.from!=this.to)h=this._getDistanceToEdge(t,e,i,o,s,r,a);else{var d=this._getCircleData(),l=n(d,3),u=l[0],c=l[1],p=l[2],f=u-s,m=c-r;h=Math.abs(Math.sqrt(f*f+m*m)-p)}return this.labelModule.size.lefts&&this.labelModule.size.topr?0:h}},{key:"_getDistanceToLine",value:function(t,e,i,o,n,s){var r=i-t,a=o-e,h=r*r+a*a,d=((n-t)*r+(s-e)*a)/h;d>1?d=1:0>d&&(d=0);var l=t+d*r,u=e+d*a,c=l-n,p=u-s;return Math.sqrt(c*c+p*p)}},{key:"drawArrowHead",value:function(t,e,i,o,s){t.strokeStyle=this.getColor(t,o,s),t.fillStyle=t.strokeStyle,t.lineWidth=this.getLineWidth(o,s);var r=void 0,a=void 0,h=void 0,d=void 0,l=void 0,u=void 0,c=void 0;if("from"===e?(d=this.from,l=this.to,u=.1,c=this.options.arrows.from.scaleFactor):"to"===e?(d=this.to,l=this.from,u=-.1,c=this.options.arrows.to.scaleFactor):(d=this.to,l=this.from,c=this.options.arrows.middle.scaleFactor),d!=l){if("middle"!==e)if(this.options.smooth.enabled===!0){h=this.findBorderPosition(d,t,{via:i});var p=this.getPoint(Math.max(0,Math.min(1,h.t+u)),i);r=Math.atan2(h.y-p.y,h.x-p.x)}else r=Math.atan2(d.y-l.y,d.x-l.x),h=this.findBorderPosition(d,t);else r=Math.atan2(d.y-l.y,d.x-l.x),h=this.getPoint(.6,i);a=(10+5*this.options.width)*c,t.arrow(h.x,h.y,r,a),this.enableShadow(t),t.fill(),this.disableShadow(t),t.stroke()}else{var f=void 0,m=void 0,v=this._getCircleData(t),g=n(v,3),y=g[0],b=g[1],w=g[2];"from"===e?(m=this.findBorderPosition(this.from,t,{x:y,y:b,low:.25,high:.6,direction:-1}),f=-2*m.t*Math.PI+1.5*Math.PI+.1*Math.PI):"to"===e?(m=this.findBorderPosition(this.from,t,{x:y,y:b,low:.6,high:1,direction:1}),f=-2*m.t*Math.PI+1.5*Math.PI-1.1*Math.PI):(m=this._pointOnCircle(y,b,w,.175),f=3.9269908169872414);var _=(10+5*this.options.width)*c;t.arrow(m.x,m.y,f,_),this.enableShadow(t),t.fill(),this.disableShadow(t),t.stroke()}}},{key:"enableShadow",value:function(t){this.options.shadow.enabled===!0&&(t.shadowColor="rgba(0,0,0,0.5)",t.shadowBlur=this.options.shadow.size,t.shadowOffsetX=this.options.shadow.x,t.shadowOffsetY=this.options.shadow.y)}},{key:"disableShadow",value:function(t){this.options.shadow.enabled===!0&&(t.shadowColor="rgba(0,0,0,0)",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0)}}]),t}();e["default"]=a,t.exports=e["default"]},function(t,e,i){function o(t){return t&&t.__esModule?t:{"default":t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var i=0;i=this.to.y?this.from.x<=this.to.x?(t=this.from.x+i*s,e=this.from.y-i*s):this.from.x>this.to.x&&(t=this.from.x-i*s,e=this.from.y-i*s):this.from.ythis.to.x&&(t=this.from.x-i*s,e=this.from.y+i*s)),"discrete"===o&&(t=i*s>n?this.from.x:t)):Math.abs(this.from.x-this.to.x)>Math.abs(this.from.y-this.to.y)&&(this.from.y>=this.to.y?this.from.x<=this.to.x?(t=this.from.x+i*n,e=this.from.y-i*n):this.from.x>this.to.x&&(t=this.from.x-i*n,e=this.from.y-i*n):this.from.ythis.to.x&&(t=this.from.x-i*n,e=this.from.y+i*n)),"discrete"===o&&(e=i*n>s?this.from.y:e));else if("straightCross"===o)Math.abs(this.from.x-this.to.x)<=Math.abs(this.from.y-this.to.y)?(t=this.from.x,e=this.from.yMath.abs(this.from.y-this.to.y)&&(t=this.from.x=this.to.y?this.from.x<=this.to.x?(t=this.from.x+i*s,e=this.from.y-i*s,t=this.to.xthis.to.x&&(t=this.from.x-i*s,e=this.from.y-i*s,t=this.to.x>t?this.to.x:t):this.from.ythis.to.x&&(t=this.from.x-i*s,e=this.from.y+i*s,t=this.to.x>t?this.to.x:t)):Math.abs(this.from.x-this.to.x)>Math.abs(this.from.y-this.to.y)&&(this.from.y>=this.to.y?this.from.x<=this.to.x?(t=this.from.x+i*n,e=this.from.y-i*n,e=this.to.y>e?this.to.y:e):this.from.x>this.to.x&&(t=this.from.x-i*n,e=this.from.y-i*n,e=this.to.y>e?this.to.y:e):this.from.ythis.to.x&&(t=this.from.x-i*n,e=this.from.y+i*n,e=this.to.y1||this.startedStabilization===!0)&&setTimeout(function(){t.body.emitter.emit("stabilized",{iterations:e}),t.startedStabilization=!1,t.stabilizationIterations=0},0)}},{key:"physicsTick",value:function(){if(this.startedStabilization===!1&&(this.body.emitter.emit("startStabilizing"),this.startedStabilization=!0),this.stabilized===!1){if(this.adaptiveTimestep===!0&&this.adaptiveTimestepEnabled===!0){var t=1.2;this.adaptiveCounter%this.adaptiveInterval===0?(this.timestep=2*this.timestep,this.calculateForces(),this.moveNodes(),this.revert(),this.timestep=.5*this.timestep,this.calculateForces(),this.moveNodes(),this.calculateForces(),this.moveNodes(),this._evaluateStepQuality()===!0?this.timestep=t*this.timestep:this.timestep/ts))return!1;return!0}},{key:"moveNodes",value:function(){for(var t=this.physicsBody.physicsNodeIndices,e=this.options.maxVelocity?this.options.maxVelocity:1e9,i=0,o=0,n=5,s=0;se?s[t].x>0?e:-e:s[t].x,i.x+=s[t].x*o}else n[t].x=0,s[t].x=0;if(i.options.fixed.y===!1){var h=this.modelOptions.damping*s[t].y,d=(n[t].y-h)/i.options.mass;s[t].y+=d*o,s[t].y=Math.abs(s[t].y)>e?s[t].y>0?e:-e:s[t].y,i.y+=s[t].y*o}else n[t].y=0,s[t].y=0;var l=Math.sqrt(Math.pow(s[t].x,2)+Math.pow(s[t].y,2));return l}},{key:"calculateForces",value:function(){this.gravitySolver.solve(),this.nodesSolver.solve(),this.edgesSolver.solve()}},{key:"_freezeNodes",value:function(){var t=this.body.nodes;for(var e in t)t.hasOwnProperty(e)&&t[e].x&&t[e].y&&(this.freezeCache[e]={x:t[e].options.fixed.x,y:t[e].options.fixed.y},t[e].options.fixed.x=!0,t[e].options.fixed.y=!0)}},{key:"_restoreFrozenNodes",value:function(){var t=this.body.nodes;for(var e in t)t.hasOwnProperty(e)&&void 0!==this.freezeCache[e]&&(t[e].options.fixed.x=this.freezeCache[e].x,t[e].options.fixed.y=this.freezeCache[e].y);this.freezeCache={}}},{key:"stabilize",value:function(){var t=this,e=arguments.length<=0||void 0===arguments[0]?this.options.stabilization.iterations:arguments[0];return"number"!=typeof e&&(console.log("The stabilize method needs a numeric amount of iterations. Switching to default: ",this.options.stabilization.iterations),e=this.options.stabilization.iterations),0===this.physicsBody.physicsNodeIndices.length?void(this.ready=!0):(this.adaptiveTimestep=this.options.adaptiveTimestep,this.body.emitter.emit("_resizeNodes"),this.stopSimulation(),this.stabilized=!1,this.body.emitter.emit("_blockRedraw"),this.targetIterations=e,this.options.stabilization.onlyDynamicEdges===!0&&this._freezeNodes(),this.stabilizationIterations=0,void setTimeout(function(){return t._stabilizationBatch()},0))}},{key:"_stabilizationBatch",value:function(){this.startedStabilization===!1&&(this.body.emitter.emit("startStabilizing"),this.startedStabilization=!0);for(var t=0;this.stabilized===!1&&t0){var t=void 0,e=this.body.nodes,i=this.physicsBody.physicsNodeIndices,o=i.length,n=this._formBarnesHutTree(e,i);this.barnesHutTree=n;for(var s=0;o>s;s++)t=e[i[s]],t.options.mass>0&&(this._getForceContribution(n.root.children.NW,t),this._getForceContribution(n.root.children.NE,t),this._getForceContribution(n.root.children.SW,t),this._getForceContribution(n.root.children.SE,t))}}},{key:"_getForceContribution",value:function(t,e){if(t.childrenCount>0){var i=void 0,o=void 0,n=void 0;i=t.centerOfMass.x-e.x,o=t.centerOfMass.y-e.y,n=Math.sqrt(i*i+o*o),n*t.calcSize>this.thetaInversed?this._calculateForces(n,i,o,e,t):4===t.childrenCount?(this._getForceContribution(t.children.NW,e),this._getForceContribution(t.children.NE,e),this._getForceContribution(t.children.SW,e),this._getForceContribution(t.children.SE,e)):t.children.data.id!=e.id&&this._calculateForces(n,i,o,e,t)}}},{key:"_calculateForces",value:function(t,e,i,o,n){0===t&&(t=.1,e=t),this.overlapAvoidanceFactor<1&&(t=Math.max(.1+this.overlapAvoidanceFactor*o.shape.radius,t-o.shape.radius));var s=this.options.gravitationalConstant*n.mass*o.options.mass/Math.pow(t,3),r=e*s,a=i*s;this.physicsBody.forces[o.id].x+=r,this.physicsBody.forces[o.id].y+=a}},{key:"_formBarnesHutTree",value:function(t,e){for(var i=void 0,o=e.length,n=t[e[0]].x,s=t[e[0]].y,r=t[e[0]].x,a=t[e[0]].y,h=1;o>h;h++){var d=t[e[h]].x,l=t[e[h]].y;t[e[h]].options.mass>0&&(n>d&&(n=d),d>r&&(r=d),s>l&&(s=l),l>a&&(a=l))}var u=Math.abs(r-n)-Math.abs(a-s);u>0?(s-=.5*u,a+=.5*u):(n+=.5*u,r-=.5*u);var c=1e-5,p=Math.max(c,Math.abs(r-n)),f=.5*p,m=.5*(n+r),v=.5*(s+a),g={root:{centerOfMass:{x:0,y:0},mass:0,range:{minX:m-f,maxX:m+f,minY:v-f,maxY:v+f},size:p,calcSize:1/p,children:{data:null},maxWidth:0,level:0,childrenCount:4}};this._splitBranch(g.root);for(var h=0;o>h;h++)i=t[e[h]],i.options.mass>0&&this._placeInTree(g.root,i);return g}},{key:"_updateBranchMass",value:function(t,e){var i=t.mass+e.options.mass,o=1/i;t.centerOfMass.x=t.centerOfMass.x*t.mass+e.x*e.options.mass,t.centerOfMass.x*=o,t.centerOfMass.y=t.centerOfMass.y*t.mass+e.y*e.options.mass,t.centerOfMass.y*=o,t.mass=i;var n=Math.max(Math.max(e.height,e.radius),e.width);t.maxWidth=t.maxWidthe.x?t.children.NW.range.maxY>e.y?this._placeInRegion(t,e,"NW"):this._placeInRegion(t,e,"SW"):t.children.NW.range.maxY>e.y?this._placeInRegion(t,e,"NE"):this._placeInRegion(t,e,"SE")}},{key:"_placeInRegion",value:function(t,e,i){switch(t.children[i].childrenCount){case 0:t.children[i].children.data=e,t.children[i].childrenCount=1,this._updateBranchMass(t.children[i],e);break;case 1:t.children[i].children.data.x===e.x&&t.children[i].children.data.y===e.y?(e.x+=this.seededRandom(),e.y+=this.seededRandom()):(this._splitBranch(t.children[i]),this._placeInTree(t.children[i],e));break;case 4:this._placeInTree(t.children[i],e)}}},{key:"_splitBranch",value:function(t){var e=null;1===t.childrenCount&&(e=t.children.data,t.mass=0,t.centerOfMass.x=0,t.centerOfMass.y=0),t.childrenCount=4,t.children.data=null,this._insertRegion(t,"NW"),this._insertRegion(t,"NE"),this._insertRegion(t,"SW"),this._insertRegion(t,"SE"),null!=e&&this._placeInTree(t,e)}},{key:"_insertRegion",value:function(t,e){var i=void 0,o=void 0,n=void 0,s=void 0,r=.5*t.size;switch(e){case"NW":i=t.range.minX,o=t.range.minX+r,n=t.range.minY,s=t.range.minY+r;break;case"NE":i=t.range.minX+r,o=t.range.maxX,n=t.range.minY,s=t.range.minY+r;break;case"SW":i=t.range.minX,o=t.range.minX+r,n=t.range.minY+r,s=t.range.maxY;break;case"SE":i=t.range.minX+r,o=t.range.maxX,n=t.range.minY+r,s=t.range.maxY}t.children[e]={centerOfMass:{x:0,y:0},mass:0,range:{minX:i,maxX:o,minY:n,maxY:s},size:.5*t.size,calcSize:2*t.calcSize,children:{data:null},maxWidth:0,level:t.level+1,childrenCount:0}}},{key:"_debug",value:function(t,e){void 0!==this.barnesHutTree&&(t.lineWidth=1,this._drawBranch(this.barnesHutTree.root,t,e))}},{key:"_drawBranch",value:function(t,e,i){void 0===i&&(i="#FF0000"),4===t.childrenCount&&(this._drawBranch(t.children.NW,e),this._drawBranch(t.children.NE,e),this._drawBranch(t.children.SE,e),this._drawBranch(t.children.SW,e)),e.strokeStyle=i,e.beginPath(),e.moveTo(t.range.minX,t.range.minY),e.lineTo(t.range.maxX,t.range.minY),e.stroke(),e.beginPath(),e.moveTo(t.range.maxX,t.range.minY),e.lineTo(t.range.maxX,t.range.maxY),e.stroke(),e.beginPath(),e.moveTo(t.range.maxX,t.range.maxY),e.lineTo(t.range.minX,t.range.maxY),e.stroke(),e.beginPath(),e.moveTo(t.range.minX,t.range.maxY),e.lineTo(t.range.minX,t.range.minY),e.stroke()}}]),t}();e["default"]=n,t.exports=e["default"]},function(t,e){function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;ii&&(s=.5*u>i?1:c*i+p,s/=i,o=t*s,n=e*s,l[r.id].x-=o,l[r.id].y-=n,l[a.id].x+=o,l[a.id].y+=n)}}}]),t}();e["default"]=n,t.exports=e["default"]},function(t,e){function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;ii?-Math.pow(f*i,2)+Math.pow(f*p,2):0,0===i?i=.01:s/=i,o=t*s,n=e*s,c[r.id].x-=o,c[r.id].y-=n,c[a.id].x+=o,c[a.id].y+=n}}}]),t}();e["default"]=n,t.exports=e["default"]},function(t,e){function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;i0){var s=n.edges.length+1,r=this.options.centralGravity*s*n.options.mass;o[n.id].x=e*r,o[n.id].y=i*r}}}]),e}(d["default"]);e["default"]=l,t.exports=e["default"]},function(t,e,i){function o(t){return t&&t.__esModule?t:{"default":t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var i=0;i=t&&i.push(n.id)}for(var o=0;o0&&Object.keys(c).length>0&&f===!0&&o.push({nodes:u,edges:c})}}}for(var l=0;lo?r.x:o,n=r.ys?r.y:s;return{x:.5*(i+o),y:.5*(n+s)}}},{key:"openCluster",value:function(t,e){var i=arguments.length<=2||void 0===arguments[2]?!0:arguments[2];if(void 0===t)throw new Error("No clusterNodeId supplied to openCluster.");if(void 0===this.body.nodes[t])throw new Error("The clusterNodeId supplied to openCluster does not exist.");if(void 0===this.body.nodes[t].containedNodes)return void console.log("The node:"+t+" is not a cluster.");var o=this.body.nodes[t],n=o.containedNodes,s=o.containedEdges;if(void 0!==e&&void 0!==e.releaseFunction&&"function"==typeof e.releaseFunction){var r={},a={x:o.x,y:o.y};for(var d in n)if(n.hasOwnProperty(d)){var l=this.body.nodes[d];r[d]={x:l.x,y:l.y}}var u=e.releaseFunction(a,r);for(var d in n)if(n.hasOwnProperty(d)){var l=this.body.nodes[d];void 0!==u[d]&&(l.x=void 0===u[d].x?o.x:u[d].x,l.y=void 0===u[d].y?o.y:u[d].y)}}else for(var d in n)if(n.hasOwnProperty(d)){var l=this.body.nodes[d];l=n[d],l.x=o.x,l.y=o.y}for(var d in n)if(n.hasOwnProperty(d)){var l=this.body.nodes[d];l.vx=o.vx,l.vy=o.vy,l.setOptions({hidden:!1,physics:!0}),delete this.clusteredNodes[d]}for(var c=[],p=0;po;)e.push(this.clusteredNodes[t].node),t=this.clusteredNodes[t].clusterId,o++;return e.push(this.body.nodes[t]),e}},{key:"_getConnectedId",value:function(t,e){return t.toId!=e?t.toId:t.fromId!=e?t.fromId:t.fromId}},{key:"_getHubSize",value:function(){for(var t=0,e=0,i=0,o=0,n=0;no&&(o=s.edges.length),t+=s.edges.length,e+=Math.pow(s.edges.length,2),i+=1}t/=i,e/=i;var r=e-Math.pow(t,2),a=Math.sqrt(r),h=Math.floor(t+2*a);return h>o&&(h=o),h}}]),t}();e["default"]=d,t.exports=e["default"]},function(t,e,i){function o(t){return t&&t.__esModule?t:{"default":t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var r=function(t,e,i){for(var o=!0;o;){var n=t,s=e,r=i;a=d=h=void 0,o=!1,null===n&&(n=Function.prototype);var a=Object.getOwnPropertyDescriptor(n,s);if(void 0!==a){if("value"in a)return a.value;var h=a.get;return void 0===h?void 0:h.call(r)}var d=Object.getPrototypeOf(n);if(null===d)return void 0;t=d,e=s,i=r,o=!0}},a=i(62),h=o(a),d=function(t){function e(t,i,o,s,a){n(this,e),r(Object.getPrototypeOf(e.prototype),"constructor",this).call(this,t,i,o,s,a),this.isCluster=!0,this.containedNodes={},this.containedEdges={}}return s(e,t),e}(h["default"]);e["default"]=d,t.exports=e["default"]},function(t,e,i){function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){for(var i=0;i0,t.renderTimer=void 0}),this.body.emitter.on("destroy",function(){t.renderRequests=0,t.allowRedraw=!1,t.renderingActive=!1,t.requiresTimeout===!0?clearTimeout(t.renderTimer):cancelAnimationFrame(t.renderTimer),t.body.emitter.off()})}},{key:"setOptions",value:function(t){if(void 0!==t){var e=["hideEdgesOnDrag","hideNodesOnDrag"];s.selectiveDeepExtend(e,this.options,t)}}},{key:"_startRendering",value:function(){this.renderingActive===!0&&void 0===this.renderTimer&&(this.requiresTimeout===!0?this.renderTimer=window.setTimeout(this._renderStep.bind(this),this.simulationInterval):this.renderTimer=window.requestAnimationFrame(this._renderStep.bind(this)))}},{key:"_renderStep",value:function(){this.renderingActive===!0&&(this.renderTimer=void 0,this.requiresTimeout===!0&&this._startRendering(),this._redraw(),this.requiresTimeout===!1&&this._startRendering())}},{key:"redraw",value:function(){this.body.emitter.emit("setSize"),this._redraw()}},{key:"_requestRedraw",value:function(){var t=this;this.redrawRequested!==!0&&this.renderingActive===!1&&this.allowRedraw===!0&&(this.redrawRequested=!0,this.requiresTimeout===!0?window.setTimeout(function(){t._redraw(!1)},0):window.requestAnimationFrame(function(){t._redraw(!1)}))}},{key:"_redraw",value:function(){var t=arguments.length<=0||void 0===arguments[0]?!1:arguments[0];if(this.allowRedraw===!0){this.body.emitter.emit("initRedraw"),this.redrawRequested=!1;var e=this.canvas.frame.canvas.getContext("2d");(0===this.canvas.frame.canvas.width||0===this.canvas.frame.canvas.height)&&this.canvas.setSize(),this.pixelRatio=(window.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1),e.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0);var i=this.canvas.frame.canvas.clientWidth,o=this.canvas.frame.canvas.clientHeight;if(e.clearRect(0,0,i,o),0===this.canvas.frame.clientWidth)return;e.save(),e.translate(this.body.view.translation.x,this.body.view.translation.y),e.scale(this.body.view.scale,this.body.view.scale),e.beginPath(),this.body.emitter.emit("beforeDrawing",e),e.closePath(),t===!1&&(this.dragging===!1||this.dragging===!0&&this.options.hideEdgesOnDrag===!1)&&this._drawEdges(e),(this.dragging===!1||this.dragging===!0&&this.options.hideNodesOnDrag===!1)&&this._drawNodes(e,t),this.controlNodesActive===!0&&this._drawControlNodes(e),e.beginPath(),this.body.emitter.emit("afterDrawing",e),e.closePath(),e.restore(),t===!0&&e.clearRect(0,0,i,o)}}},{key:"_resizeNodes",value:function(){var t=this.canvas.frame.canvas.getContext("2d");void 0===this.pixelRatio&&(this.pixelRatio=(window.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)),t.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0),t.save(),t.translate(this.body.view.translation.x,this.body.view.translation.y),t.scale(this.body.view.scale,this.body.view.scale);var e=this.body.nodes,i=void 0;for(var o in e)e.hasOwnProperty(o)&&(i=e[o],i.resize(t),i.updateBoundingBox(t,i.selected));t.restore()}},{key:"_drawNodes",value:function(t){for(var e=arguments.length<=1||void 0===arguments[1]?!1:arguments[1],i=this.body.nodes,o=this.body.nodeIndices,n=void 0,s=[],r=20,a=this.canvas.DOMtoCanvas({x:-r,y:-r}),h=this.canvas.DOMtoCanvas({x:this.canvas.frame.canvas.clientWidth+r,y:this.canvas.frame.canvas.clientHeight+r -}),d={top:a.y,left:a.x,bottom:h.y,right:h.x},l=0;l0){this.body.view.scale=this.cameraState.scale*Math.min(this.frame.canvas.width/this.pixelRatio/this.cameraState.previousWidth,this.frame.canvas.height/this.pixelRatio/this.cameraState.previousHeight);var t=this.DOMtoCanvas({x:.5*this.frame.canvas.clientWidth,y:.5*this.frame.canvas.clientHeight}),e={x:t.x-this.cameraState.position.x,y:t.y-this.cameraState.position.y};this.body.view.translation.x+=e.x*this.body.view.scale,this.body.view.translation.y+=e.y*this.body.view.scale}}},{key:"_prepareValue",value:function(t){if("number"==typeof t)return t+"px";if("string"==typeof t){if(-1!==t.indexOf("%")||-1!==t.indexOf("px"))return t;if(-1===t.indexOf("%"))return t+"px"}throw new Error("Could not use the value supplied for width or height:"+t)}},{key:"_create",value:function(){for(;this.body.container.hasChildNodes();)this.body.container.removeChild(this.body.container.firstChild);if(this.frame=document.createElement("div"),this.frame.className="vis-network",this.frame.style.position="relative",this.frame.style.overflow="hidden",this.frame.tabIndex=900,this.frame.canvas=document.createElement("canvas"),this.frame.canvas.style.position="relative",this.frame.appendChild(this.frame.canvas),this.frame.canvas.getContext){var t=this.frame.canvas.getContext("2d");this.pixelRatio=(window.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1),this.frame.canvas.getContext("2d").setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0)}else{var e=document.createElement("DIV");e.style.color="red",e.style.fontWeight="bold",e.style.padding="10px",e.innerHTML="Error: your browser does not support HTML canvas",this.frame.canvas.appendChild(e)}this.body.container.appendChild(this.frame),this.body.view.scale=1,this.body.view.translation={x:.5*this.frame.canvas.clientWidth,y:.5*this.frame.canvas.clientHeight},this._bindHammer()}},{key:"_bindHammer",value:function(){var t=this;void 0!==this.hammer&&this.hammer.destroy(),this.drag={},this.pinch={},this.hammer=new s(this.frame.canvas),this.hammer.get("pinch").set({enable:!0}),this.hammer.get("pan").set({threshold:5,direction:30}),r.onTouch(this.hammer,function(e){t.body.eventListeners.onTouch(e)}),this.hammer.on("tap",function(e){t.body.eventListeners.onTap(e)}),this.hammer.on("doubletap",function(e){t.body.eventListeners.onDoubleTap(e)}),this.hammer.on("press",function(e){t.body.eventListeners.onHold(e)}),this.hammer.on("panstart",function(e){t.body.eventListeners.onDragStart(e)}),this.hammer.on("panmove",function(e){t.body.eventListeners.onDrag(e)}),this.hammer.on("panend",function(e){t.body.eventListeners.onDragEnd(e)}),this.hammer.on("pinch",function(e){t.body.eventListeners.onPinch(e)}),this.frame.canvas.addEventListener("mousewheel",function(e){t.body.eventListeners.onMouseWheel(e)}),this.frame.canvas.addEventListener("DOMMouseScroll",function(e){t.body.eventListeners.onMouseWheel(e)}),this.frame.canvas.addEventListener("mousemove",function(e){t.body.eventListeners.onMouseMove(e)}),this.frame.canvas.addEventListener("contextmenu",function(e){t.body.eventListeners.onContext(e)}),this.hammerFrame=new s(this.frame),r.onRelease(this.hammerFrame,function(e){t.body.eventListeners.onRelease(e)})}},{key:"setSize",value:function(){var t=arguments.length<=0||void 0===arguments[0]?this.options.width:arguments[0],e=arguments.length<=1||void 0===arguments[1]?this.options.height:arguments[1];t=this._prepareValue(t),e=this._prepareValue(e);var i=!1,o=this.frame.canvas.width,n=this.frame.canvas.height,s=this.frame.canvas.getContext("2d"),r=this.pixelRatio;return this.pixelRatio=(window.devicePixelRatio||1)/(s.webkitBackingStorePixelRatio||s.mozBackingStorePixelRatio||s.msBackingStorePixelRatio||s.oBackingStorePixelRatio||s.backingStorePixelRatio||1),t!=this.options.width||e!=this.options.height||this.frame.style.width!=t||this.frame.style.height!=e?(this._getCameraState(r),this.frame.style.width=t,this.frame.style.height=e,this.frame.canvas.style.width="100%",this.frame.canvas.style.height="100%",this.frame.canvas.width=Math.round(this.frame.canvas.clientWidth*this.pixelRatio),this.frame.canvas.height=Math.round(this.frame.canvas.clientHeight*this.pixelRatio),this.options.width=t,this.options.height=e,i=!0):((this.frame.canvas.width!=Math.round(this.frame.canvas.clientWidth*this.pixelRatio)||this.frame.canvas.height!=Math.round(this.frame.canvas.clientHeight*this.pixelRatio))&&this._getCameraState(r),this.frame.canvas.width!=Math.round(this.frame.canvas.clientWidth*this.pixelRatio)&&(this.frame.canvas.width=Math.round(this.frame.canvas.clientWidth*this.pixelRatio),i=!0),this.frame.canvas.height!=Math.round(this.frame.canvas.clientHeight*this.pixelRatio)&&(this.frame.canvas.height=Math.round(this.frame.canvas.clientHeight*this.pixelRatio),i=!0)),i===!0&&(this.body.emitter.emit("resize",{width:Math.round(this.frame.canvas.width/this.pixelRatio),height:Math.round(this.frame.canvas.height/this.pixelRatio),oldWidth:Math.round(o/this.pixelRatio),oldHeight:Math.round(n/this.pixelRatio)}),this._setCameraState()),i}},{key:"_XconvertDOMtoCanvas",value:function(t){return(t-this.body.view.translation.x)/this.body.view.scale}},{key:"_XconvertCanvasToDOM",value:function(t){return t*this.body.view.scale+this.body.view.translation.x}},{key:"_YconvertDOMtoCanvas",value:function(t){return(t-this.body.view.translation.y)/this.body.view.scale}},{key:"_YconvertCanvasToDOM",value:function(t){return t*this.body.view.scale+this.body.view.translation.y}},{key:"canvasToDOM",value:function(t){return{x:this._XconvertCanvasToDOM(t.x),y:this._YconvertCanvasToDOM(t.y)}}},{key:"DOMtoCanvas",value:function(t){return{x:this._XconvertDOMtoCanvas(t.x),y:this._YconvertDOMtoCanvas(t.y)}}}]),t}();e["default"]=h,t.exports=e["default"]},function(t,e,i){function o(t){return t&&t.__esModule?t:{"default":t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var i=0;i.5*this.body.nodeIndices.length)return void this.fit(t,!1);i=a["default"]._getRange(this.body.nodes,t.nodes);var h=this.body.nodeIndices.length;o=12.662/(h+7.4147)+.0964822;var d=Math.min(this.canvas.frame.canvas.clientWidth/600,this.canvas.frame.canvas.clientHeight/600);o*=d}else{this.body.emitter.emit("_resizeNodes"),i=a["default"]._getRange(this.body.nodes,t.nodes);var l=1.1*Math.abs(i.maxX-i.minX),u=1.1*Math.abs(i.maxY-i.minY),c=this.canvas.frame.canvas.clientWidth/l,p=this.canvas.frame.canvas.clientHeight/u;o=p>=c?c:p}o>1?o=1:0===o&&(o=1);var f=a["default"]._findCenter(i),m={position:f,scale:o,animation:t.animation};this.moveTo(m)}},{key:"focus",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if(void 0!==this.body.nodes[t]){var i={x:this.body.nodes[t].x,y:this.body.nodes[t].y};e.position=i,e.lockedOnNode=t,this.moveTo(e)}else console.log("Node: "+t+" cannot be found.")}},{key:"moveTo",value:function(t){return void 0===t?void(t={}):(void 0===t.offset&&(t.offset={x:0,y:0}),void 0===t.offset.x&&(t.offset.x=0),void 0===t.offset.y&&(t.offset.y=0),void 0===t.scale&&(t.scale=this.body.view.scale),void 0===t.position&&(t.position=this.getViewPosition()),void 0===t.animation&&(t.animation={duration:0}),t.animation===!1&&(t.animation={duration:0}),t.animation===!0&&(t.animation={}),void 0===t.animation.duration&&(t.animation.duration=1e3),void 0===t.animation.easingFunction&&(t.animation.easingFunction="easeInOutQuad"),void this.animateView(t))}},{key:"animateView",value:function(t){if(void 0!==t){this.animationEasingFunction=t.animation.easingFunction,this.releaseNode(),t.locked===!0&&(this.lockedOnNodeId=t.lockedOnNode,this.lockedOnNodeOffset=t.offset),0!=this.easingTime&&this._transitionRedraw(!0),this.sourceScale=this.body.view.scale,this.sourceTranslation=this.body.view.translation,this.targetScale=t.scale,this.body.view.scale=this.targetScale;var e=this.canvas.DOMtoCanvas({x:.5*this.canvas.frame.canvas.clientWidth,y:.5*this.canvas.frame.canvas.clientHeight}),i={x:e.x-t.position.x,y:e.y-t.position.y};this.targetTranslation={x:this.sourceTranslation.x+i.x*this.targetScale+t.offset.x,y:this.sourceTranslation.y+i.y*this.targetScale+t.offset.y},0===t.animation.duration?void 0!=this.lockedOnNodeId?(this.viewFunction=this._lockedRedraw.bind(this),this.body.emitter.on("initRedraw",this.viewFunction)):(this.body.view.scale=this.targetScale,this.body.view.translation=this.targetTranslation,this.body.emitter.emit("_requestRedraw")):(this.animationSpeed=1/(60*t.animation.duration*.001)||1/60,this.animationEasingFunction=t.animation.easingFunction,this.viewFunction=this._transitionRedraw.bind(this),this.body.emitter.on("initRedraw",this.viewFunction),this.body.emitter.emit("_startRendering"))}}},{key:"_lockedRedraw",value:function(){var t={x:this.body.nodes[this.lockedOnNodeId].x,y:this.body.nodes[this.lockedOnNodeId].y},e=this.canvas.DOMtoCanvas({x:.5*this.canvas.frame.canvas.clientWidth,y:.5*this.canvas.frame.canvas.clientHeight}),i={x:e.x-t.x,y:e.y-t.y},o=this.body.view.translation,n={x:o.x+i.x*this.body.view.scale+this.lockedOnNodeOffset.x,y:o.y+i.y*this.body.view.scale+this.lockedOnNodeOffset.y};this.body.view.translation=n}},{key:"releaseNode",value:function(){void 0!==this.lockedOnNodeId&&void 0!==this.viewFunction&&(this.body.emitter.off("initRedraw",this.viewFunction),this.lockedOnNodeId=void 0,this.lockedOnNodeOffset=void 0)}},{key:"_transitionRedraw",value:function(){var t=arguments.length<=0||void 0===arguments[0]?!1:arguments[0];this.easingTime+=this.animationSpeed,this.easingTime=t===!0?1:this.easingTime;var e=h.easingFunctions[this.animationEasingFunction](this.easingTime);this.body.view.scale=this.sourceScale+(this.targetScale-this.sourceScale)*e,this.body.view.translation={x:this.sourceTranslation.x+(this.targetTranslation.x-this.sourceTranslation.x)*e,y:this.sourceTranslation.y+(this.targetTranslation.y-this.sourceTranslation.y)*e},this.easingTime>=1&&(this.body.emitter.off("initRedraw",this.viewFunction),this.easingTime=0,void 0!=this.lockedOnNodeId&&(this.viewFunction=this._lockedRedraw.bind(this),this.body.emitter.on("initRedraw",this.viewFunction)),this.body.emitter.emit("animationFinished"))}},{key:"getScale",value:function(){return this.body.view.scale}},{key:"getViewPosition",value:function(){return this.canvas.DOMtoCanvas({x:.5*this.canvas.frame.canvas.clientWidth,y:.5*this.canvas.frame.canvas.clientHeight})}}]),t}();e["default"]=d,t.exports=e["default"]},function(t,e){function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;i0)for(var a=0;ae.shape.boundingBox.left&&(s=e.shape.boundingBox.left),re.shape.boundingBox.top&&(o=e.shape.boundingBox.top),n0)for(var a=0;ae.x&&(s=e.x),re.y&&(o=e.y),n50&&(this.drag.pointer=this.getPointer(t.center),this.drag.pinched=!1,this.pinch.scale=this.body.view.scale,this.touchTime=(new Date).valueOf())}},{key:"onTap",value:function(t){var e=this.getPointer(t.center),i=this.selectionHandler.options.multiselect&&(t.changedPointers[0].ctrlKey||t.changedPointers[0].metaKey);this.checkSelectionChanges(e,t,i),this.selectionHandler._generateClickEvent("click",t,e)}},{key:"onDoubleTap",value:function(t){var e=this.getPointer(t.center);this.selectionHandler._generateClickEvent("doubleClick",t,e)}},{key:"onHold",value:function(t){var e=this.getPointer(t.center),i=this.selectionHandler.options.multiselect;this.checkSelectionChanges(e,t,i),this.selectionHandler._generateClickEvent("click",t,e),this.selectionHandler._generateClickEvent("hold",t,e)}},{key:"onRelease",value:function(t){if((new Date).valueOf()-this.touchTime>10){var e=this.getPointer(t.center);this.selectionHandler._generateClickEvent("release",t,e),this.touchTime=(new Date).valueOf()}}},{key:"onContext",value:function(t){var e=this.getPointer({x:t.clientX,y:t.clientY});this.selectionHandler._generateClickEvent("oncontext",t,e)}},{key:"checkSelectionChanges",value:function(t,e){var i=arguments.length<=2||void 0===arguments[2]?!1:arguments[2],o=this.selectionHandler._getSelectedEdgeCount(),n=this.selectionHandler._getSelectedNodeCount(),s=this.selectionHandler.getSelection(),r=void 0;r=i===!0?this.selectionHandler.selectAdditionalOnPoint(t):this.selectionHandler.selectOnPoint(t);var a=this.selectionHandler._getSelectedEdgeCount(),h=this.selectionHandler._getSelectedNodeCount(),d=this.selectionHandler.getSelection(),l=this._determineIfDifferent(s,d),u=l.nodesChanges,c=l.edgesChanges,p=!1;h-n>0?(this.selectionHandler._generateClickEvent("selectNode",e,t),r=!0,p=!0):0>h-n?(this.selectionHandler._generateClickEvent("deselectNode",e,t,s),r=!0):h===n&&u===!0&&(this.selectionHandler._generateClickEvent("deselectNode",e,t,s),this.selectionHandler._generateClickEvent("selectNode",e,t),p=!0,r=!0),a-o>0&&p===!1?(this.selectionHandler._generateClickEvent("selectEdge",e,t),r=!0):0>a-o?(this.selectionHandler._generateClickEvent("deselectEdge",e,t,s),r=!0):a===o&&c===!0&&(this.selectionHandler._generateClickEvent("deselectEdge",e,t,s),this.selectionHandler._generateClickEvent("selectEdge",e,t),r=!0),r===!0&&this.selectionHandler._generateClickEvent("select",e,t)}},{key:"_determineIfDifferent",value:function(t,e){for(var i=!1,o=!1,n=0;nt&&(t=1e-5),t>10&&(t=10);var o=void 0;void 0!==this.drag&&this.drag.dragging===!0&&(o=this.canvas.DOMtoCanvas(this.drag.pointer));var n=this.body.view.translation,s=t/i,r=(1-s)*e.x+n.x*s,a=(1-s)*e.y+n.y*s;if(this.body.view.scale=t,this.body.view.translation={x:r,y:a},void 0!=o){var h=this.canvas.canvasToDOM(o);this.drag.pointer.x=h.x,this.drag.pointer.y=h.y}this.body.emitter.emit("_requestRedraw"),t>i?this.body.emitter.emit("zoom",{direction:"+",scale:this.body.view.scale}):this.body.emitter.emit("zoom",{direction:"-",scale:this.body.view.scale})}}},{key:"onMouseWheel",value:function(t){var e=0;if(t.wheelDelta?e=t.wheelDelta/120:t.detail&&(e=-t.detail/3),0!==e){var i=this.body.view.scale,o=e/10;0>e&&(o/=1-o),i*=1+o;var n=this.getPointer({x:t.clientX,y:t.clientY});this.zoom(i,n)}t.preventDefault()}},{key:"onMouseMove",value:function(t){var e=this,i=this.getPointer({x:t.clientX,y:t.clientY}),o=!1;if(void 0!==this.popup&&(this.popup.hidden===!1&&this._checkHidePopup(i),this.popup.hidden===!1&&(o=!0,this.popup.setPosition(i.x+3,i.y-5),this.popup.show())),this.options.keyboard.bindToWindow===!1&&this.options.keyboard.enabled===!0&&this.canvas.frame.focus(),o===!1&&(void 0!==this.popupTimer&&(clearInterval(this.popupTimer),this.popupTimer=void 0),this.drag.dragging||(this.popupTimer=setTimeout(function(){return e._checkShowPopup(i)},this.options.tooltipDelay))),this.options.hover===!0){var n=this.selectionHandler.getNodeAt(i);void 0===n&&(n=this.selectionHandler.getEdgeAt(i)),this.selectionHandler.hoverObject(n)}}},{key:"_checkShowPopup",value:function(t){var e=this.canvas._XconvertDOMtoCanvas(t.x),i=this.canvas._YconvertDOMtoCanvas(t.y),o={left:e,top:i,right:e,bottom:i},n=void 0===this.popupObj?void 0:this.popupObj.id,s=!1,r="node";if(void 0===this.popupObj){for(var a=this.body.nodeIndices,h=this.body.nodes,l=void 0,u=[],c=0;c0&&(this.popupObj=h[u[u.length-1]],s=!0)}if(void 0===this.popupObj&&s===!1){for(var p=this.body.edgeIndices,f=this.body.edges,m=void 0,v=[],c=0;c0&&(this.popupObj=f[v[v.length-1]],r="edge")}void 0!==this.popupObj?this.popupObj.id!==n&&(void 0===this.popup&&(this.popup=new d["default"](this.canvas.frame)),this.popup.popupTargetType=r,this.popup.popupTargetId=this.popupObj.id,this.popup.setPosition(t.x+3,t.y-5),this.popup.setText(this.popupObj.getTitle()),this.popup.show(),this.body.emitter.emit("showPopup",this.popupObj.id)):void 0!==this.popup&&(this.popup.hide(),this.body.emitter.emit("hidePopup"))}},{key:"_checkHidePopup",value:function(t){var e=this.selectionHandler._pointerToPositionObject(t),i=!1;if("node"===this.popup.popupTargetType){if(void 0!==this.body.nodes[this.popup.popupTargetId]&&(i=this.body.nodes[this.popup.popupTargetId].isOverlappingWith(e),i===!0)){var o=this.selectionHandler.getNodeAt(t);i=o.id===this.popup.popupTargetId}}else void 0===this.selectionHandler.getNodeAt(t)&&void 0!==this.body.edges[this.popup.popupTargetId]&&(i=this.body.edges[this.popup.popupTargetId].isOverlappingWith(e));i===!1&&(this.popupObj=void 0,this.popup.hide(),this.body.emitter.emit("hidePopup"))}}]),t}();e["default"]=u,t.exports=e["default"]},function(t,e,i){function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){for(var i=0;i700&&(this.body.emitter.emit("fit",{duration:700}),this.touchTime=(new Date).valueOf())}},{key:"_stopMovement",value:function(){for(var t in this.boundFunctions)this.boundFunctions.hasOwnProperty(t)&&(this.body.emitter.off("initRedraw",this.boundFunctions[t]),this.body.emitter.emit("_stopRendering"));this.boundFunctions={}}},{key:"_moveUp",value:function(){this.body.view.translation.y+=this.options.keyboard.speed.y}},{key:"_moveDown",value:function(){this.body.view.translation.y-=this.options.keyboard.speed.y}},{key:"_moveLeft",value:function(){this.body.view.translation.x+=this.options.keyboard.speed.x}},{key:"_moveRight",value:function(){this.body.view.translation.x-=this.options.keyboard.speed.x}},{key:"_zoomIn",value:function(){this.body.view.scale*=1+this.options.keyboard.speed.zoom,this.body.emitter.emit("zoom",{direction:"+",scale:this.body.view.scale})}},{key:"_zoomOut",value:function(){this.body.view.scale/=1+this.options.keyboard.speed.zoom,this.body.emitter.emit("zoom",{direction:"-",scale:this.body.view.scale})}},{key:"configureKeyboardBindings",value:function(){var t=this;void 0!==this.keycharm&&this.keycharm.destroy(),this.options.keyboard.enabled===!0&&(this.options.keyboard.bindToWindow===!0?this.keycharm=a({ -container:window,preventDefault:!0}):this.keycharm=a({container:this.canvas.frame,preventDefault:!0}),this.keycharm.reset(),this.activated===!0&&(this.keycharm.bind("up",function(){t.bindToRedraw("_moveUp")},"keydown"),this.keycharm.bind("down",function(){t.bindToRedraw("_moveDown")},"keydown"),this.keycharm.bind("left",function(){t.bindToRedraw("_moveLeft")},"keydown"),this.keycharm.bind("right",function(){t.bindToRedraw("_moveRight")},"keydown"),this.keycharm.bind("=",function(){t.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("num+",function(){t.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("num-",function(){t.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("-",function(){t.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("[",function(){t.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("]",function(){t.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("pageup",function(){t.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("pagedown",function(){t.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("up",function(){t.unbindFromRedraw("_moveUp")},"keyup"),this.keycharm.bind("down",function(){t.unbindFromRedraw("_moveDown")},"keyup"),this.keycharm.bind("left",function(){t.unbindFromRedraw("_moveLeft")},"keyup"),this.keycharm.bind("right",function(){t.unbindFromRedraw("_moveRight")},"keyup"),this.keycharm.bind("=",function(){t.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("num+",function(){t.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("num-",function(){t.unbindFromRedraw("_zoomOut")},"keyup"),this.keycharm.bind("-",function(){t.unbindFromRedraw("_zoomOut")},"keyup"),this.keycharm.bind("[",function(){t.unbindFromRedraw("_zoomOut")},"keyup"),this.keycharm.bind("]",function(){t.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("pageup",function(){t.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("pagedown",function(){t.unbindFromRedraw("_zoomOut")},"keyup")))}}]),t}();e["default"]=h,t.exports=e["default"]},function(t,e){function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;io&&(s=o-e-this.padding),sn&&(r=n-i-this.padding),r0?e===!0?this.body.nodes[o[o.length-1]]:o[o.length-1]:void 0}},{key:"_getEdgesOverlappingWith",value:function(t,e){for(var i=this.body.edges,o=0;o0?e===!0?this.body.edges[o[o.length-1]]:o[o.length-1]:void 0}},{key:"_addToSelection",value:function(t){t instanceof s?this.selectionObj.nodes[t.id]=t:this.selectionObj.edges[t.id]=t}},{key:"_addToHover",value:function(t){t instanceof s?this.hoverObj.nodes[t.id]=t:this.hoverObj.edges[t.id]=t}},{key:"_removeFromSelection",value:function(t){t instanceof s?delete this.selectionObj.nodes[t.id]:delete this.selectionObj.edges[t.id]}},{key:"unselectAll",value:function(){for(var t in this.selectionObj.nodes)this.selectionObj.nodes.hasOwnProperty(t)&&this.selectionObj.nodes[t].unselect();for(var e in this.selectionObj.edges)this.selectionObj.edges.hasOwnProperty(e)&&this.selectionObj.edges[e].unselect();this.selectionObj={nodes:{},edges:{}}}},{key:"_getSelectedNodeCount",value:function(){var t=0;for(var e in this.selectionObj.nodes)this.selectionObj.nodes.hasOwnProperty(e)&&(t+=1);return t}},{key:"_getSelectedNode",value:function(){for(var t in this.selectionObj.nodes)if(this.selectionObj.nodes.hasOwnProperty(t))return this.selectionObj.nodes[t];return void 0}},{key:"_getSelectedEdge",value:function(){for(var t in this.selectionObj.edges)if(this.selectionObj.edges.hasOwnProperty(t))return this.selectionObj.edges[t];return void 0}},{key:"_getSelectedEdgeCount",value:function(){var t=0;for(var e in this.selectionObj.edges)this.selectionObj.edges.hasOwnProperty(e)&&(t+=1);return t}},{key:"_getSelectedObjectCount",value:function(){var t=0;for(var e in this.selectionObj.nodes)this.selectionObj.nodes.hasOwnProperty(e)&&(t+=1);for(var i in this.selectionObj.edges)this.selectionObj.edges.hasOwnProperty(i)&&(t+=1);return t}},{key:"_selectionIsEmpty",value:function(){for(var t in this.selectionObj.nodes)if(this.selectionObj.nodes.hasOwnProperty(t))return!1;for(var e in this.selectionObj.edges)if(this.selectionObj.edges.hasOwnProperty(e))return!1;return!0}},{key:"_clusterInSelection",value:function(){for(var t in this.selectionObj.nodes)if(this.selectionObj.nodes.hasOwnProperty(t)&&this.selectionObj.nodes[t].clusterSize>1)return!0;return!1}},{key:"_selectConnectedEdges",value:function(t){for(var e=0;e0&&(this.options.hierarchical.levelSeparation*=-1):this.options.hierarchical.levelSeparation<0&&(this.options.hierarchical.levelSeparation*=-1),this.body.emitter.emit("_resetHierarchicalLayout"),this.adaptAllOptions(e);if(i===!0)return this.body.emitter.emit("refresh"),h.deepExtend(e,this.optionsBackup)}return e}},{key:"adaptAllOptions",value:function(t){if(this.options.hierarchical.enabled===!0){void 0===t.physics||t.physics===!0?(t.physics={solver:"hierarchicalRepulsion"},this.optionsBackup.physics={solver:"barnesHut"}):"object"==typeof t.physics?(this.optionsBackup.physics={solver:"barnesHut"},void 0!==t.physics.solver&&(this.optionsBackup.physics={solver:t.physics.solver}),t.physics.solver="hierarchicalRepulsion"):t.physics!==!1&&(this.optionsBackup.physics={solver:"barnesHut"},t.physics.solver="hierarchicalRepulsion");var e="horizontal";("RL"===this.options.hierarchical.direction||"LR"===this.options.hierarchical.direction)&&(e="vertical"),void 0===t.edges?(this.optionsBackup.edges={smooth:{enabled:!0,type:"dynamic"}},t.edges={smooth:!1}):void 0===t.edges.smooth?(this.optionsBackup.edges={smooth:{enabled:!0,type:"dynamic"}},t.edges.smooth=!1):"boolean"==typeof t.edges.smooth?(this.optionsBackup.edges={smooth:t.edges.smooth},t.edges.smooth={enabled:t.edges.smooth,type:e}):(void 0!==t.edges.smooth.type&&"dynamic"!==t.edges.smooth.type&&(e=t.edges.smooth.type),this.optionsBackup.edges={smooth:void 0===t.edges.smooth.enabled?!0:t.edges.smooth.enabled,type:void 0===t.edges.smooth.type?"dynamic":t.edges.smooth.type,roundness:void 0===t.edges.smooth.roundness?.5:t.edges.smooth.roundness,forceDirection:void 0===t.edges.smooth.forceDirection?!1:t.edges.smooth.forceDirection},t.edges.smooth={enabled:void 0===t.edges.smooth.enabled?!0:t.edges.smooth.enabled,type:e,roundness:void 0===t.edges.smooth.roundness?.5:t.edges.smooth.roundness,forceDirection:void 0===t.edges.smooth.forceDirection?!1:t.edges.smooth.forceDirection}),this.body.emitter.emit("_forceDisableDynamicCurves",e)}return t}},{key:"seededRandom",value:function(){var t=1e4*Math.sin(this.randomSeed++);return t-Math.floor(t)}},{key:"positionInitially",value:function(t){if(this.options.hierarchical.enabled!==!0){this.randomSeed=this.initialRandomSeed;for(var e=0;es){for(var r=this.body.nodeIndices.length;this.body.nodeIndices.length>s;){n+=1;var a=this.body.nodeIndices.length;n%3===0?this.body.modules.clustering.clusterBridges():this.body.modules.clustering.clusterOutliers();var h=this.body.nodeIndices.length;if(a==h&&n%3!==0||n>o)return this._declusterAll(),this.body.emitter.emit("_layoutFailed"),void console.info("This network could not be positioned by this version of the improved layout algorithm. Please disable improvedLayout for better performance.")}this.body.modules.kamadaKawai.setOptions({springLength:Math.max(150,2*r)})}this.body.modules.kamadaKawai.solve(this.body.nodeIndices,this.body.edgeIndices,!0),this._shiftToCenter();for(var d=70,e=0;e0){var t=void 0,e=void 0,i=!1,o=!1;this.hierarchicalLevels={},this.nodeSpacing=100;for(e in this.body.nodes)this.body.nodes.hasOwnProperty(e)&&(t=this.body.nodes[e],void 0!==t.options.level?(i=!0,this.hierarchicalLevels[e]=t.options.level):o=!0);if(o===!0&&i===!0)throw new Error("To use the hierarchical layout, nodes require either no predefined levels or levels have to be defined for all nodes.");o===!0&&("hubsize"===this.options.hierarchical.sortMethod?this._determineLevelsByHubsize():("directed"===this.options.hierarchical.sortMethod,this._determineLevelsDirected()));var n=this._getDistribution();this._placeNodesByHierarchy(n)}}},{key:"_placeNodesByHierarchy",value:function(t){var e=void 0,i=void 0;this.positionedNodes={};for(var o in t)if(t.hasOwnProperty(o))for(e in t[o].nodes)t[o].nodes.hasOwnProperty(e)&&(i=t[o].nodes[e],"UD"===this.options.hierarchical.direction||"DU"===this.options.hierarchical.direction?(void 0===i.x&&(i.x=t[o].distance),t[o].distance=i.x+this.nodeSpacing):(void 0===i.y&&(i.y=t[o].distance),t[o].distance=i.y+this.nodeSpacing),this.positionedNodes[e]=!0,this._placeBranchNodes(i.edges,i.id,t,o))}},{key:"_getDistribution",value:function(){var t={},e=void 0,i=void 0;for(e in this.body.nodes)if(this.body.nodes.hasOwnProperty(e)){i=this.body.nodes[e];var o=void 0===this.hierarchicalLevels[e]?0:this.hierarchicalLevels[e];"UD"===this.options.hierarchical.direction||"DU"===this.options.hierarchical.direction?(i.y=this.options.hierarchical.levelSeparation*o,i.options.fixed.y=!0):(i.x=this.options.hierarchical.levelSeparation*o,i.options.fixed.x=!0),void 0===t[o]&&(t[o]={amount:0,nodes:{},distance:0}),t[o].amount+=1,t[o].nodes[e]=i}return t}},{key:"_getHubSize",value:function(){var t=0;for(var e in this.body.nodes)if(this.body.nodes.hasOwnProperty(e)){var i=this.body.nodes[e];void 0===this.hierarchicalLevels[e]&&(t=i.edges.length0&&(i=this._getHubSize(),0!==i);)for(t in this.body.nodes)this.body.nodes.hasOwnProperty(t)&&(e=this.body.nodes[t],e.edges.length===i&&this._setLevelByHubsize(0,e))}},{key:"_setLevelByHubsize",value:function(t,e){if(void 0===this.hierarchicalLevels[e.id]){var i=void 0;this.hierarchicalLevels[e.id]=t;for(var o=0;oo&&("UD"===this.options.hierarchical.direction||"DU"===this.options.hierarchical.direction?(void 0===s.x&&(s.x=Math.max(i[a].distance,r.x)),i[a].distance=s.x+this.nodeSpacing,this.positionedNodes[s.id]=!0):(void 0===s.y&&(s.y=Math.max(i[a].distance,r.y)),i[a].distance=s.y+this.nodeSpacing),this.positionedNodes[s.id]=!0,s.edges.length>1&&this._placeBranchNodes(s.edges,s.id,i,a))}}}]),t}();e["default"]=d,t.exports=e["default"]},function(t,e,i){function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){for(var i=0;i0&&this.options.deleteNode!==!1?(n===!0&&this._createSeperator(4),this._createDeleteButton(o)):0===t&&this.options.deleteEdge!==!1&&(n===!0&&this._createSeperator(4),this._createDeleteButton(o))),this._bindHammerToDiv(this.closeDiv,this.toggleEditMode.bind(this)),this._temporaryBindEvent("select",this.showManipulatorToolbar.bind(this))}this.body.emitter.emit("_redraw")}},{key:"addNodeMode",value:function(){if(this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="addNode",this.guiEnabled===!0){var t=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(t),this._createSeperator(),this._createDescription(t.addDescription||this.options.locales.en.addDescription),this._bindHammerToDiv(this.closeDiv,this.toggleEditMode.bind(this))}this._temporaryBindEvent("click",this._performAddNode.bind(this))}},{key:"editNode",value:function(){var t=this;this.editMode!==!0&&this.enableEditMode(),this._clean();var e=this.selectionHandler._getSelectedNode();if(void 0!==e){if(this.inMode="editNode","function"!=typeof this.options.editNode)throw new Error("No function has been configured to handle the editing of nodes.");if(e.isCluster!==!0){var i=s.deepExtend({},e.options,!0);if(i.x=e.x,i.y=e.y,2!==this.options.editNode.length)throw new Error("The function for edit does not support two arguments (data, callback)");this.options.editNode(i,function(e){null!==e&&void 0!==e&&"editNode"===t.inMode&&t.body.data.nodes.getDataSet().update(e),t.showManipulatorToolbar()})}else alert(this.options.locales[this.options.locale].editClusterError||this.options.locales.en.editClusterError)}else this.showManipulatorToolbar()}},{key:"addEdgeMode",value:function(){if(this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="addEdge",this.guiEnabled===!0){var t=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(t),this._createSeperator(),this._createDescription(t.edgeDescription||this.options.locales.en.edgeDescription),this._bindHammerToDiv(this.closeDiv,this.toggleEditMode.bind(this))}this._temporaryBindUI("onTouch",this._handleConnect.bind(this)),this._temporaryBindUI("onDragEnd",this._finishConnect.bind(this)),this._temporaryBindUI("onDrag",this._dragControlNode.bind(this)),this._temporaryBindUI("onRelease",this._finishConnect.bind(this)),this._temporaryBindUI("onDragStart",function(){}),this._temporaryBindUI("onHold",function(){})}},{key:"editEdgeMode",value:function(){var t=this;if(this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="editEdge",this.guiEnabled===!0){var e=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(e),this._createSeperator(),this._createDescription(e.editEdgeDescription||this.options.locales.en.editEdgeDescription),this._bindHammerToDiv(this.closeDiv,this.toggleEditMode.bind(this))}this.edgeBeingEditedId=this.selectionHandler.getSelectedEdges()[0],void 0!==this.edgeBeingEditedId?!function(){var e=t.body.edges[t.edgeBeingEditedId],i=t._getNewTargetNode(e.from.x,e.from.y),o=t._getNewTargetNode(e.to.x,e.to.y);t.temporaryIds.nodes.push(i.id),t.temporaryIds.nodes.push(o.id),t.body.nodes[i.id]=i,t.body.nodeIndices.push(i.id),t.body.nodes[o.id]=o,t.body.nodeIndices.push(o.id),t._temporaryBindUI("onTouch",t._controlNodeTouch.bind(t)),t._temporaryBindUI("onTap",function(){}),t._temporaryBindUI("onHold",function(){}),t._temporaryBindUI("onDragStart",t._controlNodeDragStart.bind(t)),t._temporaryBindUI("onDrag",t._controlNodeDrag.bind(t)),t._temporaryBindUI("onDragEnd",t._controlNodeDragEnd.bind(t)),t._temporaryBindUI("onMouseMove",function(){}),t._temporaryBindEvent("beforeDrawing",function(t){var n=e.edgeType.findBorderPositions(t);i.selected===!1&&(i.x=n.from.x,i.y=n.from.y),o.selected===!1&&(o.x=n.to.x,o.y=n.to.y)}),t.body.emitter.emit("_redraw")}():this.showManipulatorToolbar()}},{key:"deleteSelected",value:function(){var t=this;this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="delete";var e=this.selectionHandler.getSelectedNodes(),i=this.selectionHandler.getSelectedEdges(),o=void 0;if(e.length>0){for(var n=0;n0&&"function"==typeof this.options.deleteEdge&&(o=this.options.deleteEdge);if("function"==typeof o){var s={nodes:e,edges:i};if(2!==o.length)throw new Error("The function for delete does not support two arguments (data, callback)");o(s,function(e){null!==e&&void 0!==e&&"delete"===t.inMode?(t.body.data.edges.getDataSet().remove(e.edges),t.body.data.nodes.getDataSet().remove(e.nodes),t.body.emitter.emit("startSimulation"),t.showManipulatorToolbar()):(t.body.emitter.emit("startSimulation"),t.showManipulatorToolbar())})}else this.body.data.edges.getDataSet().remove(i),this.body.data.nodes.getDataSet().remove(e),this.body.emitter.emit("startSimulation"),this.showManipulatorToolbar()}},{key:"_setup",value:function(){this.options.enabled===!0?(this.guiEnabled=!0,this._createWrappers(),this.editMode===!1?this._createEditButton():this.showManipulatorToolbar()):(this._removeManipulationDOM(),this.guiEnabled=!1)}},{key:"_createWrappers",value:function(){void 0===this.manipulationDiv&&(this.manipulationDiv=document.createElement("div"),this.manipulationDiv.className="vis-manipulation",this.editMode===!0?this.manipulationDiv.style.display="block":this.manipulationDiv.style.display="none",this.canvas.frame.appendChild(this.manipulationDiv)),void 0===this.editModeDiv&&(this.editModeDiv=document.createElement("div"),this.editModeDiv.className="vis-edit-mode",this.editMode===!0?this.editModeDiv.style.display="none":this.editModeDiv.style.display="block",this.canvas.frame.appendChild(this.editModeDiv)),void 0===this.closeDiv&&(this.closeDiv=document.createElement("div"),this.closeDiv.className="vis-close",this.closeDiv.style.display=this.manipulationDiv.style.display,this.canvas.frame.appendChild(this.closeDiv))}},{key:"_getNewTargetNode",value:function(t,e){var i=s.deepExtend({},this.options.controlNodeStyle);return i.id="targetNode"+s.randomUUID(),i.hidden=!1,i.physics=!1,i.x=t,i.y=e,this.body.functions.createNode(i)}},{key:"_createEditButton",value:function(){this._clean(),this.manipulationDOM={},s.recursiveDOMDelete(this.editModeDiv);var t=this.options.locales[this.options.locale],e=this._createButton("editMode","vis-button vis-edit vis-edit-mode",t.edit||this.options.locales.en.edit);this.editModeDiv.appendChild(e),this._bindHammerToDiv(e,this.toggleEditMode.bind(this))}},{key:"_clean",value:function(){this.inMode=!1,this.guiEnabled===!0&&(s.recursiveDOMDelete(this.editModeDiv),s.recursiveDOMDelete(this.manipulationDiv),this._cleanManipulatorHammers()),this._cleanupTemporaryNodesAndEdges(),this._unbindTemporaryUIs(),this._unbindTemporaryEvents(),this.body.emitter.emit("restorePhysics")}},{key:"_cleanManipulatorHammers", -value:function(){if(0!=this.manipulationHammers.length){for(var t=0;t=0;r--)if(n[r]!==this.selectedControlNode.id){s=this.body.nodes[n[r]];break}if(void 0!==s&&void 0!==this.selectedControlNode)if(s.isCluster===!0)alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError);else{var a=this.body.nodes[this.temporaryIds.nodes[0]];this.selectedControlNode.id===a.id?this._performEditEdge(s.id,o.to.id):this._performEditEdge(o.from.id,s.id)}else o.updateEdgeType(),this.body.emitter.emit("restorePhysics");this.body.emitter.emit("_redraw")}}},{key:"_handleConnect",value:function(t){if((new Date).valueOf()-this.touchTime>100){this.lastTouch=this.body.functions.getPointer(t.center),this.lastTouch.translation=s.extend({},this.body.view.translation);var e=this.lastTouch,i=this.selectionHandler.getNodeAt(e);if(void 0!==i)if(i.isCluster===!0)alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError);else{var o=this._getNewTargetNode(i.x,i.y);this.body.nodes[o.id]=o,this.body.nodeIndices.push(o.id);var n=this.body.functions.createEdge({id:"connectionEdge"+s.randomUUID(),from:i.id,to:o.id,physics:!1,smooth:{enabled:!0,type:"continuous",roundness:.5}});this.body.edges[n.id]=n,this.body.edgeIndices.push(n.id),this.temporaryIds.nodes.push(o.id),this.temporaryIds.edges.push(n.id)}this.touchTime=(new Date).valueOf()}}},{key:"_dragControlNode",value:function(t){var e=this.body.functions.getPointer(t.center);if(void 0!==this.temporaryIds.nodes[0]){var i=this.body.nodes[this.temporaryIds.nodes[0]];i.x=this.canvas._XconvertDOMtoCanvas(e.x),i.y=this.canvas._YconvertDOMtoCanvas(e.y),this.body.emitter.emit("_redraw")}else{var o=e.x-this.lastTouch.x,n=e.y-this.lastTouch.y;this.body.view.translation={x:this.lastTouch.translation.x+o,y:this.lastTouch.translation.y+n}}}},{key:"_finishConnect",value:function(t){var e=this.body.functions.getPointer(t.center),i=this.selectionHandler._pointerToPositionObject(e),o=void 0;void 0!==this.temporaryIds.edges[0]&&(o=this.body.edges[this.temporaryIds.edges[0]].fromId);for(var n=this.selectionHandler._getAllNodesOverlappingWith(i),s=void 0,r=n.length-1;r>=0;r--)if(-1===this.temporaryIds.nodes.indexOf(n[r])){s=this.body.nodes[n[r]];break}this._cleanupTemporaryNodesAndEdges(),void 0!==s&&(s.isCluster===!0?alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError):void 0!==this.body.nodes[o]&&void 0!==this.body.nodes[s.id]&&this._performAddEdge(o,s.id)),this.body.emitter.emit("_redraw")}},{key:"_performAddNode",value:function(t){var e=this,i={id:s.randomUUID(),x:t.pointer.canvas.x,y:t.pointer.canvas.y,label:"new"};if("function"==typeof this.options.addNode){if(2!==this.options.addNode.length)throw new Error("The function for add does not support two arguments (data,callback)");this.options.addNode(i,function(t){null!==t&&void 0!==t&&"addNode"===e.inMode&&(e.body.data.nodes.getDataSet().add(t),e.showManipulatorToolbar())})}else this.body.data.nodes.getDataSet().add(i),this.showManipulatorToolbar()}},{key:"_performAddEdge",value:function(t,e){var i=this,o={from:t,to:e};if("function"==typeof this.options.addEdge){if(2!==this.options.addEdge.length)throw new Error("The function for connect does not support two arguments (data,callback)");this.options.addEdge(o,function(t){null!==t&&void 0!==t&&"addEdge"===i.inMode&&(i.body.data.edges.getDataSet().add(t),i.selectionHandler.unselectAll(),i.showManipulatorToolbar())})}else this.body.data.edges.getDataSet().add(o),this.selectionHandler.unselectAll(),this.showManipulatorToolbar()}},{key:"_performEditEdge",value:function(t,e){var i=this,o={id:this.edgeBeingEditedId,from:t,to:e};if("function"==typeof this.options.editEdge){if(2!==this.options.editEdge.length)throw new Error("The function for edit does not support two arguments (data, callback)");this.options.editEdge(o,function(t){null===t||void 0===t||"editEdge"!==i.inMode?(i.body.edges[o.id].updateEdgeType(),i.body.emitter.emit("_redraw")):(i.body.data.edges.getDataSet().update(t),i.selectionHandler.unselectAll(),i.showManipulatorToolbar())})}else this.body.data.edges.getDataSet().update(o),this.selectionHandler.unselectAll(),this.showManipulatorToolbar()}}]),t}();e["default"]=h,t.exports=e["default"]},function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var i="string",o="boolean",n="number",s="array",r="object",a="dom",h="any",d={configure:{enabled:{"boolean":o},filter:{"boolean":o,string:i,array:s,"function":"function"},container:{dom:a},showButton:{"boolean":o},__type__:{object:r,"boolean":o,string:i,array:s,"function":"function"}},edges:{arrows:{to:{enabled:{"boolean":o},scaleFactor:{number:n},__type__:{object:r,"boolean":o}},middle:{enabled:{"boolean":o},scaleFactor:{number:n},__type__:{object:r,"boolean":o}},from:{enabled:{"boolean":o},scaleFactor:{number:n},__type__:{object:r,"boolean":o}},__type__:{string:["from","to","middle"],object:r}},color:{color:{string:i},highlight:{string:i},hover:{string:i},inherit:{string:["from","to","both"],"boolean":o},opacity:{number:n},__type__:{object:r,string:i}},dashes:{"boolean":o,array:s},font:{color:{string:i},size:{number:n},face:{string:i},background:{string:i},strokeWidth:{number:n},strokeColor:{string:i},align:{string:["horizontal","top","middle","bottom"]},__type__:{object:r,string:i}},hidden:{"boolean":o},hoverWidth:{"function":"function",number:n},label:{string:i,undefined:"undefined"},labelHighlightBold:{"boolean":o},length:{number:n,undefined:"undefined"},physics:{"boolean":o},scaling:{min:{number:n},max:{number:n},label:{enabled:{"boolean":o},min:{number:n},max:{number:n},maxVisible:{number:n},drawThreshold:{number:n},__type__:{object:r,"boolean":o}},customScalingFunction:{"function":"function"},__type__:{object:r}},selectionWidth:{"function":"function",number:n},selfReferenceSize:{number:n},shadow:{enabled:{"boolean":o},size:{number:n},x:{number:n},y:{number:n},__type__:{object:r,"boolean":o}},smooth:{enabled:{"boolean":o},type:{string:["dynamic","continuous","discrete","diagonalCross","straightCross","horizontal","vertical","curvedCW","curvedCCW","cubicBezier"]},roundness:{number:n},forceDirection:{string:["horizontal","vertical","none"],"boolean":o},__type__:{object:r,"boolean":o}},title:{string:i,undefined:"undefined"},width:{number:n},value:{number:n,undefined:"undefined"},__type__:{object:r}},groups:{useDefaultGroups:{"boolean":o},__any__:"get from nodes, will be overwritten below",__type__:{object:r}},interaction:{dragNodes:{"boolean":o},dragView:{"boolean":o},hideEdgesOnDrag:{"boolean":o},hideNodesOnDrag:{"boolean":o},hover:{"boolean":o},keyboard:{enabled:{"boolean":o},speed:{x:{number:n},y:{number:n},zoom:{number:n},__type__:{object:r}},bindToWindow:{"boolean":o},__type__:{object:r,"boolean":o}},multiselect:{"boolean":o},navigationButtons:{"boolean":o},selectable:{"boolean":o},selectConnectedEdges:{"boolean":o},hoverConnectedEdges:{"boolean":o},tooltipDelay:{number:n},zoomView:{"boolean":o},__type__:{object:r}},layout:{randomSeed:{undefined:"undefined",number:n},improvedLayout:{"boolean":o},hierarchical:{enabled:{"boolean":o},levelSeparation:{number:n},direction:{string:["UD","DU","LR","RL"]},sortMethod:{string:["hubsize","directed"]},__type__:{object:r,"boolean":o}},__type__:{object:r}},manipulation:{enabled:{"boolean":o},initiallyActive:{"boolean":o},addNode:{"boolean":o,"function":"function"},addEdge:{"boolean":o,"function":"function"},editNode:{"function":"function"},editEdge:{"boolean":o,"function":"function"},deleteNode:{"boolean":o,"function":"function"},deleteEdge:{"boolean":o,"function":"function"},controlNodeStyle:"get from nodes, will be overwritten below",__type__:{object:r,"boolean":o}},nodes:{borderWidth:{number:n},borderWidthSelected:{number:n,undefined:"undefined"},brokenImage:{string:i,undefined:"undefined"},color:{border:{string:i},background:{string:i},highlight:{border:{string:i},background:{string:i},__type__:{object:r,string:i}},hover:{border:{string:i},background:{string:i},__type__:{object:r,string:i}},__type__:{object:r,string:i}},fixed:{x:{"boolean":o},y:{"boolean":o},__type__:{object:r,"boolean":o}},font:{color:{string:i},size:{number:n},face:{string:i},background:{string:i},strokeWidth:{number:n},strokeColor:{string:i},__type__:{object:r,string:i}},group:{string:i,number:n,undefined:"undefined"},hidden:{"boolean":o},icon:{face:{string:i},code:{string:i},size:{number:n},color:{string:i},__type__:{object:r}},id:{string:i,number:n},image:{string:i,undefined:"undefined"},label:{string:i,undefined:"undefined"},labelHighlightBold:{"boolean":o},level:{number:n,undefined:"undefined"},mass:{number:n},physics:{"boolean":o},scaling:{min:{number:n},max:{number:n},label:{enabled:{"boolean":o},min:{number:n},max:{number:n},maxVisible:{number:n},drawThreshold:{number:n},__type__:{object:r,"boolean":o}},customScalingFunction:{"function":"function"},__type__:{object:r}},shadow:{enabled:{"boolean":o},size:{number:n},x:{number:n},y:{number:n},__type__:{object:r,"boolean":o}},shape:{string:["ellipse","circle","database","box","text","image","circularImage","diamond","dot","star","triangle","triangleDown","square","icon"]},shapeProperties:{borderDashes:{"boolean":o,array:s},borderRadius:{number:n},useImageSize:{"boolean":o},useBorderWithImage:{"boolean":o},__type__:{object:r}},size:{number:n},title:{string:i,undefined:"undefined"},value:{number:n,undefined:"undefined"},x:{number:n},y:{number:n},__type__:{object:r}},physics:{enabled:{"boolean":o},barnesHut:{gravitationalConstant:{number:n},centralGravity:{number:n},springLength:{number:n},springConstant:{number:n},damping:{number:n},avoidOverlap:{number:n},__type__:{object:r}},forceAtlas2Based:{gravitationalConstant:{number:n},centralGravity:{number:n},springLength:{number:n},springConstant:{number:n},damping:{number:n},avoidOverlap:{number:n},__type__:{object:r}},repulsion:{centralGravity:{number:n},springLength:{number:n},springConstant:{number:n},nodeDistance:{number:n},damping:{number:n},__type__:{object:r}},hierarchicalRepulsion:{centralGravity:{number:n},springLength:{number:n},springConstant:{number:n},nodeDistance:{number:n},damping:{number:n},__type__:{object:r}},maxVelocity:{number:n},minVelocity:{number:n},solver:{string:["barnesHut","repulsion","hierarchicalRepulsion","forceAtlas2Based"]},stabilization:{enabled:{"boolean":o},iterations:{number:n},updateInterval:{number:n},onlyDynamicEdges:{"boolean":o},fit:{"boolean":o},__type__:{object:r,"boolean":o}},timestep:{number:n},adaptiveTimestep:{"boolean":o},__type__:{object:r,"boolean":o}},autoResize:{"boolean":o},clickToUse:{"boolean":o},locale:{string:i},locales:{__any__:{any:h},__type__:{object:r}},height:{string:i},width:{string:i},__type__:{object:r}};d.groups.__any__=d.nodes,d.manipulation.controlNodeStyle=d.nodes;var l={nodes:{borderWidth:[1,0,10,1],borderWidthSelected:[2,0,10,1],color:{border:["color","#2B7CE9"],background:["color","#97C2FC"],highlight:{border:["color","#2B7CE9"],background:["color","#D2E5FF"]},hover:{border:["color","#2B7CE9"],background:["color","#D2E5FF"]}},fixed:{x:!1,y:!1},font:{color:["color","#343434"],size:[14,0,100,1],face:["arial","verdana","tahoma"],background:["color","none"],strokeWidth:[0,0,50,1],strokeColor:["color","#ffffff"]},hidden:!1,labelHighlightBold:!0,physics:!0,scaling:{min:[10,0,200,1],max:[30,0,200,1],label:{enabled:!1,min:[14,0,200,1],max:[30,0,200,1],maxVisible:[30,0,200,1],drawThreshold:[5,0,20,1]}},shadow:{enabled:!1,size:[10,0,20,1],x:[5,-30,30,1],y:[5,-30,30,1]},shape:["ellipse","box","circle","database","diamond","dot","square","star","text","triangle","triangleDown"],shapeProperties:{borderDashes:!1,borderRadius:[6,0,20,1],useImageSize:!1},size:[25,0,200,1]},edges:{arrows:{to:{enabled:!1,scaleFactor:[1,0,3,.05]},middle:{enabled:!1,scaleFactor:[1,0,3,.05]},from:{enabled:!1,scaleFactor:[1,0,3,.05]}},color:{color:["color","#848484"],highlight:["color","#848484"],hover:["color","#848484"],inherit:["from","to","both",!0,!1],opacity:[1,0,1,.05]},dashes:!1,font:{color:["color","#343434"],size:[14,0,100,1],face:["arial","verdana","tahoma"],background:["color","none"],strokeWidth:[2,0,50,1],strokeColor:["color","#ffffff"],align:["horizontal","top","middle","bottom"]},hidden:!1,hoverWidth:[1.5,0,5,.1],labelHighlightBold:!0,physics:!0,scaling:{min:[1,0,100,1],max:[15,0,100,1],label:{enabled:!0,min:[14,0,200,1],max:[30,0,200,1],maxVisible:[30,0,200,1],drawThreshold:[5,0,20,1]}},selectionWidth:[1.5,0,5,.1],selfReferenceSize:[20,0,200,1],shadow:{enabled:!1,size:[10,0,20,1],x:[5,-30,30,1],y:[5,-30,30,1]},smooth:{enabled:!0,type:["dynamic","continuous","discrete","diagonalCross","straightCross","horizontal","vertical","curvedCW","curvedCCW","cubicBezier"],forceDirection:["horizontal","vertical","none"],roundness:[.5,0,1,.05]},width:[1,0,30,1]},layout:{hierarchical:{enabled:!1,levelSeparation:[150,20,500,5],direction:["UD","DU","LR","RL"],sortMethod:["hubsize","directed"]}},interaction:{dragNodes:!0,dragView:!0,hideEdgesOnDrag:!1,hideNodesOnDrag:!1,hover:!1,keyboard:{enabled:!1,speed:{x:[10,0,40,1],y:[10,0,40,1],zoom:[.02,0,.1,.005]},bindToWindow:!0},multiselect:!1,navigationButtons:!1,selectable:!0,selectConnectedEdges:!0,hoverConnectedEdges:!0,tooltipDelay:[300,0,1e3,25],zoomView:!0},manipulation:{enabled:!1,initiallyActive:!1},physics:{enabled:!0,barnesHut:{gravitationalConstant:[-2e3,-3e4,0,50],centralGravity:[.3,0,10,.05],springLength:[95,0,500,5],springConstant:[.04,0,1.2,.005],damping:[.09,0,1,.01],avoidOverlap:[0,0,1,.01]},forceAtlas2Based:{gravitationalConstant:[-50,-500,0,1],centralGravity:[.01,0,1,.005],springLength:[95,0,500,5],springConstant:[.08,0,1.2,.005],damping:[.4,0,1,.01],avoidOverlap:[0,0,1,.01]},repulsion:{centralGravity:[.2,0,10,.05],springLength:[200,0,500,5],springConstant:[.05,0,1.2,.005],nodeDistance:[100,0,500,5],damping:[.09,0,1,.01]},hierarchicalRepulsion:{centralGravity:[.2,0,10,.05],springLength:[100,0,500,5],springConstant:[.01,0,1.2,.005],nodeDistance:[120,0,500,5],damping:[.09,0,1,.01]},maxVelocity:[50,0,150,1],minVelocity:[.1,.01,.5,.01],solver:["barnesHut","forceAtlas2Based","repulsion","hierarchicalRepulsion"],timestep:[.5,.01,1,.01]},global:{locale:["en","nl"]}};e.allOptions=d,e.configureOptions=l},function(t,e,i){function o(t){return t&&t.__esModule?t:{"default":t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){var i=[],o=!0,n=!1,s=void 0;try{for(var r,a=t[Symbol.iterator]();!(o=(r=a.next()).done)&&(i.push(r.value),!e||i.length!==e);o=!0);}catch(h){n=!0,s=h}finally{try{!o&&a["return"]&&a["return"]()}finally{if(n)throw s}}return i}return function(e,i){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),r=function(){function t(t,e){for(var i=0;in&&h>a;){a+=1;var v=this._getHighestEnergyNode(i),g=s(v,4);for(u=g[0],l=g[1],c=g[2],p=g[3],f=l,m=0;f>r&&d>m;){m+=1,this._moveNode(u,c,p);var y=this._getEnergy(u),b=s(y,3);f=b[0],c=b[1],p=b[2]}}}},{key:"_getHighestEnergyNode",value:function(t){for(var e=this.body.nodeIndices,i=this.body.nodes,o=0,n=e[0],r=0,a=0,h=0;ho&&(o=c,n=d,r=p,a=f)}}return[n,o,r,a]}},{key:"_getEnergy",value:function(t){for(var e=this.body.nodeIndices,i=this.body.nodes,o=i[t].x,n=i[t].y,s=0,r=0,a=0;ad;d++)for(var s=0;h-1>s;s++)for(var r=s+1;h>r;r++)o[e[s]][e[r]]=Math.min(o[e[s]][e[r]],o[e[s]][e[d]]+o[e[d]][e[r]]),o[e[r]][e[s]]=o[e[s]][e[r]];return o}}]),t}();e["default"]=n,t.exports=e["default"]},function(t,e){"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.circle=function(t,e,i){this.beginPath(),this.arc(t,e,i,0,2*Math.PI,!1),this.closePath()},CanvasRenderingContext2D.prototype.square=function(t,e,i){this.beginPath(),this.rect(t-i,e-i,2*i,2*i),this.closePath()},CanvasRenderingContext2D.prototype.triangle=function(t,e,i){this.beginPath(),i*=1.15,e+=.275*i;var o=2*i,n=o/2,s=Math.sqrt(3)/6*o,r=Math.sqrt(o*o-n*n);this.moveTo(t,e-(r-s)),this.lineTo(t+n,e+s),this.lineTo(t-n,e+s),this.lineTo(t,e-(r-s)),this.closePath()},CanvasRenderingContext2D.prototype.triangleDown=function(t,e,i){this.beginPath(),i*=1.15,e-=.275*i;var o=2*i,n=o/2,s=Math.sqrt(3)/6*o,r=Math.sqrt(o*o-n*n);this.moveTo(t,e+(r-s)),this.lineTo(t+n,e-s),this.lineTo(t-n,e-s),this.lineTo(t,e+(r-s)),this.closePath()},CanvasRenderingContext2D.prototype.star=function(t,e,i){this.beginPath(),i*=.82,e+=.1*i;for(var o=0;10>o;o++){var n=o%2===0?1.3*i:.5*i;this.lineTo(t+n*Math.sin(2*o*Math.PI/10),e-n*Math.cos(2*o*Math.PI/10))}this.closePath()},CanvasRenderingContext2D.prototype.diamond=function(t,e,i){this.beginPath(),this.lineTo(t,e+i),this.lineTo(t+i,e),this.lineTo(t,e-i),this.lineTo(t-i,e),this.closePath()},CanvasRenderingContext2D.prototype.roundRect=function(t,e,i,o,n){var s=Math.PI/180;0>i-2*n&&(n=i/2),0>o-2*n&&(n=o/2),this.beginPath(),this.moveTo(t+n,e),this.lineTo(t+i-n,e),this.arc(t+i-n,e+n,n,270*s,360*s,!1),this.lineTo(t+i,e+o-n),this.arc(t+i-n,e+o-n,n,0,90*s,!1),this.lineTo(t+n,e+o),this.arc(t+n,e+o-n,n,90*s,180*s,!1),this.lineTo(t,e+n),this.arc(t+n,e+n,n,180*s,270*s,!1),this.closePath()},CanvasRenderingContext2D.prototype.ellipse=function(t,e,i,o){var n=.5522848,s=i/2*n,r=o/2*n,a=t+i,h=e+o,d=t+i/2,l=e+o/2;this.beginPath(),this.moveTo(t,l),this.bezierCurveTo(t,l-r,d-s,e,d,e),this.bezierCurveTo(d+s,e,a,l-r,a,l),this.bezierCurveTo(a,l+r,d+s,h,d,h),this.bezierCurveTo(d-s,h,t,l+r,t,l),this.closePath()},CanvasRenderingContext2D.prototype.database=function(t,e,i,o){var n=1/3,s=i,r=o*n,a=.5522848,h=s/2*a,d=r/2*a,l=t+s,u=e+r,c=t+s/2,p=e+r/2,f=e+(o-r/2),m=e+o;this.beginPath(),this.moveTo(l,p),this.bezierCurveTo(l,p+d,c+h,u,c,u),this.bezierCurveTo(c-h,u,t,p+d,t,p),this.bezierCurveTo(t,p-d,c-h,e,c,e),this.bezierCurveTo(c+h,e,l,p-d,l,p),this.lineTo(l,f),this.bezierCurveTo(l,f+d,c+h,m,c,m),this.bezierCurveTo(c-h,m,t,f+d,t,f),this.lineTo(t,p)},CanvasRenderingContext2D.prototype.arrow=function(t,e,i,o){var n=t-o*Math.cos(i),s=e-o*Math.sin(i),r=t-.9*o*Math.cos(i),a=e-.9*o*Math.sin(i),h=n+o/3*Math.cos(i+.5*Math.PI),d=s+o/3*Math.sin(i+.5*Math.PI),l=n+o/3*Math.cos(i-.5*Math.PI),u=s+o/3*Math.sin(i-.5*Math.PI);this.beginPath(),this.moveTo(t,e),this.lineTo(h,d),this.lineTo(r,a),this.lineTo(l,u),this.closePath()},CanvasRenderingContext2D.prototype.dashedLine=function(t,e,i,o,n){this.beginPath(),this.moveTo(t,e);for(var s=n.length,r=i-t,a=o-e,h=a/r,d=Math.sqrt(r*r+a*a),l=0,u=!0,c=0,p=n[0];d>=.1;)p=n[l++%s],p>d&&(p=d),c=Math.sqrt(p*p/(1+h*h)),c=0>r?-c:c,t+=c,e+=h*c,u===!0?this.lineTo(t,e):this.moveTo(t,e),d-=p,u=!u})},function(t,e){function i(t){return P=t,p()}function o(){I=0,z=P.charAt(0)}function n(){I++,z=P.charAt(I)}function s(){return P.charAt(I+1)}function r(t){return A.test(t)}function a(t,e){if(t||(t={}),e)for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t}function h(t,e,i){for(var o=e.split("."),n=t;o.length;){var s=o.shift();o.length?(n[s]||(n[s]={}),n=n[s]):n[s]=i}}function d(t,e){for(var i,o,n=null,s=[t],r=t;r.parent;)s.push(r.parent),r=r.parent;if(r.nodes)for(i=0,o=r.nodes.length;o>i;i++)if(e.id===r.nodes[i].id){n=r.nodes[i];break}for(n||(n={id:e.id},t.node&&(n.attr=a(n.attr,t.node))),i=s.length-1;i>=0;i--){var h=s[i];h.nodes||(h.nodes=[]),-1===h.nodes.indexOf(n)&&h.nodes.push(n)}e.attr&&(n.attr=a(n.attr,e.attr))}function l(t,e){if(t.edges||(t.edges=[]),t.edges.push(e),t.edge){var i=a({},t.edge);e.attr=a(i,e.attr)}}function u(t,e,i,o,n){var s={from:e,to:i,type:o};return t.edge&&(s.attr=a({},t.edge)),s.attr=a(s.attr||{},n),s}function c(){for(L=E.NULL,N="";" "===z||" "===z||"\n"===z||"\r"===z;)n();do{var t=!1;if("#"===z){for(var e=I-1;" "===P.charAt(e)||" "===P.charAt(e);)e--;if("\n"===P.charAt(e)||""===P.charAt(e)){for(;""!=z&&"\n"!=z;)n();t=!0}}if("/"===z&&"/"===s()){for(;""!=z&&"\n"!=z;)n();t=!0}if("/"===z&&"*"===s()){for(;""!=z;){if("*"===z&&"/"===s()){n(),n();break}n()}t=!0}for(;" "===z||" "===z||"\n"===z||"\r"===z;)n()}while(t);if(""===z)return void(L=E.DELIMITER);var i=z+s();if(S[i])return L=E.DELIMITER,N=i,n(),void n();if(S[z])return L=E.DELIMITER,N=z,void n();if(r(z)||"-"===z){for(N+=z,n();r(z);)N+=z,n();return"false"===N?N=!1:"true"===N?N=!0:isNaN(Number(N))||(N=Number(N)),void(L=E.IDENTIFIER)}if('"'===z){for(n();""!=z&&('"'!=z||'"'===z&&'"'===s());)N+=z,'"'===z&&n(),n();if('"'!=z)throw _('End of string " expected');return n(),void(L=E.IDENTIFIER)}for(L=E.UNKNOWN;""!=z;)N+=z,n();throw new SyntaxError('Syntax error in part "'+x(N,30)+'"')}function p(){var t={};if(o(),c(),"strict"===N&&(t.strict=!0,c()),("graph"===N||"digraph"===N)&&(t.type=N,c()),L===E.IDENTIFIER&&(t.id=N,c()),"{"!=N)throw _("Angle bracket { expected");if(c(),f(t),"}"!=N)throw _("Angle bracket } expected");if(c(),""!==N)throw _("End of file expected");return c(),delete t.node,delete t.edge,delete t.graph,t}function f(t){for(;""!==N&&"}"!=N;)m(t),";"===N&&c()}function m(t){var e=v(t);if(e)return void b(t,e);var i=g(t);if(!i){if(L!=E.IDENTIFIER)throw _("Identifier expected");var o=N;if(c(),"="===N){if(c(),L!=E.IDENTIFIER)throw _("Identifier expected");t[o]=N,c()}else y(t,o)}}function v(t){var e=null;if("subgraph"===N&&(e={},e.type="subgraph",c(),L===E.IDENTIFIER&&(e.id=N,c())),"{"===N){if(c(),e||(e={}),e.parent=t,e.node=t.node,e.edge=t.edge,e.graph=t.graph,f(e),"}"!=N)throw _("Angle bracket } expected");c(),delete e.node,delete e.edge,delete e.graph,delete e.parent,t.subgraphs||(t.subgraphs=[]),t.subgraphs.push(e)}return e}function g(t){return"node"===N?(c(),t.node=w(),"node"):"edge"===N?(c(),t.edge=w(),"edge"):"graph"===N?(c(),t.graph=w(),"graph"):null}function y(t,e){var i={id:e},o=w();o&&(i.attr=o),d(t,i),b(t,e)}function b(t,e){for(;"->"===N||"--"===N;){var i,o=N;c();var n=v(t);if(n)i=n;else{if(L!=E.IDENTIFIER)throw _("Identifier or subgraph expected");i=N,d(t,{id:i}),c()}var s=w(),r=u(t,e,i,o,s);l(t,r),e=i}}function w(){for(var t=null;"["===N;){for(c(),t={};""!==N&&"]"!=N;){if(L!=E.IDENTIFIER)throw _("Attribute name expected");var e=N;if(c(),"="!=N)throw _("Equal sign = expected");if(c(),L!=E.IDENTIFIER)throw _("Attribute value expected");var i=N;h(t,e,i),c(),","==N&&c()}if("]"!=N)throw _("Bracket ] expected");c()}return t}function _(t){return new SyntaxError(t+', got "'+x(N,30)+'" (char '+I+")")}function x(t,e){return t.length<=e?t:t.substr(0,27)+"..."}function k(t,e,i){Array.isArray(t)?t.forEach(function(t){Array.isArray(e)?e.forEach(function(e){i(t,e)}):i(t,e)}):Array.isArray(e)?e.forEach(function(e){i(t,e)}):i(t,e)}function O(t,e,i){for(var o=e.split("."),n=o.pop(),s=t,r=0;r":!0,"--":!0},P="",I=0,z="",N="",L=E.NULL,A=/[a-zA-Z_0-9.:#]/;e.parseDOT=i,e.DOTToGraph=M},function(t,e){function i(t,e){var i=[],o=[],n={edges:{inheritColor:!1},nodes:{fixed:!1,parseColor:!1}};void 0!==e&&(void 0!==e.fixed&&(n.nodes.fixed=e.fixed),void 0!==e.parseColor&&(n.nodes.parseColor=e.parseColor),void 0!==e.inheritColor&&(n.edges.inheritColor=e.inheritColor));for(var s=t.edges,r=t.nodes,a=0;a + + + + + + +

+ +
+
+

Influences

+
+
+

Dependencies

+
+
+ + + + + + +
+
+ + + \ No newline at end of file diff --git a/schedoscope-metascope/src/main/resources/templates/body/table/sections/dependency.html b/schedoscope-metascope/src/main/resources/templates/body/table/sections/dependency.html index 4298eb9ce..fbefe99e5 100644 --- a/schedoscope-metascope/src/main/resources/templates/body/table/sections/dependency.html +++ b/schedoscope-metascope/src/main/resources/templates/body/table/sections/dependency.html @@ -52,43 +52,10 @@ dependencies
-
+ - +
- - - \ No newline at end of file diff --git a/schedoscope-metascope/src/main/resources/templates/body/viewLineage.html b/schedoscope-metascope/src/main/resources/templates/body/viewLineage.html new file mode 100644 index 000000000..a271a0dc2 --- /dev/null +++ b/schedoscope-metascope/src/main/resources/templates/body/viewLineage.html @@ -0,0 +1,51 @@ + + + + + + + + + +
+
+
+ + + + + + +
+
+ + + \ No newline at end of file diff --git a/schedoscope-metascope/src/main/resources/templates/includes/scripts.html b/schedoscope-metascope/src/main/resources/templates/includes/scripts.html index d5722bdd1..3d3e59ec5 100644 --- a/schedoscope-metascope/src/main/resources/templates/includes/scripts.html +++ b/schedoscope-metascope/src/main/resources/templates/includes/scripts.html @@ -22,10 +22,6 @@ - - - - @@ -37,7 +33,6 @@
- From 484eb4d9a8d613bf64a6b1072266debecd8bbb3f Mon Sep 17 00:00:00 2001 From: Jan Hicken Date: Mon, 12 Jun 2017 17:35:13 +0200 Subject: [PATCH 06/24] Add missing JavaScript libraries. --- .../src/main/resources/static/js/d3.min.js | 5 + .../resources/static/js/dagre-d3.core.min.js | 24 +++++ .../resources/static/js/dagre.core.min.js | 2 + .../resources/static/js/graphlib.core.min.js | 31 ++++++ .../main/resources/static/js/lodash.min.js | 98 +++++++++++++++++++ .../resources/templates/includes/head.html | 6 ++ 6 files changed, 166 insertions(+) create mode 100644 schedoscope-metascope/src/main/resources/static/js/d3.min.js create mode 100644 schedoscope-metascope/src/main/resources/static/js/dagre-d3.core.min.js create mode 100644 schedoscope-metascope/src/main/resources/static/js/dagre.core.min.js create mode 100644 schedoscope-metascope/src/main/resources/static/js/graphlib.core.min.js create mode 100644 schedoscope-metascope/src/main/resources/static/js/lodash.min.js diff --git a/schedoscope-metascope/src/main/resources/static/js/d3.min.js b/schedoscope-metascope/src/main/resources/static/js/d3.min.js new file mode 100644 index 000000000..166487309 --- /dev/null +++ b/schedoscope-metascope/src/main/resources/static/js/d3.min.js @@ -0,0 +1,5 @@ +!function(){function n(n){return n&&(n.ownerDocument||n.document||n).documentElement}function t(n){return n&&(n.ownerDocument&&n.ownerDocument.defaultView||n.document&&n||n.defaultView)}function e(n,t){return t>n?-1:n>t?1:n>=t?0:NaN}function r(n){return null===n?NaN:+n}function i(n){return!isNaN(n)}function u(n){return{left:function(t,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=t.length);i>r;){var u=r+i>>>1;n(t[u],e)<0?r=u+1:i=u}return r},right:function(t,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=t.length);i>r;){var u=r+i>>>1;n(t[u],e)>0?i=u:r=u+1}return r}}}function o(n){return n.length}function a(n){for(var t=1;n*t%1;)t*=10;return t}function l(n,t){for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}function c(){this._=Object.create(null)}function f(n){return(n+="")===bo||n[0]===_o?_o+n:n}function s(n){return(n+="")[0]===_o?n.slice(1):n}function h(n){return f(n)in this._}function p(n){return(n=f(n))in this._&&delete this._[n]}function g(){var n=[];for(var t in this._)n.push(s(t));return n}function v(){var n=0;for(var t in this._)++n;return n}function d(){for(var n in this._)return!1;return!0}function y(){this._=Object.create(null)}function m(n){return n}function M(n,t,e){return function(){var r=e.apply(t,arguments);return r===t?n:r}}function x(n,t){if(t in n)return t;t=t.charAt(0).toUpperCase()+t.slice(1);for(var e=0,r=wo.length;r>e;++e){var i=wo[e]+t;if(i in n)return i}}function b(){}function _(){}function w(n){function t(){for(var t,r=e,i=-1,u=r.length;++ie;e++)for(var i,u=n[e],o=0,a=u.length;a>o;o++)(i=u[o])&&t(i,o,e);return n}function Z(n){return ko(n,qo),n}function V(n){var t,e;return function(r,i,u){var o,a=n[u].update,l=a.length;for(u!=e&&(e=u,t=0),i>=t&&(t=i+1);!(o=a[t])&&++t0&&(n=n.slice(0,a));var c=To.get(n);return c&&(n=c,l=B),a?t?i:r:t?b:u}function $(n,t){return function(e){var r=ao.event;ao.event=e,t[0]=this.__data__;try{n.apply(this,t)}finally{ao.event=r}}}function B(n,t){var e=$(n,t);return function(n){var t=this,r=n.relatedTarget;r&&(r===t||8&r.compareDocumentPosition(t))||e.call(t,n)}}function W(e){var r=".dragsuppress-"+ ++Do,i="click"+r,u=ao.select(t(e)).on("touchmove"+r,S).on("dragstart"+r,S).on("selectstart"+r,S);if(null==Ro&&(Ro="onselectstart"in e?!1:x(e.style,"userSelect")),Ro){var o=n(e).style,a=o[Ro];o[Ro]="none"}return function(n){if(u.on(r,null),Ro&&(o[Ro]=a),n){var t=function(){u.on(i,null)};u.on(i,function(){S(),t()},!0),setTimeout(t,0)}}}function J(n,e){e.changedTouches&&(e=e.changedTouches[0]);var r=n.ownerSVGElement||n;if(r.createSVGPoint){var i=r.createSVGPoint();if(0>Po){var u=t(n);if(u.scrollX||u.scrollY){r=ao.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var o=r[0][0].getScreenCTM();Po=!(o.f||o.e),r.remove()}}return Po?(i.x=e.pageX,i.y=e.pageY):(i.x=e.clientX,i.y=e.clientY),i=i.matrixTransform(n.getScreenCTM().inverse()),[i.x,i.y]}var a=n.getBoundingClientRect();return[e.clientX-a.left-n.clientLeft,e.clientY-a.top-n.clientTop]}function G(){return ao.event.changedTouches[0].identifier}function K(n){return n>0?1:0>n?-1:0}function Q(n,t,e){return(t[0]-n[0])*(e[1]-n[1])-(t[1]-n[1])*(e[0]-n[0])}function nn(n){return n>1?0:-1>n?Fo:Math.acos(n)}function tn(n){return n>1?Io:-1>n?-Io:Math.asin(n)}function en(n){return((n=Math.exp(n))-1/n)/2}function rn(n){return((n=Math.exp(n))+1/n)/2}function un(n){return((n=Math.exp(2*n))-1)/(n+1)}function on(n){return(n=Math.sin(n/2))*n}function an(){}function ln(n,t,e){return this instanceof ln?(this.h=+n,this.s=+t,void(this.l=+e)):arguments.length<2?n instanceof ln?new ln(n.h,n.s,n.l):_n(""+n,wn,ln):new ln(n,t,e)}function cn(n,t,e){function r(n){return n>360?n-=360:0>n&&(n+=360),60>n?u+(o-u)*n/60:180>n?o:240>n?u+(o-u)*(240-n)/60:u}function i(n){return Math.round(255*r(n))}var u,o;return n=isNaN(n)?0:(n%=360)<0?n+360:n,t=isNaN(t)?0:0>t?0:t>1?1:t,e=0>e?0:e>1?1:e,o=.5>=e?e*(1+t):e+t-e*t,u=2*e-o,new mn(i(n+120),i(n),i(n-120))}function fn(n,t,e){return this instanceof fn?(this.h=+n,this.c=+t,void(this.l=+e)):arguments.length<2?n instanceof fn?new fn(n.h,n.c,n.l):n instanceof hn?gn(n.l,n.a,n.b):gn((n=Sn((n=ao.rgb(n)).r,n.g,n.b)).l,n.a,n.b):new fn(n,t,e)}function sn(n,t,e){return isNaN(n)&&(n=0),isNaN(t)&&(t=0),new hn(e,Math.cos(n*=Yo)*t,Math.sin(n)*t)}function hn(n,t,e){return this instanceof hn?(this.l=+n,this.a=+t,void(this.b=+e)):arguments.length<2?n instanceof hn?new hn(n.l,n.a,n.b):n instanceof fn?sn(n.h,n.c,n.l):Sn((n=mn(n)).r,n.g,n.b):new hn(n,t,e)}function pn(n,t,e){var r=(n+16)/116,i=r+t/500,u=r-e/200;return i=vn(i)*na,r=vn(r)*ta,u=vn(u)*ea,new mn(yn(3.2404542*i-1.5371385*r-.4985314*u),yn(-.969266*i+1.8760108*r+.041556*u),yn(.0556434*i-.2040259*r+1.0572252*u))}function gn(n,t,e){return n>0?new fn(Math.atan2(e,t)*Zo,Math.sqrt(t*t+e*e),n):new fn(NaN,NaN,n)}function vn(n){return n>.206893034?n*n*n:(n-4/29)/7.787037}function dn(n){return n>.008856?Math.pow(n,1/3):7.787037*n+4/29}function yn(n){return Math.round(255*(.00304>=n?12.92*n:1.055*Math.pow(n,1/2.4)-.055))}function mn(n,t,e){return this instanceof mn?(this.r=~~n,this.g=~~t,void(this.b=~~e)):arguments.length<2?n instanceof mn?new mn(n.r,n.g,n.b):_n(""+n,mn,cn):new mn(n,t,e)}function Mn(n){return new mn(n>>16,n>>8&255,255&n)}function xn(n){return Mn(n)+""}function bn(n){return 16>n?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16)}function _n(n,t,e){var r,i,u,o=0,a=0,l=0;if(r=/([a-z]+)\((.*)\)/.exec(n=n.toLowerCase()))switch(i=r[2].split(","),r[1]){case"hsl":return e(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return t(Nn(i[0]),Nn(i[1]),Nn(i[2]))}return(u=ua.get(n))?t(u.r,u.g,u.b):(null==n||"#"!==n.charAt(0)||isNaN(u=parseInt(n.slice(1),16))||(4===n.length?(o=(3840&u)>>4,o=o>>4|o,a=240&u,a=a>>4|a,l=15&u,l=l<<4|l):7===n.length&&(o=(16711680&u)>>16,a=(65280&u)>>8,l=255&u)),t(o,a,l))}function wn(n,t,e){var r,i,u=Math.min(n/=255,t/=255,e/=255),o=Math.max(n,t,e),a=o-u,l=(o+u)/2;return a?(i=.5>l?a/(o+u):a/(2-o-u),r=n==o?(t-e)/a+(e>t?6:0):t==o?(e-n)/a+2:(n-t)/a+4,r*=60):(r=NaN,i=l>0&&1>l?0:r),new ln(r,i,l)}function Sn(n,t,e){n=kn(n),t=kn(t),e=kn(e);var r=dn((.4124564*n+.3575761*t+.1804375*e)/na),i=dn((.2126729*n+.7151522*t+.072175*e)/ta),u=dn((.0193339*n+.119192*t+.9503041*e)/ea);return hn(116*i-16,500*(r-i),200*(i-u))}function kn(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function Nn(n){var t=parseFloat(n);return"%"===n.charAt(n.length-1)?Math.round(2.55*t):t}function En(n){return"function"==typeof n?n:function(){return n}}function An(n){return function(t,e,r){return 2===arguments.length&&"function"==typeof e&&(r=e,e=null),Cn(t,e,n,r)}}function Cn(n,t,e,r){function i(){var n,t=l.status;if(!t&&Ln(l)||t>=200&&300>t||304===t){try{n=e.call(u,l)}catch(r){return void o.error.call(u,r)}o.load.call(u,n)}else o.error.call(u,l)}var u={},o=ao.dispatch("beforesend","progress","load","error"),a={},l=new XMLHttpRequest,c=null;return!this.XDomainRequest||"withCredentials"in l||!/^(http(s)?:)?\/\//.test(n)||(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=i:l.onreadystatechange=function(){l.readyState>3&&i()},l.onprogress=function(n){var t=ao.event;ao.event=n;try{o.progress.call(u,l)}finally{ao.event=t}},u.header=function(n,t){return n=(n+"").toLowerCase(),arguments.length<2?a[n]:(null==t?delete a[n]:a[n]=t+"",u)},u.mimeType=function(n){return arguments.length?(t=null==n?null:n+"",u):t},u.responseType=function(n){return arguments.length?(c=n,u):c},u.response=function(n){return e=n,u},["get","post"].forEach(function(n){u[n]=function(){return u.send.apply(u,[n].concat(co(arguments)))}}),u.send=function(e,r,i){if(2===arguments.length&&"function"==typeof r&&(i=r,r=null),l.open(e,n,!0),null==t||"accept"in a||(a.accept=t+",*/*"),l.setRequestHeader)for(var f in a)l.setRequestHeader(f,a[f]);return null!=t&&l.overrideMimeType&&l.overrideMimeType(t),null!=c&&(l.responseType=c),null!=i&&u.on("error",i).on("load",function(n){i(null,n)}),o.beforesend.call(u,l),l.send(null==r?null:r),u},u.abort=function(){return l.abort(),u},ao.rebind(u,o,"on"),null==r?u:u.get(zn(r))}function zn(n){return 1===n.length?function(t,e){n(null==t?e:null)}:n}function Ln(n){var t=n.responseType;return t&&"text"!==t?n.response:n.responseText}function qn(n,t,e){var r=arguments.length;2>r&&(t=0),3>r&&(e=Date.now());var i=e+t,u={c:n,t:i,n:null};return aa?aa.n=u:oa=u,aa=u,la||(ca=clearTimeout(ca),la=1,fa(Tn)),u}function Tn(){var n=Rn(),t=Dn()-n;t>24?(isFinite(t)&&(clearTimeout(ca),ca=setTimeout(Tn,t)),la=0):(la=1,fa(Tn))}function Rn(){for(var n=Date.now(),t=oa;t;)n>=t.t&&t.c(n-t.t)&&(t.c=null),t=t.n;return n}function Dn(){for(var n,t=oa,e=1/0;t;)t.c?(t.t8?function(n){return n/e}:function(n){return n*e},symbol:n}}function jn(n){var t=n.decimal,e=n.thousands,r=n.grouping,i=n.currency,u=r&&e?function(n,t){for(var i=n.length,u=[],o=0,a=r[0],l=0;i>0&&a>0&&(l+a+1>t&&(a=Math.max(1,t-l)),u.push(n.substring(i-=a,i+a)),!((l+=a+1)>t));)a=r[o=(o+1)%r.length];return u.reverse().join(e)}:m;return function(n){var e=ha.exec(n),r=e[1]||" ",o=e[2]||">",a=e[3]||"-",l=e[4]||"",c=e[5],f=+e[6],s=e[7],h=e[8],p=e[9],g=1,v="",d="",y=!1,m=!0;switch(h&&(h=+h.substring(1)),(c||"0"===r&&"="===o)&&(c=r="0",o="="),p){case"n":s=!0,p="g";break;case"%":g=100,d="%",p="f";break;case"p":g=100,d="%",p="r";break;case"b":case"o":case"x":case"X":"#"===l&&(v="0"+p.toLowerCase());case"c":m=!1;case"d":y=!0,h=0;break;case"s":g=-1,p="r"}"$"===l&&(v=i[0],d=i[1]),"r"!=p||h||(p="g"),null!=h&&("g"==p?h=Math.max(1,Math.min(21,h)):"e"!=p&&"f"!=p||(h=Math.max(0,Math.min(20,h)))),p=pa.get(p)||Fn;var M=c&&s;return function(n){var e=d;if(y&&n%1)return"";var i=0>n||0===n&&0>1/n?(n=-n,"-"):"-"===a?"":a;if(0>g){var l=ao.formatPrefix(n,h);n=l.scale(n),e=l.symbol+d}else n*=g;n=p(n,h);var x,b,_=n.lastIndexOf(".");if(0>_){var w=m?n.lastIndexOf("e"):-1;0>w?(x=n,b=""):(x=n.substring(0,w),b=n.substring(w))}else x=n.substring(0,_),b=t+n.substring(_+1);!c&&s&&(x=u(x,1/0));var S=v.length+x.length+b.length+(M?0:i.length),k=f>S?new Array(S=f-S+1).join(r):"";return M&&(x=u(k+x,k.length?f-b.length:1/0)),i+=v,n=x+b,("<"===o?i+n+k:">"===o?k+i+n:"^"===o?k.substring(0,S>>=1)+i+n+k.substring(S):i+(M?n:k+n))+e}}}function Fn(n){return n+""}function Hn(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function On(n,t,e){function r(t){var e=n(t),r=u(e,1);return r-t>t-e?e:r}function i(e){return t(e=n(new va(e-1)),1),e}function u(n,e){return t(n=new va(+n),e),n}function o(n,r,u){var o=i(n),a=[];if(u>1)for(;r>o;)e(o)%u||a.push(new Date(+o)),t(o,1);else for(;r>o;)a.push(new Date(+o)),t(o,1);return a}function a(n,t,e){try{va=Hn;var r=new Hn;return r._=n,o(r,t,e)}finally{va=Date}}n.floor=n,n.round=r,n.ceil=i,n.offset=u,n.range=o;var l=n.utc=In(n);return l.floor=l,l.round=In(r),l.ceil=In(i),l.offset=In(u),l.range=a,n}function In(n){return function(t,e){try{va=Hn;var r=new Hn;return r._=t,n(r,e)._}finally{va=Date}}}function Yn(n){function t(n){function t(t){for(var e,i,u,o=[],a=-1,l=0;++aa;){if(r>=c)return-1;if(i=t.charCodeAt(a++),37===i){if(o=t.charAt(a++),u=C[o in ya?t.charAt(a++):o],!u||(r=u(n,e,r))<0)return-1}else if(i!=e.charCodeAt(r++))return-1}return r}function r(n,t,e){_.lastIndex=0;var r=_.exec(t.slice(e));return r?(n.w=w.get(r[0].toLowerCase()),e+r[0].length):-1}function i(n,t,e){x.lastIndex=0;var r=x.exec(t.slice(e));return r?(n.w=b.get(r[0].toLowerCase()),e+r[0].length):-1}function u(n,t,e){N.lastIndex=0;var r=N.exec(t.slice(e));return r?(n.m=E.get(r[0].toLowerCase()),e+r[0].length):-1}function o(n,t,e){S.lastIndex=0;var r=S.exec(t.slice(e));return r?(n.m=k.get(r[0].toLowerCase()),e+r[0].length):-1}function a(n,t,r){return e(n,A.c.toString(),t,r)}function l(n,t,r){return e(n,A.x.toString(),t,r)}function c(n,t,r){return e(n,A.X.toString(),t,r)}function f(n,t,e){var r=M.get(t.slice(e,e+=2).toLowerCase());return null==r?-1:(n.p=r,e)}var s=n.dateTime,h=n.date,p=n.time,g=n.periods,v=n.days,d=n.shortDays,y=n.months,m=n.shortMonths;t.utc=function(n){function e(n){try{va=Hn;var t=new va;return t._=n,r(t)}finally{va=Date}}var r=t(n);return e.parse=function(n){try{va=Hn;var t=r.parse(n);return t&&t._}finally{va=Date}},e.toString=r.toString,e},t.multi=t.utc.multi=ct;var M=ao.map(),x=Vn(v),b=Xn(v),_=Vn(d),w=Xn(d),S=Vn(y),k=Xn(y),N=Vn(m),E=Xn(m);g.forEach(function(n,t){M.set(n.toLowerCase(),t)});var A={a:function(n){return d[n.getDay()]},A:function(n){return v[n.getDay()]},b:function(n){return m[n.getMonth()]},B:function(n){return y[n.getMonth()]},c:t(s),d:function(n,t){return Zn(n.getDate(),t,2)},e:function(n,t){return Zn(n.getDate(),t,2)},H:function(n,t){return Zn(n.getHours(),t,2)},I:function(n,t){return Zn(n.getHours()%12||12,t,2)},j:function(n,t){return Zn(1+ga.dayOfYear(n),t,3)},L:function(n,t){return Zn(n.getMilliseconds(),t,3)},m:function(n,t){return Zn(n.getMonth()+1,t,2)},M:function(n,t){return Zn(n.getMinutes(),t,2)},p:function(n){return g[+(n.getHours()>=12)]},S:function(n,t){return Zn(n.getSeconds(),t,2)},U:function(n,t){return Zn(ga.sundayOfYear(n),t,2)},w:function(n){return n.getDay()},W:function(n,t){return Zn(ga.mondayOfYear(n),t,2)},x:t(h),X:t(p),y:function(n,t){return Zn(n.getFullYear()%100,t,2)},Y:function(n,t){return Zn(n.getFullYear()%1e4,t,4)},Z:at,"%":function(){return"%"}},C={a:r,A:i,b:u,B:o,c:a,d:tt,e:tt,H:rt,I:rt,j:et,L:ot,m:nt,M:it,p:f,S:ut,U:Bn,w:$n,W:Wn,x:l,X:c,y:Gn,Y:Jn,Z:Kn,"%":lt};return t}function Zn(n,t,e){var r=0>n?"-":"",i=(r?-n:n)+"",u=i.length;return r+(e>u?new Array(e-u+1).join(t)+i:i)}function Vn(n){return new RegExp("^(?:"+n.map(ao.requote).join("|")+")","i")}function Xn(n){for(var t=new c,e=-1,r=n.length;++e68?1900:2e3)}function nt(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+2));return r?(n.m=r[0]-1,e+r[0].length):-1}function tt(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+2));return r?(n.d=+r[0],e+r[0].length):-1}function et(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+3));return r?(n.j=+r[0],e+r[0].length):-1}function rt(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+2));return r?(n.H=+r[0],e+r[0].length):-1}function it(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+2));return r?(n.M=+r[0],e+r[0].length):-1}function ut(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+2));return r?(n.S=+r[0],e+r[0].length):-1}function ot(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+3));return r?(n.L=+r[0],e+r[0].length):-1}function at(n){var t=n.getTimezoneOffset(),e=t>0?"-":"+",r=xo(t)/60|0,i=xo(t)%60;return e+Zn(r,"0",2)+Zn(i,"0",2)}function lt(n,t,e){Ma.lastIndex=0;var r=Ma.exec(t.slice(e,e+1));return r?e+r[0].length:-1}function ct(n){for(var t=n.length,e=-1;++e=0?1:-1,a=o*e,l=Math.cos(t),c=Math.sin(t),f=u*c,s=i*l+f*Math.cos(a),h=f*o*Math.sin(a);ka.add(Math.atan2(h,s)),r=n,i=l,u=c}var t,e,r,i,u;Na.point=function(o,a){Na.point=n,r=(t=o)*Yo,i=Math.cos(a=(e=a)*Yo/2+Fo/4),u=Math.sin(a)},Na.lineEnd=function(){n(t,e)}}function dt(n){var t=n[0],e=n[1],r=Math.cos(e);return[r*Math.cos(t),r*Math.sin(t),Math.sin(e)]}function yt(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]}function mt(n,t){return[n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]]}function Mt(n,t){n[0]+=t[0],n[1]+=t[1],n[2]+=t[2]}function xt(n,t){return[n[0]*t,n[1]*t,n[2]*t]}function bt(n){var t=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);n[0]/=t,n[1]/=t,n[2]/=t}function _t(n){return[Math.atan2(n[1],n[0]),tn(n[2])]}function wt(n,t){return xo(n[0]-t[0])a;++a)i.point((e=n[a])[0],e[1]);return void i.lineEnd()}var l=new Tt(e,n,null,!0),c=new Tt(e,null,l,!1);l.o=c,u.push(l),o.push(c),l=new Tt(r,n,null,!1),c=new Tt(r,null,l,!0),l.o=c,u.push(l),o.push(c)}}),o.sort(t),qt(u),qt(o),u.length){for(var a=0,l=e,c=o.length;c>a;++a)o[a].e=l=!l;for(var f,s,h=u[0];;){for(var p=h,g=!0;p.v;)if((p=p.n)===h)return;f=p.z,i.lineStart();do{if(p.v=p.o.v=!0,p.e){if(g)for(var a=0,c=f.length;c>a;++a)i.point((s=f[a])[0],s[1]);else r(p.x,p.n.x,1,i);p=p.n}else{if(g){f=p.p.z;for(var a=f.length-1;a>=0;--a)i.point((s=f[a])[0],s[1])}else r(p.x,p.p.x,-1,i);p=p.p}p=p.o,f=p.z,g=!g}while(!p.v);i.lineEnd()}}}function qt(n){if(t=n.length){for(var t,e,r=0,i=n[0];++r0){for(b||(u.polygonStart(),b=!0),u.lineStart();++o1&&2&t&&e.push(e.pop().concat(e.shift())),p.push(e.filter(Dt))}var p,g,v,d=t(u),y=i.invert(r[0],r[1]),m={point:o,lineStart:l,lineEnd:c,polygonStart:function(){m.point=f,m.lineStart=s,m.lineEnd=h,p=[],g=[]},polygonEnd:function(){m.point=o,m.lineStart=l,m.lineEnd=c,p=ao.merge(p);var n=Ot(y,g);p.length?(b||(u.polygonStart(),b=!0),Lt(p,Ut,n,e,u)):n&&(b||(u.polygonStart(),b=!0),u.lineStart(),e(null,null,1,u),u.lineEnd()),b&&(u.polygonEnd(),b=!1),p=g=null},sphere:function(){u.polygonStart(),u.lineStart(),e(null,null,1,u),u.lineEnd(),u.polygonEnd()}},M=Pt(),x=t(M),b=!1;return m}}function Dt(n){return n.length>1}function Pt(){var n,t=[];return{lineStart:function(){t.push(n=[])},point:function(t,e){n.push([t,e])},lineEnd:b,buffer:function(){var e=t;return t=[],n=null,e},rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))}}}function Ut(n,t){return((n=n.x)[0]<0?n[1]-Io-Uo:Io-n[1])-((t=t.x)[0]<0?t[1]-Io-Uo:Io-t[1])}function jt(n){var t,e=NaN,r=NaN,i=NaN;return{lineStart:function(){n.lineStart(),t=1},point:function(u,o){var a=u>0?Fo:-Fo,l=xo(u-e);xo(l-Fo)0?Io:-Io),n.point(i,r),n.lineEnd(),n.lineStart(),n.point(a,r),n.point(u,r),t=0):i!==a&&l>=Fo&&(xo(e-i)Uo?Math.atan((Math.sin(t)*(u=Math.cos(r))*Math.sin(e)-Math.sin(r)*(i=Math.cos(t))*Math.sin(n))/(i*u*o)):(t+r)/2}function Ht(n,t,e,r){var i;if(null==n)i=e*Io,r.point(-Fo,i),r.point(0,i),r.point(Fo,i),r.point(Fo,0),r.point(Fo,-i),r.point(0,-i),r.point(-Fo,-i),r.point(-Fo,0),r.point(-Fo,i);else if(xo(n[0]-t[0])>Uo){var u=n[0]a;++a){var c=t[a],f=c.length;if(f)for(var s=c[0],h=s[0],p=s[1]/2+Fo/4,g=Math.sin(p),v=Math.cos(p),d=1;;){d===f&&(d=0),n=c[d];var y=n[0],m=n[1]/2+Fo/4,M=Math.sin(m),x=Math.cos(m),b=y-h,_=b>=0?1:-1,w=_*b,S=w>Fo,k=g*M;if(ka.add(Math.atan2(k*_*Math.sin(w),v*x+k*Math.cos(w))),u+=S?b+_*Ho:b,S^h>=e^y>=e){var N=mt(dt(s),dt(n));bt(N);var E=mt(i,N);bt(E);var A=(S^b>=0?-1:1)*tn(E[2]);(r>A||r===A&&(N[0]||N[1]))&&(o+=S^b>=0?1:-1)}if(!d++)break;h=y,g=M,v=x,s=n}}return(-Uo>u||Uo>u&&-Uo>ka)^1&o}function It(n){function t(n,t){return Math.cos(n)*Math.cos(t)>u}function e(n){var e,u,l,c,f;return{lineStart:function(){c=l=!1,f=1},point:function(s,h){var p,g=[s,h],v=t(s,h),d=o?v?0:i(s,h):v?i(s+(0>s?Fo:-Fo),h):0;if(!e&&(c=l=v)&&n.lineStart(),v!==l&&(p=r(e,g),(wt(e,p)||wt(g,p))&&(g[0]+=Uo,g[1]+=Uo,v=t(g[0],g[1]))),v!==l)f=0,v?(n.lineStart(),p=r(g,e),n.point(p[0],p[1])):(p=r(e,g),n.point(p[0],p[1]),n.lineEnd()),e=p;else if(a&&e&&o^v){var y;d&u||!(y=r(g,e,!0))||(f=0,o?(n.lineStart(),n.point(y[0][0],y[0][1]),n.point(y[1][0],y[1][1]),n.lineEnd()):(n.point(y[1][0],y[1][1]),n.lineEnd(),n.lineStart(),n.point(y[0][0],y[0][1])))}!v||e&&wt(e,g)||n.point(g[0],g[1]),e=g,l=v,u=d},lineEnd:function(){l&&n.lineEnd(),e=null},clean:function(){return f|(c&&l)<<1}}}function r(n,t,e){var r=dt(n),i=dt(t),o=[1,0,0],a=mt(r,i),l=yt(a,a),c=a[0],f=l-c*c;if(!f)return!e&&n;var s=u*l/f,h=-u*c/f,p=mt(o,a),g=xt(o,s),v=xt(a,h);Mt(g,v);var d=p,y=yt(g,d),m=yt(d,d),M=y*y-m*(yt(g,g)-1);if(!(0>M)){var x=Math.sqrt(M),b=xt(d,(-y-x)/m);if(Mt(b,g),b=_t(b),!e)return b;var _,w=n[0],S=t[0],k=n[1],N=t[1];w>S&&(_=w,w=S,S=_);var E=S-w,A=xo(E-Fo)E;if(!A&&k>N&&(_=k,k=N,N=_),C?A?k+N>0^b[1]<(xo(b[0]-w)Fo^(w<=b[0]&&b[0]<=S)){var z=xt(d,(-y+x)/m);return Mt(z,g),[b,_t(z)]}}}function i(t,e){var r=o?n:Fo-n,i=0;return-r>t?i|=1:t>r&&(i|=2),-r>e?i|=4:e>r&&(i|=8),i}var u=Math.cos(n),o=u>0,a=xo(u)>Uo,l=ve(n,6*Yo);return Rt(t,e,l,o?[0,-n]:[-Fo,n-Fo])}function Yt(n,t,e,r){return function(i){var u,o=i.a,a=i.b,l=o.x,c=o.y,f=a.x,s=a.y,h=0,p=1,g=f-l,v=s-c;if(u=n-l,g||!(u>0)){if(u/=g,0>g){if(h>u)return;p>u&&(p=u)}else if(g>0){if(u>p)return;u>h&&(h=u)}if(u=e-l,g||!(0>u)){if(u/=g,0>g){if(u>p)return;u>h&&(h=u)}else if(g>0){if(h>u)return;p>u&&(p=u)}if(u=t-c,v||!(u>0)){if(u/=v,0>v){if(h>u)return;p>u&&(p=u)}else if(v>0){if(u>p)return;u>h&&(h=u)}if(u=r-c,v||!(0>u)){if(u/=v,0>v){if(u>p)return;u>h&&(h=u)}else if(v>0){if(h>u)return;p>u&&(p=u)}return h>0&&(i.a={x:l+h*g,y:c+h*v}),1>p&&(i.b={x:l+p*g,y:c+p*v}),i}}}}}}function Zt(n,t,e,r){function i(r,i){return xo(r[0]-n)0?0:3:xo(r[0]-e)0?2:1:xo(r[1]-t)0?1:0:i>0?3:2}function u(n,t){return o(n.x,t.x)}function o(n,t){var e=i(n,1),r=i(t,1);return e!==r?e-r:0===e?t[1]-n[1]:1===e?n[0]-t[0]:2===e?n[1]-t[1]:t[0]-n[0]}return function(a){function l(n){for(var t=0,e=d.length,r=n[1],i=0;e>i;++i)for(var u,o=1,a=d[i],l=a.length,c=a[0];l>o;++o)u=a[o],c[1]<=r?u[1]>r&&Q(c,u,n)>0&&++t:u[1]<=r&&Q(c,u,n)<0&&--t,c=u;return 0!==t}function c(u,a,l,c){var f=0,s=0;if(null==u||(f=i(u,l))!==(s=i(a,l))||o(u,a)<0^l>0){do c.point(0===f||3===f?n:e,f>1?r:t);while((f=(f+l+4)%4)!==s)}else c.point(a[0],a[1])}function f(i,u){return i>=n&&e>=i&&u>=t&&r>=u}function s(n,t){f(n,t)&&a.point(n,t)}function h(){C.point=g,d&&d.push(y=[]),S=!0,w=!1,b=_=NaN}function p(){v&&(g(m,M),x&&w&&E.rejoin(),v.push(E.buffer())),C.point=s,w&&a.lineEnd()}function g(n,t){n=Math.max(-Ha,Math.min(Ha,n)),t=Math.max(-Ha,Math.min(Ha,t));var e=f(n,t);if(d&&y.push([n,t]),S)m=n,M=t,x=e,S=!1,e&&(a.lineStart(),a.point(n,t));else if(e&&w)a.point(n,t);else{var r={a:{x:b,y:_},b:{x:n,y:t}};A(r)?(w||(a.lineStart(),a.point(r.a.x,r.a.y)),a.point(r.b.x,r.b.y),e||a.lineEnd(),k=!1):e&&(a.lineStart(),a.point(n,t),k=!1)}b=n,_=t,w=e}var v,d,y,m,M,x,b,_,w,S,k,N=a,E=Pt(),A=Yt(n,t,e,r),C={point:s,lineStart:h,lineEnd:p,polygonStart:function(){a=E,v=[],d=[],k=!0},polygonEnd:function(){a=N,v=ao.merge(v);var t=l([n,r]),e=k&&t,i=v.length;(e||i)&&(a.polygonStart(),e&&(a.lineStart(),c(null,null,1,a),a.lineEnd()),i&&Lt(v,u,t,c,a),a.polygonEnd()),v=d=y=null}};return C}}function Vt(n){var t=0,e=Fo/3,r=ae(n),i=r(t,e);return i.parallels=function(n){return arguments.length?r(t=n[0]*Fo/180,e=n[1]*Fo/180):[t/Fo*180,e/Fo*180]},i}function Xt(n,t){function e(n,t){var e=Math.sqrt(u-2*i*Math.sin(t))/i;return[e*Math.sin(n*=i),o-e*Math.cos(n)]}var r=Math.sin(n),i=(r+Math.sin(t))/2,u=1+r*(2*i-r),o=Math.sqrt(u)/i;return e.invert=function(n,t){var e=o-t;return[Math.atan2(n,e)/i,tn((u-(n*n+e*e)*i*i)/(2*i))]},e}function $t(){function n(n,t){Ia+=i*n-r*t,r=n,i=t}var t,e,r,i;$a.point=function(u,o){$a.point=n,t=r=u,e=i=o},$a.lineEnd=function(){n(t,e)}}function Bt(n,t){Ya>n&&(Ya=n),n>Va&&(Va=n),Za>t&&(Za=t),t>Xa&&(Xa=t)}function Wt(){function n(n,t){o.push("M",n,",",t,u)}function t(n,t){o.push("M",n,",",t),a.point=e}function e(n,t){o.push("L",n,",",t)}function r(){a.point=n}function i(){o.push("Z")}var u=Jt(4.5),o=[],a={point:n,lineStart:function(){a.point=t},lineEnd:r,polygonStart:function(){a.lineEnd=i},polygonEnd:function(){a.lineEnd=r,a.point=n},pointRadius:function(n){return u=Jt(n),a},result:function(){if(o.length){var n=o.join("");return o=[],n}}};return a}function Jt(n){return"m0,"+n+"a"+n+","+n+" 0 1,1 0,"+-2*n+"a"+n+","+n+" 0 1,1 0,"+2*n+"z"}function Gt(n,t){Ca+=n,za+=t,++La}function Kt(){function n(n,r){var i=n-t,u=r-e,o=Math.sqrt(i*i+u*u);qa+=o*(t+n)/2,Ta+=o*(e+r)/2,Ra+=o,Gt(t=n,e=r)}var t,e;Wa.point=function(r,i){Wa.point=n,Gt(t=r,e=i)}}function Qt(){Wa.point=Gt}function ne(){function n(n,t){var e=n-r,u=t-i,o=Math.sqrt(e*e+u*u);qa+=o*(r+n)/2,Ta+=o*(i+t)/2,Ra+=o,o=i*n-r*t,Da+=o*(r+n),Pa+=o*(i+t),Ua+=3*o,Gt(r=n,i=t)}var t,e,r,i;Wa.point=function(u,o){Wa.point=n,Gt(t=r=u,e=i=o)},Wa.lineEnd=function(){n(t,e)}}function te(n){function t(t,e){n.moveTo(t+o,e),n.arc(t,e,o,0,Ho)}function e(t,e){n.moveTo(t,e),a.point=r}function r(t,e){n.lineTo(t,e)}function i(){a.point=t}function u(){n.closePath()}var o=4.5,a={point:t,lineStart:function(){a.point=e},lineEnd:i,polygonStart:function(){a.lineEnd=u},polygonEnd:function(){a.lineEnd=i,a.point=t},pointRadius:function(n){return o=n,a},result:b};return a}function ee(n){function t(n){return(a?r:e)(n)}function e(t){return ue(t,function(e,r){e=n(e,r),t.point(e[0],e[1])})}function r(t){function e(e,r){e=n(e,r),t.point(e[0],e[1])}function r(){M=NaN,S.point=u,t.lineStart()}function u(e,r){var u=dt([e,r]),o=n(e,r);i(M,x,m,b,_,w,M=o[0],x=o[1],m=e,b=u[0],_=u[1],w=u[2],a,t),t.point(M,x)}function o(){S.point=e,t.lineEnd()}function l(){ +r(),S.point=c,S.lineEnd=f}function c(n,t){u(s=n,h=t),p=M,g=x,v=b,d=_,y=w,S.point=u}function f(){i(M,x,m,b,_,w,p,g,s,v,d,y,a,t),S.lineEnd=o,o()}var s,h,p,g,v,d,y,m,M,x,b,_,w,S={point:e,lineStart:r,lineEnd:o,polygonStart:function(){t.polygonStart(),S.lineStart=l},polygonEnd:function(){t.polygonEnd(),S.lineStart=r}};return S}function i(t,e,r,a,l,c,f,s,h,p,g,v,d,y){var m=f-t,M=s-e,x=m*m+M*M;if(x>4*u&&d--){var b=a+p,_=l+g,w=c+v,S=Math.sqrt(b*b+_*_+w*w),k=Math.asin(w/=S),N=xo(xo(w)-1)u||xo((m*z+M*L)/x-.5)>.3||o>a*p+l*g+c*v)&&(i(t,e,r,a,l,c,A,C,N,b/=S,_/=S,w,d,y),y.point(A,C),i(A,C,N,b,_,w,f,s,h,p,g,v,d,y))}}var u=.5,o=Math.cos(30*Yo),a=16;return t.precision=function(n){return arguments.length?(a=(u=n*n)>0&&16,t):Math.sqrt(u)},t}function re(n){var t=ee(function(t,e){return n([t*Zo,e*Zo])});return function(n){return le(t(n))}}function ie(n){this.stream=n}function ue(n,t){return{point:t,sphere:function(){n.sphere()},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}}}function oe(n){return ae(function(){return n})()}function ae(n){function t(n){return n=a(n[0]*Yo,n[1]*Yo),[n[0]*h+l,c-n[1]*h]}function e(n){return n=a.invert((n[0]-l)/h,(c-n[1])/h),n&&[n[0]*Zo,n[1]*Zo]}function r(){a=Ct(o=se(y,M,x),u);var n=u(v,d);return l=p-n[0]*h,c=g+n[1]*h,i()}function i(){return f&&(f.valid=!1,f=null),t}var u,o,a,l,c,f,s=ee(function(n,t){return n=u(n,t),[n[0]*h+l,c-n[1]*h]}),h=150,p=480,g=250,v=0,d=0,y=0,M=0,x=0,b=Fa,_=m,w=null,S=null;return t.stream=function(n){return f&&(f.valid=!1),f=le(b(o,s(_(n)))),f.valid=!0,f},t.clipAngle=function(n){return arguments.length?(b=null==n?(w=n,Fa):It((w=+n)*Yo),i()):w},t.clipExtent=function(n){return arguments.length?(S=n,_=n?Zt(n[0][0],n[0][1],n[1][0],n[1][1]):m,i()):S},t.scale=function(n){return arguments.length?(h=+n,r()):h},t.translate=function(n){return arguments.length?(p=+n[0],g=+n[1],r()):[p,g]},t.center=function(n){return arguments.length?(v=n[0]%360*Yo,d=n[1]%360*Yo,r()):[v*Zo,d*Zo]},t.rotate=function(n){return arguments.length?(y=n[0]%360*Yo,M=n[1]%360*Yo,x=n.length>2?n[2]%360*Yo:0,r()):[y*Zo,M*Zo,x*Zo]},ao.rebind(t,s,"precision"),function(){return u=n.apply(this,arguments),t.invert=u.invert&&e,r()}}function le(n){return ue(n,function(t,e){n.point(t*Yo,e*Yo)})}function ce(n,t){return[n,t]}function fe(n,t){return[n>Fo?n-Ho:-Fo>n?n+Ho:n,t]}function se(n,t,e){return n?t||e?Ct(pe(n),ge(t,e)):pe(n):t||e?ge(t,e):fe}function he(n){return function(t,e){return t+=n,[t>Fo?t-Ho:-Fo>t?t+Ho:t,e]}}function pe(n){var t=he(n);return t.invert=he(-n),t}function ge(n,t){function e(n,t){var e=Math.cos(t),a=Math.cos(n)*e,l=Math.sin(n)*e,c=Math.sin(t),f=c*r+a*i;return[Math.atan2(l*u-f*o,a*r-c*i),tn(f*u+l*o)]}var r=Math.cos(n),i=Math.sin(n),u=Math.cos(t),o=Math.sin(t);return e.invert=function(n,t){var e=Math.cos(t),a=Math.cos(n)*e,l=Math.sin(n)*e,c=Math.sin(t),f=c*u-l*o;return[Math.atan2(l*u+c*o,a*r+f*i),tn(f*r-a*i)]},e}function ve(n,t){var e=Math.cos(n),r=Math.sin(n);return function(i,u,o,a){var l=o*t;null!=i?(i=de(e,i),u=de(e,u),(o>0?u>i:i>u)&&(i+=o*Ho)):(i=n+o*Ho,u=n-.5*l);for(var c,f=i;o>0?f>u:u>f;f-=l)a.point((c=_t([e,-r*Math.cos(f),-r*Math.sin(f)]))[0],c[1])}}function de(n,t){var e=dt(t);e[0]-=n,bt(e);var r=nn(-e[1]);return((-e[2]<0?-r:r)+2*Math.PI-Uo)%(2*Math.PI)}function ye(n,t,e){var r=ao.range(n,t-Uo,e).concat(t);return function(n){return r.map(function(t){return[n,t]})}}function me(n,t,e){var r=ao.range(n,t-Uo,e).concat(t);return function(n){return r.map(function(t){return[t,n]})}}function Me(n){return n.source}function xe(n){return n.target}function be(n,t,e,r){var i=Math.cos(t),u=Math.sin(t),o=Math.cos(r),a=Math.sin(r),l=i*Math.cos(n),c=i*Math.sin(n),f=o*Math.cos(e),s=o*Math.sin(e),h=2*Math.asin(Math.sqrt(on(r-t)+i*o*on(e-n))),p=1/Math.sin(h),g=h?function(n){var t=Math.sin(n*=h)*p,e=Math.sin(h-n)*p,r=e*l+t*f,i=e*c+t*s,o=e*u+t*a;return[Math.atan2(i,r)*Zo,Math.atan2(o,Math.sqrt(r*r+i*i))*Zo]}:function(){return[n*Zo,t*Zo]};return g.distance=h,g}function _e(){function n(n,i){var u=Math.sin(i*=Yo),o=Math.cos(i),a=xo((n*=Yo)-t),l=Math.cos(a);Ja+=Math.atan2(Math.sqrt((a=o*Math.sin(a))*a+(a=r*u-e*o*l)*a),e*u+r*o*l),t=n,e=u,r=o}var t,e,r;Ga.point=function(i,u){t=i*Yo,e=Math.sin(u*=Yo),r=Math.cos(u),Ga.point=n},Ga.lineEnd=function(){Ga.point=Ga.lineEnd=b}}function we(n,t){function e(t,e){var r=Math.cos(t),i=Math.cos(e),u=n(r*i);return[u*i*Math.sin(t),u*Math.sin(e)]}return e.invert=function(n,e){var r=Math.sqrt(n*n+e*e),i=t(r),u=Math.sin(i),o=Math.cos(i);return[Math.atan2(n*u,r*o),Math.asin(r&&e*u/r)]},e}function Se(n,t){function e(n,t){o>0?-Io+Uo>t&&(t=-Io+Uo):t>Io-Uo&&(t=Io-Uo);var e=o/Math.pow(i(t),u);return[e*Math.sin(u*n),o-e*Math.cos(u*n)]}var r=Math.cos(n),i=function(n){return Math.tan(Fo/4+n/2)},u=n===t?Math.sin(n):Math.log(r/Math.cos(t))/Math.log(i(t)/i(n)),o=r*Math.pow(i(n),u)/u;return u?(e.invert=function(n,t){var e=o-t,r=K(u)*Math.sqrt(n*n+e*e);return[Math.atan2(n,e)/u,2*Math.atan(Math.pow(o/r,1/u))-Io]},e):Ne}function ke(n,t){function e(n,t){var e=u-t;return[e*Math.sin(i*n),u-e*Math.cos(i*n)]}var r=Math.cos(n),i=n===t?Math.sin(n):(r-Math.cos(t))/(t-n),u=r/i+n;return xo(i)i;i++){for(;r>1&&Q(n[e[r-2]],n[e[r-1]],n[i])<=0;)--r;e[r++]=i}return e.slice(0,r)}function qe(n,t){return n[0]-t[0]||n[1]-t[1]}function Te(n,t,e){return(e[0]-t[0])*(n[1]-t[1])<(e[1]-t[1])*(n[0]-t[0])}function Re(n,t,e,r){var i=n[0],u=e[0],o=t[0]-i,a=r[0]-u,l=n[1],c=e[1],f=t[1]-l,s=r[1]-c,h=(a*(l-c)-s*(i-u))/(s*o-a*f);return[i+h*o,l+h*f]}function De(n){var t=n[0],e=n[n.length-1];return!(t[0]-e[0]||t[1]-e[1])}function Pe(){rr(this),this.edge=this.site=this.circle=null}function Ue(n){var t=cl.pop()||new Pe;return t.site=n,t}function je(n){Be(n),ol.remove(n),cl.push(n),rr(n)}function Fe(n){var t=n.circle,e=t.x,r=t.cy,i={x:e,y:r},u=n.P,o=n.N,a=[n];je(n);for(var l=u;l.circle&&xo(e-l.circle.x)f;++f)c=a[f],l=a[f-1],nr(c.edge,l.site,c.site,i);l=a[0],c=a[s-1],c.edge=Ke(l.site,c.site,null,i),$e(l),$e(c)}function He(n){for(var t,e,r,i,u=n.x,o=n.y,a=ol._;a;)if(r=Oe(a,o)-u,r>Uo)a=a.L;else{if(i=u-Ie(a,o),!(i>Uo)){r>-Uo?(t=a.P,e=a):i>-Uo?(t=a,e=a.N):t=e=a;break}if(!a.R){t=a;break}a=a.R}var l=Ue(n);if(ol.insert(t,l),t||e){if(t===e)return Be(t),e=Ue(t.site),ol.insert(l,e),l.edge=e.edge=Ke(t.site,l.site),$e(t),void $e(e);if(!e)return void(l.edge=Ke(t.site,l.site));Be(t),Be(e);var c=t.site,f=c.x,s=c.y,h=n.x-f,p=n.y-s,g=e.site,v=g.x-f,d=g.y-s,y=2*(h*d-p*v),m=h*h+p*p,M=v*v+d*d,x={x:(d*m-p*M)/y+f,y:(h*M-v*m)/y+s};nr(e.edge,c,g,x),l.edge=Ke(c,n,null,x),e.edge=Ke(n,g,null,x),$e(t),$e(e)}}function Oe(n,t){var e=n.site,r=e.x,i=e.y,u=i-t;if(!u)return r;var o=n.P;if(!o)return-(1/0);e=o.site;var a=e.x,l=e.y,c=l-t;if(!c)return a;var f=a-r,s=1/u-1/c,h=f/c;return s?(-h+Math.sqrt(h*h-2*s*(f*f/(-2*c)-l+c/2+i-u/2)))/s+r:(r+a)/2}function Ie(n,t){var e=n.N;if(e)return Oe(e,t);var r=n.site;return r.y===t?r.x:1/0}function Ye(n){this.site=n,this.edges=[]}function Ze(n){for(var t,e,r,i,u,o,a,l,c,f,s=n[0][0],h=n[1][0],p=n[0][1],g=n[1][1],v=ul,d=v.length;d--;)if(u=v[d],u&&u.prepare())for(a=u.edges,l=a.length,o=0;l>o;)f=a[o].end(),r=f.x,i=f.y,c=a[++o%l].start(),t=c.x,e=c.y,(xo(r-t)>Uo||xo(i-e)>Uo)&&(a.splice(o,0,new tr(Qe(u.site,f,xo(r-s)Uo?{x:s,y:xo(t-s)Uo?{x:xo(e-g)Uo?{x:h,y:xo(t-h)Uo?{x:xo(e-p)=-jo)){var p=l*l+c*c,g=f*f+s*s,v=(s*p-c*g)/h,d=(l*g-f*p)/h,s=d+a,y=fl.pop()||new Xe;y.arc=n,y.site=i,y.x=v+o,y.y=s+Math.sqrt(v*v+d*d),y.cy=s,n.circle=y;for(var m=null,M=ll._;M;)if(y.yd||d>=a)return;if(h>g){if(u){if(u.y>=c)return}else u={x:d,y:l};e={x:d,y:c}}else{if(u){if(u.yr||r>1)if(h>g){if(u){if(u.y>=c)return}else u={x:(l-i)/r,y:l};e={x:(c-i)/r,y:c}}else{if(u){if(u.yp){if(u){if(u.x>=a)return}else u={x:o,y:r*o+i};e={x:a,y:r*a+i}}else{if(u){if(u.xu||s>o||r>h||i>p)){if(g=n.point){var g,v=t-n.x,d=e-n.y,y=v*v+d*d;if(l>y){var m=Math.sqrt(l=y);r=t-m,i=e-m,u=t+m,o=e+m,a=g}}for(var M=n.nodes,x=.5*(f+h),b=.5*(s+p),_=t>=x,w=e>=b,S=w<<1|_,k=S+4;k>S;++S)if(n=M[3&S])switch(3&S){case 0:c(n,f,s,x,b);break;case 1:c(n,x,s,h,b);break;case 2:c(n,f,b,x,p);break;case 3:c(n,x,b,h,p)}}}(n,r,i,u,o),a}function vr(n,t){n=ao.rgb(n),t=ao.rgb(t);var e=n.r,r=n.g,i=n.b,u=t.r-e,o=t.g-r,a=t.b-i;return function(n){return"#"+bn(Math.round(e+u*n))+bn(Math.round(r+o*n))+bn(Math.round(i+a*n))}}function dr(n,t){var e,r={},i={};for(e in n)e in t?r[e]=Mr(n[e],t[e]):i[e]=n[e];for(e in t)e in n||(i[e]=t[e]);return function(n){for(e in r)i[e]=r[e](n);return i}}function yr(n,t){return n=+n,t=+t,function(e){return n*(1-e)+t*e}}function mr(n,t){var e,r,i,u=hl.lastIndex=pl.lastIndex=0,o=-1,a=[],l=[];for(n+="",t+="";(e=hl.exec(n))&&(r=pl.exec(t));)(i=r.index)>u&&(i=t.slice(u,i),a[o]?a[o]+=i:a[++o]=i),(e=e[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,l.push({i:o,x:yr(e,r)})),u=pl.lastIndex;return ur;++r)a[(e=l[r]).i]=e.x(n);return a.join("")})}function Mr(n,t){for(var e,r=ao.interpolators.length;--r>=0&&!(e=ao.interpolators[r](n,t)););return e}function xr(n,t){var e,r=[],i=[],u=n.length,o=t.length,a=Math.min(n.length,t.length);for(e=0;a>e;++e)r.push(Mr(n[e],t[e]));for(;u>e;++e)i[e]=n[e];for(;o>e;++e)i[e]=t[e];return function(n){for(e=0;a>e;++e)i[e]=r[e](n);return i}}function br(n){return function(t){return 0>=t?0:t>=1?1:n(t)}}function _r(n){return function(t){return 1-n(1-t)}}function wr(n){return function(t){return.5*(.5>t?n(2*t):2-n(2-2*t))}}function Sr(n){return n*n}function kr(n){return n*n*n}function Nr(n){if(0>=n)return 0;if(n>=1)return 1;var t=n*n,e=t*n;return 4*(.5>n?e:3*(n-t)+e-.75)}function Er(n){return function(t){return Math.pow(t,n)}}function Ar(n){return 1-Math.cos(n*Io)}function Cr(n){return Math.pow(2,10*(n-1))}function zr(n){return 1-Math.sqrt(1-n*n)}function Lr(n,t){var e;return arguments.length<2&&(t=.45),arguments.length?e=t/Ho*Math.asin(1/n):(n=1,e=t/4),function(r){return 1+n*Math.pow(2,-10*r)*Math.sin((r-e)*Ho/t)}}function qr(n){return n||(n=1.70158),function(t){return t*t*((n+1)*t-n)}}function Tr(n){return 1/2.75>n?7.5625*n*n:2/2.75>n?7.5625*(n-=1.5/2.75)*n+.75:2.5/2.75>n?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375}function Rr(n,t){n=ao.hcl(n),t=ao.hcl(t);var e=n.h,r=n.c,i=n.l,u=t.h-e,o=t.c-r,a=t.l-i;return isNaN(o)&&(o=0,r=isNaN(r)?t.c:r),isNaN(u)?(u=0,e=isNaN(e)?t.h:e):u>180?u-=360:-180>u&&(u+=360),function(n){return sn(e+u*n,r+o*n,i+a*n)+""}}function Dr(n,t){n=ao.hsl(n),t=ao.hsl(t);var e=n.h,r=n.s,i=n.l,u=t.h-e,o=t.s-r,a=t.l-i;return isNaN(o)&&(o=0,r=isNaN(r)?t.s:r),isNaN(u)?(u=0,e=isNaN(e)?t.h:e):u>180?u-=360:-180>u&&(u+=360),function(n){return cn(e+u*n,r+o*n,i+a*n)+""}}function Pr(n,t){n=ao.lab(n),t=ao.lab(t);var e=n.l,r=n.a,i=n.b,u=t.l-e,o=t.a-r,a=t.b-i;return function(n){return pn(e+u*n,r+o*n,i+a*n)+""}}function Ur(n,t){return t-=n,function(e){return Math.round(n+t*e)}}function jr(n){var t=[n.a,n.b],e=[n.c,n.d],r=Hr(t),i=Fr(t,e),u=Hr(Or(e,t,-i))||0;t[0]*e[1]180?t+=360:t-n>180&&(n+=360),r.push({i:e.push(Ir(e)+"rotate(",null,")")-2,x:yr(n,t)})):t&&e.push(Ir(e)+"rotate("+t+")")}function Vr(n,t,e,r){n!==t?r.push({i:e.push(Ir(e)+"skewX(",null,")")-2,x:yr(n,t)}):t&&e.push(Ir(e)+"skewX("+t+")")}function Xr(n,t,e,r){if(n[0]!==t[0]||n[1]!==t[1]){var i=e.push(Ir(e)+"scale(",null,",",null,")");r.push({i:i-4,x:yr(n[0],t[0])},{i:i-2,x:yr(n[1],t[1])})}else 1===t[0]&&1===t[1]||e.push(Ir(e)+"scale("+t+")")}function $r(n,t){var e=[],r=[];return n=ao.transform(n),t=ao.transform(t),Yr(n.translate,t.translate,e,r),Zr(n.rotate,t.rotate,e,r),Vr(n.skew,t.skew,e,r),Xr(n.scale,t.scale,e,r),n=t=null,function(n){for(var t,i=-1,u=r.length;++i=0;)e.push(i[r])}function oi(n,t){for(var e=[n],r=[];null!=(n=e.pop());)if(r.push(n),(u=n.children)&&(i=u.length))for(var i,u,o=-1;++oe;++e)(t=n[e][1])>i&&(r=e,i=t);return r}function yi(n){return n.reduce(mi,0)}function mi(n,t){return n+t[1]}function Mi(n,t){return xi(n,Math.ceil(Math.log(t.length)/Math.LN2+1))}function xi(n,t){for(var e=-1,r=+n[0],i=(n[1]-r)/t,u=[];++e<=t;)u[e]=i*e+r;return u}function bi(n){return[ao.min(n),ao.max(n)]}function _i(n,t){return n.value-t.value}function wi(n,t){var e=n._pack_next;n._pack_next=t,t._pack_prev=n,t._pack_next=e,e._pack_prev=t}function Si(n,t){n._pack_next=t,t._pack_prev=n}function ki(n,t){var e=t.x-n.x,r=t.y-n.y,i=n.r+t.r;return.999*i*i>e*e+r*r}function Ni(n){function t(n){f=Math.min(n.x-n.r,f),s=Math.max(n.x+n.r,s),h=Math.min(n.y-n.r,h),p=Math.max(n.y+n.r,p)}if((e=n.children)&&(c=e.length)){var e,r,i,u,o,a,l,c,f=1/0,s=-(1/0),h=1/0,p=-(1/0);if(e.forEach(Ei),r=e[0],r.x=-r.r,r.y=0,t(r),c>1&&(i=e[1],i.x=i.r,i.y=0,t(i),c>2))for(u=e[2],zi(r,i,u),t(u),wi(r,u),r._pack_prev=u,wi(u,i),i=r._pack_next,o=3;c>o;o++){zi(r,i,u=e[o]);var g=0,v=1,d=1;for(a=i._pack_next;a!==i;a=a._pack_next,v++)if(ki(a,u)){g=1;break}if(1==g)for(l=r._pack_prev;l!==a._pack_prev&&!ki(l,u);l=l._pack_prev,d++);g?(d>v||v==d&&i.ro;o++)u=e[o],u.x-=y,u.y-=m,M=Math.max(M,u.r+Math.sqrt(u.x*u.x+u.y*u.y));n.r=M,e.forEach(Ai)}}function Ei(n){n._pack_next=n._pack_prev=n}function Ai(n){delete n._pack_next,delete n._pack_prev}function Ci(n,t,e,r){var i=n.children;if(n.x=t+=r*n.x,n.y=e+=r*n.y,n.r*=r,i)for(var u=-1,o=i.length;++u=0;)t=i[u],t.z+=e,t.m+=e,e+=t.s+(r+=t.c)}function Pi(n,t,e){return n.a.parent===t.parent?n.a:e}function Ui(n){return 1+ao.max(n,function(n){return n.y})}function ji(n){return n.reduce(function(n,t){return n+t.x},0)/n.length}function Fi(n){var t=n.children;return t&&t.length?Fi(t[0]):n}function Hi(n){var t,e=n.children;return e&&(t=e.length)?Hi(e[t-1]):n}function Oi(n){return{x:n.x,y:n.y,dx:n.dx,dy:n.dy}}function Ii(n,t){var e=n.x+t[3],r=n.y+t[0],i=n.dx-t[1]-t[3],u=n.dy-t[0]-t[2];return 0>i&&(e+=i/2,i=0),0>u&&(r+=u/2,u=0),{x:e,y:r,dx:i,dy:u}}function Yi(n){var t=n[0],e=n[n.length-1];return e>t?[t,e]:[e,t]}function Zi(n){return n.rangeExtent?n.rangeExtent():Yi(n.range())}function Vi(n,t,e,r){var i=e(n[0],n[1]),u=r(t[0],t[1]);return function(n){return u(i(n))}}function Xi(n,t){var e,r=0,i=n.length-1,u=n[r],o=n[i];return u>o&&(e=r,r=i,i=e,e=u,u=o,o=e),n[r]=t.floor(u),n[i]=t.ceil(o),n}function $i(n){return n?{floor:function(t){return Math.floor(t/n)*n},ceil:function(t){return Math.ceil(t/n)*n}}:Sl}function Bi(n,t,e,r){var i=[],u=[],o=0,a=Math.min(n.length,t.length)-1;for(n[a]2?Bi:Vi,l=r?Wr:Br;return o=i(n,t,l,e),a=i(t,n,l,Mr),u}function u(n){return o(n)}var o,a;return u.invert=function(n){return a(n)},u.domain=function(t){return arguments.length?(n=t.map(Number),i()):n},u.range=function(n){return arguments.length?(t=n,i()):t},u.rangeRound=function(n){return u.range(n).interpolate(Ur)},u.clamp=function(n){return arguments.length?(r=n,i()):r},u.interpolate=function(n){return arguments.length?(e=n,i()):e},u.ticks=function(t){return Qi(n,t)},u.tickFormat=function(t,e){return nu(n,t,e)},u.nice=function(t){return Gi(n,t),i()},u.copy=function(){return Wi(n,t,e,r)},i()}function Ji(n,t){return ao.rebind(n,t,"range","rangeRound","interpolate","clamp")}function Gi(n,t){return Xi(n,$i(Ki(n,t)[2])),Xi(n,$i(Ki(n,t)[2])),n}function Ki(n,t){null==t&&(t=10);var e=Yi(n),r=e[1]-e[0],i=Math.pow(10,Math.floor(Math.log(r/t)/Math.LN10)),u=t/r*i;return.15>=u?i*=10:.35>=u?i*=5:.75>=u&&(i*=2),e[0]=Math.ceil(e[0]/i)*i,e[1]=Math.floor(e[1]/i)*i+.5*i,e[2]=i,e}function Qi(n,t){return ao.range.apply(ao,Ki(n,t))}function nu(n,t,e){var r=Ki(n,t);if(e){var i=ha.exec(e);if(i.shift(),"s"===i[8]){var u=ao.formatPrefix(Math.max(xo(r[0]),xo(r[1])));return i[7]||(i[7]="."+tu(u.scale(r[2]))),i[8]="f",e=ao.format(i.join("")),function(n){return e(u.scale(n))+u.symbol}}i[7]||(i[7]="."+eu(i[8],r)),e=i.join("")}else e=",."+tu(r[2])+"f";return ao.format(e)}function tu(n){return-Math.floor(Math.log(n)/Math.LN10+.01)}function eu(n,t){var e=tu(t[2]);return n in kl?Math.abs(e-tu(Math.max(xo(t[0]),xo(t[1]))))+ +("e"!==n):e-2*("%"===n)}function ru(n,t,e,r){function i(n){return(e?Math.log(0>n?0:n):-Math.log(n>0?0:-n))/Math.log(t)}function u(n){return e?Math.pow(t,n):-Math.pow(t,-n)}function o(t){return n(i(t))}return o.invert=function(t){return u(n.invert(t))},o.domain=function(t){return arguments.length?(e=t[0]>=0,n.domain((r=t.map(Number)).map(i)),o):r},o.base=function(e){return arguments.length?(t=+e,n.domain(r.map(i)),o):t},o.nice=function(){var t=Xi(r.map(i),e?Math:El);return n.domain(t),r=t.map(u),o},o.ticks=function(){var n=Yi(r),o=[],a=n[0],l=n[1],c=Math.floor(i(a)),f=Math.ceil(i(l)),s=t%1?2:t;if(isFinite(f-c)){if(e){for(;f>c;c++)for(var h=1;s>h;h++)o.push(u(c)*h);o.push(u(c))}else for(o.push(u(c));c++0;h--)o.push(u(c)*h);for(c=0;o[c]l;f--);o=o.slice(c,f)}return o},o.tickFormat=function(n,e){if(!arguments.length)return Nl;arguments.length<2?e=Nl:"function"!=typeof e&&(e=ao.format(e));var r=Math.max(1,t*n/o.ticks().length);return function(n){var o=n/u(Math.round(i(n)));return t-.5>o*t&&(o*=t),r>=o?e(n):""}},o.copy=function(){return ru(n.copy(),t,e,r)},Ji(o,n)}function iu(n,t,e){function r(t){return n(i(t))}var i=uu(t),u=uu(1/t);return r.invert=function(t){return u(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain((e=t.map(Number)).map(i)),r):e},r.ticks=function(n){return Qi(e,n)},r.tickFormat=function(n,t){return nu(e,n,t)},r.nice=function(n){return r.domain(Gi(e,n))},r.exponent=function(o){return arguments.length?(i=uu(t=o),u=uu(1/t),n.domain(e.map(i)),r):t},r.copy=function(){return iu(n.copy(),t,e)},Ji(r,n)}function uu(n){return function(t){return 0>t?-Math.pow(-t,n):Math.pow(t,n)}}function ou(n,t){function e(e){return u[((i.get(e)||("range"===t.t?i.set(e,n.push(e)):NaN))-1)%u.length]}function r(t,e){return ao.range(n.length).map(function(n){return t+e*n})}var i,u,o;return e.domain=function(r){if(!arguments.length)return n;n=[],i=new c;for(var u,o=-1,a=r.length;++oe?[NaN,NaN]:[e>0?a[e-1]:n[0],et?NaN:t/u+n,[t,t+1/u]},r.copy=function(){return lu(n,t,e)},i()}function cu(n,t){function e(e){return e>=e?t[ao.bisect(n,e)]:void 0}return e.domain=function(t){return arguments.length?(n=t,e):n},e.range=function(n){return arguments.length?(t=n,e):t},e.invertExtent=function(e){return e=t.indexOf(e),[n[e-1],n[e]]},e.copy=function(){return cu(n,t)},e}function fu(n){function t(n){return+n}return t.invert=t,t.domain=t.range=function(e){return arguments.length?(n=e.map(t),t):n},t.ticks=function(t){return Qi(n,t)},t.tickFormat=function(t,e){return nu(n,t,e)},t.copy=function(){return fu(n)},t}function su(){return 0}function hu(n){return n.innerRadius}function pu(n){return n.outerRadius}function gu(n){return n.startAngle}function vu(n){return n.endAngle}function du(n){return n&&n.padAngle}function yu(n,t,e,r){return(n-e)*t-(t-r)*n>0?0:1}function mu(n,t,e,r,i){var u=n[0]-t[0],o=n[1]-t[1],a=(i?r:-r)/Math.sqrt(u*u+o*o),l=a*o,c=-a*u,f=n[0]+l,s=n[1]+c,h=t[0]+l,p=t[1]+c,g=(f+h)/2,v=(s+p)/2,d=h-f,y=p-s,m=d*d+y*y,M=e-r,x=f*p-h*s,b=(0>y?-1:1)*Math.sqrt(Math.max(0,M*M*m-x*x)),_=(x*y-d*b)/m,w=(-x*d-y*b)/m,S=(x*y+d*b)/m,k=(-x*d+y*b)/m,N=_-g,E=w-v,A=S-g,C=k-v;return N*N+E*E>A*A+C*C&&(_=S,w=k),[[_-l,w-c],[_*e/M,w*e/M]]}function Mu(n){function t(t){function o(){c.push("M",u(n(f),a))}for(var l,c=[],f=[],s=-1,h=t.length,p=En(e),g=En(r);++s1?n.join("L"):n+"Z"}function bu(n){return n.join("L")+"Z"}function _u(n){for(var t=0,e=n.length,r=n[0],i=[r[0],",",r[1]];++t1&&i.push("H",r[0]),i.join("")}function wu(n){for(var t=0,e=n.length,r=n[0],i=[r[0],",",r[1]];++t1){a=t[1],u=n[l],l++,r+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(u[0]-a[0])+","+(u[1]-a[1])+","+u[0]+","+u[1];for(var c=2;c9&&(i=3*t/Math.sqrt(i),o[a]=i*e,o[a+1]=i*r));for(a=-1;++a<=l;)i=(n[Math.min(l,a+1)][0]-n[Math.max(0,a-1)][0])/(6*(1+o[a]*o[a])),u.push([i||0,o[a]*i||0]);return u}function Fu(n){return n.length<3?xu(n):n[0]+Au(n,ju(n))}function Hu(n){for(var t,e,r,i=-1,u=n.length;++i=t?o(n-t):void(f.c=o)}function o(e){var i=g.active,u=g[i];u&&(u.timer.c=null,u.timer.t=NaN,--g.count,delete g[i],u.event&&u.event.interrupt.call(n,n.__data__,u.index));for(var o in g)if(r>+o){var c=g[o];c.timer.c=null,c.timer.t=NaN,--g.count,delete g[o]}f.c=a,qn(function(){return f.c&&a(e||1)&&(f.c=null,f.t=NaN),1},0,l),g.active=r,v.event&&v.event.start.call(n,n.__data__,t),p=[],v.tween.forEach(function(e,r){(r=r.call(n,n.__data__,t))&&p.push(r)}),h=v.ease,s=v.duration}function a(i){for(var u=i/s,o=h(u),a=p.length;a>0;)p[--a].call(n,o);return u>=1?(v.event&&v.event.end.call(n,n.__data__,t),--g.count?delete g[r]:delete n[e],1):void 0}var l,f,s,h,p,g=n[e]||(n[e]={active:0,count:0}),v=g[r];v||(l=i.time,f=qn(u,0,l),v=g[r]={tween:new c,time:l,timer:f,delay:i.delay,duration:i.duration,ease:i.ease,index:t},i=null,++g.count)}function no(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate("+(isFinite(r)?r:e(n))+",0)"})}function to(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate(0,"+(isFinite(r)?r:e(n))+")"})}function eo(n){return n.toISOString()}function ro(n,t,e){function r(t){return n(t)}function i(n,e){var r=n[1]-n[0],i=r/e,u=ao.bisect(Kl,i);return u==Kl.length?[t.year,Ki(n.map(function(n){return n/31536e6}),e)[2]]:u?t[i/Kl[u-1]1?{floor:function(t){for(;e(t=n.floor(t));)t=io(t-1);return t},ceil:function(t){for(;e(t=n.ceil(t));)t=io(+t+1);return t}}:n))},r.ticks=function(n,t){var e=Yi(r.domain()),u=null==n?i(e,10):"number"==typeof n?i(e,n):!n.range&&[{range:n},t];return u&&(n=u[0],t=u[1]),n.range(e[0],io(+e[1]+1),1>t?1:t)},r.tickFormat=function(){return e},r.copy=function(){return ro(n.copy(),t,e)},Ji(r,n)}function io(n){return new Date(n)}function uo(n){return JSON.parse(n.responseText)}function oo(n){var t=fo.createRange();return t.selectNode(fo.body),t.createContextualFragment(n.responseText)}var ao={version:"3.5.17"},lo=[].slice,co=function(n){return lo.call(n)},fo=this.document;if(fo)try{co(fo.documentElement.childNodes)[0].nodeType}catch(so){co=function(n){for(var t=n.length,e=new Array(t);t--;)e[t]=n[t];return e}}if(Date.now||(Date.now=function(){return+new Date}),fo)try{fo.createElement("DIV").style.setProperty("opacity",0,"")}catch(ho){var po=this.Element.prototype,go=po.setAttribute,vo=po.setAttributeNS,yo=this.CSSStyleDeclaration.prototype,mo=yo.setProperty;po.setAttribute=function(n,t){go.call(this,n,t+"")},po.setAttributeNS=function(n,t,e){vo.call(this,n,t,e+"")},yo.setProperty=function(n,t,e){mo.call(this,n,t+"",e)}}ao.ascending=e,ao.descending=function(n,t){return n>t?-1:t>n?1:t>=n?0:NaN},ao.min=function(n,t){var e,r,i=-1,u=n.length;if(1===arguments.length){for(;++i=r){e=r;break}for(;++ir&&(e=r)}else{for(;++i=r){e=r;break}for(;++ir&&(e=r)}return e},ao.max=function(n,t){var e,r,i=-1,u=n.length;if(1===arguments.length){for(;++i=r){e=r;break}for(;++ie&&(e=r)}else{for(;++i=r){e=r;break}for(;++ie&&(e=r)}return e},ao.extent=function(n,t){var e,r,i,u=-1,o=n.length;if(1===arguments.length){for(;++u=r){e=i=r;break}for(;++ur&&(e=r),r>i&&(i=r))}else{for(;++u=r){e=i=r;break}for(;++ur&&(e=r),r>i&&(i=r))}return[e,i]},ao.sum=function(n,t){var e,r=0,u=n.length,o=-1;if(1===arguments.length)for(;++o1?l/(f-1):void 0},ao.deviation=function(){var n=ao.variance.apply(this,arguments);return n?Math.sqrt(n):n};var Mo=u(e);ao.bisectLeft=Mo.left,ao.bisect=ao.bisectRight=Mo.right,ao.bisector=function(n){return u(1===n.length?function(t,r){return e(n(t),r)}:n)},ao.shuffle=function(n,t,e){(u=arguments.length)<3&&(e=n.length,2>u&&(t=0));for(var r,i,u=e-t;u;)i=Math.random()*u--|0,r=n[u+t],n[u+t]=n[i+t],n[i+t]=r;return n},ao.permute=function(n,t){for(var e=t.length,r=new Array(e);e--;)r[e]=n[t[e]];return r},ao.pairs=function(n){for(var t,e=0,r=n.length-1,i=n[0],u=new Array(0>r?0:r);r>e;)u[e]=[t=i,i=n[++e]];return u},ao.transpose=function(n){if(!(i=n.length))return[];for(var t=-1,e=ao.min(n,o),r=new Array(e);++t=0;)for(r=n[i],t=r.length;--t>=0;)e[--o]=r[t];return e};var xo=Math.abs;ao.range=function(n,t,e){if(arguments.length<3&&(e=1,arguments.length<2&&(t=n,n=0)),(t-n)/e===1/0)throw new Error("infinite range");var r,i=[],u=a(xo(e)),o=-1;if(n*=u,t*=u,e*=u,0>e)for(;(r=n+e*++o)>t;)i.push(r/u);else for(;(r=n+e*++o)=u.length)return r?r.call(i,o):e?o.sort(e):o;for(var l,f,s,h,p=-1,g=o.length,v=u[a++],d=new c;++p=u.length)return n;var r=[],i=o[e++];return n.forEach(function(n,i){r.push({key:n,values:t(i,e)})}),i?r.sort(function(n,t){return i(n.key,t.key)}):r}var e,r,i={},u=[],o=[];return i.map=function(t,e){return n(e,t,0)},i.entries=function(e){return t(n(ao.map,e,0),0)},i.key=function(n){return u.push(n),i},i.sortKeys=function(n){return o[u.length-1]=n,i},i.sortValues=function(n){return e=n,i},i.rollup=function(n){return r=n,i},i},ao.set=function(n){var t=new y;if(n)for(var e=0,r=n.length;r>e;++e)t.add(n[e]);return t},l(y,{has:h,add:function(n){return this._[f(n+="")]=!0,n},remove:p,values:g,size:v,empty:d,forEach:function(n){for(var t in this._)n.call(this,s(t))}}),ao.behavior={},ao.rebind=function(n,t){for(var e,r=1,i=arguments.length;++r=0&&(r=n.slice(e+1),n=n.slice(0,e)),n)return arguments.length<2?this[n].on(r):this[n].on(r,t);if(2===arguments.length){if(null==t)for(n in this)this.hasOwnProperty(n)&&this[n].on(r,null);return this}},ao.event=null,ao.requote=function(n){return n.replace(So,"\\$&")};var So=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,ko={}.__proto__?function(n,t){n.__proto__=t}:function(n,t){for(var e in t)n[e]=t[e]},No=function(n,t){return t.querySelector(n)},Eo=function(n,t){return t.querySelectorAll(n)},Ao=function(n,t){var e=n.matches||n[x(n,"matchesSelector")];return(Ao=function(n,t){return e.call(n,t)})(n,t)};"function"==typeof Sizzle&&(No=function(n,t){return Sizzle(n,t)[0]||null},Eo=Sizzle,Ao=Sizzle.matchesSelector),ao.selection=function(){return ao.select(fo.documentElement)};var Co=ao.selection.prototype=[];Co.select=function(n){var t,e,r,i,u=[];n=A(n);for(var o=-1,a=this.length;++o=0&&"xmlns"!==(e=n.slice(0,t))&&(n=n.slice(t+1)),Lo.hasOwnProperty(e)?{space:Lo[e],local:n}:n}},Co.attr=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node();return n=ao.ns.qualify(n),n.local?e.getAttributeNS(n.space,n.local):e.getAttribute(n)}for(t in n)this.each(z(t,n[t]));return this}return this.each(z(n,t))},Co.classed=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node(),r=(n=T(n)).length,i=-1;if(t=e.classList){for(;++ii){if("string"!=typeof n){2>i&&(e="");for(r in n)this.each(P(r,n[r],e));return this}if(2>i){var u=this.node();return t(u).getComputedStyle(u,null).getPropertyValue(n)}r=""}return this.each(P(n,e,r))},Co.property=function(n,t){if(arguments.length<2){if("string"==typeof n)return this.node()[n];for(t in n)this.each(U(t,n[t]));return this}return this.each(U(n,t))},Co.text=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.textContent=null==t?"":t}:null==n?function(){this.textContent=""}:function(){this.textContent=n}):this.node().textContent},Co.html=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.innerHTML=null==t?"":t}:null==n?function(){this.innerHTML=""}:function(){this.innerHTML=n}):this.node().innerHTML},Co.append=function(n){return n=j(n),this.select(function(){return this.appendChild(n.apply(this,arguments))})},Co.insert=function(n,t){return n=j(n),t=A(t),this.select(function(){return this.insertBefore(n.apply(this,arguments),t.apply(this,arguments)||null)})},Co.remove=function(){return this.each(F)},Co.data=function(n,t){function e(n,e){var r,i,u,o=n.length,s=e.length,h=Math.min(o,s),p=new Array(s),g=new Array(s),v=new Array(o);if(t){var d,y=new c,m=new Array(o);for(r=-1;++rr;++r)g[r]=H(e[r]);for(;o>r;++r)v[r]=n[r]}g.update=p,g.parentNode=p.parentNode=v.parentNode=n.parentNode,a.push(g),l.push(p),f.push(v)}var r,i,u=-1,o=this.length;if(!arguments.length){for(n=new Array(o=(r=this[0]).length);++uu;u++){i.push(t=[]),t.parentNode=(e=this[u]).parentNode;for(var a=0,l=e.length;l>a;a++)(r=e[a])&&n.call(r,r.__data__,a,u)&&t.push(r)}return E(i)},Co.order=function(){for(var n=-1,t=this.length;++n=0;)(e=r[i])&&(u&&u!==e.nextSibling&&u.parentNode.insertBefore(e,u),u=e);return this},Co.sort=function(n){n=I.apply(this,arguments);for(var t=-1,e=this.length;++tn;n++)for(var e=this[n],r=0,i=e.length;i>r;r++){var u=e[r];if(u)return u}return null},Co.size=function(){var n=0;return Y(this,function(){++n}),n};var qo=[];ao.selection.enter=Z,ao.selection.enter.prototype=qo,qo.append=Co.append,qo.empty=Co.empty,qo.node=Co.node,qo.call=Co.call,qo.size=Co.size,qo.select=function(n){for(var t,e,r,i,u,o=[],a=-1,l=this.length;++ar){if("string"!=typeof n){2>r&&(t=!1);for(e in n)this.each(X(e,n[e],t));return this}if(2>r)return(r=this.node()["__on"+n])&&r._;e=!1}return this.each(X(n,t,e))};var To=ao.map({mouseenter:"mouseover",mouseleave:"mouseout"});fo&&To.forEach(function(n){"on"+n in fo&&To.remove(n)});var Ro,Do=0;ao.mouse=function(n){return J(n,k())};var Po=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;ao.touch=function(n,t,e){if(arguments.length<3&&(e=t,t=k().changedTouches),t)for(var r,i=0,u=t.length;u>i;++i)if((r=t[i]).identifier===e)return J(n,r)},ao.behavior.drag=function(){function n(){this.on("mousedown.drag",u).on("touchstart.drag",o)}function e(n,t,e,u,o){return function(){function a(){var n,e,r=t(h,v);r&&(n=r[0]-M[0],e=r[1]-M[1],g|=n|e,M=r,p({type:"drag",x:r[0]+c[0],y:r[1]+c[1],dx:n,dy:e}))}function l(){t(h,v)&&(y.on(u+d,null).on(o+d,null),m(g),p({type:"dragend"}))}var c,f=this,s=ao.event.target.correspondingElement||ao.event.target,h=f.parentNode,p=r.of(f,arguments),g=0,v=n(),d=".drag"+(null==v?"":"-"+v),y=ao.select(e(s)).on(u+d,a).on(o+d,l),m=W(s),M=t(h,v);i?(c=i.apply(f,arguments),c=[c.x-M[0],c.y-M[1]]):c=[0,0],p({type:"dragstart"})}}var r=N(n,"drag","dragstart","dragend"),i=null,u=e(b,ao.mouse,t,"mousemove","mouseup"),o=e(G,ao.touch,m,"touchmove","touchend");return n.origin=function(t){return arguments.length?(i=t,n):i},ao.rebind(n,r,"on")},ao.touches=function(n,t){return arguments.length<2&&(t=k().touches),t?co(t).map(function(t){var e=J(n,t);return e.identifier=t.identifier,e}):[]};var Uo=1e-6,jo=Uo*Uo,Fo=Math.PI,Ho=2*Fo,Oo=Ho-Uo,Io=Fo/2,Yo=Fo/180,Zo=180/Fo,Vo=Math.SQRT2,Xo=2,$o=4;ao.interpolateZoom=function(n,t){var e,r,i=n[0],u=n[1],o=n[2],a=t[0],l=t[1],c=t[2],f=a-i,s=l-u,h=f*f+s*s;if(jo>h)r=Math.log(c/o)/Vo,e=function(n){return[i+n*f,u+n*s,o*Math.exp(Vo*n*r)]};else{var p=Math.sqrt(h),g=(c*c-o*o+$o*h)/(2*o*Xo*p),v=(c*c-o*o-$o*h)/(2*c*Xo*p),d=Math.log(Math.sqrt(g*g+1)-g),y=Math.log(Math.sqrt(v*v+1)-v);r=(y-d)/Vo,e=function(n){var t=n*r,e=rn(d),a=o/(Xo*p)*(e*un(Vo*t+d)-en(d));return[i+a*f,u+a*s,o*e/rn(Vo*t+d)]}}return e.duration=1e3*r,e},ao.behavior.zoom=function(){function n(n){n.on(L,s).on(Wo+".zoom",p).on("dblclick.zoom",g).on(R,h)}function e(n){return[(n[0]-k.x)/k.k,(n[1]-k.y)/k.k]}function r(n){return[n[0]*k.k+k.x,n[1]*k.k+k.y]}function i(n){k.k=Math.max(A[0],Math.min(A[1],n))}function u(n,t){t=r(t),k.x+=n[0]-t[0],k.y+=n[1]-t[1]}function o(t,e,r,o){t.__chart__={x:k.x,y:k.y,k:k.k},i(Math.pow(2,o)),u(d=e,r),t=ao.select(t),C>0&&(t=t.transition().duration(C)),t.call(n.event)}function a(){b&&b.domain(x.range().map(function(n){return(n-k.x)/k.k}).map(x.invert)),w&&w.domain(_.range().map(function(n){return(n-k.y)/k.k}).map(_.invert))}function l(n){z++||n({type:"zoomstart"})}function c(n){a(),n({type:"zoom",scale:k.k,translate:[k.x,k.y]})}function f(n){--z||(n({type:"zoomend"}),d=null)}function s(){function n(){a=1,u(ao.mouse(i),h),c(o)}function r(){s.on(q,null).on(T,null),p(a),f(o)}var i=this,o=D.of(i,arguments),a=0,s=ao.select(t(i)).on(q,n).on(T,r),h=e(ao.mouse(i)),p=W(i);Il.call(i),l(o)}function h(){function n(){var n=ao.touches(g);return p=k.k,n.forEach(function(n){n.identifier in d&&(d[n.identifier]=e(n))}),n}function t(){var t=ao.event.target;ao.select(t).on(x,r).on(b,a),_.push(t);for(var e=ao.event.changedTouches,i=0,u=e.length;u>i;++i)d[e[i].identifier]=null;var l=n(),c=Date.now();if(1===l.length){if(500>c-M){var f=l[0];o(g,f,d[f.identifier],Math.floor(Math.log(k.k)/Math.LN2)+1),S()}M=c}else if(l.length>1){var f=l[0],s=l[1],h=f[0]-s[0],p=f[1]-s[1];y=h*h+p*p}}function r(){var n,t,e,r,o=ao.touches(g);Il.call(g);for(var a=0,l=o.length;l>a;++a,r=null)if(e=o[a],r=d[e.identifier]){if(t)break;n=e,t=r}if(r){var f=(f=e[0]-n[0])*f+(f=e[1]-n[1])*f,s=y&&Math.sqrt(f/y);n=[(n[0]+e[0])/2,(n[1]+e[1])/2],t=[(t[0]+r[0])/2,(t[1]+r[1])/2],i(s*p)}M=null,u(n,t),c(v)}function a(){if(ao.event.touches.length){for(var t=ao.event.changedTouches,e=0,r=t.length;r>e;++e)delete d[t[e].identifier];for(var i in d)return void n()}ao.selectAll(_).on(m,null),w.on(L,s).on(R,h),N(),f(v)}var p,g=this,v=D.of(g,arguments),d={},y=0,m=".zoom-"+ao.event.changedTouches[0].identifier,x="touchmove"+m,b="touchend"+m,_=[],w=ao.select(g),N=W(g);t(),l(v),w.on(L,null).on(R,t)}function p(){var n=D.of(this,arguments);m?clearTimeout(m):(Il.call(this),v=e(d=y||ao.mouse(this)),l(n)),m=setTimeout(function(){m=null,f(n)},50),S(),i(Math.pow(2,.002*Bo())*k.k),u(d,v),c(n)}function g(){var n=ao.mouse(this),t=Math.log(k.k)/Math.LN2;o(this,n,e(n),ao.event.shiftKey?Math.ceil(t)-1:Math.floor(t)+1)}var v,d,y,m,M,x,b,_,w,k={x:0,y:0,k:1},E=[960,500],A=Jo,C=250,z=0,L="mousedown.zoom",q="mousemove.zoom",T="mouseup.zoom",R="touchstart.zoom",D=N(n,"zoomstart","zoom","zoomend");return Wo||(Wo="onwheel"in fo?(Bo=function(){return-ao.event.deltaY*(ao.event.deltaMode?120:1)},"wheel"):"onmousewheel"in fo?(Bo=function(){return ao.event.wheelDelta},"mousewheel"):(Bo=function(){return-ao.event.detail},"MozMousePixelScroll")),n.event=function(n){n.each(function(){var n=D.of(this,arguments),t=k;Hl?ao.select(this).transition().each("start.zoom",function(){k=this.__chart__||{x:0,y:0,k:1},l(n)}).tween("zoom:zoom",function(){var e=E[0],r=E[1],i=d?d[0]:e/2,u=d?d[1]:r/2,o=ao.interpolateZoom([(i-k.x)/k.k,(u-k.y)/k.k,e/k.k],[(i-t.x)/t.k,(u-t.y)/t.k,e/t.k]);return function(t){var r=o(t),a=e/r[2];this.__chart__=k={x:i-r[0]*a,y:u-r[1]*a,k:a},c(n)}}).each("interrupt.zoom",function(){f(n)}).each("end.zoom",function(){f(n)}):(this.__chart__=k,l(n),c(n),f(n))})},n.translate=function(t){return arguments.length?(k={x:+t[0],y:+t[1],k:k.k},a(),n):[k.x,k.y]},n.scale=function(t){return arguments.length?(k={x:k.x,y:k.y,k:null},i(+t),a(),n):k.k},n.scaleExtent=function(t){return arguments.length?(A=null==t?Jo:[+t[0],+t[1]],n):A},n.center=function(t){return arguments.length?(y=t&&[+t[0],+t[1]],n):y},n.size=function(t){return arguments.length?(E=t&&[+t[0],+t[1]],n):E},n.duration=function(t){return arguments.length?(C=+t,n):C},n.x=function(t){return arguments.length?(b=t,x=t.copy(),k={x:0,y:0,k:1},n):b},n.y=function(t){return arguments.length?(w=t,_=t.copy(),k={x:0,y:0,k:1},n):w},ao.rebind(n,D,"on")};var Bo,Wo,Jo=[0,1/0];ao.color=an,an.prototype.toString=function(){return this.rgb()+""},ao.hsl=ln;var Go=ln.prototype=new an;Go.brighter=function(n){return n=Math.pow(.7,arguments.length?n:1),new ln(this.h,this.s,this.l/n)},Go.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new ln(this.h,this.s,n*this.l)},Go.rgb=function(){return cn(this.h,this.s,this.l)},ao.hcl=fn;var Ko=fn.prototype=new an;Ko.brighter=function(n){return new fn(this.h,this.c,Math.min(100,this.l+Qo*(arguments.length?n:1)))},Ko.darker=function(n){return new fn(this.h,this.c,Math.max(0,this.l-Qo*(arguments.length?n:1)))},Ko.rgb=function(){return sn(this.h,this.c,this.l).rgb()},ao.lab=hn;var Qo=18,na=.95047,ta=1,ea=1.08883,ra=hn.prototype=new an;ra.brighter=function(n){return new hn(Math.min(100,this.l+Qo*(arguments.length?n:1)),this.a,this.b)},ra.darker=function(n){return new hn(Math.max(0,this.l-Qo*(arguments.length?n:1)),this.a,this.b)},ra.rgb=function(){return pn(this.l,this.a,this.b)},ao.rgb=mn;var ia=mn.prototype=new an;ia.brighter=function(n){n=Math.pow(.7,arguments.length?n:1);var t=this.r,e=this.g,r=this.b,i=30;return t||e||r?(t&&i>t&&(t=i),e&&i>e&&(e=i),r&&i>r&&(r=i),new mn(Math.min(255,t/n),Math.min(255,e/n),Math.min(255,r/n))):new mn(i,i,i)},ia.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new mn(n*this.r,n*this.g,n*this.b)},ia.hsl=function(){return wn(this.r,this.g,this.b)},ia.toString=function(){return"#"+bn(this.r)+bn(this.g)+bn(this.b)};var ua=ao.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});ua.forEach(function(n,t){ua.set(n,Mn(t))}),ao.functor=En,ao.xhr=An(m),ao.dsv=function(n,t){function e(n,e,u){arguments.length<3&&(u=e,e=null);var o=Cn(n,t,null==e?r:i(e),u);return o.row=function(n){return arguments.length?o.response(null==(e=n)?r:i(n)):e},o}function r(n){return e.parse(n.responseText)}function i(n){return function(t){return e.parse(t.responseText,n)}}function u(t){return t.map(o).join(n)}function o(n){return a.test(n)?'"'+n.replace(/\"/g,'""')+'"':n}var a=new RegExp('["'+n+"\n]"),l=n.charCodeAt(0);return e.parse=function(n,t){var r;return e.parseRows(n,function(n,e){if(r)return r(n,e-1);var i=new Function("d","return {"+n.map(function(n,t){return JSON.stringify(n)+": d["+t+"]"}).join(",")+"}");r=t?function(n,e){return t(i(n),e)}:i})},e.parseRows=function(n,t){function e(){if(f>=c)return o;if(i)return i=!1,u;var t=f;if(34===n.charCodeAt(t)){for(var e=t;e++f;){var r=n.charCodeAt(f++),a=1;if(10===r)i=!0;else if(13===r)i=!0,10===n.charCodeAt(f)&&(++f,++a);else if(r!==l)continue;return n.slice(t,f-a)}return n.slice(t)}for(var r,i,u={},o={},a=[],c=n.length,f=0,s=0;(r=e())!==o;){for(var h=[];r!==u&&r!==o;)h.push(r),r=e();t&&null==(h=t(h,s++))||a.push(h)}return a},e.format=function(t){if(Array.isArray(t[0]))return e.formatRows(t);var r=new y,i=[];return t.forEach(function(n){for(var t in n)r.has(t)||i.push(r.add(t))}),[i.map(o).join(n)].concat(t.map(function(t){return i.map(function(n){return o(t[n])}).join(n)})).join("\n")},e.formatRows=function(n){return n.map(u).join("\n")},e},ao.csv=ao.dsv(",","text/csv"),ao.tsv=ao.dsv(" ","text/tab-separated-values");var oa,aa,la,ca,fa=this[x(this,"requestAnimationFrame")]||function(n){setTimeout(n,17)};ao.timer=function(){qn.apply(this,arguments)},ao.timer.flush=function(){Rn(),Dn()},ao.round=function(n,t){return t?Math.round(n*(t=Math.pow(10,t)))/t:Math.round(n)};var sa=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(Un);ao.formatPrefix=function(n,t){var e=0;return(n=+n)&&(0>n&&(n*=-1),t&&(n=ao.round(n,Pn(n,t))),e=1+Math.floor(1e-12+Math.log(n)/Math.LN10),e=Math.max(-24,Math.min(24,3*Math.floor((e-1)/3)))),sa[8+e/3]};var ha=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,pa=ao.map({b:function(n){return n.toString(2)},c:function(n){return String.fromCharCode(n)},o:function(n){return n.toString(8)},x:function(n){return n.toString(16)},X:function(n){return n.toString(16).toUpperCase()},g:function(n,t){return n.toPrecision(t)},e:function(n,t){return n.toExponential(t)},f:function(n,t){return n.toFixed(t)},r:function(n,t){return(n=ao.round(n,Pn(n,t))).toFixed(Math.max(0,Math.min(20,Pn(n*(1+1e-15),t))))}}),ga=ao.time={},va=Date;Hn.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){da.setUTCDate.apply(this._,arguments)},setDay:function(){da.setUTCDay.apply(this._,arguments)},setFullYear:function(){da.setUTCFullYear.apply(this._,arguments)},setHours:function(){da.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){da.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){da.setUTCMinutes.apply(this._,arguments)},setMonth:function(){da.setUTCMonth.apply(this._,arguments)},setSeconds:function(){da.setUTCSeconds.apply(this._,arguments)},setTime:function(){da.setTime.apply(this._,arguments)}};var da=Date.prototype;ga.year=On(function(n){return n=ga.day(n),n.setMonth(0,1),n},function(n,t){n.setFullYear(n.getFullYear()+t)},function(n){return n.getFullYear()}),ga.years=ga.year.range,ga.years.utc=ga.year.utc.range,ga.day=On(function(n){var t=new va(2e3,0);return t.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),t},function(n,t){n.setDate(n.getDate()+t)},function(n){return n.getDate()-1}),ga.days=ga.day.range,ga.days.utc=ga.day.utc.range,ga.dayOfYear=function(n){var t=ga.year(n);return Math.floor((n-t-6e4*(n.getTimezoneOffset()-t.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(n,t){t=7-t;var e=ga[n]=On(function(n){return(n=ga.day(n)).setDate(n.getDate()-(n.getDay()+t)%7),n},function(n,t){n.setDate(n.getDate()+7*Math.floor(t))},function(n){var e=ga.year(n).getDay();return Math.floor((ga.dayOfYear(n)+(e+t)%7)/7)-(e!==t)});ga[n+"s"]=e.range,ga[n+"s"].utc=e.utc.range,ga[n+"OfYear"]=function(n){var e=ga.year(n).getDay();return Math.floor((ga.dayOfYear(n)+(e+t)%7)/7)}}),ga.week=ga.sunday,ga.weeks=ga.sunday.range,ga.weeks.utc=ga.sunday.utc.range,ga.weekOfYear=ga.sundayOfYear;var ya={"-":"",_:" ",0:"0"},ma=/^\s*\d+/,Ma=/^%/;ao.locale=function(n){return{numberFormat:jn(n),timeFormat:Yn(n)}};var xa=ao.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"], +shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});ao.format=xa.numberFormat,ao.geo={},ft.prototype={s:0,t:0,add:function(n){st(n,this.t,ba),st(ba.s,this.s,this),this.s?this.t+=ba.t:this.s=ba.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var ba=new ft;ao.geo.stream=function(n,t){n&&_a.hasOwnProperty(n.type)?_a[n.type](n,t):ht(n,t)};var _a={Feature:function(n,t){ht(n.geometry,t)},FeatureCollection:function(n,t){for(var e=n.features,r=-1,i=e.length;++rn?4*Fo+n:n,Na.lineStart=Na.lineEnd=Na.point=b}};ao.geo.bounds=function(){function n(n,t){M.push(x=[f=n,h=n]),s>t&&(s=t),t>p&&(p=t)}function t(t,e){var r=dt([t*Yo,e*Yo]);if(y){var i=mt(y,r),u=[i[1],-i[0],0],o=mt(u,i);bt(o),o=_t(o);var l=t-g,c=l>0?1:-1,v=o[0]*Zo*c,d=xo(l)>180;if(d^(v>c*g&&c*t>v)){var m=o[1]*Zo;m>p&&(p=m)}else if(v=(v+360)%360-180,d^(v>c*g&&c*t>v)){var m=-o[1]*Zo;s>m&&(s=m)}else s>e&&(s=e),e>p&&(p=e);d?g>t?a(f,t)>a(f,h)&&(h=t):a(t,h)>a(f,h)&&(f=t):h>=f?(f>t&&(f=t),t>h&&(h=t)):t>g?a(f,t)>a(f,h)&&(h=t):a(t,h)>a(f,h)&&(f=t)}else n(t,e);y=r,g=t}function e(){b.point=t}function r(){x[0]=f,x[1]=h,b.point=n,y=null}function i(n,e){if(y){var r=n-g;m+=xo(r)>180?r+(r>0?360:-360):r}else v=n,d=e;Na.point(n,e),t(n,e)}function u(){Na.lineStart()}function o(){i(v,d),Na.lineEnd(),xo(m)>Uo&&(f=-(h=180)),x[0]=f,x[1]=h,y=null}function a(n,t){return(t-=n)<0?t+360:t}function l(n,t){return n[0]-t[0]}function c(n,t){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:nka?(f=-(h=180),s=-(p=90)):m>Uo?p=90:-Uo>m&&(s=-90),x[0]=f,x[1]=h}};return function(n){p=h=-(f=s=1/0),M=[],ao.geo.stream(n,b);var t=M.length;if(t){M.sort(l);for(var e,r=1,i=M[0],u=[i];t>r;++r)e=M[r],c(e[0],i)||c(e[1],i)?(a(i[0],e[1])>a(i[0],i[1])&&(i[1]=e[1]),a(e[0],i[1])>a(i[0],i[1])&&(i[0]=e[0])):u.push(i=e);for(var o,e,g=-(1/0),t=u.length-1,r=0,i=u[t];t>=r;i=e,++r)e=u[r],(o=a(i[1],e[0]))>g&&(g=o,f=e[0],h=i[1])}return M=x=null,f===1/0||s===1/0?[[NaN,NaN],[NaN,NaN]]:[[f,s],[h,p]]}}(),ao.geo.centroid=function(n){Ea=Aa=Ca=za=La=qa=Ta=Ra=Da=Pa=Ua=0,ao.geo.stream(n,ja);var t=Da,e=Pa,r=Ua,i=t*t+e*e+r*r;return jo>i&&(t=qa,e=Ta,r=Ra,Uo>Aa&&(t=Ca,e=za,r=La),i=t*t+e*e+r*r,jo>i)?[NaN,NaN]:[Math.atan2(e,t)*Zo,tn(r/Math.sqrt(i))*Zo]};var Ea,Aa,Ca,za,La,qa,Ta,Ra,Da,Pa,Ua,ja={sphere:b,point:St,lineStart:Nt,lineEnd:Et,polygonStart:function(){ja.lineStart=At},polygonEnd:function(){ja.lineStart=Nt}},Fa=Rt(zt,jt,Ht,[-Fo,-Fo/2]),Ha=1e9;ao.geo.clipExtent=function(){var n,t,e,r,i,u,o={stream:function(n){return i&&(i.valid=!1),i=u(n),i.valid=!0,i},extent:function(a){return arguments.length?(u=Zt(n=+a[0][0],t=+a[0][1],e=+a[1][0],r=+a[1][1]),i&&(i.valid=!1,i=null),o):[[n,t],[e,r]]}};return o.extent([[0,0],[960,500]])},(ao.geo.conicEqualArea=function(){return Vt(Xt)}).raw=Xt,ao.geo.albers=function(){return ao.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},ao.geo.albersUsa=function(){function n(n){var u=n[0],o=n[1];return t=null,e(u,o),t||(r(u,o),t)||i(u,o),t}var t,e,r,i,u=ao.geo.albers(),o=ao.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),a=ao.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(n,e){t=[n,e]}};return n.invert=function(n){var t=u.scale(),e=u.translate(),r=(n[0]-e[0])/t,i=(n[1]-e[1])/t;return(i>=.12&&.234>i&&r>=-.425&&-.214>r?o:i>=.166&&.234>i&&r>=-.214&&-.115>r?a:u).invert(n)},n.stream=function(n){var t=u.stream(n),e=o.stream(n),r=a.stream(n);return{point:function(n,i){t.point(n,i),e.point(n,i),r.point(n,i)},sphere:function(){t.sphere(),e.sphere(),r.sphere()},lineStart:function(){t.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){t.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){t.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){t.polygonEnd(),e.polygonEnd(),r.polygonEnd()}}},n.precision=function(t){return arguments.length?(u.precision(t),o.precision(t),a.precision(t),n):u.precision()},n.scale=function(t){return arguments.length?(u.scale(t),o.scale(.35*t),a.scale(t),n.translate(u.translate())):u.scale()},n.translate=function(t){if(!arguments.length)return u.translate();var c=u.scale(),f=+t[0],s=+t[1];return e=u.translate(t).clipExtent([[f-.455*c,s-.238*c],[f+.455*c,s+.238*c]]).stream(l).point,r=o.translate([f-.307*c,s+.201*c]).clipExtent([[f-.425*c+Uo,s+.12*c+Uo],[f-.214*c-Uo,s+.234*c-Uo]]).stream(l).point,i=a.translate([f-.205*c,s+.212*c]).clipExtent([[f-.214*c+Uo,s+.166*c+Uo],[f-.115*c-Uo,s+.234*c-Uo]]).stream(l).point,n},n.scale(1070)};var Oa,Ia,Ya,Za,Va,Xa,$a={point:b,lineStart:b,lineEnd:b,polygonStart:function(){Ia=0,$a.lineStart=$t},polygonEnd:function(){$a.lineStart=$a.lineEnd=$a.point=b,Oa+=xo(Ia/2)}},Ba={point:Bt,lineStart:b,lineEnd:b,polygonStart:b,polygonEnd:b},Wa={point:Gt,lineStart:Kt,lineEnd:Qt,polygonStart:function(){Wa.lineStart=ne},polygonEnd:function(){Wa.point=Gt,Wa.lineStart=Kt,Wa.lineEnd=Qt}};ao.geo.path=function(){function n(n){return n&&("function"==typeof a&&u.pointRadius(+a.apply(this,arguments)),o&&o.valid||(o=i(u)),ao.geo.stream(n,o)),u.result()}function t(){return o=null,n}var e,r,i,u,o,a=4.5;return n.area=function(n){return Oa=0,ao.geo.stream(n,i($a)),Oa},n.centroid=function(n){return Ca=za=La=qa=Ta=Ra=Da=Pa=Ua=0,ao.geo.stream(n,i(Wa)),Ua?[Da/Ua,Pa/Ua]:Ra?[qa/Ra,Ta/Ra]:La?[Ca/La,za/La]:[NaN,NaN]},n.bounds=function(n){return Va=Xa=-(Ya=Za=1/0),ao.geo.stream(n,i(Ba)),[[Ya,Za],[Va,Xa]]},n.projection=function(n){return arguments.length?(i=(e=n)?n.stream||re(n):m,t()):e},n.context=function(n){return arguments.length?(u=null==(r=n)?new Wt:new te(n),"function"!=typeof a&&u.pointRadius(a),t()):r},n.pointRadius=function(t){return arguments.length?(a="function"==typeof t?t:(u.pointRadius(+t),+t),n):a},n.projection(ao.geo.albersUsa()).context(null)},ao.geo.transform=function(n){return{stream:function(t){var e=new ie(t);for(var r in n)e[r]=n[r];return e}}},ie.prototype={point:function(n,t){this.stream.point(n,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},ao.geo.projection=oe,ao.geo.projectionMutator=ae,(ao.geo.equirectangular=function(){return oe(ce)}).raw=ce.invert=ce,ao.geo.rotation=function(n){function t(t){return t=n(t[0]*Yo,t[1]*Yo),t[0]*=Zo,t[1]*=Zo,t}return n=se(n[0]%360*Yo,n[1]*Yo,n.length>2?n[2]*Yo:0),t.invert=function(t){return t=n.invert(t[0]*Yo,t[1]*Yo),t[0]*=Zo,t[1]*=Zo,t},t},fe.invert=ce,ao.geo.circle=function(){function n(){var n="function"==typeof r?r.apply(this,arguments):r,t=se(-n[0]*Yo,-n[1]*Yo,0).invert,i=[];return e(null,null,1,{point:function(n,e){i.push(n=t(n,e)),n[0]*=Zo,n[1]*=Zo}}),{type:"Polygon",coordinates:[i]}}var t,e,r=[0,0],i=6;return n.origin=function(t){return arguments.length?(r=t,n):r},n.angle=function(r){return arguments.length?(e=ve((t=+r)*Yo,i*Yo),n):t},n.precision=function(r){return arguments.length?(e=ve(t*Yo,(i=+r)*Yo),n):i},n.angle(90)},ao.geo.distance=function(n,t){var e,r=(t[0]-n[0])*Yo,i=n[1]*Yo,u=t[1]*Yo,o=Math.sin(r),a=Math.cos(r),l=Math.sin(i),c=Math.cos(i),f=Math.sin(u),s=Math.cos(u);return Math.atan2(Math.sqrt((e=s*o)*e+(e=c*f-l*s*a)*e),l*f+c*s*a)},ao.geo.graticule=function(){function n(){return{type:"MultiLineString",coordinates:t()}}function t(){return ao.range(Math.ceil(u/d)*d,i,d).map(h).concat(ao.range(Math.ceil(c/y)*y,l,y).map(p)).concat(ao.range(Math.ceil(r/g)*g,e,g).filter(function(n){return xo(n%d)>Uo}).map(f)).concat(ao.range(Math.ceil(a/v)*v,o,v).filter(function(n){return xo(n%y)>Uo}).map(s))}var e,r,i,u,o,a,l,c,f,s,h,p,g=10,v=g,d=90,y=360,m=2.5;return n.lines=function(){return t().map(function(n){return{type:"LineString",coordinates:n}})},n.outline=function(){return{type:"Polygon",coordinates:[h(u).concat(p(l).slice(1),h(i).reverse().slice(1),p(c).reverse().slice(1))]}},n.extent=function(t){return arguments.length?n.majorExtent(t).minorExtent(t):n.minorExtent()},n.majorExtent=function(t){return arguments.length?(u=+t[0][0],i=+t[1][0],c=+t[0][1],l=+t[1][1],u>i&&(t=u,u=i,i=t),c>l&&(t=c,c=l,l=t),n.precision(m)):[[u,c],[i,l]]},n.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],a=+t[0][1],o=+t[1][1],r>e&&(t=r,r=e,e=t),a>o&&(t=a,a=o,o=t),n.precision(m)):[[r,a],[e,o]]},n.step=function(t){return arguments.length?n.majorStep(t).minorStep(t):n.minorStep()},n.majorStep=function(t){return arguments.length?(d=+t[0],y=+t[1],n):[d,y]},n.minorStep=function(t){return arguments.length?(g=+t[0],v=+t[1],n):[g,v]},n.precision=function(t){return arguments.length?(m=+t,f=ye(a,o,90),s=me(r,e,m),h=ye(c,l,90),p=me(u,i,m),n):m},n.majorExtent([[-180,-90+Uo],[180,90-Uo]]).minorExtent([[-180,-80-Uo],[180,80+Uo]])},ao.geo.greatArc=function(){function n(){return{type:"LineString",coordinates:[t||r.apply(this,arguments),e||i.apply(this,arguments)]}}var t,e,r=Me,i=xe;return n.distance=function(){return ao.geo.distance(t||r.apply(this,arguments),e||i.apply(this,arguments))},n.source=function(e){return arguments.length?(r=e,t="function"==typeof e?null:e,n):r},n.target=function(t){return arguments.length?(i=t,e="function"==typeof t?null:t,n):i},n.precision=function(){return arguments.length?n:0},n},ao.geo.interpolate=function(n,t){return be(n[0]*Yo,n[1]*Yo,t[0]*Yo,t[1]*Yo)},ao.geo.length=function(n){return Ja=0,ao.geo.stream(n,Ga),Ja};var Ja,Ga={sphere:b,point:b,lineStart:_e,lineEnd:b,polygonStart:b,polygonEnd:b},Ka=we(function(n){return Math.sqrt(2/(1+n))},function(n){return 2*Math.asin(n/2)});(ao.geo.azimuthalEqualArea=function(){return oe(Ka)}).raw=Ka;var Qa=we(function(n){var t=Math.acos(n);return t&&t/Math.sin(t)},m);(ao.geo.azimuthalEquidistant=function(){return oe(Qa)}).raw=Qa,(ao.geo.conicConformal=function(){return Vt(Se)}).raw=Se,(ao.geo.conicEquidistant=function(){return Vt(ke)}).raw=ke;var nl=we(function(n){return 1/n},Math.atan);(ao.geo.gnomonic=function(){return oe(nl)}).raw=nl,Ne.invert=function(n,t){return[n,2*Math.atan(Math.exp(t))-Io]},(ao.geo.mercator=function(){return Ee(Ne)}).raw=Ne;var tl=we(function(){return 1},Math.asin);(ao.geo.orthographic=function(){return oe(tl)}).raw=tl;var el=we(function(n){return 1/(1+n)},function(n){return 2*Math.atan(n)});(ao.geo.stereographic=function(){return oe(el)}).raw=el,Ae.invert=function(n,t){return[-t,2*Math.atan(Math.exp(n))-Io]},(ao.geo.transverseMercator=function(){var n=Ee(Ae),t=n.center,e=n.rotate;return n.center=function(n){return n?t([-n[1],n[0]]):(n=t(),[n[1],-n[0]])},n.rotate=function(n){return n?e([n[0],n[1],n.length>2?n[2]+90:90]):(n=e(),[n[0],n[1],n[2]-90])},e([0,0,90])}).raw=Ae,ao.geom={},ao.geom.hull=function(n){function t(n){if(n.length<3)return[];var t,i=En(e),u=En(r),o=n.length,a=[],l=[];for(t=0;o>t;t++)a.push([+i.call(this,n[t],t),+u.call(this,n[t],t),t]);for(a.sort(qe),t=0;o>t;t++)l.push([a[t][0],-a[t][1]]);var c=Le(a),f=Le(l),s=f[0]===c[0],h=f[f.length-1]===c[c.length-1],p=[];for(t=c.length-1;t>=0;--t)p.push(n[a[c[t]][2]]);for(t=+s;t=r&&c.x<=u&&c.y>=i&&c.y<=o?[[r,o],[u,o],[u,i],[r,i]]:[];f.point=n[a]}),t}function e(n){return n.map(function(n,t){return{x:Math.round(u(n,t)/Uo)*Uo,y:Math.round(o(n,t)/Uo)*Uo,i:t}})}var r=Ce,i=ze,u=r,o=i,a=sl;return n?t(n):(t.links=function(n){return ar(e(n)).edges.filter(function(n){return n.l&&n.r}).map(function(t){return{source:n[t.l.i],target:n[t.r.i]}})},t.triangles=function(n){var t=[];return ar(e(n)).cells.forEach(function(e,r){for(var i,u,o=e.site,a=e.edges.sort(Ve),l=-1,c=a.length,f=a[c-1].edge,s=f.l===o?f.r:f.l;++l=c,h=r>=f,p=h<<1|s;n.leaf=!1,n=n.nodes[p]||(n.nodes[p]=hr()),s?i=c:a=c,h?o=f:l=f,u(n,t,e,r,i,o,a,l)}var f,s,h,p,g,v,d,y,m,M=En(a),x=En(l);if(null!=t)v=t,d=e,y=r,m=i;else if(y=m=-(v=d=1/0),s=[],h=[],g=n.length,o)for(p=0;g>p;++p)f=n[p],f.xy&&(y=f.x),f.y>m&&(m=f.y),s.push(f.x),h.push(f.y);else for(p=0;g>p;++p){var b=+M(f=n[p],p),_=+x(f,p);v>b&&(v=b),d>_&&(d=_),b>y&&(y=b),_>m&&(m=_),s.push(b),h.push(_)}var w=y-v,S=m-d;w>S?m=d+w:y=v+S;var k=hr();if(k.add=function(n){u(k,n,+M(n,++p),+x(n,p),v,d,y,m)},k.visit=function(n){pr(n,k,v,d,y,m)},k.find=function(n){return gr(k,n[0],n[1],v,d,y,m)},p=-1,null==t){for(;++p=0?n.slice(0,t):n,r=t>=0?n.slice(t+1):"in";return e=vl.get(e)||gl,r=dl.get(r)||m,br(r(e.apply(null,lo.call(arguments,1))))},ao.interpolateHcl=Rr,ao.interpolateHsl=Dr,ao.interpolateLab=Pr,ao.interpolateRound=Ur,ao.transform=function(n){var t=fo.createElementNS(ao.ns.prefix.svg,"g");return(ao.transform=function(n){if(null!=n){t.setAttribute("transform",n);var e=t.transform.baseVal.consolidate()}return new jr(e?e.matrix:yl)})(n)},jr.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var yl={a:1,b:0,c:0,d:1,e:0,f:0};ao.interpolateTransform=$r,ao.layout={},ao.layout.bundle=function(){return function(n){for(var t=[],e=-1,r=n.length;++ea*a/y){if(v>l){var c=t.charge/l;n.px-=u*c,n.py-=o*c}return!0}if(t.point&&l&&v>l){var c=t.pointCharge/l;n.px-=u*c,n.py-=o*c}}return!t.charge}}function t(n){n.px=ao.event.x,n.py=ao.event.y,l.resume()}var e,r,i,u,o,a,l={},c=ao.dispatch("start","tick","end"),f=[1,1],s=.9,h=ml,p=Ml,g=-30,v=xl,d=.1,y=.64,M=[],x=[];return l.tick=function(){if((i*=.99)<.005)return e=null,c.end({type:"end",alpha:i=0}),!0;var t,r,l,h,p,v,y,m,b,_=M.length,w=x.length;for(r=0;w>r;++r)l=x[r],h=l.source,p=l.target,m=p.x-h.x,b=p.y-h.y,(v=m*m+b*b)&&(v=i*o[r]*((v=Math.sqrt(v))-u[r])/v,m*=v,b*=v,p.x-=m*(y=h.weight+p.weight?h.weight/(h.weight+p.weight):.5),p.y-=b*y,h.x+=m*(y=1-y),h.y+=b*y);if((y=i*d)&&(m=f[0]/2,b=f[1]/2,r=-1,y))for(;++r<_;)l=M[r],l.x+=(m-l.x)*y,l.y+=(b-l.y)*y;if(g)for(ri(t=ao.geom.quadtree(M),i,a),r=-1;++r<_;)(l=M[r]).fixed||t.visit(n(l));for(r=-1;++r<_;)l=M[r],l.fixed?(l.x=l.px,l.y=l.py):(l.x-=(l.px-(l.px=l.x))*s,l.y-=(l.py-(l.py=l.y))*s);c.tick({type:"tick",alpha:i})},l.nodes=function(n){return arguments.length?(M=n,l):M},l.links=function(n){return arguments.length?(x=n,l):x},l.size=function(n){return arguments.length?(f=n,l):f},l.linkDistance=function(n){return arguments.length?(h="function"==typeof n?n:+n,l):h},l.distance=l.linkDistance,l.linkStrength=function(n){return arguments.length?(p="function"==typeof n?n:+n,l):p},l.friction=function(n){return arguments.length?(s=+n,l):s},l.charge=function(n){return arguments.length?(g="function"==typeof n?n:+n,l):g},l.chargeDistance=function(n){return arguments.length?(v=n*n,l):Math.sqrt(v)},l.gravity=function(n){return arguments.length?(d=+n,l):d},l.theta=function(n){return arguments.length?(y=n*n,l):Math.sqrt(y)},l.alpha=function(n){return arguments.length?(n=+n,i?n>0?i=n:(e.c=null,e.t=NaN,e=null,c.end({type:"end",alpha:i=0})):n>0&&(c.start({type:"start",alpha:i=n}),e=qn(l.tick)),l):i},l.start=function(){function n(n,r){if(!e){for(e=new Array(i),l=0;i>l;++l)e[l]=[];for(l=0;c>l;++l){var u=x[l];e[u.source.index].push(u.target),e[u.target.index].push(u.source)}}for(var o,a=e[t],l=-1,f=a.length;++lt;++t)(r=M[t]).index=t,r.weight=0;for(t=0;c>t;++t)r=x[t],"number"==typeof r.source&&(r.source=M[r.source]),"number"==typeof r.target&&(r.target=M[r.target]),++r.source.weight,++r.target.weight;for(t=0;i>t;++t)r=M[t],isNaN(r.x)&&(r.x=n("x",s)),isNaN(r.y)&&(r.y=n("y",v)),isNaN(r.px)&&(r.px=r.x),isNaN(r.py)&&(r.py=r.y);if(u=[],"function"==typeof h)for(t=0;c>t;++t)u[t]=+h.call(this,x[t],t);else for(t=0;c>t;++t)u[t]=h;if(o=[],"function"==typeof p)for(t=0;c>t;++t)o[t]=+p.call(this,x[t],t);else for(t=0;c>t;++t)o[t]=p;if(a=[],"function"==typeof g)for(t=0;i>t;++t)a[t]=+g.call(this,M[t],t);else for(t=0;i>t;++t)a[t]=g;return l.resume()},l.resume=function(){return l.alpha(.1)},l.stop=function(){return l.alpha(0)},l.drag=function(){return r||(r=ao.behavior.drag().origin(m).on("dragstart.force",Qr).on("drag.force",t).on("dragend.force",ni)),arguments.length?void this.on("mouseover.force",ti).on("mouseout.force",ei).call(r):r},ao.rebind(l,c,"on")};var ml=20,Ml=1,xl=1/0;ao.layout.hierarchy=function(){function n(i){var u,o=[i],a=[];for(i.depth=0;null!=(u=o.pop());)if(a.push(u),(c=e.call(n,u,u.depth))&&(l=c.length)){for(var l,c,f;--l>=0;)o.push(f=c[l]),f.parent=u,f.depth=u.depth+1;r&&(u.value=0),u.children=c}else r&&(u.value=+r.call(n,u,u.depth)||0),delete u.children;return oi(i,function(n){var e,i;t&&(e=n.children)&&e.sort(t),r&&(i=n.parent)&&(i.value+=n.value)}),a}var t=ci,e=ai,r=li;return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(ui(t,function(n){n.children&&(n.value=0)}),oi(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},ao.layout.partition=function(){function n(t,e,r,i){var u=t.children;if(t.x=e,t.y=t.depth*i,t.dx=r,t.dy=i,u&&(o=u.length)){var o,a,l,c=-1;for(r=t.value?r/t.value:0;++cs?-1:1),g=ao.sum(c),v=g?(s-l*p)/g:0,d=ao.range(l),y=[];return null!=e&&d.sort(e===bl?function(n,t){return c[t]-c[n]}:function(n,t){return e(o[n],o[t])}),d.forEach(function(n){y[n]={data:o[n],value:a=c[n],startAngle:f,endAngle:f+=a*v+p,padAngle:h}}),y}var t=Number,e=bl,r=0,i=Ho,u=0;return n.value=function(e){return arguments.length?(t=e,n):t},n.sort=function(t){return arguments.length?(e=t,n):e},n.startAngle=function(t){return arguments.length?(r=t,n):r},n.endAngle=function(t){return arguments.length?(i=t,n):i},n.padAngle=function(t){return arguments.length?(u=t,n):u},n};var bl={};ao.layout.stack=function(){function n(a,l){if(!(h=a.length))return a;var c=a.map(function(e,r){return t.call(n,e,r)}),f=c.map(function(t){return t.map(function(t,e){return[u.call(n,t,e),o.call(n,t,e)]})}),s=e.call(n,f,l);c=ao.permute(c,s),f=ao.permute(f,s);var h,p,g,v,d=r.call(n,f,l),y=c[0].length;for(g=0;y>g;++g)for(i.call(n,c[0][g],v=d[g],f[0][g][1]),p=1;h>p;++p)i.call(n,c[p][g],v+=f[p-1][g][1],f[p][g][1]);return a}var t=m,e=gi,r=vi,i=pi,u=si,o=hi;return n.values=function(e){return arguments.length?(t=e,n):t},n.order=function(t){return arguments.length?(e="function"==typeof t?t:_l.get(t)||gi,n):e},n.offset=function(t){return arguments.length?(r="function"==typeof t?t:wl.get(t)||vi,n):r},n.x=function(t){return arguments.length?(u=t,n):u},n.y=function(t){return arguments.length?(o=t,n):o},n.out=function(t){return arguments.length?(i=t,n):i},n};var _l=ao.map({"inside-out":function(n){var t,e,r=n.length,i=n.map(di),u=n.map(yi),o=ao.range(r).sort(function(n,t){return i[n]-i[t]}),a=0,l=0,c=[],f=[];for(t=0;r>t;++t)e=o[t],l>a?(a+=u[e],c.push(e)):(l+=u[e],f.push(e));return f.reverse().concat(c)},reverse:function(n){return ao.range(n.length).reverse()},"default":gi}),wl=ao.map({silhouette:function(n){var t,e,r,i=n.length,u=n[0].length,o=[],a=0,l=[];for(e=0;u>e;++e){for(t=0,r=0;i>t;t++)r+=n[t][e][1];r>a&&(a=r),o.push(r)}for(e=0;u>e;++e)l[e]=(a-o[e])/2;return l},wiggle:function(n){var t,e,r,i,u,o,a,l,c,f=n.length,s=n[0],h=s.length,p=[];for(p[0]=l=c=0,e=1;h>e;++e){for(t=0,i=0;f>t;++t)i+=n[t][e][1];for(t=0,u=0,a=s[e][0]-s[e-1][0];f>t;++t){for(r=0,o=(n[t][e][1]-n[t][e-1][1])/(2*a);t>r;++r)o+=(n[r][e][1]-n[r][e-1][1])/a;u+=o*n[t][e][1]}p[e]=l-=i?u/i*a:0,c>l&&(c=l)}for(e=0;h>e;++e)p[e]-=c;return p},expand:function(n){var t,e,r,i=n.length,u=n[0].length,o=1/i,a=[];for(e=0;u>e;++e){for(t=0,r=0;i>t;t++)r+=n[t][e][1];if(r)for(t=0;i>t;t++)n[t][e][1]/=r;else for(t=0;i>t;t++)n[t][e][1]=o}for(e=0;u>e;++e)a[e]=0;return a},zero:vi});ao.layout.histogram=function(){function n(n,u){for(var o,a,l=[],c=n.map(e,this),f=r.call(this,c,u),s=i.call(this,f,c,u),u=-1,h=c.length,p=s.length-1,g=t?1:1/h;++u0)for(u=-1;++u=f[0]&&a<=f[1]&&(o=l[ao.bisect(s,a,1,p)-1],o.y+=g,o.push(n[u]));return l}var t=!0,e=Number,r=bi,i=Mi;return n.value=function(t){return arguments.length?(e=t,n):e},n.range=function(t){return arguments.length?(r=En(t),n):r},n.bins=function(t){return arguments.length?(i="number"==typeof t?function(n){return xi(n,t)}:En(t),n):i},n.frequency=function(e){return arguments.length?(t=!!e,n):t},n},ao.layout.pack=function(){function n(n,u){var o=e.call(this,n,u),a=o[0],l=i[0],c=i[1],f=null==t?Math.sqrt:"function"==typeof t?t:function(){return t};if(a.x=a.y=0,oi(a,function(n){n.r=+f(n.value)}),oi(a,Ni),r){var s=r*(t?1:Math.max(2*a.r/l,2*a.r/c))/2;oi(a,function(n){n.r+=s}),oi(a,Ni),oi(a,function(n){n.r-=s})}return Ci(a,l/2,c/2,t?1:1/Math.max(2*a.r/l,2*a.r/c)),o}var t,e=ao.layout.hierarchy().sort(_i),r=0,i=[1,1];return n.size=function(t){return arguments.length?(i=t,n):i},n.radius=function(e){return arguments.length?(t=null==e||"function"==typeof e?e:+e,n):t},n.padding=function(t){return arguments.length?(r=+t,n):r},ii(n,e)},ao.layout.tree=function(){function n(n,i){var f=o.call(this,n,i),s=f[0],h=t(s);if(oi(h,e),h.parent.m=-h.z,ui(h,r),c)ui(s,u);else{var p=s,g=s,v=s;ui(s,function(n){n.xg.x&&(g=n),n.depth>v.depth&&(v=n)});var d=a(p,g)/2-p.x,y=l[0]/(g.x+a(g,p)/2+d),m=l[1]/(v.depth||1);ui(s,function(n){n.x=(n.x+d)*y,n.y=n.depth*m})}return f}function t(n){for(var t,e={A:null,children:[n]},r=[e];null!=(t=r.pop());)for(var i,u=t.children,o=0,a=u.length;a>o;++o)r.push((u[o]=i={_:u[o],parent:t,children:(i=u[o].children)&&i.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:o}).a=i);return e.children[0]}function e(n){var t=n.children,e=n.parent.children,r=n.i?e[n.i-1]:null;if(t.length){Di(n);var u=(t[0].z+t[t.length-1].z)/2;r?(n.z=r.z+a(n._,r._),n.m=n.z-u):n.z=u}else r&&(n.z=r.z+a(n._,r._));n.parent.A=i(n,r,n.parent.A||e[0])}function r(n){n._.x=n.z+n.parent.m,n.m+=n.parent.m}function i(n,t,e){if(t){for(var r,i=n,u=n,o=t,l=i.parent.children[0],c=i.m,f=u.m,s=o.m,h=l.m;o=Ti(o),i=qi(i),o&&i;)l=qi(l),u=Ti(u),u.a=n,r=o.z+s-i.z-c+a(o._,i._),r>0&&(Ri(Pi(o,n,e),n,r),c+=r,f+=r),s+=o.m,c+=i.m,h+=l.m,f+=u.m;o&&!Ti(u)&&(u.t=o,u.m+=s-f),i&&!qi(l)&&(l.t=i,l.m+=c-h,e=n)}return e}function u(n){n.x*=l[0],n.y=n.depth*l[1]}var o=ao.layout.hierarchy().sort(null).value(null),a=Li,l=[1,1],c=null;return n.separation=function(t){return arguments.length?(a=t,n):a},n.size=function(t){return arguments.length?(c=null==(l=t)?u:null,n):c?null:l},n.nodeSize=function(t){return arguments.length?(c=null==(l=t)?null:u,n):c?l:null},ii(n,o)},ao.layout.cluster=function(){function n(n,u){var o,a=t.call(this,n,u),l=a[0],c=0;oi(l,function(n){var t=n.children;t&&t.length?(n.x=ji(t),n.y=Ui(t)):(n.x=o?c+=e(n,o):0,n.y=0,o=n)});var f=Fi(l),s=Hi(l),h=f.x-e(f,s)/2,p=s.x+e(s,f)/2;return oi(l,i?function(n){n.x=(n.x-l.x)*r[0],n.y=(l.y-n.y)*r[1]}:function(n){n.x=(n.x-h)/(p-h)*r[0],n.y=(1-(l.y?n.y/l.y:1))*r[1]}),a}var t=ao.layout.hierarchy().sort(null).value(null),e=Li,r=[1,1],i=!1;return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(i=null==(r=t),n):i?null:r},n.nodeSize=function(t){return arguments.length?(i=null!=(r=t),n):i?r:null},ii(n,t)},ao.layout.treemap=function(){function n(n,t){for(var e,r,i=-1,u=n.length;++it?0:t),e.area=isNaN(r)||0>=r?0:r}function t(e){var u=e.children;if(u&&u.length){var o,a,l,c=s(e),f=[],h=u.slice(),g=1/0,v="slice"===p?c.dx:"dice"===p?c.dy:"slice-dice"===p?1&e.depth?c.dy:c.dx:Math.min(c.dx,c.dy);for(n(h,c.dx*c.dy/e.value),f.area=0;(l=h.length)>0;)f.push(o=h[l-1]),f.area+=o.area,"squarify"!==p||(a=r(f,v))<=g?(h.pop(),g=a):(f.area-=f.pop().area,i(f,v,c,!1),v=Math.min(c.dx,c.dy),f.length=f.area=0,g=1/0);f.length&&(i(f,v,c,!0),f.length=f.area=0),u.forEach(t)}}function e(t){var r=t.children;if(r&&r.length){var u,o=s(t),a=r.slice(),l=[];for(n(a,o.dx*o.dy/t.value),l.area=0;u=a.pop();)l.push(u),l.area+=u.area,null!=u.z&&(i(l,u.z?o.dx:o.dy,o,!a.length),l.length=l.area=0);r.forEach(e)}}function r(n,t){for(var e,r=n.area,i=0,u=1/0,o=-1,a=n.length;++oe&&(u=e),e>i&&(i=e));return r*=r,t*=t,r?Math.max(t*i*g/r,r/(t*u*g)):1/0}function i(n,t,e,r){var i,u=-1,o=n.length,a=e.x,c=e.y,f=t?l(n.area/t):0; +if(t==e.dx){for((r||f>e.dy)&&(f=e.dy);++ue.dx)&&(f=e.dx);++ue&&(t=1),1>e&&(n=0),function(){var e,r,i;do e=2*Math.random()-1,r=2*Math.random()-1,i=e*e+r*r;while(!i||i>1);return n+t*e*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var n=ao.random.normal.apply(ao,arguments);return function(){return Math.exp(n())}},bates:function(n){var t=ao.random.irwinHall(n);return function(){return t()/n}},irwinHall:function(n){return function(){for(var t=0,e=0;n>e;e++)t+=Math.random();return t}}},ao.scale={};var Sl={floor:m,ceil:m};ao.scale.linear=function(){return Wi([0,1],[0,1],Mr,!1)};var kl={s:1,g:1,p:1,r:1,e:1};ao.scale.log=function(){return ru(ao.scale.linear().domain([0,1]),10,!0,[1,10])};var Nl=ao.format(".0e"),El={floor:function(n){return-Math.ceil(-n)},ceil:function(n){return-Math.floor(-n)}};ao.scale.pow=function(){return iu(ao.scale.linear(),1,[0,1])},ao.scale.sqrt=function(){return ao.scale.pow().exponent(.5)},ao.scale.ordinal=function(){return ou([],{t:"range",a:[[]]})},ao.scale.category10=function(){return ao.scale.ordinal().range(Al)},ao.scale.category20=function(){return ao.scale.ordinal().range(Cl)},ao.scale.category20b=function(){return ao.scale.ordinal().range(zl)},ao.scale.category20c=function(){return ao.scale.ordinal().range(Ll)};var Al=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(xn),Cl=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(xn),zl=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(xn),Ll=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(xn);ao.scale.quantile=function(){return au([],[])},ao.scale.quantize=function(){return lu(0,1,[0,1])},ao.scale.threshold=function(){return cu([.5],[0,1])},ao.scale.identity=function(){return fu([0,1])},ao.svg={},ao.svg.arc=function(){function n(){var n=Math.max(0,+e.apply(this,arguments)),c=Math.max(0,+r.apply(this,arguments)),f=o.apply(this,arguments)-Io,s=a.apply(this,arguments)-Io,h=Math.abs(s-f),p=f>s?0:1;if(n>c&&(g=c,c=n,n=g),h>=Oo)return t(c,p)+(n?t(n,1-p):"")+"Z";var g,v,d,y,m,M,x,b,_,w,S,k,N=0,E=0,A=[];if((y=(+l.apply(this,arguments)||0)/2)&&(d=u===ql?Math.sqrt(n*n+c*c):+u.apply(this,arguments),p||(E*=-1),c&&(E=tn(d/c*Math.sin(y))),n&&(N=tn(d/n*Math.sin(y)))),c){m=c*Math.cos(f+E),M=c*Math.sin(f+E),x=c*Math.cos(s-E),b=c*Math.sin(s-E);var C=Math.abs(s-f-2*E)<=Fo?0:1;if(E&&yu(m,M,x,b)===p^C){var z=(f+s)/2;m=c*Math.cos(z),M=c*Math.sin(z),x=b=null}}else m=M=0;if(n){_=n*Math.cos(s-N),w=n*Math.sin(s-N),S=n*Math.cos(f+N),k=n*Math.sin(f+N);var L=Math.abs(f-s+2*N)<=Fo?0:1;if(N&&yu(_,w,S,k)===1-p^L){var q=(f+s)/2;_=n*Math.cos(q),w=n*Math.sin(q),S=k=null}}else _=w=0;if(h>Uo&&(g=Math.min(Math.abs(c-n)/2,+i.apply(this,arguments)))>.001){v=c>n^p?0:1;var T=g,R=g;if(Fo>h){var D=null==S?[_,w]:null==x?[m,M]:Re([m,M],[S,k],[x,b],[_,w]),P=m-D[0],U=M-D[1],j=x-D[0],F=b-D[1],H=1/Math.sin(Math.acos((P*j+U*F)/(Math.sqrt(P*P+U*U)*Math.sqrt(j*j+F*F)))/2),O=Math.sqrt(D[0]*D[0]+D[1]*D[1]);R=Math.min(g,(n-O)/(H-1)),T=Math.min(g,(c-O)/(H+1))}if(null!=x){var I=mu(null==S?[_,w]:[S,k],[m,M],c,T,p),Y=mu([x,b],[_,w],c,T,p);g===T?A.push("M",I[0],"A",T,",",T," 0 0,",v," ",I[1],"A",c,",",c," 0 ",1-p^yu(I[1][0],I[1][1],Y[1][0],Y[1][1]),",",p," ",Y[1],"A",T,",",T," 0 0,",v," ",Y[0]):A.push("M",I[0],"A",T,",",T," 0 1,",v," ",Y[0])}else A.push("M",m,",",M);if(null!=S){var Z=mu([m,M],[S,k],n,-R,p),V=mu([_,w],null==x?[m,M]:[x,b],n,-R,p);g===R?A.push("L",V[0],"A",R,",",R," 0 0,",v," ",V[1],"A",n,",",n," 0 ",p^yu(V[1][0],V[1][1],Z[1][0],Z[1][1]),",",1-p," ",Z[1],"A",R,",",R," 0 0,",v," ",Z[0]):A.push("L",V[0],"A",R,",",R," 0 0,",v," ",Z[0])}else A.push("L",_,",",w)}else A.push("M",m,",",M),null!=x&&A.push("A",c,",",c," 0 ",C,",",p," ",x,",",b),A.push("L",_,",",w),null!=S&&A.push("A",n,",",n," 0 ",L,",",1-p," ",S,",",k);return A.push("Z"),A.join("")}function t(n,t){return"M0,"+n+"A"+n+","+n+" 0 1,"+t+" 0,"+-n+"A"+n+","+n+" 0 1,"+t+" 0,"+n}var e=hu,r=pu,i=su,u=ql,o=gu,a=vu,l=du;return n.innerRadius=function(t){return arguments.length?(e=En(t),n):e},n.outerRadius=function(t){return arguments.length?(r=En(t),n):r},n.cornerRadius=function(t){return arguments.length?(i=En(t),n):i},n.padRadius=function(t){return arguments.length?(u=t==ql?ql:En(t),n):u},n.startAngle=function(t){return arguments.length?(o=En(t),n):o},n.endAngle=function(t){return arguments.length?(a=En(t),n):a},n.padAngle=function(t){return arguments.length?(l=En(t),n):l},n.centroid=function(){var n=(+e.apply(this,arguments)+ +r.apply(this,arguments))/2,t=(+o.apply(this,arguments)+ +a.apply(this,arguments))/2-Io;return[Math.cos(t)*n,Math.sin(t)*n]},n};var ql="auto";ao.svg.line=function(){return Mu(m)};var Tl=ao.map({linear:xu,"linear-closed":bu,step:_u,"step-before":wu,"step-after":Su,basis:zu,"basis-open":Lu,"basis-closed":qu,bundle:Tu,cardinal:Eu,"cardinal-open":ku,"cardinal-closed":Nu,monotone:Fu});Tl.forEach(function(n,t){t.key=n,t.closed=/-closed$/.test(n)});var Rl=[0,2/3,1/3,0],Dl=[0,1/3,2/3,0],Pl=[0,1/6,2/3,1/6];ao.svg.line.radial=function(){var n=Mu(Hu);return n.radius=n.x,delete n.x,n.angle=n.y,delete n.y,n},wu.reverse=Su,Su.reverse=wu,ao.svg.area=function(){return Ou(m)},ao.svg.area.radial=function(){var n=Ou(Hu);return n.radius=n.x,delete n.x,n.innerRadius=n.x0,delete n.x0,n.outerRadius=n.x1,delete n.x1,n.angle=n.y,delete n.y,n.startAngle=n.y0,delete n.y0,n.endAngle=n.y1,delete n.y1,n},ao.svg.chord=function(){function n(n,a){var l=t(this,u,n,a),c=t(this,o,n,a);return"M"+l.p0+r(l.r,l.p1,l.a1-l.a0)+(e(l,c)?i(l.r,l.p1,l.r,l.p0):i(l.r,l.p1,c.r,c.p0)+r(c.r,c.p1,c.a1-c.a0)+i(c.r,c.p1,l.r,l.p0))+"Z"}function t(n,t,e,r){var i=t.call(n,e,r),u=a.call(n,i,r),o=l.call(n,i,r)-Io,f=c.call(n,i,r)-Io;return{r:u,a0:o,a1:f,p0:[u*Math.cos(o),u*Math.sin(o)],p1:[u*Math.cos(f),u*Math.sin(f)]}}function e(n,t){return n.a0==t.a0&&n.a1==t.a1}function r(n,t,e){return"A"+n+","+n+" 0 "+ +(e>Fo)+",1 "+t}function i(n,t,e,r){return"Q 0,0 "+r}var u=Me,o=xe,a=Iu,l=gu,c=vu;return n.radius=function(t){return arguments.length?(a=En(t),n):a},n.source=function(t){return arguments.length?(u=En(t),n):u},n.target=function(t){return arguments.length?(o=En(t),n):o},n.startAngle=function(t){return arguments.length?(l=En(t),n):l},n.endAngle=function(t){return arguments.length?(c=En(t),n):c},n},ao.svg.diagonal=function(){function n(n,i){var u=t.call(this,n,i),o=e.call(this,n,i),a=(u.y+o.y)/2,l=[u,{x:u.x,y:a},{x:o.x,y:a},o];return l=l.map(r),"M"+l[0]+"C"+l[1]+" "+l[2]+" "+l[3]}var t=Me,e=xe,r=Yu;return n.source=function(e){return arguments.length?(t=En(e),n):t},n.target=function(t){return arguments.length?(e=En(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},ao.svg.diagonal.radial=function(){var n=ao.svg.diagonal(),t=Yu,e=n.projection;return n.projection=function(n){return arguments.length?e(Zu(t=n)):t},n},ao.svg.symbol=function(){function n(n,r){return(Ul.get(t.call(this,n,r))||$u)(e.call(this,n,r))}var t=Xu,e=Vu;return n.type=function(e){return arguments.length?(t=En(e),n):t},n.size=function(t){return arguments.length?(e=En(t),n):e},n};var Ul=ao.map({circle:$u,cross:function(n){var t=Math.sqrt(n/5)/2;return"M"+-3*t+","+-t+"H"+-t+"V"+-3*t+"H"+t+"V"+-t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+-t+"V"+t+"H"+-3*t+"Z"},diamond:function(n){var t=Math.sqrt(n/(2*Fl)),e=t*Fl;return"M0,"+-t+"L"+e+",0 0,"+t+" "+-e+",0Z"},square:function(n){var t=Math.sqrt(n)/2;return"M"+-t+","+-t+"L"+t+","+-t+" "+t+","+t+" "+-t+","+t+"Z"},"triangle-down":function(n){var t=Math.sqrt(n/jl),e=t*jl/2;return"M0,"+e+"L"+t+","+-e+" "+-t+","+-e+"Z"},"triangle-up":function(n){var t=Math.sqrt(n/jl),e=t*jl/2;return"M0,"+-e+"L"+t+","+e+" "+-t+","+e+"Z"}});ao.svg.symbolTypes=Ul.keys();var jl=Math.sqrt(3),Fl=Math.tan(30*Yo);Co.transition=function(n){for(var t,e,r=Hl||++Zl,i=Ku(n),u=[],o=Ol||{time:Date.now(),ease:Nr,delay:0,duration:250},a=-1,l=this.length;++au;u++){i.push(t=[]);for(var e=this[u],a=0,l=e.length;l>a;a++)(r=e[a])&&n.call(r,r.__data__,a,u)&&t.push(r)}return Wu(i,this.namespace,this.id)},Yl.tween=function(n,t){var e=this.id,r=this.namespace;return arguments.length<2?this.node()[r][e].tween.get(n):Y(this,null==t?function(t){t[r][e].tween.remove(n)}:function(i){i[r][e].tween.set(n,t)})},Yl.attr=function(n,t){function e(){this.removeAttribute(a)}function r(){this.removeAttributeNS(a.space,a.local)}function i(n){return null==n?e:(n+="",function(){var t,e=this.getAttribute(a);return e!==n&&(t=o(e,n),function(n){this.setAttribute(a,t(n))})})}function u(n){return null==n?r:(n+="",function(){var t,e=this.getAttributeNS(a.space,a.local);return e!==n&&(t=o(e,n),function(n){this.setAttributeNS(a.space,a.local,t(n))})})}if(arguments.length<2){for(t in n)this.attr(t,n[t]);return this}var o="transform"==n?$r:Mr,a=ao.ns.qualify(n);return Ju(this,"attr."+n,t,a.local?u:i)},Yl.attrTween=function(n,t){function e(n,e){var r=t.call(this,n,e,this.getAttribute(i));return r&&function(n){this.setAttribute(i,r(n))}}function r(n,e){var r=t.call(this,n,e,this.getAttributeNS(i.space,i.local));return r&&function(n){this.setAttributeNS(i.space,i.local,r(n))}}var i=ao.ns.qualify(n);return this.tween("attr."+n,i.local?r:e)},Yl.style=function(n,e,r){function i(){this.style.removeProperty(n)}function u(e){return null==e?i:(e+="",function(){var i,u=t(this).getComputedStyle(this,null).getPropertyValue(n);return u!==e&&(i=Mr(u,e),function(t){this.style.setProperty(n,i(t),r)})})}var o=arguments.length;if(3>o){if("string"!=typeof n){2>o&&(e="");for(r in n)this.style(r,n[r],e);return this}r=""}return Ju(this,"style."+n,e,u)},Yl.styleTween=function(n,e,r){function i(i,u){var o=e.call(this,i,u,t(this).getComputedStyle(this,null).getPropertyValue(n));return o&&function(t){this.style.setProperty(n,o(t),r)}}return arguments.length<3&&(r=""),this.tween("style."+n,i)},Yl.text=function(n){return Ju(this,"text",n,Gu)},Yl.remove=function(){var n=this.namespace;return this.each("end.transition",function(){var t;this[n].count<2&&(t=this.parentNode)&&t.removeChild(this)})},Yl.ease=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].ease:("function"!=typeof n&&(n=ao.ease.apply(ao,arguments)),Y(this,function(r){r[e][t].ease=n}))},Yl.delay=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].delay:Y(this,"function"==typeof n?function(r,i,u){r[e][t].delay=+n.call(r,r.__data__,i,u)}:(n=+n,function(r){r[e][t].delay=n}))},Yl.duration=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].duration:Y(this,"function"==typeof n?function(r,i,u){r[e][t].duration=Math.max(1,n.call(r,r.__data__,i,u))}:(n=Math.max(1,n),function(r){r[e][t].duration=n}))},Yl.each=function(n,t){var e=this.id,r=this.namespace;if(arguments.length<2){var i=Ol,u=Hl;try{Hl=e,Y(this,function(t,i,u){Ol=t[r][e],n.call(t,t.__data__,i,u)})}finally{Ol=i,Hl=u}}else Y(this,function(i){var u=i[r][e];(u.event||(u.event=ao.dispatch("start","end","interrupt"))).on(n,t)});return this},Yl.transition=function(){for(var n,t,e,r,i=this.id,u=++Zl,o=this.namespace,a=[],l=0,c=this.length;c>l;l++){a.push(n=[]);for(var t=this[l],f=0,s=t.length;s>f;f++)(e=t[f])&&(r=e[o][i],Qu(e,f,o,u,{time:r.time,ease:r.ease,delay:r.delay+r.duration,duration:r.duration})),n.push(e)}return Wu(a,o,u)},ao.svg.axis=function(){function n(n){n.each(function(){var n,c=ao.select(this),f=this.__chart__||e,s=this.__chart__=e.copy(),h=null==l?s.ticks?s.ticks.apply(s,a):s.domain():l,p=null==t?s.tickFormat?s.tickFormat.apply(s,a):m:t,g=c.selectAll(".tick").data(h,s),v=g.enter().insert("g",".domain").attr("class","tick").style("opacity",Uo),d=ao.transition(g.exit()).style("opacity",Uo).remove(),y=ao.transition(g.order()).style("opacity",1),M=Math.max(i,0)+o,x=Zi(s),b=c.selectAll(".domain").data([0]),_=(b.enter().append("path").attr("class","domain"),ao.transition(b));v.append("line"),v.append("text");var w,S,k,N,E=v.select("line"),A=y.select("line"),C=g.select("text").text(p),z=v.select("text"),L=y.select("text"),q="top"===r||"left"===r?-1:1;if("bottom"===r||"top"===r?(n=no,w="x",k="y",S="x2",N="y2",C.attr("dy",0>q?"0em":".71em").style("text-anchor","middle"),_.attr("d","M"+x[0]+","+q*u+"V0H"+x[1]+"V"+q*u)):(n=to,w="y",k="x",S="y2",N="x2",C.attr("dy",".32em").style("text-anchor",0>q?"end":"start"),_.attr("d","M"+q*u+","+x[0]+"H0V"+x[1]+"H"+q*u)),E.attr(N,q*i),z.attr(k,q*M),A.attr(S,0).attr(N,q*i),L.attr(w,0).attr(k,q*M),s.rangeBand){var T=s,R=T.rangeBand()/2;f=s=function(n){return T(n)+R}}else f.rangeBand?f=s:d.call(n,s,f);v.call(n,f,s),y.call(n,s,s)})}var t,e=ao.scale.linear(),r=Vl,i=6,u=6,o=3,a=[10],l=null;return n.scale=function(t){return arguments.length?(e=t,n):e},n.orient=function(t){return arguments.length?(r=t in Xl?t+"":Vl,n):r},n.ticks=function(){return arguments.length?(a=co(arguments),n):a},n.tickValues=function(t){return arguments.length?(l=t,n):l},n.tickFormat=function(e){return arguments.length?(t=e,n):t},n.tickSize=function(t){var e=arguments.length;return e?(i=+t,u=+arguments[e-1],n):i},n.innerTickSize=function(t){return arguments.length?(i=+t,n):i},n.outerTickSize=function(t){return arguments.length?(u=+t,n):u},n.tickPadding=function(t){return arguments.length?(o=+t,n):o},n.tickSubdivide=function(){return arguments.length&&n},n};var Vl="bottom",Xl={top:1,right:1,bottom:1,left:1};ao.svg.brush=function(){function n(t){t.each(function(){var t=ao.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",u).on("touchstart.brush",u),o=t.selectAll(".background").data([0]);o.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),t.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var a=t.selectAll(".resize").data(v,m);a.exit().remove(),a.enter().append("g").attr("class",function(n){return"resize "+n}).style("cursor",function(n){return $l[n]}).append("rect").attr("x",function(n){return/[ew]$/.test(n)?-3:null}).attr("y",function(n){return/^[ns]/.test(n)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),a.style("display",n.empty()?"none":null);var l,s=ao.transition(t),h=ao.transition(o);c&&(l=Zi(c),h.attr("x",l[0]).attr("width",l[1]-l[0]),r(s)),f&&(l=Zi(f),h.attr("y",l[0]).attr("height",l[1]-l[0]),i(s)),e(s)})}function e(n){n.selectAll(".resize").attr("transform",function(n){return"translate("+s[+/e$/.test(n)]+","+h[+/^s/.test(n)]+")"})}function r(n){n.select(".extent").attr("x",s[0]),n.selectAll(".extent,.n>rect,.s>rect").attr("width",s[1]-s[0])}function i(n){n.select(".extent").attr("y",h[0]),n.selectAll(".extent,.e>rect,.w>rect").attr("height",h[1]-h[0])}function u(){function u(){32==ao.event.keyCode&&(C||(M=null,L[0]-=s[1],L[1]-=h[1],C=2),S())}function v(){32==ao.event.keyCode&&2==C&&(L[0]+=s[1],L[1]+=h[1],C=0,S())}function d(){var n=ao.mouse(b),t=!1;x&&(n[0]+=x[0],n[1]+=x[1]),C||(ao.event.altKey?(M||(M=[(s[0]+s[1])/2,(h[0]+h[1])/2]),L[0]=s[+(n[0]f?(i=r,r=f):i=f),v[0]!=r||v[1]!=i?(e?a=null:o=null,v[0]=r,v[1]=i,!0):void 0}function m(){d(),k.style("pointer-events","all").selectAll(".resize").style("display",n.empty()?"none":null),ao.select("body").style("cursor",null),q.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),z(),w({type:"brushend"})}var M,x,b=this,_=ao.select(ao.event.target),w=l.of(b,arguments),k=ao.select(b),N=_.datum(),E=!/^(n|s)$/.test(N)&&c,A=!/^(e|w)$/.test(N)&&f,C=_.classed("extent"),z=W(b),L=ao.mouse(b),q=ao.select(t(b)).on("keydown.brush",u).on("keyup.brush",v);if(ao.event.changedTouches?q.on("touchmove.brush",d).on("touchend.brush",m):q.on("mousemove.brush",d).on("mouseup.brush",m),k.interrupt().selectAll("*").interrupt(),C)L[0]=s[0]-L[0],L[1]=h[0]-L[1];else if(N){var T=+/w$/.test(N),R=+/^n/.test(N);x=[s[1-T]-L[0],h[1-R]-L[1]],L[0]=s[T],L[1]=h[R]}else ao.event.altKey&&(M=L.slice());k.style("pointer-events","none").selectAll(".resize").style("display",null),ao.select("body").style("cursor",_.style("cursor")),w({type:"brushstart"}),d()}var o,a,l=N(n,"brushstart","brush","brushend"),c=null,f=null,s=[0,0],h=[0,0],p=!0,g=!0,v=Bl[0];return n.event=function(n){n.each(function(){var n=l.of(this,arguments),t={x:s,y:h,i:o,j:a},e=this.__chart__||t;this.__chart__=t,Hl?ao.select(this).transition().each("start.brush",function(){o=e.i,a=e.j,s=e.x,h=e.y,n({type:"brushstart"})}).tween("brush:brush",function(){var e=xr(s,t.x),r=xr(h,t.y);return o=a=null,function(i){s=t.x=e(i),h=t.y=r(i),n({type:"brush",mode:"resize"})}}).each("end.brush",function(){o=t.i,a=t.j,n({type:"brush",mode:"resize"}),n({type:"brushend"})}):(n({type:"brushstart"}),n({type:"brush",mode:"resize"}),n({type:"brushend"}))})},n.x=function(t){return arguments.length?(c=t,v=Bl[!c<<1|!f],n):c},n.y=function(t){return arguments.length?(f=t,v=Bl[!c<<1|!f],n):f},n.clamp=function(t){return arguments.length?(c&&f?(p=!!t[0],g=!!t[1]):c?p=!!t:f&&(g=!!t),n):c&&f?[p,g]:c?p:f?g:null},n.extent=function(t){var e,r,i,u,l;return arguments.length?(c&&(e=t[0],r=t[1],f&&(e=e[0],r=r[0]),o=[e,r],c.invert&&(e=c(e),r=c(r)),e>r&&(l=e,e=r,r=l),e==s[0]&&r==s[1]||(s=[e,r])),f&&(i=t[0],u=t[1],c&&(i=i[1],u=u[1]),a=[i,u],f.invert&&(i=f(i),u=f(u)),i>u&&(l=i,i=u,u=l),i==h[0]&&u==h[1]||(h=[i,u])),n):(c&&(o?(e=o[0],r=o[1]):(e=s[0],r=s[1],c.invert&&(e=c.invert(e),r=c.invert(r)),e>r&&(l=e,e=r,r=l))),f&&(a?(i=a[0],u=a[1]):(i=h[0],u=h[1],f.invert&&(i=f.invert(i),u=f.invert(u)),i>u&&(l=i,i=u,u=l))),c&&f?[[e,i],[r,u]]:c?[e,r]:f&&[i,u])},n.clear=function(){return n.empty()||(s=[0,0],h=[0,0],o=a=null),n},n.empty=function(){return!!c&&s[0]==s[1]||!!f&&h[0]==h[1]},ao.rebind(n,l,"on")};var $l={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Bl=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],Wl=ga.format=xa.timeFormat,Jl=Wl.utc,Gl=Jl("%Y-%m-%dT%H:%M:%S.%LZ");Wl.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?eo:Gl,eo.parse=function(n){var t=new Date(n);return isNaN(t)?null:t},eo.toString=Gl.toString,ga.second=On(function(n){return new va(1e3*Math.floor(n/1e3))},function(n,t){n.setTime(n.getTime()+1e3*Math.floor(t))},function(n){return n.getSeconds()}),ga.seconds=ga.second.range,ga.seconds.utc=ga.second.utc.range,ga.minute=On(function(n){return new va(6e4*Math.floor(n/6e4))},function(n,t){n.setTime(n.getTime()+6e4*Math.floor(t))},function(n){return n.getMinutes()}),ga.minutes=ga.minute.range,ga.minutes.utc=ga.minute.utc.range,ga.hour=On(function(n){var t=n.getTimezoneOffset()/60;return new va(36e5*(Math.floor(n/36e5-t)+t))},function(n,t){n.setTime(n.getTime()+36e5*Math.floor(t))},function(n){return n.getHours()}),ga.hours=ga.hour.range,ga.hours.utc=ga.hour.utc.range,ga.month=On(function(n){return n=ga.day(n),n.setDate(1),n},function(n,t){n.setMonth(n.getMonth()+t)},function(n){return n.getMonth()}),ga.months=ga.month.range,ga.months.utc=ga.month.utc.range;var Kl=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Ql=[[ga.second,1],[ga.second,5],[ga.second,15],[ga.second,30],[ga.minute,1],[ga.minute,5],[ga.minute,15],[ga.minute,30],[ga.hour,1],[ga.hour,3],[ga.hour,6],[ga.hour,12],[ga.day,1],[ga.day,2],[ga.week,1],[ga.month,1],[ga.month,3],[ga.year,1]],nc=Wl.multi([[".%L",function(n){return n.getMilliseconds()}],[":%S",function(n){return n.getSeconds()}],["%I:%M",function(n){return n.getMinutes()}],["%I %p",function(n){return n.getHours()}],["%a %d",function(n){return n.getDay()&&1!=n.getDate()}],["%b %d",function(n){return 1!=n.getDate()}],["%B",function(n){return n.getMonth()}],["%Y",zt]]),tc={range:function(n,t,e){return ao.range(Math.ceil(n/e)*e,+t,e).map(io)},floor:m,ceil:m};Ql.year=ga.year,ga.scale=function(){return ro(ao.scale.linear(),Ql,nc)};var ec=Ql.map(function(n){return[n[0].utc,n[1]]}),rc=Jl.multi([[".%L",function(n){return n.getUTCMilliseconds()}],[":%S",function(n){return n.getUTCSeconds()}],["%I:%M",function(n){return n.getUTCMinutes()}],["%I %p",function(n){return n.getUTCHours()}],["%a %d",function(n){return n.getUTCDay()&&1!=n.getUTCDate()}],["%b %d",function(n){return 1!=n.getUTCDate()}],["%B",function(n){return n.getUTCMonth()}],["%Y",zt]]);ec.year=ga.year.utc,ga.scale.utc=function(){return ro(ao.scale.linear(),ec,rc)},ao.text=An(function(n){return n.responseText}),ao.json=function(n,t){return Cn(n,"application/json",uo,t)},ao.html=function(n,t){return Cn(n,"text/html",oo,t)},ao.xml=An(function(n){return n.responseXML}),"function"==typeof define&&define.amd?(this.d3=ao,define(ao)):"object"==typeof module&&module.exports?module.exports=ao:this.d3=ao}(); \ No newline at end of file diff --git a/schedoscope-metascope/src/main/resources/static/js/dagre-d3.core.min.js b/schedoscope-metascope/src/main/resources/static/js/dagre-d3.core.min.js new file mode 100644 index 000000000..7d11c8b2c --- /dev/null +++ b/schedoscope-metascope/src/main/resources/static/js/dagre-d3.core.min.js @@ -0,0 +1,24 @@ +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.dagreD3=t()}}(function(){return function t(e,r,n){function a(l,s){if(!r[l]){if(!e[l]){var o="function"==typeof require&&require;if(!s&&o)return o(l,!0);if(i)return i(l,!0);var d=new Error("Cannot find module '"+l+"'");throw d.code="MODULE_NOT_FOUND",d}var c=r[l]={exports:{}};e[l][0].call(c.exports,function(t){var r=e[l][1][t];return a(r?r:t)},c,c.exports,t,e,r,n)}return r[l].exports}for(var i="function"==typeof require&&require,l=0;lv?(v-y)/g:(v+y)/g,v=l*d-i*c,b=0>v?(v-y)/g:(v+y)/g,{x:x,y:b})}function a(t,e){return t*e>0}e.exports=n},{}],14:[function(t,e,r){function n(t,e){return t.intersect(e)}e.exports=n},{}],15:[function(t,e,r){function n(t,e,r){var n=t.x,i=t.y,l=[],s=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY;e.forEach(function(t){s=Math.min(s,t.x),o=Math.min(o,t.y)});for(var d=n-t.width/2-s,c=i-t.height/2-o,u=0;u1&&l.sort(function(t,e){var n=t.x-r.x,a=t.y-r.y,i=Math.sqrt(n*n+a*a),l=e.x-r.x,s=e.y-r.y,o=Math.sqrt(l*l+s*s);return o>i?-1:i===o?0:1}),l[0]):(console.log("NO INTERSECTION FOUND, RETURN NODE CENTER",t),t)}var a=t("./intersect-line");e.exports=n},{"./intersect-line":13}],16:[function(t,e,r){function n(t,e){var r,n,a=t.x,i=t.y,l=e.x-a,s=e.y-i,o=t.width/2,d=t.height/2;return Math.abs(s)*o>Math.abs(l)*d?(0>s&&(d=-d),r=0===s?0:d*l/s,n=d):(0>l&&(o=-o),r=o,n=0===l?0:o*s/l),{x:a+r,y:i+n}}e.exports=n},{}],17:[function(t,e,r){function n(t,e){var r=t.append("foreignObject").attr("width","100000"),n=r.append("xhtml:div");n.attr("xmlns","http://www.w3.org/1999/xhtml");var i=e.label;switch(typeof i){case"function":n.insert(i);break;case"object":n.insert(function(){return i});break;default:n.html(i)}a.applyStyle(n,e.labelStyle),n.style("display","inline-block"),n.style("white-space","nowrap");var l=n[0][0].getBoundingClientRect();return r.attr("width",l.width).attr("height",l.height),r}var a=t("../util");e.exports=n},{"../util":27}],18:[function(t,e,r){function n(t,e,r){var n=e.label,s=t.append("g");"svg"===e.labelType?l(s,e):"string"!=typeof n||"html"===e.labelType?i(s,e):a(s,e);var o,d=s.node().getBBox();switch(r){case"top":o=-e.height/2;break;case"bottom":o=e.height/2-d.height;break;default:o=-d.height/2}return s.attr("transform","translate("+-d.width/2+","+o+")"),s}var a=t("./add-text-label"),i=t("./add-html-label"),l=t("./add-svg-label");e.exports=n},{"./add-html-label":17,"./add-svg-label":19,"./add-text-label":20}],19:[function(t,e,r){function n(t,e){var r=t;return r.node().appendChild(e.label),a.applyStyle(r,e.labelStyle),r}var a=t("../util");e.exports=n},{"../util":27}],20:[function(t,e,r){function n(t,e){for(var r=t.append("text"),n=a(e.label).split("\n"),l=0;l0;--i){entry=buckets[i].dequeue();if(entry){results=results.concat(removeNode(g,buckets,zeroIdx,entry,true));break}}}}return results}function removeNode(g,buckets,zeroIdx,entry,collectPredecessors){var results=collectPredecessors?[]:undefined;_.each(g.inEdges(entry.v),function(edge){var weight=g.edge(edge),uEntry=g.node(edge.v);if(collectPredecessors){results.push({v:edge.v,w:edge.w})}uEntry.out-=weight;assignBucket(buckets,zeroIdx,uEntry)});_.each(g.outEdges(entry.v),function(edge){var weight=g.edge(edge),w=edge.w,wEntry=g.node(w);wEntry["in"]-=weight;assignBucket(buckets,zeroIdx,wEntry)});g.removeNode(entry.v);return results}function buildState(g,weightFn){var fasGraph=new Graph,maxIn=0,maxOut=0;_.each(g.nodes(),function(v){fasGraph.setNode(v,{v:v,"in":0,out:0})});_.each(g.edges(),function(e){var prevWeight=fasGraph.edge(e.v,e.w)||0,weight=weightFn(e),edgeWeight=prevWeight+weight;fasGraph.setEdge(e.v,e.w,edgeWeight);maxOut=Math.max(maxOut,fasGraph.node(e.v).out+=weight);maxIn=Math.max(maxIn,fasGraph.node(e.w)["in"]+=weight)});var buckets=_.range(maxOut+maxIn+3).map(function(){return new List});var zeroIdx=maxIn+1;_.each(fasGraph.nodes(),function(v){assignBucket(buckets,zeroIdx,fasGraph.node(v))});return{graph:fasGraph,buckets:buckets,zeroIdx:zeroIdx}}function assignBucket(buckets,zeroIdx,entry){if(!entry.out){buckets[0].enqueue(entry)}else if(!entry["in"]){buckets[buckets.length-1].enqueue(entry)}else{buckets[entry.out-entry["in"]+zeroIdx].enqueue(entry)}}},{"./data/list":5,"./graphlib":7,"./lodash":10}],9:[function(require,module,exports){"use strict";var _=require("./lodash"),acyclic=require("./acyclic"),normalize=require("./normalize"),rank=require("./rank"),normalizeRanks=require("./util").normalizeRanks,parentDummyChains=require("./parent-dummy-chains"),removeEmptyRanks=require("./util").removeEmptyRanks,nestingGraph=require("./nesting-graph"),addBorderSegments=require("./add-border-segments"),coordinateSystem=require("./coordinate-system"),order=require("./order"),position=require("./position"),util=require("./util"),Graph=require("./graphlib").Graph;module.exports=layout;function layout(g,opts){var time=opts&&opts.debugTiming?util.time:util.notime;time("layout",function(){var layoutGraph=time(" buildLayoutGraph",function(){return buildLayoutGraph(g)});time(" runLayout",function(){runLayout(layoutGraph,time)});time(" updateInputGraph",function(){updateInputGraph(g,layoutGraph)})})}function runLayout(g,time){time(" makeSpaceForEdgeLabels",function(){makeSpaceForEdgeLabels(g)});time(" removeSelfEdges",function(){removeSelfEdges(g)});time(" acyclic",function(){acyclic.run(g)});time(" nestingGraph.run",function(){nestingGraph.run(g)});time(" rank",function(){rank(util.asNonCompoundGraph(g))});time(" injectEdgeLabelProxies",function(){injectEdgeLabelProxies(g)});time(" removeEmptyRanks",function(){removeEmptyRanks(g)});time(" nestingGraph.cleanup",function(){nestingGraph.cleanup(g)});time(" normalizeRanks",function(){normalizeRanks(g)});time(" assignRankMinMax",function(){assignRankMinMax(g)});time(" removeEdgeLabelProxies",function(){removeEdgeLabelProxies(g)});time(" normalize.run",function(){normalize.run(g)});time(" parentDummyChains",function(){parentDummyChains(g)});time(" addBorderSegments",function(){addBorderSegments(g)});time(" order",function(){order(g)});time(" insertSelfEdges",function(){insertSelfEdges(g)});time(" adjustCoordinateSystem",function(){coordinateSystem.adjust(g)});time(" position",function(){position(g)});time(" positionSelfEdges",function(){positionSelfEdges(g)});time(" removeBorderNodes",function(){removeBorderNodes(g)});time(" normalize.undo",function(){normalize.undo(g)});time(" fixupEdgeLabelCoords",function(){fixupEdgeLabelCoords(g)});time(" undoCoordinateSystem",function(){coordinateSystem.undo(g)});time(" translateGraph",function(){translateGraph(g)});time(" assignNodeIntersects",function(){assignNodeIntersects(g)});time(" reversePoints",function(){reversePointsForReversedEdges(g)});time(" acyclic.undo",function(){acyclic.undo(g)})}function updateInputGraph(inputGraph,layoutGraph){_.each(inputGraph.nodes(),function(v){var inputLabel=inputGraph.node(v),layoutLabel=layoutGraph.node(v);if(inputLabel){inputLabel.x=layoutLabel.x;inputLabel.y=layoutLabel.y;if(layoutGraph.children(v).length){inputLabel.width=layoutLabel.width;inputLabel.height=layoutLabel.height}}});_.each(inputGraph.edges(),function(e){var inputLabel=inputGraph.edge(e),layoutLabel=layoutGraph.edge(e);inputLabel.points=layoutLabel.points;if(_.has(layoutLabel,"x")){inputLabel.x=layoutLabel.x;inputLabel.y=layoutLabel.y}});inputGraph.graph().width=layoutGraph.graph().width;inputGraph.graph().height=layoutGraph.graph().height}var graphNumAttrs=["nodesep","edgesep","ranksep","marginx","marginy"],graphDefaults={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},graphAttrs=["acyclicer","ranker","rankdir","align"],nodeNumAttrs=["width","height"],nodeDefaults={width:0,height:0},edgeNumAttrs=["minlen","weight","width","height","labeloffset"],edgeDefaults={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},edgeAttrs=["labelpos"];function buildLayoutGraph(inputGraph){var g=new Graph({multigraph:true,compound:true}),graph=canonicalize(inputGraph.graph());g.setGraph(_.merge({},graphDefaults,selectNumberAttrs(graph,graphNumAttrs),_.pick(graph,graphAttrs)));_.each(inputGraph.nodes(),function(v){var node=canonicalize(inputGraph.node(v));g.setNode(v,_.defaults(selectNumberAttrs(node,nodeNumAttrs),nodeDefaults));g.setParent(v,inputGraph.parent(v))});_.each(inputGraph.edges(),function(e){var edge=canonicalize(inputGraph.edge(e));g.setEdge(e,_.merge({},edgeDefaults,selectNumberAttrs(edge,edgeNumAttrs),_.pick(edge,edgeAttrs)))});return g}function makeSpaceForEdgeLabels(g){var graph=g.graph();graph.ranksep/=2;_.each(g.edges(),function(e){var edge=g.edge(e);edge.minlen*=2;if(edge.labelpos.toLowerCase()!=="c"){if(graph.rankdir==="TB"||graph.rankdir==="BT"){edge.width+=edge.labeloffset}else{edge.height+=edge.labeloffset}}})}function injectEdgeLabelProxies(g){_.each(g.edges(),function(e){var edge=g.edge(e);if(edge.width&&edge.height){var v=g.node(e.v),w=g.node(e.w),label={rank:(w.rank-v.rank)/2+v.rank,e:e};util.addDummyNode(g,"edge-proxy",label,"_ep")}})}function assignRankMinMax(g){var maxRank=0;_.each(g.nodes(),function(v){var node=g.node(v);if(node.borderTop){node.minRank=g.node(node.borderTop).rank;node.maxRank=g.node(node.borderBottom).rank;maxRank=_.max(maxRank,node.maxRank)}});g.graph().maxRank=maxRank}function removeEdgeLabelProxies(g){_.each(g.nodes(),function(v){var node=g.node(v);if(node.dummy==="edge-proxy"){g.edge(node.e).labelRank=node.rank;g.removeNode(v)}})}function translateGraph(g){var minX=Number.POSITIVE_INFINITY,maxX=0,minY=Number.POSITIVE_INFINITY,maxY=0,graphLabel=g.graph(),marginX=graphLabel.marginx||0,marginY=graphLabel.marginy||0;function getExtremes(attrs){var x=attrs.x,y=attrs.y,w=attrs.width,h=attrs.height;minX=Math.min(minX,x-w/2);maxX=Math.max(maxX,x+w/2);minY=Math.min(minY,y-h/2);maxY=Math.max(maxY,y+h/2)}_.each(g.nodes(),function(v){getExtremes(g.node(v))});_.each(g.edges(),function(e){var edge=g.edge(e);if(_.has(edge,"x")){getExtremes(edge)}});minX-=marginX;minY-=marginY;_.each(g.nodes(),function(v){var node=g.node(v);node.x-=minX;node.y-=minY});_.each(g.edges(),function(e){var edge=g.edge(e);_.each(edge.points,function(p){p.x-=minX;p.y-=minY});if(_.has(edge,"x")){edge.x-=minX}if(_.has(edge,"y")){edge.y-=minY}});graphLabel.width=maxX-minX+marginX;graphLabel.height=maxY-minY+marginY}function assignNodeIntersects(g){_.each(g.edges(),function(e){var edge=g.edge(e),nodeV=g.node(e.v),nodeW=g.node(e.w),p1,p2;if(!edge.points){edge.points=[];p1=nodeW;p2=nodeV}else{p1=edge.points[0];p2=edge.points[edge.points.length-1]}edge.points.unshift(util.intersectRect(nodeV,p1));edge.points.push(util.intersectRect(nodeW,p2))})}function fixupEdgeLabelCoords(g){_.each(g.edges(),function(e){var edge=g.edge(e);if(_.has(edge,"x")){if(edge.labelpos==="l"||edge.labelpos==="r"){edge.width-=edge.labeloffset}switch(edge.labelpos){case"l":edge.x-=edge.width/2+edge.labeloffset;break;case"r":edge.x+=edge.width/2+edge.labeloffset;break}}})}function reversePointsForReversedEdges(g){_.each(g.edges(),function(e){var edge=g.edge(e);if(edge.reversed){edge.points.reverse()}})}function removeBorderNodes(g){_.each(g.nodes(),function(v){if(g.children(v).length){var node=g.node(v),t=g.node(node.borderTop),b=g.node(node.borderBottom),l=g.node(_.last(node.borderLeft)),r=g.node(_.last(node.borderRight));node.width=Math.abs(r.x-l.x);node.height=Math.abs(b.y-t.y);node.x=l.x+node.width/2;node.y=t.y+node.height/2}});_.each(g.nodes(),function(v){if(g.node(v).dummy==="border"){g.removeNode(v)}})}function removeSelfEdges(g){_.each(g.edges(),function(e){if(e.v===e.w){var node=g.node(e.v);if(!node.selfEdges){node.selfEdges=[]}node.selfEdges.push({e:e,label:g.edge(e)});g.removeEdge(e)}})}function insertSelfEdges(g){var layers=util.buildLayerMatrix(g);_.each(layers,function(layer){var orderShift=0;_.each(layer,function(v,i){var node=g.node(v);node.order=i+orderShift;_.each(node.selfEdges,function(selfEdge){util.addDummyNode(g,"selfedge",{width:selfEdge.label.width,height:selfEdge.label.height,rank:node.rank,order:i+ ++orderShift,e:selfEdge.e,label:selfEdge.label},"_se")});delete node.selfEdges})})}function positionSelfEdges(g){_.each(g.nodes(),function(v){var node=g.node(v);if(node.dummy==="selfedge"){var selfNode=g.node(node.e.v),x=selfNode.x+selfNode.width/2,y=selfNode.y,dx=node.x-x,dy=selfNode.height/2;g.setEdge(node.e,node.label);g.removeNode(v);node.label.points=[{x:x+2*dx/3,y:y-dy},{x:x+5*dx/6,y:y-dy},{x:x+dx,y:y},{x:x+5*dx/6,y:y+dy},{x:x+2*dx/3,y:y+dy}];node.label.x=node.x;node.label.y=node.y}})}function selectNumberAttrs(obj,attrs){return _.mapValues(_.pick(obj,attrs),Number)}function canonicalize(attrs){var newAttrs={};_.each(attrs,function(v,k){newAttrs[k.toLowerCase()]=v});return newAttrs}},{"./acyclic":2,"./add-border-segments":3,"./coordinate-system":4,"./graphlib":7,"./lodash":10,"./nesting-graph":11,"./normalize":12,"./order":17,"./parent-dummy-chains":22,"./position":24,"./rank":26,"./util":29}],10:[function(require,module,exports){var lodash;if(typeof require==="function"){try{lodash=require("lodash")}catch(e){}}if(!lodash){lodash=window._}module.exports=lodash},{lodash:undefined}],11:[function(require,module,exports){var _=require("./lodash"),util=require("./util");module.exports={run:run,cleanup:cleanup};function run(g){var root=util.addDummyNode(g,"root",{},"_root"),depths=treeDepths(g),height=_.max(depths)-1,nodeSep=2*height+1;g.graph().nestingRoot=root;_.each(g.edges(),function(e){g.edge(e).minlen*=nodeSep});var weight=sumWeights(g)+1;_.each(g.children(),function(child){dfs(g,root,nodeSep,weight,height,depths,child)});g.graph().nodeRankFactor=nodeSep}function dfs(g,root,nodeSep,weight,height,depths,v){var children=g.children(v);if(!children.length){if(v!==root){g.setEdge(root,v,{weight:0,minlen:nodeSep})}return}var top=util.addBorderNode(g,"_bt"),bottom=util.addBorderNode(g,"_bb"),label=g.node(v);g.setParent(top,v);label.borderTop=top;g.setParent(bottom,v);label.borderBottom=bottom;_.each(children,function(child){dfs(g,root,nodeSep,weight,height,depths,child);var childNode=g.node(child),childTop=childNode.borderTop?childNode.borderTop:child,childBottom=childNode.borderBottom?childNode.borderBottom:child,thisWeight=childNode.borderTop?weight:2*weight,minlen=childTop!==childBottom?1:height-depths[v]+1;g.setEdge(top,childTop,{weight:thisWeight,minlen:minlen,nestingEdge:true});g.setEdge(childBottom,bottom,{weight:thisWeight,minlen:minlen,nestingEdge:true})});if(!g.parent(v)){g.setEdge(root,top,{weight:0,minlen:height+depths[v]})}}function treeDepths(g){var depths={};function dfs(v,depth){var children=g.children(v);if(children&&children.length){_.each(children,function(child){dfs(child,depth+1)})}depths[v]=depth}_.each(g.children(),function(v){dfs(v,1)});return depths}function sumWeights(g){return _.reduce(g.edges(),function(acc,e){return acc+g.edge(e).weight},0)}function cleanup(g){var graphLabel=g.graph();g.removeNode(graphLabel.nestingRoot);delete graphLabel.nestingRoot;_.each(g.edges(),function(e){var edge=g.edge(e);if(edge.nestingEdge){g.removeEdge(e)}})}},{"./lodash":10,"./util":29}],12:[function(require,module,exports){"use strict";var _=require("./lodash"),util=require("./util");module.exports={run:run,undo:undo};function run(g){g.graph().dummyChains=[];_.each(g.edges(),function(edge){normalizeEdge(g,edge)})}function normalizeEdge(g,e){var v=e.v,vRank=g.node(v).rank,w=e.w,wRank=g.node(w).rank,name=e.name,edgeLabel=g.edge(e),labelRank=edgeLabel.labelRank;if(wRank===vRank+1)return;g.removeEdge(e);var dummy,attrs,i;for(i=0,++vRank;vRank0){if(index%2){weightSum+=tree[index+1]}index=index-1>>1;tree[index]+=entry.weight}cc+=entry.weight*weightSum}));return cc}},{"../lodash":10}],17:[function(require,module,exports){"use strict";var _=require("../lodash"),initOrder=require("./init-order"),crossCount=require("./cross-count"),sortSubgraph=require("./sort-subgraph"),buildLayerGraph=require("./build-layer-graph"),addSubgraphConstraints=require("./add-subgraph-constraints"),Graph=require("../graphlib").Graph,util=require("../util");module.exports=order;function order(g){var maxRank=util.maxRank(g),downLayerGraphs=buildLayerGraphs(g,_.range(1,maxRank+1),"inEdges"),upLayerGraphs=buildLayerGraphs(g,_.range(maxRank-1,-1,-1),"outEdges");var layering=initOrder(g);assignOrder(g,layering);var bestCC=Number.POSITIVE_INFINITY,best;for(var i=0,lastBest=0;lastBest<4;++i,++lastBest){sweepLayerGraphs(i%2?downLayerGraphs:upLayerGraphs,i%4>=2);layering=util.buildLayerMatrix(g);var cc=crossCount(g,layering);if(cc=vEntry.barycenter){mergeEntries(vEntry,uEntry)}}}function handleOut(vEntry){return function(wEntry){wEntry["in"].push(vEntry);if(--wEntry.indegree===0){sourceSet.push(wEntry)}}}while(sourceSet.length){var entry=sourceSet.pop();entries.push(entry);_.each(entry["in"].reverse(),handleIn(entry));_.each(entry.out,handleOut(entry))}return _.chain(entries).filter(function(entry){return!entry.merged}).map(function(entry){return _.pick(entry,["vs","i","barycenter","weight"])}).value()}function mergeEntries(target,source){var sum=0,weight=0;if(target.weight){sum+=target.barycenter*target.weight;weight+=target.weight}if(source.weight){sum+=source.barycenter*source.weight;weight+=source.weight}target.vs=source.vs.concat(target.vs);target.barycenter=sum/weight;target.weight=weight;target.i=Math.min(source.i,target.i);source.merged=true}},{"../lodash":10}],20:[function(require,module,exports){var _=require("../lodash"),barycenter=require("./barycenter"),resolveConflicts=require("./resolve-conflicts"),sort=require("./sort");module.exports=sortSubgraph;function sortSubgraph(g,v,cg,biasRight){var movable=g.children(v),node=g.node(v),bl=node?node.borderLeft:undefined,br=node?node.borderRight:undefined,subgraphs={};if(bl){movable=_.filter(movable,function(w){return w!==bl&&w!==br})}var barycenters=barycenter(g,movable);_.each(barycenters,function(entry){if(g.children(entry.v).length){var subgraphResult=sortSubgraph(g,entry.v,cg,biasRight);subgraphs[entry.v]=subgraphResult;if(_.has(subgraphResult,"barycenter")){mergeBarycenters(entry,subgraphResult)}}});var entries=resolveConflicts(barycenters,cg);expandSubgraphs(entries,subgraphs);var result=sort(entries,biasRight);if(bl){result.vs=_.flatten([bl,result.vs,br],true);if(g.predecessors(bl).length){var blPred=g.node(g.predecessors(bl)[0]),brPred=g.node(g.predecessors(br)[0]);if(!_.has(result,"barycenter")){result.barycenter=0;result.weight=0}result.barycenter=(result.barycenter*result.weight+blPred.order+brPred.order)/(result.weight+2);result.weight+=2}}return result}function expandSubgraphs(entries,subgraphs){_.each(entries,function(entry){entry.vs=_.flatten(entry.vs.map(function(v){if(subgraphs[v]){return subgraphs[v].vs}return v}),true)})}function mergeBarycenters(target,other){if(!_.isUndefined(target.barycenter)){target.barycenter=(target.barycenter*target.weight+other.barycenter*other.weight)/(target.weight+other.weight);target.weight+=other.weight}else{target.barycenter=other.barycenter;target.weight=other.weight}}},{"../lodash":10,"./barycenter":14,"./resolve-conflicts":19,"./sort":21}],21:[function(require,module,exports){var _=require("../lodash"),util=require("../util");module.exports=sort;function sort(entries,biasRight){var parts=util.partition(entries,function(entry){return _.has(entry,"barycenter")});var sortable=parts.lhs,unsortable=_.sortBy(parts.rhs,function(entry){return-entry.i}),vs=[],sum=0,weight=0,vsIndex=0;sortable.sort(compareWithBias(!!biasRight));vsIndex=consumeUnsortable(vs,unsortable,vsIndex);_.each(sortable,function(entry){vsIndex+=entry.vs.length;vs.push(entry.vs);sum+=entry.barycenter*entry.weight;weight+=entry.weight;vsIndex=consumeUnsortable(vs,unsortable,vsIndex)});var result={vs:_.flatten(vs,true)};if(weight){result.barycenter=sum/weight;result.weight=weight}return result}function consumeUnsortable(vs,unsortable,index){var last;while(unsortable.length&&(last=_.last(unsortable)).i<=index){unsortable.pop();vs.push(last.vs);index++}return index}function compareWithBias(bias){return function(entryV,entryW){if(entryV.barycenterentryW.barycenter){return 1}return!bias?entryV.i-entryW.i:entryW.i-entryV.i}}},{"../lodash":10,"../util":29}],22:[function(require,module,exports){var _=require("./lodash");module.exports=parentDummyChains;function parentDummyChains(g){var postorderNums=postorder(g);_.each(g.graph().dummyChains,function(v){var node=g.node(v),edgeObj=node.edgeObj,pathData=findPath(g,postorderNums,edgeObj.v,edgeObj.w),path=pathData.path,lca=pathData.lca,pathIdx=0,pathV=path[pathIdx],ascending=true;while(v!==edgeObj.w){node=g.node(v);if(ascending){while((pathV=path[pathIdx])!==lca&&g.node(pathV).maxRanklow||lim>postorderNums[parent].lim));lca=parent;parent=w;while((parent=g.parent(parent))!==lca){wPath.push(parent)}return{path:vPath.concat(wPath.reverse()),lca:lca}}function postorder(g){var result={},lim=0;function dfs(v){var low=lim;_.each(g.children(v),dfs);result[v]={low:low,lim:lim++}}_.each(g.children(),dfs);return result}},{"./lodash":10}],23:[function(require,module,exports){"use strict";var _=require("../lodash"),Graph=require("../graphlib").Graph,util=require("../util");module.exports={positionX:positionX,findType1Conflicts:findType1Conflicts,findType2Conflicts:findType2Conflicts,addConflict:addConflict,hasConflict:hasConflict,verticalAlignment:verticalAlignment,horizontalCompaction:horizontalCompaction,alignCoordinates:alignCoordinates,findSmallestWidthAlignment:findSmallestWidthAlignment,balance:balance};function findType1Conflicts(g,layering){var conflicts={};function visitLayer(prevLayer,layer){var k0=0,scanPos=0,prevLayerLength=prevLayer.length,lastNode=_.last(layer);_.each(layer,function(v,i){var w=findOtherInnerSegmentNode(g,v),k1=w?g.node(w).order:prevLayerLength;if(w||v===lastNode){_.each(layer.slice(scanPos,i+1),function(scanNode){_.each(g.predecessors(scanNode),function(u){var uLabel=g.node(u),uPos=uLabel.order; +if((uPosnextNorthBorder)){addConflict(conflicts,u,v)}})}})}function visitLayer(north,south){var prevNorthPos=-1,nextNorthPos,southPos=0;_.each(south,function(v,southLookahead){if(g.node(v).dummy==="border"){var predecessors=g.predecessors(v);if(predecessors.length){nextNorthPos=g.node(predecessors[0]).order;scan(south,southPos,southLookahead,prevNorthPos,nextNorthPos);southPos=southLookahead;prevNorthPos=nextNorthPos}}scan(south,southPos,south.length,nextNorthPos,north.length)});return south}_.reduce(layering,visitLayer);return conflicts}function findOtherInnerSegmentNode(g,v){if(g.node(v).dummy){return _.find(g.predecessors(v),function(u){return g.node(u).dummy})}}function addConflict(conflicts,v,w){if(v>w){var tmp=v;v=w;w=tmp}var conflictsV=conflicts[v];if(!conflictsV){conflicts[v]=conflictsV={}}conflictsV[w]=true}function hasConflict(conflicts,v,w){if(v>w){var tmp=v;v=w;w=tmp}return _.has(conflicts[v],w)}function verticalAlignment(g,layering,conflicts,neighborFn){var root={},align={},pos={};_.each(layering,function(layer){_.each(layer,function(v,order){root[v]=v;align[v]=v;pos[v]=order})});_.each(layering,function(layer){var prevIdx=-1;_.each(layer,function(v){var ws=neighborFn(v);if(ws.length){ws=_.sortBy(ws,function(w){return pos[w]});var mp=(ws.length-1)/2;for(var i=Math.floor(mp),il=Math.ceil(mp);i<=il;++i){var w=ws[i];if(align[v]===v&&prevIdxwLabel.lim){tailLabel=wLabel;flip=true}var candidates=_.filter(g.edges(),function(edge){return flip===isDescendant(t,t.node(edge.v),tailLabel)&&flip!==isDescendant(t,t.node(edge.w),tailLabel)});return _.min(candidates,function(edge){return slack(g,edge)})}function exchangeEdges(t,g,e,f){var v=e.v,w=e.w;t.removeEdge(v,w);t.setEdge(f.v,f.w,{});initLowLimValues(t);initCutValues(t,g);updateRanks(t,g)}function updateRanks(t,g){var root=_.find(t.nodes(),function(v){return!g.node(v).parent}),vs=preorder(t,root);vs=vs.slice(1);_.each(vs,function(v){var parent=t.node(v).parent,edge=g.edge(v,parent),flipped=false;if(!edge){edge=g.edge(parent,v);flipped=true}g.node(v).rank=g.node(parent).rank+(flipped?edge.minlen:-edge.minlen)})}function isTreeEdge(tree,u,v){return tree.hasEdge(u,v)}function isDescendant(tree,vLabel,rootLabel){return rootLabel.low<=vLabel.lim&&vLabel.lim<=rootLabel.lim}},{"../graphlib":7,"../lodash":10,"../util":29,"./feasible-tree":25,"./util":28}],28:[function(require,module,exports){"use strict";var _=require("../lodash");module.exports={longestPath:longestPath,slack:slack};function longestPath(g){var visited={};function dfs(v){var label=g.node(v);if(_.has(visited,v)){return label.rank}visited[v]=true;var rank=_.min(_.map(g.outEdges(v),function(e){return dfs(e.w)-g.edge(e).minlen}));if(rank===Number.POSITIVE_INFINITY){rank=0}return label.rank=rank}_.each(g.sources(),dfs)}function slack(g,e){return g.node(e.w).rank-g.node(e.v).rank-g.edge(e).minlen}},{"../lodash":10}],29:[function(require,module,exports){"use strict";var _=require("./lodash"),Graph=require("./graphlib").Graph;module.exports={addDummyNode:addDummyNode,simplify:simplify,asNonCompoundGraph:asNonCompoundGraph,successorWeights:successorWeights,predecessorWeights:predecessorWeights,intersectRect:intersectRect,buildLayerMatrix:buildLayerMatrix,normalizeRanks:normalizeRanks,removeEmptyRanks:removeEmptyRanks,addBorderNode:addBorderNode,maxRank:maxRank,partition:partition,time:time,notime:notime};function addDummyNode(g,type,attrs,name){var v;do{v=_.uniqueId(name)}while(g.hasNode(v));attrs.dummy=type;g.setNode(v,attrs);return v}function simplify(g){var simplified=(new Graph).setGraph(g.graph());_.each(g.nodes(),function(v){simplified.setNode(v,g.node(v))});_.each(g.edges(),function(e){var simpleLabel=simplified.edge(e.v,e.w)||{weight:0,minlen:1},label=g.edge(e);simplified.setEdge(e.v,e.w,{weight:simpleLabel.weight+label.weight,minlen:Math.max(simpleLabel.minlen,label.minlen)})});return simplified}function asNonCompoundGraph(g){var simplified=new Graph({multigraph:g.isMultigraph()}).setGraph(g.graph());_.each(g.nodes(),function(v){if(!g.children(v).length){simplified.setNode(v,g.node(v))}});_.each(g.edges(),function(e){simplified.setEdge(e,g.edge(e))});return simplified}function successorWeights(g){var weightMap=_.map(g.nodes(),function(v){var sucs={};_.each(g.outEdges(v),function(e){sucs[e.w]=(sucs[e.w]||0)+g.edge(e).weight});return sucs});return _.zipObject(g.nodes(),weightMap)}function predecessorWeights(g){var weightMap=_.map(g.nodes(),function(v){var preds={};_.each(g.inEdges(v),function(e){preds[e.v]=(preds[e.v]||0)+g.edge(e).weight});return preds});return _.zipObject(g.nodes(),weightMap)}function intersectRect(rect,point){var x=rect.x;var y=rect.y;var dx=point.x-x;var dy=point.y-y;var w=rect.width/2;var h=rect.height/2;if(!dx&&!dy){throw new Error("Not possible to find intersection inside of the rectangle")}var sx,sy;if(Math.abs(dy)*w>Math.abs(dx)*h){if(dy<0){h=-h}sx=h*dx/dy;sy=h}else{if(dx<0){w=-w}sx=w;sy=w*dy/dx}return{x:x+sx,y:y+sy}}function buildLayerMatrix(g){var layering=_.map(_.range(maxRank(g)+1),function(){return[]});_.each(g.nodes(),function(v){var node=g.node(v),rank=node.rank;if(!_.isUndefined(rank)){layering[rank][node.order]=v}});return layering}function normalizeRanks(g){var min=_.min(_.map(g.nodes(),function(v){return g.node(v).rank}));_.each(g.nodes(),function(v){var node=g.node(v);if(_.has(node,"rank")){node.rank-=min}})}function removeEmptyRanks(g){var offset=_.min(_.map(g.nodes(),function(v){return g.node(v).rank}));var layers=[];_.each(g.nodes(),function(v){var rank=g.node(v).rank-offset;if(!layers[rank]){layers[rank]=[]}layers[rank].push(v)});var delta=0,nodeRankFactor=g.graph().nodeRankFactor;_.each(layers,function(vs,i){if(_.isUndefined(vs)&&i%nodeRankFactor!==0){--delta}else if(delta){_.each(vs,function(v){g.node(v).rank+=delta})}})}function addBorderNode(g,prefix,rank,order){var node={width:0,height:0};if(arguments.length>=4){node.rank=rank;node.order=order}return addDummyNode(g,"border",node,prefix)}function maxRank(g){return _.max(_.map(g.nodes(),function(v){var rank=g.node(v).rank;if(!_.isUndefined(rank)){return rank}}))}function partition(collection,fn){var result={lhs:[],rhs:[]};_.each(collection,function(value){if(fn(value)){result.lhs.push(value)}else{result.rhs.push(value)}});return result}function time(name,fn){var start=_.now();try{return fn()}finally{console.log(name+" time: "+(_.now()-start)+"ms")}}function notime(name,fn){return fn()}},{"./graphlib":7,"./lodash":10}],30:[function(require,module,exports){module.exports="0.7.4"},{}]},{},[1])(1)}); \ No newline at end of file diff --git a/schedoscope-metascope/src/main/resources/static/js/graphlib.core.min.js b/schedoscope-metascope/src/main/resources/static/js/graphlib.core.min.js new file mode 100644 index 000000000..363886695 --- /dev/null +++ b/schedoscope-metascope/src/main/resources/static/js/graphlib.core.min.js @@ -0,0 +1,31 @@ +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o0){v=pq.removeMin();vEntry=results[v];if(vEntry.distance===Number.POSITIVE_INFINITY){break}edgeFn(v).forEach(updateNeighbors)}return results}},{"../data/priority-queue":16,"../lodash":20}],7:[function(require,module,exports){var _=require("../lodash"),tarjan=require("./tarjan");module.exports=findCycles;function findCycles(g){return _.filter(tarjan(g),function(cmpt){return cmpt.length>1||cmpt.length===1&&g.hasEdge(cmpt[0],cmpt[0])})}},{"../lodash":20,"./tarjan":14}],8:[function(require,module,exports){var _=require("../lodash");module.exports=floydWarshall;var DEFAULT_WEIGHT_FUNC=_.constant(1);function floydWarshall(g,weightFn,edgeFn){return runFloydWarshall(g,weightFn||DEFAULT_WEIGHT_FUNC,edgeFn||function(v){return g.outEdges(v)})}function runFloydWarshall(g,weightFn,edgeFn){var results={},nodes=g.nodes();nodes.forEach(function(v){results[v]={};results[v][v]={distance:0};nodes.forEach(function(w){if(v!==w){results[v][w]={distance:Number.POSITIVE_INFINITY}}});edgeFn(v).forEach(function(edge){var w=edge.v===v?edge.w:edge.v,d=weightFn(edge);results[v][w]={distance:d,predecessor:v}})});nodes.forEach(function(k){var rowK=results[k];nodes.forEach(function(i){var rowI=results[i];nodes.forEach(function(j){var ik=rowI[k];var kj=rowK[j];var ij=rowI[j];var altDistance=ik.distance+kj.distance;if(altDistance0){v=pq.removeMin();if(_.has(parents,v)){result.setEdge(v,parents[v])}else if(init){throw new Error("Input graph is not connected: "+g)}else{init=true}g.nodeEdges(v).forEach(updateNeighbors)}return result}},{"../data/priority-queue":16,"../graph":17,"../lodash":20}],14:[function(require,module,exports){var _=require("../lodash");module.exports=tarjan;function tarjan(g){var index=0,stack=[],visited={},results=[];function dfs(v){var entry=visited[v]={onStack:true,lowlink:index,index:index++};stack.push(v);g.successors(v).forEach(function(w){if(!_.has(visited,w)){dfs(w);entry.lowlink=Math.min(entry.lowlink,visited[w].lowlink)}else if(visited[w].onStack){entry.lowlink=Math.min(entry.lowlink,visited[w].index)}});if(entry.lowlink===entry.index){var cmpt=[],w;do{w=stack.pop();visited[w].onStack=false;cmpt.push(w)}while(v!==w);results.push(cmpt)}}g.nodes().forEach(function(v){if(!_.has(visited,v)){dfs(v)}});return results}},{"../lodash":20}],15:[function(require,module,exports){var _=require("../lodash");module.exports=topsort;topsort.CycleException=CycleException;function topsort(g){var visited={},stack={},results=[];function visit(node){if(_.has(stack,node)){throw new CycleException}if(!_.has(visited,node)){stack[node]=true;visited[node]=true;_.each(g.predecessors(node),visit);delete stack[node];results.push(node)}}_.each(g.sinks(),visit);if(_.size(visited)!==g.nodeCount()){throw new CycleException}return results}function CycleException(){}},{"../lodash":20}],16:[function(require,module,exports){var _=require("../lodash");module.exports=PriorityQueue;function PriorityQueue(){this._arr=[];this._keyIndices={}}PriorityQueue.prototype.size=function(){return this._arr.length};PriorityQueue.prototype.keys=function(){return this._arr.map(function(x){return x.key})};PriorityQueue.prototype.has=function(key){return _.has(this._keyIndices,key)};PriorityQueue.prototype.priority=function(key){var index=this._keyIndices[key];if(index!==undefined){return this._arr[index].priority}};PriorityQueue.prototype.min=function(){if(this.size()===0){throw new Error("Queue underflow")}return this._arr[0].key};PriorityQueue.prototype.add=function(key,priority){var keyIndices=this._keyIndices;key=String(key);if(!_.has(keyIndices,key)){var arr=this._arr;var index=arr.length;keyIndices[key]=index;arr.push({key:key,priority:priority});this._decrease(index);return true}return false};PriorityQueue.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var min=this._arr.pop();delete this._keyIndices[min.key];this._heapify(0);return min.key};PriorityQueue.prototype.decrease=function(key,priority){var index=this._keyIndices[key];if(priority>this._arr[index].priority){throw new Error("New priority is greater than current priority. "+"Key: "+key+" Old: "+this._arr[index].priority+" New: "+priority)}this._arr[index].priority=priority;this._decrease(index)};PriorityQueue.prototype._heapify=function(i){var arr=this._arr;var l=2*i,r=l+1,largest=i;if(l>1;if(arr[parent].priority1){this.setNode(v,value)}else{this.setNode(v)}},this);return this};Graph.prototype.setNode=function(v,value){if(_.has(this._nodes,v)){if(arguments.length>1){this._nodes[v]=value}return this}this._nodes[v]=arguments.length>1?value:this._defaultNodeLabelFn(v);if(this._isCompound){this._parent[v]=GRAPH_NODE;this._children[v]={};this._children[GRAPH_NODE][v]=true}this._in[v]={};this._preds[v]={};this._out[v]={};this._sucs[v]={};++this._nodeCount;return this};Graph.prototype.node=function(v){return this._nodes[v]};Graph.prototype.hasNode=function(v){return _.has(this._nodes,v)};Graph.prototype.removeNode=function(v){var self=this;if(_.has(this._nodes,v)){var removeEdge=function(e){self.removeEdge(self._edgeObjs[e])};delete this._nodes[v];if(this._isCompound){this._removeFromParentsChildList(v);delete this._parent[v];_.each(this.children(v),function(child){this.setParent(child)},this);delete this._children[v]}_.each(_.keys(this._in[v]),removeEdge);delete this._in[v];delete this._preds[v];_.each(_.keys(this._out[v]),removeEdge);delete this._out[v];delete this._sucs[v];--this._nodeCount}return this};Graph.prototype.setParent=function(v,parent){if(!this._isCompound){throw new Error("Cannot set parent in a non-compound graph")}if(_.isUndefined(parent)){parent=GRAPH_NODE}else{parent+="";for(var ancestor=parent;!_.isUndefined(ancestor);ancestor=this.parent(ancestor)){if(ancestor===v){throw new Error("Setting "+parent+" as parent of "+v+" would create create a cycle")}}this.setNode(parent)}this.setNode(v);this._removeFromParentsChildList(v);this._parent[v]=parent;this._children[parent][v]=true;return this};Graph.prototype._removeFromParentsChildList=function(v){delete this._children[this._parent[v]][v]};Graph.prototype.parent=function(v){if(this._isCompound){var parent=this._parent[v];if(parent!==GRAPH_NODE){return parent}}};Graph.prototype.children=function(v){if(_.isUndefined(v)){v=GRAPH_NODE}if(this._isCompound){var children=this._children[v];if(children){return _.keys(children)}}else if(v===GRAPH_NODE){return this.nodes()}else if(this.hasNode(v)){return[]}};Graph.prototype.predecessors=function(v){var predsV=this._preds[v];if(predsV){return _.keys(predsV)}};Graph.prototype.successors=function(v){var sucsV=this._sucs[v];if(sucsV){return _.keys(sucsV)}};Graph.prototype.neighbors=function(v){var preds=this.predecessors(v);if(preds){return _.union(preds,this.successors(v))}};Graph.prototype.filterNodes=function(filter){var copy=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});copy.setGraph(this.graph());_.each(this._nodes,function(value,v){if(filter(v)){copy.setNode(v,value)}},this);_.each(this._edgeObjs,function(e){if(copy.hasNode(e.v)&©.hasNode(e.w)){copy.setEdge(e,this.edge(e))}},this);var self=this;var parents={};function findParent(v){var parent=self.parent(v);if(parent===undefined||copy.hasNode(parent)){parents[v]=parent;return parent}else if(parent in parents){return parents[parent]}else{return findParent(parent)}}if(this._isCompound){_.each(copy.nodes(),function(v){copy.setParent(v,findParent(v))})}return copy};Graph.prototype.setDefaultEdgeLabel=function(newDefault){if(!_.isFunction(newDefault)){newDefault=_.constant(newDefault)}this._defaultEdgeLabelFn=newDefault;return this};Graph.prototype.edgeCount=function(){return this._edgeCount};Graph.prototype.edges=function(){return _.values(this._edgeObjs)};Graph.prototype.setPath=function(vs,value){var self=this,args=arguments;_.reduce(vs,function(v,w){if(args.length>1){self.setEdge(v,w,value)}else{self.setEdge(v,w)}return w});return this};Graph.prototype.setEdge=function(){var v,w,name,value,valueSpecified=false,arg0=arguments[0];if(typeof arg0==="object"&&arg0!==null&&"v"in arg0){v=arg0.v;w=arg0.w;name=arg0.name;if(arguments.length===2){value=arguments[1];valueSpecified=true}}else{v=arg0;w=arguments[1];name=arguments[3];if(arguments.length>2){value=arguments[2];valueSpecified=true}}v=""+v;w=""+w;if(!_.isUndefined(name)){name=""+name}var e=edgeArgsToId(this._isDirected,v,w,name);if(_.has(this._edgeLabels,e)){if(valueSpecified){this._edgeLabels[e]=value}return this}if(!_.isUndefined(name)&&!this._isMultigraph){throw new Error("Cannot set a named edge when isMultigraph = false")}this.setNode(v);this.setNode(w);this._edgeLabels[e]=valueSpecified?value:this._defaultEdgeLabelFn(v,w,name);var edgeObj=edgeArgsToObj(this._isDirected,v,w,name);v=edgeObj.v;w=edgeObj.w;Object.freeze(edgeObj);this._edgeObjs[e]=edgeObj;incrementOrInitEntry(this._preds[w],v);incrementOrInitEntry(this._sucs[v],w);this._in[w][e]=edgeObj;this._out[v][e]=edgeObj;this._edgeCount++;return this};Graph.prototype.edge=function(v,w,name){var e=arguments.length===1?edgeObjToId(this._isDirected,arguments[0]):edgeArgsToId(this._isDirected,v,w,name);return this._edgeLabels[e]};Graph.prototype.hasEdge=function(v,w,name){var e=arguments.length===1?edgeObjToId(this._isDirected,arguments[0]):edgeArgsToId(this._isDirected,v,w,name);return _.has(this._edgeLabels,e)};Graph.prototype.removeEdge=function(v,w,name){var e=arguments.length===1?edgeObjToId(this._isDirected,arguments[0]):edgeArgsToId(this._isDirected,v,w,name),edge=this._edgeObjs[e];if(edge){v=edge.v;w=edge.w;delete this._edgeLabels[e];delete this._edgeObjs[e];decrementOrRemoveEntry(this._preds[w],v);decrementOrRemoveEntry(this._sucs[v],w);delete this._in[w][e];delete this._out[v][e];this._edgeCount--}return this};Graph.prototype.inEdges=function(v,u){var inV=this._in[v];if(inV){var edges=_.values(inV);if(!u){return edges}return _.filter(edges,function(edge){return edge.v===u})}};Graph.prototype.outEdges=function(v,w){var outV=this._out[v];if(outV){var edges=_.values(outV);if(!w){return edges}return _.filter(edges,function(edge){return edge.w===w})}};Graph.prototype.nodeEdges=function(v,w){var inEdges=this.inEdges(v,w);if(inEdges){return inEdges.concat(this.outEdges(v,w))}};function incrementOrInitEntry(map,k){if(map[k]){map[k]++}else{map[k]=1}}function decrementOrRemoveEntry(map,k){if(!--map[k]){delete map[k]}}function edgeArgsToId(isDirected,v_,w_,name){var v=""+v_;var w=""+w_;if(!isDirected&&v>w){var tmp=v;v=w;w=tmp}return v+EDGE_KEY_DELIM+w+EDGE_KEY_DELIM+(_.isUndefined(name)?DEFAULT_EDGE_NAME:name)}function edgeArgsToObj(isDirected,v_,w_,name){var v=""+v_;var w=""+w_;if(!isDirected&&v>w){var tmp=v;v=w;w=tmp}var edgeObj={v:v,w:w};if(name){edgeObj.name=name}return edgeObj}function edgeObjToId(isDirected,edgeObj){return edgeArgsToId(isDirected,edgeObj.v,edgeObj.w,edgeObj.name)}},{"./lodash":20}],18:[function(require,module,exports){module.exports={Graph:require("./graph"),version:require("./version")}},{"./graph":17,"./version":21}],19:[function(require,module,exports){var _=require("./lodash"),Graph=require("./graph");module.exports={write:write,read:read};function write(g){var json={options:{directed:g.isDirected(),multigraph:g.isMultigraph(),compound:g.isCompound()},nodes:writeNodes(g),edges:writeEdges(g)};if(!_.isUndefined(g.graph())){json.value=_.clone(g.graph())}return json}function writeNodes(g){return _.map(g.nodes(),function(v){var nodeValue=g.node(v),parent=g.parent(v),node={v:v};if(!_.isUndefined(nodeValue)){node.value=nodeValue}if(!_.isUndefined(parent)){node.parent=parent}return node})}function writeEdges(g){return _.map(g.edges(),function(e){var edgeValue=g.edge(e),edge={v:e.v,w:e.w};if(!_.isUndefined(e.name)){edge.name=e.name}if(!_.isUndefined(edgeValue)){edge.value=edgeValue}return edge})}function read(json){var g=new Graph(json.options).setGraph(json.value);_.each(json.nodes,function(entry){g.setNode(entry.v,entry.value);if(entry.parent){g.setParent(entry.v,entry.parent)}});_.each(json.edges,function(entry){g.setEdge({v:entry.v,w:entry.w,name:entry.name},entry.value)});return g}},{"./graph":17,"./lodash":20}],20:[function(require,module,exports){var lodash;if(typeof require==="function"){try{lodash=require("lodash")}catch(e){}}if(!lodash){lodash=window._}module.exports=lodash},{lodash:undefined}],21:[function(require,module,exports){module.exports="1.0.7"},{}]},{},[1]); diff --git a/schedoscope-metascope/src/main/resources/static/js/lodash.min.js b/schedoscope-metascope/src/main/resources/static/js/lodash.min.js new file mode 100644 index 000000000..e6c9820b2 --- /dev/null +++ b/schedoscope-metascope/src/main/resources/static/js/lodash.min.js @@ -0,0 +1,98 @@ +/** + * @license + * lodash 3.10.1 (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE + * Build: `lodash modern -o ./lodash.js` + */ +;(function(){function n(n,t){if(n!==t){var r=null===n,e=n===w,u=n===n,o=null===t,i=t===w,f=t===t;if(n>t&&!o||!u||r&&!i&&f||e&&f)return 1;if(n=n&&9<=n&&13>=n||32==n||160==n||5760==n||6158==n||8192<=n&&(8202>=n||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n); +}function v(n,t){for(var r=-1,e=n.length,u=-1,o=[];++r=F&&gu&&lu?new Dn(t):null,c=t.length;a&&(i=Mn,f=false,t=a);n:for(;++oi(t,a,0)&&u.push(a);return u}function at(n,t){var r=true;return Su(n,function(n,e,u){return r=!!t(n,e,u)}),r}function ct(n,t,r,e){var u=e,o=u;return Su(n,function(n,i,f){i=+t(n,i,f),(r(i,u)||i===e&&i===o)&&(u=i, +o=n)}),o}function lt(n,t){var r=[];return Su(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function st(n,t,r,e){var u;return r(n,function(n,r,o){return t(n,r,o)?(u=e?r:n,false):void 0}),u}function pt(n,t,r,e){e||(e=[]);for(var u=-1,o=n.length;++ut&&(t=-t>u?0:u+t),r=r===w||r>u?u:+r||0,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=Be(u);++e=c)break n;o=e[o],u*="asc"===o||true===o?1:-1;break n}u=t.b-r.b}return u})}function $t(n,t){ +var r=0;return Su(n,function(n,e,u){r+=+t(n,e,u)||0}),r}function St(n,t){var e=-1,u=xr(),o=n.length,i=u===r,f=i&&o>=F,a=f&&gu&&lu?new Dn(void 0):null,c=[];a?(u=Mn,i=false):(f=false,a=t?[]:c);n:for(;++eu(a,s,0)&&((t||f)&&a.push(s),c.push(l))}return c}function Ft(n,t){for(var r=-1,e=t.length,u=Be(e);++r>>1,i=n[o];(r?i<=t:iu?w:o,u=1);++e=F)return t.plant(e).value();for(var u=0,n=r?o[u].apply(this,n):e;++uarguments.length;return typeof e=="function"&&o===w&&Oo(r)?n(r,e,u,i):Ot(r,wr(e,o,4),u,i,t)}}function sr(n,t,r,e,u,o,i,f,a,c){function l(){for(var m=arguments.length,b=m,j=Be(m);b--;)j[b]=arguments[b];if(e&&(j=Mt(j,e,u)),o&&(j=qt(j,o,i)),_||y){var b=l.placeholder,k=v(j,b),m=m-k.length;if(mt?0:t)):[]}function Pr(n,t,r){var e=n?n.length:0;return e?((r?Ur(n,t,r):null==t)&&(t=1),t=e-(+t||0),Et(n,0,0>t?0:t)):[]}function Kr(n){return n?n[0]:w}function Vr(n,t,e){var u=n?n.length:0;if(!u)return-1;if(typeof e=="number")e=0>e?bu(u+e,0):e;else if(e)return e=Lt(n,t), +er?bu(u+r,0):r||0,typeof n=="string"||!Oo(n)&&be(n)?r<=u&&-1t?0:+t||0,e);++r=n&&(t=w),r}}function ae(n,t,r){function e(t,r){r&&iu(r),a=p=h=w,t&&(_=ho(),c=n.apply(s,f),p||a||(f=s=w))}function u(){var n=t-(ho()-l);0>=n||n>t?e(h,a):p=su(u,n)}function o(){e(g,p); +}function i(){if(f=arguments,l=ho(),s=this,h=g&&(p||!y),false===v)var r=y&&!p;else{a||y||(_=l);var e=v-(l-_),i=0>=e||e>v;i?(a&&(a=iu(a)),_=l,c=n.apply(s,f)):a||(a=su(o,e))}return i&&p?p=iu(p):p||t===v||(p=su(u,t)),r&&(i=true,c=n.apply(s,f)),!i||p||a||(f=s=w),c}var f,a,c,l,s,p,h,_=0,v=false,g=true;if(typeof n!="function")throw new Ge(L);if(t=0>t?0:+t||0,true===r)var y=true,g=false;else ge(r)&&(y=!!r.leading,v="maxWait"in r&&bu(+r.maxWait||0,t),g="trailing"in r?!!r.trailing:g);return i.cancel=function(){p&&iu(p),a&&iu(a), +_=0,a=p=h=w},i}function ce(n,t){function r(){var e=arguments,u=t?t.apply(this,e):e[0],o=r.cache;return o.has(u)?o.get(u):(e=n.apply(this,e),r.cache=o.set(u,e),e)}if(typeof n!="function"||t&&typeof t!="function")throw new Ge(L);return r.cache=new ce.Cache,r}function le(n,t){if(typeof n!="function")throw new Ge(L);return t=bu(t===w?n.length-1:+t||0,0),function(){for(var r=arguments,e=-1,u=bu(r.length-t,0),o=Be(u);++et}function pe(n){return h(n)&&Er(n)&&nu.call(n,"callee")&&!cu.call(n,"callee")}function he(n,t,r,e){return e=(r=typeof r=="function"?Bt(r,e,3):w)?r(n,t):w,e===w?dt(n,t,r):!!e}function _e(n){return h(n)&&typeof n.message=="string"&&ru.call(n)==P}function ve(n){return ge(n)&&ru.call(n)==K}function ge(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function ye(n){ +return null==n?false:ve(n)?uu.test(Qe.call(n)):h(n)&&Rn.test(n)}function de(n){return typeof n=="number"||h(n)&&ru.call(n)==V}function me(n){var t;if(!h(n)||ru.call(n)!=Z||pe(n)||!(nu.call(n,"constructor")||(t=n.constructor,typeof t!="function"||t instanceof t)))return false;var r;return ht(n,function(n,t){r=t}),r===w||nu.call(n,r)}function we(n){return ge(n)&&ru.call(n)==Y}function be(n){return typeof n=="string"||h(n)&&ru.call(n)==G}function xe(n){return h(n)&&Sr(n.length)&&!!Sn[ru.call(n)]}function Ae(n,t){ +return nt||!n||!mu(t))return r;do t%2&&(r+=n),t=yu(t/2),n+=n;while(t);return r}function We(n,t,r){var e=n;return(n=u(n))?(r?Ur(e,t,r):null==t)?n.slice(g(n),y(n)+1):(t+="",n.slice(o(n,t),i(n,t)+1)):n}function $e(n,t,r){return r&&Ur(n,t,r)&&(t=w),n=u(n),n.match(t||Wn)||[]}function Se(n,t,r){return r&&Ur(n,t,r)&&(t=w),h(n)?Ne(n):ut(n,t)}function Fe(n){ +return n}function Ne(n){return bt(ot(n,true))}function Te(n,t,r){if(null==r){var e=ge(t),u=e?zo(t):w;((u=u&&u.length?gt(t,u):w)?u.length:e)||(u=false,r=t,t=n,n=this)}u||(u=gt(t,zo(t)));var o=true,e=-1,i=ve(n),f=u.length;false===r?o=false:ge(r)&&"chain"in r&&(o=r.chain);for(;++e=$)return r}else n=0;return Lu(r,e)}}(),Mu=le(function(n,t){ +return h(n)&&Er(n)?ft(n,pt(t,false,true)):[]}),qu=tr(),Pu=tr(true),Ku=le(function(n){for(var t=n.length,e=t,u=Be(l),o=xr(),i=o===r,f=[];e--;){var a=n[e]=Er(a=n[e])?a:[];u[e]=i&&120<=a.length&&gu&&lu?new Dn(e&&a):null}var i=n[0],c=-1,l=i?i.length:0,s=u[0];n:for(;++c(s?Mn(s,a):o(f,a,0))){for(e=t;--e;){var p=u[e];if(0>(p?Mn(p,a):o(n[e],a,0)))continue n}s&&s.push(a),f.push(a)}return f}),Vu=le(function(t,r){r=pt(r);var e=rt(t,r);return It(t,r.sort(n)),e}),Zu=vr(),Yu=vr(true),Gu=le(function(n){return St(pt(n,false,true)); +}),Ju=le(function(n,t){return Er(n)?ft(n,t):[]}),Xu=le(Jr),Hu=le(function(n){var t=n.length,r=2--n?t.apply(this,arguments):void 0}},Nn.ary=function(n,t,r){return r&&Ur(n,t,r)&&(t=w),t=n&&null==t?n.length:bu(+t||0,0),gr(n,E,w,w,w,w,t)},Nn.assign=Co,Nn.at=no,Nn.before=fe,Nn.bind=_o,Nn.bindAll=vo,Nn.bindKey=go,Nn.callback=Se,Nn.chain=Qr,Nn.chunk=function(n,t,r){t=(r?Ur(n,t,r):null==t)?1:bu(yu(t)||1,1),r=0;for(var e=n?n.length:0,u=-1,o=Be(vu(e/t));rr&&(r=-r>u?0:u+r),e=e===w||e>u?u:+e||0,0>e&&(e+=u),u=r>e?0:e>>>0,r>>>=0;rt?0:t)):[]},Nn.takeRight=function(n,t,r){var e=n?n.length:0;return e?((r?Ur(n,t,r):null==t)&&(t=1),t=e-(+t||0),Et(n,0>t?0:t)):[]},Nn.takeRightWhile=function(n,t,r){ +return n&&n.length?Nt(n,wr(t,r,3),false,true):[]},Nn.takeWhile=function(n,t,r){return n&&n.length?Nt(n,wr(t,r,3)):[]},Nn.tap=function(n,t,r){return t.call(r,n),n},Nn.throttle=function(n,t,r){var e=true,u=true;if(typeof n!="function")throw new Ge(L);return false===r?e=false:ge(r)&&(e="leading"in r?!!r.leading:e,u="trailing"in r?!!r.trailing:u),ae(n,t,{leading:e,maxWait:+t,trailing:u})},Nn.thru=ne,Nn.times=function(n,t,r){if(n=yu(n),1>n||!mu(n))return[];var e=-1,u=Be(xu(n,4294967295));for(t=Bt(t,r,1);++ee?u[e]=t(e):t(e); +return u},Nn.toArray=je,Nn.toPlainObject=ke,Nn.transform=function(n,t,r,e){var u=Oo(n)||xe(n);return t=wr(t,e,4),null==r&&(u||ge(n)?(e=n.constructor,r=u?Oo(n)?new e:[]:$u(ve(e)?e.prototype:w)):r={}),(u?Pn:_t)(n,function(n,e,u){return t(r,n,e,u)}),r},Nn.union=Gu,Nn.uniq=Gr,Nn.unzip=Jr,Nn.unzipWith=Xr,Nn.values=Ee,Nn.valuesIn=function(n){return Ft(n,Re(n))},Nn.where=function(n,t){return re(n,bt(t))},Nn.without=Ju,Nn.wrap=function(n,t){return t=null==t?Fe:t,gr(t,R,w,[n],[])},Nn.xor=function(){for(var n=-1,t=arguments.length;++nr?0:+r||0,e),r-=t.length,0<=r&&n.indexOf(t,r)==r},Nn.escape=function(n){return(n=u(n))&&hn.test(n)?n.replace(sn,c):n},Nn.escapeRegExp=function(n){return(n=u(n))&&bn.test(n)?n.replace(wn,l):n||"(?:)"},Nn.every=te,Nn.find=ro,Nn.findIndex=qu,Nn.findKey=$o,Nn.findLast=eo, +Nn.findLastIndex=Pu,Nn.findLastKey=So,Nn.findWhere=function(n,t){return ro(n,bt(t))},Nn.first=Kr,Nn.floor=ni,Nn.get=function(n,t,r){return n=null==n?w:yt(n,Dr(t),t+""),n===w?r:n},Nn.gt=se,Nn.gte=function(n,t){return n>=t},Nn.has=function(n,t){if(null==n)return false;var r=nu.call(n,t);if(!r&&!Wr(t)){if(t=Dr(t),n=1==t.length?n:yt(n,Et(t,0,-1)),null==n)return false;t=Zr(t),r=nu.call(n,t)}return r||Sr(n.length)&&Cr(t,n.length)&&(Oo(n)||pe(n))},Nn.identity=Fe,Nn.includes=ee,Nn.indexOf=Vr,Nn.inRange=function(n,t,r){ +return t=+t||0,r===w?(r=t,t=0):r=+r||0,n>=xu(t,r)&&nr?bu(e+r,0):xu(r||0,e-1))+1;else if(r)return u=Lt(n,t,true)-1,n=n[u],(t===t?t===n:n!==n)?u:-1; +if(t!==t)return p(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},Nn.lt=Ae,Nn.lte=function(n,t){return n<=t},Nn.max=ti,Nn.min=ri,Nn.noConflict=function(){return Zn._=eu,this},Nn.noop=Le,Nn.now=ho,Nn.pad=function(n,t,r){n=u(n),t=+t;var e=n.length;return er?0:+r||0,n.length),n.lastIndexOf(t,r)==r},Nn.sum=function(n,t,r){if(r&&Ur(n,t,r)&&(t=w),t=wr(t,r,3),1==t.length){n=Oo(n)?n:zr(n),r=n.length;for(var e=0;r--;)e+=+t(n[r])||0;n=e}else n=$t(n,t);return n},Nn.template=function(n,t,r){var e=Nn.templateSettings;r&&Ur(n,t,r)&&(t=r=w),n=u(n),t=nt(tt({},r||t),e,Qn),r=nt(tt({},t.imports),e.imports,Qn); +var o,i,f=zo(r),a=Ft(r,f),c=0;r=t.interpolate||Cn;var l="__p+='";r=Ze((t.escape||Cn).source+"|"+r.source+"|"+(r===gn?jn:Cn).source+"|"+(t.evaluate||Cn).source+"|$","g");var p="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";if(n.replace(r,function(t,r,e,u,f,a){return e||(e=u),l+=n.slice(c,a).replace(Un,s),r&&(o=true,l+="'+__e("+r+")+'"),f&&(i=true,l+="';"+f+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),c=a+t.length,t}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(i?l.replace(fn,""):l).replace(an,"$1").replace(cn,"$1;"), +l="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(o?",__e=_.escape":"")+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",t=Jo(function(){return qe(f,p+"return "+l).apply(w,a)}),t.source=l,_e(t))throw t;return t},Nn.trim=We,Nn.trimLeft=function(n,t,r){var e=n;return(n=u(n))?n.slice((r?Ur(e,t,r):null==t)?g(n):o(n,t+"")):n},Nn.trimRight=function(n,t,r){var e=n;return(n=u(n))?(r?Ur(e,t,r):null==t)?n.slice(0,y(n)+1):n.slice(0,i(n,t+"")+1):n; +},Nn.trunc=function(n,t,r){r&&Ur(n,t,r)&&(t=w);var e=U;if(r=W,null!=t)if(ge(t)){var o="separator"in t?t.separator:o,e="length"in t?+t.length||0:e;r="omission"in t?u(t.omission):r}else e=+t||0;if(n=u(n),e>=n.length)return n;if(e-=r.length,1>e)return r;if(t=n.slice(0,e),null==o)return t+r;if(we(o)){if(n.slice(e).search(o)){var i,f=n.slice(0,e);for(o.global||(o=Ze(o.source,(kn.exec(o)||"")+"g")),o.lastIndex=0;n=o.exec(f);)i=n.index;t=t.slice(0,null==i?e:i)}}else n.indexOf(o,e)!=e&&(o=t.lastIndexOf(o), +-1u.__dir__?"Right":"")}),u},zn.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()}}),Pn(["filter","map","takeWhile"],function(n,t){ +var r=t+1,e=r!=T;zn.prototype[n]=function(n,t){var u=this.clone();return u.__iteratees__.push({iteratee:wr(n,t,1),type:r}),u.__filtered__=u.__filtered__||e,u}}),Pn(["first","last"],function(n,t){var r="take"+(t?"Right":"");zn.prototype[n]=function(){return this[r](1).value()[0]}}),Pn(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right");zn.prototype[n]=function(){return this.__filtered__?new zn(this):this[r](1)}}),Pn(["pluck","where"],function(n,t){var r=t?"filter":"map",e=t?bt:ze;zn.prototype[n]=function(n){ +return this[r](e(n))}}),zn.prototype.compact=function(){return this.filter(Fe)},zn.prototype.reject=function(n,t){return n=wr(n,t,1),this.filter(function(t){return!n(t)})},zn.prototype.slice=function(n,t){n=null==n?0:+n||0;var r=this;return r.__filtered__&&(0t)?new zn(r):(0>n?r=r.takeRight(-n):n&&(r=r.drop(n)),t!==w&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r)},zn.prototype.takeRightWhile=function(n,t){return this.reverse().takeWhile(n,t).reverse()},zn.prototype.toArray=function(){return this.take(Ru); +},_t(zn.prototype,function(n,t){var r=/^(?:filter|map|reject)|While$/.test(t),e=/^(?:first|last)$/.test(t),u=Nn[e?"take"+("last"==t?"Right":""):t];u&&(Nn.prototype[t]=function(){function t(n){return e&&i?u(n,1)[0]:u.apply(w,Jn([n],o))}var o=e?[1]:arguments,i=this.__chain__,f=this.__wrapped__,a=!!this.__actions__.length,c=f instanceof zn,l=o[0],s=c||Oo(f);return s&&r&&typeof l=="function"&&1!=l.length&&(c=s=false),l={func:ne,args:[t],thisArg:w},a=c&&!a,e&&!i?a?(f=f.clone(),f.__actions__.push(l),n.call(f)):u.call(w,this.value())[0]:!e&&s?(f=a?f:new zn(this), +f=n.apply(f,o),f.__actions__.push(l),new Ln(f,i)):this.thru(t)})}),Pn("join pop push replace shift sort splice split unshift".split(" "),function(n){var t=(/^(?:replace|split)$/.test(n)?He:Je)[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|replace|shift)$/.test(n);Nn.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)})}}),_t(zn.prototype,function(n,t){var r=Nn[t];if(r){var e=r.name+"";(Wu[e]||(Wu[e]=[])).push({ +name:t,func:r})}}),Wu[sr(w,A).name]=[{name:"wrapper",func:w}],zn.prototype.clone=function(){var n=new zn(this.__wrapped__);return n.__actions__=qn(this.__actions__),n.__dir__=this.__dir__,n.__filtered__=this.__filtered__,n.__iteratees__=qn(this.__iteratees__),n.__takeCount__=this.__takeCount__,n.__views__=qn(this.__views__),n},zn.prototype.reverse=function(){if(this.__filtered__){var n=new zn(this);n.__dir__=-1,n.__filtered__=true}else n=this.clone(),n.__dir__*=-1;return n},zn.prototype.value=function(){ +var n,t=this.__wrapped__.value(),r=this.__dir__,e=Oo(t),u=0>r,o=e?t.length:0;n=o;for(var i=this.__views__,f=0,a=-1,c=i.length;++a"'`]/g,pn=RegExp(ln.source),hn=RegExp(sn.source),_n=/<%-([\s\S]+?)%>/g,vn=/<%([\s\S]+?)%>/g,gn=/<%=([\s\S]+?)%>/g,yn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,dn=/^\w*$/,mn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,wn=/^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g,bn=RegExp(wn.source),xn=/[\u0300-\u036f\ufe20-\ufe23]/g,An=/\\(\\)?/g,jn=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,kn=/\w*$/,In=/^0[xX]/,Rn=/^\[object .+?Constructor\]$/,On=/^\d+$/,En=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,Cn=/($^)/,Un=/['\n\r\u2028\u2029\\]/g,Wn=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]+(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),$n="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout isFinite parseFloat parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap".split(" "),Sn={}; +Sn[X]=Sn[H]=Sn[Q]=Sn[nn]=Sn[tn]=Sn[rn]=Sn[en]=Sn[un]=Sn[on]=true,Sn[B]=Sn[D]=Sn[J]=Sn[M]=Sn[q]=Sn[P]=Sn[K]=Sn["[object Map]"]=Sn[V]=Sn[Z]=Sn[Y]=Sn["[object Set]"]=Sn[G]=Sn["[object WeakMap]"]=false;var Fn={};Fn[B]=Fn[D]=Fn[J]=Fn[M]=Fn[q]=Fn[X]=Fn[H]=Fn[Q]=Fn[nn]=Fn[tn]=Fn[V]=Fn[Z]=Fn[Y]=Fn[G]=Fn[rn]=Fn[en]=Fn[un]=Fn[on]=true,Fn[P]=Fn[K]=Fn["[object Map]"]=Fn["[object Set]"]=Fn["[object WeakMap]"]=false;var Nn={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a", +"\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y", +"\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss"},Tn={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Ln={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},zn={"function":true,object:true},Bn={0:"x30",1:"x31",2:"x32",3:"x33",4:"x34",5:"x35",6:"x36",7:"x37",8:"x38",9:"x39",A:"x41",B:"x42",C:"x43",D:"x44",E:"x45",F:"x46",a:"x61",b:"x62",c:"x63",d:"x64",e:"x65",f:"x66",n:"x6e",r:"x72",t:"x74",u:"x75",v:"x76",x:"x78"},Dn={"\\":"\\", +"'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Mn=zn[typeof exports]&&exports&&!exports.nodeType&&exports,qn=zn[typeof module]&&module&&!module.nodeType&&module,Pn=zn[typeof self]&&self&&self.Object&&self,Kn=zn[typeof window]&&window&&window.Object&&window,Vn=qn&&qn.exports===Mn&&Mn,Zn=Mn&&qn&&typeof global=="object"&&global&&global.Object&&global||Kn!==(this&&this.window)&&Kn||Pn||this,Yn=m();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Zn._=Yn, define(function(){ +return Yn})):Mn&&qn?Vn?(qn.exports=Yn)._=Yn:Mn._=Yn:Zn._=Yn}).call(this); \ No newline at end of file diff --git a/schedoscope-metascope/src/main/resources/templates/includes/head.html b/schedoscope-metascope/src/main/resources/templates/includes/head.html index e0767d7e5..434a1def5 100644 --- a/schedoscope-metascope/src/main/resources/templates/includes/head.html +++ b/schedoscope-metascope/src/main/resources/templates/includes/head.html @@ -29,5 +29,11 @@ + + + + + + \ No newline at end of file From e1c8a8b8e0059d449a33f637ecc21769f542e29b Mon Sep 17 00:00:00 2001 From: Jan Hicken Date: Mon, 12 Jun 2017 17:39:45 +0200 Subject: [PATCH 07/24] Add missing lineage graph button in fields table. --- .../resources/templates/body/table/sections/fields.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/schedoscope-metascope/src/main/resources/templates/body/table/sections/fields.html b/schedoscope-metascope/src/main/resources/templates/body/table/sections/fields.html index 189c48a90..197c48db9 100644 --- a/schedoscope-metascope/src/main/resources/templates/body/table/sections/fields.html +++ b/schedoscope-metascope/src/main/resources/templates/body/table/sections/fields.html @@ -79,6 +79,13 @@ +
+
+ + +
+
+
From df1ac792ae934803851271fd63041cc496684bae Mon Sep 17 00:00:00 2001 From: Jan Hicken Date: Mon, 12 Jun 2017 17:44:52 +0200 Subject: [PATCH 08/24] Save the corresponding MetascopeTable in MetascopeField. --- .../java/org/schedoscope/metascope/task/SchedoscopeTask.java | 1 + 1 file changed, 1 insertion(+) diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java index abc4c0aa5..742aca5d3 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java @@ -164,6 +164,7 @@ public boolean run(long start) { field.setFieldOrder(i++); field.setParameter(false); field.setDescription(viewField.getComment()); + field.setTable(table); //lineage if (view.getLineage() != null && view.getLineage().get(fieldFqdn) != null) { From 2245feadf85f3aaa56fc453fe762e353b7f15cb8 Mon Sep 17 00:00:00 2001 From: Jan Hicken Date: Tue, 13 Jun 2017 10:17:08 +0200 Subject: [PATCH 09/24] Revert "Save the corresponding MetascopeTable in MetascopeField." This reverts commit df1ac792ae934803851271fd63041cc496684bae. --- .../java/org/schedoscope/metascope/task/SchedoscopeTask.java | 1 - 1 file changed, 1 deletion(-) diff --git a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java index a938b5508..64d7cd118 100644 --- a/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java +++ b/schedoscope-metascope/src/main/java/org/schedoscope/metascope/task/SchedoscopeTask.java @@ -161,7 +161,6 @@ public boolean run(long start) { field.setFieldOrder(i++); field.setParameter(false); field.setDescription(viewField.getComment()); - field.setTable(table); //lineage if (view.getLineage() != null && view.getLineage().get(fieldFqdn) != null) { From 2df02eabe6c428311704ef4945bbec7f83bed0b9 Mon Sep 17 00:00:00 2001 From: Jan Hicken Date: Tue, 13 Jun 2017 12:46:46 +0200 Subject: [PATCH 10/24] Filter out Parameters in lineage REST service, fix FieldLike.toString to use snake case. --- .../src/main/scala/org/schedoscope/dsl/FieldLike.scala | 4 ++-- .../scheduler/service/SchedoscopeServiceImpl.scala | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/schedoscope-core/src/main/scala/org/schedoscope/dsl/FieldLike.scala b/schedoscope-core/src/main/scala/org/schedoscope/dsl/FieldLike.scala index 01405c62c..600730dae 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/dsl/FieldLike.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/dsl/FieldLike.scala @@ -66,7 +66,7 @@ abstract class FieldLike[T: Manifest] extends Named { } override def toString: String = assignedStructure match { - case Some(view: View) => s"${view.tableName}.${view.nameOf(this).getOrElse("")}" - case _ => namingBase + case Some(view: View) => s"${view.tableName}.$n}" + case _ => n } } \ No newline at end of file diff --git a/schedoscope-core/src/main/scala/org/schedoscope/scheduler/service/SchedoscopeServiceImpl.scala b/schedoscope-core/src/main/scala/org/schedoscope/scheduler/service/SchedoscopeServiceImpl.scala index 2415e20d0..1d97c9690 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/scheduler/service/SchedoscopeServiceImpl.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/scheduler/service/SchedoscopeServiceImpl.scala @@ -22,7 +22,7 @@ import akka.event.Logging import org.joda.time.format.DateTimeFormat import org.schedoscope.AskPattern._ import org.schedoscope.conf.SchedoscopeSettings -import org.schedoscope.dsl.View +import org.schedoscope.dsl.{Field, View} import org.schedoscope.dsl.transformations._ import org.schedoscope.scheduler.actors.ViewManagerActor import org.schedoscope.scheduler.driver.{DriverRunFailed, DriverRunOngoing, DriverRunState, DriverRunSucceeded} @@ -142,7 +142,7 @@ class SchedoscopeServiceImpl(actorSystem: ActorSystem, settings: SchedoscopeSett Some(vsr.view.dependencies.map(d => (d.tableName, d.urlPath)).groupBy(_._1).mapValues(_.toList.map(_._2))) else None, - lineage = if (overview) None else Some(vsr.view.lineage.map { case (f, deps) => f.toString -> deps.map(_.toString).toList }), + lineage = if (overview) None else Some(vsr.view.lineage.filter(_._1.isInstanceOf[Field[_]]).map { case (f, deps) => f.toString -> deps.map(_.toString).toList }), transformation = if (overview) None else Option(vsr.view.registeredTransformation().viewTransformationStatus), export = if (overview) None else Option(viewExportStatus(vsr.view.registeredExports.map(e => e.apply()))), storageFormat = if (overview) None else Option(vsr.view.storageFormat.getClass.getSimpleName), From 1921869495cfa8cdfe3a79188d3652163ab85aa3 Mon Sep 17 00:00:00 2001 From: Jan Hicken Date: Tue, 13 Jun 2017 13:00:11 +0200 Subject: [PATCH 11/24] Stupid cunt. --- .../src/main/scala/org/schedoscope/dsl/FieldLike.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schedoscope-core/src/main/scala/org/schedoscope/dsl/FieldLike.scala b/schedoscope-core/src/main/scala/org/schedoscope/dsl/FieldLike.scala index 600730dae..1c693adcf 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/dsl/FieldLike.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/dsl/FieldLike.scala @@ -66,7 +66,7 @@ abstract class FieldLike[T: Manifest] extends Named { } override def toString: String = assignedStructure match { - case Some(view: View) => s"${view.tableName}.$n}" + case Some(view: View) => s"${view.tableName}.$n" case _ => n } } \ No newline at end of file From 92b3949e716a353dbd80f7948c6f9b2acd4477dd Mon Sep 17 00:00:00 2001 From: Jan Hicken Date: Wed, 14 Jun 2017 10:11:08 +0200 Subject: [PATCH 12/24] Remove Parameter.toString override implementation --- .../src/main/scala/org/schedoscope/dsl/Parameter.scala | 2 -- 1 file changed, 2 deletions(-) diff --git a/schedoscope-core/src/main/scala/org/schedoscope/dsl/Parameter.scala b/schedoscope-core/src/main/scala/org/schedoscope/dsl/Parameter.scala index 150ce69c1..1f5652045 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/dsl/Parameter.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/dsl/Parameter.scala @@ -38,8 +38,6 @@ case class Parameter[T: Manifest](orderWeight: Long) extends FieldLike[T] { override def hashCode(): Int = { t.hashCode + 7 * v.hashCode() } - - override def toString() = if (v.isDefined) s"Parameter(${v.get})" else super.toString } /** From 66b4eff0f881f8adccd876eaea27a3be90b10fc8 Mon Sep 17 00:00:00 2001 From: Jan Hicken Date: Wed, 14 Jun 2017 11:16:53 +0200 Subject: [PATCH 13/24] Initialize explicit lineage with parameters, too. --- schedoscope-core/src/main/scala/org/schedoscope/dsl/View.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schedoscope-core/src/main/scala/org/schedoscope/dsl/View.scala b/schedoscope-core/src/main/scala/org/schedoscope/dsl/View.scala index 7905da747..3d3ebf7e4 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/dsl/View.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/dsl/View.scala @@ -394,7 +394,7 @@ abstract class View extends Structure with ViewDsl with DelayedInit { case (influencer, influencee) => val ownerView: View = influencee.assignedStructure.get.asInstanceOf[View] if (ownerView.explicitLineage.isEmpty) - ownerView.explicitLineage = ownerView.fields.map(f => f -> mutable.Set[FieldLike[_]]()).toMap + ownerView.explicitLineage = ownerView.fieldsAndParameters.map(f => f -> mutable.Set[FieldLike[_]]()).toMap ownerView.explicitLineage(influencee).add(influencer) } From 5436c4535306117c6a4642ab9be46f650e673d31 Mon Sep 17 00:00:00 2001 From: Jan Hicken Date: Wed, 14 Jun 2017 13:53:59 +0200 Subject: [PATCH 14/24] Switch direction and naming of schema lineage overview. --- .../src/main/resources/static/css/lineage.css | 2 +- .../main/resources/templates/body/schemaLineage.html | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/schedoscope-metascope/src/main/resources/static/css/lineage.css b/schedoscope-metascope/src/main/resources/static/css/lineage.css index c0f2d8c97..fd863e41e 100644 --- a/schedoscope-metascope/src/main/resources/static/css/lineage.css +++ b/schedoscope-metascope/src/main/resources/static/css/lineage.css @@ -1,4 +1,4 @@ -#forward-lineage-container + #backward-lineage-container { +#backward-lineage-container + #forward-lineage-container { box-sizing: border-box; border-left: 1px solid black; } diff --git a/schedoscope-metascope/src/main/resources/templates/body/schemaLineage.html b/schedoscope-metascope/src/main/resources/templates/body/schemaLineage.html index 1e9847361..80847095c 100644 --- a/schedoscope-metascope/src/main/resources/templates/body/schemaLineage.html +++ b/schedoscope-metascope/src/main/resources/templates/body/schemaLineage.html @@ -23,11 +23,11 @@
-
-

Influences

-
-

Dependencies

+

← depends on ←

+
+
+

→ influences →

@@ -39,8 +39,8 @@

Dependencies

(function () { document.addEventListener("DOMContentLoaded", function () { var lineage = /*[[${lineage}]]*/ null; - new LineageGraph("#forward-lineage-container", "RL").setData(lineage["forwardEdges"]); - new LineageGraph("#backward-lineage-container", "LR").setData(lineage["backwardEdges"]); + new LineageGraph("#forward-lineage-container", "LR").setData(lineage["forwardEdges"]); + new LineageGraph("#backward-lineage-container", "RL").setData(lineage["backwardEdges"]); }); })(); /*]]>*/ From 8c3a98dfea78ed29f0619134089f59edce1cb45a Mon Sep 17 00:00:00 2001 From: Jan Hicken Date: Wed, 14 Jun 2017 14:54:49 +0200 Subject: [PATCH 15/24] Add isExternal JSON property to fix test spec. --- .../SchedoscopeServiceRestClientImplSpec.scala | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/schedoscope-core/src/test/scala/org/schedoscope/scheduler/rest/client/SchedoscopeServiceRestClientImplSpec.scala b/schedoscope-core/src/test/scala/org/schedoscope/scheduler/rest/client/SchedoscopeServiceRestClientImplSpec.scala index a5b7c2f9a..482976a0e 100644 --- a/schedoscope-core/src/test/scala/org/schedoscope/scheduler/rest/client/SchedoscopeServiceRestClientImplSpec.scala +++ b/schedoscope-core/src/test/scala/org/schedoscope/scheduler/rest/client/SchedoscopeServiceRestClientImplSpec.scala @@ -61,6 +61,7 @@ class SchedoscopeServiceRestClientImplSpec extends FlatSpecLike "views": [ { "viewPath": "${pakkage}/ProductBrand/${shop01}/${year}/${month}/${day}/${year}${month}${day}", + "isExternal": false, "status": "receive" } ] @@ -81,6 +82,7 @@ class SchedoscopeServiceRestClientImplSpec extends FlatSpecLike response.isCompleted shouldBe true response.value.get.get.overview shouldBe Map(("receive", 1)) response.value.get.get.views.size shouldBe 1 + response.value.get.get.views.head.isExternal shouldBe false response.value.get.get.views(0).status shouldBe "receive" response.value.get.get.views(0).viewPath shouldBe prodBrandUrl01 + s"/${year}${month}${day}" response.value.get.get.views(0).dependencies shouldBe None @@ -98,14 +100,17 @@ class SchedoscopeServiceRestClientImplSpec extends FlatSpecLike "views": [ { "viewPath": "${pakkage}/Brand/${shop01}", + "isExternal": true, "status": "materializing" }, { "viewPath": "${pakkage}/Product/${shop01}/${year}/${month}/${day}/${year}${month}${day}", + "isExternal": false, "status": "materializing" }, { "viewPath": "${pakkage}/ProductBrand/${shop01}/${year}/${month}/${day}/${year}${month}${day}", + "isExternal": false, "status": "waiting", "dependencies": { "dev_test_views.brand_${shop01.toLowerCase}" : ["${brandUrl01}"], @@ -131,6 +136,10 @@ class SchedoscopeServiceRestClientImplSpec extends FlatSpecLike response.value.get.get.overview shouldBe Map(("waiting", 1), ("materializing", 2)) response.value.get.get.views.size shouldBe 3 + response.value.get.get.views(0).isExternal shouldBe true + response.value.get.get.views(1).isExternal shouldBe false + response.value.get.get.views(2).isExternal shouldBe false + response.value.get.get.views(0).status shouldBe "materializing" response.value.get.get.views(1).status shouldBe "materializing" response.value.get.get.views(2).status shouldBe "waiting" @@ -158,6 +167,7 @@ class SchedoscopeServiceRestClientImplSpec extends FlatSpecLike "views": [ { "viewPath": "${pakkage}/ProductBrand/${shop01}/${year}/${month}/${day}/${year}${month}${day}", + "isExternal": false, "status": "receive" } ] @@ -174,6 +184,7 @@ class SchedoscopeServiceRestClientImplSpec extends FlatSpecLike response.isCompleted shouldBe true response.value.get.get.overview shouldBe Map(("receive", 1)) response.value.get.get.views.size shouldBe 1 + response.value.get.get.views.head.isExternal shouldBe false response.value.get.get.views(0).status shouldBe "receive" response.value.get.get.views(0).viewPath shouldBe prodBrandUrl01 + s"/${year}${month}${day}" response.value.get.get.views(0).dependencies shouldBe None @@ -190,6 +201,7 @@ class SchedoscopeServiceRestClientImplSpec extends FlatSpecLike "views": [ { "viewPath": "${pakkage}/ProductBrand/${shop01}/${year}/${month}/${day}/${year}${month}${day}", + "isExternal": false, "status": "receive" } ] @@ -208,6 +220,7 @@ class SchedoscopeServiceRestClientImplSpec extends FlatSpecLike response.isCompleted shouldBe true response.value.get.get.overview shouldBe Map(("receive", 1)) response.value.get.get.views.size shouldBe 1 + response.value.get.get.views.head.isExternal shouldBe false response.value.get.get.views(0).status shouldBe "receive" response.value.get.get.views(0).viewPath shouldBe prodBrandUrl01 + s"/${year}${month}${day}" response.value.get.get.views(0).dependencies shouldBe None @@ -224,6 +237,7 @@ class SchedoscopeServiceRestClientImplSpec extends FlatSpecLike "views": [ { "viewPath": "${pakkage}/ProductBrand/${shop01}/${year}/${month}/${day}/${year}${month}${day}", + "isExternal": false, "status": "invalid" } ] @@ -241,6 +255,7 @@ class SchedoscopeServiceRestClientImplSpec extends FlatSpecLike response.isCompleted shouldBe true response.value.get.get.overview shouldBe Map(("invalid", 1)) response.value.get.get.views.size shouldBe 1 + response.value.get.get.views.head.isExternal shouldBe false response.value.get.get.views(0).status shouldBe "invalid" response.value.get.get.views(0).viewPath shouldBe prodBrandUrl01 + s"/${year}${month}${day}" response.value.get.get.views(0).dependencies shouldBe None From cf30465e0f1372be813ca47ced47d200ec6c4711 Mon Sep 17 00:00:00 2001 From: Jan Hicken Date: Wed, 14 Jun 2017 16:02:52 +0200 Subject: [PATCH 16/24] Register view before using it in affects() --- schedoscope-core/src/main/scala/org/schedoscope/dsl/View.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schedoscope-core/src/main/scala/org/schedoscope/dsl/View.scala b/schedoscope-core/src/main/scala/org/schedoscope/dsl/View.scala index 3d3ebf7e4..2d8a0c42e 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/dsl/View.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/dsl/View.scala @@ -392,7 +392,7 @@ abstract class View extends Structure with ViewDsl with DelayedInit { def affects(influenceFunc: this.type => Traversable[(FieldLike[_], FieldLike[_])]): this.type = { influenceFunc(this).foreach { case (influencer, influencee) => - val ownerView: View = influencee.assignedStructure.get.asInstanceOf[View] + val ownerView: View = View.register(env, influencee.assignedStructure.get.asInstanceOf[View]) if (ownerView.explicitLineage.isEmpty) ownerView.explicitLineage = ownerView.fieldsAndParameters.map(f => f -> mutable.Set[FieldLike[_]]()).toMap From 552243d4db1a5f9bc0cc0d8bb78e0cebf2e89776 Mon Sep 17 00:00:00 2001 From: Jan Hicken Date: Wed, 14 Jun 2017 18:21:10 +0200 Subject: [PATCH 17/24] Revert "Register view before using it in affects()" This reverts commit cf30465e0f1372be813ca47ced47d200ec6c4711. --- schedoscope-core/src/main/scala/org/schedoscope/dsl/View.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schedoscope-core/src/main/scala/org/schedoscope/dsl/View.scala b/schedoscope-core/src/main/scala/org/schedoscope/dsl/View.scala index 2d8a0c42e..3d3ebf7e4 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/dsl/View.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/dsl/View.scala @@ -392,7 +392,7 @@ abstract class View extends Structure with ViewDsl with DelayedInit { def affects(influenceFunc: this.type => Traversable[(FieldLike[_], FieldLike[_])]): this.type = { influenceFunc(this).foreach { case (influencer, influencee) => - val ownerView: View = View.register(env, influencee.assignedStructure.get.asInstanceOf[View]) + val ownerView: View = influencee.assignedStructure.get.asInstanceOf[View] if (ownerView.explicitLineage.isEmpty) ownerView.explicitLineage = ownerView.fieldsAndParameters.map(f => f -> mutable.Set[FieldLike[_]]()).toMap From d3d6c654311a5313b39c2c4c838acb2a079734fd Mon Sep 17 00:00:00 2001 From: Jan Hicken Date: Wed, 14 Jun 2017 18:30:04 +0200 Subject: [PATCH 18/24] Keep a parameter's assigned structure when creating a new instance. --- .../src/main/scala/org/schedoscope/dsl/Parameter.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/schedoscope-core/src/main/scala/org/schedoscope/dsl/Parameter.scala b/schedoscope-core/src/main/scala/org/schedoscope/dsl/Parameter.scala index 1f5652045..f9ea3ce51 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/dsl/Parameter.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/dsl/Parameter.scala @@ -76,5 +76,9 @@ object Parameter { * Create a parameter out of an existing parameter, thereby assigning it a new order weight. When passing parameters * between views, they should be wrapped using this method to ensure correct parameter ordering. */ - def p[T: Manifest](v: Parameter[T]): Parameter[T] = p(v.v.get) + def p[T: Manifest](v: Parameter[T]): Parameter[T] = { + val tmp = p(v.v.get) + if (v.assignedStructure.isDefined) tmp.assignTo(v.assignedStructure.get) + tmp + } } \ No newline at end of file From 241869bbd24849d9716f6e03bf4ac17330c030f5 Mon Sep 17 00:00:00 2001 From: Jan Hicken Date: Wed, 14 Jun 2017 18:35:07 +0200 Subject: [PATCH 19/24] Revert "Keep a parameter's assigned structure when creating a new instance." This reverts commit d3d6c654311a5313b39c2c4c838acb2a079734fd. --- .../src/main/scala/org/schedoscope/dsl/Parameter.scala | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/schedoscope-core/src/main/scala/org/schedoscope/dsl/Parameter.scala b/schedoscope-core/src/main/scala/org/schedoscope/dsl/Parameter.scala index f9ea3ce51..1f5652045 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/dsl/Parameter.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/dsl/Parameter.scala @@ -76,9 +76,5 @@ object Parameter { * Create a parameter out of an existing parameter, thereby assigning it a new order weight. When passing parameters * between views, they should be wrapped using this method to ensure correct parameter ordering. */ - def p[T: Manifest](v: Parameter[T]): Parameter[T] = { - val tmp = p(v.v.get) - if (v.assignedStructure.isDefined) tmp.assignTo(v.assignedStructure.get) - tmp - } + def p[T: Manifest](v: Parameter[T]): Parameter[T] = p(v.v.get) } \ No newline at end of file From bd363f0f892b48523b5919a45b9ebe9999edf173 Mon Sep 17 00:00:00 2001 From: Jan Hicken Date: Wed, 14 Jun 2017 19:51:33 +0200 Subject: [PATCH 20/24] Do not let views have an environment other than the one defined in the settings --- .../org/schedoscope/dsl/ExternalView.scala | 8 ---- .../main/scala/org/schedoscope/dsl/View.scala | 45 +++++++------------ .../schedoscope/dsl/views/ViewUrlParser.scala | 8 ++-- .../service/SchedoscopeServiceImpl.scala | 2 +- .../schedoscope/schema/SchemaManager.scala | 3 +- .../org/schedoscope/test/WritableView.scala | 3 +- .../scala/org/schedoscope/dsl/DslTest.scala | 13 +++--- .../dsl/transformations/ExportTest.scala | 2 +- .../dsl/views/ViewUrlParserTest.scala | 25 ++++------- .../schedoscope/test/TestableViewTest.scala | 10 ----- 10 files changed, 37 insertions(+), 82 deletions(-) diff --git a/schedoscope-core/src/main/scala/org/schedoscope/dsl/ExternalView.scala b/schedoscope-core/src/main/scala/org/schedoscope/dsl/ExternalView.scala index fc5654225..20aa1a1a4 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/dsl/ExternalView.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/dsl/ExternalView.scala @@ -34,14 +34,6 @@ case class ExternalView(view: View) extends View { override val isExternal = true - // - // Pass env through to wrapped view - // - override def env_=(env: String): Unit = { - super.env_=(env) - view.env = env - } - // // Give us a string representation clearly showing this is an external view // diff --git a/schedoscope-core/src/main/scala/org/schedoscope/dsl/View.scala b/schedoscope-core/src/main/scala/org/schedoscope/dsl/View.scala index 3d3ebf7e4..6a49e6471 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/dsl/View.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/dsl/View.scala @@ -103,13 +103,7 @@ abstract class View extends Structure with ViewDsl with DelayedInit { /** * The view's environment. */ - private var _env: String = "dev" - - def env: String = _env - - def env_=(env: String): Unit = { - _env = env - } + def env = Schedoscope.settings.env var storageFormat: StorageFormat = TextFile() var additionalStoragePathPrefix: Option[String] = None @@ -238,7 +232,7 @@ abstract class View extends Structure with ViewDsl with DelayedInit { * current view depends on. This function is returned so that it can be assigned to variables for further reference. */ override def dependsOn[V <: View : Manifest](df: () => V) = { - val dsf = () => List(View.register(this.env, df())) + val dsf = () => List(View.register(df())) dependsOn(dsf) @@ -250,9 +244,7 @@ abstract class View extends Structure with ViewDsl with DelayedInit { * current view depends on. */ override def dependsOn[V <: View : Manifest](dsf: () => Seq[V]) { - val df = () => dsf().map { - View.register(this.env, _) - } + val df = () => dsf().map (View.register[V]) deferredDependencies += df } @@ -468,19 +460,19 @@ object View { } /** - * Instantiate views given an environment and view URL path. A parsed view augmentor can further modify the created views. + * Instantiate views given a view URL path. A parsed view augmentor can further modify the created views. */ - def viewsFromUrl(env: String, viewUrlPath: String, parsedViewAugmentor: ParsedViewAugmentor = new ParsedViewAugmentor() {}): List[View] = + def viewsFromUrl(viewUrlPath: String, parsedViewAugmentor: ParsedViewAugmentor = new ParsedViewAugmentor() {}): List[View] = try { ViewUrlParser - .parse(env, viewUrlPath) + .parse(viewUrlPath) .map { parsedViewAugmentor.augment(_) } .filter { _ != null } - .map { case ParsedView(env, viewClass, parameters) => newView(viewClass, env, parameters: _*) } + .map { case ParsedView(viewClass, parameters) => newView(viewClass, parameters: _*) } } catch { case t: Throwable => if (t.isInstanceOf[java.lang.reflect.InvocationTargetException]) { @@ -491,9 +483,9 @@ object View { } /** - * Instantiate a new view given its class name, an environment, and a list of parameter values. + * Instantiate a new view given its class name and a list of parameter values. */ - def newView[V <: View : Manifest](viewClass: Class[V], env: String, parameterValues: TypedAny*): V = { + def newView[V <: View : Manifest](viewClass: Class[V], parameterValues: TypedAny*): V = { val viewCompanionObjectClass = Class.forName(viewClass.getName() + "$") val viewCompanionConstructor = viewCompanionObjectClass.getDeclaredConstructor() viewCompanionConstructor.setAccessible(true) @@ -535,21 +527,14 @@ object View { parametersToPass += passedValueForParameter.v } - register(env, viewConstructor.invoke(viewCompanionObject, parametersToPass.asInstanceOf[Seq[Object]]: _*).asInstanceOf[V]) + register(viewConstructor.invoke(viewCompanionObject, parametersToPass.asInstanceOf[Seq[Object]]: _*).asInstanceOf[V]) } - private def register[V <: View : Manifest](env: String, v: V): V = this.synchronized { - val registeredView = knownViews.get(v.urlPath) match { - case Some(registeredView) => { - registeredView.asInstanceOf[V] - } - case None => { - knownViews.put(v.urlPath, v) - v - } - } - registeredView.env = env - registeredView + private def register[V <: View : Manifest](v: V): V = this.synchronized { + if (!knownViews.contains(v.urlPath)) + knownViews.put(v.urlPath, v) + + knownViews(v.urlPath).asInstanceOf[V] } private def recursiveDependenciesOf(view: View, soFar: mutable.Set[View] = mutable.Set[View]()): mutable.Set[View] = { diff --git a/schedoscope-core/src/main/scala/org/schedoscope/dsl/views/ViewUrlParser.scala b/schedoscope-core/src/main/scala/org/schedoscope/dsl/views/ViewUrlParser.scala index f8529571e..b7f392781 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/dsl/views/ViewUrlParser.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/dsl/views/ViewUrlParser.scala @@ -28,7 +28,7 @@ class NoAugmentation extends ViewUrlParser.ParsedViewAugmentor object ViewUrlParser { - case class ParsedView(env: String, viewClass: Class[View], parameters: List[TypedAny]) + case class ParsedView(viewClass: Class[View], parameters: List[TypedAny]) trait ParsedViewAugmentor { def augment(pv: ParsedView): ParsedView = pv @@ -132,7 +132,7 @@ object ViewUrlParser { case cnf: ClassNotFoundException => throw new IllegalArgumentException("No class for package and view: " + cnf.getMessage()) } - def parse(env: String, viewUrlPath: String): List[ParsedView] = try { + def parse(viewUrlPath: String): List[ParsedView] = try { val normalizedPathFront = if (viewUrlPath.startsWith("/")) viewUrlPath.tail else @@ -154,7 +154,7 @@ object ViewUrlParser { for { viewClass <- parseViewClassnames(packageName, viewClassNames) pl <- parseParameters(parameters) - } yield ParsedView(env, viewClass, pl) + } yield ParsedView(viewClass, pl) } catch { @@ -196,5 +196,5 @@ Quoting: """) } - def viewNames(viewUrlPath: String) = parse("dev", viewUrlPath).map(pv => pv.viewClass.getName) + def viewNames(viewUrlPath: String) = parse(viewUrlPath).map(pv => pv.viewClass.getName) } \ No newline at end of file diff --git a/schedoscope-core/src/main/scala/org/schedoscope/scheduler/service/SchedoscopeServiceImpl.scala b/schedoscope-core/src/main/scala/org/schedoscope/scheduler/service/SchedoscopeServiceImpl.scala index 1d97c9690..9cd3e2ac7 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/scheduler/service/SchedoscopeServiceImpl.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/scheduler/service/SchedoscopeServiceImpl.scala @@ -74,7 +74,7 @@ class SchedoscopeServiceImpl(actorSystem: ActorSystem, settings: SchedoscopeSett } private def viewsFromUrl(viewUrlPath: String) = - View.viewsFromUrl(settings.env, viewUrlPath, settings.viewAugmentor) + View.viewsFromUrl(viewUrlPath, settings.viewAugmentor) private def parseQueueElements(q: List[AnyRef]): List[RunStatus] = q.map { diff --git a/schedoscope-core/src/main/scala/org/schedoscope/schema/SchemaManager.scala b/schedoscope-core/src/main/scala/org/schedoscope/schema/SchemaManager.scala index be59e6799..e1f91345f 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/schema/SchemaManager.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/schema/SchemaManager.scala @@ -322,8 +322,7 @@ class SchemaManager(val metastoreClient: IMetaStoreClient, val connection: Conne private def partitionToView(tablePrototype: View, p: Partition) = { val viewUrl = s"${tablePrototype.urlPathPrefix}/${p.getValues.mkString("/")}" - View.viewsFromUrl(settings.env, - viewUrl, + View.viewsFromUrl(viewUrl, settings.viewAugmentor).head } diff --git a/schedoscope-core/src/main/scala/org/schedoscope/test/WritableView.scala b/schedoscope-core/src/main/scala/org/schedoscope/test/WritableView.scala index 903edcccc..2f9570301 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/test/WritableView.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/test/WritableView.scala @@ -19,6 +19,7 @@ import java.io.OutputStreamWriter import java.net.URI import org.apache.hadoop.fs.Path +import org.schedoscope.Schedoscope import org.schedoscope.dsl.{FieldLike, Named, View} import org.schedoscope.test.resources.{LocalTestResources, TestResources} @@ -30,8 +31,6 @@ import scala.collection.mutable.ListBuffer */ trait WritableView extends View { - env = "test" - val isStatic = false var resources: TestResources = new LocalTestResources() diff --git a/schedoscope-core/src/test/scala/org/schedoscope/dsl/DslTest.scala b/schedoscope-core/src/test/scala/org/schedoscope/dsl/DslTest.scala index 917d852d8..da1b1212c 100644 --- a/schedoscope-core/src/test/scala/org/schedoscope/dsl/DslTest.scala +++ b/schedoscope-core/src/test/scala/org/schedoscope/dsl/DslTest.scala @@ -246,11 +246,9 @@ class DslTest extends FlatSpec with Matchers { it should "be transformable into DDL for an env" in { val productBrand = ProductBrand(p("ec0106"), p("2014"), p("01"), p("01")) - productBrand.env = "prod" - val ddlStatement = ddl(productBrand) - ddlStatement.contains("CREATE EXTERNAL TABLE IF NOT EXISTS prod_test_views.product_brand (") shouldBe true + ddlStatement.contains("CREATE EXTERNAL TABLE IF NOT EXISTS dev_test_views.product_brand (") shouldBe true ddlStatement.contains("occurred_at STRING,") shouldBe true ddlStatement.contains("product_id STRING,") shouldBe true ddlStatement.contains("brand_name STRING,") shouldBe true @@ -260,13 +258,12 @@ class DslTest extends FlatSpec with Matchers { ddlStatement.contains("COMMENT 'ProductBrand joins brands with products'") shouldBe true ddlStatement.contains("PARTITIONED BY (shop_code STRING, year STRING, month STRING, day STRING, date_id STRING)") shouldBe true ddlStatement.contains("STORED AS PARQUET") shouldBe true - ddlStatement.contains("LOCATION '/hdp/prod/test/views/product_brand'") shouldBe true + ddlStatement.contains("LOCATION '/hdp/dev/test/views/product_brand'") shouldBe true } it should "inherit its env to its dependencies" in { val productBrand = ProductBrand(p("ec0106"), p("2014"), p("01"), p("01")) - productBrand.env = "prod" for (d <- productBrand.dependencies) { d.env shouldEqual productBrand.env @@ -344,7 +341,7 @@ class DslTest extends FlatSpec with Matchers { } it should "be dynamically instantiatable via URL path" in { - val views = View.viewsFromUrl("dev", "/test.views/Product/e(EC0106,EC0101)/rymd(20140224-20131202)/") + val views = View.viewsFromUrl("/test.views/Product/e(EC0106,EC0101)/rymd(20140224-20131202)/") views.length shouldBe 2 * 85 @@ -360,12 +357,12 @@ class DslTest extends FlatSpec with Matchers { } it should "throw an exception during dynamic instantiation" in { - val thrown = the[java.lang.RuntimeException] thrownBy View.viewsFromUrl("dev", "/test.views/RequireView/ec0106/") + val thrown = the[java.lang.RuntimeException] thrownBy View.viewsFromUrl("/test.views/RequireView/ec0106/") thrown.getMessage() shouldBe "Error while parsing view(s) /test.views/RequireView/ec0106/ : requirement failed: Put in upper case: ec0106" } it should "have the same urlPath as the one they were dynamically constructed with" in { - val views = View.viewsFromUrl("dev", "test.views/Product/EC0106/2014/02/24/20140224") + val views = View.viewsFromUrl("test.views/Product/EC0106/2014/02/24/20140224") views.length shouldBe 1 diff --git a/schedoscope-core/src/test/scala/org/schedoscope/dsl/transformations/ExportTest.scala b/schedoscope-core/src/test/scala/org/schedoscope/dsl/transformations/ExportTest.scala index d8081da52..a2e2b1463 100644 --- a/schedoscope-core/src/test/scala/org/schedoscope/dsl/transformations/ExportTest.scala +++ b/schedoscope-core/src/test/scala/org/schedoscope/dsl/transformations/ExportTest.scala @@ -89,7 +89,7 @@ class ExportTest extends FlatSpec with Matchers { } val statement = dbConnection.createStatement() - val resultSet = statement.executeQuery("SELECT COUNT(*) FROM TEST_TEST_VIEWS_CLICK_OF_E_C0101_WITH_JDBC_EXPORT") + val resultSet = statement.executeQuery("SELECT COUNT(*) FROM DEV_TEST_VIEWS_CLICK_OF_E_C0101_WITH_JDBC_EXPORT") resultSet.next() resultSet.getInt(1) shouldBe 3 diff --git a/schedoscope-core/src/test/scala/org/schedoscope/dsl/views/ViewUrlParserTest.scala b/schedoscope-core/src/test/scala/org/schedoscope/dsl/views/ViewUrlParserTest.scala index 9761c3426..7cf23717d 100644 --- a/schedoscope-core/src/test/scala/org/schedoscope/dsl/views/ViewUrlParserTest.scala +++ b/schedoscope-core/src/test/scala/org/schedoscope/dsl/views/ViewUrlParserTest.scala @@ -25,61 +25,54 @@ import test.views.{Brand, Product} class ViewUrlParserTest extends FlatSpec with Matchers { "ViewUrlParse.parse(viewUrlPath)" should "start with /env/package/view" in { - val List(ParsedView(env, clazz, arguments)) = parse("dev", "/test.views/Brand") - env shouldBe "dev" + val List(ParsedView(clazz, arguments)) = parse("/test.views/Brand") clazz shouldBe classOf[Brand] arguments should be(empty) } it should "work without preceding /" in { - val List(ParsedView(env, clazz, arguments)) = parse("dev", "test.views/Brand") - env shouldBe "dev" + val List(ParsedView(clazz, arguments)) = parse("test.views/Brand") clazz shouldBe classOf[Brand] arguments should be(empty) } it should "work with trailing /" in { - val List(ParsedView(env, clazz, arguments)) = parse("dev", "test.views/Brand/") - env shouldBe "dev" + val List(ParsedView(clazz, arguments)) = parse("test.views/Brand/") clazz shouldBe classOf[Brand] arguments should be(empty) } it should "work with preceding and trailing /" in { - val List(ParsedView(env, clazz, arguments)) = parse("dev", "/test.views/Brand/") - env shouldBe "dev" + val List(ParsedView(clazz, arguments)) = parse("/test.views/Brand/") clazz shouldBe classOf[Brand] arguments should be(empty) } it should "parse parameters as well" in { - val List(ParsedView(env, clazz, arguments)) = parse("dev", "/test.views/Product/EC0106/2014/01/12/") - env shouldBe "dev" + val List(ParsedView(clazz, arguments)) = parse("/test.views/Product/EC0106/2014/01/12/") clazz shouldBe classOf[Product] arguments should be(List(typedAny(p("EC0106")), typedAny(p("2014")), typedAny(p("01")), typedAny(p("12")))) } it should "parse multiple views" in { - val parsedViews = parse("dev", "/test.views/e(Product,Brand)/EC0106/2014/01/12/") + val parsedViews = parse("/test.views/e(Product,Brand)/EC0106/2014/01/12/") parsedViews.size shouldBe 2 - parsedViews(0).env shouldBe "dev" parsedViews(0).viewClass shouldBe classOf[Product] parsedViews(0).parameters should be(List(typedAny(p("EC0106")), typedAny(p("2014")), typedAny(p("01")), typedAny(p("12")))) - parsedViews(1).env shouldBe "dev" parsedViews(1).viewClass shouldBe classOf[Brand] parsedViews(1).parameters should be(List(typedAny(p("EC0106")), typedAny(p("2014")), typedAny(p("01")), typedAny(p("12")))) } it should "fail when called with not enough arguments" in { - an[IllegalArgumentException] should be thrownBy parse("dev", "/test.views/") + an[IllegalArgumentException] should be thrownBy parse("/test.views/") } it should "fail when called with illegal class name" in { - an[IllegalArgumentException] should be thrownBy parse("dev", "/test.views/Brund/") + an[IllegalArgumentException] should be thrownBy parse("/test.views/Brund/") } it should "fail when called with illegal package name" in { - an[IllegalArgumentException] should be thrownBy parse("dev", "/eci.datahub/Brand/") + an[IllegalArgumentException] should be thrownBy parse("/eci.datahub/Brand/") } "ViewUrlParse.parseParameters(viewUrlPath)" should "parse basic view parameter types" in { diff --git a/schedoscope-core/src/test/scala/org/schedoscope/test/TestableViewTest.scala b/schedoscope-core/src/test/scala/org/schedoscope/test/TestableViewTest.scala index 8cf098cd0..4f0717b1a 100644 --- a/schedoscope-core/src/test/scala/org/schedoscope/test/TestableViewTest.scala +++ b/schedoscope-core/src/test/scala/org/schedoscope/test/TestableViewTest.scala @@ -222,16 +222,6 @@ class TestableViewTest extends FlatSpec with Matchers { } } - it should "forward the test environment to external views" in { - val productBrand = ProductBrand(p("ec0101"), p("2016"), p("11"), p("07")) - val externalProductBrand = ExternalView(productBrand) - - externalProductBrand.env = "test" - - productBrand.env shouldBe "test" - externalProductBrand.env shouldBe "test" - } - it should "not change output/goal view storage format Avro" in { new ClickEC01Avro(p("2014"), p("01"), p("01")) with test { basedOn(ec0101Clicks, ec0106Clicks) From 5cfca1338fdcd33755d66c54f328d939346c2833 Mon Sep 17 00:00:00 2001 From: Jan Hicken Date: Thu, 15 Jun 2017 09:32:38 +0200 Subject: [PATCH 21/24] Rectify ShopProfilesTest using the new test env --- .../schedoscope/example/osm/datamart/ShopProfilesTest.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schedoscope-tutorial/src/test/scala/schedoscope/example/osm/datamart/ShopProfilesTest.scala b/schedoscope-tutorial/src/test/scala/schedoscope/example/osm/datamart/ShopProfilesTest.scala index 6348d5bf7..e0f0e6716 100644 --- a/schedoscope-tutorial/src/test/scala/schedoscope/example/osm/datamart/ShopProfilesTest.scala +++ b/schedoscope-tutorial/src/test/scala/schedoscope/example/osm/datamart/ShopProfilesTest.scala @@ -98,7 +98,7 @@ class ShopProfilesTest extends SchedoscopeSpec { } val statement = dbConnection.createStatement() - val resultSet = statement.executeQuery("SELECT COUNT(*) FROM TEST_SCHEDOSCOPE_EXAMPLE_OSM_DATAMART_SHOP_PROFILES") + val resultSet = statement.executeQuery("SELECT COUNT(*) FROM DEV_SCHEDOSCOPE_EXAMPLE_OSM_DATAMART_SHOP_PROFILES") resultSet.next() resultSet.getInt(1) shouldBe 3 From 2a3ecc73db41bf835bf874790f3aeebeab699288 Mon Sep 17 00:00:00 2001 From: Jan Hicken Date: Wed, 12 Apr 2017 16:26:07 +0200 Subject: [PATCH 22/24] `convert` and `translate` can now be used as UDF names * add some additional debug output when using the recursive schema --- .../scala/org/schedoscope/lineage/DependencyAnalyzer.scala | 4 ++-- .../scala/org/schedoscope/lineage/DummyOperatorTable.scala | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/schedoscope-core/src/main/scala/org/schedoscope/lineage/DependencyAnalyzer.scala b/schedoscope-core/src/main/scala/org/schedoscope/lineage/DependencyAnalyzer.scala index 8843214ee..dcc393391 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/lineage/DependencyAnalyzer.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/lineage/DependencyAnalyzer.scala @@ -119,8 +119,8 @@ object DependencyAnalyzer { val validated = try { planner.validate(parsed) } catch { - case _: ValidationException => - log.debug("Trying again with a recursively-built schema...") + case ex: ValidationException => + log.debug("Trying again with a recursively-built schema...", ex) planner = new NonFlatteningPlannerImpl(SchedoscopeConfig(view, scanRecursive = true)) planner.validate(planner.parse(firstStmt)) } diff --git a/schedoscope-core/src/main/scala/org/schedoscope/lineage/DummyOperatorTable.scala b/schedoscope-core/src/main/scala/org/schedoscope/lineage/DummyOperatorTable.scala index bfed98d27..d6090cc5a 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/lineage/DummyOperatorTable.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/lineage/DummyOperatorTable.scala @@ -35,6 +35,8 @@ object DummyOperatorTable extends SqlOperatorTable { case class FramingSqlRankFunction(name: String) extends SqlRankFunction(name) { override def allowsFraming(): Boolean = true + + override def getOperandCountRange: SqlOperandCountRange = SqlOperandCountRanges.any() } case class FramingSqlAggFunction(name: String) extends SqlAggFunction(name, @@ -56,6 +58,10 @@ object DummyOperatorTable extends SqlOperatorTable { "LAG", "LEAD" ).map(n => n -> FramingSqlAggFunction(n) + ) ++ Seq( + "CONVERT", "TRANSLATE" + ).map(n => + n -> HiveQlFunction(n) ) override def lookupOperatorOverloads(opName: SqlIdentifier, category: SqlFunctionCategory, syntax: SqlSyntax, From 3da883a5986b9370353fe9edab2de28c0e6ae5aa Mon Sep 17 00:00:00 2001 From: Jan Hicken Date: Wed, 12 Apr 2017 16:24:24 +0200 Subject: [PATCH 23/24] Support the HiveQL operator `div` --- schedoscope-core/src/main/resources/fmpp/templates/Parser.jj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/schedoscope-core/src/main/resources/fmpp/templates/Parser.jj b/schedoscope-core/src/main/resources/fmpp/templates/Parser.jj index 2dce045d7..a34dd25a4 100644 --- a/schedoscope-core/src/main/resources/fmpp/templates/Parser.jj +++ b/schedoscope-core/src/main/resources/fmpp/templates/Parser.jj @@ -4546,6 +4546,8 @@ SqlBinaryOperator BinaryRowOperator() : { return SqlStdOperatorTable.DIVIDE; } | { return SqlStdOperatorTable.DIVIDE; } + |
+ { return SqlStdOperatorTable.DIVIDE; } | { return SqlStdOperatorTable.CONCAT; } | @@ -4761,6 +4763,7 @@ SqlPostfixOperator PostfixRowOperator() : | < DISPATCH: "DISPATCH" > | < DISTINCT: "DISTINCT" > | < DISTRIBUTE: "DISTRIBUTE" > + | < DIV: "DIV" > | < DOMAIN: "DOMAIN" > | < DOUBLE: "DOUBLE" > | < DROP: "DROP" > From f7e7875ec63917ae7f530ae6bbb9dd5ce57a63e1 Mon Sep 17 00:00:00 2001 From: diogopaurelio Date: Tue, 20 Jun 2017 18:07:07 +0200 Subject: [PATCH 24/24] Changed SupervisionStrategy, added tests --- .../scheduler/actors/DriverActor.scala | 14 +++- .../actors/TransformationManagerActor.scala | 11 +-- .../scheduler/driver/DriverRunState.scala | 2 + .../scheduler/actors/DriverActorSpec.scala | 84 ++++++++++++++++++- .../TransformationManagerActorSpec.scala | 76 ++++++++++++++++- 5 files changed, 173 insertions(+), 14 deletions(-) diff --git a/schedoscope-core/src/main/scala/org/schedoscope/scheduler/actors/DriverActor.scala b/schedoscope-core/src/main/scala/org/schedoscope/scheduler/actors/DriverActor.scala index faa73798f..d58e6b61b 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/scheduler/actors/DriverActor.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/scheduler/actors/DriverActor.scala @@ -17,7 +17,8 @@ package org.schedoscope.scheduler.actors import java.security.PrivilegedAction -import akka.actor.{Actor, ActorRef, Props, actorRef2Scala} +import akka.actor.SupervisorStrategy.{Escalate, Restart, Stop} +import akka.actor.{Actor, ActorInitializationException, ActorRef, OneForOneStrategy, Props, actorRef2Scala} import akka.event.{Logging, LoggingReceive} import org.apache.commons.lang.exception.ExceptionUtils import org.apache.hadoop.fs._ @@ -63,7 +64,8 @@ class DriverActor[T <: Transformation](transformationManagerActor: ActorRef, try { driver = driverConstructor(ds) } catch { - case t: Throwable => throw RetryableDriverException("Driver actor could not initialize driver because driver constructor throws exception (HINT: if Driver Actor start failure behaviour persists, validate the respective transformation driver config in conf file). Restarting driver actor...", t) + // note: whatever is thrown here is packed as an ActorInitializationException to Supervisor + case i: Throwable => throw InvalidDriverClassException(s"Unable to instantiate new Driver for provided transformation: ${i.getMessage}", i) } logStateInfo("booted", "DRIVER ACTOR: booted") } @@ -301,6 +303,14 @@ class DriverActor[T <: Transformation](transformationManagerActor: ActorRef, * Factory methods for driver actors. */ object DriverActor { + + // used for determining BalancingDispatcher children' Supervision + lazy val driverRouterSupervisorStrategy = OneForOneStrategy(maxNrOfRetries = -1) { + case _: RetryableDriverException => Restart + case _: ActorInitializationException => Stop + case _ => Escalate + } + def props(settings: SchedoscopeSettings, transformationName: String, transformationManager: ActorRef, hdfs: FileSystem): Props = Props( classOf[DriverActor[_]], diff --git a/schedoscope-core/src/main/scala/org/schedoscope/scheduler/actors/TransformationManagerActor.scala b/schedoscope-core/src/main/scala/org/schedoscope/scheduler/actors/TransformationManagerActor.scala index fed561dfc..d7cca26d7 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/scheduler/actors/TransformationManagerActor.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/scheduler/actors/TransformationManagerActor.scala @@ -51,16 +51,10 @@ class TransformationManagerActor(settings: SchedoscopeSettings, override val supervisorStrategy = OneForOneStrategy(maxNrOfRetries = -1) { case _: RetryableDriverException => Restart - case _: ActorInitializationException => Restart + case _: ActorInitializationException => Stop case _ => Escalate } - // used for determining BalancingDispatcher children' Supervision - lazy val driverRouterSupervisorStrategy = OneForOneStrategy(maxNrOfRetries = -1) { - case _: RetryableDriverException => Restart - case _: ActorInitializationException => Restart - case _ => Escalate - } val driverStates = HashMap[String, TransformationStatusResponse[_]]() val driverActorsBackOffSupervision = new BackOffSupervision( @@ -107,7 +101,7 @@ class TransformationManagerActor(settings: SchedoscopeSettings, actorOf( SmallestMailboxPool( nrOfInstances = settings.getDriverSettings(transformation).concurrency, - supervisorStrategy = driverRouterSupervisorStrategy, + supervisorStrategy = DriverActor.driverRouterSupervisorStrategy, routerDispatcher = "akka.actor.driver-router-dispatcher" ).props(routeeProps = DriverActor.props(settings, transformation, self)), s"${transformation}-driver" @@ -153,6 +147,7 @@ class TransformationManagerActor(settings: SchedoscopeSettings, * Factory for the actions manager actor. */ object TransformationManagerActor { + def props(settings: SchedoscopeSettings, bootstrapDriverActors: Boolean = true) = Props(classOf[TransformationManagerActor], diff --git a/schedoscope-core/src/main/scala/org/schedoscope/scheduler/driver/DriverRunState.scala b/schedoscope-core/src/main/scala/org/schedoscope/scheduler/driver/DriverRunState.scala index 1898cc6d4..de9237a01 100644 --- a/schedoscope-core/src/main/scala/org/schedoscope/scheduler/driver/DriverRunState.scala +++ b/schedoscope-core/src/main/scala/org/schedoscope/scheduler/driver/DriverRunState.scala @@ -44,3 +44,5 @@ case class DriverRunFailed[T <: Transformation](override val driver: Driver[T], * to cause a driver actor restart. */ case class RetryableDriverException(message: String = null, cause: Throwable = null) extends RuntimeException(message, cause) + +case class InvalidDriverClassException(message: String = null, cause: Throwable = null) extends RuntimeException(message, cause) \ No newline at end of file diff --git a/schedoscope-core/src/test/scala/org/schedoscope/scheduler/actors/DriverActorSpec.scala b/schedoscope-core/src/test/scala/org/schedoscope/scheduler/actors/DriverActorSpec.scala index cd9ea8270..f579f3f9c 100644 --- a/schedoscope-core/src/test/scala/org/schedoscope/scheduler/actors/DriverActorSpec.scala +++ b/schedoscope-core/src/test/scala/org/schedoscope/scheduler/actors/DriverActorSpec.scala @@ -15,12 +15,16 @@ */ package org.schedoscope.scheduler.actors -import akka.actor.{ActorRef, ActorSystem} +import akka.actor.{Actor, ActorRef, ActorSystem, Props, Terminated} +import akka.routing.SmallestMailboxPool import akka.testkit.{TestActorRef, TestKit, TestProbe} import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers} import org.schedoscope.Settings +import org.schedoscope.conf.DriverSettings import org.schedoscope.dsl.Parameter._ import org.schedoscope.dsl.transformations.HiveTransformation +import org.schedoscope.scheduler.driver.FilesystemDriver.{apply => _, _} +import org.schedoscope.scheduler.driver.{Driver, FilesystemDriver, InvalidDriverClassException, RetryableDriverException} import org.schedoscope.scheduler.messages._ import org.schedoscope.schema.ddl.HiveQl import test.views.ProductBrand @@ -42,6 +46,32 @@ class DriverActorSpec extends TestKit(ActorSystem("schedoscope")) val settings = Settings() val transformationManagerActor = TestProbe() + class BombActor(to: ActorRef, blastOnStart: Boolean = false, ex: Option[Exception] = None) extends Actor { + + override def receive: Receive = { + + case retryable: RetryableDriverException => to.forward("blasting on msg"); throw retryable + + case ie: IllegalArgumentException => to.forward("committing suicide..."); context stop self + + case "ref" => to.forward(self) + + case x => to.forward(x) + } + + override def preStart() { + if (blastOnStart) { + to.forward("blasting on start") + ex match { + case Some(ex) => throw ex + case _ => throw InvalidDriverClassException("boom goes the dynamite", + new IllegalArgumentException) + } + } + + } + } + trait HiveActorTest { val hivedriverActor = TestActorRef(DriverActor.props(settings, "hive", transformationManagerActor.ref)) @@ -101,6 +131,58 @@ class DriverActorSpec extends TestKit(ActorSystem("schedoscope")) } } +/* it should "NOT restart Driver actors upon exception thrown on ActorInitialization" in { + val hackActor = TestProbe() + + val transformationManagerActor = system.actorOf(Props(new TransformationManagerActor(settings, + bootstrapDriverActors = false) { + override def preStart { + val bombActor = context.actorOf(Props(new BombActor(hackActor.ref, true))) + hackActor.watch(bombActor) + } + })) + hackActor.expectMsg("blasting on start") + hackActor.expectMsgPF() { case Terminated(t) => () } + }*/ + + it should "restart Driver routees upon RetryableDriverException" in { + val hackActor = TestProbe() + + val driverRouterActor = system.actorOf(Props(new DriverActor[HiveTransformation]( + transformationManagerActor.ref, + settings.getDriverSettings("hive"), + (ds: DriverSettings) => Driver.driverFor(ds), + 5.seconds, + settings, + FilesystemDriver.defaultFileSystem(settings.hadoopConf) + ) { + override val supervisorStrategy = DriverActor.driverRouterSupervisorStrategy + + override def preStart { + val bombActor1 = context.actorOf(Props(new BombActor(hackActor.ref, false))) + hackActor.watch(bombActor1) + hackActor.send(bombActor1, "ref") + } + }) + ) + + val bombActor = hackActor.expectMsgType[ActorRef] + hackActor.send(bombActor, RetryableDriverException("retry me")) + hackActor.expectMsg("blasting on msg") + hackActor.send(bombActor, RetryableDriverException("retry me")) + hackActor.expectMsg("blasting on msg") + hackActor.send(bombActor, RetryableDriverException("retry me")) + hackActor.expectMsg("blasting on msg") + hackActor.send(bombActor, RetryableDriverException("retry me")) + hackActor.expectMsg("blasting on msg") + hackActor.send(bombActor, new IllegalArgumentException("bam")) + hackActor.expectMsg("committing suicide...") + hackActor.expectMsgPF() { case Terminated(t) => () } + hackActor.send(bombActor, RetryableDriverException("retry me")) + hackActor.expectNoMsg() + + } + it should "not execute commands before changing to activeReceive state" in { val hivedriverActor = TestActorRef(DriverActor.props(settings, "hive", transformationManagerActor.ref)) diff --git a/schedoscope-core/src/test/scala/org/schedoscope/scheduler/actors/TransformationManagerActorSpec.scala b/schedoscope-core/src/test/scala/org/schedoscope/scheduler/actors/TransformationManagerActorSpec.scala index 3d2dabedb..53c8540e6 100644 --- a/schedoscope-core/src/test/scala/org/schedoscope/scheduler/actors/TransformationManagerActorSpec.scala +++ b/schedoscope-core/src/test/scala/org/schedoscope/scheduler/actors/TransformationManagerActorSpec.scala @@ -16,13 +16,17 @@ package org.schedoscope.scheduler.actors -import akka.actor.{Actor, ActorRef, ActorSystem, Props} -import akka.testkit.{EventFilter, TestActorRef, TestKit, TestProbe} +import akka.actor.Actor.Receive +import akka.actor.SupervisorStrategy.{Restart, Stop} +import akka.actor.TypedActor.Supervisor +import akka.actor.{Actor, ActorInitializationException, ActorRef, ActorSystem, Props, Terminated} +import akka.routing.SmallestMailboxPool +import akka.testkit.{EventFilter, ImplicitSender, TestActorRef, TestKit, TestProbe} import com.typesafe.config.ConfigFactory import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers} import org.schedoscope.dsl.Parameter._ import org.schedoscope.dsl.transformations.FilesystemTransformation -import org.schedoscope.scheduler.driver.{Driver, HiveDriver} +import org.schedoscope.scheduler.driver.{Driver, HiveDriver, InvalidDriverClassException, RetryableDriverException} import org.schedoscope.scheduler.messages._ import org.schedoscope.{Settings, TestUtils} import test.views.ProductBrand @@ -33,6 +37,7 @@ import scala.concurrent.duration._ class TransformationManagerActorSpec extends TestKit(ActorSystem("schedoscope", ConfigFactory.parseString("""akka.loggers = ["akka.testkit.TestEventListener"]"""))) + with ImplicitSender with FlatSpecLike with Matchers with BeforeAndAfterAll { @@ -51,6 +56,31 @@ class TransformationManagerActorSpec extends TestKit(ActorSystem("schedoscope", } } + class BombActor(to: ActorRef, blastOnStart: Boolean = false, ex: Option[Exception] = None) extends Actor { + + override def receive: Receive = { + + case retryable: RetryableDriverException => to.forward("blasting on msg"); throw retryable + + case ie: IllegalArgumentException => to.forward("committing suicide..."); context stop self + + case "ref" => to.forward(self) + + case x => to.forward(x) + } + + override def preStart() { + if (blastOnStart) { + to.forward("blasting on start") + ex match { + case Some(ex) => throw ex + case _ => throw InvalidDriverClassException("boom goes the dynamite", new IllegalArgumentException) + } + } + + } + } + trait TransformationManagerActorTest { val hiveDriverRouter = TestProbe() @@ -80,9 +110,49 @@ class TransformationManagerActorSpec extends TestKit(ActorSystem("schedoscope", seqDriverRouter.send(transformationManagerActor, idleSeqStatus) val idleFSStatus = TransformationStatusResponse("idle", fsDriverRouter.ref, null, null, null) fsDriverRouter.send(transformationManagerActor, idleFSStatus) + } + it should "NOT restart Driver actors upon exception thrown on ActorInitialization" in { + val hackActor = TestProbe() + + val transformationManagerActor = system.actorOf(Props(new TransformationManagerActor(settings, + bootstrapDriverActors = false) { + override def preStart { + val bombActor = context.actorOf(Props(new BombActor(hackActor.ref, true))) + hackActor.watch(bombActor) + } + })) + hackActor.expectMsg("blasting on start") + hackActor.expectMsgPF() { case Terminated(t) => () } } + it should "restart Driver actors upon RetryableDriverException" in { + val hackActor = TestProbe() + + val transformationManagerActor = system.actorOf(Props(new TransformationManagerActor(settings, + bootstrapDriverActors = false) { + override def preStart { + val bombActor = context.actorOf(Props(new BombActor(hackActor.ref, false))) + hackActor.watch(bombActor) + hackActor.send(bombActor, "ref") + } + })) + + val bombActor = hackActor.expectMsgType[ActorRef] + hackActor.send(bombActor, RetryableDriverException("retry me")) + hackActor.expectMsg("blasting on msg") + hackActor.send(bombActor, RetryableDriverException("retry me")) + hackActor.expectMsg("blasting on msg") + hackActor.send(bombActor, RetryableDriverException("retry me")) + hackActor.expectMsg("blasting on msg") + hackActor.send(bombActor, new IllegalArgumentException("bam")) + hackActor.expectMsg("committing suicide...") + hackActor.expectMsgPF() { case Terminated(t) => () } + hackActor.send(bombActor, RetryableDriverException("retry me")) + hackActor.expectNoMsg() + } + + it should "forward transformations to the correct DriverManager based on incoming View" in new TransformationManagerActorTest { val msgSender = TestProbe()