phylotree 2.2.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/phylotree.js CHANGED
@@ -4,8 +4,7 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.phylotree = global.phylotree || {}, global._, global._$1));
5
5
  })(this, (function (exports, _, _$1) { 'use strict';
6
6
 
7
- function _interopNamespace(e) {
8
- if (e && e.__esModule) return e;
7
+ function _interopNamespaceDefault(e) {
9
8
  var n = Object.create(null);
10
9
  if (e) {
11
10
  Object.keys(e).forEach(function (k) {
@@ -18,12 +17,12 @@
18
17
  }
19
18
  });
20
19
  }
21
- n["default"] = e;
20
+ n.default = e;
22
21
  return Object.freeze(n);
23
22
  }
24
23
 
25
- var ___namespace = /*#__PURE__*/_interopNamespace(_);
26
- var ___namespace$1 = /*#__PURE__*/_interopNamespace(_$1);
24
+ var ___namespace = /*#__PURE__*/_interopNamespaceDefault(_);
25
+ var ___namespace$1 = /*#__PURE__*/_interopNamespaceDefault(_$1);
27
26
 
28
27
  function ascending$1(a, b) {
29
28
  return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
@@ -98,7 +97,6 @@
98
97
  const ascendingBisect = bisector(ascending$1);
99
98
  const bisectRight = ascendingBisect.right;
100
99
  bisector(number$2).center;
101
- var bisect = bisectRight;
102
100
 
103
101
  const e10 = Math.sqrt(50),
104
102
  e5 = Math.sqrt(10),
@@ -182,19 +180,12 @@
182
180
  }
183
181
 
184
182
  var top = 1,
185
- right = 2,
186
- bottom = 3,
187
- left = 4,
188
183
  epsilon$1 = 1e-6;
189
184
 
190
185
  function translateX(x) {
191
186
  return "translate(" + x + ",0)";
192
187
  }
193
188
 
194
- function translateY(y) {
195
- return "translate(0," + y + ")";
196
- }
197
-
198
189
  function number$1(scale) {
199
190
  return d => +scale(d);
200
191
  }
@@ -217,9 +208,9 @@
217
208
  tickSizeOuter = 6,
218
209
  tickPadding = 3,
219
210
  offset = typeof window !== "undefined" && window.devicePixelRatio > 1 ? 0 : 0.5,
220
- k = orient === top || orient === left ? -1 : 1,
221
- x = orient === left || orient === right ? "x" : "y",
222
- transform = orient === top || orient === bottom ? translateX : translateY;
211
+ k = -1 ,
212
+ x = "y",
213
+ transform = translateX ;
223
214
 
224
215
  function axis(context) {
225
216
  var values = tickValues == null ? (scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain()) : tickValues,
@@ -250,7 +241,7 @@
250
241
  text = text.merge(tickEnter.append("text")
251
242
  .attr("fill", "currentColor")
252
243
  .attr(x, k * spacing)
253
- .attr("dy", orient === top ? "0em" : orient === bottom ? "0.71em" : "0.32em"));
244
+ .attr("dy", "0em" ));
254
245
 
255
246
  if (context !== selection) {
256
247
  path = path.transition(context);
@@ -270,9 +261,7 @@
270
261
  tickExit.remove();
271
262
 
272
263
  path
273
- .attr("d", orient === left || orient === right
274
- ? (tickSizeOuter ? "M" + k * tickSizeOuter + "," + range0 + "H" + offset + "V" + range1 + "H" + k * tickSizeOuter : "M" + offset + "," + range0 + "V" + range1)
275
- : (tickSizeOuter ? "M" + range0 + "," + k * tickSizeOuter + "V" + offset + "H" + range1 + "V" + k * tickSizeOuter : "M" + range0 + "," + offset + "H" + range1));
264
+ .attr("d", (tickSizeOuter ? "M" + range0 + "," + k * tickSizeOuter + "V" + offset + "H" + range1 + "V" + k * tickSizeOuter : "M" + range0 + "," + offset + "H" + range1));
276
265
 
277
266
  tick
278
267
  .attr("opacity", 1)
@@ -289,7 +278,7 @@
289
278
  .attr("fill", "none")
290
279
  .attr("font-size", 10)
291
280
  .attr("font-family", "sans-serif")
292
- .attr("text-anchor", orient === right ? "start" : orient === left ? "end" : "middle");
281
+ .attr("text-anchor", "middle");
293
282
 
294
283
  selection
295
284
  .each(function() { this.__axis = position; });
@@ -1379,6 +1368,7 @@
1379
1368
  }
1380
1369
 
1381
1370
  // These are typically used in conjunction with noevent to ensure that we can
1371
+ // preventDefault on the event.
1382
1372
  const nonpassivecapture = {capture: true, passive: false};
1383
1373
 
1384
1374
  function noevent$2(event) {
@@ -3222,18 +3212,10 @@
3222
3212
  }
3223
3213
 
3224
3214
  var X = {
3225
- name: "x",
3226
- handles: ["w", "e"].map(type),
3227
- input: function(x, e) { return x == null ? null : [[+x[0], e[0][1]], [+x[1], e[1][1]]]; },
3228
- output: function(xy) { return xy && [xy[0][0], xy[1][0]]; }
3229
- };
3215
+ };
3230
3216
 
3231
3217
  var Y = {
3232
- name: "y",
3233
- handles: ["n", "s"].map(type),
3234
- input: function(y, e) { return y == null ? null : [[e[0][0], +y[0]], [e[1][0], +y[1]]]; },
3235
- output: function(xy) { return xy && [xy[0][1], xy[1][1]]; }
3236
- };
3218
+ };
3237
3219
 
3238
3220
  var XY = {
3239
3221
  name: "xy",
@@ -3274,29 +3256,29 @@
3274
3256
  };
3275
3257
 
3276
3258
  var signsX = {
3277
- overlay: +1,
3278
- selection: +1,
3259
+ overlay: 1,
3260
+ selection: 1,
3279
3261
  n: null,
3280
- e: +1,
3262
+ e: 1,
3281
3263
  s: null,
3282
3264
  w: -1,
3283
3265
  nw: -1,
3284
- ne: +1,
3285
- se: +1,
3266
+ ne: 1,
3267
+ se: 1,
3286
3268
  sw: -1
3287
3269
  };
3288
3270
 
3289
3271
  var signsY = {
3290
- overlay: +1,
3291
- selection: +1,
3272
+ overlay: 1,
3273
+ selection: 1,
3292
3274
  n: -1,
3293
3275
  e: null,
3294
- s: +1,
3276
+ s: 1,
3295
3277
  w: null,
3296
3278
  nw: -1,
3297
3279
  ne: -1,
3298
- se: +1,
3299
- sw: +1
3280
+ se: 1,
3281
+ sw: 1
3300
3282
  };
3301
3283
 
3302
3284
  function type(t) {
@@ -3332,11 +3314,11 @@
3332
3314
  || extent[0][1] === extent[1][1];
3333
3315
  }
3334
3316
 
3335
- function brush() {
3336
- return brush$1(XY);
3317
+ function brush_default() {
3318
+ return brush(XY);
3337
3319
  }
3338
3320
 
3339
- function brush$1(dim) {
3321
+ function brush(dim) {
3340
3322
  var extent = defaultExtent$1,
3341
3323
  filter = defaultFilter$1,
3342
3324
  touchable = defaultTouchable$1,
@@ -4576,7 +4558,7 @@
4576
4558
  }
4577
4559
 
4578
4560
  return function(x) {
4579
- var i = bisect(domain, x, 1, j) - 1;
4561
+ var i = bisectRight(domain, x, 1, j) - 1;
4580
4562
  return r[i](d[i](x));
4581
4563
  };
4582
4564
  }
@@ -4789,7 +4771,7 @@
4789
4771
  if (step < 0) while (++step <= 0) {
4790
4772
  while (offseti(date, -1), !test(date)) {} // eslint-disable-line no-empty
4791
4773
  } else while (--step >= 0) {
4792
- while (offseti(date, +1), !test(date)) {} // eslint-disable-line no-empty
4774
+ while (offseti(date, 1), !test(date)) {} // eslint-disable-line no-empty
4793
4775
  }
4794
4776
  }
4795
4777
  });
@@ -6172,7 +6154,6 @@
6172
6154
  new ZoomEvent(type, {
6173
6155
  sourceEvent: this.sourceEvent,
6174
6156
  target: zoom,
6175
- type,
6176
6157
  transform: this.that.__zoom,
6177
6158
  dispatch: listeners
6178
6159
  }),
@@ -6931,244 +6912,370 @@
6931
6912
  }
6932
6913
  }
6933
6914
 
6934
- //TODO: handle comments
6935
- function readDocType(xmlData, i){
6915
+ class DocTypeReader{
6916
+ constructor(processEntities){
6917
+ this.suppressValidationErr = !processEntities;
6918
+ }
6936
6919
 
6937
- const entities = {};
6938
- if( xmlData[i + 3] === 'O' &&
6939
- xmlData[i + 4] === 'C' &&
6940
- xmlData[i + 5] === 'T' &&
6941
- xmlData[i + 6] === 'Y' &&
6942
- xmlData[i + 7] === 'P' &&
6943
- xmlData[i + 8] === 'E')
6944
- {
6945
- i = i+9;
6946
- let angleBracketsCount = 1;
6947
- let hasBody = false, comment = false;
6948
- let exp = "";
6949
- for(;i<xmlData.length;i++){
6950
- if (xmlData[i] === '<' && !comment) { //Determine the tag type
6951
- if( hasBody && hasSeq(xmlData, "!ENTITY",i)){
6952
- i += 7;
6953
- let entityName, val;
6954
- [entityName, val,i] = readEntityExp(xmlData,i+1);
6955
- if(val.indexOf("&") === -1) //Parameter entities are not supported
6956
- entities[ entityName ] = {
6957
- regx : RegExp( `&${entityName};`,"g"),
6958
- val: val
6959
- };
6960
- }
6961
- else if( hasBody && hasSeq(xmlData, "!ELEMENT",i)) {
6962
- i += 8;//Not supported
6963
- const {index} = readElementExp(xmlData,i+1);
6964
- i = index;
6965
- }else if( hasBody && hasSeq(xmlData, "!ATTLIST",i)){
6966
- i += 8;//Not supported
6967
- // const {index} = readAttlistExp(xmlData,i+1);
6968
- // i = index;
6969
- }else if( hasBody && hasSeq(xmlData, "!NOTATION",i)) {
6970
- i += 9;//Not supported
6971
- const {index} = readNotationExp(xmlData,i+1);
6972
- i = index;
6973
- }else if( hasSeq(xmlData, "!--",i) ) comment = true;
6974
- else throw new Error(`Invalid DOCTYPE`);
6975
-
6976
- angleBracketsCount++;
6977
- exp = "";
6978
- } else if (xmlData[i] === '>') { //Read tag content
6979
- if(comment){
6980
- if( xmlData[i - 1] === "-" && xmlData[i - 2] === "-"){
6981
- comment = false;
6920
+ readDocType(xmlData, i){
6921
+
6922
+ const entities = {};
6923
+ if( xmlData[i + 3] === 'O' &&
6924
+ xmlData[i + 4] === 'C' &&
6925
+ xmlData[i + 5] === 'T' &&
6926
+ xmlData[i + 6] === 'Y' &&
6927
+ xmlData[i + 7] === 'P' &&
6928
+ xmlData[i + 8] === 'E')
6929
+ {
6930
+ i = i+9;
6931
+ let angleBracketsCount = 1;
6932
+ let hasBody = false, comment = false;
6933
+ let exp = "";
6934
+ for(;i<xmlData.length;i++){
6935
+ if (xmlData[i] === '<' && !comment) { //Determine the tag type
6936
+ if( hasBody && hasSeq(xmlData, "!ENTITY",i)){
6937
+ i += 7;
6938
+ let entityName, val;
6939
+ [entityName, val,i] = this.readEntityExp(xmlData,i+1,this.suppressValidationErr);
6940
+ if(val.indexOf("&") === -1) //Parameter entities are not supported
6941
+ entities[ entityName ] = {
6942
+ regx : RegExp( `&${entityName};`,"g"),
6943
+ val: val
6944
+ };
6945
+ }
6946
+ else if( hasBody && hasSeq(xmlData, "!ELEMENT",i)) {
6947
+ i += 8;//Not supported
6948
+ const {index} = this.readElementExp(xmlData,i+1);
6949
+ i = index;
6950
+ }else if( hasBody && hasSeq(xmlData, "!ATTLIST",i)){
6951
+ i += 8;//Not supported
6952
+ // const {index} = this.readAttlistExp(xmlData,i+1);
6953
+ // i = index;
6954
+ }else if( hasBody && hasSeq(xmlData, "!NOTATION",i)) {
6955
+ i += 9;//Not supported
6956
+ const {index} = this.readNotationExp(xmlData,i+1,this.suppressValidationErr);
6957
+ i = index;
6958
+ }else if( hasSeq(xmlData, "!--",i) ) comment = true;
6959
+ else throw new Error(`Invalid DOCTYPE`);
6960
+
6961
+ angleBracketsCount++;
6962
+ exp = "";
6963
+ } else if (xmlData[i] === '>') { //Read tag content
6964
+ if(comment){
6965
+ if( xmlData[i - 1] === "-" && xmlData[i - 2] === "-"){
6966
+ comment = false;
6967
+ angleBracketsCount--;
6968
+ }
6969
+ }else {
6982
6970
  angleBracketsCount--;
6983
6971
  }
6972
+ if (angleBracketsCount === 0) {
6973
+ break;
6974
+ }
6975
+ }else if( xmlData[i] === '['){
6976
+ hasBody = true;
6984
6977
  }else {
6985
- angleBracketsCount--;
6978
+ exp += xmlData[i];
6986
6979
  }
6987
- if (angleBracketsCount === 0) {
6988
- break;
6989
- }
6990
- }else if( xmlData[i] === '['){
6991
- hasBody = true;
6992
- }else {
6993
- exp += xmlData[i];
6994
6980
  }
6981
+ if(angleBracketsCount !== 0){
6982
+ throw new Error(`Unclosed DOCTYPE`);
6983
+ }
6984
+ }else {
6985
+ throw new Error(`Invalid Tag instead of DOCTYPE`);
6995
6986
  }
6996
- if(angleBracketsCount !== 0){
6997
- throw new Error(`Unclosed DOCTYPE`);
6998
- }
6999
- }else {
7000
- throw new Error(`Invalid Tag instead of DOCTYPE`);
6987
+ return {entities, i};
7001
6988
  }
7002
- return {entities, i};
7003
- }
6989
+ readEntityExp(xmlData, i) {
6990
+ //External entities are not supported
6991
+ // <!ENTITY ext SYSTEM "http://normal-website.com" >
7004
6992
 
7005
- const skipWhitespace = (data, index) => {
7006
- while (index < data.length && /\s/.test(data[index])) {
7007
- index++;
7008
- }
7009
- return index;
7010
- };
6993
+ //Parameter entities are not supported
6994
+ // <!ENTITY entityname "&anotherElement;">
7011
6995
 
7012
- function readEntityExp(xmlData, i) {
7013
- //External entities are not supported
7014
- // <!ENTITY ext SYSTEM "http://normal-website.com" >
6996
+ //Internal entities are supported
6997
+ // <!ENTITY entityname "replacement text">
7015
6998
 
7016
- //Parameter entities are not supported
7017
- // <!ENTITY entityname "&anotherElement;">
6999
+ // Skip leading whitespace after <!ENTITY
7000
+ i = skipWhitespace(xmlData, i);
7018
7001
 
7019
- //Internal entities are supported
7020
- // <!ENTITY entityname "replacement text">
7002
+ // Read entity name
7003
+ let entityName = "";
7004
+ while (i < xmlData.length && !/\s/.test(xmlData[i]) && xmlData[i] !== '"' && xmlData[i] !== "'") {
7005
+ entityName += xmlData[i];
7006
+ i++;
7007
+ }
7008
+ validateEntityName(entityName);
7021
7009
 
7022
- // Skip leading whitespace after <!ENTITY
7023
- i = skipWhitespace(xmlData, i);
7010
+ // Skip whitespace after entity name
7011
+ i = skipWhitespace(xmlData, i);
7024
7012
 
7025
- // Read entity name
7026
- let entityName = "";
7027
- while (i < xmlData.length && !/\s/.test(xmlData[i]) && xmlData[i] !== '"' && xmlData[i] !== "'") {
7028
- entityName += xmlData[i];
7029
- i++;
7013
+ // Check for unsupported constructs (external entities or parameter entities)
7014
+ if(!this.suppressValidationErr){
7015
+ if (xmlData.substring(i, i + 6).toUpperCase() === "SYSTEM") {
7016
+ throw new Error("External entities are not supported");
7017
+ }else if (xmlData[i] === "%") {
7018
+ throw new Error("Parameter entities are not supported");
7019
+ }
7020
+ }
7021
+
7022
+ // Read entity value (internal entity)
7023
+ let entityValue = "";
7024
+ [i, entityValue] = this.readIdentifierVal(xmlData, i, "entity");
7025
+ i--;
7026
+ return [entityName, entityValue, i ];
7030
7027
  }
7031
- validateEntityName(entityName);
7032
7028
 
7033
- // Skip whitespace after entity name
7034
- i = skipWhitespace(xmlData, i);
7029
+ readNotationExp(xmlData, i) {
7030
+ // Skip leading whitespace after <!NOTATION
7031
+ i = skipWhitespace(xmlData, i);
7035
7032
 
7036
- // Check for unsupported constructs (external entities or parameter entities)
7037
- if (xmlData.substring(i, i + 6).toUpperCase() === "SYSTEM") {
7038
- throw new Error("External entities are not supported");
7039
- }else if (xmlData[i] === "%") {
7040
- throw new Error("Parameter entities are not supported");
7033
+ // Read notation name
7034
+ let notationName = "";
7035
+ while (i < xmlData.length && !/\s/.test(xmlData[i])) {
7036
+ notationName += xmlData[i];
7037
+ i++;
7038
+ }
7039
+ !this.suppressValidationErr && validateEntityName(notationName);
7040
+
7041
+ // Skip whitespace after notation name
7042
+ i = skipWhitespace(xmlData, i);
7043
+
7044
+ // Check identifier type (SYSTEM or PUBLIC)
7045
+ const identifierType = xmlData.substring(i, i + 6).toUpperCase();
7046
+ if (!this.suppressValidationErr && identifierType !== "SYSTEM" && identifierType !== "PUBLIC") {
7047
+ throw new Error(`Expected SYSTEM or PUBLIC, found "${identifierType}"`);
7048
+ }
7049
+ i += identifierType.length;
7050
+
7051
+ // Skip whitespace after identifier type
7052
+ i = skipWhitespace(xmlData, i);
7053
+
7054
+ // Read public identifier (if PUBLIC)
7055
+ let publicIdentifier = null;
7056
+ let systemIdentifier = null;
7057
+
7058
+ if (identifierType === "PUBLIC") {
7059
+ [i, publicIdentifier ] = this.readIdentifierVal(xmlData, i, "publicIdentifier");
7060
+
7061
+ // Skip whitespace after public identifier
7062
+ i = skipWhitespace(xmlData, i);
7063
+
7064
+ // Optionally read system identifier
7065
+ if (xmlData[i] === '"' || xmlData[i] === "'") {
7066
+ [i, systemIdentifier ] = this.readIdentifierVal(xmlData, i,"systemIdentifier");
7067
+ }
7068
+ } else if (identifierType === "SYSTEM") {
7069
+ // Read system identifier (mandatory for SYSTEM)
7070
+ [i, systemIdentifier ] = this.readIdentifierVal(xmlData, i, "systemIdentifier");
7071
+
7072
+ if (!this.suppressValidationErr && !systemIdentifier) {
7073
+ throw new Error("Missing mandatory system identifier for SYSTEM notation");
7074
+ }
7075
+ }
7076
+
7077
+ return {notationName, publicIdentifier, systemIdentifier, index: --i};
7041
7078
  }
7042
7079
 
7043
- // Read entity value (internal entity)
7044
- let entityValue = "";
7045
- [i, entityValue] = readIdentifierVal(xmlData, i, "entity");
7046
- i--;
7047
- return [entityName, entityValue, i ];
7048
- }
7080
+ readIdentifierVal(xmlData, i, type) {
7081
+ let identifierVal = "";
7082
+ const startChar = xmlData[i];
7083
+ if (startChar !== '"' && startChar !== "'") {
7084
+ throw new Error(`Expected quoted string, found "${startChar}"`);
7085
+ }
7086
+ i++;
7049
7087
 
7050
- function readNotationExp(xmlData, i) {
7051
- // Skip leading whitespace after <!NOTATION
7052
- i = skipWhitespace(xmlData, i);
7088
+ while (i < xmlData.length && xmlData[i] !== startChar) {
7089
+ identifierVal += xmlData[i];
7090
+ i++;
7091
+ }
7053
7092
 
7054
- // Read notation name
7055
- let notationName = "";
7056
- while (i < xmlData.length && !/\s/.test(xmlData[i])) {
7057
- notationName += xmlData[i];
7093
+ if (xmlData[i] !== startChar) {
7094
+ throw new Error(`Unterminated ${type} value`);
7095
+ }
7058
7096
  i++;
7097
+ return [i, identifierVal];
7059
7098
  }
7060
- validateEntityName(notationName);
7061
7099
 
7062
- // Skip whitespace after notation name
7063
- i = skipWhitespace(xmlData, i);
7100
+ readElementExp(xmlData, i) {
7101
+ // <!ELEMENT br EMPTY>
7102
+ // <!ELEMENT div ANY>
7103
+ // <!ELEMENT title (#PCDATA)>
7104
+ // <!ELEMENT book (title, author+)>
7105
+ // <!ELEMENT name (content-model)>
7106
+
7107
+ // Skip leading whitespace after <!ELEMENT
7108
+ i = skipWhitespace(xmlData, i);
7064
7109
 
7065
- // Check identifier type (SYSTEM or PUBLIC)
7066
- const identifierType = xmlData.substring(i, i + 6).toUpperCase();
7067
- if (identifierType !== "SYSTEM" && identifierType !== "PUBLIC") {
7068
- throw new Error(`Expected SYSTEM or PUBLIC, found "${identifierType}"`);
7110
+ // Read element name
7111
+ let elementName = "";
7112
+ while (i < xmlData.length && !/\s/.test(xmlData[i])) {
7113
+ elementName += xmlData[i];
7114
+ i++;
7115
+ }
7116
+
7117
+ // Validate element name
7118
+ if (!this.suppressValidationErr && !isName(elementName)) {
7119
+ throw new Error(`Invalid element name: "${elementName}"`);
7120
+ }
7121
+
7122
+ // Skip whitespace after element name
7123
+ i = skipWhitespace(xmlData, i);
7124
+ let contentModel = "";
7125
+ // Expect '(' to start content model
7126
+ if(xmlData[i] === "E" && hasSeq(xmlData, "MPTY",i)) i+=4;
7127
+ else if(xmlData[i] === "A" && hasSeq(xmlData, "NY",i)) i+=2;
7128
+ else if (xmlData[i] === "(") {
7129
+ i++; // Move past '('
7130
+
7131
+ // Read content model
7132
+ while (i < xmlData.length && xmlData[i] !== ")") {
7133
+ contentModel += xmlData[i];
7134
+ i++;
7135
+ }
7136
+ if (xmlData[i] !== ")") {
7137
+ throw new Error("Unterminated content model");
7138
+ }
7139
+
7140
+ }else if(!this.suppressValidationErr){
7141
+ throw new Error(`Invalid Element Expression, found "${xmlData[i]}"`);
7142
+ }
7143
+
7144
+ return {
7145
+ elementName,
7146
+ contentModel: contentModel.trim(),
7147
+ index: i
7148
+ };
7069
7149
  }
7070
- i += identifierType.length;
7071
7150
 
7072
- // Skip whitespace after identifier type
7073
- i = skipWhitespace(xmlData, i);
7151
+ readAttlistExp(xmlData, i) {
7152
+ // Skip leading whitespace after <!ATTLIST
7153
+ i = skipWhitespace(xmlData, i);
7074
7154
 
7075
- // Read public identifier (if PUBLIC)
7076
- let publicIdentifier = null;
7077
- let systemIdentifier = null;
7155
+ // Read element name
7156
+ let elementName = "";
7157
+ while (i < xmlData.length && !/\s/.test(xmlData[i])) {
7158
+ elementName += xmlData[i];
7159
+ i++;
7160
+ }
7078
7161
 
7079
- if (identifierType === "PUBLIC") {
7080
- [i, publicIdentifier ] = readIdentifierVal(xmlData, i, "publicIdentifier");
7162
+ // Validate element name
7163
+ validateEntityName(elementName);
7081
7164
 
7082
- // Skip whitespace after public identifier
7165
+ // Skip whitespace after element name
7083
7166
  i = skipWhitespace(xmlData, i);
7084
7167
 
7085
- // Optionally read system identifier
7086
- if (xmlData[i] === '"' || xmlData[i] === "'") {
7087
- [i, systemIdentifier ] = readIdentifierVal(xmlData, i,"systemIdentifier");
7168
+ // Read attribute name
7169
+ let attributeName = "";
7170
+ while (i < xmlData.length && !/\s/.test(xmlData[i])) {
7171
+ attributeName += xmlData[i];
7172
+ i++;
7088
7173
  }
7089
- } else if (identifierType === "SYSTEM") {
7090
- // Read system identifier (mandatory for SYSTEM)
7091
- [i, systemIdentifier ] = readIdentifierVal(xmlData, i, "systemIdentifier");
7092
7174
 
7093
- if (!systemIdentifier) {
7094
- throw new Error("Missing mandatory system identifier for SYSTEM notation");
7175
+ // Validate attribute name
7176
+ if (!validateEntityName(attributeName)) {
7177
+ throw new Error(`Invalid attribute name: "${attributeName}"`);
7095
7178
  }
7096
- }
7097
-
7098
- return {notationName, publicIdentifier, systemIdentifier, index: --i};
7099
- }
7100
7179
 
7101
- function readIdentifierVal(xmlData, i, type) {
7102
- let identifierVal = "";
7103
- const startChar = xmlData[i];
7104
- if (startChar !== '"' && startChar !== "'") {
7105
- throw new Error(`Expected quoted string, found "${startChar}"`);
7106
- }
7107
- i++;
7180
+ // Skip whitespace after attribute name
7181
+ i = skipWhitespace(xmlData, i);
7108
7182
 
7109
- while (i < xmlData.length && xmlData[i] !== startChar) {
7110
- identifierVal += xmlData[i];
7111
- i++;
7112
- }
7183
+ // Read attribute type
7184
+ let attributeType = "";
7185
+ if (xmlData.substring(i, i + 8).toUpperCase() === "NOTATION") {
7186
+ attributeType = "NOTATION";
7187
+ i += 8; // Move past "NOTATION"
7113
7188
 
7114
- if (xmlData[i] !== startChar) {
7115
- throw new Error(`Unterminated ${type} value`);
7116
- }
7117
- i++;
7118
- return [i, identifierVal];
7119
- }
7189
+ // Skip whitespace after "NOTATION"
7190
+ i = skipWhitespace(xmlData, i);
7120
7191
 
7121
- function readElementExp(xmlData, i) {
7122
- // <!ELEMENT br EMPTY>
7123
- // <!ELEMENT div ANY>
7124
- // <!ELEMENT title (#PCDATA)>
7125
- // <!ELEMENT book (title, author+)>
7126
- // <!ELEMENT name (content-model)>
7127
-
7128
- // Skip leading whitespace after <!ELEMENT
7129
- i = skipWhitespace(xmlData, i);
7192
+ // Expect '(' to start the list of notations
7193
+ if (xmlData[i] !== "(") {
7194
+ throw new Error(`Expected '(', found "${xmlData[i]}"`);
7195
+ }
7196
+ i++; // Move past '('
7197
+
7198
+ // Read the list of allowed notations
7199
+ let allowedNotations = [];
7200
+ while (i < xmlData.length && xmlData[i] !== ")") {
7201
+ let notation = "";
7202
+ while (i < xmlData.length && xmlData[i] !== "|" && xmlData[i] !== ")") {
7203
+ notation += xmlData[i];
7204
+ i++;
7205
+ }
7130
7206
 
7131
- // Read element name
7132
- let elementName = "";
7133
- while (i < xmlData.length && !/\s/.test(xmlData[i])) {
7134
- elementName += xmlData[i];
7135
- i++;
7136
- }
7207
+ // Validate notation name
7208
+ notation = notation.trim();
7209
+ if (!validateEntityName(notation)) {
7210
+ throw new Error(`Invalid notation name: "${notation}"`);
7211
+ }
7137
7212
 
7138
- // Validate element name
7139
- if (!validateEntityName(elementName)) {
7140
- throw new Error(`Invalid element name: "${elementName}"`);
7141
- }
7213
+ allowedNotations.push(notation);
7142
7214
 
7143
- // Skip whitespace after element name
7144
- i = skipWhitespace(xmlData, i);
7145
- let contentModel = "";
7146
- // Expect '(' to start content model
7147
- if(xmlData[i] === "E" && hasSeq(xmlData, "MPTY",i)) i+=4;
7148
- else if(xmlData[i] === "A" && hasSeq(xmlData, "NY",i)) i+=2;
7149
- else if (xmlData[i] === "(") {
7150
- i++; // Move past '('
7215
+ // Skip '|' separator or exit loop
7216
+ if (xmlData[i] === "|") {
7217
+ i++; // Move past '|'
7218
+ i = skipWhitespace(xmlData, i); // Skip optional whitespace after '|'
7219
+ }
7220
+ }
7151
7221
 
7152
- // Read content model
7153
- while (i < xmlData.length && xmlData[i] !== ")") {
7154
- contentModel += xmlData[i];
7155
- i++;
7222
+ if (xmlData[i] !== ")") {
7223
+ throw new Error("Unterminated list of notations");
7224
+ }
7225
+ i++; // Move past ')'
7226
+
7227
+ // Store the allowed notations as part of the attribute type
7228
+ attributeType += " (" + allowedNotations.join("|") + ")";
7229
+ } else {
7230
+ // Handle simple types (e.g., CDATA, ID, IDREF, etc.)
7231
+ while (i < xmlData.length && !/\s/.test(xmlData[i])) {
7232
+ attributeType += xmlData[i];
7233
+ i++;
7234
+ }
7235
+
7236
+ // Validate simple attribute type
7237
+ const validTypes = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"];
7238
+ if (!this.suppressValidationErr && !validTypes.includes(attributeType.toUpperCase())) {
7239
+ throw new Error(`Invalid attribute type: "${attributeType}"`);
7240
+ }
7156
7241
  }
7157
- if (xmlData[i] !== ")") {
7158
- throw new Error("Unterminated content model");
7242
+
7243
+ // Skip whitespace after attribute type
7244
+ i = skipWhitespace(xmlData, i);
7245
+
7246
+ // Read default value
7247
+ let defaultValue = "";
7248
+ if (xmlData.substring(i, i + 8).toUpperCase() === "#REQUIRED") {
7249
+ defaultValue = "#REQUIRED";
7250
+ i += 8;
7251
+ } else if (xmlData.substring(i, i + 7).toUpperCase() === "#IMPLIED") {
7252
+ defaultValue = "#IMPLIED";
7253
+ i += 7;
7254
+ } else {
7255
+ [i, defaultValue] = this.readIdentifierVal(xmlData, i, "ATTLIST");
7159
7256
  }
7160
7257
 
7161
- }else {
7162
- throw new Error(`Invalid Element Expression, found "${xmlData[i]}"`);
7258
+ return {
7259
+ elementName,
7260
+ attributeName,
7261
+ attributeType,
7262
+ defaultValue,
7263
+ index: i
7264
+ }
7163
7265
  }
7164
-
7165
- return {
7166
- elementName,
7167
- contentModel: contentModel.trim(),
7168
- index: i
7169
- };
7170
7266
  }
7171
7267
 
7268
+
7269
+
7270
+ const skipWhitespace = (data, index) => {
7271
+ while (index < data.length && /\s/.test(data[index])) {
7272
+ index++;
7273
+ }
7274
+ return index;
7275
+ };
7276
+
7277
+
7278
+
7172
7279
  function hasSeq(data, seq,i){
7173
7280
  for(let j=0;j<seq.length;j++){
7174
7281
  if(seq[j]!==data[i+j+1]) return false;
@@ -7178,7 +7285,7 @@
7178
7285
 
7179
7286
  function validateEntityName(name){
7180
7287
  if (isName(name))
7181
- return name;
7288
+ return name;
7182
7289
  else
7183
7290
  throw new Error(`Invalid entity name ${name}`);
7184
7291
  }
@@ -7210,7 +7317,7 @@
7210
7317
  return parse_int(trimmedStr, 16);
7211
7318
  // }else if (options.oct && octRegex.test(str)) {
7212
7319
  // return Number.parseInt(val, 8);
7213
- }else if (trimmedStr.search(/.+[eE].+/)!== -1) { //eNotation
7320
+ }else if (trimmedStr.includes('e') || trimmedStr.includes('E')) { //eNotation
7214
7321
  return resolveEnotation(str,trimmedStr,options);
7215
7322
  // }else if (options.parseBin && binRegex.test(str)) {
7216
7323
  // return Number.parseInt(val, 2);
@@ -7380,6 +7487,20 @@
7380
7487
  this.saveTextToParentTag = saveTextToParentTag;
7381
7488
  this.addChild = addChild$1;
7382
7489
  this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes);
7490
+
7491
+ if(this.options.stopNodes && this.options.stopNodes.length > 0){
7492
+ this.stopNodesExact = new Set();
7493
+ this.stopNodesWildcard = new Set();
7494
+ for(let i = 0; i < this.options.stopNodes.length; i++){
7495
+ const stopNodeExp = this.options.stopNodes[i];
7496
+ if(typeof stopNodeExp !== 'string') continue;
7497
+ if(stopNodeExp.startsWith("*.")){
7498
+ this.stopNodesWildcard.add(stopNodeExp.substring(2));
7499
+ }else {
7500
+ this.stopNodesExact.add(stopNodeExp);
7501
+ }
7502
+ }
7503
+ }
7383
7504
  }
7384
7505
 
7385
7506
  }
@@ -7451,7 +7572,7 @@
7451
7572
  //const attrsRegx = new RegExp("([\\w\\-\\.\\:]+)\\s*=\\s*(['\"])((.|\n)*?)\\2","gm");
7452
7573
  const attrsRegx = new RegExp('([^\\s=]+)\\s*(=\\s*([\'"])([\\s\\S]*?)\\3)?', 'gm');
7453
7574
 
7454
- function buildAttributesMap(attrStr, jPath, tagName) {
7575
+ function buildAttributesMap(attrStr, jPath) {
7455
7576
  if (this.options.ignoreAttributes !== true && typeof attrStr === 'string') {
7456
7577
  // attrStr = attrStr.replace(/\r?\n/g, ' ');
7457
7578
  //attrStr = attrStr || attrStr.trim();
@@ -7514,6 +7635,7 @@
7514
7635
  let currentNode = xmlObj;
7515
7636
  let textData = "";
7516
7637
  let jPath = "";
7638
+ const docTypeReader = new DocTypeReader(this.options.processEntities);
7517
7639
  for(let i=0; i< xmlData.length; i++){//for each char in XML data
7518
7640
  const ch = xmlData[i];
7519
7641
  if(ch === '<'){
@@ -7567,7 +7689,7 @@
7567
7689
  childNode.add(this.options.textNodeName, "");
7568
7690
 
7569
7691
  if(tagData.tagName !== tagData.tagExp && tagData.attrExpPresent){
7570
- childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath, tagData.tagName);
7692
+ childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath);
7571
7693
  }
7572
7694
  this.addChild(currentNode, childNode, jPath, i);
7573
7695
  }
@@ -7585,7 +7707,7 @@
7585
7707
  }
7586
7708
  i = endIndex;
7587
7709
  } else if( xmlData.substr(i + 1, 2) === '!D') {
7588
- const result = readDocType(xmlData, i);
7710
+ const result = docTypeReader.readDocType(xmlData, i);
7589
7711
  this.docTypeEntities = result.entities;
7590
7712
  i = result.i;
7591
7713
  }else if(xmlData.substr(i + 1, 2) === '![') {
@@ -7614,7 +7736,12 @@
7614
7736
  let closeIndex = result.closeIndex;
7615
7737
 
7616
7738
  if (this.options.transformTagName) {
7617
- tagName = this.options.transformTagName(tagName);
7739
+ //console.log(tagExp, tagName)
7740
+ const newTagName = this.options.transformTagName(tagName);
7741
+ if(tagExp === tagName) {
7742
+ tagExp = newTagName;
7743
+ }
7744
+ tagName = newTagName;
7618
7745
  }
7619
7746
 
7620
7747
  //save text as child node
@@ -7635,7 +7762,7 @@
7635
7762
  jPath += jPath ? "." + tagName : tagName;
7636
7763
  }
7637
7764
  const startIndex = i;
7638
- if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) {
7765
+ if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, jPath, tagName)) {
7639
7766
  let tagContent = "";
7640
7767
  //self-closing tag
7641
7768
  if(tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1){
@@ -7665,7 +7792,8 @@
7665
7792
  const childNode = new XmlNode(tagName);
7666
7793
 
7667
7794
  if(tagName !== tagExp && attrExpPresent){
7668
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
7795
+ childNode[":@"] = this.buildAttributesMap(tagExp, jPath
7796
+ );
7669
7797
  }
7670
7798
  if(tagContent) {
7671
7799
  tagContent = this.parseTextData(tagContent, tagName, jPath, true, attrExpPresent, true, true);
@@ -7687,12 +7815,16 @@
7687
7815
  }
7688
7816
 
7689
7817
  if(this.options.transformTagName) {
7690
- tagName = this.options.transformTagName(tagName);
7818
+ const newTagName = this.options.transformTagName(tagName);
7819
+ if(tagExp === tagName) {
7820
+ tagExp = newTagName;
7821
+ }
7822
+ tagName = newTagName;
7691
7823
  }
7692
7824
 
7693
7825
  const childNode = new XmlNode(tagName);
7694
7826
  if(tagName !== tagExp && attrExpPresent){
7695
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
7827
+ childNode[":@"] = this.buildAttributesMap(tagExp, jPath);
7696
7828
  }
7697
7829
  this.addChild(currentNode, childNode, jPath, startIndex);
7698
7830
  jPath = jPath.substr(0, jPath.lastIndexOf("."));
@@ -7703,7 +7835,7 @@
7703
7835
  this.tagsNodeStack.push(currentNode);
7704
7836
 
7705
7837
  if(tagName !== tagExp && attrExpPresent){
7706
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
7838
+ childNode[":@"] = this.buildAttributesMap(tagExp, jPath);
7707
7839
  }
7708
7840
  this.addChild(currentNode, childNode, jPath, startIndex);
7709
7841
  currentNode = childNode;
@@ -7772,17 +7904,14 @@
7772
7904
 
7773
7905
  //TODO: use jPath to simplify the logic
7774
7906
  /**
7775
- *
7776
- * @param {string[]} stopNodes
7907
+ * @param {Set} stopNodesExact
7908
+ * @param {Set} stopNodesWildcard
7777
7909
  * @param {string} jPath
7778
- * @param {string} currentTagName
7910
+ * @param {string} currentTagName
7779
7911
  */
7780
- function isItStopNode(stopNodes, jPath, currentTagName){
7781
- const allNodesExp = "*." + currentTagName;
7782
- for (const stopNodePath in stopNodes) {
7783
- const stopNodeExp = stopNodes[stopNodePath];
7784
- if( allNodesExp === stopNodeExp || jPath === stopNodeExp ) return true;
7785
- }
7912
+ function isItStopNode(stopNodesExact, stopNodesWildcard, jPath, currentTagName){
7913
+ if(stopNodesWildcard && stopNodesWildcard.has(currentTagName)) return true;
7914
+ if(stopNodesExact && stopNodesExact.has(jPath)) return true;
7786
7915
  return false;
7787
7916
  }
7788
7917
 
@@ -8052,15 +8181,16 @@
8052
8181
  }
8053
8182
  /**
8054
8183
  * Parse XML dats to JS object
8055
- * @param {string|Buffer} xmlData
8184
+ * @param {string|Uint8Array} xmlData
8056
8185
  * @param {boolean|Object} validationOption
8057
8186
  */
8058
8187
  parse(xmlData,validationOption){
8059
- if(typeof xmlData === "string");else if( xmlData.toString){
8188
+ if(typeof xmlData !== "string" && xmlData.toString){
8060
8189
  xmlData = xmlData.toString();
8061
- }else {
8190
+ }else if(typeof xmlData !== "string"){
8062
8191
  throw new Error("XML data is accepted in String or Bytes[] form.")
8063
8192
  }
8193
+
8064
8194
  if( validationOption){
8065
8195
  if(validationOption === true) validationOption = {}; //validate with default options
8066
8196
 
@@ -8473,20 +8603,20 @@
8473
8603
 
8474
8604
  var node_operations = /*#__PURE__*/Object.freeze({
8475
8605
  __proto__: null,
8476
- graftANode: graftANode,
8477
8606
  addChild: addChild,
8607
+ assignAttributes: assignAttributes,
8608
+ clearInternalNodes: clearInternalNodes,
8478
8609
  createNode: createNode,
8479
8610
  deleteANode: deleteANode,
8480
- getTips: getTips,
8481
8611
  getInternals: getInternals,
8482
- getRootNode: getRootNode,
8483
- getNodes: getNodes,
8484
8612
  getNodeByName: getNodeByName,
8485
- assignAttributes: assignAttributes,
8613
+ getNodes: getNodes,
8614
+ getRootNode: getRootNode,
8615
+ getTips: getTips,
8616
+ graftANode: graftANode,
8486
8617
  isLeafNode: isLeafNode,
8487
- updateKeyName: updateKeyName,
8488
- clearInternalNodes: clearInternalNodes,
8489
- selectAllDescendants: selectAllDescendants$1
8618
+ selectAllDescendants: selectAllDescendants$1,
8619
+ updateKeyName: updateKeyName
8490
8620
  });
8491
8621
 
8492
8622
  /**
@@ -8951,53 +9081,53 @@
8951
9081
 
8952
9082
  var nexus = /*#__PURE__*/Object.freeze({
8953
9083
  __proto__: null,
8954
- parseAnnotations: parseAnnotations,
9084
+ default: loadTree,
8955
9085
  loadAnnotations: loadAnnotations,
8956
- 'default': loadTree
9086
+ parseAnnotations: parseAnnotations
8957
9087
  });
8958
9088
 
8959
9089
  // Changes XML to JSON
8960
9090
  // Modified version from here: http://davidwalsh.name/convert-xml-json
8961
9091
  function xmlToJson(xml) {
8962
9092
 
8963
- // Create the return object
8964
- var obj = {};
8965
-
8966
- if (xml.nodeType == 1) { // element
8967
- // do attributes
8968
- if (xml.attributes.length > 0) {
8969
- obj["@attributes"] = {};
8970
- for (var j = 0; j < xml.attributes.length; j++) {
8971
- var attribute = xml.attributes.item(j);
8972
- obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
8973
- }
8974
- }
8975
- } else if (xml.nodeType == 3) { // text
8976
- obj = xml.nodeValue;
8977
- }
8978
-
8979
- // do children
8980
- // If just one text node inside
8981
- if (xml.hasChildNodes() && xml.childNodes.length === 1 && xml.childNodes[0].nodeType === 3) {
8982
- obj = xml.childNodes[0].nodeValue;
8983
- }
8984
- else if (xml.hasChildNodes()) {
8985
- for(var i = 0; i < xml.childNodes.length; i++) {
8986
- var item = xml.childNodes.item(i);
8987
- var nodeName = item.nodeName;
8988
- if (typeof(obj[nodeName]) == "undefined") {
8989
- obj[nodeName] = xmlToJson(item);
8990
- } else {
8991
- if (typeof(obj[nodeName].push) == "undefined") {
8992
- var old = obj[nodeName];
8993
- obj[nodeName] = [];
8994
- obj[nodeName].push(old);
8995
- }
8996
- obj[nodeName].push(xmlToJson(item));
8997
- }
8998
- }
8999
- }
9000
- return obj;
9093
+ // Create the return object
9094
+ var obj = {};
9095
+
9096
+ if (xml.nodeType == 1) { // element
9097
+ // do attributes
9098
+ if (xml.attributes.length > 0) {
9099
+ obj["@attributes"] = {};
9100
+ for (var j = 0; j < xml.attributes.length; j++) {
9101
+ var attribute = xml.attributes.item(j);
9102
+ obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
9103
+ }
9104
+ }
9105
+ } else if (xml.nodeType == 3) { // text
9106
+ obj = xml.nodeValue;
9107
+ }
9108
+
9109
+ // do children
9110
+ // If just one text node inside
9111
+ if (xml.hasChildNodes() && xml.childNodes.length === 1 && xml.childNodes[0].nodeType === 3) {
9112
+ obj = xml.childNodes[0].nodeValue;
9113
+ }
9114
+ else if (xml.hasChildNodes()) {
9115
+ for(var i = 0; i < xml.childNodes.length; i++) {
9116
+ var item = xml.childNodes.item(i);
9117
+ var nodeName = item.nodeName;
9118
+ if (typeof(obj[nodeName]) == "undefined") {
9119
+ obj[nodeName] = xmlToJson(item);
9120
+ } else {
9121
+ if (typeof(obj[nodeName].push) == "undefined") {
9122
+ var old = obj[nodeName];
9123
+ obj[nodeName] = [];
9124
+ obj[nodeName].push(old);
9125
+ }
9126
+ obj[nodeName].push(xmlToJson(item));
9127
+ }
9128
+ }
9129
+ }
9130
+ return obj;
9001
9131
  }
9002
9132
 
9003
9133
  var phyloxml_parser = function(xml, options) {
@@ -9005,8 +9135,8 @@
9005
9135
  function parsePhyloxml(node, index) {
9006
9136
  if (node.clade) {
9007
9137
  if (!Array.isArray(node.clade)) {
9008
- node.clade = [node.clade];
9009
- }
9138
+ node.clade = [node.clade];
9139
+ }
9010
9140
  node.clade.forEach(parsePhyloxml);
9011
9141
  node.children = node.clade;
9012
9142
  delete node.clade;
@@ -9028,20 +9158,20 @@
9028
9158
  var tree_json;
9029
9159
 
9030
9160
  if (typeof xml === "string") {
9031
- if (DOMParser) {
9032
- const parser = new DOMParser();
9033
- xml = parser.parseFromString(xml, "text/xml");
9034
- } else {
9035
- const parser = new XMLParser();
9036
- xml = parser.parse(xml);
9037
- }
9161
+ if (DOMParser) {
9162
+ const parser = new DOMParser();
9163
+ xml = parser.parseFromString(xml, "text/xml");
9164
+ } else {
9165
+ const parser = new XMLParser();
9166
+ xml = parser.parse(xml);
9167
+ }
9038
9168
  }
9039
9169
 
9040
9170
  xml = xmlToJson(xml);
9041
9171
  var phylogeny = xml.phyloxml.phylogeny;
9042
9172
  if (Array.isArray(phylogeny)) {
9043
- phylogeny = phylogeny[0];
9044
- console.warn('PhyloXML files with multiple phylogenies are not currently supported. Only the first phylogeny will be loaded.');
9173
+ phylogeny = phylogeny[0];
9174
+ console.warn("PhyloXML files with multiple phylogenies are not currently supported. Only the first phylogeny will be loaded.");
9045
9175
  }
9046
9176
  tree_json = phylogeny.clade;
9047
9177
  tree_json.name = "root";
@@ -9705,9 +9835,9 @@
9705
9835
 
9706
9836
  var rooting = /*#__PURE__*/Object.freeze({
9707
9837
  __proto__: null,
9838
+ pathToRoot: pathToRoot,
9708
9839
  reroot: reroot,
9709
- rootpath: rootpath,
9710
- pathToRoot: pathToRoot
9840
+ rootpath: rootpath
9711
9841
  });
9712
9842
 
9713
9843
  function xCoord(d) {
@@ -9873,19 +10003,7 @@
9873
10003
  }
9874
10004
  }
9875
10005
 
9876
- function shiftTip$1(d) {
9877
- if (this.options["is-radial"]) {
9878
- return [
9879
- (d.text_align == "end" ? -1 : 1) *
9880
- (this.radius_pad_for_bubbles - d.radius),
9881
- 0
9882
- ];
9883
- }
9884
- if (this.options["right-to-left"]) {
9885
- return [this.right_most_leaf - d.screen_x, 0];
9886
- }
9887
- return [this.right_most_leaf - d.screen_x, 0];
9888
- }
10006
+ // shiftTip function is defined in nodes.js - removed duplicate here
9889
10007
 
9890
10008
  function layoutHandler(attr) {
9891
10009
  if (!arguments.length) return this.layout_listener_handler;
@@ -9960,18 +10078,17 @@
9960
10078
 
9961
10079
  var opt = /*#__PURE__*/Object.freeze({
9962
10080
  __proto__: null,
10081
+ alignTips: alignTips,
9963
10082
  css_classes: css_classes,
9964
10083
  initializeCssClasses: initializeCssClasses,
9965
10084
  internalNames: internalNames,
9966
- radial: radial,
9967
- alignTips: alignTips,
9968
- nodeBubbleSize: nodeBubbleSize,
9969
- shiftTip: shiftTip$1,
9970
10085
  layoutHandler: layoutHandler,
9971
- selectionLabel: selectionLabel,
10086
+ nodeBubbleSize: nodeBubbleSize,
9972
10087
  get nodeSpan () { return nodeSpan$1; },
9973
10088
  predefined_selecters: predefined_selecters,
9974
- selectionCallback: selectionCallback$1
10089
+ radial: radial,
10090
+ selectionCallback: selectionCallback$1,
10091
+ selectionLabel: selectionLabel
9975
10092
  });
9976
10093
 
9977
10094
  function shiftTip(d) {
@@ -9984,8 +10101,10 @@
9984
10101
  ];
9985
10102
  }
9986
10103
 
9987
- if (this.options["right-to-left"]) {
9988
- return [this.right_most_leaf - d.screen_x, 0];
10104
+ if (this.options["layout"] == "right-to-left") {
10105
+ // For RTL, shift labels to align at the left edge (x=0)
10106
+ // screen_x is the node's horizontal position; shifting by -screen_x moves label to x=0
10107
+ return [-d.screen_x, 0];
9989
10108
  }
9990
10109
 
9991
10110
  return [this.right_most_leaf - d.screen_x, 0];
@@ -10042,18 +10161,27 @@
10042
10161
  return d.text_align;
10043
10162
  });
10044
10163
  } else {
10045
- labels = labels.attr("text-anchor", "start").attr("transform", d => {
10046
- if (this.options["layout"] == "right-to-left") {
10047
- return this.d3PhylotreeSvgTranslate([-20, 0]);
10048
- }
10049
- return this.d3PhylotreeSvgTranslate(
10050
- this.alignTips() ? this.shiftTip(d) : null
10051
- );
10052
- });
10164
+ const isRTL = this.options["layout"] == "right-to-left";
10165
+ labels = labels
10166
+ .attr("text-anchor", isRTL ? "end" : "start")
10167
+ .attr("transform", d => {
10168
+ return this.d3PhylotreeSvgTranslate(
10169
+ this.alignTips() ? this.shiftTip(d) : null
10170
+ );
10171
+ });
10053
10172
  }
10054
10173
 
10055
10174
  if (this.alignTips()) {
10056
10175
  tracers = tracers.data([node]);
10176
+ const isRTL = this.options["layout"] == "right-to-left";
10177
+
10178
+ // Determine direction multiplier for tracer start position
10179
+ const getX1Direction = (d) => {
10180
+ if (this.radial()) {
10181
+ return d.text_align == "end" ? -1 : 1;
10182
+ }
10183
+ return isRTL ? -1 : 1;
10184
+ };
10057
10185
 
10058
10186
  if (transitions) {
10059
10187
  tracers = tracers
@@ -10062,27 +10190,12 @@
10062
10190
  .classed(this.css_classes["branch-tracer"], true)
10063
10191
  .merge(tracers)
10064
10192
  .attr("x1", d => {
10065
- return (
10066
- (d.text_align == "end" ? -1 : 1) * this.nodeBubbleSize(node)
10067
- );
10193
+ return getX1Direction(d) * this.nodeBubbleSize(node);
10068
10194
  })
10069
10195
  .attr("x2", 0)
10070
10196
  .attr("y1", 0)
10071
10197
  .attr("y2", 0)
10072
10198
  .attr("x2", d => {
10073
- if (this.options["layout"] == "right-to-left") {
10074
- return d.screen_x;
10075
- }
10076
-
10077
- return this.shiftTip(d)[0];
10078
- })
10079
- .attr("transform", d => {
10080
- return this.d3PhylotreeSvgRotate(d.text_angle);
10081
- })
10082
- .attr("x2", d => {
10083
- if (this.options["layout"] == "right-to-left") {
10084
- return d.screen_x;
10085
- }
10086
10199
  return this.shiftTip(d)[0];
10087
10200
  })
10088
10201
  .attr("transform", d => {
@@ -10095,9 +10208,7 @@
10095
10208
  .classed(this.css_classes["branch-tracer"], true)
10096
10209
  .merge(tracers)
10097
10210
  .attr("x1", d => {
10098
- return (
10099
- (d.text_align == "end" ? -1 : 1) * this.nodeBubbleSize(node)
10100
- );
10211
+ return getX1Direction(d) * this.nodeBubbleSize(node);
10101
10212
  })
10102
10213
  .attr("y2", 0)
10103
10214
  .attr("y1", 0)
@@ -10127,17 +10238,24 @@
10127
10238
  });
10128
10239
 
10129
10240
  if (this.shown_font_size >= 5) {
10241
+ const isRTL = this.options["layout"] == "right-to-left";
10130
10242
  labels = labels.attr("dx", d => {
10131
- return (
10132
- (d.text_align == "end" ? -1 : 1) *
10133
- ((this.alignTips() ? 0 : shift) + this.shown_font_size * 0.33)
10134
- );
10243
+ // For radial, use text_align; for linear RTL, use negative offset; otherwise positive
10244
+ const direction = this.radial()
10245
+ ? (d.text_align == "end" ? -1 : 1)
10246
+ : (isRTL ? -1 : 1);
10247
+ return direction * ((this.alignTips() ? 0 : shift) + this.shown_font_size * 0.33);
10135
10248
  });
10136
10249
  }
10137
10250
  } else {
10138
10251
  if (this.shown_font_size >= 5) {
10252
+ const isRTL = this.options["layout"] == "right-to-left";
10139
10253
  labels = labels.attr("dx", d => { // eslint-disable-line
10140
- return (d.text_align == "end" ? -1 : 1) * this.shown_font_size * 0.33;
10254
+ // For radial, use text_align; for linear RTL, use negative offset; otherwise positive
10255
+ const direction = this.radial()
10256
+ ? (d.text_align == "end" ? -1 : 1)
10257
+ : (isRTL ? -1 : 1);
10258
+ return direction * this.shown_font_size * 0.33;
10141
10259
  });
10142
10260
  }
10143
10261
  }
@@ -10326,26 +10444,26 @@
10326
10444
  function nodeLabel(attr) {
10327
10445
  if (!arguments.length) return this._nodeLabel;
10328
10446
  this._nodeLabel = attr ? attr : defNodeLabel;
10329
- this.update();
10447
+ this.update();
10330
10448
  return this;
10331
10449
  }
10332
10450
 
10333
10451
  var render_nodes = /*#__PURE__*/Object.freeze({
10334
10452
  __proto__: null,
10335
- shiftTip: shiftTip,
10453
+ defNodeLabel: defNodeLabel,
10336
10454
  drawNode: drawNode,
10337
- updateHasHiddenNodes: updateHasHiddenNodes,
10338
- showInternalName: showInternalName,
10339
- nodeSpan: nodeSpan,
10340
- reclassNode: reclassNode,
10341
- nodeVisible: nodeVisible,
10342
- nodeNotshown: nodeNotshown,
10343
10455
  hasHiddenNodes: hasHiddenNodes,
10456
+ internalLabel: internalLabel,
10344
10457
  isNodeCollapsed: isNodeCollapsed,
10345
10458
  nodeCssSelectors: nodeCssSelectors,
10346
- internalLabel: internalLabel,
10347
- defNodeLabel: defNodeLabel,
10348
- nodeLabel: nodeLabel
10459
+ nodeLabel: nodeLabel,
10460
+ nodeNotshown: nodeNotshown,
10461
+ nodeSpan: nodeSpan,
10462
+ nodeVisible: nodeVisible,
10463
+ reclassNode: reclassNode,
10464
+ shiftTip: shiftTip,
10465
+ showInternalName: showInternalName,
10466
+ updateHasHiddenNodes: updateHasHiddenNodes
10349
10467
  });
10350
10468
 
10351
10469
  function cladeCssSelectors(css_classes) {
@@ -10611,12 +10729,12 @@
10611
10729
  var render_edges = /*#__PURE__*/Object.freeze({
10612
10730
  __proto__: null,
10613
10731
  drawEdge: drawEdge,
10614
- reclassEdge: reclassEdge,
10615
- initializeEdgeLabels: initializeEdgeLabels,
10616
- syncEdgeLabels: syncEdgeLabels,
10617
- edgeVisible: edgeVisible,
10618
10732
  edgeCssSelectors: edgeCssSelectors,
10619
- placeAlongAnEdge: placeAlongAnEdge
10733
+ edgeVisible: edgeVisible,
10734
+ initializeEdgeLabels: initializeEdgeLabels,
10735
+ placeAlongAnEdge: placeAlongAnEdge,
10736
+ reclassEdge: reclassEdge,
10737
+ syncEdgeLabels: syncEdgeLabels
10620
10738
  });
10621
10739
 
10622
10740
  let d3_layout_phylotree_event_id = "phylotree.event";
@@ -10671,17 +10789,25 @@
10671
10789
  sizes[0] + 2 * pad_radius + vertical_offset
10672
10790
  ];
10673
10791
 
10792
+ // Update base transform for radial layout
10793
+ this.baseTransform = {
10794
+ x: pad_radius,
10795
+ y: pad_radius + vertical_offset
10796
+ };
10797
+
10674
10798
  if (svg) {
10799
+ // Compose with zoom transform if present
10800
+ let transform;
10801
+ if (this.currentZoomTransform && this.options["zoom"]) {
10802
+ const zt = this.currentZoomTransform;
10803
+ transform = `translate(${zt.x + this.baseTransform.x * zt.k}, ${zt.y + this.baseTransform.y * zt.k}) scale(${zt.k})`;
10804
+ } else {
10805
+ transform = "translate(" + pad_radius + "," + (pad_radius + vertical_offset) + ")";
10806
+ }
10807
+
10675
10808
  svg
10676
10809
  .selectAll("." + css_classes["tree-container"])
10677
- .attr(
10678
- "transform",
10679
- "translate (" +
10680
- pad_radius +
10681
- "," +
10682
- (pad_radius + vertical_offset) +
10683
- ")"
10684
- );
10810
+ .attr("transform", transform);
10685
10811
  }
10686
10812
  } else {
10687
10813
 
@@ -10795,16 +10921,16 @@
10795
10921
 
10796
10922
  var events = /*#__PURE__*/Object.freeze({
10797
10923
  __proto__: null,
10798
- toggleCollapse: toggleCollapse,
10799
- resizeSvg: resizeSvg,
10800
- rescale: rescale,
10801
- triggerRefresh: triggerRefresh,
10802
10924
  countUpdate: countUpdate,
10803
- d3PhylotreeTriggerLayout: d3PhylotreeTriggerLayout,
10804
- d3PhylotreeEventListener: d3PhylotreeEventListener,
10805
10925
  d3PhylotreeAddEventListener: d3PhylotreeAddEventListener,
10926
+ d3PhylotreeEventListener: d3PhylotreeEventListener,
10927
+ d3PhylotreeSvgRotate: d3PhylotreeSvgRotate,
10806
10928
  d3PhylotreeSvgTranslate: d3PhylotreeSvgTranslate,
10807
- d3PhylotreeSvgRotate: d3PhylotreeSvgRotate
10929
+ d3PhylotreeTriggerLayout: d3PhylotreeTriggerLayout,
10930
+ rescale: rescale,
10931
+ resizeSvg: resizeSvg,
10932
+ toggleCollapse: toggleCollapse,
10933
+ triggerRefresh: triggerRefresh
10808
10934
  });
10809
10935
 
10810
10936
  let d3_layout_phylotree_context_menu_id = "d3_layout_phylotree_context_menu";
@@ -11342,15 +11468,15 @@
11342
11468
 
11343
11469
  var menus = /*#__PURE__*/Object.freeze({
11344
11470
  __proto__: null,
11345
- nodeDropdownMenu: nodeDropdownMenu,
11346
11471
  addCustomMenu: addCustomMenu,
11347
- modifySelection: modifySelection,
11472
+ clearSelection: clearSelection,
11473
+ deselectNodes: deselectNodes,
11348
11474
  getSelection: getSelection,
11475
+ modifySelection: modifySelection,
11476
+ nodeDropdownMenu: nodeDropdownMenu,
11349
11477
  selectAllDescendants: selectAllDescendants,
11350
- selectionCallback: selectionCallback,
11351
11478
  selectNodes: selectNodes,
11352
- deselectNodes: deselectNodes,
11353
- clearSelection: clearSelection
11479
+ selectionCallback: selectionCallback
11354
11480
  });
11355
11481
 
11356
11482
  /**
@@ -11420,9 +11546,9 @@
11420
11546
 
11421
11547
  var eventEmitter = /*#__PURE__*/Object.freeze({
11422
11548
  __proto__: null,
11423
- on: on,
11549
+ emit: emit,
11424
11550
  off: off,
11425
- emit: emit
11551
+ on: on
11426
11552
  });
11427
11553
 
11428
11554
  /**
@@ -11465,11 +11591,11 @@
11465
11591
  * @private
11466
11592
  */
11467
11593
  function _injectSetStyles(sets) {
11468
- const styleId = 'phylotree-selection-set-styles';
11594
+ const styleId = "phylotree-selection-set-styles";
11469
11595
  let styleEl = document.getElementById(styleId);
11470
11596
 
11471
11597
  if (!styleEl) {
11472
- styleEl = document.createElement('style');
11598
+ styleEl = document.createElement("style");
11473
11599
  styleEl.id = styleId;
11474
11600
  document.head.appendChild(styleEl);
11475
11601
  }
@@ -11554,8 +11680,8 @@
11554
11680
  return this;
11555
11681
  }
11556
11682
 
11557
- const nodeName = typeof node === 'string' ? node : node.data.name;
11558
- const nodeObj = typeof node === 'string'
11683
+ const nodeName = typeof node === "string" ? node : node.data.name;
11684
+ const nodeObj = typeof node === "string"
11559
11685
  ? this.phylotree.getNodeByName(node)
11560
11686
  : node;
11561
11687
 
@@ -11568,8 +11694,8 @@
11568
11694
  this._selectionSets[setName].members.add(nodeName);
11569
11695
  nodeObj._selectionSet = setName;
11570
11696
 
11571
- this.emit('setChange', {
11572
- action: 'add',
11697
+ this.emit("setChange", {
11698
+ action: "add",
11573
11699
  set: setName,
11574
11700
  node: nodeObj,
11575
11701
  allSets: this._getSetsSummary()
@@ -11596,8 +11722,8 @@
11596
11722
  return this;
11597
11723
  }
11598
11724
 
11599
- const nodeName = typeof node === 'string' ? node : node.data.name;
11600
- const nodeObj = typeof node === 'string'
11725
+ const nodeName = typeof node === "string" ? node : node.data.name;
11726
+ const nodeObj = typeof node === "string"
11601
11727
  ? this.phylotree.getNodeByName(node)
11602
11728
  : node;
11603
11729
 
@@ -11607,8 +11733,8 @@
11607
11733
  delete nodeObj._selectionSet;
11608
11734
  }
11609
11735
 
11610
- this.emit('setChange', {
11611
- action: 'remove',
11736
+ this.emit("setChange", {
11737
+ action: "remove",
11612
11738
  set: setName,
11613
11739
  node: nodeObj,
11614
11740
  allSets: this._getSetsSummary()
@@ -11687,17 +11813,17 @@
11687
11813
 
11688
11814
  var selectionSets = /*#__PURE__*/Object.freeze({
11689
11815
  __proto__: null,
11690
- initializeSelectionSets: initializeSelectionSets,
11816
+ _getSetsSummary: _getSetsSummary,
11691
11817
  _injectSetStyles: _injectSetStyles,
11692
- setActiveSet: setActiveSet,
11818
+ addToSet: addToSet,
11693
11819
  getActiveSet: getActiveSet,
11820
+ getNodeSet: getNodeSet,
11694
11821
  getSetMembers: getSetMembers,
11695
- addToSet: addToSet,
11696
- removeFromSet: removeFromSet,
11697
- _getSetsSummary: _getSetsSummary,
11698
11822
  handleMultiSetClick: handleMultiSetClick,
11823
+ initializeSelectionSets: initializeSelectionSets,
11699
11824
  isInSet: isInSet,
11700
- getNodeSet: getNodeSet
11825
+ removeFromSet: removeFromSet,
11826
+ setActiveSet: setActiveSet
11701
11827
  });
11702
11828
 
11703
11829
  // replacement for d3.functor
@@ -11814,6 +11940,10 @@
11814
11940
  this.node_styler = this.options['node-styler'];
11815
11941
  this.edge_styler = this.options['edge-styler'];
11816
11942
 
11943
+ // Store zoom state to preserve across updates
11944
+ this.currentZoomTransform = null;
11945
+ this.baseTransform = { x: 0, y: 0 };
11946
+
11817
11947
  this.nodeSpan = this.options['node-span'];
11818
11948
 
11819
11949
  if(!this.nodeSpan) {
@@ -11998,6 +12128,10 @@
11998
12128
 
11999
12129
  this.placenodes();
12000
12130
 
12131
+ // Sync edge labels BEFORE drawing edges so that edge.selected reflects node.selected
12132
+ // This is critical for custom edge stylers that rely on selection state
12133
+ this.syncEdgeLabels();
12134
+
12001
12135
  transitions = this.transitions(transitions);
12002
12136
 
12003
12137
  let node_id = 0;
@@ -12006,15 +12140,26 @@
12006
12140
  .selectAll("." + css_classes["tree-container"])
12007
12141
  .data([0]);
12008
12142
 
12143
+ // Store base transform for composition with zoom
12144
+ this.baseTransform = {
12145
+ x: this.offsets[1] + this.options["left-offset"],
12146
+ y: this.pad_height()
12147
+ };
12148
+
12009
12149
  enclosure = enclosure
12010
12150
  .enter()
12011
12151
  .append("g")
12012
12152
  .attr("class", css_classes["tree-container"])
12013
12153
  .merge(enclosure)
12014
12154
  .attr("transform", d => {
12155
+ // Compose base transform with current zoom transform if present
12156
+ if (this.currentZoomTransform && this.options["zoom"]) {
12157
+ const zt = this.currentZoomTransform;
12158
+ return `translate(${zt.x + this.baseTransform.x * zt.k}, ${zt.y + this.baseTransform.y * zt.k}) scale(${zt.k})`;
12159
+ }
12015
12160
  return this.d3PhylotreeSvgTranslate([
12016
- this.offsets[1] + this.options["left-offset"],
12017
- this.pad_height()
12161
+ this.baseTransform.x,
12162
+ this.baseTransform.y
12018
12163
  ]);
12019
12164
  });
12020
12165
 
@@ -12114,14 +12259,14 @@
12114
12259
  this.resizeSvg(this.phylotree, this.svg, transitions);
12115
12260
 
12116
12261
  if (this.options["brush"]) {
12117
- var brush$1 = enclosure
12262
+ var brush = enclosure
12118
12263
  .selectAll("." + css_classes["tree-selection-brush"])
12119
12264
  .data([0])
12120
12265
  .enter()
12121
12266
  .insert("g", ":first-child")
12122
12267
  .attr("class", css_classes["tree-selection-brush"]);
12123
12268
 
12124
- var brush_object = brush()
12269
+ var brush_object = brush_default()
12125
12270
  .on("brush", (event, d) => {
12126
12271
  var extent = event.selection,
12127
12272
  shown_links = this.links.filter(edgeVisible);
@@ -12160,31 +12305,41 @@
12160
12305
  //brush.call(d3.event.target.clear());
12161
12306
  });
12162
12307
 
12163
- brush$1.call(brush_object);
12308
+ brush.call(brush_object);
12164
12309
  }
12165
12310
 
12166
- this.syncEdgeLabels();
12311
+ // Note: syncEdgeLabels() is called at the start of update() before edges are drawn
12312
+ // to ensure selection state is synced before reclassEdge and edge_styler run
12167
12313
 
12168
12314
  if (this.options["zoom"]) {
12169
- let zoom$1 = zoom()
12170
- .scaleExtent([0.1, 10])
12171
- .on("zoom", (event) => {
12172
-
12173
- select("." + css_classes["tree-container"]).attr("transform", d => {
12174
- let toTransform = event.transform;
12175
- return toTransform;
12315
+ // Create zoom behavior if not already created
12316
+ if (!this.zoomBehavior) {
12317
+ this.zoomBehavior = zoom()
12318
+ .scaleExtent([0.1, 10])
12319
+ .on("zoom", (event) => {
12320
+ // Store the current zoom transform
12321
+ this.currentZoomTransform = event.transform;
12322
+
12323
+ // Compose zoom transform with base transform
12324
+ const zt = event.transform;
12325
+ const composedTransform = `translate(${zt.x + this.baseTransform.x * zt.k}, ${zt.y + this.baseTransform.y * zt.k}) scale(${zt.k})`;
12326
+
12327
+ // Use this.svg.select() to target only this tree instance (not global d3.select)
12328
+ this.svg.select("." + css_classes["tree-container"]).attr("transform", composedTransform);
12329
+
12330
+ // Apply same transform to scale bar
12331
+ this.svg.select("." + css_classes["tree-scale-bar"]).attr("transform", d => {
12332
+ return `translate(${zt.x + this.baseTransform.x * zt.k}, ${zt.y + (this.baseTransform.y - 10) * zt.k}) scale(${zt.k})`;
12333
+ });
12176
12334
  });
12335
+ }
12177
12336
 
12178
- // Give some extra room
12179
- select("." + css_classes["tree-scale-bar"]).attr("transform", d => {
12180
- let toTransform = event.transform;
12181
- toTransform.y -= 10;
12182
- return toTransform;
12183
- });
12184
-
12185
- });
12337
+ this.svg.call(this.zoomBehavior);
12186
12338
 
12187
- this.svg.call(zoom$1);
12339
+ // Restore zoom transform if we have one stored (preserves zoom across updates)
12340
+ if (this.currentZoomTransform) {
12341
+ this.svg.call(this.zoomBehavior.transform, this.currentZoomTransform);
12342
+ }
12188
12343
  }
12189
12344
 
12190
12345
  // Emit rendered event
@@ -12511,12 +12666,7 @@
12511
12666
  return n.depth;
12512
12667
  });
12513
12668
 
12514
- if (this.do_scaling && undef_BL) {
12515
- // requested scaling, but some branches had no branch lengths
12516
- // redo layout without branch lengths
12517
- this.do_scaling = false;
12518
- this.phylotree.nodes.x = this.tree_layout(this.phylotree.nodes);
12519
- }
12669
+ if (this.do_scaling && undef_BL) ;
12520
12670
 
12521
12671
  let at_least_one_dimension_fixed = false;
12522
12672
 
@@ -12713,7 +12863,7 @@
12713
12863
  this.size[0] = this.radial_center + this.radius / scaler;
12714
12864
  this.size[1] = this.radial_center + this.radius / scaler;
12715
12865
  } else {
12716
- this.do_lr();
12866
+ this.do_lr();
12717
12867
 
12718
12868
  this.draw_branch = draw_line;
12719
12869
  this.edge_placer = lineSegmentPlacer;
@@ -12724,8 +12874,10 @@
12724
12874
  d.x *= this.scales[0];
12725
12875
  d.y *= this.scales[1]*.8;
12726
12876
 
12727
- if (this.options["layout"] == "right-to-left") {
12728
- d.y = this._extents[1][1] * this.scales[1] - d.y;
12877
+ if (this.options["layout"] == "right-to-left") {
12878
+ // For RTL, always add label_width offset to shift tree right,
12879
+ // creating space on the left for labels (prevents labels overlapping branches)
12880
+ d.y = this._extents[1][1] * this.scales[1] - d.y + this.label_width;
12729
12881
  }
12730
12882
 
12731
12883
 
@@ -12803,7 +12955,7 @@
12803
12955
  this.draw_scale_bar.tickValues([domain_limit]);
12804
12956
  } else {
12805
12957
  let round = function(x, n) {
12806
- return n ? Math.round(x * (n = Math.pow(10, n))) / n : Math.round(x);
12958
+ return Math.round(x);
12807
12959
  };
12808
12960
 
12809
12961
  let my_ticks = scale.ticks();
@@ -12816,9 +12968,7 @@
12816
12968
  range_limit /
12817
12969
  (this.shown_font_size *
12818
12970
  scaleTickFormatter(my_ticks).length *
12819
- 2),
12820
- 0
12821
- )
12971
+ 2))
12822
12972
  )
12823
12973
  );
12824
12974
  }
@@ -14509,7 +14659,7 @@
14509
14659
  let N = n;
14510
14660
  let totalDistances = getTotalDistances(distanceMatrixArr);
14511
14661
  let dPrime = getDPrime(distanceMatrixArr, totalDistances, N);
14512
- let [i, j, minD] = ijMinDPrime(dPrime, N);
14662
+ let [i, j] = ijMinDPrime(dPrime, N);
14513
14663
  let deltaMatrix = createDelta(totalDistances, N);
14514
14664
  let limbLengthI = (distanceMatrixArr[i][j] + deltaMatrix[i][j]) / 2;
14515
14665
  let limbLengthJ = (distanceMatrixArr[i][j] - deltaMatrix[i][j]) / 2;
@@ -14584,6 +14734,7 @@
14584
14734
  exports.centerOfTree = centerOfTree;
14585
14735
  exports.clusterPicker = clusterPicker;
14586
14736
  exports.computeMidpoint = computeMidpoint;
14737
+ exports.extractDates = extract_dates;
14587
14738
  exports.extract_dates = extract_dates;
14588
14739
  exports.fitRootToTip = fitRootToTip;
14589
14740
  exports.getDistanceMatrix = getDistanceMatrix;
@@ -14593,6 +14744,7 @@
14593
14744
  exports.loadAnnotations = loadAnnotations;
14594
14745
  exports.neighborJoining = neighborJoining;
14595
14746
  exports.newickParser = newickParser;
14747
+ exports.pairwiseDistances = computePairwiseDistances;
14596
14748
  exports.pairwise_distances = computePairwiseDistances;
14597
14749
  exports.parseAnnotations = parseAnnotations;
14598
14750
  exports.parseFasta = parseFasta;
@@ -14603,7 +14755,5 @@
14603
14755
  exports.rootToTip = rootToTip;
14604
14756
  exports.sackin = sackin;
14605
14757
 
14606
- Object.defineProperty(exports, '__esModule', { value: true });
14607
-
14608
14758
  }));
14609
14759
  //# sourceMappingURL=phylotree.js.map