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;
vendor: 4,394 bytes, lines 2266-2394
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 }
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;
vendor: 6,238 bytes, lines 3147-3361
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);
vendor: 5,073 bytes, lines 3362-3500
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;
vendor: 4,474 bytes, lines 4375-4518
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 this.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 this.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 function fetchExtensionSettings(html) { 6547 if (Type.isStringFilled(html)) { 6548 const scripts = html.match(/<script type="extension\/settings" \b[^>]*>([\s\S]*?)<\/script>/g); 6549 if (Type.isArrayFilled(scripts)) { 6550 return scripts.map(script => { 6551 const [, extension] = script.match(/data-extension="(.[a-z0-9_.-]+)"/); 6552 return { 6553 extension, 6554 script 6555 }; 6556 }); 6557 } 6558 } 6559 return []; 6560 } 6561 6562 let Extension = /*#__PURE__*/function () { 6563 function Extension(options) { 6564 babelHelpers.classCallCheck(this, Extension); 6565 this.config = options.config || {}; 6566 this.name = options.extension; 6567 this.state = 'scheduled'; 6568 6569 // eslint-disable-next-line 6570 const result = BX.processHTML(options.html || ''); 6571 this.inlineScripts = result.SCRIPT.reduce(inlineScripts, []); 6572 this.externalScripts = result.SCRIPT.reduce(externalScripts, []); 6573 this.externalStyles = result.STYLE.reduce(externalStyles, []); 6574 this.settingsScripts = fetchExtensionSettings(result.HTML); 6575 } 6576 babelHelpers.createClass(Extension, [{ 6577 key: "load", 6578 value: function load() { 6579 if (this.state === 'error') { 6580 this.loadPromise = this.loadPromise || Promise.resolve(this); 6581 console.warn('Extension', this.name, 'not found'); 6582 } 6583 if (!this.loadPromise && this.state) { 6584 this.state = 'load';
6585 this.settingsScripts.forEach(entry => { 6586 const isLoaded = !!document.querySelector(`script[data-extension="${entry.extension}"]`); 6587 if (!isLoaded) { 6588 document.body.insertAdjacentHTML('beforeend', entry.script); 6589 } 6590 }); 6591 this.inlineScripts.forEach(BX.evalGlobal); 6592 this.loadPromise = Promise.all([loadAll(this.externalScripts), loadAll(this.externalStyles)]).then(() => { 6593 this.state = 'loaded'; 6594 if (Type.isPlainObject(this.config) && this.config.namespace) { 6595 return Reflection.getClass(this.config.namespace); 6596 } 6597 return window; 6598 }); 6599 } 6600 return this.loadPromise; 6601 } 6602 }]); 6603 return Extension; 6604 }(); 6605 6606 const initialized = {}; 6607 const ajaxController = 'main.bitrix.main.controller.loadext.getextensions'; 6608 6609 function makeIterable(value) { 6610 return Type.isArray(value) ? value : [value]; 6611 } 6612 function isInitialized(extension) { 6613 return extension in initialized; 6614 } 6615 function getInitialized(extension) { 6616 return initialized[extension]; 6617 } 6618 function isAllInitialized(extensions) { 6619 return extensions.every(isInitialized); 6620 } 6621 function loadExtensions(extensions) { 6622 return Promise.all(extensions.map(item => item.load())); 6623 } 6624 function mergeExports(exports) { 6625 return exports.reduce((acc, currentExports) => { 6626 if (Type.isObject(currentExports)) { 6627 return { 6628 ...currentExports 6629 }; 6630 } 6631 return currentExports; 6632 }, {}); 6633 } 6634 function inlineScripts(acc, item) { 6635 if (item.isInternal) { 6636 acc.push(item.JS); 6637 } 6638 return acc; 6639 } 6640 function externalScripts(acc, item) { 6641 if (!item.isInternal) { 6642 acc.push(item.JS); 6643 } 6644 return acc; 6645 } 6646 function externalStyles(acc, item) { 6647 if (Type.isString(item) && item !== '') { 6648 acc.push(item); 6649 } 6650 return acc; 6651 } 6652 function request(options) { 6653 return new Promise(resolve => { 6654 // eslint-disable-next-line 6655 BX.ajax.runAction(ajaxController, { 6656 data: options 6657 }).then(resolve); 6658 }); 6659 } 6660 function prepareExtensions(response) { 6661 if (response.status !== 'success') { 6662 response.errors.map(console.warn); 6663 return []; 6664 } 6665 return response.data.map(item => { 6666 const initializedExtension = getInitialized(item.extension); 6667 if (initializedExtension) { 6668 return initializedExtension; 6669 } 6670 initialized[item.extension] = new Extension(item); 6671 return initialized[item.extension]; 6672 }); 6673 } 6674 function loadAll(items) { 6675 const itemsList = makeIterable(items); 6676 if (!itemsList.length) { 6677 return Promise.resolve(); 6678 } 6679 return new Promise(resolve => { 6680 // eslint-disable-next-line 6681 BX.load(itemsList, resolve); 6682 }); 6683 } 6684 6685 /** 6686 * Loads extensions asynchronously 6687 * @param {string|Array<string>} extension 6688 * @return {Promise<Array<Extension>>} 6689 */ 6690 function loadExtension(extension) { 6691 const extensions = makeIterable(extension); 6692 const isAllInitialized$$1 = isAllInitialized(extensions); 6693 if (isAllInitialized$$1) { 6694 const initializedExtensions = extensions.map(getInitialized); 6695 return loadExtensions(initializedExtensions).then(mergeExports); 6696 } 6697 return request({ 6698 extension: extensions 6699 }).then(prepareExtensions).then(loadExtensions).then(mergeExports); 6700 } 6701 6702 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]']; 6703 function isCloneable(value) { 6704 const isCloneableValue = Type.isObjectLike(value) && cloneableTags.includes(getTag(value)); 6705 return isCloneableValue || Type.isDomNode(value); 6706 } 6707 function internalClone(value, map) { 6708 if (map.has(value)) { 6709 return map.get(value); 6710 } 6711 if (isCloneable(value)) { 6712 if (Type.isArray(value)) { 6713 const cloned = Array.from(value); 6714 map.set(value, cloned); 6715 value.forEach((item, index) => { 6716 cloned[index] = internalClone(item, map); 6717 }); 6718 return map.get(value); 6719 } 6720 if (Type.isDomNode(value)) { 6721 return value.cloneNode(true); 6722 } 6723 if (Type.isMap(value)) { 6724 const result = new Map(); 6725 map.set(value, result); 6726 value.forEach((item, key) => { 6727 result.set(internalClone(key, map), internalClone(item, map)); 6728 }); 6729 return result; 6730 } 6731 if (Type.isSet(value)) { 6732 const result = new Set(); 6733 map.set(value, result); 6734 value.forEach(item => { 6735 result.add(internalClone(item, map)); 6736 }); 6737 return result; 6738 } 6739 if (Type.isDate(value)) { 6740 return new Date(value); 6741 } 6742 if (Type.isRegExp(value)) { 6743 const regExpFlags = /\w*$/; 6744 const flags = regExpFlags.exec(value); 6745 let result = new RegExp(value.source); 6746 if (flags && Type.isArray(flags)) { 6747 result = new RegExp(value.source, flags[0]); 6748 } 6749 result.lastIndex = value.lastIndex; 6750 return result; 6751 } 6752 const proto = Object.getPrototypeOf(value); 6753 const result = Object.assign(Object.create(proto), value); 6754 map.set(value, result); 6755 Object.keys(value).forEach(key => { 6756 result[key] = internalClone(value[key], map); 6757 }); 6758 return result; 6759 } 6760 return value; 6761 } 6762 6763 /** 6764 * Clones any cloneable object 6765 * @param value 6766 * @return {*} 6767 */ 6768 function clone(value) { 6769 return internalClone(value, new WeakMap()); 6770 } 6771 6772 function merge(current, target) { 6773 return Object.entries(target).reduce((acc, [key, value]) => { 6774 if (!Type.isDomNode(acc[key]) && Type.isObjectLike(acc[key]) && Type.isObjectLike(value)) { 6775 acc[key] = merge(acc[key], value); 6776 return acc; 6777 } 6778 acc[key] = value; 6779 return acc; 6780 }, current); 6781 } 6782 6783 function createComparator(fields, orders = []) { 6784 return (a, b) => { 6785 const field = fields[0]; 6786 const order = orders[0] || 'asc'; 6787 if (Type.isUndefined(field)) { 6788 return 0; 6789 } 6790 let valueA = a[field]; 6791 let valueB = b[field]; 6792 if (Type.isString(valueA) && Type.isString(valueB)) { 6793 valueA = valueA.toLowerCase(); 6794 valueB = valueB.toLowerCase(); 6795 } 6796 if (valueA < valueB) { 6797 return order === 'asc' ? -1 : 1; 6798 } 6799 if (valueA > valueB) { 6800 return order === 'asc' ? 1 : -1; 6801 } 6802 return createComparator(fields.slice(1), orders.slice(1))(a, b); 6803 }; 6804 } 6805 6806 /** 6807 * @memberOf BX 6808 */ 6809 let Runtime = /*#__PURE__*/function () { 6810 function Runtime() { 6811 babelHelpers.classCallCheck(this, Runtime); 6812 } 6813 babelHelpers.createClass(Runtime, null, [{ 6814 key: "debounce", 6815 value: function debounce(func, wait = 0, context = null) { 6816 let timeoutId; 6817 return function debounced(...args) { 6818 if (Type.isNumber(timeoutId)) { 6819 clearTimeout(timeoutId); 6820 } 6821 timeoutId = setTimeout(() => { 6822 func.apply(context || this, args); 6823 }, wait); 6824 }; 6825 } 6826 }, { 6827 key: "throttle", 6828 value: function throttle(func, wait = 0, context = null) { 6829 let timer = 0; 6830 let invoke; 6831 return function wrapper(...args) { 6832 invoke = true; 6833 if (!timer) { 6834 const q = function q() { 6835 if (invoke) { 6836 func.apply(context || this, args); 6837 invoke = false;
6838 timer = setTimeout(q, wait); 6839 } else { 6840 timer = null; 6841 } 6842 }; 6843 q(); 6844 } 6845 }; 6846 } 6847 }, { 6848 key: "html", 6849 value: function html(node, _html, params = {}) { 6850 if (Type.isNil(_html) && Type.isDomNode(node)) { 6851 return node.innerHTML; 6852 } 6853 6854 // eslint-disable-next-line 6855 const parsedHtml = BX.processHTML(_html); 6856 const externalCss = parsedHtml.STYLE.reduce(externalStyles, []); 6857 const externalJs = parsedHtml.SCRIPT.reduce(externalScripts, []); 6858 const inlineJs = parsedHtml.SCRIPT.reduce(inlineScripts, []); 6859 if (Type.isDomNode(node)) { 6860 if (params.htmlFirst || !externalJs.length && !externalCss.length) { 6861 if (params.useAdjacentHTML) { 6862 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 6863 } else { 6864 node.innerHTML = parsedHtml.HTML; 6865 } 6866 } 6867 } 6868 return Promise.all([loadAll(externalJs), loadAll(externalCss)]).then(() => { 6869 if (Type.isDomNode(node) && (externalJs.length > 0 || externalCss.length > 0)) { 6870 if (params.useAdjacentHTML) { 6871 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 6872 } else { 6873 node.innerHTML = parsedHtml.HTML; 6874 } 6875 } 6876 6877 // eslint-disable-next-line 6878 inlineJs.forEach(script => BX.evalGlobal(script)); 6879 if (Type.isFunction(params.callback)) { 6880 params.callback(); 6881 } 6882 }); 6883 } 6884 /** 6885 * Merges objects or arrays 6886 * @param targets 6887 * @return {any} 6888 */ 6889 }, { 6890 key: "merge", 6891 value: function merge$$1(...targets) { 6892 if (Type.isArray(targets[0])) { 6893 targets.unshift([]); 6894 } else if (Type.isObject(targets[0])) { 6895 targets.unshift({}); 6896 } 6897 return targets.reduce((acc, item) => { 6898 return merge(acc, item); 6899 }, targets[0]); 6900 } 6901 }, { 6902 key: "orderBy", 6903 value: function orderBy(collection, fields = [], orders = []) { 6904 const comparator = createComparator(fields, orders); 6905 return Object.values(collection).sort(comparator); 6906 } 6907 }, { 6908 key: "destroy", 6909 value: function destroy(target, errorMessage = 'Object is destroyed') { 6910 if (Type.isObject(target)) { 6911 const onPropertyAccess = () => { 6912 throw new Error(errorMessage); 6913 }; 6914 const ownProperties = Object.keys(target); 6915 const prototypeProperties = (() => { 6916 const targetPrototype = Object.getPrototypeOf(target); 6917 if (Type.isObject(targetPrototype)) { 6918 return Object.getOwnPropertyNames(targetPrototype); 6919 } 6920 return []; 6921 })(); 6922 const uniquePropertiesList = [...new Set([...ownProperties, ...prototypeProperties])]; 6923 uniquePropertiesList.filter(name => { 6924 const descriptor = Object.getOwnPropertyDescriptor(target, name); 6925 return !/__(.+)__/.test(name) && (!Type.isObject(descriptor) || descriptor.configurable === true); 6926 }
6926).forEach(name => { 6927 Object.defineProperty(target, name, { 6928 get: onPropertyAccess, 6929 set: onPropertyAccess, 6930 configurable: false 6931 }); 6932 }); 6933 Object.setPrototypeOf(target, null); 6934 } 6935 } 6936 }]); 6937 return Runtime; 6938 }(); 6939 babelHelpers.defineProperty(Runtime, "debug", debug); 6940 babelHelpers.defineProperty(Runtime, "loadExtension", loadExtension); 6941 babelHelpers.defineProperty(Runtime, "clone", clone); 6942 6943 const _isError = Symbol.for('BX.BaseError.isError'); 6944 6945 /** 6946 * @memberOf BX 6947 */ 6948 let BaseError = /*#__PURE__*/function () { 6949 function BaseError(message, code, customData) { 6950 babelHelpers.classCallCheck(this, BaseError); 6951 this[_isError] = true; 6952 this.message = ''; 6953 this.code = null; 6954 this.customData = null; 6955 this.setMessage(message); 6956 this.setCode(code); 6957 this.setCustomData(customData); 6958 } 6959 6960 /** 6961 * Returns a brief description of the error 6962 * @returns {string} 6963 */ 6964 babelHelpers.createClass(BaseError, [{ 6965 key: "getMessage", 6966 value: function getMessage() { 6967 return this.message; 6968 } 6969 /** 6970 * Sets a message of the error 6971 * @param {string} message 6972 * @returns {this} 6973 */ 6974 }, { 6975 key: "setMessage", 6976 value: function setMessage(message) { 6977 if (Type.isString(message)) { 6978 this.message = message; 6979 } 6980 return this; 6981 } 6982 /** 6983 * Returns a code of the error 6984 * @returns {?string} 6985 */ 6986 }, { 6987 key: "getCode", 6988 value: function getCode() { 6989 return this.code; 6990 } 6991 /** 6992 * Sets a code of the error 6993 * @param {string} code 6994 * @returns {this} 6995 */ 6996 }, { 6997 key: "setCode", 6998 value: function setCode(code) { 6999 if (Type.isStringFilled(code) || code === null) { 7000 this.code = code; 7001 } 7002 return this; 7003 } 7004 /** 7005 * Returns custom data of the error 7006 * @returns {null|*} 7007 */ 7008 }, { 7009 key: "getCustomData", 7010 value: function getCustomData() { 7011 return this.customData; 7012 } 7013 /** 7014 * Sets custom data of the error 7015 * @returns {this} 7016 */ 7017 }, { 7018 key: "setCustomData", 7019 value: function setCustomData(customData) { 7020 if (!Type.isUndefined(customData)) { 7021 this.customData = customData; 7022 } 7023 return this; 7024 } 7025 }, { 7026 key: "toString", 7027 value: function toString() { 7028 const code = this.getCode(); 7029 const message = this.getMessage(); 7030 if (!Type.isStringFilled(code) && !Type.isStringFilled(message)) { 7031 return ''; 7032 } else if (!Type.isStringFilled(code)) { 7033 return `Error: ${message}`; 7034 } else if (!Type.isStringFilled(message)) { 7035 return code; 7036 } else { 7037 return `${code}: ${message}`; 7038 } 7039 } 7040 /** 7041 * Returns true if the object is an instance of BaseError 7042 * @param error 7043 * @returns {boolean} 7044 */ 7045 }], [{ 7046 key: "isError", 7047 value: function isError(error) { 7048 return Type.isObject(error) && error[_isError] === true; 7049 } 7050 }]); 7051 return BaseError; 7052 }(); 7053 7054 /** 7055 * Implements base event object interface 7056 */ 7057 let BaseEvent = /*#__PURE__*/function () { 7058 function BaseEvent(options = { 7059 data: {} 7060 }) { 7061 babelHelpers.classCallCheck(this, BaseEvent); 7062 this.type = ''; 7063 this.data = null; 7064 this.target = null; 7065 this.compatData = null; 7066 this.defaultPrevented = false; 7067 this.immediatePropagationStopped = false; 7068 this.errors = []; 7069 this.setData(options.data); 7070 this.setCompatData(options.compatData); 7071 } 7072 babelHelpers.createClass(BaseEvent, [{ 7073 key: "getType", 7074 /** 7075 * Returns the name of the event 7076 * @returns {string} 7077 */ 7078 value: function getType() { 7079 return this.type; 7080 } 7081 /** 7082 * 7083 * @param {string} type 7084 */ 7085 }, { 7086 key: "setType", 7087 value: function setType(type) { 7088 if (Type.isStringFilled(type)) { 7089 this.type = type; 7090 } 7091 return this; 7092 } 7093 /** 7094 * Returns an event data 7095 */ 7096 }, { 7097 key: "getData", 7098 value: function getData() { 7099 return this.data; 7100 } 7101 /** 7102 * Sets an event data 7103 * @param data 7104 */ 7105 }, { 7106 key: "setData", 7107 value: function setData(data) { 7108 if (!Type.isUndefined(data)) { 7109 this.data = data; 7110 } 7111 return this; 7112 } 7113 /** 7114 * Returns arguments for BX.addCustomEvent handlers (deprecated). 7115 * @returns {array | null} 7116 */ 7117 }, { 7118 key: "getCompatData", 7119 value: function getCompatData() { 7120 return this.compatData; 7121 } 7122 /** 7123 * Sets arguments for BX.addCustomEvent handlers (deprecated) 7124 * @param data 7125 */ 7126 }, { 7127 key: "setCompatData", 7128 value: function setCompatData(data) { 7129 if (Type.isArrayLike(data)) { 7130 this.compatData = data; 7131 } 7132 return this; 7133 } 7134 /** 7135 * Sets a event target 7136 * @param target 7137 */ 7138 }, { 7139 key: "setTarget", 7140 value: function setTarget(target) { 7141 this.target = target; 7142 return this; 7143 } 7144 /** 7145 * Returns a event target 7146 */ 7147 }, { 7148 key: "getTarget", 7149 value: function getTarget() { 7150 return this.target; 7151 } 7152 /** 7153 * Returns an array of event errors 7154 * @returns {[]} 7155 */ 7156 }, { 7157 key: "getErrors", 7158 value: function getErrors() { 7159 return this.errors; 7160 } 7161 /** 7162 * Adds an error of the event. 7163 * Event listeners can prevent emitter's default action and set the reason of this behavior. 7164 * @param error 7165 */ 7166 }, { 7167 key: "setError", 7168 value: function setError(error) { 7169 if (BaseError.isError(error)) { 7170 this.errors.push(error); 7171 } 7172 } 7173 /** 7174 * Prevents default action 7175 */ 7176 }, { 7177 key: "preventDefault", 7178 value: function preventDefault() { 7179 this.defaultPrevented = true; 7180 } 7181 /** 7182 * Checks that is default action prevented 7183 * @return {boolean} 7184 */ 7185 }, { 7186 key: "isDefaultPrevented", 7187 value: function isDefaultPrevented() { 7188 return this.defaultPrevented; 7189 } 7190 /** 7191 * Stops event immediate propagation 7192 */ 7193 }, { 7194 key: "stopImmediatePropagation", 7195 value: function stopImmediatePropagation() { 7196 this.immediatePropagationStopped = true; 7197 } 7198 /** 7199 * Checks that is immediate propagation stopped 7200 * @return {boolean} 7201 */ 7202 }, { 7203 key: "isImmediatePropagationStopped", 7204 value: function isImmediatePropagationStopped() { 7205 return this.immediatePropagationStopped; 7206 } 7207 }], [{ 7208 key: "create", 7209 value: function create(options) { 7210 return new this(options); 7211 } 7212 }]); 7213 return BaseEvent; 7214 }(); 7215 7216 let EventStore = /*#__PURE__*/function () { 7217 function EventStore(options = {}) { 7218 babelHelpers.classCallCheck(this, EventStore); 7219 this.defaultMaxListeners = Type.isNumber(options.defaultMaxListeners) ? options.defaultMaxListeners : 10; 7220 this.eventStore = new WeakMap(); 7221 } 7222 babelHelpers.createClass(EventStore, [{ 7223 key: "add", 7224 value: function add(target, options = {}) { 7225 const record = this.getRecordScheme(); 7226 if (Type.isNumber(options.maxListeners)) { 7227 record.maxListeners = options.maxListeners; 7228 } 7229 this.eventStore.set(target, record); 7230 return record; 7231 } 7232 }, { 7233 key: "get", 7234 value: function get(target) { 7235 return this.eventStore.get(target); 7236 } 7237 }, { 7238 key: "getOrAdd", 7239 value: function getOrAdd(target, options = {}) { 7240 return this.get(target) || this.add(target, options); 7241 } 7242 }, { 7243 key: "delete", 7244 value: function _delete(context) { 7245 this.eventStore.delete(context); 7246 } 7247 }, { 7248 key: "getRecordScheme", 7249 value: function getRecordScheme() { 7250 return { 7251 eventsMap: new Map(), 7252 onceMap: new Map(), 7253 maxListeners: this.getDefaultMaxListeners(), 7254 eventsMaxListeners: new Map() 7255 }; 7256 } 7257 }, { 7258 key: "getDefaultMaxListeners", 7259 value: function getDefaultMaxListeners() { 7260 return this.defaultMaxListeners; 7261 } 7262 }]); 7263 return EventStore; 7264 }(); 7265 7266 let WarningStore = /*#__PURE__*/function () {
7267 function WarningStore() { 7268 babelHelpers.classCallCheck(this, WarningStore); 7269 this.warnings = new Map(); 7270 this.printDelayed = Runtime.debounce(this.print.bind(this), 500); 7271 } 7272 babelHelpers.createClass(WarningStore, [{ 7273 key: "add", 7274 value: function add(target, eventName, listeners) { 7275 let contextWarnings = this.warnings.get(target); 7276 if (!contextWarnings) { 7277 contextWarnings = Object.create(null); 7278 this.warnings.set(target, contextWarnings); 7279 } 7280 if (!contextWarnings[eventName]) { 7281 contextWarnings[eventName] = {}; 7282 } 7283 contextWarnings[eventName].size = listeners.size; 7284 if (!Type.isArray(contextWarnings[eventName].errors)) { 7285 contextWarnings[eventName].errors = []; 7286 } 7287 contextWarnings[eventName].errors.push(new Error()); 7288 } 7289 }, { 7290 key: "print", 7291 value: function print() { 7292 this.warnings.forEach(warnings => { 7293 for (let eventName in warnings) { 7294 console.groupCollapsed('Possible BX.Event.EventEmitter memory leak detected. ' + warnings[eventName].size + ' "' + eventName + '" listeners added. ' + 'Use emitter.setMaxListeners() to increase limit.'); 7295 console.dir(warnings[eventName].errors); 7296 console.groupEnd(); 7297 } 7298 }); 7299 this.clear(); 7300 } 7301 }, { 7302 key: "clear", 7303 value: function clear() { 7304 this.warnings.clear(); 7305 } 7306 }, { 7307 key: "printDelayed", 7308 value: function printDelayed() {} 7309 }]); 7310 return WarningStore; 7311 }(); 7312 7313 const eventStore = new EventStore({ 7314 defaultMaxListeners: 10 7315 }); 7316 const warningStore = new WarningStore(); 7317 const aliasStore = new Map(); 7318 const globalTarget = { 7319 GLOBAL_TARGET: 'GLOBAL_TARGET' // this key only for debugging purposes 7320 }; 7321 7322 eventStore.add(globalTarget, { 7323 maxListeners: 25 7324 }); 7325 const isEmitterProperty = Symbol.for('BX.Event.EventEmitter.isEmitter'); 7326 const namespaceProperty = Symbol('namespaceProperty'); 7327 const targetProperty = Symbol('targetProperty'); 7328 let EventEmitter = /*#__PURE__*/function () { 7329 /** @private */ 7330 7331 function EventEmitter(...args) { 7332 babelHelpers.classCallCheck(this, EventEmitter); 7333 this[targetProperty] = null; 7334 this[namespaceProperty] = null; 7335 this[isEmitterProperty] = true; 7336 let target = this; 7337 if (Object.getPrototypeOf(this) === EventEmitter.prototype && args.length > 0) 7338 //new EventEmitter(obj) case 7339 { 7340 if (!Type.isObject(args[0])) { 7341 throw new TypeError(`The "target" argument must be an object.`); 7342 } 7343 target = args[0]; 7344 this.setEventNamespace(args[1]); 7345 } 7346 this[targetProperty] = target; 7347 } 7348 7349 /** 7350 * Makes a target observable 7351 * @param {object} target 7352 * @param {string} namespace 7353 */ 7354 babelHelpers.createClass(EventEmitter, [{ 7355 key: "setEventNamespace", 7356 value: function setEventNamespace(namespace) { 7357 if (Type.isStringFilled(namespace)) { 7358 this[namespaceProperty] = namespace; 7359 } 7360 } 7361 }, { 7362 key: "getEventNamespace", 7363 value: function getEventNamespace() { 7364 return this[namespaceProperty]; 7365 } 7366 /** 7367 * Subscribes listener on specified global event 7368 * @param {object} target 7369 * @param {string} eventName 7370 * @param {Function<BaseEvent>} listener 7371 * @param {object} options 7372 */ 7373 }, { 7374 key: "subscribe", 7375 /** 7376 * Subscribes a listener on a specified event 7377 * @param {string} eventName 7378 * @param {Function<BaseEvent>} listener 7379 * @return {this} 7380 */ 7381 value: function subscribe(eventName, listener) { 7382 EventEmitter.subscribe(this, eventName, listener); 7383 return this; 7384 } 7385 /** 7386 * 7387 * @param {object} options 7388 * @param {object} [aliases] 7389 * @param {boolean} [compatMode=false] 7390 */ 7391 }, { 7392 key: "subscribeFromOptions", 7393 value: function subscribeFromOptions(options, aliases, compatMode) { 7394 if (!Type.isPlainObject(options)) { 7395 return; 7396 } 7397 aliases = Type.isPlainObject(aliases) ? EventEmitter.normalizeAliases(aliases) : {};
7398 Object.keys(options).forEach(eventName => { 7399 const listener = EventEmitter.normalizeListener(options[eventName]); 7400 eventName = EventEmitter.normalizeEventName(eventName); 7401 if (aliases[eventName]) { 7402 const { 7403 eventName: actualName 7404 } = aliases[eventName]; 7405 EventEmitter.subscribe(this, actualName, listener, { 7406 compatMode: compatMode !== false 7407 }); 7408 } else { 7409 EventEmitter.subscribe(this, eventName, listener, { 7410 compatMode: compatMode === true 7411 }); 7412 } 7413 }); 7414 } 7415 /** 7416 * Subscribes a listener that is called at 7417 * most once for a specified event. 7418 * @param {object} target 7419 * @param {string} eventName 7420 * @param {Function<BaseEvent>} listener 7421 */ 7422 }, { 7423 key: "subscribeOnce", 7424 /** 7425 * Subscribes a listener that is called at most once for a specified event. 7426 * @param {string} eventName 7427 * @param {Function<BaseEvent>} listener 7428 * @return {this} 7429 */ 7430 value: function subscribeOnce(eventName, listener) { 7431 EventEmitter.subscribeOnce(this, eventName, listener); 7432 return this; 7433 } 7434 /** 7435 * Unsubscribes an event listener 7436 * @param {object} target 7437 * @param {string} eventName 7438 * @param {Function<BaseEvent>} listener 7439 * @param options 7440 */ 7441 }, { 7442 key: "unsubscribe", 7443 /** 7444 * Unsubscribes an event listener 7445 * @param {string} eventName 7446 * @param {Function<BaseEvent>} listener 7447 * @return {this} 7448 */ 7449 value: function unsubscribe(eventName, listener) { 7450 EventEmitter.unsubscribe(this, eventName, listener); 7451 return this; 7452 } 7453 /** 7454 * Unsubscribes all event listeners 7455 * @param {object} target 7456 * @param {string} eventName 7457 * @param options 7458 */ 7459 }, { 7460 key: "unsubscribeAll", 7461 /** 7462 * Unsubscribes all event listeners 7463 * @param {string} [eventName] 7464 */ 7465 value: function unsubscribeAll(eventName) { 7466 EventEmitter.unsubscribeAll(this, eventName); 7467 } 7468 /** 7469 * 7470 * @param {object} target 7471 * @param {string} eventName 7472 * @param {BaseEvent | any} event 7473 * @param {object} options 7474 * @returns {Array} 7475 */ 7476 }, { 7477 key: "emit", 7478 /** 7479 * Emits specified event with specified event object 7480 * @param {string} eventName 7481 * @param {BaseEvent | any} event 7482 * @return {this} 7483 */ 7484 value: function emit(eventName, event) { 7485 if (this.getEventNamespace() === null) { 7486 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7487 } 7488 EventEmitter.emit(this, eventName, event); 7489 return this; 7490 } 7491 /** 7492 * Emits global event and returns a promise that is resolved when 7493 * all promise returned from event handlers are resolved, 7494 * or rejected when at least one of the returned promise is rejected. 7495 * Importantly. You can return any value from synchronous handlers, not just promise 7496 * @param {object} target 7497 * @param {string} eventName 7498 * @param {BaseEvent | any} event 7499 * @return {Promise<Array>} 7500 */ 7501 }, { 7502 key: "emitAsync", 7503 /** 7504 * Emits event and returns a promise that is resolved when 7505 * all promise returned from event handlers are resolved, 7506 * or rejected when at least one of the returned promise is rejected. 7507 * Importantly. You can return any value from synchronous handlers, not just promise 7508 * @param {string} eventName 7509 * @param {BaseEvent|any} event 7510 * @return {Promise<Array>} 7511 */ 7512 value: function emitAsync(eventName, event) { 7513 if (this.getEventNamespace() === null) { 7514 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7515 } 7516 return EventEmitter.emitAsync(this, eventName, event); 7517 } 7518 /** 7519 * @private 7520 * @param {object} target 7521 * @param {string} eventName 7522 * @param {BaseEvent|any} event 7523 * @returns {BaseEvent} 7524 */ 7525 }, { 7526 key: "setMaxListeners", 7527 /** 7528 * Sets max events listeners count 7529 * this.setMaxListeners(10) - sets the default value for all events
7530 * this.setMaxListeners("onClose", 10) sets the value for onClose event 7531 * @return {this} 7532 * @param args 7533 */ 7534 value: function setMaxListeners(...args) { 7535 EventEmitter.setMaxListeners(this, ...args); 7536 return this; 7537 } 7538 /** 7539 * Returns max event listeners count 7540 * @param {object} target 7541 * @param {string} [eventName] 7542 * @returns {number} 7543 */ 7544 }, { 7545 key: "getMaxListeners", 7546 /** 7547 * Returns max event listeners count 7548 * @param {string} [eventName] 7549 * @returns {number} 7550 */ 7551 value: function getMaxListeners(eventName) { 7552 return EventEmitter.getMaxListeners(this, eventName); 7553 } 7554 /** 7555 * Adds or subtracts max listeners count 7556 * Event.EventEmitter.addMaxListeners() - adds one max listener for all events of global target 7557 * Event.EventEmitter.addMaxListeners(3) - adds three max listeners for all events of global target 7558 * Event.EventEmitter.addMaxListeners(-1) - subtracts one max listener for all events of global target 7559 * Event.EventEmitter.addMaxListeners('onClose') - adds one max listener for onClose event of global target 7560 * Event.EventEmitter.addMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 7561 * Event.EventEmitter.addMaxListeners('onClose', -1) - subtracts one max listener for onClose event of global target 7562 * 7563 * Event.EventEmitter.addMaxListeners(obj) - adds one max listener for all events of 'obj' target 7564 * Event.EventEmitter.addMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 7565 * Event.EventEmitter.addMaxListeners(obj, -1) - subtracts one max listener for all events of 'obj' target 7566 * Event.EventEmitter.addMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 7567 * Event.EventEmitter.addMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 7568 * Event.EventEmitter.addMaxListeners(obj, 'onClose', -1) - subtracts one max listener for onClose event of 'obj' target 7569 * @param args 7570 * @returns {number} 7571 */ 7572 }, { 7573 key: "incrementMaxListeners", 7574 /** 7575 * Increases max listeners count 7576 * this.incrementMaxListeners() - adds one max listener for all events 7577 * this.incrementMaxListeners(3) - adds three max listeners for all events 7578 * this.incrementMaxListeners('onClose') - adds one max listener for onClose event 7579 * this.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event 7580 */ 7581 value: function incrementMaxListeners(...args) { 7582 return EventEmitter.incrementMaxListeners(this, ...args); 7583 } 7584 /** 7585 * Decreases max listeners count 7586 * 7587 * Event.EventEmitter.decrementMaxListeners() - subtracts one max listener for all events of global target 7588 * Event.EventEmitter.decrementMaxListeners(3) - subtracts three max listeners for all events of global target 7589 * Event.EventEmitter.decrementMaxListeners('onClose') - subtracts one max listener for onClose event of global target 7590 * Event.EventEmitter.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event of global target 7591 * 7592 * Event.EventEmitter.decrementMaxListeners(obj) - subtracts one max listener for all events of 'obj' target 7593 * Event.EventEmitter.decrementMaxListeners(obj, 3) - subtracts three max listeners for all events of 'obj' target 7594 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose') - subtracts one max listener for onClose event of 'obj' target 7595 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose', 2) - subtracts two max listeners for onClose event of 'obj' target 7596 */ 7597 }, { 7598 key: "decrementMaxListeners", 7599 /** 7600 * Increases max listeners count 7601 * this.decrementMaxListeners() - subtracts one max listener for all events 7602 * this.decrementMaxListeners(3) - subtracts three max listeners for all events 7603 * this.decrementMaxListeners('onClose') - subtracts one max listener for onClose event 7604 * this.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event 7605 */ 7606 value: function decrementMaxListeners(...args) { 7607 return EventEmitter.decrementMaxListeners(this, ...args); 7608 } 7609 /** 7610 * @private 7611 * @param {Array} args 7612 * @returns Array 7613 */ 7614 }, { 7615 key: "getListeners", 7616 /** 7617 * Gets listeners list for specified event 7618 * @param {string} eventName 7619 */ 7620 value: function getListeners(eventName) { 7621 return EventEmitter.getListeners(this, eventName); 7622 } 7623 /** 7624 * Returns a full event name with namespace 7625 * @param {string} eventName 7626 * @returns {string} 7627 */ 7628 }, { 7629 key: "getFullEventName", 7630 value: function getFullEventName(eventName) { 7631 if (!Type.isStringFilled(eventName)) { 7632 throw new TypeError(`The "eventName" argument must be a string.`); 7633 } 7634 return EventEmitter.makeFullEventName(this.getEventNamespace(), eventName); 7635 } 7636 /** 7637 * Registers aliases (old event names for BX.onCustomEvent) 7638 * @param aliases 7639 */ 7640 }], [{ 7641 key: "makeObservable", 7642 value: function makeObservable(target, namespace) { 7643 if (!Type.isObject(target)) { 7644 throw new TypeError('The "target" argument must be an object.'); 7645 } 7646 if (!Type.isStringFilled(namespace)) { 7647 throw new TypeError('The "namespace" must be an non-empty string.'); 7648 } 7649 if (EventEmitter.isEventEmitter(target)) { 7650 throw new TypeError('The "target" is an event emitter already.'); 7651 } 7652 const targetProto = Object.getPrototypeOf(target); 7653 const emitter = new EventEmitter(); 7654 emitter.setEventNamespace(namespace); 7655 Object.setPrototypeOf(emitter, targetProto); 7656 Object.setPrototypeOf(target, emitter); 7657 Object.getOwnPropertyNames(EventEmitter.prototype).forEach(method => {
7658 if (['constructor'].includes(method)) { 7659 return; 7660 } 7661 emitter[method] = function (...args) { 7662 return EventEmitter.prototype[method].apply(target, args); 7663 }; 7664 }); 7665 } 7666 }, { 7667 key: "subscribe", 7668 value: function subscribe(target, eventName, listener, options) { 7669 if (Type.isString(target)) { 7670 options = listener; 7671 listener = eventName; 7672 eventName = target; 7673 target = this.GLOBAL_TARGET; 7674 } 7675 if (!Type.isObject(target)) { 7676 throw new TypeError(`The "target" argument must be an object.`); 7677 } 7678 eventName = this.normalizeEventName(eventName); 7679 if (!Type.isStringFilled(eventName)) { 7680 throw new TypeError(`The "eventName" argument must be a string.`); 7681 } 7682 listener = this.normalizeListener(listener); 7683 options = Type.isPlainObject(options) ? options : {}; 7684 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7685 const { 7686 eventsMap, 7687 onceMap 7688 } = eventStore.getOrAdd(target); 7689 const onceListeners = onceMap.get(fullEventName); 7690 let listeners = eventsMap.get(fullEventName); 7691 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7692 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7693 } else { 7694 if (listeners) { 7695 listeners.set(listener, { 7696 listener, 7697 options, 7698 sort: this.getNextSequenceValue() 7699 }); 7700 } else { 7701 listeners = new Map([[listener, { 7702 listener, 7703 options, 7704 sort: this.getNextSequenceValue() 7705 }]]); 7706 eventsMap.set(fullEventName, listeners); 7707 } 7708 } 7709 const maxListeners = this.getMaxListeners(target, eventName); 7710 if (listeners.size > maxListeners) { 7711 warningStore.add(target, fullEventName, listeners); 7712 warningStore.printDelayed(); 7713 } 7714 } 7715 }, { 7716 key: "subscribeOnce", 7717 value: function subscribeOnce(target, eventName, listener) { 7718 if (Type.isString(target)) { 7719 listener = eventName; 7720 eventName = target; 7721 target = this.GLOBAL_TARGET;
7722 } 7723 if (!Type.isObject(target)) { 7724 throw new TypeError(`The "target" argument must be an object.`); 7725 } 7726 eventName = this.normalizeEventName(eventName); 7727 if (!Type.isStringFilled(eventName)) { 7728 throw new TypeError(`The "eventName" argument must be a string.`); 7729 } 7730 listener = this.normalizeListener(listener); 7731 const fullEventName = this.resolveEventName(eventName, target); 7732 const { 7733 eventsMap, 7734 onceMap 7735 } = eventStore.getOrAdd(target); 7736 const listeners = eventsMap.get(fullEventName); 7737 let onceListeners = onceMap.get(fullEventName); 7738 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7739 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7740 } else { 7741 const once = (...args) => { 7742 this.unsubscribe(target, eventName, once); 7743 onceListeners.delete(listener); 7744 listener(...args); 7745 }; 7746 if (onceListeners) { 7747 onceListeners.set(listener, once); 7748 } else { 7749 onceListeners = new Map([[listener, once]]); 7750 onceMap.set(fullEventName, onceListeners); 7751 } 7752 this.subscribe(target, eventName, once); 7753 } 7754 } 7755 }, { 7756 key: "unsubscribe", 7757 value: function unsubscribe(target, eventName, listener, options) { 7758 if (Type.isString(target)) { 7759 listener = eventName; 7760 eventName = target; 7761 target = this.GLOBAL_TARGET;
7762 } 7763 eventName = this.normalizeEventName(eventName); 7764 if (!Type.isStringFilled(eventName)) { 7765 throw new TypeError(`The "eventName" argument must be a string.`); 7766 } 7767 listener = this.normalizeListener(listener); 7768 options = Type.isPlainObject(options) ? options : {}; 7769 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7770 const targetInfo = eventStore.get(target); 7771 const listeners = targetInfo && targetInfo.eventsMap.get(fullEventName); 7772 const onceListeners = targetInfo && targetInfo.onceMap.get(fullEventName); 7773 if (listeners) { 7774 listeners.delete(listener); 7775 } 7776 if (onceListeners) { 7777 const once = onceListeners.get(listener); 7778 if (once) { 7779 onceListeners.delete(listener); 7780 listeners.delete(once); 7781 } 7782 } 7783 } 7784 }, { 7785 key: "unsubscribeAll", 7786 value: function unsubscribeAll(target, eventName, options) { 7787 if (Type.isString(target)) { 7788 eventName = target; 7789 target = this.GLOBAL_TARGET;
7790 } 7791 if (Type.isStringFilled(eventName)) { 7792 const targetInfo = eventStore.get(target); 7793 if (targetInfo) { 7794 options = Type.isPlainObject(options) ? options : {}; 7795 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7796 targetInfo.eventsMap.delete(fullEventName); 7797 targetInfo.onceMap.delete(fullEventName); 7798 } 7799 } else if (Type.isNil(eventName)) { 7800 if (target === this.GLOBAL_TARGET) { 7801 console.error('You cannot unsubscribe all global listeners.'); 7802 } else { 7803 eventStore.delete(target); 7804 } 7805 } 7806 } 7807 }, { 7808 key: "emit", 7809 value: function emit(target, eventName, event, options) { 7810 if (Type.isString(target)) { 7811 options = event; 7812 event = eventName; 7813 eventName = target; 7814 target = this.GLOBAL_TARGET; 7815 } 7816 if (!Type.isObject(target)) { 7817 throw new TypeError(`The "target" argument must be an object.`); 7818 } 7819 eventName = this.normalizeEventName(eventName); 7820 if (!Type.isStringFilled(eventName)) { 7821 throw new TypeError(`The "eventName" argument must be a string.`); 7822 } 7823 options = Type.isPlainObject(options) ? options : {}; 7824 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7825 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 7826 const globalListeners = globalEvents && globalEvents.eventsMap.get(fullEventName) || new Map(); 7827 let targetListeners = new Set(); 7828 if (target !== this.GLOBAL_TARGET) { 7829 const targetEvents = eventStore.get(target); 7830 targetListeners = targetEvents && targetEvents.eventsMap.get(fullEventName) || new Map(); 7831 } 7832 const listeners = [...globalListeners.values(), ...targetListeners.values()]; 7833 listeners.sort(function (a, b) { 7834 return a.sort - b.sort; 7835 }); 7836 const preparedEvent = this.prepareEvent(target, fullEventName, event); 7837 const result = []; 7838 for (let i = 0; i < listeners.length; i++) { 7839 if (preparedEvent.isImmediatePropagationStopped()) { 7840 break; 7841 } 7842 const { 7843 listener, 7844 options: listenerOptions 7845 } = listeners[i]; 7846 7847 //A previous listener could remove a current listener. 7848 if (globalListeners.has(listener) || targetListeners.has(listener)) { 7849 let listenerResult; 7850 if (listenerOptions.compatMode) { 7851 let params = []; 7852 const compatData = preparedEvent.getCompatData(); 7853 if (compatData !== null) { 7854 params = options.cloneData === true ? Runtime.clone(compatData) : compatData; 7855 } else { 7856 params = [preparedEvent]; 7857 } 7858 const context = Type.isUndefined(options.thisArg) ? target : options.thisArg; 7859 listenerResult = listener.apply(context, params); 7860 } else { 7861 listenerResult = Type.isUndefined(options.thisArg) ? listener(preparedEvent) : listener.call(options.thisArg, preparedEvent); 7862 } 7863 result.push(listenerResult); 7864 } 7865 } 7866 return result; 7867 } 7868 }, { 7869 key: "emitAsync", 7870 value: function emitAsync(target, eventName, event) { 7871 if (Type.isString(target)) { 7872 event = eventName; 7873 eventName = target; 7874 target = this.GLOBAL_TARGET;
7875 } 7876 return Promise.all(this.emit(target, eventName, event)); 7877 } 7878 }, { 7879 key: "prepareEvent", 7880 value: function prepareEvent(target, eventName, event) { 7881 let preparedEvent = event; 7882 if (!(event instanceof BaseEvent)) { 7883 preparedEvent = new BaseEvent(); 7884 preparedEvent.setData(event); 7885 } 7886 preparedEvent.setTarget(this.isEventEmitter(target) ? target[targetProperty] : target); 7887 preparedEvent.setType(eventName); 7888 return preparedEvent; 7889 } 7890 /** 7891 * @private 7892 * @returns {number} 7893 */ 7894 }, { 7895 key: "getNextSequenceValue", 7896 value: function getNextSequenceValue() { 7897 return this.sequenceValue++; 7898 } 7899 /** 7900 * Sets max global events listeners count 7901 * Event.EventEmitter.setMaxListeners(10) - sets the default value for all events (global target) 7902 * Event.EventEmitter.setMaxListeners("onClose", 10) - sets the value for onClose event (global target) 7903 * Event.EventEmitter.setMaxListeners(obj, 10) - sets the default value for all events (obj target) 7904 * Event.EventEmitter.setMaxListeners(obj, "onClose", 10); - sets the value for onClose event (obj target) 7905 * @return {void} 7906 * @param args 7907 */ 7908 }, { 7909 key: "setMaxListeners", 7910 value: function setMaxListeners(...args) { 7911 let target = this.GLOBAL_TARGET;
7912 let eventName = null; 7913 let count = undefined; 7914 if (args.length === 1) { 7915 count = args[0]; 7916 } else if (args.length === 2) { 7917 if (Type.isString(args[0])) { 7918 [eventName, count] = args; 7919 } else { 7920 [target, count] = args; 7921 } 7922 } else if (args.length >= 3) { 7923 [target, eventName, count] = args; 7924 } 7925 if (!Type.isObject(target)) { 7926 throw new TypeError(`The "target" argument must be an object.`); 7927 } 7928 if (eventName !== null && !Type.isStringFilled(eventName)) { 7929 throw new TypeError(`The "eventName" argument must be a string.`); 7930 } 7931 if (!Type.isNumber(count) || count < 0) { 7932 throw new TypeError(`The value of "count" is out of range. It must be a non-negative number. Received ${count}.`); 7933 } 7934 const targetInfo = eventStore.getOrAdd(target); 7935 if (Type.isStringFilled(eventName)) { 7936 const fullEventName = this.resolveEventName(eventName, target); 7937 targetInfo.eventsMaxListeners.set(fullEventName, count); 7938 } else { 7939 targetInfo.maxListeners = count; 7940 } 7941 } 7942 }, { 7943 key: "getMaxListeners", 7944 value: function getMaxListeners(target, eventName) { 7945 if (Type.isString(target)) { 7946 eventName = target; 7947 target = this.GLOBAL_TARGET;
7948 } else if (Type.isNil(target)) { 7949 target = this.GLOBAL_TARGET; 7950 } 7951 if (!Type.isObject(target)) { 7952 throw new TypeError(`The "target" argument must be an object.`); 7953 } 7954 const targetInfo = eventStore.get(target); 7955 if (targetInfo) { 7956 let maxListeners = targetInfo.maxListeners; 7957 if (Type.isStringFilled(eventName)) { 7958 const fullEventName = this.resolveEventName(eventName, target); 7959 maxListeners = targetInfo.eventsMaxListeners.get(fullEventName) || maxListeners; 7960 } 7961 return maxListeners; 7962 } 7963 return this.DEFAULT_MAX_LISTENERS; 7964 } 7965 }, { 7966 key: "addMaxListeners", 7967 value: function addMaxListeners(...args) { 7968 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 7969 const maxListeners = Math.max(this.getMaxListeners(target, eventName) + increment, 0); 7970 if (Type.isStringFilled(eventName)) { 7971 EventEmitter.setMaxListeners(target, eventName, maxListeners); 7972 } else { 7973 EventEmitter.setMaxListeners(target, maxListeners); 7974 } 7975 return maxListeners; 7976 } 7977 /** 7978 * Increases max listeners count 7979 * 7980 * Event.EventEmitter.incrementMaxListeners() - adds one max listener for all events of global target 7981 * Event.EventEmitter.incrementMaxListeners(3) - adds three max listeners for all events of global target 7982 * Event.EventEmitter.incrementMaxListeners('onClose') - adds one max listener for onClose event of global target 7983 * Event.EventEmitter.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 7984 * 7985 * Event.EventEmitter.incrementMaxListeners(obj) - adds one max listener for all events of 'obj' target 7986 * Event.EventEmitter.incrementMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 7987 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 7988 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 7989 */ 7990 }, { 7991 key: "incrementMaxListeners", 7992 value: function incrementMaxListeners(...args) { 7993 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 7994 return this.addMaxListeners(target, eventName, Math.abs(increment)); 7995 } 7996 }, { 7997 key: "decrementMaxListeners", 7998 value: function decrementMaxListeners(...args) { 7999 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 8000 return this.addMaxListeners(target, eventName, -Math.abs(increment)); 8001 } 8002 }, { 8003 key: "destructMaxListenersArgs", 8004 value: function destructMaxListenersArgs(...args) { 8005 let eventName = null; 8006 let increment = 1; 8007 let target = this.GLOBAL_TARGET;
8008 if (args.length === 1) { 8009 if (Type.isNumber(args[0])) { 8010 increment = args[0]; 8011 } else if (Type.isString(args[0])) { 8012 eventName = args[0]; 8013 } else { 8014 target = args[0]; 8015 } 8016 } else if (args.length === 2) { 8017 if (Type.isString(args[0])) { 8018 [eventName, increment] = args; 8019 } else if (Type.isString(args[1])) { 8020 [target, eventName] = args; 8021 } else { 8022 [target, increment] = args; 8023 } 8024 } else if (args.length >= 3) { 8025 [target, eventName, increment] = args; 8026 } 8027 if (!Type.isObject(target)) { 8028 throw new TypeError(`The "target" argument must be an object.`); 8029 } 8030 if (eventName !== null && !Type.isStringFilled(eventName)) { 8031 throw new TypeError(`The "eventName" argument must be a string.`); 8032 } 8033 if (!Type.isNumber(increment)) { 8034 throw new TypeError(`The value of "increment" must be a number.`); 8035 } 8036 return [target, eventName, increment]; 8037 } 8038 /** 8039 * Gets listeners list for a specified event 8040 * @param {object} target 8041 * @param {string} eventName 8042 */ 8043 }, { 8044 key: "getListeners", 8045 value: function getListeners(target, eventName) { 8046 if (Type.isString(target)) { 8047 eventName = target; 8048 target = this.GLOBAL_TARGET;
8049 } 8050 if (!Type.isObject(target)) { 8051 throw new TypeError(`The "target" argument must be an object.`); 8052 } 8053 eventName = this.normalizeEventName(eventName); 8054 if (!Type.isStringFilled(eventName)) { 8055 throw new TypeError(`The "eventName" argument must be a string.`); 8056 } 8057 const targetInfo = eventStore.get(target); 8058 if (!targetInfo) { 8059 return new Map(); 8060 } 8061 const fullEventName = this.resolveEventName(eventName, target); 8062 return targetInfo.eventsMap.get(fullEventName) || new Map(); 8063 } 8064 }, { 8065 key: "registerAliases", 8066 value: function registerAliases(aliases) { 8067 aliases = this.normalizeAliases(aliases); 8068 Object.keys(aliases).forEach(alias => { 8069 aliasStore.set(alias, { 8070 eventName: aliases[alias].eventName, 8071 namespace: aliases[alias].namespace 8072 }); 8073 }); 8074 EventEmitter.mergeEventAliases(aliases); 8075 } 8076 /** 8077 * @private 8078 * @param aliases 8079 */ 8080 }, { 8081 key: "normalizeAliases", 8082 value: function normalizeAliases(aliases) { 8083 if (!Type.isPlainObject(aliases)) { 8084 throw new TypeError(`The "aliases" argument must be an object.`); 8085 } 8086 const result = Object.create(null); 8087 for (let alias in aliases) { 8088 if (!Type.isStringFilled(alias)) { 8089 throw new TypeError(`The alias must be an non-empty string.`); 8090 } 8091 const options = aliases[alias]; 8092 if (!options || !Type.isStringFilled(options.eventName) || !Type.isStringFilled(options.namespace)) { 8093 throw new TypeError(`The alias options must set the "eventName" and the "namespace".`); 8094 } 8095 alias = this.normalizeEventName(alias); 8096 result[alias] = { 8097 eventName: options.eventName, 8098 namespace: options.namespace 8099 }; 8100 } 8101 return result; 8102 } 8103 /** 8104 * @private 8105 */ 8106 }, { 8107 key: "mergeEventAliases", 8108 value: function mergeEventAliases(aliases) { 8109 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 8110 if (!globalEvents) { 8111 return; 8112 } 8113 Object.keys(aliases).forEach(alias => { 8114 const options = aliases[alias]; 8115 alias = this.normalizeEventName(alias); 8116 const fullEventName = this.makeFullEventName(options.namespace, options.eventName); 8117 const aliasListeners = globalEvents.eventsMap.get(alias); 8118 if (aliasListeners) { 8119 const listeners = globalEvents.eventsMap.get(fullEventName) || new Map(); 8120 globalEvents.eventsMap.set(fullEventName, new Map([...listeners, ...aliasListeners])); 8121 globalEvents.eventsMap.delete(alias); 8122 } 8123 const aliasOnceListeners = globalEvents.onceMap.get(alias); 8124 if (aliasOnceListeners) { 8125 const onceListeners = globalEvents.onceMap.get(fullEventName) || new Map(); 8126 globalEvents.onceMap.set(fullEventName, new Map([...onceListeners, ...aliasOnceListeners])); 8127 globalEvents.onceMap.delete(alias); 8128 } 8129 const aliasMaxListeners = globalEvents.eventsMaxListeners.get(alias); 8130 if (aliasMaxListeners) { 8131 const eventMaxListeners = globalEvents.eventsMaxListeners.get(fullEventName) || 0; 8132 globalEvents.eventsMaxListeners.set(fullEventName, Math.max(eventMaxListeners, aliasMaxListeners)); 8133 globalEvents.eventsMaxListeners.delete(alias); 8134 } 8135 }); 8136 } 8137 /** 8138 * Returns true if the target is an instance of Event.EventEmitter 8139 * @param {object} target 8140 * @returns {boolean} 8141 */ 8142 }, { 8143 key: "isEventEmitter", 8144 value: function isEventEmitter(target) { 8145 return Type.isObject(target) && target[isEmitterProperty] === true; 8146 } 8147 /** 8148 * @private 8149 * @param {string} eventName 8150 * @returns {string} 8151 */ 8152 }, { 8153 key: "normalizeEventName", 8154 value: function normalizeEventName(eventName) { 8155 if (!Type.isStringFilled(eventName)) { 8156 return ''; 8157 } 8158 return eventName.toLowerCase(); 8159 } 8160 /** 8161 * @private 8162 */ 8163 }, { 8164 key: "normalizeListener", 8165 value: function normalizeListener(listener) { 8166 if (Type.isString(listener)) { 8167 listener = Reflection.getClass(listener); 8168 } 8169 if (!Type.isFunction(listener)) { 8170 throw new TypeError(`The "listener" argument must be of type Function. Received type ${typeof listener}.`); 8171 } 8172 return listener; 8173 } 8174 /** 8175 * @private 8176 * @param eventName 8177 * @param target 8178 * @param useGlobalNaming 8179 * @returns {string} 8180 */ 8181 }, { 8182 key: "resolveEventName", 8183 value: function resolveEventName(eventName, target, useGlobalNaming = false) { 8184 eventName = this.normalizeEventName(eventName); 8185 if (!Type.isStringFilled(eventName)) { 8186 return ''; 8187 } 8188 if (this.isEventEmitter(target) && useGlobalNaming !== true) { 8189 if (target.getEventNamespace() !== null && eventName.includes('.')) { 8190 console.warn(`Possible the wrong event name "${eventName}".`); 8191 } 8192 eventName = target.getFullEventName(eventName); 8193 } else if (aliasStore.has(eventName)) { 8194 const { 8195 namespace, 8196 eventName: actualEventName 8197 } = aliasStore.get(eventName); 8198 eventName = this.makeFullEventName(namespace, actualEventName); 8199 } 8200 return eventName; 8201 } 8202 /** 8203 * @private 8204 * @param {string} namespace 8205 * @param {string} eventName 8206 * @returns {string} 8207 */ 8208 }, { 8209 key: "makeFullEventName", 8210 value: function makeFullEventName(namespace, eventName) { 8211 const fullName = Type.isStringFilled(namespace) ? `${namespace}:${eventName}` : eventName; 8212 return Type.isStringFilled(fullName) ? fullName.toLowerCase() : ''; 8213 } 8214 }]); 8215 return EventEmitter; 8216 }(); 8217 babelHelpers.defineProperty(EventEmitter, "GLOBAL_TARGET", globalTarget); 8218 babelHelpers.defineProperty(EventEmitter, "DEFAULT_MAX_LISTENERS", eventStore.getDefaultMaxListeners()); 8219 babelHelpers.defineProperty(EventEmitter, "sequenceValue", 1); 8220 8221 let stack = []; 8222 /** 8223 * For compatibility only 8224 * @type {boolean} 8225 */ 8226 // eslint-disable-next-line 8227 exports.isReady = false;
8228 function ready(handler) { 8229 switch (document.readyState) { 8230 case 'loading': 8231 stack.push(handler); 8232 break; 8233 case 'interactive': 8234 case 'complete': 8235 if (Type.isFunction(handler)) { 8236 handler(); 8237 } 8238 exports.isReady = true; 8239 break; 8240 default: 8241 break; 8242 } 8243 } 8244 document.addEventListener('readystatechange', () => { 8245 if (!exports.isReady) { 8246 stack.forEach(ready); 8247 stack = []; 8248 } 8249 }); 8250 8251 /** 8252 * @memberOf BX 8253 */ 8254 let Event = function Event() { 8255 babelHelpers.classCallCheck(this, Event); 8256 }; 8257 babelHelpers.defineProperty(Event, "bind", bind); 8258 babelHelpers.defineProperty(Event, "bindOnce", bindOnce); 8259 babelHelpers.defineProperty(Event, "unbind", unbind); 8260 babelHelpers.defineProperty(Event, "unbindAll", unbindAll); 8261 babelHelpers.defineProperty(Event, "ready", ready); 8262 babelHelpers.defineProperty(Event, "EventEmitter", EventEmitter); 8263 babelHelpers.defineProperty(Event, "BaseEvent", BaseEvent); 8264 8265 function encodeAttributeValue(value) { 8266 if (Type.isPlainObject(value) || Type.isArray(value)) { 8267 return JSON.stringify(value); 8268 } 8269 return Text.encode(Text.decode(value)); 8270 } 8271 8272 function decodeAttributeValue(value) { 8273 if (Type.isString(value)) { 8274 const decodedValue = Text.decode(value); 8275 let result; 8276 try { 8277 result = JSON.parse(decodedValue); 8278 } catch (e) { 8279 result = decodedValue; 8280 } 8281 if (result === decodedValue) { 8282 if (/^[\d.]+[.]?\d+$/.test(result)) { 8283 return Number(result); 8284 } 8285 } 8286 if (result === 'true' || result === 'false') { 8287 return Boolean(result); 8288 } 8289 return result; 8290 } 8291 return value; 8292 } 8293 8294 function getPageScroll() { 8295 const { 8296 documentElement, 8297 body 8298 } = document; 8299 const scrollTop = Math.max(window.pageYOffset || 0, documentElement ? documentElement.scrollTop : 0, body ? body.scrollTop : 0); 8300 const scrollLeft = Math.max(window.pageXOffset || 0, documentElement ? documentElement.scrollLeft : 0, body ? body.scrollLeft : 0); 8301 return { 8302 scrollTop, 8303 scrollLeft 8304 }; 8305 } 8306 8307 /** 8308 * @memberOf BX 8309 */ 8310 let Dom = /*#__PURE__*/function () { 8311 function Dom() { 8312 babelHelpers.classCallCheck(this, Dom); 8313 } 8314 babelHelpers.createClass(Dom, null, [{ 8315 key: "replace", 8316 /** 8317 * Replaces old html element to new html element 8318 * @param oldElement 8319 * @param newElement 8320 */ 8321 value: function replace(oldElement, newElement) { 8322 if (Type.isDomNode(oldElement) && Type.isDomNode(newElement)) { 8323 if (Type.isDomNode(oldElement.parentNode)) { 8324 oldElement.parentNode.replaceChild(newElement, oldElement); 8325 } 8326 } 8327 } 8328 /** 8329 * Removes element 8330 * @param element 8331 */ 8332 }, { 8333 key: "remove", 8334 value: function remove(element) { 8335 if (Type.isDomNode(element) && Type.isDomNode(element.parentNode)) { 8336 element.parentNode.removeChild(element); 8337 } 8338 } 8339 /** 8340 * Cleans element 8341 * @param element 8342 */ 8343 }, { 8344 key: "clean", 8345 value: function clean(element) { 8346 if (Type.isDomNode(element)) { 8347 while (element.childNodes.length > 0) { 8348 element.removeChild(element.firstChild); 8349 } 8350 return; 8351 } 8352 if (Type.isString(element)) { 8353 Dom.clean(document.getElementById(element)); 8354 } 8355 } 8356 /** 8357 * Inserts element before target element 8358 * @param current 8359 * @param target 8360 */ 8361 }, { 8362 key: "insertBefore", 8363 value: function insertBefore(current, target) { 8364 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8365 if (Type.isDomNode(target.parentNode)) { 8366 target.parentNode.insertBefore(current, target); 8367 } 8368 } 8369 } 8370 /** 8371 * Inserts element after target element 8372 * @param current 8373 * @param target 8374 */ 8375 }, { 8376 key: "insertAfter", 8377 value: function insertAfter(current, target) { 8378 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8379 if (Type.isDomNode(target.parentNode)) { 8380 const parent = target.parentNode; 8381 if (Type.isDomNode(target.nextSibling)) { 8382 parent.insertBefore(current, target.nextSibling); 8383 return; 8384 } 8385 parent.appendChild(current); 8386 } 8387 } 8388 } 8389 /** 8390 * Appends element to target element 8391 * @param current 8392 * @param target 8393 */ 8394 }, { 8395 key: "append", 8396 value: function append(current, target) { 8397 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8398 target.appendChild(current); 8399 } 8400 } 8401 /** 8402 * Prepends element to target element 8403 * @param current 8404 * @param target 8405 */ 8406 }, {
8407 key: "prepend", 8408 value: function prepend(current, target) { 8409 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8410 if (Type.isDomNode(target.firstChild)) { 8411 target.insertBefore(current, target.firstChild); 8412 return; 8413 } 8414 Dom.append(current, target); 8415 } 8416 } 8417 /** 8418 * Checks that element contains class name or class names 8419 * @param element 8420 * @param className 8421 * @return {Boolean} 8422 */ 8423 }, { 8424 key: "hasClass", 8425 value: function hasClass(element, className) { 8426 if (Type.isElementNode(element)) { 8427 if (Type.isString(className)) { 8428 const preparedClassName = className.trim(); 8429 if (preparedClassName.length > 0) { 8430 if (preparedClassName.includes(' ')) { 8431 return preparedClassName.split(' ').every(name => Dom.hasClass(element, name)); 8432 } 8433 if ('classList' in element) { 8434 return element.classList.contains(preparedClassName); 8435 } 8436 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8437 return element.getAttribute('class').split(' ').some(name => name === preparedClassName); 8438 } 8439 } 8440 } 8441 if (Type.isArray(className) && className.length > 0) { 8442 return className.every(name => Dom.hasClass(element, name)); 8443 } 8444 } 8445 return false; 8446 } 8447 /** 8448 * Adds class name 8449 * @param element 8450 * @param className 8451 */ 8452 }, { 8453 key: "addClass", 8454 value: function addClass(element, className) { 8455 if (Type.isElementNode(element)) { 8456 if (Type.isString(className)) { 8457 const preparedClassName = className.trim(); 8458 if (preparedClassName.length > 0) { 8459 if (preparedClassName.includes(' ')) { 8460 Dom.addClass(element, preparedClassName.split(' ')); 8461 return; 8462 } 8463 if ('classList' in element) { 8464 element.classList.add(preparedClassName); 8465 return; 8466 } 8467 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8468 if (element.className.baseVal === '') { 8469 element.className.baseVal = preparedClassName; 8470 return; 8471 } 8472 const names = element.className.baseVal.split(' '); 8473 if (!names.includes(preparedClassName)) { 8474 names.push(preparedClassName); 8475 element.className.baseVal = names.join(' ').trim(); 8476 return; 8477 } 8478 } 8479 return; 8480 } 8481 } 8482 if (Type.isArray(className)) { 8483 className.forEach(name => Dom.addClass(element, name)); 8484 } 8485 } 8486 } 8487 /** 8488 * Removes class name 8489 * @param element 8490 * @param className 8491 */ 8492 }, { 8493 key: "removeClass", 8494 value: function removeClass(element, className) { 8495 if (Type.isElementNode(element)) { 8496 if (Type.isString(className)) { 8497 const preparedClassName = className.trim(); 8498 if (preparedClassName.length > 0) { 8499 if (preparedClassName.includes(' ')) { 8500 Dom.removeClass(element, preparedClassName.split(' ')); 8501 return; 8502 } 8503 if ('classList' in element) { 8504 element.classList.remove(preparedClassName); 8505 return; 8506 } 8507 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8508 const names = element.className.baseVal.split(' ').filter(name => name !== preparedClassName); 8509 element.className.baseVal = names.join(' '); 8510 return; 8511 } 8512 } 8513 } 8514 if (Type.isArray(className)) { 8515 className.forEach(name => Dom.removeClass(element, name)); 8516 } 8517 } 8518 } 8519 /** 8520 * Toggles class name 8521 * @param element 8522 * @param className 8523 */ 8524 }, { 8525 key: "toggleClass", 8526 value: function toggleClass(element, className) { 8527 if (Type.isElementNode(element)) { 8528 if (Type.isString(className)) { 8529 const preparedClassName = className.trim(); 8530 if (preparedClassName.length > 0) { 8531 if (preparedClassName.includes(' ')) { 8532 Dom.toggleClass(element, preparedClassName.split(' ')); 8533 return; 8534 } 8535 element.classList.toggle(preparedClassName); 8536 return; 8537 } 8538 } 8539 if (Type.isArray(className)) { 8540 className.forEach(name => Dom.toggleClass(element, name)); 8541 } 8542 } 8543 } 8544 /** 8545 * Styles element 8546 */ 8547 }, { 8548 key: "style", 8549 value: function style(element, prop, value) { 8550 if (Type.isElementNode(element)) { 8551 if (Type.isNull(prop)) { 8552 element.removeAttribute('style'); 8553 return element; 8554 } 8555 if (Type.isPlainObject(prop)) {
8556 Object.entries(prop).forEach(item => { 8557 const [currentKey, currentValue] = item; 8558 Dom.style(element, currentKey, currentValue); 8559 }); 8560 return element; 8561 } 8562 if (Type.isString(prop)) { 8563 if (Type.isUndefined(value) && element.nodeType !== Node.DOCUMENT_NODE) { 8564 const computedStyle = getComputedStyle(element); 8565 if (prop in computedStyle) { 8566 return computedStyle[prop]; 8567 } 8568 return computedStyle.getPropertyValue(prop); 8569 } 8570 if (Type.isNull(value) || value === '' || value === 'null') { 8571 if (String(prop).startsWith('--')) { 8572 // eslint-disable-next-line 8573 element.style.removeProperty(prop); 8574 return element; 8575 } 8576 8577 // eslint-disable-next-line 8578 element.style[prop] = ''; 8579 return element; 8580 } 8581 if (Type.isString(value) || Type.isNumber(value)) { 8582 if (String(prop).startsWith('--')) { 8583 // eslint-disable-next-line 8584 element.style.setProperty(prop, value); 8585 return element; 8586 } 8587 8588 // eslint-disable-next-line 8589 element.style[prop] = value; 8590 return element; 8591 } 8592 } 8593 } 8594 return null; 8595 } 8596 /** 8597 * Adjusts element 8598 * @param target 8599 * @param data 8600 * @return {*} 8601 */ 8602 }, { 8603 key: "adjust", 8604 value: function adjust(target, data = {}) { 8605 if (!target.nodeType) { 8606 return null; 8607 } 8608 let element = target; 8609 if (target.nodeType === Node.DOCUMENT_NODE) { 8610 element = target.body; 8611 } 8612 if (Type.isPlainObject(data)) { 8613 if (Type.isPlainObject(data.attrs)) { 8614 Object.keys(data.attrs).forEach(key => { 8615 if (key === 'class' || key.toLowerCase() === 'classname') { 8616 element.className = data.attrs[key]; 8617 return; 8618 } 8619 8620 // eslint-disable-next-line 8621 if (data.attrs[key] == '') { 8622 element.removeAttribute(key); 8623 return; 8624 } 8625 element.setAttribute(key, data.attrs[key]); 8626 }); 8627 } 8628 if (Type.isPlainObject(data.style)) { 8629 Dom.style(element, data.style); 8630 } 8631 if (Type.isPlainObject(data.props)) { 8632 Object.keys(data.props).forEach(key => { 8633 element[key] = data.props[key]; 8634 }); 8635 } 8636 if (Type.isPlainObject(data.events)) { 8637 Object.keys(data.events).forEach(key => { 8638 Event.bind(element, key, data.events[key]); 8639 }); 8640 } 8641 if (Type.isPlainObject(data.dataset)) { 8642 Object.keys(data.dataset).forEach(key => { 8643 element.dataset[key] = data.dataset[key]; 8644 }); 8645 } 8646 if (Type.isString(data.children)) { 8647 data.children = [data.children]; 8648 } 8649 if (Type.isArray(data.children) && data.children.length > 0) { 8650 data.children.forEach(item => { 8651 if (Type.isDomNode(item)) { 8652 Dom.append(item, element); 8653 } 8654 if (Type.isString(item)) { 8655 element.insertAdjacentHTML('beforeend', item); 8656 } 8657 }); 8658 return element; 8659 } 8660 if ('text' in data && !Type.isNil(data.text)) { 8661 element.innerText = data.text; 8662 return element; 8663 } 8664 if ('html' in data && !Type.isNil(data.html)) { 8665 element.innerHTML = data.html; 8666 } 8667 } 8668 return element; 8669 } 8670 /** 8671 * Creates element 8672 * @param tag 8673 * @param data 8674 * @param context 8675 * @return {HTMLElement|HTMLBodyElement} 8676 */ 8677 }, { 8678 key: "create", 8679 value: function create(tag, data = {}, context = document) { 8680 let tagName = tag; 8681 let options = data; 8682 if (Type.isObjectLike(tag)) { 8683 options = tag; 8684 tagName = tag.tag; 8685 } 8686 return Dom.adjust(context.createElement(tagName), options); 8687 } 8688 /** 8689 * Shows element 8690 * @param element 8691 */ 8692 }, { 8693 key: "show", 8694 value: function show(element) { 8695 if (Type.isDomNode(element)) { 8696 // eslint-disable-next-line 8697 element.hidden = false;
8698 } 8699 } 8700 /** 8701 * Hides element 8702 * @param element 8703 */ 8704 }, { 8705 key: "hide", 8706 value: function hide(element) { 8707 if (Type.isDomNode(element)) { 8708 // eslint-disable-next-line 8709 element.hidden = true; 8710 } 8711 } 8712 /** 8713 * Checks that element is shown 8714 * @param element 8715 * @return {*|boolean} 8716 */ 8717 }, { 8718 key: "isShown", 8719 value: function isShown(element) { 8720 return Type.isDomNode(element) && !element.hidden && element.style.getPropertyValue('display') !== 'none'; 8721 } 8722 /** 8723 * Toggles element visibility 8724 * @param element 8725 */ 8726 }, { 8727 key: "toggle", 8728 value: function toggle(element) { 8729 if (Type.isDomNode(element)) { 8730 if (Dom.isShown(element)) { 8731 Dom.hide(element); 8732 } else { 8733 Dom.show(element); 8734 } 8735 } 8736 } 8737 /** 8738 * Gets element position relative page 8739 * @param {HTMLElement} element 8740 * @return {DOMRect} 8741 */ 8742 }, { 8743 key: "getPosition", 8744 value: function getPosition(element) { 8745 if (Type.isDomNode(element)) { 8746 const elementRect = element.getBoundingClientRect(); 8747 const { 8748 scrollLeft, 8749 scrollTop 8750 } = getPageScroll(); 8751 return new DOMRect(elementRect.left + scrollLeft, elementRect.top + scrollTop, elementRect.width, elementRect.height); 8752 } 8753 return new DOMRect(); 8754 } 8755 /** 8756 * Gets element position relative specified element position 8757 * @param {HTMLElement} element 8758 * @param {HTMLElement} relationElement 8759 * @return {DOMRect} 8760 */ 8761 }, { 8762 key: "getRelativePosition", 8763 value: function getRelativePosition(element, relationElement) { 8764 if (Type.isDomNode(element) && Type.isDomNode(relationElement)) { 8765 const elementPosition = Dom.getPosition(element); 8766 const relationElementPosition = Dom.getPosition(relationElement); 8767 return new DOMRect(elementPosition.left - relationElementPosition.left, elementPosition.top - relationElementPosition.top, elementPosition.width, elementPosition.height); 8768 } 8769 return new DOMRect(); 8770 } 8771 }, { 8772 key: "attr", 8773 value: function attr(element, _attr, value) { 8774 if (Type.isElementNode(element)) { 8775 if (Type.isString(_attr)) { 8776 if (!Type.isNil(value)) { 8777 return element.setAttribute(_attr, encodeAttributeValue(value)); 8778 } 8779 if (Type.isNull(value)) { 8780 return element.removeAttribute(_attr); 8781 } 8782 return decodeAttributeValue(element.getAttribute(_attr)); 8783 } 8784 if (Type.isPlainObject(_attr)) { 8785 return Object.entries(_attr).forEach(([attrKey, attrValue]) => { 8786 Dom.attr(element, attrKey, attrValue); 8787 }); 8788 } 8789 } 8790 return null; 8791 } 8792 }]); 8793 return Dom; 8794 }(); 8795 8796 const UA = navigator.userAgent.toLowerCase(); 8797 8798 /** 8799 * @memberOf BX 8800 */ 8801 let Browser = /*#__PURE__*/function () { 8802 function Browser() { 8803 babelHelpers.classCallCheck(this, Browser); 8804 } 8805 babelHelpers.createClass(Browser, null, [{ 8806 key: "isOpera", 8807 value: function isOpera() { 8808 return UA.includes('opera'); 8809 } 8810 }, { 8811 key: "isIE", 8812 value: function isIE() { 8813 return 'attachEvent' in document && !Browser.isOpera(); 8814 } 8815 }, { 8816 key: "isIE6", 8817 value: function isIE6() { 8818 return UA.includes('msie 6'); 8819 } 8820 }, { 8821 key: "isIE7", 8822 value: function isIE7() { 8823 return UA.includes('msie 7'); 8824 } 8825 }, { 8826 key: "isIE8", 8827 value: function isIE8() { 8828 return UA.includes('msie 8'); 8829 } 8830 }, { 8831 key: "isIE9", 8832 value: function isIE9() { 8833 return 'documentMode' in document && document.documentMode >= 9; 8834 } 8835 }, { 8836 key: "isIE10", 8837 value: function isIE10() { 8838 return 'documentMode' in document && document.documentMode >= 10; 8839 } 8840 }, { 8841 key: "isSafari", 8842 value: function isSafari() { 8843 return UA.includes('safari') && !UA.includes('chrome'); 8844 } 8845 }, { 8846 key: "isFirefox", 8847 value: function isFirefox() { 8848 return UA.includes('firefox'); 8849 } 8850 }, { 8851 key: "isChrome", 8852 value: function isChrome() { 8853 return UA.includes('chrome'); 8854 } 8855 }, { 8856 key: "detectIEVersion", 8857 value: function detectIEVersion() { 8858 if (Browser.isOpera() || Browser.isSafari() || Browser.isFirefox() || Browser.isChrome()) { 8859 return -1; 8860 } 8861 let rv = -1; 8862 if (!!window.MSStream && !window.ActiveXObject && 'ActiveXObject' in window) { 8863 rv = 11; 8864 } else if (Browser.isIE10()) { 8865 rv = 10; 8866 } else if (Browser.isIE9()) { 8867 rv = 9; 8868 } else if (Browser.isIE()) { 8869 rv = 8; 8870 } 8871 if (rv === -1 || rv === 8) { 8872 if (navigator.appName === 'Microsoft Internet Explorer') { 8873 const re = new RegExp('MSIE ([0-9]+[.0-9]*)'); 8874 const res = navigator.userAgent.match(re); 8875 if (Type.isArrayLike(res) && res.length > 0) { 8876 rv = parseFloat(res[1]); 8877 } 8878 } 8879 if (navigator.appName === 'Netscape') { 8880 // Alternative check for IE 11 8881 rv = 11; 8882 const re = new RegExp('Trident/.*rv:([0-9]+[.0-9]*)'); 8883 if (re.exec(navigator.userAgent) != null) { 8884 const res = navigator.userAgent.match(re); 8885 if (Type.isArrayLike(res) && res.length > 0) { 8886 rv = parseFloat(res[1]); 8887 } 8888 } 8889 } 8890 } 8891 return rv; 8892 } 8893 }, { 8894 key: "isIE11", 8895 value: function isIE11() { 8896 return Browser.detectIEVersion() >= 11; 8897 } 8898 }, { 8899 key: "isMac", 8900 value: function isMac() { 8901 return UA.includes('macintosh'); 8902 } 8903 }, { 8904 key: "isWin", 8905 value: function isWin() { 8906 return UA.includes('windows'); 8907 } 8908 }, { 8909 key: "isLinux", 8910 value: function isLinux() { 8911 return UA.includes('linux') && !Browser.isAndroid(); 8912 } 8913 }, { 8914 key: "isAndroid", 8915 value: function isAndroid() { 8916 return UA.includes('android'); 8917 } 8918 }, { 8919 key: "isIPad", 8920 value: function isIPad() { 8921 return UA.includes('ipad;') || this.isMac() && this.isTouchDevice(); 8922 } 8923 }, { 8924 key: "isIPhone", 8925 value: function isIPhone() { 8926 return UA.includes('iphone;'); 8927 } 8928 }, { 8929 key: "isIOS", 8930 value: function isIOS() { 8931 return Browser.isIPad() || Browser.isIPhone(); 8932 } 8933 }, { 8934 key: "isMobile", 8935 value: function isMobile() { 8936 return Browser.isIPhone() || Browser.isIPad() || Browser.isAndroid() || UA.includes('mobile') || UA.includes('touch'); 8937 } 8938 }, { 8939 key: "isRetina", 8940 value: function isRetina() { 8941 return window.devicePixelRatio && window.devicePixelRatio >= 2; 8942 } 8943 }, { 8944 key: "isTouchDevice", 8945 value: function isTouchDevice() { 8946 return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; 8947 } 8948 }, { 8949 key: "isDoctype", 8950 value: function isDoctype(target) { 8951 const doc = target || document; 8952 if (doc.compatMode) { 8953 return doc.compatMode === 'CSS1Compat'; 8954 } 8955 return doc.documentElement && doc.documentElement.clientHeight; 8956 } 8957 }, { 8958 key: "isLocalStorageSupported", 8959 value: function isLocalStorageSupported() { 8960 try { 8961 localStorage.setItem('test', 'test'); 8962 localStorage.removeItem('test'); 8963 return true; 8964 } catch (e) { 8965 return false;
8966 } 8967 } 8968 }, { 8969 key: "addGlobalClass", 8970 value: function addGlobalClass(target) { 8971 let globalClass = 'bx-core'; 8972 target = Type.isElementNode(target) ? target : document.documentElement; 8973 if (Dom.hasClass(target, globalClass)) { 8974 return; 8975 } 8976 if (Browser.isIOS()) { 8977 globalClass += ' bx-ios'; 8978 } else if (Browser.isWin()) { 8979 globalClass += ' bx-win'; 8980 } else if (Browser.isMac()) { 8981 globalClass += ' bx-mac'; 8982 } else if (Browser.isLinux()) { 8983 globalClass += ' bx-linux'; 8984 } else if (Browser.isAndroid()) { 8985 globalClass += ' bx-android'; 8986 } 8987 globalClass += Browser.isMobile() ? ' bx-touch' : ' bx-no-touch'; 8988 globalClass += Browser.isRetina() ? ' bx-retina' : ' bx-no-retina'; 8989 if (/AppleWebKit/.test(navigator.userAgent)) { 8990 globalClass += ' bx-chrome'; 8991 } else if (/Opera/.test(navigator.userAgent)) { 8992 globalClass += ' bx-opera'; 8993 } else if (Browser.isFirefox()) { 8994 globalClass += ' bx-firefox'; 8995 } 8996 Dom.addClass(target, globalClass); 8997 } 8998 }, { 8999 key: "detectAndroidVersion", 9000 value: function detectAndroidVersion() { 9001 const re = new RegExp('Android ([0-9]+[.0-9]*)'); 9002 if (re.exec(navigator.userAgent) != null) { 9003 const res = navigator.userAgent.match(re); 9004 if (Type.isArrayLike(res) && res.length > 0) { 9005 return parseFloat(res[1]); 9006 } 9007 } 9008 return 0; 9009 } 9010 }, { 9011 key: "isPropertySupported", 9012 value: function isPropertySupported(jsProperty, returnCSSName) { 9013 if (jsProperty === '') { 9014 return false; 9015 } 9016 function getCssName(propertyName) { 9017 return propertyName.replace(/([A-Z])/g, (...args) => `-${args[1].toLowerCase()}`); 9018 } 9019 function getJsName(cssName) { 9020 const reg = /(\\-([a-z]))/g; 9021 if (reg.test(cssName)) { 9022 return cssName.replace(reg, (...args) => args[2].toUpperCase()); 9023 } 9024 return cssName; 9025 } 9026 const property = jsProperty.includes('-') ? getJsName(jsProperty) : jsProperty; 9027 const bReturnCSSName = !!returnCSSName; 9028 const ucProperty = property.charAt(0).toUpperCase() + property.slice(1); 9029 const props = ['Webkit', 'Moz', 'O', 'ms'].join(`${ucProperty} `); 9030 const properties = `${property} ${props} ${ucProperty}`.split(' '); 9031 const obj = document.body || document.documentElement; 9032 for (let i = 0; i < properties.length; i += 1) { 9033 const prop = properties[i]; 9034 if (obj && 'style' in obj && prop in obj.style) { 9035 const lowerProp = prop.substr(0, prop.length - property.length).toLowerCase(); 9036 const prefix = prop === property ? '' : `-${lowerProp}-`; 9037 return bReturnCSSName ? prefix + getCssName(property) : prop; 9038 } 9039 } 9040 return false; 9041 } 9042 }, { 9043 key: "addGlobalFeatures", 9044 value: function addGlobalFeatures(features) { 9045 if (!Type.isArray(features)) { 9046 return; 9047 } 9048 const classNames = []; 9049 for (let i = 0; i < features.length; i += 1) { 9050 const support = !!Browser.isPropertySupported(features[i]); 9051 classNames.push(`bx-${support ? '' : 'no-'}${features[i].toLowerCase()}`); 9052 } 9053 Dom.addClass(document.documentElement, classNames.join(' ')); 9054 } 9055 }]); 9056 return Browser; 9057 }(); 9058 9059 let Cookie = /*#__PURE__*/function () { 9060 function Cookie() { 9061 babelHelpers.classCallCheck(this, Cookie); 9062 } 9063 babelHelpers.createClass(Cookie, null, [{ 9064 key: "getList", 9065 /** 9066 * Gets cookies list for current domain 9067 * @return {object} 9068 */ 9069 value: function getList() { 9070 return document.cookie.split(';').map(item => item.split('=')).map(item => item.map(subItem => subItem.trim())).reduce((acc, item) => { 9071 const [key, value] = item; 9072 acc[decodeURIComponent(key)] = decodeURIComponent(value); 9073 return acc; 9074 }, {}); 9075 } 9076 /** 9077 * Gets cookie value 9078 * @param {string} name 9079 * @return {*} 9080 */ 9081 }, { 9082 key: "get", 9083 value: function get(name) { 9084 const cookiesList = Cookie.getList(); 9085 if (name in cookiesList) { 9086 return cookiesList[name]; 9087 } 9088 return undefined; 9089 } 9090 /** 9091 * Sets cookie 9092 * @param {string} name 9093 * @param {*} value 9094 * @param {object} [options] 9095 */ 9096 }, { 9097 key: "set", 9098 value: function set(name, value, options = {}) { 9099 const attributes = { 9100 expires: '', 9101 ...options 9102 }; 9103 if (Type.isNumber(attributes.expires)) { 9104 const now = +new Date(); 9105 const days = attributes.expires; 9106 const dayInMs = 864e+5; 9107 attributes.expires = new Date(now + days * dayInMs); 9108 } 9109 if (Type.isDate(attributes.expires)) { 9110 attributes.expires = attributes.expires.toUTCString(); 9111 } 9112 const safeName = decodeURIComponent(String(name)).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape); 9113 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); 9114 const stringifiedAttributes = Object.keys(attributes).reduce((acc, key) => { 9115 const attributeValue = attributes[key]; 9116 if (!attributeValue) { 9117 return acc; 9118 } 9119 if (attributeValue === true) { 9120 return `${acc}; ${key}`; 9121 } 9122 9123 /** 9124 * Considers RFC 6265 section 5.2: 9125 * ... 9126 * 3. If the remaining unparsed-attributes contains a %x3B (';') 9127 * character: 9128 * Consume the characters of the unparsed-attributes up to, 9129 * not including, the first %x3B (';') character. 9130 */ 9131 return `${acc}; ${key}=${attributeValue.split(';')[0]}`; 9132 }, ''); 9133 document.cookie = `${safeName}=${safeValue}${stringifiedAttributes}`; 9134 } 9135 /** 9136 * Removes cookie 9137 * @param {string} name 9138 * @param {object} [options] 9139 */ 9140 }, { 9141 key: "remove", 9142 value: function remove(name, options = {}) { 9143 Cookie.set(name, '', { 9144 ...options, 9145 expires: -1 9146 }); 9147 } 9148 }]); 9149 return Cookie; 9150 }(); 9151 9152 function objectToFormData(source, formData = new FormData(), pre = null) { 9153 if (Type.isUndefined(source)) { 9154 return formData; 9155 } 9156 if (Type.isNull(source)) { 9157 formData.append(pre, ''); 9158 } else if (Type.isArray(source)) { 9159 if (!source.length) {
9160 const key = `${pre}[]`; 9161 formData.append(key, ''); 9162 } else { 9163 source.forEach((value, index) => { 9164 const key = `${pre}[${index}]`; 9165 objectToFormData(value, formData, key); 9166 }); 9167 } 9168 } else if (Type.isDate(source)) { 9169 formData.append(pre, source.toISOString()); 9170 } else if (Type.isObject(source) && !Type.isFile(source) && !Type.isBlob(source)) { 9171 Object.keys(source).forEach(property => { 9172 const value = source[property]; 9173 let preparedProperty = property; 9174 if (Type.isArray(value)) { 9175 while (property.length > 2 && property.lastIndexOf('[]') === property.length - 2) { 9176 preparedProperty = property.substring(0, property.length - 2); 9177 } 9178 } 9179 const key = pre ? `${pre}[${preparedProperty}]` : preparedProperty; 9180 objectToFormData(value, formData, key); 9181 }); 9182 } else { 9183 formData.append(pre, source); 9184 } 9185 return formData; 9186 } 9187 9188 let Data = /*#__PURE__*/function () { 9189 function Data() { 9190 babelHelpers.classCallCheck(this, Data); 9191 } 9192 babelHelpers.createClass(Data, null, [{ 9193 key: "convertObjectToFormData", 9194 /** 9195 * Converts object to FormData 9196 * @param source 9197 * @return {FormData} 9198 */ 9199 value: function convertObjectToFormData(source) { 9200 return objectToFormData(source); 9201 } 9202 }]); 9203 return Data; 9204 }(); 9205 9206 /** 9207 * @memberOf BX 9208 */ 9209 let Http = function Http() { 9210 babelHelpers.classCallCheck(this, Http); 9211 }; 9212 babelHelpers.defineProperty(Http, "Cookie", Cookie); 9213 babelHelpers.defineProperty(Http, "Data", Data); 9214 9215 function message(value) { 9216 if (Type.isString(value)) { 9217 if (Type.isNil(message[value])) { 9218 // eslint-disable-next-line 9219 EventEmitter.emit('onBXMessageNotFound', new BaseEvent({ 9220 compatData: [value] 9221 })); 9222 if (Type.isNil(message[value])) { 9223 Runtime.debug(`message undefined: ${value}`); 9224 message[value] = ''; 9225 } 9226 } 9227 } 9228 if (Type.isPlainObject(value)) { 9229 Object.keys(value).forEach(key => { 9230 message[key] = value[key]; 9231 }); 9232 } 9233 return message[value]; 9234 } 9235 if (!Type.isNil(window.BX) && Type.isFunction(window.BX.message)) { 9236 Object.keys(window.BX.message).forEach(key => { 9237 message({ 9238 [key]: window.BX.message[key] 9239 }); 9240 }); 9241 } 9242 9243 /** 9244 * Implements interface for works with language messages 9245 * @memberOf BX 9246 */ 9247 let Loc = /*#__PURE__*/function () { 9248 function Loc() { 9249 babelHelpers.classCallCheck(this, Loc); 9250 } 9251 babelHelpers.createClass(Loc, null, [{ 9252 key: "getMessage", 9253 /** 9254 * Gets message by id 9255 * @param {string} messageId 9256 * @param {object} replacements 9257 * @return {?string} 9258 */ 9259 value: function getMessage(messageId, replacements = null) { 9260 let mess = message(messageId); 9261 if (Type.isString(mess) && Type.isPlainObject(replacements)) { 9262 const escape = str => String(str).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&'); 9263 Object.keys(replacements).forEach(replacement => { 9264 const globalRegexp = new RegExp(escape(replacement), 'gi'); 9265 mess = mess.replace(globalRegexp, () => { 9266 return Type.isNil(replacements[replacement]) ? '' : String(replacements[replacement]); 9267 }); 9268 }); 9269 } 9270 return mess; 9271 } 9272 }, { 9273 key: "hasMessage", 9274 value: function hasMessage(messageId) { 9275 return Type.isString(messageId) && !Type.isNil(message[messageId]); 9276 } 9277 /** 9278 * Sets message or messages 9279 * @param {string | Object<string, string>} id 9280 * @param {string} [value] 9281 */ 9282 }, { 9283 key: "setMessage", 9284 value: function setMessage(id, value) { 9285 if (Type.isString(id) && Type.isString(value)) { 9286 message({ 9287 [id]: value 9288 }); 9289 } 9290 if (Type.isObject(id)) { 9291 message(id); 9292 } 9293 } 9294 /** 9295 * Gets plural message by id and number 9296 * @param {string} messageId 9297 * @param {number} value 9298 * @param {object} [replacements] 9299 * @return {?string} 9300 */ 9301 }, { 9302 key: "getMessagePlural",
9303 value: function getMessagePlural(messageId, value, replacements = null) { 9304 let result = ''; 9305 if (Type.isNumber(value)) { 9306 if (this.hasMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`)) { 9307 result = this.getMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`, replacements); 9308 } else { 9309 result = this.getMessage(`${messageId}_PLURAL_1`, replacements); 9310 } 9311 } else { 9312 result = this.getMessage(messageId, replacements); 9313 } 9314 return result; 9315 } 9316 /** 9317 * Gets language plural form id by number 9318 * see http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html 9319 * @param {number} value 9320 * @param {string} [languageId] 9321 * @return {?number} 9322 */ 9323 }, { 9324 key: "getPluralForm", 9325 value: function getPluralForm(value, languageId) { 9326 let pluralForm; 9327 if (!Type.isStringFilled(languageId)) { 9328 languageId = message('LANGUAGE_ID'); 9329 } 9330 if (value < 0) { 9331 value = -1 * value; 9332 } 9333 switch (languageId) { 9334 case 'ar': 9335 pluralForm = value !== 1 ? 1 : 0; 9336 /* 9337 if (value === 0) 9338 { 9339 pluralForm = 0; 9340 } 9341 else if (value === 1) 9342 { 9343 pluralForm = 1; 9344 } 9345 else if (value === 2) 9346 { 9347 pluralForm = 2; 9348 } 9349 else if ( 9350 value % 100 >= 3 9351 && value % 100 <= 10 9352 ) 9353 { 9354 pluralForm = 3; 9355 } 9356 else if (value % 100 >= 11) 9357 { 9358 pluralForm = 4; 9359 } 9360 else 9361 { 9362 pluralForm = 5; 9363 } 9364 */ 9365 break; 9366 case 'br': 9367 case 'fr': 9368 case 'tr': 9369 pluralForm = value > 1 ? 1 : 0; 9370 break; 9371 case 'de': 9372 case 'en': 9373 case 'hi': 9374 case 'it': 9375 case 'la': 9376 pluralForm = value !== 1 ? 1 : 0; 9377 break; 9378 case 'ru': 9379 case 'ua': 9380 if (value % 10 === 1 && value % 100 !== 11) { 9381 pluralForm = 0; 9382 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9383 pluralForm = 1; 9384 } else { 9385 pluralForm = 2; 9386 } 9387 break; 9388 case 'pl': 9389 if (value === 1) { 9390 pluralForm = 0; 9391 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9392 pluralForm = 1; 9393 } else { 9394 pluralForm = 2; 9395 } 9396 break; 9397 case 'id': 9398 case 'ja': 9399 case 'ms': 9400 case 'sc': 9401 case 'tc': 9402 case 'th': 9403 case 'vn': 9404 pluralForm = 0; 9405 break; 9406 default: 9407 pluralForm = 1; 9408 break; 9409 } 9410 return pluralForm; 9411 } 9412 }]); 9413 return Loc; 9414 }(); 9415 9416 const voidElements = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr']; 9417 function isVoidElement(element) { 9418 return voidElements.includes(element); 9419 } 9420 9421 const matchers = { 9422 tag: /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>|{{uid[0-9]+}}/g, 9423 comment: /<!--(?!<!)[^\[>].*?-->/g, 9424 tagName: /<\/?([^\s]+?)[/\s>]/, 9425 attributes: /\s([\w\-_:.]+)\s?\n?=\s?\n?"([^"]+)?"|\s([\w\-_:.]+)\s?\n?=\s?\n?'([^']+)?'|\s([\w\-_:.]+)/gs, 9426 placeholder: /{{uid[0-9]+}}/g 9427 }; 9428 9429 function parseTag(tag) { 9430 const tagResult = { 9431 type: 'tag', 9432 name: '', 9433 svg: false, 9434 attrs: {}, 9435 children: [], 9436 voidElement: false 9437 }; 9438 if (tag.startsWith('<!--')) { 9439 const endIndex = tag.indexOf('-->'); 9440 const openTagLength = '<!--'.length; 9441 return { 9442 type: 'comment', 9443 content: endIndex !== -1 ? tag.slice(openTagLength, endIndex) : '' 9444 }; 9445 } 9446 const tagNameMatch = tag.match(matchers.tagName); 9447 if (Type.isArrayFilled(tagNameMatch)) { 9448 const [, tagName] = tagNameMatch; 9449 tagResult.name = tagName; 9450 tagResult.svg = tagName === 'svg'; 9451 tagResult.voidElement = isVoidElement(tagName) || tag.trim().endsWith('/>'); 9452 } 9453 const reg = new RegExp(matchers.attributes); 9454 for (;;) { 9455 const result = reg.exec(tag); 9456 if (!Type.isNil(result)) { 9457 // Attributes with double quotes 9458 const [, attrName, attrValue] = result; 9459 if (!Type.isNil(attrName)) { 9460 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9461 } else { 9462 // Attributes with single quotes 9463 const [,,, attrName, attrValue] = result; 9464 if (!Type.isNil(attrName)) { 9465 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9466 } else { 9467 // Attributes without value 9468 const [,,,,, attrName] = result; 9469 tagResult.attrs[attrName] = ''; 9470 } 9471 } 9472 } else { 9473 break; 9474 } 9475 } 9476 return tagResult; 9477 } 9478 9479 function parseText(input) { 9480 const preparedText = input.replace(/[\n\r\t]$/, ''); 9481 const placeholders = preparedText.match(matchers.placeholder); 9482 return preparedText.split(matchers.placeholder).reduce((acc, item, index) => { 9483 if (Type.isStringFilled(item)) { 9484 acc.push(...item.split(/\n/).reduce((textAcc, text) => { 9485 const preparedItemText = text.replace(/[\t\r]/g, ''); 9486 if (Type.isStringFilled(preparedItemText)) { 9487 textAcc.push({ 9488 type: 'text', 9489 content: preparedItemText 9490 }); 9491 } 9492 return textAcc; 9493 }, [])); 9494 } 9495 if (placeholders && placeholders[index]) { 9496 acc.push({ 9497 type: 'placeholder', 9498 uid: parseInt(placeholders[index].replace(/{{uid|}}/, '')) 9499 }); 9500 } 9501 return acc; 9502 }, []); 9503 } 9504 9505 function parse(html, substitutions) { 9506 const result = []; 9507 if (html.indexOf('<') !== 0 && !html.startsWith('{{')) { 9508 const end = html.indexOf('<'); 9509 result.push(...parseText(end === -1 ? html : html.slice(0, end))); 9510 } 9511 const commentsContent = []; 9512 let commentIndex = -1; 9513 html = html.replace(matchers.comment, tag => { 9514 commentIndex += 1; 9515 commentsContent.push(tag.replace(/^<!--|-->$/g, '')); 9516 return `<!--{{cUid${commentIndex}}}-->`; 9517 }); 9518 const arr = []; 9519 let level = -1; 9520 let current; 9521 html.replace(matchers.tag, (tag, index) => { 9522 const start = index + tag.length; 9523 const nextChar = html.charAt(start); 9524 let parent; 9525 if (tag.startsWith('<!--')) { 9526 const comment = parseTag(tag, substitutions); 9527 comment.content = commentsContent[tag.replace(/<!--{{cUid|}}-->/g, '')]; 9528 if (level < 0) { 9529 result.push(comment); 9530 return result; 9531 } 9532 parent = arr[level]; 9533 parent.children.push(comment); 9534 return result; 9535 } 9536 if (tag.startsWith('{{')) { 9537 const [placeholder] = parseText(tag); 9538 if (level < 0) { 9539 result.push(placeholder); 9540 return result; 9541 } 9542 parent = arr[level]; 9543 parent.children.push(placeholder); 9544 return result; 9545 } 9546 if (!tag.startsWith('</')) { 9547 level++; 9548 current = parseTag(tag, substitutions); 9549 if (!current.voidElement && nextChar && nextChar !== '<') { 9550 current.children.push(...parseText(html.slice(start, html.indexOf('<', start)))); 9551 } 9552 if (level === 0) { 9553 result.push(current); 9554 } 9555 parent = arr[level - 1]; 9556 if (parent) { 9557 if (!current.svg) { 9558 current.svg = parent.svg; 9559 } 9560 parent.children.push(current); 9561 } 9562 arr[level] = current; 9563 } 9564 if (tag.startsWith('</') || current.voidElement) { 9565 if (level > -1 && (current.voidElement || current.name === tag.slice(2, -1))) { 9566 level--; 9567 current = level === -1 ? result : arr[level]; 9568 } 9569 if (nextChar && nextChar !== '<') { 9570 parent = level === -1 ? result : arr[level].children; 9571 const end = html.indexOf('<', start); 9572 const content = html.slice(start, end === -1 ? undefined : end); 9573 if (end >
9573 -1 && level + parent.length >= 0 || content !== ' ') { 9574 parent.push(...parseText(content)); 9575 } 9576 } 9577 } 9578 }); 9579 return result; 9580 } 9581 9582 const appendElement = (current, target) => { 9583 if (Type.isDomNode(current) && Type.isDomNode(target)) { 9584 if (target.nodeName !== 'TEMPLATE') { 9585 Dom.append(current, target); 9586 } else { 9587 // eslint-disable-next-line bitrix-rules/no-native-dom-methods 9588 target.content.append(current); 9589 } 9590 } 9591 }; 9592 function renderNode(options) { 9593 const { 9594 node, 9595 parentElement, 9596 substitutions, 9597 refs = [] 9598 } = options; 9599 if (node.type === 'tag') { 9600 const element = (() => { 9601 if (node.svg) { 9602 return document.createElementNS('http://www.w3.org/2000/svg', node.name); 9603 } 9604 return document.createElement(node.name); 9605 })(); 9606 if (Object.hasOwn(node.attrs, 'ref')) { 9607 refs.push([node.attrs.ref, element]); 9608 delete node.attrs.ref; 9609 } 9610 Object.entries(node.attrs).forEach(([key, value]) => { 9611 if (key.startsWith('on') && new RegExp(matchers.placeholder).test(value)) { 9612 const substitution = substitutions[parseInt(value.replace(/{{uid|}}/, '')) - 1]; 9613 if (Type.isFunction(substitution)) { 9614 const bindFunctionName = key.endsWith('once') ? 'bindOnce' : 'bind'; 9615 Event[bindFunctionName](element, key.replace(/^on|once$/g, ''), substitution); 9616 } else { 9617 element.setAttribute(key, substitution); 9618 } 9619 } else { 9620 if (new RegExp(matchers.placeholder).test(value)) { 9621 const preparedValue = value.split(/{{|}}/).reduce((acc, item) => { 9622 if (item.startsWith('uid')) { 9623 const substitution = substitutions[parseInt(item.replace('uid', '')) - 1]; 9624 return `${acc}${substitution}`; 9625 } 9626 return `${acc}${item}`; 9627 }, ''); 9628 element.setAttribute(key, preparedValue); 9629 } else { 9630 element.setAttribute(key, Text.decode(value)); 9631 } 9632 } 9633 }); 9634 node.children.forEach(childNode => { 9635 const result = renderNode({ 9636 node: childNode, 9637 parentElement: element, 9638 substitutions, 9639 refs 9640 }); 9641 if (Type.isArray(result)) { 9642 result.forEach(subChildElement => { 9643 appendElement(subChildElement, element); 9644 }); 9645 } else { 9646 appendElement(result, element); 9647 } 9648 }); 9649 return element; 9650 } 9651 if (node.type === 'comment') { 9652 return document.createComment(node.content); 9653 } 9654 if (node.type === 'text') { 9655 if (parentElement) { 9656 if (parentElement.nodeName !== 'TEMPLATE') { 9657 parentElement.insertAdjacentHTML('beforeend', node.content); 9658 } else { 9659 parentElement.content.append(node.content); 9660 } 9661 return; 9662 } 9663 return document.createTextNode(node.content); 9664 } 9665 if (node.type === 'placeholder') { 9666 return substitutions[node.uid - 1]; 9667 } 9668 } 9669 9670 function render(sections, ...substitutions) { 9671 const html = sections.reduce((acc, item, index) => { 9672 if (index > 0) { 9673 const substitution = substitutions[index - 1]; 9674 if (Type.isString(substitution) || Type.isNumber(substitution)) { 9675 return `${acc}${substitution}${item}`; 9676 } 9677 return `${acc}{{uid${index}}}${item}`; 9678 } 9679 return acc; 9680 }, sections[0]).replace(/^[\r\n\t\s]+/gm, '').replace(/>[\n]+/g, '>').replace(/[}][\n]+/g, '}'); 9681 const ast = parse(html); 9682 if (ast.length === 1) { 9683 const refs = []; 9684 const renderedNode = renderNode({ 9685 node: ast[0], 9686 substitutions, 9687 refs 9688 }); 9689 if (Type.isArrayFilled(refs)) { 9690 return Object.fromEntries([['root', renderedNode], ...refs]); 9691 } 9692 return renderedNode; 9693 } 9694 if (ast.length > 1) { 9695 const refs = []; 9696 const renderedNodes = ast.map(node => { 9697 return renderNode({ 9698 node, 9699 substitutions, 9700 refs 9701 }); 9702 }); 9703 if (Type.isArrayFilled(refs)) { 9704 return Object.fromEntries([['root', renderedNodes], ...refs]); 9705 } 9706 return renderedNodes; 9707 } 9708 return false;
9709 } 9710 9711 function parseProps(sections, ...substitutions) { 9712 return substitutions.reduce((acc, item, index) => { 9713 const nextSectionIndex = index + 1; 9714 if (!Type.isPlainObject(item) && !Type.isArray(item)) { 9715 return acc + item + sections[nextSectionIndex]; 9716 } 9717 return `${acc}__s${index}${sections[nextSectionIndex]}`; 9718 }, sections[0]).replace(/[\r\t]/gm, '').split(';\n').map(item => item.replace(/\n/, '')).reduce((acc, item) => { 9719 if (item !== '') { 9720 const matches = item.match(/^[\w-. ]+:/); 9721 const splitted = item.split(/^[\w-. ]+:/); 9722 const key = matches[0].replace(':', '').trim(); 9723 const value = splitted[1].trim(); 9724 const substitutionPlaceholderExp = /^__s\d+/; 9725 if (substitutionPlaceholderExp.test(value)) { 9726 acc[key] = substitutions[value.replace('__s', '')]; 9727 return acc; 9728 } 9729 acc[key] = value; 9730 } 9731 return acc; 9732 }, {}); 9733 } 9734 9735 /** 9736 * @memberOf BX 9737 */ 9738 let Tag = /*#__PURE__*/function () { 9739 function Tag() { 9740 babelHelpers.classCallCheck(this, Tag); 9741 } 9742 babelHelpers.createClass(Tag, null, [{ 9743 key: "safe", 9744 /** 9745 * Encodes all substitutions 9746 * @param sections 9747 * @param substitutions 9748 * @return {string} 9749 */ 9750 value: function safe(sections, ...substitutions) { 9751 return substitutions.reduce((acc, item, index) => acc + Text.encode(item) + sections[index + 1], sections[0]); 9752 } 9753 /** 9754 * Decodes all substitutions 9755 * @param sections 9756 * @param substitutions 9757 * @return {string} 9758 */ 9759 }, { 9760 key: "unsafe", 9761 value: function unsafe(sections, ...substitutions) { 9762 return substitutions.reduce((acc, item, index) => acc + Text.decode(item) + sections[index + 1], sections[0]); 9763 } 9764 /** 9765 * Adds styles to specified element 9766 * @param {HTMLElement} element 9767 * @return {Function} 9768 */ 9769 }, { 9770 key: "style", 9771 value: function style(element) { 9772 if (!Type.isDomNode(element)) { 9773 throw new Error('element is not HTMLElement'); 9774 } 9775 return function styleTagHandler(...args) { 9776 Dom.style(element, parseProps(...args)); 9777 }; 9778 } 9779 /** 9780 * Replace all messages identifiers to real messages 9781 * @param sections 9782 * @param substitutions 9783 * @return {string} 9784 */ 9785 }, { 9786 key: "message", 9787 value: function message(sections, ...substitutions) { 9788 return substitutions.reduce((acc, item, index) => acc + Loc.getMessage(item) + sections[index + 1], sections[0]); 9789 } 9790 }, { 9791 key: "attrs", 9792 /** 9793 * Adds attributes to specified element 9794 * @param element 9795 * @return {Function} 9796 */ 9797 value: function attrs(element) { 9798 if (!Type.isDomNode(element)) { 9799 throw new Error('element is not HTMLElement'); 9800 } 9801 return function attrsTagHandler(...args) { 9802 Dom.attr(element, parseProps(...args)); 9803 }; 9804 } 9805 }]); 9806 return Tag; 9807 }(); 9808 babelHelpers.defineProperty(Tag, "render", render); 9809 babelHelpers.defineProperty(Tag, "attr", Tag.attrs); 9810 9811 function getParser(format) { 9812 switch (format) { 9813 case 'index': 9814 return (sourceKey, value, accumulator) => { 9815 const result = /\[(\w*)\]$/.exec(sourceKey); 9816 const key = sourceKey.replace(/\[\w*\]$/, ''); 9817 if (Type.isNil(result)) { 9818 accumulator[key] = value; 9819 return; 9820 } 9821 if (Type.isUndefined(accumulator[key])) { 9822 accumulator[key] = {}; 9823 } 9824 accumulator[key][result[1]] = value; 9825 }; 9826 case 'bracket': 9827 return (sourceKey, value, accumulator) => { 9828 const result = /(\[\])$/.exec(sourceKey); 9829 const key = sourceKey.replace(/\[\]$/, ''); 9830 if (Type.isNil(result)) { 9831 accumulator[key] = value; 9832 return; 9833 } 9834 if (Type.isUndefined(accumulator[key])) { 9835 accumulator[key] = [value]; 9836 return; 9837 } 9838 accumulator[key] = [].concat(accumulator[key], value); 9839 }; 9840 default: 9841 return (sourceKey, value, accumulator) => {
9842 const key = sourceKey.replace(/\[\]$/, ''); 9843 accumulator[key] = value; 9844 }; 9845 } 9846 } 9847 function getKeyFormat(key) { 9848 if (/^\w+\[([\w]+)\]$/.test(key)) { 9849 return 'index'; 9850 } 9851 if (/^\w+\[\]$/.test(key)) { 9852 return 'bracket'; 9853 } 9854 return 'default'; 9855 } 9856 function isAllowedKey(key) { 9857 return !String(key).startsWith('__proto__'); 9858 } 9859 function parseQuery(input) { 9860 if (!Type.isString(input)) { 9861 return {}; 9862 } 9863 const url = input.trim().replace(/^[?#&]/, ''); 9864 if (!url) { 9865 return {}; 9866 } 9867 return { 9868 ...url.split('&').reduce((acc, param) => { 9869 const [key, value] = param.replace(/\+/g, ' ').split('='); 9870 if (isAllowedKey(key)) { 9871 const keyFormat = getKeyFormat(key); 9872 const formatter = getParser(keyFormat); 9873 formatter(key, value, acc); 9874 } 9875 return acc; 9876 }, Object.create(null)) 9877 }; 9878 } 9879 const urlExp = /^((\w+):)?(\/\/((\w+)?(:(\w+))?@)?([^\/\?:]+)(:(\d+))?)?(\/?([^\/\?#][^\?#]*)?)?(\?([^#]+))?(#(\w*))?/; 9880 function parseUrl(url) { 9881 const result = url.match(urlExp); 9882 if (Type.isArray(result)) { 9883 const queryParams = parseQuery(result[14]); 9884 return { 9885 useShort: /^\/\//.test(url), 9886 href: result[0] || '', 9887 schema: result[2] || '', 9888 host: result[8] || '', 9889 port: result[10] || '', 9890 path: result[11] || '', 9891 query: result[14] || '', 9892 queryParams, 9893 hash: result[16] || '', 9894 username: result[5] || '', 9895 password: result[7] || '', 9896 origin: result[8] || '' 9897 }; 9898 } 9899 return {}; 9900 } 9901 9902 function buildQueryString(params = {}) { 9903 const queryString = Object.keys(params).reduce((acc, key) => { 9904 if (Type.isArray(params[key])) { 9905 params[key].forEach(paramValue => { 9906 acc.push(`${key}[]=${paramValue}`); 9907 }, ''); 9908 } 9909 if (Type.isPlainObject(params[key])) { 9910 Object.keys(params[key]).forEach(paramIndex => { 9911 acc.push(`${key}[${paramIndex}]=${params[key][paramIndex]}`); 9912 }, ''); 9913 } 9914 if (!Type.isObject(params[key]) && !Type.isArray(params[key])) { 9915 acc.push(`${key}=${params[key]}`); 9916 } 9917 return acc; 9918 }, []).join('&'); 9919 if (queryString.length > 0) { 9920 return `?${queryString}`; 9921 } 9922 return queryString; 9923 } 9924 9925 function prepareParamValue(value) { 9926 if (Type.isArray(value)) { 9927 return value.map(item => String(item)); 9928 } 9929 if (Type.isPlainObject(value)) { 9930 return { 9931 ...value 9932 }; 9933 } 9934 return String(value); 9935 } 9936 9937 const map = new WeakMap(); 9938 9939 /** 9940 * Implements interface for works with URI 9941 * @memberOf BX 9942 */ 9943 let Uri = /*#__PURE__*/function () { 9944 babelHelpers.createClass(Uri, null, [{ 9945 key: "addParam", 9946 value: function addParam(url, params = {}) { 9947 return new Uri(url).setQueryParams(params).toString(); 9948 } 9949 }, { 9950 key: "removeParam", 9951 value: function removeParam(url, params) { 9952 const removableParams = Type.isArray(params) ? params : [params]; 9953 return new Uri(url).removeQueryParam(...removableParams).toString(); 9954 } 9955 }]); 9956 function Uri(url = '') { 9957 babelHelpers.classCallCheck(this, Uri); 9958 map.set(this, parseUrl(url)); 9959 } 9960 9961 /** 9962 * Gets schema 9963 * @return {?string} 9964 */ 9965 babelHelpers.createClass(Uri, [{ 9966 key: "getSchema", 9967 value: function getSchema() { 9968 return map.get(this).schema; 9969 } 9970 /** 9971 * Sets schema 9972 * @param {string} schema 9973 * @return {Uri} 9974 */ 9975 }, { 9976 key: "setSchema", 9977 value: function setSchema(schema) { 9978 map.get(this).schema = String(schema); 9979 return this; 9980 } 9981 /** 9982 * Gets host 9983 * @return {?string} 9984 */ 9985 }, { 9986 key: "getHost", 9987 value: function getHost() { 9988 return map.get(this).host; 9989 } 9990 /** 9991 * Sets host 9992 * @param {string} host 9993 * @return {Uri} 9994 */ 9995 }, { 9996 key: "setHost", 9997 value: function setHost(host) { 9998 map.get(this).host = String(host); 9999 return this; 10000 } 10001 /** 10002 * Gets port 10003 * @return {?string} 10004 */ 10005 }, { 10006 key: "getPort", 10007 value: function getPort() { 10008 return map.get(this).port; 10009 } 10010 /** 10011 * Sets port 10012 * @param {String | Number} port 10013 * @return {Uri} 10014 */ 10015 }, { 10016 key: "setPort", 10017 value: function setPort(port) { 10018 map.get(this).port = String(port); 10019 return this; 10020 } 10021 /** 10022 * Gets path 10023 * @return {?string} 10024 */ 10025 }, { 10026 key: "getPath", 10027 value: function getPath() { 10028 return map.get(this).path; 10029 } 10030 /** 10031 * Sets path 10032 * @param {string} path 10033 * @return {Uri} 10034 */ 10035 }, { 10036 key: "setPath", 10037 value: function setPath(path) { 10038 if (!/^\//.test(path)) {
10039 map.get(this).path = `/${String(path)}`; 10040 return this; 10041 } 10042 map.get(this).path = String(path); 10043 return this; 10044 } 10045 /** 10046 * Gets query 10047 * @return {?string} 10048 */ 10049 }, { 10050 key: "getQuery", 10051 value: function getQuery() { 10052 return buildQueryString(map.get(this).queryParams); 10053 } 10054 /** 10055 * Gets query param value by name 10056 * @param {string} key 10057 * @return {?string} 10058 */ 10059 }, { 10060 key: "getQueryParam", 10061 value: function getQueryParam(key) { 10062 const params = this.getQueryParams(); 10063 if (Object.hasOwn(params, key)) { 10064 return params[key]; 10065 } 10066 return null; 10067 } 10068 /** 10069 * Sets query param 10070 * @param {string} key 10071 * @param [value] 10072 * @return {Uri} 10073 */ 10074 }, { 10075 key: "setQueryParam", 10076 value: function setQueryParam(key, value = '') { 10077 map.get(this).queryParams[key] = prepareParamValue(value); 10078 return this; 10079 } 10080 /** 10081 * Gets query params 10082 * @return {Object<string, any>} 10083 */ 10084 }, { 10085 key: "getQueryParams", 10086 value: function getQueryParams() { 10087 return { 10088 ...map.get(this).queryParams 10089 }; 10090 } 10091 /** 10092 * Sets query params 10093 * @param {Object<string, any>} params 10094 * @return {Uri} 10095 */ 10096 }, { 10097 key: "setQueryParams", 10098 value: function setQueryParams(params = {}) { 10099 const currentParams = this.getQueryParams(); 10100 const newParams = { 10101 ...currentParams, 10102 ...params 10103 }; 10104 Object.keys(newParams).forEach(key => { 10105 newParams[key] = prepareParamValue(newParams[key]); 10106 }); 10107 map.get(this).queryParams = newParams; 10108 return this; 10109 } 10110 /** 10111 * Removes query params by name 10112 * @param keys 10113 * @return {Uri} 10114 */ 10115 }, { 10116 key: "removeQueryParam", 10117 value: function removeQueryParam(...keys) { 10118 const currentParams = { 10119 ...map.get(this).queryParams 10120 }; 10121 keys.forEach(key => { 10122 if (Object.hasOwn(currentParams, key)) { 10123 delete currentParams[key]; 10124 } 10125 }); 10126 map.get(this).queryParams = currentParams; 10127 return this; 10128 } 10129 /** 10130 * Gets fragment 10131 * @return {?string} 10132 */ 10133 }, { 10134 key: "getFragment", 10135 value: function getFragment() { 10136 return map.get(this).hash; 10137 } 10138 /** 10139 * Sets fragment 10140 * @param {string} hash 10141 * @return {Uri} 10142 */ 10143 }, { 10144 key: "setFragment", 10145 value: function setFragment(hash) { 10146 map.get(this).hash = String(hash); 10147 return this; 10148 } 10149 /** 10150 * Serializes URI 10151 * @return {Object} 10152 */ 10153 }, { 10154 key: "serialize", 10155 value: function serialize() { 10156 const serialized = { 10157 ...map.get(this) 10158 }; 10159 serialized.href = this.toString(); 10160 return serialized; 10161 } 10162 /** 10163 * Gets URI string 10164 * @return {string} 10165 */ 10166 }, { 10167 key: "toString", 10168 value: function toString() { 10169 const data = { 10170 ...map.get(this) 10171 }; 10172 let protocol = data.schema ? `${data.schema}://` : ''; 10173 if (data.useShort) { 10174 protocol = '//'; 10175 } 10176 const port = (() => { 10177 if (Type.isString(data.port) && !['', '80'].includes(data.port)) { 10178 return `:${data.port}`; 10179 } 10180 return ''; 10181 })(); 10182 const host = this.getHost(); 10183 const path = this.getPath(); 10184 const query = buildQueryString(data.queryParams); 10185 const hash = data.hash ? `#${data.hash}` : ''; 10186 return `${host ? protocol : ''}${host}${host ? port : ''}${path}${query}${hash}`; 10187 } 10188 }]); 10189 return Uri; 10190 }(); 10191 10192 /** 10193 * @memberOf BX 10194 */ 10195 let Validation = /*#__PURE__*/function () { 10196 function Validation() { 10197 babelHelpers.classCallCheck(this, Validation); 10198 } 10199 babelHelpers.createClass(Validation, null, [{ 10200 key: "isEmail", 10201 /** 10202 * Checks that value is valid email 10203 * @param value 10204 * @return {boolean} 10205 */ 10206 value: function isEmail(value) { 10207 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])?)*$/; 10208 return exp.test(String(value).toLowerCase()); 10209 } 10210 }]); 10211 return Validation; 10212 }(); 10213 10214 let BaseCache = /*#__PURE__*/function () { 10215 function BaseCache() { 10216 babelHelpers.classCallCheck(this, BaseCache); 10217 babelHelpers.defineProperty(this, "storage", new Map()); 10218 } 10219 babelHelpers.createClass(BaseCache, [{ 10220 key: "get", 10221 /** 10222 * Gets cached value or default value 10223 */ 10224 value: function get(key, defaultValue) { 10225 if (!this.storage.has(key)) { 10226 if (Type.isFunction(defaultValue)) { 10227 return defaultValue(); 10228 } 10229 if (!Type.isUndefined(defaultValue)) { 10230 return defaultValue; 10231 } 10232 } 10233 return this.storage.get(key); 10234 } 10235 /**
10236 * Sets cache entry 10237 */ 10238 }, { 10239 key: "set", 10240 value: function set(key, value) { 10241 this.storage.set(key, value); 10242 } 10243 /** 10244 * Deletes cache entry 10245 */ 10246 }, { 10247 key: "delete", 10248 value: function _delete(key) { 10249 this.storage.delete(key); 10250 } 10251 /** 10252 * Checks that storage contains entry with specified key 10253 */ 10254 }, { 10255 key: "has", 10256 value: function has(key) { 10257 return this.storage.has(key); 10258 } 10259 /** 10260 * Gets cached value if exists, 10261 */ 10262 }, { 10263 key: "remember", 10264 value: function remember(key, defaultValue) { 10265 if (!this.storage.has(key)) { 10266 if (Type.isFunction(defaultValue)) { 10267 this.storage.set(key, defaultValue()); 10268 } else if (!Type.isUndefined(defaultValue)) { 10269 this.storage.set(key, defaultValue); 10270 } 10271 } 10272 return this.storage.get(key); 10273 } 10274 /** 10275 * Gets storage size 10276 */ 10277 }, { 10278 key: "size", 10279 value: function size() { 10280 return this.storage.size; 10281 } 10282 /** 10283 * Gets storage keys 10284 */ 10285 }, { 10286 key: "keys", 10287 value: function keys() { 10288 return [...this.storage.keys()]; 10289 } 10290 /** 10291 * Gets storage values 10292 */ 10293 }, { 10294 key: "values", 10295 value: function values() { 10296 return [...this.storage.values()]; 10297 } 10298 }]); 10299 return BaseCache; 10300 }(); 10301 10302 let MemoryCache = /*#__PURE__*/function (_BaseCache) { 10303 babelHelpers.inherits(MemoryCache, _BaseCache); 10304 function MemoryCache(...args) { 10305 var _this; 10306 babelHelpers.classCallCheck(this, MemoryCache); 10307 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(MemoryCache).call(this, ...args)); 10308 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new Map()); 10309 return _this; 10310 } 10311 return MemoryCache; 10312 }(BaseCache); 10313 10314 let LsStorage = /*#__PURE__*/function () { 10315 function LsStorage() { 10316 babelHelpers.classCallCheck(this, LsStorage); 10317 babelHelpers.defineProperty(this, "stackKey", 'BX.Cache.Storage.LsStorage.stack'); 10318 babelHelpers.defineProperty(this, "stack", null); 10319 } 10320 babelHelpers.createClass(LsStorage, [{ 10321 key: "getStack", 10322 /** 10323 * @private 10324 */ 10325 value: function getStack() { 10326 if (Type.isPlainObject(this.stack)) { 10327 return this.stack; 10328 } 10329 const stack = localStorage.getItem(this.stackKey); 10330 if (Type.isString(stack) && stack !== '') { 10331 const parsedStack = JSON.parse(stack); 10332 if (Type.isPlainObject(parsedStack)) { 10333 this.stack = parsedStack; 10334 return this.stack; 10335 } 10336 } 10337 this.stack = {}; 10338 return this.stack; 10339 } 10340 /** 10341 * @private 10342 */ 10343 }, { 10344 key: "saveStack", 10345 value: function saveStack() { 10346 if (Type.isPlainObject(this.stack)) { 10347 const preparedStack = JSON.stringify(this.stack); 10348 localStorage.setItem(this.stackKey, preparedStack); 10349 } 10350 } 10351 }, { 10352 key: "get", 10353 value: function get(key) { 10354 const stack = this.getStack(); 10355 return stack[key]; 10356 } 10357 }, { 10358 key: "set", 10359 value: function set(key, value) { 10360 const stack = this.getStack(); 10361 stack[key] = value; 10362 this.saveStack(); 10363 } 10364 }, { 10365 key: "delete", 10366 value: function _delete(key) { 10367 const stack = this.getStack(); 10368 if (key in stack) { 10369 delete stack[key]; 10370 } 10371 } 10372 }, { 10373 key: "has", 10374 value: function has(key) { 10375 const stack = this.getStack(); 10376 return key in stack; 10377 } 10378 }, { 10379 key: "keys", 10380 value: function keys() { 10381 const stack = this.getStack(); 10382 return Object.keys(stack); 10383 } 10384 }, { 10385 key: "values", 10386 value: function values() { 10387 const stack = this.getStack(); 10388 return Object.values(stack); 10389 } 10390 }, { 10391 key: "size", 10392 get: function () { 10393 const stack = this.getStack(); 10394 return Object.keys(stack).length; 10395 } 10396 }]); 10397 return LsStorage; 10398 }(); 10399 10400 let LocalStorageCache = /*#__PURE__*/function (_BaseCache) { 10401 babelHelpers.inherits(LocalStorageCache, _BaseCache); 10402 function LocalStorageCache(...args) { 10403 var _this; 10404 babelHelpers.classCallCheck(this, LocalStorageCache); 10405 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(LocalStorageCache).call(this, ...args)); 10406 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new LsStorage()); 10407 return _this; 10408 } 10409 return LocalStorageCache; 10410 }(BaseCache); 10411 10412 /** 10413 * @memberOf BX 10414 */ 10415 let Cache = function Cache() { 10416 babelHelpers.classCallCheck(this, Cache); 10417 }; 10418 babelHelpers.defineProperty(Cache, "MemoryCache", MemoryCache); 10419 babelHelpers.defineProperty(Cache, "LocalStorageCache", LocalStorageCache); 10420 10421 function convertPath(path) { 10422 if (Type.isStringFilled(path)) { 10423 return path.split('.').reduce((acc, item) => { 10424 item.split(/\[['"]?(.+?)['"]?\]/g).forEach(key => { 10425 if (Type.isStringFilled(key)) { 10426 acc.push(key); 10427 } 10428 }); 10429 return acc; 10430 }, []); 10431 } 10432 return []; 10433 } 10434 10435 let SettingsCollection = /*#__PURE__*/function () { 10436 function SettingsCollection(options = {}) { 10437 babelHelpers.classCallCheck(this, SettingsCollection); 10438 if (Type.isPlainObject(options)) { 10439 Object.assign(this, options); 10440 } 10441 } 10442 babelHelpers.createClass(SettingsCollection, [{ 10443 key: "get", 10444 value: function get(path, defaultValue = null) { 10445 const convertedPath = convertPath(path); 10446 return convertedPath.reduce((acc, key) => { 10447 if (!Type.isNil(acc) && acc !== defaultValue) { 10448 if (!Type.isUndefined(acc[key])) { 10449 return acc[key]; 10450 } 10451 return defaultValue; 10452 } 10453 return acc; 10454 }, this); 10455 } 10456 }]); 10457 return SettingsCollection; 10458 }(); 10459 10460 function deepFreeze(target) { 10461 if (Type.isObject(target)) { 10462 Object.values(target).forEach(value => { 10463 deepFreeze(value); 10464 }); 10465 return Object.freeze(target); 10466 } 10467 return target; 10468 } 10469 10470 const settingsStorage = new Map(); 10471 let Extension$1 = /*#__PURE__*/function () { 10472 function Extension() { 10473 babelHelpers.classCallCheck(this, Extension); 10474 } 10475 babelHelpers.createClass(Extension, null, [{ 10476 key: "getSettings", 10477 value: function getSettings(extensionName) { 10478 if (Type.isStringFilled(extensionName)) { 10479 if (settingsStorage.has(extensionName)) { 10480 return settingsStorage.get(extensionName); 10481 } 10482 const settingsScriptNode = document.querySelector(`script[data-extension="${extensionName}"]`); 10483 if (Type.isDomNode(settingsScriptNode)) { 10484 const decodedSettings = (() => { 10485 try { 10486 return new SettingsCollection(JSON.parse(settingsScriptNode.innerHTML)); 10487 } catch (error) { 10488 return new SettingsCollection(); 10489 } 10490 })(); 10491 const frozenSettings = deepFreeze(decodedSettings); 10492 settingsStorage.set(extensionName, frozenSettings); 10493 return frozenSettings; 10494 } 10495 } 10496 return deepFreeze(new SettingsCollection()); 10497 } 10498 }]); 10499 return Extension; 10500 }(); 10501 10502 let _Symbol$iterator; 10503 function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); } 10504 function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 10505 function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 10506 var _searchIndexToInsert = /*#__PURE__*/new WeakSet(); 10507 _Symbol$iterator = Symbol.iterator; 10508 let OrderedArray = /*#__PURE__*/function () { 10509 function OrderedArray(comparator = null) { 10510 babelHelpers.classCallCheck(this, OrderedArray); 10511 _classPrivateMethodInitSpec(this, _searchIndexToInsert); 10512 babelHelpers.defineProperty(this, "comparator", null); 10513 babelHelpers.defineProperty(this, "items", []); 10514 this.comparator = Type.isFunction(comparator) ? comparator : null; 10515 } 10516 babelHelpers.createClass(OrderedArray, [{ 10517 key: "add", 10518 value: function add(item) { 10519 let index = -1; 10520 if (this.comparator) { 10521 index = _classPrivateMethodGet(this, _searchIndexToInsert, _searchIndexToInsert2).call(this, item); 10522 this.items.splice(index, 0, item); 10523 } else { 10524 this.items.push(item); 10525 } 10526 return index; 10527 } 10528 }, { 10529 key: "has", 10530 value: function has(item) { 10531 return this.items.includes(item); 10532 } 10533 }, { 10534 key: "getIndex", 10535 value: function getIndex(item) { 10536 return this.items.indexOf(item); 10537 } 10538 }, { 10539 key: "getByIndex", 10540 value: function getByIndex(index) { 10541 if (Type.isNumber(index) && index >= 0) { 10542 const item = this.items[index]; 10543 return Type.isUndefined(item) ? null : item; 10544 } 10545 return null; 10546 } 10547 }, { 10548 key: "getFirst", 10549 value: function getFirst() { 10550 const first = this.items[0]; 10551 return Type.isUndefined(first) ? null : first; 10552 } 10553 }, { 10554 key: "getLast", 10555 value: function getLast() { 10556 const last = this.items[this.count() - 1]; 10557 return Type.isUndefined(last) ? null : last; 10558 } 10559 }, { 10560 key: "count", 10561 value: function count() { 10562 return this.items.length; 10563 } 10564 }, { 10565 key: "delete", 10566 value: function _delete(item) { 10567 const index = this.getIndex(item); 10568 if (index !== -1) { 10569 this.items.splice(index, 1); 10570 return true; 10571 } 10572 return false;
10573 } 10574 }, { 10575 key: "clear", 10576 value: function clear() { 10577 this.items = []; 10578 } 10579 }, { 10580 key: _Symbol$iterator, 10581 value: function () { 10582 return this.items[Symbol.iterator](); 10583 } 10584 }, { 10585 key: "forEach", 10586 value: function forEach(callbackfn, thisArg) { 10587 return this.items.forEach(callbackfn, thisArg); 10588 } 10589 }, { 10590 key: "getAll", 10591 value: function getAll() { 10592 return this.items; 10593 } 10594 }, { 10595 key: "getComparator", 10596 value: function getComparator() { 10597 return this.comparator; 10598 } 10599 }, { 10600 key: "sort", 10601 value: function sort() { 10602 const comparator = this.getComparator(); 10603 if (comparator === null) { 10604 return; 10605 } 10606 10607 /* 10608 Simple implementation 10609 this.items.sort((item1, item2) => { 10610 return comparator(item1, item2); 10611 }); 10612 */ 10613 10614 // For stable sorting https://v8.dev/features/stable-sort 10615 const length = this.items.length; 10616 const indexes = new Array(length); 10617 for (let i = 0; i < length; i++) { 10618 indexes[i] = i; 10619 } 10620 10621 // If the comparator returns zero, use the original indexes 10622 indexes.sort((index1, index2) => { 10623 return comparator(this.items[index1], this.items[index2]) || index1 - index2; 10624 }); 10625 for (let i = 0; i < length; i++) { 10626 indexes[i] = this.items[indexes[i]]; 10627 } 10628 for (let i = 0; i < length; i++) { 10629 this.items[i] = indexes[i]; 10630 } 10631 } 10632 }]); 10633 return OrderedArray; 10634 }(); 10635 function _searchIndexToInsert2(value) { 10636 let low = 0; 10637 let high = this.items.length; 10638 while (low < high) { 10639 const mid = Math.floor((low + high) / 2); 10640 if (this.comparator(this.items[mid], value) >= 0) { 10641 high = mid; 10642 } else { 10643 low = mid + 1; 10644 } 10645 } 10646 return low; 10647 } 10648 10649 let ZIndexComponent = /*#__PURE__*/function (_EventEmitter) { 10650 babelHelpers.inherits(ZIndexComponent, _EventEmitter); 10651 function ZIndexComponent(element, componentOptions = {}) { 10652 var _this; 10653 babelHelpers.classCallCheck(this, ZIndexComponent); 10654 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(ZIndexComponent).call(this)); 10655 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "sort", 0); 10656 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "alwaysOnTop", false); 10657 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "zIndex", 0); 10658 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "element", null); 10659 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlay", null); 10660 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlayGap", -5); 10661 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "stack", null); 10662 _this.setEventNamespace('BX.Main.ZIndexManager.Component'); 10663 if (!Type.isElementNode(element)) { 10664 throw new Error('ZIndexManager.Component: The argument \'element\' must be a DOM element.'); 10665 } 10666 _this.element = element; 10667 const options = Type.isPlainObject(componentOptions) ? componentOptions : {}; 10668 _this.setAlwaysOnTop(options.alwaysOnTop); 10669 _this.setOverlay(options.overlay); 10670 _this.setOverlayGap(options.overlayGap); 10671 _this.subscribeFromOptions(options.events); 10672 return _this; 10673 } 10674 babelHelpers.createClass(ZIndexComponent, [{ 10675 key: "getSort", 10676 value: function getSort() { 10677 return this.sort; 10678 } 10679 /** 10680 * @internal 10681 * @param sort 10682 */ 10683 }, { 10684 key: "setSort", 10685 value: function setSort(sort) { 10686 if (Type.isNumber(sort)) { 10687 this.sort = sort; 10688 } 10689 } 10690 /** 10691 * @internal 10692 * @param stack 10693 */ 10694 }, { 10695 key: "setStack", 10696 value: function setStack(stack) { 10697 this.stack = stack; 10698 } 10699 }, { 10700 key: "getStack", 10701 value: function getStack() { 10702 return this.stack; 10703 } 10704 }, { 10705 key: "getZIndex", 10706 value: function getZIndex() { 10707 return this.zIndex; 10708 } 10709 /** 10710 * @internal 10711 */ 10712 }, { 10713 key: "setZIndex", 10714 value: function setZIndex(zIndex) { 10715 const changed = this.getZIndex() !== zIndex; 10716 this.getElement().style.setProperty('z-index', zIndex, 'important'); 10717 this.zIndex = zIndex; 10718 if (this.getOverlay() !== null) { 10719 this.getOverlay().style.setProperty('z-index', zIndex + this.getOverlayGap(), 'important'); 10720 } 10721 if (changed) {
10722 this.emit('onZIndexChange', { 10723 component: this 10724 }); 10725 } 10726 } 10727 }, { 10728 key: "getAlwaysOnTop", 10729 value: function getAlwaysOnTop() { 10730 return this.alwaysOnTop; 10731 } 10732 }, { 10733 key: "setAlwaysOnTop", 10734 value: function setAlwaysOnTop(value) { 10735 if (Type.isNumber(value) || Type.isBoolean(value)) { 10736 this.alwaysOnTop = value; 10737 } 10738 } 10739 }, { 10740 key: "getElement", 10741 value: function getElement() { 10742 return this.element; 10743 } 10744 }, { 10745 key: "setOverlay", 10746 value: function setOverlay(overlay, gap) { 10747 if (Type.isElementNode(overlay) || overlay === null) { 10748 this.overlay = overlay; 10749 this.setOverlayGap(gap); 10750 if (this.getStack()) { 10751 this.getStack().sort(); 10752 } 10753 } 10754 } 10755 }, { 10756 key: "getOverlay", 10757 value: function getOverlay() { 10758 return this.overlay; 10759 } 10760 }, { 10761 key: "setOverlayGap", 10762 value: function setOverlayGap(gap) { 10763 if (Type.isNumber(gap)) { 10764 this.overlayGap = gap; 10765 } 10766 } 10767 }, { 10768 key: "getOverlayGap", 10769 value: function getOverlayGap() { 10770 return this.overlayGap; 10771 } 10772 }]); 10773 return ZIndexComponent; 10774 }(EventEmitter); 10775 10776 let ZIndexStack = /*#__PURE__*/function () { 10777 function ZIndexStack(container) { 10778 babelHelpers.classCallCheck(this, ZIndexStack); 10779 babelHelpers.defineProperty(this, "container", null); 10780 babelHelpers.defineProperty(this, "components", null); 10781 babelHelpers.defineProperty(this, "elements", new WeakMap()); 10782 babelHelpers.defineProperty(this, "baseIndex", 1000); 10783 babelHelpers.defineProperty(this, "baseStep", 50); 10784 babelHelpers.defineProperty(this, "sortCount", 0); 10785 if (!Type.isDomNode(container)) { 10786 throw new Error('ZIndexManager.Stack: The \'container\' argument must be a DOM element.'); 10787 } 10788 this.container = container; 10789 const comparator = (componentA, componentB) => { 10790 let result = (componentA.getAlwaysOnTop() || 0) - (componentB.getAlwaysOnTop() || 0); 10791 if (!result) { 10792 result = componentA.getSort() - componentB.getSort(); 10793 } 10794 return result; 10795 }; 10796 this.components = new OrderedArray(comparator); 10797 } 10798 babelHelpers.createClass(ZIndexStack, [{ 10799 key: "getBaseIndex", 10800 value: function getBaseIndex() { 10801 return this.baseIndex; 10802 } 10803 }, { 10804 key: "setBaseIndex", 10805 value: function setBaseIndex(index) { 10806 if (Type.isNumber(index) && index >= 0) { 10807 this.baseIndex = index; 10808 this.sort(); 10809 } 10810 } 10811 }, { 10812 key: "setBaseStep", 10813 value: function setBaseStep(step) { 10814 if (Type.isNumber(step) && step > 0) { 10815 this.baseStep = step; 10816 this.sort(); 10817 } 10818 } 10819 }, { 10820 key: "getBaseStep", 10821 value: function getBaseStep() { 10822 return this.baseStep; 10823 } 10824 }, { 10825 key: "register", 10826 value: function register(element, options = {}) { 10827 if (this.getComponent(element)) { 10828 console.warn('ZIndexManager: You cannot register the element twice.', element); 10829 return this.getComponent(element); 10830 } 10831 const component = new ZIndexComponent(element, options); 10832 component.setStack(this); 10833 component.setSort(++this.sortCount); 10834 this.elements.set(element, component); 10835 this.components.add(component); 10836 this.sort(); 10837 return component; 10838 } 10839 }, { 10840 key: "unregister", 10841 value: function unregister(element) { 10842 const component = this.elements.get(element); 10843 this.components.delete(component); 10844 this.elements.delete(element); 10845 this.sort(); 10846 } 10847 }, { 10848 key: "getComponent", 10849 value: function getComponent(element) { 10850 return this.elements.get(element) || null; 10851 } 10852 }, { 10853 key: "getComponents", 10854 value: function getComponents() { 10855 return this.components.getAll(); 10856 } 10857 }, { 10858 key: "getMaxZIndex", 10859 value: function getMaxZIndex() { 10860 const last = this.components.getLast(); 10861 return last ? last.getZIndex() : this.baseIndex; 10862 } 10863 }, { 10864 key: "sort", 10865 value: function sort() { 10866 this.components.sort(); 10867 let zIndex = this.baseIndex;
10868 this.components.forEach(component => { 10869 component.setZIndex(zIndex); 10870 zIndex += this.baseStep; 10871 }); 10872 } 10873 }, { 10874 key: "bringToFront", 10875 value: function bringToFront(element) { 10876 const component = this.getComponent(element); 10877 if (!component) { 10878 console.error('ZIndexManager: element was not found in the stack.', element); 10879 return null; 10880 } 10881 component.setSort(++this.sortCount); 10882 this.sort(); 10883 return component; 10884 } 10885 }]); 10886 return ZIndexStack; 10887 }(); 10888 10889 function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; } 10890 function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } } 10891 /** 10892 * @memberof BX 10893 */ 10894 let ZIndexManager = /*#__PURE__*/function () { 10895 function ZIndexManager() { 10896 babelHelpers.classCallCheck(this, ZIndexManager); 10897 } 10898 babelHelpers.createClass(ZIndexManager, null, [{ 10899 key: "register", 10900 value: function register(element, options = {}) { 10901 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10902 if (!parentNode) { 10903 return null; 10904 } 10905 const stack = this.getOrAddStack(parentNode); 10906 return stack.register(element, options); 10907 } 10908 }, { 10909 key: "unregister", 10910 value: function unregister(element) { 10911 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10912 const stack = this.getStack(parentNode); 10913 if (stack) { 10914 stack.unregister(element); 10915 } 10916 } 10917 }, { 10918 key: "addStack", 10919 value: function addStack(container) { 10920 const stack = new ZIndexStack(container); 10921 this.stacks.set(container, stack); 10922 return stack; 10923 } 10924 }, { 10925 key: "getStack", 10926 value: function getStack(container) { 10927 return this.stacks.get(container) || null; 10928 } 10929 }, { 10930 key: "getOrAddStack", 10931 value: function getOrAddStack(container) { 10932 return this.getStack(container) || this.addStack(container); 10933 } 10934 }, { 10935 key: "getComponent", 10936 value: function getComponent(element) { 10937 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element, true); 10938 if (!parentNode) { 10939 return null; 10940 } 10941 const stack = this.getStack(parentNode); 10942 return stack ? stack.getComponent(element) : null; 10943 } 10944 }, { 10945 key: "bringToFront", 10946 value: function bringToFront(element) { 10947 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10948 const stack = this.getStack(parentNode); 10949 if (stack) { 10950 return stack.bringToFront(element); 10951 } 10952 return null; 10953 } 10954 }]); 10955 return ZIndexManager; 10956 }(); 10957 function _getParentNode(element, suppressWarnings = false) { 10958 if (!Type.isElementNode(element)) { 10959 if (!suppressWarnings) { 10960 console.error('ZIndexManager: The argument \'element\' must be a DOM element.', element); 10961 } 10962 return null; 10963 } else if (!Type.isElementNode(element.parentNode)) { 10964 if (!suppressWarnings) { 10965 console.error('ZIndexManager: The \'element\' doesn\'t have a parent node.', element); 10966 } 10967 return null; 10968 } 10969 return element.parentNode; 10970 } 10971 babelHelpers.defineProperty(ZIndexManager, "stacks", new WeakMap()); 10972 10973 var collections = { 10974 OrderedArray 10975 }; 10976 10977 function getElement(element) { 10978 if (Type.isString(element)) { 10979 return document.getElementById(element); 10980 } 10981 return element; 10982 } 10983 10984 function getWindow(element) { 10985 if (Type.isElementNode(element)) { 10986 return element.ownerDocument.parentWindow || element.ownerDocument.defaultView || window; 10987 } 10988 if (Type.isDomNode(element)) { 10989 return element.parentWindow || element.defaultView || window; 10990 } 10991 return window; 10992 } 10993 10994 /* eslint-disable prefer-rest-params */ 10995 10996 // BX.* 10997 const { 10998 getClass, 10999 namespace 11000 } = Reflection; 11001 const message$1 = message; 11002 11003 /** 11004 * @memberOf BX 11005 */ 11006 const { 11007 replace, 11008 remove, 11009 clean, 11010 insertBefore, 11011 insertAfter, 11012 append, 11013 prepend, 11014 style, 11015 adjust, 11016 create, 11017 isShown 11018 } = Dom; 11019 const addClass = function addClass() { 11020 Dom.addClass(...Runtime.merge([], Array.from(arguments), [getElement(arguments[0])])); 11021 }; 11022 const removeClass = function removeClass() { 11023 Dom.removeClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11024 }; 11025 const hasClass = function hasClass() { 11026 return Dom.hasClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11027 }; 11028 const toggleClass = function toggleClass() { 11029 Dom.toggleClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11030 }; 11031 const cleanNode = (element, removeElement = false) => { 11032 const currentElement = getElement(element); 11033 if (Type.isDomNode(currentElement)) { 11034 Dom.clean(currentElement); 11035 if (removeElement) { 11036 Dom.remove(currentElement); 11037 return currentElement; 11038 } 11039 } 11040 return currentElement; 11041 }; 11042 const getCookie = Http.Cookie.get;
11043 const setCookie = (name, value, options = {}) => { 11044 const attributes = { 11045 ...options 11046 }; 11047 if (Type.isNumber(attributes.expires)) { 11048 attributes.expires /= 3600 * 24; 11049 } 11050 Http.Cookie.set(name, value, attributes); 11051 }; 11052 const { 11053 bind: bind$1, 11054 unbind: unbind$1, 11055 unbindAll: unbindAll$1, 11056 bindOnce: bindOnce$1, 11057 ready: ready$1 11058 } = Event; 11059 const { 11060 debugState: debugEnableFlag, 11061 isDebugEnabled: debugStatus, 11062 default: debug$1 11063 } = debugNs; 11064 const debugEnable = value => { 11065 if (value) { 11066 enableDebug(); 11067 } else { 11068 disableDebug(); 11069 } 11070 }; 11071 const { 11072 clone: clone$1, 11073 loadExtension: loadExt, 11074 debounce, 11075 throttle, 11076 html 11077 } = Runtime; 11078 11079 // BX.type 11080 const type = { 11081 ...Object.getOwnPropertyNames(Type).filter(key => !['name', 'length', 'prototype', 'caller', 'arguments'].includes(key)).reduce((acc, key) => { 11082 acc[key] = Type[key]; 11083 return acc; 11084 }, {}), 11085 isNotEmptyString: value => Type.isString(value) && value !== '', 11086 isNotEmptyObject: value => Type.isObjectLike(value) && Object.keys(value).length > 0, 11087 isMapKey: Type.isObject, 11088 stringToInt: value => { 11089 const parsed = parseInt(value); 11090 return !Number.isNaN(parsed) ? parsed : 0; 11091 } 11092 }; 11093 11094 // BX.browser 11095 const browser = { 11096 IsOpera: Browser.isOpera, 11097 IsIE: Browser.isIE, 11098 IsIE6: Browser.isIE6, 11099 IsIE7: Browser.isIE7, 11100 IsIE8: Browser.isIE8, 11101 IsIE9: Browser.isIE9, 11102 IsIE10: Browser.isIE10, 11103 IsIE11: Browser.isIE11, 11104 IsSafari: Browser.isSafari, 11105 IsFirefox: Browser.isFirefox, 11106 IsChrome: Browser.isChrome, 11107 DetectIeVersion: Browser.detectIEVersion, 11108 IsMac: Browser.isMac, 11109 IsAndroid: Browser.isAndroid, 11110 isIPad: Browser.isIPad, 11111 isIPhone: Browser.isIPhone, 11112 IsIOS: Browser.isIOS, 11113 IsMobile: Browser.isMobile, 11114 isRetina: Browser.isRetina, 11115 IsDoctype: Browser.isDoctype, 11116 SupportLocalStorage: Browser.isLocalStorageSupported, 11117 addGlobalClass: Browser.addGlobalClass, 11118 DetectAndroidVersion: Browser.detectAndroidVersion, 11119 isPropertySupported: Browser.isPropertySupported, 11120 addGlobalFeatures: Browser.addGlobalFeatures 11121 }; 11122 11123 // eslint-disable-next-line 11124 const ajax = window.BX ? window.BX.ajax : () => {}; 11125 function GetWindowScrollSize(doc = document) { 11126 return { 11127 scrollWidth: doc.documentElement.scrollWidth, 11128 scrollHeight: doc.documentElement.scrollHeight 11129 }; 11130 } 11131 function GetWindowScrollPos(doc = document) { 11132 const win = getWindow(doc); 11133 return { 11134 scrollLeft: win.pageXOffset, 11135 scrollTop: win.pageYOffset 11136 }; 11137 } 11138 function GetWindowInnerSize(doc = document) { 11139 const win = getWindow(doc); 11140 return { 11141 innerWidth: win.innerWidth, 11142 innerHeight: win.innerHeight 11143 }; 11144 } 11145 function GetWindowSize(doc = document) { 11146 return { 11147 ...GetWindowInnerSize(doc), 11148 ...GetWindowScrollPos(doc), 11149 ...GetWindowScrollSize(doc) 11150 }; 11151 } 11152 function GetContext(node) { 11153 return getWindow(node); 11154 } 11155 function pos(element, relative = false) { 11156 if (!element) { 11157 return new DOMRect().toJSON(); 11158 } 11159 if (element.ownerDocument === document && !relative) { 11160 const clientRect = element.getBoundingClientRect(); 11161 const root = document.documentElement; 11162 const { 11163 body 11164 } = document; 11165 return { 11166 top: Math.round(clientRect.top + (root.scrollTop || body.scrollTop)), 11167 left: Math.round(clientRect.left + (root.scrollLeft || body.scrollLeft)), 11168 width: Math.round(clientRect.right - clientRect.left), 11169 height: Math.round(clientRect.bottom - clientRect.top), 11170 right: Math.round(clientRect.right + (root.scrollLeft || body.scrollLeft)), 11171 bottom: Math.round(clientRect.bottom + (root.scrollTop || body.scrollTop)) 11172 }; 11173 } 11174 let x = 0; 11175 let y = 0; 11176 const w = element.offsetWidth; 11177 const h = element.offsetHeight; 11178 let first = true; 11179 11180 // eslint-disable-next-line no-param-reassign 11181 for (; element != null; element = element.offsetParent) { 11182 if (!first && relative && BX.is_relative(element)) { 11183 break; 11184 } 11185 x += element.offsetLeft; 11186 y += element.offsetTop; 11187 if (first) { 11188 first = false; 11189 // eslint-disable-next-line no-continue 11190 continue; 11191 } 11192 x += Text.toNumber(Dom.style(element, 'border-left-width')); 11193 y += Text.toNumber(Dom.style(element, 'border-top-width')); 11194 } 11195 return new DOMRect(x, y, w, h).toJSON(); 11196 } 11197 function addCustomEvent(eventObject, eventName, eventHandler) { 11198 if (Type.isString(eventObject)) { 11199 eventHandler = eventName; 11200 eventName = eventObject; 11201 eventObject = EventEmitter.GLOBAL_TARGET;
11202 } 11203 if (eventObject === window) { 11204 eventObject = EventEmitter.GLOBAL_TARGET; 11205 } 11206 if (!Type.isObject(eventObject)) { 11207 console.error('The "eventObject" argument must be an object. Received type ' + typeof eventObject + '.'); 11208 return; 11209 } 11210 if (!Type.isStringFilled(eventName)) { 11211 console.error('The "eventName" argument must be a string.'); 11212 return; 11213 } 11214 if (!Type.isFunction(eventHandler)) { 11215 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11216 return; 11217 } 11218 eventName = eventName.toLowerCase(); 11219 EventEmitter.subscribe(eventObject, eventName, eventHandler, { 11220 compatMode: true, 11221 useGlobalNaming: true 11222 }); 11223 } 11224 function onCustomEvent(eventObject, eventName, eventParams, secureParams) { 11225 if (Type.isString(eventObject)) { 11226 secureParams = eventParams; 11227 eventParams = eventName; 11228 eventName = eventObject; 11229 eventObject = EventEmitter.GLOBAL_TARGET; 11230 } 11231 if (!Type.isObject(eventObject) || eventObject === window) { 11232 eventObject = EventEmitter.GLOBAL_TARGET;
11233 } 11234 if (!eventParams) { 11235 eventParams = []; 11236 } 11237 eventName = eventName.toLowerCase(); 11238 const event = new BaseEvent(); 11239 event.setData(eventParams); 11240 event.setCompatData(eventParams); 11241 EventEmitter.emit(eventObject, eventName, event, { 11242 cloneData: secureParams === true, 11243 useGlobalNaming: true 11244 }); 11245 } 11246 function removeCustomEvent(eventObject, eventName, eventHandler) { 11247 if (Type.isString(eventObject)) { 11248 eventHandler = eventName; 11249 eventName = eventObject; 11250 eventObject = EventEmitter.GLOBAL_TARGET; 11251 } 11252 if (!Type.isFunction(eventHandler)) { 11253 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11254 return; 11255 } 11256 if (eventObject === window) { 11257 eventObject = EventEmitter.GLOBAL_TARGET; 11258 } 11259 eventName = eventName.toLowerCase(); 11260 EventEmitter.unsubscribe(eventObject, eventName, eventHandler, { 11261 useGlobalNaming: true 11262 }); 11263 } 11264 function removeAllCustomEvents(eventObject, eventName) { 11265 if (Type.isString(eventObject)) { 11266 eventName = eventObject; 11267 eventObject = EventEmitter.GLOBAL_TARGET;
11268 } 11269 if (eventObject === window) { 11270 eventObject = EventEmitter.GLOBAL_TARGET; 11271 } 11272 eventName = eventName.toLowerCase(); 11273 EventEmitter.unsubscribeAll(eventObject, eventName, { 11274 useGlobalNaming: true 11275 }); 11276 } 11277 11278 if (typeof global === 'object' && global.window && global.window.BX) { 11279 Object.assign(global.window.BX, exports); 11280 } 11281 11282 exports.Type = Type; 11283 exports.Reflection = Reflection; 11284 exports.Text = Text; 11285 exports.Dom = Dom; 11286 exports.Browser = Browser; 11287 exports.Event = Event; 11288 exports.Http = Http; 11289 exports.Runtime = Runtime; 11290 exports.Loc = Loc; 11291 exports.Tag = Tag; 11292 exports.Uri = Uri; 11293 exports.Validation = Validation; 11294 exports.Cache = Cache; 11295 exports.BaseError = BaseError; 11296 exports.Extension = Extension$1; 11297 exports.ZIndexManager = ZIndexManager; 11298 exports.Collections = collections; 11299 exports.getClass = getClass; 11300 exports.namespace = namespace; 11301 exports.message = message$1; 11302 exports.replace = replace; 11303 exports.remove = remove; 11304 exports.clean = clean; 11305 exports.insertBefore = insertBefore; 11306 exports.insertAfter = insertAfter; 11307 exports.append = append; 11308 exports.prepend = prepend; 11309 exports.style = style; 11310 exports.adjust = adjust; 11311 exports.create = create; 11312 exports.isShown = isShown; 11313 exports.addClass = addClass; 11314 exports.removeClass = removeClass; 11315 exports.hasClass = hasClass; 11316 exports.toggleClass = toggleClass; 11317 exports.cleanNode = cleanNode; 11318 exports.getCookie = getCookie; 11319 exports.setCookie = setCookie; 11320 exports.bind = bind$1; 11321 exports.unbind = unbind$1; 11322 exports.unbindAll = unbindAll$1; 11323 exports.bindOnce = bindOnce$1; 11324 exports.ready = ready$1; 11325 exports.debugEnableFlag = debugEnableFlag; 11326 exports.debugStatus = debugStatus; 11327 exports.debug = debug$1; 11328 exports.debugEnable = debugEnable; 11329 exports.clone = clone$1; 11330 exports.loadExt = loadExt; 11331 exports.debounce = debounce; 11332 exports.throttle = throttle; 11333 exports.html = html; 11334 exports.type = type; 11335 exports.browser = browser; 11336 exports.ajax = ajax; 11337 exports.GetWindowScrollSize = GetWindowScrollSize; 11338 exports.GetWindowScrollPos = GetWindowScrollPos; 11339 exports.GetWindowInnerSize = GetWindowInnerSize; 11340 exports.GetWindowSize = GetWindowSize; 11341 exports.GetContext = GetContext; 11342 exports.pos = pos; 11343 exports.addCustomEvent = addCustomEvent; 11344 exports.onCustomEvent = onCustomEvent; 11345 exports.removeCustomEvent = removeCustomEvent; 11346 exports.removeAllCustomEvents = removeAllCustomEvents; 11347 11348}((this.BX = this.BX || {}))); 11349 11350 11351 11352(function(BX) { 11353 /* list of registered proxy functions */ 11354 var proxyList = new WeakMap(); 11355 var deferList = new WeakMap(); 11356 11357 /* List of denied event handlers */ 11358 var deniedEvents = []; 11359 11360 /* list of registered custom events */ 11361 var customEvents = new WeakMap(); 11362 var customEventsCnt = 0; 11363 11364 /* list of external garbage collectors */ 11365 var garbageCollectors = []; 11366 11367 /* list of loaded CSS files */ 11368 var cssList = []; 11369 var cssInit = false; 11370 11371 /* list of loaded JS files */ 11372 var jsList = []; 11373 var jsInit = false; 11374 11375 var eventTypes = { 11376 click: 'MouseEvent', 11377 dblclick: 'MouseEvent', 11378 mousedown: 'MouseEvent', 11379 mousemove: 'MouseEvent', 11380 mouseout: 'MouseEvent', 11381 mouseover: 'MouseEvent', 11382 mouseup: 'MouseEvent', 11383 focus: 'MouseEvent', 11384 blur: 'MouseEvent' 11385 }; 11386 11387 var lastWait = []; 11388 11389 var CHECK_FORM_ELEMENTS = {tagName: /^INPUT|SELECT|TEXTAREA|BUTTON$/i}; 11390 11391 BX.MSLEFT = 1; 11392 BX.MSMIDDLE = 2; 11393 BX.MSRIGHT = 4; 11394 11395 BX.AM_PM_UPPER = 1; 11396 BX.AM_PM_LOWER = 2; 11397 BX.AM_PM_NONE = false; 11398 11399 BX.ext = function(ob) 11400 { 11401 for (var i in ob) 11402 { 11403 if(ob.hasOwnProperty(i)) 11404 { 11405 this[i] = ob[i]; 11406 } 11407 } 11408 }; 11409 11410 var r = { 11411 script: /<script([^>]*)>/ig, 11412 script_end: /<\/script>/ig, 11413 script_src: /src=["\']([^"\']+)["\']/i, 11414 script_type: /type=["\']([^"\']+)["\']/i, 11415 space: /\s+/, 11416 ltrim: /^[\s\r\n]+/g, 11417 rtrim: /[\s\r\n]+$/g, 11418 style: /<link.*?(rel="stylesheet"|type="text\/css")[^>]*>/i, 11419 style_href: /href=["\']([^"\']+)["\']/i 11420 }; 11421 11422 BX.processHTML = function(data, scriptsRunFirst) 11423 { 11424 var matchScript, matchStyle, matchSrc, matchHref, matchType, scripts = [], styles = []; 11425 var textIndexes = []; 11426 var lastIndex = r.script.lastIndex = r.script_end.lastIndex = 0; 11427 11428 while ((matchScript = r.script.exec(data)) !== null) 11429 { 11430 r.script_end.lastIndex = r.script.lastIndex; 11431 var matchScriptEnd = r.script_end.exec(data); 11432 if (matchScriptEnd === null) 11433 { 11434 break; 11435 } 11436 11437 // skip script tags of special types 11438 var skipTag = false;
11439 if ((matchType = matchScript[1].match(r.script_type)) !== null) 11440 { 11441 if( 11442 matchType[1] == 'text/html' 11443 || matchType[1] == 'text/template' 11444 || matchType[1] == 'extension/settings' 11445 ) 11446 { 11447 skipTag = true; 11448 } 11449 } 11450 11451 if(skipTag) 11452 { 11453 textIndexes.push([lastIndex, r.script_end.lastIndex - lastIndex]); 11454 } 11455 else 11456 { 11457 textIndexes.push([lastIndex, matchScript.index - lastIndex]); 11458 11459 var bRunFirst = scriptsRunFirst || (matchScript[1].indexOf('bxrunfirst') != '-1'); 11460 11461 if ((matchSrc = matchScript[1].match(r.script_src)) !== null) 11462 { 11463 scripts.push({"bRunFirst": bRunFirst, "isInternal": false, "JS": matchSrc[1]}); 11464 } 11465 else 11466 { 11467 var start = matchScript.index + matchScript[0].length; 11468 var js = data.substr(start, matchScriptEnd.index-start); 11469 11470 scripts.push({"bRunFirst": bRunFirst, "isInternal": true, "JS": js}); 11471 } 11472 } 11473 11474 lastIndex = matchScriptEnd.index + 9; 11475 r.script.lastIndex = lastIndex; 11476 } 11477 11478 textIndexes.push([lastIndex, lastIndex === 0 ? data.length : data.length - lastIndex]); 11479 var pureData = ""; 11480 for (var i = 0, length = textIndexes.length; i < length; i++) 11481 { 11482 if (BX.type.isString(data) && BX.type.isFunction(data.substr)) 11483 { 11484 pureData += data.substr(textIndexes[i][0], textIndexes[i][1]); 11485 } 11486 } 11487 11488 while ((matchStyle = pureData.match(r.style)) !== null) 11489 { 11490 if ((matchHref = matchStyle[0].match(r.style_href)) !== null && matchStyle[0].indexOf('media="') < 0) 11491 { 11492 styles.push(matchHref[1]); 11493 } 11494 11495 pureData = pureData.replace(matchStyle[0], ''); 11496 } 11497 11498 return {'HTML': pureData, 'SCRIPT': scripts, 'STYLE': styles}; 11499 }; 11500 11501 /* OO emulation utility */ 11502 BX.extend = function(child, parent) 11503 { 11504 var f = function() {}; 11505 f.prototype = parent.prototype; 11506 11507 child.prototype = new f(); 11508 child.prototype.constructor = child; 11509 11510 child.superclass = parent.prototype; 11511 child.prototype.superclass = parent.prototype; 11512 if(parent.prototype.constructor == Object.prototype.constructor) 11513 { 11514 parent.prototype.constructor = parent; 11515 } 11516 }; 11517 11518 BX.is_subclass_of = function(ob, parent_class) 11519 { 11520 if (ob instanceof parent_class) 11521 return true; 11522 11523 if (parent_class.superclass) 11524 return BX.is_subclass_of(ob, parent_class.superclass); 11525 11526 return false; 11527 }; 11528 11529 BX.clearNodeCache = function() 11530 { 11531 return false; 11532 }; 11533 11534 BX.bitrix_sessid = function() {return BX.message("bitrix_sessid"); }; 11535 11536 /** 11537 * Creates document fragment with child nodes. 11538 * 11539 * @param {Node[]} nodes 11540 * @return {DocumentFragment} 11541 */ 11542 BX.createFragment = function(nodes) 11543 { 11544 var fragment = document.createDocumentFragment(); 11545 11546 if(!BX.type.isArray(nodes)) 11547 { 11548 return fragment; 11549 } 11550 for(var i = 0; i < nodes.length; i++) 11551 { 11552 fragment.appendChild(nodes[i]); 11553 } 11554 11555 return fragment; 11556 }; 11557 11558 /** 11559 * @deprecated 11560 * @use BX.style 11561 * @param element 11562 * @param opacity 11563 */ 11564 BX.setOpacity = function(element, opacity) 11565 { 11566 var opacityValue = parseFloat(opacity); 11567 11568 if (!isNaN(opacityValue) && BX.type.isDomNode(element)) 11569 { 11570 opacityValue = opacityValue < 1 ? opacityValue : opacityValue / 100; 11571 BX.style(element, 'opacity', opacityValue); 11572 } 11573 }; 11574 11575 /** 11576 * @deprecated 11577 * @param el 11578 * @return {*} 11579 */ 11580 BX.hoverEvents = function(el) 11581 { 11582 if (el) 11583 return BX.adjust(el, {events: BX.hoverEvents()}); 11584 else 11585 return {mouseover: BX.hoverEventsHover, mouseout: BX.hoverEventsHout}; 11586 }; 11587 11588 /** 11589 * @deprecated 11590 */ 11591 BX.hoverEventsHover = function(){BX.addClass(this,'bx-hover');this.BXHOVER=true;}; 11592 /** 11593 * @deprecated 11594 */ 11595 BX.hoverEventsHout = function(){BX.removeClass(this,'bx-hover');this.BXHOVER=false;}; 11596 11597 /** 11598 * @deprecated 11599 */ 11600 BX.focusEvents = function(el) 11601 { 11602 if (el) 11603 return BX.adjust(el, {events: BX.focusEvents()}); 11604 else 11605 return {mouseover: BX.focusEventsFocus, mouseout: BX.focusEventsBlur}; 11606 }; 11607 11608 /** 11609 * @deprecated 11610 */ 11611 BX.focusEventsFocus = function(){BX.addClass(this,'bx-focus');this.BXFOCUS=true;}; 11612 /** 11613 * @deprecated 11614 */ 11615 BX.focusEventsBlur = function(){BX.removeClass(this,'bx-focus');this.BXFOCUS=false;}; 11616 11617 BX.setUnselectable = function(node) 11618 { 11619 BX.style(node, { 11620 'userSelect': 'none', 11621 'MozUserSelect': 'none', 11622 'WebkitUserSelect': 'none', 11623 'KhtmlUserSelect': 'none', 11624 }); 11625 node.setAttribute('unSelectable', 'on'); 11626 }; 11627 11628 BX.setSelectable = function(node) 11629 { 11630 BX.style(node, { 11631 'userSelect': null, 11632 'MozUserSelect': null, 11633 'WebkitUserSelect': null, 11634 'KhtmlUserSelect': null, 11635 }); 11636 node.removeAttribute('unSelectable'); 11637 }; 11638 11639 BX.styleIEPropertyName = function(name) 11640 { 11641 if (name == 'float') 11642 name = BX.browser.IsIE() ? 'styleFloat' : 'cssFloat'; 11643 else 11644 { 11645 var res = BX.browser.isPropertySupported(name); 11646 if (res) 11647 { 11648 name = res; 11649 } 11650 else 11651 {
11652 var reg = /(\-([a-z]){1})/g; 11653 if (reg.test(name)) 11654 { 11655 name = name.replace(reg, function () {return arguments[2].toUpperCase();}); 11656 } 11657 } 11658 } 11659 return name; 11660 }; 11661 11662 BX.focus = function(el) 11663 { 11664 try 11665 { 11666 el.focus(); 11667 return true; 11668 } 11669 catch (e) 11670 { 11671 return false; 11672 } 11673 }; 11674 11675 BX.firstChild = function(el) 11676 { 11677 return BX.type.isDomNode(el) ? el.firstElementChild : null; 11678 }; 11679 11680 BX.lastChild = function(el) 11681 { 11682 return BX.type.isDomNode(el) ? el.lastElementChild : null; 11683 }; 11684 11685 BX.previousSibling = function(el) 11686 { 11687 return BX.type.isDomNode(el) ? el.previousElementSibling : null; 11688 }; 11689 11690 BX.nextSibling = function(el) 11691 { 11692 return BX.type.isDomNode(el) ? el.nextElementSibling : null; 11693 }; 11694 11695 /* 11696 params: { 11697 obj : html node 11698 className : className value 11699 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 11700 } 11701 11702 Search all nodes with className 11703 */ 11704 /** 11705 * @deprecated 11706 * @use .querySelectorAll 11707 * @param obj 11708 * @param className 11709 * @param recursive 11710 * @return {*} 11711 */ 11712 BX.findChildrenByClassName = function(obj, className, recursive) 11713 { 11714 if(!obj || !obj.childNodes) return null; 11715 11716 var result = []; 11717 if (typeof(obj.getElementsByClassName) == 'undefined') 11718 { 11719 recursive = recursive !== false; 11720 result = BX.findChildren(obj, {className : className}, recursive); 11721 } 11722 else 11723 { 11724 var col = obj.getElementsByClassName(className); 11725 for (i=0,l=col.length;i<l;i++) 11726 { 11727 result[i] = col[i]; 11728 } 11729 } 11730 return result; 11731 }; 11732 11733 /* 11734 params: { 11735 obj : html node 11736 className : className value 11737 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 11738 } 11739 11740 Search first node with className 11741 */ 11742 /** 11743 * @deprecated 11744 * @use .querySelector 11745 * @param obj 11746 * @param className 11747 * @param recursive 11748 * @return {*} 11749 */ 11750 BX.findChildByClassName = function(obj, className, recursive) 11751 { 11752 if(!obj || !obj.childNodes) return null; 11753 11754 var result = null; 11755 if (typeof(obj.getElementsByClassName) == 'undefined') 11756 { 11757 recursive = recursive !== false; 11758 result = BX.findChild(obj, {className : className}, recursive); 11759 } 11760 else 11761 { 11762 var col = obj.getElementsByClassName(className); 11763 if (col && typeof(col[0]) != 'undefined') 11764 { 11765 result = col[0]; 11766 } 11767 else 11768 { 11769 result = null; 11770 } 11771 } 11772 return result; 11773 }; 11774 11775 /* 11776 params: { 11777 tagName|tag : 'tagName', 11778 className|class : 'className', 11779 attribute : {attribute : value, attribute : value} | attribute | [attribute, attribute....], 11780 property : {prop: value, prop: value} | prop | [prop, prop] 11781 } 11782 11783 all values can be RegExps or strings 11784 */ 11785 /** 11786 * @deprecated 11787 * @use .querySelectorAll 11788 * @param obj 11789 * @param params 11790 * @param recursive 11791 * @return {*|Node} 11792 */ 11793 BX.findChildren = function(obj, params, recursive) 11794 { 11795 return BX.findChild(obj, params, recursive, true); 11796 }; 11797 11798 /** 11799 * @deprecated 11800 * @use .querySelectorAll 11801 * @param obj 11802 * @param params 11803 * @param recursive 11804 * @param get_all 11805 * @return {*} 11806 */ 11807 BX.findChild = function(obj, params, recursive, get_all) 11808 { 11809 if(!obj || !obj.childNodes) return null; 11810 11811 recursive = !!recursive; get_all = !!get_all; 11812 11813 var n = obj.childNodes.length, result = []; 11814 11815 for (var j=0; j<n; j++) 11816 { 11817 var child = obj.childNodes[j]; 11818 11819 if (_checkNode(child, params)) 11820 { 11821 if (get_all) 11822 result.push(child); 11823 else 11824 return child; 11825 } 11826 11827 if(recursive == true) 11828 { 11829 var res = BX.findChild(child, params, recursive, get_all); 11830 if (res) 11831 { 11832 if (get_all) 11833 result = BX.util.array_merge(result, res); 11834 else 11835 return res; 11836 } 11837 } 11838 } 11839 11840 if (get_all || result.length > 0) 11841 return result; 11842 else 11843 return null; 11844 }; 11845 11846 /** 11847 * @deprecated 11848 * @use .closest() 11849 * @param obj 11850 * @param params 11851 * @param maxParent 11852 * @return {*} 11853 */ 11854 BX.findParent = function(obj, params, maxParent) 11855 { 11856 if(!obj) 11857 return null; 11858 11859 var o = obj; 11860 while(o.parentNode) 11861 { 11862 var parent = o.parentNode; 11863 11864 if (_checkNode(parent, params)) 11865 return parent; 11866 11867 o = parent; 11868 11869 if (!!maxParent &&
11870 (BX.type.isFunction(maxParent) 11871 || typeof maxParent == 'object')) 11872 { 11873 if (BX.type.isElementNode(maxParent)) 11874 { 11875 if (o == maxParent) 11876 break; 11877 } 11878 else 11879 { 11880 if (_checkNode(o, maxParent)) 11881 break; 11882 } 11883 } 11884 } 11885 return null; 11886 }; 11887 11888 /** 11889 * @deprecated 11890 * @use .querySelector 11891 * @param obj 11892 * @param params 11893 * @return {*} 11894 */ 11895 BX.findNextSibling = function(obj, params) 11896 { 11897 if(!obj) 11898 return null; 11899 var o = obj; 11900 while(o.nextSibling) 11901 { 11902 var sibling = o.nextSibling; 11903 if (_checkNode(sibling, params)) 11904 return sibling; 11905 o = sibling; 11906 } 11907 return null; 11908 }; 11909 11910 /** 11911 * @deprecated 11912 * @use .querySelector 11913 * @param obj 11914 * @param params 11915 * @return {*} 11916 */ 11917 BX.findPreviousSibling = function(obj, params) 11918 { 11919 if(!obj) 11920 return null; 11921 11922 var o = obj; 11923 while(o.previousSibling) 11924 { 11925 var sibling = o.previousSibling; 11926 if(_checkNode(sibling, params)) 11927 return sibling; 11928 o = sibling; 11929 } 11930 return null; 11931 }; 11932 11933 BX.checkNode = function(obj, params) 11934 { 11935 return _checkNode(obj, params); 11936 }; 11937 11938 /** 11939 * @deprecated 11940 * @use .querySelectorAll 11941 * @param form 11942 * @return {Array} 11943 */ 11944 BX.findFormElements = function(form) 11945 { 11946 if (BX.type.isString(form)) 11947 form = document.forms[form]||BX(form); 11948 11949 var res = []; 11950 11951 if (BX.type.isElementNode(form)) 11952 { 11953 if (form.tagName.toUpperCase() == 'FORM') 11954 { 11955 res = form.elements; 11956 } 11957 else 11958 { 11959 res = BX.findChildren(form, CHECK_FORM_ELEMENTS, true); 11960 } 11961 } 11962 11963 return res; 11964 }; 11965 11966 /** 11967 * @deprecated 11968 * @use .contains() 11969 * @param whichNode 11970 * @param forNode 11971 * @return {boolean} 11972 */ 11973 BX.isParentForNode = function(whichNode, forNode) 11974 { 11975 if (BX.type.isDomNode(whichNode) && BX.type.isDomNode(forNode)) 11976 { 11977 return whichNode.contains(forNode); 11978 } 11979 11980 return false; 11981 }; 11982 11983 BX.getCaretPosition = function(node) 11984 { 11985 var pos = 0; 11986 11987 if(node.selectionStart || node.selectionStart == 0) 11988 { 11989 pos = node.selectionStart; 11990 } 11991 else if(document.selection) 11992 { 11993 node.focus(); 11994 var selection = document.selection.createRange(); 11995 selection.moveStart('character', -node.value.length); 11996 pos = selection.text.length; 11997 } 11998 11999 return (pos); 12000 }; 12001 12002 BX.setCaretPosition = function(node, pos) 12003 { 12004 if(!BX.isNodeInDom(node) || BX.isNodeHidden(node) || node.disabled) 12005 { 12006 return; 12007 } 12008 12009 if(node.setSelectionRange) 12010 { 12011 node.focus(); 12012 node.setSelectionRange(pos, pos); 12013 } 12014 else if(node.createTextRange) 12015 { 12016 var range = node.createTextRange(); 12017 range.collapse(true); 12018 range.moveEnd('character', pos); 12019 range.moveStart('character', pos); 12020 range.select(); 12021 } 12022 }; 12023 12024 // access private. use BX.mergeEx instead. 12025 // todo: refactor BX.merge, make it work through BX.mergeEx 12026 BX.merge = function(){ 12027 var arg = Array.prototype.slice.call(arguments); 12028 12029 if(arg.length < 2) 12030 return {}; 12031 12032 var result = arg.shift(); 12033 12034 for(var i = 0; i < arg.length; i++) 12035 { 12036 for(var k in arg[i]){ 12037 12038 if(typeof arg[i] == 'undefined' || arg[i] == null) 12039 continue; 12040 12041 if(arg[i].hasOwnProperty(k)){ 12042 12043 if(typeof arg[i][k] == 'undefined' || arg[i][k] == null) 12044 continue; 12045 12046 if(typeof arg[i][k] == 'object' && !BX.type.isDomNode(arg[i][k]) && (typeof arg[i][k]['isUIWidget'] == 'undefined')){ 12047 12048 // go deeper 12049 12050 var isArray = 'length' in arg[i][k]; 12051 12052 if(typeof result[k] != 'object') 12053 result[k] = isArray ? [] : {}; 12054 12055 if(isArray) 12056 BX.util.array_merge(result[k], arg[i][k]); 12057 else 12058 BX.merge(result[k], arg[i][k]); 12059 12060 }else 12061 result[k] = arg[i][k]; 12062 } 12063 } 12064 } 12065 12066 return result; 12067 }; 12068 12069 BX.mergeEx = function() 12070 { 12071 var arg = Array.prototype.slice.call(arguments); 12072 if(arg.length < 2) 12073 { 12074 return {}; 12075 } 12076 12077 var result = arg.shift(); 12078 for (var i = 0; i < arg.length; i++) 12079 { 12080 for (var k in arg[i]) 12081 { 12082 if (typeof arg[i] == "undefined" || arg[i] == null || !arg[i].hasOwnProperty(k)) 12083 { 12084 continue; 12085 } 12086 12087 if (BX.type.isPlainObject(arg[i][k]) && BX.type.isPlainObject(result[k])) 12088 { 12089 BX.mergeEx(result[k], arg[i][k]); 12090 } 12091 else 12092 { 12093 result[k] = BX.type.isPlainObject(arg[i][k]) ? BX.clone(arg[i][k]) : arg[i][k]; 12094 } 12095 } 12096 } 12097 12098 return result; 12099 }; 12100 12101 BX.getEventButton = function(e) 12102 { 12103 e = e || window.event; 12104 12105 var flags = 0; 12106 12107 if (typeof e.which != 'undefined') 12108 { 12109 switch (e.which) 12110 { 12111 case 1: flags = flags|BX.MSLEFT; break; 12112 case 2: flags = flags|BX.MSMIDDLE; break; 12113 case 3: flags = flags|BX.MSRIGHT; break; 12114 } 12115 } 12116 else if (typeof e.button != 'undefined') 12117 { 12118 flags = event.button; 12119 } 12120 12121 return flags || BX.MSLEFT; 12122 }; 12123 12124 var captured_events = null, _bind = null; 12125 BX.CaptureEvents = function(el_c, evname_c) 12126 { 12127 if (_bind) 12128 return; 12129 12130 _bind = BX.bind; 12131 captured_events = []; 12132 12133 BX.bind = function(el, evname, func) 12134 { 12135 if (el === el_c && evname === evname_c) 12136 captured_events.push(func); 12137 12138 _bind.apply(this, arguments); 12139 } 12140 }; 12141 12142 BX.CaptureEventsGet = function() 12143 { 12144 if (_bind) 12145 { 12146 BX.bind = _bind; 12147 12148 var captured = captured_events; 12149 12150 _bind = null; 12151 captured_events = null; 12152 return captured; 12153 } 12154 return null; 12155 }; 12156 12157 // Don't even try to use it for submit event! 12158 BX.fireEvent = function(ob,ev) 12159 { 12160 var result = false, e = null; 12161 if (BX.type.isDomNode(ob)) 12162 { 12163 result = true; 12164 if (document.createEventObject) 12165 { 12166 // IE 12167 if (eventTypes[ev] != 'MouseEvent') 12168 { 12169 e = document.createEventObject(); 12170 e.type = ev; 12171 result = ob.fireEvent('on' + ev, e); 12172 } 12173 12174 if (ob[ev]) 12175 { 12176 ob[ev](); 12177 } 12178 } 12179 else 12180 {
12181 // non-IE 12182 e = null; 12183 12184 switch (eventTypes[ev]) 12185 { 12186 case 'MouseEvent': 12187 e = document.createEvent('MouseEvent'); 12188 try 12189 { 12190 e.initMouseEvent(ev, true, true, top, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12191 } 12192 catch (initException) 12193 { 12194 e.initMouseEvent(ev, true, true, window, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12195 } 12196 12197 break; 12198 default: 12199 e = document.createEvent('Event'); 12200 e.initEvent(ev, true, true); 12201 } 12202 12203 result = ob.dispatchEvent(e); 12204 } 12205 } 12206 12207 return result; 12208 }; 12209 12210 BX.getWheelData = function(e) 12211 { 12212 e = e || window.event; 12213 e.wheelData = e.detail ? e.detail * -1 : e.wheelDelta / 40; 12214 return e.wheelData; 12215 }; 12216 12217 BX.proxy_context = null; 12218 12219 BX.delegate = function (func, thisObject) 12220 { 12221 if (!func || !thisObject) 12222 return func; 12223 12224 return function() { 12225 var cur = BX.proxy_context; 12226 BX.proxy_context = this; 12227 var res = func.apply(thisObject, arguments); 12228 BX.proxy_context = cur; 12229 return res; 12230 } 12231 }; 12232 12233 BX.delegateLater = function (func_name, thisObject, contextObject) 12234 { 12235 return function() 12236 { 12237 if (thisObject[func_name]) 12238 { 12239 var cur = BX.proxy_context; 12240 BX.proxy_context = this; 12241 var res = thisObject[func_name].apply(contextObject||thisObject, arguments); 12242 BX.proxy_context = cur; 12243 return res; 12244 } 12245 return null; 12246 } 12247 }; 12248 12249 BX.proxy = function(func, thisObject) 12250 { 12251 return getObjectDelegate(func, thisObject, proxyList); 12252 }; 12253 12254 BX.defer = function(func, thisObject) 12255 { 12256 if (!!thisObject) 12257 return BX.defer_proxy(func, thisObject); 12258 else 12259 return function() { 12260 var arg = arguments; 12261 setTimeout(function(){func.apply(this,arg)}, 10); 12262 }; 12263 }; 12264 12265 BX.defer_proxy = function(func, thisObject) 12266 { 12267 return getObjectDelegate(func, thisObject, deferList, BX.defer); 12268 }; 12269 12270 /** 12271 * 12272 * @private 12273 */ 12274 function getObjectDelegate(func, thisObject, collection, decorator) 12275 { 12276 if (!BX.type.isFunction(func) || !BX.type.isMapKey(thisObject)) 12277 { 12278 return func; 12279 } 12280 12281 var objectDelegates = collection.get(thisObject); 12282 if (!objectDelegates) 12283 { 12284 objectDelegates = new WeakMap(); 12285 collection.set(thisObject, objectDelegates); 12286 } 12287 12288 var delegate = objectDelegates.get(func); 12289 if (!delegate) 12290 { 12291 delegate = decorator ? decorator(BX.delegate(func, thisObject)) : BX.delegate(func, thisObject); 12292 objectDelegates.set(func, delegate); 12293 } 12294 12295 return delegate; 12296 } 12297 12298 BX.once = function(el, evname, func) 12299 { 12300 var fn = function() 12301 { 12302 BX.unbind(el, evname, fn); 12303 func.apply(this, arguments); 12304 }; 12305 12306 return fn; 12307 }; 12308 12309 BX.bindDelegate = function (elem, eventName, isTarget, handler) 12310 { 12311 var h = BX.delegateEvent(isTarget, handler); 12312 BX.bind(elem, eventName, h); 12313 return h; 12314 }; 12315 12316 BX.delegateEvent = function(isTarget, handler) 12317 { 12318 return function(e) 12319 { 12320 e = e || window.event; 12321 var target = e.target || e.srcElement; 12322 12323 while (target != this) 12324 { 12325 if (_checkNode(target, isTarget)) 12326 { 12327 return handler.call(target, e); 12328 } 12329 if (target && target.parentNode) 12330 target = target.parentNode; 12331 else 12332 break; 12333 } 12334 return null; 12335 } 12336 }; 12337 12338 BX.False = function() {return false;}; 12339 BX.DoNothing = function() {}; 12340 12341 // TODO: also check event handlers set via BX.bind() 12342 BX.denyEvent = function(el, ev) 12343 { 12344 deniedEvents.push([el, ev, el['on' + ev]]); 12345 el['on' + ev] = BX.DoNothing; 12346 }; 12347 12348 BX.allowEvent = function(el, ev) 12349 { 12350 for(var i=0, len=deniedEvents.length; i<len; i++) 12351 { 12352 if (deniedEvents[i][0] == el && deniedEvents[i][1] == ev) 12353 { 12354 el['on' + ev] = deniedEvents[i][2]; 12355 BX.util.deleteFromArray(deniedEvents, i); 12356 return; 12357 } 12358 } 12359 }; 12360 12361 BX.fixEventPageXY = function(event) 12362 { 12363 BX.fixEventPageX(event); 12364 BX.fixEventPageY(event); 12365 return event; 12366 }; 12367 12368 BX.fixEventPageX = function(event) 12369 { 12370 if (event.pageX == null && event.clientX != null) 12371 { 12372 event.pageX = 12373 event.clientX + 12374 (document.documentElement && document.documentElement.scrollLeft || document.body && document.body.scrollLeft || 0) - 12375 (document.documentElement.clientLeft || 0); 12376 } 12377 12378 return event; 12379 }; 12380 12381 BX.fixEventPageY = function(event) 12382 { 12383 if (event.pageY == null && event.clientY != null) 12384 { 12385 event.pageY = 12386 event.clientY + 12387 (document.documentElement && document.documentElement.scrollTop || document.body && document.body.scrollTop || 0) - 12388 (document.documentElement.clientTop || 0); 12389 } 12390 12391 return event; 12392 }; 12393 12394 /** 12395 * @deprecated 12396 * @see e.preventDefault() 12397 */ 12398 BX.PreventDefault = function(e) 12399 { 12400 if(!e) e = window.event; 12401 if(e.stopPropagation) 12402 { 12403 e.preventDefault(); 12404 e.stopPropagation(); 12405 } 12406 else 12407 { 12408 e.cancelBubble = true; 12409 e.returnValue = false;
12410 } 12411 return false; 12412 }; 12413 12414 /** 12415 * @deprecated 12416 * @see e.preventDefault(); 12417 * 12418 * @param e 12419 * @return {boolean} 12420 */ 12421 BX.eventReturnFalse = function(e) 12422 { 12423 e=e||window.event; 12424 if (e && e.preventDefault) e.preventDefault(); 12425 else e.returnValue = false; 12426 return false; 12427 }; 12428 12429 /** 12430 * @deprecated 12431 * @see e.stopPropagation() 12432 * @param e 12433 */ 12434 BX.eventCancelBubble = function(e) 12435 { 12436 e=e||window.event; 12437 if(e && e.stopPropagation) 12438 e.stopPropagation(); 12439 else 12440 e.cancelBubble = true; 12441 }; 12442 12443 BX.bindDebouncedChange = function(node, fn, fnInstant, timeout, ctx) 12444 { 12445 ctx = ctx || window; 12446 timeout = timeout || 300; 12447 12448 var dataTag = 'bx-dc-previous-value'; 12449 BX.data(node, dataTag, node.value); 12450 12451 var act = function(fn, val){ 12452 12453 var pVal = BX.data(node, dataTag); 12454 12455 if(typeof pVal == 'undefined' || pVal != val){ 12456 if(typeof ctx != 'object') 12457 fn(val); 12458 else 12459 fn.apply(ctx, [val]); 12460 } 12461 }; 12462 12463 var actD = BX.debounce(function(){ 12464 var val = node.value; 12465 act(fn, val); 12466 BX.data(node, dataTag, val); 12467 }, timeout); 12468 12469 BX.bind(node, 'keyup', actD); 12470 BX.bind(node, 'change', actD); 12471 BX.bind(node, 'input', actD); 12472 12473 if(BX.type.isFunction(fnInstant)){ 12474 12475 var actI = function(){ 12476 act(fnInstant, node.value); 12477 }; 12478 12479 BX.bind(node, 'keyup', actI); 12480 BX.bind(node, 'change', actI); 12481 BX.bind(node, 'input', actI); 12482 } 12483 }; 12484 12485 BX.parseJSON = function(data, context) 12486 { 12487 var result = null; 12488 if (BX.type.isNotEmptyString(data)) 12489 { 12490 try { 12491 if (data.indexOf("\n") >= 0) 12492 eval('result = ' + data); 12493 else 12494 result = (new Function("return " + data))(); 12495 } catch(e) { 12496 BX.onCustomEvent(context, 'onParseJSONFailure', [data, context]) 12497 } 12498 } 12499 else if(BX.type.isPlainObject(data)) 12500 { 12501 return data; 12502 } 12503 12504 return result; 12505 }; 12506 12507 BX.submit = function(obForm, action_name, action_value, onAfterSubmit) 12508 { 12509 action_name = action_name || 'save'; 12510 if (!obForm['BXFormSubmit_' + action_name]) 12511 { 12512 obForm['BXFormSubmit_' + action_name] = obForm.appendChild(BX.create('INPUT', { 12513 'props': { 12514 'type': 'submit', 12515 'name': action_name, 12516 'value': action_value || 'Y' 12517 }, 12518 'style': { 12519 'display': 'none' 12520 } 12521 })); 12522 } 12523 12524 if (obForm.sessid) 12525 obForm.sessid.value = BX.bitrix_sessid(); 12526 12527 setTimeout(BX.delegate(function() {BX.fireEvent(this, 'click'); if (onAfterSubmit) onAfterSubmit();}, obForm['BXFormSubmit_' + action_name]), 10); 12528 }; 12529 12530 BX.show = function(ob, displayType) 12531 { 12532 if (ob.BXDISPLAY || !_checkDisplay(ob, displayType)) 12533 { 12534 ob.style.display = ob.BXDISPLAY; 12535 } 12536 }; 12537 12538 BX.hide = function(ob, displayType) 12539 { 12540 if (!ob.BXDISPLAY) 12541 _checkDisplay(ob, displayType); 12542 12543 ob.style.display = 'none'; 12544 }; 12545 12546 BX.toggle = function(ob, values) 12547 { 12548 if (!values && BX.type.isElementNode(ob)) 12549 { 12550 var bShow = true; 12551 if (ob.BXDISPLAY) 12552 bShow = !_checkDisplay(ob); 12553 else 12554 bShow = ob.style.display == 'none'; 12555 12556 if (bShow) 12557 BX.show(ob); 12558 else 12559 BX.hide(ob); 12560 } 12561 else if (BX.type.isArray(values)) 12562 { 12563 for (var i=0,len=values.length; i<len; i++) 12564 { 12565 if (ob == values[i]) 12566 { 12567 ob = values[i==len-1 ? 0 : i+1]; 12568 break; 12569 } 12570 } 12571 if (i==len) 12572 ob = values[0]; 12573 } 12574 12575 return ob; 12576 }; 12577 12578 function _checkDisplay(ob, displayType) 12579 { 12580 if (typeof displayType != 'undefined') 12581 ob.BXDISPLAY = displayType; 12582 12583 var d = ob.style.display || BX.style(ob, 'display'); 12584 if (d != 'none') 12585 { 12586 ob.BXDISPLAY = ob.BXDISPLAY || d; 12587 return true; 12588 } 12589 else 12590 { 12591 ob.BXDISPLAY = ob.BXDISPLAY || 'block'; 12592 return false; 12593 } 12594 } 12595 12596 /* some useful util functions */ 12597 12598 BX.util = { 12599 /** 12600 * @deprecated 12601 * @use [].filter(value => !BX.Type.isNil(value)) 12602 * @param ar 12603 * @return {*} 12604 */ 12605 array_values: function(ar) 12606 { 12607 if (!BX.type.isArray(ar)) 12608 return BX.util._array_values_ob(ar); 12609 var arv = []; 12610 for(var i=0,l=ar.length;i<l;i++) 12611 if (ar[i] !== null && typeof ar[i] != 'undefined') 12612 arv.push(ar[i]); 12613 return arv; 12614 }, 12615 12616 /** 12617 * @deprecated 12618 * @use Object.values([]).filter(value => !BX.Type.isNil(value)) 12619 * @param ar 12620 * @return {Array} 12621 * @private 12622 */ 12623 _array_values_ob: function(ar) 12624 { 12625 var arv = []; 12626 for(var i in ar) 12627 if (ar[i] !== null && typeof ar[i] != 'undefined') 12628 arv.push(ar[i]); 12629 return arv; 12630 }, 12631 12632 /** 12633 * @deprecated 12634 * @use 12635 * @param ar 12636 * @return {*} 12637 */ 12638 array_keys: function(ar) 12639 { 12640 if (!BX.type.isArray(ar)) 12641 return BX.util._array_keys_ob(ar); 12642 var arv = []; 12643 for(var i=0,l=ar.length;i<l;i++) 12644 if (ar[i] !== null && typeof ar[i] != 'undefined') 12645 arv.push(i); 12646 return arv; 12647 }, 12648 12649 _array_keys_ob: function(ar) 12650 { 12651 var arv = []; 12652 for(var i in ar) 12653 if (ar[i] !== null && typeof ar[i] != 'undefined') 12654 arv.push(i); 12655 return arv; 12656 }, 12657 12658 object_keys: function(obj) 12659 { 12660 var arv = []; 12661 for(var k in obj) 12662 { 12663 if(obj.hasOwnProperty(k)) 12664 { 12665 arv.push(k); 12666 } 12667 } 12668 return arv; 12669 }, 12670 12671 /** 12672 * @deprecated 12673 * @use firstArr.concat(secondArr); 12674 * @param first 12675 * @param second 12676 * @return {*[]} 12677 */ 12678 array_merge: function(first, second) 12679 { 12680 if (!BX.type.isArray(first)) first = []; 12681 if (!BX.type.isArray(second)) second = []; 12682 12683 var i = first.length, j = 0; 12684 12685 if (typeof second.length === "number") 12686 { 12687 for (var l = second.length; j < l; j++) 12688 { 12689 first[i++] = second[j]; 12690 } 12691 } 12692 else 12693 {
12694 while (second[j] !== undefined) 12695 { 12696 first[i++] = second[j++]; 12697 } 12698 } 12699 12700 first.length = i; 12701 12702 return first; 12703 }, 12704 12705 array_flip: function (object) 12706 { 12707 var newObject = {}; 12708 12709 for (var key in object) 12710 { 12711 newObject[object[key]] = key; 12712 } 12713 12714 return newObject; 12715 }, 12716 12717 array_diff: function(ar1, ar2, hash) 12718 { 12719 hash = BX.type.isFunction(hash) ? hash : null; 12720 var i, length, v, h, map = {}, result = []; 12721 for(i = 0, length = ar2.length; i < length; i++) 12722 { 12723 v = ar2[i]; 12724 h = hash ? hash(v) : v; 12725 map[h] = true; 12726 } 12727 12728 for(i = 0, length = ar1.length; i < length; i++) 12729 { 12730 v = ar1[i]; 12731 h = hash ? hash(v) : v; 12732 if(typeof(map[h]) === "undefined") 12733 { 12734 result.push(v); 12735 } 12736 } 12737 return result; 12738 }, 12739 12740 /** 12741 * @deprecated 12742 * @use Set 12743 */ 12744 array_unique: function(ar) 12745 { 12746 var i=0,j,len=ar.length; 12747 if(len<2) return ar; 12748 12749 for (; i<len-1;i++) 12750 { 12751 for (j=i+1; j<len;j++) 12752 { 12753 if (ar[i]==ar[j]) 12754 { 12755 ar.splice(j--,1); len--; 12756 } 12757 } 12758 } 12759 12760 return ar; 12761 }, 12762 12763 /** 12764 * @deprecated 12765 * @use myArr.includes(needle) 12766 */ 12767 in_array: function(needle, haystack) 12768 { 12769 for(var i=0; i<haystack.length; i++) 12770 { 12771 if(haystack[i] == needle) 12772 return true; 12773 } 12774 return false; 12775 }, 12776 12777 /** 12778 * @deprecated 12779 * @use myArr.findIndex(item => item === needle); 12780 */ 12781 array_search: function(needle, haystack) 12782 { 12783 for(var i=0; i<haystack.length; i++) 12784 { 12785 if(haystack[i] == needle) 12786 return i; 12787 } 12788 return -1; 12789 }, 12790 12791 object_search_key: function(needle, haystack) 12792 { 12793 if (typeof haystack[needle] != 'undefined') 12794 return haystack[needle]; 12795 12796 for(var i in haystack) 12797 { 12798 if (typeof haystack[i] == "object") 12799 { 12800 var result = BX.util.object_search_key(needle, haystack[i]); 12801 if (result !== false) 12802 return result; 12803 } 12804 } 12805 return false; 12806 }, 12807 12808 trim: function(s) 12809 { 12810 if (BX.type.isString(s)) 12811 { 12812 return s.trim(); 12813 } 12814 12815 return s; 12816 }, 12817 12818 urlencode: function(s){return encodeURIComponent(s);}, 12819 12820 // it may also be useful. via sVD. 12821 deleteFromArray: function(ar, ind) {return ar.slice(0, ind).concat(ar.slice(ind + 1));}, 12822 insertIntoArray: function(ar, ind, el) {return ar.slice(0, ind).concat([el]).concat(ar.slice(ind));}, 12823 12824 htmlspecialchars: function(str) 12825 { 12826 return BX.Text.encode(str); 12827 }, 12828 12829 htmlspecialcharsback: function(str) 12830 { 12831 return BX.Text.decode(str); 12832 }, 12833 12834 // Quote regular expression characters plus an optional character 12835 preg_quote: function(str, delimiter) 12836 { 12837 if(!str.replace) 12838 return str; 12839 return str.replace(new RegExp('[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + (delimiter || '') + '-]', 'g'), '\\$&'); 12840 }, 12841 12842 jsencode: function(str) 12843 { 12844 if (!str || !str.replace) 12845 return str; 12846 12847 var escapes = 12848 [ 12849 { c: "\\\\", r: "\\\\" }, // should be first 12850 { c: "\\t", r: "\\t" }, 12851 { c: "\\n", r: "\\n" }, 12852 { c: "\\r", r: "\\r" }, 12853 { c: "\"", r: "\\\"" }, 12854 { c: "'", r: "\\'" }, 12855 { c: "<", r: "\\x3C" }, 12856 { c: ">", r: "\\x3E" }, 12857 { c: "\\u2028", r: "\\u2028" }, 12858 { c: "\\u2029", r: "\\u2029" } 12859 ]; 12860 for (var i = 0; i < escapes.length; i++) 12861 str = str.replace(new RegExp(escapes[i].c, 'g'), escapes[i].r); 12862 return str; 12863 }, 12864 12865 getCssName: function(jsName) 12866 { 12867 if (!BX.type.isNotEmptyString(jsName)) 12868 { 12869 return ""; 12870 } 12871 12872 return jsName.replace(/[A-Z]/g, function(match) { 12873 return "-" + match.toLowerCase(); 12874 }); 12875 }, 12876 12877 getJsName: function(cssName) 12878 { 12879 var regex = /\-([a-z]){1}/g; 12880 if (regex.test(cssName)) 12881 { 12882 return cssName.replace(regex, function(match, letter) { 12883 return letter.toUpperCase(); 12884 }); 12885 } 12886 12887 return cssName; 12888 }, 12889 12890 nl2br: function(str) 12891 { 12892 if (!str || !str.replace) 12893 return str; 12894 12895 return str.replace(/([^>])\n/g, '$1<br/>'); 12896 }, 12897 12898 /** 12899 * @deprecated 12900 * @use .padStart() / .padEnd() 12901 * @param input 12902 * @param pad_length 12903 * @param pad_string 12904 * @param pad_type 12905 * @return {*} 12906 */ 12907 str_pad: function(input, pad_length, pad_string, pad_type) 12908 { 12909 pad_string = pad_string || ' '; 12910 pad_type = pad_type || 'right'; 12911 input = input.toString(); 12912 12913 if (pad_type === 'left') 12914 { 12915 return BX.util.str_pad_left(input, pad_length, pad_string); 12916 } 12917 12918 return BX.util.str_pad_right(input, pad_length, pad_string); 12919 }, 12920 12921 str_pad_left: function(input, pad_length, pad_string) 12922 { 12923 return input.toString().padStart(pad_length, pad_string); 12924 }, 12925 12926 str_pad_right: function(input, pad_length, pad_string) 12927 { 12928 return input.toString().padEnd(pad_length, pad_string); 12929 }, 12930 12931 strip_tags: function(str) 12932 { 12933 return str.split(/<[^>]+>/g).join(''); 12934 }, 12935 12936 strip_php_tags: function(str) 12937 { 12938 return str.replace(/<\?(.|[\r\n])*?\?>/g, ''); 12939 }, 12940 12941 popup: function(url, width, height) 12942 { 12943 var w, h; 12944 if(BX.browser.IsOpera()) 12945 { 12946 w = document.body.offsetWidth; 12947 h = document.body.offsetHeight; 12948 } 12949 else 12950 {
12951 w = screen.width; 12952 h = screen.height; 12953 } 12954 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)); 12955 }, 12956 12957 shuffle: function(array) 12958 { 12959 var temporaryValue, randomIndex; 12960 var currentIndex = array.length; 12961 12962 while (0 !== currentIndex) 12963 { 12964 randomIndex = Math.floor(Math.random() * currentIndex); 12965 currentIndex -= 1; 12966 12967 temporaryValue = array[currentIndex]; 12968 array[currentIndex] = array[randomIndex]; 12969 array[randomIndex] = temporaryValue; 12970 } 12971 12972 return array; 12973 }, 12974 12975 // BX.util.objectSort(object, sortBy, sortDir) - Sort object by property 12976 // function params: 1 - object for sort, 2 - sort by property, 3 - sort direction (asc/desc) 12977 // return: sort array [[objectElement], [objectElement]] in sortDir direction 12978 12979 // example: BX.util.objectSort({'L1': {'name': 'Last'}, 'F1': {'name': 'First'}}, 'name', 'asc'); 12980 // return: [{'name' : 'First'}, {'name' : 'Last'}] 12981 objectSort: function(object, sortBy, sortDir) 12982 { 12983 sortDir = sortDir == 'asc'? 'asc': 'desc'; 12984 12985 var arItems = [], i; 12986 for (i in object) 12987 { 12988 if (object.hasOwnProperty(i) && object[i][sortBy]) 12989 { 12990 arItems.push([i, object[i][sortBy]]); 12991 } 12992 } 12993 12994 if (sortDir == 'asc') 12995 { 12996 arItems.sort(function(i, ii) { 12997 var s1, s2; 12998 if (BX.type.isDate(i[1])) 12999 { 13000 s1 = i[1].getTime(); 13001 } 13002 else if (!isNaN(i[1])) 13003 { 13004 s1 = parseInt(i[1]); 13005 } 13006 else 13007 { 13008 s1 = i[1].toString().toLowerCase(); 13009 } 13010 13011 if (BX.type.isDate(ii[1])) 13012 { 13013 s2 = ii[1].getTime(); 13014 } 13015 else if (!isNaN(ii[1])) 13016 { 13017 s2 = parseInt(ii[1]); 13018 } 13019 else 13020 { 13021 s2 = ii[1].toString().toLowerCase(); 13022 } 13023 13024 if (s1 > s2) 13025 return 1; 13026 else if (s1 < s2) 13027 return -1; 13028 else 13029 return 0; 13030 }); 13031 } 13032 else 13033 { 13034 arItems.sort(function(i, ii) { 13035 var s1, s2; 13036 if (BX.type.isDate(i[1])) 13037 { 13038 s1 = i[1].getTime(); 13039 } 13040 else if (!isNaN(i[1])) 13041 { 13042 s1 = parseInt(i[1]); 13043 } 13044 else 13045 { 13046 s1 = i[1].toString().toLowerCase(); 13047 } 13048 13049 if (BX.type.isDate(ii[1])) 13050 { 13051 s2 = ii[1].getTime(); 13052 } 13053 else if (!isNaN(ii[1])) 13054 { 13055 s2 = parseInt(ii[1]); 13056 } 13057 else 13058 { 13059 s2 = ii[1].toString().toLowerCase(); 13060 } 13061 13062 if (s1 < s2) 13063 return 1; 13064 else if (s1 > s2) 13065 return -1; 13066 else 13067 return 0; 13068 }); 13069 } 13070 13071 var arReturnArray = Array(); 13072 for (i = 0; i < arItems.length; i++) 13073 { 13074 arReturnArray.push(object[arItems[i][0]]); 13075 } 13076 13077 return arReturnArray; 13078 }, 13079 13080 objectMerge: function() 13081 { 13082 return BX.mergeEx.apply(window, arguments); 13083 }, 13084 13085 objectClone : function(object) 13086 { 13087 return BX.clone(object, true); 13088 }, 13089 13090 // #fdf9e5 => {r=253, g=249, b=229} 13091 hex2rgb: function(color) 13092 { 13093 var rgb = color.replace(/[# ]/g,"").replace(/^(.)(.)(.)$/,'$1$1$2$2$3$3').match(/.{2}/g); 13094 for (var i=0; i<3; i++) 13095 { 13096 rgb[i] = parseInt(rgb[i], 16); 13097 } 13098 return {'r':rgb[0],'g':rgb[1],'b':rgb[2]}; 13099 }, 13100 13101 /** 13102 * @deprecated 13103 * @use BX.Uri 13104 * @param url 13105 * @param param 13106 * @return {string} 13107 */ 13108 remove_url_param: function(url, param) 13109 { 13110 return BX.Uri.removeParam(url, param); 13111 }, 13112 13113 /* 13114 {'param1': 'value1', 'param2': 'value2'} 13115 */ 13116 /** 13117 * @deprecated 13118 * @use BX.Uri 13119 * @param url 13120 * @param params 13121 * @return {string} 13122 */ 13123 add_url_param: function(url, params) 13124 { 13125 var preparedParams = Object.entries(params).reduce(function(acc, item) { 13126 acc[item[0]] = BX.type.isArray(item[1]) ? item[1].join() : item[1]; 13127 return acc; 13128 }, {}); 13129 13130 return BX.Uri.addParam(url, preparedParams); 13131 }, 13132 13133 /* 13134 {'param1': 'value1', 'param2': 'value2'} 13135 */ 13136 buildQueryString: function(params) 13137 { 13138 var result = ''; 13139 for (var key in params) 13140 { 13141 var value = params[key]; 13142 if(BX.type.isArray(value)) 13143 { 13144 value.forEach(function(valueElement, index) 13145 { 13146 result += encodeURIComponent(key + "[" + index + "]") + "=" + encodeURIComponent(valueElement) + "&"; 13147 }); 13148 } 13149 else 13150 { 13151 result += encodeURIComponent(key) + "=" + encodeURIComponent(value) + "&"; 13152 } 13153 } 13154 13155 if(result.length > 0) 13156 { 13157 result = result.substr(0, result.length - 1); 13158 } 13159 return result; 13160 }, 13161 13162 even: function(digit) 13163 { 13164 return (parseInt(digit) % 2 == 0); 13165 }, 13166 13167 hashCode: function(str) 13168 { 13169 if(!BX.type.isNotEmptyString(str)) 13170 { 13171 return 0; 13172 } 13173 13174 var hash = 0; 13175 for (var i = 0; i < str.length; i++) 13176 { 13177 var c = str.charCodeAt(i); 13178 hash = ((hash << 5) - hash) + c; 13179 hash = hash & hash; 13180 } 13181 return hash; 13182 }, 13183 13184 getRandomString: function (length) 13185 { 13186 return BX.Text.getRandom(length); 13187 }, 13188 13189 number_format: function(number, decimals, dec_point, thousands_sep) 13190 { 13191 var i, j, kw, kd, km, sign = ''; 13192 decimals = Math.abs(decimals); 13193 if (isNaN(decimals) || decimals < 0) 13194 { 13195 decimals = 2; 13196 } 13197 dec_point = dec_point || ','; 13198 if (typeof thousands_sep === 'undefined') 13199 thousands_sep = '.'; 13200 13201 number = (+number || 0).toFixed(decimals); 13202 if (number < 0) 13203 { 13204 sign = '-'; 13205 number = -number; 13206 } 13207 13208 i = parseInt(number, 10) + ''; 13209 j = (i.length > 3 ? i.length % 3 : 0); 13210 13211 km = (j ? i.substr(0, j) + thousands_sep : ''); 13212 kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep); 13213 kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, '0').slice(2) : ''); 13214 13215 return sign + km + kw + kd; 13216 }, 13217 13218 getExtension: function (url) 13219 { 13220 url = url || ""; 13221 var items = url.split("?")[0].split("."); 13222 return items[items.length-1].toLowerCase(); 13223 }, 13224 addObjectToForm: function(object, form, prefix) 13225 { 13226 if(!BX.type.isString(prefix)) 13227 { 13228 prefix = ""; 13229 } 13230 13231 for(var key in object) 13232 { 13233 if(!object.hasOwnProperty(key)) 13234 { 13235 continue; 13236 } 13237 13238 var value = object[key]; 13239 var name = prefix !== "" ? (prefix + "[" + key + "]") : key; 13240 if(BX.type.isArray(value)) 13241 { 13242 var obj = {}; 13243 for(var i = 0; i < value.length; i++) 13244 { 13245 obj[i] = value[i]; 13246 } 13247 13248 BX.util.addObjectToForm(obj, form, name); 13249 } 13250 else if(BX.type.isPlainObject(value)) 13251 { 13252 BX.util.addObjectToForm(value, form, name); 13253 } 13254 else 13255 { 13256 value = BX.type.isFunction(value.toString) ? value.toString() : ""; 13257 if(value !== "") 13258 { 13259 form.appendChild(BX.create("INPUT", { attrs: { type: "hidden", name: name, value: value } })); 13260 } 13261 } 13262 } 13263 }, 13264 13265 observe: function(object, enable) 13266 {
13267 console.error('BX.util.observe: function is no longer supported by browser.'); 13268 return false; 13269 }, 13270 13271 escapeRegExp: function(str) 13272 { 13273 return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); 13274 } 13275 }; 13276 13277 BX.validation = { 13278 checkIfEmail: function(s) 13279 { 13280 var atom = "[=a-z0-9_+~'!$&*^`|#%/?{}-]"; 13281 return (new RegExp('^\\s*'+atom+'+(\\.'+atom+'+)*@([a-z0-9-]+\\.)+[a-z0-9-]{2,20}\\s*$', 'i')).test(s); 13282 }, 13283 checkIfPhone: function(s) 13284 { 13285 var regexp = new RegExp( 13286 typeof(BX.PhoneNumber) === "undefined" 13287 ? BX.PhoneNumber.getValidNumberPattern() 13288 : '^\\s*\\+?\s*[0-9(-)\\s]+\\s*$', 13289 'i' 13290 ); 13291 return regexp.test(s); 13292 } 13293 }; 13294 13295 BX.prop = 13296 { 13297 get: function(object, key, defaultValue) 13298 { 13299 return object && object.hasOwnProperty(key) ? object[key] : defaultValue; 13300 }, 13301 getObject: function(object, key, defaultValue) 13302 { 13303 return object && BX.type.isPlainObject(object[key]) ? object[key] : defaultValue; 13304 }, 13305 getElementNode: function(object, key, defaultValue) 13306 { 13307 return object && BX.type.isElementNode(object[key]) ? object[key] : defaultValue; 13308 }, 13309 getArray: function(object, key, defaultValue) 13310 { 13311 return object && BX.type.isArray(object[key]) ? object[key] : defaultValue; 13312 }, 13313 getFunction: function(object, key, defaultValue) 13314 { 13315 return object && BX.type.isFunction(object[key]) ? object[key] : defaultValue; 13316 }, 13317 getNumber: function(object, key, defaultValue) 13318 { 13319 if(!(object && object.hasOwnProperty(key))) 13320 { 13321 return defaultValue; 13322 } 13323 13324 var value = object[key]; 13325 if(BX.type.isNumber(value)) 13326 { 13327 return value; 13328 } 13329 13330 value = parseFloat(value); 13331 return !isNaN(value) ? value : defaultValue; 13332 }, 13333 getInteger: function(object, key, defaultValue) 13334 { 13335 if(!(object && object.hasOwnProperty(key))) 13336 { 13337 return defaultValue; 13338 } 13339 13340 var value = object[key]; 13341 if(BX.type.isNumber(value)) 13342 { 13343 return value; 13344 } 13345 13346 value = parseInt(value); 13347 return !isNaN(value) ? value : defaultValue; 13348 }, 13349 getBoolean: function(object, key, defaultValue) 13350 { 13351 if(!(object && object.hasOwnProperty(key))) 13352 { 13353 return defaultValue; 13354 } 13355 13356 var value = object[key]; 13357 return (BX.type.isBoolean(value) 13358 ? value 13359 : (BX.type.isString(value) ? (value.toLowerCase() === "true") : !!value) 13360 ); 13361 }, 13362 getString: function(object, key, defaultValue) 13363 { 13364 if(!(object && object.hasOwnProperty(key))) 13365 { 13366 return defaultValue; 13367 } 13368 13369 var value = object[key]; 13370 return BX.type.isString(value) ? value : (value ? value.toString() : ''); 13371 }, 13372 extractDate: function(datetime) 13373 { 13374 if(!BX.type.isDate(datetime)) 13375 { 13376 datetime = new Date(); 13377 } 13378 13379 datetime.setHours(0); 13380 datetime.setMinutes(0); 13381 datetime.setSeconds(0); 13382 datetime.setMilliseconds(0); 13383 13384 return datetime; 13385 } 13386 }; 13387 13388 BX.isNodeInDom = function(node, doc) 13389 { 13390 return node === (doc || document) ? true : 13391 (node.parentNode ? BX.isNodeInDom(node.parentNode) : false); 13392 }; 13393 13394 BX.isNodeHidden = function(node) 13395 { 13396 if (node === document) 13397 return false; 13398 else if (BX.style(node, 'display') == 'none') 13399 return true; 13400 else 13401 return (node.parentNode ? BX.isNodeHidden(node.parentNode) : true); 13402 }; 13403 13404 BX.evalPack = function(code) 13405 { 13406 while (code.length > 0) 13407 { 13408 var c = code.shift(); 13409 13410 if (c.TYPE == 'SCRIPT_EXT' || c.TYPE == 'SCRIPT_SRC') 13411 { 13412 BX.loadScript(c.DATA, function() {BX.evalPack(code)}); 13413 return; 13414 } 13415 else if (c.TYPE == 'SCRIPT') 13416 { 13417 BX.evalGlobal(c.DATA); 13418 } 13419 } 13420 }; 13421 13422 BX.evalGlobal = function(data) 13423 { 13424 if (data) 13425 { 13426 var head = document.getElementsByTagName("head")[0] || document.documentElement, 13427 script = document.createElement("script"); 13428 13429 script.type = "text/javascript"; 13430 13431 if (!BX.browser.IsIE()) 13432 { 13433 script.appendChild(document.createTextNode(data)); 13434 } 13435 else 13436 { 13437 script.text = data; 13438 } 13439 13440 head.insertBefore(script, head.firstChild); 13441 head.removeChild(script); 13442 } 13443 }; 13444 13445 BX.garbage = function(call, thisObject) 13446 { 13447 garbageCollectors.push({callback: call, context: thisObject}); 13448 }; 13449 13450 BX.GetDocElement = function (pDoc) 13451 { 13452 pDoc = pDoc || document; 13453 return (BX.browser.IsDoctype(pDoc) ? pDoc.documentElement : pDoc.body); 13454 }; 13455 13456 BX.scrollTop = function(node, val){ 13457 if(typeof val != 'undefined'){ 13458 13459 if(node == window){ 13460 throw new Error('scrollTop() for window is not implemented'); 13461 }else 13462 node.scrollTop = parseInt(val); 13463 13464 }else{ 13465 13466 if(node == window) 13467 return BX.GetWindowScrollPos().scrollTop; 13468 13469 return node.scrollTop; 13470 } 13471 }; 13472 13473 BX.scrollLeft = function(node, val){ 13474 if(typeof val != 'undefined'){ 13475 13476 if(node == window){ 13477 throw new Error('scrollLeft() for window is not implemented'); 13478 }else 13479 node.scrollLeft = parseInt(val); 13480 13481 }else{ 13482 13483 if(node == window) 13484 return BX.GetWindowScrollPos().scrollLeft; 13485 13486 return node.scrollLeft; 13487 } 13488 }; 13489 13490 BX.hide_object = function(ob) 13491 { 13492 ob = BX(ob); 13493 ob.style.position = 'absolute'; 13494 ob.style.top = '-1000px'; 13495 ob.style.left = '-1000px'; 13496 ob.style.height = '10px'; 13497 ob.style.width = '10px'; 13498 }; 13499 13500 BX.is_relative = function(el) 13501 { 13502 var p = BX.style(el, 'position'); 13503 return p == 'relative' || p == 'absolute'; 13504 }; 13505 13506 BX.is_float = function(el) 13507 { 13508 var p = BX.style(el, 'float'); 13509 return p == 'right' || p == 'left'; 13510 }; 13511 13512 BX.is_fixed = function(el) 13513 { 13514 var p = BX.style(el, 'position'); 13515 return p == 'fixed'; 13516 }; 13517 13518 BX.width = function(node, val){ 13519 if(typeof val != 'undefined') 13520 BX.style(node, 'width', parseInt(val)+'px'); 13521 else{ 13522 13523 if(node == window) 13524 return window.innerWidth; 13525 13526 //return parseInt(BX.style(node, 'width')); 13527 return BX.pos(node).width; 13528 } 13529 }; 13530 13531 BX.height = function(node, val){ 13532 if(typeof val != 'undefined') 13533 BX.style(node, 'height', parseInt(val)+'px'); 13534 else{ 13535 13536 if(node == window) 13537 return window.innerHeight; 13538 13539 //return parseInt(BX.style(node, 'height')); 13540 return BX.pos(node).height; 13541 } 13542 }; 13543 13544 BX.align = function(pos, w, h, type) 13545 { 13546 if (type) 13547 type = type.toLowerCase(); 13548 else 13549 type = ''; 13550 13551 var pDoc = document; 13552 if (BX.type.isElementNode(pos)) 13553 { 13554 pDoc = pos.ownerDocument; 13555 pos = BX.pos(pos); 13556 } 13557 13558 var x = pos["left"], y = pos["bottom"]; 13559 13560 var scroll = BX.GetWindowScrollPos(pDoc); 13561 var size = BX.GetWindowInnerSize(pDoc); 13562 13563 if((size.innerWidth + scroll.scrollLeft) - (pos["left"] + w) < 0) 13564 { 13565 if(pos["right"] - w >= 0 ) 13566 x = pos["right"] - w; 13567 else 13568 x = scroll.scrollLeft; 13569 } 13570
13571 if(((size.innerHeight + scroll.scrollTop) - (pos["bottom"] + h) < 0) || ~type.indexOf('top')) 13572 { 13573 if(pos["top"] - h >= 0 || ~type.indexOf('top')) 13574 y = pos["top"] - h; 13575 else 13576 y = scroll.scrollTop; 13577 } 13578 13579 return {'left':x, 'top':y}; 13580 }; 13581 13582 BX.scrollToNode = function(node) 13583 { 13584 var obNode = BX(node); 13585 13586 if (obNode.scrollIntoView) 13587 obNode.scrollIntoView(true); 13588 else 13589 { 13590 var arNodePos = BX.pos(obNode); 13591 window.scrollTo(arNodePos.left, arNodePos.top); 13592 } 13593 }; 13594 13595 /* non-xhr loadings */ 13596 BX.showWait = function(node, msg) 13597 { 13598 node = BX(node) || document.body || document.documentElement; 13599 msg = msg || BX.message('JS_CORE_LOADING'); 13600 13601 var container_id = node.id || Math.random(); 13602 13603 var obMsg = node.bxmsg = document.body.appendChild(BX.create('DIV', { 13604 props: { 13605 id: 'wait_' + container_id 13606 }, 13607 style: { 13608 background: 'url("/bitrix/js/main/core/images/wait.gif") no-repeat scroll 10px center #fcf7d1', 13609 border: '1px solid #E1B52D', 13610 color: 'black', 13611 fontFamily: 'Verdana,Arial,sans-serif', 13612 fontSize: '11px', 13613 padding: '10px 30px 10px 37px', 13614 position: 'absolute', 13615 textAlign:'center' 13616 }, 13617 text: msg 13618 })); 13619 13620 BX.ZIndexManager.register(obMsg); 13621 BX.ZIndexManager.bringToFront(obMsg); 13622 13623 setTimeout(BX.delegate(_adjustWait, node), 10); 13624 13625 lastWait[lastWait.length] = obMsg; 13626 return obMsg; 13627 }; 13628 13629 BX.closeWait = function(node, obMsg) 13630 { 13631 if(node && !obMsg) 13632 obMsg = node.bxmsg; 13633 if(node && !obMsg && BX.hasClass(node, 'bx-core-waitwindow')) 13634 obMsg = node; 13635 if(node && !obMsg) 13636 obMsg = BX('wait_' + node.id); 13637 if(!obMsg) 13638 obMsg = lastWait.pop(); 13639 13640 if (obMsg && obMsg.parentNode) 13641 { 13642 for (var i=0,len=lastWait.length;i<len;i++) 13643 { 13644 if (obMsg == lastWait[i]) 13645 { 13646 lastWait = BX.util.deleteFromArray(lastWait, i); 13647 break; 13648 } 13649 } 13650 13651 BX.ZIndexManager.unregister(obMsg); 13652 obMsg.parentNode.removeChild(obMsg); 13653 if (node) node.bxmsg = null; 13654 BX.cleanNode(obMsg, true); 13655 } 13656 }; 13657 13658 BX.setJSList = function(scripts) 13659 { 13660 if (BX.type.isArray(scripts)) 13661 { 13662 scripts = scripts.map(function(script) { 13663 return normalizeUrl(script) 13664 }); 13665 13666 jsList = jsList.concat(scripts); 13667 } 13668 }; 13669 13670 BX.getJSList = function() 13671 { 13672 initJsList(); 13673 return jsList; 13674 }; 13675 13676 BX.setCSSList = function(cssFiles) 13677 { 13678 if (BX.type.isArray(cssFiles)) 13679 { 13680 cssFiles = cssFiles.map(function(cssFile) { 13681 return normalizeUrl(cssFile); 13682 }); 13683 13684 cssList = cssList.concat(cssFiles); 13685 } 13686 }; 13687 13688 BX.getCSSList = function() 13689 { 13690 initCssList(); 13691 return cssList; 13692 }; 13693 13694 BX.getJSPath = function(js) 13695 { 13696 return js.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 13697 }; 13698 13699 BX.getCSSPath = function(css) 13700 { 13701 return css.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 13702 }; 13703 13704 BX.getCDNPath = function(path) 13705 { 13706 return path; 13707 }; 13708 13709 BX.loadScript = function(script, callback, doc) 13710 { 13711 if (BX.type.isString(script)) 13712 { 13713 script = [script]; 13714 } 13715 13716 return BX.load(script, callback, doc); 13717 }; 13718 13719 BX.loadCSS = function(css, doc, win) 13720 { 13721 if (BX.type.isString(css)) 13722 { 13723 css = [css]; 13724 } 13725 13726 if (BX.type.isArray(css)) 13727 { 13728 css = css.map(function(url) { 13729 return { url: url, ext: "css" } 13730 }); 13731 13732 BX.load(css, null, doc); 13733 } 13734 }; 13735 13736 const LOADING = 3; 13737 const LOADED = 4; 13738 const assets = {}; 13739 13740 BX.load = function(items, callback, doc) 13741 { 13742 if (!BX.isReady) 13743 { 13744 var _args = arguments; 13745 BX.ready(function() { 13746 BX.load.apply(this, _args); 13747 }); 13748 13749 return null; 13750 } 13751 13752 doc = doc || document; 13753 13754 callback = BX.Type.isFunction(callback) ? callback : () => {}; 13755 13756 return loadAsync(items, callback, doc); 13757 }; 13758 13759 function loadAsync(items, callback, doc) 13760 { 13761 if (!BX.type.isArray(items)) 13762 { 13763 callback(); 13764 13765 return; 13766 } 13767 13768 function onLoad() 13769 { 13770 const nextAsset = queue.shift(); 13771 if (nextAsset) 13772 { 13773 load(nextAsset, onLoad, doc); 13774 } 13775 else if (allLoaded()) 13776 { 13777 callback(); 13778 } 13779 } 13780 13781 function allLoaded() 13782 { 13783 for (const name in assetMap) 13784 { 13785 if (assetMap[name].state !== LOADED) 13786 { 13787 return false; 13788 } 13789 } 13790 13791 return true; 13792 } 13793 13794 const queue = []; 13795 const assetMap = {}; 13796 items.forEach(item => { 13797 const asset = getAsset(item); 13798 if (asset && asset.state !== LOADED) 13799 { 13800 queue.push(asset); 13801 assetMap[asset.name] = asset; 13802 } 13803 }); 13804 13805 if (queue.length > 0) 13806 {
13807 const maxParallelLoads = 6; 13808 const parallelLoads = Math.min(queue.length, maxParallelLoads); 13809 const firstPackage = queue.splice(0, parallelLoads); 13810 firstPackage.forEach(asset => { 13811 load(asset, onLoad, doc); 13812 }); 13813 } 13814 else 13815 { 13816 callback(); 13817 } 13818 } 13819 13820 function load(asset, callback, doc) 13821 { 13822 callback = callback || BX.DoNothing; 13823 13824 if (asset.state === LOADED) 13825 { 13826 callback(); 13827 return; 13828 } 13829 13830 asset.state = LOADING; 13831 13832 loadAsset( 13833 asset, 13834 function () { 13835 asset.state = LOADED; 13836 callback(); 13837 }, 13838 doc 13839 ); 13840 } 13841 13842 function loadAsset(asset, callback, doc) 13843 { 13844 callback = callback || BX.DoNothing; 13845 13846 function error(event) 13847 { 13848 ele.onload = ele.onreadystatechange = ele.onerror = null; 13849 callback(); 13850 } 13851 13852 function process(event) 13853 { 13854 event = event || window.event; 13855 if (event.type === "load" || (/loaded|complete/.test(ele.readyState) && (!doc.documentMode || doc.documentMode < 9))) 13856 { 13857 window.clearTimeout(asset.errorTimeout); 13858 window.clearTimeout(asset.cssTimeout); 13859 ele.onload = ele.onreadystatechange = ele.onerror = null; 13860 callback(); 13861 } 13862 } 13863 13864 function isCssLoaded() 13865 { 13866 if (asset.state !== LOADED && asset.cssRetries <= 20) 13867 { 13868 for (var i = 0, l = doc.styleSheets.length; i < l; i++) 13869 { 13870 if (doc.styleSheets[i].href === ele.href) 13871 { 13872 process({"type": "load"}); 13873 return; 13874 } 13875 } 13876 13877 asset.cssRetries++; 13878 asset.cssTimeout = window.setTimeout(isCssLoaded, 250); 13879 } 13880 } 13881 13882 let ele = null; 13883 const ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 13884 13885 if (ext === "css") 13886 { 13887 ele = doc.createElement("link"); 13888 ele.type = "text/" + (asset.type || "css"); 13889 ele.rel = "stylesheet"; 13890 ele.href = asset.url; 13891 13892 asset.cssRetries = 0; 13893 asset.cssTimeout = window.setTimeout(isCssLoaded, 500); 13894 } 13895 else 13896 { 13897 ele = doc.createElement("script"); 13898 ele.type = "text/" + (asset.type || "javascript"); 13899 ele.src = asset.url; 13900 } 13901 13902 ele.onload = ele.onreadystatechange = process; 13903 ele.onerror = error; 13904 13905 ele.async = false; 13906 ele.defer = false; 13907 13908 asset.errorTimeout = window.setTimeout(function () { 13909 error({type: "timeout"}); 13910 }, 7000); 13911 13912 if (ext === "css") 13913 { 13914 cssList.push(normalizeMinUrl(normalizeUrl(asset.url))); 13915 } 13916 else 13917 { 13918 jsList.push(normalizeMinUrl(normalizeUrl(asset.url))); 13919 } 13920 13921 let templateLink = null; 13922 const head = doc.head || doc.getElementsByTagName("head")[0]; 13923 if (ext === "css" && (templateLink = getTemplateLink(head)) !== null) 13924 { 13925 templateLink.parentNode.insertBefore(ele, templateLink); 13926 } 13927 else 13928 { 13929 head.insertBefore(ele, head.lastChild); 13930 } 13931 } 13932 13933 function getAsset(item) 13934 { 13935 var asset = {}; 13936 if (typeof item === "object") 13937 { 13938 asset = item; 13939 asset.name = asset.name ? asset.name : BX.util.hashCode(item.url); 13940 } 13941 else 13942 { 13943 asset = { name: BX.util.hashCode(item), url : item }; 13944 } 13945 13946 var ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 13947 if ((ext === "css" && isCssLoaded(asset.url)) || isScriptLoaded(asset.url)) 13948 { 13949 asset.state = LOADED; 13950 } 13951 13952 var existing = assets[asset.name]; 13953 if (existing && existing.url === asset.url) 13954 { 13955 return existing; 13956 } 13957 13958 assets[asset.name] = asset; 13959 13960 return asset; 13961 } 13962 13963 function normalizeUrl(url) 13964 { 13965 if (!BX.type.isNotEmptyString(url)) 13966 { 13967 return ""; 13968 } 13969 13970 url = BX.getJSPath(url); 13971 url = url.replace(/\?[0-9]*$/, ""); 13972 13973 return url; 13974 } 13975 13976 function normalizeMinUrl(url) 13977 { 13978 if (!BX.type.isNotEmptyString(url)) 13979 { 13980 return ""; 13981 } 13982 13983 var minPos = url.indexOf(".min"); 13984 return minPos >= 0 ? url.substr(0, minPos) + url.substr(minPos + 4) : url; 13985 } 13986 13987 function isCssLoaded(fileSrc) 13988 { 13989 initCssList(); 13990 13991 fileSrc = normalizeUrl(fileSrc); 13992 var fileSrcMin = normalizeMinUrl(fileSrc); 13993 13994 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, cssList)) || BX.util.in_array(fileSrc, cssList); 13995 } 13996 13997 function initCssList() 13998 { 13999 if(!cssInit) 14000 { 14001 var linksCol = document.getElementsByTagName('link'); 14002 14003 if(!!linksCol && linksCol.length > 0) 14004 { 14005 for(var i = 0; i < linksCol.length; i++) 14006 { 14007 var href = linksCol[i].getAttribute('href'); 14008 if (BX.type.isNotEmptyString(href)) 14009 { 14010 href = normalizeMinUrl(normalizeUrl(href)); 14011 cssList.push(href); 14012 } 14013 } 14014 } 14015 cssInit = true; 14016 } 14017 } 14018 14019 function getTemplateLink(head) 14020 { 14021 var findLink = function(tag) 14022 { 14023 var links = head.getElementsByTagName(tag); 14024 for (var i = 0, length = links.length; i < length; i++) 14025 { 14026 var templateStyle = links[i].getAttribute("data-template-style"); 14027 if (BX.type.isNotEmptyString(templateStyle) && templateStyle == "true") 14028 { 14029 return links[i]; 14030 } 14031 } 14032 14033 return null; 14034 }; 14035 14036 var link = findLink("link"); 14037 if (link === null) 14038 { 14039 link = findLink("style"); 14040 } 14041 14042 return link; 14043 } 14044 14045 function isScriptLoaded(fileSrc) 14046 { 14047 initJsList(); 14048 14049 fileSrc = normalizeUrl(fileSrc); 14050 var fileSrcMin = normalizeMinUrl(fileSrc); 14051 14052 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, jsList)) || BX.util.in_array(fileSrc, jsList); 14053 } 14054 14055 function initJsList() 14056 { 14057 if(!jsInit) 14058 { 14059 var scriptCol = document.getElementsByTagName('script'); 14060 14061 if(!!scriptCol && scriptCol.length > 0) 14062 { 14063 for(var i=0; i<scriptCol.length; i++) 14064 { 14065 var src = scriptCol[i].getAttribute('src'); 14066 14067 if (BX.type.isNotEmptyString(src)) 14068 { 14069 src = normalizeMinUrl(normalizeUrl(src)); 14070 jsList.push(src); 14071 } 14072 } 14073 } 14074 jsInit = true; 14075 } 14076 } 14077 14078 function reloadInternal(back_url, bAddClearCache) 14079 { 14080 if (back_url === true) 14081 { 14082 bAddClearCache = true; 14083 back_url = null; 14084 } 14085 14086 var topWindow = (function() { 14087 if (BX.PageObject && BX.PageObject.getRootWindow) 14088 { 14089 return BX.PageObject.getRootWindow(); 14090 } 14091 14092 return window.top; 14093 })(); 14094 var new_href = back_url || topWindow.location.href; 14095 14096 var hashpos = new_href.indexOf('#'), hash = ''; 14097 14098 if (hashpos != -1) 14099 { 14100 hash = new_href.substr(hashpos); 14101 new_href = new_href.substr(0, hashpos); 14102 } 14103 14104 if (bAddClearCache && new_href.indexOf('clear_cache=Y') < 0) 14105 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + 'clear_cache=Y'; 14106 14107 if (hash) 14108 { 14109 // hack for clearing cache in ajax mode components with history emulation 14110 if (bAddClearCache && (hash.substr(0, 5) == 'view/' || hash.substr(0, 6) == '#view/') && hash.indexOf('clear_cache%3DY') < 0) 14111 hash += (hash.indexOf('%3F') == -1 ? '%3F' : '%26') + 'clear_cache%3DY'; 14112 14113 new_href = new_href.replace(/(\?|\&)_r=[\d]*/, ''); 14114 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + '_r='+Math.round(Math.random()*10000) + hash; 14115 } 14116 14117 topWindow.location.href = new_href; 14118 } 14119 14120 BX.reload = function(back_url, bAddClearCache) 14121 { 14122 if (window !== window.top) 14123 { 14124 BX.Runtime 14125 .loadExtension('main.pageobject') 14126 .then(function() { 14127 reloadInternal(back_url, bAddClearCache); 14128 }); 14129 } 14130 else 14131 { 14132 reloadInternal(back_url, bAddClearCache); 14133 } 14134 }; 14135 14136 BX.clearCache = function() 14137 { 14138 BX.showWait(); 14139 BX.reload(true); 14140 }; 14141 14142 BX.template = function(tpl, callback, bKillTpl) 14143 { 14144 BX.ready(function() { 14145 _processTpl(BX(tpl), callback, bKillTpl); 14146 }); 14147 }; 14148 14149 BX.isAmPmMode = function(returnConst) 14150 { 14151 if (returnConst === true) 14152 { 14153 return BX.message.AMPM_MODE; 14154 } 14155 return BX.message.AMPM_MODE !== false; 14156 }; 14157 14158 BX.formatDate = function(date, format) 14159 { 14160 date = date || new Date(); 14161 14162 var bTime = date.getHours() || date.getMinutes() || date.getSeconds(), 14163 str = !!format 14164 ? format : 14165 (bTime ? BX.message('FORMAT_DATETIME') : BX.message('FORMAT_DATE') 14166 ); 14167 14168 return str.replace(/YYYY/ig, date.getFullYear()) 14169 .replace(/MMMM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14170 .replace(/MM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14171 .replace(/DD/ig, BX.util.str_pad_left(date.getDate().toString(), 2, '0')) 14172 .replace(/HH/ig, BX.util.str_pad_left(date.getHours().toString(), 2, '0')) 14173 .replace(/MI/ig, BX.util.str_pad_left(date.getMinutes().toString(), 2, '0')) 14174 .replace(/SS/ig, BX.util.str_pad_left(date.getSeconds().toString(), 2, '0')); 14175 }; 14176 BX.formatName = function(user, template, login) 14177 { 14178 user = user || {}; 14179 template = (template || ''); 14180 var replacement = { 14181 TITLE : (user["TITLE"] || ''), 14182 NAME : (user["NAME"] || ''),
14183 LAST_NAME : (user["LAST_NAME"] || ''), 14184 SECOND_NAME : (user["SECOND_NAME"] || ''), 14185 LOGIN : (user["LOGIN"] || ''), 14186 NAME_SHORT : user["NAME"] ? user["NAME"].substr(0, 1) + '.' : '', 14187 LAST_NAME_SHORT : user["LAST_NAME"] ? user["LAST_NAME"].substr(0, 1) + '.' : '', 14188 SECOND_NAME_SHORT : user["SECOND_NAME"] ? user["SECOND_NAME"].substr(0, 1) + '.' : '', 14189 EMAIL : (user["EMAIL"] || ''), 14190 ID : (user["ID"] || ''), 14191 NOBR : "", 14192 '/NOBR' : "" 14193 }, result = template; 14194 for (var ii in replacement) 14195 { 14196 if (replacement.hasOwnProperty(ii)) 14197 { 14198 result = result.replace("#" + ii+ "#", replacement[ii]) 14199 } 14200 } 14201 result = result.replace(/([\s]+)/gi, " ").trim(); 14202 if (result == "") 14203 { 14204 result = (login == "Y" ? replacement["LOGIN"] : ""); 14205 result = (result == "" ? "Noname" : result); 14206 } 14207 return result; 14208 }; 14209 14210 BX.getNumMonth = function(month) 14211 { 14212 var wordMonthCut = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; 14213 var wordMonth = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']; 14214 14215 var q = month.toUpperCase(); 14216 for (i = 1; i <= 12; i++) 14217 { 14218 if (q == BX.message('MON_'+i).toUpperCase() || q == BX.message('MONTH_'+i).toUpperCase() || q == wordMonthCut[i-1].toUpperCase() || q == wordMonth[i-1].toUpperCase()) 14219 { 14220 return i; 14221 } 14222 } 14223 return month; 14224 }; 14225 14226 BX.parseDate = function(str, bUTC, formatDate, formatDatetime) 14227 { 14228 if (BX.type.isNotEmptyString(str)) 14229 { 14230 if (!formatDate) 14231 formatDate = BX.message('FORMAT_DATE'); 14232 if (!formatDatetime) 14233 formatDatetime = BX.message('FORMAT_DATETIME'); 14234 14235 var regMonths = ''; 14236 for (i = 1; i <= 12; i++) 14237 { 14238 regMonths = regMonths + '|' + BX.message('MON_'+i); 14239 } 14240
14241 var expr = new RegExp('([0-9]+|[a-z]+' + regMonths + ')', 'ig'); 14242 var aDate = str.match(expr), 14243 aFormat = formatDate.match(/(DD|MI|MMMM|MM|M|YYYY)/ig), 14244 i, cnt, 14245 aDateArgs=[], aFormatArgs=[], 14246 aResult={}; 14247 14248 if (!aDate) 14249 return null; 14250 14251 if(aDate.length > aFormat.length) 14252 { 14253 aFormat = formatDatetime.match(/(DD|MI|MMMM|MM|M|YYYY|HH|H|SS|TT|T|GG|G)/ig); 14254 } 14255 14256 for(i = 0, cnt = aDate.length; i < cnt; i++) 14257 { 14258 if(BX.util.trim(aDate[i]) != '') 14259 { 14260 aDateArgs[aDateArgs.length] = aDate[i]; 14261 } 14262 } 14263 14264 for(i = 0, cnt = aFormat.length; i < cnt; i++) 14265 { 14266 if(BX.util.trim(aFormat[i]) != '') 14267 { 14268 aFormatArgs[aFormatArgs.length] = aFormat[i]; 14269 } 14270 } 14271 14272 14273 var m = BX.util.array_search('MMMM', aFormatArgs); 14274 if (m > 0) 14275 { 14276 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 14277 aFormatArgs[m] = "MM"; 14278 } 14279 else 14280 { 14281 m = BX.util.array_search('M', aFormatArgs); 14282 if (m > 0) 14283 { 14284 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 14285 aFormatArgs[m] = "MM"; 14286 } 14287 } 14288 14289 for(i = 0, cnt = aFormatArgs.length; i < cnt; i++) 14290 { 14291 var k = aFormatArgs[i].toUpperCase(); 14292 aResult[k] = k == 'T' || k == 'TT' ? aDateArgs[i] : parseInt(aDateArgs[i], 10); 14293 } 14294 14295 if(aResult['DD'] > 0 && aResult['MM'] > 0 && aResult['YYYY'] > 0) 14296 { 14297 var d = new Date(); 14298 14299 if(bUTC) 14300 { 14301 d.setUTCDate(1); 14302 d.setUTCFullYear(aResult['YYYY']); 14303 d.setUTCMonth(aResult['MM'] - 1); 14304 d.setUTCDate(aResult['DD']); 14305 d.setUTCHours(0, 0, 0, 0); 14306 } 14307 else 14308 { 14309 d.setDate(1); 14310 d.setFullYear(aResult['YYYY']); 14311 d.setMonth(aResult['MM'] - 1); 14312 d.setDate(aResult['DD']); 14313 d.setHours(0, 0, 0, 0); 14314 } 14315 14316 if( 14317 (!isNaN(aResult['HH']) || !isNaN(aResult['GG']) || !isNaN(aResult['H']) || !isNaN(aResult['G'])) 14318 && !isNaN(aResult['MI']) 14319 ) 14320 { 14321 if (!isNaN(aResult['H']) || !isNaN(aResult['G'])) 14322 { 14323 var bPM = (aResult['T']||aResult['TT']||'am').toUpperCase()=='PM'; 14324 var h = parseInt(aResult['H']||aResult['G']||0, 10); 14325 if(bPM) 14326 { 14327 aResult['HH'] = h + (h == 12 ? 0 : 12); 14328 } 14329 else 14330 { 14331 aResult['HH'] = h < 12 ? h : 0; 14332 } 14333 } 14334 else 14335 { 14336 aResult['HH'] = parseInt(aResult['HH']||aResult['GG']||0, 10); 14337 } 14338 14339 if (isNaN(aResult['SS'])) 14340 aResult['SS'] = 0; 14341 14342 if(bUTC) 14343 { 14344 d.setUTCHours(aResult['HH'], aResult['MI'], aResult['SS']); 14345 } 14346 else 14347 { 14348 d.setHours(aResult['HH'], aResult['MI'], aResult['SS']); 14349 } 14350 } 14351 14352 return d; 14353 } 14354 } 14355 14356 return null; 14357 }; 14358 14359 BX.selectUtils = 14360 { 14361 addNewOption: function(oSelect, opt_value, opt_name, do_sort, check_unique) 14362 { 14363 oSelect = BX(oSelect); 14364 if(oSelect) 14365 { 14366 var n = oSelect.length; 14367 if(check_unique !== false) 14368 { 14369 for(var i=0;i<n;i++) 14370 { 14371 if(oSelect[i].value==opt_value) 14372 { 14373 return; 14374 } 14375 } 14376 } 14377 14378 oSelect.options[n] = new Option(opt_name, opt_value, false, false); 14379 } 14380 14381 if(do_sort === true) 14382 { 14383 this.sortSelect(oSelect); 14384 } 14385 }, 14386 14387 deleteOption: function(oSelect, opt_value) 14388 { 14389 oSelect = BX(oSelect); 14390 if(oSelect) 14391 { 14392 for(var i=0;i<oSelect.length;i++) 14393 { 14394 if(oSelect[i].value==opt_value) 14395 { 14396 oSelect.remove(i); 14397 break; 14398 } 14399 } 14400 } 14401 }, 14402 14403 deleteSelectedOptions: function(oSelect) 14404 { 14405 oSelect = BX(oSelect); 14406 if(oSelect) 14407 { 14408 var i=0; 14409 while(i<oSelect.length) 14410 { 14411 if(oSelect[i].selected) 14412 { 14413 oSelect[i].selected=false; 14414 oSelect.remove(i); 14415 } 14416 else 14417 { 14418 i++; 14419 } 14420 } 14421 } 14422 }, 14423 14424 deleteAllOptions: function(oSelect) 14425 { 14426 oSelect = BX(oSelect); 14427 if(oSelect) 14428 { 14429 for(var i=oSelect.length-1; i>=0; i--) 14430 { 14431 oSelect.remove(i); 14432 } 14433 } 14434 }, 14435 14436 optionCompare: function(record1, record2) 14437 { 14438 var value1 = record1.optText.toLowerCase(); 14439 var value2 = record2.optText.toLowerCase(); 14440 if (value1 > value2) return(1); 14441 if (value1 < value2) return(-1); 14442 return(0); 14443 }, 14444 14445 sortSelect: function(oSelect) 14446 { 14447 oSelect = BX(oSelect); 14448 if(oSelect) 14449 { 14450 var myOptions = []; 14451 var n = oSelect.options.length; 14452 var i; 14453 for (i=0;i<n;i++) 14454 { 14455 myOptions[i] = { 14456 optText:oSelect[i].text, 14457 optValue:oSelect[i].value 14458 }; 14459 } 14460 myOptions.sort(this.optionCompare); 14461 oSelect.length=0; 14462 n = myOptions.length; 14463 for(i=0;i<n;i++) 14464 { 14465 oSelect[i] = new Option(myOptions[i].optText, myOptions[i].optValue, false, false); 14466 } 14467 } 14468 }, 14469 14470 selectAllOptions: function(oSelect) 14471 { 14472 oSelect = BX(oSelect); 14473 if(oSelect) 14474 { 14475 var n = oSelect.length; 14476 for(var i=0;i<n;i++) 14477 { 14478 oSelect[i].selected=true; 14479 } 14480 } 14481 }, 14482 14483 selectOption: function(oSelect, opt_value) 14484 { 14485 oSelect = BX(oSelect); 14486 if(oSelect) 14487 { 14488 var n = oSelect.length; 14489 for(var i=0;i<n;i++) 14490 { 14491 oSelect[i].selected = (oSelect[i].value == opt_value); 14492 } 14493 } 14494 }, 14495 14496 addSelectedOptions: function(oSelect, to_select_id, check_unique, do_sort) 14497 { 14498 oSelect = BX(oSelect); 14499 if(!oSelect) 14500 return; 14501 var n = oSelect.length; 14502 for(var i=0; i<n; i++) 14503 if(oSelect[i].selected) 14504 this.addNewOption(to_select_id, oSelect[i].value, oSelect[i].text, do_sort, check_unique); 14505 }, 14506 14507 moveOptionsUp: function(oSelect) 14508 { 14509 oSelect = BX(oSelect); 14510 if(!oSelect) 14511 return; 14512 var n = oSelect.length; 14513 for(var i=0; i<n; i++) 14514 { 14515 if(oSelect[i].selected && i>0 && oSelect[i-1].selected == false) 14516 { 14517 var option = new Option(oSelect[i].text, oSelect[i].value); 14518 oSelect[i] = new Option(oSelect[i-1].text, oSelect[i-1].value); 14519 oSelect[i].selected = false;
14520 oSelect[i-1] = option; 14521 oSelect[i-1].selected = true; 14522 } 14523 } 14524 }, 14525 14526 moveOptionsDown: function(oSelect) 14527 { 14528 oSelect = BX(oSelect); 14529 if(!oSelect) 14530 return; 14531 var n = oSelect.length; 14532 for(var i=n-1; i>=0; i--) 14533 { 14534 if(oSelect[i].selected && i<n-1 && oSelect[i+1].selected == false) 14535 { 14536 var option = new Option(oSelect[i].text, oSelect[i].value); 14537 oSelect[i] = new Option(oSelect[i+1].text, oSelect[i+1].value); 14538 oSelect[i].selected = false; 14539 oSelect[i+1] = option; 14540 oSelect[i+1].selected = true; 14541 } 14542 } 14543 } 14544 }; 14545 14546 BX.getEventTarget = function(e) 14547 { 14548 if(e.target) 14549 { 14550 return e.target; 14551 } 14552 else if(e.srcElement) 14553 { 14554 return e.srcElement; 14555 } 14556 return null; 14557 }; 14558 14559 BX.convert = { 14560 toNumber: function(value) 14561 { 14562 if(BX.type.isNumber(value)) 14563 { 14564 return value; 14565 } 14566 14567 value = Number(value); 14568 return !isNaN(value) ? value : 0; 14569 }, 14570 nodeListToArray: function(nodes) 14571 { 14572 try 14573 { 14574 return (Array.prototype.slice.call(nodes, 0)); 14575 } 14576 catch (ex) 14577 { 14578 var ary = []; 14579 for(var i = 0, l = nodes.length; i < l; i++) 14580 { 14581 ary.push(nodes[i]); 14582 } 14583 return ary; 14584 } 14585 } 14586 }; 14587 14588 /******* HINT ***************/ 14589// if function has 2 params - the 2nd one is hint html. otherwise hint_html is third and hint_title - 2nd; 14590// '<div onmouseover="BX.hint(this, 'This is <b>Hint</b>')"'>; 14591// BX.hint(el, 'This is <b>Hint</b>') - this won't work, use constructor 14592 BX.hint = function(el, hint_title, hint_html, hint_id) 14593 { 14594 if (null == hint_html) 14595 { 14596 hint_html = hint_title; 14597 hint_title = ''; 14598 } 14599 14600 if (null == el.BXHINT) 14601 { 14602 el.BXHINT = new BX.CHint({ 14603 parent: el, hint: hint_html, title: hint_title, id: hint_id 14604 }); 14605 el.BXHINT.Show(); 14606 } 14607 }; 14608 14609 BX.hint_replace = function(el, hint_title, hint_html) 14610 { 14611 if (null == hint_html) 14612 { 14613 hint_html = hint_title; 14614 hint_title = ''; 14615 } 14616 14617 if (!el || !el.parentNode || !hint_html) 14618 return null; 14619 14620 var obHint = new BX.CHint({ 14621 hint: hint_html, 14622 title: hint_title 14623 }); 14624 14625 obHint.CreateParent(); 14626 14627 el.parentNode.insertBefore(obHint.PARENT, el); 14628 el.parentNode.removeChild(el); 14629 14630 obHint.PARENT.style.marginLeft = '5px'; 14631 14632 return el; 14633 }; 14634 14635 BX.CHint = function(params) 14636 { 14637 if (BX.CHint.cssLoaded === false) 14638 { 14639 BX.load(['/bitrix/js/main/core/css/core_hint.css']); 14640 BX.CHint.cssLoaded = true; 14641 } 14642 14643 this.PARENT = BX(params.parent); 14644 14645 this.HINT = params.hint; 14646 this.HINT_TITLE = params.title; 14647 14648 this.PARAMS = {}; 14649 for (var i in this.defaultSettings) 14650 { 14651 if (null == params[i]) 14652 this.PARAMS[i] = this.defaultSettings[i]; 14653 else 14654 this.PARAMS[i] = params[i]; 14655 } 14656 14657 if (null != params.id) 14658 this.ID = params.id; 14659 14660 this.timer = null; 14661 this.bInited = false; 14662 this.msover = true; 14663 14664 if (this.PARAMS.showOnce) 14665 { 14666 this.__show(); 14667 this.msover = false; 14668 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14669 } 14670 else if (this.PARENT) 14671 { 14672 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14673 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14674 } 14675 }; 14676 14677 BX.CHint.cssLoaded = false; 14678 14679 BX.CHint.openHints = new Set(); 14680 14681 BX.CHint.globalDisabled = false; 14682 14683 BX.CHint.handleMenuOpen = function() { 14684 BX.CHint.globalDisabled = true; 14685 14686 BX.CHint.openHints.forEach(function(hint) { 14687 hint.__hide_immediately(); 14688 }); 14689 }; 14690 14691 BX.CHint.handleMenuClose = function() { 14692 BX.CHint.globalDisabled = false; 14693 }; 14694 14695 BX.addCustomEvent('onMenuOpen', BX.CHint.handleMenuOpen); 14696 BX.addCustomEvent('onMenuClose', BX.CHint.handleMenuClose); 14697 14698 BX.CHint.prototype.defaultSettings = { 14699 show_timeout: 1000, 14700 hide_timeout: 500, 14701 dx: 2, 14702 showOnce: false, 14703 preventHide: true, 14704 min_width: 250 14705 }; 14706 14707 BX.CHint.prototype.CreateParent = function(element, params) 14708 { 14709 if (this.PARENT) 14710 { 14711 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14712 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14713 } 14714 14715 if (!params) params = {}; 14716 var type = 'icon'; 14717 14718 if (params.type && (params.type == "link" || params.type == "icon")) 14719 type = params.type; 14720 14721 if (element) 14722 type = "element";
14723 14724 if (type == "icon") 14725 { 14726 element = BX.create('IMG', { 14727 props: { 14728 src: params.iconSrc 14729 ? params.iconSrc 14730 : "/bitrix/js/main/core/images/hint.gif" 14731 } 14732 }); 14733 } 14734 else if (type == "link") 14735 { 14736 element = BX.create("A", { 14737 props: {href: 'javascript:void(0)'}, 14738 html: '[?]' 14739 }); 14740 } 14741 14742 this.PARENT = element; 14743 14744 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14745 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14746 14747 return this.PARENT; 14748 }; 14749 14750 BX.CHint.prototype.Show = function() 14751 { 14752 this.msover = true; 14753 14754 if (null != this.timer) 14755 clearTimeout(this.timer); 14756 14757 this.timer = setTimeout(BX.proxy(this.__show, this), this.PARAMS.show_timeout); 14758 }; 14759 14760 BX.CHint.prototype.Hide = function() 14761 { 14762 this.msover = false; 14763 14764 if (null != this.timer) 14765 clearTimeout(this.timer); 14766 14767 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14768 }; 14769 14770 BX.CHint.prototype.__show = function() 14771 { 14772 if (!this.msover || this.disabled || BX.CHint.globalDisabled) return; 14773 if (!this.bInited) this.Init(); 14774 14775 if (this.prepareAdjustPos()) 14776 { 14777 this.DIV.style.display = 'block'; 14778 BX.ZIndexManager.bringToFront(this.DIV); 14779 14780 this.adjustPos(); 14781 14782 BX.CHint.openHints.add(this); 14783 14784 BX.bind(window, 'scroll', BX.proxy(this.__onscroll, this)); 14785 14786 if (this.PARAMS.showOnce) 14787 { 14788 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14789 } 14790 } 14791 }; 14792 14793 BX.CHint.prototype.__onscroll = function() 14794 { 14795 if (!BX.admin || !BX.admin.panel || !BX.admin.panel.isFixed()) return; 14796 14797 if (this.scrollTimer) clearTimeout(this.scrollTimer); 14798 14799 this.DIV.style.display = 'none'; 14800 this.scrollTimer = setTimeout(BX.proxy(this.Reopen, this), this.PARAMS.show_timeout); 14801 }; 14802 14803 BX.CHint.prototype.Reopen = function() 14804 { 14805 if (null != this.timer) clearTimeout(this.timer); 14806 this.timer = setTimeout(BX.proxy(this.__show, this), 50); 14807 }; 14808 14809 BX.CHint.prototype.__hide = function() 14810 { 14811 if (this.msover) return; 14812 if (!this.bInited) return; 14813 14814 BX.unbind(window, 'scroll', BX.proxy(this.Reopen, this)); 14815 14816 BX.CHint.openHints.delete(this); 14817 14818 if (this.PARAMS.showOnce) 14819 { 14820 this.Destroy(); 14821 } 14822 else 14823 { 14824 this.DIV.style.display = 'none'; 14825 } 14826 }; 14827 14828 BX.CHint.prototype.__hide_immediately = function() 14829 { 14830 this.msover = false; 14831 this.__hide(); 14832 }; 14833 14834 BX.CHint.prototype.Init = function() 14835 { 14836 this.DIV = document.body.appendChild(BX.create('DIV', { 14837 props: {className: 'bx-panel-tooltip'}, 14838 style: { 14839 display: 'none', 14840 position: 'absolute', 14841 visibility: 'hidden' 14842 }, 14843 children: [ 14844 (this.CONTENT = BX.create('DIV', { 14845 props: {className: 'bx-panel-tooltip-content'}, 14846 children: [ 14847 BX.create('DIV', { 14848 props: {className: 'bx-panel-tooltip-underlay'}, 14849 children: [ 14850 BX.create('DIV', {props: {className: 'bx-panel-tooltip-underlay-bg'}}) 14851 ] 14852 }) 14853 ] 14854 })) 14855 ] 14856 })); 14857 14858 BX.ZIndexManager.register(this.DIV); 14859 14860 if (this.ID) 14861 { 14862 this.CONTENT.insertBefore(BX.create('A', { 14863 attrs: {href: 'javascript:void(0)'}, 14864 props: {className: 'bx-panel-tooltip-close'}, 14865 events: {click: BX.delegate(this.Close, this)} 14866 }), this.CONTENT.firstChild); 14867 } 14868 14869 if (this.HINT_TITLE) 14870 { 14871 this.CONTENT.appendChild( 14872 BX.create('DIV', { 14873 props: {className: 'bx-panel-tooltip-title'}, 14874 text: this.HINT_TITLE 14875 }) 14876 ); 14877 } 14878 14879 if (this.HINT) 14880 { 14881 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 14882 } 14883 14884 if (this.PARAMS.preventHide) 14885 { 14886 BX.bind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 14887 BX.bind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 14888 } 14889 14890 this.bInited = true; 14891 }; 14892 14893 BX.CHint.prototype.setContent = function(content) 14894 { 14895 this.HINT = content; 14896 14897 if (this.CONTENT_TEXT) 14898 this.CONTENT_TEXT.innerHTML = this.HINT; 14899 else 14900 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 14901 }; 14902 14903 BX.CHint.prototype.prepareAdjustPos = function() 14904 { 14905 this._wnd = {scrollPos: BX.GetWindowScrollPos(),scrollSize:BX.GetWindowScrollSize()}; 14906 return BX.style(this.PARENT, 'display') != 'none'; 14907 }; 14908 14909 BX.CHint.prototype.getAdjustPos = function() 14910 { 14911 var res = {}, pos = BX.pos(this.PARENT), min_top = 0; 14912 14913 res.top = pos.bottom + this.PARAMS.dx; 14914 14915 if (BX.admin && BX.admin.panel.DIV) 14916 { 14917 min_top = BX.admin.panel.DIV.offsetHeight + this.PARAMS.dx; 14918 14919 if (BX.admin.panel.isFixed()) 14920 { 14921 min_top += this._wnd.scrollPos.scrollTop; 14922 } 14923 } 14924 14925 if (res.top < min_top) 14926 res.top = min_top; 14927 else 14928 { 14929 if (res.top + this.DIV.offsetHeight > this._wnd.scrollSize.scrollHeight) 14930 res.top = pos.top - this.PARAMS.dx - this.DIV.offsetHeight; 14931 } 14932 14933 res.left = pos.left; 14934 if (pos.left < this.PARAMS.dx) 14935 pos.left = this.PARAMS.dx; 14936 else 14937 { 14938 var floatWidth = this.DIV.offsetWidth; 14939 14940 var max_left = this._wnd.scrollSize.scrollWidth - floatWidth - this.PARAMS.dx; 14941 14942 if (res.left > max_left) 14943 res.left = max_left; 14944 } 14945 14946 return res; 14947 }; 14948 14949 BX.CHint.prototype.adjustWidth = function() 14950 { 14951 if (this.bWidthAdjusted) return; 14952 14953 var w = this.DIV.offsetWidth, h = this.DIV.offsetHeight; 14954 14955 if (w > this.PARAMS.min_width) 14956 w = Math.round(Math.sqrt(1.618*w*h)); 14957 14958 if (w < this.PARAMS.min_width) 14959 w = this.PARAMS.min_width; 14960 14961 this.DIV.style.width = w + "px"; 14962 14963 if (this._adjustWidthInt) 14964 clearInterval(this._adjustWidthInt); 14965 this._adjustWidthInt = setInterval(BX.delegate(this._adjustWidthInterval, this), 5); 14966 14967 this.bWidthAdjusted = true; 14968 }; 14969 14970 BX.CHint.prototype._adjustWidthInterval = function() 14971 { 14972 if (!this.DIV || this.DIV.style.display == 'none') 14973 clearInterval(this._adjustWidthInt); 14974 14975 var
14976 dW = 20, 14977 maxWidth = 1500, 14978 w = this.DIV.offsetWidth, 14979 w1 = this.CONTENT_TEXT.offsetWidth; 14980 14981 if (w > 0 && w1 > 0 && w - w1 < dW && w < maxWidth) 14982 { 14983 this.DIV.style.width = (w + dW) + "px"; 14984 return; 14985 } 14986 14987 clearInterval(this._adjustWidthInt); 14988 }; 14989 14990 BX.CHint.prototype.adjustPos = function() 14991 { 14992 this.adjustWidth(); 14993 14994 var pos = this.getAdjustPos(); 14995 14996 this.DIV.style.top = pos.top + 'px'; 14997 this.DIV.style.left = pos.left + 'px'; 14998 }; 14999 15000 BX.CHint.prototype.Close = function() 15001 { 15002 if (this.ID && BX.WindowManager) 15003 BX.WindowManager.saveWindowOptions(this.ID, {display: 'off'}); 15004 this.__hide_immediately(); 15005 this.Destroy(); 15006 }; 15007 15008 BX.CHint.prototype.Destroy = function() 15009 { 15010 if (this.PARENT) 15011 { 15012 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 15013 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 15014 } 15015 15016 if (this.DIV) 15017 { 15018 BX.unbind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 15019 BX.unbind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 15020 15021 BX.ZIndexManager.unregister(this.DIV); 15022 15023 BX.cleanNode(this.DIV, true); 15024 } 15025 }; 15026 15027 BX.CHint.prototype.enable = function(){this.disabled = false;}; 15028 BX.CHint.prototype.disable = function(){this.__hide_immediately(); this.disabled = true;}; 15029 15030 15031 function _adjustWait() 15032 { 15033 if (!this.bxmsg) return; 15034 15035 var arContainerPos = BX.pos(this), 15036 div_top = arContainerPos.top; 15037 15038 if (div_top < BX.GetDocElement().scrollTop) 15039 div_top = BX.GetDocElement().scrollTop + 5; 15040 15041 this.bxmsg.style.top = (div_top + 5) + 'px'; 15042 15043 if (this == BX.GetDocElement()) 15044 { 15045 this.bxmsg.style.right = '5px'; 15046 } 15047 else 15048 { 15049 this.bxmsg.style.left = (arContainerPos.right - this.bxmsg.offsetWidth - 5) + 'px'; 15050 } 15051 } 15052 15053 function _processTpl(tplNode, cb, bKillTpl) 15054 { 15055 if (tplNode) 15056 { 15057 if (bKillTpl) 15058 tplNode.parentNode.removeChild(tplNode); 15059 15060 var res = {}, nodes = BX.findChildren(tplNode, {attribute: 'data-role'}, true); 15061 15062 for (var i = 0, l = nodes.length; i < l; i++) 15063 { 15064 res[nodes[i].getAttribute('data-role')] = nodes[i]; 15065 } 15066 15067 cb.apply(tplNode, [res]); 15068 } 15069 } 15070 15071 function _checkNode(obj, params) 15072 { 15073 params = params || {}; 15074 15075 if (BX.type.isFunction(params)) 15076 return params.call(window, obj); 15077 15078 if (!params.allowTextNodes && !BX.type.isElementNode(obj)) 15079 return false; 15080 var i,j,len; 15081 for (i in params) 15082 { 15083 if(params.hasOwnProperty(i)) 15084 { 15085 switch(i) 15086 { 15087 case 'tag': 15088 case 'tagName': 15089 if (BX.type.isString(params[i])) 15090 { 15091 if (obj.tagName.toUpperCase() != params[i].toUpperCase()) 15092 return false; 15093 } 15094 else if (params[i] instanceof RegExp) 15095 { 15096 if (!params[i].test(obj.tagName)) 15097 return false; 15098 } 15099 break; 15100 15101 case 'class': 15102 case 'className': 15103 if (BX.type.isString(params[i])) 15104 { 15105 if (!BX.hasClass(obj, params[i])) 15106 return false; 15107 } 15108 else if (params[i] instanceof RegExp) 15109 { 15110 if (!BX.type.isString(obj.className) || !params[i].test(obj.className)) 15111 return false; 15112 } 15113 break; 15114 15115 case 'attr': 15116 case 'attrs': 15117 case 'attribute': 15118 if (BX.type.isString(params[i])) 15119 { 15120 if (!obj.getAttribute(params[i])) 15121 return false; 15122 } 15123 else if (BX.type.isArray(params[i])) 15124 { 15125 for (j = 0, len = params[i].length; j < len; j++) 15126 { 15127 if (params[i] && !obj.getAttribute(params[i])) 15128 return false; 15129 } 15130 } 15131 else 15132 { 15133 for (j in params[i]) 15134 { 15135 if(params[i].hasOwnProperty(j)) 15136 { 15137 var q = obj.getAttribute(j); 15138 if (params[i][j] instanceof RegExp) 15139 { 15140 if (!BX.type.isString(q) || !params[i][j].test(q)) 15141 { 15142 return false; 15143 } 15144 } 15145 else 15146 { 15147 if (q != '' + params[i][j]) 15148 { 15149 return false; 15150 } 15151 } 15152 } 15153 } 15154 } 15155 break; 15156 15157 case 'property': 15158 case 'props': 15159 if (BX.type.isString(params[i])) 15160 { 15161 if (!obj[params[i]]) 15162 return false; 15163 } 15164 else if (BX.type.isArray(params[i])) 15165 { 15166 for (j = 0, len = params[i].length; j < len; j++) 15167 { 15168 if (params[i] && !obj[params[i]]) 15169 return false;
15170 } 15171 } 15172 else 15173 { 15174 for (j in params[i]) 15175 { 15176 if (BX.type.isString(params[i][j])) 15177 { 15178 if (obj[j] != params[i][j]) 15179 return false; 15180 } 15181 else if (params[i][j] instanceof RegExp) 15182 { 15183 if (!BX.type.isString(obj[j]) || !params[i][j].test(obj[j])) 15184 return false; 15185 } 15186 } 15187 } 15188 break; 15189 15190 case 'callback': 15191 return params[i](obj); 15192 } 15193 } 15194 } 15195 15196 return true; 15197 } 15198 15199 /* garbage collector */ 15200 function Trash() 15201 { 15202 var i,len; 15203 15204 for (i = 0, len = garbageCollectors.length; i<len; i++) 15205 { 15206 try { 15207 garbageCollectors[i].callback.apply(garbageCollectors[i].context || window); 15208 delete garbageCollectors[i]; 15209 garbageCollectors[i] = null; 15210 } catch (e) {} 15211 } 15212 } 15213 15214 if(window.attachEvent) // IE 15215 window.attachEvent("onunload", Trash); 15216 else if(window.addEventListener) // Gecko / W3C 15217 window.addEventListener('unload', Trash, false); 15218 else 15219 window.onunload = Trash; 15220 /* \garbage collector */ 15221 15222// set empty ready handler 15223 BX(BX.DoNothing); 15224 window.BX = BX; 15225 15226 BX.browser.addGlobalClass(); 15227 15228 /* data storage */ 15229 BX.data = function(node, key, value) 15230 { 15231 if(typeof node == 'undefined') 15232 return undefined; 15233 15234 if(typeof key == 'undefined') 15235 return undefined; 15236 15237 if(typeof value != 'undefined') 15238 { 15239 // write to manager 15240 dataStorage.set(node, key, value); 15241 } 15242 else 15243 { 15244 var data; 15245 15246 // from manager 15247 if((data = dataStorage.get(node, key)) != undefined) 15248 { 15249 return data; 15250 } 15251 else 15252 { 15253 // from attribute data-* 15254 if('getAttribute' in node) 15255 { 15256 data = node.getAttribute('data-'+key.toString()); 15257 if(data === null) 15258 { 15259 return undefined; 15260 } 15261 return data; 15262 } 15263 } 15264 15265 return undefined; 15266 } 15267 }; 15268 15269 BX.DataStorage = function() 15270 { 15271 15272 this.keyOffset = 1; 15273 this.data = {}; 15274 this.uniqueTag = 'BX-'+Math.random(); 15275 15276 this.resolve = function(owner, create){ 15277 if(typeof owner[this.uniqueTag] == 'undefined') 15278 if(create) 15279 { 15280 try 15281 { 15282 Object.defineProperty(owner, this.uniqueTag, { 15283 value: this.keyOffset++ 15284 }); 15285 } 15286 catch(e) 15287 { 15288 owner[this.uniqueTag] = this.keyOffset++; 15289 } 15290 } 15291 else 15292 return undefined; 15293 15294 return owner[this.uniqueTag]; 15295 }; 15296 this.get = function(owner, key){ 15297 if((owner != document && !BX.type.isElementNode(owner)) || typeof key == 'undefined') 15298 return undefined; 15299 15300 owner = this.resolve(owner, false); 15301 15302 if(typeof owner == 'undefined' || typeof this.data[owner] == 'undefined') 15303 return undefined; 15304 15305 return this.data[owner][key]; 15306 }; 15307 this.set = function(owner, key, value){ 15308 15309 if((owner != document && !BX.type.isElementNode(owner)) || typeof value == 'undefined') 15310 return; 15311 15312 var o = this.resolve(owner, true); 15313 15314 if(typeof this.data[o] == 'undefined') 15315 this.data[o] = {}; 15316 15317 this.data[o][key] = value; 15318 }; 15319 }; 15320 15321// some internal variables for new logic 15322 var dataStorage = new BX.DataStorage(); // manager which BX.data() uses to keep data 15323})(window.BX); 15324 15325;(function(window) 15326{ 15327 /****************** ATTENTION ******************************* 15328 * Please do not use Bitrix CoreJS in this class. 15329 * This class can be called on page without Bitrix Framework 15330 *************************************************************/ 15331 15332 if (!window.BX) 15333 { 15334 window.BX = {}; 15335 } 15336 15337 var BX = window.BX; 15338 15339 BX.Promise = function(fn, ctx) // fn is future-reserved 15340 { 15341 this.state = null; 15342 this.value = null; 15343 this.reason = null; 15344 this.next = null; 15345 this.ctx = ctx || this; 15346 15347 this.onFulfilled = []; 15348 this.onRejected = []; 15349 }; 15350 BX.Promise.prototype.fulfill = function(value) 15351 { 15352 this.checkState(); 15353 15354 this.value = value; 15355 this.state = true; 15356 this.execute(); 15357 }; 15358 BX.Promise.prototype.reject = function(reason) 15359 { 15360 this.checkState(); 15361 15362 this.reason = reason; 15363 this.state = false; 15364 this.execute(); 15365 }; 15366 BX.Promise.prototype.then = function(onFulfilled, onRejected) 15367 { 15368 if(typeof (onFulfilled) == "function" || onFulfilled instanceof Function) 15369 { 15370 this.onFulfilled.push(onFulfilled); 15371 } 15372 if(typeof (onRejected) == "function" || onRejected instanceof Function) 15373 { 15374 this.onRejected.push(onRejected); 15375 } 15376 15377 if(this.next === null) 15378 { 15379 this.next = new BX.Promise(null, this.ctx); 15380 } 15381 15382 if(this.state !== null) // if promise was already resolved, execute immediately 15383 { 15384 this.execute(); 15385 } 15386 15387 return this.next; 15388 }; 15389 15390 BX.Promise.prototype.catch = function(onRejected) 15391 { 15392 if(typeof (onRejected) == "function" || onRejected instanceof Function) 15393 { 15394 this.onRejected.push(onRejected); 15395 } 15396 15397 if(this.next === null) 15398 { 15399 this.next = new BX.Promise(null, this.ctx); 15400 } 15401 15402 if(this.state !== null) // if promise was already resolved, execute immediately 15403 { 15404 this.execute(); 15405 } 15406 15407 return this.next; 15408 }; 15409 15410 BX.Promise.prototype.setAutoResolve = function(way, ms) 15411 { 15412 this.timer = setTimeout(function(){ 15413 if(this.state === null) 15414 { 15415 this[way ? 'fulfill' : 'reject'](); 15416 } 15417 }.bind(this), ms || 15); 15418 };
15419 BX.Promise.prototype.cancelAutoResolve = function() 15420 { 15421 clearTimeout(this.timer); 15422 }; 15423 /** 15424 * Resolve function. This function allows promise chaining, like ..then().then()... 15425 * Typical usage: 15426 * 15427 * var p = new Promise(); 15428 * 15429 * p.then(function(value){ 15430 * return someValue; // next promise in the chain will be fulfilled with someValue 15431 * }).then(function(value){ 15432 * 15433 * var p1 = new Promise(); 15434 * *** some async code here, that eventually resolves p1 *** 15435 * 15436 * return p1; // chain will resume when p1 resolved (fulfilled or rejected) 15437 * }).then(function(value){ 15438 * 15439 * // you can also do 15440 * var e = new Error(); 15441 * throw e; 15442 * // it will cause next promise to be rejected with e 15443 * 15444 * return someOtherValue; 15445 * }).then(function(value){ 15446 * ... 15447 * }, function(reason){ 15448 * // promise was rejected with reason 15449 * })...; 15450 * 15451 * p.fulfill('let`s start this chain'); 15452 * 15453 * @param x 15454 */ 15455 BX.Promise.prototype.resolve = function(x) 15456 { 15457 var this_ = this; 15458 15459 if(this === x) 15460 { 15461 this.reject(new TypeError('Promise cannot fulfill or reject itself')); // avoid recursion 15462 } 15463 // allow "pausing" promise chaining until promise x is fulfilled or rejected 15464 else if(x && x.toString() === "[object BX.Promise]") 15465 { 15466 x.then(function(value){ 15467 this_.fulfill(value); 15468 }, function(reason){ 15469 this_.reject(reason); 15470 }); 15471 } 15472 else // auto-fulfill this promise 15473 { 15474 this.fulfill(x); 15475 } 15476 }; 15477 15478 BX.Promise.prototype.toString = function() 15479 { 15480 return "[object BX.Promise]"; 15481 }; 15482 15483 BX.Promise.prototype.execute = function() 15484 { 15485 if(this.state === null) 15486 { 15487 //then() must not be called before BX.Promise resolve() happens 15488 return; 15489 } 15490 15491 var value = undefined; 15492 var reason = undefined; 15493 var x = undefined; 15494 var k; 15495 if(this.state === true) // promise was fulfill()-ed 15496 { 15497 if(this.onFulfilled.length) 15498 { 15499 try 15500 { 15501 for(k = 0; k < this.onFulfilled.length; k++) 15502 {
15503 x = this.onFulfilled[k].apply(this.ctx, [this.value]); 15504 if(typeof x != 'undefined') 15505 { 15506 value = x; 15507 } 15508 } 15509 } 15510 catch(e) 15511 { 15512 if('console' in window) 15513 { 15514 console.dir(e); 15515 } 15516 15517 if (typeof BX.debug !== 'undefined') 15518 { 15519 BX.debug(e); 15520 } 15521 15522 reason = e; // reject next 15523 } 15524 } 15525 else 15526 { 15527 value = this.value; // resolve next 15528 } 15529 } 15530 else if(this.state === false) // promise was reject()-ed 15531 { 15532 if(this.onRejected.length) 15533 { 15534 try 15535 { 15536 for(k = 0; k < this.onRejected.length; k++) 15537 { 15538 x = this.onRejected[k].apply(this.ctx, [this.reason]); 15539 if(typeof x != 'undefined') 15540 { 15541 value = x; 15542 } 15543 } 15544 } 15545 catch(e) 15546 { 15547 if('console' in window) 15548 { 15549 console.dir(e); 15550 } 15551 15552 if (typeof BX.debug !== 'undefined') 15553 { 15554 BX.debug(e); 15555 } 15556 15557 reason = e; // reject next 15558 } 15559 } 15560 else 15561 { 15562 reason = this.reason; // reject next 15563 } 15564 } 15565 15566 if(this.next !== null) 15567 { 15568 if(typeof reason != 'undefined') 15569 { 15570 this.next.reject(reason); 15571 } 15572 else if(typeof value != 'undefined') 15573 { 15574 this.next.resolve(value); 15575 } 15576 } 15577 }; 15578 BX.Promise.prototype.checkState = function() 15579 { 15580 if(this.state !== null) 15581 { 15582 throw new Error('You can not do fulfill() or reject() multiple times'); 15583 } 15584 }; 15585})(window); 15586 15587 15588 15589;(function(window){ 15590 15591if (window.BX.ajax) 15592 return; 15593 15594var 15595 BX = window.BX, 15596 15597 tempDefaultConfig = {}, 15598 defaultConfig = { 15599 method: 'GET', // request method: GET|POST 15600 dataType: 'html', // type of data loading: html|json|script 15601 timeout: 0, // request timeout in seconds. 0 for browser-default 15602 async: true, // whether request is asynchronous or not 15603 processData: true, // any data processing is disabled if false, only callback call 15604 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 15605 emulateOnload: true, 15606 skipAuthCheck: false, // whether to check authorization failure (SHOUD be set to true for CORS requests) 15607 start: true, // send request immediately (if false, request can be started manually via XMLHttpRequest object returned) 15608 cache: true, // whether NOT to add random addition to URL 15609 preparePost: true, // whether set Content-Type x-www-form-urlencoded in POST 15610 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'}] 15611 lsTimeout: 30, //local storage data TTL. useless without lsId. 15612 lsForce: false //wheter to force query instead of using localStorage data. useless without lsId. 15613/* 15614other parameters: 15615 url: url to get/post 15616 data: data to post 15617 onsuccess: successful request callback. BX.proxy may be used. 15618 onfailure: request failure callback. BX.proxy may be used. 15619 onprogress: request progress callback. BX.proxy may be used. 15620 15621 lsId: local storage id - for constantly updating queries which can communicate via localStorage. core_ls.js needed 15622 15623any of the default parameters can be overridden. defaults can be changed by BX.ajax.Setup() - for all further requests! 15624*/ 15625 }, 15626 loadedScripts = {}, 15627 loadedScriptsQueue = [], 15628 r = { 15629 'url_utf': /[^\034-\254]+/g, 15630 'script_self': /\/bitrix\/js\/main\/core\/core(_ajax)*.js$/i, 15631 'script_self_window': /\/bitrix\/js\/main\/core\/core_window.js$/i, 15632 'script_self_admin': /\/bitrix\/js\/main\/core\/core_admin.js$/i, 15633 'script_onload': /window.onload/g 15634 }; 15635 15636// low-level method 15637BX.ajax = function(config) 15638{ 15639 var status, data; 15640
15641 if (!config || !config.url || !BX.type.isString(config.url)) 15642 { 15643 return false; 15644 } 15645 15646 for (var i in tempDefaultConfig) 15647 if (typeof (config[i]) == "undefined") config[i] = tempDefaultConfig[i]; 15648 15649 tempDefaultConfig = {}; 15650 15651 for (i in defaultConfig) 15652 if (typeof (config[i]) == "undefined") config[i] = defaultConfig[i]; 15653 15654 config.method = config.method.toUpperCase(); 15655 15656 if (!BX.localStorage) 15657 config.lsId = null; 15658 15659 if (BX.browser.IsIE()) 15660 { 15661 var result = r.url_utf.exec(config.url); 15662 if (result) 15663 { 15664 do 15665 { 15666 config.url = config.url.replace(result, BX.util.urlencode(result)); 15667 result = r.url_utf.exec(config.url); 15668 } while (result); 15669 } 15670 } 15671 15672 if(config.dataType == 'json') 15673 config.emulateOnload = false; 15674 15675 if (!config.cache && config.method == 'GET') 15676 config.url = BX.ajax._uncache(config.url); 15677 15678 if (config.method == 'POST') 15679 { 15680 if (config.preparePost) 15681 { 15682 config.data = BX.ajax.prepareData(config.data); 15683 } 15684 else if (getLastContentTypeHeader(config.headers) === 'application/json') 15685 { 15686 const isJson = ( 15687 BX.Type.isPlainObject(config.data) 15688 || BX.Type.isString(config.data) 15689 || BX.Type.isNumber(config.data) 15690 || BX.Type.isBoolean(config.data) 15691 || BX.Type.isArray(config.data) 15692 ); 15693 15694 if (isJson) 15695 { 15696 config.data = JSON.stringify(config.data); 15697 } 15698 } 15699 } 15700 15701 var bXHR = true; 15702 if (config.lsId && !config.lsForce) 15703 { 15704 var v = BX.localStorage.get('ajax-' + config.lsId); 15705 if (v !== null) 15706 { 15707 bXHR = false; 15708 15709 var lsHandler = function(lsData) { 15710 if (lsData.key == 'ajax-' + config.lsId && lsData.value != 'BXAJAXWAIT') 15711 { 15712 var data = lsData.value, 15713 bRemove = !!lsData.oldValue && data == null; 15714 if (!bRemove) 15715 BX.ajax.__run(config, data); 15716 else if (config.onfailure) 15717 config.onfailure("timeout"); 15718 15719 BX.removeCustomEvent('onLocalStorageChange', lsHandler); 15720 } 15721 }; 15722 15723 if (v == 'BXAJAXWAIT') 15724 { 15725 BX.addCustomEvent('onLocalStorageChange', lsHandler); 15726 } 15727 else 15728 { 15729 setTimeout(function() {lsHandler({key: 'ajax-' + config.lsId, value: v})}, 10); 15730 } 15731 } 15732 } 15733 15734 if (bXHR) 15735 { 15736 config.xhr = BX.ajax.xhr(); 15737 if (!config.xhr) return; 15738 15739 if (config.lsId) 15740 { 15741 BX.localStorage.set('ajax-' + config.lsId, 'BXAJAXWAIT', config.lsTimeout); 15742 } 15743 15744 if (BX.Type.isFunction(config.onprogress)) 15745 { 15746 BX.bind(config.xhr, 'progress', config.onprogress); 15747 } 15748 15749 if (BX.Type.isFunction(config.onprogressupload) && config.xhr.upload) 15750 { 15751 BX.bind(config.xhr.upload, 'progress', config.onprogressupload); 15752 } 15753 15754 config.xhr.open(config.method, config.url, config.async); 15755 15756 if (!config.skipBxHeader && !BX.ajax.isCrossDomain(config.url)) 15757 { 15758 config.xhr.setRequestHeader('Bx-ajax', 'true'); 15759 } 15760 15761 if (config.method == 'POST' && config.preparePost) 15762 { 15763 config.xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 15764 } 15765 if (typeof(config.headers) == "object") 15766 { 15767 for (i = 0; i < config.headers.length; i++) 15768 config.xhr.setRequestHeader(config.headers[i].name, config.headers[i].value); 15769 } 15770 15771 var bRequestCompleted = false; 15772 var onreadystatechange = config.xhr.onreadystatechange = function(additional) 15773 { 15774 if (bRequestCompleted) 15775 return; 15776 15777 if (additional === 'timeout') 15778 { 15779 if (config.onfailure) 15780 { 15781 config.onfailure('timeout', '', config); 15782 } 15783 15784 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['timeout', '', config]); 15785 15786 config.xhr.onreadystatechange = BX.DoNothing; 15787 config.xhr.abort(); 15788 15789 if (config.async) 15790 { 15791 config.xhr = null; 15792 } 15793 } 15794 else 15795 { 15796 if (config.xhr.readyState == 4 || additional == 'run') 15797 { 15798 status = BX.ajax.xhrSuccess(config.xhr) ? "success" : "error"; 15799 bRequestCompleted = true; 15800 config.xhr.onreadystatechange = BX.DoNothing; 15801 15802 if (status == 'success') 15803 { 15804 var authHeader = (!!config.skipAuthCheck || BX.ajax.isCrossDomain(config.url)) 15805 ? false 15806 : config.xhr.getResponseHeader('X-Bitrix-Ajax-Status'); 15807 15808 if(!!authHeader && authHeader == 'Authorize') 15809 { 15810 if (config.onfailure) 15811 { 15812 config.onfailure('auth', config.xhr.status, config); 15813 } 15814 15815 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['auth', config.xhr.status, config]); 15816 } 15817 else 15818 { 15819 var data = config.xhr.responseText; 15820 15821 if (config.lsId) 15822 { 15823 BX.localStorage.set('ajax-' + config.lsId, data, config.lsTimeout); 15824 } 15825 15826 BX.ajax.__run(config, data); 15827 } 15828 } 15829 else 15830 { 15831 if (config.onfailure) 15832 { 15833 config.onfailure('status', config.xhr.status, config); 15834 } 15835 15836 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['status', config.xhr.status, config]); 15837 } 15838 15839 if (config.async) 15840 { 15841 config.xhr = null; 15842 } 15843 } 15844 } 15845 }; 15846 15847 if (config.async && config.timeout > 0) 15848 { 15849 setTimeout(function() { 15850 if (config.xhr && !bRequestCompleted) 15851 { 15852 onreadystatechange("timeout"); 15853 } 15854 }, config.timeout * 1000); 15855 } 15856 15857 if (config.start) 15858 {
15859 config.xhr.send(config.data); 15860 15861 if (!config.async) 15862 { 15863 onreadystatechange('run'); 15864 } 15865 } 15866 15867 return config.xhr; 15868 } 15869}; 15870 15871BX.ajax.xhr = function() 15872{ 15873 if (window.XMLHttpRequest) 15874 { 15875 try {return new XMLHttpRequest();} catch(e){} 15876 } 15877 else if (window.ActiveXObject) 15878 { 15879 try { return new window.ActiveXObject("Msxml2.XMLHTTP.6.0"); } 15880 catch(e) {} 15881 try { return new window.ActiveXObject("Msxml2.XMLHTTP.3.0"); } 15882 catch(e) {} 15883 try { return new window.ActiveXObject("Msxml2.XMLHTTP"); } 15884 catch(e) {} 15885 try { return new window.ActiveXObject("Microsoft.XMLHTTP"); } 15886 catch(e) {} 15887 throw new Error("This browser does not support XMLHttpRequest."); 15888 } 15889 15890 return null; 15891}; 15892 15893BX.ajax.isCrossDomain = function(url, location) 15894{ 15895 location = location || window.location; 15896 15897 //Relative URL gets a current protocol 15898 if (url.indexOf("//") === 0) 15899 { 15900 url = location.protocol + url; 15901 } 15902 15903 //Fast check 15904 if (url.indexOf("http") !== 0) 15905 { 15906 return false; 15907 } 15908 15909 var link = window.document.createElement("a"); 15910 link.href = url; 15911 15912 return link.protocol !== location.protocol || 15913 link.hostname !== location.hostname || 15914 BX.ajax.getHostPort(link.protocol, link.host) !== BX.ajax.getHostPort(location.protocol, location.host); 15915}; 15916 15917BX.ajax.getHostPort = function(protocol, host) 15918{ 15919 var match = /:(\d+)$/.exec(host); 15920 if (match) 15921 { 15922 return match[1]; 15923 } 15924 else 15925 { 15926 if (protocol === "http:") 15927 { 15928 return "80"; 15929 } 15930 else if (protocol === "https:") 15931 { 15932 return "443"; 15933 } 15934 } 15935 15936 return ""; 15937}; 15938 15939BX.ajax.__prepareOnload = function(scripts, ajax_session) 15940{ 15941 if (scripts.length > 0) 15942 { 15943 BX.ajax['onload_' + ajax_session] = null; 15944 15945 for (var i=0,len=scripts.length;i<len;i++) 15946 { 15947 if (scripts[i].isInternal) 15948 { 15949 scripts[i].JS = scripts[i].JS.replace(r.script_onload, 'BX.aja
15949x.onload_' + ajax_session); 15950 } 15951 } 15952 } 15953 15954 BX.CaptureEventsGet(); 15955 BX.CaptureEvents(window, 'load'); 15956}; 15957 15958BX.ajax.__runOnload = function(ajax_session) 15959{ 15960 if (null != BX.ajax['onload_' + ajax_session]) 15961 { 15962 BX.ajax['onload_' + ajax_session].apply(window); 15963 BX.ajax['onload_' + ajax_session] = null; 15964 } 15965 15966 var h = BX.CaptureEventsGet(); 15967 15968 if (h) 15969 { 15970 for (var i=0; i<h.length; i++) 15971 h[i].apply(window); 15972 } 15973}; 15974 15975BX.ajax.__run = function(config, data) 15976{ 15977 if (!config.processData) 15978 { 15979 if (config.onsuccess) 15980 { 15981 config.onsuccess(data); 15982 } 15983 15984 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [data, config]); 15985 } 15986 else 15987 { 15988 data = BX.ajax.processRequestData(data, config); 15989 } 15990}; 15991 15992 15993BX.ajax._onParseJSONFailure = function(data) 15994{ 15995 this.jsonFailure = true; 15996 this.jsonResponse = data; 15997 this.jsonProactive = /^\[WAF\]/.test(data); 15998}; 15999 16000BX.ajax.processRequestData = function(data, config) 16001{ 16002 var result, scripts = [], styles = []; 16003 switch (config.dataType.toUpperCase()) 16004 { 16005 case 'JSON': 16006 16007 var context = config.xhr || {}; 16008 BX.addCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 16009 result = BX.parseJSON(data, context); 16010 BX.removeCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 16011 16012 if(!!result && BX.type.isArray(result['bxjs'])) 16013 { 16014 for(var i = 0; i < result['bxjs'].length; i++) 16015 { 16016 if(BX.type.isNotEmptyString(result['bxjs'][i])) 16017 { 16018 scripts.push({ 16019 "isInternal": false, 16020 "JS": result['bxjs'][i], 16021 "bRunFirst": config.scriptsRunFirst 16022 }); 16023 } 16024 else 16025 { 16026 scripts.push(result['bxjs'][i]) 16027 } 16028 } 16029 } 16030 16031 if(!!result && BX.type.isArray(result['bxcss'])) 16032 { 16033 styles = result['bxcss']; 16034 } 16035 16036 break; 16037 case 'SCRIPT': 16038 scripts.push({"isInternal": true, "JS": data, "bRunFirst": config.scriptsRunFirst}); 16039 result = data; 16040 break; 16041 16042 default: // HTML 16043 var ob = BX.processHTML(data, config.scriptsRunFirst); 16044 result = ob.HTML; scripts = ob.SCRIPT; styles = ob.STYLE; 16045 break; 16046 } 16047 16048 if (styles.length > 0) 16049 { 16050 BX.loadCSS(styles); 16051 } 16052 16053 let ajax_session = null; 16054 if (config.emulateOnload) 16055 { 16056 ajax_session = parseInt(Math.random() * 1000000); 16057 BX.ajax.__prepareOnload(scripts, ajax_session); 16058 } 16059 16060 const cb = BX.defer(function() 16061 { 16062 if (config.emulateOnload) 16063 { 16064 BX.ajax.__runOnload(ajax_session); 16065 } 16066 16067 BX.onCustomEvent(config.xhr, 'onAjaxSuccessFinish', [config]); 16068 }); 16069 16070 try 16071 { 16072 if (!!config.jsonFailure) 16073 { 16074 throw {type: 'json_failure', data: config.jsonResponse, bProactive: config.jsonProactive}; 16075 } 16076 16077 config.scripts = scripts; 16078 16079 BX.ajax.processScripts(config.scripts, true); 16080 16081 if (config.onsuccess) 16082 { 16083 config.onsuccess(result); 16084 } 16085 16086 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [result, config]); 16087 16088 BX.ajax.processScripts(config.scripts, false, cb); 16089 } 16090 catch (e) 16091 { 16092 if (config.onfailure) 16093 config.onfailure("processing", e); 16094 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['processing', e, config]); 16095 } 16096}; 16097 16098BX.ajax.processScripts = function(scripts, bRunFirst, cb) 16099{ 16100 var scriptsExt = [], scriptsInt = ''; 16101 16102 cb = cb || BX.DoNothing; 16103 16104 for (var i = 0, length = scripts.length; i < length; i++) 16105 { 16106 if (typeof bRunFirst != 'undefined' && bRunFirst != !!scripts[i].bRunFirst) 16107 continue; 16108 16109 if (scripts[i].isInternal) 16110 scriptsInt += ';' + scripts[i].JS; 16111 else 16112 scriptsExt.push(scripts[i].JS); 16113 } 16114 16115 scriptsExt = BX.util.array_unique(scriptsExt); 16116 var inlineScripts = scriptsInt.length > 0 ? function() { BX.evalGlobal(scriptsInt); } : BX.DoNothing; 16117 16118 if (scriptsExt.length > 0) 16119 { 16120 BX.load(scriptsExt, function() { 16121 inlineScripts(); 16122 cb(); 16123 }); 16124 } 16125 else 16126 { 16127 inlineScripts(); 16128 cb(); 16129 } 16130}; 16131 16132// TODO: extend this function to use with any data objects or forms 16133BX.ajax.prepareData = function(arData, prefix) 16134{ 16135 var data = ''; 16136 if (BX.type.isString(arData)) 16137 data = arData; 16138 else if (null != arData) 16139 { 16140 for(var i in arData) 16141 { 16142 if (arData.hasOwnProperty(i)) 16143 { 16144 if (data.length > 0) 16145 data += '&'; 16146 var name = BX.util.urlencode(i); 16147 if(prefix) 16148 name = prefix + '[' + name + ']'; 16149 if(typeof arData[i] == 'object') 16150 data += BX.ajax.prepareData(arData[i], name); 16151 else 16152 data += name + '=' + BX.util.urlencode(arData[i]); 16153 } 16154 } 16155 } 16156 return data; 16157}; 16158 16159BX.ajax.xhrSuccess = function(xhr) 16160{ 16161 return (xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || xhr.status === 1223 || xhr.status === 0; 16162}; 16163 16164BX.ajax.Setup = function(config, bTemp) 16165{ 16166 bTemp = !!bTemp; 16167 16168 for (var i in config) 16169 { 16170 if (bTemp) 16171 tempDefaultConfig[i] = config[i]; 16172 else 16173 defaultConfig[i] = config[i]; 16174 } 16175}; 16176 16177BX.ajax.replaceLocalStorageValue = function(lsId, data, ttl) 16178{ 16179 if (!!BX.localStorage) 16180 BX.localStorage.set('ajax-' + lsId, data, ttl); 16181}; 16182 16183 16184BX.ajax._uncache = function(url) 16185{ 16186 return url + ((url.indexOf('?') !== -1 ? "&" : "?") + '_=' + (new Date()).getTime()); 16187}; 16188 16189/* simple interface */ 16190BX.ajax.get = function(url, data, callback) 16191{ 16192 if (BX.type.isFunction(data)) 16193 { 16194 callback = data; 16195 data = ''; 16196 } 16197
16198 data = BX.ajax.prepareData(data); 16199 16200 if (data) 16201 { 16202 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 16203 data = ''; 16204 } 16205 16206 return BX.ajax({ 16207 'method': 'GET', 16208 'dataType': 'html', 16209 'url': url, 16210 'data': '', 16211 'onsuccess': callback 16212 }); 16213}; 16214 16215BX.ajax.getCaptcha = function(callback) 16216{ 16217 return BX.ajax.loadJSON('/bitrix/tools/ajax_captcha.php', callback); 16218}; 16219 16220BX.ajax.insertToNode = function(url, node) 16221{ 16222 node = BX(node); 16223 if (!!node) 16224 { 16225 var eventArgs = { cancel: false }; 16226 BX.onCustomEvent('onAjaxInsertToNode', [{ url: url, node: node, eventArgs: eventArgs }]); 16227 if(eventArgs.cancel === true) 16228 { 16229 return; 16230 } 16231 16232 var show = null; 16233 if (!tempDefaultConfig.denyShowWait) 16234 { 16235 show = BX.showWait(node); 16236 delete tempDefaultConfig.denyShowWait; 16237 } 16238 16239 return BX.ajax.get(url, function(data) { 16240 node.innerHTML = data; 16241 BX.closeWait(node, show); 16242 }); 16243 } 16244}; 16245 16246BX.ajax.post = function(url, data, callback) 16247{ 16248 data = BX.ajax.prepareData(data); 16249 16250 return BX.ajax({ 16251 'method': 'POST', 16252 'dataType': 'html', 16253 'url': url, 16254 'data': data, 16255 'onsuccess': callback 16256 }); 16257}; 16258 16259/** 16260 * BX.ajax with BX.Promise 16261 * 16262 * @param config 16263 * @returns {BX.Promise|false} 16264 */ 16265BX.ajax.promise = function(config) 16266{ 16267 var result = new BX.Promise(); 16268 16269 config.onsuccess = function(data) 16270 { 16271 result.fulfill(data); 16272 }; 16273 config.onfailure = function(reason, httpStatus, config) 16274 { 16275 result.reject({ 16276 reason: reason, 16277 data: httpStatus, 16278 ajaxConfig: config, 16279 xhr: config.xhr 16280 }); 16281 }; 16282 16283 var xhr = BX.ajax(config); 16284 if (xhr) 16285 { 16286 if (typeof config.onrequeststart === 'function') 16287 { 16288 config.onrequeststart(xhr); 16289 } 16290 } 16291 else 16292 { 16293 result.reject({ 16294 reason: "init", 16295 data: false 16296 }); 16297 } 16298 16299 return result; 16300}; 16301 16302/* load and execute external file script with onload emulation */ 16303BX.ajax.loadScriptAjax = function(script_src, callback, bPreload) 16304{ 16305 if (BX.type.isArray(script_src)) 16306 { 16307 for (var i=0,len=script_src.length;i<len;i++) 16308 { 16309 BX.ajax.loadScriptAjax(script_src[i], callback, bPreload); 16310 } 16311 } 16312 else 16313 { 16314 var script_src_test = script_src.replace(/\.js\?.*/, '.js'); 16315 16316 if (r.script_self.test(script_src_test)) return; 16317 if (r.script_self_window.test(script_src_test) && BX.CWindow) return; 16318 if (r.script_self_admin.test(script_src_test) && BX.admin) return; 16319 16320 if (typeof loadedScripts[script_src_test] == 'undefined') 16321 { 16322 if (!!bPreload) 16323 { 16324 loadedScripts[script_src_test] = ''; 16325 return BX.loadScript(script_src); 16326 } 16327 else 16328 { 16329 return BX.ajax({ 16330 url: script_src, 16331 method: 'GET', 16332 dataType: 'script', 16333 processData: true, 16334 emulateOnload: false, 16335 scriptsRunFirst: true, 16336 async: false, 16337 start: true, 16338 onsuccess: function(result) { 16339 loadedScripts[script_src_test] = result; 16340 if (callback) 16341 callback(result); 16342 } 16343 }); 16344 } 16345 } 16346 else if (callback) 16347 { 16348 callback(loadedScripts[script_src_test]); 16349 } 16350 } 16351}; 16352 16353/* non-xhr loadings */ 16354BX.ajax.loadJSON = function(url, data, callback, callback_failure) 16355{ 16356 if (BX.type.isFunction(data)) 16357 { 16358 callback_failure = callback; 16359 callback = data; 16360 data = ''; 16361 } 16362 16363 data = BX.ajax.prepareData(data); 16364 16365 if (data) 16366 { 16367 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 16368 data = ''; 16369 } 16370 16371 return BX.ajax({ 16372 'method': 'GET', 16373 'dataType': 'json', 16374 'url': url, 16375 'onsuccess': callback, 16376 'onfailure': callback_failure 16377 }); 16378}; 16379 16380var getLastContentTypeHeader = function (headers) { 16381 if (!BX.Type.isArray(headers)) 16382 { 16383 return null; 16384 } 16385 var lastHeader = headers 16386 .filter(function (header) { 16387 return header.name === 'Content-Type'; 16388 }) 16389 .pop(); 16390 16391 return lastHeader ? lastHeader.value : null; 16392}; 16393 16394var prepareAjaxGetParameters = function(config) 16395{ 16396 var getParameters = config.getParameters || {}; 16397 if (BX.type.isNotEmptyString(config.analyticsLabel)) 16398 { 16399 getParameters.analyticsLabel = config.analyticsLabel; 16400 } 16401 else if (BX.type.isNotEmptyObject(config.analyticsLabel)) 16402 { 16403 getParameters.analyticsLabel = config.analyticsLabel; 16404 } 16405 if (typeof config.mode !== 'undefined') 16406 { 16407 getParameters.mode = config.mode; 16408 } 16409 if (config.navigation) 16410 { 16411 if(config.navigation.page) 16412 { 16413 getParameters.nav = 'page-' + config.navigation.page; 16414 } 16415 if(config.navigation.size) 16416 { 16417 if(getParameters.nav) 16418 { 16419 getParameters.nav += '-'; 16420 } 16421 else 16422 {
16423 getParameters.nav = ''; 16424 } 16425 getParameters.nav += 'size-' + config.navigation.size; 16426 } 16427 } 16428 16429 return getParameters; 16430}; 16431 16432var prepareAjaxConfig = function(config) 16433{ 16434 config = BX.type.isPlainObject(config) ? config : {}; 16435 16436 config.headers = config.headers || []; 16437 config.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 16438 if (BX.message.SITE_ID) 16439 { 16440 config.headers.push({name: 'X-Bitrix-Site-Id', value: BX.message.SITE_ID}); 16441 } 16442 16443 if (typeof config.json !== 'undefined') 16444 { 16445 if (!BX.type.isPlainObject(config.json)) 16446 { 16447 throw new Error('Wrong `config.json`, plain object expected.') 16448 } 16449 16450 config.headers.push({name: 'Content-Type', value: 'application/json'}); 16451 config.data = config.json; 16452 config.preparePost = false; 16453 } 16454 else if (config.data instanceof FormData) 16455 { 16456 config.preparePost = false; 16457 if (typeof config.signedParameters !== 'undefined') 16458 { 16459 config.data.append('signedParameters', config.signedParameters); 16460 } 16461 } 16462 else if (BX.type.isPlainObject(config.data) || BX.Type.isNil(config.data)) 16463 { 16464 config.data = BX.type.isPlainObject(config.data) ? config.data : {}; 16465 if (typeof config.signedParameters !== 'undefined') 16466 { 16467 config.data.signedParameters = config.signedParameters; 16468 } 16469 } 16470 16471 if (!config.method) 16472 { 16473 config.method = 'POST' 16474 } 16475 16476 return config; 16477}; 16478 16479var buildAjaxPromiseToRestoreCsrf = function(config, withoutRestoringCsrf) 16480{ 16481 withoutRestoringCsrf = withoutRestoringCsrf || false; 16482 var originalConfig = BX.clone(config); 16483 var request = null; 16484 16485 var onrequeststart = config.onrequeststart; 16486 config.onrequeststart = function(xhr) { 16487 request = xhr; 16488 if (BX.type.isFunction(onrequeststart)) 16489 { 16490 onrequeststart(xhr); 16491 } 16492 }; 16493 var onrequeststartOrig = originalConfig.onrequeststart; 16494 originalConfig.onrequeststart = function(xhr) { 16495 request = xhr; 16496 if (BX.type.isFunction(onrequeststartOrig)) 16497 { 16498 onrequeststartOrig(xhr); 16499 } 16500 }; 16501 16502 var promise = BX.ajax.promise(config); 16503 16504 return promise.then(function(response) { 16505 if (!withoutRestoringCsrf && BX.type.isPlainObject(response) && BX.type.isArray(response.errors)) 16506 { 16507 var csrfProblem = false; 16508 response.errors.forEach(function(error) { 16509 if (error.code === 'invalid_csrf' && error.customData.csrf) 16510 { 16511 BX.message({'bitrix_sessid': error.customData.csrf}); 16512 16513 originalConfig.headers = originalConfig.headers || []; 16514 originalConfig.headers = originalConfig.headers.filter(function(header) { 16515 return header && header.name !== 'X-Bitrix-Csrf-Token'; 16516 }); 16517 originalConfig.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 16518 16519 csrfProblem = true; 16520 } 16521 }); 16522 16523 if (csrfProblem) 16524 { 16525 return buildAjaxPromiseToRestoreCsrf(originalConfig, true); 16526 } 16527 } 16528 16529 if (!BX.type.isPlainObject(response) || response.status !== 'success') 16530 { 16531 var errorPromise = new BX.Promise(); 16532 errorPromise.reject(response); 16533 16534 return errorPromise; 16535 } 16536 16537 return response; 16538 }).catch(function(data) { 16539 var ajaxReject = new BX.Promise(); 16540 16541 var originalJsonResponse; 16542 if (BX.type.isPlainObject(data) && data.xhr && data.xhr.responseText) 16543 { 16544 try 16545 { 16546 originalJsonResponse = JSON.parse(data.xhr.responseText); 16547 data = originalJsonResponse; 16548 } 16549 catch (err) 16550 {} 16551 } 16552 16553 if (BX.type.isPlainObject(data) && data.status && data.hasOwnProperty('data')) 16554 { 16555 ajaxReject.reject(data); 16556 } 16557 else 16558 { 16559 ajaxReject.reject({ 16560 status: 'error', 16561 data: { 16562 ajaxRejectData: data 16563 }, 16564 errors: [ 16565 { 16566 code: 'NETWORK_ERROR', 16567 message: 'Network error' 16568 } 16569 ] 16570 }); 16571 } 16572 16573 return ajaxReject; 16574 }).then(function(response){ 16575 16576 var assetsLoaded = new BX.Promise(); 16577 16578 var headers = request.getAllResponseHeaders().trim().split(/[\r\n]+/); 16579 var headerMap = {}; 16580 headers.forEach(function (line) { 16581 var parts = line.split(': '); 16582 var header = parts.shift().toLowerCase(); 16583 headerMap[header] = parts.join(': '); 16584 }); 16585 16586 if (!headerMap['x-process-assets']) 16587 { 16588 assetsLoaded.fulfill(response); 16589 16590 return assetsLoaded; 16591 } 16592 16593 var assets = BX.prop.getObject(BX.prop.getObject(response, "data", {}), "assets", {}); 16594 var promise = new Promise(function(resolve, reject) { 16595 var css = BX.prop.getArray(assets, "css", []); 16596 BX.load(css, function(){ 16597 BX.loadScript( 16598 BX.prop.getArray(assets, "js", []), 16599 resolve 16600 ); 16601 }); 16602 }); 16603 promise.then(function(){ 16604 var strings = BX.prop.getArray(assets, "string", []); 16605 var stringAsset = strings.join('\n'); 16606 BX.html(document.head, stringAsset, { useAdjacentHTML: true }).then(function(){ 16607 assetsLoaded.fulfill(response); 16608 }); 16609 }); 16610 16611 return assetsLoaded; 16612 }); 16613}; 16614 16615/** 16616 * 16617 * @param {string} action 16618 * @param {Object} config 16619 * @param {?string|?Object} [config.analyticsLabel] 16620 * @param {string} [config.method='POST'] 16621 * @param {Object} [config.data] 16622 * @param {?Object} [config.getParameters] 16623 * @param {?Object} [config.headers] 16624 * @param {?Object} [config.timeout] 16625 * @param {Object} [config.navigation] 16626 * @param {number} [config.navigation.page] 16627 */ 16628BX.ajax.runAction = function(action, config) 16629{ 16630 config = prepareAjaxConfig(config); 16631 var getParameters = prepareAjaxGetParameters(config); 16632 getParameters.action = action; 16633
16634 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 16635 return buildAjaxPromiseToRestoreCsrf({ 16636 method: config.method, 16637 dataType: 'json', 16638 url: url, 16639 data: config.data, 16640 timeout: config.timeout, 16641 preparePost: config.preparePost, 16642 headers: config.headers, 16643 onrequeststart: config.onrequeststart, 16644 onprogress: config.onprogress, 16645 onprogressupload: config.onprogressupload 16646 }); 16647}; 16648 16649/** 16650 * 16651 * @param {string} component 16652 * @param {string} action 16653 * @param {Object} config 16654 * @param {?string|?Object} [config.analyticsLabel] 16655 * @param {?string} [config.signedParameters] 16656 * @param {string} [config.method='POST'] 16657 * @param {string} [config.mode='ajax'] Ajax or class. 16658 * @param {Object} [config.data] 16659 * @param {?Object} [config.getParameters] 16660 * @param {?array} [config.headers] 16661 * @param {?number} [config.timeout] 16662 * @param {Object} [config.navigation] 16663 */ 16664BX.ajax.runComponentAction = function (component, action, config) 16665{ 16666 config = prepareAjaxConfig(config); 16667 config.mode = config.mode || 'ajax'; 16668 16669 var getParameters = prepareAjaxGetParameters(config); 16670 getParameters.c = component; 16671 getParameters.action = action; 16672
16673 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 16674 16675 return buildAjaxPromiseToRestoreCsrf({ 16676 method: config.method, 16677 dataType: 'json', 16678 url: url, 16679 data: config.data, 16680 timeout: config.timeout, 16681 preparePost: config.preparePost, 16682 headers: config.headers, 16683 onrequeststart: (config.onrequeststart ? config.onrequeststart : null), 16684 onprogress: config.onprogress, 16685 onprogressupload: config.onprogressupload 16686 }); 16687}; 16688 16689/* 16690arObs = [{ 16691 url: url, 16692 type: html|script|json|css, 16693 callback: function 16694}] 16695*/ 16696BX.ajax.load = function(arObs, callback) 16697{ 16698 if (!BX.type.isArray(arObs)) 16699 arObs = [arObs]; 16700 16701 var cnt = 0; 16702 16703 if (!BX.type.isFunction(callback)) 16704 callback = BX.DoNothing; 16705 16706 var handler = function(data) 16707 { 16708 if (BX.type.isFunction(this.callback)) 16709 this.callback(data); 16710 16711 if (++cnt >= len) 16712 callback(); 16713 }; 16714 16715 for (var i = 0, len = arObs.length; i<len; i++) 16716 { 16717 switch(arObs[i].type.toUpperCase()) 16718 { 16719 case 'SCRIPT': 16720 BX.loadScript([arObs[i].url], BX.proxy(handler, arObs[i])); 16721 break; 16722 case 'CSS': 16723 BX.loadCSS([arObs[i].url]); 16724 16725 if (++cnt >= len) 16726 callback(); 16727 break; 16728 case 'JSON': 16729 BX.ajax.loadJSON(arObs[i].url, BX.proxy(handler, arObs[i])); 16730 break; 16731 16732 default: 16733 BX.ajax.get(arObs[i].url, '', BX.proxy(handler, arObs[i])); 16734 break; 16735 } 16736 } 16737}; 16738 16739/* ajax form sending */ 16740BX.ajax.submit = function(obForm, callback) 16741{ 16742 if (!obForm.target) 16743 { 16744 if (null == obForm.BXFormTarget) 16745 { 16746 var frame_name = 'formTarget_' + Math.random(); 16747 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 16748 props: { 16749 name: frame_name, 16750 id: frame_name, 16751 src: 'javascript:void(0)' 16752 }, 16753 style: { 16754 display: 'none' 16755 } 16756 })); 16757 } 16758 16759 obForm.target = obForm.BXFormTarget.name; 16760 } 16761 16762 obForm.BXFormCallback = callback; 16763 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 16764 16765 BX.submit(obForm); 16766 16767 return false; 16768}; 16769 16770BX.ajax.submitComponentForm = function(obForm, container, bWait) 16771{ 16772 if (!obForm.target) 16773 { 16774 if (null == obForm.BXFormTarget) 16775 { 16776 var frame_name = 'formTarget_' + Math.random(); 16777 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 16778 props: { 16779 name: frame_name, 16780 id: frame_name, 16781 src: 'javascript:void(0)' 16782 }, 16783 style: { 16784 display: 'none' 16785 } 16786 })); 16787 } 16788 16789 obForm.target = obForm.BXFormTarget.name; 16790 } 16791 16792 if (!!bWait) 16793 var w = BX.showWait(container); 16794 16795 obForm.BXFormCallback = function(d) { 16796 if (!!bWait) 16797 BX.closeWait(w); 16798 16799 var callOnload = function(){ 16800 if(!!window.bxcompajaxframeonload) 16801 { 16802 setTimeout(function(){window.bxcompajaxframeonload();window.bxcompajaxframeonload=null;}, 10); 16803 } 16804 }; 16805 16806 BX(container).innerHTML = d; 16807 BX.onCustomEvent('onAjaxSuccess', [null,null,callOnload]); 16808 }; 16809 16810 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 16811 16812 return true; 16813}; 16814 16815// func will be executed in form context 16816BX.ajax._submit_callback = function() 16817{ 16818 //opera and IE8 triggers onload event even on empty iframe 16819 try 16820 { 16821 if(this.BXFormTarget.contentWindow.location.href.indexOf('http') != 0) 16822 return; 16823 } catch (e) { 16824 return; 16825 } 16826 16827 if (this.BXFormCallback) 16828 this.BXFormCallback.apply(this, [this.BXFormTarget.contentWindow.document.body.innerHTML]); 16829 16830 BX.unbindAll(this.BXFormTarget); 16831}; 16832 16833BX.ajax.prepareForm = function(obForm, data) 16834{ 16835 data = (!!data ? data : {}); 16836 var i, ii, el, 16837 _data = [], 16838 n = obForm.elements.length, 16839 files = 0, length = 0; 16840 if(!!obForm) 16841 { 16842 for (i = 0; i < n; i++) 16843 { 16844 el = obForm.elements[i]; 16845 if (el.disabled) 16846 continue; 16847 16848 if(!el.type) 16849 continue; 16850 16851 switch(el.type.toLowerCase()) 16852 { 16853 case 'text': 16854 case 'textarea': 16855 case 'password': 16856 case 'number': 16857 case 'hidden': 16858 case 'select-one': 16859 _data.push({name: el.name, value: el.value}); 16860 length += (el.name.length + el.value.length); 16861 break; 16862 case 'file': 16863 if (!!el.files) 16864 { 16865 for (ii = 0; ii < el.files.length; ii++) 16866 { 16867 files++; 16868 _data.push({name: el.name, value: el.files[ii], file : true}); 16869 length += el.files[ii].size; 16870 } 16871 } 16872 break; 16873 case 'radio':
16874 case 'checkbox': 16875 if(el.checked) 16876 { 16877 _data.push({name: el.name, value: el.value}); 16878 length += (el.name.length + el.value.length); 16879 } 16880 break; 16881 case 'select-multiple': 16882 for (var j = 0; j < el.options.length; j++) 16883 { 16884 if (el.options[j].selected) 16885 { 16886 _data.push({name : el.name, value : el.options[j].value}); 16887 length += (el.name.length + el.options[j].length); 16888 } 16889 } 16890 break; 16891 default: 16892 break; 16893 } 16894 } 16895 16896 i = 0; length = 0; 16897 var current = data, name, rest, pp, tmpKey; 16898 16899 while(i < _data.length) 16900 { 16901 var p = _data[i].name.indexOf('['); 16902 if (tmpKey) 16903 { 16904 current[_data[i].name] = {}; 16905 current[_data[i].name][tmpKey.replace(/\[|\]/gi, '')] = _data[i].value; 16906 current = data; 16907 tmpKey = null; 16908 i++; 16909 } 16910 else if (p == -1) 16911 { 16912 current[_data[i].name] = _data[i].value; 16913 current = data; 16914 i++; 16915 } 16916 else 16917 { 16918 name = _data[i].name.substring(0, p); 16919 rest = _data[i].name.substring(p+1); 16920 pp = rest.indexOf(']'); 16921 16922 if(pp == -1) 16923 { 16924 if (!current[name]) 16925 current[name] = []; 16926 current = data; 16927 i++; 16928 } 16929 else if(pp == 0) 16930 { 16931 if (!current[name]) 16932 current[name] = []; 16933 //No index specified - so take the next integer 16934 current = current[name]; 16935 _data[i].name = '' + current.length; 16936 if (rest.substring(pp+1).indexOf('[') === 0) 16937 tmpKey = rest.substring(0, pp) + rest.substring(pp+1); 16938 } 16939 else 16940 { 16941 if (!current[name]) 16942 current[name] = {}; 16943 //Now index name becomes and name and we go deeper into the array 16944 current = current[name]; 16945 _data[i].name = rest.substring(0, pp) + rest.substring(pp+1); 16946 } 16947 } 16948 } 16949 } 16950 return {data : data, filesCount : files, roughSize : length}; 16951}; 16952BX.ajax.submitAjax = function(obForm, config) 16953{ 16954 config = (config !== null && typeof config == "object" ? config : {}); 16955 config.url = (config["url"] || obForm.getAttribute("action")); 16956 16957 var additionalData = (config["data"] || {}); 16958 config.data = BX.ajax.prepareForm(obForm).data; 16959 for (var ii in additionalData) 16960 { 16961 if (additionalData.hasOwnProperty(ii)) 16962 { 16963 config.data[ii] = additionalData[ii]; 16964 } 16965 } 16966 16967 if (!window["FormData"]) 16968 { 16969 BX.ajax(config); 16970 } 16971 else 16972 { 16973 var isFile = function(item) 16974 { 16975 var res = Object.prototype.toString.call(item); 16976 return (res == '[object File]' || res == '[object Blob]'); 16977 }, 16978 appendToForm = function(fd, key, val) 16979 { 16980 if (!!val && typeof val == "object" && !isFile(val)) 16981 { 16982 for (var ii in val) 16983 { 16984 if (val.hasOwnProperty(ii)) 16985 { 16986 appendToForm(fd, (key == '' ? ii : key + '[' + ii + ']'), val[ii]); 16987 } 16988 } 16989 } 16990 else 16991 fd.append(key, (!!val ? val : '')); 16992 }, 16993 prepareData = function(arData) 16994 { 16995 var data = {}; 16996 if (null != arData) 16997 { 16998 if(typeof arData == 'object') 16999 { 17000 for(var i in arData) 17001 { 17002 if (arData.hasOwnProperty(i)) 17003 { 17004 var name = BX.util.urlencode(i); 17005 if(typeof arData[i] == 'object' && arData[i]["file"] !== true) 17006 data[name] = prepareData(arData[i]); 17007 else if (arData[i]["file"] === true) 17008 data[name] = arData[i]["value"]; 17009 else 17010 data[name] = BX.util.urlencode(arData[i]); 17011 } 17012 } 17013 } 17014 else 17015 data = BX.util.urlencode(arData); 17016 } 17017 return data; 17018 }, 17019 fd = new window.FormData(); 17020 17021 if (config.method !== 'POST') 17022 { 17023 config.data = BX.ajax.prepareData(config.data); 17024 if (config.data) 17025 { 17026 config.url += (config.url.indexOf('?') !== -1 ? "&" : "?") + config.data; 17027 config.data = ''; 17028 } 17029 } 17030 else 17031 { 17032 if (config.preparePost === true) 17033 config.data = prepareData(config.data); 17034 appendToForm(fd, '', config.data); 17035 config.data = fd; 17036 } 17037 17038 config.preparePost = false; 17039 config.start = false;
17040 17041 var xhr = BX.ajax(config); 17042 if (!!config["onprogress"]) 17043 xhr.upload.addEventListener( 17044 'progress', 17045 function(e){ 17046 var percent = null; 17047 if(e.lengthComputable && (e.total || e["totalSize"])) { 17048 percent = e.loaded * 100 / (e.total || e["totalSize"]); 17049 } 17050 config["onprogress"](e, percent); 17051 } 17052 ); 17053 xhr.send(fd); 17054 } 17055}; 17056 17057BX.ajax.UpdatePageData = function (arData) 17058{ 17059 if (arData.TITLE) 17060 BX.ajax.UpdatePageTitle(arData.TITLE); 17061 if (arData.WINDOW_TITLE || arData.TITLE) 17062 BX.ajax.UpdateWindowTitle(arData.WINDOW_TITLE || arData.TITLE); 17063 if (arData.NAV_CHAIN) 17064 BX.ajax.UpdatePageNavChain(arData.NAV_CHAIN); 17065 if (arData.CSS && arData.CSS.length > 0) 17066 BX.loadCSS(arData.CSS); 17067 if (arData.SCRIPTS && arData.SCRIPTS.length > 0) 17068 { 17069 var f = function(result,config,cb){ 17070 17071 if(!!config && BX.type.isArray(config.scripts)) 17072 { 17073 for(var i=0,l=arData.SCRIPTS.length;i<l;i++) 17074 { 17075 config.scripts.push({isInternal:false,JS:arData.SCRIPTS[i]}); 17076 } 17077 } 17078 else 17079 { 17080 BX.loadScript(arData.SCRIPTS,cb); 17081 } 17082 17083 BX.removeCustomEvent('onAjaxSuccess',f); 17084 }; 17085 BX.addCustomEvent('onAjaxSuccess',f); 17086 } 17087 else 17088 { 17089 var f1 = function(result,config,cb){ 17090 if(BX.type.isFunction(cb)) 17091 { 17092 cb(); 17093 } 17094 BX.removeCustomEvent('onAjaxSuccess',f1); 17095 }; 17096 BX.addCustomEvent('onAjaxSuccess', f1); 17097 } 17098}; 17099 17100BX.ajax.UpdatePageTitle = function(title) 17101{ 17102 var obTitle = BX('pagetitle'); 17103 if (obTitle) 17104 { 17105 BX.remove(obTitle.firstChild); 17106 if (!obTitle.firstChild) 17107 obTitle.appendChild(document.createTextNode(title)); 17108 else 17109 obTitle.insertBefore(document.createTextNode(title), obTitle.firstChild); 17110 } 17111}; 17112 17113BX.ajax.UpdateWindowTitle = function(title) 17114{ 17115 document.title = title; 17116}; 17117 17118BX.ajax.UpdatePageNavChain = function(nav_chain) 17119{ 17120 var obNavChain = BX('navigation'); 17121 if (obNavChain) 17122 { 17123 obNavChain.innerHTML = nav_chain; 17124 } 17125}; 17126 17127/* user options handling */ 17128BX.userOptions = { 17129 options: null, 17130 bSend: false, 17131 delay: 5000, 17132 path: '/bitrix/admin/user_options.php?' 17133}; 17134 17135BX.userOptions.setAjaxPath = function(url) 17136{ 17137 BX.userOptions.path = url.indexOf('?') == -1? url+'?': url+'&'; 17138} 17139BX.userOptions.save = function(sCategory, sName, sValName, sVal, bCommon) 17140{ 17141 if (null == BX.userOptions.options) 17142 BX.userOptions.options = {}; 17143 17144 bCommon = !!bCommon; 17145 BX.userOptions.options[sCategory+'.'+sName+'.'+sValName] = [sCategory, sName, sValName, sVal, bCommon]; 17146 17147 var sParam = BX.userOptions.__get(); 17148 if (sParam != '') 17149 document.cookie = BX.message('COOKIE_PREFIX')+"_LAST_SETTINGS=" + encodeURIComponent(sParam) + "&sessid="+BX.bitrix_sessid()+"; expires=Thu, 31 Dec " + ((new Date()).getFullYear() + 1) + " 23:59:59 GMT; path=/;"; 17150 17151 if(!BX.userOptions.bSend) 17152 { 17153 BX.userOptions.bSend = true; 17154 setTimeout(function(){BX.userOptions.send(null)}, BX.userOptions.delay); 17155 } 17156}; 17157 17158BX.userOptions.send = function(callback) 17159{ 17160 var sParam = BX.userOptions.__get(); 17161 BX.userOptions.options = null; 17162 BX.userOptions.bSend = false; 17163 17164 if (sParam != '') 17165 { 17166 document.cookie = BX.message('COOKIE_PREFIX') + "_LAST_SETTINGS=; path=/;"; 17167 BX.ajax({ 17168 'method': 'GET', 17169 'dataType': 'html', 17170 'processData': false, 17171 'cache': false, 17172 'url': BX.userOptions.path+sParam+'&sessid='+BX.bitrix_sessid(), 17173 'onsuccess': callback 17174 }); 17175 } 17176}; 17177 17178BX.userOptions.del = function(sCategory, sName, bCommon, callback) 17179{ 17180 BX.ajax.get(BX.userOptions.path+'action=delete&c='+sCategory+'&n='+sName+(bCommon == true? '&common=Y':'')+'&sessid='+BX.bitrix_sessid(), callback); 17181}; 17182 17183BX.userOptions.__get = function() 17184{ 17185 if (!BX.userOptions.options) return ''; 17186 17187 var sParam = '', n = -1, prevParam = '', aOpt, i; 17188 17189 for (i in BX.userOptions.options) 17190 { 17191 if(BX.userOptions.options.hasOwnProperty(i)) 17192 { 17193 aOpt = BX.userOptions.options[i]; 17194 17195 if (prevParam != aOpt[0]+'.'+aOpt[1]) 17196 { 17197 n++; 17198 sParam += '&p['+n+'][c]='+BX.util.urlencode(aOpt[0]); 17199 sParam += '&p['+n+'][n]='+BX.util.urlencode(aOpt[1]); 17200 if (aOpt[4] == true) 17201 sParam += '&p['+n+'][d]=Y'; 17202 prevParam = aOpt[0]+'.'+aOpt[1]; 17203 } 17204 17205 var valueName = aOpt[2]; 17206 var value = aOpt[3]; 17207 17208 if (valueName === null) 17209 { 17210 sParam += '&p['+n+'][v]='+BX.util.urlencode(value); 17211 } 17212 else 17213 {
17214 sParam += '&p['+n+'][v]['+BX.util.urlencode(valueName)+']='+BX.util.urlencode(value); 17215 } 17216 } 17217 } 17218 17219 return sParam.substr(1); 17220}; 17221 17222BX.ajax.history = { 17223 expected_hash: '', 17224 17225 obParams: null, 17226 17227 obFrame: null, 17228 obImage: null, 17229 17230 obTimer: null, 17231 17232 bInited: false, 17233 bHashCollision: false, 17234 bPushState: !!(history.pushState && BX.type.isFunction(history.pushState)), 17235 17236 startState: null, 17237 17238 init: function(obParams) 17239 { 17240 if (BX.ajax.history.bInited) 17241 return; 17242 17243 this.obParams = obParams; 17244 var obCurrentState = this.obParams.getState(); 17245 17246 if (BX.ajax.history.bPushState) 17247 { 17248 BX.ajax.history.expected_hash = window.location.pathname; 17249 if (window.location.search) 17250 BX.ajax.history.expected_hash += window.location.search; 17251 17252 BX.ajax.history.put(obCurrentState, BX.ajax.history.expected_hash, '', true); 17253 // due to some strange thing, chrome calls popstate event on page start. so we should delay it 17254 setTimeout(function(){BX.bind(window, 'popstate', BX.ajax.history.__hashListener);}, 500); 17255 } 17256 else 17257 { 17258 BX.ajax.history.expected_hash = window.location.hash; 17259 17260 if (!BX.ajax.history.expected_hash || BX.ajax.history.expected_hash == '#') 17261 BX.ajax.history.expected_hash = '__bx_no_hash__'; 17262 17263 jsAjaxHistoryContainer.put(BX.ajax.history.expected_hash, obCurrentState); 17264 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 17265 17266 if (BX.browser.IsIE()) 17267 { 17268 BX.ajax.history.obFrame = document.createElement('IFRAME'); 17269 BX.hide_object(BX.ajax.history.obFrame); 17270 17271 document.body.appendChild(BX.ajax.history.obFrame); 17272 17273 BX.ajax.history.obFrame.contentWindow.document.open(); 17274 BX.ajax.history.obFrame.contentWindow.document.write(BX.ajax.history.expected_hash); 17275 BX.ajax.history.obFrame.contentWindow.document.close(); 17276 } 17277 else if (BX.browser.IsOpera()) 17278 { 17279 BX.ajax.history.obImage = document.createElement('IMG'); 17280 BX.hide_object(BX.ajax.history.obImage); 17281 17282 document.body.appendChild(BX.ajax.history.obImage); 17283 17284 BX.ajax.history.obImage.setAttribute('src', 'javascript:location.href = \'javascript:BX.ajax.history.__hashListener();\';'); 17285 } 17286 } 17287 17288 BX.ajax.history.bInited = true; 17289 }, 17290 17291 __hashListener: function(e) 17292 { 17293 e = e || window.event || {state:false}; 17294 17295 if (BX.ajax.history.bPushState) 17296 { 17297 BX.ajax.history.obParams.setState(e.state||BX.ajax.history.startState); 17298 } 17299 else 17300 { 17301 if (BX.ajax.history.obTimer) 17302 { 17303 window.clearTimeout(BX.ajax.history.obTimer); 17304 BX.ajax.history.obTimer = null; 17305 } 17306 17307 var current_hash; 17308 if (null != BX.ajax.history.obFrame) 17309 current_hash = BX.ajax.history.obFrame.contentWindow.document.body.innerText; 17310 else 17311 current_hash = window.location.hash; 17312 17313 if (!current_hash || current_hash == '#') 17314 current_hash = '__bx_no_hash__'; 17315 17316 if (current_hash.indexOf('#') == 0) 17317 current_hash = current_hash.substring(1); 17318 17319 if (current_hash != BX.ajax.history.expected_hash) 17320 { 17321 var state = jsAjaxHistoryContainer.get(current_hash); 17322 if (state) 17323 { 17324 BX.ajax.history.obParams.setState(state); 17325 17326 BX.ajax.history.expected_hash = current_hash; 17327 if (null != BX.ajax.history.obFrame) 17328 { 17329 var __hash = current_hash == '__bx_no_hash__' ? '' : current_hash; 17330 if (window.location.hash != __hash && window.location.hash != '#' + __hash) 17331 window.location.hash = __hash; 17332 } 17333 } 17334 } 17335 17336 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 17337 } 17338 }, 17339 17340 put: function(state, new_hash, new_hash1, bStartState) 17341 { 17342 if (this.bPushState) 17343 { 17344 if(!bStartState) 17345 { 17346 history.pushState(state, '', new_hash); 17347 } 17348 else 17349 { 17350 BX.ajax.history.startState = state; 17351 } 17352 } 17353 else 17354 { 17355 if (typeof new_hash1 != 'undefined') 17356 new_hash = new_hash1; 17357 else 17358 new_hash = 'view' + new_hash; 17359 17360 jsAjaxHistoryContainer.put(new_hash, state); 17361 BX.ajax.history.expected_hash = new_hash; 17362 17363 window.location.hash = BX.util.urlencode(new_hash); 17364 17365 if (null != BX.ajax.history.obFrame) 17366 { 17367 BX.ajax.history.obFrame.contentWindow.document.open(); 17368 BX.ajax.history.obFrame.contentWindow.document.write(new_hash); 17369 BX.ajax.history.obFrame.contentWindow.document.close(); 17370 } 17371 } 17372 }, 17373 17374 checkRedirectStart: function(param_name, param_value) 17375 { 17376 var current_hash = window.location.hash; 17377 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 17378 17379 var test = current_hash.substring(0, 5); 17380 if (test == 'view/' || test == 'view%') 17381 { 17382 BX.ajax.history.bHashCollision = true;
17383 document.write('<' + 'div id="__ajax_hash_collision_' + param_value + '" style="display: none;">'); 17384 } 17385 }, 17386 17387 checkRedirectFinish: function(param_name, param_value) 17388 { 17389 document.write('</div>'); 17390 17391 var current_hash = window.location.hash; 17392 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 17393 17394 BX.ready(function () 17395 { 17396 var test = current_hash.substring(0, 5); 17397 if (test == 'view/' || test == 'view%') 17398 { 17399 var obColNode = BX('__ajax_hash_collision_' + param_value); 17400 var obNode = obColNode.firstChild; 17401 BX.cleanNode(obNode); 17402 obColNode.style.display = 'block'; 17403 17404 // IE, Opera and Chrome automatically modifies hash with urlencode, but FF doesn't ;-( 17405 if (test != 'view%') 17406 current_hash = BX.util.urlencode(current_hash); 17407 17408 current_hash += (current_hash.indexOf('%3F') == -1 ? '%3F' : '%26') + param_name + '=' + param_value; 17409 17410 var url = '/bitrix/tools/ajax_redirector.php?hash=' + current_hash; 17411 17412 BX.ajax.insertToNode(url, obNode); 17413 } 17414 }); 17415 } 17416}; 17417 17418BX.ajax.component = function(node) 17419{ 17420 this.node = node; 17421}; 17422 17423BX.ajax.component.prototype.getState = function() 17424{ 17425 var state = { 17426 'node': this.node, 17427 'title': window.document.title, 17428 'data': BX(this.node).innerHTML 17429 }; 17430 17431 var obNavChain = BX('navigation'); 17432 if (null != obNavChain) 17433 state.nav_chain = obNavChain.innerHTML; 17434 17435 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistoryGetState", [state]); 17436 17437 return state; 17438}; 17439 17440BX.ajax.component.prototype.setState = function(state) 17441{ 17442 BX(state.node).innerHTML = state.data; 17443 BX.ajax.UpdatePageTitle(state.title); 17444 17445 if (state.nav_chain) 17446 { 17447 BX.ajax.UpdatePageNavChain(state.nav_chain); 17448 } 17449 17450 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistorySetState", [state]); 17451}; 17452 17453var jsAjaxHistoryContainer = { 17454 arHistory: {}, 17455 17456 put: function(hash, state) 17457 { 17458 this.arHistory[hash] = state; 17459 }, 17460 17461 get: function(hash) 17462 { 17463 return this.arHistory[hash]; 17464 } 17465}; 17466 17467 17468BX.ajax.FormData = function() 17469{ 17470 this.elements = []; 17471 this.files = []; 17472 this.features = {}; 17473 this.isSupported(); 17474 this.log('BX FormData init'); 17475}; 17476 17477BX.ajax.FormData.isSupported = function() 17478{ 17479 var f = new BX.ajax.FormData(); 17480 var result = f.features.supported; 17481 f = null; 17482 return result; 17483}; 17484 17485BX.ajax.FormData.prototype.log = function(o) 17486{ 17487 if (false) { 17488 try { 17489 if (BX.browser.IsIE()) o = JSON.stringify(o); 17490 console.log(o); 17491 } catch(e) {} 17492 } 17493}; 17494 17495BX.ajax.FormData.prototype.isSupported = function() 17496{ 17497 var f = {}; 17498 f.fileReader = (window.FileReader && window.FileReader.prototype.readAsBinaryString); 17499 f.readFormData = f.sendFormData = !!(window.FormData); 17500 f.supported = !!(f.readFormData && f.sendFormData); 17501 this.features = f; 17502 this.log('features:'); 17503 this.log(f); 17504 17505 return f.supported; 17506}; 17507 17508BX.ajax.FormData.prototype.append = function(name, value) 17509{ 17510 if (typeof(value) === 'object') { // seems to be files element 17511 this.files.push({'name': name, 'value':value}); 17512 } else { 17513 this.elements.push({'name': name, 'value':value}); 17514 } 17515}; 17516 17517BX.ajax.FormData.prototype.send = function(url, callbackOk, callbackProgress, callbackError) 17518{ 17519 this.log('FD send'); 17520 this.xhr = BX.ajax({ 17521 'method': 'POST', 17522 'dataType': 'html', 17523 'url': url, 17524 'onsuccess': callbackOk, 17525 'onfailure': callbackError, 17526 'start': false, 17527 'preparePost':false 17528 }); 17529 17530 if (callbackProgress) 17531 { 17532 this.xhr.upload.addEventListener( 17533 'progress', 17534 function(e) { 17535 if (e.lengthComputable) 17536 callbackProgress(e.loaded / (e.total || e.totalSize)); 17537 }, 17538 false 17539 ); 17540 } 17541 17542 if (this.features.readFormData && this.features.sendFormData) 17543 { 17544 var fd = new FormData(); 17545 this.log('use browser formdata'); 17546 for (var i in this.elements) 17547 { 17548 if(this.elements.hasOwnProperty(i)) 17549 fd.append(this.elements[i].name,this.elements[i].value); 17550 } 17551 for (i in this.files) 17552 { 17553 if(this.files.hasOwnProperty(i)) 17554 fd.append(this.files[i].name, this.files[i].value); 17555 } 17556 this.xhr.send(fd); 17557 } 17558 17559 return this.xhr; 17560}; 17561 17562BX.addCustomEvent('onAjaxFailure', BX.debug); 17563})(window); 17564 17565 17566(function (exports,main_core) { 17567 'use strict'; 17568 17569 var LazyLoad = { 17570 observer: null, 17571 images: {}, 17572 imageStatus: { 17573 hidden: -2, 17574 error: -1, 17575 "undefined": 0, 17576 inited: 1, 17577 loaded: 2 17578 }, 17579 imageTypes: { 17580 image: 1, 17581 background: 2 17582 },
17583 initObserver: function initObserver() { 17584 this.observer = new IntersectionObserver(this.onIntersection.bind(this), { 17585 rootMargin: '20% 0% 20% 0%', 17586 threshold: 0.10 17587 }); 17588 }, 17589 onIntersection: function onIntersection(entries) { 17590 entries.forEach(function (entry) { 17591 if (entry.isIntersecting) { 17592 this.showImage(entry.target); 17593 } 17594 }.bind(this)); 17595 }, 17596 registerImage: function registerImage(id, isImageVisibleCallback, options) { 17597 if (this.observer === null) { 17598 this.initObserver(); 17599 } 17600 17601 options = options || {}; 17602 17603 if (!main_core.Type.isStringFilled(id)) { 17604 return; 17605 } 17606 17607 if (main_core.Type.isObject(this.images[id])) { 17608 return; 17609 } 17610 17611 var element = document.getElementById(id); 17612 17613 if (!main_core.Type.isDomNode(element)) { 17614 return; 17615 } 17616 17617 this.observer.observe(element); 17618 this.images[id] = { 17619 id: id, 17620 node: null, 17621 src: null, 17622 dataSrcName: options.dataSrcName || 'src', 17623 type: null, 17624 func: main_core.Type.isFunction(isImageVisibleCallback) ? isImageVisibleCallback : null, 17625 status: this.imageStatus.undefined 17626 }; 17627 }, 17628 registerImages: function registerImages(ids, isImageVisibleCallback, options) { 17629 if (main_core.Type.isArray(ids)) { 17630 for (var i = 0, length = ids.length; i < length; i++) { 17631 this.registerImage(ids[i], isImageVisibleCallback, options); 17632 } 17633 } 17634 }, 17635 showImage: function showImage(imageNode) { 17636 var imageNodeId = imageNode.id; 17637 17638 if (!main_core.Type.isStringFilled(imageNodeId)) { 17639 return; 17640 } 17641 17642 var image = this.images[imageNodeId]; 17643 17644 if (!main_core.Type.isPlainObject(image)) { 17645 return; 17646 } 17647 17648 if (image.status == this.imageStatus.undefined) { 17649 this.initImage(image); 17650 } 17651 17652 if (image.status !== this.imageStatus.inited) { 17653 return; 17654 } 17655 17656 if (!image.node || !image.node.parentNode) { 17657 image.node = null; 17658 image.status = this.imageStatus.error; 17659 return; 17660 } 17661 17662 if (image.type == this.imageTypes.image) { 17663 image.node.src = image.src; 17664 } else { 17665 image.node.style.backgroundImage = "url('" + image.src + "')"; 17666 } 17667 17668 image.node.dataset[image.dataSrcName] = ""; 17669 image.status = this.imageStatus.loaded; 17670 }, 17671 showImages: function showImages(checkOwnVisibility) { 17672 checkOwnVisibility = checkOwnVisibility !== false; 17673 17674 for (var id in this.images) { 17675 if (!this.images.hasOwnProperty(id)) { 17676 continue; 17677 } 17678 17679 var image = this.images[id]; 17680 17681 if (image.status == this.imageStatus.undefined) { 17682 this.initImage(image); 17683 } 17684 17685 if (image.status !== this.imageStatus.inited) { 17686 continue; 17687 } 17688 17689 if (!image.node || !image.node.parentNode) { 17690 image.node = null; 17691 image.status = this.imageStatus.error; 17692 continue; 17693 } 17694 17695 var isImageVisible = true; 17696 17697 if (checkOwnVisibility && main_core.Type.isFunction(image.func)) { 17698 isImageVisible = image.func(image); 17699 } 17700 17701 if (isImageVisible === true && this.isElementVisibleOnScreen(image.node)) { 17702 if (image.type == this.imageTypes.image) { 17703 image.node.src = image.src; 17704 } else { 17705 image.node.style.backgroundImage = "url('" + image.src + "')"; 17706 } 17707 17708 image.node.dataset[image.dataSrcName] = ""; 17709 image.status = this.imageStatus.loaded; 17710 } 17711 } 17712 }, 17713 initImage: function initImage(image) { 17714 image.status = this.imageStatus.error; 17715 var node = document.getElementById(image.id); 17716 17717 if (!main_core.Type.isDomNode(node)) { 17718 return; 17719 } 17720 17721 var src = node.dataset[image.dataSrcName]; 17722 17723 if (main_core.Type.isStringFilled(src)) { 17724 image.node = node; 17725 image.src = src; 17726 image.status = this.imageStatus.inited; 17727 image.type = image.node.tagName.toLowerCase() == "img" ? this.imageTypes.image : this.imageTypes.background; 17728 } 17729 }, 17730 isElementVisibleOnScreen: function isElementVisibleOnScreen(element) { 17731 var coords = this.getElementCoords(element); 17732 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 17733 var windowBottom = windowTop + document.documentElement.clientHeight; 17734 coords.bottom = coords.top + element.offsetHeight; 17735 return coords.top > windowTop && coords.top < windowBottom || // topVisible 17736 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 17737 ; 17738 }, 17739 isElementVisibleOn2Screens: function isElementVisibleOn2Screens(element) { 17740 var windowHeight = document.documentElement.clientHeight; 17741 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 17742 var windowBottom = windowTop + windowHeight; 17743 var coords = this.getElementCoords(element); 17744 coords.bottom = coords.top + element.offsetHeight; 17745 windowTop -= windowHeight; 17746 windowBottom += windowHeight; 17747 return coords.top > windowTop && coords.top < windowBottom || // topVisible 17748 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 17749 ; 17750 }, 17751 getElementCoords: function getElementCoords(element) { 17752 var box = element.getBoundingClientRect(); 17753 return { 17754 originTop: box.top, 17755 originLeft: box.left, 17756 top: box.top + window.pageYOffset, 17757 left: box.left + window.pageXOffset 17758 }; 17759 }, 17760 onScroll: function onScroll() {}, 17761 clearImages: function clearImages() { 17762 this.images = []; 17763 } 17764 }; 17765 17766 exports.LazyLoad = LazyLoad; 17767 17768}((this.BX = this.BX || {}),BX)); 17769 17770 17771 17772(function (exports) { 17773 'use strict'; 17774 17775 var ParamBag = /*#__PURE__*/function () { 17776 function ParamBag() { 17777 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 17778 babelHelpers.classCallCheck(this, ParamBag); 17779 17780 if (!!params && babelHelpers.typeof(params) === 'object') { 17781 this.params = new Map(Object.entries(params)); 17782 } else { 17783 this.params = new Map(); 17784 } 17785 } 17786 17787 babelHelpers.createClass(ParamBag, [{ 17788 key: "getParam", 17789 value: function getParam(key) { 17790 var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 17791 17792 if (this.params.has(key)) { 17793 return this.params.get(key); 17794 } 17795 17796 return defaultValue; 17797 } 17798 }, { 17799 key: "setParam", 17800 value: function setParam(key, value) { 17801 this.params.set(key, value); 17802 } 17803 }, { 17804 key: "clear", 17805 value: function clear() { 17806 this.params.clear(); 17807 } 17808 }], [{ 17809 key: "create", 17810 value: function create() { 17811 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 17812 return new ParamBag(params); 17813 } 17814 }]); 17815 return ParamBag; 17816 }(); 17817 17818 exports.ParamBag = ParamBag; 17819 17820}((this.BX = this.BX || {}))); 17821 17822 17823 17824(function() { 17825 BX.FixFontSize = function(params) 17826 { 17827 var widthNode, computedStyles, width; 17828 17829 this.node = null; 17830 this.prevWindowSize = 0; 17831 this.prevWrapperSize = 0; 17832 this.mainWrapper = null; 17833 this.textWrapper = null; 17834 this.objList = params.objList; 17835 this.minFontSizeList = []; 17836 this.minFontSize = 0; 17837 17838 if (params.onresize) 17839 { 17840 this.prevWindowSize = window.innerWidth || document.documentElement.clientWidth; 17841 BX.bind(window, 'resize', BX.throttle(this.onResize, 350, this)); 17842 } 17843 17844 if (params.onAdaptiveResize) 17845 { 17846 widthNode = this.objList[0].scaleBy || this.objList[0].node; 17847 computedStyles = getComputedStyle(widthNode); 17848 this.prevWrapperSize = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 17849 BX.bind(window, 'resize', BX.throttle(this.onAdaptiveResize, 350, this)); 17850 } 17851 17852 this.createTestNodes(); 17853 this.decrease(); 17854 }; 17855 17856 BX.FixFontSize.prototype = 17857 { 17858 createTestNodes: function() 17859 { 17860 this.textWrapper = BX.create('div',{ 17861 style : { 17862 display : 'inline-block', 17863 whiteSpace : 'nowrap' 17864 } 17865 }); 17866 17867 this.mainWrapper = BX.create('div',{ 17868 style : { 17869 height : 0, 17870 overflow : 'hidden' 17871 }, 17872 children : [this.textWrapper] 17873 }); 17874 17875 }, 17876 insertTestNodes: function() 17877 { 17878 document.body.appendChild(this.mainWrapper); 17879 }, 17880 removeTestNodes: function() 17881 { 17882 document.body.removeChild(this.mainWrapper); 17883 }, 17884 decrease: function() 17885 { 17886 var width, 17887 fontSize, 17888 widthNode, 17889 computedStyles; 17890 17891 this.insertTestNodes(); 17892
17893 for(var i=this.objList.length-1; i>=0; i--) 17894 { 17895 widthNode = this.objList[i].scaleBy || this.objList[i].node; 17896 computedStyles = getComputedStyle(widthNode); 17897 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 17898 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 17899 17900 this.textWrapperSetStyle(this.objList[i].node); 17901 17902 if(this.textWrapperInsertText(this.objList[i].node)) 17903 { 17904 while(this.textWrapper.offsetWidth > width && fontSize > 0) 17905 { 17906 this.textWrapper.style.fontSize = --fontSize + 'px'; 17907 } 17908 17909 if(this.objList[i].smallestValue) 17910 { 17911 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 17912 17913 this.minFontSizeList.push(this.objList[i].node) 17914 } 17915 else 17916 { 17917 this.objList[i].node.style.fontSize = fontSize + 'px'; 17918 } 17919 } 17920 } 17921 17922 if(this.minFontSizeList.length > 0) 17923 this.setMinFont(); 17924 17925 this.removeTestNodes(); 17926 17927 }, 17928 increase: function() 17929 { 17930 this.insertTestNodes(); 17931 var width, 17932 fontSize, 17933 widthNode, 17934 computedStyles; 17935 17936 this.insertTestNodes(); 17937 17938 for(var i=this.objList.length-1; i>=0; i--) 17939 { 17940 widthNode = this.objList[i].scaleBy || this.objList[i].node; 17941 computedStyles = getComputedStyle(widthNode); 17942 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 17943 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 17944 17945 this.textWrapperSetStyle(this.objList[i].node); 17946 17947 if(this.textWrapperInsertText(this.objList[i].node)) 17948 { 17949 while(this.textWrapper.offsetWidth < width && fontSize < this.objList[i].maxFontSize) 17950 { 17951 this.textWrapper.style.fontSize = ++fontSize + 'px'; 17952 } 17953 17954 fontSize--; 17955 17956 if(this.objList[i].smallestValue) 17957 { 17958 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 17959 17960 this.minFontSizeList.push(this.objList[i].node) 17961 } 17962 else 17963 { 17964 this.objList[i].node.style.fontSize = fontSize + 'px'; 17965 } 17966 } 17967 } 17968 17969 if(this.minFontSizeList.length > 0) 17970 this.setMinFont(); 17971 17972 this.removeTestNodes(); 17973 }, 17974 setMinFont : function() 17975 { 17976 for(var i = this.minFontSizeList.length-1; i>=0; i--) 17977 { 17978 this.minFontSizeList[i].style.fontSize = this.minFontSize + 'px'; 17979 } 17980 17981 this.minFontSize = 0; 17982 }, 17983 onResize : function() 17984 { 17985 var width = window.innerWidth || document.documentElement.clientWidth; 17986 17987 if(this.prevWindowSize > width) 17988 this.decrease(); 17989 17990 else if (this.prevWindowSize < width) 17991 this.increase(); 17992 17993 this.prevWindowSize = width; 17994 }, 17995 onAdaptiveResize : function() 17996 { 17997 var widthNode = this.objList[0].scaleBy || this.objList[0].node, 17998 computedStyles = getComputedStyle(widthNode), 17999 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 18000 18001 if (this.prevWrapperSize > width) 18002 this.decrease(); 18003 else if (this.prevWrapperSize < width) 18004 this.increase(); 18005 18006 this.prevWrapperSize = width; 18007 }, 18008 textWrapperInsertText : function(node) 18009 { 18010 if(node.textContent){ 18011 this.textWrapper.textContent = node.textContent; 18012 return true; 18013 } 18014 else if(node.innerText) 18015 { 18016 this.textWrapper.innerText = node.innerText; 18017 return true; 18018 } 18019 else { 18020 return false; 18021 } 18022 }, 18023 textWrapperSetStyle : function(node) 18024 { 18025 this.textWrapper.style.fontFamily = getComputedStyle(node)["font-family"]; 18026 this.textWrapper.style.fontSize = getComputedStyle(node)["font-size"]; 18027 this.textWrapper.style.fontStyle = getComputedStyle(node)["font-style"]; 18028 this.textWrapper.style.fontWeight = getComputedStyle(node)["font-weight"]; 18029 this.textWrapper.style.lineHeight = getComputedStyle(node)["line-height"]; 18030 } 18031 }; 18032 18033 BX.FixFontSize.init = function(params) 18034 { 18035 return new BX.FixFontSize(params); 18036 }; 18037})(); 18038 18039})(); 18040//# 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.