1;(function() { 2 3 if (typeof window.BX === 'function') 4 { 5 return; 6 } 7 8/** 9 * Babel external helpers 10 * (c) 2018 Babel 11 * @license MIT 12 */ 13(function (global) { 14 var babelHelpers = global.babelHelpers = {}; 15 16 function _typeof(obj) { 17 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 18 babelHelpers.typeof = _typeof = function (obj) { 19 return typeof obj; 20 }; 21 } else { 22 babelHelpers.typeof = _typeof = function (obj) { 23 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 24 }; 25 } 26 27 return _typeof(obj); 28 } 29 30 babelHelpers.typeof = _typeof; 31 var REACT_ELEMENT_TYPE; 32 33 function _createRawReactElement(type, props, key, children) { 34 if (!REACT_ELEMENT_TYPE) { 35 REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; 36 } 37 38 var defaultProps = type && type.defaultProps; 39 var childrenLength = arguments.length - 3; 40 41 if (!props && childrenLength !== 0) { 42 props = { 43 children: void 0 44 }; 45 } 46 47 if (props && defaultProps) { 48 for (var propName in defaultProps) { 49 if (props[propName] === void 0) { 50 props[propName] = defaultProps[propName]; 51 } 52 } 53 } else if (!props) { 54 props = defaultProps || {}; 55 } 56 57 if (childrenLength === 1) { 58 props.children = children; 59 } else if (childrenLength > 1) { 60 var childArray = new Array(childrenLength); 61 62 for (var i = 0; i < childrenLength; i++) { 63 childArray[i] = arguments[i + 3]; 64 } 65 66 props.children = childArray; 67 } 68 69 return { 70 $$typeof: REACT_ELEMENT_TYPE, 71 type: type, 72 key: key === undefined ? null : '' + key, 73 ref: null, 74 props: props, 75 _owner: null 76 }; 77 } 78 79 babelHelpers.jsx = _createRawReactElement; 80 81 function _asyncIterator(iterable) { 82 var method; 83 84 if (typeof Symbol === "function") { 85 if (Symbol.asyncIterator) { 86 method = iterable[Symbol.asyncIterator]; 87 if (method != null) return method.call(iterable); 88 } 89 90 if (Symbol.iterator) { 91 method = iterable[Symbol.iterator]; 92 if (method != null) return method.call(iterable); 93 } 94 } 95 96 throw new TypeError("Object is not async iterable"); 97 } 98 99 babelHelpers.asyncIterator = _asyncIterator; 100 101 function _AwaitValue(value) { 102 this.wrapped = value; 103 } 104 105 babelHelpers.AwaitValue = _AwaitValue; 106 107 function AsyncGenerator(gen) { 108 var front, back; 109 110 function send(key, arg) { 111 return new Promise(function (resolve, reject) { 112 var request = { 113 key: key, 114 arg: arg, 115 resolve: resolve, 116 reject: reject, 117 next: null 118 }; 119 120 if (back) { 121 back = back.next = request; 122 } else { 123 front = back = request; 124 resume(key, arg); 125 } 126 }); 127 } 128 129 function resume(key, arg) { 130 try { 131 var result = gen[key](arg); 132 var value = result.value; 133 var wrappedAwait = value instanceof babelHelpers.AwaitValue; 134 Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { 135 if (wrappedAwait) { 136 resume("next", arg); 137 return; 138 } 139 140 settle(result.done ? "return" : "normal", arg); 141 }, function (err) { 142 resume("throw", err); 143 }); 144 } catch (err) { 145 settle("throw", err); 146 } 147 } 148 149 function settle(type, value) { 150 switch (type) { 151 case "return": 152 front.resolve({ 153 value: value, 154 done: true 155 }); 156 break; 157 158 case "throw": 159 front.reject(value); 160 break; 161 162 default: 163 front.resolve({ 164 value: value, 165 done: false 166 }); 167 break; 168 } 169 170 front = front.next; 171 172 if (front) { 173 resume(front.key, front.arg); 174 } else { 175 back = null; 176 } 177 } 178 179 this._invoke = send; 180 181 if (typeof gen.return !== "function") { 182 this.return = undefined; 183 } 184 } 185 186 if (typeof Symbol === "function" && Symbol.asyncIterator) { 187 AsyncGenerator.prototype[Symbol.asyncIterator] = function () { 188 return this; 189 }; 190 } 191 192 AsyncGenerator.prototype.next = function (arg) { 193 return this._invoke("next", arg); 194 }; 195 196 AsyncGenerator.prototype.throw = function (arg) { 197 return this._invoke("throw", arg); 198 }; 199 200 AsyncGenerator.prototype.return = function (arg) { 201 return this._invoke("return", arg); 202 }; 203 204 babelHelpers.AsyncGenerator = AsyncGenerator; 205 206 function _wrapAsyncGenerator(fn) { 207 return function () { 208 return new babelHelpers.AsyncGenerator(fn.apply(this, arguments)); 209 }; 210 } 211 212 babelHelpers.wrapAsyncGenerator = _wrapAsyncGenerator; 213 214 function _awaitAsyncGenerator(value) { 215 return new babelHelpers.AwaitValue(value); 216 } 217 218 babelHelpers.awaitAsyncGenerator = _awaitAsyncGenerator; 219 220 function _asyncGeneratorDelegate(inner, awaitWrap) { 221 var iter = {}, 222 waiting = false;
223 224 function pump(key, value) { 225 waiting = true; 226 value = new Promise(function (resolve) { 227 resolve(inner[key](value)); 228 }); 229 return { 230 done: false, 231 value: awaitWrap(value) 232 }; 233 } 234 235 ; 236 237 if (typeof Symbol === "function" && Symbol.iterator) { 238 iter[Symbol.iterator] = function () { 239 return this; 240 }; 241 } 242 243 iter.next = function (value) { 244 if (waiting) { 245 waiting = false; 246 return value; 247 } 248 249 return pump("next", value); 250 }; 251 252 if (typeof inner.throw === "function") { 253 iter.throw = function (value) { 254 if (waiting) { 255 waiting = false; 256 throw value; 257 } 258 259 return pump("throw", value); 260 }; 261 } 262 263 if (typeof inner.return === "function") { 264 iter.return = function (value) { 265 return pump("return", value); 266 }; 267 } 268 269 return iter; 270 } 271 272 babelHelpers.asyncGeneratorDelegate = _asyncGeneratorDelegate; 273 274 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { 275 try { 276 var info = gen[key](arg); 277 var value = info.value; 278 } catch (error) { 279 reject(error); 280 return; 281 } 282 283 if (info.done) { 284 resolve(value); 285 } else { 286 Promise.resolve(value).then(_next, _throw); 287 } 288 } 289 290 function _asyncToGenerator(fn) { 291 return function () { 292 var self = this, 293 args = arguments; 294 return new Promise(function (resolve, reject) { 295 var gen = fn.apply(self, args); 296 297 function _next(value) { 298 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); 299 } 300 301 function _throw(err) { 302 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); 303 } 304 305 _next(undefined); 306 }); 307 }; 308 } 309 310 babelHelpers.asyncToGenerator = _asyncToGenerator; 311 312 function _classCallCheck(instance, Constructor) { 313 if (!(instance instanceof Constructor)) { 314 throw new TypeError("Cannot call a class as a function"); 315 } 316 } 317 318 babelHelpers.classCallCheck = _classCallCheck; 319 320 function _defineProperties(target, props) { 321 for (var i = 0; i < props.length; i++) { 322 var descriptor = props[i]; 323 descriptor.enumerable = descriptor.enumerable || false; 324 descriptor.configurable = true; 325 if ("value" in descriptor) descriptor.writable = true; 326 Object.defineProperty(target, descriptor.key, descriptor); 327 } 328 } 329 330 function _createClass(Constructor, protoProps, staticProps) { 331 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 332 if (staticProps) _defineProperties(Constructor, staticProps); 333 return Constructor; 334 } 335 336 babelHelpers.createClass = _createClass; 337 338 function _defineEnumerableProperties(obj, descs) { 339 for (var key in descs) { 340 var desc = descs[key]; 341 desc.configurable = desc.enumerable = true; 342 if ("value" in desc) desc.writable = true; 343 Object.defineProperty(obj, key, desc); 344 } 345 346 if (Object.getOwnPropertySymbols) { 347 var objectSymbols = Object.getOwnPropertySymbols(descs); 348 349 for (var i = 0; i < objectSymbols.length; i++) { 350 var sym = objectSymbols[i]; 351 var desc = descs[sym]; 352 desc.configurable = desc.enumerable = true; 353 if ("value" in desc) desc.writable = true; 354 Object.defineProperty(obj, sym, desc); 355 } 356 } 357 358 return obj; 359 } 360 361 babelHelpers.defineEnumerableProperties = _defineEnumerableProperties; 362 363 function _defaults(obj, defaults) { 364 var keys = Object.getOwnPropertyNames(defaults); 365 366 for (var i = 0; i < keys.length; i++) { 367 var key = keys[i]; 368 var value = Object.getOwnPropertyDescriptor(defaults, key); 369 370 if (value && value.configurable && obj[key] === undefined) { 371 Object.defineProperty(obj, key, value); 372 } 373 } 374 375 return obj; 376 } 377 378 babelHelpers.defaults = _defaults; 379 380 function _defineProperty(obj, key, value) { 381 if (key in obj) { 382 Object.defineProperty(obj, key, { 383 value: value, 384 enumerable: true, 385 configurable: true, 386 writable: true 387 }); 388 } else { 389 obj[key] = value; 390 } 391 392 return obj; 393 } 394 395 babelHelpers.defineProperty = _defineProperty; 396 397 function _extends() { 398 babelHelpers.extends = _extends = Object.assign || function (target) { 399 for (var i = 1; i < arguments.length; i++) { 400 var source = arguments[i]; 401 402 for (var key in source) { 403 if (Object.prototype.hasOwnProperty.call(source, key)) { 404 target[key] = source[key]; 405 } 406 } 407 } 408 409 return target; 410 }; 411 412 return _extends.apply(this, arguments); 413 } 414 415 babelHelpers.extends = _extends; 416 417 function _objectSpread(target) { 418 for (var i = 1; i < arguments.length; i++) { 419 var source = arguments[i] != null ? arguments[i] : {}; 420 var ownKeys = Object.keys(source); 421 422 if (typeof Object.getOwnPropertySymbols === 'function') { 423 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { 424 return Object.getOwnPropertyDescriptor(source, sym).enumerable; 425 })); 426 } 427 428 ownKeys.forEach(function (key) { 429 babelHelpers.defineProperty(target, key, source[key]); 430 }); 431 } 432 433 return target; 434 } 435 436 babelHelpers.objectSpread = _objectSpread; 437 438 function _inherits(subClass, superClass) { 439 if (typeof superClass !== "function" && superClass !== null) { 440 throw new TypeError("Super expression must either be null or a function"); 441 } 442 443 subClass.prototype = Object.create(superClass && superClass.prototype, { 444 constructor: { 445 value: subClass, 446 writable: true, 447 configurable: true 448 } 449 }); 450 if (superClass) babelHelpers.setPrototypeOf(subClass, superClass); 451 } 452 453 babelHelpers.inherits = _inherits; 454 455 function _inheritsLoose(subClass, superClass) { 456 subClass.prototype = Object.create(superClass.prototype); 457 subClass.prototype.constructor = subClass; 458 subClass.__proto__ = superClass; 459 } 460 461 babelHelpers.inheritsLoose = _inheritsLoose; 462
463 function _getPrototypeOf(o) { 464 babelHelpers.getPrototypeOf = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { 465 return o.__proto__ || Object.getPrototypeOf(o); 466 }; 467 return _getPrototypeOf(o); 468 } 469 470 babelHelpers.getPrototypeOf = _getPrototypeOf; 471 472 function _setPrototypeOf(o, p) { 473 babelHelpers.setPrototypeOf = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { 474 o.__proto__ = p; 475 return o; 476 }; 477 478 return _setPrototypeOf(o, p); 479 } 480 481 babelHelpers.setPrototypeOf = _setPrototypeOf; 482 483 function isNativeReflectConstruct() { 484 if (typeof Reflect === "undefined" || !Reflect.construct) return false; 485 if (Reflect.construct.sham) return false; 486 if (typeof Proxy === "function") return true; 487 488 try { 489 Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); 490 return true; 491 } catch (e) { 492 return false; 493 } 494 } 495 496 function _construct(Parent, args, Class) { 497 if (isNativeReflectConstruct()) { 498 babelHelpers.construct = _construct = Reflect.construct; 499 } else { 500 babelHelpers.construct = _construct = function _construct(Parent, args, Class) { 501 var a = [null]; 502 a.push.apply(a, args); 503 var Constructor = Function.bind.apply(Parent, a); 504 var instance = new Constructor(); 505 if (Class) babelHelpers.setPrototypeOf(instance, Class.prototype); 506 return instance; 507 }; 508 } 509 510 return _construct.apply(null, arguments); 511 } 512 513 babelHelpers.construct = _construct; 514 515 function _isNativeFunction(fn) { 516 return Function.toString.call(fn).indexOf("[native code]") !== -1; 517 } 518 519 babelHelpers.isNativeFunction = _isNativeFunction; 520 521 function _wrapNativeSuper(Class) { 522 var _cache = typeof Map === "function" ? new Map() : undefined; 523 524 babelHelpers.wrapNativeSuper = _wrapNativeSuper = function _wrapNativeSuper(Class) { 525 if (Class === null || !babelHelpers.isNativeFunction(Class)) return Class; 526 527 if (typeof Class !== "function") { 528 throw new TypeError("Super expression must either be null or a function"); 529 } 530 531 if (typeof _cache !== "undefined") { 532 if (_cache.has(Class)) return _cache.get(Class); 533 534 _cache.set(Class, Wrapper); 535 } 536 537 function Wrapper() { 538 return babelHelpers.construct(Class, arguments, babelHelpers.getPrototypeOf(this).constructor); 539 } 540 541 Wrapper.prototype = Object.create(Class.prototype, { 542 constructor: { 543 value: Wrapper, 544 enumerable: false, 545 writable: true, 546 configurable: true 547 } 548 }); 549 return babelHelpers.setPrototypeOf(Wrapper, Class); 550 }; 551 552 return _wrapNativeSuper(Class); 553 } 554 555 babelHelpers.wrapNativeSuper = _wrapNativeSuper; 556 557 function _instanceof(left, right) { 558 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { 559 return right[Symbol.hasInstance](left); 560 } else { 561 return left instanceof right; 562 } 563 } 564 565 babelHelpers.instanceof = _instanceof; 566 567 function _interopRequireDefault(obj) { 568 return obj && obj.__esModule ? obj : { 569 default: obj 570 }; 571 } 572 573 babelHelpers.interopRequireDefault = _interopRequireDefault; 574 575 function _interopRequireWildcard(obj) { 576 if (obj && obj.__esModule) { 577 return obj; 578 } else { 579 var newObj = {}; 580 581 if (obj != null) { 582 for (var key in obj) { 583 if (Object.prototype.hasOwnProperty.call(obj, key)) { 584 var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; 585 586 if (desc.get || desc.set) { 587 Object.defineProperty(newObj, key, desc); 588 } else { 589 newObj[key] = obj[key]; 590 } 591 } 592 } 593 } 594 595 newObj.default = obj; 596 return newObj; 597 } 598 } 599 600 babelHelpers.interopRequireWildcard = _interopRequireWildcard; 601 602 function _newArrowCheck(innerThis, boundThis) { 603 if (innerThis !== boundThis) { 604 throw new TypeError("Cannot instantiate an arrow function"); 605 } 606 } 607 608 babelHelpers.newArrowCheck = _newArrowCheck; 609 610 function _objectDestructuringEmpty(obj) { 611 if (obj == null) throw new TypeError("Cannot destructure undefined"); 612 } 613 614 babelHelpers.objectDestructuringEmpty = _objectDestructuringEmpty; 615 616 function _objectWithoutPropertiesLoose(source, excluded) { 617 if (source == null) return {}; 618 var target = {}; 619 var sourceKeys = Object.keys(source); 620 var key, i; 621 622 for (i = 0; i < sourceKeys.length; i++) { 623 key = sourceKeys[i]; 624 if (excluded.indexOf(key) >= 0) continue; 625 target[key] = source[key]; 626 } 627 628 return target; 629 } 630 631 babelHelpers.objectWithoutPropertiesLoose = _objectWithoutPropertiesLoose; 632 633 function _objectWithoutProperties(source, excluded) { 634 if (source == null) return {}; 635 var target = babelHelpers.objectWithoutPropertiesLoose(source, excluded); 636 var key, i; 637 638 if (Object.getOwnPropertySymbols) { 639 var sourceSymbolKeys = Object.getOwnPropertySymbols(source); 640 641 for (i = 0; i < sourceSymbolKeys.length; i++) { 642 key = sourceSymbolKeys[i]; 643 if (excluded.indexOf(key) >= 0) continue; 644 if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; 645 target[key] = source[key]; 646 } 647 } 648 649 return target; 650 } 651 652 babelHelpers.objectWithoutProperties = _objectWithoutProperties; 653 654 function _assertThisInitialized(self) { 655 if (self === void 0) { 656 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 657 } 658 659 return self; 660 } 661 662 babelHelpers.assertThisInitialized = _assertThisInitialized; 663 664 function _possibleConstructorReturn(self, call) { 665 if (call && (typeof call === "object" || typeof call === "function")) { 666 return call; 667 } 668 669 return babelHelpers.assertThisInitialized(self); 670 } 671 672 babelHelpers.possibleConstructorReturn = _possibleConstructorReturn; 673 674 function _superPropBase(object, property) { 675 while (!Object.prototype.hasOwnProperty.call(object, property)) { 676 object = babelHelpers.getPrototypeOf(object); 677 if (object === null) break; 678 } 679 680 return object; 681 } 682 683 babelHelpers.superPropBase = _superPropBase; 684 685 function _get(target, property, receiver) { 686 if (typeof Reflect !== "undefined" && Reflect.get) { 687 babelHelpers.get = _get = Reflect.get; 688 } else { 689 babelHelpers.get = _get = function _get(target, property, receiver) { 690 var base = babelHelpers.superPropBase(target, property); 691 if (!base) return; 692 var desc = Object.getOwnPropertyDescriptor(base, property); 693 694 if (desc.get) { 695 return desc.get.call(receiver); 696 } 697 698 return desc.value; 699 }; 700 } 701 702 return _get(target, property, receiver || target); 703 } 704 705 babelHelpers.get = _get; 706 707 function set(target, property, value, receiver) { 708 if (typeof Reflect !== "undefined" && Reflect.set) { 709 set = Reflect.set; 710 } else { 711 set = function set(target, property, value, receiver) { 712 var base = babelHelpers.superPropBase(target, property); 713 var desc; 714 715 if (base) { 716 desc = Object.getOwnPropertyDescriptor(base, property); 717 718 if (desc.set) { 719 desc.set.call(receiver, value); 720 return true; 721 } else if (!desc.writable) { 722 return false;
723 } 724 } 725 726 desc = Object.getOwnPropertyDescriptor(receiver, property); 727 728 if (desc) { 729 if (!desc.writable) { 730 return false; 731 } 732 733 desc.value = value; 734 Object.defineProperty(receiver, property, desc); 735 } else { 736 babelHelpers.defineProperty(receiver, property, value); 737 } 738 739 return true; 740 }; 741 } 742 743 return set(target, property, value, receiver); 744 } 745 746 function _set(target, property, value, receiver, isStrict) { 747 var s = set(target, property, value, receiver || target); 748 749 if (!s && isStrict) { 750 throw new Error('failed to set property'); 751 } 752 753 return value; 754 } 755 756 babelHelpers.set = _set; 757 758 function _taggedTemplateLiteral(strings, raw) { 759 if (!raw) { 760 raw = strings.slice(0); 761 } 762 763 return Object.freeze(Object.defineProperties(strings, { 764 raw: { 765 value: Object.freeze(raw) 766 } 767 })); 768 } 769 770 babelHelpers.taggedTemplateLiteral = _taggedTemplateLiteral; 771 772 function _taggedTemplateLiteralLoose(strings, raw) { 773 if (!raw) { 774 raw = strings.slice(0); 775 } 776 777 strings.raw = raw; 778 return strings; 779 } 780 781 babelHelpers.taggedTemplateLiteralLoose = _taggedTemplateLiteralLoose; 782 783 function _temporalRef(val, name) { 784 if (val === babelHelpers.temporalUndefined) { 785 throw new ReferenceError(name + " is not defined - temporal dead zone"); 786 } else { 787 return val; 788 } 789 } 790 791 babelHelpers.temporalRef = _temporalRef; 792 793 function _readOnlyError(name) { 794 throw new Error("\"" + name + "\" is read-only"); 795 } 796 797 babelHelpers.readOnlyError = _readOnlyError; 798 799 function _classNameTDZError(name) { 800 throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); 801 } 802 803 babelHelpers.classNameTDZError = _classNameTDZError; 804 babelHelpers.temporalUndefined = {}; 805 806 function _slicedToArray(arr, i) { 807 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArrayLimit(arr, i) || babelHelpers.nonIterableRest(); 808 } 809 810 babelHelpers.slicedToArray = _slicedToArray; 811 812 function _slicedToArrayLoose(arr, i) { 813 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArrayLimitLoose(arr, i) || babelHelpers.nonIterableRest(); 814 } 815 816 babelHelpers.slicedToArrayLoose = _slicedToArrayLoose; 817 818 function _toArray(arr) { 819 return babelHelpers.arrayWithHoles(arr) || babelHelpers.iterableToArray(arr) || babelHelpers.nonIterableRest(); 820 } 821 822 babelHelpers.toArray = _toArray; 823 824 function _toConsumableArray(arr) { 825 return babelHelpers.arrayWithoutHoles(arr) || babelHelpers.iterableToArray(arr) || babelHelpers.nonIterableSpread(); 826 } 827 828 babelHelpers.toConsumableArray = _toConsumableArray; 829 830 function _arrayWithoutHoles(arr) { 831 if (Array.isArray(arr)) { 832 for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; 833 834 return arr2; 835 } 836 } 837 838 babelHelpers.arrayWithoutHoles = _arrayWithoutHoles; 839 840 function _arrayWithHoles(arr) { 841 if (Array.isArray(arr)) return arr; 842 } 843 844 babelHelpers.arrayWithHoles = _arrayWithHoles; 845 846 function _iterableToArray(iter) { 847 if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); 848 } 849 850 babelHelpers.iterableToArray = _iterableToArray; 851 852 function _iterableToArrayLimit(arr, i) { 853 var _arr = []; 854 var _n = true; 855 var _d = false; 856 var _e = undefined; 857 858 try { 859 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { 860 _arr.push(_s.value); 861 862 if (i && _arr.length === i) break; 863 } 864 } catch (err) { 865 _d = true; 866 _e = err; 867 } finally { 868 try { 869 if (!_n && _i["return"] != null) _i["return"](); 870 } finally { 871 if (_d) throw _e; 872 } 873 } 874 875 return _arr; 876 } 877 878 babelHelpers.iterableToArrayLimit = _iterableToArrayLimit; 879 880 function _iterableToArrayLimitLoose(arr, i) { 881 var _arr = []; 882 883 for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { 884 _arr.push(_step.value); 885 886 if (i && _arr.length === i) break; 887 } 888 889 return _arr; 890 } 891 892 babelHelpers.iterableToArrayLimitLoose = _iterableToArrayLimitLoose; 893 894 function _nonIterableSpread() { 895 throw new TypeError("Invalid attempt to spread non-iterable instance"); 896 } 897 898 babelHelpers.nonIterableSpread = _nonIterableSpread; 899 900 function _nonIterableRest() {
901 throw new TypeError("Invalid attempt to destructure non-iterable instance"); 902 } 903 904 babelHelpers.nonIterableRest = _nonIterableRest; 905 906 function _skipFirstGeneratorNext(fn) { 907 return function () { 908 var it = fn.apply(this, arguments); 909 it.next(); 910 return it; 911 }; 912 } 913 914 babelHelpers.skipFirstGeneratorNext = _skipFirstGeneratorNext; 915 916 function _toPropertyKey(key) { 917 if (typeof key === "symbol") { 918 return key; 919 } else { 920 return String(key); 921 } 922 } 923 924 babelHelpers.toPropertyKey = _toPropertyKey; 925 926 function _initializerWarningHelper(descriptor, context) { 927 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.'); 928 } 929 930 babelHelpers.initializerWarningHelper = _initializerWarningHelper; 931 932 function _initializerDefineProperty(target, property, descriptor, context) { 933 if (!descriptor) return; 934 Object.defineProperty(target, property, { 935 enumerable: descriptor.enumerable, 936 configurable: descriptor.configurable, 937 writable: descriptor.writable, 938 value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 939 }); 940 } 941 942 babelHelpers.initializerDefineProperty = _initializerDefineProperty; 943 944 function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { 945 var desc = {}; 946 Object['ke' + 'ys'](descriptor).forEach(function (key) { 947 desc[key] = descriptor[key]; 948 }); 949 desc.enumerable = !!desc.enumerable; 950 desc.configurable = !!desc.configurable; 951 952 if ('value' in desc || desc.initializer) { 953 desc.writable = true; 954 } 955 956 desc = decorators.slice().reverse().reduce(function (desc, decorator) { 957 return decorator(target, property, desc) || desc; 958 }, desc); 959 960 if (context && desc.initializer !== void 0) { 961 desc.value = desc.initializer ? desc.initializer.call(context) : void 0; 962 desc.initializer = undefined; 963 } 964 965 if (desc.initializer === void 0) { 966 Object['define' + 'Property'](target, property, desc); 967 desc = null; 968 } 969 970 return desc; 971 } 972 973 babelHelpers.applyDecoratedDescriptor = _applyDecoratedDescriptor; 974 var id = 0; 975 976 function _classPrivateFieldKey(name) { 977 return "__private_" + id++ + "_" + name; 978 } 979 980 babelHelpers.classPrivateFieldLooseKey = _classPrivateFieldKey; 981 982 function _classPrivateFieldBase(receiver, privateKey) { 983 if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { 984 throw new TypeError("attempted to use private field on non-instance"); 985 } 986 987 return receiver; 988 } 989 990 babelHelpers.classPrivateFieldLooseBase = _classPrivateFieldBase; 991 992 function _classPrivateFieldGet(receiver, privateMap) { 993 if (!privateMap.has(receiver)) { 994 throw new TypeError("attempted to get private field on non-instance"); 995 } 996 997 return privateMap.get(receiver).value; 998 } 999 1000 babelHelpers.classPrivateFieldGet = _classPrivateFieldGet; 1001 1002 function _classPrivateFieldSet(receiver, privateMap, value) { 1003 if (!privateMap.has(receiver)) { 1004 throw new TypeError("attempted to set private field on non-instance"); 1005 } 1006 1007 var descriptor = privateMap.get(receiver); 1008 1009 if (!descriptor.writable) { 1010 throw new TypeError("attempted to set read only private field"); 1011 } 1012 1013 descriptor.value = value; 1014 return value; 1015 } 1016 1017 babelHelpers.classPrivateFieldSet = _classPrivateFieldSet; 1018})(typeof global === "undefined" ? window : global); 1019 1020/** 1021 * Copyright (c) 2014-present, Facebook, Inc. 1022 * 1023 * This source code is licensed under the MIT license found in the 1024 * LICENSE file in the root directory of this source tree. 1025 */ 1026 1027!(function(global) { 1028 "use strict"; 1029 1030 var Op = Object.prototype; 1031 var hasOwn = Op.hasOwnProperty; 1032 var undefined; // More compressible than void 0. 1033 var $Symbol = typeof Symbol === "function" ? Symbol : {}; 1034 var iteratorSymbol = $Symbol.iterator || "@@iterator"; 1035 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; 1036 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; 1037 1038 // Define the runtime globally (as expected by generated code) as either 1039 // module.exports (if we're in a module) or a new, empty object. 1040 var runtime = global.regeneratorRuntime = {}; 1041 1042 function wrap(innerFn, outerFn, self, tryLocsList) { 1043 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. 1044 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; 1045 var generator = Object.create(protoGenerator.prototype); 1046 var context = new Context(tryLocsList || []); 1047 1048 // The ._invoke method unifies the implementations of the .next, 1049 // .throw, and .return methods. 1050 generator._invoke = makeInvokeMethod(innerFn, self, context); 1051 1052 return generator; 1053 } 1054 runtime.wrap = wrap; 1055 1056 // Try/catch helper to minimize deoptimizations. Returns a completion 1057 // record like context.tryEntries[i].completion. This interface could
vendor: 10,591 bytes, lines 1058-1351
1058 // have been (and was previously) designed to take a closure to be 1059 // invoked without arguments, but in all the cases we care about we 1060 // already have an existing method we want to call, so there's no need 1061 // to create a new function object. We can even get away with assuming 1062 // the method takes exactly one argument, since that happens to be true 1063 // in every case, so we don't have to touch the arguments object. The 1064 // only additional allocation required is the completion record, which 1065 // has a stable shape and so hopefully should be cheap to allocate. 1066 function tryCatch(fn, obj, arg) { 1067 try { 1068 return { type: "normal", arg: fn.call(obj, arg) }; 1069 } catch (err) { 1070 return { type: "throw", arg: err }; 1071 } 1072 } 1073 1074 var GenStateSuspendedStart = "suspendedStart"; 1075 var GenStateSuspendedYield = "suspendedYield"; 1076 var GenStateExecuting = "executing"; 1077 var GenStateCompleted = "completed"; 1078 1079 // Returning this object from the innerFn has the same effect as 1080 // breaking out of the dispatch switch statement. 1081 var ContinueSentinel = {}; 1082 1083 // Dummy constructor functions that we use as the .constructor and 1084 // .constructor.prototype properties for functions that return Generator 1085 // objects. For full spec compliance, you may wish to configure your 1086 // minifier not to mangle the names of these two functions. 1087 function Generator() {} 1088 function GeneratorFunction() {} 1089 function GeneratorFunctionPrototype() {} 1090 1091 // This is a polyfill for %IteratorPrototype% for environments that 1092 // don't natively support it. 1093 var IteratorPrototype = {}; 1094 IteratorPrototype[iteratorSymbol] = function () { 1095 return this; 1096 }; 1097 1098 var getProto = Object.getPrototypeOf; 1099 var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); 1100 if (NativeIteratorPrototype && 1101 NativeIteratorPrototype !== Op && 1102 hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { 1103 // This environment has a native %IteratorPrototype%; use it instead 1104 // of the polyfill. 1105 IteratorPrototype = NativeIteratorPrototype; 1106 } 1107 1108 var Gp = GeneratorFunctionPrototype.prototype = 1109 Generator.prototype = Object.create(IteratorPrototype); 1110 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; 1111 GeneratorFunctionPrototype.constructor = GeneratorFunction; 1112 GeneratorFunctionPrototype[toStringTagSymbol] = 1113 GeneratorFunction.displayName = "GeneratorFunction"; 1114 1115 // Helper for defining the .next, .throw, and .return methods of the 1116 // Iterator interface in terms of a single ._invoke method. 1117 function defineIteratorMethods(prototype) { 1118 ["next", "throw", "return"].forEach(function(method) { 1119 prototype[method] = function(arg) { 1120 return this._invoke(method, arg); 1121 }; 1122 }); 1123 } 1124 1125 runtime.isGeneratorFunction = function(genFun) { 1126 var ctor = typeof genFun === "function" && genFun.constructor; 1127 return ctor 1128 ? ctor === GeneratorFunction || 1129 // For the native GeneratorFunction constructor, the best we can 1130 // do is to check its .name property. 1131 (ctor.displayName || ctor.name) === "GeneratorFunction" 1132 : false; 1133 }; 1134 1135 runtime.mark = function(genFun) { 1136 if (Object.setPrototypeOf) { 1137 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); 1138 } else { 1139 genFun.__proto__ = GeneratorFunctionPrototype; 1140 if (!(toStringTagSymbol in genFun)) { 1141 genFun[toStringTagSymbol] = "GeneratorFunction"; 1142 } 1143 } 1144 genFun.prototype = Object.create(Gp); 1145 return genFun; 1146 }; 1147 1148 // Within the body of any async function, `await x` is transformed to 1149 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test 1150 // `hasOwn.call(value, "__await")` to determine if the yielded value is 1151 // meant to be awaited. 1152 runtime.awrap = function(arg) { 1153 return { __await: arg }; 1154 }; 1155 1156 function AsyncIterator(generator) { 1157 function invoke(method, arg, resolve, reject) { 1158 var record = tryCatch(generator[method], generator, arg); 1159 if (record.type === "throw") { 1160 reject(record.arg); 1161 } else { 1162 var result = record.arg; 1163 var value = result.value; 1164 if (value && 1165 typeof value === "object" && 1166 hasOwn.call(value, "__await")) { 1167 return Promise.resolve(value.__await).then(function(value) { 1168 invoke("next", value, resolve, reject); 1169 }, function(err) { 1170 invoke("throw", err, resolve, reject); 1171 }); 1172 } 1173 1174 return Promise.resolve(value).then(function(unwrapped) { 1175 // When a yielded Promise is resolved, its final value becomes 1176 // the .value of the Promise<{value,done}> result for the 1177 // current iteration. If the Promise is rejected, however, the 1178 // result for this iteration will be rejected with the same 1179 // reason. Note that rejections of yielded Promises are not 1180 // thrown back into the generator function, as is the case 1181 // when an awaited Promise is rejected. This difference in 1182 // behavior between yield and await is important, because it 1183 // allows the consumer to decide what to do with the yielded 1184 // rejection (swallow it and continue, manually .throw it back 1185 // into the generator, abandon iteration, whatever). With 1186 // await, by contrast, there is no opportunity to examine the 1187 // rejection reason outside the generator function, so the 1188 // only option is to throw it from the await expression, and 1189 // let the generator function handle the exception. 1190 result.value = unwrapped; 1191 resolve(result); 1192 }, reject); 1193 } 1194 } 1195 1196 var previousPromise; 1197 1198 function enqueue(method, arg) { 1199 function callInvokeWithMethodAndArg() { 1200 return new Promise(function(resolve, reject) { 1201 invoke(method, arg, resolve, reject); 1202 }); 1203 } 1204 1205 return previousPromise = 1206 // If enqueue has been called before, then we want to wait until 1207 // all previous Promises have been resolved before calling invoke, 1208 // so that results are always delivered in the correct order. If 1209 // enqueue has not been called before, then it is important to 1210 // call invoke immediately, without waiting on a callback to fire, 1211 // so that the async generator function has the opportunity to do 1212 // any necessary setup in a predictable way. This predictability 1213 // is why the Promise constructor synchronously invokes its 1214 // executor callback, and why async functions synchronously 1215 // execute code before the first await. Since we implement simple 1216 // async functions in terms of async generators, it is especially 1217 // important to get this right, even though it requires care. 1218 previousPromise ? previousPromise.then( 1219 callInvokeWithMethodAndArg, 1220 // Avoid propagating failures to Promises returned by later 1221 // invocations of the iterator. 1222 callInvokeWithMethodAndArg 1223 ) : callInvokeWithMethodAndArg(); 1224 } 1225 1226 // Define the unified helper method that is used to implement .next, 1227 // .throw, and .return (see defineIteratorMethods). 1228 this._invoke = enqueue; 1229 } 1230 1231 defineIteratorMethods(AsyncIterator.prototype); 1232 AsyncIterator.prototype[asyncIteratorSymbol] = function () { 1233 return this; 1234 }; 1235 runtime.AsyncIterator = AsyncIterator; 1236 1237 // Note that simple async functions are implemented on top of 1238 // AsyncIterator objects; they just return a Promise for the value of 1239 // the final result produced by the iterator. 1240 runtime.async = function(innerFn, outerFn, self, tryLocsList) { 1241 var iter = new AsyncIterator( 1242 wrap(innerFn, outerFn, self, tryLocsList) 1243 ); 1244 1245 return runtime.isGeneratorFunction(outerFn) 1246 ? iter // If outerFn is a generator, return the full iterator. 1247 : iter.next().then(function(result) { 1248 return result.done ? result.value : iter.next(); 1249 }); 1250 }; 1251 1252 function makeInvokeMethod(innerFn, self, context) { 1253 var state = GenStateSuspendedStart; 1254 1255 return function invoke(method, arg) { 1256 if (state === GenStateExecuting) { 1257 throw new Error("Generator is already running"); 1258 } 1259 1260 if (state === GenStateCompleted) { 1261 if (method === "throw") { 1262 throw arg; 1263 } 1264 1265 // Be forgiving, per 25.3.3.3.3 of the spec: 1266 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume 1267 return doneResult(); 1268 } 1269 1270 context.method = method; 1271 context.arg = arg; 1272 1273 while (true) { 1274 var delegate = context.delegate; 1275 if (delegate) { 1276 var delegateResult = maybeInvokeDelegate(delegate, context); 1277 if (delegateResult) { 1278 if (delegateResult === ContinueSentinel) continue; 1279 return delegateResult; 1280 } 1281 } 1282 1283 if (context.method === "next") { 1284 // Setting context._sent for legacy support of Babel's 1285 // function.sent implementation. 1286 context.sent = context._sent = context.arg; 1287 1288 } else if (context.method === "throw") { 1289 if (state === GenStateSuspendedStart) { 1290 state = GenStateCompleted; 1291 throw context.arg; 1292 } 1293 1294 context.dispatchException(context.arg); 1295 1296 } else if (context.method === "return") { 1297 context.abrupt("return", context.arg); 1298 } 1299 1300 state = GenStateExecuting; 1301 1302 var record = tryCatch(innerFn, self, context); 1303 if (record.type === "normal") { 1304 // If an exception is thrown from innerFn, we leave state === 1305 // GenStateExecuting and loop back for another invocation. 1306 state = context.done 1307 ? GenStateCompleted 1308 : GenStateSuspendedYield; 1309 1310 if (record.arg === ContinueSentinel) { 1311 continue; 1312 } 1313 1314 return { 1315 value: record.arg, 1316 done: context.done 1317 }; 1318 1319 } else if (record.type === "throw") { 1320 state = GenStateCompleted; 1321 // Dispatch the exception by looping back around to the 1322 // context.dispatchException(context.arg) call above. 1323 context.method = "throw"; 1324 context.arg = record.arg; 1325 } 1326 } 1327 }; 1328 } 1329 1330 // Call delegate.iterator[context.method](context.arg) and handle the 1331 // result, either by returning a { value, done } result from the 1332 // delegate iterator, or by modifying context.method and context.arg, 1333 // setting context.delegate to null, and returning the ContinueSentinel. 1334 function maybeInvokeDelegate(delegate, context) { 1335 var method = delegate.iterator[context.method]; 1336 if (method === undefined) { 1337 // A .throw or .return when the delegate iterator has no .throw 1338 // method always terminates the yield* loop. 1339 context.delegate = null; 1340 1341 if (context.method === "throw") { 1342 if (delegate.iterator.return) { 1343 // If the delegate iterator has a return method, give it a 1344 // chance to clean up. 1345 context.method = "return"; 1346 context.arg = undefined; 1347 maybeInvokeDelegate(delegate, context); 1348 1349 if (context.method === "throw") { 1350 // If maybeInvokeDelegate(context) changed context.method from 1351 // "return" to "throw", let that override the TypeError below.
vendor: 4,172 bytes, lines 1352-1505
1352 return ContinueSentinel; 1353 } 1354 } 1355 1356 context.method = "throw"; 1357 context.arg = new TypeError( 1358 "The iterator does not provide a 'throw' method"); 1359 } 1360 1361 return ContinueSentinel; 1362 } 1363 1364 var record = tryCatch(method, delegate.iterator, context.arg); 1365 1366 if (record.type === "throw") { 1367 context.method = "throw"; 1368 context.arg = record.arg; 1369 context.delegate = null; 1370 return ContinueSentinel; 1371 } 1372 1373 var info = record.arg; 1374 1375 if (! info) { 1376 context.method = "throw"; 1377 context.arg = new TypeError("iterator result is not an object"); 1378 context.delegate = null; 1379 return ContinueSentinel; 1380 } 1381 1382 if (info.done) { 1383 // Assign the result of the finished delegate to the temporary 1384 // variable specified by delegate.resultName (see delegateYield). 1385 context[delegate.resultName] = info.value; 1386 1387 // Resume execution at the desired location (see delegateYield). 1388 context.next = delegate.nextLoc; 1389 1390 // If context.method was "throw" but the delegate handled the 1391 // exception, let the outer generator proceed normally. If 1392 // context.method was "next", forget context.arg since it has been 1393 // "consumed" by the delegate iterator. If context.method was 1394 // "return", allow the original .return call to continue in the 1395 // outer generator. 1396 if (context.method !== "return") { 1397 context.method = "next"; 1398 context.arg = undefined; 1399 } 1400 1401 } else { 1402 // Re-yield the result returned by the delegate method. 1403 return info; 1404 } 1405 1406 // The delegate iterator is finished, so forget it and continue with 1407 // the outer generator. 1408 context.delegate = null; 1409 return ContinueSentinel; 1410 } 1411 1412 // Define Generator.prototype.{next,throw,return} in terms of the 1413 // unified ._invoke helper method. 1414 defineIteratorMethods(Gp); 1415 1416 Gp[toStringTagSymbol] = "Generator"; 1417 1418 // A Generator should always return itself as the iterator object when the 1419 // @@iterator function is called on it. Some browsers' implementations of the 1420 // iterator prototype chain incorrectly implement this, causing the Generator 1421 // object to not be returned from this call. This ensures that doesn't happen. 1422 // See https://github.com/facebook/regenerator/issues/274 for more details. 1423 Gp[iteratorSymbol] = function() { 1424 return this; 1425 }; 1426 1427 Gp.toString = function() { 1428 return "[object Generator]"; 1429 }; 1430 1431 function pushTryEntry(locs) { 1432 var entry = { tryLoc: locs[0] }; 1433 1434 if (1 in locs) { 1435 entry.catchLoc = locs[1]; 1436 } 1437 1438 if (2 in locs) { 1439 entry.finallyLoc = locs[2]; 1440 entry.afterLoc = locs[3]; 1441 } 1442 1443 this.tryEntries.push(entry); 1444 } 1445 1446 function resetTryEntry(entry) { 1447 var record = entry.completion || {}; 1448 record.type = "normal"; 1449 delete record.arg; 1450 entry.completion = record; 1451 } 1452 1453 function Context(tryLocsList) { 1454 // The root entry object (effectively a try statement without a catch 1455 // or a finally block) gives us a place to store values thrown from 1456 // locations where there is no enclosing try statement. 1457 this.tryEntries = [{ tryLoc: "root" }]; 1458 tryLocsList.forEach(pushTryEntry, this); 1459 this.reset(true); 1460 } 1461 1462 runtime.keys = function(object) { 1463 var keys = []; 1464 for (var key in object) { 1465 keys.push(key); 1466 } 1467 keys.reverse(); 1468 1469 // Rather than returning an object with a next method, we keep 1470 // things simple and return the next function itself. 1471 return function next() { 1472 while (keys.length) { 1473 var key = keys.pop(); 1474 if (key in object) { 1475 next.value = key; 1476 next.done = false; 1477 return next; 1478 } 1479 } 1480 1481 // To avoid creating an additional object, we just hang the .value 1482 // and .done properties off the next function object itself. This 1483 // also ensures that the minifier will not anonymize the function. 1484 next.done = true; 1485 return next; 1486 }; 1487 }; 1488 1489 function values(iterable) { 1490 if (iterable) { 1491 var iteratorMethod = iterable[iteratorSymbol]; 1492 if (iteratorMethod) { 1493 return iteratorMethod.call(iterable); 1494 } 1495 1496 if (typeof iterable.next === "function") { 1497 return iterable; 1498 } 1499 1500 if (!isNaN(iterable.length)) { 1501 var i = -1, next = function next() { 1502 while (++i < iterable.length) { 1503 if (hasOwn.call(iterable, i)) { 1504 next.value = iterable[i]; 1505 next.done = false;
1506 return next; 1507 } 1508 } 1509 1510 next.value = undefined; 1511 next.done = true; 1512 1513 return next; 1514 }; 1515 1516 return next.next = next; 1517 } 1518 } 1519 1520 // Return an iterator with no values. 1521 return { next: doneResult }; 1522 } 1523 runtime.values = values; 1524 1525 function doneResult() { 1526 return { value: undefined, done: true }; 1527 } 1528 1529 Context.prototype = { 1530 constructor: Context, 1531 1532 reset: function(skipTempReset) { 1533 this.prev = 0; 1534 this.next = 0; 1535 // Resetting context._sent for legacy support of Babel's 1536 // function.sent implementation. 1537 this.sent = this._sent = undefined; 1538 this.done = false; 1539 this.delegate = null; 1540 1541 this.method = "next"; 1542 this.arg = undefined; 1543 1544 this.tryEntries.forEach(resetTryEntry); 1545 1546 if (!skipTempReset) { 1547 for (var name in this) { 1548 // Not sure about the optimal order of these conditions: 1549 if (name.charAt(0) === "t" && 1550 hasOwn.call(this, name) && 1551 !isNaN(+name.slice(1))) { 1552 this[name] = undefined; 1553 } 1554 } 1555 } 1556 }, 1557 1558 stop: function() { 1559 this.done = true; 1560 1561 var rootEntry = this.tryEntries[0]; 1562 var rootRecord = rootEntry.completion; 1563 if (rootRecord.type === "throw") { 1564 throw rootRecord.arg; 1565 } 1566 1567 return this.rval; 1568 }, 1569 1570 dispatchException: function(exception) { 1571 if (this.done) { 1572 throw exception; 1573 } 1574 1575 var context = this; 1576 function handle(loc, caught) { 1577 record.type = "throw"; 1578 record.arg = exception; 1579 context.next = loc; 1580 1581 if (caught) { 1582 // If the dispatched exception was caught by a catch block, 1583 // then let that catch block handle the exception normally. 1584 context.method = "next"; 1585 context.arg = undefined; 1586 } 1587 1588 return !! caught; 1589 } 1590 1591 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1592 var entry = this.tryEntries[i]; 1593 var record = entry.completion; 1594 1595 if (entry.tryLoc === "root") { 1596 // Exception thrown outside of any try block that could handle 1597 // it, so set the completion value of the entire function to 1598 // throw the exception. 1599 return handle("end"); 1600 } 1601 1602 if (entry.tryLoc <= this.prev) { 1603 var hasCatch = hasOwn.call(entry, "catchLoc"); 1604 var hasFinally = hasOwn.call(entry, "finallyLoc"); 1605 1606 if (hasCatch && hasFinally) { 1607 if (this.prev < entry.catchLoc) { 1608 return handle(entry.catchLoc, true); 1609 } else if (this.prev < entry.finallyLoc) { 1610 return handle(entry.finallyLoc); 1611 } 1612 1613 } else if (hasCatch) { 1614 if (this.prev < entry.catchLoc) { 1615 return handle(entry.catchLoc, true); 1616 } 1617 1618 } else if (hasFinally) { 1619 if (this.prev < entry.finallyLoc) { 1620 return handle(entry.finallyLoc); 1621 } 1622 1623 } else { 1624 throw new Error("try statement without catch or finally"); 1625 } 1626 } 1627 } 1628 }, 1629 1630 abrupt: function(type, arg) { 1631 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1632 var entry = this.tryEntries[i]; 1633 if (entry.tryLoc <= this.prev && 1634 hasOwn.call(entry, "finallyLoc") && 1635 this.prev < entry.finallyLoc) { 1636 var finallyEntry = entry; 1637 break; 1638 } 1639 } 1640 1641 if (finallyEntry && 1642 (type === "break" || 1643 type === "continue") && 1644 finallyEntry.tryLoc <= arg && 1645 arg <= finallyEntry.finallyLoc) { 1646 // Ignore the finally entry if control is not jumping to a 1647 // location outside the try/catch block. 1648 finallyEntry = null; 1649 } 1650 1651 var record = finallyEntry ? finallyEntry.completion : {}; 1652 record.type = type; 1653 record.arg = arg; 1654 1655 if (finallyEntry) { 1656 this.method = "next"; 1657 this.next = finallyEntry.finallyLoc; 1658 return ContinueSentinel; 1659 } 1660 1661 return this.complete(record); 1662 }, 1663 1664 complete: function(record, afterLoc) { 1665 if (record.type === "throw") { 1666 throw record.arg; 1667 } 1668 1669 if (record.type === "break" || 1670 record.type === "continue") { 1671 this.next = record.arg; 1672 } else if (record.type === "return") { 1673 this.rval = this.arg = record.arg; 1674 this.method = "return"; 1675 this.next = "end"; 1676 } else if (record.type === "normal" && afterLoc) { 1677 this.next = afterLoc; 1678 } 1679 1680 return ContinueSentinel; 1681 }, 1682 1683 finish: function(finallyLoc) { 1684 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1685 var entry = this.tryEntries[i]; 1686 if (entry.finallyLoc === finallyLoc) { 1687 this.complete(entry.completion, entry.afterLoc); 1688 resetTryEntry(entry); 1689 return ContinueSentinel; 1690 } 1691 } 1692 }, 1693 1694 "catch": function(tryLoc) { 1695 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 1696 var entry = this.tryEntries[i]; 1697 if (entry.tryLoc === tryLoc) { 1698 var record = entry.completion; 1699 if (record.type === "throw") { 1700 var thrown = record.arg; 1701 resetTryEntry(entry); 1702 } 1703 return thrown; 1704 } 1705 } 1706 1707 // The context.catch method must only be called with a location 1708 // argument that corresponds to a known catch block. 1709 throw new Error("illegal catch attempt"); 1710 }, 1711 1712 delegateYield: function(iterable, resultName, nextLoc) { 1713 this.delegate = { 1714 iterator: values(iterable), 1715 resultName: resultName, 1716 nextLoc: nextLoc 1717 }; 1718 1719 if (this.method === "next") { 1720 // Deliberately forget the last sent value so that we don't 1721 // accidentally pass it on to the delegate. 1722 this.arg = undefined; 1723 } 1724 1725 return ContinueSentinel; 1726 } 1727 }; 1728})( 1729 // In sloppy mode, unbound `this` refers to the global object, fallback to 1730 // Function constructor if we're in global strict mode. That is sadly a form 1731 // of indirect eval which violates Content Security Policy. 1732 (function() { return this })() || Function("return this")() 1733); 1734 1735(function (exports) { 1736 'use strict'; 1737 1738 var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; 1739 function createCommonjsModule(fn, module) { 1740 return module = { 1741 exports: {} 1742 }, fn(module, module.exports), module.exports; 1743 } 1744 1745 var check = function (it) { 1746 return it && it.Math == Math && it; 1747 }; // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 1748 1749 1750 var global_1 = // eslint-disable-next-line es/no-global-this -- safe 1751 check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || // eslint-disable-next-line no-restricted-globals -- safe 1752 check(typeof self == 'object' && self) || check(typeof commonjsGlobal == 'object' && commonjsGlobal) || // eslint-disable-next-line no-new-func -- fallback 1753 function () { 1754 return this; 1755 }() || Function('return this')(); 1756 1757 var fails = function (exec) { 1758 try { 1759 return !!exec(); 1760 } catch (error) { 1761 return true; 1762 } 1763 }; 1764 1765 // Detect IE8's incomplete defineProperty implementation 1766 1767 1768 var descriptors = !fails(function () { 1769 // eslint-disable-next-line es/no-object-defineproperty -- required for testing 1770 return Object.defineProperty({}, 1, { 1771 get: function () { 1772 return 7; 1773 } 1774 })[1] != 7; 1775 }); 1776 1777 var call = Function.prototype.call; 1778 var functionCall = call.bind ? call.bind(call) : function () { 1779 return call.apply(call, arguments); 1780 }; 1781 1782 var $propertyIsEnumerable = {}.propertyIsEnumerable; // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 1783 1784 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; // Nashorn ~ JDK8 bug 1785 1786 var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1787 1: 2 1788 }, 1); // `Object.prototype.propertyIsEnumerable` method implementation 1789 // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable 1790 1791 var f = NASHORN_BUG ? function propertyIsEnumerable(V) { 1792 var descriptor = getOwnPropertyDescriptor(this, V); 1793 return !!descriptor && descriptor.enumerable; 1794 } : $propertyIsEnumerable; 1795 1796 var objectPropertyIsEnumerable = { 1797 f: f 1798 }; 1799 1800 var createPropertyDescriptor = function (bitmap, value) { 1801 return { 1802 enumerable: !(bitmap & 1), 1803 configurable: !(bitmap & 2), 1804 writable: !(bitmap & 4), 1805 value: value 1806 }; 1807 }; 1808 1809 var FunctionPrototype = Function.prototype; 1810 var bind = FunctionPrototype.bind; 1811 var call$1 = FunctionPrototype.call; 1812 var callBind = bind && bind.bind(call$1); 1813 var functionUncurryThis = bind ? function (fn) {
1814 return fn && callBind(call$1, fn); 1815 } : function (fn) { 1816 return fn && function () { 1817 return call$1.apply(fn, arguments); 1818 }; 1819 }; 1820 1821 var toString = functionUncurryThis({}.toString); 1822 var stringSlice = functionUncurryThis(''.slice); 1823 1824 var classofRaw = function (it) { 1825 return stringSlice(toString(it), 8, -1); 1826 }; 1827 1828 var Object$1 = global_1.Object; 1829 var split = functionUncurryThis(''.split); // fallback for non-array-like ES3 and non-enumerable old V8 strings 1830 1831 var indexedObject = fails(function () { 1832 // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346 1833 // eslint-disable-next-line no-prototype-builtins -- safe 1834 return !Object$1('z').propertyIsEnumerable(0); 1835 }) ? function (it) { 1836 return classofRaw(it) == 'String' ? split(it, '') : Object$1(it); 1837 } : Object$1; 1838 1839 var TypeError$1 = global_1.TypeError; // `RequireObjectCoercible` abstract operation 1840 // https://tc39.es/ecma262/#sec-requireobjectcoercible 1841 1842 var requireObjectCoercible = function (it) { 1843 if (it == undefined) throw TypeError$1("Can't call method on " + it); 1844 return it; 1845 }; 1846 1847 // toObject with fallback for non-array-like ES3 strings 1848 1849 1850 1851 1852 var toIndexedObject = function (it) { 1853 return indexedObject(requireObjectCoercible(it)); 1854 }; 1855 1856 // `IsCallable` abstract operation 1857 // https://tc39.es/ecma262/#sec-iscallable 1858 var isCallable = function (argument) { 1859 return typeof argument == 'function'; 1860 }; 1861 1862 var isObject = function (it) { 1863 return typeof it == 'object' ? it !== null : isCallable(it); 1864 }; 1865 1866 var aFunction = function (argument) { 1867 return isCallable(argument) ? argument : undefined; 1868 }; 1869 1870 var getBuiltIn = function (namespace, method) { 1871 return arguments.length < 2 ? aFunction(global_1[namespace]) : global_1[namespace] && global_1[namespace][method]; 1872 }; 1873 1874 var objectIsPrototypeOf = functionUncurryThis({}.isPrototypeOf); 1875 1876 var engineUserAgent = getBuiltIn('navigator', 'userAgent') || ''; 1877 1878 var process = global_1.process; 1879 var Deno = global_1.Deno; 1880 var versions = process && process.versions || Deno && Deno.version; 1881 var v8 = versions && versions.v8; 1882 var match, version; 1883 1884 if (v8) { 1885 match = v8.split('.'); // in old Chrome, versions of V8 isn't V8 = Chrome / 10 1886 // but their correct versions are not interesting for us 1887 1888 version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]); 1889 } // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0` 1890 // so check `userAgent` even if `.v8` exists, but 0 1891 1892 1893 if (!version && engineUserAgent) { 1894 match = engineUserAgent.match(/Edge\/(\d+)/); 1895 1896 if (!match || match[1] >= 74) { 1897 match = engineUserAgent.match(/Chrome\/(\d+)/); 1898 if (match) version = +match[1]; 1899 } 1900 } 1901 1902 var engineV8Version = version; 1903 1904 /* eslint-disable es/no-symbol -- required for testing */ 1905 1906 1907 // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing 1908 1909 1910 var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () { 1911 var symbol = Symbol(); // Chrome 38 Symbol has incorrect toString conversion 1912 // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances 1913 1914 return !String(symbol) || !(Object(symbol) instanceof Symbol) || // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances 1915 !Symbol.sham && engineV8Version && engineV8Version < 41; 1916 }); 1917 1918 /* eslint-disable es/no-symbol -- required for testing */ 1919 1920 1921 var useSymbolAsUid = nativeSymbol && !Symbol.sham && typeof Symbol.iterator == 'symbol'; 1922 1923 var Object$2 = global_1.Object; 1924 var isSymbol = useSymbolAsUid ? function (it) { 1925 return typeof it == 'symbol'; 1926 } : function (it) { 1927 var $Symbol = getBuiltIn('Symbol'); 1928 return isCallable($Symbol) && objectIsPrototypeOf($Symbol.prototype, Object$2(it)); 1929 }; 1930 1931 var String$1 = global_1.String; 1932 1933 var tryToString = function (argument) { 1934 try { 1935 return String$1(argument); 1936 } catch (error) { 1937 return 'Object'; 1938 } 1939 }; 1940 1941 var TypeError$2 = global_1.TypeError; // `Assert: IsCallable(argument) is true` 1942 1943 var aCallable = function (argument) { 1944 if (isCallable(argument)) return argument; 1945 throw TypeError$2(tryToString(argument) + ' is not a function'); 1946 }; 1947 1948 // `GetMethod` abstract operation 1949 // https://tc39.es/ecma262/#sec-getmethod 1950 1951 1952 var getMethod = function (V, P) { 1953 var func = V[P]; 1954 return func == null ? undefined : aCallable(func); 1955 }; 1956 1957 var TypeError$3 = global_1.TypeError; // `OrdinaryToPrimitive` abstract operation 1958 // https://tc39.es/ecma262/#sec-ordinarytoprimitive 1959 1960 var ordinaryToPrimitive = function (input, pref) { 1961 var fn, val; 1962 if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val; 1963 if (isCallable(fn = input.valueOf) && !isObject(val = functionCall(fn, input))) return val; 1964 if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val; 1965 throw TypeError$3("Can't convert object to primitive value"); 1966 }; 1967 1968 var isPure = false;
1969 1970 // eslint-disable-next-line es/no-object-defineproperty -- safe 1971 1972 1973 var defineProperty = Object.defineProperty; 1974 1975 var setGlobal = function (key, value) { 1976 try { 1977 defineProperty(global_1, key, { 1978 value: value, 1979 configurable: true, 1980 writable: true 1981 }); 1982 } catch (error) { 1983 global_1[key] = value; 1984 } 1985 1986 return value; 1987 }; 1988 1989 var SHARED = '__core-js_shared__'; 1990 var store = global_1[SHARED] || setGlobal(SHARED, {}); 1991 var sharedStore = store; 1992 1993 var shared = createCommonjsModule(function (module) { 1994 (module.exports = function (key, value) { 1995 return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {}); 1996 })('versions', []).push({ 1997 version: '3.19.2', 1998 mode: 'global', 1999 copyright: '(c) 2021 Denis Pushkarev (zloirock.ru)' 2000 }); 2001 }); 2002 2003 var Object$3 = global_1.Object; // `ToObject` abstract operation 2004 // https://tc39.es/ecma262/#sec-toobject 2005 2006 var toObject = function (argument) { 2007 return Object$3(requireObjectCoercible(argument)); 2008 }; 2009 2010 var hasOwnProperty = functionUncurryThis({}.hasOwnProperty); // `HasOwnProperty` abstract operation 2011 // https://tc39.es/ecma262/#sec-hasownproperty 2012 2013 var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) { 2014 return hasOwnProperty(toObject(it), key); 2015 }; 2016 2017 var id = 0; 2018 var postfix = Math.random(); 2019 var toString$1 = functionUncurryThis(1.0.toString); 2020 2021 var uid = function (key) { 2022 return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$1(++id + postfix, 36); 2023 }; 2024 2025 var WellKnownSymbolsStore = shared('wks'); 2026 var Symbol$1 = global_1.Symbol; 2027 var symbolFor = Symbol$1 && Symbol$1['for']; 2028 var createWellKnownSymbol = useSymbolAsUid ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid; 2029 2030 var wellKnownSymbol = function (name) { 2031 if (!hasOwnProperty_1(WellKnownSymbolsStore, name) || !(nativeSymbol || typeof WellKnownSymbolsStore[name] == 'string')) { 2032 var description = 'Symbol.' + name; 2033 2034 if (nativeSymbol && hasOwnProperty_1(Symbol$1, name)) { 2035 WellKnownSymbolsStore[name] = Symbol$1[name]; 2036 } else if (useSymbolAsUid && symbolFor) { 2037 WellKnownSymbolsStore[name] = symbolFor(description); 2038 } else { 2039 WellKnownSymbolsStore[name] = createWellKnownSymbol(description); 2040 } 2041 } 2042 2043 return WellKnownSymbolsStore[name]; 2044 }; 2045 2046 var TypeError$4 = global_1.TypeError; 2047 var TO_PRIMITIVE = wellKnownSymbol('toPrimitive'); // `ToPrimitive` abstract operation 2048 // https://tc39.es/ecma262/#sec-toprimitive 2049 2050 var toPrimitive = function (input, pref) { 2051 if (!isObject(input) || isSymbol(input)) return input; 2052 var exoticToPrim = getMethod(input, TO_PRIMITIVE); 2053 var result; 2054 2055 if (exoticToPrim) { 2056 if (pref === undefined) pref = 'default'; 2057 result = functionCall(exoticToPrim, input, pref); 2058 if (!isObject(result) || isSymbol(result)) return result; 2059 throw TypeError$4("Can't convert object to primitive value"); 2060 } 2061 2062 if (pref === undefined) pref = 'number'; 2063 return ordinaryToPrimitive(input, pref); 2064 }; 2065 2066 // `ToPropertyKey` abstract operation 2067 // https://tc39.es/ecma262/#sec-topropertykey 2068 2069 2070 var toPropertyKey = function (argument) { 2071 var key = toPrimitive(argument, 'string'); 2072 return isSymbol(key) ? key : key + ''; 2073 }; 2074 2075 var document$1 = global_1.document; // typeof document.createElement is 'object' in old IE 2076 2077 var EXISTS = isObject(document$1) && isObject(document$1.createElement); 2078 2079 var documentCreateElement = function (it) { 2080 return EXISTS ? document$1.createElement(it) : {}; 2081 }; 2082 2083 // Thank's IE8 for his funny defineProperty 2084 2085 2086 var ie8DomDefine = !descriptors && !fails(function () { 2087 // eslint-disable-next-line es/no-object-defineproperty -- requied for testing 2088 return Object.defineProperty(documentCreateElement('div'), 'a', { 2089 get: function () { 2090 return 7; 2091 } 2092 }).a != 7; 2093 }); 2094 2095 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2096 2097 2098 var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; // `Object.getOwnPropertyDescriptor` method 2099 // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor 2100 2101 var f$1 = descriptors ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) { 2102 O = toIndexedObject(O); 2103 P = toPropertyKey(P); 2104 if (ie8DomDefine) try { 2105 return $getOwnPropertyDescriptor(O, P); 2106 } catch (error) { 2107 /* empty */ 2108 } 2109 if (hasOwnProperty_1(O, P)) return createPropertyDescriptor(!functionCall(objectPropertyIsEnumerable.f, O, P), O[P]); 2110 }; 2111 2112 var objectGetOwnPropertyDescriptor = { 2113 f: f$1 2114 }; 2115 2116 var String$2 = global_1.String; 2117 var TypeError$5 = global_1.TypeError; // `Assert: Type(argument) is Object` 2118 2119 var anObject = function (argument) { 2120 if (isObject(argument)) return argument; 2121 throw TypeError$5(String$2(argument) + ' is not an object'); 2122 }; 2123 2124 var TypeError$6 = global_1.TypeError; // eslint-disable-next-line es/no-object-defineproperty -- safe 2125 2126 var $defineProperty = Object.defineProperty; // `Object.defineProperty` method 2127 // https://tc39.es/ecma262/#sec-object.defineproperty 2128 2129 var f$2 = descriptors ? $defineProperty : function defineProperty(O, P, Attributes) { 2130 anObject(O); 2131 P = toPropertyKey(P); 2132 anObject(Attributes); 2133 if (ie8DomDefine) try { 2134 return $defineProperty(O, P, Attributes); 2135 } catch (error) { 2136 /* empty */ 2137 } 2138 if ('get' in Attributes || 'set' in Attributes) throw TypeError$6('Accessors not supported'); 2139 if ('value' in Attributes) O[P] = Attributes.value; 2140 return O; 2141 }; 2142 2143 var objectDefineProperty = { 2144 f: f$2 2145 }; 2146 2147 var createNonEnumerableProperty = descriptors ? function (object, key, value) { 2148 return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value)); 2149 } : function (object, key, value) { 2150 object[key] = value; 2151 return object; 2152 }; 2153 2154 var functionToString = functionUncurryThis(Function.toString); // this helper broken in `[email protected]`, so we can't use `shared` helper 2155 2156 if (!isCallable(sharedStore.inspectSource)) { 2157 sharedStore.inspectSource = function (it) { 2158 return functionToString(it); 2159 }; 2160 } 2161 2162 var inspectSource = sharedStore.inspectSource; 2163 2164 var WeakMap = global_1.WeakMap; 2165 var nativeWeakMap = isCallable(WeakMap) && /native code/.test(inspectSource(WeakMap)); 2166 2167 var keys = shared('keys'); 2168 2169 var sharedKey = function (key) { 2170 return keys[key] || (keys[key] = uid(key)); 2171 }; 2172 2173 var hiddenKeys = {}; 2174 2175 var OBJECT_ALREADY_INITIALIZED = 'Object already initialized'; 2176 var TypeError$7 = global_1.TypeError; 2177 var WeakMap$1 = global_1.WeakMap; 2178 var set, get, has; 2179 2180 var enforce = function (it) { 2181 return has(it) ? get(it) : set(it, {}); 2182 }; 2183 2184 var getterFor = function (TYPE) { 2185 return function (it) { 2186 var state; 2187 2188 if (!isObject(it) || (state = get(it)).type !== TYPE) { 2189 throw TypeError$7('Incompatible receiver, ' + TYPE + ' required'); 2190 } 2191 2192 return state; 2193 }; 2194 }; 2195 2196 if (nativeWeakMap || sharedStore.state) { 2197 var store$1 = sharedStore.state || (sharedStore.state = new WeakMap$1()); 2198 var wmget = functionUncurryThis(store$1.get); 2199 var wmhas = functionUncurryThis(store$1.has); 2200 var wmset = functionUncurryThis(store$1.set); 2201 2202 set = function (it, metadata) { 2203 if (wmhas(store$1, it)) throw new TypeError$7(OBJECT_ALREADY_INITIALIZED); 2204 metadata.facade = it; 2205 wmset(store$1, it, metadata); 2206 return metadata; 2207 }; 2208 2209 get = function (it) { 2210 return wmget(store$1, it) || {}; 2211 }; 2212 2213 has = function (it) { 2214 return wmhas(store$1, it); 2215 }; 2216 } else { 2217 var STATE = sharedKey('state'); 2218 hiddenKeys[STATE] = true; 2219 2220 set = function (it, metadata) { 2221 if (hasOwnProperty_1(it, STATE)) throw new TypeError$7(OBJECT_ALREADY_INITIALIZED); 2222 metadata.facade = it; 2223 createNonEnumerableProperty(it, STATE, metadata); 2224 return metadata; 2225 }; 2226 2227 get = function (it) { 2228 return hasOwnProperty_1(it, STATE) ? it[STATE] : {}; 2229 }; 2230 2231 has = function (it) { 2232 return hasOwnProperty_1(it, STATE); 2233 }; 2234 } 2235 2236 var internalState = { 2237 set: set, 2238 get: get, 2239 has: has, 2240 enforce: enforce, 2241 getterFor: getterFor 2242 }; 2243 2244 var FunctionPrototype$1 = Function.prototype; // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2245 2246 var getDescriptor = descriptors && Object.getOwnPropertyDescriptor; 2247 var EXISTS$1 = hasOwnProperty_1(FunctionPrototype$1, 'name'); // additional protection from minified / mangled / dropped function names 2248 2249 var PROPER = EXISTS$1 && function something() { 2250 /* empty */ 2251 }.name === 'something'; 2252 2253 var CONFIGURABLE = EXISTS$1 && (!descriptors || descriptors && getDescriptor(FunctionPrototype$1, 'name').configurable); 2254 var functionName = { 2255 EXISTS: EXISTS$1, 2256 PROPER: PROPER, 2257 CONFIGURABLE: CONFIGURABLE 2258 }; 2259 2260 var redefine = createCommonjsModule(function (module) { 2261 var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE; 2262 2263 var getInternalState = internalState.get; 2264 var enforceInternalState = internalState.enforce;
vendor: 4,394 bytes, lines 2265-2393
2265 var TEMPLATE = String(String).split('String'); 2266 (module.exports = function (O, key, value, options) { 2267 var unsafe = options ? !!options.unsafe : false; 2268 var simple = options ? !!options.enumerable : false; 2269 var noTargetGet = options ? !!options.noTargetGet : false; 2270 var name = options && options.name !== undefined ? options.name : key; 2271 var state; 2272 2273 if (isCallable(value)) { 2274 if (String(name).slice(0, 7) === 'Symbol(') { 2275 name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']'; 2276 } 2277 2278 if (!hasOwnProperty_1(value, 'name') || CONFIGURABLE_FUNCTION_NAME && value.name !== name) { 2279 createNonEnumerableProperty(value, 'name', name); 2280 } 2281 2282 state = enforceInternalState(value); 2283 2284 if (!state.source) { 2285 state.source = TEMPLATE.join(typeof name == 'string' ? name : ''); 2286 } 2287 } 2288 2289 if (O === global_1) { 2290 if (simple) O[key] = value;else setGlobal(key, value); 2291 return; 2292 } else if (!unsafe) { 2293 delete O[key]; 2294 } else if (!noTargetGet && O[key]) { 2295 simple = true; 2296 } 2297 2298 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 2299 })(Function.prototype, 'toString', function toString() { 2300 return isCallable(this) && getInternalState(this).source || inspectSource(this); 2301 }); 2302 }); 2303 2304 var ceil = Math.ceil; 2305 var floor = Math.floor; // `ToIntegerOrInfinity` abstract operation 2306 // https://tc39.es/ecma262/#sec-tointegerorinfinity 2307 2308 var toIntegerOrInfinity = function (argument) { 2309 var number = +argument; // eslint-disable-next-line no-self-compare -- safe 2310 2311 return number !== number || number === 0 ? 0 : (number > 0 ? floor : ceil)(number); 2312 }; 2313 2314 var max = Math.max; 2315 var min = Math.min; // Helper for a popular repeating case of the spec: 2316 // Let integer be ? ToInteger(index). 2317 // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length). 2318 2319 var toAbsoluteIndex = function (index, length) { 2320 var integer = toIntegerOrInfinity(index); 2321 return integer < 0 ? max(integer + length, 0) : min(integer, length); 2322 }; 2323 2324 var min$1 = Math.min; // `ToLength` abstract operation 2325 // https://tc39.es/ecma262/#sec-tolength 2326 2327 var toLength = function (argument) { 2328 return argument > 0 ? min$1(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 2329 }; 2330 2331 // `LengthOfArrayLike` abstract operation 2332 // https://tc39.es/ecma262/#sec-lengthofarraylike 2333 2334 2335 var lengthOfArrayLike = function (obj) { 2336 return toLength(obj.length); 2337 }; 2338 2339 // `Array.prototype.{ indexOf, includes }` methods implementation 2340 2341 2342 var createMethod = function (IS_INCLUDES) { 2343 return function ($this, el, fromIndex) { 2344 var O = toIndexedObject($this); 2345 var length = lengthOfArrayLike(O); 2346 var index = toAbsoluteIndex(fromIndex, length); 2347 var value; // Array#includes uses SameValueZero equality algorithm 2348 // eslint-disable-next-line no-self-compare -- NaN check 2349 2350 if (IS_INCLUDES && el != el) while (length > index) { 2351 value = O[index++]; // eslint-disable-next-line no-self-compare -- NaN check 2352 2353 if (value != value) return true; // Array#indexOf ignores holes, Array#includes - not 2354 } else for (; length > index; index++) { 2355 if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0; 2356 } 2357 return !IS_INCLUDES && -1; 2358 }; 2359 }; 2360 2361 var arrayIncludes = { 2362 // `Array.prototype.includes` method 2363 // https://tc39.es/ecma262/#sec-array.prototype.includes 2364 includes: createMethod(true), 2365 // `Array.prototype.indexOf` method 2366 // https://tc39.es/ecma262/#sec-array.prototype.indexof 2367 indexOf: createMethod(false) 2368 }; 2369 2370 var indexOf = arrayIncludes.indexOf; 2371 2372 2373 2374 var push = functionUncurryThis([].push); 2375 2376 var objectKeysInternal = function (object, names) { 2377 var O = toIndexedObject(object); 2378 var i = 0; 2379 var result = []; 2380 var key; 2381 2382 for (key in O) !hasOwnProperty_1(hiddenKeys, key) && hasOwnProperty_1(O, key) && push(result, key); // Don't enum bug & hidden keys 2383 2384 2385 while (names.length > i) if (hasOwnProperty_1(O, key = names[i++])) { 2386 ~indexOf(result, key) || push(result, key); 2387 } 2388 2389 return result; 2390 }; 2391 2392 // IE8- don't enum bug keys 2393 var enumBugKeys = ['constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleStr
2393ing', 'toString', 'valueOf']; 2394 2395 var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype'); // `Object.getOwnPropertyNames` method 2396 // https://tc39.es/ecma262/#sec-object.getownpropertynames 2397 // eslint-disable-next-line es/no-object-getownpropertynames -- safe 2398 2399 var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { 2400 return objectKeysInternal(O, hiddenKeys$1); 2401 }; 2402 2403 var objectGetOwnPropertyNames = { 2404 f: f$3 2405 }; 2406 2407 // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe 2408 var f$4 = Object.getOwnPropertySymbols; 2409 2410 var objectGetOwnPropertySymbols = { 2411 f: f$4 2412 }; 2413 2414 var concat = functionUncurryThis([].concat); // all object keys, includes non-enumerable and symbols 2415 2416 var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) { 2417 var keys = objectGetOwnPropertyNames.f(anObject(it)); 2418 var getOwnPropertySymbols = objectGetOwnPropertySymbols.f; 2419 return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys; 2420 }; 2421 2422 var copyConstructorProperties = function (target, source) { 2423 var keys = ownKeys(source); 2424 var defineProperty = objectDefineProperty.f; 2425 var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; 2426 2427 for (var i = 0; i < keys.length; i++) { 2428 var key = keys[i]; 2429 if (!hasOwnProperty_1(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key)); 2430 } 2431 }; 2432 2433 var replacement = /#|\.prototype\./; 2434 2435 var isForced = function (feature, detection) { 2436 var value = data[normalize(feature)]; 2437 return value == POLYFILL ? true : value == NATIVE ? false : isCallable(detection) ? fails(detection) : !!detection; 2438 }; 2439 2440 var normalize = isForced.normalize = function (string) { 2441 return String(string).replace(replacement, '.').toLowerCase(); 2442 }; 2443 2444 var data = isForced.data = {}; 2445 var NATIVE = isForced.NATIVE = 'N'; 2446 var POLYFILL = isForced.POLYFILL = 'P'; 2447 var isForced_1 = isForced; 2448 2449 var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f; 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 /* 2461 options.target - name of the target object 2462 options.global - target is the global object 2463 options.stat - export as static methods of target 2464 options.proto - export as prototype methods of target 2465 options.real - real prototype method for the `pure` version 2466 options.forced - export even if the native feature is available 2467 options.bind - bind methods to the target, required for the `pure` version 2468 options.wrap - wrap constructors to preventing global pollution, required for the `pure` version 2469 options.unsafe - use the simple assignment of property instead of delete + defineProperty 2470 options.sham - add a flag to not completely full polyfills 2471 options.enumerable - export as enumerable property 2472 options.noTargetGet - prevent calling a getter on target 2473 options.name - the .name of the function if it does not match the key 2474 */ 2475 2476 2477 var _export = function (options, source) { 2478 var TARGET = options.target; 2479 var GLOBAL = options.global; 2480 var STATIC = options.stat; 2481 var FORCED, target, key, targetProperty, sourceProperty, descriptor; 2482 2483 if (GLOBAL) { 2484 target = global_1; 2485 } else if (STATIC) { 2486 target = global_1[TARGET] || setGlobal(TARGET, {}); 2487 } else { 2488 target = (global_1[TARGET] || {}).prototype; 2489 } 2490 2491 if (target) for (key in source) { 2492 sourceProperty = source[key]; 2493 2494 if (options.noTargetGet) { 2495 descriptor = getOwnPropertyDescriptor$1(target, key); 2496 targetProperty = descriptor && descriptor.value; 2497 } else targetProperty = target[key]; 2498 2499 FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); // contained in target 2500 2501 if (!FORCED && targetProperty !== undefined) { 2502 if (typeof sourceProperty == typeof targetProperty) continue; 2503 copyConstructorProperties(sourceProperty, targetProperty); 2504 } // add a flag to not completely full polyfills 2505 2506 2507 if (options.sham || targetProperty && targetProperty.sham) { 2508 createNonEnumerableProperty(sourceProperty, 'sham', true); 2509 } // extend global 2510 2511 2512 redefine(target, key, sourceProperty, options); 2513 } 2514 }; 2515 2516 var correctPrototypeGetter = !fails(function () { 2517 function F() { 2518 /* empty */ 2519 } 2520 2521 F.prototype.constructor = null; // eslint-disable-next-line es/no-object-getprototypeof -- required for testing 2522 2523 return Object.getPrototypeOf(new F()) !== F.prototype; 2524 }); 2525 2526 var IE_PROTO = sharedKey('IE_PROTO'); 2527 var Object$4 = global_1.Object; 2528 var ObjectPrototype = Object$4.prototype; // `Object.getPrototypeOf` method 2529 // https://tc39.es/ecma262/#sec-object.getprototypeof 2530 2531 var objectGetPrototypeOf = correctPrototypeGetter ? Object$4.getPrototypeOf : function (O) { 2532 var object = toObject(O); 2533 if (hasOwnProperty_1(object, IE_PROTO)) return object[IE_PROTO]; 2534 var constructor = object.constructor; 2535 2536 if (isCallable(constructor) && object instanceof constructor) { 2537 return constructor.prototype; 2538 } 2539
2540 return object instanceof Object$4 ? ObjectPrototype : null; 2541 }; 2542 2543 var String$3 = global_1.String; 2544 var TypeError$8 = global_1.TypeError; 2545 2546 var aPossiblePrototype = function (argument) { 2547 if (typeof argument == 'object' || isCallable(argument)) return argument; 2548 throw TypeError$8("Can't set " + String$3(argument) + ' as a prototype'); 2549 }; 2550 2551 /* eslint-disable no-proto -- safe */ 2552 2553 2554 2555 2556 // `Object.setPrototypeOf` method 2557 // https://tc39.es/ecma262/#sec-object.setprototypeof 2558 // Works with __proto__ only. Old v8 can't work with null proto objects. 2559 // eslint-disable-next-line es/no-object-setprototypeof -- safe 2560 2561 2562 var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () { 2563 var CORRECT_SETTER = false; 2564 var test = {}; 2565 var setter; 2566 2567 try { 2568 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe 2569 setter = functionUncurryThis(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set); 2570 setter(test, []); 2571 CORRECT_SETTER = test instanceof Array; 2572 } catch (error) { 2573 /* empty */ 2574 } 2575 2576 return function setPrototypeOf(O, proto) { 2577 anObject(O); 2578 aPossiblePrototype(proto); 2579 if (CORRECT_SETTER) setter(O, proto);else O.__proto__ = proto; 2580 return O; 2581 }; 2582 }() : undefined); 2583 2584 // `Object.keys` method 2585 // https://tc39.es/ecma262/#sec-object.keys 2586 // eslint-disable-next-line es/no-object-keys -- safe 2587 2588 2589 var objectKeys = Object.keys || function keys(O) { 2590 return objectKeysInternal(O, enumBugKeys); 2591 }; 2592 2593 // `Object.defineProperties` method 2594 // https://tc39.es/ecma262/#sec-object.defineproperties 2595 // eslint-disable-next-line es/no-object-defineproperties -- safe 2596 2597 2598 var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) { 2599 anObject(O); 2600 var props = toIndexedObject(Properties); 2601 var keys = objectKeys(Properties); 2602 var length = keys.length; 2603 var index = 0; 2604 var key; 2605 2606 while (length > index) objectDefineProperty.f(O, key = keys[index++], props[key]); 2607 2608 return O; 2609 }; 2610 2611 var html = getBuiltIn('document', 'documentElement'); 2612 2613 /* global ActiveXObject -- old IE, WSH */ 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 var GT = '>'; 2629 var LT = '<'; 2630 var PROTOTYPE = 'prototype'; 2631 var SCRIPT = 'script'; 2632 var IE_PROTO$1 = sharedKey('IE_PROTO'); 2633 2634 var EmptyConstructor = function () { 2635 /* empty */ 2636 }; 2637 2638 var scriptTag = function (content) { 2639 return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT; 2640 }; // Create object with fake `null` prototype: use ActiveX Object with cleared prototype 2641 2642 2643 var NullProtoObjectViaActiveX = function (activeXDocument) { 2644 activeXDocument.write(scriptTag('')); 2645 activeXDocument.close(); 2646 var temp = activeXDocument.parentWindow.Object; 2647 activeXDocument = null; // avoid memory leak 2648 2649 return temp; 2650 }; // Create object with fake `null` prototype: use iframe Object with cleared prototype 2651 2652 2653 var NullProtoObjectViaIFrame = function () { 2654 // Thrash, waste and sodomy: IE GC bug 2655 var iframe = documentCreateElement('iframe'); 2656 var JS = 'java' + SCRIPT + ':'; 2657 var iframeDocument; 2658 iframe.style.display = 'none'; 2659 html.appendChild(iframe); // https://github.com/zloirock/core-js/issues/475 2660 2661 iframe.src = String(JS); 2662 iframeDocument = iframe.contentWindow.document; 2663 iframeDocument.open(); 2664 iframeDocument.write(scriptTag('document.F=Object')); 2665 iframeDocument.close(); 2666 return iframeDocument.F; 2667 }; // Check for document.domain and active x support 2668 // No need to use active x approach when document.domain is not set 2669 // see https://github.com/es-shims/es5-shim/issues/150 2670 // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346 2671 // avoid IE GC bug 2672 2673 2674 var activeXDocument; 2675 2676 var NullProtoObject = function () { 2677 try { 2678 activeXDocument = new ActiveXObject('htmlfile'); 2679 } catch (error) { 2680 /* ignore */ 2681 } 2682 2683 NullProtoObject = typeof document != 'undefined' ? document.domain && activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) // old IE 2684 : NullProtoObjectViaIFrame() : NullProtoObjectViaActiveX(activeXDocument); // WSH 2685 2686 var length = enumBugKeys.length; 2687 2688 while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]]; 2689 2690 return NullProtoObject(); 2691 }; 2692 2693 hiddenKeys[IE_PROTO$1] = true; // `Object.create` method 2694 // https://tc39.es/ecma262/#sec-object.create 2695 2696 var objectCreate = Object.create || function create(O, Properties) { 2697 var result; 2698 2699 if (O !== null) { 2700 EmptyConstructor[PROTOTYPE] = anObject(O); 2701 result = new EmptyConstructor(); 2702 EmptyConstructor[PROTOTYPE] = null; // add "__proto__" for Object.getPrototypeOf polyfill 2703 2704 result[IE_PROTO$1] = O; 2705 } else result = NullProtoObject(); 2706 2707 return Properties === undefined ? result : objectDefineProperties(result, Properties); 2708 }; 2709 2710 var createProperty = function (object, key, value) { 2711 var propertyKey = toPropertyKey(key); 2712 if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value));else object[propertyKey] = value; 2713 }; 2714 2715 var Array$1 = global_1.Array; 2716 var max$1 = Math.max; 2717 2718 var arraySliceSimple = function (O, start, end) { 2719 var length = lengthOfArrayLike(O); 2720 var k = toAbsoluteIndex(start, length); 2721 var fin = toAbsoluteIndex(end === undefined ? length : end, length); 2722 var result = Array$1(max$1(fin - k, 0)); 2723 2724 for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]); 2725 2726 result.length = n; 2727 return result; 2728 }; 2729 2730 var replace = functionUncurryThis(''.replace); 2731 var split$1 = functionUncurryThis(''.split); 2732 var join = functionUncurryThis([].join); 2733 2734 var TEST = function (arg) { 2735 return String(Error(arg).stack); 2736 }('zxcasd'); 2737 2738 var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/; 2739 var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST); 2740 var IS_FIREFOX_OR_SAFARI_STACK = /@[^\n]*\n/.test(TEST) && !/zxcasd/.test(TEST); 2741 2742 var clearErrorStack = function (stack, dropEntries) { 2743 if (typeof stack != 'string') return stack; 2744 2745 if (IS_V8_OR_CHAKRA_STACK) { 2746 while (dropEntries--) stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, ''); 2747 }
2747 else if (IS_FIREFOX_OR_SAFARI_STACK) { 2748 return join(arraySliceSimple(split$1(stack, '\n'), dropEntries), '\n'); 2749 } 2750 2751 return stack; 2752 }; 2753 2754 // `InstallErrorCause` abstract operation 2755 // https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause 2756 2757 2758 var installErrorCause = function (O, options) { 2759 if (isObject(options) && 'cause' in options) { 2760 createNonEnumerableProperty(O, 'cause', options.cause); 2761 } 2762 }; 2763 2764 var bind$1 = functionUncurryThis(functionUncurryThis.bind); // optional / simple context binding 2765 2766 var functionBindContext = function (fn, that) { 2767 aCallable(fn); 2768 return that === undefined ? fn : bind$1 ? bind$1(fn, that) : function () 2769 /* ...args */ 2770 { 2771 return fn.apply(that, arguments); 2772 }; 2773 }; 2774 2775 var iterators = {}; 2776 2777 var ITERATOR = wellKnownSymbol('iterator'); 2778 var ArrayPrototype = Array.prototype; // check on default Array iterator 2779 2780 var isArrayIteratorMethod = function (it) { 2781 return it !== undefined && (iterators.Array === it || ArrayPrototype[ITERATOR] === it); 2782 }; 2783 2784 var TO_STRING_TAG = wellKnownSymbol('toStringTag'); 2785 var test = {}; 2786 test[TO_STRING_TAG] = 'z'; 2787 var toStringTagSupport = String(test) === '[object z]'; 2788 2789 var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag'); 2790 var Object$5 = global_1.Object; // ES3 wrong here 2791 2792 var CORRECT_ARGUMENTS = classofRaw(function () { 2793 return arguments; 2794 }()) == 'Arguments'; // fallback for IE11 Script Access Denied error 2795 2796 var tryGet = function (it, key) { 2797 try { 2798 return it[key]; 2799 } catch (error) { 2800 /* empty */ 2801 } 2802 }; // getting tag from ES6+ `Object.prototype.toString` 2803 2804 2805 var classof = toStringTagSupport ? classofRaw : function (it) { 2806 var O, tag, result; 2807 return it === undefined ? 'Undefined' : it === null ? 'Null' // @@toStringTag case 2808 : typeof (tag = tryGet(O = Object$5(it), TO_STRING_TAG$1)) == 'string' ? tag // builtinTag case 2809 : CORRECT_ARGUMENTS ? classofRaw(O) // ES3 arguments fallback 2810 : (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result; 2811 }; 2812 2813 var ITERATOR$1 = wellKnownSymbol('iterator'); 2814 2815 var getIteratorMethod = function (it) { 2816 if (it != undefined) return getMethod(it, ITERATOR$1) || getMethod(it, '@@iterator') || iterators[classof(it)]; 2817 }; 2818 2819 var TypeError$9 = global_1.TypeError; 2820 2821 var getIterator = function (argument, usingIterator) { 2822 var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator; 2823 if (aCallable(iteratorMethod)) return anObject(functionCall(iteratorMethod, argument)); 2824 throw TypeError$9(tryToString(argument) + ' is not iterable'); 2825 }; 2826 2827 var iteratorClose = function (iterator, kind, value) { 2828 var innerResult, innerError; 2829 anObject(iterator); 2830 2831 try { 2832 innerResult = getMethod(iterator, 'return'); 2833 2834 if (!innerResult) { 2835 if (kind === 'throw') throw value; 2836 return value; 2837 } 2838 2839 innerResult = functionCall(innerResult, iterator); 2840 } catch (error) { 2841 innerError = true; 2842 innerResult = error; 2843 } 2844 2845 if (kind === 'throw') throw value; 2846 if (innerError) throw innerResult; 2847 anObject(innerResult); 2848 return value; 2849 }; 2850 2851 var TypeError$a = global_1.TypeError; 2852 2853 var Result = function (stopped, result) { 2854 this.stopped = stopped; 2855 this.result = result; 2856 }; 2857 2858 var ResultPrototype = Result.prototype; 2859 2860 var iterate = function (iterable, unboundFunction, options) { 2861 var that = options && options.that; 2862 var AS_ENTRIES = !!(options && options.AS_ENTRIES); 2863 var IS_ITERATOR = !!(options && options.IS_ITERATOR); 2864 var INTERRUPTED = !!(options && options.INTERRUPTED); 2865 var fn = functionBindContext(unboundFunction, that); 2866 var iterator, iterFn, index, length, result, next, step; 2867 2868 var stop = function (condition) { 2869 if (iterator) iteratorClose(iterator, 'normal', condition); 2870 return new Result(true, condition); 2871 }; 2872 2873 var callFn = function (value) { 2874 if (AS_ENTRIES) { 2875 anObject(value); 2876 return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]); 2877 } 2878 2879 return INTERRUPTED ? fn(value, stop) : fn(value); 2880 }; 2881 2882 if (IS_ITERATOR) { 2883 iterator = iterable; 2884 } else { 2885 iterFn = getIteratorMethod(iterable); 2886 if (!iterFn) throw TypeError$a(tryToString(iterable) + ' is not iterable'); // optimisation for array iterators 2887 2888 if (isArrayIteratorMethod(iterFn)) { 2889 for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) { 2890 result = callFn(iterable[index]); 2891 if (result && objectIsPrototypeOf(ResultPrototype, result)) return result; 2892 } 2893 2894 return new Result(false); 2895 } 2896 2897 iterator = getIterator(iterable, iterFn); 2898 } 2899 2900 next = iterator.next; 2901 2902 while (!(step = functionCall(next, iterator)).done) { 2903 try { 2904 result = callFn(step.value); 2905 } catch (error) { 2906 iteratorClose(iterator, 'throw', error); 2907 } 2908 2909 if (typeof result == 'object' && result && objectIsPrototypeOf(ResultPrototype, result)) return result; 2910 } 2911 2912 return new Result(false); 2913 }; 2914 2915 var String$4 = global_1.String; 2916 2917 var toString_1 = function (argument) { 2918 if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string'); 2919 return String$4(argument); 2920 }; 2921 2922 var normalizeStringArgument = function (argument, $default) { 2923 return argument === undefined ? arguments.length < 2 ? '' : $default : toString_1(argument); 2924 }; 2925 2926 var errorStackInstallable = !fails(function () { 2927 var error = Error('a'); 2928 if (!('stack' in error)) return true; // eslint-disable-next-line es/no-object-defineproperty -- safe 2929 2930 Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7)); 2931 return error.stack !== 7; 2932 }); 2933 2934 var TO_STRING_TAG$2 = wellKnownSymbol('toStringTag'); 2935 var Error$1 = global_1.Error; 2936 var push$1 = [].push; 2937 2938 var $AggregateError = function AggregateError(errors, message 2939 /* , options */ 2940 ) { 2941 var options = arguments.length > 2 ? arguments[2] : undefined; 2942 var isInstance = objectIsPrototypeOf(AggregateErrorPrototype, this); 2943 var that; 2944 2945 if (objectSetPrototypeOf) { 2946 that = objectSetPrototypeOf(new Error$1(undefined), isInstance ? objectGetPrototypeOf(this) : AggregateErrorPrototype); 2947 } else { 2948 that = isInstance ? this : objectCreate(AggregateErrorPrototype); 2949 createNonEnumerableProperty(that, TO_STRING_TAG$2, 'Error'); 2950 } 2951 2952 createNonEnumerableProperty(that, 'message', normalizeStringArgument(message, '')); 2953 if (errorStackInstallable) createNonEnumerableProperty(that, 'stack', clearErrorStack(that.stack, 1)); 2954 installErrorCause(that, options); 2955 var errorsArray = []; 2956 iterate(errors, push$1, { 2957 that: errorsArray 2958 }); 2959 createNonEnumerableProperty(that, 'errors', errorsArray); 2960 return that; 2961 }; 2962 2963 if (objectSetPrototypeOf) objectSetPrototypeOf($AggregateError, Error$1);else copyConstructorProperties($AggregateError, Error$1); 2964 var AggregateErrorPrototype = $AggregateError.prototype = objectCreate(Error$1.prototype, { 2965 constructor: createPropertyDescriptor(1, $AggregateError), 2966 message: createPropertyDescriptor(1, ''), 2967 name: createPropertyDescriptor(1, 'AggregateError') 2968 }); // `AggregateError` constructor 2969 // https://tc39.es/ecma262/#sec-aggregate-error-constructor 2970 2971 _export({ 2972 global: true 2973 }, { 2974 AggregateError: $AggregateError 2975 }); 2976 2977 var UNSCOPABLES = wellKnownSymbol('unscopables'); 2978 var ArrayPrototype$1 = Array.prototype; // Array.prototype[@@unscopables] 2979 // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 2980 2981 if (ArrayPrototype$1[UNSCOPABLES] == undefined) { 2982 objectDefineProperty.f(ArrayPrototype$1, UNSCOPABLES, { 2983 configurable: true, 2984 value: objectCreate(null) 2985 }); 2986 } // add a key to Array.prototype[@@unscopables] 2987 2988 2989 var addToUnscopables = function (key) { 2990 ArrayPrototype$1[UNSCOPABLES][key] = true; 2991 }; 2992 2993 // `Array.prototype.at` method 2994 // https://github.com/tc39/proposal-relative-indexing-method 2995 2996 2997 _export({ 2998 target: 'Array', 2999 proto: true 3000 }, { 3001 at: function at(index) { 3002 var O = toObject(this); 3003 var len = lengthOfArrayLike(O); 3004 var relativeIndex = toIntegerOrInfinity(index); 3005 var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; 3006 return k < 0 || k >= len ? undefined : O[k]; 3007 } 3008 }); 3009 addToUnscopables('at'); 3010 3011 // `IsArray` abstract operation 3012 // https://tc39.es/ecma262/#sec-isarray 3013 // eslint-disable-next-line es/no-array-isarray -- safe 3014 3015 3016 var isArray = Array.isArray || function isArray(argument) { 3017 return classofRaw(argument) == 'Array'; 3018 }; 3019 3020 var un$Reverse = functionUncurryThis([].reverse); 3021 var test$1 = [1, 2]; // `Array.prototype.reverse` method 3022 // https://tc39.es/ecma262/#sec-array.prototype.reverse 3023 // fix for Safari 12.0 bug 3024 // https://bugs.webkit.org/show_bug.cgi?id=188794 3025 3026 _export({ 3027 target: 'Array', 3028 proto: true, 3029 forced: String(test$1) === String(test$1.reverse()) 3030 }, { 3031 reverse: function reverse() { 3032 // eslint-disable-next-line no-self-assign -- dirty hack 3033 if (isArray(this)) this.length = this.length; 3034 return un$Reverse(this); 3035 } 3036 }); 3037 3038 // eslint-disable-next-line es/no-typed-arrays -- safe 3039 var arrayBufferNative = typeof ArrayBuffer != 'undefined' && typeof DataView != 'undefined'; 3040 3041 var redefineAll = function (target, src, options) { 3042 for (var key in src) redefine(target, key, src[key], options); 3043 3044 return target; 3045 }; 3046 3047 var TypeError$b = global_1.TypeError; 3048 3049 var anInstance = function (it, Prototype) { 3050 if (objectIsPrototypeOf(Prototype, it)) return it; 3051 throw TypeError$b('Incorrect invocation'); 3052 }; 3053 3054 var RangeError = global_1.RangeError; // `ToIndex` abstract operation 3055 // https://tc39.es/ecma262/#sec-toindex 3056 3057 var toIndex = function (it) { 3058 if (it === undefined) return 0; 3059 var number = toIntegerOrInfinity(it); 3060 var length = toLength(number); 3061 if (number !== length) throw RangeError('Wrong length or index'); 3062 return length; 3063 }; 3064 3065 // IEEE754 conversions based on https://github.com/feross/ieee754 3066 3067 3068 var Array$2 = global_1.Array; 3069 var abs = Math.abs; 3070 var pow = Math.pow; 3071 var floor$1 = Math.floor; 3072 var log = Math.log; 3073 var LN2 = Math.LN2; 3074 3075 var pack = function (number, mantissaLength, bytes) { 3076 var buffer = Array$2(bytes); 3077 var exponentLength = bytes * 8 - mantissaLength - 1; 3078 var eMax = (1 << exponentLength) - 1; 3079 var eBias = eMax >> 1; 3080 var rt = mantissaLength === 23 ? pow(2, -24) - pow(2, -77) : 0; 3081 var sign = number < 0 || number === 0 && 1 / number < 0 ? 1 : 0; 3082 var index = 0; 3083 var exponent, mantissa, c; 3084 number = abs(number); // eslint-disable-next-line no-self-compare -- NaN check 3085 3086 if (number != number || number === Infinity) { 3087 // eslint-disable-next-line no-self-compare -- NaN check 3088 mantissa = number != number ? 1 : 0; 3089 exponent = eMax; 3090 } else { 3091 exponent = floor$1(log(number) / LN2); 3092 c = pow(2, -exponent); 3093 3094 if (number * c < 1) { 3095 exponent--; 3096 c *= 2; 3097 } 3098 3099 if (exponent + eBias >= 1) { 3100 number += rt / c; 3101 } else { 3102 number += rt * pow(2, 1 - eBias); 3103 } 3104 3105 if (number * c >= 2) { 3106 exponent++; 3107 c /= 2; 3108 } 3109 3110 if (exponent + eBias >= eMax) { 3111 mantissa = 0; 3112 exponent = eMax; 3113 } else if (exponent + eBias >= 1) { 3114 mantissa = (number * c - 1) * pow(2, mantissaLength); 3115 exponent = exponent + eBias; 3116 } else { 3117 mantissa = number * pow(2, eBias - 1) * pow(2, mantissaLength); 3118 exponent = 0; 3119 } 3120 } 3121 3122 while (mantissaLength >= 8) { 3123 buffer[index++] = mantissa & 255; 3124 mantissa /= 256; 3125 mantissaLength -= 8; 3126 } 3127 3128 exponent = exponent << mantissaLength | mantissa; 3129 exponentLength += mantissaLength; 3130 3131 while (exponentLength > 0) { 3132 buffer[index++] = exponent & 255; 3133 exponent /= 256; 3134 exponentLength -= 8; 3135 } 3136 3137 buffer[--index] |= sign * 128; 3138 return buffer; 3139 }; 3140 3141 var unpack = function (buffer, mantissaLength) { 3142 var bytes = buffer.length; 3143 var exponentLength = bytes * 8 - mantissaLength - 1; 3144 var eMax = (1 << exponentLength) - 1; 3145 var eBias = eMax >> 1;
vendor: 6,238 bytes, lines 3146-3360
3146 var nBits = exponentLength - 7; 3147 var index = bytes - 1; 3148 var sign = buffer[index--]; 3149 var exponent = sign & 127; 3150 var mantissa; 3151 sign >>= 7; 3152 3153 while (nBits > 0) { 3154 exponent = exponent * 256 + buffer[index--]; 3155 nBits -= 8; 3156 } 3157 3158 mantissa = exponent & (1 << -nBits) - 1; 3159 exponent >>= -nBits; 3160 nBits += mantissaLength; 3161 3162 while (nBits > 0) { 3163 mantissa = mantissa * 256 + buffer[index--]; 3164 nBits -= 8; 3165 } 3166 3167 if (exponent === 0) { 3168 exponent = 1 - eBias; 3169 } else if (exponent === eMax) { 3170 return mantissa ? NaN : sign ? -Infinity : Infinity; 3171 } else { 3172 mantissa = mantissa + pow(2, mantissaLength); 3173 exponent = exponent - eBias; 3174 } 3175 3176 return (sign ? -1 : 1) * mantissa * pow(2, exponent - mantissaLength); 3177 }; 3178 3179 var ieee754 = { 3180 pack: pack, 3181 unpack: unpack 3182 }; 3183 3184 // `Array.prototype.fill` method implementation 3185 // https://tc39.es/ecma262/#sec-array.prototype.fill 3186 3187 3188 var arrayFill = function fill(value 3189 /* , start = 0, end = @length */ 3190 ) { 3191 var O = toObject(this); 3192 var length = lengthOfArrayLike(O); 3193 var argumentsLength = arguments.length; 3194 var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length); 3195 var end = argumentsLength > 2 ? arguments[2] : undefined; 3196 var endPos = end === undefined ? length : toAbsoluteIndex(end, length); 3197 3198 while (endPos > index) O[index++] = value; 3199 3200 return O; 3201 }; 3202 3203 var defineProperty$1 = objectDefineProperty.f; 3204 3205 3206 3207 3208 3209 var TO_STRING_TAG$3 = wellKnownSymbol('toStringTag'); 3210 3211 var setToStringTag = function (it, TAG, STATIC) { 3212 if (it && !hasOwnProperty_1(it = STATIC ? it : it.prototype, TO_STRING_TAG$3)) { 3213 defineProperty$1(it, TO_STRING_TAG$3, { 3214 configurable: true, 3215 value: TAG 3216 }); 3217 } 3218 }; 3219 3220 var getOwnPropertyNames = objectGetOwnPropertyNames.f; 3221 3222 var defineProperty$2 = objectDefineProperty.f; 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 var PROPER_FUNCTION_NAME = functionName.PROPER; 3233 var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE; 3234 var getInternalState = internalState.get; 3235 var setInternalState = internalState.set; 3236 var ARRAY_BUFFER = 'ArrayBuffer'; 3237 var DATA_VIEW = 'DataView'; 3238 var PROTOTYPE$1 = 'prototype'; 3239 var WRONG_LENGTH = 'Wrong length'; 3240 var WRONG_INDEX = 'Wrong index'; 3241 var NativeArrayBuffer = global_1[ARRAY_BUFFER]; 3242 var $ArrayBuffer = NativeArrayBuffer; 3243 var ArrayBufferPrototype = $ArrayBuffer && $ArrayBuffer[PROTOTYPE$1]; 3244 var $DataView = global_1[DATA_VIEW]; 3245 var DataViewPrototype = $DataView && $DataView[PROTOTYPE$1]; 3246 var ObjectPrototype$1 = Object.prototype; 3247 var Array$3 = global_1.Array; 3248 var RangeError$1 = global_1.RangeError; 3249 var fill = functionUncurryThis(arrayFill); 3250 var reverse = functionUncurryThis([].reverse); 3251 var packIEEE754 = ieee754.pack; 3252 var unpackIEEE754 = ieee754.unpack; 3253 3254 var packInt8 = function (number) { 3255 return [number & 0xFF]; 3256 }; 3257 3258 var packInt16 = function (number) { 3259 return [number & 0xFF, number >> 8 & 0xFF]; 3260 }; 3261 3262 var packInt32 = function (number) { 3263 return [number & 0xFF, number >> 8 & 0xFF, number >> 16 & 0xFF, number >> 24 & 0xFF]; 3264 }; 3265 3266 var unpackInt32 = function (buffer) { 3267 return buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0]; 3268 }; 3269 3270 var packFloat32 = function (number) { 3271 return packIEEE754(number, 23, 4); 3272 }; 3273 3274 var packFloat64 = function (number) { 3275 return packIEEE754(number, 52, 8); 3276 }; 3277 3278 var addGetter = function (Constructor, key) { 3279 defineProperty$2(Constructor[PROTOTYPE$1], key, { 3280 get: function () { 3281 return getInternalState(this)[key]; 3282 } 3283 }); 3284 }; 3285 3286 var get$1 = function (view, count, index, isLittleEndian) { 3287 var intIndex = toIndex(index); 3288 var store = getInternalState(view); 3289 if (intIndex + count > store.byteLength) throw RangeError$1(WRONG_INDEX); 3290 var bytes = getInternalState(store.buffer).bytes; 3291 var start = intIndex + store.byteOffset; 3292 var pack = arraySliceSimple(bytes, start, start + count); 3293 return isLittleEndian ? pack : reverse(pack); 3294 }; 3295 3296 var set$1 = function (view, count, index, conversion, value, isLittleEndian) { 3297 var intIndex = toIndex(index); 3298 var store = getInternalState(view); 3299 if (intIndex + count > store.byteLength) throw RangeError$1(WRONG_INDEX); 3300 var bytes = getInternalState(store.buffer).bytes; 3301 var start = intIndex + store.byteOffset; 3302 var pack = conversion(+value); 3303 3304 for (var i = 0; i < count; i++) bytes[start + i] = pack[isLittleEndian ? i : count - i - 1]; 3305 }; 3306 3307 if (!arrayBufferNative) { 3308 $ArrayBuffer = function ArrayBuffer(length) { 3309 anInstance(this, ArrayBufferPrototype); 3310 var byteLength = toIndex(length); 3311 setInternalState(this, { 3312 bytes: fill(Array$3(byteLength), 0), 3313 byteLength: byteLength 3314 }); 3315 if (!descriptors) this.byteLength = byteLength; 3316 }; 3317 3318 ArrayBufferPrototype = $ArrayBuffer[PROTOTYPE$1]; 3319 3320 $DataView = function DataView(buffer, byteOffset, byteLength) { 3321 anInstance(this, DataViewPrototype); 3322 anInstance(buffer, ArrayBufferPrototype); 3323 var bufferLength = getInternalState(buffer).byteLength; 3324 var offset = toIntegerOrInfinity(byteOffset); 3325 if (offset < 0 || offset > bufferLength) throw RangeError$1('Wrong offset'); 3326 byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength); 3327 if (offset + byteLength > bufferLength) throw RangeError$1(WRONG_LENGTH); 3328 setInternalState(this, { 3329 buffer: buffer, 3330 byteLength: byteLength, 3331 byteOffset: offset 3332 }); 3333 3334 if (!descriptors) { 3335 this.buffer = buffer; 3336 this.byteLength = byteLength; 3337 this.byteOffset = offset; 3338 } 3339 }; 3340 3341 DataViewPrototype = $DataView[PROTOTYPE$1]; 3342 3343 if (descriptors) { 3344 addGetter($ArrayBuffer, 'byteLength'); 3345 addGetter($DataView, 'buffer'); 3346 addGetter($DataView, 'byteLength'); 3347 addGetter($DataView, 'byteOffset'); 3348 } 3349 3350 redefineAll(DataViewPrototype, { 3351 getInt8: function getInt8(byteOffset) { 3352 return get$1(this, 1, byteOffset)[0] << 24 >> 24; 3353 }, 3354 getUint8: function getUint8(byteOffset) { 3355 return get$1(this, 1, byteOffset)[0]; 3356 }, 3357 getInt16: function getInt16(byteOffset 3358 /* , littleEndian */ 3359 ) { 3360 var bytes = get$1(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined);
vendor: 5,073 bytes, lines 3361-3499
3361 return (bytes[1] << 8 | bytes[0]) << 16 >> 16; 3362 }, 3363 getUint16: function getUint16(byteOffset 3364 /* , littleEndian */ 3365 ) { 3366 var bytes = get$1(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined); 3367 return bytes[1] << 8 | bytes[0]; 3368 }, 3369 getInt32: function getInt32(byteOffset 3370 /* , littleEndian */ 3371 ) { 3372 return unpackInt32(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)); 3373 }, 3374 getUint32: function getUint32(byteOffset 3375 /* , littleEndian */ 3376 ) { 3377 return unpackInt32(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)) >>> 0; 3378 }, 3379 getFloat32: function getFloat32(byteOffset 3380 /* , littleEndian */ 3381 ) { 3382 return unpackIEEE754(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 23); 3383 }, 3384 getFloat64: function getFloat64(byteOffset 3385 /* , littleEndian */ 3386 ) { 3387 return unpackIEEE754(get$1(this, 8, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 52); 3388 }, 3389 setInt8: function setInt8(byteOffset, value) { 3390 set$1(this, 1, byteOffset, packInt8, value); 3391 }, 3392 setUint8: function setUint8(byteOffset, value) { 3393 set$1(this, 1, byteOffset, packInt8, value); 3394 }, 3395 setInt16: function setInt16(byteOffset, value 3396 /* , littleEndian */ 3397 ) { 3398 set$1(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined); 3399 }, 3400 setUint16: function setUint16(byteOffset, value 3401 /* , littleEndian */ 3402 ) { 3403 set$1(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined); 3404 }, 3405 setInt32: function setInt32(byteOffset, value 3406 /* , littleEndian */ 3407 ) { 3408 set$1(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined); 3409 }, 3410 setUint32: function setUint32(byteOffset, value 3411 /* , littleEndian */ 3412 ) { 3413 set$1(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined); 3414 }, 3415 setFloat32: function setFloat32(byteOffset, value 3416 /* , littleEndian */ 3417 ) { 3418 set$1(this, 4, byteOffset, packFloat32, value, arguments.length > 2 ? arguments[2] : undefined); 3419 }, 3420 setFloat64: function setFloat64(byteOffset, value 3421 /* , littleEndian */ 3422 ) { 3423 set$1(this, 8, byteOffset, packFloat64, value, arguments.length > 2 ? arguments[2] : undefined); 3424 } 3425 }); 3426 } else { 3427 var INCORRECT_ARRAY_BUFFER_NAME = PROPER_FUNCTION_NAME && NativeArrayBuffer.name !== ARRAY_BUFFER; 3428 /* eslint-disable no-new -- required for testing */ 3429 3430 if (!fails(function () { 3431 NativeArrayBuffer(1); 3432 }) || !fails(function () { 3433 new NativeArrayBuffer(-1); 3434 }) || fails(function () { 3435 new NativeArrayBuffer(); 3436 new NativeArrayBuffer(1.5); 3437 new NativeArrayBuffer(NaN); 3438 return INCORRECT_ARRAY_BUFFER_NAME && !CONFIGURABLE_FUNCTION_NAME; 3439 })) { 3440 /* eslint-enable no-new -- required for testing */ 3441 $ArrayBuffer = function ArrayBuffer(length) { 3442 anInstance(this, ArrayBufferPrototype); 3443 return new NativeArrayBuffer(toIndex(length)); 3444 }; 3445 3446 $ArrayBuffer[PROTOTYPE$1] = ArrayBufferPrototype; 3447 3448 for (var keys$1 = getOwnPropertyNames(NativeArrayBuffer), j = 0, key; keys$1.length > j;) { 3449 if (!((key = keys$1[j++]) in $ArrayBuffer)) { 3450 createNonEnumerableProperty($ArrayBuffer, key, NativeArrayBuffer[key]); 3451 } 3452 } 3453 3454 ArrayBufferPrototype.constructor = $ArrayBuffer; 3455 } else if (INCORRECT_ARRAY_BUFFER_NAME && CONFIGURABLE_FUNCTION_NAME) { 3456 createNonEnumerableProperty(NativeArrayBuffer, 'name', ARRAY_BUFFER); 3457 } // WebKit bug - the same parent prototype for typed arrays and data view 3458 3459 3460 if (objectSetPrototypeOf && objectGetPrototypeOf(DataViewPrototype) !== ObjectPrototype$1) { 3461 objectSetPrototypeOf(DataViewPrototype, ObjectPrototype$1); 3462 } // iOS Safari 7.x bug 3463 3464 3465 var testView = new $DataView(new $ArrayBuffer(2)); 3466 var $setInt8 = functionUncurryThis(DataViewPrototype.setInt8); 3467 testView.setInt8(0, 2147483648); 3468 testView.setInt8(1, 2147483649); 3469 if (testView.getInt8(0) || !testView.getInt8(1)) redefineAll(DataViewPrototype, { 3470 setInt8: function setInt8(byteOffset, value) { 3471 $setInt8(this, byteOffset, value << 24 >> 24); 3472 }, 3473 setUint8: function setUint8(byteOffset, value) { 3474 $setInt8(this, byteOffset, value << 24 >> 24); 3475 } 3476 }, { 3477 unsafe: true 3478 }); 3479 } 3480 3481 setToStringTag($ArrayBuffer, ARRAY_BUFFER); 3482 setToStringTag($DataView, DATA_VIEW); 3483 var arrayBuffer = { 3484 ArrayBuffer: $ArrayBuffer, 3485 DataView: $DataView 3486 }; 3487 3488 var noop = function () { 3489 /* empty */ 3490 }; 3491 3492 var empty = []; 3493 var construct = getBuiltIn('Reflect', 'construct'); 3494 var constructorRegExp = /^\s*(?:class|function)\b/; 3495 var exec = functionUncurryThis(constructorRegExp.exec); 3496 var INCORRECT_TO_STRING = !constructorRegExp.exec(noop); 3497 3498 var isConstructorModern = function (argument) { 3499 if (!isCallable(argument)) return false;
3500 3501 try { 3502 construct(noop, empty, argument); 3503 return true; 3504 } catch (error) { 3505 return false; 3506 } 3507 }; 3508 3509 var isConstructorLegacy = function (argument) { 3510 if (!isCallable(argument)) return false; 3511 3512 switch (classof(argument)) { 3513 case 'AsyncFunction': 3514 case 'GeneratorFunction': 3515 case 'AsyncGeneratorFunction': 3516 return false; 3517 // we can't check .prototype since constructors produced by .bind haven't it 3518 } 3519 3520 return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument)); 3521 }; // `IsConstructor` abstract operation 3522 // https://tc39.es/ecma262/#sec-isconstructor 3523 3524 3525 var isConstructor = !construct || fails(function () { 3526 var called; 3527 return isConstructorModern(isConstructorModern.call) || !isConstructorModern(Object) || !isConstructorModern(function () { 3528 called = true; 3529 }) || called; 3530 }) ? isConstructorLegacy : isConstructorModern; 3531 3532 var TypeError$c = global_1.TypeError; // `Assert: IsConstructor(argument) is true` 3533 3534 var aConstructor = function (argument) { 3535 if (isConstructor(argument)) return argument; 3536 throw TypeError$c(tryToString(argument) + ' is not a constructor'); 3537 }; 3538 3539 var SPECIES = wellKnownSymbol('species'); // `SpeciesConstructor` abstract operation 3540 // https://tc39.es/ecma262/#sec-speciesconstructor 3541 3542 var speciesConstructor = function (O, defaultConstructor) { 3543 var C = anObject(O).constructor; 3544 var S; 3545 return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aConstructor(S); 3546 }; 3547 3548 var ArrayBuffer$1 = arrayBuffer.ArrayBuffer; 3549 var DataView$1 = arrayBuffer.DataView; 3550 var DataViewPrototype$1 = DataView$1.prototype; 3551 var un$ArrayBufferSlice = functionUncurryThis(ArrayBuffer$1.prototype.slice); 3552 var getUint8 = functionUncurryThis(DataViewPrototype$1.getUint8); 3553 var setUint8 = functionUncurryThis(DataViewPrototype$1.setUint8); 3554 var INCORRECT_SLICE = fails(function () { 3555 return !new ArrayBuffer$1(2).slice(1, undefined).byteLength; 3556 }); // `ArrayBuffer.prototype.slice` method 3557 // https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice 3558 3559 _export({ 3560 target: 'ArrayBuffer', 3561 proto: true, 3562 unsafe: true, 3563 forced: INCORRECT_SLICE 3564 }, { 3565 slice: function slice(start, end) { 3566 if (un$ArrayBufferSlice && end === undefined) { 3567 return un$ArrayBufferSlice(anObject(this), start); // FF fix 3568 } 3569 3570 var length = anObject(this).byteLength; 3571 var first = toAbsoluteIndex(start, length); 3572 var fin = toAbsoluteIndex(end === undefined ? length : end, length); 3573 var result = new (speciesConstructor(this, ArrayBuffer$1))(toLength(fin - first)); 3574 var viewSource = new DataView$1(this); 3575 var viewTarget = new DataView$1(result); 3576 var index = 0; 3577 3578 while (first < fin) { 3579 setUint8(viewTarget, index++, getUint8(viewSource, first++)); 3580 } 3581 3582 return result; 3583 } 3584 }); 3585 3586 // `Object.fromEntries` method 3587 // https://github.com/tc39/proposal-object-from-entries 3588 3589 3590 _export({ 3591 target: 'Object', 3592 stat: true 3593 }, { 3594 fromEntries: function fromEntries(iterable) { 3595 var obj = {}; 3596 iterate(iterable, function (k, v) { 3597 createProperty(obj, k, v); 3598 }, { 3599 AS_ENTRIES: true 3600 }); 3601 return obj; 3602 } 3603 }); 3604 3605 // `Object.hasOwn` method 3606 // https://github.com/tc39/proposal-accessible-object-hasownproperty 3607 3608 3609 _export({ 3610 target: 'Object', 3611 stat: true 3612 }, { 3613 hasOwn: hasOwnProperty_1 3614 }); 3615 3616 var PromiseCapability = function (C) { 3617 var resolve, reject; 3618 this.promise = new C(function ($$resolve, $$reject) { 3619 if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor'); 3620 resolve = $$resolve; 3621 reject = $$reject; 3622 }); 3623 this.resolve = aCallable(resolve); 3624 this.reject = aCallable(reject); 3625 }; // `NewPromiseCapability` abstract operation 3626 // https://tc39.es/ecma262/#sec-newpromisecapability 3627 3628 3629 var f$5 = function (C) { 3630 return new PromiseCapability(C); 3631 }; 3632 3633 var newPromiseCapability = { 3634 f: f$5 3635 }; 3636 3637 var perform = function (exec) { 3638 try { 3639 return { 3640 error: false, 3641 value: exec() 3642 }; 3643 } catch (error) { 3644 return { 3645 error: true, 3646 value: error 3647 }; 3648 } 3649 }; 3650 3651 // `Promise.allSettled` method 3652 // https://tc39.es/ecma262/#sec-promise.allsettled 3653 3654 3655 _export({ 3656 target: 'Promise', 3657 stat: true 3658 }, { 3659 allSettled: function allSettled(iterable) { 3660 var C = this; 3661 var capability = newPromiseCapability.f(C); 3662 var resolve = capability.resolve; 3663 var reject = capability.reject; 3664 var result = perform(function () { 3665 var promiseResolve = aCallable(C.resolve); 3666 var values = []; 3667 var counter = 0; 3668 var remaining = 1; 3669 iterate(iterable, function (promise) { 3670 var index = counter++; 3671 var alreadyCalled = false;
vendor: 2,994 bytes, lines 3672-3771
3672 remaining++; 3673 functionCall(promiseResolve, C, promise).then(function (value) { 3674 if (alreadyCalled) return; 3675 alreadyCalled = true; 3676 values[index] = { 3677 status: 'fulfilled', 3678 value: value 3679 }; 3680 --remaining || resolve(values); 3681 }, function (error) { 3682 if (alreadyCalled) return; 3683 alreadyCalled = true; 3684 values[index] = { 3685 status: 'rejected', 3686 reason: error 3687 }; 3688 --remaining || resolve(values); 3689 }); 3690 }); 3691 --remaining || resolve(values); 3692 }); 3693 if (result.error) reject(result.value); 3694 return capability.promise; 3695 } 3696 }); 3697 3698 var PROMISE_ANY_ERROR = 'No one promise resolved'; // `Promise.any` method 3699 // https://tc39.es/ecma262/#sec-promise.any 3700 3701 _export({ 3702 target: 'Promise', 3703 stat: true 3704 }, { 3705 any: function any(iterable) { 3706 var C = this; 3707 var AggregateError = getBuiltIn('AggregateError'); 3708 var capability = newPromiseCapability.f(C); 3709 var resolve = capability.resolve; 3710 var reject = capability.reject; 3711 var result = perform(function () { 3712 var promiseResolve = aCallable(C.resolve); 3713 var errors = []; 3714 var counter = 0; 3715 var remaining = 1; 3716 var alreadyResolved = false; 3717 iterate(iterable, function (promise) { 3718 var index = counter++; 3719 var alreadyRejected = false; 3720 remaining++; 3721 functionCall(promiseResolve, C, promise).then(function (value) { 3722 if (alreadyRejected || alreadyResolved) return; 3723 alreadyResolved = true; 3724 resolve(value); 3725 }, function (error) { 3726 if (alreadyRejected || alreadyResolved) return; 3727 alreadyRejected = true; 3728 errors[index] = error; 3729 --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR)); 3730 }); 3731 }); 3732 --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR)); 3733 }); 3734 if (result.error) reject(result.value); 3735 return capability.promise; 3736 } 3737 }); 3738 3739 var nativePromiseConstructor = global_1.Promise; 3740 3741 var promiseResolve = function (C, x) { 3742 anObject(C); 3743 if (isObject(x) && x.constructor === C) return x; 3744 var promiseCapability = newPromiseCapability.f(C); 3745 var resolve = promiseCapability.resolve; 3746 resolve(x); 3747 return promiseCapability.promise; 3748 }; 3749 3750 // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829 3751 3752 3753 var NON_GENERIC = !!nativePromiseConstructor && fails(function () { 3754 nativePromiseConstructor.prototype['finally'].call({ 3755 then: function () { 3756 /* empty */ 3757 } 3758 }, function () { 3759 /* empty */ 3760 }); 3761 }); // `Promise.prototype.finally` method 3762 // https://tc39.es/ecma262/#sec-promise.prototype.finally 3763 3764 _export({ 3765 target: 'Promise', 3766 proto: true, 3767 real: true, 3768 forced: NON_GENERIC 3769 }, { 3770 'finally': function (onFinally) { 3771 var C = speciesConstructor(this, getBuiltIn('Promise'));
3772 var isFunction = isCallable(onFinally); 3773 return this.then(isFunction ? function (x) { 3774 return promiseResolve(C, onFinally()).then(function () { 3775 return x; 3776 }); 3777 } : onFinally, isFunction ? function (e) { 3778 return promiseResolve(C, onFinally()).then(function () { 3779 throw e; 3780 }); 3781 } : onFinally); 3782 } 3783 }); // makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then` 3784 3785 if (!isPure && isCallable(nativePromiseConstructor)) { 3786 var method = getBuiltIn('Promise').prototype['finally']; 3787 3788 if (nativePromiseConstructor.prototype['finally'] !== method) { 3789 redefine(nativePromiseConstructor.prototype, 'finally', method, { 3790 unsafe: true 3791 }); 3792 } 3793 } 3794 3795 var ITERATOR$2 = wellKnownSymbol('iterator'); 3796 var BUGGY_SAFARI_ITERATORS = false; // `%IteratorPrototype%` object 3797 // https://tc39.es/ecma262/#sec-%iteratorprototype%-object 3798 3799 var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator; 3800 /* eslint-disable es/no-array-prototype-keys -- safe */ 3801 3802 if ([].keys) { 3803 arrayIterator = [].keys(); // Safari 8 has buggy iterators w/o `next` 3804 3805 if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;else { 3806 PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator)); 3807 if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype; 3808 } 3809 } 3810 3811 var NEW_ITERATOR_PROTOTYPE = IteratorPrototype == undefined || fails(function () { 3812 var test = {}; // FF44- legacy iterators case 3813 3814 return IteratorPrototype[ITERATOR$2].call(test) !== test; 3815 }); 3816 if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {}; // `%IteratorPrototype%[@@iterator]()` method 3817 // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator 3818 3819 if (!isCallable(IteratorPrototype[ITERATOR$2])) { 3820 redefine(IteratorPrototype, ITERATOR$2, function () { 3821 return this; 3822 }); 3823 } 3824 3825 var iteratorsCore = { 3826 IteratorPrototype: IteratorPrototype, 3827 BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS 3828 }; 3829 3830 var IteratorPrototype$1 = iteratorsCore.IteratorPrototype; 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 var returnThis = function () { 3841 return this; 3842 }; 3843 3844 var createIteratorConstructor = function (IteratorConstructor, NAME, next) { 3845 var TO_STRING_TAG = NAME + ' Iterator'; 3846 IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, { 3847 next: createPropertyDescriptor(1, next) 3848 }); 3849 setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true); 3850 iterators[TO_STRING_TAG] = returnThis; 3851 return IteratorConstructor; 3852 }; 3853 3854 var MATCH = wellKnownSymbol('match'); // `IsRegExp` abstract operation 3855 // https://tc39.es/ecma262/#sec-isregexp 3856 3857 var isRegexp = function (it) { 3858 var isRegExp; 3859 return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classofRaw(it) == 'RegExp'); 3860 }; 3861 3862 // `RegExp.prototype.flags` getter implementation 3863 // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags 3864 3865 3866 var regexpFlags = function () { 3867 var that = anObject(this); 3868 var result = ''; 3869 if (that.global) result += 'g'; 3870 if (that.ignoreCase) result += 'i'; 3871 if (that.multiline) result += 'm'; 3872 if (that.dotAll) result += 's'; 3873 if (that.unicode) result += 'u'; 3874 if (that.sticky) result += 'y'; 3875 return result; 3876 }; 3877 3878 var charAt = functionUncurryThis(''.charAt); 3879 var charCodeAt = functionUncurryThis(''.charCodeAt); 3880 var stringSlice$1 = functionUncurryThis(''.slice); 3881 3882 var createMethod$1 = function (CONVERT_TO_STRING) { 3883 return function ($this, pos) { 3884 var S = toString_1(requireObjectCoercible($this)); 3885 var position = toIntegerOrInfinity(pos); 3886 var size = S.length; 3887 var first, second; 3888 if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined; 3889 first = charCodeAt(S, position); 3890 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; 3891 }; 3892 }; 3893 3894 var stringMultibyte = { 3895 // `String.prototype.codePointAt` method 3896 // https://tc39.es/ecma262/#sec-string.prototype.codepointat 3897 codeAt: createMethod$1(false), 3898 // `String.prototype.at` method 3899 // https://github.com/mathiasbynens/String.prototype.at 3900 charAt: createMethod$1(true) 3901 }; 3902 3903 var charAt$1 = stringMultibyte.charAt; // `AdvanceStringIndex` abstract operation 3904 // https://tc39.es/ecma262/#sec-advancestringindex 3905 3906 3907 var advanceStringIndex = function (S, index, unicode) { 3908 return index + (unicode ? charAt$1(S, index).length : 1); 3909 }; 3910 3911 // babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError 3912 3913 3914 var $RegExp = global_1.RegExp; 3915 var UNSUPPORTED_Y = fails(function () { 3916 var re = $RegExp('a', 'y'); 3917 re.lastIndex = 2; 3918 return re.exec('abcd') != null; 3919 }); // UC Browser bug 3920 // https://github.com/zloirock/core-js/issues/1008 3921 3922 var MISSED_STICKY = UNSUPPORTED_Y || fails(function () { 3923 return !$RegExp('a', 'y').sticky; 3924 }); 3925 var BROKEN_CARET = UNSUPPORTED_Y || fails(function () { 3926 // https://bugzilla.mozilla.org/show_bug.cgi?id=773687 3927 var re = $RegExp('^r', 'gy'); 3928 re.lastIndex = 2; 3929 return re.exec('str') != null; 3930 }); 3931 var regexpStickyHelpers = { 3932 BROKEN_CARET: BROKEN_CARET, 3933 MISSED_STICKY: MISSED_STICKY, 3934 UNSUPPORTED_Y: UNSUPPORTED_Y 3935 }; 3936 3937 // babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError 3938 3939 3940 var $RegExp$1 = global_1.RegExp; 3941 var regexpUnsupportedDotAll = fails(function () { 3942 var re = $RegExp$1('.', 's'); 3943 return !(re.dotAll && re.exec('\n') && re.flags === 's'); 3944 }); 3945 3946 // babel-minify and Closure Compiler transpiles RegExp('(?<a>b)', 'g') -> /(?<a>b)/g and it causes SyntaxError 3947 3948 3949 var $RegExp$2 = global_1.RegExp; 3950 var regexpUnsupportedNcg = fails(function () {
vendor: 5,743 bytes, lines 3951-4184
3951 var re = $RegExp$2('(?<a>b)', 'g'); 3952 return re.exec('b').groups.a !== 'b' || 'b'.replace(re, '$<a>c') !== 'bc'; 3953 }); 3954 3955 /* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */ 3956 3957 /* eslint-disable regexp/no-useless-quantifier -- testing */ 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 var getInternalState$1 = internalState.get; 3974 3975 3976 3977 3978 3979 var nativeReplace = shared('native-string-replace', String.prototype.replace); 3980 var nativeExec = RegExp.prototype.exec; 3981 var patchedExec = nativeExec; 3982 var charAt$2 = functionUncurryThis(''.charAt); 3983 var indexOf$1 = functionUncurryThis(''.indexOf); 3984 var replace$1 = functionUncurryThis(''.replace); 3985 var stringSlice$2 = functionUncurryThis(''.slice); 3986 3987 var UPDATES_LAST_INDEX_WRONG = function () { 3988 var re1 = /a/; 3989 var re2 = /b*/g; 3990 functionCall(nativeExec, re1, 'a'); 3991 functionCall(nativeExec, re2, 'a'); 3992 return re1.lastIndex !== 0 || re2.lastIndex !== 0; 3993 }(); 3994 3995 var UNSUPPORTED_Y$1 = regexpStickyHelpers.BROKEN_CARET; // nonparticipating capturing group, copied from es5-shim's String#split patch. 3996 3997 var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; 3998 var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$1 || regexpUnsupportedDotAll || regexpUnsupportedNcg; 3999 4000 if (PATCH) { 4001 patchedExec = function exec(string) { 4002 var re = this; 4003 var state = getInternalState$1(re); 4004 var str = toString_1(string); 4005 var raw = state.raw; 4006 var result, reCopy, lastIndex, match, i, object, group; 4007 4008 if (raw) { 4009 raw.lastIndex = re.lastIndex; 4010 result = functionCall(patchedExec, raw, str); 4011 re.lastIndex = raw.lastIndex; 4012 return result; 4013 } 4014 4015 var groups = state.groups; 4016 var sticky = UNSUPPORTED_Y$1 && re.sticky; 4017 var flags = functionCall(regexpFlags, re); 4018 var source = re.source; 4019 var charsAdded = 0; 4020 var strCopy = str; 4021 4022 if (sticky) { 4023 flags = replace$1(flags, 'y', ''); 4024 4025 if (indexOf$1(flags, 'g') === -1) { 4026 flags += 'g'; 4027 } 4028 4029 strCopy = stringSlice$2(str, re.lastIndex); // Support anchored sticky behavior. 4030 4031 if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$2(str, re.lastIndex - 1) !== '\n')) { 4032 source = '(?: ' + source + ')'; 4033 strCopy = ' ' + strCopy; 4034 charsAdded++; 4035 } // ^(? + rx + ) is needed, in combination with some str slicing, to 4036 // simulate the 'y' flag. 4037 4038 4039 reCopy = new RegExp('^(?:' + source + ')', flags); 4040 } 4041 4042 if (NPCG_INCLUDED) { 4043 reCopy = new RegExp('^' + source + '$(?!\\s)', flags); 4044 } 4045 4046 if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex; 4047 match = functionCall(nativeExec, sticky ? reCopy : re, strCopy); 4048 4049 if (sticky) { 4050 if (match) { 4051 match.input = stringSlice$2(match.input, charsAdded); 4052 match[0] = stringSlice$2(match[0], charsAdded); 4053 match.index = re.lastIndex; 4054 re.lastIndex += match[0].length; 4055 } else re.lastIndex = 0; 4056 } else if (UPDATES_LAST_INDEX_WRONG && match) { 4057 re.lastIndex = re.global ? match.index + match[0].length : lastIndex; 4058 } 4059 4060 if (NPCG_INCLUDED && match && match.length > 1) { 4061 // Fix browsers whose `exec` methods don't consistently return `undefined` 4062 // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/ 4063 functionCall(nativeReplace, match[0], reCopy, function () { 4064 for (i = 1; i < arguments.length - 2; i++) { 4065 if (arguments[i] === undefined) match[i] = undefined; 4066 } 4067 }); 4068 } 4069 4070 if (match && groups) { 4071 match.groups = object = objectCreate(null); 4072 4073 for (i = 0; i < groups.length; i++) { 4074 group = groups[i]; 4075 object[group[0]] = match[group[1]]; 4076 } 4077 } 4078 4079 return match; 4080 }; 4081 } 4082 4083 var regexpExec = patchedExec; 4084 4085 var TypeError$d = global_1.TypeError; // `RegExpExec` abstract operation 4086 // https://tc39.es/ecma262/#sec-regexpexec 4087 4088 var regexpExecAbstract = function (R, S) { 4089 var exec = R.exec; 4090 4091 if (isCallable(exec)) { 4092 var result = functionCall(exec, R, S); 4093 if (result !== null) anObject(result); 4094 return result; 4095 } 4096 4097 if (classofRaw(R) === 'RegExp') return functionCall(regexpExec, R, S); 4098 throw TypeError$d('RegExp#exec called on incompatible receiver'); 4099 }; 4100 4101 /* eslint-disable es/no-string-prototype-matchall -- safe */ 4102 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 var MATCH_ALL = wellKnownSymbol('matchAll'); 4148 var REGEXP_STRING = 'RegExp String'; 4149 var REGEXP_STRING_ITERATOR = REGEXP_STRING + ' Iterator'; 4150 var setInternalState$1 = internalState.set; 4151 var getInternalState$2 = internalState.getterFor(REGEXP_STRING_ITERATOR); 4152 var RegExpPrototype = RegExp.prototype; 4153 var TypeError$e = global_1.TypeError; 4154 var getFlags = functionUncurryThis(regexpFlags); 4155 var stringIndexOf = functionUncurryThis(''.indexOf); 4156 var un$MatchAll = functionUncurryThis(''.matchAll); 4157 var WORKS_WITH_NON_GLOBAL_REGEX = !!un$MatchAll && !fails(function () { 4158 un$MatchAll('a', /./); 4159 }); 4160 var $RegExpStringIterator = createIteratorConstructor(function RegExpStringIterator(regexp, string, $global, fullUnicode) { 4161 setInternalState$1(this, { 4162 type: REGEXP_STRING_ITERATOR, 4163 regexp: regexp, 4164 string: string, 4165 global: $global, 4166 unicode: fullUnicode, 4167 done: false 4168 }); 4169 }, REGEXP_STRING, function next() { 4170 var state = getInternalState$2(this); 4171 if (state.done) return { 4172 value: undefined, 4173 done: true 4174 }; 4175 var R = state.regexp; 4176 var S = state.string; 4177 var match = regexpExecAbstract(R, S); 4178 if (match === null) return { 4179 value: undefined, 4180 done: state.done = true 4181 }; 4182 4183 if (state.global) { 4184 if (toString_1(match[0]) === '') R.lastIndex = advanceStringIndex(S, toLe
4184ngth(R.lastIndex), state.unicode); 4185 return { 4186 value: match, 4187 done: false 4188 }; 4189 } 4190 4191 state.done = true; 4192 return { 4193 value: match, 4194 done: false 4195 }; 4196 }); 4197 4198 var $matchAll = function (string) { 4199 var R = anObject(this); 4200 var S = toString_1(string); 4201 var C, flagsValue, flags, matcher, $global, fullUnicode; 4202 C = speciesConstructor(R, RegExp); 4203 flagsValue = R.flags; 4204 4205 if (flagsValue === undefined && objectIsPrototypeOf(RegExpPrototype, R) && !('flags' in RegExpPrototype)) { 4206 flagsValue = getFlags(R); 4207 } 4208 4209 flags = flagsValue === undefined ? '' : toString_1(flagsValue); 4210 matcher = new C(C === RegExp ? R.source : R, flags); 4211 $global = !!~stringIndexOf(flags, 'g'); 4212 fullUnicode = !!~stringIndexOf(flags, 'u'); 4213 matcher.lastIndex = toLength(R.lastIndex); 4214 return new $RegExpStringIterator(matcher, S, $global, fullUnicode); 4215 }; // `String.prototype.matchAll` method 4216 // https://tc39.es/ecma262/#sec-string.prototype.matchall 4217 4218 4219 _export({ 4220 target: 'String', 4221 proto: true, 4222 forced: WORKS_WITH_NON_GLOBAL_REGEX 4223 }, { 4224 matchAll: function matchAll(regexp) { 4225 var O = requireObjectCoercible(this); 4226 var flags, S, matcher, rx; 4227 4228 if (regexp != null) { 4229 if (isRegexp(regexp)) { 4230 flags = toString_1(requireObjectCoercible('flags' in RegExpPrototype ? regexp.flags : getFlags(regexp))); 4231 if (!~stringIndexOf(flags, 'g')) throw TypeError$e('`.matchAll` does not allow non-global regexes'); 4232 } 4233 4234 if (WORKS_WITH_NON_GLOBAL_REGEX) return un$MatchAll(O, regexp); 4235 matcher = getMethod(regexp, MATCH_ALL); 4236 if (matcher === undefined && isPure && classofRaw(regexp) == 'RegExp') matcher = $matchAll; 4237 if (matcher) return functionCall(matcher, regexp, O); 4238 } else if (WORKS_WITH_NON_GLOBAL_REGEX) return un$MatchAll(O, regexp); 4239 4240 S = toString_1(O); 4241 rx = new RegExp(regexp, 'g'); 4242 return isPure ? functionCall($matchAll, rx, S) : rx[MATCH_ALL](S); 4243 } 4244 }); 4245 isPure || MATCH_ALL in RegExpPrototype || redefine(RegExpPrototype, MATCH_ALL, $matchAll); 4246 4247 var floor$2 = Math.floor; 4248 var charAt$3 = functionUncurryThis(''.charAt); 4249 var replace$2 = functionUncurryThis(''.replace); 4250 var stringSlice$3 = functionUncurryThis(''.slice); 4251 var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g; 4252 var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g; // `GetSubstitution` abstract operation 4253 // https://tc39.es/ecma262/#sec-getsubstitution 4254 4255 var getSubstitution = function (matched, str, position, captures, namedCaptures, replacement) { 4256 var tailPos = position + matched.length; 4257 var m = captures.length; 4258 var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED; 4259 4260 if (namedCaptures !== undefined) { 4261 namedCaptures = toObject(namedCaptures); 4262 symbols = SUBSTITUTION_SYMBOLS; 4263 } 4264 4265 return replace$2(replacement, symbols, function (match, ch) { 4266 var capture; 4267 4268 switch (charAt$3(ch, 0)) { 4269 case '$': 4270 return '$'; 4271 4272 case '&': 4273 return matched; 4274 4275 case '`': 4276 return stringSlice$3(str, 0, position); 4277 4278 case "'": 4279 return stringSlice$3(str, tailPos); 4280 4281 case '<': 4282 capture = namedCaptures[stringSlice$3(ch, 1, -1)]; 4283 break; 4284 4285 default: 4286 // \d\d? 4287 var n = +ch; 4288 if (n === 0) return match; 4289 4290 if (n > m) { 4291 var f = floor$2(n / 10); 4292 if (f === 0) return match; 4293 if (f <= m) return captures[f - 1] === undefined ? charAt$3(ch, 1) : captures[f - 1] + charAt$3(ch, 1); 4294 return match; 4295 } 4296 4297 capture = captures[n - 1]; 4298 } 4299 4300 return capture === undefined ? '' : capture; 4301 }); 4302 }; 4303 4304 var REPLACE = wellKnownSymbol('replace'); 4305 var RegExpPrototype$1 = RegExp.prototype; 4306 var TypeError$f = global_1.TypeError; 4307 var getFlags$1 = functionUncurryThis(regexpFlags); 4308 var indexOf$2 = functionUncurryThis(''.indexOf); 4309 var replace$3 = functionUncurryThis(''.replace); 4310 var stringSlice$4 = functionUncurryThis(''.slice); 4311 var max$2 = Math.max; 4312 4313 var stringIndexOf$1 = function (string, searchValue, fromIndex) { 4314 if (fromIndex > string.length) return -1; 4315 if (searchValue === '') return fromIndex; 4316 return indexOf$2(string, searchValue, fromIndex); 4317 }; // `String.prototype.replaceAll` method 4318 // https://tc39.es/ecma262/#sec-string.prototype.replaceall 4319 4320 4321 _export({ 4322 target: 'String', 4323 proto: true 4324 }, { 4325 replaceAll: function replaceAll(searchValue, replaceValue) { 4326 var O = requireObjectCoercible(this); 4327 var IS_REG_EXP, flags, replacer, string, searchString, functionalReplace, searchLength, advanceBy, replacement; 4328 var position = 0; 4329 var endOfLastMatch = 0; 4330 var result = ''; 4331 4332 if (searchValue != null) { 4333 IS_REG_EXP = isRegexp(searchValue); 4334 4335 if (IS_REG_EXP) { 4336 flags = toString_1(requireObjectCoercible('flags' in RegExpPrototype$1 ? searchValue.flags : getFlags$1(searchValue))); 4337 if (!~indexOf$2(flags, 'g')) throw TypeError$f('`.replaceAll` does not allow non-global regexes'); 4338 } 4339 4340 replacer = getMethod(searchValue, REPLACE); 4341 4342 if (replacer) { 4343 return functionCall(replacer, searchValue, O, replaceValue); 4344 } else if (isPure && IS_REG_EXP) { 4345 return replace$3(toString_1(O), searchValue, replaceValue); 4346 } 4347 } 4348 4349 string = toString_1(O); 4350 searchString = toString_1(searchValue); 4351 functionalReplace = isCallable(replaceValue); 4352 if (!functionalReplace) replaceValue = toString_1(replaceValue); 4353 searchLength = searchString.length; 4354 advanceBy = max$2(1, searchLength); 4355 position = stringIndexOf$1(string, searchString, 0); 4356 4357 while (position !== -1) { 4358 replacement = functionalReplace ? toString_1(replaceValue(searchString, position, string)) : getSubstitution(searchString, string, position, [], undefined, replaceValue); 4359 result += stringSlice$4(string, endOfLastMatch, position) + replacement; 4360 endOfLastMatch = position + searchLength; 4361 position = stringIndexOf$1(string, searchString, position + advanceBy); 4362 } 4363 4364 if (endOfLastMatch < string.length) { 4365 result += stringSlice$4(string, endOfLastMatch); 4366 } 4367 4368 return result; 4369 } 4370 }); 4371 4372 var ITERATOR$3 = wellKnownSymbol('iterator'); 4373 var SAFE_CLOSING = false;
vendor: 4,474 bytes, lines 4374-4517
4374 4375 var checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) { 4376 if (!SKIP_CLOSING && !SAFE_CLOSING) return false; 4377 var ITERATION_SUPPORT = false; 4378 4379 try { 4380 var object = {}; 4381 4382 object[ITERATOR$3] = function () { 4383 return { 4384 next: function () { 4385 return { 4386 done: ITERATION_SUPPORT = true 4387 }; 4388 } 4389 }; 4390 }; 4391 4392 exec(object); 4393 } catch (error) { 4394 /* empty */ 4395 } 4396 4397 return ITERATION_SUPPORT; 4398 }; 4399 4400 var defineProperty$3 = objectDefineProperty.f; 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 var Int8Array = global_1.Int8Array; 4413 var Int8ArrayPrototype = Int8Array && Int8Array.prototype; 4414 var Uint8ClampedArray = global_1.Uint8ClampedArray; 4415 var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype; 4416 var TypedArray = Int8Array && objectGetPrototypeOf(Int8Array); 4417 var TypedArrayPrototype = Int8ArrayPrototype && objectGetPrototypeOf(Int8ArrayPrototype); 4418 var ObjectPrototype$2 = Object.prototype; 4419 var TypeError$g = global_1.TypeError; 4420 var TO_STRING_TAG$4 = wellKnownSymbol('toStringTag'); 4421 var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG'); 4422 var TYPED_ARRAY_CONSTRUCTOR = uid('TYPED_ARRAY_CONSTRUCTOR'); // Fixing native typed arrays in Opera Presto crashes the browser, see #595 4423 4424 var NATIVE_ARRAY_BUFFER_VIEWS = arrayBufferNative && !!objectSetPrototypeOf && classof(global_1.opera) !== 'Opera'; 4425 var TYPED_ARRAY_TAG_REQIRED = false; 4426 var NAME, Constructor, Prototype; 4427 var TypedArrayConstructorsList = { 4428 Int8Array: 1, 4429 Uint8Array: 1, 4430 Uint8ClampedArray: 1, 4431 Int16Array: 2, 4432 Uint16Array: 2, 4433 Int32Array: 4, 4434 Uint32Array: 4, 4435 Float32Array: 4, 4436 Float64Array: 8 4437 }; 4438 var BigIntArrayConstructorsList = { 4439 BigInt64Array: 8, 4440 BigUint64Array: 8 4441 }; 4442 4443 var isView = function isView(it) { 4444 if (!isObject(it)) return false; 4445 var klass = classof(it); 4446 return klass === 'DataView' || hasOwnProperty_1(TypedArrayConstructorsList, klass) || hasOwnProperty_1(BigIntArrayConstructorsList, klass); 4447 }; 4448 4449 var isTypedArray = function (it) { 4450 if (!isObject(it)) return false; 4451 var klass = classof(it); 4452 return hasOwnProperty_1(TypedArrayConstructorsList, klass) || hasOwnProperty_1(BigIntArrayConstructorsList, klass); 4453 }; 4454 4455 var aTypedArray = function (it) { 4456 if (isTypedArray(it)) return it; 4457 throw TypeError$g('Target is not a typed array'); 4458 }; 4459 4460 var aTypedArrayConstructor = function (C) { 4461 if (isCallable(C) && (!objectSetPrototypeOf || objectIsPrototypeOf(TypedArray, C))) return C; 4462 throw TypeError$g(tryToString(C) + ' is not a typed array constructor'); 4463 }; 4464 4465 var exportTypedArrayMethod = function (KEY, property, forced) { 4466 if (!descriptors) return; 4467 if (forced) for (var ARRAY in TypedArrayConstructorsList) { 4468 var TypedArrayConstructor = global_1[ARRAY]; 4469 if (TypedArrayConstructor && hasOwnProperty_1(TypedArrayConstructor.prototype, KEY)) try { 4470 delete TypedArrayConstructor.prototype[KEY]; 4471 } catch (error) { 4472 /* empty */ 4473 } 4474 } 4475 4476 if (!TypedArrayPrototype[KEY] || forced) { 4477 redefine(TypedArrayPrototype, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property); 4478 } 4479 }; 4480 4481 var exportTypedArrayStaticMethod = function (KEY, property, forced) { 4482 var ARRAY, TypedArrayConstructor; 4483 if (!descriptors) return; 4484 4485 if (objectSetPrototypeOf) { 4486 if (forced) for (ARRAY in TypedArrayConstructorsList) { 4487 TypedArrayConstructor = global_1[ARRAY]; 4488 if (TypedArrayConstructor && hasOwnProperty_1(TypedArrayConstructor, KEY)) try { 4489 delete TypedArrayConstructor[KEY]; 4490 } catch (error) { 4491 /* empty */ 4492 } 4493 } 4494 4495 if (!TypedArray[KEY] || forced) { 4496 // V8 ~ Chrome 49-50 `%TypedArray%` methods are non-writable non-configurable 4497 try { 4498 return redefine(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && TypedArray[KEY] || property); 4499 } catch (error) { 4500 /* empty */ 4501 } 4502 } else return; 4503 } 4504 4505 for (ARRAY in TypedArrayConstructorsList) { 4506 TypedArrayConstructor = global_1[ARRAY]; 4507 4508 if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) { 4509 redefine(TypedArrayConstructor, KEY, property); 4510 } 4511 } 4512 }; 4513 4514 for (NAME in TypedArrayConstructorsList) { 4515 Constructor = global_1[NAME]; 4516 Prototype = Constructor && Constructor.prototype; 4517 if (Prototype) createNonEnumerableProperty(Prototype, TYPED_ARRAY_CONSTRUCTOR, Constructor);else NATIVE_ARRAY_BUFFER_VIEWS = false;
vendor: 5,622 bytes, lines 4518-4690
4518 } 4519 4520 for (NAME in BigIntArrayConstructorsList) { 4521 Constructor = global_1[NAME]; 4522 Prototype = Constructor && Constructor.prototype; 4523 if (Prototype) createNonEnumerableProperty(Prototype, TYPED_ARRAY_CONSTRUCTOR, Constructor); 4524 } // WebKit bug - typed arrays constructors prototype is Object.prototype 4525 4526 4527 if (!NATIVE_ARRAY_BUFFER_VIEWS || !isCallable(TypedArray) || TypedArray === Function.prototype) { 4528 // eslint-disable-next-line no-shadow -- safe 4529 TypedArray = function TypedArray() { 4530 throw TypeError$g('Incorrect invocation'); 4531 }; 4532 4533 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { 4534 if (global_1[NAME]) objectSetPrototypeOf(global_1[NAME], TypedArray); 4535 } 4536 } 4537 4538 if (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype$2) { 4539 TypedArrayPrototype = TypedArray.prototype; 4540 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { 4541 if (global_1[NAME]) objectSetPrototypeOf(global_1[NAME].prototype, TypedArrayPrototype); 4542 } 4543 } // WebKit bug - one more object in Uint8ClampedArray prototype chain 4544 4545 4546 if (NATIVE_ARRAY_BUFFER_VIEWS && objectGetPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) { 4547 objectSetPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype); 4548 } 4549 4550 if (descriptors && !hasOwnProperty_1(TypedArrayPrototype, TO_STRING_TAG$4)) { 4551 TYPED_ARRAY_TAG_REQIRED = true; 4552 defineProperty$3(TypedArrayPrototype, TO_STRING_TAG$4, { 4553 get: function () { 4554 return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined; 4555 } 4556 }); 4557 4558 for (NAME in TypedArrayConstructorsList) if (global_1[NAME]) { 4559 createNonEnumerableProperty(global_1[NAME], TYPED_ARRAY_TAG, NAME); 4560 } 4561 } 4562 4563 var arrayBufferViewCore = { 4564 NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS, 4565 TYPED_ARRAY_CONSTRUCTOR: TYPED_ARRAY_CONSTRUCTOR, 4566 TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQIRED && TYPED_ARRAY_TAG, 4567 aTypedArray: aTypedArray, 4568 aTypedArrayConstructor: aTypedArrayConstructor, 4569 exportTypedArrayMethod: exportTypedArrayMethod, 4570 exportTypedArrayStaticMethod: exportTypedArrayStaticMethod, 4571 isView: isView, 4572 isTypedArray: isTypedArray, 4573 TypedArray: TypedArray, 4574 TypedArrayPrototype: TypedArrayPrototype 4575 }; 4576 4577 /* eslint-disable no-new -- required for testing */ 4578 4579 4580 4581 4582 4583 4584 var NATIVE_ARRAY_BUFFER_VIEWS$1 = arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; 4585 4586 var ArrayBuffer$2 = global_1.ArrayBuffer; 4587 var Int8Array$1 = global_1.Int8Array; 4588 var typedArrayConstructorsRequireWrappers = !NATIVE_ARRAY_BUFFER_VIEWS$1 || !fails(function () { 4589 Int8Array$1(1); 4590 }) || !fails(function () { 4591 new Int8Array$1(-1); 4592 }) || !checkCorrectnessOfIteration(function (iterable) { 4593 new Int8Array$1(); 4594 new Int8Array$1(null); 4595 new Int8Array$1(1.5); 4596 new Int8Array$1(iterable); 4597 }, true) || fails(function () { 4598 // Safari (11+) bug - a reason why even Safari 13 should load a typed array polyfill 4599 return new Int8Array$1(new ArrayBuffer$2(2), 1, undefined).length !== 1; 4600 }); 4601 4602 var floor$3 = Math.floor; // `IsIntegralNumber` abstract operation 4603 // https://tc39.es/ecma262/#sec-isintegralnumber 4604 // eslint-disable-next-line es/no-number-isinteger -- safe 4605 4606 var isIntegralNumber = Number.isInteger || function isInteger(it) { 4607 return !isObject(it) && isFinite(it) && floor$3(it) === it; 4608 }; 4609 4610 var RangeError$2 = global_1.RangeError; 4611 4612 var toPositiveInteger = function (it) { 4613 var result = toIntegerOrInfinity(it); 4614 if (result < 0) throw RangeError$2("The argument can't be less than 0"); 4615 return result; 4616 }; 4617 4618 var RangeError$3 = global_1.RangeError; 4619 4620 var toOffset = function (it, BYTES) { 4621 var offset = toPositiveInteger(it); 4622 if (offset % BYTES) throw RangeError$3('Wrong offset'); 4623 return offset; 4624 }; 4625 4626 var aTypedArrayConstructor$1 = arrayBufferViewCore.aTypedArrayConstructor; 4627 4628 var typedArrayFrom = function from(source 4629 /* , mapfn, thisArg */ 4630 ) { 4631 var C = aConstructor(this); 4632 var O = toObject(source); 4633 var argumentsLength = arguments.length; 4634 var mapfn = argumentsLength > 1 ? arguments[1] : undefined; 4635 var mapping = mapfn !== undefined; 4636 var iteratorMethod = getIteratorMethod(O); 4637 var i, length, result, step, iterator, next; 4638 4639 if (iteratorMethod && !isArrayIteratorMethod(iteratorMethod)) { 4640 iterator = getIterator(O, iteratorMethod); 4641 next = iterator.next; 4642 O = []; 4643 4644 while (!(step = functionCall(next, iterator)).done) { 4645 O.push(step.value); 4646 } 4647 } 4648 4649 if (mapping && argumentsLength > 2) { 4650 mapfn = functionBindContext(mapfn, arguments[2]); 4651 } 4652 4653 length = lengthOfArrayLike(O); 4654 result = new (aTypedArrayConstructor$1(C))(length); 4655 4656 for (i = 0; length > i; i++) { 4657 result[i] = mapping ? mapfn(O[i], i) : O[i]; 4658 } 4659 4660 return result; 4661 }; 4662 4663 var SPECIES$1 = wellKnownSymbol('species'); 4664 var Array$4 = global_1.Array; // a part of `ArraySpeciesCreate` abstract operation 4665 // https://tc39.es/ecma262/#sec-arrayspeciescreate 4666 4667 var arraySpeciesConstructor = function (originalArray) { 4668 var C; 4669 4670 if (isArray(originalArray)) { 4671 C = originalArray.constructor; // cross-realm fallback 4672 4673 if (isConstructor(C) && (C === Array$4 || isArray(C.prototype))) C = undefined;else if (isObject(C)) { 4674 C = C[SPECIES$1]; 4675 if (C === null) C = undefined; 4676 } 4677 } 4678 4679 return C === undefined ? Array$4 : C; 4680 }; 4681 4682 // `ArraySpeciesCreate` abstract operation 4683 // https://tc39.es/ecma262/#sec-arrayspeciescreate 4684 4685 4686 var arraySpeciesCreate = function (originalArray, length) { 4687 return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length); 4688 }; 4689 4690 var push$2 = functionUncurryThis([].push);
4690 // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation 4691 4692 var createMethod$2 = function (TYPE) { 4693 var IS_MAP = TYPE == 1; 4694 var IS_FILTER = TYPE == 2; 4695 var IS_SOME = TYPE == 3; 4696 var IS_EVERY = TYPE == 4; 4697 var IS_FIND_INDEX = TYPE == 6; 4698 var IS_FILTER_REJECT = TYPE == 7; 4699 var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; 4700 return function ($this, callbackfn, that, specificCreate) { 4701 var O = toObject($this); 4702 var self = indexedObject(O); 4703 var boundFunction = functionBindContext(callbackfn, that); 4704 var length = lengthOfArrayLike(self); 4705 var index = 0; 4706 var create = specificCreate || arraySpeciesCreate; 4707 var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined; 4708 var value, result; 4709 4710 for (; length > index; index++) if (NO_HOLES || index in self) { 4711 value = self[index]; 4712 result = boundFunction(value, index, O); 4713 4714 if (TYPE) { 4715 if (IS_MAP) target[index] = result; // map 4716 else if (result) switch (TYPE) { 4717 case 3: 4718 return true; 4719 // some 4720 4721 case 5: 4722 return value; 4723 // find 4724 4725 case 6: 4726 return index; 4727 // findIndex 4728 4729 case 2: 4730 push$2(target, value); 4731 // filter 4732 } else switch (TYPE) { 4733 case 4: 4734 return false; 4735 // every 4736 4737 case 7: 4738 push$2(target, value); 4739 // filterReject 4740 } 4741 } 4742 } 4743 4744 return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target; 4745 }; 4746 }; 4747 4748 var arrayIteration = { 4749 // `Array.prototype.forEach` method 4750 // https://tc39.es/ecma262/#sec-array.prototype.foreach 4751 forEach: createMethod$2(0), 4752 // `Array.prototype.map` method 4753 // https://tc39.es/ecma262/#sec-array.prototype.map 4754 map: createMethod$2(1), 4755 // `Array.prototype.filter` method 4756 // https://tc39.es/ecma262/#sec-array.prototype.filter 4757 filter: createMethod$2(2), 4758 // `Array.prototype.some` method 4759 // https://tc39.es/ecma262/#sec-array.prototype.some 4760 some: createMethod$2(3), 4761 // `Array.prototype.every` method 4762 // https://tc39.es/ecma262/#sec-array.prototype.every 4763 every: createMethod$2(4), 4764 // `Array.prototype.find` method 4765 // https://tc39.es/ecma262/#sec-array.prototype.find 4766 find: createMethod$2(5), 4767 // `Array.prototype.findIndex` method 4768 // https://tc39.es/ecma262/#sec-array.prototype.findIndex 4769 findIndex: createMethod$2(6), 4770 // `Array.prototype.filterReject` method 4771 // https://github.com/tc39/proposal-array-filtering 4772 filterReject: createMethod$2(7) 4773 }; 4774 4775 var SPECIES$2 = wellKnownSymbol('species'); 4776 4777 var setSpecies = function (CONSTRUCTOR_NAME) { 4778 var Constructor = getBuiltIn(CONSTRUCTOR_NAME); 4779 var defineProperty = objectDefineProperty.f; 4780 4781 if (descriptors && Constructor && !Constructor[SPECIES$2]) { 4782 defineProperty(Constructor, SPECIES$2, { 4783 configurable: true, 4784 get: function () { 4785 return this; 4786 } 4787 }); 4788 } 4789 }; 4790 4791 // makes subclassing work correct for wrapped built-ins 4792 4793 4794 var inheritIfRequired = function ($this, dummy, Wrapper) { 4795 var NewTarget, NewTargetPrototype; 4796 if ( // it can work only with native `setPrototypeOf` 4797 objectSetPrototypeOf && // we haven't completely correct pre-ES6 way for getting `new.target`, so use this 4798 isCallable(NewTarget = dummy.constructor) && NewTarget !== Wrapper && isObject(NewTargetPrototype = NewTarget.prototype) && NewTargetPrototype !== Wrapper.prototype) objectSetPrototypeOf($this, NewTargetPrototype); 4799 return $this; 4800 }; 4801 4802 var typedArrayConstructor = createCommonjsModule(function (module) { 4803 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 var getOwnPropertyNames = objectGetOwnPropertyNames.f; 4849 4850 4851
vendor: 7,113 bytes, lines 4852-5034
4852 var forEach = arrayIteration.forEach; 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 var getInternalState = internalState.get; 4865 var setInternalState = internalState.set; 4866 var nativeDefineProperty = objectDefineProperty.f; 4867 var nativeGetOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; 4868 var round = Math.round; 4869 var RangeError = global_1.RangeError; 4870 var ArrayBuffer = arrayBuffer.ArrayBuffer; 4871 var ArrayBufferPrototype = ArrayBuffer.prototype; 4872 var DataView = arrayBuffer.DataView; 4873 var NATIVE_ARRAY_BUFFER_VIEWS = arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; 4874 var TYPED_ARRAY_CONSTRUCTOR = arrayBufferViewCore.TYPED_ARRAY_CONSTRUCTOR; 4875 var TYPED_ARRAY_TAG = arrayBufferViewCore.TYPED_ARRAY_TAG; 4876 var TypedArray = arrayBufferViewCore.TypedArray; 4877 var TypedArrayPrototype = arrayBufferViewCore.TypedArrayPrototype; 4878 var aTypedArrayConstructor = arrayBufferViewCore.aTypedArrayConstructor; 4879 var isTypedArray = arrayBufferViewCore.isTypedArray; 4880 var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT'; 4881 var WRONG_LENGTH = 'Wrong length'; 4882 4883 var fromList = function (C, list) { 4884 aTypedArrayConstructor(C); 4885 var index = 0; 4886 var length = list.length; 4887 var result = new C(length); 4888 4889 while (length > index) result[index] = list[index++]; 4890 4891 return result; 4892 }; 4893 4894 var addGetter = function (it, key) { 4895 nativeDefineProperty(it, key, { 4896 get: function () { 4897 return getInternalState(this)[key]; 4898 } 4899 }); 4900 }; 4901 4902 var isArrayBuffer = function (it) { 4903 var klass; 4904 return objectIsPrototypeOf(ArrayBufferPrototype, it) || (klass = classof(it)) == 'ArrayBuffer' || klass == 'SharedArrayBuffer'; 4905 }; 4906 4907 var isTypedArrayIndex = function (target, key) { 4908 return isTypedArray(target) && !isSymbol(key) && key in target && isIntegralNumber(+key) && key >= 0; 4909 }; 4910 4911 var wrappedGetOwnPropertyDescriptor = function getOwnPropertyDescriptor(target, key) { 4912 key = toPropertyKey(key); 4913 return isTypedArrayIndex(target, key) ? createPropertyDescriptor(2, target[key]) : nativeGetOwnPropertyDescriptor(target, key); 4914 }; 4915 4916 var wrappedDefineProperty = function defineProperty(target, key, descriptor) { 4917 key = toPropertyKey(key); 4918 4919 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 4920 && !descriptor.configurable && (!hasOwnProperty_1(descriptor, 'writable') || descriptor.writable) && (!hasOwnProperty_1(descriptor, 'enumerable') || descriptor.enumerable)) { 4921 target[key] = descriptor.value; 4922 return target; 4923 } 4924 4925 return nativeDefineProperty(target, key, descriptor); 4926 }; 4927 4928 if (descriptors) { 4929 if (!NATIVE_ARRAY_BUFFER_VIEWS) { 4930 objectGetOwnPropertyDescriptor.f = wrappedGetOwnPropertyDescriptor; 4931 objectDefineProperty.f = wrappedDefineProperty; 4932 addGetter(TypedArrayPrototype, 'buffer'); 4933 addGetter(TypedArrayPrototype, 'byteOffset'); 4934 addGetter(TypedArrayPrototype, 'byteLength'); 4935 addGetter(TypedArrayPrototype, 'length'); 4936 } 4937 4938 _export({ 4939 target: 'Object', 4940 stat: true, 4941 forced: !NATIVE_ARRAY_BUFFER_VIEWS 4942 }, { 4943 getOwnPropertyDescriptor: wrappedGetOwnPropertyDescriptor, 4944 defineProperty: wrappedDefineProperty 4945 }); 4946 4947 module.exports = function (TYPE, wrapper, CLAMPED) { 4948 var BYTES = TYPE.match(/\d+$/)[0] / 8; 4949 var CONSTRUCTOR_NAME = TYPE + (CLAMPED ? 'Clamped' : '') + 'Array'; 4950 var GETTER = 'get' + TYPE; 4951 var SETTER = 'set' + TYPE; 4952 var NativeTypedArrayConstructor = global_1[CONSTRUCTOR_NAME]; 4953 var TypedArrayConstructor = NativeTypedArrayConstructor; 4954 var TypedArrayConstructorPrototype = TypedArrayConstructor && TypedArrayConstructor.prototype; 4955 var exported = {}; 4956 4957 var getter = function (that, index) { 4958 var data = getInternalState(that); 4959 return data.view[GETTER](index * BYTES + data.byteOffset, true); 4960 }; 4961 4962 var setter = function (that, index, value) { 4963 var data = getInternalState(that); 4964 if (CLAMPED) value = (value = round(value)) < 0 ? 0 : value > 0xFF ? 0xFF : value & 0xFF; 4965 data.view[SETTER](index * BYTES + data.byteOffset, value, true); 4966 }; 4967 4968 var addElement = function (that, index) { 4969 nativeDefineProperty(that, index, { 4970 get: function () { 4971 return getter(this, index); 4972 }, 4973 set: function (value) { 4974 return setter(this, index, value); 4975 }, 4976 enumerable: true 4977 }); 4978 }; 4979 4980 if (!NATIVE_ARRAY_BUFFER_VIEWS) { 4981 TypedArrayConstructor = wrapper(function (that, data, offset, $length) { 4982 anInstance(that, TypedArrayConstructorPrototype); 4983 var index = 0; 4984 var byteOffset = 0; 4985 var buffer, byteLength, length; 4986 4987 if (!isObject(data)) { 4988 length = toIndex(data); 4989 byteLength = length * BYTES; 4990 buffer = new ArrayBuffer(byteLength); 4991 } else if (isArrayBuffer(data)) { 4992 buffer = data; 4993 byteOffset = toOffset(offset, BYTES); 4994 var $len = data.byteLength; 4995 4996 if ($length === undefined) { 4997 if ($len % BYTES) throw RangeError(WRONG_LENGTH); 4998 byteLength = $len - byteOffset; 4999 if (byteLength < 0) throw RangeError(WRONG_LENGTH); 5000 } else { 5001 byteLength = toLength($length) * BYTES; 5002 if (byteLength + byteOffset > $len) throw RangeError(WRONG_LENGTH); 5003 } 5004 5005 length = byteLength / BYTES; 5006 } else if (isTypedArray(data)) { 5007 return fromList(TypedArrayConstructor, data); 5008 } else { 5009 return functionCall(typedArrayFrom, TypedArrayConstructor, data); 5010 } 5011 5012 setInternalState(that, { 5013 buffer: buffer, 5014 byteOffset: byteOffset, 5015 byteLength: byteLength, 5016 length: length, 5017 view: new DataView(buffer) 5018 }); 5019 5020 while (index < length) addElement(that, index++); 5021 }); 5022 if (objectSetPrototypeOf) objectSetPrototypeOf(TypedArrayConstructor, TypedArray); 5023 TypedArrayConstructorPrototype = TypedArrayConstructor.prototype = objectCreate(TypedArrayPrototype); 5024 } else if (typedArrayConstructorsRequireWrappers) { 5025 TypedArrayConstructor = wrapper(function (dummy, data, typedArrayOffset, $length) { 5026 anInstance(dummy, TypedArrayConstructorPrototype); 5027 return inheritIfRequired(function () { 5028 if (!isObject(data)) return new NativeTypedArrayConstructor(toIndex(data)); 5029 if (isArrayBuffer(data)) return $length !== undefined ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES), $length) : typedArrayOffset !== undefined ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES)) : new NativeTypedArrayConstructor(data); 5030 if (isTypedArray(data)) return fromList(TypedArrayConstructor, data); 5031 return functionCall(typedArrayFrom, TypedArrayConstructor, data); 5032 }(), dummy, TypedArrayConstructor); 5033 }); 5034 if (objectSetPrototypeOf) objectSetPrototypeOf(TypedArrayConstructor, TypedArray);
5035 forEach(getOwnPropertyNames(NativeTypedArrayConstructor), function (key) { 5036 if (!(key in TypedArrayConstructor)) { 5037 createNonEnumerableProperty(TypedArrayConstructor, key, NativeTypedArrayConstructor[key]); 5038 } 5039 }); 5040 TypedArrayConstructor.prototype = TypedArrayConstructorPrototype; 5041 } 5042 5043 if (TypedArrayConstructorPrototype.constructor !== TypedArrayConstructor) { 5044 createNonEnumerableProperty(TypedArrayConstructorPrototype, 'constructor', TypedArrayConstructor); 5045 } 5046 5047 createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_CONSTRUCTOR, TypedArrayConstructor); 5048 5049 if (TYPED_ARRAY_TAG) { 5050 createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_TAG, CONSTRUCTOR_NAME); 5051 } 5052 5053 exported[CONSTRUCTOR_NAME] = TypedArrayConstructor; 5054 _export({ 5055 global: true, 5056 forced: TypedArrayConstructor != NativeTypedArrayConstructor, 5057 sham: !NATIVE_ARRAY_BUFFER_VIEWS 5058 }, exported); 5059 5060 if (!(BYTES_PER_ELEMENT in TypedArrayConstructor)) { 5061 createNonEnumerableProperty(TypedArrayConstructor, BYTES_PER_ELEMENT, BYTES); 5062 } 5063 5064 if (!(BYTES_PER_ELEMENT in TypedArrayConstructorPrototype)) { 5065 createNonEnumerableProperty(TypedArrayConstructorPrototype, BYTES_PER_ELEMENT, BYTES); 5066 } 5067 5068 setSpecies(CONSTRUCTOR_NAME); 5069 }; 5070 } else module.exports = function () { 5071 /* empty */ 5072 }; 5073 }); 5074 5075 // `Float32Array` constructor 5076 // https://tc39.es/ecma262/#sec-typedarray-objects 5077 5078 5079 typedArrayConstructor('Float32', function (init) { 5080 return function Float32Array(data, byteOffset, length) { 5081 return init(this, data, byteOffset, length); 5082 }; 5083 }); 5084 5085 // `Float64Array` constructor 5086 // https://tc39.es/ecma262/#sec-typedarray-objects 5087 5088 5089 typedArrayConstructor('Float64', function (init) { 5090 return function Float64Array(data, byteOffset, length) { 5091 return init(this, data, byteOffset, length); 5092 }; 5093 }); 5094 5095 // `Int8Array` constructor 5096 // https://tc39.es/ecma262/#sec-typedarray-objects 5097 5098 5099 typedArrayConstructor('Int8', function (init) { 5100 return function Int8Array(data, byteOffset, length) { 5101 return init(this, data, byteOffset, length); 5102 }; 5103 }); 5104 5105 // `Int16Array` constructor 5106 // https://tc39.es/ecma262/#sec-typedarray-objects 5107 5108 5109 typedArrayConstructor('Int16', function (init) { 5110 return function Int16Array(data, byteOffset, length) { 5111 return init(this, data, byteOffset, length); 5112 }; 5113 }); 5114 5115 // `Int32Array` constructor 5116 // https://tc39.es/ecma262/#sec-typedarray-objects 5117 5118 5119 typedArrayConstructor('Int32', function (init) { 5120 return function Int32Array(data, byteOffset, length) { 5121 return init(this, data, byteOffset, length); 5122 }; 5123 }); 5124 5125 // `Uint8Array` constructor 5126 // https://tc39.es/ecma262/#sec-typedarray-objects 5127 5128 5129 typedArrayConstructor('Uint8', function (init) { 5130 return function Uint8Array(data, byteOffset, length) { 5131 return init(this, data, byteOffset, length); 5132 }; 5133 }); 5134 5135 // `Uint8ClampedArray` constructor 5136 // https://tc39.es/ecma262/#sec-typedarray-objects 5137 5138 5139 typedArrayConstructor('Uint8', function (init) { 5140 return function Uint8ClampedArray(data, byteOffset, length) { 5141 return init(this, data, byteOffset, length); 5142 }; 5143 }, true); 5144 5145 // `Uint16Array` constructor 5146 // https://tc39.es/ecma262/#sec-typedarray-objects 5147 5148 5149 typedArrayConstructor('Uint16', function (init) { 5150 return function Uint16Array(data, byteOffset, length) { 5151 return init(this, data, byteOffset, length); 5152 }; 5153 }); 5154 5155 // `Uint32Array` constructor 5156 // https://tc39.es/ecma262/#sec-typedarray-objects 5157 5158 5159 typedArrayConstructor('Uint32', function (init) { 5160 return function Uint32Array(data, byteOffset, length) { 5161 return init(this, data, byteOffset, length); 5162 }; 5163 }); 5164 5165 var aTypedArray$1 = arrayBufferViewCore.aTypedArray; 5166 var exportTypedArrayMethod$1 = arrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.at` method 5167 // https://github.com/tc39/proposal-relative-indexing-method 5168 5169 exportTypedArrayMethod$1('at', function at(index) { 5170 var O = aTypedArray$1(this); 5171 var len = lengthOfArrayLike(O); 5172 var relativeIndex = toIntegerOrInfinity(index); 5173 var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; 5174 return k < 0 || k >= len ? undefined : O[k]; 5175 }); 5176 5177 var exportTypedArrayStaticMethod$1 = arrayBufferViewCore.exportTypedArrayStaticMethod; 5178 5179 // `%TypedArray%.from` method 5180 // https://tc39.es/ecma262/#sec-%typedarray%.from 5181 5182 5183 exportTypedArrayStaticMethod$1('from', typedArrayFrom, typedArrayConstructorsRequireWrappers); 5184 5185 var aTypedArrayConstructor$2 = arrayBufferViewCore.aTypedArrayConstructor; 5186 var exportTypedArrayStaticMethod$2 = arrayBufferViewCore.exportTypedArrayStaticMethod; // `%TypedArray%.of` method 5187 // https://tc39.es/ecma262/#sec-%typedarray%.of 5188 5189 exportTypedArrayStaticMethod$2('of', function of() 5190 /* ...items */ 5191 { 5192 var index = 0; 5193 var length = arguments.length; 5194 var result = new (aTypedArrayConstructor$2(this))(length); 5195 5196 while (length > index) result[index] = arguments[index++]; 5197 5198 return result; 5199 }, typedArrayConstructorsRequireWrappers); 5200 5201 var floor$4 = Math.floor; 5202 5203 var mergeSort = function (array, comparefn) { 5204 var length = array.length; 5205 var middle = floor$4(length / 2); 5206 return length < 8 ? insertionSort(array, comparefn) : merge(array, mergeSort(arraySliceSimple(array, 0, middle), comparefn), mergeSort(arraySliceSimple(array, middle), comparefn), comparefn); 5207 }; 5208 5209 var insertionSort = function (array, comparefn) { 5210 var length = array.length; 5211 var i = 1; 5212 var element, j; 5213 5214 while (i < length) { 5215 j = i; 5216 element = array[i]; 5217 5218 while (j && comparefn(array[j - 1], element) > 0) { 5219 array[j] = array[--j]; 5220 } 5221 5222 if (j !== i++) array[j] = element; 5223 } 5224 5225 return array; 5226 }; 5227 5228 var merge = function (array, left, right, comparefn) { 5229 var llength = left.length; 5230 var rlength = right.length; 5231 var lindex = 0; 5232 var rindex = 0; 5233 5234 while (lindex < llength || rindex < rlength) { 5235 array[lindex + rindex] = lindex < llength && rindex < rlength ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++] : lindex < llength ? left[lindex++] : right[rindex++]; 5236 } 5237 5238 return array; 5239 }; 5240 5241 var arraySort = mergeSort; 5242 5243 var firefox = engineUserAgent.match(/firefox\/(\d+)/i); 5244 var engineFfVersion = !!firefox && +firefox[1]; 5245 5246 var engineIsIeOrEdge = /MSIE|Trident/.test(engineUserAgent); 5247
vendor: 4,612 bytes, lines 5248-5392
5248 var webkit = engineUserAgent.match(/AppleWebKit\/(\d+)\./); 5249 var engineWebkitVersion = !!webkit && +webkit[1]; 5250 5251 var Array$5 = global_1.Array; 5252 var aTypedArray$2 = arrayBufferViewCore.aTypedArray; 5253 var exportTypedArrayMethod$2 = arrayBufferViewCore.exportTypedArrayMethod; 5254 var Uint16Array = global_1.Uint16Array; 5255 var un$Sort = Uint16Array && functionUncurryThis(Uint16Array.prototype.sort); // WebKit 5256 5257 var ACCEPT_INCORRECT_ARGUMENTS = !!un$Sort && !(fails(function () { 5258 un$Sort(new Uint16Array(2), null); 5259 }) && fails(function () { 5260 un$Sort(new Uint16Array(2), {}); 5261 })); 5262 var STABLE_SORT = !!un$Sort && !fails(function () { 5263 // feature detection can be too slow, so check engines versions 5264 if (engineV8Version) return engineV8Version < 74; 5265 if (engineFfVersion) return engineFfVersion < 67; 5266 if (engineIsIeOrEdge) return true; 5267 if (engineWebkitVersion) return engineWebkitVersion < 602; 5268 var array = new Uint16Array(516); 5269 var expected = Array$5(516); 5270 var index, mod; 5271 5272 for (index = 0; index < 516; index++) { 5273 mod = index % 4; 5274 array[index] = 515 - index; 5275 expected[index] = index - 2 * mod + 3; 5276 } 5277 5278 un$Sort(array, function (a, b) { 5279 return (a / 4 | 0) - (b / 4 | 0); 5280 }); 5281 5282 for (index = 0; index < 516; index++) { 5283 if (array[index] !== expected[index]) return true; 5284 } 5285 }); 5286 5287 var getSortCompare = function (comparefn) { 5288 return function (x, y) { 5289 if (comparefn !== undefined) return +comparefn(x, y) || 0; // eslint-disable-next-line no-self-compare -- NaN check 5290 5291 if (y !== y) return -1; // eslint-disable-next-line no-self-compare -- NaN check 5292 5293 if (x !== x) return 1; 5294 if (x === 0 && y === 0) return 1 / x > 0 && 1 / y < 0 ? 1 : -1; 5295 return x > y; 5296 }; 5297 }; // `%TypedArray%.prototype.sort` method 5298 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.sort 5299 5300 5301 exportTypedArrayMethod$2('sort', function sort(comparefn) { 5302 if (comparefn !== undefined) aCallable(comparefn); 5303 if (STABLE_SORT) return un$Sort(this, comparefn); 5304 return arraySort(aTypedArray$2(this), getSortCompare(comparefn)); 5305 }, !STABLE_SORT || ACCEPT_INCORRECT_ARGUMENTS); 5306 5307 // iterable DOM collections 5308 // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods 5309 var domIterables = { 5310 CSSRuleList: 0, 5311 CSSStyleDeclaration: 0, 5312 CSSValueList: 0, 5313 ClientRectList: 0, 5314 DOMRectList: 0, 5315 DOMStringList: 0, 5316 DOMTokenList: 1, 5317 DataTransferItemList: 0, 5318 FileList: 0, 5319 HTMLAllCollection: 0, 5320 HTMLCollection: 0, 5321 HTMLFormElement: 0, 5322 HTMLSelectElement: 0, 5323 MediaList: 0, 5324 MimeTypeArray: 0, 5325 NamedNodeMap: 0, 5326 NodeList: 1, 5327 PaintRequestList: 0, 5328 Plugin: 0, 5329 PluginArray: 0, 5330 SVGLengthList: 0, 5331 SVGNumberList: 0, 5332 SVGPathSegList: 0, 5333 SVGPointList: 0, 5334 SVGStringList: 0, 5335 SVGTransformList: 0, 5336 SourceBufferList: 0, 5337 StyleSheetList: 0, 5338 TextTrackCueList: 0, 5339 TextTrackList: 0, 5340 TouchList: 0 5341 }; 5342 5343 // in old WebKit versions, `element.classList` is not an instance of global `DOMTokenList` 5344 5345 5346 var classList = documentCreateElement('span').classList; 5347 var DOMTokenListPrototype = classList && classList.constructor && classList.constructor.prototype; 5348 var domTokenListPrototype = DOMTokenListPrototype === Object.prototype ? undefined : DOMTokenListPrototype; 5349 5350 var PROPER_FUNCTION_NAME$1 = functionName.PROPER; 5351 var CONFIGURABLE_FUNCTION_NAME$1 = functionName.CONFIGURABLE; 5352 var IteratorPrototype$2 = iteratorsCore.IteratorPrototype; 5353 var BUGGY_SAFARI_ITERATORS$1 = iteratorsCore.BUGGY_SAFARI_ITERATORS; 5354 var ITERATOR$4 = wellKnownSymbol('iterator'); 5355 var KEYS = 'keys'; 5356 var VALUES = 'values'; 5357 var ENTRIES = 'entries'; 5358 5359 var returnThis$1 = function () { 5360 return this; 5361 }; 5362 5363 var defineIterator = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) { 5364 createIteratorConstructor(IteratorConstructor, NAME, next); 5365 5366 var getIterationMethod = function (KIND) { 5367 if (KIND === DEFAULT && defaultIterator) return defaultIterator; 5368 if (!BUGGY_SAFARI_ITERATORS$1 && KIND in IterablePrototype) return IterablePrototype[KIND]; 5369 5370 switch (KIND) { 5371 case KEYS: 5372 return function keys() { 5373 return new IteratorConstructor(this, KIND); 5374 }; 5375 5376 case VALUES: 5377 return function values() { 5378 return new IteratorConstructor(this, KIND); 5379 }; 5380 5381 case ENTRIES: 5382 return function entries() { 5383 return new IteratorConstructor(this, KIND); 5384 }; 5385 } 5386 5387 return function () { 5388 return new IteratorConstructor(this); 5389 }; 5390 }; 5391 5392 var TO_STRING_TAG = NAME + ' Iterator';
5393 var INCORRECT_VALUES_NAME = false; 5394 var IterablePrototype = Iterable.prototype; 5395 var nativeIterator = IterablePrototype[ITERATOR$4] || IterablePrototype['@@iterator'] || DEFAULT && IterablePrototype[DEFAULT]; 5396 var defaultIterator = !BUGGY_SAFARI_ITERATORS$1 && nativeIterator || getIterationMethod(DEFAULT); 5397 var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator; 5398 var CurrentIteratorPrototype, methods, KEY; // fix native 5399 5400 if (anyNativeIterator) { 5401 CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable())); 5402 5403 if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) { 5404 if (objectGetPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype$2) { 5405 if (objectSetPrototypeOf) { 5406 objectSetPrototypeOf(CurrentIteratorPrototype, IteratorPrototype$2); 5407 } else if (!isCallable(CurrentIteratorPrototype[ITERATOR$4])) { 5408 redefine(CurrentIteratorPrototype, ITERATOR$4, returnThis$1); 5409 } 5410 } // Set @@toStringTag to native iterators 5411 5412 5413 setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true); 5414 } 5415 } // fix Array.prototype.{ values, @@iterator }.name in V8 / FF 5416 5417 5418 if (PROPER_FUNCTION_NAME$1 && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) { 5419 if (CONFIGURABLE_FUNCTION_NAME$1) { 5420 createNonEnumerableProperty(IterablePrototype, 'name', VALUES); 5421 } else { 5422 INCORRECT_VALUES_NAME = true; 5423 5424 defaultIterator = function values() { 5425 return functionCall(nativeIterator, this); 5426 }; 5427 } 5428 } // export additional methods 5429 5430 5431 if (DEFAULT) { 5432 methods = { 5433 values: getIterationMethod(VALUES), 5434 keys: IS_SET ? defaultIterator : getIterationMethod(KEYS), 5435 entries: getIterationMethod(ENTRIES) 5436 }; 5437 if (FORCED) for (KEY in methods) { 5438 if (BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) { 5439 redefine(IterablePrototype, KEY, methods[KEY]); 5440 } 5441 } else _export({ 5442 target: NAME, 5443 proto: true, 5444 forced: BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME 5445 }, methods); 5446 } // define iterator 5447 5448 5449 if (IterablePrototype[ITERATOR$4] !== defaultIterator) { 5450 redefine(IterablePrototype, ITERATOR$4, defaultIterator, { 5451 name: DEFAULT 5452 }); 5453 } 5454 5455 iterators[NAME] = defaultIterator; 5456 return methods; 5457 }; 5458 5459 var ARRAY_ITERATOR = 'Array Iterator'; 5460 var setInternalState$2 = internalState.set; 5461 var getInternalState$3 = internalState.getterFor(ARRAY_ITERATOR); // `Array.prototype.entries` method 5462 // https://tc39.es/ecma262/#sec-array.prototype.entries 5463 // `Array.prototype.keys` method 5464 // https://tc39.es/ecma262/#sec-array.prototype.keys 5465 // `Array.prototype.values` method 5466 // https://tc39.es/ecma262/#sec-array.prototype.values 5467 // `Array.prototype[@@iterator]` method 5468 // https://tc39.es/ecma262/#sec-array.prototype-@@iterator 5469 // `CreateArrayIterator` internal method 5470 // https://tc39.es/ecma262/#sec-createarrayiterator 5471 5472 var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind) { 5473 setInternalState$2(this, { 5474 type: ARRAY_ITERATOR, 5475 target: toIndexedObject(iterated), 5476 // target 5477 index: 0, 5478 // next index 5479 kind: kind // kind 5480 5481 }); // `%ArrayIteratorPrototype%.next` method 5482 // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next 5483 }, function () { 5484 var state = getInternalState$3(this); 5485 var target = state.target; 5486 var kind = state.kind; 5487 var index = state.index++; 5488 5489 if (!target || index >= target.length) { 5490 state.target = undefined; 5491 return { 5492 value: undefined, 5493 done: true 5494 }; 5495 } 5496 5497 if (kind == 'keys') return { 5498 value: index, 5499 done: false 5500 }; 5501 if (kind == 'values') return { 5502 value: target[index], 5503 done: false 5504 }; 5505 return { 5506 value: [index, target[index]], 5507 done: false 5508 }; 5509 }, 'values'); // argumentsList[@@iterator] is %ArrayProto_values% 5510 // https://tc39.es/ecma262/#sec-createunmappedargumentsobject 5511 // https://tc39.es/ecma262/#sec-createmappedargumentsobject 5512 5513 iterators.Arguments = iterators.Array; // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables 5514 5515 addToUnscopables('keys'); 5516 addToUnscopables('values'); 5517 addToUnscopables('entries'); 5518 5519 var ITERATOR$5 = wellKnownSymbol('iterator'); 5520 var TO_STRING_TAG$5 = wellKnownSymbol('toStringTag'); 5521 var ArrayValues = es_array_iterator.values; 5522 5523 var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) { 5524 if (CollectionPrototype) { 5525 // some Chrome versions have non-configurable methods on DOMTokenList 5526 if (CollectionPrototype[ITERATOR$5] !== ArrayValues) try { 5527 createNonEnumerableProperty(CollectionPrototype, ITERATOR$5, ArrayValues); 5528 } catch (error) { 5529 CollectionPrototype[ITERATOR$5] = ArrayValues; 5530 } 5531 5532 if (!CollectionPrototype[TO_STRING_TAG$5]) { 5533 createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG$5, COLLECTION_NAME); 5534 } 5535 5536 if (domIterables[COLLECTION_NAME]) for (var METHOD_NAME in es_array_iterator) { 5537 // some Chrome versions have non-configurable methods on DOMTokenList 5538 if (CollectionPrototype[METHOD_NAME] !== es_array_iterator[METHOD_NAME]) try { 5539 createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, es_array_iterator[METHOD_NAME]); 5540 } catch (error) { 5541 CollectionPrototype[METHOD_NAME] = es_array_iterator[METHOD_NAME]; 5542 } 5543 } 5544 } 5545 }; 5546 5547 for (var COLLECTION_NAME in domIterables) { 5548 handlePrototype(global_1[COLLECTION_NAME] && global_1[COLLECTION_NAME].prototype, COLLECTION_NAME); 5549 } 5550 5551 handlePrototype(domTokenListPrototype, 'DOMTokenList'); 5552 5553 var FunctionPrototype$2 = Function.prototype; 5554 var apply = FunctionPrototype$2.apply; 5555 var bind$2 = FunctionPrototype$2.bind; 5556 var call$2 = FunctionPrototype$2.call; // eslint-disable-next-line es/no-reflect -- safe 5557 5558 var functionApply = typeof Reflect == 'object' && Reflect.apply || (bind$2 ? call$2.bind(apply) : function () { 5559 return call$2.apply(apply, arguments); 5560 }); 5561 5562 var arraySlice = functionUncurryThis([].slice); 5563 5564 var engineIsIos = /(?:ipad|iphone|ipod).*applewebkit/i.test(engineUserAgent); 5565 5566 var engineIsNode = classofRaw(global_1.process) == 'process'; 5567 5568 var set$2 = global_1.setImmediate; 5569 var clear = global_1.clearImmediate; 5570 var process$1 = global_1.process; 5571 var Dispatch = global_1.Dispatch; 5572 var Function$1 = global_1.Function; 5573 var MessageChannel = global_1.MessageChannel; 5574 var String$5 = global_1.String; 5575 var counter = 0; 5576 var queue = {}; 5577 var ONREADYSTATECHANGE = 'onreadystatechange'; 5578 var location, defer, channel, port; 5579 5580 try { 5581 // Deno throws a ReferenceError on `location` access without `--location` flag 5582 location = global_1.location; 5583 } catch (error) { 5584 /* empty */ 5585 } 5586 5587 var run = function (id) { 5588 if (hasOwnProperty_1(queue, id)) { 5589 var fn = queue[id]; 5590 delete queue[id]; 5591 fn(); 5592 } 5593 }; 5594 5595 var runner = function (id) { 5596 return function () { 5597 run(id); 5598 }; 5599 }; 5600 5601 var listener = function (event) { 5602 run(event.data); 5603 }; 5604 5605 var post = function (id) { 5606 // old engines have not location.origin 5607 global_1.postMessage(String$5(id), location.protocol + '//' + location.host); 5608 }; // Node.js 0.9+ & IE10+ has setImmediate, otherwise: 5609 5610 5611 if (!set$2 || !clear) { 5612 set$2 = function setImmediate(fn) { 5613 var args = arraySlice(arguments, 1); 5614 5615 queue[++counter] = function () { 5616 functionApply(isCallable(fn) ? fn : Function$1(fn), undefined, args); 5617 }; 5618 5619 defer(counter); 5620 return counter; 5621 }; 5622 5623 clear = function clearImmediate(id) { 5624 delete queue[id]; 5625 }; // Node.js 0.8- 5626 5627 5628 if (engineIsNode) { 5629 defer = function (id) { 5630 process$1.nextTick(runner(id)); 5631 }; // Sphere (JS game engine) Dispatch API 5632 5633 } else if (Dispatch && Dispatch.now) { 5634 defer = function (id) { 5635 Dispatch.now(runner(id)); 5636 }; // Browsers with MessageChannel, includes WebWorkers 5637 // except iOS - https://github.com/zloirock/core-js/issues/624 5638 5639 } else if (MessageChannel && !engineIsIos) { 5640 channel = new MessageChannel(); 5641 port = channel.port2; 5642 channel.port1.onmessage = listener; 5643 defer = functionBindContext(port.postMessage, port); // Browsers with postMessage, skip WebWorkers 5644 // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' 5645 } else if (global_1.addEventListener && isCallable(global_1.postMessage) && !global_1.importScripts && location && location.protocol !== 'file:' && !fails(post)) { 5646 defer = post; 5647 global_1.addEventListener('message', listener, false); // IE8- 5648 } else if (ONREADYSTATECHANGE in documentCreateElement('script')) { 5649 defer = function (id) { 5650 html.appendChild(documentCreateElement('script'))[ONREADYSTATECHANGE] = function () { 5651 html.removeChild(this); 5652 run(id); 5653 }; 5654 }; // Rest old browsers 5655 5656 } else { 5657 defer = function (id) { 5658 setTimeout(runner(id), 0); 5659 }; 5660 } 5661 } 5662 5663 var task = { 5664 set: set$2, 5665 clear: clear 5666 }; 5667 5668 var FORCED = !global_1.setImmediate || !global_1.clearImmediate; // http://w3c.github.io/setImmediate/ 5669 5670 _export({ 5671 global: true, 5672 bind: true, 5673 enumerable: true, 5674 forced: FORCED 5675 }, { 5676 // `setImmediate` method 5677 // http://w3c.github.io/setImmediate/#si-setImmediate 5678 setImmediate: task.set, 5679 // `clearImmediate` method 5680 // http://w3c.github.io/setImmediate/#si-clearImmediate 5681 clearImmediate: task.clear 5682 }); 5683 5684 var engineIsIosPebble = /ipad|iphone|ipod/i.test(engineUserAgent) && global_1.Pebble !== undefined; 5685 5686 var engineIsWebosWebkit = /web0s(?!.*chrome)/i.test(engineUserAgent); 5687 5688 var getOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f; 5689 5690 var macrotask = task.set; 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 var MutationObserver = global_1.MutationObserver || global_1.WebKitMutationObserver; 5701 var document$2 = global_1.document; 5702 var process$2 = global_1.process; 5703 var Promise = global_1.Promise; // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask` 5704 5705 var queueMicrotaskDescriptor = getOwnPropertyDescriptor$2(global_1, 'queueMicrotask'); 5706 var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value; 5707 var flush, head, last, notify, toggle, node, promise, then; // modern engines have queueMicrotask method 5708 5709 if (!queueMicrotask) { 5710 flush = function () { 5711 var parent, fn; 5712 if (engineIsNode && (parent = process$2.domain)) parent.exit(); 5713 5714 while (head) { 5715 fn = head.fn; 5716 head = head.next; 5717 5718 try { 5719 fn(); 5720 } catch (error) { 5721 if (head) notify();else last = undefined; 5722 throw error; 5723 } 5724 } 5725 5726 last = undefined; 5727 if (parent) parent.enter(); 5728 }; // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339 5729 // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898 5730 5731 5732 if (!engineIsIos && !engineIsNode && !engineIsWebosWebkit && MutationObserver && document$2) { 5733 toggle = true; 5734 node = document$2.createTextNode(''); 5735 new MutationObserver(flush).observe(node, { 5736 characterData: true 5737 }); 5738 5739 notify = function () { 5740 node.data = toggle = !toggle; 5741 }; // environments with maybe non-completely correct, but existent Promise 5742 5743 } else if (!engineIsIosPebble && Promise && Promise.resolve) { 5744 // Promise.resolve without an argument throws an error in LG WebOS 2 5745 promise = Promise.resolve(undefined); // workaround of WebKit ~ iOS Safari 10.1 bug 5746 5747 promise.constructor = Promise; 5748 then = functionBindContext(promise.then, promise); 5749 5750 notify = function () { 5751 then(flush); 5752 }; // Node.js without promises 5753 5754 } else if (engineIsNode) { 5755 notify = function () { 5756 process$2.nextTick(flush); 5757 }; // for other environments - macrotask based on: 5758 // - setImmediate 5759 // - MessageChannel 5760 // - window.postMessag 5761 // - onreadystatechange 5762 // - setTimeout 5763 5764 } else { 5765 // strange IE + webpack dev server bug - use .bind(global) 5766 macrotask = functionBindContext(macrotask, global_1); 5767 5768 notify = function () { 5769 macrotask(flush); 5770 }; 5771 } 5772 } 5773 5774 var microtask = queueMicrotask || function (fn) { 5775 var task$$1 = { 5776 fn: fn, 5777 next: undefined 5778 }; 5779 if (last) last.next = task$$1; 5780 5781 if (!head) { 5782 head = task$$1; 5783 notify(); 5784 } 5785 5786 last = task$$1; 5787 }; 5788 5789 var process$3 = global_1.process; // `queueMicrotask` method 5790 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask 5791 5792 _export({ 5793 global: true, 5794 enumerable: true, 5795 noTargetGet: true 5796 }, { 5797 queueMicrotask: function queueMicrotask(fn) { 5798 var domain = engineIsNode && process$3.domain; 5799 microtask(domain ? domain.bind(fn) : fn); 5800 } 5801 }); 5802 5803 // File generated automatically. Don't modify it. 5804 5805}((this.window = this.window || {}))); 5806 5807 5808 5809if (window._main_polyfill_core) 5810{ 5811 console.warn('main.polyfill.core is loaded more than once on this page'); 5812} 5813 5814window._main_polyfill_core = true; 5815 5816 5817(function (exports) { 5818 'use strict'; 5819 5820 var bxTmp = window.BX; 5821 window.BX = function (node) { 5822 if (window.BX.type.isNotEmptyString(node)) { 5823 return document.getElementById(node); 5824 } 5825 if (window.BX.type.isDomNode(node)) { 5826 return node; 5827 } 5828 if (window.BX.type.isFunction(node)) { 5829 return window.BX.ready(node); 5830 } 5831 return null; 5832 }; 5833 if (bxTmp) {
5834 Object.keys(bxTmp).forEach(key => { 5835 window.BX[key] = bxTmp[key]; 5836 }); 5837 } 5838 exports = window.BX; 5839 5840 /** 5841 * Gets object.toString result 5842 * @param value 5843 * @return {string} 5844 */ 5845 function getTag(value) { 5846 return Object.prototype.toString.call(value); 5847 } 5848 5849 const objectCtorString = Function.prototype.toString.call(Object); 5850 5851 /** 5852 * @memberOf BX 5853 */ 5854 let Type = /*#__PURE__*/function () { 5855 function Type() { 5856 babelHelpers.classCallCheck(this, Type); 5857 } 5858 babelHelpers.createClass(Type, null, [{ 5859 key: "isString", 5860 /** 5861 * Checks that value is string 5862 * @param value 5863 * @return {boolean} 5864 */ 5865 value: function isString(value) { 5866 return typeof value === 'string'; 5867 } 5868 /** 5869 * Returns true if a value is not empty string 5870 * @param value 5871 * @returns {boolean} 5872 */ 5873 }, { 5874 key: "isStringFilled", 5875 value: function isStringFilled(value) { 5876 return this.isString(value) && value !== ''; 5877 } 5878 /** 5879 * Checks that value is function 5880 * @param value 5881 * @return {boolean} 5882 */ 5883 }, { 5884 key: "isFunction", 5885 value: function isFunction(value) { 5886 return typeof value === 'function'; 5887 } 5888 /** 5889 * Checks that value is object 5890 * @param value 5891 * @return {boolean} 5892 */ 5893 }, { 5894 key: "isObject", 5895 value: function isObject(value) { 5896 return !!value && (typeof value === 'object' || typeof value === 'function'); 5897 } 5898 /** 5899 * Checks that value is object like 5900 * @param value 5901 * @return {boolean} 5902 */ 5903 }, { 5904 key: "isObjectLike", 5905 value: function isObjectLike(value) { 5906 return !!value && typeof value === 'object'; 5907 } 5908 /** 5909 * Checks that value is plain object 5910 * @param value 5911 * @return {boolean} 5912 */ 5913 }, { 5914 key: "isPlainObject", 5915 value: function isPlainObject(value) { 5916 if (!Type.isObjectLike(value) || getTag(value) !== '[object Object]') { 5917 return false; 5918 } 5919 const proto = Object.getPrototypeOf(value); 5920 if (proto === null) { 5921 return true; 5922 } 5923 const ctor = proto.hasOwnProperty('constructor') && proto.constructor; 5924 return typeof ctor === 'function' && Function.prototype.toString.call(ctor) === objectCtorString; 5925 } 5926 /** 5927 * Checks that value is boolean 5928 * @param value 5929 * @return {boolean} 5930 */ 5931 }, { 5932 key: "isBoolean", 5933 value: function isBoolean(value) { 5934 return value === true || value === false; 5935 } 5936 /** 5937 * Checks that value is number 5938 * @param value 5939 * @return {boolean} 5940 */ 5941 }, { 5942 key: "isNumber", 5943 value: function isNumber(value) { 5944 return !Number.isNaN(value) && typeof value === 'number'; 5945 } 5946 /** 5947 * Checks that value is integer 5948 * @param value 5949 * @return {boolean} 5950 */ 5951 }, { 5952 key: "isInteger", 5953 value: function isInteger(value) { 5954 return Type.isNumber(value) && value % 1 === 0; 5955 } 5956 /** 5957 * Checks that value is float 5958 * @param value 5959 * @return {boolean} 5960 */ 5961 }, { 5962 key: "isFloat", 5963 value: function isFloat(value) { 5964 return Type.isNumber(value) && !Type.isInteger(value); 5965 } 5966 /** 5967 * Checks that value is nil 5968 * @param value 5969 * @return {boolean} 5970 */ 5971 }, { 5972 key: "isNil", 5973 value: function isNil(value) { 5974 return value === null || value === undefined; 5975 } 5976 /** 5977 * Checks that value is array 5978 * @param value 5979 * @return {boolean} 5980 */ 5981 }, { 5982 key: "isArray", 5983 value: function isArray(value) { 5984 return !Type.isNil(value) && Array.isArray(value); 5985 } 5986 /** 5987 * Returns true if a value is an array and it has at least one element 5988 * @param value 5989 * @returns {boolean} 5990 */ 5991 }, { 5992 key: "isArrayFilled", 5993 value: function isArrayFilled(value) { 5994 return this.isArray(value) && value.length > 0; 5995 } 5996 /** 5997 * Checks that value is array like 5998 * @param value 5999 * @return {boolean} 6000 */ 6001 }, { 6002 key: "isArrayLike", 6003 value: function isArrayLike(value) { 6004 return !Type.isNil(value) && !Type.isFunction(value) && value.length > -1 && value.length <= Number.MAX_SAFE_INTEGER; 6005 } 6006 /** 6007 * Checks that value is Date 6008 * @param value 6009 * @return {boolean} 6010 */ 6011 }, { 6012 key: "isDate", 6013 value: function isDate(value) { 6014 return Type.isObjectLike(value) && getTag(value) === '[object Date]'; 6015 } 6016 /** 6017 * Checks that is DOM node 6018 * @param value 6019 * @return {boolean} 6020 */ 6021 }, { 6022 key: "isDomNode", 6023 value: function isDomNode(value) { 6024 return Type.isObjectLike(value) && !Type.isPlainObject(value) && 'nodeType' in value; 6025 } 6026 /** 6027 * Checks that value is element node 6028 * @param value 6029 * @return {boolean} 6030 */ 6031 }, { 6032 key: "isElementNode", 6033 value: function isElementNode(value) { 6034 return Type.isDomNode(value) && value.nodeType === Node.ELEMENT_NODE; 6035 } 6036 /** 6037 * Checks that value is text node 6038 * @param value 6039 * @return {boolean} 6040 */ 6041 }, { 6042 key: "isTextNode", 6043 value: function isTextNode(value) { 6044 return Type.isDomNode(value) && value.nodeType === Node.TEXT_NODE; 6045 } 6046 /** 6047 * Checks that value is Map 6048 * @param value 6049 * @return {boolean} 6050 */ 6051 }, { 6052 key: "isMap", 6053 value: function isMap(value) { 6054 return Type.isObjectLike(value) && getTag(value) === '[object Map]'; 6055 } 6056 /** 6057 * Checks that value is Set 6058 * @param value 6059 * @return {boolean} 6060 */ 6061 }, { 6062 key: "isSet", 6063 value: function isSet(value) { 6064 return Type.isObjectLike(value) && getTag(value) === '[object Set]'; 6065 } 6066 /** 6067 * Checks that value is WeakMap 6068 * @param value 6069 * @return {boolean} 6070 */ 6071 }, { 6072 key: "isWeakMap", 6073 value: function isWeakMap(value) { 6074 return Type.isObjectLike(value) && getTag(value) === '[object WeakMap]'; 6075 } 6076 /** 6077 * Checks that value is WeakSet 6078 * @param value 6079 * @return {boolean} 6080 */ 6081 }, { 6082 key: "isWeakSet", 6083 value: function isWeakSet(value) { 6084 return Type.isObjectLike(value) && getTag(value) === '[object WeakSet]'; 6085 } 6086 /** 6087 * Checks that value is prototype 6088 * @param value 6089 * @return {boolean} 6090 */ 6091 }, { 6092 key: "isPrototype", 6093 value: function isPrototype(value) { 6094 return (typeof (value && value.constructor) === 'function' && value.constructor.prototype || Object.prototype) === value; 6095 } 6096 /** 6097 * Checks that value is regexp 6098 * @param value 6099 * @return {boolean} 6100 */ 6101 }, { 6102 key: "isRegExp", 6103 value: function isRegExp(value) { 6104 return Type.isObjectLike(value) && getTag(value) === '[object RegExp]'; 6105 } 6106 /** 6107 * Checks that value is null 6108 * @param value 6109 * @return {boolean} 6110 */ 6111 }, { 6112 key: "isNull", 6113 value: function isNull(value) { 6114 return value === null; 6115 } 6116 /** 6117 * Checks that value is undefined 6118 * @param value 6119 * @return {boolean} 6120 */ 6121 }, { 6122 key: "isUndefined", 6123 value: function isUndefined(value) { 6124 return typeof value === 'undefined'; 6125 } 6126 /** 6127 * Checks that value is ArrayBuffer 6128 * @param value 6129 * @return {boolean} 6130 */ 6131 }, { 6132 key: "isArrayBuffer", 6133 value: function isArrayBuffer(value) { 6134 return Type.isObjectLike(value) && getTag(value) === '[object ArrayBuffer]'; 6135 } 6136 /** 6137 * Checks that value is typed array 6138 * @param value 6139 * @return {boolean} 6140 */ 6141 }, { 6142 key: "isTypedArray", 6143 value: function isTypedArray(value) { 6144 const regExpTypedTag = /^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)]$/; 6145 return Type.isObjectLike(value) && regExpTypedTag.test(getTag(value)); 6146 } 6147 /** 6148 * Checks that value is Blob 6149 * @param value 6150 * @return {boolean} 6151 */ 6152 }, { 6153 key: "isBlob", 6154 value: function isBlob(value) { 6155 return Type.isObjectLike(value) && Type.isNumber(value.size) && Type.isString(value.type) && Type.isFunction(value.slice); 6156 } 6157 /** 6158 * Checks that value is File 6159 * @param value 6160 * @return {boolean} 6161 */ 6162 }, { 6163 key: "isFile", 6164 value: function isFile(value) { 6165 return Type.isBlob(value) && Type.isString(value.name) && (Type.isNumber(value.lastModified) || Type.isObjectLike(value.lastModifiedDate)); 6166 } 6167 /** 6168 * Checks that value is FormData 6169 * @param value 6170 * @return {boolean} 6171 */ 6172 }, { 6173 key: "isFormData", 6174 value: function isFormData(value) { 6175 return value instanceof FormData; 6176 } 6177 }]); 6178 return Type; 6179 }(); 6180 6181 /** 6182 * @memberOf BX 6183 */ 6184 let Reflection = /*#__PURE__*/function () { 6185 function Reflection() { 6186 babelHelpers.classCallCheck(this, Reflection); 6187 } 6188 babelHelpers.createClass(Reflection, null, [{ 6189 key: "getClass", 6190 /** 6191 * Gets link to function by function name 6192 * @param className 6193 * @return {?Function} 6194 */ 6195 value: function getClass(className) { 6196 if (Type.isString(className) && !!className) { 6197 let classFn = null; 6198 let currentNamespace = window; 6199 const namespaces = className.split('.'); 6200 for (let i = 0; i < namespaces.length; i += 1) { 6201 const namespace = namespaces[i]; 6202 if (!currentNamespace[namespace]) { 6203 return null; 6204 } 6205 currentNamespace = currentNamespace[namespace]; 6206 classFn = currentNamespace; 6207 } 6208 return classFn; 6209 } 6210 if (Type.isFunction(className)) { 6211 return className; 6212 } 6213 return null; 6214 } 6215 /** 6216 * Creates a namespace or returns a link to a previously created one 6217 * @param {String} namespaceName 6218 * @return {Object<string, any> | Function | null} 6219 */ 6220 }, { 6221 key: "namespace", 6222 value: function namespace(namespaceName) { 6223 let parts = namespaceName.split('.'); 6224 let parent = window.BX; 6225 if (parts[0] === 'BX') { 6226 parts = parts.slice(1); 6227 } 6228 for (let i = 0; i < parts.length; i += 1) { 6229 if (Type.isUndefined(parent[parts[i]])) { 6230 parent[parts[i]] = {}; 6231 } 6232 parent = parent[parts[i]]; 6233 } 6234 return parent; 6235 } 6236 }]); 6237 return Reflection; 6238 }(); 6239 6240 const reEscape = /[&<>'"]/g; 6241 const reUnescape = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g; 6242 const escapeEntities = { 6243 '&': '&', 6244 '<': '<', 6245 '>': '>', 6246 "'": ''', 6247 '"': '"' 6248 }; 6249 const unescapeEntities = { 6250 '&': '&', 6251 '&': '&', 6252 '<': '<', 6253 '<': '<', 6254 '>': '>', 6255 '>': '>', 6256 ''': "'", 6257 ''': "'", 6258 '"': '"', 6259 '"': '"' 6260 }; 6261 6262 /** 6263 * @memberOf BX 6264 */ 6265 let Text = /*#__PURE__*/function () { 6266 function Text() { 6267 babelHelpers.classCallCheck(this, Text); 6268 } 6269 babelHelpers.createClass(Text, null, [{ 6270 key: "encode", 6271 /** 6272 * Encodes all unsafe entities 6273 * @param {string} value 6274 * @return {string} 6275 */ 6276 value: function encode(value) { 6277 if (Type.isString(value)) { 6278 return value.replace(reEscape, item => escapeEntities[item]); 6279 } 6280 return value; 6281 } 6282 /** 6283 * Decodes all encoded entities 6284 * @param {string} value 6285 * @return {string} 6286 */ 6287 }, { 6288 key: "decode", 6289 value: function decode(value) { 6290 if (Type.isString(value)) { 6291 return value.replace(reUnescape, item => unescapeEntities[item]); 6292 } 6293 return value; 6294 } 6295 }, { 6296 key: "getRandom", 6297 value: function getRandom(length = 8) { 6298 // eslint-disable-next-line 6299 return [...Array(length)].map(() => (~~(Math.random() * 36)).toString(36)).join(''); 6300 } 6301 }, { 6302 key: "toNumber", 6303 value: function toNumber(value) { 6304 const parsedValue = Number.parseFloat(value); 6305 if (Type.isNumber(parsedValue)) { 6306 return parsedValue; 6307 } 6308 return 0; 6309 } 6310 }, { 6311 key: "toInteger", 6312 value: function toInteger(value) { 6313 return Text.toNumber(Number.parseInt(value, 10)); 6314 } 6315 }, { 6316 key: "toBoolean", 6317 value: function toBoolean(value, trueValues = []) { 6318 const transformedValue = Type.isString(value) ? value.toLowerCase() : value; 6319 return ['true', 'y', '1', 1, true, ...trueValues].includes(transformedValue); 6320 } 6321 }, { 6322 key: "toCamelCase", 6323 value: function toCamelCase(str) { 6324 if (!Type.isStringFilled(str)) { 6325 return str; 6326 } 6327 const regex = /[-_\s]+(.)?/g; 6328 if (!regex.test(str)) { 6329 return str.match(/^[A-Z]+$/) ? str.toLowerCase() : str[0].toLowerCase() + str.slice(1); 6330 } 6331 str = str.toLowerCase(); 6332 str = str.replace(regex, function (match, letter) { 6333 return letter ? letter.toUpperCase() : ''; 6334 }); 6335 return str[0].toLowerCase() + str.substr(1); 6336 } 6337 }, { 6338 key: "toPascalCase", 6339 value: function toPascalCase(str) { 6340 if (!Type.isStringFilled(str)) { 6341 return str; 6342 } 6343 return this.capitalize(this.toCamelCase(str)); 6344 } 6345 }, { 6346 key: "toKebabCase", 6347 value: function toKebabCase(str) { 6348 if (!Type.isStringFilled(str)) { 6349 return str; 6350 } 6351 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); 6352 if (!matches) { 6353 return str; 6354 } 6355 return matches.map(x => x.toLowerCase()).join('-'); 6356 } 6357 }, { 6358 key: "capitalize", 6359 value: function capitalize(str) { 6360 if (!Type.isStringFilled(str)) { 6361 return str; 6362 } 6363 return str[0].toUpperCase() + str.substr(1); 6364 } 6365 }]); 6366 return Text; 6367 }(); 6368 6369 const aliases = { 6370 mousewheel: ['DOMMouseScroll'], 6371 bxchange: ['change', 'cut', 'paste', 'drop', 'keyup'], 6372 animationend: ['animationend', 'oAnimationEnd', 'webkitAnimationEnd', 'MSAnimationEnd'], 6373 transitionend: ['webkitTransitionEnd', 'otransitionend', 'oTransitionEnd', 'msTransitionEnd', 'transitionend'], 6374 fullscreenchange: ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange', 'MSFullscreenChange'], 6375 fullscreenerror: ['fullscreenerror', 'webkitfullscreenerror', 'mozfullscreenerror', 'MSFullscreenError'] 6376 }; 6377 6378 let Registry = /*#__PURE__*/function () { 6379 function Registry() { 6380 babelHelpers.classCallCheck(this, Registry); 6381 babelHelpers.defineProperty(this, "registry", new WeakMap()); 6382 } 6383 babelHelpers.createClass(Registry, [{ 6384 key: "set", 6385 value: function set(target, event, listener) { 6386 const events = this.get(target); 6387 if (!Type.isSet(events[event])) { 6388 events[event] = new Set(); 6389 } 6390 events[event].add(listener); 6391 this.registry.set(target, events); 6392 } 6393 }, { 6394 key: "get", 6395 value: function get(target) { 6396 return this.registry.get(target) || {}; 6397 } 6398 }, { 6399 key: "has", 6400 value: function has(target, event, listener) { 6401 if (event && listener) { 6402 return this.registry.has(target) && this.registry.get(target)[event].has(listener); 6403 } 6404 return this.registry.has(target); 6405 } 6406 }, { 6407 key: "delete", 6408 value: function _delete(target, event, listener) { 6409 if (!Type.isDomNode(target)) { 6410 return; 6411 } 6412 if (Type.isString(event) && Type.isFunction(listener)) { 6413 const events = this.registry.get(target); 6414 if (Type.isPlainObject(events) && Type.isSet(events[event])) { 6415 events[event].delete(listener); 6416 } 6417 return; 6418 } 6419 if (Type.isString(event)) { 6420 const events = this.registry.get(target); 6421 if (Type.isPlainObject(events) && Type.isSet(events[event])) { 6422 events[event] = new Set(); 6423 } 6424 return; 6425 } 6426 this.registry.delete(target); 6427 } 6428 }]); 6429 return Registry; 6430 }(); 6431 var registry = new Registry(); 6432 6433 function isOptionSupported(name) { 6434 let isSupported = false;
6435 try { 6436 const options = Object.defineProperty({}, name, { 6437 get() { 6438 isSupported = true; 6439 return undefined; 6440 } 6441 }); 6442 window.addEventListener('test', null, options); 6443 } 6444 // eslint-disable-next-line 6445 catch (err) {} 6446 return isSupported; 6447 } 6448 function fetchSupportedListenerOptions(options) { 6449 if (!Type.isPlainObject(options)) { 6450 return options; 6451 } 6452 return Object.keys(options).reduce((acc, name) => { 6453 if (isOptionSupported(name)) { 6454 acc[name] = options[name]; 6455 } 6456 return acc; 6457 }, {}); 6458 } 6459 6460 function bind(target, eventName, handler, options) { 6461 if (!Type.isObject(target) || !Type.isFunction(target.addEventListener)) { 6462 return; 6463 } 6464 const listenerOptions = fetchSupportedListenerOptions(options); 6465 if (eventName in aliases) { 6466 aliases[eventName].forEach(key => { 6467 target.addEventListener(key, handler, listenerOptions); 6468 registry.set(target, eventName, handler); 6469 }); 6470 return; 6471 } 6472 target.addEventListener(eventName, handler, listenerOptions); 6473 registry.set(target, eventName, handler); 6474 } 6475 6476 function unbind(target, eventName, handler, options) { 6477 if (!Type.isObject(target) || !Type.isFunction(target.removeEventListener)) { 6478 return; 6479 } 6480 const listenerOptions = fetchSupportedListenerOptions(options); 6481 if (eventName in aliases) { 6482 aliases[eventName].forEach(key => { 6483 target.removeEventListener(key, handler, listenerOptions); 6484 registry.delete(target, key, handler); 6485 }); 6486 return; 6487 } 6488 target.removeEventListener(eventName, handler, listenerOptions); 6489 registry.delete(target, eventName, handler); 6490 } 6491 6492 function unbindAll(target, eventName) { 6493 const events = registry.get(target); 6494 Object.keys(events).forEach(currentEvent => { 6495 events[currentEvent].forEach(handler => { 6496 if (!Type.isString(eventName) || eventName === currentEvent) { 6497 unbind(target, currentEvent, handler); 6498 } 6499 }); 6500 }); 6501 } 6502 6503 function bindOnce(target, eventName, handler, options) { 6504 const once = function once(...args) { 6505 unbind(target, eventName, once, options); 6506 handler(...args); 6507 }; 6508 bind(target, eventName, once, options); 6509 } 6510 6511 // eslint-disable-next-line 6512 let debugState = true; 6513 function enableDebug() { 6514 debugState = true; 6515 } 6516 function disableDebug() { 6517 debugState = false; 6518 } 6519 function isDebugEnabled() { 6520 return debugState; 6521 } 6522 function debug(...args) { 6523 if (isDebugEnabled() && Type.isObject(window.console)) { 6524 if (Type.isFunction(window.console.log)) { 6525 window.console.log('BX.debug: ', args.length > 0 ? args : args[0]); 6526 if (args[0] instanceof Error && args[0].stack) { 6527 window.console.log('BX.debug error stack trace', args[0].stack); 6528 } 6529 } 6530 if (Type.isFunction(window.console.trace)) { 6531 // eslint-disable-next-line 6532 console.trace(); 6533 } 6534 } 6535 } 6536 6537 var debugNs = /*#__PURE__*/Object.freeze({ 6538 get debugState () { return debugState; }, 6539 enableDebug: enableDebug, 6540 disableDebug: disableDebug, 6541 isDebugEnabled: isDebugEnabled, 6542 default: debug 6543 }); 6544 6545 function fetchExtensionSettings(html) { 6546 if (Type.isStringFilled(html)) { 6547 const scripts = html.match(/<script type="extension\/settings" \b[^>]*>([\s\S]*?)<\/script>/g); 6548 if (Type.isArrayFilled(scripts)) { 6549 return scripts.map(script => { 6550 const [, extension] = script.match(/data-extension="(.[a-z0-9_.-]+)"/); 6551 return { 6552 extension, 6553 script 6554 }; 6555 }); 6556 } 6557 } 6558 return []; 6559 } 6560 6561 let Extension = /*#__PURE__*/function () { 6562 function Extension(options) { 6563 babelHelpers.classCallCheck(this, Extension); 6564 this.config = options.config || {}; 6565 this.name = options.extension; 6566 this.state = 'scheduled'; 6567 6568 // eslint-disable-next-line 6569 const result = BX.processHTML(options.html || ''); 6570 this.inlineScripts = result.SCRIPT.reduce(inlineScripts, []); 6571 this.externalScripts = result.SCRIPT.reduce(externalScripts, []); 6572 this.externalStyles = result.STYLE.reduce(externalStyles, []); 6573 this.settingsScripts = fetchExtensionSettings(result.HTML); 6574 } 6575 babelHelpers.createClass(Extension, [{ 6576 key: "load", 6577 value: function load() { 6578 if (this.state === 'error') { 6579 this.loadPromise = this.loadPromise || Promise.resolve(this); 6580 console.warn('Extension', this.name, 'not found'); 6581 } 6582 if (!this.loadPromise && this.state) { 6583 this.state = 'load';
6584 this.settingsScripts.forEach(entry => { 6585 const isLoaded = !!document.querySelector(`script[data-extension="${entry.extension}"]`); 6586 if (!isLoaded) { 6587 document.body.insertAdjacentHTML('beforeend', entry.script); 6588 } 6589 }); 6590 this.inlineScripts.forEach(BX.evalGlobal); 6591 this.loadPromise = Promise.all([loadAll(this.externalScripts), loadAll(this.externalStyles)]).then(() => { 6592 this.state = 'loaded'; 6593 if (Type.isPlainObject(this.config) && this.config.namespace) { 6594 return Reflection.getClass(this.config.namespace); 6595 } 6596 return window; 6597 }); 6598 } 6599 return this.loadPromise; 6600 } 6601 }]); 6602 return Extension; 6603 }(); 6604 6605 const initialized = {}; 6606 const ajaxController = 'main.bitrix.main.controller.loadext.getextensions'; 6607 6608 function makeIterable(value) { 6609 return Type.isArray(value) ? value : [value]; 6610 } 6611 function isInitialized(extension) { 6612 return extension in initialized; 6613 } 6614 function getInitialized(extension) { 6615 return initialized[extension]; 6616 } 6617 function isAllInitialized(extensions) { 6618 return extensions.every(isInitialized); 6619 } 6620 function loadExtensions(extensions) { 6621 return Promise.all(extensions.map(item => item.load())); 6622 } 6623 function mergeExports(exports) { 6624 return exports.reduce((acc, currentExports) => { 6625 if (Type.isObject(currentExports)) { 6626 return { 6627 ...currentExports 6628 }; 6629 } 6630 return currentExports; 6631 }, {}); 6632 } 6633 function inlineScripts(acc, item) { 6634 if (item.isInternal) { 6635 acc.push(item.JS); 6636 } 6637 return acc; 6638 } 6639 function externalScripts(acc, item) { 6640 if (!item.isInternal) { 6641 acc.push(item.JS); 6642 } 6643 return acc; 6644 } 6645 function externalStyles(acc, item) { 6646 if (Type.isString(item) && item !== '') { 6647 acc.push(item); 6648 } 6649 return acc; 6650 } 6651 function request(options) { 6652 return new Promise(resolve => { 6653 // eslint-disable-next-line 6654 BX.ajax.runAction(ajaxController, { 6655 data: options 6656 }).then(resolve); 6657 }); 6658 } 6659 function prepareExtensions(response) { 6660 if (response.status !== 'success') { 6661 response.errors.map(console.warn); 6662 return []; 6663 } 6664 return response.data.map(item => { 6665 const initializedExtension = getInitialized(item.extension); 6666 if (initializedExtension) { 6667 return initializedExtension; 6668 } 6669 initialized[item.extension] = new Extension(item); 6670 return initialized[item.extension]; 6671 }); 6672 } 6673 function loadAll(items) { 6674 const itemsList = makeIterable(items); 6675 if (!itemsList.length) { 6676 return Promise.resolve(); 6677 } 6678 return new Promise(resolve => { 6679 // eslint-disable-next-line 6680 BX.load(itemsList, resolve); 6681 }); 6682 } 6683 6684 /** 6685 * Loads extensions asynchronously 6686 * @param {string|Array<string>} extension 6687 * @return {Promise<Array<Extension>>} 6688 */ 6689 function loadExtension(extension) { 6690 const extensions = makeIterable(extension); 6691 const isAllInitialized$$1 = isAllInitialized(extensions); 6692 if (isAllInitialized$$1) { 6693 const initializedExtensions = extensions.map(getInitialized); 6694 return loadExtensions(initializedExtensions).then(mergeExports); 6695 } 6696 return request({ 6697 extension: extensions 6698 }).then(prepareExtensions).then(loadExtensions).then(mergeExports); 6699 } 6700 6701 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]']; 6702 function isCloneable(value) { 6703 const isCloneableValue = Type.isObjectLike(value) && cloneableTags.includes(getTag(value)); 6704 return isCloneableValue || Type.isDomNode(value); 6705 } 6706 function internalClone(value, map) { 6707 if (map.has(value)) { 6708 return map.get(value); 6709 } 6710 if (isCloneable(value)) { 6711 if (Type.isArray(value)) { 6712 const cloned = Array.from(value); 6713 map.set(value, cloned); 6714 value.forEach((item, index) => { 6715 cloned[index] = internalClone(item, map); 6716 }); 6717 return map.get(value); 6718 } 6719 if (Type.isDomNode(value)) { 6720 return value.cloneNode(true); 6721 } 6722 if (Type.isMap(value)) { 6723 const result = new Map(); 6724 map.set(value, result); 6725 value.forEach((item, key) => { 6726 result.set(internalClone(key, map), internalClone(item, map)); 6727 }); 6728 return result; 6729 } 6730 if (Type.isSet(value)) { 6731 const result = new Set(); 6732 map.set(value, result); 6733 value.forEach(item => { 6734 result.add(internalClone(item, map)); 6735 }); 6736 return result; 6737 } 6738 if (Type.isDate(value)) { 6739 return new Date(value); 6740 } 6741 if (Type.isRegExp(value)) { 6742 const regExpFlags = /\w*$/; 6743 const flags = regExpFlags.exec(value); 6744 let result = new RegExp(value.source); 6745 if (flags && Type.isArray(flags)) { 6746 result = new RegExp(value.source, flags[0]); 6747 } 6748 result.lastIndex = value.lastIndex; 6749 return result; 6750 } 6751 const proto = Object.getPrototypeOf(value); 6752 const result = Object.assign(Object.create(proto), value); 6753 map.set(value, result); 6754 Object.keys(value).forEach(key => { 6755 result[key] = internalClone(value[key], map); 6756 }); 6757 return result; 6758 } 6759 return value; 6760 } 6761 6762 /** 6763 * Clones any cloneable object 6764 * @param value 6765 * @return {*} 6766 */ 6767 function clone(value) { 6768 return internalClone(value, new WeakMap()); 6769 } 6770 6771 function merge(current, target) { 6772 return Object.entries(target).reduce((acc, [key, value]) => { 6773 if (!Type.isDomNode(acc[key]) && Type.isObjectLike(acc[key]) && Type.isObjectLike(value)) { 6774 acc[key] = merge(acc[key], value); 6775 return acc; 6776 } 6777 acc[key] = value; 6778 return acc; 6779 }, current); 6780 } 6781 6782 function createComparator(fields, orders = []) { 6783 return (a, b) => { 6784 const field = fields[0]; 6785 const order = orders[0] || 'asc'; 6786 if (Type.isUndefined(field)) { 6787 return 0; 6788 } 6789 let valueA = a[field]; 6790 let valueB = b[field]; 6791 if (Type.isString(valueA) && Type.isString(valueB)) { 6792 valueA = valueA.toLowerCase(); 6793 valueB = valueB.toLowerCase(); 6794 } 6795 if (valueA < valueB) { 6796 return order === 'asc' ? -1 : 1; 6797 } 6798 if (valueA > valueB) { 6799 return order === 'asc' ? 1 : -1; 6800 } 6801 return createComparator(fields.slice(1), orders.slice(1))(a, b); 6802 }; 6803 } 6804 6805 /** 6806 * @memberOf BX 6807 */ 6808 let Runtime = /*#__PURE__*/function () { 6809 function Runtime() { 6810 babelHelpers.classCallCheck(this, Runtime); 6811 } 6812 babelHelpers.createClass(Runtime, null, [{ 6813 key: "debounce", 6814 value: function debounce(func, wait = 0, context = null) { 6815 let timeoutId; 6816 return function debounced(...args) { 6817 if (Type.isNumber(timeoutId)) { 6818 clearTimeout(timeoutId); 6819 } 6820 timeoutId = setTimeout(() => { 6821 func.apply(context || this, args); 6822 }, wait); 6823 }; 6824 } 6825 }, { 6826 key: "throttle", 6827 value: function throttle(func, wait = 0, context = null) { 6828 let timer = 0; 6829 let invoke; 6830 return function wrapper(...args) { 6831 invoke = true; 6832 if (!timer) { 6833 const q = function q() { 6834 if (invoke) { 6835 func.apply(context || this, args); 6836 invoke = false;
6837 timer = setTimeout(q, wait); 6838 } else { 6839 timer = null; 6840 } 6841 }; 6842 q(); 6843 } 6844 }; 6845 } 6846 }, { 6847 key: "html", 6848 value: function html(node, _html, params = {}) { 6849 if (Type.isNil(_html) && Type.isDomNode(node)) { 6850 return node.innerHTML; 6851 } 6852 6853 // eslint-disable-next-line 6854 const parsedHtml = BX.processHTML(_html); 6855 const externalCss = parsedHtml.STYLE.reduce(externalStyles, []); 6856 const externalJs = parsedHtml.SCRIPT.reduce(externalScripts, []); 6857 const inlineJs = parsedHtml.SCRIPT.reduce(inlineScripts, []); 6858 if (Type.isDomNode(node)) { 6859 if (params.htmlFirst || !externalJs.length && !externalCss.length) { 6860 if (params.useAdjacentHTML) { 6861 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 6862 } else { 6863 node.innerHTML = parsedHtml.HTML; 6864 } 6865 } 6866 } 6867 return Promise.all([loadAll(externalJs), loadAll(externalCss)]).then(() => { 6868 if (Type.isDomNode(node) && (externalJs.length > 0 || externalCss.length > 0)) { 6869 if (params.useAdjacentHTML) { 6870 node.insertAdjacentHTML('beforeend', parsedHtml.HTML); 6871 } else { 6872 node.innerHTML = parsedHtml.HTML; 6873 } 6874 } 6875 6876 // eslint-disable-next-line 6877 inlineJs.forEach(script => BX.evalGlobal(script)); 6878 if (Type.isFunction(params.callback)) { 6879 params.callback(); 6880 } 6881 }); 6882 } 6883 /** 6884 * Merges objects or arrays 6885 * @param targets 6886 * @return {any} 6887 */ 6888 }, { 6889 key: "merge", 6890 value: function merge$$1(...targets) { 6891 if (Type.isArray(targets[0])) { 6892 targets.unshift([]); 6893 } else if (Type.isObject(targets[0])) { 6894 targets.unshift({}); 6895 } 6896 return targets.reduce((acc, item) => { 6897 return merge(acc, item); 6898 }, targets[0]); 6899 } 6900 }, { 6901 key: "orderBy", 6902 value: function orderBy(collection, fields = [], orders = []) { 6903 const comparator = createComparator(fields, orders); 6904 return Object.values(collection).sort(comparator); 6905 } 6906 }, { 6907 key: "destroy", 6908 value: function destroy(target, errorMessage = 'Object is destroyed') { 6909 if (Type.isObject(target)) { 6910 const onPropertyAccess = () => { 6911 throw new Error(errorMessage); 6912 }; 6913 const ownProperties = Object.keys(target); 6914 const prototypeProperties = (() => { 6915 const targetPrototype = Object.getPrototypeOf(target); 6916 if (Type.isObject(targetPrototype)) { 6917 return Object.getOwnPropertyNames(targetPrototype); 6918 } 6919 return []; 6920 })(); 6921 const uniquePropertiesList = [...new Set([...ownProperties, ...prototypeProperties])]; 6922 uniquePropertiesList.filter(name => { 6923 const descriptor = Object.getOwnPropertyDescriptor(target, name); 6924 return !/__(.+)__/.test(name) && (!Type.isObject(descriptor) || descriptor.configurable === true); 6925 }
6925).forEach(name => { 6926 Object.defineProperty(target, name, { 6927 get: onPropertyAccess, 6928 set: onPropertyAccess, 6929 configurable: false 6930 }); 6931 }); 6932 Object.setPrototypeOf(target, null); 6933 } 6934 } 6935 }]); 6936 return Runtime; 6937 }(); 6938 babelHelpers.defineProperty(Runtime, "debug", debug); 6939 babelHelpers.defineProperty(Runtime, "loadExtension", loadExtension); 6940 babelHelpers.defineProperty(Runtime, "clone", clone); 6941 6942 const _isError = Symbol.for('BX.BaseError.isError'); 6943 6944 /** 6945 * @memberOf BX 6946 */ 6947 let BaseError = /*#__PURE__*/function () { 6948 function BaseError(message, code, customData) { 6949 babelHelpers.classCallCheck(this, BaseError); 6950 this[_isError] = true; 6951 this.message = ''; 6952 this.code = null; 6953 this.customData = null; 6954 this.setMessage(message); 6955 this.setCode(code); 6956 this.setCustomData(customData); 6957 } 6958 6959 /** 6960 * Returns a brief description of the error 6961 * @returns {string} 6962 */ 6963 babelHelpers.createClass(BaseError, [{ 6964 key: "getMessage", 6965 value: function getMessage() { 6966 return this.message; 6967 } 6968 /** 6969 * Sets a message of the error 6970 * @param {string} message 6971 * @returns {this} 6972 */ 6973 }, { 6974 key: "setMessage", 6975 value: function setMessage(message) { 6976 if (Type.isString(message)) { 6977 this.message = message; 6978 } 6979 return this; 6980 } 6981 /** 6982 * Returns a code of the error 6983 * @returns {?string} 6984 */ 6985 }, { 6986 key: "getCode", 6987 value: function getCode() { 6988 return this.code; 6989 } 6990 /** 6991 * Sets a code of the error 6992 * @param {string} code 6993 * @returns {this} 6994 */ 6995 }, { 6996 key: "setCode", 6997 value: function setCode(code) { 6998 if (Type.isStringFilled(code) || code === null) { 6999 this.code = code; 7000 } 7001 return this; 7002 } 7003 /** 7004 * Returns custom data of the error 7005 * @returns {null|*} 7006 */ 7007 }, { 7008 key: "getCustomData", 7009 value: function getCustomData() { 7010 return this.customData; 7011 } 7012 /** 7013 * Sets custom data of the error 7014 * @returns {this} 7015 */ 7016 }, { 7017 key: "setCustomData", 7018 value: function setCustomData(customData) { 7019 if (!Type.isUndefined(customData)) { 7020 this.customData = customData; 7021 } 7022 return this; 7023 } 7024 }, { 7025 key: "toString", 7026 value: function toString() { 7027 const code = this.getCode(); 7028 const message = this.getMessage(); 7029 if (!Type.isStringFilled(code) && !Type.isStringFilled(message)) { 7030 return ''; 7031 } else if (!Type.isStringFilled(code)) { 7032 return `Error: ${message}`; 7033 } else if (!Type.isStringFilled(message)) { 7034 return code; 7035 } else { 7036 return `${code}: ${message}`; 7037 } 7038 } 7039 /** 7040 * Returns true if the object is an instance of BaseError 7041 * @param error 7042 * @returns {boolean} 7043 */ 7044 }], [{ 7045 key: "isError", 7046 value: function isError(error) { 7047 return Type.isObject(error) && error[_isError] === true; 7048 } 7049 }]); 7050 return BaseError; 7051 }(); 7052 7053 /** 7054 * Implements base event object interface 7055 */ 7056 let BaseEvent = /*#__PURE__*/function () { 7057 function BaseEvent(options = { 7058 data: {} 7059 }) { 7060 babelHelpers.classCallCheck(this, BaseEvent); 7061 this.type = ''; 7062 this.data = null; 7063 this.target = null; 7064 this.compatData = null; 7065 this.defaultPrevented = false; 7066 this.immediatePropagationStopped = false; 7067 this.errors = []; 7068 this.setData(options.data); 7069 this.setCompatData(options.compatData); 7070 } 7071 babelHelpers.createClass(BaseEvent, [{ 7072 key: "getType", 7073 /** 7074 * Returns the name of the event 7075 * @returns {string} 7076 */ 7077 value: function getType() { 7078 return this.type; 7079 } 7080 /** 7081 * 7082 * @param {string} type 7083 */ 7084 }, { 7085 key: "setType", 7086 value: function setType(type) { 7087 if (Type.isStringFilled(type)) { 7088 this.type = type; 7089 } 7090 return this; 7091 } 7092 /** 7093 * Returns an event data 7094 */ 7095 }, { 7096 key: "getData", 7097 value: function getData() { 7098 return this.data; 7099 } 7100 /** 7101 * Sets an event data 7102 * @param data 7103 */ 7104 }, { 7105 key: "setData", 7106 value: function setData(data) { 7107 if (!Type.isUndefined(data)) { 7108 this.data = data; 7109 } 7110 return this; 7111 } 7112 /** 7113 * Returns arguments for BX.addCustomEvent handlers (deprecated). 7114 * @returns {array | null} 7115 */ 7116 }, { 7117 key: "getCompatData", 7118 value: function getCompatData() { 7119 return this.compatData; 7120 } 7121 /** 7122 * Sets arguments for BX.addCustomEvent handlers (deprecated) 7123 * @param data 7124 */ 7125 }, { 7126 key: "setCompatData", 7127 value: function setCompatData(data) { 7128 if (Type.isArrayLike(data)) { 7129 this.compatData = data; 7130 } 7131 return this; 7132 } 7133 /** 7134 * Sets a event target 7135 * @param target 7136 */ 7137 }, { 7138 key: "setTarget", 7139 value: function setTarget(target) { 7140 this.target = target; 7141 return this; 7142 } 7143 /** 7144 * Returns a event target 7145 */ 7146 }, { 7147 key: "getTarget", 7148 value: function getTarget() { 7149 return this.target; 7150 } 7151 /** 7152 * Returns an array of event errors 7153 * @returns {[]} 7154 */ 7155 }, { 7156 key: "getErrors", 7157 value: function getErrors() { 7158 return this.errors; 7159 } 7160 /** 7161 * Adds an error of the event. 7162 * Event listeners can prevent emitter's default action and set the reason of this behavior. 7163 * @param error 7164 */ 7165 }, { 7166 key: "setError", 7167 value: function setError(error) { 7168 if (BaseError.isError(error)) { 7169 this.errors.push(error); 7170 } 7171 } 7172 /** 7173 * Prevents default action 7174 */ 7175 }, { 7176 key: "preventDefault", 7177 value: function preventDefault() { 7178 this.defaultPrevented = true; 7179 } 7180 /** 7181 * Checks that is default action prevented 7182 * @return {boolean} 7183 */ 7184 }, { 7185 key: "isDefaultPrevented", 7186 value: function isDefaultPrevented() { 7187 return this.defaultPrevented; 7188 } 7189 /** 7190 * Stops event immediate propagation 7191 */ 7192 }, { 7193 key: "stopImmediatePropagation", 7194 value: function stopImmediatePropagation() { 7195 this.immediatePropagationStopped = true; 7196 } 7197 /** 7198 * Checks that is immediate propagation stopped 7199 * @return {boolean} 7200 */ 7201 }, { 7202 key: "isImmediatePropagationStopped", 7203 value: function isImmediatePropagationStopped() { 7204 return this.immediatePropagationStopped; 7205 } 7206 }], [{ 7207 key: "create", 7208 value: function create(options) { 7209 return new this(options); 7210 } 7211 }]); 7212 return BaseEvent; 7213 }(); 7214 7215 let EventStore = /*#__PURE__*/function () { 7216 function EventStore(options = {}) { 7217 babelHelpers.classCallCheck(this, EventStore); 7218 this.defaultMaxListeners = Type.isNumber(options.defaultMaxListeners) ? options.defaultMaxListeners : 10; 7219 this.eventStore = new WeakMap(); 7220 } 7221 babelHelpers.createClass(EventStore, [{ 7222 key: "add", 7223 value: function add(target, options = {}) { 7224 const record = this.getRecordScheme(); 7225 if (Type.isNumber(options.maxListeners)) { 7226 record.maxListeners = options.maxListeners; 7227 } 7228 this.eventStore.set(target, record); 7229 return record; 7230 } 7231 }, { 7232 key: "get", 7233 value: function get(target) { 7234 return this.eventStore.get(target); 7235 } 7236 }, { 7237 key: "getOrAdd", 7238 value: function getOrAdd(target, options = {}) { 7239 return this.get(target) || this.add(target, options); 7240 } 7241 }, { 7242 key: "delete", 7243 value: function _delete(context) { 7244 this.eventStore.delete(context); 7245 } 7246 }, { 7247 key: "getRecordScheme", 7248 value: function getRecordScheme() { 7249 return { 7250 eventsMap: new Map(), 7251 onceMap: new Map(), 7252 maxListeners: this.getDefaultMaxListeners(), 7253 eventsMaxListeners: new Map() 7254 }; 7255 } 7256 }, { 7257 key: "getDefaultMaxListeners", 7258 value: function getDefaultMaxListeners() { 7259 return this.defaultMaxListeners; 7260 } 7261 }]); 7262 return EventStore; 7263 }(); 7264 7265 let WarningStore = /*#__PURE__*/function () {
7266 function WarningStore() { 7267 babelHelpers.classCallCheck(this, WarningStore); 7268 this.warnings = new Map(); 7269 this.printDelayed = Runtime.debounce(this.print.bind(this), 500); 7270 } 7271 babelHelpers.createClass(WarningStore, [{ 7272 key: "add", 7273 value: function add(target, eventName, listeners) { 7274 let contextWarnings = this.warnings.get(target); 7275 if (!contextWarnings) { 7276 contextWarnings = Object.create(null); 7277 this.warnings.set(target, contextWarnings); 7278 } 7279 if (!contextWarnings[eventName]) { 7280 contextWarnings[eventName] = {}; 7281 } 7282 contextWarnings[eventName].size = listeners.size; 7283 if (!Type.isArray(contextWarnings[eventName].errors)) { 7284 contextWarnings[eventName].errors = []; 7285 } 7286 contextWarnings[eventName].errors.push(new Error()); 7287 } 7288 }, { 7289 key: "print", 7290 value: function print() { 7291 this.warnings.forEach(warnings => { 7292 for (let eventName in warnings) { 7293 console.groupCollapsed('Possible BX.Event.EventEmitter memory leak detected. ' + warnings[eventName].size + ' "' + eventName + '" listeners added. ' + 'Use emitter.setMaxListeners() to increase limit.'); 7294 console.dir(warnings[eventName].errors); 7295 console.groupEnd(); 7296 } 7297 }); 7298 this.clear(); 7299 } 7300 }, { 7301 key: "clear", 7302 value: function clear() { 7303 this.warnings.clear(); 7304 } 7305 }, { 7306 key: "printDelayed", 7307 value: function printDelayed() {} 7308 }]); 7309 return WarningStore; 7310 }(); 7311 7312 const eventStore = new EventStore({ 7313 defaultMaxListeners: 10 7314 }); 7315 const warningStore = new WarningStore(); 7316 const aliasStore = new Map(); 7317 const globalTarget = { 7318 GLOBAL_TARGET: 'GLOBAL_TARGET' // this key only for debugging purposes 7319 }; 7320 7321 eventStore.add(globalTarget, { 7322 maxListeners: 25 7323 }); 7324 const isEmitterProperty = Symbol.for('BX.Event.EventEmitter.isEmitter'); 7325 const namespaceProperty = Symbol('namespaceProperty'); 7326 const targetProperty = Symbol('targetProperty'); 7327 let EventEmitter = /*#__PURE__*/function () { 7328 /** @private */ 7329 7330 function EventEmitter(...args) { 7331 babelHelpers.classCallCheck(this, EventEmitter); 7332 this[targetProperty] = null; 7333 this[namespaceProperty] = null; 7334 this[isEmitterProperty] = true; 7335 let target = this; 7336 if (Object.getPrototypeOf(this) === EventEmitter.prototype && args.length > 0) 7337 //new EventEmitter(obj) case 7338 { 7339 if (!Type.isObject(args[0])) { 7340 throw new TypeError(`The "target" argument must be an object.`); 7341 } 7342 target = args[0]; 7343 this.setEventNamespace(args[1]); 7344 } 7345 this[targetProperty] = target; 7346 } 7347 7348 /** 7349 * Makes a target observable 7350 * @param {object} target 7351 * @param {string} namespace 7352 */ 7353 babelHelpers.createClass(EventEmitter, [{ 7354 key: "setEventNamespace", 7355 value: function setEventNamespace(namespace) { 7356 if (Type.isStringFilled(namespace)) { 7357 this[namespaceProperty] = namespace; 7358 } 7359 } 7360 }, { 7361 key: "getEventNamespace", 7362 value: function getEventNamespace() { 7363 return this[namespaceProperty]; 7364 } 7365 /** 7366 * Subscribes listener on specified global event 7367 * @param {object} target 7368 * @param {string} eventName 7369 * @param {Function<BaseEvent>} listener 7370 * @param {object} options 7371 */ 7372 }, { 7373 key: "subscribe", 7374 /** 7375 * Subscribes a listener on a specified event 7376 * @param {string} eventName 7377 * @param {Function<BaseEvent>} listener 7378 * @return {this} 7379 */ 7380 value: function subscribe(eventName, listener) { 7381 EventEmitter.subscribe(this, eventName, listener); 7382 return this; 7383 } 7384 /** 7385 * 7386 * @param {object} options 7387 * @param {object} [aliases] 7388 * @param {boolean} [compatMode=false] 7389 */ 7390 }, { 7391 key: "subscribeFromOptions", 7392 value: function subscribeFromOptions(options, aliases, compatMode) { 7393 if (!Type.isPlainObject(options)) { 7394 return; 7395 } 7396 aliases = Type.isPlainObject(aliases) ? EventEmitter.normalizeAliases(aliases) : {};
7397 Object.keys(options).forEach(eventName => { 7398 const listener = EventEmitter.normalizeListener(options[eventName]); 7399 eventName = EventEmitter.normalizeEventName(eventName); 7400 if (aliases[eventName]) { 7401 const { 7402 eventName: actualName 7403 } = aliases[eventName]; 7404 EventEmitter.subscribe(this, actualName, listener, { 7405 compatMode: compatMode !== false 7406 }); 7407 } else { 7408 EventEmitter.subscribe(this, eventName, listener, { 7409 compatMode: compatMode === true 7410 }); 7411 } 7412 }); 7413 } 7414 /** 7415 * Subscribes a listener that is called at 7416 * most once for a specified event. 7417 * @param {object} target 7418 * @param {string} eventName 7419 * @param {Function<BaseEvent>} listener 7420 */ 7421 }, { 7422 key: "subscribeOnce", 7423 /** 7424 * Subscribes a listener that is called at most once for a specified event. 7425 * @param {string} eventName 7426 * @param {Function<BaseEvent>} listener 7427 * @return {this} 7428 */ 7429 value: function subscribeOnce(eventName, listener) { 7430 EventEmitter.subscribeOnce(this, eventName, listener); 7431 return this; 7432 } 7433 /** 7434 * Unsubscribes an event listener 7435 * @param {object} target 7436 * @param {string} eventName 7437 * @param {Function<BaseEvent>} listener 7438 * @param options 7439 */ 7440 }, { 7441 key: "unsubscribe", 7442 /** 7443 * Unsubscribes an event listener 7444 * @param {string} eventName 7445 * @param {Function<BaseEvent>} listener 7446 * @return {this} 7447 */ 7448 value: function unsubscribe(eventName, listener) { 7449 EventEmitter.unsubscribe(this, eventName, listener); 7450 return this; 7451 } 7452 /** 7453 * Unsubscribes all event listeners 7454 * @param {object} target 7455 * @param {string} eventName 7456 * @param options 7457 */ 7458 }, { 7459 key: "unsubscribeAll", 7460 /** 7461 * Unsubscribes all event listeners 7462 * @param {string} [eventName] 7463 */ 7464 value: function unsubscribeAll(eventName) { 7465 EventEmitter.unsubscribeAll(this, eventName); 7466 } 7467 /** 7468 * 7469 * @param {object} target 7470 * @param {string} eventName 7471 * @param {BaseEvent | any} event 7472 * @param {object} options 7473 * @returns {Array} 7474 */ 7475 }, { 7476 key: "emit", 7477 /** 7478 * Emits specified event with specified event object 7479 * @param {string} eventName 7480 * @param {BaseEvent | any} event 7481 * @return {this} 7482 */ 7483 value: function emit(eventName, event) { 7484 if (this.getEventNamespace() === null) { 7485 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7486 } 7487 EventEmitter.emit(this, eventName, event); 7488 return this; 7489 } 7490 /** 7491 * Emits global event and returns a promise that is resolved when 7492 * all promise returned from event handlers are resolved, 7493 * or rejected when at least one of the returned promise is rejected. 7494 * Importantly. You can return any value from synchronous handlers, not just promise 7495 * @param {object} target 7496 * @param {string} eventName 7497 * @param {BaseEvent | any} event 7498 * @return {Promise<Array>} 7499 */ 7500 }, { 7501 key: "emitAsync", 7502 /** 7503 * Emits event and returns a promise that is resolved when 7504 * all promise returned from event handlers are resolved, 7505 * or rejected when at least one of the returned promise is rejected. 7506 * Importantly. You can return any value from synchronous handlers, not just promise 7507 * @param {string} eventName 7508 * @param {BaseEvent|any} event 7509 * @return {Promise<Array>} 7510 */ 7511 value: function emitAsync(eventName, event) { 7512 if (this.getEventNamespace() === null) { 7513 console.warn('The instance of BX.Event.EventEmitter is supposed to have an event namespace. ' + 'Use emitter.setEventNamespace() to make events more unique.'); 7514 } 7515 return EventEmitter.emitAsync(this, eventName, event); 7516 } 7517 /** 7518 * @private 7519 * @param {object} target 7520 * @param {string} eventName 7521 * @param {BaseEvent|any} event 7522 * @returns {BaseEvent} 7523 */ 7524 }, { 7525 key: "setMaxListeners", 7526 /** 7527 * Sets max events listeners count 7528 * this.setMaxListeners(10) - sets the default value for all events
7529 * this.setMaxListeners("onClose", 10) sets the value for onClose event 7530 * @return {this} 7531 * @param args 7532 */ 7533 value: function setMaxListeners(...args) { 7534 EventEmitter.setMaxListeners(this, ...args); 7535 return this; 7536 } 7537 /** 7538 * Returns max event listeners count 7539 * @param {object} target 7540 * @param {string} [eventName] 7541 * @returns {number} 7542 */ 7543 }, { 7544 key: "getMaxListeners", 7545 /** 7546 * Returns max event listeners count 7547 * @param {string} [eventName] 7548 * @returns {number} 7549 */ 7550 value: function getMaxListeners(eventName) { 7551 return EventEmitter.getMaxListeners(this, eventName); 7552 } 7553 /** 7554 * Adds or subtracts max listeners count 7555 * Event.EventEmitter.addMaxListeners() - adds one max listener for all events of global target 7556 * Event.EventEmitter.addMaxListeners(3) - adds three max listeners for all events of global target 7557 * Event.EventEmitter.addMaxListeners(-1) - subtracts one max listener for all events of global target 7558 * Event.EventEmitter.addMaxListeners('onClose') - adds one max listener for onClose event of global target 7559 * Event.EventEmitter.addMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 7560 * Event.EventEmitter.addMaxListeners('onClose', -1) - subtracts one max listener for onClose event of global target 7561 * 7562 * Event.EventEmitter.addMaxListeners(obj) - adds one max listener for all events of 'obj' target 7563 * Event.EventEmitter.addMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 7564 * Event.EventEmitter.addMaxListeners(obj, -1) - subtracts one max listener for all events of 'obj' target 7565 * Event.EventEmitter.addMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 7566 * Event.EventEmitter.addMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 7567 * Event.EventEmitter.addMaxListeners(obj, 'onClose', -1) - subtracts one max listener for onClose event of 'obj' target 7568 * @param args 7569 * @returns {number} 7570 */ 7571 }, { 7572 key: "incrementMaxListeners", 7573 /** 7574 * Increases max listeners count 7575 * this.incrementMaxListeners() - adds one max listener for all events 7576 * this.incrementMaxListeners(3) - adds three max listeners for all events 7577 * this.incrementMaxListeners('onClose') - adds one max listener for onClose event 7578 * this.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event 7579 */ 7580 value: function incrementMaxListeners(...args) { 7581 return EventEmitter.incrementMaxListeners(this, ...args); 7582 } 7583 /** 7584 * Decreases max listeners count 7585 * 7586 * Event.EventEmitter.decrementMaxListeners() - subtracts one max listener for all events of global target 7587 * Event.EventEmitter.decrementMaxListeners(3) - subtracts three max listeners for all events of global target 7588 * Event.EventEmitter.decrementMaxListeners('onClose') - subtracts one max listener for onClose event of global target 7589 * Event.EventEmitter.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event of global target 7590 * 7591 * Event.EventEmitter.decrementMaxListeners(obj) - subtracts one max listener for all events of 'obj' target 7592 * Event.EventEmitter.decrementMaxListeners(obj, 3) - subtracts three max listeners for all events of 'obj' target 7593 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose') - subtracts one max listener for onClose event of 'obj' target 7594 * Event.EventEmitter.decrementMaxListeners(obj, 'onClose', 2) - subtracts two max listeners for onClose event of 'obj' target 7595 */ 7596 }, { 7597 key: "decrementMaxListeners", 7598 /** 7599 * Increases max listeners count 7600 * this.decrementMaxListeners() - subtracts one max listener for all events 7601 * this.decrementMaxListeners(3) - subtracts three max listeners for all events 7602 * this.decrementMaxListeners('onClose') - subtracts one max listener for onClose event 7603 * this.decrementMaxListeners('onClose', 2) - subtracts two max listeners for onClose event 7604 */ 7605 value: function decrementMaxListeners(...args) { 7606 return EventEmitter.decrementMaxListeners(this, ...args); 7607 } 7608 /** 7609 * @private 7610 * @param {Array} args 7611 * @returns Array 7612 */ 7613 }, { 7614 key: "getListeners", 7615 /** 7616 * Gets listeners list for specified event 7617 * @param {string} eventName 7618 */ 7619 value: function getListeners(eventName) { 7620 return EventEmitter.getListeners(this, eventName); 7621 } 7622 /** 7623 * Returns a full event name with namespace 7624 * @param {string} eventName 7625 * @returns {string} 7626 */ 7627 }, { 7628 key: "getFullEventName", 7629 value: function getFullEventName(eventName) { 7630 if (!Type.isStringFilled(eventName)) { 7631 throw new TypeError(`The "eventName" argument must be a string.`); 7632 } 7633 return EventEmitter.makeFullEventName(this.getEventNamespace(), eventName); 7634 } 7635 /** 7636 * Registers aliases (old event names for BX.onCustomEvent) 7637 * @param aliases 7638 */ 7639 }], [{ 7640 key: "makeObservable", 7641 value: function makeObservable(target, namespace) { 7642 if (!Type.isObject(target)) { 7643 throw new TypeError('The "target" argument must be an object.'); 7644 } 7645 if (!Type.isStringFilled(namespace)) { 7646 throw new TypeError('The "namespace" must be an non-empty string.'); 7647 } 7648 if (EventEmitter.isEventEmitter(target)) { 7649 throw new TypeError('The "target" is an event emitter already.'); 7650 } 7651 const targetProto = Object.getPrototypeOf(target); 7652 const emitter = new EventEmitter(); 7653 emitter.setEventNamespace(namespace); 7654 Object.setPrototypeOf(emitter, targetProto); 7655 Object.setPrototypeOf(target, emitter); 7656 Object.getOwnPropertyNames(EventEmitter.prototype).forEach(method => {
7657 if (['constructor'].includes(method)) { 7658 return; 7659 } 7660 emitter[method] = function (...args) { 7661 return EventEmitter.prototype[method].apply(target, args); 7662 }; 7663 }); 7664 } 7665 }, { 7666 key: "subscribe", 7667 value: function subscribe(target, eventName, listener, options) { 7668 if (Type.isString(target)) { 7669 options = listener; 7670 listener = eventName; 7671 eventName = target; 7672 target = this.GLOBAL_TARGET; 7673 } 7674 if (!Type.isObject(target)) { 7675 throw new TypeError(`The "target" argument must be an object.`); 7676 } 7677 eventName = this.normalizeEventName(eventName); 7678 if (!Type.isStringFilled(eventName)) { 7679 throw new TypeError(`The "eventName" argument must be a string.`); 7680 } 7681 listener = this.normalizeListener(listener); 7682 options = Type.isPlainObject(options) ? options : {}; 7683 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7684 const { 7685 eventsMap, 7686 onceMap 7687 } = eventStore.getOrAdd(target); 7688 const onceListeners = onceMap.get(fullEventName); 7689 let listeners = eventsMap.get(fullEventName); 7690 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7691 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7692 } else { 7693 if (listeners) { 7694 listeners.set(listener, { 7695 listener, 7696 options, 7697 sort: this.getNextSequenceValue() 7698 }); 7699 } else { 7700 listeners = new Map([[listener, { 7701 listener, 7702 options, 7703 sort: this.getNextSequenceValue() 7704 }]]); 7705 eventsMap.set(fullEventName, listeners); 7706 } 7707 } 7708 const maxListeners = this.getMaxListeners(target, eventName); 7709 if (listeners.size > maxListeners) { 7710 warningStore.add(target, fullEventName, listeners); 7711 warningStore.printDelayed(); 7712 } 7713 } 7714 }, { 7715 key: "subscribeOnce", 7716 value: function subscribeOnce(target, eventName, listener) { 7717 if (Type.isString(target)) { 7718 listener = eventName; 7719 eventName = target; 7720 target = this.GLOBAL_TARGET;
7721 } 7722 if (!Type.isObject(target)) { 7723 throw new TypeError(`The "target" argument must be an object.`); 7724 } 7725 eventName = this.normalizeEventName(eventName); 7726 if (!Type.isStringFilled(eventName)) { 7727 throw new TypeError(`The "eventName" argument must be a string.`); 7728 } 7729 listener = this.normalizeListener(listener); 7730 const fullEventName = this.resolveEventName(eventName, target); 7731 const { 7732 eventsMap, 7733 onceMap 7734 } = eventStore.getOrAdd(target); 7735 const listeners = eventsMap.get(fullEventName); 7736 let onceListeners = onceMap.get(fullEventName); 7737 if (listeners && listeners.has(listener) || onceListeners && onceListeners.has(listener)) { 7738 console.error(`You cannot subscribe the same "${fullEventName}" event listener twice.`); 7739 } else { 7740 const once = (...args) => { 7741 this.unsubscribe(target, eventName, once); 7742 onceListeners.delete(listener); 7743 listener(...args); 7744 }; 7745 if (onceListeners) { 7746 onceListeners.set(listener, once); 7747 } else { 7748 onceListeners = new Map([[listener, once]]); 7749 onceMap.set(fullEventName, onceListeners); 7750 } 7751 this.subscribe(target, eventName, once); 7752 } 7753 } 7754 }, { 7755 key: "unsubscribe", 7756 value: function unsubscribe(target, eventName, listener, options) { 7757 if (Type.isString(target)) { 7758 listener = eventName; 7759 eventName = target; 7760 target = this.GLOBAL_TARGET;
7761 } 7762 eventName = this.normalizeEventName(eventName); 7763 if (!Type.isStringFilled(eventName)) { 7764 throw new TypeError(`The "eventName" argument must be a string.`); 7765 } 7766 listener = this.normalizeListener(listener); 7767 options = Type.isPlainObject(options) ? options : {}; 7768 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7769 const targetInfo = eventStore.get(target); 7770 const listeners = targetInfo && targetInfo.eventsMap.get(fullEventName); 7771 const onceListeners = targetInfo && targetInfo.onceMap.get(fullEventName); 7772 if (listeners) { 7773 listeners.delete(listener); 7774 } 7775 if (onceListeners) { 7776 const once = onceListeners.get(listener); 7777 if (once) { 7778 onceListeners.delete(listener); 7779 listeners.delete(once); 7780 } 7781 } 7782 } 7783 }, { 7784 key: "unsubscribeAll", 7785 value: function unsubscribeAll(target, eventName, options) { 7786 if (Type.isString(target)) { 7787 eventName = target; 7788 target = this.GLOBAL_TARGET;
7789 } 7790 if (Type.isStringFilled(eventName)) { 7791 const targetInfo = eventStore.get(target); 7792 if (targetInfo) { 7793 options = Type.isPlainObject(options) ? options : {}; 7794 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7795 targetInfo.eventsMap.delete(fullEventName); 7796 targetInfo.onceMap.delete(fullEventName); 7797 } 7798 } else if (Type.isNil(eventName)) { 7799 if (target === this.GLOBAL_TARGET) { 7800 console.error('You cannot unsubscribe all global listeners.'); 7801 } else { 7802 eventStore.delete(target); 7803 } 7804 } 7805 } 7806 }, { 7807 key: "emit", 7808 value: function emit(target, eventName, event, options) { 7809 if (Type.isString(target)) { 7810 options = event; 7811 event = eventName; 7812 eventName = target; 7813 target = this.GLOBAL_TARGET; 7814 } 7815 if (!Type.isObject(target)) { 7816 throw new TypeError(`The "target" argument must be an object.`); 7817 } 7818 eventName = this.normalizeEventName(eventName); 7819 if (!Type.isStringFilled(eventName)) { 7820 throw new TypeError(`The "eventName" argument must be a string.`); 7821 } 7822 options = Type.isPlainObject(options) ? options : {}; 7823 const fullEventName = this.resolveEventName(eventName, target, options.useGlobalNaming === true); 7824 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 7825 const globalListeners = globalEvents && globalEvents.eventsMap.get(fullEventName) || new Map(); 7826 let targetListeners = new Set(); 7827 if (target !== this.GLOBAL_TARGET) { 7828 const targetEvents = eventStore.get(target); 7829 targetListeners = targetEvents && targetEvents.eventsMap.get(fullEventName) || new Map(); 7830 } 7831 const listeners = [...globalListeners.values(), ...targetListeners.values()]; 7832 listeners.sort(function (a, b) { 7833 return a.sort - b.sort; 7834 }); 7835 const preparedEvent = this.prepareEvent(target, fullEventName, event); 7836 const result = []; 7837 for (let i = 0; i < listeners.length; i++) { 7838 if (preparedEvent.isImmediatePropagationStopped()) { 7839 break; 7840 } 7841 const { 7842 listener, 7843 options: listenerOptions 7844 } = listeners[i]; 7845 7846 //A previous listener could remove a current listener. 7847 if (globalListeners.has(listener) || targetListeners.has(listener)) { 7848 let listenerResult; 7849 if (listenerOptions.compatMode) { 7850 let params = []; 7851 const compatData = preparedEvent.getCompatData(); 7852 if (compatData !== null) { 7853 params = options.cloneData === true ? Runtime.clone(compatData) : compatData; 7854 } else { 7855 params = [preparedEvent]; 7856 } 7857 const context = Type.isUndefined(options.thisArg) ? target : options.thisArg; 7858 listenerResult = listener.apply(context, params); 7859 } else { 7860 listenerResult = Type.isUndefined(options.thisArg) ? listener(preparedEvent) : listener.call(options.thisArg, preparedEvent); 7861 } 7862 result.push(listenerResult); 7863 } 7864 } 7865 return result; 7866 } 7867 }, { 7868 key: "emitAsync", 7869 value: function emitAsync(target, eventName, event) { 7870 if (Type.isString(target)) { 7871 event = eventName; 7872 eventName = target; 7873 target = this.GLOBAL_TARGET;
7874 } 7875 return Promise.all(this.emit(target, eventName, event)); 7876 } 7877 }, { 7878 key: "prepareEvent", 7879 value: function prepareEvent(target, eventName, event) { 7880 let preparedEvent = event; 7881 if (!(event instanceof BaseEvent)) { 7882 preparedEvent = new BaseEvent(); 7883 preparedEvent.setData(event); 7884 } 7885 preparedEvent.setTarget(this.isEventEmitter(target) ? target[targetProperty] : target); 7886 preparedEvent.setType(eventName); 7887 return preparedEvent; 7888 } 7889 /** 7890 * @private 7891 * @returns {number} 7892 */ 7893 }, { 7894 key: "getNextSequenceValue", 7895 value: function getNextSequenceValue() { 7896 return this.sequenceValue++; 7897 } 7898 /** 7899 * Sets max global events listeners count 7900 * Event.EventEmitter.setMaxListeners(10) - sets the default value for all events (global target) 7901 * Event.EventEmitter.setMaxListeners("onClose", 10) - sets the value for onClose event (global target) 7902 * Event.EventEmitter.setMaxListeners(obj, 10) - sets the default value for all events (obj target) 7903 * Event.EventEmitter.setMaxListeners(obj, "onClose", 10); - sets the value for onClose event (obj target) 7904 * @return {void} 7905 * @param args 7906 */ 7907 }, { 7908 key: "setMaxListeners", 7909 value: function setMaxListeners(...args) { 7910 let target = this.GLOBAL_TARGET;
7911 let eventName = null; 7912 let count = undefined; 7913 if (args.length === 1) { 7914 count = args[0]; 7915 } else if (args.length === 2) { 7916 if (Type.isString(args[0])) { 7917 [eventName, count] = args; 7918 } else { 7919 [target, count] = args; 7920 } 7921 } else if (args.length >= 3) { 7922 [target, eventName, count] = args; 7923 } 7924 if (!Type.isObject(target)) { 7925 throw new TypeError(`The "target" argument must be an object.`); 7926 } 7927 if (eventName !== null && !Type.isStringFilled(eventName)) { 7928 throw new TypeError(`The "eventName" argument must be a string.`); 7929 } 7930 if (!Type.isNumber(count) || count < 0) { 7931 throw new TypeError(`The value of "count" is out of range. It must be a non-negative number. Received ${count}.`); 7932 } 7933 const targetInfo = eventStore.getOrAdd(target); 7934 if (Type.isStringFilled(eventName)) { 7935 const fullEventName = this.resolveEventName(eventName, target); 7936 targetInfo.eventsMaxListeners.set(fullEventName, count); 7937 } else { 7938 targetInfo.maxListeners = count; 7939 } 7940 } 7941 }, { 7942 key: "getMaxListeners", 7943 value: function getMaxListeners(target, eventName) { 7944 if (Type.isString(target)) { 7945 eventName = target; 7946 target = this.GLOBAL_TARGET;
7947 } else if (Type.isNil(target)) { 7948 target = this.GLOBAL_TARGET; 7949 } 7950 if (!Type.isObject(target)) { 7951 throw new TypeError(`The "target" argument must be an object.`); 7952 } 7953 const targetInfo = eventStore.get(target); 7954 if (targetInfo) { 7955 let maxListeners = targetInfo.maxListeners; 7956 if (Type.isStringFilled(eventName)) { 7957 const fullEventName = this.resolveEventName(eventName, target); 7958 maxListeners = targetInfo.eventsMaxListeners.get(fullEventName) || maxListeners; 7959 } 7960 return maxListeners; 7961 } 7962 return this.DEFAULT_MAX_LISTENERS; 7963 } 7964 }, { 7965 key: "addMaxListeners", 7966 value: function addMaxListeners(...args) { 7967 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 7968 const maxListeners = Math.max(this.getMaxListeners(target, eventName) + increment, 0); 7969 if (Type.isStringFilled(eventName)) { 7970 EventEmitter.setMaxListeners(target, eventName, maxListeners); 7971 } else { 7972 EventEmitter.setMaxListeners(target, maxListeners); 7973 } 7974 return maxListeners; 7975 } 7976 /** 7977 * Increases max listeners count 7978 * 7979 * Event.EventEmitter.incrementMaxListeners() - adds one max listener for all events of global target 7980 * Event.EventEmitter.incrementMaxListeners(3) - adds three max listeners for all events of global target 7981 * Event.EventEmitter.incrementMaxListeners('onClose') - adds one max listener for onClose event of global target 7982 * Event.EventEmitter.incrementMaxListeners('onClose', 2) - adds two max listeners for onClose event of global target 7983 * 7984 * Event.EventEmitter.incrementMaxListeners(obj) - adds one max listener for all events of 'obj' target 7985 * Event.EventEmitter.incrementMaxListeners(obj, 3) - adds three max listeners for all events of 'obj' target 7986 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose') - adds one max listener for onClose event of 'obj' target 7987 * Event.EventEmitter.incrementMaxListeners(obj, 'onClose', 2) - adds two max listeners for onClose event of 'obj' target 7988 */ 7989 }, { 7990 key: "incrementMaxListeners", 7991 value: function incrementMaxListeners(...args) { 7992 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 7993 return this.addMaxListeners(target, eventName, Math.abs(increment)); 7994 } 7995 }, { 7996 key: "decrementMaxListeners", 7997 value: function decrementMaxListeners(...args) { 7998 const [target, eventName, increment] = this.destructMaxListenersArgs(...args); 7999 return this.addMaxListeners(target, eventName, -Math.abs(increment)); 8000 } 8001 }, { 8002 key: "destructMaxListenersArgs", 8003 value: function destructMaxListenersArgs(...args) { 8004 let eventName = null; 8005 let increment = 1; 8006 let target = this.GLOBAL_TARGET;
8007 if (args.length === 1) { 8008 if (Type.isNumber(args[0])) { 8009 increment = args[0]; 8010 } else if (Type.isString(args[0])) { 8011 eventName = args[0]; 8012 } else { 8013 target = args[0]; 8014 } 8015 } else if (args.length === 2) { 8016 if (Type.isString(args[0])) { 8017 [eventName, increment] = args; 8018 } else if (Type.isString(args[1])) { 8019 [target, eventName] = args; 8020 } else { 8021 [target, increment] = args; 8022 } 8023 } else if (args.length >= 3) { 8024 [target, eventName, increment] = args; 8025 } 8026 if (!Type.isObject(target)) { 8027 throw new TypeError(`The "target" argument must be an object.`); 8028 } 8029 if (eventName !== null && !Type.isStringFilled(eventName)) { 8030 throw new TypeError(`The "eventName" argument must be a string.`); 8031 } 8032 if (!Type.isNumber(increment)) { 8033 throw new TypeError(`The value of "increment" must be a number.`); 8034 } 8035 return [target, eventName, increment]; 8036 } 8037 /** 8038 * Gets listeners list for a specified event 8039 * @param {object} target 8040 * @param {string} eventName 8041 */ 8042 }, { 8043 key: "getListeners", 8044 value: function getListeners(target, eventName) { 8045 if (Type.isString(target)) { 8046 eventName = target; 8047 target = this.GLOBAL_TARGET;
8048 } 8049 if (!Type.isObject(target)) { 8050 throw new TypeError(`The "target" argument must be an object.`); 8051 } 8052 eventName = this.normalizeEventName(eventName); 8053 if (!Type.isStringFilled(eventName)) { 8054 throw new TypeError(`The "eventName" argument must be a string.`); 8055 } 8056 const targetInfo = eventStore.get(target); 8057 if (!targetInfo) { 8058 return new Map(); 8059 } 8060 const fullEventName = this.resolveEventName(eventName, target); 8061 return targetInfo.eventsMap.get(fullEventName) || new Map(); 8062 } 8063 }, { 8064 key: "registerAliases", 8065 value: function registerAliases(aliases) { 8066 aliases = this.normalizeAliases(aliases); 8067 Object.keys(aliases).forEach(alias => { 8068 aliasStore.set(alias, { 8069 eventName: aliases[alias].eventName, 8070 namespace: aliases[alias].namespace 8071 }); 8072 }); 8073 EventEmitter.mergeEventAliases(aliases); 8074 } 8075 /** 8076 * @private 8077 * @param aliases 8078 */ 8079 }, { 8080 key: "normalizeAliases", 8081 value: function normalizeAliases(aliases) { 8082 if (!Type.isPlainObject(aliases)) { 8083 throw new TypeError(`The "aliases" argument must be an object.`); 8084 } 8085 const result = Object.create(null); 8086 for (let alias in aliases) { 8087 if (!Type.isStringFilled(alias)) { 8088 throw new TypeError(`The alias must be an non-empty string.`); 8089 } 8090 const options = aliases[alias]; 8091 if (!options || !Type.isStringFilled(options.eventName) || !Type.isStringFilled(options.namespace)) { 8092 throw new TypeError(`The alias options must set the "eventName" and the "namespace".`); 8093 } 8094 alias = this.normalizeEventName(alias); 8095 result[alias] = { 8096 eventName: options.eventName, 8097 namespace: options.namespace 8098 }; 8099 } 8100 return result; 8101 } 8102 /** 8103 * @private 8104 */ 8105 }, { 8106 key: "mergeEventAliases", 8107 value: function mergeEventAliases(aliases) { 8108 const globalEvents = eventStore.get(this.GLOBAL_TARGET); 8109 if (!globalEvents) { 8110 return; 8111 } 8112 Object.keys(aliases).forEach(alias => { 8113 const options = aliases[alias]; 8114 alias = this.normalizeEventName(alias); 8115 const fullEventName = this.makeFullEventName(options.namespace, options.eventName); 8116 const aliasListeners = globalEvents.eventsMap.get(alias); 8117 if (aliasListeners) { 8118 const listeners = globalEvents.eventsMap.get(fullEventName) || new Map(); 8119 globalEvents.eventsMap.set(fullEventName, new Map([...listeners, ...aliasListeners])); 8120 globalEvents.eventsMap.delete(alias); 8121 } 8122 const aliasOnceListeners = globalEvents.onceMap.get(alias); 8123 if (aliasOnceListeners) { 8124 const onceListeners = globalEvents.onceMap.get(fullEventName) || new Map(); 8125 globalEvents.onceMap.set(fullEventName, new Map([...onceListeners, ...aliasOnceListeners])); 8126 globalEvents.onceMap.delete(alias); 8127 } 8128 const aliasMaxListeners = globalEvents.eventsMaxListeners.get(alias); 8129 if (aliasMaxListeners) { 8130 const eventMaxListeners = globalEvents.eventsMaxListeners.get(fullEventName) || 0; 8131 globalEvents.eventsMaxListeners.set(fullEventName, Math.max(eventMaxListeners, aliasMaxListeners)); 8132 globalEvents.eventsMaxListeners.delete(alias); 8133 } 8134 }); 8135 } 8136 /** 8137 * Returns true if the target is an instance of Event.EventEmitter 8138 * @param {object} target 8139 * @returns {boolean} 8140 */ 8141 }, { 8142 key: "isEventEmitter", 8143 value: function isEventEmitter(target) { 8144 return Type.isObject(target) && target[isEmitterProperty] === true; 8145 } 8146 /** 8147 * @private 8148 * @param {string} eventName 8149 * @returns {string} 8150 */ 8151 }, { 8152 key: "normalizeEventName", 8153 value: function normalizeEventName(eventName) { 8154 if (!Type.isStringFilled(eventName)) { 8155 return ''; 8156 } 8157 return eventName.toLowerCase(); 8158 } 8159 /** 8160 * @private 8161 */ 8162 }, { 8163 key: "normalizeListener", 8164 value: function normalizeListener(listener) { 8165 if (Type.isString(listener)) { 8166 listener = Reflection.getClass(listener); 8167 } 8168 if (!Type.isFunction(listener)) { 8169 throw new TypeError(`The "listener" argument must be of type Function. Received type ${typeof listener}.`); 8170 } 8171 return listener; 8172 } 8173 /** 8174 * @private 8175 * @param eventName 8176 * @param target 8177 * @param useGlobalNaming 8178 * @returns {string} 8179 */ 8180 }, { 8181 key: "resolveEventName", 8182 value: function resolveEventName(eventName, target, useGlobalNaming = false) { 8183 eventName = this.normalizeEventName(eventName); 8184 if (!Type.isStringFilled(eventName)) { 8185 return ''; 8186 } 8187 if (this.isEventEmitter(target) && useGlobalNaming !== true) { 8188 if (target.getEventNamespace() !== null && eventName.includes('.')) { 8189 console.warn(`Possible the wrong event name "${eventName}".`); 8190 } 8191 eventName = target.getFullEventName(eventName); 8192 } else if (aliasStore.has(eventName)) { 8193 const { 8194 namespace, 8195 eventName: actualEventName 8196 } = aliasStore.get(eventName); 8197 eventName = this.makeFullEventName(namespace, actualEventName); 8198 } 8199 return eventName; 8200 } 8201 /** 8202 * @private 8203 * @param {string} namespace 8204 * @param {string} eventName 8205 * @returns {string} 8206 */ 8207 }, { 8208 key: "makeFullEventName", 8209 value: function makeFullEventName(namespace, eventName) { 8210 const fullName = Type.isStringFilled(namespace) ? `${namespace}:${eventName}` : eventName; 8211 return Type.isStringFilled(fullName) ? fullName.toLowerCase() : ''; 8212 } 8213 }]); 8214 return EventEmitter; 8215 }(); 8216 babelHelpers.defineProperty(EventEmitter, "GLOBAL_TARGET", globalTarget); 8217 babelHelpers.defineProperty(EventEmitter, "DEFAULT_MAX_LISTENERS", eventStore.getDefaultMaxListeners()); 8218 babelHelpers.defineProperty(EventEmitter, "sequenceValue", 1); 8219 8220 let stack = []; 8221 /** 8222 * For compatibility only 8223 * @type {boolean} 8224 */ 8225 // eslint-disable-next-line 8226 exports.isReady = false;
8227 function ready(handler) { 8228 switch (document.readyState) { 8229 case 'loading': 8230 stack.push(handler); 8231 break; 8232 case 'interactive': 8233 case 'complete': 8234 if (Type.isFunction(handler)) { 8235 handler(); 8236 } 8237 exports.isReady = true; 8238 break; 8239 default: 8240 break; 8241 } 8242 } 8243 document.addEventListener('readystatechange', () => { 8244 if (!exports.isReady) { 8245 stack.forEach(ready); 8246 stack = []; 8247 } 8248 }); 8249 8250 /** 8251 * @memberOf BX 8252 */ 8253 let Event = function Event() { 8254 babelHelpers.classCallCheck(this, Event); 8255 }; 8256 babelHelpers.defineProperty(Event, "bind", bind); 8257 babelHelpers.defineProperty(Event, "bindOnce", bindOnce); 8258 babelHelpers.defineProperty(Event, "unbind", unbind); 8259 babelHelpers.defineProperty(Event, "unbindAll", unbindAll); 8260 babelHelpers.defineProperty(Event, "ready", ready); 8261 babelHelpers.defineProperty(Event, "EventEmitter", EventEmitter); 8262 babelHelpers.defineProperty(Event, "BaseEvent", BaseEvent); 8263 8264 function encodeAttributeValue(value) { 8265 if (Type.isPlainObject(value) || Type.isArray(value)) { 8266 return JSON.stringify(value); 8267 } 8268 return Text.encode(Text.decode(value)); 8269 } 8270 8271 function decodeAttributeValue(value) { 8272 if (Type.isString(value)) { 8273 const decodedValue = Text.decode(value); 8274 let result; 8275 try { 8276 result = JSON.parse(decodedValue); 8277 } catch (e) { 8278 result = decodedValue; 8279 } 8280 if (result === decodedValue) { 8281 if (/^[\d.]+[.]?\d+$/.test(result)) { 8282 return Number(result); 8283 } 8284 } 8285 if (result === 'true' || result === 'false') { 8286 return Boolean(result); 8287 } 8288 return result; 8289 } 8290 return value; 8291 } 8292 8293 function getPageScroll() { 8294 const { 8295 documentElement, 8296 body 8297 } = document; 8298 const scrollTop = Math.max(window.pageYOffset || 0, documentElement ? documentElement.scrollTop : 0, body ? body.scrollTop : 0); 8299 const scrollLeft = Math.max(window.pageXOffset || 0, documentElement ? documentElement.scrollLeft : 0, body ? body.scrollLeft : 0); 8300 return { 8301 scrollTop, 8302 scrollLeft 8303 }; 8304 } 8305 8306 /** 8307 * @memberOf BX 8308 */ 8309 let Dom = /*#__PURE__*/function () { 8310 function Dom() { 8311 babelHelpers.classCallCheck(this, Dom); 8312 } 8313 babelHelpers.createClass(Dom, null, [{ 8314 key: "replace", 8315 /** 8316 * Replaces old html element to new html element 8317 * @param oldElement 8318 * @param newElement 8319 */ 8320 value: function replace(oldElement, newElement) { 8321 if (Type.isDomNode(oldElement) && Type.isDomNode(newElement)) { 8322 if (Type.isDomNode(oldElement.parentNode)) { 8323 oldElement.parentNode.replaceChild(newElement, oldElement); 8324 } 8325 } 8326 } 8327 /** 8328 * Removes element 8329 * @param element 8330 */ 8331 }, { 8332 key: "remove", 8333 value: function remove(element) { 8334 if (Type.isDomNode(element) && Type.isDomNode(element.parentNode)) { 8335 element.parentNode.removeChild(element); 8336 } 8337 } 8338 /** 8339 * Cleans element 8340 * @param element 8341 */ 8342 }, { 8343 key: "clean", 8344 value: function clean(element) { 8345 if (Type.isDomNode(element)) { 8346 while (element.childNodes.length > 0) { 8347 element.removeChild(element.firstChild); 8348 } 8349 return; 8350 } 8351 if (Type.isString(element)) { 8352 Dom.clean(document.getElementById(element)); 8353 } 8354 } 8355 /** 8356 * Inserts element before target element 8357 * @param current 8358 * @param target 8359 */ 8360 }, { 8361 key: "insertBefore", 8362 value: function insertBefore(current, target) { 8363 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8364 if (Type.isDomNode(target.parentNode)) { 8365 target.parentNode.insertBefore(current, target); 8366 } 8367 } 8368 } 8369 /** 8370 * Inserts element after target element 8371 * @param current 8372 * @param target 8373 */ 8374 }, { 8375 key: "insertAfter", 8376 value: function insertAfter(current, target) { 8377 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8378 if (Type.isDomNode(target.parentNode)) { 8379 const parent = target.parentNode; 8380 if (Type.isDomNode(target.nextSibling)) { 8381 parent.insertBefore(current, target.nextSibling); 8382 return; 8383 } 8384 parent.appendChild(current); 8385 } 8386 } 8387 } 8388 /** 8389 * Appends element to target element 8390 * @param current 8391 * @param target 8392 */ 8393 }, { 8394 key: "append", 8395 value: function append(current, target) { 8396 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8397 target.appendChild(current); 8398 } 8399 } 8400 /** 8401 * Prepends element to target element 8402 * @param current 8403 * @param target 8404 */ 8405 }, {
8406 key: "prepend", 8407 value: function prepend(current, target) { 8408 if (Type.isDomNode(current) && Type.isDomNode(target)) { 8409 if (Type.isDomNode(target.firstChild)) { 8410 target.insertBefore(current, target.firstChild); 8411 return; 8412 } 8413 Dom.append(current, target); 8414 } 8415 } 8416 /** 8417 * Checks that element contains class name or class names 8418 * @param element 8419 * @param className 8420 * @return {Boolean} 8421 */ 8422 }, { 8423 key: "hasClass", 8424 value: function hasClass(element, className) { 8425 if (Type.isElementNode(element)) { 8426 if (Type.isString(className)) { 8427 const preparedClassName = className.trim(); 8428 if (preparedClassName.length > 0) { 8429 if (preparedClassName.includes(' ')) { 8430 return preparedClassName.split(' ').every(name => Dom.hasClass(element, name)); 8431 } 8432 if ('classList' in element) { 8433 return element.classList.contains(preparedClassName); 8434 } 8435 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8436 return element.getAttribute('class').split(' ').some(name => name === preparedClassName); 8437 } 8438 } 8439 } 8440 if (Type.isArray(className) && className.length > 0) { 8441 return className.every(name => Dom.hasClass(element, name)); 8442 } 8443 } 8444 return false; 8445 } 8446 /** 8447 * Adds class name 8448 * @param element 8449 * @param className 8450 */ 8451 }, { 8452 key: "addClass", 8453 value: function addClass(element, className) { 8454 if (Type.isElementNode(element)) { 8455 if (Type.isString(className)) { 8456 const preparedClassName = className.trim(); 8457 if (preparedClassName.length > 0) { 8458 if (preparedClassName.includes(' ')) { 8459 Dom.addClass(element, preparedClassName.split(' ')); 8460 return; 8461 } 8462 if ('classList' in element) { 8463 element.classList.add(preparedClassName); 8464 return; 8465 } 8466 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8467 if (element.className.baseVal === '') { 8468 element.className.baseVal = preparedClassName; 8469 return; 8470 } 8471 const names = element.className.baseVal.split(' '); 8472 if (!names.includes(preparedClassName)) { 8473 names.push(preparedClassName); 8474 element.className.baseVal = names.join(' ').trim(); 8475 return; 8476 } 8477 } 8478 return; 8479 } 8480 } 8481 if (Type.isArray(className)) { 8482 className.forEach(name => Dom.addClass(element, name)); 8483 } 8484 } 8485 } 8486 /** 8487 * Removes class name 8488 * @param element 8489 * @param className 8490 */ 8491 }, { 8492 key: "removeClass", 8493 value: function removeClass(element, className) { 8494 if (Type.isElementNode(element)) { 8495 if (Type.isString(className)) { 8496 const preparedClassName = className.trim(); 8497 if (preparedClassName.length > 0) { 8498 if (preparedClassName.includes(' ')) { 8499 Dom.removeClass(element, preparedClassName.split(' ')); 8500 return; 8501 } 8502 if ('classList' in element) { 8503 element.classList.remove(preparedClassName); 8504 return; 8505 } 8506 if (Type.isObject(element.className) && Type.isString(element.className.baseVal)) { 8507 const names = element.className.baseVal.split(' ').filter(name => name !== preparedClassName); 8508 element.className.baseVal = names.join(' '); 8509 return; 8510 } 8511 } 8512 } 8513 if (Type.isArray(className)) { 8514 className.forEach(name => Dom.removeClass(element, name)); 8515 } 8516 } 8517 } 8518 /** 8519 * Toggles class name 8520 * @param element 8521 * @param className 8522 */ 8523 }, { 8524 key: "toggleClass", 8525 value: function toggleClass(element, className) { 8526 if (Type.isElementNode(element)) { 8527 if (Type.isString(className)) { 8528 const preparedClassName = className.trim(); 8529 if (preparedClassName.length > 0) { 8530 if (preparedClassName.includes(' ')) { 8531 Dom.toggleClass(element, preparedClassName.split(' ')); 8532 return; 8533 } 8534 element.classList.toggle(preparedClassName); 8535 return; 8536 } 8537 } 8538 if (Type.isArray(className)) { 8539 className.forEach(name => Dom.toggleClass(element, name)); 8540 } 8541 } 8542 } 8543 /** 8544 * Styles element 8545 */ 8546 }, { 8547 key: "style", 8548 value: function style(element, prop, value) { 8549 if (Type.isElementNode(element)) { 8550 if (Type.isNull(prop)) { 8551 element.removeAttribute('style'); 8552 return element; 8553 } 8554 if (Type.isPlainObject(prop)) {
8555 Object.entries(prop).forEach(item => { 8556 const [currentKey, currentValue] = item; 8557 Dom.style(element, currentKey, currentValue); 8558 }); 8559 return element; 8560 } 8561 if (Type.isString(prop)) { 8562 if (Type.isUndefined(value) && element.nodeType !== Node.DOCUMENT_NODE) { 8563 const computedStyle = getComputedStyle(element); 8564 if (prop in computedStyle) { 8565 return computedStyle[prop]; 8566 } 8567 return computedStyle.getPropertyValue(prop); 8568 } 8569 if (Type.isNull(value) || value === '' || value === 'null') { 8570 if (String(prop).startsWith('--')) { 8571 // eslint-disable-next-line 8572 element.style.removeProperty(prop); 8573 return element; 8574 } 8575 8576 // eslint-disable-next-line 8577 element.style[prop] = ''; 8578 return element; 8579 } 8580 if (Type.isString(value) || Type.isNumber(value)) { 8581 if (String(prop).startsWith('--')) { 8582 // eslint-disable-next-line 8583 element.style.setProperty(prop, value); 8584 return element; 8585 } 8586 8587 // eslint-disable-next-line 8588 element.style[prop] = value; 8589 return element; 8590 } 8591 } 8592 } 8593 return null; 8594 } 8595 /** 8596 * Adjusts element 8597 * @param target 8598 * @param data 8599 * @return {*} 8600 */ 8601 }, { 8602 key: "adjust", 8603 value: function adjust(target, data = {}) { 8604 if (!target.nodeType) { 8605 return null; 8606 } 8607 let element = target; 8608 if (target.nodeType === Node.DOCUMENT_NODE) { 8609 element = target.body; 8610 } 8611 if (Type.isPlainObject(data)) { 8612 if (Type.isPlainObject(data.attrs)) { 8613 Object.keys(data.attrs).forEach(key => { 8614 if (key === 'class' || key.toLowerCase() === 'classname') { 8615 element.className = data.attrs[key]; 8616 return; 8617 } 8618 8619 // eslint-disable-next-line 8620 if (data.attrs[key] == '') { 8621 element.removeAttribute(key); 8622 return; 8623 } 8624 element.setAttribute(key, data.attrs[key]); 8625 }); 8626 } 8627 if (Type.isPlainObject(data.style)) { 8628 Dom.style(element, data.style); 8629 } 8630 if (Type.isPlainObject(data.props)) { 8631 Object.keys(data.props).forEach(key => { 8632 element[key] = data.props[key]; 8633 }); 8634 } 8635 if (Type.isPlainObject(data.events)) { 8636 Object.keys(data.events).forEach(key => { 8637 Event.bind(element, key, data.events[key]); 8638 }); 8639 } 8640 if (Type.isPlainObject(data.dataset)) { 8641 Object.keys(data.dataset).forEach(key => { 8642 element.dataset[key] = data.dataset[key]; 8643 }); 8644 } 8645 if (Type.isString(data.children)) { 8646 data.children = [data.children]; 8647 } 8648 if (Type.isArray(data.children) && data.children.length > 0) { 8649 data.children.forEach(item => { 8650 if (Type.isDomNode(item)) { 8651 Dom.append(item, element); 8652 } 8653 if (Type.isString(item)) { 8654 element.insertAdjacentHTML('beforeend', item); 8655 } 8656 }); 8657 return element; 8658 } 8659 if ('text' in data && !Type.isNil(data.text)) { 8660 element.innerText = data.text; 8661 return element; 8662 } 8663 if ('html' in data && !Type.isNil(data.html)) { 8664 element.innerHTML = data.html; 8665 } 8666 } 8667 return element; 8668 } 8669 /** 8670 * Creates element 8671 * @param tag 8672 * @param data 8673 * @param context 8674 * @return {HTMLElement|HTMLBodyElement} 8675 */ 8676 }, { 8677 key: "create", 8678 value: function create(tag, data = {}, context = document) { 8679 let tagName = tag; 8680 let options = data; 8681 if (Type.isObjectLike(tag)) { 8682 options = tag; 8683 tagName = tag.tag; 8684 } 8685 return Dom.adjust(context.createElement(tagName), options); 8686 } 8687 /** 8688 * Shows element 8689 * @param element 8690 */ 8691 }, { 8692 key: "show", 8693 value: function show(element) { 8694 if (Type.isDomNode(element)) { 8695 // eslint-disable-next-line 8696 element.hidden = false;
8697 } 8698 } 8699 /** 8700 * Hides element 8701 * @param element 8702 */ 8703 }, { 8704 key: "hide", 8705 value: function hide(element) { 8706 if (Type.isDomNode(element)) { 8707 // eslint-disable-next-line 8708 element.hidden = true; 8709 } 8710 } 8711 /** 8712 * Checks that element is shown 8713 * @param element 8714 * @return {*|boolean} 8715 */ 8716 }, { 8717 key: "isShown", 8718 value: function isShown(element) { 8719 return Type.isDomNode(element) && !element.hidden && element.style.getPropertyValue('display') !== 'none'; 8720 } 8721 /** 8722 * Toggles element visibility 8723 * @param element 8724 */ 8725 }, { 8726 key: "toggle", 8727 value: function toggle(element) { 8728 if (Type.isDomNode(element)) { 8729 if (Dom.isShown(element)) { 8730 Dom.hide(element); 8731 } else { 8732 Dom.show(element); 8733 } 8734 } 8735 } 8736 /** 8737 * Gets element position relative page 8738 * @param {HTMLElement} element 8739 * @return {DOMRect} 8740 */ 8741 }, { 8742 key: "getPosition", 8743 value: function getPosition(element) { 8744 if (Type.isDomNode(element)) { 8745 const elementRect = element.getBoundingClientRect(); 8746 const { 8747 scrollLeft, 8748 scrollTop 8749 } = getPageScroll(); 8750 return new DOMRect(elementRect.left + scrollLeft, elementRect.top + scrollTop, elementRect.width, elementRect.height); 8751 } 8752 return new DOMRect(); 8753 } 8754 /** 8755 * Gets element position relative specified element position 8756 * @param {HTMLElement} element 8757 * @param {HTMLElement} relationElement 8758 * @return {DOMRect} 8759 */ 8760 }, { 8761 key: "getRelativePosition", 8762 value: function getRelativePosition(element, relationElement) { 8763 if (Type.isDomNode(element) && Type.isDomNode(relationElement)) { 8764 const elementPosition = Dom.getPosition(element); 8765 const relationElementPosition = Dom.getPosition(relationElement); 8766 return new DOMRect(elementPosition.left - relationElementPosition.left, elementPosition.top - relationElementPosition.top, elementPosition.width, elementPosition.height); 8767 } 8768 return new DOMRect(); 8769 } 8770 }, { 8771 key: "attr", 8772 value: function attr(element, _attr, value) { 8773 if (Type.isElementNode(element)) { 8774 if (Type.isString(_attr)) { 8775 if (!Type.isNil(value)) { 8776 return element.setAttribute(_attr, encodeAttributeValue(value)); 8777 } 8778 if (Type.isNull(value)) { 8779 return element.removeAttribute(_attr); 8780 } 8781 return decodeAttributeValue(element.getAttribute(_attr)); 8782 } 8783 if (Type.isPlainObject(_attr)) { 8784 return Object.entries(_attr).forEach(([attrKey, attrValue]) => { 8785 Dom.attr(element, attrKey, attrValue); 8786 }); 8787 } 8788 } 8789 return null; 8790 } 8791 }]); 8792 return Dom; 8793 }(); 8794 8795 const UA = navigator.userAgent.toLowerCase(); 8796 8797 /** 8798 * @memberOf BX 8799 */ 8800 let Browser = /*#__PURE__*/function () { 8801 function Browser() { 8802 babelHelpers.classCallCheck(this, Browser); 8803 } 8804 babelHelpers.createClass(Browser, null, [{ 8805 key: "isOpera", 8806 value: function isOpera() { 8807 return UA.includes('opera'); 8808 } 8809 }, { 8810 key: "isIE", 8811 value: function isIE() { 8812 return 'attachEvent' in document && !Browser.isOpera(); 8813 } 8814 }, { 8815 key: "isIE6", 8816 value: function isIE6() { 8817 return UA.includes('msie 6'); 8818 } 8819 }, { 8820 key: "isIE7", 8821 value: function isIE7() { 8822 return UA.includes('msie 7'); 8823 } 8824 }, { 8825 key: "isIE8", 8826 value: function isIE8() { 8827 return UA.includes('msie 8'); 8828 } 8829 }, { 8830 key: "isIE9", 8831 value: function isIE9() { 8832 return 'documentMode' in document && document.documentMode >= 9; 8833 } 8834 }, { 8835 key: "isIE10", 8836 value: function isIE10() { 8837 return 'documentMode' in document && document.documentMode >= 10; 8838 } 8839 }, { 8840 key: "isSafari", 8841 value: function isSafari() { 8842 return UA.includes('safari') && !UA.includes('chrome'); 8843 } 8844 }, { 8845 key: "isFirefox", 8846 value: function isFirefox() { 8847 return UA.includes('firefox'); 8848 } 8849 }, { 8850 key: "isChrome", 8851 value: function isChrome() { 8852 return UA.includes('chrome'); 8853 } 8854 }, { 8855 key: "detectIEVersion", 8856 value: function detectIEVersion() { 8857 if (Browser.isOpera() || Browser.isSafari() || Browser.isFirefox() || Browser.isChrome()) { 8858 return -1; 8859 } 8860 let rv = -1; 8861 if (!!window.MSStream && !window.ActiveXObject && 'ActiveXObject' in window) { 8862 rv = 11; 8863 } else if (Browser.isIE10()) { 8864 rv = 10; 8865 } else if (Browser.isIE9()) { 8866 rv = 9; 8867 } else if (Browser.isIE()) { 8868 rv = 8; 8869 } 8870 if (rv === -1 || rv === 8) { 8871 if (navigator.appName === 'Microsoft Internet Explorer') { 8872 const re = new RegExp('MSIE ([0-9]+[.0-9]*)'); 8873 const res = navigator.userAgent.match(re); 8874 if (Type.isArrayLike(res) && res.length > 0) { 8875 rv = parseFloat(res[1]); 8876 } 8877 } 8878 if (navigator.appName === 'Netscape') { 8879 // Alternative check for IE 11 8880 rv = 11; 8881 const re = new RegExp('Trident/.*rv:([0-9]+[.0-9]*)'); 8882 if (re.exec(navigator.userAgent) != null) { 8883 const res = navigator.userAgent.match(re); 8884 if (Type.isArrayLike(res) && res.length > 0) { 8885 rv = parseFloat(res[1]); 8886 } 8887 } 8888 } 8889 } 8890 return rv; 8891 } 8892 }, { 8893 key: "isIE11", 8894 value: function isIE11() { 8895 return Browser.detectIEVersion() >= 11; 8896 } 8897 }, { 8898 key: "isMac", 8899 value: function isMac() { 8900 return UA.includes('macintosh'); 8901 } 8902 }, { 8903 key: "isWin", 8904 value: function isWin() { 8905 return UA.includes('windows'); 8906 } 8907 }, { 8908 key: "isLinux", 8909 value: function isLinux() { 8910 return UA.includes('linux') && !Browser.isAndroid(); 8911 } 8912 }, { 8913 key: "isAndroid", 8914 value: function isAndroid() { 8915 return UA.includes('android'); 8916 } 8917 }, { 8918 key: "isIPad", 8919 value: function isIPad() { 8920 return UA.includes('ipad;') || this.isMac() && this.isTouchDevice(); 8921 } 8922 }, { 8923 key: "isIPhone", 8924 value: function isIPhone() { 8925 return UA.includes('iphone;'); 8926 } 8927 }, { 8928 key: "isIOS", 8929 value: function isIOS() { 8930 return Browser.isIPad() || Browser.isIPhone(); 8931 } 8932 }, { 8933 key: "isMobile", 8934 value: function isMobile() { 8935 return Browser.isIPhone() || Browser.isIPad() || Browser.isAndroid() || UA.includes('mobile') || UA.includes('touch'); 8936 } 8937 }, { 8938 key: "isRetina", 8939 value: function isRetina() { 8940 return window.devicePixelRatio && window.devicePixelRatio >= 2; 8941 } 8942 }, { 8943 key: "isTouchDevice", 8944 value: function isTouchDevice() { 8945 return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; 8946 } 8947 }, { 8948 key: "isDoctype", 8949 value: function isDoctype(target) { 8950 const doc = target || document; 8951 if (doc.compatMode) { 8952 return doc.compatMode === 'CSS1Compat'; 8953 } 8954 return doc.documentElement && doc.documentElement.clientHeight; 8955 } 8956 }, { 8957 key: "isLocalStorageSupported", 8958 value: function isLocalStorageSupported() { 8959 try { 8960 localStorage.setItem('test', 'test'); 8961 localStorage.removeItem('test'); 8962 return true; 8963 } catch (e) { 8964 return false;
8965 } 8966 } 8967 }, { 8968 key: "addGlobalClass", 8969 value: function addGlobalClass(target) { 8970 let globalClass = 'bx-core'; 8971 target = Type.isElementNode(target) ? target : document.documentElement; 8972 if (Dom.hasClass(target, globalClass)) { 8973 return; 8974 } 8975 if (Browser.isIOS()) { 8976 globalClass += ' bx-ios'; 8977 } else if (Browser.isWin()) { 8978 globalClass += ' bx-win'; 8979 } else if (Browser.isMac()) { 8980 globalClass += ' bx-mac'; 8981 } else if (Browser.isLinux()) { 8982 globalClass += ' bx-linux'; 8983 } else if (Browser.isAndroid()) { 8984 globalClass += ' bx-android'; 8985 } 8986 globalClass += Browser.isMobile() ? ' bx-touch' : ' bx-no-touch'; 8987 globalClass += Browser.isRetina() ? ' bx-retina' : ' bx-no-retina'; 8988 if (/AppleWebKit/.test(navigator.userAgent)) { 8989 globalClass += ' bx-chrome'; 8990 } else if (/Opera/.test(navigator.userAgent)) { 8991 globalClass += ' bx-opera'; 8992 } else if (Browser.isFirefox()) { 8993 globalClass += ' bx-firefox'; 8994 } 8995 Dom.addClass(target, globalClass); 8996 } 8997 }, { 8998 key: "detectAndroidVersion", 8999 value: function detectAndroidVersion() { 9000 const re = new RegExp('Android ([0-9]+[.0-9]*)'); 9001 if (re.exec(navigator.userAgent) != null) { 9002 const res = navigator.userAgent.match(re); 9003 if (Type.isArrayLike(res) && res.length > 0) { 9004 return parseFloat(res[1]); 9005 } 9006 } 9007 return 0; 9008 } 9009 }, { 9010 key: "isPropertySupported", 9011 value: function isPropertySupported(jsProperty, returnCSSName) { 9012 if (jsProperty === '') { 9013 return false; 9014 } 9015 function getCssName(propertyName) { 9016 return propertyName.replace(/([A-Z])/g, (...args) => `-${args[1].toLowerCase()}`); 9017 } 9018 function getJsName(cssName) { 9019 const reg = /(\\-([a-z]))/g; 9020 if (reg.test(cssName)) { 9021 return cssName.replace(reg, (...args) => args[2].toUpperCase()); 9022 } 9023 return cssName; 9024 } 9025 const property = jsProperty.includes('-') ? getJsName(jsProperty) : jsProperty; 9026 const bReturnCSSName = !!returnCSSName; 9027 const ucProperty = property.charAt(0).toUpperCase() + property.slice(1); 9028 const props = ['Webkit', 'Moz', 'O', 'ms'].join(`${ucProperty} `); 9029 const properties = `${property} ${props} ${ucProperty}`.split(' '); 9030 const obj = document.body || document.documentElement; 9031 for (let i = 0; i < properties.length; i += 1) { 9032 const prop = properties[i]; 9033 if (obj && 'style' in obj && prop in obj.style) { 9034 const lowerProp = prop.substr(0, prop.length - property.length).toLowerCase(); 9035 const prefix = prop === property ? '' : `-${lowerProp}-`; 9036 return bReturnCSSName ? prefix + getCssName(property) : prop; 9037 } 9038 } 9039 return false; 9040 } 9041 }, { 9042 key: "addGlobalFeatures", 9043 value: function addGlobalFeatures(features) { 9044 if (!Type.isArray(features)) { 9045 return; 9046 } 9047 const classNames = []; 9048 for (let i = 0; i < features.length; i += 1) { 9049 const support = !!Browser.isPropertySupported(features[i]); 9050 classNames.push(`bx-${support ? '' : 'no-'}${features[i].toLowerCase()}`); 9051 } 9052 Dom.addClass(document.documentElement, classNames.join(' ')); 9053 } 9054 }]); 9055 return Browser; 9056 }(); 9057 9058 let Cookie = /*#__PURE__*/function () { 9059 function Cookie() { 9060 babelHelpers.classCallCheck(this, Cookie); 9061 } 9062 babelHelpers.createClass(Cookie, null, [{ 9063 key: "getList", 9064 /** 9065 * Gets cookies list for current domain 9066 * @return {object} 9067 */ 9068 value: function getList() { 9069 return document.cookie.split(';').map(item => item.split('=')).map(item => item.map(subItem => subItem.trim())).reduce((acc, item) => { 9070 const [key, value] = item; 9071 acc[decodeURIComponent(key)] = decodeURIComponent(value); 9072 return acc; 9073 }, {}); 9074 } 9075 /** 9076 * Gets cookie value 9077 * @param {string} name 9078 * @return {*} 9079 */ 9080 }, { 9081 key: "get", 9082 value: function get(name) { 9083 const cookiesList = Cookie.getList(); 9084 if (name in cookiesList) { 9085 return cookiesList[name]; 9086 } 9087 return undefined; 9088 } 9089 /** 9090 * Sets cookie 9091 * @param {string} name 9092 * @param {*} value 9093 * @param {object} [options] 9094 */ 9095 }, { 9096 key: "set", 9097 value: function set(name, value, options = {}) { 9098 const attributes = { 9099 expires: '', 9100 ...options 9101 }; 9102 if (Type.isNumber(attributes.expires)) { 9103 const now = +new Date(); 9104 const days = attributes.expires; 9105 const dayInMs = 864e+5; 9106 attributes.expires = new Date(now + days * dayInMs); 9107 } 9108 if (Type.isDate(attributes.expires)) { 9109 attributes.expires = attributes.expires.toUTCString(); 9110 } 9111 const safeName = decodeURIComponent(String(name)).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape); 9112 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); 9113 const stringifiedAttributes = Object.keys(attributes).reduce((acc, key) => { 9114 const attributeValue = attributes[key]; 9115 if (!attributeValue) { 9116 return acc; 9117 } 9118 if (attributeValue === true) { 9119 return `${acc}; ${key}`; 9120 } 9121 9122 /** 9123 * Considers RFC 6265 section 5.2: 9124 * ... 9125 * 3. If the remaining unparsed-attributes contains a %x3B (';') 9126 * character: 9127 * Consume the characters of the unparsed-attributes up to, 9128 * not including, the first %x3B (';') character. 9129 */ 9130 return `${acc}; ${key}=${attributeValue.split(';')[0]}`; 9131 }, ''); 9132 document.cookie = `${safeName}=${safeValue}${stringifiedAttributes}`; 9133 } 9134 /** 9135 * Removes cookie 9136 * @param {string} name 9137 * @param {object} [options] 9138 */ 9139 }, { 9140 key: "remove", 9141 value: function remove(name, options = {}) { 9142 Cookie.set(name, '', { 9143 ...options, 9144 expires: -1 9145 }); 9146 } 9147 }]); 9148 return Cookie; 9149 }(); 9150 9151 function objectToFormData(source, formData = new FormData(), pre = null) { 9152 if (Type.isUndefined(source)) { 9153 return formData; 9154 } 9155 if (Type.isNull(source)) { 9156 formData.append(pre, ''); 9157 } else if (Type.isArray(source)) { 9158 if (!source.length) {
9159 const key = `${pre}[]`; 9160 formData.append(key, ''); 9161 } else { 9162 source.forEach((value, index) => { 9163 const key = `${pre}[${index}]`; 9164 objectToFormData(value, formData, key); 9165 }); 9166 } 9167 } else if (Type.isDate(source)) { 9168 formData.append(pre, source.toISOString()); 9169 } else if (Type.isObject(source) && !Type.isFile(source) && !Type.isBlob(source)) { 9170 Object.keys(source).forEach(property => { 9171 const value = source[property]; 9172 let preparedProperty = property; 9173 if (Type.isArray(value)) { 9174 while (property.length > 2 && property.lastIndexOf('[]') === property.length - 2) { 9175 preparedProperty = property.substring(0, property.length - 2); 9176 } 9177 } 9178 const key = pre ? `${pre}[${preparedProperty}]` : preparedProperty; 9179 objectToFormData(value, formData, key); 9180 }); 9181 } else { 9182 formData.append(pre, source); 9183 } 9184 return formData; 9185 } 9186 9187 let Data = /*#__PURE__*/function () { 9188 function Data() { 9189 babelHelpers.classCallCheck(this, Data); 9190 } 9191 babelHelpers.createClass(Data, null, [{ 9192 key: "convertObjectToFormData", 9193 /** 9194 * Converts object to FormData 9195 * @param source 9196 * @return {FormData} 9197 */ 9198 value: function convertObjectToFormData(source) { 9199 return objectToFormData(source); 9200 } 9201 }]); 9202 return Data; 9203 }(); 9204 9205 /** 9206 * @memberOf BX 9207 */ 9208 let Http = function Http() { 9209 babelHelpers.classCallCheck(this, Http); 9210 }; 9211 babelHelpers.defineProperty(Http, "Cookie", Cookie); 9212 babelHelpers.defineProperty(Http, "Data", Data); 9213 9214 function message(value) { 9215 if (Type.isString(value)) { 9216 if (Type.isNil(message[value])) { 9217 // eslint-disable-next-line 9218 EventEmitter.emit('onBXMessageNotFound', new BaseEvent({ 9219 compatData: [value] 9220 })); 9221 if (Type.isNil(message[value])) { 9222 Runtime.debug(`message undefined: ${value}`); 9223 message[value] = ''; 9224 } 9225 } 9226 } 9227 if (Type.isPlainObject(value)) { 9228 Object.keys(value).forEach(key => { 9229 message[key] = value[key]; 9230 }); 9231 } 9232 return message[value]; 9233 } 9234 if (!Type.isNil(window.BX) && Type.isFunction(window.BX.message)) { 9235 Object.keys(window.BX.message).forEach(key => { 9236 message({ 9237 [key]: window.BX.message[key] 9238 }); 9239 }); 9240 } 9241 9242 /** 9243 * Implements interface for works with language messages 9244 * @memberOf BX 9245 */ 9246 let Loc = /*#__PURE__*/function () { 9247 function Loc() { 9248 babelHelpers.classCallCheck(this, Loc); 9249 } 9250 babelHelpers.createClass(Loc, null, [{ 9251 key: "getMessage", 9252 /** 9253 * Gets message by id 9254 * @param {string} messageId 9255 * @param {object} replacements 9256 * @return {?string} 9257 */ 9258 value: function getMessage(messageId, replacements = null) { 9259 let mess = message(messageId); 9260 if (Type.isString(mess) && Type.isPlainObject(replacements)) { 9261 const escape = str => String(str).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&'); 9262 Object.keys(replacements).forEach(replacement => { 9263 const globalRegexp = new RegExp(escape(replacement), 'gi'); 9264 mess = mess.replace(globalRegexp, () => { 9265 return Type.isNil(replacements[replacement]) ? '' : String(replacements[replacement]); 9266 }); 9267 }); 9268 } 9269 return mess; 9270 } 9271 }, { 9272 key: "hasMessage", 9273 value: function hasMessage(messageId) { 9274 return Type.isString(messageId) && !Type.isNil(message[messageId]); 9275 } 9276 /** 9277 * Sets message or messages 9278 * @param {string | Object<string, string>} id 9279 * @param {string} [value] 9280 */ 9281 }, { 9282 key: "setMessage", 9283 value: function setMessage(id, value) { 9284 if (Type.isString(id) && Type.isString(value)) { 9285 message({ 9286 [id]: value 9287 }); 9288 } 9289 if (Type.isObject(id)) { 9290 message(id); 9291 } 9292 } 9293 /** 9294 * Gets plural message by id and number 9295 * @param {string} messageId 9296 * @param {number} value 9297 * @param {object} [replacements] 9298 * @return {?string} 9299 */ 9300 }, { 9301 key: "getMessagePlural",
9302 value: function getMessagePlural(messageId, value, replacements = null) { 9303 let result = ''; 9304 if (Type.isNumber(value)) { 9305 if (this.hasMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`)) { 9306 result = this.getMessage(`${messageId}_PLURAL_${this.getPluralForm(value)}`, replacements); 9307 } else { 9308 result = this.getMessage(`${messageId}_PLURAL_1`, replacements); 9309 } 9310 } else { 9311 result = this.getMessage(messageId, replacements); 9312 } 9313 return result; 9314 } 9315 /** 9316 * Gets language plural form id by number 9317 * see http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html 9318 * @param {number} value 9319 * @param {string} [languageId] 9320 * @return {?number} 9321 */ 9322 }, { 9323 key: "getPluralForm", 9324 value: function getPluralForm(value, languageId) { 9325 let pluralForm; 9326 if (!Type.isStringFilled(languageId)) { 9327 languageId = message('LANGUAGE_ID'); 9328 } 9329 if (value < 0) { 9330 value = -1 * value; 9331 } 9332 switch (languageId) { 9333 case 'ar': 9334 pluralForm = value !== 1 ? 1 : 0; 9335 /* 9336 if (value === 0) 9337 { 9338 pluralForm = 0; 9339 } 9340 else if (value === 1) 9341 { 9342 pluralForm = 1; 9343 } 9344 else if (value === 2) 9345 { 9346 pluralForm = 2; 9347 } 9348 else if ( 9349 value % 100 >= 3 9350 && value % 100 <= 10 9351 ) 9352 { 9353 pluralForm = 3; 9354 } 9355 else if (value % 100 >= 11) 9356 { 9357 pluralForm = 4; 9358 } 9359 else 9360 { 9361 pluralForm = 5; 9362 } 9363 */ 9364 break; 9365 case 'br': 9366 case 'fr': 9367 case 'tr': 9368 pluralForm = value > 1 ? 1 : 0; 9369 break; 9370 case 'de': 9371 case 'en': 9372 case 'hi': 9373 case 'it': 9374 case 'la': 9375 pluralForm = value !== 1 ? 1 : 0; 9376 break; 9377 case 'ru': 9378 case 'ua': 9379 if (value % 10 === 1 && value % 100 !== 11) { 9380 pluralForm = 0; 9381 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9382 pluralForm = 1; 9383 } else { 9384 pluralForm = 2; 9385 } 9386 break; 9387 case 'pl': 9388 if (value === 1) { 9389 pluralForm = 0; 9390 } else if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { 9391 pluralForm = 1; 9392 } else { 9393 pluralForm = 2; 9394 } 9395 break; 9396 case 'id': 9397 case 'ja': 9398 case 'ms': 9399 case 'sc': 9400 case 'tc': 9401 case 'th': 9402 case 'vn': 9403 pluralForm = 0; 9404 break; 9405 default: 9406 pluralForm = 1; 9407 break; 9408 } 9409 return pluralForm; 9410 } 9411 }]); 9412 return Loc; 9413 }(); 9414 9415 const voidElements = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr']; 9416 function isVoidElement(element) { 9417 return voidElements.includes(element); 9418 } 9419 9420 const matchers = { 9421 tag: /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>|{{uid[0-9]+}}/g, 9422 comment: /<!--(?!<!)[^\[>].*?-->/g, 9423 tagName: /<\/?([^\s]+?)[/\s>]/, 9424 attributes: /\s([\w\-_:.]+)\s?\n?=\s?\n?"([^"]+)?"|\s([\w\-_:.]+)\s?\n?=\s?\n?'([^']+)?'|\s([\w\-_:.]+)/gs, 9425 placeholder: /{{uid[0-9]+}}/g 9426 }; 9427 9428 function parseTag(tag) { 9429 const tagResult = { 9430 type: 'tag', 9431 name: '', 9432 svg: false, 9433 attrs: {}, 9434 children: [], 9435 voidElement: false 9436 }; 9437 if (tag.startsWith('<!--')) { 9438 const endIndex = tag.indexOf('-->'); 9439 const openTagLength = '<!--'.length; 9440 return { 9441 type: 'comment', 9442 content: endIndex !== -1 ? tag.slice(openTagLength, endIndex) : '' 9443 }; 9444 } 9445 const tagNameMatch = tag.match(matchers.tagName); 9446 if (Type.isArrayFilled(tagNameMatch)) { 9447 const [, tagName] = tagNameMatch; 9448 tagResult.name = tagName; 9449 tagResult.svg = tagName === 'svg'; 9450 tagResult.voidElement = isVoidElement(tagName) || tag.trim().endsWith('/>'); 9451 } 9452 const reg = new RegExp(matchers.attributes); 9453 for (;;) { 9454 const result = reg.exec(tag); 9455 if (!Type.isNil(result)) { 9456 // Attributes with double quotes 9457 const [, attrName, attrValue] = result; 9458 if (!Type.isNil(attrName)) { 9459 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9460 } else { 9461 // Attributes with single quotes 9462 const [,,, attrName, attrValue] = result; 9463 if (!Type.isNil(attrName)) { 9464 tagResult.attrs[attrName] = Type.isStringFilled(attrValue) ? attrValue : ''; 9465 } else { 9466 // Attributes without value 9467 const [,,,,, attrName] = result; 9468 tagResult.attrs[attrName] = ''; 9469 } 9470 } 9471 } else { 9472 break; 9473 } 9474 } 9475 return tagResult; 9476 } 9477 9478 function parseText(input) { 9479 const preparedText = input.replace(/[\n\r\t]$/, ''); 9480 const placeholders = preparedText.match(matchers.placeholder); 9481 return preparedText.split(matchers.placeholder).reduce((acc, item, index) => { 9482 if (Type.isStringFilled(item)) { 9483 acc.push(...item.split(/\n/).reduce((textAcc, text) => { 9484 const preparedItemText = text.replace(/[\t\r]/g, ''); 9485 if (Type.isStringFilled(preparedItemText)) { 9486 textAcc.push({ 9487 type: 'text', 9488 content: preparedItemText 9489 }); 9490 } 9491 return textAcc; 9492 }, [])); 9493 } 9494 if (placeholders && placeholders[index]) { 9495 acc.push({ 9496 type: 'placeholder', 9497 uid: parseInt(placeholders[index].replace(/{{uid|}}/, '')) 9498 }); 9499 } 9500 return acc; 9501 }, []); 9502 } 9503 9504 function parse(html, substitutions) { 9505 const result = []; 9506 if (html.indexOf('<') !== 0 && !html.startsWith('{{')) { 9507 const end = html.indexOf('<'); 9508 result.push(...parseText(end === -1 ? html : html.slice(0, end))); 9509 } 9510 const commentsContent = []; 9511 let commentIndex = -1; 9512 html = html.replace(matchers.comment, tag => { 9513 commentIndex += 1; 9514 commentsContent.push(tag.replace(/^<!--|-->$/g, '')); 9515 return `<!--{{cUid${commentIndex}}}-->`; 9516 }); 9517 const arr = []; 9518 let level = -1; 9519 let current; 9520 html.replace(matchers.tag, (tag, index) => { 9521 const start = index + tag.length; 9522 const nextChar = html.charAt(start); 9523 let parent; 9524 if (tag.startsWith('<!--')) { 9525 const comment = parseTag(tag, substitutions); 9526 comment.content = commentsContent[tag.replace(/<!--{{cUid|}}-->/g, '')]; 9527 if (level < 0) { 9528 result.push(comment); 9529 return result; 9530 } 9531 parent = arr[level]; 9532 parent.children.push(comment); 9533 return result; 9534 } 9535 if (tag.startsWith('{{')) { 9536 const [placeholder] = parseText(tag); 9537 if (level < 0) { 9538 result.push(placeholder); 9539 return result; 9540 } 9541 parent = arr[level]; 9542 parent.children.push(placeholder); 9543 return result; 9544 } 9545 if (!tag.startsWith('</')) { 9546 level++; 9547 current = parseTag(tag, substitutions); 9548 if (!current.voidElement && nextChar && nextChar !== '<') { 9549 current.children.push(...parseText(html.slice(start, html.indexOf('<', start)))); 9550 } 9551 if (level === 0) { 9552 result.push(current); 9553 } 9554 parent = arr[level - 1]; 9555 if (parent) { 9556 if (!current.svg) { 9557 current.svg = parent.svg; 9558 } 9559 parent.children.push(current); 9560 } 9561 arr[level] = current; 9562 } 9563 if (tag.startsWith('</') || current.voidElement) { 9564 if (level > -1 && (current.voidElement || current.name === tag.slice(2, -1))) { 9565 level--; 9566 current = level === -1 ? result : arr[level]; 9567 } 9568 if (nextChar && nextChar !== '<') { 9569 parent = level === -1 ? result : arr[level].children; 9570 const end = html.indexOf('<', start); 9571 const content = html.slice(start, end === -1 ? undefined : end); 9572 if (end >
9572 -1 && level + parent.length >= 0 || content !== ' ') { 9573 parent.push(...parseText(content)); 9574 } 9575 } 9576 } 9577 }); 9578 return result; 9579 } 9580 9581 const appendElement = (current, target) => { 9582 if (Type.isDomNode(current) && Type.isDomNode(target)) { 9583 if (target.nodeName !== 'TEMPLATE') { 9584 Dom.append(current, target); 9585 } else { 9586 // eslint-disable-next-line bitrix-rules/no-native-dom-methods 9587 target.content.append(current); 9588 } 9589 } 9590 }; 9591 function renderNode(options) { 9592 const { 9593 node, 9594 parentElement, 9595 substitutions 9596 } = options; 9597 if (node.type === 'tag') { 9598 const element = (() => { 9599 if (node.svg) { 9600 return document.createElementNS('http://www.w3.org/2000/svg', node.name); 9601 } 9602 return document.createElement(node.name); 9603 })(); 9604 Object.entries(node.attrs).forEach(([key, value]) => { 9605 if (key.startsWith('on') && new RegExp(matchers.placeholder).test(value)) { 9606 const substitution = substitutions[parseInt(value.replace(/{{uid|}}/, '')) - 1]; 9607 if (Type.isFunction(substitution)) { 9608 const bindFunctionName = key.endsWith('once') ? 'bindOnce' : 'bind'; 9609 Event[bindFunctionName](element, key.replace(/^on|once$/g, ''), substitution); 9610 } else { 9611 element.setAttribute(key, substitution); 9612 } 9613 } else { 9614 if (new RegExp(matchers.placeholder).test(value)) { 9615 const preparedValue = value.split(/{{|}}/).reduce((acc, item) => { 9616 if (item.startsWith('uid')) { 9617 const substitution = substitutions[parseInt(item.replace('uid', '')) - 1]; 9618 return `${acc}${substitution}`; 9619 } 9620 return `${acc}${item}`; 9621 }, ''); 9622 element.setAttribute(key, preparedValue); 9623 } else { 9624 element.setAttribute(key, Text.decode(value)); 9625 } 9626 } 9627 }); 9628 node.children.forEach(childNode => { 9629 const result = renderNode({ 9630 node: childNode, 9631 parentElement: element, 9632 substitutions 9633 }); 9634 if (Type.isArray(result)) { 9635 result.forEach(subChildElement => { 9636 appendElement(subChildElement, element); 9637 }); 9638 } else { 9639 appendElement(result, element); 9640 } 9641 }); 9642 return element; 9643 } 9644 if (node.type === 'comment') { 9645 return document.createComment(node.content); 9646 } 9647 if (node.type === 'text') { 9648 if (parentElement) { 9649 if (parentElement.nodeName !== 'TEMPLATE') { 9650 parentElement.insertAdjacentHTML('beforeend', node.content); 9651 } else { 9652 parentElement.content.append(node.content); 9653 } 9654 return; 9655 } 9656 return document.createTextNode(node.content); 9657 } 9658 if (node.type === 'placeholder') { 9659 return substitutions[node.uid - 1]; 9660 } 9661 } 9662 9663 function render(sections, ...substitutions) { 9664 const html = sections.reduce((acc, item, index) => { 9665 if (index > 0) { 9666 const substitution = substitutions[index - 1]; 9667 if (Type.isString(substitution) || Type.isNumber(substitution)) { 9668 return `${acc}${substitution}${item}`; 9669 } 9670 return `${acc}{{uid${index}}}${item}`; 9671 } 9672 return acc; 9673 }, sections[0]).replace(/^[\r\n\t\s]+/gm, '').replace(/>[\n]+/g, '>').replace(/[}][\n]+/g, '}'); 9674 const ast = parse(html); 9675 if (ast.length === 1) { 9676 return renderNode({ 9677 node: ast[0], 9678 substitutions 9679 }); 9680 } 9681 if (ast.length > 1) { 9682 return ast.map(node => { 9683 return renderNode({ 9684 node, 9685 substitutions 9686 }); 9687 }); 9688 } 9689 return false; 9690 } 9691 9692 function parseProps(sections, ...substitutions) { 9693 return substitutions.reduce((acc, item, index) => { 9694 const nextSectionIndex = index + 1; 9695 if (!Type.isPlainObject(item) && !Type.isArray(item)) { 9696 return acc + item + sections[nextSectionIndex]; 9697 } 9698 return `${acc}__s${index}${sections[nextSectionIndex]}`; 9699 }, sections[0]).replace(/[\r\t]/gm, '').split(';\n').map(item => item.replace(/\n/, '')).reduce((acc, item) => { 9700 if (item !== '') { 9701 const matches = item.match(/^[\w-. ]+:/); 9702 const splitted = item.split(/^[\w-. ]+:/);
9703 const key = matches[0].replace(':', '').trim(); 9704 const value = splitted[1].trim(); 9705 const substitutionPlaceholderExp = /^__s\d+/; 9706 if (substitutionPlaceholderExp.test(value)) { 9707 acc[key] = substitutions[value.replace('__s', '')]; 9708 return acc; 9709 } 9710 acc[key] = value; 9711 } 9712 return acc; 9713 }, {}); 9714 } 9715 9716 /** 9717 * @memberOf BX 9718 */ 9719 let Tag = /*#__PURE__*/function () { 9720 function Tag() { 9721 babelHelpers.classCallCheck(this, Tag); 9722 } 9723 babelHelpers.createClass(Tag, null, [{ 9724 key: "safe", 9725 /** 9726 * Encodes all substitutions 9727 * @param sections 9728 * @param substitutions 9729 * @return {string} 9730 */ 9731 value: function safe(sections, ...substitutions) { 9732 return substitutions.reduce((acc, item, index) => acc + Text.encode(item) + sections[index + 1], sections[0]); 9733 } 9734 /** 9735 * Decodes all substitutions 9736 * @param sections 9737 * @param substitutions 9738 * @return {string} 9739 */ 9740 }, { 9741 key: "unsafe", 9742 value: function unsafe(sections, ...substitutions) { 9743 return substitutions.reduce((acc, item, index) => acc + Text.decode(item) + sections[index + 1], sections[0]); 9744 } 9745 /** 9746 * Adds styles to specified element 9747 * @param {HTMLElement} element 9748 * @return {Function} 9749 */ 9750 }, { 9751 key: "style", 9752 value: function style(element) { 9753 if (!Type.isDomNode(element)) { 9754 throw new Error('element is not HTMLElement'); 9755 } 9756 return function styleTagHandler(...args) { 9757 Dom.style(element, parseProps(...args)); 9758 }; 9759 } 9760 /** 9761 * Replace all messages identifiers to real messages 9762 * @param sections 9763 * @param substitutions 9764 * @return {string} 9765 */ 9766 }, { 9767 key: "message", 9768 value: function message(sections, ...substitutions) { 9769 return substitutions.reduce((acc, item, index) => acc + Loc.getMessage(item) + sections[index + 1], sections[0]); 9770 } 9771 }, { 9772 key: "attrs", 9773 /** 9774 * Adds attributes to specified element 9775 * @param element 9776 * @return {Function} 9777 */ 9778 value: function attrs(element) { 9779 if (!Type.isDomNode(element)) { 9780 throw new Error('element is not HTMLElement'); 9781 } 9782 return function attrsTagHandler(...args) { 9783 Dom.attr(element, parseProps(...args)); 9784 }; 9785 } 9786 }]); 9787 return Tag; 9788 }(); 9789 babelHelpers.defineProperty(Tag, "render", render); 9790 babelHelpers.defineProperty(Tag, "attr", Tag.attrs); 9791 9792 function getParser(format) { 9793 switch (format) { 9794 case 'index': 9795 return (sourceKey, value, accumulator) => { 9796 const result = /\[(\w*)\]$/.exec(sourceKey); 9797 const key = sourceKey.replace(/\[\w*\]$/, ''); 9798 if (Type.isNil(result)) { 9799 accumulator[key] = value; 9800 return; 9801 } 9802 if (Type.isUndefined(accumulator[key])) { 9803 accumulator[key] = {}; 9804 } 9805 accumulator[key][result[1]] = value; 9806 }; 9807 case 'bracket': 9808 return (sourceKey, value, accumulator) => { 9809 const result = /(\[\])$/.exec(sourceKey); 9810 const key = sourceKey.replace(/\[\]$/, ''); 9811 if (Type.isNil(result)) { 9812 accumulator[key] = value; 9813 return; 9814 } 9815 if (Type.isUndefined(accumulator[key])) { 9816 accumulator[key] = [value]; 9817 return; 9818 } 9819 accumulator[key] = [].concat(accumulator[key], value); 9820 }; 9821 default: 9822 return (sourceKey, value, accumulator) => { 9823 const key = sourceKey.replace(/\[\]$/, ''); 9824 accumulator[key] = value; 9825 }; 9826 } 9827 } 9828 function getKeyFormat(key) { 9829 if (/^\w+\[([\w]+)\]$/.test(key)) { 9830 return 'index'; 9831 } 9832 if (/^\w+\[\]$/.test(key)) { 9833 return 'bracket'; 9834 } 9835 return 'default'; 9836 } 9837 function isAllowedKey(key) { 9838 return !String(key).startsWith('__proto__'); 9839 } 9840 function parseQuery(input) { 9841 if (!Type.isString(input)) { 9842 return {}; 9843 } 9844 const url = input.trim().replace(/^[?#&]/, ''); 9845 if (!url) { 9846 return {}; 9847 } 9848 return { 9849 ...url.split('&').reduce((acc, param) => { 9850 const [key, value] = param.replace(/\+/g, ' ').split('='); 9851 if (isAllowedKey(key)) {
9852 const keyFormat = getKeyFormat(key); 9853 const formatter = getParser(keyFormat); 9854 formatter(key, value, acc); 9855 } 9856 return acc; 9857 }, Object.create(null)) 9858 }; 9859 } 9860 const urlExp = /^((\w+):)?(\/\/((\w+)?(:(\w+))?@)?([^\/\?:]+)(:(\d+))?)?(\/?([^\/\?#][^\?#]*)?)?(\?([^#]+))?(#(\w*))?/; 9861 function parseUrl(url) { 9862 const result = url.match(urlExp); 9863 if (Type.isArray(result)) { 9864 const queryParams = parseQuery(result[14]); 9865 return { 9866 useShort: /^\/\//.test(url), 9867 href: result[0] || '', 9868 schema: result[2] || '', 9869 host: result[8] || '', 9870 port: result[10] || '', 9871 path: result[11] || '', 9872 query: result[14] || '', 9873 queryParams, 9874 hash: result[16] || '', 9875 username: result[5] || '', 9876 password: result[7] || '', 9877 origin: result[8] || '' 9878 }; 9879 } 9880 return {}; 9881 } 9882 9883 function buildQueryString(params = {}) { 9884 const queryString = Object.keys(params).reduce((acc, key) => { 9885 if (Type.isArray(params[key])) { 9886 params[key].forEach(paramValue => { 9887 acc.push(`${key}[]=${paramValue}`); 9888 }, ''); 9889 } 9890 if (Type.isPlainObject(params[key])) { 9891 Object.keys(params[key]).forEach(paramIndex => { 9892 acc.push(`${key}[${paramIndex}]=${params[key][paramIndex]}`); 9893 }, ''); 9894 } 9895 if (!Type.isObject(params[key]) && !Type.isArray(params[key])) { 9896 acc.push(`${key}=${params[key]}`); 9897 } 9898 return acc; 9899 }, []).join('&'); 9900 if (queryString.length > 0) { 9901 return `?${queryString}`; 9902 } 9903 return queryString; 9904 } 9905 9906 function prepareParamValue(value) { 9907 if (Type.isArray(value)) { 9908 return value.map(item => String(item)); 9909 } 9910 if (Type.isPlainObject(value)) { 9911 return { 9912 ...value 9913 }; 9914 } 9915 return String(value); 9916 } 9917 9918 const map = new WeakMap(); 9919 9920 /** 9921 * Implements interface for works with URI 9922 * @memberOf BX 9923 */ 9924 let Uri = /*#__PURE__*/function () { 9925 babelHelpers.createClass(Uri, null, [{ 9926 key: "addParam", 9927 value: function addParam(url, params = {}) { 9928 return new Uri(url).setQueryParams(params).toString(); 9929 } 9930 }, { 9931 key: "removeParam", 9932 value: function removeParam(url, params) { 9933 const removableParams = Type.isArray(params) ? params : [params]; 9934 return new Uri(url).removeQueryParam(...removableParams).toString(); 9935 } 9936 }]); 9937 function Uri(url = '') { 9938 babelHelpers.classCallCheck(this, Uri); 9939 map.set(this, parseUrl(url)); 9940 } 9941 9942 /** 9943 * Gets schema 9944 * @return {?string} 9945 */ 9946 babelHelpers.createClass(Uri, [{ 9947 key: "getSchema", 9948 value: function getSchema() { 9949 return map.get(this).schema; 9950 } 9951 /** 9952 * Sets schema 9953 * @param {string} schema 9954 * @return {Uri} 9955 */ 9956 }, { 9957 key: "setSchema", 9958 value: function setSchema(schema) { 9959 map.get(this).schema = String(schema); 9960 return this; 9961 } 9962 /** 9963 * Gets host 9964 * @return {?string} 9965 */ 9966 }, { 9967 key: "getHost", 9968 value: function getHost() { 9969 return map.get(this).host; 9970 } 9971 /** 9972 * Sets host 9973 * @param {string} host 9974 * @return {Uri} 9975 */ 9976 }, { 9977 key: "setHost", 9978 value: function setHost(host) { 9979 map.get(this).host = String(host); 9980 return this; 9981 } 9982 /** 9983 * Gets port 9984 * @return {?string} 9985 */ 9986 }, { 9987 key: "getPort", 9988 value: function getPort() { 9989 return map.get(this).port; 9990 } 9991 /** 9992 * Sets port 9993 * @param {String | Number} port 9994 * @return {Uri} 9995 */ 9996 }, { 9997 key: "setPort", 9998 value: function setPort(port) { 9999 map.get(this).port = String(port); 10000 return this; 10001 } 10002 /** 10003 * Gets path 10004 * @return {?string} 10005 */ 10006 }, { 10007 key: "getPath", 10008 value: function getPath() { 10009 return map.get(this).path; 10010 } 10011 /** 10012 * Sets path 10013 * @param {string} path 10014 * @return {Uri} 10015 */ 10016 }, { 10017 key: "setPath", 10018 value: function setPath(path) { 10019 if (!/^\//.test(path)) { 10020 map.get(this).path = `/${String(path)}`; 10021 return this; 10022 } 10023 map.get(this).path = String(path); 10024 return this; 10025 } 10026 /** 10027 * Gets query 10028 * @return {?string} 10029 */ 10030 }, { 10031 key: "getQuery", 10032 value: function getQuery() { 10033 return buildQueryString(map.get(this).queryParams); 10034 } 10035 /** 10036 * Gets query param value by name 10037 * @param {string} key 10038 * @return {?string} 10039 */ 10040 }, { 10041 key: "getQueryParam", 10042 value: function getQueryParam(key) { 10043 const params = this.getQueryParams(); 10044 if (Object.hasOwn(params, key)) { 10045 return params[key]; 10046 } 10047 return null; 10048 } 10049 /** 10050 * Sets query param 10051 * @param {string} key 10052 * @param [value] 10053 * @return {Uri} 10054 */ 10055 }, { 10056 key: "setQueryParam", 10057 value: function setQueryParam(key, value = '') { 10058 map.get(this).queryParams[key] = prepareParamValue(value); 10059 return this; 10060 } 10061 /** 10062 * Gets query params 10063 * @return {Object<string, any>} 10064 */ 10065 }, { 10066 key: "getQueryParams", 10067 value: function getQueryParams() { 10068 return { 10069 ...map.get(this).queryParams 10070 }; 10071 } 10072 /** 10073 * Sets query params 10074 * @param {Object<string, any>} params 10075 * @return {Uri} 10076 */ 10077 }, { 10078 key: "setQueryParams", 10079 value: function setQueryParams(params = {}) {
10080 const currentParams = this.getQueryParams(); 10081 const newParams = { 10082 ...currentParams, 10083 ...params 10084 }; 10085 Object.keys(newParams).forEach(key => { 10086 newParams[key] = prepareParamValue(newParams[key]); 10087 }); 10088 map.get(this).queryParams = newParams; 10089 return this; 10090 } 10091 /** 10092 * Removes query params by name 10093 * @param keys 10094 * @return {Uri} 10095 */ 10096 }, { 10097 key: "removeQueryParam", 10098 value: function removeQueryParam(...keys) { 10099 const currentParams = { 10100 ...map.get(this).queryParams 10101 }; 10102 keys.forEach(key => { 10103 if (Object.hasOwn(currentParams, key)) { 10104 delete currentParams[key]; 10105 } 10106 }); 10107 map.get(this).queryParams = currentParams; 10108 return this; 10109 } 10110 /** 10111 * Gets fragment 10112 * @return {?string} 10113 */ 10114 }, { 10115 key: "getFragment", 10116 value: function getFragment() { 10117 return map.get(this).hash; 10118 } 10119 /** 10120 * Sets fragment 10121 * @param {string} hash 10122 * @return {Uri} 10123 */ 10124 }, { 10125 key: "setFragment", 10126 value: function setFragment(hash) { 10127 map.get(this).hash = String(hash); 10128 return this; 10129 } 10130 /** 10131 * Serializes URI 10132 * @return {Object} 10133 */ 10134 }, { 10135 key: "serialize", 10136 value: function serialize() { 10137 const serialized = { 10138 ...map.get(this) 10139 }; 10140 serialized.href = this.toString(); 10141 return serialized; 10142 } 10143 /** 10144 * Gets URI string 10145 * @return {string} 10146 */ 10147 }, { 10148 key: "toString", 10149 value: function toString() { 10150 const data = { 10151 ...map.get(this) 10152 }; 10153 let protocol = data.schema ? `${data.schema}://` : ''; 10154 if (data.useShort) { 10155 protocol = '//'; 10156 } 10157 const port = (() => { 10158 if (Type.isString(data.port) && !['', '80'].includes(data.port)) { 10159 return `:${data.port}`; 10160 } 10161 return ''; 10162 })(); 10163 const host = this.getHost(); 10164 const path = this.getPath(); 10165 const query = buildQueryString(data.queryParams); 10166 const hash = data.hash ? `#${data.hash}` : ''; 10167 return `${host ? protocol : ''}${host}${host ? port : ''}${path}${query}${hash}`; 10168 } 10169 }]); 10170 return Uri; 10171 }(); 10172 10173 /** 10174 * @memberOf BX 10175 */ 10176 let Validation = /*#__PURE__*/function () { 10177 function Validation() { 10178 babelHelpers.classCallCheck(this, Validation); 10179 } 10180 babelHelpers.createClass(Validation, null, [{ 10181 key: "isEmail", 10182 /** 10183 * Checks that value is valid email 10184 * @param value 10185 * @return {boolean} 10186 */ 10187 value: function isEmail(value) { 10188 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])?)*$/; 10189 return exp.test(String(value).toLowerCase()); 10190 } 10191 }]); 10192 return Validation; 10193 }(); 10194 10195 let BaseCache = /*#__PURE__*/function () { 10196 function BaseCache() { 10197 babelHelpers.classCallCheck(this, BaseCache); 10198 babelHelpers.defineProperty(this, "storage", new Map()); 10199 } 10200 babelHelpers.createClass(BaseCache, [{ 10201 key: "get", 10202 /** 10203 * Gets cached value or default value 10204 */ 10205 value: function get(key, defaultValue) { 10206 if (!this.storage.has(key)) { 10207 if (Type.isFunction(defaultValue)) { 10208 return defaultValue(); 10209 } 10210 if (!Type.isUndefined(defaultValue)) { 10211 return defaultValue; 10212 } 10213 } 10214 return this.storage.get(key); 10215 } 10216 /** 10217 * Sets cache entry 10218 */ 10219 }, { 10220 key: "set", 10221 value: function set(key, value) { 10222 this.storage.set(key, value); 10223 } 10224 /** 10225 * Deletes cache entry 10226 */ 10227 }, { 10228 key: "delete", 10229 value: function _delete(key) { 10230 this.storage.delete(key); 10231 } 10232 /** 10233 * Checks that storage contains entry with specified key 10234 */ 10235 }, { 10236 key: "has", 10237 value: function has(key) { 10238 return this.storage.has(key); 10239 } 10240 /** 10241 * Gets cached value if exists, 10242 */ 10243 }, { 10244 key: "remember", 10245 value: function remember(key, defaultValue) { 10246 if (!this.storage.has(key)) { 10247 if (Type.isFunction(defaultValue)) { 10248 this.storage.set(key, defaultValue()); 10249 } else if (!Type.isUndefined(defaultValue)) { 10250 this.storage.set(key, defaultValue); 10251 } 10252 } 10253 return this.storage.get(key); 10254 } 10255 /** 10256 * Gets storage size 10257 */ 10258 }, { 10259 key: "size", 10260 value: function size() { 10261 return this.storage.size; 10262 } 10263 /** 10264 * Gets storage keys 10265 */ 10266 }, { 10267 key: "keys", 10268 value: function keys() { 10269 return [...this.storage.keys()]; 10270 } 10271 /** 10272 * Gets storage values 10273 */ 10274 }, { 10275 key: "values", 10276 value: function values() { 10277 return [...this.storage.values()]; 10278 } 10279 }]); 10280 return BaseCache; 10281 }(); 10282 10283 let MemoryCache = /*#__PURE__*/function (_BaseCache) { 10284 babelHelpers.inherits(MemoryCache, _BaseCache); 10285 function MemoryCache(...args) { 10286 var _this; 10287 babelHelpers.classCallCheck(this, MemoryCache); 10288 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(MemoryCache).call(this, ...args)); 10289 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new Map()); 10290 return _this; 10291 } 10292 return MemoryCache; 10293 }(BaseCache); 10294 10295 let LsStorage = /*#__PURE__*/function () { 10296 function LsStorage() { 10297 babelHelpers.classCallCheck(this, LsStorage); 10298 babelHelpers.defineProperty(this, "stackKey", 'BX.Cache.Storage.LsStorage.stack'); 10299 babelHelpers.defineProperty(this, "stack", null); 10300 } 10301 babelHelpers.createClass(LsStorage, [{ 10302 key: "getStack", 10303 /** 10304 * @private 10305 */ 10306 value: function getStack() { 10307 if (Type.isPlainObject(this.stack)) { 10308 return this.stack; 10309 } 10310 const stack = localStorage.getItem(this.stackKey); 10311 if (Type.isString(stack) && stack !== '') { 10312 const parsedStack = JSON.parse(stack); 10313 if (Type.isPlainObject(parsedStack)) { 10314 this.stack = parsedStack; 10315 return this.stack; 10316 } 10317 } 10318 this.stack = {}; 10319 return this.stack; 10320 } 10321 /** 10322 * @private 10323 */ 10324 }, { 10325 key: "saveStack", 10326 value: function saveStack() { 10327 if (Type.isPlainObject(this.stack)) { 10328 const preparedStack = JSON.stringify(this.stack); 10329 localStorage.setItem(this.stackKey, preparedStack); 10330 } 10331 } 10332 }, { 10333 key: "get", 10334 value: function get(key) {
10335 const stack = this.getStack(); 10336 return stack[key]; 10337 } 10338 }, { 10339 key: "set", 10340 value: function set(key, value) { 10341 const stack = this.getStack(); 10342 stack[key] = value; 10343 this.saveStack(); 10344 } 10345 }, { 10346 key: "delete", 10347 value: function _delete(key) { 10348 const stack = this.getStack(); 10349 if (key in stack) { 10350 delete stack[key]; 10351 } 10352 } 10353 }, { 10354 key: "has", 10355 value: function has(key) { 10356 const stack = this.getStack(); 10357 return key in stack; 10358 } 10359 }, { 10360 key: "keys", 10361 value: function keys() { 10362 const stack = this.getStack(); 10363 return Object.keys(stack); 10364 } 10365 }, { 10366 key: "values", 10367 value: function values() { 10368 const stack = this.getStack(); 10369 return Object.values(stack); 10370 } 10371 }, { 10372 key: "size", 10373 get: function () { 10374 const stack = this.getStack(); 10375 return Object.keys(stack).length; 10376 } 10377 }]); 10378 return LsStorage; 10379 }(); 10380 10381 let LocalStorageCache = /*#__PURE__*/function (_BaseCache) { 10382 babelHelpers.inherits(LocalStorageCache, _BaseCache); 10383 function LocalStorageCache(...args) { 10384 var _this; 10385 babelHelpers.classCallCheck(this, LocalStorageCache); 10386 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(LocalStorageCache).call(this, ...args)); 10387 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "storage", new LsStorage()); 10388 return _this; 10389 } 10390 return LocalStorageCache; 10391 }(BaseCache); 10392 10393 /** 10394 * @memberOf BX 10395 */ 10396 let Cache = function Cache() { 10397 babelHelpers.classCallCheck(this, Cache); 10398 }; 10399 babelHelpers.defineProperty(Cache, "MemoryCache", MemoryCache); 10400 babelHelpers.defineProperty(Cache, "LocalStorageCache", LocalStorageCache); 10401 10402 function convertPath(path) { 10403 if (Type.isStringFilled(path)) { 10404 return path.split('.').reduce((acc, item) => { 10405 item.split(/\[['"]?(.+?)['"]?\]/g).forEach(key => { 10406 if (Type.isStringFilled(key)) { 10407 acc.push(key); 10408 } 10409 }); 10410 return acc; 10411 }, []); 10412 } 10413 return []; 10414 } 10415 10416 let SettingsCollection = /*#__PURE__*/function () { 10417 function SettingsCollection(options = {}) { 10418 babelHelpers.classCallCheck(this, SettingsCollection); 10419 if (Type.isPlainObject(options)) { 10420 Object.assign(this, options); 10421 } 10422 } 10423 babelHelpers.createClass(SettingsCollection, [{ 10424 key: "get", 10425 value: function get(path, defaultValue = null) { 10426 const convertedPath = convertPath(path); 10427 return convertedPath.reduce((acc, key) => { 10428 if (!Type.isNil(acc) && acc !== defaultValue) { 10429 if (!Type.isUndefined(acc[key])) { 10430 return acc[key]; 10431 } 10432 return defaultValue; 10433 } 10434 return acc; 10435 }, this); 10436 } 10437 }]); 10438 return SettingsCollection; 10439 }(); 10440 10441 function deepFreeze(target) { 10442 if (Type.isObject(target)) { 10443 Object.values(target).forEach(value => { 10444 deepFreeze(value); 10445 }); 10446 return Object.freeze(target); 10447 } 10448 return target; 10449 } 10450 10451 const settingsStorage = new Map(); 10452 let Extension$1 = /*#__PURE__*/function () { 10453 function Extension() { 10454 babelHelpers.classCallCheck(this, Extension); 10455 } 10456 babelHelpers.createClass(Extension, null, [{ 10457 key: "getSettings", 10458 value: function getSettings(extensionName) { 10459 if (Type.isStringFilled(extensionName)) { 10460 if (settingsStorage.has(extensionName)) { 10461 return settingsStorage.get(extensionName); 10462 } 10463 const settingsScriptNode = document.querySelector(`script[data-extension="${extensionName}"]`); 10464 if (Type.isDomNode(settingsScriptNode)) { 10465 const decodedSettings = (() => { 10466 try { 10467 return new SettingsCollection(JSON.parse(settingsScriptNode.innerHTML)); 10468 } catch (error) { 10469 return new SettingsCollection(); 10470 } 10471 })(); 10472 const frozenSettings = deepFreeze(decodedSettings); 10473 settingsStorage.set(extensionName, frozenSettings); 10474 return frozenSettings; 10475 } 10476 } 10477 return deepFreeze(new SettingsCollection()); 10478 } 10479 }]); 10480 return Extension; 10481 }(); 10482 10483 let _Symbol$iterator; 10484 function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); } 10485 function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 10486 function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 10487 var _searchIndexToInsert = /*#__PURE__*/new WeakSet(); 10488 _Symbol$iterator = Symbol.iterator; 10489 let OrderedArray = /*#__PURE__*/function () { 10490 function OrderedArray(comparator = null) { 10491 babelHelpers.classCallCheck(this, OrderedArray); 10492 _classPrivateMethodInitSpec(this, _searchIndexToInsert); 10493 babelHelpers.defineProperty(this, "comparator", null); 10494 babelHelpers.defineProperty(this, "items", []); 10495 this.comparator = Type.isFunction(comparator) ? comparator : null; 10496 } 10497 babelHelpers.createClass(OrderedArray, [{ 10498 key: "add", 10499 value: function add(item) { 10500 let index = -1; 10501 if (this.comparator) { 10502 index = _classPrivateMethodGet(this, _searchIndexToInsert, _searchIndexToInsert2).call(this, item); 10503 this.items.splice(index, 0, item); 10504 } else { 10505 this.items.push(item); 10506 } 10507 return index; 10508 } 10509 }, { 10510 key: "has", 10511 value: function has(item) { 10512 return this.items.includes(item); 10513 } 10514 }, { 10515 key: "getIndex", 10516 value: function getIndex(item) { 10517 return this.items.indexOf(item); 10518 } 10519 }, { 10520 key: "getByIndex", 10521 value: function getByIndex(index) { 10522 if (Type.isNumber(index) && index >= 0) { 10523 const item = this.items[index]; 10524 return Type.isUndefined(item) ? null : item; 10525 } 10526 return null; 10527 } 10528 }, { 10529 key: "getFirst", 10530 value: function getFirst() { 10531 const first = this.items[0]; 10532 return Type.isUndefined(first) ? null : first; 10533 } 10534 }, { 10535 key: "getLast", 10536 value: function getLast() { 10537 const last = this.items[this.count() - 1]; 10538 return Type.isUndefined(last) ? null : last; 10539 } 10540 }, { 10541 key: "count", 10542 value: function count() { 10543 return this.items.length; 10544 } 10545 }, { 10546 key: "delete", 10547 value: function _delete(item) { 10548 const index = this.getIndex(item); 10549 if (index !== -1) { 10550 this.items.splice(index, 1); 10551 return true; 10552 } 10553 return false;
10554 } 10555 }, { 10556 key: "clear", 10557 value: function clear() { 10558 this.items = []; 10559 } 10560 }, { 10561 key: _Symbol$iterator, 10562 value: function () { 10563 return this.items[Symbol.iterator](); 10564 } 10565 }, { 10566 key: "forEach", 10567 value: function forEach(callbackfn, thisArg) { 10568 return this.items.forEach(callbackfn, thisArg); 10569 } 10570 }, { 10571 key: "getAll", 10572 value: function getAll() { 10573 return this.items; 10574 } 10575 }, { 10576 key: "getComparator", 10577 value: function getComparator() { 10578 return this.comparator; 10579 } 10580 }, { 10581 key: "sort", 10582 value: function sort() { 10583 const comparator = this.getComparator(); 10584 if (comparator === null) { 10585 return; 10586 } 10587 10588 /* 10589 Simple implementation 10590 this.items.sort((item1, item2) => { 10591 return comparator(item1, item2); 10592 }); 10593 */ 10594 10595 // For stable sorting https://v8.dev/features/stable-sort 10596 const length = this.items.length; 10597 const indexes = new Array(length); 10598 for (let i = 0; i < length; i++) { 10599 indexes[i] = i; 10600 } 10601 10602 // If the comparator returns zero, use the original indexes 10603 indexes.sort((index1, index2) => { 10604 return comparator(this.items[index1], this.items[index2]) || index1 - index2; 10605 }); 10606 for (let i = 0; i < length; i++) { 10607 indexes[i] = this.items[indexes[i]]; 10608 } 10609 for (let i = 0; i < length; i++) { 10610 this.items[i] = indexes[i]; 10611 } 10612 } 10613 }]); 10614 return OrderedArray; 10615 }(); 10616 function _searchIndexToInsert2(value) { 10617 let low = 0; 10618 let high = this.items.length; 10619 while (low < high) { 10620 const mid = Math.floor((low + high) / 2); 10621 if (this.comparator(this.items[mid], value) >= 0) { 10622 high = mid; 10623 } else { 10624 low = mid + 1; 10625 } 10626 } 10627 return low; 10628 } 10629 10630 let ZIndexComponent = /*#__PURE__*/function (_EventEmitter) { 10631 babelHelpers.inherits(ZIndexComponent, _EventEmitter); 10632 function ZIndexComponent(element, componentOptions = {}) { 10633 var _this; 10634 babelHelpers.classCallCheck(this, ZIndexComponent); 10635 _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(ZIndexComponent).call(this)); 10636 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "sort", 0); 10637 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "alwaysOnTop", false); 10638 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "zIndex", 0); 10639 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "element", null); 10640 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlay", null); 10641 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlayGap", -5); 10642 babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "stack", null); 10643 _this.setEventNamespace('BX.Main.ZIndexManager.Component'); 10644 if (!Type.isElementNode(element)) { 10645 throw new Error('ZIndexManager.Component: The argument \'element\' must be a DOM element.'); 10646 } 10647 _this.element = element; 10648 const options = Type.isPlainObject(componentOptions) ? componentOptions : {}; 10649 _this.setAlwaysOnTop(options.alwaysOnTop); 10650 _this.setOverlay(options.overlay); 10651 _this.setOverlayGap(options.overlayGap); 10652 _this.subscribeFromOptions(options.events); 10653 return _this; 10654 } 10655 babelHelpers.createClass(ZIndexComponent, [{ 10656 key: "getSort", 10657 value: function getSort() { 10658 return this.sort; 10659 } 10660 /** 10661 * @internal 10662 * @param sort 10663 */ 10664 }, { 10665 key: "setSort", 10666 value: function setSort(sort) { 10667 if (Type.isNumber(sort)) { 10668 this.sort = sort; 10669 } 10670 } 10671 /** 10672 * @internal 10673 * @param stack 10674 */ 10675 }, { 10676 key: "setStack", 10677 value: function setStack(stack) { 10678 this.stack = stack; 10679 } 10680 }, { 10681 key: "getStack", 10682 value: function getStack() { 10683 return this.stack; 10684 } 10685 }, { 10686 key: "getZIndex", 10687 value: function getZIndex() { 10688 return this.zIndex; 10689 } 10690 /** 10691 * @internal 10692 */ 10693 }, { 10694 key: "setZIndex", 10695 value: function setZIndex(zIndex) { 10696 const changed = this.getZIndex() !== zIndex; 10697 this.getElement().style.setProperty('z-index', zIndex, 'important'); 10698 this.zIndex = zIndex; 10699 if (this.getOverlay() !== null) { 10700 this.getOverlay().style.setProperty('z-index', zIndex + this.getOverlayGap(), 'important'); 10701 } 10702 if (changed) {
10703 this.emit('onZIndexChange', { 10704 component: this 10705 }); 10706 } 10707 } 10708 }, { 10709 key: "getAlwaysOnTop", 10710 value: function getAlwaysOnTop() { 10711 return this.alwaysOnTop; 10712 } 10713 }, { 10714 key: "setAlwaysOnTop", 10715 value: function setAlwaysOnTop(value) { 10716 if (Type.isNumber(value) || Type.isBoolean(value)) { 10717 this.alwaysOnTop = value; 10718 } 10719 } 10720 }, { 10721 key: "getElement", 10722 value: function getElement() { 10723 return this.element; 10724 } 10725 }, { 10726 key: "setOverlay", 10727 value: function setOverlay(overlay, gap) { 10728 if (Type.isElementNode(overlay) || overlay === null) { 10729 this.overlay = overlay; 10730 this.setOverlayGap(gap); 10731 if (this.getStack()) { 10732 this.getStack().sort(); 10733 } 10734 } 10735 } 10736 }, { 10737 key: "getOverlay", 10738 value: function getOverlay() { 10739 return this.overlay; 10740 } 10741 }, { 10742 key: "setOverlayGap", 10743 value: function setOverlayGap(gap) { 10744 if (Type.isNumber(gap)) { 10745 this.overlayGap = gap; 10746 } 10747 } 10748 }, { 10749 key: "getOverlayGap", 10750 value: function getOverlayGap() { 10751 return this.overlayGap; 10752 } 10753 }]); 10754 return ZIndexComponent; 10755 }(EventEmitter); 10756 10757 let ZIndexStack = /*#__PURE__*/function () { 10758 function ZIndexStack(container) { 10759 babelHelpers.classCallCheck(this, ZIndexStack); 10760 babelHelpers.defineProperty(this, "container", null); 10761 babelHelpers.defineProperty(this, "components", null); 10762 babelHelpers.defineProperty(this, "elements", new WeakMap()); 10763 babelHelpers.defineProperty(this, "baseIndex", 1000); 10764 babelHelpers.defineProperty(this, "baseStep", 50); 10765 babelHelpers.defineProperty(this, "sortCount", 0); 10766 if (!Type.isDomNode(container)) { 10767 throw new Error('ZIndexManager.Stack: The \'container\' argument must be a DOM element.'); 10768 } 10769 this.container = container; 10770 const comparator = (componentA, componentB) => { 10771 let result = (componentA.getAlwaysOnTop() || 0) - (componentB.getAlwaysOnTop() || 0); 10772 if (!result) { 10773 result = componentA.getSort() - componentB.getSort(); 10774 } 10775 return result; 10776 }; 10777 this.components = new OrderedArray(comparator); 10778 } 10779 babelHelpers.createClass(ZIndexStack, [{ 10780 key: "getBaseIndex", 10781 value: function getBaseIndex() { 10782 return this.baseIndex; 10783 } 10784 }, { 10785 key: "setBaseIndex", 10786 value: function setBaseIndex(index) { 10787 if (Type.isNumber(index) && index >= 0) { 10788 this.baseIndex = index; 10789 this.sort(); 10790 } 10791 } 10792 }, { 10793 key: "setBaseStep", 10794 value: function setBaseStep(step) { 10795 if (Type.isNumber(step) && step > 0) { 10796 this.baseStep = step; 10797 this.sort(); 10798 } 10799 } 10800 }, { 10801 key: "getBaseStep", 10802 value: function getBaseStep() { 10803 return this.baseStep; 10804 } 10805 }, { 10806 key: "register", 10807 value: function register(element, options = {}) { 10808 if (this.getComponent(element)) { 10809 console.warn('ZIndexManager: You cannot register the element twice.', element); 10810 return this.getComponent(element); 10811 } 10812 const component = new ZIndexComponent(element, options); 10813 component.setStack(this); 10814 component.setSort(++this.sortCount); 10815 this.elements.set(element, component); 10816 this.components.add(component); 10817 this.sort(); 10818 return component; 10819 } 10820 }, { 10821 key: "unregister", 10822 value: function unregister(element) { 10823 const component = this.elements.get(element); 10824 this.components.delete(component); 10825 this.elements.delete(element); 10826 this.sort(); 10827 } 10828 }, { 10829 key: "getComponent", 10830 value: function getComponent(element) { 10831 return this.elements.get(element) || null; 10832 } 10833 }, { 10834 key: "getComponents", 10835 value: function getComponents() { 10836 return this.components.getAll(); 10837 } 10838 }, { 10839 key: "getMaxZIndex", 10840 value: function getMaxZIndex() { 10841 const last = this.components.getLast(); 10842 return last ? last.getZIndex() : this.baseIndex; 10843 } 10844 }, { 10845 key: "sort", 10846 value: function sort() { 10847 this.components.sort(); 10848 let zIndex = this.baseIndex;
10849 this.components.forEach(component => { 10850 component.setZIndex(zIndex); 10851 zIndex += this.baseStep; 10852 }); 10853 } 10854 }, { 10855 key: "bringToFront", 10856 value: function bringToFront(element) { 10857 const component = this.getComponent(element); 10858 if (!component) { 10859 console.error('ZIndexManager: element was not found in the stack.', element); 10860 return null; 10861 } 10862 component.setSort(++this.sortCount); 10863 this.sort(); 10864 return component; 10865 } 10866 }]); 10867 return ZIndexStack; 10868 }(); 10869 10870 function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; } 10871 function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } } 10872 /** 10873 * @memberof BX 10874 */ 10875 let ZIndexManager = /*#__PURE__*/function () { 10876 function ZIndexManager() { 10877 babelHelpers.classCallCheck(this, ZIndexManager); 10878 } 10879 babelHelpers.createClass(ZIndexManager, null, [{ 10880 key: "register", 10881 value: function register(element, options = {}) { 10882 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10883 if (!parentNode) { 10884 return null; 10885 } 10886 const stack = this.getOrAddStack(parentNode); 10887 return stack.register(element, options); 10888 } 10889 }, { 10890 key: "unregister", 10891 value: function unregister(element) { 10892 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10893 const stack = this.getStack(parentNode); 10894 if (stack) { 10895 stack.unregister(element); 10896 } 10897 } 10898 }, { 10899 key: "addStack", 10900 value: function addStack(container) { 10901 const stack = new ZIndexStack(container); 10902 this.stacks.set(container, stack); 10903 return stack; 10904 } 10905 }, { 10906 key: "getStack", 10907 value: function getStack(container) { 10908 return this.stacks.get(container) || null; 10909 } 10910 }, { 10911 key: "getOrAddStack", 10912 value: function getOrAddStack(container) { 10913 return this.getStack(container) || this.addStack(container); 10914 } 10915 }, { 10916 key: "getComponent", 10917 value: function getComponent(element) { 10918 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element, true); 10919 if (!parentNode) { 10920 return null; 10921 } 10922 const stack = this.getStack(parentNode); 10923 return stack ? stack.getComponent(element) : null; 10924 } 10925 }, { 10926 key: "bringToFront", 10927 value: function bringToFront(element) { 10928 const parentNode = _classStaticPrivateMethodGet(this, ZIndexManager, _getParentNode).call(this, element); 10929 const stack = this.getStack(parentNode); 10930 if (stack) { 10931 return stack.bringToFront(element); 10932 } 10933 return null; 10934 } 10935 }]); 10936 return ZIndexManager; 10937 }(); 10938 function _getParentNode(element, suppressWarnings = false) { 10939 if (!Type.isElementNode(element)) { 10940 if (!suppressWarnings) { 10941 console.error('ZIndexManager: The argument \'element\' must be a DOM element.', element); 10942 } 10943 return null; 10944 } else if (!Type.isElementNode(element.parentNode)) { 10945 if (!suppressWarnings) { 10946 console.error('ZIndexManager: The \'element\' doesn\'t have a parent node.', element); 10947 } 10948 return null; 10949 } 10950 return element.parentNode; 10951 } 10952 babelHelpers.defineProperty(ZIndexManager, "stacks", new WeakMap()); 10953 10954 var collections = { 10955 OrderedArray 10956 }; 10957 10958 function getElement(element) { 10959 if (Type.isString(element)) { 10960 return document.getElementById(element); 10961 } 10962 return element; 10963 } 10964 10965 function getWindow(element) { 10966 if (Type.isElementNode(element)) { 10967 return element.ownerDocument.parentWindow || element.ownerDocument.defaultView || window; 10968 } 10969 if (Type.isDomNode(element)) { 10970 return element.parentWindow || element.defaultView || window; 10971 } 10972 return window; 10973 } 10974 10975 /* eslint-disable prefer-rest-params */ 10976 10977 // BX.* 10978 const { 10979 getClass, 10980 namespace 10981 } = Reflection; 10982 const message$1 = message; 10983 10984 /** 10985 * @memberOf BX 10986 */ 10987 const { 10988 replace, 10989 remove, 10990 clean, 10991 insertBefore, 10992 insertAfter, 10993 append, 10994 prepend, 10995 style, 10996 adjust, 10997 create, 10998 isShown 10999 } = Dom; 11000 const addClass = function addClass() { 11001 Dom.addClass(...Runtime.merge([], Array.from(arguments), [getElement(arguments[0])])); 11002 }; 11003 const removeClass = function removeClass() { 11004 Dom.removeClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11005 }; 11006 const hasClass = function hasClass() { 11007 return Dom.hasClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11008 }; 11009 const toggleClass = function toggleClass() { 11010 Dom.toggleClass(...Runtime.merge(Array.from(arguments), [getElement(arguments[0])])); 11011 }; 11012 const cleanNode = (element, removeElement = false) => { 11013 const currentElement = getElement(element); 11014 if (Type.isDomNode(currentElement)) { 11015 Dom.clean(currentElement); 11016 if (removeElement) { 11017 Dom.remove(currentElement); 11018 return currentElement; 11019 } 11020 } 11021 return currentElement; 11022 }; 11023 const getCookie = Http.Cookie.get;
11024 const setCookie = (name, value, options = {}) => { 11025 const attributes = { 11026 ...options 11027 }; 11028 if (Type.isNumber(attributes.expires)) { 11029 attributes.expires /= 3600 * 24; 11030 } 11031 Http.Cookie.set(name, value, attributes); 11032 }; 11033 const { 11034 bind: bind$1, 11035 unbind: unbind$1, 11036 unbindAll: unbindAll$1, 11037 bindOnce: bindOnce$1, 11038 ready: ready$1 11039 } = Event; 11040 const { 11041 debugState: debugEnableFlag, 11042 isDebugEnabled: debugStatus, 11043 default: debug$1 11044 } = debugNs; 11045 const debugEnable = value => { 11046 if (value) { 11047 enableDebug(); 11048 } else { 11049 disableDebug(); 11050 } 11051 }; 11052 const { 11053 clone: clone$1, 11054 loadExtension: loadExt, 11055 debounce, 11056 throttle, 11057 html 11058 } = Runtime; 11059 11060 // BX.type 11061 const type = { 11062 ...Object.getOwnPropertyNames(Type).filter(key => !['name', 'length', 'prototype', 'caller', 'arguments'].includes(key)).reduce((acc, key) => { 11063 acc[key] = Type[key]; 11064 return acc; 11065 }, {}), 11066 isNotEmptyString: value => Type.isString(value) && value !== '', 11067 isNotEmptyObject: value => Type.isObjectLike(value) && Object.keys(value).length > 0, 11068 isMapKey: Type.isObject, 11069 stringToInt: value => { 11070 const parsed = parseInt(value); 11071 return !Number.isNaN(parsed) ? parsed : 0; 11072 } 11073 }; 11074 11075 // BX.browser 11076 const browser = { 11077 IsOpera: Browser.isOpera, 11078 IsIE: Browser.isIE, 11079 IsIE6: Browser.isIE6, 11080 IsIE7: Browser.isIE7, 11081 IsIE8: Browser.isIE8, 11082 IsIE9: Browser.isIE9, 11083 IsIE10: Browser.isIE10, 11084 IsIE11: Browser.isIE11, 11085 IsSafari: Browser.isSafari, 11086 IsFirefox: Browser.isFirefox, 11087 IsChrome: Browser.isChrome, 11088 DetectIeVersion: Browser.detectIEVersion, 11089 IsMac: Browser.isMac, 11090 IsAndroid: Browser.isAndroid, 11091 isIPad: Browser.isIPad, 11092 isIPhone: Browser.isIPhone, 11093 IsIOS: Browser.isIOS, 11094 IsMobile: Browser.isMobile, 11095 isRetina: Browser.isRetina, 11096 IsDoctype: Browser.isDoctype, 11097 SupportLocalStorage: Browser.isLocalStorageSupported, 11098 addGlobalClass: Browser.addGlobalClass, 11099 DetectAndroidVersion: Browser.detectAndroidVersion, 11100 isPropertySupported: Browser.isPropertySupported, 11101 addGlobalFeatures: Browser.addGlobalFeatures 11102 }; 11103 11104 // eslint-disable-next-line 11105 const ajax = window.BX ? window.BX.ajax : () => {}; 11106 function GetWindowScrollSize(doc = document) { 11107 return { 11108 scrollWidth: doc.documentElement.scrollWidth, 11109 scrollHeight: doc.documentElement.scrollHeight 11110 }; 11111 } 11112 function GetWindowScrollPos(doc = document) { 11113 const win = getWindow(doc); 11114 return { 11115 scrollLeft: win.pageXOffset, 11116 scrollTop: win.pageYOffset 11117 }; 11118 } 11119 function GetWindowInnerSize(doc = document) { 11120 const win = getWindow(doc); 11121 return { 11122 innerWidth: win.innerWidth, 11123 innerHeight: win.innerHeight 11124 }; 11125 } 11126 function GetWindowSize(doc = document) { 11127 return { 11128 ...GetWindowInnerSize(doc), 11129 ...GetWindowScrollPos(doc), 11130 ...GetWindowScrollSize(doc) 11131 }; 11132 } 11133 function GetContext(node) { 11134 return getWindow(node); 11135 } 11136 function pos(element, relative = false) { 11137 if (!element) { 11138 return new DOMRect().toJSON(); 11139 } 11140 if (element.ownerDocument === document && !relative) { 11141 const clientRect = element.getBoundingClientRect(); 11142 const root = document.documentElement; 11143 const { 11144 body 11145 } = document; 11146 return { 11147 top: Math.round(clientRect.top + (root.scrollTop || body.scrollTop)), 11148 left: Math.round(clientRect.left + (root.scrollLeft || body.scrollLeft)), 11149 width: Math.round(clientRect.right - clientRect.left), 11150 height: Math.round(clientRect.bottom - clientRect.top), 11151 right: Math.round(clientRect.right + (root.scrollLeft || body.scrollLeft)), 11152 bottom: Math.round(clientRect.bottom + (root.scrollTop || body.scrollTop)) 11153 }; 11154 } 11155 let x = 0; 11156 let y = 0; 11157 const w = element.offsetWidth; 11158 const h = element.offsetHeight; 11159 let first = true; 11160 11161 // eslint-disable-next-line no-param-reassign 11162 for (; element != null; element = element.offsetParent) { 11163 if (!first && relative && BX.is_relative(element)) { 11164 break; 11165 } 11166 x += element.offsetLeft; 11167 y += element.offsetTop; 11168 if (first) { 11169 first = false; 11170 // eslint-disable-next-line no-continue 11171 continue; 11172 } 11173 x += Text.toNumber(Dom.style(element, 'border-left-width')); 11174 y += Text.toNumber(Dom.style(element, 'border-top-width')); 11175 } 11176 return new DOMRect(x, y, w, h).toJSON(); 11177 } 11178 function addCustomEvent(eventObject, eventName, eventHandler) { 11179 if (Type.isString(eventObject)) { 11180 eventHandler = eventName; 11181 eventName = eventObject; 11182 eventObject = EventEmitter.GLOBAL_TARGET;
11183 } 11184 if (eventObject === window) { 11185 eventObject = EventEmitter.GLOBAL_TARGET; 11186 } 11187 if (!Type.isObject(eventObject)) { 11188 console.error('The "eventObject" argument must be an object. Received type ' + typeof eventObject + '.'); 11189 return; 11190 } 11191 if (!Type.isStringFilled(eventName)) { 11192 console.error('The "eventName" argument must be a string.'); 11193 return; 11194 } 11195 if (!Type.isFunction(eventHandler)) { 11196 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11197 return; 11198 } 11199 eventName = eventName.toLowerCase(); 11200 EventEmitter.subscribe(eventObject, eventName, eventHandler, { 11201 compatMode: true, 11202 useGlobalNaming: true 11203 }); 11204 } 11205 function onCustomEvent(eventObject, eventName, eventParams, secureParams) { 11206 if (Type.isString(eventObject)) { 11207 secureParams = eventParams; 11208 eventParams = eventName; 11209 eventName = eventObject; 11210 eventObject = EventEmitter.GLOBAL_TARGET; 11211 } 11212 if (!Type.isObject(eventObject) || eventObject === window) { 11213 eventObject = EventEmitter.GLOBAL_TARGET;
11214 } 11215 if (!eventParams) { 11216 eventParams = []; 11217 } 11218 eventName = eventName.toLowerCase(); 11219 const event = new BaseEvent(); 11220 event.setData(eventParams); 11221 event.setCompatData(eventParams); 11222 EventEmitter.emit(eventObject, eventName, event, { 11223 cloneData: secureParams === true, 11224 useGlobalNaming: true 11225 }); 11226 } 11227 function removeCustomEvent(eventObject, eventName, eventHandler) { 11228 if (Type.isString(eventObject)) { 11229 eventHandler = eventName; 11230 eventName = eventObject; 11231 eventObject = EventEmitter.GLOBAL_TARGET; 11232 } 11233 if (!Type.isFunction(eventHandler)) { 11234 console.error('The "eventHandler" argument must be a function. Received type ' + typeof eventHandler + '.'); 11235 return; 11236 } 11237 if (eventObject === window) { 11238 eventObject = EventEmitter.GLOBAL_TARGET; 11239 } 11240 eventName = eventName.toLowerCase(); 11241 EventEmitter.unsubscribe(eventObject, eventName, eventHandler, { 11242 useGlobalNaming: true 11243 }); 11244 } 11245 function removeAllCustomEvents(eventObject, eventName) { 11246 if (Type.isString(eventObject)) { 11247 eventName = eventObject; 11248 eventObject = EventEmitter.GLOBAL_TARGET;
11249 } 11250 if (eventObject === window) { 11251 eventObject = EventEmitter.GLOBAL_TARGET; 11252 } 11253 eventName = eventName.toLowerCase(); 11254 EventEmitter.unsubscribeAll(eventObject, eventName, { 11255 useGlobalNaming: true 11256 }); 11257 } 11258 11259 if (typeof global === 'object' && global.window && global.window.BX) { 11260 Object.assign(global.window.BX, exports); 11261 } 11262 11263 exports.Type = Type; 11264 exports.Reflection = Reflection; 11265 exports.Text = Text; 11266 exports.Dom = Dom; 11267 exports.Browser = Browser; 11268 exports.Event = Event; 11269 exports.Http = Http; 11270 exports.Runtime = Runtime; 11271 exports.Loc = Loc; 11272 exports.Tag = Tag; 11273 exports.Uri = Uri; 11274 exports.Validation = Validation; 11275 exports.Cache = Cache; 11276 exports.BaseError = BaseError; 11277 exports.Extension = Extension$1; 11278 exports.ZIndexManager = ZIndexManager; 11279 exports.Collections = collections; 11280 exports.getClass = getClass; 11281 exports.namespace = namespace; 11282 exports.message = message$1; 11283 exports.replace = replace; 11284 exports.remove = remove; 11285 exports.clean = clean; 11286 exports.insertBefore = insertBefore; 11287 exports.insertAfter = insertAfter; 11288 exports.append = append; 11289 exports.prepend = prepend; 11290 exports.style = style; 11291 exports.adjust = adjust; 11292 exports.create = create; 11293 exports.isShown = isShown; 11294 exports.addClass = addClass; 11295 exports.removeClass = removeClass; 11296 exports.hasClass = hasClass; 11297 exports.toggleClass = toggleClass; 11298 exports.cleanNode = cleanNode; 11299 exports.getCookie = getCookie; 11300 exports.setCookie = setCookie; 11301 exports.bind = bind$1; 11302 exports.unbind = unbind$1; 11303 exports.unbindAll = unbindAll$1; 11304 exports.bindOnce = bindOnce$1; 11305 exports.ready = ready$1; 11306 exports.debugEnableFlag = debugEnableFlag; 11307 exports.debugStatus = debugStatus; 11308 exports.debug = debug$1; 11309 exports.debugEnable = debugEnable; 11310 exports.clone = clone$1; 11311 exports.loadExt = loadExt; 11312 exports.debounce = debounce; 11313 exports.throttle = throttle; 11314 exports.html = html; 11315 exports.type = type; 11316 exports.browser = browser; 11317 exports.ajax = ajax; 11318 exports.GetWindowScrollSize = GetWindowScrollSize; 11319 exports.GetWindowScrollPos = GetWindowScrollPos; 11320 exports.GetWindowInnerSize = GetWindowInnerSize; 11321 exports.GetWindowSize = GetWindowSize; 11322 exports.GetContext = GetContext; 11323 exports.pos = pos; 11324 exports.addCustomEvent = addCustomEvent; 11325 exports.onCustomEvent = onCustomEvent; 11326 exports.removeCustomEvent = removeCustomEvent; 11327 exports.removeAllCustomEvents = removeAllCustomEvents; 11328 11329}((this.BX = this.BX || {}))); 11330 11331 11332 11333(function(BX) { 11334 /* list of registered proxy functions */ 11335 var proxyList = new WeakMap(); 11336 var deferList = new WeakMap(); 11337 11338 /* List of denied event handlers */ 11339 var deniedEvents = []; 11340 11341 /* list of registered custom events */ 11342 var customEvents = new WeakMap(); 11343 var customEventsCnt = 0; 11344 11345 /* list of external garbage collectors */ 11346 var garbageCollectors = []; 11347 11348 /* list of loaded CSS files */ 11349 var cssList = []; 11350 var cssInit = false; 11351 11352 /* list of loaded JS files */ 11353 var jsList = []; 11354 var jsInit = false; 11355 11356 var eventTypes = { 11357 click: 'MouseEvent', 11358 dblclick: 'MouseEvent', 11359 mousedown: 'MouseEvent', 11360 mousemove: 'MouseEvent', 11361 mouseout: 'MouseEvent', 11362 mouseover: 'MouseEvent', 11363 mouseup: 'MouseEvent', 11364 focus: 'MouseEvent', 11365 blur: 'MouseEvent' 11366 }; 11367 11368 var lastWait = []; 11369 11370 var CHECK_FORM_ELEMENTS = {tagName: /^INPUT|SELECT|TEXTAREA|BUTTON$/i}; 11371 11372 BX.MSLEFT = 1; 11373 BX.MSMIDDLE = 2; 11374 BX.MSRIGHT = 4; 11375 11376 BX.AM_PM_UPPER = 1; 11377 BX.AM_PM_LOWER = 2; 11378 BX.AM_PM_NONE = false; 11379 11380 BX.ext = function(ob) 11381 { 11382 for (var i in ob) 11383 { 11384 if(ob.hasOwnProperty(i)) 11385 { 11386 this[i] = ob[i]; 11387 } 11388 } 11389 }; 11390 11391 var r = { 11392 script: /<script([^>]*)>/ig, 11393 script_end: /<\/script>/ig, 11394 script_src: /src=["\']([^"\']+)["\']/i, 11395 script_type: /type=["\']([^"\']+)["\']/i, 11396 space: /\s+/, 11397 ltrim: /^[\s\r\n]+/g, 11398 rtrim: /[\s\r\n]+$/g, 11399 style: /<link.*?(rel="stylesheet"|type="text\/css")[^>]*>/i, 11400 style_href: /href=["\']([^"\']+)["\']/i 11401 }; 11402 11403 BX.processHTML = function(data, scriptsRunFirst) 11404 { 11405 var matchScript, matchStyle, matchSrc, matchHref, matchType, scripts = [], styles = []; 11406 var textIndexes = []; 11407 var lastIndex = r.script.lastIndex = r.script_end.lastIndex = 0; 11408 11409 while ((matchScript = r.script.exec(data)) !== null) 11410 { 11411 r.script_end.lastIndex = r.script.lastIndex; 11412 var matchScriptEnd = r.script_end.exec(data); 11413 if (matchScriptEnd === null) 11414 { 11415 break; 11416 } 11417 11418 // skip script tags of special types 11419 var skipTag = false;
11420 if ((matchType = matchScript[1].match(r.script_type)) !== null) 11421 { 11422 if( 11423 matchType[1] == 'text/html' 11424 || matchType[1] == 'text/template' 11425 || matchType[1] == 'extension/settings' 11426 ) 11427 { 11428 skipTag = true; 11429 } 11430 } 11431 11432 if(skipTag) 11433 { 11434 textIndexes.push([lastIndex, r.script_end.lastIndex - lastIndex]); 11435 } 11436 else 11437 { 11438 textIndexes.push([lastIndex, matchScript.index - lastIndex]); 11439 11440 var bRunFirst = scriptsRunFirst || (matchScript[1].indexOf('bxrunfirst') != '-1'); 11441 11442 if ((matchSrc = matchScript[1].match(r.script_src)) !== null) 11443 { 11444 scripts.push({"bRunFirst": bRunFirst, "isInternal": false, "JS": matchSrc[1]}); 11445 } 11446 else 11447 { 11448 var start = matchScript.index + matchScript[0].length; 11449 var js = data.substr(start, matchScriptEnd.index-start); 11450 11451 scripts.push({"bRunFirst": bRunFirst, "isInternal": true, "JS": js}); 11452 } 11453 } 11454 11455 lastIndex = matchScriptEnd.index + 9; 11456 r.script.lastIndex = lastIndex; 11457 } 11458 11459 textIndexes.push([lastIndex, lastIndex === 0 ? data.length : data.length - lastIndex]); 11460 var pureData = ""; 11461 for (var i = 0, length = textIndexes.length; i < length; i++) 11462 { 11463 if (BX.type.isString(data) && BX.type.isFunction(data.substr)) 11464 { 11465 pureData += data.substr(textIndexes[i][0], textIndexes[i][1]); 11466 } 11467 } 11468 11469 while ((matchStyle = pureData.match(r.style)) !== null) 11470 { 11471 if ((matchHref = matchStyle[0].match(r.style_href)) !== null && matchStyle[0].indexOf('media="') < 0) 11472 { 11473 styles.push(matchHref[1]); 11474 } 11475 11476 pureData = pureData.replace(matchStyle[0], ''); 11477 } 11478 11479 return {'HTML': pureData, 'SCRIPT': scripts, 'STYLE': styles}; 11480 }; 11481 11482 /* OO emulation utility */ 11483 BX.extend = function(child, parent) 11484 { 11485 var f = function() {}; 11486 f.prototype = parent.prototype; 11487 11488 child.prototype = new f(); 11489 child.prototype.constructor = child; 11490 11491 child.superclass = parent.prototype; 11492 child.prototype.superclass = parent.prototype; 11493 if(parent.prototype.constructor == Object.prototype.constructor) 11494 { 11495 parent.prototype.constructor = parent; 11496 } 11497 }; 11498 11499 BX.is_subclass_of = function(ob, parent_class) 11500 { 11501 if (ob instanceof parent_class) 11502 return true; 11503 11504 if (parent_class.superclass) 11505 return BX.is_subclass_of(ob, parent_class.superclass); 11506 11507 return false; 11508 }; 11509 11510 BX.clearNodeCache = function() 11511 { 11512 return false; 11513 }; 11514 11515 BX.bitrix_sessid = function() {return BX.message("bitrix_sessid"); }; 11516 11517 /** 11518 * Creates document fragment with child nodes. 11519 * 11520 * @param {Node[]} nodes 11521 * @return {DocumentFragment} 11522 */ 11523 BX.createFragment = function(nodes) 11524 { 11525 var fragment = document.createDocumentFragment(); 11526 11527 if(!BX.type.isArray(nodes)) 11528 { 11529 return fragment; 11530 } 11531 for(var i = 0; i < nodes.length; i++) 11532 { 11533 fragment.appendChild(nodes[i]); 11534 } 11535 11536 return fragment; 11537 }; 11538 11539 /** 11540 * @deprecated 11541 * @use BX.style 11542 * @param element 11543 * @param opacity 11544 */ 11545 BX.setOpacity = function(element, opacity) 11546 { 11547 var opacityValue = parseFloat(opacity); 11548 11549 if (!isNaN(opacityValue) && BX.type.isDomNode(element)) 11550 { 11551 opacityValue = opacityValue < 1 ? opacityValue : opacityValue / 100; 11552 BX.style(element, 'opacity', opacityValue); 11553 } 11554 }; 11555 11556 /** 11557 * @deprecated 11558 * @param el 11559 * @return {*} 11560 */ 11561 BX.hoverEvents = function(el) 11562 { 11563 if (el) 11564 return BX.adjust(el, {events: BX.hoverEvents()}); 11565 else 11566 return {mouseover: BX.hoverEventsHover, mouseout: BX.hoverEventsHout}; 11567 }; 11568 11569 /** 11570 * @deprecated 11571 */ 11572 BX.hoverEventsHover = function(){BX.addClass(this,'bx-hover');this.BXHOVER=true;}; 11573 /** 11574 * @deprecated 11575 */ 11576 BX.hoverEventsHout = function(){BX.removeClass(this,'bx-hover');this.BXHOVER=false;}; 11577 11578 /** 11579 * @deprecated 11580 */ 11581 BX.focusEvents = function(el) 11582 { 11583 if (el) 11584 return BX.adjust(el, {events: BX.focusEvents()}); 11585 else 11586 return {mouseover: BX.focusEventsFocus, mouseout: BX.focusEventsBlur}; 11587 }; 11588 11589 /** 11590 * @deprecated 11591 */ 11592 BX.focusEventsFocus = function(){BX.addClass(this,'bx-focus');this.BXFOCUS=true;}; 11593 /** 11594 * @deprecated 11595 */ 11596 BX.focusEventsBlur = function(){BX.removeClass(this,'bx-focus');this.BXFOCUS=false;}; 11597 11598 BX.setUnselectable = function(node) 11599 { 11600 BX.style(node, { 11601 'userSelect': 'none', 11602 'MozUserSelect': 'none', 11603 'WebkitUserSelect': 'none', 11604 'KhtmlUserSelect': 'none', 11605 }); 11606 node.setAttribute('unSelectable', 'on'); 11607 }; 11608 11609 BX.setSelectable = function(node) 11610 { 11611 BX.style(node, { 11612 'userSelect': null, 11613 'MozUserSelect': null, 11614 'WebkitUserSelect': null, 11615 'KhtmlUserSelect': null, 11616 }); 11617 node.removeAttribute('unSelectable'); 11618 }; 11619 11620 BX.styleIEPropertyName = function(name) 11621 { 11622 if (name == 'float') 11623 name = BX.browser.IsIE() ? 'styleFloat' : 'cssFloat'; 11624 else 11625 { 11626 var res = BX.browser.isPropertySupported(name); 11627 if (res) 11628 { 11629 name = res; 11630 } 11631 else 11632 {
11633 var reg = /(\-([a-z]){1})/g; 11634 if (reg.test(name)) 11635 { 11636 name = name.replace(reg, function () {return arguments[2].toUpperCase();}); 11637 } 11638 } 11639 } 11640 return name; 11641 }; 11642 11643 BX.focus = function(el) 11644 { 11645 try 11646 { 11647 el.focus(); 11648 return true; 11649 } 11650 catch (e) 11651 { 11652 return false; 11653 } 11654 }; 11655 11656 BX.firstChild = function(el) 11657 { 11658 return BX.type.isDomNode(el) ? el.firstElementChild : null; 11659 }; 11660 11661 BX.lastChild = function(el) 11662 { 11663 return BX.type.isDomNode(el) ? el.lastElementChild : null; 11664 }; 11665 11666 BX.previousSibling = function(el) 11667 { 11668 return BX.type.isDomNode(el) ? el.previousElementSibling : null; 11669 }; 11670 11671 BX.nextSibling = function(el) 11672 { 11673 return BX.type.isDomNode(el) ? el.nextElementSibling : null; 11674 }; 11675 11676 /* 11677 params: { 11678 obj : html node 11679 className : className value 11680 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 11681 } 11682 11683 Search all nodes with className 11684 */ 11685 /** 11686 * @deprecated 11687 * @use .querySelectorAll 11688 * @param obj 11689 * @param className 11690 * @param recursive 11691 * @return {*} 11692 */ 11693 BX.findChildrenByClassName = function(obj, className, recursive) 11694 { 11695 if(!obj || !obj.childNodes) return null; 11696 11697 var result = []; 11698 if (typeof(obj.getElementsByClassName) == 'undefined') 11699 { 11700 recursive = recursive !== false; 11701 result = BX.findChildren(obj, {className : className}, recursive); 11702 } 11703 else 11704 { 11705 var col = obj.getElementsByClassName(className); 11706 for (i=0,l=col.length;i<l;i++) 11707 { 11708 result[i] = col[i]; 11709 } 11710 } 11711 return result; 11712 }; 11713 11714 /* 11715 params: { 11716 obj : html node 11717 className : className value 11718 recursive : used only for older browsers to optimize the tree traversal, in new browsers the search is always recursively, default - true 11719 } 11720 11721 Search first node with className 11722 */ 11723 /** 11724 * @deprecated 11725 * @use .querySelector 11726 * @param obj 11727 * @param className 11728 * @param recursive 11729 * @return {*} 11730 */ 11731 BX.findChildByClassName = function(obj, className, recursive) 11732 { 11733 if(!obj || !obj.childNodes) return null; 11734 11735 var result = null; 11736 if (typeof(obj.getElementsByClassName) == 'undefined') 11737 { 11738 recursive = recursive !== false; 11739 result = BX.findChild(obj, {className : className}, recursive); 11740 } 11741 else 11742 { 11743 var col = obj.getElementsByClassName(className); 11744 if (col && typeof(col[0]) != 'undefined') 11745 { 11746 result = col[0]; 11747 } 11748 else 11749 { 11750 result = null; 11751 } 11752 } 11753 return result; 11754 }; 11755 11756 /* 11757 params: { 11758 tagName|tag : 'tagName', 11759 className|class : 'className', 11760 attribute : {attribute : value, attribute : value} | attribute | [attribute, attribute....], 11761 property : {prop: value, prop: value} | prop | [prop, prop] 11762 } 11763 11764 all values can be RegExps or strings 11765 */ 11766 /** 11767 * @deprecated 11768 * @use .querySelectorAll 11769 * @param obj 11770 * @param params 11771 * @param recursive 11772 * @return {*|Node} 11773 */ 11774 BX.findChildren = function(obj, params, recursive) 11775 { 11776 return BX.findChild(obj, params, recursive, true); 11777 }; 11778 11779 /** 11780 * @deprecated 11781 * @use .querySelectorAll 11782 * @param obj 11783 * @param params 11784 * @param recursive 11785 * @param get_all 11786 * @return {*} 11787 */ 11788 BX.findChild = function(obj, params, recursive, get_all) 11789 { 11790 if(!obj || !obj.childNodes) return null; 11791 11792 recursive = !!recursive; get_all = !!get_all; 11793 11794 var n = obj.childNodes.length, result = []; 11795 11796 for (var j=0; j<n; j++) 11797 { 11798 var child = obj.childNodes[j]; 11799 11800 if (_checkNode(child, params)) 11801 { 11802 if (get_all) 11803 result.push(child); 11804 else 11805 return child; 11806 } 11807 11808 if(recursive == true) 11809 { 11810 var res = BX.findChild(child, params, recursive, get_all); 11811 if (res) 11812 { 11813 if (get_all) 11814 result = BX.util.array_merge(result, res); 11815 else 11816 return res; 11817 } 11818 } 11819 } 11820 11821 if (get_all || result.length > 0) 11822 return result; 11823 else 11824 return null; 11825 }; 11826 11827 /** 11828 * @deprecated 11829 * @use .closest() 11830 * @param obj 11831 * @param params 11832 * @param maxParent 11833 * @return {*} 11834 */ 11835 BX.findParent = function(obj, params, maxParent) 11836 { 11837 if(!obj) 11838 return null; 11839 11840 var o = obj; 11841 while(o.parentNode) 11842 { 11843 var parent = o.parentNode; 11844 11845 if (_checkNode(parent, params)) 11846 return parent; 11847 11848 o = parent; 11849 11850 if (!!maxParent &&
11851 (BX.type.isFunction(maxParent) 11852 || typeof maxParent == 'object')) 11853 { 11854 if (BX.type.isElementNode(maxParent)) 11855 { 11856 if (o == maxParent) 11857 break; 11858 } 11859 else 11860 { 11861 if (_checkNode(o, maxParent)) 11862 break; 11863 } 11864 } 11865 } 11866 return null; 11867 }; 11868 11869 /** 11870 * @deprecated 11871 * @use .querySelector 11872 * @param obj 11873 * @param params 11874 * @return {*} 11875 */ 11876 BX.findNextSibling = function(obj, params) 11877 { 11878 if(!obj) 11879 return null; 11880 var o = obj; 11881 while(o.nextSibling) 11882 { 11883 var sibling = o.nextSibling; 11884 if (_checkNode(sibling, params)) 11885 return sibling; 11886 o = sibling; 11887 } 11888 return null; 11889 }; 11890 11891 /** 11892 * @deprecated 11893 * @use .querySelector 11894 * @param obj 11895 * @param params 11896 * @return {*} 11897 */ 11898 BX.findPreviousSibling = function(obj, params) 11899 { 11900 if(!obj) 11901 return null; 11902 11903 var o = obj; 11904 while(o.previousSibling) 11905 { 11906 var sibling = o.previousSibling; 11907 if(_checkNode(sibling, params)) 11908 return sibling; 11909 o = sibling; 11910 } 11911 return null; 11912 }; 11913 11914 BX.checkNode = function(obj, params) 11915 { 11916 return _checkNode(obj, params); 11917 }; 11918 11919 /** 11920 * @deprecated 11921 * @use .querySelectorAll 11922 * @param form 11923 * @return {Array} 11924 */ 11925 BX.findFormElements = function(form) 11926 { 11927 if (BX.type.isString(form)) 11928 form = document.forms[form]||BX(form); 11929 11930 var res = []; 11931 11932 if (BX.type.isElementNode(form)) 11933 { 11934 if (form.tagName.toUpperCase() == 'FORM') 11935 { 11936 res = form.elements; 11937 } 11938 else 11939 { 11940 res = BX.findChildren(form, CHECK_FORM_ELEMENTS, true); 11941 } 11942 } 11943 11944 return res; 11945 }; 11946 11947 /** 11948 * @deprecated 11949 * @use .contains() 11950 * @param whichNode 11951 * @param forNode 11952 * @return {boolean} 11953 */ 11954 BX.isParentForNode = function(whichNode, forNode) 11955 { 11956 if (BX.type.isDomNode(whichNode) && BX.type.isDomNode(forNode)) 11957 { 11958 return whichNode.contains(forNode); 11959 } 11960 11961 return false; 11962 }; 11963 11964 BX.getCaretPosition = function(node) 11965 { 11966 var pos = 0; 11967 11968 if(node.selectionStart || node.selectionStart == 0) 11969 { 11970 pos = node.selectionStart; 11971 } 11972 else if(document.selection) 11973 { 11974 node.focus(); 11975 var selection = document.selection.createRange(); 11976 selection.moveStart('character', -node.value.length); 11977 pos = selection.text.length; 11978 } 11979 11980 return (pos); 11981 }; 11982 11983 BX.setCaretPosition = function(node, pos) 11984 { 11985 if(!BX.isNodeInDom(node) || BX.isNodeHidden(node) || node.disabled) 11986 { 11987 return; 11988 } 11989 11990 if(node.setSelectionRange) 11991 { 11992 node.focus(); 11993 node.setSelectionRange(pos, pos); 11994 } 11995 else if(node.createTextRange) 11996 { 11997 var range = node.createTextRange(); 11998 range.collapse(true); 11999 range.moveEnd('character', pos); 12000 range.moveStart('character', pos); 12001 range.select(); 12002 } 12003 }; 12004 12005 // access private. use BX.mergeEx instead. 12006 // todo: refactor BX.merge, make it work through BX.mergeEx 12007 BX.merge = function(){ 12008 var arg = Array.prototype.slice.call(arguments); 12009 12010 if(arg.length < 2) 12011 return {}; 12012 12013 var result = arg.shift(); 12014 12015 for(var i = 0; i < arg.length; i++) 12016 { 12017 for(var k in arg[i]){ 12018 12019 if(typeof arg[i] == 'undefined' || arg[i] == null) 12020 continue; 12021 12022 if(arg[i].hasOwnProperty(k)){ 12023 12024 if(typeof arg[i][k] == 'undefined' || arg[i][k] == null) 12025 continue; 12026 12027 if(typeof arg[i][k] == 'object' && !BX.type.isDomNode(arg[i][k]) && (typeof arg[i][k]['isUIWidget'] == 'undefined')){ 12028 12029 // go deeper 12030 12031 var isArray = 'length' in arg[i][k]; 12032 12033 if(typeof result[k] != 'object') 12034 result[k] = isArray ? [] : {}; 12035 12036 if(isArray) 12037 BX.util.array_merge(result[k], arg[i][k]); 12038 else 12039 BX.merge(result[k], arg[i][k]); 12040 12041 }else 12042 result[k] = arg[i][k]; 12043 } 12044 } 12045 } 12046 12047 return result; 12048 }; 12049 12050 BX.mergeEx = function() 12051 { 12052 var arg = Array.prototype.slice.call(arguments); 12053 if(arg.length < 2) 12054 { 12055 return {}; 12056 } 12057 12058 var result = arg.shift(); 12059 for (var i = 0; i < arg.length; i++) 12060 { 12061 for (var k in arg[i]) 12062 { 12063 if (typeof arg[i] == "undefined" || arg[i] == null || !arg[i].hasOwnProperty(k)) 12064 { 12065 continue; 12066 } 12067 12068 if (BX.type.isPlainObject(arg[i][k]) && BX.type.isPlainObject(result[k])) 12069 { 12070 BX.mergeEx(result[k], arg[i][k]); 12071 } 12072 else 12073 { 12074 result[k] = BX.type.isPlainObject(arg[i][k]) ? BX.clone(arg[i][k]) : arg[i][k]; 12075 } 12076 } 12077 } 12078 12079 return result; 12080 }; 12081 12082 BX.getEventButton = function(e) 12083 { 12084 e = e || window.event; 12085 12086 var flags = 0; 12087 12088 if (typeof e.which != 'undefined') 12089 { 12090 switch (e.which) 12091 { 12092 case 1: flags = flags|BX.MSLEFT; break; 12093 case 2: flags = flags|BX.MSMIDDLE; break; 12094 case 3: flags = flags|BX.MSRIGHT; break; 12095 } 12096 } 12097 else if (typeof e.button != 'undefined') 12098 { 12099 flags = event.button; 12100 } 12101 12102 return flags || BX.MSLEFT; 12103 }; 12104 12105 var captured_events = null, _bind = null; 12106 BX.CaptureEvents = function(el_c, evname_c) 12107 { 12108 if (_bind) 12109 return; 12110 12111 _bind = BX.bind; 12112 captured_events = []; 12113 12114 BX.bind = function(el, evname, func) 12115 { 12116 if (el === el_c && evname === evname_c) 12117 captured_events.push(func); 12118 12119 _bind.apply(this, arguments); 12120 } 12121 }; 12122 12123 BX.CaptureEventsGet = function() 12124 { 12125 if (_bind) 12126 { 12127 BX.bind = _bind; 12128 12129 var captured = captured_events; 12130 12131 _bind = null; 12132 captured_events = null; 12133 return captured; 12134 } 12135 return null; 12136 }; 12137 12138 // Don't even try to use it for submit event! 12139 BX.fireEvent = function(ob,ev) 12140 { 12141 var result = false, e = null; 12142 if (BX.type.isDomNode(ob)) 12143 { 12144 result = true; 12145 if (document.createEventObject) 12146 { 12147 // IE 12148 if (eventTypes[ev] != 'MouseEvent') 12149 { 12150 e = document.createEventObject(); 12151 e.type = ev; 12152 result = ob.fireEvent('on' + ev, e); 12153 } 12154 12155 if (ob[ev]) 12156 { 12157 ob[ev](); 12158 } 12159 } 12160 else 12161 {
12162 // non-IE 12163 e = null; 12164 12165 switch (eventTypes[ev]) 12166 { 12167 case 'MouseEvent': 12168 e = document.createEvent('MouseEvent'); 12169 try 12170 { 12171 e.initMouseEvent(ev, true, true, top, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12172 } 12173 catch (initException) 12174 { 12175 e.initMouseEvent(ev, true, true, window, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); 12176 } 12177 12178 break; 12179 default: 12180 e = document.createEvent('Event'); 12181 e.initEvent(ev, true, true); 12182 } 12183 12184 result = ob.dispatchEvent(e); 12185 } 12186 } 12187 12188 return result; 12189 }; 12190 12191 BX.getWheelData = function(e) 12192 { 12193 e = e || window.event; 12194 e.wheelData = e.detail ? e.detail * -1 : e.wheelDelta / 40; 12195 return e.wheelData; 12196 }; 12197 12198 BX.proxy_context = null; 12199 12200 BX.delegate = function (func, thisObject) 12201 { 12202 if (!func || !thisObject) 12203 return func; 12204 12205 return function() { 12206 var cur = BX.proxy_context; 12207 BX.proxy_context = this; 12208 var res = func.apply(thisObject, arguments); 12209 BX.proxy_context = cur; 12210 return res; 12211 } 12212 }; 12213 12214 BX.delegateLater = function (func_name, thisObject, contextObject) 12215 { 12216 return function() 12217 { 12218 if (thisObject[func_name]) 12219 { 12220 var cur = BX.proxy_context; 12221 BX.proxy_context = this; 12222 var res = thisObject[func_name].apply(contextObject||thisObject, arguments); 12223 BX.proxy_context = cur; 12224 return res; 12225 } 12226 return null; 12227 } 12228 }; 12229 12230 BX.proxy = function(func, thisObject) 12231 { 12232 return getObjectDelegate(func, thisObject, proxyList); 12233 }; 12234 12235 BX.defer = function(func, thisObject) 12236 { 12237 if (!!thisObject) 12238 return BX.defer_proxy(func, thisObject); 12239 else 12240 return function() { 12241 var arg = arguments; 12242 setTimeout(function(){func.apply(this,arg)}, 10); 12243 }; 12244 }; 12245 12246 BX.defer_proxy = function(func, thisObject) 12247 { 12248 return getObjectDelegate(func, thisObject, deferList, BX.defer); 12249 }; 12250 12251 /** 12252 * 12253 * @private 12254 */ 12255 function getObjectDelegate(func, thisObject, collection, decorator) 12256 { 12257 if (!BX.type.isFunction(func) || !BX.type.isMapKey(thisObject)) 12258 { 12259 return func; 12260 } 12261 12262 var objectDelegates = collection.get(thisObject); 12263 if (!objectDelegates) 12264 { 12265 objectDelegates = new WeakMap(); 12266 collection.set(thisObject, objectDelegates); 12267 } 12268 12269 var delegate = objectDelegates.get(func); 12270 if (!delegate) 12271 { 12272 delegate = decorator ? decorator(BX.delegate(func, thisObject)) : BX.delegate(func, thisObject); 12273 objectDelegates.set(func, delegate); 12274 } 12275 12276 return delegate; 12277 } 12278 12279 BX.once = function(el, evname, func) 12280 { 12281 var fn = function() 12282 { 12283 BX.unbind(el, evname, fn); 12284 func.apply(this, arguments); 12285 }; 12286 12287 return fn; 12288 }; 12289 12290 BX.bindDelegate = function (elem, eventName, isTarget, handler) 12291 { 12292 var h = BX.delegateEvent(isTarget, handler); 12293 BX.bind(elem, eventName, h); 12294 return h; 12295 }; 12296 12297 BX.delegateEvent = function(isTarget, handler) 12298 { 12299 return function(e) 12300 { 12301 e = e || window.event; 12302 var target = e.target || e.srcElement; 12303 12304 while (target != this) 12305 { 12306 if (_checkNode(target, isTarget)) 12307 { 12308 return handler.call(target, e); 12309 } 12310 if (target && target.parentNode) 12311 target = target.parentNode; 12312 else 12313 break; 12314 } 12315 return null; 12316 } 12317 }; 12318 12319 BX.False = function() {return false;}; 12320 BX.DoNothing = function() {}; 12321 12322 // TODO: also check event handlers set via BX.bind() 12323 BX.denyEvent = function(el, ev) 12324 { 12325 deniedEvents.push([el, ev, el['on' + ev]]); 12326 el['on' + ev] = BX.DoNothing; 12327 }; 12328 12329 BX.allowEvent = function(el, ev) 12330 { 12331 for(var i=0, len=deniedEvents.length; i<len; i++) 12332 { 12333 if (deniedEvents[i][0] == el && deniedEvents[i][1] == ev) 12334 { 12335 el['on' + ev] = deniedEvents[i][2]; 12336 BX.util.deleteFromArray(deniedEvents, i); 12337 return; 12338 } 12339 } 12340 }; 12341 12342 BX.fixEventPageXY = function(event) 12343 { 12344 BX.fixEventPageX(event); 12345 BX.fixEventPageY(event); 12346 return event; 12347 }; 12348 12349 BX.fixEventPageX = function(event) 12350 { 12351 if (event.pageX == null && event.clientX != null) 12352 { 12353 event.pageX = 12354 event.clientX + 12355 (document.documentElement && document.documentElement.scrollLeft || document.body && document.body.scrollLeft || 0) - 12356 (document.documentElement.clientLeft || 0); 12357 } 12358 12359 return event; 12360 }; 12361 12362 BX.fixEventPageY = function(event) 12363 { 12364 if (event.pageY == null && event.clientY != null) 12365 { 12366 event.pageY = 12367 event.clientY + 12368 (document.documentElement && document.documentElement.scrollTop || document.body && document.body.scrollTop || 0) - 12369 (document.documentElement.clientTop || 0); 12370 } 12371 12372 return event; 12373 }; 12374 12375 /** 12376 * @deprecated 12377 * @see e.preventDefault() 12378 */ 12379 BX.PreventDefault = function(e) 12380 { 12381 if(!e) e = window.event; 12382 if(e.stopPropagation) 12383 { 12384 e.preventDefault(); 12385 e.stopPropagation(); 12386 } 12387 else 12388 { 12389 e.cancelBubble = true; 12390 e.returnValue = false;
12391 } 12392 return false; 12393 }; 12394 12395 /** 12396 * @deprecated 12397 * @see e.preventDefault(); 12398 * 12399 * @param e 12400 * @return {boolean} 12401 */ 12402 BX.eventReturnFalse = function(e) 12403 { 12404 e=e||window.event; 12405 if (e && e.preventDefault) e.preventDefault(); 12406 else e.returnValue = false; 12407 return false; 12408 }; 12409 12410 /** 12411 * @deprecated 12412 * @see e.stopPropagation() 12413 * @param e 12414 */ 12415 BX.eventCancelBubble = function(e) 12416 { 12417 e=e||window.event; 12418 if(e && e.stopPropagation) 12419 e.stopPropagation(); 12420 else 12421 e.cancelBubble = true; 12422 }; 12423 12424 BX.bindDebouncedChange = function(node, fn, fnInstant, timeout, ctx) 12425 { 12426 ctx = ctx || window; 12427 timeout = timeout || 300; 12428 12429 var dataTag = 'bx-dc-previous-value'; 12430 BX.data(node, dataTag, node.value); 12431 12432 var act = function(fn, val){ 12433 12434 var pVal = BX.data(node, dataTag); 12435 12436 if(typeof pVal == 'undefined' || pVal != val){ 12437 if(typeof ctx != 'object') 12438 fn(val); 12439 else 12440 fn.apply(ctx, [val]); 12441 } 12442 }; 12443 12444 var actD = BX.debounce(function(){ 12445 var val = node.value; 12446 act(fn, val); 12447 BX.data(node, dataTag, val); 12448 }, timeout); 12449 12450 BX.bind(node, 'keyup', actD); 12451 BX.bind(node, 'change', actD); 12452 BX.bind(node, 'input', actD); 12453 12454 if(BX.type.isFunction(fnInstant)){ 12455 12456 var actI = function(){ 12457 act(fnInstant, node.value); 12458 }; 12459 12460 BX.bind(node, 'keyup', actI); 12461 BX.bind(node, 'change', actI); 12462 BX.bind(node, 'input', actI); 12463 } 12464 }; 12465 12466 BX.parseJSON = function(data, context) 12467 { 12468 var result = null; 12469 if (BX.type.isNotEmptyString(data)) 12470 { 12471 try { 12472 if (data.indexOf("\n") >= 0) 12473 eval('result = ' + data); 12474 else 12475 result = (new Function("return " + data))(); 12476 } catch(e) { 12477 BX.onCustomEvent(context, 'onParseJSONFailure', [data, context]) 12478 } 12479 } 12480 else if(BX.type.isPlainObject(data)) 12481 { 12482 return data; 12483 } 12484 12485 return result; 12486 }; 12487 12488 BX.submit = function(obForm, action_name, action_value, onAfterSubmit) 12489 { 12490 action_name = action_name || 'save'; 12491 if (!obForm['BXFormSubmit_' + action_name]) 12492 { 12493 obForm['BXFormSubmit_' + action_name] = obForm.appendChild(BX.create('INPUT', { 12494 'props': { 12495 'type': 'submit', 12496 'name': action_name, 12497 'value': action_value || 'Y' 12498 }, 12499 'style': { 12500 'display': 'none' 12501 } 12502 })); 12503 } 12504 12505 if (obForm.sessid) 12506 obForm.sessid.value = BX.bitrix_sessid(); 12507 12508 setTimeout(BX.delegate(function() {BX.fireEvent(this, 'click'); if (onAfterSubmit) onAfterSubmit();}, obForm['BXFormSubmit_' + action_name]), 10); 12509 }; 12510 12511 BX.show = function(ob, displayType) 12512 { 12513 if (ob.BXDISPLAY || !_checkDisplay(ob, displayType)) 12514 { 12515 ob.style.display = ob.BXDISPLAY; 12516 } 12517 }; 12518 12519 BX.hide = function(ob, displayType) 12520 { 12521 if (!ob.BXDISPLAY) 12522 _checkDisplay(ob, displayType); 12523 12524 ob.style.display = 'none'; 12525 }; 12526 12527 BX.toggle = function(ob, values) 12528 { 12529 if (!values && BX.type.isElementNode(ob)) 12530 { 12531 var bShow = true; 12532 if (ob.BXDISPLAY) 12533 bShow = !_checkDisplay(ob); 12534 else 12535 bShow = ob.style.display == 'none'; 12536 12537 if (bShow) 12538 BX.show(ob); 12539 else 12540 BX.hide(ob); 12541 } 12542 else if (BX.type.isArray(values)) 12543 { 12544 for (var i=0,len=values.length; i<len; i++) 12545 { 12546 if (ob == values[i]) 12547 { 12548 ob = values[i==len-1 ? 0 : i+1]; 12549 break; 12550 } 12551 } 12552 if (i==len) 12553 ob = values[0]; 12554 } 12555 12556 return ob; 12557 }; 12558 12559 function _checkDisplay(ob, displayType) 12560 { 12561 if (typeof displayType != 'undefined') 12562 ob.BXDISPLAY = displayType; 12563 12564 var d = ob.style.display || BX.style(ob, 'display'); 12565 if (d != 'none') 12566 { 12567 ob.BXDISPLAY = ob.BXDISPLAY || d; 12568 return true; 12569 } 12570 else 12571 { 12572 ob.BXDISPLAY = ob.BXDISPLAY || 'block'; 12573 return false; 12574 } 12575 } 12576 12577 /* some useful util functions */ 12578 12579 BX.util = { 12580 /** 12581 * @deprecated 12582 * @use [].filter(value => !BX.Type.isNil(value)) 12583 * @param ar 12584 * @return {*} 12585 */ 12586 array_values: function(ar) 12587 { 12588 if (!BX.type.isArray(ar)) 12589 return BX.util._array_values_ob(ar); 12590 var arv = []; 12591 for(var i=0,l=ar.length;i<l;i++) 12592 if (ar[i] !== null && typeof ar[i] != 'undefined') 12593 arv.push(ar[i]); 12594 return arv; 12595 }, 12596 12597 /** 12598 * @deprecated 12599 * @use Object.values([]).filter(value => !BX.Type.isNil(value)) 12600 * @param ar 12601 * @return {Array} 12602 * @private 12603 */ 12604 _array_values_ob: function(ar) 12605 { 12606 var arv = []; 12607 for(var i in ar) 12608 if (ar[i] !== null && typeof ar[i] != 'undefined') 12609 arv.push(ar[i]); 12610 return arv; 12611 }, 12612 12613 /** 12614 * @deprecated 12615 * @use 12616 * @param ar 12617 * @return {*} 12618 */ 12619 array_keys: function(ar) 12620 { 12621 if (!BX.type.isArray(ar)) 12622 return BX.util._array_keys_ob(ar); 12623 var arv = []; 12624 for(var i=0,l=ar.length;i<l;i++) 12625 if (ar[i] !== null && typeof ar[i] != 'undefined') 12626 arv.push(i); 12627 return arv; 12628 }, 12629 12630 _array_keys_ob: function(ar) 12631 { 12632 var arv = []; 12633 for(var i in ar) 12634 if (ar[i] !== null && typeof ar[i] != 'undefined') 12635 arv.push(i); 12636 return arv; 12637 }, 12638 12639 object_keys: function(obj) 12640 { 12641 var arv = []; 12642 for(var k in obj) 12643 { 12644 if(obj.hasOwnProperty(k)) 12645 { 12646 arv.push(k); 12647 } 12648 } 12649 return arv; 12650 }, 12651 12652 /** 12653 * @deprecated 12654 * @use firstArr.concat(secondArr); 12655 * @param first 12656 * @param second 12657 * @return {*[]} 12658 */ 12659 array_merge: function(first, second) 12660 { 12661 if (!BX.type.isArray(first)) first = []; 12662 if (!BX.type.isArray(second)) second = []; 12663 12664 var i = first.length, j = 0; 12665 12666 if (typeof second.length === "number") 12667 { 12668 for (var l = second.length; j < l; j++) 12669 { 12670 first[i++] = second[j]; 12671 } 12672 } 12673 else 12674 {
12675 while (second[j] !== undefined) 12676 { 12677 first[i++] = second[j++]; 12678 } 12679 } 12680 12681 first.length = i; 12682 12683 return first; 12684 }, 12685 12686 array_flip: function (object) 12687 { 12688 var newObject = {}; 12689 12690 for (var key in object) 12691 { 12692 newObject[object[key]] = key; 12693 } 12694 12695 return newObject; 12696 }, 12697 12698 array_diff: function(ar1, ar2, hash) 12699 { 12700 hash = BX.type.isFunction(hash) ? hash : null; 12701 var i, length, v, h, map = {}, result = []; 12702 for(i = 0, length = ar2.length; i < length; i++) 12703 { 12704 v = ar2[i]; 12705 h = hash ? hash(v) : v; 12706 map[h] = true; 12707 } 12708 12709 for(i = 0, length = ar1.length; i < length; i++) 12710 { 12711 v = ar1[i]; 12712 h = hash ? hash(v) : v; 12713 if(typeof(map[h]) === "undefined") 12714 { 12715 result.push(v); 12716 } 12717 } 12718 return result; 12719 }, 12720 12721 /** 12722 * @deprecated 12723 * @use Set 12724 */ 12725 array_unique: function(ar) 12726 { 12727 var i=0,j,len=ar.length; 12728 if(len<2) return ar; 12729 12730 for (; i<len-1;i++) 12731 { 12732 for (j=i+1; j<len;j++) 12733 { 12734 if (ar[i]==ar[j]) 12735 { 12736 ar.splice(j--,1); len--; 12737 } 12738 } 12739 } 12740 12741 return ar; 12742 }, 12743 12744 /** 12745 * @deprecated 12746 * @use myArr.includes(needle) 12747 */ 12748 in_array: function(needle, haystack) 12749 { 12750 for(var i=0; i<haystack.length; i++) 12751 { 12752 if(haystack[i] == needle) 12753 return true; 12754 } 12755 return false; 12756 }, 12757 12758 /** 12759 * @deprecated 12760 * @use myArr.findIndex(item => item === needle); 12761 */ 12762 array_search: function(needle, haystack) 12763 { 12764 for(var i=0; i<haystack.length; i++) 12765 { 12766 if(haystack[i] == needle) 12767 return i; 12768 } 12769 return -1; 12770 }, 12771 12772 object_search_key: function(needle, haystack) 12773 { 12774 if (typeof haystack[needle] != 'undefined') 12775 return haystack[needle]; 12776 12777 for(var i in haystack) 12778 { 12779 if (typeof haystack[i] == "object") 12780 { 12781 var result = BX.util.object_search_key(needle, haystack[i]); 12782 if (result !== false) 12783 return result; 12784 } 12785 } 12786 return false; 12787 }, 12788 12789 trim: function(s) 12790 { 12791 if (BX.type.isString(s)) 12792 { 12793 return s.trim(); 12794 } 12795 12796 return s; 12797 }, 12798 12799 urlencode: function(s){return encodeURIComponent(s);}, 12800 12801 // it may also be useful. via sVD. 12802 deleteFromArray: function(ar, ind) {return ar.slice(0, ind).concat(ar.slice(ind + 1));}, 12803 insertIntoArray: function(ar, ind, el) {return ar.slice(0, ind).concat([el]).concat(ar.slice(ind));}, 12804 12805 htmlspecialchars: function(str) 12806 { 12807 return BX.Text.encode(str); 12808 }, 12809 12810 htmlspecialcharsback: function(str) 12811 { 12812 return BX.Text.decode(str); 12813 }, 12814 12815 // Quote regular expression characters plus an optional character 12816 preg_quote: function(str, delimiter) 12817 { 12818 if(!str.replace) 12819 return str; 12820 return str.replace(new RegExp('[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + (delimiter || '') + '-]', 'g'), '\\$&'); 12821 }, 12822 12823 jsencode: function(str) 12824 { 12825 if (!str || !str.replace) 12826 return str; 12827 12828 var escapes = 12829 [ 12830 { c: "\\\\", r: "\\\\" }, // should be first 12831 { c: "\\t", r: "\\t" }, 12832 { c: "\\n", r: "\\n" }, 12833 { c: "\\r", r: "\\r" }, 12834 { c: "\"", r: "\\\"" }, 12835 { c: "'", r: "\\'" }, 12836 { c: "<", r: "\\x3C" }, 12837 { c: ">", r: "\\x3E" }, 12838 { c: "\\u2028", r: "\\u2028" }, 12839 { c: "\\u2029", r: "\\u2029" } 12840 ]; 12841 for (var i = 0; i < escapes.length; i++) 12842 str = str.replace(new RegExp(escapes[i].c, 'g'), escapes[i].r); 12843 return str; 12844 }, 12845 12846 getCssName: function(jsName) 12847 { 12848 if (!BX.type.isNotEmptyString(jsName)) 12849 { 12850 return ""; 12851 } 12852 12853 return jsName.replace(/[A-Z]/g, function(match) { 12854 return "-" + match.toLowerCase(); 12855 }); 12856 }, 12857 12858 getJsName: function(cssName) 12859 { 12860 var regex = /\-([a-z]){1}/g; 12861 if (regex.test(cssName)) 12862 { 12863 return cssName.replace(regex, function(match, letter) { 12864 return letter.toUpperCase(); 12865 }); 12866 } 12867 12868 return cssName; 12869 }, 12870 12871 nl2br: function(str) 12872 { 12873 if (!str || !str.replace) 12874 return str; 12875 12876 return str.replace(/([^>])\n/g, '$1<br/>'); 12877 }, 12878 12879 /** 12880 * @deprecated 12881 * @use .padStart() / .padEnd() 12882 * @param input 12883 * @param pad_length 12884 * @param pad_string 12885 * @param pad_type 12886 * @return {*} 12887 */ 12888 str_pad: function(input, pad_length, pad_string, pad_type) 12889 { 12890 pad_string = pad_string || ' '; 12891 pad_type = pad_type || 'right'; 12892 input = input.toString(); 12893 12894 if (pad_type === 'left') 12895 { 12896 return BX.util.str_pad_left(input, pad_length, pad_string); 12897 } 12898 12899 return BX.util.str_pad_right(input, pad_length, pad_string); 12900 }, 12901 12902 str_pad_left: function(input, pad_length, pad_string) 12903 { 12904 return input.toString().padStart(pad_length, pad_string); 12905 }, 12906 12907 str_pad_right: function(input, pad_length, pad_string) 12908 { 12909 return input.toString().padEnd(pad_length, pad_string); 12910 }, 12911 12912 strip_tags: function(str) 12913 { 12914 return str.split(/<[^>]+>/g).join(''); 12915 }, 12916 12917 strip_php_tags: function(str) 12918 { 12919 return str.replace(/<\?(.|[\r\n])*?\?>/g, ''); 12920 }, 12921 12922 popup: function(url, width, height) 12923 { 12924 var w, h; 12925 if(BX.browser.IsOpera()) 12926 { 12927 w = document.body.offsetWidth; 12928 h = document.body.offsetHeight; 12929 } 12930 else 12931 {
12932 w = screen.width; 12933 h = screen.height; 12934 } 12935 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)); 12936 }, 12937 12938 shuffle: function(array) 12939 { 12940 var temporaryValue, randomIndex; 12941 var currentIndex = array.length; 12942 12943 while (0 !== currentIndex) 12944 { 12945 randomIndex = Math.floor(Math.random() * currentIndex); 12946 currentIndex -= 1; 12947 12948 temporaryValue = array[currentIndex]; 12949 array[currentIndex] = array[randomIndex]; 12950 array[randomIndex] = temporaryValue; 12951 } 12952 12953 return array; 12954 }, 12955 12956 // BX.util.objectSort(object, sortBy, sortDir) - Sort object by property 12957 // function params: 1 - object for sort, 2 - sort by property, 3 - sort direction (asc/desc) 12958 // return: sort array [[objectElement], [objectElement]] in sortDir direction 12959 12960 // example: BX.util.objectSort({'L1': {'name': 'Last'}, 'F1': {'name': 'First'}}, 'name', 'asc'); 12961 // return: [{'name' : 'First'}, {'name' : 'Last'}] 12962 objectSort: function(object, sortBy, sortDir) 12963 { 12964 sortDir = sortDir == 'asc'? 'asc': 'desc'; 12965 12966 var arItems = [], i; 12967 for (i in object) 12968 { 12969 if (object.hasOwnProperty(i) && object[i][sortBy]) 12970 { 12971 arItems.push([i, object[i][sortBy]]); 12972 } 12973 } 12974 12975 if (sortDir == 'asc') 12976 { 12977 arItems.sort(function(i, ii) { 12978 var s1, s2; 12979 if (BX.type.isDate(i[1])) 12980 { 12981 s1 = i[1].getTime(); 12982 } 12983 else if (!isNaN(i[1])) 12984 { 12985 s1 = parseInt(i[1]); 12986 } 12987 else 12988 { 12989 s1 = i[1].toString().toLowerCase(); 12990 } 12991 12992 if (BX.type.isDate(ii[1])) 12993 { 12994 s2 = ii[1].getTime(); 12995 } 12996 else if (!isNaN(ii[1])) 12997 { 12998 s2 = parseInt(ii[1]); 12999 } 13000 else 13001 { 13002 s2 = ii[1].toString().toLowerCase(); 13003 } 13004 13005 if (s1 > s2) 13006 return 1; 13007 else if (s1 < s2) 13008 return -1; 13009 else 13010 return 0; 13011 }); 13012 } 13013 else 13014 { 13015 arItems.sort(function(i, ii) { 13016 var s1, s2; 13017 if (BX.type.isDate(i[1])) 13018 { 13019 s1 = i[1].getTime(); 13020 } 13021 else if (!isNaN(i[1])) 13022 { 13023 s1 = parseInt(i[1]); 13024 } 13025 else 13026 { 13027 s1 = i[1].toString().toLowerCase(); 13028 } 13029 13030 if (BX.type.isDate(ii[1])) 13031 { 13032 s2 = ii[1].getTime(); 13033 } 13034 else if (!isNaN(ii[1])) 13035 { 13036 s2 = parseInt(ii[1]); 13037 } 13038 else 13039 { 13040 s2 = ii[1].toString().toLowerCase(); 13041 } 13042 13043 if (s1 < s2) 13044 return 1; 13045 else if (s1 > s2) 13046 return -1; 13047 else 13048 return 0; 13049 }); 13050 } 13051 13052 var arReturnArray = Array(); 13053 for (i = 0; i < arItems.length; i++) 13054 { 13055 arReturnArray.push(object[arItems[i][0]]); 13056 } 13057 13058 return arReturnArray; 13059 }, 13060 13061 objectMerge: function() 13062 { 13063 return BX.mergeEx.apply(window, arguments); 13064 }, 13065 13066 objectClone : function(object) 13067 { 13068 return BX.clone(object, true); 13069 }, 13070 13071 // #fdf9e5 => {r=253, g=249, b=229} 13072 hex2rgb: function(color) 13073 { 13074 var rgb = color.replace(/[# ]/g,"").replace(/^(.)(.)(.)$/,'$1$1$2$2$3$3').match(/.{2}/g); 13075 for (var i=0; i<3; i++) 13076 { 13077 rgb[i] = parseInt(rgb[i], 16); 13078 } 13079 return {'r':rgb[0],'g':rgb[1],'b':rgb[2]}; 13080 }, 13081 13082 /** 13083 * @deprecated 13084 * @use BX.Uri 13085 * @param url 13086 * @param param 13087 * @return {string} 13088 */ 13089 remove_url_param: function(url, param) 13090 { 13091 return BX.Uri.removeParam(url, param); 13092 }, 13093 13094 /* 13095 {'param1': 'value1', 'param2': 'value2'} 13096 */ 13097 /** 13098 * @deprecated 13099 * @use BX.Uri 13100 * @param url 13101 * @param params 13102 * @return {string} 13103 */ 13104 add_url_param: function(url, params) 13105 { 13106 var preparedParams = Object.entries(params).reduce(function(acc, item) { 13107 acc[item[0]] = BX.type.isArray(item[1]) ? item[1].join() : item[1]; 13108 return acc; 13109 }, {}); 13110 13111 return BX.Uri.addParam(url, preparedParams); 13112 }, 13113 13114 /* 13115 {'param1': 'value1', 'param2': 'value2'} 13116 */ 13117 buildQueryString: function(params) 13118 { 13119 var result = ''; 13120 for (var key in params) 13121 { 13122 var value = params[key]; 13123 if(BX.type.isArray(value)) 13124 { 13125 value.forEach(function(valueElement, index) 13126 { 13127 result += encodeURIComponent(key + "[" + index + "]") + "=" + encodeURIComponent(valueElement) + "&"; 13128 }); 13129 } 13130 else 13131 { 13132 result += encodeURIComponent(key) + "=" + encodeURIComponent(value) + "&"; 13133 } 13134 } 13135 13136 if(result.length > 0) 13137 { 13138 result = result.substr(0, result.length - 1); 13139 } 13140 return result; 13141 }, 13142 13143 even: function(digit) 13144 { 13145 return (parseInt(digit) % 2 == 0); 13146 }, 13147 13148 hashCode: function(str) 13149 { 13150 if(!BX.type.isNotEmptyString(str)) 13151 { 13152 return 0; 13153 } 13154 13155 var hash = 0; 13156 for (var i = 0; i < str.length; i++) 13157 { 13158 var c = str.charCodeAt(i); 13159 hash = ((hash << 5) - hash) + c; 13160 hash = hash & hash; 13161 } 13162 return hash; 13163 }, 13164 13165 getRandomString: function (length) 13166 { 13167 return BX.Text.getRandom(length); 13168 }, 13169 13170 number_format: function(number, decimals, dec_point, thousands_sep) 13171 { 13172 var i, j, kw, kd, km, sign = ''; 13173 decimals = Math.abs(decimals); 13174 if (isNaN(decimals) || decimals < 0) 13175 { 13176 decimals = 2; 13177 } 13178 dec_point = dec_point || ','; 13179 if (typeof thousands_sep === 'undefined') 13180 thousands_sep = '.'; 13181 13182 number = (+number || 0).toFixed(decimals); 13183 if (number < 0) 13184 { 13185 sign = '-'; 13186 number = -number; 13187 } 13188 13189 i = parseInt(number, 10) + ''; 13190 j = (i.length > 3 ? i.length % 3 : 0); 13191 13192 km = (j ? i.substr(0, j) + thousands_sep : ''); 13193 kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep); 13194 kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, '0').slice(2) : ''); 13195 13196 return sign + km + kw + kd; 13197 }, 13198 13199 getExtension: function (url) 13200 { 13201 url = url || ""; 13202 var items = url.split("?")[0].split("."); 13203 return items[items.length-1].toLowerCase(); 13204 }, 13205 addObjectToForm: function(object, form, prefix) 13206 { 13207 if(!BX.type.isString(prefix)) 13208 { 13209 prefix = ""; 13210 } 13211 13212 for(var key in object) 13213 { 13214 if(!object.hasOwnProperty(key)) 13215 { 13216 continue; 13217 } 13218 13219 var value = object[key]; 13220 var name = prefix !== "" ? (prefix + "[" + key + "]") : key; 13221 if(BX.type.isArray(value)) 13222 { 13223 var obj = {}; 13224 for(var i = 0; i < value.length; i++) 13225 { 13226 obj[i] = value[i]; 13227 } 13228 13229 BX.util.addObjectToForm(obj, form, name); 13230 } 13231 else if(BX.type.isPlainObject(value)) 13232 { 13233 BX.util.addObjectToForm(value, form, name); 13234 } 13235 else 13236 { 13237 value = BX.type.isFunction(value.toString) ? value.toString() : ""; 13238 if(value !== "") 13239 { 13240 form.appendChild(BX.create("INPUT", { attrs: { type: "hidden", name: name, value: value } })); 13241 } 13242 } 13243 } 13244 }, 13245 13246 observe: function(object, enable) 13247 {
13248 console.error('BX.util.observe: function is no longer supported by browser.'); 13249 return false; 13250 }, 13251 13252 escapeRegExp: function(str) 13253 { 13254 return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); 13255 } 13256 }; 13257 13258 BX.validation = { 13259 checkIfEmail: function(s) 13260 { 13261 var atom = "[=a-z0-9_+~'!$&*^`|#%/?{}-]"; 13262 return (new RegExp('^\\s*'+atom+'+(\\.'+atom+'+)*@([a-z0-9-]+\\.)+[a-z0-9-]{2,20}\\s*$', 'i')).test(s); 13263 }, 13264 checkIfPhone: function(s) 13265 { 13266 var regexp = new RegExp( 13267 typeof(BX.PhoneNumber) === "undefined" 13268 ? BX.PhoneNumber.getValidNumberPattern() 13269 : '^\\s*\\+?\s*[0-9(-)\\s]+\\s*$', 13270 'i' 13271 ); 13272 return regexp.test(s); 13273 } 13274 }; 13275 13276 BX.prop = 13277 { 13278 get: function(object, key, defaultValue) 13279 { 13280 return object && object.hasOwnProperty(key) ? object[key] : defaultValue; 13281 }, 13282 getObject: function(object, key, defaultValue) 13283 { 13284 return object && BX.type.isPlainObject(object[key]) ? object[key] : defaultValue; 13285 }, 13286 getElementNode: function(object, key, defaultValue) 13287 { 13288 return object && BX.type.isElementNode(object[key]) ? object[key] : defaultValue; 13289 }, 13290 getArray: function(object, key, defaultValue) 13291 { 13292 return object && BX.type.isArray(object[key]) ? object[key] : defaultValue; 13293 }, 13294 getFunction: function(object, key, defaultValue) 13295 { 13296 return object && BX.type.isFunction(object[key]) ? object[key] : defaultValue; 13297 }, 13298 getNumber: function(object, key, defaultValue) 13299 { 13300 if(!(object && object.hasOwnProperty(key))) 13301 { 13302 return defaultValue; 13303 } 13304 13305 var value = object[key]; 13306 if(BX.type.isNumber(value)) 13307 { 13308 return value; 13309 } 13310 13311 value = parseFloat(value); 13312 return !isNaN(value) ? value : defaultValue; 13313 }, 13314 getInteger: function(object, key, defaultValue) 13315 { 13316 if(!(object && object.hasOwnProperty(key))) 13317 { 13318 return defaultValue; 13319 } 13320 13321 var value = object[key]; 13322 if(BX.type.isNumber(value)) 13323 { 13324 return value; 13325 } 13326 13327 value = parseInt(value); 13328 return !isNaN(value) ? value : defaultValue; 13329 }, 13330 getBoolean: function(object, key, defaultValue) 13331 { 13332 if(!(object && object.hasOwnProperty(key))) 13333 { 13334 return defaultValue; 13335 } 13336 13337 var value = object[key]; 13338 return (BX.type.isBoolean(value) 13339 ? value 13340 : (BX.type.isString(value) ? (value.toLowerCase() === "true") : !!value) 13341 ); 13342 }, 13343 getString: function(object, key, defaultValue) 13344 { 13345 if(!(object && object.hasOwnProperty(key))) 13346 { 13347 return defaultValue; 13348 } 13349 13350 var value = object[key]; 13351 return BX.type.isString(value) ? value : (value ? value.toString() : ''); 13352 }, 13353 extractDate: function(datetime) 13354 { 13355 if(!BX.type.isDate(datetime)) 13356 { 13357 datetime = new Date(); 13358 } 13359 13360 datetime.setHours(0); 13361 datetime.setMinutes(0); 13362 datetime.setSeconds(0); 13363 datetime.setMilliseconds(0); 13364 13365 return datetime; 13366 } 13367 }; 13368 13369 BX.isNodeInDom = function(node, doc) 13370 { 13371 return node === (doc || document) ? true : 13372 (node.parentNode ? BX.isNodeInDom(node.parentNode) : false); 13373 }; 13374 13375 BX.isNodeHidden = function(node) 13376 { 13377 if (node === document) 13378 return false; 13379 else if (BX.style(node, 'display') == 'none') 13380 return true; 13381 else 13382 return (node.parentNode ? BX.isNodeHidden(node.parentNode) : true); 13383 }; 13384 13385 BX.evalPack = function(code) 13386 { 13387 while (code.length > 0) 13388 { 13389 var c = code.shift(); 13390 13391 if (c.TYPE == 'SCRIPT_EXT' || c.TYPE == 'SCRIPT_SRC') 13392 { 13393 BX.loadScript(c.DATA, function() {BX.evalPack(code)}); 13394 return; 13395 } 13396 else if (c.TYPE == 'SCRIPT') 13397 { 13398 BX.evalGlobal(c.DATA); 13399 } 13400 } 13401 }; 13402 13403 BX.evalGlobal = function(data) 13404 { 13405 if (data) 13406 { 13407 var head = document.getElementsByTagName("head")[0] || document.documentElement, 13408 script = document.createElement("script"); 13409 13410 script.type = "text/javascript"; 13411 13412 if (!BX.browser.IsIE()) 13413 { 13414 script.appendChild(document.createTextNode(data)); 13415 } 13416 else 13417 { 13418 script.text = data; 13419 } 13420 13421 head.insertBefore(script, head.firstChild); 13422 head.removeChild(script); 13423 } 13424 }; 13425 13426 BX.garbage = function(call, thisObject) 13427 { 13428 garbageCollectors.push({callback: call, context: thisObject}); 13429 }; 13430 13431 BX.GetDocElement = function (pDoc) 13432 { 13433 pDoc = pDoc || document; 13434 return (BX.browser.IsDoctype(pDoc) ? pDoc.documentElement : pDoc.body); 13435 }; 13436 13437 BX.scrollTop = function(node, val){ 13438 if(typeof val != 'undefined'){ 13439 13440 if(node == window){ 13441 throw new Error('scrollTop() for window is not implemented'); 13442 }else 13443 node.scrollTop = parseInt(val); 13444 13445 }else{ 13446 13447 if(node == window) 13448 return BX.GetWindowScrollPos().scrollTop; 13449 13450 return node.scrollTop; 13451 } 13452 }; 13453 13454 BX.scrollLeft = function(node, val){ 13455 if(typeof val != 'undefined'){ 13456 13457 if(node == window){ 13458 throw new Error('scrollLeft() for window is not implemented'); 13459 }else 13460 node.scrollLeft = parseInt(val); 13461 13462 }else{ 13463 13464 if(node == window) 13465 return BX.GetWindowScrollPos().scrollLeft; 13466 13467 return node.scrollLeft; 13468 } 13469 }; 13470 13471 BX.hide_object = function(ob) 13472 { 13473 ob = BX(ob); 13474 ob.style.position = 'absolute'; 13475 ob.style.top = '-1000px'; 13476 ob.style.left = '-1000px'; 13477 ob.style.height = '10px'; 13478 ob.style.width = '10px'; 13479 }; 13480 13481 BX.is_relative = function(el) 13482 { 13483 var p = BX.style(el, 'position'); 13484 return p == 'relative' || p == 'absolute'; 13485 }; 13486 13487 BX.is_float = function(el) 13488 { 13489 var p = BX.style(el, 'float'); 13490 return p == 'right' || p == 'left'; 13491 }; 13492 13493 BX.is_fixed = function(el) 13494 { 13495 var p = BX.style(el, 'position'); 13496 return p == 'fixed'; 13497 }; 13498 13499 BX.width = function(node, val){ 13500 if(typeof val != 'undefined') 13501 BX.style(node, 'width', parseInt(val)+'px'); 13502 else{ 13503 13504 if(node == window) 13505 return window.innerWidth; 13506 13507 //return parseInt(BX.style(node, 'width')); 13508 return BX.pos(node).width; 13509 } 13510 }; 13511 13512 BX.height = function(node, val){ 13513 if(typeof val != 'undefined') 13514 BX.style(node, 'height', parseInt(val)+'px'); 13515 else{ 13516 13517 if(node == window) 13518 return window.innerHeight; 13519 13520 //return parseInt(BX.style(node, 'height')); 13521 return BX.pos(node).height; 13522 } 13523 }; 13524 13525 BX.align = function(pos, w, h, type) 13526 { 13527 if (type) 13528 type = type.toLowerCase(); 13529 else 13530 type = ''; 13531 13532 var pDoc = document; 13533 if (BX.type.isElementNode(pos)) 13534 { 13535 pDoc = pos.ownerDocument; 13536 pos = BX.pos(pos); 13537 } 13538 13539 var x = pos["left"], y = pos["bottom"]; 13540 13541 var scroll = BX.GetWindowScrollPos(pDoc); 13542 var size = BX.GetWindowInnerSize(pDoc); 13543 13544 if((size.innerWidth + scroll.scrollLeft) - (pos["left"] + w) < 0) 13545 { 13546 if(pos["right"] - w >= 0 ) 13547 x = pos["right"] - w; 13548 else 13549 x = scroll.scrollLeft; 13550 } 13551
13552 if(((size.innerHeight + scroll.scrollTop) - (pos["bottom"] + h) < 0) || ~type.indexOf('top')) 13553 { 13554 if(pos["top"] - h >= 0 || ~type.indexOf('top')) 13555 y = pos["top"] - h; 13556 else 13557 y = scroll.scrollTop; 13558 } 13559 13560 return {'left':x, 'top':y}; 13561 }; 13562 13563 BX.scrollToNode = function(node) 13564 { 13565 var obNode = BX(node); 13566 13567 if (obNode.scrollIntoView) 13568 obNode.scrollIntoView(true); 13569 else 13570 { 13571 var arNodePos = BX.pos(obNode); 13572 window.scrollTo(arNodePos.left, arNodePos.top); 13573 } 13574 }; 13575 13576 /* non-xhr loadings */ 13577 BX.showWait = function(node, msg) 13578 { 13579 node = BX(node) || document.body || document.documentElement; 13580 msg = msg || BX.message('JS_CORE_LOADING'); 13581 13582 var container_id = node.id || Math.random(); 13583 13584 var obMsg = node.bxmsg = document.body.appendChild(BX.create('DIV', { 13585 props: { 13586 id: 'wait_' + container_id 13587 }, 13588 style: { 13589 background: 'url("/bitrix/js/main/core/images/wait.gif") no-repeat scroll 10px center #fcf7d1', 13590 border: '1px solid #E1B52D', 13591 color: 'black', 13592 fontFamily: 'Verdana,Arial,sans-serif', 13593 fontSize: '11px', 13594 padding: '10px 30px 10px 37px', 13595 position: 'absolute', 13596 textAlign:'center' 13597 }, 13598 text: msg 13599 })); 13600 13601 BX.ZIndexManager.register(obMsg); 13602 BX.ZIndexManager.bringToFront(obMsg); 13603 13604 setTimeout(BX.delegate(_adjustWait, node), 10); 13605 13606 lastWait[lastWait.length] = obMsg; 13607 return obMsg; 13608 }; 13609 13610 BX.closeWait = function(node, obMsg) 13611 { 13612 if(node && !obMsg) 13613 obMsg = node.bxmsg; 13614 if(node && !obMsg && BX.hasClass(node, 'bx-core-waitwindow')) 13615 obMsg = node; 13616 if(node && !obMsg) 13617 obMsg = BX('wait_' + node.id); 13618 if(!obMsg) 13619 obMsg = lastWait.pop(); 13620 13621 if (obMsg && obMsg.parentNode) 13622 { 13623 for (var i=0,len=lastWait.length;i<len;i++) 13624 { 13625 if (obMsg == lastWait[i]) 13626 { 13627 lastWait = BX.util.deleteFromArray(lastWait, i); 13628 break; 13629 } 13630 } 13631 13632 BX.ZIndexManager.unregister(obMsg); 13633 obMsg.parentNode.removeChild(obMsg); 13634 if (node) node.bxmsg = null; 13635 BX.cleanNode(obMsg, true); 13636 } 13637 }; 13638 13639 BX.setJSList = function(scripts) 13640 { 13641 if (BX.type.isArray(scripts)) 13642 { 13643 scripts = scripts.map(function(script) { 13644 return normalizeUrl(script) 13645 }); 13646 13647 jsList = jsList.concat(scripts); 13648 } 13649 }; 13650 13651 BX.getJSList = function() 13652 { 13653 initJsList(); 13654 return jsList; 13655 }; 13656 13657 BX.setCSSList = function(cssFiles) 13658 { 13659 if (BX.type.isArray(cssFiles)) 13660 { 13661 cssFiles = cssFiles.map(function(cssFile) { 13662 return normalizeUrl(cssFile); 13663 }); 13664 13665 cssList = cssList.concat(cssFiles); 13666 } 13667 }; 13668 13669 BX.getCSSList = function() 13670 { 13671 initCssList(); 13672 return cssList; 13673 }; 13674 13675 BX.getJSPath = function(js) 13676 { 13677 return js.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 13678 }; 13679 13680 BX.getCSSPath = function(css) 13681 { 13682 return css.replace(/^(http[s]*:)*\/\/[^\/]+/i, ''); 13683 }; 13684 13685 BX.getCDNPath = function(path) 13686 { 13687 return path; 13688 }; 13689 13690 BX.loadScript = function(script, callback, doc) 13691 { 13692 if (BX.type.isString(script)) 13693 { 13694 script = [script]; 13695 } 13696 13697 return BX.load(script, callback, doc); 13698 }; 13699 13700 BX.loadCSS = function(css, doc, win) 13701 { 13702 if (BX.type.isString(css)) 13703 { 13704 css = [css]; 13705 } 13706 13707 if (BX.type.isArray(css)) 13708 { 13709 css = css.map(function(url) { 13710 return { url: url, ext: "css" } 13711 }); 13712 13713 BX.load(css, null, doc); 13714 } 13715 }; 13716 13717 const LOADING = 3; 13718 const LOADED = 4; 13719 const assets = {}; 13720 13721 BX.load = function(items, callback, doc) 13722 { 13723 if (!BX.isReady) 13724 { 13725 var _args = arguments; 13726 BX.ready(function() { 13727 BX.load.apply(this, _args); 13728 }); 13729 13730 return null; 13731 } 13732 13733 doc = doc || document; 13734 13735 callback = BX.Type.isFunction(callback) ? callback : () => {}; 13736 13737 return loadAsync(items, callback, doc); 13738 }; 13739 13740 function loadAsync(items, callback, doc) 13741 { 13742 if (!BX.type.isArray(items)) 13743 { 13744 callback(); 13745 13746 return; 13747 } 13748 13749 function onLoad() 13750 { 13751 const nextAsset = queue.shift(); 13752 if (nextAsset) 13753 { 13754 load(nextAsset, onLoad, doc); 13755 } 13756 else if (allLoaded()) 13757 { 13758 callback(); 13759 } 13760 } 13761 13762 function allLoaded() 13763 { 13764 for (const name in assetMap) 13765 { 13766 if (assetMap[name].state !== LOADED) 13767 { 13768 return false; 13769 } 13770 } 13771 13772 return true; 13773 } 13774 13775 const queue = []; 13776 const assetMap = {}; 13777 items.forEach(item => { 13778 const asset = getAsset(item); 13779 if (asset && asset.state !== LOADED) 13780 { 13781 queue.push(asset); 13782 assetMap[asset.name] = asset; 13783 } 13784 }); 13785 13786 if (queue.length > 0) 13787 {
13788 const maxParallelLoads = 6; 13789 const parallelLoads = Math.min(queue.length, maxParallelLoads); 13790 const firstPackage = queue.splice(0, parallelLoads); 13791 firstPackage.forEach(asset => { 13792 load(asset, onLoad, doc); 13793 }); 13794 } 13795 else 13796 { 13797 callback(); 13798 } 13799 } 13800 13801 function load(asset, callback, doc) 13802 { 13803 callback = callback || BX.DoNothing; 13804 13805 if (asset.state === LOADED) 13806 { 13807 callback(); 13808 return; 13809 } 13810 13811 asset.state = LOADING; 13812 13813 loadAsset( 13814 asset, 13815 function () { 13816 asset.state = LOADED; 13817 callback(); 13818 }, 13819 doc 13820 ); 13821 } 13822 13823 function loadAsset(asset, callback, doc) 13824 { 13825 callback = callback || BX.DoNothing; 13826 13827 function error(event) 13828 { 13829 ele.onload = ele.onreadystatechange = ele.onerror = null; 13830 callback(); 13831 } 13832 13833 function process(event) 13834 { 13835 event = event || window.event; 13836 if (event.type === "load" || (/loaded|complete/.test(ele.readyState) && (!doc.documentMode || doc.documentMode < 9))) 13837 { 13838 window.clearTimeout(asset.errorTimeout); 13839 window.clearTimeout(asset.cssTimeout); 13840 ele.onload = ele.onreadystatechange = ele.onerror = null; 13841 callback(); 13842 } 13843 } 13844 13845 function isCssLoaded() 13846 { 13847 if (asset.state !== LOADED && asset.cssRetries <= 20) 13848 { 13849 for (var i = 0, l = doc.styleSheets.length; i < l; i++) 13850 { 13851 if (doc.styleSheets[i].href === ele.href) 13852 { 13853 process({"type": "load"}); 13854 return; 13855 } 13856 } 13857 13858 asset.cssRetries++; 13859 asset.cssTimeout = window.setTimeout(isCssLoaded, 250); 13860 } 13861 } 13862 13863 let ele = null; 13864 const ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 13865 13866 if (ext === "css") 13867 { 13868 ele = doc.createElement("link"); 13869 ele.type = "text/" + (asset.type || "css"); 13870 ele.rel = "stylesheet"; 13871 ele.href = asset.url; 13872 13873 asset.cssRetries = 0; 13874 asset.cssTimeout = window.setTimeout(isCssLoaded, 500); 13875 } 13876 else 13877 { 13878 ele = doc.createElement("script"); 13879 ele.type = "text/" + (asset.type || "javascript"); 13880 ele.src = asset.url; 13881 } 13882 13883 ele.onload = ele.onreadystatechange = process; 13884 ele.onerror = error; 13885 13886 ele.async = false; 13887 ele.defer = false; 13888 13889 asset.errorTimeout = window.setTimeout(function () { 13890 error({type: "timeout"}); 13891 }, 7000); 13892 13893 if (ext === "css") 13894 { 13895 cssList.push(normalizeMinUrl(normalizeUrl(asset.url))); 13896 } 13897 else 13898 { 13899 jsList.push(normalizeMinUrl(normalizeUrl(asset.url))); 13900 } 13901 13902 let templateLink = null; 13903 const head = doc.head || doc.getElementsByTagName("head")[0]; 13904 if (ext === "css" && (templateLink = getTemplateLink(head)) !== null) 13905 { 13906 templateLink.parentNode.insertBefore(ele, templateLink); 13907 } 13908 else 13909 { 13910 head.insertBefore(ele, head.lastChild); 13911 } 13912 } 13913 13914 function getAsset(item) 13915 { 13916 var asset = {}; 13917 if (typeof item === "object") 13918 { 13919 asset = item; 13920 asset.name = asset.name ? asset.name : BX.util.hashCode(item.url); 13921 } 13922 else 13923 { 13924 asset = { name: BX.util.hashCode(item), url : item }; 13925 } 13926 13927 var ext = BX.type.isNotEmptyString(asset.ext) ? asset.ext : BX.util.getExtension(asset.url); 13928 if ((ext === "css" && isCssLoaded(asset.url)) || isScriptLoaded(asset.url)) 13929 { 13930 asset.state = LOADED; 13931 } 13932 13933 var existing = assets[asset.name]; 13934 if (existing && existing.url === asset.url) 13935 { 13936 return existing; 13937 } 13938 13939 assets[asset.name] = asset; 13940 13941 return asset; 13942 } 13943 13944 function normalizeUrl(url) 13945 { 13946 if (!BX.type.isNotEmptyString(url)) 13947 { 13948 return ""; 13949 } 13950 13951 url = BX.getJSPath(url); 13952 url = url.replace(/\?[0-9]*$/, ""); 13953 13954 return url; 13955 } 13956 13957 function normalizeMinUrl(url) 13958 { 13959 if (!BX.type.isNotEmptyString(url)) 13960 { 13961 return ""; 13962 } 13963 13964 var minPos = url.indexOf(".min"); 13965 return minPos >= 0 ? url.substr(0, minPos) + url.substr(minPos + 4) : url; 13966 } 13967 13968 function isCssLoaded(fileSrc) 13969 { 13970 initCssList(); 13971 13972 fileSrc = normalizeUrl(fileSrc); 13973 var fileSrcMin = normalizeMinUrl(fileSrc); 13974 13975 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, cssList)) || BX.util.in_array(fileSrc, cssList); 13976 } 13977 13978 function initCssList() 13979 { 13980 if(!cssInit) 13981 { 13982 var linksCol = document.getElementsByTagName('link'); 13983 13984 if(!!linksCol && linksCol.length > 0) 13985 { 13986 for(var i = 0; i < linksCol.length; i++) 13987 { 13988 var href = linksCol[i].getAttribute('href'); 13989 if (BX.type.isNotEmptyString(href)) 13990 { 13991 href = normalizeMinUrl(normalizeUrl(href)); 13992 cssList.push(href); 13993 } 13994 } 13995 } 13996 cssInit = true; 13997 } 13998 } 13999 14000 function getTemplateLink(head) 14001 { 14002 var findLink = function(tag) 14003 { 14004 var links = head.getElementsByTagName(tag); 14005 for (var i = 0, length = links.length; i < length; i++) 14006 { 14007 var templateStyle = links[i].getAttribute("data-template-style"); 14008 if (BX.type.isNotEmptyString(templateStyle) && templateStyle == "true") 14009 { 14010 return links[i]; 14011 } 14012 } 14013 14014 return null; 14015 }; 14016 14017 var link = findLink("link"); 14018 if (link === null) 14019 { 14020 link = findLink("style"); 14021 } 14022 14023 return link; 14024 } 14025 14026 function isScriptLoaded(fileSrc) 14027 { 14028 initJsList(); 14029 14030 fileSrc = normalizeUrl(fileSrc); 14031 var fileSrcMin = normalizeMinUrl(fileSrc); 14032 14033 return (fileSrc !== fileSrcMin && BX.util.in_array(fileSrcMin, jsList)) || BX.util.in_array(fileSrc, jsList); 14034 } 14035 14036 function initJsList() 14037 { 14038 if(!jsInit) 14039 { 14040 var scriptCol = document.getElementsByTagName('script'); 14041 14042 if(!!scriptCol && scriptCol.length > 0) 14043 { 14044 for(var i=0; i<scriptCol.length; i++) 14045 { 14046 var src = scriptCol[i].getAttribute('src'); 14047 14048 if (BX.type.isNotEmptyString(src)) 14049 { 14050 src = normalizeMinUrl(normalizeUrl(src)); 14051 jsList.push(src); 14052 } 14053 } 14054 } 14055 jsInit = true; 14056 } 14057 } 14058 14059 function reloadInternal(back_url, bAddClearCache) 14060 { 14061 if (back_url === true) 14062 { 14063 bAddClearCache = true; 14064 back_url = null; 14065 } 14066 14067 var topWindow = (function() { 14068 if (BX.PageObject && BX.PageObject.getRootWindow) 14069 { 14070 return BX.PageObject.getRootWindow(); 14071 } 14072 14073 return window.top; 14074 })(); 14075 var new_href = back_url || topWindow.location.href; 14076 14077 var hashpos = new_href.indexOf('#'), hash = ''; 14078 14079 if (hashpos != -1) 14080 { 14081 hash = new_href.substr(hashpos); 14082 new_href = new_href.substr(0, hashpos); 14083 } 14084 14085 if (bAddClearCache && new_href.indexOf('clear_cache=Y') < 0) 14086 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + 'clear_cache=Y'; 14087 14088 if (hash) 14089 { 14090 // hack for clearing cache in ajax mode components with history emulation 14091 if (bAddClearCache && (hash.substr(0, 5) == 'view/' || hash.substr(0, 6) == '#view/') && hash.indexOf('clear_cache%3DY') < 0) 14092 hash += (hash.indexOf('%3F') == -1 ? '%3F' : '%26') + 'clear_cache%3DY'; 14093 14094 new_href = new_href.replace(/(\?|\&)_r=[\d]*/, ''); 14095 new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + '_r='+Math.round(Math.random()*10000) + hash; 14096 } 14097 14098 topWindow.location.href = new_href; 14099 } 14100 14101 BX.reload = function(back_url, bAddClearCache) 14102 { 14103 if (window !== window.top) 14104 { 14105 BX.Runtime 14106 .loadExtension('main.pageobject') 14107 .then(function() { 14108 reloadInternal(back_url, bAddClearCache); 14109 }); 14110 } 14111 else 14112 { 14113 reloadInternal(back_url, bAddClearCache); 14114 } 14115 }; 14116 14117 BX.clearCache = function() 14118 { 14119 BX.showWait(); 14120 BX.reload(true); 14121 }; 14122 14123 BX.template = function(tpl, callback, bKillTpl) 14124 { 14125 BX.ready(function() { 14126 _processTpl(BX(tpl), callback, bKillTpl); 14127 }); 14128 }; 14129 14130 BX.isAmPmMode = function(returnConst) 14131 { 14132 if (returnConst === true) 14133 { 14134 return BX.message.AMPM_MODE; 14135 } 14136 return BX.message.AMPM_MODE !== false; 14137 }; 14138 14139 BX.formatDate = function(date, format) 14140 { 14141 date = date || new Date(); 14142 14143 var bTime = date.getHours() || date.getMinutes() || date.getSeconds(), 14144 str = !!format 14145 ? format : 14146 (bTime ? BX.message('FORMAT_DATETIME') : BX.message('FORMAT_DATE') 14147 ); 14148 14149 return str.replace(/YYYY/ig, date.getFullYear()) 14150 .replace(/MMMM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14151 .replace(/MM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0')) 14152 .replace(/DD/ig, BX.util.str_pad_left(date.getDate().toString(), 2, '0')) 14153 .replace(/HH/ig, BX.util.str_pad_left(date.getHours().toString(), 2, '0')) 14154 .replace(/MI/ig, BX.util.str_pad_left(date.getMinutes().toString(), 2, '0')) 14155 .replace(/SS/ig, BX.util.str_pad_left(date.getSeconds().toString(), 2, '0')); 14156 }; 14157 BX.formatName = function(user, template, login) 14158 { 14159 user = user || {}; 14160 template = (template || ''); 14161 var replacement = { 14162 TITLE : (user["TITLE"] || ''), 14163 NAME : (user["NAME"] || ''),
14164 LAST_NAME : (user["LAST_NAME"] || ''), 14165 SECOND_NAME : (user["SECOND_NAME"] || ''), 14166 LOGIN : (user["LOGIN"] || ''), 14167 NAME_SHORT : user["NAME"] ? user["NAME"].substr(0, 1) + '.' : '', 14168 LAST_NAME_SHORT : user["LAST_NAME"] ? user["LAST_NAME"].substr(0, 1) + '.' : '', 14169 SECOND_NAME_SHORT : user["SECOND_NAME"] ? user["SECOND_NAME"].substr(0, 1) + '.' : '', 14170 EMAIL : (user["EMAIL"] || ''), 14171 ID : (user["ID"] || ''), 14172 NOBR : "", 14173 '/NOBR' : "" 14174 }, result = template; 14175 for (var ii in replacement) 14176 { 14177 if (replacement.hasOwnProperty(ii)) 14178 { 14179 result = result.replace("#" + ii+ "#", replacement[ii]) 14180 } 14181 } 14182 result = result.replace(/([\s]+)/gi, " ").trim(); 14183 if (result == "") 14184 { 14185 result = (login == "Y" ? replacement["LOGIN"] : ""); 14186 result = (result == "" ? "Noname" : result); 14187 } 14188 return result; 14189 }; 14190 14191 BX.getNumMonth = function(month) 14192 { 14193 var wordMonthCut = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; 14194 var wordMonth = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']; 14195 14196 var q = month.toUpperCase(); 14197 for (i = 1; i <= 12; i++) 14198 { 14199 if (q == BX.message('MON_'+i).toUpperCase() || q == BX.message('MONTH_'+i).toUpperCase() || q == wordMonthCut[i-1].toUpperCase() || q == wordMonth[i-1].toUpperCase()) 14200 { 14201 return i; 14202 } 14203 } 14204 return month; 14205 }; 14206 14207 BX.parseDate = function(str, bUTC, formatDate, formatDatetime) 14208 { 14209 if (BX.type.isNotEmptyString(str)) 14210 { 14211 if (!formatDate) 14212 formatDate = BX.message('FORMAT_DATE'); 14213 if (!formatDatetime) 14214 formatDatetime = BX.message('FORMAT_DATETIME'); 14215 14216 var regMonths = ''; 14217 for (i = 1; i <= 12; i++) 14218 { 14219 regMonths = regMonths + '|' + BX.message('MON_'+i); 14220 } 14221
14222 var expr = new RegExp('([0-9]+|[a-z]+' + regMonths + ')', 'ig'); 14223 var aDate = str.match(expr), 14224 aFormat = formatDate.match(/(DD|MI|MMMM|MM|M|YYYY)/ig), 14225 i, cnt, 14226 aDateArgs=[], aFormatArgs=[], 14227 aResult={}; 14228 14229 if (!aDate) 14230 return null; 14231 14232 if(aDate.length > aFormat.length) 14233 { 14234 aFormat = formatDatetime.match(/(DD|MI|MMMM|MM|M|YYYY|HH|H|SS|TT|T|GG|G)/ig); 14235 } 14236 14237 for(i = 0, cnt = aDate.length; i < cnt; i++) 14238 { 14239 if(BX.util.trim(aDate[i]) != '') 14240 { 14241 aDateArgs[aDateArgs.length] = aDate[i]; 14242 } 14243 } 14244 14245 for(i = 0, cnt = aFormat.length; i < cnt; i++) 14246 { 14247 if(BX.util.trim(aFormat[i]) != '') 14248 { 14249 aFormatArgs[aFormatArgs.length] = aFormat[i]; 14250 } 14251 } 14252 14253 14254 var m = BX.util.array_search('MMMM', aFormatArgs); 14255 if (m > 0) 14256 { 14257 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 14258 aFormatArgs[m] = "MM"; 14259 } 14260 else 14261 { 14262 m = BX.util.array_search('M', aFormatArgs); 14263 if (m > 0) 14264 { 14265 aDateArgs[m] = BX.getNumMonth(aDateArgs[m]); 14266 aFormatArgs[m] = "MM"; 14267 } 14268 } 14269 14270 for(i = 0, cnt = aFormatArgs.length; i < cnt; i++) 14271 { 14272 var k = aFormatArgs[i].toUpperCase(); 14273 aResult[k] = k == 'T' || k == 'TT' ? aDateArgs[i] : parseInt(aDateArgs[i], 10); 14274 } 14275 14276 if(aResult['DD'] > 0 && aResult['MM'] > 0 && aResult['YYYY'] > 0) 14277 { 14278 var d = new Date(); 14279 14280 if(bUTC) 14281 { 14282 d.setUTCDate(1); 14283 d.setUTCFullYear(aResult['YYYY']); 14284 d.setUTCMonth(aResult['MM'] - 1); 14285 d.setUTCDate(aResult['DD']); 14286 d.setUTCHours(0, 0, 0, 0); 14287 } 14288 else 14289 { 14290 d.setDate(1); 14291 d.setFullYear(aResult['YYYY']); 14292 d.setMonth(aResult['MM'] - 1); 14293 d.setDate(aResult['DD']); 14294 d.setHours(0, 0, 0, 0); 14295 } 14296 14297 if( 14298 (!isNaN(aResult['HH']) || !isNaN(aResult['GG']) || !isNaN(aResult['H']) || !isNaN(aResult['G'])) 14299 && !isNaN(aResult['MI']) 14300 ) 14301 { 14302 if (!isNaN(aResult['H']) || !isNaN(aResult['G'])) 14303 { 14304 var bPM = (aResult['T']||aResult['TT']||'am').toUpperCase()=='PM'; 14305 var h = parseInt(aResult['H']||aResult['G']||0, 10); 14306 if(bPM) 14307 { 14308 aResult['HH'] = h + (h == 12 ? 0 : 12); 14309 } 14310 else 14311 { 14312 aResult['HH'] = h < 12 ? h : 0; 14313 } 14314 } 14315 else 14316 { 14317 aResult['HH'] = parseInt(aResult['HH']||aResult['GG']||0, 10); 14318 } 14319 14320 if (isNaN(aResult['SS'])) 14321 aResult['SS'] = 0; 14322 14323 if(bUTC) 14324 { 14325 d.setUTCHours(aResult['HH'], aResult['MI'], aResult['SS']); 14326 } 14327 else 14328 { 14329 d.setHours(aResult['HH'], aResult['MI'], aResult['SS']); 14330 } 14331 } 14332 14333 return d; 14334 } 14335 } 14336 14337 return null; 14338 }; 14339 14340 BX.selectUtils = 14341 { 14342 addNewOption: function(oSelect, opt_value, opt_name, do_sort, check_unique) 14343 { 14344 oSelect = BX(oSelect); 14345 if(oSelect) 14346 { 14347 var n = oSelect.length; 14348 if(check_unique !== false) 14349 { 14350 for(var i=0;i<n;i++) 14351 { 14352 if(oSelect[i].value==opt_value) 14353 { 14354 return; 14355 } 14356 } 14357 } 14358 14359 oSelect.options[n] = new Option(opt_name, opt_value, false, false); 14360 } 14361 14362 if(do_sort === true) 14363 { 14364 this.sortSelect(oSelect); 14365 } 14366 }, 14367 14368 deleteOption: function(oSelect, opt_value) 14369 { 14370 oSelect = BX(oSelect); 14371 if(oSelect) 14372 { 14373 for(var i=0;i<oSelect.length;i++) 14374 { 14375 if(oSelect[i].value==opt_value) 14376 { 14377 oSelect.remove(i); 14378 break; 14379 } 14380 } 14381 } 14382 }, 14383 14384 deleteSelectedOptions: function(oSelect) 14385 { 14386 oSelect = BX(oSelect); 14387 if(oSelect) 14388 { 14389 var i=0; 14390 while(i<oSelect.length) 14391 { 14392 if(oSelect[i].selected) 14393 { 14394 oSelect[i].selected=false; 14395 oSelect.remove(i); 14396 } 14397 else 14398 { 14399 i++; 14400 } 14401 } 14402 } 14403 }, 14404 14405 deleteAllOptions: function(oSelect) 14406 { 14407 oSelect = BX(oSelect); 14408 if(oSelect) 14409 { 14410 for(var i=oSelect.length-1; i>=0; i--) 14411 { 14412 oSelect.remove(i); 14413 } 14414 } 14415 }, 14416 14417 optionCompare: function(record1, record2) 14418 { 14419 var value1 = record1.optText.toLowerCase(); 14420 var value2 = record2.optText.toLowerCase(); 14421 if (value1 > value2) return(1); 14422 if (value1 < value2) return(-1); 14423 return(0); 14424 }, 14425 14426 sortSelect: function(oSelect) 14427 { 14428 oSelect = BX(oSelect); 14429 if(oSelect) 14430 { 14431 var myOptions = []; 14432 var n = oSelect.options.length; 14433 var i; 14434 for (i=0;i<n;i++) 14435 { 14436 myOptions[i] = { 14437 optText:oSelect[i].text, 14438 optValue:oSelect[i].value 14439 }; 14440 } 14441 myOptions.sort(this.optionCompare); 14442 oSelect.length=0; 14443 n = myOptions.length; 14444 for(i=0;i<n;i++) 14445 { 14446 oSelect[i] = new Option(myOptions[i].optText, myOptions[i].optValue, false, false); 14447 } 14448 } 14449 }, 14450 14451 selectAllOptions: function(oSelect) 14452 { 14453 oSelect = BX(oSelect); 14454 if(oSelect) 14455 { 14456 var n = oSelect.length; 14457 for(var i=0;i<n;i++) 14458 { 14459 oSelect[i].selected=true; 14460 } 14461 } 14462 }, 14463 14464 selectOption: function(oSelect, opt_value) 14465 { 14466 oSelect = BX(oSelect); 14467 if(oSelect) 14468 { 14469 var n = oSelect.length; 14470 for(var i=0;i<n;i++) 14471 { 14472 oSelect[i].selected = (oSelect[i].value == opt_value); 14473 } 14474 } 14475 }, 14476 14477 addSelectedOptions: function(oSelect, to_select_id, check_unique, do_sort) 14478 { 14479 oSelect = BX(oSelect); 14480 if(!oSelect) 14481 return; 14482 var n = oSelect.length; 14483 for(var i=0; i<n; i++) 14484 if(oSelect[i].selected) 14485 this.addNewOption(to_select_id, oSelect[i].value, oSelect[i].text, do_sort, check_unique); 14486 }, 14487 14488 moveOptionsUp: function(oSelect) 14489 { 14490 oSelect = BX(oSelect); 14491 if(!oSelect) 14492 return; 14493 var n = oSelect.length; 14494 for(var i=0; i<n; i++) 14495 { 14496 if(oSelect[i].selected && i>0 && oSelect[i-1].selected == false) 14497 { 14498 var option = new Option(oSelect[i].text, oSelect[i].value); 14499 oSelect[i] = new Option(oSelect[i-1].text, oSelect[i-1].value); 14500 oSelect[i].selected = false;
14501 oSelect[i-1] = option; 14502 oSelect[i-1].selected = true; 14503 } 14504 } 14505 }, 14506 14507 moveOptionsDown: function(oSelect) 14508 { 14509 oSelect = BX(oSelect); 14510 if(!oSelect) 14511 return; 14512 var n = oSelect.length; 14513 for(var i=n-1; i>=0; i--) 14514 { 14515 if(oSelect[i].selected && i<n-1 && 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 14527 BX.getEventTarget = function(e) 14528 { 14529 if(e.target) 14530 { 14531 return e.target; 14532 } 14533 else if(e.srcElement) 14534 { 14535 return e.srcElement; 14536 } 14537 return null; 14538 }; 14539 14540 BX.convert = { 14541 toNumber: function(value) 14542 { 14543 if(BX.type.isNumber(value)) 14544 { 14545 return value; 14546 } 14547 14548 value = Number(value); 14549 return !isNaN(value) ? value : 0; 14550 }, 14551 nodeListToArray: function(nodes) 14552 { 14553 try 14554 { 14555 return (Array.prototype.slice.call(nodes, 0)); 14556 } 14557 catch (ex) 14558 { 14559 var ary = []; 14560 for(var i = 0, l = nodes.length; i < l; i++) 14561 { 14562 ary.push(nodes[i]); 14563 } 14564 return ary; 14565 } 14566 } 14567 }; 14568 14569 /******* HINT ***************/ 14570// if function has 2 params - the 2nd one is hint html. otherwise hint_html is third and hint_title - 2nd; 14571// '<div onmouseover="BX.hint(this, 'This is <b>Hint</b>')"'>; 14572// BX.hint(el, 'This is <b>Hint</b>') - this won't work, use constructor 14573 BX.hint = function(el, hint_title, hint_html, hint_id) 14574 { 14575 if (null == hint_html) 14576 { 14577 hint_html = hint_title; 14578 hint_title = ''; 14579 } 14580 14581 if (null == el.BXHINT) 14582 { 14583 el.BXHINT = new BX.CHint({ 14584 parent: el, hint: hint_html, title: hint_title, id: hint_id 14585 }); 14586 el.BXHINT.Show(); 14587 } 14588 }; 14589 14590 BX.hint_replace = function(el, hint_title, hint_html) 14591 { 14592 if (null == hint_html) 14593 { 14594 hint_html = hint_title; 14595 hint_title = ''; 14596 } 14597 14598 if (!el || !el.parentNode || !hint_html) 14599 return null; 14600 14601 var obHint = new BX.CHint({ 14602 hint: hint_html, 14603 title: hint_title 14604 }); 14605 14606 obHint.CreateParent(); 14607 14608 el.parentNode.insertBefore(obHint.PARENT, el); 14609 el.parentNode.removeChild(el); 14610 14611 obHint.PARENT.style.marginLeft = '5px'; 14612 14613 return el; 14614 }; 14615 14616 BX.CHint = function(params) 14617 { 14618 if (BX.CHint.cssLoaded === false) 14619 { 14620 BX.load(['/bitrix/js/main/core/css/core_hint.css']); 14621 BX.CHint.cssLoaded = true; 14622 } 14623 14624 this.PARENT = BX(params.parent); 14625 14626 this.HINT = params.hint; 14627 this.HINT_TITLE = params.title; 14628 14629 this.PARAMS = {}; 14630 for (var i in this.defaultSettings) 14631 { 14632 if (null == params[i]) 14633 this.PARAMS[i] = this.defaultSettings[i]; 14634 else 14635 this.PARAMS[i] = params[i]; 14636 } 14637 14638 if (null != params.id) 14639 this.ID = params.id; 14640 14641 this.timer = null; 14642 this.bInited = false; 14643 this.msover = true; 14644 14645 if (this.PARAMS.showOnce) 14646 { 14647 this.__show(); 14648 this.msover = false; 14649 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14650 } 14651 else if (this.PARENT) 14652 { 14653 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14654 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14655 } 14656 }; 14657 14658 BX.CHint.cssLoaded = false; 14659 14660 BX.CHint.openHints = new Set(); 14661 14662 BX.CHint.globalDisabled = false; 14663 14664 BX.CHint.handleMenuOpen = function() { 14665 BX.CHint.globalDisabled = true; 14666 14667 BX.CHint.openHints.forEach(function(hint) { 14668 hint.__hide_immediately(); 14669 }); 14670 }; 14671 14672 BX.CHint.handleMenuClose = function() { 14673 BX.CHint.globalDisabled = false; 14674 }; 14675 14676 BX.addCustomEvent('onMenuOpen', BX.CHint.handleMenuOpen); 14677 BX.addCustomEvent('onMenuClose', BX.CHint.handleMenuClose); 14678 14679 BX.CHint.prototype.defaultSettings = { 14680 show_timeout: 1000, 14681 hide_timeout: 500, 14682 dx: 2, 14683 showOnce: false, 14684 preventHide: true, 14685 min_width: 250 14686 }; 14687 14688 BX.CHint.prototype.CreateParent = function(element, params) 14689 { 14690 if (this.PARENT) 14691 { 14692 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14693 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14694 } 14695 14696 if (!params) params = {}; 14697 var type = 'icon'; 14698 14699 if (params.type && (params.type == "link" || params.type == "icon")) 14700 type = params.type; 14701 14702 if (element) 14703 type = "element";
14704 14705 if (type == "icon") 14706 { 14707 element = BX.create('IMG', { 14708 props: { 14709 src: params.iconSrc 14710 ? params.iconSrc 14711 : "/bitrix/js/main/core/images/hint.gif" 14712 } 14713 }); 14714 } 14715 else if (type == "link") 14716 { 14717 element = BX.create("A", { 14718 props: {href: 'javascript:void(0)'}, 14719 html: '[?]' 14720 }); 14721 } 14722 14723 this.PARENT = element; 14724 14725 BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14726 BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14727 14728 return this.PARENT; 14729 }; 14730 14731 BX.CHint.prototype.Show = function() 14732 { 14733 this.msover = true; 14734 14735 if (null != this.timer) 14736 clearTimeout(this.timer); 14737 14738 this.timer = setTimeout(BX.proxy(this.__show, this), this.PARAMS.show_timeout); 14739 }; 14740 14741 BX.CHint.prototype.Hide = function() 14742 { 14743 this.msover = false; 14744 14745 if (null != this.timer) 14746 clearTimeout(this.timer); 14747 14748 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14749 }; 14750 14751 BX.CHint.prototype.__show = function() 14752 { 14753 if (!this.msover || this.disabled || BX.CHint.globalDisabled) return; 14754 if (!this.bInited) this.Init(); 14755 14756 if (this.prepareAdjustPos()) 14757 { 14758 this.DIV.style.display = 'block'; 14759 BX.ZIndexManager.bringToFront(this.DIV); 14760 14761 this.adjustPos(); 14762 14763 BX.CHint.openHints.add(this); 14764 14765 BX.bind(window, 'scroll', BX.proxy(this.__onscroll, this)); 14766 14767 if (this.PARAMS.showOnce) 14768 { 14769 this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout); 14770 } 14771 } 14772 }; 14773 14774 BX.CHint.prototype.__onscroll = function() 14775 { 14776 if (!BX.admin || !BX.admin.panel || !BX.admin.panel.isFixed()) return; 14777 14778 if (this.scrollTimer) clearTimeout(this.scrollTimer); 14779 14780 this.DIV.style.display = 'none'; 14781 this.scrollTimer = setTimeout(BX.proxy(this.Reopen, this), this.PARAMS.show_timeout); 14782 }; 14783 14784 BX.CHint.prototype.Reopen = function() 14785 { 14786 if (null != this.timer) clearTimeout(this.timer); 14787 this.timer = setTimeout(BX.proxy(this.__show, this), 50); 14788 }; 14789 14790 BX.CHint.prototype.__hide = function() 14791 { 14792 if (this.msover) return; 14793 if (!this.bInited) return; 14794 14795 BX.unbind(window, 'scroll', BX.proxy(this.Reopen, this)); 14796 14797 BX.CHint.openHints.delete(this); 14798 14799 if (this.PARAMS.showOnce) 14800 { 14801 this.Destroy(); 14802 } 14803 else 14804 { 14805 this.DIV.style.display = 'none'; 14806 } 14807 }; 14808 14809 BX.CHint.prototype.__hide_immediately = function() 14810 { 14811 this.msover = false; 14812 this.__hide(); 14813 }; 14814 14815 BX.CHint.prototype.Init = function() 14816 { 14817 this.DIV = document.body.appendChild(BX.create('DIV', { 14818 props: {className: 'bx-panel-tooltip'}, 14819 style: { 14820 display: 'none', 14821 position: 'absolute', 14822 visibility: 'hidden' 14823 }, 14824 children: [ 14825 (this.CONTENT = BX.create('DIV', { 14826 props: {className: 'bx-panel-tooltip-content'}, 14827 children: [ 14828 BX.create('DIV', { 14829 props: {className: 'bx-panel-tooltip-underlay'}, 14830 children: [ 14831 BX.create('DIV', {props: {className: 'bx-panel-tooltip-underlay-bg'}}) 14832 ] 14833 }) 14834 ] 14835 })) 14836 ] 14837 })); 14838 14839 BX.ZIndexManager.register(this.DIV); 14840 14841 if (this.ID) 14842 { 14843 this.CONTENT.insertBefore(BX.create('A', { 14844 attrs: {href: 'javascript:void(0)'}, 14845 props: {className: 'bx-panel-tooltip-close'}, 14846 events: {click: BX.delegate(this.Close, this)} 14847 }), this.CONTENT.firstChild); 14848 } 14849 14850 if (this.HINT_TITLE) 14851 { 14852 this.CONTENT.appendChild( 14853 BX.create('DIV', { 14854 props: {className: 'bx-panel-tooltip-title'}, 14855 text: this.HINT_TITLE 14856 }) 14857 ); 14858 } 14859 14860 if (this.HINT) 14861 { 14862 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT})); 14863 } 14864 14865 if (this.PARAMS.preventHide) 14866 { 14867 BX.bind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 14868 BX.bind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 14869 } 14870 14871 this.bInited = true; 14872 }; 14873 14874 BX.CHint.prototype.setContent = function(content) 14875 { 14876 this.HINT = content; 14877 14878 if (this.CONTENT_TEXT) 14879 this.CONTENT_TEXT.innerHTML = this.HINT; 14880 else 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 BX.CHint.prototype.prepareAdjustPos = function() 14885 { 14886 this._wnd = {scrollPos: BX.GetWindowScrollPos(),scrollSize:BX.GetWindowScrollSize()}; 14887 return BX.style(this.PARENT, 'display') != 'none'; 14888 }; 14889 14890 BX.CHint.prototype.getAdjustPos = function() 14891 { 14892 var res = {}, pos = BX.pos(this.PARENT), min_top = 0; 14893 14894 res.top = pos.bottom + this.PARAMS.dx; 14895 14896 if (BX.admin && BX.admin.panel.DIV) 14897 { 14898 min_top = BX.admin.panel.DIV.offsetHeight + this.PARAMS.dx; 14899 14900 if (BX.admin.panel.isFixed()) 14901 { 14902 min_top += this._wnd.scrollPos.scrollTop; 14903 } 14904 } 14905 14906 if (res.top < min_top) 14907 res.top = min_top; 14908 else 14909 { 14910 if (res.top + this.DIV.offsetHeight > this._wnd.scrollSize.scrollHeight) 14911 res.top = pos.top - this.PARAMS.dx - this.DIV.offsetHeight; 14912 } 14913 14914 res.left = pos.left; 14915 if (pos.left < this.PARAMS.dx) 14916 pos.left = this.PARAMS.dx; 14917 else 14918 { 14919 var floatWidth = this.DIV.offsetWidth; 14920 14921 var max_left = this._wnd.scrollSize.scrollWidth - floatWidth - this.PARAMS.dx; 14922 14923 if (res.left > max_left) 14924 res.left = max_left; 14925 } 14926 14927 return res; 14928 }; 14929 14930 BX.CHint.prototype.adjustWidth = function() 14931 { 14932 if (this.bWidthAdjusted) return; 14933 14934 var w = this.DIV.offsetWidth, h = this.DIV.offsetHeight; 14935 14936 if (w > this.PARAMS.min_width) 14937 w = Math.round(Math.sqrt(1.618*w*h)); 14938 14939 if (w < this.PARAMS.min_width) 14940 w = this.PARAMS.min_width; 14941 14942 this.DIV.style.width = w + "px"; 14943 14944 if (this._adjustWidthInt) 14945 clearInterval(this._adjustWidthInt); 14946 this._adjustWidthInt = setInterval(BX.delegate(this._adjustWidthInterval, this), 5); 14947 14948 this.bWidthAdjusted = true; 14949 }; 14950 14951 BX.CHint.prototype._adjustWidthInterval = function() 14952 { 14953 if (!this.DIV || this.DIV.style.display == 'none') 14954 clearInterval(this._adjustWidthInt); 14955 14956 var
14957 dW = 20, 14958 maxWidth = 1500, 14959 w = this.DIV.offsetWidth, 14960 w1 = this.CONTENT_TEXT.offsetWidth; 14961 14962 if (w > 0 && w1 > 0 && w - w1 < dW && w < maxWidth) 14963 { 14964 this.DIV.style.width = (w + dW) + "px"; 14965 return; 14966 } 14967 14968 clearInterval(this._adjustWidthInt); 14969 }; 14970 14971 BX.CHint.prototype.adjustPos = function() 14972 { 14973 this.adjustWidth(); 14974 14975 var pos = this.getAdjustPos(); 14976 14977 this.DIV.style.top = pos.top + 'px'; 14978 this.DIV.style.left = pos.left + 'px'; 14979 }; 14980 14981 BX.CHint.prototype.Close = function() 14982 { 14983 if (this.ID && BX.WindowManager) 14984 BX.WindowManager.saveWindowOptions(this.ID, {display: 'off'}); 14985 this.__hide_immediately(); 14986 this.Destroy(); 14987 }; 14988 14989 BX.CHint.prototype.Destroy = function() 14990 { 14991 if (this.PARENT) 14992 { 14993 BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this)); 14994 BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this)); 14995 } 14996 14997 if (this.DIV) 14998 { 14999 BX.unbind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 15000 BX.unbind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 15001 15002 BX.ZIndexManager.unregister(this.DIV); 15003 15004 BX.cleanNode(this.DIV, true); 15005 } 15006 }; 15007 15008 BX.CHint.prototype.enable = function(){this.disabled = false;}; 15009 BX.CHint.prototype.disable = function(){this.__hide_immediately(); this.disabled = true;}; 15010 15011 15012 function _adjustWait() 15013 { 15014 if (!this.bxmsg) return; 15015 15016 var arContainerPos = BX.pos(this), 15017 div_top = arContainerPos.top; 15018 15019 if (div_top < BX.GetDocElement().scrollTop) 15020 div_top = BX.GetDocElement().scrollTop + 5; 15021 15022 this.bxmsg.style.top = (div_top + 5) + 'px'; 15023 15024 if (this == BX.GetDocElement()) 15025 { 15026 this.bxmsg.style.right = '5px'; 15027 } 15028 else 15029 { 15030 this.bxmsg.style.left = (arContainerPos.right - this.bxmsg.offsetWidth - 5) + 'px'; 15031 } 15032 } 15033 15034 function _processTpl(tplNode, cb, bKillTpl) 15035 { 15036 if (tplNode) 15037 { 15038 if (bKillTpl) 15039 tplNode.parentNode.removeChild(tplNode); 15040 15041 var res = {}, nodes = BX.findChildren(tplNode, {attribute: 'data-role'}, true); 15042 15043 for (var i = 0, l = nodes.length; i < l; i++) 15044 { 15045 res[nodes[i].getAttribute('data-role')] = nodes[i]; 15046 } 15047 15048 cb.apply(tplNode, [res]); 15049 } 15050 } 15051 15052 function _checkNode(obj, params) 15053 { 15054 params = params || {}; 15055 15056 if (BX.type.isFunction(params)) 15057 return params.call(window, obj); 15058 15059 if (!params.allowTextNodes && !BX.type.isElementNode(obj)) 15060 return false; 15061 var i,j,len; 15062 for (i in params) 15063 { 15064 if(params.hasOwnProperty(i)) 15065 { 15066 switch(i) 15067 { 15068 case 'tag': 15069 case 'tagName': 15070 if (BX.type.isString(params[i])) 15071 { 15072 if (obj.tagName.toUpperCase() != params[i].toUpperCase()) 15073 return false; 15074 } 15075 else if (params[i] instanceof RegExp) 15076 { 15077 if (!params[i].test(obj.tagName)) 15078 return false; 15079 } 15080 break; 15081 15082 case 'class': 15083 case 'className': 15084 if (BX.type.isString(params[i])) 15085 { 15086 if (!BX.hasClass(obj, params[i])) 15087 return false; 15088 } 15089 else if (params[i] instanceof RegExp) 15090 { 15091 if (!BX.type.isString(obj.className) || !params[i].test(obj.className)) 15092 return false; 15093 } 15094 break; 15095 15096 case 'attr': 15097 case 'attrs': 15098 case 'attribute': 15099 if (BX.type.isString(params[i])) 15100 { 15101 if (!obj.getAttribute(params[i])) 15102 return false; 15103 } 15104 else if (BX.type.isArray(params[i])) 15105 { 15106 for (j = 0, len = params[i].length; j < len; j++) 15107 { 15108 if (params[i] && !obj.getAttribute(params[i])) 15109 return false; 15110 } 15111 } 15112 else 15113 { 15114 for (j in params[i]) 15115 { 15116 if(params[i].hasOwnProperty(j)) 15117 { 15118 var q = obj.getAttribute(j); 15119 if (params[i][j] instanceof RegExp) 15120 { 15121 if (!BX.type.isString(q) || !params[i][j].test(q)) 15122 { 15123 return false; 15124 } 15125 } 15126 else 15127 { 15128 if (q != '' + params[i][j]) 15129 { 15130 return false; 15131 } 15132 } 15133 } 15134 } 15135 } 15136 break; 15137 15138 case 'property': 15139 case 'props': 15140 if (BX.type.isString(params[i])) 15141 { 15142 if (!obj[params[i]]) 15143 return false; 15144 } 15145 else if (BX.type.isArray(params[i])) 15146 { 15147 for (j = 0, len = params[i].length; j < len; j++) 15148 { 15149 if (params[i] && !obj[params[i]]) 15150 return false;
15151 } 15152 } 15153 else 15154 { 15155 for (j in params[i]) 15156 { 15157 if (BX.type.isString(params[i][j])) 15158 { 15159 if (obj[j] != params[i][j]) 15160 return false; 15161 } 15162 else if (params[i][j] instanceof RegExp) 15163 { 15164 if (!BX.type.isString(obj[j]) || !params[i][j].test(obj[j])) 15165 return false; 15166 } 15167 } 15168 } 15169 break; 15170 15171 case 'callback': 15172 return params[i](obj); 15173 } 15174 } 15175 } 15176 15177 return true; 15178 } 15179 15180 /* garbage collector */ 15181 function Trash() 15182 { 15183 var i,len; 15184 15185 for (i = 0, len = garbageCollectors.length; i<len; i++) 15186 { 15187 try { 15188 garbageCollectors[i].callback.apply(garbageCollectors[i].context || window); 15189 delete garbageCollectors[i]; 15190 garbageCollectors[i] = null; 15191 } catch (e) {} 15192 } 15193 } 15194 15195 if(window.attachEvent) // IE 15196 window.attachEvent("onunload", Trash); 15197 else if(window.addEventListener) // Gecko / W3C 15198 window.addEventListener('unload', Trash, false); 15199 else 15200 window.onunload = Trash; 15201 /* \garbage collector */ 15202 15203// set empty ready handler 15204 BX(BX.DoNothing); 15205 window.BX = BX; 15206 15207 BX.browser.addGlobalClass(); 15208 15209 /* data storage */ 15210 BX.data = function(node, key, value) 15211 { 15212 if(typeof node == 'undefined') 15213 return undefined; 15214 15215 if(typeof key == 'undefined') 15216 return undefined; 15217 15218 if(typeof value != 'undefined') 15219 { 15220 // write to manager 15221 dataStorage.set(node, key, value); 15222 } 15223 else 15224 { 15225 var data; 15226 15227 // from manager 15228 if((data = dataStorage.get(node, key)) != undefined) 15229 { 15230 return data; 15231 } 15232 else 15233 { 15234 // from attribute data-* 15235 if('getAttribute' in node) 15236 { 15237 data = node.getAttribute('data-'+key.toString()); 15238 if(data === null) 15239 { 15240 return undefined; 15241 } 15242 return data; 15243 } 15244 } 15245 15246 return undefined; 15247 } 15248 }; 15249 15250 BX.DataStorage = function() 15251 { 15252 15253 this.keyOffset = 1; 15254 this.data = {}; 15255 this.uniqueTag = 'BX-'+Math.random(); 15256 15257 this.resolve = function(owner, create){ 15258 if(typeof owner[this.uniqueTag] == 'undefined') 15259 if(create) 15260 { 15261 try 15262 { 15263 Object.defineProperty(owner, this.uniqueTag, { 15264 value: this.keyOffset++ 15265 }); 15266 } 15267 catch(e) 15268 { 15269 owner[this.uniqueTag] = this.keyOffset++; 15270 } 15271 } 15272 else 15273 return undefined; 15274 15275 return owner[this.uniqueTag]; 15276 }; 15277 this.get = function(owner, key){ 15278 if((owner != document && !BX.type.isElementNode(owner)) || typeof key == 'undefined') 15279 return undefined; 15280 15281 owner = this.resolve(owner, false); 15282 15283 if(typeof owner == 'undefined' || typeof this.data[owner] == 'undefined') 15284 return undefined; 15285 15286 return this.data[owner][key]; 15287 }; 15288 this.set = function(owner, key, value){ 15289 15290 if((owner != document && !BX.type.isElementNode(owner)) || typeof value == 'undefined') 15291 return; 15292 15293 var o = this.resolve(owner, true); 15294 15295 if(typeof this.data[o] == 'undefined') 15296 this.data[o] = {}; 15297 15298 this.data[o][key] = value; 15299 }; 15300 }; 15301 15302// some internal variables for new logic 15303 var dataStorage = new BX.DataStorage(); // manager which BX.data() uses to keep data 15304})(window.BX); 15305 15306;(function(window) 15307{ 15308 /****************** ATTENTION ******************************* 15309 * Please do not use Bitrix CoreJS in this class. 15310 * This class can be called on page without Bitrix Framework 15311 *************************************************************/ 15312 15313 if (!window.BX) 15314 { 15315 window.BX = {}; 15316 } 15317 15318 var BX = window.BX; 15319 15320 BX.Promise = function(fn, ctx) // fn is future-reserved 15321 { 15322 this.state = null; 15323 this.value = null; 15324 this.reason = null; 15325 this.next = null; 15326 this.ctx = ctx || this; 15327 15328 this.onFulfilled = []; 15329 this.onRejected = []; 15330 }; 15331 BX.Promise.prototype.fulfill = function(value) 15332 { 15333 this.checkState(); 15334 15335 this.value = value; 15336 this.state = true; 15337 this.execute(); 15338 }; 15339 BX.Promise.prototype.reject = function(reason) 15340 { 15341 this.checkState(); 15342 15343 this.reason = reason; 15344 this.state = false; 15345 this.execute(); 15346 }; 15347 BX.Promise.prototype.then = function(onFulfilled, onRejected) 15348 { 15349 if(typeof (onFulfilled) == "function" || onFulfilled instanceof Function) 15350 { 15351 this.onFulfilled.push(onFulfilled); 15352 } 15353 if(typeof (onRejected) == "function" || onRejected instanceof Function) 15354 { 15355 this.onRejected.push(onRejected); 15356 } 15357 15358 if(this.next === null) 15359 { 15360 this.next = new BX.Promise(null, this.ctx); 15361 } 15362 15363 if(this.state !== null) // if promise was already resolved, execute immediately 15364 { 15365 this.execute(); 15366 } 15367 15368 return this.next; 15369 }; 15370 15371 BX.Promise.prototype.catch = function(onRejected) 15372 { 15373 if(typeof (onRejected) == "function" || onRejected instanceof Function) 15374 { 15375 this.onRejected.push(onRejected); 15376 } 15377 15378 if(this.next === null) 15379 { 15380 this.next = new BX.Promise(null, this.ctx); 15381 } 15382 15383 if(this.state !== null) // if promise was already resolved, execute immediately 15384 { 15385 this.execute(); 15386 } 15387 15388 return this.next; 15389 }; 15390 15391 BX.Promise.prototype.setAutoResolve = function(way, ms) 15392 { 15393 this.timer = setTimeout(function(){ 15394 if(this.state === null) 15395 { 15396 this[way ? 'fulfill' : 'reject'](); 15397 } 15398 }.bind(this), ms || 15); 15399 };
15400 BX.Promise.prototype.cancelAutoResolve = function() 15401 { 15402 clearTimeout(this.timer); 15403 }; 15404 /** 15405 * Resolve function. This function allows promise chaining, like ..then().then()... 15406 * Typical usage: 15407 * 15408 * var p = new Promise(); 15409 * 15410 * p.then(function(value){ 15411 * return someValue; // next promise in the chain will be fulfilled with someValue 15412 * }).then(function(value){ 15413 * 15414 * var p1 = new Promise(); 15415 * *** some async code here, that eventually resolves p1 *** 15416 * 15417 * return p1; // chain will resume when p1 resolved (fulfilled or rejected) 15418 * }).then(function(value){ 15419 * 15420 * // you can also do 15421 * var e = new Error(); 15422 * throw e; 15423 * // it will cause next promise to be rejected with e 15424 * 15425 * return someOtherValue; 15426 * }).then(function(value){ 15427 * ... 15428 * }, function(reason){ 15429 * // promise was rejected with reason 15430 * })...; 15431 * 15432 * p.fulfill('let`s start this chain'); 15433 * 15434 * @param x 15435 */ 15436 BX.Promise.prototype.resolve = function(x) 15437 { 15438 var this_ = this; 15439 15440 if(this === x) 15441 { 15442 this.reject(new TypeError('Promise cannot fulfill or reject itself')); // avoid recursion 15443 } 15444 // allow "pausing" promise chaining until promise x is fulfilled or rejected 15445 else if(x && x.toString() === "[object BX.Promise]") 15446 { 15447 x.then(function(value){ 15448 this_.fulfill(value); 15449 }, function(reason){ 15450 this_.reject(reason); 15451 }); 15452 } 15453 else // auto-fulfill this promise 15454 { 15455 this.fulfill(x); 15456 } 15457 }; 15458 15459 BX.Promise.prototype.toString = function() 15460 { 15461 return "[object BX.Promise]"; 15462 }; 15463 15464 BX.Promise.prototype.execute = function() 15465 { 15466 if(this.state === null) 15467 { 15468 //then() must not be called before BX.Promise resolve() happens 15469 return; 15470 } 15471 15472 var value = undefined; 15473 var reason = undefined; 15474 var x = undefined; 15475 var k; 15476 if(this.state === true) // promise was fulfill()-ed 15477 { 15478 if(this.onFulfilled.length) 15479 { 15480 try 15481 { 15482 for(k = 0; k < this.onFulfilled.length; k++) 15483 {
15484 x = this.onFulfilled[k].apply(this.ctx, [this.value]); 15485 if(typeof x != 'undefined') 15486 { 15487 value = x; 15488 } 15489 } 15490 } 15491 catch(e) 15492 { 15493 if('console' in window) 15494 { 15495 console.dir(e); 15496 } 15497 15498 if (typeof BX.debug !== 'undefined') 15499 { 15500 BX.debug(e); 15501 } 15502 15503 reason = e; // reject next 15504 } 15505 } 15506 else 15507 { 15508 value = this.value; // resolve next 15509 } 15510 } 15511 else if(this.state === false) // promise was reject()-ed 15512 { 15513 if(this.onRejected.length) 15514 { 15515 try 15516 { 15517 for(k = 0; k < this.onRejected.length; k++) 15518 { 15519 x = this.onRejected[k].apply(this.ctx, [this.reason]); 15520 if(typeof x != 'undefined') 15521 { 15522 value = x; 15523 } 15524 } 15525 } 15526 catch(e) 15527 { 15528 if('console' in window) 15529 { 15530 console.dir(e); 15531 } 15532 15533 if (typeof BX.debug !== 'undefined') 15534 { 15535 BX.debug(e); 15536 } 15537 15538 reason = e; // reject next 15539 } 15540 } 15541 else 15542 { 15543 reason = this.reason; // reject next 15544 } 15545 } 15546 15547 if(this.next !== null) 15548 { 15549 if(typeof reason != 'undefined') 15550 { 15551 this.next.reject(reason); 15552 } 15553 else if(typeof value != 'undefined') 15554 { 15555 this.next.resolve(value); 15556 } 15557 } 15558 }; 15559 BX.Promise.prototype.checkState = function() 15560 { 15561 if(this.state !== null) 15562 { 15563 throw new Error('You can not do fulfill() or reject() multiple times'); 15564 } 15565 }; 15566})(window); 15567 15568 15569 15570;(function(window){ 15571 15572if (window.BX.ajax) 15573 return; 15574 15575var 15576 BX = window.BX, 15577 15578 tempDefaultConfig = {}, 15579 defaultConfig = { 15580 method: 'GET', // request method: GET|POST 15581 dataType: 'html', // type of data loading: html|json|script 15582 timeout: 0, // request timeout in seconds. 0 for browser-default 15583 async: true, // whether request is asynchronous or not 15584 processData: true, // any data processing is disabled if false, only callback call 15585 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 15586 emulateOnload: true, 15587 skipAuthCheck: false, // whether to check authorization failure (SHOUD be set to true for CORS requests) 15588 start: true, // send request immediately (if false, request can be started manually via XMLHttpRequest object returned) 15589 cache: true, // whether NOT to add random addition to URL 15590 preparePost: true, // whether set Content-Type x-www-form-urlencoded in POST 15591 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'}] 15592 lsTimeout: 30, //local storage data TTL. useless without lsId. 15593 lsForce: false //wheter to force query instead of using localStorage data. useless without lsId. 15594/* 15595other parameters: 15596 url: url to get/post 15597 data: data to post 15598 onsuccess: successful request callback. BX.proxy may be used. 15599 onfailure: request failure callback. BX.proxy may be used. 15600 onprogress: request progress callback. BX.proxy may be used. 15601 15602 lsId: local storage id - for constantly updating queries which can communicate via localStorage. core_ls.js needed 15603 15604any of the default parameters can be overridden. defaults can be changed by BX.ajax.Setup() - for all further requests! 15605*/ 15606 }, 15607 loadedScripts = {}, 15608 loadedScriptsQueue = [], 15609 r = { 15610 'url_utf': /[^\034-\254]+/g, 15611 'script_self': /\/bitrix\/js\/main\/core\/core(_ajax)*.js$/i, 15612 'script_self_window': /\/bitrix\/js\/main\/core\/core_window.js$/i, 15613 'script_self_admin': /\/bitrix\/js\/main\/core\/core_admin.js$/i, 15614 'script_onload': /window.onload/g 15615 }; 15616 15617// low-level method 15618BX.ajax = function(config) 15619{ 15620 var status, data; 15621
15622 if (!config || !config.url || !BX.type.isString(config.url)) 15623 { 15624 return false; 15625 } 15626 15627 for (var i in tempDefaultConfig) 15628 if (typeof (config[i]) == "undefined") config[i] = tempDefaultConfig[i]; 15629 15630 tempDefaultConfig = {}; 15631 15632 for (i in defaultConfig) 15633 if (typeof (config[i]) == "undefined") config[i] = defaultConfig[i]; 15634 15635 config.method = config.method.toUpperCase(); 15636 15637 if (!BX.localStorage) 15638 config.lsId = null; 15639 15640 if (BX.browser.IsIE()) 15641 { 15642 var result = r.url_utf.exec(config.url); 15643 if (result) 15644 { 15645 do 15646 { 15647 config.url = config.url.replace(result, BX.util.urlencode(result)); 15648 result = r.url_utf.exec(config.url); 15649 } while (result); 15650 } 15651 } 15652 15653 if(config.dataType == 'json') 15654 config.emulateOnload = false; 15655 15656 if (!config.cache && config.method == 'GET') 15657 config.url = BX.ajax._uncache(config.url); 15658 15659 if (config.method == 'POST') 15660 { 15661 if (config.preparePost) 15662 { 15663 config.data = BX.ajax.prepareData(config.data); 15664 } 15665 else if (getLastContentTypeHeader(config.headers) === 'application/json') 15666 { 15667 config.data = JSON.stringify(config.data); 15668 } 15669 } 15670 15671 var bXHR = true; 15672 if (config.lsId && !config.lsForce) 15673 { 15674 var v = BX.localStorage.get('ajax-' + config.lsId); 15675 if (v !== null) 15676 { 15677 bXHR = false; 15678 15679 var lsHandler = function(lsData) { 15680 if (lsData.key == 'ajax-' + config.lsId && lsData.value != 'BXAJAXWAIT') 15681 { 15682 var data = lsData.value, 15683 bRemove = !!lsData.oldValue && data == null; 15684 if (!bRemove) 15685 BX.ajax.__run(config, data); 15686 else if (config.onfailure) 15687 config.onfailure("timeout"); 15688 15689 BX.removeCustomEvent('onLocalStorageChange', lsHandler); 15690 } 15691 }; 15692 15693 if (v == 'BXAJAXWAIT') 15694 { 15695 BX.addCustomEvent('onLocalStorageChange', lsHandler); 15696 } 15697 else 15698 { 15699 setTimeout(function() {lsHandler({key: 'ajax-' + config.lsId, value: v})}, 10); 15700 } 15701 } 15702 } 15703 15704 if (bXHR) 15705 { 15706 config.xhr = BX.ajax.xhr(); 15707 if (!config.xhr) return; 15708 15709 if (config.lsId) 15710 { 15711 BX.localStorage.set('ajax-' + config.lsId, 'BXAJAXWAIT', config.lsTimeout); 15712 } 15713 15714 if (BX.Type.isFunction(config.onprogress)) 15715 { 15716 BX.bind(config.xhr, 'progress', config.onprogress); 15717 } 15718 15719 if (BX.Type.isFunction(config.onprogressupload) && config.xhr.upload) 15720 { 15721 BX.bind(config.xhr.upload, 'progress', config.onprogressupload); 15722 } 15723 15724 config.xhr.open(config.method, config.url, config.async); 15725 15726 if (!config.skipBxHeader && !BX.ajax.isCrossDomain(config.url)) 15727 { 15728 config.xhr.setRequestHeader('Bx-ajax', 'true'); 15729 } 15730 15731 if (config.method == 'POST' && config.preparePost) 15732 { 15733 config.xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 15734 } 15735 if (typeof(config.headers) == "object") 15736 { 15737 for (i = 0; i < config.headers.length; i++) 15738 config.xhr.setRequestHeader(config.headers[i].name, config.headers[i].value); 15739 } 15740 15741 var bRequestCompleted = false; 15742 var onreadystatechange = config.xhr.onreadystatechange = function(additional) 15743 { 15744 if (bRequestCompleted) 15745 return; 15746 15747 if (additional === 'timeout') 15748 { 15749 if (config.onfailure) 15750 { 15751 config.onfailure('timeout', '', config); 15752 } 15753 15754 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['timeout', '', config]); 15755 15756 config.xhr.onreadystatechange = BX.DoNothing; 15757 config.xhr.abort(); 15758 15759 if (config.async) 15760 { 15761 config.xhr = null; 15762 } 15763 } 15764 else 15765 { 15766 if (config.xhr.readyState == 4 || additional == 'run') 15767 { 15768 status = BX.ajax.xhrSuccess(config.xhr) ? "success" : "error"; 15769 bRequestCompleted = true; 15770 config.xhr.onreadystatechange = BX.DoNothing; 15771 15772 if (status == 'success') 15773 { 15774 var authHeader = (!!config.skipAuthCheck || BX.ajax.isCrossDomain(config.url)) 15775 ? false 15776 : config.xhr.getResponseHeader('X-Bitrix-Ajax-Status'); 15777 15778 if(!!authHeader && authHeader == 'Authorize') 15779 { 15780 if (config.onfailure) 15781 { 15782 config.onfailure('auth', config.xhr.status, config); 15783 } 15784 15785 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['auth', config.xhr.status, config]); 15786 } 15787 else 15788 { 15789 var data = config.xhr.responseText; 15790 15791 if (config.lsId) 15792 { 15793 BX.localStorage.set('ajax-' + config.lsId, data, config.lsTimeout); 15794 } 15795 15796 BX.ajax.__run(config, data); 15797 } 15798 } 15799 else 15800 { 15801 if (config.onfailure) 15802 { 15803 config.onfailure('status', config.xhr.status, config); 15804 } 15805 15806 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['status', config.xhr.status, config]); 15807 } 15808 15809 if (config.async) 15810 { 15811 config.xhr = null; 15812 } 15813 } 15814 } 15815 }; 15816 15817 if (config.async && config.timeout > 0) 15818 { 15819 setTimeout(function() { 15820 if (config.xhr && !bRequestCompleted) 15821 { 15822 onreadystatechange("timeout"); 15823 } 15824 }, config.timeout * 1000); 15825 } 15826 15827 if (config.start) 15828 {
15829 config.xhr.send(config.data); 15830 15831 if (!config.async) 15832 { 15833 onreadystatechange('run'); 15834 } 15835 } 15836 15837 return config.xhr; 15838 } 15839}; 15840 15841BX.ajax.xhr = function() 15842{ 15843 if (window.XMLHttpRequest) 15844 { 15845 try {return new XMLHttpRequest();} catch(e){} 15846 } 15847 else if (window.ActiveXObject) 15848 { 15849 try { return new window.ActiveXObject("Msxml2.XMLHTTP.6.0"); } 15850 catch(e) {} 15851 try { return new window.ActiveXObject("Msxml2.XMLHTTP.3.0"); } 15852 catch(e) {} 15853 try { return new window.ActiveXObject("Msxml2.XMLHTTP"); } 15854 catch(e) {} 15855 try { return new window.ActiveXObject("Microsoft.XMLHTTP"); } 15856 catch(e) {} 15857 throw new Error("This browser does not support XMLHttpRequest."); 15858 } 15859 15860 return null; 15861}; 15862 15863BX.ajax.isCrossDomain = function(url, location) 15864{ 15865 location = location || window.location; 15866 15867 //Relative URL gets a current protocol 15868 if (url.indexOf("//") === 0) 15869 { 15870 url = location.protocol + url; 15871 } 15872 15873 //Fast check 15874 if (url.indexOf("http") !== 0) 15875 { 15876 return false; 15877 } 15878 15879 var link = window.document.createElement("a"); 15880 link.href = url; 15881 15882 return link.protocol !== location.protocol || 15883 link.hostname !== location.hostname || 15884 BX.ajax.getHostPort(link.protocol, link.host) !== BX.ajax.getHostPort(location.protocol, location.host); 15885}; 15886 15887BX.ajax.getHostPort = function(protocol, host) 15888{ 15889 var match = /:(\d+)$/.exec(host); 15890 if (match) 15891 { 15892 return match[1]; 15893 } 15894 else 15895 { 15896 if (protocol === "http:") 15897 { 15898 return "80"; 15899 } 15900 else if (protocol === "https:") 15901 { 15902 return "443"; 15903 } 15904 } 15905 15906 return ""; 15907}; 15908 15909BX.ajax.__prepareOnload = function(scripts, ajax_session) 15910{ 15911 if (scripts.length > 0) 15912 { 15913 BX.ajax['onload_' + ajax_session] = null; 15914 15915 for (var i=0,len=scripts.length;i<len;i++) 15916 { 15917 if (scripts[i].isInternal) 15918 { 15919 scripts[i].JS = scripts[i].JS.replace(r.script_onload, 'BX.aja
15919x.onload_' + ajax_session); 15920 } 15921 } 15922 } 15923 15924 BX.CaptureEventsGet(); 15925 BX.CaptureEvents(window, 'load'); 15926}; 15927 15928BX.ajax.__runOnload = function(ajax_session) 15929{ 15930 if (null != BX.ajax['onload_' + ajax_session]) 15931 { 15932 BX.ajax['onload_' + ajax_session].apply(window); 15933 BX.ajax['onload_' + ajax_session] = null; 15934 } 15935 15936 var h = BX.CaptureEventsGet(); 15937 15938 if (h) 15939 { 15940 for (var i=0; i<h.length; i++) 15941 h[i].apply(window); 15942 } 15943}; 15944 15945BX.ajax.__run = function(config, data) 15946{ 15947 if (!config.processData) 15948 { 15949 if (config.onsuccess) 15950 { 15951 config.onsuccess(data); 15952 } 15953 15954 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [data, config]); 15955 } 15956 else 15957 { 15958 data = BX.ajax.processRequestData(data, config); 15959 } 15960}; 15961 15962 15963BX.ajax._onParseJSONFailure = function(data) 15964{ 15965 this.jsonFailure = true; 15966 this.jsonResponse = data; 15967 this.jsonProactive = /^\[WAF\]/.test(data); 15968}; 15969 15970BX.ajax.processRequestData = function(data, config) 15971{ 15972 var result, scripts = [], styles = []; 15973 switch (config.dataType.toUpperCase()) 15974 { 15975 case 'JSON': 15976 15977 var context = config.xhr || {}; 15978 BX.addCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 15979 result = BX.parseJSON(data, context); 15980 BX.removeCustomEvent(context, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config)); 15981 15982 if(!!result && BX.type.isArray(result['bxjs'])) 15983 { 15984 for(var i = 0; i < result['bxjs'].length; i++) 15985 { 15986 if(BX.type.isNotEmptyString(result['bxjs'][i])) 15987 { 15988 scripts.push({ 15989 "isInternal": false, 15990 "JS": result['bxjs'][i], 15991 "bRunFirst": config.scriptsRunFirst 15992 }); 15993 } 15994 else 15995 { 15996 scripts.push(result['bxjs'][i]) 15997 } 15998 } 15999 } 16000 16001 if(!!result && BX.type.isArray(result['bxcss'])) 16002 { 16003 styles = result['bxcss']; 16004 } 16005 16006 break; 16007 case 'SCRIPT': 16008 scripts.push({"isInternal": true, "JS": data, "bRunFirst": config.scriptsRunFirst}); 16009 result = data; 16010 break; 16011 16012 default: // HTML 16013 var ob = BX.processHTML(data, config.scriptsRunFirst); 16014 result = ob.HTML; scripts = ob.SCRIPT; styles = ob.STYLE; 16015 break; 16016 } 16017 16018 if (styles.length > 0) 16019 { 16020 BX.loadCSS(styles); 16021 } 16022 16023 let ajax_session = null; 16024 if (config.emulateOnload) 16025 { 16026 ajax_session = parseInt(Math.random() * 1000000); 16027 BX.ajax.__prepareOnload(scripts, ajax_session); 16028 } 16029 16030 const cb = BX.defer(function() 16031 { 16032 if (config.emulateOnload) 16033 { 16034 BX.ajax.__runOnload(ajax_session); 16035 } 16036 16037 BX.onCustomEvent(config.xhr, 'onAjaxSuccessFinish', [config]); 16038 }); 16039 16040 try 16041 { 16042 if (!!config.jsonFailure) 16043 { 16044 throw {type: 'json_failure', data: config.jsonResponse, bProactive: config.jsonProactive}; 16045 } 16046 16047 config.scripts = scripts; 16048 16049 BX.ajax.processScripts(config.scripts, true); 16050 16051 if (config.onsuccess) 16052 { 16053 config.onsuccess(result); 16054 } 16055 16056 BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [result, config]); 16057 16058 BX.ajax.processScripts(config.scripts, false, cb); 16059 } 16060 catch (e) 16061 { 16062 if (config.onfailure) 16063 config.onfailure("processing", e); 16064 BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['processing', e, config]); 16065 } 16066}; 16067 16068BX.ajax.processScripts = function(scripts, bRunFirst, cb) 16069{ 16070 var scriptsExt = [], scriptsInt = ''; 16071 16072 cb = cb || BX.DoNothing; 16073 16074 for (var i = 0, length = scripts.length; i < length; i++) 16075 { 16076 if (typeof bRunFirst != 'undefined' && bRunFirst != !!scripts[i].bRunFirst) 16077 continue; 16078 16079 if (scripts[i].isInternal) 16080 scriptsInt += ';' + scripts[i].JS; 16081 else 16082 scriptsExt.push(scripts[i].JS); 16083 } 16084 16085 scriptsExt = BX.util.array_unique(scriptsExt); 16086 var inlineScripts = scriptsInt.length > 0 ? function() { BX.evalGlobal(scriptsInt); } : BX.DoNothing; 16087 16088 if (scriptsExt.length > 0) 16089 { 16090 BX.load(scriptsExt, function() { 16091 inlineScripts(); 16092 cb(); 16093 }); 16094 } 16095 else 16096 { 16097 inlineScripts(); 16098 cb(); 16099 } 16100}; 16101 16102// TODO: extend this function to use with any data objects or forms 16103BX.ajax.prepareData = function(arData, prefix) 16104{ 16105 var data = ''; 16106 if (BX.type.isString(arData)) 16107 data = arData; 16108 else if (null != arData) 16109 { 16110 for(var i in arData) 16111 { 16112 if (arData.hasOwnProperty(i)) 16113 { 16114 if (data.length > 0) 16115 data += '&'; 16116 var name = BX.util.urlencode(i); 16117 if(prefix) 16118 name = prefix + '[' + name + ']'; 16119 if(typeof arData[i] == 'object') 16120 data += BX.ajax.prepareData(arData[i], name); 16121 else 16122 data += name + '=' + BX.util.urlencode(arData[i]); 16123 } 16124 } 16125 } 16126 return data; 16127}; 16128 16129BX.ajax.xhrSuccess = function(xhr) 16130{ 16131 return (xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || xhr.status === 1223 || xhr.status === 0; 16132}; 16133 16134BX.ajax.Setup = function(config, bTemp) 16135{ 16136 bTemp = !!bTemp; 16137 16138 for (var i in config) 16139 { 16140 if (bTemp) 16141 tempDefaultConfig[i] = config[i]; 16142 else 16143 defaultConfig[i] = config[i]; 16144 } 16145}; 16146 16147BX.ajax.replaceLocalStorageValue = function(lsId, data, ttl) 16148{ 16149 if (!!BX.localStorage) 16150 BX.localStorage.set('ajax-' + lsId, data, ttl); 16151}; 16152 16153 16154BX.ajax._uncache = function(url) 16155{ 16156 return url + ((url.indexOf('?') !== -1 ? "&" : "?") + '_=' + (new Date()).getTime()); 16157}; 16158 16159/* simple interface */ 16160BX.ajax.get = function(url, data, callback) 16161{ 16162 if (BX.type.isFunction(data)) 16163 { 16164 callback = data; 16165 data = ''; 16166 } 16167
16168 data = BX.ajax.prepareData(data); 16169 16170 if (data) 16171 { 16172 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 16173 data = ''; 16174 } 16175 16176 return BX.ajax({ 16177 'method': 'GET', 16178 'dataType': 'html', 16179 'url': url, 16180 'data': '', 16181 'onsuccess': callback 16182 }); 16183}; 16184 16185BX.ajax.getCaptcha = function(callback) 16186{ 16187 return BX.ajax.loadJSON('/bitrix/tools/ajax_captcha.php', callback); 16188}; 16189 16190BX.ajax.insertToNode = function(url, node) 16191{ 16192 node = BX(node); 16193 if (!!node) 16194 { 16195 var eventArgs = { cancel: false }; 16196 BX.onCustomEvent('onAjaxInsertToNode', [{ url: url, node: node, eventArgs: eventArgs }]); 16197 if(eventArgs.cancel === true) 16198 { 16199 return; 16200 } 16201 16202 var show = null; 16203 if (!tempDefaultConfig.denyShowWait) 16204 { 16205 show = BX.showWait(node); 16206 delete tempDefaultConfig.denyShowWait; 16207 } 16208 16209 return BX.ajax.get(url, function(data) { 16210 node.innerHTML = data; 16211 BX.closeWait(node, show); 16212 }); 16213 } 16214}; 16215 16216BX.ajax.post = function(url, data, callback) 16217{ 16218 data = BX.ajax.prepareData(data); 16219 16220 return BX.ajax({ 16221 'method': 'POST', 16222 'dataType': 'html', 16223 'url': url, 16224 'data': data, 16225 'onsuccess': callback 16226 }); 16227}; 16228 16229/** 16230 * BX.ajax with BX.Promise 16231 * 16232 * @param config 16233 * @returns {BX.Promise|false} 16234 */ 16235BX.ajax.promise = function(config) 16236{ 16237 var result = new BX.Promise(); 16238 16239 config.onsuccess = function(data) 16240 { 16241 result.fulfill(data); 16242 }; 16243 config.onfailure = function(reason, httpStatus, config) 16244 { 16245 result.reject({ 16246 reason: reason, 16247 data: httpStatus, 16248 ajaxConfig: config, 16249 xhr: config.xhr 16250 }); 16251 }; 16252 16253 var xhr = BX.ajax(config); 16254 if (xhr) 16255 { 16256 if (typeof config.onrequeststart === 'function') 16257 { 16258 config.onrequeststart(xhr); 16259 } 16260 } 16261 else 16262 { 16263 result.reject({ 16264 reason: "init", 16265 data: false 16266 }); 16267 } 16268 16269 return result; 16270}; 16271 16272/* load and execute external file script with onload emulation */ 16273BX.ajax.loadScriptAjax = function(script_src, callback, bPreload) 16274{ 16275 if (BX.type.isArray(script_src)) 16276 { 16277 for (var i=0,len=script_src.length;i<len;i++) 16278 { 16279 BX.ajax.loadScriptAjax(script_src[i], callback, bPreload); 16280 } 16281 } 16282 else 16283 { 16284 var script_src_test = script_src.replace(/\.js\?.*/, '.js'); 16285 16286 if (r.script_self.test(script_src_test)) return; 16287 if (r.script_self_window.test(script_src_test) && BX.CWindow) return; 16288 if (r.script_self_admin.test(script_src_test) && BX.admin) return; 16289 16290 if (typeof loadedScripts[script_src_test] == 'undefined') 16291 { 16292 if (!!bPreload) 16293 { 16294 loadedScripts[script_src_test] = ''; 16295 return BX.loadScript(script_src); 16296 } 16297 else 16298 { 16299 return BX.ajax({ 16300 url: script_src, 16301 method: 'GET', 16302 dataType: 'script', 16303 processData: true, 16304 emulateOnload: false, 16305 scriptsRunFirst: true, 16306 async: false, 16307 start: true, 16308 onsuccess: function(result) { 16309 loadedScripts[script_src_test] = result; 16310 if (callback) 16311 callback(result); 16312 } 16313 }); 16314 } 16315 } 16316 else if (callback) 16317 { 16318 callback(loadedScripts[script_src_test]); 16319 } 16320 } 16321}; 16322 16323/* non-xhr loadings */ 16324BX.ajax.loadJSON = function(url, data, callback, callback_failure) 16325{ 16326 if (BX.type.isFunction(data)) 16327 { 16328 callback_failure = callback; 16329 callback = data; 16330 data = ''; 16331 } 16332 16333 data = BX.ajax.prepareData(data); 16334 16335 if (data) 16336 { 16337 url += (url.indexOf('?') !== -1 ? "&" : "?") + data; 16338 data = ''; 16339 } 16340 16341 return BX.ajax({ 16342 'method': 'GET', 16343 'dataType': 'json', 16344 'url': url, 16345 'onsuccess': callback, 16346 'onfailure': callback_failure 16347 }); 16348}; 16349 16350var getLastContentTypeHeader = function (headers) { 16351 if (!BX.Type.isArray(headers)) 16352 { 16353 return null; 16354 } 16355 var lastHeader = headers 16356 .filter(function (header) { 16357 return header.name === 'Content-Type'; 16358 }) 16359 .pop(); 16360 16361 return lastHeader ? lastHeader.value : null; 16362}; 16363 16364var prepareAjaxGetParameters = function(config) 16365{ 16366 var getParameters = config.getParameters || {}; 16367 if (BX.type.isNotEmptyString(config.analyticsLabel)) 16368 { 16369 getParameters.analyticsLabel = config.analyticsLabel; 16370 } 16371 else if (BX.type.isNotEmptyObject(config.analyticsLabel)) 16372 { 16373 getParameters.analyticsLabel = config.analyticsLabel; 16374 } 16375 if (typeof config.mode !== 'undefined') 16376 { 16377 getParameters.mode = config.mode; 16378 } 16379 if (config.navigation) 16380 { 16381 if(config.navigation.page) 16382 { 16383 getParameters.nav = 'page-' + config.navigation.page; 16384 } 16385 if(config.navigation.size) 16386 { 16387 if(getParameters.nav) 16388 { 16389 getParameters.nav += '-'; 16390 } 16391 else 16392 {
16393 getParameters.nav = ''; 16394 } 16395 getParameters.nav += 'size-' + config.navigation.size; 16396 } 16397 } 16398 16399 return getParameters; 16400}; 16401 16402var prepareAjaxConfig = function(config) 16403{ 16404 config = BX.type.isPlainObject(config) ? config : {}; 16405 16406 config.headers = config.headers || []; 16407 config.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 16408 if (BX.message.SITE_ID) 16409 { 16410 config.headers.push({name: 'X-Bitrix-Site-Id', value: BX.message.SITE_ID}); 16411 } 16412 16413 if (typeof config.json !== 'undefined') 16414 { 16415 if (!BX.type.isPlainObject(config.json)) 16416 { 16417 throw new Error('Wrong `config.json`, plain object expected.') 16418 } 16419 16420 config.headers.push({name: 'Content-Type', value: 'application/json'}); 16421 config.data = config.json; 16422 config.preparePost = false; 16423 } 16424 else if (config.data instanceof FormData) 16425 { 16426 config.preparePost = false; 16427 if (typeof config.signedParameters !== 'undefined') 16428 { 16429 config.data.append('signedParameters', config.signedParameters); 16430 } 16431 } 16432 else if (BX.type.isPlainObject(config.data) || BX.Type.isNil(config.data)) 16433 { 16434 config.data = BX.type.isPlainObject(config.data) ? config.data : {}; 16435 if (typeof config.signedParameters !== 'undefined') 16436 { 16437 config.data.signedParameters = config.signedParameters; 16438 } 16439 } 16440 16441 if (!config.method) 16442 { 16443 config.method = 'POST' 16444 } 16445 16446 return config; 16447}; 16448 16449var buildAjaxPromiseToRestoreCsrf = function(config, withoutRestoringCsrf) 16450{ 16451 withoutRestoringCsrf = withoutRestoringCsrf || false; 16452 var originalConfig = BX.clone(config); 16453 var request = null; 16454 16455 var onrequeststart = config.onrequeststart; 16456 config.onrequeststart = function(xhr) { 16457 request = xhr; 16458 if (BX.type.isFunction(onrequeststart)) 16459 { 16460 onrequeststart(xhr); 16461 } 16462 }; 16463 var onrequeststartOrig = originalConfig.onrequeststart; 16464 originalConfig.onrequeststart = function(xhr) { 16465 request = xhr; 16466 if (BX.type.isFunction(onrequeststartOrig)) 16467 { 16468 onrequeststartOrig(xhr); 16469 } 16470 }; 16471 16472 var promise = BX.ajax.promise(config); 16473 16474 return promise.then(function(response) { 16475 if (!withoutRestoringCsrf && BX.type.isPlainObject(response) && BX.type.isArray(response.errors)) 16476 { 16477 var csrfProblem = false; 16478 response.errors.forEach(function(error) { 16479 if (error.code === 'invalid_csrf' && error.customData.csrf) 16480 { 16481 BX.message({'bitrix_sessid': error.customData.csrf}); 16482 16483 originalConfig.headers = originalConfig.headers || []; 16484 originalConfig.headers = originalConfig.headers.filter(function(header) { 16485 return header && header.name !== 'X-Bitrix-Csrf-Token'; 16486 }); 16487 originalConfig.headers.push({name: 'X-Bitrix-Csrf-Token', value: BX.bitrix_sessid()}); 16488 16489 csrfProblem = true; 16490 } 16491 }); 16492 16493 if (csrfProblem) 16494 { 16495 return buildAjaxPromiseToRestoreCsrf(originalConfig, true); 16496 } 16497 } 16498 16499 if (!BX.type.isPlainObject(response) || response.status !== 'success') 16500 { 16501 var errorPromise = new BX.Promise(); 16502 errorPromise.reject(response); 16503 16504 return errorPromise; 16505 } 16506 16507 return response; 16508 }).catch(function(data) { 16509 var ajaxReject = new BX.Promise(); 16510 16511 var originalJsonResponse; 16512 if (BX.type.isPlainObject(data) && data.xhr && data.xhr.responseText) 16513 { 16514 try 16515 { 16516 originalJsonResponse = JSON.parse(data.xhr.responseText); 16517 data = originalJsonResponse; 16518 } 16519 catch (err) 16520 {} 16521 } 16522 16523 if (BX.type.isPlainObject(data) && data.status && data.hasOwnProperty('data')) 16524 { 16525 ajaxReject.reject(data); 16526 } 16527 else 16528 { 16529 ajaxReject.reject({ 16530 status: 'error', 16531 data: { 16532 ajaxRejectData: data 16533 }, 16534 errors: [ 16535 { 16536 code: 'NETWORK_ERROR', 16537 message: 'Network error' 16538 } 16539 ] 16540 }); 16541 } 16542 16543 return ajaxReject; 16544 }).then(function(response){ 16545 16546 var assetsLoaded = new BX.Promise(); 16547 16548 var headers = request.getAllResponseHeaders().trim().split(/[\r\n]+/); 16549 var headerMap = {}; 16550 headers.forEach(function (line) { 16551 var parts = line.split(': '); 16552 var header = parts.shift().toLowerCase(); 16553 headerMap[header] = parts.join(': '); 16554 }); 16555 16556 if (!headerMap['x-process-assets']) 16557 { 16558 assetsLoaded.fulfill(response); 16559 16560 return assetsLoaded; 16561 } 16562 16563 var assets = BX.prop.getObject(BX.prop.getObject(response, "data", {}), "assets", {}); 16564 var promise = new Promise(function(resolve, reject) { 16565 var css = BX.prop.getArray(assets, "css", []); 16566 BX.load(css, function(){ 16567 BX.loadScript( 16568 BX.prop.getArray(assets, "js", []), 16569 resolve 16570 ); 16571 }); 16572 }); 16573 promise.then(function(){ 16574 var strings = BX.prop.getArray(assets, "string", []); 16575 var stringAsset = strings.join('\n'); 16576 BX.html(document.head, stringAsset, { useAdjacentHTML: true }).then(function(){ 16577 assetsLoaded.fulfill(response); 16578 }); 16579 }); 16580 16581 return assetsLoaded; 16582 }); 16583}; 16584 16585/** 16586 * 16587 * @param {string} action 16588 * @param {Object} config 16589 * @param {?string|?Object} [config.analyticsLabel] 16590 * @param {string} [config.method='POST'] 16591 * @param {Object} [config.data] 16592 * @param {?Object} [config.getParameters] 16593 * @param {?Object} [config.headers] 16594 * @param {?Object} [config.timeout] 16595 * @param {Object} [config.navigation] 16596 * @param {number} [config.navigation.page] 16597 */ 16598BX.ajax.runAction = function(action, config) 16599{ 16600 config = prepareAjaxConfig(config); 16601 var getParameters = prepareAjaxGetParameters(config); 16602 getParameters.action = action; 16603
16604 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 16605 return buildAjaxPromiseToRestoreCsrf({ 16606 method: config.method, 16607 dataType: 'json', 16608 url: url, 16609 data: config.data, 16610 timeout: config.timeout, 16611 preparePost: config.preparePost, 16612 headers: config.headers, 16613 onrequeststart: config.onrequeststart, 16614 onprogress: config.onprogress, 16615 onprogressupload: config.onprogressupload 16616 }); 16617}; 16618 16619/** 16620 * 16621 * @param {string} component 16622 * @param {string} action 16623 * @param {Object} config 16624 * @param {?string|?Object} [config.analyticsLabel] 16625 * @param {?string} [config.signedParameters] 16626 * @param {string} [config.method='POST'] 16627 * @param {string} [config.mode='ajax'] Ajax or class. 16628 * @param {Object} [config.data] 16629 * @param {?Object} [config.getParameters] 16630 * @param {?array} [config.headers] 16631 * @param {?number} [config.timeout] 16632 * @param {Object} [config.navigation] 16633 */ 16634BX.ajax.runComponentAction = function (component, action, config) 16635{ 16636 config = prepareAjaxConfig(config); 16637 config.mode = config.mode || 'ajax'; 16638 16639 var getParameters = prepareAjaxGetParameters(config); 16640 getParameters.c = component; 16641 getParameters.action = action; 16642
16643 var url = '/bitrix/services/main/ajax.php?' + BX.ajax.prepareData(getParameters); 16644 16645 return buildAjaxPromiseToRestoreCsrf({ 16646 method: config.method, 16647 dataType: 'json', 16648 url: url, 16649 data: config.data, 16650 timeout: config.timeout, 16651 preparePost: config.preparePost, 16652 headers: config.headers, 16653 onrequeststart: (config.onrequeststart ? config.onrequeststart : null), 16654 onprogress: config.onprogress, 16655 onprogressupload: config.onprogressupload 16656 }); 16657}; 16658 16659/* 16660arObs = [{ 16661 url: url, 16662 type: html|script|json|css, 16663 callback: function 16664}] 16665*/ 16666BX.ajax.load = function(arObs, callback) 16667{ 16668 if (!BX.type.isArray(arObs)) 16669 arObs = [arObs]; 16670 16671 var cnt = 0; 16672 16673 if (!BX.type.isFunction(callback)) 16674 callback = BX.DoNothing; 16675 16676 var handler = function(data) 16677 { 16678 if (BX.type.isFunction(this.callback)) 16679 this.callback(data); 16680 16681 if (++cnt >= len) 16682 callback(); 16683 }; 16684 16685 for (var i = 0, len = arObs.length; i<len; i++) 16686 { 16687 switch(arObs[i].type.toUpperCase()) 16688 { 16689 case 'SCRIPT': 16690 BX.loadScript([arObs[i].url], BX.proxy(handler, arObs[i])); 16691 break; 16692 case 'CSS': 16693 BX.loadCSS([arObs[i].url]); 16694 16695 if (++cnt >= len) 16696 callback(); 16697 break; 16698 case 'JSON': 16699 BX.ajax.loadJSON(arObs[i].url, BX.proxy(handler, arObs[i])); 16700 break; 16701 16702 default: 16703 BX.ajax.get(arObs[i].url, '', BX.proxy(handler, arObs[i])); 16704 break; 16705 } 16706 } 16707}; 16708 16709/* ajax form sending */ 16710BX.ajax.submit = function(obForm, callback) 16711{ 16712 if (!obForm.target) 16713 { 16714 if (null == obForm.BXFormTarget) 16715 { 16716 var frame_name = 'formTarget_' + Math.random(); 16717 obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', { 16718 props: { 16719 name: frame_name, 16720 id: frame_name, 16721 src: 'javascript:void(0)' 16722 }, 16723 style: { 16724 display: 'none' 16725 } 16726 })); 16727 } 16728 16729 obForm.target = obForm.BXFormTarget.name; 16730 } 16731 16732 obForm.BXFormCallback = callback; 16733 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 16734 16735 BX.submit(obForm); 16736 16737 return false; 16738}; 16739 16740BX.ajax.submitComponentForm = function(obForm, container, bWait) 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 if (!!bWait) 16763 var w = BX.showWait(container); 16764 16765 obForm.BXFormCallback = function(d) { 16766 if (!!bWait) 16767 BX.closeWait(w); 16768 16769 var callOnload = function(){ 16770 if(!!window.bxcompajaxframeonload) 16771 { 16772 setTimeout(function(){window.bxcompajaxframeonload();window.bxcompajaxframeonload=null;}, 10); 16773 } 16774 }; 16775 16776 BX(container).innerHTML = d; 16777 BX.onCustomEvent('onAjaxSuccess', [null,null,callOnload]); 16778 }; 16779 16780 BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm)); 16781 16782 return true; 16783}; 16784 16785// func will be executed in form context 16786BX.ajax._submit_callback = function() 16787{ 16788 //opera and IE8 triggers onload event even on empty iframe 16789 try 16790 { 16791 if(this.BXFormTarget.contentWindow.location.href.indexOf('http') != 0) 16792 return; 16793 } catch (e) { 16794 return; 16795 } 16796 16797 if (this.BXFormCallback) 16798 this.BXFormCallback.apply(this, [this.BXFormTarget.contentWindow.document.body.innerHTML]); 16799 16800 BX.unbindAll(this.BXFormTarget); 16801}; 16802 16803BX.ajax.prepareForm = function(obForm, data) 16804{ 16805 data = (!!data ? data : {}); 16806 var i, ii, el, 16807 _data = [], 16808 n = obForm.elements.length, 16809 files = 0, length = 0; 16810 if(!!obForm) 16811 { 16812 for (i = 0; i < n; i++) 16813 { 16814 el = obForm.elements[i]; 16815 if (el.disabled) 16816 continue; 16817 16818 if(!el.type) 16819 continue; 16820 16821 switch(el.type.toLowerCase()) 16822 { 16823 case 'text': 16824 case 'textarea': 16825 case 'password': 16826 case 'number': 16827 case 'hidden': 16828 case 'select-one': 16829 _data.push({name: el.name, value: el.value}); 16830 length += (el.name.length + el.value.length); 16831 break; 16832 case 'file': 16833 if (!!el.files) 16834 { 16835 for (ii = 0; ii < el.files.length; ii++) 16836 { 16837 files++; 16838 _data.push({name: el.name, value: el.files[ii], file : true}); 16839 length += el.files[ii].size; 16840 } 16841 } 16842 break; 16843 case 'radio':
16844 case 'checkbox': 16845 if(el.checked) 16846 { 16847 _data.push({name: el.name, value: el.value}); 16848 length += (el.name.length + el.value.length); 16849 } 16850 break; 16851 case 'select-multiple': 16852 for (var j = 0; j < el.options.length; j++) 16853 { 16854 if (el.options[j].selected) 16855 { 16856 _data.push({name : el.name, value : el.options[j].value}); 16857 length += (el.name.length + el.options[j].length); 16858 } 16859 } 16860 break; 16861 default: 16862 break; 16863 } 16864 } 16865 16866 i = 0; length = 0; 16867 var current = data, name, rest, pp, tmpKey; 16868 16869 while(i < _data.length) 16870 { 16871 var p = _data[i].name.indexOf('['); 16872 if (tmpKey) 16873 { 16874 current[_data[i].name] = {}; 16875 current[_data[i].name][tmpKey.replace(/\[|\]/gi, '')] = _data[i].value; 16876 current = data; 16877 tmpKey = null; 16878 i++; 16879 } 16880 else if (p == -1) 16881 { 16882 current[_data[i].name] = _data[i].value; 16883 current = data; 16884 i++; 16885 } 16886 else 16887 { 16888 name = _data[i].name.substring(0, p); 16889 rest = _data[i].name.substring(p+1); 16890 pp = rest.indexOf(']'); 16891 16892 if(pp == -1) 16893 { 16894 if (!current[name]) 16895 current[name] = []; 16896 current = data; 16897 i++; 16898 } 16899 else if(pp == 0) 16900 { 16901 if (!current[name]) 16902 current[name] = []; 16903 //No index specified - so take the next integer 16904 current = current[name]; 16905 _data[i].name = '' + current.length; 16906 if (rest.substring(pp+1).indexOf('[') === 0) 16907 tmpKey = rest.substring(0, pp) + rest.substring(pp+1); 16908 } 16909 else 16910 { 16911 if (!current[name]) 16912 current[name] = {}; 16913 //Now index name becomes and name and we go deeper into the array 16914 current = current[name]; 16915 _data[i].name = rest.substring(0, pp) + rest.substring(pp+1); 16916 } 16917 } 16918 } 16919 } 16920 return {data : data, filesCount : files, roughSize : length}; 16921}; 16922BX.ajax.submitAjax = function(obForm, config) 16923{ 16924 config = (config !== null && typeof config == "object" ? config : {}); 16925 config.url = (config["url"] || obForm.getAttribute("action")); 16926 16927 var additionalData = (config["data"] || {}); 16928 config.data = BX.ajax.prepareForm(obForm).data; 16929 for (var ii in additionalData) 16930 { 16931 if (additionalData.hasOwnProperty(ii)) 16932 { 16933 config.data[ii] = additionalData[ii]; 16934 } 16935 } 16936 16937 if (!window["FormData"]) 16938 { 16939 BX.ajax(config); 16940 } 16941 else 16942 { 16943 var isFile = function(item) 16944 { 16945 var res = Object.prototype.toString.call(item); 16946 return (res == '[object File]' || res == '[object Blob]'); 16947 }, 16948 appendToForm = function(fd, key, val) 16949 { 16950 if (!!val && typeof val == "object" && !isFile(val)) 16951 { 16952 for (var ii in val) 16953 { 16954 if (val.hasOwnProperty(ii)) 16955 { 16956 appendToForm(fd, (key == '' ? ii : key + '[' + ii + ']'), val[ii]); 16957 } 16958 } 16959 } 16960 else 16961 fd.append(key, (!!val ? val : '')); 16962 }, 16963 prepareData = function(arData) 16964 { 16965 var data = {}; 16966 if (null != arData) 16967 { 16968 if(typeof arData == 'object') 16969 { 16970 for(var i in arData) 16971 { 16972 if (arData.hasOwnProperty(i)) 16973 { 16974 var name = BX.util.urlencode(i); 16975 if(typeof arData[i] == 'object' && arData[i]["file"] !== true) 16976 data[name] = prepareData(arData[i]); 16977 else if (arData[i]["file"] === true) 16978 data[name] = arData[i]["value"]; 16979 else 16980 data[name] = BX.util.urlencode(arData[i]); 16981 } 16982 } 16983 } 16984 else 16985 data = BX.util.urlencode(arData); 16986 } 16987 return data; 16988 }, 16989 fd = new window.FormData(); 16990 16991 if (config.method !== 'POST') 16992 { 16993 config.data = BX.ajax.prepareData(config.data); 16994 if (config.data) 16995 { 16996 config.url += (config.url.indexOf('?') !== -1 ? "&" : "?") + config.data; 16997 config.data = ''; 16998 } 16999 } 17000 else 17001 { 17002 if (config.preparePost === true) 17003 config.data = prepareData(config.data); 17004 appendToForm(fd, '', config.data); 17005 config.data = fd; 17006 } 17007 17008 config.preparePost = false; 17009 config.start = false;
17010 17011 var xhr = BX.ajax(config); 17012 if (!!config["onprogress"]) 17013 xhr.upload.addEventListener( 17014 'progress', 17015 function(e){ 17016 var percent = null; 17017 if(e.lengthComputable && (e.total || e["totalSize"])) { 17018 percent = e.loaded * 100 / (e.total || e["totalSize"]); 17019 } 17020 config["onprogress"](e, percent); 17021 } 17022 ); 17023 xhr.send(fd); 17024 } 17025}; 17026 17027BX.ajax.UpdatePageData = function (arData) 17028{ 17029 if (arData.TITLE) 17030 BX.ajax.UpdatePageTitle(arData.TITLE); 17031 if (arData.WINDOW_TITLE || arData.TITLE) 17032 BX.ajax.UpdateWindowTitle(arData.WINDOW_TITLE || arData.TITLE); 17033 if (arData.NAV_CHAIN) 17034 BX.ajax.UpdatePageNavChain(arData.NAV_CHAIN); 17035 if (arData.CSS && arData.CSS.length > 0) 17036 BX.loadCSS(arData.CSS); 17037 if (arData.SCRIPTS && arData.SCRIPTS.length > 0) 17038 { 17039 var f = function(result,config,cb){ 17040 17041 if(!!config && BX.type.isArray(config.scripts)) 17042 { 17043 for(var i=0,l=arData.SCRIPTS.length;i<l;i++) 17044 { 17045 config.scripts.push({isInternal:false,JS:arData.SCRIPTS[i]}); 17046 } 17047 } 17048 else 17049 { 17050 BX.loadScript(arData.SCRIPTS,cb); 17051 } 17052 17053 BX.removeCustomEvent('onAjaxSuccess',f); 17054 }; 17055 BX.addCustomEvent('onAjaxSuccess',f); 17056 } 17057 else 17058 { 17059 var f1 = function(result,config,cb){ 17060 if(BX.type.isFunction(cb)) 17061 { 17062 cb(); 17063 } 17064 BX.removeCustomEvent('onAjaxSuccess',f1); 17065 }; 17066 BX.addCustomEvent('onAjaxSuccess', f1); 17067 } 17068}; 17069 17070BX.ajax.UpdatePageTitle = function(title) 17071{ 17072 var obTitle = BX('pagetitle'); 17073 if (obTitle) 17074 { 17075 BX.remove(obTitle.firstChild); 17076 if (!obTitle.firstChild) 17077 obTitle.appendChild(document.createTextNode(title)); 17078 else 17079 obTitle.insertBefore(document.createTextNode(title), obTitle.firstChild); 17080 } 17081}; 17082 17083BX.ajax.UpdateWindowTitle = function(title) 17084{ 17085 document.title = title; 17086}; 17087 17088BX.ajax.UpdatePageNavChain = function(nav_chain) 17089{ 17090 var obNavChain = BX('navigation'); 17091 if (obNavChain) 17092 { 17093 obNavChain.innerHTML = nav_chain; 17094 } 17095}; 17096 17097/* user options handling */ 17098BX.userOptions = { 17099 options: null, 17100 bSend: false, 17101 delay: 5000, 17102 path: '/bitrix/admin/user_options.php?' 17103}; 17104 17105BX.userOptions.setAjaxPath = function(url) 17106{ 17107 BX.userOptions.path = url.indexOf('?') == -1? url+'?': url+'&'; 17108} 17109BX.userOptions.save = function(sCategory, sName, sValName, sVal, bCommon) 17110{ 17111 if (null == BX.userOptions.options) 17112 BX.userOptions.options = {}; 17113 17114 bCommon = !!bCommon; 17115 BX.userOptions.options[sCategory+'.'+sName+'.'+sValName] = [sCategory, sName, sValName, sVal, bCommon]; 17116 17117 var sParam = BX.userOptions.__get(); 17118 if (sParam != '') 17119 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=/;"; 17120 17121 if(!BX.userOptions.bSend) 17122 { 17123 BX.userOptions.bSend = true; 17124 setTimeout(function(){BX.userOptions.send(null)}, BX.userOptions.delay); 17125 } 17126}; 17127 17128BX.userOptions.send = function(callback) 17129{ 17130 var sParam = BX.userOptions.__get(); 17131 BX.userOptions.options = null; 17132 BX.userOptions.bSend = false; 17133 17134 if (sParam != '') 17135 { 17136 document.cookie = BX.message('COOKIE_PREFIX') + "_LAST_SETTINGS=; path=/;"; 17137 BX.ajax({ 17138 'method': 'GET', 17139 'dataType': 'html', 17140 'processData': false, 17141 'cache': false, 17142 'url': BX.userOptions.path+sParam+'&sessid='+BX.bitrix_sessid(), 17143 'onsuccess': callback 17144 }); 17145 } 17146}; 17147 17148BX.userOptions.del = function(sCategory, sName, bCommon, callback) 17149{ 17150 BX.ajax.get(BX.userOptions.path+'action=delete&c='+sCategory+'&n='+sName+(bCommon == true? '&common=Y':'')+'&sessid='+BX.bitrix_sessid(), callback); 17151}; 17152 17153BX.userOptions.__get = function() 17154{ 17155 if (!BX.userOptions.options) return ''; 17156 17157 var sParam = '', n = -1, prevParam = '', aOpt, i; 17158 17159 for (i in BX.userOptions.options) 17160 { 17161 if(BX.userOptions.options.hasOwnProperty(i)) 17162 { 17163 aOpt = BX.userOptions.options[i]; 17164 17165 if (prevParam != aOpt[0]+'.'+aOpt[1]) 17166 { 17167 n++; 17168 sParam += '&p['+n+'][c]='+BX.util.urlencode(aOpt[0]); 17169 sParam += '&p['+n+'][n]='+BX.util.urlencode(aOpt[1]); 17170 if (aOpt[4] == true) 17171 sParam += '&p['+n+'][d]=Y'; 17172 prevParam = aOpt[0]+'.'+aOpt[1]; 17173 } 17174 17175 var valueName = aOpt[2]; 17176 var value = aOpt[3]; 17177 17178 if (valueName === null) 17179 { 17180 sParam += '&p['+n+'][v]='+BX.util.urlencode(value); 17181 } 17182 else 17183 {
17184 sParam += '&p['+n+'][v]['+BX.util.urlencode(valueName)+']='+BX.util.urlencode(value); 17185 } 17186 } 17187 } 17188 17189 return sParam.substr(1); 17190}; 17191 17192BX.ajax.history = { 17193 expected_hash: '', 17194 17195 obParams: null, 17196 17197 obFrame: null, 17198 obImage: null, 17199 17200 obTimer: null, 17201 17202 bInited: false, 17203 bHashCollision: false, 17204 bPushState: !!(history.pushState && BX.type.isFunction(history.pushState)), 17205 17206 startState: null, 17207 17208 init: function(obParams) 17209 { 17210 if (BX.ajax.history.bInited) 17211 return; 17212 17213 this.obParams = obParams; 17214 var obCurrentState = this.obParams.getState(); 17215 17216 if (BX.ajax.history.bPushState) 17217 { 17218 BX.ajax.history.expected_hash = window.location.pathname; 17219 if (window.location.search) 17220 BX.ajax.history.expected_hash += window.location.search; 17221 17222 BX.ajax.history.put(obCurrentState, BX.ajax.history.expected_hash, '', true); 17223 // due to some strange thing, chrome calls popstate event on page start. so we should delay it 17224 setTimeout(function(){BX.bind(window, 'popstate', BX.ajax.history.__hashListener);}, 500); 17225 } 17226 else 17227 { 17228 BX.ajax.history.expected_hash = window.location.hash; 17229 17230 if (!BX.ajax.history.expected_hash || BX.ajax.history.expected_hash == '#') 17231 BX.ajax.history.expected_hash = '__bx_no_hash__'; 17232 17233 jsAjaxHistoryContainer.put(BX.ajax.history.expected_hash, obCurrentState); 17234 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 17235 17236 if (BX.browser.IsIE()) 17237 { 17238 BX.ajax.history.obFrame = document.createElement('IFRAME'); 17239 BX.hide_object(BX.ajax.history.obFrame); 17240 17241 document.body.appendChild(BX.ajax.history.obFrame); 17242 17243 BX.ajax.history.obFrame.contentWindow.document.open(); 17244 BX.ajax.history.obFrame.contentWindow.document.write(BX.ajax.history.expected_hash); 17245 BX.ajax.history.obFrame.contentWindow.document.close(); 17246 } 17247 else if (BX.browser.IsOpera()) 17248 { 17249 BX.ajax.history.obImage = document.createElement('IMG'); 17250 BX.hide_object(BX.ajax.history.obImage); 17251 17252 document.body.appendChild(BX.ajax.history.obImage); 17253 17254 BX.ajax.history.obImage.setAttribute('src', 'javascript:location.href = \'javascript:BX.ajax.history.__hashListener();\';'); 17255 } 17256 } 17257 17258 BX.ajax.history.bInited = true; 17259 }, 17260 17261 __hashListener: function(e) 17262 { 17263 e = e || window.event || {state:false}; 17264 17265 if (BX.ajax.history.bPushState) 17266 { 17267 BX.ajax.history.obParams.setState(e.state||BX.ajax.history.startState); 17268 } 17269 else 17270 { 17271 if (BX.ajax.history.obTimer) 17272 { 17273 window.clearTimeout(BX.ajax.history.obTimer); 17274 BX.ajax.history.obTimer = null; 17275 } 17276 17277 var current_hash; 17278 if (null != BX.ajax.history.obFrame) 17279 current_hash = BX.ajax.history.obFrame.contentWindow.document.body.innerText; 17280 else 17281 current_hash = window.location.hash; 17282 17283 if (!current_hash || current_hash == '#') 17284 current_hash = '__bx_no_hash__'; 17285 17286 if (current_hash.indexOf('#') == 0) 17287 current_hash = current_hash.substring(1); 17288 17289 if (current_hash != BX.ajax.history.expected_hash) 17290 { 17291 var state = jsAjaxHistoryContainer.get(current_hash); 17292 if (state) 17293 { 17294 BX.ajax.history.obParams.setState(state); 17295 17296 BX.ajax.history.expected_hash = current_hash; 17297 if (null != BX.ajax.history.obFrame) 17298 { 17299 var __hash = current_hash == '__bx_no_hash__' ? '' : current_hash; 17300 if (window.location.hash != __hash && window.location.hash != '#' + __hash) 17301 window.location.hash = __hash; 17302 } 17303 } 17304 } 17305 17306 BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500); 17307 } 17308 }, 17309 17310 put: function(state, new_hash, new_hash1, bStartState) 17311 { 17312 if (this.bPushState) 17313 { 17314 if(!bStartState) 17315 { 17316 history.pushState(state, '', new_hash); 17317 } 17318 else 17319 { 17320 BX.ajax.history.startState = state; 17321 } 17322 } 17323 else 17324 { 17325 if (typeof new_hash1 != 'undefined') 17326 new_hash = new_hash1; 17327 else 17328 new_hash = 'view' + new_hash; 17329 17330 jsAjaxHistoryContainer.put(new_hash, state); 17331 BX.ajax.history.expected_hash = new_hash; 17332 17333 window.location.hash = BX.util.urlencode(new_hash); 17334 17335 if (null != BX.ajax.history.obFrame) 17336 { 17337 BX.ajax.history.obFrame.contentWindow.document.open(); 17338 BX.ajax.history.obFrame.contentWindow.document.write(new_hash); 17339 BX.ajax.history.obFrame.contentWindow.document.close(); 17340 } 17341 } 17342 }, 17343 17344 checkRedirectStart: function(param_name, param_value) 17345 { 17346 var current_hash = window.location.hash; 17347 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 17348 17349 var test = current_hash.substring(0, 5); 17350 if (test == 'view/' || test == 'view%') 17351 { 17352 BX.ajax.history.bHashCollision = true;
17353 document.write('<' + 'div id="__ajax_hash_collision_' + param_value + '" style="display: none;">'); 17354 } 17355 }, 17356 17357 checkRedirectFinish: function(param_name, param_value) 17358 { 17359 document.write('</div>'); 17360 17361 var current_hash = window.location.hash; 17362 if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1); 17363 17364 BX.ready(function () 17365 { 17366 var test = current_hash.substring(0, 5); 17367 if (test == 'view/' || test == 'view%') 17368 { 17369 var obColNode = BX('__ajax_hash_collision_' + param_value); 17370 var obNode = obColNode.firstChild; 17371 BX.cleanNode(obNode); 17372 obColNode.style.display = 'block'; 17373 17374 // IE, Opera and Chrome automatically modifies hash with urlencode, but FF doesn't ;-( 17375 if (test != 'view%') 17376 current_hash = BX.util.urlencode(current_hash); 17377 17378 current_hash += (current_hash.indexOf('%3F') == -1 ? '%3F' : '%26') + param_name + '=' + param_value; 17379 17380 var url = '/bitrix/tools/ajax_redirector.php?hash=' + current_hash; 17381 17382 BX.ajax.insertToNode(url, obNode); 17383 } 17384 }); 17385 } 17386}; 17387 17388BX.ajax.component = function(node) 17389{ 17390 this.node = node; 17391}; 17392 17393BX.ajax.component.prototype.getState = function() 17394{ 17395 var state = { 17396 'node': this.node, 17397 'title': window.document.title, 17398 'data': BX(this.node).innerHTML 17399 }; 17400 17401 var obNavChain = BX('navigation'); 17402 if (null != obNavChain) 17403 state.nav_chain = obNavChain.innerHTML; 17404 17405 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistoryGetState", [state]); 17406 17407 return state; 17408}; 17409 17410BX.ajax.component.prototype.setState = function(state) 17411{ 17412 BX(state.node).innerHTML = state.data; 17413 BX.ajax.UpdatePageTitle(state.title); 17414 17415 if (state.nav_chain) 17416 { 17417 BX.ajax.UpdatePageNavChain(state.nav_chain); 17418 } 17419 17420 BX.onCustomEvent(BX(state.node), "onComponentAjaxHistorySetState", [state]); 17421}; 17422 17423var jsAjaxHistoryContainer = { 17424 arHistory: {}, 17425 17426 put: function(hash, state) 17427 { 17428 this.arHistory[hash] = state; 17429 }, 17430 17431 get: function(hash) 17432 { 17433 return this.arHistory[hash]; 17434 } 17435}; 17436 17437 17438BX.ajax.FormData = function() 17439{ 17440 this.elements = []; 17441 this.files = []; 17442 this.features = {}; 17443 this.isSupported(); 17444 this.log('BX FormData init'); 17445}; 17446 17447BX.ajax.FormData.isSupported = function() 17448{ 17449 var f = new BX.ajax.FormData(); 17450 var result = f.features.supported; 17451 f = null; 17452 return result; 17453}; 17454 17455BX.ajax.FormData.prototype.log = function(o) 17456{ 17457 if (false) { 17458 try { 17459 if (BX.browser.IsIE()) o = JSON.stringify(o); 17460 console.log(o); 17461 } catch(e) {} 17462 } 17463}; 17464 17465BX.ajax.FormData.prototype.isSupported = function() 17466{ 17467 var f = {}; 17468 f.fileReader = (window.FileReader && window.FileReader.prototype.readAsBinaryString); 17469 f.readFormData = f.sendFormData = !!(window.FormData); 17470 f.supported = !!(f.readFormData && f.sendFormData); 17471 this.features = f; 17472 this.log('features:'); 17473 this.log(f); 17474 17475 return f.supported; 17476}; 17477 17478BX.ajax.FormData.prototype.append = function(name, value) 17479{ 17480 if (typeof(value) === 'object') { // seems to be files element 17481 this.files.push({'name': name, 'value':value}); 17482 } else { 17483 this.elements.push({'name': name, 'value':value}); 17484 } 17485}; 17486 17487BX.ajax.FormData.prototype.send = function(url, callbackOk, callbackProgress, callbackError) 17488{ 17489 this.log('FD send'); 17490 this.xhr = BX.ajax({ 17491 'method': 'POST', 17492 'dataType': 'html', 17493 'url': url, 17494 'onsuccess': callbackOk, 17495 'onfailure': callbackError, 17496 'start': false, 17497 'preparePost':false 17498 }); 17499 17500 if (callbackProgress) 17501 { 17502 this.xhr.upload.addEventListener( 17503 'progress', 17504 function(e) { 17505 if (e.lengthComputable) 17506 callbackProgress(e.loaded / (e.total || e.totalSize)); 17507 }, 17508 false 17509 ); 17510 } 17511 17512 if (this.features.readFormData && this.features.sendFormData) 17513 { 17514 var fd = new FormData(); 17515 this.log('use browser formdata'); 17516 for (var i in this.elements) 17517 { 17518 if(this.elements.hasOwnProperty(i)) 17519 fd.append(this.elements[i].name,this.elements[i].value); 17520 } 17521 for (i in this.files) 17522 { 17523 if(this.files.hasOwnProperty(i)) 17524 fd.append(this.files[i].name, this.files[i].value); 17525 } 17526 this.xhr.send(fd); 17527 } 17528 17529 return this.xhr; 17530}; 17531 17532BX.addCustomEvent('onAjaxFailure', BX.debug); 17533})(window); 17534 17535 17536 17537(function (exports,main_core) { 17538 'use strict'; 17539 17540 var LazyLoad = { 17541 observer: null, 17542 images: {}, 17543 imageStatus: { 17544 hidden: -2, 17545 error: -1, 17546 "undefined": 0, 17547 inited: 1, 17548 loaded: 2 17549 }, 17550 imageTypes: { 17551 image: 1, 17552 background: 2 17553 },
17554 initObserver: function initObserver() { 17555 this.observer = new IntersectionObserver(this.onIntersection.bind(this), { 17556 rootMargin: '20% 0% 20% 0%', 17557 threshold: 0.10 17558 }); 17559 }, 17560 onIntersection: function onIntersection(entries) { 17561 entries.forEach(function (entry) { 17562 if (entry.isIntersecting) { 17563 this.showImage(entry.target); 17564 } 17565 }.bind(this)); 17566 }, 17567 registerImage: function registerImage(id, isImageVisibleCallback, options) { 17568 if (this.observer === null) { 17569 this.initObserver(); 17570 } 17571 17572 options = options || {}; 17573 17574 if (!main_core.Type.isStringFilled(id)) { 17575 return; 17576 } 17577 17578 if (main_core.Type.isObject(this.images[id])) { 17579 return; 17580 } 17581 17582 var element = document.getElementById(id); 17583 17584 if (!main_core.Type.isDomNode(element)) { 17585 return; 17586 } 17587 17588 this.observer.observe(element); 17589 this.images[id] = { 17590 id: id, 17591 node: null, 17592 src: null, 17593 dataSrcName: options.dataSrcName || 'src', 17594 type: null, 17595 func: main_core.Type.isFunction(isImageVisibleCallback) ? isImageVisibleCallback : null, 17596 status: this.imageStatus.undefined 17597 }; 17598 }, 17599 registerImages: function registerImages(ids, isImageVisibleCallback, options) { 17600 if (main_core.Type.isArray(ids)) { 17601 for (var i = 0, length = ids.length; i < length; i++) { 17602 this.registerImage(ids[i], isImageVisibleCallback, options); 17603 } 17604 } 17605 }, 17606 showImage: function showImage(imageNode) { 17607 var imageNodeId = imageNode.id; 17608 17609 if (!main_core.Type.isStringFilled(imageNodeId)) { 17610 return; 17611 } 17612 17613 var image = this.images[imageNodeId]; 17614 17615 if (!main_core.Type.isPlainObject(image)) { 17616 return; 17617 } 17618 17619 if (image.status == this.imageStatus.undefined) { 17620 this.initImage(image); 17621 } 17622 17623 if (image.status !== this.imageStatus.inited) { 17624 return; 17625 } 17626 17627 if (!image.node || !image.node.parentNode) { 17628 image.node = null; 17629 image.status = this.imageStatus.error; 17630 return; 17631 } 17632 17633 if (image.type == this.imageTypes.image) { 17634 image.node.src = image.src; 17635 } else { 17636 image.node.style.backgroundImage = "url('" + image.src + "')"; 17637 } 17638 17639 image.node.dataset[image.dataSrcName] = ""; 17640 image.status = this.imageStatus.loaded; 17641 }, 17642 showImages: function showImages(checkOwnVisibility) { 17643 checkOwnVisibility = checkOwnVisibility !== false; 17644 17645 for (var id in this.images) { 17646 if (!this.images.hasOwnProperty(id)) { 17647 continue; 17648 } 17649 17650 var image = this.images[id]; 17651 17652 if (image.status == this.imageStatus.undefined) { 17653 this.initImage(image); 17654 } 17655 17656 if (image.status !== this.imageStatus.inited) { 17657 continue; 17658 } 17659 17660 if (!image.node || !image.node.parentNode) { 17661 image.node = null; 17662 image.status = this.imageStatus.error; 17663 continue; 17664 } 17665 17666 var isImageVisible = true; 17667 17668 if (checkOwnVisibility && main_core.Type.isFunction(image.func)) { 17669 isImageVisible = image.func(image); 17670 } 17671 17672 if (isImageVisible === true && this.isElementVisibleOnScreen(image.node)) { 17673 if (image.type == this.imageTypes.image) { 17674 image.node.src = image.src; 17675 } else { 17676 image.node.style.backgroundImage = "url('" + image.src + "')"; 17677 } 17678 17679 image.node.dataset[image.dataSrcName] = ""; 17680 image.status = this.imageStatus.loaded; 17681 } 17682 } 17683 }, 17684 initImage: function initImage(image) { 17685 image.status = this.imageStatus.error; 17686 var node = document.getElementById(image.id); 17687 17688 if (!main_core.Type.isDomNode(node)) { 17689 return; 17690 } 17691 17692 var src = node.dataset[image.dataSrcName]; 17693 17694 if (main_core.Type.isStringFilled(src)) { 17695 image.node = node; 17696 image.src = src; 17697 image.status = this.imageStatus.inited; 17698 image.type = image.node.tagName.toLowerCase() == "img" ? this.imageTypes.image : this.imageTypes.background; 17699 } 17700 }, 17701 isElementVisibleOnScreen: function isElementVisibleOnScreen(element) { 17702 var coords = this.getElementCoords(element); 17703 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 17704 var windowBottom = windowTop + document.documentElement.clientHeight; 17705 coords.bottom = coords.top + element.offsetHeight; 17706 return coords.top > windowTop && coords.top < windowBottom || // topVisible 17707 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 17708 ; 17709 }, 17710 isElementVisibleOn2Screens: function isElementVisibleOn2Screens(element) { 17711 var windowHeight = document.documentElement.clientHeight; 17712 var windowTop = window.pageYOffset || document.documentElement.scrollTop; 17713 var windowBottom = windowTop + windowHeight; 17714 var coords = this.getElementCoords(element); 17715 coords.bottom = coords.top + element.offsetHeight; 17716 windowTop -= windowHeight; 17717 windowBottom += windowHeight; 17718 return coords.top > windowTop && coords.top < windowBottom || // topVisible 17719 coords.bottom < windowBottom && coords.bottom > windowTop // bottomVisible 17720 ; 17721 }, 17722 getElementCoords: function getElementCoords(element) { 17723 var box = element.getBoundingClientRect(); 17724 return { 17725 originTop: box.top, 17726 originLeft: box.left, 17727 top: box.top + window.pageYOffset, 17728 left: box.left + window.pageXOffset 17729 }; 17730 }, 17731 onScroll: function onScroll() {}, 17732 clearImages: function clearImages() { 17733 this.images = []; 17734 } 17735 }; 17736 17737 exports.LazyLoad = LazyLoad; 17738 17739}((this.BX = this.BX || {}),BX)); 17740 17741 17742 17743(function (exports) { 17744 'use strict'; 17745 17746 var ParamBag = /*#__PURE__*/function () { 17747 function ParamBag() { 17748 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 17749 babelHelpers.classCallCheck(this, ParamBag); 17750 17751 if (!!params && babelHelpers.typeof(params) === 'object') { 17752 this.params = new Map(Object.entries(params)); 17753 } else { 17754 this.params = new Map(); 17755 } 17756 } 17757 17758 babelHelpers.createClass(ParamBag, [{ 17759 key: "getParam", 17760 value: function getParam(key) { 17761 var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 17762 17763 if (this.params.has(key)) { 17764 return this.params.get(key); 17765 } 17766 17767 return defaultValue; 17768 } 17769 }, { 17770 key: "setParam", 17771 value: function setParam(key, value) { 17772 this.params.set(key, value); 17773 } 17774 }, { 17775 key: "clear", 17776 value: function clear() { 17777 this.params.clear(); 17778 } 17779 }], [{ 17780 key: "create", 17781 value: function create() { 17782 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 17783 return new ParamBag(params); 17784 } 17785 }]); 17786 return ParamBag; 17787 }(); 17788 17789 exports.ParamBag = ParamBag; 17790 17791}((this.BX = this.BX || {}))); 17792 17793 17794 17795(function() { 17796 BX.FixFontSize = function(params) 17797 { 17798 var widthNode, computedStyles, width; 17799 17800 this.node = null; 17801 this.prevWindowSize = 0; 17802 this.prevWrapperSize = 0; 17803 this.mainWrapper = null; 17804 this.textWrapper = null; 17805 this.objList = params.objList; 17806 this.minFontSizeList = []; 17807 this.minFontSize = 0; 17808 17809 if (params.onresize) 17810 { 17811 this.prevWindowSize = window.innerWidth || document.documentElement.clientWidth; 17812 BX.bind(window, 'resize', BX.throttle(this.onResize, 350, this)); 17813 } 17814 17815 if (params.onAdaptiveResize) 17816 { 17817 widthNode = this.objList[0].scaleBy || this.objList[0].node; 17818 computedStyles = getComputedStyle(widthNode); 17819 this.prevWrapperSize = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 17820 BX.bind(window, 'resize', BX.throttle(this.onAdaptiveResize, 350, this)); 17821 } 17822 17823 this.createTestNodes(); 17824 this.decrease(); 17825 }; 17826 17827 BX.FixFontSize.prototype = 17828 { 17829 createTestNodes: function() 17830 { 17831 this.textWrapper = BX.create('div',{ 17832 style : { 17833 display : 'inline-block', 17834 whiteSpace : 'nowrap' 17835 } 17836 }); 17837 17838 this.mainWrapper = BX.create('div',{ 17839 style : { 17840 height : 0, 17841 overflow : 'hidden' 17842 }, 17843 children : [this.textWrapper] 17844 }); 17845 17846 }, 17847 insertTestNodes: function() 17848 { 17849 document.body.appendChild(this.mainWrapper); 17850 }, 17851 removeTestNodes: function() 17852 { 17853 document.body.removeChild(this.mainWrapper); 17854 }, 17855 decrease: function() 17856 { 17857 var width, 17858 fontSize, 17859 widthNode, 17860 computedStyles; 17861 17862 this.insertTestNodes(); 17863
17864 for(var i=this.objList.length-1; i>=0; i--) 17865 { 17866 widthNode = this.objList[i].scaleBy || this.objList[i].node; 17867 computedStyles = getComputedStyle(widthNode); 17868 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 17869 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 17870 17871 this.textWrapperSetStyle(this.objList[i].node); 17872 17873 if(this.textWrapperInsertText(this.objList[i].node)) 17874 { 17875 while(this.textWrapper.offsetWidth > width && fontSize > 0) 17876 { 17877 this.textWrapper.style.fontSize = --fontSize + 'px'; 17878 } 17879 17880 if(this.objList[i].smallestValue) 17881 { 17882 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 17883 17884 this.minFontSizeList.push(this.objList[i].node) 17885 } 17886 else 17887 { 17888 this.objList[i].node.style.fontSize = fontSize + 'px'; 17889 } 17890 } 17891 } 17892 17893 if(this.minFontSizeList.length > 0) 17894 this.setMinFont(); 17895 17896 this.removeTestNodes(); 17897 17898 }, 17899 increase: function() 17900 { 17901 this.insertTestNodes(); 17902 var width, 17903 fontSize, 17904 widthNode, 17905 computedStyles; 17906 17907 this.insertTestNodes(); 17908 17909 for(var i=this.objList.length-1; i>=0; i--) 17910 { 17911 widthNode = this.objList[i].scaleBy || this.objList[i].node; 17912 computedStyles = getComputedStyle(widthNode); 17913 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 17914 fontSize = parseInt(getComputedStyle(this.objList[i].node)["font-size"]); 17915 17916 this.textWrapperSetStyle(this.objList[i].node); 17917 17918 if(this.textWrapperInsertText(this.objList[i].node)) 17919 { 17920 while(this.textWrapper.offsetWidth < width && fontSize < this.objList[i].maxFontSize) 17921 { 17922 this.textWrapper.style.fontSize = ++fontSize + 'px'; 17923 } 17924 17925 fontSize--; 17926 17927 if(this.objList[i].smallestValue) 17928 { 17929 this.minFontSize = this.minFontSize ? Math.min(this.minFontSize, fontSize) : fontSize; 17930 17931 this.minFontSizeList.push(this.objList[i].node) 17932 } 17933 else 17934 { 17935 this.objList[i].node.style.fontSize = fontSize + 'px'; 17936 } 17937 } 17938 } 17939 17940 if(this.minFontSizeList.length > 0) 17941 this.setMinFont(); 17942 17943 this.removeTestNodes(); 17944 }, 17945 setMinFont : function() 17946 { 17947 for(var i = this.minFontSizeList.length-1; i>=0; i--) 17948 { 17949 this.minFontSizeList[i].style.fontSize = this.minFontSize + 'px'; 17950 } 17951 17952 this.minFontSize = 0; 17953 }, 17954 onResize : function() 17955 { 17956 var width = window.innerWidth || document.documentElement.clientWidth; 17957 17958 if(this.prevWindowSize > width) 17959 this.decrease(); 17960 17961 else if (this.prevWindowSize < width) 17962 this.increase(); 17963 17964 this.prevWindowSize = width; 17965 }, 17966 onAdaptiveResize : function() 17967 { 17968 var widthNode = this.objList[0].scaleBy || this.objList[0].node, 17969 computedStyles = getComputedStyle(widthNode), 17970 width = parseInt(computedStyles["width"]) - parseInt(computedStyles["paddingLeft"]) - parseInt(computedStyles["paddingRight"]); 17971 17972 if (this.prevWrapperSize > width) 17973 this.decrease(); 17974 else if (this.prevWrapperSize < width) 17975 this.increase(); 17976 17977 this.prevWrapperSize = width; 17978 }, 17979 textWrapperInsertText : function(node) 17980 { 17981 if(node.textContent){ 17982 this.textWrapper.textContent = node.textContent; 17983 return true; 17984 } 17985 else if(node.innerText) 17986 { 17987 this.textWrapper.innerText = node.innerText; 17988 return true; 17989 } 17990 else { 17991 return false; 17992 } 17993 }, 17994 textWrapperSetStyle : function(node) 17995 { 17996 this.textWrapper.style.fontFamily = getComputedStyle(node)["font-family"]; 17997 this.textWrapper.style.fontSize = getComputedStyle(node)["font-size"]; 17998 this.textWrapper.style.fontStyle = getComputedStyle(node)["font-style"]; 17999 this.textWrapper.style.fontWeight = getComputedStyle(node)["font-weight"]; 18000 this.textWrapper.style.lineHeight = getComputedStyle(node)["line-height"]; 18001 } 18002 }; 18003 18004 BX.FixFontSize.init = function(params) 18005 { 18006 return new BX.FixFontSize(params); 18007 }; 18008})(); 18009 18010})(); 18011//# 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.