@wavemaker/angular-codegen 11.15.6-1.647701 → 11.15.7-rc.647843

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.
@@ -37982,6 +37982,13 @@ function requireDom () {
37982
37982
  * used for attributes or DocumentType entities
37983
37983
  */
37984
37984
  function NamedNodeMap() {
37985
+ // nodeName -> Attr membership index; lets the parse-time de-duplication in
37986
+ // setNamedItem resolve an existing attribute in O(1) instead of scanning the
37987
+ // list, so building an element with M attributes costs O(M) rather than O(M^2).
37988
+ // The numbered entries and length remain the sole authority for attribute order.
37989
+ // Object.create(null) so an attribute named __proto__ or constructor is an
37990
+ // ordinary key.
37991
+ this._nameIndex = Object.create(null);
37985
37992
  }
37986
37993
  function _findNodeIndex(list,node){
37987
37994
  var i = list.length;
@@ -37990,12 +37997,27 @@ function requireDom () {
37990
37997
  }
37991
37998
  }
37992
37999
 
38000
+ function _nnmIndexAdd(list, attr) {
38001
+ list._nameIndex[attr.nodeName] = attr;
38002
+ }
38003
+ function _nnmIndexRemove(list, attr) {
38004
+ // Only drop the entry if it still points at this attribute; a replacement with
38005
+ // a different nodeName may already have re-keyed it.
38006
+ if (list._nameIndex[attr.nodeName] === attr) {
38007
+ delete list._nameIndex[attr.nodeName];
38008
+ }
38009
+ }
38010
+
37993
38011
  function _addNamedNode(el,list,newAttr,oldAttr){
37994
38012
  if(oldAttr){
37995
38013
  list[_findNodeIndex(list,oldAttr)] = newAttr;
38014
+ // oldAttr leaves the list; drop its index entry (its nodeName may differ
38015
+ // from newAttr's when the replacement came via setNamedItemNS).
38016
+ _nnmIndexRemove(list, oldAttr);
37996
38017
  }else {
37997
38018
  list[list.length++] = newAttr;
37998
38019
  }
38020
+ _nnmIndexAdd(list, newAttr);
37999
38021
  if(el){
38000
38022
  newAttr.ownerElement = el;
38001
38023
  var doc = el.ownerDocument;
@@ -38014,6 +38036,7 @@ function requireDom () {
38014
38036
  list[i] = list[++i];
38015
38037
  }
38016
38038
  list.length = lastIndex;
38039
+ _nnmIndexRemove(list, attr);
38017
38040
  if(el){
38018
38041
  var doc = el.ownerDocument;
38019
38042
  if(doc){
@@ -38047,7 +38070,11 @@ function requireDom () {
38047
38070
  if(el && el!=this._ownerElement){
38048
38071
  throw new DOMException(INUSE_ATTRIBUTE_ERR);
38049
38072
  }
38050
- var oldAttr = this.getNamedItem(attr.nodeName);
38073
+ // Resolve any existing attribute with the same nodeName through the O(1)
38074
+ // membership index rather than an O(M) scan — this is the parse-dedup hot
38075
+ // path (setAttributeNode per attribute during parse). Absent -> undefined,
38076
+ // matching getNamedItem's contract.
38077
+ var oldAttr = this._nameIndex[attr.nodeName];
38051
38078
  _addNamedNode(this._ownerElement,this,attr,oldAttr);
38052
38079
  return oldAttr;
38053
38080
  },
@@ -38280,9 +38307,38 @@ function requireDom () {
38280
38307
  while (child) {
38281
38308
  var next = child.nextSibling;
38282
38309
  if (next !== null && next.nodeType === TEXT_NODE && child.nodeType === TEXT_NODE) {
38283
- node.removeChild(next);
38284
- child.appendData(next.data);
38285
- // Do not advance child: re-check new nextSibling for another text run
38310
+ // Merge the whole run of adjacent text nodes at once: gather the
38311
+ // following text siblings' data, unlink them in a single pass, and
38312
+ // re-index the child list a single time. Per-sibling `removeChild`
38313
+ // (each an O(K) re-index) plus per-sibling `appendData` (each an O(K)
38314
+ // string rebuild) is O(K^2) over a long run of single-character text
38315
+ // nodes; this keeps it O(K). The first text node of the run survives
38316
+ // and carries the concatenated data, preserving node identity and
38317
+ // locator semantics.
38318
+ var tail = [];
38319
+ var sibling = next;
38320
+ while (sibling !== null && sibling.nodeType === TEXT_NODE) {
38321
+ tail.push(sibling.data);
38322
+ sibling = sibling.nextSibling;
38323
+ }
38324
+ // `sibling` is now the first non-text node after the run, or null.
38325
+ var removed = child.nextSibling;
38326
+ while (removed !== sibling) {
38327
+ var following = removed.nextSibling;
38328
+ removed.parentNode = null;
38329
+ removed.previousSibling = null;
38330
+ removed.nextSibling = null;
38331
+ removed = following;
38332
+ }
38333
+ child.nextSibling = sibling;
38334
+ if (sibling !== null) {
38335
+ sibling.previousSibling = child;
38336
+ } else {
38337
+ node.lastChild = child;
38338
+ }
38339
+ child.appendData(tail.join('')); // single O(K) string rebuild
38340
+ _onUpdateChild(node.ownerDocument, node); // single O(K) re-index
38341
+ child = sibling;
38286
38342
  } else {
38287
38343
  child = next;
38288
38344
  }
@@ -39093,8 +39149,10 @@ function requireDom () {
39093
39149
  * - it does not do any input validation on the arguments and doesn't throw "InvalidCharacterError".
39094
39150
  *
39095
39151
  * Note: When the resulting document is serialized with `requireWellFormed: true`, the
39096
- * serializer throws with code `INVALID_STATE_ERR` if `.data` contains `?>` (W3C DOM Parsing
39097
- * §3.2.1.7). Without that option the data is emitted verbatim.
39152
+ * serializer throws with code `INVALID_STATE_ERR` if `.target` is not a valid XML `NCName`
39153
+ * (a `Name` with no colon) or is an ASCII case-insensitive match for `"xml"`, or if `.data`
39154
+ * contains `?>` (W3C DOM Parsing §3.2.1.7). Without that option the target and data are
39155
+ * emitted verbatim.
39098
39156
  *
39099
39157
  * @param {string} target
39100
39158
  * @param {string} data
@@ -39119,7 +39177,27 @@ function requireDom () {
39119
39177
  node.specified = true;
39120
39178
  return node;
39121
39179
  },
39180
+ /**
39181
+ * Creates an EntityReference object, serialized as `&name;`.
39182
+ *
39183
+ * The `name` is validated against the XML `Name` production at creation time; an invalid name
39184
+ * throws a `DOMException` with code `INVALID_CHARACTER_ERR`. When the resulting node is
39185
+ * serialized with `requireWellFormed: true`, the serializer re-validates `nodeName` and throws
39186
+ * a `DOMException` with code `INVALID_STATE_ERR` if a later `nodeName` mutation made it invalid;
39187
+ * without that option the name is emitted verbatim.
39188
+ *
39189
+ * Note: xmldom does not expand entities — the parser resolves entity references inline and never
39190
+ * constructs `EntityReference` nodes, so this method is the only producer.
39191
+ *
39192
+ * @param {string} name The name of the entity to reference.
39193
+ * @returns {EntityReference}
39194
+ * @throws {DOMException} With code `INVALID_CHARACTER_ERR` when `name` is not a valid XML `Name`.
39195
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-392B75AE
39196
+ */
39122
39197
  createEntityReference : function(name){
39198
+ if (!tagNamePattern.test(name)) {
39199
+ throw new DOMException(INVALID_CHARACTER_ERR, 'not a valid xml name "' + name + '"');
39200
+ }
39123
39201
  var node = new EntityReference();
39124
39202
  node.ownerDocument = this;
39125
39203
  node.nodeName = name;
@@ -39331,15 +39409,16 @@ function requireDom () {
39331
39409
  /**
39332
39410
  * Represents a DocumentType node (the `<!DOCTYPE ...>` declaration).
39333
39411
  *
39334
- * `publicId`, `systemId`, and `internalSubset` are plain own-property assignments.
39412
+ * `name`, `publicId`, `systemId`, and `internalSubset` are plain own-property assignments.
39335
39413
  * xmldom does not enforce the `readonly` constraint declared by the WHATWG DOM spec —
39336
39414
  * direct property writes succeed silently. Values are serialized verbatim when
39337
39415
  * `requireWellFormed` is false (the default). When the serializer is invoked with
39338
39416
  * `requireWellFormed: true` (via the 4th-parameter options object), it validates each
39339
- * field and throws `DOMException` with code `INVALID_STATE_ERR` on invalid values.
39417
+ * field — including `name`, which is checked against the XML `Name` production — and throws
39418
+ * `DOMException` with code `INVALID_STATE_ERR` on invalid values.
39340
39419
  *
39341
39420
  * @class
39342
- * @see https://developer.mozilla.org/en-US/docs/Web/API/DocumentType MDN
39421
+ * @see https://developer.mozilla.org/docs/Web/API/DocumentType MDN
39343
39422
  */
39344
39423
  function DocumentType() {
39345
39424
  } DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
@@ -39353,6 +39432,20 @@ function requireDom () {
39353
39432
  } Entity.prototype.nodeType = ENTITY_NODE;
39354
39433
  _extends(Entity,Node);
39355
39434
 
39435
+ /**
39436
+ * Represents an EntityReference node, serialized as `&nodeName;`.
39437
+ *
39438
+ * `nodeName` is the referenced entity's name, stored verbatim. When serialized with
39439
+ * `requireWellFormed: true`, the serializer validates `nodeName` against the XML `Name` production
39440
+ * and throws a `DOMException` with code `INVALID_STATE_ERR` if it does not match; without that
39441
+ * option the name is emitted verbatim between `&` and `;`.
39442
+ *
39443
+ * Note: xmldom does not expand entities — the parser resolves entity references inline and never
39444
+ * constructs `EntityReference` nodes, so the only producer is `Document.createEntityReference`.
39445
+ *
39446
+ * @class
39447
+ * @see https://www.w3.org/TR/xml/#NT-Name
39448
+ */
39356
39449
  function EntityReference() {
39357
39450
  } EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
39358
39451
  _extends(EntityReference,Node);
@@ -39395,12 +39488,15 @@ function requireDom () {
39395
39488
  * not a valid XML QName,
39396
39489
  * - a CDATASection node's data contains `"]]>"`,
39397
39490
  * - a Comment node's data contains `"-->"` (bare `"--"` does not throw on this branch),
39398
- * - a ProcessingInstruction's data contains `"?>"`,
39491
+ * - a ProcessingInstruction's target is not a valid XML `NCName` (a `Name` with no colon) or is
39492
+ * an ASCII case-insensitive match for `"xml"`, or its data contains `"?>"`,
39493
+ * - a DocumentType's `name` is not a valid XML `Name` (XML 1.0 production [5]),
39399
39494
  * - a DocumentType's `publicId` is non-empty and does not match the XML `PubidLiteral`
39400
39495
  * production,
39401
39496
  * - a DocumentType's `systemId` is non-empty and does not match the XML `SystemLiteral`
39402
- * production, or
39403
- * - a DocumentType's `internalSubset` contains `"]>"`.
39497
+ * production,
39498
+ * - a DocumentType's `internalSubset` contains `"]>"`, or
39499
+ * - an EntityReference's `nodeName` is not a valid XML `Name` (XML 1.0 production [5]).
39404
39500
  * Note: xmldom does not enforce `readonly` on DocumentType fields — direct property
39405
39501
  * writes succeed and are covered by the serializer-level checks above.
39406
39502
  * @see https://html.spec.whatwg.org/#dom-xmlserializer-serializetostring
@@ -39655,6 +39751,9 @@ function requireDom () {
39655
39751
 
39656
39752
  case DOCUMENT_TYPE_NODE:
39657
39753
  if (requireWellFormed) {
39754
+ if (!tagNamePattern.test(n.name)) {
39755
+ throw new DOMException(INVALID_STATE_ERR, 'The doctype name "' + n.name + '" is not a valid XML Name');
39756
+ }
39658
39757
  if (n.publicId && !/^("[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%']*"|'[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%'"]*')$/.test(n.publicId)) {
39659
39758
  throw new DOMException(INVALID_STATE_ERR, 'DocumentType publicId is not a valid PubidLiteral');
39660
39759
  }
@@ -39686,13 +39785,27 @@ function requireDom () {
39686
39785
  return null;
39687
39786
 
39688
39787
  case PROCESSING_INSTRUCTION_NODE:
39689
- if (requireWellFormed && n.data.indexOf('?>') !== -1) {
39690
- throw new DOMException(INVALID_STATE_ERR, 'The ProcessingInstruction data contains "?>"');
39788
+ if (requireWellFormed) {
39789
+ if (!tagNamePattern.test(n.target) || n.target.indexOf(':') !== -1 || n.target.toLowerCase() === 'xml') {
39790
+ throw new DOMException(
39791
+ INVALID_STATE_ERR,
39792
+ 'The processing instruction target "' + n.target + '" is not a valid XML NCName or is reserved'
39793
+ );
39794
+ }
39795
+ if (n.data.indexOf('?>') !== -1) {
39796
+ throw new DOMException(INVALID_STATE_ERR, 'The ProcessingInstruction data contains "?>"');
39797
+ }
39691
39798
  }
39692
39799
  buf.push('<?', n.target, ' ', n.data, '?>');
39693
39800
  return null;
39694
39801
 
39695
39802
  case ENTITY_REFERENCE_NODE:
39803
+ if (requireWellFormed && !tagNamePattern.test(n.nodeName)) {
39804
+ throw new DOMException(
39805
+ INVALID_STATE_ERR,
39806
+ 'The entity reference name "' + n.nodeName + '" is not a valid XML Name'
39807
+ );
39808
+ }
39696
39809
  buf.push('&', n.nodeName, ';');
39697
39810
  return null;
39698
39811
 
@@ -42185,7 +42298,13 @@ function requireSax () {
42185
42298
  switch(source.charAt(tagStart+1)){
42186
42299
  case '/':
42187
42300
  var end = source.indexOf('>',tagStart+3);
42188
- var tagName = source.substring(tagStart + 2, end).replace(/[ \t\n\r]+$/g, '');
42301
+ // Anchored trailing-whitespace trim. The former `/[ \t\n\r]+$/g` backtracked
42302
+ // quadratically on a name shaped `whitespace-run + non-whitespace char`
42303
+ // (an end tag `</ … x>`): from every start position it extended `[ws]+`
42304
+ // to the end and then failed the `$` anchor. This anchored form matches the
42305
+ // whole string once and captures everything up to the last non-whitespace
42306
+ // character, so it trims in linear time with byte-identical output.
42307
+ var tagName = source.substring(tagStart + 2, end).replace(/^([\s\S]*?[^ \t\n\r])?[ \t\n\r]*$/, '$1');
42189
42308
  var config = parseStack.pop();
42190
42309
  if(end<0){
42191
42310
 
@@ -42196,6 +42315,14 @@ function requireSax () {
42196
42315
  tagName = tagName.replace(/[\s<].*/,'');
42197
42316
  errorHandler.error("end tag name: "+tagName+' maybe not complete');
42198
42317
  end = tagStart+1+tagName.length;
42318
+ }else if(/[ \t\n\r]/.test(tagName) && tagNamePattern.test(tagName.split(/[ \t\n\r]/)[0])){
42319
+ // The XML `ETag` production is `'</' Name S? '>'`: only optional whitespace may follow
42320
+ // the `Name`. A valid `Name` followed by whitespace and non-whitespace residue (e.g.
42321
+ // `</a\nbogus>` or `</a bogus>`) is not well-formed, but historically it was silently
42322
+ // accepted (the malformed end tag ignored, the residue dropped, the element left on the
42323
+ // stack). Report it as a recoverable `error` (which a custom errorHandler may escalate to
42324
+ // fatal) while keeping the existing recovery so the parsed DOM stays byte-identical.
42325
+ errorHandler.error('end tag name is followed by whitespace and trailing content: "'+tagName+'"');
42199
42326
  }
42200
42327
  var localNSMap = config.localNSMap;
42201
42328
  var endMatch = config.tagName == tagName;
@@ -42319,6 +42446,15 @@ function requireSax () {
42319
42446
  var s = S_TAG;//status
42320
42447
  while(true){
42321
42448
  var c = source.charAt(p);
42449
+ if (s === S_TAG && c === '<') {
42450
+ // A `<` can never occur inside a tag name. Without this guard the scan runs
42451
+ // on to the next `>` (or EOF) before the tag name is rejected, so a document
42452
+ // with many `<` inside a malformed tag makes each one-character recovery step
42453
+ // re-scan to the distant `>` — O(n^2). Stopping at the `<` keeps each recovery
42454
+ // step bounded. The candidate scanned so far is reported raw, consistent with
42455
+ // the sibling invalid-tag-name throw below.
42456
+ throw new Error('unexpected < in tag name: ' + source.slice(start, p));
42457
+ }
42322
42458
  switch(c){
42323
42459
  case '=':
42324
42460
  if(s === S_ATTR){//attrName
@@ -42511,9 +42647,13 @@ function requireSax () {
42511
42647
  if(nsPrefix !== false){//hack!!
42512
42648
  if(localNSMap == null){
42513
42649
  localNSMap = {};
42514
- //console.log(currentNSMap,0)
42515
- _copy(currentNSMap,currentNSMap={});
42516
- //console.log(currentNSMap,1)
42650
+ // Derive the child scope's namespace map by prototype-chain inheritance
42651
+ // instead of a flat copy: lookups inherit ancestor prefixes transparently,
42652
+ // so a document nesting N scopes retains O(N) map entries rather than
42653
+ // sum(1..N) = O(N^2). localNSMap stays a flat own-only record of the
42654
+ // prefixes declared at THIS element, so own-property enumeration
42655
+ // (endPrefixMapping below) still reports only local declarations.
42656
+ currentNSMap = Object.create(currentNSMap);
42517
42657
  }
42518
42658
  currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
42519
42659
  a.uri = NAMESPACE.XMLNS;
@@ -49552,7 +49692,7 @@ function requireMomentTimezone () {
49552
49692
  hasRequiredMomentTimezone = 1;
49553
49693
  (function (module) {
49554
49694
  //! moment-timezone.js
49555
- //! version : 0.6.3
49695
+ //! version : 0.6.6
49556
49696
  //! Copyright (c) JS Foundation and other contributors
49557
49697
  //! license : MIT
49558
49698
  //! github.com/moment/moment-timezone
@@ -49578,12 +49718,18 @@ function requireMomentTimezone () {
49578
49718
  // return moment;
49579
49719
  // }
49580
49720
 
49581
- var VERSION = "0.6.3",
49721
+ var VERSION = "0.6.6",
49582
49722
  zones = {},
49583
49723
  links = {},
49584
49724
  countries = {},
49585
49725
  names = {},
49586
49726
  guesses = {},
49727
+ parsingInZone = false,
49728
+ parsingNow,
49729
+ parsingNowFunction,
49730
+ hasParsingNow = false,
49731
+ ignoreDefaultZoneForInput,
49732
+ hasIgnoredDefaultZoneInput = false,
49587
49733
  cachedGuess;
49588
49734
 
49589
49735
  if (!moment || typeof moment.version !== 'string') {
@@ -49755,17 +49901,16 @@ function requireMomentTimezone () {
49755
49901
  offsets = this.offsets,
49756
49902
  untils = this.untils,
49757
49903
  max = untils.length - 1,
49758
- offset, offsetNext, offsetPrev, i;
49904
+ offset, offsetNext, i;
49759
49905
 
49760
49906
  for (i = 0; i < max; i++) {
49761
49907
  offset = offsets[i];
49762
49908
  offsetNext = offsets[i + 1];
49763
- offsetPrev = offsets[i ? i - 1 : i];
49764
49909
 
49765
49910
  if (offset < offsetNext && tz.moveAmbiguousForward) {
49766
49911
  offset = offsetNext;
49767
- } else if (offset > offsetPrev && tz.moveInvalidForward) {
49768
- offset = offsetPrev;
49912
+ } else if (offset > offsetNext && tz.moveInvalidForward) {
49913
+ offset = offsetNext;
49769
49914
  }
49770
49915
 
49771
49916
  if (target < untils[i] - (offset * 60000)) {
@@ -49790,6 +49935,15 @@ function requireMomentTimezone () {
49790
49935
  }
49791
49936
  };
49792
49937
 
49938
+ var utcDefaultZone = new Zone();
49939
+ utcDefaultZone._set({
49940
+ name : 'UTC',
49941
+ abbrs : ['UTC'],
49942
+ untils : [Infinity],
49943
+ offsets : [0],
49944
+ population : 0
49945
+ });
49946
+
49793
49947
  /************************************
49794
49948
  Country object
49795
49949
  ************************************/
@@ -49803,6 +49957,10 @@ function requireMomentTimezone () {
49803
49957
  Current Timezone
49804
49958
  ************************************/
49805
49959
 
49960
+ function hasOwnProp(a, b) {
49961
+ return Object.prototype.hasOwnProperty.call(a, b);
49962
+ }
49963
+
49806
49964
  function OffsetAt(at) {
49807
49965
  var timeString = at.toTimeString();
49808
49966
  var abbr = timeString.match(/\([a-z ]+\)/i);
@@ -49915,12 +50073,12 @@ function requireMomentTimezone () {
49915
50073
 
49916
50074
  for (i = 0; i < offsetsLength; i++) {
49917
50075
  offset = offsets[i].offset;
49918
- if (checkedOffsets.hasOwnProperty(offset)) {
50076
+ if (hasOwnProp(checkedOffsets, offset)) {
49919
50077
  continue;
49920
50078
  }
49921
50079
  guessesOffset = guesses[offset] || {};
49922
50080
  for (j in guessesOffset) {
49923
- if (guessesOffset.hasOwnProperty(j)) {
50081
+ if (hasOwnProp(guessesOffset, j)) {
49924
50082
  filteredGuesses[j] = true;
49925
50083
  }
49926
50084
  }
@@ -49928,7 +50086,7 @@ function requireMomentTimezone () {
49928
50086
  }
49929
50087
 
49930
50088
  for (i in filteredGuesses) {
49931
- if (filteredGuesses.hasOwnProperty(i)) {
50089
+ if (hasOwnProp(filteredGuesses, i)) {
49932
50090
  out.push(names[i]);
49933
50091
  }
49934
50092
  }
@@ -49983,7 +50141,7 @@ function requireMomentTimezone () {
49983
50141
  ************************************/
49984
50142
 
49985
50143
  function normalizeName (name) {
49986
- return (name || '').toLowerCase().replace(/\//g, '_');
50144
+ return (typeof name === 'string' ? name : '').toLowerCase().replace(/\//g, '_');
49987
50145
  }
49988
50146
 
49989
50147
  function addZone (packed) {
@@ -50007,7 +50165,7 @@ function requireMomentTimezone () {
50007
50165
 
50008
50166
  name = normalizeName(name);
50009
50167
 
50010
- var zone = zones[name];
50168
+ var zone = hasOwnProp(zones, name) ? zones[name] : undefined;
50011
50169
  var link;
50012
50170
 
50013
50171
  if (zone instanceof Zone) {
@@ -50021,7 +50179,7 @@ function requireMomentTimezone () {
50021
50179
  }
50022
50180
 
50023
50181
  // Pass getZone to prevent recursion more than 1 level deep
50024
- if (links[name] && caller !== getZone && (link = getZone(links[name], getZone))) {
50182
+ if (hasOwnProp(links, name) && caller !== getZone && (link = getZone(links[name], getZone))) {
50025
50183
  zone = zones[name] = new Zone();
50026
50184
  zone._set(link);
50027
50185
  zone.name = names[name];
@@ -50035,7 +50193,7 @@ function requireMomentTimezone () {
50035
50193
  var i, out = [];
50036
50194
 
50037
50195
  for (i in names) {
50038
- if (names.hasOwnProperty(i) && (zones[i] || zones[links[i]]) && names[i]) {
50196
+ if (hasOwnProp(names, i) && (zones[i] || zones[links[i]]) && names[i]) {
50039
50197
  out.push(names[i]);
50040
50198
  }
50041
50199
  }
@@ -50083,8 +50241,9 @@ function requireMomentTimezone () {
50083
50241
  }
50084
50242
 
50085
50243
  function getCountry (name) {
50244
+ if (typeof name !== 'string') return null;
50086
50245
  name = name.toUpperCase();
50087
- return countries[name] || null;
50246
+ return hasOwnProp(countries, name) ? countries[name] : null;
50088
50247
  }
50089
50248
 
50090
50249
  function zonesForCountry(country, with_offset) {
@@ -50127,6 +50286,85 @@ function requireMomentTimezone () {
50127
50286
  return !!(m._a && (m._tzm === undefined) && !isUnixTimestamp);
50128
50287
  }
50129
50288
 
50289
+ function isObjectInput (input) {
50290
+ var prop;
50291
+
50292
+ if (moment.isMoment(input) || input === null || Object.prototype.toString.call(input) !== '[object Object]') {
50293
+ return false;
50294
+ }
50295
+ if (Object.getOwnPropertyNames) {
50296
+ return Object.getOwnPropertyNames(input).length > 0;
50297
+ }
50298
+ for (prop in input) {
50299
+ if (hasOwnProp(input, prop)) {
50300
+ return true;
50301
+ }
50302
+ }
50303
+ return false;
50304
+ }
50305
+
50306
+ function parseWithZoneNow (args, name, stringInput) {
50307
+ var savedNow = moment.now,
50308
+ savedDefaultZone = moment.defaultZone,
50309
+ savedParsingInZone = parsingInZone,
50310
+ savedParsingNow = parsingNow,
50311
+ savedParsingNowFunction = parsingNowFunction,
50312
+ savedHasParsingNow = hasParsingNow,
50313
+ now,
50314
+ hasNow = false,
50315
+ zonedNow,
50316
+ wallNow,
50317
+ parsedDateParts,
50318
+ out;
50319
+
50320
+ if (!parsingInZone) {
50321
+ parsingNow = undefined;
50322
+ parsingNowFunction = savedNow;
50323
+ hasParsingNow = false;
50324
+ }
50325
+ parsingInZone = true;
50326
+ moment.now = function () {
50327
+ if (!hasNow) {
50328
+ if (!hasParsingNow) {
50329
+ parsingNow = parsingNowFunction.call(moment);
50330
+ hasParsingNow = true;
50331
+ }
50332
+ now = parsingNow;
50333
+ hasNow = true;
50334
+ zonedNow = moment.tz(now, name);
50335
+ wallNow = zonedNow.valueOf() + zonedNow.utcOffset() * 60000;
50336
+ }
50337
+ return wallNow;
50338
+ };
50339
+ if (stringInput) {
50340
+ moment.defaultZone = utcDefaultZone;
50341
+ }
50342
+ try {
50343
+ out = moment.utc.apply(null, args);
50344
+ if (stringInput && hasNow && out._a && out._tzm !== undefined) {
50345
+ parsedDateParts = out.parsingFlags().parsedDateParts;
50346
+ if (!parsedDateParts || parsedDateParts[0] == null || parsedDateParts[1] == null || parsedDateParts[2] == null) {
50347
+ moment.now = function () {
50348
+ return now;
50349
+ };
50350
+ moment.defaultZone = savedDefaultZone;
50351
+ out = moment.utc.apply(null, args);
50352
+ }
50353
+ }
50354
+ } finally {
50355
+ moment.now = savedNow;
50356
+ moment.defaultZone = savedDefaultZone;
50357
+ parsingInZone = savedParsingInZone;
50358
+ if (!savedParsingInZone) {
50359
+ parsingNow = savedParsingNow;
50360
+ parsingNowFunction = savedParsingNowFunction;
50361
+ hasParsingNow = savedHasParsingNow;
50362
+ }
50363
+ }
50364
+
50365
+ return out;
50366
+ }
50367
+
50130
50368
  function logError (message) {
50131
50369
  if (typeof console !== 'undefined' && typeof console.error === 'function') {
50132
50370
  console.error(message);
@@ -50140,10 +50378,13 @@ function requireMomentTimezone () {
50140
50378
  function tz (input) {
50141
50379
  var args = Array.prototype.slice.call(arguments, 0, -1),
50142
50380
  name = arguments[arguments.length - 1],
50143
- out = moment.utc.apply(null, args),
50144
- zone;
50381
+ objectInput = isObjectInput(input),
50382
+ stringInput = args.length > 0 && typeof input === 'string',
50383
+ zone = objectInput || stringInput ? getZone(name) : null,
50384
+ out = objectInput && zone ? parseWithZoneNow(args, name) :
50385
+ stringInput && zone ? parseWithZoneNow(args, name, true) : moment.utc.apply(null, args);
50145
50386
 
50146
- if (!moment.isMoment(input) && needsOffset(out) && (zone = getZone(name))) {
50387
+ if (!moment.isMoment(input) && needsOffset(out) && (zone || (!objectInput && (zone = getZone(name))))) {
50147
50388
  out.add(zone.parse(out), 'minutes');
50148
50389
  }
50149
50390
 
@@ -50183,10 +50424,49 @@ function requireMomentTimezone () {
50183
50424
  moment.tz = tz;
50184
50425
 
50185
50426
  moment.defaultZone = null;
50427
+ var momentGetDefaultDateParts = moment._getDefaultDateParts;
50428
+ if (momentGetDefaultDateParts) {
50429
+ moment._getDefaultDateParts = function (config, now, forWeek) {
50430
+ var zone = moment.defaultZone,
50431
+ zonedNow,
50432
+ dateParts,
50433
+ savedIgnoredInput,
50434
+ savedHasIgnoredInput;
50435
+ forWeek = forWeek || config._isDefaultDatePartsForWeek;
50436
+
50437
+ if (parsingInZone && config._tzm === undefined) {
50438
+ zonedNow = new Date(now);
50439
+ return [zonedNow.getUTCFullYear(), zonedNow.getUTCMonth(), zonedNow.getUTCDate()];
50440
+ }
50441
+
50442
+ if (zone && !config._useUTC && config._tzm === undefined) {
50443
+ zonedNow = new Date(now - zone.utcOffset(now) * 60000);
50444
+ return [zonedNow.getUTCFullYear(), zonedNow.getUTCMonth(), zonedNow.getUTCDate()];
50445
+ }
50446
+
50447
+ if (forWeek && (config._useUTC || config._tzm !== undefined)) {
50448
+ savedIgnoredInput = ignoreDefaultZoneForInput;
50449
+ savedHasIgnoredInput = hasIgnoredDefaultZoneInput;
50450
+ ignoreDefaultZoneForInput = now;
50451
+ hasIgnoredDefaultZoneInput = true;
50452
+ try {
50453
+ dateParts = momentGetDefaultDateParts.call(this, config, now, forWeek);
50454
+ } finally {
50455
+ ignoreDefaultZoneForInput = savedIgnoredInput;
50456
+ hasIgnoredDefaultZoneInput = savedHasIgnoredInput;
50457
+ }
50458
+ return dateParts;
50459
+ }
50460
+
50461
+ return momentGetDefaultDateParts.call(this, config, now, forWeek);
50462
+ };
50463
+ }
50186
50464
 
50187
50465
  moment.updateOffset = function (mom, keepTime) {
50188
- var zone = moment.defaultZone,
50189
- offset;
50466
+ var zone = hasIgnoredDefaultZoneInput && ignoreDefaultZoneForInput === mom._i ? null : moment.defaultZone,
50467
+ offset,
50468
+ localTimestamp,
50469
+ normalizedTimestamp;
50190
50470
 
50191
50471
  if (mom._z === undefined) {
50192
50472
  if (zone && needsOffset(mom) && !mom._isUTC && mom.isValid()) {
@@ -50197,6 +50477,20 @@ function requireMomentTimezone () {
50197
50477
  }
50198
50478
  if (mom._z) {
50199
50479
  offset = mom._z.utcOffset(mom);
50480
+ if (keepTime) {
50481
+ // Resolve local times inside a forward gap using the configured
50482
+ // invalid-input policy before applying the new offset.
50483
+ localTimestamp = mom._d.valueOf();
50484
+ if (!mom._isUTC) {
50485
+ localTimestamp -= mom._d.getTimezoneOffset() * 60000;
50486
+ }
50487
+ if (mom._z.utcOffset(localTimestamp + offset * 60000) !== offset) {
50488
+ offset = mom._z.parse(localTimestamp);
50489
+ localTimestamp += offset * 60000;
50490
+ offset = mom._z.utcOffset(localTimestamp);
50491
+ normalizedTimestamp = localTimestamp - offset * 60000;
50492
+ }
50493
+ }
50200
50494
  if (Math.abs(offset) < 16) {
50201
50495
  offset = offset / 60;
50202
50496
  }
@@ -50207,6 +50501,9 @@ function requireMomentTimezone () {
50207
50501
  } else {
50208
50502
  mom.zone(offset, keepTime);
50209
50503
  }
50504
+ if (normalizedTimestamp != null) {
50505
+ mom._d.setTime(normalizedTimestamp);
50506
+ }
50210
50507
  }
50211
50508
  };
50212
50509