1/* eslint-disable */ 2;(function() { 3 4 if (typeof window.BX === 'function') 5 { 6 return; 7 } 8 9/** 10 * Babel external helpers 11 * (c) 2018 Babel 12 * @license MIT 13 */ 14(function (global) { 15 var babelHelpers = global.babelHelpers = {}; 16 17 function _typeof(obj) { 18 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 19 babelHelpers.typeof = _typeof = function (obj) { 20 return typeof obj; 21 }; 22 } else { 23 babelHelpers.typeof = _typeof = function (obj) { 24 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 25 }; 26 } 27 28 return _typeof(obj); 29 } 30 31 babelHelpers.typeof = _typeof; 32 var REACT_ELEMENT_TYPE; 33 34 function _createRawReactElement(type, props, key, children) { 35 if (!REACT_ELEMENT_TYPE) { 36 REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; 37 } 38 39 var defaultProps = type && type.defaultProps; 40 var childrenLength = arguments.length - 3; 41 42 if (!props && childrenLength !== 0) { 43 props = { 44 children: void 0 45 }; 46 } 47 48 if (props && defaultProps) { 49 for (var propName in defaultProps) { 50 if (props[propName] === void 0) { 51 props[propName] = defaultProps[propName]; 52 } 53 } 54 } else if (!props) { 55 props = defaultProps || {}; 56 } 57 58 if (childrenLength === 1) { 59 props.children = children; 60 } else if (childrenLength > 1) { 61 var childArray = new Array(childrenLength); 62 63 for (var i = 0; i < childrenLength; i++) { 64 childArray[i] = arguments[i + 3]; 65 } 66 67 props.children = childArray; 68 } 69 70 return { 71 $$typeof: REACT_ELEMENT_TYPE, 72 type: type, 73 key: key === undefined ? null : '' + key, 74 ref: null, 75 props: props, 76 _owner: null 77 }; 78 } 79 80 babelHelpers.jsx = _createRawReactElement; 81 82 function _asyncIterator(iterable) { 83 var method; 84 85 if (typeof Symbol === "function") { 86 if (Symbol.asyncIterator) { 87 method = iterable[Symbol.asyncIterator]; 88 if (method != null) return method.call(iterable); 89 } 90 91 if (Symbol.iterator) { 92 method = iterable[Symbol.iterator]; 93 if (method != null) return method.call(iterable); 94 } 95 } 96 97 throw new TypeError("Object is not async iterable"); 98 } 99 100 babelHelpers.asyncIterator = _asyncIterator; 101 102 function _AwaitValue(value) { 103 this.wrapped = value; 104 } 105 106 babelHelpers.AwaitValue = _AwaitValue; 107 108 function AsyncGenerator(gen) { 109 var front, back; 110 111 function send(key, arg) { 112 return new Promise(function (resolve, reject) { 113 var request = { 114 key: key, 115 arg: arg, 116 resolve: resolve, 117 reject: reject, 118 next: null 119 }; 120 121 if (back) { 122 back = back.next = request; 123 } else { 124 front = back = request; 125 resume(key, arg); 126 } 127 }); 128 } 129 130 function resume(key, arg) { 131 try { 132 var result = gen[key](arg); 133 var value = result.value; 134 var wrappedAwait = value instanceof babelHelpers.AwaitValue; 135 Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { 136 if (wrappedAwait) { 137 resume("next", arg); 138 return; 139 } 140 141 settle(result.done ? "return" : "normal", arg); 142 }, function (err) { 143 resume("throw", err); 144 }); 145 } catch (err) { 146 settle("throw", err); 147 } 148 } 149 150 function settle(type, value) { 151 switch (type) { 152 case "return": 153 front.resolve({ 154 value: value, 155 done: true 156 }); 157 break; 158 159 case "throw": 160 front.reject(value); 161 break; 162 163 default: 164 front.resolve({ 165 value: value, 166 done: false 167 }); 168 break; 169 } 170 171 front = front.next; 172 173 if (front) { 174 resume(front.key, front.arg); 175 } else { 176 back = null; 177 } 178 } 179 180 this._invoke = send; 181 182 if (typeof gen.return !== "function") { 183 this.return = undefined; 184 } 185 } 186 187 if (typeof Symbol === "function" && Symbol.asyncIterator) { 188 AsyncGenerator.prototype[Symbol.asyncIterator] = function () { 189 return this; 190 }; 191 } 192 193 AsyncGenerator.prototype.next = function (arg) { 194 return this._invoke("next", arg); 195 }; 196 197 AsyncGenerator.prototype.throw = function (arg) { 198 return this._invoke("throw", arg); 199 }; 200 201 AsyncGenerator.prototype.return = function (arg) { 202 return this._invoke("return", arg); 203 }; 204 205 babelHelpers.AsyncGenerator = AsyncGenerator; 206 207 function _wrapAsyncGenerator(fn) { 208 return function () { 209 return new babelHelpers.AsyncGenerator(fn.apply(this, arguments)); 210 }; 211 } 212 213 babelHelpers.wrapAsyncGenerator = _wrapAsyncGenerator; 214 215 function _awaitAsyncGenerator(value) { 216 return new babelHelpers.AwaitValue(value); 217 } 218 219 babelHelpers.awaitAsyncGenerator = _awaitAsyncGenerator; 220 221 function _asyncGeneratorDelegate(inner, awaitWrap) { 222 var iter = {}, 223 waiting = false;
224 225 function pump(key, value) { 226 waiting = true; 227 value = new Promise(function (resolve) { 228 resolve(inner[key](value)); 229 }); 230 return { 231 done: false, 232 value: awaitWrap(value) 233 }; 234 } 235 236 ; 237 238 if (typeof Symbol === "function" && Symbol.iterator) { 239 iter[Symbol.iterator] = function () { 240 return this; 241 }; 242 } 243 244 iter.next = function (value) { 245 if (waiting) { 246 waiting = false; 247 return value; 248 } 249 250 return pump("next", value); 251 }; 252 253 if (typeof inner.throw === "function") { 254 iter.throw = function (value) { 255 if (waiting) { 256 waiting = false; 257 throw value; 258 } 259 260 return pump("throw", value); 261 }; 262 } 263 264 if (typeof inner.return === "function") { 265 iter.return = function (value) { 266 return pump("return", value); 267 }; 268 } 269 270 return iter; 271 } 272 273 babelHelpers.asyncGeneratorDelegate = _asyncGeneratorDelegate; 274 275 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { 276 try { 277 var info = gen[key](arg); 278 var value = info.value; 279 } catch (error) { 280 reject(error); 281 return; 282 } 283 284 if (info.done) { 285 resolve(value); 286 } else { 287 Promise.resolve(value).then(_next, _throw); 288 } 289 } 290 291 function _asyncToGenerator(fn) { 292 return function () { 293 var self = this, 294 args = arguments; 295 return new Promise(function (resolve, reject) { 296 var gen = fn.apply(self, args); 297 298 function _next(value) { 299 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); 300 } 301 302 function _throw(err) { 303 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); 304 } 305 306 _next(undefined); 307 }); 308 }; 309 } 310 311 babelHelpers.asyncToGenerator = _asyncToGenerator; 312 313 function _classCallCheck(instance, Constructor) { 314 if (!(instance instanceof Constructor)) { 315 throw new TypeError("Cannot call a class as a function"); 316 } 317 } 318 319 babelHelpers.classCallCheck = _classCallCheck; 320 321 function _defineProperties(target, props) { 322 for (var i = 0; i < props.length; i++) { 323 var descriptor = props[i]; 324 descriptor.enumerable = descriptor.enumerable || false; 325 descriptor.configurable = true; 326 if ("value" in descriptor) descriptor.writable = true; 327 Object.defineProperty(target, descriptor.key, descriptor); 328 } 329 } 330 331 function _createClass(Constructor, protoProps, staticProps) { 332 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 333 if (staticProps) _defineProperties(Constructor, staticProps); 334 return Constructor; 335 } 336 337 babelHelpers.createClass = _createClass; 338 339 function _defineEnumerableProperties(obj, descs) { 340 for (var key in descs) { 341 var desc = descs[key]; 342 desc.configurable = desc.enumerable = true; 343 if ("value" in desc) desc.writable = true; 344 Object.defineProperty(obj, key, desc); 345 } 346 347 if (Object.getOwnPropertySymbols) { 348 var objectSymbols = Object.getOwnPropertySymbols(descs); 349 350 for (var i = 0; i < objectSymbols.length; i++) { 351 var sym = objectSymbols[i]; 352 var desc = descs[sym]; 353 desc.configurable = desc.enumerable = true; 354 if ("value" in desc) desc.writable = true; 355 Object.defineProperty(obj, sym, desc); 356 } 357 } 358 359 return obj; 360 } 361 362 babelHelpers.defineEnumerableProperties = _defineEnumerableProperties; 363 364 function _defaults(obj, defaults) { 365 var keys = Object.getOwnPropertyNames(defaults); 366 367 for (var i = 0; i < keys.length; i++) { 368 var key = keys[i]; 369 var value = Object.getOwnPropertyDescriptor(defaults, key); 370 371 if (value && value.configurable && obj[key] === undefined) { 372 Object.defineProperty(obj, key, value); 373 } 374 } 375 376 return obj; 377 } 378 379 babelHelpers.defaults = _defaults; 380 381 function _defineProperty(obj, key, value) { 382 if (key in obj) { 383 Object.defineProperty(obj, key, { 384 value: value, 385 enumerable: true, 386 configurable: true, 387 writable: true 388 }); 389 } else { 390 obj[key] = value; 391 } 392 393 return obj; 394 } 395 396 babelHelpers.defineProperty = _defineProperty; 397 398 function _extends() { 399 babelHelpers.extends = _extends = Object.assign || function (target) { 400 for (var i = 1; i < arguments.length; i++) { 401 var source = arguments[i]; 402 403 for (var key in source) { 404 if (Object.prototype.hasOwnProperty.call(source, key)) { 405 target[key] = source[key]; 406 } 407 } 408 } 409 410 return target; 411 }; 412 413 return _extends.apply(this, arguments); 414 } 415 416 babelHelpers.extends = _extends; 417 418 function _objectSpread(target) { 419 for (var i = 1; i < arguments.length; i++) { 420 var source = arguments[i] != null ? arguments[i] : {}; 421 var ownKeys = Object.keys(source); 422 423 if (typeof Object.getOwnPropertySymbols === 'function') { 424 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { 425 return Object.getOwnPropertyDescriptor(source, sym).enumerable; 426 })); 427 } 428 429 ownKeys.forEach(function (key) { 430 babelHelpers.defineProperty(target, key, source[key]); 431 }); 432 } 433 434 return target; 435 } 436 437 babelHelpers.objectSpread = _objectSpread; 438 439 function _inherits(subClass, superClass) { 440 if (typeof superClass !== "function" && superClass !== null) { 441 throw new TypeError("Super expression must either be null or a function"); 442 } 443 444 subClass.prototype = Object.create(superClass && superClass.prototype, { 445 constructor: { 446 value: subClass, 447 writable: true, 448 configurable: true 449 } 450 }); 451 if (superClass) babelHelpers.setPrototypeOf(subClass, superClass); 452 } 453 454 babelHelpers.inherits = _inherits; 455 456 function _inheritsLoose(subClass, superClass) { 457 subClass.prototype = Object.create(superClass.prototype); 458 subClass.prototype.constructor = subClass; 459 subClass.__proto__ = superClass; 460 } 461 462 babelHelpers.inheritsLoose = _inheritsLoose; 463
464 function _getPrototypeOf(o) { 465 babelHelpers.getPrototypeOf = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { 466 return o.__proto__ || Object.getPrototypeOf(o); 467 }; 468 return _getPrototypeOf(o); 469 } 470 471 babelHelpers.getPrototypeOf = _getPrototypeOf; 472 473 function _setPrototypeOf(o, p) { 474 babelHelpers.setPrototypeOf = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { 475 o.__proto__ = p; 476 return o; 477 }; 478 479 return _setPrototypeOf(o, p); 480 } 481 482 babelHelpers.setPrototypeOf = _setPrototypeOf; 483 484 function isNativeReflectConstruct() { 485 if (typeof Reflect === "undefined" || !Reflect.construct) return false; 486 if (Reflect.construct.sham) return false; 487 if (typeof Proxy === "function") return true; 488 489 try { 490 Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); 491 return true; 492 } catch (e) { 493 return false; 494 } 495 } 496 497 function _construct(Parent, args, Class) { 498 if (isNativeReflectConstruct()) { 499 babelHelpers.construct = _construct = Reflect.construct; 500 } else { 501 babelHelpers.construct = _construct = function _construct(Parent, args, Class) { 502 var a = [null]; 503 a.push.apply(a, args); 504 var Constructor = Function.bind.apply(Parent, a); 505 var instance = new Constructor(); 506 if (Class) babelHelpers.setPrototypeOf(instance, Class.prototype); 507 return instance; 508 }; 509 } 510 511 return _construct.apply(null, arguments); 512 } 513 514 babelHelpers.construct = _construct; 515 516 function _isNativeFunction(fn) { 517 return Function.toString.call(fn).indexOf("[native code]") !== -1; 518 } 519 520 babelHelpers.isNativeFunction = _isNativeFunction; 521 522 function _wrapNativeSuper(Class) { 523 var _cache = typeof Map === "function" ? new Map() : undefined; 524 525 babelHelpers.wrapNativeSuper = _wrapNativeSuper = function _wrapNativeSuper(Class) { 526 if (Class === null || !babelHelpers.isNativeFunction(Class)) return Class; 527 528 if (typeof Class !== "function") { 529 throw new TypeError("Super expression must either be null or a function"); 530 } 531 532 if (typeof _cache !== "undefined") { 533 if (_cache.has(Class)) return _cache.get(Class); 534 535 _cache.set(Class, Wrapper); 536 } 537 538 function Wrapper() { 539 return babelHelpers.construct(Class, arguments, babelHelpers.getPrototypeOf(this).constructor); 540 } 541 542 Wrapper.prototype = Object.create(Class.prototype, { 543 constructor: { 544 value: Wrapper, 545 enumerable: false, 546 writable: true, 547 configurable: true 548 } 549 }); 550 return babelHelpers.setPrototypeOf(Wrapper, Class); 551 }; 552 553 return _wrapNativeSuper(Class); 554 } 555 556 babelHelpers.wrapNativeSuper = _wrapNativeSuper; 557 558 function _instanceof(left, right) { 559 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { 560 return right[Symbol.hasInstance](left); 561 } else { 562 return left instanceof right; 563 } 564 } 565 566 babelHelpers.instanceof = _instanceof; 567 568 function _interopRequireDefault(obj) { 569 return obj && obj.__esModule ? obj : { 570 default: obj 571 }; 572 } 573 574 babelHelpers.interopRequireDefault = _interopRequireDefault; 575 576 function _interopRequireWildcard(obj) { 577 if (obj && obj.__esModule) { 578 return obj; 579 } else { 580 var newObj = {}; 581 582 if (obj != null) { 583 for (var key in obj) { 584 if (Object.prototype.hasOwnProperty.call(obj, key)) { 585 var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; 586 587 if (desc.get || desc.set) { 588 Object.defineProperty(newObj, key, desc); 589 } else { 590 newObj[key] = obj[key]; 591 } 592 } 593 } 594 } 595 596 newObj.default = obj; 597 return newObj; 598 } 599 } 600 601 babelHelpers.interopRequireWildcard = _interopRequireWildcard; 602 603 function _newArrowCheck(innerThis, boundThis) { 604 if (innerThis !== boundThis) { 605 throw new TypeError("Cannot instantiate an arrow function"); 606 } 607 } 608 609 babelHelpers.newArrowCheck = _newArrowCheck; 610 611 function _objectDestructuringEmpty(obj) { 612 if (obj == null) throw new TypeError("Cannot destructure undefined"); 613 } 614 615 babelHelpers.objectDestructuringEmpty = _objectDestructuringEmpty; 616 617 function _objectWithoutPropertiesLoose(source, excluded) { 618 if (source == null) return {}; 619 var target = {}; 620 var sourceKeys = Object.keys(source); 621 var key, i; 622 623 for (i = 0; i < sourceKeys.length; i++) { 624 key = sourceKeys[i]; 625 if (excluded.indexOf(key) >= 0) continue; 626 target[key] = source[key]; 627 } 628 629 return target; 630 } 631 632 babelHelpers.objectWithoutPropertiesLoose = _objectWithoutPropertiesLoose; 633 634 function _objectWithoutProperties(source, excluded) { 635 if (source == null) return {}; 636 var target = babelHelpers.objectWithoutPropertiesLoose(source, excluded); 637 var key, i; 638 639 if (Object.getOwnPropertySymbols) { 640 var sourceSymbolKeys = Object.getOwnPropertySymbols(source); 641 642 for (i = 0; i < sourceSymbolKeys.length; i++) { 643 key = sourceSymbolKeys[i]; 644 if (excluded.indexOf(key) >= 0) continue; 645 if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; 646 target[key] = source[key]; 647 } 648 } 649 650 return target; 651 } 652 653 babelHelpers.objectWithoutProperties = _objectWithoutProperties; 654 655 function _assertThisInitialized(self) { 656 if (self === void 0) { 657 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 658 } 659 660 return self; 661 } 662 663 babelHelpers.assertThisInitialized = _assertThisInitialized; 664 665 function _possibleConstructorReturn(self, call) { 666 if (call && (typeof call === "object" || typeof call === "function")) { 667 return call; 668 } 669 670 return babelHelpers.assertThisInitialized(self); 671 } 672 673 babelHelpers.possibleConstructorReturn = _possibleConstructorReturn; 674 675 function _superPropBase(object, property) { 676 while (!Object.prototype.hasOwnProperty.call(object, property)) { 677 object = babelHelpers.getPrototypeOf(object); 678 if (object === null) break; 679 } 680 681 return object; 682 } 683 684 babelHelpers.superPropBase = _superPropBase; 685 686 function _get(target, property, receiver) { 687 if (typeof Reflect !== "undefined" && Reflect.get) { 688 babelHelpers.get = _get = Reflect.get; 689 } else { 690 babelHelpers.get = _get = function _get(target, property, receiver) { 691 var base = babelHelpers.superPropBase(target, property); 692 if (!base) return; 693 var desc = Object.getOwnPropertyDescriptor(base, property); 694 695 if (desc.get) { 696 return desc.get.call(receiver); 697 } 698 699 return desc.value; 700 }; 701 } 702 703 return _get(target, property, receiver || target); 704 } 705 706 babelHelpers.get = _get; 707 708 function set(target, property, value, receiver) { 709 if (typeof Reflect !== "undefined" && Reflect.set) { 710 set = Reflect.set; 711 } else { 712 set = function set(target, property, value, receiver) { 713 var base = babelHelpers.superPropBase(target, property); 714 var desc; 715 716 if (base) { 717 desc = Object.getOwnPropertyDescriptor(base, property); 718 719 if (desc.set) { 720 desc.set.call(receiver, value); 721 return true; 722 } else if (!desc.writable) { 723 return false;
724 } 725 } 726 727 desc = Object.getOwnPropertyDescriptor(receiver, property); 728 729 if (desc) { 730 if (!desc.writable) { 731 return false; 732 } 733 734 desc.value = value; 735 Object.defineProperty(receiver, property, desc); 736 } else { 737 babelHelpers.defineProperty(receiver, property, value); 738 } 739 740 return true; 741 }; 742 } 743 744 return set(target, property, value, receiver); 745 } 746 747 function _set(target, property, value, receiver, isStrict) { 748 var s = set(target, property, value, receiver || target); 749 750 if (!s && isStrict) { 751 throw new Error('failed to set property'); 752 } 753 754 return value; 755 } 756 757 babelHelpers.set = _set; 758 759 function _taggedTemplateLiteral(strings, raw) { 760 if (!raw) { 761 raw = strings.slice(0); 762 } 763 764 return Object.freeze(Object.defineProperties(strings, { 765 raw: { 766 value: Object.freeze(raw) 767 } 768 })); 769 } 770 771 babelHelpers.taggedTemplateLiteral = _taggedTemplateLiteral; 772 773 function _taggedTemplateLiteralLoose(strings, raw) { 774 if (!raw) { 775 raw = strings.slice(0); 776 } 777 778 strings.raw = raw; 779 return strings; 780 } 781 782 babelHelpers.taggedTemplateLiteralLoose = _taggedTemplateLiteralLoose; 783 784 function _temporalRef(val, name) { 785 if (val === babelHelpers.temporalUndefined) { 786 throw new ReferenceError(name + " is not defined - temporal dead zone"); 787 } else { 788 return val; 789 } 790 } 791 792 babelHelpers.temporalRef = _temporalRef; 793 794 function _readOnlyError(name) { 795 throw new Error("\"" + name + "\" is read-only"); 796 } 797 798 babelHelpers.readOnlyError = _readOnlyError; 799 800 function _classNameTDZError(name) { 801 throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); 802 } 803 804 babelHelpers.classNameTDZError = _classNameTDZError; 805 babelHelpers.temporalUndefined = {}; 806 807 function _slicedToArray(arr, i) { 808 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArrayLimit(arr, i) || babelHelpers.nonIterableRest(); 809 } 810 811 babelHelpers.slicedToArray = _slicedToArray; 812 813 function _slicedToArrayLoose(arr, i) { 814 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArrayLimitLoose(arr, i) || babelHelpers.nonIterableRest(); 815 } 816 817 babelHelpers.slicedToArrayLoose = _slicedToArrayLoose; 818 819 function _toArray(arr) { 820 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArray(arr) || babelHelpers.nonIterableRest(); 821 } 822 823 babelHelpers.toArray = _toArray; 824 825 function _toConsumableArray(arr) { 826 return babelHelpers.arrayWithoutHoles(arr) || babelHelpers.iterableToArray(arr) || babelHelpers.nonIterableSpread(); 827 } 828 829 babelHelpers.toConsumableArray = _toConsumableArray; 830 831 function _arrayWithoutHoles(arr) { 832 if (Array.isArray(arr)) { 833 for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; 834 835 return arr2; 836 } 837 } 838 839 babelHelpers.arrayWithoutHoles = _arrayWithoutHoles; 840 841 function _arrayWithHoles(arr) { 842 if (Array.isArray(arr)) return arr; 843 } 844 845 babelHelpers.arrayWithHoles = _arrayWithHoles; 846 847 function _iterableToArray(iter) { 848 if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); 849 } 850 851 babelHelpers.iterableToArray = _iterableToArray; 852 853 function _iterableToArrayLimit(arr, i) { 854 var _arr = []; 855 var _n = true; 856 var _d = false; 857 var _e = undefined; 858 859 try { 860 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { 861 _arr.push(_s.value); 862 863 if (i && _arr.length === i) break; 864 } 865 } catch (err) { 866 _d = true; 867 _e = err; 868 } finally { 869 try { 870 if (!_n && _i["return"] != null) _i["return"](); 871 } finally { 872 if (_d) throw _e; 873 } 874 } 875 876 return _arr; 877 } 878 879 babelHelpers.iterableToArrayLimit = _iterableToArrayLimit; 880 881 function _iterableToArrayLimitLoose(arr, i) { 882 var _arr = []; 883 884 for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { 885 _arr.push(_step.value); 886 887 if (i && _arr.length === i) break; 888 } 889 890 return _arr; 891 } 892 893 babelHelpers.iterableToArrayLimitLoose = _iterableToArrayLimitLoose; 894 895 function _nonIterableSpread() { 896 throw new TypeError("Invalid attempt to spread non-iterable instance"); 897 } 898 899 babelHelpers.nonIterableSpread = _nonIterableSpread; 900 901 function _nonIterableRest() {
902 throw new TypeError("Invalid attempt to destructure non-iterable instance"); 903 } 904 905 babelHelpers.nonIterableRest = _nonIterableRest; 906 907 function _skipFirstGeneratorNext(fn) { 908 return function () { 909 var it = fn.apply(this, arguments); 910 it.next(); 911 return it; 912 }; 913 } 914 915 babelHelpers.skipFirstGeneratorNext = _skipFirstGeneratorNext; 916 917 function _toPropertyKey(key) { 918 if (typeof key === "symbol") { 919 return key; 920 } else { 921 return String(key); 922 } 923 } 924 925 babelHelpers.toPropertyKey = _toPropertyKey; 926 927 function _initializerWarningHelper(descriptor, context) { 928 throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and set to use loose mode. ' + 'To use proposal-class-properties in spec mode with decorators, wait for ' + 'the next major version of decorators in stage 2.'); 929 } 930 931 babelHelpers.initializerWarningHelper = _initializerWarningHelper; 932 933 function _initializerDefineProperty(target, property, descriptor, context) { 934 if (!descriptor) return; 935 Object.defineProperty(target, property, { 936 enumerable: descriptor.enumerable, 937 configurable: descriptor.configurable, 938 writable: descriptor.writable, 939 value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 940 }); 941 } 942 943 babelHelpers.initializerDefineProperty = _initializerDefineProperty; 944 945 function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { 946 var desc = {}; 947 Object['ke' + 'ys'](descriptor).forEach(function (key) { 948 desc[key] = descriptor[key]; 949 }); 950 desc.enumerable = !!desc.enumerable; 951 desc.configurable = !!desc.configurable; 952 953 if ('value' in desc || desc.initializer) { 954 desc.writable = true; 955 } 956 957 desc = decorators.slice().reverse().reduce(function (desc, decorator) { 958 return decorator(target, property, desc) || desc; 959 }, desc); 960 961 if (context && desc.initializer !== void 0) { 962 desc.value = desc.initializer ? desc.initializer.call(context) : void 0; 963 desc.initializer = undefined; 964 } 965 966 if (desc.initializer === void 0) { 967 Object['define' + 'Property'](target, property, desc); 968 desc = null; 969 } 970 971 return desc; 972 } 973 974 babelHelpers.applyDecoratedDescriptor = _applyDecoratedDescriptor; 975 var id = 0; 976 977 function _classPrivateFieldKey(name) { 978 return "__private_" + id++ + "_" + name; 979 } 980 981 babelHelpers.classPrivateFieldLooseKey = _classPrivateFieldKey; 982 983 function _classPrivateFieldBase(receiver, privateKey) { 984 if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { 985 throw new TypeError("attempted to use private field on non-instance"); 986 } 987 988 return receiver; 989 } 990 991 babelHelpers.classPrivateFieldLooseBase = _classPrivateFieldBase; 992 993 function _classPrivateFieldGet(receiver, privateMap) { 994 if (!privateMap.has(receiver)) { 995 throw new TypeError("attempted to get private field on non-instance"); 996 } 997 998 return privateMap.get(receiver).value; 999 } 1000 1001 babelHelpers.classPrivateFieldGet = _classPrivateFieldGet; 1002 1003 function _classPrivateFieldSet(receiver, privateMap, value) { 1004 if (!privateMap.has(receiver)) { 1005 throw new TypeError("attempted to set private field on non-instance"); 1006 } 1007 1008 var descriptor = privateMap.get(receiver); 1009 1010 if (!descriptor.writable) { 1011 throw new TypeError("attempted to set read only private field"); 1012 } 1013 1014 descriptor.value = value; 1015 return value; 1016 } 1017 1018 babelHelpers.classPrivateFieldSet = _classPrivateFieldSet; 1019})(typeof global === "undefined" ? window : global); 1020 1021/** 1022 * Copyright (c) 2014-present, Facebook, Inc. 1023 * 1024 * This source code is licensed under the MIT license found in the 1025 * LICENSE file in the root directory of this source tree. 1026 */ 1027 1028!(function(global) { 1029 "use strict"; 1030 1031 var Op = Object.prototype; 1032 var hasOwn = Op.hasOwnProperty; 1033 var undefined; // More compressible than void 0. 1034 var $Symbol = typeof Symbol === "function" ? Symbol : {}; 1035 var iteratorSymbol = $Symbol.iterator || "@@iterator"; 1036 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; 1037 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; 1038 1039 // Define the runtime globally (as expected by generated code) as either 1040 // module.exports (if we're in a module) or a new, empty object. 1041 var runtime = global.regeneratorRuntime = {}; 1042 1043 function wrap(innerFn, outerFn, self, tryLocsList) { 1044 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. 1045 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; 1046 var generator = Object.create(protoGenerator.prototype); 1047 var context = new Context(tryLocsList || []); 1048 1049 // The ._invoke method unifies the implementations of the .next, 1050 // .throw, and .return methods. 1051 generator._invoke = makeInvokeMethod(innerFn, self, context); 1052 1053 return generator; 1054 } 1055 runtime.wrap = wrap; 1056 1057 // Try/catch helper to minimize deoptimizations. Returns a completion 1058 // record like context.tryEntries[i].completion. This interface could
vendor: 10,591 bytes, lines 1059-1352
1059 // have been (and was previously) designed to take a closure to be 1060 // invoked without arguments, but in all the cases we care about we 1061 // already have an existing method we want to call, so there's no need 1062 // to create a new function object. We can even get away with assuming 1063 // the method takes exactly one argument, since that happens to be true 1064 // in every case, so we don't have to touch the arguments object. The 1065 // only additional allocation required is the completion record, which 1066 // has a stable shape and so hopefully should be cheap to allocate. 1067 function tryCatch(fn, obj, arg) { 1068 try { 1069 return { type: "normal", arg: fn.call(obj, arg) }; 1070 } catch (err) { 1071 return { type: "throw", arg: err }; 1072 } 1073 } 1074 1075 var GenStateSuspendedStart = "suspendedStart"; 1076 var GenStateSuspendedYield = "suspendedYield"; 1077 var GenStateExecuting = "executing"; 1078 var GenStateCompleted = "completed"; 1079 1080 // Returning this object from the innerFn has the same effect as 1081 // breaking out of the dispatch switch statement. 1082 var ContinueSentinel = {}; 1083 1084 // Dummy constructor functions that we use as the .constructor and 1085 // .constructor.prototype properties for functions that return Generator 1086 // objects. For full spec compliance, you may wish to configure your 1087 // minifier not to mangle the names of these two functions. 1088 function Generator() {} 1089 function GeneratorFunction() {} 1090 function GeneratorFunctionPrototype() {} 1091 1092 // This is a polyfill for %IteratorPrototype% for environments that 1093 // don't natively support it. 1094 var IteratorPrototype = {}; 1095 IteratorPrototype[iteratorSymbol] = function () { 1096 return this; 1097 }; 1098 1099 var getProto = Object.getPrototypeOf; 1100 var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); 1101 if (NativeIteratorPrototype && 1102 NativeIteratorPrototype !== Op && 1103 hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { 1104 // This environment has a native %IteratorPrototype%; use it instead 1105 // of the polyfill. 1106 IteratorPrototype = NativeIteratorPrototype; 1107 } 1108 1109 var Gp = GeneratorFunctionPrototype.prototype = 1110 Generator.prototype = Object.create(IteratorPrototype); 1111 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; 1112 GeneratorFunctionPrototype.constructor = GeneratorFunction; 1113 GeneratorFunctionPrototype[toStringTagSymbol] = 1114 GeneratorFunction.displayName = "GeneratorFunction"; 1115 1116 // Helper for defining the .next, .throw, and .return methods of the 1117 // Iterator interface in terms of a single ._invoke method. 1118 function defineIteratorMethods(prototype) { 1119 ["next", "throw", "return"].forEach(function(method) { 1120 prototype[method] = function(arg) { 1121 return this._invoke(method, arg); 1122 }; 1123 }); 1124 } 1125 1126 runtime.isGeneratorFunction = function(genFun) { 1127 var ctor = typeof genFun === "function" && genFun.constructor; 1128 return ctor 1129 ? ctor === GeneratorFunction || 1130 // For the native GeneratorFunction constructor, the best we can 1131 // do is to check its .name property. 1132 (ctor.displayName || ctor.name) === "GeneratorFunction" 1133 : false; 1134 }; 1135 1136 runtime.mark = function(genFun) { 1137 if (Object.setPrototypeOf) { 1138 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); 1139 } else { 1140 genFun.__proto__ = GeneratorFunctionPrototype; 1141 if (!(toStringTagSymbol in genFun)) { 1142 genFun[toStringTagSymbol] = "GeneratorFunction"; 1143 } 1144 } 1145 genFun.prototype = Object.create(Gp); 1146 return genFun; 1147 }; 1148 1149 // Within the body of any async function, `await x` is transformed to 1150 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test 1151 // `hasOwn.call(value, "__await")` to determine if the yielded value is 1152 // meant to be awaited. 1153 runtime.awrap = function(arg) { 1154 return { __await: arg }; 1155 }; 1156 1157 function AsyncIterator(generator) { 1158 function invoke(method, arg, resolve, reject) { 1159 var record = tryCatch(generator[method], generator, arg); 1160 if (record.type === "throw") { 1161 reject(record.arg); 1162 } else { 1163 var result = record.arg; 1164 var value = result.value; 1165 if (value && 1166 typeof value === "object" && 1167 hasOwn.call(value, "__await")) { 1168 return Promise.resolve(value.__await).then(function(value) { 1169 invoke("next", value, resolve, reject); 1170 }, function(err) { 1171 invoke("throw", err, resolve, reject); 1172 }); 1173 } 1174 1175 return Promise.resolve(value).then(function(unwrapped) { 1176 // When a yielded Promise is resolved, its final value becomes 1177 // the .value of the Promise<{value,done}> result for the 1178 // current iteration. If the Promise is rejected, however, the 1179 // result for this iteration will be rejected with the same 1180 // reason. Note that rejections of yielded Promises are not 1181 // thrown back into the generator function, as is the case 1182 // when an awaited Promise is rejected. This difference in 1183 // behavior between yield and await is important, because it 1184 // allows the consumer to decide what to do with the yielded 1185 // rejection (swallow it and continue, manually .throw it back 1186 // into the generator, abandon iteration, whatever). With 1187 // await, by contrast, there is no opportunity to examine the 1188 // rejection reason outside the generator function, so the 1189 // only option is to throw it from the await expression, and 1190 // let the generator function handle the exception. 1191 result.value = unwrapped; 1192 resolve(result); 1193 }, reject); 1194 } 1195 } 1196 1197 var previousPromise; 1198 1199 function enqueue(method, arg) { 1200 function callInvokeWithMethodAndArg() { 1201 return new Promise(function(resolve, reject) { 1202 invoke(method, arg, resolve, reject); 1203 }); 1204 } 1205 1206 return previousPromise = 1207 // If enqueue has been called before, then we want to wait until 1208 // all previous Promises have been resolved before calling invoke, 1209 // so that results are always delivered in the correct order. If 1210 // enqueue has not been called before, then it is important to 1211 // call invoke immediately, without waiting on a callback to fire, 1212 // so that the async generator function has the opportunity to do 1213 // any necessary setup in a predictable way. This predictability 1214 // is why the Promise constructor synchronously invokes its 1215 // executor callback, and why async functions synchronously 1216 // execute code before the first await. Since we implement simple 1217 // async functions in terms of async generators, it is especially 1218 // important to get this right, even though it requires care. 1219 previousPromise ? previousPromise.then( 1220 callInvokeWithMethodAndArg, 1221 // Avoid propagating failures to Promises returned by later 1222 // invocations of the iterator. 1223 callInvokeWithMethodAndArg 1224 ) : callInvokeWithMethodAndArg(); 1225 } 1226 1227 // Define the unified helper method that is used to implement .next, 1228 // .throw, and .return (see defineIteratorMethods). 1229 this._invoke = enqueue; 1230 } 1231 1232 defineIteratorMethods(AsyncIterator.prototype); 1233 AsyncIterator.prototype[asyncIteratorSymbol] = function () { 1234 return this; 1235 }; 1236 runtime.AsyncIterator = AsyncIterator; 1237 1238 // Note that simple async functions are implemented on top of 1239 // AsyncIterator objects; they just return a Promise for the value of 1240 // the final result produced by the iterator. 1241 runtime.async = function(innerFn, outerFn, self, tryLocsList) { 1242 var iter = new AsyncIterator( 1243 wrap(innerFn, outerFn, self, tryLocsList) 1244 ); 1245 1246 return runtime.isGeneratorFunction(outerFn) 1247 ? iter // If outerFn is a generator, return the full iterator. 1248 : iter.next().then(function(result) { 1249 return result.done ? result.value : iter.next(); 1250 }); 1251 }; 1252 1253 function makeInvokeMethod(innerFn, self, context) { 1254 var state = GenStateSuspendedStart; 1255 1256 return function invoke(method, arg) { 1257 if (state === GenStateExecuting) { 1258 throw new Error("Generator is already running"); 1259 } 1260 1261 if (state === GenStateCompleted) { 1262 if (method === "throw") { 1263 throw arg; 1264 } 1265 1266 // Be forgiving, per 25.3.3.3.3 of the spec: 1267 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume 1268 return doneResult(); 1269 } 1270 1271 context.method = method; 1272 context.arg = arg; 1273 1274 while (true) { 1275 var delegate = context.delegate; 1276 if (delegate) { 1277 var delegateResult = maybeInvokeDelegate(delegate, context); 1278 if (delegateResult) { 1279 if (delegateResult === ContinueSentinel) continue; 1280 return delegateResult; 1281 } 1282 } 1283 1284 if (context.method === "next") { 1285 // Setting context._sent for legacy support of Babel's 1286 // function.sent implementation. 1287 context.sent = context._sent = context.arg; 1288 1289 } else if (context.method === "throw") { 1290 if (state === GenStateSuspendedStart) { 1291 state = GenStateCompleted; 1292 throw context.arg; 1293 } 1294 1295 context.dispatchException(context.arg); 1296 1297 } else if (context.method === "return") { 1298 context.abrupt("return", context.arg); 1299 } 1300 1301 state = GenStateExecuting; 1302 1303 var record = tryCatch(innerFn, self, context); 1304 if (record.type === "normal") { 1305 // If an exception is thrown from innerFn, we leave state === 1306 // GenStateExecuting and loop back for another invocation. 1307 state = context.done 1308 ? GenStateCompleted 1309 : GenStateSuspendedYield; 1310 1311 if (record.arg === ContinueSentinel) { 1312 continue; 1313 } 1314 1315 return { 1316 value: record.arg, 1317 done: context.done 1318 }; 1319 1320 } else if (record.type === "throw") { 1321 state = GenStateCompleted; 1322 // Dispatch the exception by looping back around to the 1323 // context.dispatchException(context.arg) call above. 1324 context.method = "throw"; 1325 context.arg = record.arg; 1326 } 1327 } 1328 }; 1329 } 1330 1331 // Call delegate.iterator[context.method](context.arg) and handle the 1332 // result, either by returning a { value, done } result from the 1333 // delegate iterator, or by modifying context.method and context.arg, 1334 // setting context.delegate to null, and returning the ContinueSentinel. 1335 function maybeInvokeDelegate(delegate, context) { 1336 var method = delegate.iterator[context.method]; 1337 if (method === undefined) { 1338 // A .throw or .return when the delegate iterator has no .throw 1339 // method always terminates the yield* loop. 1340 context.delegate = null; 1341 1342 if (context.method === "throw") { 1343 if (delegate.iterator.return) { 1344 // If the delegate iterator has a return method, give it a 1345 // chance to clean up. 1346 context.method = "return"; 1347 context.arg = undefined; 1348 maybeInvokeDelegate(delegate, context); 1349 1350 if (context.method === "throw") { 1351 // If maybeInvokeDelegate(context) changed context.method from 1352 // "return" to "throw", let that override the TypeError below.
vendor: 4,172 bytes, lines 1353-1506
1353 return ContinueSentinel; 1354 } 1355 } 1356 1357 context.method = "throw"; 1358 context.arg = new TypeError( 1359 "The iterator does not provide a 'throw' method"); 1360 } 1361 1362 return ContinueSentinel; 1363 } 1364 1365 var record = tryCatch(method, delegate.iterator, context.arg); 1366 1367 if (record.type === "throw") { 1368 context.method = "throw"; 1369 context.arg = record.arg; 1370 context.delegate = null; 1371 return ContinueSentinel; 1372 } 1373 1374 var info = record.arg; 1375 1376 if (! info) { 1377 context.method = "throw"; 1378 context.arg = new TypeError("iterator result is not an object"); 1379 context.delegate = null; 1380 return ContinueSentinel; 1381 } 1382 1383 if (info.done) { 1384 // Assign the result of the finished delegate to the temporary 1385 // variable specified by delegate.resultName (see delegateYield). 1386 context[delegate.resultName] = info.value; 1387 1388 // Resume execution at the desired location (see delegateYield). 1389 context.next = delegate.nextLoc; 1390 1391 // If context.method was "throw" but the delegate handled the 1392 // exception, let the outer generator proceed normally. If 1393 // context.method was "next", forget context.arg since it has been 1394 // "consumed" by the delegate iterator. If context.method was 1395 // "return", allow the original .return call to continue in the 1396 // outer generator. 1397 if (context.method !== "return") { 1398 context.method = "next"; 1399 context.arg = undefined; 1400 } 1401 1402 } else { 1403 // Re-yield the result returned by the delegate method. 1404 return info; 1405 } 1406 1407 // The delegate iterator is finished, so forget it and continue with 1408 // the outer generator. 1409 context.delegate = null; 1410 return ContinueSentinel; 1411 } 1412 1413 // Define Generator.prototype.{next,throw,return} in terms of the 1414 // unified ._invoke helper method. 1415 defineIteratorMethods(Gp); 1416 1417 Gp[toStringTagSymbol] = "Generator"; 1418 1419 // A Generator should always return itself as the iterator object when the 1420 // @@iterator function is called on it. Some browsers' implementations of the 1421 // iterator prototype chain incorrectly implement this, causing the Generator 1422 // object to not be returned from this call. This ensures that doesn't happen. 1423 // See https://github.com/facebook/regenerator/issues/274 for more details. 1424 Gp[iteratorSymbol] = function() { 1425 return this; 1426 }; 1427 1428 Gp.toString = function() { 1429 return "[object Generator]"; 1430 }; 1431 1432 function pushTryEntry(locs) { 1433 var entry = { tryLoc: locs[0] }; 1434 1435 if (1 in locs) { 1436 entry.catchLoc = locs[1]; 1437 } 1438 1439 if (2 in locs) { 1440 entry.finallyLoc = locs[2]; 1441 entry.afterLoc = locs[3]; 1442 } 1443 1444 this.tryEntries.push(entry); 1445 } 1446 1447 function resetTryEntry(entry) { 1448 var record = entry.completion || {}; 1449 record.type = "normal"; 1450 delete record.arg; 1451 entry.completion = record; 1452 } 1453 1454 function Context(tryLocsList) { 1455 // The root entry object (effectively a try statement without a catch 1456 // or a finally block) gives us a place to store values thrown from 1457 // locations where there is no enclosing try statement. 1458 this.tryEntries = [{ tryLoc: "root" }]; 1459 tryLocsList.forEach(pushTryEntry, this); 1460 this.reset(true); 1461 } 1462 1463 runtime.keys = function(object) { 1464 var keys = []; 1465 for (var key in object) { 1466 keys.push(key); 1467 } 1468 keys.reverse(); 1469 1470 // Rather than returning an object with a next method, we keep 1471 // things simple and return the next function itself. 1472 return function next() { 1473 while (keys.length) { 1474 var key = keys.pop(); 1475 if (key in object) { 1476 next.value = key; 1477 next.done = false; 1478 return next; 1479 } 1480 } 1481 1482 // To avoid creating an additional object, we just hang the .value 1483 // and .done properties off the next function object itself. This 1484 // also ensures that the minifier will not anonymize the function. 1485 next.done = true; 1486 return next; 1487 }; 1488 }; 1489 1490 function values(iterable) { 1491 if (iterable) { 1492 var iteratorMethod = iterable[iteratorSymbol]; 1493 if (iteratorMethod) { 1494 return iteratorMethod.call(iterable); 1495 } 1496 1497 if (typeof iterable.next === "function") { 1498 return iterable; 1499 } 1500 1501 if (!isNaN(iterable.length)) { 1502 var i = -1, next = function next() { 1503 while (++i < iterable.length) { 1504 if (hasOwn.call(iterable, i)) { 1505 next.value = iterable[i]; 1506 next.done = false;
1507 return next; 1508 } 1509 } 1510 1511 next.value = undefined; 1512 next.done = true; 1513 1514 return next; 1515 }; 1516 1517 return next.next = next; 1518 } 1519 } 1520 1521 // Return an iterator with no values. 1522 return { next: doneResult }; 1523 } 1524 runtime.values = values; 1525 1526 function doneResult() { 1527 return { value: undefined, done: true }; 1528 } 1529 1530 Context.prototype = { 1531 constructor: Context, 1532 1533 reset: function(skipTempReset) { 1534 this.prev = 0; 1535 this.next = 0; 1536 // Resetting context._sent for legacy support of Babel's 1537 // function.sent implementation. 1538 this.sent = this._sent = undefined; 1539 this.done = false; 1540 this.delegate = null; 1541 1542 this.method = "next"; 1543 this.arg = undefined; 1544 1545 this.tryEntries.forEach(resetTryEntry); 1546 1547 if (!skipTempReset) { 1548 for (var name in this) { 1549 // Not sure about the optimal order of these conditions: 1550 if (name.charAt(0) === "t" && 1551 hasOwn.call(this, name) && 1552 !isNaN(+name.slice(1))) { 1553 this[name] = undefined; 1554 } 1555 } 1556 } 1557 }, 1558 1559 stop: function() { 1560 this.done = true; 1561 1562 var rootEntry = this.tryEntries[0]; 1563 var rootRecord = rootEntry.completion; 1564 if (rootRecord.type === "throw") { 1565 throw rootRecord.arg; 1566 } 1567 1568 return this.rval; 1569 }, 1570 1571 dispatchException: function(exception) { 1572 if (this.done) { 1573 throw exception; 1574 } 1575 1576 var context = this; 1577 function handle(loc, caught) { 1578 record.type = "throw"; 1579 record.arg = exception; 1580 context.next = loc; 1581 1582 if (caught) { 1583 // If the dispatched exception was caught by a catch block, 1584 // then let that catch block handle the exception normally. 1585 context.method = "next"; 1586 context.arg = undefined; 1587 } 1588 1589 return !! caught; 1590 } 1591 1592 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1593 var entry = this.tryEntries[i]; 1594 var record = entry.completion; 1595 1596 if (entry.tryLoc === "root") { 1597 // Exception thrown outside of any try block that could handle 1598 // it, so set the completion value of the entire function to 1599 // throw the exception. 1600 return handle("end"); 1601 } 1602 1603 if (entry.tryLoc <= this.prev) { 1604 var hasCatch = hasOwn.call(entry, "catchLoc"); 1605 var hasFinally = hasOwn.call(entry, "finallyLoc"); 1606 1607 if (hasCatch && hasFinally) { 1608 if (this.prev < entry.catchLoc) { 1609 return handle(entry.catchLoc, true); 1610 } else if (this.prev < entry.finallyLoc) { 1611 return handle(entry.finallyLoc); 1612 } 1613 1614 } else if (hasCatch) { 1615 if (this.prev < entry.catchLoc) { 1616 return handle(entry.catchLoc, true); 1617 } 1618 1619 } else if (hasFinally) { 1620 if (this.prev < entry.finallyLoc) { 1621 return handle(entry.finallyLoc); 1622 } 1623 1624 } else { 1625 throw new Error("try statement without catch or finally"); 1626 } 1627 } 1628 } 1629 }, 1630 1631 abrupt: function(type, arg) { 1632 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1633 var entry = this.tryEntries[i]; 1634 if (entry.tryLoc <= this.prev && 1635 hasOwn.call(entry, "finallyLoc") && 1636 this.prev < entry.finallyLoc) { 1637 var finallyEntry = entry; 1638 break; 1639 } 1640 } 1641 1642 if (finallyEntry && 1643 (type === "break" || 1644 type === "continue") && 1645 finallyEntry.tryLoc <= arg && 1646 arg <= finallyEntry.finallyLoc) { 1647 // Ignore the finally entry if control is not jumping to a 1648 // location outside the try/catch block. 1649 finallyEntry = null; 1650 } 1651 1652 var record = finallyEntry ? finallyEntry.completion : {}; 1653 record.type = type; 1654 record.arg = arg; 1655 1656 if (finallyEntry) { 1657 this.method = "next"; 1658 this.next = finallyEntry.finallyLoc; 1659 return ContinueSentinel; 1660 } 1661 1662 return this.complete(record); 1663 }, 1664 1665 complete: function(record, afterLoc) { 1666 if (record.type === "throw") { 1667 throw record.arg; 1668 } 1669 1670 if (record.type === "break" || 1671 record.type === "continue") { 1672 this.next = record.arg; 1673 } else if (record.type === "return") { 1674 this.rval = this.arg = record.arg; 1675 this.method = "return"; 1676 this.next = "end"; 1677 } else if (record.type === "normal" && afterLoc) { 1678 this.next = afterLoc; 1679 } 1680 1681 return ContinueSentinel; 1682 }, 1683 1684 finish: function(finallyLoc) { 1685 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1686 var entry = this.tryEntries[i]; 1687 if (entry.finallyLoc === finallyLoc) { 1688 this.complete(entry.completion, entry.afterLoc); 1689 resetTryEntry(entry); 1690 return ContinueSentinel; 1691 } 1692 } 1693 }, 1694 1695 "catch": function(tryLoc) { 1696 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1697 var entry = this.tryEntries[i]; 1698 if (entry.tryLoc === tryLoc) { 1699 var record = entry.completion; 1700 if (record.type === "throw") { 1701 var thrown = record.arg; 1702 resetTryEntry(entry); 1703 } 1704 return thrown; 1705 } 1706 } 1707 1708 // The context.catch method must only be called with a location 1709 // argument that corresponds to a known catch block. 1710 throw new Error("illegal catch attempt"); 1711 }, 1712 1713 delegateYield: function(iterable, resultName, nextLoc) { 1714 this.delegate = { 1715 iterator: values(iterable), 1716 resultName: resultName, 1717 nextLoc: nextLoc 1718 }; 1719 1720 if (this.method === "next") { 1721 // Deliberately forget the last sent value so that we don't 1722 // accidentally pass it on to the delegate. 1723 this.arg = undefined; 1724 } 1725 1726 return ContinueSentinel; 1727 } 1728 }; 1729})( 1730 // In sloppy mode, unbound `this` refers to the global object, fallback to 1731 // Function constructor if we're in global strict mode. That is sadly a form 1732 // of indirect eval which violates Content Security Policy. 1733 (function() { return this })() || Function("return this")() 1734); 1735 1736(function (exports) { 1737 'use strict'; 1738 1739 var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; 1740 function createCommonjsModule(fn, module) { 1741 return module = { 1742 exports: {} 1743 }, fn(module, module.exports), module.exports; 1744 } 1745 1746 var check = function (it) { 1747 return it && it.Math == Math && it; 1748 }; // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 1749 1750 1751 var global_1 = // eslint-disable-next-line es/no-global-this -- safe 1752 check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || // eslint-disable-next-line no-restricted-globals -- safe 1753 check(typeof self == 'object' && self) || check(typeof commonjsGlobal == 'object' && commonjsGlobal) || // eslint-disable-next-line no-new-func -- fallback 1754 function () { 1755 return this; 1756 }() || Function('return this')(); 1757 1758 var fails = function (exec) { 1759 try { 1760 return !!exec(); 1761 } catch (error) { 1762 return true; 1763 } 1764 }; 1765 1766 // Detect IE8's incomplete defineProperty implementation 1767 1768 1769 var descriptors = !fails(function () { 1770 // eslint-disable-next-line es/no-object-defineproperty -- required for testing 1771 return Object.defineProperty({}, 1, { 1772 get: function () { 1773 return 7; 1774 } 1775 })[1] != 7; 1776 }); 1777 1778 var call = Function.prototype.call; 1779 var functionCall = call.bind ? call.bind(call) : function () { 1780 return call.apply(call, arguments); 1781 }; 1782 1783 var $propertyIsEnumerable = {}.propertyIsEnumerable; // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 1784 1785 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; // Nashorn ~ JDK8 bug 1786 1787 var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1788 1: 2 1789 }, 1); // `Object.prototype.propertyIsEnumerable` method implementation 1790 // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable 1791 1792 var f = NASHORN_BUG ? function propertyIsEnumerable(V) { 1793 var descriptor = getOwnPropertyDescriptor(this, V); 1794 return !!descriptor && descriptor.enumerable; 1795 } : $propertyIsEnumerable; 1796 1797 var objectPropertyIsEnumerable = { 1798 f: f 1799 }; 1800 1801 var createPropertyDescriptor = function (bitmap, value) { 1802 return { 1803 enumerable: !(bitmap & 1), 1804 configurable: !(bitmap & 2), 1805 writable: !(bitmap & 4), 1806 value: value 1807 }; 1808 }; 1809 1810 var FunctionPrototype = Function.prototype; 1811 var bind = FunctionPrototype.bind; 1812 var call$1 = FunctionPrototype.call; 1813 var callBind = bind && bind.bind(call$1); 1814 var functionUncurryThis = bind ? function (fn) {
1815 return fn && callBind(call$1, fn); 1816 } : function (fn) { 1817 return fn && function () { 1818 return call$1.apply(fn, arguments); 1819 }; 1820 }; 1821 1822 var toString = functionUncurryThis({}.toString); 1823 var stringSlice = functionUncurryThis(''.slice); 1824 1825 var classofRaw = function (it) { 1826 return stringSlice(toString(it), 8, -1); 1827 }; 1828 1829 var Object$1 = global_1.Object; 1830 var split = functionUncurryThis(''.split); // fallback for non-array-like ES3 and non-enumerable old V8 strings 1831 1832 var indexedObject = fails(function () { 1833 // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346 1834 // eslint-disable-next-line no-prototype-builtins -- safe 1835 return !Object$1('z').propertyIsEnumerable(0); 1836 }) ? function (it) { 1837 return classofRaw(it) == 'String' ? split(it, '') : Object$1(it); 1838 } : Object$1; 1839 1840 var TypeError$1 = global_1.TypeError; // `RequireObjectCoercible` abstract operation 1841 // https://tc39.es/ecma262/#sec-requireobjectcoercible 1842 1843 var requireObjectCoercible = function (it) { 1844 if (it == undefined) throw TypeError$1("Can't call method on " + it); 1845 return it; 1846 }; 1847 1848 // toObject with fallback for non-array-like ES3 strings 1849 1850 1851 1852 1853 var toIndexedObject = function (it) { 1854 return indexedObject(requireObjectCoercible(it)); 1855 }; 1856 1857 // `IsCallable` abstract operation 1858 // https://tc39.es/ecma262/#sec-iscallable 1859 var isCallable = function (argument) { 1860 return typeof argument == 'function'; 1861 }; 1862 1863 var isObject = function (it) { 1864 return typeof it == 'object' ? it !== null : isCallable(it); 1865 }; 1866 1867 var aFunction = function (argument) { 1868 return isCallable(argument) ? argument : undefined; 1869 }; 1870 1871 var getBuiltIn = function (namespace, method) { 1872 return arguments.length < 2 ? aFunction(global_1[namespace]) : global_1[namespace] && global_1[namespace][method]; 1873 }; 1874 1875 var objectIsPrototypeOf = functionUncurryThis({}.isPrototypeOf); 1876 1877 var engineUserAgent = getBuiltIn('navigator', 'userAgent') || ''; 1878 1879 var process = global_1.process; 1880 var Deno = global_1.Deno; 1881 var versions = process && process.versions || Deno && Deno.version; 1882 var v8 = versions && versions.v8; 1883 var match, version; 1884 1885 if (v8) { 1886 match = v8.split('.'); // in old Chrome, versions of V8 isn't V8 = Chrome / 10 1887 // but their correct versions are not interesting for us 1888 1889 version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]); 1890 } // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0` 1891 // so check `userAgent` even if `.v8` exists, but 0 1892 1893 1894 if (!version && engineUserAgent) { 1895 match = engineUserAgent.match(/Edge\/(\d+)/); 1896 1897 if (!match || match[1] >= 74) { 1898 match = engineUserAgent.match(/Chrome\/(\d+)/); 1899 if (match) version = +match[1]; 1900 } 1901 } 1902 1903 var engineV8Version = version; 1904 1905 /* eslint-disable es/no-symbol -- required for testing */ 1906 1907 1908 // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing 1909 1910 1911 var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () { 1912 var symbol = Symbol(); // Chrome 38 Symbol has incorrect toString conversion 1913 // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances 1914 1915 return !String(symbol) || !(Object(symbol) instanceof Symbol) || // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances 1916 !Symbol.sham && engineV8Version && engineV8Version < 41; 1917 }); 1918 1919 /* eslint-disable es/no-symbol -- required for testing */ 1920 1921 1922 var useSymbolAsUid = nativeSymbol && !Symbol.sham && typeof Symbol.iterator == 'symbol'; 1923 1924 var Object$2 = global_1.Object; 1925 var isSymbol = useSymbolAsUid ? function (it) { 1926 return typeof it == 'symbol'; 1927 } : function (it) { 1928 var $Symbol = getBuiltIn('Symbol'); 1929 return isCallable($Symbol) && objectIsPrototypeOf($Symbol.prototype, Object$2(it)); 1930 }; 1931 1932 var String$1 = global_1.String; 1933 1934 var tryToString = function (argument) { 1935 try { 1936 return String$1(argument); 1937 } catch (error) { 1938 return 'Object'; 1939 } 1940 }; 1941 1942 var TypeError$2 = global_1.TypeError; // `Assert: IsCallable(argument) is true` 1943 1944 var aCallable = function (argument) { 1945 if (isCallable(argument)) return argument; 1946 throw TypeError$2(tryToString(argument) + ' is not a function'); 1947 }; 1948 1949 // `GetMethod` abstract operation 1950 // https://tc39.es/ecma262/#sec-getmethod 1951 1952 1953 var getMethod = function (V, P) { 1954 var func = V[P]; 1955 return func == null ? undefined : aCallable(func); 1956 }; 1957 1958 var TypeError$3 = global_1.TypeError; // `OrdinaryToPrimitive` abstract operation 1959 // https://tc39.es/ecma262/#sec-ordinarytoprimitive 1960 1961 var ordinaryToPrimitive = function (input, pref) { 1962 var fn, val; 1963 if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val; 1964 if (isCallable(fn = input.valueOf) && !isObject(val = functionCall(fn, input))) return val; 1965 if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val; 1966 throw TypeError$3("Can't convert object to primitive value"); 1967 }; 1968 1969 var isPure = false;
1970 1971 // eslint-disable-next-line es/no-object-defineproperty -- safe 1972 1973 1974 var defineProperty = Object.defineProperty; 1975 1976 var setGlobal = function (key, value) { 1977 try { 1978 defineProperty(global_1, key, { 1979 value: value, 1980 configurable: true, 1981 writable: true 1982 }); 1983 } catch (error) { 1984 global_1[key] = value; 1985 } 1986 1987 return value; 1988 }; 1989 1990 var SHARED = '__core-js_shared__'; 1991 var store = global_1[SHARED] || setGlobal(SHARED, {}); 1992 var sharedStore = store; 1993 1994 var shared = createCommonjsModule(function (module) { 1995 (module.exports = function (key, value) { 1996 return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {}); 1997 })('versions', []).push({ 1998 version: '3.19.2', 1999 mode: 'global', 2000 copyright: '(c) 2021 Denis Pushkarev (zloirock.ru)' 2001 }); 2002 }); 2003 2004 var Object$3 = global_1.Object; // `ToObject` abstract operation 2005 // https://tc39.es/ecma262/#sec-toobject 2006 2007 var toObject = function (argument) { 2008 return Object$3(requireObjectCoercible(argument)); 2009 }; 2010 2011 var hasOwnProperty = functionUncurryThis({}.hasOwnProperty); // `HasOwnProperty` abstract operation 2012 // https://tc39.es/ecma262/#sec-hasownproperty 2013 2014 var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) { 2015 return hasOwnProperty(toObject(it), key); 2016 }; 2017 2018 var id = 0; 2019 var postfix = Math.random(); 2020 var toString$1 = functionUncurryThis(1.0.toString); 2021 2022 var uid = function (key) { 2023 return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$1(++id + postfix, 36); 2024 }; 2025 2026 var WellKnownSymbolsStore = shared('wks'); 2027 var Symbol$1 = global_1.Symbol; 2028 var symbolFor = Symbol$1 && Symbol$1['for']; 2029 var createWellKnownSymbol = useSymbolAsUid ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid; 2030 2031 var wellKnownSymbol = function (name) { 2032 if (!hasOwnProperty_1(WellKnownSymbolsStore, name) || !(nativeSymbol || typeof WellKnownSymbolsStore[name] == 'string')) { 2033 var description = 'Symbol.' + name; 2034 2035 if (nativeSymbol && hasOwnProperty_1(Symbol$1, name)) { 2036 WellKnownSymbolsStore[name] = Symbol$1[name]; 2037 } else if (useSymbolAsUid && symbolFor) { 2038 WellKnownSymbolsStore[name] = symbolFor(description); 2039 } else { 2040 WellKnownSymbolsStore[name] = createWellKnownSymbol(description); 2041 } 2042 } 2043 2044 return WellKnownSymbolsStore[name]; 2045 }; 2046 2047 var TypeError$4 = global_1.TypeError; 2048 var TO_PRIMITIVE = wellKnownSymbol('toPrimitive'); // `ToPrimitive` abstract operation 2049 // https://tc39.es/ecma262/#sec-toprimitive 2050 2051 var toPrimitive = function (input, pref) { 2052 if (!isObject(input) || isSymbol(input)) return input; 2053 var exoticToPrim = getMethod(input, TO_PRIMITIVE); 2054 var result; 2055 2056 if (exoticToPrim) { 2057 if (pref === undefined) pref = 'default'; 2058 result = functionCall(exoticToPrim, input, pref); 2059 if (!isObject(result) || isSymbol(result)) return result; 2060 throw TypeError$4("Can't convert object to primitive value"); 2061 } 2062 2063 if (pref === undefined) pref = 'number'; 2064 return ordinaryToPrimitive(input, pref); 2065 }; 2066 2067 // `ToPropertyKey` abstract operation 2068 // https://tc39.es/ecma262/#sec-topropertykey 2069 2070 2071 var toPropertyKey = function (argument) { 2072 var key = toPrimitive(argument, 'string'); 2073 return isSymbol(key) ? key : key + ''; 2074 }; 2075 2076 var document$1 = global_1.document; // typeof document.createElement is 'object' in old IE 2077 2078 var EXISTS = isObject(document$1) && isObject(document$1.createElement); 2079 2080 var documentCreateElement = function (it) { 2081 return EXISTS ? document$1.createElement(it) : {}; 2082 }; 2083 2084 // Thank's IE8 for his funny defineProperty 2085 2086 2087 var ie8DomDefine = !descriptors && !fails(function () { 2088 // eslint-disable-next-line es/no-object-defineproperty -- requied for testing 2089 return Object.defineProperty(documentCreateElement('div'), 'a', { 2090 get: function () { 2091 return 7; 2092 } 2093 }).a != 7; 2094 }); 2095 2096 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2097 2098 2099 var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; // `Object.getOwnPropertyDescriptor` method 2100 // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor 2101 2102 var f$1 = descriptors ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) { 2103 O = toIndexedObject(O); 2104 P = toPropertyKey(P); 2105 if (ie8DomDefine) try { 2106 return $getOwnPropertyDescriptor(O, P); 2107 } catch (error) { 2108 /* empty */ 2109 } 2110 if (hasOwnProperty_1(O, P)) return createPropertyDescriptor(!functionCall(objectPropertyIsEnumerable.f, O, P), O[P]); 2111 }; 2112 2113 var objectGetOwnPropertyDescriptor = { 2114 f: f$1 2115 }; 2116 2117 var String$2 = global_1.String; 2118 var TypeError$5 = global_1.TypeError; // `Assert: Type(argument) is Object` 2119 2120 var anObject = function (argument) { 2121 if (isObject(argument)) return argument; 2122 throw TypeError$5(String$2(argument) + ' is not an object'); 2123 }; 2124 2125 var TypeError$6 = global_1.TypeError; // eslint-disable-next-line es/no-object-defineproperty -- safe 2126 2127 var $defineProperty = Object.defineProperty; // `Object.defineProperty` method 2128 // https://tc39.es/ecma262/#sec-object.defineproperty 2129 2130 var f$2 = descriptors ? $defineProperty : function defineProperty(O, P, Attributes) { 2131 anObject(O); 2132 P = toPropertyKey(P); 2133 anObject(Attributes); 2134 if (ie8DomDefine) try { 2135 return $defineProperty(O, P, Attributes); 2136 } catch (error) { 2137 /* empty */ 2138 } 2139 if ('get' in Attributes || 'set' in Attributes) throw TypeError$6('Accessors not supported'); 2140 if ('value' in Attributes) O[P] = Attributes.value; 2141 return O; 2142 }; 2143 2144 var objectDefineProperty = { 2145 f: f$2 2146 }; 2147 2148 var createNonEnumerableProperty = descriptors ? function (object, key, value) { 2149 return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value)); 2150 } : function (object, key, value) { 2151 object[key] = value; 2152 return object; 2153 }; 2154 2155 var functionToString = functionUncurryThis(Function.toString); // this helper broken in `[email protected]`, so we can't use `shared` helper 2156 2157 if (!isCallable(sharedStore.inspectSource)) { 2158 sharedStore.inspectSource = function (it) { 2159 return functionToString(it); 2160 }; 2161 } 2162 2163 var inspectSource = sharedStore.inspectSource; 2164 2165 var WeakMap = global_1.WeakMap; 2166 var nativeWeakMap = isCallable(WeakMap) && /native code/.test(inspectSource(WeakMap)); 2167 2168 var keys = shared('keys'); 2169 2170 var sharedKey = function (key) { 2171 return keys[key] || (keys[key] = uid(key)); 2172 }; 2173 2174 var hiddenKeys = {}; 2175 2176 var OBJECT_ALREADY_INITIALIZED = 'Object already initialized'; 2177 var TypeError$7 = global_1.TypeError; 2178 var WeakMap$1 = global_1.WeakMap; 2179 var set, get, has; 2180 2181 var enforce = function (it) { 2182 return has(it) ? get(it) : set(it, {}); 2183 }; 2184 2185 var getterFor = function (TYPE) { 2186 return function (it) { 2187 var state; 2188 2189 if (!isObject(it) || (state = get(it)).type !== TYPE) { 2190 throw TypeError$7('Incompatible receiver, ' + TYPE + ' required'); 2191 } 2192 2193 return state; 2194 }; 2195 }; 2196 2197 if (nativeWeakMap || sharedStore.state) { 2198 var store$1 = sharedStore.state || (sharedStore.state = new WeakMap$1()); 2199 var wmget = functionUncurryThis(store$1.get); 2200 var wmhas = functionUncurryThis(store$1.has); 2201 var wmset = functionUncurryThis(store$1.set); 2202 2203 set = function (it, metadata) { 2204 if (wmhas(store$1, it)) throw new TypeError$7(OBJECT_ALREADY_INITIALIZED); 2205 metadata.facade = it; 2206 wmset(store$1, it, metadata); 2207 return metadata; 2208 }; 2209 2210 get = function (it) { 2211 return wmget(store$1, it) || {}; 2212 }; 2213 2214 has = function (it) { 2215 return wmhas(store$1, it); 2216 }; 2217 } else { 2218 var STATE = sharedKey('state'); 2219 hiddenKeys[STATE] = true; 2220 2221 set = function (it, metadata) { 2222 if (hasOwnProperty_1(it, STATE)) throw new TypeError$7(OBJECT_ALREADY_INITIALIZED); 2223 metadata.facade = it; 2224 createNonEnumerableProperty(it, STATE, metadata); 2225 return metadata; 2226 }; 2227 2228 get = function (it) { 2229 return hasOwnProperty_1(it, STATE) ? it[STATE] : {}; 2230 }; 2231 2232 has = function (it) { 2233 return hasOwnProperty_1(it, STATE); 2234 }; 2235 } 2236 2237 var internalState = { 2238 set: set, 2239 get: get, 2240 has: has, 2241 enforce: enforce, 2242 getterFor: getterFor 2243 }; 2244 2245 var FunctionPrototype$1 = Function.prototype; // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2246 2247 var getDescriptor = descriptors && Object.getOwnPropertyDescriptor; 2248 var EXISTS$1 = hasOwnProperty_1(FunctionPrototype$1, 'name'); // additional protection from minified / mangled / dropped function names 2249 2250 var PROPER = EXISTS$1 && function something() { 2251 /* empty */ 2252 }.name === 'something'; 2253 2254 var CONFIGURABLE = EXISTS$1 && (!descriptors || descriptors && getDescriptor(FunctionPrototype$1, 'name').configurable); 2255 var functionName = { 2256 EXISTS: EXISTS$1, 2257 PROPER: PROPER, 2258 CONFIGURABLE: CONFIGURABLE 2259 }; 2260 2261 var redefine = createCommonjsModule(function (module) { 2262 var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE; 2263 2264 var getInternalState = internalState.get; 2265 var enforceInternalState = internalState.enforce;
2266 var TEMPLATE = String(String).split('String'); 2267 (module.exports = function (O, key, value, options) { 2268 var unsafe = options ? !!options.unsafe : false; 2269 var simple = options ? !!options.enumerable : false; 2270 var noTargetGet = options ? !!options.noTargetGet : false; 2271 var name = options && options.name !== undefined ? options.name : key; 2272 var state; 2273 2274 if (isCallable(value)) { 2275 if (String(name).slice(0, 7) === 'Symbol(') { 2276 name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']'; 2277 } 2278 2279 if (!hasOwnProperty_1(value, 'name') || CONFIGURABLE_FUNCTION_NAME && value.name !== name) { 2280 createNonEnumerableProperty(value, 'name', name); 2281 } 2282 2283 state = enforceInternalState(value); 2284 2285 if (!state.source) { 2286 state.source = TEMPLATE.join(typeof name == 'string' ? name : ''); 2287 } 2288 } 2289 2290 if (O === global_1) { 2291 if (simple) O[key] = value;else setGlobal(key, value); 2292 return; 2293 } else if (!unsafe) { 2294 delete O[key]; 2295 } else if (!noTargetGet && O[key]) { 2296 simple = true; 2297 } 2298 2299 if (simple) O[key] = value;else createNonEnumerableProperty(O, key, value); // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative 2300 })(Function.prototype, 'toString', function toString() { 2301 return isCallable(this) && getInternalState(this).source || inspectSource(this); 2302 }); 2303 }); 2304 2305 var ceil = Math.ceil; 2306 var floor = Math.floor; // `ToIntegerOrInfinity` abstract operation 2307 // https://tc39.es/ecma262/#sec-tointegerorinfinity 2308 2309 var toIntegerOrInfinity = function (argument) { 2310 var number = +argument; // eslint-disable-next-line no-self-compare -- safe 2311 2312 return number !== number || number === 0 ? 0 : (number > 0 ? floor : ceil)(number); 2313 }; 2314 2315 var max = Math.max; 2316 var min = Math.min; // Helper for a popular repeating case of the spec: 2317 // Let integer be ? ToInteger(index). 2318 // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length). 2319 2320 var toAbsoluteIndex = function (index, length) { 2321 var integer = toIntegerOrInfinity(index); 2322 return integer < 0 ? max(integer + length, 0) : min(integer, length); 2323 }; 2324 2325 var min$1 = Math.min; // `ToLength` abstract operation 2326 // https://tc39.es/ecma262/#sec-tolength 2327 2328 var toLength = function (argument) { 2329 return argument > 0 ? min$1(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 2330 }; 2331 2332 // `LengthOfArrayLike` abstract operation 2333 // https://tc39.es/ecma262/#sec-lengthofarraylike 2334 2335 2336 var lengthOfArrayLike = function (obj) { 2337 return toLength(obj.length); 2338 }; 2339 2340 // `Array.prototype.{ indexOf, includes }` methods implementation 2341 2342 2343 var createMethod = function (IS_INCLUDES) { 2344 return function ($this, el, fromIndex) { 2345 var O = toIndexedObject($this); 2346 var length = lengthOfArrayLike(O); 2347 var index = toAbsoluteIndex(fromIndex, length); 2348 var value; // Array#includes uses SameValueZero equality algorithm 2349 // eslint-disable-next-line no-self-compare -- NaN check 2350 2351 if (IS_INCLUDES && el != el) while (length > index) { 2352 value = O[index++]; // eslint-disable-next-line no-self-compare -- NaN check 2353 2354 if (value != value) return true; // Array#indexOf ignores holes, Array#includes - not 2355 } else for (; length > index; index++) { 2356 if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0; 2357 } 2358 return !IS_INCLUDES && -1; 2359 }; 2360 }; 2361 2362 var arrayIncludes = { 2363 // `Array.prototype.includes` method 2364 // https://tc39.es/ecma262/#sec-array.prototype.includes 2365 includes: createMethod(true), 2366 // `Array.prototype.indexOf` method 2367 // https://tc39.es/ecma262/#sec-array.prototype.indexof 2368 indexOf: createMethod(false) 2369 }; 2370 2371 var indexOf = arrayIncludes.indexOf; 2372 2373 2374 2375 var push = functionUncurryThis([].push); 2376 2377 var objectKeysInternal = function (object, names) { 2378 var O = toIndexedObject(object); 2379 var i = 0; 2380 var result = []; 2381 var key; 2382 2383 for (key in O) !hasOwnProperty_1(hiddenKeys, key) && hasOwnProperty_1(O, key) && push(result, key); // Don't enum bug & hidden keys 2384 2385 2386 while (names.length > i) if (hasOwnProperty_1(O, key = names[i++])) { 2387 ~indexOf(result, key) || push(result, key); 2388 } 2389 2390 return result; 2391 }; 2392 2393 // IE8- don't enum bug keys 2394 var enumBugKeys = ['constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleStr
2394ing', 'toString', 'valueOf']; 2395 2396 var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype'); // `Object.getOwnPropertyNames` method 2397 // https://tc39.es/ecma262/#sec-object.getownpropertynames 2398 // eslint-disable-next-line es/no-object-getownpropertynames -- safe 2399 2400 var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { 2401 return objectKeysInternal(O, hiddenKeys$1); 2402 }; 2403 2404 var objectGetOwnPropertyNames = { 2405 f: f$3 2406 }; 2407 2408 // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe 2409 var f$4 = Object.getOwnPropertySymbols; 2410 2411 var objectGetOwnPropertySymbols = { 2412 f: f$4 2413 }; 2414 2415 var concat = functionUncurryThis([].concat); // all object keys, includes non-enumerable and symbols 2416 2417 var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) { 2418 var keys = objectGetOwnPropertyNames.f(anObject(it)); 2419 var getOwnPropertySymbols = objectGetOwnPropertySymbols.f; 2420 return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys; 2421 }; 2422 2423 var copyConstructorProperties = function (target, source) { 2424 var keys = ownKeys(source); 2425 var defineProperty = objectDefineProperty.f; 2426 var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; 2427 2428 for (var i = 0; i < keys.length; i++) { 2429 var key = keys[i]; 2430 if (!hasOwnProperty_1(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key)); 2431 } 2432 }; 2433 2434 var replacement = /#|\.prototype\./; 2435 2436 var isForced = function (feature, detection) { 2437 var value = data[normalize(feature)]; 2438 return value == POLYFILL ? true : value == NATIVE ? false : isCallable(detection) ? fails(detection) : !!detection; 2439 }; 2440 2441 var normalize = isForced.normalize = function (string) { 2442 return String(string).replace(replacement, '.').toLowerCase(); 2443 }; 2444 2445 var data = isForced.data = {}; 2446 var NATIVE = isForced.NATIVE = 'N'; 2447 var POLYFILL = isForced.POLYFILL = 'P'; 2448 var isForced_1 = isForced; 2449 2450 var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f; 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 /* 2462 options.target - name of the target object 2463 options.global - target is the global object 2464 options.stat - export as static methods of target 2465 options.proto - export as prototype methods of target 2466 options.real - real prototype method for the `pure` version 2467 options.forced - export even if the native feature is available 2468 options.bind - bind methods to the target, required for the `pure` version 2469 options.wrap - wrap constructors to preventing global pollution, required for the `pure` version 2470 options.unsafe - use the simple assignment of property instead of delete + defineProperty 2471 options.sham - add a flag to not completely full polyfills 2472 options.enumerable - export as enumerable property 2473 options.noTargetGet - prevent calling a getter on target 2474 options.name - the .name of the function if it does not match the key 2475 */ 2476 2477 2478 var _export = function (options, source) { 2479 var TARGET = options.target; 2480 var GLOBAL = options.global; 2481 var STATIC = options.stat; 2482 var FORCED, target, key, targetProperty, sourceProperty, descriptor; 2483 2484 if (GLOBAL) { 2485 target = global_1; 2486 } else if (STATIC) { 2487 target = global_1[TARGET] || setGlobal(TARGET, {}); 2488 } else { 2489 target = (global_1[TARGET] || {}).prototype; 2490 } 2491 2492 if (target) for (key in source) { 2493 sourceProperty = source[key]; 2494 2495 if (options.noTargetGet) { 2496 descriptor = getOwnPropertyDescriptor$1(target, key); 2497 targetProperty = descriptor && descriptor.value; 2498 } else targetProperty = target[key]; 2499 2500 FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); // contained in target 2501 2502 if (!FORCED && targetProperty !== undefined) { 2503 if (typeof sourceProperty == typeof targetProperty) continue; 2504 copyConstructorProperties(sourceProperty, targetProperty); 2505 } // add a flag to not completely full polyfills 2506 2507 2508 if (options.sham || targetProperty && targetProperty.sham) { 2509 createNonEnumerableProperty(sourceProperty, 'sham', true); 2510 } // extend global 2511 2512 2513 redefine(target, key, sourceProperty, options); 2514 } 2515 }; 2516 2517 var correctPrototypeGetter = !fails(function () { 2518 function F() { 2519 /* empty */ 2520 } 2521 2522 F.prototype.constructor = null; // eslint-disable-next-line es/no-object-getprototypeof -- required for testing 2523 2524 return Object.getPrototypeOf(new F()) !== F.prototype; 2525 }); 2526 2527 var IE_PROTO = sharedKey('IE_PROTO'); 2528 var Object$4 = global_1.Object; 2529 var ObjectPrototype = Object$4.prototype; // `Object.getPrototypeOf` method 2530 // https://tc39.es/ecma262/#sec-object.getprototypeof 2531 2532 var objectGetPrototypeOf = correctPrototypeGetter ? Object$4.getPrototypeOf : function (O) { 2533 var object = toObject(O); 2534 if (hasOwnProperty_1(object, IE_PROTO)) return object[IE_PROTO]; 2535 var constructor = object.constructor; 2536 2537 if (isCallable(constructor) && object instanceof constructor) { 2538 return constructor.prototype; 2539 } 2540
2541 return object instanceof Object$4 ? ObjectPrototype : null; 2542 }; 2543 2544 var String$3 = global_1.String; 2545 var TypeError$8 = global_1.TypeError; 2546 2547 var aPossiblePrototype = function (argument) { 2548 if (typeof argument == 'object' || isCallable(argument)) return argument; 2549 throw TypeError$8("Can't set " + String$3(argument) + ' as a prototype'); 2550 }; 2551 2552 /* eslint-disable no-proto -- safe */ 2553 2554 2555 2556 2557 // `Object.setPrototypeOf` method 2558 // https://tc39.es/ecma262/#sec-object.setprototypeof 2559 // Works with __proto__ only. Old v8 can't work with null proto objects. 2560 // eslint-disable-next-line es/no-object-setprototypeof -- safe 2561 2562 2563 var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () { 2564 var CORRECT_SETTER = false; 2565 var test = {}; 2566 var setter; 2567 2568 try { 2569 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2570 setter = functionUncurryThis(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set); 2571 setter(test, []); 2572 CORRECT_SETTER = test instanceof Array; 2573 } catch (error) { 2574 /* empty */ 2575 } 2576 2577 return function setPrototypeOf(O, proto) { 2578 anObject(O); 2579 aPossiblePrototype(proto); 2580 if (CORRECT_SETTER) setter(O, proto);else O.__proto__ = proto; 2581 return O; 2582 }; 2583 }() : undefined); 2584 2585 // `Object.keys` method 2586 // https://tc39.es/ecma262/#sec-object.keys 2587 // eslint-disable-next-line es/no-object-keys -- safe 2588 2589 2590 var objectKeys = Object.keys || function keys(O) { 2591 return objectKeysInternal(O, enumBugKeys); 2592 }; 2593 2594 // `Object.defineProperties` method 2595 // https://tc39.es/ecma262/#sec-object.defineproperties 2596 // eslint-disable-next-line es/no-object-defineproperties -- safe 2597 2598 2599 var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) { 2600 anObject(O); 2601 var props = toIndexedObject(Properties); 2602 var keys = objectKeys(Properties); 2603 var length = keys.length; 2604 var index = 0; 2605 var key; 2606 2607 while (length > index) objectDefineProperty.f(O, key = keys[index++], props[key]); 2608 2609 return O; 2610 }; 2611 2612 var html = getBuiltIn('document', 'documentElement'); 2613 2614 /* global ActiveXObject -- old IE, WSH */ 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 var GT = '>'; 2630 var LT = '<'; 2631 var PROTOTYPE = 'prototype'; 2632 var SCRIPT = 'script'; 2633 var IE_PROTO$1 = sharedKey('IE_PROTO'); 2634 2635 var EmptyConstructor = function () { 2636 /* empty */ 2637 }; 2638 2639 var scriptTag = function (content) { 2640 return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT; 2641 }; // Create object with fake `null` prototype: use ActiveX Object with cleared prototype 2642 2643 2644 var NullProtoObjectViaActiveX = function (activeXDocument) { 2645 activeXDocument.write(scriptTag('')); 2646 activeXDocument.close(); 2647 var temp = activeXDocument.parentWindow.Object; 2648 activeXDocument = null; // avoid memory leak 2649 2650 return temp; 2651 }; // Create object with fake `null` prototype: use iframe Object with cleared prototype 2652 2653 2654 var NullProtoObjectViaIFrame = function () { 2655 // Thrash, waste and sodomy: IE GC bug 2656 var iframe = documentCreateElement('iframe'); 2657 var JS = 'java' + SCRIPT + ':'; 2658 var iframeDocument; 2659 iframe.style.display = 'none'; 2660 html.appendChild(iframe); // https://github.com/zloirock/core-js/issues/475 2661 2662 iframe.src = String(JS); 2663 iframeDocument = iframe.contentWindow.document; 2664 iframeDocument.open(); 2665 iframeDocument.write(scriptTag('document.F=Object')); 2666 iframeDocument.close(); 2667 return iframeDocument.F; 2668 }; // Check for document.domain and active x support 2669 // No need to use active x approach when document.domain is not set 2670 // see https://github.com/es-shims/es5-shim/issues/150 2671 // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346 2672 // avoid IE GC bug 2673 2674 2675 var activeXDocument; 2676 2677 var NullProtoObject = function () { 2678 try { 2679 activeXDocument = new ActiveXObject('htmlfile'); 2680 } catch (error) { 2681 /* ignore */ 2682 } 2683 2684 NullProtoObject = typeof document != 'undefined' ? document.domain && activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) // old IE 2685 : NullProtoObjectViaIFrame() : NullProtoObjectViaActiveX(activeXDocument); // WSH 2686 2687 var length = enumBugKeys.length; 2688 2689 while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]]; 2690 2691 return NullProtoObject(); 2692 }; 2693 2694 hiddenKeys[IE_PROTO$1] = true; // `Object.create` method 2695 // https://tc39.es/ecma262/#sec-object.create 2696 2697 var objectCreate = Object.create || function create(O, Properties) { 2698 var result; 2699 2700 if (O !== null) { 2701 EmptyConstructor[PROTOTYPE] = anObject(O); 2702 result = new EmptyConstructor(); 2703 EmptyConstructor[PROTOTYPE] = null; // add "__proto__" for Object.getPrototypeOf polyfill 2704 2705 result[IE_PROTO$1] = O; 2706 } else result = NullProtoObject(); 2707 2708 return Properties === undefined ? result : objectDefineProperties(result, Properties); 2709 }; 2710 2711 var createProperty = function (object, key, value) { 2712 var propertyKey = toPropertyKey(key); 2713 if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value));else object[propertyKey] = value; 2714 }; 2715 2716 var Array$1 = global_1.Array; 2717 var max$1 = Math.max; 2718 2719 var arraySliceSimple = function (O, start, end) { 2720 var length = lengthOfArrayLike(O); 2721 var k = toAbsoluteIndex(start, length); 2722 var fin = toAbsoluteIndex(end === undefined ? length : end, length); 2723 var result = Array$1(max$1(fin - k, 0)); 2724 2725 for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]); 2726 2727 result.length = n; 2728 return result; 2729 }; 2730 2731 var replace = functionUncurryThis(''.replace); 2732 var split$1 = functionUncurryThis(''.split); 2733 var join = functionUncurryThis([].join); 2734 2735 var TEST = function (arg) { 2736 return String(Error(arg).stack); 2737 }('zxcasd'); 2738 2739 var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/; 2740 var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST); 2741 var IS_FIREFOX_OR_SAFARI_STACK = /@[^\n]*\n/.test(TEST) && !/zxcasd/.test(TEST); 2742 2743 var clearErrorStack = function (stack, dropEntries) { 2744 if (typeof stack != 'string') return stack; 2745 2746 if (IS_V8_OR_CHAKRA_STACK) { 2747 while (dropEntries--) stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, ''); 2748 }
vendor: 12,022 bytes, lines 2748-3146
2748 else if (IS_FIREFOX_OR_SAFARI_STACK) { 2749 return join(arraySliceSimple(split$1(stack, '\n'), dropEntries), '\n'); 2750 } 2751 2752 return stack; 2753 }; 2754 2755 // `InstallErrorCause` abstract operation 2756 // https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause 2757 2758 2759 var installErrorCause = function (O, options) { 2760 if (isObject(options) && 'cause' in options) { 2761 createNonEnumerableProperty(O, 'cause', options.cause); 2762 } 2763 }; 2764 2765 var bind$1 = functionUncurryThis(functionUncurryThis.bind); // optional / simple context binding 2766 2767 var functionBindContext = function (fn, that) { 2768 aCallable(fn); 2769 return that === undefined ? fn : bind$1 ? bind$1(fn, that) : function () 2770 /* ...args */ 2771 { 2772 return fn.apply(that, arguments); 2773 }; 2774 }; 2775 2776 var iterators = {}; 2777 2778 var ITERATOR = wellKnownSymbol('iterator'); 2779 var ArrayPrototype = Array.prototype; // check on default Array iterator 2780 2781 var isArrayIteratorMethod = function (it) { 2782 return it !== undefined && (iterators.Array === it || ArrayPrototype[ITERATOR] === it); 2783 }; 2784 2785 var TO_STRING_TAG = wellKnownSymbol('toStringTag'); 2786 var test = {}; 2787 test[TO_STRING_TAG] = 'z'; 2788 var toStringTagSupport = String(test) === '[object z]'; 2789 2790 var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag'); 2791 var Object$5 = global_1.Object; // ES3 wrong here 2792 2793 var CORRECT_ARGUMENTS = classofRaw(function () { 2794 return arguments; 2795 }()) == 'Arguments'; // fallback for IE11 Script Access Denied error 2796 2797 var tryGet = function (it, key) { 2798 try { 2799 return it[key]; 2800 } catch (error) { 2801 /* empty */ 2802 } 2803 }; // getting tag from ES6+ `Object.prototype.toString` 2804 2805 2806 var classof = toStringTagSupport ? classofRaw : function (it) { 2807 var O, tag, result; 2808 return it === undefined ? 'Undefined' : it === null ? 'Null' // @@toStringTag case 2809 : typeof (tag = tryGet(O = Object$5(it), TO_STRING_TAG$1)) == 'string' ? tag // builtinTag case 2810 : CORRECT_ARGUMENTS ? classofRaw(O) // ES3 arguments fallback 2811 : (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result; 2812 }; 2813 2814 var ITERATOR$1 = wellKnownSymbol('iterator'); 2815 2816 var getIteratorMethod = function (it) { 2817 if (it != undefined) return getMethod(it, ITERATOR$1) || getMethod(it, '@@iterator') || iterators[classof(it)]; 2818 }; 2819 2820 var TypeError$9 = global_1.TypeError; 2821 2822 var getIterator = function (argument, usingIterator) { 2823 var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator; 2824 if (aCallable(iteratorMethod)) return anObject(functionCall(iteratorMethod, argument)); 2825 throw TypeError$9(tryToString(argument) + ' is not iterable'); 2826 }; 2827 2828 var iteratorClose = function (iterator, kind, value) { 2829 var innerResult, innerError; 2830 anObject(iterator); 2831 2832 try { 2833 innerResult = getMethod(iterator, 'return'); 2834 2835 if (!innerResult) { 2836 if (kind === 'throw') throw value; 2837 return value; 2838 } 2839 2840 innerResult = functionCall(innerResult, iterator); 2841 } catch (error) { 2842 innerError = true; 2843 innerResult = error; 2844 } 2845 2846 if (kind === 'throw') throw value; 2847 if (innerError) throw innerResult; 2848 anObject(innerResult); 2849 return value; 2850 }; 2851 2852 var TypeError$a = global_1.TypeError; 2853 2854 var Result = function (stopped, result) { 2855 this.stopped = stopped; 2856 this.result = result; 2857 }; 2858 2859 var ResultPrototype = Result.prototype; 2860 2861 var iterate = function (iterable, unboundFunction, options) { 2862 var that = options && options.that; 2863 var AS_ENTRIES = !!(options && options.AS_ENTRIES); 2864 var IS_ITERATOR = !!(options && options.IS_ITERATOR); 2865 var INTERRUPTED = !!(options && options.INTERRUPTED); 2866 var fn = functionBindContext(unboundFunction, that); 2867 var iterator, iterFn, index, length, result, next, step; 2868 2869 var stop = function (condition) { 2870 if (iterator) iteratorClose(iterator, 'normal', condition); 2871 return new Result(true, condition); 2872 }; 2873 2874 var callFn = function (value) { 2875 if (AS_ENTRIES) { 2876 anObject(value); 2877 return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]); 2878 } 2879 2880 return INTERRUPTED ? fn(value, stop) : fn(value); 2881 }; 2882 2883 if (IS_ITERATOR) { 2884 iterator = iterable; 2885 } else { 2886 iterFn = getIteratorMethod(iterable); 2887 if (!iterFn) throw TypeError$a(tryToString(iterable) + ' is not iterable'); // optimisation for array iterators 2888 2889 if (isArrayIteratorMethod(iterFn)) { 2890 for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) { 2891 result = callFn(iterable[index]); 2892 if (result && objectIsPrototypeOf(ResultPrototype, result)) return result; 2893 } 2894 2895 return new Result(false); 2896 } 2897 2898 iterator = getIterator(iterable, iterFn); 2899 } 2900 2901 next = iterator.next; 2902 2903 while (!(step = functionCall(next, iterator)).done) { 2904 try { 2905 result = callFn(step.value); 2906 } catch (error) { 2907 iteratorClose(iterator, 'throw', error); 2908 } 2909 2910 if (typeof result == 'object' && result && objectIsPrototypeOf(ResultPrototype, result)) return result; 2911 } 2912 2913 return new Result(false); 2914 }; 2915 2916 var String$4 = global_1.String; 2917 2918 var toString_1 = function (argument) { 2919 if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string'); 2920 return String$4(argument); 2921 }; 2922 2923 var normalizeStringArgument = function (argument, $default) { 2924 return argument === undefined ? arguments.length < 2 ? '' : $default : toString_1(argument); 2925 }; 2926 2927 var errorStackInstallable = !fails(function () { 2928 var error = Error('a'); 2929 if (!('stack' in error)) return true; // eslint-disable-next-line es/no-object-defineproperty -- safe 2930 2931 Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7)); 2932 return error.stack !== 7; 2933 }); 2934 2935 var TO_STRING_TAG$2 = wellKnownSymbol('toStringTag'); 2936 var Error$1 = global_1.Error; 2937 var push$1 = [].push; 2938 2939 var $AggregateError = function AggregateError(errors, message 2940 /* , options */ 2941 ) { 2942 var options = arguments.length > 2 ? arguments[2] : undefined; 2943 var isInstance = objectIsPrototypeOf(AggregateErrorPrototype, this); 2944 var that; 2945 2946 if (objectSetPrototypeOf) { 2947 that = objectSetPrototypeOf(new Error$1(undefined), isInstance ? objectGetPrototypeOf(this) : AggregateErrorPrototype); 2948 } else { 2949 that = isInstance ? this : objectCreate(AggregateErrorPrototype); 2950 createNonEnumerableProperty(that, TO_STRING_TAG$2, 'Error'); 2951 } 2952 2953 createNonEnumerableProperty(that, 'message', normalizeStringArgument(message, '')); 2954 if (errorStackInstallable) createNonEnumerableProperty(that, 'stack', clearErrorStack(that.stack, 1)); 2955 installErrorCause(that, options); 2956 var errorsArray = []; 2957 iterate(errors, push$1, { 2958 that: errorsArray 2959 }); 2960 createNonEnumerableProperty(that, 'errors', errorsArray); 2961 return that; 2962 }; 2963 2964 if (objectSetPrototypeOf) objectSetPrototypeOf($AggregateError, Error$1);else copyConstructorProperties($AggregateError, Error$1); 2965 var AggregateErrorPrototype = $AggregateError.prototype = objectCreate(Error$1.prototype, { 2966 constructor: createPropertyDescriptor(1, $AggregateError), 2967 message: createPropertyDescriptor(1, ''), 2968 name: createPropertyDescriptor(1, 'AggregateError') 2969 }); // `AggregateError` constructor 2970 // https://tc39.es/ecma262/#sec-aggregate-error-constructor 2971 2972 _export({ 2973 global: true 2974 }, { 2975 AggregateError: $AggregateError 2976 }); 2977 2978 var UNSCOPABLES = wellKnownSymbol('unscopables'); 2979 var ArrayPrototype$1 = Array.prototype; // Array.prototype[@@unscopables] 2980 // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 2981 2982 if (ArrayPrototype$1[UNSCOPABLES] == undefined) { 2983 objectDefineProperty.f(ArrayPrototype$1, UNSCOPABLES, { 2984 configurable: true, 2985 value: objectCreate(null) 2986 }); 2987 } // add a key to Array.prototype[@@unscopables] 2988 2989 2990 var addToUnscopables = function (key) { 2991 ArrayPrototype$1[UNSCOPABLES][key] = true; 2992 }; 2993 2994 // `Array.prototype.at` method 2995 // https://github.com/tc39/proposal-relative-indexing-method 2996 2997 2998 _export({ 2999 target: 'Array', 3000 proto: true 3001 }, { 3002 at: function at(index) { 3003 var O = toObject(this); 3004 var len = lengthOfArrayLike(O); 3005 var relativeIndex = toIntegerOrInfinity(index); 3006 var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; 3007 return k < 0 || k >= len ? undefined : O[k]; 3008 } 3009 }); 3010 addToUnscopables('at'); 3011 3012 // `IsArray` abstract operation 3013 // https://tc39.es/ecma262/#sec-isarray 3014 // eslint-disable-next-line es/no-array-isarray -- safe 3015 3016 3017 var isArray = Array.isArray || function isArray(argument) { 3018 return classofRaw(argument) == 'Array'; 3019 }; 3020 3021 var un$Reverse = functionUncurryThis([].reverse); 3022 var test$1 = [1, 2]; // `Array.prototype.reverse` method 3023 // https://tc39.es/ecma262/#sec-array.prototype.reverse 3024 // fix for Safari 12.0 bug 3025 // https://bugs.webkit.org/show_bug.cgi?id=188794 3026 3027 _export({ 3028 target: 'Array', 3029 proto: true, 3030 forced: String(test$1) === String(test$1.reverse()) 3031 }, { 3032 reverse: function reverse() { 3033 // eslint-disable-next-line no-self-assign -- dirty hack 3034 if (isArray(this)) this.length = this.length; 3035 return un$Reverse(this); 3036 } 3037 }); 3038 3039 // eslint-disable-next-line es/no-typed-arrays -- safe 3040 var arrayBufferNative = typeof ArrayBuffer != 'undefined' && typeof DataView != 'undefined'; 3041 3042 var redefineAll = function (target, src, options) { 3043 for (var key in src) redefine(target, key, src[key], options); 3044 3045 return target; 3046 }; 3047 3048 var TypeError$b = global_1.TypeError; 3049 3050 var anInstance = function (it, Prototype) { 3051 if (objectIsPrototypeOf(Prototype, it)) return it; 3052 throw TypeError$b('Incorrect invocation'); 3053 }; 3054 3055 var RangeError = global_1.RangeError; // `ToIndex` abstract operation 3056 // https://tc39.es/ecma262/#sec-toindex 3057 3058 var toIndex = function (it) { 3059 if (it === undefined) return 0; 3060 var number = toIntegerOrInfinity(it); 3061 var length = toLength(number); 3062 if (number !== length) throw RangeError('Wrong length or index'); 3063 return length; 3064 }; 3065 3066 // IEEE754 conversions based on https://github.com/feross/ieee754 3067 3068 3069 var Array$2 = global_1.Array; 3070 var abs = Math.abs; 3071 var pow = Math.pow; 3072 var floor$1 = Math.floor; 3073 var log = Math.log; 3074 var LN2 = Math.LN2; 3075 3076 var pack = function (number, mantissaLength, bytes) { 3077 var buffer = Array$2(bytes); 3078 var exponentLength = bytes * 8 - mantissaLength - 1; 3079 var eMax = (1 << exponentLength) - 1; 3080 var eBias = eMax >> 1; 3081 var rt = mantissaLength === 23 ? pow(2, -24) - pow(2, -77) : 0; 3082 var sign = number < 0 || number === 0 && 1 / number < 0 ? 1 : 0; 3083 var index = 0; 3084 var exponent, mantissa, c; 3085 number = abs(number); // eslint-disable-next-line no-self-compare -- NaN check 3086 3087 if (number != number || number === Infinity) { 3088 // eslint-disable-next-line no-self-compare -- NaN check 3089 mantissa = number != number ? 1 : 0; 3090 exponent = eMax; 3091 } else { 3092 exponent = floor$1(log(number) / LN2); 3093 c = pow(2, -exponent); 3094 3095 if (number * c < 1) { 3096 exponent--; 3097 c *= 2; 3098 } 3099 3100 if (exponent + eBias >= 1) { 3101 number += rt / c; 3102 } else { 3103 number += rt * pow(2, 1 - eBias); 3104 } 3105 3106 if (number * c >= 2) { 3107 exponent++; 3108 c /= 2; 3109 } 3110 3111 if (exponent + eBias >= eMax) { 3112 mantissa = 0; 3113 exponent = eMax; 3114 } else if (exponent + eBias >= 1) { 3115 mantissa = (number * c - 1) * pow(2, mantissaLength); 3116 exponent = exponent + eBias; 3117 } else { 3118 mantissa = number * pow(2, eBias - 1) * pow(2, mantissaLength); 3119 exponent = 0; 3120 } 3121 } 3122 3123 while (mantissaLength >= 8) { 3124 buffer[index++] = mantissa & 255; 3125 mantissa /= 256; 3126 mantissaLength -= 8; 3127 } 3128 3129 exponent = exponent << mantissaLength | mantissa; 3130 exponentLength += mantissaLength; 3131 3132 while (exponentLength > 0) { 3133 buffer[index++] = exponent & 255; 3134 exponent /= 256; 3135 exponentLength -= 8; 3136 } 3137 3138 buffer[--index] |= sign * 128; 3139 return buffer; 3140 }; 3141 3142 var unpack = function (buffer, mantissaLength) { 3143 var bytes = buffer.length; 3144 var exponentLength = bytes * 8 - mantissaLength - 1; 3145 var eMax = (1 << exponentLength) - 1; 3146 var eBias = eMax >> 1;
3147 var nBits = exponentLength - 7; 3148 var index = bytes - 1; 3149 var sign = buffer[index--]; 3150 var exponent = sign & 127; 3151 var mantissa; 3152 sign >>= 7; 3153 3154 while (nBits > 0) { 3155 exponent = exponent * 256 + buffer[index--]; 3156 nBits -= 8; 3157 } 3158 3159 mantissa = exponent & (1 << -nBits) - 1; 3160 exponent >>= -nBits; 3161 nBits += mantissaLength; 3162 3163 while (nBits > 0) { 3164 mantissa = mantissa * 256 + buffer[index--]; 3165 nBits -= 8; 3166 } 3167 3168 if (exponent === 0) { 3169 exponent = 1 - eBias; 3170 } else if (exponent === eMax) { 3171 return mantissa ? NaN : sign ? -Infinity : Infinity; 3172 } else { 3173 mantissa = mantissa + pow(2, mantissaLength); 3174 exponent = exponent - eBias; 3175 } 3176 3177 return (sign ? -1 : 1) * mantissa * pow(2, exponent - mantissaLength); 3178 }; 3179 3180 var ieee754 = { 3181 pack: pack, 3182 unpack: unpack 3183 }; 3184 3185 // `Array.prototype.fill` method implementation 3186 // https://tc39.es/ecma262/#sec-array.prototype.fill 3187 3188 3189 var arrayFill = function fill(value 3190 /* , start = 0, end = @length */ 3191 ) { 3192 var O = toObject(this); 3193 var length = lengthOfArrayLike(O); 3194 var argumentsLength = arguments.length; 3195 var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length); 3196 var end = argumentsLength > 2 ? arguments[2] : undefined; 3197 var endPos = end === undefined ? length : toAbsoluteIndex(end, length); 3198 3199 while (endPos > index) O[index++] = value; 3200 3201 return O; 3202 }; 3203 3204 var defineProperty$1 = objectDefineProperty.f; 3205 3206 3207 3208 3209 3210 var TO_STRING_TAG$3 = wellKnownSymbol('toStringTag'); 3211 3212 var setToStringTag = function (it, TAG, STATIC) { 3213 if (it && !hasOwnProperty_1(it = STATIC ? it : it.prototype, TO_STRING_TAG$3)) { 3214 defineProperty$1(it, TO_STRING_TAG$3, { 3215 configurable: true, 3216 value: TAG 3217 }); 3218 } 3219 }; 3220 3221 var getOwnPropertyNames = objectGetOwnPropertyNames.f; 3222 3223 var defineProperty$2 = objectDefineProperty.f; 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 var PROPER_FUNCTION_NAME = functionName.PROPER; 3234 var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE; 3235 var getInternalState = internalState.get; 3236 var setInternalState = internalState.set; 3237 var ARRAY_BUFFER = 'ArrayBuffer'; 3238 var DATA_VIEW = 'DataView'; 3239 var PROTOTYPE$1 = 'prototype'; 3240 var WRONG_LENGTH = 'Wrong length'; 3241 var WRONG_INDEX = 'Wrong index'; 3242 var NativeArrayBuffer = global_1[ARRAY_BUFFER]; 3243 var $ArrayBuffer = NativeArrayBuffer; 3244 var ArrayBufferPrototype = $ArrayBuffer && $ArrayBuffer[PROTOTYPE$1]; 3245 var $DataView = global_1[DATA_VIEW]; 3246 var DataViewPrototype = $DataView && $DataView[PROTOTYPE$1]; 3247 var ObjectPrototype$1 = Object.prototype; 3248 var Array$3 = global_1.Array; 3249 var RangeError$1 = global_1.RangeError; 3250 var fill = functionUncurryThis(arrayFill); 3251 var reverse = functionUncurryThis([].reverse); 3252 var packIEEE754 = ieee754.pack; 3253 var unpackIEEE754 = ieee754.unpack; 3254 3255 var packInt8 = function (number) { 3256 return [number & 0xFF]; 3257 }; 3258 3259 var packInt16 = function (number) { 3260 return [number & 0xFF, number >> 8 & 0xFF]; 3261 }; 3262 3263 var packInt32 = function (number) { 3264 return [number & 0xFF, number >> 8 & 0xFF, number >> 16 & 0xFF, number >> 24 & 0xFF]; 3265 }; 3266 3267 var unpackInt32 = function (buffer) { 3268 return buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0]; 3269 }; 3270 3271 var packFloat32 = function (number) { 3272 return packIEEE754(number, 23, 4); 3273 }; 3274 3275 var packFloat64 = function (number) { 3276 return packIEEE754(number, 52, 8); 3277 }; 3278 3279 var addGetter = function (Constructor, key) { 3280 defineProperty$2(Constructor[PROTOTYPE$1], key, { 3281 get: function () { 3282 return getInternalState(this)[key]; 3283 } 3284 }); 3285 }; 3286 3287 var get$1 = function (view, count, index, isLittleEndian) { 3288 var intIndex = toIndex(index); 3289 var store = getInternalState(view); 3290 if (intIndex + count > store.byteLength) throw RangeError$1(WRONG_INDEX); 3291 var bytes = getInternalState(store.buffer).bytes; 3292 var start = intIndex + store.byteOffset; 3293 var pack = arraySliceSimple(bytes, start, start + count); 3294 return isLittleEndian ? pack : reverse(pack); 3295 }; 3296 3297 var set$1 = function (view, count, index, conversion, value, isLittleEndian) { 3298 var intIndex = toIndex(index); 3299 var store = getInternalState(view); 3300 if (intIndex + count > store.byteLength) throw RangeError$1(WRONG_INDEX); 3301 var bytes = getInternalState(store.buffer).bytes; 3302 var start = intIndex + store.byteOffset; 3303 var pack = conversion(+value); 3304 3305 for (var i = 0; i < count; i++) bytes[start + i] = pack[isLittleEndian ? i : count - i - 1]; 3306 }; 3307 3308 if (!arrayBufferNative) { 3309 $ArrayBuffer = function ArrayBuffer(length) { 3310 anInstance(this, ArrayBufferPrototype); 3311 var byteLength = toIndex(length); 3312 setInternalState(this, { 3313 bytes: fill(Array$3(byteLength), 0), 3314 byteLength: byteLength 3315 }); 3316 if (!descriptors) this.byteLength = byteLength; 3317 }; 3318 3319 ArrayBufferPrototype = $ArrayBuffer[PROTOTYPE$1]; 3320 3321 $DataView = function DataView(buffer, byteOffset, byteLength) { 3322 anInstance(this, DataViewPrototype); 3323 anInstance(buffer, ArrayBufferPrototype); 3324 var bufferLength = getInternalState(buffer).byteLength; 3325 var offset = toIntegerOrInfinity(byteOffset); 3326 if (offset < 0 || offset > bufferLength) throw RangeError$1('Wrong offset'); 3327 byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength); 3328 if (offset + byteLength > bufferLength) throw RangeError$1(WRONG_LENGTH); 3329 setInternalState(this, { 3330 buffer: buffer, 3331 byteLength: byteLength, 3332 byteOffset: offset 3333 }); 3334 3335 if (!descriptors) { 3336 this.buffer = buffer; 3337 this.byteLength = byteLength; 3338 this.byteOffset = offset; 3339 } 3340 }; 3341 3342 DataViewPrototype = $DataView[PROTOTYPE$1]; 3343 3344 if (descriptors) { 3345 addGetter($ArrayBuffer, 'byteLength'); 3346 addGetter($DataView, 'buffer'); 3347 addGetter($DataView, 'byteLength'); 3348 addGetter($DataView, 'byteOffset'); 3349 } 3350 3351 redefineAll(DataViewPrototype, { 3352 getInt8: function getInt8(byteOffset) { 3353 return get$1(this, 1, byteOffset)[0] << 24 >> 24; 3354 }, 3355 getUint8: function getUint8(byteOffset) { 3356 return get$1(this, 1, byteOffset)[0]; 3357 }, 3358 getInt16: function getInt16(byteOffset 3359 /* , littleEndian */ 3360 ) { 3361 var bytes = get$1(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined);
3362 return (bytes[1] << 8 | bytes[0]) << 16 >> 16; 3363 }, 3364 getUint16: function getUint16(byteOffset 3365 /* , littleEndian */ 3366 ) { 3367 var bytes = get$1(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined); 3368 return bytes[1] << 8 | bytes[0]; 3369 }, 3370 getInt32: function getInt32(byteOffset 3371 /* , littleEndian */ 3372 ) { 3373 return unpackInt32(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)); 3374 }, 3375 getUint32: function getUint32(byteOffset 3376 /* , littleEndian */ 3377 ) { 3378 return unpackInt32(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)) >>> 0; 3379 }, 3380 getFloat32: function getFloat32(byteOffset 3381 /* , littleEndian */ 3382 ) { 3383 return unpackIEEE754(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 23); 3384 }, 3385 getFloat64: function getFloat64(byteOffset 3386 /* , littleEndian */ 3387 ) { 3388 return unpackIEEE754(get$1(this, 8, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 52); 3389 }, 3390 setInt8: function setInt8(byteOffset, value) { 3391 set$1(this, 1, byteOffset, packInt8, value); 3392 }, 3393 setUint8: function setUint8(byteOffset, value) { 3394 set$1(this, 1, byteOffset, packInt8, value); 3395 }, 3396 setInt16: function setInt16(byteOffset, value 3397 /* , littleEndian */ 3398 ) { 3399 set$1(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined); 3400 }, 3401 setUint16: function setUint16(byteOffset, value 3402 /* , littleEndian */ 3403 ) { 3404 set$1(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined); 3405 }, 3406 setInt32: function setInt32(byteOffset, value 3407 /* , littleEndian */ 3408 ) { 3409 set$1(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined); 3410 }, 3411 setUint32: function setUint32(byteOffset, value 3412 /* , littleEndian */ 3413 ) { 3414 set$1(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined); 3415 }, 3416 setFloat32: function setFloat32(byteOffset, value 3417 /* , littleEndian */ 3418 ) { 3419 set$1(this, 4, byteOffset, packFloat32, value, arguments.length > 2 ? arguments[2] : undefined); 3420 }, 3421 setFloat64: function setFloat64(byteOffset, value 3422 /* , littleEndian */ 3423 ) { 3424 set$1(this, 8, byteOffset, packFloat64, value, arguments.length > 2 ? arguments[2] : undefined); 3425 } 3426 }); 3427 } else { 3428 var INCORRECT_ARRAY_BUFFER_NAME = PROPER_FUNCTION_NAME && NativeArrayBuffer.name !== ARRAY_BUFFER; 3429 /* eslint-disable no-new -- required for testing */ 3430 3431 if (!fails(function () { 3432 NativeArrayBuffer(1); 3433 }) || !fails(function () { 3434 new NativeArrayBuffer(-1); 3435 }) || fails(function () { 3436 new NativeArrayBuffer(); 3437 new NativeArrayBuffer(1.5); 3438 new NativeArrayBuffer(NaN); 3439 return INCORRECT_ARRAY_BUFFER_NAME && !CONFIGURABLE_FUNCTION_NAME; 3440 })) { 3441 /* eslint-enable no-new -- required for testing */ 3442 $ArrayBuffer = function ArrayBuffer(length) { 3443 anInstance(this, ArrayBufferPrototype); 3444 return new NativeArrayBuffer(toIndex(length)); 3445 }; 3446 3447 $ArrayBuffer[PROTOTYPE$1] = ArrayBufferPrototype; 3448 3449 for (var keys$1 = getOwnPropertyNames(NativeArrayBuffer), j = 0, key; keys$1.length > j;) { 3450 if (!((key = keys$1[j++]) in $ArrayBuffer)) { 3451 createNonEnumerableProperty($ArrayBuffer, key, NativeArrayBuffer[key]); 3452 } 3453 } 3454 3455 ArrayBufferPrototype.constructor = $ArrayBuffer; 3456 } else if (INCORRECT_ARRAY_BUFFER_NAME && CONFIGURABLE_FUNCTION_NAME) { 3457 createNonEnumerableProperty(NativeArrayBuffer, 'name', ARRAY_BUFFER); 3458 } // WebKit bug - the same parent prototype for typed arrays and data view 3459 3460 3461 if (objectSetPrototypeOf && objectGetPrototypeOf(DataViewPrototype) !== ObjectPrototype$1) { 3462 objectSetPrototypeOf(DataViewPrototype, ObjectPrototype$1); 3463 } // iOS Safari 7.x bug 3464 3465 3466 var testView = new $DataView(new $ArrayBuffer(2)); 3467 var $setInt8 = functionUncurryThis(DataViewPrototype.setInt8); 3468 testView.setInt8(0, 2147483648); 3469 testView.setInt8(1, 2147483649); 3470 if (testView.getInt8(0) || !testView.getInt8(1)) redefineAll(DataViewPrototype, { 3471 setInt8: function setInt8(byteOffset, value) { 3472 $setInt8(this, byteOffset, value << 24 >> 24); 3473 }, 3474 setUint8: function setUint8(byteOffset, value) { 3475 $setInt8(this, byteOffset, value << 24 >> 24); 3476 } 3477 }, { 3478 unsafe: true 3479 }); 3480 } 3481 3482 setToStringTag($ArrayBuffer, ARRAY_BUFFER); 3483 setToStringTag($DataView, DATA_VIEW); 3484 var arrayBuffer = { 3485 ArrayBuffer: $ArrayBuffer, 3486 DataView: $DataView 3487 }; 3488 3489 var noop = function () { 3490 /* empty */ 3491 }; 3492 3493 var empty = []; 3494 var construct = getBuiltIn('Reflect', 'construct'); 3495 var constructorRegExp = /^\s*(?:class|function)\b/; 3496 var exec = functionUncurryThis(constructorRegExp.exec); 3497 var INCORRECT_TO_STRING = !constructorRegExp.exec(noop); 3498 3499 var isConstructorModern = function (argument) { 3500 if (!isCallable(argument)) return false;
3501 3502 try { 3503 construct(noop, empty, argument); 3504 return true; 3505 } catch (error) { 3506 return false; 3507 } 3508 }; 3509 3510 var isConstructorLegacy = function (argument) { 3511 if (!isCallable(argument)) return false; 3512 3513 switch (classof(argument)) { 3514 case 'AsyncFunction': 3515 case 'GeneratorFunction': 3516 case 'AsyncGeneratorFunction': 3517 return false; 3518 // we can't check .prototype since constructors produced by .bind haven't it 3519 } 3520 3521 return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument)); 3522 }; // `IsConstructor` abstract operation 3523 // https://tc39.es/ecma262/#sec-isconstructor 3524 3525 3526 var isConstructor = !construct || fails(function () { 3527 var called; 3528 return isConstructorModern(isConstructorModern.call) || !isConstructorModern(Object) || !isConstructorModern(function () { 3529 called = true; 3530 }) || called; 3531 }) ? isConstructorLegacy : isConstructorModern; 3532 3533 var TypeError$c = global_1.TypeError; // `Assert: IsConstructor(argument) is true` 3534 3535 var aConstructor = function (argument) { 3536 if (isConstructor(argument)) return argument; 3537 throw TypeError$c(tryToString(argument) + ' is not a constructor'); 3538 }; 3539 3540 var SPECIES = wellKnownSymbol('species'); // `SpeciesConstructor` abstract operation 3541 // https://tc39.es/ecma262/#sec-speciesconstructor 3542 3543 var speciesConstructor = function (O, defaultConstructor) { 3544 var C = anObject(O).constructor; 3545 var S; 3546 return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aConstructor(S); 3547 }; 3548 3549 var ArrayBuffer$1 = arrayBuffer.ArrayBuffer; 3550 var DataView$1 = arrayBuffer.DataView; 3551 var DataViewPrototype$1 = DataView$1.prototype; 3552 var un$ArrayBufferSlice = functionUncurryThis(ArrayBuffer$1.prototype.slice); 3553 var getUint8 = functionUncurryThis(DataViewPrototype$1.getUint8); 3554 var setUint8 = functionUncurryThis(DataViewPrototype$1.setUint8); 3555 var INCORRECT_SLICE = fails(function () { 3556 return !new ArrayBuffer$1(2).slice(1, undefined).byteLength; 3557 }); // `ArrayBuffer.prototype.slice` method 3558 // https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice 3559 3560 _export({ 3561 target: 'ArrayBuffer', 3562 proto: true, 3563 unsafe: true, 3564 forced: INCORRECT_SLICE 3565 }, { 3566 slice: function slice(start, end) { 3567 if (un$ArrayBufferSlice && end === undefined) { 3568 return un$ArrayBufferSlice(anObject(this), start); // FF fix 3569 } 3570 3571 var length = anObject(this).byteLength; 3572 var first = toAbsoluteIndex(start, length); 3573 var fin = toAbsoluteIndex(end === undefined ? length : end, length); 3574 var result = new (speciesConstructor(this, ArrayBuffer$1))(toLength(fin - first)); 3575 var viewSource = new DataView$1(this); 3576 var viewTarget = new DataView$1(result); 3577 var index = 0; 3578 3579 while (first < fin) { 3580 setUint8(viewTarget, index++, getUint8(viewSource, first++)); 3581 } 3582 3583 return result; 3584 } 3585 }); 3586 3587 // `Object.fromEntries` method 3588 // https://github.com/tc39/proposal-object-from-entries 3589 3590 3591 _export({ 3592 target: 'Object', 3593 stat: true 3594 }, { 3595 fromEntries: function fromEntries(iterable) { 3596 var obj = {}; 3597 iterate(iterable, function (k, v) { 3598 createProperty(obj, k, v); 3599 }, { 3600 AS_ENTRIES: true 3601 }); 3602 return obj; 3603 } 3604 }); 3605 3606 // `Object.hasOwn` method 3607 // https://github.com/tc39/proposal-accessible-object-hasownproperty 3608 3609 3610 _export({ 3611 target: 'Object', 3612 stat: true 3613 }, { 3614 hasOwn: hasOwnProperty_1 3615 }); 3616 3617 var PromiseCapability = function (C) { 3618 var resolve, reject; 3619 this.promise = new C(function ($$resolve, $$reject) { 3620 if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor'); 3621 resolve = $$resolve; 3622 reject = $$reject; 3623 }); 3624 this.resolve = aCallable(resolve); 3625 this.reject = aCallable(reject); 3626 }; // `NewPromiseCapability` abstract operation 3627 // https://tc39.es/ecma262/#sec-newpromisecapability 3628 3629 3630 var f$5 = function (C) { 3631 return new PromiseCapability(C); 3632 }; 3633 3634 var newPromiseCapability = { 3635 f: f$5 3636 }; 3637 3638 var perform = function (exec) { 3639 try { 3640 return { 3641 error: false, 3642 value: exec() 3643 }; 3644 } catch (error) { 3645 return { 3646 error: true, 3647 value: error 3648 }; 3649 } 3650 }; 3651 3652 // `Promise.allSettled` method 3653 // https://tc39.es/ecma262/#sec-promise.allsettled 3654 3655 3656 _export({ 3657 target: 'Promise', 3658 stat: true 3659 }, { 3660 allSettled: function allSettled(iterable) { 3661 var C = this; 3662 var capability = newPromiseCapability.f(C); 3663 var resolve = capability.resolve; 3664 var reject = capability.reject; 3665 var result = perform(function () { 3666 var promiseResolve = aCallable(C.resolve); 3667 var values = []; 3668 var counter = 0; 3669 var remaining = 1; 3670 iterate(iterable, function (promise) { 3671 var index = counter++; 3672 var alreadyCalled = false;
vendor: 2,994 bytes, lines 3673-3772
3673 remaining++; 3674 functionCall(promiseResolve, C, promise).then(function (value) { 3675 if (alreadyCalled) return; 3676 alreadyCalled = true; 3677 values[index] = { 3678 status: 'fulfilled', 3679 value: value 3680 }; 3681 --remaining || resolve(values); 3682 }, function (error) { 3683 if (alreadyCalled) return; 3684 alreadyCalled = true; 3685 values[index] = { 3686 status: 'rejected', 3687 reason: error 3688 }; 3689 --remaining || resolve(values); 3690 }); 3691 }); 3692 --remaining || resolve(values); 3693 }); 3694 if (result.error) reject(result.value); 3695 return capability.promise; 3696 } 3697 }); 3698 3699 var PROMISE_ANY_ERROR = 'No one promise resolved'; // `Promise.any` method 3700 // https://tc39.es/ecma262/#sec-promise.any 3701 3702 _export({ 3703 target: 'Promise', 3704 stat: true 3705 }, { 3706 any: function any(iterable) { 3707 var C = this; 3708 var AggregateError = getBuiltIn('AggregateError'); 3709 var capability = newPromiseCapability.f(C); 3710 var resolve = capability.resolve; 3711 var reject = capability.reject; 3712 var result = perform(function () { 3713 var promiseResolve = aCallable(C.resolve); 3714 var errors = []; 3715 var counter = 0; 3716 var remaining = 1; 3717 var alreadyResolved = false; 3718 iterate(iterable, function (promise) { 3719 var index = counter++; 3720 var alreadyRejected = false; 3721 remaining++; 3722 functionCall(promiseResolve, C, promise).then(function (value) { 3723 if (alreadyRejected || alreadyResolved) return; 3724 alreadyResolved = true; 3725 resolve(value); 3726 }, function (error) { 3727 if (alreadyRejected || alreadyResolved) return; 3728 alreadyRejected = true; 3729 errors[index] = error; 3730 --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR)); 3731 }); 3732 }); 3733 --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR)); 3734 }); 3735 if (result.error) reject(result.value); 3736 return capability.promise; 3737 } 3738 }); 3739 3740 var nativePromiseConstructor = global_1.Promise; 3741 3742 var promiseResolve = function (C, x) { 3743 anObject(C); 3744 if (isObject(x) && x.constructor === C) return x; 3745 var promiseCapability = newPromiseCapability.f(C); 3746 var resolve = promiseCapability.resolve; 3747 resolve(x); 3748 return promiseCapability.promise; 3749 }; 3750 3751 // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829 3752 3753 3754 var NON_GENERIC = !!nativePromiseConstructor && fails(function () { 3755 nativePromiseConstructor.prototype['finally'].call({ 3756 then: function () { 3757 /* empty */ 3758 } 3759 }, function () { 3760 /* empty */ 3761 }); 3762 }); // `Promise.prototype.finally` method 3763 // https://tc39.es/ecma262/#sec-promise.prototype.finally 3764 3765 _export({ 3766 target: 'Promise', 3767 proto: true, 3768 real: true, 3769 forced: NON_GENERIC 3770 }, { 3771 'finally': function (onFinally) { 3772 var C = speciesConstructor(this, getBuiltIn('Promise'));
3773 var isFunction = isCallable(onFinally); 3774 return this.then(isFunction ? function (x) { 3775 return promiseResolve(C, onFinally()).then(function () { 3776 return x; 3777 }); 3778 } : onFinally, isFunction ? function (e) { 3779 return promiseResolve(C, onFinally()).then(function () { 3780 throw e; 3781 }); 3782 } : onFinally); 3783 } 3784 }); // makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then` 3785 3786 if (!isPure && isCallable(nativePromiseConstructor)) { 3787 var method = getBuiltIn('Promise').prototype['finally']; 3788 3789 if (nativePromiseConstructor.prototype['finally'] !== method) { 3790 redefine(nativePromiseConstructor.prototype, 'finally', method, { 3791 unsafe: true 3792 }); 3793 } 3794 } 3795 3796 var ITERATOR$2 = wellKnownSymbol('iterator'); 3797 var BUGGY_SAFARI_ITERATORS = false; // `%IteratorPrototype%` object 3798 // https://tc39.es/ecma262/#sec-%iteratorprototype%-object 3799 3800 var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator; 3801 /* eslint-disable es/no-array-prototype-keys -- safe */ 3802 3803 if ([].keys) { 3804 arrayIterator = [].keys(); // Safari 8 has buggy iterators w/o `next` 3805 3806 if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;else { 3807 PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator)); 3808 if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype; 3809 } 3810 } 3811 3812 var NEW_ITERATOR_PROTOTYPE = IteratorPrototype == undefined || fails(function () { 3813 var test = {}; // FF44- legacy iterators case 3814 3815 return IteratorPrototype[ITERATOR$2].call(test) !== test; 3816 }); 3817 if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {}; // `%IteratorPrototype%[@@iterator]()` method 3818 // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator 3819 3820 if (!isCallable(IteratorPrototype[ITERATOR$2])) { 3821 redefine(IteratorPrototype, ITERATOR$2, function () { 3822 return this; 3823 }); 3824 } 3825 3826 var iteratorsCore = { 3827 IteratorPrototype: IteratorPrototype, 3828 BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS 3829 }; 3830 3831 var IteratorPrototype$1 = iteratorsCore.IteratorPrototype; 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 var returnThis = function () { 3842 return this; 3843 }; 3844 3845 var createIteratorConstructor = function (IteratorConstructor, NAME, next) { 3846 var TO_STRING_TAG = NAME + ' Iterator'; 3847 IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, { 3848 next: createPropertyDescriptor(1, next) 3849 }); 3850 setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true); 3851 iterators[TO_STRING_TAG] = returnThis; 3852 return IteratorConstructor; 3853 }; 3854 3855 var MATCH = wellKnownSymbol('match'); // `IsRegExp` abstract operation 3856 // https://tc39.es/ecma262/#sec-isregexp 3857 3858 var isRegexp = function (it) { 3859 var isRegExp; 3860 return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classofRaw(it) == 'RegExp'); 3861 }; 3862 3863 // `RegExp.prototype.flags` getter implementation 3864 // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags 3865 3866 3867 var regexpFlags = function () { 3868 var that = anObject(this); 3869 var result = ''; 3870 if (that.global) result += 'g'; 3871 if (that.ignoreCase) result += 'i'; 3872 if (that.multiline) result += 'm'; 3873 if (that.dotAll) result += 's'; 3874 if (that.unicode) result += 'u'; 3875 if (that.sticky) result += 'y'; 3876 return result; 3877 }; 3878 3879 var charAt = functionUncurryThis(''.charAt); 3880 var charCodeAt = functionUncurryThis(''.charCodeAt); 3881 var stringSlice$1 = functionUncurryThis(''.slice); 3882 3883 var createMethod$1 = function (CONVERT_TO_STRING) { 3884 return function ($this, pos) { 3885 var S = toString_1(requireObjectCoercible($this)); 3886 var position = toIntegerOrInfinity(pos); 3887 var size = S.length; 3888 var first, second; 3889 if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined; 3890 first = charCodeAt(S, position); 3891 return first < 0xD800 || first > 0xDBFF || position + 1 === size || (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF ? CONVERT_TO_STRING ? charAt(S, position) : first : CONVERT_TO_STRING ? stringSlice$1(S, position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000; 3892 }; 3893 }; 3894 3895 var stringMultibyte = { 3896 // `String.prototype.codePointAt` method 3897 // https://tc39.es/ecma262/#sec-string.prototype.codepointat 3898 codeAt: createMethod$1(false), 3899 // `String.prototype.at` method 3900 // https://github.com/mathiasbynens/String.prototype.at 3901 charAt: createMethod$1(true) 3902 }; 3903 3904 var charAt$1 = stringMultibyte.charAt; // `AdvanceStringIndex` abstract operation 3905 // https://tc39.es/ecma262/#sec-advancestringindex 3906 3907 3908 var advanceStringIndex = function (S, index, unicode) { 3909 return index + (unicode ? charAt$1(S, index).length : 1); 3910 }; 3911 3912 // babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError 3913 3914 3915 var $RegExp = global_1.RegExp; 3916 var UNSUPPORTED_Y = fails(function () { 3917 var re = $RegExp('a', 'y'); 3918 re.lastIndex = 2; 3919 return re.exec('abcd') != null; 3920 }); // UC Browser bug 3921 // https://github.com/zloirock/core-js/issues/1008 3922 3923 var MISSED_STICKY = UNSUPPORTED_Y || fails(function () { 3924 return !$RegExp('a', 'y').sticky; 3925 }); 3926 var BROKEN_CARET = UNSUPPORTED_Y || fails(function () { 3927 // https://bugzilla.mozilla.org/show_bug.cgi?id=773687 3928 var re = $RegExp('^r', 'gy'); 3929 re.lastIndex = 2; 3930 return re.exec('str') != null; 3931 }); 3932 var regexpStickyHelpers = { 3933 BROKEN_CARET: BROKEN_CARET, 3934 MISSED_STICKY: MISSED_STICKY, 3935 UNSUPPORTED_Y: UNSUPPORTED_Y 3936 }; 3937 3938 // babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError 3939 3940 3941 var $RegExp$1 = global_1.RegExp; 3942 var regexpUnsupportedDotAll = fails(function () { 3943 var re = $RegExp$1('.', 's'); 3944 return !(re.dotAll && re.exec('\n') && re.flags === 's'); 3945 }); 3946 3947 // babel-minify and Closure Compiler transpiles RegExp('(?<a>b)', 'g') -> /(?<a>b)/g and it causes SyntaxError 3948 3949 3950 var $RegExp$2 = global_1.RegExp; 3951 var regexpUnsupportedNcg = fails(function () {
vendor: 5,743 bytes, lines 3952-4185
3952 var re = $RegExp$2('(?<a>b)', 'g'); 3953 return re.exec('b').groups.a !== 'b' || 'b'.replace(re, '$<a>c') !== 'bc'; 3954 }); 3955 3956 /* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */ 3957 3958 /* eslint-disable regexp/no-useless-quantifier -- testing */ 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 var getInternalState$1 = internalState.get; 3975 3976 3977 3978 3979 3980 var nativeReplace = shared('native-string-replace', String.prototype.replace); 3981 var nativeExec = RegExp.prototype.exec; 3982 var patchedExec = nativeExec; 3983 var charAt$2 = functionUncurryThis(''.charAt); 3984 var indexOf$1 = functionUncurryThis(''.indexOf); 3985 var replace$1 = functionUncurryThis(''.replace); 3986 var stringSlice$2 = functionUncurryThis(''.slice); 3987 3988 var UPDATES_LAST_INDEX_WRONG = function () { 3989 var re1 = /a/; 3990 var re2 = /b*/g; 3991 functionCall(nativeExec, re1, 'a'); 3992 functionCall(nativeExec, re2, 'a'); 3993 return re1.lastIndex !== 0 || re2.lastIndex !== 0; 3994 }(); 3995 3996 var UNSUPPORTED_Y$1 = regexpStickyHelpers.BROKEN_CARET; // nonparticipating capturing group, copied from es5-shim's String#split patch. 3997 3998 var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; 3999 var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$1 || regexpUnsupportedDotAll || regexpUnsupportedNcg; 4000 4001 if (PATCH) { 4002 patchedExec = function exec(string) { 4003 var re = this; 4004 var state = getInternalState$1(re); 4005 var str = toString_1(string); 4006 var raw = state.raw; 4007 var result, reCopy, lastIndex, match, i, object, group; 4008 4009 if (raw) { 4010 raw.lastIndex = re.lastIndex; 4011 result = functionCall(patchedExec, raw, str); 4012 re.lastIndex = raw.lastIndex; 4013 return result; 4014 } 4015 4016 var groups = state.groups; 4017 var sticky = UNSUPPORTED_Y$1 && re.sticky; 4018 var flags = functionCall(regexpFlags, re); 4019 var source = re.source; 4020 var charsAdded = 0; 4021 var strCopy = str; 4022 4023 if (sticky) { 4024 flags = replace$1(flags, 'y', ''); 4025 4026 if (indexOf$1(flags, 'g') === -1) { 4027 flags += 'g'; 4028 } 4029 4030 strCopy = stringSlice$2(str, re.lastIndex); // Support anchored sticky behavior. 4031 4032 if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$2(str, re.lastIndex - 1) !== '\n')) { 4033 source = '(?: ' + source + ')'; 4034 strCopy = ' ' + strCopy; 4035 charsAdded++; 4036 } // ^(? + rx + ) is needed, in combination with some str slicing, to 4037 // simulate the 'y' flag. 4038 4039 4040 reCopy = new RegExp('^(?:' + source + ')', flags); 4041 } 4042 4043 if (NPCG_INCLUDED) { 4044 reCopy = new RegExp('^' + source + '$(?!\\s)', flags); 4045 } 4046 4047 if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex; 4048 match = functionCall(nativeExec, sticky ? reCopy : re, strCopy); 4049 4050 if (sticky) { 4051 if (match) { 4052 match.input = stringSlice$2(match.input, charsAdded); 4053 match[0] = stringSlice$2(match[0], charsAdded); 4054 match.index = re.lastIndex; 4055 re.lastIndex += match[0].length; 4056 } else re.lastIndex = 0; 4057 } else if (UPDATES_LAST_INDEX_WRONG && match) { 4058 re.lastIndex = re.global ? match.index + match[0].length : lastIndex; 4059 } 4060 4061 if (NPCG_INCLUDED && match && match.length > 1) { 4062 // Fix browsers whose `exec` methods don't consistently return `undefined` 4063 // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/ 4064 functionCall(nativeReplace, match[0], reCopy, function () { 4065 for (i = 1; i < arguments.length - 2; i++) { 4066 if (arguments[i] === undefined) match[i] = undefined; 4067 } 4068 }); 4069 } 4070 4071 if (match && groups) { 4072 match.groups = object = objectCreate(null); 4073 4074 for (i = 0; i < groups.length; i++) { 4075 group = groups[i]; 4076 object[group[0]] = match[group[1]]; 4077 } 4078 } 4079 4080 return match; 4081 }; 4082 } 4083 4084 var regexpExec = patchedExec; 4085 4086 var TypeError$d = global_1.TypeError; // `RegExpExec` abstract operation 4087 // https://tc39.es/ecma262/#sec-regexpexec 4088 4089 var regexpExecAbstract = function (R, S) { 4090 var exec = R.exec; 4091 4092 if (isCallable(exec)) { 4093 var result = functionCall(exec, R, S); 4094 if (result !== null) anObject(result); 4095 return result; 4096 } 4097 4098 if (classofRaw(R) === 'RegExp') return functionCall(regexpExec, R, S); 4099 throw TypeError$d('RegExp#exec called on incompatible receiver'); 4100 }; 4101 4102 /* eslint-disable es/no-string-prototype-matchall -- safe */ 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 var MATCH_ALL = wellKnownSymbol('matchAll'); 4149 var REGEXP_STRING = 'RegExp String'; 4150 var REGEXP_STRING_ITERATOR = REGEXP_STRING + ' Iterator'; 4151 var setInternalState$1 = internalState.set; 4152 var getInternalState$2 = internalState.getterFor(REGEXP_STRING_ITERATOR); 4153 var RegExpPrototype = RegExp.prototype; 4154 var TypeError$e = global_1.TypeError; 4155 var getFlags = functionUncurryThis(regexpFlags); 4156 var stringIndexOf = functionUncurryThis(''.indexOf); 4157 var un$MatchAll = functionUncurryThis(''.matchAll); 4158 var WORKS_WITH_NON_GLOBAL_REGEX = !!un$MatchAll && !fails(function () { 4159 un$MatchAll('a', /./); 4160 }); 4161 var $RegExpStringIterator = createIteratorConstructor(function RegExpStringIterator(regexp, string, $global, fullUnicode) { 4162 setInternalState$1(this, { 4163 type: REGEXP_STRING_ITERATOR, 4164 regexp: regexp, 4165 string: string, 4166 global: $global, 4167 unicode: fullUnicode, 4168 done: false 4169 }); 4170 }, REGEXP_STRING, function next() { 4171 var state = getInternalState$2(this); 4172 if (state.done) return { 4173 value: undefined, 4174 done: true 4175 }; 4176 var R = state.regexp; 4177 var S = state.string; 4178 var match = regexpExecAbstract(R, S); 4179 if (match === null) return { 4180 value: undefined, 4181 done: state.done = true 4182 }; 4183 4184 if (state.global) { 4185 if (toString_1(match[0]) === '') R.lastIndex = advanceStringIndex(S, toLe
4185ngth(R.lastIndex), state.unicode); 4186 return { 4187 value: match, 4188 done: false 4189 }; 4190 } 4191 4192 state.done = true; 4193 return { 4194 value: match, 4195 done: false 4196 }; 4197 }); 4198 4199 var $matchAll = function (string) { 4200 var R = anObject(this); 4201 var S = toString_1(string); 4202 var C, flagsValue, flags, matcher, $global, fullUnicode; 4203 C = speciesConstructor(R, RegExp); 4204 flagsValue = R.flags; 4205 4206 if (flagsValue === undefined && objectIsPrototypeOf(RegExpPrototype, R) && !('flags' in RegExpPrototype)) { 4207 flagsValue = getFlags(R); 4208 } 4209 4210 flags = flagsValue === undefined ? '' : toString_1(flagsValue); 4211 matcher = new C(C === RegExp ? R.source : R, flags); 4212 $global = !!~stringIndexOf(flags, 'g'); 4213 fullUnicode = !!~stringIndexOf(flags, 'u'); 4214 matcher.lastIndex = toLength(R.lastIndex); 4215 return new $RegExpStringIterator(matcher, S, $global, fullUnicode); 4216 }; // `String.prototype.matchAll` method 4217 // https://tc39.es/ecma262/#sec-string.prototype.matchall 4218 4219 4220 _export({ 4221 target: 'String', 4222 proto: true, 4223 forced: WORKS_WITH_NON_GLOBAL_REGEX 4224 }, { 4225 matchAll: function matchAll(regexp) { 4226 var O = requireObjectCoercible(this); 4227 var flags, S, matcher, rx; 4228 4229 if (regexp != null) { 4230 if (isRegexp(regexp)) { 4231 flags = toString_1(requireObjectCoercible('flags' in RegExpPrototype ? regexp.flags : getFlags(regexp))); 4232 if (!~stringIndexOf(flags, 'g')) throw TypeError$e('`.matchAll` does not allow non-global regexes'); 4233 } 4234 4235 if (WORKS_WITH_NON_GLOBAL_REGEX) return un$MatchAll(O, regexp); 4236 matcher = getMethod(regexp, MATCH_ALL); 4237 if (matcher === undefined && isPure && classofRaw(regexp) == 'RegExp') matcher = $matchAll; 4238 if (matcher) return functionCall(matcher, regexp, O); 4239 } else if (WORKS_WITH_NON_GLOBAL_REGEX) return un$MatchAll(O, regexp); 4240 4241 S = toString_1(O); 4242 rx = new RegExp(regexp, 'g'); 4243 return isPure ? functionCall($matchAll, rx, S) : rx[MATCH_ALL](S); 4244 } 4245 }); 4246 isPure || MATCH_ALL in RegExpPrototype || redefine(RegExpPrototype, MATCH_ALL, $matchAll); 4247 4248 var floor$2 = Math.floor; 4249 var charAt$3 = functionUncurryThis(''.charAt); 4250 var replace$2 = functionUncurryThis(''.replace); 4251 var stringSlice$3 = functionUncurryThis(''.slice); 4252 var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g; 4253 var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g; // `GetSubstitution` abstract operation 4254 // https://tc39.es/ecma262/#sec-getsubstitution 4255 4256 var getSubstitution = function (matched, str, position, captures, namedCaptures, replacement) { 4257 var tailPos = position + matched.length; 4258 var m = captures.length; 4259 var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED; 4260 4261 if (namedCaptures !== undefined) { 4262 namedCaptures = toObject(namedCaptures); 4263 symbols = SUBSTITUTION_SYMBOLS; 4264 } 4265 4266 return replace$2(replacement, symbols, function (match, ch) { 4267 var capture; 4268 4269 switch (charAt$3(ch, 0)) { 4270 case '$': 4271 return '$'; 4272 4273 case '&': 4274 return matched; 4275 4276 case '`': 4277 return stringSlice$3(str, 0, position); 4278 4279 case "'": 4280 return stringSlice$3(str, tailPos); 4281 4282 case '<': 4283 capture = namedCaptures[stringSlice$3(ch, 1, -1)]; 4284 break; 4285 4286 default: 4287 // \d\d? 4288 var n = +ch; 4289 if (n === 0) return match; 4290 4291 if (n > m) { 4292 var f = floor$2(n / 10); 4293 if (f === 0) return match; 4294 if (f <= m) return captures[f - 1] === undefined ? charAt$3(ch, 1) : captures[f - 1] + charAt$3(ch, 1); 4295 return match; 4296 } 4297 4298 capture = captures[n - 1]; 4299 } 4300 4301 return capture === undefined ? '' : capture; 4302 }); 4303 }; 4304 4305 var REPLACE = wellKnownSymbol('replace'); 4306 var RegExpPrototype$1 = RegExp.prototype; 4307 var TypeError$f = global_1.TypeError; 4308 var getFlags$1 = functionUncurryThis(regexpFlags); 4309 var indexOf$2 = functionUncurryThis(''.indexOf); 4310 var replace$3 = functionUncurryThis(''.replace); 4311 var stringSlice$4 = functionUncurryThis(''.slice); 4312 var max$2 = Math.max; 4313 4314 var stringIndexOf$1 = function (string, searchValue, fromIndex) { 4315 if (fromIndex > string.length) return -1; 4316 if (searchValue === '') return fromIndex; 4317 return indexOf$2(string, searchValue, fromIndex); 4318 }; // `String.prototype.replaceAll` method 4319 // https://tc39.es/ecma262/#sec-string.prototype.replaceall 4320 4321 4322 _export({ 4323 target: 'String', 4324 proto: true 4325 }, { 4326 replaceAll: function replaceAll(searchValue, replaceValue) { 4327 var O = requireObjectCoercible(this); 4328 var IS_REG_EXP, flags, replacer, string, searchString, functionalReplace, searchLength, advanceBy, replacement; 4329 var position = 0; 4330 var endOfLastMatch = 0; 4331 var result = ''; 4332 4333 if (searchValue != null) { 4334 IS_REG_EXP = isRegexp(searchValue); 4335 4336 if (IS_REG_EXP) { 4337 flags = toString_1(requireObjectCoercible('flags' in RegExpPrototype$1 ? searchValue.flags : getFlags$1(searchValue))); 4338 if (!~indexOf$2(flags, 'g')) throw TypeError$f('`.replaceAll` does not allow non-global regexes'); 4339 } 4340 4341 replacer = getMethod(searchValue, REPLACE); 4342 4343 if (replacer) { 4344 return functionCall(replacer, searchValue, O, replaceValue); 4345 } else if (isPure && IS_REG_EXP) { 4346 return replace$3(toString_1(O), searchValue, replaceValue); 4347 } 4348 } 4349 4350 string = toString_1(O); 4351 searchString = toString_1(searchValue); 4352 functionalReplace = isCallable(replaceValue); 4353 if (!functionalReplace) replaceValue = toString_1(replaceValue); 4354 searchLength = searchString.length; 4355 advanceBy = max$2(1, searchLength); 4356 position = stringIndexOf$1(string, searchString, 0); 4357 4358 while (position !== -1) { 4359 replacement = functionalReplace ? toString_1(replaceValue(searchString, position, string)) : getSubstitution(searchString, string, position, [], undefined, replaceValue); 4360 result += stringSlice$4(string, endOfLastMatch, position) + replacement; 4361 endOfLastMatch = position + searchLength; 4362 position = stringIndexOf$1(string, searchString, position + advanceBy); 4363 } 4364 4365 if (endOfLastMatch < string.length) { 4366 result += stringSlice$4(string, endOfLastMatch); 4367 } 4368 4369 return result; 4370 } 4371 }); 4372 4373 var ITERATOR$3 = wellKnownSymbol('iterator'); 4374 var SAFE_CLOSING = false;
4375 4376 var checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) { 4377 if (!SKIP_CLOSING && !SAFE_CLOSING) return false; 4378 var ITERATION_SUPPORT = false; 4379 4380 try { 4381 var object = {}; 4382 4383 object[ITERATOR$3] = function () { 4384 return { 4385 next: function () { 4386 return { 4387 done: ITERATION_SUPPORT = true 4388 }; 4389 } 4390 }; 4391 }; 4392 4393 exec(object); 4394 } catch (error) { 4395 /* empty */ 4396 } 4397 4398 return ITERATION_SUPPORT; 4399 }; 4400 4401 var defineProperty$3 = objectDefineProperty.f; 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 var Int8Array = global_1.Int8Array; 4414 var Int8ArrayPrototype = Int8Array && Int8Array.prototype; 4415 var Uint8ClampedArray = global_1.Uint8ClampedArray; 4416 var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype; 4417 var TypedArray = Int8Array && objectGetPrototypeOf(Int8Array); 4418 var TypedArrayPrototype = Int8ArrayPrototype && objectGetPrototypeOf(Int8ArrayPrototype); 4419 var ObjectPrototype$2 = Object.prototype; 4420 var TypeError$g = global_1.TypeError; 4421 var TO_STRING_TAG$4 = wellKnownSymbol('toStringTag'); 4422 var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG'); 4423 var TYPED_ARRAY_CONSTRUCTOR = uid('TYPED_ARRAY_CONSTRUCTOR'); // Fixing native typed arrays in Opera Presto crashes the browser, see #595 4424 4425 var NATIVE_ARRAY_BUFFER_VIEWS = arrayBufferNative && !!objectSetPrototypeOf && classof(global_1.opera) !== 'Opera'; 4426 var TYPED_ARRAY_TAG_REQIRED = false; 4427 var NAME, Constructor, Prototype; 4428 var TypedArrayConstructorsList = { 4429 Int8Array: 1, 4430 Uint8Array: 1, 4431 Uint8ClampedArray: 1, 4432 Int16Array: 2, 4433 Uint16Array: 2, 4434 Int32Array: 4, 4435 Uint32Array: 4, 4436 Float32Array: 4, 4437 Float64Array: 8 4438 }; 4439 var BigIntArrayConstructorsList = { 4440 BigInt64Array: 8, 4441 BigUint64Array: 8 4442 }; 4443 4444 var isView = function isView(it) { 4445 if (!isObject(it)) return false; 4446 var klass = classof(it); 4447 return klass === 'DataView' || hasOwnProperty_1(TypedArrayConstructorsList, klass) || hasOwnProperty_1(BigIntArrayConstructorsList, klass); 4448 }; 4449 4450 var isTypedArray = function (it) { 4451 if (!isObject(it)) return false; 4452 var klass = classof(it); 4453 return hasOwnProperty_1(TypedArrayConstructorsList, klass) || hasOwnProperty_1(BigIntArrayConstructorsList, klass); 4454 }; 4455 4456 var aTypedArray = function (it) { 4457 if (isTypedArray(it)) return it; 4458 throw TypeError$g('Target is not a typed array'); 4459 }; 4460 4461 var aTypedArrayConstructor = function (C) { 4462 if (isCallable(C) && (!objectSetPrototypeOf || objectIsPrototypeOf(TypedArray, C))) return C; 4463 throw TypeError$g(tryToString(C) + ' is not a typed array constructor'); 4464 }; 4465 4466 var exportTypedArrayMethod = function (KEY, property, forced) { 4467 if (!descriptors) return; 4468 if (forced) for (var ARRAY in TypedArrayConstructorsList) { 4469 var TypedArrayConstructor = global_1[ARRAY]; 4470 if (TypedArrayConstructor && hasOwnProperty_1(TypedArrayConstructor.prototype, KEY)) try { 4471 delete TypedArrayConstructor.prototype[KEY]; 4472 } catch (error) { 4473 /* empty */ 4474 } 4475 } 4476 4477 if (!TypedArrayPrototype[KEY] || forced) { 4478 redefine(TypedArrayPrototype, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property); 4479 } 4480 }; 4481 4482 var exportTypedArrayStaticMethod = function (KEY, property, forced) { 4483 var ARRAY, TypedArrayConstructor; 4484 if (!descriptors) return; 4485 4486 if (objectSetPrototypeOf) { 4487 if (forced) for (ARRAY in TypedArrayConstructorsList) { 4488 TypedArrayConstructor = global_1[ARRAY]; 4489 if (TypedArrayConstructor && hasOwnProperty_1(TypedArrayConstructor, KEY)) try { 4490 delete TypedArrayConstructor[KEY]; 4491 } catch (error) { 4492 /* empty */ 4493 } 4494 } 4495 4496 if (!TypedArray[KEY] || forced) { 4497 // V8 ~ Chrome 49-50 `%TypedArray%` methods are non-writable non-configurable 4498 try { 4499 return redefine(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && TypedArray[KEY] || property); 4500 } catch (error) { 4501 /* empty */ 4502 } 4503 } else return; 4504 } 4505 4506 for (ARRAY in TypedArrayConstructorsList) { 4507 TypedArrayConstructor = global_1[ARRAY]; 4508 4509 if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) { 4510 redefine(TypedArrayConstructor, KEY, property); 4511 } 4512 } 4513 }; 4514 4515 for (NAME in TypedArrayConstructorsList) { 4516 Constructor = global_1[NAME]; 4517 Prototype = Constructor && Constructor.prototype; 4518 if (Prototype) createNonEnumerableProperty(Prototype, TYPED_ARRAY_CONSTRUCTOR, Constructor);else NATIVE_ARRAY_BUFFER_VIEWS = false;
vendor: 5,622 bytes, lines 4519-4691
4519 } 4520 4521 for (NAME in BigIntArrayConstructorsList) { 4522 Constructor = global_1[NAME]; 4523 Prototype = Constructor && Constructor.prototype; 4524 if (Prototype) createNonEnumerableProperty(Prototype, TYPED_ARRAY_CONSTRUCTOR, Constructor); 4525 } // WebKit bug - typed arrays constructors prototype is Object.prototype 4526 4527 4528 if (!NATIVE_ARRAY_BUFFER_VIEWS || !isCallable(TypedArray) || TypedArray === Function.prototype) { 4529 // eslint-disable-next-line no-shadow -- safe 4530 TypedArray = function TypedArray() { 4531 throw TypeError$g('Incorrect invocation'); 4532 }; 4533 4534 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { 4535 if (global_1[NAME]) objectSetPrototypeOf(global_1[NAME], TypedArray); 4536 } 4537 } 4538 4539 if (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype$2) { 4540 TypedArrayPrototype = TypedArray.prototype; 4541 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { 4542 if (global_1[NAME]) objectSetPrototypeOf(global_1[NAME].prototype, TypedArrayPrototype); 4543 } 4544 } // WebKit bug - one more object in Uint8ClampedArray prototype chain 4545 4546 4547 if (NATIVE_ARRAY_BUFFER_VIEWS && objectGetPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) { 4548 objectSetPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype); 4549 } 4550 4551 if (descriptors && !hasOwnProperty_1(TypedArrayPrototype, TO_STRING_TAG$4)) { 4552 TYPED_ARRAY_TAG_REQIRED = true; 4553 defineProperty$3(TypedArrayPrototype, TO_STRING_TAG$4, { 4554 get: function () { 4555 return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined; 4556 } 4557 }); 4558 4559 for (NAME in TypedArrayConstructorsList) if (global_1[NAME]) { 4560 createNonEnumerableProperty(global_1[NAME], TYPED_ARRAY_TAG, NAME); 4561 } 4562 } 4563 4564 var arrayBufferViewCore = { 4565 NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS, 4566 TYPED_ARRAY_CONSTRUCTOR: TYPED_ARRAY_CONSTRUCTOR, 4567 TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQIRED && TYPED_ARRAY_TAG, 4568 aTypedArray: aTypedArray, 4569 aTypedArrayConstructor: aTypedArrayConstructor, 4570 exportTypedArrayMethod: exportTypedArrayMethod, 4571 exportTypedArrayStaticMethod: exportTypedArrayStaticMethod, 4572 isView: isView, 4573 isTypedArray: isTypedArray, 4574 TypedArray: TypedArray, 4575 TypedArrayPrototype: TypedArrayPrototype 4576 }; 4577 4578 /* eslint-disable no-new -- required for testing */ 4579 4580 4581 4582 4583 4584 4585 var NATIVE_ARRAY_BUFFER_VIEWS$1 = arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; 4586 4587 var ArrayBuffer$2 = global_1.ArrayBuffer; 4588 var Int8Array$1 = global_1.Int8Array; 4589 var typedArrayConstructorsRequireWrappers = !NATIVE_ARRAY_BUFFER_VIEWS$1 || !fails(function () { 4590 Int8Array$1(1); 4591 }) || !fails(function () { 4592 new Int8Array$1(-1); 4593 }) || !checkCorrectnessOfIteration(function (iterable) { 4594 new Int8Array$1(); 4595 new Int8Array$1(null); 4596 new Int8Array$1(1.5); 4597 new Int8Array$1(iterable); 4598 }, true) || fails(function () { 4599 // Safari (11+) bug - a reason why even Safari 13 should load a typed array polyfill 4600 return new Int8Array$1(new ArrayBuffer$2(2), 1, undefined).length !== 1; 4601 }); 4602 4603 var floor$3 = Math.floor; // `IsIntegralNumber` abstract operation 4604 // https://tc39.es/ecma262/#sec-isintegralnumber 4605 // eslint-disable-next-line es/no-number-isinteger -- safe 4606 4607 var isIntegralNumber = Number.isInteger || function isInteger(it) { 4608 return !isObject(it) && isFinite(it) && floor$3(it) === it; 4609 }; 4610 4611 var RangeError$2 = global_1.RangeError; 4612 4613 var toPositiveInteger = function (it) { 4614 var result = toIntegerOrInfinity(it); 4615 if (result < 0) throw RangeError$2("The argument can't be less than 0"); 4616 return result; 4617 }; 4618 4619 var RangeError$3 = global_1.RangeError; 4620 4621 var toOffset = function (it, BYTES) { 4622 var offset = toPositiveInteger(it); 4623 if (offset % BYTES) throw RangeError$3('Wrong offset'); 4624 return offset; 4625 }; 4626 4627 var aTypedArrayConstructor$1 = arrayBufferViewCore.aTypedArrayConstructor; 4628 4629 var typedArrayFrom = function from(source 4630 /* , mapfn, thisArg */ 4631 ) { 4632 var C = aConstructor(this); 4633 var O = toObject(source); 4634 var argumentsLength = arguments.length; 4635 var mapfn = argumentsLength > 1 ? arguments[1] : undefined; 4636 var mapping = mapfn !== undefined; 4637 var iteratorMethod = getIteratorMethod(O); 4638 var i, length, result, step, iterator, next; 4639 4640 if (iteratorMethod && !isArrayIteratorMethod(iteratorMethod)) { 4641 iterator = getIterator(O, iteratorMethod); 4642 next = iterator.next; 4643 O = []; 4644 4645 while (!(step = functionCall(next, iterator)).done) { 4646 O.push(step.value); 4647 } 4648 } 4649 4650 if (mapping && argumentsLength > 2) { 4651 mapfn = functionBindContext(mapfn, arguments[2]); 4652 } 4653 4654 length = lengthOfArrayLike(O); 4655 result = new (aTypedArrayConstructor$1(C))(length); 4656 4657 for (i = 0; length > i; i++) { 4658 result[i] = mapping ? mapfn(O[i], i) : O[i]; 4659 } 4660 4661 return result; 4662 }; 4663 4664 var SPECIES$1 = wellKnownSymbol('species'); 4665 var Array$4 = global_1.Array; // a part of `ArraySpeciesCreate` abstract operation 4666 // https://tc39.es/ecma262/#sec-arrayspeciescreate 4667 4668 var arraySpeciesConstructor = function (originalArray) { 4669 var C; 4670 4671 if (isArray(originalArray)) { 4672 C = originalArray.constructor; // cross-realm fallback 4673 4674 if (isConstructor(C) && (C === Array$4 || isArray(C.prototype))) C = undefined;else if (isObject(C)) { 4675 C = C[SPECIES$1]; 4676 if (C === null) C = undefined; 4677 } 4678 } 4679 4680 return C === undefined ? Array$4 : C; 4681 }; 4682 4683 // `ArraySpeciesCreate` abstract operation 4684 // https://tc39.es/ecma262/#sec-arrayspeciescreate 4685 4686 4687 var arraySpeciesCreate = function (originalArray, length) { 4688 return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length); 4689 }; 4690 4691 var push$2 = functionUncurryThis([].push);
4691 // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation 4692 4693 var createMethod$2 = function (TYPE) { 4694 var IS_MAP = TYPE == 1; 4695 var IS_FILTER = TYPE == 2; 4696 var IS_SOME = TYPE == 3; 4697 var IS_EVERY = TYPE == 4; 4698 var IS_FIND_INDEX = TYPE == 6; 4699 var IS_FILTER_REJECT = TYPE == 7; 4700 var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; 4701 return function ($this, callbackfn, that, specificCreate) { 4702 var O = toObject($this); 4703 var self = indexedObject(O); 4704 var boundFunction = functionBindContext(callbackfn, that); 4705 var length = lengthOfArrayLike(self); 4706 var index = 0; 4707 var create = specificCreate || arraySpeciesCreate; 4708 var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined; 4709 var value, result; 4710 4711 for (; length > index; index++) if (NO_HOLES || index in self) { 4712 value = self[index]; 4713 result = boundFunction(value, index, O); 4714 4715 if (TYPE) { 4716 if (IS_MAP) target[index] = result; // map 4717 else if (result) switch (TYPE) { 4718 case 3: 4719 return true; 4720 // some 4721 4722 case 5: 4723 return value; 4724 // find 4725 4726 case 6: 4727 return index; 4728 // findIndex 4729 4730 case 2: 4731 push$2(target, value); 4732 // filter 4733 } else switch (TYPE) { 4734 case 4: 4735 return false; 4736 // every 4737 4738 case 7: 4739 push$2(target, value); 4740 // filterReject 4741 } 4742 } 4743 } 4744 4745 return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target; 4746 }; 4747 }; 4748 4749 var arrayIteration = { 4750 // `Array.prototype.forEach` method 4751 // https://tc39.es/ecma262/#sec-array.prototype.foreach 4752 forEach: createMethod$2(0), 4753 // `Array.prototype.map` method 4754 // https://tc39.es/ecma262/#sec-array.prototype.map 4755 map: createMethod$2(1), 4756 // `Array.prototype.filter` method 4757 // https://tc39.es/ecma262/#sec-array.prototype.filter 4758 filter: createMethod$2(2), 4759 // `Array.prototype.some` method 4760 // https://tc39.es/ecma262/#sec-array.prototype.some 4761 some: createMethod$2(3), 4762 // `Array.prototype.every` method 4763 // https://tc39.es/ecma262/#sec-array.prototype.every 4764 every: createMethod$2(4), 4765 // `Array.prototype.find` method 4766 // https://tc39.es/ecma262/#sec-array.prototype.find 4767 find: createMethod$2(5), 4768 // `Array.prototype.findIndex` method 4769 // https://tc39.es/ecma262/#sec-array.prototype.findIndex 4770 findIndex: createMethod$2(6), 4771 // `Array.prototype.filterReject` method 4772 // https://github.com/tc39/proposal-array-filtering 4773 filterReject: createMethod$2(7) 4774 }; 4775 4776 var SPECIES$2 = wellKnownSymbol('species'); 4777 4778 var setSpecies = function (CONSTRUCTOR_NAME) { 4779 var Constructor = getBuiltIn(CONSTRUCTOR_NAME); 4780 var defineProperty = objectDefineProperty.f; 4781 4782 if (descriptors && Constructor && !Constructor[SPECIES$2]) { 4783 defineProperty(Constructor, SPECIES$2, { 4784 configurable: true, 4785 get: function () { 4786 return this; 4787 } 4788 }); 4789 } 4790 }; 4791 4792 // makes subclassing work correct for wrapped built-ins 4793 4794 4795 var inheritIfRequired = function ($this, dummy, Wrapper) { 4796 var NewTarget, NewTargetPrototype; 4797 if ( // it can work only with native `setPrototypeOf` 4798 objectSetPrototypeOf && // we haven't completely correct pre-ES6 way for getting `new.target`, so use this 4799 isCallable(NewTarget = dummy.constructor) && NewTarget !== Wrapper && isObject(NewTargetPrototype = NewTarget.prototype) && NewTargetPrototype !== Wrapper.prototype) objectSetPrototypeOf($this, NewTargetPrototype); 4800 return $this; 4801 }; 4802 4803 var typedArrayConstructor = createCommonjsModule(function (module) { 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 var getOwnPropertyNames = objectGetOwnPropertyNames.f; 4850 4851 4852
vendor: 7,113 bytes, lines 4853-5035
4853 var forEach = arrayIteration.forEach; 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 var getInternalState = internalState.get; 4866 var setInternalState = internalState.set; 4867 var nativeDefineProperty = objectDefineProperty.f; 4868 var nativeGetOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; 4869 var round = Math.round; 4870 var RangeError = global_1.RangeError; 4871 var ArrayBuffer = arrayBuffer.ArrayBuffer; 4872 var ArrayBufferPrototype = ArrayBuffer.prototype; 4873 var DataView = arrayBuffer.DataView; 4874 var NATIVE_ARRAY_BUFFER_VIEWS = arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; 4875 var TYPED_ARRAY_CONSTRUCTOR = arrayBufferViewCore.TYPED_ARRAY_CONSTRUCTOR; 4876 var TYPED_ARRAY_TAG = arrayBufferViewCore.TYPED_ARRAY_TAG; 4877 var TypedArray = arrayBufferViewCore.TypedArray; 4878 var TypedArrayPrototype = arrayBufferViewCore.TypedArrayPrototype; 4879 var aTypedArrayConstructor = arrayBufferViewCore.aTypedArrayConstructor; 4880 var isTypedArray = arrayBufferViewCore.isTypedArray; 4881 var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT'; 4882 var WRONG_LENGTH = 'Wrong length'; 4883 4884 var fromList = function (C, list) { 4885 aTypedArrayConstructor(C); 4886 var index = 0; 4887 var length = list.length; 4888 var result = new C(length); 4889 4890 while (length > index) result[index] = list[index++]; 4891 4892 return result; 4893 }; 4894 4895 var addGetter = function (it, key) { 4896 nativeDefineProperty(it, key, { 4897 get: function () { 4898 return getInternalState(this)[key]; 4899 } 4900 }); 4901 }; 4902 4903 var isArrayBuffer = function (it) { 4904 var klass; 4905 return objectIsPrototypeOf(ArrayBufferPrototype, it) || (klass = classof(it)) == 'ArrayBuffer' || klass == 'SharedArrayBuffer'; 4906 }; 4907 4908 var isTypedArrayIndex = function (target, key) { 4909 return isTypedArray(target) && !isSymbol(key) && key in target && isIntegralNumber(+key) && key >= 0; 4910 }; 4911 4912 var wrappedGetOwnPropertyDescriptor = function getOwnPropertyDescriptor(target, key) { 4913 key = toPropertyKey(key); 4914 return isTypedArrayIndex(target, key) ? createPropertyDescriptor(2, target[key]) : nativeGetOwnPropertyDescriptor(target, key); 4915 }; 4916 4917 var wrappedDefineProperty = function defineProperty(target, key, descriptor) { 4918 key = toPropertyKey(key); 4919 4920 if (isTypedArrayIndex(target, key) && isObject(descriptor) && hasOwnProperty_1(descriptor, 'value') && !hasOwnProperty_1(descriptor, 'get') && !hasOwnProperty_1(descriptor, 'set') // TODO: add validation descriptor w/o calling accessors 4921 && !descriptor.configurable && (!hasOwnProperty_1(descriptor, 'writable') || descriptor.writable) && (!hasOwnProperty_1(descriptor, 'enumerable') || descriptor.enumerable)) { 4922 target[key] = descriptor.value; 4923 return target; 4924 } 4925 4926 return nativeDefineProperty(target, key, descriptor); 4927 }; 4928 4929 if (descriptors) { 4930 if (!NATIVE_ARRAY_BUFFER_VIEWS) { 4931 objectGetOwnPropertyDescriptor.f = wrappedGetOwnPropertyDescriptor; 4932 objectDefineProperty.f = wrappedDefineProperty; 4933 addGetter(TypedArrayPrototype, 'buffer'); 4934 addGetter(TypedArrayPrototype, 'byteOffset'); 4935 addGetter(TypedArrayPrototype, 'byteLength'); 4936 addGetter(TypedArrayPrototype, 'length'); 4937 } 4938 4939 _export({ 4940 target: 'Object', 4941 stat: true, 4942 forced: !NATIVE_ARRAY_BUFFER_VIEWS 4943 }, { 4944 getOwnPropertyDescriptor: wrappedGetOwnPropertyDescriptor, 4945 defineProperty: wrappedDefineProperty 4946 }); 4947 4948 module.exports = function (TYPE, wrapper, CLAMPED) { 4949 var BYTES = TYPE.match(/\d+$/)[0] / 8; 4950 var CONSTRUCTOR_NAME = TYPE + (CLAMPED ? 'Clamped' : '') + 'Array'; 4951 var GETTER = 'get' + TYPE; 4952 var SETTER = 'set' + TYPE; 4953 var NativeTypedArrayConstructor = global_1[CONSTRUCTOR_NAME]; 4954 var TypedArrayConstructor = NativeTypedArrayConstructor; 4955 var TypedArrayConstructorPrototype = TypedArrayConstructor && TypedArrayConstructor.prototype; 4956 var exported = {}; 4957 4958 var getter = function (that, index) { 4959 var data = getInternalState(that); 4960 return data.view[GETTER](index * BYTES + data.byteOffset, true); 4961 }; 4962 4963 var setter = function (that, index, value) { 4964 var data = getInternalState(that); 4965 if (CLAMPED) value = (value = round(value)) < 0 ? 0 : value > 0xFF ? 0xFF : value & 0xFF; 4966 data.view[SETTER](index * BYTES + data.byteOffset, value, true); 4967 }; 4968 4969 var addElement = function (that, index) { 4970 nativeDefineProperty(that, index, { 4971 get: function () { 4972 return getter(this, index); 4973 }, 4974 set: function (value) { 4975 return setter(this, index, value); 4976 }, 4977 enumerable: true 4978 }); 4979 }; 4980 4981 if (!NATIVE_ARRAY_BUFFER_VIEWS) { 4982 TypedArrayConstructor = wrapper(function (that, data, offset, $length) { 4983 anInstance(that, TypedArrayConstructorPrototype); 4984 var index = 0; 4985 var byteOffset = 0; 4986 var buffer, byteLength, length; 4987 4988 if (!isObject(data)) { 4989 length = toIndex(data); 4990 byteLength = length * BYTES; 4991 buffer = new ArrayBuffer(byteLength); 4992 } else if (isArrayBuffer(data)) { 4993 buffer = data; 4994 byteOffset = toOffset(offset, BYTES); 4995 var $len = data.byteLength; 4996 4997 if ($length === undefined) { 4998 if ($len % BYTES) throw RangeError(WRONG_LENGTH); 4999 byteLength = $len - byteOffset; 5000 if (byteLength < 0) throw RangeError(WRONG_LENGTH); 5001 } else { 5002 byteLength = toLength($length) * BYTES; 5003 if (byteLength + byteOffset > $len) throw RangeError(WRONG_LENGTH); 5004 } 5005 5006 length = byteLength / BYTES; 5007 } else if (isTypedArray(data)) { 5008 return fromList(TypedArrayConstructor, data); 5009 } else { 5010 return functionCall(typedArrayFrom, TypedArrayConstructor, data); 5011 } 5012 5013 setInternalState(that, { 5014 buffer: buffer, 5015 byteOffset: byteOffset, 5016 byteLength: byteLength, 5017 length: length, 5018 view: new DataView(buffer) 5019 }); 5020 5021 while (index < length) addElement(that, index++); 5022 }); 5023 if (objectSetPrototypeOf) objectSetPrototypeOf(TypedArrayConstructor, TypedArray); 5024 TypedArrayConstructorPrototype = TypedArrayConstructor.prototype = objectCreate(TypedArrayPrototype); 5025 } else if (typedArrayConstructorsRequireWrappers) { 5026 TypedArrayConstructor = wrapper(function (dummy, data, typedArrayOffset, $length) { 5027 anInstance(dummy, TypedArrayConstructorPrototype); 5028 return inheritIfRequired(function () { 5029 if (!isObject(data)) return new NativeTypedArrayConstructor(toIndex(data)); 5030 if (isArrayBuffer(data)) return $length !== undefined ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES), $length) : typedArrayOffset !== undefined ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES)) : new NativeTypedArrayConstructor(data); 5031 if (isTypedArray(data)) return fromList(TypedArrayConstructor, data); 5032 return functionCall(typedArrayFrom, TypedArrayConstructor, data); 5033 }(), dummy, TypedArrayConstructor); 5034 }); 5035 if (objectSetPrototypeOf) objectSetPrototypeOf(TypedArrayConstructor, TypedArray);
5036 forEach(getOwnPropertyNames(NativeTypedArrayConstructor), function (key) { 5037 if (!(key in TypedArrayConstructor)) { 5038 createNonEnumerableProperty(TypedArrayConstructor, key, NativeTypedArrayConstructor[key]); 5039 } 5040 }); 5041 TypedArrayConstructor.prototype = TypedArrayConstructorPrototype; 5042 } 5043 5044 if (TypedArrayConstructorPrototype.constructor !== TypedArrayConstructor) { 5045 createNonEnumerableProperty(TypedArrayConstructorPrototype, 'constructor', TypedArrayConstructor); 5046 } 5047 5048 createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_CONSTRUCTOR, TypedArrayConstructor); 5049 5050 if (TYPED_ARRAY_TAG) { 5051 createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_TAG, CONSTRUCTOR_NAME); 5052 } 5053 5054 exported[CONSTRUCTOR_NAME] = TypedArrayConstructor; 5055 _export({ 5056 global: true, 5057 forced: TypedArrayConstructor != NativeTypedArrayConstructor, 5058 sham: !NATIVE_ARRAY_BUFFER_VIEWS 5059 }, exported); 5060 5061 if (!(BYTES_PER_ELEMENT in TypedArrayConstructor)) { 5062 createNonEnumerableProperty(TypedArrayConstructor, BYTES_PER_ELEMENT, BYTES); 5063 } 5064 5065 if (!(BYTES_PER_ELEMENT in TypedArrayConstructorPrototype)) { 5066 createNonEnumerableProperty(TypedArrayConstructorPrototype, BYTES_PER_ELEMENT, BYTES); 5067 } 5068 5069 setSpecies(CONSTRUCTOR_NAME); 5070 }; 5071 } else module.exports = function () { 5072 /* empty */ 5073 }; 5074 }); 5075 5076 // `Float32Array` constructor 5077 // https://tc39.es/ecma262/#sec-typedarray-objects 5078 5079 5080 typedArrayConstructor('Float32', function (init) { 5081 return function Float32Array(data, byteOffset, length) { 5082 return init(this, data, byteOffset, length); 5083 }; 5084 }); 5085 5086 // `Float64Array` constructor 5087 // https://tc39.es/ecma262/#sec-typedarray-objects 5088 5089 5090 typedArrayConstructor('Float64', function (init) { 5091 return function Float64Array(data, byteOffset, length) { 5092 return init(this, data, byteOffset, length); 5093 }; 5094 }); 5095 5096 // `Int8Array` constructor 5097 // https://tc39.es/ecma262/#sec-typedarray-objects 5098 5099 5100 typedArrayConstructor('Int8', function (init) { 5101 return function Int8Array(data, byteOffset, length) { 5102 return init(this, data, byteOffset, length); 5103 }; 5104 }); 5105 5106 // `Int16Array` constructor 5107 // https://tc39.es/ecma262/#sec-typedarray-objects 5108 5109 5110 typedArrayConstructor('Int16', function (init) { 5111 return function Int16Array(data, byteOffset, length) { 5112 return init(this, data, byteOffset, length); 5113 }; 5114 }); 5115 5116 // `Int32Array` constructor 5117 // https://tc39.es/ecma262/#sec-typedarray-objects 5118 5119 5120 typedArrayConstructor('Int32', function (init) { 5121 return function Int32Array(data, byteOffset, length) { 5122 return init(this, data, byteOffset, length); 5123 }; 5124 }); 5125 5126 // `Uint8Array` constructor 5127 // https://tc39.es/ecma262/#sec-typedarray-objects 5128 5129 5130 typedArrayConstructor('Uint8', function (init) { 5131 return function Uint8Array(data, byteOffset, length) { 5132 return init(this, data, byteOffset, length); 5133 }; 5134 }); 5135 5136 // `Uint8ClampedArray` constructor 5137 // https://tc39.es/ecma262/#sec-typedarray-objects 5138 5139 5140 typedArrayConstructor('Uint8', function (init) { 5141 return function Uint8ClampedArray(data, byteOffset, length) { 5142 return init(this, data, byteOffset, length); 5143 }; 5144 }, true); 5145 5146 // `Uint16Array` constructor 5147 // https://tc39.es/ecma262/#sec-typedarray-objects 5148 5149 5150 typedArrayConstructor('Uint16', function (init) { 5151 return function Uint16Array(data, byteOffset, length) { 5152 return init(this, data, byteOffset, length); 5153 }; 5154 }); 5155 5156 // `Uint32Array` constructor 5157 // https://tc39.es/ecma262/#sec-typedarray-objects 5158 5159 5160 typedArrayConstructor('Uint32', function (init) { 5161 return function Uint32Array(data, byteOffset, length) { 5162 return init(this, data, byteOffset, length); 5163 }; 5164 }); 5165 5166 var aTypedArray$1 = arrayBufferViewCore.aTypedArray; 5167 var exportTypedArrayMethod$1 = arrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.at` method 5168 // https://github.com/tc39/proposal-relative-indexing-method 5169 5170 exportTypedArrayMethod$1('at', function at(index) { 5171 var O = aTypedArray$1(this); 5172 var len = lengthOfArrayLike(O); 5173 var relativeIndex = toIntegerOrInfinity(index); 5174 var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; 5175 return k < 0 || k >= len ? undefined : O[k]; 5176 }); 5177 5178 var exportTypedArrayStaticMethod$1 = arrayBufferViewCore.exportTypedArrayStaticMethod; 5179 5180 // `%TypedArray%.from` method 5181 // https://tc39.es/ecma262/#sec-%typedarray%.from 5182 5183 5184 exportTypedArrayStaticMethod$1('from', typedArrayFrom, typedArrayConstructorsRequireWrappers); 5185 5186 var aTypedArrayConstructor$2 = arrayBufferViewCore.aTypedArrayConstructor; 5187 var exportTypedArrayStaticMethod$2 = arrayBufferViewCore.exportTypedArrayStaticMethod; // `%TypedArray%.of` method 5188 // https://tc39.es/ecma262/#sec-%typedarray%.of 5189 5190 exportTypedArrayStaticMethod$2('of', function of() 5191 /* ...items */ 5192 { 5193 var index = 0; 5194 var length = arguments.length; 5195 var result = new (aTypedArrayConstructor$2(this))(length); 5196 5197 while (length > index) result[index] = arguments[index++]; 5198 5199 return result; 5200 }, typedArrayConstructorsRequireWrappers); 5201 5202 var floor$4 = Math.floor; 5203 5204 var mergeSort = function (array, comparefn) { 5205 var length = array.length; 5206 var middle = floor$4(length / 2); 5207 return length < 8 ? insertionSort(array, comparefn) : merge(array, mergeSort(arraySliceSimple(array, 0, middle), comparefn), mergeSort(arraySliceSimple(array, middle), comparefn), comparefn); 5208 }; 5209 5210 var insertionSort = function (array, comparefn) { 5211 var length = array.length; 5212 var i = 1; 5213 var element, j; 5214 5215 while (i < length) { 5216 j = i; 5217 element = array[i]; 5218 5219 while (j && comparefn(array[j - 1], element) > 0) { 5220 array[j] = array[--j]; 5221 } 5222 5223 if (j !== i++) array[j] = element; 5224 } 5225 5226 return array; 5227 }; 5228 5229 var merge = function (array, left, right, comparefn) { 5230 var llength = left.length; 5231 var rlength = right.length; 5232 var lindex = 0; 5233 var rindex = 0; 5234 5235 while (lindex < llength || rindex < rlength) { 5236 array[lindex + rindex] = lindex < llength && rindex < rlength ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++] : lindex < llength ? left[lindex++] : right[rindex++]; 5237 } 5238 5239 return array; 5240 }; 5241 5242 var arraySort = mergeSort; 5243 5244 var firefox = engineUserAgent.match(/firefox\/(\d+)/i); 5245 var engineFfVersion = !!firefox && +firefox[1]; 5246 5247 var engineIsIeOrEdge = /MSIE|Trident/.test(engineUserAgent); 5248
vendor: 4,612 bytes, lines 5249-5393
5249 var webkit = engineUserAgent.match(/AppleWebKit\/(\d+)\./); 5250 var engineWebkitVersion = !!webkit && +webkit[1]; 5251 5252 var Array$5 = global_1.Array; 5253 var aTypedArray$2 = arrayBufferViewCore.aTypedArray; 5254 var exportTypedArrayMethod$2 = arrayBufferViewCore.exportTypedArrayMethod; 5255 var Uint16Array = global_1.Uint16Array; 5256 var un$Sort = Uint16Array && functionUncurryThis(Uint16Array.prototype.sort); // WebKit 5257 5258 var ACCEPT_INCORRECT_ARGUMENTS = !!un$Sort && !(fails(function () { 5259 un$Sort(new Uint16Array(2), null); 5260 }) && fails(function () { 5261 un$Sort(new Uint16Array(2), {}); 5262 })); 5263 var STABLE_SORT = !!un$Sort && !fails(function () { 5264 // feature detection can be too slow, so check engines versions 5265 if (engineV8Version) return engineV8Version < 74; 5266 if (engineFfVersion) return engineFfVersion < 67; 5267 if (engineIsIeOrEdge) return true; 5268 if (engineWebkitVersion) return engineWebkitVersion < 602; 5269 var array = new Uint16Array(516); 5270 var expected = Array$5(516); 5271 var index, mod; 5272 5273 for (index = 0; index < 516; index++) { 5274 mod = index % 4; 5275 array[index] = 515 - index; 5276 expected[index] = index - 2 * mod + 3; 5277 } 5278 5279 un$Sort(array, function (a, b) { 5280 return (a / 4 | 0) - (b / 4 | 0); 5281 }); 5282 5283 for (index = 0; index < 516; index++) { 5284 if (array[index] !== expected[index]) return true; 5285 } 5286 }); 5287 5288 var getSortCompare = function (comparefn) { 5289 return function (x, y) { 5290 if (comparefn !== undefined) return +comparefn(x, y) || 0; // eslint-disable-next-line no-self-compare -- NaN check 5291 5292 if (y !== y) return -1; // eslint-disable-next-line no-self-compare -- NaN check 5293 5294 if (x !== x) return 1; 5295 if (x === 0 && y === 0) return 1 / x > 0 && 1 / y < 0 ? 1 : -1; 5296 return x > y; 5297 }; 5298 }; // `%TypedArray%.prototype.sort` method 5299 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.sort 5300 5301 5302 exportTypedArrayMethod$2('sort', function sort(comparefn) { 5303 if (comparefn !== undefined) aCallable(comparefn); 5304 if (STABLE_SORT) return un$Sort(this, comparefn); 5305 return arraySort(aTypedArray$2(this), getSortCompare(comparefn)); 5306 }, !STABLE_SORT || ACCEPT_INCORRECT_ARGUMENTS); 5307 5308 // iterable DOM collections 5309 // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods 5310 var domIterables = { 5311 CSSRuleList: 0, 5312 CSSStyleDeclaration: 0, 5313 CSSValueList: 0, 5314 ClientRectList: 0, 5315 DOMRectList: 0, 5316 DOMStringList: 0, 5317 DOMTokenList: 1, 5318 DataTransferItemList: 0, 5319 FileList: 0, 5320 HTMLAllCollection: 0, 5321 HTMLCollection: 0, 5322 HTMLFormElement: 0, 5323 HTMLSelectElement: 0, 5324 MediaList: 0, 5325 MimeTypeArray: 0, 5326 NamedNodeMap: 0, 5327 NodeList: 1, 5328 PaintRequestList: 0, 5329 Plugin: 0, 5330 PluginArray: 0, 5331 SVGLengthList: 0, 5332 SVGNumberList: 0, 5333 SVGPathSegList: 0, 5334 SVGPointList: 0, 5335 SVGStringList: 0, 5336 SVGTransformList: 0, 5337 SourceBufferList: 0, 5338 StyleSheetList: 0, 5339 TextTrackCueList: 0, 5340 TextTrackList: 0, 5341 TouchList: 0 5342 }; 5343 5344 // in old WebKit versions, `element.classList` is not an instance of global `DOMTokenList` 5345 5346 5347 var classList = documentCreateElement('span').classList; 5348 var DOMTokenListPrototype = classList && classList.constructor && classList.constructor.prototype; 5349 var domTokenListPrototype = DOMTokenListPrototype === Object.prototype ? undefined : DOMTokenListPrototype; 5350 5351 var PROPER_FUNCTION_NAME$1 = functionName.PROPER; 5352 var CONFIGURABLE_FUNCTION_NAME$1 = functionName.CONFIGURABLE; 5353 var IteratorPrototype$2 = iteratorsCore.IteratorPrototype; 5354 var BUGGY_SAFARI_ITERATORS$1 = iteratorsCore.BUGGY_SAFARI_ITERATORS; 5355 var ITERATOR$4 = wellKnownSymbol('iterator'); 5356 var KEYS = 'keys'; 5357 var VALUES = 'values'; 5358 var ENTRIES = 'entries'; 5359 5360 var returnThis$1 = function () { 5361 return this; 5362 }; 5363 5364 var defineIterator = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) { 5365 createIteratorConstructor(IteratorConstructor, NAME, next); 5366 5367 var getIterationMethod = function (KIND) { 5368 if (KIND === DEFAULT && defaultIterator) return defaultIterator; 5369 if (!BUGGY_SAFARI_ITERATORS$1 && KIND in IterablePrototype) return IterablePrototype[KIND]; 5370 5371 switch (KIND) { 5372 case KEYS: 5373 return function keys() { 5374 return new IteratorConstructor(this, KIND); 5375 }; 5376 5377 case VALUES: 5378 return function values() { 5379 return new IteratorConstructor(this, KIND); 5380 }; 5381 5382 case ENTRIES: 5383 return function entries() { 5384 return new IteratorConstructor(this, KIND); 5385 }; 5386 } 5387 5388 return function () { 5389 return new IteratorConstructor(this); 5390 }; 5391 }; 5392 5393 var TO_STRING_TAG = NAME + ' Iterator';
5394 var INCORRECT_VALUES_NAME = false; 5395 var IterablePrototype = Iterable.prototype; 5396 var nativeIterator = IterablePrototype[ITERATOR$4] || IterablePrototype['@@iterator'] || DEFAULT && IterablePrototype[DEFAULT]; 5397 var defaultIterator = !BUGGY_SAFARI_ITERATORS$1 && nativeIterator || getIterationMethod(DEFAULT); 5398 var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator; 5399 var CurrentIteratorPrototype, methods, KEY; // fix native 5400 5401 if (anyNativeIterator) { 5402 CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable())); 5403 5404 if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) { 5405 if (objectGetPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype$2) { 5406 if (objectSetPrototypeOf) { 5407 objectSetPrototypeOf(CurrentIteratorPrototype, IteratorPrototype$2); 5408 } else if (!isCallable(CurrentIteratorPrototype[ITERATOR$4])) { 5409 redefine(CurrentIteratorPrototype, ITERATOR$4, returnThis$1); 5410 } 5411 } // Set @@toStringTag to native iterators 5412 5413 5414 setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true); 5415 } 5416 } // fix Array.prototype.{ values, @@iterator }.name in V8 / FF 5417 5418 5419 if (PROPER_FUNCTION_NAME$1 && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) { 5420 if (CONFIGURABLE_FUNCTION_NAME$1) { 5421 createNonEnumerableProperty(IterablePrototype, 'name', VALUES); 5422 } else { 5423 INCORRECT_VALUES_NAME = true; 5424 5425 defaultIterator = function values() { 5426 return functionCall(nativeIterator, this); 5427 }; 5428 } 5429 } // export additional methods 5430 5431 5432 if (DEFAULT) { 5433 methods = { 5434 values: getIterationMethod(VALUES), 5435 keys: IS_SET ? defaultIterator : getIterationMethod(KEYS), 5436 entries: getIterationMethod(ENTRIES) 5437 }; 5438 if (FORCED) for (KEY in methods) { 5439 if (BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) { 5440 redefine(IterablePrototype, KEY, methods[KEY]); 5441 } 5442 } else _export({ 5443 target: NAME, 5444 proto: true, 5445 forced: BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME 5446 }, methods); 5447 } // define iterator 5448 5449 5450 if (IterablePrototype[ITERATOR$4] !== defaultIterator) { 5451 redefine(IterablePrototype, ITERATOR$4, defaultIterator, { 5452 name: DEFAULT 5453 }); 5454 } 5455 5456 iterators[NAME] = defaultIterator; 5457 return methods; 5458 }; 5459 5460 var ARRAY_ITERATOR = 'Array Iterator'; 5461 var setInternalState$2 = internalState.set; 5462 var getInternalState$3 = internalState.getterFor(ARRAY_ITERATOR); // `Array.prototype.entries` method 5463 // https://tc39.es/ecma262/#sec-array.prototype.entries 5464 // `Array.prototype.keys` method 5465 // https://tc39.es/ecma262/#sec-array.prototype.keys 5466 // `Array.prototype.values` method 5467 // https://tc39.es/ecma262/#sec-array.prototype.values 5468 // `Array.prototype[@@iterator]` method 5469 // https://tc39.es/ecma262/#sec-array.prototype-@@iterator 5470 // `CreateArrayIterator` internal method 5471 // https://tc39.es/ecma262/#sec-createarrayiterator 5472 5473 var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind) { 5474 setInternalState$2(this, { 5475 type: ARRAY_ITERATOR, 5476 target: toIndexedObject(iterated), 5477 // target 5478 index: 0, 5479 // next index 5480 kind: kind // kind 5481 5482 }); // `%ArrayIteratorPrototype%.next` method 5483 // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next 5484 }, function () { 5485 var state = getInternalState$3(this); 5486 var target = state.target; 5487 var kind = state.kind; 5488 var index = state.index++; 5489 5490 if (!target || index >= target.length) { 5491 state.target = undefined; 5492 return { 5493 value: undefined, 5494 done: true 5495 }; 5496 } 5497 5498 if (kind == 'keys') return { 5499 value: index, 5500 done: false 5501 }; 5502 if (kind == 'values') return { 5503 value: target[index], 5504 done: false 5505 }; 5506 return { 5507 value: [index, target[index]], 5508 done: false 5509 }; 5510 }, 'values'); // argumentsList[@@iterator] is %ArrayProto_values% 5511 // https://tc39.es/ecma262/#sec-createunmappedargumentsobject 5512 // https://tc39.es/ecma262/#sec-createmappedargumentsobject 5513 5514 iterators.Arguments = iterators.Array; // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 5515 5516 addToUnscopables('keys'); 5517 addToUnscopables('values'); 5518 addToUnscopables('entries'); 5519 5520 var ITERATOR$5 = wellKnownSymbol('iterator'); 5521 var TO_STRING_TAG$5 = wellKnownSymbol('toStringTag'); 5522 var ArrayValues = es_array_iterator.values; 5523 5524 var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) { 5525 if (CollectionPrototype) { 5526 // some Chrome versions have non-configurable methods on DOMTokenList 5527 if (CollectionPrototype[ITERATOR$5] !== ArrayValues) try { 5528 createNonEnumerableProperty(CollectionPrototype, ITERATOR$5, ArrayValues); 5529 } catch (error) { 5530 CollectionPrototype[ITERATOR$5] = ArrayValues; 5531 } 5532 5533 if (!CollectionPrototype[TO_STRING_TAG$5]) { 5534 createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG$5, COLLECTION_NAME); 5535 } 5536 5537 if (domIterables[COLLECTION_NAME]) for (var METHOD_NAME in es_array_iterator) { 5538 // some Chrome versions have non-configurable methods on DOMTokenList 5539 if (CollectionPrototype[METHOD_NAME] !== es_array_iterator[METHOD_NAME]) try { 5540 createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, es_array_iterator[METHOD_NAME]); 5541 } catch (error) { 5542 CollectionPrototype[METHOD_NAME] = es_array_iterator[METHOD_NAME]; 5543 } 5544 } 5545 } 5546 }; 5547 5548 for (var COLLECTION_NAME in domIterables) { 5549 handlePrototype(global_1[COLLECTION_NAME] && global_1[COLLECTION_NAME].prototype, COLLECTION_NAME); 5550 } 5551 5552 handlePrototype(domTokenListPrototype, 'DOMTokenList'); 5553 5554 var FunctionPrototype$2 = Function.prototype; 5555 var apply = FunctionPrototype$2.apply; 5556 var bind$2 = FunctionPrototype$2.bind; 5557 var call$2 = FunctionPrototype$2.call; // eslint-disable-next-line es/no-reflect -- safe 5558 5559 var functionApply = typeof Reflect == 'object' && Reflect.apply || (bind$2 ? call$2.bind(apply) : function () { 5560 return call$2.apply(apply, arguments); 5561 }); 5562 5563 var arraySlice = functionUncurryThis([].slice); 5564 5565 var engineIsIos = /(?:ipad|iphone|ipod).*applewebkit/i.test(engineUserAgent); 5566 5567 var engineIsNode = classofRaw(global_1.process) == 'process'; 5568 5569 var set$2 = global_1.setImmediate; 5570 var clear = global_1.clearImmediate; 5571 var process$1 = global_1.process; 5572 var Dispatch = global_1.Dispatch; 5573 var Function$1 = global_1.Function; 5574 var MessageChannel = global_1.MessageChannel; 5575 var String$5 = global_1.String; 5576 var counter = 0; 5577 var queue = {}; 5578 var ONREADYSTATECHANGE = 'onreadystatechange'; 5579 var location, defer, channel, port; 5580 5581 try { 5582 // Deno throws a ReferenceError on `location` access without `--location` flag 5583 location = global_1.location; 5584 } catch (error) { 5585 /* empty */ 5586 } 5587 5588 var run = function (id) { 5589 if (hasOwnProperty_1(queue, id)) { 5590 var fn = queue[id]; 5591 delete queue[id]; 5592 fn(); 5593 } 5594 }; 5595 5596 var runner = function (id) { 5597 return function () { 5598 run(id); 5599 }; 5600 }; 5601 5602 var listener = function (event) { 5603 run(event.data); 5604 }; 5605 5606 var post = function (id) { 5607 // old engines have not location.origin 5608 global_1.postMessage(String$5(id), location.protocol + '//' + location.host); 5609 }; // Node.js 0.9+ & IE10+ has setImmediate, otherwise: 5610 5611 5612 if (!set$2 || !clear) { 5613 set$2 = function setImmediate(fn) { 5614 var args = arraySlice(arguments, 1); 5615 5616 queue[++counter] = function () { 5617 functionApply(isCallable(fn) ? fn : Function$1(fn), undefined, args); 5618 }; 5619 5620 defer(counter); 5621 return counter; 5622 }; 5623 5624 clear = function clearImmediate(id) { 5625 delete queue[id]; 5626 }; // Node.js 0.8- 5627 5628 5629 if (engineIsNode) { 5630 defer = function (id) { 5631 process$1.nextTick(runner(id)); 5632 }; // Sphere (JS game engine) Dispatch API 5633 5634 } else if (Dispatch && Dispatch.now) { 5635 defer = function (id) { 5636 Dispatch.now(runner(id)); 5637 }; // Browsers with MessageChannel, includes WebWorkers 5638 // except iOS - https://github.com/zloirock/core-js/issues/624 5639 5640 } else if (MessageChannel && !engineIsIos) { 5641 channel = new MessageChannel(); 5642 port = channel.port2; 5643 channel.port1.onmessage = listener; 5644 defer = functionBindContext(port.postMessage, port); // Browsers with postMessage, skip WebWorkers 5645 // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' 5646 } else if (global_1.addEventListener && isCallable(global_1.postMessage) && !global_1.importScripts && location && location.protocol !== 'file:' && !fails(post)) { 5647 defer = post; 5648 global_1.addEventListener('message', listener, false); // IE8- 5649 } else if (ONREADYSTATECHANGE in documentCreateElement('script')) { 5650 defer = function (id) { 5651 html.appendChild(documentCreateElement('script'))[ONREADYSTATECHANGE] = function () { 5652 html.removeChild(this); 5653 run(id); 5654 }; 5655 }; // Rest old browsers 5656 5657 } else { 5658 defer = function (id) { 5659 setTimeout(runner(id), 0); 5660 }; 5661 } 5662 } 5663 5664 var task = { 5665 set: set$2, 5666 clear: clear 5667 }; 5668 5669 var FORCED = !global_1.setImmediate || !global_1.clearImmediate; // http://w3c.github.io/setImmediate/ 5670 5671 _export({ 5672 global: true, 5673 bind: true, 5674 enumerable: true, 5675 forced: FORCED 5676 }, { 5677 // `setImmediate` method 5678 // http://w3c.github.io/setImmediate/#si-setImmediate 5679 setImmediate: task.set, 5680 // `clearImmediate` method 5681 // http://w3c.github.io/setImmediate/#si-clearImmediate 5682 clearImmediate: task.clear 5683 }); 5684 5685 var engineIsIosPebble = /ipad|iphone|ipod/i.test(engineUserAgent) && global_1.Pebble !== undefined; 5686 5687 var engineIsWebosWebkit = /web0s(?!.*chrome)/i.test(engineUserAgent); 5688 5689 var getOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f; 5690 5691 var macrotask = task.set; 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 var MutationObserver = global_1.MutationObserver || global_1.WebKitMutationObserver; 5702 var document$2 = global_1.document; 5703 var process$2 = global_1.process; 5704 var Promise = global_1.Promise; // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask` 5705 5706 var queueMicrotaskDescriptor = getOwnPropertyDescriptor$2(global_1, 'queueMicrotask'); 5707 var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value; 5708 var flush, head, last, notify, toggle, node, promise, then; // modern engines have queueMicrotask method 5709 5710 if (!queueMicrotask) { 5711 flush = function () { 5712 var parent, fn; 5713 if (engineIsNode && (parent = process$2.domain)) parent.exit(); 5714 5715 while (head) { 5716 fn = head.fn; 5717 head = head.next; 5718 5719 try { 5720 fn(); 5721 } catch (error) { 5722 if (head) notify();else last = undefined; 5723 throw error; 5724 } 5725 } 5726 5727 last = undefined; 5728 if (parent) parent.enter(); 5729 }; // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339 5730 // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898 5731 5732 5733 if (!engineIsIos && !engineIsNode && !engineIsWebosWebkit && MutationObserver && document$2) { 5734 toggle = true; 5735 node = document$2.createTextNode(''); 5736 new MutationObserver(flush).observe(node, { 5737 characterData: true 5738 }); 5739 5740 notify = function () { 5741 node.data = toggle = !toggle; 5742 }; // environments with maybe non-completely correct, but existent Promise 5743 5744 } else if (!engineIsIosPebble && Promise && Promise.resolve) { 5745 // Promise.resolve without an argument throws an error in LG WebOS 2 5746 promise = Promise.resolve(undefined); // workaround of WebKit ~ iOS Safari 10.1 bug 5747 5748 promise.constructor = Promise; 5749 then = functionBindContext(promise.then, promise); 5750 5751 notify = function () { 5752 then(flush); 5753 }; // Node.js without promises 5754 5755 } else if (engineIsNode) { 5756 notify = function () { 5757 process$2.nextTick(flush); 5758 }; // for other environments - macrotask based on: 5759 // - setImmediate 5760 // - MessageChannel 5761 // - window.postMessag 5762 // - onreadystatechange 5763 // - setTimeout 5764 5765 } else { 5766 // strange IE + webpack dev server bug - use .bind(global) 5767 macrotask = functionBindContext(macrotask, global_1); 5768 5769 notify = function () { 5770 macrotask(flush); 5771 }; 5772 } 5773 } 5774 5775 var microtask = queueMicrotask || function (fn) { 5776 var task$$1 = { 5777 fn: fn, 5778 next: undefined 5779 }; 5780 if (last) last.next = task$$1; 5781 5782 if (!head) { 5783 head = task$$1; 5784 notify(); 5785 } 5786 5787 last = task$$1; 5788 }; 5789 5790 var process$3 = global_1.process; // `queueMicrotask` method 5791 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask 5792 5793 _export({ 5794 global: true, 5795 enumerable: true, 5796 noTargetGet: true 5797 }, { 5798 queueMicrotask: function queueMicrotask(fn) { 5799 var domain = engineIsNode && process$3.domain; 5800 microtask(domain ? domain.bind(fn) : fn); 5801 } 5802 }); 5803 5804 // File generated automatically. Don't modify it. 5805 5806}((this.window = this.window || {}))); 5807 5808 5809 5810if (window._main_polyfill_core) 5811{ 5812 console.warn('main.polyfill.core is loaded more than once on this page'); 5813} 5814 5815window._main_polyfill_core = true; 5816 5817 5818(function (exports) { 5819 'use strict'; 5820 5821 var bxTmp = window.BX; 5822 window.BX = function (node) { 5823 if (window.BX.type.isNotEmptyString(node)) { 5824 return document.getElementById(node); 5825 } 5826 if (window.BX.type.isDomNode(node)) { 5827 return node; 5828 } 5829 if (window.BX.type.isFunction(node)) { 5830 return window.BX.ready(node); 5831 } 5832 return null; 5833 }; 5834 if (bxTmp) {
5835 Object.keys(bxTmp).forEach(key => { 5836 window.BX[key] = bxTmp[key]; 5837 }); 5838 } 5839 exports = window.BX; 5840 5841 /** 5842 * Gets object.toString result 5843 * @param value 5844 * @return {string} 5845 */ 5846 function getTag(value) { 5847 return Object.prototype.toString.call(value); 5848 } 5849 5850 const objectCtorString = Function.prototype.toString.call(Object); 5851 5852 /** 5853 * @memberOf BX 5854 */ 5855 let Type = /*#__PURE__*/function () { 5856 function Type() { 5857 babelHelpers.classCallCheck(this, Type); 5858 } 5859 babelHelpers.createClass(Type, null, [{ 5860 key: "isString", 5861 /** 5862 * Checks that value is string 5863 * @param value 5864 * @return {boolean} 5865 */ 5866 value: function isString(value) { 5867 return typeof value === 'string'; 5868 } 5869 /** 5870 * Returns true if a value is not empty string 5871 * @param value 5872 * @returns {boolean} 5873 */ 5874 }, { 5875 key: "isStringFilled", 5876 value: function isStringFilled(value) { 5877 return Type.isString(value) && value !== ''; 5878 } 5879 /** 5880 * Checks that value is function 5881 * @param value 5882 * @return {boolean} 5883 */ 5884 }, { 5885 key: "isFunction", 5886 value: function isFunction(value) { 5887 return typeof value === 'function'; 5888 } 5889 /** 5890 * Checks that value is object 5891 * @param value 5892 * @return {boolean} 5893 */ 5894 }, { 5895 key: "isObject", 5896 value: function isObject(value) { 5897 return !!value && (typeof value === 'object' || typeof value === 'function'); 5898 } 5899 /** 5900 * Checks that value is object like 5901 * @param value 5902 * @return {boolean} 5903 */ 5904 }, { 5905 key: "isObjectLike", 5906 value: function isObjectLike(value) { 5907 return !!value && typeof value === 'object'; 5908 } 5909 /** 5910 * Checks that value is plain object 5911 * @param value 5912 * @return {boolean} 5913 */ 5914 }, { 5915 key: "isPlainObject", 5916 value: function isPlainObject(value) { 5917 if (!Type.isObjectLike(value) || getTag(value) !== '[object Object]') { 5918 return false; 5919 } 5920 const proto = Object.getPrototypeOf(value); 5921 if (proto === null) { 5922 return true; 5923 } 5924 const ctor = proto.hasOwnProperty('constructor') && proto.constructor; 5925 return typeof ctor === 'function' && Function.prototype.toString.call(ctor) === objectCtorString; 5926 } 5927 /** 5928 * Checks that value is boolean 5929 * @param value 5930 * @return {boolean} 5931 */ 5932 }, { 5933 key: "isBoolean", 5934 value: function isBoolean(value) { 5935 return value === true || value === false; 5936 } 5937 /** 5938 * Checks that value is number 5939 * @param value 5940 * @return {boolean} 5941 */ 5942 }, { 5943 key: "isNumber", 5944 value: function isNumber(value) { 5945 return !Number.isNaN(value) && typeof value === 'number'; 5946 } 5947 /** 5948 * Checks that value is integer 5949 * @param value 5950 * @return {boolean} 5951 */ 5952 }, { 5953 key: "isInteger", 5954 value: function isInteger(value) { 5955 return Type.isNumber(value) && value % 1 === 0; 5956 } 5957 /** 5958 * Checks that value is float 5959 * @param value 5960 * @return {boolean} 5961 */ 5962 }, { 5963 key: "isFloat", 5964 value: function isFloat(value) { 5965 return Type.isNumber(value) && !Type.isInteger(value); 5966 } 5967 /** 5968 * Checks that value is nil 5969 * @param value 5970 * @return {boolean} 5971 */ 5972 }, { 5973 key: "isNil", 5974 value: function isNil(value) { 5975 return value === null || value === undefined; 5976 } 5977 /** 5978 * Checks that value is array 5979 * @param value 5980 * @return {boolean} 5981 */ 5982 }, { 5983 key: "isArray", 5984 value: function isArray(value) { 5985 return !Type.isNil(value) && Array.isArray(value); 5986 } 5987 /** 5988 * Returns true if a value is an array and it has at least one element 5989 * @param value 5990 * @returns {boolean} 5991 */ 5992 }, { 5993 key: "isArrayFilled", 5994 value: function isArrayFilled(value) { 5995 return Type.isArray(value) && value.length > 0; 5996 } 5997 /** 5998 * Checks that value is array like 5999 * @param value 6000 * @return {boolean} 6001 */ 6002 }, { 6003 key: "isArrayLike", 6004 value: function isArrayLike(value) { 6005 return !Type.isNil(value) && !Type.isFunction(value) && value.length > -1 && value.length <= Number.MAX_SAFE_INTEGER; 6006 } 6007 /** 6008 * Checks that value is Date 6009 * @param value 6010 * @return {boolean} 6011 */ 6012 }, { 6013 key: "isDate", 6014 value: function isDate(value) { 6015 return Type.isObjectLike(value) && getTag(value) === '[object Date]'; 6016 } 6017 /** 6018 * Checks that is DOM node 6019 * @param value 6020 * @return {boolean} 6021 */ 6022 }, { 6023 key: "isDomNode", 6024 value: function isDomNode(value) { 6025 return Type.isObjectLike(value) && !Type.isPlainObject(value) && 'nodeType' in value; 6026 } 6027 /** 6028 * Checks that value is element node 6029 * @param value 6030 * @return {boolean} 6031 */ 6032 }, { 6033 key: "isElementNode", 6034 value: function isElementNode(value) { 6035 return Type.isDomNode(value) && value.nodeType === Node.ELEMENT_NODE; 6036 } 6037 /** 6038 * Checks that value is text node 6039 * @param value 6040 * @return {boolean} 6041 */ 6042 }, { 6043 key: "isTextNode", 6044 value: function isTextNode(value) { 6045 return Type.isDomNode(value) && value.nodeType === Node.TEXT_NODE; 6046 } 6047 /** 6048 * Checks that value is Map 6049 * @param value 6050 * @return {boolean} 6051 */ 6052 }, { 6053 key: "isMap", 6054 value: function isMap(value) { 6055 return Type.isObjectLike(value) && getTag(value) === '[object Map]'; 6056 } 6057 /** 6058 * Checks that value is Set 6059 * @param value 6060 * @return {boolean} 6061 */ 6062 }, { 6063 key: "isSet", 6064 value: function isSet(value) { 6065 return Type.isObjectLike(value) && getTag(value) === '[object Set]'; 6066 } 6067 /** 6068 * Checks that value is WeakMap 6069 * @param value 6070 * @return {boolean} 6071 */ 6072 }, { 6073 key: "isWeakMap", 6074 value: function isWeakMap(value) { 6075 return Type.isObjectLike(value) && getTag(value) === '[object WeakMap]'; 6076 } 6077 /** 6078 * Checks that value is WeakSet 6079 * @param value 6080 * @return {boolean} 6081 */ 6082 }, { 6083 key: "isWeakSet", 6084 value: function isWeakSet(value) { 6085 return Type.isObjectLike(value) && getTag(value) === '[object WeakSet]'; 6086 } 6087 /** 6088 * Checks that value is prototype 6089 * @param value 6090 * @return {boolean} 6091 */ 6092 }, { 6093 key: "isPrototype", 6094 value: function isPrototype(value) { 6095 return (typeof (value && value.constructor) === 'function' && value.constructor.prototype || Object.prototype) === value; 6096 } 6097 /** 6098 * Checks that value is regexp 6099 * @param value 6100 * @return {boolean} 6101 */ 6102 }, { 6103 key: "isRegExp", 6104 value: function isRegExp(value) { 6105 return Type.isObjectLike(value) && getTag(value) === '[object RegExp]'; 6106 } 6107 /** 6108 * Checks that value is null 6109 * @param value 6110 * @return {boolean} 6111 */ 6112 }, { 6113 key: "isNull", 6114 value: function isNull(value) { 6115 return value === null; 6116 } 6117 /** 6118 * Checks that value is undefined 6119 * @param value 6120 * @return {boolean} 6121 */ 6122 }, { 6123 key: "isUndefined", 6124 value: function isUndefined(value) { 6125 return typeof value === 'undefined'; 6126 } 6127 /** 6128 * Checks that value is ArrayBuffer 6129 * @param value 6130 * @return {boolean} 6131 */ 6132 }, { 6133 key: "isArrayBuffer", 6134 value: function isArrayBuffer(value) { 6135 return Type.isObjectLike(value) && getTag(value) === '[object ArrayBuffer]'; 6136 } 6137 /** 6138 * Checks that value is typed array 6139 * @param value 6140 * @return {boolean} 6141 */ 6142 }, { 6143 key: "isTypedArray", 6144 value: function isTypedArray(value) { 6145 const regExpTypedTag = /^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)]$/; 6146 return Type.isObjectLike(value) && regExpTypedTag.test(getTag(value)); 6147 } 6148 /** 6149 * Checks that value is Blob 6150 * @param value 6151 * @return {boolean} 6152 */ 6153 }, { 6154 key: "isBlob", 6155 value: function isBlob(value) { 6156 return Type.isObjectLike(value) && Type.isNumber(value.size) && Type.isString(value.type) && Type.isFunction(value.slice); 6157 } 6158 /** 6159 * Checks that value is File 6160 * @param value 6161 * @return {boolean} 6162 */ 6163 }, { 6164 key: "isFile", 6165 value: function isFile(value) { 6166 return Type.isBlob(value) && Type.isString(value.name) && (Type.isNumber(value.lastModified) || Type.isObjectLike(value.lastModifiedDate)); 6167 } 6168 /** 6169 * Checks that value is FormData 6170 * @param value 6171 * @return {boolean} 6172 */ 6173 }, { 6174 key: "isFormData", 6175 value: function isFormData(value) { 6176 return value instanceof FormData; 6177 } 6178 }]); 6179 return Type; 6180 }(); 6181 6182 /** 6183 * @memberOf BX 6184 */ 6185 let Reflection = /*#__PURE__*/function () { 6186 function Reflection() { 6187 babelHelpers.classCallCheck(this, Reflection); 6188 } 6189 babelHelpers.createClass(Reflection, null, [{ 6190 key: "getClass", 6191 /** 6192 * Gets link to function by function name 6193 * @param className 6194 * @return {?Function} 6195 */ 6196 value: function getClass(className) { 6197 if (Type.isString(className) && !!className) { 6198 let classFn = null; 6199 let currentNamespace = window; 6200 const namespaces = className.split('.'); 6201 for (let i = 0; i < namespaces.length; i += 1) { 6202 const namespace = namespaces[i]; 6203 if (!currentNamespace[namespace]) { 6204 return null; 6205 } 6206 currentNamespace = currentNamespace[namespace]; 6207 classFn = currentNamespace; 6208 } 6209 return classFn; 6210 } 6211 if (Type.isFunction(className)) { 6212 return className; 6213 } 6214 return null; 6215 } 6216 /** 6217 * Creates a namespace or returns a link to a previously created one 6218 * @param {String} namespaceName 6219 * @return {Object<string, any> | Function | null} 6220 */ 6221 }, { 6222 key: "namespace", 6223 value: function namespace(namespaceName) { 6224 let parts = namespaceName.split('.'); 6225 let parent = window.BX; 6226 if (parts[0] === 'BX') { 6227 parts = parts.slice(1); 6228 } 6229 for (let i = 0; i < parts.length; i += 1) { 6230 if (Type.isUndefined(parent[parts[i]])) { 6231 parent[parts[i]] = {}; 6232 } 6233 parent = parent[parts[i]]; 6234 } 6235 return parent; 6236 } 6237 }]); 6238 return Reflection; 6239 }(); 6240 6241 const reEscape = /[&<>'"]/g; 6242 const reUnescape = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g; 6243 const escapeEntities = { 6244 '&': '&', 6245 '<': '<', 6246 '>': '>', 6247 "'": ''', 6248 '"': '"' 6249 }; 6250 const unescapeEntities = { 6251 '&': '&', 6252 '&': '&', 6253 '<': '<', 6254 '<': '<', 6255 '>': '>', 6256 '>': '>', 6257 ''': "'", 6258 ''': "'", 6259 '"': '"', 6260 '"': '"' 6261 }; 6262 6263 /** 6264 * @memberOf BX 6265 */ 6266 let Text = /*#__PURE__*/function () { 6267 function Text() { 6268 babelHelpers.classCallCheck(this, Text); 6269 } 6270 babelHelpers.createClass(Text, null, [{ 6271 key: "encode", 6272 /** 6273 * Encodes all unsafe entities 6274 * @param {string} value 6275 * @return {string} 6276 */ 6277 value: function encode(value) { 6278 if (Type.isString(value)) { 6279 return value.replace(reEscape, item => escapeEntities[item]); 6280 } 6281 return value; 6282 } 6283 /** 6284 * Decodes all encoded entities 6285 * @param {string} value 6286 * @return {string} 6287 */ 6288 }, { 6289 key: "decode", 6290 value: function decode(value) { 6291 if (Type.isString(value)) { 6292 return value.replace(reUnescape, item => unescapeEntities[item]); 6293 } 6294 return value; 6295 } 6296 }, { 6297 key: "getRandom", 6298 value: function getRandom(length = 8) { 6299 // eslint-disable-next-line 6300 return [...Array(length)].map(() => (~~(Math.random() * 36)).toString(36)).join(''); 6301 } 6302 }, { 6303 key: "toNumber", 6304 value: function toNumber(value) { 6305 const parsedValue = Number.parseFloat(value); 6306 if (Type.isNumber(parsedValue)) { 6307 return parsedValue; 6308 } 6309 return 0; 6310 } 6311 }, { 6312 key: "toInteger", 6313 value: function toInteger(value) { 6314 return Text.toNumber(Number.parseInt(value, 10)); 6315 } 6316 }, { 6317 key: "toBoolean", 6318 value: function toBoolean(value, trueValues = []) { 6319 const transformedValue = Type.isString(value) ? value.toLowerCase() : value; 6320 return ['true', 'y', '1', 1, true, ...trueValues].includes(transformedValue); 6321 } 6322 }, { 6323 key: "toCamelCase", 6324 value: function toCamelCase(str) { 6325 if (!Type.isStringFilled(str)) { 6326 return str; 6327 } 6328 const regex = /[-_\s]+(.)?/g; 6329 if (!regex.test(str)) { 6330 return str.match(/^[A-Z]+$/) ? str.toLowerCase() : str[0].toLowerCase() + str.slice(1); 6331 } 6332 str = str.toLowerCase(); 6333 str = str.replace(regex, function (match, letter) { 6334 return letter ? letter.toUpperCase() : ''; 6335 }); 6336 return str[0].toLowerCase() + str.substr(1); 6337 } 6338 }, { 6339 key: "toPascalCase", 6340 value: function toPascalCase(str) { 6341 if (!Type.isStringFilled(str)) { 6342 return str; 6343 } 6344 return this.capitalize(this.toCamelCase(str)); 6345 } 6346 }, { 6347 key: "toKebabCase", 6348 value: function toKebabCase(str) { 6349 if (!Type.isStringFilled(str)) { 6350 return str; 6351 } 6352 const matches = str.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g); 6353 if (!matches) { 6354 return str; 6355 } 6356 return matches.map(x => x.toLowerCase()).join('-'); 6357 } 6358 }, { 6359 key: "capitalize", 6360 value: function capitalize(str) { 6361 if (!Type.isStringFilled(str)) { 6362 return str; 6363 } 6364 return str[0].toUpperCase() + str.substr(1); 6365 } 6366 }]); 6367 return Text; 6368 }(); 6369 6370 const aliases = { 6371 mousewheel: ['DOMMouseScroll'], 6372 bxchange: ['change', 'cut', 'paste', 'drop', 'keyup'], 6373 animationend: ['animationend', 'oAnimationEnd', 'webkitAnimationEnd', 'MSAnimationEnd'], 6374 transitionend: ['webkitTransitionEnd', 'otransitionend', 'oTransitionEnd', 'msTransitionEnd', 'transitionend'], 6375 fullscreenchange: ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange', 'MSFullscreenChange'], 6376 fullscreenerror: ['fullscreenerror', 'webkitfullscreenerror', 'mozfullscreenerror', 'MSFullscreenError'] 6377 }; 6378 6379 let Registry = /*#__PURE__*/function () { 6380 function Registry() { 6381 babelHelpers.classCallCheck(this, Registry); 6382 babelHelpers.defineProperty(this, "registry", new WeakMap()); 6383 } 6384 babelHelpers.createClass(Registry, [{ 6385 key: "set", 6386 value: function set(target, event, listener) { 6387 const events = this.get(target); 6388 if (!Type.isSet(events[event])) { 6389 events[event] = new Set(); 6390 } 6391 events[event].add(listener); 6392 this.registry.set(target, events); 6393 } 6394 }, { 6395 key: "get", 6396 value: function get(target) { 6397 return this.registry.get(target) || {}; 6398 } 6399 }, { 6400 key: "has", 6401 value: function has(target, event, listener) { 6402 if (event && listener) { 6403 return this.registry.has(target) && this.registry.get(target)[event].has(listener); 6404 } 6405 return this.registry.has(target); 6406 } 6407 }, { 6408 key: "delete", 6409 value: function _delete(target, event, listener) { 6410 if (!Type.isDomNode(target)) { 6411 return; 6412 } 6413 if (Type.isString(event) && Type.isFunction(listener)) { 6414 const events = this.registry.get(target); 6415 if (Type.isPlainObject(events) && Type.isSet(events[event])) { 6416 events[event].delete(listener); 6417 } 6418 return; 6419 } 6420 if (Type.isString(event)) { 6421 const events = this.registry.get(target); 6422 if (Type.isPlainObject(events) && Type.isSet(events[event])) { 6423 events[event] = new Set(); 6424 } 6425 return; 6426 } 6427 this.registry.delete(target); 6428 } 6429 }]); 6430 return Registry; 6431 }(); 6432 var registry = new Registry(); 6433 6434 function isOptionSupported(name) { 6435 let isSupported = false;
6436 try { 6437 const options = Object.defineProperty({}, name, { 6438 get() { 6439 isSupported = true; 6440 return undefined; 6441 } 6442 }); 6443 window.addEventListener('test', null, options); 6444 } 6445 // eslint-disable-next-line 6446 catch (err) {} 6447 return isSupported; 6448 } 6449 function fetchSupportedListenerOptions(options) { 6450 if (!Type.isPlainObject(options)) { 6451 return options; 6452 } 6453 return Object.keys(options).reduce((acc, name) => { 6454 if (isOptionSupported(name)) { 6455 acc[name] = options[name]; 6456 } 6457 return acc; 6458 }, {}); 6459 } 6460 6461 function bind(target, eventName, handler, options) { 6462 if (!Type.isObject(target) || !Type.isFunction(target.addEventListener)) { 6463 return; 6464 } 6465 const listenerOptions = fetchSupportedListenerOptions(options); 6466 if (eventName in aliases) { 6467 aliases[eventName].forEach(key => { 6468 target.addEventListener(key, handler, listenerOptions); 6469 registry.set(target, eventName, handler); 6470 }); 6471 return; 6472 } 6473 target.addEventListener(eventName, handler, listenerOptions); 6474 registry.set(target, eventName, handler); 6475 } 6476 6477 function unbind(target, eventName, handler, options) { 6478 if (!Type.isObject(target) || !Type.isFunction(target.removeEventListener)) { 6479 return; 6480 } 6481 const listenerOptions = fetchSupportedListenerOptions(options); 6482 if (eventName in aliases) { 6483 aliases[eventName].forEach(key => { 6484 target.removeEventListener(key, handler, listenerOptions); 6485 registry.delete(target, key, handler); 6486 }); 6487 return; 6488 } 6489 target.removeEventListener(eventName, handler, listenerOptions); 6490 registry.delete(target, eventName, handler); 6491 } 6492 6493 function unbindAll(target, eventName) { 6494 const events = registry.get(target); 6495 Object.keys(events).forEach(currentEvent => { 6496 events[currentEvent].forEach(handler => { 6497 if (!Type.isString(eventName) || eventName === currentEvent) { 6498 unbind(target, currentEvent, handler); 6499 } 6500 }); 6501 }); 6502 } 6503 6504 function bindOnce(target, eventName, handler, options) { 6505 const once = function once(...args) { 6506 unbind(target, eventName, once, options); 6507 handler(...args); 6508 }; 6509 bind(target, eventName, once, options); 6510 } 6511 6512 // eslint-disable-next-line 6513 let debugState = true; 6514 function enableDebug() { 6515 debugState = true; 6516 } 6517 function disableDebug() { 6518 debugState = false; 6519 } 6520 function isDebugEnabled() { 6521 return debugState; 6522 } 6523 function debug(...args) { 6524 if (isDebugEnabled() && Type.isObject(window.console)) { 6525 if (Type.isFunction(window.console.log)) { 6526 window.console.log('BX.debug: ', args.length > 0 ? args : args[0]); 6527 if (args[0] instanceof Error && args[0].stack) { 6528 window.console.log('BX.debug error stack trace', args[0].stack); 6529 } 6530 } 6531 if (Type.isFunction(window.console.trace)) { 6532 // eslint-disable-next-line 6533 console.trace(); 6534 } 6535 } 6536 } 6537 6538 var debugNs = /*#__PURE__*/Object.freeze({ 6539 get debugState () { return debugState; }, 6540 enableDebug: enableDebug, 6541 disableDebug: disableDebug, 6542 isDebugEnabled: isDebugEnabled, 6543 default: debug 6544 }); 6545 6546 const extensionsStorage = new Map(); 6547 6548 const ajaxController = 'main.bitrix.main.controller.loadext.getextensions'; 6549 function loadAssets(options) { 6550 return new Promise(resolve => { 6551 // eslint-disable-next-line 6552 BX.ajax.runAction(ajaxController, { 6553 data: options 6554 }).then(resolve); 6555 }); 6556 } 6557 6558 function fetchInlineScripts(acc, item) { 6559 if (item.isInternal) { 6560 acc.push(item.JS); 6561 } 6562 return acc; 6563 } 6564 function fetchExternalScripts(acc, item) { 6565 if (!item.isInternal) { 6566 acc.push(item.JS); 6567 } 6568 return acc; 6569 } 6570 function fetchExternalStyles(acc, item) { 6571 if (Type.isString(item) && item !== '') { 6572 acc.push(item); 6573 } 6574 return acc; 6575 } 6576 function fetchExtensionSettings(html) { 6577 if (Type.isStringFilled(html)) { 6578 const scripts = html.match(/<script type="extension\/settings" \b[^>]*>([\s\S]*?)<\/script>/g); 6579 if (Type.isArrayFilled(scripts)) { 6580 return scripts.map(script => { 6581 const [, extension] = script.match(/data-extension="(.[a-z0-9_.-]+)"/); 6582 return { 6583 extension, 6584 script 6585 }; 6586 }); 6587 } 6588 } 6589 return []; 6590 } 6591 function loadAll(items) { 6592 const itemsList = Type.isArray(items) ? items : [items]; 6593 if (!itemsList.length) { 6594 return Promise.resolve(); 6595 } 6596 return new Promise(resolve => { 6597 // eslint-disable-next-line 6598 BX.load(itemsList, resolve); 6599 }); 6600 } 6601 6602 function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); } 6603 function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 6604 const defaultOptions = { 6605 loaded: false 6606 }; 6607 var _state = /*#__PURE__*/new WeakMap(); 6608 var _name = /*#__PURE__*/new WeakMap(); 6609 var _namespace = /*#__PURE__*/new WeakMap(); 6610 var _promise = /*#__PURE__*/new WeakMap(); 6611 let Extension = /*#__PURE__*/function () { 6612 function Extension(options) { 6613 babelHelpers.classCallCheck(this, Extension); 6614 _classPrivateFieldInitSpec(this, _state, { 6615 writable: true, 6616 value: Extension.State.LOADING 6617 }); 6618 _classPrivateFieldInitSpec(this, _name, { 6619 writable: true, 6620 value: '' 6621 }); 6622 _classPrivateFieldInitSpec(this, _namespace, { 6623 writable: true, 6624 value: '' 6625 }); 6626 _classPrivateFieldInitSpec(this, _promise, { 6627 writable: true, 6628 value: null 6629 }); 6630 const preparedOptions = { 6631 ...defaultOptions, 6632 ...options 6633 }; 6634 babelHelpers.classPrivateFieldSet(this, _name, preparedOptions.name); 6635 babelHelpers.classPrivateFieldSet(this, _namespace, Type.isStringFilled(preparedOptions.namespace) ? preparedOptions.namespace : 'window'); 6636 if (preparedOptions.loaded) { 6637 babelHelpers.classPrivateFieldSet(this, _state, Extension.State.LOADED); 6638 } 6639 } 6640 babelHelpers.createClass(Extension, [{ 6641 key: "load", 6642 value: function load() { 6643 if (babelHelpers.classPrivateFieldGet(this, _state) === Extension.State.LOADED && !babelHelpers.classPrivateFieldGet(this, _promise)) { 6644 babelHelpers.classPrivateFieldSet(this, _promise, Promise.resolve(Reflection.getClass(babelHelpers.classPrivateFieldGet(this, _namespace)))); 6645 } 6646 if (babelHelpers.classPrivateFieldGet(this, _promise)) { 6647 return babelHelpers.classPrivateFieldGet(this, _promise); 6648 } 6649 babelHelpers.classPrivateFieldSet(this, _state, Extension.State.LOADING); 6650 babelHelpers.classPrivateFieldSet(this, _promise, new Promise(resolve => { 6651 void loadAssets({ 6652 extension: [babelHelpers.classPrivateFieldGet(this, _name)] 6653 }).then(assetsResult => { 6654 if (!Type.isArrayFilled(assetsResult.data)) { 6655 resolve(window); 6656 }
6657 const extensionData = assetsResult.data.at(0); 6658 if (Type.isPlainObject(extensionData.config) && Type.isStringFilled(extensionData.config.namespace)) { 6659 babelHelpers.classPrivateFieldSet(this, _namespace, extensionData.config.namespace); 6660 } 6661 const result = BX.processHTML(extensionData.html || ''); 6662 const inlineScripts = result.SCRIPT.reduce(fetchInlineScripts, []); 6663 const externalScripts = result.SCRIPT.reduce(fetchExternalScripts, []); 6664 const externalStyles = result.STYLE.reduce(fetchExternalStyles, []); 6665 const settingsScripts = fetchExtensionSettings(result.HTML); 6666 settingsScripts.forEach(entry => { 6667 document.body.insertAdjacentHTML('beforeend', entry.script); 6668 }); 6669 const runScriptsBefore = inlineScripts.filter(script => { 6670 return !script.startsWith('BX.Runtime.registerExtension'); 6671 }); 6672 const runScriptsAfter = inlineScripts.filter(script => { 6673 return script.startsWith('BX.Runtime.registerExtension'); 6674 }); 6675 runScriptsBefore.forEach(script => { 6676 BX.evalGlobal(script); 6677 }); 6678 void Promise.all([loadAll(externalScripts), loadAll(externalStyles)]).then(() => { 6679 babelHelpers.classPrivateFieldSet(this, _state, Extension.State.LOADED); 6680 runScriptsAfter.forEach(script => { 6681 BX.evalGlobal(script); 6682 }); 6683 if (babelHelpers.classPrivateFieldGet(this, _namespace)) { 6684 return Reflection.getClass(babelHelpers.classPrivateFieldGet(this, _namespace)); 6685 } 6686 return window; 6687 }).then(exports => { 6688 resolve(exports); 6689 }); 6690 }); 6691 })); 6692 return babelHelpers.classPrivateFieldGet(this, _promise); 6693 } 6694 }]); 6695 return Extension; 6696 }(); 6697 babelHelpers.defineProperty(Extension, "State", { 6698 LOADED: 'LOADED', 6699 LOADING: 'LOADING' 6700 }); 6701 6702 async function loadExtension(...extensionName) { 6703 const extensionNames = extensionName.flat(); 6704 const result = extensionNames.map(name => { 6705 if (extensionsStorage.has(name)) { 6706 return extensionsStorage.get(name).load(); 6707 } 6708 const extension = new Extension({ 6709 name 6710 }); 6711 extensionsStorage.set(name, extension); 6712 return extension.load(); 6713 }); 6714 return Promise.all(result).then(exports => { 6715 return exports.reduce((acc, currentExports) => { 6716 if (Type.isObject(currentExports)) { 6717 return { 6718 ...acc, 6719 ...currentExports 6720 }; 6721 } 6722 return acc; 6723 }, {}); 6724 }); 6725 } 6726 6727 const cloneableTags = ['[object Object]', '[object Array]', '[object RegExp]', '[object Arguments]', '[object Date]', '[object Error]', '[object Map]', '[object Set]', '[object ArrayBuffer]', '[object DataView]', '[object Float32Array]', '[object Float64Array]', '[object Int8Array]', '[object Int16Array]', '[object Int32Array]', '[object Uint8Array]', '[object Uint16Array]', '[object Uint32Array]', '[object Uint8ClampedArray]']; 6728 function isCloneable(value) { 6729 const isCloneableValue = Type.isObjectLike(value) && cloneableTags.includes(getTag(value)); 6730 return isCloneableValue || Type.isDomNode(value); 6731 } 6732 function internalClone(value, map) { 6733 if (map.has(value)) { 6734 return map.get(value); 6735 } 6736 if (isCloneable(value)) { 6737 if (Type.isArray(value)) { 6738 const cloned = Array.from(value); 6739 map.set(value, cloned); 6740 value.forEach((item, index) => { 6741 cloned[index] = internalClone(item, map); 6742 }); 6743 return map.get(value); 6744 } 6745 if (Type.isDomNode(value)) { 6746 return value.cloneNode(true); 6747 } 6748 if (Type.isMap(value)) { 6749 const result = new Map(); 6750 map.set(value, result); 6751 value.forEach((item, key) => { 6752 result.set(internalClone(key, map), internalClone(item, map)); 6753 }); 6754 return result; 6755 } 6756 if (Type.isSet(value)) { 6757 const result = new Set(); 6758 map.set(value, result); 6759 value.forEach(item => { 6760 result.add(internalClone(item, map)); 6761 }); 6762 return result; 6763 } 6764 if (Type.isDate(value)) { 6765 return new Date(value); 6766 } 6767 if (Type.isRegExp(value)) { 6768 const regExpFlags = /\w*$/; 6769 const flags = regExpFlags.exec(value); 6770 let result = new RegExp(value.source); 6771 if (flags && Type.isArray(flags)) { 6772 result = new RegExp(value.source, flags[0]); 6773 } 6774 result.lastIndex = value.lastIndex; 6775 return result; 6776 } 6777 const proto = Object.getPrototypeOf(value); 6778 const result = Object.assign(Object.create(proto), value); 6779 map.set(value, result); 6780 Object.keys(value).forEach(key => { 6781 result[key] = internalClone(value[key], map); 6782 }); 6783 return result; 6784 } 6785 return value; 6786 } 6787 6788 /** 6789 * Clones any cloneable object 6790 * @param value 6791 * @return {*} 6792 */ 6793 function clone(value) { 6794 return internalClone(value, new WeakMap()); 6795 } 6796 6797 function merge(current, target) { 6798 return Object.entries(target).reduce((acc, [key, value]) => { 6799 if (!Type.isDomNode(acc[key]) && Type.isObjectLike(acc[key]) && Type.isObjectLike(value)) { 6800 acc[key] = merge(acc[key], value); 6801 return acc; 6802 } 6803 acc[key] = value; 6804 return acc; 6805 }, current); 6806 } 6807 6808 function createComparator(fields, orders = []) { 6809 return (a, b) => { 6810 const field = fields[0]; 6811 const order = orders[0] || 'asc'; 6812 if (Type.isUndefined(field)) { 6813 return 0; 6814 } 6815 let valueA = a[field]; 6816 let valueB = b[field]; 6817 if (Type.isString(valueA) && Type.isString(valueB)) { 6818 valueA = valueA.toLowerCase(); 6819 valueB = valueB.toLowerCase(); 6820 } 6821 if (valueA < valueB) { 6822 return order === 'asc' ? -1 : 1; 6823 } 6824 if (valueA > valueB) { 6825 return order === 'asc' ? 1 : -1; 6826 } 6827 return createComparator(fields.slice(1), orders.slice(1))(a, b); 6828 }; 6829 } 6830 6831 function registerExtension(options) { 6832 if (!extensionsStorage.has(options.name)) { 6833 extensionsStorage.set(options.name, new Extension(options)); 6834 } 6835 } 6836
6837 /** 6838 * @memberOf BX 6839 */ 6840 let Runtime = /*#__PURE__*/function () { 6841 function Runtime() { 6842 babelHelpers.classCallCheck(this, Runtime); 6843 } 6844 babelHelpers.createClass(Runtime, null, [{ 6845 key: "debounce", 6846 value: function debounce(func, wait = 0, context = null) { 6847 let timeoutId; 6848 return function debounced(...args) { 6849 if (Type.isNumber(timeoutId)) { 6850 clearTimeout(timeoutId); 6851 } 6852 timeoutId = setTimeout(() => { 6853 func.apply(context || this, args); 6854 }, wait); 6855 }; 6856 } 6857 }, { 6858 key: "throttle", 6859 value: function throttle(func, wait = 0, context = null) { 6860 let timer = 0; 6861 let invoke; 6862 return function wrapper(...args) { 6863 invoke = true; 6864 if (!timer) { 6865 const q = function q() { 6866 if (invoke) { 6867 func.apply(context || this, args); 6868 invoke = false; 6869 timer = setTimeout(q, wait); 6870 } else { 6871 timer = null; 6872 } 6873 }; 6874 q(); 6875 } 6876 }; 6877 } 6878 }, { 6879 key: "html", 6880 value: function html(node, _html, params = {}) { 6881 if (Type.isNil(_html) && Type.isDomNode(node)) { 6882 return node.innerHTML; 6883 } 6884 6885 // eslint-disable-next-line 6886 const parsedHtml = BX.processHTML(_html); 6887 const externalCss = parsedHtml.STYLE.reduce(fetchExternalStyles, []); 6888 const externalJs = parsedHtml.SCRIPT.reduce(fetchExternalScripts, []); 6889 const inlineJs = parsedHtml.SCRIPT.reduce(fetchInlineScripts, []); 6890 if (Type.isDomNode(node)) { 6891 if (params.htmlFirst || !externalJs.length && !externalCss.length) { 6892 if (params.useAdjacentHTML) { 6893 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 6894 } else { 6895 node.innerHTML = parsedHtml.HTML; 6896 } 6897 } 6898 } 6899 return Promise.all([loadAll(externalJs), loadAll(externalCss)]).then(() => { 6900 if (Type.isDomNode(node) && (externalJs.length > 0 || externalCss.length > 0)) { 6901 if (params.useAdjacentHTML) { 6902 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 6903 } else { 6904 node.innerHTML = parsedHtml.HTML; 6905 } 6906 } 6907 6908 // eslint-disable-next-line 6909 inlineJs.forEach(script => BX.evalGlobal(script)); 6910 if (Type.isFunction(params.callback)) { 6911 params.callback(); 6912 } 6913 }); 6914 } 6915 /** 6916 * Merges objects or arrays 6917 * @param targets 6918 * @return {any} 6919 */ 6920 }, { 6921 key: "merge", 6922 value: function merge$$1(...targets) { 6923 if (Type.isArray(targets[0])) { 6924 targets.unshift([]); 6925 } else if (Type.isObject(targets[0])) { 6926 targets.unshift({}); 6927 } 6928 return targets.reduce((acc, item) => { 6929 return merge(acc, item); 6930 }, targets[0]); 6931 } 6932 }, { 6933 key: "orderBy", 6934 value: function orderBy(collection, fields = [], orders = []) { 6935 const comparator = createComparator(fields, orders); 6936 return Object.values(collection).sort(comparator); 6937 } 6938 }, { 6939 key: "destroy", 6940 value: function destroy(target, errorMessage = 'Object is destroyed') { 6941 if (Type.isObject(target)) { 6942 const onPropertyAccess = () => { 6943 throw new Error(errorMessage); 6944 }; 6945 const ownProperties = Object.keys(target); 6946 const prototypeProperties = (() => { 6947 const targetPrototype = Object.getPrototypeOf(target); 6948 if (Type.isObject(targetPrototype)) { 6949 return Object.getOwnPropertyNames(targetPrototype); 6950 } 6951 return []; 6952 })(); 6953 const uniquePropertiesList = [...new Set([...ownProperties, ...prototypeProperties])]; 6954 uniquePropertiesList.filter(name => { 6955 const descriptor = Object.getOwnPropertyDescriptor(target, name); 6956 return !/__(.+)__/.test(name) && (!Type.isObject(descriptor) || descriptor.configurable === true); 6957 }
6957).forEach(name => { 6958 Object.defineProperty(target, name, { 6959 get: onPropertyAccess, 6960 set: onPropertyAccess, 6961 configurable: false 6962 }); 6963 }); 6964 Object.setPrototypeOf(target, null); 6965 } 6966 } 6967 }]); 6968 return Runtime; 6969 }(); 6970 babelHelpers.defineProperty(Runtime, "debug", debug); 6971 babelHelpers.defineProperty(Runtime, "loadExtension", loadExtension); 6972 babelHelpers.defineProperty(Runtime, "registerExtension", registerExtension); 6973 babelHelpers.defineProperty(Runtime, "clone", clone); 6974 6975 const _isError = Symbol.for('BX.BaseError.isError'); 6976 6977 /** 6978 * @memberOf BX 6979 */ 6980 let BaseError = /*#__PURE__*/function () { 6981 function BaseError(message, code, customData) { 6982 babelHelpers.classCallCheck(this, BaseError); 6983 this[_isError] = true; 6984 this.message = ''; 6985 this.code = null; 6986 this.customData = null; 6987 this.setMessage(message); 6988 this.setCode(code); 6989 this.setCustomData(customData); 6990 } 6991 6992 /** 6993 * Returns a brief description of the error 6994 * @returns {string} 6995 */ 6996 babelHelpers.createClass(BaseError, [{ 6997 key: "getMessage", 6998 value: function getMessage() { 6999 return this.message; 7000 } 7001 /** 7002 * Sets a message of the error 7003 * @param {string} message 7004 * @returns {this} 7005 */ 7006 }, { 7007 key: "setMessage", 7008 value: function setMessage(message) { 7009 if (Type.isString(message)) { 7010 this.message = message; 7011 } 7012 return this; 7013 } 7014 /** 7015 * Returns a code of the error 7016 * @returns {?string} 7017 */ 7018 }, { 7019 key: "getCode", 7020 value: function getCode() { 7021 return this.code; 7022 } 7023 /** 7024 * Sets a code of the error 7025 * @param {string} code 7026 * @returns {this} 7027 */ 7028 }, { 7029 key: "setCode", 7030 value: function setCode(code) { 7031 if (Type.isStringFilled(code) || code === null) { 7032 this.code = code; 7033 } 7034 return this; 7035 } 7036 /** 7037 * Returns custom data of the error 7038 * @returns {null|*} 7039 */ 7040 }, { 7041 key: "getCustomData", 7042 value: function getCustomData() { 7043 return this.customData; 7044 } 7045 /** 7046 * Sets custom data of the error 7047 * @returns {this} 7048 */ 7049 }, { 7050 key: "setCustomData", 7051 value: function setCustomData(customData) { 7052 if (!Type.isUndefined(customData)) { 7053 this.customData = customData; 7054 } 7055 return this; 7056 } 7057 }, { 7058 key: "toString", 7059 value: function toString() { 7060 const code = this.getCode(); 7061 const message = this.getMessage(); 7062 if (!Type.isStringFilled(code) && !Type.isStringFilled(message)) { 7063 return ''; 7064 } else if (!Type.isStringFilled(code)) { 7065 return `Error: ${message}`; 7066 } else if (!Type.isStringFilled(message)) { 7067 return code; 7068 } else { 7069 return `${code}: ${message}`; 7070 } 7071 } 7072 /** 7073 * Returns true if the object is an instance of BaseError 7074 * @param error 7075 * @returns {boolean} 7076 */ 7077 }], [{ 7078 key: "isError", 7079 value: function isError(error) { 7080 return Type.isObject(error) && error[_isError] === true; 7081 } 7082 }]); 7083 return BaseError; 7084 }(); 7085 7086 /** 7087 * Implements base event object interface 7088 */ 7089 let BaseEvent = /*#__PURE__*/function () { 7090 function BaseEvent(options = { 7091 data: {} 7092 }) { 7093 babelHelpers.classCallCheck(this, BaseEvent); 7094 this.type = ''; 7095 this.data = null; 7096 this.target = null; 7097 this.compatData = null; 7098 this.defaultPrevented = false; 7099 this.immediatePropagationStopped = false; 7100 this.errors = []; 7101 this.setData(options.data); 7102 this.setCompatData(options.compatData); 7103 } 7104 babelHelpers.createClass(BaseEvent, [{ 7105 key: "getType", 7106 /** 7107 * Returns the name of the event 7108 * @returns {string} 7109 */ 7110 value: function getType() { 7111 return this.type; 7112 } 7113 /** 7114 * 7115 * @param {string} type 7116 */ 7117 }, { 7118 key: "setType", 7119 value: function setType(type) { 7120 if (Type.isStringFilled(type)) { 7121 this.type = type; 7122 } 7123 return this; 7124 } 7125 /** 7126 * Returns an event data 7127 */ 7128 }, { 7129 key: "getData", 7130 value: function getData() { 7131 return this.data; 7132 } 7133 /** 7134 * Sets an event data 7135 * @param data 7136 */ 7137 }, { 7138 key: "setData", 7139 value: function setData(data) { 7140 if (!Type.isUndefined(data)) { 7141 this.data = data; 7142 } 7143 return this; 7144 } 7145 /** 7146 * Returns arguments for BX.addCustomEvent handlers (deprecated). 7147 * @returns {array | null} 7148 */ 7149 }, { 7150 key: "getCompatData", 7151 value: function getCompatData() { 7152 return this.compatData; 7153 } 7154 /** 7155 * Sets arguments for BX.addCustomEvent handlers (deprecated) 7156 * @param data 7157 */ 7158 }, { 7159 key: "setCompatData", 7160 value: function setCompatData(data) { 7161 if (Type.isArrayLike(data)) { 7162 this.compatData = data; 7163 } 7164 return this; 7165 } 7166 /** 7167 * Sets a event target 7168 * @param target 7169 */ 7170 }, { 7171 key: "setTarget", 7172 value: function setTarget(target) { 7173 this.target = target; 7174 return this; 7175 } 7176 /** 7177 * Returns a event target 7178 */ 7179 }, { 7180 key: "getTarget", 7181 value: function getTarget() { 7182 return this.target; 7183 } 7184 /** 7185 * Returns an array of event errors 7186 * @returns {[]} 7187 */ 7188 }, { 7189 key: "getErrors", 7190 value: function getErrors() { 7191 return this.errors; 7192 } 7193 /** 7194 * Adds an error of the event. 7195 * Event listeners can prevent emitter's default action and set the reason of this behavior. 7196 * @param error 7197 */ 7198 }, { 7199 key: "setError", 7200 value: function setError(error) { 7201 if (BaseError.isError(error)) { 7202 this.errors.push(error); 7203 } 7204 } 7205 /** 7206 * Prevents default action 7207 */ 7208 }, { 7209 key: "preventDefault", 7210 value: function preventDefault() { 7211 this.defaultPrevented = true; 7212 } 7213 /** 7214 * Checks that is default action prevented 7215 * @return {boolean} 7216 */ 7217 }, { 7218 key: "isDefaultPrevented", 7219 value: function isDefaultPrevented() { 7220 return this.defaultPrevented; 7221 } 7222 /** 7223 * Stops event immediate propagation 7224 */ 7225 }, { 7226 key: "stopImmediatePropagation", 7227 value: function stopImmediatePropagation() { 7228 this.immediatePropagationStopped = true; 7229 } 7230 /** 7231 * Checks that is immediate propagation stopped 7232 * @return {boolean} 7233 */ 7234 }, { 7235 key: "isImmediatePropagationStopped", 7236 value: function isImmediatePropagationStopped() { 7237 return this.immediatePropagationStopped; 7238 } 7239 }], [{ 7240 key: "create", 7241 value: function create(options) { 7242 return new this(options); 7243 } 7244 }]); 7245 return BaseEvent; 7246 }(); 7247 7248 let EventStore = /*#__PURE__*/function () { 7249 function EventStore(options = {}) { 7250 babelHelpers.classCallCheck(this, EventStore); 7251 this.defaultMaxListeners = Type.isNumber(options.defaultMaxListeners) ? options.defaultMaxListeners : 10; 7252 this.eventStore = new WeakMap(); 7253 } 7254 babelHelpers.createClass(EventStore, [{ 7255 key: "add", 7256 value: function add(target, options = {}) { 7257 const record = this.getRecordScheme(); 7258 if (Type.isNumber(options.maxListeners)) { 7259 record.maxListeners = options.maxListeners; 7260 } 7261 this.eventStore.set(target, record); 7262 return record; 7263 } 7264 }, { 7265 key: "get", 7266 value: function get(target) { 7267 return this.eventStore.get(target); 7268 } 7269 }, { 7270 key: "getOrAdd", 7271 value: function getOrAdd(target, options = {}) { 7272 return this.get(target) || this.add(target, options); 7273 } 7274 }, { 7275 key: "delete", 7276 value: function _delete(context) { 7277 this.eventStore.delete(context); 7278 } 7279 }, { 7280 key: "getRecordScheme", 7281 value: function getRecordScheme() { 7282 return { 7283 eventsMap: new Map(), 7284 onceMap: new Map(), 7285 maxListeners: this.getDefaultMaxListeners(), 7286 eventsMaxListeners: new Map() 7287 }; 7288 } 7289 }, { 7290 key: "getDefaultMaxListeners", 7291 value: function getDefaultMaxListeners() { 7292 return this.defaultMaxListeners; 7293 } 7294 }]); 7295 return EventStore; 7296 }(); 7297 7298 let WarningStore = /*#__PURE__*/function () {
7299 function WarningStore() { 7300 babelHelpers.classCallCheck(this, WarningStore); 7301 this.warnings = new Map(); 7302 this.printDelayed = Runtime.debounce(this.print.bind(this), 500); 7303 } 7304 babelHelpers.createClass(WarningStore, [{ 7305 key: "add", 7306 value: function add(target, eventName, listeners) { 7307 let contextWarnings = this.warnings.get(target); 7308 if (!contextWarnings) { 7309 contextWarnings = Object.create(null); 7310 this.warnings.set(target, contextWarnings); 7311 } 7312 if (!contextWarnings[eventName]) { 7313 contextWarnings[eventName] = {}; 7314 } 7315 contextWarnings[eventName].size = listeners.size; 7316 if (!Type.isArray(contextWarnings[eventName].errors)) { 7317 contextWarnings[eventName].errors = []; 7318 } 7319 contextWarnings[eventName].errors.push(new Error()); 7320 } 7321 }, { 7322 key: "print", 7323 value: function print() { 7324 this.warnings.forEach(warnings => { 7325 for (let eventName in warnings) { 7326 console.groupCollapsed('Possible BX.Event.EventEmitter memory leak detected. ' + warnings[eventName].size + ' "' + eventName + '" listeners added. ' + 'Use emitter.setMaxListeners() to increase limit.'); 7327 console.dir(warnings[eventName].errors); 7328 console.groupEnd(); 7329 } 7330 }); 7331 this.clear(); 7332 } 7333 }, { 7334 key: "clear", 7335 value: function clear() { 7336 this.warnings.clear(); 7337 } 7338 }, { 7339 key: "printDelayed", 7340 value: function printDelayed() {} 7341 }]); 7342 return WarningStore; 7343 }(); 7344 7345 const eventStore = new EventStore({ 7346 defaultMaxListeners: 10 7347 }); 7348 const warningStore = new WarningStore(); 7349 const aliasStore = new Map(); 7350 const globalTarget = { 7351 GLOBAL_TARGET: 'GLOBAL_TARGET' // this key only for debugging purposes 7352 }; 7353 7354 eventStore.add(globalTarget, { 7355 maxListeners: 25 7356 }); 7357 const isEmitterProperty = Symbol.for('BX.Event.EventEmitter.isEmitter'); 7358 const namespaceProperty = Symbol('namespaceProperty'); 7359 const targetProperty = Symbol('targetProperty'); 7360 let EventEmitter = /*#__PURE__*/function () { 7361 /** @private */ 7362 7363 function EventEmitter(...args) { 7364 babelHelpers.classCallCheck(this, EventEmitter); 7365 this[targetProperty] = null; 7366 this[namespaceProperty] = null; 7367 this[isEmitterProperty] = true; 7368 let target = this; 7369 if (Object.getPrototypeOf(this) === EventEmitter.prototype && args.length > 0) 7370 //new EventEmitter(obj) case 7371 { 7372 if (!Type.isObject(args[0])) { 7373 throw new TypeError(`The "target" argument must be an object.`); 7374 } 7375 target = args[0]; 7376 this.setEventNamespace(args[1]); 7377 } 7378 this[targetProperty] = target; 7379 } 7380 7381 /** 7382 * Makes a target observable 7383 * @param {object} target 7384 * @param {string} namespace 7385 */ 7386 babelHelpers.createClass(EventEmitter, [{ 7387 key: "setEventNamespace", 7388 value: function setEventNamespace(namespace) { 7389 if (Type.isStringFilled(namespace)) { 7390 this[namespaceProperty] = namespace; 7391 } 7392 } 7393 }, { 7394 key: "getEventNamespace", 7395 value: function getEventNamespace() { 7396 return this[namespaceProperty]; 7397 } 7398 /** 7399 * Subscribes listener on specified global event 7400 * @param {object} target 7401 * @param {string} eventName 7402 * @param {Function<BaseEvent>} listener 7403 * @param {object} options 7404 */ 7405 }, { 7406 key: "subscribe", 7407 /** 7408 * Subscribes a listener on a specified event 7409 * @param {string} eventName 7410 * @param {Function<BaseEvent>} listener 7411 * @return {this} 7412 */ 7413 value: function subscribe(eventName, listener) { 7414 EventEmitter.subscribe(this, eventName, listener); 7415 return this; 7416 } 7417 /** 7418 * 7419 * @param {object} options 7420 * @param {object} [aliases] 7421 * @param {boolean} [compatMode=false] 7422 */ 7423 }, { 7424 key: "subscribeFromOptions", 7425 value: function subscribeFromOptions(options, aliases, compatMode) { 7426 if (Type.isArrayFilled(options)) { 7427 options.forEach(events => { 7428 this.subscribeFromOptions(events); 7429 }); 7430 return; 7431 } 7432 if (!Type.isPlainObject(options)) { 7433 return; 7434 } 7435 aliases = Type.isPlainObject(aliases) ? EventEmitter.normalizeAliases(aliases) : {};
7436 Object.keys(options).forEach(eventName => { 7437 const listener = EventEmitter.normalizeListener(options[eventName]); 7438 eventName = EventEmitter.normalizeEventName(eventName); 7439 if (aliases[eventName]) { 7440 const { 7441 eventName: actualName 7442 } = aliases[eventName]; 7443 EventEmitter.subscribe(this, actualName, listener, { 7444 compatMode: compatMode !== false 7445 }); 7446 } else { 7447 EventEmitter.subscribe(this, eventName, listener, { 7448 compatMode: compatMode === true 7449 }); 7450 } 7451 }); 7452 } 7453 /** 7454 * Subscribes a listener that is called at 7455 * most once for a specified event. 7456 * @param {object} target 7457 * @param {string} eventName 7458 * @param {Function<BaseEvent>} listener 7459 */ 7460 }, { 7461 key: "subscribeOnce", 7462 /** 7463 * Subscribes a listener that is called at most once for a specified event. 7464 * @param {string} eventName 7465 * @param {Function<BaseEvent>} listener 7466 * @return {this} 7467 */ 7468 value: function subscribeOnce(eventName, listener) { 7469 EventEmitter.subscribeOnce(this, eventName, listener); 7470 return this; 7471 } 7472 /** 7473 * Unsubscribes an event listener 7474 * @param {object} target 7475 * @param {string} eventName 7476 * @param {Function<BaseEvent>} listener 7477 * @param options 7478 */ 7479 }, { 7480 key: "unsubscribe", 7481 /** 7482 * Unsubscribes an event listener 7483 * @param {string} eventName 7484 * @param {Function<BaseEvent>} listener 7485 * @return {this} 7486 */ 7487 value: function unsubscribe(eventName, listener) { 7488 EventEmitter.unsubscribe(this, eventName, listener); 7489 return this; 7490 } 7491 /** 7492 * Unsubscribes all event listeners 7493 * @param {object} target 7494 * @param {string} eventName 7495 * @param options 7496 */ 7497 }, { 7498 key: "unsubscribeAll", 7499 /** 7500 * Unsubscribes all event listeners 7501 * @param {string} [eventName] 7502 */ 7503 value: function unsubscribeAll(eventName) { 7504 EventEmitter.unsubscribeAll(this, eventName); 7505 } 7506 /** 7507 * 7508 * @param {object} target 7509 * @param {string} eventName 7510 * @param {BaseEvent | any} event 7511 * @param {object} options 7512 * @returns {Array} 7513 */ 7514 }, { 7515 key: "emit", 7516 /** 7517 * Emits specified event with specified event object 7518 * @param {string} eventName 7519 * @param {BaseEvent | any} event 7520 * @return {this} 7521 */ 7522 value: function emit(eventName, event) { 7523 if (this.getEventNamespace() === null) { 7524 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7525 } 7526 EventEmitter.emit(this, eventName, event); 7527 return this; 7528 } 7529 /** 7530 * Emits global event and returns a promise that is resolved when 7531 * all promise returned from event handlers are resolved, 7532 * or rejected when at least one of the returned promise is rejected. 7533 * Importantly. You can return any value from synchronous handlers, not just promise 7534 * @param {object} target 7535 * @param {string} eventName 7536 * @param {BaseEvent | any} event 7537 * @return {Promise<Array>} 7538 */ 7539 }, { 7540 key: "emitAsync", 7541 /** 7542 * Emits event and returns a promise that is resolved when 7543 * all promise returned from event handlers are resolved, 7544 * or rejected when at least one of the returned promise is rejected. 7545 * Importantly. You can return any value from synchronous handlers, not just promise 7546 * @param {string} eventName 7547 * @param {BaseEvent|any} event 7548 * @return {Promise<Array>} 7549 */ 7550 value: function emitAsync(eventName, event) { 7551 if (this.getEventNamespace() === null) { 7552 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7553 } 7554 return EventEmitter.emitAsync(this, eventName, event); 7555 } 7556 /** 7557 * @private 7558 * @param {object} target 7559 * @param {string} eventName 7560 * @param {BaseEvent|any} event 7561 * @returns {BaseEvent} 7562 */ 7563 }, { 7564 key: "setMaxListeners", 7565 /** 7566 * Sets max events listeners count 7567 * this.setMaxListeners(10) - sets the default value for all events
7568 * this.setMaxListeners("onClose", 10) sets the value for onClose event 7569 * @return {this} 7570 * @param args 7571 */ 7572 value: function setMaxListeners(...args) { 7573 EventEmitter.setMaxListeners(this, ...args); 7574 return this; 7575 } 7576 /** 7577 * Returns max event listeners count 7578 * @param {object} target 7579 * @param {string} [eventName] 7580 * @returns {number} 7581 */ 7582 }, { 7583 key: "getMaxListeners", 7584 /** 7585 * Returns max event listeners count 7586 * @param {string} [eventName] 7587 * @returns {number} 7588 */ 7589 value: function getMaxListeners(eventName) { 7590 return EventEmitter.getMaxListeners(this, eventName); 7591 } 7592 /** 7593 * Adds or subtracts max listeners count 7594 * Event.EventEmitter.addMaxListeners() - adds one max listener for all events of global target 7595 * Event.EventEmitter.addMaxListeners(3) - adds three max listeners for all events of global target 7596 * Event.EventEmitter.addMaxListeners(-1) - subtracts one max listener for all events of global target 7597 * Event.EventEmitter.addMaxListeners('onClose') - adds one max listener for onClose event of global target 7598 * Event.EventEmitter.addMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 7599 * Event.EventEmitter.addMaxListeners('onClose', -1) - subtracts one max listener for onClose event of global target 7600 * 7601 * Event.EventEmitter.addMaxListeners(obj) - adds one max listener for all events of 'obj' target 7602 * Event.EventEmitter.addMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 7603 * Event.EventEmitter.addMaxListeners(obj, -1) - subtracts one max listener for all events of 'obj' target 7604 * Event.EventEmitter.addMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 7605 * Event.EventEmitter.addMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 7606 * Event.EventEmitter.addMaxListeners(obj, 'onClose', -1) - subtracts one max listener for onClose event of 'obj' target 7607 * @param args 7608 * @returns {number} 7609 */ 7610 }, { 7611 key: "incrementMaxListeners", 7612 /** 7613 * Increases max listeners count 7614 * this.incrementMaxListeners() - adds one max listener for all events 7615 * this.incrementMaxListeners(3) - adds three max listeners for all events 7616 * this.incrementMaxListeners('onClose') - adds one max listener for onClose event 7617 * this.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event 7618 */ 7619 value: function incrementMaxListeners(...args) { 7620 return EventEmitter.incrementMaxListeners(this, ...args); 7621 } 7622 /** 7623 * Decreases max listeners count 7624 * 7625 * Event.EventEmitter.decrementMaxListeners() - subtracts one max listener for all events of global target 7626 * Event.EventEmitter.decrementMaxListeners(3) - subtracts three max listeners for all events of global target 7627 * Event.EventEmitter.decrementMaxListeners('onClose') - subtracts one max listener for onClose event of global target 7628 * Event.EventEmitter.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event of global target 7629 * 7630 * Event.EventEmitter.decrementMaxListeners(obj) - subtracts one max listener for all events of 'obj' target 7631 * Event.EventEmitter.decrementMaxListeners(obj, 3) - subtracts three max listeners for all events of 'obj' target 7632 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose') - subtracts one max listener for onClose event of 'obj' target 7633 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose', 2) - subtracts two max listeners for onClose event of 'obj' target 7634 */ 7635 }, { 7636 key: "decrementMaxListeners", 7637 /** 7638 * Increases max listeners count 7639 * this.decrementMaxListeners() - subtracts one max listener for all events 7640 * this.decrementMaxListeners(3) - subtracts three max listeners for all events 7641 * this.decrementMaxListeners('onClose') - subtracts one max listener for onClose event 7642 * this.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event 7643 */ 7644 value: function decrementMaxListeners(...args) { 7645 return EventEmitter.decrementMaxListeners(this, ...args); 7646 } 7647 /** 7648 * @private 7649 * @param {Array} args 7650 * @returns Array 7651 */ 7652 }, { 7653 key: "getListeners", 7654 /** 7655 * Gets listeners list for specified event 7656 * @param {string} eventName 7657 */ 7658 value: function getListeners(eventName) { 7659 return EventEmitter.getListeners(this, eventName); 7660 } 7661 /** 7662 * Returns a full event name with namespace 7663 * @param {string} eventName 7664 * @returns {string} 7665 */ 7666 }, { 7667 key: "getFullEventName", 7668 value: function getFullEventName(eventName) { 7669 if (!Type.isStringFilled(eventName)) { 7670 throw new TypeError(`The "eventName" argument must be a string.`); 7671 } 7672 return EventEmitter.makeFullEventName(this.getEventNamespace(), eventName); 7673 } 7674 /** 7675 * Registers aliases (old event names for BX.onCustomEvent) 7676 * @param aliases 7677 */ 7678 }], [{ 7679 key: "makeObservable", 7680 value: function makeObservable(target, namespace) { 7681 if (!Type.isObject(target)) { 7682 throw new TypeError('The "target" argument must be an object.'); 7683 } 7684 if (!Type.isStringFilled(namespace)) { 7685 throw new TypeError('The "namespace" must be an non-empty string.'); 7686 } 7687 if (EventEmitter.isEventEmitter(target)) { 7688 throw new TypeError('The "target" is an event emitter already.'); 7689 } 7690 const targetProto = Object.getPrototypeOf(target); 7691 const emitter = new EventEmitter(); 7692 emitter.setEventNamespace(namespace); 7693 Object.setPrototypeOf(emitter, targetProto); 7694 Object.setPrototypeOf(target, emitter); 7695 Object.getOwnPropertyNames(EventEmitter.prototype).forEach(method => {
7696 if (['constructor'].includes(method)) { 7697 return; 7698 } 7699 emitter[method] = function (...args) { 7700 return EventEmitter.prototype[method].apply(target, args); 7701 }; 7702 }); 7703 } 7704 }, { 7705 key: "subscribe", 7706 value: function subscribe(target, eventName, listener, options) { 7707 if (Type.isString(target)) { 7708 options = listener; 7709 listener = eventName; 7710 eventName = target; 7711 target = this.GLOBAL_TARGET; 7712 } 7713 if (!Type.isObject(target)) { 7714 throw new TypeError(`The "target" argument must be an object.`); 7715 } 7716 eventName = this.normalizeEventName(eventName); 7717 if (!Type.isStringFilled(eventName)) { 7718 throw new TypeError(`The "eventName" argument must be a string.`); 7719 } 7720 listener = this.normalizeListener(listener); 7721 options = Type.isPlainObject(options) ? options : {}; 7722 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7723 const { 7724 eventsMap, 7725 onceMap 7726 } = eventStore.getOrAdd(target); 7727 const onceListeners = onceMap.get(fullEventName); 7728 let listeners = eventsMap.get(fullEventName); 7729 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7730 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7731 } else { 7732 if (listeners) { 7733 listeners.set(listener, { 7734 listener, 7735 options, 7736 sort: this.getNextSequenceValue() 7737 }); 7738 } else { 7739 listeners = new Map([[listener, { 7740 listener, 7741 options, 7742 sort: this.getNextSequenceValue() 7743 }]]); 7744 eventsMap.set(fullEventName, listeners); 7745 } 7746 } 7747 const maxListeners = this.getMaxListeners(target, eventName); 7748 if (listeners.size > maxListeners) { 7749 warningStore.add(target, fullEventName, listeners); 7750 warningStore.printDelayed(); 7751 } 7752 } 7753 }, { 7754 key: "subscribeOnce", 7755 value: function subscribeOnce(target, eventName, listener) { 7756 if (Type.isString(target)) { 7757 listener = eventName; 7758 eventName = target; 7759 target = this.GLOBAL_TARGET;
7760 } 7761 if (!Type.isObject(target)) { 7762 throw new TypeError(`The "target" argument must be an object.`); 7763 } 7764 eventName = this.normalizeEventName(eventName); 7765 if (!Type.isStringFilled(eventName)) { 7766 throw new TypeError(`The "eventName" argument must be a string.`); 7767 } 7768 listener = this.normalizeListener(listener); 7769 const fullEventName = this.resolveEventName(eventName, target); 7770 const { 7771 eventsMap, 7772 onceMap 7773 } = eventStore.getOrAdd(target); 7774 const listeners = eventsMap.get(fullEventName); 7775 let onceListeners = onceMap.get(fullEventName); 7776 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7777 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7778 } else { 7779 const once = (...args) => { 7780 this.unsubscribe(target, eventName, once); 7781 onceListeners.delete(listener); 7782 listener(...args); 7783 }; 7784 if (onceListeners) { 7785 onceListeners.set(listener, once); 7786 } else { 7787 onceListeners = new Map([[listener, once]]); 7788 onceMap.set(fullEventName, onceListeners); 7789 } 7790 this.subscribe(target, eventName, once); 7791 } 7792 } 7793 }, { 7794 key: "unsubscribe", 7795 value: function unsubscribe(target, eventName, listener, options) { 7796 if (Type.isString(target)) { 7797 listener = eventName; 7798 eventName = target; 7799 target = this.GLOBAL_TARGET;
7800 } 7801 eventName = this.normalizeEventName(eventName); 7802 if (!Type.isStringFilled(eventName)) { 7803 throw new TypeError(`The "eventName" argument must be a string.`); 7804 } 7805 listener = this.normalizeListener(listener); 7806 options = Type.isPlainObject(options) ? options : {}; 7807 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7808 const targetInfo = eventStore.get(target); 7809 const listeners = targetInfo && targetInfo.eventsMap.get(fullEventName); 7810 const onceListeners = targetInfo && targetInfo.onceMap.get(fullEventName); 7811 if (listeners) { 7812 listeners.delete(listener); 7813 } 7814 if (onceListeners) { 7815 const once = onceListeners.get(listener); 7816 if (once) { 7817 onceListeners.delete(listener); 7818 listeners.delete(once); 7819 } 7820 } 7821 } 7822 }, { 7823 key: "unsubscribeAll", 7824 value: function unsubscribeAll(target, eventName, options) { 7825 if (Type.isString(target)) { 7826 eventName = target; 7827 target = this.GLOBAL_TARGET;
7828 } 7829 if (Type.isStringFilled(eventName)) { 7830 const targetInfo = eventStore.get(target); 7831 if (targetInfo) { 7832 options = Type.isPlainObject(options) ? options : {}; 7833 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7834 targetInfo.eventsMap.delete(fullEventName); 7835 targetInfo.onceMap.delete(fullEventName); 7836 } 7837 } else if (Type.isNil(eventName)) { 7838 if (target === this.GLOBAL_TARGET) { 7839 console.error('You cannot unsubscribe all global listeners.'); 7840 } else { 7841 eventStore.delete(target); 7842 } 7843 } 7844 } 7845 }, { 7846 key: "emit", 7847 value: function emit(target, eventName, event, options) { 7848 if (Type.isString(target)) { 7849 options = event; 7850 event = eventName; 7851 eventName = target; 7852 target = this.GLOBAL_TARGET; 7853 } 7854 if (!Type.isObject(target)) { 7855 throw new TypeError(`The "target" argument must be an object.`); 7856 } 7857 eventName = this.normalizeEventName(eventName); 7858 if (!Type.isStringFilled(eventName)) { 7859 throw new TypeError(`The "eventName" argument must be a string.`); 7860 } 7861 options = Type.isPlainObject(options) ? options : {}; 7862 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7863 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 7864 const globalListeners = globalEvents && globalEvents.eventsMap.get(fullEventName) || new Map(); 7865 let targetListeners = new Set(); 7866 if (target !== this.GLOBAL_TARGET) { 7867 const targetEvents = eventStore.get(target); 7868 targetListeners = targetEvents && targetEvents.eventsMap.get(fullEventName) || new Map(); 7869 } 7870 const listeners = [...globalListeners.values(), ...targetListeners.values()]; 7871 listeners.sort(function (a, b) { 7872 return a.sort - b.sort; 7873 }); 7874 const preparedEvent = this.prepareEvent(target, fullEventName, event); 7875 const result = []; 7876 for (let i = 0; i < listeners.length; i++) { 7877 if (preparedEvent.isImmediatePropagationStopped()) { 7878 break; 7879 } 7880 const { 7881 listener, 7882 options: listenerOptions 7883 } = listeners[i]; 7884 7885 //A previous listener could remove a current listener. 7886 if (globalListeners.has(listener) || targetListeners.has(listener)) { 7887 let listenerResult; 7888 if (listenerOptions.compatMode) { 7889 let params = []; 7890 const compatData = preparedEvent.getCompatData(); 7891 if (compatData !== null) { 7892 params = options.cloneData === true ? Runtime.clone(compatData) : compatData; 7893 } else { 7894 params = [preparedEvent]; 7895 } 7896 const context = Type.isUndefined(options.thisArg) ? target : options.thisArg; 7897 listenerResult = listener.apply(context, params); 7898 } else { 7899 listenerResult = Type.isUndefined(options.thisArg) ? listener(preparedEvent) : listener.call(options.thisArg, preparedEvent); 7900 } 7901 result.push(listenerResult); 7902 } 7903 } 7904 return result; 7905 } 7906 }, { 7907 key: "emitAsync", 7908 value: function emitAsync(target, eventName, event) { 7909 if (Type.isString(target)) { 7910 event = eventName; 7911 eventName = target; 7912 target = this.GLOBAL_TARGET;
7913 } 7914 return Promise.all(this.emit(target, eventName, event)); 7915 } 7916 }, { 7917 key: "prepareEvent", 7918 value: function prepareEvent(target, eventName, event) { 7919 let preparedEvent = event; 7920 if (!(event instanceof BaseEvent)) { 7921 preparedEvent = new BaseEvent(); 7922 preparedEvent.setData(event); 7923 } 7924 preparedEvent.setTarget(this.isEventEmitter(target) ? target[targetProperty] : target); 7925 preparedEvent.setType(eventName); 7926 return preparedEvent; 7927 } 7928 /** 7929 * @private 7930 * @returns {number} 7931 */ 7932 }, { 7933 key: "getNextSequenceValue", 7934 value: function getNextSequenceValue() { 7935 return this.sequenceValue++; 7936 } 7937 /** 7938 * Sets max global events listeners count 7939 * Event.EventEmitter.setMaxListeners(10) - sets the default value for all events (global target) 7940 * Event.EventEmitter.setMaxListeners("onClose", 10) - sets the value for onClose event (global target) 7941 * Event.EventEmitter.setMaxListeners(obj, 10) - sets the default value for all events (obj target) 7942 * Event.EventEmitter.setMaxListeners(obj, "onClose", 10); - sets the value for onClose event (obj target) 7943 * @return {void} 7944 * @param args 7945 */ 7946 }, { 7947 key: "setMaxListeners", 7948 value: function setMaxListeners(...args) { 7949 let target = this.GLOBAL_TARGET;
7950 let eventName = null; 7951 let count = undefined; 7952 if (args.length === 1) { 7953 count = args[0]; 7954 } else if (args.length === 2) { 7955 if (Type.isString(args[0])) { 7956 [eventName, count] = args; 7957 } else { 7958 [target, count] = args; 7959 } 7960 } else if (args.length >= 3) { 7961 [target, eventName, count] = args; 7962 } 7963 if (!Type.isObject(target)) { 7964 throw new TypeError(`The "target" argument must be an object.`); 7965 } 7966 if (eventName !== null && !Type.isStringFilled(eventName)) { 7967 throw new TypeError(`The "eventName" argument must be a string.`); 7968 } 7969 if (!Type.isNumber(count) || count < 0) { 7970 throw new TypeError(`The value of "count" is out of range. It must be a non-negative number. Received ${count}.`); 7971 } 7972 const targetInfo = eventStore.getOrAdd(target); 7973 if (Type.isStringFilled(eventName)) { 7974 const fullEventName = this.resolveEventName(eventName, target); 7975 targetInfo.eventsMaxListeners.set(fullEventName, count); 7976 } else { 7977 targetInfo.maxListeners = count; 7978 } 7979 } 7980 }, { 7981 key: "getMaxListeners", 7982 value: function getMaxListeners(target, eventName) { 7983 if (Type.isString(target)) { 7984 eventName = target; 7985 target = this.GLOBAL_TARGET;
7986 } else if (Type.isNil(target)) { 7987 target = this.GLOBAL_TARGET; 7988 } 7989 if (!Type.isObject(target)) { 7990 throw new TypeError(`The "target" argument must be an object.`); 7991 } 7992 const targetInfo = eventStore.get(target); 7993 if (targetInfo) { 7994 let maxListeners = targetInfo.maxListeners; 7995 if (Type.isStringFilled(eventName)) { 7996 const fullEventName = this.resolveEventName(eventName, target); 7997 maxListeners = targetInfo.eventsMaxListeners.get(fullEventName) || maxListeners; 7998 } 7999 return maxListeners; 8000 } 8001 return this.DEFAULT_MAX_LISTENERS; 8002 } 8003 }, { 8004 key: "addMaxListeners", 8005 value: function addMaxListeners(...args) { 8006 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 8007 const maxListeners = Math.max(this.getMaxListeners(target, eventName) + increment, 0); 8008 if (Type.isStringFilled(eventName)) { 8009 EventEmitter.setMaxListeners(target, eventName, maxListeners); 8010 } else { 8011 EventEmitter.setMaxListeners(target, maxListeners); 8012 } 8013 return maxListeners; 8014 } 8015 /** 8016 * Increases max listeners count 8017 * 8018 * Event.EventEmitter.incrementMaxListeners() - adds one max listener for all events of global target 8019 * Event.EventEmitter.incrementMaxListeners(3) - adds three max listeners for all events of global target 8020 * Event.EventEmitter.incrementMaxListeners('onClose') - adds one max listener for onClose event of global target 8021 * Event.EventEmitter.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 8022 * 8023 * Event.EventEmitter.incrementMaxListeners(obj) - adds one max listener for all events of 'obj' target 8024 * Event.EventEmitter.incrementMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 8025 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 8026 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 8027 */ 8028 }, { 8029 key: "incrementMaxListeners", 8030 value: function incrementMaxListeners(...args) { 8031 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 8032 return this.addMaxListeners(target, eventName, Math.abs(increment)); 8033 } 8034 }, { 8035 key: "decrementMaxListeners", 8036 value: function decrementMaxListeners(...args) { 8037 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 8038 return this.addMaxListeners(target, eventName, -Math.abs(increment)); 8039 } 8040 }, { 8041 key: "destructMaxListenersArgs", 8042 value: function destructMaxListenersArgs(...args) { 8043 let eventName = null; 8044 let increment = 1; 8045 let target = this.GLOBAL_TARGET;
8046 if (args.length === 1) { 8047 if (Type.isNumber(args[0])) { 8048 increment = args[0]; 8049 } else if (Type.isString(args[0])) { 8050 eventName = args[0]; 8051 } else { 8052 target = args[0]; 8053 } 8054 } else if (args.length === 2) { 8055 if (Type.isString(args[0])) { 8056 [eventName, increment] = args; 8057 } else if (Type.isString(args[1])) { 8058 [target, eventName] = args; 8059 } else { 8060 [target, increment] = args; 8061 } 8062 } else if (args.length >= 3) { 8063 [target, eventName, increment] = args; 8064 } 8065 if (!Type.isObject(target)) { 8066 throw new TypeError(`The "target" argument must be an object.`); 8067 } 8068 if (eventName !== null && !Type.isStringFilled(eventName)) { 8069 throw new TypeError(`The "eventName" argument must be a string.`); 8070 } 8071 if (!Type.isNumber(increment)) { 8072 throw new TypeError(`The value of "increment" must be a number.`); 8073 } 8074 return [target, eventName, increment]; 8075 } 8076 /** 8077 * Gets listeners list for a specified event 8078 * @param {object} target 8079 * @param {string} eventName 8080 */ 8081 }, { 8082 key: "getListeners", 8083 value: function getListeners(target, eventName) { 8084 if (Type.isString(target)) { 8085 eventName = target; 8086 target = this.GLOBAL_TARGET;
8087 } 8088 if (!Type.isObject(target)) { 8089 throw new TypeError(`The "target" argument must be an object.`); 8090 } 8091 eventName = this.normalizeEventName(eventName); 8092 if (!Type.isStringFilled(eventName)) { 8093 throw new TypeError(`The "eventName" argument must be a string.`); 8094 } 8095 const targetInfo = eventStore.get(target); 8096 if (!targetInfo) { 8097 return new Map(); 8098 } 8099 const fullEventName = this.resolveEventName(eventName, target); 8100 return targetInfo.eventsMap.get(fullEventName) || new Map(); 8101 } 8102 }, { 8103 key: "registerAliases", 8104 value: function registerAliases(aliases) { 8105 aliases = this.normalizeAliases(aliases); 8106 Object.keys(aliases).forEach(alias => { 8107 aliasStore.set(alias, { 8108 eventName: aliases[alias].eventName, 8109 namespace: aliases[alias].namespace 8110 }); 8111 }); 8112 EventEmitter.mergeEventAliases(aliases); 8113 } 8114 /** 8115 * @private 8116 * @param aliases 8117 */ 8118 }, { 8119 key: "normalizeAliases", 8120 value: function normalizeAliases(aliases) { 8121 if (!Type.isPlainObject(aliases)) { 8122 throw new TypeError(`The "aliases" argument must be an object.`); 8123 } 8124 const result = Object.create(null); 8125 for (let alias in aliases) { 8126 if (!Type.isStringFilled(alias)) { 8127 throw new TypeError(`The alias must be an non-empty string.`); 8128 } 8129 const options = aliases[alias]; 8130 if (!options || !Type.isStringFilled(options.eventName) || !Type.isStringFilled(options.namespace)) { 8131 throw new TypeError(`The alias options must set the "eventName" and the "namespace".`); 8132 } 8133 alias = this.normalizeEventName(alias); 8134 result[alias] = { 8135 eventName: options.eventName, 8136 namespace: options.namespace 8137 }; 8138 } 8139 return result; 8140 } 8141 /** 8142 * @private 8143 */ 8144 }, { 8145 key: "mergeEventAliases", 8146 value: function mergeEventAliases(aliases) { 8147 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 8148 if (!globalEvents) { 8149 return; 8150 } 8151 Object.keys(aliases).forEach(alias => { 8152 const options = aliases[alias]; 8153 alias = this.normalizeEventName(alias); 8154 const fullEventName = this.makeFullEventName(options.namespace, options.eventName); 8155 const aliasListeners = globalEvents.eventsMap.get(alias); 8156 if (aliasListeners) { 8157 const listeners = globalEvents.eventsMap.get(fullEventName) || new Map(); 8158 globalEvents.eventsMap.set(fullEventName, new Map([...listeners, ...aliasListeners])); 8159 globalEvents.eventsMap.delete(alias); 8160 } 8161 const aliasOnceListeners = globalEvents.onceMap.get(alias); 8162 if (aliasOnceListeners) { 8163 const onceListeners = globalEvents.onceMap.get(fullEventName) || new Map(); 8164 globalEvents.onceMap.set(fullEventName, new Map([...onceListeners, ...aliasOnceListeners])); 8165 globalEvents.onceMap.delete(alias); 8166 } 8167 const aliasMaxListeners = globalEvents.eventsMaxListeners.get(alias); 8168 if (aliasMaxListeners) { 8169 const eventMaxListeners = globalEvents.eventsMaxListeners.get(fullEventName) || 0; 8170 globalEvents.eventsMaxListeners.set(fullEventName, Math.max(eventMaxListeners, aliasMaxListeners)); 8171 globalEvents.eventsMaxListeners.delete(alias); 8172 } 8173 }); 8174 } 8175 /** 8176 * Returns true if the target is an instance of Event.EventEmitter 8177 * @param {object} target 8178 * @returns {boolean} 8179 */ 8180 }, { 8181 key: "isEventEmitter", 8182 value: function isEventEmitter(target) { 8183 return Type.isObject(target) && target[isEmitterProperty] === true; 8184 } 8185 /** 8186 * @private 8187 * @param {string} eventName 8188 * @returns {string} 8189 */ 8190 }, { 8191 key: "normalizeEventName", 8192 value: function normalizeEventName(eventName) { 8193 if (!Type.isStringFilled(eventName)) { 8194 return ''; 8195 } 8196 return eventName.toLowerCase(); 8197 } 8198 /** 8199 * @private 8200 */ 8201 }, { 8202 key: "normalizeListener", 8203 value: function normalizeListener(listener) { 8204 if (Type.isString(listener)) { 8205 listener = Reflection.getClass(listener); 8206 } 8207 if (!Type.isFunction(listener)) { 8208 throw new TypeError(`The "listener" argument must be of type Function. Received type ${typeof listener}.`); 8209 } 8210 return listener; 8211 } 8212 /** 8213 * @private 8214 * @param eventName 8215 * @param target 8216 * @param useGlobalNaming 8217 * @returns {string} 8218 */ 8219 }, { 8220 key: "resolveEventName", 8221 value: function resolveEventName(eventName, target, useGlobalNaming = false) { 8222 eventName = this.normalizeEventName(eventName); 8223 if (!Type.isStringFilled(eventName)) { 8224 return ''; 8225 } 8226 if (this.isEventEmitter(target) && useGlobalNaming !== true) { 8227 if (target.getEventNamespace() !== null && eventName.includes('.')) { 8228 console.warn(`Possible the wrong event name "${eventName}".`); 8229 } 8230 eventName = target.getFullEventName(eventName); 8231 } else if (aliasStore.has(eventName)) { 8232 const { 8233 namespace, 8234 eventName: actualEventName 8235 } = aliasStore.get(eventName); 8236 eventName = this.makeFullEventName(namespace, actualEventName); 8237 } 8238 return eventName; 8239 } 8240 /** 8241 * @private 8242 * @param {string} namespace 8243 * @param {string} eventName 8244 * @returns {string} 8245 */ 8246 }, { 8247 key: "makeFullEventName", 8248 value: function makeFullEventName(namespace, eventName) { 8249 const fullName = Type.isStringFilled(namespace) ? `${namespace}:${eventName}` : eventName; 8250 return Type.isStringFilled(fullName) ? fullName.toLowerCase() : ''; 8251 } 8252 }]); 8253 return EventEmitter; 8254 }(); 8255 babelHelpers.defineProperty(EventEmitter, "GLOBAL_TARGET", globalTarget); 8256 babelHelpers.defineProperty(EventEmitter, "DEFAULT_MAX_LISTENERS", eventStore.getDefaultMaxListeners()); 8257 babelHelpers.defineProperty(EventEmitter, "sequenceValue", 1); 8258 8259 let stack = []; 8260 /** 8261 * For compatibility only 8262 * @type {boolean} 8263 */ 8264 // eslint-disable-next-line 8265 exports.isReady = false;
8266 function ready(handler) { 8267 if (!Type.isFunction(handler)) { 8268 return; 8269 } 8270 if (exports.isReady) { 8271 handler(); 8272 } else { 8273 stack.push(handler); 8274 } 8275 } 8276 bindOnce(document, 'DOMContentLoaded', () => { 8277 exports.isReady = true; 8278 stack.forEach(handler => { 8279 handler(); 8280 }); 8281 stack = []; 8282 }); 8283 8284 /** 8285 * @memberOf BX 8286 */ 8287 let Event = function Event() { 8288 babelHelpers.classCallCheck(this, Event); 8289 }; 8290 babelHelpers.defineProperty(Event, "bind", bind); 8291 babelHelpers.defineProperty(Event, "bindOnce", bindOnce); 8292 babelHelpers.defineProperty(Event, "unbind", unbind); 8293 babelHelpers.defineProperty(Event, "unbindAll", unbindAll); 8294 babelHelpers.defineProperty(Event, "ready", ready); 8295 babelHelpers.defineProperty(Event, "EventEmitter", EventEmitter); 8296 babelHelpers.defineProperty(Event, "BaseEvent", BaseEvent); 8297 8298 function encodeAttributeValue(value) { 8299 if (Type.isPlainObject(value) || Type.isArray(value)) { 8300 return JSON.stringify(value); 8301 } 8302 return Text.encode(Text.decode(value)); 8303 } 8304 8305 function decodeAttributeValue(value) { 8306 if (Type.isString(value)) { 8307 const decodedValue = Text.decode(value); 8308 let result; 8309 try { 8310 result = JSON.parse(decodedValue); 8311 } catch (e) { 8312 result = decodedValue; 8313 } 8314 if (result === decodedValue) { 8315 if (/^[\d.]+[.]?\d+$/.test(result)) { 8316 return Number(result); 8317 } 8318 } 8319 if (result === 'true' || result === 'false') { 8320 return Boolean(result); 8321 } 8322 return result; 8323 } 8324 return value; 8325 } 8326 8327 function getPageScroll() { 8328 const { 8329 documentElement, 8330 body 8331 } = document; 8332 const scrollTop = Math.max(window.pageYOffset || 0, documentElement ? documentElement.scrollTop : 0, body ? body.scrollTop : 0); 8333 const scrollLeft = Math.max(window.pageXOffset || 0, documentElement ? documentElement.scrollLeft : 0, body ? body.scrollLeft : 0); 8334 return { 8335 scrollTop, 8336 scrollLeft 8337 }; 8338 } 8339 8340 /** 8341 * @memberOf BX 8342 */ 8343 let Dom = /*#__PURE__*/function () { 8344 function Dom() { 8345 babelHelpers.classCallCheck(this, Dom); 8346 } 8347 babelHelpers.createClass(Dom, null, [{ 8348 key: "replace", 8349 /** 8350 * Replaces old html element to new html element 8351 * @param oldElement 8352 * @param newElement 8353 */ 8354 value: function replace(oldElement, newElement) { 8355 if (Type.isDomNode(oldElement) && Type.isDomNode(newElement)) { 8356 if (Type.isDomNode(oldElement.parentNode)) { 8357 oldElement.parentNode.replaceChild(newElement, oldElement); 8358 } 8359 } 8360 } 8361 /** 8362 * Removes element 8363 * @param element 8364 */ 8365 }, { 8366 key: "remove", 8367 value: function remove(element) { 8368 if (Type.isDomNode(element) && Type.isDomNode(element.parentNode)) { 8369 element.parentNode.removeChild(element); 8370 } 8371 } 8372 /** 8373 * Cleans element 8374 * @param element 8375 */ 8376 }, { 8377 key: "clean", 8378 value: function clean(element) { 8379 if (Type.isDomNode(element)) { 8380 while (element.childNodes.length > 0) { 8381 element.removeChild(element.firstChild); 8382 } 8383 return; 8384 } 8385 if (Type.isString(element)) { 8386 Dom.clean(document.getElementById(element)); 8387 } 8388 } 8389 /** 8390 * Inserts element before target element 8391 * @param current 8392 * @param target 8393 */ 8394 }, { 8395 key: "insertBefore", 8396 value: function insertBefore(current, target) { 8397 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8398 if (Type.isDomNode(target.parentNode)) { 8399 target.parentNode.insertBefore(current, target); 8400 } 8401 } 8402 } 8403 /** 8404 * Inserts element after target element 8405 * @param current 8406 * @param target 8407 */ 8408 }, { 8409 key: "insertAfter", 8410 value: function insertAfter(current, target) { 8411 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8412 if (Type.isDomNode(target.parentNode)) { 8413 const parent = target.parentNode; 8414 if (Type.isDomNode(target.nextSibling)) { 8415 parent.insertBefore(current, target.nextSibling); 8416 return; 8417 } 8418 parent.appendChild(current); 8419 } 8420 } 8421 } 8422 /** 8423 * Appends element to target element 8424 * @param current 8425 * @param target 8426 */ 8427 }, { 8428 key: "append", 8429 value: function append(current, target) { 8430 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8431 target.appendChild(current); 8432 } 8433 } 8434 /** 8435 * Prepends element to target element 8436 * @param current 8437 * @param target 8438 */ 8439 }, {
8440 key: "prepend", 8441 value: function prepend(current, target) { 8442 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8443 if (Type.isDomNode(target.firstChild)) { 8444 target.insertBefore(current, target.firstChild); 8445 return; 8446 } 8447 Dom.append(current, target); 8448 } 8449 } 8450 /** 8451 * Checks that element contains class name or class names 8452 * @param element 8453 * @param className 8454 * @return {Boolean} 8455 */ 8456 }, { 8457 key: "hasClass", 8458 value: function hasClass(element, className) { 8459 if (Type.isElementNode(element)) { 8460 if (Type.isString(className)) { 8461 const preparedClassName = className.trim(); 8462 if (preparedClassName.length > 0) { 8463 if (preparedClassName.includes(' ')) { 8464 return preparedClassName.split(' ').every(name => Dom.hasClass(element, name)); 8465 } 8466 if ('classList' in element) { 8467 return element.classList.contains(preparedClassName); 8468 } 8469 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8470 return element.getAttribute('class').split(' ').some(name => name === preparedClassName); 8471 } 8472 } 8473 } 8474 if (Type.isArray(className) && className.length > 0) { 8475 return className.every(name => Dom.hasClass(element, name)); 8476 } 8477 } 8478 return false; 8479 } 8480 /** 8481 * Adds class name 8482 * @param element 8483 * @param className 8484 */ 8485 }, { 8486 key: "addClass", 8487 value: function addClass(element, className) { 8488 if (Type.isElementNode(element)) { 8489 if (Type.isString(className)) { 8490 const preparedClassName = className.trim(); 8491 if (preparedClassName.length > 0) { 8492 if (preparedClassName.includes(' ')) { 8493 Dom.addClass(element, preparedClassName.split(' ')); 8494 return; 8495 } 8496 if ('classList' in element) { 8497 element.classList.add(preparedClassName); 8498 return; 8499 } 8500 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8501 if (element.className.baseVal === '') { 8502 element.className.baseVal = preparedClassName; 8503 return; 8504 } 8505 const names = element.className.baseVal.split(' '); 8506 if (!names.includes(preparedClassName)) { 8507 names.push(preparedClassName); 8508 element.className.baseVal = names.join(' ').trim(); 8509 return; 8510 } 8511 } 8512 return; 8513 } 8514 } 8515 if (Type.isArray(className)) { 8516 className.forEach(name => Dom.addClass(element, name)); 8517 } 8518 } 8519 } 8520 /** 8521 * Removes class name 8522 * @param element 8523 * @param className 8524 */ 8525 }, { 8526 key: "removeClass", 8527 value: function removeClass(element, className) { 8528 if (Type.isElementNode(element)) { 8529 if (Type.isString(className)) { 8530 const preparedClassName = className.trim(); 8531 if (preparedClassName.length > 0) { 8532 if (preparedClassName.includes(' ')) { 8533 Dom.removeClass(element, preparedClassName.split(' ')); 8534 return; 8535 } 8536 if ('classList' in element) { 8537 element.classList.remove(preparedClassName); 8538 return; 8539 } 8540 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8541 const names = element.className.baseVal.split(' ').filter(name => name !== preparedClassName); 8542 element.className.baseVal = names.join(' '); 8543 return; 8544 } 8545 } 8546 } 8547 if (Type.isArray(className)) { 8548 className.forEach(name => Dom.removeClass(element, name)); 8549 } 8550 } 8551 } 8552 /** 8553 * Toggles class name 8554 * @param element 8555 * @param className 8556 */ 8557 }, { 8558 key: "toggleClass", 8559 value: function toggleClass(element, className) { 8560 if (Type.isElementNode(element)) { 8561 if (Type.isString(className)) { 8562 const preparedClassName = className.trim(); 8563 if (preparedClassName.length > 0) { 8564 if (preparedClassName.includes(' ')) { 8565 Dom.toggleClass(element, preparedClassName.split(' ')); 8566 return; 8567 } 8568 element.classList.toggle(preparedClassName); 8569 return; 8570 } 8571 } 8572 if (Type.isArray(className)) { 8573 className.forEach(name => Dom.toggleClass(element, name)); 8574 } 8575 } 8576 } 8577 /** 8578 * Styles element 8579 */ 8580 }, { 8581 key: "style", 8582 value: function style(element, prop, value) { 8583 if (Type.isElementNode(element)) { 8584 if (Type.isNull(prop)) { 8585 element.removeAttribute('style'); 8586 return element; 8587 } 8588 if (Type.isPlainObject(prop)) {
8589 Object.entries(prop).forEach(item => { 8590 const [currentKey, currentValue] = item; 8591 Dom.style(element, currentKey, currentValue); 8592 }); 8593 return element; 8594 } 8595 if (Type.isString(prop)) { 8596 if (Type.isUndefined(value) && element.nodeType !== Node.DOCUMENT_NODE) { 8597 const computedStyle = getComputedStyle(element); 8598 if (prop in computedStyle) { 8599 return computedStyle[prop]; 8600 } 8601 return computedStyle.getPropertyValue(prop); 8602 } 8603 if (Type.isNull(value) || value === '' || value === 'null') { 8604 if (String(prop).startsWith('--')) { 8605 // eslint-disable-next-line 8606 element.style.removeProperty(prop); 8607 return element; 8608 } 8609 8610 // eslint-disable-next-line 8611 element.style[prop] = ''; 8612 return element; 8613 } 8614 if (Type.isString(value) || Type.isNumber(value)) { 8615 if (String(prop).startsWith('--')) { 8616 // eslint-disable-next-line 8617 element.style.setProperty(prop, value); 8618 return element; 8619 } 8620 8621 // eslint-disable-next-line 8622 element.style[prop] = value; 8623 return element; 8624 } 8625 } 8626 } 8627 return null; 8628 } 8629 /** 8630 * Adjusts element 8631 * @param target 8632 * @param data 8633 * @return {*} 8634 */ 8635 }, { 8636 key: "adjust", 8637 value: function adjust(target, data = {}) { 8638 if (!target.nodeType) { 8639 return null; 8640 } 8641 let element = target; 8642 if (target.nodeType === Node.DOCUMENT_NODE) { 8643 element = target.body; 8644 } 8645 if (Type.isPlainObject(data)) { 8646 if (Type.isPlainObject(data.attrs)) { 8647 Object.keys(data.attrs).forEach(key => { 8648 if (key === 'class' || key.toLowerCase() === 'classname') { 8649 element.className = data.attrs[key]; 8650 return; 8651 } 8652 8653 // eslint-disable-next-line 8654 if (data.attrs[key] == '') { 8655 element.removeAttribute(key); 8656 return; 8657 } 8658 element.setAttribute(key, data.attrs[key]); 8659 }); 8660 } 8661 if (Type.isPlainObject(data.style)) { 8662 Dom.style(element, data.style); 8663 } 8664 if (Type.isPlainObject(data.props)) { 8665 Object.keys(data.props).forEach(key => { 8666 element[key] = data.props[key]; 8667 }); 8668 } 8669 if (Type.isPlainObject(data.events)) { 8670 Object.keys(data.events).forEach(key => { 8671 Event.bind(element, key, data.events[key]); 8672 }); 8673 } 8674 if (Type.isPlainObject(data.dataset)) { 8675 Object.keys(data.dataset).forEach(key => { 8676 element.dataset[key] = data.dataset[key]; 8677 }); 8678 } 8679 if (Type.isString(data.children)) { 8680 data.children = [data.children]; 8681 } 8682 if (Type.isArray(data.children) && data.children.length > 0) { 8683 data.children.forEach(item => { 8684 if (Type.isDomNode(item)) { 8685 Dom.append(item, element); 8686 } 8687 if (Type.isString(item)) { 8688 element.insertAdjacentHTML('beforeend', item); 8689 } 8690 }); 8691 return element; 8692 } 8693 if ('text' in data && !Type.isNil(data.text)) { 8694 element.textContent = data.text; 8695 return element; 8696 } 8697 if ('html' in data && !Type.isNil(data.html)) { 8698 element.innerHTML = data.html; 8699 } 8700 } 8701 return element; 8702 } 8703 /** 8704 * Creates element 8705 * @param tag 8706 * @param data 8707 * @param context 8708 * @return {HTMLElement|HTMLBodyElement} 8709 */ 8710 }, { 8711 key: "create", 8712 value: function create(tag, data = {}, context = document) { 8713 let tagName = tag; 8714 let options = data; 8715 if (Type.isObjectLike(tag)) { 8716 options = tag; 8717 tagName = tag.tag; 8718 } 8719 return Dom.adjust(context.createElement(tagName), options); 8720 } 8721 /** 8722 * Shows element 8723 * @param element 8724 */ 8725 }, { 8726 key: "show", 8727 value: function show(element) { 8728 if (Type.isDomNode(element)) { 8729 // eslint-disable-next-line 8730 element.hidden = false;
8731 } 8732 } 8733 /** 8734 * Hides element 8735 * @param element 8736 */ 8737 }, { 8738 key: "hide", 8739 value: function hide(element) { 8740 if (Type.isDomNode(element)) { 8741 // eslint-disable-next-line 8742 element.hidden = true; 8743 } 8744 } 8745 /** 8746 * Checks that element is shown 8747 * @param element 8748 * @return {*|boolean} 8749 */ 8750 }, { 8751 key: "isShown", 8752 value: function isShown(element) { 8753 return Type.isDomNode(element) && !element.hidden && element.style.getPropertyValue('display') !== 'none'; 8754 } 8755 /** 8756 * Toggles element visibility 8757 * @param element 8758 */ 8759 }, { 8760 key: "toggle", 8761 value: function toggle(element) { 8762 if (Type.isDomNode(element)) { 8763 if (Dom.isShown(element)) { 8764 Dom.hide(element); 8765 } else { 8766 Dom.show(element); 8767 } 8768 } 8769 } 8770 /** 8771 * Gets element position relative page 8772 * @param {HTMLElement} element 8773 * @return {DOMRect} 8774 */ 8775 }, { 8776 key: "getPosition", 8777 value: function getPosition(element) { 8778 if (Type.isDomNode(element)) { 8779 const elementRect = element.getBoundingClientRect(); 8780 const { 8781 scrollLeft, 8782 scrollTop 8783 } = getPageScroll(); 8784 return new DOMRect(elementRect.left + scrollLeft, elementRect.top + scrollTop, elementRect.width, elementRect.height); 8785 } 8786 return new DOMRect(); 8787 } 8788 /** 8789 * Gets element position relative specified element position 8790 * @param {HTMLElement} element 8791 * @param {HTMLElement} relationElement 8792 * @return {DOMRect} 8793 */ 8794 }, { 8795 key: "getRelativePosition", 8796 value: function getRelativePosition(element, relationElement) { 8797 if (Type.isDomNode(element) && Type.isDomNode(relationElement)) { 8798 const elementPosition = Dom.getPosition(element); 8799 const relationElementPosition = Dom.getPosition(relationElement); 8800 return new DOMRect(elementPosition.left - relationElementPosition.left, elementPosition.top - relationElementPosition.top, elementPosition.width, elementPosition.height); 8801 } 8802 return new DOMRect(); 8803 } 8804 }, { 8805 key: "attr", 8806 value: function attr(element, _attr, value) { 8807 if (Type.isElementNode(element)) { 8808 if (Type.isString(_attr)) { 8809 if (!Type.isNil(value)) { 8810 return element.setAttribute(_attr, encodeAttributeValue(value)); 8811 } 8812 if (Type.isNull(value)) { 8813 return element.removeAttribute(_attr); 8814 } 8815 return decodeAttributeValue(element.getAttribute(_attr)); 8816 } 8817 if (Type.isPlainObject(_attr)) { 8818 return Object.entries(_attr).forEach(([attrKey, attrValue]) => { 8819 Dom.attr(element, attrKey, attrValue); 8820 }); 8821 } 8822 } 8823 return null; 8824 } 8825 }]); 8826 return Dom; 8827 }(); 8828 8829 const UA = navigator.userAgent.toLowerCase(); 8830 8831 /** 8832 * @memberOf BX 8833 */ 8834 let Browser = /*#__PURE__*/function () { 8835 function Browser() { 8836 babelHelpers.classCallCheck(this, Browser); 8837 } 8838 babelHelpers.createClass(Browser, null, [{ 8839 key: "isOpera", 8840 value: function isOpera() { 8841 return UA.includes('opera'); 8842 } 8843 }, { 8844 key: "isIE", 8845 value: function isIE() { 8846 return 'attachEvent' in document && !Browser.isOpera(); 8847 } 8848 }, { 8849 key: "isIE6", 8850 value: function isIE6() { 8851 return UA.includes('msie 6'); 8852 } 8853 }, { 8854 key: "isIE7", 8855 value: function isIE7() { 8856 return UA.includes('msie 7'); 8857 } 8858 }, { 8859 key: "isIE8", 8860 value: function isIE8() { 8861 return UA.includes('msie 8'); 8862 } 8863 }, { 8864 key: "isIE9", 8865 value: function isIE9() { 8866 return 'documentMode' in document && document.documentMode >= 9; 8867 } 8868 }, { 8869 key: "isIE10", 8870 value: function isIE10() { 8871 return 'documentMode' in document && document.documentMode >= 10; 8872 } 8873 }, { 8874 key: "isSafari", 8875 value: function isSafari() { 8876 return UA.includes('safari') && !UA.includes('chrome'); 8877 } 8878 }, { 8879 key: "isFirefox", 8880 value: function isFirefox() { 8881 return UA.includes('firefox'); 8882 } 8883 }, { 8884 key: "isChrome", 8885 value: function isChrome() { 8886 return UA.includes('chrome'); 8887 } 8888 }, { 8889 key: "detectIEVersion", 8890 value: function detectIEVersion() { 8891 if (Browser.isOpera() || Browser.isSafari() || Browser.isFirefox() || Browser.isChrome()) { 8892 return -1; 8893 } 8894 let rv = -1; 8895 if (!!window.MSStream && !window.ActiveXObject && 'ActiveXObject' in window) { 8896 rv = 11; 8897 } else if (Browser.isIE10()) { 8898 rv = 10; 8899 } else if (Browser.isIE9()) { 8900 rv = 9; 8901 } else if (Browser.isIE()) { 8902 rv = 8; 8903 } 8904 if (rv === -1 || rv === 8) { 8905 if (navigator.appName === 'Microsoft Internet Explorer') { 8906 const re = new RegExp('MSIE ([0-9]+[.0-9]*)'); 8907 const res = navigator.userAgent.match(re); 8908 if (Type.isArrayLike(res) && res.length > 0) { 8909 rv = parseFloat(res[1]); 8910 } 8911 } 8912 if (navigator.appName === 'Netscape') { 8913 // Alternative check for IE 11 8914 rv = 11; 8915 const re = new RegExp('Trident/.*rv:([0-9]+[.0-9]*)'); 8916 if (re.exec(navigator.userAgent) != null) { 8917 const res = navigator.userAgent.match(re); 8918 if (Type.isArrayLike(res) && res.length > 0) { 8919 rv = parseFloat(res[1]); 8920 } 8921 } 8922 } 8923 } 8924 return rv; 8925 } 8926 }, { 8927 key: "isIE11", 8928 value: function isIE11() { 8929 return Browser.detectIEVersion() >= 11; 8930 } 8931 }, { 8932 key: "isMac", 8933 value: function isMac() { 8934 return UA.includes('macintosh'); 8935 } 8936 }, { 8937 key: "isWin", 8938 value: function isWin() { 8939 return UA.includes('windows'); 8940 } 8941 }, { 8942 key: "isLinux", 8943 value: function isLinux() { 8944 return UA.includes('linux') && !Browser.isAndroid(); 8945 } 8946 }, { 8947 key: "isAndroid", 8948 value: function isAndroid() { 8949 return UA.includes('android'); 8950 } 8951 }, { 8952 key: "isIPad", 8953 value: function isIPad() { 8954 return UA.includes('ipad;') || this.isMac() && this.isTouchDevice(); 8955 } 8956 }, { 8957 key: "isIPhone", 8958 value: function isIPhone() { 8959 return UA.includes('iphone;'); 8960 } 8961 }, { 8962 key: "isIOS", 8963 value: function isIOS() { 8964 return Browser.isIPad() || Browser.isIPhone(); 8965 } 8966 }, { 8967 key: "isMobile", 8968 value: function isMobile() { 8969 return Browser.isIPhone() || Browser.isIPad() || Browser.isAndroid() || UA.includes('mobile') || UA.includes('touch'); 8970 } 8971 }, { 8972 key: "isRetina", 8973 value: function isRetina() { 8974 return window.devicePixelRatio && window.devicePixelRatio >= 2; 8975 } 8976 }, { 8977 key: "isTouchDevice", 8978 value: function isTouchDevice() { 8979 return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; 8980 } 8981 }, { 8982 key: "isDoctype", 8983 value: function isDoctype(target) { 8984 const doc = target || document; 8985 if (doc.compatMode) { 8986 return doc.compatMode === 'CSS1Compat'; 8987 } 8988 return doc.documentElement && doc.documentElement.clientHeight; 8989 } 8990 }, { 8991 key: "isLocalStorageSupported", 8992 value: function isLocalStorageSupported() { 8993 try { 8994 localStorage.setItem('test', 'test'); 8995 localStorage.removeItem('test'); 8996 return true; 8997 } catch (e) { 8998 return false;
8999 } 9000 } 9001 }, { 9002 key: "addGlobalClass", 9003 value: function addGlobalClass(target) { 9004 let globalClass = 'bx-core'; 9005 target = Type.isElementNode(target) ? target : document.documentElement; 9006 if (Dom.hasClass(target, globalClass)) { 9007 return; 9008 } 9009 if (Browser.isIOS()) { 9010 globalClass += ' bx-ios'; 9011 } else if (Browser.isWin()) { 9012 globalClass += ' bx-win'; 9013 } else if (Browser.isMac()) { 9014 globalClass += ' bx-mac'; 9015 } else if (Browser.isLinux()) { 9016 globalClass += ' bx-linux'; 9017 } else if (Browser.isAndroid()) { 9018 globalClass += ' bx-android'; 9019 } 9020 globalClass += Browser.isMobile() ? ' bx-touch' : ' bx-no-touch'; 9021 globalClass += Browser.isRetina() ? ' bx-retina' : ' bx-no-retina'; 9022 if (/AppleWebKit/.test(navigator.userAgent)) { 9023 globalClass += ' bx-chrome'; 9024 } else if (/Opera/.test(navigator.userAgent)) { 9025 globalClass += ' bx-opera'; 9026 } else if (Browser.isFirefox()) { 9027 globalClass += ' bx-firefox'; 9028 } 9029 Dom.addClass(target, globalClass); 9030 } 9031 }, { 9032 key: "detectAndroidVersion", 9033 value: function detectAndroidVersion() { 9034 const re = new RegExp('Android ([0-9]+[.0-9]*)'); 9035 if (re.exec(navigator.userAgent) != null) { 9036 const res = navigator.userAgent.match(re); 9037 if (Type.isArrayLike(res) && res.length > 0) { 9038 return parseFloat(res[1]); 9039 } 9040 } 9041 return 0; 9042 } 9043 }, { 9044 key: "isPropertySupported", 9045 value: function isPropertySupported(jsProperty, returnCSSName) { 9046 if (jsProperty === '') { 9047 return false; 9048 } 9049 function getCssName(propertyName) { 9050 return propertyName.replace(/([A-Z])/g, (...args) => `-${args[1].toLowerCase()}`); 9051 } 9052 function getJsName(cssName) { 9053 const reg = /(\\-([a-z]))/g; 9054 if (reg.test(cssName)) { 9055 return cssName.replace(reg, (...args) => args[2].toUpperCase()); 9056 } 9057 return cssName; 9058 } 9059 const property = jsProperty.includes('-') ? getJsName(jsProperty) : jsProperty; 9060 const bReturnCSSName = !!returnCSSName; 9061 const ucProperty = property.charAt(0).toUpperCase() + property.slice(1); 9062 const props = ['Webkit', 'Moz', 'O', 'ms'].join(`${ucProperty} `); 9063 const properties = `${property} ${props} ${ucProperty}`.split(' '); 9064 const obj = document.body || document.documentElement; 9065 for (let i = 0; i < properties.length; i += 1) { 9066 const prop = properties[i]; 9067 if (obj && 'style' in obj && prop in obj.style) { 9068 const lowerProp = prop.substr(0, prop.length - property.length).toLowerCase(); 9069 const prefix = prop === property ? '' : `-${lowerProp}-`; 9070 return bReturnCSSName ? prefix + getCssName(property) : prop; 9071 } 9072 } 9073 return false; 9074 } 9075 }, { 9076 key: "addGlobalFeatures", 9077 value: function addGlobalFeatures(features) { 9078 if (!Type.isArray(features)) { 9079 return; 9080 } 9081 const classNames = []; 9082 for (let i = 0; i < features.length; i += 1) { 9083 const support = !!Browser.isPropertySupported(features[i]); 9084 classNames.push(`bx-${support ? '' : 'no-'}${features[i].toLowerCase()}`); 9085 } 9086 Dom.addClass(document.documentElement, classNames.join(' ')); 9087 } 9088 }]); 9089 return Browser; 9090 }(); 9091 9092 let Cookie = /*#__PURE__*/function () { 9093 function Cookie() { 9094 babelHelpers.classCallCheck(this, Cookie); 9095 } 9096 babelHelpers.createClass(Cookie, null, [{ 9097 key: "getList", 9098 /** 9099 * Gets cookies list for current domain 9100 * @return {object} 9101 */ 9102 value: function getList() { 9103 return document.cookie.split(';').map(item => item.split('=')).map(item => item.map(subItem => subItem.trim())).reduce((acc, item) => { 9104 const [key, value] = item; 9105 acc[decodeURIComponent(key)] = decodeURIComponent(value); 9106 return acc; 9107 }, {}); 9108 } 9109 /** 9110 * Gets cookie value 9111 * @param {string} name 9112 * @return {*} 9113 */ 9114 }, { 9115 key: "get", 9116 value: function get(name) { 9117 const cookiesList = Cookie.getList(); 9118 if (name in cookiesList) { 9119 return cookiesList[name]; 9120 } 9121 return undefined; 9122 } 9123 /** 9124 * Sets cookie 9125 * @param {string} name 9126 * @param {*} value 9127 * @param {object} [options] 9128 */ 9129 }, { 9130 key: "set", 9131 value: function set(name, value, options = {}) { 9132 const attributes = { 9133 expires: '', 9134 ...options 9135 }; 9136 if (Type.isNumber(attributes.expires)) { 9137 const now = +new Date(); 9138 const days = attributes.expires; 9139 const dayInMs = 864e+5; 9140 attributes.expires = new Date(now + days * dayInMs); 9141 } 9142 if (Type.isDate(attributes.expires)) { 9143 attributes.expires = attributes.expires.toUTCString(); 9144 } 9145 const safeName = decodeURIComponent(String(name)).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape); 9146 const safeValue = encodeURIComponent(String(value)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent); 9147 const stringifiedAttributes = Object.keys(attributes).reduce((acc, key) => { 9148 const attributeValue = attributes[key]; 9149 if (!attributeValue) { 9150 return acc; 9151 } 9152 if (attributeValue === true) { 9153 return `${acc}; ${key}`; 9154 } 9155 9156 /** 9157 * Considers RFC 6265 section 5.2: 9158 * ... 9159 * 3. If the remaining unparsed-attributes contains a %x3B (';') 9160 * character: 9161 * Consume the characters of the unparsed-attributes up to, 9162 * not including, the first %x3B (';') character. 9163 */ 9164 return `${acc}; ${key}=${attributeValue.split(';')[0]}`; 9165 }, ''); 9166 document.cookie = `${safeName}=${safeValue}${stringifiedAttributes}`; 9167 } 9168 /** 9169 * Removes cookie 9170 * @param {string} name 9171 * @param {object} [options] 9172 */ 9173 }, { 9174 key: "remove", 9175 value: function remove(name, options = {}) { 9176 Cookie.set(name, '', { 9177 ...options, 9178 expires: -1 9179 }); 9180 } 9181 }]); 9182 return Cookie; 9183 }(); 9184 9185 function objectToFormData(source, formData = new FormData(), pre = null) { 9186 if (Type.isUndefined(source)) { 9187 return formData; 9188 } 9189 if (Type.isNull(source)) { 9190 formData.append(pre, ''); 9191 } else if (Type.isArray(source)) { 9192 if (!source.length) {
9193 const key = `${pre}[]`; 9194 formData.append(key, ''); 9195 } else { 9196 source.forEach((value, index) => { 9197 const key = `${pre}[${index}]`; 9198 objectToFormData(value, formData, key); 9199 }); 9200 } 9201 } else if (Type.isDate(source)) { 9202 formData.append(pre, source.toISOString()); 9203 } else if (Type.isObject(source) && !Type.isFile(source) && !Type.isBlob(source)) { 9204 Object.keys(source).forEach(property => { 9205 const value = source[property]; 9206 let preparedProperty = property; 9207 if (Type.isArray(value)) { 9208 while (preparedProperty.length > 2 && preparedProperty.lastIndexOf('[]') === preparedProperty.length - 2) { 9209 preparedProperty = preparedProperty.substring(0, preparedProperty.length - 2); 9210 } 9211 } 9212 const key = pre ? `${pre}[${preparedProperty}]` : preparedProperty; 9213 objectToFormData(value, formData, key); 9214 }); 9215 } else { 9216 formData.append(pre, source); 9217 } 9218 return formData; 9219 } 9220 9221 let Data = /*#__PURE__*/function () { 9222 function Data() { 9223 babelHelpers.classCallCheck(this, Data); 9224 } 9225 babelHelpers.createClass(Data, null, [{ 9226 key: "convertObjectToFormData", 9227 /** 9228 * Converts object to FormData 9229 * @param source 9230 * @return {FormData} 9231 */ 9232 value: function convertObjectToFormData(source) { 9233 return objectToFormData(source); 9234 } 9235 }]); 9236 return Data; 9237 }(); 9238 9239 /** 9240 * @memberOf BX 9241 */ 9242 let Http = function Http() { 9243 babelHelpers.classCallCheck(this, Http); 9244 }; 9245 babelHelpers.defineProperty(Http, "Cookie", Cookie); 9246 babelHelpers.defineProperty(Http, "Data", Data); 9247 9248 function message(value) { 9249 if (Type.isString(value)) { 9250 if (Type.isNil(message[value])) { 9251 // eslint-disable-next-line 9252 EventEmitter.emit('onBXMessageNotFound', new BaseEvent({ 9253 compatData: [value] 9254 })); 9255 if (Type.isNil(message[value])) { 9256 Runtime.debug(`message undefined: ${value}`); 9257 message[value] = ''; 9258 } 9259 } 9260 } 9261 if (Type.isPlainObject(value)) { 9262 Object.keys(value).forEach(key => { 9263 message[key] = value[key]; 9264 }); 9265 } 9266 return message[value]; 9267 } 9268 if (!Type.isNil(window.BX) && Type.isFunction(window.BX.message)) { 9269 Object.keys(window.BX.message).forEach(key => { 9270 message({ 9271 [key]: window.BX.message[key] 9272 }); 9273 }); 9274 } 9275 9276 /** 9277 * Implements interface for works with language messages 9278 * @memberOf BX 9279 */ 9280 let Loc = /*#__PURE__*/function () { 9281 function Loc() { 9282 babelHelpers.classCallCheck(this, Loc); 9283 } 9284 babelHelpers.createClass(Loc, null, [{ 9285 key: "getMessage", 9286 /** 9287 * Gets message by id 9288 * @param {string} messageId 9289 * @param {object} replacements 9290 * @return {?string} 9291 */ 9292 value: function getMessage(messageId, replacements = null) { 9293 let mess = message(messageId); 9294 if (Type.isString(mess) && Type.isPlainObject(replacements)) { 9295 const escape = str => String(str).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&'); 9296 Object.keys(replacements).forEach(replacement => { 9297 const globalRegexp = new RegExp(escape(replacement), 'gi'); 9298 mess = mess.replace(globalRegexp, () => { 9299 return Type.isNil(replacements[replacement]) ? '' : String(replacements[replacement]); 9300 }); 9301 }); 9302 } 9303 return mess; 9304 } 9305 }, { 9306 key: "hasMessage", 9307 value: function hasMessage(messageId) { 9308 return Type.isString(messageId) && !Type.isNil(message[messageId]); 9309 } 9310 /** 9311 * Sets message or messages 9312 * @param {string | Object<string, string>} id 9313 * @param {string} [value] 9314 */ 9315 }, { 9316 key: "setMessage", 9317 value: function setMessage(id, value) { 9318 if (Type.isString(id) && Type.isString(value)) { 9319 message({ 9320 [id]: value 9321 }); 9322 } 9323 if (Type.isObject(id)) { 9324 message(id); 9325 } 9326 } 9327 /** 9328 * Gets plural message by id and number 9329 * @param {string} messageId 9330 * @param {number} value 9331 * @param {object} [replacements] 9332 * @return {?string} 9333 */ 9334 }, { 9335 key: "getMessagePlural",
9336 value: function getMessagePlural(messageId, value, replacements = null) { 9337 let result = ''; 9338 if (Type.isNumber(value)) { 9339 if (this.hasMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`)) { 9340 result = this.getMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`, replacements); 9341 } else { 9342 result = this.getMessage(`${messageId}_PLURAL_1`, replacements); 9343 } 9344 } else { 9345 result = this.getMessage(messageId, replacements); 9346 } 9347 return result; 9348 } 9349 /** 9350 * Gets language plural form id by number 9351 * see http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html 9352 * @param {number} value 9353 * @param {string} [languageId] 9354 * @return {?number} 9355 */ 9356 }, { 9357 key: "getPluralForm", 9358 value: function getPluralForm(value, languageId) { 9359 let pluralForm; 9360 if (!Type.isStringFilled(languageId)) { 9361 languageId = message('LANGUAGE_ID'); 9362 } 9363 if (value < 0) { 9364 value = -1 * value; 9365 } 9366 switch (languageId) { 9367 case 'ar': 9368 pluralForm = value !== 1 ? 1 : 0; 9369 /* 9370 if (value === 0) 9371 { 9372 pluralForm = 0; 9373 } 9374 else if (value === 1) 9375 { 9376 pluralForm = 1; 9377 } 9378 else if (value === 2) 9379 { 9380 pluralForm = 2; 9381 } 9382 else if ( 9383 value % 100 >= 3 9384 && value % 100 <= 10 9385 ) 9386 { 9387 pluralForm = 3; 9388 } 9389 else if (value % 100 >= 11) 9390 { 9391 pluralForm = 4; 9392 } 9393 else 9394 { 9395 pluralForm = 5; 9396 } 9397 */ 9398 break; 9399 case 'br': 9400 case 'fr': 9401 case 'tr': 9402 pluralForm = value > 1 ? 1 : 0; 9403 break; 9404 case 'de': 9405 case 'en': 9406 case 'hi': 9407 case 'it': 9408 case 'la': 9409 pluralForm = value !== 1 ? 1 : 0; 9410 break; 9411 case 'ru': 9412 case 'ua': 9413 if (value % 10 === 1 && value % 100 !== 11) { 9414 pluralForm = 0; 9415 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9416 pluralForm = 1; 9417 } else { 9418 pluralForm = 2; 9419 } 9420 break; 9421 case 'pl': 9422 if (value === 1) { 9423 pluralForm = 0; 9424 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9425 pluralForm = 1; 9426 } else { 9427 pluralForm = 2; 9428 } 9429 break; 9430 case 'id': 9431 case 'ja': 9432 case 'ms': 9433 case 'sc': 9434 case 'tc': 9435 case 'th': 9436 case 'vn': 9437 pluralForm = 0; 9438 break; 9439 default: 9440 pluralForm = 1; 9441 break; 9442 } 9443 return pluralForm; 9444 } 9445 }]); 9446 return Loc; 9447 }(); 9448 9449 const voidElements = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr']; 9450 function isVoidElement(element) { 9451 return voidElements.includes(element); 9452 } 9453 9454 const matchers = { 9455 tag: /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>|{{uid[0-9]+}}/g, 9456 comment: /<!--(?!<!)[^\[>].*?-->/g, 9457 tagName: /<\/?([^\s]+?)[/\s>]/, 9458 attributes: /\s([\w\-_:.]+)\s?\n?=\s?\n?"([^"]+)?"|\s([\w\-_:.]+)\s?\n?=\s?\n?'([^']+)?'|\s([\w\-_:.]+)/gs, 9459 placeholder: /{{uid[0-9]+}}/g 9460 }; 9461 9462 function parseTag(tag) { 9463 const tagResult = { 9464 type: 'tag', 9465 name: '', 9466 svg: false, 9467 attrs: {}, 9468 children: [], 9469 voidElement: false 9470 }; 9471 if (tag.startsWith('<!--')) { 9472 const endIndex = tag.indexOf('-->'); 9473 const openTagLength = '<!--'.length; 9474 return { 9475 type: 'comment', 9476 content: endIndex !== -1 ? tag.slice(openTagLength, endIndex) : '' 9477 }; 9478 } 9479 const tagNameMatch = tag.match(matchers.tagName); 9480 if (Type.isArrayFilled(tagNameMatch)) { 9481 const [, tagName] = tagNameMatch; 9482 tagResult.name = tagName; 9483 tagResult.svg = tagName === 'svg'; 9484 tagResult.voidElement = isVoidElement(tagName) || tag.trim().endsWith('/>'); 9485 } 9486 const reg = new RegExp(matchers.attributes); 9487 for (;;) { 9488 const result = reg.exec(tag); 9489 if (!Type.isNil(result)) { 9490 // Attributes with double quotes 9491 const [, attrName, attrValue] = result; 9492 if (!Type.isNil(attrName)) { 9493 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9494 } else { 9495 // Attributes with single quotes 9496 const [,,, attrName, attrValue] = result; 9497 if (!Type.isNil(attrName)) { 9498 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9499 } else { 9500 // Attributes without value 9501 const [,,,,, attrName] = result; 9502 tagResult.attrs[attrName] = ''; 9503 } 9504 } 9505 } else { 9506 break; 9507 } 9508 } 9509 return tagResult; 9510 } 9511 9512 function parseText(input) { 9513 const preparedText = input.replace(/[\n\r\t]$/, ''); 9514 const placeholders = preparedText.match(matchers.placeholder); 9515 return preparedText.split(matchers.placeholder).reduce((acc, item, index) => { 9516 if (Type.isStringFilled(item)) { 9517 acc.push(...item.split(/\n/).reduce((textAcc, text) => { 9518 const preparedItemText = text.replace(/[\t\r]/g, ''); 9519 if (Type.isStringFilled(preparedItemText)) { 9520 textAcc.push({ 9521 type: 'text', 9522 content: preparedItemText 9523 }); 9524 } 9525 return textAcc; 9526 }, [])); 9527 } 9528 if (placeholders && placeholders[index]) { 9529 acc.push({ 9530 type: 'placeholder', 9531 uid: parseInt(placeholders[index].replace(/{{uid|}}/, '')) 9532 }); 9533 } 9534 return acc; 9535 }, []); 9536 } 9537 9538 function parse(html, substitutions) { 9539 const result = []; 9540 if (html.indexOf('<') !== 0 && !html.startsWith('{{')) { 9541 const end = html.indexOf('<'); 9542 result.push(...parseText(end === -1 ? html : html.slice(0, end))); 9543 } 9544 const commentsContent = []; 9545 let commentIndex = -1; 9546 html = html.replace(matchers.comment, tag => { 9547 commentIndex += 1; 9548 commentsContent.push(tag.replace(/^<!--|-->$/g, '')); 9549 return `<!--{{cUid${commentIndex}}}-->`; 9550 }); 9551 const arr = []; 9552 let level = -1; 9553 let current; 9554 html.replace(matchers.tag, (tag, index) => { 9555 const start = index + tag.length; 9556 const nextChar = html.charAt(start); 9557 let parent; 9558 if (tag.startsWith('<!--')) { 9559 const comment = parseTag(tag, substitutions); 9560 comment.content = commentsContent[tag.replace(/<!--{{cUid|}}-->/g, '')]; 9561 if (level < 0) { 9562 result.push(comment); 9563 return result; 9564 } 9565 parent = arr[level]; 9566 parent.children.push(comment); 9567 return result; 9568 } 9569 if (tag.startsWith('{{')) { 9570 const [placeholder] = parseText(tag); 9571 if (level < 0) { 9572 result.push(placeholder); 9573 return result; 9574 } 9575 parent = arr[level]; 9576 parent.children.push(placeholder); 9577 return result; 9578 } 9579 if (!tag.startsWith('</')) { 9580 level++; 9581 current = parseTag(tag, substitutions); 9582 if (!current.voidElement && nextChar && nextChar !== '<') { 9583 current.children.push(...parseText(html.slice(start, html.indexOf('<', start)))); 9584 } 9585 if (level === 0) { 9586 result.push(current); 9587 } 9588 parent = arr[level - 1]; 9589 if (parent) { 9590 if (!current.svg) { 9591 current.svg = parent.svg; 9592 } 9593 parent.children.push(current); 9594 } 9595 arr[level] = current; 9596 } 9597 if (tag.startsWith('</') || current.voidElement) { 9598 if (level > -1 && (current.voidElement || current.name === tag.slice(2, -1))) { 9599 level--; 9600 current = level === -1 ? result : arr[level]; 9601 } 9602 if (nextChar && nextChar !== '<') { 9603 parent = level === -1 ? result : arr[level].children; 9604 const end = html.indexOf('<', start); 9605 const content = html.slice(start, end === -1 ? undefined : end); 9606 if (end >
9606 -1 && level + parent.length >= 0 || content !== ' ') { 9607 parent.push(...parseText(content)); 9608 } 9609 } 9610 } 9611 }); 9612 return result; 9613 } 9614 9615 const appendElement = (current, target) => { 9616 if (Type.isDomNode(current) && Type.isDomNode(target)) { 9617 if (target.nodeName !== 'TEMPLATE') { 9618 Dom.append(current, target); 9619 } else { 9620 // eslint-disable-next-line bitrix-rules/no-native-dom-methods 9621 target.content.append(current); 9622 } 9623 } 9624 }; 9625 function renderNode(options) { 9626 const { 9627 node, 9628 parentElement, 9629 substitutions, 9630 refs = [] 9631 } = options; 9632 if (node.type === 'tag') { 9633 const element = (() => { 9634 if (node.svg) { 9635 return document.createElementNS('http://www.w3.org/2000/svg', node.name); 9636 } 9637 return document.createElement(node.name); 9638 })(); 9639 if (Object.hasOwn(node.attrs, 'ref')) { 9640 refs.push([node.attrs.ref, element]); 9641 delete node.attrs.ref; 9642 } 9643 Object.entries(node.attrs).forEach(([key, value]) => { 9644 if (key.startsWith('on') && new RegExp(matchers.placeholder).test(value)) { 9645 const substitution = substitutions[parseInt(value.replace(/{{uid|}}/, '')) - 1]; 9646 if (Type.isFunction(substitution)) { 9647 const bindFunctionName = key.endsWith('once') ? 'bindOnce' : 'bind'; 9648 Event[bindFunctionName](element, key.replace(/^on|once$/g, ''), substitution); 9649 } else { 9650 element.setAttribute(key, substitution); 9651 } 9652 } else { 9653 if (new RegExp(matchers.placeholder).test(value)) { 9654 const preparedValue = value.split(/{{|}}/).reduce((acc, item) => { 9655 if (item.startsWith('uid')) { 9656 const substitution = substitutions[parseInt(item.replace('uid', '')) - 1]; 9657 return `${acc}${substitution}`; 9658 } 9659 return `${acc}${item}`; 9660 }, ''); 9661 element.setAttribute(key, preparedValue); 9662 } else { 9663 element.setAttribute(key, Text.decode(value)); 9664 } 9665 } 9666 }); 9667 node.children.forEach(childNode => { 9668 const result = renderNode({ 9669 node: childNode, 9670 parentElement: element, 9671 substitutions, 9672 refs 9673 }); 9674 if (Type.isArray(result)) { 9675 result.forEach(subChildElement => { 9676 appendElement(subChildElement, element); 9677 }); 9678 } else { 9679 appendElement(result, element); 9680 } 9681 }); 9682 return element; 9683 } 9684 if (node.type === 'comment') { 9685 return document.createComment(node.content); 9686 } 9687 if (node.type === 'text') { 9688 if (parentElement) { 9689 if (parentElement.nodeName !== 'TEMPLATE') { 9690 parentElement.insertAdjacentHTML('beforeend', node.content); 9691 } else { 9692 parentElement.content.append(node.content); 9693 } 9694 return; 9695 } 9696 return document.createTextNode(node.content); 9697 } 9698 if (node.type === 'placeholder') { 9699 return substitutions[node.uid - 1]; 9700 } 9701 } 9702 9703 function render(sections, ...substitutions) { 9704 const html = sections.reduce((acc, item, index) => { 9705 if (index > 0) { 9706 const substitution = substitutions[index - 1]; 9707 if (Type.isString(substitution) || Type.isNumber(substitution)) { 9708 return `${acc}${substitution}${item}`; 9709 } 9710 return `${acc}{{uid${index}}}${item}`; 9711 } 9712 return acc; 9713 }, sections[0]).replace(/^[\r\n\t\s]+/gm, '').replace(/>[\n]+/g, '>').replace(/[}][\n]+/g, '}'); 9714 const ast = parse(html); 9715 if (ast.length === 1) { 9716 const refs = []; 9717 const renderedNode = renderNode({ 9718 node: ast[0], 9719 substitutions, 9720 refs 9721 }); 9722 if (Type.isArrayFilled(refs)) { 9723 return Object.fromEntries([['root', renderedNode], ...refs]); 9724 } 9725 return renderedNode; 9726 } 9727 if (ast.length > 1) { 9728 const refs = []; 9729 const renderedNodes = ast.map(node => { 9730 return renderNode({ 9731 node, 9732 substitutions, 9733 refs 9734 }); 9735 }); 9736 if (Type.isArrayFilled(refs)) { 9737 return Object.fromEntries([['root', renderedNodes], ...refs]); 9738 } 9739 return renderedNodes; 9740 } 9741 return false;
9742 } 9743 9744 function parseProps(sections, ...substitutions) { 9745 return substitutions.reduce((acc, item, index) => { 9746 const nextSectionIndex = index + 1; 9747 if (!Type.isPlainObject(item) && !Type.isArray(item)) { 9748 return acc + item + sections[nextSectionIndex]; 9749 } 9750 return `${acc}__s${index}${sections[nextSectionIndex]}`; 9751 }, sections[0]).replace(/[\r\t]/gm, '').split(';\n').map(item => item.replace(/\n/, '')).reduce((acc, item) => { 9752 if (item !== '') { 9753 const matches = item.match(/^[\w-. ]+:/); 9754 const splitted = item.split(/^[\w-. ]+:/); 9755 const key = matches[0].replace(':', '').trim(); 9756 const value = splitted[1].trim(); 9757 const substitutionPlaceholderExp = /^__s\d+/; 9758 if (substitutionPlaceholderExp.test(value)) { 9759 acc[key] = substitutions[value.replace('__s', '')]; 9760 return acc; 9761 } 9762 acc[key] = value; 9763 } 9764 return acc; 9765 }, {}); 9766 } 9767 9768 /** 9769 * @memberOf BX 9770 */ 9771 let Tag = /*#__PURE__*/function () { 9772 function Tag() { 9773 babelHelpers.classCallCheck(this, Tag); 9774 } 9775 babelHelpers.createClass(Tag, null, [{ 9776 key: "safe", 9777 /** 9778 * Encodes all substitutions 9779 * @param sections 9780 * @param substitutions 9781 * @return {string} 9782 */ 9783 value: function safe(sections, ...substitutions) { 9784 return substitutions.reduce((acc, item, index) => acc + Text.encode(item) + sections[index + 1], sections[0]); 9785 } 9786 /** 9787 * Decodes all substitutions 9788 * @param sections 9789 * @param substitutions 9790 * @return {string} 9791 */ 9792 }, { 9793 key: "unsafe", 9794 value: function unsafe(sections, ...substitutions) { 9795 return substitutions.reduce((acc, item, index) => acc + Text.decode(item) + sections[index + 1], sections[0]); 9796 } 9797 /** 9798 * Adds styles to specified element 9799 * @param {HTMLElement} element 9800 * @return {Function} 9801 */ 9802 }, { 9803 key: "style", 9804 value: function style(element) { 9805 if (!Type.isDomNode(element)) { 9806 throw new Error('element is not HTMLElement'); 9807 } 9808 return function styleTagHandler(...args) { 9809 Dom.style(element, parseProps(...args)); 9810 }; 9811 } 9812 /** 9813 * Replace all messages identifiers to real messages 9814 * @param sections 9815 * @param substitutions 9816 * @return {string} 9817 */ 9818 }, { 9819 key: "message", 9820 value: function message(sections, ...substitutions) { 9821 return substitutions.reduce((acc, item, index) => acc + Loc.getMessage(item) + sections[index + 1], sections[0]); 9822 } 9823 }, { 9824 key: "attrs", 9825 /** 9826 * Adds attributes to specified element 9827 * @param element 9828 * @return {Function} 9829 */ 9830 value: function attrs(element) { 9831 if (!Type.isDomNode(element)) { 9832 throw new Error('element is not HTMLElement'); 9833 } 9834 return function attrsTagHandler(...args) { 9835 Dom.attr(element, parseProps(...args)); 9836 }; 9837 } 9838 }]); 9839 return Tag; 9840 }(); 9841 babelHelpers.defineProperty(Tag, "render", render); 9842 babelHelpers.defineProperty(Tag, "attr", Tag.attrs); 9843 9844 function getParser(format) { 9845 switch (format) { 9846 case 'index': 9847 return (sourceKey, value, accumulator) => { 9848 const result = /\[(\w*)\]$/.exec(sourceKey); 9849 const key = sourceKey.replace(/\[\w*\]$/, ''); 9850 if (Type.isNil(result)) { 9851 accumulator[key] = value; 9852 return; 9853 } 9854 if (Type.isUndefined(accumulator[key])) { 9855 accumulator[key] = {}; 9856 } 9857 accumulator[key][result[1]] = value; 9858 }; 9859 case 'bracket': 9860 return (sourceKey, value, accumulator) => { 9861 const result = /(\[\])$/.exec(sourceKey); 9862 const key = sourceKey.replace(/\[\]$/, ''); 9863 if (Type.isNil(result)) { 9864 accumulator[key] = value; 9865 return; 9866 } 9867 if (Type.isUndefined(accumulator[key])) { 9868 accumulator[key] = [value]; 9869 return; 9870 } 9871 accumulator[key] = [].concat(accumulator[key], value); 9872 }; 9873 default: 9874 return (sourceKey, value, accumulator) => {
9875 const key = sourceKey.replace(/\[\]$/, ''); 9876 accumulator[key] = value; 9877 }; 9878 } 9879 } 9880 function getKeyFormat(key) { 9881 if (/^\w+\[([\w]+)\]$/.test(key)) { 9882 return 'index'; 9883 } 9884 if (/^\w+\[\]$/.test(key)) { 9885 return 'bracket'; 9886 } 9887 return 'default'; 9888 } 9889 function isAllowedKey(key) { 9890 return !String(key).startsWith('__proto__'); 9891 } 9892 function parseQuery(input) { 9893 if (!Type.isString(input)) { 9894 return {}; 9895 } 9896 const url = input.trim().replace(/^[?#&]/, ''); 9897 if (!url) { 9898 return {}; 9899 } 9900 return { 9901 ...url.split('&').reduce((acc, param) => { 9902 const [key, value] = param.replace(/\+/g, ' ').split('='); 9903 if (isAllowedKey(key)) { 9904 const keyFormat = getKeyFormat(key); 9905 const formatter = getParser(keyFormat); 9906 formatter(key, value, acc); 9907 } 9908 return acc; 9909 }, Object.create(null)) 9910 }; 9911 } 9912 const urlExp = /^((\w+):)?(\/\/((\w+)?(:(\w+))?@)?([^\/\?:]+)(:(\d+))?)?(\/?([^\/\?#][^\?#]*)?)?(\?([^#]+))?(#((?:[\w-?/:@.~!$&'()*+,;=]|%\w{2})*))?/; 9913 function parseUrl(url) { 9914 const result = url.match(urlExp); 9915 if (Type.isArray(result)) { 9916 const queryParams = parseQuery(result[14]); 9917 return { 9918 useShort: /^\/\//.test(url), 9919 href: result[0] || '', 9920 schema: result[2] || '', 9921 host: result[8] || '', 9922 port: result[10] || '', 9923 path: result[11] || '', 9924 query: result[14] || '', 9925 queryParams, 9926 hash: result[16] || '', 9927 username: result[5] || '', 9928 password: result[7] || '', 9929 origin: result[8] || '' 9930 }; 9931 } 9932 return {}; 9933 } 9934 9935 function buildQueryString(params = {}) { 9936 const queryString = Object.keys(params).reduce((acc, key) => { 9937 if (Type.isArray(params[key])) { 9938 params[key].forEach(paramValue => { 9939 acc.push(`${key}[]=${paramValue}`); 9940 }, ''); 9941 } 9942 if (Type.isPlainObject(params[key])) { 9943 Object.keys(params[key]).forEach(paramIndex => { 9944 acc.push(`${key}[${paramIndex}]=${params[key][paramIndex]}`); 9945 }, ''); 9946 } 9947 if (!Type.isObject(params[key]) && !Type.isArray(params[key])) { 9948 acc.push(`${key}=${params[key]}`); 9949 } 9950 return acc; 9951 }, []).join('&'); 9952 if (queryString.length > 0) { 9953 return `?${queryString}`; 9954 } 9955 return queryString; 9956 } 9957 9958 function prepareParamValue(value) { 9959 if (Type.isArray(value)) { 9960 return value.map(item => String(item)); 9961 } 9962 if (Type.isPlainObject(value)) { 9963 return { 9964 ...value 9965 }; 9966 } 9967 return String(value); 9968 } 9969 9970 const map = new WeakMap(); 9971 9972 /** 9973 * Implements interface for works with URI 9974 * @memberOf BX 9975 */ 9976 let Uri = /*#__PURE__*/function () { 9977 babelHelpers.createClass(Uri, null, [{ 9978 key: "addParam", 9979 value: function addParam(url, params = {}) { 9980 return new Uri(url).setQueryParams(params).toString(); 9981 } 9982 }, { 9983 key: "removeParam", 9984 value: function removeParam(url, params) { 9985 const removableParams = Type.isArray(params) ? params : [params]; 9986 return new Uri(url).removeQueryParam(...removableParams).toString(); 9987 } 9988 }]); 9989 function Uri(url = '') { 9990 babelHelpers.classCallCheck(this, Uri); 9991 map.set(this, parseUrl(url)); 9992 } 9993 9994 /** 9995 * Gets schema 9996 * @return {?string} 9997 */ 9998 babelHelpers.createClass(Uri, [{ 9999 key: "getSchema", 10000 value: function getSchema() { 10001 return map.get(this).schema; 10002 } 10003 /** 10004 * Sets schema 10005 * @param {string} schema 10006 * @return {Uri} 10007 */ 10008 }, { 10009 key: "setSchema", 10010 value: function setSchema(schema) { 10011 map.get(this).schema = String(schema); 10012 return this; 10013 } 10014 /** 10015 * Gets host 10016 * @return {?string} 10017 */ 10018 }, { 10019 key: "getHost", 10020 value: function getHost() { 10021 return map.get(this).host; 10022 } 10023 /** 10024 * Sets host 10025 * @param {string} host 10026 * @return {Uri} 10027 */ 10028 }, { 10029 key: "setHost", 10030 value: function setHost(host) { 10031 map.get(this).host = String(host); 10032 return this; 10033 } 10034 /** 10035 * Gets port 10036 * @return {?string} 10037 */ 10038 }, { 10039 key: "getPort", 10040 value: function getPort() { 10041 return map.get(this).port; 10042 } 10043 /** 10044 * Sets port 10045 * @param {String | Number} port 10046 * @return {Uri} 10047 */ 10048 }, { 10049 key: "setPort", 10050 value: function setPort(port) { 10051 map.get(this).port = String(port); 10052 return this; 10053 } 10054 /** 10055 * Gets path 10056 * @return {?string} 10057 */ 10058 }, { 10059 key: "getPath", 10060 value: function getPath() { 10061 return map.get(this).path; 10062 } 10063 /** 10064 * Sets path 10065 * @param {string} path 10066 * @return {Uri} 10067 */ 10068 }, { 10069 key: "setPath", 10070 value: function setPath(path) { 10071 if (!/^\//.test(path)) {
10072 map.get(this).path = `/${String(path)}`; 10073 return this; 10074 } 10075 map.get(this).path = String(path); 10076 return this; 10077 } 10078 /** 10079 * Gets query 10080 * @return {?string} 10081 */ 10082 }, { 10083 key: "getQuery", 10084 value: function getQuery() { 10085 return buildQueryString(map.get(this).queryParams); 10086 } 10087 /** 10088 * Gets query param value by name 10089 * @param {string} key 10090 * @return {?string} 10091 */ 10092 }, { 10093 key: "getQueryParam", 10094 value: function getQueryParam(key) { 10095 const params = this.getQueryParams(); 10096 if (Object.hasOwn(params, key)) { 10097 return params[key]; 10098 } 10099 return null; 10100 } 10101 /** 10102 * Sets query param 10103 * @param {string} key 10104 * @param [value] 10105 * @return {Uri} 10106 */ 10107 }, { 10108 key: "setQueryParam", 10109 value: function setQueryParam(key, value = '') { 10110 map.get(this).queryParams[key] = prepareParamValue(value); 10111 return this; 10112 } 10113 /** 10114 * Gets query params 10115 * @return {Object<string, any>} 10116 */ 10117 }, { 10118 key: "getQueryParams", 10119 value: function getQueryParams() { 10120 return { 10121 ...map.get(this).queryParams 10122 }; 10123 } 10124 /** 10125 * Sets query params 10126 * @param {Object<string, any>} params 10127 * @return {Uri} 10128 */ 10129 }, { 10130 key: "setQueryParams", 10131 value: function setQueryParams(params = {}) { 10132 const currentParams = this.getQueryParams(); 10133 const newParams = { 10134 ...currentParams, 10135 ...params 10136 }; 10137 Object.keys(newParams).forEach(key => { 10138 newParams[key] = prepareParamValue(newParams[key]); 10139 }); 10140 map.get(this).queryParams = newParams; 10141 return this; 10142 } 10143 /** 10144 * Removes query params by name 10145 * @param keys 10146 * @return {Uri} 10147 */ 10148 }, { 10149 key: "removeQueryParam", 10150 value: function removeQueryParam(...keys) { 10151 const currentParams = { 10152 ...map.get(this).queryParams 10153 }; 10154 keys.forEach(key => { 10155 if (Object.hasOwn(currentParams, key)) { 10156 delete currentParams[key]; 10157 } 10158 }); 10159 map.get(this).queryParams = currentParams; 10160 return this; 10161 } 10162 /** 10163 * Gets fragment 10164 * @return {?string} 10165 */ 10166 }, { 10167 key: "getFragment", 10168 value: function getFragment() { 10169 return map.get(this).hash; 10170 } 10171 /** 10172 * Sets fragment 10173 * @param {string} hash 10174 * @return {Uri} 10175 */ 10176 }, { 10177 key: "setFragment", 10178 value: function setFragment(hash) { 10179 map.get(this).hash = String(hash); 10180 return this; 10181 } 10182 /** 10183 * Serializes URI 10184 * @return {Object} 10185 */ 10186 }, { 10187 key: "serialize", 10188 value: function serialize() { 10189 const serialized = { 10190 ...map.get(this) 10191 }; 10192 serialized.href = this.toString(); 10193 return serialized; 10194 } 10195 /** 10196 * Gets URI string 10197 * @return {string} 10198 */ 10199 }, { 10200 key: "toString", 10201 value: function toString() { 10202 const data = { 10203 ...map.get(this) 10204 }; 10205 let protocol = data.schema ? `${data.schema}://` : ''; 10206 if (data.useShort) { 10207 protocol = '//'; 10208 } 10209 const port = (() => { 10210 if (Type.isString(data.port) && !['', '80'].includes(data.port)) { 10211 return `:${data.port}`; 10212 } 10213 return ''; 10214 })(); 10215 const host = this.getHost(); 10216 const path = this.getPath(); 10217 const query = buildQueryString(data.queryParams); 10218 const hash = data.hash ? `#${data.hash}` : ''; 10219 return `${host ? protocol : ''}${host}${host ? port : ''}${path}${query}${hash}`; 10220 } 10221 }]); 10222 return Uri; 10223 }(); 10224 10225 /** 10226 * @memberOf BX 10227 */ 10228 let Validation = /*#__PURE__*/function () { 10229 function Validation() { 10230 babelHelpers.classCallCheck(this, Validation); 10231 } 10232 babelHelpers.createClass(Validation, null, [{ 10233 key: "isEmail", 10234 /** 10235 * Checks that value is valid email 10236 * @param value 10237 * @return {boolean} 10238 */ 10239 value: function isEmail(value) { 10240 const exp = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/; 10241 return exp.test(String(value).toLowerCase()); 10242 } 10243 }]); 10244 return Validation; 10245 }(); 10246 10247 let BaseCache = /*#__PURE__*/function () { 10248 function BaseCache() { 10249 babelHelpers.classCallCheck(this, BaseCache); 10250 babelHelpers.defineProperty(this, "storage", new Map()); 10251 } 10252 babelHelpers.createClass(BaseCache, [{ 10253 key: "get", 10254 /** 10255 * Gets cached value or default value 10256 */ 10257 value: function get(key, defaultValue) { 10258 if (!this.storage.has(key)) { 10259 if (Type.isFunction(defaultValue)) { 10260 return defaultValue(); 10261 } 10262 if (!Type.isUndefined(defaultValue)) { 10263 return defaultValue; 10264 } 10265 } 10266 return this.storage.get(key); 10267 } 10268 /**
10269 * Sets cache entry 10270 */ 10271 }, { 10272 key: "set", 10273 value: function set(key, value) { 10274 this.storage.set(key, value); 10275 } 10276 /** 10277 * Deletes cache entry 10278 */ 10279 }, { 10280 key: "delete", 10281 value: function _delete(key) { 10282 this.storage.delete(key); 10283 } 10284 /** 10285 * Checks that storage contains entry with specified key 10286 */ 10287 }, { 10288 key: "has", 10289 value: function has(key) { 10290 return this.storage.has(key); 10291 } 10292 /** 10293 * Gets cached value if exists, 10294 */ 10295 }, { 10296 key: "remember", 10297 value: function remember(key, defaultValue) { 10298 if (!this.storage.has(key)) { 10299 if (Type.isFunction(defaultValue)) { 10300 this.storage.set(key, defaultValue()); 10301 } else if (!Type.isUndefined(defaultValue)) { 10302 this.storage.set(key, defaultValue); 10303 } 10304 } 10305 return this.storage.get(key); 10306 } 10307 /** 10308 * Gets storage size 10309 */ 10310 }, { 10311 key: "size", 10312 value: function size() { 10313 return this.storage.size; 10314 } 10315 /** 10316 * Gets storage keys 10317 */ 10318 }, { 10319 key: "keys", 10320 value: function keys() { 10321 return [...this.storage.keys()]; 10322 } 10323 /** 10324 * Gets storage values 10325 */ 10326 }, { 10327 key: "values", 10328 value: function values() { 10329 return [...this.storage.values()]; 10330 } 10331 }]); 10332 return BaseCache; 10333 }(); 10334 10335 let MemoryCache = /*#__PURE__*/function (_BaseCache) { 10336 babelHelpers.inherits(MemoryCache, _BaseCache); 10337 function MemoryCache(...args) { 10338 var _this; 10339 babelHelpers.classCallCheck(this, MemoryCache); 10340 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(MemoryCache).call(this, ...args)); 10341 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new Map()); 10342 return _this; 10343 } 10344 return MemoryCache; 10345 }(BaseCache); 10346 10347 let LsStorage = /*#__PURE__*/function () { 10348 function LsStorage() { 10349 babelHelpers.classCallCheck(this, LsStorage); 10350 babelHelpers.defineProperty(this, "stackKey", 'BX.Cache.Storage.LsStorage.stack'); 10351 babelHelpers.defineProperty(this, "stack", null); 10352 } 10353 babelHelpers.createClass(LsStorage, [{ 10354 key: "getStack", 10355 /** 10356 * @private 10357 */ 10358 value: function getStack() { 10359 if (Type.isPlainObject(this.stack)) { 10360 return this.stack; 10361 } 10362 const stack = localStorage.getItem(this.stackKey); 10363 if (Type.isString(stack) && stack !== '') { 10364 const parsedStack = JSON.parse(stack); 10365 if (Type.isPlainObject(parsedStack)) { 10366 this.stack = parsedStack; 10367 return this.stack; 10368 } 10369 } 10370 this.stack = {}; 10371 return this.stack; 10372 } 10373 /** 10374 * @private 10375 */ 10376 }, { 10377 key: "saveStack", 10378 value: function saveStack() { 10379 if (Type.isPlainObject(this.stack)) { 10380 const preparedStack = JSON.stringify(this.stack); 10381 localStorage.setItem(this.stackKey, preparedStack); 10382 } 10383 } 10384 }, { 10385 key: "get", 10386 value: function get(key) { 10387 const stack = this.getStack(); 10388 return stack[key]; 10389 } 10390 }, { 10391 key: "set", 10392 value: function set(key, value) { 10393 const stack = this.getStack(); 10394 stack[key] = value; 10395 this.saveStack(); 10396 } 10397 }, { 10398 key: "delete", 10399 value: function _delete(key) { 10400 const stack = this.getStack(); 10401 if (key in stack) { 10402 delete stack[key]; 10403 } 10404 } 10405 }, { 10406 key: "has", 10407 value: function has(key) { 10408 const stack = this.getStack(); 10409 return key in stack; 10410 } 10411 }, { 10412 key: "keys", 10413 value: function keys() { 10414 const stack = this.getStack(); 10415 return Object.keys(stack); 10416 } 10417 }, { 10418 key: "values", 10419 value: function values() { 10420 const stack = this.getStack(); 10421 return Object.values(stack); 10422 } 10423 }, { 10424 key: "size", 10425 get: function () { 10426 const stack = this.getStack(); 10427 return Object.keys(stack).length; 10428 } 10429 }]); 10430 return LsStorage; 10431 }(); 10432 10433 let LocalStorageCache = /*#__PURE__*/function (_BaseCache) { 10434 babelHelpers.inherits(LocalStorageCache, _BaseCache); 10435 function LocalStorageCache(...args) { 10436 var _this; 10437 babelHelpers.classCallCheck(this, LocalStorageCache); 10438 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(LocalStorageCache).call(this, ...args)); 10439 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new LsStorage()); 10440 return _this; 10441 } 10442 return LocalStorageCache; 10443 }(BaseCache); 10444 10445 /** 10446 * @memberOf BX 10447 */ 10448 let Cache = function Cache() { 10449 babelHelpers.classCallCheck(this, Cache); 10450 }; 10451 babelHelpers.defineProperty(Cache, "BaseCache", BaseCache); 10452 babelHelpers.defineProperty(Cache, "MemoryCache", MemoryCache); 10453 babelHelpers.defineProperty(Cache, "LocalStorageCache", LocalStorageCache); 10454 10455 function convertPath(path) { 10456 if (Type.isStringFilled(path)) { 10457 return path.split('.').reduce((acc, item) => { 10458 item.split(/\[['"]?(.+?)['"]?\]/g).forEach(key => { 10459 if (Type.isStringFilled(key)) { 10460 acc.push(key); 10461 } 10462 }); 10463 return acc; 10464 }, []); 10465 } 10466 return []; 10467 } 10468 10469 let SettingsCollection = /*#__PURE__*/function () { 10470 function SettingsCollection(options = {}) { 10471 babelHelpers.classCallCheck(this, SettingsCollection); 10472 if (Type.isPlainObject(options)) { 10473 Object.assign(this, options); 10474 } 10475 } 10476 babelHelpers.createClass(SettingsCollection, [{ 10477 key: "get", 10478 value: function get(path, defaultValue = null) { 10479 const convertedPath = convertPath(path); 10480 return convertedPath.reduce((acc, key) => { 10481 if (!Type.isNil(acc) && acc !== defaultValue) { 10482 if (!Type.isUndefined(acc[key])) { 10483 return acc[key]; 10484 } 10485 return defaultValue; 10486 } 10487 return acc; 10488 }, this); 10489 } 10490 }]); 10491 return SettingsCollection; 10492 }(); 10493 10494 function deepFreeze(target) { 10495 if (Type.isObject(target)) { 10496 Object.values(target).forEach(value => { 10497 deepFreeze(value); 10498 }); 10499 return Object.freeze(target); 10500 } 10501 return target; 10502 } 10503 10504 const settingsStorage = new Map(); 10505 let Extension$1 = /*#__PURE__*/function () { 10506 function Extension() { 10507 babelHelpers.classCallCheck(this, Extension); 10508 } 10509 babelHelpers.createClass(Extension, null, [{ 10510 key: "getSettings", 10511 value: function getSettings(extensionName) { 10512 if (Type.isStringFilled(extensionName)) { 10513 if (settingsStorage.has(extensionName)) { 10514 return settingsStorage.get(extensionName); 10515 } 10516 const settingsScriptNode = document.querySelector(`script[data-extension="${extensionName}"]`); 10517 if (Type.isDomNode(settingsScriptNode)) { 10518 const decodedSettings = (() => { 10519 try { 10520 return new SettingsCollection(JSON.parse(settingsScriptNode.innerHTML)); 10521 } catch (error) { 10522 return new SettingsCollection(); 10523 } 10524 })(); 10525 const frozenSettings = deepFreeze(decodedSettings); 10526 settingsStorage.set(extensionName, frozenSettings); 10527 return frozenSettings; 10528 } 10529 } 10530 return deepFreeze(new SettingsCollection()); 10531 } 10532 }]); 10533 return Extension; 10534 }(); 10535 10536 let _Symbol$iterator; 10537 function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration$1(obj, privateSet); privateSet.add(obj); } 10538 function _checkPrivateRedeclaration$1(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 10539 function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 10540 var _searchIndexToInsert = /*#__PURE__*/new WeakSet(); 10541 _Symbol$iterator = Symbol.iterator; 10542 let OrderedArray = /*#__PURE__*/function () { 10543 function OrderedArray(comparator = null) { 10544 babelHelpers.classCallCheck(this, OrderedArray); 10545 _classPrivateMethodInitSpec(this, _searchIndexToInsert); 10546 babelHelpers.defineProperty(this, "comparator", null); 10547 babelHelpers.defineProperty(this, "items", []); 10548 this.comparator = Type.isFunction(comparator) ? comparator : null; 10549 } 10550 babelHelpers.createClass(OrderedArray, [{ 10551 key: "add", 10552 value: function add(item) { 10553 let index = -1; 10554 if (this.comparator) { 10555 index = _classPrivateMethodGet(this, _searchIndexToInsert, _searchIndexToInsert2).call(this, item); 10556 this.items.splice(index, 0, item); 10557 } else { 10558 this.items.push(item); 10559 } 10560 return index; 10561 } 10562 }, { 10563 key: "has", 10564 value: function has(item) { 10565 return this.items.includes(item); 10566 } 10567 }, { 10568 key: "getIndex", 10569 value: function getIndex(item) { 10570 return this.items.indexOf(item); 10571 } 10572 }, { 10573 key: "getByIndex", 10574 value: function getByIndex(index) { 10575 if (Type.isNumber(index) && index >= 0) { 10576 const item = this.items[index]; 10577 return Type.isUndefined(item) ? null : item; 10578 } 10579 return null; 10580 } 10581 }, { 10582 key: "getFirst", 10583 value: function getFirst() { 10584 const first = this.items[0]; 10585 return Type.isUndefined(first) ? null : first; 10586 } 10587 }, { 10588 key: "getLast", 10589 value: function getLast() { 10590 const last = this.items[this.count() - 1]; 10591 return Type.isUndefined(last) ? null : last; 10592 } 10593 }, { 10594 key: "count", 10595 value: function count() { 10596 return this.items.length; 10597 } 10598 }, { 10599 key: "delete", 10600 value: function _delete(item) { 10601 const index = this.getIndex(item); 10602 if (index !== -1) { 10603 this.items.splice(index, 1); 10604 return true; 10605 } 10606 return false;
10607 } 10608 }, { 10609 key: "clear", 10610 value: function clear() { 10611 this.items = []; 10612 } 10613 }, { 10614 key: _Symbol$iterator, 10615 value: function () { 10616 return this.items[Symbol.iterator](); 10617 } 10618 }, { 10619 key: "forEach", 10620 value: function forEach(callbackfn, thisArg) { 10621 return this.items.forEach(callbackfn, thisArg); 10622 } 10623 }, { 10624 key: "getAll", 10625 value: function getAll() { 10626 return this.items; 10627 } 10628 }, { 10629 key: "getComparator", 10630 value: function getComparator() { 10631 return this.comparator; 10632 } 10633 }, { 10634 key: "sort", 10635 value: function sort() { 10636 const comparator = this.getComparator(); 10637 if (comparator === null) { 10638 return; 10639 } 10640 10641 /* 10642 Simple implementation 10643 this.items.sort((item1, item2) => { 10644 return comparator(item1, item2); 10645 }); 10646 */ 10647 10648 // For stable sorting https://v8.dev/features/stable-sort 10649 const length = this.items.length; 10650 const indexes = new Array(length); 10651 for (let i = 0; i < length; i++) { 10652 indexes[i] = i; 10653 } 10654 10655 // If the comparator returns zero, use the original indexes 10656 indexes.sort((index1, index2) => { 10657 return comparator(this.items[index1], this.items[index2]) || index1 - index2; 10658 }); 10659 for (let i = 0; i < length; i++) { 10660 indexes[i] = this.items[indexes[i]]; 10661 } 10662 for (let i = 0; i < length; i++) { 10663 this.items[i] = indexes[i]; 10664 } 10665 } 10666 }]); 10667 return OrderedArray; 10668 }(); 10669 function _searchIndexToInsert2(value) { 10670 let low = 0; 10671 let high = this.items.length; 10672 while (low < high) { 10673 const mid = Math.floor((low + high) / 2); 10674 if (this.comparator(this.items[mid], value) >= 0) { 10675 high = mid; 10676 } else { 10677 low = mid + 1; 10678 } 10679 } 10680 return low; 10681 } 10682 10683 let ZIndexComponent = /*#__PURE__*/function (_EventEmitter) { 10684 babelHelpers.inherits(ZIndexComponent, _EventEmitter); 10685 function ZIndexComponent(element, componentOptions = {}) { 10686 var _this; 10687 babelHelpers.classCallCheck(this, ZIndexComponent); 10688 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(ZIndexComponent).call(this)); 10689 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "sort", 0); 10690 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "alwaysOnTop", false); 10691 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "zIndex", 0); 10692 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "element", null); 10693 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlay", null); 10694 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlayGap", -5); 10695 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "stack", null); 10696 _this.setEventNamespace('BX.Main.ZIndexManager.Component'); 10697 if (!Type.isElementNode(element)) { 10698 throw new Error('ZIndexManager.Component: The argument \'element\' must be a DOM element.'); 10699 } 10700 _this.element = element; 10701 const options = Type.isPlainObject(componentOptions) ? componentOptions : {}; 10702 _this.setAlwaysOnTop(options.alwaysOnTop); 10703 _this.setOverlay(options.overlay); 10704 _this.setOverlayGap(options.overlayGap); 10705 _this.subscribeFromOptions(options.events); 10706 return _this; 10707 } 10708 babelHelpers.createClass(ZIndexComponent, [{ 10709 key: "getSort", 10710 value: function getSort() { 10711 return this.sort; 10712 } 10713 /** 10714 * @internal 10715 * @param sort 10716 */ 10717 }, { 10718 key: "setSort", 10719 value: function setSort(sort) { 10720 if (Type.isNumber(sort)) { 10721 this.sort = sort; 10722 } 10723 } 10724 /** 10725 * @internal 10726 * @param stack 10727 */ 10728 }, { 10729 key: "setStack", 10730 value: function setStack(stack) { 10731 this.stack = stack; 10732 } 10733 }, { 10734 key: "getStack", 10735 value: function getStack() { 10736 return this.stack; 10737 } 10738 }, { 10739 key: "getZIndex", 10740 value: function getZIndex() { 10741 return this.zIndex; 10742 } 10743 /** 10744 * @internal 10745 */ 10746 }, { 10747 key: "setZIndex", 10748 value: function setZIndex(zIndex) { 10749 const changed = this.getZIndex() !== zIndex; 10750 this.getElement().style.setProperty('z-index', zIndex, 'important'); 10751 this.zIndex = zIndex; 10752 if (this.getOverlay() !== null) { 10753 this.getOverlay().style.setProperty('z-index', zIndex + this.getOverlayGap(), 'important'); 10754 } 10755 if (changed) {
10756 this.emit('onZIndexChange', { 10757 component: this 10758 }); 10759 } 10760 } 10761 }, { 10762 key: "getAlwaysOnTop", 10763 value: function getAlwaysOnTop() { 10764 return this.alwaysOnTop; 10765 } 10766 }, { 10767 key: "setAlwaysOnTop", 10768 value: function setAlwaysOnTop(value) { 10769 if (Type.isNumber(value) || Type.isBoolean(value)) { 10770 this.alwaysOnTop = value; 10771 } 10772 } 10773 }, { 10774 key: "getElement", 10775 value: function getElement() { 10776 return this.element; 10777 } 10778 }, { 10779 key: "setOverlay", 10780 value: function setOverlay(overlay, gap) { 10781 if (Type.isElementNode(overlay) || overlay === null) { 10782 this.overlay = overlay; 10783 this.setOverlayGap(gap); 10784 if (this.getStack()) { 10785 this.getStack().sort(); 10786 } 10787 } 10788 } 10789 }, { 10790 key: "getOverlay", 10791 value: function getOverlay() { 10792 return this.overlay; 10793 } 10794 }, { 10795 key: "setOverlayGap", 10796 value: function setOverlayGap(gap) { 10797 if (Type.isNumber(gap)) { 10798 this.overlayGap = gap; 10799 } 10800 } 10801 }, { 10802 key: "getOverlayGap", 10803 value: function getOverlayGap() { 10804 return this.overlayGap; 10805 } 10806 }]); 10807 return ZIndexComponent; 10808 }(EventEmitter); 10809 10810 let ZIndexStack = /*#__PURE__*/function () { 10811 function ZIndexStack(container) { 10812 babelHelpers.classCallCheck(this, ZIndexStack); 10813 babelHelpers.defineProperty(this, "container", null); 10814 babelHelpers.defineProperty(this, "components", null); 10815 babelHelpers.defineProperty(this, "elements", new WeakMap()); 10816 babelHelpers.defineProperty(this, "baseIndex", 1000); 10817 babelHelpers.defineProperty(this, "baseStep", 50); 10818 babelHelpers.defineProperty(this, "sortCount", 0); 10819 if (!Type.isDomNode(container)) { 10820 throw new Error('ZIndexManager.Stack: The \'container\' argument must be a DOM element.'); 10821 } 10822 this.container = container; 10823 const comparator = (componentA, componentB) => { 10824 let result = (componentA.getAlwaysOnTop() || 0) - (componentB.getAlwaysOnTop() || 0); 10825 if (!result) { 10826 result = componentA.getSort() - componentB.getSort(); 10827 } 10828 return result; 10829 }; 10830 this.components = new OrderedArray(comparator); 10831 } 10832 babelHelpers.createClass(ZIndexStack, [{ 10833 key: "getBaseIndex", 10834 value: function getBaseIndex() { 10835 return this.baseIndex; 10836 } 10837 }, { 10838 key: "setBaseIndex", 10839 value: function setBaseIndex(index) { 10840 if (Type.isNumber(index) && index >= 0) { 10841 this.baseIndex = index; 10842 this.sort(); 10843 } 10844 } 10845 }, { 10846 key: "setBaseStep", 10847 value: function setBaseStep(step) { 10848 if (Type.isNumber(step) && step > 0) { 10849 this.baseStep = step; 10850 this.sort(); 10851 } 10852 } 10853 }, { 10854 key: "getBaseStep", 10855 value: function getBaseStep() { 10856 return this.baseStep; 10857 } 10858 }, { 10859 key: "register", 10860 value: function register(element, options = {}) { 10861 if (this.getComponent(element)) { 10862 console.warn('ZIndexManager: You cannot register the element twice.', element); 10863 return this.getComponent(element); 10864 } 10865 const component = new ZIndexComponent(element, options); 10866 component.setStack(this); 10867 component.setSort(++this.sortCount); 10868 this.elements.set(element, component); 10869 this.components.add(component); 10870 this.sort(); 10871 return component; 10872 } 10873 }, { 10874 key: "unregister", 10875 value: function unregister(element) { 10876 const component = this.elements.get(element); 10877 this.components.delete(component); 10878 this.elements.delete(element); 10879 this.sort(); 10880 } 10881 }, { 10882 key: "getComponent", 10883 value: function getComponent(element) { 10884 return this.elements.get(element) || null; 10885 } 10886 }, { 10887 key: "getComponents", 10888 value: function getComponents() { 10889 return this.components.getAll(); 10890 } 10891 }, { 10892 key: "getMaxZIndex", 10893 value: function getMaxZIndex() { 10894 const last = this.components.getLast(); 10895 return last ? last.getZIndex() : this.baseIndex; 10896 } 10897 }, { 10898 key: "sort", 10899 value: function sort() { 10900 this.components.sort(); 10901 let zIndex = this.baseIndex;
10902 this.components.forEach(component => { 10903 component.setZIndex(zIndex); 10904 zIndex += this.baseStep; 10905 }); 10906 } 10907 }, { 10908 key: "bringToFront", 10909 value: function bringToFront(element) { 10910 const component = this.getComponent(element); 10911 if (!component) { 10912 console.error('ZIndexManager: element was not found in the stack.', element); 10913 return null; 10914 } 10915 component.setSort(++this.sortCount); 10916 this.sort(); 10917 return component; 10918 } 10919 }]); 10920 return ZIndexStack; 10921 }(); 10922 10923 function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; } 10924 function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } } 10925 /** 10926 * @memberof BX 10927 */ 10928 let ZIndexManager = /*#__PURE__*/function () { 10929 function ZIndexManager() { 10930 babelHelpers.classCallCheck(this, ZIndexManager); 10931 } 10932 babelHelpers.createClass(ZIndexManager, null, [{ 10933 key: "register", 10934 value: function register(element, options = {}) { 10935 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10936 if (!parentNode) { 10937 return null; 10938 } 10939 const stack = this.getOrAddStack(parentNode); 10940 return stack.register(element, options); 10941 } 10942 }, { 10943 key: "unregister", 10944 value: function unregister(element) { 10945 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10946 const stack = this.getStack(parentNode); 10947 if (stack) { 10948 stack.unregister(element); 10949 } 10950 } 10951 }, { 10952 key: "addStack", 10953 value: function addStack(container) { 10954 const stack = new ZIndexStack(container); 10955 this.stacks.set(container, stack); 10956 return stack; 10957 } 10958 }, { 10959 key: "getStack", 10960 value: function getStack(container) { 10961 return this.stacks.get(container) || null; 10962 } 10963 }, { 10964 key: "getOrAddStack", 10965 value: function getOrAddStack(container) { 10966 return this.getStack(container) || this.addStack(container); 10967 } 10968 }, { 10969 key: "getComponent", 10970 value: function getComponent(element) { 10971 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element, true); 10972 if (!parentNode) { 10973 return null; 10974 } 10975 const stack = this.getStack(parentNode); 10976 return stack ? stack.getComponent(element) : null; 10977 } 10978 }, { 10979 key: "bringToFront", 10980 value: function bringToFront(element) { 10981 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10982 const stack = this.getStack(parentNode); 10983 if (stack) { 10984 return stack.bringToFront(element); 10985 } 10986 return null; 10987 } 10988 }]); 10989 return ZIndexManager; 10990 }(); 10991 function _getParentNode(element, suppressWarnings = false) { 10992 if (!Type.isElementNode(element)) { 10993 if (!suppressWarnings) { 10994 console.error('ZIndexManager: The argument \'element\' must be a DOM element.', element); 10995 } 10996 return null; 10997 } else if (!Type.isElementNode(element.parentNode)) { 10998 if (!suppressWarnings) { 10999 console.error('ZIndexManager: The \'element\' doesn\'t have a parent node.', element); 11000 } 11001 return null; 11002 } 11003 return element.parentNode; 11004 } 11005 babelHelpers.defineProperty(ZIndexManager, "stacks", new WeakMap()); 11006 11007 function _classPrivateMethodInitSpec$1(obj, privateSet) { _checkPrivateRedeclaration$2(obj, privateSet); privateSet.add(obj); } 11008 function _classPrivateFieldInitSpec$1(obj, privateMap, value) { _checkPrivateRedeclaration$2(obj, privateMap); privateMap.set(obj, value); } 11009 function _checkPrivateRedeclaration$2(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 11010 function _classPrivateMethodGet$1(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 11011 11012 // eslint-disable-next-line @bitrix24/bitrix24-rules/no-typeof 11013 const IS_WEAK_REF_SUPPORTED = typeof WeakRef !== 'undefined'; 11014 var _refs = /*#__PURE__*/new WeakMap(); 11015 var _registry = /*#__PURE__*/new WeakMap(); 11016 var _cleanupCallback = /*#__PURE__*/new WeakSet(); 11017 let WeakRefMap = /*#__PURE__*/function () { 11018 function WeakRefMap() { 11019 babelHelpers.classCallCheck(this, WeakRefMap); 11020 _classPrivateMethodInitSpec$1(this, _cleanupCallback); 11021 _classPrivateFieldInitSpec$1(this, _refs, { 11022 writable: true, 11023 value: new Map() 11024 }); 11025 _classPrivateFieldInitSpec$1(this, _registry, { 11026 writable: true, 11027 value: null 11028 }); 11029 if (IS_WEAK_REF_SUPPORTED) { 11030 babelHelpers.classPrivateFieldSet(this, _registry, new FinalizationRegistry(_classPrivateMethodGet$1(this, _cleanupCallback, _cleanupCallback2).bind(this))); 11031 } 11032 } 11033 babelHelpers.createClass(WeakRefMap, [{ 11034 key: "clear", 11035 value: function clear() { 11036 if (!IS_WEAK_REF_SUPPORTED) { 11037 babelHelpers.classPrivateFieldGet(this, _refs).clear(); 11038 return; 11039 }
11040 babelHelpers.classPrivateFieldGet(this, _refs).forEach((ref, key) => { 11041 const value = ref === null || ref === void 0 ? void 0 : ref.deref(); 11042 if (!Type.isUndefined(value)) { 11043 babelHelpers.classPrivateFieldGet(this, _registry).unregister(value); 11044 } 11045 }); 11046 babelHelpers.classPrivateFieldGet(this, _refs).clear(); 11047 } 11048 }, { 11049 key: "delete", 11050 value: function _delete(key) { 11051 if (!IS_WEAK_REF_SUPPORTED) { 11052 return babelHelpers.classPrivateFieldGet(this, _refs).delete(key); 11053 } 11054 const value = this.get(key); 11055 if (!Type.isUndefined(value)) { 11056 babelHelpers.classPrivateFieldGet(this, _registry).unregister(value); 11057 } 11058 return babelHelpers.classPrivateFieldGet(this, _refs).delete(key); 11059 } 11060 }, { 11061 key: "get", 11062 value: function get(key) { 11063 var _babelHelpers$classPr; 11064 if (!IS_WEAK_REF_SUPPORTED) { 11065 return babelHelpers.classPrivateFieldGet(this, _refs).get(key); 11066 } 11067 return (_babelHelpers$classPr = babelHelpers.classPrivateFieldGet(this, _refs).get(key)) === null || _babelHelpers$classPr === void 0 ? void 0 : _babelHelpers$classPr.deref(); 11068 } 11069 }, { 11070 key: "has", 11071 value: function has(key) { 11072 var _babelHelpers$classPr2; 11073 if (!IS_WEAK_REF_SUPPORTED) { 11074 return babelHelpers.classPrivateFieldGet(this, _refs).has(key); 11075 } 11076 return !Type.isUndefined((_babelHelpers$classPr2 = babelHelpers.classPrivateFieldGet(this, _refs).get(key)) === null || _babelHelpers$classPr2 === void 0 ? void 0 : _babelHelpers$classPr2.deref()); 11077 } 11078 }, { 11079 key: "set", 11080 value: function set(key, value) { 11081 if (!IS_WEAK_REF_SUPPORTED) { 11082 babelHelpers.classPrivateFieldGet(this, _refs).set(key, value); 11083 return this; 11084 } 11085 babelHelpers.classPrivateFieldGet(this, _refs).set(key, new WeakRef(value)); 11086 babelHelpers.classPrivateFieldGet(this, _registry).register(value, key, value); 11087 return this; 11088 } 11089 }]); 11090 return WeakRefMap; 11091 }(); 11092 function _cleanupCallback2(key) { 11093 const ref = babelHelpers.classPrivateFieldGet(this, _refs).get(key); 11094 if (ref && !ref.deref()) { 11095 babelHelpers.classPrivateFieldGet(this, _refs).delete(key); 11096 } 11097 } 11098 11099 var collections = { 11100 OrderedArray, 11101 SettingsCollection, 11102 WeakRefMap 11103 }; 11104 11105 function getElement(element) { 11106 if (Type.isString(element)) { 11107 return document.getElementById(element); 11108 } 11109 return element; 11110 } 11111 11112 function getWindow(element) { 11113 if (Type.isElementNode(element)) { 11114 return element.ownerDocument.parentWindow || element.ownerDocument.defaultView || window; 11115 } 11116 if (Type.isDomNode(element)) { 11117 return element.parentWindow || element.defaultView || window; 11118 } 11119 return window; 11120 } 11121 11122 /* eslint-disable prefer-rest-params */ 11123 11124 // BX.* 11125 const { 11126 getClass, 11127 namespace 11128 } = Reflection; 11129 const message$1 = message; 11130 11131 /** 11132 * @memberOf BX 11133 */ 11134 const { 11135 replace, 11136 remove, 11137 clean, 11138 insertBefore, 11139 insertAfter, 11140 append, 11141 prepend, 11142 style, 11143 adjust, 11144 create, 11145 isShown 11146 } = Dom; 11147 const addClass = function addClass() { 11148 Dom.addClass(...Runtime.merge([], Array.from(arguments), [getElement(arguments[0])])); 11149 }; 11150 const removeClass = function removeClass() { 11151 Dom.removeClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11152 }; 11153 const hasClass = function hasClass() { 11154 return Dom.hasClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11155 }; 11156 const toggleClass = function toggleClass() { 11157 Dom.toggleClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11158 }; 11159 const cleanNode = (element, removeElement = false) => { 11160 const currentElement = getElement(element); 11161 if (Type.isDomNode(currentElement)) { 11162 Dom.clean(currentElement); 11163 if (removeElement) { 11164 Dom.remove(currentElement); 11165 return currentElement; 11166 } 11167 } 11168 return currentElement; 11169 }; 11170 const getCookie = Http.Cookie.get; 11171 const setCookie = (name, value, options = {}) => { 11172 const attributes = { 11173 ...options 11174 }; 11175 if (Type.isNumber(attributes.expires)) { 11176 attributes.expires /= 3600 * 24; 11177 } 11178 Http.Cookie.set(name, value, attributes); 11179 }; 11180 const { 11181 bind: bind$1, 11182 unbind: unbind$1, 11183 unbindAll: unbindAll$1, 11184 bindOnce: bindOnce$1, 11185 ready: ready$1 11186 } = Event; 11187 const { 11188 debugState: debugEnableFlag, 11189 isDebugEnabled: debugStatus, 11190 default: debug$1 11191 }
11191 = debugNs; 11192 const debugEnable = value => { 11193 if (value) { 11194 enableDebug(); 11195 } else { 11196 disableDebug(); 11197 } 11198 }; 11199 const { 11200 clone: clone$1, 11201 loadExtension: loadExt, 11202 debounce, 11203 throttle, 11204 html 11205 } = Runtime; 11206 11207 // BX.type 11208 const type = { 11209 ...Object.getOwnPropertyNames(Type).filter(key => !['name', 'length', 'prototype', 'caller', 'arguments'].includes(key)).reduce((acc, key) => { 11210 acc[key] = Type[key]; 11211 return acc; 11212 }, {}), 11213 isNotEmptyString: value => Type.isString(value) && value !== '', 11214 isNotEmptyObject: value => Type.isObjectLike(value) && Object.keys(value).length > 0, 11215 isMapKey: Type.isObject, 11216 stringToInt: value => { 11217 const parsed = parseInt(value); 11218 return !Number.isNaN(parsed) ? parsed : 0; 11219 } 11220 }; 11221 11222 // BX.browser 11223 const browser = { 11224 IsOpera: Browser.isOpera, 11225 IsIE: Browser.isIE, 11226 IsIE6: Browser.isIE6, 11227 IsIE7: Browser.isIE7, 11228 IsIE8: Browser.isIE8, 11229 IsIE9: Browser.isIE9, 11230 IsIE10: Browser.isIE10, 11231 IsIE11: Browser.isIE11, 11232 IsSafari: Browser.isSafari, 11233 IsFirefox: Browser.isFirefox, 11234 IsChrome: Browser.isChrome, 11235 DetectIeVersion: Browser.detectIEVersion, 11236 IsMac: Browser.isMac, 11237 IsAndroid: Browser.isAndroid, 11238 isIPad: Browser.isIPad, 11239 isIPhone: Browser.isIPhone, 11240 IsIOS: Browser.isIOS, 11241 IsMobile: Browser.isMobile, 11242 isRetina: Browser.isRetina, 11243 IsDoctype: Browser.isDoctype, 11244 SupportLocalStorage: Browser.isLocalStorageSupported, 11245 addGlobalClass: Browser.addGlobalClass, 11246 DetectAndroidVersion: Browser.detectAndroidVersion, 11247 isPropertySupported: Browser.isPropertySupported, 11248 addGlobalFeatures: Browser.addGlobalFeatures 11249 }; 11250 11251 // eslint-disable-next-line 11252 const ajax = window.BX ? window.BX.ajax : () => {}; 11253 function GetWindowScrollSize(doc = document) { 11254 return { 11255 scrollWidth: doc.documentElement.scrollWidth, 11256 scrollHeight: doc.documentElement.scrollHeight 11257 }; 11258 } 11259 function GetWindowScrollPos(doc = document) { 11260 const win = getWindow(doc); 11261 return { 11262 scrollLeft: win.pageXOffset, 11263 scrollTop: win.pageYOffset 11264 }; 11265 } 11266 function GetWindowInnerSize(doc = document) { 11267 const win = getWindow(doc); 11268 return { 11269 innerWidth: win.innerWidth, 11270 innerHeight: win.innerHeight 11271 }; 11272 } 11273 function GetWindowSize(doc = document) { 11274 return { 11275 ...GetWindowInnerSize(doc), 11276 ...GetWindowScrollPos(doc), 11277 ...GetWindowScrollSize(doc) 11278 }; 11279 } 11280 function GetContext(node) { 11281 return getWindow(node); 11282 } 11283 function pos(element, relative = false) { 11284 if (!element) { 11285 return new DOMRect().toJSON(); 11286 } 11287 if (element.ownerDocument === document && !relative) { 11288 const clientRect = element.getBoundingClientRect(); 11289 const root = document.documentElement; 11290 const { 11291 body 11292 } = document; 11293 return { 11294 top: Math.round(clientRect.top + (root.scrollTop || body.scrollTop)), 11295 left: Math.round(clientRect.left + (root.scrollLeft || body.scrollLeft)), 11296 width: Math.round(clientRect.right - clientRect.left), 11297 height: Math.round(clientRect.bottom - clientRect.top), 11298 right: Math.round(clientRect.right + (root.scrollLeft || body.scrollLeft)), 11299 bottom: Math.round(clientRect.bottom + (root.scrollTop || body.scrollTop)) 11300 }; 11301 } 11302 let x = 0; 11303 let y = 0; 11304 const w = element.offsetWidth; 11305 const h = element.offsetHeight; 11306 let first = true; 11307 11308 // eslint-disable-next-line no-param-reassign 11309 for (; element != null; element = element.offsetParent) { 11310 if (!first && relative && BX.is_relative(element)) { 11311 break; 11312 } 11313 x += element.offsetLeft; 11314 y += element.offsetTop; 11315 if (first) { 11316 first = false; 11317 // eslint-disable-next-line no-continue 11318 continue; 11319 } 11320 x += Text.toNumber(Dom.style(element, 'border-left-width')); 11321 y += Text.toNumber(Dom.style(element, 'border-top-width')); 11322 } 11323 return new DOMRect(x, y, w, h).toJSON(); 11324 } 11325 function addCustomEvent(eventObject, eventName, eventHandler) { 11326 if (Type.isString(eventObject)) { 11327 eventHandler = eventName; 11328 eventName = eventObject; 11329 eventObject = EventEmitter.GLOBAL_TARGET;
11330 } 11331 if (eventObject === window) { 11332 eventObject = EventEmitter.GLOBAL_TARGET; 11333 } 11334 if (!Type.isObject(eventObject)) { 11335 console.error('The "eventObject" argument must be an object. Received type ' + typeof eventObject + '.'); 11336 return; 11337 } 11338 if (!Type.isStringFilled(eventName)) { 11339 console.error('The "eventName" argument must be a string.'); 11340 return; 11341 } 11342 if (!Type.isFunction(eventHandler)) { 11343 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11344 return; 11345 } 11346 eventName = eventName.toLowerCase(); 11347 EventEmitter.subscribe(eventObject, eventName, eventHandler, { 11348 compatMode: true, 11349 useGlobalNaming: true 11350 }); 11351 } 11352 function onCustomEvent(eventObject, eventName, eventParams, secureParams) { 11353 if (Type.isString(eventObject)) { 11354 secureParams = eventParams; 11355 eventParams = eventName; 11356 eventName = eventObject; 11357 eventObject = EventEmitter.GLOBAL_TARGET; 11358 } 11359 if (!Type.isObject(eventObject) || eventObject === window) { 11360 eventObject = EventEmitter.GLOBAL_TARGET;
11361 } 11362 if (!eventParams) { 11363 eventParams = []; 11364 } 11365 eventName = eventName.toLowerCase(); 11366 const event = new BaseEvent(); 11367 event.setData(eventParams); 11368 event.setCompatData(eventParams); 11369 EventEmitter.emit(eventObject, eventName, event, { 11370 cloneData: secureParams === true, 11371 useGlobalNaming: true 11372 }); 11373 } 11374 function removeCustomEvent(eventObject, eventName, eventHandler) { 11375 if (Type.isString(eventObject)) { 11376 eventHandler = eventName; 11377 eventName = eventObject; 11378 eventObject = EventEmitter.GLOBAL_TARGET; 11379 } 11380 if (!Type.isFunction(eventHandler)) { 11381 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11382 return; 11383 } 11384 if (eventObject === window) { 11385 eventObject = EventEmitter.GLOBAL_TARGET; 11386 } 11387 eventName = eventName.toLowerCase(); 11388 EventEmitter.unsubscribe(eventObject, eventName, eventHandler, { 11389 useGlobalNaming: true 11390 }); 11391 } 11392 function removeAllCustomEvents(eventObject, eventName) { 11393 if (Type.isString(eventObject)) { 11394 eventName = eventObject; 11395 eventObject = EventEmitter.GLOBAL_TARGET;
11396 } 11397 if (eventObject === window) { 11398 eventObject = EventEmitter.GLOBAL_TARGET; 11399 } 11400 eventName = eventName.toLowerCase(); 11401 EventEmitter.unsubscribeAll(eventObject, eventName, { 11402 useGlobalNaming: true 11403 }); 11404 } 11405 11406 if (typeof global === 'object' && global.window && global.window.BX) { 11407 Object.assign(global.window.BX, exports); 11408 } 11409 11410 exports.Type = Type; 11411 exports.Reflection = Reflection; 11412 exports.Text = Text; 11413 exports.Dom = Dom; 11414 exports.Browser = Browser; 11415 exports.Event = Event; 11416 exports.Http = Http; 11417 exports.Runtime = Runtime; 11418 exports.Loc = Loc; 11419 exports.Tag = Tag; 11420 exports.Uri = Uri; 11421 exports.Validation = Validation; 11422 exports.Cache = Cache; 11423 exports.BaseError = BaseError; 11424 exports.Extension = Extension$1; 11425 exports.ZIndexManager = ZIndexManager; 11426 exports.Collections = collections; 11427 exports.getClass = getClass; 11428 exports.namespace = namespace; 11429 exports.message = message$1; 11430 exports.replace = replace; 11431 exports.remove = remove; 11432 exports.clean = clean; 11433 exports.insertBefore = insertBefore; 11434 exports.insertAfter = insertAfter; 11435 exports.append = append; 11436 exports.prepend = prepend; 11437 exports.style = style; 11438 exports.adjust = adjust; 11439 exports.create = create; 11440 exports.isShown = isShown; 11441 exports.addClass = addClass; 11442 exports.removeClass = removeClass; 11443 exports.hasClass = hasClass; 11444 exports.toggleClass = toggleClass; 11445 exports.cleanNode = cleanNode; 11446 exports.getCookie = getCookie; 11447 exports.setCookie = setCookie; 11448 exports.bind = bind$1; 11449 exports.unbind = unbind$1; 11450 exports.unbindAll = unbindAll$1; 11451 exports.bindOnce = bindOnce$1; 11452 exports.ready = ready$1; 11453 exports.debugEnableFlag = debugEnableFlag; 11454 exports.debugStatus = debugStatus; 11455 exports.debug = debug$1; 11456 exports.debugEnable = debugEnable; 11457 exports.clone = clone$1; 11458 exports.loadExt = loadExt; 11459 exports.debounce = debounce; 11460 exports.throttle = throttle; 11461 exports.html = html; 11462 exports.type = type; 11463 exports.browser = browser; 11464 exports.ajax = ajax; 11465 exports.GetWindowScrollSize = GetWindowScrollSize; 11466 exports.GetWindowScrollPos = GetWindowScrollPos; 11467 exports.GetWindowInnerSize = GetWindowInnerSize; 11468 exports.GetWindowSize = GetWindowSize; 11469 exports.GetContext = GetContext; 11470 exports.pos = pos; 11471 exports.addCustomEvent = addCustomEvent; 11472 exports.onCustomEvent = onCustomEvent; 11473 exports.removeCustomEvent = removeCustomEvent; 11474 exports.removeAllCustomEvents = removeAllCustomEvents; 11475 11476}((this.BX = this.BX || {}))); 11477 11478 11479 11480(function(BX) { 11481 /* list of registered proxy functions */ 11482 var proxyList = new WeakMap(); 11483 var deferList = new WeakMap(); 11484 11485 /* List of denied event handlers */ 11486 var deniedEvents = []; 11487 11488 /* list of registered custom events */ 11489 var customEvents = new WeakMap(); 11490 var customEventsCnt = 0; 11491 11492 /* list of external garbage collectors */ 11493 var garbageCollectors = []; 11494 11495 /* list of loaded CSS files */ 11496 var cssList = []; 11497 var cssInit = false; 11498 11499 /* list of loaded JS files */ 11500 var jsList = []; 11501 var jsInit = false; 11502 11503 var eventTypes = { 11504 click: 'MouseEvent', 11505 dblclick: 'MouseEvent', 11506 mousedown: 'MouseEvent', 11507 mousemove: 'MouseEvent', 11508 mouseout: 'MouseEvent', 11509 mouseover: 'MouseEvent', 11510 mouseup: 'MouseEvent', 11511 focus: 'MouseEvent', 11512 blur: 'MouseEvent' 11513 }; 11514 11515 var lastWait = []; 11516 11517 var CHECK_FORM_ELEMENTS = {tagName: /^INPUT|SELECT|TEXTAREA|BUTTON$/i}; 11518 11519 BX.MSLEFT = 1; 11520 BX.MSMIDDLE = 2; 11521 BX.MSRIGHT = 4; 11522 11523 BX.AM_PM_UPPER = 1; 11524 BX.AM_PM_LOWER = 2; 11525 BX.AM_PM_NONE = false; 11526 11527 BX.ext = function(ob) 11528 { 11529 for (var i in ob) 11530 { 11531 if(ob.hasOwnProperty(i)) 11532 { 11533 this[i] = ob[i]; 11534 } 11535 } 11536 }; 11537 11538 var r = { 11539 script: /<script([^>]*)>/ig, 11540 script_end: /<\/script>/ig, 11541 script_src: /src=["\']([^"\']+)["\']/i, 11542 script_type: /type=["\']([^"\']+)["\']/i, 11543 space: /\s+/, 11544 ltrim: /^[\s\r\n]+/g, 11545 rtrim: /[\s\r\n]+$/g, 11546 style: /<link.*?(rel="stylesheet"|type="text\/css")[^>]*>/i, 11547 style_href: /href=["\']([^"\']+)["\']/i 11548 }; 11549 11550 BX.processHTML = function(data, scriptsRunFirst) 11551 { 11552 var matchScript, matchStyle, matchSrc, matchHref, matchType, scripts = [], styles = []; 11553 var textIndexes = []; 11554 var lastIndex = r.script.lastIndex = r.script_end.lastIndex = 0; 11555 11556 while ((matchScript = r.script.exec(data)) !== null) 11557 { 11558 r.script_end.lastIndex = r.script.lastIndex; 11559 var matchScriptEnd = r.script_end.exec(data); 11560 if (matchScriptEnd === null) 11561 { 11562 break; 11563 } 11564 11565 // skip script tags of special types 11566 var skipTag = false;
11567 if ((matchType = matchScript[1].match(r.script_type)) !== null) 11568 { 11569 if( 11570 matchType[1] == 'text/html' 11571 || matchType[1] == 'text/template' 11572 || matchType[1] == 'extension/settings' 11573 ) 11574 { 11575 skipTag = true; 11576 } 11577 } 11578 11579 if(skipTag) 11580 { 11581 textIndexes.push([lastIndex, r.script_end.lastIndex - lastIndex]); 11582 } 11583 else 11584 { 11585 textIndexes.push([lastIndex, matchScript.index - lastIndex]); 11586 11587 var bRunFirst = scriptsRunFirst || (matchScript[1].indexOf('bxrunfirst') != '-1'); 11588 11589 if ((matchSrc = matchScript[1].match(r.script_src)) !== null) 11590 { 11591 scripts.push({"bRunFirst": bRunFirst, "isInternal": false, "JS": matchSrc[1]}); 11592 } 11593 else 11594 { 11595 var start = matchScript.index + matchScript[0].length; 11596 var js = data.substr(start, matchScriptEnd.index-start); 11597 11598 scripts.push({"bRunFirst": bRunFirst, "isInternal": true, "JS": js}); 11599 } 11600 } 11601 11602 lastIndex = matchScriptEnd.index + 9; 11603 r.script.lastIndex = lastIndex; 11604 } 11605 11606 textIndexes.push([lastIndex, lastIndex === 0 ? data.length : data.length - lastIndex]); 11607 var pureData = ""; 11608 for (var i = 0, length = textIndexes.length; i < length; i++) 11609 { 11610 if (BX.type.isString(data) && BX.type.isFunction(data.substr)) 11611 { 11612 pureData += data.substr(textIndexes[i][0], textIndexes[i][1]); 11613 } 11614 } 11615 11616 while ((matchStyle = pureData.match(r.style)) !== null) 11617 { 11618 if ((matchHref = matchStyle[0].match(r.style_href)) !== null && matchStyle[0].indexOf('media="') < 0) 11619 { 11620 styles.push(matchHref[1]); 11621 } 11622 11623 pureData = pureData.replace(matchStyle[0], ''); 11624 } 11625 11626 return {'HTML': pureData, 'SCRIPT': scripts, 'STYLE': styles}; 11627 }; 11628 11629 /* OO emulation utility */ 11630 BX.extend = function(child, parent) 11631 { 11632 var f = function() {}; 11633 f.prototype = parent.prototype; 11634 11635 child.prototype = new f(); 11636 child.prototype.constructor = child; 11637 11638 child.superclass = parent.prototype; 11639 child.prototype.superclass = parent.prototype; 11640 if(parent.prototype.constructor == Object.prototype.constructor) 11641 { 11642 parent.prototype.constructor = parent; 11643 } 11644 }; 11645 11646 BX.is_subclass_of = function(ob, parent_class) 11647 { 11648 if (ob instanceof parent_class) 11649 return true; 11650 11651 if (parent_class.superclass) 11652 return BX.is_subclass_of(ob, parent_class.superclass); 11653 11654 return false; 11655 }; 11656 11657 BX.clearNodeCache = function() 11658 { 11659 return false; 11660 }; 11661 11662 BX.bitrix_sessid = function() {return BX.message("bitrix_sessid"); }; 11663 11664 /** 11665 * Creates document fragment with child nodes. 11666 * 11667 * @param {Node[]} nodes 11668 * @return {DocumentFragment} 11669 */ 11670 BX.createFragment = function(nodes) 11671 { 11672 var fragment = document.createDocumentFragment(); 11673 11674 if(!BX.type.isArray(nodes)) 11675 { 11676 return fragment; 11677 } 11678 for(var i = 0; i < nodes.length; i++) 11679 { 11680 fragment.appendChild(nodes[i]); 11681 } 11682 11683 return fragment; 11684 }; 11685 11686 /** 11687 * @deprecated 11688 * @use BX.style 11689 * @param element 11690 * @param opacity 11691 */ 11692 BX.setOpacity = function(element, opacity) 11693 { 11694 var opacityValue = parseFloat(opacity); 11695 11696 if (!isNaN(opacityValue) && BX.type.isDomNode(element)) 11697 { 11698 opacityValue = opacityValue < 1 ? opacityValue : opacityValue / 100; 11699 BX.style(element, 'opacity', opacityValue); 11700 } 11701 }; 11702 11703 /** 11704 * @deprecated 11705 * @param el 11706 * @return {*} 11707 */ 11708 BX.hoverEvents = function(el) 11709 { 11710 if (el) 11711 return BX.adjust(el, {events: BX.hoverEvents()}); 11712 else 11713 return {mouseover: BX.hoverEventsHover, mouseout: BX.hoverEventsHout}; 11714 }; 11715 11716 /** 11717 * @deprecated 11718 */ 11719 BX.hoverEventsHover = function(){BX.addClass(this,'bx-hover');this.BXHOVER=true;}; 11720 /** 11721 * @deprecated 11722 */ 11723 BX.hoverEventsHout = function(){BX.removeClass(this,'bx-hover');this.BXHOVER=false;}; 11724 11725 /** 11726 * @deprecated 11727 */ 11728 BX.focusEvents = function(el) 11729 { 11730 if (el) 11731 return BX.adjust(el, {events: BX.focusEvents()}); 11732 else 11733 return {mouseover: BX.focusEventsFocus, mouseout: BX.focusEventsBlur}; 11734 }; 11735 11736 /** 11737 * @deprecated 11738 */ 11739 BX.focusEventsFocus = function(){BX.addClass(this,'bx-focus');this.BXFOCUS=true;}; 11740 /** 11741 * @deprecated 11742 */ 11743 BX.focusEventsBlur = function(){BX.removeClass(this,'bx-focus');this.BXFOCUS=false;}; 11744 11745 BX.setUnselectable = function(node) 11746 { 11747 BX.style(node, { 11748 'userSelect': 'none', 11749 'MozUserSelect': 'none', 11750 'WebkitUserSelect': 'none', 11751 'KhtmlUserSelect': 'none', 11752 }); 11753 node.setAttribute('unSelectable', 'on'); 11754 }; 11755 11756 BX.setSelectable = function(node) 11757 { 11758 BX.style(node, { 11759 'userSelect': null, 11760 'MozUserSelect': null, 11761 'WebkitUserSelect': null, 11762 'KhtmlUserSelect': null, 11763 }); 11764 node.removeAttribute('unSelectable'); 11765 }; 11766 11767 BX.styleIEPropertyName = function(name) 11768 { 11769 if (name == 'float') 11770 name = BX.browser.IsIE() ? 'styleFloat' : 'cssFloat'; 11771 else 11772 { 11773 var res = BX.browser.isPropertySupported(name); 11774 if (res) 11775 { 11776 name = res; 11777 } 11778 else 11779 {
11780 var reg = /(\-([a-z]){1})/g; 11781 if (reg.test(name)) 11782 { 11783 name = name.replace(reg, function () {return arguments[2].toUpperCase();}); 11784 } 11785 } 11786 } 11787 return name; 11788 }; 11789 11790 BX.focus = function(el) 11791 { 11792 try 11793 { 11794 el.focus(); 11795 return true; 11796 } 11797 catch (e) 11798 { 11799 return false; 11800 } 11801 }; 11802 11803 BX.firstChild = function(el) 11804 { 11805 return BX.type.isDomNode(el) ? el.firstElementChild : null; 11806 }; 11807 11808 BX.lastChild = function(el) 11809 { 11810 return BX.type.isDomNode(el) ? el.lastElementChild : null; 11811 }; 11812 11813 BX.previousSibling = function(el) 11814 { 11815 return BX.type.isDomNode(el) ? el.previousElementSibling : null; 11816 }; 11817 11818 BX.nextSibling = function(el) 11819 { 11820 return BX.type.isDomNode(el) ? el.nextElementSibling : null; 11821 }; 11822 11823 /* 11824 params: { 11825 obj : html node 11826 className : className value 11827 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 11828 } 11829 11830 Search all nodes with className 11831 */ 11832 /** 11833 * @deprecated 11834 * @use .querySelectorAll 11835 * @param obj 11836 * @param className 11837 * @param recursive 11838 * @return {*} 11839 */ 11840 BX.findChildrenByClassName = function(obj, className, recursive) 11841 { 11842 if(!obj || !obj.childNodes) return null; 11843 11844 var result = []; 11845 if (typeof(obj.getElementsByClassName) == 'undefined') 11846 { 11847 recursive = recursive !== false; 11848 result = BX.findChildren(obj, {className : className}, recursive); 11849 } 11850 else 11851 { 11852 var col = obj.getElementsByClassName(className); 11853 for (i=0,l=col.length;i<l;i++) 11854 { 11855 result[i] = col[i]; 11856 } 11857 } 11858 return result; 11859 }; 11860 11861 /* 11862 params: { 11863 obj : html node 11864 className : className value 11865 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 11866 } 11867 11868 Search first node with className 11869 */ 11870 /** 11871 * @deprecated 11872 * @use .querySelector 11873 * @param obj 11874 * @param className 11875 * @param recursive 11876 * @return {*} 11877 */ 11878 BX.findChildByClassName = function(obj, className, recursive) 11879 { 11880 if(!obj || !obj.childNodes) return null; 11881 11882 var result = null; 11883 if (typeof(obj.getElementsByClassName) == 'undefined') 11884 { 11885 recursive = recursive !== false; 11886 result = BX.findChild(obj, {className : className}, recursive); 11887 } 11888 else 11889 { 11890 var col = obj.getElementsByClassName(className); 11891 if (col && typeof(col[0]) != 'undefined') 11892 { 11893 result = col[0]; 11894 } 11895 else 11896 { 11897 result = null; 11898 } 11899 } 11900 return result; 11901 }; 11902 11903 /* 11904 params: { 11905 tagName|tag : 'tagName', 11906 className|class : 'className', 11907 attribute : {attribute : value, attribute : value} | attribute | [attribute, attribute....], 11908 property : {prop: value, prop: value} | prop | [prop, prop] 11909 } 11910 11911 all values can be RegExps or strings 11912 */ 11913 /** 11914 * @deprecated 11915 * @use .querySelectorAll 11916 * @param obj 11917 * @param params 11918 * @param recursive 11919 * @return {*|Node} 11920 */ 11921 BX.findChildren = function(obj, params, recursive) 11922 { 11923 return BX.findChild(obj, params, recursive, true); 11924 }; 11925 11926 /** 11927 * @deprecated 11928 * @use .querySelectorAll 11929 * @param obj 11930 * @param params 11931 * @param recursive 11932 * @param get_all 11933 * @return {*} 11934 */ 11935 BX.findChild = function(obj, params, recursive, get_all) 11936 { 11937 if(!obj || !obj.childNodes) return null; 11938 11939 recursive = !!recursive; get_all = !!get_all; 11940 11941 var n = obj.childNodes.length, result = []; 11942 11943 for (var j=0; j<n; j++) 11944 { 11945 var child = obj.childNodes[j]; 11946 11947 if (_checkNode(child, params)) 11948 { 11949 if (get_all) 11950 result.push(child); 11951 else 11952 return child; 11953 } 11954 11955 if(recursive == true) 11956 { 11957 var res = BX.findChild(child, params, recursive, get_all); 11958 if (res) 11959 { 11960 if (get_all) 11961 result = BX.util.array_merge(result, res); 11962 else 11963 return res; 11964 } 11965 } 11966 } 11967 11968 if (get_all || result.length > 0) 11969 return result; 11970 else 11971 return null; 11972 }; 11973 11974 /** 11975 * @deprecated 11976 * @use .closest() 11977 * @param obj 11978 * @param params 11979 * @param maxParent 11980 * @return {*} 11981 */ 11982 BX.findParent = function(obj, params, maxParent) 11983 { 11984 if(!obj) 11985 return null; 11986 11987 var o = obj; 11988 while(o.parentNode) 11989 { 11990 var parent = o.parentNode; 11991 11992 if (_checkNode(parent, params)) 11993 return parent; 11994 11995 o = parent; 11996 11997 if (!!maxParent &&
11998 (BX.type.isFunction(maxParent) 11999 || typeof maxParent == 'object')) 12000 { 12001 if (BX.type.isElementNode(maxParent)) 12002 { 12003 if (o == maxParent) 12004 break; 12005 } 12006 else 12007 { 12008 if (_checkNode(o, maxParent)) 12009 break; 12010 } 12011 } 12012 } 12013 return null; 12014 }; 12015 12016 /** 12017 * @deprecated 12018 * @use .querySelector 12019 * @param obj 12020 * @param params 12021 * @return {*} 12022 */ 12023 BX.findNextSibling = function(obj, params) 12024 { 12025 if(!obj) 12026 return null; 12027 var o = obj; 12028 while(o.nextSibling) 12029 { 12030 var sibling = o.nextSibling; 12031 if (_checkNode(sibling, params)) 12032 return sibling; 12033 o = sibling; 12034 } 12035 return null; 12036 }; 12037 12038 /** 12039 * @deprecated 12040 * @use .querySelector 12041 * @param obj 12042 * @param params 12043 * @return {*} 12044 */ 12045 BX.findPreviousSibling = function(obj, params) 12046 { 12047 if(!obj) 12048 return null; 12049 12050 var o = obj; 12051 while(o.previousSibling) 12052 { 12053 var sibling = o.previousSibling; 12054 if(_checkNode(sibling, params)) 12055 return sibling; 12056 o = sibling; 12057 } 12058 return null; 12059 }; 12060 12061 BX.checkNode = function(obj, params) 12062 { 12063 return _checkNode(obj, params); 12064 }; 12065 12066 /** 12067 * @deprecated 12068 * @use .querySelectorAll 12069 * @param form 12070 * @return {Array} 12071 */ 12072 BX.findFormElements = function(form) 12073 { 12074 if (BX.type.isString(form)) 12075 form = document.forms[form]||BX(form); 12076 12077 var res = []; 12078 12079 if (BX.type.isElementNode(form)) 12080 { 12081 if (form.tagName.toUpperCase() == 'FORM') 12082 { 12083 res = form.elements; 12084 } 12085 else 12086 { 12087 res = BX.findChildren(form, CHECK_FORM_ELEMENTS, true); 12088 } 12089 } 12090 12091 return res; 12092 }; 12093 12094 /** 12095 * @deprecated 12096 * @use .contains() 12097 * @param whichNode 12098 * @param forNode 12099 * @return {boolean} 12100 */ 12101 BX.isParentForNode = function(whichNode, forNode) 12102 { 12103 if (BX.type.isDomNode(whichNode) && BX.type.isDomNode(forNode)) 12104 { 12105 return whichNode.contains(forNode); 12106 } 12107 12108 return false; 12109 }; 12110 12111 BX.getCaretPosition = function(node) 12112 { 12113 var pos = 0; 12114 12115 if(node.selectionStart || node.selectionStart == 0) 12116 { 12117 pos = node.selectionStart; 12118 } 12119 else if(document.selection) 12120 { 12121 node.focus(); 12122 var selection = document.selection.createRange(); 12123 selection.moveStart('character', -node.value.length); 12124 pos = selection.text.length; 12125 } 12126 12127 return (pos); 12128 }; 12129 12130 BX.setCaretPosition = function(node, pos) 12131 { 12132 if(!BX.isNodeInDom(node) || BX.isNodeHidden(node) || node.disabled) 12133 { 12134 return; 12135 } 12136 12137 if(node.setSelectionRange) 12138 { 12139 node.focus(); 12140 node.setSelectionRange(pos, pos); 12141 } 12142 else if(node.createTextRange) 12143 { 12144 var range = node.createTextRange(); 12145 range.collapse(true); 12146 range.moveEnd('character', pos); 12147 range.moveStart('character', pos); 12148 range.select(); 12149 } 12150 }; 12151 12152 // access private. use BX.mergeEx instead. 12153 // todo: refactor BX.merge, make it work through BX.mergeEx 12154 BX.merge = function(){ 12155 var arg = Array.prototype.slice.call(arguments); 12156 12157 if(arg.length < 2) 12158 return {}; 12159 12160 var result = arg.shift(); 12161 12162 for(var i = 0; i < arg.length; i++) 12163 { 12164 for(var k in arg[i]){ 12165 12166 if(typeof arg[i] == 'undefined' || arg[i] == null) 12167 continue; 12168 12169 if(arg[i].hasOwnProperty(k)){ 12170 12171 if(typeof arg[i][k] == 'undefined' || arg[i][k] == null) 12172 continue; 12173 12174 if(typeof arg[i][k] == 'object' && !BX.type.isDomNode(arg[i][k]) && (typeof arg[i][k]['isUIWidget'] == 'undefined')){ 12175 12176 // go deeper 12177 12178 var isArray = 'length' in arg[i][k]; 12179 12180 if(typeof result[k] != 'object') 12181 result[k] = isArray ? [] : {}; 12182 12183 if(isArray) 12184 BX.util.array_merge(result[k], arg[i][k]); 12185 else 12186 BX.merge(result[k], arg[i][k]); 12187 12188 }else 12189 result[k] = arg[i][k]; 12190 } 12191 } 12192 } 12193 12194 return result; 12195 }; 12196 12197 BX.mergeEx = function() 12198 { 12199 var arg = Array.prototype.slice.call(arguments); 12200 if(arg.length < 2) 12201 { 12202 return {}; 12203 } 12204 12205 var result = arg.shift(); 12206 for (var i = 0; i < arg.length; i++) 12207 { 12208 for (var k in arg[i]) 12209 { 12210 if (typeof arg[i] == "undefined" || arg[i] == null || !arg[i].hasOwnProperty(k)) 12211 { 12212 continue; 12213 } 12214 12215 if (BX.type.isPlainObject(arg[i][k]) && BX.type.isPlainObject(result[k])) 12216 { 12217 BX.mergeEx(result[k], arg[i][k]); 12218 } 12219 else 12220 { 12221 result[k] = BX.type.isPlainObject(arg[i][k]) ? BX.clone(arg[i][k]) : arg[i][k]; 12222 } 12223 } 12224 } 12225 12226 return result; 12227 }; 12228 12229 BX.getEventButton = function(e) 12230 { 12231 e = e || window.event; 12232 12233 var flags = 0; 12234 12235 if (typeof e.which != 'undefined') 12236 { 12237 switch (e.which) 12238 { 12239 case 1: flags = flags|BX.MSLEFT; break; 12240 case 2: flags = flags|BX.MSMIDDLE; break; 12241 case 3: flags = flags|BX.MSRIGHT; break; 12242 } 12243 } 12244 else if (typeof e.button != 'undefined') 12245 { 12246 flags = event.button; 12247 } 12248 12249 return flags || BX.MSLEFT; 12250 }; 12251 12252 var captured_events = null, _bind = null; 12253 BX.CaptureEvents = function(el_c, evname_c) 12254 { 12255 if (_bind) 12256 return; 12257 12258 _bind = BX.bind; 12259 captured_events = []; 12260 12261 BX.bind = function(el, evname, func) 12262 { 12263 if (el === el_c && evname === evname_c) 12264 captured_events.push(func); 12265 12266 _bind.apply(this, arguments); 12267 } 12268 }; 12269 12270 BX.CaptureEventsGet = function() 12271 { 12272 if (_bind) 12273 { 12274 BX.bind = _bind; 12275 12276 var captured = captured_events; 12277 12278 _bind = null; 12279 captured_events = null; 12280 return captured; 12281 } 12282 return null; 12283 }; 12284 12285 // Don't even try to use it for submit event! 12286 BX.fireEvent = function(ob,ev) 12287 { 12288 var result = false, e = null; 12289 if (BX.type.isDomNode(ob)) 12290 { 12291 result = true; 12292 if (document.createEventObject) 12293 { 12294 // IE 12295 if (eventTypes[ev] != 'MouseEvent') 12296 { 12297 e = document.createEventObject(); 12298 e.type = ev; 12299 result = ob.fireEvent('on' + ev, e); 12300 } 12301 12302 if (ob[ev]) 12303 { 12304 ob[ev](); 12305 } 12306 } 12307 else 12308 {
12309 // non-IE 12310 e = null; 12311 12312 switch (eventTypes[ev]) 12313 { 12314 case 'MouseEvent': 12315 e = document.createEvent('MouseEvent'); 12316 try 12317 { 12318 e.initMouseEvent(ev, true, true, top, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12319 } 12320 catch (initException) 12321 { 12322 e.initMouseEvent(ev, true, true, window, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12323 } 12324 12325 break; 12326 default: 12327 e = document.createEvent('Event'); 12328 e.initEvent(ev, true, true); 12329 } 12330 12331 result = ob.dispatchEvent(e); 12332 } 12333 } 12334 12335 return result; 12336 }; 12337 12338 BX.getWheelData = function(e) 12339 { 12340 e = e || window.event; 12341 e.wheelData = e.detail ? e.detail * -1 : e.wheelDelta / 40; 12342 return e.wheelData; 12343 }; 12344 12345 BX.proxy_context = null; 12346 12347 BX.delegate = function (func, thisObject) 12348 { 12349 if (!func || !thisObject) 12350 return func; 12351 12352 return function() { 12353 var cur = BX.proxy_context; 12354 BX.proxy_context = this; 12355 var res = func.apply(thisObject, arguments); 12356 BX.proxy_context = cur; 12357 return res; 12358 } 12359 }; 12360 12361 BX.delegateLater = function (func_name, thisObject, contextObject) 12362 { 12363 return function() 12364 { 12365 if (thisObject[func_name]) 12366 { 12367 var cur = BX.proxy_context; 12368 BX.proxy_context = this; 12369 var res = thisObject[func_name].apply(contextObject||thisObject, arguments); 12370 BX.proxy_context = cur; 12371 return res; 12372 } 12373 return null; 12374 } 12375 }; 12376 12377 BX.proxy = function(func, thisObject) 12378 { 12379 return getObjectDelegate(func, thisObject, proxyList); 12380 }; 12381 12382 BX.defer = function(func, thisObject) 12383 { 12384 if (!!thisObject) 12385 return BX.defer_proxy(func, thisObject); 12386 else 12387 return function() { 12388 var arg = arguments; 12389 setTimeout(function(){func.apply(this,arg)}, 10); 12390 }; 12391 }; 12392 12393 BX.defer_proxy = function(func, thisObject) 12394 { 12395 return getObjectDelegate(func, thisObject, deferList, BX.defer); 12396 }; 12397 12398 /** 12399 * 12400 * @private 12401 */ 12402 function getObjectDelegate(func, thisObject, collection, decorator) 12403 { 12404 if (!BX.type.isFunction(func) || !BX.type.isMapKey(thisObject)) 12405 { 12406 return func; 12407 } 12408 12409 var objectDelegates = collection.get(thisObject); 12410 if (!objectDelegates) 12411 { 12412 objectDelegates = new WeakMap(); 12413 collection.set(thisObject, objectDelegates); 12414 } 12415 12416 var delegate = objectDelegates.get(func); 12417 if (!delegate) 12418 { 12419 delegate = decorator ? decorator(BX.delegate(func, thisObject)) : BX.delegate(func, thisObject); 12420 objectDelegates.set(func, delegate); 12421 } 12422 12423 return delegate; 12424 } 12425 12426 BX.once = function(el, evname, func) 12427 { 12428 var fn = function() 12429 { 12430 BX.unbind(el, evname, fn); 12431 func.apply(this, arguments); 12432 }; 12433 12434 return fn; 12435 }; 12436 12437 BX.bindDelegate = function (elem, eventName, isTarget, handler) 12438 { 12439 var h = BX.delegateEvent(isTarget, handler); 12440 BX.bind(elem, eventName, h); 12441 return h; 12442 }; 12443 12444 BX.delegateEvent = function(isTarget, handler) 12445 { 12446 return function(e) 12447 { 12448 e = e || window.event; 12449 var target = e.target || e.srcElement; 12450 12451 while (target != this) 12452 { 12453 if (_checkNode(target, isTarget)) 12454 { 12455 return handler.call(target, e); 12456 } 12457 if (target && target.parentNode) 12458 target = target.parentNode; 12459 else 12460 break; 12461 } 12462 return null; 12463 } 12464 }; 12465 12466 BX.False = function() {return false;}; 12467 BX.DoNothing = function() {}; 12468 12469 // TODO: also check event handlers set via BX.bind() 12470 BX.denyEvent = function(el, ev) 12471 { 12472 deniedEvents.push([el, ev, el['on' + ev]]); 12473 el['on' + ev] = BX.DoNothing; 12474 }; 12475 12476 BX.allowEvent = function(el, ev) 12477 { 12478 for(var i=0, len=deniedEvents.length; i<len; i++) 12479 { 12480 if (deniedEvents[i][0] == el && deniedEvents[i][1] == ev) 12481 { 12482 el['on' + ev] = deniedEvents[i][2]; 12483 BX.util.deleteFromArray(deniedEvents, i); 12484 return; 12485 } 12486 } 12487 }; 12488 12489 BX.fixEventPageXY = function(event) 12490 { 12491 BX.fixEventPageX(event); 12492 BX.fixEventPageY(event); 12493 return event; 12494 }; 12495 12496 BX.fixEventPageX = function(event) 12497 { 12498 if (event.pageX == null && event.clientX != null) 12499 { 12500 event.pageX = 12501 event.clientX + 12502 (document.documentElement && document.documentElement.scrollLeft || document.body && document.body.scrollLeft || 0) - 12503 (document.documentElement.clientLeft || 0); 12504 } 12505 12506 return event; 12507 }; 12508 12509 BX.fixEventPageY = function(event) 12510 { 12511 if (event.pageY == null && event.clientY != null) 12512 { 12513 event.pageY = 12514 event.clientY + 12515 (document.documentElement && document.documentElement.scrollTop || document.body && document.body.scrollTop || 0) - 12516 (document.documentElement.clientTop || 0); 12517 } 12518 12519 return event; 12520 }; 12521 12522 /** 12523 * @deprecated 12524 * @see e.preventDefault() 12525 */ 12526 BX.PreventDefault = function(e) 12527 { 12528 if(!e) e = window.event; 12529 if(e.stopPropagation) 12530 { 12531 e.preventDefault(); 12532 e.stopPropagation(); 12533 } 12534 else 12535 { 12536 e.cancelBubble = true; 12537 e.returnValue = false;
12538 } 12539 return false; 12540 }; 12541 12542 /** 12543 * @deprecated 12544 * @see e.preventDefault(); 12545 * 12546 * @param e 12547 * @return {boolean} 12548 */ 12549 BX.eventReturnFalse = function(e) 12550 { 12551 e=e||window.event; 12552 if (e && e.preventDefault) e.preventDefault(); 12553 else e.returnValue = false; 12554 return false; 12555 }; 12556 12557 /** 12558 * @deprecated 12559 * @see e.stopPropagation() 12560 * @param e 12561 */ 12562 BX.eventCancelBubble = function(e) 12563 { 12564 e=e||window.event; 12565 if(e && e.stopPropagation) 12566 e.stopPropagation(); 12567 else 12568 e.cancelBubble = true; 12569 }; 12570 12571 BX.bindDebouncedChange = function(node, fn, fnInstant, timeout, ctx) 12572 { 12573 ctx = ctx || window; 12574 timeout = timeout || 300; 12575 12576 var dataTag = 'bx-dc-previous-value'; 12577 BX.data(node, dataTag, node.value); 12578 12579 var act = function(fn, val){ 12580 12581 var pVal = BX.data(node, dataTag); 12582 12583 if(typeof pVal == 'undefined' || pVal != val){ 12584 if(typeof ctx != 'object') 12585 fn(val); 12586 else 12587 fn.apply(ctx, [val]); 12588 } 12589 }; 12590 12591 var actD = BX.debounce(function(){ 12592 var val = node.value; 12593 act(fn, val); 12594 BX.data(node, dataTag, val); 12595 }, timeout); 12596 12597 BX.bind(node, 'keyup', actD); 12598 BX.bind(node, 'change', actD); 12599 BX.bind(node, 'input', actD); 12600 12601 if(BX.type.isFunction(fnInstant)){ 12602 12603 var actI = function(){ 12604 act(fnInstant, node.value); 12605 }; 12606 12607 BX.bind(node, 'keyup', actI); 12608 BX.bind(node, 'change', actI); 12609 BX.bind(node, 'input', actI); 12610 } 12611 }; 12612 12613 BX.parseJSON = function(data, context) 12614 { 12615 var result = null; 12616 if (BX.type.isNotEmptyString(data)) 12617 { 12618 try { 12619 if (data.indexOf("\n") >= 0) 12620 eval('result = ' + data); 12621 else 12622 result = (new Function("return " + data))(); 12623 } catch(e) { 12624 BX.onCustomEvent(context, 'onParseJSONFailure', [data, context]) 12625 } 12626 } 12627 else if(BX.type.isPlainObject(data)) 12628 { 12629 return data; 12630 } 12631 12632 return result; 12633 }; 12634 12635 BX.submit = function(obForm, action_name, action_value, onAfterSubmit) 12636 { 12637 action_name = action_name || 'save'; 12638 if (!obForm['BXFormSubmit_' + action_name]) 12639 { 12640 obForm['BXFormSubmit_' + action_name] = obForm.appendChild(BX.create('INPUT', { 12641 'props': { 12642 'type': 'submit', 12643 'name': action_name, 12644 'value': action_value || 'Y' 12645 }, 12646 'style': { 12647 'display': 'none' 12648 } 12649 })); 12650 } 12651 12652 if (obForm.sessid) 12653 obForm.sessid.value = BX.bitrix_sessid(); 12654 12655 setTimeout(BX.delegate(function() {BX.fireEvent(this, 'click'); if (onAfterSubmit) onAfterSubmit();}, obForm['BXFormSubmit_' + action_name]), 10); 12656 }; 12657 12658 BX.show = function(ob, displayType) 12659 { 12660 if (ob.BXDISPLAY || !_checkDisplay(ob, displayType)) 12661 { 12662 ob.style.display = ob.BXDISPLAY; 12663 } 12664 }; 12665 12666 BX.hide = function(ob, displayType) 12667 { 12668 if (!ob.BXDISPLAY) 12669 _checkDisplay(ob, displayType); 12670 12671 ob.style.display = 'none'; 12672 }; 12673 12674 BX.toggle = function(ob, values) 12675 { 12676 if (!values && BX.type.isElementNode(ob)) 12677 { 12678 var bShow = true; 12679 if (ob.BXDISPLAY) 12680 bShow = !_checkDisplay(ob); 12681 else 12682 bShow = ob.style.display == 'none'; 12683 12684 if (bShow) 12685 BX.show(ob); 12686 else 12687 BX.hide(ob); 12688 } 12689 else if (BX.type.isArray(values)) 12690 { 12691 for (var i=0,len=values.length; i<len; i++) 12692 { 12693 if (ob == values[i]) 12694 { 12695 ob = values[i==len-1 ? 0 : i+1]; 12696 break; 12697 } 12698 } 12699 if (i==len) 12700 ob = values[0]; 12701 } 12702 12703 return ob; 12704 }; 12705 12706 function _checkDisplay(ob, displayType) 12707 { 12708 if (typeof displayType != 'undefined') 12709 ob.BXDISPLAY = displayType; 12710 12711 var d = ob.style.display || BX.style(ob, 'display'); 12712 if (d != 'none') 12713 { 12714 ob.BXDISPLAY = ob.BXDISPLAY || d; 12715 return true; 12716 } 12717 else 12718 { 12719 ob.BXDISPLAY = ob.BXDISPLAY || 'block'; 12720 return false; 12721 } 12722 } 12723 12724 /* some useful util functions */ 12725 12726 BX.util = { 12727 /** 12728 * @deprecated 12729 * @use [].filter(value => !BX.Type.isNil(value)) 12730 * @param ar 12731 * @return {*} 12732 */ 12733 array_values: function(ar) 12734 { 12735 if (!BX.type.isArray(ar)) 12736 return BX.util._array_values_ob(ar); 12737 var arv = []; 12738 for(var i=0,l=ar.length;i<l;i++) 12739 if (ar[i] !== null && typeof ar[i] != 'undefined') 12740 arv.push(ar[i]); 12741 return arv; 12742 }, 12743 12744 /** 12745 * @deprecated 12746 * @use Object.values([]).filter(value => !BX.Type.isNil(value)) 12747 * @param ar 12748 * @return {Array} 12749 * @private 12750 */ 12751 _array_values_ob: function(ar) 12752 { 12753 var arv = []; 12754 for(var i in ar) 12755 if (ar[i] !== null && typeof ar[i] != 'undefined') 12756 arv.push(ar[i]); 12757 return arv; 12758 }, 12759 12760 /** 12761 * @deprecated 12762 * @use 12763 * @param ar 12764 * @return {*} 12765 */ 12766 array_keys: function(ar) 12767 { 12768 if (!BX.type.isArray(ar)) 12769 return BX.util._array_keys_ob(ar); 12770 var arv = []; 12771 for(var i=0,l=ar.length;i<l;i++) 12772 if (ar[i] !== null && typeof ar[i] != 'undefined') 12773 arv.push(i); 12774 return arv; 12775 }, 12776 12777 _array_keys_ob: function(ar) 12778 { 12779 var arv = []; 12780 for(var i in ar) 12781 if (ar[i] !== null && typeof ar[i] != 'undefined') 12782 arv.push(i); 12783 return arv; 12784 }, 12785 12786 object_keys: function(obj) 12787 { 12788 var arv = []; 12789 for(var k in obj) 12790 { 12791 if(obj.hasOwnProperty(k)) 12792 { 12793 arv.push(k); 12794 } 12795 } 12796 return arv; 12797 }, 12798 12799 /** 12800 * @deprecated 12801 * @use firstArr.concat(secondArr); 12802 * @param first 12803 * @param second 12804 * @return {*[]} 12805 */ 12806 array_merge: function(first, second) 12807 { 12808 if (!BX.type.isArray(first)) first = []; 12809 if (!BX.type.isArray(second)) second = []; 12810 12811 var i = first.length, j = 0; 12812 12813 if (typeof second.length === "number") 12814 { 12815 for (var l = second.length; j < l; j++) 12816 { 12817 first[i++] = second[j]; 12818 } 12819 } 12820 else 12821 {
12822 while (second[j] !== undefined) 12823 { 12824 first[i++] = second[j++]; 12825 } 12826 } 12827 12828 first.length = i; 12829 12830 return first; 12831 }, 12832 12833 array_flip: function (object) 12834 { 12835 var newObject = {}; 12836 12837 for (var key in object) 12838 { 12839 newObject[object[key]] = key; 12840 } 12841 12842 return newObject; 12843 }, 12844 12845 array_diff: function(ar1, ar2, hash) 12846 { 12847 hash = BX.type.isFunction(hash) ? hash : null; 12848 var i, length, v, h, map = {}, result = []; 12849 for(i = 0, length = ar2.length; i < length; i++) 12850 { 12851 v = ar2[i]; 12852 h = hash ? hash(v) : v; 12853 map[h] = true; 12854 } 12855 12856 for(i = 0, length = ar1.length; i < length; i++) 12857 { 12858 v = ar1[i]; 12859 h = hash ? hash(v) : v; 12860 if(typeof(map[h]) === "undefined") 12861 { 12862 result.push(v); 12863 } 12864 } 12865 return result; 12866 }, 12867 12868 /** 12869 * @deprecated 12870 * @use Set 12871 */ 12872 array_unique: function(ar) 12873 { 12874 var i=0,j,len=ar.length; 12875 if(len<2) return ar; 12876 12877 for (; i<len-1;i++) 12878 { 12879 for (j=i+1; j<len;j++) 12880 { 12881 if (ar[i]==ar[j]) 12882 { 12883 ar.splice(j--,1); len--; 12884 } 12885 } 12886 } 12887 12888 return ar; 12889 }, 12890 12891 /** 12892 * @deprecated 12893 * @use myArr.includes(needle) 12894 */ 12895 in_array: function(needle, haystack) 12896 { 12897 for(var i=0; i<haystack.length; i++) 12898 { 12899 if(haystack[i] == needle) 12900 return true; 12901 } 12902 return false; 12903 }, 12904 12905 /** 12906 * @deprecated 12907 * @use myArr.findIndex(item => item === needle); 12908 */ 12909 array_search: function(needle, haystack) 12910 { 12911 for(var i=0; i<haystack.length; i++) 12912 { 12913 if(haystack[i] == needle) 12914 return i; 12915 } 12916 return -1; 12917 }, 12918 12919 object_search_key: function(needle, haystack) 12920 { 12921 if (typeof haystack[needle] != 'undefined') 12922 return haystack[needle]; 12923 12924 for(var i in haystack) 12925 { 12926 if (typeof haystack[i] == "object") 12927 { 12928 var result = BX.util.object_search_key(needle, haystack[i]); 12929 if (result !== false) 12930 return result; 12931 } 12932 } 12933 return false; 12934 }, 12935 12936 trim: function(s) 12937 { 12938 if (BX.type.isString(s)) 12939 { 12940 return s.trim(); 12941 } 12942 12943 return s; 12944 }, 12945 12946 urlencode: function(s){return encodeURIComponent(s);}, 12947 12948 // it may also be useful. via sVD. 12949 deleteFromArray: function(ar, ind) {return ar.slice(0, ind).concat(ar.slice(ind + 1));}, 12950 insertIntoArray: function(ar, ind, el) {return ar.slice(0, ind).concat([el]).concat(ar.slice(ind));}, 12951 12952 htmlspecialchars: function(str) 12953 { 12954 return BX.Text.encode(str); 12955 }, 12956 12957 htmlspecialcharsback: function(str) 12958 { 12959 return BX.Text.decode(str); 12960 }, 12961 12962 // Quote regular expression characters plus an optional character 12963 preg_quote: function(str, delimiter) 12964 { 12965 if(!str.replace) 12966 return str; 12967 return str.replace(new RegExp('[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + (delimiter || '') + '-]', 'g'), '\\$&'); 12968 }, 12969 12970 jsencode: function(str) 12971 { 12972 if (!str || !str.replace) 12973 return str; 12974 12975 var escapes = 12976 [ 12977 { c: "\\\\", r: "\\\\" }, // should be first 12978 { c: "\\t", r: "\\t" }, 12979 { c: "\\n", r: "\\n" }, 12980 { c: "\\r", r: "\\r" }, 12981 { c: "\"", r: "\\\"" }, 12982 { c: "'", r: "\\'" }, 12983 { c: "<", r: "\\x3C" }, 12984 { c: ">", r: "\\x3E" }, 12985 { c: "\\u2028", r: "\\u2028" }, 12986 { c: "\\u2029", r: "\\u2029" } 12987 ]; 12988 for (var i = 0; i < escapes.length; i++) 12989 str = str.replace(new RegExp(escapes[i].c, 'g'), escapes[i].r); 12990 return str; 12991 }, 12992 12993 getCssName: function(jsName) 12994 { 12995 if (!BX.type.isNotEmptyString(jsName)) 12996 { 12997 return ""; 12998 } 12999 13000 return jsName.replace(/[A-Z]/g, function(match) { 13001 return "-" + match.toLowerCase(); 13002 }); 13003 }, 13004 13005 getJsName: function(cssName) 13006 { 13007 var regex = /\-([a-z]){1}/g; 13008 if (regex.test(cssName)) 13009 { 13010 return cssName.replace(regex, function(match, letter) { 13011 return letter.toUpperCase(); 13012 }); 13013 } 13014 13015 return cssName; 13016 }, 13017 13018 nl2br: function(str) 13019 { 13020 if (!str || !str.replace) 13021 return str; 13022 13023 return str.replace(/([^>])\n/g, '$1<br/>'); 13024 }, 13025 13026 /** 13027 * @deprecated 13028 * @use .padStart() / .padEnd() 13029 * @param input 13030 * @param pad_length 13031 * @param pad_string 13032 * @param pad_type 13033 * @return {*} 13034 */ 13035 str_pad: function(input, pad_length, pad_string, pad_type) 13036 { 13037 pad_string = pad_string || ' '; 13038 pad_type = pad_type || 'right'; 13039 input = input.toString(); 13040 13041 if (pad_type === 'left') 13042 { 13043 return BX.util.str_pad_left(input, pad_length, pad_string); 13044 } 13045 13046 return BX.util.str_pad_right(input, pad_length, pad_string); 13047 }, 13048 13049 str_pad_left: function(input, pad_length, pad_string) 13050 { 13051 return input.toString().padStart(pad_length, pad_string); 13052 }, 13053 13054 str_pad_right: function(input, pad_length, pad_string) 13055 { 13056 return input.toString().padEnd(pad_length, pad_string); 13057 }, 13058 13059 strip_tags: function(str) 13060 { 13061 return str.split(/<[^>]+>/g).join(''); 13062 }, 13063 13064 strip_php_tags: function(str) 13065 { 13066 return str.replace(/<\?(.|[\r\n])*?\?>/g, ''); 13067 }, 13068 13069 popup: function(url, width, height) 13070 { 13071 var w, h; 13072 if(BX.browser.IsOpera()) 13073 { 13074 w = document.body.offsetWidth; 13075 h = document.body.offsetHeight; 13076 } 13077 else 13078 {
13079 w = screen.width; 13080 h = screen.height; 13081 } 13082 return window.open(url, '', 'status=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+',top='+Math.floor((h - height)/2-14)+',left='+Math.floor((w - width)/2-5)); 13083 }, 13084 13085 shuffle: function(array) 13086 { 13087 var temporaryValue, randomIndex; 13088 var currentIndex = array.length; 13089 13090 while (0 !== currentIndex) 13091 { 13092 randomIndex = Math.floor(Math.random() * currentIndex); 13093 currentIndex -= 1; 13094 13095 temporaryValue = array[currentIndex]; 13096 array[currentIndex] = array[randomIndex]; 13097 array[randomIndex] = temporaryValue; 13098 } 13099 13100 return array; 13101 }, 13102 13103 // BX.util.objectSort(object, sortBy, sortDir) - Sort object by property 13104 // function params: 1 - object for sort, 2 - sort by property, 3 - sort direction (asc/desc) 13105 // return: sort array [[objectElement], [objectElement]] in sortDir direction 13106 13107 // example: BX.util.objectSort({'L1': {'name': 'Last'}, 'F1': {'name': 'First'}}, 'name', 'asc'); 13108 // return: [{'name' : 'First'}, {'name' : 'Last'}] 13109 objectSort: function(object, sortBy, sortDir) 13110 { 13111 sortDir = sortDir == 'asc'? 'asc': 'desc'; 13112 13113 var arItems = [], i; 13114 for (i in object) 13115 { 13116 if (object.hasOwnProperty(i) && object[i][sortBy]) 13117 { 13118 arItems.push([i, object[i][sortBy]]); 13119 } 13120 } 13121 13122 if (sortDir == 'asc') 13123 { 13124 arItems.sort(function(i, ii) { 13125 var s1, s2; 13126 if (BX.type.isDate(i[1])) 13127 { 13128 s1 = i[1].getTime(); 13129 } 13130 else if (!isNaN(i[1])) 13131 { 13132 s1 = parseInt(i[1]); 13133 } 13134 else 13135 { 13136 s1 = i[1].toString().toLowerCase(); 13137 } 13138 13139 if (BX.type.isDate(ii[1])) 13140 { 13141 s2 = ii[1].getTime(); 13142 } 13143 else if (!isNaN(ii[1])) 13144 { 13145 s2 = parseInt(ii[1]); 13146 } 13147 else 13148 { 13149 s2 = ii[1].toString().toLowerCase(); 13150 } 13151 13152 if (s1 > s2) 13153 return 1; 13154 else if (s1 < s2) 13155 return -1; 13156 else 13157 return 0; 13158 }); 13159 } 13160 else 13161 { 13162 arItems.sort(function(i, ii) { 13163 var s1, s2; 13164 if (BX.type.isDate(i[1])) 13165 { 13166 s1 = i[1].getTime(); 13167 } 13168 else if (!isNaN(i[1])) 13169 { 13170 s1 = parseInt(i[1]); 13171 } 13172 else 13173 { 13174 s1 = i[1].toString().toLowerCase(); 13175 } 13176 13177 if (BX.type.isDate(ii[1])) 13178 { 13179 s2 = ii[1].getTime(); 13180 } 13181 else if (!isNaN(ii[1])) 13182 { 13183 s2 = parseInt(ii[1]); 13184 } 13185 else 13186 { 13187 s2 = ii[1].toString().toLowerCase(); 13188 } 13189 13190 if (s1 < s2) 13191 return 1; 13192 else if (s1 > s2) 13193 return -1; 13194 else 13195 return 0; 13196 }); 13197 } 13198 13199 var arReturnArray = Array(); 13200 for (i = 0; i < arItems.length; i++) 13201 { 13202 arReturnArray.push(object[arItems[i][0]]); 13203 } 13204 13205 return arReturnArray; 13206 }, 13207 13208 objectMerge: function() 13209 { 13210 return BX.mergeEx.apply(window, arguments); 13211 }, 13212 13213 objectClone : function(object) 13214 { 13215 return BX.clone(object, true); 13216 }, 13217 13218 // #fdf9e5 => {r=253, g=249, b=229} 13219 hex2rgb: function(color) 13220 { 13221 var rgb = color.replace(/[# ]/g,"").replace(/^(.)(.)(.)$/,'$1$1$2$2$3$3').match(/.{2}/g); 13222 for (var i=0; i<3; i++) 13223 { 13224 rgb[i] = parseInt(rgb[i], 16); 13225 } 13226 return {'r':rgb[0],'g':rgb[1],'b':rgb[2]}; 13227 }, 13228 13229 /** 13230 * @deprecated 13231 * @use BX.Uri 13232 * @param url 13233 * @param param 13234 * @return {string} 13235 */ 13236 remove_url_param: function(url, param) 13237 { 13238 return BX.Uri.removeParam(url, param); 13239 }, 13240 13241 /* 13242 {'param1': 'value1', 'param2': 'value2'} 13243 */ 13244 /** 13245 * @deprecated 13246 * @use BX.Uri 13247 * @param url 13248 * @param params 13249 * @return {string} 13250 */ 13251 add_url_param: function(url, params) 13252 { 13253 var preparedParams = Object.entries(params).reduce(function(acc, item) { 13254 acc[item[0]] = BX.type.isArray(item[1]) ? item[1].join() : item[1]; 13255 return acc; 13256 }, {}); 13257 13258 return BX.Uri.addParam(url, preparedParams); 13259 }, 13260 13261 /* 13262 {'param1': 'value1', 'param2': 'value2'} 13263 */ 13264 buildQueryString: function(params) 13265 { 13266 var result = ''; 13267 for (var key in params) 13268 { 13269 var value = params[key]; 13270 if(BX.type.isArray(value)) 13271 { 13272 value.forEach(function(valueElement, index) 13273 { 13274 result += encodeURIComponent(key + "[" + index + "]") + "=" + encodeURIComponent(valueElement) + "&"; 13275 }); 13276 } 13277 else 13278 { 13279 result += encodeURIComponent(key) + "=" + encodeURIComponent(value) + "&"; 13280 } 13281 } 13282 13283 if(result.length > 0) 13284 { 13285 result = result.substr(0, result.length - 1); 13286 } 13287 return result; 13288 }, 13289 13290 even: function(digit) 13291 { 13292 return (parseInt(digit) % 2 == 0); 13293 }, 13294 13295 hashCode: function(str) 13296 { 13297 if(!BX.type.isNotEmptyString(str)) 13298 { 13299 return 0; 13300 } 13301 13302 var hash = 0; 13303 for (var i = 0; i < str.length; i++) 13304 { 13305 var c = str.charCodeAt(i); 13306 hash = ((hash << 5) - hash) + c; 13307 hash = hash & hash; 13308 } 13309 return hash; 13310 }, 13311 13312 getRandomString: function (length) 13313 { 13314 return BX.Text.getRandom(length); 13315 }, 13316 13317 number_format: function(number, decimals, dec_point, thousands_sep) 13318 { 13319 var i, j, kw, kd, km, sign = ''; 13320 decimals = Math.abs(decimals); 13321 if (isNaN(decimals) || decimals < 0) 13322 { 13323 decimals = 2; 13324 } 13325 dec_point = dec_point || ','; 13326 if (typeof thousands_sep === 'undefined') 13327 thousands_sep = '.'; 13328 13329 number = (+number || 0).toFixed(decimals); 13330 if (number < 0) 13331 { 13332 sign = '-'; 13333 number = -number; 13334 } 13335 13336 i = parseInt(number, 10) + ''; 13337 j = (i.length > 3 ? i.length % 3 : 0); 13338 13339 km = (j ? i.substr(0, j) + thousands_sep : ''); 13340 kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep); 13341 kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, '0').slice(2) : ''); 13342 13343 return sign + km + kw + kd; 13344 }, 13345 13346 getExtension: function (url) 13347 { 13348 url = url || ""; 13349 var items = url.split("?")[0].split("."); 13350 return items[items.length-1].toLowerCase(); 13351 }, 13352 addObjectToForm: function(object, form, prefix) 13353 { 13354 if(!BX.type.isString(prefix)) 13355 { 13356 prefix = ""; 13357 } 13358 13359 for(var key in object) 13360 { 13361 if(!object.hasOwnProperty(key)) 13362 { 13363 continue; 13364 } 13365 13366 var value = object[key]; 13367 var name = prefix !== "" ? (prefix + "[" + key + "]") : key; 13368 if(BX.type.isArray(value)) 13369 { 13370 var obj = {}; 13371 for(var i = 0; i < value.length; i++) 13372 { 13373 obj[i] = value[i]; 13374 } 13375 13376 BX.util.addObjectToForm(obj, form, name); 13377 } 13378 else if(BX.type.isPlainObject(value)) 13379 { 13380 BX.util.addObjectToForm(value, form, name); 13381 } 13382 else 13383 { 13384 value = BX.type.isFunction(value.toString) ? value.toString() : ""; 13385 if(value !== "") 13386 { 13387 form.appendChild(BX.create("INPUT", { attrs: { type: "hidden", name: name, value: value } })); 13388 } 13389 } 13390 } 13391 }, 13392 13393 observe: function(object, enable) 13394 {
13395 console.error('BX.util.observe: function is no longer supported by browser.'); 13396 return false; 13397 }, 13398 13399 escapeRegExp: function(str) 13400 { 13401 return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); 13402 } 13403 }; 13404 13405 BX.validation = { 13406 checkIfEmail: function(s) 13407 { 13408 var atom = "[=a-z0-9_+~'!$&*^`|#%/?{}-]"; 13409 return (new RegExp('^\\s*'+atom+'+(\\.'+atom+'+)*@([a-z0-9-]+\\.)+[a-z0-9-]{2,20}\\s*$', 'i')).test(s); 13410 }, 13411 checkIfPhone: function(s) 13412 { 13413 var regexp = new RegExp( 13414 typeof(BX.PhoneNumber) === "undefined" 13415 ? BX.PhoneNumber.getValidNumberPattern() 13416 : '^\\s*\\+?\s*[0-9(-)\\s]+\\s*$', 13417 'i' 13418 ); 13419 return regexp.test(s); 13420 } 13421 }; 13422 13423 BX.prop = 13424 { 13425 get: function(object, key, defaultValue) 13426 { 13427 return object && object.hasOwnProperty(key) ? object[key] : defaultValue; 13428 }, 13429 getObject: function(object, key, defaultValue) 13430 { 13431 return object && BX.type.isPlainObject(object[key]) ? object[key] : defaultValue; 13432 }, 13433 getElementNode: function(object, key, defaultValue) 13434 { 13435 return object && BX.type.isElementNode(object[key]) ? object[key] : defaultValue; 13436 }, 13437 getArray: function(object, key, defaultValue) 13438 { 13439 return object && BX.type.isArray(object[key]) ? object[key] : defaultValue; 13440 }, 13441 getFunction: function(object, key, defaultValue) 13442 { 13443 return object && BX.type.isFunction(object[key]) ? object[key] : defaultValue; 13444 }, 13445 getNumber: function(object, key, defaultValue) 13446 { 13447 if(!(object && object.hasOwnProperty(key))) 13448 { 13449 return defaultValue; 13450 } 13451 13452 var value = object[key]; 13453 if(BX.type.isNumber(value)) 13454 { 13455 return value; 13456 } 13457 13458 value = parseFloat(value); 13459 return !isNaN(value) ? value : defaultValue; 13460 }, 13461 getInteger: function(object, key, defaultValue) 13462 { 13463 if(!(object && object.hasOwnProperty(key))) 13464 { 13465 return defaultValue; 13466 } 13467 13468 var value = object[key]; 13469 if(BX.type.isNumber(value)) 13470 { 13471 return value; 13472 } 13473 13474 value = parseInt(value); 13475 return !isNaN(value) ? value : defaultValue; 13476 }, 13477 getBoolean: function(object, key, defaultValue) 13478 { 13479 if(!(object && object.hasOwnProperty(key))) 13480 { 13481 return defaultValue; 13482 } 13483 13484 var value = object[key]; 13485 return (BX.type.isBoolean(value) 13486 ? value 13487 : (BX.type.isString(value) ? (value.toLowerCase() === "true") : !!value) 13488 ); 13489 }, 13490 getString: function(object, key, defaultValue) 13491 { 13492 if(!(object && object.hasOwnProperty(key))) 13493 { 13494 return defaultValue; 13495 } 13496 13497 var value = object[key]; 13498 return BX.type.isString(value) ? value : (value ? value.toString() : ''); 13499 }, 13500 extractDate: function(datetime) 13501 { 13502 if(!BX.type.isDate(datetime)) 13503 { 13504 datetime = new Date(); 13505 } 13506 13507 datetime.setHours(0); 13508 datetime.setMinutes(0); 13509 datetime.setSeconds(0); 13510 datetime.setMilliseconds(0); 13511 13512 return datetime; 13513 } 13514 }; 13515 13516 BX.isNodeInDom = function(node, doc) 13517 { 13518 return node === (doc || document) ? true : 13519 (node.parentNode ? BX.isNodeInDom(node.parentNode) : false); 13520 }; 13521 13522 BX.isNodeHidden = function(node) 13523 { 13524 if (node === document) 13525 return false; 13526 else if (BX.style(node, 'display') == 'none') 13527 return true; 13528 else 13529 return (node.parentNode ? BX.isNodeHidden(node.parentNode) : true); 13530 }; 13531 13532 BX.evalPack = function(code) 13533 { 13534 while (code.length > 0) 13535 { 13536 var c = code.shift(); 13537 13538 if (c.TYPE == 'SCRIPT_EXT' || c.TYPE == 'SCRIPT_SRC') 13539 { 13540 BX.loadScript(c.DATA, function() {BX.evalPack(code)}); 13541 return; 13542 } 13543 else if (c.TYPE == 'SCRIPT') 13544 { 13545 BX.evalGlobal(c.DATA); 13546 } 13547 } 13548 }; 13549 13550 BX.evalGlobal = function(data) 13551 { 13552 if (data) 13553 { 13554 var head = document.getElementsByTagName("head")[0] || document.documentElement, 13555 script = document.createElement("script"); 13556 13557 script.type = "text/javascript"; 13558 13559 if (!BX.browser.IsIE()) 13560 { 13561 script.appendChild(document.createTextNode(data)); 13562 } 13563 else 13564 { 13565 script.text = data; 13566 } 13567 13568 head.insertBefore(script, head.firstChild); 13569 head.removeChild(script); 13570 } 13571 }; 13572 13573 BX.garbage = function(call, thisObject) 13574 { 13575 garbageCollectors.push({callback: call, context: thisObject}); 13576 }; 13577 13578 BX.GetDocElement = function (pDoc) 13579 { 13580 pDoc = pDoc || document; 13581 return (BX.browser.IsDoctype(pDoc) ? pDoc.documentElement : pDoc.body); 13582 }; 13583 13584 BX.scrollTop = function(node, val){ 13585 if(typeof val != 'undefined'){ 13586 13587 if(node == window){ 13588 throw new Error('scrollTop() for window is not implemented'); 13589 }else 13590 node.scrollTop = parseInt(val); 13591 13592 }else{ 13593 13594 if(node == window) 13595 return BX.GetWindowScrollPos().scrollTop; 13596 13597 return node.scrollTop; 13598 } 13599 }; 13600 13601 BX.scrollLeft = function(node, val){ 13602 if(typeof val != 'undefined'){ 13603 13604 if(node == window){ 13605 throw new Error('scrollLeft() for window is not implemented'); 13606 }else 13607 node.scrollLeft = parseInt(val); 13608 13609 }else{ 13610 13611 if(node == window) 13612 return BX.GetWindowScrollPos().scrollLeft; 13613 13614 return node.scrollLeft; 13615 } 13616 }; 13617 13618 BX.hide_object = function(ob) 13619 { 13620 ob = BX(ob); 13621 ob.style.position = 'absolute'; 13622 ob.style.top = '-1000px'; 13623 ob.style.left = '-1000px'; 13624 ob.style.height = '10px'; 13625 ob.style.width = '10px'; 13626 }; 13627 13628 BX.is_relative = function(el) 13629 { 13630 var p = BX.style(el, 'position'); 13631 return p == 'relative' || p == 'absolute'; 13632 }; 13633 13634 BX.is_float = function(el) 13635 { 13636 var p = BX.style(el, 'float'); 13637 return p == 'right' || p == 'left'; 13638 }; 13639 13640 BX.is_fixed = function(el) 13641 { 13642 var p = BX.style(el, 'position'); 13643 return p == 'fixed'; 13644 }; 13645 13646 BX.width = function(node, val){ 13647 if(typeof val != 'undefined') 13648 BX.style(node, 'width', parseInt(val)+'px'); 13649 else{ 13650 13651 if(node == window) 13652 return window.innerWidth; 13653 13654 //return parseInt(BX.style(node, 'width')); 13655 return BX.pos(node).width; 13656 } 13657 }; 13658 13659 BX.height = function(node, val){ 13660 if(typeof val != 'undefined') 13661 BX.style(node, 'height', parseInt(val)+'px'); 13662 else{ 13663 13664 if(node == window) 13665 return window.innerHeight; 13666 13667 //return parseInt(BX.style(node, 'height')); 13668 return BX.pos(node).height; 13669 } 13670 }; 13671 13672 BX.align = function(pos, w, h, type) 13673 { 13674 if (type) 13675 type = type.toLowerCase(); 13676 else 13677 type = ''; 13678 13679 var pDoc = document; 13680 if (BX.type.isElementNode(pos)) 13681 { 13682 pDoc = pos.ownerDocument; 13683 pos = BX.pos(pos); 13684 } 13685 13686 var x = pos["left"], y = pos["bottom"]; 13687 13688 var scroll = BX.GetWindowScrollPos(pDoc); 13689 var size = BX.GetWindowInnerSize(pDoc); 13690 13691 if((size.innerWidth + scroll.scrollLeft) - (pos["left"] + w) < 0) 13692 { 13693 if(pos["right"] - w >= 0 ) 13694 x = pos["right"] - w; 13695 else 13696 x = scroll.scrollLeft; 13697 } 13698
13699 if(((size.innerHeight + scroll.scrollTop) - (pos["bottom"] + h) < 0) || ~type.indexOf('top')) 13700 { 13701 if(pos["top"] - h >= 0 || ~type.indexOf('top')) 13702 y = pos["top"] - h; 13703 else 13704 y = scroll.scrollTop; 13705 } 13706 13707 return {'left':x, 'top':y}; 13708 }; 13709 13710 BX.scrollToNode = function(node) 13711 { 13712 var obNode = BX(node); 13713 13714 if (obNode.scrollIntoView) 13715 obNode.scrollIntoView(true); 13716 else 13717 { 13718 var arNodePos = BX.pos(obNode); 13719 window.scrollTo(arNodePos.left, arNodePos.top); 13720 } 13721 }; 13722 13723 /* non-xhr loadings */ 13724 BX.showWait = function(node, msg) 13725 { 13726 node = BX(node) || document.body || document.documentElement; 13727 msg = msg || BX.message('JS_CORE_LOADING'); 13728 13729 var container_id = node.id || Math.random(); 13730 13731 var obMsg = node.bxmsg = document.body.appendChild(BX.create('DIV', { 13732 props: { 13733 id: 'wait_' + container_id 13734 }, 13735 style: { 13736 background: 'url("/bitrix/js/main/core/images/wait.gif") no-repeat scroll 10px center #fcf7d1', 13737 border: '1px solid #E1B52D', 13738 color: 'black', 13739 fontFamily: 'Verdana,Arial,sans-serif', 13740 fontSize: '11px', 13741 padding: '10px 30px 10px 37px', 13742 position: 'absolute', 13743 textAlign:'center' 13744 }, 13745 text: msg 13746 })); 13747 13748 BX.ZIndexManager.register(obMsg); 13749 BX.ZIndexManager.bringToFront(obMsg); 13750 13751 setTimeout(BX.delegate(_adjustWait, node), 10); 13752 13753 lastWait[lastWait.length] = obMsg; 13754 return obMsg; 13755 }; 13756 13757 BX.closeWait = function(node, obMsg) 13758 { 13759 if(node && !obMsg) 13760 obMsg = node.bxmsg; 13761 if(node && !obMsg && BX.hasClass(node, 'bx-core-waitwindow')) 13762 obMsg = node; 13763 if(node && !obMsg) 13764 obMsg = BX('wait_' + node.id); 13765 if(!obMsg) 13766 obMsg = lastWait.pop(); 13767 13768 if (obMsg && obMsg.parentNode) 13769 { 13770 for (var i=0,len=lastWait.length;i<len;i++) 13771 { 13772 if (obMsg == lastWait[i]) 13773 { 13774 lastWait = BX.util.deleteFromArray(lastWait, i); 13775 break; 13776 } 13777 } 13778 13779 BX.ZIndexManager.unregister(obMsg); 13780 obMsg.parentNode.removeChild(obMsg); 13781 if (node) node.bxmsg = null; 13782 BX.cleanNode(obMsg, true); 13783 } 13784 }; 13785 13786 BX.setJSList = function(scripts) 13787 { 13788 if (BX.type.isArray(scripts)) 13789 { 13790 scripts = scripts.map(function(script) { 13791 return normalizeUrl(script) 13792 }); 13793 13794 jsList = jsList.concat(scripts); 13795 } 13796 }; 13797 13798 BX.getJSList = function() 13799 { 13800 initJsList(); 13801 return jsList; 13802 }; 13803 13804 BX.setCSSList = function(cssFiles) 13805 { 13806 if (BX.type.isArray(cssFiles)) 13807 { 13808 cssFiles = cssFiles.map(function(cssFile) { 13809 return normalizeUrl(cssFile); 13810 }); 13811 13812 cssList = cssList.concat(cssFiles); 13813 } 13814 }; 13815 13816 BX.getCSSList = function() 13817 { 13818 initCssList(); 13819 return cssList; 13820 }; 13821 13822 BX.getJSPath = function(js) 13823 { 13824 return js.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 13825 }; 13826 13827 BX.getCSSPath = function(css) 13828 { 13829 return css.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 13830 }; 13831 13832 BX.getCDNPath = function(path) 13833 { 13834 return path; 13835 }; 13836 13837 BX.loadScript = function(script, callback, doc) 13838 { 13839 if (BX.type.isString(script)) 13840 { 13841 script = [script]; 13842 } 13843 13844 return BX.load(script, callback, doc); 13845 }; 13846 13847 BX.loadCSS = function(css, doc, win) 13848 { 13849 if (BX.type.isString(css)) 13850 { 13851 css = [css]; 13852 } 13853 13854 if (BX.type.isArray(css)) 13855 { 13856 css = css.map(function(url) { 13857 return { url: url, ext: "css" } 13858 }); 13859 13860 BX.load(css, null, doc); 13861 } 13862 }; 13863 13864 const LOADING = 3; 13865 const LOADED = 4; 13866 const assets = {}; 13867 const loadingAssetCallbacks = {}; 13868 13869 BX.load = function(items, callback, doc) 13870 { 13871 if (!BX.isReady) 13872 { 13873 var _args = arguments; 13874 BX.ready(function() { 13875 BX.load.apply(this, _args); 13876 }); 13877 13878 return null; 13879 } 13880 13881 doc = doc || document; 13882 13883 callback = BX.Type.isFunction(callback) ? callback : () => {}; 13884 13885 return loadAsync(items, callback, doc); 13886 }; 13887 13888 function loadAsync(items, callback, doc) 13889 { 13890 if (!BX.type.isArray(items)) 13891 { 13892 callback(); 13893 13894 return; 13895 } 13896 13897 function onLoad() 13898 { 13899 const nextAsset = queue.shift(); 13900 if (nextAsset) 13901 { 13902 load(nextAsset, onLoad, doc); 13903 } 13904 else if (allLoaded()) 13905 { 13906 callback(); 13907 } 13908 } 13909 13910 function allLoaded() 13911 { 13912 for (const name in assetMap) 13913 { 13914 if (assetMap[name].state !== LOADED) 13915 { 13916 return false; 13917 } 13918 } 13919 13920 return true; 13921 } 13922 13923 const queue = []; 13924 const assetMap = {}; 13925 items.forEach(item => { 13926 const asset = getAsset(item); 13927 if (asset && asset.state !== LOADED) 13928 { 13929 queue.push(asset); 13930 assetMap[asset.name] = asset; 13931 } 13932 }); 13933 13934 if (queue.length > 0) 13935 {
13936 const maxParallelLoads = 6; 13937 const parallelLoads = Math.min(queue.length, maxParallelLoads); 13938 const firstPackage = queue.splice(0, parallelLoads); 13939 firstPackage.forEach(asset => { 13940 load(asset, onLoad, doc); 13941 }); 13942 } 13943 else 13944 { 13945 callback(); 13946 } 13947 } 13948 13949 function load(asset, callback, doc) 13950 { 13951 callback = callback || BX.DoNothing; 13952 13953 if (asset.state === LOADED) 13954 { 13955 callback(); 13956 return; 13957 } 13958 13959 if (asset.state === LOADING) 13960 { 13961 if (!BX.Type.isArray(loadingAssetCallbacks[asset.name])) 13962 { 13963 loadingAssetCallbacks[asset.name] = []; 13964 } 13965 13966 loadingAssetCallbacks[asset.name].push(callback); 13967 13968 return; 13969 } 13970 13971 asset.state = LOADING; 13972 13973 loadAsset( 13974 asset, 13975 function () { 13976 asset.state = LOADED; 13977 callback(); 13978 if (BX.Type.isArrayFilled(loadingAssetCallbacks[asset.name])) 13979 { 13980 for (const cb of loadingAssetCallbacks[asset.name]) 13981 { 13982 cb(); 13983 } 13984 } 13985 13986 delete loadingAssetCallbacks[asset.name]; 13987 }, 13988 doc 13989 ); 13990 } 13991 13992 function loadAsset(asset, callback, doc) 13993 { 13994 callback = callback || BX.DoNothing; 13995 13996 function error(event) 13997 { 13998 window.clearTimeout(asset.errorTimeout); 13999 window.clearTimeout(asset.cssTimeout); 14000 ele.onload = ele.onreadystatechange = ele.onerror = null; 14001 callback(); 14002 } 14003 14004 function process(event) 14005 { 14006 event = event || window.event; 14007 if (event.type === "load" || (/loaded|complete/.test(ele.readyState) && (!doc.documentMode || doc.documentMode < 9))) 14008 { 14009 window.clearTimeout(asset.errorTimeout); 14010 window.clearTimeout(asset.cssTimeout); 14011 ele.onload = ele.onreadystatechange = ele.onerror = null; 14012 callback(); 14013 } 14014 } 14015 14016 function isCssLoaded() 14017 { 14018 if (asset.state !== LOADED && asset.cssRetries <= 20) 14019 { 14020 for (var i = 0, l = doc.styleSheets.length; i < l; i++) 14021 { 14022 if (doc.styleSheets[i].href === ele.href) 14023 { 14024 process({"type": "load"}); 14025 return; 14026 } 14027 } 14028 14029 asset.cssRetries++; 14030 asset.cssTimeout = window.setTimeout(isCssLoaded, 250); 14031 } 14032 } 14033 14034 let ele = null; 14035 const ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 14036 14037 if (ext === "css") 14038 { 14039 ele = doc.createElement("link"); 14040 ele.type = "text/" + (asset.type || "css"); 14041 ele.rel = "stylesheet"; 14042 ele.href = asset.url; 14043 14044 asset.cssRetries = 0; 14045 asset.cssTimeout = window.setTimeout(isCssLoaded, 500); 14046 } 14047 else 14048 { 14049 ele = doc.createElement("script"); 14050 ele.type = "text/" + (asset.type || "javascript"); 14051 ele.src = asset.url; 14052 } 14053 14054 ele.onload = ele.onreadystatechange = process; 14055 ele.onerror = error; 14056 14057 ele.async = false; 14058 ele.defer = false; 14059 14060 asset.errorTimeout = window.setTimeout(function () { 14061 error({type: "timeout"}); 14062 }, 7000); 14063 14064 if (ext === "css") 14065 { 14066 cssList.push(normalizeMinUrl(normalizeUrl(asset.url))); 14067 } 14068 else 14069 { 14070 jsList.push(normalizeMinUrl(normalizeUrl(asset.url))); 14071 } 14072 14073 let templateLink = null; 14074 const head = doc.head || doc.getElementsByTagName("head")[0]; 14075 if (ext === "css" && (templateLink = getTemplateLink(head)) !== null) 14076 { 14077 templateLink.parentNode.insertBefore(ele, templateLink); 14078 } 14079 else 14080 { 14081 head.insertBefore(ele, head.lastChild); 14082 } 14083 } 14084 14085 function getAsset(item) 14086 { 14087 var asset = {}; 14088 if (typeof item === "object") 14089 { 14090 asset = item; 14091 asset.name = asset.name ? asset.name : BX.util.hashCode(item.url); 14092 } 14093 else 14094 { 14095 asset = { name: BX.util.hashCode(item), url : item }; 14096 } 14097 14098 var ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 14099 if ((ext === "css" && isCssLoaded(asset.url)) || isScriptLoaded(asset.url)) 14100 { 14101 asset.state = LOADED; 14102 } 14103 14104 var existing = assets[asset.name]; 14105 if (existing && existing.url === asset.url) 14106 { 14107 return existing; 14108 } 14109 14110 assets[asset.name] = asset; 14111 14112 return asset; 14113 } 14114 14115 function normalizeUrl(url) 14116 { 14117 if (!BX.type.isNotEmptyString(url)) 14118 { 14119 return ""; 14120 } 14121 14122 url = BX.getJSPath(url); 14123 url = url.replace(/\?[0-9]*$/, ""); 14124 14125 return url; 14126 } 14127 14128 function normalizeMinUrl(url) 14129 { 14130 if (!BX.type.isNotEmptyString(url)) 14131 { 14132 return ""; 14133 } 14134 14135 var minPos = url.indexOf(".min"); 14136 return minPos >= 0 ? url.substr(0, minPos) + url.substr(minPos + 4) : url; 14137 } 14138 14139 function isCssLoaded(fileSrc) 14140 { 14141 initCssList(); 14142 14143 fileSrc = normalizeUrl(fileSrc); 14144 var fileSrcMin = normalizeMinUrl(fileSrc); 14145 14146 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, cssList)) || BX.util.in_array(fileSrc, cssList); 14147 } 14148 14149 function initCssList() 14150 { 14151 if(!cssInit) 14152 { 14153 var linksCol = document.getElementsByTagName('link'); 14154 14155 if(!!linksCol && linksCol.length > 0) 14156 { 14157 for(var i = 0; i < linksCol.length; i++) 14158 { 14159 var href = linksCol[i].getAttribute('href'); 14160 if (BX.type.isNotEmptyString(href)) 14161 { 14162 href = normalizeMinUrl(normalizeUrl(href)); 14163 cssList.push(href); 14164 } 14165 } 14166 } 14167 cssInit = true; 14168 } 14169 } 14170 14171 function getTemplateLink(head) 14172 { 14173 var findLink = function(tag) 14174 { 14175 var links = head.getElementsByTagName(tag); 14176 for (var i = 0, length = links.length; i < length; i++) 14177 { 14178 var templateStyle = links[i].getAttribute("data-template-style"); 14179 if (BX.type.isNotEmptyString(templateStyle) && templateStyle == "true") 14180 { 14181 return links[i]; 14182 } 14183 } 14184 14185 return null; 14186 }; 14187 14188 var link = findLink("link"); 14189 if (link === null) 14190 { 14191 link = findLink("style"); 14192 } 14193 14194 return link; 14195 } 14196 14197 function isScriptLoaded(fileSrc) 14198 { 14199 initJsList(); 14200 14201 fileSrc = normalizeUrl(fileSrc); 14202 var fileSrcMin = normalizeMinUrl(fileSrc); 14203 14204 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, jsList)) || BX.util.in_array(fileSrc, jsList); 14205 } 14206 14207 function initJsList() 14208 { 14209 if(!jsInit) 14210 { 14211 var scriptCol = document.getElementsByTagName('script'); 14212 14213 if(!!scriptCol && scriptCol.length > 0) 14214 { 14215 for(var i=0; i<scriptCol.length; i++) 14216 { 14217 var src = scriptCol[i].getAttribute('src'); 14218 14219 if (BX.type.isNotEmptyString(src)) 14220 { 14221 src = normalizeMinUrl(normalizeUrl(src)); 14222 jsList.push(src); 14223 } 14224 } 14225 } 14226 jsInit = true; 14227 } 14228 } 14229 14230 function reloadInternal(back_url, bAddClearCache) 14231 { 14232 if (back_url === true) 14233 { 14234 bAddClearCache = true; 14235 back_url = null; 14236 } 14237 14238 var topWindow = (function() { 14239 if (BX.PageObject && BX.PageObject.getRootWindow) 14240 { 14241 return BX.PageObject.getRootWindow(); 14242 } 14243 14244 return window.top; 14245 })(); 14246 var new_href = back_url || topWindow.location.href; 14247 14248 var hashpos = new_href.indexOf('#'), hash = ''; 14249 14250 if (hashpos != -1) 14251 { 14252 hash = new_href.substr(hashpos); 14253 new_href = new_href.substr(0, hashpos); 14254 } 14255 14256 if (bAddClearCache && new_href.indexOf('clear_cache=Y') < 0) 14257 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + 'clear_cache=Y'; 14258 14259 if (hash) 14260 { 14261 // hack for clearing cache in ajax mode components with history emulation 14262 if (bAddClearCache && (hash.substr(0, 5) == 'view/' || hash.substr(0, 6) == '#view/') && hash.indexOf('clear_cache%3DY') < 0) 14263 hash += (hash.indexOf('%3F') == -1 ? '%3F' : '%26') + 'clear_cache%3DY'; 14264 14265 new_href = new_href.replace(/(\?|\&)_r=[\d]*/, ''); 14266 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + '_r='+Math.round(Math.random()*10000) + hash; 14267 } 14268 14269 topWindow.location.href = new_href; 14270 } 14271 14272 BX.reload = function(back_url, bAddClearCache) 14273 { 14274 if (window !== window.top) 14275 { 14276 BX.Runtime 14277 .loadExtension('main.pageobject') 14278 .then(function() { 14279 reloadInternal(back_url, bAddClearCache); 14280 }); 14281 } 14282 else 14283 { 14284 reloadInternal(back_url, bAddClearCache); 14285 } 14286 }; 14287 14288 BX.clearCache = function() 14289 { 14290 BX.showWait(); 14291 BX.reload(true); 14292 }; 14293 14294 BX.template = function(tpl, callback, bKillTpl) 14295 { 14296 BX.ready(function() { 14297 _processTpl(BX(tpl), callback, bKillTpl); 14298 }); 14299 }; 14300 14301 BX.isAmPmMode = function(returnConst) 14302 { 14303 if (returnConst === true) 14304 { 14305 return BX.message.AMPM_MODE; 14306 } 14307 return BX.message.AMPM_MODE !== false; 14308 }; 14309 14310 BX.formatDate = function(date, format) 14311 { 14312 date = date || new Date(); 14313 14314 var bTime = date.getHours() || date.getMinutes() || date.getSeconds(), 14315 str = !!format 14316 ? format : 14317 (bTime ? BX.message('FORMAT_DATETIME') : BX.message('FORMAT_DATE') 14318 ); 14319 14320 return str.replace(/YYYY/ig, date.getFullYear()) 14321 .replace(/MMMM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14322 .replace(/MM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14323 .replace(/DD/ig, BX.util.str_pad_left(date.getDate().toString(), 2, '0')) 14324 .replace(/HH/ig, BX.util.str_pad_left(date.getHours().toString(), 2, '0')) 14325 .replace(/MI/ig, BX.util.str_pad_left(date.getMinutes().toString(), 2, '0')) 14326 .replace(/SS/ig, BX.util.str_pad_left(date.getSeconds().toString(), 2, '0')); 14327 }; 14328 BX.formatName = function(user, template, login) 14329 { 14330 user = user || {}; 14331 template = (template || ''); 14332 var replacement = { 14333 TITLE : (user["TITLE"] || ''), 14334 NAME : (user["NAME"] || ''),
14335 LAST_NAME : (user["LAST_NAME"] || ''), 14336 SECOND_NAME : (user["SECOND_NAME"] || ''), 14337 LOGIN : (user["LOGIN"] || ''), 14338 NAME_SHORT : user["NAME"] ? user["NAME"].substr(0, 1) + '.' : '', 14339 LAST_NAME_SHORT : user["LAST_NAME"] ? user["LAST_NAME"].substr(0, 1) + '.' : '', 14340 SECOND_NAME_SHORT : user["SECOND_NAME"] ? user["SECOND_NAME"].substr(0, 1) + '.' : '', 14341 EMAIL : (user["EMAIL"] || ''), 14342 ID : (user["ID"] || ''), 14343 NOBR : "", 14344 '/NOBR' : "" 14345 }, result = template; 14346 for (var ii in replacement) 14347 { 14348 if (replacement.hasOwnProperty(ii)) 14349 { 14350 result = result.replace("#" + ii+ "#", replacement[ii]) 14351 } 14352 } 14353 result = result.replace(/([\s]+)/gi, " ").trim(); 14354 if (result == "") 14355 { 14356 result = (login == "Y" ? replacement["LOGIN"] : ""); 14357 result = (result == "" ? "Noname" : result); 14358 } 14359 return result; 14360 }; 14361 14362 BX.getNumMonth = function(month) 14363 { 14364 var wordMonthCut = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; 14365 var wordMonth = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']; 14366 14367 var q = month.toUpperCase(); 14368 for (i = 1; i <= 12; i++) 14369 { 14370 if (q == BX.message('MON_'+i).toUpperCase() || q == BX.message('MONTH_'+i).toUpperCase() || q == wordMonthCut[i-1].toUpperCase() || q == wordMonth[i-1].toUpperCase()) 14371 { 14372 return i; 14373 } 14374 } 14375 return month; 14376 }; 14377 14378 BX.parseDate = function(str, bUTC, formatDate, formatDatetime) 14379 { 14380 if (BX.type.isNotEmptyString(str)) 14381 { 14382 if (!formatDate) 14383 formatDate = BX.message('FORMAT_DATE'); 14384 if (!formatDatetime) 14385 formatDatetime = BX.message('FORMAT_DATETIME'); 14386 14387 var regMonths = ''; 14388 for (i = 1; i <= 12; i++) 14389 { 14390 regMonths = regMonths + '|' + BX.message('MON_'+i); 14391 } 14392
14393 var expr = new RegExp('([0-9]+|[a-z]+' + regMonths + ')', 'ig'); 14394 var aDate = str.match(expr), 14395 aFormat = formatDate.match(/(DD|MI|MMMM|MM|M|YYYY)/ig), 14396 i, cnt, 14397 aDateArgs=[], aFormatArgs=[], 14398 aResult={}; 14399 14400 if (!aDate) 14401 return null; 14402 14403 if(aDate.length > aFormat.length) 14404 { 14405 aFormat = formatDatetime.match(/(DD|MI|MMMM|MM|M|YYYY|HH|H|SS|TT|T|GG|G)/ig); 14406 } 14407 14408 for(i = 0, cnt = aDate.length; i < cnt; i++) 14409 { 14410 if(BX.util.trim(aDate[i]) != '') 14411 { 14412 aDateArgs[aDateArgs.length] = aDate[i]; 14413 } 14414 } 14415 14416 for(i = 0, cnt = aFormat.length; i < cnt; i++) 14417 { 14418 if(BX.util.trim(aFormat[i]) != '') 14419 { 14420 aFormatArgs[aFormatArgs.length] = aFormat[i]; 14421 } 14422 } 14423 14424 14425 var m = BX.util.array_search('MMMM', aFormatArgs); 14426 if (m > 0) 14427 { 14428 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 14429 aFormatArgs[m] = "MM"; 14430 } 14431 else 14432 { 14433 m = BX.util.array_search('M', aFormatArgs); 14434 if (m > 0) 14435 { 14436 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 14437 aFormatArgs[m] = "MM"; 14438 } 14439 } 14440 14441 for(i = 0, cnt = aFormatArgs.length; i < cnt; i++) 14442 { 14443 var k = aFormatArgs[i].toUpperCase(); 14444 aResult[k] = k == 'T' || k == 'TT' ? aDateArgs[i] : parseInt(aDateArgs[i], 10); 14445 } 14446 14447 if(aResult['DD'] > 0 && aResult['MM'] > 0 && aResult['YYYY'] > 0) 14448 { 14449 var d = new Date(); 14450 14451 if(bUTC) 14452 { 14453 d.setUTCDate(1); 14454 d.setUTCFullYear(aResult['YYYY']); 14455 d.setUTCMonth(aResult['MM'] - 1); 14456 d.setUTCDate(aResult['DD']); 14457 d.setUTCHours(0, 0, 0, 0); 14458 } 14459 else 14460 { 14461 d.setDate(1); 14462 d.setFullYear(aResult['YYYY']); 14463 d.setMonth(aResult['MM'] - 1); 14464 d.setDate(aResult['DD']); 14465 d.setHours(0, 0, 0, 0); 14466 } 14467 14468 if( 14469 (!isNaN(aResult['HH']) || !isNaN(aResult['GG']) || !isNaN(aResult['H']) || !isNaN(aResult['G'])) 14470 && !isNaN(aResult['MI']) 14471 ) 14472 { 14473 if (!isNaN(aResult['H']) || !isNaN(aResult['G'])) 14474 { 14475 var bPM = (aResult['T']||aResult['TT']||'am').toUpperCase()=='PM'; 14476 var h = parseInt(aResult['H']||aResult['G']||0, 10); 14477 if(bPM) 14478 { 14479 aResult['HH'] = h + (h == 12 ? 0 : 12); 14480 } 14481 else 14482 { 14483 aResult['HH'] = h < 12 ? h : 0; 14484 } 14485 } 14486 else 14487 { 14488 aResult['HH'] = parseInt(aResult['HH']||aResult['GG']||0, 10); 14489 } 14490 14491 if (isNaN(aResult['SS'])) 14492 aResult['SS'] = 0; 14493 14494 if(bUTC) 14495 { 14496 d.setUTCHours(aResult['HH'], aResult['MI'], aResult['SS']); 14497 } 14498 else 14499 { 14500 d.setHours(aResult['HH'], aResult['MI'], aResult['SS']); 14501 } 14502 } 14503 14504 return d; 14505 } 14506 } 14507 14508 return null; 14509 }; 14510 14511 BX.selectUtils = 14512 { 14513 addNewOption: function(oSelect, opt_value, opt_name, do_sort, check_unique) 14514 { 14515 oSelect = BX(oSelect); 14516 if(oSelect) 14517 { 14518 var n = oSelect.length; 14519 if(check_unique !== false) 14520 { 14521 for(var i=0;i<n;i++) 14522 { 14523 if(oSelect[i].value==opt_value) 14524 { 14525 return; 14526 } 14527 } 14528 } 14529 14530 oSelect.options[n] = new Option(opt_name, opt_value, false, false); 14531 } 14532 14533 if(do_sort === true) 14534 { 14535 this.sortSelect(oSelect); 14536 } 14537 }, 14538 14539 deleteOption: function(oSelect, opt_value) 14540 { 14541 oSelect = BX(oSelect); 14542 if(oSelect) 14543 { 14544 for(var i=0;i<oSelect.length;i++) 14545 { 14546 if(oSelect[i].value==opt_value) 14547 { 14548 oSelect.remove(i); 14549 break; 14550 } 14551 } 14552 } 14553 }, 14554 14555 deleteSelectedOptions: function(oSelect) 14556 { 14557 oSelect = BX(oSelect); 14558 if(oSelect) 14559 { 14560 var i=0; 14561 while(i<oSelect.length) 14562 { 14563 if(oSelect[i].selected) 14564 { 14565 oSelect[i].selected=false; 14566 oSelect.remove(i); 14567 } 14568 else 14569 { 14570 i++; 14571 } 14572 } 14573 } 14574 }, 14575 14576 deleteAllOptions: function(oSelect) 14577 { 14578 oSelect = BX(oSelect); 14579 if(oSelect) 14580 { 14581 for(var i=oSelect.length-1; i>=0; i--) 14582 { 14583 oSelect.remove(i); 14584 } 14585 } 14586 }, 14587 14588 optionCompare: function(record1, record2) 14589 { 14590 var value1 = record1.optText.toLowerCase(); 14591 var value2 = record2.optText.toLowerCase(); 14592 if (value1 > value2) return(1); 14593 if (value1 < value2) return(-1); 14594 return(0); 14595 }, 14596 14597 sortSelect: function(oSelect) 14598 { 14599 oSelect = BX(oSelect); 14600 if(oSelect) 14601 { 14602 var myOptions = []; 14603 var n = oSelect.options.length; 14604 var i; 14605 for (i=0;i<n;i++) 14606 { 14607 myOptions[i] = { 14608 optText:oSelect[i].text, 14609 optValue:oSelect[i].value 14610 }; 14611 } 14612 myOptions.sort(this.optionCompare); 14613 oSelect.length=0; 14614 n = myOptions.length; 14615 for(i=0;i<n;i++) 14616 { 14617 oSelect[i] = new Option(myOptions[i].optText, myOptions[i].optValue, false, false); 14618 } 14619 } 14620 }, 14621 14622 selectAllOptions: function(oSelect) 14623 { 14624 oSelect = BX(oSelect); 14625 if(oSelect) 14626 { 14627 var n = oSelect.length; 14628 for(var i=0;i<n;i++) 14629 { 14630 oSelect[i].selected=true; 14631 } 14632 } 14633 }, 14634 14635 selectOption: function(oSelect, opt_value) 14636 { 14637 oSelect = BX(oSelect); 14638 if(oSelect) 14639 { 14640 var n = oSelect.length; 14641 for(var i=0;i<n;i++) 14642 { 14643 oSelect[i].selected = (oSelect[i].value == opt_value); 14644 } 14645 } 14646 }, 14647 14648 addSelectedOptions: function(oSelect, to_select_id, check_unique, do_sort) 14649 { 14650 oSelect = BX(oSelect); 14651 if(!oSelect) 14652 return; 14653 var n = oSelect.length; 14654 for(var i=0; i<n; i++) 14655 if(oSelect[i].selected) 14656 this.addNewOption(to_select_id, oSelect[i].value, oSelect[i].text, do_sort, check_unique); 14657 }, 14658 14659 moveOptionsUp: function(oSelect) 14660 { 14661 oSelect = BX(oSelect); 14662 if(!oSelect) 14663 return; 14664 var n = oSelect.length; 14665 for(var i=0; i<n; i++) 14666 { 14667 if(oSelect[i].selected && i>0 && oSelect[i-1].selected == false) 14668 { 14669 var option = new Option(oSelect[i].text, oSelect[i].value); 14670 oSelect[i] = new Option(oSelect[i-1].text, oSelect[i-1].value); 14671 oSelect[i].selected = false;
14672 oSelect[i-1] = option; 14673 oSelect[i-1].selected = true; 14674 } 14675 } 14676 }, 14677 14678 moveOptionsDown: function(oSelect) 14679 { 14680 oSelect = BX(oSelect); 14681 if(!oSelect) 14682 return; 14683 var n = oSelect.length; 14684 for(var i=n-1; i>=0; i--) 14685 { 14686 if(oSelect[i].selected && i<n-1 && oSelect[i+1].selected == false) 14687 { 14688 var option = new Option(oSelect[i].text, oSelect[i].value); 14689 oSelect[i] = new Option(oSelect[i+1].text, oSelect[i+1].value); 14690 oSelect[i].selected = false; 14691 oSelect[i+1] = option; 14692 oSelect[i+1].selected = true; 14693 } 14694 } 14695 } 14696 }; 14697 14698 BX.getEventTarget = function(e) 14699 { 14700 if(e.target) 14701 { 14702 return e.target; 14703 } 14704 else if(e.srcElement) 14705 { 14706 return e.srcElement; 14707 } 14708 return null; 14709 }; 14710 14711 BX.convert = { 14712 toNumber: function(value) 14713 { 14714 if(BX.type.isNumber(value)) 14715 { 14716 return value; 14717 } 14718 14719 value = Number(value); 14720 return !isNaN(value) ? value : 0; 14721 }, 14722 nodeListToArray: function(nodes) 14723 { 14724 try 14725 { 14726 return (Array.prototype.slice.call(nodes, 0)); 14727 } 14728 catch (ex) 14729 { 14730 var ary = []; 14731 for(var i = 0, l = nodes.length; i < l; i++) 14732 { 14733 ary.push(nodes[i]); 14734 } 14735 return ary; 14736 } 14737 } 14738 }; 14739 14740 /******* HINT ***************/ 14741// if function has 2 params - the 2nd one is hint html. otherwise hint_html is third and hint_title - 2nd; 14742// '<div onmouseover="BX.hint(this, 'This is <b>Hint</b>')"'>; 14743// BX.hint(el, 'This is <b>Hint</b>') - this won't work, use constructor 14744 BX.hint = function(el, hint_title, hint_html, hint_id) 14745 { 14746 if (null == hint_html) 14747 { 14748 hint_html = hint_title; 14749 hint_title = ''; 14750 } 14751 14752 if (null == el.BXHINT) 14753 { 14754 el.BXHINT = new BX.CHint({ 14755 parent: el, hint: hint_html, title: hint_title, id: hint_id 14756 }); 14757 el.BXHINT.Show(); 14758 } 14759 }; 14760 14761 BX.hint_replace = function(el, hint_title, hint_html) 14762 { 14763 if (null == hint_html) 14764 { 14765 hint_html = hint_title; 14766 hint_title = ''; 14767 } 14768 14769 if (!el || !el.parentNode || !hint_html) 14770 return null; 14771 14772 var obHint = new BX.CHint({ 14773 hint: hint_html, 14774 title: hint_title 14775 }); 14776 14777 obHint.CreateParent(); 14778 14779 el.parentNode.insertBefore(obHint.PARENT, el); 14780 el.parentNode.removeChild(el); 14781 14782 obHint.PARENT.style.marginLeft = '5px'; 14783 14784 return el; 14785 }; 14786 14787 BX.CHint = function(params) 14788 { 14789 if (BX.CHint.cssLoaded === false) 14790 { 14791 BX.load(['/bitrix/js/main/core/css/core_hint.css']); 14792 BX.CHint.cssLoaded = true; 14793 } 14794 14795 this.PARENT = BX(params.parent); 14796 14797 this.HINT = params.hint; 14798 this.HINT_TITLE = params.title; 14799 14800 this.PARAMS = {}; 14801 for (var i in this.defaultSettings) 14802 { 14803 if (null == params[i]) 14804 this.PARAMS[i] = this.defaultSettings[i]; 14805 else 14806 this.PARAMS[i] = params[i]; 14807 } 14808 14809 if (null != params.id) 14810 this.ID = params.id; 14811 14812 this.timer = null; 14813 this.bInited = false; 14814 this.msover = true; 14815 14816 if (this.PARAMS.showOnce) 14817 { 14818 this.__show(); 14819 this.msover = false; 14820 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14821 } 14822 else if (this.PARENT) 14823 { 14824 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14825 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14826 } 14827 }; 14828 14829 BX.CHint.cssLoaded = false; 14830 14831 BX.CHint.openHints = new Set(); 14832 14833 BX.CHint.globalDisabled = false; 14834 14835 BX.CHint.handleMenuOpen = function() { 14836 BX.CHint.globalDisabled = true; 14837 14838 BX.CHint.openHints.forEach(function(hint) { 14839 hint.__hide_immediately(); 14840 }); 14841 }; 14842 14843 BX.CHint.handleMenuClose = function() { 14844 BX.CHint.globalDisabled = false; 14845 }; 14846 14847 BX.addCustomEvent('onMenuOpen', BX.CHint.handleMenuOpen); 14848 BX.addCustomEvent('onMenuClose', BX.CHint.handleMenuClose); 14849 14850 BX.CHint.prototype.defaultSettings = { 14851 show_timeout: 1000, 14852 hide_timeout: 500, 14853 dx: 2, 14854 showOnce: false, 14855 preventHide: true, 14856 min_width: 250 14857 }; 14858 14859 BX.CHint.prototype.CreateParent = function(element, params) 14860 { 14861 if (this.PARENT) 14862 { 14863 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14864 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14865 } 14866 14867 if (!params) params = {}; 14868 var type = 'icon'; 14869 14870 if (params.type && (params.type == "link" || params.type == "icon")) 14871 type = params.type; 14872 14873 if (element) 14874 type = "element";
14875 14876 if (type == "icon") 14877 { 14878 element = BX.create('IMG', { 14879 props: { 14880 src: params.iconSrc 14881 ? params.iconSrc 14882 : "/bitrix/js/main/core/images/hint.gif" 14883 } 14884 }); 14885 } 14886 else if (type == "link") 14887 { 14888 element = BX.create("A", { 14889 props: {href: 'javascript:void(0)'}, 14890 html: '[?]' 14891 }); 14892 } 14893 14894 this.PARENT = element; 14895 14896 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14897 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14898 14899 return this.PARENT; 14900 }; 14901 14902 BX.CHint.prototype.Show = function() 14903 { 14904 this.msover = true; 14905 14906 if (null != this.timer) 14907 clearTimeout(this.timer); 14908 14909 this.timer = setTimeout(BX.proxy(this.__show, this), this.PARAMS.show_timeout); 14910 }; 14911 14912 BX.CHint.prototype.Hide = function() 14913 { 14914 this.msover = false; 14915 14916 if (null != this.timer) 14917 clearTimeout(this.timer); 14918 14919 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14920 }; 14921 14922 BX.CHint.prototype.__show = function() 14923 { 14924 if (!this.msover || this.disabled || BX.CHint.globalDisabled) return; 14925 if (!this.bInited) this.Init(); 14926 14927 if (this.prepareAdjustPos()) 14928 { 14929 this.DIV.style.display = 'block'; 14930 BX.ZIndexManager.bringToFront(this.DIV); 14931 14932 this.adjustPos(); 14933 14934 BX.CHint.openHints.add(this); 14935 14936 BX.bind(window, 'scroll', BX.proxy(this.__onscroll, this)); 14937 14938 if (this.PARAMS.showOnce) 14939 { 14940 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14941 } 14942 } 14943 }; 14944 14945 BX.CHint.prototype.__onscroll = function() 14946 { 14947 if (!BX.admin || !BX.admin.panel || !BX.admin.panel.isFixed()) return; 14948 14949 if (this.scrollTimer) clearTimeout(this.scrollTimer); 14950 14951 this.DIV.style.display = 'none'; 14952 this.scrollTimer = setTimeout(BX.proxy(this.Reopen, this), this.PARAMS.show_timeout); 14953 }; 14954 14955 BX.CHint.prototype.Reopen = function() 14956 { 14957 if (null != this.timer) clearTimeout(this.timer); 14958 this.timer = setTimeout(BX.proxy(this.__show, this), 50); 14959 }; 14960 14961 BX.CHint.prototype.__hide = function() 14962 { 14963 if (this.msover) return; 14964 if (!this.bInited) return; 14965 14966 BX.unbind(window, 'scroll', BX.proxy(this.Reopen, this)); 14967 14968 BX.CHint.openHints.delete(this); 14969 14970 if (this.PARAMS.showOnce) 14971 { 14972 this.Destroy(); 14973 } 14974 else 14975 { 14976 this.DIV.style.display = 'none'; 14977 } 14978 }; 14979 14980 BX.CHint.prototype.__hide_immediately = function() 14981 { 14982 this.msover = false; 14983 this.__hide(); 14984 }; 14985 14986 BX.CHint.prototype.Init = function() 14987 { 14988 this.DIV = document.body.appendChild(BX.create('DIV', { 14989 props: {className: 'bx-panel-tooltip'}, 14990 style: { 14991 display: 'none', 14992 position: 'absolute', 14993 visibility: 'hidden' 14994 }, 14995 children: [ 14996 (this.CONTENT = BX.create('DIV', { 14997 props: {className: 'bx-panel-tooltip-content'}, 14998 children: [ 14999 BX.create('DIV', { 15000 props: {className: 'bx-panel-tooltip-underlay'}, 15001 children: [ 15002 BX.create('DIV', {props: {className: 'bx-panel-tooltip-underlay-bg'}}) 15003 ] 15004 }) 15005 ] 15006 })) 15007 ] 15008 })); 15009 15010 BX.ZIndexManager.register(this.DIV); 15011 15012 if (this.ID) 15013 { 15014 this.CONTENT.insertBefore(BX.create('A', { 15015 attrs: {href: 'javascript:void(0)'}, 15016 props: {className: 'bx-panel-tooltip-close'}, 15017 events: {click: BX.delegate(this.Close, this)} 15018 }), this.CONTENT.firstChild); 15019 } 15020 15021 if (this.HINT_TITLE) 15022 { 15023 this.CONTENT.appendChild( 15024 BX.create('DIV', { 15025 props: {className: 'bx-panel-tooltip-title'}, 15026 text: this.HINT_TITLE 15027 }) 15028 ); 15029 } 15030 15031 if (this.HINT) 15032 { 15033 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 15034 } 15035 15036 if (this.PARAMS.preventHide) 15037 { 15038 BX.bind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 15039 BX.bind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 15040 } 15041 15042 this.bInited = true; 15043 }; 15044 15045 BX.CHint.prototype.setContent = function(content) 15046 { 15047 this.HINT = content; 15048 15049 if (this.CONTENT_TEXT) 15050 this.CONTENT_TEXT.innerHTML = this.HINT; 15051 else 15052 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 15053 }; 15054 15055 BX.CHint.prototype.prepareAdjustPos = function() 15056 { 15057 this._wnd = {scrollPos: BX.GetWindowScrollPos(),scrollSize:BX.GetWindowScrollSize()}; 15058 return BX.style(this.PARENT, 'display') != 'none'; 15059 }; 15060 15061 BX.CHint.prototype.getAdjustPos = function() 15062 { 15063 var res = {}, pos = BX.pos(this.PARENT), min_top = 0; 15064 15065 res.top = pos.bottom + this.PARAMS.dx; 15066 15067 if (BX.admin && BX.admin.panel.DIV) 15068 { 15069 min_top = BX.admin.panel.DIV.offsetHeight + this.PARAMS.dx; 15070 15071 if (BX.admin.panel.isFixed()) 15072 { 15073 min_top += this._wnd.scrollPos.scrollTop; 15074 } 15075 } 15076 15077 if (res.top < min_top) 15078 res.top = min_top; 15079 else 15080 { 15081 if (res.top + this.DIV.offsetHeight > this._wnd.scrollSize.scrollHeight) 15082 res.top = pos.top - this.PARAMS.dx - this.DIV.offsetHeight; 15083 } 15084 15085 res.left = pos.left; 15086 if (pos.left < this.PARAMS.dx) 15087 pos.left = this.PARAMS.dx; 15088 else 15089 { 15090 var floatWidth = this.DIV.offsetWidth; 15091 15092 var max_left = this._wnd.scrollSize.scrollWidth - floatWidth - this.PARAMS.dx; 15093 15094 if (res.left > max_left) 15095 res.left = max_left; 15096 } 15097 15098 return res; 15099 }; 15100 15101 BX.CHint.prototype.adjustWidth = function() 15102 { 15103 if (this.bWidthAdjusted) return; 15104 15105 var w = this.DIV.offsetWidth, h = this.DIV.offsetHeight; 15106 15107 if (w > this.PARAMS.min_width) 15108 w = Math.round(Math.sqrt(1.618*w*h)); 15109 15110 if (w < this.PARAMS.min_width) 15111 w = this.PARAMS.min_width; 15112 15113 this.DIV.style.width = w + "px"; 15114 15115 if (this._adjustWidthInt) 15116 clearInterval(this._adjustWidthInt); 15117 this._adjustWidthInt = setInterval(BX.delegate(this._adjustWidthInterval, this), 5); 15118 15119 this.bWidthAdjusted = true; 15120 }; 15121 15122 BX.CHint.prototype._adjustWidthInterval = function() 15123 { 15124 if (!this.DIV || this.DIV.style.display == 'none') 15125 clearInterval(this._adjustWidthInt); 15126 15127 var
15128 dW = 20, 15129 maxWidth = 1500, 15130 w = this.DIV.offsetWidth, 15131 w1 = this.CONTENT_TEXT.offsetWidth; 15132 15133 if (w > 0 && w1 > 0 && w - w1 < dW && w < maxWidth) 15134 { 15135 this.DIV.style.width = (w + dW) + "px"; 15136 return; 15137 } 15138 15139 clearInterval(this._adjustWidthInt); 15140 }; 15141 15142 BX.CHint.prototype.adjustPos = function() 15143 { 15144 this.adjustWidth(); 15145 15146 var pos = this.getAdjustPos(); 15147 15148 this.DIV.style.top = pos.top + 'px'; 15149 this.DIV.style.left = pos.left + 'px'; 15150 }; 15151 15152 BX.CHint.prototype.Close = function() 15153 { 15154 if (this.ID && BX.WindowManager) 15155 BX.WindowManager.saveWindowOptions(this.ID, {display: 'off'}); 15156 this.__hide_immediately(); 15157 this.Destroy(); 15158 }; 15159 15160 BX.CHint.prototype.Destroy = function() 15161 { 15162 if (this.PARENT) 15163 { 15164 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 15165 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 15166 } 15167 15168 if (this.DIV) 15169 { 15170 BX.unbind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 15171 BX.unbind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 15172 15173 BX.ZIndexManager.unregister(this.DIV); 15174 15175 BX.cleanNode(this.DIV, true); 15176 } 15177 }; 15178 15179 BX.CHint.prototype.enable = function(){this.disabled = false;}; 15180 BX.CHint.prototype.disable = function(){this.__hide_immediately(); this.disabled = true;}; 15181 15182 15183 function _adjustWait() 15184 { 15185 if (!this.bxmsg) return; 15186 15187 var arContainerPos = BX.pos(this), 15188 div_top = arContainerPos.top; 15189 15190 if (div_top < BX.GetDocElement().scrollTop) 15191 div_top = BX.GetDocElement().scrollTop + 5; 15192 15193 this.bxmsg.style.top = (div_top + 5) + 'px'; 15194 15195 if (this == BX.GetDocElement()) 15196 { 15197 this.bxmsg.style.right = '5px'; 15198 } 15199 else 15200 { 15201 this.bxmsg.style.left = (arContainerPos.right - this.bxmsg.offsetWidth - 5) + 'px'; 15202 } 15203 } 15204 15205 function _processTpl(tplNode, cb, bKillTpl) 15206 { 15207 if (tplNode) 15208 { 15209 if (bKillTpl) 15210 tplNode.parentNode.removeChild(tplNode); 15211 15212 var res = {}, nodes = BX.findChildren(tplNode, {attribute: 'data-role'}, true); 15213 15214 for (var i = 0, l = nodes.length; i < l; i++) 15215 { 15216 res[nodes[i].getAttribute('data-role')] = nodes[i]; 15217 } 15218 15219 cb.apply(tplNode, [res]); 15220 } 15221 } 15222 15223 function _checkNode(obj, params) 15224 { 15225 params = params || {}; 15226 15227 if (BX.type.isFunction(params)) 15228 return params.call(window, obj); 15229 15230 if (!params.allowTextNodes && !BX.type.isElementNode(obj)) 15231 return false; 15232 var i,j,len; 15233 for (i in params) 15234 { 15235 if(params.hasOwnProperty(i)) 15236 { 15237 switch(i) 15238 { 15239 case 'tag': 15240 case 'tagName': 15241 if (BX.type.isString(params[i])) 15242 { 15243 if (obj.tagName.toUpperCase() != params[i].toUpperCase()) 15244 return false; 15245 } 15246 else if (params[i] instanceof RegExp) 15247 { 15248 if (!params[i].test(obj.tagName)) 15249 return false; 15250 } 15251 break; 15252 15253 case 'class': 15254 case 'className': 15255 if (BX.type.isString(params[i])) 15256 { 15257 if (!BX.hasClass(obj, params[i])) 15258 return false; 15259 } 15260 else if (params[i] instanceof RegExp) 15261 { 15262 if (!BX.type.isString(obj.className) || !params[i].test(obj.className)) 15263 return false; 15264 } 15265 break; 15266 15267 case 'attr': 15268 case 'attrs': 15269 case 'attribute': 15270 if (BX.type.isString(params[i])) 15271 { 15272 if (!obj.getAttribute(params[i])) 15273 return false; 15274 } 15275 else if (BX.type.isArray(params[i])) 15276 { 15277 for (j = 0, len = params[i].length; j < len; j++) 15278 { 15279 if (params[i] && !obj.getAttribute(params[i])) 15280 return false; 15281 } 15282 } 15283 else 15284 { 15285 for (j in params[i]) 15286 { 15287 if(params[i].hasOwnProperty(j)) 15288 { 15289 var q = obj.getAttribute(j); 15290 if (params[i][j] instanceof RegExp) 15291 { 15292 if (!BX.type.isString(q) || !params[i][j].test(q)) 15293 { 15294 return false; 15295 } 15296 } 15297 else 15298 { 15299 if (q != '' + params[i][j]) 15300 { 15301 return false; 15302 } 15303 } 15304 } 15305 } 15306 } 15307 break; 15308 15309 case 'property': 15310 case 'props': 15311 if (BX.type.isString(params[i])) 15312 { 15313 if (!obj[params[i]]) 15314 return false; 15315 } 15316 else if (BX.type.isArray(params[i])) 15317 { 15318 for (j = 0, len = params[i].length; j < len; j++) 15319 { 15320 if (params[i] && !obj[params[i]]) 15321 return false;
15322 } 15323 } 15324 else 15325 { 15326 for (j in params[i]) 15327 { 15328 if (BX.type.isString(params[i][j])) 15329 { 15330 if (obj[j] != params[i][j]) 15331 return false; 15332 } 15333 else if (params[i][j] instanceof RegExp) 15334 { 15335 if (!BX.type.isString(obj[j]) || !params[i][j].test(obj[j])) 15336 return false; 15337 } 15338 } 15339 } 15340 break; 15341 15342 case 'callback': 15343 return params[i](obj); 15344 } 15345 } 15346 } 15347 15348 return true; 15349 } 15350 15351 window.addEventListener('pagehide', () => { 15352 garbageCollectors.forEach(({ callback, context = window }) => { 15353 try 15354 { 15355 callback.apply(context); 15356 } catch (err) {} 15357 }); 15358 }); 15359 15360 // set empty ready handler 15361 BX(BX.DoNothing); 15362 window.BX = BX; 15363 15364 BX.browser.addGlobalClass(); 15365 15366 /* data storage */ 15367 BX.data = function(node, key, value) 15368 { 15369 if(typeof node == 'undefined') 15370 return undefined; 15371 15372 if(typeof key == 'undefined') 15373 return undefined; 15374 15375 if(typeof value != 'undefined') 15376 { 15377 // write to manager 15378 dataStorage.set(node, key, value); 15379 } 15380 else 15381 { 15382 var data; 15383 15384 // from manager 15385 if((data = dataStorage.get(node, key)) != undefined) 15386 { 15387 return data; 15388 } 15389 else 15390 { 15391 // from attribute data-* 15392 if('getAttribute' in node) 15393 { 15394 data = node.getAttribute('data-'+key.toString()); 15395 if(data === null) 15396 { 15397 return undefined; 15398 } 15399 return data; 15400 } 15401 } 15402 15403 return undefined; 15404 } 15405 }; 15406 15407 BX.DataStorage = function() 15408 { 15409 15410 this.keyOffset = 1; 15411 this.data = {}; 15412 this.uniqueTag = 'BX-'+Math.random(); 15413 15414 this.resolve = function(owner, create){ 15415 if(typeof owner[this.uniqueTag] == 'undefined') 15416 if(create) 15417 { 15418 try 15419 { 15420 Object.defineProperty(owner, this.uniqueTag, { 15421 value: this.keyOffset++ 15422 }); 15423 } 15424 catch(e) 15425 { 15426 owner[this.uniqueTag] = this.keyOffset++; 15427 } 15428 } 15429 else 15430 return undefined; 15431 15432 return owner[this.uniqueTag]; 15433 }; 15434 this.get = function(owner, key){ 15435 if((owner != document && !BX.type.isElementNode(owner)) || typeof key == 'undefined') 15436 return undefined; 15437 15438 owner = this.resolve(owner, false); 15439 15440 if(typeof owner == 'undefined' || typeof this.data[owner] == 'undefined') 15441 return undefined; 15442 15443 return this.data[owner][key]; 15444 }; 15445 this.set = function(owner, key, value){ 15446 15447 if((owner != document && !BX.type.isElementNode(owner)) || typeof value == 'undefined') 15448 return; 15449 15450 var o = this.resolve(owner, true); 15451 15452 if(typeof this.data[o] == 'undefined') 15453 this.data[o] = {}; 15454 15455 this.data[o][key] = value; 15456 }; 15457 }; 15458 15459// some internal variables for new logic 15460 var dataStorage = new BX.DataStorage(); // manager which BX.data() uses to keep data 15461})(window.BX); 15462 15463 15464;(function(window) 15465{ 15466 /****************** ATTENTION ******************************* 15467 * Please do not use Bitrix CoreJS in this class. 15468 * This class can be called on page without Bitrix Framework 15469 *************************************************************/ 15470 15471 if (!window.BX) 15472 { 15473 window.BX = {}; 15474 } 15475 15476 var BX = window.BX; 15477 15478 BX.Promise = function(fn, ctx) // fn is future-reserved 15479 { 15480 this.state = null; 15481 this.value = null; 15482 this.reason = null; 15483 this.next = null; 15484 this.ctx = ctx || this; 15485 15486 this.onFulfilled = []; 15487 this.onRejected = []; 15488 }; 15489 BX.Promise.prototype.fulfill = function(value) 15490 { 15491 this.checkState(); 15492 15493 this.value = value; 15494 this.state = true; 15495 this.execute(); 15496 }; 15497 BX.Promise.prototype.reject = function(reason) 15498 { 15499 this.checkState(); 15500 15501 this.reason = reason; 15502 this.state = false; 15503 this.execute(); 15504 }; 15505 BX.Promise.prototype.then = function(onFulfilled, onRejected) 15506 { 15507 if(typeof (onFulfilled) == "function" || onFulfilled instanceof Function) 15508 { 15509 this.onFulfilled.push(onFulfilled); 15510 } 15511 if(typeof (onRejected) == "function" || onRejected instanceof Function) 15512 { 15513 this.onRejected.push(onRejected); 15514 } 15515 15516 if(this.next === null) 15517 { 15518 this.next = new BX.Promise(null, this.ctx); 15519 } 15520 15521 if(this.state !== null) // if promise was already resolved, execute immediately 15522 { 15523 this.execute(); 15524 } 15525 15526 return this.next; 15527 }; 15528 15529 BX.Promise.prototype.catch = function(onRejected) 15530 { 15531 if(typeof (onRejected) == "function" || onRejected instanceof Function) 15532 { 15533 this.onRejected.push(onRejected); 15534 } 15535 15536 if(this.next === null) 15537 { 15538 this.next = new BX.Promise(null, this.ctx); 15539 } 15540 15541 if(this.state !== null) // if promise was already resolved, execute immediately 15542 { 15543 this.execute(); 15544 } 15545 15546 return this.next; 15547 }; 15548 15549 BX.Promise.prototype.setAutoResolve = function(way, ms) 15550 { 15551 this.timer = setTimeout(function(){ 15552 if(this.state === null) 15553 { 15554 this[way ? 'fulfill' : 'reject'](); 15555 } 15556 }.bind(this), ms || 15); 15557 };
15558 BX.Promise.prototype.cancelAutoResolve = function() 15559 { 15560 clearTimeout(this.timer); 15561 }; 15562 /** 15563 * Resolve function. This function allows promise chaining, like ..then().then()... 15564 * Typical usage: 15565 * 15566 * var p = new Promise(); 15567 * 15568 * p.then(function(value){ 15569 * return someValue; // next promise in the chain will be fulfilled with someValue 15570 * }).then(function(value){ 15571 * 15572 * var p1 = new Promise(); 15573 * *** some async code here, that eventually resolves p1 *** 15574 * 15575 * return p1; // chain will resume when p1 resolved (fulfilled or rejected) 15576 * }).then(function(value){ 15577 * 15578 * // you can also do 15579 * var e = new Error(); 15580 * throw e; 15581 * // it will cause next promise to be rejected with e 15582 * 15583 * return someOtherValue; 15584 * }).then(function(value){ 15585 * ... 15586 * }, function(reason){ 15587 * // promise was rejected with reason 15588 * })...; 15589 * 15590 * p.fulfill('let`s start this chain'); 15591 * 15592 * @param x 15593 */ 15594 BX.Promise.prototype.resolve = function(x) 15595 { 15596 var this_ = this; 15597 15598 if(this === x) 15599 { 15600 this.reject(new TypeError('Promise cannot fulfill or reject itself')); // avoid recursion 15601 } 15602 // allow "pausing" promise chaining until promise x is fulfilled or rejected 15603 else if(x && x.toString() === "[object BX.Promise]") 15604 { 15605 x.then(function(value){ 15606 this_.fulfill(value); 15607 }, function(reason){ 15608 this_.reject(reason); 15609 }); 15610 } 15611 else // auto-fulfill this promise 15612 { 15613 this.fulfill(x); 15614 } 15615 }; 15616 15617 BX.Promise.prototype.toString = function() 15618 { 15619 return "[object BX.Promise]"; 15620 }; 15621 15622 BX.Promise.prototype.execute = function() 15623 { 15624 if(this.state === null) 15625 { 15626 //then() must not be called before BX.Promise resolve() happens 15627 return; 15628 } 15629 15630 var value = undefined; 15631 var reason = undefined; 15632 var x = undefined; 15633 var k; 15634 if(this.state === true) // promise was fulfill()-ed 15635 { 15636 if(this.onFulfilled.length) 15637 { 15638 try 15639 { 15640 for(k = 0; k < this.onFulfilled.length; k++) 15641 {
15642 x = this.onFulfilled[k].apply(this.ctx, [this.value]); 15643 if(typeof x != 'undefined') 15644 { 15645 value = x; 15646 } 15647 } 15648 } 15649 catch(e) 15650 { 15651 if('console' in window) 15652 { 15653 console.dir(e); 15654 } 15655 15656 if (typeof BX.debug !== 'undefined') 15657 { 15658 BX.debug(e); 15659 } 15660 15661 reason = e; // reject next 15662 } 15663 } 15664 else 15665 { 15666 value = this.value; // resolve next 15667 } 15668 } 15669 else if(this.state === false) // promise was reject()-ed 15670 { 15671 if(this.onRejected.length) 15672 { 15673 try 15674 { 15675 for(k = 0; k < this.onRejected.length; k++) 15676 { 15677 x = this.onRejected[k].apply(this.ctx, [this.reason]); 15678 if(typeof x != 'undefined') 15679 { 15680 value = x; 15681 } 15682 } 15683 } 15684 catch(e) 15685 { 15686 if('console' in window) 15687 { 15688 console.dir(e); 15689 } 15690 15691 if (typeof BX.debug !== 'undefined') 15692 { 15693 BX.debug(e); 15694 } 15695 15696 reason = e; // reject next 15697 } 15698 } 15699 else 15700 { 15701 reason = this.reason; // reject next 15702 } 15703 } 15704 15705 if(this.next !== null) 15706 { 15707 if(typeof reason != 'undefined') 15708 { 15709 this.next.reject(reason); 15710 } 15711 else if(typeof value != 'undefined') 15712 { 15713 this.next.resolve(value); 15714 } 15715 } 15716 }; 15717 BX.Promise.prototype.checkState = function() 15718 { 15719 if(this.state !== null) 15720 { 15721 throw new Error('You can not do fulfill() or reject() multiple times'); 15722 } 15723 }; 15724})(window); 15725 15726 15727 15728;(function(window){ 15729 15730if (window.BX.ajax) 15731 return; 15732 15733var 15734 BX = window.BX, 15735 15736 tempDefaultConfig = {}, 15737 defaultConfig = { 15738 method: 'GET', // request method: GET|POST 15739 dataType: 'html', // type of data loading: html|json|script 15740 timeout: 0, // request timeout in seconds. 0 for browser-default 15741 async: true, // whether request is asynchronous or not 15742 processData: true, // any data processing is disabled if false, only callback call 15743 scriptsRunFirst: false, // whether to run _all_ found scripts before onsuccess call. script tag can have an attribute "bxrunfirst" to turn this flag on only for itself 15744 emulateOnload: true, 15745 skipAuthCheck: false, // whether to check authorization failure (SHOUD be set to true for CORS requests) 15746 start: true, // send request immediately (if false, request can be started manually via XMLHttpRequest object returned) 15747 cache: true, // whether NOT to add random addition to URL 15748 preparePost: true, // whether set Content-Type x-www-form-urlencoded in POST 15749 headers: false, // add additional headers, example: [{'name': 'If-Modified-Since', 'value': 'Wed, 15 Aug 2012 08:59:08 GMT'}, {'name': 'If-None-Match', 'value': '0'}] 15750 lsTimeout: 30, //local storage data TTL. useless without lsId. 15751 lsForce: false //wheter to force query instead of using localStorage data. useless without lsId. 15752/* 15753other parameters: 15754 url: url to get/post 15755 data: data to post 15756 onsuccess: successful request callback. BX.proxy may be used. 15757 onfailure: request failure callback. BX.proxy may be used. 15758 onprogress: request progress callback. BX.proxy may be used. 15759 15760 lsId: local storage id - for constantly updating queries which can communicate via localStorage. core_ls.js needed 15761 15762any of the default parameters can be overridden. defaults can be changed by BX.ajax.Setup() - for all further requests! 15763*/ 15764 }, 15765 loadedScripts = {}, 15766 loadedScriptsQueue = [], 15767 r = { 15768 'url_utf': /[^\034-\254]+/g, 15769 'script_self': /\/bitrix\/js\/main\/core\/core(_ajax)*.js$/i, 15770 'script_self_window': /\/bitrix\/js\/main\/core\/core_window.js$/i, 15771 'script_self_admin': /\/bitrix\/js\/main\/core\/core_admin.js$/i, 15772 'script_onload': /window.onload/g 15773 }; 15774 15775// low-level method 15776BX.ajax = function(config) 15777{ 15778 var status, data; 15779
15780 if (!config || !config.url || !BX.type.isString(config.url)) 15781 { 15782 return false; 15783 } 15784 15785 for (var i in tempDefaultConfig) 15786 if (typeof (config[i]) == "undefined") config[i] = tempDefaultConfig[i]; 15787 15788 tempDefaultConfig = {}; 15789 15790 for (i in defaultConfig) 15791 if (typeof (config[i]) == "undefined") config[i] = defaultConfig[i]; 15792 15793 config.method = config.method.toUpperCase(); 15794 15795 if (!BX.localStorage) 15796 config.lsId = null; 15797 15798 if (BX.browser.IsIE()) 15799 { 15800 var result = r.url_utf.exec(config.url); 15801 if (result) 15802 { 15803 do 15804 { 15805 config.url = config.url.replace(result, BX.util.urlencode(result)); 15806 result = r.url_utf.exec(config.url); 15807 } while (result); 15808 } 15809 } 15810 15811 if(config.dataType == 'json') 15812 config.emulateOnload = false; 15813 15814 if (!config.cache && config.method == 'GET') 15815 config.url = BX.ajax._uncache(config.url); 15816 15817 if (config.method == 'POST') 15818 { 15819 if (config.preparePost) 15820 { 15821 config.data = BX.ajax.prepareData(config.data); 15822 } 15823 else if (getLastContentTypeHeader(config.headers) === 'application/json') 15824 { 15825 const isJson = ( 15826 BX.Type.isPlainObject(config.data) 15827 || BX.Type.isString(config.data) 15828 || BX.Type.isNumber(config.data) 15829 || BX.Type.isBoolean(config.data) 15830 || BX.Type.isArray(config.data) 15831 ); 15832 15833 if (isJson) 15834 { 15835 config.data = JSON.stringify(config.data); 15836 } 15837 } 15838 } 15839 15840 var bXHR = true; 15841 if (config.lsId && !config.lsForce) 15842 { 15843 var v = BX.localStorage.get('ajax-' + config.lsId); 15844 if (v !== null) 15845 { 15846 bXHR = false; 15847 15848 var lsHandler = function(lsData) { 15849 if (lsData.key == 'ajax-' + config.lsId && lsData.value != 'BXAJAXWAIT') 15850 { 15851 var data = lsData.value, 15852 bRemove = !!lsData.oldValue && data == null; 15853 if (!bRemove) 15854 BX.ajax.__run(config, data); 15855 else if (config.onfailure) 15856 config.onfailure("timeout"); 15857 15858 BX.removeCustomEvent('onLocalStorageChange', lsHandler); 15859 } 15860 }; 15861 15862 if (v == 'BXAJAXWAIT') 15863 { 15864 BX.addCustomEvent('onLocalStorageChange', lsHandler); 15865 } 15866 else 15867 { 15868 setTimeout(function() {lsHandler({key: 'ajax-' + config.lsId, value: v})}, 10); 15869 } 15870 } 15871 } 15872 15873 if (bXHR) 15874 { 15875 config.xhr = BX.ajax.xhr(); 15876 if (!config.xhr) return; 15877 15878 if (config.lsId) 15879 { 15880 BX.localStorage.set('ajax-' + config.lsId, 'BXAJAXWAIT', config.lsTimeout); 15881 } 15882 15883 if (BX.Type.isFunction(config.onprogress)) 15884 { 15885 BX.bind(config.xhr, 'progress', config.onprogress); 15886 } 15887 15888 if (BX.Type.isFunction(config.onprogressupload) && config.xhr.upload) 15889 { 15890 BX.bind(config.xhr.upload, 'progress', config.onprogressupload); 15891 } 15892 15893 config.xhr.open(config.method, config.url, config.async); 15894 15895 if (!config.skipBxHeader && !BX.ajax.isCrossDomain(config.url)) 15896 { 15897 config.xhr.setRequestHeader('Bx-ajax', 'true'); 15898 } 15899 15900 if (config.method == 'POST' && config.preparePost) 15901 { 15902 config.xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 15903 } 15904 if (typeof(config.headers) == "object") 15905 { 15906 for (i = 0; i < config.headers.length; i++) 15907 config.xhr.setRequestHeader(config.headers[i].name, config.headers[i].value); 15908 } 15909 15910 var bRequestCompleted = false; 15911 var onreadystatechange = config.xhr.onreadystatechange = function(additional) 15912 { 15913 if (bRequestCompleted) 15914 return; 15915 15916 if (additional === 'timeout') 15917 { 15918 if (config.onfailure) 15919 { 15920 config.onfailure('timeout', '', config); 15921 } 15922 15923 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['timeout', '', config]); 15924 15925 config.xhr.onreadystatechange = BX.DoNothing; 15926 config.xhr.abort(); 15927 15928 if (config.async) 15929 { 15930 config.xhr = null; 15931 } 15932 } 15933 else 15934 { 15935 if (config.xhr.readyState == 4 || additional == 'run') 15936 { 15937 status = BX.ajax.xhrSuccess(config.xhr) ? "success" : "error"; 15938 bRequestCompleted = true; 15939 config.xhr.onreadystatechange = BX.DoNothing; 15940 15941 if (status == 'success') 15942 { 15943 var authHeader = (!!config.skipAuthCheck || BX.ajax.isCrossDomain(config.url)) 15944 ? false 15945 : config.xhr.getResponseHeader('X-Bitrix-Ajax-Status'); 15946 15947 if(!!authHeader && authHeader == 'Authorize') 15948 { 15949 if (config.onfailure) 15950 { 15951 config.onfailure('auth', config.xhr.status, config); 15952 } 15953 15954 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['auth', config.xhr.status, config]); 15955 } 15956 else 15957 { 15958 var data = config.xhr.responseText; 15959 15960 if (config.lsId) 15961 { 15962 BX.localStorage.set('ajax-' + config.lsId, data, config.lsTimeout); 15963 } 15964 15965 BX.ajax.__run(config, data); 15966 } 15967 } 15968 else 15969 { 15970 if (config.onfailure) 15971 { 15972 config.onfailure('status', config.xhr.status, config); 15973 } 15974 15975 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['status', config.xhr.status, config]); 15976 } 15977 15978 if (config.async) 15979 { 15980 config.xhr = null; 15981 } 15982 } 15983 } 15984 }; 15985 15986 if (config.async && config.timeout > 0) 15987 { 15988 setTimeout(function() { 15989 if (config.xhr && !bRequestCompleted) 15990 { 15991 onreadystatechange("timeout"); 15992 } 15993 }, config.timeout * 1000); 15994 } 15995 15996 if (config.start) 15997 {
15998 config.xhr.send(config.data); 15999 16000 if (!config.async) 16001 { 16002 onreadystatechange('run'); 16003 } 16004 } 16005 16006 return config.xhr; 16007 } 16008}; 16009 16010BX.ajax.xhr = function() 16011{ 16012 if (window.XMLHttpRequest) 16013 { 16014 try {return new XMLHttpRequest();} catch(e){} 16015 } 16016 else if (window.ActiveXObject) 16017 { 16018 try { return new window.ActiveXObject("Msxml2.XMLHTTP.6.0"); } 16019 catch(e) {} 16020 try { return new window.ActiveXObject("Msxml2.XMLHTTP.3.0"); } 16021 catch(e) {} 16022 try { return new window.ActiveXObject("Msxml2.XMLHTTP"); } 16023 catch(e) {} 16024 try { return new window.ActiveXObject("Microsoft.XMLHTTP"); } 16025 catch(e) {} 16026 throw new Error("This browser does not support XMLHttpRequest."); 16027 } 16028 16029 return null; 16030}; 16031 16032BX.ajax.isCrossDomain = function(url, location) 16033{ 16034 location = location || window.location; 16035 16036 //Relative URL gets a current protocol 16037 if (url.indexOf("//") === 0) 16038 { 16039 url = location.protocol + url; 16040 } 16041 16042 //Fast check 16043 if (url.indexOf("http") !== 0) 16044 { 16045 return false; 16046 } 16047 16048 var link = window.document.createElement("a"); 16049 link.href = url; 16050 16051 return link.protocol !== location.protocol || 16052 link.hostname !== location.hostname || 16053 BX.ajax.getHostPort(link.protocol, link.host) !== BX.ajax.getHostPort(location.protocol, location.host); 16054}; 16055 16056BX.ajax.getHostPort = function(protocol, host) 16057{ 16058 var match = /:(\d+)$/.exec(host); 16059 if (match) 16060 { 16061 return match[1]; 16062 } 16063 else 16064 { 16065 if (protocol === "http:") 16066 { 16067 return "80"; 16068 } 16069 else if (protocol === "https:") 16070 { 16071 return "443"; 16072 } 16073 } 16074 16075 return ""; 16076}; 16077 16078BX.ajax.__prepareOnload = function(scripts, ajax_session) 16079{ 16080 if (scripts.length > 0) 16081 { 16082 BX.ajax['onload_' + ajax_session] = null; 16083 16084 for (var i=0,len=scripts.length;i<len;i++) 16085 { 16086 if (scripts[i].isInternal) 16087 { 16088 scripts[i].JS = scripts[i].JS.replace(r.script_onload, 'BX.aja
16088x.onload_' + ajax_session); 16089 } 16090 } 16091 } 16092 16093 BX.CaptureEventsGet(); 16094 BX.CaptureEvents(window, 'load'); 16095}; 16096 16097BX.ajax.__runOnload = function(ajax_session) 16098{ 16099 if (null != BX.ajax['onload_' + ajax_session]) 16100 { 16101 BX.ajax['onload_' + ajax_session].apply(window); 16102 BX.ajax['onload_' + ajax_session] = null; 16103 } 16104 16105 var h = BX.CaptureEventsGet(); 16106 16107 if (h) 16108 { 16109 for (var i=0; i<h.length; i++) 16110 h[i].apply(window); 16111 } 16112}; 16113 16114BX.ajax.__run = function(config, data) 16115{ 16116 if (!config.processData) 16117 { 16118 if (config.onsuccess) 16119 { 16120 config.onsuccess(data); 16121 } 16122 16123 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [data, config]); 16124 } 16125 else 16126 { 16127 data = BX.ajax.processRequestData(data, config); 16128 } 16129}; 16130 16131 16132BX.ajax._onParseJSONFailure = function(data) 16133{ 16134 this.jsonFailure = true; 16135 this.jsonResponse = data; 16136 this.jsonProactive = /^\[WAF\]/.test(data); 16137}; 16138 16139BX.ajax.processRequestData = function(data, config) 16140{ 16141 var result, scripts = [], styles = []; 16142 switch (config.dataType.toUpperCase()) 16143 { 16144 case 'JSON': 16145 16146 var context = config.xhr || {}; 16147 BX.addCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 16148 result = BX.parseJSON(data, context); 16149 BX.removeCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 16150 16151 if(!!result && BX.type.isArray(result['bxjs'])) 16152 { 16153 for(var i = 0; i < result['bxjs'].length; i++) 16154 { 16155 if(BX.type.isNotEmptyString(result['bxjs'][i])) 16156 { 16157 scripts.push({ 16158 "isInternal": false, 16159 "JS": result['bxjs'][i], 16160 "bRunFirst": config.scriptsRunFirst 16161 }); 16162 } 16163 else 16164 { 16165 scripts.push(result['bxjs'][i]) 16166 } 16167 } 16168 } 16169 16170 if(!!result && BX.type.isArray(result['bxcss'])) 16171 { 16172 styles = result['bxcss']; 16173 } 16174 16175 break; 16176 case 'SCRIPT': 16177 scripts.push({"isInternal": true, "JS": data, "bRunFirst": config.scriptsRunFirst}); 16178 result = data; 16179 break; 16180 16181 default: // HTML 16182 var ob = BX.processHTML(data, config.scriptsRunFirst); 16183 result = ob.HTML; scripts = ob.SCRIPT; styles = ob.STYLE; 16184 break; 16185 } 16186 16187 if (styles.length > 0) 16188 { 16189 BX.loadCSS(styles); 16190 } 16191 16192 let ajax_session = null; 16193 if (config.emulateOnload) 16194 { 16195 ajax_session = parseInt(Math.random() * 1000000); 16196 BX.ajax.__prepareOnload(scripts, ajax_session); 16197 } 16198 16199 const cb = BX.defer(function() 16200 { 16201 if (config.emulateOnload) 16202 { 16203 BX.ajax.__runOnload(ajax_session); 16204 } 16205 16206 BX.onCustomEvent(config.xhr, 'onAjaxSuccessFinish', [config]); 16207 }); 16208 16209 try 16210 { 16211 if (!!config.jsonFailure) 16212 { 16213 throw {type: 'json_failure', data: config.jsonResponse, bProactive: config.jsonProactive}; 16214 } 16215 16216 config.scripts = scripts; 16217 16218 BX.ajax.processScripts(config.scripts, true); 16219 16220 if (config.onsuccess) 16221 { 16222 config.onsuccess(result); 16223 } 16224 16225 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [result, config]); 16226 16227 BX.ajax.processScripts(config.scripts, false, cb); 16228 } 16229 catch (e) 16230 { 16231 if (config.onfailure) 16232 config.onfailure("processing", e); 16233 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['processing', e, config]); 16234 } 16235}; 16236 16237BX.ajax.processScripts = function(scripts, bRunFirst, cb) 16238{ 16239 var scriptsExt = [], scriptsInt = ''; 16240 16241 cb = cb || BX.DoNothing; 16242 16243 for (var i = 0, length = scripts.length; i < length; i++) 16244 { 16245 if (typeof bRunFirst != 'undefined' && bRunFirst != !!scripts[i].bRunFirst) 16246 continue; 16247 16248 if (scripts[i].isInternal) 16249 scriptsInt += ';' + scripts[i].JS; 16250 else 16251 scriptsExt.push(scripts[i].JS); 16252 } 16253 16254 scriptsExt = BX.util.array_unique(scriptsExt); 16255 var inlineScripts = scriptsInt.length > 0 ? function() { BX.evalGlobal(scriptsInt); } : BX.DoNothing; 16256 16257 if (scriptsExt.length > 0) 16258 { 16259 BX.load(scriptsExt, function() { 16260 inlineScripts(); 16261 cb(); 16262 }); 16263 } 16264 else 16265 { 16266 inlineScripts(); 16267 cb(); 16268 } 16269}; 16270 16271// TODO: extend this function to use with any data objects or forms 16272BX.ajax.prepareData = function(arData, prefix) 16273{ 16274 var data = ''; 16275 if (BX.type.isString(arData)) 16276 data = arData; 16277 else if (null != arData) 16278 { 16279 for(var i in arData) 16280 { 16281 if (arData.hasOwnProperty(i)) 16282 { 16283 if (data.length > 0) 16284 data += '&'; 16285 var name = BX.util.urlencode(i); 16286 if(prefix) 16287 name = prefix + '[' + name + ']'; 16288 if(typeof arData[i] == 'object') 16289 data += BX.ajax.prepareData(arData[i], name); 16290 else 16291 data += name + '=' + BX.util.urlencode(arData[i]); 16292 } 16293 } 16294 } 16295 return data; 16296}; 16297 16298BX.ajax.xhrSuccess = function(xhr) 16299{ 16300 return (xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || xhr.status === 1223 || xhr.status === 0; 16301}; 16302 16303BX.ajax.Setup = function(config, bTemp) 16304{ 16305 bTemp = !!bTemp; 16306 16307 for (var i in config) 16308 { 16309 if (bTemp) 16310 tempDefaultConfig[i] = config[i]; 16311 else 16312 defaultConfig[i] = config[i]; 16313 } 16314}; 16315 16316BX.ajax.replaceLocalStorageValue = function(lsId, data, ttl) 16317{ 16318 if (!!BX.localStorage) 16319 BX.localStorage.set('ajax-' + lsId, data, ttl); 16320}; 16321 16322 16323BX.ajax._uncache = function(url) 16324{ 16325 return url + ((url.indexOf('?') !== -1 ? "&" : "?") + '_=' + (new Date()).getTime()); 16326}; 16327 16328/* simple interface */ 16329BX.ajax.get = function(url, data, callback) 16330{ 16331 if (BX.type.isFunction(data)) 16332 { 16333 callback = data; 16334 data = ''; 16335 } 16336
16337 data = BX.ajax.prepareData(data); 16338 16339 if (data) 16340 { 16341 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 16342 data = ''; 16343 } 16344 16345 return BX.ajax({ 16346 'method': 'GET', 16347 'dataType': 'html', 16348 'url': url, 16349 'data': '', 16350 'onsuccess': callback 16351 }); 16352}; 16353 16354BX.ajax.getCaptcha = function(callback) 16355{ 16356 return BX.ajax.loadJSON('/bitrix/tools/ajax_captcha.php', callback); 16357}; 16358 16359BX.ajax.insertToNode = function(url, node) 16360{ 16361 node = BX(node); 16362 if (!!node) 16363 { 16364 var eventArgs = { cancel: false }; 16365 BX.onCustomEvent('onAjaxInsertToNode', [{ url: url, node: node, eventArgs: eventArgs }]); 16366 if(eventArgs.cancel === true) 16367 { 16368 return; 16369 } 16370 16371 var show = null; 16372 if (!tempDefaultConfig.denyShowWait) 16373 { 16374 show = BX.showWait(node); 16375 delete tempDefaultConfig.denyShowWait; 16376 } 16377 16378 return BX.ajax.get(url, function(data) { 16379 node.innerHTML = data; 16380 BX.closeWait(node, show); 16381 }); 16382 } 16383}; 16384 16385BX.ajax.post = function(url, data, callback) 16386{ 16387 data = BX.ajax.prepareData(data); 16388 16389 return BX.ajax({ 16390 'method': 'POST', 16391 'dataType': 'html', 16392 'url': url, 16393 'data': data, 16394 'onsuccess': callback 16395 }); 16396}; 16397 16398/** 16399 * BX.ajax with BX.Promise 16400 * 16401 * @param config 16402 * @returns {BX.Promise|false} 16403 */ 16404BX.ajax.promise = function(config) 16405{ 16406 var result = new BX.Promise(); 16407 16408 config.onsuccess = function(data) 16409 { 16410 result.fulfill(data); 16411 }; 16412 config.onfailure = function(reason, httpStatus, config) 16413 { 16414 result.reject({ 16415 reason: reason, 16416 data: httpStatus, 16417 ajaxConfig: config, 16418 xhr: config.xhr 16419 }); 16420 }; 16421 16422 var xhr = BX.ajax(config); 16423 if (xhr) 16424 { 16425 if (typeof config.onrequeststart === 'function') 16426 { 16427 config.onrequeststart(xhr); 16428 } 16429 } 16430 else 16431 { 16432 result.reject({ 16433 reason: "init", 16434 data: false 16435 }); 16436 } 16437 16438 return result; 16439}; 16440 16441/* load and execute external file script with onload emulation */ 16442BX.ajax.loadScriptAjax = function(script_src, callback, bPreload) 16443{ 16444 if (BX.type.isArray(script_src)) 16445 { 16446 for (var i=0,len=script_src.length;i<len;i++) 16447 { 16448 BX.ajax.loadScriptAjax(script_src[i], callback, bPreload); 16449 } 16450 } 16451 else 16452 { 16453 var script_src_test = script_src.replace(/\.js\?.*/, '.js'); 16454 16455 if (r.script_self.test(script_src_test)) return; 16456 if (r.script_self_window.test(script_src_test) && BX.CWindow) return; 16457 if (r.script_self_admin.test(script_src_test) && BX.admin) return; 16458 16459 if (typeof loadedScripts[script_src_test] == 'undefined') 16460 { 16461 if (!!bPreload) 16462 { 16463 loadedScripts[script_src_test] = ''; 16464 return BX.loadScript(script_src); 16465 } 16466 else 16467 { 16468 return BX.ajax({ 16469 url: script_src, 16470 method: 'GET', 16471 dataType: 'script', 16472 processData: true, 16473 emulateOnload: false, 16474 scriptsRunFirst: true, 16475 async: false, 16476 start: true, 16477 onsuccess: function(result) { 16478 loadedScripts[script_src_test] = result; 16479 if (callback) 16480 callback(result); 16481 } 16482 }); 16483 } 16484 } 16485 else if (callback) 16486 { 16487 callback(loadedScripts[script_src_test]); 16488 } 16489 } 16490}; 16491 16492/* non-xhr loadings */ 16493BX.ajax.loadJSON = function(url, data, callback, callback_failure) 16494{ 16495 if (BX.type.isFunction(data)) 16496 { 16497 callback_failure = callback; 16498 callback = data; 16499 data = ''; 16500 } 16501 16502 data = BX.ajax.prepareData(data); 16503 16504 if (data) 16505 { 16506 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 16507 data = ''; 16508 } 16509 16510 return BX.ajax({ 16511 'method': 'GET', 16512 'dataType': 'json', 16513 'url': url, 16514 'onsuccess': callback, 16515 'onfailure': callback_failure 16516 }); 16517}; 16518 16519var getLastContentTypeHeader = function (headers) { 16520 if (!BX.Type.isArray(headers)) 16521 { 16522 return null; 16523 } 16524 var lastHeader = headers 16525 .filter(function (header) { 16526 return header.name === 'Content-Type'; 16527 }) 16528 .pop(); 16529 16530 return lastHeader ? lastHeader.value : null; 16531}; 16532 16533/** 16534 * @see isValidAnalyticsData in ui.analytics 16535* */ 16536const isValidAnalyticsData = function (analytics) 16537{ 16538 if (!BX.Type.isPlainObject(analytics)) 16539 { 16540 console.error('BX.ajax: {analytics} must be an object.'); 16541 16542 return false; 16543 } 16544 16545 const requiredFields = ['event', 'tool', 'category']; 16546 for (const field of requiredFields) 16547 { 16548 if (!BX.Type.isStringFilled(analytics[field])) 16549 { 16550 console.error(`BX.ajax: The "${field}" property in the "analytics" object must be a non-empty string.`); 16551 16552 return false;
16553 } 16554 } 16555 16556 const additionalFields = ['p1', 'p2', 'p3', 'p4', 'p5']; 16557 for (const field of additionalFields) 16558 { 16559 const value = analytics[field]; 16560 if (!BX.Type.isStringFilled(value)) 16561 { 16562 continue; 16563 } 16564 16565 if (value.split('_').length > 2) 16566 { 16567 console.error(`BX.ajax: The "${field}" property (${value}) in the "analytics" object must be a string containing a single underscore.`); 16568 16569 return false; 16570 } 16571 } 16572 16573 return true; 16574}; 16575 16576const processAnalyticsDataToGetParameters = function(config) 16577{ 16578 const getParameters = {}; 16579 if (BX.Type.isStringFilled(config.analyticsLabel) || BX.Type.isPlainObject(config.analyticsLabel)) 16580 { 16581 getParameters.analyticsLabel = config.analyticsLabel; 16582 } 16583 16584 if (BX.Type.isPlainObject(config.analytics)) 16585 { 16586 if (config.analyticsLabel) 16587 { 16588 delete getParameters.analyticsLabel; 16589 console.error('BX.ajax: Only {analytics} or {analyticsLabel} should be used. If both are present, {analyticsLabel} will be ignored.'); 16590 } 16591 16592 if (isValidAnalyticsData(config.analytics)) 16593 { 16594 getParameters.st = config.analytics; 16595 } 16596 else 16597 { 16598 console.error('BX.ajax: {analytics} is invalid and is skipped.'); 16599 } 16600 } 16601 16602 return getParameters; 16603}; 16604 16605const prepareAjaxGetParameters = function(config) 16606{ 16607 let getParameters = config.getParameters || {}; 16608 getParameters = { ...getParameters, ...processAnalyticsDataToGetParameters(config) }; 16609 16610 if (typeof config.mode !== 'undefined') 16611 { 16612 getParameters.mode = config.mode; 16613 } 16614 if (config.navigation) 16615 { 16616 if (config.navigation.page) 16617 { 16618 getParameters.nav = 'page-' + config.navigation.page; 16619 } 16620 if (config.navigation.size) 16621 { 16622 if (getParameters.nav) 16623 { 16624 getParameters.nav += '-'; 16625 } 16626 else 16627 { 16628 getParameters.nav = ''; 16629 } 16630 getParameters.nav += 'size-' + config.navigation.size; 16631 } 16632 } 16633 16634 return getParameters; 16635}; 16636 16637var prepareAjaxConfig = function(config) 16638{ 16639 config = BX.type.isPlainObject(config) ? config : {}; 16640 16641 config.headers = config.headers || []; 16642 config.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 16643 if (BX.message.SITE_ID) 16644 { 16645 config.headers.push({name: 'X-Bitrix-Site-Id', value: BX.message.SITE_ID}); 16646 } 16647 16648 if (typeof config.json !== 'undefined') 16649 { 16650 if (!BX.type.isPlainObject(config.json)) 16651 { 16652 throw new Error('Wrong `config.json`, plain object expected.') 16653 } 16654 16655 config.headers.push({name: 'Content-Type', value: 'application/json'}); 16656 config.data = config.json; 16657 config.preparePost = false; 16658 } 16659 else if (config.data instanceof FormData) 16660 { 16661 config.preparePost = false; 16662 if (typeof config.signedParameters !== 'undefined') 16663 { 16664 config.data.append('signedParameters', config.signedParameters); 16665 } 16666 } 16667 else if (BX.type.isPlainObject(config.data) || BX.Type.isNil(config.data)) 16668 { 16669 config.data = BX.type.isPlainObject(config.data) ? config.data : {}; 16670 if (typeof config.signedParameters !== 'undefined') 16671 { 16672 config.data.signedParameters = config.signedParameters; 16673 } 16674 } 16675 16676 if (!config.method) 16677 { 16678 config.method = 'POST' 16679 } 16680 16681 return config; 16682}; 16683 16684var buildAjaxPromiseToRestoreCsrf = function(config, withoutRestoringCsrf) 16685{ 16686 withoutRestoringCsrf = withoutRestoringCsrf || false; 16687 var originalConfig = BX.clone(config); 16688 var request = null; 16689 16690 var onrequeststart = config.onrequeststart; 16691 config.onrequeststart = function(xhr) { 16692 request = xhr; 16693 if (BX.type.isFunction(onrequeststart)) 16694 { 16695 onrequeststart(xhr); 16696 } 16697 }; 16698 var onrequeststartOrig = originalConfig.onrequeststart; 16699 originalConfig.onrequeststart = function(xhr) { 16700 request = xhr; 16701 if (BX.type.isFunction(onrequeststartOrig)) 16702 { 16703 onrequeststartOrig(xhr); 16704 } 16705 }; 16706 16707 var promise = BX.ajax.promise(config); 16708 16709 return promise.then(function(response) { 16710 if (!withoutRestoringCsrf && BX.type.isPlainObject(response) && BX.type.isArray(response.errors)) 16711 { 16712 var csrfProblem = false; 16713 response.errors.forEach(function(error) { 16714 if (error.code === 'invalid_csrf' && error.customData.csrf) 16715 { 16716 BX.message({'bitrix_sessid': error.customData.csrf}); 16717 16718 originalConfig.headers = originalConfig.headers || []; 16719 originalConfig.headers = originalConfig.headers.filter(function(header) {
16720 return header && header.name !== 'X-Bitrix-Csrf-Token'; 16721 }); 16722 originalConfig.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 16723 16724 csrfProblem = true; 16725 } 16726 }); 16727 16728 if (csrfProblem) 16729 { 16730 return buildAjaxPromiseToRestoreCsrf(originalConfig, true); 16731 } 16732 } 16733 16734 if (!BX.type.isPlainObject(response) || response.status !== 'success') 16735 { 16736 var errorPromise = new BX.Promise(); 16737 errorPromise.reject(response); 16738 16739 return errorPromise; 16740 } 16741 16742 return response; 16743 }).catch(function(data) { 16744 var ajaxReject = new BX.Promise(); 16745 16746 var originalJsonResponse; 16747 if (BX.type.isPlainObject(data) && data.xhr && data.xhr.responseText) 16748 { 16749 try 16750 { 16751 originalJsonResponse = JSON.parse(data.xhr.responseText); 16752 data = originalJsonResponse; 16753 } 16754 catch (err) 16755 {} 16756 } 16757 16758 if (BX.type.isPlainObject(data) && data.status && data.hasOwnProperty('data')) 16759 { 16760 ajaxReject.reject(data); 16761 } 16762 else 16763 { 16764 ajaxReject.reject({ 16765 status: 'error', 16766 data: { 16767 ajaxRejectData: data 16768 }, 16769 errors: [ 16770 { 16771 code: 'NETWORK_ERROR', 16772 message: 'Network error' 16773 } 16774 ] 16775 }); 16776 } 16777 16778 return ajaxReject; 16779 }).then(function(response){ 16780 16781 var assetsLoaded = new BX.Promise(); 16782 16783 var headers = request.getAllResponseHeaders().trim().split(/[\r\n]+/); 16784 var headerMap = {}; 16785 headers.forEach(function (line) { 16786 var parts = line.split(': '); 16787 var header = parts.shift().toLowerCase(); 16788 headerMap[header] = parts.join(': '); 16789 }); 16790 16791 if (!headerMap['x-process-assets']) 16792 { 16793 assetsLoaded.fulfill(response); 16794 16795 return assetsLoaded; 16796 } 16797 16798 var assets = BX.prop.getObject(BX.prop.getObject(response, "data", {}), "assets", {}); 16799 16800 var inlineScripts = []; 16801 if (BX.Type.isArrayFilled(assets.string)) 16802 { 16803 assets.string 16804 .reduce(function(acc, item) { 16805 if (String(item).length > 0 && !acc.includes(item)) 16806 { 16807 acc.push(item); 16808 } 16809 16810 return acc; 16811 }, []) 16812 .forEach(function(item) { 16813 if (String(item).startsWith('<script type="extension/settings"')) 16814 { 16815 BX.html(document.head, item, { useAdjacentHTML: true }); 16816 } 16817 else 16818 { 16819 inlineScripts.push(item); 16820 } 16821 }); 16822 } 16823 16824 var promise = new Promise(function(resolve, reject) { 16825 var css = BX.prop.getArray(assets, "css", []); 16826 BX.load(css, function(){ 16827 BX.loadScript( 16828 BX.prop.getArray(assets, "js", []), 16829 resolve 16830 ); 16831 }); 16832 }); 16833 16834 promise.then(function(){ 16835 var stringAsset = inlineScripts.join('\n'); 16836 BX.html(document.head, stringAsset, { useAdjacentHTML: true }).then(function(){ 16837 assetsLoaded.fulfill(response); 16838 }); 16839 }); 16840 16841 return assetsLoaded; 16842 }); 16843}; 16844 16845/** 16846 * 16847 * @param {string} action 16848 * @param {Object} config 16849 * @param {?string|?Object} [config.analyticsLabel] 16850 * @param {?Object} [config.analytics] 16851 * @param {string} [config.analytics.event] 16852 * @param {string} [config.analytics.tool] 16853 * @param {string} [config.analytics.category] 16854 * @param {?string} [config.analytics.c_section] 16855 * @param {?string} [config.analytics.c_sub_section] 16856 * @param {?string} [config.analytics.c_element] 16857 * @param {?string} [config.analytics.type] 16858 * @param {?string} [config.analytics.p1] 16859 * @param {?string} [config.analytics.p2] 16860 * @param {?string} [config.analytics.p3] 16861 * @param {?string} [config.analytics.p4] 16862 * @param {?string} [config.analytics.p5] 16863 * @param {?('success' | 'error' | 'attempt' | 'cancel')} [config.analytics.status] 16864 * @param {string} [config.method='POST'] 16865 * @param {Object} [config.data] 16866 * @param {?Object} [config.getParameters] 16867 * @param {?Object} [config.headers] 16868 * @param {?Object} [config.timeout] 16869 * @param {Object} [config.navigation] 16870 * @param {number} [config.navigation.page] 16871 */ 16872BX.ajax.runAction = function(action, config) 16873{ 16874 config = prepareAjaxConfig(config); 16875 var getParameters = prepareAjaxGetParameters(config); 16876 getParameters.action = action; 16877
16878 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 16879 return buildAjaxPromiseToRestoreCsrf({ 16880 method: config.method, 16881 dataType: 'json', 16882 url: url, 16883 data: config.data, 16884 timeout: config.timeout, 16885 preparePost: config.preparePost, 16886 headers: config.headers, 16887 onrequeststart: config.onrequeststart, 16888 onprogress: config.onprogress, 16889 onprogressupload: config.onprogressupload 16890 }); 16891}; 16892 16893/** 16894 * 16895 * @param {string} component 16896 * @param {string} action 16897 * @param {Object} config 16898 * @param {?string|?Object} [config.analyticsLabel] 16899 * @param {?Object} [config.analytics] 16900 * @param {string} [config.analytics.event] 16901 * @param {string} [config.analytics.tool] 16902 * @param {string} [config.analytics.category] 16903 * @param {?string} [config.analytics.c_section] 16904 * @param {?string} [config.analytics.c_sub_section] 16905 * @param {?string} [config.analytics.c_element] 16906 * @param {?string} [config.analytics.type] 16907 * @param {?string} [config.analytics.p1] 16908 * @param {?string} [config.analytics.p2] 16909 * @param {?string} [config.analytics.p3] 16910 * @param {?string} [config.analytics.p4] 16911 * @param {?string} [config.analytics.p5] 16912 * @param {?string} [config.signedParameters] 16913 * @param {string} [config.method='POST'] 16914 * @param {string} [config.mode='ajax'] Ajax or class. 16915 * @param {Object} [config.data] 16916 * @param {?Object} [config.getParameters] 16917 * @param {?array} [config.headers] 16918 * @param {?number} [config.timeout] 16919 * @param {Object} [config.navigation] 16920 */ 16921BX.ajax.runComponentAction = function (component, action, config) 16922{ 16923 config = prepareAjaxConfig(config); 16924 config.mode = config.mode || 'ajax'; 16925 16926 var getParameters = prepareAjaxGetParameters(config); 16927 getParameters.c = component; 16928 getParameters.action = action; 16929
16930 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 16931 16932 return buildAjaxPromiseToRestoreCsrf({ 16933 method: config.method, 16934 dataType: 'json', 16935 url: url, 16936 data: config.data, 16937 timeout: config.timeout, 16938 preparePost: config.preparePost, 16939 headers: config.headers, 16940 onrequeststart: (config.onrequeststart ? config.onrequeststart : null), 16941 onprogress: config.onprogress, 16942 onprogressupload: config.onprogressupload 16943 }); 16944}; 16945 16946/* 16947arObs = [{ 16948 url: url, 16949 type: html|script|json|css, 16950 callback: function 16951}] 16952*/ 16953BX.ajax.load = function(arObs, callback) 16954{ 16955 if (!BX.type.isArray(arObs)) 16956 arObs = [arObs]; 16957 16958 var cnt = 0; 16959 16960 if (!BX.type.isFunction(callback)) 16961 callback = BX.DoNothing; 16962 16963 var handler = function(data) 16964 { 16965 if (BX.type.isFunction(this.callback)) 16966 this.callback(data); 16967 16968 if (++cnt >= len) 16969 callback(); 16970 }; 16971 16972 for (var i = 0, len = arObs.length; i<len; i++) 16973 { 16974 switch(arObs[i].type.toUpperCase()) 16975 { 16976 case 'SCRIPT': 16977 BX.loadScript([arObs[i].url], BX.proxy(handler, arObs[i])); 16978 break; 16979 case 'CSS': 16980 BX.loadCSS([arObs[i].url]); 16981 16982 if (++cnt >= len) 16983 callback(); 16984 break; 16985 case 'JSON': 16986 BX.ajax.loadJSON(arObs[i].url, BX.proxy(handler, arObs[i])); 16987 break; 16988 16989 default: 16990 BX.ajax.get(arObs[i].url, '', BX.proxy(handler, arObs[i])); 16991 break; 16992 } 16993 } 16994}; 16995 16996/* ajax form sending */ 16997BX.ajax.submit = function(obForm, callback) 16998{ 16999 if (!obForm.target) 17000 { 17001 if (null == obForm.BXFormTarget) 17002 { 17003 var frame_name = 'formTarget_' + Math.random(); 17004 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 17005 props: { 17006 name: frame_name, 17007 id: frame_name, 17008 src: 'javascript:void(0)' 17009 }, 17010 style: { 17011 display: 'none' 17012 } 17013 })); 17014 } 17015 17016 obForm.target = obForm.BXFormTarget.name; 17017 } 17018 17019 obForm.BXFormCallback = callback; 17020 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 17021 17022 BX.submit(obForm); 17023 17024 return false; 17025}; 17026 17027BX.ajax.submitComponentForm = function(obForm, container, bWait) 17028{ 17029 if (!obForm.target) 17030 { 17031 if (null == obForm.BXFormTarget) 17032 { 17033 var frame_name = 'formTarget_' + Math.random(); 17034 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 17035 props: { 17036 name: frame_name, 17037 id: frame_name, 17038 src: 'javascript:void(0)' 17039 }, 17040 style: { 17041 display: 'none' 17042 } 17043 })); 17044 } 17045 17046 obForm.target = obForm.BXFormTarget.name; 17047 } 17048 17049 if (!!bWait) 17050 var w = BX.showWait(container); 17051 17052 obForm.BXFormCallback = function(d) { 17053 if (!!bWait) 17054 BX.closeWait(w); 17055 17056 var callOnload = function(){ 17057 if(!!window.bxcompajaxframeonload) 17058 { 17059 setTimeout(function(){window.bxcompajaxframeonload();window.bxcompajaxframeonload=null;}, 10); 17060 } 17061 }; 17062 17063 BX(container).innerHTML = d; 17064 BX.onCustomEvent('onAjaxSuccess', [null,null,callOnload]); 17065 }; 17066 17067 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 17068 17069 return true; 17070}; 17071 17072// func will be executed in form context 17073BX.ajax._submit_callback = function() 17074{ 17075 //opera and IE8 triggers onload event even on empty iframe 17076 try 17077 { 17078 if(this.BXFormTarget.contentWindow.location.href.indexOf('http') != 0) 17079 return; 17080 } catch (e) { 17081 return; 17082 } 17083 17084 if (this.BXFormCallback) 17085 this.BXFormCallback.apply(this, [this.BXFormTarget.contentWindow.document.body.innerHTML]); 17086 17087 BX.unbindAll(this.BXFormTarget); 17088}; 17089 17090BX.ajax.prepareForm = function(obForm, data) 17091{ 17092 data = (!!data ? data : {}); 17093 var i, ii, el, 17094 _data = [], 17095 n = obForm.elements.length, 17096 files = 0, length = 0; 17097 if(!!obForm) 17098 { 17099 for (i = 0; i < n; i++) 17100 { 17101 el = obForm.elements[i]; 17102 if (el.disabled) 17103 continue; 17104 17105 if(!el.type) 17106 continue; 17107 17108 switch(el.type.toLowerCase()) 17109 { 17110 case 'text': 17111 case 'textarea': 17112 case 'password': 17113 case 'number': 17114 case 'hidden': 17115 case 'select-one': 17116 _data.push({name: el.name, value: el.value}); 17117 length += (el.name.length + el.value.length); 17118 break; 17119 case 'file': 17120 if (!!el.files) 17121 { 17122 for (ii = 0; ii < el.files.length; ii++) 17123 { 17124 files++; 17125 _data.push({name: el.name, value: el.files[ii], file : true}); 17126 length += el.files[ii].size; 17127 } 17128 } 17129 break; 17130 case 'radio':
17131 case 'checkbox': 17132 if(el.checked) 17133 { 17134 _data.push({name: el.name, value: el.value}); 17135 length += (el.name.length + el.value.length); 17136 } 17137 break; 17138 case 'select-multiple': 17139 for (var j = 0; j < el.options.length; j++) 17140 { 17141 if (el.options[j].selected) 17142 { 17143 _data.push({name : el.name, value : el.options[j].value}); 17144 length += (el.name.length + el.options[j].length); 17145 } 17146 } 17147 break; 17148 default: 17149 break; 17150 } 17151 } 17152 17153 i = 0; length = 0; 17154 var current = data, name, rest, pp, tmpKey; 17155 17156 while(i < _data.length) 17157 { 17158 var p = _data[i].name.indexOf('['); 17159 if (tmpKey) 17160 { 17161 current[_data[i].name] = {}; 17162 current[_data[i].name][tmpKey.replace(/\[|\]/gi, '')] = _data[i].value; 17163 current = data; 17164 tmpKey = null; 17165 i++; 17166 } 17167 else if (p == -1) 17168 { 17169 current[_data[i].name] = _data[i].value; 17170 current = data; 17171 i++; 17172 } 17173 else 17174 { 17175 name = _data[i].name.substring(0, p); 17176 rest = _data[i].name.substring(p+1); 17177 pp = rest.indexOf(']'); 17178 17179 if(pp == -1) 17180 { 17181 if (!current[name]) 17182 current[name] = []; 17183 current = data; 17184 i++; 17185 } 17186 else if(pp == 0) 17187 { 17188 if (!current[name]) 17189 current[name] = []; 17190 //No index specified - so take the next integer 17191 current = current[name]; 17192 _data[i].name = '' + current.length; 17193 if (rest.substring(pp+1).indexOf('[') === 0) 17194 tmpKey = rest.substring(0, pp) + rest.substring(pp+1); 17195 } 17196 else 17197 { 17198 if (!current[name]) 17199 current[name] = {}; 17200 //Now index name becomes and name and we go deeper into the array 17201 current = current[name]; 17202 _data[i].name = rest.substring(0, pp) + rest.substring(pp+1); 17203 } 17204 } 17205 } 17206 } 17207 return {data : data, filesCount : files, roughSize : length}; 17208}; 17209BX.ajax.submitAjax = function(obForm, config) 17210{ 17211 config = (config !== null && typeof config == "object" ? config : {}); 17212 config.url = (config["url"] || obForm.getAttribute("action")); 17213 17214 var additionalData = (config["data"] || {}); 17215 config.data = BX.ajax.prepareForm(obForm).data; 17216 for (var ii in additionalData) 17217 { 17218 if (additionalData.hasOwnProperty(ii)) 17219 { 17220 config.data[ii] = additionalData[ii]; 17221 } 17222 } 17223 17224 if (!window["FormData"]) 17225 { 17226 BX.ajax(config); 17227 } 17228 else 17229 { 17230 var isFile = function(item) 17231 { 17232 var res = Object.prototype.toString.call(item); 17233 return (res == '[object File]' || res == '[object Blob]'); 17234 }, 17235 appendToForm = function(fd, key, val) 17236 { 17237 if (!!val && typeof val == "object" && !isFile(val)) 17238 { 17239 for (var ii in val) 17240 { 17241 if (val.hasOwnProperty(ii)) 17242 { 17243 appendToForm(fd, (key == '' ? ii : key + '[' + ii + ']'), val[ii]); 17244 } 17245 } 17246 } 17247 else 17248 fd.append(key, (!!val ? val : '')); 17249 }, 17250 prepareData = function(arData) 17251 { 17252 var data = {}; 17253 if (null != arData) 17254 { 17255 if(typeof arData == 'object') 17256 { 17257 for(var i in arData) 17258 { 17259 if (arData.hasOwnProperty(i)) 17260 { 17261 var name = BX.util.urlencode(i); 17262 if(typeof arData[i] == 'object' && arData[i]["file"] !== true) 17263 data[name] = prepareData(arData[i]); 17264 else if (arData[i]["file"] === true) 17265 data[name] = arData[i]["value"]; 17266 else 17267 data[name] = BX.util.urlencode(arData[i]); 17268 } 17269 } 17270 } 17271 else 17272 data = BX.util.urlencode(arData); 17273 } 17274 return data; 17275 }, 17276 fd = new window.FormData(); 17277 17278 if (config.method !== 'POST') 17279 { 17280 config.data = BX.ajax.prepareData(config.data); 17281 if (config.data) 17282 { 17283 config.url += (config.url.indexOf('?') !== -1 ? "&" : "?") + config.data; 17284 config.data = ''; 17285 } 17286 } 17287 else 17288 { 17289 if (config.preparePost === true) 17290 config.data = prepareData(config.data); 17291 appendToForm(fd, '', config.data); 17292 config.data = fd; 17293 } 17294 17295 config.preparePost = false; 17296 config.start = false;
17297 17298 var xhr = BX.ajax(config); 17299 if (!!config["onprogress"]) 17300 xhr.upload.addEventListener( 17301 'progress', 17302 function(e){ 17303 var percent = null; 17304 if(e.lengthComputable && (e.total || e["totalSize"])) { 17305 percent = e.loaded * 100 / (e.total || e["totalSize"]); 17306 } 17307 config["onprogress"](e, percent); 17308 } 17309 ); 17310 xhr.send(fd); 17311 } 17312}; 17313 17314BX.ajax.UpdatePageData = function (arData) 17315{ 17316 if (arData.TITLE) 17317 BX.ajax.UpdatePageTitle(arData.TITLE); 17318 if (arData.WINDOW_TITLE || arData.TITLE) 17319 BX.ajax.UpdateWindowTitle(arData.WINDOW_TITLE || arData.TITLE); 17320 if (arData.NAV_CHAIN) 17321 BX.ajax.UpdatePageNavChain(arData.NAV_CHAIN); 17322 if (arData.CSS && arData.CSS.length > 0) 17323 BX.loadCSS(arData.CSS); 17324 if (arData.SCRIPTS && arData.SCRIPTS.length > 0) 17325 { 17326 var f = function(result,config,cb){ 17327 17328 if(!!config && BX.type.isArray(config.scripts)) 17329 { 17330 for(var i=0,l=arData.SCRIPTS.length;i<l;i++) 17331 { 17332 config.scripts.push({isInternal:false,JS:arData.SCRIPTS[i]}); 17333 } 17334 } 17335 else 17336 { 17337 BX.loadScript(arData.SCRIPTS,cb); 17338 } 17339 17340 BX.removeCustomEvent('onAjaxSuccess',f); 17341 }; 17342 BX.addCustomEvent('onAjaxSuccess',f); 17343 } 17344 else 17345 { 17346 var f1 = function(result,config,cb){ 17347 if(BX.type.isFunction(cb)) 17348 { 17349 cb(); 17350 } 17351 BX.removeCustomEvent('onAjaxSuccess',f1); 17352 }; 17353 BX.addCustomEvent('onAjaxSuccess', f1); 17354 } 17355}; 17356 17357BX.ajax.UpdatePageTitle = function(title) 17358{ 17359 var obTitle = BX('pagetitle'); 17360 if (obTitle) 17361 { 17362 BX.remove(obTitle.firstChild); 17363 if (!obTitle.firstChild) 17364 obTitle.appendChild(document.createTextNode(title)); 17365 else 17366 obTitle.insertBefore(document.createTextNode(title), obTitle.firstChild); 17367 } 17368}; 17369 17370BX.ajax.UpdateWindowTitle = function(title) 17371{ 17372 document.title = title; 17373}; 17374 17375BX.ajax.UpdatePageNavChain = function(nav_chain) 17376{ 17377 var obNavChain = BX('navigation'); 17378 if (obNavChain) 17379 { 17380 obNavChain.innerHTML = nav_chain; 17381 } 17382}; 17383 17384/* user options handling */ 17385BX.userOptions = { 17386 options: null, 17387 bSend: false, 17388 delay: 5000, 17389 path: '/bitrix/admin/user_options.php?' 17390}; 17391 17392BX.userOptions.setAjaxPath = function(url) 17393{ 17394 // eslint-disable-next-line no-console 17395 console.warn('BX.userOptions.setAjaxPath is deprecated. There is no way to change ajax path.'); 17396}; 17397BX.userOptions.save = function(category, name, valueName, value, common) 17398{ 17399 if (BX.userOptions.options === null) 17400 { 17401 BX.userOptions.options = {}; 17402 } 17403 17404 common = Boolean(common); 17405 BX.userOptions.options[`${category}.${name}.${valueName}`] = [category, name, valueName, value, common]; 17406 17407 const stringPackedValue = BX.userOptions.__get(); 17408 if (stringPackedValue) 17409 { 17410 document.cookie = `${BX.message('COOKIE_PREFIX')}_LAST_SETTINGS=${encodeURIComponent(stringPackedValue)}&sessid=${BX.bitrix_sessid()}; expires=Thu, 31 Dec ${(new Date()).getFullYear() + 1} 23:59:59 GMT; path=/;`; 17411 } 17412 17413 if (!BX.userOptions.bSend) 17414 { 17415 BX.userOptions.bSend = true; 17416 setTimeout(() => { 17417 BX.userOptions.send(null); 17418 }, BX.userOptions.delay); 17419 } 17420}; 17421 17422BX.userOptions.send = function(callback) 17423{ 17424 const values = BX.userOptions.__get_values({ backwardCompatibility: true}); 17425 17426 BX.userOptions.options = null; 17427 BX.userOptions.bSend = false; 17428 17429 if (values) 17430 { 17431 document.cookie = `${BX.message('COOKIE_PREFIX')}_LAST_SETTINGS=; path=/;`; 17432 17433 BX.ajax.runAction( 17434 'main.userOption.saveOptions', 17435 { 17436 json: { 17437 newValues: values, 17438 }, 17439 }, 17440 ).then((response) => { 17441 if (BX.type.isFunction(callback)) 17442 { 17443 callback(response); 17444 } 17445 }); 17446 } 17447}; 17448 17449BX.userOptions.del = function(category, name, common, callback) 17450{ 17451 BX.ajax.runAction( 17452 'main.userOption.deleteOption', 17453 { 17454 json: { 17455 category, 17456 name, 17457 common, 17458 }, 17459 }, 17460 ).then((response) => { 17461 if (BX.type.isFunction(callback)) 17462 { 17463 callback(response); 17464 } 17465 }); 17466}; 17467 17468BX.userOptions.__get_values = function({ backwardCompatibility }) 17469{ 17470 if (!BX.userOptions || !BX.Type.isPlainObject(BX.userOptions.options)) 17471 { 17472 return null; 17473 } 17474 17475 const CATEGORY = 0; 17476 const NAME = 1; 17477 const VALUE_NAME = 2; 17478 const VALUE = 3; 17479 const IS_DEFAULT = 4; 17480 17481 const packedValues = { p: [] }; 17482 let currentIndex = -1; 17483 let previousOptionIdentifier = ''; 17484 17485 Object.entries(BX.userOptions.options).forEach(([key, userOption]) => { 17486 const category = userOption[CATEGORY]; 17487 const name = userOption[NAME]; 17488 const currentOptionIdentifier = `${category}.${name}`; 17489 17490 if (previousOptionIdentifier !== currentOptionIdentifier) 17491 { 17492 currentIndex++; 17493 packedValues.p.push({ 17494 c: category, 17495 n: name, 17496 v: {}, 17497 }); 17498 if (userOption[IS_DEFAULT] === true) 17499 { 17500 packedValues.p[currentIndex].d = 'Y'; 17501 } 17502 previousOptionIdentifier = currentOptionIdentifier; 17503 } 17504 17505 if (userOption[VALUE_NAME] === null) 17506 { 17507 packedValues.p[currentIndex].v = userOption[VALUE]; 17508 } 17509 else 17510 { 17511 let data = userOption[VALUE]; 17512 if (backwardCompatibility && Array.isArray(userOption[VALUE])) 17513 { 17514 data = userOption[VALUE].join(','); 17515 } 17516 packedValues.p[currentIndex].v[userOption[VALUE_NAME]] = data; 17517 } 17518 }); 17519 17520 return packedValues.p.length > 0 ? packedValues.p : null; 17521}; 17522 17523/** 17524 * @deprecated Use instead BX.userOptions.__get_values. 17525 * */ 17526BX.userOptions.__get = function() 17527{ 17528 if (!BX.userOptions.options) return ''; 17529 17530 var sParam = '', n = -1, prevParam = '', aOpt, i; 17531 17532 for (i in BX.userOptions.options) 17533 { 17534 if(BX.userOptions.options.hasOwnProperty(i)) 17535 { 17536 aOpt = BX.userOptions.options[i]; 17537 17538 if (prevParam != aOpt[0]+'.'+aOpt[1]) 17539 { 17540 n++; 17541 sParam += '&p['+n+'][c]='+BX.util.urlencode(aOpt[0]); 17542 sParam += '&p['+n+'][n]='+BX.util.urlencode(aOpt[1]); 17543 if (aOpt[4] == true) 17544 sParam += '&p['+n+'][d]=Y'; 17545 prevParam = aOpt[0]+'.'+aOpt[1]; 17546 } 17547 17548 var valueName = aOpt[2]; 17549 var value = aOpt[3]; 17550 17551 if (valueName === null) 17552 { 17553 sParam += '&p['+n+'][v]='+BX.util.urlencode(value); 17554 } 17555 else 17556 {
17557 sParam += '&p['+n+'][v]['+BX.util.urlencode(valueName)+']='+BX.util.urlencode(value); 17558 } 17559 } 17560 } 17561 17562 return sParam.substr(1); 17563}; 17564 17565BX.ajax.history = { 17566 expected_hash: '', 17567 17568 obParams: null, 17569 17570 obFrame: null, 17571 obImage: null, 17572 17573 obTimer: null, 17574 17575 bInited: false, 17576 bHashCollision: false, 17577 bPushState: !!(history.pushState && BX.type.isFunction(history.pushState)), 17578 17579 startState: null, 17580 17581 init: function(obParams) 17582 { 17583 if (BX.ajax.history.bInited) 17584 return; 17585 17586 this.obParams = obParams; 17587 var obCurrentState = this.obParams.getState(); 17588 17589 if (BX.ajax.history.bPushState) 17590 { 17591 BX.ajax.history.expected_hash = window.location.pathname; 17592 if (window.location.search) 17593 BX.ajax.history.expected_hash += window.location.search; 17594 17595 BX.ajax.history.put(obCurrentState, BX.ajax.history.expected_hash, '', true); 17596 // due to some strange thing, chrome calls popstate event on page start. so we should delay it 17597 setTimeout(function(){BX.bind(window, 'popstate', BX.ajax.history.__hashListener);}, 500); 17598 } 17599 else 17600 { 17601 BX.ajax.history.expected_hash = window.location.hash; 17602 17603 if (!BX.ajax.history.expected_hash || BX.ajax.history.expected_hash == '#') 17604 BX.ajax.history.expected_hash = '__bx_no_hash__'; 17605 17606 jsAjaxHistoryContainer.put(BX.ajax.history.expected_hash, obCurrentState); 17607 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 17608 17609 if (BX.browser.IsIE()) 17610 { 17611 BX.ajax.history.obFrame = document.createElement('IFRAME'); 17612 BX.hide_object(BX.ajax.history.obFrame); 17613 17614 document.body.appendChild(BX.ajax.history.obFrame); 17615 17616 BX.ajax.history.obFrame.contentWindow.document.open(); 17617 BX.ajax.history.obFrame.contentWindow.document.write(BX.ajax.history.expected_hash); 17618 BX.ajax.history.obFrame.contentWindow.document.close(); 17619 } 17620 else if (BX.browser.IsOpera()) 17621 { 17622 BX.ajax.history.obImage = document.createElement('IMG'); 17623 BX.hide_object(BX.ajax.history.obImage); 17624 17625 document.body.appendChild(BX.ajax.history.obImage); 17626 17627 BX.ajax.history.obImage.setAttribute('src', 'javascript:location.href = \'javascript:BX.ajax.history.__hashListener();\';'); 17628 } 17629 } 17630 17631 BX.ajax.history.bInited = true; 17632 }, 17633 17634 __hashListener: function(e) 17635 { 17636 e = e || window.event || {state:false}; 17637 17638 if (BX.ajax.history.bPushState) 17639 { 17640 BX.ajax.history.obParams.setState(e.state||BX.ajax.history.startState); 17641 } 17642 else 17643 { 17644 if (BX.ajax.history.obTimer) 17645 { 17646 window.clearTimeout(BX.ajax.history.obTimer); 17647 BX.ajax.history.obTimer = null; 17648 } 17649 17650 var current_hash; 17651 if (null != BX.ajax.history.obFrame) 17652 current_hash = BX.ajax.history.obFrame.contentWindow.document.body.innerText; 17653 else 17654 current_hash = window.location.hash; 17655 17656 if (!current_hash || current_hash == '#') 17657 current_hash = '__bx_no_hash__'; 17658 17659 if (current_hash.indexOf('#') == 0) 17660 current_hash = current_hash.substring(1); 17661 17662 if (current_hash != BX.ajax.history.expected_hash) 17663 { 17664 var state = jsAjaxHistoryContainer.get(current_hash); 17665 if (state) 17666 { 17667 BX.ajax.history.obParams.setState(state); 17668 17669 BX.ajax.history.expected_hash = current_hash; 17670 if (null != BX.ajax.history.obFrame) 17671 { 17672 var __hash = current_hash == '__bx_no_hash__' ? '' : current_hash; 17673 if (window.location.hash != __hash && window.location.hash != '#' + __hash) 17674 window.location.hash = __hash; 17675 } 17676 } 17677 } 17678 17679 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 17680 } 17681 }, 17682 17683 put: function(state, new_hash, new_hash1, bStartState) 17684 { 17685 if (this.bPushState) 17686 { 17687 if(!bStartState) 17688 { 17689 history.pushState(state, '', new_hash); 17690 } 17691 else 17692 { 17693 BX.ajax.history.startState = state; 17694 } 17695 } 17696 else 17697 { 17698 if (typeof new_hash1 != 'undefined') 17699 new_hash = new_hash1; 17700 else 17701 new_hash = 'view' + new_hash; 17702 17703 jsAjaxHistoryContainer.put(new_hash, state); 17704 BX.ajax.history.expected_hash = new_hash; 17705 17706 window.location.hash = BX.util.urlencode(new_hash); 17707 17708 if (null != BX.ajax.history.obFrame) 17709 { 17710 BX.ajax.history.obFrame.contentWindow.document.open(); 17711 BX.ajax.history.obFrame.contentWindow.document.write(new_hash); 17712 BX.ajax.history.obFrame.contentWindow.document.close(); 17713 } 17714 } 17715 }, 17716 17717 checkRedirectStart: function(param_name, param_value) 17718 { 17719 var current_hash = window.location.hash; 17720 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 17721 17722 var test = current_hash.substring(0, 5); 17723 if (test == 'view/' || test == 'view%') 17724 { 17725 BX.ajax.history.bHashCollision = true;
17726 document.write('<' + 'div id="__ajax_hash_collision_' + param_value + '" style="display: none;">'); 17727 } 17728 }, 17729 17730 checkRedirectFinish: function(param_name, param_value) 17731 { 17732 document.write('</div>'); 17733 17734 var current_hash = window.location.hash; 17735 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 17736 17737 BX.ready(function () 17738 { 17739 var test = current_hash.substring(0, 5); 17740 if (test == 'view/' || test == 'view%') 17741 { 17742 var obColNode = BX('__ajax_hash_collision_' + param_value); 17743 var obNode = obColNode.firstChild; 17744 BX.cleanNode(obNode); 17745 obColNode.style.display = 'block'; 17746 17747 // IE, Opera and Chrome automatically modifies hash with urlencode, but FF doesn't ;-( 17748 if (test != 'view%') 17749 current_hash = BX.util.urlencode(current_hash); 17750 17751 current_hash += (current_hash.indexOf('%3F') == -1 ? '%3F' : '%26') + param_name + '=' + param_value; 17752 17753 var url = '/bitrix/tools/ajax_redirector.php?hash=' + current_hash; 17754 17755 BX.ajax.insertToNode(url, obNode); 17756 } 17757 }); 17758 } 17759}; 17760 17761BX.ajax.component = function(node) 17762{ 17763 this.node = node; 17764}; 17765 17766BX.ajax.component.prototype.getState = function() 17767{ 17768 var state = { 17769 'node': this.node, 17770 'title': window.document.title, 17771 'data': BX(this.node).innerHTML 17772 }; 17773 17774 var obNavChain = BX('navigation'); 17775 if (null != obNavChain) 17776 state.nav_chain = obNavChain.innerHTML; 17777 17778 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistoryGetState", [state]); 17779 17780 return state; 17781}; 17782 17783BX.ajax.component.prototype.setState = function(state) 17784{ 17785 BX(state.node).innerHTML = state.data; 17786 BX.ajax.UpdatePageTitle(state.title); 17787 17788 if (state.nav_chain) 17789 { 17790 BX.ajax.UpdatePageNavChain(state.nav_chain); 17791 } 17792 17793 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistorySetState", [state]); 17794}; 17795 17796var jsAjaxHistoryContainer = { 17797 arHistory: {}, 17798 17799 put: function(hash, state) 17800 { 17801 this.arHistory[hash] = state; 17802 }, 17803 17804 get: function(hash) 17805 { 17806 return this.arHistory[hash]; 17807 } 17808}; 17809 17810 17811BX.ajax.FormData = function() 17812{ 17813 this.elements = []; 17814 this.files = []; 17815 this.features = {}; 17816 this.isSupported(); 17817 this.log('BX FormData init'); 17818}; 17819 17820BX.ajax.FormData.isSupported = function() 17821{ 17822 var f = new BX.ajax.FormData(); 17823 var result = f.features.supported; 17824 f = null; 17825 return result; 17826}; 17827 17828BX.ajax.FormData.prototype.log = function(o) 17829{ 17830 if (false) { 17831 try { 17832 if (BX.browser.IsIE()) o = JSON.stringify(o); 17833 console.log(o); 17834 } catch(e) {} 17835 } 17836}; 17837 17838BX.ajax.FormData.prototype.isSupported = function() 17839{ 17840 var f = {}; 17841 f.fileReader = (window.FileReader && window.FileReader.prototype.readAsBinaryString); 17842 f.readFormData = f.sendFormData = !!(window.FormData); 17843 f.supported = !!(f.readFormData && f.sendFormData); 17844 this.features = f; 17845 this.log('features:'); 17846 this.log(f); 17847 17848 return f.supported; 17849}; 17850 17851BX.ajax.FormData.prototype.append = function(name, value) 17852{ 17853 if (typeof(value) === 'object') { // seems to be files element 17854 this.files.push({'name': name, 'value':value}); 17855 } else { 17856 this.elements.push({'name': name, 'value':value}); 17857 } 17858}; 17859 17860BX.ajax.FormData.prototype.send = function(url, callbackOk, callbackProgress, callbackError) 17861{ 17862 this.log('FD send'); 17863 this.xhr = BX.ajax({ 17864 'method': 'POST', 17865 'dataType': 'html', 17866 'url': url, 17867 'onsuccess': callbackOk, 17868 'onfailure': callbackError, 17869 'start': false, 17870 'preparePost':false 17871 }); 17872 17873 if (callbackProgress) 17874 { 17875 this.xhr.upload.addEventListener( 17876 'progress', 17877 function(e) { 17878 if (e.lengthComputable) 17879 callbackProgress(e.loaded / (e.total || e.totalSize)); 17880 }, 17881 false 17882 ); 17883 } 17884 17885 if (this.features.readFormData && this.features.sendFormData) 17886 { 17887 var fd = new FormData(); 17888 this.log('use browser formdata'); 17889 for (var i in this.elements) 17890 { 17891 if(this.elements.hasOwnProperty(i)) 17892 fd.append(this.elements[i].name,this.elements[i].value); 17893 } 17894 for (i in this.files) 17895 { 17896 if(this.files.hasOwnProperty(i)) 17897 fd.append(this.files[i].name, this.files[i].value); 17898 } 17899 this.xhr.send(fd); 17900 } 17901 17902 return this.xhr; 17903}; 17904 17905BX.addCustomEvent('onAjaxFailure', BX.debug); 17906})(window); 17907 17908 17909(function (exports,main_core) { 17910 'use strict'; 17911 17912 var LazyLoad = { 17913 observer: null, 17914 images: {}, 17915 imageStatus: { 17916 hidden: -2, 17917 error: -1, 17918 "undefined": 0, 17919 inited: 1, 17920 loaded: 2 17921 }, 17922 imageTypes: { 17923 image: 1, 17924 background: 2 17925 },
17926 initObserver: function initObserver() { 17927 this.observer = new IntersectionObserver(this.onIntersection.bind(this), { 17928 rootMargin: '20% 0% 20% 0%', 17929 threshold: 0.10 17930 }); 17931 }, 17932 onIntersection: function onIntersection(entries) { 17933 entries.forEach(function (entry) { 17934 if (entry.isIntersecting) { 17935 this.showImage(entry.target); 17936 } 17937 }.bind(this)); 17938 }, 17939 registerImage: function registerImage(id, isImageVisibleCallback, options) { 17940 if (this.observer === null) { 17941 this.initObserver(); 17942 } 17943 17944 options = options || {}; 17945 17946 if (!main_core.Type.isStringFilled(id)) { 17947 return; 17948 } 17949 17950 if (main_core.Type.isObject(this.images[id])) { 17951 return; 17952 } 17953 17954 var element = document.getElementById(id); 17955 17956 if (!main_core.Type.isDomNode(element)) { 17957 return; 17958 } 17959 17960 this.observer.observe(element); 17961 this.images[id] = { 17962 id: id, 17963 node: null, 17964 src: null, 17965 dataSrcName: options.dataSrcName || 'src', 17966 type: null, 17967 func: main_core.Type.isFunction(isImageVisibleCallback) ? isImageVisibleCallback : null, 17968 status: this.imageStatus.undefined 17969 }; 17970 }, 17971 registerImages: function registerImages(ids, isImageVisibleCallback, options) { 17972 if (main_core.Type.isArray(ids)) { 17973 for (var i = 0, length = ids.length; i < length; i++) { 17974 this.registerImage(ids[i], isImageVisibleCallback, options); 17975 } 17976 } 17977 }, 17978 showImage: function showImage(imageNode) { 17979 var imageNodeId = imageNode.id; 17980 17981 if (!main_core.Type.isStringFilled(imageNodeId)) { 17982 return; 17983 } 17984 17985 var image = this.images[imageNodeId]; 17986 17987 if (!main_core.Type.isPlainObject(image)) { 17988 return; 17989 } 17990 17991 if (image.status == this.imageStatus.undefined) { 17992 this.initImage(image); 17993 } 17994 17995 if (image.status !== this.imageStatus.inited) { 17996 return; 17997 } 17998 17999 if (!image.node || !image.node.parentNode) { 18000 image.node = null; 18001 image.status = this.imageStatus.error; 18002 return; 18003 } 18004 18005 if (image.type == this.imageTypes.image) { 18006 image.node.src = image.src; 18007 } else { 18008 image.node.style.backgroundImage = "url('" + image.src + "')"; 18009 } 18010 18011 image.node.dataset[image.dataSrcName] = ""; 18012 image.status = this.imageStatus.loaded; 18013 }, 18014 showImages: function showImages(checkOwnVisibility) { 18015 checkOwnVisibility = checkOwnVisibility !== false; 18016 18017 for (var id in this.images) { 18018 if (!this.images.hasOwnProperty(id)) { 18019 continue; 18020 } 18021 18022 var image = this.images[id]; 18023 18024 if (image.status == this.imageStatus.undefined) { 18025 this.initImage(image); 18026 } 18027 18028 if (image.status !== this.imageStatus.inited) { 18029 continue; 18030 } 18031 18032 if (!image.node || !image.node.parentNode) { 18033 image.node = null; 18034 image.status = this.imageStatus.error; 18035 continue; 18036 } 18037 18038 var isImageVisible = true; 18039 18040 if (checkOwnVisibility && main_core.Type.isFunction(image.func)) { 18041 isImageVisible = image.func(image); 18042 } 18043 18044 if (isImageVisible === true && this.isElementVisibleOnScreen(image.node)) { 18045 if (image.type == this.imageTypes.image) { 18046 image.node.src = image.src; 18047 } else { 18048 image.node.style.backgroundImage = "url('" + image.src + "')"; 18049 } 18050 18051 image.node.dataset[image.dataSrcName] = ""; 18052 image.status = this.imageStatus.loaded; 18053 } 18054 } 18055 }, 18056 initImage: function initImage(image) { 18057 image.status = this.imageStatus.error; 18058 var node = document.getElementById(image.id); 18059 18060 if (!main_core.Type.isDomNode(node)) { 18061 return; 18062 } 18063 18064 var src = node.dataset[image.dataSrcName]; 18065 18066 if (main_core.Type.isStringFilled(src)) { 18067 image.node = node; 18068 image.src = src; 18069 image.status = this.imageStatus.inited; 18070 image.type = image.node.tagName.toLowerCase() == "img" ? this.imageTypes.image : this.imageTypes.background; 18071 } 18072 }, 18073 isElementVisibleOnScreen: function isElementVisibleOnScreen(element) { 18074 var coords = this.getElementCoords(element); 18075 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 18076 var windowBottom = windowTop + document.documentElement.clientHeight; 18077 coords.bottom = coords.top + element.offsetHeight; 18078 return coords.top > windowTop && coords.top < windowBottom || // topVisible 18079 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 18080 ; 18081 }, 18082 isElementVisibleOn2Screens: function isElementVisibleOn2Screens(element) { 18083 var windowHeight = document.documentElement.clientHeight; 18084 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 18085 var windowBottom = windowTop + windowHeight; 18086 var coords = this.getElementCoords(element); 18087 coords.bottom = coords.top + element.offsetHeight; 18088 windowTop -= windowHeight; 18089 windowBottom += windowHeight; 18090 return coords.top > windowTop && coords.top < windowBottom || // topVisible 18091 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 18092 ; 18093 }, 18094 getElementCoords: function getElementCoords(element) { 18095 var box = element.getBoundingClientRect(); 18096 return { 18097 originTop: box.top, 18098 originLeft: box.left, 18099 top: box.top + window.pageYOffset, 18100 left: box.left + window.pageXOffset 18101 }; 18102 }, 18103 onScroll: function onScroll() {}, 18104 clearImages: function clearImages() { 18105 this.images = []; 18106 } 18107 }; 18108 18109 exports.LazyLoad = LazyLoad; 18110 18111}((this.BX = this.BX || {}),BX)); 18112 18113 18114 18115(function (exports) { 18116 'use strict'; 18117 18118 var ParamBag = /*#__PURE__*/function () { 18119 function ParamBag() { 18120 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 18121 babelHelpers.classCallCheck(this, ParamBag); 18122 18123 if (!!params && babelHelpers.typeof(params) === 'object') { 18124 this.params = new Map(Object.entries(params)); 18125 } else { 18126 this.params = new Map(); 18127 } 18128 } 18129 18130 babelHelpers.createClass(ParamBag, [{ 18131 key: "getParam", 18132 value: function getParam(key) { 18133 var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 18134 18135 if (this.params.has(key)) { 18136 return this.params.get(key); 18137 } 18138 18139 return defaultValue; 18140 } 18141 }, { 18142 key: "setParam", 18143 value: function setParam(key, value) { 18144 this.params.set(key, value); 18145 } 18146 }, { 18147 key: "clear", 18148 value: function clear() { 18149 this.params.clear(); 18150 } 18151 }], [{ 18152 key: "create", 18153 value: function create() { 18154 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 18155 return new ParamBag(params); 18156 } 18157 }]); 18158 return ParamBag; 18159 }(); 18160 18161 exports.ParamBag = ParamBag; 18162 18163}((this.BX = this.BX || {}))); 18164 18165 18166 18167(function() { 18168 BX.FixFontSize = function(params) 18169 { 18170 var widthNode, computedStyles, width; 18171 18172 this.node = null; 18173 this.prevWindowSize = 0; 18174 this.prevWrapperSize = 0; 18175 this.mainWrapper = null; 18176 this.textWrapper = null; 18177 this.objList = params.objList; 18178 this.minFontSizeList = []; 18179 this.minFontSize = 0; 18180 18181 if (params.onresize) 18182 { 18183 this.prevWindowSize = window.innerWidth || document.documentElement.clientWidth; 18184 BX.bind(window, 'resize', BX.throttle(this.onResize, 350, this)); 18185 } 18186 18187 if (params.onAdaptiveResize) 18188 { 18189 widthNode = this.objList[0].scaleBy || this.objList[0].node; 18190 computedStyles = getComputedStyle(widthNode); 18191 this.prevWrapperSize = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18192 BX.bind(window, 'resize', BX.throttle(this.onAdaptiveResize, 350, this)); 18193 } 18194 18195 this.createTestNodes(); 18196 this.decrease(); 18197 }; 18198 18199 BX.FixFontSize.prototype = 18200 { 18201 createTestNodes: function() 18202 { 18203 this.textWrapper = BX.create('div',{ 18204 style : { 18205 display : 'inline-block', 18206 whiteSpace : 'nowrap' 18207 } 18208 }); 18209 18210 this.mainWrapper = BX.create('div',{ 18211 style : { 18212 height : 0, 18213 overflow : 'hidden' 18214 }, 18215 children : [this.textWrapper] 18216 }); 18217 18218 }, 18219 insertTestNodes: function() 18220 { 18221 document.body.appendChild(this.mainWrapper); 18222 }, 18223 removeTestNodes: function() 18224 { 18225 document.body.removeChild(this.mainWrapper); 18226 }, 18227 decrease: function() 18228 { 18229 var width, 18230 fontSize, 18231 widthNode, 18232 computedStyles; 18233 18234 this.insertTestNodes(); 18235
18236 for(var i=this.objList.length-1; i>=0; i--) 18237 { 18238 widthNode = this.objList[i].scaleBy || this.objList[i].node; 18239 computedStyles = getComputedStyle(widthNode); 18240 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18241 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 18242 18243 this.textWrapperSetStyle(this.objList[i].node); 18244 18245 if(this.textWrapperInsertText(this.objList[i].node)) 18246 { 18247 while(this.textWrapper.offsetWidth > width && fontSize > 0) 18248 { 18249 this.textWrapper.style.fontSize = --fontSize + 'px'; 18250 } 18251 18252 if(this.objList[i].smallestValue) 18253 { 18254 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 18255 18256 this.minFontSizeList.push(this.objList[i].node) 18257 } 18258 else 18259 { 18260 this.objList[i].node.style.fontSize = fontSize + 'px'; 18261 } 18262 } 18263 } 18264 18265 if(this.minFontSizeList.length > 0) 18266 this.setMinFont(); 18267 18268 this.removeTestNodes(); 18269 18270 }, 18271 increase: function() 18272 { 18273 this.insertTestNodes(); 18274 var width, 18275 fontSize, 18276 widthNode, 18277 computedStyles; 18278 18279 this.insertTestNodes(); 18280 18281 for(var i=this.objList.length-1; i>=0; i--) 18282 { 18283 widthNode = this.objList[i].scaleBy || this.objList[i].node; 18284 computedStyles = getComputedStyle(widthNode); 18285 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18286 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 18287 18288 this.textWrapperSetStyle(this.objList[i].node); 18289 18290 if(this.textWrapperInsertText(this.objList[i].node)) 18291 { 18292 while(this.textWrapper.offsetWidth < width && fontSize < this.objList[i].maxFontSize) 18293 { 18294 this.textWrapper.style.fontSize = ++fontSize + 'px'; 18295 } 18296 18297 fontSize--; 18298 18299 if(this.objList[i].smallestValue) 18300 { 18301 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 18302 18303 this.minFontSizeList.push(this.objList[i].node) 18304 } 18305 else 18306 { 18307 this.objList[i].node.style.fontSize = fontSize + 'px'; 18308 } 18309 } 18310 } 18311 18312 if(this.minFontSizeList.length > 0) 18313 this.setMinFont(); 18314 18315 this.removeTestNodes(); 18316 }, 18317 setMinFont : function() 18318 { 18319 for(var i = this.minFontSizeList.length-1; i>=0; i--) 18320 { 18321 this.minFontSizeList[i].style.fontSize = this.minFontSize + 'px'; 18322 } 18323 18324 this.minFontSize = 0; 18325 }, 18326 onResize : function() 18327 { 18328 var width = window.innerWidth || document.documentElement.clientWidth; 18329 18330 if(this.prevWindowSize > width) 18331 this.decrease(); 18332 18333 else if (this.prevWindowSize < width) 18334 this.increase(); 18335 18336 this.prevWindowSize = width; 18337 }, 18338 onAdaptiveResize : function() 18339 { 18340 var widthNode = this.objList[0].scaleBy || this.objList[0].node, 18341 computedStyles = getComputedStyle(widthNode), 18342 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18343 18344 if (this.prevWrapperSize > width) 18345 this.decrease(); 18346 else if (this.prevWrapperSize < width) 18347 this.increase(); 18348 18349 this.prevWrapperSize = width; 18350 }, 18351 textWrapperInsertText : function(node) 18352 { 18353 if(node.textContent){ 18354 this.textWrapper.textContent = node.textContent; 18355 return true; 18356 } 18357 else if(node.innerText) 18358 { 18359 this.textWrapper.innerText = node.innerText; 18360 return true; 18361 } 18362 else { 18363 return false; 18364 } 18365 }, 18366 textWrapperSetStyle : function(node) 18367 { 18368 this.textWrapper.style.fontFamily = getComputedStyle(node)["font-family"]; 18369 this.textWrapper.style.fontSize = getComputedStyle(node)["font-size"]; 18370 this.textWrapper.style.fontStyle = getComputedStyle(node)["font-style"]; 18371 this.textWrapper.style.fontWeight = getComputedStyle(node)["font-weight"]; 18372 this.textWrapper.style.lineHeight = getComputedStyle(node)["line-height"]; 18373 } 18374 }; 18375 18376 BX.FixFontSize.init = function(params) 18377 { 18378 return new BX.FixFontSize(params); 18379 }; 18380})(); 18381 18382})(); 18383//# sourceMappingURL=core.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.